diff --git a/README.md b/README.md index b506fc9..39c13b2 100644 --- a/README.md +++ b/README.md @@ -107,25 +107,28 @@ Or include Choices directly: itemSelectable: 'choices__item--selectable', itemDisabled: 'choices__item--disabled', itemChoice: 'choices__item--choice', + placeholder: 'choices__placeholder', group: 'choices__group', - groupHeading : 'choices__heading', + groupHeading: 'choices__heading', button: 'choices__button', activeState: 'is-active', focusState: 'is-focused', openState: 'is-open', - disabledState: 'is-disabled', + disabledState: 'is-disaqbled', highlightedState: 'is-highlighted', hiddenState: 'is-hidden', flippedState: 'is-flipped', loadingState: 'is-loading', + noResults: 'has-no-results', + noChoices: 'has-no-choices' }, // Choices uses the great Fuse library for searching. You // can find more options here: https://github.com/krisk/Fuse#options fuseOptions: { - include: 'score', + include: 'score' }, callbackOnInit: null, - callbackOnCreateTemplates: null, + callbackOnCreateTemplates: null }); ``` diff --git a/assets/scripts/src/choices.js b/assets/scripts/src/choices.js index 16b95c3..93df458 100644 --- a/assets/scripts/src/choices.js +++ b/assets/scripts/src/choices.js @@ -115,12 +115,14 @@ class Choices { hiddenState: 'is-hidden', flippedState: 'is-flipped', loadingState: 'is-loading', + noResults: 'has-no-results', + noChoices: 'has-no-choices' }, fuseOptions: { - include: 'score', + include: 'score' }, callbackOnInit: null, - callbackOnCreateTemplates: null, + callbackOnCreateTemplates: null }; this.idNames = { @@ -534,13 +536,13 @@ class Choices { this.config.noResultsText() : this.config.noResultsText; - dropdownItem = this._getTemplate('notice', notice); + dropdownItem = this._getTemplate('notice', notice, 'no-results'); } else { notice = isType('Function', this.config.noChoicesText) ? this.config.noChoicesText() : this.config.noChoicesText; - dropdownItem = this._getTemplate('notice', notice); + dropdownItem = this._getTemplate('notice', notice, 'no-choices'); } this.choiceList.appendChild(dropdownItem); @@ -2655,10 +2657,14 @@ class Choices { `); }, - notice: (label) => { + notice: (label, type) => { let localClasses = classNames( globalClasses.item, - globalClasses.itemChoice + globalClasses.itemChoice, + { + [globalClasses.noResults]: (type === 'no-results'), + [globalClasses.noChoices]: (type === 'no-choices'), + } ); return strToEl(`