From 053f908332866847f76aadd6b46556ebead8dc8a Mon Sep 17 00:00:00 2001 From: mtriff Date: Wed, 12 Jan 2022 01:26:00 +0000 Subject: [PATCH] deploy: 96e4ac53d971949208fa5062528d910bb90fb61f --- .nojekyll | 0 assets/scripts/choices.js | 11758 +++++++++------- assets/scripts/choices.min.js | 13 +- assets/scripts/choices.min.js.LICENSE.txt | 1 + assets/styles/base.css | 30 +- assets/styles/base.css.map | 1 + assets/styles/base.min.css | 2 +- assets/styles/choices.css | 152 +- assets/styles/choices.css.map | 1 + assets/styles/choices.min.css | 2 +- index.html | 45 +- .../integration/select-multiple.spec.d.ts | 1 + .../integration/select-multiple.spec.d.ts.map | 1 + .../cypress/integration/select-one.spec.d.ts | 1 + .../integration/select-one.spec.d.ts.map | 1 + types/cypress/integration/text.spec.d.ts | 1 + types/cypress/integration/text.spec.d.ts.map | 1 + types/src/index.d.ts | 7 + types/src/index.d.ts.map | 1 + types/src/scripts/actions/choices.d.ts | 44 + types/src/scripts/actions/choices.d.ts.map | 1 + types/src/scripts/actions/choices.test.d.ts | 2 + .../src/scripts/actions/choices.test.d.ts.map | 1 + types/src/scripts/actions/groups.d.ts | 15 + types/src/scripts/actions/groups.d.ts.map | 1 + types/src/scripts/actions/groups.test.d.ts | 2 + .../src/scripts/actions/groups.test.d.ts.map | 1 + types/src/scripts/actions/items.d.ts | 35 + types/src/scripts/actions/items.d.ts.map | 1 + types/src/scripts/actions/items.test.d.ts | 2 + types/src/scripts/actions/items.test.d.ts.map | 1 + types/src/scripts/actions/misc.d.ts | 17 + types/src/scripts/actions/misc.d.ts.map | 1 + types/src/scripts/actions/misc.test.d.ts | 2 + types/src/scripts/actions/misc.test.d.ts.map | 1 + types/src/scripts/choices.d.ts | 218 + types/src/scripts/choices.d.ts.map | 1 + types/src/scripts/choices.test.d.ts | 2 + types/src/scripts/choices.test.d.ts.map | 1 + types/src/scripts/components/container.d.ts | 43 + .../src/scripts/components/container.d.ts.map | 1 + .../scripts/components/container.test.d.ts | 2 + .../components/container.test.d.ts.map | 1 + types/src/scripts/components/dropdown.d.ts | 27 + .../src/scripts/components/dropdown.d.ts.map | 1 + .../src/scripts/components/dropdown.test.d.ts | 2 + .../scripts/components/dropdown.test.d.ts.map | 1 + types/src/scripts/components/index.d.ts | 8 + types/src/scripts/components/index.d.ts.map | 1 + types/src/scripts/components/input.d.ts | 39 + types/src/scripts/components/input.d.ts.map | 1 + types/src/scripts/components/input.test.d.ts | 2 + .../scripts/components/input.test.d.ts.map | 1 + types/src/scripts/components/list.d.ts | 18 + types/src/scripts/components/list.d.ts.map | 1 + types/src/scripts/components/list.test.d.ts | 2 + .../src/scripts/components/list.test.d.ts.map | 1 + .../scripts/components/wrapped-element.d.ts | 21 + .../components/wrapped-element.d.ts.map | 1 + .../components/wrapped-element.test.d.ts | 2 + .../components/wrapped-element.test.d.ts.map | 1 + .../src/scripts/components/wrapped-input.d.ts | 14 + .../scripts/components/wrapped-input.d.ts.map | 1 + .../components/wrapped-input.test.d.ts | 2 + .../components/wrapped-input.test.d.ts.map | 1 + .../scripts/components/wrapped-select.d.ts | 19 + .../components/wrapped-select.d.ts.map | 1 + .../components/wrapped-select.test.d.ts | 2 + .../components/wrapped-select.test.d.ts.map | 1 + types/src/scripts/constants.d.ts | 11 + types/src/scripts/constants.d.ts.map | 1 + types/src/scripts/constants.test.d.ts | 2 + types/src/scripts/constants.test.d.ts.map | 1 + types/src/scripts/defaults.d.ts | 5 + types/src/scripts/defaults.d.ts.map | 1 + types/src/scripts/interfaces/action-type.d.ts | 2 + .../scripts/interfaces/action-type.d.ts.map | 1 + types/src/scripts/interfaces/choice.d.ts | 16 + types/src/scripts/interfaces/choice.d.ts.map | 1 + types/src/scripts/interfaces/choices.d.ts | 46 + types/src/scripts/interfaces/choices.d.ts.map | 1 + types/src/scripts/interfaces/class-names.d.ts | 56 + .../scripts/interfaces/class-names.d.ts.map | 1 + types/src/scripts/interfaces/event-type.d.ts | 2 + .../scripts/interfaces/event-type.d.ts.map | 1 + types/src/scripts/interfaces/group.d.ts | 7 + types/src/scripts/interfaces/group.d.ts.map | 1 + types/src/scripts/interfaces/index.d.ts | 16 + types/src/scripts/interfaces/index.d.ts.map | 1 + types/src/scripts/interfaces/item.d.ts | 6 + types/src/scripts/interfaces/item.d.ts.map | 1 + types/src/scripts/interfaces/keycode-map.d.ts | 12 + .../scripts/interfaces/keycode-map.d.ts.map | 1 + types/src/scripts/interfaces/notice.d.ts | 5 + types/src/scripts/interfaces/notice.d.ts.map | 1 + types/src/scripts/interfaces/options.d.ts | 460 + types/src/scripts/interfaces/options.d.ts.map | 1 + .../interfaces/passed-element-type.d.ts | 2 + .../interfaces/passed-element-type.d.ts.map | 1 + .../scripts/interfaces/passed-element.d.ts | 129 + .../interfaces/passed-element.d.ts.map | 1 + .../interfaces/position-options-type.d.ts | 2 + .../interfaces/position-options-type.d.ts.map | 1 + types/src/scripts/interfaces/state.d.ts | 10 + types/src/scripts/interfaces/state.d.ts.map | 1 + types/src/scripts/interfaces/types.d.ts | 9 + types/src/scripts/interfaces/types.d.ts.map | 1 + types/src/scripts/lib/utils.d.ts | 27 + types/src/scripts/lib/utils.d.ts.map | 1 + types/src/scripts/lib/utils.test.d.ts | 2 + types/src/scripts/lib/utils.test.d.ts.map | 1 + types/src/scripts/reducers/choices.d.ts | 8 + types/src/scripts/reducers/choices.d.ts.map | 1 + types/src/scripts/reducers/choices.test.d.ts | 2 + .../scripts/reducers/choices.test.d.ts.map | 1 + types/src/scripts/reducers/groups.d.ts | 9 + types/src/scripts/reducers/groups.d.ts.map | 1 + types/src/scripts/reducers/groups.test.d.ts | 2 + .../src/scripts/reducers/groups.test.d.ts.map | 1 + types/src/scripts/reducers/index.d.ts | 9 + types/src/scripts/reducers/index.d.ts.map | 1 + types/src/scripts/reducers/index.test.d.ts | 2 + .../src/scripts/reducers/index.test.d.ts.map | 1 + types/src/scripts/reducers/items.d.ts | 8 + types/src/scripts/reducers/items.d.ts.map | 1 + types/src/scripts/reducers/items.test.d.ts | 2 + .../src/scripts/reducers/items.test.d.ts.map | 1 + types/src/scripts/reducers/loading.d.ts | 7 + types/src/scripts/reducers/loading.d.ts.map | 1 + types/src/scripts/reducers/loading.test.d.ts | 2 + .../scripts/reducers/loading.test.d.ts.map | 1 + types/src/scripts/store/store.d.ts | 74 + types/src/scripts/store/store.d.ts.map | 1 + types/src/scripts/store/store.test.d.ts | 2 + types/src/scripts/store/store.test.d.ts.map | 1 + types/src/scripts/templates.d.ts | 25 + types/src/scripts/templates.d.ts.map | 1 + types/src/scripts/templates.test.d.ts | 2 + types/src/scripts/templates.test.d.ts.map | 1 + 139 files changed, 8590 insertions(+), 5012 deletions(-) create mode 100644 .nojekyll create mode 100644 assets/scripts/choices.min.js.LICENSE.txt create mode 100644 assets/styles/base.css.map create mode 100644 assets/styles/choices.css.map create mode 100644 types/cypress/integration/select-multiple.spec.d.ts create mode 100644 types/cypress/integration/select-multiple.spec.d.ts.map create mode 100644 types/cypress/integration/select-one.spec.d.ts create mode 100644 types/cypress/integration/select-one.spec.d.ts.map create mode 100644 types/cypress/integration/text.spec.d.ts create mode 100644 types/cypress/integration/text.spec.d.ts.map create mode 100644 types/src/index.d.ts create mode 100644 types/src/index.d.ts.map create mode 100644 types/src/scripts/actions/choices.d.ts create mode 100644 types/src/scripts/actions/choices.d.ts.map create mode 100644 types/src/scripts/actions/choices.test.d.ts create mode 100644 types/src/scripts/actions/choices.test.d.ts.map create mode 100644 types/src/scripts/actions/groups.d.ts create mode 100644 types/src/scripts/actions/groups.d.ts.map create mode 100644 types/src/scripts/actions/groups.test.d.ts create mode 100644 types/src/scripts/actions/groups.test.d.ts.map create mode 100644 types/src/scripts/actions/items.d.ts create mode 100644 types/src/scripts/actions/items.d.ts.map create mode 100644 types/src/scripts/actions/items.test.d.ts create mode 100644 types/src/scripts/actions/items.test.d.ts.map create mode 100644 types/src/scripts/actions/misc.d.ts create mode 100644 types/src/scripts/actions/misc.d.ts.map create mode 100644 types/src/scripts/actions/misc.test.d.ts create mode 100644 types/src/scripts/actions/misc.test.d.ts.map create mode 100644 types/src/scripts/choices.d.ts create mode 100644 types/src/scripts/choices.d.ts.map create mode 100644 types/src/scripts/choices.test.d.ts create mode 100644 types/src/scripts/choices.test.d.ts.map create mode 100644 types/src/scripts/components/container.d.ts create mode 100644 types/src/scripts/components/container.d.ts.map create mode 100644 types/src/scripts/components/container.test.d.ts create mode 100644 types/src/scripts/components/container.test.d.ts.map create mode 100644 types/src/scripts/components/dropdown.d.ts create mode 100644 types/src/scripts/components/dropdown.d.ts.map create mode 100644 types/src/scripts/components/dropdown.test.d.ts create mode 100644 types/src/scripts/components/dropdown.test.d.ts.map create mode 100644 types/src/scripts/components/index.d.ts create mode 100644 types/src/scripts/components/index.d.ts.map create mode 100644 types/src/scripts/components/input.d.ts create mode 100644 types/src/scripts/components/input.d.ts.map create mode 100644 types/src/scripts/components/input.test.d.ts create mode 100644 types/src/scripts/components/input.test.d.ts.map create mode 100644 types/src/scripts/components/list.d.ts create mode 100644 types/src/scripts/components/list.d.ts.map create mode 100644 types/src/scripts/components/list.test.d.ts create mode 100644 types/src/scripts/components/list.test.d.ts.map create mode 100644 types/src/scripts/components/wrapped-element.d.ts create mode 100644 types/src/scripts/components/wrapped-element.d.ts.map create mode 100644 types/src/scripts/components/wrapped-element.test.d.ts create mode 100644 types/src/scripts/components/wrapped-element.test.d.ts.map create mode 100644 types/src/scripts/components/wrapped-input.d.ts create mode 100644 types/src/scripts/components/wrapped-input.d.ts.map create mode 100644 types/src/scripts/components/wrapped-input.test.d.ts create mode 100644 types/src/scripts/components/wrapped-input.test.d.ts.map create mode 100644 types/src/scripts/components/wrapped-select.d.ts create mode 100644 types/src/scripts/components/wrapped-select.d.ts.map create mode 100644 types/src/scripts/components/wrapped-select.test.d.ts create mode 100644 types/src/scripts/components/wrapped-select.test.d.ts.map create mode 100644 types/src/scripts/constants.d.ts create mode 100644 types/src/scripts/constants.d.ts.map create mode 100644 types/src/scripts/constants.test.d.ts create mode 100644 types/src/scripts/constants.test.d.ts.map create mode 100644 types/src/scripts/defaults.d.ts create mode 100644 types/src/scripts/defaults.d.ts.map create mode 100644 types/src/scripts/interfaces/action-type.d.ts create mode 100644 types/src/scripts/interfaces/action-type.d.ts.map create mode 100644 types/src/scripts/interfaces/choice.d.ts create mode 100644 types/src/scripts/interfaces/choice.d.ts.map create mode 100644 types/src/scripts/interfaces/choices.d.ts create mode 100644 types/src/scripts/interfaces/choices.d.ts.map create mode 100644 types/src/scripts/interfaces/class-names.d.ts create mode 100644 types/src/scripts/interfaces/class-names.d.ts.map create mode 100644 types/src/scripts/interfaces/event-type.d.ts create mode 100644 types/src/scripts/interfaces/event-type.d.ts.map create mode 100644 types/src/scripts/interfaces/group.d.ts create mode 100644 types/src/scripts/interfaces/group.d.ts.map create mode 100644 types/src/scripts/interfaces/index.d.ts create mode 100644 types/src/scripts/interfaces/index.d.ts.map create mode 100644 types/src/scripts/interfaces/item.d.ts create mode 100644 types/src/scripts/interfaces/item.d.ts.map create mode 100644 types/src/scripts/interfaces/keycode-map.d.ts create mode 100644 types/src/scripts/interfaces/keycode-map.d.ts.map create mode 100644 types/src/scripts/interfaces/notice.d.ts create mode 100644 types/src/scripts/interfaces/notice.d.ts.map create mode 100644 types/src/scripts/interfaces/options.d.ts create mode 100644 types/src/scripts/interfaces/options.d.ts.map create mode 100644 types/src/scripts/interfaces/passed-element-type.d.ts create mode 100644 types/src/scripts/interfaces/passed-element-type.d.ts.map create mode 100644 types/src/scripts/interfaces/passed-element.d.ts create mode 100644 types/src/scripts/interfaces/passed-element.d.ts.map create mode 100644 types/src/scripts/interfaces/position-options-type.d.ts create mode 100644 types/src/scripts/interfaces/position-options-type.d.ts.map create mode 100644 types/src/scripts/interfaces/state.d.ts create mode 100644 types/src/scripts/interfaces/state.d.ts.map create mode 100644 types/src/scripts/interfaces/types.d.ts create mode 100644 types/src/scripts/interfaces/types.d.ts.map create mode 100644 types/src/scripts/lib/utils.d.ts create mode 100644 types/src/scripts/lib/utils.d.ts.map create mode 100644 types/src/scripts/lib/utils.test.d.ts create mode 100644 types/src/scripts/lib/utils.test.d.ts.map create mode 100644 types/src/scripts/reducers/choices.d.ts create mode 100644 types/src/scripts/reducers/choices.d.ts.map create mode 100644 types/src/scripts/reducers/choices.test.d.ts create mode 100644 types/src/scripts/reducers/choices.test.d.ts.map create mode 100644 types/src/scripts/reducers/groups.d.ts create mode 100644 types/src/scripts/reducers/groups.d.ts.map create mode 100644 types/src/scripts/reducers/groups.test.d.ts create mode 100644 types/src/scripts/reducers/groups.test.d.ts.map create mode 100644 types/src/scripts/reducers/index.d.ts create mode 100644 types/src/scripts/reducers/index.d.ts.map create mode 100644 types/src/scripts/reducers/index.test.d.ts create mode 100644 types/src/scripts/reducers/index.test.d.ts.map create mode 100644 types/src/scripts/reducers/items.d.ts create mode 100644 types/src/scripts/reducers/items.d.ts.map create mode 100644 types/src/scripts/reducers/items.test.d.ts create mode 100644 types/src/scripts/reducers/items.test.d.ts.map create mode 100644 types/src/scripts/reducers/loading.d.ts create mode 100644 types/src/scripts/reducers/loading.d.ts.map create mode 100644 types/src/scripts/reducers/loading.test.d.ts create mode 100644 types/src/scripts/reducers/loading.test.d.ts.map create mode 100644 types/src/scripts/store/store.d.ts create mode 100644 types/src/scripts/store/store.d.ts.map create mode 100644 types/src/scripts/store/store.test.d.ts create mode 100644 types/src/scripts/store/store.test.d.ts.map create mode 100644 types/src/scripts/templates.d.ts create mode 100644 types/src/scripts/templates.d.ts.map create mode 100644 types/src/scripts/templates.test.d.ts create mode 100644 types/src/scripts/templates.test.d.ts.map diff --git a/.nojekyll b/.nojekyll new file mode 100644 index 0000000..e69de29 diff --git a/assets/scripts/choices.js b/assets/scripts/choices.js index ce284ff..219e0ce 100644 --- a/assets/scripts/choices.js +++ b/assets/scripts/choices.js @@ -1,4 +1,4 @@ -/*! choices.js v9.0.1 | © 2019 Josh Johnson | https://github.com/jshjohnson/Choices#readme */ +/*! choices.js v10.0.0 | © 2022 Josh Johnson | https://github.com/jshjohnson/Choices#readme */ (function webpackUniversalModuleDefinition(root, factory) { if(typeof exports === 'object' && typeof module === 'object') module.exports = factory(); @@ -9,97 +9,4862 @@ else root["Choices"] = factory(); })(window, function() { -return /******/ (function(modules) { // webpackBootstrap -/******/ // The module cache -/******/ var installedModules = {}; -/******/ -/******/ // The require function -/******/ function __webpack_require__(moduleId) { -/******/ -/******/ // Check if module is in cache -/******/ if(installedModules[moduleId]) { -/******/ return installedModules[moduleId].exports; -/******/ } -/******/ // Create a new module (and put it into the cache) -/******/ var module = installedModules[moduleId] = { -/******/ i: moduleId, -/******/ l: false, -/******/ exports: {} -/******/ }; -/******/ -/******/ // Execute the module function -/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); -/******/ -/******/ // Flag the module as loaded -/******/ module.l = true; -/******/ -/******/ // Return the exports of the module -/******/ return module.exports; -/******/ } -/******/ -/******/ -/******/ // expose the modules object (__webpack_modules__) -/******/ __webpack_require__.m = modules; -/******/ -/******/ // expose the module cache -/******/ __webpack_require__.c = installedModules; -/******/ -/******/ // define getter function for harmony exports -/******/ __webpack_require__.d = function(exports, name, getter) { -/******/ if(!__webpack_require__.o(exports, name)) { -/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); -/******/ } -/******/ }; -/******/ -/******/ // define __esModule on exports -/******/ __webpack_require__.r = function(exports) { -/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { -/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); -/******/ } -/******/ Object.defineProperty(exports, '__esModule', { value: true }); -/******/ }; -/******/ -/******/ // create a fake namespace object -/******/ // mode & 1: value is a module id, require it -/******/ // mode & 2: merge all properties of value into the ns -/******/ // mode & 4: return value when already ns object -/******/ // mode & 8|1: behave like require -/******/ __webpack_require__.t = function(value, mode) { -/******/ if(mode & 1) value = __webpack_require__(value); -/******/ if(mode & 8) return value; -/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; -/******/ var ns = Object.create(null); -/******/ __webpack_require__.r(ns); -/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); -/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); -/******/ return ns; -/******/ }; -/******/ -/******/ // getDefaultExport function for compatibility with non-harmony modules -/******/ __webpack_require__.n = function(module) { -/******/ var getter = module && module.__esModule ? -/******/ function getDefault() { return module['default']; } : -/******/ function getModuleExports() { return module; }; -/******/ __webpack_require__.d(getter, 'a', getter); -/******/ return getter; -/******/ }; -/******/ -/******/ // Object.prototype.hasOwnProperty.call -/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; -/******/ -/******/ // __webpack_public_path__ -/******/ __webpack_require__.p = "/public/assets/scripts/"; -/******/ -/******/ -/******/ // Load entry module and return exports -/******/ return __webpack_require__(__webpack_require__.s = 4); -/******/ }) -/************************************************************************/ -/******/ ([ -/* 0 */ -/***/ (function(module, exports, __webpack_require__) { +return /******/ (function() { // webpackBootstrap +/******/ "use strict"; +/******/ var __webpack_modules__ = ({ + +/***/ 282: +/***/ (function(__unused_webpack_module, exports, __webpack_require__) { + + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports.clearChoices = exports.activateChoices = exports.filterChoices = exports.addChoice = void 0; + +var constants_1 = __webpack_require__(883); + +var addChoice = function (_a) { + var value = _a.value, + label = _a.label, + id = _a.id, + groupId = _a.groupId, + disabled = _a.disabled, + elementId = _a.elementId, + customProperties = _a.customProperties, + placeholder = _a.placeholder, + keyCode = _a.keyCode; + return { + type: constants_1.ACTION_TYPES.ADD_CHOICE, + value: value, + label: label, + id: id, + groupId: groupId, + disabled: disabled, + elementId: elementId, + customProperties: customProperties, + placeholder: placeholder, + keyCode: keyCode + }; +}; + +exports.addChoice = addChoice; + +var filterChoices = function (results) { + return { + type: constants_1.ACTION_TYPES.FILTER_CHOICES, + results: results + }; +}; + +exports.filterChoices = filterChoices; + +var activateChoices = function (active) { + if (active === void 0) { + active = true; + } + + return { + type: constants_1.ACTION_TYPES.ACTIVATE_CHOICES, + active: active + }; +}; + +exports.activateChoices = activateChoices; + +var clearChoices = function () { + return { + type: constants_1.ACTION_TYPES.CLEAR_CHOICES + }; +}; + +exports.clearChoices = clearChoices; + +/***/ }), + +/***/ 783: +/***/ (function(__unused_webpack_module, exports, __webpack_require__) { + + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports.addGroup = void 0; + +var constants_1 = __webpack_require__(883); + +var addGroup = function (_a) { + var value = _a.value, + id = _a.id, + active = _a.active, + disabled = _a.disabled; + return { + type: constants_1.ACTION_TYPES.ADD_GROUP, + value: value, + id: id, + active: active, + disabled: disabled + }; +}; + +exports.addGroup = addGroup; + +/***/ }), + +/***/ 464: +/***/ (function(__unused_webpack_module, exports, __webpack_require__) { + + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports.highlightItem = exports.removeItem = exports.addItem = void 0; + +var constants_1 = __webpack_require__(883); + +var addItem = function (_a) { + var value = _a.value, + label = _a.label, + id = _a.id, + choiceId = _a.choiceId, + groupId = _a.groupId, + customProperties = _a.customProperties, + placeholder = _a.placeholder, + keyCode = _a.keyCode; + return { + type: constants_1.ACTION_TYPES.ADD_ITEM, + value: value, + label: label, + id: id, + choiceId: choiceId, + groupId: groupId, + customProperties: customProperties, + placeholder: placeholder, + keyCode: keyCode + }; +}; + +exports.addItem = addItem; + +var removeItem = function (id, choiceId) { + return { + type: constants_1.ACTION_TYPES.REMOVE_ITEM, + id: id, + choiceId: choiceId + }; +}; + +exports.removeItem = removeItem; + +var highlightItem = function (id, highlighted) { + return { + type: constants_1.ACTION_TYPES.HIGHLIGHT_ITEM, + id: id, + highlighted: highlighted + }; +}; + +exports.highlightItem = highlightItem; + +/***/ }), + +/***/ 137: +/***/ (function(__unused_webpack_module, exports, __webpack_require__) { + + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports.setIsLoading = exports.resetTo = exports.clearAll = void 0; + +var constants_1 = __webpack_require__(883); + +var clearAll = function () { + return { + type: constants_1.ACTION_TYPES.CLEAR_ALL + }; +}; + +exports.clearAll = clearAll; + +var resetTo = function (state) { + return { + type: constants_1.ACTION_TYPES.RESET_TO, + state: state + }; +}; + +exports.resetTo = resetTo; + +var setIsLoading = function (isLoading) { + return { + type: constants_1.ACTION_TYPES.SET_IS_LOADING, + isLoading: isLoading + }; +}; + +exports.setIsLoading = setIsLoading; + +/***/ }), + +/***/ 373: +/***/ (function(__unused_webpack_module, exports, __webpack_require__) { + + + +var __spreadArray = this && this.__spreadArray || function (to, from, pack) { + if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { + if (ar || !(i in from)) { + if (!ar) ar = Array.prototype.slice.call(from, 0, i); + ar[i] = from[i]; + } + } + return to.concat(ar || Array.prototype.slice.call(from)); +}; + +var __importDefault = this && this.__importDefault || function (mod) { + return mod && mod.__esModule ? mod : { + "default": mod + }; +}; + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); + +var deepmerge_1 = __importDefault(__webpack_require__(996)); +/* eslint-disable @typescript-eslint/no-explicit-any */ + + +var fuse_js_1 = __importDefault(__webpack_require__(221)); + +var choices_1 = __webpack_require__(282); + +var groups_1 = __webpack_require__(783); + +var items_1 = __webpack_require__(464); + +var misc_1 = __webpack_require__(137); + +var components_1 = __webpack_require__(520); + +var constants_1 = __webpack_require__(883); + +var defaults_1 = __webpack_require__(789); + +var utils_1 = __webpack_require__(799); + +var reducers_1 = __webpack_require__(655); + +var store_1 = __importDefault(__webpack_require__(744)); + +var templates_1 = __importDefault(__webpack_require__(686)); +/** @see {@link http://browserhacks.com/#hack-acea075d0ac6954f275a70023906050c} */ + + +var IS_IE11 = '-ms-scroll-limit' in document.documentElement.style && '-ms-ime-align' in document.documentElement.style; +var USER_DEFAULTS = {}; +/** + * Choices + * @author Josh Johnson + */ + +var Choices = +/** @class */ +function () { + function Choices(element, userConfig) { + var _this = this; + + if (element === void 0) { + element = '[data-choice]'; + } + + if (userConfig === void 0) { + userConfig = {}; + } + + if (userConfig.allowHTML === undefined) { + console.warn('Deprecation warning: allowHTML will default to false in a future release. To render HTML in Choices, you will need to set it to true. Setting allowHTML will suppress this message.'); + } + + this.config = deepmerge_1.default.all([defaults_1.DEFAULT_CONFIG, Choices.defaults.options, userConfig], // When merging array configs, replace with a copy of the userConfig array, + // instead of concatenating with the default array + { + arrayMerge: function (_, sourceArray) { + return __spreadArray([], sourceArray, true); + } + }); + var invalidConfigOptions = (0, utils_1.diff)(this.config, defaults_1.DEFAULT_CONFIG); + + if (invalidConfigOptions.length) { + console.warn('Unknown config option(s) passed', invalidConfigOptions.join(', ')); + } + + var passedElement = typeof element === 'string' ? document.querySelector(element) : element; + + if (!(passedElement instanceof HTMLInputElement || passedElement instanceof HTMLSelectElement)) { + throw TypeError('Expected one of the following types text|select-one|select-multiple'); + } + + this._isTextElement = passedElement.type === constants_1.TEXT_TYPE; + this._isSelectOneElement = passedElement.type === constants_1.SELECT_ONE_TYPE; + this._isSelectMultipleElement = passedElement.type === constants_1.SELECT_MULTIPLE_TYPE; + this._isSelectElement = this._isSelectOneElement || this._isSelectMultipleElement; + this.config.searchEnabled = this._isSelectMultipleElement || this.config.searchEnabled; + + if (!['auto', 'always'].includes("".concat(this.config.renderSelectedChoices))) { + this.config.renderSelectedChoices = 'auto'; + } + + if (userConfig.addItemFilter && typeof userConfig.addItemFilter !== 'function') { + var re = userConfig.addItemFilter instanceof RegExp ? userConfig.addItemFilter : new RegExp(userConfig.addItemFilter); + this.config.addItemFilter = re.test.bind(re); + } + + if (this._isTextElement) { + this.passedElement = new components_1.WrappedInput({ + element: passedElement, + classNames: this.config.classNames, + delimiter: this.config.delimiter + }); + } else { + this.passedElement = new components_1.WrappedSelect({ + element: passedElement, + classNames: this.config.classNames, + template: function (data) { + return _this._templates.option(data); + } + }); + } + + this.initialised = false; + this._store = new store_1.default(); + this._initialState = reducers_1.defaultState; + this._currentState = reducers_1.defaultState; + this._prevState = reducers_1.defaultState; + this._currentValue = ''; + this._canSearch = !!this.config.searchEnabled; + this._isScrollingOnIe = false; + this._highlightPosition = 0; + this._wasTap = true; + this._placeholderValue = this._generatePlaceholderValue(); + this._baseId = (0, utils_1.generateId)(this.passedElement.element, 'choices-'); + /** + * setting direction in cases where it's explicitly set on passedElement + * or when calculated direction is different from the document + */ + + this._direction = this.passedElement.dir; + + if (!this._direction) { + var elementDirection = window.getComputedStyle(this.passedElement.element).direction; + var documentDirection = window.getComputedStyle(document.documentElement).direction; + + if (elementDirection !== documentDirection) { + this._direction = elementDirection; + } + } + + this._idNames = { + itemChoice: 'item-choice' + }; + + if (this._isSelectElement) { + // Assign preset groups from passed element + this._presetGroups = this.passedElement.optionGroups; // Assign preset options from passed element + + this._presetOptions = this.passedElement.options; + } // Assign preset choices from passed object + + + this._presetChoices = this.config.choices; // Assign preset items from passed object first + + this._presetItems = this.config.items; // Add any values passed from attribute + + if (this.passedElement.value && this._isTextElement) { + var splitValues = this.passedElement.value.split(this.config.delimiter); + this._presetItems = this._presetItems.concat(splitValues); + } // Create array of choices from option elements + + + if (this.passedElement.options) { + this.passedElement.options.forEach(function (option) { + _this._presetChoices.push({ + value: option.value, + label: option.innerHTML, + selected: !!option.selected, + disabled: option.disabled || option.parentNode.disabled, + placeholder: option.value === '' || option.hasAttribute('placeholder'), + customProperties: option.dataset['custom-properties'] + }); + }); + } + + 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._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); // If element has already been initialised with Choices, fail silently + + if (this.passedElement.isActive) { + if (!this.config.silent) { + console.warn('Trying to initialise Choices on element already initialised', { + element: element + }); + } + + this.initialised = true; + return; + } // Let's go + + + this.init(); + } + + Object.defineProperty(Choices, "defaults", { + get: function () { + return Object.preventExtensions({ + get options() { + return USER_DEFAULTS; + }, + + get templates() { + return templates_1.default; + } + + }); + }, + enumerable: false, + configurable: true + }); + + Choices.prototype.init = function () { + if (this.initialised) { + return; + } + + this._createTemplates(); + + this._createElements(); + + this._createStructure(); + + this._store.subscribe(this._render); + + this._render(); + + this._addEventListeners(); + + var shouldDisable = !this.config.addItems || this.passedElement.element.hasAttribute('disabled'); + + if (shouldDisable) { + this.disable(); + } + + this.initialised = true; + var callbackOnInit = this.config.callbackOnInit; // Run callback if it is a function + + if (callbackOnInit && typeof callbackOnInit === 'function') { + callbackOnInit.call(this); + } + }; + + Choices.prototype.destroy = function () { + if (!this.initialised) { + return; + } + + this._removeEventListeners(); + + this.passedElement.reveal(); + this.containerOuter.unwrap(this.passedElement.element); + this.clearStore(); + + if (this._isSelectElement) { + this.passedElement.options = this._presetOptions; + } + + this._templates = templates_1.default; + this.initialised = false; + }; + + Choices.prototype.enable = function () { + if (this.passedElement.isDisabled) { + this.passedElement.enable(); + } + + if (this.containerOuter.isDisabled) { + this._addEventListeners(); + + this.input.enable(); + this.containerOuter.enable(); + } + + return this; + }; + + Choices.prototype.disable = function () { + if (!this.passedElement.isDisabled) { + this.passedElement.disable(); + } + + if (!this.containerOuter.isDisabled) { + this._removeEventListeners(); + + this.input.disable(); + this.containerOuter.disable(); + } + + return this; + }; + + Choices.prototype.highlightItem = function (item, runEvent) { + if (runEvent === void 0) { + runEvent = true; + } + + if (!item || !item.id) { + return this; + } + + var id = item.id, + _a = item.groupId, + groupId = _a === void 0 ? -1 : _a, + _b = item.value, + value = _b === void 0 ? '' : _b, + _c = item.label, + label = _c === void 0 ? '' : _c; + var group = groupId >= 0 ? this._store.getGroupById(groupId) : null; + + this._store.dispatch((0, items_1.highlightItem)(id, true)); + + if (runEvent) { + this.passedElement.triggerEvent(constants_1.EVENTS.highlightItem, { + id: id, + value: value, + label: label, + groupValue: group && group.value ? group.value : null + }); + } + + return this; + }; + + Choices.prototype.unhighlightItem = function (item) { + if (!item || !item.id) { + return this; + } + + var id = item.id, + _a = item.groupId, + groupId = _a === void 0 ? -1 : _a, + _b = item.value, + value = _b === void 0 ? '' : _b, + _c = item.label, + label = _c === void 0 ? '' : _c; + var group = groupId >= 0 ? this._store.getGroupById(groupId) : null; + + this._store.dispatch((0, items_1.highlightItem)(id, false)); + + this.passedElement.triggerEvent(constants_1.EVENTS.highlightItem, { + id: id, + value: value, + label: label, + groupValue: group && group.value ? group.value : null + }); + return this; + }; + + Choices.prototype.highlightAll = function () { + var _this = this; + + this._store.items.forEach(function (item) { + return _this.highlightItem(item); + }); + + return this; + }; + + Choices.prototype.unhighlightAll = function () { + var _this = this; + + this._store.items.forEach(function (item) { + return _this.unhighlightItem(item); + }); + + return this; + }; + + Choices.prototype.removeActiveItemsByValue = function (value) { + var _this = this; + + this._store.activeItems.filter(function (item) { + return item.value === value; + }).forEach(function (item) { + return _this._removeItem(item); + }); + + return this; + }; + + Choices.prototype.removeActiveItems = function (excludedId) { + var _this = this; + + this._store.activeItems.filter(function (_a) { + var id = _a.id; + return id !== excludedId; + }).forEach(function (item) { + return _this._removeItem(item); + }); + + return this; + }; + + Choices.prototype.removeHighlightedItems = function (runEvent) { + var _this = this; + + if (runEvent === void 0) { + runEvent = false; + } + + this._store.highlightedActiveItems.forEach(function (item) { + _this._removeItem(item); // If this action was performed by the user + // trigger the event + + + if (runEvent) { + _this._triggerChange(item.value); + } + }); + + return this; + }; + + Choices.prototype.showDropdown = function (preventInputFocus) { + var _this = this; + + if (this.dropdown.isActive) { + return this; + } + + requestAnimationFrame(function () { + _this.dropdown.show(); + + _this.containerOuter.open(_this.dropdown.distanceFromTopWindow); + + if (!preventInputFocus && _this._canSearch) { + _this.input.focus(); + } + + _this.passedElement.triggerEvent(constants_1.EVENTS.showDropdown, {}); + }); + return this; + }; + + Choices.prototype.hideDropdown = function (preventInputBlur) { + var _this = this; + + if (!this.dropdown.isActive) { + return this; + } + + requestAnimationFrame(function () { + _this.dropdown.hide(); + + _this.containerOuter.close(); + + if (!preventInputBlur && _this._canSearch) { + _this.input.removeActiveDescendant(); + + _this.input.blur(); + } + + _this.passedElement.triggerEvent(constants_1.EVENTS.hideDropdown, {}); + }); + return this; + }; + + Choices.prototype.getValue = function (valueOnly) { + if (valueOnly === void 0) { + valueOnly = false; + } + + var values = this._store.activeItems.reduce(function (selectedItems, item) { + var itemValue = valueOnly ? item.value : item; + selectedItems.push(itemValue); + return selectedItems; + }, []); + + return this._isSelectOneElement ? values[0] : values; + }; + + Choices.prototype.setValue = function (items) { + var _this = this; + + if (!this.initialised) { + return this; + } + + items.forEach(function (value) { + return _this._setChoiceOrItem(value); + }); + return this; + }; + + Choices.prototype.setChoiceByValue = function (value) { + var _this = this; + + if (!this.initialised || this._isTextElement) { + return this; + } // If only one value has been passed, convert to array + + + var choiceValue = Array.isArray(value) ? value : [value]; // Loop through each value and + + choiceValue.forEach(function (val) { + return _this._findAndSelectChoiceByValue(val); + }); + return this; + }; + /** + * Set choices of select input via an array of objects (or function that returns array of object or promise of it), + * a value field name and a label field name. + * This behaves the same as passing items via the choices option but can be called after initialising Choices. + * This can also be used to add groups of choices (see example 2); Optionally pass a true `replaceChoices` value to remove any existing choices. + * Optionally pass a `customProperties` object to add additional data to your choices (useful when searching/filtering etc). + * + * **Input types affected:** select-one, select-multiple + * + * @example + * ```js + * const example = new Choices(element); + * + * example.setChoices([ + * {value: 'One', label: 'Label One', disabled: true}, + * {value: 'Two', label: 'Label Two', selected: true}, + * {value: 'Three', label: 'Label Three'}, + * ], 'value', 'label', false); + * ``` + * + * @example + * ```js + * const example = new Choices(element); + * + * example.setChoices(async () => { + * try { + * const items = await fetch('/items'); + * return items.json() + * } catch(err) { + * console.error(err) + * } + * }); + * ``` + * + * @example + * ```js + * const example = new Choices(element); + * + * example.setChoices([{ + * label: 'Group one', + * id: 1, + * disabled: false, + * choices: [ + * {value: 'Child One', label: 'Child One', selected: true}, + * {value: 'Child Two', label: 'Child Two', disabled: true}, + * {value: 'Child Three', label: 'Child Three'}, + * ] + * }, + * { + * label: 'Group two', + * id: 2, + * disabled: false, + * choices: [ + * {value: 'Child Four', label: 'Child Four', disabled: true}, + * {value: 'Child Five', label: 'Child Five'}, + * {value: 'Child Six', label: 'Child Six', customProperties: { + * description: 'Custom description about child six', + * random: 'Another random custom property' + * }}, + * ] + * }], 'value', 'label', false); + * ``` + */ + + + Choices.prototype.setChoices = function (choicesArrayOrFetcher, value, label, replaceChoices) { + var _this = this; + + if (choicesArrayOrFetcher === void 0) { + choicesArrayOrFetcher = []; + } + + if (value === void 0) { + value = 'value'; + } + + if (label === void 0) { + label = 'label'; + } + + if (replaceChoices === void 0) { + replaceChoices = false; + } + + if (!this.initialised) { + throw new ReferenceError("setChoices was called on a non-initialized instance of Choices"); + } + + if (!this._isSelectElement) { + throw new TypeError("setChoices can't be used with INPUT based Choices"); + } + + if (typeof value !== 'string' || !value) { + throw new TypeError("value parameter must be a name of 'value' field in passed objects"); + } // Clear choices if needed + + + if (replaceChoices) { + this.clearChoices(); + } + + if (typeof choicesArrayOrFetcher === 'function') { + // it's a choices fetcher function + var fetcher_1 = choicesArrayOrFetcher(this); + + if (typeof Promise === 'function' && fetcher_1 instanceof Promise) { + // that's a promise + // eslint-disable-next-line no-promise-executor-return + return new Promise(function (resolve) { + return requestAnimationFrame(resolve); + }).then(function () { + return _this._handleLoadingState(true); + }).then(function () { + return fetcher_1; + }).then(function (data) { + return _this.setChoices(data, value, label, replaceChoices); + }).catch(function (err) { + if (!_this.config.silent) { + console.error(err); + } + }).then(function () { + return _this._handleLoadingState(false); + }).then(function () { + return _this; + }); + } // function returned something else than promise, let's check if it's an array of choices + + + if (!Array.isArray(fetcher_1)) { + throw new TypeError(".setChoices first argument function must return either array of choices or Promise, got: ".concat(typeof fetcher_1)); + } // recursion with results, it's sync and choices were cleared already + + + return this.setChoices(fetcher_1, value, label, false); + } + + if (!Array.isArray(choicesArrayOrFetcher)) { + throw new TypeError(".setChoices must be called either with array of choices with a function resulting into Promise of array of choices"); + } + + this.containerOuter.removeLoadingState(); + + this._startLoading(); + + choicesArrayOrFetcher.forEach(function (groupOrChoice) { + if (groupOrChoice.choices) { + _this._addGroup({ + id: groupOrChoice.id ? parseInt("".concat(groupOrChoice.id), 10) : null, + group: groupOrChoice, + valueKey: value, + labelKey: label + }); + } else { + var choice = groupOrChoice; + + _this._addChoice({ + value: choice[value], + label: choice[label], + isSelected: !!choice.selected, + isDisabled: !!choice.disabled, + placeholder: !!choice.placeholder, + customProperties: choice.customProperties + }); + } + }); + + this._stopLoading(); + + return this; + }; + + Choices.prototype.clearChoices = function () { + this._store.dispatch((0, choices_1.clearChoices)()); + + return this; + }; + + Choices.prototype.clearStore = function () { + this._store.dispatch((0, misc_1.clearAll)()); + + return this; + }; + + Choices.prototype.clearInput = function () { + var shouldSetInputWidth = !this._isSelectOneElement; + this.input.clear(shouldSetInputWidth); + + if (!this._isTextElement && this._canSearch) { + this._isSearching = false; + + this._store.dispatch((0, choices_1.activateChoices)(true)); + } + + return this; + }; + + Choices.prototype._render = function () { + if (this._store.isLoading()) { + return; + } + + this._currentState = this._store.state; + var stateChanged = this._currentState.choices !== this._prevState.choices || this._currentState.groups !== this._prevState.groups || this._currentState.items !== this._prevState.items; + var shouldRenderChoices = this._isSelectElement; + var shouldRenderItems = this._currentState.items !== this._prevState.items; + + if (!stateChanged) { + return; + } + + if (shouldRenderChoices) { + this._renderChoices(); + } + + if (shouldRenderItems) { + this._renderItems(); + } + + this._prevState = this._currentState; + }; + + Choices.prototype._renderChoices = function () { + var _this = this; + + var _a = this._store, + activeGroups = _a.activeGroups, + activeChoices = _a.activeChoices; + var choiceListFragment = document.createDocumentFragment(); + this.choiceList.clear(); + + if (this.config.resetScrollPosition) { + requestAnimationFrame(function () { + return _this.choiceList.scrollToTop(); + }); + } // If we have grouped options + + + if (activeGroups.length >= 1 && !this._isSearching) { + // If we have a placeholder choice along with groups + var activePlaceholders = activeChoices.filter(function (activeChoice) { + return activeChoice.placeholder === true && activeChoice.groupId === -1; + }); + + if (activePlaceholders.length >= 1) { + choiceListFragment = this._createChoicesFragment(activePlaceholders, choiceListFragment); + } + + choiceListFragment = this._createGroupsFragment(activeGroups, activeChoices, choiceListFragment); + } else if (activeChoices.length >= 1) { + choiceListFragment = this._createChoicesFragment(activeChoices, choiceListFragment); + } // If we have choices to show + + + if (choiceListFragment.childNodes && choiceListFragment.childNodes.length > 0) { + var activeItems = this._store.activeItems; + + var canAddItem = this._canAddItem(activeItems, this.input.value); // ...and we can select them + + + if (canAddItem.response) { + // ...append them and highlight the first choice + this.choiceList.append(choiceListFragment); + + this._highlightChoice(); + } else { + var notice = this._getTemplate('notice', canAddItem.notice); + + this.choiceList.append(notice); + } + } else { + // Otherwise show a notice + var dropdownItem = void 0; + var notice = void 0; + + if (this._isSearching) { + notice = typeof this.config.noResultsText === 'function' ? this.config.noResultsText() : this.config.noResultsText; + dropdownItem = this._getTemplate('notice', notice, 'no-results'); + } else { + notice = typeof this.config.noChoicesText === 'function' ? this.config.noChoicesText() : this.config.noChoicesText; + dropdownItem = this._getTemplate('notice', notice, 'no-choices'); + } + + this.choiceList.append(dropdownItem); + } + }; + + Choices.prototype._renderItems = function () { + var activeItems = this._store.activeItems || []; + this.itemList.clear(); // Create a fragment to store our list items + // (so we don't have to update the DOM for each item) + + var itemListFragment = this._createItemsFragment(activeItems); // If we have items to add, append them + + + if (itemListFragment.childNodes) { + this.itemList.append(itemListFragment); + } + }; + + Choices.prototype._createGroupsFragment = function (groups, choices, fragment) { + var _this = this; + + if (fragment === void 0) { + fragment = document.createDocumentFragment(); + } + + var getGroupChoices = function (group) { + return choices.filter(function (choice) { + if (_this._isSelectOneElement) { + return choice.groupId === group.id; + } + + return choice.groupId === group.id && (_this.config.renderSelectedChoices === 'always' || !choice.selected); + }); + }; // If sorting is enabled, filter groups + + + if (this.config.shouldSort) { + groups.sort(this.config.sorter); + } + + groups.forEach(function (group) { + var groupChoices = getGroupChoices(group); + + if (groupChoices.length >= 1) { + var dropdownGroup = _this._getTemplate('choiceGroup', group); + + fragment.appendChild(dropdownGroup); + + _this._createChoicesFragment(groupChoices, fragment, true); + } + }); + return fragment; + }; + + Choices.prototype._createChoicesFragment = function (choices, fragment, withinGroup) { + var _this = this; + + if (fragment === void 0) { + fragment = document.createDocumentFragment(); + } + + if (withinGroup === void 0) { + withinGroup = false; + } // Create a fragment to store our list items (so we don't have to update the DOM for each item) + + + var _a = this.config, + renderSelectedChoices = _a.renderSelectedChoices, + searchResultLimit = _a.searchResultLimit, + renderChoiceLimit = _a.renderChoiceLimit; + var filter = this._isSearching ? utils_1.sortByScore : this.config.sorter; + + var appendChoice = function (choice) { + var shouldRender = renderSelectedChoices === 'auto' ? _this._isSelectOneElement || !choice.selected : true; + + if (shouldRender) { + var dropdownItem = _this._getTemplate('choice', choice, _this.config.itemSelectText); + + fragment.appendChild(dropdownItem); + } + }; + + var rendererableChoices = choices; + + if (renderSelectedChoices === 'auto' && !this._isSelectOneElement) { + rendererableChoices = choices.filter(function (choice) { + return !choice.selected; + }); + } // Split array into placeholders and "normal" choices + + + var _b = rendererableChoices.reduce(function (acc, choice) { + if (choice.placeholder) { + acc.placeholderChoices.push(choice); + } else { + acc.normalChoices.push(choice); + } + + return acc; + }, { + placeholderChoices: [], + normalChoices: [] + }), + placeholderChoices = _b.placeholderChoices, + normalChoices = _b.normalChoices; // If sorting is enabled or the user is searching, filter choices + + + if (this.config.shouldSort || this._isSearching) { + normalChoices.sort(filter); + } + + var choiceLimit = rendererableChoices.length; // Prepend placeholeder + + var sortedChoices = this._isSelectOneElement ? __spreadArray(__spreadArray([], placeholderChoices, true), normalChoices, true) : normalChoices; + + if (this._isSearching) { + choiceLimit = searchResultLimit; + } else if (renderChoiceLimit && renderChoiceLimit > 0 && !withinGroup) { + choiceLimit = renderChoiceLimit; + } // Add each choice to dropdown within range + + + for (var i = 0; i < choiceLimit; i += 1) { + if (sortedChoices[i]) { + appendChoice(sortedChoices[i]); + } + } + + return fragment; + }; + + Choices.prototype._createItemsFragment = function (items, fragment) { + var _this = this; + + if (fragment === void 0) { + fragment = document.createDocumentFragment(); + } // Create fragment to add elements to + + + var _a = this.config, + shouldSortItems = _a.shouldSortItems, + sorter = _a.sorter, + removeItemButton = _a.removeItemButton; // If sorting is enabled, filter items + + if (shouldSortItems && !this._isSelectOneElement) { + items.sort(sorter); + } + + if (this._isTextElement) { + // Update the value of the hidden input + this.passedElement.value = items.map(function (_a) { + var value = _a.value; + return value; + }).join(this.config.delimiter); + } else { + // Update the options of the hidden input + this.passedElement.options = items; + } + + var addItemToFragment = function (item) { + // Create new list element + var listItem = _this._getTemplate('item', item, removeItemButton); // Append it to list + + + fragment.appendChild(listItem); + }; // Add each list item to list + + + items.forEach(addItemToFragment); + return fragment; + }; + + Choices.prototype._triggerChange = function (value) { + if (value === undefined || value === null) { + return; + } + + this.passedElement.triggerEvent(constants_1.EVENTS.change, { + value: value + }); + }; + + Choices.prototype._selectPlaceholderChoice = function (placeholderChoice) { + this._addItem({ + value: placeholderChoice.value, + label: placeholderChoice.label, + choiceId: placeholderChoice.id, + groupId: placeholderChoice.groupId, + placeholder: placeholderChoice.placeholder + }); + + this._triggerChange(placeholderChoice.value); + }; + + Choices.prototype._handleButtonAction = function (activeItems, element) { + if (!activeItems || !element || !this.config.removeItems || !this.config.removeItemButton) { + return; + } + + var itemId = element.parentNode && element.parentNode.dataset.id; + var itemToRemove = itemId && activeItems.find(function (item) { + return item.id === parseInt(itemId, 10); + }); + + if (!itemToRemove) { + return; + } // Remove item associated with button + + + this._removeItem(itemToRemove); + + this._triggerChange(itemToRemove.value); + + if (this._isSelectOneElement && this._store.placeholderChoice) { + this._selectPlaceholderChoice(this._store.placeholderChoice); + } + }; + + Choices.prototype._handleItemAction = function (activeItems, element, hasShiftKey) { + var _this = this; + + if (hasShiftKey === void 0) { + hasShiftKey = false; + } + + if (!activeItems || !element || !this.config.removeItems || this._isSelectOneElement) { + return; + } + + var passedId = element.dataset.id; // We only want to select one item with a click + // so we deselect any items that aren't the target + // unless shift is being pressed + + activeItems.forEach(function (item) { + if (item.id === parseInt("".concat(passedId), 10) && !item.highlighted) { + _this.highlightItem(item); + } else if (!hasShiftKey && item.highlighted) { + _this.unhighlightItem(item); + } + }); // Focus input as without focus, a user cannot do anything with a + // highlighted item + + this.input.focus(); + }; + + Choices.prototype._handleChoiceAction = function (activeItems, element) { + if (!activeItems || !element) { + return; + } // If we are clicking on an option + + + var id = element.dataset.id; + + var choice = id && this._store.getChoiceById(id); + + if (!choice) { + return; + } + + var passedKeyCode = activeItems[0] && activeItems[0].keyCode ? activeItems[0].keyCode : undefined; + var hasActiveDropdown = this.dropdown.isActive; // Update choice keyCode + + choice.keyCode = passedKeyCode; + this.passedElement.triggerEvent(constants_1.EVENTS.choice, { + choice: choice + }); + + if (!choice.selected && !choice.disabled) { + var canAddItem = this._canAddItem(activeItems, choice.value); + + if (canAddItem.response) { + this._addItem({ + value: choice.value, + label: choice.label, + choiceId: choice.id, + groupId: choice.groupId, + customProperties: choice.customProperties, + placeholder: choice.placeholder, + keyCode: choice.keyCode + }); + + this._triggerChange(choice.value); + } + } + + this.clearInput(); // We want to close the dropdown if we are dealing with a single select box + + if (hasActiveDropdown && this._isSelectOneElement) { + this.hideDropdown(true); + this.containerOuter.focus(); + } + }; + + Choices.prototype._handleBackspace = function (activeItems) { + if (!this.config.removeItems || !activeItems) { + return; + } + + var lastItem = activeItems[activeItems.length - 1]; + var hasHighlightedItems = activeItems.some(function (item) { + return item.highlighted; + }); // If editing the last item is allowed and there are not other selected items, + // we can edit the item value. Otherwise if we can remove items, remove all selected items + + if (this.config.editItems && !hasHighlightedItems && lastItem) { + this.input.value = lastItem.value; + this.input.setWidth(); + + this._removeItem(lastItem); + + this._triggerChange(lastItem.value); + } else { + if (!hasHighlightedItems) { + // Highlight last item if none already highlighted + this.highlightItem(lastItem, false); + } + + this.removeHighlightedItems(true); + } + }; + + Choices.prototype._startLoading = function () { + this._store.dispatch((0, misc_1.setIsLoading)(true)); + }; + + Choices.prototype._stopLoading = function () { + this._store.dispatch((0, misc_1.setIsLoading)(false)); + }; + + Choices.prototype._handleLoadingState = function (setLoading) { + if (setLoading === void 0) { + setLoading = true; + } + + var placeholderItem = this.itemList.getChild(".".concat(this.config.classNames.placeholder)); + + if (setLoading) { + this.disable(); + this.containerOuter.addLoadingState(); + + if (this._isSelectOneElement) { + if (!placeholderItem) { + placeholderItem = this._getTemplate('placeholder', this.config.loadingText); + + if (placeholderItem) { + this.itemList.append(placeholderItem); + } + } else { + placeholderItem.innerHTML = this.config.loadingText; + } + } else { + this.input.placeholder = this.config.loadingText; + } + } else { + this.enable(); + this.containerOuter.removeLoadingState(); + + if (this._isSelectOneElement) { + if (placeholderItem) { + placeholderItem.innerHTML = this._placeholderValue || ''; + } + } else { + this.input.placeholder = this._placeholderValue || ''; + } + } + }; + + Choices.prototype._handleSearch = function (value) { + if (!this.input.isFocussed) { + return; + } + + var choices = this._store.choices; + var _a = this.config, + searchFloor = _a.searchFloor, + searchChoices = _a.searchChoices; + var hasUnactiveChoices = choices.some(function (option) { + return !option.active; + }); // Check that we have a value to search and the input was an alphanumeric character + + if (value !== null && typeof value !== 'undefined' && value.length >= searchFloor) { + var resultCount = searchChoices ? this._searchChoices(value) : 0; // Trigger search event + + this.passedElement.triggerEvent(constants_1.EVENTS.search, { + value: value, + resultCount: resultCount + }); + } else if (hasUnactiveChoices) { + // Otherwise reset choices to active + this._isSearching = false; + + this._store.dispatch((0, choices_1.activateChoices)(true)); + } + }; + + Choices.prototype._canAddItem = function (activeItems, value) { + var canAddItem = true; + var notice = typeof this.config.addItemText === 'function' ? this.config.addItemText(value) : this.config.addItemText; + + if (!this._isSelectOneElement) { + var isDuplicateValue = (0, utils_1.existsInArray)(activeItems, value); + + if (this.config.maxItemCount > 0 && this.config.maxItemCount <= activeItems.length) { + // If there is a max entry limit and we have reached that limit + // don't update + canAddItem = false; + notice = typeof this.config.maxItemText === 'function' ? this.config.maxItemText(this.config.maxItemCount) : this.config.maxItemText; + } + + if (!this.config.duplicateItemsAllowed && isDuplicateValue && canAddItem) { + canAddItem = false; + notice = typeof this.config.uniqueItemText === 'function' ? this.config.uniqueItemText(value) : this.config.uniqueItemText; + } + + if (this._isTextElement && this.config.addItems && canAddItem && typeof this.config.addItemFilter === 'function' && !this.config.addItemFilter(value)) { + canAddItem = false; + notice = typeof this.config.customAddItemText === 'function' ? this.config.customAddItemText(value) : this.config.customAddItemText; + } + } + + return { + response: canAddItem, + notice: notice + }; + }; + + Choices.prototype._searchChoices = function (value) { + var newValue = typeof value === 'string' ? value.trim() : value; + var currentValue = typeof this._currentValue === 'string' ? this._currentValue.trim() : this._currentValue; + + if (newValue.length < 1 && newValue === "".concat(currentValue, " ")) { + return 0; + } // If new value matches the desired length and is not the same as the current value with a space + + + var haystack = this._store.searchableChoices; + var needle = newValue; + var options = Object.assign(this.config.fuseOptions, { + keys: __spreadArray([], this.config.searchFields, true), + includeMatches: true + }); + var fuse = new fuse_js_1.default(haystack, options); + var results = fuse.search(needle); // see https://github.com/krisk/Fuse/issues/303 + + this._currentValue = newValue; + this._highlightPosition = 0; + this._isSearching = true; + + this._store.dispatch((0, choices_1.filterChoices)(results)); + + return results.length; + }; + + Choices.prototype._addEventListeners = function () { + var documentElement = document.documentElement; // capture events - can cancel event processing or propagation + + documentElement.addEventListener('touchend', this._onTouchEnd, true); + this.containerOuter.element.addEventListener('keydown', this._onKeyDown, true); + this.containerOuter.element.addEventListener('mousedown', this._onMouseDown, true); // passive events - doesn't call `preventDefault` or `stopPropagation` + + documentElement.addEventListener('click', this._onClick, { + passive: true + }); + documentElement.addEventListener('touchmove', this._onTouchMove, { + passive: true + }); + this.dropdown.element.addEventListener('mouseover', this._onMouseOver, { + passive: true + }); + + if (this._isSelectOneElement) { + this.containerOuter.element.addEventListener('focus', this._onFocus, { + passive: true + }); + this.containerOuter.element.addEventListener('blur', this._onBlur, { + passive: true + }); + } + + this.input.element.addEventListener('keyup', this._onKeyUp, { + passive: true + }); + this.input.element.addEventListener('focus', this._onFocus, { + passive: true + }); + this.input.element.addEventListener('blur', this._onBlur, { + passive: true + }); + + if (this.input.element.form) { + this.input.element.form.addEventListener('reset', this._onFormReset, { + passive: true + }); + } + + this.input.addEventListeners(); + }; + + Choices.prototype._removeEventListeners = function () { + var documentElement = document.documentElement; + documentElement.removeEventListener('touchend', this._onTouchEnd, true); + this.containerOuter.element.removeEventListener('keydown', this._onKeyDown, true); + this.containerOuter.element.removeEventListener('mousedown', this._onMouseDown, true); + documentElement.removeEventListener('click', this._onClick); + documentElement.removeEventListener('touchmove', this._onTouchMove); + this.dropdown.element.removeEventListener('mouseover', this._onMouseOver); + + if (this._isSelectOneElement) { + this.containerOuter.element.removeEventListener('focus', this._onFocus); + this.containerOuter.element.removeEventListener('blur', this._onBlur); + } + + this.input.element.removeEventListener('keyup', this._onKeyUp); + this.input.element.removeEventListener('focus', this._onFocus); + this.input.element.removeEventListener('blur', this._onBlur); + + if (this.input.element.form) { + this.input.element.form.removeEventListener('reset', this._onFormReset); + } + + this.input.removeEventListeners(); + }; + + Choices.prototype._onKeyDown = function (event) { + var keyCode = event.keyCode; + var activeItems = this._store.activeItems; + var hasFocusedInput = this.input.isFocussed; + var hasActiveDropdown = this.dropdown.isActive; + var hasItems = this.itemList.hasChildren(); + var keyString = String.fromCharCode(keyCode); + var wasAlphaNumericChar = /[a-zA-Z0-9-_ ]/.test(keyString); + var BACK_KEY = constants_1.KEY_CODES.BACK_KEY, + DELETE_KEY = constants_1.KEY_CODES.DELETE_KEY, + ENTER_KEY = constants_1.KEY_CODES.ENTER_KEY, + A_KEY = constants_1.KEY_CODES.A_KEY, + ESC_KEY = constants_1.KEY_CODES.ESC_KEY, + UP_KEY = constants_1.KEY_CODES.UP_KEY, + DOWN_KEY = constants_1.KEY_CODES.DOWN_KEY, + PAGE_UP_KEY = constants_1.KEY_CODES.PAGE_UP_KEY, + PAGE_DOWN_KEY = constants_1.KEY_CODES.PAGE_DOWN_KEY; + + if (!this._isTextElement && !hasActiveDropdown && wasAlphaNumericChar) { + this.showDropdown(); + + if (!this.input.isFocussed) { + /* + We update the input value with the pressed key as + the input was not focussed at the time of key press + therefore does not have the value of the key. + */ + this.input.value += keyString.toLowerCase(); + } + } + + switch (keyCode) { + case A_KEY: + return this._onSelectKey(event, hasItems); + + case ENTER_KEY: + return this._onEnterKey(event, activeItems, hasActiveDropdown); + + case ESC_KEY: + return this._onEscapeKey(hasActiveDropdown); + + case UP_KEY: + case PAGE_UP_KEY: + case DOWN_KEY: + case PAGE_DOWN_KEY: + return this._onDirectionKey(event, hasActiveDropdown); + + case DELETE_KEY: + case BACK_KEY: + return this._onDeleteKey(event, activeItems, hasFocusedInput); + + default: + } + }; + + Choices.prototype._onKeyUp = function (_a) { + var target = _a.target, + keyCode = _a.keyCode; + var value = this.input.value; + var activeItems = this._store.activeItems; + + var canAddItem = this._canAddItem(activeItems, value); + + var backKey = constants_1.KEY_CODES.BACK_KEY, + deleteKey = constants_1.KEY_CODES.DELETE_KEY; // We are typing into a text input and have a value, we want to show a dropdown + // notice. Otherwise hide the dropdown + + if (this._isTextElement) { + var canShowDropdownNotice = canAddItem.notice && value; + + if (canShowDropdownNotice) { + var dropdownItem = this._getTemplate('notice', canAddItem.notice); + + this.dropdown.element.innerHTML = dropdownItem.outerHTML; + this.showDropdown(true); + } else { + this.hideDropdown(true); + } + } else { + var wasRemovalKeyCode = keyCode === backKey || keyCode === deleteKey; + var userHasRemovedValue = wasRemovalKeyCode && target && !target.value; + var canReactivateChoices = !this._isTextElement && this._isSearching; + var canSearch = this._canSearch && canAddItem.response; + + if (userHasRemovedValue && canReactivateChoices) { + this._isSearching = false; + + this._store.dispatch((0, choices_1.activateChoices)(true)); + } else if (canSearch) { + this._handleSearch(this.input.rawValue); + } + } + + this._canSearch = this.config.searchEnabled; + }; + + Choices.prototype._onSelectKey = function (event, hasItems) { + var ctrlKey = event.ctrlKey, + metaKey = event.metaKey; + var hasCtrlDownKeyPressed = ctrlKey || metaKey; // If CTRL + A or CMD + A have been pressed and there are items to select + + if (hasCtrlDownKeyPressed && hasItems) { + this._canSearch = false; + var shouldHightlightAll = this.config.removeItems && !this.input.value && this.input.element === document.activeElement; + + if (shouldHightlightAll) { + this.highlightAll(); + } + } + }; + + Choices.prototype._onEnterKey = function (event, activeItems, hasActiveDropdown) { + var target = event.target; + var enterKey = constants_1.KEY_CODES.ENTER_KEY; + var targetWasButton = target && target.hasAttribute('data-button'); + + if (this._isTextElement && target && target.value) { + var value = this.input.value; + + var canAddItem = this._canAddItem(activeItems, value); + + if (canAddItem.response) { + this.hideDropdown(true); + + this._addItem({ + value: value + }); + + this._triggerChange(value); + + this.clearInput(); + } + } + + if (targetWasButton) { + this._handleButtonAction(activeItems, target); + + event.preventDefault(); + } + + if (hasActiveDropdown) { + var highlightedChoice = this.dropdown.getChild(".".concat(this.config.classNames.highlightedState)); + + if (highlightedChoice) { + // add enter keyCode value + if (activeItems[0]) { + activeItems[0].keyCode = enterKey; // eslint-disable-line no-param-reassign + } + + this._handleChoiceAction(activeItems, highlightedChoice); + } + + event.preventDefault(); + } else if (this._isSelectOneElement) { + this.showDropdown(); + event.preventDefault(); + } + }; + + Choices.prototype._onEscapeKey = function (hasActiveDropdown) { + if (hasActiveDropdown) { + this.hideDropdown(true); + this.containerOuter.focus(); + } + }; + + Choices.prototype._onDirectionKey = function (event, hasActiveDropdown) { + var keyCode = event.keyCode, + metaKey = event.metaKey; + var downKey = constants_1.KEY_CODES.DOWN_KEY, + pageUpKey = constants_1.KEY_CODES.PAGE_UP_KEY, + pageDownKey = constants_1.KEY_CODES.PAGE_DOWN_KEY; // If up or down key is pressed, traverse through options + + if (hasActiveDropdown || this._isSelectOneElement) { + this.showDropdown(); + this._canSearch = false; + var directionInt = keyCode === downKey || keyCode === pageDownKey ? 1 : -1; + var skipKey = metaKey || keyCode === pageDownKey || keyCode === pageUpKey; + var selectableChoiceIdentifier = '[data-choice-selectable]'; + var nextEl = void 0; + + if (skipKey) { + if (directionInt > 0) { + nextEl = this.dropdown.element.querySelector("".concat(selectableChoiceIdentifier, ":last-of-type")); + } else { + nextEl = this.dropdown.element.querySelector(selectableChoiceIdentifier); + } + } else { + var currentEl = this.dropdown.element.querySelector(".".concat(this.config.classNames.highlightedState)); + + if (currentEl) { + nextEl = (0, utils_1.getAdjacentEl)(currentEl, selectableChoiceIdentifier, directionInt); + } else { + nextEl = this.dropdown.element.querySelector(selectableChoiceIdentifier); + } + } + + if (nextEl) { + // We prevent default to stop the cursor moving + // when pressing the arrow + if (!(0, utils_1.isScrolledIntoView)(nextEl, this.choiceList.element, directionInt)) { + this.choiceList.scrollToChildElement(nextEl, directionInt); + } + + this._highlightChoice(nextEl); + } // Prevent default to maintain cursor position whilst + // traversing dropdown options + + + event.preventDefault(); + } + }; + + Choices.prototype._onDeleteKey = function (event, activeItems, hasFocusedInput) { + var target = event.target; // If backspace or delete key is pressed and the input has no value + + if (!this._isSelectOneElement && !target.value && hasFocusedInput) { + this._handleBackspace(activeItems); + + event.preventDefault(); + } + }; + + Choices.prototype._onTouchMove = function () { + if (this._wasTap) { + this._wasTap = false; + } + }; + + Choices.prototype._onTouchEnd = function (event) { + var target = (event || event.touches[0]).target; + var touchWasWithinContainer = this._wasTap && this.containerOuter.element.contains(target); + + if (touchWasWithinContainer) { + var containerWasExactTarget = target === this.containerOuter.element || target === this.containerInner.element; + + if (containerWasExactTarget) { + if (this._isTextElement) { + this.input.focus(); + } else if (this._isSelectMultipleElement) { + this.showDropdown(); + } + } // Prevents focus event firing + + + event.stopPropagation(); + } + + this._wasTap = true; + }; + /** + * Handles mousedown event in capture mode for containetOuter.element + */ + + + Choices.prototype._onMouseDown = function (event) { + var target = event.target; + + if (!(target instanceof HTMLElement)) { + return; + } // If we have our mouse down on the scrollbar and are on IE11... + + + if (IS_IE11 && this.choiceList.element.contains(target)) { + // check if click was on a scrollbar area + var firstChoice = this.choiceList.element.firstElementChild; + var isOnScrollbar = this._direction === 'ltr' ? event.offsetX >= firstChoice.offsetWidth : event.offsetX < firstChoice.offsetLeft; + this._isScrollingOnIe = isOnScrollbar; + } + + if (target === this.input.element) { + return; + } + + var item = target.closest('[data-button],[data-item],[data-choice]'); + + if (item instanceof HTMLElement) { + var hasShiftKey = event.shiftKey; + var activeItems = this._store.activeItems; + var dataset = item.dataset; + + if ('button' in dataset) { + this._handleButtonAction(activeItems, item); + } else if ('item' in dataset) { + this._handleItemAction(activeItems, item, hasShiftKey); + } else if ('choice' in dataset) { + this._handleChoiceAction(activeItems, item); + } + } + + event.preventDefault(); + }; + /** + * Handles mouseover event over this.dropdown + * @param {MouseEvent} event + */ + + + Choices.prototype._onMouseOver = function (_a) { + var target = _a.target; + + if (target instanceof HTMLElement && 'choice' in target.dataset) { + this._highlightChoice(target); + } + }; + + Choices.prototype._onClick = function (_a) { + var target = _a.target; + var clickWasWithinContainer = this.containerOuter.element.contains(target); + + if (clickWasWithinContainer) { + if (!this.dropdown.isActive && !this.containerOuter.isDisabled) { + if (this._isTextElement) { + if (document.activeElement !== this.input.element) { + this.input.focus(); + } + } else { + this.showDropdown(); + this.containerOuter.focus(); + } + } else if (this._isSelectOneElement && target !== this.input.element && !this.dropdown.element.contains(target)) { + this.hideDropdown(); + } + } else { + var hasHighlightedItems = this._store.highlightedActiveItems.length > 0; + + if (hasHighlightedItems) { + this.unhighlightAll(); + } + + this.containerOuter.removeFocusState(); + this.hideDropdown(true); + } + }; + + Choices.prototype._onFocus = function (_a) { + var _b; + + var _this = this; + + var target = _a.target; + var focusWasWithinContainer = target && this.containerOuter.element.contains(target); + + if (!focusWasWithinContainer) { + return; + } + + var focusActions = (_b = {}, _b[constants_1.TEXT_TYPE] = function () { + if (target === _this.input.element) { + _this.containerOuter.addFocusState(); + } + }, _b[constants_1.SELECT_ONE_TYPE] = function () { + _this.containerOuter.addFocusState(); + + if (target === _this.input.element) { + _this.showDropdown(true); + } + }, _b[constants_1.SELECT_MULTIPLE_TYPE] = function () { + if (target === _this.input.element) { + _this.showDropdown(true); // If element is a select box, the focused element is the container and the dropdown + // isn't already open, focus and show dropdown + + + _this.containerOuter.addFocusState(); + } + }, _b); + focusActions[this.passedElement.element.type](); + }; + + Choices.prototype._onBlur = function (_a) { + var _b; + + var _this = this; + + var target = _a.target; + var blurWasWithinContainer = target && this.containerOuter.element.contains(target); + + if (blurWasWithinContainer && !this._isScrollingOnIe) { + var activeItems = this._store.activeItems; + var hasHighlightedItems_1 = activeItems.some(function (item) { + return item.highlighted; + }); + var blurActions = (_b = {}, _b[constants_1.TEXT_TYPE] = function () { + if (target === _this.input.element) { + _this.containerOuter.removeFocusState(); + + if (hasHighlightedItems_1) { + _this.unhighlightAll(); + } + + _this.hideDropdown(true); + } + }, _b[constants_1.SELECT_ONE_TYPE] = function () { + _this.containerOuter.removeFocusState(); + + if (target === _this.input.element || target === _this.containerOuter.element && !_this._canSearch) { + _this.hideDropdown(true); + } + }, _b[constants_1.SELECT_MULTIPLE_TYPE] = function () { + if (target === _this.input.element) { + _this.containerOuter.removeFocusState(); + + _this.hideDropdown(true); + + if (hasHighlightedItems_1) { + _this.unhighlightAll(); + } + } + }, _b); + blurActions[this.passedElement.element.type](); + } else { + // On IE11, clicking the scollbar blurs our input and thus + // closes the dropdown. To stop this, we refocus our input + // if we know we are on IE *and* are scrolling. + this._isScrollingOnIe = false; + this.input.element.focus(); + } + }; + + Choices.prototype._onFormReset = function () { + this._store.dispatch((0, misc_1.resetTo)(this._initialState)); + }; + + Choices.prototype._highlightChoice = function (el) { + var _this = this; + + if (el === void 0) { + el = null; + } + + var choices = Array.from(this.dropdown.element.querySelectorAll('[data-choice-selectable]')); + + if (!choices.length) { + return; + } + + var passedEl = el; + var highlightedChoices = Array.from(this.dropdown.element.querySelectorAll(".".concat(this.config.classNames.highlightedState))); // Remove any highlighted choices + + highlightedChoices.forEach(function (choice) { + choice.classList.remove(_this.config.classNames.highlightedState); + choice.setAttribute('aria-selected', 'false'); + }); + + if (passedEl) { + this._highlightPosition = choices.indexOf(passedEl); + } else { + // Highlight choice based on last known highlight location + if (choices.length > this._highlightPosition) { + // If we have an option to highlight + passedEl = choices[this._highlightPosition]; + } else { + // Otherwise highlight the option before + passedEl = choices[choices.length - 1]; + } + + if (!passedEl) { + passedEl = choices[0]; + } + } + + passedEl.classList.add(this.config.classNames.highlightedState); + passedEl.setAttribute('aria-selected', 'true'); + this.passedElement.triggerEvent(constants_1.EVENTS.highlightChoice, { + el: passedEl + }); + + if (this.dropdown.isActive) { + // IE11 ignores aria-label and blocks virtual keyboard + // if aria-activedescendant is set without a dropdown + this.input.setActiveDescendant(passedEl.id); + this.containerOuter.setActiveDescendant(passedEl.id); + } + }; + + Choices.prototype._addItem = function (_a) { + var value = _a.value, + _b = _a.label, + label = _b === void 0 ? null : _b, + _c = _a.choiceId, + choiceId = _c === void 0 ? -1 : _c, + _d = _a.groupId, + groupId = _d === void 0 ? -1 : _d, + _e = _a.customProperties, + customProperties = _e === void 0 ? {} : _e, + _f = _a.placeholder, + placeholder = _f === void 0 ? false : _f, + _g = _a.keyCode, + keyCode = _g === void 0 ? -1 : _g; + var passedValue = typeof value === 'string' ? value.trim() : value; + var items = this._store.items; + var passedLabel = label || passedValue; + var passedOptionId = choiceId || -1; + var group = groupId >= 0 ? this._store.getGroupById(groupId) : null; + var id = items ? items.length + 1 : 1; // If a prepended value has been passed, prepend it + + if (this.config.prependValue) { + passedValue = this.config.prependValue + passedValue.toString(); + } // If an appended value has been passed, append it + + + if (this.config.appendValue) { + passedValue += this.config.appendValue.toString(); + } + + this._store.dispatch((0, items_1.addItem)({ + value: passedValue, + label: passedLabel, + id: id, + choiceId: passedOptionId, + groupId: groupId, + customProperties: customProperties, + placeholder: placeholder, + keyCode: keyCode + })); + + if (this._isSelectOneElement) { + this.removeActiveItems(id); + } // Trigger change event + + + this.passedElement.triggerEvent(constants_1.EVENTS.addItem, { + id: id, + value: passedValue, + label: passedLabel, + customProperties: customProperties, + groupValue: group && group.value ? group.value : null, + keyCode: keyCode + }); + }; + + Choices.prototype._removeItem = function (item) { + var id = item.id, + value = item.value, + label = item.label, + customProperties = item.customProperties, + choiceId = item.choiceId, + groupId = item.groupId; + var group = groupId && groupId >= 0 ? this._store.getGroupById(groupId) : null; + + if (!id || !choiceId) { + return; + } + + this._store.dispatch((0, items_1.removeItem)(id, choiceId)); + + this.passedElement.triggerEvent(constants_1.EVENTS.removeItem, { + id: id, + value: value, + label: label, + customProperties: customProperties, + groupValue: group && group.value ? group.value : null + }); + }; + + Choices.prototype._addChoice = function (_a) { + var value = _a.value, + _b = _a.label, + label = _b === void 0 ? null : _b, + _c = _a.isSelected, + isSelected = _c === void 0 ? false : _c, + _d = _a.isDisabled, + isDisabled = _d === void 0 ? false : _d, + _e = _a.groupId, + groupId = _e === void 0 ? -1 : _e, + _f = _a.customProperties, + customProperties = _f === void 0 ? {} : _f, + _g = _a.placeholder, + placeholder = _g === void 0 ? false : _g, + _h = _a.keyCode, + keyCode = _h === void 0 ? -1 : _h; + + if (typeof value === 'undefined' || value === null) { + return; + } // Generate unique id + + + var choices = this._store.choices; + var choiceLabel = label || value; + var choiceId = choices ? choices.length + 1 : 1; + var choiceElementId = "".concat(this._baseId, "-").concat(this._idNames.itemChoice, "-").concat(choiceId); + + this._store.dispatch((0, choices_1.addChoice)({ + id: choiceId, + groupId: groupId, + elementId: choiceElementId, + value: value, + label: choiceLabel, + disabled: isDisabled, + customProperties: customProperties, + placeholder: placeholder, + keyCode: keyCode + })); + + if (isSelected) { + this._addItem({ + value: value, + label: choiceLabel, + choiceId: choiceId, + customProperties: customProperties, + placeholder: placeholder, + keyCode: keyCode + }); + } + }; + + Choices.prototype._addGroup = function (_a) { + var _this = this; + + var group = _a.group, + id = _a.id, + _b = _a.valueKey, + valueKey = _b === void 0 ? 'value' : _b, + _c = _a.labelKey, + labelKey = _c === void 0 ? 'label' : _c; + var groupChoices = (0, utils_1.isType)('Object', group) ? group.choices : Array.from(group.getElementsByTagName('OPTION')); + var groupId = id || Math.floor(new Date().valueOf() * Math.random()); + var isDisabled = group.disabled ? group.disabled : false; + + if (groupChoices) { + this._store.dispatch((0, groups_1.addGroup)({ + value: group.label, + id: groupId, + active: true, + disabled: isDisabled + })); + + var addGroupChoices = function (choice) { + var isOptDisabled = choice.disabled || choice.parentNode && choice.parentNode.disabled; + + _this._addChoice({ + value: choice[valueKey], + label: (0, utils_1.isType)('Object', choice) ? choice[labelKey] : choice.innerHTML, + isSelected: choice.selected, + isDisabled: isOptDisabled, + groupId: groupId, + customProperties: choice.customProperties, + placeholder: choice.placeholder + }); + }; + + groupChoices.forEach(addGroupChoices); + } else { + this._store.dispatch((0, groups_1.addGroup)({ + value: group.label, + id: group.id, + active: false, + disabled: group.disabled + })); + } + }; + + Choices.prototype._getTemplate = function (template) { + var _a; + + var args = []; + + for (var _i = 1; _i < arguments.length; _i++) { + args[_i - 1] = arguments[_i]; + } + + return (_a = this._templates[template]).call.apply(_a, __spreadArray([this, this.config], args, false)); + }; + + Choices.prototype._createTemplates = function () { + var callbackOnCreateTemplates = this.config.callbackOnCreateTemplates; + var userTemplates = {}; + + if (callbackOnCreateTemplates && typeof callbackOnCreateTemplates === 'function') { + userTemplates = callbackOnCreateTemplates.call(this, utils_1.strToEl); + } + + this._templates = (0, deepmerge_1.default)(templates_1.default, userTemplates); + }; + + Choices.prototype._createElements = function () { + this.containerOuter = new components_1.Container({ + element: this._getTemplate('containerOuter', this._direction, this._isSelectElement, this._isSelectOneElement, this.config.searchEnabled, this.passedElement.element.type), + classNames: this.config.classNames, + type: this.passedElement.element.type, + position: this.config.position + }); + this.containerInner = new components_1.Container({ + element: this._getTemplate('containerInner'), + classNames: this.config.classNames, + type: this.passedElement.element.type, + position: this.config.position + }); + this.input = new components_1.Input({ + element: this._getTemplate('input', this._placeholderValue), + classNames: this.config.classNames, + type: this.passedElement.element.type, + preventPaste: !this.config.paste + }); + this.choiceList = new components_1.List({ + element: this._getTemplate('choiceList', this._isSelectOneElement) + }); + this.itemList = new components_1.List({ + element: this._getTemplate('itemList', this._isSelectOneElement) + }); + this.dropdown = new components_1.Dropdown({ + element: this._getTemplate('dropdown'), + classNames: this.config.classNames, + type: this.passedElement.element.type + }); + }; + + Choices.prototype._createStructure = function () { + // Hide original element + this.passedElement.conceal(); // Wrap input in container preserving DOM ordering + + this.containerInner.wrap(this.passedElement.element); // Wrapper inner container with outer container + + this.containerOuter.wrap(this.containerInner.element); + + if (this._isSelectOneElement) { + this.input.placeholder = this.config.searchPlaceholderValue || ''; + } else if (this._placeholderValue) { + this.input.placeholder = this._placeholderValue; + this.input.setWidth(); + } + + this.containerOuter.element.appendChild(this.containerInner.element); + this.containerOuter.element.appendChild(this.dropdown.element); + this.containerInner.element.appendChild(this.itemList.element); + + if (!this._isTextElement) { + this.dropdown.element.appendChild(this.choiceList.element); + } + + if (!this._isSelectOneElement) { + this.containerInner.element.appendChild(this.input.element); + } else if (this.config.searchEnabled) { + this.dropdown.element.insertBefore(this.input.element, this.dropdown.element.firstChild); + } + + if (this._isSelectElement) { + this._highlightPosition = 0; + this._isSearching = false; + + this._startLoading(); + + if (this._presetGroups.length) { + this._addPredefinedGroups(this._presetGroups); + } else { + this._addPredefinedChoices(this._presetChoices); + } + + this._stopLoading(); + } + + if (this._isTextElement) { + this._addPredefinedItems(this._presetItems); + } + }; + + Choices.prototype._addPredefinedGroups = function (groups) { + var _this = this; // If we have a placeholder option + + + var placeholderChoice = this.passedElement.placeholderOption; + + if (placeholderChoice && placeholderChoice.parentNode && placeholderChoice.parentNode.tagName === 'SELECT') { + this._addChoice({ + value: placeholderChoice.value, + label: placeholderChoice.innerHTML, + isSelected: placeholderChoice.selected, + isDisabled: placeholderChoice.disabled, + placeholder: true + }); + } + + groups.forEach(function (group) { + return _this._addGroup({ + group: group, + id: group.id || null + }); + }); + }; + + Choices.prototype._addPredefinedChoices = function (choices) { + var _this = this; // If sorting is enabled or the user is searching, filter choices + + + if (this.config.shouldSort) { + choices.sort(this.config.sorter); + } + + var hasSelectedChoice = choices.some(function (choice) { + return choice.selected; + }); + var firstEnabledChoiceIndex = choices.findIndex(function (choice) { + return choice.disabled === undefined || !choice.disabled; + }); + choices.forEach(function (choice, index) { + var _a = choice.value, + value = _a === void 0 ? '' : _a, + label = choice.label, + customProperties = choice.customProperties, + placeholder = choice.placeholder; + + if (_this._isSelectElement) { + // If the choice is actually a group + if (choice.choices) { + _this._addGroup({ + group: choice, + id: choice.id || null + }); + } else { + /** + * If there is a selected choice already or the choice is not the first in + * the array, add each choice normally. + * + * Otherwise we pre-select the first enabled choice in the array ("select-one" only) + */ + var shouldPreselect = _this._isSelectOneElement && !hasSelectedChoice && index === firstEnabledChoiceIndex; + var isSelected = shouldPreselect ? true : choice.selected; + var isDisabled = choice.disabled; + + _this._addChoice({ + value: value, + label: label, + isSelected: !!isSelected, + isDisabled: !!isDisabled, + placeholder: !!placeholder, + customProperties: customProperties + }); + } + } else { + _this._addChoice({ + value: value, + label: label, + isSelected: !!choice.selected, + isDisabled: !!choice.disabled, + placeholder: !!choice.placeholder, + customProperties: customProperties + }); + } + }); + }; + + Choices.prototype._addPredefinedItems = function (items) { + var _this = this; + + items.forEach(function (item) { + if (typeof item === 'object' && item.value) { + _this._addItem({ + value: item.value, + label: item.label, + choiceId: item.id, + customProperties: item.customProperties, + placeholder: item.placeholder + }); + } + + if (typeof item === 'string') { + _this._addItem({ + value: item + }); + } + }); + }; + + Choices.prototype._setChoiceOrItem = function (item) { + var _this = this; + + var itemType = (0, utils_1.getType)(item).toLowerCase(); + var handleType = { + object: function () { + if (!item.value) { + return; + } // If we are dealing with a select input, we need to create an option first + // that is then selected. For text inputs we can just add items normally. + + + if (!_this._isTextElement) { + _this._addChoice({ + value: item.value, + label: item.label, + isSelected: true, + isDisabled: false, + customProperties: item.customProperties, + placeholder: item.placeholder + }); + } else { + _this._addItem({ + value: item.value, + label: item.label, + choiceId: item.id, + customProperties: item.customProperties, + placeholder: item.placeholder + }); + } + }, + string: function () { + if (!_this._isTextElement) { + _this._addChoice({ + value: item, + label: item, + isSelected: true, + isDisabled: false + }); + } else { + _this._addItem({ + value: item + }); + } + } + }; + handleType[itemType](); + }; + + Choices.prototype._findAndSelectChoiceByValue = function (value) { + var _this = this; + + var choices = this._store.choices; // Check 'value' property exists and the choice isn't already selected + + var foundChoice = choices.find(function (choice) { + return _this.config.valueComparer(choice.value, value); + }); + + if (foundChoice && !foundChoice.selected) { + this._addItem({ + value: foundChoice.value, + label: foundChoice.label, + choiceId: foundChoice.id, + groupId: foundChoice.groupId, + customProperties: foundChoice.customProperties, + placeholder: foundChoice.placeholder, + keyCode: foundChoice.keyCode + }); + } + }; + + Choices.prototype._generatePlaceholderValue = function () { + if (this._isSelectElement && this.passedElement.placeholderOption) { + var placeholderOption = this.passedElement.placeholderOption; + return placeholderOption ? placeholderOption.text : null; + } + + var _a = this.config, + placeholder = _a.placeholder, + placeholderValue = _a.placeholderValue; + var dataset = this.passedElement.element.dataset; + + if (placeholder) { + if (placeholderValue) { + return placeholderValue; + } + + if (dataset.placeholder) { + return dataset.placeholder; + } + } + + return null; + }; + + return Choices; +}(); + +exports["default"] = Choices; + +/***/ }), + +/***/ 613: +/***/ (function(__unused_webpack_module, exports, __webpack_require__) { + + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); + +var utils_1 = __webpack_require__(799); + +var constants_1 = __webpack_require__(883); + +var Container = +/** @class */ +function () { + function Container(_a) { + var element = _a.element, + type = _a.type, + classNames = _a.classNames, + position = _a.position; + this.element = element; + this.classNames = classNames; + this.type = type; + this.position = position; + this.isOpen = false; + this.isFlipped = false; + this.isFocussed = false; + this.isDisabled = false; + this.isLoading = false; + this._onFocus = this._onFocus.bind(this); + this._onBlur = this._onBlur.bind(this); + } + + Container.prototype.addEventListeners = function () { + this.element.addEventListener('focus', this._onFocus); + this.element.addEventListener('blur', this._onBlur); + }; + + Container.prototype.removeEventListeners = function () { + this.element.removeEventListener('focus', this._onFocus); + this.element.removeEventListener('blur', this._onBlur); + }; + /** + * Determine whether container should be flipped based on passed + * dropdown position + */ + + + Container.prototype.shouldFlip = function (dropdownPos) { + if (typeof dropdownPos !== 'number') { + return false; + } // If flip is enabled and the dropdown bottom position is + // greater than the window height flip the dropdown. + + + var shouldFlip = false; + + if (this.position === 'auto') { + shouldFlip = !window.matchMedia("(min-height: ".concat(dropdownPos + 1, "px)")).matches; + } else if (this.position === 'top') { + shouldFlip = true; + } + + return shouldFlip; + }; + + Container.prototype.setActiveDescendant = function (activeDescendantID) { + this.element.setAttribute('aria-activedescendant', activeDescendantID); + }; + + Container.prototype.removeActiveDescendant = function () { + this.element.removeAttribute('aria-activedescendant'); + }; + + Container.prototype.open = function (dropdownPos) { + this.element.classList.add(this.classNames.openState); + this.element.setAttribute('aria-expanded', 'true'); + this.isOpen = true; + + if (this.shouldFlip(dropdownPos)) { + this.element.classList.add(this.classNames.flippedState); + this.isFlipped = true; + } + }; + + Container.prototype.close = function () { + this.element.classList.remove(this.classNames.openState); + this.element.setAttribute('aria-expanded', 'false'); + this.removeActiveDescendant(); + this.isOpen = false; // A dropdown flips if it does not have space within the page + + if (this.isFlipped) { + this.element.classList.remove(this.classNames.flippedState); + this.isFlipped = false; + } + }; + + Container.prototype.focus = function () { + if (!this.isFocussed) { + this.element.focus(); + } + }; + + Container.prototype.addFocusState = function () { + this.element.classList.add(this.classNames.focusState); + }; + + Container.prototype.removeFocusState = function () { + this.element.classList.remove(this.classNames.focusState); + }; + + Container.prototype.enable = function () { + this.element.classList.remove(this.classNames.disabledState); + this.element.removeAttribute('aria-disabled'); + + if (this.type === constants_1.SELECT_ONE_TYPE) { + this.element.setAttribute('tabindex', '0'); + } + + this.isDisabled = false; + }; + + Container.prototype.disable = function () { + this.element.classList.add(this.classNames.disabledState); + this.element.setAttribute('aria-disabled', 'true'); + + if (this.type === constants_1.SELECT_ONE_TYPE) { + this.element.setAttribute('tabindex', '-1'); + } + + this.isDisabled = true; + }; + + Container.prototype.wrap = function (element) { + (0, utils_1.wrap)(element, this.element); + }; + + Container.prototype.unwrap = function (element) { + if (this.element.parentNode) { + // Move passed element outside this element + this.element.parentNode.insertBefore(element, this.element); // Remove this element + + this.element.parentNode.removeChild(this.element); + } + }; + + Container.prototype.addLoadingState = function () { + this.element.classList.add(this.classNames.loadingState); + this.element.setAttribute('aria-busy', 'true'); + this.isLoading = true; + }; + + Container.prototype.removeLoadingState = function () { + this.element.classList.remove(this.classNames.loadingState); + this.element.removeAttribute('aria-busy'); + this.isLoading = false; + }; + + Container.prototype._onFocus = function () { + this.isFocussed = true; + }; + + Container.prototype._onBlur = function () { + this.isFocussed = false; + }; + + return Container; +}(); + +exports["default"] = Container; + +/***/ }), + +/***/ 217: +/***/ (function(__unused_webpack_module, exports) { + + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); + +var Dropdown = +/** @class */ +function () { + function Dropdown(_a) { + var element = _a.element, + type = _a.type, + classNames = _a.classNames; + this.element = element; + this.classNames = classNames; + this.type = type; + this.isActive = false; + } + + Object.defineProperty(Dropdown.prototype, "distanceFromTopWindow", { + /** + * Bottom position of dropdown in viewport coordinates + */ + get: function () { + return this.element.getBoundingClientRect().bottom; + }, + enumerable: false, + configurable: true + }); + + Dropdown.prototype.getChild = function (selector) { + return this.element.querySelector(selector); + }; + /** + * Show dropdown to user by adding active state class + */ + + + Dropdown.prototype.show = function () { + this.element.classList.add(this.classNames.activeState); + this.element.setAttribute('aria-expanded', 'true'); + this.isActive = true; + return this; + }; + /** + * Hide dropdown from user + */ + + + Dropdown.prototype.hide = function () { + this.element.classList.remove(this.classNames.activeState); + this.element.setAttribute('aria-expanded', 'false'); + this.isActive = false; + return this; + }; + + return Dropdown; +}(); + +exports["default"] = Dropdown; + +/***/ }), + +/***/ 520: +/***/ (function(__unused_webpack_module, exports, __webpack_require__) { + + + +var __importDefault = this && this.__importDefault || function (mod) { + return mod && mod.__esModule ? mod : { + "default": mod + }; +}; + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports.WrappedSelect = exports.WrappedInput = exports.List = exports.Input = exports.Container = exports.Dropdown = void 0; + +var dropdown_1 = __importDefault(__webpack_require__(217)); + +exports.Dropdown = dropdown_1.default; + +var container_1 = __importDefault(__webpack_require__(613)); + +exports.Container = container_1.default; + +var input_1 = __importDefault(__webpack_require__(11)); + +exports.Input = input_1.default; + +var list_1 = __importDefault(__webpack_require__(624)); + +exports.List = list_1.default; + +var wrapped_input_1 = __importDefault(__webpack_require__(541)); + +exports.WrappedInput = wrapped_input_1.default; + +var wrapped_select_1 = __importDefault(__webpack_require__(982)); + +exports.WrappedSelect = wrapped_select_1.default; + +/***/ }), + +/***/ 11: +/***/ (function(__unused_webpack_module, exports, __webpack_require__) { + + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); + +var utils_1 = __webpack_require__(799); + +var constants_1 = __webpack_require__(883); + +var Input = +/** @class */ +function () { + function Input(_a) { + var element = _a.element, + type = _a.type, + classNames = _a.classNames, + preventPaste = _a.preventPaste; + this.element = element; + this.type = type; + this.classNames = classNames; + this.preventPaste = preventPaste; + this.isFocussed = this.element.isEqualNode(document.activeElement); + this.isDisabled = element.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); + } + + Object.defineProperty(Input.prototype, "placeholder", { + set: function (placeholder) { + this.element.placeholder = placeholder; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(Input.prototype, "value", { + get: function () { + return (0, utils_1.sanitise)(this.element.value); + }, + set: function (value) { + this.element.value = value; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(Input.prototype, "rawValue", { + get: function () { + return this.element.value; + }, + enumerable: false, + configurable: true + }); + + Input.prototype.addEventListeners = function () { + this.element.addEventListener('paste', this._onPaste); + this.element.addEventListener('input', this._onInput, { + passive: true + }); + this.element.addEventListener('focus', this._onFocus, { + passive: true + }); + this.element.addEventListener('blur', this._onBlur, { + passive: true + }); + }; + + Input.prototype.removeEventListeners = function () { + this.element.removeEventListener('input', this._onInput); + this.element.removeEventListener('paste', this._onPaste); + this.element.removeEventListener('focus', this._onFocus); + this.element.removeEventListener('blur', this._onBlur); + }; + + Input.prototype.enable = function () { + this.element.removeAttribute('disabled'); + this.isDisabled = false; + }; + + Input.prototype.disable = function () { + this.element.setAttribute('disabled', ''); + this.isDisabled = true; + }; + + Input.prototype.focus = function () { + if (!this.isFocussed) { + this.element.focus(); + } + }; + + Input.prototype.blur = function () { + if (this.isFocussed) { + this.element.blur(); + } + }; + + Input.prototype.clear = function (setWidth) { + if (setWidth === void 0) { + setWidth = true; + } + + if (this.element.value) { + this.element.value = ''; + } + + if (setWidth) { + this.setWidth(); + } + + return this; + }; + /** + * Set the correct input width based on placeholder + * value or input value + */ + + + Input.prototype.setWidth = function () { + // Resize input to contents or placeholder + var _a = this.element, + style = _a.style, + value = _a.value, + placeholder = _a.placeholder; + style.minWidth = "".concat(placeholder.length + 1, "ch"); + style.width = "".concat(value.length + 1, "ch"); + }; + + Input.prototype.setActiveDescendant = function (activeDescendantID) { + this.element.setAttribute('aria-activedescendant', activeDescendantID); + }; + + Input.prototype.removeActiveDescendant = function () { + this.element.removeAttribute('aria-activedescendant'); + }; + + Input.prototype._onInput = function () { + if (this.type !== constants_1.SELECT_ONE_TYPE) { + this.setWidth(); + } + }; + + Input.prototype._onPaste = function (event) { + if (this.preventPaste) { + event.preventDefault(); + } + }; + + Input.prototype._onFocus = function () { + this.isFocussed = true; + }; + + Input.prototype._onBlur = function () { + this.isFocussed = false; + }; + + return Input; +}(); + +exports["default"] = Input; + +/***/ }), + +/***/ 624: +/***/ (function(__unused_webpack_module, exports, __webpack_require__) { + + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); + +var constants_1 = __webpack_require__(883); + +var List = +/** @class */ +function () { + function List(_a) { + var element = _a.element; + this.element = element; + this.scrollPos = this.element.scrollTop; + this.height = this.element.offsetHeight; + } + + List.prototype.clear = function () { + this.element.innerHTML = ''; + }; + + List.prototype.append = function (node) { + this.element.appendChild(node); + }; + + List.prototype.getChild = function (selector) { + return this.element.querySelector(selector); + }; + + List.prototype.hasChildren = function () { + return this.element.hasChildNodes(); + }; + + List.prototype.scrollToTop = function () { + this.element.scrollTop = 0; + }; + + List.prototype.scrollToChildElement = function (element, direction) { + var _this = this; + + if (!element) { + return; + } + + var listHeight = this.element.offsetHeight; // Scroll position of dropdown + + var listScrollPosition = this.element.scrollTop + listHeight; + var elementHeight = element.offsetHeight; // Distance from bottom of element to top of parent + + var elementPos = element.offsetTop + elementHeight; // Difference between the element and scroll position + + var destination = direction > 0 ? this.element.scrollTop + elementPos - listScrollPosition : element.offsetTop; + requestAnimationFrame(function () { + _this._animateScroll(destination, direction); + }); + }; + + List.prototype._scrollDown = function (scrollPos, strength, destination) { + var easing = (destination - scrollPos) / strength; + var distance = easing > 1 ? easing : 1; + this.element.scrollTop = scrollPos + distance; + }; + + List.prototype._scrollUp = function (scrollPos, strength, destination) { + var easing = (scrollPos - destination) / strength; + var distance = easing > 1 ? easing : 1; + this.element.scrollTop = scrollPos - distance; + }; + + List.prototype._animateScroll = function (destination, direction) { + var _this = this; + + var strength = constants_1.SCROLLING_SPEED; + var choiceListScrollTop = this.element.scrollTop; + var continueAnimation = false; + + if (direction > 0) { + this._scrollDown(choiceListScrollTop, strength, destination); + + if (choiceListScrollTop < destination) { + continueAnimation = true; + } + } else { + this._scrollUp(choiceListScrollTop, strength, destination); + + if (choiceListScrollTop > destination) { + continueAnimation = true; + } + } + + if (continueAnimation) { + requestAnimationFrame(function () { + _this._animateScroll(destination, direction); + }); + } + }; + + return List; +}(); + +exports["default"] = List; + +/***/ }), + +/***/ 730: +/***/ (function(__unused_webpack_module, exports, __webpack_require__) { + + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); + +var utils_1 = __webpack_require__(799); + +var WrappedElement = +/** @class */ +function () { + function WrappedElement(_a) { + var element = _a.element, + classNames = _a.classNames; + this.element = element; + this.classNames = classNames; + + if (!(element instanceof HTMLInputElement) && !(element instanceof HTMLSelectElement)) { + throw new TypeError('Invalid element passed'); + } + + this.isDisabled = false; + } + + Object.defineProperty(WrappedElement.prototype, "isActive", { + get: function () { + return this.element.dataset.choice === 'active'; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(WrappedElement.prototype, "dir", { + get: function () { + return this.element.dir; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(WrappedElement.prototype, "value", { + get: function () { + return this.element.value; + }, + set: function (value) { + // you must define setter here otherwise it will be readonly property + this.element.value = value; + }, + enumerable: false, + configurable: true + }); + + WrappedElement.prototype.conceal = function () { + // Hide passed input + this.element.classList.add(this.classNames.input); + this.element.hidden = true; // Remove element from tab index + + this.element.tabIndex = -1; // Backup original styles if any + + var origStyle = this.element.getAttribute('style'); + + if (origStyle) { + this.element.setAttribute('data-choice-orig-style', origStyle); + } + + this.element.setAttribute('data-choice', 'active'); + }; + + WrappedElement.prototype.reveal = function () { + // Reinstate passed element + this.element.classList.remove(this.classNames.input); + this.element.hidden = false; + this.element.removeAttribute('tabindex'); // Recover original styles if any + + var origStyle = this.element.getAttribute('data-choice-orig-style'); + + if (origStyle) { + this.element.removeAttribute('data-choice-orig-style'); + this.element.setAttribute('style', origStyle); + } else { + this.element.removeAttribute('style'); + } + + this.element.removeAttribute('data-choice'); // Re-assign values - this is weird, I know + // @todo Figure out why we need to do this + + this.element.value = this.element.value; // eslint-disable-line no-self-assign + }; + + WrappedElement.prototype.enable = function () { + this.element.removeAttribute('disabled'); + this.element.disabled = false; + this.isDisabled = false; + }; + + WrappedElement.prototype.disable = function () { + this.element.setAttribute('disabled', ''); + this.element.disabled = true; + this.isDisabled = true; + }; + + WrappedElement.prototype.triggerEvent = function (eventType, data) { + (0, utils_1.dispatchEvent)(this.element, eventType, data); + }; + + return WrappedElement; +}(); + +exports["default"] = WrappedElement; + +/***/ }), + +/***/ 541: +/***/ (function(__unused_webpack_module, exports, __webpack_require__) { + + + +var __extends = this && this.__extends || function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || { + __proto__: [] + } instanceof Array && function (d, b) { + d.__proto__ = b; + } || function (d, b) { + for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; + }; + + return extendStatics(d, b); + }; + + return function (d, b) { + if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); + extendStatics(d, b); + + function __() { + this.constructor = d; + } + + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +}(); + +var __importDefault = this && this.__importDefault || function (mod) { + return mod && mod.__esModule ? mod : { + "default": mod + }; +}; + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); + +var wrapped_element_1 = __importDefault(__webpack_require__(730)); + +var WrappedInput = +/** @class */ +function (_super) { + __extends(WrappedInput, _super); + + function WrappedInput(_a) { + var element = _a.element, + classNames = _a.classNames, + delimiter = _a.delimiter; + + var _this = _super.call(this, { + element: element, + classNames: classNames + }) || this; + + _this.delimiter = delimiter; + return _this; + } + + Object.defineProperty(WrappedInput.prototype, "value", { + get: function () { + return this.element.value; + }, + set: function (value) { + this.element.setAttribute('value', value); + this.element.value = value; + }, + enumerable: false, + configurable: true + }); + return WrappedInput; +}(wrapped_element_1.default); + +exports["default"] = WrappedInput; + +/***/ }), + +/***/ 982: +/***/ (function(__unused_webpack_module, exports, __webpack_require__) { + + + +var __extends = this && this.__extends || function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || { + __proto__: [] + } instanceof Array && function (d, b) { + d.__proto__ = b; + } || function (d, b) { + for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; + }; + + return extendStatics(d, b); + }; + + return function (d, b) { + if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); + extendStatics(d, b); + + function __() { + this.constructor = d; + } + + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +}(); + +var __importDefault = this && this.__importDefault || function (mod) { + return mod && mod.__esModule ? mod : { + "default": mod + }; +}; + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); + +var wrapped_element_1 = __importDefault(__webpack_require__(730)); + +var WrappedSelect = +/** @class */ +function (_super) { + __extends(WrappedSelect, _super); + + function WrappedSelect(_a) { + var element = _a.element, + classNames = _a.classNames, + template = _a.template; + + var _this = _super.call(this, { + element: element, + classNames: classNames + }) || this; + + _this.template = template; + return _this; + } + + Object.defineProperty(WrappedSelect.prototype, "placeholderOption", { + get: function () { + return this.element.querySelector('option[value=""]') || // Backward compatibility layer for the non-standard placeholder attribute supported in older versions. + this.element.querySelector('option[placeholder]'); + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(WrappedSelect.prototype, "optionGroups", { + get: function () { + return Array.from(this.element.getElementsByTagName('OPTGROUP')); + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(WrappedSelect.prototype, "options", { + get: function () { + return Array.from(this.element.options); + }, + set: function (options) { + var _this = this; + + var fragment = document.createDocumentFragment(); + + var addOptionToFragment = function (data) { + // Create a standard select option + var option = _this.template(data); // Append it to fragment + + + fragment.appendChild(option); + }; // Add each list item to list + + + options.forEach(function (optionData) { + return addOptionToFragment(optionData); + }); + this.appendDocFragment(fragment); + }, + enumerable: false, + configurable: true + }); + + WrappedSelect.prototype.appendDocFragment = function (fragment) { + this.element.innerHTML = ''; + this.element.appendChild(fragment); + }; + + return WrappedSelect; +}(wrapped_element_1.default); + +exports["default"] = WrappedSelect; + +/***/ }), + +/***/ 883: +/***/ (function(__unused_webpack_module, exports) { + + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports.SCROLLING_SPEED = exports.SELECT_MULTIPLE_TYPE = exports.SELECT_ONE_TYPE = exports.TEXT_TYPE = exports.KEY_CODES = exports.ACTION_TYPES = exports.EVENTS = void 0; +exports.EVENTS = { + showDropdown: 'showDropdown', + hideDropdown: 'hideDropdown', + change: 'change', + choice: 'choice', + search: 'search', + addItem: 'addItem', + removeItem: 'removeItem', + highlightItem: 'highlightItem', + highlightChoice: 'highlightChoice', + unhighlightItem: 'unhighlightItem' +}; +exports.ACTION_TYPES = { + ADD_CHOICE: 'ADD_CHOICE', + FILTER_CHOICES: 'FILTER_CHOICES', + ACTIVATE_CHOICES: 'ACTIVATE_CHOICES', + CLEAR_CHOICES: 'CLEAR_CHOICES', + ADD_GROUP: 'ADD_GROUP', + ADD_ITEM: 'ADD_ITEM', + REMOVE_ITEM: 'REMOVE_ITEM', + HIGHLIGHT_ITEM: 'HIGHLIGHT_ITEM', + CLEAR_ALL: 'CLEAR_ALL', + RESET_TO: 'RESET_TO', + SET_IS_LOADING: 'SET_IS_LOADING' +}; +exports.KEY_CODES = { + BACK_KEY: 46, + DELETE_KEY: 8, + ENTER_KEY: 13, + A_KEY: 65, + ESC_KEY: 27, + UP_KEY: 38, + DOWN_KEY: 40, + PAGE_UP_KEY: 33, + PAGE_DOWN_KEY: 34 +}; +exports.TEXT_TYPE = 'text'; +exports.SELECT_ONE_TYPE = 'select-one'; +exports.SELECT_MULTIPLE_TYPE = 'select-multiple'; +exports.SCROLLING_SPEED = 4; + +/***/ }), + +/***/ 789: +/***/ (function(__unused_webpack_module, exports, __webpack_require__) { + + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports.DEFAULT_CONFIG = exports.DEFAULT_CLASSNAMES = void 0; + +var utils_1 = __webpack_require__(799); + +exports.DEFAULT_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', + 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', + noResults: 'has-no-results', + noChoices: 'has-no-choices' +}; +exports.DEFAULT_CONFIG = { + items: [], + choices: [], + silent: false, + renderChoiceLimit: -1, + maxItemCount: -1, + addItems: true, + addItemFilter: null, + removeItems: true, + removeItemButton: false, + editItems: false, + allowHTML: true, + duplicateItemsAllowed: true, + delimiter: ',', + paste: true, + searchEnabled: true, + searchChoices: true, + searchFloor: 1, + searchResultLimit: 4, + searchFields: ['label', 'value'], + position: 'auto', + resetScrollPosition: true, + shouldSort: true, + shouldSortItems: false, + sorter: utils_1.sortByAlpha, + placeholder: true, + 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 (value) { + return "Press Enter to add \"".concat((0, utils_1.sanitise)(value), "\""); + }, + maxItemText: function (maxItemCount) { + return "Only ".concat(maxItemCount, " values can be added"); + }, + valueComparer: function (value1, value2) { + return value1 === value2; + }, + fuseOptions: { + includeScore: true + }, + callbackOnInit: null, + callbackOnCreateTemplates: null, + classNames: exports.DEFAULT_CLASSNAMES +}; + +/***/ }), + +/***/ 18: +/***/ (function(__unused_webpack_module, exports) { + + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); + +/***/ }), + +/***/ 978: +/***/ (function(__unused_webpack_module, exports) { + + +/* eslint-disable @typescript-eslint/no-explicit-any */ + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); + +/***/ }), + +/***/ 948: +/***/ (function(__unused_webpack_module, exports) { + + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); + +/***/ }), + +/***/ 359: +/***/ (function(__unused_webpack_module, exports) { + + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); + +/***/ }), + +/***/ 285: +/***/ (function(__unused_webpack_module, exports) { + + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); + +/***/ }), + +/***/ 533: +/***/ (function(__unused_webpack_module, exports) { + + +/* eslint-disable @typescript-eslint/no-explicit-any */ + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); + +/***/ }), + +/***/ 187: +/***/ (function(__unused_webpack_module, exports, __webpack_require__) { + + + +var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) { + if (k2 === undefined) k2 = k; + Object.defineProperty(o, k2, { + enumerable: true, + get: function () { + return m[k]; + } + }); +} : function (o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +}); + +var __exportStar = this && this.__exportStar || function (m, exports) { + for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); +}; + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); + +__exportStar(__webpack_require__(18), exports); + +__exportStar(__webpack_require__(978), exports); + +__exportStar(__webpack_require__(948), exports); + +__exportStar(__webpack_require__(359), exports); + +__exportStar(__webpack_require__(285), exports); + +__exportStar(__webpack_require__(533), exports); + +__exportStar(__webpack_require__(287), exports); + +__exportStar(__webpack_require__(132), exports); + +__exportStar(__webpack_require__(837), exports); + +__exportStar(__webpack_require__(598), exports); + +__exportStar(__webpack_require__(369), exports); + +__exportStar(__webpack_require__(37), exports); + +__exportStar(__webpack_require__(47), exports); + +__exportStar(__webpack_require__(923), exports); + +__exportStar(__webpack_require__(876), exports); + +/***/ }), + +/***/ 287: +/***/ (function(__unused_webpack_module, exports) { + + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); + +/***/ }), + +/***/ 132: +/***/ (function(__unused_webpack_module, exports) { + + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); + +/***/ }), + +/***/ 837: +/***/ (function(__unused_webpack_module, exports) { + + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); + +/***/ }), + +/***/ 598: +/***/ (function(__unused_webpack_module, exports) { + + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); + +/***/ }), + +/***/ 37: +/***/ (function(__unused_webpack_module, exports) { + + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); + +/***/ }), + +/***/ 369: +/***/ (function(__unused_webpack_module, exports) { + + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); + +/***/ }), + +/***/ 47: +/***/ (function(__unused_webpack_module, exports) { + + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); + +/***/ }), + +/***/ 923: +/***/ (function(__unused_webpack_module, exports) { + + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); + +/***/ }), + +/***/ 876: +/***/ (function(__unused_webpack_module, exports) { + + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); + +/***/ }), + +/***/ 799: +/***/ (function(__unused_webpack_module, exports) { + + +/* eslint-disable @typescript-eslint/no-explicit-any */ + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports.diff = exports.cloneObject = exports.existsInArray = exports.dispatchEvent = exports.sortByScore = exports.sortByAlpha = exports.strToEl = exports.sanitise = exports.isScrolledIntoView = exports.getAdjacentEl = exports.wrap = exports.isType = exports.getType = exports.generateId = exports.generateChars = exports.getRandomNumber = void 0; + +var getRandomNumber = function (min, max) { + return Math.floor(Math.random() * (max - min) + min); +}; + +exports.getRandomNumber = getRandomNumber; + +var generateChars = function (length) { + return Array.from({ + length: length + }, function () { + return (0, exports.getRandomNumber)(0, 36).toString(36); + }).join(''); +}; + +exports.generateChars = generateChars; + +var generateId = function (element, prefix) { + var id = element.id || element.name && "".concat(element.name, "-").concat((0, exports.generateChars)(2)) || (0, exports.generateChars)(4); + id = id.replace(/(:|\.|\[|\]|,)/g, ''); + id = "".concat(prefix, "-").concat(id); + return id; +}; + +exports.generateId = generateId; + +var getType = function (obj) { + return Object.prototype.toString.call(obj).slice(8, -1); +}; + +exports.getType = getType; + +var isType = function (type, obj) { + return obj !== undefined && obj !== null && (0, exports.getType)(obj) === type; +}; + +exports.isType = isType; + +var wrap = function (element, wrapper) { + if (wrapper === void 0) { + wrapper = document.createElement('div'); + } + + if (element.parentNode) { + if (element.nextSibling) { + element.parentNode.insertBefore(wrapper, element.nextSibling); + } else { + element.parentNode.appendChild(wrapper); + } + } + + return wrapper.appendChild(element); +}; + +exports.wrap = wrap; + +var getAdjacentEl = function (startEl, selector, direction) { + if (direction === void 0) { + direction = 1; + } + + var prop = "".concat(direction > 0 ? 'next' : 'previous', "ElementSibling"); + var sibling = startEl[prop]; + + while (sibling) { + if (sibling.matches(selector)) { + return sibling; + } + + sibling = sibling[prop]; + } + + return sibling; +}; + +exports.getAdjacentEl = getAdjacentEl; + +var isScrolledIntoView = function (element, parent, direction) { + if (direction === void 0) { + direction = 1; + } + + if (!element) { + return false; + } + + var isVisible; + + if (direction > 0) { + // In view from bottom + isVisible = parent.scrollTop + parent.offsetHeight >= element.offsetTop + element.offsetHeight; + } else { + // In view from top + isVisible = element.offsetTop >= parent.scrollTop; + } + + return isVisible; +}; + +exports.isScrolledIntoView = isScrolledIntoView; + +var sanitise = function (value) { + if (typeof value !== 'string') { + return value; + } + + return value.replace(/&/g, '&').replace(/>/g, '>').replace(/ -1) { + return state.map(function (obj) { + var choice = obj; + + if (choice.id === parseInt("".concat(addItemAction_1.choiceId), 10)) { + choice.selected = true; + } + + return choice; + }); + } + + return state; + } + + case 'REMOVE_ITEM': + { + var removeItemAction_1 = action; // When an item is removed and it has an associated choice, + // we want to re-enable it so it can be chosen again + + if (removeItemAction_1.choiceId && removeItemAction_1.choiceId > -1) { + return state.map(function (obj) { + var choice = obj; + + if (choice.id === parseInt("".concat(removeItemAction_1.choiceId), 10)) { + choice.selected = false; + } + + return choice; + }); + } + + return state; + } + + case 'FILTER_CHOICES': + { + var filterChoicesAction_1 = action; + return state.map(function (obj) { + var choice = obj; // Set active state based on whether choice is + // within filtered results + + choice.active = filterChoicesAction_1.results.some(function (_a) { + var item = _a.item, + score = _a.score; + + if (item.id === choice.id) { + choice.score = score; + return true; + } + + return false; + }); + return choice; + }); + } + + case 'ACTIVATE_CHOICES': + { + var activateChoicesAction_1 = action; + return state.map(function (obj) { + var choice = obj; + choice.active = activateChoicesAction_1.active; + return choice; + }); + } + + case 'CLEAR_CHOICES': + { + return exports.defaultState; + } + + default: + { + return state; + } + } +} + +exports["default"] = choices; + +/***/ }), + +/***/ 871: +/***/ (function(__unused_webpack_module, exports) { + + + +var __spreadArray = this && this.__spreadArray || function (to, from, pack) { + if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { + if (ar || !(i in from)) { + if (!ar) ar = Array.prototype.slice.call(from, 0, i); + ar[i] = from[i]; + } + } + return to.concat(ar || Array.prototype.slice.call(from)); +}; + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports.defaultState = void 0; +exports.defaultState = []; + +function groups(state, action) { + if (state === void 0) { + state = exports.defaultState; + } + + if (action === void 0) { + action = {}; + } + + switch (action.type) { + case 'ADD_GROUP': + { + var addGroupAction = action; + return __spreadArray(__spreadArray([], state, true), [{ + id: addGroupAction.id, + value: addGroupAction.value, + active: addGroupAction.active, + disabled: addGroupAction.disabled + }], false); + } + + case 'CLEAR_CHOICES': + { + return []; + } + + default: + { + return state; + } + } +} + +exports["default"] = groups; + +/***/ }), + +/***/ 655: +/***/ (function(__unused_webpack_module, exports, __webpack_require__) { + + + +var __importDefault = this && this.__importDefault || function (mod) { + return mod && mod.__esModule ? mod : { + "default": mod + }; +}; + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports.defaultState = void 0; + +var redux_1 = __webpack_require__(857); + +var items_1 = __importDefault(__webpack_require__(52)); + +var groups_1 = __importDefault(__webpack_require__(871)); + +var choices_1 = __importDefault(__webpack_require__(273)); + +var loading_1 = __importDefault(__webpack_require__(502)); + +var utils_1 = __webpack_require__(799); + +exports.defaultState = { + groups: [], + items: [], + choices: [], + loading: false +}; +var appReducer = (0, redux_1.combineReducers)({ + items: items_1.default, + groups: groups_1.default, + choices: choices_1.default, + loading: loading_1.default +}); + +var rootReducer = function (passedState, action) { + var state = passedState; // If we are clearing all items, groups and options we reassign + // state and then pass that state to our proper reducer. This isn't + // mutating our actual state + // See: http://stackoverflow.com/a/35641992 + + if (action.type === 'CLEAR_ALL') { + state = exports.defaultState; + } else if (action.type === 'RESET_TO') { + return (0, utils_1.cloneObject)(action.state); + } + + return appReducer(state, action); +}; + +exports["default"] = rootReducer; + +/***/ }), + +/***/ 52: +/***/ (function(__unused_webpack_module, exports) { + + + +var __spreadArray = this && this.__spreadArray || function (to, from, pack) { + if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { + if (ar || !(i in from)) { + if (!ar) ar = Array.prototype.slice.call(from, 0, i); + ar[i] = from[i]; + } + } + return to.concat(ar || Array.prototype.slice.call(from)); +}; + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports.defaultState = void 0; +exports.defaultState = []; + +function items(state, action) { + if (state === void 0) { + state = exports.defaultState; + } + + if (action === void 0) { + action = {}; + } + + switch (action.type) { + case 'ADD_ITEM': + { + var addItemAction = action; // Add object to items array + + var newState = __spreadArray(__spreadArray([], state, true), [{ + id: addItemAction.id, + choiceId: addItemAction.choiceId, + groupId: addItemAction.groupId, + value: addItemAction.value, + label: addItemAction.label, + active: true, + highlighted: false, + customProperties: addItemAction.customProperties, + placeholder: addItemAction.placeholder || false, + keyCode: null + }], false); + + return newState.map(function (obj) { + var item = obj; + item.highlighted = false; + return item; + }); + } + + case 'REMOVE_ITEM': + { + // Set item to inactive + return state.map(function (obj) { + var item = obj; + + if (item.id === action.id) { + item.active = false; + } + + return item; + }); + } + + case 'HIGHLIGHT_ITEM': + { + var highlightItemAction_1 = action; + return state.map(function (obj) { + var item = obj; + + if (item.id === highlightItemAction_1.id) { + item.highlighted = highlightItemAction_1.highlighted; + } + + return item; + }); + } + + default: + { + return state; + } + } +} + +exports["default"] = items; + +/***/ }), + +/***/ 502: +/***/ (function(__unused_webpack_module, exports) { + + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports.defaultState = void 0; +exports.defaultState = false; + +var general = function (state, action) { + if (state === void 0) { + state = exports.defaultState; + } + + if (action === void 0) { + action = {}; + } + + switch (action.type) { + case 'SET_IS_LOADING': + { + return action.isLoading; + } + + default: + { + return state; + } + } +}; + +exports["default"] = general; + +/***/ }), + +/***/ 744: +/***/ (function(__unused_webpack_module, exports, __webpack_require__) { + + + +var __spreadArray = this && this.__spreadArray || function (to, from, pack) { + if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { + if (ar || !(i in from)) { + if (!ar) ar = Array.prototype.slice.call(from, 0, i); + ar[i] = from[i]; + } + } + return to.concat(ar || Array.prototype.slice.call(from)); +}; + +var __importDefault = this && this.__importDefault || function (mod) { + return mod && mod.__esModule ? mod : { + "default": mod + }; +}; + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +/* eslint-disable @typescript-eslint/no-explicit-any */ + +var redux_1 = __webpack_require__(857); + +var index_1 = __importDefault(__webpack_require__(655)); + +var Store = +/** @class */ +function () { + function Store() { + this._store = (0, redux_1.createStore)(index_1.default, window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__()); + } + /** + * Subscribe store to function call (wrapped Redux method) + */ + + + Store.prototype.subscribe = function (onChange) { + this._store.subscribe(onChange); + }; + /** + * Dispatch event to store (wrapped Redux method) + */ + + + Store.prototype.dispatch = function (action) { + this._store.dispatch(action); + }; + + Object.defineProperty(Store.prototype, "state", { + /** + * Get store object (wrapping Redux method) + */ + get: function () { + return this._store.getState(); + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(Store.prototype, "items", { + /** + * Get items from store + */ + get: function () { + return this.state.items; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(Store.prototype, "activeItems", { + /** + * Get active items from store + */ + get: function () { + return this.items.filter(function (item) { + return item.active === true; + }); + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(Store.prototype, "highlightedActiveItems", { + /** + * Get highlighted items from store + */ + get: function () { + return this.items.filter(function (item) { + return item.active && item.highlighted; + }); + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(Store.prototype, "choices", { + /** + * Get choices from store + */ + get: function () { + return this.state.choices; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(Store.prototype, "activeChoices", { + /** + * Get active choices from store + */ + get: function () { + return this.choices.filter(function (choice) { + return choice.active === true; + }); + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(Store.prototype, "selectableChoices", { + /** + * Get selectable choices from store + */ + get: function () { + return this.choices.filter(function (choice) { + return choice.disabled !== true; + }); + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(Store.prototype, "searchableChoices", { + /** + * Get choices that can be searched (excluding placeholders) + */ + get: function () { + return this.selectableChoices.filter(function (choice) { + return choice.placeholder !== true; + }); + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(Store.prototype, "placeholderChoice", { + /** + * Get placeholder choice from store + */ + get: function () { + return __spreadArray([], this.choices, true).reverse().find(function (choice) { + return choice.placeholder === true; + }); + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(Store.prototype, "groups", { + /** + * Get groups from store + */ + get: function () { + return this.state.groups; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(Store.prototype, "activeGroups", { + /** + * Get active groups from store + */ + get: function () { + var _a = this, + groups = _a.groups, + choices = _a.choices; + + return groups.filter(function (group) { + var isActive = group.active === true && group.disabled === false; + var hasActiveOptions = choices.some(function (choice) { + return choice.active === true && choice.disabled === false; + }); + return isActive && hasActiveOptions; + }, []); + }, + enumerable: false, + configurable: true + }); + /** + * Get loading state from store + */ + + Store.prototype.isLoading = function () { + return this.state.loading; + }; + /** + * Get single choice by it's ID + */ + + + Store.prototype.getChoiceById = function (id) { + return this.activeChoices.find(function (choice) { + return choice.id === parseInt(id, 10); + }); + }; + /** + * Get group by group id + */ + + + Store.prototype.getGroupById = function (id) { + return this.groups.find(function (group) { + return group.id === id; + }); + }; + + return Store; +}(); + +exports["default"] = Store; + +/***/ }), + +/***/ 686: +/***/ (function(__unused_webpack_module, exports) { + + +/** + * Helpers to create HTML elements used by Choices + * Can be overridden by providing `callbackOnCreateTemplates` option + */ + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +var templates = { + containerOuter: function (_a, dir, isSelectElement, isSelectOneElement, searchEnabled, passedElementType) { + var containerOuter = _a.classNames.containerOuter; + var div = Object.assign(document.createElement('div'), { + className: containerOuter + }); + div.dataset.type = passedElementType; + + if (dir) { + div.dir = dir; + } + + if (isSelectOneElement) { + div.tabIndex = 0; + } + + if (isSelectElement) { + div.setAttribute('role', searchEnabled ? 'combobox' : 'listbox'); + + if (searchEnabled) { + div.setAttribute('aria-autocomplete', 'list'); + } + } + + div.setAttribute('aria-haspopup', 'true'); + div.setAttribute('aria-expanded', 'false'); + return div; + }, + containerInner: function (_a) { + var containerInner = _a.classNames.containerInner; + return Object.assign(document.createElement('div'), { + className: containerInner + }); + }, + itemList: function (_a, isSelectOneElement) { + var _b = _a.classNames, + list = _b.list, + listSingle = _b.listSingle, + listItems = _b.listItems; + return Object.assign(document.createElement('div'), { + className: "".concat(list, " ").concat(isSelectOneElement ? listSingle : listItems) + }); + }, + placeholder: function (_a, value) { + var _b; + + var allowHTML = _a.allowHTML, + placeholder = _a.classNames.placeholder; + return Object.assign(document.createElement('div'), (_b = { + className: placeholder + }, _b[allowHTML ? 'innerHTML' : 'innerText'] = value, _b)); + }, + item: function (_a, _b, removeItemButton) { + var _c, _d; + + var allowHTML = _a.allowHTML, + _e = _a.classNames, + item = _e.item, + button = _e.button, + highlightedState = _e.highlightedState, + itemSelectable = _e.itemSelectable, + placeholder = _e.placeholder; + var id = _b.id, + value = _b.value, + label = _b.label, + customProperties = _b.customProperties, + active = _b.active, + disabled = _b.disabled, + highlighted = _b.highlighted, + isPlaceholder = _b.placeholder; + var div = Object.assign(document.createElement('div'), (_c = { + className: item + }, _c[allowHTML ? 'innerHTML' : 'innerText'] = label, _c)); + Object.assign(div.dataset, { + item: '', + id: id, + value: value, + customProperties: customProperties + }); + + if (active) { + div.setAttribute('aria-selected', 'true'); + } + + if (disabled) { + div.setAttribute('aria-disabled', 'true'); + } + + if (isPlaceholder) { + div.classList.add(placeholder); + } + + div.classList.add(highlighted ? highlightedState : itemSelectable); + + if (removeItemButton) { + if (disabled) { + div.classList.remove(itemSelectable); + } + + div.dataset.deletable = ''; + /** @todo This MUST be localizable, not hardcoded! */ + + var REMOVE_ITEM_TEXT = 'Remove item'; + var removeButton = Object.assign(document.createElement('button'), (_d = { + type: 'button', + className: button + }, _d[allowHTML ? 'innerHTML' : 'innerText'] = REMOVE_ITEM_TEXT, _d)); + removeButton.setAttribute('aria-label', "".concat(REMOVE_ITEM_TEXT, ": '").concat(value, "'")); + removeButton.dataset.button = ''; + div.appendChild(removeButton); + } + + return div; + }, + choiceList: function (_a, isSelectOneElement) { + var list = _a.classNames.list; + var div = Object.assign(document.createElement('div'), { + className: list + }); + + if (!isSelectOneElement) { + div.setAttribute('aria-multiselectable', 'true'); + } + + div.setAttribute('role', 'listbox'); + return div; + }, + choiceGroup: function (_a, _b) { + var _c; + + var allowHTML = _a.allowHTML, + _d = _a.classNames, + group = _d.group, + groupHeading = _d.groupHeading, + itemDisabled = _d.itemDisabled; + var id = _b.id, + value = _b.value, + disabled = _b.disabled; + var div = Object.assign(document.createElement('div'), { + className: "".concat(group, " ").concat(disabled ? itemDisabled : '') + }); + div.setAttribute('role', 'group'); + Object.assign(div.dataset, { + group: '', + id: id, + value: value + }); + + if (disabled) { + div.setAttribute('aria-disabled', 'true'); + } + + div.appendChild(Object.assign(document.createElement('div'), (_c = { + className: groupHeading + }, _c[allowHTML ? 'innerHTML' : 'innerText'] = value, _c))); + return div; + }, + choice: function (_a, _b, selectText) { + var _c; + + var allowHTML = _a.allowHTML, + _d = _a.classNames, + item = _d.item, + itemChoice = _d.itemChoice, + itemSelectable = _d.itemSelectable, + selectedState = _d.selectedState, + itemDisabled = _d.itemDisabled, + placeholder = _d.placeholder; + var id = _b.id, + value = _b.value, + label = _b.label, + groupId = _b.groupId, + elementId = _b.elementId, + isDisabled = _b.disabled, + isSelected = _b.selected, + isPlaceholder = _b.placeholder; + var div = Object.assign(document.createElement('div'), (_c = { + id: elementId + }, _c[allowHTML ? 'innerHTML' : 'innerText'] = label, _c.className = "".concat(item, " ").concat(itemChoice), _c)); + + if (isSelected) { + div.classList.add(selectedState); + } + + if (isPlaceholder) { + div.classList.add(placeholder); + } + + div.setAttribute('role', groupId && groupId > 0 ? 'treeitem' : 'option'); + Object.assign(div.dataset, { + choice: '', + id: id, + value: value, + selectText: selectText + }); + + if (isDisabled) { + div.classList.add(itemDisabled); + div.dataset.choiceDisabled = ''; + div.setAttribute('aria-disabled', 'true'); + } else { + div.classList.add(itemSelectable); + div.dataset.choiceSelectable = ''; + } + + return div; + }, + input: function (_a, placeholderValue) { + var _b = _a.classNames, + input = _b.input, + inputCloned = _b.inputCloned; + var inp = Object.assign(document.createElement('input'), { + type: 'search', + name: 'search_terms', + className: "".concat(input, " ").concat(inputCloned), + autocomplete: 'off', + autocapitalize: 'off', + spellcheck: false + }); + inp.setAttribute('role', 'textbox'); + inp.setAttribute('aria-autocomplete', 'list'); + inp.setAttribute('aria-label', placeholderValue); + return inp; + }, + dropdown: function (_a) { + var _b = _a.classNames, + list = _b.list, + listDropdown = _b.listDropdown; + var div = document.createElement('div'); + div.classList.add(list, listDropdown); + div.setAttribute('aria-expanded', 'false'); + return div; + }, + notice: function (_a, innerText, type) { + var _b; + + var allowHTML = _a.allowHTML, + _c = _a.classNames, + item = _c.item, + itemChoice = _c.itemChoice, + noResults = _c.noResults, + noChoices = _c.noChoices; + + if (type === void 0) { + type = ''; + } + + var classes = [item, itemChoice]; + + if (type === 'no-choices') { + classes.push(noChoices); + } else if (type === 'no-results') { + classes.push(noResults); + } + + return Object.assign(document.createElement('div'), (_b = {}, _b[allowHTML ? 'innerHTML' : 'innerText'] = innerText, _b.className = classes.join(' '), _b)); + }, + option: function (_a) { + var label = _a.label, + value = _a.value, + customProperties = _a.customProperties, + active = _a.active, + disabled = _a.disabled; + var opt = new Option(label, value, false, active); + + if (customProperties) { + opt.dataset.customProperties = "".concat(customProperties); + } + + opt.disabled = !!disabled; + return opt; + } +}; +exports["default"] = templates; + +/***/ }), + +/***/ 996: +/***/ (function(module) { -"use strict"; var isMergeableObject = function isMergeableObject(value) { @@ -163,19 +4928,21 @@ function getKeys(target) { return Object.keys(target).concat(getEnumerableOwnPropertySymbols(target)) } -// Protects from prototype poisoning and unexpected merging up the prototype chain. -function propertyIsUnsafe(target, key) { +function propertyIsOnObject(object, property) { try { - return (key in target) // Properties are safe to merge if they don't exist in the target yet, - && !(Object.hasOwnProperty.call(target, key) // unsafe if they exist up the prototype chain, - && Object.propertyIsEnumerable.call(target, key)) // and also unsafe if they're nonenumerable. - } catch (unused) { - // Counterintuitively, it's safe to merge any property on a target that causes the `in` operator to throw. - // This happens when trying to copy an object in the source over a plain string in the target. + return property in object + } catch(_) { return false } } +// Protects from prototype poisoning and unexpected merging up the prototype chain. +function propertyIsUnsafe(target, key) { + return propertyIsOnObject(target, key) // Properties are safe to merge if they don't exist in the target yet, + && !(Object.hasOwnProperty.call(target, key) // unsafe if they exist up the prototype chain, + && Object.propertyIsEnumerable.call(target, key)) // and also unsafe if they're nonenumerable. +} + function mergeObject(target, source, options) { var destination = {}; if (options.isMergeableObject(target)) { @@ -188,10 +4955,10 @@ function mergeObject(target, source, options) { return } - if (!options.isMergeableObject(source[key]) || !target[key]) { - destination[key] = cloneUnlessOtherwiseSpecified(source[key], options); - } else { + if (propertyIsOnObject(target, key) && options.isMergeableObject(source[key])) { destination[key] = getMergeFunction(key, options)(target[key], source[key], options); + } else { + destination[key] = cloneUnlessOtherwiseSpecified(source[key], options); } }); return destination @@ -234,153 +5001,1872 @@ module.exports = deepmerge_1; /***/ }), -/* 1 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { -"use strict"; -/* WEBPACK VAR INJECTION */(function(global, module) {/* harmony import */ var _ponyfill_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(3); -/* global window */ +/***/ 221: +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { - -var root; - -if (typeof self !== 'undefined') { - root = self; -} else if (typeof window !== 'undefined') { - root = window; -} else if (typeof global !== 'undefined') { - root = global; -} else if (true) { - root = module; -} else {} - -var result = Object(_ponyfill_js__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"])(root); -/* harmony default export */ __webpack_exports__["a"] = (result); - -/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(5), __webpack_require__(6)(module))) - -/***/ }), -/* 2 */ -/***/ (function(module, exports, __webpack_require__) { - -/*! - * Fuse.js v3.4.5 - Lightweight fuzzy-search (http://fusejs.io) - * - * Copyright (c) 2012-2017 Kirollos Risk (http://kiro.me) +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": function() { return /* binding */ Fuse; } +/* harmony export */ }); +/** + * Fuse.js v6.5.3 - Lightweight fuzzy-search (http://fusejs.io) + * + * Copyright (c) 2021 Kiro Risk (http://kiro.me) * All Rights Reserved. Apache Software License 2.0 - * + * * http://www.apache.org/licenses/LICENSE-2.0 */ -!function(e,t){ true?module.exports=t():undefined}(this,function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=1)}([function(e,t){e.exports=function(e){return Array.isArray?Array.isArray(e):"[object Array]"===Object.prototype.toString.call(e)}},function(e,t,n){function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function o(e,t){for(var n=0;n1&&void 0!==arguments[1]?arguments[1]:{limit:!1};this._log('---------\nSearch pattern: "'.concat(e,'"'));var n=this._prepareSearchers(e),r=n.tokenSearchers,o=n.fullSearcher,i=this._search(r,o),a=i.weights,s=i.results;return this._computeScore(a,s),this.options.shouldSort&&this._sort(s),t.limit&&"number"==typeof t.limit&&(s=s.slice(0,t.limit)),this._format(s)}},{key:"_prepareSearchers",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=[];if(this.options.tokenize)for(var n=e.split(this.options.tokenSeparator),r=0,o=n.length;r0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1?arguments[1]:void 0,n=this.list,r={},o=[];if("string"==typeof n[0]){for(var i=0,a=n.length;i1)throw new Error("Key weight has to be > 0 and <= 1");d=d.name}else s[d]={weight:1};this._analyze({key:d,value:this.options.getFn(l,d),record:l,index:c},{resultMap:r,results:o,tokenSearchers:e,fullSearcher:t})}return{weights:s,results:o}}},{key:"_analyze",value:function(e,t){var n=e.key,r=e.arrayIndex,o=void 0===r?-1:r,i=e.value,a=e.record,c=e.index,h=t.tokenSearchers,l=void 0===h?[]:h,u=t.fullSearcher,f=void 0===u?[]:u,d=t.resultMap,v=void 0===d?{}:d,p=t.results,g=void 0===p?[]:p;if(null!=i){var y=!1,m=-1,k=0;if("string"==typeof i){this._log("\nKey: ".concat(""===n?"-":n));var S=f.search(i);if(this._log('Full text: "'.concat(i,'", score: ').concat(S.score)),this.options.tokenize){for(var x=i.split(this.options.tokenSeparator),b=[],M=0;M-1&&(P=(P+m)/2),this._log("Score average:",P);var F=!this.options.tokenize||!this.options.matchAllTokens||k>=l.length;if(this._log("\nCheck Matches: ".concat(F)),(y||S.isMatch)&&F){var T=v[c];T?T.output.push({key:n,arrayIndex:o,value:i,score:P,matchedIndices:S.matchedIndices}):(v[c]={item:a,output:[{key:n,arrayIndex:o,value:i,score:P,matchedIndices:S.matchedIndices}]},g.push(v[c]))}}else if(s(i))for(var z=0,E=i.length;z-1&&(a.arrayIndex=i.arrayIndex),t.matches.push(a)}}}),this.options.includeScore&&o.push(function(e,t){t.score=e.score});for(var i=0,a=e.length;in)return o(e,this.pattern,r);var a=this.options,s=a.location,c=a.distance,h=a.threshold,l=a.findAllMatches,u=a.minMatchCharLength;return i(e,this.pattern,this.patternAlphabet,{location:s,distance:c,threshold:h,findAllMatches:l,minMatchCharLength:u})}}])&&r(t.prototype,n),s&&r(t,s),e}();e.exports=s},function(e,t){var n=/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g;e.exports=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:/ +/g,o=new RegExp(t.replace(n,"\\$&").replace(r,"|")),i=e.match(o),a=!!i,s=[];if(a)for(var c=0,h=i.length;c=P;z-=1){var E=z-1,K=n[e.charAt(E)];if(K&&(x[E]=1),T[z]=(T[z+1]<<1|1)&K,0!==I&&(T[z]|=(L[z+1]|L[z])<<1|1|L[z+1]),T[z]&C&&(w=r(t,{errors:I,currentLocation:E,expectedLocation:g,distance:h}))<=m){if(m=w,(k=E)<=g)break;P=Math.max(1,2*g-k)}}if(r(t,{errors:I+1,currentLocation:g,expectedLocation:g,distance:h})>m)break;L=T}return{isMatch:k>=0,score:0===w?.001:w,matchedIndices:o(x,p)}}},function(e,t){e.exports=function(e,t){var n=t.errors,r=void 0===n?0:n,o=t.currentLocation,i=void 0===o?0:o,a=t.expectedLocation,s=void 0===a?0:a,c=t.distance,h=void 0===c?100:c,l=r/e.length,u=Math.abs(s-i);return h?l+u/h:u?1:l}},function(e,t){e.exports=function(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,n=[],r=-1,o=-1,i=0,a=e.length;i=t&&n.push([r,o]),r=-1)}return e[i-1]&&i-r>=t&&n.push([r,i-1]),n}},function(e,t){e.exports=function(e){for(var t={},n=e.length,r=0;r + `Invalid value for key ${key}`; + +const PATTERN_LENGTH_TOO_LARGE = (max) => + `Pattern length exceeds max of ${max}.`; + +const MISSING_KEY_PROPERTY = (name) => `Missing ${name} property in key`; + +const INVALID_KEY_WEIGHT_VALUE = (key) => + `Property 'weight' in key '${key}' must be a positive integer`; + +const hasOwn = Object.prototype.hasOwnProperty; + +class KeyStore { + constructor(keys) { + this._keys = []; + this._keyMap = {}; + + let totalWeight = 0; + + keys.forEach((key) => { + let obj = createKey(key); + + totalWeight += obj.weight; + + this._keys.push(obj); + this._keyMap[obj.id] = obj; + + totalWeight += obj.weight; + }); + + // Normalize weights so that their sum is equal to 1 + this._keys.forEach((key) => { + key.weight /= totalWeight; + }); + } + get(keyId) { + return this._keyMap[keyId] + } + keys() { + return this._keys + } + toJSON() { + return JSON.stringify(this._keys) + } +} + +function createKey(key) { + let path = null; + let id = null; + let src = null; + let weight = 1; + + if (isString(key) || isArray(key)) { + src = key; + path = createKeyPath(key); + id = createKeyId(key); + } else { + if (!hasOwn.call(key, 'name')) { + throw new Error(MISSING_KEY_PROPERTY('name')) + } + + const name = key.name; + src = name; + + if (hasOwn.call(key, 'weight')) { + weight = key.weight; + + if (weight <= 0) { + throw new Error(INVALID_KEY_WEIGHT_VALUE(name)) + } + } + + path = createKeyPath(name); + id = createKeyId(name); + } + + return { path, id, weight, src } +} + +function createKeyPath(key) { + return isArray(key) ? key : key.split('.') +} + +function createKeyId(key) { + return isArray(key) ? key.join('.') : key +} + +function get(obj, path) { + let list = []; + let arr = false; + + const deepGet = (obj, path, index) => { + if (!isDefined(obj)) { + return + } + if (!path[index]) { + // If there's no path left, we've arrived at the object we care about. + list.push(obj); + } else { + let key = path[index]; + + const value = obj[key]; + + if (!isDefined(value)) { + return + } + + // If we're at the last value in the path, and if it's a string/number/bool, + // add it to the list + if ( + index === path.length - 1 && + (isString(value) || isNumber(value) || isBoolean(value)) + ) { + list.push(toString(value)); + } else if (isArray(value)) { + arr = true; + // Search each item in the array. + for (let i = 0, len = value.length; i < len; i += 1) { + deepGet(value[i], path, index + 1); + } + } else if (path.length) { + // An object. Recurse further. + deepGet(value, path, index + 1); + } + } + }; + + // Backwards compatibility (since path used to be a string) + deepGet(obj, isString(path) ? path.split('.') : path, 0); + + return arr ? list : list[0] +} + +const MatchOptions = { + // Whether the matches should be included in the result set. When `true`, each record in the result + // set will include the indices of the matched characters. + // These can consequently be used for highlighting purposes. + includeMatches: false, + // When `true`, the matching function will continue to the end of a search pattern even if + // a perfect match has already been located in the string. + findAllMatches: false, + // Minimum number of characters that must be matched before a result is considered a match + minMatchCharLength: 1 }; +const BasicOptions = { + // When `true`, the algorithm continues searching to the end of the input even if a perfect + // match is found before the end of the same input. + isCaseSensitive: false, + // When true, the matching function will continue to the end of a search pattern even if + includeScore: false, + // List of properties that will be searched. This also supports nested properties. + keys: [], + // Whether to sort the result list, by score + shouldSort: true, + // Default sort function: sort by ascending score, ascending index + sortFn: (a, b) => + a.score === b.score ? (a.idx < b.idx ? -1 : 1) : a.score < b.score ? -1 : 1 +}; + +const FuzzyOptions = { + // Approximately where in the text is the pattern expected to be found? + location: 0, + // At what point does the match algorithm give up. A threshold of '0.0' requires a perfect match + // (of both letters and location), a threshold of '1.0' would match anything. + threshold: 0.6, + // Determines how close the match must be to the fuzzy location (specified above). + // An exact letter match which is 'distance' characters away from the fuzzy location + // would score as a complete mismatch. A distance of '0' requires the match be at + // the exact location specified, a threshold of '1000' would require a perfect match + // to be within 800 characters of the fuzzy location to be found using a 0.8 threshold. + distance: 100 +}; + +const AdvancedOptions = { + // When `true`, it enables the use of unix-like search commands + useExtendedSearch: false, + // The get function to use when fetching an object's properties. + // The default will search nested paths *ie foo.bar.baz* + getFn: get, + // When `true`, search will ignore `location` and `distance`, so it won't matter + // where in the string the pattern appears. + // More info: https://fusejs.io/concepts/scoring-theory.html#fuzziness-score + ignoreLocation: false, + // When `true`, the calculation for the relevance score (used for sorting) will + // ignore the field-length norm. + // More info: https://fusejs.io/concepts/scoring-theory.html#field-length-norm + ignoreFieldNorm: false, + // The weight to determine how much field length norm effects scoring. + fieldNormWeight: 1 +}; + +var Config = { + ...BasicOptions, + ...MatchOptions, + ...FuzzyOptions, + ...AdvancedOptions +}; + +const SPACE = /[^ ]+/g; + +// Field-length norm: the shorter the field, the higher the weight. +// Set to 3 decimals to reduce index size. +function norm(weight = 1, mantissa = 3) { + const cache = new Map(); + const m = Math.pow(10, mantissa); + + return { + get(value) { + const numTokens = value.match(SPACE).length; + + if (cache.has(numTokens)) { + return cache.get(numTokens) + } + + // Default function is 1/sqrt(x), weight makes that variable + const norm = 1 / Math.pow(numTokens, 0.5 * weight); + + // In place of `toFixed(mantissa)`, for faster computation + const n = parseFloat(Math.round(norm * m) / m); + + cache.set(numTokens, n); + + return n + }, + clear() { + cache.clear(); + } + } +} + +class FuseIndex { + constructor({ + getFn = Config.getFn, + fieldNormWeight = Config.fieldNormWeight + } = {}) { + this.norm = norm(fieldNormWeight, 3); + this.getFn = getFn; + this.isCreated = false; + + this.setIndexRecords(); + } + setSources(docs = []) { + this.docs = docs; + } + setIndexRecords(records = []) { + this.records = records; + } + setKeys(keys = []) { + this.keys = keys; + this._keysMap = {}; + keys.forEach((key, idx) => { + this._keysMap[key.id] = idx; + }); + } + create() { + if (this.isCreated || !this.docs.length) { + return + } + + this.isCreated = true; + + // List is Array + if (isString(this.docs[0])) { + this.docs.forEach((doc, docIndex) => { + this._addString(doc, docIndex); + }); + } else { + // List is Array + this.docs.forEach((doc, docIndex) => { + this._addObject(doc, docIndex); + }); + } + + this.norm.clear(); + } + // Adds a doc to the end of the index + add(doc) { + const idx = this.size(); + + if (isString(doc)) { + this._addString(doc, idx); + } else { + this._addObject(doc, idx); + } + } + // Removes the doc at the specified index of the index + removeAt(idx) { + this.records.splice(idx, 1); + + // Change ref index of every subsquent doc + for (let i = idx, len = this.size(); i < len; i += 1) { + this.records[i].i -= 1; + } + } + getValueForItemAtKeyId(item, keyId) { + return item[this._keysMap[keyId]] + } + size() { + return this.records.length + } + _addString(doc, docIndex) { + if (!isDefined(doc) || isBlank(doc)) { + return + } + + let record = { + v: doc, + i: docIndex, + n: this.norm.get(doc) + }; + + this.records.push(record); + } + _addObject(doc, docIndex) { + let record = { i: docIndex, $: {} }; + + // Iterate over every key (i.e, path), and fetch the value at that key + this.keys.forEach((key, keyIndex) => { + // console.log(key) + let value = this.getFn(doc, key.path); + + if (!isDefined(value)) { + return + } + + if (isArray(value)) { + let subRecords = []; + const stack = [{ nestedArrIndex: -1, value }]; + + while (stack.length) { + const { nestedArrIndex, value } = stack.pop(); + + if (!isDefined(value)) { + continue + } + + if (isString(value) && !isBlank(value)) { + let subRecord = { + v: value, + i: nestedArrIndex, + n: this.norm.get(value) + }; + + subRecords.push(subRecord); + } else if (isArray(value)) { + value.forEach((item, k) => { + stack.push({ + nestedArrIndex: k, + value: item + }); + }); + } else ; + } + record.$[keyIndex] = subRecords; + } else if (!isBlank(value)) { + let subRecord = { + v: value, + n: this.norm.get(value) + }; + + record.$[keyIndex] = subRecord; + } + }); + + this.records.push(record); + } + toJSON() { + return { + keys: this.keys, + records: this.records + } + } +} + +function createIndex( + keys, + docs, + { getFn = Config.getFn, fieldNormWeight = Config.fieldNormWeight } = {} +) { + const myIndex = new FuseIndex({ getFn, fieldNormWeight }); + myIndex.setKeys(keys.map(createKey)); + myIndex.setSources(docs); + myIndex.create(); + return myIndex +} + +function parseIndex( + data, + { getFn = Config.getFn, fieldNormWeight = Config.fieldNormWeight } = {} +) { + const { keys, records } = data; + const myIndex = new FuseIndex({ getFn, fieldNormWeight }); + myIndex.setKeys(keys); + myIndex.setIndexRecords(records); + return myIndex +} + +function computeScore$1( + pattern, + { + errors = 0, + currentLocation = 0, + expectedLocation = 0, + distance = Config.distance, + ignoreLocation = Config.ignoreLocation + } = {} +) { + const accuracy = errors / pattern.length; + + if (ignoreLocation) { + return accuracy + } + + const proximity = Math.abs(expectedLocation - currentLocation); + + if (!distance) { + // Dodge divide by zero error. + return proximity ? 1.0 : accuracy + } + + return accuracy + proximity / distance +} + +function convertMaskToIndices( + matchmask = [], + minMatchCharLength = Config.minMatchCharLength +) { + let indices = []; + let start = -1; + let end = -1; + let i = 0; + + for (let len = matchmask.length; i < len; i += 1) { + let match = matchmask[i]; + if (match && start === -1) { + start = i; + } else if (!match && start !== -1) { + end = i - 1; + if (end - start + 1 >= minMatchCharLength) { + indices.push([start, end]); + } + start = -1; + } + } + + // (i-1 - start) + 1 => i - start + if (matchmask[i - 1] && i - start >= minMatchCharLength) { + indices.push([start, i - 1]); + } + + return indices +} + +// Machine word size +const MAX_BITS = 32; + +function search( + text, + pattern, + patternAlphabet, + { + location = Config.location, + distance = Config.distance, + threshold = Config.threshold, + findAllMatches = Config.findAllMatches, + minMatchCharLength = Config.minMatchCharLength, + includeMatches = Config.includeMatches, + ignoreLocation = Config.ignoreLocation + } = {} +) { + if (pattern.length > MAX_BITS) { + throw new Error(PATTERN_LENGTH_TOO_LARGE(MAX_BITS)) + } + + const patternLen = pattern.length; + // Set starting location at beginning text and initialize the alphabet. + const textLen = text.length; + // Handle the case when location > text.length + const expectedLocation = Math.max(0, Math.min(location, textLen)); + // Highest score beyond which we give up. + let currentThreshold = threshold; + // Is there a nearby exact match? (speedup) + let bestLocation = expectedLocation; + + // Performance: only computer matches when the minMatchCharLength > 1 + // OR if `includeMatches` is true. + const computeMatches = minMatchCharLength > 1 || includeMatches; + // A mask of the matches, used for building the indices + const matchMask = computeMatches ? Array(textLen) : []; + + let index; + + // Get all exact matches, here for speed up + while ((index = text.indexOf(pattern, bestLocation)) > -1) { + let score = computeScore$1(pattern, { + currentLocation: index, + expectedLocation, + distance, + ignoreLocation + }); + + currentThreshold = Math.min(score, currentThreshold); + bestLocation = index + patternLen; + + if (computeMatches) { + let i = 0; + while (i < patternLen) { + matchMask[index + i] = 1; + i += 1; + } + } + } + + // Reset the best location + bestLocation = -1; + + let lastBitArr = []; + let finalScore = 1; + let binMax = patternLen + textLen; + + const mask = 1 << (patternLen - 1); + + for (let i = 0; i < patternLen; i += 1) { + // Scan for the best match; each iteration allows for one more error. + // Run a binary search to determine how far from the match location we can stray + // at this error level. + let binMin = 0; + let binMid = binMax; + + while (binMin < binMid) { + const score = computeScore$1(pattern, { + errors: i, + currentLocation: expectedLocation + binMid, + expectedLocation, + distance, + ignoreLocation + }); + + if (score <= currentThreshold) { + binMin = binMid; + } else { + binMax = binMid; + } + + binMid = Math.floor((binMax - binMin) / 2 + binMin); + } + + // Use the result from this iteration as the maximum for the next. + binMax = binMid; + + let start = Math.max(1, expectedLocation - binMid + 1); + let finish = findAllMatches + ? textLen + : Math.min(expectedLocation + binMid, textLen) + patternLen; + + // Initialize the bit array + let bitArr = Array(finish + 2); + + bitArr[finish + 1] = (1 << i) - 1; + + for (let j = finish; j >= start; j -= 1) { + let currentLocation = j - 1; + let charMatch = patternAlphabet[text.charAt(currentLocation)]; + + if (computeMatches) { + // Speed up: quick bool to int conversion (i.e, `charMatch ? 1 : 0`) + matchMask[currentLocation] = +!!charMatch; + } + + // First pass: exact match + bitArr[j] = ((bitArr[j + 1] << 1) | 1) & charMatch; + + // Subsequent passes: fuzzy match + if (i) { + bitArr[j] |= + ((lastBitArr[j + 1] | lastBitArr[j]) << 1) | 1 | lastBitArr[j + 1]; + } + + if (bitArr[j] & mask) { + finalScore = computeScore$1(pattern, { + errors: i, + currentLocation, + expectedLocation, + distance, + ignoreLocation + }); + + // This match will almost certainly be better than any existing match. + // But check anyway. + if (finalScore <= currentThreshold) { + // Indeed it is + currentThreshold = finalScore; + bestLocation = currentLocation; + + // Already passed `loc`, downhill from here on in. + if (bestLocation <= expectedLocation) { + break + } + + // When passing `bestLocation`, don't exceed our current distance from `expectedLocation`. + start = Math.max(1, 2 * expectedLocation - bestLocation); + } + } + } + + // No hope for a (better) match at greater error levels. + const score = computeScore$1(pattern, { + errors: i + 1, + currentLocation: expectedLocation, + expectedLocation, + distance, + ignoreLocation + }); + + if (score > currentThreshold) { + break + } + + lastBitArr = bitArr; + } + + const result = { + isMatch: bestLocation >= 0, + // Count exact matches (those with a score of 0) to be "almost" exact + score: Math.max(0.001, finalScore) + }; + + if (computeMatches) { + const indices = convertMaskToIndices(matchMask, minMatchCharLength); + if (!indices.length) { + result.isMatch = false; + } else if (includeMatches) { + result.indices = indices; + } + } + + return result +} + +function createPatternAlphabet(pattern) { + let mask = {}; + + for (let i = 0, len = pattern.length; i < len; i += 1) { + const char = pattern.charAt(i); + mask[char] = (mask[char] || 0) | (1 << (len - i - 1)); + } + + return mask +} + +class BitapSearch { + constructor( + pattern, + { + location = Config.location, + threshold = Config.threshold, + distance = Config.distance, + includeMatches = Config.includeMatches, + findAllMatches = Config.findAllMatches, + minMatchCharLength = Config.minMatchCharLength, + isCaseSensitive = Config.isCaseSensitive, + ignoreLocation = Config.ignoreLocation + } = {} + ) { + this.options = { + location, + threshold, + distance, + includeMatches, + findAllMatches, + minMatchCharLength, + isCaseSensitive, + ignoreLocation + }; + + this.pattern = isCaseSensitive ? pattern : pattern.toLowerCase(); + + this.chunks = []; + + if (!this.pattern.length) { + return + } + + const addChunk = (pattern, startIndex) => { + this.chunks.push({ + pattern, + alphabet: createPatternAlphabet(pattern), + startIndex + }); + }; + + const len = this.pattern.length; + + if (len > MAX_BITS) { + let i = 0; + const remainder = len % MAX_BITS; + const end = len - remainder; + + while (i < end) { + addChunk(this.pattern.substr(i, MAX_BITS), i); + i += MAX_BITS; + } + + if (remainder) { + const startIndex = len - MAX_BITS; + addChunk(this.pattern.substr(startIndex), startIndex); + } + } else { + addChunk(this.pattern, 0); + } + } + + searchIn(text) { + const { isCaseSensitive, includeMatches } = this.options; + + if (!isCaseSensitive) { + text = text.toLowerCase(); + } + + // Exact match + if (this.pattern === text) { + let result = { + isMatch: true, + score: 0 + }; + + if (includeMatches) { + result.indices = [[0, text.length - 1]]; + } + + return result + } + + // Otherwise, use Bitap algorithm + const { + location, + distance, + threshold, + findAllMatches, + minMatchCharLength, + ignoreLocation + } = this.options; + + let allIndices = []; + let totalScore = 0; + let hasMatches = false; + + this.chunks.forEach(({ pattern, alphabet, startIndex }) => { + const { isMatch, score, indices } = search(text, pattern, alphabet, { + location: location + startIndex, + distance, + threshold, + findAllMatches, + minMatchCharLength, + includeMatches, + ignoreLocation + }); + + if (isMatch) { + hasMatches = true; + } + + totalScore += score; + + if (isMatch && indices) { + allIndices = [...allIndices, ...indices]; + } + }); + + let result = { + isMatch: hasMatches, + score: hasMatches ? totalScore / this.chunks.length : 1 + }; + + if (hasMatches && includeMatches) { + result.indices = allIndices; + } + + return result + } +} + +class BaseMatch { + constructor(pattern) { + this.pattern = pattern; + } + static isMultiMatch(pattern) { + return getMatch(pattern, this.multiRegex) + } + static isSingleMatch(pattern) { + return getMatch(pattern, this.singleRegex) + } + search(/*text*/) {} +} + +function getMatch(pattern, exp) { + const matches = pattern.match(exp); + return matches ? matches[1] : null +} + +// Token: 'file + +class ExactMatch extends BaseMatch { + constructor(pattern) { + super(pattern); + } + static get type() { + return 'exact' + } + static get multiRegex() { + return /^="(.*)"$/ + } + static get singleRegex() { + return /^=(.*)$/ + } + search(text) { + const isMatch = text === this.pattern; + + return { + isMatch, + score: isMatch ? 0 : 1, + indices: [0, this.pattern.length - 1] + } + } +} + +// Token: !fire + +class InverseExactMatch extends BaseMatch { + constructor(pattern) { + super(pattern); + } + static get type() { + return 'inverse-exact' + } + static get multiRegex() { + return /^!"(.*)"$/ + } + static get singleRegex() { + return /^!(.*)$/ + } + search(text) { + const index = text.indexOf(this.pattern); + const isMatch = index === -1; + + return { + isMatch, + score: isMatch ? 0 : 1, + indices: [0, text.length - 1] + } + } +} + +// Token: ^file + +class PrefixExactMatch extends BaseMatch { + constructor(pattern) { + super(pattern); + } + static get type() { + return 'prefix-exact' + } + static get multiRegex() { + return /^\^"(.*)"$/ + } + static get singleRegex() { + return /^\^(.*)$/ + } + search(text) { + const isMatch = text.startsWith(this.pattern); + + return { + isMatch, + score: isMatch ? 0 : 1, + indices: [0, this.pattern.length - 1] + } + } +} + +// Token: !^fire + +class InversePrefixExactMatch extends BaseMatch { + constructor(pattern) { + super(pattern); + } + static get type() { + return 'inverse-prefix-exact' + } + static get multiRegex() { + return /^!\^"(.*)"$/ + } + static get singleRegex() { + return /^!\^(.*)$/ + } + search(text) { + const isMatch = !text.startsWith(this.pattern); + + return { + isMatch, + score: isMatch ? 0 : 1, + indices: [0, text.length - 1] + } + } +} + +// Token: .file$ + +class SuffixExactMatch extends BaseMatch { + constructor(pattern) { + super(pattern); + } + static get type() { + return 'suffix-exact' + } + static get multiRegex() { + return /^"(.*)"\$$/ + } + static get singleRegex() { + return /^(.*)\$$/ + } + search(text) { + const isMatch = text.endsWith(this.pattern); + + return { + isMatch, + score: isMatch ? 0 : 1, + indices: [text.length - this.pattern.length, text.length - 1] + } + } +} + +// Token: !.file$ + +class InverseSuffixExactMatch extends BaseMatch { + constructor(pattern) { + super(pattern); + } + static get type() { + return 'inverse-suffix-exact' + } + static get multiRegex() { + return /^!"(.*)"\$$/ + } + static get singleRegex() { + return /^!(.*)\$$/ + } + search(text) { + const isMatch = !text.endsWith(this.pattern); + return { + isMatch, + score: isMatch ? 0 : 1, + indices: [0, text.length - 1] + } + } +} + +class FuzzyMatch extends BaseMatch { + constructor( + pattern, + { + location = Config.location, + threshold = Config.threshold, + distance = Config.distance, + includeMatches = Config.includeMatches, + findAllMatches = Config.findAllMatches, + minMatchCharLength = Config.minMatchCharLength, + isCaseSensitive = Config.isCaseSensitive, + ignoreLocation = Config.ignoreLocation + } = {} + ) { + super(pattern); + this._bitapSearch = new BitapSearch(pattern, { + location, + threshold, + distance, + includeMatches, + findAllMatches, + minMatchCharLength, + isCaseSensitive, + ignoreLocation + }); + } + static get type() { + return 'fuzzy' + } + static get multiRegex() { + return /^"(.*)"$/ + } + static get singleRegex() { + return /^(.*)$/ + } + search(text) { + return this._bitapSearch.searchIn(text) + } +} + +// Token: 'file + +class IncludeMatch extends BaseMatch { + constructor(pattern) { + super(pattern); + } + static get type() { + return 'include' + } + static get multiRegex() { + return /^'"(.*)"$/ + } + static get singleRegex() { + return /^'(.*)$/ + } + search(text) { + let location = 0; + let index; + + const indices = []; + const patternLen = this.pattern.length; + + // Get all exact matches + while ((index = text.indexOf(this.pattern, location)) > -1) { + location = index + patternLen; + indices.push([index, location - 1]); + } + + const isMatch = !!indices.length; + + return { + isMatch, + score: isMatch ? 0 : 1, + indices + } + } +} + +// ❗Order is important. DO NOT CHANGE. +const searchers = [ + ExactMatch, + IncludeMatch, + PrefixExactMatch, + InversePrefixExactMatch, + InverseSuffixExactMatch, + SuffixExactMatch, + InverseExactMatch, + FuzzyMatch +]; + +const searchersLen = searchers.length; + +// Regex to split by spaces, but keep anything in quotes together +const SPACE_RE = / +(?=([^\"]*\"[^\"]*\")*[^\"]*$)/; +const OR_TOKEN = '|'; + +// Return a 2D array representation of the query, for simpler parsing. +// Example: +// "^core go$ | rb$ | py$ xy$" => [["^core", "go$"], ["rb$"], ["py$", "xy$"]] +function parseQuery(pattern, options = {}) { + return pattern.split(OR_TOKEN).map((item) => { + let query = item + .trim() + .split(SPACE_RE) + .filter((item) => item && !!item.trim()); + + let results = []; + for (let i = 0, len = query.length; i < len; i += 1) { + const queryItem = query[i]; + + // 1. Handle multiple query match (i.e, once that are quoted, like `"hello world"`) + let found = false; + let idx = -1; + while (!found && ++idx < searchersLen) { + const searcher = searchers[idx]; + let token = searcher.isMultiMatch(queryItem); + if (token) { + results.push(new searcher(token, options)); + found = true; + } + } + + if (found) { + continue + } + + // 2. Handle single query matches (i.e, once that are *not* quoted) + idx = -1; + while (++idx < searchersLen) { + const searcher = searchers[idx]; + let token = searcher.isSingleMatch(queryItem); + if (token) { + results.push(new searcher(token, options)); + break + } + } + } + + return results + }) +} + +// These extended matchers can return an array of matches, as opposed +// to a singl match +const MultiMatchSet = new Set([FuzzyMatch.type, IncludeMatch.type]); + +/** + * Command-like searching + * ====================== + * + * Given multiple search terms delimited by spaces.e.g. `^jscript .python$ ruby !java`, + * search in a given text. + * + * Search syntax: + * + * | Token | Match type | Description | + * | ----------- | -------------------------- | -------------------------------------- | + * | `jscript` | fuzzy-match | Items that fuzzy match `jscript` | + * | `=scheme` | exact-match | Items that are `scheme` | + * | `'python` | include-match | Items that include `python` | + * | `!ruby` | inverse-exact-match | Items that do not include `ruby` | + * | `^java` | prefix-exact-match | Items that start with `java` | + * | `!^earlang` | inverse-prefix-exact-match | Items that do not start with `earlang` | + * | `.js$` | suffix-exact-match | Items that end with `.js` | + * | `!.go$` | inverse-suffix-exact-match | Items that do not end with `.go` | + * + * A single pipe character acts as an OR operator. For example, the following + * query matches entries that start with `core` and end with either`go`, `rb`, + * or`py`. + * + * ``` + * ^core go$ | rb$ | py$ + * ``` + */ +class ExtendedSearch { + constructor( + pattern, + { + isCaseSensitive = Config.isCaseSensitive, + includeMatches = Config.includeMatches, + minMatchCharLength = Config.minMatchCharLength, + ignoreLocation = Config.ignoreLocation, + findAllMatches = Config.findAllMatches, + location = Config.location, + threshold = Config.threshold, + distance = Config.distance + } = {} + ) { + this.query = null; + this.options = { + isCaseSensitive, + includeMatches, + minMatchCharLength, + findAllMatches, + ignoreLocation, + location, + threshold, + distance + }; + + this.pattern = isCaseSensitive ? pattern : pattern.toLowerCase(); + this.query = parseQuery(this.pattern, this.options); + } + + static condition(_, options) { + return options.useExtendedSearch + } + + searchIn(text) { + const query = this.query; + + if (!query) { + return { + isMatch: false, + score: 1 + } + } + + const { includeMatches, isCaseSensitive } = this.options; + + text = isCaseSensitive ? text : text.toLowerCase(); + + let numMatches = 0; + let allIndices = []; + let totalScore = 0; + + // ORs + for (let i = 0, qLen = query.length; i < qLen; i += 1) { + const searchers = query[i]; + + // Reset indices + allIndices.length = 0; + numMatches = 0; + + // ANDs + for (let j = 0, pLen = searchers.length; j < pLen; j += 1) { + const searcher = searchers[j]; + const { isMatch, indices, score } = searcher.search(text); + + if (isMatch) { + numMatches += 1; + totalScore += score; + if (includeMatches) { + const type = searcher.constructor.type; + if (MultiMatchSet.has(type)) { + allIndices = [...allIndices, ...indices]; + } else { + allIndices.push(indices); + } + } + } else { + totalScore = 0; + numMatches = 0; + allIndices.length = 0; + break + } + } + + // OR condition, so if TRUE, return + if (numMatches) { + let result = { + isMatch: true, + score: totalScore / numMatches + }; + + if (includeMatches) { + result.indices = allIndices; + } + + return result + } + } + + // Nothing was matched + return { + isMatch: false, + score: 1 + } + } +} + +const registeredSearchers = []; + +function register(...args) { + registeredSearchers.push(...args); +} + +function createSearcher(pattern, options) { + for (let i = 0, len = registeredSearchers.length; i < len; i += 1) { + let searcherClass = registeredSearchers[i]; + if (searcherClass.condition(pattern, options)) { + return new searcherClass(pattern, options) + } + } + + return new BitapSearch(pattern, options) +} + +const LogicalOperator = { + AND: '$and', + OR: '$or' +}; + +const KeyType = { + PATH: '$path', + PATTERN: '$val' +}; + +const isExpression = (query) => + !!(query[LogicalOperator.AND] || query[LogicalOperator.OR]); + +const isPath = (query) => !!query[KeyType.PATH]; + +const isLeaf = (query) => + !isArray(query) && isObject(query) && !isExpression(query); + +const convertToExplicit = (query) => ({ + [LogicalOperator.AND]: Object.keys(query).map((key) => ({ + [key]: query[key] + })) +}); + +// When `auto` is `true`, the parse function will infer and initialize and add +// the appropriate `Searcher` instance +function parse(query, options, { auto = true } = {}) { + const next = (query) => { + let keys = Object.keys(query); + + const isQueryPath = isPath(query); + + if (!isQueryPath && keys.length > 1 && !isExpression(query)) { + return next(convertToExplicit(query)) + } + + if (isLeaf(query)) { + const key = isQueryPath ? query[KeyType.PATH] : keys[0]; + + const pattern = isQueryPath ? query[KeyType.PATTERN] : query[key]; + + if (!isString(pattern)) { + throw new Error(LOGICAL_SEARCH_INVALID_QUERY_FOR_KEY(key)) + } + + const obj = { + keyId: createKeyId(key), + pattern + }; + + if (auto) { + obj.searcher = createSearcher(pattern, options); + } + + return obj + } + + let node = { + children: [], + operator: keys[0] + }; + + keys.forEach((key) => { + const value = query[key]; + + if (isArray(value)) { + value.forEach((item) => { + node.children.push(next(item)); + }); + } + }); + + return node + }; + + if (!isExpression(query)) { + query = convertToExplicit(query); + } + + return next(query) +} + +// Practical scoring function +function computeScore( + results, + { ignoreFieldNorm = Config.ignoreFieldNorm } +) { + results.forEach((result) => { + let totalScore = 1; + + result.matches.forEach(({ key, norm, score }) => { + const weight = key ? key.weight : null; + + totalScore *= Math.pow( + score === 0 && weight ? Number.EPSILON : score, + (weight || 1) * (ignoreFieldNorm ? 1 : norm) + ); + }); + + result.score = totalScore; + }); +} + +function transformMatches(result, data) { + const matches = result.matches; + data.matches = []; + + if (!isDefined(matches)) { + return + } + + matches.forEach((match) => { + if (!isDefined(match.indices) || !match.indices.length) { + return + } + + const { indices, value } = match; + + let obj = { + indices, + value + }; + + if (match.key) { + obj.key = match.key.src; + } + + if (match.idx > -1) { + obj.refIndex = match.idx; + } + + data.matches.push(obj); + }); +} + +function transformScore(result, data) { + data.score = result.score; +} + +function format( + results, + docs, + { + includeMatches = Config.includeMatches, + includeScore = Config.includeScore + } = {} +) { + const transformers = []; + + if (includeMatches) transformers.push(transformMatches); + if (includeScore) transformers.push(transformScore); + + return results.map((result) => { + const { idx } = result; + + const data = { + item: docs[idx], + refIndex: idx + }; + + if (transformers.length) { + transformers.forEach((transformer) => { + transformer(result, data); + }); + } + + return data + }) +} + +class Fuse { + constructor(docs, options = {}, index) { + this.options = { ...Config, ...options }; + + if ( + this.options.useExtendedSearch && + !true + ) {} + + this._keyStore = new KeyStore(this.options.keys); + + this.setCollection(docs, index); + } + + setCollection(docs, index) { + this._docs = docs; + + if (index && !(index instanceof FuseIndex)) { + throw new Error(INCORRECT_INDEX_TYPE) + } + + this._myIndex = + index || + createIndex(this.options.keys, this._docs, { + getFn: this.options.getFn, + fieldNormWeight: this.options.fieldNormWeight + }); + } + + add(doc) { + if (!isDefined(doc)) { + return + } + + this._docs.push(doc); + this._myIndex.add(doc); + } + + remove(predicate = (/* doc, idx */) => false) { + const results = []; + + for (let i = 0, len = this._docs.length; i < len; i += 1) { + const doc = this._docs[i]; + if (predicate(doc, i)) { + this.removeAt(i); + i -= 1; + len -= 1; + + results.push(doc); + } + } + + return results + } + + removeAt(idx) { + this._docs.splice(idx, 1); + this._myIndex.removeAt(idx); + } + + getIndex() { + return this._myIndex + } + + search(query, { limit = -1 } = {}) { + const { + includeMatches, + includeScore, + shouldSort, + sortFn, + ignoreFieldNorm + } = this.options; + + let results = isString(query) + ? isString(this._docs[0]) + ? this._searchStringList(query) + : this._searchObjectList(query) + : this._searchLogical(query); + + computeScore(results, { ignoreFieldNorm }); + + if (shouldSort) { + results.sort(sortFn); + } + + if (isNumber(limit) && limit > -1) { + results = results.slice(0, limit); + } + + return format(results, this._docs, { + includeMatches, + includeScore + }) + } + + _searchStringList(query) { + const searcher = createSearcher(query, this.options); + const { records } = this._myIndex; + const results = []; + + // Iterate over every string in the index + records.forEach(({ v: text, i: idx, n: norm }) => { + if (!isDefined(text)) { + return + } + + const { isMatch, score, indices } = searcher.searchIn(text); + + if (isMatch) { + results.push({ + item: text, + idx, + matches: [{ score, value: text, norm, indices }] + }); + } + }); + + return results + } + + _searchLogical(query) { + + const expression = parse(query, this.options); + + const evaluate = (node, item, idx) => { + if (!node.children) { + const { keyId, searcher } = node; + + const matches = this._findMatches({ + key: this._keyStore.get(keyId), + value: this._myIndex.getValueForItemAtKeyId(item, keyId), + searcher + }); + + if (matches && matches.length) { + return [ + { + idx, + item, + matches + } + ] + } + + return [] + } + + const res = []; + for (let i = 0, len = node.children.length; i < len; i += 1) { + const child = node.children[i]; + const result = evaluate(child, item, idx); + if (result.length) { + res.push(...result); + } else if (node.operator === LogicalOperator.AND) { + return [] + } + } + return res + }; + + const records = this._myIndex.records; + const resultMap = {}; + const results = []; + + records.forEach(({ $: item, i: idx }) => { + if (isDefined(item)) { + let expResults = evaluate(expression, item, idx); + + if (expResults.length) { + // Dedupe when adding + if (!resultMap[idx]) { + resultMap[idx] = { idx, item, matches: [] }; + results.push(resultMap[idx]); + } + expResults.forEach(({ matches }) => { + resultMap[idx].matches.push(...matches); + }); + } + } + }); + + return results + } + + _searchObjectList(query) { + const searcher = createSearcher(query, this.options); + const { keys, records } = this._myIndex; + const results = []; + + // List is Array + records.forEach(({ $: item, i: idx }) => { + if (!isDefined(item)) { + return + } + + let matches = []; + + // Iterate over every key (i.e, path), and fetch the value at that key + keys.forEach((key, keyIndex) => { + matches.push( + ...this._findMatches({ + key, + value: item[keyIndex], + searcher + }) + ); + }); + + if (matches.length) { + results.push({ + idx, + item, + matches + }); + } + }); + + return results + } + _findMatches({ key, value, searcher }) { + if (!isDefined(value)) { + return [] + } + + let matches = []; + + if (isArray(value)) { + value.forEach(({ v: text, i: idx, n: norm }) => { + if (!isDefined(text)) { + return + } + + const { isMatch, score, indices } = searcher.searchIn(text); + + if (isMatch) { + matches.push({ + score, + key, + value: text, + idx, + norm, + indices + }); + } + }); + } else { + const { v: text, n: norm } = value; + + const { isMatch, score, indices } = searcher.searchIn(text); + + if (isMatch) { + matches.push({ score, key, value: text, norm, indices }); + } + } + + return matches + } +} + +Fuse.version = '6.5.3'; +Fuse.createIndex = createIndex; +Fuse.parseIndex = parseIndex; +Fuse.config = Config; + +{ + Fuse.parseQuery = parse; +} + +{ + register(ExtendedSearch); +} + + + /***/ }), -/* 7 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { -"use strict"; +/***/ 857: +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +// ESM COMPAT FLAG __webpack_require__.r(__webpack_exports__); -// EXTERNAL MODULE: ./node_modules/fuse.js/dist/fuse.js -var dist_fuse = __webpack_require__(2); -var fuse_default = /*#__PURE__*/__webpack_require__.n(dist_fuse); +// EXPORTS +__webpack_require__.d(__webpack_exports__, { + "__DO_NOT_USE__ActionTypes": function() { return /* binding */ ActionTypes; }, + "applyMiddleware": function() { return /* binding */ applyMiddleware; }, + "bindActionCreators": function() { return /* binding */ bindActionCreators; }, + "combineReducers": function() { return /* binding */ combineReducers; }, + "compose": function() { return /* binding */ compose; }, + "createStore": function() { return /* binding */ createStore; } +}); -// EXTERNAL MODULE: ./node_modules/deepmerge/dist/cjs.js -var cjs = __webpack_require__(0); -var cjs_default = /*#__PURE__*/__webpack_require__.n(cjs); +;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/defineProperty.js +function _defineProperty(obj, key, value) { + if (key in obj) { + Object.defineProperty(obj, key, { + value: value, + enumerable: true, + configurable: true, + writable: true + }); + } else { + obj[key] = value; + } -// EXTERNAL MODULE: ./node_modules/symbol-observable/es/index.js -var es = __webpack_require__(1); + return obj; +} +;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/objectSpread2.js -// CONCATENATED MODULE: ./node_modules/redux/es/redux.js +function ownKeys(object, enumerableOnly) { + var keys = Object.keys(object); + + if (Object.getOwnPropertySymbols) { + var symbols = Object.getOwnPropertySymbols(object); + enumerableOnly && (symbols = symbols.filter(function (sym) { + return Object.getOwnPropertyDescriptor(object, sym).enumerable; + })), keys.push.apply(keys, symbols); + } + + return keys; +} + +function _objectSpread2(target) { + for (var i = 1; i < arguments.length; i++) { + var source = null != arguments[i] ? arguments[i] : {}; + i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { + _defineProperty(target, key, source[key]); + }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { + Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); + }); + } + + return target; +} +;// CONCATENATED MODULE: ./node_modules/redux/es/redux.js + + +/** + * Adapted from React: https://github.com/facebook/react/blob/master/packages/shared/formatProdErrorMessage.js + * + * Do not require this module directly! Use normal throw error calls. These messages will be replaced with error codes + * during build. + * @param {number} code + */ +function formatProdErrorMessage(code) { + return "Minified Redux error #" + code + "; visit https://redux.js.org/Errors?code=" + code + " for the full message or " + 'use the non-minified dev environment for full errors. '; +} + +// Inlined version of the `symbol-observable` polyfill +var $$observable = (function () { + return typeof Symbol === 'function' && Symbol.observable || '@@observable'; +})(); /** * These are private action types reserved by Redux. @@ -415,6 +6901,63 @@ function isPlainObject(obj) { return Object.getPrototypeOf(obj) === proto; } +// Inlined / shortened version of `kindOf` from https://github.com/jonschlinkert/kind-of +function miniKindOf(val) { + if (val === void 0) return 'undefined'; + if (val === null) return 'null'; + var type = typeof val; + + switch (type) { + case 'boolean': + case 'string': + case 'number': + case 'symbol': + case 'function': + { + return type; + } + } + + if (Array.isArray(val)) return 'array'; + if (isDate(val)) return 'date'; + if (isError(val)) return 'error'; + var constructorName = ctorName(val); + + switch (constructorName) { + case 'Symbol': + case 'Promise': + case 'WeakMap': + case 'WeakSet': + case 'Map': + case 'Set': + return constructorName; + } // other + + + return type.slice(8, -1).toLowerCase().replace(/\s/g, ''); +} + +function ctorName(val) { + return typeof val.constructor === 'function' ? val.constructor.name : null; +} + +function isError(val) { + return val instanceof Error || typeof val.message === 'string' && val.constructor && typeof val.constructor.stackTraceLimit === 'number'; +} + +function isDate(val) { + if (val instanceof Date) return true; + return typeof val.toDateString === 'function' && typeof val.getDate === 'function' && typeof val.setDate === 'function'; +} + +function kindOf(val) { + var typeOfVal = typeof val; + + if (false) {} + + return typeOfVal; +} + /** * Creates a Redux store that holds the state tree. * The only way to change the data in the store is to call `dispatch()` on it. @@ -445,7 +6988,7 @@ function createStore(reducer, preloadedState, enhancer) { var _ref2; if (typeof preloadedState === 'function' && typeof enhancer === 'function' || typeof enhancer === 'function' && typeof arguments[3] === 'function') { - throw new Error('It looks like you are passing several store enhancers to ' + 'createStore(). This is not supported. Instead, compose them ' + 'together to a single function.'); + throw new Error( true ? formatProdErrorMessage(0) : 0); } if (typeof preloadedState === 'function' && typeof enhancer === 'undefined') { @@ -455,14 +6998,14 @@ function createStore(reducer, preloadedState, enhancer) { if (typeof enhancer !== 'undefined') { if (typeof enhancer !== 'function') { - throw new Error('Expected the enhancer to be a function.'); + throw new Error( true ? formatProdErrorMessage(1) : 0); } return enhancer(createStore)(reducer, preloadedState); } if (typeof reducer !== 'function') { - throw new Error('Expected the reducer to be a function.'); + throw new Error( true ? formatProdErrorMessage(2) : 0); } var currentReducer = reducer; @@ -492,7 +7035,7 @@ function createStore(reducer, preloadedState, enhancer) { function getState() { if (isDispatching) { - throw new Error('You may not call store.getState() while the reducer is executing. ' + 'The reducer has already received the state as an argument. ' + 'Pass it down from the top reducer instead of reading it from the store.'); + throw new Error( true ? formatProdErrorMessage(3) : 0); } return currentState; @@ -524,11 +7067,11 @@ function createStore(reducer, preloadedState, enhancer) { function subscribe(listener) { if (typeof listener !== 'function') { - throw new Error('Expected the listener to be a function.'); + throw new Error( true ? formatProdErrorMessage(4) : 0); } if (isDispatching) { - throw new Error('You may not call store.subscribe() while the reducer is executing. ' + 'If you would like to be notified after the store has been updated, subscribe from a ' + 'component and invoke store.getState() in the callback to access the latest state. ' + 'See https://redux.js.org/api-reference/store#subscribe(listener) for more details.'); + throw new Error( true ? formatProdErrorMessage(5) : 0); } var isSubscribed = true; @@ -540,13 +7083,14 @@ function createStore(reducer, preloadedState, enhancer) { } if (isDispatching) { - throw new Error('You may not unsubscribe from a store listener while the reducer is executing. ' + 'See https://redux.js.org/api-reference/store#subscribe(listener) for more details.'); + throw new Error( true ? formatProdErrorMessage(6) : 0); } isSubscribed = false; ensureCanMutateNextListeners(); var index = nextListeners.indexOf(listener); nextListeners.splice(index, 1); + currentListeners = null; }; } /** @@ -578,15 +7122,15 @@ function createStore(reducer, preloadedState, enhancer) { function dispatch(action) { if (!isPlainObject(action)) { - throw new Error('Actions must be plain objects. ' + 'Use custom middleware for async actions.'); + throw new Error( true ? formatProdErrorMessage(7) : 0); } if (typeof action.type === 'undefined') { - throw new Error('Actions may not have an undefined "type" property. ' + 'Have you misspelled a constant?'); + throw new Error( true ? formatProdErrorMessage(8) : 0); } if (isDispatching) { - throw new Error('Reducers may not dispatch actions.'); + throw new Error( true ? formatProdErrorMessage(9) : 0); } try { @@ -619,7 +7163,7 @@ function createStore(reducer, preloadedState, enhancer) { function replaceReducer(nextReducer) { if (typeof nextReducer !== 'function') { - throw new Error('Expected the nextReducer to be a function.'); + throw new Error( true ? formatProdErrorMessage(10) : 0); } currentReducer = nextReducer; // This action has a similiar effect to ActionTypes.INIT. @@ -654,7 +7198,7 @@ function createStore(reducer, preloadedState, enhancer) { */ subscribe: function subscribe(observer) { if (typeof observer !== 'object' || observer === null) { - throw new TypeError('Expected the observer to be an object.'); + throw new Error( true ? formatProdErrorMessage(11) : 0); } function observeState() { @@ -669,7 +7213,7 @@ function createStore(reducer, preloadedState, enhancer) { unsubscribe: unsubscribe }; } - }, _ref[es["a" /* default */]] = function () { + }, _ref[$$observable] = function () { return this; }, _ref; } // When a store is created, an "INIT" action is dispatched so that every @@ -685,7 +7229,7 @@ function createStore(reducer, preloadedState, enhancer) { subscribe: subscribe, getState: getState, replaceReducer: replaceReducer - }, _ref2[es["a" /* default */]] = observable, _ref2; + }, _ref2[$$observable] = observable, _ref2; } /** @@ -711,12 +7255,6 @@ function warning(message) { } -function getUndefinedStateErrorMessage(key, action) { - var actionType = action && action.type; - var actionDescription = actionType && "action \"" + String(actionType) + "\"" || 'an action'; - return "Given " + actionDescription + ", reducer \"" + key + "\" returned undefined. " + "To ignore an action, you must explicitly return the previous state. " + "If you want this reducer to hold no value, you can return null instead of undefined."; -} - function getUnexpectedStateShapeWarningMessage(inputState, reducers, action, unexpectedKeyCache) { var reducerKeys = Object.keys(reducers); var argumentName = action && action.type === ActionTypes.INIT ? 'preloadedState argument passed to createStore' : 'previous state received by the reducer'; @@ -726,7 +7264,7 @@ function getUnexpectedStateShapeWarningMessage(inputState, reducers, action, une } if (!isPlainObject(inputState)) { - return "The " + argumentName + " has unexpected type of \"" + {}.toString.call(inputState).match(/\s([a-z|A-Z]+)/)[1] + "\". Expected argument to be an object with the following " + ("keys: \"" + reducerKeys.join('", "') + "\""); + return "The " + argumentName + " has unexpected type of \"" + kindOf(inputState) + "\". Expected argument to be an object with the following " + ("keys: \"" + reducerKeys.join('", "') + "\""); } var unexpectedKeys = Object.keys(inputState).filter(function (key) { @@ -750,13 +7288,13 @@ function assertReducerShape(reducers) { }); if (typeof initialState === 'undefined') { - throw new Error("Reducer \"" + key + "\" returned undefined during initialization. " + "If the state passed to the reducer is undefined, you must " + "explicitly return the initial state. The initial state may " + "not be undefined. If you don't want to set a value for this reducer, " + "you can use null instead of undefined."); + throw new Error( true ? formatProdErrorMessage(12) : 0); } if (typeof reducer(undefined, { type: ActionTypes.PROBE_UNKNOWN_ACTION() }) === 'undefined') { - throw new Error("Reducer \"" + key + "\" returned undefined when probed with a random type. " + ("Don't try to handle " + ActionTypes.INIT + " or other actions in \"redux/*\" ") + "namespace. They are considered private. Instead, you must return the " + "current state for any unknown actions, unless it is undefined, " + "in which case you must return the initial state, regardless of the " + "action type. The initial state may not be undefined, but can be null."); + throw new Error( true ? formatProdErrorMessage(13) : 0); } }); } @@ -828,14 +7366,15 @@ function combineReducers(reducers) { var nextStateForKey = reducer(previousStateForKey, action); if (typeof nextStateForKey === 'undefined') { - var errorMessage = getUndefinedStateErrorMessage(_key, action); - throw new Error(errorMessage); + var actionType = action && action.type; + throw new Error( true ? formatProdErrorMessage(14) : 0); } nextState[_key] = nextStateForKey; hasChanged = hasChanged || nextStateForKey !== previousStateForKey; } + hasChanged = hasChanged || finalReducerKeys.length !== Object.keys(state).length; return hasChanged ? nextState : state; }; } @@ -874,7 +7413,7 @@ function bindActionCreators(actionCreators, dispatch) { } if (typeof actionCreators !== 'object' || actionCreators === null) { - throw new Error("bindActionCreators expected an object or a function, instead received " + (actionCreators === null ? 'null' : typeof actionCreators) + ". " + "Did you write \"import ActionCreators from\" instead of \"import * as ActionCreators from\"?"); + throw new Error( true ? formatProdErrorMessage(16) : 0); } var boundActionCreators = {}; @@ -890,54 +7429,6 @@ function bindActionCreators(actionCreators, dispatch) { return boundActionCreators; } -function _defineProperty(obj, key, value) { - if (key in obj) { - Object.defineProperty(obj, key, { - value: value, - enumerable: true, - configurable: true, - writable: true - }); - } else { - obj[key] = value; - } - - return obj; -} - -function ownKeys(object, enumerableOnly) { - var keys = Object.keys(object); - - if (Object.getOwnPropertySymbols) { - keys.push.apply(keys, Object.getOwnPropertySymbols(object)); - } - - if (enumerableOnly) keys = keys.filter(function (sym) { - return Object.getOwnPropertyDescriptor(object, sym).enumerable; - }); - return keys; -} - -function _objectSpread2(target) { - for (var i = 1; i < arguments.length; i++) { - var source = arguments[i] != null ? arguments[i] : {}; - - if (i % 2) { - ownKeys(source, true).forEach(function (key) { - _defineProperty(target, key, source[key]); - }); - } else if (Object.getOwnPropertyDescriptors) { - Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); - } else { - ownKeys(source).forEach(function (key) { - Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); - }); - } - } - - return target; -} - /** * Composes single-argument functions from right to left. The rightmost * function can take multiple arguments as it provides the signature for @@ -997,7 +7488,7 @@ function applyMiddleware() { var store = createStore.apply(void 0, arguments); var _dispatch = function dispatch() { - throw new Error('Dispatching while constructing your middleware is not allowed. ' + 'Other middleware would not be applied to this dispatch.'); + throw new Error( true ? formatProdErrorMessage(15) : 0); }; var middlewareAPI = { @@ -1010,7 +7501,7 @@ function applyMiddleware() { return middleware(middlewareAPI); }); _dispatch = compose.apply(void 0, chain)(store.dispatch); - return _objectSpread2({}, store, { + return _objectSpread2(_objectSpread2({}, store), {}, { dispatch: _dispatch }); }; @@ -1028,4576 +7519,99 @@ if (false) {} -// CONCATENATED MODULE: ./src/scripts/reducers/items.js -var defaultState = []; -function items_items(state, action) { - if (state === void 0) { - state = defaultState; - } - - switch (action.type) { - case 'ADD_ITEM': - { - // Add object to items array - var newState = [].concat(state, [{ - id: action.id, - choiceId: action.choiceId, - groupId: action.groupId, - value: action.value, - label: action.label, - active: true, - highlighted: false, - customProperties: action.customProperties, - placeholder: action.placeholder || false, - keyCode: null - }]); - return newState.map(function (obj) { - var item = obj; - item.highlighted = false; - return item; - }); - } - - case 'REMOVE_ITEM': - { - // Set item to inactive - return state.map(function (obj) { - var item = obj; - - if (item.id === action.id) { - item.active = false; - } - - return item; - }); - } - - case 'HIGHLIGHT_ITEM': - { - return state.map(function (obj) { - var item = obj; - - if (item.id === action.id) { - item.highlighted = action.highlighted; - } - - return item; - }); - } - - default: - { - return state; - } - } -} -// CONCATENATED MODULE: ./src/scripts/reducers/groups.js -var groups_defaultState = []; -function groups(state, action) { - if (state === void 0) { - state = groups_defaultState; - } - - switch (action.type) { - case 'ADD_GROUP': - { - return [].concat(state, [{ - id: action.id, - value: action.value, - active: action.active, - disabled: action.disabled - }]); - } - - case 'CLEAR_CHOICES': - { - return []; - } - - default: - { - return state; - } - } -} -// CONCATENATED MODULE: ./src/scripts/reducers/choices.js -var choices_defaultState = []; -function choices_choices(state, action) { - if (state === void 0) { - state = choices_defaultState; - } - - switch (action.type) { - case 'ADD_CHOICE': - { - /* - A disabled choice appears in the choice dropdown but cannot be selected - A selected choice has been added to the passed input's value (added as an item) - An active choice appears within the choice dropdown - */ - return [].concat(state, [{ - id: action.id, - elementId: action.elementId, - groupId: action.groupId, - value: action.value, - label: action.label || action.value, - disabled: action.disabled || false, - selected: false, - active: true, - score: 9999, - customProperties: action.customProperties, - placeholder: action.placeholder || false, - keyCode: null - }]); - } - - case 'ADD_ITEM': - { - // If all choices need to be activated - if (action.activateOptions) { - return state.map(function (obj) { - var choice = obj; - choice.active = action.active; - return choice; - }); - } // When an item is added and it has an associated choice, - // we want to disable it so it can't be chosen again - - - if (action.choiceId > -1) { - return state.map(function (obj) { - var choice = obj; - - if (choice.id === parseInt(action.choiceId, 10)) { - choice.selected = true; - } - - return choice; - }); - } - - return state; - } - - case 'REMOVE_ITEM': - { - // When an item is removed and it has an associated choice, - // we want to re-enable it so it can be chosen again - if (action.choiceId > -1) { - return state.map(function (obj) { - var choice = obj; - - if (choice.id === parseInt(action.choiceId, 10)) { - choice.selected = false; - } - - return choice; - }); - } - - return state; - } - - case 'FILTER_CHOICES': - { - return state.map(function (obj) { - var choice = obj; // Set active state based on whether choice is - // within filtered results - - choice.active = action.results.some(function (_ref) { - var item = _ref.item, - score = _ref.score; - - if (item.id === choice.id) { - choice.score = score; - return true; - } - - return false; - }); - return choice; - }); - } - - case 'ACTIVATE_CHOICES': - { - return state.map(function (obj) { - var choice = obj; - choice.active = action.active; - return choice; - }); - } - - case 'CLEAR_CHOICES': - { - return choices_defaultState; - } - - default: - { - return state; - } - } -} -// CONCATENATED MODULE: ./src/scripts/reducers/general.js -var general_defaultState = { - loading: false -}; - -var general = function general(state, action) { - if (state === void 0) { - state = general_defaultState; - } - - switch (action.type) { - case 'SET_IS_LOADING': - { - return { - loading: action.isLoading - }; - } - - default: - { - return state; - } - } -}; - -/* harmony default export */ var reducers_general = (general); -// CONCATENATED MODULE: ./src/scripts/lib/utils.js -/** - * @param {number} min - * @param {number} max - * @returns {number} - */ -var getRandomNumber = function getRandomNumber(min, max) { - return Math.floor(Math.random() * (max - min) + min); -}; -/** - * @param {number} length - * @returns {string} - */ - -var generateChars = function generateChars(length) { - return Array.from({ - length: length - }, function () { - return getRandomNumber(0, 36).toString(36); - }).join(''); -}; -/** - * @param {HTMLInputElement | HTMLSelectElement} element - * @param {string} prefix - * @returns {string} - */ - -var generateId = function generateId(element, prefix) { - var id = element.id || element.name && element.name + "-" + generateChars(2) || generateChars(4); - id = id.replace(/(:|\.|\[|\]|,)/g, ''); - id = prefix + "-" + id; - return id; -}; -/** - * @param {any} obj - * @returns {string} - */ - -var getType = function getType(obj) { - return Object.prototype.toString.call(obj).slice(8, -1); -}; -/** - * @param {string} type - * @param {any} obj - * @returns {boolean} - */ - -var isType = function isType(type, obj) { - return obj !== undefined && obj !== null && getType(obj) === type; -}; -/** - * @param {HTMLElement} element - * @param {HTMLElement} [wrapper={HTMLDivElement}] - * @returns {HTMLElement} - */ - -var utils_wrap = function wrap(element, wrapper) { - if (wrapper === void 0) { - wrapper = document.createElement('div'); - } - - if (element.nextSibling) { - element.parentNode.insertBefore(wrapper, element.nextSibling); - } else { - element.parentNode.appendChild(wrapper); - } - - return wrapper.appendChild(element); -}; -/** - * @param {Element} startEl - * @param {string} selector - * @param {1 | -1} direction - * @returns {Element | undefined} - */ - -var getAdjacentEl = function getAdjacentEl(startEl, selector, direction) { - if (direction === void 0) { - direction = 1; - } - - if (!(startEl instanceof Element) || typeof selector !== 'string') { - return undefined; - } - - var prop = (direction > 0 ? 'next' : 'previous') + "ElementSibling"; - var sibling = startEl[prop]; - - while (sibling) { - if (sibling.matches(selector)) { - return sibling; - } - - sibling = sibling[prop]; - } - - return sibling; -}; -/** - * @param {Element} element - * @param {Element} parent - * @param {-1 | 1} direction - * @returns {boolean} - */ - -var isScrolledIntoView = function isScrolledIntoView(element, parent, direction) { - if (direction === void 0) { - direction = 1; - } - - if (!element) { - return false; - } - - var isVisible; - - if (direction > 0) { - // In view from bottom - isVisible = parent.scrollTop + parent.offsetHeight >= element.offsetTop + element.offsetHeight; - } else { - // In view from top - isVisible = element.offsetTop >= parent.scrollTop; - } - - return isVisible; -}; -/** - * @param {any} value - * @returns {any} - */ - -var sanitise = function sanitise(value) { - if (typeof value !== 'string') { - return value; - } - - return value.replace(/&/g, '&').replace(/>/g, '&rt;').replace(/ (str: string) => Element} - */ - -var strToEl = function () { - var tmpEl = document.createElement('div'); - return function (str) { - var cleanedInput = str.trim(); - tmpEl.innerHTML = cleanedInput; - var firldChild = tmpEl.children[0]; - - while (tmpEl.firstChild) { - tmpEl.removeChild(tmpEl.firstChild); - } - - return firldChild; - }; -}(); -/** - * @param {{ label?: string, value: string }} a - * @param {{ label?: string, value: string }} b - * @returns {number} - */ - -var sortByAlpha = function sortByAlpha(_ref, _ref2) { - var value = _ref.value, - _ref$label = _ref.label, - label = _ref$label === void 0 ? value : _ref$label; - var value2 = _ref2.value, - _ref2$label = _ref2.label, - label2 = _ref2$label === void 0 ? value2 : _ref2$label; - return label.localeCompare(label2, [], { - sensitivity: 'base', - ignorePunctuation: true, - numeric: true - }); -}; -/** - * @param {{ score: number }} a - * @param {{ score: number }} b - */ - -var sortByScore = function sortByScore(a, b) { - return a.score - b.score; -}; -/** - * @param {HTMLElement} element - * @param {string} type - * @param {object} customArgs - */ - -var dispatchEvent = function dispatchEvent(element, type, customArgs) { - if (customArgs === void 0) { - customArgs = null; - } - - var event = new CustomEvent(type, { - detail: customArgs, - bubbles: true, - cancelable: true - }); - return element.dispatchEvent(event); -}; -/** - * @param {array} array - * @param {any} value - * @param {string} [key="value"] - * @returns {boolean} - */ - -var existsInArray = function existsInArray(array, value, key) { - if (key === void 0) { - key = 'value'; - } - - return array.some(function (item) { - if (typeof value === 'string') { - return item[key] === value.trim(); - } - - return item[key] === value; - }); -}; -/** - * @param {any} obj - * @returns {any} - */ - -var cloneObject = function cloneObject(obj) { - return JSON.parse(JSON.stringify(obj)); -}; -/** - * Returns an array of keys present on the first but missing on the second object - * @param {object} a - * @param {object} b - * @returns {string[]} - */ - -var diff = function diff(a, b) { - var aKeys = Object.keys(a).sort(); - var bKeys = Object.keys(b).sort(); - return aKeys.filter(function (i) { - return bKeys.indexOf(i) < 0; - }); -}; -// CONCATENATED MODULE: ./src/scripts/reducers/index.js - - - - - - -var appReducer = combineReducers({ - items: items_items, - groups: groups, - choices: choices_choices, - general: reducers_general -}); - -var reducers_rootReducer = function rootReducer(passedState, action) { - var state = passedState; // If we are clearing all items, groups and options we reassign - // state and then pass that state to our proper reducer. This isn't - // mutating our actual state - // See: http://stackoverflow.com/a/35641992 - - if (action.type === 'CLEAR_ALL') { - state = undefined; - } else if (action.type === 'RESET_TO') { - return cloneObject(action.state); - } - - return appReducer(state, action); -}; - -/* harmony default export */ var reducers = (reducers_rootReducer); -// CONCATENATED MODULE: ./src/scripts/store/store.js -function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } - -function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } - - - -/** - * @typedef {import('../../../types/index').Choices.Choice} Choice - * @typedef {import('../../../types/index').Choices.Group} Group - * @typedef {import('../../../types/index').Choices.Item} Item - */ - -var store_Store = -/*#__PURE__*/ -function () { - function Store() { - this._store = createStore(reducers, window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__()); - } - /** - * Subscribe store to function call (wrapped Redux method) - * @param {Function} onChange Function to trigger when state changes - * @return - */ - - - var _proto = Store.prototype; - - _proto.subscribe = function subscribe(onChange) { - this._store.subscribe(onChange); - } - /** - * Dispatch event to store (wrapped Redux method) - * @param {{ type: string, [x: string]: any }} action Action to trigger - * @return - */ - ; - - _proto.dispatch = function dispatch(action) { - this._store.dispatch(action); - } - /** - * Get store object (wrapping Redux method) - * @returns {object} State - */ - ; - - /** - * Get loading state from store - * @returns {boolean} Loading State - */ - _proto.isLoading = function isLoading() { - return this.state.general.loading; - } - /** - * Get single choice by it's ID - * @param {string} id - * @returns {Choice | undefined} Found choice - */ - ; - - _proto.getChoiceById = function getChoiceById(id) { - return this.activeChoices.find(function (choice) { - return choice.id === parseInt(id, 10); - }); - } - /** - * Get group by group id - * @param {number} id Group ID - * @returns {Group | undefined} Group data - */ - ; - - _proto.getGroupById = function getGroupById(id) { - return this.groups.find(function (group) { - return group.id === id; - }); - }; - - _createClass(Store, [{ - key: "state", - get: function get() { - return this._store.getState(); - } - /** - * Get items from store - * @returns {Item[]} Item objects - */ - - }, { - key: "items", - get: function get() { - return this.state.items; - } - /** - * Get active items from store - * @returns {Item[]} Item objects - */ - - }, { - key: "activeItems", - get: function get() { - return this.items.filter(function (item) { - return item.active === true; - }); - } - /** - * Get highlighted items from store - * @returns {Item[]} Item objects - */ - - }, { - key: "highlightedActiveItems", - get: function get() { - return this.items.filter(function (item) { - return item.active && item.highlighted; - }); - } - /** - * Get choices from store - * @returns {Choice[]} Option objects - */ - - }, { - key: "choices", - get: function get() { - return this.state.choices; - } - /** - * Get active choices from store - * @returns {Choice[]} Option objects - */ - - }, { - key: "activeChoices", - get: function get() { - return this.choices.filter(function (choice) { - return choice.active === true; - }); - } - /** - * Get selectable choices from store - * @returns {Choice[]} Option objects - */ - - }, { - key: "selectableChoices", - get: function get() { - return this.choices.filter(function (choice) { - return choice.disabled !== true; - }); - } - /** - * Get choices that can be searched (excluding placeholders) - * @returns {Choice[]} Option objects - */ - - }, { - key: "searchableChoices", - get: function get() { - return this.selectableChoices.filter(function (choice) { - return choice.placeholder !== true; - }); - } - /** - * Get placeholder choice from store - * @returns {Choice | undefined} Found placeholder - */ - - }, { - key: "placeholderChoice", - get: function get() { - return [].concat(this.choices).reverse().find(function (choice) { - return choice.placeholder === true; - }); - } - /** - * Get groups from store - * @returns {Group[]} Group objects - */ - - }, { - key: "groups", - get: function get() { - return this.state.groups; - } - /** - * Get active groups from store - * @returns {Group[]} Group objects - */ - - }, { - key: "activeGroups", - get: function get() { - var groups = this.groups, - choices = this.choices; - return groups.filter(function (group) { - var isActive = group.active === true && group.disabled === false; - var hasActiveOptions = choices.some(function (choice) { - return choice.active === true && choice.disabled === false; - }); - return isActive && hasActiveOptions; - }, []); - } - }]); - - return Store; -}(); - - -// CONCATENATED MODULE: ./src/scripts/components/dropdown.js -function dropdown_defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } - -function dropdown_createClass(Constructor, protoProps, staticProps) { if (protoProps) dropdown_defineProperties(Constructor.prototype, protoProps); if (staticProps) dropdown_defineProperties(Constructor, staticProps); return Constructor; } - -/** - * @typedef {import('../../../types/index').Choices.passedElement} passedElement - * @typedef {import('../../../types/index').Choices.ClassNames} ClassNames - */ -var Dropdown = -/*#__PURE__*/ -function () { - /** - * @param {{ - * element: HTMLElement, - * type: passedElement['type'], - * classNames: ClassNames, - * }} args - */ - function Dropdown(_ref) { - var element = _ref.element, - type = _ref.type, - classNames = _ref.classNames; - this.element = element; - this.classNames = classNames; - this.type = type; - this.isActive = false; - } - /** - * Bottom position of dropdown in viewport coordinates - * @returns {number} Vertical position - */ - - - var _proto = Dropdown.prototype; - - /** - * Find element that matches passed selector - * @param {string} selector - * @returns {HTMLElement | null} - */ - _proto.getChild = function getChild(selector) { - return this.element.querySelector(selector); - } - /** - * Show dropdown to user by adding active state class - * @returns {this} - */ - ; - - _proto.show = function show() { - this.element.classList.add(this.classNames.activeState); - this.element.setAttribute('aria-expanded', 'true'); - this.isActive = true; - return this; - } - /** - * Hide dropdown from user - * @returns {this} - */ - ; - - _proto.hide = function hide() { - this.element.classList.remove(this.classNames.activeState); - this.element.setAttribute('aria-expanded', 'false'); - this.isActive = false; - return this; - }; - - dropdown_createClass(Dropdown, [{ - key: "distanceFromTopWindow", - get: function get() { - return this.element.getBoundingClientRect().bottom; - } - }]); - - return Dropdown; -}(); - - -// CONCATENATED MODULE: ./src/scripts/constants.js - -/** - * @typedef {import('../../types/index').Choices.ClassNames} ClassNames - * @typedef {import('../../types/index').Choices.Options} Options - */ - -/** @type {ClassNames} */ - -var DEFAULT_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', - 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', - noResults: 'has-no-results', - noChoices: 'has-no-choices' -}; -/** @type {Options} */ - -var DEFAULT_CONFIG = { - items: [], - choices: [], - silent: false, - renderChoiceLimit: -1, - maxItemCount: -1, - addItems: true, - addItemFilter: null, - removeItems: true, - removeItemButton: false, - editItems: false, - duplicateItemsAllowed: true, - delimiter: ',', - paste: true, - searchEnabled: true, - searchChoices: true, - searchFloor: 1, - searchResultLimit: 4, - searchFields: ['label', 'value'], - position: 'auto', - resetScrollPosition: true, - shouldSort: true, - shouldSortItems: false, - sorter: sortByAlpha, - placeholder: true, - 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 addItemText(value) { - return "Press Enter to add \"" + sanitise(value) + "\""; - }, - maxItemText: function maxItemText(maxItemCount) { - return "Only " + maxItemCount + " values can be added"; - }, - valueComparer: function valueComparer(value1, value2) { - return value1 === value2; - }, - fuseOptions: { - includeScore: true - }, - callbackOnInit: null, - callbackOnCreateTemplates: null, - classNames: DEFAULT_CLASSNAMES -}; -var EVENTS = { - showDropdown: 'showDropdown', - hideDropdown: 'hideDropdown', - change: 'change', - choice: 'choice', - search: 'search', - addItem: 'addItem', - removeItem: 'removeItem', - highlightItem: 'highlightItem', - highlightChoice: 'highlightChoice' -}; -var ACTION_TYPES = { - ADD_CHOICE: 'ADD_CHOICE', - FILTER_CHOICES: 'FILTER_CHOICES', - ACTIVATE_CHOICES: 'ACTIVATE_CHOICES', - CLEAR_CHOICES: 'CLEAR_CHOICES', - ADD_GROUP: 'ADD_GROUP', - ADD_ITEM: 'ADD_ITEM', - REMOVE_ITEM: 'REMOVE_ITEM', - HIGHLIGHT_ITEM: 'HIGHLIGHT_ITEM', - CLEAR_ALL: 'CLEAR_ALL' -}; -var KEY_CODES = { - BACK_KEY: 46, - DELETE_KEY: 8, - ENTER_KEY: 13, - A_KEY: 65, - ESC_KEY: 27, - UP_KEY: 38, - DOWN_KEY: 40, - PAGE_UP_KEY: 33, - PAGE_DOWN_KEY: 34 -}; -var TEXT_TYPE = 'text'; -var SELECT_ONE_TYPE = 'select-one'; -var SELECT_MULTIPLE_TYPE = 'select-multiple'; -var SCROLLING_SPEED = 4; -// CONCATENATED MODULE: ./src/scripts/components/container.js - - -/** - * @typedef {import('../../../types/index').Choices.passedElement} passedElement - * @typedef {import('../../../types/index').Choices.ClassNames} ClassNames - */ - -var container_Container = -/*#__PURE__*/ -function () { - /** - * @param {{ - * element: HTMLElement, - * type: passedElement['type'], - * classNames: ClassNames, - * position - * }} args - */ - function Container(_ref) { - var element = _ref.element, - type = _ref.type, - classNames = _ref.classNames, - position = _ref.position; - this.element = element; - this.classNames = classNames; - this.type = type; - this.position = position; - this.isOpen = false; - this.isFlipped = false; - this.isFocussed = false; - this.isDisabled = false; - this.isLoading = false; - this._onFocus = this._onFocus.bind(this); - this._onBlur = this._onBlur.bind(this); - } - - var _proto = Container.prototype; - - _proto.addEventListeners = function addEventListeners() { - this.element.addEventListener('focus', this._onFocus); - this.element.addEventListener('blur', this._onBlur); - }; - - _proto.removeEventListeners = function removeEventListeners() { - this.element.removeEventListener('focus', this._onFocus); - this.element.removeEventListener('blur', this._onBlur); - } - /** - * Determine whether container should be flipped based on passed - * dropdown position - * @param {number} dropdownPos - * @returns {boolean} - */ - ; - - _proto.shouldFlip = function shouldFlip(dropdownPos) { - if (typeof dropdownPos !== 'number') { - return false; - } // If flip is enabled and the dropdown bottom position is - // greater than the window height flip the dropdown. - - - var shouldFlip = false; - - if (this.position === 'auto') { - shouldFlip = !window.matchMedia("(min-height: " + (dropdownPos + 1) + "px)").matches; - } else if (this.position === 'top') { - shouldFlip = true; - } - - return shouldFlip; - } - /** - * @param {string} activeDescendantID - */ - ; - - _proto.setActiveDescendant = function setActiveDescendant(activeDescendantID) { - this.element.setAttribute('aria-activedescendant', activeDescendantID); - }; - - _proto.removeActiveDescendant = function removeActiveDescendant() { - this.element.removeAttribute('aria-activedescendant'); - } - /** - * @param {number} dropdownPos - */ - ; - - _proto.open = function open(dropdownPos) { - this.element.classList.add(this.classNames.openState); - this.element.setAttribute('aria-expanded', 'true'); - this.isOpen = true; - - if (this.shouldFlip(dropdownPos)) { - this.element.classList.add(this.classNames.flippedState); - this.isFlipped = true; - } - }; - - _proto.close = function close() { - this.element.classList.remove(this.classNames.openState); - this.element.setAttribute('aria-expanded', 'false'); - this.removeActiveDescendant(); - this.isOpen = false; // A dropdown flips if it does not have space within the page - - if (this.isFlipped) { - this.element.classList.remove(this.classNames.flippedState); - this.isFlipped = false; - } - }; - - _proto.focus = function focus() { - if (!this.isFocussed) { - this.element.focus(); - } - }; - - _proto.addFocusState = function addFocusState() { - this.element.classList.add(this.classNames.focusState); - }; - - _proto.removeFocusState = function removeFocusState() { - this.element.classList.remove(this.classNames.focusState); - }; - - _proto.enable = function enable() { - this.element.classList.remove(this.classNames.disabledState); - this.element.removeAttribute('aria-disabled'); - - if (this.type === SELECT_ONE_TYPE) { - this.element.setAttribute('tabindex', '0'); - } - - this.isDisabled = false; - }; - - _proto.disable = function disable() { - this.element.classList.add(this.classNames.disabledState); - this.element.setAttribute('aria-disabled', 'true'); - - if (this.type === SELECT_ONE_TYPE) { - this.element.setAttribute('tabindex', '-1'); - } - - this.isDisabled = true; - } - /** - * @param {HTMLElement} element - */ - ; - - _proto.wrap = function wrap(element) { - utils_wrap(element, this.element); - } - /** - * @param {Element} element - */ - ; - - _proto.unwrap = function unwrap(element) { - // Move passed element outside this element - this.element.parentNode.insertBefore(element, this.element); // Remove this element - - this.element.parentNode.removeChild(this.element); - }; - - _proto.addLoadingState = function addLoadingState() { - this.element.classList.add(this.classNames.loadingState); - this.element.setAttribute('aria-busy', 'true'); - this.isLoading = true; - }; - - _proto.removeLoadingState = function removeLoadingState() { - this.element.classList.remove(this.classNames.loadingState); - this.element.removeAttribute('aria-busy'); - this.isLoading = false; - }; - - _proto._onFocus = function _onFocus() { - this.isFocussed = true; - }; - - _proto._onBlur = function _onBlur() { - this.isFocussed = false; - }; - - return Container; -}(); - - -// CONCATENATED MODULE: ./src/scripts/components/input.js -function input_defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } - -function input_createClass(Constructor, protoProps, staticProps) { if (protoProps) input_defineProperties(Constructor.prototype, protoProps); if (staticProps) input_defineProperties(Constructor, staticProps); return Constructor; } - - - -/** - * @typedef {import('../../../types/index').Choices.passedElement} passedElement - * @typedef {import('../../../types/index').Choices.ClassNames} ClassNames - */ - -var input_Input = -/*#__PURE__*/ -function () { - /** - * @param {{ - * element: HTMLInputElement, - * type: passedElement['type'], - * classNames: ClassNames, - * preventPaste: boolean - * }} args - */ - function Input(_ref) { - var element = _ref.element, - type = _ref.type, - classNames = _ref.classNames, - preventPaste = _ref.preventPaste; - this.element = element; - this.type = type; - this.classNames = classNames; - this.preventPaste = preventPaste; - this.isFocussed = this.element === document.activeElement; - this.isDisabled = element.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); - } - /** - * @param {string} placeholder - */ - - - var _proto = Input.prototype; - - _proto.addEventListeners = function addEventListeners() { - this.element.addEventListener('paste', this._onPaste); - this.element.addEventListener('input', this._onInput, { - passive: true - }); - this.element.addEventListener('focus', this._onFocus, { - passive: true - }); - this.element.addEventListener('blur', this._onBlur, { - passive: true - }); - }; - - _proto.removeEventListeners = function removeEventListeners() { - this.element.removeEventListener('input', this._onInput, { - passive: true - }); - this.element.removeEventListener('paste', this._onPaste); - this.element.removeEventListener('focus', this._onFocus, { - passive: true - }); - this.element.removeEventListener('blur', this._onBlur, { - passive: true - }); - }; - - _proto.enable = function enable() { - this.element.removeAttribute('disabled'); - this.isDisabled = false; - }; - - _proto.disable = function disable() { - this.element.setAttribute('disabled', ''); - this.isDisabled = true; - }; - - _proto.focus = function focus() { - if (!this.isFocussed) { - this.element.focus(); - } - }; - - _proto.blur = function blur() { - if (this.isFocussed) { - this.element.blur(); - } - } - /** - * Set value of input to blank - * @param {boolean} setWidth - * @returns {this} - */ - ; - - _proto.clear = function clear(setWidth) { - if (setWidth === void 0) { - setWidth = true; - } - - if (this.element.value) { - this.element.value = ''; - } - - if (setWidth) { - this.setWidth(); - } - - return this; - } - /** - * Set the correct input width based on placeholder - * value or input value - */ - ; - - _proto.setWidth = function setWidth() { - // Resize input to contents or placeholder - var _this$element = this.element, - style = _this$element.style, - value = _this$element.value, - placeholder = _this$element.placeholder; - style.minWidth = placeholder.length + 1 + "ch"; - style.width = value.length + 1 + "ch"; - } - /** - * @param {string} activeDescendantID - */ - ; - - _proto.setActiveDescendant = function setActiveDescendant(activeDescendantID) { - this.element.setAttribute('aria-activedescendant', activeDescendantID); - }; - - _proto.removeActiveDescendant = function removeActiveDescendant() { - this.element.removeAttribute('aria-activedescendant'); - }; - - _proto._onInput = function _onInput() { - if (this.type !== SELECT_ONE_TYPE) { - this.setWidth(); - } - } - /** - * @param {Event} event - */ - ; - - _proto._onPaste = function _onPaste(event) { - if (this.preventPaste) { - event.preventDefault(); - } - }; - - _proto._onFocus = function _onFocus() { - this.isFocussed = true; - }; - - _proto._onBlur = function _onBlur() { - this.isFocussed = false; - }; - - input_createClass(Input, [{ - key: "placeholder", - set: function set(placeholder) { - this.element.placeholder = placeholder; - } - /** - * @returns {string} - */ - - }, { - key: "value", - get: function get() { - return sanitise(this.element.value); - } - /** - * @param {string} value - */ - , - set: function set(value) { - this.element.value = value; - } - }]); - - return Input; -}(); - - -// CONCATENATED MODULE: ./src/scripts/components/list.js - -/** - * @typedef {import('../../../types/index').Choices.Choice} Choice - */ - -var list_List = -/*#__PURE__*/ -function () { - /** - * @param {{ element: HTMLElement }} args - */ - function List(_ref) { - var element = _ref.element; - this.element = element; - this.scrollPos = this.element.scrollTop; - this.height = this.element.offsetHeight; - } - - var _proto = List.prototype; - - _proto.clear = function clear() { - this.element.innerHTML = ''; - } - /** - * @param {Element | DocumentFragment} node - */ - ; - - _proto.append = function append(node) { - this.element.appendChild(node); - } - /** - * @param {string} selector - * @returns {Element | null} - */ - ; - - _proto.getChild = function getChild(selector) { - return this.element.querySelector(selector); - } - /** - * @returns {boolean} - */ - ; - - _proto.hasChildren = function hasChildren() { - return this.element.hasChildNodes(); - }; - - _proto.scrollToTop = function scrollToTop() { - this.element.scrollTop = 0; - } - /** - * @param {Element} element - * @param {1 | -1} direction - */ - ; - - _proto.scrollToChildElement = function scrollToChildElement(element, direction) { - var _this = this; - - if (!element) { - return; - } - - var listHeight = this.element.offsetHeight; // Scroll position of dropdown - - var listScrollPosition = this.element.scrollTop + listHeight; - var elementHeight = element.offsetHeight; // Distance from bottom of element to top of parent - - var elementPos = element.offsetTop + elementHeight; // Difference between the element and scroll position - - var destination = direction > 0 ? this.element.scrollTop + elementPos - listScrollPosition : element.offsetTop; - requestAnimationFrame(function () { - _this._animateScroll(destination, direction); - }); - } - /** - * @param {number} scrollPos - * @param {number} strength - * @param {number} destination - */ - ; - - _proto._scrollDown = function _scrollDown(scrollPos, strength, destination) { - var easing = (destination - scrollPos) / strength; - var distance = easing > 1 ? easing : 1; - this.element.scrollTop = scrollPos + distance; - } - /** - * @param {number} scrollPos - * @param {number} strength - * @param {number} destination - */ - ; - - _proto._scrollUp = function _scrollUp(scrollPos, strength, destination) { - var easing = (scrollPos - destination) / strength; - var distance = easing > 1 ? easing : 1; - this.element.scrollTop = scrollPos - distance; - } - /** - * @param {*} destination - * @param {*} direction - */ - ; - - _proto._animateScroll = function _animateScroll(destination, direction) { - var _this2 = this; - - var strength = SCROLLING_SPEED; - var choiceListScrollTop = this.element.scrollTop; - var continueAnimation = false; - - if (direction > 0) { - this._scrollDown(choiceListScrollTop, strength, destination); - - if (choiceListScrollTop < destination) { - continueAnimation = true; - } - } else { - this._scrollUp(choiceListScrollTop, strength, destination); - - if (choiceListScrollTop > destination) { - continueAnimation = true; - } - } - - if (continueAnimation) { - requestAnimationFrame(function () { - _this2._animateScroll(destination, direction); - }); - } - }; - - return List; -}(); - - -// CONCATENATED MODULE: ./src/scripts/components/wrapped-element.js -function wrapped_element_defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } - -function wrapped_element_createClass(Constructor, protoProps, staticProps) { if (protoProps) wrapped_element_defineProperties(Constructor.prototype, protoProps); if (staticProps) wrapped_element_defineProperties(Constructor, staticProps); return Constructor; } - - -/** - * @typedef {import('../../../types/index').Choices.passedElement} passedElement - * @typedef {import('../../../types/index').Choices.ClassNames} ClassNames - */ - -var wrapped_element_WrappedElement = -/*#__PURE__*/ -function () { - /** - * @param {{ - * element: HTMLInputElement | HTMLSelectElement, - * classNames: ClassNames, - * }} args - */ - function WrappedElement(_ref) { - var element = _ref.element, - classNames = _ref.classNames; - this.element = element; - this.classNames = classNames; - - if (!(element instanceof HTMLInputElement) && !(element instanceof HTMLSelectElement)) { - throw new TypeError('Invalid element passed'); - } - - this.isDisabled = false; - } - - var _proto = WrappedElement.prototype; - - _proto.conceal = function conceal() { - // Hide passed input - this.element.classList.add(this.classNames.input); - this.element.hidden = true; // Remove element from tab index - - this.element.tabIndex = -1; // Backup original styles if any - - var origStyle = this.element.getAttribute('style'); - - if (origStyle) { - this.element.setAttribute('data-choice-orig-style', origStyle); - } - - this.element.setAttribute('data-choice', 'active'); - }; - - _proto.reveal = function reveal() { - // Reinstate passed element - this.element.classList.remove(this.classNames.input); - this.element.hidden = false; - this.element.removeAttribute('tabindex'); // Recover original styles if any - - var origStyle = this.element.getAttribute('data-choice-orig-style'); - - if (origStyle) { - this.element.removeAttribute('data-choice-orig-style'); - this.element.setAttribute('style', origStyle); - } else { - this.element.removeAttribute('style'); - } - - this.element.removeAttribute('data-choice'); // Re-assign values - this is weird, I know - // @todo Figure out why we need to do this - - this.element.value = this.element.value; // eslint-disable-line no-self-assign - }; - - _proto.enable = function enable() { - this.element.removeAttribute('disabled'); - this.element.disabled = false; - this.isDisabled = false; - }; - - _proto.disable = function disable() { - this.element.setAttribute('disabled', ''); - this.element.disabled = true; - this.isDisabled = true; - }; - - _proto.triggerEvent = function triggerEvent(eventType, data) { - dispatchEvent(this.element, eventType, data); - }; - - wrapped_element_createClass(WrappedElement, [{ - key: "isActive", - get: function get() { - return this.element.dataset.choice === 'active'; - } - }, { - key: "dir", - get: function get() { - return this.element.dir; - } - }, { - key: "value", - get: function get() { - return this.element.value; - }, - set: function set(value) { - // you must define setter here otherwise it will be readonly property - this.element.value = value; - } - }]); - - return WrappedElement; -}(); - - -// CONCATENATED MODULE: ./src/scripts/components/wrapped-input.js -function wrapped_input_defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } - -function wrapped_input_createClass(Constructor, protoProps, staticProps) { if (protoProps) wrapped_input_defineProperties(Constructor.prototype, protoProps); if (staticProps) wrapped_input_defineProperties(Constructor, staticProps); return Constructor; } - -function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; } - - -/** - * @typedef {import('../../../types/index').Choices.ClassNames} ClassNames - * @typedef {import('../../../types/index').Choices.Item} Item - */ - -var WrappedInput = -/*#__PURE__*/ -function (_WrappedElement) { - _inheritsLoose(WrappedInput, _WrappedElement); - - /** - * @param {{ - * element: HTMLInputElement, - * classNames: ClassNames, - * delimiter: string - * }} args - */ - function WrappedInput(_ref) { - var _this; - - var element = _ref.element, - classNames = _ref.classNames, - delimiter = _ref.delimiter; - _this = _WrappedElement.call(this, { - element: element, - classNames: classNames - }) || this; - _this.delimiter = delimiter; - return _this; - } - /** - * @returns {string} - */ - - - wrapped_input_createClass(WrappedInput, [{ - key: "value", - get: function get() { - return this.element.value; - } - /** - * @param {Item[]} items - */ - , - set: function set(items) { - var itemValues = items.map(function (_ref2) { - var value = _ref2.value; - return value; - }); - var joinedValues = itemValues.join(this.delimiter); - this.element.setAttribute('value', joinedValues); - this.element.value = joinedValues; - } - }]); - - return WrappedInput; -}(wrapped_element_WrappedElement); - - -// CONCATENATED MODULE: ./src/scripts/components/wrapped-select.js -function wrapped_select_defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } - -function wrapped_select_createClass(Constructor, protoProps, staticProps) { if (protoProps) wrapped_select_defineProperties(Constructor.prototype, protoProps); if (staticProps) wrapped_select_defineProperties(Constructor, staticProps); return Constructor; } - -function wrapped_select_inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; } - - -/** - * @typedef {import('../../../types/index').Choices.ClassNames} ClassNames - * @typedef {import('../../../types/index').Choices.Item} Item - * @typedef {import('../../../types/index').Choices.Choice} Choice - */ - -var WrappedSelect = -/*#__PURE__*/ -function (_WrappedElement) { - wrapped_select_inheritsLoose(WrappedSelect, _WrappedElement); - - /** - * @param {{ - * element: HTMLSelectElement, - * classNames: ClassNames, - * delimiter: string - * template: function - * }} args - */ - function WrappedSelect(_ref) { - var _this; - - var element = _ref.element, - classNames = _ref.classNames, - template = _ref.template; - _this = _WrappedElement.call(this, { - element: element, - classNames: classNames - }) || this; - _this.template = template; - return _this; - } - - var _proto = WrappedSelect.prototype; - - /** - * @param {DocumentFragment} fragment - */ - _proto.appendDocFragment = function appendDocFragment(fragment) { - this.element.innerHTML = ''; - this.element.appendChild(fragment); - }; - - wrapped_select_createClass(WrappedSelect, [{ - key: "placeholderOption", - get: function get() { - return this.element.querySelector('option[value=""]') || // Backward compatibility layer for the non-standard placeholder attribute supported in older versions. - this.element.querySelector('option[placeholder]'); - } - /** - * @returns {Element[]} - */ - - }, { - key: "optionGroups", - get: function get() { - return Array.from(this.element.getElementsByTagName('OPTGROUP')); - } - /** - * @returns {Item[] | Choice[]} - */ - - }, { - key: "options", - get: function get() { - return Array.from(this.element.options); - } - /** - * @param {Item[] | Choice[]} options - */ - , - set: function set(options) { - var _this2 = this; - - var fragment = document.createDocumentFragment(); - - var addOptionToFragment = function addOptionToFragment(data) { - // Create a standard select option - var option = _this2.template(data); // Append it to fragment - - - fragment.appendChild(option); - }; // Add each list item to list - - - options.forEach(function (optionData) { - return addOptionToFragment(optionData); - }); - this.appendDocFragment(fragment); - } - }]); - - return WrappedSelect; -}(wrapped_element_WrappedElement); - - -// CONCATENATED MODULE: ./src/scripts/components/index.js - - - - - - - -// CONCATENATED MODULE: ./src/scripts/templates.js -/** - * Helpers to create HTML elements used by Choices - * Can be overridden by providing `callbackOnCreateTemplates` option - * @typedef {import('../../types/index').Choices.Templates} Templates - * @typedef {import('../../types/index').Choices.ClassNames} ClassNames - * @typedef {import('../../types/index').Choices.Options} Options - * @typedef {import('../../types/index').Choices.Item} Item - * @typedef {import('../../types/index').Choices.Choice} Choice - * @typedef {import('../../types/index').Choices.Group} Group - */ -var TEMPLATES = -/** @type {Templates} */ -{ - /** - * @param {Partial} classNames - * @param {"ltr" | "rtl" | "auto"} dir - * @param {boolean} isSelectElement - * @param {boolean} isSelectOneElement - * @param {boolean} searchEnabled - * @param {"select-one" | "select-multiple" | "text"} passedElementType - */ - containerOuter: function containerOuter(_ref, dir, isSelectElement, isSelectOneElement, searchEnabled, passedElementType) { - var _containerOuter = _ref.containerOuter; - var div = Object.assign(document.createElement('div'), { - className: _containerOuter - }); - div.dataset.type = passedElementType; - - if (dir) { - div.dir = dir; - } - - if (isSelectOneElement) { - div.tabIndex = 0; - } - - if (isSelectElement) { - div.setAttribute('role', searchEnabled ? 'combobox' : 'listbox'); - - if (searchEnabled) { - div.setAttribute('aria-autocomplete', 'list'); - } - } - - div.setAttribute('aria-haspopup', 'true'); - div.setAttribute('aria-expanded', 'false'); - return div; - }, - - /** - * @param {Partial} classNames - */ - containerInner: function containerInner(_ref2) { - var _containerInner = _ref2.containerInner; - return Object.assign(document.createElement('div'), { - className: _containerInner - }); - }, - - /** - * @param {Partial} classNames - * @param {boolean} isSelectOneElement - */ - itemList: function itemList(_ref3, isSelectOneElement) { - var list = _ref3.list, - listSingle = _ref3.listSingle, - listItems = _ref3.listItems; - return Object.assign(document.createElement('div'), { - className: list + " " + (isSelectOneElement ? listSingle : listItems) - }); - }, - - /** - * @param {Partial} classNames - * @param {string} value - */ - placeholder: function placeholder(_ref4, value) { - var _placeholder = _ref4.placeholder; - return Object.assign(document.createElement('div'), { - className: _placeholder, - innerHTML: value - }); - }, - - /** - * @param {Partial} classNames - * @param {Item} item - * @param {boolean} removeItemButton - */ - item: function item(_ref5, _ref6, removeItemButton) { - var _item = _ref5.item, - button = _ref5.button, - highlightedState = _ref5.highlightedState, - itemSelectable = _ref5.itemSelectable, - placeholder = _ref5.placeholder; - var id = _ref6.id, - value = _ref6.value, - label = _ref6.label, - customProperties = _ref6.customProperties, - active = _ref6.active, - disabled = _ref6.disabled, - highlighted = _ref6.highlighted, - isPlaceholder = _ref6.placeholder; - var div = Object.assign(document.createElement('div'), { - className: _item, - innerHTML: label - }); - Object.assign(div.dataset, { - item: '', - id: id, - value: value, - customProperties: customProperties - }); - - if (active) { - div.setAttribute('aria-selected', 'true'); - } - - if (disabled) { - div.setAttribute('aria-disabled', 'true'); - } - - if (isPlaceholder) { - div.classList.add(placeholder); - } - - div.classList.add(highlighted ? highlightedState : itemSelectable); - - if (removeItemButton) { - if (disabled) { - div.classList.remove(itemSelectable); - } - - div.dataset.deletable = ''; - /** @todo This MUST be localizable, not hardcoded! */ - - var REMOVE_ITEM_TEXT = 'Remove item'; - var removeButton = Object.assign(document.createElement('button'), { - type: 'button', - className: button, - innerHTML: REMOVE_ITEM_TEXT - }); - removeButton.setAttribute('aria-label', REMOVE_ITEM_TEXT + ": '" + value + "'"); - removeButton.dataset.button = ''; - div.appendChild(removeButton); - } - - return div; - }, - - /** - * @param {Partial} classNames - * @param {boolean} isSelectOneElement - */ - choiceList: function choiceList(_ref7, isSelectOneElement) { - var list = _ref7.list; - var div = Object.assign(document.createElement('div'), { - className: list - }); - - if (!isSelectOneElement) { - div.setAttribute('aria-multiselectable', 'true'); - } - - div.setAttribute('role', 'listbox'); - return div; - }, - - /** - * @param {Partial} classNames - * @param {Group} group - */ - choiceGroup: function choiceGroup(_ref8, _ref9) { - var group = _ref8.group, - groupHeading = _ref8.groupHeading, - itemDisabled = _ref8.itemDisabled; - var id = _ref9.id, - value = _ref9.value, - disabled = _ref9.disabled; - var div = Object.assign(document.createElement('div'), { - className: group + " " + (disabled ? itemDisabled : '') - }); - div.setAttribute('role', 'group'); - Object.assign(div.dataset, { - group: '', - id: id, - value: value - }); - - if (disabled) { - div.setAttribute('aria-disabled', 'true'); - } - - div.appendChild(Object.assign(document.createElement('div'), { - className: groupHeading, - innerHTML: value - })); - return div; - }, - - /** - * @param {Partial} classNames - * @param {Choice} choice - * @param {Options['itemSelectText']} selectText - */ - choice: function choice(_ref10, _ref11, selectText) { - var item = _ref10.item, - itemChoice = _ref10.itemChoice, - itemSelectable = _ref10.itemSelectable, - selectedState = _ref10.selectedState, - itemDisabled = _ref10.itemDisabled, - placeholder = _ref10.placeholder; - var id = _ref11.id, - value = _ref11.value, - label = _ref11.label, - groupId = _ref11.groupId, - elementId = _ref11.elementId, - isDisabled = _ref11.disabled, - isSelected = _ref11.selected, - isPlaceholder = _ref11.placeholder; - var div = Object.assign(document.createElement('div'), { - id: elementId, - innerHTML: label, - className: item + " " + itemChoice - }); - - if (isSelected) { - div.classList.add(selectedState); - } - - if (isPlaceholder) { - div.classList.add(placeholder); - } - - div.setAttribute('role', groupId > 0 ? 'treeitem' : 'option'); - Object.assign(div.dataset, { - choice: '', - id: id, - value: value, - selectText: selectText - }); - - if (isDisabled) { - div.classList.add(itemDisabled); - div.dataset.choiceDisabled = ''; - div.setAttribute('aria-disabled', 'true'); - } else { - div.classList.add(itemSelectable); - div.dataset.choiceSelectable = ''; - } - - return div; - }, - - /** - * @param {Partial} classNames - * @param {string} placeholderValue - */ - input: function input(_ref12, placeholderValue) { - var _input = _ref12.input, - inputCloned = _ref12.inputCloned; - var inp = Object.assign(document.createElement('input'), { - type: 'text', - className: _input + " " + inputCloned, - autocomplete: 'off', - autocapitalize: 'off', - spellcheck: false - }); - inp.setAttribute('role', 'textbox'); - inp.setAttribute('aria-autocomplete', 'list'); - inp.setAttribute('aria-label', placeholderValue); - return inp; - }, - - /** - * @param {Partial} classNames - */ - dropdown: function dropdown(_ref13) { - var list = _ref13.list, - listDropdown = _ref13.listDropdown; - var div = document.createElement('div'); - div.classList.add(list, listDropdown); - div.setAttribute('aria-expanded', 'false'); - return div; - }, - - /** - * - * @param {Partial} classNames - * @param {string} innerHTML - * @param {"no-choices" | "no-results" | ""} type - */ - notice: function notice(_ref14, innerHTML, type) { - var item = _ref14.item, - itemChoice = _ref14.itemChoice, - noResults = _ref14.noResults, - noChoices = _ref14.noChoices; - - if (type === void 0) { - type = ''; - } - - var classes = [item, itemChoice]; - - if (type === 'no-choices') { - classes.push(noChoices); - } else if (type === 'no-results') { - classes.push(noResults); - } - - return Object.assign(document.createElement('div'), { - innerHTML: innerHTML, - className: classes.join(' ') - }); - }, - - /** - * @param {Item} option - */ - option: function option(_ref15) { - var label = _ref15.label, - value = _ref15.value, - customProperties = _ref15.customProperties, - active = _ref15.active, - disabled = _ref15.disabled; - var opt = new Option(label, value, false, active); - - if (customProperties) { - opt.dataset.customProperties = customProperties; - } - - opt.disabled = disabled; - return opt; - } -}; -/* harmony default export */ var templates = (TEMPLATES); -// CONCATENATED MODULE: ./src/scripts/actions/choices.js -/** - * @typedef {import('redux').Action} Action - * @typedef {import('../../../types/index').Choices.Choice} Choice - */ - -/** - * @argument {Choice} choice - * @returns {Action & Choice} - */ - -var choices_addChoice = function addChoice(_ref) { - var value = _ref.value, - label = _ref.label, - id = _ref.id, - groupId = _ref.groupId, - disabled = _ref.disabled, - elementId = _ref.elementId, - customProperties = _ref.customProperties, - placeholder = _ref.placeholder, - keyCode = _ref.keyCode; - return { - type: ACTION_TYPES.ADD_CHOICE, - value: value, - label: label, - id: id, - groupId: groupId, - disabled: disabled, - elementId: elementId, - customProperties: customProperties, - placeholder: placeholder, - keyCode: keyCode - }; -}; -/** - * @argument {Choice[]} results - * @returns {Action & { results: Choice[] }} - */ - -var choices_filterChoices = function filterChoices(results) { - return { - type: ACTION_TYPES.FILTER_CHOICES, - results: results - }; -}; -/** - * @argument {boolean} active - * @returns {Action & { active: boolean }} - */ - -var choices_activateChoices = function activateChoices(active) { - if (active === void 0) { - active = true; - } - - return { - type: ACTION_TYPES.ACTIVATE_CHOICES, - active: active - }; -}; -/** - * @returns {Action} - */ - -var choices_clearChoices = function clearChoices() { - return { - type: ACTION_TYPES.CLEAR_CHOICES - }; -}; -// CONCATENATED MODULE: ./src/scripts/actions/items.js - -/** - * @typedef {import('redux').Action} Action - * @typedef {import('../../../types/index').Choices.Item} Item - */ - -/** - * @param {Item} item - * @returns {Action & Item} - */ - -var items_addItem = function addItem(_ref) { - var value = _ref.value, - label = _ref.label, - id = _ref.id, - choiceId = _ref.choiceId, - groupId = _ref.groupId, - customProperties = _ref.customProperties, - placeholder = _ref.placeholder, - keyCode = _ref.keyCode; - return { - type: ACTION_TYPES.ADD_ITEM, - value: value, - label: label, - id: id, - choiceId: choiceId, - groupId: groupId, - customProperties: customProperties, - placeholder: placeholder, - keyCode: keyCode - }; -}; -/** - * @param {string} id - * @param {string} choiceId - * @returns {Action & { id: string, choiceId: string }} - */ - -var items_removeItem = function removeItem(id, choiceId) { - return { - type: ACTION_TYPES.REMOVE_ITEM, - id: id, - choiceId: choiceId - }; -}; -/** - * @param {string} id - * @param {boolean} highlighted - * @returns {Action & { id: string, highlighted: boolean }} - */ - -var items_highlightItem = function highlightItem(id, highlighted) { - return { - type: ACTION_TYPES.HIGHLIGHT_ITEM, - id: id, - highlighted: highlighted - }; -}; -// CONCATENATED MODULE: ./src/scripts/actions/groups.js - -/** - * @typedef {import('redux').Action} Action - * @typedef {import('../../../types/index').Choices.Group} Group - */ - -/** - * @param {Group} group - * @returns {Action & Group} - */ - -var groups_addGroup = function addGroup(_ref) { - var value = _ref.value, - id = _ref.id, - active = _ref.active, - disabled = _ref.disabled; - return { - type: ACTION_TYPES.ADD_GROUP, - value: value, - id: id, - active: active, - disabled: disabled - }; -}; -// CONCATENATED MODULE: ./src/scripts/actions/misc.js -/** - * @typedef {import('redux').Action} Action - */ - -/** - * @returns {Action} - */ -var clearAll = function clearAll() { - return { - type: 'CLEAR_ALL' - }; -}; -/** - * @param {any} state - * @returns {Action & { state: object }} - */ - -var resetTo = function resetTo(state) { - return { - type: 'RESET_TO', - state: state - }; -}; -/** - * @param {boolean} isLoading - * @returns {Action & { isLoading: boolean }} - */ - -var setIsLoading = function setIsLoading(isLoading) { - return { - type: 'SET_IS_LOADING', - isLoading: isLoading - }; -}; -// CONCATENATED MODULE: ./src/scripts/choices.js -function choices_defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } - -function choices_createClass(Constructor, protoProps, staticProps) { if (protoProps) choices_defineProperties(Constructor.prototype, protoProps); if (staticProps) choices_defineProperties(Constructor, staticProps); return Constructor; } - - - - - - - - - - - - -/** @see {@link http://browserhacks.com/#hack-acea075d0ac6954f275a70023906050c} */ - -var IS_IE11 = '-ms-scroll-limit' in document.documentElement.style && '-ms-ime-align' in document.documentElement.style; -/** - * @typedef {import('../../types/index').Choices.Choice} Choice - * @typedef {import('../../types/index').Choices.Item} Item - * @typedef {import('../../types/index').Choices.Group} Group - * @typedef {import('../../types/index').Choices.Options} Options - */ - -/** @type {Partial} */ - -var USER_DEFAULTS = {}; -/** - * Choices - * @author Josh Johnson - */ - -var choices_Choices = -/*#__PURE__*/ -function () { - choices_createClass(Choices, null, [{ - key: "defaults", - get: function get() { - return Object.preventExtensions({ - get options() { - return USER_DEFAULTS; - }, - - get templates() { - return TEMPLATES; - } - - }); - } - /** - * @param {string | HTMLInputElement | HTMLSelectElement} element - * @param {Partial} userConfig - */ - - }]); - - function Choices(element, userConfig) { - var _this = this; - - if (element === void 0) { - element = '[data-choice]'; - } - - if (userConfig === void 0) { - userConfig = {}; - } - - /** @type {Partial} */ - this.config = cjs_default.a.all([DEFAULT_CONFIG, Choices.defaults.options, userConfig], // When merging array configs, replace with a copy of the userConfig array, - // instead of concatenating with the default array - { - arrayMerge: function arrayMerge(_, sourceArray) { - return [].concat(sourceArray); - } - }); - var invalidConfigOptions = diff(this.config, DEFAULT_CONFIG); - - if (invalidConfigOptions.length) { - console.warn('Unknown config option(s) passed', invalidConfigOptions.join(', ')); - } - - var passedElement = typeof element === 'string' ? document.querySelector(element) : element; - - if (!(passedElement instanceof HTMLInputElement || passedElement instanceof HTMLSelectElement)) { - throw TypeError('Expected one of the following types text|select-one|select-multiple'); - } - - this._isTextElement = passedElement.type === TEXT_TYPE; - this._isSelectOneElement = passedElement.type === SELECT_ONE_TYPE; - this._isSelectMultipleElement = passedElement.type === SELECT_MULTIPLE_TYPE; - this._isSelectElement = this._isSelectOneElement || this._isSelectMultipleElement; - this.config.searchEnabled = this._isSelectMultipleElement || this.config.searchEnabled; - - if (!['auto', 'always'].includes(this.config.renderSelectedChoices)) { - this.config.renderSelectedChoices = 'auto'; - } - - if (userConfig.addItemFilter && typeof userConfig.addItemFilter !== 'function') { - var re = userConfig.addItemFilter instanceof RegExp ? userConfig.addItemFilter : new RegExp(userConfig.addItemFilter); - this.config.addItemFilter = re.test.bind(re); - } - - if (this._isTextElement) { - this.passedElement = new WrappedInput({ - element: passedElement, - classNames: this.config.classNames, - delimiter: this.config.delimiter - }); - } else { - this.passedElement = new WrappedSelect({ - element: passedElement, - classNames: this.config.classNames, - template: function template(data) { - return _this._templates.option(data); - } - }); - } - - this.initialised = false; - this._store = new store_Store(); - this._initialState = {}; - this._currentState = {}; - this._prevState = {}; - this._currentValue = ''; - this._canSearch = this.config.searchEnabled; - this._isScrollingOnIe = false; - this._highlightPosition = 0; - this._wasTap = true; - this._placeholderValue = this._generatePlaceholderValue(); - this._baseId = generateId(this.passedElement.element, 'choices-'); - /** - * setting direction in cases where it's explicitly set on passedElement - * or when calculated direction is different from the document - * @type {HTMLElement['dir']} - */ - - this._direction = this.passedElement.dir; - - if (!this._direction) { - var _window$getComputedSt = window.getComputedStyle(this.passedElement.element), - elementDirection = _window$getComputedSt.direction; - - var _window$getComputedSt2 = window.getComputedStyle(document.documentElement), - documentDirection = _window$getComputedSt2.direction; - - if (elementDirection !== documentDirection) { - this._direction = elementDirection; - } - } - - this._idNames = { - itemChoice: 'item-choice' - }; // Assign preset groups from passed element - - this._presetGroups = this.passedElement.optionGroups; // Assign preset options from passed element - - this._presetOptions = this.passedElement.options; // Assign preset choices from passed object - - this._presetChoices = this.config.choices; // Assign preset items from passed object first - - this._presetItems = this.config.items; // Add any values passed from attribute - - if (this.passedElement.value) { - this._presetItems = this._presetItems.concat(this.passedElement.value.split(this.config.delimiter)); - } // Create array of choices from option elements - - - if (this.passedElement.options) { - this.passedElement.options.forEach(function (o) { - _this._presetChoices.push({ - value: o.value, - label: o.innerHTML, - selected: o.selected, - disabled: o.disabled || o.parentNode.disabled, - placeholder: o.value === '' || o.hasAttribute('placeholder'), - customProperties: o.getAttribute('data-custom-properties') - }); - }); - } - - 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._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._onAKey = this._onAKey.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); // If element has already been initialised with Choices, fail silently - - if (this.passedElement.isActive) { - if (!this.config.silent) { - console.warn('Trying to initialise Choices on element already initialised'); - } - - this.initialised = true; - return; - } // Let's go - - - this.init(); - } - - var _proto = Choices.prototype; - - _proto.init = function init() { - if (this.initialised) { - return; - } - - this._createTemplates(); - - this._createElements(); - - this._createStructure(); // Set initial state (We need to clone the state because some reducers - // modify the inner objects properties in the state) 🤢 - - - this._initialState = cloneObject(this._store.state); - - this._store.subscribe(this._render); - - this._render(); - - this._addEventListeners(); - - var shouldDisable = !this.config.addItems || this.passedElement.element.hasAttribute('disabled'); - - if (shouldDisable) { - this.disable(); - } - - this.initialised = true; - var callbackOnInit = this.config.callbackOnInit; // Run callback if it is a function - - if (callbackOnInit && typeof callbackOnInit === 'function') { - callbackOnInit.call(this); - } - }; - - _proto.destroy = function destroy() { - if (!this.initialised) { - return; - } - - this._removeEventListeners(); - - this.passedElement.reveal(); - this.containerOuter.unwrap(this.passedElement.element); - this.clearStore(); - - if (this._isSelectElement) { - this.passedElement.options = this._presetOptions; - } - - this._templates = null; - this.initialised = false; - }; - - _proto.enable = function enable() { - if (this.passedElement.isDisabled) { - this.passedElement.enable(); - } - - if (this.containerOuter.isDisabled) { - this._addEventListeners(); - - this.input.enable(); - this.containerOuter.enable(); - } - - return this; - }; - - _proto.disable = function disable() { - if (!this.passedElement.isDisabled) { - this.passedElement.disable(); - } - - if (!this.containerOuter.isDisabled) { - this._removeEventListeners(); - - this.input.disable(); - this.containerOuter.disable(); - } - - return this; - }; - - _proto.highlightItem = function highlightItem(item, runEvent) { - if (runEvent === void 0) { - runEvent = true; - } - - if (!item) { - return this; - } - - var id = item.id, - _item$groupId = item.groupId, - groupId = _item$groupId === void 0 ? -1 : _item$groupId, - _item$value = item.value, - value = _item$value === void 0 ? '' : _item$value, - _item$label = item.label, - label = _item$label === void 0 ? '' : _item$label; - var group = groupId >= 0 ? this._store.getGroupById(groupId) : null; - - this._store.dispatch(items_highlightItem(id, true)); - - if (runEvent) { - this.passedElement.triggerEvent(EVENTS.highlightItem, { - id: id, - value: value, - label: label, - groupValue: group && group.value ? group.value : null - }); - } - - return this; - }; - - _proto.unhighlightItem = function unhighlightItem(item) { - if (!item) { - return this; - } - - var id = item.id, - _item$groupId2 = item.groupId, - groupId = _item$groupId2 === void 0 ? -1 : _item$groupId2, - _item$value2 = item.value, - value = _item$value2 === void 0 ? '' : _item$value2, - _item$label2 = item.label, - label = _item$label2 === void 0 ? '' : _item$label2; - var group = groupId >= 0 ? this._store.getGroupById(groupId) : null; - - this._store.dispatch(items_highlightItem(id, false)); - - this.passedElement.triggerEvent(EVENTS.highlightItem, { - id: id, - value: value, - label: label, - groupValue: group && group.value ? group.value : null - }); - return this; - }; - - _proto.highlightAll = function highlightAll() { - var _this2 = this; - - this._store.items.forEach(function (item) { - return _this2.highlightItem(item); - }); - - return this; - }; - - _proto.unhighlightAll = function unhighlightAll() { - var _this3 = this; - - this._store.items.forEach(function (item) { - return _this3.unhighlightItem(item); - }); - - return this; - }; - - _proto.removeActiveItemsByValue = function removeActiveItemsByValue(value) { - var _this4 = this; - - this._store.activeItems.filter(function (item) { - return item.value === value; - }).forEach(function (item) { - return _this4._removeItem(item); - }); - - return this; - }; - - _proto.removeActiveItems = function removeActiveItems(excludedId) { - var _this5 = this; - - this._store.activeItems.filter(function (_ref) { - var id = _ref.id; - return id !== excludedId; - }).forEach(function (item) { - return _this5._removeItem(item); - }); - - return this; - }; - - _proto.removeHighlightedItems = function removeHighlightedItems(runEvent) { - var _this6 = this; - - if (runEvent === void 0) { - runEvent = false; - } - - this._store.highlightedActiveItems.forEach(function (item) { - _this6._removeItem(item); // If this action was performed by the user - // trigger the event - - - if (runEvent) { - _this6._triggerChange(item.value); - } - }); - - return this; - }; - - _proto.showDropdown = function showDropdown(preventInputFocus) { - var _this7 = this; - - if (this.dropdown.isActive) { - return this; - } - - requestAnimationFrame(function () { - _this7.dropdown.show(); - - _this7.containerOuter.open(_this7.dropdown.distanceFromTopWindow); - - if (!preventInputFocus && _this7._canSearch) { - _this7.input.focus(); - } - - _this7.passedElement.triggerEvent(EVENTS.showDropdown, {}); - }); - return this; - }; - - _proto.hideDropdown = function hideDropdown(preventInputBlur) { - var _this8 = this; - - if (!this.dropdown.isActive) { - return this; - } - - requestAnimationFrame(function () { - _this8.dropdown.hide(); - - _this8.containerOuter.close(); - - if (!preventInputBlur && _this8._canSearch) { - _this8.input.removeActiveDescendant(); - - _this8.input.blur(); - } - - _this8.passedElement.triggerEvent(EVENTS.hideDropdown, {}); - }); - return this; - }; - - _proto.getValue = function getValue(valueOnly) { - if (valueOnly === void 0) { - valueOnly = false; - } - - var values = this._store.activeItems.reduce(function (selectedItems, item) { - var itemValue = valueOnly ? item.value : item; - selectedItems.push(itemValue); - return selectedItems; - }, []); - - return this._isSelectOneElement ? values[0] : values; - } - /** - * @param {string[] | import('../../types/index').Choices.Item[]} items - */ - ; - - _proto.setValue = function setValue(items) { - var _this9 = this; - - if (!this.initialised) { - return this; - } - - items.forEach(function (value) { - return _this9._setChoiceOrItem(value); - }); - return this; - }; - - _proto.setChoiceByValue = function setChoiceByValue(value) { - var _this10 = this; - - if (!this.initialised || this._isTextElement) { - return this; - } // If only one value has been passed, convert to array - - - var choiceValue = Array.isArray(value) ? value : [value]; // Loop through each value and - - choiceValue.forEach(function (val) { - return _this10._findAndSelectChoiceByValue(val); - }); - return this; - } - /** - * Set choices of select input via an array of objects (or function that returns array of object or promise of it), - * a value field name and a label field name. - * This behaves the same as passing items via the choices option but can be called after initialising Choices. - * This can also be used to add groups of choices (see example 2); Optionally pass a true `replaceChoices` value to remove any existing choices. - * Optionally pass a `customProperties` object to add additional data to your choices (useful when searching/filtering etc). - * - * **Input types affected:** select-one, select-multiple - * - * @template {Choice[] | ((instance: Choices) => object[] | Promise)} T - * @param {T} [choicesArrayOrFetcher] - * @param {string} [value = 'value'] - name of `value` field - * @param {string} [label = 'label'] - name of 'label' field - * @param {boolean} [replaceChoices = false] - whether to replace of add choices - * @returns {this | Promise} - * - * @example - * ```js - * const example = new Choices(element); - * - * example.setChoices([ - * {value: 'One', label: 'Label One', disabled: true}, - * {value: 'Two', label: 'Label Two', selected: true}, - * {value: 'Three', label: 'Label Three'}, - * ], 'value', 'label', false); - * ``` - * - * @example - * ```js - * const example = new Choices(element); - * - * example.setChoices(async () => { - * try { - * const items = await fetch('/items'); - * return items.json() - * } catch(err) { - * console.error(err) - * } - * }); - * ``` - * - * @example - * ```js - * const example = new Choices(element); - * - * example.setChoices([{ - * label: 'Group one', - * id: 1, - * disabled: false, - * choices: [ - * {value: 'Child One', label: 'Child One', selected: true}, - * {value: 'Child Two', label: 'Child Two', disabled: true}, - * {value: 'Child Three', label: 'Child Three'}, - * ] - * }, - * { - * label: 'Group two', - * id: 2, - * disabled: false, - * choices: [ - * {value: 'Child Four', label: 'Child Four', disabled: true}, - * {value: 'Child Five', label: 'Child Five'}, - * {value: 'Child Six', label: 'Child Six', customProperties: { - * description: 'Custom description about child six', - * random: 'Another random custom property' - * }}, - * ] - * }], 'value', 'label', false); - * ``` - */ - ; - - _proto.setChoices = function setChoices(choicesArrayOrFetcher, value, label, replaceChoices) { - var _this11 = this; - - if (choicesArrayOrFetcher === void 0) { - choicesArrayOrFetcher = []; - } - - if (value === void 0) { - value = 'value'; - } - - if (label === void 0) { - label = 'label'; - } - - if (replaceChoices === void 0) { - replaceChoices = false; - } - - if (!this.initialised) { - throw new ReferenceError("setChoices was called on a non-initialized instance of Choices"); - } - - if (!this._isSelectElement) { - throw new TypeError("setChoices can't be used with INPUT based Choices"); - } - - if (typeof value !== 'string' || !value) { - throw new TypeError("value parameter must be a name of 'value' field in passed objects"); - } // Clear choices if needed - - - if (replaceChoices) { - this.clearChoices(); - } - - if (typeof choicesArrayOrFetcher === 'function') { - // it's a choices fetcher function - var fetcher = choicesArrayOrFetcher(this); - - if (typeof Promise === 'function' && fetcher instanceof Promise) { - // that's a promise - // eslint-disable-next-line compat/compat - return new Promise(function (resolve) { - return requestAnimationFrame(resolve); - }).then(function () { - return _this11._handleLoadingState(true); - }).then(function () { - return fetcher; - }).then(function (data) { - return _this11.setChoices(data, value, label, replaceChoices); - }).catch(function (err) { - if (!_this11.config.silent) { - console.error(err); - } - }).then(function () { - return _this11._handleLoadingState(false); - }).then(function () { - return _this11; - }); - } // function returned something else than promise, let's check if it's an array of choices - - - if (!Array.isArray(fetcher)) { - throw new TypeError(".setChoices first argument function must return either array of choices or Promise, got: " + typeof fetcher); - } // recursion with results, it's sync and choices were cleared already - - - return this.setChoices(fetcher, value, label, false); - } - - if (!Array.isArray(choicesArrayOrFetcher)) { - throw new TypeError(".setChoices must be called either with array of choices with a function resulting into Promise of array of choices"); - } - - this.containerOuter.removeLoadingState(); - - this._startLoading(); - - choicesArrayOrFetcher.forEach(function (groupOrChoice) { - if (groupOrChoice.choices) { - _this11._addGroup({ - id: parseInt(groupOrChoice.id, 10) || null, - group: groupOrChoice, - valueKey: value, - labelKey: label - }); - } else { - _this11._addChoice({ - value: groupOrChoice[value], - label: groupOrChoice[label], - isSelected: groupOrChoice.selected, - isDisabled: groupOrChoice.disabled, - customProperties: groupOrChoice.customProperties, - placeholder: groupOrChoice.placeholder - }); - } - }); - - this._stopLoading(); - - return this; - }; - - _proto.clearChoices = function clearChoices() { - this._store.dispatch(choices_clearChoices()); - - return this; - }; - - _proto.clearStore = function clearStore() { - this._store.dispatch(clearAll()); - - return this; - }; - - _proto.clearInput = function clearInput() { - var shouldSetInputWidth = !this._isSelectOneElement; - this.input.clear(shouldSetInputWidth); - - if (!this._isTextElement && this._canSearch) { - this._isSearching = false; - - this._store.dispatch(choices_activateChoices(true)); - } - - return this; - }; - - _proto._render = function _render() { - if (this._store.isLoading()) { - return; - } - - this._currentState = this._store.state; - var stateChanged = this._currentState.choices !== this._prevState.choices || this._currentState.groups !== this._prevState.groups || this._currentState.items !== this._prevState.items; - var shouldRenderChoices = this._isSelectElement; - var shouldRenderItems = this._currentState.items !== this._prevState.items; - - if (!stateChanged) { - return; - } - - if (shouldRenderChoices) { - this._renderChoices(); - } - - if (shouldRenderItems) { - this._renderItems(); - } - - this._prevState = this._currentState; - }; - - _proto._renderChoices = function _renderChoices() { - var _this12 = this; - - var _this$_store = this._store, - activeGroups = _this$_store.activeGroups, - activeChoices = _this$_store.activeChoices; - var choiceListFragment = document.createDocumentFragment(); - this.choiceList.clear(); - - if (this.config.resetScrollPosition) { - requestAnimationFrame(function () { - return _this12.choiceList.scrollToTop(); - }); - } // If we have grouped options - - - if (activeGroups.length >= 1 && !this._isSearching) { - // If we have a placeholder choice along with groups - var activePlaceholders = activeChoices.filter(function (activeChoice) { - return activeChoice.placeholder === true && activeChoice.groupId === -1; - }); - - if (activePlaceholders.length >= 1) { - choiceListFragment = this._createChoicesFragment(activePlaceholders, choiceListFragment); - } - - choiceListFragment = this._createGroupsFragment(activeGroups, activeChoices, choiceListFragment); - } else if (activeChoices.length >= 1) { - choiceListFragment = this._createChoicesFragment(activeChoices, choiceListFragment); - } // If we have choices to show - - - if (choiceListFragment.childNodes && choiceListFragment.childNodes.length > 0) { - var activeItems = this._store.activeItems; - - var canAddItem = this._canAddItem(activeItems, this.input.value); // ...and we can select them - - - if (canAddItem.response) { - // ...append them and highlight the first choice - this.choiceList.append(choiceListFragment); - - this._highlightChoice(); - } else { - // ...otherwise show a notice - this.choiceList.append(this._getTemplate('notice', canAddItem.notice)); - } - } else { - // Otherwise show a notice - var dropdownItem; - var notice; - - if (this._isSearching) { - notice = typeof this.config.noResultsText === 'function' ? this.config.noResultsText() : this.config.noResultsText; - dropdownItem = this._getTemplate('notice', notice, 'no-results'); - } else { - notice = typeof this.config.noChoicesText === 'function' ? this.config.noChoicesText() : this.config.noChoicesText; - dropdownItem = this._getTemplate('notice', notice, 'no-choices'); - } - - this.choiceList.append(dropdownItem); - } - }; - - _proto._renderItems = function _renderItems() { - var activeItems = this._store.activeItems || []; - this.itemList.clear(); // Create a fragment to store our list items - // (so we don't have to update the DOM for each item) - - var itemListFragment = this._createItemsFragment(activeItems); // If we have items to add, append them - - - if (itemListFragment.childNodes) { - this.itemList.append(itemListFragment); - } - }; - - _proto._createGroupsFragment = function _createGroupsFragment(groups, choices, fragment) { - var _this13 = this; - - if (fragment === void 0) { - fragment = document.createDocumentFragment(); - } - - var getGroupChoices = function getGroupChoices(group) { - return choices.filter(function (choice) { - if (_this13._isSelectOneElement) { - return choice.groupId === group.id; - } - - return choice.groupId === group.id && (_this13.config.renderSelectedChoices === 'always' || !choice.selected); - }); - }; // If sorting is enabled, filter groups - - - if (this.config.shouldSort) { - groups.sort(this.config.sorter); - } - - groups.forEach(function (group) { - var groupChoices = getGroupChoices(group); - - if (groupChoices.length >= 1) { - var dropdownGroup = _this13._getTemplate('choiceGroup', group); - - fragment.appendChild(dropdownGroup); - - _this13._createChoicesFragment(groupChoices, fragment, true); - } - }); - return fragment; - }; - - _proto._createChoicesFragment = function _createChoicesFragment(choices, fragment, withinGroup) { - var _this14 = this; - - if (fragment === void 0) { - fragment = document.createDocumentFragment(); - } - - if (withinGroup === void 0) { - withinGroup = false; - } - - // Create a fragment to store our list items (so we don't have to update the DOM for each item) - var _this$config = this.config, - renderSelectedChoices = _this$config.renderSelectedChoices, - searchResultLimit = _this$config.searchResultLimit, - renderChoiceLimit = _this$config.renderChoiceLimit; - var filter = this._isSearching ? sortByScore : this.config.sorter; - - var appendChoice = function appendChoice(choice) { - var shouldRender = renderSelectedChoices === 'auto' ? _this14._isSelectOneElement || !choice.selected : true; - - if (shouldRender) { - var dropdownItem = _this14._getTemplate('choice', choice, _this14.config.itemSelectText); - - fragment.appendChild(dropdownItem); - } - }; - - var rendererableChoices = choices; - - if (renderSelectedChoices === 'auto' && !this._isSelectOneElement) { - rendererableChoices = choices.filter(function (choice) { - return !choice.selected; - }); - } // Split array into placeholders and "normal" choices - - - var _rendererableChoices$ = rendererableChoices.reduce(function (acc, choice) { - if (choice.placeholder) { - acc.placeholderChoices.push(choice); - } else { - acc.normalChoices.push(choice); - } - - return acc; - }, { - placeholderChoices: [], - normalChoices: [] - }), - placeholderChoices = _rendererableChoices$.placeholderChoices, - normalChoices = _rendererableChoices$.normalChoices; // If sorting is enabled or the user is searching, filter choices - - - if (this.config.shouldSort || this._isSearching) { - normalChoices.sort(filter); - } - - var choiceLimit = rendererableChoices.length; // Prepend placeholeder - - var sortedChoices = this._isSelectOneElement ? [].concat(placeholderChoices, normalChoices) : normalChoices; - - if (this._isSearching) { - choiceLimit = searchResultLimit; - } else if (renderChoiceLimit && renderChoiceLimit > 0 && !withinGroup) { - choiceLimit = renderChoiceLimit; - } // Add each choice to dropdown within range - - - for (var i = 0; i < choiceLimit; i += 1) { - if (sortedChoices[i]) { - appendChoice(sortedChoices[i]); - } - } - - return fragment; - }; - - _proto._createItemsFragment = function _createItemsFragment(items, fragment) { - var _this15 = this; - - if (fragment === void 0) { - fragment = document.createDocumentFragment(); - } - - // Create fragment to add elements to - var _this$config2 = this.config, - shouldSortItems = _this$config2.shouldSortItems, - sorter = _this$config2.sorter, - removeItemButton = _this$config2.removeItemButton; // If sorting is enabled, filter items - - if (shouldSortItems && !this._isSelectOneElement) { - items.sort(sorter); - } - - if (this._isTextElement) { - // Update the value of the hidden input - this.passedElement.value = items; - } else { - // Update the options of the hidden input - this.passedElement.options = items; - } - - var addItemToFragment = function addItemToFragment(item) { - // Create new list element - var listItem = _this15._getTemplate('item', item, removeItemButton); // Append it to list - - - fragment.appendChild(listItem); - }; // Add each list item to list - - - items.forEach(addItemToFragment); - return fragment; - }; - - _proto._triggerChange = function _triggerChange(value) { - if (value === undefined || value === null) { - return; - } - - this.passedElement.triggerEvent(EVENTS.change, { - value: value - }); - }; - - _proto._selectPlaceholderChoice = function _selectPlaceholderChoice() { - var placeholderChoice = this._store.placeholderChoice; - - if (placeholderChoice) { - this._addItem({ - value: placeholderChoice.value, - label: placeholderChoice.label, - choiceId: placeholderChoice.id, - groupId: placeholderChoice.groupId, - placeholder: placeholderChoice.placeholder - }); - - this._triggerChange(placeholderChoice.value); - } - }; - - _proto._handleButtonAction = function _handleButtonAction(activeItems, element) { - if (!activeItems || !element || !this.config.removeItems || !this.config.removeItemButton) { - return; - } - - var itemId = element.parentNode.getAttribute('data-id'); - var itemToRemove = activeItems.find(function (item) { - return item.id === parseInt(itemId, 10); - }); // Remove item associated with button - - this._removeItem(itemToRemove); - - this._triggerChange(itemToRemove.value); - - if (this._isSelectOneElement) { - this._selectPlaceholderChoice(); - } - }; - - _proto._handleItemAction = function _handleItemAction(activeItems, element, hasShiftKey) { - var _this16 = this; - - if (hasShiftKey === void 0) { - hasShiftKey = false; - } - - if (!activeItems || !element || !this.config.removeItems || this._isSelectOneElement) { - return; - } - - var passedId = element.getAttribute('data-id'); // We only want to select one item with a click - // so we deselect any items that aren't the target - // unless shift is being pressed - - activeItems.forEach(function (item) { - if (item.id === parseInt(passedId, 10) && !item.highlighted) { - _this16.highlightItem(item); - } else if (!hasShiftKey && item.highlighted) { - _this16.unhighlightItem(item); - } - }); // Focus input as without focus, a user cannot do anything with a - // highlighted item - - this.input.focus(); - }; - - _proto._handleChoiceAction = function _handleChoiceAction(activeItems, element) { - if (!activeItems || !element) { - return; - } // If we are clicking on an option - - - var id = element.dataset.id; - - var choice = this._store.getChoiceById(id); - - if (!choice) { - return; - } - - var passedKeyCode = activeItems[0] && activeItems[0].keyCode ? activeItems[0].keyCode : null; - var hasActiveDropdown = this.dropdown.isActive; // Update choice keyCode - - choice.keyCode = passedKeyCode; - this.passedElement.triggerEvent(EVENTS.choice, { - choice: choice - }); - - if (!choice.selected && !choice.disabled) { - var canAddItem = this._canAddItem(activeItems, choice.value); - - if (canAddItem.response) { - this._addItem({ - value: choice.value, - label: choice.label, - choiceId: choice.id, - groupId: choice.groupId, - customProperties: choice.customProperties, - placeholder: choice.placeholder, - keyCode: choice.keyCode - }); - - this._triggerChange(choice.value); - } - } - - this.clearInput(); // We want to close the dropdown if we are dealing with a single select box - - if (hasActiveDropdown && this._isSelectOneElement) { - this.hideDropdown(true); - this.containerOuter.focus(); - } - }; - - _proto._handleBackspace = function _handleBackspace(activeItems) { - if (!this.config.removeItems || !activeItems) { - return; - } - - var lastItem = activeItems[activeItems.length - 1]; - var hasHighlightedItems = activeItems.some(function (item) { - return item.highlighted; - }); // If editing the last item is allowed and there are not other selected items, - // we can edit the item value. Otherwise if we can remove items, remove all selected items - - if (this.config.editItems && !hasHighlightedItems && lastItem) { - this.input.value = lastItem.value; - this.input.setWidth(); - - this._removeItem(lastItem); - - this._triggerChange(lastItem.value); - } else { - if (!hasHighlightedItems) { - // Highlight last item if none already highlighted - this.highlightItem(lastItem, false); - } - - this.removeHighlightedItems(true); - } - }; - - _proto._startLoading = function _startLoading() { - this._store.dispatch(setIsLoading(true)); - }; - - _proto._stopLoading = function _stopLoading() { - this._store.dispatch(setIsLoading(false)); - }; - - _proto._handleLoadingState = function _handleLoadingState(setLoading) { - if (setLoading === void 0) { - setLoading = true; - } - - var placeholderItem = this.itemList.getChild("." + this.config.classNames.placeholder); - - if (setLoading) { - this.disable(); - this.containerOuter.addLoadingState(); - - if (this._isSelectOneElement) { - if (!placeholderItem) { - placeholderItem = this._getTemplate('placeholder', this.config.loadingText); - this.itemList.append(placeholderItem); - } else { - placeholderItem.innerHTML = this.config.loadingText; - } - } else { - this.input.placeholder = this.config.loadingText; - } - } else { - this.enable(); - this.containerOuter.removeLoadingState(); - - if (this._isSelectOneElement) { - placeholderItem.innerHTML = this._placeholderValue || ''; - } else { - this.input.placeholder = this._placeholderValue || ''; - } - } - }; - - _proto._handleSearch = function _handleSearch(value) { - if (!value || !this.input.isFocussed) { - return; - } - - var choices = this._store.choices; - var _this$config3 = this.config, - searchFloor = _this$config3.searchFloor, - searchChoices = _this$config3.searchChoices; - var hasUnactiveChoices = choices.some(function (option) { - return !option.active; - }); // Check that we have a value to search and the input was an alphanumeric character - - if (value && value.length >= searchFloor) { - var resultCount = searchChoices ? this._searchChoices(value) : 0; // Trigger search event - - this.passedElement.triggerEvent(EVENTS.search, { - value: value, - resultCount: resultCount - }); - } else if (hasUnactiveChoices) { - // Otherwise reset choices to active - this._isSearching = false; - - this._store.dispatch(choices_activateChoices(true)); - } - }; - - _proto._canAddItem = function _canAddItem(activeItems, value) { - var canAddItem = true; - var notice = typeof this.config.addItemText === 'function' ? this.config.addItemText(value) : this.config.addItemText; - - if (!this._isSelectOneElement) { - var isDuplicateValue = existsInArray(activeItems, value); - - if (this.config.maxItemCount > 0 && this.config.maxItemCount <= activeItems.length) { - // If there is a max entry limit and we have reached that limit - // don't update - canAddItem = false; - notice = typeof this.config.maxItemText === 'function' ? this.config.maxItemText(this.config.maxItemCount) : this.config.maxItemText; - } - - if (!this.config.duplicateItemsAllowed && isDuplicateValue && canAddItem) { - canAddItem = false; - notice = typeof this.config.uniqueItemText === 'function' ? this.config.uniqueItemText(value) : this.config.uniqueItemText; - } - - if (this._isTextElement && this.config.addItems && canAddItem && typeof this.config.addItemFilter === 'function' && !this.config.addItemFilter(value)) { - canAddItem = false; - notice = typeof this.config.customAddItemText === 'function' ? this.config.customAddItemText(value) : this.config.customAddItemText; - } - } - - return { - response: canAddItem, - notice: notice - }; - }; - - _proto._searchChoices = function _searchChoices(value) { - var newValue = typeof value === 'string' ? value.trim() : value; - var currentValue = typeof this._currentValue === 'string' ? this._currentValue.trim() : this._currentValue; - - if (newValue.length < 1 && newValue === currentValue + " ") { - return 0; - } // If new value matches the desired length and is not the same as the current value with a space - - - var haystack = this._store.searchableChoices; - var needle = newValue; - var keys = [].concat(this.config.searchFields); - var options = Object.assign(this.config.fuseOptions, { - keys: keys - }); - var fuse = new fuse_default.a(haystack, options); - var results = fuse.search(needle); - this._currentValue = newValue; - this._highlightPosition = 0; - this._isSearching = true; - - this._store.dispatch(choices_filterChoices(results)); - - return results.length; - }; - - _proto._addEventListeners = function _addEventListeners() { - var _document = document, - documentElement = _document.documentElement; // capture events - can cancel event processing or propagation - - documentElement.addEventListener('touchend', this._onTouchEnd, true); - this.containerOuter.element.addEventListener('keydown', this._onKeyDown, true); - this.containerOuter.element.addEventListener('mousedown', this._onMouseDown, true); // passive events - doesn't call `preventDefault` or `stopPropagation` - - documentElement.addEventListener('click', this._onClick, { - passive: true - }); - documentElement.addEventListener('touchmove', this._onTouchMove, { - passive: true - }); - this.dropdown.element.addEventListener('mouseover', this._onMouseOver, { - passive: true - }); - - if (this._isSelectOneElement) { - this.containerOuter.element.addEventListener('focus', this._onFocus, { - passive: true - }); - this.containerOuter.element.addEventListener('blur', this._onBlur, { - passive: true - }); - } - - this.input.element.addEventListener('keyup', this._onKeyUp, { - passive: true - }); - this.input.element.addEventListener('focus', this._onFocus, { - passive: true - }); - this.input.element.addEventListener('blur', this._onBlur, { - passive: true - }); - - if (this.input.element.form) { - this.input.element.form.addEventListener('reset', this._onFormReset, { - passive: true - }); - } - - this.input.addEventListeners(); - }; - - _proto._removeEventListeners = function _removeEventListeners() { - var _document2 = document, - documentElement = _document2.documentElement; - documentElement.removeEventListener('touchend', this._onTouchEnd, true); - this.containerOuter.element.removeEventListener('keydown', this._onKeyDown, true); - this.containerOuter.element.removeEventListener('mousedown', this._onMouseDown, true); - documentElement.removeEventListener('click', this._onClick); - documentElement.removeEventListener('touchmove', this._onTouchMove); - this.dropdown.element.removeEventListener('mouseover', this._onMouseOver); - - if (this._isSelectOneElement) { - this.containerOuter.element.removeEventListener('focus', this._onFocus); - this.containerOuter.element.removeEventListener('blur', this._onBlur); - } - - this.input.element.removeEventListener('keyup', this._onKeyUp); - this.input.element.removeEventListener('focus', this._onFocus); - this.input.element.removeEventListener('blur', this._onBlur); - - if (this.input.element.form) { - this.input.element.form.removeEventListener('reset', this._onFormReset); - } - - this.input.removeEventListeners(); - } - /** - * @param {KeyboardEvent} event - */ - ; - - _proto._onKeyDown = function _onKeyDown(event) { - var _keyDownActions; - - var target = event.target, - keyCode = event.keyCode, - ctrlKey = event.ctrlKey, - metaKey = event.metaKey; - var activeItems = this._store.activeItems; - var hasFocusedInput = this.input.isFocussed; - var hasActiveDropdown = this.dropdown.isActive; - var hasItems = this.itemList.hasChildren(); - var keyString = String.fromCharCode(keyCode); - var BACK_KEY = KEY_CODES.BACK_KEY, - DELETE_KEY = KEY_CODES.DELETE_KEY, - ENTER_KEY = KEY_CODES.ENTER_KEY, - A_KEY = KEY_CODES.A_KEY, - ESC_KEY = KEY_CODES.ESC_KEY, - UP_KEY = KEY_CODES.UP_KEY, - DOWN_KEY = KEY_CODES.DOWN_KEY, - PAGE_UP_KEY = KEY_CODES.PAGE_UP_KEY, - PAGE_DOWN_KEY = KEY_CODES.PAGE_DOWN_KEY; - var hasCtrlDownKeyPressed = ctrlKey || metaKey; // If a user is typing and the dropdown is not active - - if (!this._isTextElement && /[a-zA-Z0-9-_ ]/.test(keyString)) { - this.showDropdown(); - } // Map keys to key actions - - - var keyDownActions = (_keyDownActions = {}, _keyDownActions[A_KEY] = this._onAKey, _keyDownActions[ENTER_KEY] = this._onEnterKey, _keyDownActions[ESC_KEY] = this._onEscapeKey, _keyDownActions[UP_KEY] = this._onDirectionKey, _keyDownActions[PAGE_UP_KEY] = this._onDirectionKey, _keyDownActions[DOWN_KEY] = this._onDirectionKey, _keyDownActions[PAGE_DOWN_KEY] = this._onDirectionKey, _keyDownActions[DELETE_KEY] = this._onDeleteKey, _keyDownActions[BACK_KEY] = this._onDeleteKey, _keyDownActions); // If keycode has a function, run it - - if (keyDownActions[keyCode]) { - keyDownActions[keyCode]({ - event: event, - target: target, - keyCode: keyCode, - metaKey: metaKey, - activeItems: activeItems, - hasFocusedInput: hasFocusedInput, - hasActiveDropdown: hasActiveDropdown, - hasItems: hasItems, - hasCtrlDownKeyPressed: hasCtrlDownKeyPressed - }); - } - }; - - _proto._onKeyUp = function _onKeyUp(_ref2) { - var target = _ref2.target, - keyCode = _ref2.keyCode; - var value = this.input.value; - var activeItems = this._store.activeItems; - - var canAddItem = this._canAddItem(activeItems, value); - - var backKey = KEY_CODES.BACK_KEY, - deleteKey = KEY_CODES.DELETE_KEY; // We are typing into a text input and have a value, we want to show a dropdown - // notice. Otherwise hide the dropdown - - if (this._isTextElement) { - var canShowDropdownNotice = canAddItem.notice && value; - - if (canShowDropdownNotice) { - var dropdownItem = this._getTemplate('notice', canAddItem.notice); - - this.dropdown.element.innerHTML = dropdownItem.outerHTML; - this.showDropdown(true); - } else { - this.hideDropdown(true); - } - } else { - var userHasRemovedValue = (keyCode === backKey || keyCode === deleteKey) && !target.value; - var canReactivateChoices = !this._isTextElement && this._isSearching; - var canSearch = this._canSearch && canAddItem.response; - - if (userHasRemovedValue && canReactivateChoices) { - this._isSearching = false; - - this._store.dispatch(choices_activateChoices(true)); - } else if (canSearch) { - this._handleSearch(this.input.value); - } - } - - this._canSearch = this.config.searchEnabled; - }; - - _proto._onAKey = function _onAKey(_ref3) { - var hasItems = _ref3.hasItems, - hasCtrlDownKeyPressed = _ref3.hasCtrlDownKeyPressed; - - // If CTRL + A or CMD + A have been pressed and there are items to select - if (hasCtrlDownKeyPressed && hasItems) { - this._canSearch = false; - var shouldHightlightAll = this.config.removeItems && !this.input.value && this.input.element === document.activeElement; - - if (shouldHightlightAll) { - this.highlightAll(); - } - } - }; - - _proto._onEnterKey = function _onEnterKey(_ref4) { - var event = _ref4.event, - target = _ref4.target, - activeItems = _ref4.activeItems, - hasActiveDropdown = _ref4.hasActiveDropdown; - var enterKey = KEY_CODES.ENTER_KEY; - var targetWasButton = target.hasAttribute('data-button'); - - if (this._isTextElement && target.value) { - var value = this.input.value; - - var canAddItem = this._canAddItem(activeItems, value); - - if (canAddItem.response) { - this.hideDropdown(true); - - this._addItem({ - value: value - }); - - this._triggerChange(value); - - this.clearInput(); - } - } - - if (targetWasButton) { - this._handleButtonAction(activeItems, target); - - event.preventDefault(); - } - - if (hasActiveDropdown) { - var highlightedChoice = this.dropdown.getChild("." + this.config.classNames.highlightedState); - - if (highlightedChoice) { - // add enter keyCode value - if (activeItems[0]) { - activeItems[0].keyCode = enterKey; // eslint-disable-line no-param-reassign - } - - this._handleChoiceAction(activeItems, highlightedChoice); - } - - event.preventDefault(); - } else if (this._isSelectOneElement) { - this.showDropdown(); - event.preventDefault(); - } - }; - - _proto._onEscapeKey = function _onEscapeKey(_ref5) { - var hasActiveDropdown = _ref5.hasActiveDropdown; - - if (hasActiveDropdown) { - this.hideDropdown(true); - this.containerOuter.focus(); - } - }; - - _proto._onDirectionKey = function _onDirectionKey(_ref6) { - var event = _ref6.event, - hasActiveDropdown = _ref6.hasActiveDropdown, - keyCode = _ref6.keyCode, - metaKey = _ref6.metaKey; - var downKey = KEY_CODES.DOWN_KEY, - pageUpKey = KEY_CODES.PAGE_UP_KEY, - pageDownKey = KEY_CODES.PAGE_DOWN_KEY; // If up or down key is pressed, traverse through options - - if (hasActiveDropdown || this._isSelectOneElement) { - this.showDropdown(); - this._canSearch = false; - var directionInt = keyCode === downKey || keyCode === pageDownKey ? 1 : -1; - var skipKey = metaKey || keyCode === pageDownKey || keyCode === pageUpKey; - var selectableChoiceIdentifier = '[data-choice-selectable]'; - var nextEl; - - if (skipKey) { - if (directionInt > 0) { - nextEl = this.dropdown.element.querySelector(selectableChoiceIdentifier + ":last-of-type"); - } else { - nextEl = this.dropdown.element.querySelector(selectableChoiceIdentifier); - } - } else { - var currentEl = this.dropdown.element.querySelector("." + this.config.classNames.highlightedState); - - if (currentEl) { - nextEl = getAdjacentEl(currentEl, selectableChoiceIdentifier, directionInt); - } else { - nextEl = this.dropdown.element.querySelector(selectableChoiceIdentifier); - } - } - - if (nextEl) { - // We prevent default to stop the cursor moving - // when pressing the arrow - if (!isScrolledIntoView(nextEl, this.choiceList.element, directionInt)) { - this.choiceList.scrollToChildElement(nextEl, directionInt); - } - - this._highlightChoice(nextEl); - } // Prevent default to maintain cursor position whilst - // traversing dropdown options - - - event.preventDefault(); - } - }; - - _proto._onDeleteKey = function _onDeleteKey(_ref7) { - var event = _ref7.event, - target = _ref7.target, - hasFocusedInput = _ref7.hasFocusedInput, - activeItems = _ref7.activeItems; - - // If backspace or delete key is pressed and the input has no value - if (hasFocusedInput && !target.value && !this._isSelectOneElement) { - this._handleBackspace(activeItems); - - event.preventDefault(); - } - }; - - _proto._onTouchMove = function _onTouchMove() { - if (this._wasTap) { - this._wasTap = false; - } - }; - - _proto._onTouchEnd = function _onTouchEnd(event) { - var _ref8 = event || event.touches[0], - target = _ref8.target; - - var touchWasWithinContainer = this._wasTap && this.containerOuter.element.contains(target); - - if (touchWasWithinContainer) { - var containerWasExactTarget = target === this.containerOuter.element || target === this.containerInner.element; - - if (containerWasExactTarget) { - if (this._isTextElement) { - this.input.focus(); - } else if (this._isSelectMultipleElement) { - this.showDropdown(); - } - } // Prevents focus event firing - - - event.stopPropagation(); - } - - this._wasTap = true; - } - /** - * Handles mousedown event in capture mode for containetOuter.element - * @param {MouseEvent} event - */ - ; - - _proto._onMouseDown = function _onMouseDown(event) { - var target = event.target; - - if (!(target instanceof HTMLElement)) { - return; - } // If we have our mouse down on the scrollbar and are on IE11... - - - if (IS_IE11 && this.choiceList.element.contains(target)) { - // check if click was on a scrollbar area - var firstChoice = - /** @type {HTMLElement} */ - this.choiceList.element.firstElementChild; - var isOnScrollbar = this._direction === 'ltr' ? event.offsetX >= firstChoice.offsetWidth : event.offsetX < firstChoice.offsetLeft; - this._isScrollingOnIe = isOnScrollbar; - } - - if (target === this.input.element) { - return; - } - - var item = target.closest('[data-button],[data-item],[data-choice]'); - - if (item instanceof HTMLElement) { - var hasShiftKey = event.shiftKey; - var activeItems = this._store.activeItems; - var dataset = item.dataset; - - if ('button' in dataset) { - this._handleButtonAction(activeItems, item); - } else if ('item' in dataset) { - this._handleItemAction(activeItems, item, hasShiftKey); - } else if ('choice' in dataset) { - this._handleChoiceAction(activeItems, item); - } - } - - event.preventDefault(); - } - /** - * Handles mouseover event over this.dropdown - * @param {MouseEvent} event - */ - ; - - _proto._onMouseOver = function _onMouseOver(_ref9) { - var target = _ref9.target; - - if (target instanceof HTMLElement && 'choice' in target.dataset) { - this._highlightChoice(target); - } - }; - - _proto._onClick = function _onClick(_ref10) { - var target = _ref10.target; - var clickWasWithinContainer = this.containerOuter.element.contains(target); - - if (clickWasWithinContainer) { - if (!this.dropdown.isActive && !this.containerOuter.isDisabled) { - if (this._isTextElement) { - if (document.activeElement !== this.input.element) { - this.input.focus(); - } - } else { - this.showDropdown(); - this.containerOuter.focus(); - } - } else if (this._isSelectOneElement && target !== this.input.element && !this.dropdown.element.contains(target)) { - this.hideDropdown(); - } - } else { - var hasHighlightedItems = this._store.highlightedActiveItems.length > 0; - - if (hasHighlightedItems) { - this.unhighlightAll(); - } - - this.containerOuter.removeFocusState(); - this.hideDropdown(true); - } - }; - - _proto._onFocus = function _onFocus(_ref11) { - var _this17 = this, - _focusActions; - - var target = _ref11.target; - var focusWasWithinContainer = this.containerOuter.element.contains(target); - - if (!focusWasWithinContainer) { - return; - } - - var focusActions = (_focusActions = {}, _focusActions[TEXT_TYPE] = function () { - if (target === _this17.input.element) { - _this17.containerOuter.addFocusState(); - } - }, _focusActions[SELECT_ONE_TYPE] = function () { - _this17.containerOuter.addFocusState(); - - if (target === _this17.input.element) { - _this17.showDropdown(true); - } - }, _focusActions[SELECT_MULTIPLE_TYPE] = function () { - if (target === _this17.input.element) { - _this17.showDropdown(true); // If element is a select box, the focused element is the container and the dropdown - // isn't already open, focus and show dropdown - - - _this17.containerOuter.addFocusState(); - } - }, _focusActions); - focusActions[this.passedElement.element.type](); - }; - - _proto._onBlur = function _onBlur(_ref12) { - var _this18 = this; - - var target = _ref12.target; - var blurWasWithinContainer = this.containerOuter.element.contains(target); - - if (blurWasWithinContainer && !this._isScrollingOnIe) { - var _blurActions; - - var activeItems = this._store.activeItems; - var hasHighlightedItems = activeItems.some(function (item) { - return item.highlighted; - }); - var blurActions = (_blurActions = {}, _blurActions[TEXT_TYPE] = function () { - if (target === _this18.input.element) { - _this18.containerOuter.removeFocusState(); - - if (hasHighlightedItems) { - _this18.unhighlightAll(); - } - - _this18.hideDropdown(true); - } - }, _blurActions[SELECT_ONE_TYPE] = function () { - _this18.containerOuter.removeFocusState(); - - if (target === _this18.input.element || target === _this18.containerOuter.element && !_this18._canSearch) { - _this18.hideDropdown(true); - } - }, _blurActions[SELECT_MULTIPLE_TYPE] = function () { - if (target === _this18.input.element) { - _this18.containerOuter.removeFocusState(); - - _this18.hideDropdown(true); - - if (hasHighlightedItems) { - _this18.unhighlightAll(); - } - } - }, _blurActions); - blurActions[this.passedElement.element.type](); - } else { - // On IE11, clicking the scollbar blurs our input and thus - // closes the dropdown. To stop this, we refocus our input - // if we know we are on IE *and* are scrolling. - this._isScrollingOnIe = false; - this.input.element.focus(); - } - }; - - _proto._onFormReset = function _onFormReset() { - this._store.dispatch(resetTo(this._initialState)); - }; - - _proto._highlightChoice = function _highlightChoice(el) { - var _this19 = this; - - if (el === void 0) { - el = null; - } - - var choices = Array.from(this.dropdown.element.querySelectorAll('[data-choice-selectable]')); - - if (!choices.length) { - return; - } - - var passedEl = el; - var highlightedChoices = Array.from(this.dropdown.element.querySelectorAll("." + this.config.classNames.highlightedState)); // Remove any highlighted choices - - highlightedChoices.forEach(function (choice) { - choice.classList.remove(_this19.config.classNames.highlightedState); - choice.setAttribute('aria-selected', 'false'); - }); - - if (passedEl) { - this._highlightPosition = choices.indexOf(passedEl); - } else { - // Highlight choice based on last known highlight location - if (choices.length > this._highlightPosition) { - // If we have an option to highlight - passedEl = choices[this._highlightPosition]; - } else { - // Otherwise highlight the option before - passedEl = choices[choices.length - 1]; - } - - if (!passedEl) { - passedEl = choices[0]; - } - } - - passedEl.classList.add(this.config.classNames.highlightedState); - passedEl.setAttribute('aria-selected', 'true'); - this.passedElement.triggerEvent(EVENTS.highlightChoice, { - el: passedEl - }); - - if (this.dropdown.isActive) { - // IE11 ignores aria-label and blocks virtual keyboard - // if aria-activedescendant is set without a dropdown - this.input.setActiveDescendant(passedEl.id); - this.containerOuter.setActiveDescendant(passedEl.id); - } - }; - - _proto._addItem = function _addItem(_ref13) { - var value = _ref13.value, - _ref13$label = _ref13.label, - label = _ref13$label === void 0 ? null : _ref13$label, - _ref13$choiceId = _ref13.choiceId, - choiceId = _ref13$choiceId === void 0 ? -1 : _ref13$choiceId, - _ref13$groupId = _ref13.groupId, - groupId = _ref13$groupId === void 0 ? -1 : _ref13$groupId, - _ref13$customProperti = _ref13.customProperties, - customProperties = _ref13$customProperti === void 0 ? null : _ref13$customProperti, - _ref13$placeholder = _ref13.placeholder, - placeholder = _ref13$placeholder === void 0 ? false : _ref13$placeholder, - _ref13$keyCode = _ref13.keyCode, - keyCode = _ref13$keyCode === void 0 ? null : _ref13$keyCode; - var passedValue = typeof value === 'string' ? value.trim() : value; - var passedKeyCode = keyCode; - var passedCustomProperties = customProperties; - var items = this._store.items; - var passedLabel = label || passedValue; - var passedOptionId = choiceId || -1; - var group = groupId >= 0 ? this._store.getGroupById(groupId) : null; - var id = items ? items.length + 1 : 1; // If a prepended value has been passed, prepend it - - if (this.config.prependValue) { - passedValue = this.config.prependValue + passedValue.toString(); - } // If an appended value has been passed, append it - - - if (this.config.appendValue) { - passedValue += this.config.appendValue.toString(); - } - - this._store.dispatch(items_addItem({ - value: passedValue, - label: passedLabel, - id: id, - choiceId: passedOptionId, - groupId: groupId, - customProperties: customProperties, - placeholder: placeholder, - keyCode: passedKeyCode - })); - - if (this._isSelectOneElement) { - this.removeActiveItems(id); - } // Trigger change event - - - this.passedElement.triggerEvent(EVENTS.addItem, { - id: id, - value: passedValue, - label: passedLabel, - customProperties: passedCustomProperties, - groupValue: group && group.value ? group.value : undefined, - keyCode: passedKeyCode - }); - return this; - }; - - _proto._removeItem = function _removeItem(item) { - if (!item || !isType('Object', item)) { - return this; - } - - var id = item.id, - value = item.value, - label = item.label, - choiceId = item.choiceId, - groupId = item.groupId; - var group = groupId >= 0 ? this._store.getGroupById(groupId) : null; - - this._store.dispatch(items_removeItem(id, choiceId)); - - if (group && group.value) { - this.passedElement.triggerEvent(EVENTS.removeItem, { - id: id, - value: value, - label: label, - groupValue: group.value - }); - } else { - this.passedElement.triggerEvent(EVENTS.removeItem, { - id: id, - value: value, - label: label - }); - } - - return this; - }; - - _proto._addChoice = function _addChoice(_ref14) { - var value = _ref14.value, - _ref14$label = _ref14.label, - label = _ref14$label === void 0 ? null : _ref14$label, - _ref14$isSelected = _ref14.isSelected, - isSelected = _ref14$isSelected === void 0 ? false : _ref14$isSelected, - _ref14$isDisabled = _ref14.isDisabled, - isDisabled = _ref14$isDisabled === void 0 ? false : _ref14$isDisabled, - _ref14$groupId = _ref14.groupId, - groupId = _ref14$groupId === void 0 ? -1 : _ref14$groupId, - _ref14$customProperti = _ref14.customProperties, - customProperties = _ref14$customProperti === void 0 ? null : _ref14$customProperti, - _ref14$placeholder = _ref14.placeholder, - placeholder = _ref14$placeholder === void 0 ? false : _ref14$placeholder, - _ref14$keyCode = _ref14.keyCode, - keyCode = _ref14$keyCode === void 0 ? null : _ref14$keyCode; - - if (typeof value === 'undefined' || value === null) { - return; - } // Generate unique id - - - var choices = this._store.choices; - var choiceLabel = label || value; - var choiceId = choices ? choices.length + 1 : 1; - var choiceElementId = this._baseId + "-" + this._idNames.itemChoice + "-" + choiceId; - - this._store.dispatch(choices_addChoice({ - id: choiceId, - groupId: groupId, - elementId: choiceElementId, - value: value, - label: choiceLabel, - disabled: isDisabled, - customProperties: customProperties, - placeholder: placeholder, - keyCode: keyCode - })); - - if (isSelected) { - this._addItem({ - value: value, - label: choiceLabel, - choiceId: choiceId, - customProperties: customProperties, - placeholder: placeholder, - keyCode: keyCode - }); - } - }; - - _proto._addGroup = function _addGroup(_ref15) { - var _this20 = this; - - var group = _ref15.group, - id = _ref15.id, - _ref15$valueKey = _ref15.valueKey, - valueKey = _ref15$valueKey === void 0 ? 'value' : _ref15$valueKey, - _ref15$labelKey = _ref15.labelKey, - labelKey = _ref15$labelKey === void 0 ? 'label' : _ref15$labelKey; - var groupChoices = isType('Object', group) ? group.choices : Array.from(group.getElementsByTagName('OPTION')); - var groupId = id || Math.floor(new Date().valueOf() * Math.random()); - var isDisabled = group.disabled ? group.disabled : false; - - if (groupChoices) { - this._store.dispatch(groups_addGroup({ - value: group.label, - id: groupId, - active: true, - disabled: isDisabled - })); - - var addGroupChoices = function addGroupChoices(choice) { - var isOptDisabled = choice.disabled || choice.parentNode && choice.parentNode.disabled; - - _this20._addChoice({ - value: choice[valueKey], - label: isType('Object', choice) ? choice[labelKey] : choice.innerHTML, - isSelected: choice.selected, - isDisabled: isOptDisabled, - groupId: groupId, - customProperties: choice.customProperties, - placeholder: choice.placeholder - }); - }; - - groupChoices.forEach(addGroupChoices); - } else { - this._store.dispatch(groups_addGroup({ - value: group.label, - id: group.id, - active: false, - disabled: group.disabled - })); - } - }; - - _proto._getTemplate = function _getTemplate(template) { - var _this$_templates$temp; - - if (!template) { - return null; - } - - var classNames = this.config.classNames; - - for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { - args[_key - 1] = arguments[_key]; - } - - return (_this$_templates$temp = this._templates[template]).call.apply(_this$_templates$temp, [this, classNames].concat(args)); - }; - - _proto._createTemplates = function _createTemplates() { - var callbackOnCreateTemplates = this.config.callbackOnCreateTemplates; - var userTemplates = {}; - - if (callbackOnCreateTemplates && typeof callbackOnCreateTemplates === 'function') { - userTemplates = callbackOnCreateTemplates.call(this, strToEl); - } - - this._templates = cjs_default()(TEMPLATES, userTemplates); - }; - - _proto._createElements = function _createElements() { - this.containerOuter = new container_Container({ - element: this._getTemplate('containerOuter', this._direction, this._isSelectElement, this._isSelectOneElement, this.config.searchEnabled, this.passedElement.element.type), - classNames: this.config.classNames, - type: this.passedElement.element.type, - position: this.config.position - }); - this.containerInner = new container_Container({ - element: this._getTemplate('containerInner'), - classNames: this.config.classNames, - type: this.passedElement.element.type, - position: this.config.position - }); - this.input = new input_Input({ - element: this._getTemplate('input', this._placeholderValue), - classNames: this.config.classNames, - type: this.passedElement.element.type, - preventPaste: !this.config.paste - }); - this.choiceList = new list_List({ - element: this._getTemplate('choiceList', this._isSelectOneElement) - }); - this.itemList = new list_List({ - element: this._getTemplate('itemList', this._isSelectOneElement) - }); - this.dropdown = new Dropdown({ - element: this._getTemplate('dropdown'), - classNames: this.config.classNames, - type: this.passedElement.element.type - }); - }; - - _proto._createStructure = function _createStructure() { - // Hide original element - this.passedElement.conceal(); // Wrap input in container preserving DOM ordering - - this.containerInner.wrap(this.passedElement.element); // Wrapper inner container with outer container - - this.containerOuter.wrap(this.containerInner.element); - - if (this._isSelectOneElement) { - this.input.placeholder = this.config.searchPlaceholderValue || ''; - } else if (this._placeholderValue) { - this.input.placeholder = this._placeholderValue; - this.input.setWidth(); - } - - this.containerOuter.element.appendChild(this.containerInner.element); - this.containerOuter.element.appendChild(this.dropdown.element); - this.containerInner.element.appendChild(this.itemList.element); - - if (!this._isTextElement) { - this.dropdown.element.appendChild(this.choiceList.element); - } - - if (!this._isSelectOneElement) { - this.containerInner.element.appendChild(this.input.element); - } else if (this.config.searchEnabled) { - this.dropdown.element.insertBefore(this.input.element, this.dropdown.element.firstChild); - } - - if (this._isSelectElement) { - this._highlightPosition = 0; - this._isSearching = false; - - this._startLoading(); - - if (this._presetGroups.length) { - this._addPredefinedGroups(this._presetGroups); - } else { - this._addPredefinedChoices(this._presetChoices); - } - - this._stopLoading(); - } - - if (this._isTextElement) { - this._addPredefinedItems(this._presetItems); - } - }; - - _proto._addPredefinedGroups = function _addPredefinedGroups(groups) { - var _this21 = this; - - // If we have a placeholder option - var placeholderChoice = this.passedElement.placeholderOption; - - if (placeholderChoice && placeholderChoice.parentNode.tagName === 'SELECT') { - this._addChoice({ - value: placeholderChoice.value, - label: placeholderChoice.innerHTML, - isSelected: placeholderChoice.selected, - isDisabled: placeholderChoice.disabled, - placeholder: true - }); - } - - groups.forEach(function (group) { - return _this21._addGroup({ - group: group, - id: group.id || null - }); - }); - }; - - _proto._addPredefinedChoices = function _addPredefinedChoices(choices) { - var _this22 = this; - - // If sorting is enabled or the user is searching, filter choices - if (this.config.shouldSort) { - choices.sort(this.config.sorter); - } - - var hasSelectedChoice = choices.some(function (choice) { - return choice.selected; - }); - var firstEnabledChoiceIndex = choices.findIndex(function (choice) { - return choice.disabled === undefined || !choice.disabled; - }); - choices.forEach(function (choice, index) { - var value = choice.value, - label = choice.label, - customProperties = choice.customProperties, - placeholder = choice.placeholder; - - if (_this22._isSelectElement) { - // If the choice is actually a group - if (choice.choices) { - _this22._addGroup({ - group: choice, - id: choice.id || null - }); - } else { - /** - * If there is a selected choice already or the choice is not the first in - * the array, add each choice normally. - * - * Otherwise we pre-select the first enabled choice in the array ("select-one" only) - */ - var shouldPreselect = _this22._isSelectOneElement && !hasSelectedChoice && index === firstEnabledChoiceIndex; - var isSelected = shouldPreselect ? true : choice.selected; - var isDisabled = choice.disabled; - - _this22._addChoice({ - value: value, - label: label, - isSelected: isSelected, - isDisabled: isDisabled, - customProperties: customProperties, - placeholder: placeholder - }); - } - } else { - _this22._addChoice({ - value: value, - label: label, - isSelected: choice.selected, - isDisabled: choice.disabled, - customProperties: customProperties, - placeholder: placeholder - }); - } - }); - } - /** - * @param {Item[]} items - */ - ; - - _proto._addPredefinedItems = function _addPredefinedItems(items) { - var _this23 = this; - - items.forEach(function (item) { - if (typeof item === 'object' && item.value) { - _this23._addItem({ - value: item.value, - label: item.label, - choiceId: item.id, - customProperties: item.customProperties, - placeholder: item.placeholder - }); - } - - if (typeof item === 'string') { - _this23._addItem({ - value: item - }); - } - }); - }; - - _proto._setChoiceOrItem = function _setChoiceOrItem(item) { - var _this24 = this; - - var itemType = getType(item).toLowerCase(); - var handleType = { - object: function object() { - if (!item.value) { - return; - } // If we are dealing with a select input, we need to create an option first - // that is then selected. For text inputs we can just add items normally. - - - if (!_this24._isTextElement) { - _this24._addChoice({ - value: item.value, - label: item.label, - isSelected: true, - isDisabled: false, - customProperties: item.customProperties, - placeholder: item.placeholder - }); - } else { - _this24._addItem({ - value: item.value, - label: item.label, - choiceId: item.id, - customProperties: item.customProperties, - placeholder: item.placeholder - }); - } - }, - string: function string() { - if (!_this24._isTextElement) { - _this24._addChoice({ - value: item, - label: item, - isSelected: true, - isDisabled: false - }); - } else { - _this24._addItem({ - value: item - }); - } - } - }; - handleType[itemType](); - }; - - _proto._findAndSelectChoiceByValue = function _findAndSelectChoiceByValue(val) { - var _this25 = this; - - var choices = this._store.choices; // Check 'value' property exists and the choice isn't already selected - - var foundChoice = choices.find(function (choice) { - return _this25.config.valueComparer(choice.value, val); - }); - - if (foundChoice && !foundChoice.selected) { - this._addItem({ - value: foundChoice.value, - label: foundChoice.label, - choiceId: foundChoice.id, - groupId: foundChoice.groupId, - customProperties: foundChoice.customProperties, - placeholder: foundChoice.placeholder, - keyCode: foundChoice.keyCode - }); - } - }; - - _proto._generatePlaceholderValue = function _generatePlaceholderValue() { - if (this._isSelectElement) { - var placeholderOption = this.passedElement.placeholderOption; - return placeholderOption ? placeholderOption.text : false; - } - - var _this$config4 = this.config, - placeholder = _this$config4.placeholder, - placeholderValue = _this$config4.placeholderValue; - var dataset = this.passedElement.element.dataset; - - if (placeholder) { - if (placeholderValue) { - return placeholderValue; - } - - if (dataset.placeholder) { - return dataset.placeholder; - } - } - - return false; - }; - - return Choices; -}(); - -/* harmony default export */ var scripts_choices = __webpack_exports__["default"] = (choices_Choices); /***/ }) -/******/ ])["default"]; + +/******/ }); +/************************************************************************/ +/******/ // The module cache +/******/ var __webpack_module_cache__ = {}; +/******/ +/******/ // The require function +/******/ function __webpack_require__(moduleId) { +/******/ // Check if module is in cache +/******/ var cachedModule = __webpack_module_cache__[moduleId]; +/******/ if (cachedModule !== undefined) { +/******/ return cachedModule.exports; +/******/ } +/******/ // Create a new module (and put it into the cache) +/******/ var module = __webpack_module_cache__[moduleId] = { +/******/ // no module.id needed +/******/ // no module.loaded needed +/******/ exports: {} +/******/ }; +/******/ +/******/ // Execute the module function +/******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__); +/******/ +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } +/******/ +/************************************************************************/ +/******/ /* webpack/runtime/compat get default export */ +/******/ !function() { +/******/ // getDefaultExport function for compatibility with non-harmony modules +/******/ __webpack_require__.n = function(module) { +/******/ var getter = module && module.__esModule ? +/******/ function() { return module['default']; } : +/******/ function() { return module; }; +/******/ __webpack_require__.d(getter, { a: getter }); +/******/ return getter; +/******/ }; +/******/ }(); +/******/ +/******/ /* webpack/runtime/define property getters */ +/******/ !function() { +/******/ // define getter functions for harmony exports +/******/ __webpack_require__.d = function(exports, definition) { +/******/ for(var key in definition) { +/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { +/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); +/******/ } +/******/ } +/******/ }; +/******/ }(); +/******/ +/******/ /* webpack/runtime/hasOwnProperty shorthand */ +/******/ !function() { +/******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); } +/******/ }(); +/******/ +/******/ /* webpack/runtime/make namespace object */ +/******/ !function() { +/******/ // define __esModule on exports +/******/ __webpack_require__.r = function(exports) { +/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { +/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); +/******/ } +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ }(); +/******/ +/************************************************************************/ +var __webpack_exports__ = {}; +// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk. +!function() { +/* harmony import */ var _scripts_choices__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(373); +/* harmony import */ var _scripts_choices__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_scripts_choices__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _scripts_interfaces__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(187); +/* harmony import */ var _scripts_interfaces__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_scripts_interfaces__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var _scripts_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(883); +/* harmony import */ var _scripts_defaults__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(789); +/* harmony import */ var _scripts_templates__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(686); + + + + + + + +/* harmony default export */ __webpack_exports__["default"] = ((_scripts_choices__WEBPACK_IMPORTED_MODULE_0___default())); + +}(); +__webpack_exports__ = __webpack_exports__["default"]; +/******/ return __webpack_exports__; +/******/ })() +; }); \ No newline at end of file diff --git a/assets/scripts/choices.min.js b/assets/scripts/choices.min.js index c3eabfa..c97e39f 100644 --- a/assets/scripts/choices.min.js +++ b/assets/scripts/choices.min.js @@ -1,11 +1,2 @@ -/*! choices.js v9.0.1 | © 2019 Josh Johnson | https://github.com/jshjohnson/Choices#readme */ -window.Choices=function(e){var t={};function i(n){if(t[n])return t[n].exports;var s=t[n]={i:n,l:!1,exports:{}};return e[n].call(s.exports,s,s.exports,i),s.l=!0,s.exports}return i.m=e,i.c=t,i.d=function(e,t,n){i.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},i.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.t=function(e,t){if(1&t&&(e=i(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var s in e)i.d(n,s,function(t){return e[t]}.bind(null,s));return n},i.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(t,"a",t),t},i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i.p="/public/assets/scripts/",i(i.s=4)}([function(e,t,i){"use strict";var n=function(e){return function(e){return!!e&&"object"==typeof e}(e)&&!function(e){var t=Object.prototype.toString.call(e);return"[object RegExp]"===t||"[object Date]"===t||function(e){return e.$$typeof===s}(e)}(e)};var s="function"==typeof Symbol&&Symbol.for?Symbol.for("react.element"):60103;function r(e,t){return!1!==t.clone&&t.isMergeableObject(e)?l((i=e,Array.isArray(i)?[]:{}),e,t):e;var i}function o(e,t,i){return e.concat(t).map((function(e){return r(e,i)}))}function a(e){return Object.keys(e).concat(function(e){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e).filter((function(t){return e.propertyIsEnumerable(t)})):[]}(e))}function c(e,t,i){var n={};return i.isMergeableObject(e)&&a(e).forEach((function(t){n[t]=r(e[t],i)})),a(t).forEach((function(s){(function(e,t){try{return t in e&&!(Object.hasOwnProperty.call(e,t)&&Object.propertyIsEnumerable.call(e,t))}catch(e){return!1}})(e,s)||(i.isMergeableObject(t[s])&&e[s]?n[s]=function(e,t){if(!t.customMerge)return l;var i=t.customMerge(e);return"function"==typeof i?i:l}(s,i)(e[s],t[s],i):n[s]=r(t[s],i))})),n}function l(e,t,i){(i=i||{}).arrayMerge=i.arrayMerge||o,i.isMergeableObject=i.isMergeableObject||n,i.cloneUnlessOtherwiseSpecified=r;var s=Array.isArray(t);return s===Array.isArray(e)?s?i.arrayMerge(e,t,i):c(e,t,i):r(t,i)}l.all=function(e,t){if(!Array.isArray(e))throw new Error("first argument should be an array");return e.reduce((function(e,i){return l(e,i,t)}),{})};var h=l;e.exports=h},function(e,t,i){"use strict";(function(e,n){var s,r=i(3);s="undefined"!=typeof self?self:"undefined"!=typeof window?window:void 0!==e?e:n;var o=Object(r.a)(s);t.a=o}).call(this,i(5),i(6)(e))},function(e,t,i){ -/*! - * Fuse.js v3.4.5 - Lightweight fuzzy-search (http://fusejs.io) - * - * Copyright (c) 2012-2017 Kirollos Risk (http://kiro.me) - * All Rights Reserved. Apache Software License 2.0 - * - * http://www.apache.org/licenses/LICENSE-2.0 - */ -e.exports=function(e){var t={};function i(n){if(t[n])return t[n].exports;var s=t[n]={i:n,l:!1,exports:{}};return e[n].call(s.exports,s,s.exports,i),s.l=!0,s.exports}return i.m=e,i.c=t,i.d=function(e,t,n){i.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},i.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.t=function(e,t){if(1&t&&(e=i(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var s in e)i.d(n,s,function(t){return e[t]}.bind(null,s));return n},i.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(t,"a",t),t},i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i.p="",i(i.s=1)}([function(e,t){e.exports=function(e){return Array.isArray?Array.isArray(e):"[object Array]"===Object.prototype.toString.call(e)}},function(e,t,i){function n(e){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function s(e,t){for(var i=0;i1&&void 0!==arguments[1]?arguments[1]:{limit:!1};this._log('---------\nSearch pattern: "'.concat(e,'"'));var i=this._prepareSearchers(e),n=i.tokenSearchers,s=i.fullSearcher,r=this._search(n,s),o=r.weights,a=r.results;return this._computeScore(o,a),this.options.shouldSort&&this._sort(a),t.limit&&"number"==typeof t.limit&&(a=a.slice(0,t.limit)),this._format(a)}},{key:"_prepareSearchers",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=[];if(this.options.tokenize)for(var i=e.split(this.options.tokenSeparator),n=0,s=i.length;n0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1?arguments[1]:void 0,i=this.list,n={},s=[];if("string"==typeof i[0]){for(var r=0,o=i.length;r1)throw new Error("Key weight has to be > 0 and <= 1");p=p.name}else a[p]={weight:1};this._analyze({key:p,value:this.options.getFn(h,p),record:h,index:c},{resultMap:n,results:s,tokenSearchers:e,fullSearcher:t})}return{weights:a,results:s}}},{key:"_analyze",value:function(e,t){var i=e.key,n=e.arrayIndex,s=void 0===n?-1:n,r=e.value,o=e.record,c=e.index,l=t.tokenSearchers,h=void 0===l?[]:l,u=t.fullSearcher,d=void 0===u?[]:u,p=t.resultMap,m=void 0===p?{}:p,f=t.results,v=void 0===f?[]:f;if(null!=r){var g=!1,_=-1,b=0;if("string"==typeof r){this._log("\nKey: ".concat(""===i?"-":i));var y=d.search(r);if(this._log('Full text: "'.concat(r,'", score: ').concat(y.score)),this.options.tokenize){for(var E=r.split(this.options.tokenSeparator),I=[],S=0;S-1&&(P=(P+_)/2),this._log("Score average:",P);var D=!this.options.tokenize||!this.options.matchAllTokens||b>=h.length;if(this._log("\nCheck Matches: ".concat(D)),(g||y.isMatch)&&D){var M=m[c];M?M.output.push({key:i,arrayIndex:s,value:r,score:P,matchedIndices:y.matchedIndices}):(m[c]={item:o,output:[{key:i,arrayIndex:s,value:r,score:P,matchedIndices:y.matchedIndices}]},v.push(m[c]))}}else if(a(r))for(var N=0,F=r.length;N-1&&(o.arrayIndex=r.arrayIndex),t.matches.push(o)}}})),this.options.includeScore&&s.push((function(e,t){t.score=e.score}));for(var r=0,o=e.length;ri)return s(e,this.pattern,n);var o=this.options,a=o.location,c=o.distance,l=o.threshold,h=o.findAllMatches,u=o.minMatchCharLength;return r(e,this.pattern,this.patternAlphabet,{location:a,distance:c,threshold:l,findAllMatches:h,minMatchCharLength:u})}}])&&n(t.prototype,i),e}();e.exports=a},function(e,t){var i=/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g;e.exports=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:/ +/g,s=new RegExp(t.replace(i,"\\$&").replace(n,"|")),r=e.match(s),o=!!r,a=[];if(o)for(var c=0,l=r.length;c=P;N-=1){var F=N-1,j=i[e.charAt(F)];if(j&&(E[F]=1),M[N]=(M[N+1]<<1|1)&j,0!==T&&(M[N]|=(O[N+1]|O[N])<<1|1|O[N+1]),M[N]&L&&(C=n(t,{errors:T,currentLocation:F,expectedLocation:v,distance:l}))<=_){if(_=C,(b=F)<=v)break;P=Math.max(1,2*v-b)}}if(n(t,{errors:T+1,currentLocation:v,expectedLocation:v,distance:l})>_)break;O=M}return{isMatch:b>=0,score:0===C?.001:C,matchedIndices:s(E,f)}}},function(e,t){e.exports=function(e,t){var i=t.errors,n=void 0===i?0:i,s=t.currentLocation,r=void 0===s?0:s,o=t.expectedLocation,a=void 0===o?0:o,c=t.distance,l=void 0===c?100:c,h=n/e.length,u=Math.abs(a-r);return l?h+u/l:u?1:h}},function(e,t){e.exports=function(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,i=[],n=-1,s=-1,r=0,o=e.length;r=t&&i.push([n,s]),n=-1)}return e[r-1]&&r-n>=t&&i.push([n,r-1]),i}},function(e,t){e.exports=function(e){for(var t={},i=e.length,n=0;n/g,"&rt;").replace(/-1?e.map((function(e){var i=e;return i.id===parseInt(t.choiceId,10)&&(i.selected=!0),i})):e;case"REMOVE_ITEM":return t.choiceId>-1?e.map((function(e){var i=e;return i.id===parseInt(t.choiceId,10)&&(i.selected=!1),i})):e;case"FILTER_CHOICES":return e.map((function(e){var i=e;return i.active=t.results.some((function(e){var t=e.item,n=e.score;return t.id===i.id&&(i.score=n,!0)})),i}));case"ACTIVATE_CHOICES":return e.map((function(e){var i=e;return i.active=t.active,i}));case"CLEAR_CHOICES":return f;default:return e}},general:_}),T=function(e,t){var i=e;if("CLEAR_ALL"===t.type)i=void 0;else if("RESET_TO"===t.type)return C(t.state);return L(i,t)};function x(e,t){for(var i=0;i"'+S(e)+'"'},maxItemText:function(e){return"Only "+e+" values can be added"},valueComparer:function(e,t){return e===t},fuseOptions:{includeScore:!0},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",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",noResults:"has-no-results",noChoices:"has-no-choices"}},N="showDropdown",F="hideDropdown",j="change",K="choice",R="search",H="addItem",B="removeItem",V="highlightItem",G="highlightChoice",q="ADD_CHOICE",U="FILTER_CHOICES",z="ACTIVATE_CHOICES",W="CLEAR_CHOICES",X="ADD_GROUP",$="ADD_ITEM",J="REMOVE_ITEM",Y="HIGHLIGHT_ITEM",Z=46,Q=8,ee=13,te=65,ie=27,ne=38,se=40,re=33,oe=34,ae="text",ce="select-one",le="select-multiple",he=function(){function e(e){var t=e.element,i=e.type,n=e.classNames,s=e.position;this.element=t,this.classNames=n,this.type=i,this.position=s,this.isOpen=!1,this.isFlipped=!1,this.isFocussed=!1,this.isDisabled=!1,this.isLoading=!1,this._onFocus=this._onFocus.bind(this),this._onBlur=this._onBlur.bind(this)}var t=e.prototype;return t.addEventListeners=function(){this.element.addEventListener("focus",this._onFocus),this.element.addEventListener("blur",this._onBlur)},t.removeEventListeners=function(){this.element.removeEventListener("focus",this._onFocus),this.element.removeEventListener("blur",this._onBlur)},t.shouldFlip=function(e){if("number"!=typeof e)return!1;var t=!1;return"auto"===this.position?t=!window.matchMedia("(min-height: "+(e+1)+"px)").matches:"top"===this.position&&(t=!0),t},t.setActiveDescendant=function(e){this.element.setAttribute("aria-activedescendant",e)},t.removeActiveDescendant=function(){this.element.removeAttribute("aria-activedescendant")},t.open=function(e){this.element.classList.add(this.classNames.openState),this.element.setAttribute("aria-expanded","true"),this.isOpen=!0,this.shouldFlip(e)&&(this.element.classList.add(this.classNames.flippedState),this.isFlipped=!0)},t.close=function(){this.element.classList.remove(this.classNames.openState),this.element.setAttribute("aria-expanded","false"),this.removeActiveDescendant(),this.isOpen=!1,this.isFlipped&&(this.element.classList.remove(this.classNames.flippedState),this.isFlipped=!1)},t.focus=function(){this.isFocussed||this.element.focus()},t.addFocusState=function(){this.element.classList.add(this.classNames.focusState)},t.removeFocusState=function(){this.element.classList.remove(this.classNames.focusState)},t.enable=function(){this.element.classList.remove(this.classNames.disabledState),this.element.removeAttribute("aria-disabled"),this.type===ce&&this.element.setAttribute("tabindex","0"),this.isDisabled=!1},t.disable=function(){this.element.classList.add(this.classNames.disabledState),this.element.setAttribute("aria-disabled","true"),this.type===ce&&this.element.setAttribute("tabindex","-1"),this.isDisabled=!0},t.wrap=function(e){!function(e,t){void 0===t&&(t=document.createElement("div")),e.nextSibling?e.parentNode.insertBefore(t,e.nextSibling):e.parentNode.appendChild(t),t.appendChild(e)}(e,this.element)},t.unwrap=function(e){this.element.parentNode.insertBefore(e,this.element),this.element.parentNode.removeChild(this.element)},t.addLoadingState=function(){this.element.classList.add(this.classNames.loadingState),this.element.setAttribute("aria-busy","true"),this.isLoading=!0},t.removeLoadingState=function(){this.element.classList.remove(this.classNames.loadingState),this.element.removeAttribute("aria-busy"),this.isLoading=!1},t._onFocus=function(){this.isFocussed=!0},t._onBlur=function(){this.isFocussed=!1},e}();function ue(e,t){for(var i=0;i0?this.element.scrollTop+o-s:e.offsetTop;requestAnimationFrame((function(){i._animateScroll(a,t)}))}},t._scrollDown=function(e,t,i){var n=(i-e)/t,s=n>1?n:1;this.element.scrollTop=e+s},t._scrollUp=function(e,t,i){var n=(e-i)/t,s=n>1?n:1;this.element.scrollTop=e-s},t._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 me(e,t){for(var i=0;i0?"treeitem":"option"),Object.assign(g.dataset,{choice:"",id:l,value:h,selectText:i}),m?(g.classList.add(a),g.dataset.choiceDisabled="",g.setAttribute("aria-disabled","true")):(g.classList.add(r),g.dataset.choiceSelectable=""),g},input:function(e,t){var i=e.input,n=e.inputCloned,s=Object.assign(document.createElement("input"),{type:"text",className:i+" "+n,autocomplete:"off",autocapitalize:"off",spellcheck:!1});return s.setAttribute("role","textbox"),s.setAttribute("aria-autocomplete","list"),s.setAttribute("aria-label",t),s},dropdown:function(e){var t=e.list,i=e.listDropdown,n=document.createElement("div");return n.classList.add(t,i),n.setAttribute("aria-expanded","false"),n},notice:function(e,t,i){var n=e.item,s=e.itemChoice,r=e.noResults,o=e.noChoices;void 0===i&&(i="");var a=[n,s];return"no-choices"===i?a.push(o):"no-results"===i&&a.push(r),Object.assign(document.createElement("div"),{innerHTML:t,className:a.join(" ")})},option:function(e){var t=e.label,i=e.value,n=e.customProperties,s=e.active,r=e.disabled,o=new Option(t,i,!1,s);return n&&(o.dataset.customProperties=n),o.disabled=r,o}},Ee=function(e){return void 0===e&&(e=!0),{type:z,active:e}},Ie=function(e,t){return{type:Y,id:e,highlighted:t}},Se=function(e){var t=e.value,i=e.id,n=e.active,s=e.disabled;return{type:X,value:t,id:i,active:n,disabled:s}},we=function(e){return{type:"SET_IS_LOADING",isLoading:e}};function Oe(e,t){for(var i=0;i=0?this._store.getGroupById(s):null;return this._store.dispatch(Ie(i,!0)),t&&this.passedElement.triggerEvent(V,{id:i,value:o,label:c,groupValue:l&&l.value?l.value:null}),this},r.unhighlightItem=function(e){if(!e)return this;var t=e.id,i=e.groupId,n=void 0===i?-1:i,s=e.value,r=void 0===s?"":s,o=e.label,a=void 0===o?"":o,c=n>=0?this._store.getGroupById(n):null;return this._store.dispatch(Ie(t,!1)),this.passedElement.triggerEvent(V,{id:t,value:r,label:a,groupValue:c&&c.value?c.value:null}),this},r.highlightAll=function(){var e=this;return this._store.items.forEach((function(t){return e.highlightItem(t)})),this},r.unhighlightAll=function(){var e=this;return this._store.items.forEach((function(t){return e.unhighlightItem(t)})),this},r.removeActiveItemsByValue=function(e){var t=this;return this._store.activeItems.filter((function(t){return t.value===e})).forEach((function(e){return t._removeItem(e)})),this},r.removeActiveItems=function(e){var t=this;return this._store.activeItems.filter((function(t){return t.id!==e})).forEach((function(e){return t._removeItem(e)})),this},r.removeHighlightedItems=function(e){var t=this;return void 0===e&&(e=!1),this._store.highlightedActiveItems.forEach((function(i){t._removeItem(i),e&&t._triggerChange(i.value)})),this},r.showDropdown=function(e){var t=this;return this.dropdown.isActive?this:(requestAnimationFrame((function(){t.dropdown.show(),t.containerOuter.open(t.dropdown.distanceFromTopWindow),!e&&t._canSearch&&t.input.focus(),t.passedElement.triggerEvent(N,{})})),this)},r.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(F,{})})),this):this},r.getValue=function(e){void 0===e&&(e=!1);var t=this._store.activeItems.reduce((function(t,i){var n=e?i.value:i;return t.push(n),t}),[]);return this._isSelectOneElement?t[0]:t},r.setValue=function(e){var t=this;return this.initialised?(e.forEach((function(e){return t._setChoiceOrItem(e)})),this):this},r.setChoiceByValue=function(e){var t=this;return!this.initialised||this._isTextElement?this:((Array.isArray(e)?e:[e]).forEach((function(e){return t._findAndSelectChoiceByValue(e)})),this)},r.setChoices=function(e,t,i,n){var s=this;if(void 0===e&&(e=[]),void 0===t&&(t="value"),void 0===i&&(i="label"),void 0===n&&(n=!1),!this.initialised)throw new ReferenceError("setChoices was called on a non-initialized instance of Choices");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(n&&this.clearChoices(),"function"==typeof e){var r=e(this);if("function"==typeof Promise&&r instanceof Promise)return new Promise((function(e){return requestAnimationFrame(e)})).then((function(){return s._handleLoadingState(!0)})).then((function(){return r})).then((function(e){return s.setChoices(e,t,i,n)})).catch((function(e){s.config.silent||console.error(e)})).then((function(){return s._handleLoadingState(!1)})).then((function(){return s}));if(!Array.isArray(r))throw new TypeError(".setChoices first argument function must return either array of choices or Promise, got: "+typeof r);return this.setChoices(r,t,i,!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._startLoading(),e.forEach((function(e){e.choices?s._addGroup({id:parseInt(e.id,10)||null,group:e,valueKey:t,labelKey:i}):s._addChoice({value:e[t],label:e[i],isSelected:e.selected,isDisabled:e.disabled,customProperties:e.customProperties,placeholder:e.placeholder})})),this._stopLoading(),this},r.clearChoices=function(){return this._store.dispatch({type:W}),this},r.clearStore=function(){return this._store.dispatch({type:"CLEAR_ALL"}),this},r.clearInput=function(){var e=!this._isSelectOneElement;return this.input.clear(e),!this._isTextElement&&this._canSearch&&(this._isSearching=!1,this._store.dispatch(Ee(!0))),this},r._render=function(){if(!this._store.isLoading()){this._currentState=this._store.state;var e=this._currentState.choices!==this._prevState.choices||this._currentState.groups!==this._prevState.groups||this._currentState.items!==this._prevState.items,t=this._isSelectElement,i=this._currentState.items!==this._prevState.items;e&&(t&&this._renderChoices(),i&&this._renderItems(),this._prevState=this._currentState)}},r._renderChoices=function(){var e=this,t=this._store,i=t.activeGroups,n=t.activeChoices,s=document.createDocumentFragment();if(this.choiceList.clear(),this.config.resetScrollPosition&&requestAnimationFrame((function(){return e.choiceList.scrollToTop()})),i.length>=1&&!this._isSearching){var r=n.filter((function(e){return!0===e.placeholder&&-1===e.groupId}));r.length>=1&&(s=this._createChoicesFragment(r,s)),s=this._createGroupsFragment(i,n,s)}else n.length>=1&&(s=this._createChoicesFragment(n,s));if(s.childNodes&&s.childNodes.length>0){var o=this._store.activeItems,a=this._canAddItem(o,this.input.value);a.response?(this.choiceList.append(s),this._highlightChoice()):this.choiceList.append(this._getTemplate("notice",a.notice))}else{var c,l;this._isSearching?(l="function"==typeof this.config.noResultsText?this.config.noResultsText():this.config.noResultsText,c=this._getTemplate("notice",l,"no-results")):(l="function"==typeof this.config.noChoicesText?this.config.noChoicesText():this.config.noChoicesText,c=this._getTemplate("notice",l,"no-choices")),this.choiceList.append(c)}},r._renderItems=function(){var e=this._store.activeItems||[];this.itemList.clear();var t=this._createItemsFragment(e);t.childNodes&&this.itemList.append(t)},r._createGroupsFragment=function(e,t,i){var n=this;void 0===i&&(i=document.createDocumentFragment());return this.config.shouldSort&&e.sort(this.config.sorter),e.forEach((function(e){var s=function(e){return t.filter((function(t){return n._isSelectOneElement?t.groupId===e.id:t.groupId===e.id&&("always"===n.config.renderSelectedChoices||!t.selected)}))}(e);if(s.length>=1){var r=n._getTemplate("choiceGroup",e);i.appendChild(r),n._createChoicesFragment(s,i,!0)}})),i},r._createChoicesFragment=function(e,t,i){var n=this;void 0===t&&(t=document.createDocumentFragment()),void 0===i&&(i=!1);var s=this.config,r=s.renderSelectedChoices,o=s.searchResultLimit,a=s.renderChoiceLimit,c=this._isSearching?O:this.config.sorter,l=function(e){if("auto"!==r||(n._isSelectOneElement||!e.selected)){var i=n._getTemplate("choice",e,n.config.itemSelectText);t.appendChild(i)}},h=e;"auto"!==r||this._isSelectOneElement||(h=e.filter((function(e){return!e.selected})));var u=h.reduce((function(e,t){return t.placeholder?e.placeholderChoices.push(t):e.normalChoices.push(t),e}),{placeholderChoices:[],normalChoices:[]}),d=u.placeholderChoices,p=u.normalChoices;(this.config.shouldSort||this._isSearching)&&p.sort(c);var m=h.length,f=this._isSelectOneElement?[].concat(d,p):p;this._isSearching?m=o:a&&a>0&&!i&&(m=a);for(var v=0;v=n){var o=s?this._searchChoices(e):0;this.passedElement.triggerEvent(R,{value:e,resultCount:o})}else r&&(this._isSearching=!1,this._store.dispatch(Ee(!0)))}},r._canAddItem=function(e,t){var i=!0,n="function"==typeof this.config.addItemText?this.config.addItemText(t):this.config.addItemText;if(!this._isSelectOneElement){var s=function(e,t,i){return void 0===i&&(i="value"),e.some((function(e){return"string"==typeof t?e[i]===t.trim():e[i]===t}))}(e,t);this.config.maxItemCount>0&&this.config.maxItemCount<=e.length&&(i=!1,n="function"==typeof this.config.maxItemText?this.config.maxItemText(this.config.maxItemCount):this.config.maxItemText),!this.config.duplicateItemsAllowed&&s&&i&&(i=!1,n="function"==typeof this.config.uniqueItemText?this.config.uniqueItemText(t):this.config.uniqueItemText),this._isTextElement&&this.config.addItems&&i&&"function"==typeof this.config.addItemFilter&&!this.config.addItemFilter(t)&&(i=!1,n="function"==typeof this.config.customAddItemText?this.config.customAddItemText(t):this.config.customAddItemText)}return{response:i,notice:n}},r._searchChoices=function(e){var t="string"==typeof e?e.trim():e,i="string"==typeof this._currentValue?this._currentValue.trim():this._currentValue;if(t.length<1&&t===i+" ")return 0;var n=this._store.searchableChoices,r=t,o=[].concat(this.config.searchFields),a=Object.assign(this.config.fuseOptions,{keys:o}),c=new s.a(n,a).search(r);return this._currentValue=t,this._highlightPosition=0,this._isSearching=!0,this._store.dispatch(function(e){return{type:U,results:e}}(c)),c.length},r._addEventListeners=function(){var e=document.documentElement;e.addEventListener("touchend",this._onTouchEnd,!0),this.containerOuter.element.addEventListener("keydown",this._onKeyDown,!0),this.containerOuter.element.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&&(this.containerOuter.element.addEventListener("focus",this._onFocus,{passive:!0}),this.containerOuter.element.addEventListener("blur",this._onBlur,{passive:!0})),this.input.element.addEventListener("keyup",this._onKeyUp,{passive:!0}),this.input.element.addEventListener("focus",this._onFocus,{passive:!0}),this.input.element.addEventListener("blur",this._onBlur,{passive:!0}),this.input.element.form&&this.input.element.form.addEventListener("reset",this._onFormReset,{passive:!0}),this.input.addEventListeners()},r._removeEventListeners=function(){var e=document.documentElement;e.removeEventListener("touchend",this._onTouchEnd,!0),this.containerOuter.element.removeEventListener("keydown",this._onKeyDown,!0),this.containerOuter.element.removeEventListener("mousedown",this._onMouseDown,!0),e.removeEventListener("click",this._onClick),e.removeEventListener("touchmove",this._onTouchMove),this.dropdown.element.removeEventListener("mouseover",this._onMouseOver),this._isSelectOneElement&&(this.containerOuter.element.removeEventListener("focus",this._onFocus),this.containerOuter.element.removeEventListener("blur",this._onBlur)),this.input.element.removeEventListener("keyup",this._onKeyUp),this.input.element.removeEventListener("focus",this._onFocus),this.input.element.removeEventListener("blur",this._onBlur),this.input.element.form&&this.input.element.form.removeEventListener("reset",this._onFormReset),this.input.removeEventListeners()},r._onKeyDown=function(e){var t,i=e.target,n=e.keyCode,s=e.ctrlKey,r=e.metaKey,o=this._store.activeItems,a=this.input.isFocussed,c=this.dropdown.isActive,l=this.itemList.hasChildren(),h=String.fromCharCode(n),u=Z,d=Q,p=ee,m=te,f=ie,v=ne,g=se,_=re,b=oe,y=s||r;!this._isTextElement&&/[a-zA-Z0-9-_ ]/.test(h)&&this.showDropdown();var E=((t={})[m]=this._onAKey,t[p]=this._onEnterKey,t[f]=this._onEscapeKey,t[v]=this._onDirectionKey,t[_]=this._onDirectionKey,t[g]=this._onDirectionKey,t[b]=this._onDirectionKey,t[d]=this._onDeleteKey,t[u]=this._onDeleteKey,t);E[n]&&E[n]({event:e,target:i,keyCode:n,metaKey:r,activeItems:o,hasFocusedInput:a,hasActiveDropdown:c,hasItems:l,hasCtrlDownKeyPressed:y})},r._onKeyUp=function(e){var t=e.target,i=e.keyCode,n=this.input.value,s=this._store.activeItems,r=this._canAddItem(s,n),o=Z,a=Q;if(this._isTextElement){if(r.notice&&n){var c=this._getTemplate("notice",r.notice);this.dropdown.element.innerHTML=c.outerHTML,this.showDropdown(!0)}else this.hideDropdown(!0)}else{var l=(i===o||i===a)&&!t.value,h=!this._isTextElement&&this._isSearching,u=this._canSearch&&r.response;l&&h?(this._isSearching=!1,this._store.dispatch(Ee(!0))):u&&this._handleSearch(this.input.value)}this._canSearch=this.config.searchEnabled},r._onAKey=function(e){var t=e.hasItems;e.hasCtrlDownKeyPressed&&t&&(this._canSearch=!1,this.config.removeItems&&!this.input.value&&this.input.element===document.activeElement&&this.highlightAll())},r._onEnterKey=function(e){var t=e.event,i=e.target,n=e.activeItems,s=e.hasActiveDropdown,r=ee,o=i.hasAttribute("data-button");if(this._isTextElement&&i.value){var a=this.input.value;this._canAddItem(n,a).response&&(this.hideDropdown(!0),this._addItem({value:a}),this._triggerChange(a),this.clearInput())}if(o&&(this._handleButtonAction(n,i),t.preventDefault()),s){var c=this.dropdown.getChild("."+this.config.classNames.highlightedState);c&&(n[0]&&(n[0].keyCode=r),this._handleChoiceAction(n,c)),t.preventDefault()}else this._isSelectOneElement&&(this.showDropdown(),t.preventDefault())},r._onEscapeKey=function(e){e.hasActiveDropdown&&(this.hideDropdown(!0),this.containerOuter.focus())},r._onDirectionKey=function(e){var t,i,n,s=e.event,r=e.hasActiveDropdown,o=e.keyCode,a=e.metaKey,c=se,l=re,h=oe;if(r||this._isSelectOneElement){this.showDropdown(),this._canSearch=!1;var u,d=o===c||o===h?1:-1;if(a||o===h||o===l)u=d>0?this.dropdown.element.querySelector("[data-choice-selectable]:last-of-type"):this.dropdown.element.querySelector("[data-choice-selectable]");else{var p=this.dropdown.element.querySelector("."+this.config.classNames.highlightedState);u=p?function(e,t,i){if(void 0===i&&(i=1),e instanceof Element&&"string"==typeof t){for(var n=(i>0?"next":"previous")+"ElementSibling",s=e[n];s;){if(s.matches(t))return s;s=s[n]}return s}}(p,"[data-choice-selectable]",d):this.dropdown.element.querySelector("[data-choice-selectable]")}u&&(t=u,i=this.choiceList.element,void 0===(n=d)&&(n=1),t&&(n>0?i.scrollTop+i.offsetHeight>=t.offsetTop+t.offsetHeight:t.offsetTop>=i.scrollTop)||this.choiceList.scrollToChildElement(u,d),this._highlightChoice(u)),s.preventDefault()}},r._onDeleteKey=function(e){var t=e.event,i=e.target,n=e.hasFocusedInput,s=e.activeItems;!n||i.value||this._isSelectOneElement||(this._handleBackspace(s),t.preventDefault())},r._onTouchMove=function(){this._wasTap&&(this._wasTap=!1)},r._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},r._onMouseDown=function(e){var t=e.target;if(t instanceof HTMLElement){if(Ce&&this.choiceList.element.contains(t)){var i=this.choiceList.element.firstElementChild,n="ltr"===this._direction?e.offsetX>=i.offsetWidth:e.offsetX0&&this.unhighlightAll(),this.containerOuter.removeFocusState(),this.hideDropdown(!0))},r._onFocus=function(e){var t,i=this,n=e.target;this.containerOuter.element.contains(n)&&((t={})[ae]=function(){n===i.input.element&&i.containerOuter.addFocusState()},t[ce]=function(){i.containerOuter.addFocusState(),n===i.input.element&&i.showDropdown(!0)},t[le]=function(){n===i.input.element&&(i.showDropdown(!0),i.containerOuter.addFocusState())},t)[this.passedElement.element.type]()},r._onBlur=function(e){var t=this,i=e.target;if(this.containerOuter.element.contains(i)&&!this._isScrollingOnIe){var n,s=this._store.activeItems.some((function(e){return e.highlighted}));((n={})[ae]=function(){i===t.input.element&&(t.containerOuter.removeFocusState(),s&&t.unhighlightAll(),t.hideDropdown(!0))},n[ce]=function(){t.containerOuter.removeFocusState(),(i===t.input.element||i===t.containerOuter.element&&!t._canSearch)&&t.hideDropdown(!0)},n[le]=function(){i===t.input.element&&(t.containerOuter.removeFocusState(),t.hideDropdown(!0),s&&t.unhighlightAll())},n)[this.passedElement.element.type]()}else this._isScrollingOnIe=!1,this.input.element.focus()},r._onFormReset=function(){this._store.dispatch({type:"RESET_TO",state:this._initialState})},r._highlightChoice=function(e){var t=this;void 0===e&&(e=null);var i=Array.from(this.dropdown.element.querySelectorAll("[data-choice-selectable]"));if(i.length){var n=e;Array.from(this.dropdown.element.querySelectorAll("."+this.config.classNames.highlightedState)).forEach((function(e){e.classList.remove(t.config.classNames.highlightedState),e.setAttribute("aria-selected","false")})),n?this._highlightPosition=i.indexOf(n):(n=i.length>this._highlightPosition?i[this._highlightPosition]:i[i.length-1])||(n=i[0]),n.classList.add(this.config.classNames.highlightedState),n.setAttribute("aria-selected","true"),this.passedElement.triggerEvent(G,{el:n}),this.dropdown.isActive&&(this.input.setActiveDescendant(n.id),this.containerOuter.setActiveDescendant(n.id))}},r._addItem=function(e){var t=e.value,i=e.label,n=void 0===i?null:i,s=e.choiceId,r=void 0===s?-1:s,o=e.groupId,a=void 0===o?-1:o,c=e.customProperties,l=void 0===c?null:c,h=e.placeholder,u=void 0!==h&&h,d=e.keyCode,p=void 0===d?null:d,m="string"==typeof t?t.trim():t,f=p,v=l,g=this._store.items,_=n||m,b=r||-1,y=a>=0?this._store.getGroupById(a):null,E=g?g.length+1:1;return this.config.prependValue&&(m=this.config.prependValue+m.toString()),this.config.appendValue&&(m+=this.config.appendValue.toString()),this._store.dispatch(function(e){var t=e.value,i=e.label,n=e.id,s=e.choiceId,r=e.groupId,o=e.customProperties,a=e.placeholder,c=e.keyCode;return{type:$,value:t,label:i,id:n,choiceId:s,groupId:r,customProperties:o,placeholder:a,keyCode:c}}({value:m,label:_,id:E,choiceId:b,groupId:a,customProperties:l,placeholder:u,keyCode:f})),this._isSelectOneElement&&this.removeActiveItems(E),this.passedElement.triggerEvent(H,{id:E,value:m,label:_,customProperties:v,groupValue:y&&y.value?y.value:void 0,keyCode:f}),this},r._removeItem=function(e){if(!e||!I("Object",e))return this;var t=e.id,i=e.value,n=e.label,s=e.choiceId,r=e.groupId,o=r>=0?this._store.getGroupById(r):null;return this._store.dispatch(function(e,t){return{type:J,id:e,choiceId:t}}(t,s)),o&&o.value?this.passedElement.triggerEvent(B,{id:t,value:i,label:n,groupValue:o.value}):this.passedElement.triggerEvent(B,{id:t,value:i,label:n}),this},r._addChoice=function(e){var t=e.value,i=e.label,n=void 0===i?null:i,s=e.isSelected,r=void 0!==s&&s,o=e.isDisabled,a=void 0!==o&&o,c=e.groupId,l=void 0===c?-1:c,h=e.customProperties,u=void 0===h?null:h,d=e.placeholder,p=void 0!==d&&d,m=e.keyCode,f=void 0===m?null:m;if(null!=t){var v=this._store.choices,g=n||t,_=v?v.length+1:1,b=this._baseId+"-"+this._idNames.itemChoice+"-"+_;this._store.dispatch(function(e){var t=e.value,i=e.label,n=e.id,s=e.groupId,r=e.disabled,o=e.elementId,a=e.customProperties,c=e.placeholder,l=e.keyCode;return{type:q,value:t,label:i,id:n,groupId:s,disabled:r,elementId:o,customProperties:a,placeholder:c,keyCode:l}}({id:_,groupId:l,elementId:b,value:t,label:g,disabled:a,customProperties:u,placeholder:p,keyCode:f})),r&&this._addItem({value:t,label:g,choiceId:_,customProperties:u,placeholder:p,keyCode:f})}},r._addGroup=function(e){var t=this,i=e.group,n=e.id,s=e.valueKey,r=void 0===s?"value":s,o=e.labelKey,a=void 0===o?"label":o,c=I("Object",i)?i.choices:Array.from(i.getElementsByTagName("OPTION")),l=n||Math.floor((new Date).valueOf()*Math.random()),h=!!i.disabled&&i.disabled;if(c){this._store.dispatch(Se({value:i.label,id:l,active:!0,disabled:h}));c.forEach((function(e){var i=e.disabled||e.parentNode&&e.parentNode.disabled;t._addChoice({value:e[r],label:I("Object",e)?e[a]:e.innerHTML,isSelected:e.selected,isDisabled:i,groupId:l,customProperties:e.customProperties,placeholder:e.placeholder})}))}else this._store.dispatch(Se({value:i.label,id:i.id,active:!1,disabled:i.disabled}))},r._getTemplate=function(e){var t;if(!e)return null;for(var i=this.config.classNames,n=arguments.length,s=new Array(n>1?n-1:0),r=1;r=0?this._store.getGroupById(s):null;return this._store.dispatch((0,l.highlightItem)(i,!0)),t&&this.passedElement.triggerEvent(d.EVENTS.highlightItem,{id:i,value:o,label:c,groupValue:h&&h.value?h.value:null}),this},e.prototype.unhighlightItem=function(e){if(!e||!e.id)return this;var t=e.id,i=e.groupId,n=void 0===i?-1:i,s=e.value,r=void 0===s?"":s,o=e.label,a=void 0===o?"":o,c=n>=0?this._store.getGroupById(n):null;return this._store.dispatch((0,l.highlightItem)(t,!1)),this.passedElement.triggerEvent(d.EVENTS.highlightItem,{id:t,value:r,label:a,groupValue:c&&c.value?c.value:null}),this},e.prototype.highlightAll=function(){var e=this;return this._store.items.forEach((function(t){return e.highlightItem(t)})),this},e.prototype.unhighlightAll=function(){var e=this;return this._store.items.forEach((function(t){return e.unhighlightItem(t)})),this},e.prototype.removeActiveItemsByValue=function(e){var t=this;return this._store.activeItems.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.activeItems.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.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||requestAnimationFrame((function(){t.dropdown.show(),t.containerOuter.open(t.dropdown.distanceFromTopWindow),!e&&t._canSearch&&t.input.focus(),t.passedElement.triggerEvent(d.EVENTS.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(d.EVENTS.hideDropdown,{})})),this):this},e.prototype.getValue=function(e){void 0===e&&(e=!1);var t=this._store.activeItems.reduce((function(t,i){var n=e?i.value:i;return t.push(n),t}),[]);return this._isSelectOneElement?t[0]:t},e.prototype.setValue=function(e){var t=this;return this.initialised?(e.forEach((function(e){return t._setChoiceOrItem(e)})),this):this},e.prototype.setChoiceByValue=function(e){var t=this;return!this.initialised||this._isTextElement||(Array.isArray(e)?e:[e]).forEach((function(e){return t._findAndSelectChoiceByValue(e)})),this},e.prototype.setChoices=function(e,t,i,n){var s=this;if(void 0===e&&(e=[]),void 0===t&&(t="value"),void 0===i&&(i="label"),void 0===n&&(n=!1),!this.initialised)throw new ReferenceError("setChoices was called on a non-initialized instance of Choices");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(n&&this.clearChoices(),"function"==typeof e){var r=e(this);if("function"==typeof Promise&&r instanceof Promise)return new Promise((function(e){return requestAnimationFrame(e)})).then((function(){return s._handleLoadingState(!0)})).then((function(){return r})).then((function(e){return s.setChoices(e,t,i,n)})).catch((function(e){s.config.silent||console.error(e)})).then((function(){return s._handleLoadingState(!1)})).then((function(){return s}));if(!Array.isArray(r))throw new TypeError(".setChoices first argument function must return either array of choices or Promise, got: ".concat(typeof r));return this.setChoices(r,t,i,!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._startLoading(),e.forEach((function(e){if(e.choices)s._addGroup({id:e.id?parseInt("".concat(e.id),10):null,group:e,valueKey:t,labelKey:i});else{var n=e;s._addChoice({value:n[t],label:n[i],isSelected:!!n.selected,isDisabled:!!n.disabled,placeholder:!!n.placeholder,customProperties:n.customProperties})}})),this._stopLoading(),this},e.prototype.clearChoices=function(){return this._store.dispatch((0,a.clearChoices)()),this},e.prototype.clearStore=function(){return this._store.dispatch((0,h.clearAll)()),this},e.prototype.clearInput=function(){var e=!this._isSelectOneElement;return this.input.clear(e),!this._isTextElement&&this._canSearch&&(this._isSearching=!1,this._store.dispatch((0,a.activateChoices)(!0))),this},e.prototype._render=function(){if(!this._store.isLoading()){this._currentState=this._store.state;var e=this._currentState.choices!==this._prevState.choices||this._currentState.groups!==this._prevState.groups||this._currentState.items!==this._prevState.items,t=this._isSelectElement,i=this._currentState.items!==this._prevState.items;e&&(t&&this._renderChoices(),i&&this._renderItems(),this._prevState=this._currentState)}},e.prototype._renderChoices=function(){var e=this,t=this._store,i=t.activeGroups,n=t.activeChoices,s=document.createDocumentFragment();if(this.choiceList.clear(),this.config.resetScrollPosition&&requestAnimationFrame((function(){return e.choiceList.scrollToTop()})),i.length>=1&&!this._isSearching){var r=n.filter((function(e){return!0===e.placeholder&&-1===e.groupId}));r.length>=1&&(s=this._createChoicesFragment(r,s)),s=this._createGroupsFragment(i,n,s)}else n.length>=1&&(s=this._createChoicesFragment(n,s));if(s.childNodes&&s.childNodes.length>0){var o=this._store.activeItems,a=this._canAddItem(o,this.input.value);if(a.response)this.choiceList.append(s),this._highlightChoice();else{var c=this._getTemplate("notice",a.notice);this.choiceList.append(c)}}else{var l=void 0;c=void 0,this._isSearching?(c="function"==typeof this.config.noResultsText?this.config.noResultsText():this.config.noResultsText,l=this._getTemplate("notice",c,"no-results")):(c="function"==typeof this.config.noChoicesText?this.config.noChoicesText():this.config.noChoicesText,l=this._getTemplate("notice",c,"no-choices")),this.choiceList.append(l)}},e.prototype._renderItems=function(){var e=this._store.activeItems||[];this.itemList.clear();var t=this._createItemsFragment(e);t.childNodes&&this.itemList.append(t)},e.prototype._createGroupsFragment=function(e,t,i){var n=this;return void 0===i&&(i=document.createDocumentFragment()),this.config.shouldSort&&e.sort(this.config.sorter),e.forEach((function(e){var s=function(e){return t.filter((function(t){return n._isSelectOneElement?t.groupId===e.id:t.groupId===e.id&&("always"===n.config.renderSelectedChoices||!t.selected)}))}(e);if(s.length>=1){var r=n._getTemplate("choiceGroup",e);i.appendChild(r),n._createChoicesFragment(s,i,!0)}})),i},e.prototype._createChoicesFragment=function(e,t,i){var s=this;void 0===t&&(t=document.createDocumentFragment()),void 0===i&&(i=!1);var r=this.config,o=r.renderSelectedChoices,a=r.searchResultLimit,c=r.renderChoiceLimit,l=this._isSearching?f.sortByScore:this.config.sorter,h=function(e){if("auto"!==o||s._isSelectOneElement||!e.selected){var i=s._getTemplate("choice",e,s.config.itemSelectText);t.appendChild(i)}},u=e;"auto"!==o||this._isSelectOneElement||(u=e.filter((function(e){return!e.selected})));var d=u.reduce((function(e,t){return t.placeholder?e.placeholderChoices.push(t):e.normalChoices.push(t),e}),{placeholderChoices:[],normalChoices:[]}),p=d.placeholderChoices,m=d.normalChoices;(this.config.shouldSort||this._isSearching)&&m.sort(l);var v=u.length,g=this._isSelectOneElement?n(n([],p,!0),m,!0):m;this._isSearching?v=a:c&&c>0&&!i&&(v=c);for(var _=0;_=n){var o=s?this._searchChoices(e):0;this.passedElement.triggerEvent(d.EVENTS.search,{value:e,resultCount:o})}else r&&(this._isSearching=!1,this._store.dispatch((0,a.activateChoices)(!0)))}},e.prototype._canAddItem=function(e,t){var i=!0,n="function"==typeof this.config.addItemText?this.config.addItemText(t):this.config.addItemText;if(!this._isSelectOneElement){var s=(0,f.existsInArray)(e,t);this.config.maxItemCount>0&&this.config.maxItemCount<=e.length&&(i=!1,n="function"==typeof this.config.maxItemText?this.config.maxItemText(this.config.maxItemCount):this.config.maxItemText),!this.config.duplicateItemsAllowed&&s&&i&&(i=!1,n="function"==typeof this.config.uniqueItemText?this.config.uniqueItemText(t):this.config.uniqueItemText),this._isTextElement&&this.config.addItems&&i&&"function"==typeof this.config.addItemFilter&&!this.config.addItemFilter(t)&&(i=!1,n="function"==typeof this.config.customAddItemText?this.config.customAddItemText(t):this.config.customAddItemText)}return{response:i,notice:n}},e.prototype._searchChoices=function(e){var t="string"==typeof e?e.trim():e,i="string"==typeof this._currentValue?this._currentValue.trim():this._currentValue;if(t.length<1&&t==="".concat(i," "))return 0;var s=this._store.searchableChoices,r=t,c=Object.assign(this.config.fuseOptions,{keys:n([],this.config.searchFields,!0),includeMatches:!0}),l=new o.default(s,c).search(r);return this._currentValue=t,this._highlightPosition=0,this._isSearching=!0,this._store.dispatch((0,a.filterChoices)(l)),l.length},e.prototype._addEventListeners=function(){var e=document.documentElement;e.addEventListener("touchend",this._onTouchEnd,!0),this.containerOuter.element.addEventListener("keydown",this._onKeyDown,!0),this.containerOuter.element.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&&(this.containerOuter.element.addEventListener("focus",this._onFocus,{passive:!0}),this.containerOuter.element.addEventListener("blur",this._onBlur,{passive:!0})),this.input.element.addEventListener("keyup",this._onKeyUp,{passive:!0}),this.input.element.addEventListener("focus",this._onFocus,{passive:!0}),this.input.element.addEventListener("blur",this._onBlur,{passive:!0}),this.input.element.form&&this.input.element.form.addEventListener("reset",this._onFormReset,{passive:!0}),this.input.addEventListeners()},e.prototype._removeEventListeners=function(){var e=document.documentElement;e.removeEventListener("touchend",this._onTouchEnd,!0),this.containerOuter.element.removeEventListener("keydown",this._onKeyDown,!0),this.containerOuter.element.removeEventListener("mousedown",this._onMouseDown,!0),e.removeEventListener("click",this._onClick),e.removeEventListener("touchmove",this._onTouchMove),this.dropdown.element.removeEventListener("mouseover",this._onMouseOver),this._isSelectOneElement&&(this.containerOuter.element.removeEventListener("focus",this._onFocus),this.containerOuter.element.removeEventListener("blur",this._onBlur)),this.input.element.removeEventListener("keyup",this._onKeyUp),this.input.element.removeEventListener("focus",this._onFocus),this.input.element.removeEventListener("blur",this._onBlur),this.input.element.form&&this.input.element.form.removeEventListener("reset",this._onFormReset),this.input.removeEventListeners()},e.prototype._onKeyDown=function(e){var t=e.keyCode,i=this._store.activeItems,n=this.input.isFocussed,s=this.dropdown.isActive,r=this.itemList.hasChildren(),o=String.fromCharCode(t),a=/[a-zA-Z0-9-_ ]/.test(o),c=d.KEY_CODES.BACK_KEY,l=d.KEY_CODES.DELETE_KEY,h=d.KEY_CODES.ENTER_KEY,u=d.KEY_CODES.A_KEY,p=d.KEY_CODES.ESC_KEY,f=d.KEY_CODES.UP_KEY,m=d.KEY_CODES.DOWN_KEY,v=d.KEY_CODES.PAGE_UP_KEY,g=d.KEY_CODES.PAGE_DOWN_KEY;switch(this._isTextElement||s||!a||(this.showDropdown(),this.input.isFocussed||(this.input.value+=o.toLowerCase())),t){case u:return this._onSelectKey(e,r);case h:return this._onEnterKey(e,i,s);case p:return this._onEscapeKey(s);case f:case v:case m:case g:return this._onDirectionKey(e,s);case l:case c:return this._onDeleteKey(e,i,n)}},e.prototype._onKeyUp=function(e){var t=e.target,i=e.keyCode,n=this.input.value,s=this._store.activeItems,r=this._canAddItem(s,n),o=d.KEY_CODES.BACK_KEY,c=d.KEY_CODES.DELETE_KEY;if(this._isTextElement)if(r.notice&&n){var l=this._getTemplate("notice",r.notice);this.dropdown.element.innerHTML=l.outerHTML,this.showDropdown(!0)}else this.hideDropdown(!0);else{var h=(i===o||i===c)&&t&&!t.value,u=!this._isTextElement&&this._isSearching,p=this._canSearch&&r.response;h&&u?(this._isSearching=!1,this._store.dispatch((0,a.activateChoices)(!0))):p&&this._handleSearch(this.input.rawValue)}this._canSearch=this.config.searchEnabled},e.prototype._onSelectKey=function(e,t){var i=e.ctrlKey,n=e.metaKey;(i||n)&&t&&(this._canSearch=!1,this.config.removeItems&&!this.input.value&&this.input.element===document.activeElement&&this.highlightAll())},e.prototype._onEnterKey=function(e,t,i){var n=e.target,s=d.KEY_CODES.ENTER_KEY,r=n&&n.hasAttribute("data-button");if(this._isTextElement&&n&&n.value){var o=this.input.value;this._canAddItem(t,o).response&&(this.hideDropdown(!0),this._addItem({value:o}),this._triggerChange(o),this.clearInput())}if(r&&(this._handleButtonAction(t,n),e.preventDefault()),i){var a=this.dropdown.getChild(".".concat(this.config.classNames.highlightedState));a&&(t[0]&&(t[0].keyCode=s),this._handleChoiceAction(t,a)),e.preventDefault()}else this._isSelectOneElement&&(this.showDropdown(),e.preventDefault())},e.prototype._onEscapeKey=function(e){e&&(this.hideDropdown(!0),this.containerOuter.focus())},e.prototype._onDirectionKey=function(e,t){var i=e.keyCode,n=e.metaKey,s=d.KEY_CODES.DOWN_KEY,r=d.KEY_CODES.PAGE_UP_KEY,o=d.KEY_CODES.PAGE_DOWN_KEY;if(t||this._isSelectOneElement){this.showDropdown(),this._canSearch=!1;var a=i===s||i===o?1:-1,c="[data-choice-selectable]",l=void 0;if(n||i===o||i===r)l=a>0?this.dropdown.element.querySelector("".concat(c,":last-of-type")):this.dropdown.element.querySelector(c);else{var h=this.dropdown.element.querySelector(".".concat(this.config.classNames.highlightedState));l=h?(0,f.getAdjacentEl)(h,c,a):this.dropdown.element.querySelector(c)}l&&((0,f.isScrolledIntoView)(l,this.choiceList.element,a)||this.choiceList.scrollToChildElement(l,a),this._highlightChoice(l)),e.preventDefault()}},e.prototype._onDeleteKey=function(e,t,i){var n=e.target;this._isSelectOneElement||n.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(_&&this.choiceList.element.contains(t)){var i=this.choiceList.element.firstElementChild,n="ltr"===this._direction?e.offsetX>=i.offsetWidth:e.offsetX0&&this.unhighlightAll(),this.containerOuter.removeFocusState(),this.hideDropdown(!0))},e.prototype._onFocus=function(e){var t,i=this,n=e.target;n&&this.containerOuter.element.contains(n)&&((t={})[d.TEXT_TYPE]=function(){n===i.input.element&&i.containerOuter.addFocusState()},t[d.SELECT_ONE_TYPE]=function(){i.containerOuter.addFocusState(),n===i.input.element&&i.showDropdown(!0)},t[d.SELECT_MULTIPLE_TYPE]=function(){n===i.input.element&&(i.showDropdown(!0),i.containerOuter.addFocusState())},t)[this.passedElement.element.type]()},e.prototype._onBlur=function(e){var t,i=this,n=e.target;if(n&&this.containerOuter.element.contains(n)&&!this._isScrollingOnIe){var s=this._store.activeItems.some((function(e){return e.highlighted}));((t={})[d.TEXT_TYPE]=function(){n===i.input.element&&(i.containerOuter.removeFocusState(),s&&i.unhighlightAll(),i.hideDropdown(!0))},t[d.SELECT_ONE_TYPE]=function(){i.containerOuter.removeFocusState(),(n===i.input.element||n===i.containerOuter.element&&!i._canSearch)&&i.hideDropdown(!0)},t[d.SELECT_MULTIPLE_TYPE]=function(){n===i.input.element&&(i.containerOuter.removeFocusState(),i.hideDropdown(!0),s&&i.unhighlightAll())},t)[this.passedElement.element.type]()}else this._isScrollingOnIe=!1,this.input.element.focus()},e.prototype._onFormReset=function(){this._store.dispatch((0,h.resetTo)(this._initialState))},e.prototype._highlightChoice=function(e){var t=this;void 0===e&&(e=null);var i=Array.from(this.dropdown.element.querySelectorAll("[data-choice-selectable]"));if(i.length){var n=e;Array.from(this.dropdown.element.querySelectorAll(".".concat(this.config.classNames.highlightedState))).forEach((function(e){e.classList.remove(t.config.classNames.highlightedState),e.setAttribute("aria-selected","false")})),n?this._highlightPosition=i.indexOf(n):(n=i.length>this._highlightPosition?i[this._highlightPosition]:i[i.length-1])||(n=i[0]),n.classList.add(this.config.classNames.highlightedState),n.setAttribute("aria-selected","true"),this.passedElement.triggerEvent(d.EVENTS.highlightChoice,{el:n}),this.dropdown.isActive&&(this.input.setActiveDescendant(n.id),this.containerOuter.setActiveDescendant(n.id))}},e.prototype._addItem=function(e){var t=e.value,i=e.label,n=void 0===i?null:i,s=e.choiceId,r=void 0===s?-1:s,o=e.groupId,a=void 0===o?-1:o,c=e.customProperties,h=void 0===c?{}:c,u=e.placeholder,p=void 0!==u&&u,f=e.keyCode,m=void 0===f?-1:f,v="string"==typeof t?t.trim():t,g=this._store.items,_=n||v,y=r||-1,E=a>=0?this._store.getGroupById(a):null,b=g?g.length+1:1;this.config.prependValue&&(v=this.config.prependValue+v.toString()),this.config.appendValue&&(v+=this.config.appendValue.toString()),this._store.dispatch((0,l.addItem)({value:v,label:_,id:b,choiceId:y,groupId:a,customProperties:h,placeholder:p,keyCode:m})),this._isSelectOneElement&&this.removeActiveItems(b),this.passedElement.triggerEvent(d.EVENTS.addItem,{id:b,value:v,label:_,customProperties:h,groupValue:E&&E.value?E.value:null,keyCode:m})},e.prototype._removeItem=function(e){var t=e.id,i=e.value,n=e.label,s=e.customProperties,r=e.choiceId,o=e.groupId,a=o&&o>=0?this._store.getGroupById(o):null;t&&r&&(this._store.dispatch((0,l.removeItem)(t,r)),this.passedElement.triggerEvent(d.EVENTS.removeItem,{id:t,value:i,label:n,customProperties:s,groupValue:a&&a.value?a.value:null}))},e.prototype._addChoice=function(e){var t=e.value,i=e.label,n=void 0===i?null:i,s=e.isSelected,r=void 0!==s&&s,o=e.isDisabled,c=void 0!==o&&o,l=e.groupId,h=void 0===l?-1:l,u=e.customProperties,d=void 0===u?{}:u,p=e.placeholder,f=void 0!==p&&p,m=e.keyCode,v=void 0===m?-1:m;if(null!=t){var g=this._store.choices,_=n||t,y=g?g.length+1:1,E="".concat(this._baseId,"-").concat(this._idNames.itemChoice,"-").concat(y);this._store.dispatch((0,a.addChoice)({id:y,groupId:h,elementId:E,value:t,label:_,disabled:c,customProperties:d,placeholder:f,keyCode:v})),r&&this._addItem({value:t,label:_,choiceId:y,customProperties:d,placeholder:f,keyCode:v})}},e.prototype._addGroup=function(e){var t=this,i=e.group,n=e.id,s=e.valueKey,r=void 0===s?"value":s,o=e.labelKey,a=void 0===o?"label":o,l=(0,f.isType)("Object",i)?i.choices:Array.from(i.getElementsByTagName("OPTION")),h=n||Math.floor((new Date).valueOf()*Math.random()),u=!!i.disabled&&i.disabled;l?(this._store.dispatch((0,c.addGroup)({value:i.label,id:h,active:!0,disabled:u})),l.forEach((function(e){var i=e.disabled||e.parentNode&&e.parentNode.disabled;t._addChoice({value:e[r],label:(0,f.isType)("Object",e)?e[a]:e.innerHTML,isSelected:e.selected,isDisabled:i,groupId:h,customProperties:e.customProperties,placeholder:e.placeholder})}))):this._store.dispatch((0,c.addGroup)({value:i.label,id:i.id,active:!1,disabled:i.disabled}))},e.prototype._getTemplate=function(e){for(var t,i=[],s=1;s0?this.element.scrollTop+o-s:e.offsetTop;requestAnimationFrame((function(){i._animateScroll(a,t)}))}},e.prototype._scrollDown=function(e,t,i){var n=(i-e)/t,s=n>1?n:1;this.element.scrollTop=e+s},e.prototype._scrollUp=function(e,t,i){var n=(e-i)/t,s=n>1?n:1;this.element.scrollTop=e-s},e.prototype._animateScroll=function(e,t){var i=this,s=n.SCROLLING_SPEED,r=this.element.scrollTop,o=!1;t>0?(this._scrollDown(r,s,e),re&&(o=!0)),o&&requestAnimationFrame((function(){i._animateScroll(e,t)}))},e}();t.default=s},730:function(e,t,i){Object.defineProperty(t,"__esModule",{value:!0});var n=i(799),s=function(){function e(e){var t=e.element,i=e.classNames;if(this.element=t,this.classNames=i,!(t instanceof HTMLInputElement||t instanceof HTMLSelectElement))throw new TypeError("Invalid element passed");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.value=e},enumerable:!1,configurable:!0}),e.prototype.conceal=function(){this.element.classList.add(this.classNames.input),this.element.hidden=!0,this.element.tabIndex=-1;var e=this.element.getAttribute("style");e&&this.element.setAttribute("data-choice-orig-style",e),this.element.setAttribute("data-choice","active")},e.prototype.reveal=function(){this.element.classList.remove(this.classNames.input),this.element.hidden=!1,this.element.removeAttribute("tabindex");var e=this.element.getAttribute("data-choice-orig-style");e?(this.element.removeAttribute("data-choice-orig-style"),this.element.setAttribute("style",e)):this.element.removeAttribute("style"),this.element.removeAttribute("data-choice"),this.element.value=this.element.value},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){(0,n.dispatchEvent)(this.element,e,t)},e}();t.default=s},541:function(e,t,i){var n,s=this&&this.__extends||(n=function(e,t){return n=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])},n(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function i(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(i.prototype=t.prototype,new i)}),r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var o=function(e){function t(t){var i=t.element,n=t.classNames,s=t.delimiter,r=e.call(this,{element:i,classNames:n})||this;return r.delimiter=s,r}return s(t,e),Object.defineProperty(t.prototype,"value",{get:function(){return this.element.value},set:function(e){this.element.setAttribute("value",e),this.element.value=e},enumerable:!1,configurable:!0}),t}(r(i(730)).default);t.default=o},982:function(e,t,i){var n,s=this&&this.__extends||(n=function(e,t){return n=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])},n(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function i(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(i.prototype=t.prototype,new i)}),r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var o=function(e){function t(t){var i=t.element,n=t.classNames,s=t.template,r=e.call(this,{element:i,classNames:n})||this;return r.template=s,r}return s(t,e),Object.defineProperty(t.prototype,"placeholderOption",{get:function(){return this.element.querySelector('option[value=""]')||this.element.querySelector("option[placeholder]")},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"optionGroups",{get:function(){return Array.from(this.element.getElementsByTagName("OPTGROUP"))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"options",{get:function(){return Array.from(this.element.options)},set:function(e){var t=this,i=document.createDocumentFragment();e.forEach((function(e){return n=e,s=t.template(n),void i.appendChild(s);var n,s})),this.appendDocFragment(i)},enumerable:!1,configurable:!0}),t.prototype.appendDocFragment=function(e){this.element.innerHTML="",this.element.appendChild(e)},t}(r(i(730)).default);t.default=o},883:function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.SCROLLING_SPEED=t.SELECT_MULTIPLE_TYPE=t.SELECT_ONE_TYPE=t.TEXT_TYPE=t.KEY_CODES=t.ACTION_TYPES=t.EVENTS=void 0,t.EVENTS={showDropdown:"showDropdown",hideDropdown:"hideDropdown",change:"change",choice:"choice",search:"search",addItem:"addItem",removeItem:"removeItem",highlightItem:"highlightItem",highlightChoice:"highlightChoice",unhighlightItem:"unhighlightItem"},t.ACTION_TYPES={ADD_CHOICE:"ADD_CHOICE",FILTER_CHOICES:"FILTER_CHOICES",ACTIVATE_CHOICES:"ACTIVATE_CHOICES",CLEAR_CHOICES:"CLEAR_CHOICES",ADD_GROUP:"ADD_GROUP",ADD_ITEM:"ADD_ITEM",REMOVE_ITEM:"REMOVE_ITEM",HIGHLIGHT_ITEM:"HIGHLIGHT_ITEM",CLEAR_ALL:"CLEAR_ALL",RESET_TO:"RESET_TO",SET_IS_LOADING:"SET_IS_LOADING"},t.KEY_CODES={BACK_KEY:46,DELETE_KEY:8,ENTER_KEY:13,A_KEY:65,ESC_KEY:27,UP_KEY:38,DOWN_KEY:40,PAGE_UP_KEY:33,PAGE_DOWN_KEY:34},t.TEXT_TYPE="text",t.SELECT_ONE_TYPE="select-one",t.SELECT_MULTIPLE_TYPE="select-multiple",t.SCROLLING_SPEED=4},789:function(e,t,i){Object.defineProperty(t,"__esModule",{value:!0}),t.DEFAULT_CONFIG=t.DEFAULT_CLASSNAMES=void 0;var n=i(799);t.DEFAULT_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",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",noResults:"has-no-results",noChoices:"has-no-choices"},t.DEFAULT_CONFIG={items:[],choices:[],silent:!1,renderChoiceLimit:-1,maxItemCount:-1,addItems:!0,addItemFilter:null,removeItems:!0,removeItemButton:!1,editItems:!1,allowHTML:!0,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:n.sortByAlpha,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((0,n.sanitise)(e),'"')},maxItemText:function(e){return"Only ".concat(e," values can be added")},valueComparer:function(e,t){return e===t},fuseOptions:{includeScore:!0},callbackOnInit:null,callbackOnCreateTemplates:null,classNames:t.DEFAULT_CLASSNAMES}},18:function(e,t){Object.defineProperty(t,"__esModule",{value:!0})},978:function(e,t){Object.defineProperty(t,"__esModule",{value:!0})},948:function(e,t){Object.defineProperty(t,"__esModule",{value:!0})},359:function(e,t){Object.defineProperty(t,"__esModule",{value:!0})},285:function(e,t){Object.defineProperty(t,"__esModule",{value:!0})},533:function(e,t){Object.defineProperty(t,"__esModule",{value:!0})},187:function(e,t,i){var n=this&&this.__createBinding||(Object.create?function(e,t,i,n){void 0===n&&(n=i),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[i]}})}:function(e,t,i,n){void 0===n&&(n=i),e[n]=t[i]}),s=this&&this.__exportStar||function(e,t){for(var i in e)"default"===i||Object.prototype.hasOwnProperty.call(t,i)||n(t,e,i)};Object.defineProperty(t,"__esModule",{value:!0}),s(i(18),t),s(i(978),t),s(i(948),t),s(i(359),t),s(i(285),t),s(i(533),t),s(i(287),t),s(i(132),t),s(i(837),t),s(i(598),t),s(i(369),t),s(i(37),t),s(i(47),t),s(i(923),t),s(i(876),t)},287:function(e,t){Object.defineProperty(t,"__esModule",{value:!0})},132:function(e,t){Object.defineProperty(t,"__esModule",{value:!0})},837:function(e,t){Object.defineProperty(t,"__esModule",{value:!0})},598:function(e,t){Object.defineProperty(t,"__esModule",{value:!0})},37:function(e,t){Object.defineProperty(t,"__esModule",{value:!0})},369:function(e,t){Object.defineProperty(t,"__esModule",{value:!0})},47:function(e,t){Object.defineProperty(t,"__esModule",{value:!0})},923:function(e,t){Object.defineProperty(t,"__esModule",{value:!0})},876:function(e,t){Object.defineProperty(t,"__esModule",{value:!0})},799:function(e,t){var i;Object.defineProperty(t,"__esModule",{value:!0}),t.diff=t.cloneObject=t.existsInArray=t.dispatchEvent=t.sortByScore=t.sortByAlpha=t.strToEl=t.sanitise=t.isScrolledIntoView=t.getAdjacentEl=t.wrap=t.isType=t.getType=t.generateId=t.generateChars=t.getRandomNumber=void 0,t.getRandomNumber=function(e,t){return Math.floor(Math.random()*(t-e)+e)},t.generateChars=function(e){return Array.from({length:e},(function(){return(0,t.getRandomNumber)(0,36).toString(36)})).join("")},t.generateId=function(e,i){var n=e.id||e.name&&"".concat(e.name,"-").concat((0,t.generateChars)(2))||(0,t.generateChars)(4);return n=n.replace(/(:|\.|\[|\]|,)/g,""),"".concat(i,"-").concat(n)},t.getType=function(e){return Object.prototype.toString.call(e).slice(8,-1)},t.isType=function(e,i){return null!=i&&(0,t.getType)(i)===e},t.wrap=function(e,t){return void 0===t&&(t=document.createElement("div")),e.parentNode&&(e.nextSibling?e.parentNode.insertBefore(t,e.nextSibling):e.parentNode.appendChild(t)),t.appendChild(e)},t.getAdjacentEl=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 s},t.isScrolledIntoView=function(e,t,i){return void 0===i&&(i=1),!!e&&(i>0?t.scrollTop+t.offsetHeight>=e.offsetTop+e.offsetHeight:e.offsetTop>=t.scrollTop)},t.sanitise=function(e){return"string"!=typeof e?e:e.replace(/&/g,"&").replace(/>/g,">").replace(/-1?e.map((function(e){var t=e;return t.id===parseInt("".concat(o.choiceId),10)&&(t.selected=!0),t})):e;case"REMOVE_ITEM":var a=n;return a.choiceId&&a.choiceId>-1?e.map((function(e){var t=e;return t.id===parseInt("".concat(a.choiceId),10)&&(t.selected=!1),t})):e;case"FILTER_CHOICES":var c=n;return e.map((function(e){var t=e;return t.active=c.results.some((function(e){var i=e.item,n=e.score;return i.id===t.id&&(t.score=n,!0)})),t}));case"ACTIVATE_CHOICES":var l=n;return e.map((function(e){var t=e;return t.active=l.active,t}));case"CLEAR_CHOICES":return t.defaultState;default:return e}}},871:function(e,t){var i=this&&this.__spreadArray||function(e,t,i){if(i||2===arguments.length)for(var n,s=0,r=t.length;s0?"treeitem":"option"),Object.assign(E.dataset,{choice:"",id:d,value:p,selectText:i}),g?(E.classList.add(h),E.dataset.choiceDisabled="",E.setAttribute("aria-disabled","true")):(E.classList.add(c),E.dataset.choiceSelectable=""),E},input:function(e,t){var i=e.classNames,n=i.input,s=i.inputCloned,r=Object.assign(document.createElement("input"),{type:"search",name:"search_terms",className:"".concat(n," ").concat(s),autocomplete:"off",autocapitalize:"off",spellcheck:!1});return r.setAttribute("role","textbox"),r.setAttribute("aria-autocomplete","list"),r.setAttribute("aria-label",t),r},dropdown:function(e){var t=e.classNames,i=t.list,n=t.listDropdown,s=document.createElement("div");return s.classList.add(i,n),s.setAttribute("aria-expanded","false"),s},notice:function(e,t,i){var n,s=e.allowHTML,r=e.classNames,o=r.item,a=r.itemChoice,c=r.noResults,l=r.noChoices;void 0===i&&(i="");var h=[o,a];return"no-choices"===i?h.push(l):"no-results"===i&&h.push(c),Object.assign(document.createElement("div"),((n={})[s?"innerHTML":"innerText"]=t,n.className=h.join(" "),n))},option:function(e){var t=e.label,i=e.value,n=e.customProperties,s=e.active,r=e.disabled,o=new Option(t,i,!1,s);return n&&(o.dataset.customProperties="".concat(n)),o.disabled=!!r,o}};t.default=i},996:function(e){var t=function(e){return function(e){return!!e&&"object"==typeof e}(e)&&!function(e){var t=Object.prototype.toString.call(e);return"[object RegExp]"===t||"[object Date]"===t||function(e){return e.$$typeof===i}(e)}(e)},i="function"==typeof Symbol&&Symbol.for?Symbol.for("react.element"):60103;function n(e,t){return!1!==t.clone&&t.isMergeableObject(e)?a((i=e,Array.isArray(i)?[]:{}),e,t):e;var i}function s(e,t,i){return e.concat(t).map((function(e){return n(e,i)}))}function r(e){return Object.keys(e).concat(function(e){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e).filter((function(t){return e.propertyIsEnumerable(t)})):[]}(e))}function o(e,t){try{return t in e}catch(e){return!1}}function a(e,i,c){(c=c||{}).arrayMerge=c.arrayMerge||s,c.isMergeableObject=c.isMergeableObject||t,c.cloneUnlessOtherwiseSpecified=n;var l=Array.isArray(i);return l===Array.isArray(e)?l?c.arrayMerge(e,i,c):function(e,t,i){var s={};return i.isMergeableObject(e)&&r(e).forEach((function(t){s[t]=n(e[t],i)})),r(t).forEach((function(r){(function(e,t){return o(e,t)&&!(Object.hasOwnProperty.call(e,t)&&Object.propertyIsEnumerable.call(e,t))})(e,r)||(o(e,r)&&i.isMergeableObject(t[r])?s[r]=function(e,t){if(!t.customMerge)return a;var i=t.customMerge(e);return"function"==typeof i?i:a}(r,i)(e[r],t[r],i):s[r]=n(t[r],i))})),s}(e,i,c):n(i,c)}a.all=function(e,t){if(!Array.isArray(e))throw new Error("first argument should be an array");return e.reduce((function(e,i){return a(e,i,t)}),{})};var c=a;e.exports=c},221:function(e,t,i){function n(e){return Array.isArray?Array.isArray(e):"[object Array]"===l(e)}function s(e){return"string"==typeof e}function r(e){return"number"==typeof e}function o(e){return"object"==typeof e}function a(e){return null!=e}function c(e){return!e.trim().length}function l(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}i.r(t),i.d(t,{default:function(){return R}});const h=Object.prototype.hasOwnProperty;class u{constructor(e){this._keys=[],this._keyMap={};let t=0;e.forEach((e=>{let i=d(e);t+=i.weight,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 d(e){let t=null,i=null,r=null,o=1;if(s(e)||n(e))r=e,t=p(e),i=f(e);else{if(!h.call(e,"name"))throw new Error("Missing name property in key");const n=e.name;if(r=n,h.call(e,"weight")&&(o=e.weight,o<=0))throw new Error((e=>`Property 'weight' in key '${e}' must be a positive integer`)(n));t=p(n),i=f(n)}return{path:t,id:i,weight:o,src:r}}function p(e){return n(e)?e:e.split(".")}function f(e){return n(e)?e.join("."):e}var m={isCaseSensitive:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(e,t)=>e.score===t.score?e.idx{if(a(e))if(t[u]){const d=e[t[u]];if(!a(d))return;if(u===t.length-1&&(s(d)||r(d)||function(e){return!0===e||!1===e||function(e){return o(e)&&null!==e}(e)&&"[object Boolean]"==l(e)}(d)))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)}(d));else if(n(d)){c=!0;for(let e=0,i=d.length;e{this._keysMap[e.id]=t}))}create(){!this.isCreated&&this.docs.length&&(this.isCreated=!0,s(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();s(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 o=this.getFn(e,t.path);if(a(o))if(n(o)){let e=[];const t=[{nestedArrIndex:-1,value:o}];for(;t.length;){const{nestedArrIndex:i,value:r}=t.pop();if(a(r))if(s(r)&&!c(r)){let t={v:r,i:i,n:this.norm.get(r)};e.push(t)}else n(r)&&r.forEach(((e,i)=>{t.push({nestedArrIndex:i,value:e})}))}i.$[r]=e}else if(!c(o)){let e={v:o,n:this.norm.get(o)};i.$[r]=e}})),this.records.push(i)}toJSON(){return{keys:this.keys,records:this.records}}}function _(e,t,{getFn:i=m.getFn,fieldNormWeight:n=m.fieldNormWeight}={}){const s=new g({getFn:i,fieldNormWeight:n});return s.setKeys(e.map(d)),s.setSources(t),s.create(),s}function y(e,{errors:t=0,currentLocation:i=0,expectedLocation:n=0,distance:s=m.distance,ignoreLocation:r=m.ignoreLocation}={}){const o=t/e.length;if(r)return o;const a=Math.abs(n-i);return s?o+a/s:a?1:o}const E=32;function b(e){let t={};for(let i=0,n=e.length;i{this.chunks.push({pattern:e,alphabet:b(e),startIndex:t})},h=this.pattern.length;if(h>E){let e=0;const t=h%E,i=h-t;for(;e{const{isMatch:f,score:v,indices:g}=function(e,t,i,{location:n=m.location,distance:s=m.distance,threshold:r=m.threshold,findAllMatches:o=m.findAllMatches,minMatchCharLength:a=m.minMatchCharLength,includeMatches:c=m.includeMatches,ignoreLocation:l=m.ignoreLocation}={}){if(t.length>E)throw new Error("Pattern length exceeds max of 32.");const h=t.length,u=e.length,d=Math.max(0,Math.min(n,u));let p=r,f=d;const v=a>1||c,g=v?Array(u):[];let _;for(;(_=e.indexOf(t,f))>-1;){let e=y(t,{currentLocation:_,expectedLocation:d,distance:s,ignoreLocation:l});if(p=Math.min(e,p),f=_+h,v){let e=0;for(;e=c;r-=1){let o=r-1,a=i[e.charAt(o)];if(v&&(g[o]=+!!a),_[r]=(_[r+1]<<1|1)&a,n&&(_[r]|=(b[r+1]|b[r])<<1|1|b[r+1]),_[r]&I&&(S=y(t,{errors:n,currentLocation:o,expectedLocation:d,distance:s,ignoreLocation:l}),S<=p)){if(p=S,f=o,f<=d)break;c=Math.max(1,2*d-f)}}if(y(t,{errors:n+1,currentLocation:d,expectedLocation:d,distance:s,ignoreLocation:l})>p)break;b=_}const C={isMatch:f>=0,score:Math.max(.001,S)};if(v){const e=function(e=[],t=m.minMatchCharLength){let i=[],n=-1,s=-1,r=0;for(let o=e.length;r=t&&i.push([n,s]),n=-1)}return e[r-1]&&r-n>=t&&i.push([n,r-1]),i}(g,a);e.length?c&&(C.indices=e):C.isMatch=!1}return C}(e,t,d,{location:n+p,distance:s,threshold:r,findAllMatches:o,minMatchCharLength:a,includeMatches:i,ignoreLocation:c});f&&(u=!0),h+=v,f&&g&&(l=[...l,...g])}));let d={isMatch:u,score:u?h/this.chunks.length:1};return u&&i&&(d.indices=l),d}}class O{constructor(e){this.pattern=e}static isMultiMatch(e){return I(e,this.multiRegex)}static isSingleMatch(e){return I(e,this.singleRegex)}search(){}}function I(e,t){const i=e.match(t);return i?i[1]:null}class C extends O{constructor(e,{location:t=m.location,threshold:i=m.threshold,distance:n=m.distance,includeMatches:s=m.includeMatches,findAllMatches:r=m.findAllMatches,minMatchCharLength:o=m.minMatchCharLength,isCaseSensitive:a=m.isCaseSensitive,ignoreLocation:c=m.ignoreLocation}={}){super(e),this._bitapSearch=new S(e,{location:t,threshold:i,distance:n,includeMatches:s,findAllMatches:r,minMatchCharLength:o,isCaseSensitive:a,ignoreLocation:c})}static get type(){return"fuzzy"}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(e){return this._bitapSearch.searchIn(e)}}class T extends O{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 r=!!n.length;return{isMatch:r,score:r?0:1,indices:n}}}const L=[class extends O{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]}}},T,class extends O{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 O{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 O{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 O{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 O{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]}}},C],w=L.length,A=/ +(?=([^\"]*\"[^\"]*\")*[^\"]*$)/,M=new Set([C.type,T.type]);const P=[];function x(e,t){for(let i=0,n=P.length;i!(!e.$and&&!e.$or),j=e=>({[N]:Object.keys(e).map((t=>({[t]:e[t]})))});function F(e,t,{auto:i=!0}={}){const r=e=>{let a=Object.keys(e);const c=(e=>!!e.$path)(e);if(!c&&a.length>1&&!D(e))return r(j(e));if((e=>!n(e)&&o(e)&&!D(e))(e)){const n=c?e.$path:a[0],r=c?e.$val:e[n];if(!s(r))throw new Error((e=>`Invalid value for key ${e}`)(n));const o={keyId:f(n),pattern:r};return i&&(o.searcher=x(r,t)),o}let l={children:[],operator:a[0]};return a.forEach((t=>{const i=e[t];n(i)&&i.forEach((e=>{l.children.push(r(e))}))})),l};return D(e)||(e=j(e)),r(e)}function k(e,t){const i=e.matches;t.matches=[],a(i)&&i.forEach((e=>{if(!a(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 K(e,t){t.score=e.score}class R{constructor(e,t={},i){this.options={...m,...t},this.options.useExtendedSearch,this._keyStore=new u(this.options.keys),this.setCollection(e,i)}setCollection(e,t){if(this._docs=e,t&&!(t instanceof g))throw new Error("Incorrect 'index' type");this._myIndex=t||_(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(e){a(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 r=e?e.weight:null;i*=Math.pow(0===s&&r?Number.EPSILON:s,(r||1)*(t?1:n))})),e.score=i}))}(l,{ignoreFieldNorm:c}),o&&l.sort(a),r(t)&&t>-1&&(l=l.slice(0,t)),function(e,t,{includeMatches:i=m.includeMatches,includeScore:n=m.includeScore}={}){const s=[];return i&&s.push(k),n&&s.push(K),e.map((e=>{const{idx:i}=e,n={item:t[i],refIndex:i};return s.length&&s.forEach((t=>{t(e,n)})),n}))}(l,this._docs,{includeMatches:i,includeScore:n})}_searchStringList(e){const t=x(e,this.options),{records:i}=this._myIndex,n=[];return i.forEach((({v:e,i:i,n:s})=>{if(!a(e))return;const{isMatch:r,score:o,indices:c}=t.searchIn(e);r&&n.push({item:e,idx:i,matches:[{score:o,value:e,norm:s,indices:c}]})})),n}_searchLogical(e){const t=F(e,this.options),i=(e,t,n)=>{if(!e.children){const{keyId:i,searcher:s}=e,r=this._findMatches({key:this._keyStore.get(i),value:this._myIndex.getValueForItemAtKeyId(t,i),searcher:s});return r&&r.length?[{idx:n,item:t,matches:r}]:[]}const s=[];for(let r=0,o=e.children.length;r{if(a(e)){let o=i(t,e,n);o.length&&(s[n]||(s[n]={idx:n,item:e,matches:[]},r.push(s[n])),o.forEach((({matches:e})=>{s[n].matches.push(...e)})))}})),r}_searchObjectList(e){const t=x(e,this.options),{keys:i,records:n}=this._myIndex,s=[];return n.forEach((({$:e,i:n})=>{if(!a(e))return;let r=[];i.forEach(((i,n)=>{r.push(...this._findMatches({key:i,value:e[n],searcher:t}))})),r.length&&s.push({idx:n,item:e,matches:r})})),s}_findMatches({key:e,value:t,searcher:i}){if(!a(t))return[];let s=[];if(n(t))t.forEach((({v:t,i:n,n:r})=>{if(!a(t))return;const{isMatch:o,score:c,indices:l}=i.searchIn(t);o&&s.push({score:c,key:e,value:t,idx:n,norm:r,indices:l})}));else{const{v:n,n:r}=t,{isMatch:o,score:a,indices:c}=i.searchIn(n);o&&s.push({score:a,key:e,value:n,norm:r,indices:c})}return s}}R.version="6.5.3",R.createIndex=_,R.parseIndex=function(e,{getFn:t=m.getFn,fieldNormWeight:i=m.fieldNormWeight}={}){const{keys:n,records:s}=e,r=new g({getFn:t,fieldNormWeight:i});return r.setKeys(n),r.setIndexRecords(s),r},R.config=m,R.parseQuery=F,function(...e){P.push(...e)}(class{constructor(e,{isCaseSensitive:t=m.isCaseSensitive,includeMatches:i=m.includeMatches,minMatchCharLength:n=m.minMatchCharLength,ignoreLocation:s=m.ignoreLocation,findAllMatches:r=m.findAllMatches,location:o=m.location,threshold:a=m.threshold,distance:c=m.distance}={}){this.query=null,this.options={isCaseSensitive:t,includeMatches:i,minMatchCharLength:n,findAllMatches:r,ignoreLocation:s,location:o,threshold:a,distance:c},this.pattern=t?e:e.toLowerCase(),this.query=function(e,t={}){return e.split("|").map((e=>{let i=e.trim().split(A).filter((e=>e&&!!e.trim())),n=[];for(let e=0,s=i.length;e - + @@ -74,7 +74,7 @@ Choices.js logo

Choices.js

@@ -534,6 +534,7 @@ for (i = 0; i < genericExamples.length; ++i) { var element = genericExamples[i]; new Choices(element, { + allowHTML: true, placeholderValue: 'This is a placeholder set in the config', searchPlaceholderValue: 'This is a search placeholder', }); @@ -542,6 +543,7 @@ var textRemove = new Choices( document.getElementById('choices-text-remove-button'), { + allowHTML: true, delimiter: ',', editItems: true, maxItemCount: 5, @@ -550,12 +552,14 @@ ); var textUniqueVals = new Choices('#choices-text-unique-values', { + allowHTML: true, paste: false, duplicateItemsAllowed: false, editItems: true, }); var texti18n = new Choices('#choices-text-i18n', { + allowHTML: true, paste: false, duplicateItemsAllowed: false, editItems: true, @@ -572,6 +576,7 @@ }); var textEmailFilter = new Choices('#choices-text-email-filter', { + allowHTML: true, editItems: true, addItemFilter: function(value) { if (!value) { @@ -585,6 +590,7 @@ }).setValue(['joe@bloggs.com']); var textDisabled = new Choices('#choices-text-disabled', { + allowHTML: true, addItems: false, removeItems: false, }).disable(); @@ -592,12 +598,14 @@ var textPrependAppendVal = new Choices( '#choices-text-prepend-append-value', { + allowHTML: true, prependValue: 'item-', appendValue: '-' + Date.now(), } ).removeActiveItems(); var textPresetVal = new Choices('#choices-text-preset-values', { + allowHTML: true, items: [ 'Josh Johnson', { @@ -611,10 +619,12 @@ }); var multipleDefault = new Choices( - document.getElementById('choices-multiple-groups') + document.getElementById('choices-multiple-groups'), + { allowHTML: true } ); var multipleFetch = new Choices('#choices-multiple-remote-fetch', { + allowHTML: false, placeholder: true, placeholderValue: 'Pick an Strokes record', maxItemCount: 5, @@ -635,12 +645,14 @@ var multipleCancelButton = new Choices( '#choices-multiple-remove-button', { + allowHTML: true, removeItemButton: true, } ); /* Use label on event */ var choicesSelect = new Choices('#choices-multiple-labels', { + allowHTML: true, removeItemButton: true, choices: [ { value: 'One', label: 'Label One' }, @@ -675,6 +687,7 @@ ); var singleFetch = new Choices('#choices-single-remote-fetch', { + allowHTML: false, searchPlaceholderValue: 'Search for an Arctic Monkeys record', }) .setChoices(function() { @@ -695,6 +708,7 @@ }); var singleXhrRemove = new Choices('#choices-single-remove-xhr', { + allowHTML: true, removeItemButton: true, searchPlaceholderValue: "Search for a Smiths' record", }).setChoices(function(callback) { @@ -711,12 +725,8 @@ }); }); - var genericExamples = new Choices('[data-trigger]', { - placeholderValue: 'This is a placeholder set in the config', - searchPlaceholderValue: 'This is a search placeholder', - }); - var singleNoSearch = new Choices('#choices-single-no-search', { + allowHTML: true, searchEnabled: false, removeItemButton: true, choices: [ @@ -736,6 +746,7 @@ ); var singlePresetOpts = new Choices('#choices-single-preset-options', { + allowHTML: true, placeholder: true, }).setChoices( [ @@ -765,6 +776,7 @@ ); var singleSelectedOpt = new Choices('#choices-single-selected-option', { + allowHTML: true, searchFields: ['label', 'value', 'customProperties.description'], choices: [ { value: 'One', label: 'Label One', selected: true }, @@ -782,17 +794,20 @@ var customChoicesPropertiesViaDataAttributes = new Choices( '#choices-with-custom-props-via-html', { + allowHTML: true, searchFields: ['label', 'value', 'customProperties'], } ); var singleNoSorting = new Choices('#choices-single-no-sorting', { + allowHTML: true, shouldSort: false, }); - var cities = new Choices(document.getElementById('cities')); + var cities = new Choices(document.getElementById('cities'), { allowHTML: true }); var tubeStations = new Choices( - document.getElementById('tube-stations') + document.getElementById('tube-stations'), + { allowHTML: true } ).disable(); cities.passedElement.element.addEventListener('change', function(e) { @@ -806,11 +821,12 @@ var customTemplates = new Choices( document.getElementById('choices-single-custom-templates'), { + allowHTML: true, callbackOnCreateTemplates: function(strToEl) { var classNames = this.config.classNames; var itemSelectText = this.config.itemSelectText; return { - item: function(classNames, data) { + item: function({ classNames }, data) { return strToEl( '\ { + item: T; + score: number; +} +export interface FilterChoicesAction { + type: typeof ACTION_TYPES.FILTER_CHOICES; + results: Result[]; +} +export interface ActivateChoicesAction { + type: typeof ACTION_TYPES.ACTIVATE_CHOICES; + active: boolean; +} +export interface ClearChoicesAction { + type: typeof ACTION_TYPES.CLEAR_CHOICES; +} +export declare const addChoice: ({ value, label, id, groupId, disabled, elementId, customProperties, placeholder, keyCode, }: { + value: any; + label: any; + id: any; + groupId: any; + disabled: any; + elementId: any; + customProperties: any; + placeholder: any; + keyCode: any; +}) => AddChoiceAction; +export declare const filterChoices: (results: Result[]) => FilterChoicesAction; +export declare const activateChoices: (active?: boolean) => ActivateChoicesAction; +export declare const clearChoices: () => ClearChoicesAction; +//# sourceMappingURL=choices.d.ts.map \ No newline at end of file diff --git a/types/src/scripts/actions/choices.d.ts.map b/types/src/scripts/actions/choices.d.ts.map new file mode 100644 index 0000000..2e69e60 --- /dev/null +++ b/types/src/scripts/actions/choices.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"choices.d.ts","sourceRoot":"","sources":["../../../../../src/scripts/actions/choices.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAE9C,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,OAAO,YAAY,CAAC,UAAU,CAAC;IACrC,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,OAAO,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,gBAAgB,EAAE,MAAM,CAAC;IACzB,WAAW,EAAE,OAAO,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,MAAM,CAAC,CAAC;IACvB,IAAI,EAAE,CAAC,CAAC;IACR,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,OAAO,YAAY,CAAC,cAAc,CAAC;IACzC,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;CAC3B;AAED,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,OAAO,YAAY,CAAC,gBAAgB,CAAC;IAC3C,MAAM,EAAE,OAAO,CAAC;CACjB;AAED,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,OAAO,YAAY,CAAC,aAAa,CAAC;CACzC;AAED,eAAO,MAAM,SAAS;;;;;;;;;;MAUlB,eAWF,CAAC;AAEH,eAAO,MAAM,aAAa,YACf,OAAO,MAAM,CAAC,EAAE,KACxB,mBAGD,CAAC;AAEH,eAAO,MAAM,eAAe,wBAAoB,qBAG9C,CAAC;AAEH,eAAO,MAAM,YAAY,QAAO,kBAE9B,CAAC"} \ No newline at end of file diff --git a/types/src/scripts/actions/choices.test.d.ts b/types/src/scripts/actions/choices.test.d.ts new file mode 100644 index 0000000..1b34de1 --- /dev/null +++ b/types/src/scripts/actions/choices.test.d.ts @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=choices.test.d.ts.map \ No newline at end of file diff --git a/types/src/scripts/actions/choices.test.d.ts.map b/types/src/scripts/actions/choices.test.d.ts.map new file mode 100644 index 0000000..0f1c3a5 --- /dev/null +++ b/types/src/scripts/actions/choices.test.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"choices.test.d.ts","sourceRoot":"","sources":["../../../../../src/scripts/actions/choices.test.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/types/src/scripts/actions/groups.d.ts b/types/src/scripts/actions/groups.d.ts new file mode 100644 index 0000000..ad7a8b7 --- /dev/null +++ b/types/src/scripts/actions/groups.d.ts @@ -0,0 +1,15 @@ +import { ACTION_TYPES } from '../constants'; +export interface AddGroupAction { + type: typeof ACTION_TYPES.ADD_GROUP; + id: number; + value: string; + active: boolean; + disabled: boolean; +} +export declare const addGroup: ({ value, id, active, disabled, }: { + id: number; + value: string; + active: boolean; + disabled: boolean; +}) => AddGroupAction; +//# sourceMappingURL=groups.d.ts.map \ No newline at end of file diff --git a/types/src/scripts/actions/groups.d.ts.map b/types/src/scripts/actions/groups.d.ts.map new file mode 100644 index 0000000..4fd7516 --- /dev/null +++ b/types/src/scripts/actions/groups.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"groups.d.ts","sourceRoot":"","sources":["../../../../../src/scripts/actions/groups.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,OAAO,YAAY,CAAC,SAAS,CAAC;IACpC,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,eAAO,MAAM,QAAQ;QAMf,MAAM;WACH,MAAM;YACL,OAAO;cACL,OAAO;MACf,cAMF,CAAC"} \ No newline at end of file diff --git a/types/src/scripts/actions/groups.test.d.ts b/types/src/scripts/actions/groups.test.d.ts new file mode 100644 index 0000000..8d44d56 --- /dev/null +++ b/types/src/scripts/actions/groups.test.d.ts @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=groups.test.d.ts.map \ No newline at end of file diff --git a/types/src/scripts/actions/groups.test.d.ts.map b/types/src/scripts/actions/groups.test.d.ts.map new file mode 100644 index 0000000..80ca388 --- /dev/null +++ b/types/src/scripts/actions/groups.test.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"groups.test.d.ts","sourceRoot":"","sources":["../../../../../src/scripts/actions/groups.test.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/types/src/scripts/actions/items.d.ts b/types/src/scripts/actions/items.d.ts new file mode 100644 index 0000000..96b0b2a --- /dev/null +++ b/types/src/scripts/actions/items.d.ts @@ -0,0 +1,35 @@ +import { ACTION_TYPES } from '../constants'; +export interface AddItemAction { + type: typeof ACTION_TYPES.ADD_ITEM; + id: number; + value: string; + label: string; + choiceId: number; + groupId: number; + customProperties: object; + placeholder: boolean; + keyCode: number; +} +export interface RemoveItemAction { + type: typeof ACTION_TYPES.REMOVE_ITEM; + id: number; + choiceId: number; +} +export interface HighlightItemAction { + type: typeof ACTION_TYPES.HIGHLIGHT_ITEM; + id: number; + highlighted: boolean; +} +export declare const addItem: ({ value, label, id, choiceId, groupId, customProperties, placeholder, keyCode, }: { + id: number; + value: string; + label: string; + choiceId: number; + groupId: number; + customProperties: object; + placeholder: boolean; + keyCode: number; +}) => AddItemAction; +export declare const removeItem: (id: number, choiceId: number) => RemoveItemAction; +export declare const highlightItem: (id: number, highlighted: boolean) => HighlightItemAction; +//# sourceMappingURL=items.d.ts.map \ No newline at end of file diff --git a/types/src/scripts/actions/items.d.ts.map b/types/src/scripts/actions/items.d.ts.map new file mode 100644 index 0000000..2ad2590 --- /dev/null +++ b/types/src/scripts/actions/items.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"items.d.ts","sourceRoot":"","sources":["../../../../../src/scripts/actions/items.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,OAAO,YAAY,CAAC,QAAQ,CAAC;IACnC,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,gBAAgB,EAAE,MAAM,CAAC;IACzB,WAAW,EAAE,OAAO,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,OAAO,YAAY,CAAC,WAAW,CAAC;IACtC,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,OAAO,YAAY,CAAC,cAAc,CAAC;IACzC,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,OAAO,CAAC;CACtB;AAED,eAAO,MAAM,OAAO;QAUd,MAAM;WACH,MAAM;WACN,MAAM;cACH,MAAM;aACP,MAAM;sBACG,MAAM;iBACX,OAAO;aACX,MAAM;MACb,aAUF,CAAC;AAEH,eAAO,MAAM,UAAU,OAAQ,MAAM,YAAY,MAAM,KAAG,gBAIxD,CAAC;AAEH,eAAO,MAAM,aAAa,OACpB,MAAM,eACG,OAAO,KACnB,mBAID,CAAC"} \ No newline at end of file diff --git a/types/src/scripts/actions/items.test.d.ts b/types/src/scripts/actions/items.test.d.ts new file mode 100644 index 0000000..e81d58b --- /dev/null +++ b/types/src/scripts/actions/items.test.d.ts @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=items.test.d.ts.map \ No newline at end of file diff --git a/types/src/scripts/actions/items.test.d.ts.map b/types/src/scripts/actions/items.test.d.ts.map new file mode 100644 index 0000000..77773c2 --- /dev/null +++ b/types/src/scripts/actions/items.test.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"items.test.d.ts","sourceRoot":"","sources":["../../../../../src/scripts/actions/items.test.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/types/src/scripts/actions/misc.d.ts b/types/src/scripts/actions/misc.d.ts new file mode 100644 index 0000000..65e1faf --- /dev/null +++ b/types/src/scripts/actions/misc.d.ts @@ -0,0 +1,17 @@ +import { ACTION_TYPES } from '../constants'; +import { State } from '../interfaces/state'; +export interface ClearAllAction { + type: typeof ACTION_TYPES.CLEAR_ALL; +} +export interface ResetToAction { + type: typeof ACTION_TYPES.RESET_TO; + state: State; +} +export interface SetIsLoadingAction { + type: typeof ACTION_TYPES.SET_IS_LOADING; + isLoading: boolean; +} +export declare const clearAll: () => ClearAllAction; +export declare const resetTo: (state: State) => ResetToAction; +export declare const setIsLoading: (isLoading: boolean) => SetIsLoadingAction; +//# sourceMappingURL=misc.d.ts.map \ No newline at end of file diff --git a/types/src/scripts/actions/misc.d.ts.map b/types/src/scripts/actions/misc.d.ts.map new file mode 100644 index 0000000..0e77eb2 --- /dev/null +++ b/types/src/scripts/actions/misc.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"misc.d.ts","sourceRoot":"","sources":["../../../../../src/scripts/actions/misc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAE5C,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,OAAO,YAAY,CAAC,SAAS,CAAC;CACrC;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,OAAO,YAAY,CAAC,QAAQ,CAAC;IACnC,KAAK,EAAE,KAAK,CAAC;CACd;AAED,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,OAAO,YAAY,CAAC,cAAc,CAAC;IACzC,SAAS,EAAE,OAAO,CAAC;CACpB;AAED,eAAO,MAAM,QAAQ,QAAO,cAE1B,CAAC;AAEH,eAAO,MAAM,OAAO,UAAW,KAAK,KAAG,aAGrC,CAAC;AAEH,eAAO,MAAM,YAAY,cAAe,OAAO,KAAG,kBAGhD,CAAC"} \ No newline at end of file diff --git a/types/src/scripts/actions/misc.test.d.ts b/types/src/scripts/actions/misc.test.d.ts new file mode 100644 index 0000000..c81b2cc --- /dev/null +++ b/types/src/scripts/actions/misc.test.d.ts @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=misc.test.d.ts.map \ No newline at end of file diff --git a/types/src/scripts/actions/misc.test.d.ts.map b/types/src/scripts/actions/misc.test.d.ts.map new file mode 100644 index 0000000..912fa18 --- /dev/null +++ b/types/src/scripts/actions/misc.test.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"misc.test.d.ts","sourceRoot":"","sources":["../../../../../src/scripts/actions/misc.test.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/types/src/scripts/choices.d.ts b/types/src/scripts/choices.d.ts new file mode 100644 index 0000000..9ea386b --- /dev/null +++ b/types/src/scripts/choices.d.ts @@ -0,0 +1,218 @@ +import { Container, Dropdown, Input, List, WrappedInput, WrappedSelect } from './components'; +import { Choice } from './interfaces/choice'; +import { Group } from './interfaces/group'; +import { Item } from './interfaces/item'; +import { Notice } from './interfaces/notice'; +import { Options } from './interfaces/options'; +import { State } from './interfaces/state'; +import Store from './store/store'; +import templates from './templates'; +/** + * Choices + * @author Josh Johnson + */ +declare class Choices implements Choices { + static get defaults(): { + options: Partial; + templates: typeof templates; + }; + initialised: boolean; + config: Options; + passedElement: WrappedInput | WrappedSelect; + containerOuter: Container; + containerInner: Container; + choiceList: List; + itemList: List; + input: Input; + dropdown: Dropdown; + _isTextElement: boolean; + _isSelectOneElement: boolean; + _isSelectMultipleElement: boolean; + _isSelectElement: boolean; + _store: Store; + _templates: typeof templates; + _initialState: State; + _currentState: State; + _prevState: State; + _currentValue: string; + _canSearch: boolean; + _isScrollingOnIe: boolean; + _highlightPosition: number; + _wasTap: boolean; + _isSearching: boolean; + _placeholderValue: string | null; + _baseId: string; + _direction: HTMLElement['dir']; + _idNames: { + itemChoice: string; + }; + _presetGroups: Group[] | HTMLOptGroupElement[] | Element[]; + _presetOptions: Item[] | HTMLOptionElement[]; + _presetChoices: Partial[]; + _presetItems: Item[] | string[]; + constructor(element?: string | Element | HTMLInputElement | HTMLSelectElement, userConfig?: Partial); + init(): void; + destroy(): void; + enable(): this; + disable(): this; + highlightItem(item: Item, runEvent?: boolean): this; + unhighlightItem(item: Item): this; + highlightAll(): this; + unhighlightAll(): this; + removeActiveItemsByValue(value: string): this; + removeActiveItems(excludedId: number): this; + removeHighlightedItems(runEvent?: boolean): this; + showDropdown(preventInputFocus?: boolean): this; + hideDropdown(preventInputBlur?: boolean): this; + getValue(valueOnly?: boolean): string[] | Item[] | Item | string; + setValue(items: string[] | Item[]): this; + setChoiceByValue(value: string): this; + /** + * Set choices of select input via an array of objects (or function that returns array of object or promise of it), + * a value field name and a label field name. + * This behaves the same as passing items via the choices option but can be called after initialising Choices. + * This can also be used to add groups of choices (see example 2); Optionally pass a true `replaceChoices` value to remove any existing choices. + * Optionally pass a `customProperties` object to add additional data to your choices (useful when searching/filtering etc). + * + * **Input types affected:** select-one, select-multiple + * + * @example + * ```js + * const example = new Choices(element); + * + * example.setChoices([ + * {value: 'One', label: 'Label One', disabled: true}, + * {value: 'Two', label: 'Label Two', selected: true}, + * {value: 'Three', label: 'Label Three'}, + * ], 'value', 'label', false); + * ``` + * + * @example + * ```js + * const example = new Choices(element); + * + * example.setChoices(async () => { + * try { + * const items = await fetch('/items'); + * return items.json() + * } catch(err) { + * console.error(err) + * } + * }); + * ``` + * + * @example + * ```js + * const example = new Choices(element); + * + * example.setChoices([{ + * label: 'Group one', + * id: 1, + * disabled: false, + * choices: [ + * {value: 'Child One', label: 'Child One', selected: true}, + * {value: 'Child Two', label: 'Child Two', disabled: true}, + * {value: 'Child Three', label: 'Child Three'}, + * ] + * }, + * { + * label: 'Group two', + * id: 2, + * disabled: false, + * choices: [ + * {value: 'Child Four', label: 'Child Four', disabled: true}, + * {value: 'Child Five', label: 'Child Five'}, + * {value: 'Child Six', label: 'Child Six', customProperties: { + * description: 'Custom description about child six', + * random: 'Another random custom property' + * }}, + * ] + * }], 'value', 'label', false); + * ``` + */ + setChoices(choicesArrayOrFetcher?: Choice[] | Group[] | ((instance: Choices) => Choice[] | Promise), value?: string, label?: string, replaceChoices?: boolean): this | Promise; + clearChoices(): this; + clearStore(): this; + clearInput(): this; + _render(): void; + _renderChoices(): void; + _renderItems(): void; + _createGroupsFragment(groups: Group[], choices: Choice[], fragment?: DocumentFragment): DocumentFragment; + _createChoicesFragment(choices: Choice[], fragment?: DocumentFragment, withinGroup?: boolean): DocumentFragment; + _createItemsFragment(items: Item[], fragment?: DocumentFragment): DocumentFragment; + _triggerChange(value: any): void; + _selectPlaceholderChoice(placeholderChoice: Choice): void; + _handleButtonAction(activeItems?: Item[], element?: HTMLElement): void; + _handleItemAction(activeItems?: Item[], element?: HTMLElement, hasShiftKey?: boolean): void; + _handleChoiceAction(activeItems?: Item[], element?: HTMLElement): void; + _handleBackspace(activeItems?: Item[]): void; + _startLoading(): void; + _stopLoading(): void; + _handleLoadingState(setLoading?: boolean): void; + _handleSearch(value: string): void; + _canAddItem(activeItems: Item[], value: string): Notice; + _searchChoices(value: string): number; + _addEventListeners(): void; + _removeEventListeners(): void; + _onKeyDown(event: KeyboardEvent): void; + _onKeyUp({ target, keyCode, }: Pick): void; + _onSelectKey(event: KeyboardEvent, hasItems: boolean): void; + _onEnterKey(event: KeyboardEvent, activeItems: Item[], hasActiveDropdown: boolean): void; + _onEscapeKey(hasActiveDropdown: boolean): void; + _onDirectionKey(event: KeyboardEvent, hasActiveDropdown: boolean): void; + _onDeleteKey(event: KeyboardEvent, activeItems: Item[], hasFocusedInput: boolean): void; + _onTouchMove(): void; + _onTouchEnd(event: TouchEvent): void; + /** + * Handles mousedown event in capture mode for containetOuter.element + */ + _onMouseDown(event: MouseEvent): void; + /** + * Handles mouseover event over this.dropdown + * @param {MouseEvent} event + */ + _onMouseOver({ target }: Pick): void; + _onClick({ target }: Pick): void; + _onFocus({ target }: Pick): void; + _onBlur({ target }: Pick): void; + _onFormReset(): void; + _highlightChoice(el?: HTMLElement | null): void; + _addItem({ value, label, choiceId, groupId, customProperties, placeholder, keyCode, }: { + value: string; + label?: string | null; + choiceId?: number; + groupId?: number; + customProperties?: object; + placeholder?: boolean; + keyCode?: number; + }): void; + _removeItem(item: Item): void; + _addChoice({ value, label, isSelected, isDisabled, groupId, customProperties, placeholder, keyCode, }: { + value: string; + label?: string | null; + isSelected?: boolean; + isDisabled?: boolean; + groupId?: number; + customProperties?: Record; + placeholder?: boolean; + keyCode?: number; + }): void; + _addGroup({ group, id, valueKey, labelKey }: { + group: any; + id: any; + valueKey?: string | undefined; + labelKey?: string | undefined; + }): void; + _getTemplate(template: string, ...args: any): any; + _createTemplates(): void; + _createElements(): void; + _createStructure(): void; + _addPredefinedGroups(groups: Group[] | HTMLOptGroupElement[] | Element[]): void; + _addPredefinedChoices(choices: Partial[]): void; + _addPredefinedItems(items: Item[] | string[]): void; + _setChoiceOrItem(item: any): void; + _findAndSelectChoiceByValue(value: string): void; + _generatePlaceholderValue(): string | null; +} +export default Choices; +//# sourceMappingURL=choices.d.ts.map \ No newline at end of file diff --git a/types/src/scripts/choices.d.ts.map b/types/src/scripts/choices.d.ts.map new file mode 100644 index 0000000..6f199c3 --- /dev/null +++ b/types/src/scripts/choices.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"choices.d.ts","sourceRoot":"","sources":["../../../../src/scripts/choices.ts"],"names":[],"mappings":"AAcA,OAAO,EACL,SAAS,EACT,QAAQ,EACR,KAAK,EACL,IAAI,EACJ,YAAY,EACZ,aAAa,EACd,MAAM,cAAc,CAAC;AAStB,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAE/C,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAc3C,OAAO,KAAK,MAAM,eAAe,CAAC;AAClC,OAAO,SAAS,MAAM,aAAa,CAAC;AASpC;;;GAGG;AACH,cAAM,OAAQ,YAAW,OAAO;IAC9B,MAAM,KAAK,QAAQ,IAAI;QACrB,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;QAC1B,SAAS,EAAE,OAAO,SAAS,CAAC;KAC7B,CASA;IAED,WAAW,EAAE,OAAO,CAAC;IAErB,MAAM,EAAE,OAAO,CAAC;IAEhB,aAAa,EAAE,YAAY,GAAG,aAAa,CAAC;IAE5C,cAAc,EAAE,SAAS,CAAC;IAE1B,cAAc,EAAE,SAAS,CAAC;IAE1B,UAAU,EAAE,IAAI,CAAC;IAEjB,QAAQ,EAAE,IAAI,CAAC;IAEf,KAAK,EAAE,KAAK,CAAC;IAEb,QAAQ,EAAE,QAAQ,CAAC;IAEnB,cAAc,EAAE,OAAO,CAAC;IAExB,mBAAmB,EAAE,OAAO,CAAC;IAE7B,wBAAwB,EAAE,OAAO,CAAC;IAElC,gBAAgB,EAAE,OAAO,CAAC;IAE1B,MAAM,EAAE,KAAK,CAAC;IAEd,UAAU,EAAE,OAAO,SAAS,CAAC;IAE7B,aAAa,EAAE,KAAK,CAAC;IAErB,aAAa,EAAE,KAAK,CAAC;IAErB,UAAU,EAAE,KAAK,CAAC;IAElB,aAAa,EAAE,MAAM,CAAC;IAEtB,UAAU,EAAE,OAAO,CAAC;IAEpB,gBAAgB,EAAE,OAAO,CAAC;IAE1B,kBAAkB,EAAE,MAAM,CAAC;IAE3B,OAAO,EAAE,OAAO,CAAC;IAEjB,YAAY,EAAE,OAAO,CAAC;IAEtB,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;IAEjC,OAAO,EAAE,MAAM,CAAC;IAEhB,UAAU,EAAE,WAAW,CAAC,KAAK,CAAC,CAAC;IAE/B,QAAQ,EAAE;QACR,UAAU,EAAE,MAAM,CAAC;KACpB,CAAC;IAEF,aAAa,EAAE,KAAK,EAAE,GAAG,mBAAmB,EAAE,GAAG,OAAO,EAAE,CAAC;IAE3D,cAAc,EAAE,IAAI,EAAE,GAAG,iBAAiB,EAAE,CAAC;IAE7C,cAAc,EAAE,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;IAElC,YAAY,EAAE,IAAI,EAAE,GAAG,MAAM,EAAE,CAAC;gBAG9B,OAAO,GACH,MAAM,GACN,OAAO,GACP,gBAAgB,GAChB,iBAAmC,EACvC,UAAU,GAAE,OAAO,CAAC,OAAO,CAAM;IAqLnC,IAAI,IAAI,IAAI;IA+BZ,OAAO,IAAI,IAAI;IAmBf,MAAM,IAAI,IAAI;IAcd,OAAO,IAAI,IAAI;IAcf,aAAa,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,UAAO,GAAG,IAAI;IAsBhD,eAAe,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI;IAmBjC,YAAY,IAAI,IAAI;IAMpB,cAAc,IAAI,IAAI;IAMtB,wBAAwB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAQ7C,iBAAiB,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAQ3C,sBAAsB,CAAC,QAAQ,UAAQ,GAAG,IAAI;IAa9C,YAAY,CAAC,iBAAiB,CAAC,EAAE,OAAO,GAAG,IAAI;IAmB/C,YAAY,CAAC,gBAAgB,CAAC,EAAE,OAAO,GAAG,IAAI;IAoB9C,QAAQ,CAAC,SAAS,UAAQ,GAAG,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,IAAI,GAAG,MAAM;IAc9D,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,IAAI;IAUxC,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAcrC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8DG;IACH,UAAU,CACR,qBAAqB,GACjB,MAAM,EAAE,GACR,KAAK,EAAE,GACP,CAAC,CAAC,QAAQ,EAAE,OAAO,KAAK,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAAM,EAC9D,KAAK,SAAU,EACf,KAAK,SAAU,EACf,cAAc,UAAQ,GACrB,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IA+FvB,YAAY,IAAI,IAAI;IAMpB,UAAU,IAAI,IAAI;IAMlB,UAAU,IAAI,IAAI;IAYlB,OAAO,IAAI,IAAI;IA8Bf,cAAc,IAAI,IAAI;IA6EtB,YAAY,IAAI,IAAI;IAcpB,qBAAqB,CACnB,MAAM,EAAE,KAAK,EAAE,EACf,OAAO,EAAE,MAAM,EAAE,EACjB,QAAQ,GAAE,gBAAoD,GAC7D,gBAAgB;IA8BnB,sBAAsB,CACpB,OAAO,EAAE,MAAM,EAAE,EACjB,QAAQ,GAAE,gBAAoD,EAC9D,WAAW,UAAQ,GAClB,gBAAgB;IAyEnB,oBAAoB,CAClB,KAAK,EAAE,IAAI,EAAE,EACb,QAAQ,GAAE,gBAAoD,GAC7D,gBAAgB;IAgCnB,cAAc,CAAC,KAAK,KAAA,GAAG,IAAI;IAU3B,wBAAwB,CAAC,iBAAiB,EAAE,MAAM,GAAG,IAAI;IAYzD,mBAAmB,CAAC,WAAW,CAAC,EAAE,IAAI,EAAE,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,IAAI;IA4BtE,iBAAiB,CACf,WAAW,CAAC,EAAE,IAAI,EAAE,EACpB,OAAO,CAAC,EAAE,WAAW,EACrB,WAAW,UAAQ,GAClB,IAAI;IA4BP,mBAAmB,CAAC,WAAW,CAAC,EAAE,IAAI,EAAE,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,IAAI;IAoDtE,gBAAgB,CAAC,WAAW,CAAC,EAAE,IAAI,EAAE,GAAG,IAAI;IAwB5C,aAAa,IAAI,IAAI;IAIrB,YAAY,IAAI,IAAI;IAIpB,mBAAmB,CAAC,UAAU,UAAO,GAAG,IAAI;IAuC5C,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IA4BlC,WAAW,CAAC,WAAW,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM;IAwDvD,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IA6BrC,kBAAkB,IAAI,IAAI;IAsD1B,qBAAqB,IAAI,IAAI;IAmC7B,UAAU,CAAC,KAAK,EAAE,aAAa,GAAG,IAAI;IAqDtC,QAAQ,CAAC,EACP,MAAM,EACN,OAAO,GACR,EAAE,IAAI,CAAC,aAAa,EAAE,QAAQ,GAAG,SAAS,CAAC,GAAG,IAAI;IAoCnD,YAAY,CAAC,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,OAAO,GAAG,IAAI;IAmB3D,WAAW,CACT,KAAK,EAAE,aAAa,EACpB,WAAW,EAAE,IAAI,EAAE,EACnB,iBAAiB,EAAE,OAAO,GACzB,IAAI;IA2CP,YAAY,CAAC,iBAAiB,EAAE,OAAO,GAAG,IAAI;IAO9C,eAAe,CAAC,KAAK,EAAE,aAAa,EAAE,iBAAiB,EAAE,OAAO,GAAG,IAAI;IAgEvE,YAAY,CACV,KAAK,EAAE,aAAa,EACpB,WAAW,EAAE,IAAI,EAAE,EACnB,eAAe,EAAE,OAAO,GACvB,IAAI;IAaP,YAAY,IAAI,IAAI;IAMpB,WAAW,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI;IAyBpC;;OAEG;IACH,YAAY,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI;IAyCrC;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,EAAE,EAAE,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC,GAAG,IAAI;IAM1D,QAAQ,CAAC,EAAE,MAAM,EAAE,EAAE,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC,GAAG,IAAI;IAkCtD,QAAQ,CAAC,EAAE,MAAM,EAAE,EAAE,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC,GAAG,IAAI;IAiCtD,OAAO,CAAC,EAAE,MAAM,EAAE,EAAE,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC,GAAG,IAAI;IA+CrD,YAAY,IAAI,IAAI;IAIpB,gBAAgB,CAAC,EAAE,GAAE,WAAW,GAAG,IAAW,GAAG,IAAI;IAmDrD,QAAQ,CAAC,EACP,KAAK,EACL,KAAY,EACZ,QAAa,EACb,OAAY,EACZ,gBAAqB,EACrB,WAAmB,EACnB,OAAY,GACb,EAAE;QACD,KAAK,EAAE,MAAM,CAAC;QACd,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,gBAAgB,CAAC,EAAE,MAAM,CAAC;QAC1B,WAAW,CAAC,EAAE,OAAO,CAAC;QACtB,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,GAAG,IAAI;IA+CR,WAAW,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI;IAmB7B,UAAU,CAAC,EACT,KAAK,EACL,KAAY,EACZ,UAAkB,EAClB,UAAkB,EAClB,OAAY,EACZ,gBAAqB,EACrB,WAAmB,EACnB,OAAY,GACb,EAAE;QACD,KAAK,EAAE,MAAM,CAAC;QACd,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QACtB,UAAU,CAAC,EAAE,OAAO,CAAC;QACrB,UAAU,CAAC,EAAE,OAAO,CAAC;QACrB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QACvC,WAAW,CAAC,EAAE,OAAO,CAAC;QACtB,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,GAAG,IAAI;IAqCR,SAAS,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,QAAkB,EAAE,QAAkB,EAAE;;;;;KAAA,GAAG,IAAI;IA6CtE,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,GAAG,GAAG;IAIjD,gBAAgB,IAAI,IAAI;IAcxB,eAAe,IAAI,IAAI;IA4CvB,gBAAgB,IAAI,IAAI;IAmDxB,oBAAoB,CAClB,MAAM,EAAE,KAAK,EAAE,GAAG,mBAAmB,EAAE,GAAG,OAAO,EAAE,GAClD,IAAI;IA2BP,qBAAqB,CAAC,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,EAAE,GAAG,IAAI;IA0DvD,mBAAmB,CAAC,KAAK,EAAE,IAAI,EAAE,GAAG,MAAM,EAAE,GAAG,IAAI;IAoBnD,gBAAgB,CAAC,IAAI,EAAE,GAAG,GAAG,IAAI;IAgDjC,2BAA2B,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAoBhD,yBAAyB,IAAI,MAAM,GAAG,IAAI;CA2B3C;AAED,eAAe,OAAO,CAAC"} \ No newline at end of file diff --git a/types/src/scripts/choices.test.d.ts b/types/src/scripts/choices.test.d.ts new file mode 100644 index 0000000..1b34de1 --- /dev/null +++ b/types/src/scripts/choices.test.d.ts @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=choices.test.d.ts.map \ No newline at end of file diff --git a/types/src/scripts/choices.test.d.ts.map b/types/src/scripts/choices.test.d.ts.map new file mode 100644 index 0000000..13f8b43 --- /dev/null +++ b/types/src/scripts/choices.test.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"choices.test.d.ts","sourceRoot":"","sources":["../../../../src/scripts/choices.test.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/types/src/scripts/components/container.d.ts b/types/src/scripts/components/container.d.ts new file mode 100644 index 0000000..ad8ac4e --- /dev/null +++ b/types/src/scripts/components/container.d.ts @@ -0,0 +1,43 @@ +import { ClassNames } from '../interfaces/class-names'; +import { PositionOptionsType } from '../interfaces/position-options-type'; +import { PassedElementType } from '../interfaces/passed-element-type'; +export default class Container { + element: HTMLElement; + type: PassedElementType; + classNames: ClassNames; + position: PositionOptionsType; + isOpen: boolean; + isFlipped: boolean; + isFocussed: boolean; + isDisabled: boolean; + isLoading: boolean; + constructor({ element, type, classNames, position, }: { + element: HTMLElement; + type: PassedElementType; + classNames: ClassNames; + position: PositionOptionsType; + }); + addEventListeners(): void; + removeEventListeners(): void; + /** + * Determine whether container should be flipped based on passed + * dropdown position + */ + shouldFlip(dropdownPos: number): boolean; + setActiveDescendant(activeDescendantID: string): void; + removeActiveDescendant(): void; + open(dropdownPos: number): void; + close(): void; + focus(): void; + addFocusState(): void; + removeFocusState(): void; + enable(): void; + disable(): void; + wrap(element: HTMLSelectElement | HTMLInputElement | HTMLElement): void; + unwrap(element: HTMLElement): void; + addLoadingState(): void; + removeLoadingState(): void; + _onFocus(): void; + _onBlur(): void; +} +//# sourceMappingURL=container.d.ts.map \ No newline at end of file diff --git a/types/src/scripts/components/container.d.ts.map b/types/src/scripts/components/container.d.ts.map new file mode 100644 index 0000000..e253b2f --- /dev/null +++ b/types/src/scripts/components/container.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"container.d.ts","sourceRoot":"","sources":["../../../../../src/scripts/components/container.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAC1E,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAEtE,MAAM,CAAC,OAAO,OAAO,SAAS;IAC5B,OAAO,EAAE,WAAW,CAAC;IAErB,IAAI,EAAE,iBAAiB,CAAC;IAExB,UAAU,EAAE,UAAU,CAAC;IAEvB,QAAQ,EAAE,mBAAmB,CAAC;IAE9B,MAAM,EAAE,OAAO,CAAC;IAEhB,SAAS,EAAE,OAAO,CAAC;IAEnB,UAAU,EAAE,OAAO,CAAC;IAEpB,UAAU,EAAE,OAAO,CAAC;IAEpB,SAAS,EAAE,OAAO,CAAC;gBAEP,EACV,OAAO,EACP,IAAI,EACJ,UAAU,EACV,QAAQ,GACT,EAAE;QACD,OAAO,EAAE,WAAW,CAAC;QACrB,IAAI,EAAE,iBAAiB,CAAC;QACxB,UAAU,EAAE,UAAU,CAAC;QACvB,QAAQ,EAAE,mBAAmB,CAAC;KAC/B;IAcD,iBAAiB,IAAI,IAAI;IAKzB,oBAAoB,IAAI,IAAI;IAK5B;;;OAGG;IACH,UAAU,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO;IAkBxC,mBAAmB,CAAC,kBAAkB,EAAE,MAAM,GAAG,IAAI;IAIrD,sBAAsB,IAAI,IAAI;IAI9B,IAAI,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI;IAW/B,KAAK,IAAI,IAAI;IAab,KAAK,IAAI,IAAI;IAMb,aAAa,IAAI,IAAI;IAIrB,gBAAgB,IAAI,IAAI;IAIxB,MAAM,IAAI,IAAI;IASd,OAAO,IAAI,IAAI;IASf,IAAI,CAAC,OAAO,EAAE,iBAAiB,GAAG,gBAAgB,GAAG,WAAW,GAAG,IAAI;IAIvE,MAAM,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI;IASlC,eAAe,IAAI,IAAI;IAMvB,kBAAkB,IAAI,IAAI;IAM1B,QAAQ,IAAI,IAAI;IAIhB,OAAO,IAAI,IAAI;CAGhB"} \ No newline at end of file diff --git a/types/src/scripts/components/container.test.d.ts b/types/src/scripts/components/container.test.d.ts new file mode 100644 index 0000000..1628d9d --- /dev/null +++ b/types/src/scripts/components/container.test.d.ts @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=container.test.d.ts.map \ No newline at end of file diff --git a/types/src/scripts/components/container.test.d.ts.map b/types/src/scripts/components/container.test.d.ts.map new file mode 100644 index 0000000..85b9faa --- /dev/null +++ b/types/src/scripts/components/container.test.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"container.test.d.ts","sourceRoot":"","sources":["../../../../../src/scripts/components/container.test.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/types/src/scripts/components/dropdown.d.ts b/types/src/scripts/components/dropdown.d.ts new file mode 100644 index 0000000..a6f5742 --- /dev/null +++ b/types/src/scripts/components/dropdown.d.ts @@ -0,0 +1,27 @@ +import { ClassNames } from '../interfaces/class-names'; +import { PassedElementType } from '../interfaces/passed-element-type'; +export default class Dropdown { + element: HTMLElement; + type: PassedElementType; + classNames: ClassNames; + isActive: boolean; + constructor({ element, type, classNames, }: { + element: HTMLElement; + type: PassedElementType; + classNames: ClassNames; + }); + /** + * Bottom position of dropdown in viewport coordinates + */ + get distanceFromTopWindow(): number; + getChild(selector: string): HTMLElement | null; + /** + * Show dropdown to user by adding active state class + */ + show(): this; + /** + * Hide dropdown from user + */ + hide(): this; +} +//# sourceMappingURL=dropdown.d.ts.map \ No newline at end of file diff --git a/types/src/scripts/components/dropdown.d.ts.map b/types/src/scripts/components/dropdown.d.ts.map new file mode 100644 index 0000000..129ec11 --- /dev/null +++ b/types/src/scripts/components/dropdown.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"dropdown.d.ts","sourceRoot":"","sources":["../../../../../src/scripts/components/dropdown.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAEtE,MAAM,CAAC,OAAO,OAAO,QAAQ;IAC3B,OAAO,EAAE,WAAW,CAAC;IAErB,IAAI,EAAE,iBAAiB,CAAC;IAExB,UAAU,EAAE,UAAU,CAAC;IAEvB,QAAQ,EAAE,OAAO,CAAC;gBAEN,EACV,OAAO,EACP,IAAI,EACJ,UAAU,GACX,EAAE;QACD,OAAO,EAAE,WAAW,CAAC;QACrB,IAAI,EAAE,iBAAiB,CAAC;QACxB,UAAU,EAAE,UAAU,CAAC;KACxB;IAOD;;OAEG;IACH,IAAI,qBAAqB,IAAI,MAAM,CAElC;IAED,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,WAAW,GAAG,IAAI;IAI9C;;OAEG;IACH,IAAI,IAAI,IAAI;IAQZ;;OAEG;IACH,IAAI,IAAI,IAAI;CAOb"} \ No newline at end of file diff --git a/types/src/scripts/components/dropdown.test.d.ts b/types/src/scripts/components/dropdown.test.d.ts new file mode 100644 index 0000000..2dff0fa --- /dev/null +++ b/types/src/scripts/components/dropdown.test.d.ts @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=dropdown.test.d.ts.map \ No newline at end of file diff --git a/types/src/scripts/components/dropdown.test.d.ts.map b/types/src/scripts/components/dropdown.test.d.ts.map new file mode 100644 index 0000000..4c26ccd --- /dev/null +++ b/types/src/scripts/components/dropdown.test.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"dropdown.test.d.ts","sourceRoot":"","sources":["../../../../../src/scripts/components/dropdown.test.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/types/src/scripts/components/index.d.ts b/types/src/scripts/components/index.d.ts new file mode 100644 index 0000000..b37addf --- /dev/null +++ b/types/src/scripts/components/index.d.ts @@ -0,0 +1,8 @@ +import Dropdown from './dropdown'; +import Container from './container'; +import Input from './input'; +import List from './list'; +import WrappedInput from './wrapped-input'; +import WrappedSelect from './wrapped-select'; +export { Dropdown, Container, Input, List, WrappedInput, WrappedSelect }; +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/types/src/scripts/components/index.d.ts.map b/types/src/scripts/components/index.d.ts.map new file mode 100644 index 0000000..4e478ab --- /dev/null +++ b/types/src/scripts/components/index.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/scripts/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,YAAY,CAAC;AAClC,OAAO,SAAS,MAAM,aAAa,CAAC;AACpC,OAAO,KAAK,MAAM,SAAS,CAAC;AAC5B,OAAO,IAAI,MAAM,QAAQ,CAAC;AAC1B,OAAO,YAAY,MAAM,iBAAiB,CAAC;AAC3C,OAAO,aAAa,MAAM,kBAAkB,CAAC;AAE7C,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE,YAAY,EAAE,aAAa,EAAE,CAAC"} \ No newline at end of file diff --git a/types/src/scripts/components/input.d.ts b/types/src/scripts/components/input.d.ts new file mode 100644 index 0000000..3b36571 --- /dev/null +++ b/types/src/scripts/components/input.d.ts @@ -0,0 +1,39 @@ +import { ClassNames } from '../interfaces/class-names'; +import { PassedElementType } from '../interfaces/passed-element-type'; +export default class Input { + element: HTMLInputElement; + type: PassedElementType; + classNames: ClassNames; + preventPaste: boolean; + isFocussed: boolean; + isDisabled: boolean; + constructor({ element, type, classNames, preventPaste, }: { + element: HTMLInputElement; + type: PassedElementType; + classNames: ClassNames; + preventPaste: boolean; + }); + set placeholder(placeholder: string); + get value(): string; + set value(value: string); + get rawValue(): string; + addEventListeners(): void; + removeEventListeners(): void; + enable(): void; + disable(): void; + focus(): void; + blur(): void; + clear(setWidth?: boolean): this; + /** + * Set the correct input width based on placeholder + * value or input value + */ + setWidth(): void; + setActiveDescendant(activeDescendantID: string): void; + removeActiveDescendant(): void; + _onInput(): void; + _onPaste(event: ClipboardEvent): void; + _onFocus(): void; + _onBlur(): void; +} +//# sourceMappingURL=input.d.ts.map \ No newline at end of file diff --git a/types/src/scripts/components/input.d.ts.map b/types/src/scripts/components/input.d.ts.map new file mode 100644 index 0000000..8828eb1 --- /dev/null +++ b/types/src/scripts/components/input.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"input.d.ts","sourceRoot":"","sources":["../../../../../src/scripts/components/input.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAEtE,MAAM,CAAC,OAAO,OAAO,KAAK;IACxB,OAAO,EAAE,gBAAgB,CAAC;IAE1B,IAAI,EAAE,iBAAiB,CAAC;IAExB,UAAU,EAAE,UAAU,CAAC;IAEvB,YAAY,EAAE,OAAO,CAAC;IAEtB,UAAU,EAAE,OAAO,CAAC;IAEpB,UAAU,EAAE,OAAO,CAAC;gBAER,EACV,OAAO,EACP,IAAI,EACJ,UAAU,EACV,YAAY,GACb,EAAE;QACD,OAAO,EAAE,gBAAgB,CAAC;QAC1B,IAAI,EAAE,iBAAiB,CAAC;QACxB,UAAU,EAAE,UAAU,CAAC;QACvB,YAAY,EAAE,OAAO,CAAC;KACvB;IAcD,IAAI,WAAW,CAAC,WAAW,EAAE,MAAM,EAElC;IAED,IAAI,KAAK,IAAI,MAAM,CAElB;IAED,IAAI,KAAK,CAAC,KAAK,EAAE,MAAM,EAEtB;IAED,IAAI,QAAQ,IAAI,MAAM,CAErB;IAED,iBAAiB,IAAI,IAAI;IAazB,oBAAoB,IAAI,IAAI;IAO5B,MAAM,IAAI,IAAI;IAKd,OAAO,IAAI,IAAI;IAKf,KAAK,IAAI,IAAI;IAMb,IAAI,IAAI,IAAI;IAMZ,KAAK,CAAC,QAAQ,UAAO,GAAG,IAAI;IAY5B;;;OAGG;IACH,QAAQ,IAAI,IAAI;IAOhB,mBAAmB,CAAC,kBAAkB,EAAE,MAAM,GAAG,IAAI;IAIrD,sBAAsB,IAAI,IAAI;IAI9B,QAAQ,IAAI,IAAI;IAMhB,QAAQ,CAAC,KAAK,EAAE,cAAc,GAAG,IAAI;IAMrC,QAAQ,IAAI,IAAI;IAIhB,OAAO,IAAI,IAAI;CAGhB"} \ No newline at end of file diff --git a/types/src/scripts/components/input.test.d.ts b/types/src/scripts/components/input.test.d.ts new file mode 100644 index 0000000..f6118e4 --- /dev/null +++ b/types/src/scripts/components/input.test.d.ts @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=input.test.d.ts.map \ No newline at end of file diff --git a/types/src/scripts/components/input.test.d.ts.map b/types/src/scripts/components/input.test.d.ts.map new file mode 100644 index 0000000..be43368 --- /dev/null +++ b/types/src/scripts/components/input.test.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"input.test.d.ts","sourceRoot":"","sources":["../../../../../src/scripts/components/input.test.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/types/src/scripts/components/list.d.ts b/types/src/scripts/components/list.d.ts new file mode 100644 index 0000000..51a0868 --- /dev/null +++ b/types/src/scripts/components/list.d.ts @@ -0,0 +1,18 @@ +export default class List { + element: HTMLElement; + scrollPos: number; + height: number; + constructor({ element }: { + element: HTMLElement; + }); + clear(): void; + append(node: Element | DocumentFragment): void; + getChild(selector: string): HTMLElement | null; + hasChildren(): boolean; + scrollToTop(): void; + scrollToChildElement(element: HTMLElement, direction: 1 | -1): void; + _scrollDown(scrollPos: number, strength: number, destination: number): void; + _scrollUp(scrollPos: number, strength: number, destination: number): void; + _animateScroll(destination: number, direction: number): void; +} +//# sourceMappingURL=list.d.ts.map \ No newline at end of file diff --git a/types/src/scripts/components/list.d.ts.map b/types/src/scripts/components/list.d.ts.map new file mode 100644 index 0000000..8b9068f --- /dev/null +++ b/types/src/scripts/components/list.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../../../src/scripts/components/list.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,OAAO,OAAO,IAAI;IACvB,OAAO,EAAE,WAAW,CAAC;IAErB,SAAS,EAAE,MAAM,CAAC;IAElB,MAAM,EAAE,MAAM,CAAC;gBAEH,EAAE,OAAO,EAAE,EAAE;QAAE,OAAO,EAAE,WAAW,CAAA;KAAE;IAMjD,KAAK,IAAI,IAAI;IAIb,MAAM,CAAC,IAAI,EAAE,OAAO,GAAG,gBAAgB,GAAG,IAAI;IAI9C,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,WAAW,GAAG,IAAI;IAI9C,WAAW,IAAI,OAAO;IAItB,WAAW,IAAI,IAAI;IAInB,oBAAoB,CAAC,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,CAAC,GAAG,CAAC,CAAC,GAAG,IAAI;IAwBnE,WAAW,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,IAAI;IAO3E,SAAS,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,IAAI;IAOzE,cAAc,CAAC,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI;CAyB7D"} \ No newline at end of file diff --git a/types/src/scripts/components/list.test.d.ts b/types/src/scripts/components/list.test.d.ts new file mode 100644 index 0000000..ce43e8d --- /dev/null +++ b/types/src/scripts/components/list.test.d.ts @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=list.test.d.ts.map \ No newline at end of file diff --git a/types/src/scripts/components/list.test.d.ts.map b/types/src/scripts/components/list.test.d.ts.map new file mode 100644 index 0000000..ad13168 --- /dev/null +++ b/types/src/scripts/components/list.test.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"list.test.d.ts","sourceRoot":"","sources":["../../../../../src/scripts/components/list.test.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/types/src/scripts/components/wrapped-element.d.ts b/types/src/scripts/components/wrapped-element.d.ts new file mode 100644 index 0000000..ae18b82 --- /dev/null +++ b/types/src/scripts/components/wrapped-element.d.ts @@ -0,0 +1,21 @@ +import { ClassNames } from '../interfaces/class-names'; +import { EventType } from '../interfaces/event-type'; +export default class WrappedElement { + element: HTMLInputElement | HTMLSelectElement; + classNames: ClassNames; + isDisabled: boolean; + constructor({ element, classNames }: { + element: any; + classNames: any; + }); + get isActive(): boolean; + get dir(): string; + get value(): string; + set value(value: string); + conceal(): void; + reveal(): void; + enable(): void; + disable(): void; + triggerEvent(eventType: EventType, data?: object): void; +} +//# sourceMappingURL=wrapped-element.d.ts.map \ No newline at end of file diff --git a/types/src/scripts/components/wrapped-element.d.ts.map b/types/src/scripts/components/wrapped-element.d.ts.map new file mode 100644 index 0000000..2df95bf --- /dev/null +++ b/types/src/scripts/components/wrapped-element.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"wrapped-element.d.ts","sourceRoot":"","sources":["../../../../../src/scripts/components/wrapped-element.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAGrD,MAAM,CAAC,OAAO,OAAO,cAAc;IACjC,OAAO,EAAE,gBAAgB,GAAG,iBAAiB,CAAC;IAE9C,UAAU,EAAE,UAAU,CAAC;IAEvB,UAAU,EAAE,OAAO,CAAC;gBAER,EAAE,OAAO,EAAE,UAAU,EAAE;;;KAAA;IAcnC,IAAI,QAAQ,IAAI,OAAO,CAEtB;IAED,IAAI,GAAG,IAAI,MAAM,CAEhB;IAED,IAAI,KAAK,IAAI,MAAM,CAElB;IAED,IAAI,KAAK,CAAC,KAAK,EAAE,MAAM,EAGtB;IAED,OAAO,IAAI,IAAI;IAkBf,MAAM,IAAI,IAAI;IAsBd,MAAM,IAAI,IAAI;IAMd,OAAO,IAAI,IAAI;IAMf,YAAY,CAAC,SAAS,EAAE,SAAS,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI;CAGxD"} \ No newline at end of file diff --git a/types/src/scripts/components/wrapped-element.test.d.ts b/types/src/scripts/components/wrapped-element.test.d.ts new file mode 100644 index 0000000..a9838b8 --- /dev/null +++ b/types/src/scripts/components/wrapped-element.test.d.ts @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=wrapped-element.test.d.ts.map \ No newline at end of file diff --git a/types/src/scripts/components/wrapped-element.test.d.ts.map b/types/src/scripts/components/wrapped-element.test.d.ts.map new file mode 100644 index 0000000..fb26915 --- /dev/null +++ b/types/src/scripts/components/wrapped-element.test.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"wrapped-element.test.d.ts","sourceRoot":"","sources":["../../../../../src/scripts/components/wrapped-element.test.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/types/src/scripts/components/wrapped-input.d.ts b/types/src/scripts/components/wrapped-input.d.ts new file mode 100644 index 0000000..c4c3524 --- /dev/null +++ b/types/src/scripts/components/wrapped-input.d.ts @@ -0,0 +1,14 @@ +import { ClassNames } from '../interfaces/class-names'; +import WrappedElement from './wrapped-element'; +export default class WrappedInput extends WrappedElement { + element: HTMLInputElement; + delimiter: string; + constructor({ element, classNames, delimiter, }: { + element: HTMLInputElement; + classNames: ClassNames; + delimiter: string; + }); + get value(): string; + set value(value: string); +} +//# sourceMappingURL=wrapped-input.d.ts.map \ No newline at end of file diff --git a/types/src/scripts/components/wrapped-input.d.ts.map b/types/src/scripts/components/wrapped-input.d.ts.map new file mode 100644 index 0000000..224197b --- /dev/null +++ b/types/src/scripts/components/wrapped-input.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"wrapped-input.d.ts","sourceRoot":"","sources":["../../../../../src/scripts/components/wrapped-input.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,cAAc,MAAM,mBAAmB,CAAC;AAE/C,MAAM,CAAC,OAAO,OAAO,YAAa,SAAQ,cAAc;IACtD,OAAO,EAAE,gBAAgB,CAAC;IAE1B,SAAS,EAAE,MAAM,CAAC;gBAEN,EACV,OAAO,EACP,UAAU,EACV,SAAS,GACV,EAAE;QACD,OAAO,EAAE,gBAAgB,CAAC;QAC1B,UAAU,EAAE,UAAU,CAAC;QACvB,SAAS,EAAE,MAAM,CAAC;KACnB;IAKD,IAAI,KAAK,IAAI,MAAM,CAElB;IAED,IAAI,KAAK,CAAC,KAAK,EAAE,MAAM,EAGtB;CACF"} \ No newline at end of file diff --git a/types/src/scripts/components/wrapped-input.test.d.ts b/types/src/scripts/components/wrapped-input.test.d.ts new file mode 100644 index 0000000..5b23346 --- /dev/null +++ b/types/src/scripts/components/wrapped-input.test.d.ts @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=wrapped-input.test.d.ts.map \ No newline at end of file diff --git a/types/src/scripts/components/wrapped-input.test.d.ts.map b/types/src/scripts/components/wrapped-input.test.d.ts.map new file mode 100644 index 0000000..28ba6ce --- /dev/null +++ b/types/src/scripts/components/wrapped-input.test.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"wrapped-input.test.d.ts","sourceRoot":"","sources":["../../../../../src/scripts/components/wrapped-input.test.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/types/src/scripts/components/wrapped-select.d.ts b/types/src/scripts/components/wrapped-select.d.ts new file mode 100644 index 0000000..5b4f647 --- /dev/null +++ b/types/src/scripts/components/wrapped-select.d.ts @@ -0,0 +1,19 @@ +import { ClassNames } from '../interfaces/class-names'; +import { Item } from '../interfaces/item'; +import WrappedElement from './wrapped-element'; +export default class WrappedSelect extends WrappedElement { + element: HTMLSelectElement; + classNames: ClassNames; + template: (data: object) => HTMLOptionElement; + constructor({ element, classNames, template, }: { + element: HTMLSelectElement; + classNames: ClassNames; + template: (data: object) => HTMLOptionElement; + }); + get placeholderOption(): HTMLOptionElement | null; + get optionGroups(): Element[]; + get options(): Item[] | HTMLOptionElement[]; + set options(options: Item[] | HTMLOptionElement[]); + appendDocFragment(fragment: DocumentFragment): void; +} +//# sourceMappingURL=wrapped-select.d.ts.map \ No newline at end of file diff --git a/types/src/scripts/components/wrapped-select.d.ts.map b/types/src/scripts/components/wrapped-select.d.ts.map new file mode 100644 index 0000000..47ebbf7 --- /dev/null +++ b/types/src/scripts/components/wrapped-select.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"wrapped-select.d.ts","sourceRoot":"","sources":["../../../../../src/scripts/components/wrapped-select.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,cAAc,MAAM,mBAAmB,CAAC;AAE/C,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,cAAc;IACvD,OAAO,EAAE,iBAAiB,CAAC;IAE3B,UAAU,EAAE,UAAU,CAAC;IAEvB,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,iBAAiB,CAAC;gBAElC,EACV,OAAO,EACP,UAAU,EACV,QAAQ,GACT,EAAE;QACD,OAAO,EAAE,iBAAiB,CAAC;QAC3B,UAAU,EAAE,UAAU,CAAC;QACvB,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,iBAAiB,CAAC;KAC/C;IAKD,IAAI,iBAAiB,IAAI,iBAAiB,GAAG,IAAI,CAMhD;IAED,IAAI,YAAY,IAAI,OAAO,EAAE,CAE5B;IAED,IAAI,OAAO,IAAI,IAAI,EAAE,GAAG,iBAAiB,EAAE,CAE1C;IAED,IAAI,OAAO,CAAC,OAAO,EAAE,IAAI,EAAE,GAAG,iBAAiB,EAAE,EAahD;IAED,iBAAiB,CAAC,QAAQ,EAAE,gBAAgB,GAAG,IAAI;CAIpD"} \ No newline at end of file diff --git a/types/src/scripts/components/wrapped-select.test.d.ts b/types/src/scripts/components/wrapped-select.test.d.ts new file mode 100644 index 0000000..414d615 --- /dev/null +++ b/types/src/scripts/components/wrapped-select.test.d.ts @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=wrapped-select.test.d.ts.map \ No newline at end of file diff --git a/types/src/scripts/components/wrapped-select.test.d.ts.map b/types/src/scripts/components/wrapped-select.test.d.ts.map new file mode 100644 index 0000000..e974095 --- /dev/null +++ b/types/src/scripts/components/wrapped-select.test.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"wrapped-select.test.d.ts","sourceRoot":"","sources":["../../../../../src/scripts/components/wrapped-select.test.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/types/src/scripts/constants.d.ts b/types/src/scripts/constants.d.ts new file mode 100644 index 0000000..1891ccc --- /dev/null +++ b/types/src/scripts/constants.d.ts @@ -0,0 +1,11 @@ +import { ActionType } from './interfaces/action-type'; +import { EventType } from './interfaces/event-type'; +import { KeyCodeMap } from './interfaces/keycode-map'; +export declare const EVENTS: Record; +export declare const ACTION_TYPES: Record; +export declare const KEY_CODES: KeyCodeMap; +export declare const TEXT_TYPE: HTMLInputElement['type']; +export declare const SELECT_ONE_TYPE: HTMLSelectElement['type']; +export declare const SELECT_MULTIPLE_TYPE: HTMLSelectElement['type']; +export declare const SCROLLING_SPEED = 4; +//# sourceMappingURL=constants.d.ts.map \ No newline at end of file diff --git a/types/src/scripts/constants.d.ts.map b/types/src/scripts/constants.d.ts.map new file mode 100644 index 0000000..1a564df --- /dev/null +++ b/types/src/scripts/constants.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../src/scripts/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAEtD,eAAO,MAAM,MAAM,EAAE,MAAM,CAAC,SAAS,EAAE,SAAS,CAW/C,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,UAAU,EAAE,UAAU,CAYvD,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,UAUvB,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,gBAAgB,CAAC,MAAM,CAAU,CAAC;AAC1D,eAAO,MAAM,eAAe,EAAE,iBAAiB,CAAC,MAAM,CAAgB,CAAC;AACvE,eAAO,MAAM,oBAAoB,EAAE,iBAAiB,CAAC,MAAM,CACxC,CAAC;AAEpB,eAAO,MAAM,eAAe,IAAI,CAAC"} \ No newline at end of file diff --git a/types/src/scripts/constants.test.d.ts b/types/src/scripts/constants.test.d.ts new file mode 100644 index 0000000..bc2a88b --- /dev/null +++ b/types/src/scripts/constants.test.d.ts @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=constants.test.d.ts.map \ No newline at end of file diff --git a/types/src/scripts/constants.test.d.ts.map b/types/src/scripts/constants.test.d.ts.map new file mode 100644 index 0000000..20f7799 --- /dev/null +++ b/types/src/scripts/constants.test.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"constants.test.d.ts","sourceRoot":"","sources":["../../../../src/scripts/constants.test.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/types/src/scripts/defaults.d.ts b/types/src/scripts/defaults.d.ts new file mode 100644 index 0000000..db8a9a9 --- /dev/null +++ b/types/src/scripts/defaults.d.ts @@ -0,0 +1,5 @@ +import { ClassNames } from './interfaces/class-names'; +import { Options } from './interfaces/options'; +export declare const DEFAULT_CLASSNAMES: ClassNames; +export declare const DEFAULT_CONFIG: Options; +//# sourceMappingURL=defaults.d.ts.map \ No newline at end of file diff --git a/types/src/scripts/defaults.d.ts.map b/types/src/scripts/defaults.d.ts.map new file mode 100644 index 0000000..79c157f --- /dev/null +++ b/types/src/scripts/defaults.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../../../../src/scripts/defaults.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAG/C,eAAO,MAAM,kBAAkB,EAAE,UA2BhC,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,OA8C5B,CAAC"} \ No newline at end of file diff --git a/types/src/scripts/interfaces/action-type.d.ts b/types/src/scripts/interfaces/action-type.d.ts new file mode 100644 index 0000000..e7ce714 --- /dev/null +++ b/types/src/scripts/interfaces/action-type.d.ts @@ -0,0 +1,2 @@ +export declare type ActionType = 'ADD_CHOICE' | 'FILTER_CHOICES' | 'ACTIVATE_CHOICES' | 'CLEAR_CHOICES' | 'ADD_GROUP' | 'ADD_ITEM' | 'REMOVE_ITEM' | 'HIGHLIGHT_ITEM' | 'CLEAR_ALL' | 'RESET_TO' | 'SET_IS_LOADING'; +//# sourceMappingURL=action-type.d.ts.map \ No newline at end of file diff --git a/types/src/scripts/interfaces/action-type.d.ts.map b/types/src/scripts/interfaces/action-type.d.ts.map new file mode 100644 index 0000000..6080889 --- /dev/null +++ b/types/src/scripts/interfaces/action-type.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"action-type.d.ts","sourceRoot":"","sources":["../../../../../src/scripts/interfaces/action-type.ts"],"names":[],"mappings":"AAAA,oBAAY,UAAU,GAClB,YAAY,GACZ,gBAAgB,GAChB,kBAAkB,GAClB,eAAe,GACf,WAAW,GACX,UAAU,GACV,aAAa,GACb,gBAAgB,GAChB,WAAW,GACX,UAAU,GACV,gBAAgB,CAAC"} \ No newline at end of file diff --git a/types/src/scripts/interfaces/choice.d.ts b/types/src/scripts/interfaces/choice.d.ts new file mode 100644 index 0000000..db222d0 --- /dev/null +++ b/types/src/scripts/interfaces/choice.d.ts @@ -0,0 +1,16 @@ +export interface Choice { + id?: number; + customProperties?: Record; + disabled?: boolean; + active?: boolean; + elementId?: number; + groupId?: number; + keyCode?: number; + label: string; + placeholder?: boolean; + selected?: boolean; + value: any; + score?: number; + choices?: Choice[]; +} +//# sourceMappingURL=choice.d.ts.map \ No newline at end of file diff --git a/types/src/scripts/interfaces/choice.d.ts.map b/types/src/scripts/interfaces/choice.d.ts.map new file mode 100644 index 0000000..b692cb7 --- /dev/null +++ b/types/src/scripts/interfaces/choice.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"choice.d.ts","sourceRoot":"","sources":["../../../../../src/scripts/interfaces/choice.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,MAAM;IACrB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACvC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,GAAG,CAAC;IACX,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB"} \ No newline at end of file diff --git a/types/src/scripts/interfaces/choices.d.ts b/types/src/scripts/interfaces/choices.d.ts new file mode 100644 index 0000000..613a2ab --- /dev/null +++ b/types/src/scripts/interfaces/choices.d.ts @@ -0,0 +1,46 @@ +import { Options } from 'deepmerge'; +import { Store } from 'redux'; +import { WrappedInput, WrappedSelect, Container, List, Input, Dropdown } from '../components'; +import { Choice } from './choice'; +import { Group } from './group'; +import { Item } from './item'; +import { State } from './state'; +import templates from '../templates'; +export interface Choices { + initialised: boolean; + config: Options; + passedElement: WrappedInput | WrappedSelect; + containerOuter: Container; + containerInner: Container; + choiceList: List; + itemList: List; + input: Input; + dropdown: Dropdown; + _isTextElement: boolean; + _isSelectOneElement: boolean; + _isSelectMultipleElement: boolean; + _isSelectElement: boolean; + _store: Store; + _templates: typeof templates; + _initialState: State; + _currentState: State; + _prevState: State; + _currentValue: string; + _canSearch: boolean; + _isScrollingOnIe: boolean; + _highlightPosition: number; + _wasTap: boolean; + _isSearching: boolean; + _placeholderValue: string | null; + _baseId: string; + _direction: HTMLElement['dir']; + _idNames: { + itemChoice: string; + }; + _presetGroups: Group[] | HTMLOptGroupElement[] | Element[]; + _presetOptions: Item[] | HTMLOptionElement[]; + _presetChoices: Partial[]; + _presetItems: Item[] | string[]; + new (element: string | Element | HTMLInputElement | HTMLSelectElement, userConfig: Partial): any; +} +//# sourceMappingURL=choices.d.ts.map \ No newline at end of file diff --git a/types/src/scripts/interfaces/choices.d.ts.map b/types/src/scripts/interfaces/choices.d.ts.map new file mode 100644 index 0000000..acb6e08 --- /dev/null +++ b/types/src/scripts/interfaces/choices.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"choices.d.ts","sourceRoot":"","sources":["../../../../../src/scripts/interfaces/choices.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAC9B,OAAO,EACL,YAAY,EACZ,aAAa,EACb,SAAS,EACT,IAAI,EACJ,KAAK,EACL,QAAQ,EACT,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,SAAS,MAAM,cAAc,CAAC;AAErC,MAAM,WAAW,OAAO;IACtB,WAAW,EAAE,OAAO,CAAC;IACrB,MAAM,EAAE,OAAO,CAAC;IAEhB,aAAa,EAAE,YAAY,GAAG,aAAa,CAAC;IAE5C,cAAc,EAAE,SAAS,CAAC;IAE1B,cAAc,EAAE,SAAS,CAAC;IAE1B,UAAU,EAAE,IAAI,CAAC;IAEjB,QAAQ,EAAE,IAAI,CAAC;IAEf,KAAK,EAAE,KAAK,CAAC;IAEb,QAAQ,EAAE,QAAQ,CAAC;IAEnB,cAAc,EAAE,OAAO,CAAC;IAExB,mBAAmB,EAAE,OAAO,CAAC;IAE7B,wBAAwB,EAAE,OAAO,CAAC;IAElC,gBAAgB,EAAE,OAAO,CAAC;IAE1B,MAAM,EAAE,KAAK,CAAC;IAEd,UAAU,EAAE,OAAO,SAAS,CAAC;IAE7B,aAAa,EAAE,KAAK,CAAC;IAErB,aAAa,EAAE,KAAK,CAAC;IAErB,UAAU,EAAE,KAAK,CAAC;IAElB,aAAa,EAAE,MAAM,CAAC;IAEtB,UAAU,EAAE,OAAO,CAAC;IAEpB,gBAAgB,EAAE,OAAO,CAAC;IAE1B,kBAAkB,EAAE,MAAM,CAAC;IAE3B,OAAO,EAAE,OAAO,CAAC;IAEjB,YAAY,EAAE,OAAO,CAAC;IAEtB,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;IAEjC,OAAO,EAAE,MAAM,CAAC;IAEhB,UAAU,EAAE,WAAW,CAAC,KAAK,CAAC,CAAC;IAE/B,QAAQ,EAAE;QACR,UAAU,EAAE,MAAM,CAAC;KACpB,CAAC;IAEF,aAAa,EAAE,KAAK,EAAE,GAAG,mBAAmB,EAAE,GAAG,OAAO,EAAE,CAAC;IAE3D,cAAc,EAAE,IAAI,EAAE,GAAG,iBAAiB,EAAE,CAAC;IAE7C,cAAc,EAAE,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;IAElC,YAAY,EAAE,IAAI,EAAE,GAAG,MAAM,EAAE,CAAC;IAEhC,KACE,OAAO,EAAE,MAAM,GAAG,OAAO,GAAG,gBAAgB,GAAG,iBAAiB,EAChE,UAAU,EAAE,OAAO,CAAC,OAAO,CAAC,OAC5B;CACH"} \ No newline at end of file diff --git a/types/src/scripts/interfaces/class-names.d.ts b/types/src/scripts/interfaces/class-names.d.ts new file mode 100644 index 0000000..09818ef --- /dev/null +++ b/types/src/scripts/interfaces/class-names.d.ts @@ -0,0 +1,56 @@ +/** Classes added to HTML generated by By default classnames follow the BEM notation. */ +export interface ClassNames { + /** @default 'choices' */ + containerOuter: string; + /** @default 'choices__inner' */ + containerInner: string; + /** @default 'choices__input' */ + input: string; + /** @default 'choices__input--cloned' */ + inputCloned: string; + /** @default 'choices__list' */ + list: string; + /** @default 'choices__list--multiple' */ + listItems: string; + /** @default 'choices__list--single' */ + listSingle: string; + /** @default 'choices__list--dropdown' */ + listDropdown: string; + /** @default 'choices__item' */ + item: string; + /** @default 'choices__item--selectable' */ + itemSelectable: string; + /** @default 'choices__item--disabled' */ + itemDisabled: string; + /** @default 'choices__item--choice' */ + itemChoice: string; + /** @default 'choices__placeholder' */ + placeholder: string; + /** @default 'choices__group' */ + group: string; + /** @default 'choices__heading' */ + groupHeading: string; + /** @default 'choices__button' */ + button: string; + /** @default 'is-active' */ + activeState: string; + /** @default 'is-focused' */ + focusState: string; + /** @default 'is-open' */ + openState: string; + /** @default 'is-disabled' */ + disabledState: string; + /** @default 'is-highlighted' */ + highlightedState: string; + /** @default 'is-selected' */ + selectedState: string; + /** @default 'is-flipped' */ + flippedState: string; + /** @default 'is-loading' */ + loadingState: string; + /** @default 'has-no-results' */ + noResults: string; + /** @default 'has-no-choices' */ + noChoices: string; +} +//# sourceMappingURL=class-names.d.ts.map \ No newline at end of file diff --git a/types/src/scripts/interfaces/class-names.d.ts.map b/types/src/scripts/interfaces/class-names.d.ts.map new file mode 100644 index 0000000..b5c6068 --- /dev/null +++ b/types/src/scripts/interfaces/class-names.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"class-names.d.ts","sourceRoot":"","sources":["../../../../../src/scripts/interfaces/class-names.ts"],"names":[],"mappings":"AAAA,yFAAyF;AACzF,MAAM,WAAW,UAAU;IACzB,yBAAyB;IACzB,cAAc,EAAE,MAAM,CAAC;IACvB,gCAAgC;IAChC,cAAc,EAAE,MAAM,CAAC;IACvB,gCAAgC;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,wCAAwC;IACxC,WAAW,EAAE,MAAM,CAAC;IACpB,+BAA+B;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,yCAAyC;IACzC,SAAS,EAAE,MAAM,CAAC;IAClB,uCAAuC;IACvC,UAAU,EAAE,MAAM,CAAC;IACnB,yCAAyC;IACzC,YAAY,EAAE,MAAM,CAAC;IACrB,+BAA+B;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,2CAA2C;IAC3C,cAAc,EAAE,MAAM,CAAC;IACvB,yCAAyC;IACzC,YAAY,EAAE,MAAM,CAAC;IACrB,uCAAuC;IACvC,UAAU,EAAE,MAAM,CAAC;IACnB,sCAAsC;IACtC,WAAW,EAAE,MAAM,CAAC;IACpB,gCAAgC;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,kCAAkC;IAClC,YAAY,EAAE,MAAM,CAAC;IACrB,iCAAiC;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,2BAA2B;IAC3B,WAAW,EAAE,MAAM,CAAC;IACpB,4BAA4B;IAC5B,UAAU,EAAE,MAAM,CAAC;IACnB,yBAAyB;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,6BAA6B;IAC7B,aAAa,EAAE,MAAM,CAAC;IACtB,gCAAgC;IAChC,gBAAgB,EAAE,MAAM,CAAC;IACzB,6BAA6B;IAC7B,aAAa,EAAE,MAAM,CAAC;IACtB,4BAA4B;IAC5B,YAAY,EAAE,MAAM,CAAC;IACrB,4BAA4B;IAC5B,YAAY,EAAE,MAAM,CAAC;IACrB,gCAAgC;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,gCAAgC;IAChC,SAAS,EAAE,MAAM,CAAC;CACnB"} \ No newline at end of file diff --git a/types/src/scripts/interfaces/event-type.d.ts b/types/src/scripts/interfaces/event-type.d.ts new file mode 100644 index 0000000..5a88a96 --- /dev/null +++ b/types/src/scripts/interfaces/event-type.d.ts @@ -0,0 +1,2 @@ +export declare type EventType = 'addItem' | 'removeItem' | 'highlightItem' | 'unhighlightItem' | 'choice' | 'change' | 'search' | 'showDropdown' | 'hideDropdown' | 'highlightChoice'; +//# sourceMappingURL=event-type.d.ts.map \ No newline at end of file diff --git a/types/src/scripts/interfaces/event-type.d.ts.map b/types/src/scripts/interfaces/event-type.d.ts.map new file mode 100644 index 0000000..12a34e3 --- /dev/null +++ b/types/src/scripts/interfaces/event-type.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"event-type.d.ts","sourceRoot":"","sources":["../../../../../src/scripts/interfaces/event-type.ts"],"names":[],"mappings":"AAAA,oBAAY,SAAS,GACjB,SAAS,GACT,YAAY,GACZ,eAAe,GACf,iBAAiB,GACjB,QAAQ,GACR,QAAQ,GACR,QAAQ,GACR,cAAc,GACd,cAAc,GACd,iBAAiB,CAAC"} \ No newline at end of file diff --git a/types/src/scripts/interfaces/group.d.ts b/types/src/scripts/interfaces/group.d.ts new file mode 100644 index 0000000..3fa395a --- /dev/null +++ b/types/src/scripts/interfaces/group.d.ts @@ -0,0 +1,7 @@ +export interface Group { + id?: number; + active?: boolean; + disabled?: boolean; + value: any; +} +//# sourceMappingURL=group.d.ts.map \ No newline at end of file diff --git a/types/src/scripts/interfaces/group.d.ts.map b/types/src/scripts/interfaces/group.d.ts.map new file mode 100644 index 0000000..bff19fb --- /dev/null +++ b/types/src/scripts/interfaces/group.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"group.d.ts","sourceRoot":"","sources":["../../../../../src/scripts/interfaces/group.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,KAAK;IACpB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,GAAG,CAAC;CACZ"} \ No newline at end of file diff --git a/types/src/scripts/interfaces/index.d.ts b/types/src/scripts/interfaces/index.d.ts new file mode 100644 index 0000000..66ecddc --- /dev/null +++ b/types/src/scripts/interfaces/index.d.ts @@ -0,0 +1,16 @@ +export * from './action-type'; +export * from './choice'; +export * from './choices'; +export * from './class-names'; +export * from './event-type'; +export * from './group'; +export * from './item'; +export * from './keycode-map'; +export * from './notice'; +export * from './options'; +export * from './passed-element'; +export * from './passed-element-type'; +export * from './position-options-type'; +export * from './state'; +export * from './types'; +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/types/src/scripts/interfaces/index.d.ts.map b/types/src/scripts/interfaces/index.d.ts.map new file mode 100644 index 0000000..d28ff02 --- /dev/null +++ b/types/src/scripts/interfaces/index.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/scripts/interfaces/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC"} \ No newline at end of file diff --git a/types/src/scripts/interfaces/item.d.ts b/types/src/scripts/interfaces/item.d.ts new file mode 100644 index 0000000..1d58b80 --- /dev/null +++ b/types/src/scripts/interfaces/item.d.ts @@ -0,0 +1,6 @@ +import { Choice } from './choice'; +export interface Item extends Choice { + choiceId?: number; + highlighted?: boolean; +} +//# sourceMappingURL=item.d.ts.map \ No newline at end of file diff --git a/types/src/scripts/interfaces/item.d.ts.map b/types/src/scripts/interfaces/item.d.ts.map new file mode 100644 index 0000000..15f89f1 --- /dev/null +++ b/types/src/scripts/interfaces/item.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"item.d.ts","sourceRoot":"","sources":["../../../../../src/scripts/interfaces/item.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,MAAM,WAAW,IAAK,SAAQ,MAAM;IAClC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB"} \ No newline at end of file diff --git a/types/src/scripts/interfaces/keycode-map.d.ts b/types/src/scripts/interfaces/keycode-map.d.ts new file mode 100644 index 0000000..f7ece2b --- /dev/null +++ b/types/src/scripts/interfaces/keycode-map.d.ts @@ -0,0 +1,12 @@ +export interface KeyCodeMap { + BACK_KEY: 46; + DELETE_KEY: 8; + ENTER_KEY: 13; + A_KEY: 65; + ESC_KEY: 27; + UP_KEY: 38; + DOWN_KEY: 40; + PAGE_UP_KEY: 33; + PAGE_DOWN_KEY: 34; +} +//# sourceMappingURL=keycode-map.d.ts.map \ No newline at end of file diff --git a/types/src/scripts/interfaces/keycode-map.d.ts.map b/types/src/scripts/interfaces/keycode-map.d.ts.map new file mode 100644 index 0000000..0458006 --- /dev/null +++ b/types/src/scripts/interfaces/keycode-map.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"keycode-map.d.ts","sourceRoot":"","sources":["../../../../../src/scripts/interfaces/keycode-map.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,UAAU;IACzB,QAAQ,EAAE,EAAE,CAAC;IACb,UAAU,EAAE,CAAC,CAAC;IACd,SAAS,EAAE,EAAE,CAAC;IACd,KAAK,EAAE,EAAE,CAAC;IACV,OAAO,EAAE,EAAE,CAAC;IACZ,MAAM,EAAE,EAAE,CAAC;IACX,QAAQ,EAAE,EAAE,CAAC;IACb,WAAW,EAAE,EAAE,CAAC;IAChB,aAAa,EAAE,EAAE,CAAC;CACnB"} \ No newline at end of file diff --git a/types/src/scripts/interfaces/notice.d.ts b/types/src/scripts/interfaces/notice.d.ts new file mode 100644 index 0000000..071f8d4 --- /dev/null +++ b/types/src/scripts/interfaces/notice.d.ts @@ -0,0 +1,5 @@ +export interface Notice { + response: boolean; + notice: string; +} +//# sourceMappingURL=notice.d.ts.map \ No newline at end of file diff --git a/types/src/scripts/interfaces/notice.d.ts.map b/types/src/scripts/interfaces/notice.d.ts.map new file mode 100644 index 0000000..f2983f3 --- /dev/null +++ b/types/src/scripts/interfaces/notice.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"notice.d.ts","sourceRoot":"","sources":["../../../../../src/scripts/interfaces/notice.ts"],"names":[],"mappings":"AACA,MAAM,WAAW,MAAM;IACrB,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;CAChB"} \ No newline at end of file diff --git a/types/src/scripts/interfaces/options.d.ts b/types/src/scripts/interfaces/options.d.ts new file mode 100644 index 0000000..1a4560a --- /dev/null +++ b/types/src/scripts/interfaces/options.d.ts @@ -0,0 +1,460 @@ +import Fuse from 'fuse.js'; +import { Choices } from './choices'; +import { Choice } from './choice'; +import { ClassNames } from './class-names'; +import { PositionOptionsType } from './position-options-type'; +import { Types } from './types'; +/** + * Choices options interface + * + * **Terminology** + * + * - **Choice:** A choice is a value a user can select. A choice would be equivalent to the `` element within a select input. + * - **Group:** A group is a collection of choices. A group should be seen as equivalent to a `` element within a select input. + * - **Item:** An item is an inputted value **_(text input)_** or a selected choice **_(select element)_**. In the context of a select element, an item is equivelent to a selected option element: `` whereas in the context of a text input an item is equivelant to `` + */ +export interface Options { + /** + * Optionally suppress console errors and warnings. + * + * **Input types affected:** text, select-single, select-multiple + * + * @default false + */ + silent: boolean; + /** + * Add pre-selected items (see terminology) to text input. + * + * **Input types affected:** text + * + * @example + * ``` + * ['value 1', 'value 2', 'value 3'] + * ``` + * + * @example + * ``` + * [{ + * value: 'Value 1', + * label: 'Label 1', + * id: 1 + * }, + * { + * value: 'Value 2', + * label: 'Label 2', + * id: 2, + * customProperties: { + * random: 'I am a custom property' + * } + * }] + * ``` + * + * @default [] + */ + items: string[] | Choice[]; + /** + * Add choices (see terminology) to select input. + * + * **Input types affected:** select-one, select-multiple + * + * @example + * ``` + * [{ + * value: 'Option 1', + * label: 'Option 1', + * selected: true, + * disabled: false, + * }, + * { + * value: 'Option 2', + * label: 'Option 2', + * selected: false, + * disabled: true, + * customProperties: { + * description: 'Custom description about Option 2', + * random: 'Another random custom property' + * }, + * }] + * ``` + * + * @default [] + */ + choices: Choice[]; + /** + * The amount of choices to be rendered within the dropdown list `("-1" indicates no limit)`. This is useful if you have a lot of choices where it is easier for a user to use the search area to find a choice. + * + * **Input types affected:** select-one, select-multiple + * + * @default -1 + */ + renderChoiceLimit: number; + /** + * The amount of items a user can input/select `("-1" indicates no limit)`. + * + * **Input types affected:** text, select-multiple + * + * @default -1 + */ + maxItemCount: number; + /** + * Whether a user can add items. + * + * **Input types affected:** text + * + * @default true + */ + addItems: boolean; + /** + * A filter that will need to pass for a user to successfully add an item. + * + * **Input types affected:** text + * + * @default null + */ + addItemFilter: string | RegExp | Types.FilterFunction | null; + /** + * The text that is shown when a user has inputted a new item but has not pressed the enter key. To access the current input value, pass a function with a `value` argument (see the **default config** [https://github.com/jshjohnson/Choices#setup] for an example), otherwise pass a string. + * + * **Input types affected:** text + * + * @default + * ``` + * (value) => `Press Enter to add "${value}"`; + * ``` + */ + addItemText: string | Types.NoticeStringFunction; + /** + * Whether a user can remove items. + * + * **Input types affected:** text, select-multiple + * + * @default true + */ + removeItems: boolean; + /** + * Whether each item should have a remove button. + * + * **Input types affected:** text, select-one, select-multiple + * + * @default false + */ + removeItemButton: boolean; + /** + * Whether a user can edit items. An item's value can be edited by pressing the backspace. + * + * **Input types affected:** text + * + * @default false + */ + editItems: boolean; + /** + * Whether HTML should be rendered in all Choices elements. + * If `false`, all elements (placeholder, items, etc.) will be treated as plain text. + * If `true`, this can be used to perform XSS scripting attacks if you load choices from a remote source. + * + * **Deprecation Warning:** This will default to `false` in a future release. + * + * **Input types affected:** text, select-one, select-multiple + * + * @default true + */ + allowHTML: boolean; + /** + * Whether each inputted/chosen item should be unique. + * + * **Input types affected:** text, select-multiple + * + * @default true + */ + duplicateItemsAllowed: boolean; + /** + * What divides each value. The default delimiter separates each value with a comma: `"Value 1, Value 2, Value 3"`. + * + * **Input types affected:** text + * + * @default ',' + */ + delimiter: string; + /** + * Whether a user can paste into the input. + * + * **Input types affected:** text, select-multiple + * + * @default true + */ + paste: boolean; + /** + * Whether a search area should be shown. + * + * @note Multiple select boxes will always show search areas. + * + * **Input types affected:** select-one + * + * @default true + */ + searchEnabled: boolean; + /** + * Whether choices should be filtered by input or not. If `false`, the search event will still emit, but choices will not be filtered. + * + * **Input types affected:** select-one + * + * @default true + */ + searchChoices: boolean; + /** + * The minimum length a search value should be before choices are searched. + * + * **Input types affected:** select-one, select-multiple + * + * @default 1 + */ + searchFloor: number; + /** + * The maximum amount of search results to show. + * + * **Input types affected:** select-one, select-multiple + * + * @default 4 + */ + searchResultLimit: number; + /** + * Specify which fields should be used when a user is searching. If you have added custom properties to your choices, you can add these values thus: `['label', 'value', 'customProperties.example']`. + * + * Input types affected:select-one, select-multiple + * + * @default ['label', 'value'] + */ + searchFields: string[]; + /** + * Whether the dropdown should appear above `(top)` or below `(bottom)` the input. By default, if there is not enough space within the window the dropdown will appear above the input, otherwise below it. + * + * **Input types affected:** select-one, select-multiple + * + * @default 'auto' + */ + position: PositionOptionsType; + /** + * Whether the scroll position should reset after adding an item. + * + * **Input types affected:** select-multiple + * + * @default true + */ + resetScrollPosition: boolean; + /** + * Whether choices and groups should be sorted. If false, choices/groups will appear in the order they were given. + * + * **Input types affected:** select-one, select-multiple + * + * @default true + */ + shouldSort: boolean; + /** + * Whether items should be sorted. If false, items will appear in the order they were selected. + * + * **Input types affected:** text, select-multiple + * + * @default false + */ + shouldSortItems: boolean; + /** + * The function that will sort choices and items before they are displayed (unless a user is searching). By default choices and items are sorted by alphabetical order. + * + * **Input types affected:** select-one, select-multiple + * + * @example + * ``` + * // Sorting via length of label from largest to smallest + * const example = new Choices(element, { + * sorter: function(a, b) { + * return b.label.length - a.label.length; + * }, + * }; + * ``` + * + * @default sortByAlpha + */ + sorter: (current: Choice, next: Choice) => number; + /** + * Whether the input should show a placeholder. Used in conjunction with `placeholderValue`. If `placeholder` is set to true and no value is passed to `placeholderValue`, the passed input's placeholder attribute will be used as the placeholder value. + * + * **Input types affected:** text, select-multiple + * + * @note For single select boxes, the recommended way of adding a placeholder is as follows: + * ``` + * + * ``` + * + * @default true + */ + placeholder: boolean; + /** + * The value of the inputs placeholder. + * + * **Input types affected:** text, select-multiple + * + * @default null + */ + placeholderValue: string | null; + /** + * The value of the search inputs placeholder. + * + * **Input types affected:** select-one + * + * @default null + */ + searchPlaceholderValue: string | null; + /** + * Prepend a value to each item added/selected. + * + * **Input types affected:** text, select-one, select-multiple + * + * @default null + */ + prependValue: string | null; + /** + * Append a value to each item added/selected. + * + * **Input types affected:** text, select-one, select-multiple + * + * @default null + */ + appendValue: string | null; + /** + * Whether selected choices should be removed from the list. By default choices are removed when they are selected in multiple select box. To always render choices pass `always`. + * + * **Input types affected:** select-one, select-multiple + * + * @default 'auto'; + */ + renderSelectedChoices: 'auto' | 'always'; + /** + * The text that is shown whilst choices are being populated via AJAX. + * + * **Input types affected:** select-one, select-multiple + * + * @default 'Loading...' + */ + loadingText: string; + /** + * The text that is shown when a user's search has returned no results. Optionally pass a function returning a string. + * + * **Input types affected:** select-one, select-multiple + * + * @default 'No results found' + */ + noResultsText: string | Types.StringFunction; + /** + * The text that is shown when a user has selected all possible choices. Optionally pass a function returning a string. + * + * **Input types affected:** select-multiple + * + * @default 'No choices to choose from' + */ + noChoicesText: string | Types.StringFunction; + /** + * The text that is shown when a user hovers over a selectable choice. + * + * **Input types affected:** select-multiple, select-one + * + * @default 'Press to select' + */ + itemSelectText: string; + /** + * The text that is shown when a user has focus on the input but has already reached the **max item count** [https://github.com/jshjohnson/Choices#maxitemcount]. To access the max item count, pass a function with a `maxItemCount` argument (see the **default config** [https://github.com/jshjohnson/Choices#setup] for an example), otherwise pass a string. + * + * **Input types affected:** text + * + * @default + * ``` + * (maxItemCount) => `Only ${maxItemCount} values can be added.`; + * ``` + */ + maxItemText: string | Types.NoticeLimitFunction; + /** + * If no duplicates are allowed, and the value already exists in the array. + * + * @default 'Only unique values can be added' + */ + uniqueItemText: string | Types.NoticeStringFunction; + /** + * The text that is shown when addItemFilter is passed and it returns false + * + * **Input types affected:** text + * + * @default 'Only values matching specific conditions can be added' + */ + customAddItemText: string | Types.NoticeStringFunction; + /** + * Compare choice and value in appropriate way (e.g. deep equality for objects). To compare choice and value, pass a function with a `valueComparer` argument (see the [default config](https://github.com/jshjohnson/Choices#setup) for an example). + * + * **Input types affected:** select-one, select-multiple + * + * @default + * ``` + * (choice, item) => choice === item; + * ``` + */ + valueComparer: Types.ValueCompareFunction; + /** + * Classes added to HTML generated by By default classnames follow the BEM notation. + * + * **Input types affected:** text, select-one, select-multiple + */ + classNames: ClassNames; + /** + * Choices uses the great Fuse library for searching. You can find more options here: https://fusejs.io/api/options.html + */ + fuseOptions: Fuse.IFuseOptions; + /** + * Function to run once Choices initialises. + * + * **Input types affected:** text, select-one, select-multiple + * + * @note For each callback, this refers to the current instance of This can be useful if you need access to methods `(this.disable())` or the config object `(this.config)`. + * + * @default null + */ + callbackOnInit: ((this: Choices) => void) | null; + /** + * Function to run on template creation. Through this callback it is possible to provide custom templates for the various components of Choices (see terminology). For Choices to work with custom templates, it is important you maintain the various data attributes defined here [https://github.com/jshjohnson/Choices/blob/67f29c286aa21d88847adfcd6304dc7d068dc01f/assets/scripts/src/choices.js#L1993-L2067]. + * + * **Input types affected:** text, select-one, select-multiple + * + * @note For each callback, this refers to the current instance of This can be useful if you need access to methods `(this.disable())` or the config object `(this.config)`. + * + * @example + * ``` + * const example = new Choices(element, { + * callbackOnCreateTemplates: function (template) { + * var classNames = this.config.classNames; + * return { + * item: (data) => { + * return template(` + *
+ * ${data.label} + *
+ * `); + * }, + * choice: (data) => { + * return template(` + *
0 ? 'role="treeitem"' : 'role="option"'}> + * ${data.label} + *
+ * `); + * }, + * }; + * } + * }); + * ``` + * + * @default null + */ + callbackOnCreateTemplates: ((template: Types.StrToEl) => void) | null; +} +//# sourceMappingURL=options.d.ts.map \ No newline at end of file diff --git a/types/src/scripts/interfaces/options.d.ts.map b/types/src/scripts/interfaces/options.d.ts.map new file mode 100644 index 0000000..3b2102a --- /dev/null +++ b/types/src/scripts/interfaces/options.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../../../../src/scripts/interfaces/options.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC;;;;;;;;GAQG;AACH,MAAM,WAAW,OAAO;IACtB;;;;;;OAMG;IACH,MAAM,EAAE,OAAO,CAAC;IAEhB;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4BG;IACH,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC;IAE3B;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IACH,OAAO,EAAE,MAAM,EAAE,CAAC;IAElB;;;;;;OAMG;IACH,iBAAiB,EAAE,MAAM,CAAC;IAE1B;;;;;;OAMG;IACH,YAAY,EAAE,MAAM,CAAC;IAErB;;;;;;OAMG;IACH,QAAQ,EAAE,OAAO,CAAC;IAElB;;;;;;OAMG;IACH,aAAa,EAAE,MAAM,GAAG,MAAM,GAAG,KAAK,CAAC,cAAc,GAAG,IAAI,CAAC;IAE7D;;;;;;;;;OASG;IACH,WAAW,EAAE,MAAM,GAAG,KAAK,CAAC,oBAAoB,CAAC;IAEjD;;;;;;OAMG;IACH,WAAW,EAAE,OAAO,CAAC;IAErB;;;;;;OAMG;IACH,gBAAgB,EAAE,OAAO,CAAC;IAE1B;;;;;;OAMG;IACH,SAAS,EAAE,OAAO,CAAC;IAEnB;;;;;;;;;;OAUG;IACH,SAAS,EAAE,OAAO,CAAC;IAEnB;;;;;;OAMG;IACH,qBAAqB,EAAE,OAAO,CAAC;IAE/B;;;;;;OAMG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;;;;;OAMG;IACH,KAAK,EAAE,OAAO,CAAC;IAEf;;;;;;;;OAQG;IACH,aAAa,EAAE,OAAO,CAAC;IAEvB;;;;;;OAMG;IACH,aAAa,EAAE,OAAO,CAAC;IAEvB;;;;;;OAMG;IACH,WAAW,EAAE,MAAM,CAAC;IAEpB;;;;;;OAMG;IACH,iBAAiB,EAAE,MAAM,CAAC;IAE1B;;;;;;OAMG;IACH,YAAY,EAAE,MAAM,EAAE,CAAC;IAEvB;;;;;;OAMG;IACH,QAAQ,EAAE,mBAAmB,CAAC;IAE9B;;;;;;OAMG;IACH,mBAAmB,EAAE,OAAO,CAAC;IAE7B;;;;;;OAMG;IACH,UAAU,EAAE,OAAO,CAAC;IAEpB;;;;;;OAMG;IACH,eAAe,EAAE,OAAO,CAAC;IAEzB;;;;;;;;;;;;;;;;OAgBG;IACH,MAAM,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;IAElD;;;;;;;;;;;;;;;;OAgBG;IACH,WAAW,EAAE,OAAO,CAAC;IAErB;;;;;;OAMG;IACH,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAEhC;;;;;;OAMG;IACH,sBAAsB,EAAE,MAAM,GAAG,IAAI,CAAC;IAEtC;;;;;;OAMG;IACH,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAE5B;;;;;;OAMG;IACH,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAE3B;;;;;;OAMG;IACH,qBAAqB,EAAE,MAAM,GAAG,QAAQ,CAAC;IAEzC;;;;;;OAMG;IACH,WAAW,EAAE,MAAM,CAAC;IAEpB;;;;;;OAMG;IACH,aAAa,EAAE,MAAM,GAAG,KAAK,CAAC,cAAc,CAAC;IAE7C;;;;;;OAMG;IACH,aAAa,EAAE,MAAM,GAAG,KAAK,CAAC,cAAc,CAAC;IAE7C;;;;;;OAMG;IACH,cAAc,EAAE,MAAM,CAAC;IAEvB;;;;;;;;;OASG;IACH,WAAW,EAAE,MAAM,GAAG,KAAK,CAAC,mBAAmB,CAAC;IAEhD;;;;OAIG;IACH,cAAc,EAAE,MAAM,GAAG,KAAK,CAAC,oBAAoB,CAAC;IAEpD;;;;;;OAMG;IACH,iBAAiB,EAAE,MAAM,GAAG,KAAK,CAAC,oBAAoB,CAAC;IAEvD;;;;;;;;;OASG;IACH,aAAa,EAAE,KAAK,CAAC,oBAAoB,CAAC;IAE1C;;;;OAIG;IACH,UAAU,EAAE,UAAU,CAAC;IAEvB;;OAEG;IACH,WAAW,EAAE,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;IAExC;;;;;;;;OAQG;IACH,cAAc,EAAE,CAAC,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC,GAAG,IAAI,CAAC;IAEjD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAiCG;IACH,yBAAyB,EAAE,CAAC,CAAC,QAAQ,EAAE,KAAK,CAAC,OAAO,KAAK,IAAI,CAAC,GAAG,IAAI,CAAC;CACvE"} \ No newline at end of file diff --git a/types/src/scripts/interfaces/passed-element-type.d.ts b/types/src/scripts/interfaces/passed-element-type.d.ts new file mode 100644 index 0000000..ba9e99d --- /dev/null +++ b/types/src/scripts/interfaces/passed-element-type.d.ts @@ -0,0 +1,2 @@ +export declare type PassedElementType = 'text' | 'select-one' | 'select-multiple'; +//# sourceMappingURL=passed-element-type.d.ts.map \ No newline at end of file diff --git a/types/src/scripts/interfaces/passed-element-type.d.ts.map b/types/src/scripts/interfaces/passed-element-type.d.ts.map new file mode 100644 index 0000000..86e4161 --- /dev/null +++ b/types/src/scripts/interfaces/passed-element-type.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"passed-element-type.d.ts","sourceRoot":"","sources":["../../../../../src/scripts/interfaces/passed-element-type.ts"],"names":[],"mappings":"AAAA,oBAAY,iBAAiB,GAAG,MAAM,GAAG,YAAY,GAAG,iBAAiB,CAAC"} \ No newline at end of file diff --git a/types/src/scripts/interfaces/passed-element.d.ts b/types/src/scripts/interfaces/passed-element.d.ts new file mode 100644 index 0000000..54172d7 --- /dev/null +++ b/types/src/scripts/interfaces/passed-element.d.ts @@ -0,0 +1,129 @@ +import { Choices } from './choices'; +import { Choice } from './choice'; +import { ClassNames } from './class-names'; +import { EventType } from './event-type'; +import { PassedElementType } from './passed-element-type'; +export interface PassedElement extends HTMLElement { + classNames: ClassNames; + element: (HTMLInputElement | HTMLSelectElement) & { + addEventListener(type: K, listener: (this: HTMLInputElement | HTMLSelectElement, ev: EventMap[K]) => void, options?: boolean | AddEventListenerOptions): void; + }; + type: PassedElementType; + isDisabled: boolean; + parentInstance: Choices; +} +/** + * Events fired by Choices behave the same as standard events. Each event is triggered on the element passed to Choices (accessible via `this.passedElement`. Arguments are accessible within the `event.detail` object. + */ +export interface EventMap { + /** + * Triggered each time an item is added (programmatically or by the user). + * + * **Input types affected:** text, select-one, select-multiple + * + * Arguments: id, value, label, groupValue, keyCode + */ + addItem: CustomEvent<{ + id: number; + value: string; + label: string; + groupValue: string; + keyCode: number; + }>; + /** + * Triggered each time an item is removed (programmatically or by the user). + * + * **Input types affected:** text, select-one, select-multiple + * + * Arguments: id, value, label, groupValue + */ + removeItem: CustomEvent<{ + id: number; + value: string; + label: string; + groupValue: string; + }>; + /** + * Triggered each time an item is highlighted. + * + * **Input types affected:** text, select-multiple + * + * Arguments: id, value, label, groupValue + */ + highlightItem: CustomEvent<{ + id: number; + value: string; + label: string; + groupValue: string; + }>; + /** + * Triggered each time an item is unhighlighted. + * + * **Input types affected:** text, select-multiple + * + * Arguments: id, value, label, groupValue + */ + unhighlightItem: CustomEvent<{ + id: number; + value: string; + label: string; + groupValue: string; + }>; + /** + * Triggered each time a choice is selected **by a user**, regardless if it changes the value of the input. + * + * **Input types affected:** select-one, select-multiple + * + * Arguments: choice: Choice + */ + choice: CustomEvent<{ + choice: Choice; + }>; + /** + * Triggered each time an item is added/removed **by a user**. + * + * **Input types affected:** text, select-one, select-multiple + * + * Arguments: value + */ + change: CustomEvent<{ + value: string; + }>; + /** + * Triggered when a user types into an input to search choices. + * + * **Input types affected:** select-one, select-multiple + * + * Arguments: value, resultCount + */ + search: CustomEvent<{ + value: string; + resultCount: number; + }>; + /** + * Triggered when the dropdown is shown. + * + * **Input types affected:** select-one, select-multiple + * + * Arguments: - + */ + showDropdown: CustomEvent; + /** + * Triggered when the dropdown is hidden. + * + * **Input types affected:** select-one, select-multiple + * + * Arguments: - + */ + hideDropdown: CustomEvent; + /** + * Triggered when a choice from the dropdown is highlighted. + * + * Input types affected: select-one, select-multiple + * Arguments: el is the choice.passedElement that was affected. + */ + highlightChoice: CustomEvent<{ + el: PassedElement; + }>; +} +//# sourceMappingURL=passed-element.d.ts.map \ No newline at end of file diff --git a/types/src/scripts/interfaces/passed-element.d.ts.map b/types/src/scripts/interfaces/passed-element.d.ts.map new file mode 100644 index 0000000..4798e53 --- /dev/null +++ b/types/src/scripts/interfaces/passed-element.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"passed-element.d.ts","sourceRoot":"","sources":["../../../../../src/scripts/interfaces/passed-element.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE1D,MAAM,WAAW,aAAc,SAAQ,WAAW;IAChD,UAAU,EAAE,UAAU,CAAC;IACvB,OAAO,EAAE,CAAC,gBAAgB,GAAG,iBAAiB,CAAC,GAAG;QAEhD,gBAAgB,CAAC,CAAC,SAAS,SAAS,EAClC,IAAI,EAAE,CAAC,EACP,QAAQ,EAAE,CACR,IAAI,EAAE,gBAAgB,GAAG,iBAAiB,EAC1C,EAAE,EAAE,QAAQ,CAAC,CAAC,CAAC,KACZ,IAAI,EACT,OAAO,CAAC,EAAE,OAAO,GAAG,uBAAuB,GAC1C,IAAI,CAAC;KACT,CAAC;IACF,IAAI,EAAE,iBAAiB,CAAC;IACxB,UAAU,EAAE,OAAO,CAAC;IACpB,cAAc,EAAE,OAAO,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB;;;;;;OAMG;IACH,OAAO,EAAE,WAAW,CAAC;QACnB,EAAE,EAAE,MAAM,CAAC;QACX,KAAK,EAAE,MAAM,CAAC;QACd,KAAK,EAAE,MAAM,CAAC;QACd,UAAU,EAAE,MAAM,CAAC;QACnB,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC,CAAC;IAEH;;;;;;OAMG;IACH,UAAU,EAAE,WAAW,CAAC;QACtB,EAAE,EAAE,MAAM,CAAC;QACX,KAAK,EAAE,MAAM,CAAC;QACd,KAAK,EAAE,MAAM,CAAC;QACd,UAAU,EAAE,MAAM,CAAC;KACpB,CAAC,CAAC;IAEH;;;;;;OAMG;IACH,aAAa,EAAE,WAAW,CAAC;QACzB,EAAE,EAAE,MAAM,CAAC;QACX,KAAK,EAAE,MAAM,CAAC;QACd,KAAK,EAAE,MAAM,CAAC;QACd,UAAU,EAAE,MAAM,CAAC;KACpB,CAAC,CAAC;IAEH;;;;;;OAMG;IACH,eAAe,EAAE,WAAW,CAAC;QAC3B,EAAE,EAAE,MAAM,CAAC;QACX,KAAK,EAAE,MAAM,CAAC;QACd,KAAK,EAAE,MAAM,CAAC;QACd,UAAU,EAAE,MAAM,CAAC;KACpB,CAAC,CAAC;IAEH;;;;;;OAMG;IACH,MAAM,EAAE,WAAW,CAAC;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAExC;;;;;;OAMG;IACH,MAAM,EAAE,WAAW,CAAC;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAEvC;;;;;;OAMG;IACH,MAAM,EAAE,WAAW,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAE5D;;;;;;OAMG;IACH,YAAY,EAAE,WAAW,CAAC,SAAS,CAAC,CAAC;IAErC;;;;;;OAMG;IACH,YAAY,EAAE,WAAW,CAAC,SAAS,CAAC,CAAC;IAErC;;;;;OAKG;IACH,eAAe,EAAE,WAAW,CAAC;QAAE,EAAE,EAAE,aAAa,CAAA;KAAE,CAAC,CAAC;CACrD"} \ No newline at end of file diff --git a/types/src/scripts/interfaces/position-options-type.d.ts b/types/src/scripts/interfaces/position-options-type.d.ts new file mode 100644 index 0000000..a66abd6 --- /dev/null +++ b/types/src/scripts/interfaces/position-options-type.d.ts @@ -0,0 +1,2 @@ +export declare type PositionOptionsType = 'auto' | 'top' | 'bottom'; +//# sourceMappingURL=position-options-type.d.ts.map \ No newline at end of file diff --git a/types/src/scripts/interfaces/position-options-type.d.ts.map b/types/src/scripts/interfaces/position-options-type.d.ts.map new file mode 100644 index 0000000..a810b70 --- /dev/null +++ b/types/src/scripts/interfaces/position-options-type.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"position-options-type.d.ts","sourceRoot":"","sources":["../../../../../src/scripts/interfaces/position-options-type.ts"],"names":[],"mappings":"AAAA,oBAAY,mBAAmB,GAAG,MAAM,GAAG,KAAK,GAAG,QAAQ,CAAC"} \ No newline at end of file diff --git a/types/src/scripts/interfaces/state.d.ts b/types/src/scripts/interfaces/state.d.ts new file mode 100644 index 0000000..a713d05 --- /dev/null +++ b/types/src/scripts/interfaces/state.d.ts @@ -0,0 +1,10 @@ +import { Choice } from './choice'; +import { Group } from './group'; +import { Item } from './item'; +export interface State { + choices: Choice[]; + groups: Group[]; + items: Item[]; + loading: boolean; +} +//# sourceMappingURL=state.d.ts.map \ No newline at end of file diff --git a/types/src/scripts/interfaces/state.d.ts.map b/types/src/scripts/interfaces/state.d.ts.map new file mode 100644 index 0000000..0907396 --- /dev/null +++ b/types/src/scripts/interfaces/state.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../../../../src/scripts/interfaces/state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE9B,MAAM,WAAW,KAAK;IACpB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,MAAM,EAAE,KAAK,EAAE,CAAC;IAChB,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,OAAO,EAAE,OAAO,CAAC;CAClB"} \ No newline at end of file diff --git a/types/src/scripts/interfaces/types.d.ts b/types/src/scripts/interfaces/types.d.ts new file mode 100644 index 0000000..5a2cf64 --- /dev/null +++ b/types/src/scripts/interfaces/types.d.ts @@ -0,0 +1,9 @@ +export declare namespace Types { + type StrToEl = (str: string) => HTMLElement | HTMLInputElement | HTMLOptionElement; + type StringFunction = () => string; + type NoticeStringFunction = (value: string) => string; + type NoticeLimitFunction = (maxItemCount: number) => string; + type FilterFunction = (value: string) => boolean; + type ValueCompareFunction = (value1: string, value2: string) => boolean; +} +//# sourceMappingURL=types.d.ts.map \ No newline at end of file diff --git a/types/src/scripts/interfaces/types.d.ts.map b/types/src/scripts/interfaces/types.d.ts.map new file mode 100644 index 0000000..4c44c1d --- /dev/null +++ b/types/src/scripts/interfaces/types.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/scripts/interfaces/types.ts"],"names":[],"mappings":"AAAA,yBAAiB,KAAK,CAAC;IACrB,KAAY,OAAO,GAAG,CACpB,GAAG,EAAE,MAAM,KACR,WAAW,GAAG,gBAAgB,GAAG,iBAAiB,CAAC;IACxD,KAAY,cAAc,GAAG,MAAM,MAAM,CAAC;IAC1C,KAAY,oBAAoB,GAAG,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;IAC7D,KAAY,mBAAmB,GAAG,CAAC,YAAY,EAAE,MAAM,KAAK,MAAM,CAAC;IACnE,KAAY,cAAc,GAAG,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC;IACxD,KAAY,oBAAoB,GAAG,CACjC,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,KACX,OAAO,CAAC;CACd"} \ No newline at end of file diff --git a/types/src/scripts/lib/utils.d.ts b/types/src/scripts/lib/utils.d.ts new file mode 100644 index 0000000..15fd587 --- /dev/null +++ b/types/src/scripts/lib/utils.d.ts @@ -0,0 +1,27 @@ +import { Choice } from '../interfaces/choice'; +import { EventType } from '../interfaces/event-type'; +export declare const getRandomNumber: (min: number, max: number) => number; +export declare const generateChars: (length: number) => string; +export declare const generateId: (element: HTMLInputElement | HTMLSelectElement, prefix: string) => string; +export declare const getType: (obj: any) => string; +export declare const isType: (type: string, obj: any) => boolean; +export declare const wrap: (element: HTMLElement, wrapper?: HTMLElement) => HTMLElement; +export declare const getAdjacentEl: (startEl: Element, selector: string, direction?: number) => Element; +export declare const isScrolledIntoView: (element: HTMLElement, parent: HTMLElement, direction?: number) => boolean; +export declare const sanitise: (value: string | T) => string | T; +export declare const strToEl: (str: string) => Element; +interface RecordToCompare { + value: string; + label?: string; +} +export declare const sortByAlpha: ({ value, label }: RecordToCompare, { value: value2, label: label2 }: RecordToCompare) => number; +export declare const sortByScore: (a: Pick, b: Pick) => number; +export declare const dispatchEvent: (element: HTMLElement, type: EventType, customArgs?: object | null) => boolean; +export declare const existsInArray: (array: any[], value: string, key?: string) => boolean; +export declare const cloneObject: (obj: object) => object; +/** + * Returns an array of keys present on the first but missing on the second object + */ +export declare const diff: (a: Record, b: Record) => string[]; +export {}; +//# sourceMappingURL=utils.d.ts.map \ No newline at end of file diff --git a/types/src/scripts/lib/utils.d.ts.map b/types/src/scripts/lib/utils.d.ts.map new file mode 100644 index 0000000..560f2ff --- /dev/null +++ b/types/src/scripts/lib/utils.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../../src/scripts/lib/utils.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAErD,eAAO,MAAM,eAAe,QAAS,MAAM,OAAO,MAAM,KAAG,MACZ,CAAC;AAEhD,eAAO,MAAM,aAAa,WAAY,MAAM,KAAG,MAC6B,CAAC;AAE7E,eAAO,MAAM,UAAU,YACZ,gBAAgB,GAAG,iBAAiB,UACrC,MAAM,KACb,MASF,CAAC;AAEF,eAAO,MAAM,OAAO,QAAS,GAAG,KAAG,MACe,CAAC;AAEnD,eAAO,MAAM,MAAM,SAAU,MAAM,OAAO,GAAG,KAAG,OACY,CAAC;AAE7D,eAAO,MAAM,IAAI,YACN,WAAW,YACX,WAAW,KACnB,WAUF,CAAC;AAEF,eAAO,MAAM,aAAa,YACf,OAAO,YACN,MAAM,yBAEf,OAYF,CAAC;AAEF,eAAO,MAAM,kBAAkB,YACpB,WAAW,UACZ,WAAW,yBAElB,OAkBF,CAAC;AAEF,eAAO,MAAM,QAAQ,sCAUpB,CAAC;AAEF,eAAO,MAAM,OAAO,QAAe,MAAM,KAAK,OAc1C,CAAC;AAEL,UAAU,eAAe;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AACD,eAAO,MAAM,WAAW,qBACI,eAAe,oCACE,eAAe,KACzD,MAKC,CAAC;AAEL,eAAO,MAAM,WAAW,MACnB,KAAK,MAAM,EAAE,OAAO,CAAC,KACrB,KAAK,MAAM,EAAE,OAAO,CAAC,KACvB,MAKF,CAAC;AAEF,eAAO,MAAM,aAAa,YACf,WAAW,QACd,SAAS,eACH,MAAM,GAAG,IAAI,KACxB,OAQF,CAAC;AAEF,eAAO,MAAM,aAAa,UACjB,GAAG,EAAE,SACL,MAAM,mBAEZ,OAOC,CAAC;AAEL,eAAO,MAAM,WAAW,QAAS,MAAM,KAAG,MACT,CAAC;AAElC;;GAEG;AACH,eAAO,MAAM,IAAI,MACZ,OAAO,MAAM,EAAE,GAAG,CAAC,KACnB,OAAO,MAAM,EAAE,GAAG,CAAC,KACrB,MAAM,EAKR,CAAC"} \ No newline at end of file diff --git a/types/src/scripts/lib/utils.test.d.ts b/types/src/scripts/lib/utils.test.d.ts new file mode 100644 index 0000000..c727c85 --- /dev/null +++ b/types/src/scripts/lib/utils.test.d.ts @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=utils.test.d.ts.map \ No newline at end of file diff --git a/types/src/scripts/lib/utils.test.d.ts.map b/types/src/scripts/lib/utils.test.d.ts.map new file mode 100644 index 0000000..58a4177 --- /dev/null +++ b/types/src/scripts/lib/utils.test.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"utils.test.d.ts","sourceRoot":"","sources":["../../../../../src/scripts/lib/utils.test.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/types/src/scripts/reducers/choices.d.ts b/types/src/scripts/reducers/choices.d.ts new file mode 100644 index 0000000..e94ae64 --- /dev/null +++ b/types/src/scripts/reducers/choices.d.ts @@ -0,0 +1,8 @@ +import { AddChoiceAction, FilterChoicesAction, ActivateChoicesAction, ClearChoicesAction } from '../actions/choices'; +import { AddItemAction, RemoveItemAction } from '../actions/items'; +import { Choice } from '../interfaces/choice'; +export declare const defaultState: never[]; +declare type ActionTypes = AddChoiceAction | FilterChoicesAction | ActivateChoicesAction | ClearChoicesAction | AddItemAction | RemoveItemAction | Record; +export default function choices(state?: Choice[], action?: ActionTypes): Choice[]; +export {}; +//# sourceMappingURL=choices.d.ts.map \ No newline at end of file diff --git a/types/src/scripts/reducers/choices.d.ts.map b/types/src/scripts/reducers/choices.d.ts.map new file mode 100644 index 0000000..02f73cd --- /dev/null +++ b/types/src/scripts/reducers/choices.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"choices.d.ts","sourceRoot":"","sources":["../../../../../src/scripts/reducers/choices.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,qBAAqB,EACrB,kBAAkB,EACnB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACnE,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAE9C,eAAO,MAAM,YAAY,SAAK,CAAC;AAE/B,aAAK,WAAW,GACZ,eAAe,GACf,mBAAmB,GACnB,qBAAqB,GACrB,kBAAkB,GAClB,aAAa,GACb,gBAAgB,GAChB,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;AAE1B,MAAM,CAAC,OAAO,UAAU,OAAO,CAC7B,KAAK,GAAE,MAAM,EAAiB,EAC9B,MAAM,GAAE,WAAgB,GACvB,MAAM,EAAE,CAwGV"} \ No newline at end of file diff --git a/types/src/scripts/reducers/choices.test.d.ts b/types/src/scripts/reducers/choices.test.d.ts new file mode 100644 index 0000000..1b34de1 --- /dev/null +++ b/types/src/scripts/reducers/choices.test.d.ts @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=choices.test.d.ts.map \ No newline at end of file diff --git a/types/src/scripts/reducers/choices.test.d.ts.map b/types/src/scripts/reducers/choices.test.d.ts.map new file mode 100644 index 0000000..abcc18f --- /dev/null +++ b/types/src/scripts/reducers/choices.test.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"choices.test.d.ts","sourceRoot":"","sources":["../../../../../src/scripts/reducers/choices.test.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/types/src/scripts/reducers/groups.d.ts b/types/src/scripts/reducers/groups.d.ts new file mode 100644 index 0000000..ba4d669 --- /dev/null +++ b/types/src/scripts/reducers/groups.d.ts @@ -0,0 +1,9 @@ +import { AddGroupAction } from '../actions/groups'; +import { ClearChoicesAction } from '../actions/choices'; +import { Group } from '../interfaces/group'; +import { State } from '../interfaces/state'; +export declare const defaultState: never[]; +declare type ActionTypes = AddGroupAction | ClearChoicesAction | Record; +export default function groups(state?: Group[], action?: ActionTypes): State['groups']; +export {}; +//# sourceMappingURL=groups.d.ts.map \ No newline at end of file diff --git a/types/src/scripts/reducers/groups.d.ts.map b/types/src/scripts/reducers/groups.d.ts.map new file mode 100644 index 0000000..0aff081 --- /dev/null +++ b/types/src/scripts/reducers/groups.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"groups.d.ts","sourceRoot":"","sources":["../../../../../src/scripts/reducers/groups.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAC5C,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAE5C,eAAO,MAAM,YAAY,SAAK,CAAC;AAE/B,aAAK,WAAW,GAAG,cAAc,GAAG,kBAAkB,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;AAE/E,MAAM,CAAC,OAAO,UAAU,MAAM,CAC5B,KAAK,GAAE,KAAK,EAAiB,EAC7B,MAAM,GAAE,WAAgB,GACvB,KAAK,CAAC,QAAQ,CAAC,CAwBjB"} \ No newline at end of file diff --git a/types/src/scripts/reducers/groups.test.d.ts b/types/src/scripts/reducers/groups.test.d.ts new file mode 100644 index 0000000..8d44d56 --- /dev/null +++ b/types/src/scripts/reducers/groups.test.d.ts @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=groups.test.d.ts.map \ No newline at end of file diff --git a/types/src/scripts/reducers/groups.test.d.ts.map b/types/src/scripts/reducers/groups.test.d.ts.map new file mode 100644 index 0000000..ea6a989 --- /dev/null +++ b/types/src/scripts/reducers/groups.test.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"groups.test.d.ts","sourceRoot":"","sources":["../../../../../src/scripts/reducers/groups.test.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/types/src/scripts/reducers/index.d.ts b/types/src/scripts/reducers/index.d.ts new file mode 100644 index 0000000..212bcc1 --- /dev/null +++ b/types/src/scripts/reducers/index.d.ts @@ -0,0 +1,9 @@ +export declare const defaultState: { + groups: never[]; + items: never[]; + choices: never[]; + loading: boolean; +}; +declare const rootReducer: (passedState: any, action: any) => object; +export default rootReducer; +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/types/src/scripts/reducers/index.d.ts.map b/types/src/scripts/reducers/index.d.ts.map new file mode 100644 index 0000000..d95e352 --- /dev/null +++ b/types/src/scripts/reducers/index.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/scripts/reducers/index.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,YAAY;;;;;CAKxB,CAAC;AASF,QAAA,MAAM,WAAW,qCAA0B,MAa1C,CAAC;AAEF,eAAe,WAAW,CAAC"} \ No newline at end of file diff --git a/types/src/scripts/reducers/index.test.d.ts b/types/src/scripts/reducers/index.test.d.ts new file mode 100644 index 0000000..121d59b --- /dev/null +++ b/types/src/scripts/reducers/index.test.d.ts @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=index.test.d.ts.map \ No newline at end of file diff --git a/types/src/scripts/reducers/index.test.d.ts.map b/types/src/scripts/reducers/index.test.d.ts.map new file mode 100644 index 0000000..c182b40 --- /dev/null +++ b/types/src/scripts/reducers/index.test.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"index.test.d.ts","sourceRoot":"","sources":["../../../../../src/scripts/reducers/index.test.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/types/src/scripts/reducers/items.d.ts b/types/src/scripts/reducers/items.d.ts new file mode 100644 index 0000000..0f8bc00 --- /dev/null +++ b/types/src/scripts/reducers/items.d.ts @@ -0,0 +1,8 @@ +import { AddItemAction, RemoveItemAction, HighlightItemAction } from '../actions/items'; +import { Item } from '../interfaces/item'; +import { State } from '../interfaces/state'; +export declare const defaultState: never[]; +declare type ActionTypes = AddItemAction | RemoveItemAction | HighlightItemAction | Record; +export default function items(state?: Item[], action?: ActionTypes): State['items']; +export {}; +//# sourceMappingURL=items.d.ts.map \ No newline at end of file diff --git a/types/src/scripts/reducers/items.d.ts.map b/types/src/scripts/reducers/items.d.ts.map new file mode 100644 index 0000000..a057d64 --- /dev/null +++ b/types/src/scripts/reducers/items.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"items.d.ts","sourceRoot":"","sources":["../../../../../src/scripts/reducers/items.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,mBAAmB,EACpB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAE5C,eAAO,MAAM,YAAY,SAAK,CAAC;AAE/B,aAAK,WAAW,GACZ,aAAa,GACb,gBAAgB,GAChB,mBAAmB,GACnB,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;AAE1B,MAAM,CAAC,OAAO,UAAU,KAAK,CAC3B,KAAK,GAAE,IAAI,EAAiB,EAC5B,MAAM,GAAE,WAAgB,GACvB,KAAK,CAAC,OAAO,CAAC,CA0DhB"} \ No newline at end of file diff --git a/types/src/scripts/reducers/items.test.d.ts b/types/src/scripts/reducers/items.test.d.ts new file mode 100644 index 0000000..e81d58b --- /dev/null +++ b/types/src/scripts/reducers/items.test.d.ts @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=items.test.d.ts.map \ No newline at end of file diff --git a/types/src/scripts/reducers/items.test.d.ts.map b/types/src/scripts/reducers/items.test.d.ts.map new file mode 100644 index 0000000..6419257 --- /dev/null +++ b/types/src/scripts/reducers/items.test.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"items.test.d.ts","sourceRoot":"","sources":["../../../../../src/scripts/reducers/items.test.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/types/src/scripts/reducers/loading.d.ts b/types/src/scripts/reducers/loading.d.ts new file mode 100644 index 0000000..0e32bf9 --- /dev/null +++ b/types/src/scripts/reducers/loading.d.ts @@ -0,0 +1,7 @@ +import { SetIsLoadingAction } from '../actions/misc'; +import { State } from '../interfaces/state'; +export declare const defaultState = false; +declare type ActionTypes = SetIsLoadingAction | Record; +declare const general: (state?: boolean, action?: ActionTypes) => State['loading']; +export default general; +//# sourceMappingURL=loading.d.ts.map \ No newline at end of file diff --git a/types/src/scripts/reducers/loading.d.ts.map b/types/src/scripts/reducers/loading.d.ts.map new file mode 100644 index 0000000..e877cf9 --- /dev/null +++ b/types/src/scripts/reducers/loading.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"loading.d.ts","sourceRoot":"","sources":["../../../../../src/scripts/reducers/loading.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAE5C,eAAO,MAAM,YAAY,QAAQ,CAAC;AAElC,aAAK,WAAW,GAAG,kBAAkB,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;AAE9D,QAAA,MAAM,OAAO,6BAEH,WAAW,KAClB,KAAK,CAAC,SAAS,CAUjB,CAAC;AAEF,eAAe,OAAO,CAAC"} \ No newline at end of file diff --git a/types/src/scripts/reducers/loading.test.d.ts b/types/src/scripts/reducers/loading.test.d.ts new file mode 100644 index 0000000..b1d0de1 --- /dev/null +++ b/types/src/scripts/reducers/loading.test.d.ts @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=loading.test.d.ts.map \ No newline at end of file diff --git a/types/src/scripts/reducers/loading.test.d.ts.map b/types/src/scripts/reducers/loading.test.d.ts.map new file mode 100644 index 0000000..1f2efe5 --- /dev/null +++ b/types/src/scripts/reducers/loading.test.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"loading.test.d.ts","sourceRoot":"","sources":["../../../../../src/scripts/reducers/loading.test.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/types/src/scripts/store/store.d.ts b/types/src/scripts/store/store.d.ts new file mode 100644 index 0000000..b6ff412 --- /dev/null +++ b/types/src/scripts/store/store.d.ts @@ -0,0 +1,74 @@ +import { Store as IStore, AnyAction } from 'redux'; +import { Choice } from '../interfaces/choice'; +import { Group } from '../interfaces/group'; +import { Item } from '../interfaces/item'; +import { State } from '../interfaces/state'; +export default class Store { + _store: IStore; + constructor(); + /** + * Subscribe store to function call (wrapped Redux method) + */ + subscribe(onChange: () => void): void; + /** + * Dispatch event to store (wrapped Redux method) + */ + dispatch(action: AnyAction): void; + /** + * Get store object (wrapping Redux method) + */ + get state(): State; + /** + * Get items from store + */ + get items(): Item[]; + /** + * Get active items from store + */ + get activeItems(): Item[]; + /** + * Get highlighted items from store + */ + get highlightedActiveItems(): Item[]; + /** + * Get choices from store + */ + get choices(): Choice[]; + /** + * Get active choices from store + */ + get activeChoices(): Choice[]; + /** + * Get selectable choices from store + */ + get selectableChoices(): Choice[]; + /** + * Get choices that can be searched (excluding placeholders) + */ + get searchableChoices(): Choice[]; + /** + * Get placeholder choice from store + */ + get placeholderChoice(): Choice | undefined; + /** + * Get groups from store + */ + get groups(): Group[]; + /** + * Get active groups from store + */ + get activeGroups(): Group[]; + /** + * Get loading state from store + */ + isLoading(): boolean; + /** + * Get single choice by it's ID + */ + getChoiceById(id: string): Choice | undefined; + /** + * Get group by group id + */ + getGroupById(id: number): Group | undefined; +} +//# sourceMappingURL=store.d.ts.map \ No newline at end of file diff --git a/types/src/scripts/store/store.d.ts.map b/types/src/scripts/store/store.d.ts.map new file mode 100644 index 0000000..32a519e --- /dev/null +++ b/types/src/scripts/store/store.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../../../../src/scripts/store/store.ts"],"names":[],"mappings":"AACA,OAAO,EAAe,KAAK,IAAI,MAAM,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAChE,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAG5C,MAAM,CAAC,OAAO,OAAO,KAAK;IACxB,MAAM,EAAE,MAAM,CAAC;;IAUf;;OAEG;IACH,SAAS,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,IAAI;IAIrC;;OAEG;IACH,QAAQ,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI;IAIjC;;OAEG;IACH,IAAI,KAAK,IAAI,KAAK,CAEjB;IAED;;OAEG;IACH,IAAI,KAAK,IAAI,IAAI,EAAE,CAElB;IAED;;OAEG;IACH,IAAI,WAAW,IAAI,IAAI,EAAE,CAExB;IAED;;OAEG;IACH,IAAI,sBAAsB,IAAI,IAAI,EAAE,CAEnC;IAED;;OAEG;IACH,IAAI,OAAO,IAAI,MAAM,EAAE,CAEtB;IAED;;OAEG;IACH,IAAI,aAAa,IAAI,MAAM,EAAE,CAE5B;IAED;;OAEG;IACH,IAAI,iBAAiB,IAAI,MAAM,EAAE,CAEhC;IAED;;OAEG;IACH,IAAI,iBAAiB,IAAI,MAAM,EAAE,CAIhC;IAED;;OAEG;IACH,IAAI,iBAAiB,IAAI,MAAM,GAAG,SAAS,CAI1C;IAED;;OAEG;IACH,IAAI,MAAM,IAAI,KAAK,EAAE,CAEpB;IAED;;OAEG;IACH,IAAI,YAAY,IAAI,KAAK,EAAE,CAW1B;IAED;;OAEG;IACH,SAAS,IAAI,OAAO;IAIpB;;OAEG;IACH,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAI7C;;OAEG;IACH,YAAY,CAAC,EAAE,EAAE,MAAM,GAAG,KAAK,GAAG,SAAS;CAG5C"} \ No newline at end of file diff --git a/types/src/scripts/store/store.test.d.ts b/types/src/scripts/store/store.test.d.ts new file mode 100644 index 0000000..6ffd6f9 --- /dev/null +++ b/types/src/scripts/store/store.test.d.ts @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=store.test.d.ts.map \ No newline at end of file diff --git a/types/src/scripts/store/store.test.d.ts.map b/types/src/scripts/store/store.test.d.ts.map new file mode 100644 index 0000000..fa49f4c --- /dev/null +++ b/types/src/scripts/store/store.test.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"store.test.d.ts","sourceRoot":"","sources":["../../../../../src/scripts/store/store.test.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/types/src/scripts/templates.d.ts b/types/src/scripts/templates.d.ts new file mode 100644 index 0000000..b1b3f02 --- /dev/null +++ b/types/src/scripts/templates.d.ts @@ -0,0 +1,25 @@ +/** + * Helpers to create HTML elements used by Choices + * Can be overridden by providing `callbackOnCreateTemplates` option + */ +import { Choice } from './interfaces/choice'; +import { Group } from './interfaces/group'; +import { Item } from './interfaces/item'; +import { PassedElementType } from './interfaces/passed-element-type'; +declare type TemplateOptions = Record<'classNames' | 'allowHTML', any>; +declare const templates: { + containerOuter({ classNames: { containerOuter } }: TemplateOptions, dir: HTMLElement['dir'], isSelectElement: boolean, isSelectOneElement: boolean, searchEnabled: boolean, passedElementType: PassedElementType): HTMLDivElement; + containerInner({ classNames: { containerInner }, }: TemplateOptions): HTMLDivElement; + itemList({ classNames: { list, listSingle, listItems } }: TemplateOptions, isSelectOneElement: boolean): HTMLDivElement; + placeholder({ allowHTML, classNames: { placeholder } }: TemplateOptions, value: string): HTMLDivElement; + item({ allowHTML, classNames: { item, button, highlightedState, itemSelectable, placeholder, }, }: TemplateOptions, { id, value, label, customProperties, active, disabled, highlighted, placeholder: isPlaceholder, }: Item, removeItemButton: boolean): HTMLDivElement; + choiceList({ classNames: { list } }: TemplateOptions, isSelectOneElement: boolean): HTMLDivElement; + choiceGroup({ allowHTML, classNames: { group, groupHeading, itemDisabled }, }: TemplateOptions, { id, value, disabled }: Group): HTMLDivElement; + choice({ allowHTML, classNames: { item, itemChoice, itemSelectable, selectedState, itemDisabled, placeholder, }, }: TemplateOptions, { id, value, label, groupId, elementId, disabled: isDisabled, selected: isSelected, placeholder: isPlaceholder, }: Choice, selectText: string): HTMLDivElement; + input({ classNames: { input, inputCloned } }: TemplateOptions, placeholderValue: string): HTMLInputElement; + dropdown({ classNames: { list, listDropdown }, }: TemplateOptions): HTMLDivElement; + notice({ allowHTML, classNames: { item, itemChoice, noResults, noChoices }, }: TemplateOptions, innerText: string, type?: 'no-choices' | 'no-results' | ''): HTMLDivElement; + option({ label, value, customProperties, active, disabled, }: Item): HTMLOptionElement; +}; +export default templates; +//# sourceMappingURL=templates.d.ts.map \ No newline at end of file diff --git a/types/src/scripts/templates.d.ts.map b/types/src/scripts/templates.d.ts.map new file mode 100644 index 0000000..8252dcf --- /dev/null +++ b/types/src/scripts/templates.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../../../../src/scripts/templates.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAGrE,aAAK,eAAe,GAAG,MAAM,CAAC,YAAY,GAAG,WAAW,EAAE,GAAG,CAAC,CAAC;AAE/D,QAAA,MAAM,SAAS;uDAEyB,eAAe,OAC9C,WAAW,CAAC,KAAK,CAAC,mBACN,OAAO,sBACJ,OAAO,iBACZ,OAAO,qBACH,iBAAiB,GACnC,cAAc;wDA8Bd,eAAe,GAAG,cAAc;8DAOgB,eAAe,sBAC5C,OAAO,GAC1B,cAAc;4DAO6B,eAAe,SACpD,MAAM,GACZ,cAAc;uGAiBZ,eAAe,sGAUf,IAAI,oBACW,OAAO,GACxB,cAAc;yCAmDW,eAAe,sBACrB,OAAO,GAC1B,cAAc;mFAiBZ,eAAe,2BACO,KAAK,GAC7B,cAAc;wHAsCZ,eAAe,qHAUf,MAAM,cACG,MAAM,GACjB,cAAc;kDAqCyB,eAAe,oBACrC,MAAM,GACvB,gBAAgB;sDAmBhB,eAAe,GAAG,cAAc;mFAa9B,eAAe,aACP,MAAM,SACX,YAAY,GAAG,YAAY,GAAG,EAAE,GACrC,cAAc;kEAqBd,IAAI,GAAG,iBAAiB;CAW5B,CAAC;AAEF,eAAe,SAAS,CAAC"} \ No newline at end of file diff --git a/types/src/scripts/templates.test.d.ts b/types/src/scripts/templates.test.d.ts new file mode 100644 index 0000000..ba2e643 --- /dev/null +++ b/types/src/scripts/templates.test.d.ts @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=templates.test.d.ts.map \ No newline at end of file diff --git a/types/src/scripts/templates.test.d.ts.map b/types/src/scripts/templates.test.d.ts.map new file mode 100644 index 0000000..d7d77ed --- /dev/null +++ b/types/src/scripts/templates.test.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"templates.test.d.ts","sourceRoot":"","sources":["../../../../src/scripts/templates.test.ts"],"names":[],"mappings":""} \ No newline at end of file