- md5
- d8020557615bce02486b541c4466c929
- sha1
- e2c858aefd1a73a1a2e568292048afe152998cc7
- sha256
- 5d436616378cc7cd738344a07cf574d95e0e90e1d548057ae639b43df44c30ba
"use strict";function _typeof(a){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function _possibleConstructorReturn(a,b){return b&&("object"===_typeof(b)||"function"==typeof b)?b:_assertThisInitialized(a)}function _assertThisInitialized(a){if(void 0===a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return a}function _defineProperties(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,c.key,c)}function _createClass(a,b,c){return b&&_defineProperties(a.prototype,b),c&&_defineProperties(a,c),a}function _inherits(a,b){if("function"!=typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function");a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,writable:!0,configurable:!0}}),b&&_setPrototypeOf(a,b)}function _wrapNativeSuper(a){var b="function"==typeof Map?new Map:void 0;return _wrapNativeSuper=function(a){function c(){return _construct(a,arguments,_getPrototypeOf(this).constructor)}if(null===a||!_isNativeFunction(a))return a;if("function"!=typeof a)throw new TypeError("Super expression must either be null or a function");if("undefined"!=typeof b){if(b.has(a))return b.get(a);b.set(a,c)}return c.prototype=Object.create(a.prototype,{constructor:{value:c,enumerable:!1,writable:!0,configurable:!0}}),_setPrototypeOf(c,a)},_wrapNativeSuper(a)}function isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(a){return!1}}function _construct(){return _construct=isNativeReflectConstruct()?Reflect.construct:function(b,c,d){var e=[null];e.push.apply(e,c);var a=Function.bind.apply(b,e),f=new a;return d&&_setPrototypeOf(f,d.prototype),f},_construct.apply(null,arguments)}function _isNativeFunction(a){return-1!==Function.toString.call(a).indexOf("[native code]")}function _setPrototypeOf(a,b){return _setPrototypeOf=Object.setPrototypeOf||function(a,b){return a.__proto__=b,a},_setPrototypeOf(a,b)}function _getPrototypeOf(a){return _getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function(a){return a.__proto__||Object.getPrototypeOf(a)},_getPrototypeOf(a)}window.customElements.define("joomla-field-fancy-select",function(a){function b(){var a;if(_classCallCheck(this,b),a=_possibleConstructorReturn(this,_getPrototypeOf(b).call(this)),a.keyCode={ENTER:13},!Joomla)throw new Error("Joomla API is not properly initiated");if(!window.Choices)throw new Error("JoomlaFieldFancySelect requires Choices.js to work");return a.choicesCache={},a.activeXHR=null,a.choicesInstance=null,a}return _inherits(b,a),_createClass(b,[{key:"allowCustom",get:function a(){return this.hasAttribute("allow-custom")}},{key:"remoteSearch",get:function a(){return this.hasAttribute("remote-search")}},{key:"url",get:function a(){return this.getAttribute("url")}},{key:"termKey",get:function a(){return this.getAttribute("term-key")||"term"}},{key:"minTermLength",get:function a(){return parseInt(this.getAttribute("min-term-length"))||1}},{key:"newItemPrefix",get:function a(){return this.getAttribute("new-item-prefix")||""}},{key:"placeholder",get:function a(){return this.getAttribute("placeholder")}},{key:"searchPlaceholder",get:function a(){return this.getAttribute("search-placeholder")}},{key:"value",get:function a(){return this.choicesInstance.getValue(!0)},set:function b(a){this.choicesInstance.setValueByChoice(a)}}]),_createClass(b,[{key:"connectedCallback",value:function c(){var a=this;if(this.select=this.querySelector("select"),!this.select)throw new Error("JoomlaFieldFancySelect requires <select> element to work");if(this.choicesInstance=new Choices(this.select,{placeholderValue:this.placeholder,searchPlaceholderValue:this.searchPlaceholder,removeItemButton:!0,searchFloor:this.minTermLength,searchResultLimit:10,shouldSort:!1,fuseOptions:{threshold:.3},noResultsText:Joomla.Text._("JGLOBAL_SELECT_NO_RESULTS_MATCH","No results found"),noChoicesText:Joomla.Text._("JGLOBAL_SELECT_NO_RESULTS_MATCH","No results found"),itemSelectText:Joomla.Text._("JGLOBAL_SELECT_PRESS_TO_SELECT","Press to select"),classNames:{button:"choices__button_joomla"}}),this.allowCustom&&this.addEventListener("keydown",function(b){if(b.keyCode===a.keyCode.ENTER&&b.target===a.choicesInstance.input&&(b.preventDefault(),!(a.choicesInstance.highlightPosition||!b.target.value||a.choicesCache[b.target.value]))){var c=a.choicesInstance.dropdown.querySelector(".".concat(a.choicesInstance.config.classNames.highlightedState));if(!c)return a.choicesInstance.setChoices([{value:a.newItemPrefix+b.target.value,label:b.target.value,selected:!0,customProperties:{value:b.target.value}}],"value","label",!1),a.choicesCache[b.target.value]=b.target.value,b.target.value=null,a.choicesInstance.hideDropdown(),!1}}),this.remoteSearch&&this.url){this.choicesInstance.presetChoices.forEach(function(b){a.choicesCache[b.value]=b.label});var b=null;this.select.addEventListener("search",function(){clearTimeout(b),b=setTimeout(a.requestLookup.bind(a),300)})}}},{key:"disconnectedCallback",value:function a(){this.choicesInstance&&(this.choicesInstance.destroy(),this.choicesInstance=null),this.activeXHR&&(this.activeXHR.abort(),this.activeXHR=null)}},{key:"requestLookup",value:function c(){var a=this,b=this.url;b+=-1===b.indexOf("?")?"?":"&",b+="".concat(encodeURIComponent(this.termKey),"=").concat(encodeURIComponent(this.choicesInstance.input.value)),this.activeXHR&&this.activeXHR.abort(),this.activeXHR=Joomla.request({url:b,onSuccess:function d(b){a.activeXHR=null;var c=b?JSON.parse(b):[];c.length&&(c.forEach(function(b,d){a.choicesCache[b.value]&&c.splice(d,1)}),c.length&&a.choicesInstance.setChoices(c,"value","text",!1))},onError:function b(){a.activeXHR=null}})}}]),b}(_wrapNativeSuper(HTMLElement)));
No other release has this exact content. See every version of this file.