Socket
Socket
Sign inDemoInstall

@dotburo/select-input

Package Overview
Dependencies
0
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.2.4 to 1.3.0

622

dist/select-input-min.js

@@ -1,2 +0,620 @@

const t=document;class e{constructor(t,e={},s={}){this.options=Object.assign({},s,e),this._events=[],this.dom={el:this._setElement(t)}}on(t,e,s=null){return(s||this.dom.el).addEventListener(t,e=e.bind(this),!0),this._events.push({name:t,fn:e,el:s}),this}getElement(){return this.dom.el}remove(){this._events=this._events.filter(t=>(t.el||this.dom.el).removeEventListener(t.name,t.fn,!0)),this.dom.el.parentNode.removeChild(this.dom.el),this.dom=this.options=null}_setElement(e){if(!e&&!e.nodeType&&"string"!=typeof e)throw new Error("Wrong element type provided!");return e.nodeType?e:(this.options.parent||t).querySelector(e)}_trigger(e,s=null){let i;"function"==typeof CustomEvent?i=new CustomEvent(e,{detail:s,bubbles:!0,cancelable:!0}):(i=t.createEvent("Event")).initEvent(e,!0,!0),this.dom.el.dispatchEvent(i)}}var s={parent:null,items:[],current:null,allowAdd:!0,proposal:"Add {X} to the list?",notFound:"{X} not present in the list",allowRemove:!0,removalIcon:"&times;",placeHolder:"Type to search",sort:!0,order:"desc",maxHeight:0,onDelete:null,onCreate:null,valueKey:"value",textKey:"value"};const i=document;export default class extends e{constructor(t,e={}){super(t,e,s);let i=e.current?this._convertItem(e.current):null;this.options.items=this._convertItems(e.items),this.current=this.findItem(i[e.valueKey]),this.__found=null,this.options.sort&&this._sortItems(),this._renderInit(),this._bindEvents(),this.current&&(this.dom.input.value=this.current[e.textKey])}_bindEvents(){let t=t=>{"Escape"!==t.key&&27!==t.keyCode&&this.dom.el.contains(t.target)||this.toggle(!1)};this.on("input",this._search),this.on("click",this._handleClick),this.on("keyup",this._handleKey),this.on("focusin",()=>this._renderListItems().toggle(!0),this.dom.input),this.on("keyup",t,i),this.on("click",t,i)}onDelete(t){return this.options.onDelete=t,this}onCreate(t){return this.options.onCreate=t,this}toggle(t=!1){return this.dom.el.firstElementChild.classList[t?"remove":"add"]("si-hide"),t||this.dom.input.blur(),this}getItems(){return this.options.items}getCurrent(t=null){let e=Object.assign({},this.current);return delete e._lc_value,delete e._lc_text,t?e[t]:e}clearCurrent(){this.current=null,this.dom.input.value="",this._clearSelected()}findItem(t){let e=this.options;return t=t.nodeName?t.dataset.value:t,e.items.find(s=>s[e.valueKey]===t)}setCurrent(t){return this._setCurrent(t?this.findItem(t):null),this}_setCurrent(t,e=null){return this.dom.input.value=t?t[this.options.textKey].toString():"",t?(this.current=t,this._setSelected(t,e)):(this.current=null,this._clearSelected()),this}_setSelected(t,e=null){this._clearSelected(),(e=e||this.dom.list.querySelector(`li[data-value="${t[this.options.valueKey]}"]`))&&e.classList.add("si-current")}_clearSelected(){let t=this.dom.list.querySelector(".si-current");t&&t.classList.remove("si-current")}_convertItems(t=[]){return t.map(t=>this._convertItem(t))}_convertItem(t){let e=this.options;return(t="object"!=typeof t?{[e.valueKey]:t,[e.textKey]:t}:t)._lc_value=t[e.valueKey].toString().toLowerCase().replace(/\s+/g,"-"),t._lc_text=t[e.textKey].toString().toLowerCase().replace(/\s+/g,"-"),t}_renderInit(){let t=i.createElement("div");return t.className="si-wrap si-hide",this.dom.input=t.appendChild(this._renderInput()).firstChild,this.dom.list=t.appendChild(this._renderList()).firstChild,this.dom.el.appendChild(t)}_renderInput(){let t=i.createElement("div"),e=i.createElement("input");return t.className="si-input",e.type="text",e.autocomplete="false",e.spellcheck=!1,e.placeholder=this.options.placeHolder,t.appendChild(e),t}_renderList(){let t=i.createElement("div"),e=i.createElement("ul"),s=this.options.maxHeight;return t.className="si-list",s&&(t.style.maxHeight=s+"px"),t.appendChild(e),t}_createListItems(t=[]){let e="",s=this.options,i=this.getCurrent(s.valueKey),n="",r=s.allowRemove?this._createRemovalButton():"",l="",o="";return t.forEach(t=>{l=t[s.valueKey],o=t[s.textKey],e+=`<li class="si-item${n=i&&l===i?" si-current":""}" data-value="${l}">${o}${r}</li>`}),e}_renderListItems(t=""){return this.dom.list.innerHTML=t||this._createListItems(this.options.items),this}_createRemovalButton(){return`<button type="button" class="si-removal">${this.options.removalIcon}</button>`}_search(t){let e=this.options,s=t.target.value,i=s.toLowerCase().replace(/\s+/g,"-"),n=e.items.filter(t=>-1!==t._lc_value.indexOf(i)||-1!==t._lc_text.indexOf(i)),r=n||e.allowAdd?this._createListItems(n):"",l=n[0],o=n.length;1===o&&(this.__found=l),(o>1||!o||!s)&&(this.__found=null),e.allowAdd&&s&&(!l||i!==l._lc_text&&i!==l._lc_value)?r+=this._proposeItem(s):e.allowAdd||(r+=this._notFoundItem(s)),this._renderListItems(r)}_proposeItem(t){return`<li class="si-item si-append si-proposal" data-term="${t}">${this.options.proposal.replace("{X}",`<span>${t}</span>`)}</li>`}_notFoundItem(t){return`<li class="si-item si-append si-not-found">${this.options.notFound.replace("{X}",`<span>${t}</span>`)}</li>`}_handleClick(t){let e=t.target,s=e.classList;this.options.allowAdd&&s.contains("si-proposal")?this._tryCreateItem(e.dataset.term)&&this.toggle()._trigger("created",this.current):s.contains("si-item")?this._setCurrent(this.findItem(e),e).toggle()._trigger("selected",this.current):this.options.allowRemove&&s.contains("si-removal")&&(e=e.parentNode,this._fireCallback("onDelete",this.findItem(e))&&this._trigger("removed",this._sliceItem(e)))}_fireCallback(t,e){return"function"!=typeof this.options[t]||this.options[t](e)}_handleKey(t){let e,s=t.target.value,i=this.__found;(!s||13===t.keyCode&&"Enter"===t.key)&&(!i&&s&&this.options.allowAdd?e=this._tryCreateItem(s)?"created":null:i&&(e="selected",this._setCurrent(i)),e&&this.toggle()._trigger(e,this.current))}_tryCreateItem(t){let e=this._convertItem(t.trim());return!(this.findItem(t)||!this._fireCallback("onCreate",e)||(this._setCurrent(this._insertItem(e)),0))}_insertItem(t){return this.options.items.push(t),this.options.sort&&this._sortItems(),t}_sortItems(){let t="desc"===this.options.order?1:-1;this.options.items.sort((e,s)=>e._lc_text<s._lc_text?-t:e._lc_text>s._lc_text?t:0)}_sliceItem(t){let e,s=this.options.items,i=t.dataset.value.toLowerCase(),n=this.current;return this.dom.list.removeChild(t),e=s.splice(s.findIndex(t=>t._lc_value===i),1).shift(),n&&e._lc_value===n._lc_value&&this.clearCurrent(),e}}
//# sourceMappingURL=select-input-min.js.map
/*! @dotburo/select-input 1.2.4 | dotburo <code@dotburo.org> (https://dotburo.org) !*/
const d = document;
class DomComponent {
constructor(element, options = {}, defaults = {}) {
this.options = Object.assign({}, defaults, options);
this._events = [];
this.dom = {
el: this._setElement(element)
};
}
/**
* Bind a (delegated) event
* @param {String} event
* @param {Function} fn
* @param {HTMLElement|Document} el
* @return DomComponent
*/
on(event, fn, el = null) {
(el || this.dom.el).addEventListener(event, fn = fn.bind(this), true);
this._events.push({
name: event,
fn: fn,
el: el
});
return this;
}
/**
* Return the main wrapping element
* @return {Element}
*/
getElement() {
return this.dom.el;
}
/**
* Unbind all events and nullify references
* @return void
*/
remove() {
this._events = this._events.filter(event => {
return (event.el || this.dom.el).removeEventListener(event.name, event.fn, true);
});
this.dom.el.parentNode.removeChild(this.dom.el);
this.dom = this.options = null;
}
/**
* Query the element in the DOM if its a string
* @param {Element|String} el
* @return {Element|null}
* @protected
*/
_setElement(el) {
if (!el && !el.nodeType && typeof el !== 'string') {
throw new Error('Wrong element type provided!');
}
if (el.nodeType) return el;
return (this.options.parent || d).querySelector(el);
}
/**
* Communicate changes
* @param {String} name
* @param {Object|null} detail
* @protected
*/
_trigger(name, detail = null) {
let event;
if (typeof CustomEvent === 'function') {
event = new CustomEvent(name, {
detail: detail,
bubbles: true,
cancelable: true
});
} else {
event = d.createEvent('Event');
event.initEvent(name, true, true);
}
this.dom.el.dispatchEvent(event);
}
}
var defaults = {
parent: null,
items: [],
current: null,
allowAdd: true,
proposal: 'Add {X} to the list?',
notFound: '{X} not present in the list',
allowRemove: true,
removalIcon: '&times;',
placeHolder: 'Type to search',
sort: true,
order: 'desc',
maxHeight: 0,
onDelete: null,
onCreate: null,
valueKey: 'value',
textKey: 'value'
};
const d$1 = document;
class SelectInput extends DomComponent {
constructor(element, options = {}) {
super(element, options, defaults);
let current = options.current ? this._convertItem(options.current) : null;
this.options.items = this._convertItems(options.items);
this.current = current ? this.findItem(this._getItemProp(current)) : null;
// search result caching
this.__found = null;
if (this.options.sort) this._sortItems();
this._renderInit();
this._bindEvents();
if (current) {
this._setInputValue(current);
}
}
/**
* Bind all (delegated) DOM events
* @private
*/
_bindEvents() {
let closeOnEvent = e => {
if ((e.key === 'Escape' || e.keyCode === 27) || !this.dom.el.contains(e.target)) {
this.toggle(false);
}
};
this.on('input', this._search);
this.on('click', this._handleClick);
this.on('keyup', this._handleKey);
this.on('focusin', () => (this._renderListItems().toggle(true)), this.dom.input);
// Close the list on `Escape` or on a click outside the main element
this.on('keyup', closeOnEvent, d$1);
this.on('click', closeOnEvent, d$1);
}
/**
* Store the deletion callback
* @param {Function} fn
* @return SelectInput
*/
onDelete(fn) {
this.options.onDelete = fn;
return this;
}
/**
* Store the creation callback
* @param {Function} fn
* @return SelectInput
*/
onCreate(fn) {
this.options.onCreate = fn;
return this;
}
/**
* Show/hide the dropdown
* @param {Boolean} show
* @return DomHelper
*/
toggle(show = false) {
this.dom.el.firstElementChild.classList[show ? 'remove' : 'add']('si-hide');
if (!show) this.dom.input.blur();
return this;
}
/**
* Get all items in the list
* @return {Object[]}
*/
getItems() {
return this.options.items;
}
/**
* Return the current field value object
* @return {{value: String|Number}|null}
*/
getCurrent() {
let current = Object.assign({}, this.current);
delete current._lc_value;
delete current._lc_text;
return current;
}
/**
* Clear the current value
* @return void
* @private
*/
clearCurrent() {
this.current = null;
this.dom.input.value = '';
this._clearSelected();
}
/**
* Find an item in the list
* @param {EventTarget|HTMLElement|String|Number} value
* @return {{}}
*/
findItem(value) {
value = value.nodeName ? value.dataset.value : value;
return this.options.items.find(item => this._getItemProp(item) === value);
}
/**
* Set the current value by its string
* @param {String|undefined} value
* @return SelectInput
*/
setCurrent(value) {
this._setCurrent(value ? this.findItem(value) : null);
return this;
}
/**
* Set the current value of the field
* @param {EventTarget|null} el
* @param {Object|null} item
* @return SelectInput
* @private
*/
_setCurrent(item, el = null) {
this._setInputValue(item);
if (item) {
this.current = item;
this._setSelected(item, el);
} else {
this.current = null;
this._clearSelected();
}
return this;
}
/**
* Set the HTML input field
* @param {Object} item
* @return void
* @private
*/
_setInputValue(item) {
this.dom.input.value = item ? this._getItemProp(item, 'text').toString() : '';
}
/**
* Updated selected item in the html list
* @param {Object} item
* @param {EventTarget|HTMLElement|null} el
* @private
*/
_setSelected(item, el = null) {
this._clearSelected();
el = el ? el : this.dom.list.querySelector(`li[data-value="${this._getItemProp(item)}"]`);
if (el) el.classList.add('si-current');
}
/**
* Remove the classname of current `<li>`
* @private
*/
_clearSelected() {
let current = this.dom.list.querySelector('.si-current');
if (current) current.classList.remove('si-current');
}
/**
* Make an array of objects
* @param {Array} items
* @return {Object[]}
* @private
*/
_convertItems(items = []) {
return items.map(item => this._convertItem(item))
}
/**
* Normalize an item as an usable object
* @param {String|Number|{value: String|Number, _lc_value: String, _lc_text: String}} item
* @return {{value: String|Number, _lc_value: String, _lc_text: String}}
* @private
*/
_convertItem(item) {
let opt = this.options;
item = typeof item !== 'object' ? {[opt.valueKey]: item, [opt.textKey]: item} : item;
item._lc_value = this._makeSearchString(this._getItemProp(item));
item._lc_text = this._makeSearchString(this._getItemProp(item, 'text'));
return item;
}
/**
* Format all searchable strings
* @param {String} value
* @return {String}
* @private
*/
_makeSearchString(value) {
return value.toString().toLowerCase().replace(/\s+/g, '-');
}
/**
* Return the value of one of the custom named properties
* @param {Object} item
* @param {String} prop
* @return {String|Number}
* @private
*/
_getItemProp(item, prop = 'value') {
return item ? item[this.options[`${prop}Key`]] : null;
}
/**
* Create the HTML upon instantiation
* @return {Node}
* @private
*/
_renderInit() {
let wrap = d$1.createElement('div');
wrap.className = 'si-wrap si-hide';
this.dom.input = wrap.appendChild(this._renderInput()).firstChild;
this.dom.list = wrap.appendChild(this._renderList()).firstChild;
return this.dom.el.appendChild(wrap);
}
/**
* Create the input element
* @return {HTMLDivElement}
* @private
*/
_renderInput() {
let wrap = d$1.createElement('div'),
el = d$1.createElement('input');
wrap.className = 'si-input';
el.type = 'text';
el.autocomplete = 'false';
el.spellcheck = false;
el.placeholder = this.options.placeHolder;
wrap.appendChild(el);
return wrap;
}
/**
* Create the list element
* @return {HTMLDivElement}
* @private
*/
_renderList() {
let wrap = d$1.createElement('div'),
el = d$1.createElement('ul'),
maxHeight = this.options.maxHeight;
wrap.className = 'si-list';
if (maxHeight) wrap.style.maxHeight = maxHeight + 'px';
wrap.appendChild(el);
return wrap;
}
/**
* Create the list items
* @param {Object[]} items
* @return {String}
* @private
*/
_createListItems(items = []) {
let list = '',
opt = this.options,
currentValue = this._getItemProp(this.current),
selected = '',
button = opt.allowRemove ? this._createRemovalButton() : '',
value = '',
text = '';
items.forEach(item => {
value = this._getItemProp(item);
text = this._getItemProp(item, 'text');
selected = currentValue && value === currentValue ? ' si-current' : '';
list += `<li class="si-item${selected}" data-value="${value}">${text + button}</li>`;
});
return list;
}
/**
* Insert the set of li's in the DOM
* @param html
* @return SelectInput
* @private
*/
_renderListItems(html = '') {
this.dom.list.innerHTML = html || this._createListItems(this.options.items);
return this;
}
/**
* Item removal button template
* @return {String}
* @private
*/
_createRemovalButton() {
return `<button type="button" class="si-removal">${this.options.removalIcon}</button>`;
}
/**
* Search and update the list upon typing
* @param {KeyboardEvent} e
* @private
*/
_search(e) {
let options = this.options,
term = e.target.value,
termLc = this._makeSearchString(term),
list = this._searchItem(termLc),
html = list || options.allowAdd ? this._createListItems(list) : '',
first = list[0],
len = list.length;
if (len === 1) {
this.__found = first;
}
if (len !== 1 || !term) {
this.__found = null;
}
if (options.allowAdd && term && (!first || termLc !== first._lc_text && termLc !== first._lc_value)) {
html += this._proposeItem(term);
} else if (!options.allowAdd) {
html += this._notFoundItem(term);
}
this._renderListItems(html);
}
/**
* Filter the list of available items
* @param {String} str
* @return {[]}
* @private
*/
_searchItem(str) {
return this.options.items.filter(item => {
return item._lc_value.indexOf(str) !== -1 || item._lc_text.indexOf(str) !== -1;
})
}
/**
* Create the item creation list item
* @param {String} term
* @return {String}
* @private
*/
_proposeItem(term) {
let proposal = this.options.proposal.replace('{X}', `<span>${term}</span>`);
return `<li class="si-item si-append si-proposal" data-term="${term}">${proposal}</li>`
}
/**
* Create a 'not found' message as a list item
* @param {String} term
* @return {String}
* @private
*/
_notFoundItem(term) {
let txt = this.options.notFound.replace('{X}', `<span>${term}</span>`);
return `<li class="si-item si-append si-not-found">${txt}</li>`
}
/**
* Decide what to do when user clicks inside the component
* @param {MouseEvent} e
* @private
*/
_handleClick(e) {
let el = e.target,
classList = el.classList;
if (this.options.allowAdd && classList.contains('si-proposal')) {
if (this._tryCreateItem(el.dataset.term)) {
this.toggle()._trigger('created', this.current);
}
return;
}
if (classList.contains('si-item')) {
this._setCurrent(this.findItem(el), el)
.toggle()
._trigger('selected', this.current);
return;
}
if (this.options.allowRemove && classList.contains('si-removal')) {
el = el.parentNode;
if (this._fireCallback('onDelete', this.findItem(el))) {
this._trigger('removed', this._sliceItem(el));
}
}
}
/**
* The `onCreate` and `onDelete` callbacks allow to prevent their respective actions
* @param {String} name
* @param {Object} item
* @return {Boolean}
* @private
*/
_fireCallback(name, item) {
if (typeof this.options[name] === 'function') {
return this.options[name](item);
}
return true;
}
/**
* Handle `Enter` when there is a value in the field
* @param {KeyboardEvent} e
* @private
*/
_handleKey(e) {
let value = e.target.value,
item = this.__found,
event;
if (!!value && (e.keyCode !== 13 || e.key !== 'Enter')) {
return;
}
if (!item && value && this.options.allowAdd) {
event = this._tryCreateItem(value) ? 'created' : null;
} else if (item) {
event = 'selected';
this._setCurrent(item);
}
if (event) this.toggle()._trigger(event, this.current);
}
/**
* If the value doesn't exist and the callback returns true, create and set as current
* @param value
* @return {boolean}
* @private
*/
_tryCreateItem(value) {
let item = this._convertItem(value.trim());
if (!this.findItem(value) && this._fireCallback('onCreate', item)) {
this._setCurrent(this._insertItem(item));
return true;
}
return false;
}
/**
* Insert a new item in the list
* @param {{value: String|Number, _lc_value: String, _lc_text: String}} item
* @return {{value: String|Number, _lc_value: String, _lc_text: String}}
* @private
*/
_insertItem(item) {
this.options.items.push(item);
if (this.options.sort) this._sortItems();
return item;
}
/**
* Rearrange the list
* @private
*/
_sortItems() {
let order = this.options.order === 'desc' ? 1 : -1;
this.options.items.sort((a, b) => {
if (a._lc_text < b._lc_text) return -order;
if (a._lc_text > b._lc_text) return order;
return 0;
});
}
/**
* Remove an item from the list
* @param {HTMLElement|Node} el
* @return {{value: String|Number, _lc_value: String, _lc_text: String}}
* @private
*/
_sliceItem(el) {
let items = this.options.items,
needle = el.dataset.value.toLowerCase(),
current = this.current,
item;
this.dom.list.removeChild(el);
item = items.splice(items.findIndex(item => item._lc_value === needle), 1).shift();
if (current && item._lc_value === current._lc_value) this.clearCurrent();
return item;
}
}
export default SelectInput;

@@ -1,2 +0,2093 @@

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).SelectInput=e()}(this,function(){"use strict";function t(t,e){return t(e={exports:{}},e.exports),e.exports}var e=t(function(t){var e=t.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=e)}),n=t(function(t){var e=t.exports={version:"2.6.3"};"number"==typeof __e&&(__e=e)}),r=(n.version,function(t){return"object"==typeof t?null!==t:"function"==typeof t}),i=function(t){if(!r(t))throw TypeError(t+" is not an object!");return t},o=function(t){try{return!!t()}catch(t){return!0}},u=!o(function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a}),c=e.document,a=r(c)&&r(c.createElement),s=function(t){return a?c.createElement(t):{}},l=!u&&!o(function(){return 7!=Object.defineProperty(s("div"),"a",{get:function(){return 7}}).a}),f=Object.defineProperty,p={f:u?Object.defineProperty:function(t,e,n){if(i(t),e=function(t,e){if(!r(t))return t;var n,i;if(e&&"function"==typeof(n=t.toString)&&!r(i=n.call(t)))return i;if("function"==typeof(n=t.valueOf)&&!r(i=n.call(t)))return i;if(!e&&"function"==typeof(n=t.toString)&&!r(i=n.call(t)))return i;throw TypeError("Can't convert object to primitive value")}(e,!0),i(n),l)try{return f(t,e,n)}catch(t){}if("get"in n||"set"in n)throw TypeError("Accessors not supported!");return"value"in n&&(t[e]=n.value),t}},h=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}},v=u?function(t,e,n){return p.f(t,e,h(1,n))}:function(t,e,n){return t[e]=n,t},d={}.hasOwnProperty,y=function(t,e){return d.call(t,e)},m=0,g=Math.random(),_=function(t){return"Symbol(".concat(void 0===t?"":t,")_",(++m+g).toString(36))},b=t(function(t){var r=_("src"),i=Function.toString,o=(""+i).split("toString");n.inspectSource=function(t){return i.call(t)},(t.exports=function(t,n,i,u){var c="function"==typeof i;c&&(y(i,"name")||v(i,"name",n)),t[n]!==i&&(c&&(y(i,r)||v(i,r,t[n]?""+t[n]:o.join(String(n)))),t===e?t[n]=i:u?t[n]?t[n]=i:v(t,n,i):(delete t[n],v(t,n,i)))})(Function.prototype,"toString",function(){return"function"==typeof this&&this[r]||i.call(this)})}),x=function(t,e,n){if(function(t){if("function"!=typeof t)throw TypeError(t+" is not a function!")}(t),void 0===e)return t;switch(n){case 1:return function(n){return t.call(e,n)};case 2:return function(n,r){return t.call(e,n,r)};case 3:return function(n,r,i){return t.call(e,n,r,i)}}return function(){return t.apply(e,arguments)}},S=function(t,r,i){var o,u,c,a,s=t&S.F,l=t&S.G,f=t&S.S,p=t&S.P,h=t&S.B,d=l?e:f?e[r]||(e[r]={}):(e[r]||{}).prototype,y=l?n:n[r]||(n[r]={}),m=y.prototype||(y.prototype={});for(o in l&&(i=r),i)c=((u=!s&&d&&void 0!==d[o])?d:i)[o],a=h&&u?x(c,e):p&&"function"==typeof c?x(Function.call,c):c,d&&b(d,o,c,t&S.U),y[o]!=c&&v(y,o,a),p&&m[o]!=c&&(m[o]=c)};e.core=n,S.F=1,S.G=2,S.S=4,S.P=8,S.B=16,S.W=32,S.U=64,S.R=128;var k=S,I={}.toString,w=function(t){return I.call(t).slice(8,-1)},E=Object("z").propertyIsEnumerable(0)?Object:function(t){return"String"==w(t)?t.split(""):Object(t)},C=function(t){if(null==t)throw TypeError("Can't call method on "+t);return t},O=function(t){return Object(C(t))},L=Math.ceil,j=Math.floor,A=function(t){return isNaN(t=+t)?0:(t>0?j:L)(t)},T=Math.min,P=function(t){return t>0?T(A(t),9007199254740991):0},R=Array.isArray||function(t){return"Array"==w(t)},M=t(function(t){var r=e["__core-js_shared__"]||(e["__core-js_shared__"]={});(t.exports=function(t,e){return r[t]||(r[t]=void 0!==e?e:{})})("versions",[]).push({version:n.version,mode:"global",copyright:"© 2019 Denis Pushkarev (zloirock.ru)"})}),F=t(function(t){var n=M("wks"),r=e.Symbol,i="function"==typeof r;(t.exports=function(t){return n[t]||(n[t]=i&&r[t]||(i?r:_)("Symbol."+t))}).store=n}),K=F("species"),N=function(t,e){return new(function(t){var e;return R(t)&&("function"!=typeof(e=t.constructor)||e!==Array&&!R(e.prototype)||(e=void 0),r(e)&&null===(e=e[K])&&(e=void 0)),void 0===e?Array:e}(t))(e)},D=function(t,e){var n=1==t,r=2==t,i=3==t,o=4==t,u=6==t,c=5==t||u,a=e||N;return function(e,s,l){for(var f,p,h=O(e),v=E(h),d=x(s,l,3),y=P(v.length),m=0,g=n?a(e,y):r?a(e,0):void 0;y>m;m++)if((c||m in v)&&(p=d(f=v[m],m,h),t))if(n)g[m]=p;else if(p)switch(t){case 3:return!0;case 5:return f;case 6:return m;case 2:g.push(f)}else if(o)return!1;return u?-1:i||o?o:g}},H=F("unscopables"),G=Array.prototype;null==G[H]&&v(G,H,{});var $=function(t){G[H][t]=!0},V=D(6),q="findIndex",B=!0;q in[]&&Array(1)[q](function(){B=!1}),k(k.P+k.F*B,"Array",{findIndex:function(t){return V(this,t,arguments.length>1?arguments[1]:void 0)}}),$(q);var X=p.f,U=Function.prototype,W=/^\s*function ([^ (]*)/;"name"in U||u&&X(U,"name",{configurable:!0,get:function(){try{return(""+this).match(W)[1]}catch(t){return""}}});var z,J=function(t,e){return{value:e,done:!!t}},Q={},Y=function(t){return E(C(t))},Z=Math.max,tt=Math.min,et=M("keys"),nt=function(t){return et[t]||(et[t]=_(t))},rt=(z=!1,function(t,e,n){var r,i=Y(t),o=P(i.length),u=function(t,e){return(t=A(t))<0?Z(t+e,0):tt(t,e)}(n,o);if(z&&e!=e){for(;o>u;)if((r=i[u++])!=r)return!0}else for(;o>u;u++)if((z||u in i)&&i[u]===e)return z||u||0;return!z&&-1}),it=nt("IE_PROTO"),ot="constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf".split(","),ut=Object.keys||function(t){return function(t,e){var n,r=Y(t),i=0,o=[];for(n in r)n!=it&&y(r,n)&&o.push(n);for(;e.length>i;)y(r,n=e[i++])&&(~rt(o,n)||o.push(n));return o}(t,ot)},ct=u?Object.defineProperties:function(t,e){i(t);for(var n,r=ut(e),o=r.length,u=0;o>u;)p.f(t,n=r[u++],e[n]);return t},at=e.document,st=at&&at.documentElement,lt=nt("IE_PROTO"),ft=function(){},pt=function(){var t,e=s("iframe"),n=ot.length;for(e.style.display="none",st.appendChild(e),e.src="javascript:",(t=e.contentWindow.document).open(),t.write("<script>document.F=Object<\/script>"),t.close(),pt=t.F;n--;)delete pt.prototype[ot[n]];return pt()},ht=Object.create||function(t,e){var n;return null!==t?(ft.prototype=i(t),n=new ft,ft.prototype=null,n[lt]=t):n=pt(),void 0===e?n:ct(n,e)},vt=p.f,dt=F("toStringTag"),yt=function(t,e,n){t&&!y(t=n?t:t.prototype,dt)&&vt(t,dt,{configurable:!0,value:e})},mt={};v(mt,F("iterator"),function(){return this});var gt=function(t,e,n){t.prototype=ht(mt,{next:h(1,n)}),yt(t,e+" Iterator")},_t=nt("IE_PROTO"),bt=Object.prototype,xt=Object.getPrototypeOf||function(t){return t=O(t),y(t,_t)?t[_t]:"function"==typeof t.constructor&&t instanceof t.constructor?t.constructor.prototype:t instanceof Object?bt:null},St=F("iterator"),kt=!([].keys&&"next"in[].keys()),It=function(){return this},wt=function(t,e,n,r,i,o,u){gt(n,e,r);var c,a,s,l=function(t){if(!kt&&t in d)return d[t];switch(t){case"keys":case"values":return function(){return new n(this,t)}}return function(){return new n(this,t)}},f=e+" Iterator",p="values"==i,h=!1,d=t.prototype,y=d[St]||d["@@iterator"]||i&&d[i],m=y||l(i),g=i?p?l("entries"):m:void 0,_="Array"==e&&d.entries||y;if(_&&(s=xt(_.call(new t)))!==Object.prototype&&s.next&&(yt(s,f,!0),"function"!=typeof s[St]&&v(s,St,It)),p&&y&&"values"!==y.name&&(h=!0,m=function(){return y.call(this)}),(kt||h||!d[St])&&v(d,St,m),Q[e]=m,Q[f]=It,i)if(c={values:p?m:l("values"),keys:o?m:l("keys"),entries:g},u)for(a in c)a in d||b(d,a,c[a]);else k(k.P+k.F*(kt||h),e,c);return c}(Array,"Array",function(t,e){this._t=Y(t),this._i=0,this._k=e},function(){var t=this._t,e=this._k,n=this._i++;return!t||n>=t.length?(this._t=void 0,J(1)):J(0,"keys"==e?n:"values"==e?t[n]:[n,t[n]])},"values");Q.Arguments=Q.Array,$("keys"),$("values"),$("entries");for(var Et=F("iterator"),Ct=F("toStringTag"),Ot=Q.Array,Lt={CSSRuleList:!0,CSSStyleDeclaration:!1,CSSValueList:!1,ClientRectList:!1,DOMRectList:!1,DOMStringList:!1,DOMTokenList:!0,DataTransferItemList:!1,FileList:!1,HTMLAllCollection:!1,HTMLCollection:!1,HTMLFormElement:!1,HTMLSelectElement:!1,MediaList:!0,MimeTypeArray:!1,NamedNodeMap:!1,NodeList:!0,PaintRequestList:!1,Plugin:!1,PluginArray:!1,SVGLengthList:!1,SVGNumberList:!1,SVGPathSegList:!1,SVGPointList:!1,SVGStringList:!1,SVGTransformList:!1,SourceBufferList:!1,StyleSheetList:!0,TextTrackCueList:!1,TextTrackList:!1,TouchList:!1},jt=ut(Lt),At=0;At<jt.length;At++){var Tt,Pt=jt[At],Rt=Lt[Pt],Mt=e[Pt],Ft=Mt&&Mt.prototype;if(Ft&&(Ft[Et]||v(Ft,Et,Ot),Ft[Ct]||v(Ft,Ct,Pt),Q[Pt]=Ot,Rt))for(Tt in wt)Ft[Tt]||b(Ft,Tt,wt[Tt],!0)}var Kt,Nt,Dt=function(t){return function(e,n){var r,i,o=String(C(e)),u=A(n),c=o.length;return u<0||u>=c?t?"":void 0:(r=o.charCodeAt(u))<55296||r>56319||u+1===c||(i=o.charCodeAt(u+1))<56320||i>57343?t?o.charAt(u):r:t?o.slice(u,u+2):i-56320+(r-55296<<10)+65536}}(!0),Ht=function(t,e,n){return e+(n?Dt(t,e).length:1)},Gt=F("toStringTag"),$t="Arguments"==w(function(){return arguments}()),Vt=RegExp.prototype.exec,qt=function(t,e){var n,r,i,o,u=t.exec;if("function"==typeof u){var c=u.call(t,e);if("object"!=typeof c)throw new TypeError("RegExp exec method returned something other than an Object or null");return c}if("RegExp"!==(void 0===(n=t)?"Undefined":null===n?"Null":"string"==typeof(i=function(t,e){try{return t[e]}catch(t){}}(r=Object(n),Gt))?i:$t?w(r):"Object"==(o=w(r))&&"function"==typeof r.callee?"Arguments":o))throw new TypeError("RegExp#exec called on incompatible receiver");return Vt.call(t,e)},Bt=function(){var t=i(this),e="";return t.global&&(e+="g"),t.ignoreCase&&(e+="i"),t.multiline&&(e+="m"),t.unicode&&(e+="u"),t.sticky&&(e+="y"),e},Xt=RegExp.prototype.exec,Ut=String.prototype.replace,Wt=Xt,zt=(Kt=/a/,Nt=/b*/g,Xt.call(Kt,"a"),Xt.call(Nt,"a"),0!==Kt.lastIndex||0!==Nt.lastIndex),Jt=void 0!==/()??/.exec("")[1];(zt||Jt)&&(Wt=function(t){var e,n,r,i,o=this;return Jt&&(n=new RegExp("^"+o.source+"$(?!\\s)",Bt.call(o))),zt&&(e=o.lastIndex),r=Xt.call(o,t),zt&&r&&(o.lastIndex=o.global?r.index+r[0].length:e),Jt&&r&&r.length>1&&Ut.call(r[0],n,function(){for(i=1;i<arguments.length-2;i++)void 0===arguments[i]&&(r[i]=void 0)}),r});var Qt=Wt;k({target:"RegExp",proto:!0,forced:Qt!==/./.exec},{exec:Qt});var Yt=F("species"),Zt=!o(function(){var t=/./;return t.exec=function(){var t=[];return t.groups={a:"7"},t},"7"!=="".replace(t,"$<a>")}),te=function(){var t=/(?:)/,e=t.exec;t.exec=function(){return e.apply(this,arguments)};var n="ab".split(t);return 2===n.length&&"a"===n[0]&&"b"===n[1]}(),ee=Math.max,ne=Math.min,re=Math.floor,ie=/\$([$&`']|\d\d?|<[^>]*>)/g,oe=/\$([$&`']|\d\d?)/g;function ue(t){return(ue="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function ce(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function ae(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function se(t,e,n){return e&&ae(t.prototype,e),n&&ae(t,n),t}function le(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function fe(t){return(fe=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function pe(t,e){return(pe=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function he(t,e){return!e||"object"!=typeof e&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}!function(t,e,n){var r=F(t),i=!o(function(){var e={};return e[r]=function(){return 7},7!=""[t](e)}),u=i?!o(function(){var e=!1,n=/a/;return n.exec=function(){return e=!0,null},"split"===t&&(n.constructor={},n.constructor[Yt]=function(){return n}),n[r](""),!e}):void 0;if(!i||!u||"replace"===t&&!Zt||"split"===t&&!te){var c=/./[r],a=n(C,r,""[t],function(t,e,n,r,o){return e.exec===Qt?i&&!o?{done:!0,value:c.call(e,n,r)}:{done:!0,value:t.call(n,e,r)}:{done:!1}}),s=a[0],l=a[1];b(String.prototype,t,s),v(RegExp.prototype,r,2==e?function(t,e){return l.call(t,this,e)}:function(t){return l.call(t,this)})}}("replace",2,function(t,e,n,r){return[function(r,i){var o=t(this),u=null==r?void 0:r[e];return void 0!==u?u.call(r,o,i):n.call(String(o),r,i)},function(t,e){var u=r(n,t,this,e);if(u.done)return u.value;var c=i(t),a=String(this),s="function"==typeof e;s||(e=String(e));var l=c.global;if(l){var f=c.unicode;c.lastIndex=0}for(var p=[];;){var h=qt(c,a);if(null===h)break;if(p.push(h),!l)break;""===String(h[0])&&(c.lastIndex=Ht(a,P(c.lastIndex),f))}for(var v,d="",y=0,m=0;m<p.length;m++){h=p[m];for(var g=String(h[0]),_=ee(ne(A(h.index),a.length),0),b=[],x=1;x<h.length;x++)b.push(void 0===(v=h[x])?v:String(v));var S=h.groups;if(s){var k=[g].concat(b,_,a);void 0!==S&&k.push(S);var I=String(e.apply(void 0,k))}else I=o(g,a,_,b,S,e);_>=y&&(d+=a.slice(y,_)+I,y=_+g.length)}return d+a.slice(y)}];function o(t,e,r,i,o,u){var c=r+t.length,a=i.length,s=oe;return void 0!==o&&(o=O(o),s=ie),n.call(u,s,function(n,u){var s;switch(u.charAt(0)){case"$":return"$";case"&":return t;case"`":return e.slice(0,r);case"'":return e.slice(c);case"<":s=o[u.slice(1,-1)];break;default:var l=+u;if(0===l)return n;if(l>a){var f=re(l/10);return 0===f?n:f<=a?void 0===i[f-1]?u.charAt(1):i[f-1]+u.charAt(1):n}s=i[l-1]}return void 0===s?"":s})}}),u&&"g"!=/./g.flags&&p.f(RegExp.prototype,"flags",{configurable:!0,get:Bt});var ve=/./.toString,de=function(t){b(RegExp.prototype,"toString",t,!0)};o(function(){return"/a/b"!=ve.call({source:"a",flags:"b"})})?de(function(){var t=i(this);return"/".concat(t.source,"/","flags"in t?t.flags:!u&&t instanceof RegExp?Bt.call(t):void 0)}):"toString"!=ve.name&&de(function(){return ve.call(this)});var ye=D(5),me=!0;"find"in[]&&Array(1).find(function(){me=!1}),k(k.P+k.F*me,"Array",{find:function(t){return ye(this,t,arguments.length>1?arguments[1]:void 0)}}),$("find");var ge={f:Object.getOwnPropertySymbols},_e={f:{}.propertyIsEnumerable},be=Object.assign,xe=!be||o(function(){var t={},e={},n=Symbol(),r="abcdefghijklmnopqrst";return t[n]=7,r.split("").forEach(function(t){e[t]=t}),7!=be({},t)[n]||Object.keys(be({},e)).join("")!=r})?function(t,e){for(var n=O(t),r=arguments.length,i=1,o=ge.f,u=_e.f;r>i;)for(var c,a=E(arguments[i++]),s=o?ut(a).concat(o(a)):ut(a),l=s.length,f=0;l>f;)u.call(a,c=s[f++])&&(n[c]=a[c]);return n}:be;k(k.S+k.F,"Object",{assign:xe});var Se=document,ke=function(){function t(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};ce(this,t),this.options=Object.assign({},r,n),this._events=[],this.dom={el:this._setElement(e)}}return se(t,[{key:"on",value:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;return(n||this.dom.el).addEventListener(t,e=e.bind(this),!0),this._events.push({name:t,fn:e,el:n}),this}},{key:"getElement",value:function(){return this.dom.el}},{key:"remove",value:function(){var t=this;this._events=this._events.filter(function(e){return(e.el||t.dom.el).removeEventListener(e.name,e.fn,!0)}),this.dom.el.parentNode.removeChild(this.dom.el),this.dom=this.options=null}},{key:"_setElement",value:function(t){if(!t&&!t.nodeType&&"string"!=typeof t)throw new Error("Wrong element type provided!");return t.nodeType?t:(this.options.parent||Se).querySelector(t)}},{key:"_trigger",value:function(t){var e,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;"function"==typeof CustomEvent?e=new CustomEvent(t,{detail:n,bubbles:!0,cancelable:!0}):(e=Se.createEvent("Event")).initEvent(t,!0,!0),this.dom.el.dispatchEvent(e)}}]),t}(),Ie={parent:null,items:[],current:null,allowAdd:!0,proposal:"Add {X} to the list?",notFound:"{X} not present in the list",allowRemove:!0,removalIcon:"&times;",placeHolder:"Type to search",sort:!0,order:"desc",maxHeight:0,onDelete:null,onCreate:null,valueKey:"value",textKey:"value"},we=document;return function(t){function e(t){var n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};ce(this,e),n=he(this,fe(e).call(this,t,r,Ie));var i=r.current?n._convertItem(r.current):null;return n.options.items=n._convertItems(r.items),n.current=n.findItem(i[r.valueKey]),n.__found=null,n.options.sort&&n._sortItems(),n._renderInit(),n._bindEvents(),n.current&&(n.dom.input.value=n.current[r.textKey]),n}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&pe(t,e)}(e,ke),se(e,[{key:"_bindEvents",value:function(){var t=this,e=function(e){"Escape"!==e.key&&27!==e.keyCode&&t.dom.el.contains(e.target)||t.toggle(!1)};this.on("input",this._search),this.on("click",this._handleClick),this.on("keyup",this._handleKey),this.on("focusin",function(){return t._renderListItems().toggle(!0)},this.dom.input),this.on("keyup",e,we),this.on("click",e,we)}},{key:"onDelete",value:function(t){return this.options.onDelete=t,this}},{key:"onCreate",value:function(t){return this.options.onCreate=t,this}},{key:"toggle",value:function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return this.dom.el.firstElementChild.classList[t?"remove":"add"]("si-hide"),t||this.dom.input.blur(),this}},{key:"getItems",value:function(){return this.options.items}},{key:"getCurrent",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,e=Object.assign({},this.current);return delete e._lc_value,delete e._lc_text,t?e[t]:e}},{key:"clearCurrent",value:function(){this.current=null,this.dom.input.value="",this._clearSelected()}},{key:"findItem",value:function(t){var e=this.options;return t=t.nodeName?t.dataset.value:t,e.items.find(function(n){return n[e.valueKey]===t})}},{key:"setCurrent",value:function(t){return this._setCurrent(t?this.findItem(t):null),this}},{key:"_setCurrent",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return this.dom.input.value=t?t[this.options.textKey].toString():"",t?(this.current=t,this._setSelected(t,e)):(this.current=null,this._clearSelected()),this}},{key:"_setSelected",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;this._clearSelected(),(e=e||this.dom.list.querySelector('li[data-value="'.concat(t[this.options.valueKey],'"]')))&&e.classList.add("si-current")}},{key:"_clearSelected",value:function(){var t=this.dom.list.querySelector(".si-current");t&&t.classList.remove("si-current")}},{key:"_convertItems",value:function(){var t=this;return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]).map(function(e){return t._convertItem(e)})}},{key:"_convertItem",value:function(t){var e,n=this.options;return(t="object"!==ue(t)?(le(e={},n.valueKey,t),le(e,n.textKey,t),e):t)._lc_value=t[n.valueKey].toString().toLowerCase().replace(/\s+/g,"-"),t._lc_text=t[n.textKey].toString().toLowerCase().replace(/\s+/g,"-"),t}},{key:"_renderInit",value:function(){var t=we.createElement("div");return t.className="si-wrap si-hide",this.dom.input=t.appendChild(this._renderInput()).firstChild,this.dom.list=t.appendChild(this._renderList()).firstChild,this.dom.el.appendChild(t)}},{key:"_renderInput",value:function(){var t=we.createElement("div"),e=we.createElement("input");return t.className="si-input",e.type="text",e.autocomplete="false",e.spellcheck=!1,e.placeholder=this.options.placeHolder,t.appendChild(e),t}},{key:"_renderList",value:function(){var t=we.createElement("div"),e=we.createElement("ul"),n=this.options.maxHeight;return t.className="si-list",n&&(t.style.maxHeight=n+"px"),t.appendChild(e),t}},{key:"_createListItems",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],e="",n=this.options,r=this.getCurrent(n.valueKey),i=n.allowRemove?this._createRemovalButton():"",o="",u="";return t.forEach(function(t){o=t[n.valueKey],u=t[n.textKey],e+='<li class="si-item'.concat(r&&o===r?" si-current":"",'" data-value="').concat(o,'">').concat(u).concat(i,"</li>")}),e}},{key:"_renderListItems",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return this.dom.list.innerHTML=t||this._createListItems(this.options.items),this}},{key:"_createRemovalButton",value:function(){return'<button type="button" class="si-removal">'.concat(this.options.removalIcon,"</button>")}},{key:"_search",value:function(t){var e=this.options,n=t.target.value,r=n.toLowerCase().replace(/\s+/g,"-"),i=e.items.filter(function(t){return-1!==t._lc_value.indexOf(r)||-1!==t._lc_text.indexOf(r)}),o=i||e.allowAdd?this._createListItems(i):"",u=i[0],c=i.length;1===c&&(this.__found=u),(c>1||!c||!n)&&(this.__found=null),e.allowAdd&&n&&(!u||r!==u._lc_text&&r!==u._lc_value)?o+=this._proposeItem(n):e.allowAdd||(o+=this._notFoundItem(n)),this._renderListItems(o)}},{key:"_proposeItem",value:function(t){var e=this.options.proposal.replace("{X}","<span>".concat(t,"</span>"));return'<li class="si-item si-append si-proposal" data-term="'.concat(t,'">').concat(e,"</li>")}},{key:"_notFoundItem",value:function(t){var e=this.options.notFound.replace("{X}","<span>".concat(t,"</span>"));return'<li class="si-item si-append si-not-found">'.concat(e,"</li>")}},{key:"_handleClick",value:function(t){var e=t.target,n=e.classList;this.options.allowAdd&&n.contains("si-proposal")?this._tryCreateItem(e.dataset.term)&&this.toggle()._trigger("created",this.current):n.contains("si-item")?this._setCurrent(this.findItem(e),e).toggle()._trigger("selected",this.current):this.options.allowRemove&&n.contains("si-removal")&&(e=e.parentNode,this._fireCallback("onDelete",this.findItem(e))&&this._trigger("removed",this._sliceItem(e)))}},{key:"_fireCallback",value:function(t,e){return"function"!=typeof this.options[t]||this.options[t](e)}},{key:"_handleKey",value:function(t){var e,n=t.target.value,r=this.__found;(!n||13===t.keyCode&&"Enter"===t.key)&&(!r&&n&&this.options.allowAdd?e=this._tryCreateItem(n)?"created":null:r&&(e="selected",this._setCurrent(r)),e&&this.toggle()._trigger(e,this.current))}},{key:"_tryCreateItem",value:function(t){var e=this._convertItem(t.trim());return!(this.findItem(t)||!this._fireCallback("onCreate",e))&&(this._setCurrent(this._insertItem(e)),!0)}},{key:"_insertItem",value:function(t){return this.options.items.push(t),this.options.sort&&this._sortItems(),t}},{key:"_sortItems",value:function(){var t="desc"===this.options.order?1:-1;this.options.items.sort(function(e,n){return e._lc_text<n._lc_text?-t:e._lc_text>n._lc_text?t:0})}},{key:"_sliceItem",value:function(t){var e,n=this.options.items,r=t.dataset.value.toLowerCase(),i=this.current;return this.dom.list.removeChild(t),e=n.splice(n.findIndex(function(t){return t._lc_value===r}),1).shift(),i&&e._lc_value===i._lc_value&&this.clearCurrent(),e}}]),e}()});
//# sourceMappingURL=select-input-umd.js.map
/*! @dotburo/select-input 1.2.4 | dotburo <code@dotburo.org> (https://dotburo.org) !*/
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global = global || self, global.SelectInput = factory());
}(this, function () { 'use strict';
function createCommonjsModule(fn, module) {
return module = { exports: {} }, fn(module, module.exports), module.exports;
}
var _global = createCommonjsModule(function (module) {
// https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
var global = module.exports = typeof window != 'undefined' && window.Math == Math ? window : typeof self != 'undefined' && self.Math == Math ? self // eslint-disable-next-line no-new-func
: Function('return this')();
if (typeof __g == 'number') __g = global; // eslint-disable-line no-undef
});
var _core = createCommonjsModule(function (module) {
var core = module.exports = {
version: '2.6.3'
};
if (typeof __e == 'number') __e = core; // eslint-disable-line no-undef
});
var _core_1 = _core.version;
var _isObject = function (it) {
return typeof it === 'object' ? it !== null : typeof it === 'function';
};
var _anObject = function (it) {
if (!_isObject(it)) throw TypeError(it + ' is not an object!');
return it;
};
var _fails = function (exec) {
try {
return !!exec();
} catch (e) {
return true;
}
};
var _descriptors = !_fails(function () {
return Object.defineProperty({}, 'a', {
get: function () {
return 7;
}
}).a != 7;
});
var document$1 = _global.document; // typeof document.createElement is 'object' in old IE
var is = _isObject(document$1) && _isObject(document$1.createElement);
var _domCreate = function (it) {
return is ? document$1.createElement(it) : {};
};
var _ie8DomDefine = !_descriptors && !_fails(function () {
return Object.defineProperty(_domCreate('div'), 'a', {
get: function () {
return 7;
}
}).a != 7;
});
// instead of the ES6 spec version, we didn't implement @@toPrimitive case
// and the second argument - flag - preferred type is a string
var _toPrimitive = function (it, S) {
if (!_isObject(it)) return it;
var fn, val;
if (S && typeof (fn = it.toString) == 'function' && !_isObject(val = fn.call(it))) return val;
if (typeof (fn = it.valueOf) == 'function' && !_isObject(val = fn.call(it))) return val;
if (!S && typeof (fn = it.toString) == 'function' && !_isObject(val = fn.call(it))) return val;
throw TypeError("Can't convert object to primitive value");
};
var dP = Object.defineProperty;
var f = _descriptors ? Object.defineProperty : function defineProperty(O, P, Attributes) {
_anObject(O);
P = _toPrimitive(P, true);
_anObject(Attributes);
if (_ie8DomDefine) try {
return dP(O, P, Attributes);
} catch (e) {
/* empty */
}
if ('get' in Attributes || 'set' in Attributes) throw TypeError('Accessors not supported!');
if ('value' in Attributes) O[P] = Attributes.value;
return O;
};
var _objectDp = {
f: f
};
var _propertyDesc = function (bitmap, value) {
return {
enumerable: !(bitmap & 1),
configurable: !(bitmap & 2),
writable: !(bitmap & 4),
value: value
};
};
var _hide = _descriptors ? function (object, key, value) {
return _objectDp.f(object, key, _propertyDesc(1, value));
} : function (object, key, value) {
object[key] = value;
return object;
};
var hasOwnProperty = {}.hasOwnProperty;
var _has = function (it, key) {
return hasOwnProperty.call(it, key);
};
var id = 0;
var px = Math.random();
var _uid = function (key) {
return 'Symbol('.concat(key === undefined ? '' : key, ')_', (++id + px).toString(36));
};
var _redefine = createCommonjsModule(function (module) {
var SRC = _uid('src');
var TO_STRING = 'toString';
var $toString = Function[TO_STRING];
var TPL = ('' + $toString).split(TO_STRING);
_core.inspectSource = function (it) {
return $toString.call(it);
};
(module.exports = function (O, key, val, safe) {
var isFunction = typeof val == 'function';
if (isFunction) _has(val, 'name') || _hide(val, 'name', key);
if (O[key] === val) return;
if (isFunction) _has(val, SRC) || _hide(val, SRC, O[key] ? '' + O[key] : TPL.join(String(key)));
if (O === _global) {
O[key] = val;
} else if (!safe) {
delete O[key];
_hide(O, key, val);
} else if (O[key]) {
O[key] = val;
} else {
_hide(O, key, val);
} // add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative
})(Function.prototype, TO_STRING, function toString() {
return typeof this == 'function' && this[SRC] || $toString.call(this);
});
});
var _aFunction = function (it) {
if (typeof it != 'function') throw TypeError(it + ' is not a function!');
return it;
};
var _ctx = function (fn, that, length) {
_aFunction(fn);
if (that === undefined) return fn;
switch (length) {
case 1:
return function (a) {
return fn.call(that, a);
};
case 2:
return function (a, b) {
return fn.call(that, a, b);
};
case 3:
return function (a, b, c) {
return fn.call(that, a, b, c);
};
}
return function ()
/* ...args */
{
return fn.apply(that, arguments);
};
};
var PROTOTYPE = 'prototype';
var $export = function (type, name, source) {
var IS_FORCED = type & $export.F;
var IS_GLOBAL = type & $export.G;
var IS_STATIC = type & $export.S;
var IS_PROTO = type & $export.P;
var IS_BIND = type & $export.B;
var target = IS_GLOBAL ? _global : IS_STATIC ? _global[name] || (_global[name] = {}) : (_global[name] || {})[PROTOTYPE];
var exports = IS_GLOBAL ? _core : _core[name] || (_core[name] = {});
var expProto = exports[PROTOTYPE] || (exports[PROTOTYPE] = {});
var key, own, out, exp;
if (IS_GLOBAL) source = name;
for (key in source) {
// contains in native
own = !IS_FORCED && target && target[key] !== undefined; // export native or passed
out = (own ? target : source)[key]; // bind timers to global for call from export context
exp = IS_BIND && own ? _ctx(out, _global) : IS_PROTO && typeof out == 'function' ? _ctx(Function.call, out) : out; // extend global
if (target) _redefine(target, key, out, type & $export.U); // export
if (exports[key] != out) _hide(exports, key, exp);
if (IS_PROTO && expProto[key] != out) expProto[key] = out;
}
};
_global.core = _core; // type bitmap
$export.F = 1; // forced
$export.G = 2; // global
$export.S = 4; // static
$export.P = 8; // proto
$export.B = 16; // bind
$export.W = 32; // wrap
$export.U = 64; // safe
$export.R = 128; // real proto method for `library`
var _export = $export;
var toString = {}.toString;
var _cof = function (it) {
return toString.call(it).slice(8, -1);
};
// eslint-disable-next-line no-prototype-builtins
var _iobject = Object('z').propertyIsEnumerable(0) ? Object : function (it) {
return _cof(it) == 'String' ? it.split('') : Object(it);
};
// 7.2.1 RequireObjectCoercible(argument)
var _defined = function (it) {
if (it == undefined) throw TypeError("Can't call method on " + it);
return it;
};
var _toObject = function (it) {
return Object(_defined(it));
};
// 7.1.4 ToInteger
var ceil = Math.ceil;
var floor = Math.floor;
var _toInteger = function (it) {
return isNaN(it = +it) ? 0 : (it > 0 ? floor : ceil)(it);
};
var min = Math.min;
var _toLength = function (it) {
return it > 0 ? min(_toInteger(it), 0x1fffffffffffff) : 0; // pow(2, 53) - 1 == 9007199254740991
};
var _isArray = Array.isArray || function isArray(arg) {
return _cof(arg) == 'Array';
};
var _library = false;
var _shared = createCommonjsModule(function (module) {
var SHARED = '__core-js_shared__';
var store = _global[SHARED] || (_global[SHARED] = {});
(module.exports = function (key, value) {
return store[key] || (store[key] = value !== undefined ? value : {});
})('versions', []).push({
version: _core.version,
mode: _library ? 'pure' : 'global',
copyright: '© 2019 Denis Pushkarev (zloirock.ru)'
});
});
var _wks = createCommonjsModule(function (module) {
var store = _shared('wks');
var Symbol = _global.Symbol;
var USE_SYMBOL = typeof Symbol == 'function';
var $exports = module.exports = function (name) {
return store[name] || (store[name] = USE_SYMBOL && Symbol[name] || (USE_SYMBOL ? Symbol : _uid)('Symbol.' + name));
};
$exports.store = store;
});
var SPECIES = _wks('species');
var _arraySpeciesConstructor = function (original) {
var C;
if (_isArray(original)) {
C = original.constructor; // cross-realm fallback
if (typeof C == 'function' && (C === Array || _isArray(C.prototype))) C = undefined;
if (_isObject(C)) {
C = C[SPECIES];
if (C === null) C = undefined;
}
}
return C === undefined ? Array : C;
};
var _arraySpeciesCreate = function (original, length) {
return new (_arraySpeciesConstructor(original))(length);
};
// 1 -> Array#map
// 2 -> Array#filter
// 3 -> Array#some
// 4 -> Array#every
// 5 -> Array#find
// 6 -> Array#findIndex
var _arrayMethods = function (TYPE, $create) {
var IS_MAP = TYPE == 1;
var IS_FILTER = TYPE == 2;
var IS_SOME = TYPE == 3;
var IS_EVERY = TYPE == 4;
var IS_FIND_INDEX = TYPE == 6;
var NO_HOLES = TYPE == 5 || IS_FIND_INDEX;
var create = $create || _arraySpeciesCreate;
return function ($this, callbackfn, that) {
var O = _toObject($this);
var self = _iobject(O);
var f = _ctx(callbackfn, that, 3);
var length = _toLength(self.length);
var index = 0;
var result = IS_MAP ? create($this, length) : IS_FILTER ? create($this, 0) : undefined;
var val, res;
for (; length > index; index++) if (NO_HOLES || index in self) {
val = self[index];
res = f(val, index, O);
if (TYPE) {
if (IS_MAP) result[index] = res; // map
else if (res) switch (TYPE) {
case 3:
return true;
// some
case 5:
return val;
// find
case 6:
return index;
// findIndex
case 2:
result.push(val);
// filter
} else if (IS_EVERY) return false; // every
}
}
return IS_FIND_INDEX ? -1 : IS_SOME || IS_EVERY ? IS_EVERY : result;
};
};
var UNSCOPABLES = _wks('unscopables');
var ArrayProto = Array.prototype;
if (ArrayProto[UNSCOPABLES] == undefined) _hide(ArrayProto, UNSCOPABLES, {});
var _addToUnscopables = function (key) {
ArrayProto[UNSCOPABLES][key] = true;
};
var $find = _arrayMethods(6);
var KEY = 'findIndex';
var forced = true; // Shouldn't skip holes
if (KEY in []) Array(1)[KEY](function () {
forced = false;
});
_export(_export.P + _export.F * forced, 'Array', {
findIndex: function findIndex(callbackfn
/* , that = undefined */
) {
return $find(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
}
});
_addToUnscopables(KEY);
var dP$1 = _objectDp.f;
var FProto = Function.prototype;
var nameRE = /^\s*function ([^ (]*)/;
var NAME = 'name'; // 19.2.4.2 name
NAME in FProto || _descriptors && dP$1(FProto, NAME, {
configurable: true,
get: function () {
try {
return ('' + this).match(nameRE)[1];
} catch (e) {
return '';
}
}
});
var _iterStep = function (done, value) {
return {
value: value,
done: !!done
};
};
var _iterators = {};
var _toIobject = function (it) {
return _iobject(_defined(it));
};
var max = Math.max;
var min$1 = Math.min;
var _toAbsoluteIndex = function (index, length) {
index = _toInteger(index);
return index < 0 ? max(index + length, 0) : min$1(index, length);
};
// true -> Array#includes
var _arrayIncludes = function (IS_INCLUDES) {
return function ($this, el, fromIndex) {
var O = _toIobject($this);
var length = _toLength(O.length);
var index = _toAbsoluteIndex(fromIndex, length);
var value; // Array#includes uses SameValueZero equality algorithm
// eslint-disable-next-line no-self-compare
if (IS_INCLUDES && el != el) while (length > index) {
value = O[index++]; // eslint-disable-next-line no-self-compare
if (value != value) return true; // Array#indexOf ignores holes, Array#includes - not
} else for (; length > index; index++) if (IS_INCLUDES || index in O) {
if (O[index] === el) return IS_INCLUDES || index || 0;
}
return !IS_INCLUDES && -1;
};
};
var shared = _shared('keys');
var _sharedKey = function (key) {
return shared[key] || (shared[key] = _uid(key));
};
var arrayIndexOf = _arrayIncludes(false);
var IE_PROTO = _sharedKey('IE_PROTO');
var _objectKeysInternal = function (object, names) {
var O = _toIobject(object);
var i = 0;
var result = [];
var key;
for (key in O) if (key != IE_PROTO) _has(O, key) && result.push(key); // Don't enum bug & hidden keys
while (names.length > i) if (_has(O, key = names[i++])) {
~arrayIndexOf(result, key) || result.push(key);
}
return result;
};
// IE 8- don't enum bug keys
var _enumBugKeys = 'constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf'.split(',');
var _objectKeys = Object.keys || function keys(O) {
return _objectKeysInternal(O, _enumBugKeys);
};
var _objectDps = _descriptors ? Object.defineProperties : function defineProperties(O, Properties) {
_anObject(O);
var keys = _objectKeys(Properties);
var length = keys.length;
var i = 0;
var P;
while (length > i) _objectDp.f(O, P = keys[i++], Properties[P]);
return O;
};
var document$2 = _global.document;
var _html = document$2 && document$2.documentElement;
var IE_PROTO$1 = _sharedKey('IE_PROTO');
var Empty = function () {
/* empty */
};
var PROTOTYPE$1 = 'prototype'; // Create object with fake `null` prototype: use iframe Object with cleared prototype
var createDict = function () {
// Thrash, waste and sodomy: IE GC bug
var iframe = _domCreate('iframe');
var i = _enumBugKeys.length;
var lt = '<';
var gt = '>';
var iframeDocument;
iframe.style.display = 'none';
_html.appendChild(iframe);
iframe.src = 'javascript:'; // eslint-disable-line no-script-url
// createDict = iframe.contentWindow.Object;
// html.removeChild(iframe);
iframeDocument = iframe.contentWindow.document;
iframeDocument.open();
iframeDocument.write(lt + 'script' + gt + 'document.F=Object' + lt + '/script' + gt);
iframeDocument.close();
createDict = iframeDocument.F;
while (i--) delete createDict[PROTOTYPE$1][_enumBugKeys[i]];
return createDict();
};
var _objectCreate = Object.create || function create(O, Properties) {
var result;
if (O !== null) {
Empty[PROTOTYPE$1] = _anObject(O);
result = new Empty();
Empty[PROTOTYPE$1] = null; // add "__proto__" for Object.getPrototypeOf polyfill
result[IE_PROTO$1] = O;
} else result = createDict();
return Properties === undefined ? result : _objectDps(result, Properties);
};
var def = _objectDp.f;
var TAG = _wks('toStringTag');
var _setToStringTag = function (it, tag, stat) {
if (it && !_has(it = stat ? it : it.prototype, TAG)) def(it, TAG, {
configurable: true,
value: tag
});
};
var IteratorPrototype = {}; // 25.1.2.1.1 %IteratorPrototype%[@@iterator]()
_hide(IteratorPrototype, _wks('iterator'), function () {
return this;
});
var _iterCreate = function (Constructor, NAME, next) {
Constructor.prototype = _objectCreate(IteratorPrototype, {
next: _propertyDesc(1, next)
});
_setToStringTag(Constructor, NAME + ' Iterator');
};
var IE_PROTO$2 = _sharedKey('IE_PROTO');
var ObjectProto = Object.prototype;
var _objectGpo = Object.getPrototypeOf || function (O) {
O = _toObject(O);
if (_has(O, IE_PROTO$2)) return O[IE_PROTO$2];
if (typeof O.constructor == 'function' && O instanceof O.constructor) {
return O.constructor.prototype;
}
return O instanceof Object ? ObjectProto : null;
};
var ITERATOR = _wks('iterator');
var BUGGY = !([].keys && 'next' in [].keys()); // Safari has buggy iterators w/o `next`
var FF_ITERATOR = '@@iterator';
var KEYS = 'keys';
var VALUES = 'values';
var returnThis = function () {
return this;
};
var _iterDefine = function (Base, NAME, Constructor, next, DEFAULT, IS_SET, FORCED) {
_iterCreate(Constructor, NAME, next);
var getMethod = function (kind) {
if (!BUGGY && kind in proto) return proto[kind];
switch (kind) {
case KEYS:
return function keys() {
return new Constructor(this, kind);
};
case VALUES:
return function values() {
return new Constructor(this, kind);
};
}
return function entries() {
return new Constructor(this, kind);
};
};
var TAG = NAME + ' Iterator';
var DEF_VALUES = DEFAULT == VALUES;
var VALUES_BUG = false;
var proto = Base.prototype;
var $native = proto[ITERATOR] || proto[FF_ITERATOR] || DEFAULT && proto[DEFAULT];
var $default = $native || getMethod(DEFAULT);
var $entries = DEFAULT ? !DEF_VALUES ? $default : getMethod('entries') : undefined;
var $anyNative = NAME == 'Array' ? proto.entries || $native : $native;
var methods, key, IteratorPrototype; // Fix native
if ($anyNative) {
IteratorPrototype = _objectGpo($anyNative.call(new Base()));
if (IteratorPrototype !== Object.prototype && IteratorPrototype.next) {
// Set @@toStringTag to native iterators
_setToStringTag(IteratorPrototype, TAG, true); // fix for some old engines
if (!_library && typeof IteratorPrototype[ITERATOR] != 'function') _hide(IteratorPrototype, ITERATOR, returnThis);
}
} // fix Array#{values, @@iterator}.name in V8 / FF
if (DEF_VALUES && $native && $native.name !== VALUES) {
VALUES_BUG = true;
$default = function values() {
return $native.call(this);
};
} // Define iterator
if ((!_library || FORCED) && (BUGGY || VALUES_BUG || !proto[ITERATOR])) {
_hide(proto, ITERATOR, $default);
} // Plug for library
_iterators[NAME] = $default;
_iterators[TAG] = returnThis;
if (DEFAULT) {
methods = {
values: DEF_VALUES ? $default : getMethod(VALUES),
keys: IS_SET ? $default : getMethod(KEYS),
entries: $entries
};
if (FORCED) for (key in methods) {
if (!(key in proto)) _redefine(proto, key, methods[key]);
} else _export(_export.P + _export.F * (BUGGY || VALUES_BUG), NAME, methods);
}
return methods;
};
// 22.1.3.13 Array.prototype.keys()
// 22.1.3.29 Array.prototype.values()
// 22.1.3.30 Array.prototype[@@iterator]()
var es6_array_iterator = _iterDefine(Array, 'Array', function (iterated, kind) {
this._t = _toIobject(iterated); // target
this._i = 0; // next index
this._k = kind; // kind
// 22.1.5.2.1 %ArrayIteratorPrototype%.next()
}, function () {
var O = this._t;
var kind = this._k;
var index = this._i++;
if (!O || index >= O.length) {
this._t = undefined;
return _iterStep(1);
}
if (kind == 'keys') return _iterStep(0, index);
if (kind == 'values') return _iterStep(0, O[index]);
return _iterStep(0, [index, O[index]]);
}, 'values'); // argumentsList[@@iterator] is %ArrayProto_values% (9.4.4.6, 9.4.4.7)
_iterators.Arguments = _iterators.Array;
_addToUnscopables('keys');
_addToUnscopables('values');
_addToUnscopables('entries');
var ITERATOR$1 = _wks('iterator');
var TO_STRING_TAG = _wks('toStringTag');
var ArrayValues = _iterators.Array;
var DOMIterables = {
CSSRuleList: true,
// TODO: Not spec compliant, should be false.
CSSStyleDeclaration: false,
CSSValueList: false,
ClientRectList: false,
DOMRectList: false,
DOMStringList: false,
DOMTokenList: true,
DataTransferItemList: false,
FileList: false,
HTMLAllCollection: false,
HTMLCollection: false,
HTMLFormElement: false,
HTMLSelectElement: false,
MediaList: true,
// TODO: Not spec compliant, should be false.
MimeTypeArray: false,
NamedNodeMap: false,
NodeList: true,
PaintRequestList: false,
Plugin: false,
PluginArray: false,
SVGLengthList: false,
SVGNumberList: false,
SVGPathSegList: false,
SVGPointList: false,
SVGStringList: false,
SVGTransformList: false,
SourceBufferList: false,
StyleSheetList: true,
// TODO: Not spec compliant, should be false.
TextTrackCueList: false,
TextTrackList: false,
TouchList: false
};
for (var collections = _objectKeys(DOMIterables), i = 0; i < collections.length; i++) {
var NAME$1 = collections[i];
var explicit = DOMIterables[NAME$1];
var Collection = _global[NAME$1];
var proto = Collection && Collection.prototype;
var key;
if (proto) {
if (!proto[ITERATOR$1]) _hide(proto, ITERATOR$1, ArrayValues);
if (!proto[TO_STRING_TAG]) _hide(proto, TO_STRING_TAG, NAME$1);
_iterators[NAME$1] = ArrayValues;
if (explicit) for (key in es6_array_iterator) if (!proto[key]) _redefine(proto, key, es6_array_iterator[key], true);
}
}
// false -> String#codePointAt
var _stringAt = function (TO_STRING) {
return function (that, pos) {
var s = String(_defined(that));
var i = _toInteger(pos);
var l = s.length;
var a, b;
if (i < 0 || i >= l) return TO_STRING ? '' : undefined;
a = s.charCodeAt(i);
return a < 0xd800 || a > 0xdbff || i + 1 === l || (b = s.charCodeAt(i + 1)) < 0xdc00 || b > 0xdfff ? TO_STRING ? s.charAt(i) : a : TO_STRING ? s.slice(i, i + 2) : (a - 0xd800 << 10) + (b - 0xdc00) + 0x10000;
};
};
var at = _stringAt(true); // `AdvanceStringIndex` abstract operation
// https://tc39.github.io/ecma262/#sec-advancestringindex
var _advanceStringIndex = function (S, index, unicode) {
return index + (unicode ? at(S, index).length : 1);
};
var TAG$1 = _wks('toStringTag'); // ES3 wrong here
var ARG = _cof(function () {
return arguments;
}()) == 'Arguments'; // fallback for IE11 Script Access Denied error
var tryGet = function (it, key) {
try {
return it[key];
} catch (e) {
/* empty */
}
};
var _classof = function (it) {
var O, T, B;
return it === undefined ? 'Undefined' : it === null ? 'Null' // @@toStringTag case
: typeof (T = tryGet(O = Object(it), TAG$1)) == 'string' ? T // builtinTag case
: ARG ? _cof(O) // ES3 arguments fallback
: (B = _cof(O)) == 'Object' && typeof O.callee == 'function' ? 'Arguments' : B;
};
var builtinExec = RegExp.prototype.exec; // `RegExpExec` abstract operation
// https://tc39.github.io/ecma262/#sec-regexpexec
var _regexpExecAbstract = function (R, S) {
var exec = R.exec;
if (typeof exec === 'function') {
var result = exec.call(R, S);
if (typeof result !== 'object') {
throw new TypeError('RegExp exec method returned something other than an Object or null');
}
return result;
}
if (_classof(R) !== 'RegExp') {
throw new TypeError('RegExp#exec called on incompatible receiver');
}
return builtinExec.call(R, S);
};
var _flags = function () {
var that = _anObject(this);
var result = '';
if (that.global) result += 'g';
if (that.ignoreCase) result += 'i';
if (that.multiline) result += 'm';
if (that.unicode) result += 'u';
if (that.sticky) result += 'y';
return result;
};
var nativeExec = RegExp.prototype.exec; // This always refers to the native implementation, because the
// String#replace polyfill uses ./fix-regexp-well-known-symbol-logic.js,
// which loads this file before patching the method.
var nativeReplace = String.prototype.replace;
var patchedExec = nativeExec;
var LAST_INDEX = 'lastIndex';
var UPDATES_LAST_INDEX_WRONG = function () {
var re1 = /a/,
re2 = /b*/g;
nativeExec.call(re1, 'a');
nativeExec.call(re2, 'a');
return re1[LAST_INDEX] !== 0 || re2[LAST_INDEX] !== 0;
}(); // nonparticipating capturing group, copied from es5-shim's String#split patch.
var NPCG_INCLUDED = /()??/.exec('')[1] !== undefined;
var PATCH = UPDATES_LAST_INDEX_WRONG || NPCG_INCLUDED;
if (PATCH) {
patchedExec = function exec(str) {
var re = this;
var lastIndex, reCopy, match, i;
if (NPCG_INCLUDED) {
reCopy = new RegExp('^' + re.source + '$(?!\\s)', _flags.call(re));
}
if (UPDATES_LAST_INDEX_WRONG) lastIndex = re[LAST_INDEX];
match = nativeExec.call(re, str);
if (UPDATES_LAST_INDEX_WRONG && match) {
re[LAST_INDEX] = re.global ? match.index + match[0].length : lastIndex;
}
if (NPCG_INCLUDED && match && match.length > 1) {
// Fix browsers whose `exec` methods don't consistently return `undefined`
// for NPCG, like IE8. NOTE: This doesn' work for /(.?)?/
// eslint-disable-next-line no-loop-func
nativeReplace.call(match[0], reCopy, function () {
for (i = 1; i < arguments.length - 2; i++) {
if (arguments[i] === undefined) match[i] = undefined;
}
});
}
return match;
};
}
var _regexpExec = patchedExec;
_export({
target: 'RegExp',
proto: true,
forced: _regexpExec !== /./.exec
}, {
exec: _regexpExec
});
var SPECIES$1 = _wks('species');
var REPLACE_SUPPORTS_NAMED_GROUPS = !_fails(function () {
// #replace needs built-in support for named groups.
// #match works fine because it just return the exec results, even if it has
// a "grops" property.
var re = /./;
re.exec = function () {
var result = [];
result.groups = {
a: '7'
};
return result;
};
return ''.replace(re, '$<a>') !== '7';
});
var SPLIT_WORKS_WITH_OVERWRITTEN_EXEC = function () {
// Chrome 51 has a buggy "split" implementation when RegExp#exec !== nativeExec
var re = /(?:)/;
var originalExec = re.exec;
re.exec = function () {
return originalExec.apply(this, arguments);
};
var result = 'ab'.split(re);
return result.length === 2 && result[0] === 'a' && result[1] === 'b';
}();
var _fixReWks = function (KEY, length, exec) {
var SYMBOL = _wks(KEY);
var DELEGATES_TO_SYMBOL = !_fails(function () {
// String methods call symbol-named RegEp methods
var O = {};
O[SYMBOL] = function () {
return 7;
};
return ''[KEY](O) != 7;
});
var DELEGATES_TO_EXEC = DELEGATES_TO_SYMBOL ? !_fails(function () {
// Symbol-named RegExp methods call .exec
var execCalled = false;
var re = /a/;
re.exec = function () {
execCalled = true;
return null;
};
if (KEY === 'split') {
// RegExp[@@split] doesn't call the regex's exec method, but first creates
// a new one. We need to return the patched regex when creating the new one.
re.constructor = {};
re.constructor[SPECIES$1] = function () {
return re;
};
}
re[SYMBOL]('');
return !execCalled;
}) : undefined;
if (!DELEGATES_TO_SYMBOL || !DELEGATES_TO_EXEC || KEY === 'replace' && !REPLACE_SUPPORTS_NAMED_GROUPS || KEY === 'split' && !SPLIT_WORKS_WITH_OVERWRITTEN_EXEC) {
var nativeRegExpMethod = /./[SYMBOL];
var fns = exec(_defined, SYMBOL, ''[KEY], function maybeCallNative(nativeMethod, regexp, str, arg2, forceStringMethod) {
if (regexp.exec === _regexpExec) {
if (DELEGATES_TO_SYMBOL && !forceStringMethod) {
// The native String method already delegates to @@method (this
// polyfilled function), leasing to infinite recursion.
// We avoid it by directly calling the native @@method method.
return {
done: true,
value: nativeRegExpMethod.call(regexp, str, arg2)
};
}
return {
done: true,
value: nativeMethod.call(str, regexp, arg2)
};
}
return {
done: false
};
});
var strfn = fns[0];
var rxfn = fns[1];
_redefine(String.prototype, KEY, strfn);
_hide(RegExp.prototype, SYMBOL, length == 2 // 21.2.5.8 RegExp.prototype[@@replace](string, replaceValue)
// 21.2.5.11 RegExp.prototype[@@split](string, limit)
? function (string, arg) {
return rxfn.call(string, this, arg);
} // 21.2.5.6 RegExp.prototype[@@match](string)
// 21.2.5.9 RegExp.prototype[@@search](string)
: function (string) {
return rxfn.call(string, this);
});
}
};
var max$1 = Math.max;
var min$2 = Math.min;
var floor$1 = Math.floor;
var SUBSTITUTION_SYMBOLS = /\$([$&`']|\d\d?|<[^>]*>)/g;
var SUBSTITUTION_SYMBOLS_NO_NAMED = /\$([$&`']|\d\d?)/g;
var maybeToString = function (it) {
return it === undefined ? it : String(it);
}; // @@replace logic
_fixReWks('replace', 2, function (defined, REPLACE, $replace, maybeCallNative) {
return [// `String.prototype.replace` method
// https://tc39.github.io/ecma262/#sec-string.prototype.replace
function replace(searchValue, replaceValue) {
var O = defined(this);
var fn = searchValue == undefined ? undefined : searchValue[REPLACE];
return fn !== undefined ? fn.call(searchValue, O, replaceValue) : $replace.call(String(O), searchValue, replaceValue);
}, // `RegExp.prototype[@@replace]` method
// https://tc39.github.io/ecma262/#sec-regexp.prototype-@@replace
function (regexp, replaceValue) {
var res = maybeCallNative($replace, regexp, this, replaceValue);
if (res.done) return res.value;
var rx = _anObject(regexp);
var S = String(this);
var functionalReplace = typeof replaceValue === 'function';
if (!functionalReplace) replaceValue = String(replaceValue);
var global = rx.global;
if (global) {
var fullUnicode = rx.unicode;
rx.lastIndex = 0;
}
var results = [];
while (true) {
var result = _regexpExecAbstract(rx, S);
if (result === null) break;
results.push(result);
if (!global) break;
var matchStr = String(result[0]);
if (matchStr === '') rx.lastIndex = _advanceStringIndex(S, _toLength(rx.lastIndex), fullUnicode);
}
var accumulatedResult = '';
var nextSourcePosition = 0;
for (var i = 0; i < results.length; i++) {
result = results[i];
var matched = String(result[0]);
var position = max$1(min$2(_toInteger(result.index), S.length), 0);
var captures = []; // NOTE: This is equivalent to
// captures = result.slice(1).map(maybeToString)
// but for some reason `nativeSlice.call(result, 1, result.length)` (called in
// the slice polyfill when slicing native arrays) "doesn't work" in safari 9 and
// causes a crash (https://pastebin.com/N21QzeQA) when trying to debug it.
for (var j = 1; j < result.length; j++) captures.push(maybeToString(result[j]));
var namedCaptures = result.groups;
if (functionalReplace) {
var replacerArgs = [matched].concat(captures, position, S);
if (namedCaptures !== undefined) replacerArgs.push(namedCaptures);
var replacement = String(replaceValue.apply(undefined, replacerArgs));
} else {
replacement = getSubstitution(matched, S, position, captures, namedCaptures, replaceValue);
}
if (position >= nextSourcePosition) {
accumulatedResult += S.slice(nextSourcePosition, position) + replacement;
nextSourcePosition = position + matched.length;
}
}
return accumulatedResult + S.slice(nextSourcePosition);
}]; // https://tc39.github.io/ecma262/#sec-getsubstitution
function getSubstitution(matched, str, position, captures, namedCaptures, replacement) {
var tailPos = position + matched.length;
var m = captures.length;
var symbols = SUBSTITUTION_SYMBOLS_NO_NAMED;
if (namedCaptures !== undefined) {
namedCaptures = _toObject(namedCaptures);
symbols = SUBSTITUTION_SYMBOLS;
}
return $replace.call(replacement, symbols, function (match, ch) {
var capture;
switch (ch.charAt(0)) {
case '$':
return '$';
case '&':
return matched;
case '`':
return str.slice(0, position);
case "'":
return str.slice(tailPos);
case '<':
capture = namedCaptures[ch.slice(1, -1)];
break;
default:
// \d\d?
var n = +ch;
if (n === 0) return match;
if (n > m) {
var f = floor$1(n / 10);
if (f === 0) return match;
if (f <= m) return captures[f - 1] === undefined ? ch.charAt(1) : captures[f - 1] + ch.charAt(1);
return match;
}
capture = captures[n - 1];
}
return capture === undefined ? '' : capture;
});
}
});
function _typeof(obj) {
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
_typeof = function (obj) {
return typeof obj;
};
} else {
_typeof = function (obj) {
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
};
}
return _typeof(obj);
}
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
}
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;
}
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 _inherits(subClass, superClass) {
if (typeof superClass !== "function" && superClass !== null) {
throw new TypeError("Super expression must either be null or a function");
}
subClass.prototype = Object.create(superClass && superClass.prototype, {
constructor: {
value: subClass,
writable: true,
configurable: true
}
});
if (superClass) _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 _assertThisInitialized(self) {
if (self === void 0) {
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
}
return self;
}
function _possibleConstructorReturn(self, call) {
if (call && (typeof call === "object" || typeof call === "function")) {
return call;
}
return _assertThisInitialized(self);
}
if (_descriptors && /./g.flags != 'g') _objectDp.f(RegExp.prototype, 'flags', {
configurable: true,
get: _flags
});
var TO_STRING = 'toString';
var $toString = /./[TO_STRING];
var define = function (fn) {
_redefine(RegExp.prototype, TO_STRING, fn, true);
}; // 21.2.5.14 RegExp.prototype.toString()
if (_fails(function () {
return $toString.call({
source: 'a',
flags: 'b'
}) != '/a/b';
})) {
define(function toString() {
var R = _anObject(this);
return '/'.concat(R.source, '/', 'flags' in R ? R.flags : !_descriptors && R instanceof RegExp ? _flags.call(R) : undefined);
}); // FF44- RegExp#toString has a wrong name
} else if ($toString.name != TO_STRING) {
define(function toString() {
return $toString.call(this);
});
}
var $find$1 = _arrayMethods(5);
var KEY$1 = 'find';
var forced$1 = true; // Shouldn't skip holes
if (KEY$1 in []) Array(1)[KEY$1](function () {
forced$1 = false;
});
_export(_export.P + _export.F * forced$1, 'Array', {
find: function find(callbackfn
/* , that = undefined */
) {
return $find$1(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
}
});
_addToUnscopables(KEY$1);
var f$1 = Object.getOwnPropertySymbols;
var _objectGops = {
f: f$1
};
var f$2 = {}.propertyIsEnumerable;
var _objectPie = {
f: f$2
};
var $assign = Object.assign; // should work with symbols and should have deterministic property order (V8 bug)
var _objectAssign = !$assign || _fails(function () {
var A = {};
var B = {}; // eslint-disable-next-line no-undef
var S = Symbol();
var K = 'abcdefghijklmnopqrst';
A[S] = 7;
K.split('').forEach(function (k) {
B[k] = k;
});
return $assign({}, A)[S] != 7 || Object.keys($assign({}, B)).join('') != K;
}) ? function assign(target, source) {
// eslint-disable-line no-unused-vars
var T = _toObject(target);
var aLen = arguments.length;
var index = 1;
var getSymbols = _objectGops.f;
var isEnum = _objectPie.f;
while (aLen > index) {
var S = _iobject(arguments[index++]);
var keys = getSymbols ? _objectKeys(S).concat(getSymbols(S)) : _objectKeys(S);
var length = keys.length;
var j = 0;
var key;
while (length > j) if (isEnum.call(S, key = keys[j++])) T[key] = S[key];
}
return T;
} : $assign;
_export(_export.S + _export.F, 'Object', {
assign: _objectAssign
});
var d = document;
var DomComponent =
/*#__PURE__*/
function () {
function DomComponent(element) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var defaults = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
_classCallCheck(this, DomComponent);
this.options = Object.assign({}, defaults, options);
this._events = [];
this.dom = {
el: this._setElement(element)
};
}
/**
* Bind a (delegated) event
* @param {String} event
* @param {Function} fn
* @param {HTMLElement|Document} el
* @return DomComponent
*/
_createClass(DomComponent, [{
key: "on",
value: function on(event, fn) {
var el = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
(el || this.dom.el).addEventListener(event, fn = fn.bind(this), true);
this._events.push({
name: event,
fn: fn,
el: el
});
return this;
}
/**
* Return the main wrapping element
* @return {Element}
*/
}, {
key: "getElement",
value: function getElement() {
return this.dom.el;
}
/**
* Unbind all events and nullify references
* @return void
*/
}, {
key: "remove",
value: function remove() {
var _this = this;
this._events = this._events.filter(function (event) {
return (event.el || _this.dom.el).removeEventListener(event.name, event.fn, true);
});
this.dom.el.parentNode.removeChild(this.dom.el);
this.dom = this.options = null;
}
/**
* Query the element in the DOM if its a string
* @param {Element|String} el
* @return {Element|null}
* @protected
*/
}, {
key: "_setElement",
value: function _setElement(el) {
if (!el && !el.nodeType && typeof el !== 'string') {
throw new Error('Wrong element type provided!');
}
if (el.nodeType) return el;
return (this.options.parent || d).querySelector(el);
}
/**
* Communicate changes
* @param {String} name
* @param {Object|null} detail
* @protected
*/
}, {
key: "_trigger",
value: function _trigger(name) {
var detail = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
var event;
if (typeof CustomEvent === 'function') {
event = new CustomEvent(name, {
detail: detail,
bubbles: true,
cancelable: true
});
} else {
event = d.createEvent('Event');
event.initEvent(name, true, true);
}
this.dom.el.dispatchEvent(event);
}
}]);
return DomComponent;
}();
var defaults = {
parent: null,
items: [],
current: null,
allowAdd: true,
proposal: 'Add {X} to the list?',
notFound: '{X} not present in the list',
allowRemove: true,
removalIcon: '&times;',
placeHolder: 'Type to search',
sort: true,
order: 'desc',
maxHeight: 0,
onDelete: null,
onCreate: null,
valueKey: 'value',
textKey: 'value'
};
var d$1 = document;
var SelectInput =
/*#__PURE__*/
function (_DomHelper) {
_inherits(SelectInput, _DomHelper);
function SelectInput(element) {
var _this;
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
_classCallCheck(this, SelectInput);
_this = _possibleConstructorReturn(this, _getPrototypeOf(SelectInput).call(this, element, options, defaults));
var current = options.current ? _this._convertItem(options.current) : null;
_this.options.items = _this._convertItems(options.items);
_this.current = current ? _this.findItem(_this._getItemProp(current)) : null; // search result caching
_this.__found = null;
if (_this.options.sort) _this._sortItems();
_this._renderInit();
_this._bindEvents();
if (current) {
_this._setInputValue(current);
}
return _this;
}
/**
* Bind all (delegated) DOM events
* @private
*/
_createClass(SelectInput, [{
key: "_bindEvents",
value: function _bindEvents() {
var _this2 = this;
var closeOnEvent = function closeOnEvent(e) {
if (e.key === 'Escape' || e.keyCode === 27 || !_this2.dom.el.contains(e.target)) {
_this2.toggle(false);
}
};
this.on('input', this._search);
this.on('click', this._handleClick);
this.on('keyup', this._handleKey);
this.on('focusin', function () {
return _this2._renderListItems().toggle(true);
}, this.dom.input); // Close the list on `Escape` or on a click outside the main element
this.on('keyup', closeOnEvent, d$1);
this.on('click', closeOnEvent, d$1);
}
/**
* Store the deletion callback
* @param {Function} fn
* @return SelectInput
*/
}, {
key: "onDelete",
value: function onDelete(fn) {
this.options.onDelete = fn;
return this;
}
/**
* Store the creation callback
* @param {Function} fn
* @return SelectInput
*/
}, {
key: "onCreate",
value: function onCreate(fn) {
this.options.onCreate = fn;
return this;
}
/**
* Show/hide the dropdown
* @param {Boolean} show
* @return DomHelper
*/
}, {
key: "toggle",
value: function toggle() {
var show = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
this.dom.el.firstElementChild.classList[show ? 'remove' : 'add']('si-hide');
if (!show) this.dom.input.blur();
return this;
}
/**
* Get all items in the list
* @return {Object[]}
*/
}, {
key: "getItems",
value: function getItems() {
return this.options.items;
}
/**
* Return the current field value object
* @return {{value: String|Number}|null}
*/
}, {
key: "getCurrent",
value: function getCurrent() {
var current = Object.assign({}, this.current);
delete current._lc_value;
delete current._lc_text;
return current;
}
/**
* Clear the current value
* @return void
* @private
*/
}, {
key: "clearCurrent",
value: function clearCurrent() {
this.current = null;
this.dom.input.value = '';
this._clearSelected();
}
/**
* Find an item in the list
* @param {EventTarget|HTMLElement|String|Number} value
* @return {{}}
*/
}, {
key: "findItem",
value: function findItem(value) {
var _this3 = this;
value = value.nodeName ? value.dataset.value : value;
return this.options.items.find(function (item) {
return _this3._getItemProp(item) === value;
});
}
/**
* Set the current value by its string
* @param {String|undefined} value
* @return SelectInput
*/
}, {
key: "setCurrent",
value: function setCurrent(value) {
this._setCurrent(value ? this.findItem(value) : null);
return this;
}
/**
* Set the current value of the field
* @param {EventTarget|null} el
* @param {Object|null} item
* @return SelectInput
* @private
*/
}, {
key: "_setCurrent",
value: function _setCurrent(item) {
var el = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
this._setInputValue(item);
if (item) {
this.current = item;
this._setSelected(item, el);
} else {
this.current = null;
this._clearSelected();
}
return this;
}
/**
* Set the HTML input field
* @param {Object} item
* @return void
* @private
*/
}, {
key: "_setInputValue",
value: function _setInputValue(item) {
this.dom.input.value = item ? this._getItemProp(item, 'text').toString() : '';
}
/**
* Updated selected item in the html list
* @param {Object} item
* @param {EventTarget|HTMLElement|null} el
* @private
*/
}, {
key: "_setSelected",
value: function _setSelected(item) {
var el = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
this._clearSelected();
el = el ? el : this.dom.list.querySelector("li[data-value=\"".concat(this._getItemProp(item), "\"]"));
if (el) el.classList.add('si-current');
}
/**
* Remove the classname of current `<li>`
* @private
*/
}, {
key: "_clearSelected",
value: function _clearSelected() {
var current = this.dom.list.querySelector('.si-current');
if (current) current.classList.remove('si-current');
}
/**
* Make an array of objects
* @param {Array} items
* @return {Object[]}
* @private
*/
}, {
key: "_convertItems",
value: function _convertItems() {
var _this4 = this;
var items = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
return items.map(function (item) {
return _this4._convertItem(item);
});
}
/**
* Normalize an item as an usable object
* @param {String|Number|{value: String|Number, _lc_value: String, _lc_text: String}} item
* @return {{value: String|Number, _lc_value: String, _lc_text: String}}
* @private
*/
}, {
key: "_convertItem",
value: function _convertItem(item) {
var _ref;
var opt = this.options;
item = _typeof(item) !== 'object' ? (_ref = {}, _defineProperty(_ref, opt.valueKey, item), _defineProperty(_ref, opt.textKey, item), _ref) : item;
item._lc_value = this._makeSearchString(this._getItemProp(item));
item._lc_text = this._makeSearchString(this._getItemProp(item, 'text'));
return item;
}
/**
* Format all searchable strings
* @param {String} value
* @return {String}
* @private
*/
}, {
key: "_makeSearchString",
value: function _makeSearchString(value) {
return value.toString().toLowerCase().replace(/\s+/g, '-');
}
/**
* Return the value of one of the custom named properties
* @param {Object} item
* @param {String} prop
* @return {String|Number}
* @private
*/
}, {
key: "_getItemProp",
value: function _getItemProp(item) {
var prop = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'value';
return item ? item[this.options["".concat(prop, "Key")]] : null;
}
/**
* Create the HTML upon instantiation
* @return {Node}
* @private
*/
}, {
key: "_renderInit",
value: function _renderInit() {
var wrap = d$1.createElement('div');
wrap.className = 'si-wrap si-hide';
this.dom.input = wrap.appendChild(this._renderInput()).firstChild;
this.dom.list = wrap.appendChild(this._renderList()).firstChild;
return this.dom.el.appendChild(wrap);
}
/**
* Create the input element
* @return {HTMLDivElement}
* @private
*/
}, {
key: "_renderInput",
value: function _renderInput() {
var wrap = d$1.createElement('div'),
el = d$1.createElement('input');
wrap.className = 'si-input';
el.type = 'text';
el.autocomplete = 'false';
el.spellcheck = false;
el.placeholder = this.options.placeHolder;
wrap.appendChild(el);
return wrap;
}
/**
* Create the list element
* @return {HTMLDivElement}
* @private
*/
}, {
key: "_renderList",
value: function _renderList() {
var wrap = d$1.createElement('div'),
el = d$1.createElement('ul'),
maxHeight = this.options.maxHeight;
wrap.className = 'si-list';
if (maxHeight) wrap.style.maxHeight = maxHeight + 'px';
wrap.appendChild(el);
return wrap;
}
/**
* Create the list items
* @param {Object[]} items
* @return {String}
* @private
*/
}, {
key: "_createListItems",
value: function _createListItems() {
var _this5 = this;
var items = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
var list = '',
opt = this.options,
currentValue = this._getItemProp(this.current),
selected = '',
button = opt.allowRemove ? this._createRemovalButton() : '',
value = '',
text = '';
items.forEach(function (item) {
value = _this5._getItemProp(item);
text = _this5._getItemProp(item, 'text');
selected = currentValue && value === currentValue ? ' si-current' : '';
list += "<li class=\"si-item".concat(selected, "\" data-value=\"").concat(value, "\">").concat(text + button, "</li>");
});
return list;
}
/**
* Insert the set of li's in the DOM
* @param html
* @return SelectInput
* @private
*/
}, {
key: "_renderListItems",
value: function _renderListItems() {
var html = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
this.dom.list.innerHTML = html || this._createListItems(this.options.items);
return this;
}
/**
* Item removal button template
* @return {String}
* @private
*/
}, {
key: "_createRemovalButton",
value: function _createRemovalButton() {
return "<button type=\"button\" class=\"si-removal\">".concat(this.options.removalIcon, "</button>");
}
/**
* Search and update the list upon typing
* @param {KeyboardEvent} e
* @private
*/
}, {
key: "_search",
value: function _search(e) {
var options = this.options,
term = e.target.value,
termLc = this._makeSearchString(term),
list = this._searchItem(termLc),
html = list || options.allowAdd ? this._createListItems(list) : '',
first = list[0],
len = list.length;
if (len === 1) {
this.__found = first;
}
if (len !== 1 || !term) {
this.__found = null;
}
if (options.allowAdd && term && (!first || termLc !== first._lc_text && termLc !== first._lc_value)) {
html += this._proposeItem(term);
} else if (!options.allowAdd) {
html += this._notFoundItem(term);
}
this._renderListItems(html);
}
/**
* Filter the list of available items
* @param {String} str
* @return {[]}
* @private
*/
}, {
key: "_searchItem",
value: function _searchItem(str) {
return this.options.items.filter(function (item) {
return item._lc_value.indexOf(str) !== -1 || item._lc_text.indexOf(str) !== -1;
});
}
/**
* Create the item creation list item
* @param {String} term
* @return {String}
* @private
*/
}, {
key: "_proposeItem",
value: function _proposeItem(term) {
var proposal = this.options.proposal.replace('{X}', "<span>".concat(term, "</span>"));
return "<li class=\"si-item si-append si-proposal\" data-term=\"".concat(term, "\">").concat(proposal, "</li>");
}
/**
* Create a 'not found' message as a list item
* @param {String} term
* @return {String}
* @private
*/
}, {
key: "_notFoundItem",
value: function _notFoundItem(term) {
var txt = this.options.notFound.replace('{X}', "<span>".concat(term, "</span>"));
return "<li class=\"si-item si-append si-not-found\">".concat(txt, "</li>");
}
/**
* Decide what to do when user clicks inside the component
* @param {MouseEvent} e
* @private
*/
}, {
key: "_handleClick",
value: function _handleClick(e) {
var el = e.target,
classList = el.classList;
if (this.options.allowAdd && classList.contains('si-proposal')) {
if (this._tryCreateItem(el.dataset.term)) {
this.toggle()._trigger('created', this.current);
}
return;
}
if (classList.contains('si-item')) {
this._setCurrent(this.findItem(el), el).toggle()._trigger('selected', this.current);
return;
}
if (this.options.allowRemove && classList.contains('si-removal')) {
el = el.parentNode;
if (this._fireCallback('onDelete', this.findItem(el))) {
this._trigger('removed', this._sliceItem(el));
}
}
}
/**
* The `onCreate` and `onDelete` callbacks allow to prevent their respective actions
* @param {String} name
* @param {Object} item
* @return {Boolean}
* @private
*/
}, {
key: "_fireCallback",
value: function _fireCallback(name, item) {
if (typeof this.options[name] === 'function') {
return this.options[name](item);
}
return true;
}
/**
* Handle `Enter` when there is a value in the field
* @param {KeyboardEvent} e
* @private
*/
}, {
key: "_handleKey",
value: function _handleKey(e) {
var value = e.target.value,
item = this.__found,
event;
if (!!value && (e.keyCode !== 13 || e.key !== 'Enter')) {
return;
}
if (!item && value && this.options.allowAdd) {
event = this._tryCreateItem(value) ? 'created' : null;
} else if (item) {
event = 'selected';
this._setCurrent(item);
}
if (event) this.toggle()._trigger(event, this.current);
}
/**
* If the value doesn't exist and the callback returns true, create and set as current
* @param value
* @return {boolean}
* @private
*/
}, {
key: "_tryCreateItem",
value: function _tryCreateItem(value) {
var item = this._convertItem(value.trim());
if (!this.findItem(value) && this._fireCallback('onCreate', item)) {
this._setCurrent(this._insertItem(item));
return true;
}
return false;
}
/**
* Insert a new item in the list
* @param {{value: String|Number, _lc_value: String, _lc_text: String}} item
* @return {{value: String|Number, _lc_value: String, _lc_text: String}}
* @private
*/
}, {
key: "_insertItem",
value: function _insertItem(item) {
this.options.items.push(item);
if (this.options.sort) this._sortItems();
return item;
}
/**
* Rearrange the list
* @private
*/
}, {
key: "_sortItems",
value: function _sortItems() {
var order = this.options.order === 'desc' ? 1 : -1;
this.options.items.sort(function (a, b) {
if (a._lc_text < b._lc_text) return -order;
if (a._lc_text > b._lc_text) return order;
return 0;
});
}
/**
* Remove an item from the list
* @param {HTMLElement|Node} el
* @return {{value: String|Number, _lc_value: String, _lc_text: String}}
* @private
*/
}, {
key: "_sliceItem",
value: function _sliceItem(el) {
var items = this.options.items,
needle = el.dataset.value.toLowerCase(),
current = this.current,
item;
this.dom.list.removeChild(el);
item = items.splice(items.findIndex(function (item) {
return item._lc_value === needle;
}), 1).shift();
if (current && item._lc_value === current._lc_value) this.clearCurrent();
return item;
}
}]);
return SelectInput;
}(DomComponent);
return SelectInput;
}));

@@ -1,2 +0,2093 @@

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).SelectInput=e()}(this,function(){"use strict";function t(t,e){return t(e={exports:{}},e.exports),e.exports}var e=t(function(t){var e=t.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=e)}),n=t(function(t){var e=t.exports={version:"2.6.3"};"number"==typeof __e&&(__e=e)}),r=(n.version,function(t){return"object"==typeof t?null!==t:"function"==typeof t}),i=function(t){if(!r(t))throw TypeError(t+" is not an object!");return t},o=function(t){try{return!!t()}catch(t){return!0}},u=!o(function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a}),c=e.document,a=r(c)&&r(c.createElement),s=function(t){return a?c.createElement(t):{}},l=!u&&!o(function(){return 7!=Object.defineProperty(s("div"),"a",{get:function(){return 7}}).a}),f=Object.defineProperty,p={f:u?Object.defineProperty:function(t,e,n){if(i(t),e=function(t,e){if(!r(t))return t;var n,i;if(e&&"function"==typeof(n=t.toString)&&!r(i=n.call(t)))return i;if("function"==typeof(n=t.valueOf)&&!r(i=n.call(t)))return i;if(!e&&"function"==typeof(n=t.toString)&&!r(i=n.call(t)))return i;throw TypeError("Can't convert object to primitive value")}(e,!0),i(n),l)try{return f(t,e,n)}catch(t){}if("get"in n||"set"in n)throw TypeError("Accessors not supported!");return"value"in n&&(t[e]=n.value),t}},h=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}},v=u?function(t,e,n){return p.f(t,e,h(1,n))}:function(t,e,n){return t[e]=n,t},d={}.hasOwnProperty,y=function(t,e){return d.call(t,e)},m=0,g=Math.random(),_=function(t){return"Symbol(".concat(void 0===t?"":t,")_",(++m+g).toString(36))},b=t(function(t){var r=_("src"),i=Function.toString,o=(""+i).split("toString");n.inspectSource=function(t){return i.call(t)},(t.exports=function(t,n,i,u){var c="function"==typeof i;c&&(y(i,"name")||v(i,"name",n)),t[n]!==i&&(c&&(y(i,r)||v(i,r,t[n]?""+t[n]:o.join(String(n)))),t===e?t[n]=i:u?t[n]?t[n]=i:v(t,n,i):(delete t[n],v(t,n,i)))})(Function.prototype,"toString",function(){return"function"==typeof this&&this[r]||i.call(this)})}),x=function(t,e,n){if(function(t){if("function"!=typeof t)throw TypeError(t+" is not a function!")}(t),void 0===e)return t;switch(n){case 1:return function(n){return t.call(e,n)};case 2:return function(n,r){return t.call(e,n,r)};case 3:return function(n,r,i){return t.call(e,n,r,i)}}return function(){return t.apply(e,arguments)}},S=function(t,r,i){var o,u,c,a,s=t&S.F,l=t&S.G,f=t&S.S,p=t&S.P,h=t&S.B,d=l?e:f?e[r]||(e[r]={}):(e[r]||{}).prototype,y=l?n:n[r]||(n[r]={}),m=y.prototype||(y.prototype={});for(o in l&&(i=r),i)c=((u=!s&&d&&void 0!==d[o])?d:i)[o],a=h&&u?x(c,e):p&&"function"==typeof c?x(Function.call,c):c,d&&b(d,o,c,t&S.U),y[o]!=c&&v(y,o,a),p&&m[o]!=c&&(m[o]=c)};e.core=n,S.F=1,S.G=2,S.S=4,S.P=8,S.B=16,S.W=32,S.U=64,S.R=128;var k=S,I={}.toString,w=function(t){return I.call(t).slice(8,-1)},E=Object("z").propertyIsEnumerable(0)?Object:function(t){return"String"==w(t)?t.split(""):Object(t)},C=function(t){if(null==t)throw TypeError("Can't call method on "+t);return t},O=function(t){return Object(C(t))},L=Math.ceil,j=Math.floor,A=function(t){return isNaN(t=+t)?0:(t>0?j:L)(t)},T=Math.min,P=function(t){return t>0?T(A(t),9007199254740991):0},R=Array.isArray||function(t){return"Array"==w(t)},M=t(function(t){var r=e["__core-js_shared__"]||(e["__core-js_shared__"]={});(t.exports=function(t,e){return r[t]||(r[t]=void 0!==e?e:{})})("versions",[]).push({version:n.version,mode:"global",copyright:"© 2019 Denis Pushkarev (zloirock.ru)"})}),F=t(function(t){var n=M("wks"),r=e.Symbol,i="function"==typeof r;(t.exports=function(t){return n[t]||(n[t]=i&&r[t]||(i?r:_)("Symbol."+t))}).store=n}),K=F("species"),N=function(t,e){return new(function(t){var e;return R(t)&&("function"!=typeof(e=t.constructor)||e!==Array&&!R(e.prototype)||(e=void 0),r(e)&&null===(e=e[K])&&(e=void 0)),void 0===e?Array:e}(t))(e)},D=function(t,e){var n=1==t,r=2==t,i=3==t,o=4==t,u=6==t,c=5==t||u,a=e||N;return function(e,s,l){for(var f,p,h=O(e),v=E(h),d=x(s,l,3),y=P(v.length),m=0,g=n?a(e,y):r?a(e,0):void 0;y>m;m++)if((c||m in v)&&(p=d(f=v[m],m,h),t))if(n)g[m]=p;else if(p)switch(t){case 3:return!0;case 5:return f;case 6:return m;case 2:g.push(f)}else if(o)return!1;return u?-1:i||o?o:g}},H=F("unscopables"),G=Array.prototype;null==G[H]&&v(G,H,{});var $=function(t){G[H][t]=!0},V=D(6),q="findIndex",B=!0;q in[]&&Array(1)[q](function(){B=!1}),k(k.P+k.F*B,"Array",{findIndex:function(t){return V(this,t,arguments.length>1?arguments[1]:void 0)}}),$(q);var X=p.f,U=Function.prototype,W=/^\s*function ([^ (]*)/;"name"in U||u&&X(U,"name",{configurable:!0,get:function(){try{return(""+this).match(W)[1]}catch(t){return""}}});var z,J=function(t,e){return{value:e,done:!!t}},Q={},Y=function(t){return E(C(t))},Z=Math.max,tt=Math.min,et=M("keys"),nt=function(t){return et[t]||(et[t]=_(t))},rt=(z=!1,function(t,e,n){var r,i=Y(t),o=P(i.length),u=function(t,e){return(t=A(t))<0?Z(t+e,0):tt(t,e)}(n,o);if(z&&e!=e){for(;o>u;)if((r=i[u++])!=r)return!0}else for(;o>u;u++)if((z||u in i)&&i[u]===e)return z||u||0;return!z&&-1}),it=nt("IE_PROTO"),ot="constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf".split(","),ut=Object.keys||function(t){return function(t,e){var n,r=Y(t),i=0,o=[];for(n in r)n!=it&&y(r,n)&&o.push(n);for(;e.length>i;)y(r,n=e[i++])&&(~rt(o,n)||o.push(n));return o}(t,ot)},ct=u?Object.defineProperties:function(t,e){i(t);for(var n,r=ut(e),o=r.length,u=0;o>u;)p.f(t,n=r[u++],e[n]);return t},at=e.document,st=at&&at.documentElement,lt=nt("IE_PROTO"),ft=function(){},pt=function(){var t,e=s("iframe"),n=ot.length;for(e.style.display="none",st.appendChild(e),e.src="javascript:",(t=e.contentWindow.document).open(),t.write("<script>document.F=Object<\/script>"),t.close(),pt=t.F;n--;)delete pt.prototype[ot[n]];return pt()},ht=Object.create||function(t,e){var n;return null!==t?(ft.prototype=i(t),n=new ft,ft.prototype=null,n[lt]=t):n=pt(),void 0===e?n:ct(n,e)},vt=p.f,dt=F("toStringTag"),yt=function(t,e,n){t&&!y(t=n?t:t.prototype,dt)&&vt(t,dt,{configurable:!0,value:e})},mt={};v(mt,F("iterator"),function(){return this});var gt=function(t,e,n){t.prototype=ht(mt,{next:h(1,n)}),yt(t,e+" Iterator")},_t=nt("IE_PROTO"),bt=Object.prototype,xt=Object.getPrototypeOf||function(t){return t=O(t),y(t,_t)?t[_t]:"function"==typeof t.constructor&&t instanceof t.constructor?t.constructor.prototype:t instanceof Object?bt:null},St=F("iterator"),kt=!([].keys&&"next"in[].keys()),It=function(){return this},wt=function(t,e,n,r,i,o,u){gt(n,e,r);var c,a,s,l=function(t){if(!kt&&t in d)return d[t];switch(t){case"keys":case"values":return function(){return new n(this,t)}}return function(){return new n(this,t)}},f=e+" Iterator",p="values"==i,h=!1,d=t.prototype,y=d[St]||d["@@iterator"]||i&&d[i],m=y||l(i),g=i?p?l("entries"):m:void 0,_="Array"==e&&d.entries||y;if(_&&(s=xt(_.call(new t)))!==Object.prototype&&s.next&&(yt(s,f,!0),"function"!=typeof s[St]&&v(s,St,It)),p&&y&&"values"!==y.name&&(h=!0,m=function(){return y.call(this)}),(kt||h||!d[St])&&v(d,St,m),Q[e]=m,Q[f]=It,i)if(c={values:p?m:l("values"),keys:o?m:l("keys"),entries:g},u)for(a in c)a in d||b(d,a,c[a]);else k(k.P+k.F*(kt||h),e,c);return c}(Array,"Array",function(t,e){this._t=Y(t),this._i=0,this._k=e},function(){var t=this._t,e=this._k,n=this._i++;return!t||n>=t.length?(this._t=void 0,J(1)):J(0,"keys"==e?n:"values"==e?t[n]:[n,t[n]])},"values");Q.Arguments=Q.Array,$("keys"),$("values"),$("entries");for(var Et=F("iterator"),Ct=F("toStringTag"),Ot=Q.Array,Lt={CSSRuleList:!0,CSSStyleDeclaration:!1,CSSValueList:!1,ClientRectList:!1,DOMRectList:!1,DOMStringList:!1,DOMTokenList:!0,DataTransferItemList:!1,FileList:!1,HTMLAllCollection:!1,HTMLCollection:!1,HTMLFormElement:!1,HTMLSelectElement:!1,MediaList:!0,MimeTypeArray:!1,NamedNodeMap:!1,NodeList:!0,PaintRequestList:!1,Plugin:!1,PluginArray:!1,SVGLengthList:!1,SVGNumberList:!1,SVGPathSegList:!1,SVGPointList:!1,SVGStringList:!1,SVGTransformList:!1,SourceBufferList:!1,StyleSheetList:!0,TextTrackCueList:!1,TextTrackList:!1,TouchList:!1},jt=ut(Lt),At=0;At<jt.length;At++){var Tt,Pt=jt[At],Rt=Lt[Pt],Mt=e[Pt],Ft=Mt&&Mt.prototype;if(Ft&&(Ft[Et]||v(Ft,Et,Ot),Ft[Ct]||v(Ft,Ct,Pt),Q[Pt]=Ot,Rt))for(Tt in wt)Ft[Tt]||b(Ft,Tt,wt[Tt],!0)}var Kt,Nt,Dt=function(t){return function(e,n){var r,i,o=String(C(e)),u=A(n),c=o.length;return u<0||u>=c?t?"":void 0:(r=o.charCodeAt(u))<55296||r>56319||u+1===c||(i=o.charCodeAt(u+1))<56320||i>57343?t?o.charAt(u):r:t?o.slice(u,u+2):i-56320+(r-55296<<10)+65536}}(!0),Ht=function(t,e,n){return e+(n?Dt(t,e).length:1)},Gt=F("toStringTag"),$t="Arguments"==w(function(){return arguments}()),Vt=RegExp.prototype.exec,qt=function(t,e){var n,r,i,o,u=t.exec;if("function"==typeof u){var c=u.call(t,e);if("object"!=typeof c)throw new TypeError("RegExp exec method returned something other than an Object or null");return c}if("RegExp"!==(void 0===(n=t)?"Undefined":null===n?"Null":"string"==typeof(i=function(t,e){try{return t[e]}catch(t){}}(r=Object(n),Gt))?i:$t?w(r):"Object"==(o=w(r))&&"function"==typeof r.callee?"Arguments":o))throw new TypeError("RegExp#exec called on incompatible receiver");return Vt.call(t,e)},Bt=function(){var t=i(this),e="";return t.global&&(e+="g"),t.ignoreCase&&(e+="i"),t.multiline&&(e+="m"),t.unicode&&(e+="u"),t.sticky&&(e+="y"),e},Xt=RegExp.prototype.exec,Ut=String.prototype.replace,Wt=Xt,zt=(Kt=/a/,Nt=/b*/g,Xt.call(Kt,"a"),Xt.call(Nt,"a"),0!==Kt.lastIndex||0!==Nt.lastIndex),Jt=void 0!==/()??/.exec("")[1];(zt||Jt)&&(Wt=function(t){var e,n,r,i,o=this;return Jt&&(n=new RegExp("^"+o.source+"$(?!\\s)",Bt.call(o))),zt&&(e=o.lastIndex),r=Xt.call(o,t),zt&&r&&(o.lastIndex=o.global?r.index+r[0].length:e),Jt&&r&&r.length>1&&Ut.call(r[0],n,function(){for(i=1;i<arguments.length-2;i++)void 0===arguments[i]&&(r[i]=void 0)}),r});var Qt=Wt;k({target:"RegExp",proto:!0,forced:Qt!==/./.exec},{exec:Qt});var Yt=F("species"),Zt=!o(function(){var t=/./;return t.exec=function(){var t=[];return t.groups={a:"7"},t},"7"!=="".replace(t,"$<a>")}),te=function(){var t=/(?:)/,e=t.exec;t.exec=function(){return e.apply(this,arguments)};var n="ab".split(t);return 2===n.length&&"a"===n[0]&&"b"===n[1]}(),ee=Math.max,ne=Math.min,re=Math.floor,ie=/\$([$&`']|\d\d?|<[^>]*>)/g,oe=/\$([$&`']|\d\d?)/g;function ue(t){return(ue="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function ce(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function ae(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function se(t,e,n){return e&&ae(t.prototype,e),n&&ae(t,n),t}function le(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function fe(t){return(fe=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function pe(t,e){return(pe=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function he(t,e){return!e||"object"!=typeof e&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}!function(t,e,n){var r=F(t),i=!o(function(){var e={};return e[r]=function(){return 7},7!=""[t](e)}),u=i?!o(function(){var e=!1,n=/a/;return n.exec=function(){return e=!0,null},"split"===t&&(n.constructor={},n.constructor[Yt]=function(){return n}),n[r](""),!e}):void 0;if(!i||!u||"replace"===t&&!Zt||"split"===t&&!te){var c=/./[r],a=n(C,r,""[t],function(t,e,n,r,o){return e.exec===Qt?i&&!o?{done:!0,value:c.call(e,n,r)}:{done:!0,value:t.call(n,e,r)}:{done:!1}}),s=a[0],l=a[1];b(String.prototype,t,s),v(RegExp.prototype,r,2==e?function(t,e){return l.call(t,this,e)}:function(t){return l.call(t,this)})}}("replace",2,function(t,e,n,r){return[function(r,i){var o=t(this),u=null==r?void 0:r[e];return void 0!==u?u.call(r,o,i):n.call(String(o),r,i)},function(t,e){var u=r(n,t,this,e);if(u.done)return u.value;var c=i(t),a=String(this),s="function"==typeof e;s||(e=String(e));var l=c.global;if(l){var f=c.unicode;c.lastIndex=0}for(var p=[];;){var h=qt(c,a);if(null===h)break;if(p.push(h),!l)break;""===String(h[0])&&(c.lastIndex=Ht(a,P(c.lastIndex),f))}for(var v,d="",y=0,m=0;m<p.length;m++){h=p[m];for(var g=String(h[0]),_=ee(ne(A(h.index),a.length),0),b=[],x=1;x<h.length;x++)b.push(void 0===(v=h[x])?v:String(v));var S=h.groups;if(s){var k=[g].concat(b,_,a);void 0!==S&&k.push(S);var I=String(e.apply(void 0,k))}else I=o(g,a,_,b,S,e);_>=y&&(d+=a.slice(y,_)+I,y=_+g.length)}return d+a.slice(y)}];function o(t,e,r,i,o,u){var c=r+t.length,a=i.length,s=oe;return void 0!==o&&(o=O(o),s=ie),n.call(u,s,function(n,u){var s;switch(u.charAt(0)){case"$":return"$";case"&":return t;case"`":return e.slice(0,r);case"'":return e.slice(c);case"<":s=o[u.slice(1,-1)];break;default:var l=+u;if(0===l)return n;if(l>a){var f=re(l/10);return 0===f?n:f<=a?void 0===i[f-1]?u.charAt(1):i[f-1]+u.charAt(1):n}s=i[l-1]}return void 0===s?"":s})}}),u&&"g"!=/./g.flags&&p.f(RegExp.prototype,"flags",{configurable:!0,get:Bt});var ve=/./.toString,de=function(t){b(RegExp.prototype,"toString",t,!0)};o(function(){return"/a/b"!=ve.call({source:"a",flags:"b"})})?de(function(){var t=i(this);return"/".concat(t.source,"/","flags"in t?t.flags:!u&&t instanceof RegExp?Bt.call(t):void 0)}):"toString"!=ve.name&&de(function(){return ve.call(this)});var ye=D(5),me=!0;"find"in[]&&Array(1).find(function(){me=!1}),k(k.P+k.F*me,"Array",{find:function(t){return ye(this,t,arguments.length>1?arguments[1]:void 0)}}),$("find");var ge={f:Object.getOwnPropertySymbols},_e={f:{}.propertyIsEnumerable},be=Object.assign,xe=!be||o(function(){var t={},e={},n=Symbol(),r="abcdefghijklmnopqrst";return t[n]=7,r.split("").forEach(function(t){e[t]=t}),7!=be({},t)[n]||Object.keys(be({},e)).join("")!=r})?function(t,e){for(var n=O(t),r=arguments.length,i=1,o=ge.f,u=_e.f;r>i;)for(var c,a=E(arguments[i++]),s=o?ut(a).concat(o(a)):ut(a),l=s.length,f=0;l>f;)u.call(a,c=s[f++])&&(n[c]=a[c]);return n}:be;k(k.S+k.F,"Object",{assign:xe});var Se=document,ke=function(){function t(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};ce(this,t),this.options=Object.assign({},r,n),this._events=[],this.dom={el:this._setElement(e)}}return se(t,[{key:"on",value:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;return(n||this.dom.el).addEventListener(t,e=e.bind(this),!0),this._events.push({name:t,fn:e,el:n}),this}},{key:"getElement",value:function(){return this.dom.el}},{key:"remove",value:function(){var t=this;this._events=this._events.filter(function(e){return(e.el||t.dom.el).removeEventListener(e.name,e.fn,!0)}),this.dom.el.parentNode.removeChild(this.dom.el),this.dom=this.options=null}},{key:"_setElement",value:function(t){if(!t&&!t.nodeType&&"string"!=typeof t)throw new Error("Wrong element type provided!");return t.nodeType?t:(this.options.parent||Se).querySelector(t)}},{key:"_trigger",value:function(t){var e,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;"function"==typeof CustomEvent?e=new CustomEvent(t,{detail:n,bubbles:!0,cancelable:!0}):(e=Se.createEvent("Event")).initEvent(t,!0,!0),this.dom.el.dispatchEvent(e)}}]),t}(),Ie={parent:null,items:[],current:null,allowAdd:!0,proposal:"Add {X} to the list?",notFound:"{X} not present in the list",allowRemove:!0,removalIcon:"&times;",placeHolder:"Type to search",sort:!0,order:"desc",maxHeight:0,onDelete:null,onCreate:null,valueKey:"value",textKey:"value"},we=document;return function(t){function e(t){var n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};ce(this,e),n=he(this,fe(e).call(this,t,r,Ie));var i=r.current?n._convertItem(r.current):null;return n.options.items=n._convertItems(r.items),n.current=n.findItem(i[r.valueKey]),n.__found=null,n.options.sort&&n._sortItems(),n._renderInit(),n._bindEvents(),n.current&&(n.dom.input.value=n.current[r.textKey]),n}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&pe(t,e)}(e,ke),se(e,[{key:"_bindEvents",value:function(){var t=this,e=function(e){"Escape"!==e.key&&27!==e.keyCode&&t.dom.el.contains(e.target)||t.toggle(!1)};this.on("input",this._search),this.on("click",this._handleClick),this.on("keyup",this._handleKey),this.on("focusin",function(){return t._renderListItems().toggle(!0)},this.dom.input),this.on("keyup",e,we),this.on("click",e,we)}},{key:"onDelete",value:function(t){return this.options.onDelete=t,this}},{key:"onCreate",value:function(t){return this.options.onCreate=t,this}},{key:"toggle",value:function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return this.dom.el.firstElementChild.classList[t?"remove":"add"]("si-hide"),t||this.dom.input.blur(),this}},{key:"getItems",value:function(){return this.options.items}},{key:"getCurrent",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,e=Object.assign({},this.current);return delete e._lc_value,delete e._lc_text,t?e[t]:e}},{key:"clearCurrent",value:function(){this.current=null,this.dom.input.value="",this._clearSelected()}},{key:"findItem",value:function(t){var e=this.options;return t=t.nodeName?t.dataset.value:t,e.items.find(function(n){return n[e.valueKey]===t})}},{key:"setCurrent",value:function(t){return this._setCurrent(t?this.findItem(t):null),this}},{key:"_setCurrent",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return this.dom.input.value=t?t[this.options.textKey].toString():"",t?(this.current=t,this._setSelected(t,e)):(this.current=null,this._clearSelected()),this}},{key:"_setSelected",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;this._clearSelected(),(e=e||this.dom.list.querySelector('li[data-value="'.concat(t[this.options.valueKey],'"]')))&&e.classList.add("si-current")}},{key:"_clearSelected",value:function(){var t=this.dom.list.querySelector(".si-current");t&&t.classList.remove("si-current")}},{key:"_convertItems",value:function(){var t=this;return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]).map(function(e){return t._convertItem(e)})}},{key:"_convertItem",value:function(t){var e,n=this.options;return(t="object"!==ue(t)?(le(e={},n.valueKey,t),le(e,n.textKey,t),e):t)._lc_value=t[n.valueKey].toString().toLowerCase().replace(/\s+/g,"-"),t._lc_text=t[n.textKey].toString().toLowerCase().replace(/\s+/g,"-"),t}},{key:"_renderInit",value:function(){var t=we.createElement("div");return t.className="si-wrap si-hide",this.dom.input=t.appendChild(this._renderInput()).firstChild,this.dom.list=t.appendChild(this._renderList()).firstChild,this.dom.el.appendChild(t)}},{key:"_renderInput",value:function(){var t=we.createElement("div"),e=we.createElement("input");return t.className="si-input",e.type="text",e.autocomplete="false",e.spellcheck=!1,e.placeholder=this.options.placeHolder,t.appendChild(e),t}},{key:"_renderList",value:function(){var t=we.createElement("div"),e=we.createElement("ul"),n=this.options.maxHeight;return t.className="si-list",n&&(t.style.maxHeight=n+"px"),t.appendChild(e),t}},{key:"_createListItems",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],e="",n=this.options,r=this.getCurrent(n.valueKey),i=n.allowRemove?this._createRemovalButton():"",o="",u="";return t.forEach(function(t){o=t[n.valueKey],u=t[n.textKey],e+='<li class="si-item'.concat(r&&o===r?" si-current":"",'" data-value="').concat(o,'">').concat(u).concat(i,"</li>")}),e}},{key:"_renderListItems",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return this.dom.list.innerHTML=t||this._createListItems(this.options.items),this}},{key:"_createRemovalButton",value:function(){return'<button type="button" class="si-removal">'.concat(this.options.removalIcon,"</button>")}},{key:"_search",value:function(t){var e=this.options,n=t.target.value,r=n.toLowerCase().replace(/\s+/g,"-"),i=e.items.filter(function(t){return-1!==t._lc_value.indexOf(r)||-1!==t._lc_text.indexOf(r)}),o=i||e.allowAdd?this._createListItems(i):"",u=i[0],c=i.length;1===c&&(this.__found=u),(c>1||!c||!n)&&(this.__found=null),e.allowAdd&&n&&(!u||r!==u._lc_text&&r!==u._lc_value)?o+=this._proposeItem(n):e.allowAdd||(o+=this._notFoundItem(n)),this._renderListItems(o)}},{key:"_proposeItem",value:function(t){var e=this.options.proposal.replace("{X}","<span>".concat(t,"</span>"));return'<li class="si-item si-append si-proposal" data-term="'.concat(t,'">').concat(e,"</li>")}},{key:"_notFoundItem",value:function(t){var e=this.options.notFound.replace("{X}","<span>".concat(t,"</span>"));return'<li class="si-item si-append si-not-found">'.concat(e,"</li>")}},{key:"_handleClick",value:function(t){var e=t.target,n=e.classList;this.options.allowAdd&&n.contains("si-proposal")?this._tryCreateItem(e.dataset.term)&&this.toggle()._trigger("created",this.current):n.contains("si-item")?this._setCurrent(this.findItem(e),e).toggle()._trigger("selected",this.current):this.options.allowRemove&&n.contains("si-removal")&&(e=e.parentNode,this._fireCallback("onDelete",this.findItem(e))&&this._trigger("removed",this._sliceItem(e)))}},{key:"_fireCallback",value:function(t,e){return"function"!=typeof this.options[t]||this.options[t](e)}},{key:"_handleKey",value:function(t){var e,n=t.target.value,r=this.__found;(!n||13===t.keyCode&&"Enter"===t.key)&&(!r&&n&&this.options.allowAdd?e=this._tryCreateItem(n)?"created":null:r&&(e="selected",this._setCurrent(r)),e&&this.toggle()._trigger(e,this.current))}},{key:"_tryCreateItem",value:function(t){var e=this._convertItem(t.trim());return!(this.findItem(t)||!this._fireCallback("onCreate",e))&&(this._setCurrent(this._insertItem(e)),!0)}},{key:"_insertItem",value:function(t){return this.options.items.push(t),this.options.sort&&this._sortItems(),t}},{key:"_sortItems",value:function(){var t="desc"===this.options.order?1:-1;this.options.items.sort(function(e,n){return e._lc_text<n._lc_text?-t:e._lc_text>n._lc_text?t:0})}},{key:"_sliceItem",value:function(t){var e,n=this.options.items,r=t.dataset.value.toLowerCase(),i=this.current;return this.dom.list.removeChild(t),e=n.splice(n.findIndex(function(t){return t._lc_value===r}),1).shift(),i&&e._lc_value===i._lc_value&&this.clearCurrent(),e}}]),e}()});
//# sourceMappingURL=select-input-umd.js.map
/*! @dotburo/select-input 1.2.4 | dotburo <code@dotburo.org> (https://dotburo.org) !*/
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global = global || self, global.SelectInput = factory());
}(this, function () { 'use strict';
function createCommonjsModule(fn, module) {
return module = { exports: {} }, fn(module, module.exports), module.exports;
}
var _global = createCommonjsModule(function (module) {
// https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
var global = module.exports = typeof window != 'undefined' && window.Math == Math ? window : typeof self != 'undefined' && self.Math == Math ? self // eslint-disable-next-line no-new-func
: Function('return this')();
if (typeof __g == 'number') __g = global; // eslint-disable-line no-undef
});
var _core = createCommonjsModule(function (module) {
var core = module.exports = {
version: '2.6.3'
};
if (typeof __e == 'number') __e = core; // eslint-disable-line no-undef
});
var _core_1 = _core.version;
var _isObject = function (it) {
return typeof it === 'object' ? it !== null : typeof it === 'function';
};
var _anObject = function (it) {
if (!_isObject(it)) throw TypeError(it + ' is not an object!');
return it;
};
var _fails = function (exec) {
try {
return !!exec();
} catch (e) {
return true;
}
};
var _descriptors = !_fails(function () {
return Object.defineProperty({}, 'a', {
get: function () {
return 7;
}
}).a != 7;
});
var document$1 = _global.document; // typeof document.createElement is 'object' in old IE
var is = _isObject(document$1) && _isObject(document$1.createElement);
var _domCreate = function (it) {
return is ? document$1.createElement(it) : {};
};
var _ie8DomDefine = !_descriptors && !_fails(function () {
return Object.defineProperty(_domCreate('div'), 'a', {
get: function () {
return 7;
}
}).a != 7;
});
// instead of the ES6 spec version, we didn't implement @@toPrimitive case
// and the second argument - flag - preferred type is a string
var _toPrimitive = function (it, S) {
if (!_isObject(it)) return it;
var fn, val;
if (S && typeof (fn = it.toString) == 'function' && !_isObject(val = fn.call(it))) return val;
if (typeof (fn = it.valueOf) == 'function' && !_isObject(val = fn.call(it))) return val;
if (!S && typeof (fn = it.toString) == 'function' && !_isObject(val = fn.call(it))) return val;
throw TypeError("Can't convert object to primitive value");
};
var dP = Object.defineProperty;
var f = _descriptors ? Object.defineProperty : function defineProperty(O, P, Attributes) {
_anObject(O);
P = _toPrimitive(P, true);
_anObject(Attributes);
if (_ie8DomDefine) try {
return dP(O, P, Attributes);
} catch (e) {
/* empty */
}
if ('get' in Attributes || 'set' in Attributes) throw TypeError('Accessors not supported!');
if ('value' in Attributes) O[P] = Attributes.value;
return O;
};
var _objectDp = {
f: f
};
var _propertyDesc = function (bitmap, value) {
return {
enumerable: !(bitmap & 1),
configurable: !(bitmap & 2),
writable: !(bitmap & 4),
value: value
};
};
var _hide = _descriptors ? function (object, key, value) {
return _objectDp.f(object, key, _propertyDesc(1, value));
} : function (object, key, value) {
object[key] = value;
return object;
};
var hasOwnProperty = {}.hasOwnProperty;
var _has = function (it, key) {
return hasOwnProperty.call(it, key);
};
var id = 0;
var px = Math.random();
var _uid = function (key) {
return 'Symbol('.concat(key === undefined ? '' : key, ')_', (++id + px).toString(36));
};
var _redefine = createCommonjsModule(function (module) {
var SRC = _uid('src');
var TO_STRING = 'toString';
var $toString = Function[TO_STRING];
var TPL = ('' + $toString).split(TO_STRING);
_core.inspectSource = function (it) {
return $toString.call(it);
};
(module.exports = function (O, key, val, safe) {
var isFunction = typeof val == 'function';
if (isFunction) _has(val, 'name') || _hide(val, 'name', key);
if (O[key] === val) return;
if (isFunction) _has(val, SRC) || _hide(val, SRC, O[key] ? '' + O[key] : TPL.join(String(key)));
if (O === _global) {
O[key] = val;
} else if (!safe) {
delete O[key];
_hide(O, key, val);
} else if (O[key]) {
O[key] = val;
} else {
_hide(O, key, val);
} // add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative
})(Function.prototype, TO_STRING, function toString() {
return typeof this == 'function' && this[SRC] || $toString.call(this);
});
});
var _aFunction = function (it) {
if (typeof it != 'function') throw TypeError(it + ' is not a function!');
return it;
};
var _ctx = function (fn, that, length) {
_aFunction(fn);
if (that === undefined) return fn;
switch (length) {
case 1:
return function (a) {
return fn.call(that, a);
};
case 2:
return function (a, b) {
return fn.call(that, a, b);
};
case 3:
return function (a, b, c) {
return fn.call(that, a, b, c);
};
}
return function ()
/* ...args */
{
return fn.apply(that, arguments);
};
};
var PROTOTYPE = 'prototype';
var $export = function (type, name, source) {
var IS_FORCED = type & $export.F;
var IS_GLOBAL = type & $export.G;
var IS_STATIC = type & $export.S;
var IS_PROTO = type & $export.P;
var IS_BIND = type & $export.B;
var target = IS_GLOBAL ? _global : IS_STATIC ? _global[name] || (_global[name] = {}) : (_global[name] || {})[PROTOTYPE];
var exports = IS_GLOBAL ? _core : _core[name] || (_core[name] = {});
var expProto = exports[PROTOTYPE] || (exports[PROTOTYPE] = {});
var key, own, out, exp;
if (IS_GLOBAL) source = name;
for (key in source) {
// contains in native
own = !IS_FORCED && target && target[key] !== undefined; // export native or passed
out = (own ? target : source)[key]; // bind timers to global for call from export context
exp = IS_BIND && own ? _ctx(out, _global) : IS_PROTO && typeof out == 'function' ? _ctx(Function.call, out) : out; // extend global
if (target) _redefine(target, key, out, type & $export.U); // export
if (exports[key] != out) _hide(exports, key, exp);
if (IS_PROTO && expProto[key] != out) expProto[key] = out;
}
};
_global.core = _core; // type bitmap
$export.F = 1; // forced
$export.G = 2; // global
$export.S = 4; // static
$export.P = 8; // proto
$export.B = 16; // bind
$export.W = 32; // wrap
$export.U = 64; // safe
$export.R = 128; // real proto method for `library`
var _export = $export;
var toString = {}.toString;
var _cof = function (it) {
return toString.call(it).slice(8, -1);
};
// eslint-disable-next-line no-prototype-builtins
var _iobject = Object('z').propertyIsEnumerable(0) ? Object : function (it) {
return _cof(it) == 'String' ? it.split('') : Object(it);
};
// 7.2.1 RequireObjectCoercible(argument)
var _defined = function (it) {
if (it == undefined) throw TypeError("Can't call method on " + it);
return it;
};
var _toObject = function (it) {
return Object(_defined(it));
};
// 7.1.4 ToInteger
var ceil = Math.ceil;
var floor = Math.floor;
var _toInteger = function (it) {
return isNaN(it = +it) ? 0 : (it > 0 ? floor : ceil)(it);
};
var min = Math.min;
var _toLength = function (it) {
return it > 0 ? min(_toInteger(it), 0x1fffffffffffff) : 0; // pow(2, 53) - 1 == 9007199254740991
};
var _isArray = Array.isArray || function isArray(arg) {
return _cof(arg) == 'Array';
};
var _library = false;
var _shared = createCommonjsModule(function (module) {
var SHARED = '__core-js_shared__';
var store = _global[SHARED] || (_global[SHARED] = {});
(module.exports = function (key, value) {
return store[key] || (store[key] = value !== undefined ? value : {});
})('versions', []).push({
version: _core.version,
mode: _library ? 'pure' : 'global',
copyright: '© 2019 Denis Pushkarev (zloirock.ru)'
});
});
var _wks = createCommonjsModule(function (module) {
var store = _shared('wks');
var Symbol = _global.Symbol;
var USE_SYMBOL = typeof Symbol == 'function';
var $exports = module.exports = function (name) {
return store[name] || (store[name] = USE_SYMBOL && Symbol[name] || (USE_SYMBOL ? Symbol : _uid)('Symbol.' + name));
};
$exports.store = store;
});
var SPECIES = _wks('species');
var _arraySpeciesConstructor = function (original) {
var C;
if (_isArray(original)) {
C = original.constructor; // cross-realm fallback
if (typeof C == 'function' && (C === Array || _isArray(C.prototype))) C = undefined;
if (_isObject(C)) {
C = C[SPECIES];
if (C === null) C = undefined;
}
}
return C === undefined ? Array : C;
};
var _arraySpeciesCreate = function (original, length) {
return new (_arraySpeciesConstructor(original))(length);
};
// 1 -> Array#map
// 2 -> Array#filter
// 3 -> Array#some
// 4 -> Array#every
// 5 -> Array#find
// 6 -> Array#findIndex
var _arrayMethods = function (TYPE, $create) {
var IS_MAP = TYPE == 1;
var IS_FILTER = TYPE == 2;
var IS_SOME = TYPE == 3;
var IS_EVERY = TYPE == 4;
var IS_FIND_INDEX = TYPE == 6;
var NO_HOLES = TYPE == 5 || IS_FIND_INDEX;
var create = $create || _arraySpeciesCreate;
return function ($this, callbackfn, that) {
var O = _toObject($this);
var self = _iobject(O);
var f = _ctx(callbackfn, that, 3);
var length = _toLength(self.length);
var index = 0;
var result = IS_MAP ? create($this, length) : IS_FILTER ? create($this, 0) : undefined;
var val, res;
for (; length > index; index++) if (NO_HOLES || index in self) {
val = self[index];
res = f(val, index, O);
if (TYPE) {
if (IS_MAP) result[index] = res; // map
else if (res) switch (TYPE) {
case 3:
return true;
// some
case 5:
return val;
// find
case 6:
return index;
// findIndex
case 2:
result.push(val);
// filter
} else if (IS_EVERY) return false; // every
}
}
return IS_FIND_INDEX ? -1 : IS_SOME || IS_EVERY ? IS_EVERY : result;
};
};
var UNSCOPABLES = _wks('unscopables');
var ArrayProto = Array.prototype;
if (ArrayProto[UNSCOPABLES] == undefined) _hide(ArrayProto, UNSCOPABLES, {});
var _addToUnscopables = function (key) {
ArrayProto[UNSCOPABLES][key] = true;
};
var $find = _arrayMethods(6);
var KEY = 'findIndex';
var forced = true; // Shouldn't skip holes
if (KEY in []) Array(1)[KEY](function () {
forced = false;
});
_export(_export.P + _export.F * forced, 'Array', {
findIndex: function findIndex(callbackfn
/* , that = undefined */
) {
return $find(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
}
});
_addToUnscopables(KEY);
var dP$1 = _objectDp.f;
var FProto = Function.prototype;
var nameRE = /^\s*function ([^ (]*)/;
var NAME = 'name'; // 19.2.4.2 name
NAME in FProto || _descriptors && dP$1(FProto, NAME, {
configurable: true,
get: function () {
try {
return ('' + this).match(nameRE)[1];
} catch (e) {
return '';
}
}
});
var _iterStep = function (done, value) {
return {
value: value,
done: !!done
};
};
var _iterators = {};
var _toIobject = function (it) {
return _iobject(_defined(it));
};
var max = Math.max;
var min$1 = Math.min;
var _toAbsoluteIndex = function (index, length) {
index = _toInteger(index);
return index < 0 ? max(index + length, 0) : min$1(index, length);
};
// true -> Array#includes
var _arrayIncludes = function (IS_INCLUDES) {
return function ($this, el, fromIndex) {
var O = _toIobject($this);
var length = _toLength(O.length);
var index = _toAbsoluteIndex(fromIndex, length);
var value; // Array#includes uses SameValueZero equality algorithm
// eslint-disable-next-line no-self-compare
if (IS_INCLUDES && el != el) while (length > index) {
value = O[index++]; // eslint-disable-next-line no-self-compare
if (value != value) return true; // Array#indexOf ignores holes, Array#includes - not
} else for (; length > index; index++) if (IS_INCLUDES || index in O) {
if (O[index] === el) return IS_INCLUDES || index || 0;
}
return !IS_INCLUDES && -1;
};
};
var shared = _shared('keys');
var _sharedKey = function (key) {
return shared[key] || (shared[key] = _uid(key));
};
var arrayIndexOf = _arrayIncludes(false);
var IE_PROTO = _sharedKey('IE_PROTO');
var _objectKeysInternal = function (object, names) {
var O = _toIobject(object);
var i = 0;
var result = [];
var key;
for (key in O) if (key != IE_PROTO) _has(O, key) && result.push(key); // Don't enum bug & hidden keys
while (names.length > i) if (_has(O, key = names[i++])) {
~arrayIndexOf(result, key) || result.push(key);
}
return result;
};
// IE 8- don't enum bug keys
var _enumBugKeys = 'constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf'.split(',');
var _objectKeys = Object.keys || function keys(O) {
return _objectKeysInternal(O, _enumBugKeys);
};
var _objectDps = _descriptors ? Object.defineProperties : function defineProperties(O, Properties) {
_anObject(O);
var keys = _objectKeys(Properties);
var length = keys.length;
var i = 0;
var P;
while (length > i) _objectDp.f(O, P = keys[i++], Properties[P]);
return O;
};
var document$2 = _global.document;
var _html = document$2 && document$2.documentElement;
var IE_PROTO$1 = _sharedKey('IE_PROTO');
var Empty = function () {
/* empty */
};
var PROTOTYPE$1 = 'prototype'; // Create object with fake `null` prototype: use iframe Object with cleared prototype
var createDict = function () {
// Thrash, waste and sodomy: IE GC bug
var iframe = _domCreate('iframe');
var i = _enumBugKeys.length;
var lt = '<';
var gt = '>';
var iframeDocument;
iframe.style.display = 'none';
_html.appendChild(iframe);
iframe.src = 'javascript:'; // eslint-disable-line no-script-url
// createDict = iframe.contentWindow.Object;
// html.removeChild(iframe);
iframeDocument = iframe.contentWindow.document;
iframeDocument.open();
iframeDocument.write(lt + 'script' + gt + 'document.F=Object' + lt + '/script' + gt);
iframeDocument.close();
createDict = iframeDocument.F;
while (i--) delete createDict[PROTOTYPE$1][_enumBugKeys[i]];
return createDict();
};
var _objectCreate = Object.create || function create(O, Properties) {
var result;
if (O !== null) {
Empty[PROTOTYPE$1] = _anObject(O);
result = new Empty();
Empty[PROTOTYPE$1] = null; // add "__proto__" for Object.getPrototypeOf polyfill
result[IE_PROTO$1] = O;
} else result = createDict();
return Properties === undefined ? result : _objectDps(result, Properties);
};
var def = _objectDp.f;
var TAG = _wks('toStringTag');
var _setToStringTag = function (it, tag, stat) {
if (it && !_has(it = stat ? it : it.prototype, TAG)) def(it, TAG, {
configurable: true,
value: tag
});
};
var IteratorPrototype = {}; // 25.1.2.1.1 %IteratorPrototype%[@@iterator]()
_hide(IteratorPrototype, _wks('iterator'), function () {
return this;
});
var _iterCreate = function (Constructor, NAME, next) {
Constructor.prototype = _objectCreate(IteratorPrototype, {
next: _propertyDesc(1, next)
});
_setToStringTag(Constructor, NAME + ' Iterator');
};
var IE_PROTO$2 = _sharedKey('IE_PROTO');
var ObjectProto = Object.prototype;
var _objectGpo = Object.getPrototypeOf || function (O) {
O = _toObject(O);
if (_has(O, IE_PROTO$2)) return O[IE_PROTO$2];
if (typeof O.constructor == 'function' && O instanceof O.constructor) {
return O.constructor.prototype;
}
return O instanceof Object ? ObjectProto : null;
};
var ITERATOR = _wks('iterator');
var BUGGY = !([].keys && 'next' in [].keys()); // Safari has buggy iterators w/o `next`
var FF_ITERATOR = '@@iterator';
var KEYS = 'keys';
var VALUES = 'values';
var returnThis = function () {
return this;
};
var _iterDefine = function (Base, NAME, Constructor, next, DEFAULT, IS_SET, FORCED) {
_iterCreate(Constructor, NAME, next);
var getMethod = function (kind) {
if (!BUGGY && kind in proto) return proto[kind];
switch (kind) {
case KEYS:
return function keys() {
return new Constructor(this, kind);
};
case VALUES:
return function values() {
return new Constructor(this, kind);
};
}
return function entries() {
return new Constructor(this, kind);
};
};
var TAG = NAME + ' Iterator';
var DEF_VALUES = DEFAULT == VALUES;
var VALUES_BUG = false;
var proto = Base.prototype;
var $native = proto[ITERATOR] || proto[FF_ITERATOR] || DEFAULT && proto[DEFAULT];
var $default = $native || getMethod(DEFAULT);
var $entries = DEFAULT ? !DEF_VALUES ? $default : getMethod('entries') : undefined;
var $anyNative = NAME == 'Array' ? proto.entries || $native : $native;
var methods, key, IteratorPrototype; // Fix native
if ($anyNative) {
IteratorPrototype = _objectGpo($anyNative.call(new Base()));
if (IteratorPrototype !== Object.prototype && IteratorPrototype.next) {
// Set @@toStringTag to native iterators
_setToStringTag(IteratorPrototype, TAG, true); // fix for some old engines
if (!_library && typeof IteratorPrototype[ITERATOR] != 'function') _hide(IteratorPrototype, ITERATOR, returnThis);
}
} // fix Array#{values, @@iterator}.name in V8 / FF
if (DEF_VALUES && $native && $native.name !== VALUES) {
VALUES_BUG = true;
$default = function values() {
return $native.call(this);
};
} // Define iterator
if ((!_library || FORCED) && (BUGGY || VALUES_BUG || !proto[ITERATOR])) {
_hide(proto, ITERATOR, $default);
} // Plug for library
_iterators[NAME] = $default;
_iterators[TAG] = returnThis;
if (DEFAULT) {
methods = {
values: DEF_VALUES ? $default : getMethod(VALUES),
keys: IS_SET ? $default : getMethod(KEYS),
entries: $entries
};
if (FORCED) for (key in methods) {
if (!(key in proto)) _redefine(proto, key, methods[key]);
} else _export(_export.P + _export.F * (BUGGY || VALUES_BUG), NAME, methods);
}
return methods;
};
// 22.1.3.13 Array.prototype.keys()
// 22.1.3.29 Array.prototype.values()
// 22.1.3.30 Array.prototype[@@iterator]()
var es6_array_iterator = _iterDefine(Array, 'Array', function (iterated, kind) {
this._t = _toIobject(iterated); // target
this._i = 0; // next index
this._k = kind; // kind
// 22.1.5.2.1 %ArrayIteratorPrototype%.next()
}, function () {
var O = this._t;
var kind = this._k;
var index = this._i++;
if (!O || index >= O.length) {
this._t = undefined;
return _iterStep(1);
}
if (kind == 'keys') return _iterStep(0, index);
if (kind == 'values') return _iterStep(0, O[index]);
return _iterStep(0, [index, O[index]]);
}, 'values'); // argumentsList[@@iterator] is %ArrayProto_values% (9.4.4.6, 9.4.4.7)
_iterators.Arguments = _iterators.Array;
_addToUnscopables('keys');
_addToUnscopables('values');
_addToUnscopables('entries');
var ITERATOR$1 = _wks('iterator');
var TO_STRING_TAG = _wks('toStringTag');
var ArrayValues = _iterators.Array;
var DOMIterables = {
CSSRuleList: true,
// TODO: Not spec compliant, should be false.
CSSStyleDeclaration: false,
CSSValueList: false,
ClientRectList: false,
DOMRectList: false,
DOMStringList: false,
DOMTokenList: true,
DataTransferItemList: false,
FileList: false,
HTMLAllCollection: false,
HTMLCollection: false,
HTMLFormElement: false,
HTMLSelectElement: false,
MediaList: true,
// TODO: Not spec compliant, should be false.
MimeTypeArray: false,
NamedNodeMap: false,
NodeList: true,
PaintRequestList: false,
Plugin: false,
PluginArray: false,
SVGLengthList: false,
SVGNumberList: false,
SVGPathSegList: false,
SVGPointList: false,
SVGStringList: false,
SVGTransformList: false,
SourceBufferList: false,
StyleSheetList: true,
// TODO: Not spec compliant, should be false.
TextTrackCueList: false,
TextTrackList: false,
TouchList: false
};
for (var collections = _objectKeys(DOMIterables), i = 0; i < collections.length; i++) {
var NAME$1 = collections[i];
var explicit = DOMIterables[NAME$1];
var Collection = _global[NAME$1];
var proto = Collection && Collection.prototype;
var key;
if (proto) {
if (!proto[ITERATOR$1]) _hide(proto, ITERATOR$1, ArrayValues);
if (!proto[TO_STRING_TAG]) _hide(proto, TO_STRING_TAG, NAME$1);
_iterators[NAME$1] = ArrayValues;
if (explicit) for (key in es6_array_iterator) if (!proto[key]) _redefine(proto, key, es6_array_iterator[key], true);
}
}
// false -> String#codePointAt
var _stringAt = function (TO_STRING) {
return function (that, pos) {
var s = String(_defined(that));
var i = _toInteger(pos);
var l = s.length;
var a, b;
if (i < 0 || i >= l) return TO_STRING ? '' : undefined;
a = s.charCodeAt(i);
return a < 0xd800 || a > 0xdbff || i + 1 === l || (b = s.charCodeAt(i + 1)) < 0xdc00 || b > 0xdfff ? TO_STRING ? s.charAt(i) : a : TO_STRING ? s.slice(i, i + 2) : (a - 0xd800 << 10) + (b - 0xdc00) + 0x10000;
};
};
var at = _stringAt(true); // `AdvanceStringIndex` abstract operation
// https://tc39.github.io/ecma262/#sec-advancestringindex
var _advanceStringIndex = function (S, index, unicode) {
return index + (unicode ? at(S, index).length : 1);
};
var TAG$1 = _wks('toStringTag'); // ES3 wrong here
var ARG = _cof(function () {
return arguments;
}()) == 'Arguments'; // fallback for IE11 Script Access Denied error
var tryGet = function (it, key) {
try {
return it[key];
} catch (e) {
/* empty */
}
};
var _classof = function (it) {
var O, T, B;
return it === undefined ? 'Undefined' : it === null ? 'Null' // @@toStringTag case
: typeof (T = tryGet(O = Object(it), TAG$1)) == 'string' ? T // builtinTag case
: ARG ? _cof(O) // ES3 arguments fallback
: (B = _cof(O)) == 'Object' && typeof O.callee == 'function' ? 'Arguments' : B;
};
var builtinExec = RegExp.prototype.exec; // `RegExpExec` abstract operation
// https://tc39.github.io/ecma262/#sec-regexpexec
var _regexpExecAbstract = function (R, S) {
var exec = R.exec;
if (typeof exec === 'function') {
var result = exec.call(R, S);
if (typeof result !== 'object') {
throw new TypeError('RegExp exec method returned something other than an Object or null');
}
return result;
}
if (_classof(R) !== 'RegExp') {
throw new TypeError('RegExp#exec called on incompatible receiver');
}
return builtinExec.call(R, S);
};
var _flags = function () {
var that = _anObject(this);
var result = '';
if (that.global) result += 'g';
if (that.ignoreCase) result += 'i';
if (that.multiline) result += 'm';
if (that.unicode) result += 'u';
if (that.sticky) result += 'y';
return result;
};
var nativeExec = RegExp.prototype.exec; // This always refers to the native implementation, because the
// String#replace polyfill uses ./fix-regexp-well-known-symbol-logic.js,
// which loads this file before patching the method.
var nativeReplace = String.prototype.replace;
var patchedExec = nativeExec;
var LAST_INDEX = 'lastIndex';
var UPDATES_LAST_INDEX_WRONG = function () {
var re1 = /a/,
re2 = /b*/g;
nativeExec.call(re1, 'a');
nativeExec.call(re2, 'a');
return re1[LAST_INDEX] !== 0 || re2[LAST_INDEX] !== 0;
}(); // nonparticipating capturing group, copied from es5-shim's String#split patch.
var NPCG_INCLUDED = /()??/.exec('')[1] !== undefined;
var PATCH = UPDATES_LAST_INDEX_WRONG || NPCG_INCLUDED;
if (PATCH) {
patchedExec = function exec(str) {
var re = this;
var lastIndex, reCopy, match, i;
if (NPCG_INCLUDED) {
reCopy = new RegExp('^' + re.source + '$(?!\\s)', _flags.call(re));
}
if (UPDATES_LAST_INDEX_WRONG) lastIndex = re[LAST_INDEX];
match = nativeExec.call(re, str);
if (UPDATES_LAST_INDEX_WRONG && match) {
re[LAST_INDEX] = re.global ? match.index + match[0].length : lastIndex;
}
if (NPCG_INCLUDED && match && match.length > 1) {
// Fix browsers whose `exec` methods don't consistently return `undefined`
// for NPCG, like IE8. NOTE: This doesn' work for /(.?)?/
// eslint-disable-next-line no-loop-func
nativeReplace.call(match[0], reCopy, function () {
for (i = 1; i < arguments.length - 2; i++) {
if (arguments[i] === undefined) match[i] = undefined;
}
});
}
return match;
};
}
var _regexpExec = patchedExec;
_export({
target: 'RegExp',
proto: true,
forced: _regexpExec !== /./.exec
}, {
exec: _regexpExec
});
var SPECIES$1 = _wks('species');
var REPLACE_SUPPORTS_NAMED_GROUPS = !_fails(function () {
// #replace needs built-in support for named groups.
// #match works fine because it just return the exec results, even if it has
// a "grops" property.
var re = /./;
re.exec = function () {
var result = [];
result.groups = {
a: '7'
};
return result;
};
return ''.replace(re, '$<a>') !== '7';
});
var SPLIT_WORKS_WITH_OVERWRITTEN_EXEC = function () {
// Chrome 51 has a buggy "split" implementation when RegExp#exec !== nativeExec
var re = /(?:)/;
var originalExec = re.exec;
re.exec = function () {
return originalExec.apply(this, arguments);
};
var result = 'ab'.split(re);
return result.length === 2 && result[0] === 'a' && result[1] === 'b';
}();
var _fixReWks = function (KEY, length, exec) {
var SYMBOL = _wks(KEY);
var DELEGATES_TO_SYMBOL = !_fails(function () {
// String methods call symbol-named RegEp methods
var O = {};
O[SYMBOL] = function () {
return 7;
};
return ''[KEY](O) != 7;
});
var DELEGATES_TO_EXEC = DELEGATES_TO_SYMBOL ? !_fails(function () {
// Symbol-named RegExp methods call .exec
var execCalled = false;
var re = /a/;
re.exec = function () {
execCalled = true;
return null;
};
if (KEY === 'split') {
// RegExp[@@split] doesn't call the regex's exec method, but first creates
// a new one. We need to return the patched regex when creating the new one.
re.constructor = {};
re.constructor[SPECIES$1] = function () {
return re;
};
}
re[SYMBOL]('');
return !execCalled;
}) : undefined;
if (!DELEGATES_TO_SYMBOL || !DELEGATES_TO_EXEC || KEY === 'replace' && !REPLACE_SUPPORTS_NAMED_GROUPS || KEY === 'split' && !SPLIT_WORKS_WITH_OVERWRITTEN_EXEC) {
var nativeRegExpMethod = /./[SYMBOL];
var fns = exec(_defined, SYMBOL, ''[KEY], function maybeCallNative(nativeMethod, regexp, str, arg2, forceStringMethod) {
if (regexp.exec === _regexpExec) {
if (DELEGATES_TO_SYMBOL && !forceStringMethod) {
// The native String method already delegates to @@method (this
// polyfilled function), leasing to infinite recursion.
// We avoid it by directly calling the native @@method method.
return {
done: true,
value: nativeRegExpMethod.call(regexp, str, arg2)
};
}
return {
done: true,
value: nativeMethod.call(str, regexp, arg2)
};
}
return {
done: false
};
});
var strfn = fns[0];
var rxfn = fns[1];
_redefine(String.prototype, KEY, strfn);
_hide(RegExp.prototype, SYMBOL, length == 2 // 21.2.5.8 RegExp.prototype[@@replace](string, replaceValue)
// 21.2.5.11 RegExp.prototype[@@split](string, limit)
? function (string, arg) {
return rxfn.call(string, this, arg);
} // 21.2.5.6 RegExp.prototype[@@match](string)
// 21.2.5.9 RegExp.prototype[@@search](string)
: function (string) {
return rxfn.call(string, this);
});
}
};
var max$1 = Math.max;
var min$2 = Math.min;
var floor$1 = Math.floor;
var SUBSTITUTION_SYMBOLS = /\$([$&`']|\d\d?|<[^>]*>)/g;
var SUBSTITUTION_SYMBOLS_NO_NAMED = /\$([$&`']|\d\d?)/g;
var maybeToString = function (it) {
return it === undefined ? it : String(it);
}; // @@replace logic
_fixReWks('replace', 2, function (defined, REPLACE, $replace, maybeCallNative) {
return [// `String.prototype.replace` method
// https://tc39.github.io/ecma262/#sec-string.prototype.replace
function replace(searchValue, replaceValue) {
var O = defined(this);
var fn = searchValue == undefined ? undefined : searchValue[REPLACE];
return fn !== undefined ? fn.call(searchValue, O, replaceValue) : $replace.call(String(O), searchValue, replaceValue);
}, // `RegExp.prototype[@@replace]` method
// https://tc39.github.io/ecma262/#sec-regexp.prototype-@@replace
function (regexp, replaceValue) {
var res = maybeCallNative($replace, regexp, this, replaceValue);
if (res.done) return res.value;
var rx = _anObject(regexp);
var S = String(this);
var functionalReplace = typeof replaceValue === 'function';
if (!functionalReplace) replaceValue = String(replaceValue);
var global = rx.global;
if (global) {
var fullUnicode = rx.unicode;
rx.lastIndex = 0;
}
var results = [];
while (true) {
var result = _regexpExecAbstract(rx, S);
if (result === null) break;
results.push(result);
if (!global) break;
var matchStr = String(result[0]);
if (matchStr === '') rx.lastIndex = _advanceStringIndex(S, _toLength(rx.lastIndex), fullUnicode);
}
var accumulatedResult = '';
var nextSourcePosition = 0;
for (var i = 0; i < results.length; i++) {
result = results[i];
var matched = String(result[0]);
var position = max$1(min$2(_toInteger(result.index), S.length), 0);
var captures = []; // NOTE: This is equivalent to
// captures = result.slice(1).map(maybeToString)
// but for some reason `nativeSlice.call(result, 1, result.length)` (called in
// the slice polyfill when slicing native arrays) "doesn't work" in safari 9 and
// causes a crash (https://pastebin.com/N21QzeQA) when trying to debug it.
for (var j = 1; j < result.length; j++) captures.push(maybeToString(result[j]));
var namedCaptures = result.groups;
if (functionalReplace) {
var replacerArgs = [matched].concat(captures, position, S);
if (namedCaptures !== undefined) replacerArgs.push(namedCaptures);
var replacement = String(replaceValue.apply(undefined, replacerArgs));
} else {
replacement = getSubstitution(matched, S, position, captures, namedCaptures, replaceValue);
}
if (position >= nextSourcePosition) {
accumulatedResult += S.slice(nextSourcePosition, position) + replacement;
nextSourcePosition = position + matched.length;
}
}
return accumulatedResult + S.slice(nextSourcePosition);
}]; // https://tc39.github.io/ecma262/#sec-getsubstitution
function getSubstitution(matched, str, position, captures, namedCaptures, replacement) {
var tailPos = position + matched.length;
var m = captures.length;
var symbols = SUBSTITUTION_SYMBOLS_NO_NAMED;
if (namedCaptures !== undefined) {
namedCaptures = _toObject(namedCaptures);
symbols = SUBSTITUTION_SYMBOLS;
}
return $replace.call(replacement, symbols, function (match, ch) {
var capture;
switch (ch.charAt(0)) {
case '$':
return '$';
case '&':
return matched;
case '`':
return str.slice(0, position);
case "'":
return str.slice(tailPos);
case '<':
capture = namedCaptures[ch.slice(1, -1)];
break;
default:
// \d\d?
var n = +ch;
if (n === 0) return match;
if (n > m) {
var f = floor$1(n / 10);
if (f === 0) return match;
if (f <= m) return captures[f - 1] === undefined ? ch.charAt(1) : captures[f - 1] + ch.charAt(1);
return match;
}
capture = captures[n - 1];
}
return capture === undefined ? '' : capture;
});
}
});
function _typeof(obj) {
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
_typeof = function (obj) {
return typeof obj;
};
} else {
_typeof = function (obj) {
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
};
}
return _typeof(obj);
}
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
}
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;
}
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 _inherits(subClass, superClass) {
if (typeof superClass !== "function" && superClass !== null) {
throw new TypeError("Super expression must either be null or a function");
}
subClass.prototype = Object.create(superClass && superClass.prototype, {
constructor: {
value: subClass,
writable: true,
configurable: true
}
});
if (superClass) _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 _assertThisInitialized(self) {
if (self === void 0) {
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
}
return self;
}
function _possibleConstructorReturn(self, call) {
if (call && (typeof call === "object" || typeof call === "function")) {
return call;
}
return _assertThisInitialized(self);
}
if (_descriptors && /./g.flags != 'g') _objectDp.f(RegExp.prototype, 'flags', {
configurable: true,
get: _flags
});
var TO_STRING = 'toString';
var $toString = /./[TO_STRING];
var define = function (fn) {
_redefine(RegExp.prototype, TO_STRING, fn, true);
}; // 21.2.5.14 RegExp.prototype.toString()
if (_fails(function () {
return $toString.call({
source: 'a',
flags: 'b'
}) != '/a/b';
})) {
define(function toString() {
var R = _anObject(this);
return '/'.concat(R.source, '/', 'flags' in R ? R.flags : !_descriptors && R instanceof RegExp ? _flags.call(R) : undefined);
}); // FF44- RegExp#toString has a wrong name
} else if ($toString.name != TO_STRING) {
define(function toString() {
return $toString.call(this);
});
}
var $find$1 = _arrayMethods(5);
var KEY$1 = 'find';
var forced$1 = true; // Shouldn't skip holes
if (KEY$1 in []) Array(1)[KEY$1](function () {
forced$1 = false;
});
_export(_export.P + _export.F * forced$1, 'Array', {
find: function find(callbackfn
/* , that = undefined */
) {
return $find$1(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
}
});
_addToUnscopables(KEY$1);
var f$1 = Object.getOwnPropertySymbols;
var _objectGops = {
f: f$1
};
var f$2 = {}.propertyIsEnumerable;
var _objectPie = {
f: f$2
};
var $assign = Object.assign; // should work with symbols and should have deterministic property order (V8 bug)
var _objectAssign = !$assign || _fails(function () {
var A = {};
var B = {}; // eslint-disable-next-line no-undef
var S = Symbol();
var K = 'abcdefghijklmnopqrst';
A[S] = 7;
K.split('').forEach(function (k) {
B[k] = k;
});
return $assign({}, A)[S] != 7 || Object.keys($assign({}, B)).join('') != K;
}) ? function assign(target, source) {
// eslint-disable-line no-unused-vars
var T = _toObject(target);
var aLen = arguments.length;
var index = 1;
var getSymbols = _objectGops.f;
var isEnum = _objectPie.f;
while (aLen > index) {
var S = _iobject(arguments[index++]);
var keys = getSymbols ? _objectKeys(S).concat(getSymbols(S)) : _objectKeys(S);
var length = keys.length;
var j = 0;
var key;
while (length > j) if (isEnum.call(S, key = keys[j++])) T[key] = S[key];
}
return T;
} : $assign;
_export(_export.S + _export.F, 'Object', {
assign: _objectAssign
});
var d = document;
var DomComponent =
/*#__PURE__*/
function () {
function DomComponent(element) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var defaults = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
_classCallCheck(this, DomComponent);
this.options = Object.assign({}, defaults, options);
this._events = [];
this.dom = {
el: this._setElement(element)
};
}
/**
* Bind a (delegated) event
* @param {String} event
* @param {Function} fn
* @param {HTMLElement|Document} el
* @return DomComponent
*/
_createClass(DomComponent, [{
key: "on",
value: function on(event, fn) {
var el = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
(el || this.dom.el).addEventListener(event, fn = fn.bind(this), true);
this._events.push({
name: event,
fn: fn,
el: el
});
return this;
}
/**
* Return the main wrapping element
* @return {Element}
*/
}, {
key: "getElement",
value: function getElement() {
return this.dom.el;
}
/**
* Unbind all events and nullify references
* @return void
*/
}, {
key: "remove",
value: function remove() {
var _this = this;
this._events = this._events.filter(function (event) {
return (event.el || _this.dom.el).removeEventListener(event.name, event.fn, true);
});
this.dom.el.parentNode.removeChild(this.dom.el);
this.dom = this.options = null;
}
/**
* Query the element in the DOM if its a string
* @param {Element|String} el
* @return {Element|null}
* @protected
*/
}, {
key: "_setElement",
value: function _setElement(el) {
if (!el && !el.nodeType && typeof el !== 'string') {
throw new Error('Wrong element type provided!');
}
if (el.nodeType) return el;
return (this.options.parent || d).querySelector(el);
}
/**
* Communicate changes
* @param {String} name
* @param {Object|null} detail
* @protected
*/
}, {
key: "_trigger",
value: function _trigger(name) {
var detail = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
var event;
if (typeof CustomEvent === 'function') {
event = new CustomEvent(name, {
detail: detail,
bubbles: true,
cancelable: true
});
} else {
event = d.createEvent('Event');
event.initEvent(name, true, true);
}
this.dom.el.dispatchEvent(event);
}
}]);
return DomComponent;
}();
var defaults = {
parent: null,
items: [],
current: null,
allowAdd: true,
proposal: 'Add {X} to the list?',
notFound: '{X} not present in the list',
allowRemove: true,
removalIcon: '&times;',
placeHolder: 'Type to search',
sort: true,
order: 'desc',
maxHeight: 0,
onDelete: null,
onCreate: null,
valueKey: 'value',
textKey: 'value'
};
var d$1 = document;
var SelectInput =
/*#__PURE__*/
function (_DomHelper) {
_inherits(SelectInput, _DomHelper);
function SelectInput(element) {
var _this;
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
_classCallCheck(this, SelectInput);
_this = _possibleConstructorReturn(this, _getPrototypeOf(SelectInput).call(this, element, options, defaults));
var current = options.current ? _this._convertItem(options.current) : null;
_this.options.items = _this._convertItems(options.items);
_this.current = current ? _this.findItem(_this._getItemProp(current)) : null; // search result caching
_this.__found = null;
if (_this.options.sort) _this._sortItems();
_this._renderInit();
_this._bindEvents();
if (current) {
_this._setInputValue(current);
}
return _this;
}
/**
* Bind all (delegated) DOM events
* @private
*/
_createClass(SelectInput, [{
key: "_bindEvents",
value: function _bindEvents() {
var _this2 = this;
var closeOnEvent = function closeOnEvent(e) {
if (e.key === 'Escape' || e.keyCode === 27 || !_this2.dom.el.contains(e.target)) {
_this2.toggle(false);
}
};
this.on('input', this._search);
this.on('click', this._handleClick);
this.on('keyup', this._handleKey);
this.on('focusin', function () {
return _this2._renderListItems().toggle(true);
}, this.dom.input); // Close the list on `Escape` or on a click outside the main element
this.on('keyup', closeOnEvent, d$1);
this.on('click', closeOnEvent, d$1);
}
/**
* Store the deletion callback
* @param {Function} fn
* @return SelectInput
*/
}, {
key: "onDelete",
value: function onDelete(fn) {
this.options.onDelete = fn;
return this;
}
/**
* Store the creation callback
* @param {Function} fn
* @return SelectInput
*/
}, {
key: "onCreate",
value: function onCreate(fn) {
this.options.onCreate = fn;
return this;
}
/**
* Show/hide the dropdown
* @param {Boolean} show
* @return DomHelper
*/
}, {
key: "toggle",
value: function toggle() {
var show = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
this.dom.el.firstElementChild.classList[show ? 'remove' : 'add']('si-hide');
if (!show) this.dom.input.blur();
return this;
}
/**
* Get all items in the list
* @return {Object[]}
*/
}, {
key: "getItems",
value: function getItems() {
return this.options.items;
}
/**
* Return the current field value object
* @return {{value: String|Number}|null}
*/
}, {
key: "getCurrent",
value: function getCurrent() {
var current = Object.assign({}, this.current);
delete current._lc_value;
delete current._lc_text;
return current;
}
/**
* Clear the current value
* @return void
* @private
*/
}, {
key: "clearCurrent",
value: function clearCurrent() {
this.current = null;
this.dom.input.value = '';
this._clearSelected();
}
/**
* Find an item in the list
* @param {EventTarget|HTMLElement|String|Number} value
* @return {{}}
*/
}, {
key: "findItem",
value: function findItem(value) {
var _this3 = this;
value = value.nodeName ? value.dataset.value : value;
return this.options.items.find(function (item) {
return _this3._getItemProp(item) === value;
});
}
/**
* Set the current value by its string
* @param {String|undefined} value
* @return SelectInput
*/
}, {
key: "setCurrent",
value: function setCurrent(value) {
this._setCurrent(value ? this.findItem(value) : null);
return this;
}
/**
* Set the current value of the field
* @param {EventTarget|null} el
* @param {Object|null} item
* @return SelectInput
* @private
*/
}, {
key: "_setCurrent",
value: function _setCurrent(item) {
var el = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
this._setInputValue(item);
if (item) {
this.current = item;
this._setSelected(item, el);
} else {
this.current = null;
this._clearSelected();
}
return this;
}
/**
* Set the HTML input field
* @param {Object} item
* @return void
* @private
*/
}, {
key: "_setInputValue",
value: function _setInputValue(item) {
this.dom.input.value = item ? this._getItemProp(item, 'text').toString() : '';
}
/**
* Updated selected item in the html list
* @param {Object} item
* @param {EventTarget|HTMLElement|null} el
* @private
*/
}, {
key: "_setSelected",
value: function _setSelected(item) {
var el = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
this._clearSelected();
el = el ? el : this.dom.list.querySelector("li[data-value=\"".concat(this._getItemProp(item), "\"]"));
if (el) el.classList.add('si-current');
}
/**
* Remove the classname of current `<li>`
* @private
*/
}, {
key: "_clearSelected",
value: function _clearSelected() {
var current = this.dom.list.querySelector('.si-current');
if (current) current.classList.remove('si-current');
}
/**
* Make an array of objects
* @param {Array} items
* @return {Object[]}
* @private
*/
}, {
key: "_convertItems",
value: function _convertItems() {
var _this4 = this;
var items = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
return items.map(function (item) {
return _this4._convertItem(item);
});
}
/**
* Normalize an item as an usable object
* @param {String|Number|{value: String|Number, _lc_value: String, _lc_text: String}} item
* @return {{value: String|Number, _lc_value: String, _lc_text: String}}
* @private
*/
}, {
key: "_convertItem",
value: function _convertItem(item) {
var _ref;
var opt = this.options;
item = _typeof(item) !== 'object' ? (_ref = {}, _defineProperty(_ref, opt.valueKey, item), _defineProperty(_ref, opt.textKey, item), _ref) : item;
item._lc_value = this._makeSearchString(this._getItemProp(item));
item._lc_text = this._makeSearchString(this._getItemProp(item, 'text'));
return item;
}
/**
* Format all searchable strings
* @param {String} value
* @return {String}
* @private
*/
}, {
key: "_makeSearchString",
value: function _makeSearchString(value) {
return value.toString().toLowerCase().replace(/\s+/g, '-');
}
/**
* Return the value of one of the custom named properties
* @param {Object} item
* @param {String} prop
* @return {String|Number}
* @private
*/
}, {
key: "_getItemProp",
value: function _getItemProp(item) {
var prop = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'value';
return item ? item[this.options["".concat(prop, "Key")]] : null;
}
/**
* Create the HTML upon instantiation
* @return {Node}
* @private
*/
}, {
key: "_renderInit",
value: function _renderInit() {
var wrap = d$1.createElement('div');
wrap.className = 'si-wrap si-hide';
this.dom.input = wrap.appendChild(this._renderInput()).firstChild;
this.dom.list = wrap.appendChild(this._renderList()).firstChild;
return this.dom.el.appendChild(wrap);
}
/**
* Create the input element
* @return {HTMLDivElement}
* @private
*/
}, {
key: "_renderInput",
value: function _renderInput() {
var wrap = d$1.createElement('div'),
el = d$1.createElement('input');
wrap.className = 'si-input';
el.type = 'text';
el.autocomplete = 'false';
el.spellcheck = false;
el.placeholder = this.options.placeHolder;
wrap.appendChild(el);
return wrap;
}
/**
* Create the list element
* @return {HTMLDivElement}
* @private
*/
}, {
key: "_renderList",
value: function _renderList() {
var wrap = d$1.createElement('div'),
el = d$1.createElement('ul'),
maxHeight = this.options.maxHeight;
wrap.className = 'si-list';
if (maxHeight) wrap.style.maxHeight = maxHeight + 'px';
wrap.appendChild(el);
return wrap;
}
/**
* Create the list items
* @param {Object[]} items
* @return {String}
* @private
*/
}, {
key: "_createListItems",
value: function _createListItems() {
var _this5 = this;
var items = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
var list = '',
opt = this.options,
currentValue = this._getItemProp(this.current),
selected = '',
button = opt.allowRemove ? this._createRemovalButton() : '',
value = '',
text = '';
items.forEach(function (item) {
value = _this5._getItemProp(item);
text = _this5._getItemProp(item, 'text');
selected = currentValue && value === currentValue ? ' si-current' : '';
list += "<li class=\"si-item".concat(selected, "\" data-value=\"").concat(value, "\">").concat(text + button, "</li>");
});
return list;
}
/**
* Insert the set of li's in the DOM
* @param html
* @return SelectInput
* @private
*/
}, {
key: "_renderListItems",
value: function _renderListItems() {
var html = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
this.dom.list.innerHTML = html || this._createListItems(this.options.items);
return this;
}
/**
* Item removal button template
* @return {String}
* @private
*/
}, {
key: "_createRemovalButton",
value: function _createRemovalButton() {
return "<button type=\"button\" class=\"si-removal\">".concat(this.options.removalIcon, "</button>");
}
/**
* Search and update the list upon typing
* @param {KeyboardEvent} e
* @private
*/
}, {
key: "_search",
value: function _search(e) {
var options = this.options,
term = e.target.value,
termLc = this._makeSearchString(term),
list = this._searchItem(termLc),
html = list || options.allowAdd ? this._createListItems(list) : '',
first = list[0],
len = list.length;
if (len === 1) {
this.__found = first;
}
if (len !== 1 || !term) {
this.__found = null;
}
if (options.allowAdd && term && (!first || termLc !== first._lc_text && termLc !== first._lc_value)) {
html += this._proposeItem(term);
} else if (!options.allowAdd) {
html += this._notFoundItem(term);
}
this._renderListItems(html);
}
/**
* Filter the list of available items
* @param {String} str
* @return {[]}
* @private
*/
}, {
key: "_searchItem",
value: function _searchItem(str) {
return this.options.items.filter(function (item) {
return item._lc_value.indexOf(str) !== -1 || item._lc_text.indexOf(str) !== -1;
});
}
/**
* Create the item creation list item
* @param {String} term
* @return {String}
* @private
*/
}, {
key: "_proposeItem",
value: function _proposeItem(term) {
var proposal = this.options.proposal.replace('{X}', "<span>".concat(term, "</span>"));
return "<li class=\"si-item si-append si-proposal\" data-term=\"".concat(term, "\">").concat(proposal, "</li>");
}
/**
* Create a 'not found' message as a list item
* @param {String} term
* @return {String}
* @private
*/
}, {
key: "_notFoundItem",
value: function _notFoundItem(term) {
var txt = this.options.notFound.replace('{X}', "<span>".concat(term, "</span>"));
return "<li class=\"si-item si-append si-not-found\">".concat(txt, "</li>");
}
/**
* Decide what to do when user clicks inside the component
* @param {MouseEvent} e
* @private
*/
}, {
key: "_handleClick",
value: function _handleClick(e) {
var el = e.target,
classList = el.classList;
if (this.options.allowAdd && classList.contains('si-proposal')) {
if (this._tryCreateItem(el.dataset.term)) {
this.toggle()._trigger('created', this.current);
}
return;
}
if (classList.contains('si-item')) {
this._setCurrent(this.findItem(el), el).toggle()._trigger('selected', this.current);
return;
}
if (this.options.allowRemove && classList.contains('si-removal')) {
el = el.parentNode;
if (this._fireCallback('onDelete', this.findItem(el))) {
this._trigger('removed', this._sliceItem(el));
}
}
}
/**
* The `onCreate` and `onDelete` callbacks allow to prevent their respective actions
* @param {String} name
* @param {Object} item
* @return {Boolean}
* @private
*/
}, {
key: "_fireCallback",
value: function _fireCallback(name, item) {
if (typeof this.options[name] === 'function') {
return this.options[name](item);
}
return true;
}
/**
* Handle `Enter` when there is a value in the field
* @param {KeyboardEvent} e
* @private
*/
}, {
key: "_handleKey",
value: function _handleKey(e) {
var value = e.target.value,
item = this.__found,
event;
if (!!value && (e.keyCode !== 13 || e.key !== 'Enter')) {
return;
}
if (!item && value && this.options.allowAdd) {
event = this._tryCreateItem(value) ? 'created' : null;
} else if (item) {
event = 'selected';
this._setCurrent(item);
}
if (event) this.toggle()._trigger(event, this.current);
}
/**
* If the value doesn't exist and the callback returns true, create and set as current
* @param value
* @return {boolean}
* @private
*/
}, {
key: "_tryCreateItem",
value: function _tryCreateItem(value) {
var item = this._convertItem(value.trim());
if (!this.findItem(value) && this._fireCallback('onCreate', item)) {
this._setCurrent(this._insertItem(item));
return true;
}
return false;
}
/**
* Insert a new item in the list
* @param {{value: String|Number, _lc_value: String, _lc_text: String}} item
* @return {{value: String|Number, _lc_value: String, _lc_text: String}}
* @private
*/
}, {
key: "_insertItem",
value: function _insertItem(item) {
this.options.items.push(item);
if (this.options.sort) this._sortItems();
return item;
}
/**
* Rearrange the list
* @private
*/
}, {
key: "_sortItems",
value: function _sortItems() {
var order = this.options.order === 'desc' ? 1 : -1;
this.options.items.sort(function (a, b) {
if (a._lc_text < b._lc_text) return -order;
if (a._lc_text > b._lc_text) return order;
return 0;
});
}
/**
* Remove an item from the list
* @param {HTMLElement|Node} el
* @return {{value: String|Number, _lc_value: String, _lc_text: String}}
* @private
*/
}, {
key: "_sliceItem",
value: function _sliceItem(el) {
var items = this.options.items,
needle = el.dataset.value.toLowerCase(),
current = this.current,
item;
this.dom.list.removeChild(el);
item = items.splice(items.findIndex(function (item) {
return item._lc_value === needle;
}), 1).shift();
if (current && item._lc_value === current._lc_value) this.clearCurrent();
return item;
}
}]);
return SelectInput;
}(DomComponent);
return SelectInput;
}));

2

package.json
{
"name": "@dotburo/select-input",
"version": "1.2.4",
"version": "1.3.0",
"description": "Lightweight & dynamic select dropdown with an input field, without dependencies",

@@ -5,0 +5,0 @@ "main": "dist/select-input-min.js",

@@ -30,19 +30,22 @@ # SelectInput ![](https://img.shields.io/github/tag/dotburo/select-input.svg?label=version&style=flat) [![Maintainability](https://api.codeclimate.com/v1/badges/974d8c32d0d5eed14a5e/maintainability)](https://codeclimate.com/github/dotburo/select-input/maintainability)

## Available options (and their defaults)
```
items: [] # Array of strings/numbers or of {value: String|Number} objects
current: null # Item to select on instantiation
parent: null # Parent element, to
maxHeight: 0 # Maximum height of the dropdown, `0` means no constraint
allowAdd: true # Whether to allow adding new elements to the list
proposal: 'Add {X} to the list?' # Message to add an item to the list, {X} will be replaced
notFound: '{X} not present in the list' # Message if nothing was found (only used if `allowAdd` is `false`)
sort: true # Whether to sort the list
order: 'desc' # Sort order
allowRemove: true # Whether to allow removal of items in the list
removalIcon: '&times;' # HTML for deletion button in each item li-element
placeHolder: 'Type to search' # Input field place holder
onDelete: null # Callable, fired before deleting an item; return `false` to prevent deletion
onCreate: null # Callable, fired before creatng an item; return `false` to prevent creation
```
| Option | Default | Description |
| ------------- |---------------------------------| --------------------------|
| items | `[]` | Array of strings, numbers or objects |
| current | `null` | Item to be selected upon instantiation |
| maxHeight | `0` | Maximum height of the dropdown, `0` equals no constraint |
| allowAdd | `true` | Whether to allow adding new elements to the list |
| proposal | `'Add {X} to the list?'` | Message to add an item to the list, {X} will be replaced |
| notFound | `'{X} not present in the list'` | Message if nothing was found (only used if `allowAdd` is `false`) |
| sort | `true` | Whether to sort the list |
| order | `'desc'` | Sort order |
| allowRemove | `true` | Whether to allow removal of items in the list |
| removalIcon | `'&times;'` | HTML for deletion button in each item li-element |
| placeHolder | `'Type to search'` | Input field place holder |
| onDelete | `null` | Callable, fired before deleting an item; return `false` to prevent deletion |
| onCreate | `null` | Callable, fired before creating an item; return `false` to prevent creation |
| valueKey | `'value'` | If the items are objects, the key of the property to use as value |
| textKey | `'value'` | If the items are objects, the key of the property to use for display |
## Events

@@ -49,0 +52,0 @@

@@ -12,5 +12,5 @@ import DomHelper from "./dom-component.js";

this.options.items = this._convertItems(options.items);
this.current = this.findItem(current[options.valueKey]);
this.current = current ? this.findItem(this._getItemProp(current)) : null;
// search result caching
// Cached search result
this.__found = null;

@@ -24,4 +24,4 @@

if (this.current) {
this.dom.input.value = this.current[options.textKey];
if (current) {
this._setInputValue(current);
}

@@ -94,7 +94,7 @@ }

*/
getCurrent(key = null) {
getCurrent() {
let current = Object.assign({}, this.current);
delete current._lc_value;
delete current._lc_text;
return key ? current[key] : current;
return current;
}

@@ -119,5 +119,4 @@

findItem(value) {
let opt = this.options;
value = value.nodeName ? value.dataset.value : value;
return opt.items.find(item => item[opt.valueKey] === value);
return this.options.items.find(item => this._getItemProp(item) === value);
}

@@ -143,3 +142,3 @@

_setCurrent(item, el = null) {
this.dom.input.value = item ? item[this.options.textKey].toString() : '';
this._setInputValue(item);
if (item) {

@@ -156,2 +155,12 @@ this.current = item;

/**
* Set the HTML input field
* @param {Object} item
* @return void
* @private
*/
_setInputValue(item) {
this.dom.input.value = item ? this._getItemProp(item, 'text').toString() : '';
}
/**
* Updated selected item in the html list

@@ -164,3 +173,3 @@ * @param {Object} item

this._clearSelected();
el = el ? el : this.dom.list.querySelector(`li[data-value="${item[this.options.valueKey]}"]`);
el = el ? el : this.dom.list.querySelector(`li[data-value="${this._getItemProp(item)}"]`);
if (el) el.classList.add('si-current');

@@ -197,4 +206,4 @@ }

item = typeof item !== 'object' ? {[opt.valueKey]: item, [opt.textKey]: item} : item;
item._lc_value = item[opt.valueKey].toString().toLowerCase().replace(/\s+/g, '-');
item._lc_text = item[opt.textKey].toString().toLowerCase().replace(/\s+/g, '-');
item._lc_value = this._makeSearchString(this._getItemProp(item));
item._lc_text = this._makeSearchString(this._getItemProp(item, 'text'));
return item;

@@ -204,2 +213,23 @@ }

/**
* Format all searchable strings
* @param {String} value
* @return {String}
* @private
*/
_makeSearchString(value) {
return value.toString().toLowerCase().replace(/\s+/g, '-');
}
/**
* Return the value of one of the custom named properties
* @param {Object} item
* @param {String} prop
* @return {String|Number}
* @private
*/
_getItemProp(item, prop = 'value') {
return item ? item[this.options[`${prop}Key`]] : null;
}
/**
* Create the HTML upon instantiation

@@ -263,3 +293,3 @@ * @return {Node}

opt = this.options,
current = this.getCurrent(opt.valueKey),
currentValue = this._getItemProp(this.current),
selected = '',

@@ -271,6 +301,6 @@ button = opt.allowRemove ? this._createRemovalButton() : '',

items.forEach(item => {
value = item[opt.valueKey];
text = item[opt.textKey];
selected = current && value === current ? ' si-current' : '';
list += `<li class="si-item${selected}" data-value="${value}">${text}${button}</li>`;
value = this._getItemProp(item);
text = this._getItemProp(item, 'text');
selected = currentValue && value === currentValue ? ' si-current' : '';
list += `<li class="si-item${selected}" data-value="${value}">${text + button}</li>`;
});

@@ -309,6 +339,4 @@

term = e.target.value,
termLc = term.toLowerCase().replace(/\s+/g, '-'),
list = options.items.filter(item => {
return item._lc_value.indexOf(termLc) !== -1 || item._lc_text.indexOf(termLc) !== -1;
}),
termLc = this._makeSearchString(term),
list = this._searchItem(termLc),
html = list || options.allowAdd ? this._createListItems(list) : '',

@@ -322,3 +350,3 @@ first = list[0],

if (len > 1 || !len || !term) {
if (len !== 1 || !term) {
this.__found = null;

@@ -337,2 +365,14 @@ }

/**
* Filter the list of available items
* @param {String} str
* @return {[]}
* @private
*/
_searchItem(str) {
return this.options.items.filter(item => {
return item._lc_value.indexOf(str) !== -1 || item._lc_text.indexOf(str) !== -1;
})
}
/**
* Create the item creation list item

@@ -339,0 +379,0 @@ * @param {String} term

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc