From b0911cdfd3e7b5ee87ab18aa3848af395fe0beaf Mon Sep 17 00:00:00 2001 From: Xon Date: Mon, 5 Jan 2026 02:56:50 +0000 Subject: [PATCH] deploy: d76abba36216c6c17d4776f98e97c031e033277d --- assets/images/logo--dark.svg | 10 + assets/scripts/choices.js | 241 +++++++++++------- assets/scripts/choices.min.js | 4 +- assets/scripts/choices.mjs | 241 +++++++++++------- assets/scripts/choices.search-basic.js | 238 ++++++++++------- assets/scripts/choices.search-basic.min.js | 4 +- assets/scripts/choices.search-basic.mjs | 238 ++++++++++------- assets/scripts/choices.search-kmp.js | 224 ++++++++++------ assets/scripts/choices.search-kmp.min.js | 4 +- assets/scripts/choices.search-kmp.mjs | 224 ++++++++++------ assets/scripts/choices.search-prefix.js | 221 ++++++++++------ assets/scripts/choices.search-prefix.min.js | 4 +- assets/scripts/choices.search-prefix.mjs | 221 ++++++++++------ assets/styles/base.css | 48 +++- assets/styles/base.css.map | 2 +- assets/styles/base.min.css | 2 +- assets/styles/choices.css | 186 +++++++------- assets/styles/choices.css.map | 2 +- assets/styles/choices.min.css | 2 +- index.html | 67 +++-- types/src/scripts/choices.d.ts | 11 + types/src/scripts/components/container.d.ts | 2 + types/src/scripts/interfaces/choice-full.d.ts | 3 +- types/src/scripts/interfaces/class-names.d.ts | 2 + .../src/scripts/interfaces/input-choice.d.ts | 3 +- types/src/scripts/interfaces/options.d.ts | 22 +- types/src/scripts/interfaces/store.d.ts | 3 +- types/src/scripts/interfaces/types.d.ts | 3 +- types/src/scripts/lib/utils.d.ts | 4 +- 29 files changed, 1409 insertions(+), 827 deletions(-) create mode 100644 assets/images/logo--dark.svg diff --git a/assets/images/logo--dark.svg b/assets/images/logo--dark.svg new file mode 100644 index 00000000..c6708dc5 --- /dev/null +++ b/assets/images/logo--dark.svg @@ -0,0 +1,10 @@ + + + + Slice 1 + Created with Sketch. + + + + + \ No newline at end of file diff --git a/assets/scripts/choices.js b/assets/scripts/choices.js index 9a0a9367..b2581975 100644 --- a/assets/scripts/choices.js +++ b/assets/scripts/choices.js @@ -1,4 +1,4 @@ -/*! choices.js v11.1.0 | © 2025 Josh Johnson | https://github.com/jshjohnson/Choices#readme */ +/*! choices.js v11.2.0 | © 2026 Josh Johnson | https://github.com/jshjohnson/Choices#readme */ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : @@ -217,9 +217,6 @@ return firstChild; }; })(); - var resolveNoticeFunction = function (fn, value) { - return typeof fn === 'function' ? fn(sanitise(value), value) : fn; - }; var resolveStringFunction = function (fn) { return typeof fn === 'function' ? fn() : fn; }; @@ -251,6 +248,26 @@ } return ''; }; + var getChoiceForOutput = function (choice, keyCode) { + return { + id: choice.id, + highlighted: choice.highlighted, + labelClass: choice.labelClass, + labelDescription: unwrapStringForRaw(choice.labelDescription), + customProperties: choice.customProperties, + disabled: choice.disabled, + active: choice.active, + label: choice.label, + placeholder: choice.placeholder, + value: choice.value, + groupValue: choice.group ? choice.group.label : undefined, + element: choice.element, + keyCode: keyCode, + }; + }; + var resolveNoticeFunction = function (fn, value, item) { + return typeof fn === 'function' ? fn(sanitise(value), unwrapStringForRaw(value), item) : fn; + }; var escapeForTemplate = function (allowHTML, s) { return allowHTML ? unwrapStringForEscaped(s) : sanitise(s); }; @@ -418,6 +435,12 @@ Container.prototype.removeFocusState = function () { removeClassesFromElement(this.element, this.classNames.focusState); }; + Container.prototype.addInvalidState = function () { + addClassesToElement(this.element, this.classNames.invalidState); + }; + Container.prototype.removeInvalidState = function () { + removeClassesFromElement(this.element, this.classNames.invalidState); + }; Container.prototype.enable = function () { removeClassesFromElement(this.element, this.classNames.disabledState); this.element.removeAttribute('aria-disabled'); @@ -883,7 +906,9 @@ highlighted: false, placeholder: this.extractPlaceholder && (!option.value || option.hasAttribute('placeholder')), labelClass: typeof option.dataset.labelClass !== 'undefined' ? stringToHtmlClass(option.dataset.labelClass) : undefined, - labelDescription: typeof option.dataset.labelDescription !== 'undefined' ? option.dataset.labelDescription : undefined, + labelDescription: typeof option.dataset.labelDescription !== 'undefined' + ? { trusted: option.dataset.labelDescription } + : undefined, customProperties: parseCustomProperties(option.dataset.customProperties), }; }; @@ -929,6 +954,7 @@ selectedState: ['is-selected'], flippedState: ['is-flipped'], loadingState: ['is-loading'], + invalidState: ['is-invalid'], notice: ['choices__notice'], addChoice: ['choices__item--selectable', 'add-choice'], noResults: ['has-no-results'], @@ -956,6 +982,7 @@ paste: true, searchEnabled: true, searchChoices: true, + searchDisabledChoices: false, searchFloor: 1, searchResultLimit: 4, searchFields: ['label', 'value'], @@ -971,6 +998,7 @@ prependValue: null, appendValue: null, renderSelectedChoices: 'auto', + searchRenderSelectedChoices: true, loadingText: 'Loading...', noResultsText: 'No results found', noChoicesText: 'No choices to choose from', @@ -979,7 +1007,9 @@ customAddItemText: 'Only values matching specific conditions can be added', addItemText: function (value) { return "Press Enter to add \"".concat(value, "\""); }, removeItemIconText: function () { return "Remove item"; }, - removeItemLabelText: function (value) { return "Remove item: ".concat(value); }, + removeItemLabelText: function (value, _valueRaw, i) { + return "Remove item: ".concat(i ? sanitise(i.label) : value); + }, maxItemText: function (maxItemCount) { return "Only ".concat(maxItemCount, " values can be added"); }, valueComparer: function (value1, value2) { return value1 === value2; }, fuseOptions: { @@ -1280,7 +1310,8 @@ * Get choices that can be searched (excluding placeholders or disabled choices) */ get: function () { - return this.choices.filter(function (choice) { return !choice.disabled && !choice.placeholder; }); + var context = this._context; + return this.choices.filter(function (choice) { return !choice.placeholder && (context.searchDisabledChoices || !choice.disabled); }); }, enumerable: false, configurable: true @@ -1338,9 +1369,9 @@ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, - enumerable: !0, - configurable: !0, - writable: !0 + enumerable: true, + configurable: true, + writable: true }) : e[r] = t, e; } function ownKeys(e, r) { @@ -1356,7 +1387,7 @@ function _objectSpread2(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; - r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { + r % 2 ? ownKeys(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); @@ -1368,7 +1399,7 @@ if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { - var i = e.call(t, r || "default"); + var i = e.call(t, r); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } @@ -1391,16 +1422,13 @@ function isArray(value) { return !Array.isArray ? getTag(value) === '[object Array]' : Array.isArray(value); } - - // Adapted from: https://github.com/lodash/lodash/blob/master/.internal/baseToString.js - const INFINITY = 1 / 0; function baseToString(value) { // Exit early for strings to avoid a performance hit in some environments. if (typeof value == 'string') { return value; } let result = value + ''; - return result == '0' && 1 / value == -INFINITY ? '-0' : result; + return result == '0' && 1 / value == -Infinity ? '-0' : result; } function toString(value) { return value == null ? '' : baseToString(value); @@ -1436,7 +1464,6 @@ function getTag(value) { return value == null ? value === undefined ? '[object Undefined]' : '[object Null]' : Object.prototype.toString.call(value); } - const EXTENDED_SEARCH_UNAVAILABLE = 'Extended search is not available'; const INCORRECT_INDEX_TYPE = "Incorrect 'index' type"; const LOGICAL_SEARCH_INVALID_QUERY_FOR_KEY = key => `Invalid value for key ${key}`; const PATTERN_LENGTH_TOO_LARGE = max => `Pattern length exceeds max of ${max}.`; @@ -2690,9 +2717,7 @@ class Fuse { constructor(docs, options = {}, index) { this.options = _objectSpread2(_objectSpread2({}, Config), options); - if (this.options.useExtendedSearch && !true) { - throw new Error(EXTENDED_SEARCH_UNAVAILABLE); - } + if (this.options.useExtendedSearch && false) ; this._keyStore = new KeyStore(this.options.keys); this.setCollection(docs, index); } @@ -3024,7 +3049,7 @@ dataset.labelClass = getClassNames(labelClass).join(' '); } if (labelDescription) { - dataset.labelDescription = labelDescription; + dataset.labelDescription = unwrapStringForRaw(labelDescription); } if (withCustomProperties && customProperties) { if (typeof customProperties === 'string') { @@ -3131,8 +3156,9 @@ var removeButton = document.createElement('button'); removeButton.type = 'button'; addClassesToElement(removeButton, button); - setElementHtml(removeButton, true, resolveNoticeFunction(removeItemIconText, choice.value)); - var REMOVE_ITEM_LABEL = resolveNoticeFunction(removeItemLabelText, choice.value); + var eventChoice = getChoiceForOutput(choice); + setElementHtml(removeButton, true, resolveNoticeFunction(removeItemIconText, choice.value, eventChoice)); + var REMOVE_ITEM_LABEL = resolveNoticeFunction(removeItemLabelText, choice.value, eventChoice); if (REMOVE_ITEM_LABEL) { removeButton.setAttribute('aria-label', REMOVE_ITEM_LABEL); } @@ -3237,6 +3263,7 @@ else { addClassesToElement(div, itemSelectable); div.dataset.choiceSelectable = ''; + div.setAttribute('aria-selected', choice.selected ? 'true' : 'false'); } return div; }, @@ -3406,7 +3433,7 @@ this.initialised = false; this._store = new Store(config); this._currentValue = ''; - config.searchEnabled = (!isText && config.searchEnabled) || isSelectMultiple; + config.searchEnabled = !isText && config.searchEnabled; this._canSearch = config.searchEnabled; this._isScrollingOnIe = false; this._highlightPosition = 0; @@ -3446,6 +3473,8 @@ this._onEscapeKey = this._onEscapeKey.bind(this); this._onDirectionKey = this._onDirectionKey.bind(this); this._onDeleteKey = this._onDeleteKey.bind(this); + this._onChange = this._onChange.bind(this); + this._onInvalid = this._onInvalid.bind(this); // If element has already been initialised with Choices, fail silently if (this.passedElement.isActive) { if (!config.silent) { @@ -3552,7 +3581,7 @@ } this._store.dispatch(highlightItem(choice, true)); if (runEvent) { - this.passedElement.triggerEvent(EventType.highlightItem, this._getChoiceForOutput(choice)); + this.passedElement.triggerEvent(EventType.highlightItem, getChoiceForOutput(choice)); } return this; }; @@ -3567,7 +3596,7 @@ } this._store.dispatch(highlightItem(choice, false)); if (runEvent) { - this.passedElement.triggerEvent(EventType.unhighlightItem, this._getChoiceForOutput(choice)); + this.passedElement.triggerEvent(EventType.unhighlightItem, getChoiceForOutput(choice)); } return this; }; @@ -3577,7 +3606,7 @@ _this._store.items.forEach(function (item) { if (!item.highlighted) { _this._store.dispatch(highlightItem(item, true)); - _this.passedElement.triggerEvent(EventType.highlightItem, _this._getChoiceForOutput(item)); + _this.passedElement.triggerEvent(EventType.highlightItem, getChoiceForOutput(item)); } }); }); @@ -3589,7 +3618,7 @@ _this._store.items.forEach(function (item) { if (item.highlighted) { _this._store.dispatch(highlightItem(item, false)); - _this.passedElement.triggerEvent(EventType.highlightItem, _this._getChoiceForOutput(item)); + _this.passedElement.triggerEvent(EventType.highlightItem, getChoiceForOutput(item)); } }); }); @@ -3644,6 +3673,11 @@ _this.input.focus(); } _this.passedElement.triggerEvent(EventType.showDropdown); + var activeElement = _this.choiceList.element.querySelector(getClassNamesSelector(_this.config.classNames.selectedState)); + if (activeElement !== null && !isScrolledIntoView(activeElement, _this.choiceList.element)) { + // We use the native scrollIntoView function instead of choiceList.scrollToChildElement to avoid animated scroll. + activeElement.scrollIntoView(); + } }); return this; }; @@ -3652,6 +3686,7 @@ if (!this.dropdown.isActive) { return this; } + this._removeHighlightedChoices(); requestAnimationFrame(function () { _this.dropdown.hide(); _this.containerOuter.close(); @@ -3664,9 +3699,8 @@ return this; }; Choices.prototype.getValue = function (valueOnly) { - var _this = this; var values = this._store.items.map(function (item) { - return (valueOnly ? item.value : _this._getChoiceForOutput(item)); + return (valueOnly ? item.value : getChoiceForOutput(item)); }); return this._isSelectOneElement || this.config.singleModeForMultiSelect ? values[0] : values; }; @@ -3924,7 +3958,7 @@ // @todo integrate with Store this._searcher.reset(); if (choice.selected) { - this.passedElement.triggerEvent(EventType.removeItem, this._getChoiceForOutput(choice)); + this.passedElement.triggerEvent(EventType.removeItem, getChoiceForOutput(choice)); } return this; }; @@ -4007,13 +4041,7 @@ } var _a = this, config = _a.config, isSearching = _a._isSearching; var _b = this._store, activeGroups = _b.activeGroups, activeChoices = _b.activeChoices; - var renderLimit = 0; - if (isSearching && config.searchResultLimit > 0) { - renderLimit = config.searchResultLimit; - } - else if (config.renderChoiceLimit > 0) { - renderLimit = config.renderChoiceLimit; - } + var renderLimit = isSearching ? config.searchResultLimit : config.renderChoiceLimit; if (this._isSelectElement) { var backingOptions = activeChoices.filter(function (choice) { return !choice.element; }); if (backingOptions.length) { @@ -4023,11 +4051,16 @@ var fragment = document.createDocumentFragment(); var renderableChoices = function (choices) { return choices.filter(function (choice) { - return !choice.placeholder && (isSearching ? !!choice.rank : config.renderSelectedChoices || !choice.selected); + return !choice.placeholder && + (isSearching + ? (config.searchRenderSelectedChoices || !choice.selected) && !!choice.rank + : config.renderSelectedChoices || !choice.selected); }); }; + var showLabel = config.appendGroupInSearch && isSearching; var selectableChoices = false; - var renderChoices = function (choices, withinGroup, groupLabel) { + var highlightedEl = null; + var renderChoices = function (choices, withinGroup) { if (isSearching) { // sortByRank is used to ensure stable sorting, as scores are non-unique // this additionally ensures fuseOptions.sortFn is not ignored @@ -4037,16 +4070,20 @@ choices.sort(config.sorter); } var choiceLimit = choices.length; - choiceLimit = !withinGroup && renderLimit && choiceLimit > renderLimit ? renderLimit : choiceLimit; + choiceLimit = !withinGroup && renderLimit > 0 && choiceLimit > renderLimit ? renderLimit : choiceLimit; choiceLimit--; choices.every(function (choice, index) { // choiceEl being empty signals the contents has probably significantly changed - var dropdownItem = choice.choiceEl || _this._templates.choice(config, choice, config.itemSelectText, groupLabel); + var dropdownItem = choice.choiceEl || + _this._templates.choice(config, choice, config.itemSelectText, showLabel && choice.group ? choice.group.label : undefined); choice.choiceEl = dropdownItem; fragment.appendChild(dropdownItem); if (isSearching || !choice.selected) { selectableChoices = true; } + else if (!highlightedEl) { + highlightedEl = dropdownItem; + } return index < choiceLimit; }); }; @@ -4056,7 +4093,7 @@ } if (!this._hasNonChoicePlaceholder && !isSearching && this._isSelectOneElement) { // If we have a placeholder choice along with groups - renderChoices(activeChoices.filter(function (choice) { return choice.placeholder && !choice.group; }), false, undefined); + renderChoices(activeChoices.filter(function (choice) { return choice.placeholder && !choice.group; }), false); } // If we have grouped options if (activeGroups.length && !isSearching) { @@ -4065,7 +4102,7 @@ } // render Choices without group first, regardless of sort, otherwise they won't be distinguishable // from the last group - renderChoices(activeChoices.filter(function (choice) { return !choice.placeholder && !choice.group; }), false, undefined); + renderChoices(activeChoices.filter(function (choice) { return !choice.placeholder && !choice.group; }), false); activeGroups.forEach(function (group) { var groupChoices = renderableChoices(group.choices); if (groupChoices.length) { @@ -4075,12 +4112,12 @@ dropdownGroup.remove(); fragment.appendChild(dropdownGroup); } - renderChoices(groupChoices, true, config.appendGroupInSearch && isSearching ? group.label : undefined); + renderChoices(groupChoices, true); } }); } else { - renderChoices(renderableChoices(activeChoices), false, undefined); + renderChoices(renderableChoices(activeChoices), false); } } if (!selectableChoices && (isSearching || !fragment.children.length || !config.renderSelectedChoices)) { @@ -4094,9 +4131,7 @@ } this._renderNotice(fragment); this.choiceList.element.replaceChildren(fragment); - if (selectableChoices) { - this._highlightChoice(); - } + this._highlightChoice(highlightedEl); }; Choices.prototype._renderItems = function () { var _this = this; @@ -4206,23 +4241,12 @@ } } }; + /** + * @deprecated Use utils.getChoiceForOutput + */ // eslint-disable-next-line class-methods-use-this Choices.prototype._getChoiceForOutput = function (choice, keyCode) { - return { - id: choice.id, - highlighted: choice.highlighted, - labelClass: choice.labelClass, - labelDescription: choice.labelDescription, - customProperties: choice.customProperties, - disabled: choice.disabled, - active: choice.active, - label: choice.label, - placeholder: choice.placeholder, - value: choice.value, - groupValue: choice.group ? choice.group.label : undefined, - element: choice.element, - keyCode: keyCode, - }; + return getChoiceForOutput(choice, keyCode); }; Choices.prototype._triggerChange = function (value) { if (value === undefined || value === null) { @@ -4238,7 +4262,7 @@ if (!items.length || !this.config.removeItems || !this.config.removeItemButton) { return; } - var id = element && parseDataSetId(element.parentElement); + var id = element && parseDataSetId(element.closest('[data-id]')); var itemToRemove = id && items.find(function (item) { return item.id === id; }); if (!itemToRemove) { return; @@ -4427,7 +4451,7 @@ var notice = ''; if (canAddItem && typeof config.addItemFilter === 'function' && !config.addItemFilter(value)) { canAddItem = false; - notice = resolveNoticeFunction(config.customAddItemText, value); + notice = resolveNoticeFunction(config.customAddItemText, value, undefined); } if (canAddItem) { var foundChoice = this._store.choices.find(function (choice) { return config.valueComparer(choice.value, value); }); @@ -4439,12 +4463,12 @@ } if (!config.duplicateItemsAllowed) { canAddItem = false; - notice = resolveNoticeFunction(config.uniqueItemText, value); + notice = resolveNoticeFunction(config.uniqueItemText, value, undefined); } } } if (canAddItem) { - notice = resolveNoticeFunction(config.addItemText, value); + notice = resolveNoticeFunction(config.addItemText, value, undefined); } if (notice) { this._displayNotice(notice, NoticeTypes.addChoice); @@ -4495,6 +4519,7 @@ var documentElement = this._docRoot; var outerElement = this.containerOuter.element; var inputElement = this.input.element; + var passedElement = this.passedElement.element; // capture events - can cancel event processing or propagation documentElement.addEventListener('touchend', this._onTouchEnd, true); outerElement.addEventListener('keydown', this._onKeyDown, true); @@ -4532,12 +4557,21 @@ passive: true, }); } + if (passedElement.hasAttribute('required')) { + passedElement.addEventListener('change', this._onChange, { + passive: true, + }); + passedElement.addEventListener('invalid', this._onInvalid, { + passive: true, + }); + } this.input.addEventListeners(); }; Choices.prototype._removeEventListeners = function () { var documentElement = this._docRoot; var outerElement = this.containerOuter.element; var inputElement = this.input.element; + var passedElement = this.passedElement.element; documentElement.removeEventListener('touchend', this._onTouchEnd, true); outerElement.removeEventListener('keydown', this._onKeyDown, true); outerElement.removeEventListener('mousedown', this._onMouseDown, true); @@ -4555,6 +4589,10 @@ if (inputElement.form) { inputElement.form.removeEventListener('reset', this._onFormReset); } + if (passedElement.hasAttribute('required')) { + passedElement.removeEventListener('change', this._onChange); + passedElement.removeEventListener('invalid', this._onInvalid); + } this.input.removeEventListeners(); }; Choices.prototype._onKeyDown = function (event) { @@ -4804,7 +4842,7 @@ */ Choices.prototype._onMouseDown = function (event) { var target = event.target; - if (!(target instanceof HTMLElement)) { + if (!(target instanceof Element)) { return; } // If we have our mouse down on the scrollbar and are on IE11... @@ -4913,7 +4951,7 @@ // Remove the focus state when the past outerContainer was the target containerOuter.removeFocusState(); // Also close the dropdown if search is disabled - if (!this._canSearch) { + if (!this.config.searchEnabled) { this.hideDropdown(true); } } @@ -4937,6 +4975,27 @@ } }); }; + Choices.prototype._onChange = function (event) { + if (!event.target.checkValidity()) { + return; + } + this.containerOuter.removeInvalidState(); + }; + Choices.prototype._onInvalid = function () { + this.containerOuter.addInvalidState(); + }; + /** + * Removes any highlighted choice options + */ + Choices.prototype._removeHighlightedChoices = function () { + var highlightedState = this.config.classNames.highlightedState; + var highlightedChoices = Array.from(this.dropdown.element.querySelectorAll(getClassNamesSelector(highlightedState))); + // Remove any highlighted choices + highlightedChoices.forEach(function (choice) { + removeClassesFromElement(choice, highlightedState); + choice.setAttribute('aria-selected', 'false'); + }); + }; Choices.prototype._highlightChoice = function (el) { if (el === void 0) { el = null; } var choices = Array.from(this.dropdown.element.querySelectorAll(selectableChoiceIdentifier)); @@ -4945,12 +5004,7 @@ } var passedEl = el; var highlightedState = this.config.classNames.highlightedState; - var highlightedChoices = Array.from(this.dropdown.element.querySelectorAll(getClassNamesSelector(highlightedState))); - // Remove any highlighted choices - highlightedChoices.forEach(function (choice) { - removeClassesFromElement(choice, highlightedState); - choice.setAttribute('aria-selected', 'false'); - }); + this._removeHighlightedChoices(); if (passedEl) { this._highlightPosition = choices.indexOf(passedEl); } @@ -4991,9 +5045,10 @@ } this._store.dispatch(addItem(item)); if (withEvents) { - this.passedElement.triggerEvent(EventType.addItem, this._getChoiceForOutput(item)); + var eventChoice = getChoiceForOutput(item); + this.passedElement.triggerEvent(EventType.addItem, eventChoice); if (userTriggered) { - this.passedElement.triggerEvent(EventType.choice, this._getChoiceForOutput(item)); + this.passedElement.triggerEvent(EventType.choice, eventChoice); } } }; @@ -5006,7 +5061,7 @@ if (notice && notice.type === NoticeTypes.noChoices) { this._clearNotice(); } - this.passedElement.triggerEvent(EventType.removeItem, this._getChoiceForOutput(item)); + this.passedElement.triggerEvent(EventType.removeItem, getChoiceForOutput(item)); }; Choices.prototype._addChoice = function (choice, withEvents, userTriggered) { if (withEvents === void 0) { withEvents = true; } @@ -5121,24 +5176,24 @@ containerInner.wrap(passedElement.element); // Wrapper inner container with outer container containerOuter.wrap(containerInner.element); - if (this._isSelectOneElement) { - this.input.placeholder = this.config.searchPlaceholderValue || ''; - } - else { - if (this._placeholderValue) { - this.input.placeholder = this._placeholderValue; - } - this.input.setWidth(); - } containerOuter.element.appendChild(containerInner.element); containerOuter.element.appendChild(dropdownElement); containerInner.element.appendChild(this.itemList.element); dropdownElement.appendChild(this.choiceList.element); - if (!this._isSelectOneElement) { - containerInner.element.appendChild(this.input.element); + if (this._isSelectOneElement) { + this.input.placeholder = this.config.searchPlaceholderValue || ''; + if (this.config.searchEnabled) { + dropdownElement.insertBefore(this.input.element, dropdownElement.firstChild); + } } - else if (this.config.searchEnabled) { - dropdownElement.insertBefore(this.input.element, dropdownElement.firstChild); + else { + if (!this._isSelectMultipleElement || this.config.searchEnabled) { + containerInner.element.appendChild(this.input.element); + } + if (this._placeholderValue) { + this.input.placeholder = this._placeholderValue; + } + this.input.setWidth(); } this._highlightPosition = 0; this._isSearching = false; @@ -5221,7 +5276,7 @@ throw new TypeError("".concat(caller, " called for an element which has multiple instances of Choices initialised on it")); } }; - Choices.version = '11.1.0'; + Choices.version = '11.2.0'; return Choices; }()); diff --git a/assets/scripts/choices.min.js b/assets/scripts/choices.min.js index cc5baa70..8a04aee4 100644 --- a/assets/scripts/choices.min.js +++ b/assets/scripts/choices.min.js @@ -1,2 +1,2 @@ -/*! choices.js v11.1.0 | © 2025 Josh Johnson | https://github.com/jshjohnson/Choices#readme */ -!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).Choices=t()}(this,(function(){"use strict";var e=function(t,i){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])},e(t,i)};function t(t,i){if("function"!=typeof i&&null!==i)throw new TypeError("Class extends value "+String(i)+" is not a constructor or null");function n(){this.constructor=t}e(t,i),t.prototype=null===i?Object.create(i):(n.prototype=i.prototype,new n)}var i=function(){return i=Object.assign||function(e){for(var t,i=1,n=arguments.length;i/g,">").replace(/=0&&!window.matchMedia("(min-height: ".concat(e+1,"px)")).matches:"top"===this.position&&(i=!0),i},e.prototype.setActiveDescendant=function(e){this.element.setAttribute("aria-activedescendant",e)},e.prototype.removeActiveDescendant=function(){this.element.removeAttribute("aria-activedescendant")},e.prototype.open=function(e,t){P(this.element,this.classNames.openState),this.element.setAttribute("aria-expanded","true"),this.isOpen=!0,this.shouldFlip(e,t)&&(P(this.element,this.classNames.flippedState),this.isFlipped=!0)},e.prototype.close=function(){j(this.element,this.classNames.openState),this.element.setAttribute("aria-expanded","false"),this.removeActiveDescendant(),this.isOpen=!1,this.isFlipped&&(j(this.element,this.classNames.flippedState),this.isFlipped=!1)},e.prototype.addFocusState=function(){P(this.element,this.classNames.focusState)},e.prototype.removeFocusState=function(){j(this.element,this.classNames.focusState)},e.prototype.enable=function(){j(this.element,this.classNames.disabledState),this.element.removeAttribute("aria-disabled"),this.type===_&&this.element.setAttribute("tabindex","0"),this.isDisabled=!1},e.prototype.disable=function(){P(this.element,this.classNames.disabledState),this.element.setAttribute("aria-disabled","true"),this.type===_&&this.element.setAttribute("tabindex","-1"),this.isDisabled=!0},e.prototype.wrap=function(e){var t=this.element,i=e.parentNode;i&&(e.nextSibling?i.insertBefore(t,e.nextSibling):i.appendChild(t)),t.appendChild(e)},e.prototype.unwrap=function(e){var t=this.element,i=t.parentNode;i&&(i.insertBefore(e,t),i.removeChild(t))},e.prototype.addLoadingState=function(){P(this.element,this.classNames.loadingState),this.element.setAttribute("aria-busy","true"),this.isLoading=!0},e.prototype.removeLoadingState=function(){j(this.element,this.classNames.loadingState),this.element.removeAttribute("aria-busy"),this.isLoading=!1},e}(),B=function(){function e(e){var t=e.element,i=e.type,n=e.classNames,s=e.preventPaste;this.element=t,this.type=i,this.classNames=n,this.preventPaste=s,this.isFocussed=this.element.isEqualNode(document.activeElement),this.isDisabled=t.disabled,this._onPaste=this._onPaste.bind(this),this._onInput=this._onInput.bind(this),this._onFocus=this._onFocus.bind(this),this._onBlur=this._onBlur.bind(this)}return Object.defineProperty(e.prototype,"placeholder",{set:function(e){this.element.placeholder=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"value",{get:function(){return this.element.value},set:function(e){this.element.value=e},enumerable:!1,configurable:!0}),e.prototype.addEventListeners=function(){var e=this.element;e.addEventListener("paste",this._onPaste),e.addEventListener("input",this._onInput,{passive:!0}),e.addEventListener("focus",this._onFocus,{passive:!0}),e.addEventListener("blur",this._onBlur,{passive:!0})},e.prototype.removeEventListeners=function(){var e=this.element;e.removeEventListener("input",this._onInput),e.removeEventListener("paste",this._onPaste),e.removeEventListener("focus",this._onFocus),e.removeEventListener("blur",this._onBlur)},e.prototype.enable=function(){this.element.removeAttribute("disabled"),this.isDisabled=!1},e.prototype.disable=function(){this.element.setAttribute("disabled",""),this.isDisabled=!0},e.prototype.focus=function(){this.isFocussed||this.element.focus()},e.prototype.blur=function(){this.isFocussed&&this.element.blur()},e.prototype.clear=function(e){return void 0===e&&(e=!0),this.element.value="",e&&this.setWidth(),this},e.prototype.setWidth=function(){var e=this.element;e.style.minWidth="".concat(e.placeholder.length+1,"ch"),e.style.width="".concat(e.value.length+1,"ch")},e.prototype.setActiveDescendant=function(e){this.element.setAttribute("aria-activedescendant",e)},e.prototype.removeActiveDescendant=function(){this.element.removeAttribute("aria-activedescendant")},e.prototype._onInput=function(){this.type!==_&&this.setWidth()},e.prototype._onPaste=function(e){this.preventPaste&&e.preventDefault()},e.prototype._onFocus=function(){this.isFocussed=!0},e.prototype._onBlur=function(){this.isFocussed=!1},e}(),H=function(){function e(e){this.element=e.element,this.scrollPos=this.element.scrollTop,this.height=this.element.offsetHeight}return e.prototype.prepend=function(e){var t=this.element.firstElementChild;t?this.element.insertBefore(e,t):this.element.append(e)},e.prototype.scrollToTop=function(){this.element.scrollTop=0},e.prototype.scrollToChildElement=function(e,t){var i=this;if(e){var n=t>0?this.element.scrollTop+(e.offsetTop+e.offsetHeight)-(this.element.scrollTop+this.element.offsetHeight):e.offsetTop;requestAnimationFrame((function(){i._animateScroll(n,t)}))}},e.prototype._scrollDown=function(e,t,i){var n=(i-e)/t;this.element.scrollTop=e+(n>1?n:1)},e.prototype._scrollUp=function(e,t,i){var n=(e-i)/t;this.element.scrollTop=e-(n>1?n:1)},e.prototype._animateScroll=function(e,t){var i=this,n=this.element.scrollTop,s=!1;t>0?(this._scrollDown(n,4,e),ne&&(s=!0)),s&&requestAnimationFrame((function(){i._animateScroll(e,t)}))},e}(),$=function(){function e(e){var t=e.classNames;this.element=e.element,this.classNames=t,this.isDisabled=!1}return Object.defineProperty(e.prototype,"isActive",{get:function(){return"active"===this.element.dataset.choice},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"dir",{get:function(){return this.element.dir},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"value",{get:function(){return this.element.value},set:function(e){this.element.setAttribute("value",e),this.element.value=e},enumerable:!1,configurable:!0}),e.prototype.conceal=function(){var e=this.element;P(e,this.classNames.input),e.hidden=!0,e.tabIndex=-1;var t=e.getAttribute("style");t&&e.setAttribute("data-choice-orig-style",t),e.setAttribute("data-choice","active")},e.prototype.reveal=function(){var e=this.element;j(e,this.classNames.input),e.hidden=!1,e.removeAttribute("tabindex");var t=e.getAttribute("data-choice-orig-style");t?(e.removeAttribute("data-choice-orig-style"),e.setAttribute("style",t)):e.removeAttribute("style"),e.removeAttribute("data-choice")},e.prototype.enable=function(){this.element.removeAttribute("disabled"),this.element.disabled=!1,this.isDisabled=!1},e.prototype.disable=function(){this.element.setAttribute("disabled",""),this.element.disabled=!0,this.isDisabled=!0},e.prototype.triggerEvent=function(e,t){var i;void 0===(i=t||{})&&(i=null),this.element.dispatchEvent(new CustomEvent(e,{detail:i,bubbles:!0,cancelable:!0}))},e}(),q=function(e){function i(){return null!==e&&e.apply(this,arguments)||this}return t(i,e),i}($),W=function(e,t){return void 0===t&&(t=!0),void 0===e?t:!!e},U=function(e){if("string"==typeof e&&(e=e.split(" ").filter((function(e){return e.length}))),Array.isArray(e)&&e.length)return e},G=function(e,t,i){if(void 0===i&&(i=!0),"string"==typeof e){var n=I(e);return G({value:e,label:i||n===e?e:{escaped:n,raw:e},selected:!0},!1)}var s=e;if("choices"in s){if(!t)throw new TypeError("optGroup is not allowed");var o=s,r=o.choices.map((function(e){return G(e,!1)}));return{id:0,label:L(o.label)||o.value,active:!!r.length,disabled:!!o.disabled,choices:r}}var c=s;return{id:0,group:null,score:0,rank:0,value:c.value,label:c.label||c.value,active:W(c.active),selected:W(c.selected,!1),disabled:W(c.disabled,!1),placeholder:W(c.placeholder,!1),highlighted:!1,labelClass:U(c.labelClass),labelDescription:c.labelDescription,customProperties:c.customProperties}},z=function(e){return"SELECT"===e.tagName},J=function(e){function i(t){var i=t.template,n=t.extractPlaceholder,s=e.call(this,{element:t.element,classNames:t.classNames})||this;return s.template=i,s.extractPlaceholder=n,s}return t(i,e),Object.defineProperty(i.prototype,"placeholderOption",{get:function(){return this.element.querySelector('option[value=""]')||this.element.querySelector("option[placeholder]")},enumerable:!1,configurable:!0}),i.prototype.addOptions=function(e){var t=this,i=document.createDocumentFragment();e.forEach((function(e){var n=e;if(!n.element){var s=t.template(n);i.appendChild(s),n.element=s}})),this.element.appendChild(i)},i.prototype.optionsAsChoices=function(){var e=this,t=[];return this.element.querySelectorAll(":scope > option, :scope > optgroup").forEach((function(i){!function(e){return"OPTION"===e.tagName}(i)?function(e){return"OPTGROUP"===e.tagName}(i)&&t.push(e._optgroupToChoice(i)):t.push(e._optionToChoice(i))})),t},i.prototype._optionToChoice=function(e){return!e.hasAttribute("value")&&e.hasAttribute("placeholder")&&(e.setAttribute("value",""),e.value=""),{id:0,group:null,score:0,rank:0,value:e.value,label:e.label,element:e,active:!0,selected:this.extractPlaceholder?e.selected:e.hasAttribute("selected"),disabled:e.disabled,highlighted:!1,placeholder:this.extractPlaceholder&&(!e.value||e.hasAttribute("placeholder")),labelClass:void 0!==e.dataset.labelClass?U(e.dataset.labelClass):void 0,labelDescription:void 0!==e.dataset.labelDescription?e.dataset.labelDescription:void 0,customProperties:R(e.dataset.customProperties)}},i.prototype._optgroupToChoice=function(e){var t=this,i=e.querySelectorAll("option"),n=Array.from(i).map((function(e){return t._optionToChoice(e)}));return{id:0,label:e.label||"",element:e,active:!!n.length,disabled:e.disabled,choices:n}},i}($),X={items:[],choices:[],silent:!1,renderChoiceLimit:-1,maxItemCount:-1,closeDropdownOnSelect:"auto",singleModeForMultiSelect:!1,addChoices:!1,addItems:!0,addItemFilter:function(e){return!!e&&""!==e},removeItems:!0,removeItemButton:!1,removeItemButtonAlignLeft:!1,editItems:!1,allowHTML:!1,allowHtmlUserInput:!1,duplicateItemsAllowed:!0,delimiter:",",paste:!0,searchEnabled:!0,searchChoices:!0,searchFloor:1,searchResultLimit:4,searchFields:["label","value"],position:"auto",resetScrollPosition:!0,shouldSort:!0,shouldSortItems:!1,sorter:function(e,t){var i=e.label,n=t.label,s=void 0===n?t.value:n;return L(void 0===i?e.value:i).localeCompare(L(s),[],{sensitivity:"base",ignorePunctuation:!0,numeric:!0})},shadowRoot:null,placeholder:!0,placeholderValue:null,searchPlaceholderValue:null,prependValue:null,appendValue:null,renderSelectedChoices:"auto",loadingText:"Loading...",noResultsText:"No results found",noChoicesText:"No choices to choose from",itemSelectText:"Press to select",uniqueItemText:"Only unique values can be added",customAddItemText:"Only values matching specific conditions can be added",addItemText:function(e){return'Press Enter to add "'.concat(e,'"')},removeItemIconText:function(){return"Remove item"},removeItemLabelText:function(e){return"Remove item: ".concat(e)},maxItemText:function(e){return"Only ".concat(e," values can be added")},valueComparer:function(e,t){return e===t},fuseOptions:{includeScore:!0},labelId:"",callbackOnInit:null,callbackOnCreateTemplates:null,classNames:{containerOuter:["choices"],containerInner:["choices__inner"],input:["choices__input"],inputCloned:["choices__input--cloned"],list:["choices__list"],listItems:["choices__list--multiple"],listSingle:["choices__list--single"],listDropdown:["choices__list--dropdown"],item:["choices__item"],itemSelectable:["choices__item--selectable"],itemDisabled:["choices__item--disabled"],itemChoice:["choices__item--choice"],description:["choices__description"],placeholder:["choices__placeholder"],group:["choices__group"],groupHeading:["choices__heading"],button:["choices__button"],activeState:["is-active"],focusState:["is-focused"],openState:["is-open"],disabledState:["is-disabled"],highlightedState:["is-highlighted"],selectedState:["is-selected"],flippedState:["is-flipped"],loadingState:["is-loading"],notice:["choices__notice"],addChoice:["choices__item--selectable","add-choice"],noResults:["has-no-results"],noChoices:["has-no-choices"]},appendGroupInSearch:!1},Q=function(e){var t=e.itemEl;t&&(t.remove(),e.itemEl=void 0)},Y={groups:function(e,t){var i=e,n=!0;switch(t.type){case l:i.push(t.group);break;case h:i=[];break;default:n=!1}return{state:i,update:n}},items:function(e,t,i){var n=e,s=!0;switch(t.type){case u:t.item.selected=!0,(o=t.item.element)&&(o.selected=!0,o.setAttribute("selected","")),n.push(t.item);break;case d:var o;if(t.item.selected=!1,o=t.item.element){o.selected=!1,o.removeAttribute("selected");var c=o.parentElement;c&&z(c)&&c.type===_&&(c.value="")}Q(t.item),n=n.filter((function(e){return e.id!==t.item.id}));break;case r:Q(t.choice),n=n.filter((function(e){return e.id!==t.choice.id}));break;case p:var a=t.highlighted,h=n.find((function(e){return e.id===t.item.id}));h&&h.highlighted!==a&&(h.highlighted=a,i&&function(e,t,i){var n=e.itemEl;n&&(j(n,i),P(n,t))}(h,a?i.classNames.highlightedState:i.classNames.selectedState,a?i.classNames.selectedState:i.classNames.highlightedState));break;default:s=!1}return{state:n,update:s}},choices:function(e,t,i){var n=e,s=!0;switch(t.type){case o:n.push(t.choice);break;case r:t.choice.choiceEl=void 0,t.choice.group&&(t.choice.group.choices=t.choice.group.choices.filter((function(e){return e.id!==t.choice.id}))),n=n.filter((function(e){return e.id!==t.choice.id}));break;case u:case d:t.item.choiceEl=void 0;break;case c:var l=[];t.results.forEach((function(e){l[e.item.id]=e})),n.forEach((function(e){var t=l[e.id];void 0!==t?(e.score=t.score,e.rank=t.rank,e.active=!0):(e.score=0,e.rank=0,e.active=!1),i&&i.appendGroupInSearch&&(e.choiceEl=void 0)}));break;case a:n.forEach((function(e){e.active=t.active,i&&i.appendGroupInSearch&&(e.choiceEl=void 0)}));break;case h:n=[];break;default:s=!1}return{state:n,update:s}}},Z=function(){function e(e){this._state=this.defaultState,this._listeners=[],this._txn=0,this._context=e}return Object.defineProperty(e.prototype,"defaultState",{get:function(){return{groups:[],items:[],choices:[]}},enumerable:!1,configurable:!0}),e.prototype.changeSet=function(e){return{groups:e,items:e,choices:e}},e.prototype.reset=function(){this._state=this.defaultState;var e=this.changeSet(!0);this._txn?this._changeSet=e:this._listeners.forEach((function(t){return t(e)}))},e.prototype.subscribe=function(e){return this._listeners.push(e),this},e.prototype.dispatch=function(e){var t=this,i=this._state,n=!1,s=this._changeSet||this.changeSet(!1);Object.keys(Y).forEach((function(o){var r=Y[o](i[o],e,t._context);r.update&&(n=!0,s[o]=!0,i[o]=r.state)})),n&&(this._txn?this._changeSet=s:this._listeners.forEach((function(e){return e(s)})))},e.prototype.withTxn=function(e){this._txn++;try{e()}finally{if(this._txn=Math.max(0,this._txn-1),!this._txn){var t=this._changeSet;t&&(this._changeSet=void 0,this._listeners.forEach((function(e){return e(t)})))}}},Object.defineProperty(e.prototype,"state",{get:function(){return this._state},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"items",{get:function(){return this.state.items},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"highlightedActiveItems",{get:function(){return this.items.filter((function(e){return e.active&&e.highlighted}))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"choices",{get:function(){return this.state.choices},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"activeChoices",{get:function(){return this.choices.filter((function(e){return e.active}))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"searchableChoices",{get:function(){return this.choices.filter((function(e){return!e.disabled&&!e.placeholder}))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"groups",{get:function(){return this.state.groups},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"activeGroups",{get:function(){var e=this;return this.state.groups.filter((function(t){var i=t.active&&!t.disabled,n=e.state.choices.some((function(e){return e.active&&!e.disabled}));return i&&n}),[])},enumerable:!1,configurable:!0}),e.prototype.inTxn=function(){return this._txn>0},e.prototype.getChoiceById=function(e){return this.activeChoices.find((function(t){return t.id===e}))},e.prototype.getGroupById=function(e){return this.groups.find((function(t){return t.id===e}))},e}(),ee="no-choices",te="no-results",ie="add-choice";function ne(e,t,i){return(t=function(e){var t=function(e){if("object"!=typeof e||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var i=t.call(e,"string");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function se(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function oe(e){for(var t=1;t`Missing ${e} property in key`,fe=e=>`Property 'weight' in key '${e}' must be a positive integer`,me=Object.prototype.hasOwnProperty;class ge{constructor(e){this._keys=[],this._keyMap={};let t=0;e.forEach((e=>{let i=ve(e);this._keys.push(i),this._keyMap[i.id]=i,t+=i.weight})),this._keys.forEach((e=>{e.weight/=t}))}get(e){return this._keyMap[e]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function ve(e){let t=null,i=null,n=null,s=1,o=null;if(ce(e)||re(e))n=e,t=_e(e),i=ye(e);else{if(!me.call(e,"name"))throw new Error(pe("name"));const r=e.name;if(n=r,me.call(e,"weight")&&(s=e.weight,s<=0))throw new Error(fe(r));t=_e(r),i=ye(r),o=e.getFn}return{path:t,id:i,weight:s,src:n,getFn:o}}function _e(e){return re(e)?e:e.split(".")}function ye(e){return re(e)?e.join("."):e}const be={useExtendedSearch:!1,getFn:function(e,t){let i=[],n=!1;const s=(e,t,o)=>{if(le(e))if(t[o]){const r=e[t[o]];if(!le(r))return;if(o===t.length-1&&(ce(r)||ae(r)||function(e){return!0===e||!1===e||function(e){return he(e)&&null!==e}(e)&&"[object Boolean]"==de(e)}(r)))i.push(function(e){return null==e?"":function(e){if("string"==typeof e)return e;let t=e+"";return"0"==t&&1/e==-1/0?"-0":t}(e)}(r));else if(re(r)){n=!0;for(let e=0,i=r.length;ee.score===t.score?e.idx{this._keysMap[e.id]=t}))}create(){!this.isCreated&&this.docs.length&&(this.isCreated=!0,ce(this.docs[0])?this.docs.forEach(((e,t)=>{this._addString(e,t)})):this.docs.forEach(((e,t)=>{this._addObject(e,t)})),this.norm.clear())}add(e){const t=this.size();ce(e)?this._addString(e,t):this._addObject(e,t)}removeAt(e){this.records.splice(e,1);for(let t=e,i=this.size();t{let s=t.getFn?t.getFn(e):this.getFn(e,t.path);if(le(s))if(re(s)){let e=[];const t=[{nestedArrIndex:-1,value:s}];for(;t.length;){const{nestedArrIndex:i,value:n}=t.pop();if(le(n))if(ce(n)&&!ue(n)){let t={v:n,i:i,n:this.norm.get(n)};e.push(t)}else re(n)&&n.forEach(((e,i)=>{t.push({nestedArrIndex:i,value:e})}))}i.$[n]=e}else if(ce(s)&&!ue(s)){let e={v:s,n:this.norm.get(s)};i.$[n]=e}})),this.records.push(i)}toJSON(){return{keys:this.keys,records:this.records}}}function we(e,t,{getFn:i=Ee.getFn,fieldNormWeight:n=Ee.fieldNormWeight}={}){const s=new Se({getFn:i,fieldNormWeight:n});return s.setKeys(e.map(ve)),s.setSources(t),s.create(),s}function Ie(e,{errors:t=0,currentLocation:i=0,expectedLocation:n=0,distance:s=Ee.distance,ignoreLocation:o=Ee.ignoreLocation}={}){const r=t/e.length;if(o)return r;const c=Math.abs(n-i);return s?r+c/s:c?1:r}const Ae=32;function xe(e){let t={};for(let i=0,n=e.length;i{this.chunks.push({pattern:e,alphabet:xe(e),startIndex:t})},l=this.pattern.length;if(l>Ae){let e=0;const t=l%Ae,i=l-t;for(;e{const{isMatch:f,score:m,indices:g}=function(e,t,i,{location:n=Ee.location,distance:s=Ee.distance,threshold:o=Ee.threshold,findAllMatches:r=Ee.findAllMatches,minMatchCharLength:c=Ee.minMatchCharLength,includeMatches:a=Ee.includeMatches,ignoreLocation:h=Ee.ignoreLocation}={}){if(t.length>Ae)throw new Error("Pattern length exceeds max of 32.");const l=t.length,u=e.length,d=Math.max(0,Math.min(n,u));let p=o,f=d;const m=c>1||a,g=m?Array(u):[];let v;for(;(v=e.indexOf(t,f))>-1;){let e=Ie(t,{currentLocation:v,expectedLocation:d,distance:s,ignoreLocation:h});if(p=Math.min(e,p),f=v+l,m){let e=0;for(;e=a;o-=1){let r=o-1,c=i[e.charAt(r)];if(m&&(g[r]=+!!c),C[o]=(C[o+1]<<1|1)&c,n&&(C[o]|=(_[o+1]|_[o])<<1|1|_[o+1]),C[o]&E&&(y=Ie(t,{errors:n,currentLocation:r,expectedLocation:d,distance:s,ignoreLocation:h}),y<=p)){if(p=y,f=r,f<=d)break;a=Math.max(1,2*d-f)}}if(Ie(t,{errors:n+1,currentLocation:d,expectedLocation:d,distance:s,ignoreLocation:h})>p)break;_=C}const C={isMatch:f>=0,score:Math.max(.001,y)};if(m){const e=function(e=[],t=Ee.minMatchCharLength){let i=[],n=-1,s=-1,o=0;for(let r=e.length;o=t&&i.push([n,s]),n=-1)}return e[o-1]&&o-n>=t&&i.push([n,o-1]),i}(g,c);e.length?a&&(C.indices=e):C.isMatch=!1}return C}(e,t,d,{location:n+p,distance:s,threshold:o,findAllMatches:r,minMatchCharLength:c,includeMatches:i,ignoreLocation:a});f&&(u=!0),l+=m,f&&g&&(h=[...h,...g])}));let d={isMatch:u,score:u?l/this.chunks.length:1};return u&&i&&(d.indices=h),d}}class Le{constructor(e){this.pattern=e}static isMultiMatch(e){return Me(e,this.multiRegex)}static isSingleMatch(e){return Me(e,this.singleRegex)}search(){}}function Me(e,t){const i=e.match(t);return i?i[1]:null}class Te extends Le{constructor(e,{location:t=Ee.location,threshold:i=Ee.threshold,distance:n=Ee.distance,includeMatches:s=Ee.includeMatches,findAllMatches:o=Ee.findAllMatches,minMatchCharLength:r=Ee.minMatchCharLength,isCaseSensitive:c=Ee.isCaseSensitive,ignoreLocation:a=Ee.ignoreLocation}={}){super(e),this._bitapSearch=new Oe(e,{location:t,threshold:i,distance:n,includeMatches:s,findAllMatches:o,minMatchCharLength:r,isCaseSensitive:c,ignoreLocation:a})}static get type(){return"fuzzy"}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(e){return this._bitapSearch.searchIn(e)}}class Ne extends Le{constructor(e){super(e)}static get type(){return"include"}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(e){let t,i=0;const n=[],s=this.pattern.length;for(;(t=e.indexOf(this.pattern,i))>-1;)i=t+s,n.push([t,i-1]);const o=!!n.length;return{isMatch:o,score:o?0:1,indices:n}}}const ke=[class extends Le{constructor(e){super(e)}static get type(){return"exact"}static get multiRegex(){return/^="(.*)"$/}static get singleRegex(){return/^=(.*)$/}search(e){const t=e===this.pattern;return{isMatch:t,score:t?0:1,indices:[0,this.pattern.length-1]}}},Ne,class extends Le{constructor(e){super(e)}static get type(){return"prefix-exact"}static get multiRegex(){return/^\^"(.*)"$/}static get singleRegex(){return/^\^(.*)$/}search(e){const t=e.startsWith(this.pattern);return{isMatch:t,score:t?0:1,indices:[0,this.pattern.length-1]}}},class extends Le{constructor(e){super(e)}static get type(){return"inverse-prefix-exact"}static get multiRegex(){return/^!\^"(.*)"$/}static get singleRegex(){return/^!\^(.*)$/}search(e){const t=!e.startsWith(this.pattern);return{isMatch:t,score:t?0:1,indices:[0,e.length-1]}}},class extends Le{constructor(e){super(e)}static get type(){return"inverse-suffix-exact"}static get multiRegex(){return/^!"(.*)"\$$/}static get singleRegex(){return/^!(.*)\$$/}search(e){const t=!e.endsWith(this.pattern);return{isMatch:t,score:t?0:1,indices:[0,e.length-1]}}},class extends Le{constructor(e){super(e)}static get type(){return"suffix-exact"}static get multiRegex(){return/^"(.*)"\$$/}static get singleRegex(){return/^(.*)\$$/}search(e){const t=e.endsWith(this.pattern);return{isMatch:t,score:t?0:1,indices:[e.length-this.pattern.length,e.length-1]}}},class extends Le{constructor(e){super(e)}static get type(){return"inverse-exact"}static get multiRegex(){return/^!"(.*)"$/}static get singleRegex(){return/^!(.*)$/}search(e){const t=-1===e.indexOf(this.pattern);return{isMatch:t,score:t?0:1,indices:[0,e.length-1]}}},Te],Fe=ke.length,De=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,Pe=new Set([Te.type,Ne.type]);const je=[];function Re(e,t){for(let i=0,n=je.length;i!(!e[Ke]&&!e.$or),He=e=>({[Ke]:Object.keys(e).map((t=>({[t]:e[t]})))});function $e(e,t,{auto:i=!0}={}){const n=e=>{let s=Object.keys(e);const o=(e=>!!e[Ve])(e);if(!o&&s.length>1&&!Be(e))return n(He(e));if((e=>!re(e)&&he(e)&&!Be(e))(e)){const n=o?e[Ve]:s[0],r=o?e.$val:e[n];if(!ce(r))throw new Error((e=>`Invalid value for key ${e}`)(n));const c={keyId:ye(n),pattern:r};return i&&(c.searcher=Re(r,t)),c}let r={children:[],operator:s[0]};return s.forEach((t=>{const i=e[t];re(i)&&i.forEach((e=>{r.children.push(n(e))}))})),r};return Be(e)||(e=He(e)),n(e)}function qe(e,t){const i=e.matches;t.matches=[],le(i)&&i.forEach((e=>{if(!le(e.indices)||!e.indices.length)return;const{indices:i,value:n}=e;let s={indices:i,value:n};e.key&&(s.key=e.key.src),e.idx>-1&&(s.refIndex=e.idx),t.matches.push(s)}))}function We(e,t){t.score=e.score}class Ue{constructor(e,t={},i){this.options=oe(oe({},Ee),t),this._keyStore=new ge(this.options.keys),this.setCollection(e,i)}setCollection(e,t){if(this._docs=e,t&&!(t instanceof Se))throw new Error("Incorrect 'index' type");this._myIndex=t||we(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(e){le(e)&&(this._docs.push(e),this._myIndex.add(e))}remove(e=()=>!1){const t=[];for(let i=0,n=this._docs.length;i{let i=1;e.matches.forEach((({key:e,norm:n,score:s})=>{const o=e?e.weight:null;i*=Math.pow(0===s&&o?Number.EPSILON:s,(o||1)*(t?1:n))})),e.score=i}))}(c,{ignoreFieldNorm:r}),s&&c.sort(o),ae(t)&&t>-1&&(c=c.slice(0,t)),function(e,t,{includeMatches:i=Ee.includeMatches,includeScore:n=Ee.includeScore}={}){const s=[];return i&&s.push(qe),n&&s.push(We),e.map((e=>{const{idx:i}=e,n={item:t[i],refIndex:i};return s.length&&s.forEach((t=>{t(e,n)})),n}))}(c,this._docs,{includeMatches:i,includeScore:n})}_searchStringList(e){const t=Re(e,this.options),{records:i}=this._myIndex,n=[];return i.forEach((({v:e,i:i,n:s})=>{if(!le(e))return;const{isMatch:o,score:r,indices:c}=t.searchIn(e);o&&n.push({item:e,idx:i,matches:[{score:r,value:e,norm:s,indices:c}]})})),n}_searchLogical(e){const t=$e(e,this.options),i=(e,t,n)=>{if(!e.children){const{keyId:i,searcher:s}=e,o=this._findMatches({key:this._keyStore.get(i),value:this._myIndex.getValueForItemAtKeyId(t,i),searcher:s});return o&&o.length?[{idx:n,item:t,matches:o}]:[]}const s=[];for(let o=0,r=e.children.length;o{if(le(e)){let r=i(t,e,o);r.length&&(n[o]||(n[o]={idx:o,item:e,matches:[]},s.push(n[o])),r.forEach((({matches:e})=>{n[o].matches.push(...e)})))}})),s}_searchObjectList(e){const t=Re(e,this.options),{keys:i,records:n}=this._myIndex,s=[];return n.forEach((({$:e,i:n})=>{if(!le(e))return;let o=[];i.forEach(((i,n)=>{o.push(...this._findMatches({key:i,value:e[n],searcher:t}))})),o.length&&s.push({idx:n,item:e,matches:o})})),s}_findMatches({key:e,value:t,searcher:i}){if(!le(t))return[];let n=[];if(re(t))t.forEach((({v:t,i:s,n:o})=>{if(!le(t))return;const{isMatch:r,score:c,indices:a}=i.searchIn(t);r&&n.push({score:c,key:e,value:t,idx:s,norm:o,indices:a})}));else{const{v:s,n:o}=t,{isMatch:r,score:c,indices:a}=i.searchIn(s);r&&n.push({score:c,key:e,value:s,norm:o,indices:a})}return n}}Ue.version="7.0.0",Ue.createIndex=we,Ue.parseIndex=function(e,{getFn:t=Ee.getFn,fieldNormWeight:i=Ee.fieldNormWeight}={}){const{keys:n,records:s}=e,o=new Se({getFn:t,fieldNormWeight:i});return o.setKeys(n),o.setIndexRecords(s),o},Ue.config=Ee,Ue.parseQuery=$e,function(...e){je.push(...e)}(class{constructor(e,{isCaseSensitive:t=Ee.isCaseSensitive,includeMatches:i=Ee.includeMatches,minMatchCharLength:n=Ee.minMatchCharLength,ignoreLocation:s=Ee.ignoreLocation,findAllMatches:o=Ee.findAllMatches,location:r=Ee.location,threshold:c=Ee.threshold,distance:a=Ee.distance}={}){this.query=null,this.options={isCaseSensitive:t,includeMatches:i,minMatchCharLength:n,findAllMatches:o,ignoreLocation:s,location:r,threshold:c,distance:a},this.pattern=t?e:e.toLowerCase(),this.query=function(e,t={}){return e.split("|").map((e=>{let i=e.trim().split(De).filter((e=>e&&!!e.trim())),n=[];for(let e=0,s=i.length;e element"),this)},e.prototype.removeChoice=function(e){var t=this._store.choices.find((function(t){return t.value===e}));return t?(this._clearNotice(),this._store.dispatch(function(e){return{type:r,choice:e}}(t)),this._searcher.reset(),t.selected&&this.passedElement.triggerEvent(m,this._getChoiceForOutput(t)),this):this},e.prototype.clearChoices=function(e,t){var i=this;return void 0===e&&(e=!0),void 0===t&&(t=!1),e&&(t?this.passedElement.element.replaceChildren(""):this.passedElement.element.querySelectorAll(":not([selected])").forEach((function(e){e.remove()}))),this.itemList.element.replaceChildren(""),this.choiceList.element.replaceChildren(""),this._clearNotice(),this._store.withTxn((function(){var e=t?[]:i._store.items;i._store.reset(),e.forEach((function(e){i._store.dispatch(b(e)),i._store.dispatch(E(e))}))})),this._searcher.reset(),this},e.prototype.clearStore=function(e){return void 0===e&&(e=!0),this.clearChoices(e,!0),this._stopSearch(),this._lastAddedChoiceId=0,this._lastAddedGroupId=0,this},e.prototype.clearInput=function(){return this.input.clear(!this._isSelectOneElement),this._stopSearch(),this},e.prototype._validateConfig=function(){var e,t,i,n=this.config,s=(e=X,t=Object.keys(n).sort(),i=Object.keys(e).sort(),t.filter((function(e){return i.indexOf(e)<0})));s.length&&console.warn("Unknown config option(s) passed",s.join(", ")),n.allowHTML&&n.allowHtmlUserInput&&(n.addItems&&console.warn("Warning: allowHTML/allowHtmlUserInput/addItems all being true is strongly not recommended and may lead to XSS attacks"),n.addChoices&&console.warn("Warning: allowHTML/allowHtmlUserInput/addChoices all being true is strongly not recommended and may lead to XSS attacks"))},e.prototype._render=function(e){void 0===e&&(e={choices:!0,groups:!0,items:!0}),this._store.inTxn()||(this._isSelectElement&&(e.choices||e.groups)&&this._renderChoices(),e.items&&this._renderItems())},e.prototype._renderChoices=function(){var e=this;if(this._canAddItems()){var t=this.config,i=this._isSearching,n=this._store,s=n.activeGroups,o=n.activeChoices,r=0;if(i&&t.searchResultLimit>0?r=t.searchResultLimit:t.renderChoiceLimit>0&&(r=t.renderChoiceLimit),this._isSelectElement){var c=o.filter((function(e){return!e.element}));c.length&&this.passedElement.addOptions(c)}var a=document.createDocumentFragment(),h=function(e){return e.filter((function(e){return!e.placeholder&&(i?!!e.rank:t.renderSelectedChoices||!e.selected)}))},l=!1,u=function(n,s,o){i?n.sort(k):t.shouldSort&&n.sort(t.sorter);var c=n.length;c=!s&&r&&c>r?r:c,c--,n.every((function(n,s){var r=n.choiceEl||e._templates.choice(t,n,t.itemSelectText,o);return n.choiceEl=r,a.appendChild(r),!i&&n.selected||(l=!0),s1){var h=i.querySelector(D(n.classNames.placeholder));h&&h.remove()}else c||a||!this._placeholderValue||(c=!0,r(G({selected:!0,value:"",label:this._placeholderValue,placeholder:!0},!1)))}c&&(i.append(s),n.shouldSortItems&&!this._isSelectOneElement&&(t.sort(n.sorter),t.forEach((function(e){var t=o(e);t&&(t.remove(),s.append(t))})),i.append(s))),this._isTextElement&&(this.passedElement.value=t.map((function(e){return e.value})).join(n.delimiter))},e.prototype._displayNotice=function(e,t,i){void 0===i&&(i=!0);var n=this._notice;n&&(n.type===t&&n.text===e||n.type===ie&&(t===te||t===ee))?i&&this.showDropdown(!0):(this._clearNotice(),this._notice=e?{text:e,type:t}:void 0,this._renderNotice(),i&&e&&this.showDropdown(!0))},e.prototype._clearNotice=function(){if(this._notice){var e=this.choiceList.element.querySelector(D(this.config.classNames.notice));e&&e.remove(),this._notice=void 0}},e.prototype._renderNotice=function(e){var t=this._notice;if(t){var i=this._templates.notice(this.config,t.text,t.type);e?e.append(i):this.choiceList.prepend(i)}},e.prototype._getChoiceForOutput=function(e,t){return{id:e.id,highlighted:e.highlighted,labelClass:e.labelClass,labelDescription:e.labelDescription,customProperties:e.customProperties,disabled:e.disabled,active:e.active,label:e.label,placeholder:e.placeholder,value:e.value,groupValue:e.group?e.group.label:void 0,element:e.element,keyCode:t}},e.prototype._triggerChange=function(e){null!=e&&this.passedElement.triggerEvent("change",{value:e})},e.prototype._handleButtonAction=function(e){var t=this,i=this._store.items;if(i.length&&this.config.removeItems&&this.config.removeItemButton){var n=e&&Ze(e.parentElement),s=n&&i.find((function(e){return e.id===n}));s&&this._store.withTxn((function(){if(t._removeItem(s),t._triggerChange(s.value),t._isSelectOneElement&&!t._hasNonChoicePlaceholder){var e=(t.config.shouldSort?t._store.choices.reverse():t._store.choices).find((function(e){return e.placeholder}));e&&(t._addItem(e),t.unhighlightAll(),e.value&&t._triggerChange(e.value))}}))}},e.prototype._handleItemAction=function(e,t){var i=this;void 0===t&&(t=!1);var n=this._store.items;if(n.length&&this.config.removeItems&&!this._isSelectOneElement){var s=Ze(e);s&&(n.forEach((function(e){e.id!==s||e.highlighted?!t&&e.highlighted&&i.unhighlightItem(e):i.highlightItem(e)})),this.input.focus())}},e.prototype._handleChoiceAction=function(e){var t=this,i=Ze(e),n=i&&this._store.getChoiceById(i);if(!n||n.disabled)return!1;var s=this.dropdown.isActive;if(!n.selected){if(!this._canAddItems())return!0;this._store.withTxn((function(){t._addItem(n,!0,!0),t.clearInput(),t.unhighlightAll()})),this._triggerChange(n.value)}return s&&this.config.closeDropdownOnSelect&&(this.hideDropdown(!0),this.containerOuter.element.focus()),!0},e.prototype._handleBackspace=function(e){var t=this.config;if(t.removeItems&&e.length){var i=e[e.length-1],n=e.some((function(e){return e.highlighted}));t.editItems&&!n&&i?(this.input.value=i.value,this.input.setWidth(),this._removeItem(i),this._triggerChange(i.value)):(n||this.highlightItem(i,!1),this.removeHighlightedItems(!0))}},e.prototype._loadChoices=function(){var e,t=this,i=this.config;if(this._isTextElement){if(this._presetChoices=i.items.map((function(e){return G(e,!1)})),this.passedElement.value){var n=this.passedElement.value.split(i.delimiter).map((function(e){return G(e,!1,t.config.allowHtmlUserInput)}));this._presetChoices=this._presetChoices.concat(n)}this._presetChoices.forEach((function(e){e.selected=!0}))}else if(this._isSelectElement){this._presetChoices=i.choices.map((function(e){return G(e,!0)}));var s=this.passedElement.optionsAsChoices();s&&(e=this._presetChoices).push.apply(e,s)}},e.prototype._handleLoadingState=function(e){void 0===e&&(e=!0);var t=this.itemList.element;e?(this.disable(),this.containerOuter.addLoadingState(),this._isSelectOneElement?t.replaceChildren(this._templates.placeholder(this.config,this.config.loadingText)):this.input.placeholder=this.config.loadingText):(this.enable(),this.containerOuter.removeLoadingState(),this._isSelectOneElement?(t.replaceChildren(""),this._render()):this.input.placeholder=this._placeholderValue||"")},e.prototype._handleSearch=function(e){if(this.input.isFocussed)if(null!=e&&e.length>=this.config.searchFloor){var t=this.config.searchChoices?this._searchChoices(e):0;null!==t&&this.passedElement.triggerEvent(f,{value:e,resultCount:t})}else this._store.choices.some((function(e){return!e.active}))&&this._stopSearch()},e.prototype._canAddItems=function(){var e=this.config,t=e.maxItemCount,i=e.maxItemText;return!e.singleModeForMultiSelect&&t>0&&t<=this._store.items.length?(this.choiceList.element.replaceChildren(""),this._notice=void 0,this._displayNotice("function"==typeof i?i(t):i,ie),!1):(this._notice&&this._notice.type===ie&&this._clearNotice(),!0)},e.prototype._canCreateItem=function(e){var t=this.config,i=!0,n="";if(i&&"function"==typeof t.addItemFilter&&!t.addItemFilter(e)&&(i=!1,n=x(t.customAddItemText,e)),i&&this._store.choices.find((function(i){return t.valueComparer(i.value,e)}))){if(this._isSelectElement)return this._displayNotice("",ie),!1;t.duplicateItemsAllowed||(i=!1,n=x(t.uniqueItemText,e))}return i&&(n=x(t.addItemText,e)),n&&this._displayNotice(n,ie),i},e.prototype._searchChoices=function(e){var t=e.trim().replace(/\s{2,}/," ");if(!t.length||t===this._currentValue)return null;var i=this._searcher;i.isEmptyIndex()&&i.index(this._store.searchableChoices);var n=i.search(t);this._currentValue=t,this._highlightPosition=0,this._isSearching=!0;var s=this._notice;return(s&&s.type)!==ie&&(n.length?this._clearNotice():this._displayNotice(O(this.config.noResultsText),te)),this._store.dispatch(function(e){return{type:c,results:e}}(n)),n.length},e.prototype._stopSearch=function(){this._isSearching&&(this._currentValue="",this._isSearching=!1,this._clearNotice(),this._store.dispatch({type:a,active:!0}),this.passedElement.triggerEvent(f,{value:"",resultCount:0}))},e.prototype._addEventListeners=function(){var e=this._docRoot,t=this.containerOuter.element,i=this.input.element;e.addEventListener("touchend",this._onTouchEnd,!0),t.addEventListener("keydown",this._onKeyDown,!0),t.addEventListener("mousedown",this._onMouseDown,!0),e.addEventListener("click",this._onClick,{passive:!0}),e.addEventListener("touchmove",this._onTouchMove,{passive:!0}),this.dropdown.element.addEventListener("mouseover",this._onMouseOver,{passive:!0}),this._isSelectOneElement&&(t.addEventListener("focus",this._onFocus,{passive:!0}),t.addEventListener("blur",this._onBlur,{passive:!0})),i.addEventListener("keyup",this._onKeyUp,{passive:!0}),i.addEventListener("input",this._onInput,{passive:!0}),i.addEventListener("focus",this._onFocus,{passive:!0}),i.addEventListener("blur",this._onBlur,{passive:!0}),i.form&&i.form.addEventListener("reset",this._onFormReset,{passive:!0}),this.input.addEventListeners()},e.prototype._removeEventListeners=function(){var e=this._docRoot,t=this.containerOuter.element,i=this.input.element;e.removeEventListener("touchend",this._onTouchEnd,!0),t.removeEventListener("keydown",this._onKeyDown,!0),t.removeEventListener("mousedown",this._onMouseDown,!0),e.removeEventListener("click",this._onClick),e.removeEventListener("touchmove",this._onTouchMove),this.dropdown.element.removeEventListener("mouseover",this._onMouseOver),this._isSelectOneElement&&(t.removeEventListener("focus",this._onFocus),t.removeEventListener("blur",this._onBlur)),i.removeEventListener("keyup",this._onKeyUp),i.removeEventListener("input",this._onInput),i.removeEventListener("focus",this._onFocus),i.removeEventListener("blur",this._onBlur),i.form&&i.form.removeEventListener("reset",this._onFormReset),this.input.removeEventListeners()},e.prototype._onKeyDown=function(e){var t=e.keyCode,i=this.dropdown.isActive,n=1===e.key.length||2===e.key.length&&e.key.charCodeAt(0)>=55296||"Unidentified"===e.key;switch(this._isTextElement||i||27===t||9===t||16===t||(this.showDropdown(),!this.input.isFocussed&&n&&(this.input.value+=e.key," "===e.key&&e.preventDefault())),t){case 65:return this._onSelectKey(e,this.itemList.element.hasChildNodes());case 13:return this._onEnterKey(e,i);case 27:return this._onEscapeKey(e,i);case 38:case 33:case 40:case 34:return this._onDirectionKey(e,i);case 8:case 46:return this._onDeleteKey(e,this._store.items,this.input.isFocussed)}},e.prototype._onKeyUp=function(){this._canSearch=this.config.searchEnabled},e.prototype._onInput=function(){var e=this.input.value;e?this._canAddItems()&&(this._canSearch&&this._handleSearch(e),this._canAddUserChoices&&(this._canCreateItem(e),this._isSelectElement&&(this._highlightPosition=0,this._highlightChoice()))):this._isTextElement?this.hideDropdown(!0):this._stopSearch()},e.prototype._onSelectKey=function(e,t){(e.ctrlKey||e.metaKey)&&t&&(this._canSearch=!1,this.config.removeItems&&!this.input.value&&this.input.element===document.activeElement&&this.highlightAll())},e.prototype._onEnterKey=function(e,t){var i=this,n=this.input.value,s=e.target;if(e.preventDefault(),s&&s.hasAttribute("data-button"))this._handleButtonAction(s);else if(t){var o=this.dropdown.element.querySelector(D(this.config.classNames.highlightedState));if(!o||!this._handleChoiceAction(o))if(s&&n){if(this._canAddItems()){var r=!1;this._store.withTxn((function(){if(!(r=i._findAndSelectChoiceByValue(n,!0))){if(!i._canAddUserChoices)return;if(!i._canCreateItem(n))return;i._addChoice(G(n,!1,i.config.allowHtmlUserInput),!0,!0),r=!0}i.clearInput(),i.unhighlightAll()})),r&&(this._triggerChange(n),this.config.closeDropdownOnSelect&&this.hideDropdown(!0))}}else this.hideDropdown(!0)}else(this._isSelectElement||this._notice)&&this.showDropdown()},e.prototype._onEscapeKey=function(e,t){t&&(e.stopPropagation(),this.hideDropdown(!0),this._stopSearch(),this.containerOuter.element.focus())},e.prototype._onDirectionKey=function(e,t){var i,n,s,o=e.keyCode;if(t||this._isSelectOneElement){this.showDropdown(),this._canSearch=!1;var r=40===o||34===o?1:-1,c=void 0;if(e.metaKey||34===o||33===o)c=this.dropdown.element.querySelector(r>0?"".concat(et,":last-of-type"):et);else{var a=this.dropdown.element.querySelector(D(this.config.classNames.highlightedState));c=a?function(e,t,i){void 0===i&&(i=1);for(var n="".concat(i>0?"next":"previous","ElementSibling"),s=e[n];s;){if(s.matches(t))return s;s=s[n]}return null}(a,et,r):this.dropdown.element.querySelector(et)}c&&(i=c,n=this.choiceList.element,void 0===(s=r)&&(s=1),(s>0?n.scrollTop+n.offsetHeight>=i.offsetTop+i.offsetHeight:i.offsetTop>=n.scrollTop)||this.choiceList.scrollToChildElement(c,r),this._highlightChoice(c)),e.preventDefault()}},e.prototype._onDeleteKey=function(e,t,i){this._isSelectOneElement||e.target.value||!i||(this._handleBackspace(t),e.preventDefault())},e.prototype._onTouchMove=function(){this._wasTap&&(this._wasTap=!1)},e.prototype._onTouchEnd=function(e){var t=(e||e.touches[0]).target;this._wasTap&&this.containerOuter.element.contains(t)&&((t===this.containerOuter.element||t===this.containerInner.element)&&(this._isTextElement?this.input.focus():this._isSelectMultipleElement&&this.showDropdown()),e.stopPropagation()),this._wasTap=!0},e.prototype._onMouseDown=function(e){var t=e.target;if(t instanceof HTMLElement){if(Qe&&this.choiceList.element.contains(t)){var i=this.choiceList.element.firstElementChild;this._isScrollingOnIe="ltr"===this._direction?e.offsetX>=i.offsetWidth:e.offsetXthis._highlightPosition?t[this._highlightPosition]:t[t.length-1])||(i=t[0]),P(i,n),i.setAttribute("aria-selected","true"),this.passedElement.triggerEvent("highlightChoice",{el:i}),this.dropdown.isActive&&(this.input.setActiveDescendant(i.id),this.containerOuter.setActiveDescendant(i.id))}},e.prototype._addItem=function(e,t,i){if(void 0===t&&(t=!0),void 0===i&&(i=!1),!e.id)throw new TypeError("item.id must be set before _addItem is called for a choice/item");(this.config.singleModeForMultiSelect||this._isSelectOneElement)&&this.removeActiveItems(e.id),this._store.dispatch(E(e)),t&&(this.passedElement.triggerEvent("addItem",this._getChoiceForOutput(e)),i&&this.passedElement.triggerEvent("choice",this._getChoiceForOutput(e)))},e.prototype._removeItem=function(e){if(e.id){this._store.dispatch(C(e));var t=this._notice;t&&t.type===ee&&this._clearNotice(),this.passedElement.triggerEvent(m,this._getChoiceForOutput(e))}},e.prototype._addChoice=function(e,t,i){if(void 0===t&&(t=!0),void 0===i&&(i=!1),e.id)throw new TypeError("Can not re-add a choice which has already been added");var n=this.config;if(n.duplicateItemsAllowed||!this._store.choices.find((function(t){return n.valueComparer(t.value,e.value)}))){this._lastAddedChoiceId++,e.id=this._lastAddedChoiceId,e.elementId="".concat(this._baseId,"-").concat(this._idNames.itemChoice,"-").concat(e.id);var s=n.prependValue,o=n.appendValue;s&&(e.value=s+e.value),o&&(e.value+=o.toString()),(s||o)&&e.element&&(e.element.value=e.value),this._clearNotice(),this._store.dispatch(b(e)),e.selected&&this._addItem(e,t,i)}},e.prototype._addGroup=function(e,t){var i=this;if(void 0===t&&(t=!0),e.id)throw new TypeError("Can not re-add a group which has already been added");this._store.dispatch(function(e){return{type:l,group:e}}(e)),e.choices&&(this._lastAddedGroupId++,e.id=this._lastAddedGroupId,e.choices.forEach((function(n){n.group=e,e.disabled&&(n.disabled=!0),i._addChoice(n,t)})))},e.prototype._createTemplates=function(){var e=this,t=this.config.callbackOnCreateTemplates,i={};"function"==typeof t&&(i=t.call(this,A,T,F));var n={};Object.keys(this._templates).forEach((function(t){n[t]=t in i?i[t].bind(e):e._templates[t].bind(e)})),this._templates=n},e.prototype._createElements=function(){var e=this._templates,t=this.config,i=this._isSelectOneElement,n=t.position,s=t.classNames,o=this._elementType;this.containerOuter=new V({element:e.containerOuter(t,this._direction,this._isSelectElement,i,t.searchEnabled,o,t.labelId),classNames:s,type:o,position:n}),this.containerInner=new V({element:e.containerInner(t),classNames:s,type:o,position:n}),this.input=new B({element:e.input(t,this._placeholderValue),classNames:s,type:o,preventPaste:!t.paste}),this.choiceList=new H({element:e.choiceList(t,i)}),this.itemList=new H({element:e.itemList(t,i)}),this.dropdown=new K({element:e.dropdown(t),classNames:s,type:o})},e.prototype._createStructure=function(){var e=this,t=e.containerInner,i=e.containerOuter,n=e.passedElement,s=this.dropdown.element;n.conceal(),t.wrap(n.element),i.wrap(t.element),this._isSelectOneElement?this.input.placeholder=this.config.searchPlaceholderValue||"":(this._placeholderValue&&(this.input.placeholder=this._placeholderValue),this.input.setWidth()),i.element.appendChild(t.element),i.element.appendChild(s),t.element.appendChild(this.itemList.element),s.appendChild(this.choiceList.element),this._isSelectOneElement?this.config.searchEnabled&&s.insertBefore(this.input.element,s.firstChild):t.element.appendChild(this.input.element),this._highlightPosition=0,this._isSearching=!1},e.prototype._initStore=function(){var e=this;this._store.subscribe(this._render).withTxn((function(){e._addPredefinedChoices(e._presetChoices,e._isSelectOneElement&&!e._hasNonChoicePlaceholder,!1)})),(!this._store.choices.length||this._isSelectOneElement&&this._hasNonChoicePlaceholder)&&this._render()},e.prototype._addPredefinedChoices=function(e,t,i){var n=this;void 0===t&&(t=!1),void 0===i&&(i=!0),t&&-1===e.findIndex((function(e){return e.selected}))&&e.some((function(e){return!e.disabled&&!("choices"in e)&&(e.selected=!0,!0)})),e.forEach((function(e){"choices"in e?n._isSelectElement&&n._addGroup(e,i):n._addChoice(e,i)}))},e.prototype._findAndSelectChoiceByValue=function(e,t){var i=this;void 0===t&&(t=!1);var n=this._store.choices.find((function(t){return i.config.valueComparer(t.value,e)}));return!(!n||n.disabled||n.selected||(this._addItem(n,!0,t),0))},e.prototype._generatePlaceholderValue=function(){var e=this.config;if(!e.placeholder)return null;if(this._hasNonChoicePlaceholder)return e.placeholderValue;if(this._isSelectElement){var t=this.passedElement.placeholderOption;return t?t.text:null}return null},e.prototype._warnChoicesInitFailed=function(e){if(!this.config.silent){if(!this.initialised)throw new TypeError("".concat(e," called on a non-initialised instance of Choices"));if(!this.initialisedOK)throw new TypeError("".concat(e," called for an element which has multiple instances of Choices initialised on it"))}},e.version="11.1.0",e}()})); +/*! choices.js v11.2.0 | © 2026 Josh Johnson | https://github.com/jshjohnson/Choices#readme */ +!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).Choices=t()}(this,(function(){"use strict";var e=function(t,i){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])},e(t,i)};function t(t,i){if("function"!=typeof i&&null!==i)throw new TypeError("Class extends value "+String(i)+" is not a constructor or null");function n(){this.constructor=t}e(t,i),t.prototype=null===i?Object.create(i):(n.prototype=i.prototype,new n)}var i=function(){return i=Object.assign||function(e){for(var t,i=1,n=arguments.length;i0?t.scrollTop+t.offsetHeight>=e.offsetTop+e.offsetHeight:e.offsetTop>=t.scrollTop},A=function(e){if("string"!=typeof e){if(null==e)return"";if("object"==typeof e){if("raw"in e)return A(e.raw);if("trusted"in e)return e.trusted}return e}return e.replace(/&/g,"&").replace(/>/g,">").replace(/=0&&!window.matchMedia("(min-height: ".concat(e+1,"px)")).matches:"top"===this.position&&(i=!0),i},e.prototype.setActiveDescendant=function(e){this.element.setAttribute("aria-activedescendant",e)},e.prototype.removeActiveDescendant=function(){this.element.removeAttribute("aria-activedescendant")},e.prototype.open=function(e,t){R(this.element,this.classNames.openState),this.element.setAttribute("aria-expanded","true"),this.isOpen=!0,this.shouldFlip(e,t)&&(R(this.element,this.classNames.flippedState),this.isFlipped=!0)},e.prototype.close=function(){K(this.element,this.classNames.openState),this.element.setAttribute("aria-expanded","false"),this.removeActiveDescendant(),this.isOpen=!1,this.isFlipped&&(K(this.element,this.classNames.flippedState),this.isFlipped=!1)},e.prototype.addFocusState=function(){R(this.element,this.classNames.focusState)},e.prototype.removeFocusState=function(){K(this.element,this.classNames.focusState)},e.prototype.addInvalidState=function(){R(this.element,this.classNames.invalidState)},e.prototype.removeInvalidState=function(){K(this.element,this.classNames.invalidState)},e.prototype.enable=function(){K(this.element,this.classNames.disabledState),this.element.removeAttribute("aria-disabled"),this.type===_&&this.element.setAttribute("tabindex","0"),this.isDisabled=!1},e.prototype.disable=function(){R(this.element,this.classNames.disabledState),this.element.setAttribute("aria-disabled","true"),this.type===_&&this.element.setAttribute("tabindex","-1"),this.isDisabled=!0},e.prototype.wrap=function(e){var t=this.element,i=e.parentNode;i&&(e.nextSibling?i.insertBefore(t,e.nextSibling):i.appendChild(t)),t.appendChild(e)},e.prototype.unwrap=function(e){var t=this.element,i=t.parentNode;i&&(i.insertBefore(e,t),i.removeChild(t))},e.prototype.addLoadingState=function(){R(this.element,this.classNames.loadingState),this.element.setAttribute("aria-busy","true"),this.isLoading=!0},e.prototype.removeLoadingState=function(){K(this.element,this.classNames.loadingState),this.element.removeAttribute("aria-busy"),this.isLoading=!1},e}(),q=function(){function e(e){var t=e.element,i=e.type,n=e.classNames,s=e.preventPaste;this.element=t,this.type=i,this.classNames=n,this.preventPaste=s,this.isFocussed=this.element.isEqualNode(document.activeElement),this.isDisabled=t.disabled,this._onPaste=this._onPaste.bind(this),this._onInput=this._onInput.bind(this),this._onFocus=this._onFocus.bind(this),this._onBlur=this._onBlur.bind(this)}return Object.defineProperty(e.prototype,"placeholder",{set:function(e){this.element.placeholder=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"value",{get:function(){return this.element.value},set:function(e){this.element.value=e},enumerable:!1,configurable:!0}),e.prototype.addEventListeners=function(){var e=this.element;e.addEventListener("paste",this._onPaste),e.addEventListener("input",this._onInput,{passive:!0}),e.addEventListener("focus",this._onFocus,{passive:!0}),e.addEventListener("blur",this._onBlur,{passive:!0})},e.prototype.removeEventListeners=function(){var e=this.element;e.removeEventListener("input",this._onInput),e.removeEventListener("paste",this._onPaste),e.removeEventListener("focus",this._onFocus),e.removeEventListener("blur",this._onBlur)},e.prototype.enable=function(){this.element.removeAttribute("disabled"),this.isDisabled=!1},e.prototype.disable=function(){this.element.setAttribute("disabled",""),this.isDisabled=!0},e.prototype.focus=function(){this.isFocussed||this.element.focus()},e.prototype.blur=function(){this.isFocussed&&this.element.blur()},e.prototype.clear=function(e){return void 0===e&&(e=!0),this.element.value="",e&&this.setWidth(),this},e.prototype.setWidth=function(){var e=this.element;e.style.minWidth="".concat(e.placeholder.length+1,"ch"),e.style.width="".concat(e.value.length+1,"ch")},e.prototype.setActiveDescendant=function(e){this.element.setAttribute("aria-activedescendant",e)},e.prototype.removeActiveDescendant=function(){this.element.removeAttribute("aria-activedescendant")},e.prototype._onInput=function(){this.type!==_&&this.setWidth()},e.prototype._onPaste=function(e){this.preventPaste&&e.preventDefault()},e.prototype._onFocus=function(){this.isFocussed=!0},e.prototype._onBlur=function(){this.isFocussed=!1},e}(),$=function(){function e(e){this.element=e.element,this.scrollPos=this.element.scrollTop,this.height=this.element.offsetHeight}return e.prototype.prepend=function(e){var t=this.element.firstElementChild;t?this.element.insertBefore(e,t):this.element.append(e)},e.prototype.scrollToTop=function(){this.element.scrollTop=0},e.prototype.scrollToChildElement=function(e,t){var i=this;if(e){var n=t>0?this.element.scrollTop+(e.offsetTop+e.offsetHeight)-(this.element.scrollTop+this.element.offsetHeight):e.offsetTop;requestAnimationFrame((function(){i._animateScroll(n,t)}))}},e.prototype._scrollDown=function(e,t,i){var n=(i-e)/t;this.element.scrollTop=e+(n>1?n:1)},e.prototype._scrollUp=function(e,t,i){var n=(e-i)/t;this.element.scrollTop=e-(n>1?n:1)},e.prototype._animateScroll=function(e,t){var i=this,n=this.element.scrollTop,s=!1;t>0?(this._scrollDown(n,4,e),ne&&(s=!0)),s&&requestAnimationFrame((function(){i._animateScroll(e,t)}))},e}(),W=function(){function e(e){var t=e.classNames;this.element=e.element,this.classNames=t,this.isDisabled=!1}return Object.defineProperty(e.prototype,"isActive",{get:function(){return"active"===this.element.dataset.choice},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"dir",{get:function(){return this.element.dir},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"value",{get:function(){return this.element.value},set:function(e){this.element.setAttribute("value",e),this.element.value=e},enumerable:!1,configurable:!0}),e.prototype.conceal=function(){var e=this.element;R(e,this.classNames.input),e.hidden=!0,e.tabIndex=-1;var t=e.getAttribute("style");t&&e.setAttribute("data-choice-orig-style",t),e.setAttribute("data-choice","active")},e.prototype.reveal=function(){var e=this.element;K(e,this.classNames.input),e.hidden=!1,e.removeAttribute("tabindex");var t=e.getAttribute("data-choice-orig-style");t?(e.removeAttribute("data-choice-orig-style"),e.setAttribute("style",t)):e.removeAttribute("style"),e.removeAttribute("data-choice")},e.prototype.enable=function(){this.element.removeAttribute("disabled"),this.element.disabled=!1,this.isDisabled=!1},e.prototype.disable=function(){this.element.setAttribute("disabled",""),this.element.disabled=!0,this.isDisabled=!0},e.prototype.triggerEvent=function(e,t){var i;void 0===(i=t||{})&&(i=null),this.element.dispatchEvent(new CustomEvent(e,{detail:i,bubbles:!0,cancelable:!0}))},e}(),U=function(e){function i(){return null!==e&&e.apply(this,arguments)||this}return t(i,e),i}(W),G=function(e,t){return void 0===t&&(t=!0),void 0===e?t:!!e},z=function(e){if("string"==typeof e&&(e=e.split(" ").filter((function(e){return e.length}))),Array.isArray(e)&&e.length)return e},J=function(e,t,i){if(void 0===i&&(i=!0),"string"==typeof e){var n=A(e);return J({value:e,label:i||n===e?e:{escaped:n,raw:e},selected:!0},!1)}var s=e;if("choices"in s){if(!t)throw new TypeError("optGroup is not allowed");var o=s,r=o.choices.map((function(e){return J(e,!1)}));return{id:0,label:L(o.label)||o.value,active:!!r.length,disabled:!!o.disabled,choices:r}}var c=s;return{id:0,group:null,score:0,rank:0,value:c.value,label:c.label||c.value,active:G(c.active),selected:G(c.selected,!1),disabled:G(c.disabled,!1),placeholder:G(c.placeholder,!1),highlighted:!1,labelClass:z(c.labelClass),labelDescription:c.labelDescription,customProperties:c.customProperties}},X=function(e){return"SELECT"===e.tagName},Q=function(e){function i(t){var i=t.template,n=t.extractPlaceholder,s=e.call(this,{element:t.element,classNames:t.classNames})||this;return s.template=i,s.extractPlaceholder=n,s}return t(i,e),Object.defineProperty(i.prototype,"placeholderOption",{get:function(){return this.element.querySelector('option[value=""]')||this.element.querySelector("option[placeholder]")},enumerable:!1,configurable:!0}),i.prototype.addOptions=function(e){var t=this,i=document.createDocumentFragment();e.forEach((function(e){var n=e;if(!n.element){var s=t.template(n);i.appendChild(s),n.element=s}})),this.element.appendChild(i)},i.prototype.optionsAsChoices=function(){var e=this,t=[];return this.element.querySelectorAll(":scope > option, :scope > optgroup").forEach((function(i){!function(e){return"OPTION"===e.tagName}(i)?function(e){return"OPTGROUP"===e.tagName}(i)&&t.push(e._optgroupToChoice(i)):t.push(e._optionToChoice(i))})),t},i.prototype._optionToChoice=function(e){return!e.hasAttribute("value")&&e.hasAttribute("placeholder")&&(e.setAttribute("value",""),e.value=""),{id:0,group:null,score:0,rank:0,value:e.value,label:e.label,element:e,active:!0,selected:this.extractPlaceholder?e.selected:e.hasAttribute("selected"),disabled:e.disabled,highlighted:!1,placeholder:this.extractPlaceholder&&(!e.value||e.hasAttribute("placeholder")),labelClass:void 0!==e.dataset.labelClass?z(e.dataset.labelClass):void 0,labelDescription:void 0!==e.dataset.labelDescription?{trusted:e.dataset.labelDescription}:void 0,customProperties:V(e.dataset.customProperties)}},i.prototype._optgroupToChoice=function(e){var t=this,i=e.querySelectorAll("option"),n=Array.from(i).map((function(e){return t._optionToChoice(e)}));return{id:0,label:e.label||"",element:e,active:!!n.length,disabled:e.disabled,choices:n}},i}(W),Y={items:[],choices:[],silent:!1,renderChoiceLimit:-1,maxItemCount:-1,closeDropdownOnSelect:"auto",singleModeForMultiSelect:!1,addChoices:!1,addItems:!0,addItemFilter:function(e){return!!e&&""!==e},removeItems:!0,removeItemButton:!1,removeItemButtonAlignLeft:!1,editItems:!1,allowHTML:!1,allowHtmlUserInput:!1,duplicateItemsAllowed:!0,delimiter:",",paste:!0,searchEnabled:!0,searchChoices:!0,searchDisabledChoices:!1,searchFloor:1,searchResultLimit:4,searchFields:["label","value"],position:"auto",resetScrollPosition:!0,shouldSort:!0,shouldSortItems:!1,sorter:function(e,t){var i=e.label,n=t.label,s=void 0===n?t.value:n;return L(void 0===i?e.value:i).localeCompare(L(s),[],{sensitivity:"base",ignorePunctuation:!0,numeric:!0})},shadowRoot:null,placeholder:!0,placeholderValue:null,searchPlaceholderValue:null,prependValue:null,appendValue:null,renderSelectedChoices:"auto",searchRenderSelectedChoices:!0,loadingText:"Loading...",noResultsText:"No results found",noChoicesText:"No choices to choose from",itemSelectText:"Press to select",uniqueItemText:"Only unique values can be added",customAddItemText:"Only values matching specific conditions can be added",addItemText:function(e){return'Press Enter to add "'.concat(e,'"')},removeItemIconText:function(){return"Remove item"},removeItemLabelText:function(e,t,i){return"Remove item: ".concat(i?A(i.label):e)},maxItemText:function(e){return"Only ".concat(e," values can be added")},valueComparer:function(e,t){return e===t},fuseOptions:{includeScore:!0},labelId:"",callbackOnInit:null,callbackOnCreateTemplates:null,classNames:{containerOuter:["choices"],containerInner:["choices__inner"],input:["choices__input"],inputCloned:["choices__input--cloned"],list:["choices__list"],listItems:["choices__list--multiple"],listSingle:["choices__list--single"],listDropdown:["choices__list--dropdown"],item:["choices__item"],itemSelectable:["choices__item--selectable"],itemDisabled:["choices__item--disabled"],itemChoice:["choices__item--choice"],description:["choices__description"],placeholder:["choices__placeholder"],group:["choices__group"],groupHeading:["choices__heading"],button:["choices__button"],activeState:["is-active"],focusState:["is-focused"],openState:["is-open"],disabledState:["is-disabled"],highlightedState:["is-highlighted"],selectedState:["is-selected"],flippedState:["is-flipped"],loadingState:["is-loading"],invalidState:["is-invalid"],notice:["choices__notice"],addChoice:["choices__item--selectable","add-choice"],noResults:["has-no-results"],noChoices:["has-no-choices"]},appendGroupInSearch:!1},Z=function(e){var t=e.itemEl;t&&(t.remove(),e.itemEl=void 0)},ee={groups:function(e,t){var i=e,n=!0;switch(t.type){case l:i.push(t.group);break;case h:i=[];break;default:n=!1}return{state:i,update:n}},items:function(e,t,i){var n=e,s=!0;switch(t.type){case u:t.item.selected=!0,(o=t.item.element)&&(o.selected=!0,o.setAttribute("selected","")),n.push(t.item);break;case d:var o;if(t.item.selected=!1,o=t.item.element){o.selected=!1,o.removeAttribute("selected");var c=o.parentElement;c&&X(c)&&c.type===_&&(c.value="")}Z(t.item),n=n.filter((function(e){return e.id!==t.item.id}));break;case r:Z(t.choice),n=n.filter((function(e){return e.id!==t.choice.id}));break;case p:var a=t.highlighted,h=n.find((function(e){return e.id===t.item.id}));h&&h.highlighted!==a&&(h.highlighted=a,i&&function(e,t,i){var n=e.itemEl;n&&(K(n,i),R(n,t))}(h,a?i.classNames.highlightedState:i.classNames.selectedState,a?i.classNames.selectedState:i.classNames.highlightedState));break;default:s=!1}return{state:n,update:s}},choices:function(e,t,i){var n=e,s=!0;switch(t.type){case o:n.push(t.choice);break;case r:t.choice.choiceEl=void 0,t.choice.group&&(t.choice.group.choices=t.choice.group.choices.filter((function(e){return e.id!==t.choice.id}))),n=n.filter((function(e){return e.id!==t.choice.id}));break;case u:case d:t.item.choiceEl=void 0;break;case c:var l=[];t.results.forEach((function(e){l[e.item.id]=e})),n.forEach((function(e){var t=l[e.id];void 0!==t?(e.score=t.score,e.rank=t.rank,e.active=!0):(e.score=0,e.rank=0,e.active=!1),i&&i.appendGroupInSearch&&(e.choiceEl=void 0)}));break;case a:n.forEach((function(e){e.active=t.active,i&&i.appendGroupInSearch&&(e.choiceEl=void 0)}));break;case h:n=[];break;default:s=!1}return{state:n,update:s}}},te=function(){function e(e){this._state=this.defaultState,this._listeners=[],this._txn=0,this._context=e}return Object.defineProperty(e.prototype,"defaultState",{get:function(){return{groups:[],items:[],choices:[]}},enumerable:!1,configurable:!0}),e.prototype.changeSet=function(e){return{groups:e,items:e,choices:e}},e.prototype.reset=function(){this._state=this.defaultState;var e=this.changeSet(!0);this._txn?this._changeSet=e:this._listeners.forEach((function(t){return t(e)}))},e.prototype.subscribe=function(e){return this._listeners.push(e),this},e.prototype.dispatch=function(e){var t=this,i=this._state,n=!1,s=this._changeSet||this.changeSet(!1);Object.keys(ee).forEach((function(o){var r=ee[o](i[o],e,t._context);r.update&&(n=!0,s[o]=!0,i[o]=r.state)})),n&&(this._txn?this._changeSet=s:this._listeners.forEach((function(e){return e(s)})))},e.prototype.withTxn=function(e){this._txn++;try{e()}finally{if(this._txn=Math.max(0,this._txn-1),!this._txn){var t=this._changeSet;t&&(this._changeSet=void 0,this._listeners.forEach((function(e){return e(t)})))}}},Object.defineProperty(e.prototype,"state",{get:function(){return this._state},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"items",{get:function(){return this.state.items},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"highlightedActiveItems",{get:function(){return this.items.filter((function(e){return e.active&&e.highlighted}))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"choices",{get:function(){return this.state.choices},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"activeChoices",{get:function(){return this.choices.filter((function(e){return e.active}))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"searchableChoices",{get:function(){var e=this._context;return this.choices.filter((function(t){return!t.placeholder&&(e.searchDisabledChoices||!t.disabled)}))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"groups",{get:function(){return this.state.groups},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"activeGroups",{get:function(){var e=this;return this.state.groups.filter((function(t){var i=t.active&&!t.disabled,n=e.state.choices.some((function(e){return e.active&&!e.disabled}));return i&&n}),[])},enumerable:!1,configurable:!0}),e.prototype.inTxn=function(){return this._txn>0},e.prototype.getChoiceById=function(e){return this.activeChoices.find((function(t){return t.id===e}))},e.prototype.getGroupById=function(e){return this.groups.find((function(t){return t.id===e}))},e}(),ie="no-choices",ne="no-results",se="add-choice";function oe(e,t,i){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var n=i.call(e,t);if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function re(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function ce(e){for(var t=1;t`Missing ${e} property in key`,ve=e=>`Property 'weight' in key '${e}' must be a positive integer`,ge=Object.prototype.hasOwnProperty;class _e{constructor(e){this._keys=[],this._keyMap={};let t=0;e.forEach((e=>{let i=ye(e);this._keys.push(i),this._keyMap[i.id]=i,t+=i.weight})),this._keys.forEach((e=>{e.weight/=t}))}get(e){return this._keyMap[e]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function ye(e){let t=null,i=null,n=null,s=1,o=null;if(he(e)||ae(e))n=e,t=be(e),i=Ee(e);else{if(!ge.call(e,"name"))throw new Error(me("name"));const r=e.name;if(n=r,ge.call(e,"weight")&&(s=e.weight,s<=0))throw new Error(ve(r));t=be(r),i=Ee(r),o=e.getFn}return{path:t,id:i,weight:s,src:n,getFn:o}}function be(e){return ae(e)?e:e.split(".")}function Ee(e){return ae(e)?e.join("."):e}const Se={useExtendedSearch:!1,getFn:function(e,t){let i=[],n=!1;const s=(e,t,o)=>{if(de(e))if(t[o]){const r=e[t[o]];if(!de(r))return;if(o===t.length-1&&(he(r)||le(r)||function(e){return!0===e||!1===e||function(e){return ue(e)&&null!==e}(e)&&"[object Boolean]"==fe(e)}(r)))i.push(function(e){return null==e?"":function(e){if("string"==typeof e)return e;let t=e+"";return"0"==t&&1/e==-1/0?"-0":t}(e)}(r));else if(ae(r)){n=!0;for(let e=0,i=r.length;ee.score===t.score?e.idx{this._keysMap[e.id]=t}))}create(){!this.isCreated&&this.docs.length&&(this.isCreated=!0,he(this.docs[0])?this.docs.forEach(((e,t)=>{this._addString(e,t)})):this.docs.forEach(((e,t)=>{this._addObject(e,t)})),this.norm.clear())}add(e){const t=this.size();he(e)?this._addString(e,t):this._addObject(e,t)}removeAt(e){this.records.splice(e,1);for(let t=e,i=this.size();t{let s=t.getFn?t.getFn(e):this.getFn(e,t.path);if(de(s))if(ae(s)){let e=[];const t=[{nestedArrIndex:-1,value:s}];for(;t.length;){const{nestedArrIndex:i,value:n}=t.pop();if(de(n))if(he(n)&&!pe(n)){let t={v:n,i:i,n:this.norm.get(n)};e.push(t)}else ae(n)&&n.forEach(((e,i)=>{t.push({nestedArrIndex:i,value:e})}))}i.$[n]=e}else if(he(s)&&!pe(s)){let e={v:s,n:this.norm.get(s)};i.$[n]=e}})),this.records.push(i)}toJSON(){return{keys:this.keys,records:this.records}}}function Ae(e,t,{getFn:i=Ce.getFn,fieldNormWeight:n=Ce.fieldNormWeight}={}){const s=new Ie({getFn:i,fieldNormWeight:n});return s.setKeys(e.map(ye)),s.setSources(t),s.create(),s}function xe(e,{errors:t=0,currentLocation:i=0,expectedLocation:n=0,distance:s=Ce.distance,ignoreLocation:o=Ce.ignoreLocation}={}){const r=t/e.length;if(o)return r;const c=Math.abs(n-i);return s?r+c/s:c?1:r}const Oe=32;function Le(e){let t={};for(let i=0,n=e.length;i{this.chunks.push({pattern:e,alphabet:Le(e),startIndex:t})},l=this.pattern.length;if(l>Oe){let e=0;const t=l%Oe,i=l-t;for(;e{const{isMatch:f,score:m,indices:v}=function(e,t,i,{location:n=Ce.location,distance:s=Ce.distance,threshold:o=Ce.threshold,findAllMatches:r=Ce.findAllMatches,minMatchCharLength:c=Ce.minMatchCharLength,includeMatches:a=Ce.includeMatches,ignoreLocation:h=Ce.ignoreLocation}={}){if(t.length>Oe)throw new Error("Pattern length exceeds max of 32.");const l=t.length,u=e.length,d=Math.max(0,Math.min(n,u));let p=o,f=d;const m=c>1||a,v=m?Array(u):[];let g;for(;(g=e.indexOf(t,f))>-1;){let e=xe(t,{currentLocation:g,expectedLocation:d,distance:s,ignoreLocation:h});if(p=Math.min(e,p),f=g+l,m){let e=0;for(;e=a;o-=1){let r=o-1,c=i[e.charAt(r)];if(m&&(v[r]=+!!c),S[o]=(S[o+1]<<1|1)&c,n&&(S[o]|=(_[o+1]|_[o])<<1|1|_[o+1]),S[o]&E&&(y=xe(t,{errors:n,currentLocation:r,expectedLocation:d,distance:s,ignoreLocation:h}),y<=p)){if(p=y,f=r,f<=d)break;a=Math.max(1,2*d-f)}}if(xe(t,{errors:n+1,currentLocation:d,expectedLocation:d,distance:s,ignoreLocation:h})>p)break;_=S}const S={isMatch:f>=0,score:Math.max(.001,y)};if(m){const e=function(e=[],t=Ce.minMatchCharLength){let i=[],n=-1,s=-1,o=0;for(let r=e.length;o=t&&i.push([n,s]),n=-1)}return e[o-1]&&o-n>=t&&i.push([n,o-1]),i}(v,c);e.length?a&&(S.indices=e):S.isMatch=!1}return S}(e,t,d,{location:n+p,distance:s,threshold:o,findAllMatches:r,minMatchCharLength:c,includeMatches:i,ignoreLocation:a});f&&(u=!0),l+=m,f&&v&&(h=[...h,...v])}));let d={isMatch:u,score:u?l/this.chunks.length:1};return u&&i&&(d.indices=h),d}}class Te{constructor(e){this.pattern=e}static isMultiMatch(e){return Ne(e,this.multiRegex)}static isSingleMatch(e){return Ne(e,this.singleRegex)}search(){}}function Ne(e,t){const i=e.match(t);return i?i[1]:null}class ke extends Te{constructor(e,{location:t=Ce.location,threshold:i=Ce.threshold,distance:n=Ce.distance,includeMatches:s=Ce.includeMatches,findAllMatches:o=Ce.findAllMatches,minMatchCharLength:r=Ce.minMatchCharLength,isCaseSensitive:c=Ce.isCaseSensitive,ignoreLocation:a=Ce.ignoreLocation}={}){super(e),this._bitapSearch=new Me(e,{location:t,threshold:i,distance:n,includeMatches:s,findAllMatches:o,minMatchCharLength:r,isCaseSensitive:c,ignoreLocation:a})}static get type(){return"fuzzy"}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(e){return this._bitapSearch.searchIn(e)}}class De extends Te{constructor(e){super(e)}static get type(){return"include"}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(e){let t,i=0;const n=[],s=this.pattern.length;for(;(t=e.indexOf(this.pattern,i))>-1;)i=t+s,n.push([t,i-1]);const o=!!n.length;return{isMatch:o,score:o?0:1,indices:n}}}const Fe=[class extends Te{constructor(e){super(e)}static get type(){return"exact"}static get multiRegex(){return/^="(.*)"$/}static get singleRegex(){return/^=(.*)$/}search(e){const t=e===this.pattern;return{isMatch:t,score:t?0:1,indices:[0,this.pattern.length-1]}}},De,class extends Te{constructor(e){super(e)}static get type(){return"prefix-exact"}static get multiRegex(){return/^\^"(.*)"$/}static get singleRegex(){return/^\^(.*)$/}search(e){const t=e.startsWith(this.pattern);return{isMatch:t,score:t?0:1,indices:[0,this.pattern.length-1]}}},class extends Te{constructor(e){super(e)}static get type(){return"inverse-prefix-exact"}static get multiRegex(){return/^!\^"(.*)"$/}static get singleRegex(){return/^!\^(.*)$/}search(e){const t=!e.startsWith(this.pattern);return{isMatch:t,score:t?0:1,indices:[0,e.length-1]}}},class extends Te{constructor(e){super(e)}static get type(){return"inverse-suffix-exact"}static get multiRegex(){return/^!"(.*)"\$$/}static get singleRegex(){return/^!(.*)\$$/}search(e){const t=!e.endsWith(this.pattern);return{isMatch:t,score:t?0:1,indices:[0,e.length-1]}}},class extends Te{constructor(e){super(e)}static get type(){return"suffix-exact"}static get multiRegex(){return/^"(.*)"\$$/}static get singleRegex(){return/^(.*)\$$/}search(e){const t=e.endsWith(this.pattern);return{isMatch:t,score:t?0:1,indices:[e.length-this.pattern.length,e.length-1]}}},class extends Te{constructor(e){super(e)}static get type(){return"inverse-exact"}static get multiRegex(){return/^!"(.*)"$/}static get singleRegex(){return/^!(.*)$/}search(e){const t=-1===e.indexOf(this.pattern);return{isMatch:t,score:t?0:1,indices:[0,e.length-1]}}},ke],Pe=Fe.length,je=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,Re=new Set([ke.type,De.type]);const Ke=[];function Ve(e,t){for(let i=0,n=Ke.length;i!(!e[Be]&&!e.$or),$e=e=>({[Be]:Object.keys(e).map((t=>({[t]:e[t]})))});function We(e,t,{auto:i=!0}={}){const n=e=>{let s=Object.keys(e);const o=(e=>!!e[He])(e);if(!o&&s.length>1&&!qe(e))return n($e(e));if((e=>!ae(e)&&ue(e)&&!qe(e))(e)){const n=o?e[He]:s[0],r=o?e.$val:e[n];if(!he(r))throw new Error((e=>`Invalid value for key ${e}`)(n));const c={keyId:Ee(n),pattern:r};return i&&(c.searcher=Ve(r,t)),c}let r={children:[],operator:s[0]};return s.forEach((t=>{const i=e[t];ae(i)&&i.forEach((e=>{r.children.push(n(e))}))})),r};return qe(e)||(e=$e(e)),n(e)}function Ue(e,t){const i=e.matches;t.matches=[],de(i)&&i.forEach((e=>{if(!de(e.indices)||!e.indices.length)return;const{indices:i,value:n}=e;let s={indices:i,value:n};e.key&&(s.key=e.key.src),e.idx>-1&&(s.refIndex=e.idx),t.matches.push(s)}))}function Ge(e,t){t.score=e.score}class ze{constructor(e,t={},i){this.options=ce(ce({},Ce),t),this._keyStore=new _e(this.options.keys),this.setCollection(e,i)}setCollection(e,t){if(this._docs=e,t&&!(t instanceof Ie))throw new Error("Incorrect 'index' type");this._myIndex=t||Ae(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(e){de(e)&&(this._docs.push(e),this._myIndex.add(e))}remove(e=()=>!1){const t=[];for(let i=0,n=this._docs.length;i{let i=1;e.matches.forEach((({key:e,norm:n,score:s})=>{const o=e?e.weight:null;i*=Math.pow(0===s&&o?Number.EPSILON:s,(o||1)*(t?1:n))})),e.score=i}))}(c,{ignoreFieldNorm:r}),s&&c.sort(o),le(t)&&t>-1&&(c=c.slice(0,t)),function(e,t,{includeMatches:i=Ce.includeMatches,includeScore:n=Ce.includeScore}={}){const s=[];return i&&s.push(Ue),n&&s.push(Ge),e.map((e=>{const{idx:i}=e,n={item:t[i],refIndex:i};return s.length&&s.forEach((t=>{t(e,n)})),n}))}(c,this._docs,{includeMatches:i,includeScore:n})}_searchStringList(e){const t=Ve(e,this.options),{records:i}=this._myIndex,n=[];return i.forEach((({v:e,i:i,n:s})=>{if(!de(e))return;const{isMatch:o,score:r,indices:c}=t.searchIn(e);o&&n.push({item:e,idx:i,matches:[{score:r,value:e,norm:s,indices:c}]})})),n}_searchLogical(e){const t=We(e,this.options),i=(e,t,n)=>{if(!e.children){const{keyId:i,searcher:s}=e,o=this._findMatches({key:this._keyStore.get(i),value:this._myIndex.getValueForItemAtKeyId(t,i),searcher:s});return o&&o.length?[{idx:n,item:t,matches:o}]:[]}const s=[];for(let o=0,r=e.children.length;o{if(de(e)){let r=i(t,e,o);r.length&&(n[o]||(n[o]={idx:o,item:e,matches:[]},s.push(n[o])),r.forEach((({matches:e})=>{n[o].matches.push(...e)})))}})),s}_searchObjectList(e){const t=Ve(e,this.options),{keys:i,records:n}=this._myIndex,s=[];return n.forEach((({$:e,i:n})=>{if(!de(e))return;let o=[];i.forEach(((i,n)=>{o.push(...this._findMatches({key:i,value:e[n],searcher:t}))})),o.length&&s.push({idx:n,item:e,matches:o})})),s}_findMatches({key:e,value:t,searcher:i}){if(!de(t))return[];let n=[];if(ae(t))t.forEach((({v:t,i:s,n:o})=>{if(!de(t))return;const{isMatch:r,score:c,indices:a}=i.searchIn(t);r&&n.push({score:c,key:e,value:t,idx:s,norm:o,indices:a})}));else{const{v:s,n:o}=t,{isMatch:r,score:c,indices:a}=i.searchIn(s);r&&n.push({score:c,key:e,value:s,norm:o,indices:a})}return n}}ze.version="7.0.0",ze.createIndex=Ae,ze.parseIndex=function(e,{getFn:t=Ce.getFn,fieldNormWeight:i=Ce.fieldNormWeight}={}){const{keys:n,records:s}=e,o=new Ie({getFn:t,fieldNormWeight:i});return o.setKeys(n),o.setIndexRecords(s),o},ze.config=Ce,ze.parseQuery=We,function(...e){Ke.push(...e)}(class{constructor(e,{isCaseSensitive:t=Ce.isCaseSensitive,includeMatches:i=Ce.includeMatches,minMatchCharLength:n=Ce.minMatchCharLength,ignoreLocation:s=Ce.ignoreLocation,findAllMatches:o=Ce.findAllMatches,location:r=Ce.location,threshold:c=Ce.threshold,distance:a=Ce.distance}={}){this.query=null,this.options={isCaseSensitive:t,includeMatches:i,minMatchCharLength:n,findAllMatches:o,ignoreLocation:s,location:r,threshold:c,distance:a},this.pattern=t?e:e.toLowerCase(),this.query=function(e,t={}){return e.split("|").map((e=>{let i=e.trim().split(je).filter((e=>e&&!!e.trim())),n=[];for(let e=0,s=i.length;e element"),this)},e.prototype.removeChoice=function(e){var t=this._store.choices.find((function(t){return t.value===e}));return t?(this._clearNotice(),this._store.dispatch(function(e){return{type:r,choice:e}}(t)),this._searcher.reset(),t.selected&&this.passedElement.triggerEvent(m,T(t)),this):this},e.prototype.clearChoices=function(e,t){var i=this;return void 0===e&&(e=!0),void 0===t&&(t=!1),e&&(t?this.passedElement.element.replaceChildren(""):this.passedElement.element.querySelectorAll(":not([selected])").forEach((function(e){e.remove()}))),this.itemList.element.replaceChildren(""),this.choiceList.element.replaceChildren(""),this._clearNotice(),this._store.withTxn((function(){var e=t?[]:i._store.items;i._store.reset(),e.forEach((function(e){i._store.dispatch(b(e)),i._store.dispatch(E(e))}))})),this._searcher.reset(),this},e.prototype.clearStore=function(e){return void 0===e&&(e=!0),this.clearChoices(e,!0),this._stopSearch(),this._lastAddedChoiceId=0,this._lastAddedGroupId=0,this},e.prototype.clearInput=function(){return this.input.clear(!this._isSelectOneElement),this._stopSearch(),this},e.prototype._validateConfig=function(){var e,t,i,n=this.config,s=(e=Y,t=Object.keys(n).sort(),i=Object.keys(e).sort(),t.filter((function(e){return i.indexOf(e)<0})));s.length&&console.warn("Unknown config option(s) passed",s.join(", ")),n.allowHTML&&n.allowHtmlUserInput&&(n.addItems&&console.warn("Warning: allowHTML/allowHtmlUserInput/addItems all being true is strongly not recommended and may lead to XSS attacks"),n.addChoices&&console.warn("Warning: allowHTML/allowHtmlUserInput/addChoices all being true is strongly not recommended and may lead to XSS attacks"))},e.prototype._render=function(e){void 0===e&&(e={choices:!0,groups:!0,items:!0}),this._store.inTxn()||(this._isSelectElement&&(e.choices||e.groups)&&this._renderChoices(),e.items&&this._renderItems())},e.prototype._renderChoices=function(){var e=this;if(this._canAddItems()){var t=this.config,i=this._isSearching,n=this._store,s=n.activeGroups,o=n.activeChoices,r=i?t.searchResultLimit:t.renderChoiceLimit;if(this._isSelectElement){var c=o.filter((function(e){return!e.element}));c.length&&this.passedElement.addOptions(c)}var a=document.createDocumentFragment(),h=function(e){return e.filter((function(e){return!e.placeholder&&(i?(t.searchRenderSelectedChoices||!e.selected)&&!!e.rank:t.renderSelectedChoices||!e.selected)}))},l=t.appendGroupInSearch&&i,u=!1,d=null,p=function(n,s){i?n.sort(F):t.shouldSort&&n.sort(t.sorter);var o=n.length;o=!s&&r>0&&o>r?r:o,o--,n.every((function(n,s){var r=n.choiceEl||e._templates.choice(t,n,t.itemSelectText,l&&n.group?n.group.label:void 0);return n.choiceEl=r,a.appendChild(r),i||!n.selected?u=!0:d||(d=r),s1){var h=i.querySelector(j(n.classNames.placeholder));h&&h.remove()}else c||a||!this._placeholderValue||(c=!0,r(J({selected:!0,value:"",label:this._placeholderValue,placeholder:!0},!1)))}c&&(i.append(s),n.shouldSortItems&&!this._isSelectOneElement&&(t.sort(n.sorter),t.forEach((function(e){var t=o(e);t&&(t.remove(),s.append(t))})),i.append(s))),this._isTextElement&&(this.passedElement.value=t.map((function(e){return e.value})).join(n.delimiter))},e.prototype._displayNotice=function(e,t,i){void 0===i&&(i=!0);var n=this._notice;n&&(n.type===t&&n.text===e||n.type===se&&(t===ne||t===ie))?i&&this.showDropdown(!0):(this._clearNotice(),this._notice=e?{text:e,type:t}:void 0,this._renderNotice(),i&&e&&this.showDropdown(!0))},e.prototype._clearNotice=function(){if(this._notice){var e=this.choiceList.element.querySelector(j(this.config.classNames.notice));e&&e.remove(),this._notice=void 0}},e.prototype._renderNotice=function(e){var t=this._notice;if(t){var i=this._templates.notice(this.config,t.text,t.type);e?e.append(i):this.choiceList.prepend(i)}},e.prototype._getChoiceForOutput=function(e,t){return T(e,t)},e.prototype._triggerChange=function(e){null!=e&&this.passedElement.triggerEvent("change",{value:e})},e.prototype._handleButtonAction=function(e){var t=this,i=this._store.items;if(i.length&&this.config.removeItems&&this.config.removeItemButton){var n=e&&tt(e.closest("[data-id]")),s=n&&i.find((function(e){return e.id===n}));s&&this._store.withTxn((function(){if(t._removeItem(s),t._triggerChange(s.value),t._isSelectOneElement&&!t._hasNonChoicePlaceholder){var e=(t.config.shouldSort?t._store.choices.reverse():t._store.choices).find((function(e){return e.placeholder}));e&&(t._addItem(e),t.unhighlightAll(),e.value&&t._triggerChange(e.value))}}))}},e.prototype._handleItemAction=function(e,t){var i=this;void 0===t&&(t=!1);var n=this._store.items;if(n.length&&this.config.removeItems&&!this._isSelectOneElement){var s=tt(e);s&&(n.forEach((function(e){e.id!==s||e.highlighted?!t&&e.highlighted&&i.unhighlightItem(e):i.highlightItem(e)})),this.input.focus())}},e.prototype._handleChoiceAction=function(e){var t=this,i=tt(e),n=i&&this._store.getChoiceById(i);if(!n||n.disabled)return!1;var s=this.dropdown.isActive;if(!n.selected){if(!this._canAddItems())return!0;this._store.withTxn((function(){t._addItem(n,!0,!0),t.clearInput(),t.unhighlightAll()})),this._triggerChange(n.value)}return s&&this.config.closeDropdownOnSelect&&(this.hideDropdown(!0),this.containerOuter.element.focus()),!0},e.prototype._handleBackspace=function(e){var t=this.config;if(t.removeItems&&e.length){var i=e[e.length-1],n=e.some((function(e){return e.highlighted}));t.editItems&&!n&&i?(this.input.value=i.value,this.input.setWidth(),this._removeItem(i),this._triggerChange(i.value)):(n||this.highlightItem(i,!1),this.removeHighlightedItems(!0))}},e.prototype._loadChoices=function(){var e,t=this,i=this.config;if(this._isTextElement){if(this._presetChoices=i.items.map((function(e){return J(e,!1)})),this.passedElement.value){var n=this.passedElement.value.split(i.delimiter).map((function(e){return J(e,!1,t.config.allowHtmlUserInput)}));this._presetChoices=this._presetChoices.concat(n)}this._presetChoices.forEach((function(e){e.selected=!0}))}else if(this._isSelectElement){this._presetChoices=i.choices.map((function(e){return J(e,!0)}));var s=this.passedElement.optionsAsChoices();s&&(e=this._presetChoices).push.apply(e,s)}},e.prototype._handleLoadingState=function(e){void 0===e&&(e=!0);var t=this.itemList.element;e?(this.disable(),this.containerOuter.addLoadingState(),this._isSelectOneElement?t.replaceChildren(this._templates.placeholder(this.config,this.config.loadingText)):this.input.placeholder=this.config.loadingText):(this.enable(),this.containerOuter.removeLoadingState(),this._isSelectOneElement?(t.replaceChildren(""),this._render()):this.input.placeholder=this._placeholderValue||"")},e.prototype._handleSearch=function(e){if(this.input.isFocussed)if(null!=e&&e.length>=this.config.searchFloor){var t=this.config.searchChoices?this._searchChoices(e):0;null!==t&&this.passedElement.triggerEvent(f,{value:e,resultCount:t})}else this._store.choices.some((function(e){return!e.active}))&&this._stopSearch()},e.prototype._canAddItems=function(){var e=this.config,t=e.maxItemCount,i=e.maxItemText;return!e.singleModeForMultiSelect&&t>0&&t<=this._store.items.length?(this.choiceList.element.replaceChildren(""),this._notice=void 0,this._displayNotice("function"==typeof i?i(t):i,se),!1):(this._notice&&this._notice.type===se&&this._clearNotice(),!0)},e.prototype._canCreateItem=function(e){var t=this.config,i=!0,n="";if(i&&"function"==typeof t.addItemFilter&&!t.addItemFilter(e)&&(i=!1,n=N(t.customAddItemText,e,void 0)),i&&this._store.choices.find((function(i){return t.valueComparer(i.value,e)}))){if(this._isSelectElement)return this._displayNotice("",se),!1;t.duplicateItemsAllowed||(i=!1,n=N(t.uniqueItemText,e,void 0))}return i&&(n=N(t.addItemText,e,void 0)),n&&this._displayNotice(n,se),i},e.prototype._searchChoices=function(e){var t=e.trim().replace(/\s{2,}/," ");if(!t.length||t===this._currentValue)return null;var i=this._searcher;i.isEmptyIndex()&&i.index(this._store.searchableChoices);var n=i.search(t);this._currentValue=t,this._highlightPosition=0,this._isSearching=!0;var s=this._notice;return(s&&s.type)!==se&&(n.length?this._clearNotice():this._displayNotice(O(this.config.noResultsText),ne)),this._store.dispatch(function(e){return{type:c,results:e}}(n)),n.length},e.prototype._stopSearch=function(){this._isSearching&&(this._currentValue="",this._isSearching=!1,this._clearNotice(),this._store.dispatch({type:a,active:!0}),this.passedElement.triggerEvent(f,{value:"",resultCount:0}))},e.prototype._addEventListeners=function(){var e=this._docRoot,t=this.containerOuter.element,i=this.input.element,n=this.passedElement.element;e.addEventListener("touchend",this._onTouchEnd,!0),t.addEventListener("keydown",this._onKeyDown,!0),t.addEventListener("mousedown",this._onMouseDown,!0),e.addEventListener("click",this._onClick,{passive:!0}),e.addEventListener("touchmove",this._onTouchMove,{passive:!0}),this.dropdown.element.addEventListener("mouseover",this._onMouseOver,{passive:!0}),this._isSelectOneElement&&(t.addEventListener("focus",this._onFocus,{passive:!0}),t.addEventListener("blur",this._onBlur,{passive:!0})),i.addEventListener("keyup",this._onKeyUp,{passive:!0}),i.addEventListener("input",this._onInput,{passive:!0}),i.addEventListener("focus",this._onFocus,{passive:!0}),i.addEventListener("blur",this._onBlur,{passive:!0}),i.form&&i.form.addEventListener("reset",this._onFormReset,{passive:!0}),n.hasAttribute("required")&&(n.addEventListener("change",this._onChange,{passive:!0}),n.addEventListener("invalid",this._onInvalid,{passive:!0})),this.input.addEventListeners()},e.prototype._removeEventListeners=function(){var e=this._docRoot,t=this.containerOuter.element,i=this.input.element,n=this.passedElement.element;e.removeEventListener("touchend",this._onTouchEnd,!0),t.removeEventListener("keydown",this._onKeyDown,!0),t.removeEventListener("mousedown",this._onMouseDown,!0),e.removeEventListener("click",this._onClick),e.removeEventListener("touchmove",this._onTouchMove),this.dropdown.element.removeEventListener("mouseover",this._onMouseOver),this._isSelectOneElement&&(t.removeEventListener("focus",this._onFocus),t.removeEventListener("blur",this._onBlur)),i.removeEventListener("keyup",this._onKeyUp),i.removeEventListener("input",this._onInput),i.removeEventListener("focus",this._onFocus),i.removeEventListener("blur",this._onBlur),i.form&&i.form.removeEventListener("reset",this._onFormReset),n.hasAttribute("required")&&(n.removeEventListener("change",this._onChange),n.removeEventListener("invalid",this._onInvalid)),this.input.removeEventListeners()},e.prototype._onKeyDown=function(e){var t=e.keyCode,i=this.dropdown.isActive,n=1===e.key.length||2===e.key.length&&e.key.charCodeAt(0)>=55296||"Unidentified"===e.key;switch(this._isTextElement||i||27===t||9===t||16===t||(this.showDropdown(),!this.input.isFocussed&&n&&(this.input.value+=e.key," "===e.key&&e.preventDefault())),t){case 65:return this._onSelectKey(e,this.itemList.element.hasChildNodes());case 13:return this._onEnterKey(e,i);case 27:return this._onEscapeKey(e,i);case 38:case 33:case 40:case 34:return this._onDirectionKey(e,i);case 8:case 46:return this._onDeleteKey(e,this._store.items,this.input.isFocussed)}},e.prototype._onKeyUp=function(){this._canSearch=this.config.searchEnabled},e.prototype._onInput=function(){var e=this.input.value;e?this._canAddItems()&&(this._canSearch&&this._handleSearch(e),this._canAddUserChoices&&(this._canCreateItem(e),this._isSelectElement&&(this._highlightPosition=0,this._highlightChoice()))):this._isTextElement?this.hideDropdown(!0):this._stopSearch()},e.prototype._onSelectKey=function(e,t){(e.ctrlKey||e.metaKey)&&t&&(this._canSearch=!1,this.config.removeItems&&!this.input.value&&this.input.element===document.activeElement&&this.highlightAll())},e.prototype._onEnterKey=function(e,t){var i=this,n=this.input.value,s=e.target;if(e.preventDefault(),s&&s.hasAttribute("data-button"))this._handleButtonAction(s);else if(t){var o=this.dropdown.element.querySelector(j(this.config.classNames.highlightedState));if(!o||!this._handleChoiceAction(o))if(s&&n){if(this._canAddItems()){var r=!1;this._store.withTxn((function(){if(!(r=i._findAndSelectChoiceByValue(n,!0))){if(!i._canAddUserChoices)return;if(!i._canCreateItem(n))return;i._addChoice(J(n,!1,i.config.allowHtmlUserInput),!0,!0),r=!0}i.clearInput(),i.unhighlightAll()})),r&&(this._triggerChange(n),this.config.closeDropdownOnSelect&&this.hideDropdown(!0))}}else this.hideDropdown(!0)}else(this._isSelectElement||this._notice)&&this.showDropdown()},e.prototype._onEscapeKey=function(e,t){t&&(e.stopPropagation(),this.hideDropdown(!0),this._stopSearch(),this.containerOuter.element.focus())},e.prototype._onDirectionKey=function(e,t){var i=e.keyCode;if(t||this._isSelectOneElement){this.showDropdown(),this._canSearch=!1;var n=40===i||34===i?1:-1,s=void 0;if(e.metaKey||34===i||33===i)s=this.dropdown.element.querySelector(n>0?"".concat(it,":last-of-type"):it);else{var o=this.dropdown.element.querySelector(j(this.config.classNames.highlightedState));s=o?function(e,t,i){void 0===i&&(i=1);for(var n="".concat(i>0?"next":"previous","ElementSibling"),s=e[n];s;){if(s.matches(t))return s;s=s[n]}return null}(o,it,n):this.dropdown.element.querySelector(it)}s&&(I(s,this.choiceList.element,n)||this.choiceList.scrollToChildElement(s,n),this._highlightChoice(s)),e.preventDefault()}},e.prototype._onDeleteKey=function(e,t,i){this._isSelectOneElement||e.target.value||!i||(this._handleBackspace(t),e.preventDefault())},e.prototype._onTouchMove=function(){this._wasTap&&(this._wasTap=!1)},e.prototype._onTouchEnd=function(e){var t=(e||e.touches[0]).target;this._wasTap&&this.containerOuter.element.contains(t)&&((t===this.containerOuter.element||t===this.containerInner.element)&&(this._isTextElement?this.input.focus():this._isSelectMultipleElement&&this.showDropdown()),e.stopPropagation()),this._wasTap=!0},e.prototype._onMouseDown=function(e){var t=e.target;if(t instanceof Element){if(Ze&&this.choiceList.element.contains(t)){var i=this.choiceList.element.firstElementChild;this._isScrollingOnIe="ltr"===this._direction?e.offsetX>=i.offsetWidth:e.offsetXthis._highlightPosition?t[this._highlightPosition]:t[t.length-1])||(i=t[0]),R(i,n),i.setAttribute("aria-selected","true"),this.passedElement.triggerEvent("highlightChoice",{el:i}),this.dropdown.isActive&&(this.input.setActiveDescendant(i.id),this.containerOuter.setActiveDescendant(i.id))}},e.prototype._addItem=function(e,t,i){if(void 0===t&&(t=!0),void 0===i&&(i=!1),!e.id)throw new TypeError("item.id must be set before _addItem is called for a choice/item");if((this.config.singleModeForMultiSelect||this._isSelectOneElement)&&this.removeActiveItems(e.id),this._store.dispatch(E(e)),t){var n=T(e);this.passedElement.triggerEvent("addItem",n),i&&this.passedElement.triggerEvent("choice",n)}},e.prototype._removeItem=function(e){if(e.id){this._store.dispatch(S(e));var t=this._notice;t&&t.type===ie&&this._clearNotice(),this.passedElement.triggerEvent(m,T(e))}},e.prototype._addChoice=function(e,t,i){if(void 0===t&&(t=!0),void 0===i&&(i=!1),e.id)throw new TypeError("Can not re-add a choice which has already been added");var n=this.config;if(n.duplicateItemsAllowed||!this._store.choices.find((function(t){return n.valueComparer(t.value,e.value)}))){this._lastAddedChoiceId++,e.id=this._lastAddedChoiceId,e.elementId="".concat(this._baseId,"-").concat(this._idNames.itemChoice,"-").concat(e.id);var s=n.prependValue,o=n.appendValue;s&&(e.value=s+e.value),o&&(e.value+=o.toString()),(s||o)&&e.element&&(e.element.value=e.value),this._clearNotice(),this._store.dispatch(b(e)),e.selected&&this._addItem(e,t,i)}},e.prototype._addGroup=function(e,t){var i=this;if(void 0===t&&(t=!0),e.id)throw new TypeError("Can not re-add a group which has already been added");this._store.dispatch(function(e){return{type:l,group:e}}(e)),e.choices&&(this._lastAddedGroupId++,e.id=this._lastAddedGroupId,e.choices.forEach((function(n){n.group=e,e.disabled&&(n.disabled=!0),i._addChoice(n,t)})))},e.prototype._createTemplates=function(){var e=this,t=this.config.callbackOnCreateTemplates,i={};"function"==typeof t&&(i=t.call(this,x,k,P));var n={};Object.keys(this._templates).forEach((function(t){n[t]=t in i?i[t].bind(e):e._templates[t].bind(e)})),this._templates=n},e.prototype._createElements=function(){var e=this._templates,t=this.config,i=this._isSelectOneElement,n=t.position,s=t.classNames,o=this._elementType;this.containerOuter=new H({element:e.containerOuter(t,this._direction,this._isSelectElement,i,t.searchEnabled,o,t.labelId),classNames:s,type:o,position:n}),this.containerInner=new H({element:e.containerInner(t),classNames:s,type:o,position:n}),this.input=new q({element:e.input(t,this._placeholderValue),classNames:s,type:o,preventPaste:!t.paste}),this.choiceList=new $({element:e.choiceList(t,i)}),this.itemList=new $({element:e.itemList(t,i)}),this.dropdown=new B({element:e.dropdown(t),classNames:s,type:o})},e.prototype._createStructure=function(){var e=this,t=e.containerInner,i=e.containerOuter,n=e.passedElement,s=this.dropdown.element;n.conceal(),t.wrap(n.element),i.wrap(t.element),i.element.appendChild(t.element),i.element.appendChild(s),t.element.appendChild(this.itemList.element),s.appendChild(this.choiceList.element),this._isSelectOneElement?(this.input.placeholder=this.config.searchPlaceholderValue||"",this.config.searchEnabled&&s.insertBefore(this.input.element,s.firstChild)):(this._isSelectMultipleElement&&!this.config.searchEnabled||t.element.appendChild(this.input.element),this._placeholderValue&&(this.input.placeholder=this._placeholderValue),this.input.setWidth()),this._highlightPosition=0,this._isSearching=!1},e.prototype._initStore=function(){var e=this;this._store.subscribe(this._render).withTxn((function(){e._addPredefinedChoices(e._presetChoices,e._isSelectOneElement&&!e._hasNonChoicePlaceholder,!1)})),(!this._store.choices.length||this._isSelectOneElement&&this._hasNonChoicePlaceholder)&&this._render()},e.prototype._addPredefinedChoices=function(e,t,i){var n=this;void 0===t&&(t=!1),void 0===i&&(i=!0),t&&-1===e.findIndex((function(e){return e.selected}))&&e.some((function(e){return!e.disabled&&!("choices"in e)&&(e.selected=!0,!0)})),e.forEach((function(e){"choices"in e?n._isSelectElement&&n._addGroup(e,i):n._addChoice(e,i)}))},e.prototype._findAndSelectChoiceByValue=function(e,t){var i=this;void 0===t&&(t=!1);var n=this._store.choices.find((function(t){return i.config.valueComparer(t.value,e)}));return!(!n||n.disabled||n.selected||(this._addItem(n,!0,t),0))},e.prototype._generatePlaceholderValue=function(){var e=this.config;if(!e.placeholder)return null;if(this._hasNonChoicePlaceholder)return e.placeholderValue;if(this._isSelectElement){var t=this.passedElement.placeholderOption;return t?t.text:null}return null},e.prototype._warnChoicesInitFailed=function(e){if(!this.config.silent){if(!this.initialised)throw new TypeError("".concat(e," called on a non-initialised instance of Choices"));if(!this.initialisedOK)throw new TypeError("".concat(e," called for an element which has multiple instances of Choices initialised on it"))}},e.version="11.2.0",e}()})); diff --git a/assets/scripts/choices.mjs b/assets/scripts/choices.mjs index 9decc5a0..b0e4f711 100644 --- a/assets/scripts/choices.mjs +++ b/assets/scripts/choices.mjs @@ -1,4 +1,4 @@ -/*! choices.js v11.1.0 | © 2025 Josh Johnson | https://github.com/jshjohnson/Choices#readme */ +/*! choices.js v11.2.0 | © 2026 Josh Johnson | https://github.com/jshjohnson/Choices#readme */ /****************************************************************************** Copyright (c) Microsoft Corporation. @@ -211,9 +211,6 @@ var strToEl = (function () { return firstChild; }; })(); -var resolveNoticeFunction = function (fn, value) { - return typeof fn === 'function' ? fn(sanitise(value), value) : fn; -}; var resolveStringFunction = function (fn) { return typeof fn === 'function' ? fn() : fn; }; @@ -245,6 +242,26 @@ var unwrapStringForEscaped = function (s) { } return ''; }; +var getChoiceForOutput = function (choice, keyCode) { + return { + id: choice.id, + highlighted: choice.highlighted, + labelClass: choice.labelClass, + labelDescription: unwrapStringForRaw(choice.labelDescription), + customProperties: choice.customProperties, + disabled: choice.disabled, + active: choice.active, + label: choice.label, + placeholder: choice.placeholder, + value: choice.value, + groupValue: choice.group ? choice.group.label : undefined, + element: choice.element, + keyCode: keyCode, + }; +}; +var resolveNoticeFunction = function (fn, value, item) { + return typeof fn === 'function' ? fn(sanitise(value), unwrapStringForRaw(value), item) : fn; +}; var escapeForTemplate = function (allowHTML, s) { return allowHTML ? unwrapStringForEscaped(s) : sanitise(s); }; @@ -412,6 +429,12 @@ var Container = /** @class */ (function () { Container.prototype.removeFocusState = function () { removeClassesFromElement(this.element, this.classNames.focusState); }; + Container.prototype.addInvalidState = function () { + addClassesToElement(this.element, this.classNames.invalidState); + }; + Container.prototype.removeInvalidState = function () { + removeClassesFromElement(this.element, this.classNames.invalidState); + }; Container.prototype.enable = function () { removeClassesFromElement(this.element, this.classNames.disabledState); this.element.removeAttribute('aria-disabled'); @@ -877,7 +900,9 @@ var WrappedSelect = /** @class */ (function (_super) { highlighted: false, placeholder: this.extractPlaceholder && (!option.value || option.hasAttribute('placeholder')), labelClass: typeof option.dataset.labelClass !== 'undefined' ? stringToHtmlClass(option.dataset.labelClass) : undefined, - labelDescription: typeof option.dataset.labelDescription !== 'undefined' ? option.dataset.labelDescription : undefined, + labelDescription: typeof option.dataset.labelDescription !== 'undefined' + ? { trusted: option.dataset.labelDescription } + : undefined, customProperties: parseCustomProperties(option.dataset.customProperties), }; }; @@ -923,6 +948,7 @@ var DEFAULT_CLASSNAMES = { selectedState: ['is-selected'], flippedState: ['is-flipped'], loadingState: ['is-loading'], + invalidState: ['is-invalid'], notice: ['choices__notice'], addChoice: ['choices__item--selectable', 'add-choice'], noResults: ['has-no-results'], @@ -950,6 +976,7 @@ var DEFAULT_CONFIG = { paste: true, searchEnabled: true, searchChoices: true, + searchDisabledChoices: false, searchFloor: 1, searchResultLimit: 4, searchFields: ['label', 'value'], @@ -965,6 +992,7 @@ var DEFAULT_CONFIG = { prependValue: null, appendValue: null, renderSelectedChoices: 'auto', + searchRenderSelectedChoices: true, loadingText: 'Loading...', noResultsText: 'No results found', noChoicesText: 'No choices to choose from', @@ -973,7 +1001,9 @@ var DEFAULT_CONFIG = { customAddItemText: 'Only values matching specific conditions can be added', addItemText: function (value) { return "Press Enter to add \"".concat(value, "\""); }, removeItemIconText: function () { return "Remove item"; }, - removeItemLabelText: function (value) { return "Remove item: ".concat(value); }, + removeItemLabelText: function (value, _valueRaw, i) { + return "Remove item: ".concat(i ? sanitise(i.label) : value); + }, maxItemText: function (maxItemCount) { return "Only ".concat(maxItemCount, " values can be added"); }, valueComparer: function (value1, value2) { return value1 === value2; }, fuseOptions: { @@ -1274,7 +1304,8 @@ var Store = /** @class */ (function () { * Get choices that can be searched (excluding placeholders or disabled choices) */ get: function () { - return this.choices.filter(function (choice) { return !choice.disabled && !choice.placeholder; }); + var context = this._context; + return this.choices.filter(function (choice) { return !choice.placeholder && (context.searchDisabledChoices || !choice.disabled); }); }, enumerable: false, configurable: true @@ -1332,9 +1363,9 @@ var NoticeTypes = { function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, - enumerable: !0, - configurable: !0, - writable: !0 + enumerable: true, + configurable: true, + writable: true }) : e[r] = t, e; } function ownKeys(e, r) { @@ -1350,7 +1381,7 @@ function ownKeys(e, r) { function _objectSpread2(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; - r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { + r % 2 ? ownKeys(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); @@ -1362,7 +1393,7 @@ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { - var i = e.call(t, r || "default"); + var i = e.call(t, r); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } @@ -1385,16 +1416,13 @@ function _toPropertyKey(t) { function isArray(value) { return !Array.isArray ? getTag(value) === '[object Array]' : Array.isArray(value); } - -// Adapted from: https://github.com/lodash/lodash/blob/master/.internal/baseToString.js -const INFINITY = 1 / 0; function baseToString(value) { // Exit early for strings to avoid a performance hit in some environments. if (typeof value == 'string') { return value; } let result = value + ''; - return result == '0' && 1 / value == -INFINITY ? '-0' : result; + return result == '0' && 1 / value == -Infinity ? '-0' : result; } function toString(value) { return value == null ? '' : baseToString(value); @@ -1430,7 +1458,6 @@ function isBlank(value) { function getTag(value) { return value == null ? value === undefined ? '[object Undefined]' : '[object Null]' : Object.prototype.toString.call(value); } -const EXTENDED_SEARCH_UNAVAILABLE = 'Extended search is not available'; const INCORRECT_INDEX_TYPE = "Incorrect 'index' type"; const LOGICAL_SEARCH_INVALID_QUERY_FOR_KEY = key => `Invalid value for key ${key}`; const PATTERN_LENGTH_TOO_LARGE = max => `Pattern length exceeds max of ${max}.`; @@ -2684,9 +2711,7 @@ function format(results, docs, { class Fuse { constructor(docs, options = {}, index) { this.options = _objectSpread2(_objectSpread2({}, Config), options); - if (this.options.useExtendedSearch && !true) { - throw new Error(EXTENDED_SEARCH_UNAVAILABLE); - } + if (this.options.useExtendedSearch && false) ; this._keyStore = new KeyStore(this.options.keys); this.setCollection(docs, index); } @@ -3018,7 +3043,7 @@ var assignCustomProperties = function (el, choice, withCustomProperties) { dataset.labelClass = getClassNames(labelClass).join(' '); } if (labelDescription) { - dataset.labelDescription = labelDescription; + dataset.labelDescription = unwrapStringForRaw(labelDescription); } if (withCustomProperties && customProperties) { if (typeof customProperties === 'string') { @@ -3125,8 +3150,9 @@ var templates = { var removeButton = document.createElement('button'); removeButton.type = 'button'; addClassesToElement(removeButton, button); - setElementHtml(removeButton, true, resolveNoticeFunction(removeItemIconText, choice.value)); - var REMOVE_ITEM_LABEL = resolveNoticeFunction(removeItemLabelText, choice.value); + var eventChoice = getChoiceForOutput(choice); + setElementHtml(removeButton, true, resolveNoticeFunction(removeItemIconText, choice.value, eventChoice)); + var REMOVE_ITEM_LABEL = resolveNoticeFunction(removeItemLabelText, choice.value, eventChoice); if (REMOVE_ITEM_LABEL) { removeButton.setAttribute('aria-label', REMOVE_ITEM_LABEL); } @@ -3231,6 +3257,7 @@ var templates = { else { addClassesToElement(div, itemSelectable); div.dataset.choiceSelectable = ''; + div.setAttribute('aria-selected', choice.selected ? 'true' : 'false'); } return div; }, @@ -3400,7 +3427,7 @@ var Choices = /** @class */ (function () { this.initialised = false; this._store = new Store(config); this._currentValue = ''; - config.searchEnabled = (!isText && config.searchEnabled) || isSelectMultiple; + config.searchEnabled = !isText && config.searchEnabled; this._canSearch = config.searchEnabled; this._isScrollingOnIe = false; this._highlightPosition = 0; @@ -3440,6 +3467,8 @@ var Choices = /** @class */ (function () { this._onEscapeKey = this._onEscapeKey.bind(this); this._onDirectionKey = this._onDirectionKey.bind(this); this._onDeleteKey = this._onDeleteKey.bind(this); + this._onChange = this._onChange.bind(this); + this._onInvalid = this._onInvalid.bind(this); // If element has already been initialised with Choices, fail silently if (this.passedElement.isActive) { if (!config.silent) { @@ -3546,7 +3575,7 @@ var Choices = /** @class */ (function () { } this._store.dispatch(highlightItem(choice, true)); if (runEvent) { - this.passedElement.triggerEvent(EventType.highlightItem, this._getChoiceForOutput(choice)); + this.passedElement.triggerEvent(EventType.highlightItem, getChoiceForOutput(choice)); } return this; }; @@ -3561,7 +3590,7 @@ var Choices = /** @class */ (function () { } this._store.dispatch(highlightItem(choice, false)); if (runEvent) { - this.passedElement.triggerEvent(EventType.unhighlightItem, this._getChoiceForOutput(choice)); + this.passedElement.triggerEvent(EventType.unhighlightItem, getChoiceForOutput(choice)); } return this; }; @@ -3571,7 +3600,7 @@ var Choices = /** @class */ (function () { _this._store.items.forEach(function (item) { if (!item.highlighted) { _this._store.dispatch(highlightItem(item, true)); - _this.passedElement.triggerEvent(EventType.highlightItem, _this._getChoiceForOutput(item)); + _this.passedElement.triggerEvent(EventType.highlightItem, getChoiceForOutput(item)); } }); }); @@ -3583,7 +3612,7 @@ var Choices = /** @class */ (function () { _this._store.items.forEach(function (item) { if (item.highlighted) { _this._store.dispatch(highlightItem(item, false)); - _this.passedElement.triggerEvent(EventType.highlightItem, _this._getChoiceForOutput(item)); + _this.passedElement.triggerEvent(EventType.highlightItem, getChoiceForOutput(item)); } }); }); @@ -3638,6 +3667,11 @@ var Choices = /** @class */ (function () { _this.input.focus(); } _this.passedElement.triggerEvent(EventType.showDropdown); + var activeElement = _this.choiceList.element.querySelector(getClassNamesSelector(_this.config.classNames.selectedState)); + if (activeElement !== null && !isScrolledIntoView(activeElement, _this.choiceList.element)) { + // We use the native scrollIntoView function instead of choiceList.scrollToChildElement to avoid animated scroll. + activeElement.scrollIntoView(); + } }); return this; }; @@ -3646,6 +3680,7 @@ var Choices = /** @class */ (function () { if (!this.dropdown.isActive) { return this; } + this._removeHighlightedChoices(); requestAnimationFrame(function () { _this.dropdown.hide(); _this.containerOuter.close(); @@ -3658,9 +3693,8 @@ var Choices = /** @class */ (function () { return this; }; Choices.prototype.getValue = function (valueOnly) { - var _this = this; var values = this._store.items.map(function (item) { - return (valueOnly ? item.value : _this._getChoiceForOutput(item)); + return (valueOnly ? item.value : getChoiceForOutput(item)); }); return this._isSelectOneElement || this.config.singleModeForMultiSelect ? values[0] : values; }; @@ -3918,7 +3952,7 @@ var Choices = /** @class */ (function () { // @todo integrate with Store this._searcher.reset(); if (choice.selected) { - this.passedElement.triggerEvent(EventType.removeItem, this._getChoiceForOutput(choice)); + this.passedElement.triggerEvent(EventType.removeItem, getChoiceForOutput(choice)); } return this; }; @@ -4001,13 +4035,7 @@ var Choices = /** @class */ (function () { } var _a = this, config = _a.config, isSearching = _a._isSearching; var _b = this._store, activeGroups = _b.activeGroups, activeChoices = _b.activeChoices; - var renderLimit = 0; - if (isSearching && config.searchResultLimit > 0) { - renderLimit = config.searchResultLimit; - } - else if (config.renderChoiceLimit > 0) { - renderLimit = config.renderChoiceLimit; - } + var renderLimit = isSearching ? config.searchResultLimit : config.renderChoiceLimit; if (this._isSelectElement) { var backingOptions = activeChoices.filter(function (choice) { return !choice.element; }); if (backingOptions.length) { @@ -4017,11 +4045,16 @@ var Choices = /** @class */ (function () { var fragment = document.createDocumentFragment(); var renderableChoices = function (choices) { return choices.filter(function (choice) { - return !choice.placeholder && (isSearching ? !!choice.rank : config.renderSelectedChoices || !choice.selected); + return !choice.placeholder && + (isSearching + ? (config.searchRenderSelectedChoices || !choice.selected) && !!choice.rank + : config.renderSelectedChoices || !choice.selected); }); }; + var showLabel = config.appendGroupInSearch && isSearching; var selectableChoices = false; - var renderChoices = function (choices, withinGroup, groupLabel) { + var highlightedEl = null; + var renderChoices = function (choices, withinGroup) { if (isSearching) { // sortByRank is used to ensure stable sorting, as scores are non-unique // this additionally ensures fuseOptions.sortFn is not ignored @@ -4031,16 +4064,20 @@ var Choices = /** @class */ (function () { choices.sort(config.sorter); } var choiceLimit = choices.length; - choiceLimit = !withinGroup && renderLimit && choiceLimit > renderLimit ? renderLimit : choiceLimit; + choiceLimit = !withinGroup && renderLimit > 0 && choiceLimit > renderLimit ? renderLimit : choiceLimit; choiceLimit--; choices.every(function (choice, index) { // choiceEl being empty signals the contents has probably significantly changed - var dropdownItem = choice.choiceEl || _this._templates.choice(config, choice, config.itemSelectText, groupLabel); + var dropdownItem = choice.choiceEl || + _this._templates.choice(config, choice, config.itemSelectText, showLabel && choice.group ? choice.group.label : undefined); choice.choiceEl = dropdownItem; fragment.appendChild(dropdownItem); if (isSearching || !choice.selected) { selectableChoices = true; } + else if (!highlightedEl) { + highlightedEl = dropdownItem; + } return index < choiceLimit; }); }; @@ -4050,7 +4087,7 @@ var Choices = /** @class */ (function () { } if (!this._hasNonChoicePlaceholder && !isSearching && this._isSelectOneElement) { // If we have a placeholder choice along with groups - renderChoices(activeChoices.filter(function (choice) { return choice.placeholder && !choice.group; }), false, undefined); + renderChoices(activeChoices.filter(function (choice) { return choice.placeholder && !choice.group; }), false); } // If we have grouped options if (activeGroups.length && !isSearching) { @@ -4059,7 +4096,7 @@ var Choices = /** @class */ (function () { } // render Choices without group first, regardless of sort, otherwise they won't be distinguishable // from the last group - renderChoices(activeChoices.filter(function (choice) { return !choice.placeholder && !choice.group; }), false, undefined); + renderChoices(activeChoices.filter(function (choice) { return !choice.placeholder && !choice.group; }), false); activeGroups.forEach(function (group) { var groupChoices = renderableChoices(group.choices); if (groupChoices.length) { @@ -4069,12 +4106,12 @@ var Choices = /** @class */ (function () { dropdownGroup.remove(); fragment.appendChild(dropdownGroup); } - renderChoices(groupChoices, true, config.appendGroupInSearch && isSearching ? group.label : undefined); + renderChoices(groupChoices, true); } }); } else { - renderChoices(renderableChoices(activeChoices), false, undefined); + renderChoices(renderableChoices(activeChoices), false); } } if (!selectableChoices && (isSearching || !fragment.children.length || !config.renderSelectedChoices)) { @@ -4088,9 +4125,7 @@ var Choices = /** @class */ (function () { } this._renderNotice(fragment); this.choiceList.element.replaceChildren(fragment); - if (selectableChoices) { - this._highlightChoice(); - } + this._highlightChoice(highlightedEl); }; Choices.prototype._renderItems = function () { var _this = this; @@ -4200,23 +4235,12 @@ var Choices = /** @class */ (function () { } } }; + /** + * @deprecated Use utils.getChoiceForOutput + */ // eslint-disable-next-line class-methods-use-this Choices.prototype._getChoiceForOutput = function (choice, keyCode) { - return { - id: choice.id, - highlighted: choice.highlighted, - labelClass: choice.labelClass, - labelDescription: choice.labelDescription, - customProperties: choice.customProperties, - disabled: choice.disabled, - active: choice.active, - label: choice.label, - placeholder: choice.placeholder, - value: choice.value, - groupValue: choice.group ? choice.group.label : undefined, - element: choice.element, - keyCode: keyCode, - }; + return getChoiceForOutput(choice, keyCode); }; Choices.prototype._triggerChange = function (value) { if (value === undefined || value === null) { @@ -4232,7 +4256,7 @@ var Choices = /** @class */ (function () { if (!items.length || !this.config.removeItems || !this.config.removeItemButton) { return; } - var id = element && parseDataSetId(element.parentElement); + var id = element && parseDataSetId(element.closest('[data-id]')); var itemToRemove = id && items.find(function (item) { return item.id === id; }); if (!itemToRemove) { return; @@ -4421,7 +4445,7 @@ var Choices = /** @class */ (function () { var notice = ''; if (canAddItem && typeof config.addItemFilter === 'function' && !config.addItemFilter(value)) { canAddItem = false; - notice = resolveNoticeFunction(config.customAddItemText, value); + notice = resolveNoticeFunction(config.customAddItemText, value, undefined); } if (canAddItem) { var foundChoice = this._store.choices.find(function (choice) { return config.valueComparer(choice.value, value); }); @@ -4433,12 +4457,12 @@ var Choices = /** @class */ (function () { } if (!config.duplicateItemsAllowed) { canAddItem = false; - notice = resolveNoticeFunction(config.uniqueItemText, value); + notice = resolveNoticeFunction(config.uniqueItemText, value, undefined); } } } if (canAddItem) { - notice = resolveNoticeFunction(config.addItemText, value); + notice = resolveNoticeFunction(config.addItemText, value, undefined); } if (notice) { this._displayNotice(notice, NoticeTypes.addChoice); @@ -4489,6 +4513,7 @@ var Choices = /** @class */ (function () { var documentElement = this._docRoot; var outerElement = this.containerOuter.element; var inputElement = this.input.element; + var passedElement = this.passedElement.element; // capture events - can cancel event processing or propagation documentElement.addEventListener('touchend', this._onTouchEnd, true); outerElement.addEventListener('keydown', this._onKeyDown, true); @@ -4526,12 +4551,21 @@ var Choices = /** @class */ (function () { passive: true, }); } + if (passedElement.hasAttribute('required')) { + passedElement.addEventListener('change', this._onChange, { + passive: true, + }); + passedElement.addEventListener('invalid', this._onInvalid, { + passive: true, + }); + } this.input.addEventListeners(); }; Choices.prototype._removeEventListeners = function () { var documentElement = this._docRoot; var outerElement = this.containerOuter.element; var inputElement = this.input.element; + var passedElement = this.passedElement.element; documentElement.removeEventListener('touchend', this._onTouchEnd, true); outerElement.removeEventListener('keydown', this._onKeyDown, true); outerElement.removeEventListener('mousedown', this._onMouseDown, true); @@ -4549,6 +4583,10 @@ var Choices = /** @class */ (function () { if (inputElement.form) { inputElement.form.removeEventListener('reset', this._onFormReset); } + if (passedElement.hasAttribute('required')) { + passedElement.removeEventListener('change', this._onChange); + passedElement.removeEventListener('invalid', this._onInvalid); + } this.input.removeEventListeners(); }; Choices.prototype._onKeyDown = function (event) { @@ -4798,7 +4836,7 @@ var Choices = /** @class */ (function () { */ Choices.prototype._onMouseDown = function (event) { var target = event.target; - if (!(target instanceof HTMLElement)) { + if (!(target instanceof Element)) { return; } // If we have our mouse down on the scrollbar and are on IE11... @@ -4907,7 +4945,7 @@ var Choices = /** @class */ (function () { // Remove the focus state when the past outerContainer was the target containerOuter.removeFocusState(); // Also close the dropdown if search is disabled - if (!this._canSearch) { + if (!this.config.searchEnabled) { this.hideDropdown(true); } } @@ -4931,6 +4969,27 @@ var Choices = /** @class */ (function () { } }); }; + Choices.prototype._onChange = function (event) { + if (!event.target.checkValidity()) { + return; + } + this.containerOuter.removeInvalidState(); + }; + Choices.prototype._onInvalid = function () { + this.containerOuter.addInvalidState(); + }; + /** + * Removes any highlighted choice options + */ + Choices.prototype._removeHighlightedChoices = function () { + var highlightedState = this.config.classNames.highlightedState; + var highlightedChoices = Array.from(this.dropdown.element.querySelectorAll(getClassNamesSelector(highlightedState))); + // Remove any highlighted choices + highlightedChoices.forEach(function (choice) { + removeClassesFromElement(choice, highlightedState); + choice.setAttribute('aria-selected', 'false'); + }); + }; Choices.prototype._highlightChoice = function (el) { if (el === void 0) { el = null; } var choices = Array.from(this.dropdown.element.querySelectorAll(selectableChoiceIdentifier)); @@ -4939,12 +4998,7 @@ var Choices = /** @class */ (function () { } var passedEl = el; var highlightedState = this.config.classNames.highlightedState; - var highlightedChoices = Array.from(this.dropdown.element.querySelectorAll(getClassNamesSelector(highlightedState))); - // Remove any highlighted choices - highlightedChoices.forEach(function (choice) { - removeClassesFromElement(choice, highlightedState); - choice.setAttribute('aria-selected', 'false'); - }); + this._removeHighlightedChoices(); if (passedEl) { this._highlightPosition = choices.indexOf(passedEl); } @@ -4985,9 +5039,10 @@ var Choices = /** @class */ (function () { } this._store.dispatch(addItem(item)); if (withEvents) { - this.passedElement.triggerEvent(EventType.addItem, this._getChoiceForOutput(item)); + var eventChoice = getChoiceForOutput(item); + this.passedElement.triggerEvent(EventType.addItem, eventChoice); if (userTriggered) { - this.passedElement.triggerEvent(EventType.choice, this._getChoiceForOutput(item)); + this.passedElement.triggerEvent(EventType.choice, eventChoice); } } }; @@ -5000,7 +5055,7 @@ var Choices = /** @class */ (function () { if (notice && notice.type === NoticeTypes.noChoices) { this._clearNotice(); } - this.passedElement.triggerEvent(EventType.removeItem, this._getChoiceForOutput(item)); + this.passedElement.triggerEvent(EventType.removeItem, getChoiceForOutput(item)); }; Choices.prototype._addChoice = function (choice, withEvents, userTriggered) { if (withEvents === void 0) { withEvents = true; } @@ -5115,24 +5170,24 @@ var Choices = /** @class */ (function () { containerInner.wrap(passedElement.element); // Wrapper inner container with outer container containerOuter.wrap(containerInner.element); - if (this._isSelectOneElement) { - this.input.placeholder = this.config.searchPlaceholderValue || ''; - } - else { - if (this._placeholderValue) { - this.input.placeholder = this._placeholderValue; - } - this.input.setWidth(); - } containerOuter.element.appendChild(containerInner.element); containerOuter.element.appendChild(dropdownElement); containerInner.element.appendChild(this.itemList.element); dropdownElement.appendChild(this.choiceList.element); - if (!this._isSelectOneElement) { - containerInner.element.appendChild(this.input.element); + if (this._isSelectOneElement) { + this.input.placeholder = this.config.searchPlaceholderValue || ''; + if (this.config.searchEnabled) { + dropdownElement.insertBefore(this.input.element, dropdownElement.firstChild); + } } - else if (this.config.searchEnabled) { - dropdownElement.insertBefore(this.input.element, dropdownElement.firstChild); + else { + if (!this._isSelectMultipleElement || this.config.searchEnabled) { + containerInner.element.appendChild(this.input.element); + } + if (this._placeholderValue) { + this.input.placeholder = this._placeholderValue; + } + this.input.setWidth(); } this._highlightPosition = 0; this._isSearching = false; @@ -5215,7 +5270,7 @@ var Choices = /** @class */ (function () { throw new TypeError("".concat(caller, " called for an element which has multiple instances of Choices initialised on it")); } }; - Choices.version = '11.1.0'; + Choices.version = '11.2.0'; return Choices; }()); diff --git a/assets/scripts/choices.search-basic.js b/assets/scripts/choices.search-basic.js index bf077c7f..b3a492bc 100644 --- a/assets/scripts/choices.search-basic.js +++ b/assets/scripts/choices.search-basic.js @@ -1,4 +1,4 @@ -/*! choices.js v11.1.0 | © 2025 Josh Johnson | https://github.com/jshjohnson/Choices#readme */ +/*! choices.js v11.2.0 | © 2026 Josh Johnson | https://github.com/jshjohnson/Choices#readme */ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : @@ -217,9 +217,6 @@ return firstChild; }; })(); - var resolveNoticeFunction = function (fn, value) { - return typeof fn === 'function' ? fn(sanitise(value), value) : fn; - }; var resolveStringFunction = function (fn) { return typeof fn === 'function' ? fn() : fn; }; @@ -251,6 +248,26 @@ } return ''; }; + var getChoiceForOutput = function (choice, keyCode) { + return { + id: choice.id, + highlighted: choice.highlighted, + labelClass: choice.labelClass, + labelDescription: unwrapStringForRaw(choice.labelDescription), + customProperties: choice.customProperties, + disabled: choice.disabled, + active: choice.active, + label: choice.label, + placeholder: choice.placeholder, + value: choice.value, + groupValue: choice.group ? choice.group.label : undefined, + element: choice.element, + keyCode: keyCode, + }; + }; + var resolveNoticeFunction = function (fn, value, item) { + return typeof fn === 'function' ? fn(sanitise(value), unwrapStringForRaw(value), item) : fn; + }; var escapeForTemplate = function (allowHTML, s) { return allowHTML ? unwrapStringForEscaped(s) : sanitise(s); }; @@ -418,6 +435,12 @@ Container.prototype.removeFocusState = function () { removeClassesFromElement(this.element, this.classNames.focusState); }; + Container.prototype.addInvalidState = function () { + addClassesToElement(this.element, this.classNames.invalidState); + }; + Container.prototype.removeInvalidState = function () { + removeClassesFromElement(this.element, this.classNames.invalidState); + }; Container.prototype.enable = function () { removeClassesFromElement(this.element, this.classNames.disabledState); this.element.removeAttribute('aria-disabled'); @@ -883,7 +906,9 @@ highlighted: false, placeholder: this.extractPlaceholder && (!option.value || option.hasAttribute('placeholder')), labelClass: typeof option.dataset.labelClass !== 'undefined' ? stringToHtmlClass(option.dataset.labelClass) : undefined, - labelDescription: typeof option.dataset.labelDescription !== 'undefined' ? option.dataset.labelDescription : undefined, + labelDescription: typeof option.dataset.labelDescription !== 'undefined' + ? { trusted: option.dataset.labelDescription } + : undefined, customProperties: parseCustomProperties(option.dataset.customProperties), }; }; @@ -929,6 +954,7 @@ selectedState: ['is-selected'], flippedState: ['is-flipped'], loadingState: ['is-loading'], + invalidState: ['is-invalid'], notice: ['choices__notice'], addChoice: ['choices__item--selectable', 'add-choice'], noResults: ['has-no-results'], @@ -956,6 +982,7 @@ paste: true, searchEnabled: true, searchChoices: true, + searchDisabledChoices: false, searchFloor: 1, searchResultLimit: 4, searchFields: ['label', 'value'], @@ -971,6 +998,7 @@ prependValue: null, appendValue: null, renderSelectedChoices: 'auto', + searchRenderSelectedChoices: true, loadingText: 'Loading...', noResultsText: 'No results found', noChoicesText: 'No choices to choose from', @@ -979,7 +1007,9 @@ customAddItemText: 'Only values matching specific conditions can be added', addItemText: function (value) { return "Press Enter to add \"".concat(value, "\""); }, removeItemIconText: function () { return "Remove item"; }, - removeItemLabelText: function (value) { return "Remove item: ".concat(value); }, + removeItemLabelText: function (value, _valueRaw, i) { + return "Remove item: ".concat(i ? sanitise(i.label) : value); + }, maxItemText: function (maxItemCount) { return "Only ".concat(maxItemCount, " values can be added"); }, valueComparer: function (value1, value2) { return value1 === value2; }, fuseOptions: { @@ -1280,7 +1310,8 @@ * Get choices that can be searched (excluding placeholders or disabled choices) */ get: function () { - return this.choices.filter(function (choice) { return !choice.disabled && !choice.placeholder; }); + var context = this._context; + return this.choices.filter(function (choice) { return !choice.placeholder && (context.searchDisabledChoices || !choice.disabled); }); }, enumerable: false, configurable: true @@ -1338,9 +1369,9 @@ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, - enumerable: !0, - configurable: !0, - writable: !0 + enumerable: true, + configurable: true, + writable: true }) : e[r] = t, e; } function ownKeys(e, r) { @@ -1356,7 +1387,7 @@ function _objectSpread2(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; - r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { + r % 2 ? ownKeys(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); @@ -1368,7 +1399,7 @@ if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { - var i = e.call(t, r || "default"); + var i = e.call(t, r); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } @@ -1391,16 +1422,13 @@ function isArray(value) { return !Array.isArray ? getTag(value) === '[object Array]' : Array.isArray(value); } - - // Adapted from: https://github.com/lodash/lodash/blob/master/.internal/baseToString.js - const INFINITY = 1 / 0; function baseToString(value) { // Exit early for strings to avoid a performance hit in some environments. if (typeof value == 'string') { return value; } let result = value + ''; - return result == '0' && 1 / value == -INFINITY ? '-0' : result; + return result == '0' && 1 / value == -Infinity ? '-0' : result; } function toString(value) { return value == null ? '' : baseToString(value); @@ -2269,7 +2297,7 @@ class Fuse { constructor(docs, options = {}, index) { this.options = _objectSpread2(_objectSpread2({}, Config), options); - if (this.options.useExtendedSearch && !false) { + if (this.options.useExtendedSearch && true) { throw new Error(EXTENDED_SEARCH_UNAVAILABLE); } this._keyStore = new KeyStore(this.options.keys); @@ -2542,7 +2570,7 @@ dataset.labelClass = getClassNames(labelClass).join(' '); } if (labelDescription) { - dataset.labelDescription = labelDescription; + dataset.labelDescription = unwrapStringForRaw(labelDescription); } if (withCustomProperties && customProperties) { if (typeof customProperties === 'string') { @@ -2649,8 +2677,9 @@ var removeButton = document.createElement('button'); removeButton.type = 'button'; addClassesToElement(removeButton, button); - setElementHtml(removeButton, true, resolveNoticeFunction(removeItemIconText, choice.value)); - var REMOVE_ITEM_LABEL = resolveNoticeFunction(removeItemLabelText, choice.value); + var eventChoice = getChoiceForOutput(choice); + setElementHtml(removeButton, true, resolveNoticeFunction(removeItemIconText, choice.value, eventChoice)); + var REMOVE_ITEM_LABEL = resolveNoticeFunction(removeItemLabelText, choice.value, eventChoice); if (REMOVE_ITEM_LABEL) { removeButton.setAttribute('aria-label', REMOVE_ITEM_LABEL); } @@ -2755,6 +2784,7 @@ else { addClassesToElement(div, itemSelectable); div.dataset.choiceSelectable = ''; + div.setAttribute('aria-selected', choice.selected ? 'true' : 'false'); } return div; }, @@ -2924,7 +2954,7 @@ this.initialised = false; this._store = new Store(config); this._currentValue = ''; - config.searchEnabled = (!isText && config.searchEnabled) || isSelectMultiple; + config.searchEnabled = !isText && config.searchEnabled; this._canSearch = config.searchEnabled; this._isScrollingOnIe = false; this._highlightPosition = 0; @@ -2964,6 +2994,8 @@ this._onEscapeKey = this._onEscapeKey.bind(this); this._onDirectionKey = this._onDirectionKey.bind(this); this._onDeleteKey = this._onDeleteKey.bind(this); + this._onChange = this._onChange.bind(this); + this._onInvalid = this._onInvalid.bind(this); // If element has already been initialised with Choices, fail silently if (this.passedElement.isActive) { if (!config.silent) { @@ -3070,7 +3102,7 @@ } this._store.dispatch(highlightItem(choice, true)); if (runEvent) { - this.passedElement.triggerEvent(EventType.highlightItem, this._getChoiceForOutput(choice)); + this.passedElement.triggerEvent(EventType.highlightItem, getChoiceForOutput(choice)); } return this; }; @@ -3085,7 +3117,7 @@ } this._store.dispatch(highlightItem(choice, false)); if (runEvent) { - this.passedElement.triggerEvent(EventType.unhighlightItem, this._getChoiceForOutput(choice)); + this.passedElement.triggerEvent(EventType.unhighlightItem, getChoiceForOutput(choice)); } return this; }; @@ -3095,7 +3127,7 @@ _this._store.items.forEach(function (item) { if (!item.highlighted) { _this._store.dispatch(highlightItem(item, true)); - _this.passedElement.triggerEvent(EventType.highlightItem, _this._getChoiceForOutput(item)); + _this.passedElement.triggerEvent(EventType.highlightItem, getChoiceForOutput(item)); } }); }); @@ -3107,7 +3139,7 @@ _this._store.items.forEach(function (item) { if (item.highlighted) { _this._store.dispatch(highlightItem(item, false)); - _this.passedElement.triggerEvent(EventType.highlightItem, _this._getChoiceForOutput(item)); + _this.passedElement.triggerEvent(EventType.highlightItem, getChoiceForOutput(item)); } }); }); @@ -3162,6 +3194,11 @@ _this.input.focus(); } _this.passedElement.triggerEvent(EventType.showDropdown); + var activeElement = _this.choiceList.element.querySelector(getClassNamesSelector(_this.config.classNames.selectedState)); + if (activeElement !== null && !isScrolledIntoView(activeElement, _this.choiceList.element)) { + // We use the native scrollIntoView function instead of choiceList.scrollToChildElement to avoid animated scroll. + activeElement.scrollIntoView(); + } }); return this; }; @@ -3170,6 +3207,7 @@ if (!this.dropdown.isActive) { return this; } + this._removeHighlightedChoices(); requestAnimationFrame(function () { _this.dropdown.hide(); _this.containerOuter.close(); @@ -3182,9 +3220,8 @@ return this; }; Choices.prototype.getValue = function (valueOnly) { - var _this = this; var values = this._store.items.map(function (item) { - return (valueOnly ? item.value : _this._getChoiceForOutput(item)); + return (valueOnly ? item.value : getChoiceForOutput(item)); }); return this._isSelectOneElement || this.config.singleModeForMultiSelect ? values[0] : values; }; @@ -3442,7 +3479,7 @@ // @todo integrate with Store this._searcher.reset(); if (choice.selected) { - this.passedElement.triggerEvent(EventType.removeItem, this._getChoiceForOutput(choice)); + this.passedElement.triggerEvent(EventType.removeItem, getChoiceForOutput(choice)); } return this; }; @@ -3525,13 +3562,7 @@ } var _a = this, config = _a.config, isSearching = _a._isSearching; var _b = this._store, activeGroups = _b.activeGroups, activeChoices = _b.activeChoices; - var renderLimit = 0; - if (isSearching && config.searchResultLimit > 0) { - renderLimit = config.searchResultLimit; - } - else if (config.renderChoiceLimit > 0) { - renderLimit = config.renderChoiceLimit; - } + var renderLimit = isSearching ? config.searchResultLimit : config.renderChoiceLimit; if (this._isSelectElement) { var backingOptions = activeChoices.filter(function (choice) { return !choice.element; }); if (backingOptions.length) { @@ -3541,11 +3572,16 @@ var fragment = document.createDocumentFragment(); var renderableChoices = function (choices) { return choices.filter(function (choice) { - return !choice.placeholder && (isSearching ? !!choice.rank : config.renderSelectedChoices || !choice.selected); + return !choice.placeholder && + (isSearching + ? (config.searchRenderSelectedChoices || !choice.selected) && !!choice.rank + : config.renderSelectedChoices || !choice.selected); }); }; + var showLabel = config.appendGroupInSearch && isSearching; var selectableChoices = false; - var renderChoices = function (choices, withinGroup, groupLabel) { + var highlightedEl = null; + var renderChoices = function (choices, withinGroup) { if (isSearching) { // sortByRank is used to ensure stable sorting, as scores are non-unique // this additionally ensures fuseOptions.sortFn is not ignored @@ -3555,16 +3591,20 @@ choices.sort(config.sorter); } var choiceLimit = choices.length; - choiceLimit = !withinGroup && renderLimit && choiceLimit > renderLimit ? renderLimit : choiceLimit; + choiceLimit = !withinGroup && renderLimit > 0 && choiceLimit > renderLimit ? renderLimit : choiceLimit; choiceLimit--; choices.every(function (choice, index) { // choiceEl being empty signals the contents has probably significantly changed - var dropdownItem = choice.choiceEl || _this._templates.choice(config, choice, config.itemSelectText, groupLabel); + var dropdownItem = choice.choiceEl || + _this._templates.choice(config, choice, config.itemSelectText, showLabel && choice.group ? choice.group.label : undefined); choice.choiceEl = dropdownItem; fragment.appendChild(dropdownItem); if (isSearching || !choice.selected) { selectableChoices = true; } + else if (!highlightedEl) { + highlightedEl = dropdownItem; + } return index < choiceLimit; }); }; @@ -3574,7 +3614,7 @@ } if (!this._hasNonChoicePlaceholder && !isSearching && this._isSelectOneElement) { // If we have a placeholder choice along with groups - renderChoices(activeChoices.filter(function (choice) { return choice.placeholder && !choice.group; }), false, undefined); + renderChoices(activeChoices.filter(function (choice) { return choice.placeholder && !choice.group; }), false); } // If we have grouped options if (activeGroups.length && !isSearching) { @@ -3583,7 +3623,7 @@ } // render Choices without group first, regardless of sort, otherwise they won't be distinguishable // from the last group - renderChoices(activeChoices.filter(function (choice) { return !choice.placeholder && !choice.group; }), false, undefined); + renderChoices(activeChoices.filter(function (choice) { return !choice.placeholder && !choice.group; }), false); activeGroups.forEach(function (group) { var groupChoices = renderableChoices(group.choices); if (groupChoices.length) { @@ -3593,12 +3633,12 @@ dropdownGroup.remove(); fragment.appendChild(dropdownGroup); } - renderChoices(groupChoices, true, config.appendGroupInSearch && isSearching ? group.label : undefined); + renderChoices(groupChoices, true); } }); } else { - renderChoices(renderableChoices(activeChoices), false, undefined); + renderChoices(renderableChoices(activeChoices), false); } } if (!selectableChoices && (isSearching || !fragment.children.length || !config.renderSelectedChoices)) { @@ -3612,9 +3652,7 @@ } this._renderNotice(fragment); this.choiceList.element.replaceChildren(fragment); - if (selectableChoices) { - this._highlightChoice(); - } + this._highlightChoice(highlightedEl); }; Choices.prototype._renderItems = function () { var _this = this; @@ -3724,23 +3762,12 @@ } } }; + /** + * @deprecated Use utils.getChoiceForOutput + */ // eslint-disable-next-line class-methods-use-this Choices.prototype._getChoiceForOutput = function (choice, keyCode) { - return { - id: choice.id, - highlighted: choice.highlighted, - labelClass: choice.labelClass, - labelDescription: choice.labelDescription, - customProperties: choice.customProperties, - disabled: choice.disabled, - active: choice.active, - label: choice.label, - placeholder: choice.placeholder, - value: choice.value, - groupValue: choice.group ? choice.group.label : undefined, - element: choice.element, - keyCode: keyCode, - }; + return getChoiceForOutput(choice, keyCode); }; Choices.prototype._triggerChange = function (value) { if (value === undefined || value === null) { @@ -3756,7 +3783,7 @@ if (!items.length || !this.config.removeItems || !this.config.removeItemButton) { return; } - var id = element && parseDataSetId(element.parentElement); + var id = element && parseDataSetId(element.closest('[data-id]')); var itemToRemove = id && items.find(function (item) { return item.id === id; }); if (!itemToRemove) { return; @@ -3945,7 +3972,7 @@ var notice = ''; if (canAddItem && typeof config.addItemFilter === 'function' && !config.addItemFilter(value)) { canAddItem = false; - notice = resolveNoticeFunction(config.customAddItemText, value); + notice = resolveNoticeFunction(config.customAddItemText, value, undefined); } if (canAddItem) { var foundChoice = this._store.choices.find(function (choice) { return config.valueComparer(choice.value, value); }); @@ -3957,12 +3984,12 @@ } if (!config.duplicateItemsAllowed) { canAddItem = false; - notice = resolveNoticeFunction(config.uniqueItemText, value); + notice = resolveNoticeFunction(config.uniqueItemText, value, undefined); } } } if (canAddItem) { - notice = resolveNoticeFunction(config.addItemText, value); + notice = resolveNoticeFunction(config.addItemText, value, undefined); } if (notice) { this._displayNotice(notice, NoticeTypes.addChoice); @@ -4013,6 +4040,7 @@ var documentElement = this._docRoot; var outerElement = this.containerOuter.element; var inputElement = this.input.element; + var passedElement = this.passedElement.element; // capture events - can cancel event processing or propagation documentElement.addEventListener('touchend', this._onTouchEnd, true); outerElement.addEventListener('keydown', this._onKeyDown, true); @@ -4050,12 +4078,21 @@ passive: true, }); } + if (passedElement.hasAttribute('required')) { + passedElement.addEventListener('change', this._onChange, { + passive: true, + }); + passedElement.addEventListener('invalid', this._onInvalid, { + passive: true, + }); + } this.input.addEventListeners(); }; Choices.prototype._removeEventListeners = function () { var documentElement = this._docRoot; var outerElement = this.containerOuter.element; var inputElement = this.input.element; + var passedElement = this.passedElement.element; documentElement.removeEventListener('touchend', this._onTouchEnd, true); outerElement.removeEventListener('keydown', this._onKeyDown, true); outerElement.removeEventListener('mousedown', this._onMouseDown, true); @@ -4073,6 +4110,10 @@ if (inputElement.form) { inputElement.form.removeEventListener('reset', this._onFormReset); } + if (passedElement.hasAttribute('required')) { + passedElement.removeEventListener('change', this._onChange); + passedElement.removeEventListener('invalid', this._onInvalid); + } this.input.removeEventListeners(); }; Choices.prototype._onKeyDown = function (event) { @@ -4322,7 +4363,7 @@ */ Choices.prototype._onMouseDown = function (event) { var target = event.target; - if (!(target instanceof HTMLElement)) { + if (!(target instanceof Element)) { return; } // If we have our mouse down on the scrollbar and are on IE11... @@ -4431,7 +4472,7 @@ // Remove the focus state when the past outerContainer was the target containerOuter.removeFocusState(); // Also close the dropdown if search is disabled - if (!this._canSearch) { + if (!this.config.searchEnabled) { this.hideDropdown(true); } } @@ -4455,6 +4496,27 @@ } }); }; + Choices.prototype._onChange = function (event) { + if (!event.target.checkValidity()) { + return; + } + this.containerOuter.removeInvalidState(); + }; + Choices.prototype._onInvalid = function () { + this.containerOuter.addInvalidState(); + }; + /** + * Removes any highlighted choice options + */ + Choices.prototype._removeHighlightedChoices = function () { + var highlightedState = this.config.classNames.highlightedState; + var highlightedChoices = Array.from(this.dropdown.element.querySelectorAll(getClassNamesSelector(highlightedState))); + // Remove any highlighted choices + highlightedChoices.forEach(function (choice) { + removeClassesFromElement(choice, highlightedState); + choice.setAttribute('aria-selected', 'false'); + }); + }; Choices.prototype._highlightChoice = function (el) { if (el === void 0) { el = null; } var choices = Array.from(this.dropdown.element.querySelectorAll(selectableChoiceIdentifier)); @@ -4463,12 +4525,7 @@ } var passedEl = el; var highlightedState = this.config.classNames.highlightedState; - var highlightedChoices = Array.from(this.dropdown.element.querySelectorAll(getClassNamesSelector(highlightedState))); - // Remove any highlighted choices - highlightedChoices.forEach(function (choice) { - removeClassesFromElement(choice, highlightedState); - choice.setAttribute('aria-selected', 'false'); - }); + this._removeHighlightedChoices(); if (passedEl) { this._highlightPosition = choices.indexOf(passedEl); } @@ -4509,9 +4566,10 @@ } this._store.dispatch(addItem(item)); if (withEvents) { - this.passedElement.triggerEvent(EventType.addItem, this._getChoiceForOutput(item)); + var eventChoice = getChoiceForOutput(item); + this.passedElement.triggerEvent(EventType.addItem, eventChoice); if (userTriggered) { - this.passedElement.triggerEvent(EventType.choice, this._getChoiceForOutput(item)); + this.passedElement.triggerEvent(EventType.choice, eventChoice); } } }; @@ -4524,7 +4582,7 @@ if (notice && notice.type === NoticeTypes.noChoices) { this._clearNotice(); } - this.passedElement.triggerEvent(EventType.removeItem, this._getChoiceForOutput(item)); + this.passedElement.triggerEvent(EventType.removeItem, getChoiceForOutput(item)); }; Choices.prototype._addChoice = function (choice, withEvents, userTriggered) { if (withEvents === void 0) { withEvents = true; } @@ -4639,24 +4697,24 @@ containerInner.wrap(passedElement.element); // Wrapper inner container with outer container containerOuter.wrap(containerInner.element); - if (this._isSelectOneElement) { - this.input.placeholder = this.config.searchPlaceholderValue || ''; - } - else { - if (this._placeholderValue) { - this.input.placeholder = this._placeholderValue; - } - this.input.setWidth(); - } containerOuter.element.appendChild(containerInner.element); containerOuter.element.appendChild(dropdownElement); containerInner.element.appendChild(this.itemList.element); dropdownElement.appendChild(this.choiceList.element); - if (!this._isSelectOneElement) { - containerInner.element.appendChild(this.input.element); + if (this._isSelectOneElement) { + this.input.placeholder = this.config.searchPlaceholderValue || ''; + if (this.config.searchEnabled) { + dropdownElement.insertBefore(this.input.element, dropdownElement.firstChild); + } } - else if (this.config.searchEnabled) { - dropdownElement.insertBefore(this.input.element, dropdownElement.firstChild); + else { + if (!this._isSelectMultipleElement || this.config.searchEnabled) { + containerInner.element.appendChild(this.input.element); + } + if (this._placeholderValue) { + this.input.placeholder = this._placeholderValue; + } + this.input.setWidth(); } this._highlightPosition = 0; this._isSearching = false; @@ -4739,7 +4797,7 @@ throw new TypeError("".concat(caller, " called for an element which has multiple instances of Choices initialised on it")); } }; - Choices.version = '11.1.0'; + Choices.version = '11.2.0'; return Choices; }()); diff --git a/assets/scripts/choices.search-basic.min.js b/assets/scripts/choices.search-basic.min.js index b296e85e..6f5da664 100644 --- a/assets/scripts/choices.search-basic.min.js +++ b/assets/scripts/choices.search-basic.min.js @@ -1,2 +1,2 @@ -/*! choices.js v11.1.0 | © 2025 Josh Johnson | https://github.com/jshjohnson/Choices#readme */ -!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).Choices=t()}(this,(function(){"use strict";var e=function(t,i){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])},e(t,i)};function t(t,i){if("function"!=typeof i&&null!==i)throw new TypeError("Class extends value "+String(i)+" is not a constructor or null");function n(){this.constructor=t}e(t,i),t.prototype=null===i?Object.create(i):(n.prototype=i.prototype,new n)}var i=function(){return i=Object.assign||function(e){for(var t,i=1,n=arguments.length;i/g,">").replace(/=0&&!window.matchMedia("(min-height: ".concat(e+1,"px)")).matches:"top"===this.position&&(i=!0),i},e.prototype.setActiveDescendant=function(e){this.element.setAttribute("aria-activedescendant",e)},e.prototype.removeActiveDescendant=function(){this.element.removeAttribute("aria-activedescendant")},e.prototype.open=function(e,t){P(this.element,this.classNames.openState),this.element.setAttribute("aria-expanded","true"),this.isOpen=!0,this.shouldFlip(e,t)&&(P(this.element,this.classNames.flippedState),this.isFlipped=!0)},e.prototype.close=function(){j(this.element,this.classNames.openState),this.element.setAttribute("aria-expanded","false"),this.removeActiveDescendant(),this.isOpen=!1,this.isFlipped&&(j(this.element,this.classNames.flippedState),this.isFlipped=!1)},e.prototype.addFocusState=function(){P(this.element,this.classNames.focusState)},e.prototype.removeFocusState=function(){j(this.element,this.classNames.focusState)},e.prototype.enable=function(){j(this.element,this.classNames.disabledState),this.element.removeAttribute("aria-disabled"),this.type===g&&this.element.setAttribute("tabindex","0"),this.isDisabled=!1},e.prototype.disable=function(){P(this.element,this.classNames.disabledState),this.element.setAttribute("aria-disabled","true"),this.type===g&&this.element.setAttribute("tabindex","-1"),this.isDisabled=!0},e.prototype.wrap=function(e){var t=this.element,i=e.parentNode;i&&(e.nextSibling?i.insertBefore(t,e.nextSibling):i.appendChild(t)),t.appendChild(e)},e.prototype.unwrap=function(e){var t=this.element,i=t.parentNode;i&&(i.insertBefore(e,t),i.removeChild(t))},e.prototype.addLoadingState=function(){P(this.element,this.classNames.loadingState),this.element.setAttribute("aria-busy","true"),this.isLoading=!0},e.prototype.removeLoadingState=function(){j(this.element,this.classNames.loadingState),this.element.removeAttribute("aria-busy"),this.isLoading=!1},e}(),H=function(){function e(e){var t=e.element,i=e.type,n=e.classNames,s=e.preventPaste;this.element=t,this.type=i,this.classNames=n,this.preventPaste=s,this.isFocussed=this.element.isEqualNode(document.activeElement),this.isDisabled=t.disabled,this._onPaste=this._onPaste.bind(this),this._onInput=this._onInput.bind(this),this._onFocus=this._onFocus.bind(this),this._onBlur=this._onBlur.bind(this)}return Object.defineProperty(e.prototype,"placeholder",{set:function(e){this.element.placeholder=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"value",{get:function(){return this.element.value},set:function(e){this.element.value=e},enumerable:!1,configurable:!0}),e.prototype.addEventListeners=function(){var e=this.element;e.addEventListener("paste",this._onPaste),e.addEventListener("input",this._onInput,{passive:!0}),e.addEventListener("focus",this._onFocus,{passive:!0}),e.addEventListener("blur",this._onBlur,{passive:!0})},e.prototype.removeEventListeners=function(){var e=this.element;e.removeEventListener("input",this._onInput),e.removeEventListener("paste",this._onPaste),e.removeEventListener("focus",this._onFocus),e.removeEventListener("blur",this._onBlur)},e.prototype.enable=function(){this.element.removeAttribute("disabled"),this.isDisabled=!1},e.prototype.disable=function(){this.element.setAttribute("disabled",""),this.isDisabled=!0},e.prototype.focus=function(){this.isFocussed||this.element.focus()},e.prototype.blur=function(){this.isFocussed&&this.element.blur()},e.prototype.clear=function(e){return void 0===e&&(e=!0),this.element.value="",e&&this.setWidth(),this},e.prototype.setWidth=function(){var e=this.element;e.style.minWidth="".concat(e.placeholder.length+1,"ch"),e.style.width="".concat(e.value.length+1,"ch")},e.prototype.setActiveDescendant=function(e){this.element.setAttribute("aria-activedescendant",e)},e.prototype.removeActiveDescendant=function(){this.element.removeAttribute("aria-activedescendant")},e.prototype._onInput=function(){this.type!==g&&this.setWidth()},e.prototype._onPaste=function(e){this.preventPaste&&e.preventDefault()},e.prototype._onFocus=function(){this.isFocussed=!0},e.prototype._onBlur=function(){this.isFocussed=!1},e}(),R=function(){function e(e){this.element=e.element,this.scrollPos=this.element.scrollTop,this.height=this.element.offsetHeight}return e.prototype.prepend=function(e){var t=this.element.firstElementChild;t?this.element.insertBefore(e,t):this.element.append(e)},e.prototype.scrollToTop=function(){this.element.scrollTop=0},e.prototype.scrollToChildElement=function(e,t){var i=this;if(e){var n=t>0?this.element.scrollTop+(e.offsetTop+e.offsetHeight)-(this.element.scrollTop+this.element.offsetHeight):e.offsetTop;requestAnimationFrame((function(){i._animateScroll(n,t)}))}},e.prototype._scrollDown=function(e,t,i){var n=(i-e)/t;this.element.scrollTop=e+(n>1?n:1)},e.prototype._scrollUp=function(e,t,i){var n=(e-i)/t;this.element.scrollTop=e-(n>1?n:1)},e.prototype._animateScroll=function(e,t){var i=this,n=this.element.scrollTop,s=!1;t>0?(this._scrollDown(n,4,e),ne&&(s=!0)),s&&requestAnimationFrame((function(){i._animateScroll(e,t)}))},e}(),q=function(){function e(e){var t=e.classNames;this.element=e.element,this.classNames=t,this.isDisabled=!1}return Object.defineProperty(e.prototype,"isActive",{get:function(){return"active"===this.element.dataset.choice},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"dir",{get:function(){return this.element.dir},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"value",{get:function(){return this.element.value},set:function(e){this.element.setAttribute("value",e),this.element.value=e},enumerable:!1,configurable:!0}),e.prototype.conceal=function(){var e=this.element;P(e,this.classNames.input),e.hidden=!0,e.tabIndex=-1;var t=e.getAttribute("style");t&&e.setAttribute("data-choice-orig-style",t),e.setAttribute("data-choice","active")},e.prototype.reveal=function(){var e=this.element;j(e,this.classNames.input),e.hidden=!1,e.removeAttribute("tabindex");var t=e.getAttribute("data-choice-orig-style");t?(e.removeAttribute("data-choice-orig-style"),e.setAttribute("style",t)):e.removeAttribute("style"),e.removeAttribute("data-choice")},e.prototype.enable=function(){this.element.removeAttribute("disabled"),this.element.disabled=!1,this.isDisabled=!1},e.prototype.disable=function(){this.element.setAttribute("disabled",""),this.element.disabled=!0,this.isDisabled=!0},e.prototype.triggerEvent=function(e,t){var i;void 0===(i=t||{})&&(i=null),this.element.dispatchEvent(new CustomEvent(e,{detail:i,bubbles:!0,cancelable:!0}))},e}(),U=function(e){function i(){return null!==e&&e.apply(this,arguments)||this}return t(i,e),i}(q),G=function(e,t){return void 0===t&&(t=!0),void 0===e?t:!!e},W=function(e){if("string"==typeof e&&(e=e.split(" ").filter((function(e){return e.length}))),Array.isArray(e)&&e.length)return e},$=function(e,t,i){if(void 0===i&&(i=!0),"string"==typeof e){var n=I(e);return $({value:e,label:i||n===e?e:{escaped:n,raw:e},selected:!0},!1)}var s=e;if("choices"in s){if(!t)throw new TypeError("optGroup is not allowed");var o=s,r=o.choices.map((function(e){return $(e,!1)}));return{id:0,label:L(o.label)||o.value,active:!!r.length,disabled:!!o.disabled,choices:r}}var c=s;return{id:0,group:null,score:0,rank:0,value:c.value,label:c.label||c.value,active:G(c.active),selected:G(c.selected,!1),disabled:G(c.disabled,!1),placeholder:G(c.placeholder,!1),highlighted:!1,labelClass:W(c.labelClass),labelDescription:c.labelDescription,customProperties:c.customProperties}},J=function(e){return"SELECT"===e.tagName},z=function(e){function i(t){var i=t.template,n=t.extractPlaceholder,s=e.call(this,{element:t.element,classNames:t.classNames})||this;return s.template=i,s.extractPlaceholder=n,s}return t(i,e),Object.defineProperty(i.prototype,"placeholderOption",{get:function(){return this.element.querySelector('option[value=""]')||this.element.querySelector("option[placeholder]")},enumerable:!1,configurable:!0}),i.prototype.addOptions=function(e){var t=this,i=document.createDocumentFragment();e.forEach((function(e){var n=e;if(!n.element){var s=t.template(n);i.appendChild(s),n.element=s}})),this.element.appendChild(i)},i.prototype.optionsAsChoices=function(){var e=this,t=[];return this.element.querySelectorAll(":scope > option, :scope > optgroup").forEach((function(i){!function(e){return"OPTION"===e.tagName}(i)?function(e){return"OPTGROUP"===e.tagName}(i)&&t.push(e._optgroupToChoice(i)):t.push(e._optionToChoice(i))})),t},i.prototype._optionToChoice=function(e){return!e.hasAttribute("value")&&e.hasAttribute("placeholder")&&(e.setAttribute("value",""),e.value=""),{id:0,group:null,score:0,rank:0,value:e.value,label:e.label,element:e,active:!0,selected:this.extractPlaceholder?e.selected:e.hasAttribute("selected"),disabled:e.disabled,highlighted:!1,placeholder:this.extractPlaceholder&&(!e.value||e.hasAttribute("placeholder")),labelClass:void 0!==e.dataset.labelClass?W(e.dataset.labelClass):void 0,labelDescription:void 0!==e.dataset.labelDescription?e.dataset.labelDescription:void 0,customProperties:K(e.dataset.customProperties)}},i.prototype._optgroupToChoice=function(e){var t=this,i=e.querySelectorAll("option"),n=Array.from(i).map((function(e){return t._optionToChoice(e)}));return{id:0,label:e.label||"",element:e,active:!!n.length,disabled:e.disabled,choices:n}},i}(q),X={items:[],choices:[],silent:!1,renderChoiceLimit:-1,maxItemCount:-1,closeDropdownOnSelect:"auto",singleModeForMultiSelect:!1,addChoices:!1,addItems:!0,addItemFilter:function(e){return!!e&&""!==e},removeItems:!0,removeItemButton:!1,removeItemButtonAlignLeft:!1,editItems:!1,allowHTML:!1,allowHtmlUserInput:!1,duplicateItemsAllowed:!0,delimiter:",",paste:!0,searchEnabled:!0,searchChoices:!0,searchFloor:1,searchResultLimit:4,searchFields:["label","value"],position:"auto",resetScrollPosition:!0,shouldSort:!0,shouldSortItems:!1,sorter:function(e,t){var i=e.label,n=t.label,s=void 0===n?t.value:n;return L(void 0===i?e.value:i).localeCompare(L(s),[],{sensitivity:"base",ignorePunctuation:!0,numeric:!0})},shadowRoot:null,placeholder:!0,placeholderValue:null,searchPlaceholderValue:null,prependValue:null,appendValue:null,renderSelectedChoices:"auto",loadingText:"Loading...",noResultsText:"No results found",noChoicesText:"No choices to choose from",itemSelectText:"Press to select",uniqueItemText:"Only unique values can be added",customAddItemText:"Only values matching specific conditions can be added",addItemText:function(e){return'Press Enter to add "'.concat(e,'"')},removeItemIconText:function(){return"Remove item"},removeItemLabelText:function(e){return"Remove item: ".concat(e)},maxItemText:function(e){return"Only ".concat(e," values can be added")},valueComparer:function(e,t){return e===t},fuseOptions:{includeScore:!0},labelId:"",callbackOnInit:null,callbackOnCreateTemplates:null,classNames:{containerOuter:["choices"],containerInner:["choices__inner"],input:["choices__input"],inputCloned:["choices__input--cloned"],list:["choices__list"],listItems:["choices__list--multiple"],listSingle:["choices__list--single"],listDropdown:["choices__list--dropdown"],item:["choices__item"],itemSelectable:["choices__item--selectable"],itemDisabled:["choices__item--disabled"],itemChoice:["choices__item--choice"],description:["choices__description"],placeholder:["choices__placeholder"],group:["choices__group"],groupHeading:["choices__heading"],button:["choices__button"],activeState:["is-active"],focusState:["is-focused"],openState:["is-open"],disabledState:["is-disabled"],highlightedState:["is-highlighted"],selectedState:["is-selected"],flippedState:["is-flipped"],loadingState:["is-loading"],notice:["choices__notice"],addChoice:["choices__item--selectable","add-choice"],noResults:["has-no-results"],noChoices:["has-no-choices"]},appendGroupInSearch:!1},Q=function(e){var t=e.itemEl;t&&(t.remove(),e.itemEl=void 0)},Y={groups:function(e,t){var i=e,n=!0;switch(t.type){case l:i.push(t.group);break;case h:i=[];break;default:n=!1}return{state:i,update:n}},items:function(e,t,i){var n=e,s=!0;switch(t.type){case u:t.item.selected=!0,(o=t.item.element)&&(o.selected=!0,o.setAttribute("selected","")),n.push(t.item);break;case d:var o;if(t.item.selected=!1,o=t.item.element){o.selected=!1,o.removeAttribute("selected");var c=o.parentElement;c&&J(c)&&c.type===g&&(c.value="")}Q(t.item),n=n.filter((function(e){return e.id!==t.item.id}));break;case r:Q(t.choice),n=n.filter((function(e){return e.id!==t.choice.id}));break;case p:var a=t.highlighted,h=n.find((function(e){return e.id===t.item.id}));h&&h.highlighted!==a&&(h.highlighted=a,i&&function(e,t,i){var n=e.itemEl;n&&(j(n,i),P(n,t))}(h,a?i.classNames.highlightedState:i.classNames.selectedState,a?i.classNames.selectedState:i.classNames.highlightedState));break;default:s=!1}return{state:n,update:s}},choices:function(e,t,i){var n=e,s=!0;switch(t.type){case o:n.push(t.choice);break;case r:t.choice.choiceEl=void 0,t.choice.group&&(t.choice.group.choices=t.choice.group.choices.filter((function(e){return e.id!==t.choice.id}))),n=n.filter((function(e){return e.id!==t.choice.id}));break;case u:case d:t.item.choiceEl=void 0;break;case c:var l=[];t.results.forEach((function(e){l[e.item.id]=e})),n.forEach((function(e){var t=l[e.id];void 0!==t?(e.score=t.score,e.rank=t.rank,e.active=!0):(e.score=0,e.rank=0,e.active=!1),i&&i.appendGroupInSearch&&(e.choiceEl=void 0)}));break;case a:n.forEach((function(e){e.active=t.active,i&&i.appendGroupInSearch&&(e.choiceEl=void 0)}));break;case h:n=[];break;default:s=!1}return{state:n,update:s}}},Z=function(){function e(e){this._state=this.defaultState,this._listeners=[],this._txn=0,this._context=e}return Object.defineProperty(e.prototype,"defaultState",{get:function(){return{groups:[],items:[],choices:[]}},enumerable:!1,configurable:!0}),e.prototype.changeSet=function(e){return{groups:e,items:e,choices:e}},e.prototype.reset=function(){this._state=this.defaultState;var e=this.changeSet(!0);this._txn?this._changeSet=e:this._listeners.forEach((function(t){return t(e)}))},e.prototype.subscribe=function(e){return this._listeners.push(e),this},e.prototype.dispatch=function(e){var t=this,i=this._state,n=!1,s=this._changeSet||this.changeSet(!1);Object.keys(Y).forEach((function(o){var r=Y[o](i[o],e,t._context);r.update&&(n=!0,s[o]=!0,i[o]=r.state)})),n&&(this._txn?this._changeSet=s:this._listeners.forEach((function(e){return e(s)})))},e.prototype.withTxn=function(e){this._txn++;try{e()}finally{if(this._txn=Math.max(0,this._txn-1),!this._txn){var t=this._changeSet;t&&(this._changeSet=void 0,this._listeners.forEach((function(e){return e(t)})))}}},Object.defineProperty(e.prototype,"state",{get:function(){return this._state},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"items",{get:function(){return this.state.items},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"highlightedActiveItems",{get:function(){return this.items.filter((function(e){return e.active&&e.highlighted}))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"choices",{get:function(){return this.state.choices},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"activeChoices",{get:function(){return this.choices.filter((function(e){return e.active}))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"searchableChoices",{get:function(){return this.choices.filter((function(e){return!e.disabled&&!e.placeholder}))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"groups",{get:function(){return this.state.groups},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"activeGroups",{get:function(){var e=this;return this.state.groups.filter((function(t){var i=t.active&&!t.disabled,n=e.state.choices.some((function(e){return e.active&&!e.disabled}));return i&&n}),[])},enumerable:!1,configurable:!0}),e.prototype.inTxn=function(){return this._txn>0},e.prototype.getChoiceById=function(e){return this.activeChoices.find((function(t){return t.id===e}))},e.prototype.getGroupById=function(e){return this.groups.find((function(t){return t.id===e}))},e}(),ee="no-choices",te="no-results",ie="add-choice";function ne(e,t,i){return(t=function(e){var t=function(e){if("object"!=typeof e||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var i=t.call(e,"string");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function se(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function oe(e){for(var t=1;t`Missing ${e} property in key`,fe=e=>`Property 'weight' in key '${e}' must be a positive integer`,me=Object.prototype.hasOwnProperty;class ve{constructor(e){this._keys=[],this._keyMap={};let t=0;e.forEach((e=>{let i=_e(e);this._keys.push(i),this._keyMap[i.id]=i,t+=i.weight})),this._keys.forEach((e=>{e.weight/=t}))}get(e){return this._keyMap[e]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function _e(e){let t=null,i=null,n=null,s=1,o=null;if(ce(e)||re(e))n=e,t=ge(e),i=ye(e);else{if(!me.call(e,"name"))throw new Error(pe("name"));const r=e.name;if(n=r,me.call(e,"weight")&&(s=e.weight,s<=0))throw new Error(fe(r));t=ge(r),i=ye(r),o=e.getFn}return{path:t,id:i,weight:s,src:n,getFn:o}}function ge(e){return re(e)?e:e.split(".")}function ye(e){return re(e)?e.join("."):e}const be={useExtendedSearch:!1,getFn:function(e,t){let i=[],n=!1;const s=(e,t,o)=>{if(le(e))if(t[o]){const r=e[t[o]];if(!le(r))return;if(o===t.length-1&&(ce(r)||ae(r)||function(e){return!0===e||!1===e||function(e){return he(e)&&null!==e}(e)&&"[object Boolean]"==de(e)}(r)))i.push(function(e){return null==e?"":function(e){if("string"==typeof e)return e;let t=e+"";return"0"==t&&1/e==-1/0?"-0":t}(e)}(r));else if(re(r)){n=!0;for(let e=0,i=r.length;ee.score===t.score?e.idx{this._keysMap[e.id]=t}))}create(){!this.isCreated&&this.docs.length&&(this.isCreated=!0,ce(this.docs[0])?this.docs.forEach(((e,t)=>{this._addString(e,t)})):this.docs.forEach(((e,t)=>{this._addObject(e,t)})),this.norm.clear())}add(e){const t=this.size();ce(e)?this._addString(e,t):this._addObject(e,t)}removeAt(e){this.records.splice(e,1);for(let t=e,i=this.size();t{let s=t.getFn?t.getFn(e):this.getFn(e,t.path);if(le(s))if(re(s)){let e=[];const t=[{nestedArrIndex:-1,value:s}];for(;t.length;){const{nestedArrIndex:i,value:n}=t.pop();if(le(n))if(ce(n)&&!ue(n)){let t={v:n,i:i,n:this.norm.get(n)};e.push(t)}else re(n)&&n.forEach(((e,i)=>{t.push({nestedArrIndex:i,value:e})}))}i.$[n]=e}else if(ce(s)&&!ue(s)){let e={v:s,n:this.norm.get(s)};i.$[n]=e}})),this.records.push(i)}toJSON(){return{keys:this.keys,records:this.records}}}function Se(e,t,{getFn:i=Ee.getFn,fieldNormWeight:n=Ee.fieldNormWeight}={}){const s=new we({getFn:i,fieldNormWeight:n});return s.setKeys(e.map(_e)),s.setSources(t),s.create(),s}function Ie(e,{errors:t=0,currentLocation:i=0,expectedLocation:n=0,distance:s=Ee.distance,ignoreLocation:o=Ee.ignoreLocation}={}){const r=t/e.length;if(o)return r;const c=Math.abs(n-i);return s?r+c/s:c?1:r}const Ae=32;function Oe(e){let t={};for(let i=0,n=e.length;i{this.chunks.push({pattern:e,alphabet:Oe(e),startIndex:t})},l=this.pattern.length;if(l>Ae){let e=0;const t=l%Ae,i=l-t;for(;e{const{isMatch:f,score:m,indices:v}=function(e,t,i,{location:n=Ee.location,distance:s=Ee.distance,threshold:o=Ee.threshold,findAllMatches:r=Ee.findAllMatches,minMatchCharLength:c=Ee.minMatchCharLength,includeMatches:a=Ee.includeMatches,ignoreLocation:h=Ee.ignoreLocation}={}){if(t.length>Ae)throw new Error("Pattern length exceeds max of 32.");const l=t.length,u=e.length,d=Math.max(0,Math.min(n,u));let p=o,f=d;const m=c>1||a,v=m?Array(u):[];let _;for(;(_=e.indexOf(t,f))>-1;){let e=Ie(t,{currentLocation:_,expectedLocation:d,distance:s,ignoreLocation:h});if(p=Math.min(e,p),f=_+l,m){let e=0;for(;e=a;o-=1){let r=o-1,c=i[e.charAt(r)];if(m&&(v[r]=+!!c),C[o]=(C[o+1]<<1|1)&c,n&&(C[o]|=(g[o+1]|g[o])<<1|1|g[o+1]),C[o]&E&&(y=Ie(t,{errors:n,currentLocation:r,expectedLocation:d,distance:s,ignoreLocation:h}),y<=p)){if(p=y,f=r,f<=d)break;a=Math.max(1,2*d-f)}}if(Ie(t,{errors:n+1,currentLocation:d,expectedLocation:d,distance:s,ignoreLocation:h})>p)break;g=C}const C={isMatch:f>=0,score:Math.max(.001,y)};if(m){const e=function(e=[],t=Ee.minMatchCharLength){let i=[],n=-1,s=-1,o=0;for(let r=e.length;o=t&&i.push([n,s]),n=-1)}return e[o-1]&&o-n>=t&&i.push([n,o-1]),i}(v,c);e.length?a&&(C.indices=e):C.isMatch=!1}return C}(e,t,d,{location:n+p,distance:s,threshold:o,findAllMatches:r,minMatchCharLength:c,includeMatches:i,ignoreLocation:a});f&&(u=!0),l+=m,f&&v&&(h=[...h,...v])}));let d={isMatch:u,score:u?l/this.chunks.length:1};return u&&i&&(d.indices=h),d}}const Le=[];function Te(e,t){for(let i=0,n=Le.length;i!(!e[Ne]&&!e.$or),De=e=>({[Ne]:Object.keys(e).map((t=>({[t]:e[t]})))});function ke(e,t){const i=e.matches;t.matches=[],le(i)&&i.forEach((e=>{if(!le(e.indices)||!e.indices.length)return;const{indices:i,value:n}=e;let s={indices:i,value:n};e.key&&(s.key=e.key.src),e.idx>-1&&(s.refIndex=e.idx),t.matches.push(s)}))}function Pe(e,t){t.score=e.score}class je{constructor(e,t={},i){if(this.options=oe(oe({},Ee),t),this.options.useExtendedSearch)throw new Error("Extended search is not available");this._keyStore=new ve(this.options.keys),this.setCollection(e,i)}setCollection(e,t){if(this._docs=e,t&&!(t instanceof we))throw new Error("Incorrect 'index' type");this._myIndex=t||Se(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(e){le(e)&&(this._docs.push(e),this._myIndex.add(e))}remove(e=()=>!1){const t=[];for(let i=0,n=this._docs.length;i{let i=1;e.matches.forEach((({key:e,norm:n,score:s})=>{const o=e?e.weight:null;i*=Math.pow(0===s&&o?Number.EPSILON:s,(o||1)*(t?1:n))})),e.score=i}))}(c,{ignoreFieldNorm:r}),s&&c.sort(o),ae(t)&&t>-1&&(c=c.slice(0,t)),function(e,t,{includeMatches:i=Ee.includeMatches,includeScore:n=Ee.includeScore}={}){const s=[];return i&&s.push(ke),n&&s.push(Pe),e.map((e=>{const{idx:i}=e,n={item:t[i],refIndex:i};return s.length&&s.forEach((t=>{t(e,n)})),n}))}(c,this._docs,{includeMatches:i,includeScore:n})}_searchStringList(e){const t=Te(e,this.options),{records:i}=this._myIndex,n=[];return i.forEach((({v:e,i:i,n:s})=>{if(!le(e))return;const{isMatch:o,score:r,indices:c}=t.searchIn(e);o&&n.push({item:e,idx:i,matches:[{score:r,value:e,norm:s,indices:c}]})})),n}_searchLogical(e){throw new Error("Logical search is not available")}_searchObjectList(e){const t=Te(e,this.options),{keys:i,records:n}=this._myIndex,s=[];return n.forEach((({$:e,i:n})=>{if(!le(e))return;let o=[];i.forEach(((i,n)=>{o.push(...this._findMatches({key:i,value:e[n],searcher:t}))})),o.length&&s.push({idx:n,item:e,matches:o})})),s}_findMatches({key:e,value:t,searcher:i}){if(!le(t))return[];let n=[];if(re(t))t.forEach((({v:t,i:s,n:o})=>{if(!le(t))return;const{isMatch:r,score:c,indices:a}=i.searchIn(t);r&&n.push({score:c,key:e,value:t,idx:s,norm:o,indices:a})}));else{const{v:s,n:o}=t,{isMatch:r,score:c,indices:a}=i.searchIn(s);r&&n.push({score:c,key:e,value:s,norm:o,indices:a})}return n}}je.version="7.0.0",je.createIndex=Se,je.parseIndex=function(e,{getFn:t=Ee.getFn,fieldNormWeight:i=Ee.fieldNormWeight}={}){const{keys:n,records:s}=e,o=new we({getFn:t,fieldNormWeight:i});return o.setKeys(n),o.setIndexRecords(s),o},je.config=Ee,je.parseQuery=function(e,t,{auto:i=!0}={}){const n=e=>{let s=Object.keys(e);const o=(e=>!!e[Me])(e);if(!o&&s.length>1&&!Fe(e))return n(De(e));if((e=>!re(e)&&he(e)&&!Fe(e))(e)){const n=o?e[Me]:s[0],r=o?e.$val:e[n];if(!ce(r))throw new Error((e=>`Invalid value for key ${e}`)(n));const c={keyId:ye(n),pattern:r};return i&&(c.searcher=Te(r,t)),c}let r={children:[],operator:s[0]};return s.forEach((t=>{const i=e[t];re(i)&&i.forEach((e=>{r.children.push(n(e))}))})),r};return Fe(e)||(e=De(e)),n(e)};var Ke=function(){function e(e){this._haystack=[],this._fuseOptions=i(i({},e.fuseOptions),{keys:n([],e.searchFields,!0),includeMatches:!0})}return e.prototype.index=function(e){this._haystack=e,this._fuse&&this._fuse.setCollection(e)},e.prototype.reset=function(){this._haystack=[],this._fuse=void 0},e.prototype.isEmptyIndex=function(){return!this._haystack.length},e.prototype.search=function(e){return this._fuse||(this._fuse=new je(this._haystack,this._fuseOptions)),this._fuse.search(e).map((function(e,t){return{item:e.item,score:e.score||0,rank:t+1}}))},e}(),Be=function(e,t,i){var n=e.dataset,s=t.customProperties,o=t.labelClass,r=t.labelDescription;o&&(n.labelClass=D(o).join(" ")),r&&(n.labelDescription=r),i&&s&&("string"==typeof s?n.customProperties=s:"object"!=typeof s||function(e){for(var t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!1;return!0}(s)||(n.customProperties=JSON.stringify(s)))},Ve=function(e,t,i){var n=t&&e.querySelector("label[for='".concat(t,"']")),s=n&&n.innerText;s&&i.setAttribute("aria-label",s)},He={containerOuter:function(e,t,i,n,s,o,r){var c=e.classNames.containerOuter,a=document.createElement("div");return P(a,c),a.dataset.type=o,t&&(a.dir=t),n&&(a.tabIndex=0),i&&(a.setAttribute("role",s?"combobox":"listbox"),s?a.setAttribute("aria-autocomplete","list"):r||Ve(this._docRoot,this.passedElement.element.id,a),a.setAttribute("aria-haspopup","true"),a.setAttribute("aria-expanded","false")),r&&a.setAttribute("aria-labelledby",r),a},containerInner:function(e){var t=e.classNames.containerInner,i=document.createElement("div");return P(i,t),i},itemList:function(e,t){var i=e.searchEnabled,n=e.classNames,s=n.list,o=n.listSingle,r=n.listItems,c=document.createElement("div");return P(c,s),P(c,t?o:r),this._isSelectElement&&i&&c.setAttribute("role","listbox"),c},placeholder:function(e,t){var i=e.allowHTML,n=e.classNames.placeholder,s=document.createElement("div");return P(s,n),M(s,i,t),s},item:function(e,t,i){var n=e.allowHTML,s=e.removeItemButtonAlignLeft,o=e.removeItemIconText,r=e.removeItemLabelText,c=e.classNames,a=c.item,h=c.button,l=c.highlightedState,u=c.itemSelectable,d=c.placeholder,p=L(t.value),f=document.createElement("div");if(P(f,a),t.labelClass){var m=document.createElement("span");M(m,n,t.label),P(m,t.labelClass),f.appendChild(m)}else M(f,n,t.label);if(f.dataset.item="",f.dataset.id=t.id,f.dataset.value=p,Be(f,t,!0),(t.disabled||this.containerOuter.isDisabled)&&f.setAttribute("aria-disabled","true"),this._isSelectElement&&(f.setAttribute("aria-selected","true"),f.setAttribute("role","option")),t.placeholder&&(P(f,d),f.dataset.placeholder=""),P(f,t.highlighted?l:u),i){t.disabled&&j(f,u),f.dataset.deletable="";var v=document.createElement("button");v.type="button",P(v,h),M(v,!0,O(o,t.value));var _=O(r,t.value);_&&v.setAttribute("aria-label",_),v.dataset.button="",s?f.insertAdjacentElement("afterbegin",v):f.appendChild(v)}return f},choiceList:function(e,t){var i=e.classNames.list,n=document.createElement("div");return P(n,i),t||n.setAttribute("aria-multiselectable","true"),n.setAttribute("role","listbox"),n},choiceGroup:function(e,t){var i=e.allowHTML,n=e.classNames,s=n.group,o=n.groupHeading,r=n.itemDisabled,c=t.id,a=t.label,h=t.disabled,l=L(a),u=document.createElement("div");P(u,s),h&&P(u,r),u.setAttribute("role","group"),u.dataset.group="",u.dataset.id=c,u.dataset.value=l,h&&u.setAttribute("aria-disabled","true");var d=document.createElement("div");return P(d,o),M(d,i,a||""),u.appendChild(d),u},choice:function(e,t,i,n){var s=e.allowHTML,o=e.classNames,r=o.item,c=o.itemChoice,a=o.itemSelectable,h=o.selectedState,l=o.itemDisabled,u=o.description,d=o.placeholder,p=t.label,f=L(t.value),m=document.createElement("div");m.id=t.elementId,P(m,r),P(m,c),n&&"string"==typeof p&&(p=N(s,p),p={trusted:p+=" (".concat(n,")")});var v=m;if(t.labelClass){var _=document.createElement("span");M(_,s,p),P(_,t.labelClass),v=_,m.appendChild(_)}else M(m,s,p);if(t.labelDescription){var g="".concat(t.elementId,"-description");v.setAttribute("aria-describedby",g);var y=document.createElement("span");M(y,s,t.labelDescription),y.id=g,P(y,u),m.appendChild(y)}return t.selected&&P(m,h),t.placeholder&&P(m,d),m.setAttribute("role",t.group?"treeitem":"option"),m.dataset.choice="",m.dataset.id=t.id,m.dataset.value=f,i&&(m.dataset.selectText=i),t.group&&(m.dataset.groupId="".concat(t.group.id)),Be(m,t,!1),t.disabled?(P(m,l),m.dataset.choiceDisabled="",m.setAttribute("aria-disabled","true")):(P(m,a),m.dataset.choiceSelectable=""),m},input:function(e,t){var i=e.classNames,n=i.input,s=i.inputCloned,o=e.labelId,r=document.createElement("input");return r.type="search",P(r,n),P(r,s),r.autocomplete="off",r.autocapitalize="off",r.spellcheck=!1,r.setAttribute("aria-autocomplete","list"),t?r.setAttribute("aria-label",t):o||Ve(this._docRoot,this.passedElement.element.id,r),r},dropdown:function(e){var t=e.classNames,i=t.list,n=t.listDropdown,s=document.createElement("div");return P(s,i),P(s,n),s.setAttribute("aria-expanded","false"),s},notice:function(e,t,i){var n=e.classNames,s=n.item,o=n.itemChoice,r=n.addChoice,c=n.noResults,a=n.noChoices,h=n.notice;void 0===i&&(i="");var l=document.createElement("div");switch(M(l,!0,t),P(l,s),P(l,o),P(l,h),i){case ie:P(l,r);break;case te:P(l,c);break;case ee:P(l,a)}return i===ie&&(l.dataset.choiceSelectable="",l.dataset.choice=""),l},option:function(e){var t=L(e.label),i=new Option(t,e.value,!1,e.selected);return Be(i,e,!0),i.disabled=e.disabled,e.selected&&i.setAttribute("selected",""),i}},Re="-ms-scroll-limit"in document.documentElement.style&&"-ms-ime-align"in document.documentElement.style,qe={},Ue=function(e){if(e)return e.dataset.id?parseInt(e.dataset.id,10):void 0},Ge="[data-choice-selectable]";return function(){function e(t,n){void 0===t&&(t="[data-choice]"),void 0===n&&(n={});var s=this;this.initialisedOK=void 0,this._hasNonChoicePlaceholder=!1,this._lastAddedChoiceId=0,this._lastAddedGroupId=0;var o=e.defaults;this.config=i(i(i({},o.allOptions),o.options),n),_.forEach((function(e){s.config[e]=i(i(i({},o.allOptions[e]),o.options[e]),n[e])}));var r=this.config;r.silent||this._validateConfig();var c=r.shadowRoot||document.documentElement;this._docRoot=c;var a="string"==typeof t?c.querySelector(t):t;if(!a||"object"!=typeof a||"INPUT"!==a.tagName&&!J(a)){if(!a&&"string"==typeof t)throw TypeError("Selector ".concat(t," failed to find an element"));throw TypeError("Expected one of the following types text|select-one|select-multiple")}var h=a.type,l="text"===h;(l||1!==r.maxItemCount)&&(r.singleModeForMultiSelect=!1),r.singleModeForMultiSelect&&(h=y);var u=h===g,d=h===y,p=u||d;if(this._elementType=h,this._isTextElement=l,this._isSelectOneElement=u,this._isSelectMultipleElement=d,this._isSelectElement=u||d,this._canAddUserChoices=l&&r.addItems||p&&r.addChoices,"boolean"!=typeof r.renderSelectedChoices&&(r.renderSelectedChoices="always"===r.renderSelectedChoices||u),r.closeDropdownOnSelect="auto"===r.closeDropdownOnSelect?l||u||r.singleModeForMultiSelect:G(r.closeDropdownOnSelect),r.placeholder&&(r.placeholderValue?this._hasNonChoicePlaceholder=!0:a.dataset.placeholder&&(this._hasNonChoicePlaceholder=!0,r.placeholderValue=a.dataset.placeholder)),n.addItemFilter&&"function"!=typeof n.addItemFilter){var f=n.addItemFilter instanceof RegExp?n.addItemFilter:new RegExp(n.addItemFilter);r.addItemFilter=f.test.bind(f)}if(this.passedElement=this._isTextElement?new U({element:a,classNames:r.classNames}):new z({element:a,classNames:r.classNames,template:function(e){return s._templates.option(e)},extractPlaceholder:r.placeholder&&!this._hasNonChoicePlaceholder}),this.initialised=!1,this._store=new Z(r),this._currentValue="",r.searchEnabled=!l&&r.searchEnabled||d,this._canSearch=r.searchEnabled,this._isScrollingOnIe=!1,this._highlightPosition=0,this._wasTap=!0,this._placeholderValue=this._generatePlaceholderValue(),this._baseId=function(e){var t=e.id||e.name&&"".concat(e.name,"-").concat(S(2))||S(4);return t=t.replace(/(:|\.|\[|\]|,)/g,""),"".concat("choices-","-").concat(t)}(a),this._direction=a.dir,!this._direction){var m=window.getComputedStyle(a).direction;m!==window.getComputedStyle(document.documentElement).direction&&(this._direction=m)}if(this._idNames={itemChoice:"item-choice"},this._templates=o.templates,this._render=this._render.bind(this),this._onFocus=this._onFocus.bind(this),this._onBlur=this._onBlur.bind(this),this._onKeyUp=this._onKeyUp.bind(this),this._onKeyDown=this._onKeyDown.bind(this),this._onInput=this._onInput.bind(this),this._onClick=this._onClick.bind(this),this._onTouchMove=this._onTouchMove.bind(this),this._onTouchEnd=this._onTouchEnd.bind(this),this._onMouseDown=this._onMouseDown.bind(this),this._onMouseOver=this._onMouseOver.bind(this),this._onFormReset=this._onFormReset.bind(this),this._onSelectKey=this._onSelectKey.bind(this),this._onEnterKey=this._onEnterKey.bind(this),this._onEscapeKey=this._onEscapeKey.bind(this),this._onDirectionKey=this._onDirectionKey.bind(this),this._onDeleteKey=this._onDeleteKey.bind(this),this.passedElement.isActive)return r.silent||console.warn("Trying to initialise Choices on element already initialised",{element:t}),this.initialised=!0,void(this.initialisedOK=!1);this.init(),this._initialItems=this._store.items.map((function(e){return e.value}))}return Object.defineProperty(e,"defaults",{get:function(){return Object.preventExtensions({get options(){return qe},get allOptions(){return X},get templates(){return He}})},enumerable:!1,configurable:!0}),e.prototype.init=function(){if(!this.initialised&&void 0===this.initialisedOK){this._searcher=new Ke(this.config),this._loadChoices(),this._createTemplates(),this._createElements(),this._createStructure(),this._isTextElement&&!this.config.addItems||this.passedElement.element.hasAttribute("disabled")||this.passedElement.element.closest("fieldset:disabled")?this.disable():(this.enable(),this._addEventListeners()),this._initStore(),this.initialised=!0,this.initialisedOK=!0;var e=this.config.callbackOnInit;"function"==typeof e&&e.call(this)}},e.prototype.destroy=function(){this.initialised&&(this._removeEventListeners(),this.passedElement.reveal(),this.containerOuter.unwrap(this.passedElement.element),this._store._listeners=[],this.clearStore(!1),this._stopSearch(),this._templates=e.defaults.templates,this.initialised=!1,this.initialisedOK=void 0)},e.prototype.enable=function(){return this.passedElement.isDisabled&&this.passedElement.enable(),this.containerOuter.isDisabled&&(this._addEventListeners(),this.input.enable(),this.containerOuter.enable()),this},e.prototype.disable=function(){return this.passedElement.isDisabled||this.passedElement.disable(),this.containerOuter.isDisabled||(this._removeEventListeners(),this.input.disable(),this.containerOuter.disable()),this},e.prototype.highlightItem=function(e,t){if(void 0===t&&(t=!0),!e||!e.id)return this;var i=this._store.items.find((function(t){return t.id===e.id}));return!i||i.highlighted||(this._store.dispatch(w(i,!0)),t&&this.passedElement.triggerEvent(v,this._getChoiceForOutput(i))),this},e.prototype.unhighlightItem=function(e,t){if(void 0===t&&(t=!0),!e||!e.id)return this;var i=this._store.items.find((function(t){return t.id===e.id}));return i&&i.highlighted?(this._store.dispatch(w(i,!1)),t&&this.passedElement.triggerEvent("unhighlightItem",this._getChoiceForOutput(i)),this):this},e.prototype.highlightAll=function(){var e=this;return this._store.withTxn((function(){e._store.items.forEach((function(t){t.highlighted||(e._store.dispatch(w(t,!0)),e.passedElement.triggerEvent(v,e._getChoiceForOutput(t)))}))})),this},e.prototype.unhighlightAll=function(){var e=this;return this._store.withTxn((function(){e._store.items.forEach((function(t){t.highlighted&&(e._store.dispatch(w(t,!1)),e.passedElement.triggerEvent(v,e._getChoiceForOutput(t)))}))})),this},e.prototype.removeActiveItemsByValue=function(e){var t=this;return this._store.withTxn((function(){t._store.items.filter((function(t){return t.value===e})).forEach((function(e){return t._removeItem(e)}))})),this},e.prototype.removeActiveItems=function(e){var t=this;return this._store.withTxn((function(){t._store.items.filter((function(t){return t.id!==e})).forEach((function(e){return t._removeItem(e)}))})),this},e.prototype.removeHighlightedItems=function(e){var t=this;return void 0===e&&(e=!1),this._store.withTxn((function(){t._store.highlightedActiveItems.forEach((function(i){t._removeItem(i),e&&t._triggerChange(i.value)}))})),this},e.prototype.showDropdown=function(e){var t=this;return this.dropdown.isActive||(void 0===e&&(e=!this._canSearch),requestAnimationFrame((function(){t.dropdown.show();var i=t.dropdown.element.getBoundingClientRect();t.containerOuter.open(i.bottom,i.height),e||t.input.focus(),t.passedElement.triggerEvent("showDropdown")}))),this},e.prototype.hideDropdown=function(e){var t=this;return this.dropdown.isActive?(requestAnimationFrame((function(){t.dropdown.hide(),t.containerOuter.close(),!e&&t._canSearch&&(t.input.removeActiveDescendant(),t.input.blur()),t.passedElement.triggerEvent("hideDropdown")})),this):this},e.prototype.getValue=function(e){var t=this,i=this._store.items.map((function(i){return e?i.value:t._getChoiceForOutput(i)}));return this._isSelectOneElement||this.config.singleModeForMultiSelect?i[0]:i},e.prototype.setValue=function(e){var t=this;return this.initialisedOK?(this._store.withTxn((function(){e.forEach((function(e){e&&t._addChoice($(e,!1))}))})),this._searcher.reset(),this):(this._warnChoicesInitFailed("setValue"),this)},e.prototype.setChoiceByValue=function(e){var t=this;return this.initialisedOK?(this._isTextElement||(this._store.withTxn((function(){(Array.isArray(e)?e:[e]).forEach((function(e){return t._findAndSelectChoiceByValue(e)})),t.unhighlightAll()})),this._searcher.reset()),this):(this._warnChoicesInitFailed("setChoiceByValue"),this)},e.prototype.setChoices=function(e,t,n,s,o,r){var c=this;if(void 0===e&&(e=[]),void 0===t&&(t="value"),void 0===n&&(n="label"),void 0===s&&(s=!1),void 0===o&&(o=!0),void 0===r&&(r=!1),!this.initialisedOK)return this._warnChoicesInitFailed("setChoices"),this;if(!this._isSelectElement)throw new TypeError("setChoices can't be used with INPUT based Choices");if("string"!=typeof t||!t)throw new TypeError("value parameter must be a name of 'value' field in passed objects");if("function"==typeof e){var a=e(this);if("function"==typeof Promise&&a instanceof Promise)return new Promise((function(e){return requestAnimationFrame(e)})).then((function(){return c._handleLoadingState(!0)})).then((function(){return a})).then((function(e){return c.setChoices(e,t,n,s,o,r)})).catch((function(e){c.config.silent||console.error(e)})).then((function(){return c._handleLoadingState(!1)})).then((function(){return c}));if(!Array.isArray(a))throw new TypeError(".setChoices first argument function must return either array of choices or Promise, got: ".concat(typeof a));return this.setChoices(a,t,n,!1)}if(!Array.isArray(e))throw new TypeError(".setChoices must be called either with array of choices with a function resulting into Promise of array of choices");return this.containerOuter.removeLoadingState(),this._store.withTxn((function(){o&&(c._isSearching=!1),s&&c.clearChoices(!0,r);var a="value"===t,h="label"===n;e.forEach((function(e){if("choices"in e){var s=e;h||(s=i(i({},s),{label:s[n]})),c._addGroup($(s,!0))}else{var o=e;h&&a||(o=i(i({},o),{value:o[t],label:o[n]}));var r=$(o,!1);c._addChoice(r),r.placeholder&&!c._hasNonChoicePlaceholder&&(c._placeholderValue=T(r.label))}})),c.unhighlightAll()})),this._searcher.reset(),this},e.prototype.refresh=function(e,t,i){var n=this;return void 0===e&&(e=!1),void 0===t&&(t=!1),void 0===i&&(i=!1),this._isSelectElement?(this._store.withTxn((function(){var s=n.passedElement.optionsAsChoices(),o={};i||n._store.items.forEach((function(e){e.id&&e.active&&e.selected&&(o[e.value]=!0)})),n.clearStore(!1);var r=function(e){i?n._store.dispatch(C(e)):o[e.value]&&(e.selected=!0)};s.forEach((function(e){"choices"in e?e.choices.forEach(r):r(e)})),n._addPredefinedChoices(s,t,e),n._isSearching&&n._searchChoices(n.input.value)})),this):(this.config.silent||console.warn("refresh method can only be used on choices backed by a element"),this)},e.prototype.removeChoice=function(e){var t=this._store.choices.find((function(t){return t.value===e}));return t?(this._clearNotice(),this._store.dispatch(function(e){return{type:r,choice:e}}(t)),this._searcher.reset(),t.selected&&this.passedElement.triggerEvent(m,N(t)),this):this},e.prototype.clearChoices=function(e,t){var i=this;return void 0===e&&(e=!0),void 0===t&&(t=!1),e&&(t?this.passedElement.element.replaceChildren(""):this.passedElement.element.querySelectorAll(":not([selected])").forEach((function(e){e.remove()}))),this.itemList.element.replaceChildren(""),this.choiceList.element.replaceChildren(""),this._clearNotice(),this._store.withTxn((function(){var e=t?[]:i._store.items;i._store.reset(),e.forEach((function(e){i._store.dispatch(b(e)),i._store.dispatch(E(e))}))})),this._searcher.reset(),this},e.prototype.clearStore=function(e){return void 0===e&&(e=!0),this.clearChoices(e,!0),this._stopSearch(),this._lastAddedChoiceId=0,this._lastAddedGroupId=0,this},e.prototype.clearInput=function(){return this.input.clear(!this._isSelectOneElement),this._stopSearch(),this},e.prototype._validateConfig=function(){var e,t,i,n=this.config,s=(e=Y,t=Object.keys(n).sort(),i=Object.keys(e).sort(),t.filter((function(e){return i.indexOf(e)<0})));s.length&&console.warn("Unknown config option(s) passed",s.join(", ")),n.allowHTML&&n.allowHtmlUserInput&&(n.addItems&&console.warn("Warning: allowHTML/allowHtmlUserInput/addItems all being true is strongly not recommended and may lead to XSS attacks"),n.addChoices&&console.warn("Warning: allowHTML/allowHtmlUserInput/addChoices all being true is strongly not recommended and may lead to XSS attacks"))},e.prototype._render=function(e){void 0===e&&(e={choices:!0,groups:!0,items:!0}),this._store.inTxn()||(this._isSelectElement&&(e.choices||e.groups)&&this._renderChoices(),e.items&&this._renderItems())},e.prototype._renderChoices=function(){var e=this;if(this._canAddItems()){var t=this.config,i=this._isSearching,n=this._store,s=n.activeGroups,o=n.activeChoices,r=i?t.searchResultLimit:t.renderChoiceLimit;if(this._isSelectElement){var a=o.filter((function(e){return!e.element}));a.length&&this.passedElement.addOptions(a)}var c=document.createDocumentFragment(),l=function(e){return e.filter((function(e){return!e.placeholder&&(i?(t.searchRenderSelectedChoices||!e.selected)&&!!e.rank:t.renderSelectedChoices||!e.selected)}))},h=t.appendGroupInSearch&&i,u=!1,d=null,p=function(n,s){i?n.sort(P):t.shouldSort&&n.sort(t.sorter);var o=n.length;o=!s&&r>0&&o>r?r:o,o--,n.every((function(n,s){var r=n.choiceEl||e._templates.choice(t,n,t.itemSelectText,h&&n.group?n.group.label:void 0);return n.choiceEl=r,c.appendChild(r),i||!n.selected?u=!0:d||(d=r),s1){var l=i.querySelector(j(n.classNames.placeholder));l&&l.remove()}else a||c||!this._placeholderValue||(a=!0,r(z({selected:!0,value:"",label:this._placeholderValue,placeholder:!0},!1)))}a&&(i.append(s),n.shouldSortItems&&!this._isSelectOneElement&&(t.sort(n.sorter),t.forEach((function(e){var t=o(e);t&&(t.remove(),s.append(t))})),i.append(s))),this._isTextElement&&(this.passedElement.value=t.map((function(e){return e.value})).join(n.delimiter))},e.prototype._displayNotice=function(e,t,i){void 0===i&&(i=!0);var n=this._notice;n&&(n.type===t&&n.text===e||n.type===se&&(t===ne||t===ie))?i&&this.showDropdown(!0):(this._clearNotice(),this._notice=e?{text:e,type:t}:void 0,this._renderNotice(),i&&e&&this.showDropdown(!0))},e.prototype._clearNotice=function(){if(this._notice){var e=this.choiceList.element.querySelector(j(this.config.classNames.notice));e&&e.remove(),this._notice=void 0}},e.prototype._renderNotice=function(e){var t=this._notice;if(t){var i=this._templates.notice(this.config,t.text,t.type);e?e.append(i):this.choiceList.prepend(i)}},e.prototype._getChoiceForOutput=function(e,t){return N(e,t)},e.prototype._triggerChange=function(e){null!=e&&this.passedElement.triggerEvent("change",{value:e})},e.prototype._handleButtonAction=function(e){var t=this,i=this._store.items;if(i.length&&this.config.removeItems&&this.config.removeItemButton){var n=e&&We(e.closest("[data-id]")),s=n&&i.find((function(e){return e.id===n}));s&&this._store.withTxn((function(){if(t._removeItem(s),t._triggerChange(s.value),t._isSelectOneElement&&!t._hasNonChoicePlaceholder){var e=(t.config.shouldSort?t._store.choices.reverse():t._store.choices).find((function(e){return e.placeholder}));e&&(t._addItem(e),t.unhighlightAll(),e.value&&t._triggerChange(e.value))}}))}},e.prototype._handleItemAction=function(e,t){var i=this;void 0===t&&(t=!1);var n=this._store.items;if(n.length&&this.config.removeItems&&!this._isSelectOneElement){var s=We(e);s&&(n.forEach((function(e){e.id!==s||e.highlighted?!t&&e.highlighted&&i.unhighlightItem(e):i.highlightItem(e)})),this.input.focus())}},e.prototype._handleChoiceAction=function(e){var t=this,i=We(e),n=i&&this._store.getChoiceById(i);if(!n||n.disabled)return!1;var s=this.dropdown.isActive;if(!n.selected){if(!this._canAddItems())return!0;this._store.withTxn((function(){t._addItem(n,!0,!0),t.clearInput(),t.unhighlightAll()})),this._triggerChange(n.value)}return s&&this.config.closeDropdownOnSelect&&(this.hideDropdown(!0),this.containerOuter.element.focus()),!0},e.prototype._handleBackspace=function(e){var t=this.config;if(t.removeItems&&e.length){var i=e[e.length-1],n=e.some((function(e){return e.highlighted}));t.editItems&&!n&&i?(this.input.value=i.value,this.input.setWidth(),this._removeItem(i),this._triggerChange(i.value)):(n||this.highlightItem(i,!1),this.removeHighlightedItems(!0))}},e.prototype._loadChoices=function(){var e,t=this,i=this.config;if(this._isTextElement){if(this._presetChoices=i.items.map((function(e){return z(e,!1)})),this.passedElement.value){var n=this.passedElement.value.split(i.delimiter).map((function(e){return z(e,!1,t.config.allowHtmlUserInput)}));this._presetChoices=this._presetChoices.concat(n)}this._presetChoices.forEach((function(e){e.selected=!0}))}else if(this._isSelectElement){this._presetChoices=i.choices.map((function(e){return z(e,!0)}));var s=this.passedElement.optionsAsChoices();s&&(e=this._presetChoices).push.apply(e,s)}},e.prototype._handleLoadingState=function(e){void 0===e&&(e=!0);var t=this.itemList.element;e?(this.disable(),this.containerOuter.addLoadingState(),this._isSelectOneElement?t.replaceChildren(this._templates.placeholder(this.config,this.config.loadingText)):this.input.placeholder=this.config.loadingText):(this.enable(),this.containerOuter.removeLoadingState(),this._isSelectOneElement?(t.replaceChildren(""),this._render()):this.input.placeholder=this._placeholderValue||"")},e.prototype._handleSearch=function(e){if(this.input.isFocussed)if(null!=e&&e.length>=this.config.searchFloor){var t=this.config.searchChoices?this._searchChoices(e):0;null!==t&&this.passedElement.triggerEvent(f,{value:e,resultCount:t})}else this._store.choices.some((function(e){return!e.active}))&&this._stopSearch()},e.prototype._canAddItems=function(){var e=this.config,t=e.maxItemCount,i=e.maxItemText;return!e.singleModeForMultiSelect&&t>0&&t<=this._store.items.length?(this.choiceList.element.replaceChildren(""),this._notice=void 0,this._displayNotice("function"==typeof i?i(t):i,se),!1):(this._notice&&this._notice.type===se&&this._clearNotice(),!0)},e.prototype._canCreateItem=function(e){var t=this.config,i=!0,n="";if(i&&"function"==typeof t.addItemFilter&&!t.addItemFilter(e)&&(i=!1,n=M(t.customAddItemText,e,void 0)),i&&this._store.choices.find((function(i){return t.valueComparer(i.value,e)}))){if(this._isSelectElement)return this._displayNotice("",se),!1;t.duplicateItemsAllowed||(i=!1,n=M(t.uniqueItemText,e,void 0))}return i&&(n=M(t.addItemText,e,void 0)),n&&this._displayNotice(n,se),i},e.prototype._searchChoices=function(e){var t=e.trim().replace(/\s{2,}/," ");if(!t.length||t===this._currentValue)return null;var i=this._searcher;i.isEmptyIndex()&&i.index(this._store.searchableChoices);var n=i.search(t);this._currentValue=t,this._highlightPosition=0,this._isSearching=!0;var s=this._notice;return(s&&s.type)!==se&&(n.length?this._clearNotice():this._displayNotice(x(this.config.noResultsText),ne)),this._store.dispatch(function(e){return{type:a,results:e}}(n)),n.length},e.prototype._stopSearch=function(){this._isSearching&&(this._currentValue="",this._isSearching=!1,this._clearNotice(),this._store.dispatch({type:c,active:!0}),this.passedElement.triggerEvent(f,{value:"",resultCount:0}))},e.prototype._addEventListeners=function(){var e=this._docRoot,t=this.containerOuter.element,i=this.input.element,n=this.passedElement.element;e.addEventListener("touchend",this._onTouchEnd,!0),t.addEventListener("keydown",this._onKeyDown,!0),t.addEventListener("mousedown",this._onMouseDown,!0),e.addEventListener("click",this._onClick,{passive:!0}),e.addEventListener("touchmove",this._onTouchMove,{passive:!0}),this.dropdown.element.addEventListener("mouseover",this._onMouseOver,{passive:!0}),this._isSelectOneElement&&(t.addEventListener("focus",this._onFocus,{passive:!0}),t.addEventListener("blur",this._onBlur,{passive:!0})),i.addEventListener("keyup",this._onKeyUp,{passive:!0}),i.addEventListener("input",this._onInput,{passive:!0}),i.addEventListener("focus",this._onFocus,{passive:!0}),i.addEventListener("blur",this._onBlur,{passive:!0}),i.form&&i.form.addEventListener("reset",this._onFormReset,{passive:!0}),n.hasAttribute("required")&&(n.addEventListener("change",this._onChange,{passive:!0}),n.addEventListener("invalid",this._onInvalid,{passive:!0})),this.input.addEventListeners()},e.prototype._removeEventListeners=function(){var e=this._docRoot,t=this.containerOuter.element,i=this.input.element,n=this.passedElement.element;e.removeEventListener("touchend",this._onTouchEnd,!0),t.removeEventListener("keydown",this._onKeyDown,!0),t.removeEventListener("mousedown",this._onMouseDown,!0),e.removeEventListener("click",this._onClick),e.removeEventListener("touchmove",this._onTouchMove),this.dropdown.element.removeEventListener("mouseover",this._onMouseOver),this._isSelectOneElement&&(t.removeEventListener("focus",this._onFocus),t.removeEventListener("blur",this._onBlur)),i.removeEventListener("keyup",this._onKeyUp),i.removeEventListener("input",this._onInput),i.removeEventListener("focus",this._onFocus),i.removeEventListener("blur",this._onBlur),i.form&&i.form.removeEventListener("reset",this._onFormReset),n.hasAttribute("required")&&(n.removeEventListener("change",this._onChange),n.removeEventListener("invalid",this._onInvalid)),this.input.removeEventListeners()},e.prototype._onKeyDown=function(e){var t=e.keyCode,i=this.dropdown.isActive,n=1===e.key.length||2===e.key.length&&e.key.charCodeAt(0)>=55296||"Unidentified"===e.key;switch(this._isTextElement||i||27===t||9===t||16===t||(this.showDropdown(),!this.input.isFocussed&&n&&(this.input.value+=e.key," "===e.key&&e.preventDefault())),t){case 65:return this._onSelectKey(e,this.itemList.element.hasChildNodes());case 13:return this._onEnterKey(e,i);case 27:return this._onEscapeKey(e,i);case 38:case 33:case 40:case 34:return this._onDirectionKey(e,i);case 8:case 46:return this._onDeleteKey(e,this._store.items,this.input.isFocussed)}},e.prototype._onKeyUp=function(){this._canSearch=this.config.searchEnabled},e.prototype._onInput=function(){var e=this.input.value;e?this._canAddItems()&&(this._canSearch&&this._handleSearch(e),this._canAddUserChoices&&(this._canCreateItem(e),this._isSelectElement&&(this._highlightPosition=0,this._highlightChoice()))):this._isTextElement?this.hideDropdown(!0):this._stopSearch()},e.prototype._onSelectKey=function(e,t){(e.ctrlKey||e.metaKey)&&t&&(this._canSearch=!1,this.config.removeItems&&!this.input.value&&this.input.element===document.activeElement&&this.highlightAll())},e.prototype._onEnterKey=function(e,t){var i=this,n=this.input.value,s=e.target;if(e.preventDefault(),s&&s.hasAttribute("data-button"))this._handleButtonAction(s);else if(t){var o=this.dropdown.element.querySelector(j(this.config.classNames.highlightedState));if(!o||!this._handleChoiceAction(o))if(s&&n){if(this._canAddItems()){var r=!1;this._store.withTxn((function(){if(!(r=i._findAndSelectChoiceByValue(n,!0))){if(!i._canAddUserChoices)return;if(!i._canCreateItem(n))return;i._addChoice(z(n,!1,i.config.allowHtmlUserInput),!0,!0),r=!0}i.clearInput(),i.unhighlightAll()})),r&&(this._triggerChange(n),this.config.closeDropdownOnSelect&&this.hideDropdown(!0))}}else this.hideDropdown(!0)}else(this._isSelectElement||this._notice)&&this.showDropdown()},e.prototype._onEscapeKey=function(e,t){t&&(e.stopPropagation(),this.hideDropdown(!0),this._stopSearch(),this.containerOuter.element.focus())},e.prototype._onDirectionKey=function(e,t){var i=e.keyCode;if(t||this._isSelectOneElement){this.showDropdown(),this._canSearch=!1;var n=40===i||34===i?1:-1,s=void 0;if(e.metaKey||34===i||33===i)s=this.dropdown.element.querySelector(n>0?"".concat($e,":last-of-type"):$e);else{var o=this.dropdown.element.querySelector(j(this.config.classNames.highlightedState));s=o?function(e,t,i){void 0===i&&(i=1);for(var n="".concat(i>0?"next":"previous","ElementSibling"),s=e[n];s;){if(s.matches(t))return s;s=s[n]}return null}(o,$e,n):this.dropdown.element.querySelector($e)}s&&(I(s,this.choiceList.element,n)||this.choiceList.scrollToChildElement(s,n),this._highlightChoice(s)),e.preventDefault()}},e.prototype._onDeleteKey=function(e,t,i){this._isSelectOneElement||e.target.value||!i||(this._handleBackspace(t),e.preventDefault())},e.prototype._onTouchMove=function(){this._wasTap&&(this._wasTap=!1)},e.prototype._onTouchEnd=function(e){var t=(e||e.touches[0]).target;this._wasTap&&this.containerOuter.element.contains(t)&&((t===this.containerOuter.element||t===this.containerInner.element)&&(this._isTextElement?this.input.focus():this._isSelectMultipleElement&&this.showDropdown()),e.stopPropagation()),this._wasTap=!0},e.prototype._onMouseDown=function(e){var t=e.target;if(t instanceof Element){if(Ue&&this.choiceList.element.contains(t)){var i=this.choiceList.element.firstElementChild;this._isScrollingOnIe="ltr"===this._direction?e.offsetX>=i.offsetWidth:e.offsetXthis._highlightPosition?t[this._highlightPosition]:t[t.length-1])||(i=t[0]),K(i,n),i.setAttribute("aria-selected","true"),this.passedElement.triggerEvent("highlightChoice",{el:i}),this.dropdown.isActive&&(this.input.setActiveDescendant(i.id),this.containerOuter.setActiveDescendant(i.id))}},e.prototype._addItem=function(e,t,i){if(void 0===t&&(t=!0),void 0===i&&(i=!1),!e.id)throw new TypeError("item.id must be set before _addItem is called for a choice/item");if((this.config.singleModeForMultiSelect||this._isSelectOneElement)&&this.removeActiveItems(e.id),this._store.dispatch(E(e)),t){var n=N(e);this.passedElement.triggerEvent("addItem",n),i&&this.passedElement.triggerEvent("choice",n)}},e.prototype._removeItem=function(e){if(e.id){this._store.dispatch(S(e));var t=this._notice;t&&t.type===ie&&this._clearNotice(),this.passedElement.triggerEvent(m,N(e))}},e.prototype._addChoice=function(e,t,i){if(void 0===t&&(t=!0),void 0===i&&(i=!1),e.id)throw new TypeError("Can not re-add a choice which has already been added");var n=this.config;if(n.duplicateItemsAllowed||!this._store.choices.find((function(t){return n.valueComparer(t.value,e.value)}))){this._lastAddedChoiceId++,e.id=this._lastAddedChoiceId,e.elementId="".concat(this._baseId,"-").concat(this._idNames.itemChoice,"-").concat(e.id);var s=n.prependValue,o=n.appendValue;s&&(e.value=s+e.value),o&&(e.value+=o.toString()),(s||o)&&e.element&&(e.element.value=e.value),this._clearNotice(),this._store.dispatch(b(e)),e.selected&&this._addItem(e,t,i)}},e.prototype._addGroup=function(e,t){var i=this;if(void 0===t&&(t=!0),e.id)throw new TypeError("Can not re-add a group which has already been added");this._store.dispatch(function(e){return{type:h,group:e}}(e)),e.choices&&(this._lastAddedGroupId++,e.id=this._lastAddedGroupId,e.choices.forEach((function(n){n.group=e,e.disabled&&(n.disabled=!0),i._addChoice(n,t)})))},e.prototype._createTemplates=function(){var e=this,t=this.config.callbackOnCreateTemplates,i={};"function"==typeof t&&(i=t.call(this,O,D,F));var n={};Object.keys(this._templates).forEach((function(t){n[t]=t in i?i[t].bind(e):e._templates[t].bind(e)})),this._templates=n},e.prototype._createElements=function(){var e=this._templates,t=this.config,i=this._isSelectOneElement,n=t.position,s=t.classNames,o=this._elementType;this.containerOuter=new R({element:e.containerOuter(t,this._direction,this._isSelectElement,i,t.searchEnabled,o,t.labelId),classNames:s,type:o,position:n}),this.containerInner=new R({element:e.containerInner(t),classNames:s,type:o,position:n}),this.input=new q({element:e.input(t,this._placeholderValue),classNames:s,type:o,preventPaste:!t.paste}),this.choiceList=new U({element:e.choiceList(t,i)}),this.itemList=new U({element:e.itemList(t,i)}),this.dropdown=new H({element:e.dropdown(t),classNames:s,type:o})},e.prototype._createStructure=function(){var e=this,t=e.containerInner,i=e.containerOuter,n=e.passedElement,s=this.dropdown.element;n.conceal(),t.wrap(n.element),i.wrap(t.element),i.element.appendChild(t.element),i.element.appendChild(s),t.element.appendChild(this.itemList.element),s.appendChild(this.choiceList.element),this._isSelectOneElement?(this.input.placeholder=this.config.searchPlaceholderValue||"",this.config.searchEnabled&&s.insertBefore(this.input.element,s.firstChild)):(this._isSelectMultipleElement&&!this.config.searchEnabled||t.element.appendChild(this.input.element),this._placeholderValue&&(this.input.placeholder=this._placeholderValue),this.input.setWidth()),this._highlightPosition=0,this._isSearching=!1},e.prototype._initStore=function(){var e=this;this._store.subscribe(this._render).withTxn((function(){e._addPredefinedChoices(e._presetChoices,e._isSelectOneElement&&!e._hasNonChoicePlaceholder,!1)})),(!this._store.choices.length||this._isSelectOneElement&&this._hasNonChoicePlaceholder)&&this._render()},e.prototype._addPredefinedChoices=function(e,t,i){var n=this;void 0===t&&(t=!1),void 0===i&&(i=!0),t&&-1===e.findIndex((function(e){return e.selected}))&&e.some((function(e){return!e.disabled&&!("choices"in e)&&(e.selected=!0,!0)})),e.forEach((function(e){"choices"in e?n._isSelectElement&&n._addGroup(e,i):n._addChoice(e,i)}))},e.prototype._findAndSelectChoiceByValue=function(e,t){var i=this;void 0===t&&(t=!1);var n=this._store.choices.find((function(t){return i.config.valueComparer(t.value,e)}));return!(!n||n.disabled||n.selected||(this._addItem(n,!0,t),0))},e.prototype._generatePlaceholderValue=function(){var e=this.config;if(!e.placeholder)return null;if(this._hasNonChoicePlaceholder)return e.placeholderValue;if(this._isSelectElement){var t=this.passedElement.placeholderOption;return t?t.text:null}return null},e.prototype._warnChoicesInitFailed=function(e){if(!this.config.silent){if(!this.initialised)throw new TypeError("".concat(e," called on a non-initialised instance of Choices"));if(!this.initialisedOK)throw new TypeError("".concat(e," called for an element which has multiple instances of Choices initialised on it"))}},e.version="11.2.0",e}()})); diff --git a/assets/scripts/choices.search-basic.mjs b/assets/scripts/choices.search-basic.mjs index b32f469e..0959ea39 100644 --- a/assets/scripts/choices.search-basic.mjs +++ b/assets/scripts/choices.search-basic.mjs @@ -1,4 +1,4 @@ -/*! choices.js v11.1.0 | © 2025 Josh Johnson | https://github.com/jshjohnson/Choices#readme */ +/*! choices.js v11.2.0 | © 2026 Josh Johnson | https://github.com/jshjohnson/Choices#readme */ /****************************************************************************** Copyright (c) Microsoft Corporation. @@ -211,9 +211,6 @@ var strToEl = (function () { return firstChild; }; })(); -var resolveNoticeFunction = function (fn, value) { - return typeof fn === 'function' ? fn(sanitise(value), value) : fn; -}; var resolveStringFunction = function (fn) { return typeof fn === 'function' ? fn() : fn; }; @@ -245,6 +242,26 @@ var unwrapStringForEscaped = function (s) { } return ''; }; +var getChoiceForOutput = function (choice, keyCode) { + return { + id: choice.id, + highlighted: choice.highlighted, + labelClass: choice.labelClass, + labelDescription: unwrapStringForRaw(choice.labelDescription), + customProperties: choice.customProperties, + disabled: choice.disabled, + active: choice.active, + label: choice.label, + placeholder: choice.placeholder, + value: choice.value, + groupValue: choice.group ? choice.group.label : undefined, + element: choice.element, + keyCode: keyCode, + }; +}; +var resolveNoticeFunction = function (fn, value, item) { + return typeof fn === 'function' ? fn(sanitise(value), unwrapStringForRaw(value), item) : fn; +}; var escapeForTemplate = function (allowHTML, s) { return allowHTML ? unwrapStringForEscaped(s) : sanitise(s); }; @@ -412,6 +429,12 @@ var Container = /** @class */ (function () { Container.prototype.removeFocusState = function () { removeClassesFromElement(this.element, this.classNames.focusState); }; + Container.prototype.addInvalidState = function () { + addClassesToElement(this.element, this.classNames.invalidState); + }; + Container.prototype.removeInvalidState = function () { + removeClassesFromElement(this.element, this.classNames.invalidState); + }; Container.prototype.enable = function () { removeClassesFromElement(this.element, this.classNames.disabledState); this.element.removeAttribute('aria-disabled'); @@ -877,7 +900,9 @@ var WrappedSelect = /** @class */ (function (_super) { highlighted: false, placeholder: this.extractPlaceholder && (!option.value || option.hasAttribute('placeholder')), labelClass: typeof option.dataset.labelClass !== 'undefined' ? stringToHtmlClass(option.dataset.labelClass) : undefined, - labelDescription: typeof option.dataset.labelDescription !== 'undefined' ? option.dataset.labelDescription : undefined, + labelDescription: typeof option.dataset.labelDescription !== 'undefined' + ? { trusted: option.dataset.labelDescription } + : undefined, customProperties: parseCustomProperties(option.dataset.customProperties), }; }; @@ -923,6 +948,7 @@ var DEFAULT_CLASSNAMES = { selectedState: ['is-selected'], flippedState: ['is-flipped'], loadingState: ['is-loading'], + invalidState: ['is-invalid'], notice: ['choices__notice'], addChoice: ['choices__item--selectable', 'add-choice'], noResults: ['has-no-results'], @@ -950,6 +976,7 @@ var DEFAULT_CONFIG = { paste: true, searchEnabled: true, searchChoices: true, + searchDisabledChoices: false, searchFloor: 1, searchResultLimit: 4, searchFields: ['label', 'value'], @@ -965,6 +992,7 @@ var DEFAULT_CONFIG = { prependValue: null, appendValue: null, renderSelectedChoices: 'auto', + searchRenderSelectedChoices: true, loadingText: 'Loading...', noResultsText: 'No results found', noChoicesText: 'No choices to choose from', @@ -973,7 +1001,9 @@ var DEFAULT_CONFIG = { customAddItemText: 'Only values matching specific conditions can be added', addItemText: function (value) { return "Press Enter to add \"".concat(value, "\""); }, removeItemIconText: function () { return "Remove item"; }, - removeItemLabelText: function (value) { return "Remove item: ".concat(value); }, + removeItemLabelText: function (value, _valueRaw, i) { + return "Remove item: ".concat(i ? sanitise(i.label) : value); + }, maxItemText: function (maxItemCount) { return "Only ".concat(maxItemCount, " values can be added"); }, valueComparer: function (value1, value2) { return value1 === value2; }, fuseOptions: { @@ -1274,7 +1304,8 @@ var Store = /** @class */ (function () { * Get choices that can be searched (excluding placeholders or disabled choices) */ get: function () { - return this.choices.filter(function (choice) { return !choice.disabled && !choice.placeholder; }); + var context = this._context; + return this.choices.filter(function (choice) { return !choice.placeholder && (context.searchDisabledChoices || !choice.disabled); }); }, enumerable: false, configurable: true @@ -1332,9 +1363,9 @@ var NoticeTypes = { function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, - enumerable: !0, - configurable: !0, - writable: !0 + enumerable: true, + configurable: true, + writable: true }) : e[r] = t, e; } function ownKeys(e, r) { @@ -1350,7 +1381,7 @@ function ownKeys(e, r) { function _objectSpread2(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; - r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { + r % 2 ? ownKeys(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); @@ -1362,7 +1393,7 @@ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { - var i = e.call(t, r || "default"); + var i = e.call(t, r); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } @@ -1385,16 +1416,13 @@ function _toPropertyKey(t) { function isArray(value) { return !Array.isArray ? getTag(value) === '[object Array]' : Array.isArray(value); } - -// Adapted from: https://github.com/lodash/lodash/blob/master/.internal/baseToString.js -const INFINITY = 1 / 0; function baseToString(value) { // Exit early for strings to avoid a performance hit in some environments. if (typeof value == 'string') { return value; } let result = value + ''; - return result == '0' && 1 / value == -INFINITY ? '-0' : result; + return result == '0' && 1 / value == -Infinity ? '-0' : result; } function toString(value) { return value == null ? '' : baseToString(value); @@ -2263,7 +2291,7 @@ function format(results, docs, { class Fuse { constructor(docs, options = {}, index) { this.options = _objectSpread2(_objectSpread2({}, Config), options); - if (this.options.useExtendedSearch && !false) { + if (this.options.useExtendedSearch && true) { throw new Error(EXTENDED_SEARCH_UNAVAILABLE); } this._keyStore = new KeyStore(this.options.keys); @@ -2536,7 +2564,7 @@ var assignCustomProperties = function (el, choice, withCustomProperties) { dataset.labelClass = getClassNames(labelClass).join(' '); } if (labelDescription) { - dataset.labelDescription = labelDescription; + dataset.labelDescription = unwrapStringForRaw(labelDescription); } if (withCustomProperties && customProperties) { if (typeof customProperties === 'string') { @@ -2643,8 +2671,9 @@ var templates = { var removeButton = document.createElement('button'); removeButton.type = 'button'; addClassesToElement(removeButton, button); - setElementHtml(removeButton, true, resolveNoticeFunction(removeItemIconText, choice.value)); - var REMOVE_ITEM_LABEL = resolveNoticeFunction(removeItemLabelText, choice.value); + var eventChoice = getChoiceForOutput(choice); + setElementHtml(removeButton, true, resolveNoticeFunction(removeItemIconText, choice.value, eventChoice)); + var REMOVE_ITEM_LABEL = resolveNoticeFunction(removeItemLabelText, choice.value, eventChoice); if (REMOVE_ITEM_LABEL) { removeButton.setAttribute('aria-label', REMOVE_ITEM_LABEL); } @@ -2749,6 +2778,7 @@ var templates = { else { addClassesToElement(div, itemSelectable); div.dataset.choiceSelectable = ''; + div.setAttribute('aria-selected', choice.selected ? 'true' : 'false'); } return div; }, @@ -2918,7 +2948,7 @@ var Choices = /** @class */ (function () { this.initialised = false; this._store = new Store(config); this._currentValue = ''; - config.searchEnabled = (!isText && config.searchEnabled) || isSelectMultiple; + config.searchEnabled = !isText && config.searchEnabled; this._canSearch = config.searchEnabled; this._isScrollingOnIe = false; this._highlightPosition = 0; @@ -2958,6 +2988,8 @@ var Choices = /** @class */ (function () { this._onEscapeKey = this._onEscapeKey.bind(this); this._onDirectionKey = this._onDirectionKey.bind(this); this._onDeleteKey = this._onDeleteKey.bind(this); + this._onChange = this._onChange.bind(this); + this._onInvalid = this._onInvalid.bind(this); // If element has already been initialised with Choices, fail silently if (this.passedElement.isActive) { if (!config.silent) { @@ -3064,7 +3096,7 @@ var Choices = /** @class */ (function () { } this._store.dispatch(highlightItem(choice, true)); if (runEvent) { - this.passedElement.triggerEvent(EventType.highlightItem, this._getChoiceForOutput(choice)); + this.passedElement.triggerEvent(EventType.highlightItem, getChoiceForOutput(choice)); } return this; }; @@ -3079,7 +3111,7 @@ var Choices = /** @class */ (function () { } this._store.dispatch(highlightItem(choice, false)); if (runEvent) { - this.passedElement.triggerEvent(EventType.unhighlightItem, this._getChoiceForOutput(choice)); + this.passedElement.triggerEvent(EventType.unhighlightItem, getChoiceForOutput(choice)); } return this; }; @@ -3089,7 +3121,7 @@ var Choices = /** @class */ (function () { _this._store.items.forEach(function (item) { if (!item.highlighted) { _this._store.dispatch(highlightItem(item, true)); - _this.passedElement.triggerEvent(EventType.highlightItem, _this._getChoiceForOutput(item)); + _this.passedElement.triggerEvent(EventType.highlightItem, getChoiceForOutput(item)); } }); }); @@ -3101,7 +3133,7 @@ var Choices = /** @class */ (function () { _this._store.items.forEach(function (item) { if (item.highlighted) { _this._store.dispatch(highlightItem(item, false)); - _this.passedElement.triggerEvent(EventType.highlightItem, _this._getChoiceForOutput(item)); + _this.passedElement.triggerEvent(EventType.highlightItem, getChoiceForOutput(item)); } }); }); @@ -3156,6 +3188,11 @@ var Choices = /** @class */ (function () { _this.input.focus(); } _this.passedElement.triggerEvent(EventType.showDropdown); + var activeElement = _this.choiceList.element.querySelector(getClassNamesSelector(_this.config.classNames.selectedState)); + if (activeElement !== null && !isScrolledIntoView(activeElement, _this.choiceList.element)) { + // We use the native scrollIntoView function instead of choiceList.scrollToChildElement to avoid animated scroll. + activeElement.scrollIntoView(); + } }); return this; }; @@ -3164,6 +3201,7 @@ var Choices = /** @class */ (function () { if (!this.dropdown.isActive) { return this; } + this._removeHighlightedChoices(); requestAnimationFrame(function () { _this.dropdown.hide(); _this.containerOuter.close(); @@ -3176,9 +3214,8 @@ var Choices = /** @class */ (function () { return this; }; Choices.prototype.getValue = function (valueOnly) { - var _this = this; var values = this._store.items.map(function (item) { - return (valueOnly ? item.value : _this._getChoiceForOutput(item)); + return (valueOnly ? item.value : getChoiceForOutput(item)); }); return this._isSelectOneElement || this.config.singleModeForMultiSelect ? values[0] : values; }; @@ -3436,7 +3473,7 @@ var Choices = /** @class */ (function () { // @todo integrate with Store this._searcher.reset(); if (choice.selected) { - this.passedElement.triggerEvent(EventType.removeItem, this._getChoiceForOutput(choice)); + this.passedElement.triggerEvent(EventType.removeItem, getChoiceForOutput(choice)); } return this; }; @@ -3519,13 +3556,7 @@ var Choices = /** @class */ (function () { } var _a = this, config = _a.config, isSearching = _a._isSearching; var _b = this._store, activeGroups = _b.activeGroups, activeChoices = _b.activeChoices; - var renderLimit = 0; - if (isSearching && config.searchResultLimit > 0) { - renderLimit = config.searchResultLimit; - } - else if (config.renderChoiceLimit > 0) { - renderLimit = config.renderChoiceLimit; - } + var renderLimit = isSearching ? config.searchResultLimit : config.renderChoiceLimit; if (this._isSelectElement) { var backingOptions = activeChoices.filter(function (choice) { return !choice.element; }); if (backingOptions.length) { @@ -3535,11 +3566,16 @@ var Choices = /** @class */ (function () { var fragment = document.createDocumentFragment(); var renderableChoices = function (choices) { return choices.filter(function (choice) { - return !choice.placeholder && (isSearching ? !!choice.rank : config.renderSelectedChoices || !choice.selected); + return !choice.placeholder && + (isSearching + ? (config.searchRenderSelectedChoices || !choice.selected) && !!choice.rank + : config.renderSelectedChoices || !choice.selected); }); }; + var showLabel = config.appendGroupInSearch && isSearching; var selectableChoices = false; - var renderChoices = function (choices, withinGroup, groupLabel) { + var highlightedEl = null; + var renderChoices = function (choices, withinGroup) { if (isSearching) { // sortByRank is used to ensure stable sorting, as scores are non-unique // this additionally ensures fuseOptions.sortFn is not ignored @@ -3549,16 +3585,20 @@ var Choices = /** @class */ (function () { choices.sort(config.sorter); } var choiceLimit = choices.length; - choiceLimit = !withinGroup && renderLimit && choiceLimit > renderLimit ? renderLimit : choiceLimit; + choiceLimit = !withinGroup && renderLimit > 0 && choiceLimit > renderLimit ? renderLimit : choiceLimit; choiceLimit--; choices.every(function (choice, index) { // choiceEl being empty signals the contents has probably significantly changed - var dropdownItem = choice.choiceEl || _this._templates.choice(config, choice, config.itemSelectText, groupLabel); + var dropdownItem = choice.choiceEl || + _this._templates.choice(config, choice, config.itemSelectText, showLabel && choice.group ? choice.group.label : undefined); choice.choiceEl = dropdownItem; fragment.appendChild(dropdownItem); if (isSearching || !choice.selected) { selectableChoices = true; } + else if (!highlightedEl) { + highlightedEl = dropdownItem; + } return index < choiceLimit; }); }; @@ -3568,7 +3608,7 @@ var Choices = /** @class */ (function () { } if (!this._hasNonChoicePlaceholder && !isSearching && this._isSelectOneElement) { // If we have a placeholder choice along with groups - renderChoices(activeChoices.filter(function (choice) { return choice.placeholder && !choice.group; }), false, undefined); + renderChoices(activeChoices.filter(function (choice) { return choice.placeholder && !choice.group; }), false); } // If we have grouped options if (activeGroups.length && !isSearching) { @@ -3577,7 +3617,7 @@ var Choices = /** @class */ (function () { } // render Choices without group first, regardless of sort, otherwise they won't be distinguishable // from the last group - renderChoices(activeChoices.filter(function (choice) { return !choice.placeholder && !choice.group; }), false, undefined); + renderChoices(activeChoices.filter(function (choice) { return !choice.placeholder && !choice.group; }), false); activeGroups.forEach(function (group) { var groupChoices = renderableChoices(group.choices); if (groupChoices.length) { @@ -3587,12 +3627,12 @@ var Choices = /** @class */ (function () { dropdownGroup.remove(); fragment.appendChild(dropdownGroup); } - renderChoices(groupChoices, true, config.appendGroupInSearch && isSearching ? group.label : undefined); + renderChoices(groupChoices, true); } }); } else { - renderChoices(renderableChoices(activeChoices), false, undefined); + renderChoices(renderableChoices(activeChoices), false); } } if (!selectableChoices && (isSearching || !fragment.children.length || !config.renderSelectedChoices)) { @@ -3606,9 +3646,7 @@ var Choices = /** @class */ (function () { } this._renderNotice(fragment); this.choiceList.element.replaceChildren(fragment); - if (selectableChoices) { - this._highlightChoice(); - } + this._highlightChoice(highlightedEl); }; Choices.prototype._renderItems = function () { var _this = this; @@ -3718,23 +3756,12 @@ var Choices = /** @class */ (function () { } } }; + /** + * @deprecated Use utils.getChoiceForOutput + */ // eslint-disable-next-line class-methods-use-this Choices.prototype._getChoiceForOutput = function (choice, keyCode) { - return { - id: choice.id, - highlighted: choice.highlighted, - labelClass: choice.labelClass, - labelDescription: choice.labelDescription, - customProperties: choice.customProperties, - disabled: choice.disabled, - active: choice.active, - label: choice.label, - placeholder: choice.placeholder, - value: choice.value, - groupValue: choice.group ? choice.group.label : undefined, - element: choice.element, - keyCode: keyCode, - }; + return getChoiceForOutput(choice, keyCode); }; Choices.prototype._triggerChange = function (value) { if (value === undefined || value === null) { @@ -3750,7 +3777,7 @@ var Choices = /** @class */ (function () { if (!items.length || !this.config.removeItems || !this.config.removeItemButton) { return; } - var id = element && parseDataSetId(element.parentElement); + var id = element && parseDataSetId(element.closest('[data-id]')); var itemToRemove = id && items.find(function (item) { return item.id === id; }); if (!itemToRemove) { return; @@ -3939,7 +3966,7 @@ var Choices = /** @class */ (function () { var notice = ''; if (canAddItem && typeof config.addItemFilter === 'function' && !config.addItemFilter(value)) { canAddItem = false; - notice = resolveNoticeFunction(config.customAddItemText, value); + notice = resolveNoticeFunction(config.customAddItemText, value, undefined); } if (canAddItem) { var foundChoice = this._store.choices.find(function (choice) { return config.valueComparer(choice.value, value); }); @@ -3951,12 +3978,12 @@ var Choices = /** @class */ (function () { } if (!config.duplicateItemsAllowed) { canAddItem = false; - notice = resolveNoticeFunction(config.uniqueItemText, value); + notice = resolveNoticeFunction(config.uniqueItemText, value, undefined); } } } if (canAddItem) { - notice = resolveNoticeFunction(config.addItemText, value); + notice = resolveNoticeFunction(config.addItemText, value, undefined); } if (notice) { this._displayNotice(notice, NoticeTypes.addChoice); @@ -4007,6 +4034,7 @@ var Choices = /** @class */ (function () { var documentElement = this._docRoot; var outerElement = this.containerOuter.element; var inputElement = this.input.element; + var passedElement = this.passedElement.element; // capture events - can cancel event processing or propagation documentElement.addEventListener('touchend', this._onTouchEnd, true); outerElement.addEventListener('keydown', this._onKeyDown, true); @@ -4044,12 +4072,21 @@ var Choices = /** @class */ (function () { passive: true, }); } + if (passedElement.hasAttribute('required')) { + passedElement.addEventListener('change', this._onChange, { + passive: true, + }); + passedElement.addEventListener('invalid', this._onInvalid, { + passive: true, + }); + } this.input.addEventListeners(); }; Choices.prototype._removeEventListeners = function () { var documentElement = this._docRoot; var outerElement = this.containerOuter.element; var inputElement = this.input.element; + var passedElement = this.passedElement.element; documentElement.removeEventListener('touchend', this._onTouchEnd, true); outerElement.removeEventListener('keydown', this._onKeyDown, true); outerElement.removeEventListener('mousedown', this._onMouseDown, true); @@ -4067,6 +4104,10 @@ var Choices = /** @class */ (function () { if (inputElement.form) { inputElement.form.removeEventListener('reset', this._onFormReset); } + if (passedElement.hasAttribute('required')) { + passedElement.removeEventListener('change', this._onChange); + passedElement.removeEventListener('invalid', this._onInvalid); + } this.input.removeEventListeners(); }; Choices.prototype._onKeyDown = function (event) { @@ -4316,7 +4357,7 @@ var Choices = /** @class */ (function () { */ Choices.prototype._onMouseDown = function (event) { var target = event.target; - if (!(target instanceof HTMLElement)) { + if (!(target instanceof Element)) { return; } // If we have our mouse down on the scrollbar and are on IE11... @@ -4425,7 +4466,7 @@ var Choices = /** @class */ (function () { // Remove the focus state when the past outerContainer was the target containerOuter.removeFocusState(); // Also close the dropdown if search is disabled - if (!this._canSearch) { + if (!this.config.searchEnabled) { this.hideDropdown(true); } } @@ -4449,6 +4490,27 @@ var Choices = /** @class */ (function () { } }); }; + Choices.prototype._onChange = function (event) { + if (!event.target.checkValidity()) { + return; + } + this.containerOuter.removeInvalidState(); + }; + Choices.prototype._onInvalid = function () { + this.containerOuter.addInvalidState(); + }; + /** + * Removes any highlighted choice options + */ + Choices.prototype._removeHighlightedChoices = function () { + var highlightedState = this.config.classNames.highlightedState; + var highlightedChoices = Array.from(this.dropdown.element.querySelectorAll(getClassNamesSelector(highlightedState))); + // Remove any highlighted choices + highlightedChoices.forEach(function (choice) { + removeClassesFromElement(choice, highlightedState); + choice.setAttribute('aria-selected', 'false'); + }); + }; Choices.prototype._highlightChoice = function (el) { if (el === void 0) { el = null; } var choices = Array.from(this.dropdown.element.querySelectorAll(selectableChoiceIdentifier)); @@ -4457,12 +4519,7 @@ var Choices = /** @class */ (function () { } var passedEl = el; var highlightedState = this.config.classNames.highlightedState; - var highlightedChoices = Array.from(this.dropdown.element.querySelectorAll(getClassNamesSelector(highlightedState))); - // Remove any highlighted choices - highlightedChoices.forEach(function (choice) { - removeClassesFromElement(choice, highlightedState); - choice.setAttribute('aria-selected', 'false'); - }); + this._removeHighlightedChoices(); if (passedEl) { this._highlightPosition = choices.indexOf(passedEl); } @@ -4503,9 +4560,10 @@ var Choices = /** @class */ (function () { } this._store.dispatch(addItem(item)); if (withEvents) { - this.passedElement.triggerEvent(EventType.addItem, this._getChoiceForOutput(item)); + var eventChoice = getChoiceForOutput(item); + this.passedElement.triggerEvent(EventType.addItem, eventChoice); if (userTriggered) { - this.passedElement.triggerEvent(EventType.choice, this._getChoiceForOutput(item)); + this.passedElement.triggerEvent(EventType.choice, eventChoice); } } }; @@ -4518,7 +4576,7 @@ var Choices = /** @class */ (function () { if (notice && notice.type === NoticeTypes.noChoices) { this._clearNotice(); } - this.passedElement.triggerEvent(EventType.removeItem, this._getChoiceForOutput(item)); + this.passedElement.triggerEvent(EventType.removeItem, getChoiceForOutput(item)); }; Choices.prototype._addChoice = function (choice, withEvents, userTriggered) { if (withEvents === void 0) { withEvents = true; } @@ -4633,24 +4691,24 @@ var Choices = /** @class */ (function () { containerInner.wrap(passedElement.element); // Wrapper inner container with outer container containerOuter.wrap(containerInner.element); - if (this._isSelectOneElement) { - this.input.placeholder = this.config.searchPlaceholderValue || ''; - } - else { - if (this._placeholderValue) { - this.input.placeholder = this._placeholderValue; - } - this.input.setWidth(); - } containerOuter.element.appendChild(containerInner.element); containerOuter.element.appendChild(dropdownElement); containerInner.element.appendChild(this.itemList.element); dropdownElement.appendChild(this.choiceList.element); - if (!this._isSelectOneElement) { - containerInner.element.appendChild(this.input.element); + if (this._isSelectOneElement) { + this.input.placeholder = this.config.searchPlaceholderValue || ''; + if (this.config.searchEnabled) { + dropdownElement.insertBefore(this.input.element, dropdownElement.firstChild); + } } - else if (this.config.searchEnabled) { - dropdownElement.insertBefore(this.input.element, dropdownElement.firstChild); + else { + if (!this._isSelectMultipleElement || this.config.searchEnabled) { + containerInner.element.appendChild(this.input.element); + } + if (this._placeholderValue) { + this.input.placeholder = this._placeholderValue; + } + this.input.setWidth(); } this._highlightPosition = 0; this._isSearching = false; @@ -4733,7 +4791,7 @@ var Choices = /** @class */ (function () { throw new TypeError("".concat(caller, " called for an element which has multiple instances of Choices initialised on it")); } }; - Choices.version = '11.1.0'; + Choices.version = '11.2.0'; return Choices; }()); diff --git a/assets/scripts/choices.search-kmp.js b/assets/scripts/choices.search-kmp.js index 235e175c..610094d6 100644 --- a/assets/scripts/choices.search-kmp.js +++ b/assets/scripts/choices.search-kmp.js @@ -1,4 +1,4 @@ -/*! choices.js v11.1.0 | © 2025 Josh Johnson | https://github.com/jshjohnson/Choices#readme */ +/*! choices.js v11.2.0 | © 2026 Josh Johnson | https://github.com/jshjohnson/Choices#readme */ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : @@ -208,9 +208,6 @@ return firstChild; }; })(); - var resolveNoticeFunction = function (fn, value) { - return typeof fn === 'function' ? fn(sanitise(value), value) : fn; - }; var resolveStringFunction = function (fn) { return typeof fn === 'function' ? fn() : fn; }; @@ -242,6 +239,26 @@ } return ''; }; + var getChoiceForOutput = function (choice, keyCode) { + return { + id: choice.id, + highlighted: choice.highlighted, + labelClass: choice.labelClass, + labelDescription: unwrapStringForRaw(choice.labelDescription), + customProperties: choice.customProperties, + disabled: choice.disabled, + active: choice.active, + label: choice.label, + placeholder: choice.placeholder, + value: choice.value, + groupValue: choice.group ? choice.group.label : undefined, + element: choice.element, + keyCode: keyCode, + }; + }; + var resolveNoticeFunction = function (fn, value, item) { + return typeof fn === 'function' ? fn(sanitise(value), unwrapStringForRaw(value), item) : fn; + }; var escapeForTemplate = function (allowHTML, s) { return allowHTML ? unwrapStringForEscaped(s) : sanitise(s); }; @@ -409,6 +426,12 @@ Container.prototype.removeFocusState = function () { removeClassesFromElement(this.element, this.classNames.focusState); }; + Container.prototype.addInvalidState = function () { + addClassesToElement(this.element, this.classNames.invalidState); + }; + Container.prototype.removeInvalidState = function () { + removeClassesFromElement(this.element, this.classNames.invalidState); + }; Container.prototype.enable = function () { removeClassesFromElement(this.element, this.classNames.disabledState); this.element.removeAttribute('aria-disabled'); @@ -874,7 +897,9 @@ highlighted: false, placeholder: this.extractPlaceholder && (!option.value || option.hasAttribute('placeholder')), labelClass: typeof option.dataset.labelClass !== 'undefined' ? stringToHtmlClass(option.dataset.labelClass) : undefined, - labelDescription: typeof option.dataset.labelDescription !== 'undefined' ? option.dataset.labelDescription : undefined, + labelDescription: typeof option.dataset.labelDescription !== 'undefined' + ? { trusted: option.dataset.labelDescription } + : undefined, customProperties: parseCustomProperties(option.dataset.customProperties), }; }; @@ -920,6 +945,7 @@ selectedState: ['is-selected'], flippedState: ['is-flipped'], loadingState: ['is-loading'], + invalidState: ['is-invalid'], notice: ['choices__notice'], addChoice: ['choices__item--selectable', 'add-choice'], noResults: ['has-no-results'], @@ -947,6 +973,7 @@ paste: true, searchEnabled: true, searchChoices: true, + searchDisabledChoices: false, searchFloor: 1, searchResultLimit: 4, searchFields: ['label', 'value'], @@ -962,6 +989,7 @@ prependValue: null, appendValue: null, renderSelectedChoices: 'auto', + searchRenderSelectedChoices: true, loadingText: 'Loading...', noResultsText: 'No results found', noChoicesText: 'No choices to choose from', @@ -970,7 +998,9 @@ customAddItemText: 'Only values matching specific conditions can be added', addItemText: function (value) { return "Press Enter to add \"".concat(value, "\""); }, removeItemIconText: function () { return "Remove item"; }, - removeItemLabelText: function (value) { return "Remove item: ".concat(value); }, + removeItemLabelText: function (value, _valueRaw, i) { + return "Remove item: ".concat(i ? sanitise(i.label) : value); + }, maxItemText: function (maxItemCount) { return "Only ".concat(maxItemCount, " values can be added"); }, valueComparer: function (value1, value2) { return value1 === value2; }, fuseOptions: { @@ -1271,7 +1301,8 @@ * Get choices that can be searched (excluding placeholders or disabled choices) */ get: function () { - return this.choices.filter(function (choice) { return !choice.disabled && !choice.placeholder; }); + var context = this._context; + return this.choices.filter(function (choice) { return !choice.placeholder && (context.searchDisabledChoices || !choice.disabled); }); }, enumerable: false, configurable: true @@ -1385,11 +1416,12 @@ var field = this._fields[k]; if (field in obj && kmpSearch(needle, obj[field].toLowerCase()) !== -1) { results.push({ - item: obj[field], + item: obj, score: count, rank: count + 1, }); count++; + break; } } } @@ -1425,7 +1457,7 @@ dataset.labelClass = getClassNames(labelClass).join(' '); } if (labelDescription) { - dataset.labelDescription = labelDescription; + dataset.labelDescription = unwrapStringForRaw(labelDescription); } if (withCustomProperties && customProperties) { if (typeof customProperties === 'string') { @@ -1532,8 +1564,9 @@ var removeButton = document.createElement('button'); removeButton.type = 'button'; addClassesToElement(removeButton, button); - setElementHtml(removeButton, true, resolveNoticeFunction(removeItemIconText, choice.value)); - var REMOVE_ITEM_LABEL = resolveNoticeFunction(removeItemLabelText, choice.value); + var eventChoice = getChoiceForOutput(choice); + setElementHtml(removeButton, true, resolveNoticeFunction(removeItemIconText, choice.value, eventChoice)); + var REMOVE_ITEM_LABEL = resolveNoticeFunction(removeItemLabelText, choice.value, eventChoice); if (REMOVE_ITEM_LABEL) { removeButton.setAttribute('aria-label', REMOVE_ITEM_LABEL); } @@ -1638,6 +1671,7 @@ else { addClassesToElement(div, itemSelectable); div.dataset.choiceSelectable = ''; + div.setAttribute('aria-selected', choice.selected ? 'true' : 'false'); } return div; }, @@ -1807,7 +1841,7 @@ this.initialised = false; this._store = new Store(config); this._currentValue = ''; - config.searchEnabled = (!isText && config.searchEnabled) || isSelectMultiple; + config.searchEnabled = !isText && config.searchEnabled; this._canSearch = config.searchEnabled; this._isScrollingOnIe = false; this._highlightPosition = 0; @@ -1847,6 +1881,8 @@ this._onEscapeKey = this._onEscapeKey.bind(this); this._onDirectionKey = this._onDirectionKey.bind(this); this._onDeleteKey = this._onDeleteKey.bind(this); + this._onChange = this._onChange.bind(this); + this._onInvalid = this._onInvalid.bind(this); // If element has already been initialised with Choices, fail silently if (this.passedElement.isActive) { if (!config.silent) { @@ -1953,7 +1989,7 @@ } this._store.dispatch(highlightItem(choice, true)); if (runEvent) { - this.passedElement.triggerEvent(EventType.highlightItem, this._getChoiceForOutput(choice)); + this.passedElement.triggerEvent(EventType.highlightItem, getChoiceForOutput(choice)); } return this; }; @@ -1968,7 +2004,7 @@ } this._store.dispatch(highlightItem(choice, false)); if (runEvent) { - this.passedElement.triggerEvent(EventType.unhighlightItem, this._getChoiceForOutput(choice)); + this.passedElement.triggerEvent(EventType.unhighlightItem, getChoiceForOutput(choice)); } return this; }; @@ -1978,7 +2014,7 @@ _this._store.items.forEach(function (item) { if (!item.highlighted) { _this._store.dispatch(highlightItem(item, true)); - _this.passedElement.triggerEvent(EventType.highlightItem, _this._getChoiceForOutput(item)); + _this.passedElement.triggerEvent(EventType.highlightItem, getChoiceForOutput(item)); } }); }); @@ -1990,7 +2026,7 @@ _this._store.items.forEach(function (item) { if (item.highlighted) { _this._store.dispatch(highlightItem(item, false)); - _this.passedElement.triggerEvent(EventType.highlightItem, _this._getChoiceForOutput(item)); + _this.passedElement.triggerEvent(EventType.highlightItem, getChoiceForOutput(item)); } }); }); @@ -2045,6 +2081,11 @@ _this.input.focus(); } _this.passedElement.triggerEvent(EventType.showDropdown); + var activeElement = _this.choiceList.element.querySelector(getClassNamesSelector(_this.config.classNames.selectedState)); + if (activeElement !== null && !isScrolledIntoView(activeElement, _this.choiceList.element)) { + // We use the native scrollIntoView function instead of choiceList.scrollToChildElement to avoid animated scroll. + activeElement.scrollIntoView(); + } }); return this; }; @@ -2053,6 +2094,7 @@ if (!this.dropdown.isActive) { return this; } + this._removeHighlightedChoices(); requestAnimationFrame(function () { _this.dropdown.hide(); _this.containerOuter.close(); @@ -2065,9 +2107,8 @@ return this; }; Choices.prototype.getValue = function (valueOnly) { - var _this = this; var values = this._store.items.map(function (item) { - return (valueOnly ? item.value : _this._getChoiceForOutput(item)); + return (valueOnly ? item.value : getChoiceForOutput(item)); }); return this._isSelectOneElement || this.config.singleModeForMultiSelect ? values[0] : values; }; @@ -2325,7 +2366,7 @@ // @todo integrate with Store this._searcher.reset(); if (choice.selected) { - this.passedElement.triggerEvent(EventType.removeItem, this._getChoiceForOutput(choice)); + this.passedElement.triggerEvent(EventType.removeItem, getChoiceForOutput(choice)); } return this; }; @@ -2408,13 +2449,7 @@ } var _a = this, config = _a.config, isSearching = _a._isSearching; var _b = this._store, activeGroups = _b.activeGroups, activeChoices = _b.activeChoices; - var renderLimit = 0; - if (isSearching && config.searchResultLimit > 0) { - renderLimit = config.searchResultLimit; - } - else if (config.renderChoiceLimit > 0) { - renderLimit = config.renderChoiceLimit; - } + var renderLimit = isSearching ? config.searchResultLimit : config.renderChoiceLimit; if (this._isSelectElement) { var backingOptions = activeChoices.filter(function (choice) { return !choice.element; }); if (backingOptions.length) { @@ -2424,11 +2459,16 @@ var fragment = document.createDocumentFragment(); var renderableChoices = function (choices) { return choices.filter(function (choice) { - return !choice.placeholder && (isSearching ? !!choice.rank : config.renderSelectedChoices || !choice.selected); + return !choice.placeholder && + (isSearching + ? (config.searchRenderSelectedChoices || !choice.selected) && !!choice.rank + : config.renderSelectedChoices || !choice.selected); }); }; + var showLabel = config.appendGroupInSearch && isSearching; var selectableChoices = false; - var renderChoices = function (choices, withinGroup, groupLabel) { + var highlightedEl = null; + var renderChoices = function (choices, withinGroup) { if (isSearching) { // sortByRank is used to ensure stable sorting, as scores are non-unique // this additionally ensures fuseOptions.sortFn is not ignored @@ -2438,16 +2478,20 @@ choices.sort(config.sorter); } var choiceLimit = choices.length; - choiceLimit = !withinGroup && renderLimit && choiceLimit > renderLimit ? renderLimit : choiceLimit; + choiceLimit = !withinGroup && renderLimit > 0 && choiceLimit > renderLimit ? renderLimit : choiceLimit; choiceLimit--; choices.every(function (choice, index) { // choiceEl being empty signals the contents has probably significantly changed - var dropdownItem = choice.choiceEl || _this._templates.choice(config, choice, config.itemSelectText, groupLabel); + var dropdownItem = choice.choiceEl || + _this._templates.choice(config, choice, config.itemSelectText, showLabel && choice.group ? choice.group.label : undefined); choice.choiceEl = dropdownItem; fragment.appendChild(dropdownItem); if (isSearching || !choice.selected) { selectableChoices = true; } + else if (!highlightedEl) { + highlightedEl = dropdownItem; + } return index < choiceLimit; }); }; @@ -2457,7 +2501,7 @@ } if (!this._hasNonChoicePlaceholder && !isSearching && this._isSelectOneElement) { // If we have a placeholder choice along with groups - renderChoices(activeChoices.filter(function (choice) { return choice.placeholder && !choice.group; }), false, undefined); + renderChoices(activeChoices.filter(function (choice) { return choice.placeholder && !choice.group; }), false); } // If we have grouped options if (activeGroups.length && !isSearching) { @@ -2466,7 +2510,7 @@ } // render Choices without group first, regardless of sort, otherwise they won't be distinguishable // from the last group - renderChoices(activeChoices.filter(function (choice) { return !choice.placeholder && !choice.group; }), false, undefined); + renderChoices(activeChoices.filter(function (choice) { return !choice.placeholder && !choice.group; }), false); activeGroups.forEach(function (group) { var groupChoices = renderableChoices(group.choices); if (groupChoices.length) { @@ -2476,12 +2520,12 @@ dropdownGroup.remove(); fragment.appendChild(dropdownGroup); } - renderChoices(groupChoices, true, config.appendGroupInSearch && isSearching ? group.label : undefined); + renderChoices(groupChoices, true); } }); } else { - renderChoices(renderableChoices(activeChoices), false, undefined); + renderChoices(renderableChoices(activeChoices), false); } } if (!selectableChoices && (isSearching || !fragment.children.length || !config.renderSelectedChoices)) { @@ -2495,9 +2539,7 @@ } this._renderNotice(fragment); this.choiceList.element.replaceChildren(fragment); - if (selectableChoices) { - this._highlightChoice(); - } + this._highlightChoice(highlightedEl); }; Choices.prototype._renderItems = function () { var _this = this; @@ -2607,23 +2649,12 @@ } } }; + /** + * @deprecated Use utils.getChoiceForOutput + */ // eslint-disable-next-line class-methods-use-this Choices.prototype._getChoiceForOutput = function (choice, keyCode) { - return { - id: choice.id, - highlighted: choice.highlighted, - labelClass: choice.labelClass, - labelDescription: choice.labelDescription, - customProperties: choice.customProperties, - disabled: choice.disabled, - active: choice.active, - label: choice.label, - placeholder: choice.placeholder, - value: choice.value, - groupValue: choice.group ? choice.group.label : undefined, - element: choice.element, - keyCode: keyCode, - }; + return getChoiceForOutput(choice, keyCode); }; Choices.prototype._triggerChange = function (value) { if (value === undefined || value === null) { @@ -2639,7 +2670,7 @@ if (!items.length || !this.config.removeItems || !this.config.removeItemButton) { return; } - var id = element && parseDataSetId(element.parentElement); + var id = element && parseDataSetId(element.closest('[data-id]')); var itemToRemove = id && items.find(function (item) { return item.id === id; }); if (!itemToRemove) { return; @@ -2828,7 +2859,7 @@ var notice = ''; if (canAddItem && typeof config.addItemFilter === 'function' && !config.addItemFilter(value)) { canAddItem = false; - notice = resolveNoticeFunction(config.customAddItemText, value); + notice = resolveNoticeFunction(config.customAddItemText, value, undefined); } if (canAddItem) { var foundChoice = this._store.choices.find(function (choice) { return config.valueComparer(choice.value, value); }); @@ -2840,12 +2871,12 @@ } if (!config.duplicateItemsAllowed) { canAddItem = false; - notice = resolveNoticeFunction(config.uniqueItemText, value); + notice = resolveNoticeFunction(config.uniqueItemText, value, undefined); } } } if (canAddItem) { - notice = resolveNoticeFunction(config.addItemText, value); + notice = resolveNoticeFunction(config.addItemText, value, undefined); } if (notice) { this._displayNotice(notice, NoticeTypes.addChoice); @@ -2896,6 +2927,7 @@ var documentElement = this._docRoot; var outerElement = this.containerOuter.element; var inputElement = this.input.element; + var passedElement = this.passedElement.element; // capture events - can cancel event processing or propagation documentElement.addEventListener('touchend', this._onTouchEnd, true); outerElement.addEventListener('keydown', this._onKeyDown, true); @@ -2933,12 +2965,21 @@ passive: true, }); } + if (passedElement.hasAttribute('required')) { + passedElement.addEventListener('change', this._onChange, { + passive: true, + }); + passedElement.addEventListener('invalid', this._onInvalid, { + passive: true, + }); + } this.input.addEventListeners(); }; Choices.prototype._removeEventListeners = function () { var documentElement = this._docRoot; var outerElement = this.containerOuter.element; var inputElement = this.input.element; + var passedElement = this.passedElement.element; documentElement.removeEventListener('touchend', this._onTouchEnd, true); outerElement.removeEventListener('keydown', this._onKeyDown, true); outerElement.removeEventListener('mousedown', this._onMouseDown, true); @@ -2956,6 +2997,10 @@ if (inputElement.form) { inputElement.form.removeEventListener('reset', this._onFormReset); } + if (passedElement.hasAttribute('required')) { + passedElement.removeEventListener('change', this._onChange); + passedElement.removeEventListener('invalid', this._onInvalid); + } this.input.removeEventListeners(); }; Choices.prototype._onKeyDown = function (event) { @@ -3205,7 +3250,7 @@ */ Choices.prototype._onMouseDown = function (event) { var target = event.target; - if (!(target instanceof HTMLElement)) { + if (!(target instanceof Element)) { return; } // If we have our mouse down on the scrollbar and are on IE11... @@ -3314,7 +3359,7 @@ // Remove the focus state when the past outerContainer was the target containerOuter.removeFocusState(); // Also close the dropdown if search is disabled - if (!this._canSearch) { + if (!this.config.searchEnabled) { this.hideDropdown(true); } } @@ -3338,6 +3383,27 @@ } }); }; + Choices.prototype._onChange = function (event) { + if (!event.target.checkValidity()) { + return; + } + this.containerOuter.removeInvalidState(); + }; + Choices.prototype._onInvalid = function () { + this.containerOuter.addInvalidState(); + }; + /** + * Removes any highlighted choice options + */ + Choices.prototype._removeHighlightedChoices = function () { + var highlightedState = this.config.classNames.highlightedState; + var highlightedChoices = Array.from(this.dropdown.element.querySelectorAll(getClassNamesSelector(highlightedState))); + // Remove any highlighted choices + highlightedChoices.forEach(function (choice) { + removeClassesFromElement(choice, highlightedState); + choice.setAttribute('aria-selected', 'false'); + }); + }; Choices.prototype._highlightChoice = function (el) { if (el === void 0) { el = null; } var choices = Array.from(this.dropdown.element.querySelectorAll(selectableChoiceIdentifier)); @@ -3346,12 +3412,7 @@ } var passedEl = el; var highlightedState = this.config.classNames.highlightedState; - var highlightedChoices = Array.from(this.dropdown.element.querySelectorAll(getClassNamesSelector(highlightedState))); - // Remove any highlighted choices - highlightedChoices.forEach(function (choice) { - removeClassesFromElement(choice, highlightedState); - choice.setAttribute('aria-selected', 'false'); - }); + this._removeHighlightedChoices(); if (passedEl) { this._highlightPosition = choices.indexOf(passedEl); } @@ -3392,9 +3453,10 @@ } this._store.dispatch(addItem(item)); if (withEvents) { - this.passedElement.triggerEvent(EventType.addItem, this._getChoiceForOutput(item)); + var eventChoice = getChoiceForOutput(item); + this.passedElement.triggerEvent(EventType.addItem, eventChoice); if (userTriggered) { - this.passedElement.triggerEvent(EventType.choice, this._getChoiceForOutput(item)); + this.passedElement.triggerEvent(EventType.choice, eventChoice); } } }; @@ -3407,7 +3469,7 @@ if (notice && notice.type === NoticeTypes.noChoices) { this._clearNotice(); } - this.passedElement.triggerEvent(EventType.removeItem, this._getChoiceForOutput(item)); + this.passedElement.triggerEvent(EventType.removeItem, getChoiceForOutput(item)); }; Choices.prototype._addChoice = function (choice, withEvents, userTriggered) { if (withEvents === void 0) { withEvents = true; } @@ -3522,24 +3584,24 @@ containerInner.wrap(passedElement.element); // Wrapper inner container with outer container containerOuter.wrap(containerInner.element); - if (this._isSelectOneElement) { - this.input.placeholder = this.config.searchPlaceholderValue || ''; - } - else { - if (this._placeholderValue) { - this.input.placeholder = this._placeholderValue; - } - this.input.setWidth(); - } containerOuter.element.appendChild(containerInner.element); containerOuter.element.appendChild(dropdownElement); containerInner.element.appendChild(this.itemList.element); dropdownElement.appendChild(this.choiceList.element); - if (!this._isSelectOneElement) { - containerInner.element.appendChild(this.input.element); + if (this._isSelectOneElement) { + this.input.placeholder = this.config.searchPlaceholderValue || ''; + if (this.config.searchEnabled) { + dropdownElement.insertBefore(this.input.element, dropdownElement.firstChild); + } } - else if (this.config.searchEnabled) { - dropdownElement.insertBefore(this.input.element, dropdownElement.firstChild); + else { + if (!this._isSelectMultipleElement || this.config.searchEnabled) { + containerInner.element.appendChild(this.input.element); + } + if (this._placeholderValue) { + this.input.placeholder = this._placeholderValue; + } + this.input.setWidth(); } this._highlightPosition = 0; this._isSearching = false; @@ -3622,7 +3684,7 @@ throw new TypeError("".concat(caller, " called for an element which has multiple instances of Choices initialised on it")); } }; - Choices.version = '11.1.0'; + Choices.version = '11.2.0'; return Choices; }()); diff --git a/assets/scripts/choices.search-kmp.min.js b/assets/scripts/choices.search-kmp.min.js index ea4d67ee..43c5cc27 100644 --- a/assets/scripts/choices.search-kmp.min.js +++ b/assets/scripts/choices.search-kmp.min.js @@ -1,2 +1,2 @@ -/*! choices.js v11.1.0 | © 2025 Josh Johnson | https://github.com/jshjohnson/Choices#readme */ -!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).Choices=t()}(this,(function(){"use strict";var e=function(t,i){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])},e(t,i)};function t(t,i){if("function"!=typeof i&&null!==i)throw new TypeError("Class extends value "+String(i)+" is not a constructor or null");function n(){this.constructor=t}e(t,i),t.prototype=null===i?Object.create(i):(n.prototype=i.prototype,new n)}var i=function(){return i=Object.assign||function(e){for(var t,i=1,n=arguments.length;i/g,">").replace(/=0&&!window.matchMedia("(min-height: ".concat(e+1,"px)")).matches:"top"===this.position&&(i=!0),i},e.prototype.setActiveDescendant=function(e){this.element.setAttribute("aria-activedescendant",e)},e.prototype.removeActiveDescendant=function(){this.element.removeAttribute("aria-activedescendant")},e.prototype.open=function(e,t){k(this.element,this.classNames.openState),this.element.setAttribute("aria-expanded","true"),this.isOpen=!0,this.shouldFlip(e,t)&&(k(this.element,this.classNames.flippedState),this.isFlipped=!0)},e.prototype.close=function(){M(this.element,this.classNames.openState),this.element.setAttribute("aria-expanded","false"),this.removeActiveDescendant(),this.isOpen=!1,this.isFlipped&&(M(this.element,this.classNames.flippedState),this.isFlipped=!1)},e.prototype.addFocusState=function(){k(this.element,this.classNames.focusState)},e.prototype.removeFocusState=function(){M(this.element,this.classNames.focusState)},e.prototype.enable=function(){M(this.element,this.classNames.disabledState),this.element.removeAttribute("aria-disabled"),this.type===_&&this.element.setAttribute("tabindex","0"),this.isDisabled=!1},e.prototype.disable=function(){k(this.element,this.classNames.disabledState),this.element.setAttribute("aria-disabled","true"),this.type===_&&this.element.setAttribute("tabindex","-1"),this.isDisabled=!0},e.prototype.wrap=function(e){var t=this.element,i=e.parentNode;i&&(e.nextSibling?i.insertBefore(t,e.nextSibling):i.appendChild(t)),t.appendChild(e)},e.prototype.unwrap=function(e){var t=this.element,i=t.parentNode;i&&(i.insertBefore(e,t),i.removeChild(t))},e.prototype.addLoadingState=function(){k(this.element,this.classNames.loadingState),this.element.setAttribute("aria-busy","true"),this.isLoading=!0},e.prototype.removeLoadingState=function(){M(this.element,this.classNames.loadingState),this.element.removeAttribute("aria-busy"),this.isLoading=!1},e}(),V=function(){function e(e){var t=e.element,i=e.type,n=e.classNames,s=e.preventPaste;this.element=t,this.type=i,this.classNames=n,this.preventPaste=s,this.isFocussed=this.element.isEqualNode(document.activeElement),this.isDisabled=t.disabled,this._onPaste=this._onPaste.bind(this),this._onInput=this._onInput.bind(this),this._onFocus=this._onFocus.bind(this),this._onBlur=this._onBlur.bind(this)}return Object.defineProperty(e.prototype,"placeholder",{set:function(e){this.element.placeholder=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"value",{get:function(){return this.element.value},set:function(e){this.element.value=e},enumerable:!1,configurable:!0}),e.prototype.addEventListeners=function(){var e=this.element;e.addEventListener("paste",this._onPaste),e.addEventListener("input",this._onInput,{passive:!0}),e.addEventListener("focus",this._onFocus,{passive:!0}),e.addEventListener("blur",this._onBlur,{passive:!0})},e.prototype.removeEventListeners=function(){var e=this.element;e.removeEventListener("input",this._onInput),e.removeEventListener("paste",this._onPaste),e.removeEventListener("focus",this._onFocus),e.removeEventListener("blur",this._onBlur)},e.prototype.enable=function(){this.element.removeAttribute("disabled"),this.isDisabled=!1},e.prototype.disable=function(){this.element.setAttribute("disabled",""),this.isDisabled=!0},e.prototype.focus=function(){this.isFocussed||this.element.focus()},e.prototype.blur=function(){this.isFocussed&&this.element.blur()},e.prototype.clear=function(e){return void 0===e&&(e=!0),this.element.value="",e&&this.setWidth(),this},e.prototype.setWidth=function(){var e=this.element;e.style.minWidth="".concat(e.placeholder.length+1,"ch"),e.style.width="".concat(e.value.length+1,"ch")},e.prototype.setActiveDescendant=function(e){this.element.setAttribute("aria-activedescendant",e)},e.prototype.removeActiveDescendant=function(){this.element.removeAttribute("aria-activedescendant")},e.prototype._onInput=function(){this.type!==_&&this.setWidth()},e.prototype._onPaste=function(e){this.preventPaste&&e.preventDefault()},e.prototype._onFocus=function(){this.isFocussed=!0},e.prototype._onBlur=function(){this.isFocussed=!1},e}(),H=function(){function e(e){this.element=e.element,this.scrollPos=this.element.scrollTop,this.height=this.element.offsetHeight}return e.prototype.prepend=function(e){var t=this.element.firstElementChild;t?this.element.insertBefore(e,t):this.element.append(e)},e.prototype.scrollToTop=function(){this.element.scrollTop=0},e.prototype.scrollToChildElement=function(e,t){var i=this;if(e){var n=t>0?this.element.scrollTop+(e.offsetTop+e.offsetHeight)-(this.element.scrollTop+this.element.offsetHeight):e.offsetTop;requestAnimationFrame((function(){i._animateScroll(n,t)}))}},e.prototype._scrollDown=function(e,t,i){var n=(i-e)/t;this.element.scrollTop=e+(n>1?n:1)},e.prototype._scrollUp=function(e,t,i){var n=(e-i)/t;this.element.scrollTop=e-(n>1?n:1)},e.prototype._animateScroll=function(e,t){var i=this,n=this.element.scrollTop,s=!1;t>0?(this._scrollDown(n,4,e),ne&&(s=!0)),s&&requestAnimationFrame((function(){i._animateScroll(e,t)}))},e}(),R=function(){function e(e){var t=e.classNames;this.element=e.element,this.classNames=t,this.isDisabled=!1}return Object.defineProperty(e.prototype,"isActive",{get:function(){return"active"===this.element.dataset.choice},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"dir",{get:function(){return this.element.dir},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"value",{get:function(){return this.element.value},set:function(e){this.element.setAttribute("value",e),this.element.value=e},enumerable:!1,configurable:!0}),e.prototype.conceal=function(){var e=this.element;k(e,this.classNames.input),e.hidden=!0,e.tabIndex=-1;var t=e.getAttribute("style");t&&e.setAttribute("data-choice-orig-style",t),e.setAttribute("data-choice","active")},e.prototype.reveal=function(){var e=this.element;M(e,this.classNames.input),e.hidden=!1,e.removeAttribute("tabindex");var t=e.getAttribute("data-choice-orig-style");t?(e.removeAttribute("data-choice-orig-style"),e.setAttribute("style",t)):e.removeAttribute("style"),e.removeAttribute("data-choice")},e.prototype.enable=function(){this.element.removeAttribute("disabled"),this.element.disabled=!1,this.isDisabled=!1},e.prototype.disable=function(){this.element.setAttribute("disabled",""),this.element.disabled=!0,this.isDisabled=!0},e.prototype.triggerEvent=function(e,t){var i;void 0===(i=t||{})&&(i=null),this.element.dispatchEvent(new CustomEvent(e,{detail:i,bubbles:!0,cancelable:!0}))},e}(),q=function(e){function i(){return null!==e&&e.apply(this,arguments)||this}return t(i,e),i}(R),U=function(e,t){return void 0===t&&(t=!0),void 0===e?t:!!e},G=function(e){if("string"==typeof e&&(e=e.split(" ").filter((function(e){return e.length}))),Array.isArray(e)&&e.length)return e},W=function(e,t,i){if(void 0===i&&(i=!0),"string"==typeof e){var n=w(e);return W({value:e,label:i||n===e?e:{escaped:n,raw:e},selected:!0},!1)}var s=e;if("choices"in s){if(!t)throw new TypeError("optGroup is not allowed");var o=s,r=o.choices.map((function(e){return W(e,!1)}));return{id:0,label:T(o.label)||o.value,active:!!r.length,disabled:!!o.disabled,choices:r}}var a=s;return{id:0,group:null,score:0,rank:0,value:a.value,label:a.label||a.value,active:U(a.active),selected:U(a.selected,!1),disabled:U(a.disabled,!1),placeholder:U(a.placeholder,!1),highlighted:!1,labelClass:G(a.labelClass),labelDescription:a.labelDescription,customProperties:a.customProperties}},X=function(e){return"SELECT"===e.tagName},J=function(e){function i(t){var i=t.template,n=t.extractPlaceholder,s=e.call(this,{element:t.element,classNames:t.classNames})||this;return s.template=i,s.extractPlaceholder=n,s}return t(i,e),Object.defineProperty(i.prototype,"placeholderOption",{get:function(){return this.element.querySelector('option[value=""]')||this.element.querySelector("option[placeholder]")},enumerable:!1,configurable:!0}),i.prototype.addOptions=function(e){var t=this,i=document.createDocumentFragment();e.forEach((function(e){var n=e;if(!n.element){var s=t.template(n);i.appendChild(s),n.element=s}})),this.element.appendChild(i)},i.prototype.optionsAsChoices=function(){var e=this,t=[];return this.element.querySelectorAll(":scope > option, :scope > optgroup").forEach((function(i){!function(e){return"OPTION"===e.tagName}(i)?function(e){return"OPTGROUP"===e.tagName}(i)&&t.push(e._optgroupToChoice(i)):t.push(e._optionToChoice(i))})),t},i.prototype._optionToChoice=function(e){return!e.hasAttribute("value")&&e.hasAttribute("placeholder")&&(e.setAttribute("value",""),e.value=""),{id:0,group:null,score:0,rank:0,value:e.value,label:e.label,element:e,active:!0,selected:this.extractPlaceholder?e.selected:e.hasAttribute("selected"),disabled:e.disabled,highlighted:!1,placeholder:this.extractPlaceholder&&(!e.value||e.hasAttribute("placeholder")),labelClass:void 0!==e.dataset.labelClass?G(e.dataset.labelClass):void 0,labelDescription:void 0!==e.dataset.labelDescription?e.dataset.labelDescription:void 0,customProperties:K(e.dataset.customProperties)}},i.prototype._optgroupToChoice=function(e){var t=this,i=e.querySelectorAll("option"),n=Array.from(i).map((function(e){return t._optionToChoice(e)}));return{id:0,label:e.label||"",element:e,active:!!n.length,disabled:e.disabled,choices:n}},i}(R),z={items:[],choices:[],silent:!1,renderChoiceLimit:-1,maxItemCount:-1,closeDropdownOnSelect:"auto",singleModeForMultiSelect:!1,addChoices:!1,addItems:!0,addItemFilter:function(e){return!!e&&""!==e},removeItems:!0,removeItemButton:!1,removeItemButtonAlignLeft:!1,editItems:!1,allowHTML:!1,allowHtmlUserInput:!1,duplicateItemsAllowed:!0,delimiter:",",paste:!0,searchEnabled:!0,searchChoices:!0,searchFloor:1,searchResultLimit:4,searchFields:["label","value"],position:"auto",resetScrollPosition:!0,shouldSort:!0,shouldSortItems:!1,sorter:function(e,t){var i=e.label,n=t.label,s=void 0===n?t.value:n;return T(void 0===i?e.value:i).localeCompare(T(s),[],{sensitivity:"base",ignorePunctuation:!0,numeric:!0})},shadowRoot:null,placeholder:!0,placeholderValue:null,searchPlaceholderValue:null,prependValue:null,appendValue:null,renderSelectedChoices:"auto",loadingText:"Loading...",noResultsText:"No results found",noChoicesText:"No choices to choose from",itemSelectText:"Press to select",uniqueItemText:"Only unique values can be added",customAddItemText:"Only values matching specific conditions can be added",addItemText:function(e){return'Press Enter to add "'.concat(e,'"')},removeItemIconText:function(){return"Remove item"},removeItemLabelText:function(e){return"Remove item: ".concat(e)},maxItemText:function(e){return"Only ".concat(e," values can be added")},valueComparer:function(e,t){return e===t},fuseOptions:{includeScore:!0},labelId:"",callbackOnInit:null,callbackOnCreateTemplates:null,classNames:{containerOuter:["choices"],containerInner:["choices__inner"],input:["choices__input"],inputCloned:["choices__input--cloned"],list:["choices__list"],listItems:["choices__list--multiple"],listSingle:["choices__list--single"],listDropdown:["choices__list--dropdown"],item:["choices__item"],itemSelectable:["choices__item--selectable"],itemDisabled:["choices__item--disabled"],itemChoice:["choices__item--choice"],description:["choices__description"],placeholder:["choices__placeholder"],group:["choices__group"],groupHeading:["choices__heading"],button:["choices__button"],activeState:["is-active"],focusState:["is-focused"],openState:["is-open"],disabledState:["is-disabled"],highlightedState:["is-highlighted"],selectedState:["is-selected"],flippedState:["is-flipped"],loadingState:["is-loading"],notice:["choices__notice"],addChoice:["choices__item--selectable","add-choice"],noResults:["has-no-results"],noChoices:["has-no-choices"]},appendGroupInSearch:!1},Q=function(e){var t=e.itemEl;t&&(t.remove(),e.itemEl=void 0)},Y={groups:function(e,t){var i=e,n=!0;switch(t.type){case l:i.push(t.group);break;case c:i=[];break;default:n=!1}return{state:i,update:n}},items:function(e,t,i){var n=e,s=!0;switch(t.type){case h:t.item.selected=!0,(r=t.item.element)&&(r.selected=!0,r.setAttribute("selected","")),n.push(t.item);break;case u:var r;if(t.item.selected=!1,r=t.item.element){r.selected=!1,r.removeAttribute("selected");var a=r.parentElement;a&&X(a)&&a.type===_&&(a.value="")}Q(t.item),n=n.filter((function(e){return e.id!==t.item.id}));break;case o:Q(t.choice),n=n.filter((function(e){return e.id!==t.choice.id}));break;case d:var c=t.highlighted,l=n.find((function(e){return e.id===t.item.id}));l&&l.highlighted!==c&&(l.highlighted=c,i&&function(e,t,i){var n=e.itemEl;n&&(M(n,i),k(n,t))}(l,c?i.classNames.highlightedState:i.classNames.selectedState,c?i.classNames.selectedState:i.classNames.highlightedState));break;default:s=!1}return{state:n,update:s}},choices:function(e,t,i){var n=e,l=!0;switch(t.type){case s:n.push(t.choice);break;case o:t.choice.choiceEl=void 0,t.choice.group&&(t.choice.group.choices=t.choice.group.choices.filter((function(e){return e.id!==t.choice.id}))),n=n.filter((function(e){return e.id!==t.choice.id}));break;case h:case u:t.item.choiceEl=void 0;break;case r:var d=[];t.results.forEach((function(e){d[e.item.id]=e})),n.forEach((function(e){var t=d[e.id];void 0!==t?(e.score=t.score,e.rank=t.rank,e.active=!0):(e.score=0,e.rank=0,e.active=!1),i&&i.appendGroupInSearch&&(e.choiceEl=void 0)}));break;case a:n.forEach((function(e){e.active=t.active,i&&i.appendGroupInSearch&&(e.choiceEl=void 0)}));break;case c:n=[];break;default:l=!1}return{state:n,update:l}}},Z=function(){function e(e){this._state=this.defaultState,this._listeners=[],this._txn=0,this._context=e}return Object.defineProperty(e.prototype,"defaultState",{get:function(){return{groups:[],items:[],choices:[]}},enumerable:!1,configurable:!0}),e.prototype.changeSet=function(e){return{groups:e,items:e,choices:e}},e.prototype.reset=function(){this._state=this.defaultState;var e=this.changeSet(!0);this._txn?this._changeSet=e:this._listeners.forEach((function(t){return t(e)}))},e.prototype.subscribe=function(e){return this._listeners.push(e),this},e.prototype.dispatch=function(e){var t=this,i=this._state,n=!1,s=this._changeSet||this.changeSet(!1);Object.keys(Y).forEach((function(o){var r=Y[o](i[o],e,t._context);r.update&&(n=!0,s[o]=!0,i[o]=r.state)})),n&&(this._txn?this._changeSet=s:this._listeners.forEach((function(e){return e(s)})))},e.prototype.withTxn=function(e){this._txn++;try{e()}finally{if(this._txn=Math.max(0,this._txn-1),!this._txn){var t=this._changeSet;t&&(this._changeSet=void 0,this._listeners.forEach((function(e){return e(t)})))}}},Object.defineProperty(e.prototype,"state",{get:function(){return this._state},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"items",{get:function(){return this.state.items},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"highlightedActiveItems",{get:function(){return this.items.filter((function(e){return e.active&&e.highlighted}))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"choices",{get:function(){return this.state.choices},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"activeChoices",{get:function(){return this.choices.filter((function(e){return e.active}))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"searchableChoices",{get:function(){return this.choices.filter((function(e){return!e.disabled&&!e.placeholder}))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"groups",{get:function(){return this.state.groups},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"activeGroups",{get:function(){var e=this;return this.state.groups.filter((function(t){var i=t.active&&!t.disabled,n=e.state.choices.some((function(e){return e.active&&!e.disabled}));return i&&n}),[])},enumerable:!1,configurable:!0}),e.prototype.inTxn=function(){return this._txn>0},e.prototype.getChoiceById=function(e){return this.activeChoices.find((function(t){return t.id===e}))},e.prototype.getGroupById=function(e){return this.groups.find((function(t){return t.id===e}))},e}(),$="no-choices",ee="no-results",te="add-choice";function ie(e,t){if(0===e.length)return 0;for(var i=[0],n=1;n0&&e.charAt(n)!==e.charAt(s);)s=i[s-1];e.charAt(n)===e.charAt(s)&&s++,i.push(s)}var o=0;for(n=0;n0&&t.charAt(n)!==e.charAt(o);)o=i[o-1];if(t.charAt(n)===e.charAt(o)&&++o===e.length)return n-(o-1)}return-1}var ne=function(){function e(e){this._haystack=[],this._fields=e.searchFields}return e.prototype.index=function(e){this._haystack=e},e.prototype.reset=function(){this._haystack=[]},e.prototype.isEmptyIndex=function(){return!this._haystack.length},e.prototype.search=function(e){var t=this._fields;if(!t||!t.length||!e)return[];for(var i=e.toLowerCase(),n=[],s=0,o=0,r=this._haystack.length;o element"),this)},e.prototype.removeChoice=function(e){var t=this._store.choices.find((function(t){return t.value===e}));return t?(this._clearNotice(),this._store.dispatch(function(e){return{type:o,choice:e}}(t)),this._searcher.reset(),t.selected&&this.passedElement.triggerEvent(m,this._getChoiceForOutput(t)),this):this},e.prototype.clearChoices=function(e,t){var i=this;return void 0===e&&(e=!0),void 0===t&&(t=!1),e&&(t?this.passedElement.element.replaceChildren(""):this.passedElement.element.querySelectorAll(":not([selected])").forEach((function(e){e.remove()}))),this.itemList.element.replaceChildren(""),this.choiceList.element.replaceChildren(""),this._clearNotice(),this._store.withTxn((function(){var e=t?[]:i._store.items;i._store.reset(),e.forEach((function(e){i._store.dispatch(y(e)),i._store.dispatch(b(e))}))})),this._searcher.reset(),this},e.prototype.clearStore=function(e){return void 0===e&&(e=!0),this.clearChoices(e,!0),this._stopSearch(),this._lastAddedChoiceId=0,this._lastAddedGroupId=0,this},e.prototype.clearInput=function(){return this.input.clear(!this._isSelectOneElement),this._stopSearch(),this},e.prototype._validateConfig=function(){var e,t,i,n=this.config,s=(e=z,t=Object.keys(n).sort(),i=Object.keys(e).sort(),t.filter((function(e){return i.indexOf(e)<0})));s.length&&console.warn("Unknown config option(s) passed",s.join(", ")),n.allowHTML&&n.allowHtmlUserInput&&(n.addItems&&console.warn("Warning: allowHTML/allowHtmlUserInput/addItems all being true is strongly not recommended and may lead to XSS attacks"),n.addChoices&&console.warn("Warning: allowHTML/allowHtmlUserInput/addChoices all being true is strongly not recommended and may lead to XSS attacks"))},e.prototype._render=function(e){void 0===e&&(e={choices:!0,groups:!0,items:!0}),this._store.inTxn()||(this._isSelectElement&&(e.choices||e.groups)&&this._renderChoices(),e.items&&this._renderItems())},e.prototype._renderChoices=function(){var e=this;if(this._canAddItems()){var t=this.config,i=this._isSearching,n=this._store,s=n.activeGroups,o=n.activeChoices,r=0;if(i&&t.searchResultLimit>0?r=t.searchResultLimit:t.renderChoiceLimit>0&&(r=t.renderChoiceLimit),this._isSelectElement){var a=o.filter((function(e){return!e.element}));a.length&&this.passedElement.addOptions(a)}var c=document.createDocumentFragment(),l=function(e){return e.filter((function(e){return!e.placeholder&&(i?!!e.rank:t.renderSelectedChoices||!e.selected)}))},h=!1,u=function(n,s,o){i?n.sort(N):t.shouldSort&&n.sort(t.sorter);var a=n.length;a=!s&&r&&a>r?r:a,a--,n.every((function(n,s){var r=n.choiceEl||e._templates.choice(t,n,t.itemSelectText,o);return n.choiceEl=r,c.appendChild(r),!i&&n.selected||(h=!0),s1){var l=i.querySelector(F(n.classNames.placeholder));l&&l.remove()}else a||c||!this._placeholderValue||(a=!0,r(W({selected:!0,value:"",label:this._placeholderValue,placeholder:!0},!1)))}a&&(i.append(s),n.shouldSortItems&&!this._isSelectOneElement&&(t.sort(n.sorter),t.forEach((function(e){var t=o(e);t&&(t.remove(),s.append(t))})),i.append(s))),this._isTextElement&&(this.passedElement.value=t.map((function(e){return e.value})).join(n.delimiter))},e.prototype._displayNotice=function(e,t,i){void 0===i&&(i=!0);var n=this._notice;n&&(n.type===t&&n.text===e||n.type===te&&(t===ee||t===$))?i&&this.showDropdown(!0):(this._clearNotice(),this._notice=e?{text:e,type:t}:void 0,this._renderNotice(),i&&e&&this.showDropdown(!0))},e.prototype._clearNotice=function(){if(this._notice){var e=this.choiceList.element.querySelector(F(this.config.classNames.notice));e&&e.remove(),this._notice=void 0}},e.prototype._renderNotice=function(e){var t=this._notice;if(t){var i=this._templates.notice(this.config,t.text,t.type);e?e.append(i):this.choiceList.prepend(i)}},e.prototype._getChoiceForOutput=function(e,t){return{id:e.id,highlighted:e.highlighted,labelClass:e.labelClass,labelDescription:e.labelDescription,customProperties:e.customProperties,disabled:e.disabled,active:e.active,label:e.label,placeholder:e.placeholder,value:e.value,groupValue:e.group?e.group.label:void 0,element:e.element,keyCode:t}},e.prototype._triggerChange=function(e){null!=e&&this.passedElement.triggerEvent("change",{value:e})},e.prototype._handleButtonAction=function(e){var t=this,i=this._store.items;if(i.length&&this.config.removeItems&&this.config.removeItemButton){var n=e&&le(e.parentElement),s=n&&i.find((function(e){return e.id===n}));s&&this._store.withTxn((function(){if(t._removeItem(s),t._triggerChange(s.value),t._isSelectOneElement&&!t._hasNonChoicePlaceholder){var e=(t.config.shouldSort?t._store.choices.reverse():t._store.choices).find((function(e){return e.placeholder}));e&&(t._addItem(e),t.unhighlightAll(),e.value&&t._triggerChange(e.value))}}))}},e.prototype._handleItemAction=function(e,t){var i=this;void 0===t&&(t=!1);var n=this._store.items;if(n.length&&this.config.removeItems&&!this._isSelectOneElement){var s=le(e);s&&(n.forEach((function(e){e.id!==s||e.highlighted?!t&&e.highlighted&&i.unhighlightItem(e):i.highlightItem(e)})),this.input.focus())}},e.prototype._handleChoiceAction=function(e){var t=this,i=le(e),n=i&&this._store.getChoiceById(i);if(!n||n.disabled)return!1;var s=this.dropdown.isActive;if(!n.selected){if(!this._canAddItems())return!0;this._store.withTxn((function(){t._addItem(n,!0,!0),t.clearInput(),t.unhighlightAll()})),this._triggerChange(n.value)}return s&&this.config.closeDropdownOnSelect&&(this.hideDropdown(!0),this.containerOuter.element.focus()),!0},e.prototype._handleBackspace=function(e){var t=this.config;if(t.removeItems&&e.length){var i=e[e.length-1],n=e.some((function(e){return e.highlighted}));t.editItems&&!n&&i?(this.input.value=i.value,this.input.setWidth(),this._removeItem(i),this._triggerChange(i.value)):(n||this.highlightItem(i,!1),this.removeHighlightedItems(!0))}},e.prototype._loadChoices=function(){var e,t=this,i=this.config;if(this._isTextElement){if(this._presetChoices=i.items.map((function(e){return W(e,!1)})),this.passedElement.value){var n=this.passedElement.value.split(i.delimiter).map((function(e){return W(e,!1,t.config.allowHtmlUserInput)}));this._presetChoices=this._presetChoices.concat(n)}this._presetChoices.forEach((function(e){e.selected=!0}))}else if(this._isSelectElement){this._presetChoices=i.choices.map((function(e){return W(e,!0)}));var s=this.passedElement.optionsAsChoices();s&&(e=this._presetChoices).push.apply(e,s)}},e.prototype._handleLoadingState=function(e){void 0===e&&(e=!0);var t=this.itemList.element;e?(this.disable(),this.containerOuter.addLoadingState(),this._isSelectOneElement?t.replaceChildren(this._templates.placeholder(this.config,this.config.loadingText)):this.input.placeholder=this.config.loadingText):(this.enable(),this.containerOuter.removeLoadingState(),this._isSelectOneElement?(t.replaceChildren(""),this._render()):this.input.placeholder=this._placeholderValue||"")},e.prototype._handleSearch=function(e){if(this.input.isFocussed)if(null!=e&&e.length>=this.config.searchFloor){var t=this.config.searchChoices?this._searchChoices(e):0;null!==t&&this.passedElement.triggerEvent(p,{value:e,resultCount:t})}else this._store.choices.some((function(e){return!e.active}))&&this._stopSearch()},e.prototype._canAddItems=function(){var e=this.config,t=e.maxItemCount,i=e.maxItemText;return!e.singleModeForMultiSelect&&t>0&&t<=this._store.items.length?(this.choiceList.element.replaceChildren(""),this._notice=void 0,this._displayNotice("function"==typeof i?i(t):i,te),!1):(this._notice&&this._notice.type===te&&this._clearNotice(),!0)},e.prototype._canCreateItem=function(e){var t=this.config,i=!0,n="";if(i&&"function"==typeof t.addItemFilter&&!t.addItemFilter(e)&&(i=!1,n=I(t.customAddItemText,e)),i&&this._store.choices.find((function(i){return t.valueComparer(i.value,e)}))){if(this._isSelectElement)return this._displayNotice("",te),!1;t.duplicateItemsAllowed||(i=!1,n=I(t.uniqueItemText,e))}return i&&(n=I(t.addItemText,e)),n&&this._displayNotice(n,te),i},e.prototype._searchChoices=function(e){var t=e.trim().replace(/\s{2,}/," ");if(!t.length||t===this._currentValue)return null;var i=this._searcher;i.isEmptyIndex()&&i.index(this._store.searchableChoices);var n=i.search(t);this._currentValue=t,this._highlightPosition=0,this._isSearching=!0;var s=this._notice;return(s&&s.type)!==te&&(n.length?this._clearNotice():this._displayNotice(O(this.config.noResultsText),ee)),this._store.dispatch(function(e){return{type:r,results:e}}(n)),n.length},e.prototype._stopSearch=function(){this._isSearching&&(this._currentValue="",this._isSearching=!1,this._clearNotice(),this._store.dispatch({type:a,active:!0}),this.passedElement.triggerEvent(p,{value:"",resultCount:0}))},e.prototype._addEventListeners=function(){var e=this._docRoot,t=this.containerOuter.element,i=this.input.element;e.addEventListener("touchend",this._onTouchEnd,!0),t.addEventListener("keydown",this._onKeyDown,!0),t.addEventListener("mousedown",this._onMouseDown,!0),e.addEventListener("click",this._onClick,{passive:!0}),e.addEventListener("touchmove",this._onTouchMove,{passive:!0}),this.dropdown.element.addEventListener("mouseover",this._onMouseOver,{passive:!0}),this._isSelectOneElement&&(t.addEventListener("focus",this._onFocus,{passive:!0}),t.addEventListener("blur",this._onBlur,{passive:!0})),i.addEventListener("keyup",this._onKeyUp,{passive:!0}),i.addEventListener("input",this._onInput,{passive:!0}),i.addEventListener("focus",this._onFocus,{passive:!0}),i.addEventListener("blur",this._onBlur,{passive:!0}),i.form&&i.form.addEventListener("reset",this._onFormReset,{passive:!0}),this.input.addEventListeners()},e.prototype._removeEventListeners=function(){var e=this._docRoot,t=this.containerOuter.element,i=this.input.element;e.removeEventListener("touchend",this._onTouchEnd,!0),t.removeEventListener("keydown",this._onKeyDown,!0),t.removeEventListener("mousedown",this._onMouseDown,!0),e.removeEventListener("click",this._onClick),e.removeEventListener("touchmove",this._onTouchMove),this.dropdown.element.removeEventListener("mouseover",this._onMouseOver),this._isSelectOneElement&&(t.removeEventListener("focus",this._onFocus),t.removeEventListener("blur",this._onBlur)),i.removeEventListener("keyup",this._onKeyUp),i.removeEventListener("input",this._onInput),i.removeEventListener("focus",this._onFocus),i.removeEventListener("blur",this._onBlur),i.form&&i.form.removeEventListener("reset",this._onFormReset),this.input.removeEventListeners()},e.prototype._onKeyDown=function(e){var t=e.keyCode,i=this.dropdown.isActive,n=1===e.key.length||2===e.key.length&&e.key.charCodeAt(0)>=55296||"Unidentified"===e.key;switch(this._isTextElement||i||27===t||9===t||16===t||(this.showDropdown(),!this.input.isFocussed&&n&&(this.input.value+=e.key," "===e.key&&e.preventDefault())),t){case 65:return this._onSelectKey(e,this.itemList.element.hasChildNodes());case 13:return this._onEnterKey(e,i);case 27:return this._onEscapeKey(e,i);case 38:case 33:case 40:case 34:return this._onDirectionKey(e,i);case 8:case 46:return this._onDeleteKey(e,this._store.items,this.input.isFocussed)}},e.prototype._onKeyUp=function(){this._canSearch=this.config.searchEnabled},e.prototype._onInput=function(){var e=this.input.value;e?this._canAddItems()&&(this._canSearch&&this._handleSearch(e),this._canAddUserChoices&&(this._canCreateItem(e),this._isSelectElement&&(this._highlightPosition=0,this._highlightChoice()))):this._isTextElement?this.hideDropdown(!0):this._stopSearch()},e.prototype._onSelectKey=function(e,t){(e.ctrlKey||e.metaKey)&&t&&(this._canSearch=!1,this.config.removeItems&&!this.input.value&&this.input.element===document.activeElement&&this.highlightAll())},e.prototype._onEnterKey=function(e,t){var i=this,n=this.input.value,s=e.target;if(e.preventDefault(),s&&s.hasAttribute("data-button"))this._handleButtonAction(s);else if(t){var o=this.dropdown.element.querySelector(F(this.config.classNames.highlightedState));if(!o||!this._handleChoiceAction(o))if(s&&n){if(this._canAddItems()){var r=!1;this._store.withTxn((function(){if(!(r=i._findAndSelectChoiceByValue(n,!0))){if(!i._canAddUserChoices)return;if(!i._canCreateItem(n))return;i._addChoice(W(n,!1,i.config.allowHtmlUserInput),!0,!0),r=!0}i.clearInput(),i.unhighlightAll()})),r&&(this._triggerChange(n),this.config.closeDropdownOnSelect&&this.hideDropdown(!0))}}else this.hideDropdown(!0)}else(this._isSelectElement||this._notice)&&this.showDropdown()},e.prototype._onEscapeKey=function(e,t){t&&(e.stopPropagation(),this.hideDropdown(!0),this._stopSearch(),this.containerOuter.element.focus())},e.prototype._onDirectionKey=function(e,t){var i,n,s,o=e.keyCode;if(t||this._isSelectOneElement){this.showDropdown(),this._canSearch=!1;var r=40===o||34===o?1:-1,a=void 0;if(e.metaKey||34===o||33===o)a=this.dropdown.element.querySelector(r>0?"".concat(he,":last-of-type"):he);else{var c=this.dropdown.element.querySelector(F(this.config.classNames.highlightedState));a=c?function(e,t,i){void 0===i&&(i=1);for(var n="".concat(i>0?"next":"previous","ElementSibling"),s=e[n];s;){if(s.matches(t))return s;s=s[n]}return null}(c,he,r):this.dropdown.element.querySelector(he)}a&&(i=a,n=this.choiceList.element,void 0===(s=r)&&(s=1),(s>0?n.scrollTop+n.offsetHeight>=i.offsetTop+i.offsetHeight:i.offsetTop>=n.scrollTop)||this.choiceList.scrollToChildElement(a,r),this._highlightChoice(a)),e.preventDefault()}},e.prototype._onDeleteKey=function(e,t,i){this._isSelectOneElement||e.target.value||!i||(this._handleBackspace(t),e.preventDefault())},e.prototype._onTouchMove=function(){this._wasTap&&(this._wasTap=!1)},e.prototype._onTouchEnd=function(e){var t=(e||e.touches[0]).target;this._wasTap&&this.containerOuter.element.contains(t)&&((t===this.containerOuter.element||t===this.containerInner.element)&&(this._isTextElement?this.input.focus():this._isSelectMultipleElement&&this.showDropdown()),e.stopPropagation()),this._wasTap=!0},e.prototype._onMouseDown=function(e){var t=e.target;if(t instanceof HTMLElement){if(ae&&this.choiceList.element.contains(t)){var i=this.choiceList.element.firstElementChild;this._isScrollingOnIe="ltr"===this._direction?e.offsetX>=i.offsetWidth:e.offsetXthis._highlightPosition?t[this._highlightPosition]:t[t.length-1])||(i=t[0]),k(i,n),i.setAttribute("aria-selected","true"),this.passedElement.triggerEvent("highlightChoice",{el:i}),this.dropdown.isActive&&(this.input.setActiveDescendant(i.id),this.containerOuter.setActiveDescendant(i.id))}},e.prototype._addItem=function(e,t,i){if(void 0===t&&(t=!0),void 0===i&&(i=!1),!e.id)throw new TypeError("item.id must be set before _addItem is called for a choice/item");(this.config.singleModeForMultiSelect||this._isSelectOneElement)&&this.removeActiveItems(e.id),this._store.dispatch(b(e)),t&&(this.passedElement.triggerEvent("addItem",this._getChoiceForOutput(e)),i&&this.passedElement.triggerEvent("choice",this._getChoiceForOutput(e)))},e.prototype._removeItem=function(e){if(e.id){this._store.dispatch(E(e));var t=this._notice;t&&t.type===$&&this._clearNotice(),this.passedElement.triggerEvent(m,this._getChoiceForOutput(e))}},e.prototype._addChoice=function(e,t,i){if(void 0===t&&(t=!0),void 0===i&&(i=!1),e.id)throw new TypeError("Can not re-add a choice which has already been added");var n=this.config;if(n.duplicateItemsAllowed||!this._store.choices.find((function(t){return n.valueComparer(t.value,e.value)}))){this._lastAddedChoiceId++,e.id=this._lastAddedChoiceId,e.elementId="".concat(this._baseId,"-").concat(this._idNames.itemChoice,"-").concat(e.id);var s=n.prependValue,o=n.appendValue;s&&(e.value=s+e.value),o&&(e.value+=o.toString()),(s||o)&&e.element&&(e.element.value=e.value),this._clearNotice(),this._store.dispatch(y(e)),e.selected&&this._addItem(e,t,i)}},e.prototype._addGroup=function(e,t){var i=this;if(void 0===t&&(t=!0),e.id)throw new TypeError("Can not re-add a group which has already been added");this._store.dispatch(function(e){return{type:l,group:e}}(e)),e.choices&&(this._lastAddedGroupId++,e.id=this._lastAddedGroupId,e.choices.forEach((function(n){n.group=e,e.disabled&&(n.disabled=!0),i._addChoice(n,t)})))},e.prototype._createTemplates=function(){var e=this,t=this.config.callbackOnCreateTemplates,i={};"function"==typeof t&&(i=t.call(this,A,L,P));var n={};Object.keys(this._templates).forEach((function(t){n[t]=t in i?i[t].bind(e):e._templates[t].bind(e)})),this._templates=n},e.prototype._createElements=function(){var e=this._templates,t=this.config,i=this._isSelectOneElement,n=t.position,s=t.classNames,o=this._elementType;this.containerOuter=new B({element:e.containerOuter(t,this._direction,this._isSelectElement,i,t.searchEnabled,o,t.labelId),classNames:s,type:o,position:n}),this.containerInner=new B({element:e.containerInner(t),classNames:s,type:o,position:n}),this.input=new V({element:e.input(t,this._placeholderValue),classNames:s,type:o,preventPaste:!t.paste}),this.choiceList=new H({element:e.choiceList(t,i)}),this.itemList=new H({element:e.itemList(t,i)}),this.dropdown=new j({element:e.dropdown(t),classNames:s,type:o})},e.prototype._createStructure=function(){var e=this,t=e.containerInner,i=e.containerOuter,n=e.passedElement,s=this.dropdown.element;n.conceal(),t.wrap(n.element),i.wrap(t.element),this._isSelectOneElement?this.input.placeholder=this.config.searchPlaceholderValue||"":(this._placeholderValue&&(this.input.placeholder=this._placeholderValue),this.input.setWidth()),i.element.appendChild(t.element),i.element.appendChild(s),t.element.appendChild(this.itemList.element),s.appendChild(this.choiceList.element),this._isSelectOneElement?this.config.searchEnabled&&s.insertBefore(this.input.element,s.firstChild):t.element.appendChild(this.input.element),this._highlightPosition=0,this._isSearching=!1},e.prototype._initStore=function(){var e=this;this._store.subscribe(this._render).withTxn((function(){e._addPredefinedChoices(e._presetChoices,e._isSelectOneElement&&!e._hasNonChoicePlaceholder,!1)})),(!this._store.choices.length||this._isSelectOneElement&&this._hasNonChoicePlaceholder)&&this._render()},e.prototype._addPredefinedChoices=function(e,t,i){var n=this;void 0===t&&(t=!1),void 0===i&&(i=!0),t&&-1===e.findIndex((function(e){return e.selected}))&&e.some((function(e){return!e.disabled&&!("choices"in e)&&(e.selected=!0,!0)})),e.forEach((function(e){"choices"in e?n._isSelectElement&&n._addGroup(e,i):n._addChoice(e,i)}))},e.prototype._findAndSelectChoiceByValue=function(e,t){var i=this;void 0===t&&(t=!1);var n=this._store.choices.find((function(t){return i.config.valueComparer(t.value,e)}));return!(!n||n.disabled||n.selected||(this._addItem(n,!0,t),0))},e.prototype._generatePlaceholderValue=function(){var e=this.config;if(!e.placeholder)return null;if(this._hasNonChoicePlaceholder)return e.placeholderValue;if(this._isSelectElement){var t=this.passedElement.placeholderOption;return t?t.text:null}return null},e.prototype._warnChoicesInitFailed=function(e){if(!this.config.silent){if(!this.initialised)throw new TypeError("".concat(e," called on a non-initialised instance of Choices"));if(!this.initialisedOK)throw new TypeError("".concat(e," called for an element which has multiple instances of Choices initialised on it"))}},e.version="11.1.0",e}()})); +/*! choices.js v11.2.0 | © 2026 Josh Johnson | https://github.com/jshjohnson/Choices#readme */ +!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).Choices=t()}(this,(function(){"use strict";var e=function(t,i){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])},e(t,i)};function t(t,i){if("function"!=typeof i&&null!==i)throw new TypeError("Class extends value "+String(i)+" is not a constructor or null");function n(){this.constructor=t}e(t,i),t.prototype=null===i?Object.create(i):(n.prototype=i.prototype,new n)}var i=function(){return i=Object.assign||function(e){for(var t,i=1,n=arguments.length;i0?t.scrollTop+t.offsetHeight>=e.offsetTop+e.offsetHeight:e.offsetTop>=t.scrollTop},I=function(e){if("string"!=typeof e){if(null==e)return"";if("object"==typeof e){if("raw"in e)return I(e.raw);if("trusted"in e)return e.trusted}return e}return e.replace(/&/g,"&").replace(/>/g,">").replace(/=0&&!window.matchMedia("(min-height: ".concat(e+1,"px)")).matches:"top"===this.position&&(i=!0),i},e.prototype.setActiveDescendant=function(e){this.element.setAttribute("aria-activedescendant",e)},e.prototype.removeActiveDescendant=function(){this.element.removeAttribute("aria-activedescendant")},e.prototype.open=function(e,t){K(this.element,this.classNames.openState),this.element.setAttribute("aria-expanded","true"),this.isOpen=!0,this.shouldFlip(e,t)&&(K(this.element,this.classNames.flippedState),this.isFlipped=!0)},e.prototype.close=function(){j(this.element,this.classNames.openState),this.element.setAttribute("aria-expanded","false"),this.removeActiveDescendant(),this.isOpen=!1,this.isFlipped&&(j(this.element,this.classNames.flippedState),this.isFlipped=!1)},e.prototype.addFocusState=function(){K(this.element,this.classNames.focusState)},e.prototype.removeFocusState=function(){j(this.element,this.classNames.focusState)},e.prototype.addInvalidState=function(){K(this.element,this.classNames.invalidState)},e.prototype.removeInvalidState=function(){j(this.element,this.classNames.invalidState)},e.prototype.enable=function(){j(this.element,this.classNames.disabledState),this.element.removeAttribute("aria-disabled"),this.type===_&&this.element.setAttribute("tabindex","0"),this.isDisabled=!1},e.prototype.disable=function(){K(this.element,this.classNames.disabledState),this.element.setAttribute("aria-disabled","true"),this.type===_&&this.element.setAttribute("tabindex","-1"),this.isDisabled=!0},e.prototype.wrap=function(e){var t=this.element,i=e.parentNode;i&&(e.nextSibling?i.insertBefore(t,e.nextSibling):i.appendChild(t)),t.appendChild(e)},e.prototype.unwrap=function(e){var t=this.element,i=t.parentNode;i&&(i.insertBefore(e,t),i.removeChild(t))},e.prototype.addLoadingState=function(){K(this.element,this.classNames.loadingState),this.element.setAttribute("aria-busy","true"),this.isLoading=!0},e.prototype.removeLoadingState=function(){j(this.element,this.classNames.loadingState),this.element.removeAttribute("aria-busy"),this.isLoading=!1},e}(),R=function(){function e(e){var t=e.element,i=e.type,n=e.classNames,s=e.preventPaste;this.element=t,this.type=i,this.classNames=n,this.preventPaste=s,this.isFocussed=this.element.isEqualNode(document.activeElement),this.isDisabled=t.disabled,this._onPaste=this._onPaste.bind(this),this._onInput=this._onInput.bind(this),this._onFocus=this._onFocus.bind(this),this._onBlur=this._onBlur.bind(this)}return Object.defineProperty(e.prototype,"placeholder",{set:function(e){this.element.placeholder=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"value",{get:function(){return this.element.value},set:function(e){this.element.value=e},enumerable:!1,configurable:!0}),e.prototype.addEventListeners=function(){var e=this.element;e.addEventListener("paste",this._onPaste),e.addEventListener("input",this._onInput,{passive:!0}),e.addEventListener("focus",this._onFocus,{passive:!0}),e.addEventListener("blur",this._onBlur,{passive:!0})},e.prototype.removeEventListeners=function(){var e=this.element;e.removeEventListener("input",this._onInput),e.removeEventListener("paste",this._onPaste),e.removeEventListener("focus",this._onFocus),e.removeEventListener("blur",this._onBlur)},e.prototype.enable=function(){this.element.removeAttribute("disabled"),this.isDisabled=!1},e.prototype.disable=function(){this.element.setAttribute("disabled",""),this.isDisabled=!0},e.prototype.focus=function(){this.isFocussed||this.element.focus()},e.prototype.blur=function(){this.isFocussed&&this.element.blur()},e.prototype.clear=function(e){return void 0===e&&(e=!0),this.element.value="",e&&this.setWidth(),this},e.prototype.setWidth=function(){var e=this.element;e.style.minWidth="".concat(e.placeholder.length+1,"ch"),e.style.width="".concat(e.value.length+1,"ch")},e.prototype.setActiveDescendant=function(e){this.element.setAttribute("aria-activedescendant",e)},e.prototype.removeActiveDescendant=function(){this.element.removeAttribute("aria-activedescendant")},e.prototype._onInput=function(){this.type!==_&&this.setWidth()},e.prototype._onPaste=function(e){this.preventPaste&&e.preventDefault()},e.prototype._onFocus=function(){this.isFocussed=!0},e.prototype._onBlur=function(){this.isFocussed=!1},e}(),q=function(){function e(e){this.element=e.element,this.scrollPos=this.element.scrollTop,this.height=this.element.offsetHeight}return e.prototype.prepend=function(e){var t=this.element.firstElementChild;t?this.element.insertBefore(e,t):this.element.append(e)},e.prototype.scrollToTop=function(){this.element.scrollTop=0},e.prototype.scrollToChildElement=function(e,t){var i=this;if(e){var n=t>0?this.element.scrollTop+(e.offsetTop+e.offsetHeight)-(this.element.scrollTop+this.element.offsetHeight):e.offsetTop;requestAnimationFrame((function(){i._animateScroll(n,t)}))}},e.prototype._scrollDown=function(e,t,i){var n=(i-e)/t;this.element.scrollTop=e+(n>1?n:1)},e.prototype._scrollUp=function(e,t,i){var n=(e-i)/t;this.element.scrollTop=e-(n>1?n:1)},e.prototype._animateScroll=function(e,t){var i=this,n=this.element.scrollTop,s=!1;t>0?(this._scrollDown(n,4,e),ne&&(s=!0)),s&&requestAnimationFrame((function(){i._animateScroll(e,t)}))},e}(),U=function(){function e(e){var t=e.classNames;this.element=e.element,this.classNames=t,this.isDisabled=!1}return Object.defineProperty(e.prototype,"isActive",{get:function(){return"active"===this.element.dataset.choice},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"dir",{get:function(){return this.element.dir},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"value",{get:function(){return this.element.value},set:function(e){this.element.setAttribute("value",e),this.element.value=e},enumerable:!1,configurable:!0}),e.prototype.conceal=function(){var e=this.element;K(e,this.classNames.input),e.hidden=!0,e.tabIndex=-1;var t=e.getAttribute("style");t&&e.setAttribute("data-choice-orig-style",t),e.setAttribute("data-choice","active")},e.prototype.reveal=function(){var e=this.element;j(e,this.classNames.input),e.hidden=!1,e.removeAttribute("tabindex");var t=e.getAttribute("data-choice-orig-style");t?(e.removeAttribute("data-choice-orig-style"),e.setAttribute("style",t)):e.removeAttribute("style"),e.removeAttribute("data-choice")},e.prototype.enable=function(){this.element.removeAttribute("disabled"),this.element.disabled=!1,this.isDisabled=!1},e.prototype.disable=function(){this.element.setAttribute("disabled",""),this.element.disabled=!0,this.isDisabled=!0},e.prototype.triggerEvent=function(e,t){var i;void 0===(i=t||{})&&(i=null),this.element.dispatchEvent(new CustomEvent(e,{detail:i,bubbles:!0,cancelable:!0}))},e}(),G=function(e){function i(){return null!==e&&e.apply(this,arguments)||this}return t(i,e),i}(U),W=function(e,t){return void 0===t&&(t=!0),void 0===e?t:!!e},X=function(e){if("string"==typeof e&&(e=e.split(" ").filter((function(e){return e.length}))),Array.isArray(e)&&e.length)return e},J=function(e,t,i){if(void 0===i&&(i=!0),"string"==typeof e){var n=I(e);return J({value:e,label:i||n===e?e:{escaped:n,raw:e},selected:!0},!1)}var s=e;if("choices"in s){if(!t)throw new TypeError("optGroup is not allowed");var o=s,r=o.choices.map((function(e){return J(e,!1)}));return{id:0,label:T(o.label)||o.value,active:!!r.length,disabled:!!o.disabled,choices:r}}var a=s;return{id:0,group:null,score:0,rank:0,value:a.value,label:a.label||a.value,active:W(a.active),selected:W(a.selected,!1),disabled:W(a.disabled,!1),placeholder:W(a.placeholder,!1),highlighted:!1,labelClass:X(a.labelClass),labelDescription:a.labelDescription,customProperties:a.customProperties}},z=function(e){return"SELECT"===e.tagName},Q=function(e){function i(t){var i=t.template,n=t.extractPlaceholder,s=e.call(this,{element:t.element,classNames:t.classNames})||this;return s.template=i,s.extractPlaceholder=n,s}return t(i,e),Object.defineProperty(i.prototype,"placeholderOption",{get:function(){return this.element.querySelector('option[value=""]')||this.element.querySelector("option[placeholder]")},enumerable:!1,configurable:!0}),i.prototype.addOptions=function(e){var t=this,i=document.createDocumentFragment();e.forEach((function(e){var n=e;if(!n.element){var s=t.template(n);i.appendChild(s),n.element=s}})),this.element.appendChild(i)},i.prototype.optionsAsChoices=function(){var e=this,t=[];return this.element.querySelectorAll(":scope > option, :scope > optgroup").forEach((function(i){!function(e){return"OPTION"===e.tagName}(i)?function(e){return"OPTGROUP"===e.tagName}(i)&&t.push(e._optgroupToChoice(i)):t.push(e._optionToChoice(i))})),t},i.prototype._optionToChoice=function(e){return!e.hasAttribute("value")&&e.hasAttribute("placeholder")&&(e.setAttribute("value",""),e.value=""),{id:0,group:null,score:0,rank:0,value:e.value,label:e.label,element:e,active:!0,selected:this.extractPlaceholder?e.selected:e.hasAttribute("selected"),disabled:e.disabled,highlighted:!1,placeholder:this.extractPlaceholder&&(!e.value||e.hasAttribute("placeholder")),labelClass:void 0!==e.dataset.labelClass?X(e.dataset.labelClass):void 0,labelDescription:void 0!==e.dataset.labelDescription?{trusted:e.dataset.labelDescription}:void 0,customProperties:V(e.dataset.customProperties)}},i.prototype._optgroupToChoice=function(e){var t=this,i=e.querySelectorAll("option"),n=Array.from(i).map((function(e){return t._optionToChoice(e)}));return{id:0,label:e.label||"",element:e,active:!!n.length,disabled:e.disabled,choices:n}},i}(U),Y={items:[],choices:[],silent:!1,renderChoiceLimit:-1,maxItemCount:-1,closeDropdownOnSelect:"auto",singleModeForMultiSelect:!1,addChoices:!1,addItems:!0,addItemFilter:function(e){return!!e&&""!==e},removeItems:!0,removeItemButton:!1,removeItemButtonAlignLeft:!1,editItems:!1,allowHTML:!1,allowHtmlUserInput:!1,duplicateItemsAllowed:!0,delimiter:",",paste:!0,searchEnabled:!0,searchChoices:!0,searchDisabledChoices:!1,searchFloor:1,searchResultLimit:4,searchFields:["label","value"],position:"auto",resetScrollPosition:!0,shouldSort:!0,shouldSortItems:!1,sorter:function(e,t){var i=e.label,n=t.label,s=void 0===n?t.value:n;return T(void 0===i?e.value:i).localeCompare(T(s),[],{sensitivity:"base",ignorePunctuation:!0,numeric:!0})},shadowRoot:null,placeholder:!0,placeholderValue:null,searchPlaceholderValue:null,prependValue:null,appendValue:null,renderSelectedChoices:"auto",searchRenderSelectedChoices:!0,loadingText:"Loading...",noResultsText:"No results found",noChoicesText:"No choices to choose from",itemSelectText:"Press to select",uniqueItemText:"Only unique values can be added",customAddItemText:"Only values matching specific conditions can be added",addItemText:function(e){return'Press Enter to add "'.concat(e,'"')},removeItemIconText:function(){return"Remove item"},removeItemLabelText:function(e,t,i){return"Remove item: ".concat(i?I(i.label):e)},maxItemText:function(e){return"Only ".concat(e," values can be added")},valueComparer:function(e,t){return e===t},fuseOptions:{includeScore:!0},labelId:"",callbackOnInit:null,callbackOnCreateTemplates:null,classNames:{containerOuter:["choices"],containerInner:["choices__inner"],input:["choices__input"],inputCloned:["choices__input--cloned"],list:["choices__list"],listItems:["choices__list--multiple"],listSingle:["choices__list--single"],listDropdown:["choices__list--dropdown"],item:["choices__item"],itemSelectable:["choices__item--selectable"],itemDisabled:["choices__item--disabled"],itemChoice:["choices__item--choice"],description:["choices__description"],placeholder:["choices__placeholder"],group:["choices__group"],groupHeading:["choices__heading"],button:["choices__button"],activeState:["is-active"],focusState:["is-focused"],openState:["is-open"],disabledState:["is-disabled"],highlightedState:["is-highlighted"],selectedState:["is-selected"],flippedState:["is-flipped"],loadingState:["is-loading"],invalidState:["is-invalid"],notice:["choices__notice"],addChoice:["choices__item--selectable","add-choice"],noResults:["has-no-results"],noChoices:["has-no-choices"]},appendGroupInSearch:!1},Z=function(e){var t=e.itemEl;t&&(t.remove(),e.itemEl=void 0)},$={groups:function(e,t){var i=e,n=!0;switch(t.type){case l:i.push(t.group);break;case c:i=[];break;default:n=!1}return{state:i,update:n}},items:function(e,t,i){var n=e,s=!0;switch(t.type){case h:t.item.selected=!0,(r=t.item.element)&&(r.selected=!0,r.setAttribute("selected","")),n.push(t.item);break;case d:var r;if(t.item.selected=!1,r=t.item.element){r.selected=!1,r.removeAttribute("selected");var a=r.parentElement;a&&z(a)&&a.type===_&&(a.value="")}Z(t.item),n=n.filter((function(e){return e.id!==t.item.id}));break;case o:Z(t.choice),n=n.filter((function(e){return e.id!==t.choice.id}));break;case u:var c=t.highlighted,l=n.find((function(e){return e.id===t.item.id}));l&&l.highlighted!==c&&(l.highlighted=c,i&&function(e,t,i){var n=e.itemEl;n&&(j(n,i),K(n,t))}(l,c?i.classNames.highlightedState:i.classNames.selectedState,c?i.classNames.selectedState:i.classNames.highlightedState));break;default:s=!1}return{state:n,update:s}},choices:function(e,t,i){var n=e,l=!0;switch(t.type){case s:n.push(t.choice);break;case o:t.choice.choiceEl=void 0,t.choice.group&&(t.choice.group.choices=t.choice.group.choices.filter((function(e){return e.id!==t.choice.id}))),n=n.filter((function(e){return e.id!==t.choice.id}));break;case h:case d:t.item.choiceEl=void 0;break;case r:var u=[];t.results.forEach((function(e){u[e.item.id]=e})),n.forEach((function(e){var t=u[e.id];void 0!==t?(e.score=t.score,e.rank=t.rank,e.active=!0):(e.score=0,e.rank=0,e.active=!1),i&&i.appendGroupInSearch&&(e.choiceEl=void 0)}));break;case a:n.forEach((function(e){e.active=t.active,i&&i.appendGroupInSearch&&(e.choiceEl=void 0)}));break;case c:n=[];break;default:l=!1}return{state:n,update:l}}},ee=function(){function e(e){this._state=this.defaultState,this._listeners=[],this._txn=0,this._context=e}return Object.defineProperty(e.prototype,"defaultState",{get:function(){return{groups:[],items:[],choices:[]}},enumerable:!1,configurable:!0}),e.prototype.changeSet=function(e){return{groups:e,items:e,choices:e}},e.prototype.reset=function(){this._state=this.defaultState;var e=this.changeSet(!0);this._txn?this._changeSet=e:this._listeners.forEach((function(t){return t(e)}))},e.prototype.subscribe=function(e){return this._listeners.push(e),this},e.prototype.dispatch=function(e){var t=this,i=this._state,n=!1,s=this._changeSet||this.changeSet(!1);Object.keys($).forEach((function(o){var r=$[o](i[o],e,t._context);r.update&&(n=!0,s[o]=!0,i[o]=r.state)})),n&&(this._txn?this._changeSet=s:this._listeners.forEach((function(e){return e(s)})))},e.prototype.withTxn=function(e){this._txn++;try{e()}finally{if(this._txn=Math.max(0,this._txn-1),!this._txn){var t=this._changeSet;t&&(this._changeSet=void 0,this._listeners.forEach((function(e){return e(t)})))}}},Object.defineProperty(e.prototype,"state",{get:function(){return this._state},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"items",{get:function(){return this.state.items},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"highlightedActiveItems",{get:function(){return this.items.filter((function(e){return e.active&&e.highlighted}))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"choices",{get:function(){return this.state.choices},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"activeChoices",{get:function(){return this.choices.filter((function(e){return e.active}))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"searchableChoices",{get:function(){var e=this._context;return this.choices.filter((function(t){return!t.placeholder&&(e.searchDisabledChoices||!t.disabled)}))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"groups",{get:function(){return this.state.groups},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"activeGroups",{get:function(){var e=this;return this.state.groups.filter((function(t){var i=t.active&&!t.disabled,n=e.state.choices.some((function(e){return e.active&&!e.disabled}));return i&&n}),[])},enumerable:!1,configurable:!0}),e.prototype.inTxn=function(){return this._txn>0},e.prototype.getChoiceById=function(e){return this.activeChoices.find((function(t){return t.id===e}))},e.prototype.getGroupById=function(e){return this.groups.find((function(t){return t.id===e}))},e}(),te="no-choices",ie="no-results",ne="add-choice";function se(e,t){if(0===e.length)return 0;for(var i=[0],n=1;n0&&e.charAt(n)!==e.charAt(s);)s=i[s-1];e.charAt(n)===e.charAt(s)&&s++,i.push(s)}var o=0;for(n=0;n0&&t.charAt(n)!==e.charAt(o);)o=i[o-1];if(t.charAt(n)===e.charAt(o)&&++o===e.length)return n-(o-1)}return-1}var oe=function(){function e(e){this._haystack=[],this._fields=e.searchFields}return e.prototype.index=function(e){this._haystack=e},e.prototype.reset=function(){this._haystack=[]},e.prototype.isEmptyIndex=function(){return!this._haystack.length},e.prototype.search=function(e){var t=this._fields;if(!t||!t.length||!e)return[];for(var i=e.toLowerCase(),n=[],s=0,o=0,r=this._haystack.length;o element"),this)},e.prototype.removeChoice=function(e){var t=this._store.choices.find((function(t){return t.value===e}));return t?(this._clearNotice(),this._store.dispatch(function(e){return{type:o,choice:e}}(t)),this._searcher.reset(),t.selected&&this.passedElement.triggerEvent(m,L(t)),this):this},e.prototype.clearChoices=function(e,t){var i=this;return void 0===e&&(e=!0),void 0===t&&(t=!1),e&&(t?this.passedElement.element.replaceChildren(""):this.passedElement.element.querySelectorAll(":not([selected])").forEach((function(e){e.remove()}))),this.itemList.element.replaceChildren(""),this.choiceList.element.replaceChildren(""),this._clearNotice(),this._store.withTxn((function(){var e=t?[]:i._store.items;i._store.reset(),e.forEach((function(e){i._store.dispatch(y(e)),i._store.dispatch(b(e))}))})),this._searcher.reset(),this},e.prototype.clearStore=function(e){return void 0===e&&(e=!0),this.clearChoices(e,!0),this._stopSearch(),this._lastAddedChoiceId=0,this._lastAddedGroupId=0,this},e.prototype.clearInput=function(){return this.input.clear(!this._isSelectOneElement),this._stopSearch(),this},e.prototype._validateConfig=function(){var e,t,i,n=this.config,s=(e=Y,t=Object.keys(n).sort(),i=Object.keys(e).sort(),t.filter((function(e){return i.indexOf(e)<0})));s.length&&console.warn("Unknown config option(s) passed",s.join(", ")),n.allowHTML&&n.allowHtmlUserInput&&(n.addItems&&console.warn("Warning: allowHTML/allowHtmlUserInput/addItems all being true is strongly not recommended and may lead to XSS attacks"),n.addChoices&&console.warn("Warning: allowHTML/allowHtmlUserInput/addChoices all being true is strongly not recommended and may lead to XSS attacks"))},e.prototype._render=function(e){void 0===e&&(e={choices:!0,groups:!0,items:!0}),this._store.inTxn()||(this._isSelectElement&&(e.choices||e.groups)&&this._renderChoices(),e.items&&this._renderItems())},e.prototype._renderChoices=function(){var e=this;if(this._canAddItems()){var t=this.config,i=this._isSearching,n=this._store,s=n.activeGroups,o=n.activeChoices,r=i?t.searchResultLimit:t.renderChoiceLimit;if(this._isSelectElement){var a=o.filter((function(e){return!e.element}));a.length&&this.passedElement.addOptions(a)}var c=document.createDocumentFragment(),l=function(e){return e.filter((function(e){return!e.placeholder&&(i?(t.searchRenderSelectedChoices||!e.selected)&&!!e.rank:t.renderSelectedChoices||!e.selected)}))},h=t.appendGroupInSearch&&i,d=!1,u=null,p=function(n,s){i?n.sort(F):t.shouldSort&&n.sort(t.sorter);var o=n.length;o=!s&&r>0&&o>r?r:o,o--,n.every((function(n,s){var r=n.choiceEl||e._templates.choice(t,n,t.itemSelectText,h&&n.group?n.group.label:void 0);return n.choiceEl=r,c.appendChild(r),i||!n.selected?d=!0:u||(u=r),s1){var l=i.querySelector(M(n.classNames.placeholder));l&&l.remove()}else a||c||!this._placeholderValue||(a=!0,r(J({selected:!0,value:"",label:this._placeholderValue,placeholder:!0},!1)))}a&&(i.append(s),n.shouldSortItems&&!this._isSelectOneElement&&(t.sort(n.sorter),t.forEach((function(e){var t=o(e);t&&(t.remove(),s.append(t))})),i.append(s))),this._isTextElement&&(this.passedElement.value=t.map((function(e){return e.value})).join(n.delimiter))},e.prototype._displayNotice=function(e,t,i){void 0===i&&(i=!0);var n=this._notice;n&&(n.type===t&&n.text===e||n.type===ne&&(t===ie||t===te))?i&&this.showDropdown(!0):(this._clearNotice(),this._notice=e?{text:e,type:t}:void 0,this._renderNotice(),i&&e&&this.showDropdown(!0))},e.prototype._clearNotice=function(){if(this._notice){var e=this.choiceList.element.querySelector(M(this.config.classNames.notice));e&&e.remove(),this._notice=void 0}},e.prototype._renderNotice=function(e){var t=this._notice;if(t){var i=this._templates.notice(this.config,t.text,t.type);e?e.append(i):this.choiceList.prepend(i)}},e.prototype._getChoiceForOutput=function(e,t){return L(e,t)},e.prototype._triggerChange=function(e){null!=e&&this.passedElement.triggerEvent("change",{value:e})},e.prototype._handleButtonAction=function(e){var t=this,i=this._store.items;if(i.length&&this.config.removeItems&&this.config.removeItemButton){var n=e&&de(e.closest("[data-id]")),s=n&&i.find((function(e){return e.id===n}));s&&this._store.withTxn((function(){if(t._removeItem(s),t._triggerChange(s.value),t._isSelectOneElement&&!t._hasNonChoicePlaceholder){var e=(t.config.shouldSort?t._store.choices.reverse():t._store.choices).find((function(e){return e.placeholder}));e&&(t._addItem(e),t.unhighlightAll(),e.value&&t._triggerChange(e.value))}}))}},e.prototype._handleItemAction=function(e,t){var i=this;void 0===t&&(t=!1);var n=this._store.items;if(n.length&&this.config.removeItems&&!this._isSelectOneElement){var s=de(e);s&&(n.forEach((function(e){e.id!==s||e.highlighted?!t&&e.highlighted&&i.unhighlightItem(e):i.highlightItem(e)})),this.input.focus())}},e.prototype._handleChoiceAction=function(e){var t=this,i=de(e),n=i&&this._store.getChoiceById(i);if(!n||n.disabled)return!1;var s=this.dropdown.isActive;if(!n.selected){if(!this._canAddItems())return!0;this._store.withTxn((function(){t._addItem(n,!0,!0),t.clearInput(),t.unhighlightAll()})),this._triggerChange(n.value)}return s&&this.config.closeDropdownOnSelect&&(this.hideDropdown(!0),this.containerOuter.element.focus()),!0},e.prototype._handleBackspace=function(e){var t=this.config;if(t.removeItems&&e.length){var i=e[e.length-1],n=e.some((function(e){return e.highlighted}));t.editItems&&!n&&i?(this.input.value=i.value,this.input.setWidth(),this._removeItem(i),this._triggerChange(i.value)):(n||this.highlightItem(i,!1),this.removeHighlightedItems(!0))}},e.prototype._loadChoices=function(){var e,t=this,i=this.config;if(this._isTextElement){if(this._presetChoices=i.items.map((function(e){return J(e,!1)})),this.passedElement.value){var n=this.passedElement.value.split(i.delimiter).map((function(e){return J(e,!1,t.config.allowHtmlUserInput)}));this._presetChoices=this._presetChoices.concat(n)}this._presetChoices.forEach((function(e){e.selected=!0}))}else if(this._isSelectElement){this._presetChoices=i.choices.map((function(e){return J(e,!0)}));var s=this.passedElement.optionsAsChoices();s&&(e=this._presetChoices).push.apply(e,s)}},e.prototype._handleLoadingState=function(e){void 0===e&&(e=!0);var t=this.itemList.element;e?(this.disable(),this.containerOuter.addLoadingState(),this._isSelectOneElement?t.replaceChildren(this._templates.placeholder(this.config,this.config.loadingText)):this.input.placeholder=this.config.loadingText):(this.enable(),this.containerOuter.removeLoadingState(),this._isSelectOneElement?(t.replaceChildren(""),this._render()):this.input.placeholder=this._placeholderValue||"")},e.prototype._handleSearch=function(e){if(this.input.isFocussed)if(null!=e&&e.length>=this.config.searchFloor){var t=this.config.searchChoices?this._searchChoices(e):0;null!==t&&this.passedElement.triggerEvent(p,{value:e,resultCount:t})}else this._store.choices.some((function(e){return!e.active}))&&this._stopSearch()},e.prototype._canAddItems=function(){var e=this.config,t=e.maxItemCount,i=e.maxItemText;return!e.singleModeForMultiSelect&&t>0&&t<=this._store.items.length?(this.choiceList.element.replaceChildren(""),this._notice=void 0,this._displayNotice("function"==typeof i?i(t):i,ne),!1):(this._notice&&this._notice.type===ne&&this._clearNotice(),!0)},e.prototype._canCreateItem=function(e){var t=this.config,i=!0,n="";if(i&&"function"==typeof t.addItemFilter&&!t.addItemFilter(e)&&(i=!1,n=D(t.customAddItemText,e,void 0)),i&&this._store.choices.find((function(i){return t.valueComparer(i.value,e)}))){if(this._isSelectElement)return this._displayNotice("",ne),!1;t.duplicateItemsAllowed||(i=!1,n=D(t.uniqueItemText,e,void 0))}return i&&(n=D(t.addItemText,e,void 0)),n&&this._displayNotice(n,ne),i},e.prototype._searchChoices=function(e){var t=e.trim().replace(/\s{2,}/," ");if(!t.length||t===this._currentValue)return null;var i=this._searcher;i.isEmptyIndex()&&i.index(this._store.searchableChoices);var n=i.search(t);this._currentValue=t,this._highlightPosition=0,this._isSearching=!0;var s=this._notice;return(s&&s.type)!==ne&&(n.length?this._clearNotice():this._displayNotice(O(this.config.noResultsText),ie)),this._store.dispatch(function(e){return{type:r,results:e}}(n)),n.length},e.prototype._stopSearch=function(){this._isSearching&&(this._currentValue="",this._isSearching=!1,this._clearNotice(),this._store.dispatch({type:a,active:!0}),this.passedElement.triggerEvent(p,{value:"",resultCount:0}))},e.prototype._addEventListeners=function(){var e=this._docRoot,t=this.containerOuter.element,i=this.input.element,n=this.passedElement.element;e.addEventListener("touchend",this._onTouchEnd,!0),t.addEventListener("keydown",this._onKeyDown,!0),t.addEventListener("mousedown",this._onMouseDown,!0),e.addEventListener("click",this._onClick,{passive:!0}),e.addEventListener("touchmove",this._onTouchMove,{passive:!0}),this.dropdown.element.addEventListener("mouseover",this._onMouseOver,{passive:!0}),this._isSelectOneElement&&(t.addEventListener("focus",this._onFocus,{passive:!0}),t.addEventListener("blur",this._onBlur,{passive:!0})),i.addEventListener("keyup",this._onKeyUp,{passive:!0}),i.addEventListener("input",this._onInput,{passive:!0}),i.addEventListener("focus",this._onFocus,{passive:!0}),i.addEventListener("blur",this._onBlur,{passive:!0}),i.form&&i.form.addEventListener("reset",this._onFormReset,{passive:!0}),n.hasAttribute("required")&&(n.addEventListener("change",this._onChange,{passive:!0}),n.addEventListener("invalid",this._onInvalid,{passive:!0})),this.input.addEventListeners()},e.prototype._removeEventListeners=function(){var e=this._docRoot,t=this.containerOuter.element,i=this.input.element,n=this.passedElement.element;e.removeEventListener("touchend",this._onTouchEnd,!0),t.removeEventListener("keydown",this._onKeyDown,!0),t.removeEventListener("mousedown",this._onMouseDown,!0),e.removeEventListener("click",this._onClick),e.removeEventListener("touchmove",this._onTouchMove),this.dropdown.element.removeEventListener("mouseover",this._onMouseOver),this._isSelectOneElement&&(t.removeEventListener("focus",this._onFocus),t.removeEventListener("blur",this._onBlur)),i.removeEventListener("keyup",this._onKeyUp),i.removeEventListener("input",this._onInput),i.removeEventListener("focus",this._onFocus),i.removeEventListener("blur",this._onBlur),i.form&&i.form.removeEventListener("reset",this._onFormReset),n.hasAttribute("required")&&(n.removeEventListener("change",this._onChange),n.removeEventListener("invalid",this._onInvalid)),this.input.removeEventListeners()},e.prototype._onKeyDown=function(e){var t=e.keyCode,i=this.dropdown.isActive,n=1===e.key.length||2===e.key.length&&e.key.charCodeAt(0)>=55296||"Unidentified"===e.key;switch(this._isTextElement||i||27===t||9===t||16===t||(this.showDropdown(),!this.input.isFocussed&&n&&(this.input.value+=e.key," "===e.key&&e.preventDefault())),t){case 65:return this._onSelectKey(e,this.itemList.element.hasChildNodes());case 13:return this._onEnterKey(e,i);case 27:return this._onEscapeKey(e,i);case 38:case 33:case 40:case 34:return this._onDirectionKey(e,i);case 8:case 46:return this._onDeleteKey(e,this._store.items,this.input.isFocussed)}},e.prototype._onKeyUp=function(){this._canSearch=this.config.searchEnabled},e.prototype._onInput=function(){var e=this.input.value;e?this._canAddItems()&&(this._canSearch&&this._handleSearch(e),this._canAddUserChoices&&(this._canCreateItem(e),this._isSelectElement&&(this._highlightPosition=0,this._highlightChoice()))):this._isTextElement?this.hideDropdown(!0):this._stopSearch()},e.prototype._onSelectKey=function(e,t){(e.ctrlKey||e.metaKey)&&t&&(this._canSearch=!1,this.config.removeItems&&!this.input.value&&this.input.element===document.activeElement&&this.highlightAll())},e.prototype._onEnterKey=function(e,t){var i=this,n=this.input.value,s=e.target;if(e.preventDefault(),s&&s.hasAttribute("data-button"))this._handleButtonAction(s);else if(t){var o=this.dropdown.element.querySelector(M(this.config.classNames.highlightedState));if(!o||!this._handleChoiceAction(o))if(s&&n){if(this._canAddItems()){var r=!1;this._store.withTxn((function(){if(!(r=i._findAndSelectChoiceByValue(n,!0))){if(!i._canAddUserChoices)return;if(!i._canCreateItem(n))return;i._addChoice(J(n,!1,i.config.allowHtmlUserInput),!0,!0),r=!0}i.clearInput(),i.unhighlightAll()})),r&&(this._triggerChange(n),this.config.closeDropdownOnSelect&&this.hideDropdown(!0))}}else this.hideDropdown(!0)}else(this._isSelectElement||this._notice)&&this.showDropdown()},e.prototype._onEscapeKey=function(e,t){t&&(e.stopPropagation(),this.hideDropdown(!0),this._stopSearch(),this.containerOuter.element.focus())},e.prototype._onDirectionKey=function(e,t){var i=e.keyCode;if(t||this._isSelectOneElement){this.showDropdown(),this._canSearch=!1;var n=40===i||34===i?1:-1,s=void 0;if(e.metaKey||34===i||33===i)s=this.dropdown.element.querySelector(n>0?"".concat(ue,":last-of-type"):ue);else{var o=this.dropdown.element.querySelector(M(this.config.classNames.highlightedState));s=o?function(e,t,i){void 0===i&&(i=1);for(var n="".concat(i>0?"next":"previous","ElementSibling"),s=e[n];s;){if(s.matches(t))return s;s=s[n]}return null}(o,ue,n):this.dropdown.element.querySelector(ue)}s&&(w(s,this.choiceList.element,n)||this.choiceList.scrollToChildElement(s,n),this._highlightChoice(s)),e.preventDefault()}},e.prototype._onDeleteKey=function(e,t,i){this._isSelectOneElement||e.target.value||!i||(this._handleBackspace(t),e.preventDefault())},e.prototype._onTouchMove=function(){this._wasTap&&(this._wasTap=!1)},e.prototype._onTouchEnd=function(e){var t=(e||e.touches[0]).target;this._wasTap&&this.containerOuter.element.contains(t)&&((t===this.containerOuter.element||t===this.containerInner.element)&&(this._isTextElement?this.input.focus():this._isSelectMultipleElement&&this.showDropdown()),e.stopPropagation()),this._wasTap=!0},e.prototype._onMouseDown=function(e){var t=e.target;if(t instanceof Element){if(le&&this.choiceList.element.contains(t)){var i=this.choiceList.element.firstElementChild;this._isScrollingOnIe="ltr"===this._direction?e.offsetX>=i.offsetWidth:e.offsetXthis._highlightPosition?t[this._highlightPosition]:t[t.length-1])||(i=t[0]),K(i,n),i.setAttribute("aria-selected","true"),this.passedElement.triggerEvent("highlightChoice",{el:i}),this.dropdown.isActive&&(this.input.setActiveDescendant(i.id),this.containerOuter.setActiveDescendant(i.id))}},e.prototype._addItem=function(e,t,i){if(void 0===t&&(t=!0),void 0===i&&(i=!1),!e.id)throw new TypeError("item.id must be set before _addItem is called for a choice/item");if((this.config.singleModeForMultiSelect||this._isSelectOneElement)&&this.removeActiveItems(e.id),this._store.dispatch(b(e)),t){var n=L(e);this.passedElement.triggerEvent("addItem",n),i&&this.passedElement.triggerEvent("choice",n)}},e.prototype._removeItem=function(e){if(e.id){this._store.dispatch(E(e));var t=this._notice;t&&t.type===te&&this._clearNotice(),this.passedElement.triggerEvent(m,L(e))}},e.prototype._addChoice=function(e,t,i){if(void 0===t&&(t=!0),void 0===i&&(i=!1),e.id)throw new TypeError("Can not re-add a choice which has already been added");var n=this.config;if(n.duplicateItemsAllowed||!this._store.choices.find((function(t){return n.valueComparer(t.value,e.value)}))){this._lastAddedChoiceId++,e.id=this._lastAddedChoiceId,e.elementId="".concat(this._baseId,"-").concat(this._idNames.itemChoice,"-").concat(e.id);var s=n.prependValue,o=n.appendValue;s&&(e.value=s+e.value),o&&(e.value+=o.toString()),(s||o)&&e.element&&(e.element.value=e.value),this._clearNotice(),this._store.dispatch(y(e)),e.selected&&this._addItem(e,t,i)}},e.prototype._addGroup=function(e,t){var i=this;if(void 0===t&&(t=!0),e.id)throw new TypeError("Can not re-add a group which has already been added");this._store.dispatch(function(e){return{type:l,group:e}}(e)),e.choices&&(this._lastAddedGroupId++,e.id=this._lastAddedGroupId,e.choices.forEach((function(n){n.group=e,e.disabled&&(n.disabled=!0),i._addChoice(n,t)})))},e.prototype._createTemplates=function(){var e=this,t=this.config.callbackOnCreateTemplates,i={};"function"==typeof t&&(i=t.call(this,A,N,k));var n={};Object.keys(this._templates).forEach((function(t){n[t]=t in i?i[t].bind(e):e._templates[t].bind(e)})),this._templates=n},e.prototype._createElements=function(){var e=this._templates,t=this.config,i=this._isSelectOneElement,n=t.position,s=t.classNames,o=this._elementType;this.containerOuter=new H({element:e.containerOuter(t,this._direction,this._isSelectElement,i,t.searchEnabled,o,t.labelId),classNames:s,type:o,position:n}),this.containerInner=new H({element:e.containerInner(t),classNames:s,type:o,position:n}),this.input=new R({element:e.input(t,this._placeholderValue),classNames:s,type:o,preventPaste:!t.paste}),this.choiceList=new q({element:e.choiceList(t,i)}),this.itemList=new q({element:e.itemList(t,i)}),this.dropdown=new B({element:e.dropdown(t),classNames:s,type:o})},e.prototype._createStructure=function(){var e=this,t=e.containerInner,i=e.containerOuter,n=e.passedElement,s=this.dropdown.element;n.conceal(),t.wrap(n.element),i.wrap(t.element),i.element.appendChild(t.element),i.element.appendChild(s),t.element.appendChild(this.itemList.element),s.appendChild(this.choiceList.element),this._isSelectOneElement?(this.input.placeholder=this.config.searchPlaceholderValue||"",this.config.searchEnabled&&s.insertBefore(this.input.element,s.firstChild)):(this._isSelectMultipleElement&&!this.config.searchEnabled||t.element.appendChild(this.input.element),this._placeholderValue&&(this.input.placeholder=this._placeholderValue),this.input.setWidth()),this._highlightPosition=0,this._isSearching=!1},e.prototype._initStore=function(){var e=this;this._store.subscribe(this._render).withTxn((function(){e._addPredefinedChoices(e._presetChoices,e._isSelectOneElement&&!e._hasNonChoicePlaceholder,!1)})),(!this._store.choices.length||this._isSelectOneElement&&this._hasNonChoicePlaceholder)&&this._render()},e.prototype._addPredefinedChoices=function(e,t,i){var n=this;void 0===t&&(t=!1),void 0===i&&(i=!0),t&&-1===e.findIndex((function(e){return e.selected}))&&e.some((function(e){return!e.disabled&&!("choices"in e)&&(e.selected=!0,!0)})),e.forEach((function(e){"choices"in e?n._isSelectElement&&n._addGroup(e,i):n._addChoice(e,i)}))},e.prototype._findAndSelectChoiceByValue=function(e,t){var i=this;void 0===t&&(t=!1);var n=this._store.choices.find((function(t){return i.config.valueComparer(t.value,e)}));return!(!n||n.disabled||n.selected||(this._addItem(n,!0,t),0))},e.prototype._generatePlaceholderValue=function(){var e=this.config;if(!e.placeholder)return null;if(this._hasNonChoicePlaceholder)return e.placeholderValue;if(this._isSelectElement){var t=this.passedElement.placeholderOption;return t?t.text:null}return null},e.prototype._warnChoicesInitFailed=function(e){if(!this.config.silent){if(!this.initialised)throw new TypeError("".concat(e," called on a non-initialised instance of Choices"));if(!this.initialisedOK)throw new TypeError("".concat(e," called for an element which has multiple instances of Choices initialised on it"))}},e.version="11.2.0",e}()})); diff --git a/assets/scripts/choices.search-kmp.mjs b/assets/scripts/choices.search-kmp.mjs index c9792147..63092d7b 100644 --- a/assets/scripts/choices.search-kmp.mjs +++ b/assets/scripts/choices.search-kmp.mjs @@ -1,4 +1,4 @@ -/*! choices.js v11.1.0 | © 2025 Josh Johnson | https://github.com/jshjohnson/Choices#readme */ +/*! choices.js v11.2.0 | © 2026 Josh Johnson | https://github.com/jshjohnson/Choices#readme */ /****************************************************************************** Copyright (c) Microsoft Corporation. @@ -202,9 +202,6 @@ var strToEl = (function () { return firstChild; }; })(); -var resolveNoticeFunction = function (fn, value) { - return typeof fn === 'function' ? fn(sanitise(value), value) : fn; -}; var resolveStringFunction = function (fn) { return typeof fn === 'function' ? fn() : fn; }; @@ -236,6 +233,26 @@ var unwrapStringForEscaped = function (s) { } return ''; }; +var getChoiceForOutput = function (choice, keyCode) { + return { + id: choice.id, + highlighted: choice.highlighted, + labelClass: choice.labelClass, + labelDescription: unwrapStringForRaw(choice.labelDescription), + customProperties: choice.customProperties, + disabled: choice.disabled, + active: choice.active, + label: choice.label, + placeholder: choice.placeholder, + value: choice.value, + groupValue: choice.group ? choice.group.label : undefined, + element: choice.element, + keyCode: keyCode, + }; +}; +var resolveNoticeFunction = function (fn, value, item) { + return typeof fn === 'function' ? fn(sanitise(value), unwrapStringForRaw(value), item) : fn; +}; var escapeForTemplate = function (allowHTML, s) { return allowHTML ? unwrapStringForEscaped(s) : sanitise(s); }; @@ -403,6 +420,12 @@ var Container = /** @class */ (function () { Container.prototype.removeFocusState = function () { removeClassesFromElement(this.element, this.classNames.focusState); }; + Container.prototype.addInvalidState = function () { + addClassesToElement(this.element, this.classNames.invalidState); + }; + Container.prototype.removeInvalidState = function () { + removeClassesFromElement(this.element, this.classNames.invalidState); + }; Container.prototype.enable = function () { removeClassesFromElement(this.element, this.classNames.disabledState); this.element.removeAttribute('aria-disabled'); @@ -868,7 +891,9 @@ var WrappedSelect = /** @class */ (function (_super) { highlighted: false, placeholder: this.extractPlaceholder && (!option.value || option.hasAttribute('placeholder')), labelClass: typeof option.dataset.labelClass !== 'undefined' ? stringToHtmlClass(option.dataset.labelClass) : undefined, - labelDescription: typeof option.dataset.labelDescription !== 'undefined' ? option.dataset.labelDescription : undefined, + labelDescription: typeof option.dataset.labelDescription !== 'undefined' + ? { trusted: option.dataset.labelDescription } + : undefined, customProperties: parseCustomProperties(option.dataset.customProperties), }; }; @@ -914,6 +939,7 @@ var DEFAULT_CLASSNAMES = { selectedState: ['is-selected'], flippedState: ['is-flipped'], loadingState: ['is-loading'], + invalidState: ['is-invalid'], notice: ['choices__notice'], addChoice: ['choices__item--selectable', 'add-choice'], noResults: ['has-no-results'], @@ -941,6 +967,7 @@ var DEFAULT_CONFIG = { paste: true, searchEnabled: true, searchChoices: true, + searchDisabledChoices: false, searchFloor: 1, searchResultLimit: 4, searchFields: ['label', 'value'], @@ -956,6 +983,7 @@ var DEFAULT_CONFIG = { prependValue: null, appendValue: null, renderSelectedChoices: 'auto', + searchRenderSelectedChoices: true, loadingText: 'Loading...', noResultsText: 'No results found', noChoicesText: 'No choices to choose from', @@ -964,7 +992,9 @@ var DEFAULT_CONFIG = { customAddItemText: 'Only values matching specific conditions can be added', addItemText: function (value) { return "Press Enter to add \"".concat(value, "\""); }, removeItemIconText: function () { return "Remove item"; }, - removeItemLabelText: function (value) { return "Remove item: ".concat(value); }, + removeItemLabelText: function (value, _valueRaw, i) { + return "Remove item: ".concat(i ? sanitise(i.label) : value); + }, maxItemText: function (maxItemCount) { return "Only ".concat(maxItemCount, " values can be added"); }, valueComparer: function (value1, value2) { return value1 === value2; }, fuseOptions: { @@ -1265,7 +1295,8 @@ var Store = /** @class */ (function () { * Get choices that can be searched (excluding placeholders or disabled choices) */ get: function () { - return this.choices.filter(function (choice) { return !choice.disabled && !choice.placeholder; }); + var context = this._context; + return this.choices.filter(function (choice) { return !choice.placeholder && (context.searchDisabledChoices || !choice.disabled); }); }, enumerable: false, configurable: true @@ -1379,11 +1410,12 @@ var SearchByKMP = /** @class */ (function () { var field = this._fields[k]; if (field in obj && kmpSearch(needle, obj[field].toLowerCase()) !== -1) { results.push({ - item: obj[field], + item: obj, score: count, rank: count + 1, }); count++; + break; } } } @@ -1419,7 +1451,7 @@ var assignCustomProperties = function (el, choice, withCustomProperties) { dataset.labelClass = getClassNames(labelClass).join(' '); } if (labelDescription) { - dataset.labelDescription = labelDescription; + dataset.labelDescription = unwrapStringForRaw(labelDescription); } if (withCustomProperties && customProperties) { if (typeof customProperties === 'string') { @@ -1526,8 +1558,9 @@ var templates = { var removeButton = document.createElement('button'); removeButton.type = 'button'; addClassesToElement(removeButton, button); - setElementHtml(removeButton, true, resolveNoticeFunction(removeItemIconText, choice.value)); - var REMOVE_ITEM_LABEL = resolveNoticeFunction(removeItemLabelText, choice.value); + var eventChoice = getChoiceForOutput(choice); + setElementHtml(removeButton, true, resolveNoticeFunction(removeItemIconText, choice.value, eventChoice)); + var REMOVE_ITEM_LABEL = resolveNoticeFunction(removeItemLabelText, choice.value, eventChoice); if (REMOVE_ITEM_LABEL) { removeButton.setAttribute('aria-label', REMOVE_ITEM_LABEL); } @@ -1632,6 +1665,7 @@ var templates = { else { addClassesToElement(div, itemSelectable); div.dataset.choiceSelectable = ''; + div.setAttribute('aria-selected', choice.selected ? 'true' : 'false'); } return div; }, @@ -1801,7 +1835,7 @@ var Choices = /** @class */ (function () { this.initialised = false; this._store = new Store(config); this._currentValue = ''; - config.searchEnabled = (!isText && config.searchEnabled) || isSelectMultiple; + config.searchEnabled = !isText && config.searchEnabled; this._canSearch = config.searchEnabled; this._isScrollingOnIe = false; this._highlightPosition = 0; @@ -1841,6 +1875,8 @@ var Choices = /** @class */ (function () { this._onEscapeKey = this._onEscapeKey.bind(this); this._onDirectionKey = this._onDirectionKey.bind(this); this._onDeleteKey = this._onDeleteKey.bind(this); + this._onChange = this._onChange.bind(this); + this._onInvalid = this._onInvalid.bind(this); // If element has already been initialised with Choices, fail silently if (this.passedElement.isActive) { if (!config.silent) { @@ -1947,7 +1983,7 @@ var Choices = /** @class */ (function () { } this._store.dispatch(highlightItem(choice, true)); if (runEvent) { - this.passedElement.triggerEvent(EventType.highlightItem, this._getChoiceForOutput(choice)); + this.passedElement.triggerEvent(EventType.highlightItem, getChoiceForOutput(choice)); } return this; }; @@ -1962,7 +1998,7 @@ var Choices = /** @class */ (function () { } this._store.dispatch(highlightItem(choice, false)); if (runEvent) { - this.passedElement.triggerEvent(EventType.unhighlightItem, this._getChoiceForOutput(choice)); + this.passedElement.triggerEvent(EventType.unhighlightItem, getChoiceForOutput(choice)); } return this; }; @@ -1972,7 +2008,7 @@ var Choices = /** @class */ (function () { _this._store.items.forEach(function (item) { if (!item.highlighted) { _this._store.dispatch(highlightItem(item, true)); - _this.passedElement.triggerEvent(EventType.highlightItem, _this._getChoiceForOutput(item)); + _this.passedElement.triggerEvent(EventType.highlightItem, getChoiceForOutput(item)); } }); }); @@ -1984,7 +2020,7 @@ var Choices = /** @class */ (function () { _this._store.items.forEach(function (item) { if (item.highlighted) { _this._store.dispatch(highlightItem(item, false)); - _this.passedElement.triggerEvent(EventType.highlightItem, _this._getChoiceForOutput(item)); + _this.passedElement.triggerEvent(EventType.highlightItem, getChoiceForOutput(item)); } }); }); @@ -2039,6 +2075,11 @@ var Choices = /** @class */ (function () { _this.input.focus(); } _this.passedElement.triggerEvent(EventType.showDropdown); + var activeElement = _this.choiceList.element.querySelector(getClassNamesSelector(_this.config.classNames.selectedState)); + if (activeElement !== null && !isScrolledIntoView(activeElement, _this.choiceList.element)) { + // We use the native scrollIntoView function instead of choiceList.scrollToChildElement to avoid animated scroll. + activeElement.scrollIntoView(); + } }); return this; }; @@ -2047,6 +2088,7 @@ var Choices = /** @class */ (function () { if (!this.dropdown.isActive) { return this; } + this._removeHighlightedChoices(); requestAnimationFrame(function () { _this.dropdown.hide(); _this.containerOuter.close(); @@ -2059,9 +2101,8 @@ var Choices = /** @class */ (function () { return this; }; Choices.prototype.getValue = function (valueOnly) { - var _this = this; var values = this._store.items.map(function (item) { - return (valueOnly ? item.value : _this._getChoiceForOutput(item)); + return (valueOnly ? item.value : getChoiceForOutput(item)); }); return this._isSelectOneElement || this.config.singleModeForMultiSelect ? values[0] : values; }; @@ -2319,7 +2360,7 @@ var Choices = /** @class */ (function () { // @todo integrate with Store this._searcher.reset(); if (choice.selected) { - this.passedElement.triggerEvent(EventType.removeItem, this._getChoiceForOutput(choice)); + this.passedElement.triggerEvent(EventType.removeItem, getChoiceForOutput(choice)); } return this; }; @@ -2402,13 +2443,7 @@ var Choices = /** @class */ (function () { } var _a = this, config = _a.config, isSearching = _a._isSearching; var _b = this._store, activeGroups = _b.activeGroups, activeChoices = _b.activeChoices; - var renderLimit = 0; - if (isSearching && config.searchResultLimit > 0) { - renderLimit = config.searchResultLimit; - } - else if (config.renderChoiceLimit > 0) { - renderLimit = config.renderChoiceLimit; - } + var renderLimit = isSearching ? config.searchResultLimit : config.renderChoiceLimit; if (this._isSelectElement) { var backingOptions = activeChoices.filter(function (choice) { return !choice.element; }); if (backingOptions.length) { @@ -2418,11 +2453,16 @@ var Choices = /** @class */ (function () { var fragment = document.createDocumentFragment(); var renderableChoices = function (choices) { return choices.filter(function (choice) { - return !choice.placeholder && (isSearching ? !!choice.rank : config.renderSelectedChoices || !choice.selected); + return !choice.placeholder && + (isSearching + ? (config.searchRenderSelectedChoices || !choice.selected) && !!choice.rank + : config.renderSelectedChoices || !choice.selected); }); }; + var showLabel = config.appendGroupInSearch && isSearching; var selectableChoices = false; - var renderChoices = function (choices, withinGroup, groupLabel) { + var highlightedEl = null; + var renderChoices = function (choices, withinGroup) { if (isSearching) { // sortByRank is used to ensure stable sorting, as scores are non-unique // this additionally ensures fuseOptions.sortFn is not ignored @@ -2432,16 +2472,20 @@ var Choices = /** @class */ (function () { choices.sort(config.sorter); } var choiceLimit = choices.length; - choiceLimit = !withinGroup && renderLimit && choiceLimit > renderLimit ? renderLimit : choiceLimit; + choiceLimit = !withinGroup && renderLimit > 0 && choiceLimit > renderLimit ? renderLimit : choiceLimit; choiceLimit--; choices.every(function (choice, index) { // choiceEl being empty signals the contents has probably significantly changed - var dropdownItem = choice.choiceEl || _this._templates.choice(config, choice, config.itemSelectText, groupLabel); + var dropdownItem = choice.choiceEl || + _this._templates.choice(config, choice, config.itemSelectText, showLabel && choice.group ? choice.group.label : undefined); choice.choiceEl = dropdownItem; fragment.appendChild(dropdownItem); if (isSearching || !choice.selected) { selectableChoices = true; } + else if (!highlightedEl) { + highlightedEl = dropdownItem; + } return index < choiceLimit; }); }; @@ -2451,7 +2495,7 @@ var Choices = /** @class */ (function () { } if (!this._hasNonChoicePlaceholder && !isSearching && this._isSelectOneElement) { // If we have a placeholder choice along with groups - renderChoices(activeChoices.filter(function (choice) { return choice.placeholder && !choice.group; }), false, undefined); + renderChoices(activeChoices.filter(function (choice) { return choice.placeholder && !choice.group; }), false); } // If we have grouped options if (activeGroups.length && !isSearching) { @@ -2460,7 +2504,7 @@ var Choices = /** @class */ (function () { } // render Choices without group first, regardless of sort, otherwise they won't be distinguishable // from the last group - renderChoices(activeChoices.filter(function (choice) { return !choice.placeholder && !choice.group; }), false, undefined); + renderChoices(activeChoices.filter(function (choice) { return !choice.placeholder && !choice.group; }), false); activeGroups.forEach(function (group) { var groupChoices = renderableChoices(group.choices); if (groupChoices.length) { @@ -2470,12 +2514,12 @@ var Choices = /** @class */ (function () { dropdownGroup.remove(); fragment.appendChild(dropdownGroup); } - renderChoices(groupChoices, true, config.appendGroupInSearch && isSearching ? group.label : undefined); + renderChoices(groupChoices, true); } }); } else { - renderChoices(renderableChoices(activeChoices), false, undefined); + renderChoices(renderableChoices(activeChoices), false); } } if (!selectableChoices && (isSearching || !fragment.children.length || !config.renderSelectedChoices)) { @@ -2489,9 +2533,7 @@ var Choices = /** @class */ (function () { } this._renderNotice(fragment); this.choiceList.element.replaceChildren(fragment); - if (selectableChoices) { - this._highlightChoice(); - } + this._highlightChoice(highlightedEl); }; Choices.prototype._renderItems = function () { var _this = this; @@ -2601,23 +2643,12 @@ var Choices = /** @class */ (function () { } } }; + /** + * @deprecated Use utils.getChoiceForOutput + */ // eslint-disable-next-line class-methods-use-this Choices.prototype._getChoiceForOutput = function (choice, keyCode) { - return { - id: choice.id, - highlighted: choice.highlighted, - labelClass: choice.labelClass, - labelDescription: choice.labelDescription, - customProperties: choice.customProperties, - disabled: choice.disabled, - active: choice.active, - label: choice.label, - placeholder: choice.placeholder, - value: choice.value, - groupValue: choice.group ? choice.group.label : undefined, - element: choice.element, - keyCode: keyCode, - }; + return getChoiceForOutput(choice, keyCode); }; Choices.prototype._triggerChange = function (value) { if (value === undefined || value === null) { @@ -2633,7 +2664,7 @@ var Choices = /** @class */ (function () { if (!items.length || !this.config.removeItems || !this.config.removeItemButton) { return; } - var id = element && parseDataSetId(element.parentElement); + var id = element && parseDataSetId(element.closest('[data-id]')); var itemToRemove = id && items.find(function (item) { return item.id === id; }); if (!itemToRemove) { return; @@ -2822,7 +2853,7 @@ var Choices = /** @class */ (function () { var notice = ''; if (canAddItem && typeof config.addItemFilter === 'function' && !config.addItemFilter(value)) { canAddItem = false; - notice = resolveNoticeFunction(config.customAddItemText, value); + notice = resolveNoticeFunction(config.customAddItemText, value, undefined); } if (canAddItem) { var foundChoice = this._store.choices.find(function (choice) { return config.valueComparer(choice.value, value); }); @@ -2834,12 +2865,12 @@ var Choices = /** @class */ (function () { } if (!config.duplicateItemsAllowed) { canAddItem = false; - notice = resolveNoticeFunction(config.uniqueItemText, value); + notice = resolveNoticeFunction(config.uniqueItemText, value, undefined); } } } if (canAddItem) { - notice = resolveNoticeFunction(config.addItemText, value); + notice = resolveNoticeFunction(config.addItemText, value, undefined); } if (notice) { this._displayNotice(notice, NoticeTypes.addChoice); @@ -2890,6 +2921,7 @@ var Choices = /** @class */ (function () { var documentElement = this._docRoot; var outerElement = this.containerOuter.element; var inputElement = this.input.element; + var passedElement = this.passedElement.element; // capture events - can cancel event processing or propagation documentElement.addEventListener('touchend', this._onTouchEnd, true); outerElement.addEventListener('keydown', this._onKeyDown, true); @@ -2927,12 +2959,21 @@ var Choices = /** @class */ (function () { passive: true, }); } + if (passedElement.hasAttribute('required')) { + passedElement.addEventListener('change', this._onChange, { + passive: true, + }); + passedElement.addEventListener('invalid', this._onInvalid, { + passive: true, + }); + } this.input.addEventListeners(); }; Choices.prototype._removeEventListeners = function () { var documentElement = this._docRoot; var outerElement = this.containerOuter.element; var inputElement = this.input.element; + var passedElement = this.passedElement.element; documentElement.removeEventListener('touchend', this._onTouchEnd, true); outerElement.removeEventListener('keydown', this._onKeyDown, true); outerElement.removeEventListener('mousedown', this._onMouseDown, true); @@ -2950,6 +2991,10 @@ var Choices = /** @class */ (function () { if (inputElement.form) { inputElement.form.removeEventListener('reset', this._onFormReset); } + if (passedElement.hasAttribute('required')) { + passedElement.removeEventListener('change', this._onChange); + passedElement.removeEventListener('invalid', this._onInvalid); + } this.input.removeEventListeners(); }; Choices.prototype._onKeyDown = function (event) { @@ -3199,7 +3244,7 @@ var Choices = /** @class */ (function () { */ Choices.prototype._onMouseDown = function (event) { var target = event.target; - if (!(target instanceof HTMLElement)) { + if (!(target instanceof Element)) { return; } // If we have our mouse down on the scrollbar and are on IE11... @@ -3308,7 +3353,7 @@ var Choices = /** @class */ (function () { // Remove the focus state when the past outerContainer was the target containerOuter.removeFocusState(); // Also close the dropdown if search is disabled - if (!this._canSearch) { + if (!this.config.searchEnabled) { this.hideDropdown(true); } } @@ -3332,6 +3377,27 @@ var Choices = /** @class */ (function () { } }); }; + Choices.prototype._onChange = function (event) { + if (!event.target.checkValidity()) { + return; + } + this.containerOuter.removeInvalidState(); + }; + Choices.prototype._onInvalid = function () { + this.containerOuter.addInvalidState(); + }; + /** + * Removes any highlighted choice options + */ + Choices.prototype._removeHighlightedChoices = function () { + var highlightedState = this.config.classNames.highlightedState; + var highlightedChoices = Array.from(this.dropdown.element.querySelectorAll(getClassNamesSelector(highlightedState))); + // Remove any highlighted choices + highlightedChoices.forEach(function (choice) { + removeClassesFromElement(choice, highlightedState); + choice.setAttribute('aria-selected', 'false'); + }); + }; Choices.prototype._highlightChoice = function (el) { if (el === void 0) { el = null; } var choices = Array.from(this.dropdown.element.querySelectorAll(selectableChoiceIdentifier)); @@ -3340,12 +3406,7 @@ var Choices = /** @class */ (function () { } var passedEl = el; var highlightedState = this.config.classNames.highlightedState; - var highlightedChoices = Array.from(this.dropdown.element.querySelectorAll(getClassNamesSelector(highlightedState))); - // Remove any highlighted choices - highlightedChoices.forEach(function (choice) { - removeClassesFromElement(choice, highlightedState); - choice.setAttribute('aria-selected', 'false'); - }); + this._removeHighlightedChoices(); if (passedEl) { this._highlightPosition = choices.indexOf(passedEl); } @@ -3386,9 +3447,10 @@ var Choices = /** @class */ (function () { } this._store.dispatch(addItem(item)); if (withEvents) { - this.passedElement.triggerEvent(EventType.addItem, this._getChoiceForOutput(item)); + var eventChoice = getChoiceForOutput(item); + this.passedElement.triggerEvent(EventType.addItem, eventChoice); if (userTriggered) { - this.passedElement.triggerEvent(EventType.choice, this._getChoiceForOutput(item)); + this.passedElement.triggerEvent(EventType.choice, eventChoice); } } }; @@ -3401,7 +3463,7 @@ var Choices = /** @class */ (function () { if (notice && notice.type === NoticeTypes.noChoices) { this._clearNotice(); } - this.passedElement.triggerEvent(EventType.removeItem, this._getChoiceForOutput(item)); + this.passedElement.triggerEvent(EventType.removeItem, getChoiceForOutput(item)); }; Choices.prototype._addChoice = function (choice, withEvents, userTriggered) { if (withEvents === void 0) { withEvents = true; } @@ -3516,24 +3578,24 @@ var Choices = /** @class */ (function () { containerInner.wrap(passedElement.element); // Wrapper inner container with outer container containerOuter.wrap(containerInner.element); - if (this._isSelectOneElement) { - this.input.placeholder = this.config.searchPlaceholderValue || ''; - } - else { - if (this._placeholderValue) { - this.input.placeholder = this._placeholderValue; - } - this.input.setWidth(); - } containerOuter.element.appendChild(containerInner.element); containerOuter.element.appendChild(dropdownElement); containerInner.element.appendChild(this.itemList.element); dropdownElement.appendChild(this.choiceList.element); - if (!this._isSelectOneElement) { - containerInner.element.appendChild(this.input.element); + if (this._isSelectOneElement) { + this.input.placeholder = this.config.searchPlaceholderValue || ''; + if (this.config.searchEnabled) { + dropdownElement.insertBefore(this.input.element, dropdownElement.firstChild); + } } - else if (this.config.searchEnabled) { - dropdownElement.insertBefore(this.input.element, dropdownElement.firstChild); + else { + if (!this._isSelectMultipleElement || this.config.searchEnabled) { + containerInner.element.appendChild(this.input.element); + } + if (this._placeholderValue) { + this.input.placeholder = this._placeholderValue; + } + this.input.setWidth(); } this._highlightPosition = 0; this._isSearching = false; @@ -3616,7 +3678,7 @@ var Choices = /** @class */ (function () { throw new TypeError("".concat(caller, " called for an element which has multiple instances of Choices initialised on it")); } }; - Choices.version = '11.1.0'; + Choices.version = '11.2.0'; return Choices; }()); diff --git a/assets/scripts/choices.search-prefix.js b/assets/scripts/choices.search-prefix.js index 4efc5984..c1d47ad0 100644 --- a/assets/scripts/choices.search-prefix.js +++ b/assets/scripts/choices.search-prefix.js @@ -1,4 +1,4 @@ -/*! choices.js v11.1.0 | © 2025 Josh Johnson | https://github.com/jshjohnson/Choices#readme */ +/*! choices.js v11.2.0 | © 2026 Josh Johnson | https://github.com/jshjohnson/Choices#readme */ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : @@ -208,9 +208,6 @@ return firstChild; }; })(); - var resolveNoticeFunction = function (fn, value) { - return typeof fn === 'function' ? fn(sanitise(value), value) : fn; - }; var resolveStringFunction = function (fn) { return typeof fn === 'function' ? fn() : fn; }; @@ -242,6 +239,26 @@ } return ''; }; + var getChoiceForOutput = function (choice, keyCode) { + return { + id: choice.id, + highlighted: choice.highlighted, + labelClass: choice.labelClass, + labelDescription: unwrapStringForRaw(choice.labelDescription), + customProperties: choice.customProperties, + disabled: choice.disabled, + active: choice.active, + label: choice.label, + placeholder: choice.placeholder, + value: choice.value, + groupValue: choice.group ? choice.group.label : undefined, + element: choice.element, + keyCode: keyCode, + }; + }; + var resolveNoticeFunction = function (fn, value, item) { + return typeof fn === 'function' ? fn(sanitise(value), unwrapStringForRaw(value), item) : fn; + }; var escapeForTemplate = function (allowHTML, s) { return allowHTML ? unwrapStringForEscaped(s) : sanitise(s); }; @@ -409,6 +426,12 @@ Container.prototype.removeFocusState = function () { removeClassesFromElement(this.element, this.classNames.focusState); }; + Container.prototype.addInvalidState = function () { + addClassesToElement(this.element, this.classNames.invalidState); + }; + Container.prototype.removeInvalidState = function () { + removeClassesFromElement(this.element, this.classNames.invalidState); + }; Container.prototype.enable = function () { removeClassesFromElement(this.element, this.classNames.disabledState); this.element.removeAttribute('aria-disabled'); @@ -874,7 +897,9 @@ highlighted: false, placeholder: this.extractPlaceholder && (!option.value || option.hasAttribute('placeholder')), labelClass: typeof option.dataset.labelClass !== 'undefined' ? stringToHtmlClass(option.dataset.labelClass) : undefined, - labelDescription: typeof option.dataset.labelDescription !== 'undefined' ? option.dataset.labelDescription : undefined, + labelDescription: typeof option.dataset.labelDescription !== 'undefined' + ? { trusted: option.dataset.labelDescription } + : undefined, customProperties: parseCustomProperties(option.dataset.customProperties), }; }; @@ -920,6 +945,7 @@ selectedState: ['is-selected'], flippedState: ['is-flipped'], loadingState: ['is-loading'], + invalidState: ['is-invalid'], notice: ['choices__notice'], addChoice: ['choices__item--selectable', 'add-choice'], noResults: ['has-no-results'], @@ -947,6 +973,7 @@ paste: true, searchEnabled: true, searchChoices: true, + searchDisabledChoices: false, searchFloor: 1, searchResultLimit: 4, searchFields: ['label', 'value'], @@ -962,6 +989,7 @@ prependValue: null, appendValue: null, renderSelectedChoices: 'auto', + searchRenderSelectedChoices: true, loadingText: 'Loading...', noResultsText: 'No results found', noChoicesText: 'No choices to choose from', @@ -970,7 +998,9 @@ customAddItemText: 'Only values matching specific conditions can be added', addItemText: function (value) { return "Press Enter to add \"".concat(value, "\""); }, removeItemIconText: function () { return "Remove item"; }, - removeItemLabelText: function (value) { return "Remove item: ".concat(value); }, + removeItemLabelText: function (value, _valueRaw, i) { + return "Remove item: ".concat(i ? sanitise(i.label) : value); + }, maxItemText: function (maxItemCount) { return "Only ".concat(maxItemCount, " values can be added"); }, valueComparer: function (value1, value2) { return value1 === value2; }, fuseOptions: { @@ -1271,7 +1301,8 @@ * Get choices that can be searched (excluding placeholders or disabled choices) */ get: function () { - return this.choices.filter(function (choice) { return !choice.disabled && !choice.placeholder; }); + var context = this._context; + return this.choices.filter(function (choice) { return !choice.placeholder && (context.searchDisabledChoices || !choice.disabled); }); }, enumerable: false, configurable: true @@ -1384,7 +1415,7 @@ dataset.labelClass = getClassNames(labelClass).join(' '); } if (labelDescription) { - dataset.labelDescription = labelDescription; + dataset.labelDescription = unwrapStringForRaw(labelDescription); } if (withCustomProperties && customProperties) { if (typeof customProperties === 'string') { @@ -1491,8 +1522,9 @@ var removeButton = document.createElement('button'); removeButton.type = 'button'; addClassesToElement(removeButton, button); - setElementHtml(removeButton, true, resolveNoticeFunction(removeItemIconText, choice.value)); - var REMOVE_ITEM_LABEL = resolveNoticeFunction(removeItemLabelText, choice.value); + var eventChoice = getChoiceForOutput(choice); + setElementHtml(removeButton, true, resolveNoticeFunction(removeItemIconText, choice.value, eventChoice)); + var REMOVE_ITEM_LABEL = resolveNoticeFunction(removeItemLabelText, choice.value, eventChoice); if (REMOVE_ITEM_LABEL) { removeButton.setAttribute('aria-label', REMOVE_ITEM_LABEL); } @@ -1597,6 +1629,7 @@ else { addClassesToElement(div, itemSelectable); div.dataset.choiceSelectable = ''; + div.setAttribute('aria-selected', choice.selected ? 'true' : 'false'); } return div; }, @@ -1766,7 +1799,7 @@ this.initialised = false; this._store = new Store(config); this._currentValue = ''; - config.searchEnabled = (!isText && config.searchEnabled) || isSelectMultiple; + config.searchEnabled = !isText && config.searchEnabled; this._canSearch = config.searchEnabled; this._isScrollingOnIe = false; this._highlightPosition = 0; @@ -1806,6 +1839,8 @@ this._onEscapeKey = this._onEscapeKey.bind(this); this._onDirectionKey = this._onDirectionKey.bind(this); this._onDeleteKey = this._onDeleteKey.bind(this); + this._onChange = this._onChange.bind(this); + this._onInvalid = this._onInvalid.bind(this); // If element has already been initialised with Choices, fail silently if (this.passedElement.isActive) { if (!config.silent) { @@ -1912,7 +1947,7 @@ } this._store.dispatch(highlightItem(choice, true)); if (runEvent) { - this.passedElement.triggerEvent(EventType.highlightItem, this._getChoiceForOutput(choice)); + this.passedElement.triggerEvent(EventType.highlightItem, getChoiceForOutput(choice)); } return this; }; @@ -1927,7 +1962,7 @@ } this._store.dispatch(highlightItem(choice, false)); if (runEvent) { - this.passedElement.triggerEvent(EventType.unhighlightItem, this._getChoiceForOutput(choice)); + this.passedElement.triggerEvent(EventType.unhighlightItem, getChoiceForOutput(choice)); } return this; }; @@ -1937,7 +1972,7 @@ _this._store.items.forEach(function (item) { if (!item.highlighted) { _this._store.dispatch(highlightItem(item, true)); - _this.passedElement.triggerEvent(EventType.highlightItem, _this._getChoiceForOutput(item)); + _this.passedElement.triggerEvent(EventType.highlightItem, getChoiceForOutput(item)); } }); }); @@ -1949,7 +1984,7 @@ _this._store.items.forEach(function (item) { if (item.highlighted) { _this._store.dispatch(highlightItem(item, false)); - _this.passedElement.triggerEvent(EventType.highlightItem, _this._getChoiceForOutput(item)); + _this.passedElement.triggerEvent(EventType.highlightItem, getChoiceForOutput(item)); } }); }); @@ -2004,6 +2039,11 @@ _this.input.focus(); } _this.passedElement.triggerEvent(EventType.showDropdown); + var activeElement = _this.choiceList.element.querySelector(getClassNamesSelector(_this.config.classNames.selectedState)); + if (activeElement !== null && !isScrolledIntoView(activeElement, _this.choiceList.element)) { + // We use the native scrollIntoView function instead of choiceList.scrollToChildElement to avoid animated scroll. + activeElement.scrollIntoView(); + } }); return this; }; @@ -2012,6 +2052,7 @@ if (!this.dropdown.isActive) { return this; } + this._removeHighlightedChoices(); requestAnimationFrame(function () { _this.dropdown.hide(); _this.containerOuter.close(); @@ -2024,9 +2065,8 @@ return this; }; Choices.prototype.getValue = function (valueOnly) { - var _this = this; var values = this._store.items.map(function (item) { - return (valueOnly ? item.value : _this._getChoiceForOutput(item)); + return (valueOnly ? item.value : getChoiceForOutput(item)); }); return this._isSelectOneElement || this.config.singleModeForMultiSelect ? values[0] : values; }; @@ -2284,7 +2324,7 @@ // @todo integrate with Store this._searcher.reset(); if (choice.selected) { - this.passedElement.triggerEvent(EventType.removeItem, this._getChoiceForOutput(choice)); + this.passedElement.triggerEvent(EventType.removeItem, getChoiceForOutput(choice)); } return this; }; @@ -2367,13 +2407,7 @@ } var _a = this, config = _a.config, isSearching = _a._isSearching; var _b = this._store, activeGroups = _b.activeGroups, activeChoices = _b.activeChoices; - var renderLimit = 0; - if (isSearching && config.searchResultLimit > 0) { - renderLimit = config.searchResultLimit; - } - else if (config.renderChoiceLimit > 0) { - renderLimit = config.renderChoiceLimit; - } + var renderLimit = isSearching ? config.searchResultLimit : config.renderChoiceLimit; if (this._isSelectElement) { var backingOptions = activeChoices.filter(function (choice) { return !choice.element; }); if (backingOptions.length) { @@ -2383,11 +2417,16 @@ var fragment = document.createDocumentFragment(); var renderableChoices = function (choices) { return choices.filter(function (choice) { - return !choice.placeholder && (isSearching ? !!choice.rank : config.renderSelectedChoices || !choice.selected); + return !choice.placeholder && + (isSearching + ? (config.searchRenderSelectedChoices || !choice.selected) && !!choice.rank + : config.renderSelectedChoices || !choice.selected); }); }; + var showLabel = config.appendGroupInSearch && isSearching; var selectableChoices = false; - var renderChoices = function (choices, withinGroup, groupLabel) { + var highlightedEl = null; + var renderChoices = function (choices, withinGroup) { if (isSearching) { // sortByRank is used to ensure stable sorting, as scores are non-unique // this additionally ensures fuseOptions.sortFn is not ignored @@ -2397,16 +2436,20 @@ choices.sort(config.sorter); } var choiceLimit = choices.length; - choiceLimit = !withinGroup && renderLimit && choiceLimit > renderLimit ? renderLimit : choiceLimit; + choiceLimit = !withinGroup && renderLimit > 0 && choiceLimit > renderLimit ? renderLimit : choiceLimit; choiceLimit--; choices.every(function (choice, index) { // choiceEl being empty signals the contents has probably significantly changed - var dropdownItem = choice.choiceEl || _this._templates.choice(config, choice, config.itemSelectText, groupLabel); + var dropdownItem = choice.choiceEl || + _this._templates.choice(config, choice, config.itemSelectText, showLabel && choice.group ? choice.group.label : undefined); choice.choiceEl = dropdownItem; fragment.appendChild(dropdownItem); if (isSearching || !choice.selected) { selectableChoices = true; } + else if (!highlightedEl) { + highlightedEl = dropdownItem; + } return index < choiceLimit; }); }; @@ -2416,7 +2459,7 @@ } if (!this._hasNonChoicePlaceholder && !isSearching && this._isSelectOneElement) { // If we have a placeholder choice along with groups - renderChoices(activeChoices.filter(function (choice) { return choice.placeholder && !choice.group; }), false, undefined); + renderChoices(activeChoices.filter(function (choice) { return choice.placeholder && !choice.group; }), false); } // If we have grouped options if (activeGroups.length && !isSearching) { @@ -2425,7 +2468,7 @@ } // render Choices without group first, regardless of sort, otherwise they won't be distinguishable // from the last group - renderChoices(activeChoices.filter(function (choice) { return !choice.placeholder && !choice.group; }), false, undefined); + renderChoices(activeChoices.filter(function (choice) { return !choice.placeholder && !choice.group; }), false); activeGroups.forEach(function (group) { var groupChoices = renderableChoices(group.choices); if (groupChoices.length) { @@ -2435,12 +2478,12 @@ dropdownGroup.remove(); fragment.appendChild(dropdownGroup); } - renderChoices(groupChoices, true, config.appendGroupInSearch && isSearching ? group.label : undefined); + renderChoices(groupChoices, true); } }); } else { - renderChoices(renderableChoices(activeChoices), false, undefined); + renderChoices(renderableChoices(activeChoices), false); } } if (!selectableChoices && (isSearching || !fragment.children.length || !config.renderSelectedChoices)) { @@ -2454,9 +2497,7 @@ } this._renderNotice(fragment); this.choiceList.element.replaceChildren(fragment); - if (selectableChoices) { - this._highlightChoice(); - } + this._highlightChoice(highlightedEl); }; Choices.prototype._renderItems = function () { var _this = this; @@ -2566,23 +2607,12 @@ } } }; + /** + * @deprecated Use utils.getChoiceForOutput + */ // eslint-disable-next-line class-methods-use-this Choices.prototype._getChoiceForOutput = function (choice, keyCode) { - return { - id: choice.id, - highlighted: choice.highlighted, - labelClass: choice.labelClass, - labelDescription: choice.labelDescription, - customProperties: choice.customProperties, - disabled: choice.disabled, - active: choice.active, - label: choice.label, - placeholder: choice.placeholder, - value: choice.value, - groupValue: choice.group ? choice.group.label : undefined, - element: choice.element, - keyCode: keyCode, - }; + return getChoiceForOutput(choice, keyCode); }; Choices.prototype._triggerChange = function (value) { if (value === undefined || value === null) { @@ -2598,7 +2628,7 @@ if (!items.length || !this.config.removeItems || !this.config.removeItemButton) { return; } - var id = element && parseDataSetId(element.parentElement); + var id = element && parseDataSetId(element.closest('[data-id]')); var itemToRemove = id && items.find(function (item) { return item.id === id; }); if (!itemToRemove) { return; @@ -2787,7 +2817,7 @@ var notice = ''; if (canAddItem && typeof config.addItemFilter === 'function' && !config.addItemFilter(value)) { canAddItem = false; - notice = resolveNoticeFunction(config.customAddItemText, value); + notice = resolveNoticeFunction(config.customAddItemText, value, undefined); } if (canAddItem) { var foundChoice = this._store.choices.find(function (choice) { return config.valueComparer(choice.value, value); }); @@ -2799,12 +2829,12 @@ } if (!config.duplicateItemsAllowed) { canAddItem = false; - notice = resolveNoticeFunction(config.uniqueItemText, value); + notice = resolveNoticeFunction(config.uniqueItemText, value, undefined); } } } if (canAddItem) { - notice = resolveNoticeFunction(config.addItemText, value); + notice = resolveNoticeFunction(config.addItemText, value, undefined); } if (notice) { this._displayNotice(notice, NoticeTypes.addChoice); @@ -2855,6 +2885,7 @@ var documentElement = this._docRoot; var outerElement = this.containerOuter.element; var inputElement = this.input.element; + var passedElement = this.passedElement.element; // capture events - can cancel event processing or propagation documentElement.addEventListener('touchend', this._onTouchEnd, true); outerElement.addEventListener('keydown', this._onKeyDown, true); @@ -2892,12 +2923,21 @@ passive: true, }); } + if (passedElement.hasAttribute('required')) { + passedElement.addEventListener('change', this._onChange, { + passive: true, + }); + passedElement.addEventListener('invalid', this._onInvalid, { + passive: true, + }); + } this.input.addEventListeners(); }; Choices.prototype._removeEventListeners = function () { var documentElement = this._docRoot; var outerElement = this.containerOuter.element; var inputElement = this.input.element; + var passedElement = this.passedElement.element; documentElement.removeEventListener('touchend', this._onTouchEnd, true); outerElement.removeEventListener('keydown', this._onKeyDown, true); outerElement.removeEventListener('mousedown', this._onMouseDown, true); @@ -2915,6 +2955,10 @@ if (inputElement.form) { inputElement.form.removeEventListener('reset', this._onFormReset); } + if (passedElement.hasAttribute('required')) { + passedElement.removeEventListener('change', this._onChange); + passedElement.removeEventListener('invalid', this._onInvalid); + } this.input.removeEventListeners(); }; Choices.prototype._onKeyDown = function (event) { @@ -3164,7 +3208,7 @@ */ Choices.prototype._onMouseDown = function (event) { var target = event.target; - if (!(target instanceof HTMLElement)) { + if (!(target instanceof Element)) { return; } // If we have our mouse down on the scrollbar and are on IE11... @@ -3273,7 +3317,7 @@ // Remove the focus state when the past outerContainer was the target containerOuter.removeFocusState(); // Also close the dropdown if search is disabled - if (!this._canSearch) { + if (!this.config.searchEnabled) { this.hideDropdown(true); } } @@ -3297,6 +3341,27 @@ } }); }; + Choices.prototype._onChange = function (event) { + if (!event.target.checkValidity()) { + return; + } + this.containerOuter.removeInvalidState(); + }; + Choices.prototype._onInvalid = function () { + this.containerOuter.addInvalidState(); + }; + /** + * Removes any highlighted choice options + */ + Choices.prototype._removeHighlightedChoices = function () { + var highlightedState = this.config.classNames.highlightedState; + var highlightedChoices = Array.from(this.dropdown.element.querySelectorAll(getClassNamesSelector(highlightedState))); + // Remove any highlighted choices + highlightedChoices.forEach(function (choice) { + removeClassesFromElement(choice, highlightedState); + choice.setAttribute('aria-selected', 'false'); + }); + }; Choices.prototype._highlightChoice = function (el) { if (el === void 0) { el = null; } var choices = Array.from(this.dropdown.element.querySelectorAll(selectableChoiceIdentifier)); @@ -3305,12 +3370,7 @@ } var passedEl = el; var highlightedState = this.config.classNames.highlightedState; - var highlightedChoices = Array.from(this.dropdown.element.querySelectorAll(getClassNamesSelector(highlightedState))); - // Remove any highlighted choices - highlightedChoices.forEach(function (choice) { - removeClassesFromElement(choice, highlightedState); - choice.setAttribute('aria-selected', 'false'); - }); + this._removeHighlightedChoices(); if (passedEl) { this._highlightPosition = choices.indexOf(passedEl); } @@ -3351,9 +3411,10 @@ } this._store.dispatch(addItem(item)); if (withEvents) { - this.passedElement.triggerEvent(EventType.addItem, this._getChoiceForOutput(item)); + var eventChoice = getChoiceForOutput(item); + this.passedElement.triggerEvent(EventType.addItem, eventChoice); if (userTriggered) { - this.passedElement.triggerEvent(EventType.choice, this._getChoiceForOutput(item)); + this.passedElement.triggerEvent(EventType.choice, eventChoice); } } }; @@ -3366,7 +3427,7 @@ if (notice && notice.type === NoticeTypes.noChoices) { this._clearNotice(); } - this.passedElement.triggerEvent(EventType.removeItem, this._getChoiceForOutput(item)); + this.passedElement.triggerEvent(EventType.removeItem, getChoiceForOutput(item)); }; Choices.prototype._addChoice = function (choice, withEvents, userTriggered) { if (withEvents === void 0) { withEvents = true; } @@ -3481,24 +3542,24 @@ containerInner.wrap(passedElement.element); // Wrapper inner container with outer container containerOuter.wrap(containerInner.element); - if (this._isSelectOneElement) { - this.input.placeholder = this.config.searchPlaceholderValue || ''; - } - else { - if (this._placeholderValue) { - this.input.placeholder = this._placeholderValue; - } - this.input.setWidth(); - } containerOuter.element.appendChild(containerInner.element); containerOuter.element.appendChild(dropdownElement); containerInner.element.appendChild(this.itemList.element); dropdownElement.appendChild(this.choiceList.element); - if (!this._isSelectOneElement) { - containerInner.element.appendChild(this.input.element); + if (this._isSelectOneElement) { + this.input.placeholder = this.config.searchPlaceholderValue || ''; + if (this.config.searchEnabled) { + dropdownElement.insertBefore(this.input.element, dropdownElement.firstChild); + } } - else if (this.config.searchEnabled) { - dropdownElement.insertBefore(this.input.element, dropdownElement.firstChild); + else { + if (!this._isSelectMultipleElement || this.config.searchEnabled) { + containerInner.element.appendChild(this.input.element); + } + if (this._placeholderValue) { + this.input.placeholder = this._placeholderValue; + } + this.input.setWidth(); } this._highlightPosition = 0; this._isSearching = false; @@ -3581,7 +3642,7 @@ throw new TypeError("".concat(caller, " called for an element which has multiple instances of Choices initialised on it")); } }; - Choices.version = '11.1.0'; + Choices.version = '11.2.0'; return Choices; }()); diff --git a/assets/scripts/choices.search-prefix.min.js b/assets/scripts/choices.search-prefix.min.js index c917cbba..cf70bc96 100644 --- a/assets/scripts/choices.search-prefix.min.js +++ b/assets/scripts/choices.search-prefix.min.js @@ -1,2 +1,2 @@ -/*! choices.js v11.1.0 | © 2025 Josh Johnson | https://github.com/jshjohnson/Choices#readme */ -!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).Choices=t()}(this,(function(){"use strict";var e=function(t,i){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])},e(t,i)};function t(t,i){if("function"!=typeof i&&null!==i)throw new TypeError("Class extends value "+String(i)+" is not a constructor or null");function n(){this.constructor=t}e(t,i),t.prototype=null===i?Object.create(i):(n.prototype=i.prototype,new n)}var i=function(){return i=Object.assign||function(e){for(var t,i=1,n=arguments.length;i/g,">").replace(/=0&&!window.matchMedia("(min-height: ".concat(e+1,"px)")).matches:"top"===this.position&&(i=!0),i},e.prototype.setActiveDescendant=function(e){this.element.setAttribute("aria-activedescendant",e)},e.prototype.removeActiveDescendant=function(){this.element.removeAttribute("aria-activedescendant")},e.prototype.open=function(e,t){k(this.element,this.classNames.openState),this.element.setAttribute("aria-expanded","true"),this.isOpen=!0,this.shouldFlip(e,t)&&(k(this.element,this.classNames.flippedState),this.isFlipped=!0)},e.prototype.close=function(){M(this.element,this.classNames.openState),this.element.setAttribute("aria-expanded","false"),this.removeActiveDescendant(),this.isOpen=!1,this.isFlipped&&(M(this.element,this.classNames.flippedState),this.isFlipped=!1)},e.prototype.addFocusState=function(){k(this.element,this.classNames.focusState)},e.prototype.removeFocusState=function(){M(this.element,this.classNames.focusState)},e.prototype.enable=function(){M(this.element,this.classNames.disabledState),this.element.removeAttribute("aria-disabled"),this.type===_&&this.element.setAttribute("tabindex","0"),this.isDisabled=!1},e.prototype.disable=function(){k(this.element,this.classNames.disabledState),this.element.setAttribute("aria-disabled","true"),this.type===_&&this.element.setAttribute("tabindex","-1"),this.isDisabled=!0},e.prototype.wrap=function(e){var t=this.element,i=e.parentNode;i&&(e.nextSibling?i.insertBefore(t,e.nextSibling):i.appendChild(t)),t.appendChild(e)},e.prototype.unwrap=function(e){var t=this.element,i=t.parentNode;i&&(i.insertBefore(e,t),i.removeChild(t))},e.prototype.addLoadingState=function(){k(this.element,this.classNames.loadingState),this.element.setAttribute("aria-busy","true"),this.isLoading=!0},e.prototype.removeLoadingState=function(){M(this.element,this.classNames.loadingState),this.element.removeAttribute("aria-busy"),this.isLoading=!1},e}(),V=function(){function e(e){var t=e.element,i=e.type,n=e.classNames,s=e.preventPaste;this.element=t,this.type=i,this.classNames=n,this.preventPaste=s,this.isFocussed=this.element.isEqualNode(document.activeElement),this.isDisabled=t.disabled,this._onPaste=this._onPaste.bind(this),this._onInput=this._onInput.bind(this),this._onFocus=this._onFocus.bind(this),this._onBlur=this._onBlur.bind(this)}return Object.defineProperty(e.prototype,"placeholder",{set:function(e){this.element.placeholder=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"value",{get:function(){return this.element.value},set:function(e){this.element.value=e},enumerable:!1,configurable:!0}),e.prototype.addEventListeners=function(){var e=this.element;e.addEventListener("paste",this._onPaste),e.addEventListener("input",this._onInput,{passive:!0}),e.addEventListener("focus",this._onFocus,{passive:!0}),e.addEventListener("blur",this._onBlur,{passive:!0})},e.prototype.removeEventListeners=function(){var e=this.element;e.removeEventListener("input",this._onInput),e.removeEventListener("paste",this._onPaste),e.removeEventListener("focus",this._onFocus),e.removeEventListener("blur",this._onBlur)},e.prototype.enable=function(){this.element.removeAttribute("disabled"),this.isDisabled=!1},e.prototype.disable=function(){this.element.setAttribute("disabled",""),this.isDisabled=!0},e.prototype.focus=function(){this.isFocussed||this.element.focus()},e.prototype.blur=function(){this.isFocussed&&this.element.blur()},e.prototype.clear=function(e){return void 0===e&&(e=!0),this.element.value="",e&&this.setWidth(),this},e.prototype.setWidth=function(){var e=this.element;e.style.minWidth="".concat(e.placeholder.length+1,"ch"),e.style.width="".concat(e.value.length+1,"ch")},e.prototype.setActiveDescendant=function(e){this.element.setAttribute("aria-activedescendant",e)},e.prototype.removeActiveDescendant=function(){this.element.removeAttribute("aria-activedescendant")},e.prototype._onInput=function(){this.type!==_&&this.setWidth()},e.prototype._onPaste=function(e){this.preventPaste&&e.preventDefault()},e.prototype._onFocus=function(){this.isFocussed=!0},e.prototype._onBlur=function(){this.isFocussed=!1},e}(),H=function(){function e(e){this.element=e.element,this.scrollPos=this.element.scrollTop,this.height=this.element.offsetHeight}return e.prototype.prepend=function(e){var t=this.element.firstElementChild;t?this.element.insertBefore(e,t):this.element.append(e)},e.prototype.scrollToTop=function(){this.element.scrollTop=0},e.prototype.scrollToChildElement=function(e,t){var i=this;if(e){var n=t>0?this.element.scrollTop+(e.offsetTop+e.offsetHeight)-(this.element.scrollTop+this.element.offsetHeight):e.offsetTop;requestAnimationFrame((function(){i._animateScroll(n,t)}))}},e.prototype._scrollDown=function(e,t,i){var n=(i-e)/t;this.element.scrollTop=e+(n>1?n:1)},e.prototype._scrollUp=function(e,t,i){var n=(e-i)/t;this.element.scrollTop=e-(n>1?n:1)},e.prototype._animateScroll=function(e,t){var i=this,n=this.element.scrollTop,s=!1;t>0?(this._scrollDown(n,4,e),ne&&(s=!0)),s&&requestAnimationFrame((function(){i._animateScroll(e,t)}))},e}(),R=function(){function e(e){var t=e.classNames;this.element=e.element,this.classNames=t,this.isDisabled=!1}return Object.defineProperty(e.prototype,"isActive",{get:function(){return"active"===this.element.dataset.choice},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"dir",{get:function(){return this.element.dir},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"value",{get:function(){return this.element.value},set:function(e){this.element.setAttribute("value",e),this.element.value=e},enumerable:!1,configurable:!0}),e.prototype.conceal=function(){var e=this.element;k(e,this.classNames.input),e.hidden=!0,e.tabIndex=-1;var t=e.getAttribute("style");t&&e.setAttribute("data-choice-orig-style",t),e.setAttribute("data-choice","active")},e.prototype.reveal=function(){var e=this.element;M(e,this.classNames.input),e.hidden=!1,e.removeAttribute("tabindex");var t=e.getAttribute("data-choice-orig-style");t?(e.removeAttribute("data-choice-orig-style"),e.setAttribute("style",t)):e.removeAttribute("style"),e.removeAttribute("data-choice")},e.prototype.enable=function(){this.element.removeAttribute("disabled"),this.element.disabled=!1,this.isDisabled=!1},e.prototype.disable=function(){this.element.setAttribute("disabled",""),this.element.disabled=!0,this.isDisabled=!0},e.prototype.triggerEvent=function(e,t){var i;void 0===(i=t||{})&&(i=null),this.element.dispatchEvent(new CustomEvent(e,{detail:i,bubbles:!0,cancelable:!0}))},e}(),q=function(e){function i(){return null!==e&&e.apply(this,arguments)||this}return t(i,e),i}(R),U=function(e,t){return void 0===t&&(t=!0),void 0===e?t:!!e},G=function(e){if("string"==typeof e&&(e=e.split(" ").filter((function(e){return e.length}))),Array.isArray(e)&&e.length)return e},W=function(e,t,i){if(void 0===i&&(i=!0),"string"==typeof e){var n=w(e);return W({value:e,label:i||n===e?e:{escaped:n,raw:e},selected:!0},!1)}var s=e;if("choices"in s){if(!t)throw new TypeError("optGroup is not allowed");var o=s,r=o.choices.map((function(e){return W(e,!1)}));return{id:0,label:T(o.label)||o.value,active:!!r.length,disabled:!!o.disabled,choices:r}}var a=s;return{id:0,group:null,score:0,rank:0,value:a.value,label:a.label||a.value,active:U(a.active),selected:U(a.selected,!1),disabled:U(a.disabled,!1),placeholder:U(a.placeholder,!1),highlighted:!1,labelClass:G(a.labelClass),labelDescription:a.labelDescription,customProperties:a.customProperties}},X=function(e){return"SELECT"===e.tagName},J=function(e){function i(t){var i=t.template,n=t.extractPlaceholder,s=e.call(this,{element:t.element,classNames:t.classNames})||this;return s.template=i,s.extractPlaceholder=n,s}return t(i,e),Object.defineProperty(i.prototype,"placeholderOption",{get:function(){return this.element.querySelector('option[value=""]')||this.element.querySelector("option[placeholder]")},enumerable:!1,configurable:!0}),i.prototype.addOptions=function(e){var t=this,i=document.createDocumentFragment();e.forEach((function(e){var n=e;if(!n.element){var s=t.template(n);i.appendChild(s),n.element=s}})),this.element.appendChild(i)},i.prototype.optionsAsChoices=function(){var e=this,t=[];return this.element.querySelectorAll(":scope > option, :scope > optgroup").forEach((function(i){!function(e){return"OPTION"===e.tagName}(i)?function(e){return"OPTGROUP"===e.tagName}(i)&&t.push(e._optgroupToChoice(i)):t.push(e._optionToChoice(i))})),t},i.prototype._optionToChoice=function(e){return!e.hasAttribute("value")&&e.hasAttribute("placeholder")&&(e.setAttribute("value",""),e.value=""),{id:0,group:null,score:0,rank:0,value:e.value,label:e.label,element:e,active:!0,selected:this.extractPlaceholder?e.selected:e.hasAttribute("selected"),disabled:e.disabled,highlighted:!1,placeholder:this.extractPlaceholder&&(!e.value||e.hasAttribute("placeholder")),labelClass:void 0!==e.dataset.labelClass?G(e.dataset.labelClass):void 0,labelDescription:void 0!==e.dataset.labelDescription?e.dataset.labelDescription:void 0,customProperties:K(e.dataset.customProperties)}},i.prototype._optgroupToChoice=function(e){var t=this,i=e.querySelectorAll("option"),n=Array.from(i).map((function(e){return t._optionToChoice(e)}));return{id:0,label:e.label||"",element:e,active:!!n.length,disabled:e.disabled,choices:n}},i}(R),z={items:[],choices:[],silent:!1,renderChoiceLimit:-1,maxItemCount:-1,closeDropdownOnSelect:"auto",singleModeForMultiSelect:!1,addChoices:!1,addItems:!0,addItemFilter:function(e){return!!e&&""!==e},removeItems:!0,removeItemButton:!1,removeItemButtonAlignLeft:!1,editItems:!1,allowHTML:!1,allowHtmlUserInput:!1,duplicateItemsAllowed:!0,delimiter:",",paste:!0,searchEnabled:!0,searchChoices:!0,searchFloor:1,searchResultLimit:4,searchFields:["label","value"],position:"auto",resetScrollPosition:!0,shouldSort:!0,shouldSortItems:!1,sorter:function(e,t){var i=e.label,n=t.label,s=void 0===n?t.value:n;return T(void 0===i?e.value:i).localeCompare(T(s),[],{sensitivity:"base",ignorePunctuation:!0,numeric:!0})},shadowRoot:null,placeholder:!0,placeholderValue:null,searchPlaceholderValue:null,prependValue:null,appendValue:null,renderSelectedChoices:"auto",loadingText:"Loading...",noResultsText:"No results found",noChoicesText:"No choices to choose from",itemSelectText:"Press to select",uniqueItemText:"Only unique values can be added",customAddItemText:"Only values matching specific conditions can be added",addItemText:function(e){return'Press Enter to add "'.concat(e,'"')},removeItemIconText:function(){return"Remove item"},removeItemLabelText:function(e){return"Remove item: ".concat(e)},maxItemText:function(e){return"Only ".concat(e," values can be added")},valueComparer:function(e,t){return e===t},fuseOptions:{includeScore:!0},labelId:"",callbackOnInit:null,callbackOnCreateTemplates:null,classNames:{containerOuter:["choices"],containerInner:["choices__inner"],input:["choices__input"],inputCloned:["choices__input--cloned"],list:["choices__list"],listItems:["choices__list--multiple"],listSingle:["choices__list--single"],listDropdown:["choices__list--dropdown"],item:["choices__item"],itemSelectable:["choices__item--selectable"],itemDisabled:["choices__item--disabled"],itemChoice:["choices__item--choice"],description:["choices__description"],placeholder:["choices__placeholder"],group:["choices__group"],groupHeading:["choices__heading"],button:["choices__button"],activeState:["is-active"],focusState:["is-focused"],openState:["is-open"],disabledState:["is-disabled"],highlightedState:["is-highlighted"],selectedState:["is-selected"],flippedState:["is-flipped"],loadingState:["is-loading"],notice:["choices__notice"],addChoice:["choices__item--selectable","add-choice"],noResults:["has-no-results"],noChoices:["has-no-choices"]},appendGroupInSearch:!1},Q=function(e){var t=e.itemEl;t&&(t.remove(),e.itemEl=void 0)},Y={groups:function(e,t){var i=e,n=!0;switch(t.type){case l:i.push(t.group);break;case c:i=[];break;default:n=!1}return{state:i,update:n}},items:function(e,t,i){var n=e,s=!0;switch(t.type){case h:t.item.selected=!0,(r=t.item.element)&&(r.selected=!0,r.setAttribute("selected","")),n.push(t.item);break;case u:var r;if(t.item.selected=!1,r=t.item.element){r.selected=!1,r.removeAttribute("selected");var a=r.parentElement;a&&X(a)&&a.type===_&&(a.value="")}Q(t.item),n=n.filter((function(e){return e.id!==t.item.id}));break;case o:Q(t.choice),n=n.filter((function(e){return e.id!==t.choice.id}));break;case d:var c=t.highlighted,l=n.find((function(e){return e.id===t.item.id}));l&&l.highlighted!==c&&(l.highlighted=c,i&&function(e,t,i){var n=e.itemEl;n&&(M(n,i),k(n,t))}(l,c?i.classNames.highlightedState:i.classNames.selectedState,c?i.classNames.selectedState:i.classNames.highlightedState));break;default:s=!1}return{state:n,update:s}},choices:function(e,t,i){var n=e,l=!0;switch(t.type){case s:n.push(t.choice);break;case o:t.choice.choiceEl=void 0,t.choice.group&&(t.choice.group.choices=t.choice.group.choices.filter((function(e){return e.id!==t.choice.id}))),n=n.filter((function(e){return e.id!==t.choice.id}));break;case h:case u:t.item.choiceEl=void 0;break;case r:var d=[];t.results.forEach((function(e){d[e.item.id]=e})),n.forEach((function(e){var t=d[e.id];void 0!==t?(e.score=t.score,e.rank=t.rank,e.active=!0):(e.score=0,e.rank=0,e.active=!1),i&&i.appendGroupInSearch&&(e.choiceEl=void 0)}));break;case a:n.forEach((function(e){e.active=t.active,i&&i.appendGroupInSearch&&(e.choiceEl=void 0)}));break;case c:n=[];break;default:l=!1}return{state:n,update:l}}},Z=function(){function e(e){this._state=this.defaultState,this._listeners=[],this._txn=0,this._context=e}return Object.defineProperty(e.prototype,"defaultState",{get:function(){return{groups:[],items:[],choices:[]}},enumerable:!1,configurable:!0}),e.prototype.changeSet=function(e){return{groups:e,items:e,choices:e}},e.prototype.reset=function(){this._state=this.defaultState;var e=this.changeSet(!0);this._txn?this._changeSet=e:this._listeners.forEach((function(t){return t(e)}))},e.prototype.subscribe=function(e){return this._listeners.push(e),this},e.prototype.dispatch=function(e){var t=this,i=this._state,n=!1,s=this._changeSet||this.changeSet(!1);Object.keys(Y).forEach((function(o){var r=Y[o](i[o],e,t._context);r.update&&(n=!0,s[o]=!0,i[o]=r.state)})),n&&(this._txn?this._changeSet=s:this._listeners.forEach((function(e){return e(s)})))},e.prototype.withTxn=function(e){this._txn++;try{e()}finally{if(this._txn=Math.max(0,this._txn-1),!this._txn){var t=this._changeSet;t&&(this._changeSet=void 0,this._listeners.forEach((function(e){return e(t)})))}}},Object.defineProperty(e.prototype,"state",{get:function(){return this._state},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"items",{get:function(){return this.state.items},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"highlightedActiveItems",{get:function(){return this.items.filter((function(e){return e.active&&e.highlighted}))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"choices",{get:function(){return this.state.choices},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"activeChoices",{get:function(){return this.choices.filter((function(e){return e.active}))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"searchableChoices",{get:function(){return this.choices.filter((function(e){return!e.disabled&&!e.placeholder}))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"groups",{get:function(){return this.state.groups},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"activeGroups",{get:function(){var e=this;return this.state.groups.filter((function(t){var i=t.active&&!t.disabled,n=e.state.choices.some((function(e){return e.active&&!e.disabled}));return i&&n}),[])},enumerable:!1,configurable:!0}),e.prototype.inTxn=function(){return this._txn>0},e.prototype.getChoiceById=function(e){return this.activeChoices.find((function(t){return t.id===e}))},e.prototype.getGroupById=function(e){return this.groups.find((function(t){return t.id===e}))},e}(),$="no-choices",ee="no-results",te="add-choice",ie=function(){function e(e){this._haystack=[],this._fields=e.searchFields}return e.prototype.index=function(e){this._haystack=e},e.prototype.reset=function(){this._haystack=[]},e.prototype.isEmptyIndex=function(){return!this._haystack.length},e.prototype.search=function(e){var t=this._fields;if(!t||!t.length||!e)return[];var i=e.toLowerCase();return this._haystack.filter((function(e){return t.some((function(t){return t in e&&e[t].toLowerCase().startsWith(i)}))})).map((function(e,t){return{item:e,score:t,rank:t+1}}))},e}(),ne=function(e,t,i){var n=e.dataset,s=t.customProperties,o=t.labelClass,r=t.labelDescription;o&&(n.labelClass=P(o).join(" ")),r&&(n.labelDescription=r),i&&s&&("string"==typeof s?n.customProperties=s:"object"!=typeof s||function(e){for(var t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!1;return!0}(s)||(n.customProperties=JSON.stringify(s)))},se=function(e,t,i){var n=t&&e.querySelector("label[for='".concat(t,"']")),s=n&&n.innerText;s&&i.setAttribute("aria-label",s)},oe={containerOuter:function(e,t,i,n,s,o,r){var a=e.classNames.containerOuter,c=document.createElement("div");return k(c,a),c.dataset.type=o,t&&(c.dir=t),n&&(c.tabIndex=0),i&&(c.setAttribute("role",s?"combobox":"listbox"),s?c.setAttribute("aria-autocomplete","list"):r||se(this._docRoot,this.passedElement.element.id,c),c.setAttribute("aria-haspopup","true"),c.setAttribute("aria-expanded","false")),r&&c.setAttribute("aria-labelledby",r),c},containerInner:function(e){var t=e.classNames.containerInner,i=document.createElement("div");return k(i,t),i},itemList:function(e,t){var i=e.searchEnabled,n=e.classNames,s=n.list,o=n.listSingle,r=n.listItems,a=document.createElement("div");return k(a,s),k(a,t?o:r),this._isSelectElement&&i&&a.setAttribute("role","listbox"),a},placeholder:function(e,t){var i=e.allowHTML,n=e.classNames.placeholder,s=document.createElement("div");return k(s,n),D(s,i,t),s},item:function(e,t,i){var n=e.allowHTML,s=e.removeItemButtonAlignLeft,o=e.removeItemIconText,r=e.removeItemLabelText,a=e.classNames,c=a.item,l=a.button,h=a.highlightedState,u=a.itemSelectable,d=a.placeholder,p=T(t.value),m=document.createElement("div");if(k(m,c),t.labelClass){var f=document.createElement("span");D(f,n,t.label),k(f,t.labelClass),m.appendChild(f)}else D(m,n,t.label);if(m.dataset.item="",m.dataset.id=t.id,m.dataset.value=p,ne(m,t,!0),(t.disabled||this.containerOuter.isDisabled)&&m.setAttribute("aria-disabled","true"),this._isSelectElement&&(m.setAttribute("aria-selected","true"),m.setAttribute("role","option")),t.placeholder&&(k(m,d),m.dataset.placeholder=""),k(m,t.highlighted?h:u),i){t.disabled&&M(m,u),m.dataset.deletable="";var v=document.createElement("button");v.type="button",k(v,l),D(v,!0,A(o,t.value));var _=A(r,t.value);_&&v.setAttribute("aria-label",_),v.dataset.button="",s?m.insertAdjacentElement("afterbegin",v):m.appendChild(v)}return m},choiceList:function(e,t){var i=e.classNames.list,n=document.createElement("div");return k(n,i),t||n.setAttribute("aria-multiselectable","true"),n.setAttribute("role","listbox"),n},choiceGroup:function(e,t){var i=e.allowHTML,n=e.classNames,s=n.group,o=n.groupHeading,r=n.itemDisabled,a=t.id,c=t.label,l=t.disabled,h=T(c),u=document.createElement("div");k(u,s),l&&k(u,r),u.setAttribute("role","group"),u.dataset.group="",u.dataset.id=a,u.dataset.value=h,l&&u.setAttribute("aria-disabled","true");var d=document.createElement("div");return k(d,o),D(d,i,c||""),u.appendChild(d),u},choice:function(e,t,i,n){var s=e.allowHTML,o=e.classNames,r=o.item,a=o.itemChoice,c=o.itemSelectable,l=o.selectedState,h=o.itemDisabled,u=o.description,d=o.placeholder,p=t.label,m=T(t.value),f=document.createElement("div");f.id=t.elementId,k(f,r),k(f,a),n&&"string"==typeof p&&(p=L(s,p),p={trusted:p+=" (".concat(n,")")});var v=f;if(t.labelClass){var _=document.createElement("span");D(_,s,p),k(_,t.labelClass),v=_,f.appendChild(_)}else D(f,s,p);if(t.labelDescription){var g="".concat(t.elementId,"-description");v.setAttribute("aria-describedby",g);var y=document.createElement("span");D(y,s,t.labelDescription),y.id=g,k(y,u),f.appendChild(y)}return t.selected&&k(f,l),t.placeholder&&k(f,d),f.setAttribute("role",t.group?"treeitem":"option"),f.dataset.choice="",f.dataset.id=t.id,f.dataset.value=m,i&&(f.dataset.selectText=i),t.group&&(f.dataset.groupId="".concat(t.group.id)),ne(f,t,!1),t.disabled?(k(f,h),f.dataset.choiceDisabled="",f.setAttribute("aria-disabled","true")):(k(f,c),f.dataset.choiceSelectable=""),f},input:function(e,t){var i=e.classNames,n=i.input,s=i.inputCloned,o=e.labelId,r=document.createElement("input");return r.type="search",k(r,n),k(r,s),r.autocomplete="off",r.autocapitalize="off",r.spellcheck=!1,r.setAttribute("aria-autocomplete","list"),t?r.setAttribute("aria-label",t):o||se(this._docRoot,this.passedElement.element.id,r),r},dropdown:function(e){var t=e.classNames,i=t.list,n=t.listDropdown,s=document.createElement("div");return k(s,i),k(s,n),s.setAttribute("aria-expanded","false"),s},notice:function(e,t,i){var n=e.classNames,s=n.item,o=n.itemChoice,r=n.addChoice,a=n.noResults,c=n.noChoices,l=n.notice;void 0===i&&(i="");var h=document.createElement("div");switch(D(h,!0,t),k(h,s),k(h,o),k(h,l),i){case te:k(h,r);break;case ee:k(h,a);break;case $:k(h,c)}return i===te&&(h.dataset.choiceSelectable="",h.dataset.choice=""),h},option:function(e){var t=T(e.label),i=new Option(t,e.value,!1,e.selected);return ne(i,e,!0),i.disabled=e.disabled,e.selected&&i.setAttribute("selected",""),i}},re="-ms-scroll-limit"in document.documentElement.style&&"-ms-ime-align"in document.documentElement.style,ae={},ce=function(e){if(e)return e.dataset.id?parseInt(e.dataset.id,10):void 0},le="[data-choice-selectable]";return function(){function e(t,n){void 0===t&&(t="[data-choice]"),void 0===n&&(n={});var s=this;this.initialisedOK=void 0,this._hasNonChoicePlaceholder=!1,this._lastAddedChoiceId=0,this._lastAddedGroupId=0;var o=e.defaults;this.config=i(i(i({},o.allOptions),o.options),n),v.forEach((function(e){s.config[e]=i(i(i({},o.allOptions[e]),o.options[e]),n[e])}));var r=this.config;r.silent||this._validateConfig();var a=r.shadowRoot||document.documentElement;this._docRoot=a;var c="string"==typeof t?a.querySelector(t):t;if(!c||"object"!=typeof c||"INPUT"!==c.tagName&&!X(c)){if(!c&&"string"==typeof t)throw TypeError("Selector ".concat(t," failed to find an element"));throw TypeError("Expected one of the following types text|select-one|select-multiple")}var l=c.type,h="text"===l;(h||1!==r.maxItemCount)&&(r.singleModeForMultiSelect=!1),r.singleModeForMultiSelect&&(l=g);var u=l===_,d=l===g,p=u||d;if(this._elementType=l,this._isTextElement=h,this._isSelectOneElement=u,this._isSelectMultipleElement=d,this._isSelectElement=u||d,this._canAddUserChoices=h&&r.addItems||p&&r.addChoices,"boolean"!=typeof r.renderSelectedChoices&&(r.renderSelectedChoices="always"===r.renderSelectedChoices||u),r.closeDropdownOnSelect="auto"===r.closeDropdownOnSelect?h||u||r.singleModeForMultiSelect:U(r.closeDropdownOnSelect),r.placeholder&&(r.placeholderValue?this._hasNonChoicePlaceholder=!0:c.dataset.placeholder&&(this._hasNonChoicePlaceholder=!0,r.placeholderValue=c.dataset.placeholder)),n.addItemFilter&&"function"!=typeof n.addItemFilter){var m=n.addItemFilter instanceof RegExp?n.addItemFilter:new RegExp(n.addItemFilter);r.addItemFilter=m.test.bind(m)}if(this.passedElement=this._isTextElement?new q({element:c,classNames:r.classNames}):new J({element:c,classNames:r.classNames,template:function(e){return s._templates.option(e)},extractPlaceholder:r.placeholder&&!this._hasNonChoicePlaceholder}),this.initialised=!1,this._store=new Z(r),this._currentValue="",r.searchEnabled=!h&&r.searchEnabled||d,this._canSearch=r.searchEnabled,this._isScrollingOnIe=!1,this._highlightPosition=0,this._wasTap=!0,this._placeholderValue=this._generatePlaceholderValue(),this._baseId=function(e){var t=e.id||e.name&&"".concat(e.name,"-").concat(S(2))||S(4);return t=t.replace(/(:|\.|\[|\]|,)/g,""),"".concat("choices-","-").concat(t)}(c),this._direction=c.dir,!this._direction){var f=window.getComputedStyle(c).direction;f!==window.getComputedStyle(document.documentElement).direction&&(this._direction=f)}if(this._idNames={itemChoice:"item-choice"},this._templates=o.templates,this._render=this._render.bind(this),this._onFocus=this._onFocus.bind(this),this._onBlur=this._onBlur.bind(this),this._onKeyUp=this._onKeyUp.bind(this),this._onKeyDown=this._onKeyDown.bind(this),this._onInput=this._onInput.bind(this),this._onClick=this._onClick.bind(this),this._onTouchMove=this._onTouchMove.bind(this),this._onTouchEnd=this._onTouchEnd.bind(this),this._onMouseDown=this._onMouseDown.bind(this),this._onMouseOver=this._onMouseOver.bind(this),this._onFormReset=this._onFormReset.bind(this),this._onSelectKey=this._onSelectKey.bind(this),this._onEnterKey=this._onEnterKey.bind(this),this._onEscapeKey=this._onEscapeKey.bind(this),this._onDirectionKey=this._onDirectionKey.bind(this),this._onDeleteKey=this._onDeleteKey.bind(this),this.passedElement.isActive)return r.silent||console.warn("Trying to initialise Choices on element already initialised",{element:t}),this.initialised=!0,void(this.initialisedOK=!1);this.init(),this._initialItems=this._store.items.map((function(e){return e.value}))}return Object.defineProperty(e,"defaults",{get:function(){return Object.preventExtensions({get options(){return ae},get allOptions(){return z},get templates(){return oe}})},enumerable:!1,configurable:!0}),e.prototype.init=function(){if(!this.initialised&&void 0===this.initialisedOK){this._searcher=new ie(this.config),this._loadChoices(),this._createTemplates(),this._createElements(),this._createStructure(),this._isTextElement&&!this.config.addItems||this.passedElement.element.hasAttribute("disabled")||this.passedElement.element.closest("fieldset:disabled")?this.disable():(this.enable(),this._addEventListeners()),this._initStore(),this.initialised=!0,this.initialisedOK=!0;var e=this.config.callbackOnInit;"function"==typeof e&&e.call(this)}},e.prototype.destroy=function(){this.initialised&&(this._removeEventListeners(),this.passedElement.reveal(),this.containerOuter.unwrap(this.passedElement.element),this._store._listeners=[],this.clearStore(!1),this._stopSearch(),this._templates=e.defaults.templates,this.initialised=!1,this.initialisedOK=void 0)},e.prototype.enable=function(){return this.passedElement.isDisabled&&this.passedElement.enable(),this.containerOuter.isDisabled&&(this._addEventListeners(),this.input.enable(),this.containerOuter.enable()),this},e.prototype.disable=function(){return this.passedElement.isDisabled||this.passedElement.disable(),this.containerOuter.isDisabled||(this._removeEventListeners(),this.input.disable(),this.containerOuter.disable()),this},e.prototype.highlightItem=function(e,t){if(void 0===t&&(t=!0),!e||!e.id)return this;var i=this._store.items.find((function(t){return t.id===e.id}));return!i||i.highlighted||(this._store.dispatch(C(i,!0)),t&&this.passedElement.triggerEvent(f,this._getChoiceForOutput(i))),this},e.prototype.unhighlightItem=function(e,t){if(void 0===t&&(t=!0),!e||!e.id)return this;var i=this._store.items.find((function(t){return t.id===e.id}));return i&&i.highlighted?(this._store.dispatch(C(i,!1)),t&&this.passedElement.triggerEvent("unhighlightItem",this._getChoiceForOutput(i)),this):this},e.prototype.highlightAll=function(){var e=this;return this._store.withTxn((function(){e._store.items.forEach((function(t){t.highlighted||(e._store.dispatch(C(t,!0)),e.passedElement.triggerEvent(f,e._getChoiceForOutput(t)))}))})),this},e.prototype.unhighlightAll=function(){var e=this;return this._store.withTxn((function(){e._store.items.forEach((function(t){t.highlighted&&(e._store.dispatch(C(t,!1)),e.passedElement.triggerEvent(f,e._getChoiceForOutput(t)))}))})),this},e.prototype.removeActiveItemsByValue=function(e){var t=this;return this._store.withTxn((function(){t._store.items.filter((function(t){return t.value===e})).forEach((function(e){return t._removeItem(e)}))})),this},e.prototype.removeActiveItems=function(e){var t=this;return this._store.withTxn((function(){t._store.items.filter((function(t){return t.id!==e})).forEach((function(e){return t._removeItem(e)}))})),this},e.prototype.removeHighlightedItems=function(e){var t=this;return void 0===e&&(e=!1),this._store.withTxn((function(){t._store.highlightedActiveItems.forEach((function(i){t._removeItem(i),e&&t._triggerChange(i.value)}))})),this},e.prototype.showDropdown=function(e){var t=this;return this.dropdown.isActive||(void 0===e&&(e=!this._canSearch),requestAnimationFrame((function(){t.dropdown.show();var i=t.dropdown.element.getBoundingClientRect();t.containerOuter.open(i.bottom,i.height),e||t.input.focus(),t.passedElement.triggerEvent("showDropdown")}))),this},e.prototype.hideDropdown=function(e){var t=this;return this.dropdown.isActive?(requestAnimationFrame((function(){t.dropdown.hide(),t.containerOuter.close(),!e&&t._canSearch&&(t.input.removeActiveDescendant(),t.input.blur()),t.passedElement.triggerEvent("hideDropdown")})),this):this},e.prototype.getValue=function(e){var t=this,i=this._store.items.map((function(i){return e?i.value:t._getChoiceForOutput(i)}));return this._isSelectOneElement||this.config.singleModeForMultiSelect?i[0]:i},e.prototype.setValue=function(e){var t=this;return this.initialisedOK?(this._store.withTxn((function(){e.forEach((function(e){e&&t._addChoice(W(e,!1))}))})),this._searcher.reset(),this):(this._warnChoicesInitFailed("setValue"),this)},e.prototype.setChoiceByValue=function(e){var t=this;return this.initialisedOK?(this._isTextElement||(this._store.withTxn((function(){(Array.isArray(e)?e:[e]).forEach((function(e){return t._findAndSelectChoiceByValue(e)})),t.unhighlightAll()})),this._searcher.reset()),this):(this._warnChoicesInitFailed("setChoiceByValue"),this)},e.prototype.setChoices=function(e,t,n,s,o,r){var a=this;if(void 0===e&&(e=[]),void 0===t&&(t="value"),void 0===n&&(n="label"),void 0===s&&(s=!1),void 0===o&&(o=!0),void 0===r&&(r=!1),!this.initialisedOK)return this._warnChoicesInitFailed("setChoices"),this;if(!this._isSelectElement)throw new TypeError("setChoices can't be used with INPUT based Choices");if("string"!=typeof t||!t)throw new TypeError("value parameter must be a name of 'value' field in passed objects");if("function"==typeof e){var c=e(this);if("function"==typeof Promise&&c instanceof Promise)return new Promise((function(e){return requestAnimationFrame(e)})).then((function(){return a._handleLoadingState(!0)})).then((function(){return c})).then((function(e){return a.setChoices(e,t,n,s,o,r)})).catch((function(e){a.config.silent||console.error(e)})).then((function(){return a._handleLoadingState(!1)})).then((function(){return a}));if(!Array.isArray(c))throw new TypeError(".setChoices first argument function must return either array of choices or Promise, got: ".concat(typeof c));return this.setChoices(c,t,n,!1)}if(!Array.isArray(e))throw new TypeError(".setChoices must be called either with array of choices with a function resulting into Promise of array of choices");return this.containerOuter.removeLoadingState(),this._store.withTxn((function(){o&&(a._isSearching=!1),s&&a.clearChoices(!0,r);var c="value"===t,l="label"===n;e.forEach((function(e){if("choices"in e){var s=e;l||(s=i(i({},s),{label:s[n]})),a._addGroup(W(s,!0))}else{var o=e;l&&c||(o=i(i({},o),{value:o[t],label:o[n]}));var r=W(o,!1);a._addChoice(r),r.placeholder&&!a._hasNonChoicePlaceholder&&(a._placeholderValue=x(r.label))}})),a.unhighlightAll()})),this._searcher.reset(),this},e.prototype.refresh=function(e,t,i){var n=this;return void 0===e&&(e=!1),void 0===t&&(t=!1),void 0===i&&(i=!1),this._isSelectElement?(this._store.withTxn((function(){var s=n.passedElement.optionsAsChoices(),o={};i||n._store.items.forEach((function(e){e.id&&e.active&&e.selected&&(o[e.value]=!0)})),n.clearStore(!1);var r=function(e){i?n._store.dispatch(E(e)):o[e.value]&&(e.selected=!0)};s.forEach((function(e){"choices"in e?e.choices.forEach(r):r(e)})),n._addPredefinedChoices(s,t,e),n._isSearching&&n._searchChoices(n.input.value)})),this):(this.config.silent||console.warn("refresh method can only be used on choices backed by a element"),this)},e.prototype.removeChoice=function(e){var t=this._store.choices.find((function(t){return t.value===e}));return t?(this._clearNotice(),this._store.dispatch(function(e){return{type:o,choice:e}}(t)),this._searcher.reset(),t.selected&&this.passedElement.triggerEvent(m,L(t)),this):this},e.prototype.clearChoices=function(e,t){var i=this;return void 0===e&&(e=!0),void 0===t&&(t=!1),e&&(t?this.passedElement.element.replaceChildren(""):this.passedElement.element.querySelectorAll(":not([selected])").forEach((function(e){e.remove()}))),this.itemList.element.replaceChildren(""),this.choiceList.element.replaceChildren(""),this._clearNotice(),this._store.withTxn((function(){var e=t?[]:i._store.items;i._store.reset(),e.forEach((function(e){i._store.dispatch(y(e)),i._store.dispatch(b(e))}))})),this._searcher.reset(),this},e.prototype.clearStore=function(e){return void 0===e&&(e=!0),this.clearChoices(e,!0),this._stopSearch(),this._lastAddedChoiceId=0,this._lastAddedGroupId=0,this},e.prototype.clearInput=function(){return this.input.clear(!this._isSelectOneElement),this._stopSearch(),this},e.prototype._validateConfig=function(){var e,t,i,n=this.config,s=(e=Y,t=Object.keys(n).sort(),i=Object.keys(e).sort(),t.filter((function(e){return i.indexOf(e)<0})));s.length&&console.warn("Unknown config option(s) passed",s.join(", ")),n.allowHTML&&n.allowHtmlUserInput&&(n.addItems&&console.warn("Warning: allowHTML/allowHtmlUserInput/addItems all being true is strongly not recommended and may lead to XSS attacks"),n.addChoices&&console.warn("Warning: allowHTML/allowHtmlUserInput/addChoices all being true is strongly not recommended and may lead to XSS attacks"))},e.prototype._render=function(e){void 0===e&&(e={choices:!0,groups:!0,items:!0}),this._store.inTxn()||(this._isSelectElement&&(e.choices||e.groups)&&this._renderChoices(),e.items&&this._renderItems())},e.prototype._renderChoices=function(){var e=this;if(this._canAddItems()){var t=this.config,i=this._isSearching,n=this._store,s=n.activeGroups,o=n.activeChoices,r=i?t.searchResultLimit:t.renderChoiceLimit;if(this._isSelectElement){var a=o.filter((function(e){return!e.element}));a.length&&this.passedElement.addOptions(a)}var c=document.createDocumentFragment(),l=function(e){return e.filter((function(e){return!e.placeholder&&(i?(t.searchRenderSelectedChoices||!e.selected)&&!!e.rank:t.renderSelectedChoices||!e.selected)}))},h=t.appendGroupInSearch&&i,d=!1,u=null,p=function(n,s){i?n.sort(F):t.shouldSort&&n.sort(t.sorter);var o=n.length;o=!s&&r>0&&o>r?r:o,o--,n.every((function(n,s){var r=n.choiceEl||e._templates.choice(t,n,t.itemSelectText,h&&n.group?n.group.label:void 0);return n.choiceEl=r,c.appendChild(r),i||!n.selected?d=!0:u||(u=r),s1){var l=i.querySelector(M(n.classNames.placeholder));l&&l.remove()}else a||c||!this._placeholderValue||(a=!0,r(J({selected:!0,value:"",label:this._placeholderValue,placeholder:!0},!1)))}a&&(i.append(s),n.shouldSortItems&&!this._isSelectOneElement&&(t.sort(n.sorter),t.forEach((function(e){var t=o(e);t&&(t.remove(),s.append(t))})),i.append(s))),this._isTextElement&&(this.passedElement.value=t.map((function(e){return e.value})).join(n.delimiter))},e.prototype._displayNotice=function(e,t,i){void 0===i&&(i=!0);var n=this._notice;n&&(n.type===t&&n.text===e||n.type===ne&&(t===ie||t===te))?i&&this.showDropdown(!0):(this._clearNotice(),this._notice=e?{text:e,type:t}:void 0,this._renderNotice(),i&&e&&this.showDropdown(!0))},e.prototype._clearNotice=function(){if(this._notice){var e=this.choiceList.element.querySelector(M(this.config.classNames.notice));e&&e.remove(),this._notice=void 0}},e.prototype._renderNotice=function(e){var t=this._notice;if(t){var i=this._templates.notice(this.config,t.text,t.type);e?e.append(i):this.choiceList.prepend(i)}},e.prototype._getChoiceForOutput=function(e,t){return L(e,t)},e.prototype._triggerChange=function(e){null!=e&&this.passedElement.triggerEvent("change",{value:e})},e.prototype._handleButtonAction=function(e){var t=this,i=this._store.items;if(i.length&&this.config.removeItems&&this.config.removeItemButton){var n=e&&he(e.closest("[data-id]")),s=n&&i.find((function(e){return e.id===n}));s&&this._store.withTxn((function(){if(t._removeItem(s),t._triggerChange(s.value),t._isSelectOneElement&&!t._hasNonChoicePlaceholder){var e=(t.config.shouldSort?t._store.choices.reverse():t._store.choices).find((function(e){return e.placeholder}));e&&(t._addItem(e),t.unhighlightAll(),e.value&&t._triggerChange(e.value))}}))}},e.prototype._handleItemAction=function(e,t){var i=this;void 0===t&&(t=!1);var n=this._store.items;if(n.length&&this.config.removeItems&&!this._isSelectOneElement){var s=he(e);s&&(n.forEach((function(e){e.id!==s||e.highlighted?!t&&e.highlighted&&i.unhighlightItem(e):i.highlightItem(e)})),this.input.focus())}},e.prototype._handleChoiceAction=function(e){var t=this,i=he(e),n=i&&this._store.getChoiceById(i);if(!n||n.disabled)return!1;var s=this.dropdown.isActive;if(!n.selected){if(!this._canAddItems())return!0;this._store.withTxn((function(){t._addItem(n,!0,!0),t.clearInput(),t.unhighlightAll()})),this._triggerChange(n.value)}return s&&this.config.closeDropdownOnSelect&&(this.hideDropdown(!0),this.containerOuter.element.focus()),!0},e.prototype._handleBackspace=function(e){var t=this.config;if(t.removeItems&&e.length){var i=e[e.length-1],n=e.some((function(e){return e.highlighted}));t.editItems&&!n&&i?(this.input.value=i.value,this.input.setWidth(),this._removeItem(i),this._triggerChange(i.value)):(n||this.highlightItem(i,!1),this.removeHighlightedItems(!0))}},e.prototype._loadChoices=function(){var e,t=this,i=this.config;if(this._isTextElement){if(this._presetChoices=i.items.map((function(e){return J(e,!1)})),this.passedElement.value){var n=this.passedElement.value.split(i.delimiter).map((function(e){return J(e,!1,t.config.allowHtmlUserInput)}));this._presetChoices=this._presetChoices.concat(n)}this._presetChoices.forEach((function(e){e.selected=!0}))}else if(this._isSelectElement){this._presetChoices=i.choices.map((function(e){return J(e,!0)}));var s=this.passedElement.optionsAsChoices();s&&(e=this._presetChoices).push.apply(e,s)}},e.prototype._handleLoadingState=function(e){void 0===e&&(e=!0);var t=this.itemList.element;e?(this.disable(),this.containerOuter.addLoadingState(),this._isSelectOneElement?t.replaceChildren(this._templates.placeholder(this.config,this.config.loadingText)):this.input.placeholder=this.config.loadingText):(this.enable(),this.containerOuter.removeLoadingState(),this._isSelectOneElement?(t.replaceChildren(""),this._render()):this.input.placeholder=this._placeholderValue||"")},e.prototype._handleSearch=function(e){if(this.input.isFocussed)if(null!=e&&e.length>=this.config.searchFloor){var t=this.config.searchChoices?this._searchChoices(e):0;null!==t&&this.passedElement.triggerEvent(p,{value:e,resultCount:t})}else this._store.choices.some((function(e){return!e.active}))&&this._stopSearch()},e.prototype._canAddItems=function(){var e=this.config,t=e.maxItemCount,i=e.maxItemText;return!e.singleModeForMultiSelect&&t>0&&t<=this._store.items.length?(this.choiceList.element.replaceChildren(""),this._notice=void 0,this._displayNotice("function"==typeof i?i(t):i,ne),!1):(this._notice&&this._notice.type===ne&&this._clearNotice(),!0)},e.prototype._canCreateItem=function(e){var t=this.config,i=!0,n="";if(i&&"function"==typeof t.addItemFilter&&!t.addItemFilter(e)&&(i=!1,n=D(t.customAddItemText,e,void 0)),i&&this._store.choices.find((function(i){return t.valueComparer(i.value,e)}))){if(this._isSelectElement)return this._displayNotice("",ne),!1;t.duplicateItemsAllowed||(i=!1,n=D(t.uniqueItemText,e,void 0))}return i&&(n=D(t.addItemText,e,void 0)),n&&this._displayNotice(n,ne),i},e.prototype._searchChoices=function(e){var t=e.trim().replace(/\s{2,}/," ");if(!t.length||t===this._currentValue)return null;var i=this._searcher;i.isEmptyIndex()&&i.index(this._store.searchableChoices);var n=i.search(t);this._currentValue=t,this._highlightPosition=0,this._isSearching=!0;var s=this._notice;return(s&&s.type)!==ne&&(n.length?this._clearNotice():this._displayNotice(O(this.config.noResultsText),ie)),this._store.dispatch(function(e){return{type:r,results:e}}(n)),n.length},e.prototype._stopSearch=function(){this._isSearching&&(this._currentValue="",this._isSearching=!1,this._clearNotice(),this._store.dispatch({type:a,active:!0}),this.passedElement.triggerEvent(p,{value:"",resultCount:0}))},e.prototype._addEventListeners=function(){var e=this._docRoot,t=this.containerOuter.element,i=this.input.element,n=this.passedElement.element;e.addEventListener("touchend",this._onTouchEnd,!0),t.addEventListener("keydown",this._onKeyDown,!0),t.addEventListener("mousedown",this._onMouseDown,!0),e.addEventListener("click",this._onClick,{passive:!0}),e.addEventListener("touchmove",this._onTouchMove,{passive:!0}),this.dropdown.element.addEventListener("mouseover",this._onMouseOver,{passive:!0}),this._isSelectOneElement&&(t.addEventListener("focus",this._onFocus,{passive:!0}),t.addEventListener("blur",this._onBlur,{passive:!0})),i.addEventListener("keyup",this._onKeyUp,{passive:!0}),i.addEventListener("input",this._onInput,{passive:!0}),i.addEventListener("focus",this._onFocus,{passive:!0}),i.addEventListener("blur",this._onBlur,{passive:!0}),i.form&&i.form.addEventListener("reset",this._onFormReset,{passive:!0}),n.hasAttribute("required")&&(n.addEventListener("change",this._onChange,{passive:!0}),n.addEventListener("invalid",this._onInvalid,{passive:!0})),this.input.addEventListeners()},e.prototype._removeEventListeners=function(){var e=this._docRoot,t=this.containerOuter.element,i=this.input.element,n=this.passedElement.element;e.removeEventListener("touchend",this._onTouchEnd,!0),t.removeEventListener("keydown",this._onKeyDown,!0),t.removeEventListener("mousedown",this._onMouseDown,!0),e.removeEventListener("click",this._onClick),e.removeEventListener("touchmove",this._onTouchMove),this.dropdown.element.removeEventListener("mouseover",this._onMouseOver),this._isSelectOneElement&&(t.removeEventListener("focus",this._onFocus),t.removeEventListener("blur",this._onBlur)),i.removeEventListener("keyup",this._onKeyUp),i.removeEventListener("input",this._onInput),i.removeEventListener("focus",this._onFocus),i.removeEventListener("blur",this._onBlur),i.form&&i.form.removeEventListener("reset",this._onFormReset),n.hasAttribute("required")&&(n.removeEventListener("change",this._onChange),n.removeEventListener("invalid",this._onInvalid)),this.input.removeEventListeners()},e.prototype._onKeyDown=function(e){var t=e.keyCode,i=this.dropdown.isActive,n=1===e.key.length||2===e.key.length&&e.key.charCodeAt(0)>=55296||"Unidentified"===e.key;switch(this._isTextElement||i||27===t||9===t||16===t||(this.showDropdown(),!this.input.isFocussed&&n&&(this.input.value+=e.key," "===e.key&&e.preventDefault())),t){case 65:return this._onSelectKey(e,this.itemList.element.hasChildNodes());case 13:return this._onEnterKey(e,i);case 27:return this._onEscapeKey(e,i);case 38:case 33:case 40:case 34:return this._onDirectionKey(e,i);case 8:case 46:return this._onDeleteKey(e,this._store.items,this.input.isFocussed)}},e.prototype._onKeyUp=function(){this._canSearch=this.config.searchEnabled},e.prototype._onInput=function(){var e=this.input.value;e?this._canAddItems()&&(this._canSearch&&this._handleSearch(e),this._canAddUserChoices&&(this._canCreateItem(e),this._isSelectElement&&(this._highlightPosition=0,this._highlightChoice()))):this._isTextElement?this.hideDropdown(!0):this._stopSearch()},e.prototype._onSelectKey=function(e,t){(e.ctrlKey||e.metaKey)&&t&&(this._canSearch=!1,this.config.removeItems&&!this.input.value&&this.input.element===document.activeElement&&this.highlightAll())},e.prototype._onEnterKey=function(e,t){var i=this,n=this.input.value,s=e.target;if(e.preventDefault(),s&&s.hasAttribute("data-button"))this._handleButtonAction(s);else if(t){var o=this.dropdown.element.querySelector(M(this.config.classNames.highlightedState));if(!o||!this._handleChoiceAction(o))if(s&&n){if(this._canAddItems()){var r=!1;this._store.withTxn((function(){if(!(r=i._findAndSelectChoiceByValue(n,!0))){if(!i._canAddUserChoices)return;if(!i._canCreateItem(n))return;i._addChoice(J(n,!1,i.config.allowHtmlUserInput),!0,!0),r=!0}i.clearInput(),i.unhighlightAll()})),r&&(this._triggerChange(n),this.config.closeDropdownOnSelect&&this.hideDropdown(!0))}}else this.hideDropdown(!0)}else(this._isSelectElement||this._notice)&&this.showDropdown()},e.prototype._onEscapeKey=function(e,t){t&&(e.stopPropagation(),this.hideDropdown(!0),this._stopSearch(),this.containerOuter.element.focus())},e.prototype._onDirectionKey=function(e,t){var i=e.keyCode;if(t||this._isSelectOneElement){this.showDropdown(),this._canSearch=!1;var n=40===i||34===i?1:-1,s=void 0;if(e.metaKey||34===i||33===i)s=this.dropdown.element.querySelector(n>0?"".concat(de,":last-of-type"):de);else{var o=this.dropdown.element.querySelector(M(this.config.classNames.highlightedState));s=o?function(e,t,i){void 0===i&&(i=1);for(var n="".concat(i>0?"next":"previous","ElementSibling"),s=e[n];s;){if(s.matches(t))return s;s=s[n]}return null}(o,de,n):this.dropdown.element.querySelector(de)}s&&(w(s,this.choiceList.element,n)||this.choiceList.scrollToChildElement(s,n),this._highlightChoice(s)),e.preventDefault()}},e.prototype._onDeleteKey=function(e,t,i){this._isSelectOneElement||e.target.value||!i||(this._handleBackspace(t),e.preventDefault())},e.prototype._onTouchMove=function(){this._wasTap&&(this._wasTap=!1)},e.prototype._onTouchEnd=function(e){var t=(e||e.touches[0]).target;this._wasTap&&this.containerOuter.element.contains(t)&&((t===this.containerOuter.element||t===this.containerInner.element)&&(this._isTextElement?this.input.focus():this._isSelectMultipleElement&&this.showDropdown()),e.stopPropagation()),this._wasTap=!0},e.prototype._onMouseDown=function(e){var t=e.target;if(t instanceof Element){if(ce&&this.choiceList.element.contains(t)){var i=this.choiceList.element.firstElementChild;this._isScrollingOnIe="ltr"===this._direction?e.offsetX>=i.offsetWidth:e.offsetXthis._highlightPosition?t[this._highlightPosition]:t[t.length-1])||(i=t[0]),K(i,n),i.setAttribute("aria-selected","true"),this.passedElement.triggerEvent("highlightChoice",{el:i}),this.dropdown.isActive&&(this.input.setActiveDescendant(i.id),this.containerOuter.setActiveDescendant(i.id))}},e.prototype._addItem=function(e,t,i){if(void 0===t&&(t=!0),void 0===i&&(i=!1),!e.id)throw new TypeError("item.id must be set before _addItem is called for a choice/item");if((this.config.singleModeForMultiSelect||this._isSelectOneElement)&&this.removeActiveItems(e.id),this._store.dispatch(b(e)),t){var n=L(e);this.passedElement.triggerEvent("addItem",n),i&&this.passedElement.triggerEvent("choice",n)}},e.prototype._removeItem=function(e){if(e.id){this._store.dispatch(E(e));var t=this._notice;t&&t.type===te&&this._clearNotice(),this.passedElement.triggerEvent(m,L(e))}},e.prototype._addChoice=function(e,t,i){if(void 0===t&&(t=!0),void 0===i&&(i=!1),e.id)throw new TypeError("Can not re-add a choice which has already been added");var n=this.config;if(n.duplicateItemsAllowed||!this._store.choices.find((function(t){return n.valueComparer(t.value,e.value)}))){this._lastAddedChoiceId++,e.id=this._lastAddedChoiceId,e.elementId="".concat(this._baseId,"-").concat(this._idNames.itemChoice,"-").concat(e.id);var s=n.prependValue,o=n.appendValue;s&&(e.value=s+e.value),o&&(e.value+=o.toString()),(s||o)&&e.element&&(e.element.value=e.value),this._clearNotice(),this._store.dispatch(y(e)),e.selected&&this._addItem(e,t,i)}},e.prototype._addGroup=function(e,t){var i=this;if(void 0===t&&(t=!0),e.id)throw new TypeError("Can not re-add a group which has already been added");this._store.dispatch(function(e){return{type:l,group:e}}(e)),e.choices&&(this._lastAddedGroupId++,e.id=this._lastAddedGroupId,e.choices.forEach((function(n){n.group=e,e.disabled&&(n.disabled=!0),i._addChoice(n,t)})))},e.prototype._createTemplates=function(){var e=this,t=this.config.callbackOnCreateTemplates,i={};"function"==typeof t&&(i=t.call(this,A,N,k));var n={};Object.keys(this._templates).forEach((function(t){n[t]=t in i?i[t].bind(e):e._templates[t].bind(e)})),this._templates=n},e.prototype._createElements=function(){var e=this._templates,t=this.config,i=this._isSelectOneElement,n=t.position,s=t.classNames,o=this._elementType;this.containerOuter=new H({element:e.containerOuter(t,this._direction,this._isSelectElement,i,t.searchEnabled,o,t.labelId),classNames:s,type:o,position:n}),this.containerInner=new H({element:e.containerInner(t),classNames:s,type:o,position:n}),this.input=new R({element:e.input(t,this._placeholderValue),classNames:s,type:o,preventPaste:!t.paste}),this.choiceList=new q({element:e.choiceList(t,i)}),this.itemList=new q({element:e.itemList(t,i)}),this.dropdown=new B({element:e.dropdown(t),classNames:s,type:o})},e.prototype._createStructure=function(){var e=this,t=e.containerInner,i=e.containerOuter,n=e.passedElement,s=this.dropdown.element;n.conceal(),t.wrap(n.element),i.wrap(t.element),i.element.appendChild(t.element),i.element.appendChild(s),t.element.appendChild(this.itemList.element),s.appendChild(this.choiceList.element),this._isSelectOneElement?(this.input.placeholder=this.config.searchPlaceholderValue||"",this.config.searchEnabled&&s.insertBefore(this.input.element,s.firstChild)):(this._isSelectMultipleElement&&!this.config.searchEnabled||t.element.appendChild(this.input.element),this._placeholderValue&&(this.input.placeholder=this._placeholderValue),this.input.setWidth()),this._highlightPosition=0,this._isSearching=!1},e.prototype._initStore=function(){var e=this;this._store.subscribe(this._render).withTxn((function(){e._addPredefinedChoices(e._presetChoices,e._isSelectOneElement&&!e._hasNonChoicePlaceholder,!1)})),(!this._store.choices.length||this._isSelectOneElement&&this._hasNonChoicePlaceholder)&&this._render()},e.prototype._addPredefinedChoices=function(e,t,i){var n=this;void 0===t&&(t=!1),void 0===i&&(i=!0),t&&-1===e.findIndex((function(e){return e.selected}))&&e.some((function(e){return!e.disabled&&!("choices"in e)&&(e.selected=!0,!0)})),e.forEach((function(e){"choices"in e?n._isSelectElement&&n._addGroup(e,i):n._addChoice(e,i)}))},e.prototype._findAndSelectChoiceByValue=function(e,t){var i=this;void 0===t&&(t=!1);var n=this._store.choices.find((function(t){return i.config.valueComparer(t.value,e)}));return!(!n||n.disabled||n.selected||(this._addItem(n,!0,t),0))},e.prototype._generatePlaceholderValue=function(){var e=this.config;if(!e.placeholder)return null;if(this._hasNonChoicePlaceholder)return e.placeholderValue;if(this._isSelectElement){var t=this.passedElement.placeholderOption;return t?t.text:null}return null},e.prototype._warnChoicesInitFailed=function(e){if(!this.config.silent){if(!this.initialised)throw new TypeError("".concat(e," called on a non-initialised instance of Choices"));if(!this.initialisedOK)throw new TypeError("".concat(e," called for an element which has multiple instances of Choices initialised on it"))}},e.version="11.2.0",e}()})); diff --git a/assets/scripts/choices.search-prefix.mjs b/assets/scripts/choices.search-prefix.mjs index a5279fe3..f61a8ca1 100644 --- a/assets/scripts/choices.search-prefix.mjs +++ b/assets/scripts/choices.search-prefix.mjs @@ -1,4 +1,4 @@ -/*! choices.js v11.1.0 | © 2025 Josh Johnson | https://github.com/jshjohnson/Choices#readme */ +/*! choices.js v11.2.0 | © 2026 Josh Johnson | https://github.com/jshjohnson/Choices#readme */ /****************************************************************************** Copyright (c) Microsoft Corporation. @@ -202,9 +202,6 @@ var strToEl = (function () { return firstChild; }; })(); -var resolveNoticeFunction = function (fn, value) { - return typeof fn === 'function' ? fn(sanitise(value), value) : fn; -}; var resolveStringFunction = function (fn) { return typeof fn === 'function' ? fn() : fn; }; @@ -236,6 +233,26 @@ var unwrapStringForEscaped = function (s) { } return ''; }; +var getChoiceForOutput = function (choice, keyCode) { + return { + id: choice.id, + highlighted: choice.highlighted, + labelClass: choice.labelClass, + labelDescription: unwrapStringForRaw(choice.labelDescription), + customProperties: choice.customProperties, + disabled: choice.disabled, + active: choice.active, + label: choice.label, + placeholder: choice.placeholder, + value: choice.value, + groupValue: choice.group ? choice.group.label : undefined, + element: choice.element, + keyCode: keyCode, + }; +}; +var resolveNoticeFunction = function (fn, value, item) { + return typeof fn === 'function' ? fn(sanitise(value), unwrapStringForRaw(value), item) : fn; +}; var escapeForTemplate = function (allowHTML, s) { return allowHTML ? unwrapStringForEscaped(s) : sanitise(s); }; @@ -403,6 +420,12 @@ var Container = /** @class */ (function () { Container.prototype.removeFocusState = function () { removeClassesFromElement(this.element, this.classNames.focusState); }; + Container.prototype.addInvalidState = function () { + addClassesToElement(this.element, this.classNames.invalidState); + }; + Container.prototype.removeInvalidState = function () { + removeClassesFromElement(this.element, this.classNames.invalidState); + }; Container.prototype.enable = function () { removeClassesFromElement(this.element, this.classNames.disabledState); this.element.removeAttribute('aria-disabled'); @@ -868,7 +891,9 @@ var WrappedSelect = /** @class */ (function (_super) { highlighted: false, placeholder: this.extractPlaceholder && (!option.value || option.hasAttribute('placeholder')), labelClass: typeof option.dataset.labelClass !== 'undefined' ? stringToHtmlClass(option.dataset.labelClass) : undefined, - labelDescription: typeof option.dataset.labelDescription !== 'undefined' ? option.dataset.labelDescription : undefined, + labelDescription: typeof option.dataset.labelDescription !== 'undefined' + ? { trusted: option.dataset.labelDescription } + : undefined, customProperties: parseCustomProperties(option.dataset.customProperties), }; }; @@ -914,6 +939,7 @@ var DEFAULT_CLASSNAMES = { selectedState: ['is-selected'], flippedState: ['is-flipped'], loadingState: ['is-loading'], + invalidState: ['is-invalid'], notice: ['choices__notice'], addChoice: ['choices__item--selectable', 'add-choice'], noResults: ['has-no-results'], @@ -941,6 +967,7 @@ var DEFAULT_CONFIG = { paste: true, searchEnabled: true, searchChoices: true, + searchDisabledChoices: false, searchFloor: 1, searchResultLimit: 4, searchFields: ['label', 'value'], @@ -956,6 +983,7 @@ var DEFAULT_CONFIG = { prependValue: null, appendValue: null, renderSelectedChoices: 'auto', + searchRenderSelectedChoices: true, loadingText: 'Loading...', noResultsText: 'No results found', noChoicesText: 'No choices to choose from', @@ -964,7 +992,9 @@ var DEFAULT_CONFIG = { customAddItemText: 'Only values matching specific conditions can be added', addItemText: function (value) { return "Press Enter to add \"".concat(value, "\""); }, removeItemIconText: function () { return "Remove item"; }, - removeItemLabelText: function (value) { return "Remove item: ".concat(value); }, + removeItemLabelText: function (value, _valueRaw, i) { + return "Remove item: ".concat(i ? sanitise(i.label) : value); + }, maxItemText: function (maxItemCount) { return "Only ".concat(maxItemCount, " values can be added"); }, valueComparer: function (value1, value2) { return value1 === value2; }, fuseOptions: { @@ -1265,7 +1295,8 @@ var Store = /** @class */ (function () { * Get choices that can be searched (excluding placeholders or disabled choices) */ get: function () { - return this.choices.filter(function (choice) { return !choice.disabled && !choice.placeholder; }); + var context = this._context; + return this.choices.filter(function (choice) { return !choice.placeholder && (context.searchDisabledChoices || !choice.disabled); }); }, enumerable: false, configurable: true @@ -1378,7 +1409,7 @@ var assignCustomProperties = function (el, choice, withCustomProperties) { dataset.labelClass = getClassNames(labelClass).join(' '); } if (labelDescription) { - dataset.labelDescription = labelDescription; + dataset.labelDescription = unwrapStringForRaw(labelDescription); } if (withCustomProperties && customProperties) { if (typeof customProperties === 'string') { @@ -1485,8 +1516,9 @@ var templates = { var removeButton = document.createElement('button'); removeButton.type = 'button'; addClassesToElement(removeButton, button); - setElementHtml(removeButton, true, resolveNoticeFunction(removeItemIconText, choice.value)); - var REMOVE_ITEM_LABEL = resolveNoticeFunction(removeItemLabelText, choice.value); + var eventChoice = getChoiceForOutput(choice); + setElementHtml(removeButton, true, resolveNoticeFunction(removeItemIconText, choice.value, eventChoice)); + var REMOVE_ITEM_LABEL = resolveNoticeFunction(removeItemLabelText, choice.value, eventChoice); if (REMOVE_ITEM_LABEL) { removeButton.setAttribute('aria-label', REMOVE_ITEM_LABEL); } @@ -1591,6 +1623,7 @@ var templates = { else { addClassesToElement(div, itemSelectable); div.dataset.choiceSelectable = ''; + div.setAttribute('aria-selected', choice.selected ? 'true' : 'false'); } return div; }, @@ -1760,7 +1793,7 @@ var Choices = /** @class */ (function () { this.initialised = false; this._store = new Store(config); this._currentValue = ''; - config.searchEnabled = (!isText && config.searchEnabled) || isSelectMultiple; + config.searchEnabled = !isText && config.searchEnabled; this._canSearch = config.searchEnabled; this._isScrollingOnIe = false; this._highlightPosition = 0; @@ -1800,6 +1833,8 @@ var Choices = /** @class */ (function () { this._onEscapeKey = this._onEscapeKey.bind(this); this._onDirectionKey = this._onDirectionKey.bind(this); this._onDeleteKey = this._onDeleteKey.bind(this); + this._onChange = this._onChange.bind(this); + this._onInvalid = this._onInvalid.bind(this); // If element has already been initialised with Choices, fail silently if (this.passedElement.isActive) { if (!config.silent) { @@ -1906,7 +1941,7 @@ var Choices = /** @class */ (function () { } this._store.dispatch(highlightItem(choice, true)); if (runEvent) { - this.passedElement.triggerEvent(EventType.highlightItem, this._getChoiceForOutput(choice)); + this.passedElement.triggerEvent(EventType.highlightItem, getChoiceForOutput(choice)); } return this; }; @@ -1921,7 +1956,7 @@ var Choices = /** @class */ (function () { } this._store.dispatch(highlightItem(choice, false)); if (runEvent) { - this.passedElement.triggerEvent(EventType.unhighlightItem, this._getChoiceForOutput(choice)); + this.passedElement.triggerEvent(EventType.unhighlightItem, getChoiceForOutput(choice)); } return this; }; @@ -1931,7 +1966,7 @@ var Choices = /** @class */ (function () { _this._store.items.forEach(function (item) { if (!item.highlighted) { _this._store.dispatch(highlightItem(item, true)); - _this.passedElement.triggerEvent(EventType.highlightItem, _this._getChoiceForOutput(item)); + _this.passedElement.triggerEvent(EventType.highlightItem, getChoiceForOutput(item)); } }); }); @@ -1943,7 +1978,7 @@ var Choices = /** @class */ (function () { _this._store.items.forEach(function (item) { if (item.highlighted) { _this._store.dispatch(highlightItem(item, false)); - _this.passedElement.triggerEvent(EventType.highlightItem, _this._getChoiceForOutput(item)); + _this.passedElement.triggerEvent(EventType.highlightItem, getChoiceForOutput(item)); } }); }); @@ -1998,6 +2033,11 @@ var Choices = /** @class */ (function () { _this.input.focus(); } _this.passedElement.triggerEvent(EventType.showDropdown); + var activeElement = _this.choiceList.element.querySelector(getClassNamesSelector(_this.config.classNames.selectedState)); + if (activeElement !== null && !isScrolledIntoView(activeElement, _this.choiceList.element)) { + // We use the native scrollIntoView function instead of choiceList.scrollToChildElement to avoid animated scroll. + activeElement.scrollIntoView(); + } }); return this; }; @@ -2006,6 +2046,7 @@ var Choices = /** @class */ (function () { if (!this.dropdown.isActive) { return this; } + this._removeHighlightedChoices(); requestAnimationFrame(function () { _this.dropdown.hide(); _this.containerOuter.close(); @@ -2018,9 +2059,8 @@ var Choices = /** @class */ (function () { return this; }; Choices.prototype.getValue = function (valueOnly) { - var _this = this; var values = this._store.items.map(function (item) { - return (valueOnly ? item.value : _this._getChoiceForOutput(item)); + return (valueOnly ? item.value : getChoiceForOutput(item)); }); return this._isSelectOneElement || this.config.singleModeForMultiSelect ? values[0] : values; }; @@ -2278,7 +2318,7 @@ var Choices = /** @class */ (function () { // @todo integrate with Store this._searcher.reset(); if (choice.selected) { - this.passedElement.triggerEvent(EventType.removeItem, this._getChoiceForOutput(choice)); + this.passedElement.triggerEvent(EventType.removeItem, getChoiceForOutput(choice)); } return this; }; @@ -2361,13 +2401,7 @@ var Choices = /** @class */ (function () { } var _a = this, config = _a.config, isSearching = _a._isSearching; var _b = this._store, activeGroups = _b.activeGroups, activeChoices = _b.activeChoices; - var renderLimit = 0; - if (isSearching && config.searchResultLimit > 0) { - renderLimit = config.searchResultLimit; - } - else if (config.renderChoiceLimit > 0) { - renderLimit = config.renderChoiceLimit; - } + var renderLimit = isSearching ? config.searchResultLimit : config.renderChoiceLimit; if (this._isSelectElement) { var backingOptions = activeChoices.filter(function (choice) { return !choice.element; }); if (backingOptions.length) { @@ -2377,11 +2411,16 @@ var Choices = /** @class */ (function () { var fragment = document.createDocumentFragment(); var renderableChoices = function (choices) { return choices.filter(function (choice) { - return !choice.placeholder && (isSearching ? !!choice.rank : config.renderSelectedChoices || !choice.selected); + return !choice.placeholder && + (isSearching + ? (config.searchRenderSelectedChoices || !choice.selected) && !!choice.rank + : config.renderSelectedChoices || !choice.selected); }); }; + var showLabel = config.appendGroupInSearch && isSearching; var selectableChoices = false; - var renderChoices = function (choices, withinGroup, groupLabel) { + var highlightedEl = null; + var renderChoices = function (choices, withinGroup) { if (isSearching) { // sortByRank is used to ensure stable sorting, as scores are non-unique // this additionally ensures fuseOptions.sortFn is not ignored @@ -2391,16 +2430,20 @@ var Choices = /** @class */ (function () { choices.sort(config.sorter); } var choiceLimit = choices.length; - choiceLimit = !withinGroup && renderLimit && choiceLimit > renderLimit ? renderLimit : choiceLimit; + choiceLimit = !withinGroup && renderLimit > 0 && choiceLimit > renderLimit ? renderLimit : choiceLimit; choiceLimit--; choices.every(function (choice, index) { // choiceEl being empty signals the contents has probably significantly changed - var dropdownItem = choice.choiceEl || _this._templates.choice(config, choice, config.itemSelectText, groupLabel); + var dropdownItem = choice.choiceEl || + _this._templates.choice(config, choice, config.itemSelectText, showLabel && choice.group ? choice.group.label : undefined); choice.choiceEl = dropdownItem; fragment.appendChild(dropdownItem); if (isSearching || !choice.selected) { selectableChoices = true; } + else if (!highlightedEl) { + highlightedEl = dropdownItem; + } return index < choiceLimit; }); }; @@ -2410,7 +2453,7 @@ var Choices = /** @class */ (function () { } if (!this._hasNonChoicePlaceholder && !isSearching && this._isSelectOneElement) { // If we have a placeholder choice along with groups - renderChoices(activeChoices.filter(function (choice) { return choice.placeholder && !choice.group; }), false, undefined); + renderChoices(activeChoices.filter(function (choice) { return choice.placeholder && !choice.group; }), false); } // If we have grouped options if (activeGroups.length && !isSearching) { @@ -2419,7 +2462,7 @@ var Choices = /** @class */ (function () { } // render Choices without group first, regardless of sort, otherwise they won't be distinguishable // from the last group - renderChoices(activeChoices.filter(function (choice) { return !choice.placeholder && !choice.group; }), false, undefined); + renderChoices(activeChoices.filter(function (choice) { return !choice.placeholder && !choice.group; }), false); activeGroups.forEach(function (group) { var groupChoices = renderableChoices(group.choices); if (groupChoices.length) { @@ -2429,12 +2472,12 @@ var Choices = /** @class */ (function () { dropdownGroup.remove(); fragment.appendChild(dropdownGroup); } - renderChoices(groupChoices, true, config.appendGroupInSearch && isSearching ? group.label : undefined); + renderChoices(groupChoices, true); } }); } else { - renderChoices(renderableChoices(activeChoices), false, undefined); + renderChoices(renderableChoices(activeChoices), false); } } if (!selectableChoices && (isSearching || !fragment.children.length || !config.renderSelectedChoices)) { @@ -2448,9 +2491,7 @@ var Choices = /** @class */ (function () { } this._renderNotice(fragment); this.choiceList.element.replaceChildren(fragment); - if (selectableChoices) { - this._highlightChoice(); - } + this._highlightChoice(highlightedEl); }; Choices.prototype._renderItems = function () { var _this = this; @@ -2560,23 +2601,12 @@ var Choices = /** @class */ (function () { } } }; + /** + * @deprecated Use utils.getChoiceForOutput + */ // eslint-disable-next-line class-methods-use-this Choices.prototype._getChoiceForOutput = function (choice, keyCode) { - return { - id: choice.id, - highlighted: choice.highlighted, - labelClass: choice.labelClass, - labelDescription: choice.labelDescription, - customProperties: choice.customProperties, - disabled: choice.disabled, - active: choice.active, - label: choice.label, - placeholder: choice.placeholder, - value: choice.value, - groupValue: choice.group ? choice.group.label : undefined, - element: choice.element, - keyCode: keyCode, - }; + return getChoiceForOutput(choice, keyCode); }; Choices.prototype._triggerChange = function (value) { if (value === undefined || value === null) { @@ -2592,7 +2622,7 @@ var Choices = /** @class */ (function () { if (!items.length || !this.config.removeItems || !this.config.removeItemButton) { return; } - var id = element && parseDataSetId(element.parentElement); + var id = element && parseDataSetId(element.closest('[data-id]')); var itemToRemove = id && items.find(function (item) { return item.id === id; }); if (!itemToRemove) { return; @@ -2781,7 +2811,7 @@ var Choices = /** @class */ (function () { var notice = ''; if (canAddItem && typeof config.addItemFilter === 'function' && !config.addItemFilter(value)) { canAddItem = false; - notice = resolveNoticeFunction(config.customAddItemText, value); + notice = resolveNoticeFunction(config.customAddItemText, value, undefined); } if (canAddItem) { var foundChoice = this._store.choices.find(function (choice) { return config.valueComparer(choice.value, value); }); @@ -2793,12 +2823,12 @@ var Choices = /** @class */ (function () { } if (!config.duplicateItemsAllowed) { canAddItem = false; - notice = resolveNoticeFunction(config.uniqueItemText, value); + notice = resolveNoticeFunction(config.uniqueItemText, value, undefined); } } } if (canAddItem) { - notice = resolveNoticeFunction(config.addItemText, value); + notice = resolveNoticeFunction(config.addItemText, value, undefined); } if (notice) { this._displayNotice(notice, NoticeTypes.addChoice); @@ -2849,6 +2879,7 @@ var Choices = /** @class */ (function () { var documentElement = this._docRoot; var outerElement = this.containerOuter.element; var inputElement = this.input.element; + var passedElement = this.passedElement.element; // capture events - can cancel event processing or propagation documentElement.addEventListener('touchend', this._onTouchEnd, true); outerElement.addEventListener('keydown', this._onKeyDown, true); @@ -2886,12 +2917,21 @@ var Choices = /** @class */ (function () { passive: true, }); } + if (passedElement.hasAttribute('required')) { + passedElement.addEventListener('change', this._onChange, { + passive: true, + }); + passedElement.addEventListener('invalid', this._onInvalid, { + passive: true, + }); + } this.input.addEventListeners(); }; Choices.prototype._removeEventListeners = function () { var documentElement = this._docRoot; var outerElement = this.containerOuter.element; var inputElement = this.input.element; + var passedElement = this.passedElement.element; documentElement.removeEventListener('touchend', this._onTouchEnd, true); outerElement.removeEventListener('keydown', this._onKeyDown, true); outerElement.removeEventListener('mousedown', this._onMouseDown, true); @@ -2909,6 +2949,10 @@ var Choices = /** @class */ (function () { if (inputElement.form) { inputElement.form.removeEventListener('reset', this._onFormReset); } + if (passedElement.hasAttribute('required')) { + passedElement.removeEventListener('change', this._onChange); + passedElement.removeEventListener('invalid', this._onInvalid); + } this.input.removeEventListeners(); }; Choices.prototype._onKeyDown = function (event) { @@ -3158,7 +3202,7 @@ var Choices = /** @class */ (function () { */ Choices.prototype._onMouseDown = function (event) { var target = event.target; - if (!(target instanceof HTMLElement)) { + if (!(target instanceof Element)) { return; } // If we have our mouse down on the scrollbar and are on IE11... @@ -3267,7 +3311,7 @@ var Choices = /** @class */ (function () { // Remove the focus state when the past outerContainer was the target containerOuter.removeFocusState(); // Also close the dropdown if search is disabled - if (!this._canSearch) { + if (!this.config.searchEnabled) { this.hideDropdown(true); } } @@ -3291,6 +3335,27 @@ var Choices = /** @class */ (function () { } }); }; + Choices.prototype._onChange = function (event) { + if (!event.target.checkValidity()) { + return; + } + this.containerOuter.removeInvalidState(); + }; + Choices.prototype._onInvalid = function () { + this.containerOuter.addInvalidState(); + }; + /** + * Removes any highlighted choice options + */ + Choices.prototype._removeHighlightedChoices = function () { + var highlightedState = this.config.classNames.highlightedState; + var highlightedChoices = Array.from(this.dropdown.element.querySelectorAll(getClassNamesSelector(highlightedState))); + // Remove any highlighted choices + highlightedChoices.forEach(function (choice) { + removeClassesFromElement(choice, highlightedState); + choice.setAttribute('aria-selected', 'false'); + }); + }; Choices.prototype._highlightChoice = function (el) { if (el === void 0) { el = null; } var choices = Array.from(this.dropdown.element.querySelectorAll(selectableChoiceIdentifier)); @@ -3299,12 +3364,7 @@ var Choices = /** @class */ (function () { } var passedEl = el; var highlightedState = this.config.classNames.highlightedState; - var highlightedChoices = Array.from(this.dropdown.element.querySelectorAll(getClassNamesSelector(highlightedState))); - // Remove any highlighted choices - highlightedChoices.forEach(function (choice) { - removeClassesFromElement(choice, highlightedState); - choice.setAttribute('aria-selected', 'false'); - }); + this._removeHighlightedChoices(); if (passedEl) { this._highlightPosition = choices.indexOf(passedEl); } @@ -3345,9 +3405,10 @@ var Choices = /** @class */ (function () { } this._store.dispatch(addItem(item)); if (withEvents) { - this.passedElement.triggerEvent(EventType.addItem, this._getChoiceForOutput(item)); + var eventChoice = getChoiceForOutput(item); + this.passedElement.triggerEvent(EventType.addItem, eventChoice); if (userTriggered) { - this.passedElement.triggerEvent(EventType.choice, this._getChoiceForOutput(item)); + this.passedElement.triggerEvent(EventType.choice, eventChoice); } } }; @@ -3360,7 +3421,7 @@ var Choices = /** @class */ (function () { if (notice && notice.type === NoticeTypes.noChoices) { this._clearNotice(); } - this.passedElement.triggerEvent(EventType.removeItem, this._getChoiceForOutput(item)); + this.passedElement.triggerEvent(EventType.removeItem, getChoiceForOutput(item)); }; Choices.prototype._addChoice = function (choice, withEvents, userTriggered) { if (withEvents === void 0) { withEvents = true; } @@ -3475,24 +3536,24 @@ var Choices = /** @class */ (function () { containerInner.wrap(passedElement.element); // Wrapper inner container with outer container containerOuter.wrap(containerInner.element); - if (this._isSelectOneElement) { - this.input.placeholder = this.config.searchPlaceholderValue || ''; - } - else { - if (this._placeholderValue) { - this.input.placeholder = this._placeholderValue; - } - this.input.setWidth(); - } containerOuter.element.appendChild(containerInner.element); containerOuter.element.appendChild(dropdownElement); containerInner.element.appendChild(this.itemList.element); dropdownElement.appendChild(this.choiceList.element); - if (!this._isSelectOneElement) { - containerInner.element.appendChild(this.input.element); + if (this._isSelectOneElement) { + this.input.placeholder = this.config.searchPlaceholderValue || ''; + if (this.config.searchEnabled) { + dropdownElement.insertBefore(this.input.element, dropdownElement.firstChild); + } } - else if (this.config.searchEnabled) { - dropdownElement.insertBefore(this.input.element, dropdownElement.firstChild); + else { + if (!this._isSelectMultipleElement || this.config.searchEnabled) { + containerInner.element.appendChild(this.input.element); + } + if (this._placeholderValue) { + this.input.placeholder = this._placeholderValue; + } + this.input.setWidth(); } this._highlightPosition = 0; this._isSearching = false; @@ -3575,7 +3636,7 @@ var Choices = /** @class */ (function () { throw new TypeError("".concat(caller, " called for an element which has multiple instances of Choices initialised on it")); } }; - Choices.version = '11.1.0'; + Choices.version = '11.2.0'; return Choices; }()); diff --git a/assets/styles/base.css b/assets/styles/base.css index 4672d7ec..b890ae3e 100644 --- a/assets/styles/base.css +++ b/assets/styles/base.css @@ -1,6 +1,36 @@ /* ============================================= = Generic styling = ============================================= */ +:root { + --color-primary: #005F75; +} + +@media (prefers-color-scheme: dark) { + :root { + /* Demo defaults */ + --body-bg: #272a2b; + --text-color: #cacaca; + --color-primary: #38daff; + --section-bg: #181a1b; + --section-color: #cacaca; + --hr-border: #373a3d; + --choices-primary-color: #38daff; + --choices-item-color: black; + --choices-bg-color: #101010; + --choices-bg-color-dropdown: #101010; + --choices-keyline-color: #3b3e40; + --choices-bg-color-disabled: #181a1b; + --choices-item-disabled-color: #eee; + --choices-disabled-color: #2d2d2d; + --choices-highlighted-color: #16292d; + --choices-icon-cross: url("data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjEiIGhlaWdodD0iMjEiIHZpZXdCb3g9IjAgMCAyMSAyMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSIjMDAwIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxwYXRoIGQ9Ik0yLjU5Mi4wNDRsMTguMzY0IDE4LjM2NC0yLjU0OCAyLjU0OEwuMDQ0IDIuNTkyeiIvPjxwYXRoIGQ9Ik0wIDE4LjM2NEwxOC4zNjQgMGwyLjU0OCAyLjU0OEwyLjU0OCAyMC45MTJ6Ii8+PC9nPjwvc3ZnPg=="); + --choices-icon-cross-inverse: url("data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjEiIGhlaWdodD0iMjEiIHZpZXdCb3g9IjAgMCAyMSAyMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSIjRkZGIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxwYXRoIGQ9Ik0yLjU5Mi4wNDRsMTguMzY0IDE4LjM2NC0yLjU0OCAyLjU0OEwuMDQ0IDIuNTkyeiIvPjxwYXRoIGQ9Ik0wIDE4LjM2NEwxOC4zNjQgMGwyLjU0OCAyLjU0OEwyLjU0OCAyMC45MTJ6Ii8+PC9nPjwvc3ZnPg=="); + color-scheme: dark; + } + input, select { + color: #fff; + } +} * { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; @@ -24,8 +54,8 @@ body { font-family: "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; font-size: 16px; line-height: 1.4; - color: #fff; - background-color: #333; + color: var(--text-color, #fff); + background-color: var(--body-bg, #333); overflow-x: hidden; } @@ -46,7 +76,7 @@ hr { display: block; margin: 30px 0; border: 0; - border-bottom: 1px solid #eaeaea; + border-bottom: 1px solid var(--hr-border, #eaeaea); height: 1px; } @@ -65,7 +95,7 @@ h6 { a, a:visited, a:focus { - color: #fff; + color: var(--link-color, #fff); text-decoration: none; font-weight: 600; } @@ -73,9 +103,9 @@ a:focus { .form-control { display: block; width: 100%; - background-color: #f9f9f9; + background-color: var(--form-bg, #f9f9f9); padding: 12px; - border: 1px solid #ddd; + border: 1px solid var(--form-boder, #ddd); border-radius: 2.5px; font-size: 14px; appearance: none; @@ -129,14 +159,14 @@ label + p { } .section { - background-color: #fff; + background-color: var(--section-bg, #fff); padding: 24px; - color: #333; + color: var(--section-color, #333); } .section a, .section a:visited, .section a:focus { - color: #005F75; + color: var(--link-color-section, var(--color-primary)); } .logo { diff --git a/assets/styles/base.css.map b/assets/styles/base.css.map index 5ae6c14f..db995038 100644 --- a/assets/styles/base.css.map +++ b/assets/styles/base.css.map @@ -1 +1 @@ -{"version":3,"sourceRoot":"","sources":["../../../src/styles/base.scss"],"names":[],"mappings":"AAAA;AAAA;AAAA;AAYA;EACE;EACA;;;AAGF;AAAA;AAAA;EAGE;;;AAGF;AAAA;EAEE;EACA;EACA;EACA;;;AAGF;EACE;EACA;EACA;EACA;EACA;EACA;;;AAGF;EACE;EACA;EACA;EACA;EACA;;;AAGF;EACE;EACA;;;AAGF;EACE;EACA;EACA;EACA;EACA;;;AAGF;AAAA;AAAA;AAAA;AAAA;AAAA;EAME;EACA;EACA;EACA;;;AAGF;AAAA;AAAA;EAGE;EACA;EACA;;;AAGF;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,eAtFiB;;;AAyFnB;AAAA;EAEE,WA1FoB;;;AA6FtB;AAAA;EAEE,WA9FoB;;;AAiGtB;AAAA;EAEE,WAlGoB;;;AAqGtB;AAAA;EAEE,WAtGoB;;;AAyGtB;AAAA;EAEE,WA1GoB;;;AA6GtB;AAAA;EAEE,WA9GoB;;;AAiHtB;EACE;;;AAGF;EACE;EACA;EACA;EACA;;AAEA;EANF;IAOI;;;;AAIJ;EACE;EACA,SAxIiB;EAyIjB;;AAEA;AAAA;AAAA;EAGE;;;AAIJ;EACE;EACA;;;AAGF;EACE;EACA;EACA;EACA;EACA;EACA;;;AAGF;EACE;;;AAGF;EACE,eArKiB;;;AAwKnB;EACE;;;AAGF;EACE;;;AAGF;EACE;;;AAGF;EACE,eArLiB;;;AAwLnB","file":"base.css"} \ No newline at end of file +{"version":3,"sourceRoot":"","sources":["../../../src/styles/base.scss"],"names":[],"mappings":"AAAA;AAAA;AAAA;AAIA;EACE;;;AAGF;EACE;AACE;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IAEA;;EAGF;IACE;;;AAYJ;EACE;EACA;;;AAGF;AAAA;AAAA;EAGE;;;AAGF;AAAA;EAEE;EACA;EACA;EACA;;;AAGF;EACE;EACA;EACA;EACA;EACA;EACA;;;AAGF;EACE;EACA;EACA;EACA;EACA;;;AAGF;EACE;EACA;;;AAGF;EACE;EACA;EACA;EACA;EACA;;;AAGF;AAAA;AAAA;AAAA;AAAA;AAAA;EAME;EACA;EACA;EACA;;;AAGF;AAAA;AAAA;EAGE;EACA;EACA;;;AAGF;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,eAtFiB;;;AAyFnB;AAAA;EAEE,WA1FoB;;;AA6FtB;AAAA;EAEE,WA9FoB;;;AAiGtB;AAAA;EAEE,WAlGoB;;;AAqGtB;AAAA;EAEE,WAtGoB;;;AAyGtB;AAAA;EAEE,WA1GoB;;;AA6GtB;AAAA;EAEE,WA9GoB;;;AAiHtB;EACE;;;AAGF;EACE;EACA;EACA;EACA;;AAEA;EANF;IAOI;;;;AAIJ;EACE;EACA,SAxIiB;EAyIjB;;AAEA;AAAA;AAAA;EAGE;;;AAIJ;EACE;EACA;;;AAGF;EACE;EACA;EACA;EACA;EACA;EACA;;;AAGF;EACE;;;AAGF;EACE,eArKiB;;;AAwKnB;EACE;;;AAGF;EACE;;;AAGF;EACE;;;AAGF;EACE,eArLiB;;;AAwLnB","file":"base.css"} \ No newline at end of file diff --git a/assets/styles/base.min.css b/assets/styles/base.min.css index ebba2030..714f406d 100644 --- a/assets/styles/base.min.css +++ b/assets/styles/base.min.css @@ -1 +1 @@ -*{-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}*,::after,::before{box-sizing:border-box}body,html{position:relative;margin:0;width:100%;height:100%}body{font-family:"Helvetica Neue",Helvetica,Arial,"Lucida Grande",sans-serif;font-size:16px;line-height:1.4;color:#fff;background-color:#333;overflow-x:hidden}hr,label{display:block}label,p{margin-bottom:8px}label{font-size:14px;font-weight:500;cursor:pointer}p{margin-top:0}hr{margin:30px 0;border:0;border-bottom:1px solid #eaeaea;height:1px}h1,h2,h3,h4,h5,h6{margin-top:0;margin-bottom:12px;font-weight:400;line-height:1.2}a,a:focus,a:visited{color:#fff;text-decoration:none;font-weight:600}.form-control{display:block;width:100%;background-color:#f9f9f9;padding:12px;border:1px solid #ddd;border-radius:2.5px;font-size:14px;appearance:none;margin-bottom:24px}.h1,h1{font-size:32px}.h2,h2{font-size:24px}.h3,h3{font-size:20px}.h4,h4{font-size:18px}.h5,h5{font-size:16px}.h6,h6{font-size:14px}label+p{margin-top:-4px}.container{display:block;margin:auto;max-width:40em;padding:48px}@media (max-width:620px){.container{padding:0}}.section{background-color:#fff;padding:24px;color:#333}.section a,.section a:focus,.section a:visited{color:#005f75}.logo{display:block;margin-bottom:12px}.logo-img{width:100%;height:auto;display:inline-block;max-width:100%;vertical-align:top;padding:6px 0}.visible-ie{display:none}.push-bottom{margin-bottom:24px}.zero-bottom{margin-bottom:0}.zero-top{margin-top:0}.text-center{text-align:center}[data-test-hook]{margin-bottom:24px} \ No newline at end of file +:root{--color-primary:#005F75}@media (prefers-color-scheme:dark){:root{--body-bg:#272a2b;--text-color:#cacaca;--color-primary:#38daff;--section-bg:#181a1b;--section-color:#cacaca;--hr-border:#373a3d;--choices-primary-color:#38daff;--choices-item-color:black;--choices-bg-color:#101010;--choices-bg-color-dropdown:#101010;--choices-keyline-color:#3b3e40;--choices-bg-color-disabled:#181a1b;--choices-item-disabled-color:#eee;--choices-disabled-color:#2d2d2d;--choices-highlighted-color:#16292d;--choices-icon-cross:url("data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjEiIGhlaWdodD0iMjEiIHZpZXdCb3g9IjAgMCAyMSAyMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSIjMDAwIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxwYXRoIGQ9Ik0yLjU5Mi4wNDRsMTguMzY0IDE4LjM2NC0yLjU0OCAyLjU0OEwuMDQ0IDIuNTkyeiIvPjxwYXRoIGQ9Ik0wIDE4LjM2NEwxOC4zNjQgMGwyLjU0OCAyLjU0OEwyLjU0OCAyMC45MTJ6Ii8+PC9nPjwvc3ZnPg==");--choices-icon-cross-inverse:url("data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjEiIGhlaWdodD0iMjEiIHZpZXdCb3g9IjAgMCAyMSAyMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSIjRkZGIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxwYXRoIGQ9Ik0yLjU5Mi4wNDRsMTguMzY0IDE4LjM2NC0yLjU0OCAyLjU0OEwuMDQ0IDIuNTkyeiIvPjxwYXRoIGQ9Ik0wIDE4LjM2NEwxOC4zNjQgMGwyLjU0OCAyLjU0OEwyLjU0OCAyMC45MTJ6Ii8+PC9nPjwvc3ZnPg==");color-scheme:dark}input,select{color:#fff}}*{-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}*,::after,::before{box-sizing:border-box}body,html{position:relative;margin:0;width:100%;height:100%}body{font-family:"Helvetica Neue",Helvetica,Arial,"Lucida Grande",sans-serif;font-size:16px;line-height:1.4;color:var(--text-color, #fff);background-color:var(--body-bg, #333);overflow-x:hidden}hr,label{display:block}label,p{margin-bottom:8px}label{font-size:14px;font-weight:500;cursor:pointer}p{margin-top:0}hr{margin:30px 0;border:0;border-bottom:1px solid var(--hr-border, #eaeaea);height:1px}h1,h2,h3,h4,h5,h6{margin-top:0;margin-bottom:12px;font-weight:400;line-height:1.2}a,a:focus,a:visited{color:var(--link-color, #fff);text-decoration:none;font-weight:600}.form-control{display:block;width:100%;background-color:var(--form-bg, #f9f9f9);padding:12px;border:1px solid var(--form-boder, #ddd);border-radius:2.5px;font-size:14px;appearance:none;margin-bottom:24px}.h1,h1{font-size:32px}.h2,h2{font-size:24px}.h3,h3{font-size:20px}.h4,h4{font-size:18px}.h5,h5{font-size:16px}.h6,h6{font-size:14px}label+p{margin-top:-4px}.container{display:block;margin:auto;max-width:40em;padding:48px}@media (max-width:620px){.container{padding:0}}.section{background-color:var(--section-bg, #fff);padding:24px;color:var(--section-color, #333)}.section a,.section a:focus,.section a:visited{color:var(--link-color-section, var(--color-primary))}.logo{display:block;margin-bottom:12px}.logo-img{width:100%;height:auto;display:inline-block;max-width:100%;vertical-align:top;padding:6px 0}.visible-ie{display:none}.push-bottom{margin-bottom:24px}.zero-bottom{margin-bottom:0}.zero-top{margin-top:0}.text-center{text-align:center}[data-test-hook]{margin-bottom:24px} \ No newline at end of file diff --git a/assets/styles/choices.css b/assets/styles/choices.css index 05cd925a..f4967e91 100644 --- a/assets/styles/choices.css +++ b/assets/styles/choices.css @@ -4,8 +4,8 @@ .choices { position: relative; overflow: hidden; - margin-bottom: 24px; - font-size: 16px; + margin-bottom: var(--choices-guttering, 24px); + font-size: var(--choices-font-size-lg, 16px); } .choices:focus { outline: none; @@ -16,36 +16,39 @@ .choices.is-open { overflow: visible; } -.choices.is-disabled .choices__inner, -.choices.is-disabled .choices__input { - background-color: #eaeaea; - cursor: not-allowed; +.choices.is-disabled :is(.choices__inner, .choices__input) { + background-color: var(--choices-bg-color-disabled, #eaeaea); + cursor: not-allowed !important; -webkit-user-select: none; user-select: none; } .choices.is-disabled .choices__item { cursor: not-allowed; + color: var(--choices-item-disabled-color, #fff); } .choices [hidden] { - display: none !important; + position: absolute; + inset: 0; + pointer-events: none; + opacity: 0; } .choices[data-type*=select-one] { cursor: pointer; } .choices[data-type*=select-one] .choices__inner { - padding-bottom: 7.5px; + padding-bottom: var(--choices-inner-one-padding, 7.5px); } .choices[data-type*=select-one] .choices__input { display: block; - width: 100%; - padding: 10px; - border-bottom: 1px solid #ddd; - background-color: #fff; + width: var(--choices-width, 100%); + padding: var(--choices-dropdown-item-padding, 10px); + border-bottom: var(--choices-base-border, 1px solid) var(--choices-keyline-color, #ddd); + background-color: var(--choices-bg-color-dropdown, #fff); margin: 0; } .choices[data-type*=select-one] .choices__button { - background-image: url("data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjEiIGhlaWdodD0iMjEiIHZpZXdCb3g9IjAgMCAyMSAyMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSIjMDAwIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxwYXRoIGQ9Ik0yLjU5Mi4wNDRsMTguMzY0IDE4LjM2NC0yLjU0OCAyLjU0OEwuMDQ0IDIuNTkyeiIvPjxwYXRoIGQ9Ik0wIDE4LjM2NEwxOC4zNjQgMGwyLjU0OCAyLjU0OEwyLjU0OCAyMC45MTJ6Ii8+PC9nPjwvc3ZnPg=="); + background-image: var(--choices-icon-cross-inverse, url("data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjEiIGhlaWdodD0iMjEiIHZpZXdCb3g9IjAgMCAyMSAyMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSIjMDAwIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxwYXRoIGQ9Ik0yLjU5Mi4wNDRsMTguMzY0IDE4LjM2NC0yLjU0OCAyLjU0OEwuMDQ0IDIuNTkyeiIvPjxwYXRoIGQ9Ik0wIDE4LjM2NEwxOC4zNjQgMGwyLjU0OCAyLjU0OEwyLjU0OCAyMC45MTJ6Ii8+PC9nPjwvc3ZnPg==")); padding: 0; background-size: 8px; position: absolute; @@ -58,11 +61,11 @@ border-radius: 10em; opacity: 0.25; } -.choices[data-type*=select-one] .choices__button:hover, .choices[data-type*=select-one] .choices__button:focus { - opacity: 1; +.choices[data-type*=select-one] .choices__button:is(:hover, :focus) { + opacity: var(--choices-button-opacity-hover, 1); } .choices[data-type*=select-one] .choices__button:focus { - box-shadow: 0 0 0 2px #005F75; + box-shadow: 0 0 0 2px var(--choices-highlight-color, #005F75); } .choices[data-type*=select-one] .choices__item[data-placeholder] .choices__button { display: none; @@ -72,17 +75,17 @@ height: 0; width: 0; border-style: solid; - border-color: #333 transparent transparent transparent; - border-width: 5px; + border-color: var(--choices-text-color, #333) transparent transparent transparent; + border-width: var(--choices-arrow-size, 5px); position: absolute; - right: 11.5px; + right: var(--choices-arrow-right, 11.5px); top: 50%; - margin-top: -2.5px; + margin-top: var(--choices-arrow-margin-top, -2.5px); pointer-events: none; } .choices[data-type*=select-one].is-open::after { - border-color: transparent transparent #333; - margin-top: -7.5px; + border-color: transparent transparent var(--choices-text-color, #333); + margin-top: var(--choices-arrow-margin-top-open, -7.5px); } .choices[data-type*=select-one][dir=rtl]::after { left: 11.5px; @@ -95,53 +98,49 @@ margin-right: 0; } -.choices[data-type*=select-multiple] .choices__inner, -.choices[data-type*=text] .choices__inner { +.choices:is([data-type*=select-multiple], [data-type*=text]) .choices__inner { cursor: text; } -.choices[data-type*=select-multiple] .choices__button, -.choices[data-type*=text] .choices__button { +.choices:is([data-type*=select-multiple], [data-type*=text]) .choices__button { position: relative; display: inline-block; - margin-top: 0; - margin-right: -4px; - margin-bottom: 0; - margin-left: 8px; - padding-left: 16px; - border-left: 1px solid #003642; - background-image: url("data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjEiIGhlaWdodD0iMjEiIHZpZXdCb3g9IjAgMCAyMSAyMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSIjRkZGIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxwYXRoIGQ9Ik0yLjU5Mi4wNDRsMTguMzY0IDE4LjM2NC0yLjU0OCAyLjU0OEwuMDQ0IDIuNTkyeiIvPjxwYXRoIGQ9Ik0wIDE4LjM2NEwxOC4zNjQgMGwyLjU0OCAyLjU0OEwyLjU0OCAyMC45MTJ6Ii8+PC9nPjwvc3ZnPg=="); - background-size: 8px; - width: 8px; - line-height: 1; - opacity: 0.75; - border-radius: 0; + margin: 0 calc(var(--choices-button-offset, 8px) * -0.5) 0 var(--choices-button-offset, 8px); + padding-left: calc(var(--choices-button-offset, 8px) * 2); + border-left: 1px solid color-mix(in srgb, var(--choices-primary-color, #005F75) 90%, var(--choices-darken, black)); + background-image: var(--choices-icon-cross, url("data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjEiIGhlaWdodD0iMjEiIHZpZXdCb3g9IjAgMCAyMSAyMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSIjRkZGIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxwYXRoIGQ9Ik0yLjU5Mi4wNDRsMTguMzY0IDE4LjM2NC0yLjU0OCAyLjU0OEwuMDQ0IDIuNTkyeiIvPjxwYXRoIGQ9Ik0wIDE4LjM2NEwxOC4zNjQgMGwyLjU0OCAyLjU0OEwyLjU0OCAyMC45MTJ6Ii8+PC9nPjwvc3ZnPg==")); + background-size: var(--choices-button-dimension, 8px); + width: var(--choices-button-dimension, 8px); + line-height: var(--choices-button-line-height, 1); + border-radius: var(--choices-button-border-radius, 0); + opacity: var(--choices-button-opacity, 0.75); } -.choices[data-type*=select-multiple] .choices__button:hover, .choices[data-type*=select-multiple] .choices__button:focus, -.choices[data-type*=text] .choices__button:hover, -.choices[data-type*=text] .choices__button:focus { - opacity: 1; +.choices:is([data-type*=select-multiple], [data-type*=text]) .choices__button:is(:hover, :focus) { + --choices-button-opacity: var(--choices-button-opacity-hover, 1); } .choices__inner { display: inline-block; vertical-align: top; - width: 100%; - background-color: #f9f9f9; - padding: 7.5px 7.5px 3.75px; - border: 1px solid #ddd; - border-radius: 2.5px; - font-size: 14px; - min-height: 44px; + width: var(--choices-width, 100%); + background-color: var(--choices-bg-color, #f9f9f9); + padding: var(--choices-inner-padding, 7.5px 7.5px 3.75px); + border: var(--choices-base-border, 1px solid) var(--choices-keyline-color, #ddd); + border-radius: var(--choices-border-radius, 2.5px); + font-size: var(--choices-font-size-md, 14px); + min-height: var(--choices-input-height, 44px); overflow: hidden; } .is-focused .choices__inner, .is-open .choices__inner { - border-color: #b7b7b7; + border-color: color-mix(in srgb, var(--choices-keyline-color, #ddd) 85%, var(--choices-darken, black)); } .is-open .choices__inner { - border-radius: 2.5px 2.5px 0 0; + border-radius: var(--choices-border-radius, 2.5px) var(--choices-border-radius, 2.5px) 0 0; +} +.is-invalid .choices__inner { + border-color: var(--choices-invalid-color, #d33141); } .is-flipped.is-open .choices__inner { - border-radius: 0 0 2.5px 2.5px; + border-radius: 0 0 var(--choices-border-radius, 2.5px) var(--choices-border-radius, 2.5px); } .choices__list { @@ -151,15 +150,15 @@ } .choices__list--single { display: inline-block; - padding: 4px 16px 4px 4px; - width: 100%; + padding: var(--choices-list-single-padding, 4px 16px 4px 4px); + width: var(--choices-width, 100%); } [dir=rtl] .choices__list--single { padding-right: 4px; padding-left: 16px; } .choices__list--single .choices__item { - width: 100%; + width: var(--choices-width, 100%); } .choices__list--multiple { @@ -168,15 +167,15 @@ .choices__list--multiple .choices__item { display: inline-block; vertical-align: middle; - border-radius: 20px; - padding: 4px 10px; - font-size: 12px; + border-radius: var(--choices-border-radius-item, 20px); + padding: var(--choices-multiple-item-padding, 4px 10px); + font-size: var(--choices-font-size-sm, 12px); font-weight: 500; - margin-right: 3.75px; - margin-bottom: 3.75px; - background-color: #005F75; - border: 1px solid #004a5c; - color: #fff; + margin-right: var(--choices-multiple-item-margin, 3.75px); + margin-bottom: var(--choices-multiple-item-margin, 3.75px); + background-color: var(--choices-primary-color, #005F75); + border: 1px solid color-mix(in srgb, var(--choices-primary-color, #005F75) 95%, var(--choices-darken, black)); + color: var(--choices-item-color, #fff); word-break: break-all; box-sizing: border-box; } @@ -185,28 +184,28 @@ } [dir=rtl] .choices__list--multiple .choices__item { margin-right: 0; - margin-left: 3.75px; + margin-left: var(--choices-multiple-item-margin, 3.75px); } .choices__list--multiple .choices__item.is-highlighted { - background-color: #004a5c; - border: 1px solid #003642; + background-color: color-mix(in srgb, var(--choices-primary-color, #005F75) 95%, var(--choices-darken, black)); + border: 1px solid color-mix(in srgb, var(--choices-primary-color, #005F75) 90%, var(--choices-darken, black)); } .is-disabled .choices__list--multiple .choices__item { - background-color: #aaaaaa; - border: 1px solid #919191; + background-color: color-mix(in srgb, var(--choices-disabled-color, #eaeaea) 75%, var(--choices-darken, black)); + border: 1px solid color-mix(in srgb, var(--choices-disabled-color, #eaeaea) 65%, var(--choices-darken, black)); } .choices__list--dropdown, .choices__list[aria-expanded] { display: none; - z-index: 1; + z-index: var(--choices-z-index, 1); position: absolute; - width: 100%; - background-color: #fff; - border: 1px solid #ddd; + width: var(--choices-width, 100%); + background-color: var(--choices-bg-color-dropdown, #fff); + border: var(--choices-base-border, 1px solid) var(--choices-keyline-color, #ddd); top: 100%; margin-top: -1px; - border-bottom-left-radius: 2.5px; - border-bottom-right-radius: 2.5px; + border-bottom-left-radius: var(--choices-border-radius, 2.5px); + border-bottom-right-radius: var(--choices-border-radius, 2.5px); overflow: hidden; word-break: break-all; } @@ -214,7 +213,7 @@ display: block; } .is-open .choices__list--dropdown, .is-open .choices__list[aria-expanded] { - border-color: #b7b7b7; + border-color: color-mix(in srgb, var(--choices-keyline-color, #ddd) 85%, var(--choices-darken, black)); } .is-flipped .choices__list--dropdown, .is-flipped .choices__list[aria-expanded] { top: auto; @@ -232,40 +231,39 @@ } .choices__list--dropdown .choices__item, .choices__list[aria-expanded] .choices__item { position: relative; - padding: 10px; - font-size: 14px; + padding: var(--choices-dropdown-item-padding, 10px); + font-size: var(--choices-font-size-md, 14px); } [dir=rtl] .choices__list--dropdown .choices__item, [dir=rtl] .choices__list[aria-expanded] .choices__item { text-align: right; } @media (min-width: 640px) { - .choices__list--dropdown .choices__item--selectable[data-select-text], .choices__list[aria-expanded] .choices__item--selectable[data-select-text] { + .choices__list--dropdown .choices__item--selectable.is-highlighted[data-select-text], .choices__list[aria-expanded] .choices__item--selectable.is-highlighted[data-select-text] { padding-right: 100px; } - .choices__list--dropdown .choices__item--selectable[data-select-text]::after, .choices__list[aria-expanded] .choices__item--selectable[data-select-text]::after { + .choices__list--dropdown .choices__item--selectable.is-highlighted[data-select-text]::after, .choices__list[aria-expanded] .choices__item--selectable.is-highlighted[data-select-text]::after { content: attr(data-select-text); - font-size: 12px; - opacity: 0; + font-size: var(--choices-font-size-sm, 12px); position: absolute; right: 10px; top: 50%; transform: translateY(-50%); } - [dir=rtl] .choices__list--dropdown .choices__item--selectable[data-select-text], [dir=rtl] .choices__list[aria-expanded] .choices__item--selectable[data-select-text] { + [dir=rtl] .choices__list--dropdown .choices__item--selectable.is-highlighted[data-select-text], [dir=rtl] .choices__list[aria-expanded] .choices__item--selectable.is-highlighted[data-select-text] { text-align: right; padding-left: 100px; padding-right: 10px; } - [dir=rtl] .choices__list--dropdown .choices__item--selectable[data-select-text]::after, [dir=rtl] .choices__list[aria-expanded] .choices__item--selectable[data-select-text]::after { + [dir=rtl] .choices__list--dropdown .choices__item--selectable.is-highlighted[data-select-text]::after, [dir=rtl] .choices__list[aria-expanded] .choices__item--selectable.is-highlighted[data-select-text]::after { right: auto; left: 10px; } } -.choices__list--dropdown .choices__item--selectable.is-highlighted, .choices__list[aria-expanded] .choices__item--selectable.is-highlighted { - background-color: #f2f2f2; +.choices__list--dropdown .choices__item--selectable.is-selected::after, .choices__list[aria-expanded] .choices__item--selectable.is-selected::after { + content: none !important; } -.choices__list--dropdown .choices__item--selectable.is-highlighted::after, .choices__list[aria-expanded] .choices__item--selectable.is-highlighted::after { - opacity: 0.5; +.choices__list--dropdown .choices__item--selectable.is-selected, .choices__list[aria-expanded] .choices__item--selectable.is-selected, .choices__list--dropdown .choices__item--selectable.is-highlighted, .choices__list[aria-expanded] .choices__item--selectable.is-highlighted { + background-color: var(--choices-highlighted-color, #f2f2f2); } .choices__item { @@ -287,7 +285,7 @@ font-weight: 600; font-size: 12px; padding: 10px; - border-bottom: 1px solid #f7f7f7; + border-bottom: 1px solid color-mix(in srgb, var(--choices-keyline-color, #ddd) 90%, var(--choices-lighten, white)); color: gray; } @@ -307,13 +305,13 @@ .choices__input { display: inline-block; vertical-align: baseline; - background-color: #f9f9f9; - font-size: 14px; - margin-bottom: 5px; + background-color: var(--choices-bg-color, #f9f9f9); + font-size: var(--choices-font-size-md, 14px); + margin-bottom: var(--choices-input-margin-bottom, 5px); border: 0; border-radius: 0; - max-width: 100%; - padding: 4px 0 4px 2px; + max-width: var(--choices-width, 100%); + padding: var(--choices-input-padding, 4px 0 4px 2px); } .choices__input:focus { outline: 0; @@ -332,7 +330,7 @@ } .choices__placeholder { - opacity: 0.5; + opacity: var(--choices-placeholder-opacity, 0.5); } /* ===== End of Choices ====== */ diff --git a/assets/styles/choices.css.map b/assets/styles/choices.css.map index a0c6f002..eb5d952f 100644 --- a/assets/styles/choices.css.map +++ b/assets/styles/choices.css.map @@ -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;;AAEA;EACE;;AAGF;EACE;;AAGF;EACE;EACA;EACA;EACA;EACA;;AAEF;EACE;EACA;EACA;EACA;EACA;;AAEF;EACE;EACA;EACA,WA1RmB;;AA4RnB;EACE;;AAKA;EADF;IAEI;;EAEA;IACE;IACA,WAtSa;IAuSb;IACA;IACA;IACA;IACA;;EAGF;IACE;IACA;IACA;;EAEA;IACE;IACA;;;AAMR;EACE;;AAEA;EACE;;;AAUR;EACE;;;AAGF;EACE;;;AAGF;EACE;EACA;EACA;;;AAGF;EACE;EACA,WAzVqB;EA0VrB;EACA;EACA;;;AAGF;EACE;EACA;EACA;EACA;EACA;EACA;EACA;;AAEA;EACE;;;AAIJ;EACE;EACA;EACA,kBA5WiB;EA6WjB,WAlXqB;EAmXrB;EACA;EACA;EACA;EACA;;AAEA;EACE;;AAGF;EAIE;;AAGF;EAEE;EACA;EACA;;AAGF;EACE;EACA;;;AAIJ;EACE;;;AAGF","file":"choices.css"} \ No newline at end of file +{"version":3,"sourceRoot":"","sources":["../../../src/styles/choices.scss"],"names":[],"mappings":"AAAA;AAAA;AAAA;AAiDA;EACE;EACA;EACA;EACA;;AAEA;EACE;;AAGF;EACE;;AAGF;EACE;;AAIA;EACE;EACA;EACA;;AAEF;EACE;EACA;;AAIJ;EACE;EACA;EACA;EACA;;;AAIJ;EACE;;AACA;EACE;;AAEF;EACE;EACA;EACA;EACA;EACA;EACA;;AAEF;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AAEA;EACE;;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;;;AAMJ;EACE;;AAEF;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AAEA;EACE;;;AAKN;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AAEA;EAEE;;AAGF;EACE;;AAGF;EACE;;AAGF;EACE;;;AAIJ;EACE;EACA;EACA;;AAOF;EACE;EACA;EACA;;AAEA;EACE;EACA;;AAEF;EACE;;;AAIJ;EACE;;AACA;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AAEA;EACE;;AAGF;EACE;EACA;;AAGF;EACE;EACA;;AAGF;EACE;EACA;;;AAKN;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AAEA;EACE;;AAGF;EACE;;AAGF;EACE;EACA;EACA;EACA;EACA;;AAEF;EACE;EACA;EACA;EACA;EACA;;AAEF;EACE;EACA;EACA;;AAEA;EACE;;AAKA;EADF;IAEI;;EAEA;IACE;IACA;IACA;IACA;IACA;IACA;;EAGF;IACE;IACA;IACA;;EAEA;IACE;IACA;;;AAQN;EACE;;AAIJ;EAEE;;;AASN;EACE;;;AAGF;EACE;;;AAGF;EACE;EACA;EACA;;;AAGF;EACE;EACA,WArXqB;EAsXrB;EACA;EACA;;;AAGF;EACE;EACA;EACA;EACA;EACA;EACA;EACA;;AAEA;EACE;;;AAIJ;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AAEA;EACE;;AAGF;EAIE;;AAGF;EAEE;EACA;EACA;;AAGF;EACE;EACA;;;AAIJ;EACE;;;AAGF","file":"choices.css"} \ No newline at end of file diff --git a/assets/styles/choices.min.css b/assets/styles/choices.min.css index cf79ea91..474ed5f2 100644 --- a/assets/styles/choices.min.css +++ b/assets/styles/choices.min.css @@ -1 +1 @@ -.choices{position:relative;overflow:hidden;margin-bottom:24px;font-size:16px}.choices:focus{outline:0}.choices:last-child{margin-bottom:0}.choices.is-open{overflow:visible}.choices.is-disabled .choices__inner,.choices.is-disabled .choices__input{background-color:#eaeaea;cursor:not-allowed;-webkit-user-select:none;user-select:none}.choices.is-disabled .choices__item{cursor:not-allowed}.choices [hidden]{display:none!important}.choices[data-type*=select-one]{cursor:pointer}.choices[data-type*=select-one] .choices__inner{padding-bottom:7.5px}.choices[data-type*=select-one] .choices__input{display:block;width:100%;padding:10px;border-bottom:1px solid #ddd;background-color:#fff;margin:0}.choices[data-type*=select-one] .choices__button{background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjEiIGhlaWdodD0iMjEiIHZpZXdCb3g9IjAgMCAyMSAyMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSIjMDAwIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxwYXRoIGQ9Ik0yLjU5Mi4wNDRsMTguMzY0IDE4LjM2NC0yLjU0OCAyLjU0OEwuMDQ0IDIuNTkyeiIvPjxwYXRoIGQ9Ik0wIDE4LjM2NEwxOC4zNjQgMGwyLjU0OCAyLjU0OEwyLjU0OCAyMC45MTJ6Ii8+PC9nPjwvc3ZnPg==);padding:0;background-size:8px;position:absolute;top:50%;right:0;margin-top:-10px;margin-right:25px;height:20px;width:20px;border-radius:10em;opacity:.25}.choices[data-type*=select-one] .choices__button:focus,.choices[data-type*=select-one] .choices__button:hover{opacity:1}.choices[data-type*=select-one] .choices__button:focus{box-shadow:0 0 0 2px #005f75}.choices[data-type*=select-one] .choices__item[data-placeholder] .choices__button{display:none}.choices[data-type*=select-one]::after{content:"";height:0;width:0;border-style:solid;border-color:#333 transparent transparent;border-width:5px;position:absolute;right:11.5px;top:50%;margin-top:-2.5px;pointer-events:none}.choices[data-type*=select-one].is-open::after{border-color:transparent transparent #333;margin-top:-7.5px}.choices[data-type*=select-one][dir=rtl]::after{left:11.5px;right:auto}.choices[data-type*=select-one][dir=rtl] .choices__button{right:auto;left:0;margin-left:25px;margin-right:0}.choices[data-type*=select-multiple] .choices__inner,.choices[data-type*=text] .choices__inner{cursor:text}.choices[data-type*=select-multiple] .choices__button,.choices[data-type*=text] .choices__button{position:relative;display:inline-block;margin:0-4px 0 8px;padding-left:16px;border-left:1px solid #003642;background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjEiIGhlaWdodD0iMjEiIHZpZXdCb3g9IjAgMCAyMSAyMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSIjRkZGIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxwYXRoIGQ9Ik0yLjU5Mi4wNDRsMTguMzY0IDE4LjM2NC0yLjU0OCAyLjU0OEwuMDQ0IDIuNTkyeiIvPjxwYXRoIGQ9Ik0wIDE4LjM2NEwxOC4zNjQgMGwyLjU0OCAyLjU0OEwyLjU0OCAyMC45MTJ6Ii8+PC9nPjwvc3ZnPg==);background-size:8px;width:8px;line-height:1;opacity:.75;border-radius:0}.choices[data-type*=select-multiple] .choices__button:focus,.choices[data-type*=select-multiple] .choices__button:hover,.choices[data-type*=text] .choices__button:focus,.choices[data-type*=text] .choices__button:hover{opacity:1}.choices__inner{display:inline-block;vertical-align:top;width:100%;background-color:#f9f9f9;padding:7.5px 7.5px 3.75px;border:1px solid #ddd;border-radius:2.5px;font-size:14px;min-height:44px;overflow:hidden}.is-focused .choices__inner,.is-open .choices__inner{border-color:#b7b7b7}.is-open .choices__inner{border-radius:2.5px 2.5px 0 0}.is-flipped.is-open .choices__inner{border-radius:0 0 2.5px 2.5px}.choices__list{margin:0;padding-left:0;list-style:none}.choices__list--single{display:inline-block;padding:4px 16px 4px 4px;width:100%}[dir=rtl] .choices__list--single{padding-right:4px;padding-left:16px}.choices__list--single .choices__item{width:100%}.choices__list--multiple{display:inline}.choices__list--multiple .choices__item{display:inline-block;vertical-align:middle;border-radius:20px;padding:4px 10px;font-size:12px;font-weight:500;margin-right:3.75px;margin-bottom:3.75px;background-color:#005f75;border:1px solid #004a5c;color:#fff;word-break:break-all;box-sizing:border-box}.choices__list--multiple .choices__item[data-deletable]{padding-right:5px}[dir=rtl] .choices__list--multiple .choices__item{margin-right:0;margin-left:3.75px}.choices__list--multiple .choices__item.is-highlighted{background-color:#004a5c;border:1px solid #003642}.is-disabled .choices__list--multiple .choices__item{background-color:#aaa;border:1px solid #919191}.choices__list--dropdown,.choices__list[aria-expanded]{display:none;z-index:1;position:absolute;width:100%;background-color:#fff;border:1px solid #ddd;top:100%;margin-top:-1px;border-bottom-left-radius:2.5px;border-bottom-right-radius:2.5px;overflow:hidden;word-break:break-all}.is-active.choices__list--dropdown,.is-active.choices__list[aria-expanded]{display:block}.is-open .choices__list--dropdown,.is-open .choices__list[aria-expanded]{border-color:#b7b7b7}.is-flipped .choices__list--dropdown,.is-flipped .choices__list[aria-expanded]{top:auto;bottom:100%;margin-top:0;margin-bottom:-1px;border-radius:.25rem .25rem 0 0}.choices__list--dropdown .choices__list,.choices__list[aria-expanded] .choices__list{position:relative;max-height:300px;overflow:auto;-webkit-overflow-scrolling:touch;will-change:scroll-position}.choices__list--dropdown .choices__item,.choices__list[aria-expanded] .choices__item{position:relative;padding:10px;font-size:14px}[dir=rtl] .choices__list--dropdown .choices__item,[dir=rtl] .choices__list[aria-expanded] .choices__item{text-align:right}@media (min-width:640px){.choices__list--dropdown .choices__item--selectable[data-select-text],.choices__list[aria-expanded] .choices__item--selectable[data-select-text]{padding-right:100px}.choices__list--dropdown .choices__item--selectable[data-select-text]::after,.choices__list[aria-expanded] .choices__item--selectable[data-select-text]::after{content:attr(data-select-text);font-size:12px;opacity:0;position:absolute;right:10px;top:50%;transform:translateY(-50%)}[dir=rtl] .choices__list--dropdown .choices__item--selectable[data-select-text],[dir=rtl] .choices__list[aria-expanded] .choices__item--selectable[data-select-text]{text-align:right;padding-left:100px;padding-right:10px}[dir=rtl] .choices__list--dropdown .choices__item--selectable[data-select-text]::after,[dir=rtl] .choices__list[aria-expanded] .choices__item--selectable[data-select-text]::after{right:auto;left:10px}}.choices__list--dropdown .choices__item--selectable.is-highlighted,.choices__list[aria-expanded] .choices__item--selectable.is-highlighted{background-color:#f2f2f2}.choices__list--dropdown .choices__item--selectable.is-highlighted::after,.choices__list[aria-expanded] .choices__item--selectable.is-highlighted::after{opacity:.5}.choices__item{cursor:default}.choices__item--selectable{cursor:pointer}.choices__item--disabled{cursor:not-allowed;-webkit-user-select:none;user-select:none;opacity:.5}.choices__heading{font-weight:600;font-size:12px;padding:10px;border-bottom:1px solid #f7f7f7;color:gray}.choices__button{text-indent:-9999px;appearance:none;border:0;background-color:transparent;background-repeat:no-repeat;background-position:center;cursor:pointer}.choices__button:focus,.choices__input:focus{outline:0}.choices__input{display:inline-block;vertical-align:baseline;background-color:#f9f9f9;font-size:14px;margin-bottom:5px;border:0;border-radius:0;max-width:100%;padding:4px 0 4px 2px}.choices__input::-webkit-search-cancel-button,.choices__input::-webkit-search-decoration,.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{padding-right:2px;padding-left:0}.choices__placeholder{opacity:.5} \ No newline at end of file +.choices{position:relative;overflow:hidden;margin-bottom:var(--choices-guttering, 24px);font-size:var(--choices-font-size-lg, 16px)}.choices:focus{outline:0}.choices:last-child{margin-bottom:0}.choices.is-open{overflow:visible}.choices.is-disabled :is(.choices__inner,.choices__input){background-color:var(--choices-bg-color-disabled, #eaeaea);cursor:not-allowed!important;-webkit-user-select:none;user-select:none}.choices.is-disabled .choices__item{cursor:not-allowed;color:var(--choices-item-disabled-color, #fff)}.choices [hidden]{position:absolute;inset:0;pointer-events:none;opacity:0}.choices[data-type*=select-one]{cursor:pointer}.choices[data-type*=select-one] .choices__inner{padding-bottom:var(--choices-inner-one-padding, 7.5px)}.choices[data-type*=select-one] .choices__input{display:block;width:var(--choices-width, 100%);padding:var(--choices-dropdown-item-padding, 10px);border-bottom:var(--choices-base-border, 1px solid) var(--choices-keyline-color, #ddd);background-color:var(--choices-bg-color-dropdown, #fff);margin:0}.choices[data-type*=select-one] .choices__button{background-image:var(--choices-icon-cross-inverse, url("data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjEiIGhlaWdodD0iMjEiIHZpZXdCb3g9IjAgMCAyMSAyMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSIjMDAwIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxwYXRoIGQ9Ik0yLjU5Mi4wNDRsMTguMzY0IDE4LjM2NC0yLjU0OCAyLjU0OEwuMDQ0IDIuNTkyeiIvPjxwYXRoIGQ9Ik0wIDE4LjM2NEwxOC4zNjQgMGwyLjU0OCAyLjU0OEwyLjU0OCAyMC45MTJ6Ii8+PC9nPjwvc3ZnPg=="));padding:0;background-size:8px;position:absolute;top:50%;right:0;margin-top:-10px;margin-right:25px;height:20px;width:20px;border-radius:10em;opacity:.25}.choices[data-type*=select-one] .choices__button:is(:hover,:focus){opacity:var(--choices-button-opacity-hover, 1)}.choices[data-type*=select-one] .choices__button:focus{box-shadow:0 0 0 2px var(--choices-highlight-color, #005F75)}.choices[data-type*=select-one] .choices__item[data-placeholder] .choices__button{display:none}.choices[data-type*=select-one]::after{content:"";height:0;width:0;border-style:solid;border-color:var(--choices-text-color, #333) transparent transparent transparent;border-width:var(--choices-arrow-size, 5px);position:absolute;right:var(--choices-arrow-right, 11.5px);top:50%;margin-top:var(--choices-arrow-margin-top, -2.5px);pointer-events:none}.choices[data-type*=select-one].is-open::after{border-color:transparent transparent var(--choices-text-color, #333);margin-top:var(--choices-arrow-margin-top-open, -7.5px)}.choices[data-type*=select-one][dir=rtl]::after{left:11.5px;right:auto}.choices[data-type*=select-one][dir=rtl] .choices__button{right:auto;left:0;margin-left:25px;margin-right:0}.choices:is([data-type*=select-multiple],[data-type*=text]) .choices__inner{cursor:text}.choices:is([data-type*=select-multiple],[data-type*=text]) .choices__button{position:relative;display:inline-block;margin:0 calc(var(--choices-button-offset, 8px)*-.5)0 var(--choices-button-offset, 8px);padding-left:calc(var(--choices-button-offset, 8px)*2);border-left:1px solid color-mix(in srgb,var(--choices-primary-color, #005F75) 90%,var(--choices-darken, black));background-image:var(--choices-icon-cross, url("data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjEiIGhlaWdodD0iMjEiIHZpZXdCb3g9IjAgMCAyMSAyMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSIjRkZGIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxwYXRoIGQ9Ik0yLjU5Mi4wNDRsMTguMzY0IDE4LjM2NC0yLjU0OCAyLjU0OEwuMDQ0IDIuNTkyeiIvPjxwYXRoIGQ9Ik0wIDE4LjM2NEwxOC4zNjQgMGwyLjU0OCAyLjU0OEwyLjU0OCAyMC45MTJ6Ii8+PC9nPjwvc3ZnPg=="));background-size:var(--choices-button-dimension, 8px);width:var(--choices-button-dimension, 8px);line-height:var(--choices-button-line-height, 1);border-radius:var(--choices-button-border-radius, 0);opacity:var(--choices-button-opacity, 0.75)}.choices:is([data-type*=select-multiple],[data-type*=text]) .choices__button:is(:hover,:focus){--choices-button-opacity:var(--choices-button-opacity-hover, 1)}.choices__inner{display:inline-block;vertical-align:top;width:var(--choices-width, 100%);background-color:var(--choices-bg-color, #f9f9f9);padding:var(--choices-inner-padding, 7.5px 7.5px 3.75px);border:var(--choices-base-border, 1px solid) var(--choices-keyline-color, #ddd);border-radius:var(--choices-border-radius, 2.5px);font-size:var(--choices-font-size-md, 14px);min-height:var(--choices-input-height, 44px);overflow:hidden}.is-focused .choices__inner,.is-open .choices__inner{border-color:color-mix(in srgb,var(--choices-keyline-color, #ddd) 85%,var(--choices-darken, black))}.is-open .choices__inner{border-radius:var(--choices-border-radius, 2.5px) var(--choices-border-radius, 2.5px)0 0}.is-invalid .choices__inner{border-color:var(--choices-invalid-color, #d33141)}.is-flipped.is-open .choices__inner{border-radius:0 0 var(--choices-border-radius, 2.5px) var(--choices-border-radius, 2.5px)}.choices__list{margin:0;padding-left:0;list-style:none}.choices__list--single{display:inline-block;padding:var(--choices-list-single-padding, 4px 16px 4px 4px)}[dir=rtl] .choices__list--single{padding-right:4px;padding-left:16px}.choices__list--single,.choices__list--single .choices__item{width:var(--choices-width, 100%)}.choices__list--multiple{display:inline}.choices__list--multiple .choices__item{display:inline-block;vertical-align:middle;border-radius:var(--choices-border-radius-item, 20px);padding:var(--choices-multiple-item-padding, 4px 10px);font-size:var(--choices-font-size-sm, 12px);font-weight:500;margin-right:var(--choices-multiple-item-margin, 3.75px);margin-bottom:var(--choices-multiple-item-margin, 3.75px);background-color:var(--choices-primary-color, #005F75);border:1px solid color-mix(in srgb,var(--choices-primary-color, #005F75) 95%,var(--choices-darken, black));color:var(--choices-item-color, #fff);word-break:break-all;box-sizing:border-box}.choices__list--multiple .choices__item[data-deletable]{padding-right:5px}[dir=rtl] .choices__list--multiple .choices__item{margin-right:0;margin-left:var(--choices-multiple-item-margin, 3.75px)}.choices__list--multiple .choices__item.is-highlighted{background-color:color-mix(in srgb,var(--choices-primary-color, #005F75) 95%,var(--choices-darken, black));border:1px solid color-mix(in srgb,var(--choices-primary-color, #005F75) 90%,var(--choices-darken, black))}.is-disabled .choices__list--multiple .choices__item{background-color:color-mix(in srgb,var(--choices-disabled-color, #eaeaea) 75%,var(--choices-darken, black));border:1px solid color-mix(in srgb,var(--choices-disabled-color, #eaeaea) 65%,var(--choices-darken, black))}.choices__list--dropdown,.choices__list[aria-expanded]{display:none;z-index:var(--choices-z-index, 1);position:absolute;width:var(--choices-width, 100%);background-color:var(--choices-bg-color-dropdown, #fff);border:var(--choices-base-border, 1px solid) var(--choices-keyline-color, #ddd);top:100%;margin-top:-1px;border-bottom-left-radius:var(--choices-border-radius, 2.5px);border-bottom-right-radius:var(--choices-border-radius, 2.5px);overflow:hidden;word-break:break-all}.is-active.choices__list--dropdown,.is-active.choices__list[aria-expanded]{display:block}.is-open .choices__list--dropdown,.is-open .choices__list[aria-expanded]{border-color:color-mix(in srgb,var(--choices-keyline-color, #ddd) 85%,var(--choices-darken, black))}.is-flipped .choices__list--dropdown,.is-flipped .choices__list[aria-expanded]{top:auto;bottom:100%;margin-top:0;margin-bottom:-1px;border-radius:.25rem .25rem 0 0}.choices__list--dropdown .choices__list,.choices__list[aria-expanded] .choices__list{position:relative;max-height:300px;overflow:auto;-webkit-overflow-scrolling:touch;will-change:scroll-position}.choices__list--dropdown .choices__item,.choices__list[aria-expanded] .choices__item{position:relative;padding:var(--choices-dropdown-item-padding, 10px);font-size:var(--choices-font-size-md, 14px)}[dir=rtl] .choices__list--dropdown .choices__item,[dir=rtl] .choices__list[aria-expanded] .choices__item{text-align:right}@media (min-width:640px){.choices__list--dropdown .choices__item--selectable.is-highlighted[data-select-text],.choices__list[aria-expanded] .choices__item--selectable.is-highlighted[data-select-text]{padding-right:100px}.choices__list--dropdown .choices__item--selectable.is-highlighted[data-select-text]::after,.choices__list[aria-expanded] .choices__item--selectable.is-highlighted[data-select-text]::after{content:attr(data-select-text);font-size:var(--choices-font-size-sm, 12px);position:absolute;right:10px;top:50%;transform:translateY(-50%)}[dir=rtl] .choices__list--dropdown .choices__item--selectable.is-highlighted[data-select-text],[dir=rtl] .choices__list[aria-expanded] .choices__item--selectable.is-highlighted[data-select-text]{text-align:right;padding-left:100px;padding-right:10px}[dir=rtl] .choices__list--dropdown .choices__item--selectable.is-highlighted[data-select-text]::after,[dir=rtl] .choices__list[aria-expanded] .choices__item--selectable.is-highlighted[data-select-text]::after{right:auto;left:10px}}.choices__list--dropdown .choices__item--selectable.is-selected::after,.choices__list[aria-expanded] .choices__item--selectable.is-selected::after{content:none!important}.choices__list--dropdown .choices__item--selectable.is-highlighted,.choices__list--dropdown .choices__item--selectable.is-selected,.choices__list[aria-expanded] .choices__item--selectable.is-highlighted,.choices__list[aria-expanded] .choices__item--selectable.is-selected{background-color:var(--choices-highlighted-color, #f2f2f2)}.choices__item{cursor:default}.choices__item--selectable{cursor:pointer}.choices__item--disabled{cursor:not-allowed;-webkit-user-select:none;user-select:none;opacity:.5}.choices__heading{font-weight:600;font-size:12px;padding:10px;border-bottom:1px solid color-mix(in srgb,var(--choices-keyline-color, #ddd) 90%,var(--choices-lighten, white));color:gray}.choices__button{text-indent:-9999px;appearance:none;border:0;background-color:transparent;background-repeat:no-repeat;background-position:center;cursor:pointer}.choices__button:focus,.choices__input:focus{outline:0}.choices__input{display:inline-block;vertical-align:baseline;background-color:var(--choices-bg-color, #f9f9f9);font-size:var(--choices-font-size-md, 14px);margin-bottom:var(--choices-input-margin-bottom, 5px);border:0;border-radius:0;max-width:var(--choices-width, 100%);padding:var(--choices-input-padding, 4px 0 4px 2px)}.choices__input::-webkit-search-cancel-button,.choices__input::-webkit-search-decoration,.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{padding-right:2px;padding-left:0}.choices__placeholder{opacity:var(--choices-placeholder-opacity, 0.5)} \ No newline at end of file diff --git a/index.html b/index.html index 92b5efa7..c759fff8 100644 --- a/index.html +++ b/index.html @@ -54,28 +54,17 @@ - -

@@ -548,6 +537,37 @@ + +


+

Form validation

+

Try submitting the form first.

+

+ Then try setting the values as they are required! +

+
+
+ + +
+
+ + +
+ +
diff --git a/types/src/scripts/choices.d.ts b/types/src/scripts/choices.d.ts index ea2a97ef..0273fa5b 100644 --- a/types/src/scripts/choices.d.ts +++ b/types/src/scripts/choices.d.ts @@ -155,6 +155,9 @@ declare class Choices { _displayNotice(text: string, type: NoticeType, openDropdown?: boolean): void; _clearNotice(): void; _renderNotice(fragment?: DocumentFragment): void; + /** + * @deprecated Use utils.getChoiceForOutput + */ _getChoiceForOutput(choice: ChoiceFull, keyCode?: number): EventChoice; _triggerChange(value: any): void; _handleButtonAction(element: HTMLElement): void; @@ -193,6 +196,14 @@ declare class Choices { _onFocus({ target }: Pick): void; _onBlur({ target }: Pick): void; _onFormReset(): void; + _onChange(event: Event & { + target: HTMLInputElement | HTMLSelectElement; + }): void; + _onInvalid(): void; + /** + * Removes any highlighted choice options + */ + _removeHighlightedChoices(): void; _highlightChoice(el?: HTMLElement | null): void; _addItem(item: ChoiceFull, withEvents?: boolean, userTriggered?: boolean): void; _removeItem(item: ChoiceFull): void; diff --git a/types/src/scripts/components/container.d.ts b/types/src/scripts/components/container.d.ts index a0a67bba..4b85dc1a 100644 --- a/types/src/scripts/components/container.d.ts +++ b/types/src/scripts/components/container.d.ts @@ -27,6 +27,8 @@ export default class Container { close(): void; addFocusState(): void; removeFocusState(): void; + addInvalidState(): void; + removeInvalidState(): void; enable(): void; disable(): void; wrap(element: HTMLElement): void; diff --git a/types/src/scripts/interfaces/choice-full.d.ts b/types/src/scripts/interfaces/choice-full.d.ts index d8513320..18740d23 100644 --- a/types/src/scripts/interfaces/choice-full.d.ts +++ b/types/src/scripts/interfaces/choice-full.d.ts @@ -1,4 +1,5 @@ import { StringUntrusted } from './string-untrusted'; +import { StringPreEscaped } from './string-pre-escaped'; import { Types } from './types'; import { GroupFull } from './group-full'; export interface ChoiceFull { @@ -8,7 +9,7 @@ export interface ChoiceFull { itemEl?: HTMLElement; choiceEl?: HTMLElement; labelClass?: Array; - labelDescription?: string; + labelDescription?: StringPreEscaped | StringUntrusted | string; customProperties?: Types.CustomProperties; disabled: boolean; active: boolean; diff --git a/types/src/scripts/interfaces/class-names.d.ts b/types/src/scripts/interfaces/class-names.d.ts index b6283385..a362b75c 100644 --- a/types/src/scripts/interfaces/class-names.d.ts +++ b/types/src/scripts/interfaces/class-names.d.ts @@ -50,6 +50,8 @@ export interface ClassNames { flippedState: string | Array; /** @default ['is-loading'] */ loadingState: string | Array; + /** @default ['is-invalid'] */ + invalidState: string | Array; /** @default ['choices__notice'] */ notice: string | Array; /** @default ['choices__item--selectable', 'add-choice'] */ diff --git a/types/src/scripts/interfaces/input-choice.d.ts b/types/src/scripts/interfaces/input-choice.d.ts index eb09b1f8..897a51a5 100644 --- a/types/src/scripts/interfaces/input-choice.d.ts +++ b/types/src/scripts/interfaces/input-choice.d.ts @@ -1,10 +1,11 @@ import { StringUntrusted } from './string-untrusted'; +import { StringPreEscaped } from './string-pre-escaped'; import { Types } from './types'; export interface InputChoice { id?: number; highlighted?: boolean; labelClass?: string | Array; - labelDescription?: string; + labelDescription?: StringPreEscaped | StringUntrusted | string; customProperties?: Types.CustomProperties; disabled?: boolean; active?: boolean; diff --git a/types/src/scripts/interfaces/options.d.ts b/types/src/scripts/interfaces/options.d.ts index 0cf0c037..4653bb9f 100644 --- a/types/src/scripts/interfaces/options.d.ts +++ b/types/src/scripts/interfaces/options.d.ts @@ -186,7 +186,7 @@ export interface Options { * * @default * ``` - * (value, valueRaw) => `Remove item`; + * (value, valueRaw, item) => `Remove item`; * ``` */ removeItemIconText: string | Types.NoticeStringFunction; @@ -200,7 +200,7 @@ export interface Options { * * @default * ``` - * (value, valueRaw) => `Remove item: ${value}`; + * (value, valueRaw, item) => `Remove item: ${value}`; * ``` */ removeItemLabelText: string | Types.NoticeStringFunction; @@ -296,6 +296,14 @@ export interface Options { * @default true */ searchChoices: boolean; + /** + * Whether disabled choices should be included in search results. If `true`, disabled choices will appear in search results but still cannot be selected. + * + * **Input types affected:** select-one, select-multiple + * + * @default false + */ + searchDisabledChoices: boolean; /** * The minimum length a search value should be before choices are searched. * @@ -431,6 +439,14 @@ export interface Options { * @default 'auto'; */ renderSelectedChoices: 'auto' | 'always' | boolean; + /** + * Whether selected choices should be removed from the list during search. + * + * **Input types affected:** select-multiple + * + * @default false; + */ + searchRenderSelectedChoices: boolean; /** * The text that is shown whilst choices are being populated via AJAX. * @@ -562,5 +578,5 @@ export interface Options { * @default null */ callbackOnCreateTemplates: CallbackOnCreateTemplatesFn | null; - appendGroupInSearch: false; + appendGroupInSearch: boolean; } diff --git a/types/src/scripts/interfaces/store.d.ts b/types/src/scripts/interfaces/store.d.ts index 83256c22..79a677ae 100644 --- a/types/src/scripts/interfaces/store.d.ts +++ b/types/src/scripts/interfaces/store.d.ts @@ -38,7 +38,8 @@ export interface Store { */ get activeChoices(): ChoiceFull[]; /** - * Get choices that can be searched (excluding placeholders) + * Get choices that can be searched (excluding placeholders, + * optionally excluding disabled based on config) */ get searchableChoices(): ChoiceFull[]; /** diff --git a/types/src/scripts/interfaces/types.d.ts b/types/src/scripts/interfaces/types.d.ts index 096a37d5..5e47619a 100644 --- a/types/src/scripts/interfaces/types.d.ts +++ b/types/src/scripts/interfaces/types.d.ts @@ -1,11 +1,12 @@ import { StringUntrusted } from './string-untrusted'; import { StringPreEscaped } from './string-pre-escaped'; +import { EventChoice } from './event-choice'; export declare namespace Types { type StrToEl = (str: string) => HTMLElement | HTMLInputElement | HTMLOptionElement; type EscapeForTemplateFn = (allowHTML: boolean, s: StringUntrusted | StringPreEscaped | string) => string; type GetClassNamesFn = (s: string | Array) => string; type StringFunction = () => string; - type NoticeStringFunction = (value: string, valueRaw: string) => string; + type NoticeStringFunction = (value: string, valueRaw: string, item?: EventChoice) => string; type NoticeLimitFunction = (maxItemCount: number) => string; type FilterFunction = (value: string) => boolean; type ValueCompareFunction = (value1: string, value2: string) => boolean; diff --git a/types/src/scripts/lib/utils.d.ts b/types/src/scripts/lib/utils.d.ts index 2c2c0797..fac8fe86 100644 --- a/types/src/scripts/lib/utils.d.ts +++ b/types/src/scripts/lib/utils.d.ts @@ -3,15 +3,17 @@ import { StringUntrusted } from '../interfaces/string-untrusted'; import { StringPreEscaped } from '../interfaces/string-pre-escaped'; import { ChoiceFull } from '../interfaces/choice-full'; import { Types } from '../interfaces/types'; +import { EventChoice } from '../interfaces'; export declare const generateId: (element: HTMLInputElement | HTMLSelectElement, prefix: string) => string; export declare const getAdjacentEl: (startEl: HTMLElement, selector: string, direction?: number) => HTMLElement | null; export declare const isScrolledIntoView: (element: HTMLElement, parent: HTMLElement, direction?: number) => boolean; export declare const sanitise: (value: T | StringUntrusted | StringPreEscaped | string) => T | string; export declare const strToEl: (str: string) => Element; -export declare const resolveNoticeFunction: (fn: Types.NoticeStringFunction | string, value: string) => string; export declare const resolveStringFunction: (fn: Types.StringFunction | string) => string; export declare const unwrapStringForRaw: (s?: StringUntrusted | StringPreEscaped | string) => string; export declare const unwrapStringForEscaped: (s?: StringUntrusted | StringPreEscaped | string) => string; +export declare const getChoiceForOutput: (choice: ChoiceFull, keyCode?: number) => EventChoice; +export declare const resolveNoticeFunction: (fn: Types.NoticeStringFunction | string, value: StringUntrusted | StringPreEscaped | string, item?: EventChoice) => string; export declare const escapeForTemplate: (allowHTML: boolean, s: StringUntrusted | StringPreEscaped | string) => string; export declare const setElementHtml: (el: HTMLElement, allowHtml: boolean, html: StringUntrusted | StringPreEscaped | string) => void; export declare const sortByAlpha: ({ value, label }: Types.RecordToCompare, { value: value2, label: label2 }: Types.RecordToCompare) => number;