tom-select-rails 2.2.2 → 2.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/tom-select-rails/version.rb +1 -1
- data/vendor/assets/javascripts/tom-select-rails/cjs/tom-select.complete.js +614 -820
- data/vendor/assets/javascripts/tom-select-rails/cjs/tom-select.complete.js.map +1 -1
- data/vendor/assets/javascripts/tom-select-rails/cjs/tom-select.js +411 -685
- data/vendor/assets/javascripts/tom-select-rails/cjs/tom-select.js.map +1 -1
- data/vendor/assets/javascripts/tom-select-rails/cjs/tom-select.popular.js +436 -705
- data/vendor/assets/javascripts/tom-select-rails/cjs/tom-select.popular.js.map +1 -1
- data/vendor/assets/javascripts/tom-select-rails/cjs/utils.js +31 -27
- data/vendor/assets/javascripts/tom-select-rails/cjs/utils.js.map +1 -1
- data/vendor/assets/javascripts/tom-select-rails/esm/plugins/caret_position/plugin.js +11 -16
- data/vendor/assets/javascripts/tom-select-rails/esm/plugins/caret_position/plugin.js.map +1 -1
- data/vendor/assets/javascripts/tom-select-rails/esm/plugins/change_listener/plugin.js +3 -2
- data/vendor/assets/javascripts/tom-select-rails/esm/plugins/change_listener/plugin.js.map +1 -1
- data/vendor/assets/javascripts/tom-select-rails/esm/plugins/checkbox_options/plugin.js +47 -34
- data/vendor/assets/javascripts/tom-select-rails/esm/plugins/checkbox_options/plugin.js.map +1 -1
- data/vendor/assets/javascripts/tom-select-rails/esm/plugins/clear_button/plugin.js +3 -13
- data/vendor/assets/javascripts/tom-select-rails/esm/plugins/clear_button/plugin.js.map +1 -1
- data/vendor/assets/javascripts/tom-select-rails/esm/plugins/drag_drop/plugin.js +249 -29
- data/vendor/assets/javascripts/tom-select-rails/esm/plugins/drag_drop/plugin.js.map +1 -1
- data/vendor/assets/javascripts/tom-select-rails/esm/plugins/dropdown_header/plugin.js +3 -11
- data/vendor/assets/javascripts/tom-select-rails/esm/plugins/dropdown_header/plugin.js.map +1 -1
- data/vendor/assets/javascripts/tom-select-rails/esm/plugins/dropdown_input/plugin.js +15 -24
- data/vendor/assets/javascripts/tom-select-rails/esm/plugins/dropdown_input/plugin.js.map +1 -1
- data/vendor/assets/javascripts/tom-select-rails/esm/plugins/input_autogrow/plugin.js +4 -6
- data/vendor/assets/javascripts/tom-select-rails/esm/plugins/input_autogrow/plugin.js.map +1 -1
- data/vendor/assets/javascripts/tom-select-rails/esm/plugins/no_active_items/plugin.js +2 -1
- data/vendor/assets/javascripts/tom-select-rails/esm/plugins/no_active_items/plugin.js.map +1 -1
- data/vendor/assets/javascripts/tom-select-rails/esm/plugins/no_backspace_delete/plugin.js +2 -2
- data/vendor/assets/javascripts/tom-select-rails/esm/plugins/no_backspace_delete/plugin.js.map +1 -1
- data/vendor/assets/javascripts/tom-select-rails/esm/plugins/optgroup_columns/plugin.js +3 -15
- data/vendor/assets/javascripts/tom-select-rails/esm/plugins/optgroup_columns/plugin.js.map +1 -1
- data/vendor/assets/javascripts/tom-select-rails/esm/plugins/remove_button/plugin.js +11 -15
- data/vendor/assets/javascripts/tom-select-rails/esm/plugins/remove_button/plugin.js.map +1 -1
- data/vendor/assets/javascripts/tom-select-rails/esm/plugins/restore_on_backspace/plugin.js +2 -3
- data/vendor/assets/javascripts/tom-select-rails/esm/plugins/restore_on_backspace/plugin.js.map +1 -1
- data/vendor/assets/javascripts/tom-select-rails/esm/plugins/virtual_scroll/plugin.js +41 -50
- data/vendor/assets/javascripts/tom-select-rails/esm/plugins/virtual_scroll/plugin.js.map +1 -1
- data/vendor/assets/javascripts/tom-select-rails/esm/tom-select.complete.js +614 -820
- data/vendor/assets/javascripts/tom-select-rails/esm/tom-select.complete.js.map +1 -1
- data/vendor/assets/javascripts/tom-select-rails/esm/tom-select.js +411 -685
- data/vendor/assets/javascripts/tom-select-rails/esm/tom-select.js.map +1 -1
- data/vendor/assets/javascripts/tom-select-rails/esm/tom-select.popular.js +436 -705
- data/vendor/assets/javascripts/tom-select-rails/esm/tom-select.popular.js.map +1 -1
- data/vendor/assets/javascripts/tom-select-rails/esm/utils.js +31 -26
- data/vendor/assets/javascripts/tom-select-rails/esm/utils.js.map +1 -1
- data/vendor/assets/javascripts/tom-select-rails/js/plugins/caret_position.js +11 -16
- data/vendor/assets/javascripts/tom-select-rails/js/plugins/caret_position.js.map +1 -1
- data/vendor/assets/javascripts/tom-select-rails/js/plugins/change_listener.js +3 -2
- data/vendor/assets/javascripts/tom-select-rails/js/plugins/change_listener.js.map +1 -1
- data/vendor/assets/javascripts/tom-select-rails/js/plugins/checkbox_options.js +47 -34
- data/vendor/assets/javascripts/tom-select-rails/js/plugins/checkbox_options.js.map +1 -1
- data/vendor/assets/javascripts/tom-select-rails/js/plugins/clear_button.js +3 -13
- data/vendor/assets/javascripts/tom-select-rails/js/plugins/clear_button.js.map +1 -1
- data/vendor/assets/javascripts/tom-select-rails/js/plugins/drag_drop.js +249 -29
- data/vendor/assets/javascripts/tom-select-rails/js/plugins/drag_drop.js.map +1 -1
- data/vendor/assets/javascripts/tom-select-rails/js/plugins/dropdown_header.js +3 -11
- data/vendor/assets/javascripts/tom-select-rails/js/plugins/dropdown_header.js.map +1 -1
- data/vendor/assets/javascripts/tom-select-rails/js/plugins/dropdown_input.js +15 -24
- data/vendor/assets/javascripts/tom-select-rails/js/plugins/dropdown_input.js.map +1 -1
- data/vendor/assets/javascripts/tom-select-rails/js/plugins/input_autogrow.js +4 -6
- data/vendor/assets/javascripts/tom-select-rails/js/plugins/input_autogrow.js.map +1 -1
- data/vendor/assets/javascripts/tom-select-rails/js/plugins/no_active_items.js +2 -1
- data/vendor/assets/javascripts/tom-select-rails/js/plugins/no_active_items.js.map +1 -1
- data/vendor/assets/javascripts/tom-select-rails/js/plugins/no_backspace_delete.js +2 -2
- data/vendor/assets/javascripts/tom-select-rails/js/plugins/no_backspace_delete.js.map +1 -1
- data/vendor/assets/javascripts/tom-select-rails/js/plugins/optgroup_columns.js +3 -15
- data/vendor/assets/javascripts/tom-select-rails/js/plugins/optgroup_columns.js.map +1 -1
- data/vendor/assets/javascripts/tom-select-rails/js/plugins/remove_button.js +11 -15
- data/vendor/assets/javascripts/tom-select-rails/js/plugins/remove_button.js.map +1 -1
- data/vendor/assets/javascripts/tom-select-rails/js/plugins/restore_on_backspace.js +2 -3
- data/vendor/assets/javascripts/tom-select-rails/js/plugins/restore_on_backspace.js.map +1 -1
- data/vendor/assets/javascripts/tom-select-rails/js/plugins/virtual_scroll.js +41 -50
- data/vendor/assets/javascripts/tom-select-rails/js/plugins/virtual_scroll.js.map +1 -1
- data/vendor/assets/javascripts/tom-select-rails/js/tom-select.base.js +411 -685
- data/vendor/assets/javascripts/tom-select-rails/js/tom-select.base.js.map +1 -1
- data/vendor/assets/javascripts/tom-select-rails/js/tom-select.base.min.js +87 -78
- data/vendor/assets/javascripts/tom-select-rails/js/tom-select.base.min.js.map +1 -1
- data/vendor/assets/javascripts/tom-select-rails/js/tom-select.complete.js +614 -820
- data/vendor/assets/javascripts/tom-select-rails/js/tom-select.complete.js.map +1 -1
- data/vendor/assets/javascripts/tom-select-rails/js/tom-select.complete.min.js +195 -176
- data/vendor/assets/javascripts/tom-select-rails/js/tom-select.complete.min.js.map +1 -1
- data/vendor/assets/javascripts/tom-select-rails/js/tom-select.popular.js +436 -705
- data/vendor/assets/javascripts/tom-select-rails/js/tom-select.popular.js.map +1 -1
- data/vendor/assets/javascripts/tom-select-rails/js/tom-select.popular.min.js +87 -78
- data/vendor/assets/javascripts/tom-select-rails/js/tom-select.popular.min.js.map +1 -1
- data/vendor/assets/javascripts/tom-select-rails/types/contrib/microevent.d.ts +1 -1
- data/vendor/assets/javascripts/tom-select-rails/types/contrib/microplugin.d.ts +4 -4
- data/vendor/assets/javascripts/tom-select-rails/types/defaults.d.ts +1 -0
- data/vendor/assets/javascripts/tom-select-rails/types/plugins/checkbox_options/plugin.d.ts +3 -2
- data/vendor/assets/javascripts/tom-select-rails/types/plugins/checkbox_options/types.d.ts +14 -0
- data/vendor/assets/javascripts/tom-select-rails/types/plugins/clear_button/types.d.ts +1 -1
- data/vendor/assets/javascripts/tom-select-rails/types/plugins/dropdown_header/types.d.ts +1 -1
- data/vendor/assets/javascripts/tom-select-rails/types/plugins/remove_button/types.d.ts +1 -1
- data/vendor/assets/javascripts/tom-select-rails/types/plugins/restore_on_backspace/plugin.d.ts +1 -1
- data/vendor/assets/javascripts/tom-select-rails/types/tom-select.d.ts +10 -12
- data/vendor/assets/javascripts/tom-select-rails/types/types/core.d.ts +15 -14
- data/vendor/assets/javascripts/tom-select-rails/types/types/settings.d.ts +3 -2
- data/vendor/assets/javascripts/tom-select-rails/types/utils.d.ts +7 -0
- data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.bootstrap4.css +224 -216
- data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.bootstrap4.css.map +1 -1
- data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.bootstrap4.min.css +1 -1
- data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.bootstrap4.min.css.map +1 -1
- data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.bootstrap5.css +245 -252
- data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.bootstrap5.css.map +1 -1
- data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.bootstrap5.min.css +1 -1
- data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.bootstrap5.min.css.map +1 -1
- data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.css +213 -210
- data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.css.map +1 -1
- data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.default.css +223 -215
- data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.default.css.map +1 -1
- data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.default.min.css +1 -1
- data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.default.min.css.map +1 -1
- data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.min.css +1 -1
- data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.min.css.map +1 -1
- data/vendor/assets/stylesheets/tom-select-rails/scss/_dropdown.scss +7 -10
- data/vendor/assets/stylesheets/tom-select-rails/scss/_items.scss +2 -5
- data/vendor/assets/stylesheets/tom-select-rails/scss/plugins/checkbox_options.scss +8 -2
- data/vendor/assets/stylesheets/tom-select-rails/scss/plugins/clear_button.scss +16 -14
- data/vendor/assets/stylesheets/tom-select-rails/scss/plugins/drag_drop.scss +6 -12
- data/vendor/assets/stylesheets/tom-select-rails/scss/plugins/dropdown_header.scss +3 -2
- data/vendor/assets/stylesheets/tom-select-rails/scss/plugins/dropdown_input.scss +7 -11
- data/vendor/assets/stylesheets/tom-select-rails/scss/plugins/input_autogrow.scss +0 -3
- data/vendor/assets/stylesheets/tom-select-rails/scss/plugins/optgroup_columns.scss +7 -5
- data/vendor/assets/stylesheets/tom-select-rails/scss/plugins/remove_button.scss +20 -20
- data/vendor/assets/stylesheets/tom-select-rails/scss/tom-select.bootstrap4.scss +33 -39
- data/vendor/assets/stylesheets/tom-select-rails/scss/tom-select.bootstrap5.scss +54 -80
- data/vendor/assets/stylesheets/tom-select-rails/scss/tom-select.default.scss +16 -14
- data/vendor/assets/stylesheets/tom-select-rails/scss/tom-select.scss +52 -57
- metadata +8 -7
@@ -1,5 +1,5 @@
|
|
1
1
|
/**
|
2
|
-
* Tom Select v2.
|
2
|
+
* Tom Select v2.3.1
|
3
3
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
4
4
|
*/
|
5
5
|
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).TomSelect=e()}(this,(function(){"use strict"
|
@@ -103,17 +103,17 @@ s=this.prepareSearch(t,e),e=s.options,t=s.query
|
|
103
103
|
const o=e.score||n._getScoreFunction(s)
|
104
104
|
t.length?E(n.items,((t,n)=>{i=o(t),(!1===e.filter||i>0)&&s.items.push({score:i,id:n})})):E(n.items,((t,e)=>{s.items.push({score:1,id:e})}))
|
105
105
|
const r=n._getSortFunction(s)
|
106
|
-
return r&&s.items.sort(r),s.total=s.items.length,"number"==typeof e.limit&&(s.items=s.items.slice(0,e.limit)),s}}const
|
107
|
-
else for(var i in t)t.hasOwnProperty(i)&&e(t[i],i)},
|
106
|
+
return r&&s.items.sort(r),s.total=s.items.length,"number"==typeof e.limit&&(s.items=s.items.slice(0,e.limit)),s}}const $=(t,e)=>{if(Array.isArray(t))t.forEach(e)
|
107
|
+
else for(var i in t)t.hasOwnProperty(i)&&e(t[i],i)},j=t=>{if(t.jquery)return t[0]
|
108
108
|
if(t instanceof HTMLElement)return t
|
109
|
-
if(
|
110
|
-
return e.innerHTML=t.trim(),e.content.firstChild}return document.querySelector(t)}
|
111
|
-
i.initEvent(e,!0,!1),t.dispatchEvent(i)},D=(t,e)=>{Object.assign(t.style,e)},
|
112
|
-
return
|
109
|
+
if(V(t)){var e=document.createElement("template")
|
110
|
+
return e.innerHTML=t.trim(),e.content.firstChild}return document.querySelector(t)},V=t=>"string"==typeof t&&t.indexOf("<")>-1,q=(t,e)=>{var i=document.createEvent("HTMLEvents")
|
111
|
+
i.initEvent(e,!0,!1),t.dispatchEvent(i)},D=(t,e)=>{Object.assign(t.style,e)},R=(t,...e)=>{var i=H(e);(t=M(t)).map((t=>{i.map((e=>{t.classList.add(e)}))}))},N=(t,...e)=>{var i=H(e);(t=M(t)).map((t=>{i.map((e=>{t.classList.remove(e)}))}))},H=t=>{var e=[]
|
112
|
+
return $(t,(t=>{"string"==typeof t&&(t=t.trim().split(/[\11\12\14\15\40]/)),Array.isArray(t)&&(e=e.concat(t))})),e.filter(Boolean)},M=t=>(Array.isArray(t)||(t=[t]),t),z=(t,e,i)=>{if(!i||i.contains(t))for(;t&&t.matches;){if(t.matches(e))return t
|
113
113
|
t=t.parentNode}},B=(t,e=0)=>e>0?t[t.length-1]:t[0],K=(t,e)=>{if(!t)return-1
|
114
114
|
e=e||t.nodeName
|
115
115
|
for(var i=0;t=t.previousElementSibling;)t.matches(e)&&i++
|
116
|
-
return i},Q=(t,e)=>{
|
116
|
+
return i},Q=(t,e)=>{$(e,((e,i)=>{null==e?t.removeAttribute(i):t.setAttribute(i,""+e)}))},G=(t,e)=>{t.parentNode&&t.parentNode.replaceChild(e,t)},J=(t,e)=>{if(null===e)return
|
117
117
|
if("string"==typeof e){if(!e.length)return
|
118
118
|
e=new RegExp(e,"i")}const i=t=>3===t.nodeType?(t=>{var i=t.data.match(e)
|
119
119
|
if(i&&t.data.length>0){var s=document.createElement("span")
|
@@ -123,7 +123,7 @@ n.splitText(i[0].length)
|
|
123
123
|
var o=n.cloneNode(!0)
|
124
124
|
return s.appendChild(o),G(n,s),1}return 0})(t):((t=>{1!==t.nodeType||!t.childNodes||/(script|style)/i.test(t.tagName)||"highlight"===t.className&&"SPAN"===t.tagName||Array.from(t.childNodes).forEach((t=>{i(t)}))})(t),0)
|
125
125
|
i(t)},U="undefined"!=typeof navigator&&/Mac/.test(navigator.userAgent)?"metaKey":"ctrlKey"
|
126
|
-
var W={options:[],optgroups:[],plugins:[],delimiter:",",splitOn:null,persist:!0,diacritics:!0,create:null,createOnBlur:!1,createFilter:null,highlight:!0,openOnFocus:!0,shouldOpen:null,maxOptions:50,maxItems:null,hideSelected:null,duplicates:!1,addPrecedence:!1,selectOnTab:!1,preload:null,allowEmptyOption:!1,loadThrottle:300,loadingClass:"loading",dataAttr:null,optgroupField:"optgroup",valueField:"value",labelField:"text",disabledField:"disabled",optgroupLabelField:"label",optgroupValueField:"value",lockOptgroupOrder:!1,sortField:"$order",searchField:["text"],searchConjunction:"and",mode:null,wrapperClass:"ts-wrapper",controlClass:"ts-control",dropdownClass:"ts-dropdown",dropdownContentClass:"ts-dropdown-content",itemClass:"item",optionClass:"option",dropdownParent:null,controlInput:'<input type="text" autocomplete="off" size="1" />',copyClassesToDropdown:!1,placeholder:null,hidePlaceholder:null,shouldLoad:function(t){return t.length>0},render:{}}
|
126
|
+
var W={options:[],optgroups:[],plugins:[],delimiter:",",splitOn:null,persist:!0,diacritics:!0,create:null,createOnBlur:!1,createFilter:null,highlight:!0,openOnFocus:!0,shouldOpen:null,maxOptions:50,maxItems:null,hideSelected:null,duplicates:!1,addPrecedence:!1,selectOnTab:!1,preload:null,allowEmptyOption:!1,refreshThrottle:300,loadThrottle:300,loadingClass:"loading",dataAttr:null,optgroupField:"optgroup",valueField:"value",labelField:"text",disabledField:"disabled",optgroupLabelField:"label",optgroupValueField:"value",lockOptgroupOrder:!1,sortField:"$order",searchField:["text"],searchConjunction:"and",mode:null,wrapperClass:"ts-wrapper",controlClass:"ts-control",dropdownClass:"ts-dropdown",dropdownContentClass:"ts-dropdown-content",itemClass:"item",optionClass:"option",dropdownParent:null,controlInput:'<input type="text" autocomplete="off" size="1" />',copyClassesToDropdown:!1,placeholder:null,hidePlaceholder:null,shouldLoad:function(t){return t.length>0},render:{}}
|
127
127
|
const X=t=>null==t?null:Y(t),Y=t=>"boolean"==typeof t?t?"1":"0":t+"",Z=t=>(t+"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,"""),tt=(t,e)=>{var i
|
128
128
|
return function(s,n){var o=this
|
129
129
|
i&&(o.loading=Math.max(o.loading-1,0),clearTimeout(i)),i=setTimeout((function(){i=null,o.loadedSearches[s]=!0,t.call(o,s,n)}),e)}},et=(t,e,i)=>{var s,n=t.trigger,o={}
|
@@ -133,19 +133,22 @@ o[i]=arguments},i.apply(t,[]),t.trigger=n,e))s in o&&n.apply(t,o[s])},it=(t,e=!1
|
|
133
133
|
return i||(t.setAttribute("id",e),e)},rt=t=>t.replace(/[\\"']/g,"\\$&"),lt=(t,e)=>{e&&t.append(e)}
|
134
134
|
function at(t,e){var i=Object.assign({},W,e),s=i.dataAttr,n=i.labelField,o=i.valueField,r=i.disabledField,l=i.optgroupField,a=i.optgroupLabelField,c=i.optgroupValueField,d=t.tagName.toLowerCase(),u=t.getAttribute("placeholder")||t.getAttribute("data-placeholder")
|
135
135
|
if(!u&&!i.allowEmptyOption){let e=t.querySelector('option[value=""]')
|
136
|
-
e&&(u=e.textContent)}var p
|
137
|
-
return"select"===d?(
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
136
|
+
e&&(u=e.textContent)}var p={placeholder:u,options:[],optgroups:[],items:[],maxItems:null}
|
137
|
+
return"select"===d?(()=>{var e,d=p.options,u={},h=1
|
138
|
+
let g=0
|
139
|
+
var f=t=>{var e=Object.assign({},t.dataset),i=s&&e[s]
|
140
|
+
return"string"==typeof i&&i.length&&(e=Object.assign(e,JSON.parse(i))),e},v=(t,e)=>{var s=X(t.value)
|
141
|
+
if(null!=s&&(s||i.allowEmptyOption)){if(u.hasOwnProperty(s)){if(e){var a=u[s][l]
|
142
|
+
a?Array.isArray(a)?a.push(e):u[s][l]=[a,e]:u[s][l]=e}}else{var c=f(t)
|
143
|
+
c[n]=c[n]||t.textContent,c[o]=c[o]||s,c[r]=c[r]||t.disabled,c[l]=c[l]||e,c.$option=t,c.$order=c.$order||++g,u[s]=c,d.push(c)}t.selected&&p.items.push(s)}}
|
144
|
+
p.maxItems=t.hasAttribute("multiple")?null:1,$(t.children,(t=>{var i,s,n
|
145
|
+
"optgroup"===(e=t.tagName.toLowerCase())?((n=f(i=t))[a]=n[a]||i.getAttribute("label")||"",n[c]=n[c]||h++,n[r]=n[r]||i.disabled,n.$order=n.$order||++g,p.optgroups.push(n),s=n[c],$(i.children,(t=>{v(t,s)}))):"option"===e&&v(t)}))})():(()=>{const e=t.getAttribute(s)
|
146
|
+
if(e)p.options=JSON.parse(e),$(p.options,(t=>{p.items.push(t[o])}))
|
144
147
|
else{var r=t.value.trim()||""
|
145
148
|
if(!i.allowEmptyOption&&!r.length)return
|
146
149
|
const e=r.split(i.delimiter)
|
147
|
-
|
148
|
-
e[n]=t,e[o]=t,
|
150
|
+
$(e,(t=>{const e={}
|
151
|
+
e[n]=t,e[o]=t,p.options.push(e)})),p.items=e}})(),Object.assign({},W,p,e)}var ct=0
|
149
152
|
class dt extends(function(t){return t.plugins={},class extends t{constructor(...t){super(...t),this.plugins={names:[],settings:{},requested:{},loaded:{}}}static define(e,i){t.plugins[e]={name:e,fn:i}}initializePlugins(t){var e,i
|
150
153
|
const s=this,n=[]
|
151
154
|
if(Array.isArray(t))t.forEach((t=>{"string"==typeof t?n.push(t):(s.plugins.settings[t.name]=t.options,n.push(t.name))}))
|
@@ -155,32 +158,32 @@ if(!t.plugins.hasOwnProperty(e))throw new Error('Unable to find "'+e+'" plugin')
|
|
155
158
|
s.requested[e]=!0,s.loaded[e]=n.fn.apply(i,[i.plugins.settings[e]||{}]),s.names.push(e)}require(t){var e=this,i=e.plugins
|
156
159
|
if(!e.plugins.loaded.hasOwnProperty(t)){if(i.requested[t])throw new Error('Plugin has circular dependency ("'+t+'")')
|
157
160
|
e.loadPlugin(t)}return i.loaded[t]}}}(e)){constructor(t,e){var i
|
158
|
-
super(),this.control_input=void 0,this.wrapper=void 0,this.dropdown=void 0,this.control=void 0,this.dropdown_content=void 0,this.focus_node=void 0,this.order=0,this.settings=void 0,this.input=void 0,this.tabIndex=void 0,this.is_select_tag=void 0,this.rtl=void 0,this.inputId=void 0,this._destroy=void 0,this.sifter=void 0,this.isOpen=!1,this.isDisabled=!1,this.isRequired=void 0,this.isInvalid=!1,this.isValid=!0,this.isLocked=!1,this.isFocused=!1,this.isInputHidden=!1,this.isSetup=!1,this.ignoreFocus=!1,this.ignoreHover=!1,this.hasOptions=!1,this.currentResults=void 0,this.lastValue="",this.caretPos=0,this.loading=0,this.loadedSearches={},this.activeOption=null,this.activeItems=[],this.optgroups={},this.options={},this.userOptions={},this.items=[],ct++
|
159
|
-
var s=
|
161
|
+
super(),this.control_input=void 0,this.wrapper=void 0,this.dropdown=void 0,this.control=void 0,this.dropdown_content=void 0,this.focus_node=void 0,this.order=0,this.settings=void 0,this.input=void 0,this.tabIndex=void 0,this.is_select_tag=void 0,this.rtl=void 0,this.inputId=void 0,this._destroy=void 0,this.sifter=void 0,this.isOpen=!1,this.isDisabled=!1,this.isReadOnly=!1,this.isRequired=void 0,this.isInvalid=!1,this.isValid=!0,this.isLocked=!1,this.isFocused=!1,this.isInputHidden=!1,this.isSetup=!1,this.ignoreFocus=!1,this.ignoreHover=!1,this.hasOptions=!1,this.currentResults=void 0,this.lastValue="",this.caretPos=0,this.loading=0,this.loadedSearches={},this.activeOption=null,this.activeItems=[],this.optgroups={},this.options={},this.userOptions={},this.items=[],this.refreshTimeout=null,ct++
|
162
|
+
var s=j(t)
|
160
163
|
if(s.tomselect)throw new Error("Tom Select already initialized on this element")
|
161
164
|
s.tomselect=this,i=(window.getComputedStyle&&window.getComputedStyle(s,null)).getPropertyValue("direction")
|
162
165
|
const n=at(s,e)
|
163
166
|
this.settings=n,this.input=s,this.tabIndex=s.tabIndex||0,this.is_select_tag="select"===s.tagName.toLowerCase(),this.rtl=/rtl/i.test(i),this.inputId=ot(s,"tomselect-"+ct),this.isRequired=s.required,this.sifter=new T(this.options,{diacritics:n.diacritics}),n.mode=n.mode||(1===n.maxItems?"single":"multi"),"boolean"!=typeof n.hideSelected&&(n.hideSelected="multi"===n.mode),"boolean"!=typeof n.hidePlaceholder&&(n.hidePlaceholder="multi"!==n.mode)
|
164
167
|
var o=n.createFilter
|
165
168
|
"function"!=typeof o&&("string"==typeof o&&(o=new RegExp(o)),o instanceof RegExp?n.createFilter=t=>o.test(t):n.createFilter=t=>this.settings.duplicates||!this.options[t]),this.initializePlugins(n.plugins),this.setupCallbacks(),this.setupTemplates()
|
166
|
-
const r=
|
169
|
+
const r=j("<div>"),l=j("<div>"),a=this._render("dropdown"),c=j('<div role="listbox" tabindex="-1">'),d=this.input.getAttribute("class")||"",u=n.mode
|
167
170
|
var p
|
168
|
-
if(
|
169
|
-
E(["autocorrect","autocapitalize","autocomplete"],(t=>{s.getAttribute(t)&&Q(p,{[t]:s.getAttribute(t)})})),p.tabIndex=-1,l.appendChild(p),this.focus_node=p}else n.controlInput?(p=
|
171
|
+
if(R(r,n.wrapperClass,d,u),R(l,n.controlClass),lt(r,l),R(a,n.dropdownClass,u),n.copyClassesToDropdown&&R(a,d),R(c,n.dropdownContentClass),lt(a,c),j(n.dropdownParent||r).appendChild(a),V(n.controlInput)){p=j(n.controlInput)
|
172
|
+
E(["autocorrect","autocapitalize","autocomplete","spellcheck"],(t=>{s.getAttribute(t)&&Q(p,{[t]:s.getAttribute(t)})})),p.tabIndex=-1,l.appendChild(p),this.focus_node=p}else n.controlInput?(p=j(n.controlInput),this.focus_node=p):(p=j("<input/>"),this.focus_node=l)
|
170
173
|
this.wrapper=r,this.dropdown=a,this.dropdown_content=c,this.control=l,this.control_input=p,this.setup()}setup(){const t=this,e=t.settings,i=t.control_input,s=t.dropdown,n=t.dropdown_content,o=t.wrapper,l=t.control,a=t.input,c=t.focus_node,d={passive:!0},u=t.inputId+"-ts-dropdown"
|
171
174
|
Q(n,{id:u}),Q(c,{role:"combobox","aria-haspopup":"listbox","aria-expanded":"false","aria-controls":u})
|
172
175
|
const p=ot(c,t.inputId+"-ts-control"),h="label[for='"+(t=>t.replace(/['"\\]/g,"\\$&"))(t.inputId)+"']",g=document.querySelector(h),f=t.focus.bind(t)
|
173
176
|
if(g){st(g,"click",f),Q(g,{for:p})
|
174
177
|
const e=ot(g,t.inputId+"-ts-label")
|
175
178
|
Q(c,{"aria-labelledby":e}),Q(n,{"aria-labelledby":e})}if(o.style.width=a.style.width,t.plugins.names.length){const e="plugin-"+t.plugins.names.join(" plugin-")
|
176
|
-
|
179
|
+
R([o,s],e)}(null===e.maxItems||e.maxItems>1)&&t.is_select_tag&&Q(a,{multiple:"multiple"}),e.placeholder&&Q(i,{placeholder:e.placeholder}),!e.splitOn&&e.delimiter&&(e.splitOn=new RegExp("\\s*"+r(e.delimiter)+"+\\s*")),e.load&&e.loadThrottle&&(e.load=tt(e.load,e.loadThrottle)),st(s,"mousemove",(()=>{t.ignoreHover=!1})),st(s,"mouseenter",(e=>{var i=z(e.target,"[data-selectable]",s)
|
177
180
|
i&&t.onOptionHover(e,i)}),{capture:!0}),st(s,"click",(e=>{const i=z(e.target,"[data-selectable]")
|
178
181
|
i&&(t.onOptionSelect(e,i),it(e,!0))})),st(l,"click",(e=>{var s=z(e.target,"[data-ts-item]",l)
|
179
182
|
s&&t.onItemSelect(e,s)?it(e,!0):""==i.value&&(t.onClick(),it(e,!0))})),st(c,"keydown",(e=>t.onKeyDown(e))),st(i,"keypress",(e=>t.onKeyPress(e))),st(i,"input",(e=>t.onInput(e))),st(c,"blur",(e=>t.onBlur(e))),st(c,"focus",(e=>t.onFocus(e))),st(i,"paste",(e=>t.onPaste(e)))
|
180
183
|
const v=e=>{const n=e.composedPath()[0]
|
181
184
|
if(!o.contains(n)&&!s.contains(n))return t.isFocused&&t.blur(),void t.inputState()
|
182
185
|
n==i&&t.isOpen?e.stopPropagation():it(e,!0)},m=()=>{t.isOpen&&t.positionDropdown()}
|
183
|
-
st(document,"mousedown",v),st(window,"scroll",m,d),st(window,"resize",m,d),this._destroy=()=>{document.removeEventListener("mousedown",v),window.removeEventListener("scroll",m),window.removeEventListener("resize",m),g&&g.removeEventListener("click",f)},this.revertSettings={innerHTML:a.innerHTML,tabIndex:a.tabIndex},a.tabIndex=-1,a.insertAdjacentElement("afterend",t.wrapper),t.sync(!1),e.items=[],delete e.optgroups,delete e.options,st(a,"invalid",(()=>{t.isValid&&(t.isValid=!1,t.isInvalid=!0,t.refreshState())})),t.updateOriginalInput(),t.refreshItems(),t.close(!1),t.inputState(),t.isSetup=!0,a.disabled?t.disable():t.enable(),t.on("change",this.onChange),
|
186
|
+
st(document,"mousedown",v),st(window,"scroll",m,d),st(window,"resize",m,d),this._destroy=()=>{document.removeEventListener("mousedown",v),window.removeEventListener("scroll",m),window.removeEventListener("resize",m),g&&g.removeEventListener("click",f)},this.revertSettings={innerHTML:a.innerHTML,tabIndex:a.tabIndex},a.tabIndex=-1,a.insertAdjacentElement("afterend",t.wrapper),t.sync(!1),e.items=[],delete e.optgroups,delete e.options,st(a,"invalid",(()=>{t.isValid&&(t.isValid=!1,t.isInvalid=!0,t.refreshState())})),t.updateOriginalInput(),t.refreshItems(),t.close(!1),t.inputState(),t.isSetup=!0,a.disabled?t.disable():a.readOnly?t.setReadOnly(!0):t.enable(),t.on("change",this.onChange),R(a,"tomselected","ts-hidden-accessible"),t.trigger("initialize"),!0===e.preload&&t.preload()}setupOptions(t=[],e=[]){this.addOptions(t),E(e,(t=>{this.registerOptionGroup(t)}))}setupTemplates(){var t=this,e=t.settings.labelField,i=t.settings.optgroupLabelField,s={optgroup:t=>{let e=document.createElement("div")
|
184
187
|
return e.className="optgroup",e.appendChild(t.options),e},optgroup_header:(t,e)=>'<div class="optgroup-header">'+e(t[i])+"</div>",option:(t,i)=>"<div>"+i(t[e])+"</div>",item:(t,i)=>"<div>"+i(t[e])+"</div>",option_create:(t,e)=>'<div class="create">Add <strong>'+e(t.input)+"</strong>…</div>",no_results:()=>'<div class="no-results">No results found</div>',loading:()=>'<div class="spinner"></div>',not_loading:()=>{},dropdown:()=>"<div></div>"}
|
185
188
|
t.settings.render=Object.assign({},s,t.settings.render)}setupCallbacks(){var t,e,i={initialize:"onInitialize",change:"onChange",item_add:"onItemAdd",item_remove:"onItemRemove",item_select:"onItemSelect",clear:"onClear",option_add:"onOptionAdd",option_remove:"onOptionRemove",option_clear:"onOptionClear",optgroup_add:"onOptionGroupAdd",optgroup_remove:"onOptionGroupRemove",optgroup_clear:"onOptionGroupClear",dropdown_open:"onDropdownOpen",dropdown_close:"onDropdownClose",type:"onType",load:"onLoad",focus:"onFocus",blur:"onBlur"}
|
186
189
|
for(t in i)(e=this.settings[i[t]])&&this.on(t,e)}sync(t=!0){const e=this,i=t?at(e.input,{delimiter:e.settings.delimiter}):e.settings
|
@@ -205,37 +208,38 @@ case 13:return void(e.canSelect(e.activeOption)?(e.onOptionSelect(t,e.activeOpti
|
|
205
208
|
case 37:return void e.advanceSelection(-1,t)
|
206
209
|
case 39:return void e.advanceSelection(1,t)
|
207
210
|
case 9:return void(e.settings.selectOnTab&&(e.canSelect(e.activeOption)&&(e.onOptionSelect(t,e.activeOption),it(t)),e.settings.create&&e.createItem()&&it(t)))
|
208
|
-
case 8:case 46:return void e.deleteSelection(t)}e.isInputHidden&&!nt(U,t)&&it(t)}}onInput(t){
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
211
|
+
case 8:case 46:return void e.deleteSelection(t)}e.isInputHidden&&!nt(U,t)&&it(t)}}onInput(t){if(this.isLocked)return
|
212
|
+
const e=this.inputValue()
|
213
|
+
this.lastValue!==e&&(this.lastValue=e,""!=e?(this.refreshTimeout&&clearTimeout(this.refreshTimeout),this.refreshTimeout=((t,e)=>e>0?setTimeout(t,e):(t.call(null),null))((()=>{this.refreshTimeout=null,this._onInput()}),this.settings.refreshThrottle)):this._onInput())}_onInput(){const t=this.lastValue
|
214
|
+
this.settings.shouldLoad.call(this,t)&&this.load(t),this.refreshOptions(),this.trigger("type",t)}onOptionHover(t,e){this.ignoreHover||this.setActiveOption(e,!1)}onFocus(t){var e=this,i=e.isFocused
|
215
|
+
if(e.isDisabled||e.isReadOnly)return e.blur(),void it(t)
|
216
|
+
e.ignoreFocus||(e.isFocused=!0,"focus"===e.settings.preload&&e.preload(),i||e.trigger("focus"),e.activeItems.length||(e.inputState(),e.refreshOptions(!!e.settings.openOnFocus)),e.refreshState())}onBlur(t){if(!1!==document.hasFocus()){var e=this
|
213
217
|
if(e.isFocused){e.isFocused=!1,e.ignoreFocus=!1
|
214
218
|
var i=()=>{e.close(),e.setActiveItem(),e.setCaret(e.items.length),e.trigger("blur")}
|
215
219
|
e.settings.create&&e.settings.createOnBlur?e.createItem(null,i):i()}}}onOptionSelect(t,e){var i,s=this
|
216
220
|
e.parentElement&&e.parentElement.matches("[data-disabled]")||(e.classList.contains("create")?s.createItem(null,(()=>{s.settings.closeAfterSelect&&s.close()})):void 0!==(i=e.dataset.value)&&(s.lastQuery=null,s.addItem(i),s.settings.closeAfterSelect&&s.close(),!s.settings.hideSelected&&t.type&&/click/.test(t.type)&&s.setActiveOption(e)))}canSelect(t){return!!(this.isOpen&&t&&this.dropdown_content.contains(t))}onItemSelect(t,e){var i=this
|
217
221
|
return!i.isLocked&&"multi"===i.settings.mode&&(it(t),i.setActiveItem(e,t),!0)}canLoad(t){return!!this.settings.load&&!this.loadedSearches.hasOwnProperty(t)}load(t){const e=this
|
218
222
|
if(!e.canLoad(t))return
|
219
|
-
|
223
|
+
R(e.wrapper,e.settings.loadingClass),e.loading++
|
220
224
|
const i=e.loadCallback.bind(e)
|
221
225
|
e.settings.load.call(e,t,i)}loadCallback(t,e){const i=this
|
222
|
-
i.loading=Math.max(i.loading-1,0),i.lastQuery=null,i.clearActiveOption(),i.setupOptions(t,e),i.refreshOptions(i.isFocused&&!i.isInputHidden),i.loading||
|
226
|
+
i.loading=Math.max(i.loading-1,0),i.lastQuery=null,i.clearActiveOption(),i.setupOptions(t,e),i.refreshOptions(i.isFocused&&!i.isInputHidden),i.loading||N(i.wrapper,i.settings.loadingClass),i.trigger("load",t,e)}preload(){var t=this.wrapper.classList
|
223
227
|
t.contains("preloaded")||(t.add("preloaded"),this.load(""))}setTextboxValue(t=""){var e=this.control_input
|
224
228
|
e.value!==t&&(e.value=t,q(e,"update"),this.lastValue=t)}getValue(){return this.is_select_tag&&this.input.hasAttribute("multiple")?this.items:this.items.join(this.settings.delimiter)}setValue(t,e){et(this,e?[]:["change"],(()=>{this.clear(e),this.addItems(t,e)}))}setMaxItems(t){0===t&&(t=null),this.settings.maxItems=t,this.refreshState()}setActiveItem(t,e){var i,s,n,o,r,l,a=this
|
225
|
-
if("single"!==a.settings.mode){if(!t)return a.clearActiveItems(),void(a.isFocused&&a.
|
229
|
+
if("single"!==a.settings.mode){if(!t)return a.clearActiveItems(),void(a.isFocused&&a.inputState())
|
226
230
|
if("click"===(i=e&&e.type.toLowerCase())&&nt("shiftKey",e)&&a.activeItems.length){for(l=a.getLastActive(),(n=Array.prototype.indexOf.call(a.control.children,l))>(o=Array.prototype.indexOf.call(a.control.children,t))&&(r=n,n=o,o=r),s=n;s<=o;s++)t=a.control.children[s],-1===a.activeItems.indexOf(t)&&a.setActiveItemClass(t)
|
227
231
|
it(e)}else"click"===i&&nt(U,e)||"keydown"===i&&nt("shiftKey",e)?t.classList.contains("active")?a.removeActiveItem(t):a.setActiveItemClass(t):(a.clearActiveItems(),a.setActiveItemClass(t))
|
228
|
-
a.
|
229
|
-
i&&
|
230
|
-
this.activeItems.splice(e,1),
|
232
|
+
a.inputState(),a.isFocused||a.focus()}}setActiveItemClass(t){const e=this,i=e.control.querySelector(".last-active")
|
233
|
+
i&&N(i,"last-active"),R(t,"active last-active"),e.trigger("item_select",t),-1==e.activeItems.indexOf(t)&&e.activeItems.push(t)}removeActiveItem(t){var e=this.activeItems.indexOf(t)
|
234
|
+
this.activeItems.splice(e,1),N(t,"active")}clearActiveItems(){N(this.activeItems,"active"),this.activeItems=[]}setActiveOption(t,e=!0){t!==this.activeOption&&(this.clearActiveOption(),t&&(this.activeOption=t,Q(this.focus_node,{"aria-activedescendant":t.getAttribute("id")}),Q(t,{"aria-selected":"true"}),R(t,"active"),e&&this.scrollToOption(t)))}scrollToOption(t,e){if(!t)return
|
231
235
|
const i=this.dropdown_content,s=i.clientHeight,n=i.scrollTop||0,o=t.offsetHeight,r=t.getBoundingClientRect().top-i.getBoundingClientRect().top+n
|
232
236
|
r+o>s+n?this.scroll(r-s+o,e):r<n&&this.scroll(r,e)}scroll(t,e){const i=this.dropdown_content
|
233
|
-
e&&(i.style.scrollBehavior=e),i.scrollTop=t,i.style.scrollBehavior=""}clearActiveOption(){this.activeOption&&(
|
237
|
+
e&&(i.style.scrollBehavior=e),i.scrollTop=t,i.style.scrollBehavior=""}clearActiveOption(){this.activeOption&&(N(this.activeOption,"active"),Q(this.activeOption,{"aria-selected":null})),this.activeOption=null,Q(this.focus_node,{"aria-activedescendant":null})}selectAll(){const t=this
|
234
238
|
if("single"===t.settings.mode)return
|
235
239
|
const e=t.controlChildren()
|
236
|
-
e.length&&(t.
|
237
|
-
t.control.contains(t.control_input)&&(Q(t.control_input,{placeholder:t.settings.placeholder}),t.activeItems.length>0||!t.isFocused&&t.settings.hidePlaceholder&&t.items.length>0?(t.setTextboxValue(),t.isInputHidden=!0):(t.settings.hidePlaceholder&&t.items.length>0&&Q(t.control_input,{placeholder:""}),t.isInputHidden=!1),t.wrapper.classList.toggle("input-hidden",t.isInputHidden))}
|
238
|
-
t.isDisabled||(t.ignoreFocus=!0,t.control_input.offsetWidth?t.control_input.focus():t.focus_node.focus(),setTimeout((()=>{t.ignoreFocus=!1,t.onFocus()}),0))}blur(){this.focus_node.blur(),this.onBlur()}getScoreFunction(t){return this.sifter.getScoreFunction(t,this.getSearchOptions())}getSearchOptions(){var t=this.settings,e=t.sortField
|
240
|
+
e.length&&(t.inputState(),t.close(),t.activeItems=e,E(e,(e=>{t.setActiveItemClass(e)})))}inputState(){var t=this
|
241
|
+
t.control.contains(t.control_input)&&(Q(t.control_input,{placeholder:t.settings.placeholder}),t.activeItems.length>0||!t.isFocused&&t.settings.hidePlaceholder&&t.items.length>0?(t.setTextboxValue(),t.isInputHidden=!0):(t.settings.hidePlaceholder&&t.items.length>0&&Q(t.control_input,{placeholder:""}),t.isInputHidden=!1),t.wrapper.classList.toggle("input-hidden",t.isInputHidden))}inputValue(){return this.control_input.value.trim()}focus(){var t=this
|
242
|
+
t.isDisabled||t.isReadOnly||(t.ignoreFocus=!0,t.control_input.offsetWidth?t.control_input.focus():t.focus_node.focus(),setTimeout((()=>{t.ignoreFocus=!1,t.onFocus()}),0))}blur(){this.focus_node.blur(),this.onBlur()}getScoreFunction(t){return this.sifter.getScoreFunction(t,this.getSearchOptions())}getSearchOptions(){var t=this.settings,e=t.sortField
|
239
243
|
return"string"==typeof t.sortField&&(e=[{field:t.sortField}]),{fields:t.searchField,conjunction:t.searchConjunction,sort:e,nesting:t.nesting}}search(t){var e,i,s=this,n=this.getSearchOptions()
|
240
244
|
if(s.settings.score&&"function"!=typeof(i=s.settings.score.call(s,t)))throw new Error('Tom Select "score" setting must be a function that returns a function')
|
241
245
|
return t!==s.lastQuery?(s.lastQuery=t,e=s.sifter.search(t,Object.assign(n,{score:i})),s.currentResults=e):e=Object.assign({},s.currentResults),s.settings.hideSelected&&(e.items=e.items.filter((t=>{let e=X(t.id)
|
@@ -243,28 +247,35 @@ return!(e&&-1!==s.items.indexOf(e))}))),e}refreshOptions(t=!0){var e,i,s,n,o,r,l
|
|
243
247
|
const u={},p=[]
|
244
248
|
var h=this,g=h.inputValue()
|
245
249
|
const f=g===h.lastQuery||""==g&&null==h.lastQuery
|
246
|
-
var v
|
247
|
-
|
250
|
+
var v=h.search(g),m=null,y=h.settings.shouldOpen||!1,O=h.dropdown_content
|
251
|
+
f&&(m=h.activeOption)&&(c=m.closest("[data-group]")),n=v.items.length,"number"==typeof h.settings.maxOptions&&(n=Math.min(n,h.settings.maxOptions)),n>0&&(y=!0)
|
252
|
+
const b=(t,e)=>{let i=u[t]
|
253
|
+
if(void 0!==i){let t=p[i]
|
254
|
+
if(void 0!==t)return[i,t.fragment]}let s=document.createDocumentFragment()
|
255
|
+
return i=p.length,p.push({fragment:s,order:e,optgroup:t}),[i,s]}
|
256
|
+
for(e=0;e<n;e++){let t=v.items[e]
|
248
257
|
if(!t)continue
|
249
258
|
let n=t.id,l=h.options[n]
|
250
259
|
if(void 0===l)continue
|
251
260
|
let a=Y(n),d=h.getOption(a,!0)
|
252
|
-
for(h.settings.hideSelected||d.classList.toggle("selected",h.items.includes(a)),o=l[h.settings.optgroupField]||"",i=0,s=(r=Array.isArray(o)?o:[o])&&r.length;i<s;i++){o=r[i]
|
253
|
-
let t=
|
254
|
-
void 0===
|
255
|
-
|
261
|
+
for(h.settings.hideSelected||d.classList.toggle("selected",h.items.includes(a)),o=l[h.settings.optgroupField]||"",i=0,s=(r=Array.isArray(o)?o:[o])&&r.length;i<s;i++){o=r[i]
|
262
|
+
let t=l.$order,e=h.optgroups[o]
|
263
|
+
void 0===e?o="":t=e.$order
|
264
|
+
const[s,a]=b(o,t)
|
265
|
+
i>0&&(d=d.cloneNode(!0),Q(d,{id:l.$id+"-clone-"+i,"aria-selected":null}),d.classList.add("ts-cloned"),N(d,"active"),h.activeOption&&h.activeOption.dataset.value==n&&c&&c.dataset.group===o.toString()&&(m=d)),a.appendChild(d),""!=o&&(u[o]=s)}}var w
|
266
|
+
h.settings.lockOptgroupOrder&&p.sort(((t,e)=>t.order-e.order)),l=document.createDocumentFragment(),E(p,(t=>{let e=t.fragment,i=t.optgroup
|
256
267
|
if(!e||!e.children.length)return
|
257
|
-
let
|
258
|
-
if(void 0!==
|
259
|
-
lt(t,
|
260
|
-
let n=h.render("optgroup",{group:
|
261
|
-
lt(l,n)}else lt(l,e)})),
|
262
|
-
e.replaceChild(t.firstChild,t),e.normalize()})),
|
263
|
-
var
|
264
|
-
return e&&(
|
265
|
-
if(h.loading?
|
266
|
-
d&&!h.settings.addPrecedence&&(t=1),
|
267
|
-
t&&!h.isOpen&&(h.open(),h.scrollToOption(
|
268
|
+
let s=h.optgroups[i]
|
269
|
+
if(void 0!==s){let t=document.createDocumentFragment(),i=h.render("optgroup_header",s)
|
270
|
+
lt(t,i),lt(t,e)
|
271
|
+
let n=h.render("optgroup",{group:s,options:t})
|
272
|
+
lt(l,n)}else lt(l,e)})),O.innerHTML="",lt(O,l),h.settings.highlight&&(w=O.querySelectorAll("span.highlight"),Array.prototype.forEach.call(w,(function(t){var e=t.parentNode
|
273
|
+
e.replaceChild(t.firstChild,t),e.normalize()})),v.query.length&&v.tokens.length&&E(v.tokens,(t=>{J(O,t.regex)})))
|
274
|
+
var _=t=>{let e=h.render(t,{input:g})
|
275
|
+
return e&&(y=!0,O.insertBefore(e,O.firstChild)),e}
|
276
|
+
if(h.loading?_("loading"):h.settings.shouldLoad.call(h,g)?0===v.items.length&&_("no_results"):_("not_loading"),(a=h.canCreate(g))&&(d=_("option_create")),h.hasOptions=v.items.length>0||a,y){if(v.items.length>0){if(m||"single"!==h.settings.mode||null==h.items[0]||(m=h.getOption(h.items[0])),!O.contains(m)){let t=0
|
277
|
+
d&&!h.settings.addPrecedence&&(t=1),m=h.selectable()[t]}}else d&&(m=d)
|
278
|
+
t&&!h.isOpen&&(h.open(),h.scrollToOption(m,"auto")),h.setActiveOption(m)}else h.clearActiveOption(),t&&h.isOpen&&h.close(!1)}selectable(){return this.dropdown_content.querySelectorAll("[data-selectable]")}addOption(t,e=!1){const i=this
|
268
279
|
if(Array.isArray(t))return i.addOptions(t,e),!1
|
269
280
|
const s=X(t[i.settings.valueField])
|
270
281
|
return null!==s&&!i.options.hasOwnProperty(s)&&(t.$order=t.$order||++i.order,t.$id=i.inputId+"-opt-"+t.$order,i.options[s]=t,i.lastQuery=null,e&&(i.userOptions[s]=e,i.trigger("option_add",s,t)),s)}addOptions(t,e=!1){E(t,(t=>{this.addOption(t,e)}))}registerOption(t){return this.addOption(t)}registerOptionGroup(t){var e=X(t[this.settings.optgroupValueField])
|
@@ -278,7 +289,7 @@ if(null==l)return
|
|
278
289
|
if("string"!=typeof r)throw new Error("Value must be set in option data")
|
279
290
|
const a=i.getOption(o),c=i.getItem(o)
|
280
291
|
if(e.$order=e.$order||l.$order,delete i.options[o],i.uncacheValue(r),i.options[r]=e,a){if(i.dropdown_content.contains(a)){const t=i._render("option",e)
|
281
|
-
G(a,t),i.activeOption===a&&i.setActiveOption(t)}a.remove()}c&&(-1!==(n=i.items.indexOf(o))&&i.items.splice(n,1,r),s=i._render("item",e),c.classList.contains("active")&&
|
292
|
+
G(a,t),i.activeOption===a&&i.setActiveOption(t)}a.remove()}c&&(-1!==(n=i.items.indexOf(o))&&i.items.splice(n,1,r),s=i._render("item",e),c.classList.contains("active")&&R(s,"active"),G(c,s)),i.lastQuery=null}removeOption(t,e){const i=this
|
282
293
|
t=Y(t),i.uncacheValue(t),delete i.userOptions[t],delete i.options[t],i.lastQuery=null,i.trigger("option_remove",t),i.removeItem(t,e)}clearOptions(t){const e=(t||this.clearFilter).bind(this)
|
283
294
|
this.loadedSearches={},this.userOptions={},this.clearCache()
|
284
295
|
const i={}
|
@@ -301,7 +312,7 @@ e&&n.setActiveOption(e)}n.isPending||n.settings.closeAfterSelect||n.refreshOptio
|
|
301
312
|
if(!(t=i.getItem(t)))return
|
302
313
|
var s,n
|
303
314
|
const o=t.dataset.value
|
304
|
-
s=K(t),t.remove(),t.classList.contains("active")&&(n=i.activeItems.indexOf(t),i.activeItems.splice(n,1),
|
315
|
+
s=K(t),t.remove(),t.classList.contains("active")&&(n=i.activeItems.indexOf(t),i.activeItems.splice(n,1),N(t,"active")),i.items.splice(s,1),i.lastQuery=null,!i.settings.persist&&i.userOptions.hasOwnProperty(o)&&i.removeOption(o,e),s<i.caretPos&&i.setCaret(i.caretPos-1),i.updateOriginalInput({silent:e}),i.refreshState(),i.positionDropdown(),i.trigger("item_remove",o,t)}createItem(t=null,e=(()=>{})){3===arguments.length&&(e=arguments[2]),"function"!=typeof e&&(e=()=>{})
|
305
316
|
var i,s=this,n=s.caretPos
|
306
317
|
if(t=t||s.inputValue(),!s.canCreate(t))return e(),!1
|
307
318
|
s.lock()
|
@@ -316,18 +327,18 @@ const e=t.isFull(),i=t.isLocked
|
|
316
327
|
t.wrapper.classList.toggle("rtl",t.rtl)
|
317
328
|
const s=t.wrapper.classList
|
318
329
|
var n
|
319
|
-
s.toggle("focus",t.isFocused),s.toggle("disabled",t.isDisabled),s.toggle("required",t.isRequired),s.toggle("invalid",!t.isValid),s.toggle("locked",i),s.toggle("full",e),s.toggle("input-active",t.isFocused&&!t.isInputHidden),s.toggle("dropdown-active",t.isOpen),s.toggle("has-options",(n=t.options,0===Object.keys(n).length)),s.toggle("has-items",t.items.length>0)}refreshValidityState(){var t=this
|
330
|
+
s.toggle("focus",t.isFocused),s.toggle("disabled",t.isDisabled),s.toggle("readonly",t.isReadOnly),s.toggle("required",t.isRequired),s.toggle("invalid",!t.isValid),s.toggle("locked",i),s.toggle("full",e),s.toggle("input-active",t.isFocused&&!t.isInputHidden),s.toggle("dropdown-active",t.isOpen),s.toggle("has-options",(n=t.options,0===Object.keys(n).length)),s.toggle("has-items",t.items.length>0)}refreshValidityState(){var t=this
|
320
331
|
t.input.validity&&(t.isValid=t.input.validity.valid,t.isInvalid=!t.isValid)}isFull(){return null!==this.settings.maxItems&&this.items.length>=this.settings.maxItems}updateOriginalInput(t={}){const e=this
|
321
332
|
var i,s
|
322
333
|
const n=e.input.querySelector('option[value=""]')
|
323
|
-
if(e.is_select_tag){const
|
324
|
-
function
|
334
|
+
if(e.is_select_tag){const o=[],r=e.input.querySelectorAll("option:checked").length
|
335
|
+
function l(t,i,s){return t||(t=j('<option value="'+Z(i)+'">'+Z(s)+"</option>")),t!=n&&e.input.append(t),o.push(t),(t!=n||r>0)&&(t.selected=!0),t}e.input.querySelectorAll("option:checked").forEach((t=>{t.selected=!1})),0==e.items.length&&"single"==e.settings.mode?l(n,"",""):e.items.forEach((t=>{if(i=e.options[t],s=i[e.settings.labelField]||"",o.includes(i.$option)){l(e.input.querySelector(`option[value="${rt(t)}"]:not(:checked)`),t,s)}else i.$option=l(i.$option,t,s)}))}else e.input.value=e.getValue()
|
325
336
|
e.isSetup&&(t.silent||e.trigger("change",e.getValue()))}open(){var t=this
|
326
337
|
t.isLocked||t.isOpen||"multi"===t.settings.mode&&t.isFull()||(t.isOpen=!0,Q(t.focus_node,{"aria-expanded":"true"}),t.refreshState(),D(t.dropdown,{visibility:"hidden",display:"block"}),t.positionDropdown(),D(t.dropdown,{visibility:"visible",display:"block"}),t.focus(),t.trigger("dropdown_open",t.dropdown))}close(t=!0){var e=this,i=e.isOpen
|
327
|
-
t&&(e.setTextboxValue(),"single"===e.settings.mode&&e.items.length&&e.
|
338
|
+
t&&(e.setTextboxValue(),"single"===e.settings.mode&&e.items.length&&e.inputState()),e.isOpen=!1,Q(e.focus_node,{"aria-expanded":"false"}),D(e.dropdown,{display:"none"}),e.settings.hideSelected&&e.clearActiveOption(),e.refreshState(),i&&e.trigger("dropdown_close",e.dropdown)}positionDropdown(){if("body"===this.settings.dropdownParent){var t=this.control,e=t.getBoundingClientRect(),i=t.offsetHeight+e.top+window.scrollY,s=e.left+window.scrollX
|
328
339
|
D(this.dropdown,{width:e.width+"px",top:i+"px",left:s+"px"})}}clear(t){var e=this
|
329
340
|
if(e.items.length){var i=e.controlChildren()
|
330
|
-
E(i,(t=>{e.removeItem(t,!0)})),e.
|
341
|
+
E(i,(t=>{e.removeItem(t,!0)})),e.inputState(),t||e.updateOriginalInput(),e.trigger("clear")}}insertAtCaret(t){const e=this,i=e.caretPos,s=e.control
|
331
342
|
s.insertBefore(t,s.children[i]||null),e.setCaret(i+1)}deleteSelection(t){var e,i,s,n,o,r=this
|
332
343
|
e=t&&8===t.keyCode?-1:1,i={start:(o=r.control_input).selectionStart||0,length:(o.selectionEnd||0)-(o.selectionStart||0)}
|
333
344
|
const l=[]
|
@@ -336,20 +347,18 @@ else if((r.isFocused||"single"===r.settings.mode)&&r.items.length){const t=r.con
|
|
336
347
|
let s
|
337
348
|
e<0&&0===i.start&&0===i.length?s=t[r.caretPos-1]:e>0&&i.start===r.inputValue().length&&(s=t[r.caretPos]),void 0!==s&&l.push(s)}if(!r.shouldDelete(l,t))return!1
|
338
349
|
for(it(t,!0),void 0!==s&&r.setCaret(s);l.length;)r.removeItem(l.pop())
|
339
|
-
return r.
|
350
|
+
return r.inputState(),r.positionDropdown(),r.refreshOptions(!1),!0}shouldDelete(t,e){const i=t.map((t=>t.dataset.value))
|
340
351
|
return!(!i.length||"function"==typeof this.settings.onDelete&&!1===this.settings.onDelete(i,e))}advanceSelection(t,e){var i,s,n=this
|
341
352
|
n.rtl&&(t*=-1),n.inputValue().length||(nt(U,e)||nt("shiftKey",e)?(s=(i=n.getLastActive(t))?i.classList.contains("active")?n.getAdjacent(i,t,"item"):i:t>0?n.control_input.nextElementSibling:n.control_input.previousElementSibling)&&(s.classList.contains("active")&&n.removeActiveItem(i),n.setActiveItemClass(s)):n.moveCaret(t))}moveCaret(t){}getLastActive(t){let e=this.control.querySelector(".last-active")
|
342
353
|
if(e)return e
|
343
354
|
var i=this.control.querySelectorAll(".active")
|
344
|
-
return i?B(i,t):void 0}setCaret(t){this.caretPos=this.items.length}controlChildren(){return Array.from(this.control.querySelectorAll("[data-ts-item]"))}lock(){this.
|
345
|
-
t.
|
346
|
-
t.input.disabled=!1,t.control_input.disabled=!1,t.focus_node.tabIndex=t.tabIndex,t.isDisabled=!1,t.unlock()}destroy(){var t=this,e=t.revertSettings
|
347
|
-
t.trigger("destroy"),t.off(),t.wrapper.remove(),t.dropdown.remove(),t.input.innerHTML=e.innerHTML,t.input.tabIndex=e.tabIndex,H(t.input,"tomselected","ts-hidden-accessible"),t._destroy(),delete t.input.tomselect}render(t,e){var i,s
|
355
|
+
return i?B(i,t):void 0}setCaret(t){this.caretPos=this.items.length}controlChildren(){return Array.from(this.control.querySelectorAll("[data-ts-item]"))}lock(){this.setLocked(!0)}unlock(){this.setLocked(!1)}setLocked(t=this.isReadOnly||this.isDisabled){this.isLocked=t,this.refreshState()}disable(){this.setDisabled(!0),this.close()}enable(){this.setDisabled(!1)}setDisabled(t){this.focus_node.tabIndex=t?-1:this.tabIndex,this.isDisabled=t,this.input.disabled=t,this.control_input.disabled=t,this.setLocked()}setReadOnly(t){this.isReadOnly=t,this.input.readOnly=t,this.control_input.readOnly=t,this.setLocked()}destroy(){var t=this,e=t.revertSettings
|
356
|
+
t.trigger("destroy"),t.off(),t.wrapper.remove(),t.dropdown.remove(),t.input.innerHTML=e.innerHTML,t.input.tabIndex=e.tabIndex,N(t.input,"tomselected","ts-hidden-accessible"),t._destroy(),delete t.input.tomselect}render(t,e){var i,s
|
348
357
|
const n=this
|
349
358
|
if("function"!=typeof this.settings.render[t])return null
|
350
359
|
if(!(s=n.settings.render[t].call(this,e,Z)))return null
|
351
|
-
if(s=
|
352
|
-
Q(s,{"data-value":i}),"item"===t?(
|
360
|
+
if(s=j(s),"option"===t||"option_create"===t?e[n.settings.disabledField]?Q(s,{"aria-disabled":"true"}):Q(s,{"data-selectable":""}):"optgroup"===t&&(i=e.group[n.settings.optgroupValueField],Q(s,{"data-group":i}),e.group[n.settings.disabledField]&&Q(s,{"data-disabled":""})),"option"===t||"item"===t){const i=Y(e[n.settings.valueField])
|
361
|
+
Q(s,{"data-value":i}),"item"===t?(R(s,n.settings.itemClass),Q(s,{"data-ts-item":""})):(R(s,n.settings.optionClass),Q(s,{role:"option",id:e.$id}),e.$div=s,n.options[i]=e)}return s}_render(t,e){const i=this.render(t,e)
|
353
362
|
if(null==i)throw"HTMLElement expected"
|
354
363
|
return i}clearCache(){E(this.options,(t=>{t.$div&&(t.$div.remove(),delete t.$div)}))}uncacheValue(t){const e=this.getOption(t)
|
355
364
|
e&&e.remove()}canCreate(t){return this.settings.create&&t.length>0&&this.settings.createFilter.call(this,t)}hook(t,e,i){var s=this,n=s[e]
|
@@ -358,11 +367,11 @@ return"after"===t&&(e=n.apply(s,arguments)),o=i.apply(s,arguments),"instead"===t
|
|
358
367
|
t.hook("instead","setCaret",(e=>{"single"!==t.settings.mode&&t.control.contains(t.control_input)?(e=Math.max(0,Math.min(t.items.length,e)))==t.caretPos||t.isPending||t.controlChildren().forEach(((i,s)=>{s<e?t.control_input.insertAdjacentElement("beforebegin",i):t.control.appendChild(i)})):e=t.items.length,t.caretPos=e})),t.hook("instead","moveCaret",(e=>{if(!t.isFocused)return
|
359
368
|
const i=t.getLastActive(e)
|
360
369
|
if(i){const s=K(i)
|
361
|
-
t.setCaret(e>0?s+1:s),t.setActiveItem(),
|
362
|
-
t.settings.shouldOpen=!0,t.hook("before","setup",(()=>{t.focus_node=t.control,
|
363
|
-
const e=
|
370
|
+
t.setCaret(e>0?s+1:s),t.setActiveItem(),N(i,"last-active")}else t.setCaret(t.caretPos+e)}))})),dt.define("dropdown_input",(function(){const t=this
|
371
|
+
t.settings.shouldOpen=!0,t.hook("before","setup",(()=>{t.focus_node=t.control,R(t.control_input,"dropdown-input")
|
372
|
+
const e=j('<div class="dropdown-input-wrap">')
|
364
373
|
e.append(t.control_input),t.dropdown.insertBefore(e,t.dropdown.firstChild)
|
365
|
-
const i=
|
374
|
+
const i=j('<input class="items-placeholder" tabindex="-1" />')
|
366
375
|
i.placeholder=t.settings.placeholder||"",t.control.append(i)})),t.on("initialize",(()=>{t.control_input.addEventListener("keydown",(e=>{switch(e.keyCode){case 27:return t.isOpen&&(it(e,!0),t.close()),void t.clearActiveItems()
|
367
376
|
case 9:t.focus_node.tabIndex=-1}return t.onKeyDown.call(t,e)})),t.on("blur",(()=>{t.focus_node.tabIndex=t.isDisabled?-1:t.tabIndex})),t.on("dropdown_open",(()=>{t.control_input.focus()}))
|
368
377
|
const e=t.onBlur
|
@@ -371,8 +380,8 @@ this.hook("instead","deleteSelection",(i=>!!t.activeItems.length&&e.call(t,i)))}
|
|
371
380
|
var i=this
|
372
381
|
if(e.append){var s='<a href="javascript:void(0)" class="'+e.className+'" tabindex="-1" title="'+Z(e.title)+'">'+e.label+"</a>"
|
373
382
|
i.hook("after","setupTemplates",(()=>{var t=i.settings.render.item
|
374
|
-
i.settings.render.item=(e,n)=>{var o=
|
375
|
-
return o.appendChild(r),st(r,"mousedown",(t=>{it(t,!0)})),st(r,"click",(t=>{it(t,!0),i.isLocked||i.shouldDelete([o],t)&&(i.removeItem(o),i.refreshOptions(!1),i.inputState())})),o}}))}})),dt.define("restore_on_backspace",(function(t){const e=this,i=Object.assign({text:t=>t[e.settings.labelField]},t)
|
383
|
+
i.settings.render.item=(e,n)=>{var o=j(t.call(i,e,n)),r=j(s)
|
384
|
+
return o.appendChild(r),st(r,"mousedown",(t=>{it(t,!0)})),st(r,"click",(t=>{i.isLocked||(it(t,!0),i.isLocked||i.shouldDelete([o],t)&&(i.removeItem(o),i.refreshOptions(!1),i.inputState()))})),o}}))}})),dt.define("restore_on_backspace",(function(t){const e=this,i=Object.assign({text:t=>t[e.settings.labelField]},t)
|
376
385
|
e.on("item_remove",(function(t){if(e.isFocused&&""===e.control_input.value.trim()){var s=e.options[t]
|
377
386
|
s&&e.setTextboxValue(i.text.call(e,s))}}))})),dt}))
|
378
387
|
var tomSelect=function(t,e){return new TomSelect(t,e)}
|