mirror of
https://github.com/Choices-js/Choices.git
synced 2024-06-08 08:52:19 +02:00
Merge branch 'master' into feature/custom-properties
This commit is contained in:
commit
beb07ebc2c
BIN
.github/actions-scripts/__snapshots__/edge-win32.png
vendored
BIN
.github/actions-scripts/__snapshots__/edge-win32.png
vendored
Binary file not shown.
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 24 KiB |
Binary file not shown.
Before Width: | Height: | Size: 279 KiB After Width: | Height: | Size: 298 KiB |
16
README.md
16
README.md
|
@ -19,6 +19,13 @@ A vanilla, lightweight (~19kb gzipped 🎉), configurable select box/text input
|
||||||
|
|
||||||
### Interested in writing your own ES6 JavaScript plugins? Check out [ES6.io](https://ES6.io/friend/JOHNSON) for great tutorials! 💪🏼
|
### Interested in writing your own ES6 JavaScript plugins? Check out [ES6.io](https://ES6.io/friend/JOHNSON) for great tutorials! 💪🏼
|
||||||
|
|
||||||
|
### Sponsored by:
|
||||||
|
<p align="center">
|
||||||
|
<a href="https://wanderermaps.com/" target="_blank" rel="noopener noreferrer">
|
||||||
|
<img src="https://cdn.shopify.com/s/files/1/0614/3357/7715/files/Logo_BlackWithBackground_200x.png?v=1644802773" alt="Wanderer Maps logo">
|
||||||
|
</a>
|
||||||
|
</p>
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Table of Contents
|
## Table of Contents
|
||||||
|
@ -186,6 +193,7 @@ Or include Choices directly:
|
||||||
fuseOptions: {
|
fuseOptions: {
|
||||||
includeScore: true
|
includeScore: true
|
||||||
},
|
},
|
||||||
|
labelId: '',
|
||||||
callbackOnInit: null,
|
callbackOnInit: null,
|
||||||
callbackOnCreateTemplates: null
|
callbackOnCreateTemplates: null
|
||||||
});
|
});
|
||||||
|
@ -601,6 +609,14 @@ const example = new Choices(element, {
|
||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### labelId
|
||||||
|
|
||||||
|
**Type:** `String` **Default:** ``
|
||||||
|
|
||||||
|
**Input types affected:** `select-one`, `select-multiple`
|
||||||
|
|
||||||
|
**Usage:** The labelId improves accessibility. If set, it will add aria-labeledby to the choices element.
|
||||||
|
|
||||||
### classNames
|
### classNames
|
||||||
|
|
||||||
**Type:** `Object` **Default:**
|
**Type:** `Object` **Default:**
|
||||||
|
|
1128
package-lock.json
generated
1128
package-lock.json
generated
File diff suppressed because it is too large
Load diff
48
package.json
48
package.json
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "choices.js",
|
"name": "choices.js",
|
||||||
"version": "10.0.0",
|
"version": "10.1.0",
|
||||||
"description": "A vanilla JS customisable text input/select box plugin",
|
"description": "A vanilla JS customisable text input/select box plugin",
|
||||||
"main": "./public/assets/scripts/choices.js",
|
"main": "./public/assets/scripts/choices.js",
|
||||||
"types": "./public/types/src/index.d.ts",
|
"types": "./public/types/src/index.d.ts",
|
||||||
|
@ -56,27 +56,27 @@
|
||||||
"js"
|
"js"
|
||||||
],
|
],
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/core": "^7.16.7",
|
"@babel/core": "^7.17.2",
|
||||||
"@babel/preset-env": "^7.16.8",
|
"@babel/preset-env": "^7.16.11",
|
||||||
"@babel/register": "^7.16.9",
|
"@babel/register": "^7.17.0",
|
||||||
"@types/chai": "^4.3.0",
|
"@types/chai": "^4.3.0",
|
||||||
"@types/mocha": "^9.0.0",
|
"@types/mocha": "^9.1.0",
|
||||||
"@types/sinon": "^10.0.6",
|
"@types/sinon": "^10.0.11",
|
||||||
"@types/sinon-chai": "^3.2.8",
|
"@types/sinon-chai": "^3.2.8",
|
||||||
"@typescript-eslint/eslint-plugin": "^5.9.1",
|
"@typescript-eslint/eslint-plugin": "^5.11.0",
|
||||||
"@typescript-eslint/parser": "^5.9.1",
|
"@typescript-eslint/parser": "^5.11.0",
|
||||||
"autoprefixer": "^10.4.2",
|
"autoprefixer": "^10.4.2",
|
||||||
"babel-loader": "^8.2.3",
|
"babel-loader": "^8.2.3",
|
||||||
"bundlesize": "^0.18.1",
|
"bundlesize": "^0.18.1",
|
||||||
"chai": "^4.3.4",
|
"chai": "^4.3.6",
|
||||||
"cross-env": "^7.0.3",
|
"cross-env": "^7.0.3",
|
||||||
"csso-cli": "^3.0.0",
|
"csso-cli": "^3.0.0",
|
||||||
"cypress": "9.2.1",
|
"cypress": "9.4.1",
|
||||||
"eslint": "^8.6.0",
|
"eslint": "^8.9.0",
|
||||||
"eslint-config-airbnb-base": "^15.0.0",
|
"eslint-config-airbnb-base": "^15.0.0",
|
||||||
"eslint-config-airbnb-typescript": "^16.1.0",
|
"eslint-config-airbnb-typescript": "^16.1.0",
|
||||||
"eslint-config-prettier": "^8.3.0",
|
"eslint-config-prettier": "^8.3.0",
|
||||||
"eslint-plugin-compat": "4.0.1",
|
"eslint-plugin-compat": "4.0.2",
|
||||||
"eslint-plugin-cypress": "^2.12.1",
|
"eslint-plugin-cypress": "^2.12.1",
|
||||||
"eslint-plugin-import": "^2.25.4",
|
"eslint-plugin-import": "^2.25.4",
|
||||||
"eslint-plugin-prettier": "^4.0.0",
|
"eslint-plugin-prettier": "^4.0.0",
|
||||||
|
@ -85,26 +85,26 @@
|
||||||
"express": "^4.17.2",
|
"express": "^4.17.2",
|
||||||
"husky": "^7.0.4",
|
"husky": "^7.0.4",
|
||||||
"jsdom": "^19.0.0",
|
"jsdom": "^19.0.0",
|
||||||
"lint-staged": "^12.1.7",
|
"lint-staged": "^12.3.4",
|
||||||
"mocha": "^9.1.3",
|
"mocha": "^9.2.0",
|
||||||
"nodemon": "^2.0.15",
|
"nodemon": "^2.0.15",
|
||||||
"npm-run-all": "^4.1.5",
|
"npm-run-all": "^4.1.5",
|
||||||
"nyc": "^15.1.0",
|
"nyc": "^15.1.0",
|
||||||
"postcss": "^8.4.5",
|
"postcss": "^8.4.6",
|
||||||
"postcss-cli": "^9.1.0",
|
"postcss-cli": "^9.1.0",
|
||||||
"prettier": "^2.5.1",
|
"prettier": "^2.5.1",
|
||||||
"sass": "^1.48.0",
|
"sass": "^1.49.7",
|
||||||
"sinon": "^12.0.1",
|
"sinon": "^13.0.1",
|
||||||
"sinon-chai": "^3.7.0",
|
"sinon-chai": "^3.7.0",
|
||||||
"stylelint": "^14.2.0",
|
"stylelint": "^14.5.0",
|
||||||
"stylelint-config-standard": "^24.0.0",
|
"stylelint-config-standard": "^25.0.0",
|
||||||
"stylelint-config-standard-scss": "^3.0.0",
|
"stylelint-config-standard-scss": "^3.0.0",
|
||||||
"ts-loader": "^9.2.6",
|
"ts-loader": "^9.2.6",
|
||||||
"ts-node": "^10.4.0",
|
"ts-node": "^10.5.0",
|
||||||
"typescript": "^4.5.4",
|
"typescript": "^4.5.5",
|
||||||
"webpack": "^5.66.0",
|
"webpack": "^5.68.0",
|
||||||
"webpack-cli": "^4.9.1",
|
"webpack-cli": "^4.9.2",
|
||||||
"webpack-dev-middleware": "^5.3.0",
|
"webpack-dev-middleware": "^5.3.1",
|
||||||
"webpack-hot-middleware": "^2.25.1"
|
"webpack-hot-middleware": "^2.25.1"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/*! choices.js v10.0.0 | © 2022 Josh Johnson | https://github.com/jshjohnson/Choices#readme */
|
/*! choices.js v10.1.0 | © 2022 Josh Johnson | https://github.com/jshjohnson/Choices#readme */
|
||||||
(function webpackUniversalModuleDefinition(root, factory) {
|
(function webpackUniversalModuleDefinition(root, factory) {
|
||||||
if(typeof exports === 'object' && typeof module === 'object')
|
if(typeof exports === 'object' && typeof module === 'object')
|
||||||
module.exports = factory();
|
module.exports = factory();
|
||||||
|
@ -2222,7 +2222,7 @@ function () {
|
||||||
|
|
||||||
Choices.prototype._createElements = function () {
|
Choices.prototype._createElements = function () {
|
||||||
this.containerOuter = new components_1.Container({
|
this.containerOuter = new components_1.Container({
|
||||||
element: this._getTemplate('containerOuter', this._direction, this._isSelectElement, this._isSelectOneElement, this.config.searchEnabled, this.passedElement.element.type),
|
element: this._getTemplate('containerOuter', this._direction, this._isSelectElement, this._isSelectOneElement, this.config.searchEnabled, this.passedElement.element.type, this.config.labelId),
|
||||||
classNames: this.config.classNames,
|
classNames: this.config.classNames,
|
||||||
type: this.passedElement.element.type,
|
type: this.passedElement.element.type,
|
||||||
position: this.config.position
|
position: this.config.position
|
||||||
|
@ -3526,6 +3526,7 @@ exports.DEFAULT_CONFIG = {
|
||||||
fuseOptions: {
|
fuseOptions: {
|
||||||
includeScore: true
|
includeScore: true
|
||||||
},
|
},
|
||||||
|
labelId: '',
|
||||||
callbackOnInit: null,
|
callbackOnInit: null,
|
||||||
callbackOnCreateTemplates: null,
|
callbackOnCreateTemplates: null,
|
||||||
classNames: exports.DEFAULT_CLASSNAMES
|
classNames: exports.DEFAULT_CLASSNAMES
|
||||||
|
@ -4598,7 +4599,7 @@ Object.defineProperty(exports, "__esModule", ({
|
||||||
value: true
|
value: true
|
||||||
}));
|
}));
|
||||||
var templates = {
|
var templates = {
|
||||||
containerOuter: function (_a, dir, isSelectElement, isSelectOneElement, searchEnabled, passedElementType) {
|
containerOuter: function (_a, dir, isSelectElement, isSelectOneElement, searchEnabled, passedElementType, labelId) {
|
||||||
var containerOuter = _a.classNames.containerOuter;
|
var containerOuter = _a.classNames.containerOuter;
|
||||||
var div = Object.assign(document.createElement('div'), {
|
var div = Object.assign(document.createElement('div'), {
|
||||||
className: containerOuter
|
className: containerOuter
|
||||||
|
@ -4623,6 +4624,11 @@ var templates = {
|
||||||
|
|
||||||
div.setAttribute('aria-haspopup', 'true');
|
div.setAttribute('aria-haspopup', 'true');
|
||||||
div.setAttribute('aria-expanded', 'false');
|
div.setAttribute('aria-expanded', 'false');
|
||||||
|
|
||||||
|
if (labelId) {
|
||||||
|
div.setAttribute('aria-labeledby', labelId);
|
||||||
|
}
|
||||||
|
|
||||||
return div;
|
return div;
|
||||||
},
|
},
|
||||||
containerInner: function (_a) {
|
containerInner: function (_a) {
|
||||||
|
|
2
public/assets/scripts/choices.min.js
vendored
2
public/assets/scripts/choices.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -320,6 +320,14 @@
|
||||||
.choices__input:focus {
|
.choices__input:focus {
|
||||||
outline: 0;
|
outline: 0;
|
||||||
}
|
}
|
||||||
|
.choices__input::-webkit-search-decoration, .choices__input::-webkit-search-cancel-button, .choices__input::-webkit-search-results-button, .choices__input::-webkit-search-results-decoration {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
.choices__input::-ms-clear, .choices__input::-ms-reveal {
|
||||||
|
display: none;
|
||||||
|
width: 0;
|
||||||
|
height: 0;
|
||||||
|
}
|
||||||
[dir=rtl] .choices__input {
|
[dir=rtl] .choices__input {
|
||||||
padding-right: 2px;
|
padding-right: 2px;
|
||||||
padding-left: 0;
|
padding-left: 0;
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
{"version":3,"sourceRoot":"","sources":["../../../src/styles/choices.scss"],"names":[],"mappings":"AAAA;AAAA;AAAA;AA2BA;EACE;EACA;EACA,eApBkB;EAqBlB,WAxBqB;;AA0BrB;EACE;;AAGF;EACE;;AAGF;EACE;;AAIA;AAAA;EAEE,kBAlCsB;EAmCtB;EACA;;AAEF;EACE;;AAIJ;EACE;;;AAIJ;EACE;;AACA;EACE;;AAEF;EACE;EACA;EACA;EACA;EACA;EACA;;AAEF;EACE,kBApDyB;EAqDzB;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AAEA;EAEE;;AAGF;EACE;;AAGJ;EACE;;AAGF;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AAGF;EACE;EACA;;AAIA;EACE;EACA;;AAEF;EACE;EACA;EACA;EACA;;;AAOJ;AAAA;EACE;;AAEF;AAAA;EACE;EACA;EACA;EACA;EACA;EACA,aA5HoB;EA6HpB;EACA;EACA,kBA9HiB;EA+HjB,iBAjIuB;EAkIvB,OAlIuB;EAmIvB;EACA;EACA;;AAEA;AAAA;AAAA;EAEE;;;AAKN;EACE;EACA;EACA;EACA,kBA1JiB;EA2JjB;EACA;EACA,eA/JsB;EAgKtB,WAnKqB;EAoKrB;EACA;;AAEA;EAEE;;AAGF;EACE;;AAGF;EACE;;;AAIJ;EACE;EACA;EACA;;AAOF;EACE;EACA;EACA;;AAEA;EACE;EACA;;AAEF;EACE;;;AAIJ;EACE;;AACA;EACE;EACA;EACA,eA9MyB;EA+MzB;EACA,WAnNmB;EAoNnB;EACA;EACA;EACA,kBA9MoB;EA+MpB;EACA;EACA;EACA;;AAEA;EACE;;AAGF;EACE;EACA;;AAGF;EACE;EACA;;AAGF;EACE;EACA;;;AAKN;EACE;EACA,SApOgB;EAqOhB;EACA;EACA,kBAjP0B;EAkP1B;EACA;EACA;EACA,2BAzPsB;EA0PtB,4BA1PsB;EA2PtB;EACA;EACA;;AAEA;EACE;;AAGF;EACE;;AAGF;EACE;EACA;EACA;EACA;EACA;;AAEF;EACE;EACA;EACA;EACA;EACA;;AAEF;EACE;EACA;EACA,WA3RmB;;AA6RnB;EACE;;AAIF;EADF;IAEI;;EAEA;IACE;IACA,WAtSe;IAuSf;IACA;IACA;IACA;IACA;;EAGF;IACE;IACA;IACA;;EAEA;IACE;IACA;;;AAKN;EACE;;AAEA;EACE;;;AAUR;EACE;;;AAGF;EACE;;;AAGF;EACE;EACA;EACA;;;AAGF;EACE;EACA,WAxVqB;EAyVrB;EACA;EACA;;;AAGF;EACE;EACA;EACA;EACA;EACA;EACA;EACA;;AAEA;EACE;;;AAIJ;EACE;EACA;EACA,kBA3WiB;EA4WjB,WAjXqB;EAkXrB;EACA;EACA;EACA;EACA;;AAEA;EACE;;AAGF;EACE;EACA;;;AAIJ;EACE;;;AAGF","file":"choices.css"}
|
{"version":3,"sourceRoot":"","sources":["../../../src/styles/choices.scss"],"names":[],"mappings":"AAAA;AAAA;AAAA;AA2BA;EACE;EACA;EACA,eApBkB;EAqBlB,WAxBqB;;AA0BrB;EACE;;AAGF;EACE;;AAGF;EACE;;AAIA;AAAA;EAEE,kBAlCsB;EAmCtB;EACA;;AAEF;EACE;;AAIJ;EACE;;;AAIJ;EACE;;AACA;EACE;;AAEF;EACE;EACA;EACA;EACA;EACA;EACA;;AAEF;EACE,kBApDyB;EAqDzB;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AAEA;EAEE;;AAGF;EACE;;AAGJ;EACE;;AAGF;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AAGF;EACE;EACA;;AAIA;EACE;EACA;;AAEF;EACE;EACA;EACA;EACA;;;AAOJ;AAAA;EACE;;AAEF;AAAA;EACE;EACA;EACA;EACA;EACA;EACA,aA5HoB;EA6HpB;EACA;EACA,kBA9HiB;EA+HjB,iBAjIuB;EAkIvB,OAlIuB;EAmIvB;EACA;EACA;;AAEA;AAAA;AAAA;EAEE;;;AAKN;EACE;EACA;EACA;EACA,kBA1JiB;EA2JjB;EACA;EACA,eA/JsB;EAgKtB,WAnKqB;EAoKrB;EACA;;AAEA;EAEE;;AAGF;EACE;;AAGF;EACE;;;AAIJ;EACE;EACA;EACA;;AAOF;EACE;EACA;EACA;;AAEA;EACE;EACA;;AAEF;EACE;;;AAIJ;EACE;;AACA;EACE;EACA;EACA,eA9MyB;EA+MzB;EACA,WAnNmB;EAoNnB;EACA;EACA;EACA,kBA9MoB;EA+MpB;EACA;EACA;EACA;;AAEA;EACE;;AAGF;EACE;EACA;;AAGF;EACE;EACA;;AAGF;EACE;EACA;;;AAKN;EACE;EACA,SApOgB;EAqOhB;EACA;EACA,kBAjP0B;EAkP1B;EACA;EACA;EACA,2BAzPsB;EA0PtB,4BA1PsB;EA2PtB;EACA;EACA;;AAEA;EACE;;AAGF;EACE;;AAGF;EACE;EACA;EACA;EACA;EACA;;AAEF;EACE;EACA;EACA;EACA;EACA;;AAEF;EACE;EACA;EACA,WA3RmB;;AA6RnB;EACE;;AAIF;EADF;IAEI;;EAEA;IACE;IACA,WAtSe;IAuSf;IACA;IACA;IACA;IACA;;EAGF;IACE;IACA;IACA;;EAEA;IACE;IACA;;;AAKN;EACE;;AAEA;EACE;;;AAUR;EACE;;;AAGF;EACE;;;AAGF;EACE;EACA;EACA;;;AAGF;EACE;EACA,WAxVqB;EAyVrB;EACA;EACA;;;AAGF;EACE;EACA;EACA;EACA;EACA;EACA;EACA;;AAEA;EACE;;;AAIJ;EACE;EACA;EACA,kBA3WiB;EA4WjB,WAjXqB;EAkXrB;EACA;EACA;EACA;EACA;;AAEA;EACE;;AAGF;EAIE;;AAGF;EAEE;EACA;EACA;;AAGF;EACE;EACA;;;AAIJ;EACE;;;AAGF","file":"choices.css"}
|
2
public/assets/styles/choices.min.css
vendored
2
public/assets/styles/choices.min.css
vendored
File diff suppressed because one or more lines are too long
|
@ -96,6 +96,13 @@
|
||||||
tutorials! 💪🏼</strong
|
tutorials! 💪🏼</strong
|
||||||
>
|
>
|
||||||
</p>
|
</p>
|
||||||
|
<p class="h4 text-center">
|
||||||
|
<strong>Sponsored by:</strong>
|
||||||
|
<br />
|
||||||
|
<a href="https://wanderermaps.com/" target="_blank" rel="noopener noreferrer">
|
||||||
|
<img src="https://cdn.shopify.com/s/files/1/0614/3357/7715/files/Logo_BlackWithBackground_150x.png?v=1644802773" alt="Wanderer Maps logo">
|
||||||
|
</a>
|
||||||
|
</p>
|
||||||
<hr />
|
<hr />
|
||||||
|
|
||||||
<h2>Text inputs</h2>
|
<h2>Text inputs</h2>
|
||||||
|
@ -288,7 +295,9 @@
|
||||||
<hr />
|
<hr />
|
||||||
|
|
||||||
<h2>Single select input</h2>
|
<h2>Single select input</h2>
|
||||||
<label for="choices-single-default">Default</label>
|
<label id="choices-single-default-label" for="choices-single-default"
|
||||||
|
>Default</label
|
||||||
|
>
|
||||||
<select
|
<select
|
||||||
class="form-control"
|
class="form-control"
|
||||||
data-trigger
|
data-trigger
|
||||||
|
@ -433,7 +442,11 @@
|
||||||
>
|
>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<label for="choices-single-no-sorting">Options without sorting</label>
|
<label
|
||||||
|
id="choices-single-no-sorting-label"
|
||||||
|
for="choices-single-no-sorting"
|
||||||
|
>Options without sorting</label
|
||||||
|
>
|
||||||
<select
|
<select
|
||||||
class="form-control"
|
class="form-control"
|
||||||
name="choices-single-no-sorting"
|
name="choices-single-no-sorting"
|
||||||
|
@ -802,6 +815,7 @@
|
||||||
var singleNoSorting = new Choices('#choices-single-no-sorting', {
|
var singleNoSorting = new Choices('#choices-single-no-sorting', {
|
||||||
allowHTML: true,
|
allowHTML: true,
|
||||||
shouldSort: false,
|
shouldSort: false,
|
||||||
|
labelId: 'choices-single-no-sorting-label',
|
||||||
});
|
});
|
||||||
|
|
||||||
var cities = new Choices(document.getElementById('cities'), { allowHTML: true });
|
var cities = new Choices(document.getElementById('cities'), { allowHTML: true });
|
||||||
|
|
2
public/types/src/scripts/choices.d.ts
vendored
2
public/types/src/scripts/choices.d.ts
vendored
|
@ -66,7 +66,7 @@ declare class Choices implements Choices {
|
||||||
hideDropdown(preventInputBlur?: boolean): this;
|
hideDropdown(preventInputBlur?: boolean): this;
|
||||||
getValue(valueOnly?: boolean): string[] | Item[] | Item | string;
|
getValue(valueOnly?: boolean): string[] | Item[] | Item | string;
|
||||||
setValue(items: string[] | Item[]): this;
|
setValue(items: string[] | Item[]): this;
|
||||||
setChoiceByValue(value: string): this;
|
setChoiceByValue(value: string | string[]): this;
|
||||||
/**
|
/**
|
||||||
* Set choices of select input via an array of objects (or function that returns array of object or promise of it),
|
* Set choices of select input via an array of objects (or function that returns array of object or promise of it),
|
||||||
* a value field name and a label field name.
|
* a value field name and a label field name.
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1 +1 @@
|
||||||
{"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../../../../src/scripts/defaults.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAG/C,eAAO,MAAM,kBAAkB,EAAE,UA2BhC,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,OA8C5B,CAAC"}
|
{"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../../../../src/scripts/defaults.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAG/C,eAAO,MAAM,kBAAkB,EAAE,UA2BhC,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,OA+C5B,CAAC"}
|
|
@ -411,6 +411,10 @@ export interface Options {
|
||||||
* Choices uses the great Fuse library for searching. You can find more options here: https://fusejs.io/api/options.html
|
* Choices uses the great Fuse library for searching. You can find more options here: https://fusejs.io/api/options.html
|
||||||
*/
|
*/
|
||||||
fuseOptions: Fuse.IFuseOptions<Choices>;
|
fuseOptions: Fuse.IFuseOptions<Choices>;
|
||||||
|
/**
|
||||||
|
* ID of the connected label to improve a11y. If set, aria-labeledby will be added.
|
||||||
|
*/
|
||||||
|
labelId: string;
|
||||||
/**
|
/**
|
||||||
* Function to run once Choices initialises.
|
* Function to run once Choices initialises.
|
||||||
*
|
*
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../../../../src/scripts/interfaces/options.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC;;;;;;;;GAQG;AACH,MAAM,WAAW,OAAO;IACtB;;;;;;OAMG;IACH,MAAM,EAAE,OAAO,CAAC;IAEhB;;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ACH,WAAW,EAAE,MAAM,CAAC;IAEpB;;;;;;OAMG;IACH,aAAa,EAAE,MAAM,GAAG,KAAK,CAAC,cAAc,CAAC;IAE7C;;;;;;OAMG;IACH,aAAa,EAAE,MAAM,GAAG,KAAK,CAAC,cAAc,CAAC;IAE7C;;;;;;OAMG;IACH,cAAc,EAAE,MAAM,CAAC;IAEvB;;;;;;;;;OASG;IACH,WAAW,EAAE,MAAM,GAAG,KAAK,CAAC,mBAAmB,CAAC;IAEhD;;;;OAIG;IACH,cAAc,EAAE,MAAM,GAAG,KAAK,CAAC,oBAAoB,CAAC;IAEpD;;;;;;OAMG;IACH,iBAAiB,EAAE,MAAM,GAAG,KAAK,CAAC,oBAAoB,CAAC;IAEvD;;;;;;;;;OASG;IACH,aAAa,EAAE,KAAK,CAAC,oBAAoB,CAAC;IAE1C;;;;OAIG;IACH,UAAU,EAAE,UAAU,CAAC;IAEvB;;OAEG;IACH,WAAW,EAAE,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;IAExC;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;;;;;;;OAQG;IACH,cAAc,EAAE,CAAC,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC,GAAG,IAAI,CAAC;IAEjD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAiCG;IACH,yBAAyB,EAAE,CAAC,CAAC,QAAQ,EAAE,KAAK,CAAC,OAAO,KAAK,IAAI,CAAC,GAAG,IAAI,CAAC;CACvE"}
|
2
public/types/src/scripts/templates.d.ts
vendored
2
public/types/src/scripts/templates.d.ts
vendored
|
@ -8,7 +8,7 @@ import { Item } from './interfaces/item';
|
||||||
import { PassedElementType } from './interfaces/passed-element-type';
|
import { PassedElementType } from './interfaces/passed-element-type';
|
||||||
declare type TemplateOptions = Record<'classNames' | 'allowHTML', any>;
|
declare type TemplateOptions = Record<'classNames' | 'allowHTML', any>;
|
||||||
declare const templates: {
|
declare const templates: {
|
||||||
containerOuter({ classNames: { containerOuter } }: TemplateOptions, dir: HTMLElement['dir'], isSelectElement: boolean, isSelectOneElement: boolean, searchEnabled: boolean, passedElementType: PassedElementType): HTMLDivElement;
|
containerOuter({ classNames: { containerOuter } }: TemplateOptions, dir: HTMLElement['dir'], isSelectElement: boolean, isSelectOneElement: boolean, searchEnabled: boolean, passedElementType: PassedElementType, labelId: string): HTMLDivElement;
|
||||||
containerInner({ classNames: { containerInner }, }: TemplateOptions): HTMLDivElement;
|
containerInner({ classNames: { containerInner }, }: TemplateOptions): HTMLDivElement;
|
||||||
itemList({ classNames: { list, listSingle, listItems } }: TemplateOptions, isSelectOneElement: boolean): HTMLDivElement;
|
itemList({ classNames: { list, listSingle, listItems } }: TemplateOptions, isSelectOneElement: boolean): HTMLDivElement;
|
||||||
placeholder({ allowHTML, classNames: { placeholder } }: TemplateOptions, value: string): HTMLDivElement;
|
placeholder({ allowHTML, classNames: { placeholder } }: TemplateOptions, value: string): HTMLDivElement;
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
{"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../../../../src/scripts/templates.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAGrE,aAAK,eAAe,GAAG,MAAM,CAAC,YAAY,GAAG,WAAW,EAAE,GAAG,CAAC,CAAC;AAE/D,QAAA,MAAM,SAAS;uDAEyB,eAAe,OAC9C,WAAW,CAAC,KAAK,CAAC,mBACN,OAAO,sBACJ,OAAO,iBACZ,OAAO,qBACH,iBAAiB,GACnC,cAAc;wDA8Bd,eAAe,GAAG,cAAc;8DAOgB,eAAe,sBAC5C,OAAO,GAC1B,cAAc;4DAO6B,eAAe,SAC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Ac;kDAqCyB,eAAe,oBACrC,MAAM,GACvB,gBAAgB;sDAmBhB,eAAe,GAAG,cAAc;mFAa9B,eAAe,aACP,MAAM,SACX,YAAY,GAAG,YAAY,GAAG,EAAE,GACrC,cAAc;kEAqBd,IAAI,GAAG,iBAAiB;CAW5B,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
|
@ -553,7 +553,7 @@ class Choices implements Choices {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
setChoiceByValue(value: string): this {
|
setChoiceByValue(value: string | string[]): this {
|
||||||
if (!this.initialised || this._isTextElement) {
|
if (!this.initialised || this._isTextElement) {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -2140,6 +2140,7 @@ class Choices implements Choices {
|
||||||
this._isSelectOneElement,
|
this._isSelectOneElement,
|
||||||
this.config.searchEnabled,
|
this.config.searchEnabled,
|
||||||
this.passedElement.element.type,
|
this.passedElement.element.type,
|
||||||
|
this.config.labelId,
|
||||||
),
|
),
|
||||||
classNames: this.config.classNames,
|
classNames: this.config.classNames,
|
||||||
type: this.passedElement.element.type as PassedElement['type'],
|
type: this.passedElement.element.type as PassedElement['type'],
|
||||||
|
|
|
@ -74,6 +74,7 @@ export const DEFAULT_CONFIG: Options = {
|
||||||
fuseOptions: {
|
fuseOptions: {
|
||||||
includeScore: true,
|
includeScore: true,
|
||||||
},
|
},
|
||||||
|
labelId: '',
|
||||||
callbackOnInit: null,
|
callbackOnInit: null,
|
||||||
callbackOnCreateTemplates: null,
|
callbackOnCreateTemplates: null,
|
||||||
classNames: DEFAULT_CLASSNAMES,
|
classNames: DEFAULT_CLASSNAMES,
|
||||||
|
|
|
@ -453,6 +453,11 @@ export interface Options {
|
||||||
*/
|
*/
|
||||||
fuseOptions: Fuse.IFuseOptions<Choices>;
|
fuseOptions: Fuse.IFuseOptions<Choices>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ID of the connected label to improve a11y. If set, aria-labeledby will be added.
|
||||||
|
*/
|
||||||
|
labelId: string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function to run once Choices initialises.
|
* Function to run once Choices initialises.
|
||||||
*
|
*
|
||||||
|
|
|
@ -52,6 +52,7 @@ describe('templates', () => {
|
||||||
const isSelectOneElement = false;
|
const isSelectOneElement = false;
|
||||||
const searchEnabled = true;
|
const searchEnabled = true;
|
||||||
const passedElementType = 'select-multiple';
|
const passedElementType = 'select-multiple';
|
||||||
|
const labelId = '';
|
||||||
|
|
||||||
const expectedOutput = strToEl(`
|
const expectedOutput = strToEl(`
|
||||||
<div
|
<div
|
||||||
|
@ -72,6 +73,41 @@ describe('templates', () => {
|
||||||
isSelectOneElement,
|
isSelectOneElement,
|
||||||
searchEnabled,
|
searchEnabled,
|
||||||
passedElementType,
|
passedElementType,
|
||||||
|
labelId,
|
||||||
|
);
|
||||||
|
expectEqualElements(actualOutput, expectedOutput);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('with label id for a11y', () => {
|
||||||
|
it('returns expected html', () => {
|
||||||
|
const isSelectElement = true;
|
||||||
|
const isSelectOneElement = true;
|
||||||
|
const searchEnabled = false;
|
||||||
|
const passedElementType = 'select-one';
|
||||||
|
const labelId = 'testLabelId';
|
||||||
|
|
||||||
|
const expectedOutput = strToEl(`
|
||||||
|
<div
|
||||||
|
class="${options.classNames.containerOuter}"
|
||||||
|
data-type="${passedElementType}"
|
||||||
|
role="listbox"
|
||||||
|
tabindex="0"
|
||||||
|
aria-haspopup="true"
|
||||||
|
aria-expanded="false"
|
||||||
|
aria-labeledby="${labelId}"
|
||||||
|
dir="${direction}"
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
`);
|
||||||
|
const actualOutput = templates.containerOuter(
|
||||||
|
options,
|
||||||
|
direction,
|
||||||
|
isSelectElement,
|
||||||
|
isSelectOneElement,
|
||||||
|
searchEnabled,
|
||||||
|
passedElementType,
|
||||||
|
labelId,
|
||||||
);
|
);
|
||||||
expectEqualElements(actualOutput, expectedOutput);
|
expectEqualElements(actualOutput, expectedOutput);
|
||||||
});
|
});
|
||||||
|
@ -83,6 +119,7 @@ describe('templates', () => {
|
||||||
const isSelectOneElement = false;
|
const isSelectOneElement = false;
|
||||||
const searchEnabled = false;
|
const searchEnabled = false;
|
||||||
const passedElementType = 'select-multiple';
|
const passedElementType = 'select-multiple';
|
||||||
|
const labelId = '';
|
||||||
|
|
||||||
const expectedOutput = strToEl(`
|
const expectedOutput = strToEl(`
|
||||||
<div
|
<div
|
||||||
|
@ -102,6 +139,7 @@ describe('templates', () => {
|
||||||
isSelectOneElement,
|
isSelectOneElement,
|
||||||
searchEnabled,
|
searchEnabled,
|
||||||
passedElementType,
|
passedElementType,
|
||||||
|
labelId,
|
||||||
);
|
);
|
||||||
|
|
||||||
expectEqualElements(actualOutput, expectedOutput);
|
expectEqualElements(actualOutput, expectedOutput);
|
||||||
|
@ -114,6 +152,7 @@ describe('templates', () => {
|
||||||
const isSelectOneElement = true;
|
const isSelectOneElement = true;
|
||||||
const searchEnabled = false;
|
const searchEnabled = false;
|
||||||
const passedElementType = 'select-one';
|
const passedElementType = 'select-one';
|
||||||
|
const labelId = '';
|
||||||
|
|
||||||
const expectedOutput = strToEl(`
|
const expectedOutput = strToEl(`
|
||||||
<div
|
<div
|
||||||
|
@ -134,6 +173,7 @@ describe('templates', () => {
|
||||||
isSelectOneElement,
|
isSelectOneElement,
|
||||||
searchEnabled,
|
searchEnabled,
|
||||||
passedElementType,
|
passedElementType,
|
||||||
|
labelId,
|
||||||
);
|
);
|
||||||
|
|
||||||
expectEqualElements(actualOutput, expectedOutput);
|
expectEqualElements(actualOutput, expectedOutput);
|
||||||
|
@ -147,6 +187,7 @@ describe('templates', () => {
|
||||||
const isSelectOneElement = false;
|
const isSelectOneElement = false;
|
||||||
const searchEnabled = false;
|
const searchEnabled = false;
|
||||||
const passedElementType = 'text';
|
const passedElementType = 'text';
|
||||||
|
const labelId = '';
|
||||||
|
|
||||||
const expectedOutput = strToEl(`
|
const expectedOutput = strToEl(`
|
||||||
<div
|
<div
|
||||||
|
@ -165,6 +206,7 @@ describe('templates', () => {
|
||||||
isSelectOneElement,
|
isSelectOneElement,
|
||||||
searchEnabled,
|
searchEnabled,
|
||||||
passedElementType,
|
passedElementType,
|
||||||
|
labelId,
|
||||||
);
|
);
|
||||||
|
|
||||||
expectEqualElements(actualOutput, expectedOutput);
|
expectEqualElements(actualOutput, expectedOutput);
|
||||||
|
|
|
@ -19,6 +19,7 @@ const templates = {
|
||||||
isSelectOneElement: boolean,
|
isSelectOneElement: boolean,
|
||||||
searchEnabled: boolean,
|
searchEnabled: boolean,
|
||||||
passedElementType: PassedElementType,
|
passedElementType: PassedElementType,
|
||||||
|
labelId: string,
|
||||||
): HTMLDivElement {
|
): HTMLDivElement {
|
||||||
const div = Object.assign(document.createElement('div'), {
|
const div = Object.assign(document.createElement('div'), {
|
||||||
className: containerOuter,
|
className: containerOuter,
|
||||||
|
@ -43,6 +44,9 @@ const templates = {
|
||||||
|
|
||||||
div.setAttribute('aria-haspopup', 'true');
|
div.setAttribute('aria-haspopup', 'true');
|
||||||
div.setAttribute('aria-expanded', 'false');
|
div.setAttribute('aria-expanded', 'false');
|
||||||
|
if (labelId) {
|
||||||
|
div.setAttribute('aria-labeledby', labelId);
|
||||||
|
}
|
||||||
|
|
||||||
return div;
|
return div;
|
||||||
},
|
},
|
||||||
|
|
|
@ -386,6 +386,20 @@ $choices-z-index: 1;
|
||||||
outline: 0;
|
outline: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&::-webkit-search-decoration,
|
||||||
|
&::-webkit-search-cancel-button,
|
||||||
|
&::-webkit-search-results-button,
|
||||||
|
&::-webkit-search-results-decoration {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
&::-ms-clear,
|
||||||
|
&::-ms-reveal {
|
||||||
|
display: none;
|
||||||
|
width: 0;
|
||||||
|
height: 0;
|
||||||
|
}
|
||||||
|
|
||||||
[dir="rtl"] & {
|
[dir="rtl"] & {
|
||||||
padding-right: 2px;
|
padding-right: 2px;
|
||||||
padding-left: 0;
|
padding-left: 0;
|
||||||
|
|
Loading…
Reference in a new issue