(function () { 'use strict'; 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); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); } function _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; } function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); } /** * @copyright (C) 2018 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt */ /** * Fancy select field, which use Choices.js * * Example: * * * * * Possible attributes: * * allow-custom Whether allow User to dynamically add a new value. * new-item-prefix="" Prefix for a dynamically added value. * * remote-search Enable remote search. * url="" Url for remote search. * term-key="term" Variable key name for searched term, will be appended to Url. * * min-term-length="1" The minimum length a search value should be before choices are searched. * placeholder="" The value of the inputs placeholder. * search-placeholder="" The value of the search inputs placeholder. * * data-max-results="30" The maximum amount of search results to be displayed. * data-max-render="30" The maximum amount of items to be rendered, critical for large lists. */ window.customElements.define('joomla-field-fancy-select', /*#__PURE__*/function (_HTMLElement) { _inheritsLoose(_class, _HTMLElement); /** * Lifecycle */ function _class() { var _this; _this = _HTMLElement.call(this) || this; // Keycodes _this.keyCode = { ENTER: 13 }; if (!Joomla) { throw new Error('Joomla API is not properly initiated'); } if (!window.Choices) { throw new Error('JoomlaFieldFancySelect requires Choices.js to work'); } _this.choicesCache = {}; _this.activeXHR = null; _this.choicesInstance = null; _this.isDisconnected = false; return _this; } /** * Lifecycle */ var _proto = _class.prototype; _proto.connectedCallback = function connectedCallback() { var _this2 = this; // Make sure Choices are loaded if (window.Choices || document.readyState === 'complete') { this.doConnect(); } else { var callback = function callback() { _this2.doConnect(); window.removeEventListener('load', callback); }; window.addEventListener('load', callback); } }; _proto.doConnect = function doConnect() { var _this3 = this; // Get a element to work'); } // The element was already initialised previously and perhaps was detached from DOM if (this.choicesInstance) { if (this.isDisconnected) { // Re init previous instance this.choicesInstance.init(); this.isDisconnected = false; } return; } this.isDisconnected = false; // Add placeholder option for multiple mode, // Because it not supported as parameter by Choices for