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(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).TomSelect=t()}(this,(function(){"use strict"
|
@@ -22,18 +22,18 @@ let p,h
|
|
22
22
|
const g={},f={"/":"⁄∕",0:"߀",a:"ⱥɐɑ",aa:"ꜳ",ae:"æǽǣ",ao:"ꜵ",au:"ꜷ",av:"ꜹꜻ",ay:"ꜽ",b:"ƀɓƃ",c:"ꜿƈȼↄ",d:"đɗɖᴅƌꮷԁɦ",e:"ɛǝᴇɇ",f:"ꝼƒ",g:"ǥɠꞡᵹꝿɢ",h:"ħⱨⱶɥ",i:"ɨı",j:"ɉȷ",k:"ƙⱪꝁꝃꝅꞣ",l:"łƚɫⱡꝉꝇꞁɭ",m:"ɱɯϻ",n:"ꞥƞɲꞑᴎлԉ",o:"øǿɔɵꝋꝍᴑ",oe:"œ",oi:"ƣ",oo:"ꝏ",ou:"ȣ",p:"ƥᵽꝑꝓꝕρ",q:"ꝗꝙɋ",r:"ɍɽꝛꞧꞃ",s:"ßȿꞩꞅʂ",t:"ŧƭʈⱦꞇ",th:"þ",tz:"ꜩ",u:"ʉ",v:"ʋꝟʌ",vy:"ꝡ",w:"ⱳ",y:"ƴɏỿ",z:"ƶȥɀⱬꝣ",hv:"ƕ"}
|
23
23
|
for(let e in f){let t=f[e]||""
|
24
24
|
for(let i=0;i<t.length;i++){let s=t.substring(i,i+1)
|
25
|
-
g[s]=e}}const v=new RegExp(Object.keys(g).join("|")+"|[̀-ͯ·ʾʼ]","gu"),m=(e,t="NFKD")=>e.normalize(t),y=e=>c(e).reduce(((e,t)=>e+
|
26
|
-
const
|
25
|
+
g[s]=e}}const v=new RegExp(Object.keys(g).join("|")+"|[̀-ͯ·ʾʼ]","gu"),m=(e,t="NFKD")=>e.normalize(t),y=e=>c(e).reduce(((e,t)=>e+O(t)),""),O=e=>(e=m(e).toLowerCase().replace(v,(e=>g[e]||"")),m(e,"NFC"))
|
26
|
+
const b=e=>{const t={},i=(e,i)=>{const s=t[e]||new Set,o=new RegExp("^"+n(s)+"$","iu")
|
27
27
|
i.match(o)||(s.add(r(i)),t[e]=s)}
|
28
28
|
for(let t of function*(e){for(const[t,i]of e)for(let e=t;e<=i;e++){let t=String.fromCharCode(e),i=y(t)
|
29
29
|
i!=t.toLowerCase()&&(i.length>3||0!=i.length&&(yield{folded:i,composed:t,code_point:e}))}}(e))i(t.folded,t.folded),i(t.folded,t.composed)
|
30
|
-
return t},w=e=>{const t=
|
30
|
+
return t},w=e=>{const t=b(e),s={}
|
31
31
|
let o=[]
|
32
32
|
for(let e in t){let i=t[e]
|
33
33
|
i&&(s[e]=n(i)),e.length>1&&o.push(r(e))}o.sort(((e,t)=>t.length-e.length))
|
34
34
|
const l=i(o)
|
35
35
|
return h=new RegExp("^"+l,"u"),s},_=(e,t=1)=>(t=Math.max(t,e.length-1),i(d(e).map((e=>((e,t=1)=>{let i=0
|
36
|
-
return e=e.map((e=>(p[e]&&(i+=e.length),p[e]||e))),i>=t?s(e):""})(e,t))))),
|
36
|
+
return e=e.map((e=>(p[e]&&(i+=e.length),p[e]||e))),i>=t?s(e):""})(e,t))))),C=(e,t=!0)=>{let n=e.length>1?1:0
|
37
37
|
return i(e.map((e=>{let i=[]
|
38
38
|
const o=t?e.length():e.length()-1
|
39
39
|
for(let t=0;t<o;t++)i.push(_(e.substrs[t]||"",n))
|
@@ -44,12 +44,12 @@ const s=e=>{for(const i of t){if(i.start===e.start&&i.substr===e.substr)return!1
|
|
44
44
|
if(1!=e.length&&1!=i.length){if(e.start<i.start&&e.end>i.start)return!0
|
45
45
|
if(i.start<e.start&&i.end>e.start)return!0}}return!1}
|
46
46
|
if(!(i.parts.filter(s).length>0))return!0}return!1}
|
47
|
-
class
|
47
|
+
class I{constructor(){this.parts=[],this.substrs=[],this.start=0,this.end=0}add(e){e&&(this.parts.push(e),this.substrs.push(e.substr),this.start=Math.min(e.start,this.start),this.end=Math.max(e.end,this.end))}last(){return this.parts[this.parts.length-1]}length(){return this.parts.length}clone(e,t){let i=new I,s=JSON.parse(JSON.stringify(this.parts)),n=s.pop()
|
48
48
|
for(const e of s)i.add(e)
|
49
49
|
let o=t.substr.substring(0,e-n.start),r=o.length
|
50
50
|
return i.add({start:n.start,end:n.start+r,length:r,substr:o}),i}}const A=e=>{var t
|
51
51
|
void 0===p&&(p=w(t||u)),e=y(e)
|
52
|
-
let i="",s=[new
|
52
|
+
let i="",s=[new I]
|
53
53
|
for(let t=0;t<e.length;t++){let n=e.substring(t).match(h)
|
54
54
|
const o=e.substring(t,t+1),r=n?n[0]:null
|
55
55
|
let l=[],a=new Set
|
@@ -59,15 +59,15 @@ e.add({start:t,end:t+i,length:i,substr:r}),a.add("1")}else e.add({start:t,end:t+
|
|
59
59
|
else if(r){let s=e.clone(t,i)
|
60
60
|
const n=r.length
|
61
61
|
s.add({start:t,end:t+n,length:n,substr:r}),l.push(s)}else a.add("3")}if(l.length>0){l=l.sort(((e,t)=>e.length()-t.length()))
|
62
|
-
for(let e of l)S(e,s)||s.push(e)}else if(t>0&&1==a.size&&!a.has("3")){i+=
|
63
|
-
let e=new
|
62
|
+
for(let e of l)S(e,s)||s.push(e)}else if(t>0&&1==a.size&&!a.has("3")){i+=C(s,!1)
|
63
|
+
let e=new I
|
64
64
|
const t=s[0]
|
65
|
-
t&&e.add(t.last()),s=[e]}}return i+=
|
65
|
+
t&&e.add(t.last()),s=[e]}}return i+=C(s,!0),i},x=(e,t)=>{if(e)return e[t]},k=(e,t)=>{if(e){for(var i,s=t.split(".");(i=s.shift())&&(e=e[i]););return e}},F=(e,t,i)=>{var s,n
|
66
66
|
return e?(e+="",null==t.regex||-1===(n=e.search(t.regex))?0:(s=t.string.length/e.length,0===n&&(s+=.5),s*i)):0},L=(e,t)=>{var i=e[t]
|
67
67
|
if("function"==typeof i)return i
|
68
68
|
i&&!Array.isArray(i)&&(e[t]=[i])},E=(e,t)=>{if(Array.isArray(e))e.forEach(t)
|
69
|
-
else for(var i in e)e.hasOwnProperty(i)&&t(e[i],i)},
|
70
|
-
class
|
69
|
+
else for(var i in e)e.hasOwnProperty(i)&&t(e[i],i)},T=(e,t)=>"number"==typeof e&&"number"==typeof t?e>t?1:e<t?-1:0:(e=y(e+"").toLowerCase())>(t=y(t+"").toLowerCase())?1:t>e?-1:0
|
70
|
+
class P{constructor(e,t){this.items=void 0,this.settings=void 0,this.items=e,this.settings=t||{diacritics:!0}}tokenize(e,t,i){if(!e||!e.length)return[]
|
71
71
|
const s=[],n=e.split(/\s+/)
|
72
72
|
var o
|
73
73
|
return i&&(o=new RegExp("^("+Object.keys(i).map(r).join("|")+"):(.*)$")),n.forEach((e=>{let i,n=null,l=null
|
@@ -94,7 +94,7 @@ if(e.query){t=!0
|
|
94
94
|
for(let e of i)if("$score"===e.field){t=!1
|
95
95
|
break}t&&i.unshift({field:"$score",direction:"desc"})}else i=i.filter((e=>"$score"!==e.field))
|
96
96
|
return i.length?function(e,t){var s,n
|
97
|
-
for(let o of i){if(n=o.field,s=("desc"===o.direction?-1:1)*
|
97
|
+
for(let o of i){if(n=o.field,s=("desc"===o.direction?-1:1)*T(r(n,e),r(n,t)))return s}return 0}:null}prepareSearch(e,t){const i={}
|
98
98
|
var s=Object.assign({},t)
|
99
99
|
if(L(s,"sort"),L(s,"sort_empty"),s.fields){L(s,"fields")
|
100
100
|
const e=[]
|
@@ -103,17 +103,17 @@ s=this.prepareSearch(e,t),t=s.options,e=s.query
|
|
103
103
|
const o=t.score||n._getScoreFunction(s)
|
104
104
|
e.length?E(n.items,((e,n)=>{i=o(e),(!1===t.filter||i>0)&&s.items.push({score:i,id:n})})):E(n.items,((e,t)=>{s.items.push({score:1,id:t})}))
|
105
105
|
const r=n._getSortFunction(s)
|
106
|
-
return r&&s.items.sort(r),s.total=s.items.length,"number"==typeof t.limit&&(s.items=s.items.slice(0,t.limit)),s}}const
|
107
|
-
else for(var i in e)e.hasOwnProperty(i)&&t(e[i],i)},
|
106
|
+
return r&&s.items.sort(r),s.total=s.items.length,"number"==typeof t.limit&&(s.items=s.items.slice(0,t.limit)),s}}const N=(e,t)=>{if(Array.isArray(e))e.forEach(t)
|
107
|
+
else for(var i in e)e.hasOwnProperty(i)&&t(e[i],i)},j=e=>{if(e.jquery)return e[0]
|
108
108
|
if(e instanceof HTMLElement)return e
|
109
|
-
if(
|
110
|
-
return t.innerHTML=e.trim(),t.content.firstChild}return document.querySelector(e)}
|
111
|
-
i.initEvent(t,!0,!1),e.dispatchEvent(i)},
|
112
|
-
return
|
113
|
-
e=e.parentNode}},
|
109
|
+
if($(e)){var t=document.createElement("template")
|
110
|
+
return t.innerHTML=e.trim(),t.content.firstChild}return document.querySelector(e)},$=e=>"string"==typeof e&&e.indexOf("<")>-1,V=(e,t)=>{var i=document.createEvent("HTMLEvents")
|
111
|
+
i.initEvent(t,!0,!1),e.dispatchEvent(i)},q=(e,t)=>{Object.assign(e.style,t)},D=(e,...t)=>{var i=H(t);(e=M(e)).map((e=>{i.map((t=>{e.classList.add(t)}))}))},R=(e,...t)=>{var i=H(t);(e=M(e)).map((e=>{i.map((t=>{e.classList.remove(t)}))}))},H=e=>{var t=[]
|
112
|
+
return N(e,(e=>{"string"==typeof e&&(e=e.trim().split(/[\11\12\14\15\40]/)),Array.isArray(e)&&(t=t.concat(e))})),t.filter(Boolean)},M=e=>(Array.isArray(e)||(e=[e]),e),z=(e,t,i)=>{if(!i||i.contains(e))for(;e&&e.matches;){if(e.matches(t))return e
|
113
|
+
e=e.parentNode}},B=(e,t=0)=>t>0?e[e.length-1]:e[0],K=(e,t)=>{if(!e)return-1
|
114
114
|
t=t||e.nodeName
|
115
115
|
for(var i=0;e=e.previousElementSibling;)e.matches(t)&&i++
|
116
|
-
return i},
|
116
|
+
return i},Q=(e,t)=>{N(t,((t,i)=>{null==t?e.removeAttribute(i):e.setAttribute(i,""+t)}))},G=(e,t)=>{e.parentNode&&e.parentNode.replaceChild(t,e)},U=(e,t)=>{if(null===t)return
|
117
117
|
if("string"==typeof t){if(!t.length)return
|
118
118
|
t=new RegExp(t,"i")}const i=e=>3===e.nodeType?(e=>{var i=e.data.match(t)
|
119
119
|
if(i&&e.data.length>0){var s=document.createElement("span")
|
@@ -121,32 +121,35 @@ s.className="highlight"
|
|
121
121
|
var n=e.splitText(i.index)
|
122
122
|
n.splitText(i[0].length)
|
123
123
|
var o=n.cloneNode(!0)
|
124
|
-
return s.appendChild(o),
|
125
|
-
i(e)},
|
126
|
-
var
|
127
|
-
const
|
124
|
+
return s.appendChild(o),G(n,s),1}return 0})(e):((e=>{1!==e.nodeType||!e.childNodes||/(script|style)/i.test(e.tagName)||"highlight"===e.className&&"SPAN"===e.tagName||Array.from(e.childNodes).forEach((e=>{i(e)}))})(e),0)
|
125
|
+
i(e)},J="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,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(e){return e.length>0},render:{}}
|
127
|
+
const X=e=>null==e?null:Y(e),Y=e=>"boolean"==typeof e?e?"1":"0":e+"",Z=e=>(e+"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,"""),ee=(e,t)=>{var i
|
128
128
|
return function(s,n){var o=this
|
129
|
-
i&&(o.loading=Math.max(o.loading-1,0),clearTimeout(i)),i=setTimeout((function(){i=null,o.loadedSearches[s]=!0,e.call(o,s,n)}),t)}},
|
129
|
+
i&&(o.loading=Math.max(o.loading-1,0),clearTimeout(i)),i=setTimeout((function(){i=null,o.loadedSearches[s]=!0,e.call(o,s,n)}),t)}},te=(e,t,i)=>{var s,n=e.trigger,o={}
|
130
130
|
for(s of(e.trigger=function(){var i=arguments[0]
|
131
131
|
if(-1===t.indexOf(i))return n.apply(e,arguments)
|
132
|
-
o[i]=arguments},i.apply(e,[]),e.trigger=n,t))s in o&&n.apply(e,o[s])},
|
133
|
-
return i||(e.setAttribute("id",t),t)},
|
134
|
-
function
|
132
|
+
o[i]=arguments},i.apply(e,[]),e.trigger=n,t))s in o&&n.apply(e,o[s])},ie=(e,t=!1)=>{e&&(e.preventDefault(),t&&e.stopPropagation())},se=(e,t,i,s)=>{e.addEventListener(t,i,s)},ne=(e,t)=>!!t&&(!!t[e]&&1===(t.altKey?1:0)+(t.ctrlKey?1:0)+(t.shiftKey?1:0)+(t.metaKey?1:0)),oe=(e,t)=>{const i=e.getAttribute("id")
|
133
|
+
return i||(e.setAttribute("id",t),t)},re=e=>e.replace(/[\\"']/g,"\\$&"),le=(e,t)=>{t&&e.append(t)}
|
134
|
+
function ae(e,t){var i=Object.assign({},W,t),s=i.dataAttr,n=i.labelField,o=i.valueField,r=i.disabledField,l=i.optgroupField,a=i.optgroupLabelField,c=i.optgroupValueField,d=e.tagName.toLowerCase(),u=e.getAttribute("placeholder")||e.getAttribute("data-placeholder")
|
135
135
|
if(!u&&!i.allowEmptyOption){let t=e.querySelector('option[value=""]')
|
136
|
-
t&&(u=t.textContent)}var p
|
137
|
-
return"select"===d?(
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
136
|
+
t&&(u=t.textContent)}var p={placeholder:u,options:[],optgroups:[],items:[],maxItems:null}
|
137
|
+
return"select"===d?(()=>{var t,d=p.options,u={},h=1
|
138
|
+
let g=0
|
139
|
+
var f=e=>{var t=Object.assign({},e.dataset),i=s&&t[s]
|
140
|
+
return"string"==typeof i&&i.length&&(t=Object.assign(t,JSON.parse(i))),t},v=(e,t)=>{var s=X(e.value)
|
141
|
+
if(null!=s&&(s||i.allowEmptyOption)){if(u.hasOwnProperty(s)){if(t){var a=u[s][l]
|
142
|
+
a?Array.isArray(a)?a.push(t):u[s][l]=[a,t]:u[s][l]=t}}else{var c=f(e)
|
143
|
+
c[n]=c[n]||e.textContent,c[o]=c[o]||s,c[r]=c[r]||e.disabled,c[l]=c[l]||t,c.$option=e,c.$order=c.$order||++g,u[s]=c,d.push(c)}e.selected&&p.items.push(s)}}
|
144
|
+
p.maxItems=e.hasAttribute("multiple")?null:1,N(e.children,(e=>{var i,s,n
|
145
|
+
"optgroup"===(t=e.tagName.toLowerCase())?((n=f(i=e))[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],N(i.children,(e=>{v(e,s)}))):"option"===t&&v(e)}))})():(()=>{const t=e.getAttribute(s)
|
146
|
+
if(t)p.options=JSON.parse(t),N(p.options,(e=>{p.items.push(e[o])}))
|
144
147
|
else{var r=e.value.trim()||""
|
145
148
|
if(!i.allowEmptyOption&&!r.length)return
|
146
149
|
const t=r.split(i.delimiter)
|
147
|
-
|
148
|
-
t[n]=e,t[o]=e,
|
149
|
-
class
|
150
|
+
N(t,(e=>{const t={}
|
151
|
+
t[n]=e,t[o]=e,p.options.push(t)})),p.items=t}})(),Object.assign({},W,p,t)}var ce=0
|
152
|
+
class de extends(function(e){return e.plugins={},class extends e{constructor(...e){super(...e),this.plugins={names:[],settings:{},requested:{},loaded:{}}}static define(t,i){e.plugins[t]={name:t,fn:i}}initializePlugins(e){var t,i
|
150
153
|
const s=this,n=[]
|
151
154
|
if(Array.isArray(e))e.forEach((e=>{"string"==typeof e?n.push(e):(s.plugins.settings[e.name]=e.options,n.push(e.name))}))
|
152
155
|
else if(e)for(t in e)e.hasOwnProperty(t)&&(s.plugins.settings[t]=e[t],n.push(t))
|
@@ -155,134 +158,142 @@ if(!e.plugins.hasOwnProperty(t))throw new Error('Unable to find "'+t+'" plugin')
|
|
155
158
|
s.requested[t]=!0,s.loaded[t]=n.fn.apply(i,[i.plugins.settings[t]||{}]),s.names.push(t)}require(e){var t=this,i=t.plugins
|
156
159
|
if(!t.plugins.loaded.hasOwnProperty(e)){if(i.requested[e])throw new Error('Plugin has circular dependency ("'+e+'")')
|
157
160
|
t.loadPlugin(e)}return i.loaded[e]}}}(t)){constructor(e,t){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=[],
|
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,ce++
|
162
|
+
var s=j(e)
|
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
|
-
const n=
|
163
|
-
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=
|
165
|
+
const n=ae(s,t)
|
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=oe(s,"tomselect-"+ce),this.isRequired=s.required,this.sifter=new P(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=e=>o.test(e):n.createFilter=e=>this.settings.duplicates||!this.options[e]),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"],(e=>{s.getAttribute(e)&&
|
171
|
+
if(D(r,n.wrapperClass,d,u),D(l,n.controlClass),le(r,l),D(a,n.dropdownClass,u),n.copyClassesToDropdown&&D(a,d),D(c,n.dropdownContentClass),le(a,c),j(n.dropdownParent||r).appendChild(a),$(n.controlInput)){p=j(n.controlInput)
|
172
|
+
E(["autocorrect","autocapitalize","autocomplete","spellcheck"],(e=>{s.getAttribute(e)&&Q(p,{[e]:s.getAttribute(e)})})),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 e=this,t=e.settings,i=e.control_input,s=e.dropdown,n=e.dropdown_content,o=e.wrapper,l=e.control,a=e.input,c=e.focus_node,d={passive:!0},u=e.inputId+"-ts-dropdown"
|
171
|
-
|
172
|
-
const p=
|
173
|
-
if(g){
|
174
|
-
const t=
|
175
|
-
|
176
|
-
|
177
|
-
i&&e.onOptionHover(t,i)}),{capture:!0}),
|
178
|
-
i&&(e.onOptionSelect(t,i),
|
179
|
-
s&&e.onItemSelect(t,s)?
|
174
|
+
Q(n,{id:u}),Q(c,{role:"combobox","aria-haspopup":"listbox","aria-expanded":"false","aria-controls":u})
|
175
|
+
const p=oe(c,e.inputId+"-ts-control"),h="label[for='"+(e=>e.replace(/['"\\]/g,"\\$&"))(e.inputId)+"']",g=document.querySelector(h),f=e.focus.bind(e)
|
176
|
+
if(g){se(g,"click",f),Q(g,{for:p})
|
177
|
+
const t=oe(g,e.inputId+"-ts-label")
|
178
|
+
Q(c,{"aria-labelledby":t}),Q(n,{"aria-labelledby":t})}if(o.style.width=a.style.width,e.plugins.names.length){const t="plugin-"+e.plugins.names.join(" plugin-")
|
179
|
+
D([o,s],t)}(null===t.maxItems||t.maxItems>1)&&e.is_select_tag&&Q(a,{multiple:"multiple"}),t.placeholder&&Q(i,{placeholder:t.placeholder}),!t.splitOn&&t.delimiter&&(t.splitOn=new RegExp("\\s*"+r(t.delimiter)+"+\\s*")),t.load&&t.loadThrottle&&(t.load=ee(t.load,t.loadThrottle)),se(s,"mousemove",(()=>{e.ignoreHover=!1})),se(s,"mouseenter",(t=>{var i=z(t.target,"[data-selectable]",s)
|
180
|
+
i&&e.onOptionHover(t,i)}),{capture:!0}),se(s,"click",(t=>{const i=z(t.target,"[data-selectable]")
|
181
|
+
i&&(e.onOptionSelect(t,i),ie(t,!0))})),se(l,"click",(t=>{var s=z(t.target,"[data-ts-item]",l)
|
182
|
+
s&&e.onItemSelect(t,s)?ie(t,!0):""==i.value&&(e.onClick(),ie(t,!0))})),se(c,"keydown",(t=>e.onKeyDown(t))),se(i,"keypress",(t=>e.onKeyPress(t))),se(i,"input",(t=>e.onInput(t))),se(c,"blur",(t=>e.onBlur(t))),se(c,"focus",(t=>e.onFocus(t))),se(i,"paste",(t=>e.onPaste(t)))
|
180
183
|
const v=t=>{const n=t.composedPath()[0]
|
181
184
|
if(!o.contains(n)&&!s.contains(n))return e.isFocused&&e.blur(),void e.inputState()
|
182
|
-
n==i&&e.isOpen?t.stopPropagation():
|
183
|
-
|
185
|
+
n==i&&e.isOpen?t.stopPropagation():ie(t,!0)},m=()=>{e.isOpen&&e.positionDropdown()}
|
186
|
+
se(document,"mousedown",v),se(window,"scroll",m,d),se(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",e.wrapper),e.sync(!1),t.items=[],delete t.optgroups,delete t.options,se(a,"invalid",(()=>{e.isValid&&(e.isValid=!1,e.isInvalid=!0,e.refreshState())})),e.updateOriginalInput(),e.refreshItems(),e.close(!1),e.inputState(),e.isSetup=!0,a.disabled?e.disable():a.readOnly?e.setReadOnly(!0):e.enable(),e.on("change",this.onChange),D(a,"tomselected","ts-hidden-accessible"),e.trigger("initialize"),!0===t.preload&&e.preload()}setupOptions(e=[],t=[]){this.addOptions(e),E(t,(e=>{this.registerOptionGroup(e)}))}setupTemplates(){var e=this,t=e.settings.labelField,i=e.settings.optgroupLabelField,s={optgroup:e=>{let t=document.createElement("div")
|
184
187
|
return t.className="optgroup",t.appendChild(e.options),t},optgroup_header:(e,t)=>'<div class="optgroup-header">'+t(e[i])+"</div>",option:(e,i)=>"<div>"+i(e[t])+"</div>",item:(e,i)=>"<div>"+i(e[t])+"</div>",option_create:(e,t)=>'<div class="create">Add <strong>'+t(e.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
|
e.settings.render=Object.assign({},s,e.settings.render)}setupCallbacks(){var e,t,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
|
-
for(e in i)(t=this.settings[i[e]])&&this.on(e,t)}sync(e=!0){const t=this,i=e?
|
189
|
+
for(e in i)(t=this.settings[i[e]])&&this.on(e,t)}sync(e=!0){const t=this,i=e?ae(t.input,{delimiter:t.settings.delimiter}):t.settings
|
187
190
|
t.setupOptions(i.options,i.optgroups),t.setValue(i.items||[],!0),t.lastQuery=null}onClick(){var e=this
|
188
191
|
if(e.activeItems.length>0)return e.clearActiveItems(),void e.focus()
|
189
|
-
e.isFocused&&e.isOpen?e.blur():e.focus()}onMouseDown(){}onChange(){
|
190
|
-
t.isInputHidden||t.isLocked?
|
192
|
+
e.isFocused&&e.isOpen?e.blur():e.focus()}onMouseDown(){}onChange(){V(this.input,"input"),V(this.input,"change")}onPaste(e){var t=this
|
193
|
+
t.isInputHidden||t.isLocked?ie(e):t.settings.splitOn&&setTimeout((()=>{var e=t.inputValue()
|
191
194
|
if(e.match(t.settings.splitOn)){var i=e.trim().split(t.settings.splitOn)
|
192
|
-
E(i,(e=>{
|
195
|
+
E(i,(e=>{X(e)&&(this.options[e]?t.addItem(e):t.createItem(e))}))}}),0)}onKeyPress(e){var t=this
|
193
196
|
if(!t.isLocked){var i=String.fromCharCode(e.keyCode||e.which)
|
194
|
-
return t.settings.create&&"multi"===t.settings.mode&&i===t.settings.delimiter?(t.createItem(),void
|
195
|
-
if(t.ignoreHover=!0,t.isLocked)9!==e.keyCode&&
|
196
|
-
else{switch(e.keyCode){case 65:if(
|
197
|
+
return t.settings.create&&"multi"===t.settings.mode&&i===t.settings.delimiter?(t.createItem(),void ie(e)):void 0}ie(e)}onKeyDown(e){var t=this
|
198
|
+
if(t.ignoreHover=!0,t.isLocked)9!==e.keyCode&&ie(e)
|
199
|
+
else{switch(e.keyCode){case 65:if(ne(J,e)&&""==t.control_input.value)return ie(e),void t.selectAll()
|
197
200
|
break
|
198
|
-
case 27:return t.isOpen&&(
|
201
|
+
case 27:return t.isOpen&&(ie(e,!0),t.close()),void t.clearActiveItems()
|
199
202
|
case 40:if(!t.isOpen&&t.hasOptions)t.open()
|
200
203
|
else if(t.activeOption){let e=t.getAdjacent(t.activeOption,1)
|
201
|
-
e&&t.setActiveOption(e)}return void
|
204
|
+
e&&t.setActiveOption(e)}return void ie(e)
|
202
205
|
case 38:if(t.activeOption){let e=t.getAdjacent(t.activeOption,-1)
|
203
|
-
e&&t.setActiveOption(e)}return void
|
204
|
-
case 13:return void(t.canSelect(t.activeOption)?(t.onOptionSelect(e,t.activeOption),
|
206
|
+
e&&t.setActiveOption(e)}return void ie(e)
|
207
|
+
case 13:return void(t.canSelect(t.activeOption)?(t.onOptionSelect(e,t.activeOption),ie(e)):(t.settings.create&&t.createItem()||document.activeElement==t.control_input&&t.isOpen)&&ie(e))
|
205
208
|
case 37:return void t.advanceSelection(-1,e)
|
206
209
|
case 39:return void t.advanceSelection(1,e)
|
207
|
-
case 9:return void(t.settings.selectOnTab&&(t.canSelect(t.activeOption)&&(t.onOptionSelect(e,t.activeOption),
|
208
|
-
case 8:case 46:return void t.deleteSelection(e)}t.isInputHidden&&!
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
210
|
+
case 9:return void(t.settings.selectOnTab&&(t.canSelect(t.activeOption)&&(t.onOptionSelect(e,t.activeOption),ie(e)),t.settings.create&&t.createItem()&&ie(e)))
|
211
|
+
case 8:case 46:return void t.deleteSelection(e)}t.isInputHidden&&!ne(J,e)&&ie(e)}}onInput(e){if(this.isLocked)return
|
212
|
+
const t=this.inputValue()
|
213
|
+
this.lastValue!==t&&(this.lastValue=t,""!=t?(this.refreshTimeout&&clearTimeout(this.refreshTimeout),this.refreshTimeout=((e,t)=>t>0?setTimeout(e,t):(e.call(null),null))((()=>{this.refreshTimeout=null,this._onInput()}),this.settings.refreshThrottle)):this._onInput())}_onInput(){const e=this.lastValue
|
214
|
+
this.settings.shouldLoad.call(this,e)&&this.load(e),this.refreshOptions(),this.trigger("type",e)}onOptionHover(e,t){this.ignoreHover||this.setActiveOption(t,!1)}onFocus(e){var t=this,i=t.isFocused
|
215
|
+
if(t.isDisabled||t.isReadOnly)return t.blur(),void ie(e)
|
216
|
+
t.ignoreFocus||(t.isFocused=!0,"focus"===t.settings.preload&&t.preload(),i||t.trigger("focus"),t.activeItems.length||(t.inputState(),t.refreshOptions(!!t.settings.openOnFocus)),t.refreshState())}onBlur(e){if(!1!==document.hasFocus()){var t=this
|
213
217
|
if(t.isFocused){t.isFocused=!1,t.ignoreFocus=!1
|
214
218
|
var i=()=>{t.close(),t.setActiveItem(),t.setCaret(t.items.length),t.trigger("blur")}
|
215
219
|
t.settings.create&&t.settings.createOnBlur?t.createItem(null,i):i()}}}onOptionSelect(e,t){var i,s=this
|
216
220
|
t.parentElement&&t.parentElement.matches("[data-disabled]")||(t.classList.contains("create")?s.createItem(null,(()=>{s.settings.closeAfterSelect&&s.close()})):void 0!==(i=t.dataset.value)&&(s.lastQuery=null,s.addItem(i),s.settings.closeAfterSelect&&s.close(),!s.settings.hideSelected&&e.type&&/click/.test(e.type)&&s.setActiveOption(t)))}canSelect(e){return!!(this.isOpen&&e&&this.dropdown_content.contains(e))}onItemSelect(e,t){var i=this
|
217
|
-
return!i.isLocked&&"multi"===i.settings.mode&&(
|
221
|
+
return!i.isLocked&&"multi"===i.settings.mode&&(ie(e),i.setActiveItem(t,e),!0)}canLoad(e){return!!this.settings.load&&!this.loadedSearches.hasOwnProperty(e)}load(e){const t=this
|
218
222
|
if(!t.canLoad(e))return
|
219
|
-
|
223
|
+
D(t.wrapper,t.settings.loadingClass),t.loading++
|
220
224
|
const i=t.loadCallback.bind(t)
|
221
225
|
t.settings.load.call(t,e,i)}loadCallback(e,t){const i=this
|
222
|
-
i.loading=Math.max(i.loading-1,0),i.lastQuery=null,i.clearActiveOption(),i.setupOptions(e,t),i.refreshOptions(i.isFocused&&!i.isInputHidden),i.loading||
|
226
|
+
i.loading=Math.max(i.loading-1,0),i.lastQuery=null,i.clearActiveOption(),i.setupOptions(e,t),i.refreshOptions(i.isFocused&&!i.isInputHidden),i.loading||R(i.wrapper,i.settings.loadingClass),i.trigger("load",e,t)}preload(){var e=this.wrapper.classList
|
223
227
|
e.contains("preloaded")||(e.add("preloaded"),this.load(""))}setTextboxValue(e=""){var t=this.control_input
|
224
|
-
t.value!==e&&(t.value=e,
|
225
|
-
if("single"!==a.settings.mode){if(!e)return a.clearActiveItems(),void(a.isFocused&&a.
|
226
|
-
if("click"===(i=t&&t.type.toLowerCase())&&
|
227
|
-
|
228
|
-
a.
|
229
|
-
i&&
|
230
|
-
this.activeItems.splice(t,1),
|
228
|
+
t.value!==e&&(t.value=e,V(t,"update"),this.lastValue=e)}getValue(){return this.is_select_tag&&this.input.hasAttribute("multiple")?this.items:this.items.join(this.settings.delimiter)}setValue(e,t){te(this,t?[]:["change"],(()=>{this.clear(t),this.addItems(e,t)}))}setMaxItems(e){0===e&&(e=null),this.settings.maxItems=e,this.refreshState()}setActiveItem(e,t){var i,s,n,o,r,l,a=this
|
229
|
+
if("single"!==a.settings.mode){if(!e)return a.clearActiveItems(),void(a.isFocused&&a.inputState())
|
230
|
+
if("click"===(i=t&&t.type.toLowerCase())&&ne("shiftKey",t)&&a.activeItems.length){for(l=a.getLastActive(),(n=Array.prototype.indexOf.call(a.control.children,l))>(o=Array.prototype.indexOf.call(a.control.children,e))&&(r=n,n=o,o=r),s=n;s<=o;s++)e=a.control.children[s],-1===a.activeItems.indexOf(e)&&a.setActiveItemClass(e)
|
231
|
+
ie(t)}else"click"===i&&ne(J,t)||"keydown"===i&&ne("shiftKey",t)?e.classList.contains("active")?a.removeActiveItem(e):a.setActiveItemClass(e):(a.clearActiveItems(),a.setActiveItemClass(e))
|
232
|
+
a.inputState(),a.isFocused||a.focus()}}setActiveItemClass(e){const t=this,i=t.control.querySelector(".last-active")
|
233
|
+
i&&R(i,"last-active"),D(e,"active last-active"),t.trigger("item_select",e),-1==t.activeItems.indexOf(e)&&t.activeItems.push(e)}removeActiveItem(e){var t=this.activeItems.indexOf(e)
|
234
|
+
this.activeItems.splice(t,1),R(e,"active")}clearActiveItems(){R(this.activeItems,"active"),this.activeItems=[]}setActiveOption(e,t=!0){e!==this.activeOption&&(this.clearActiveOption(),e&&(this.activeOption=e,Q(this.focus_node,{"aria-activedescendant":e.getAttribute("id")}),Q(e,{"aria-selected":"true"}),D(e,"active"),t&&this.scrollToOption(e)))}scrollToOption(e,t){if(!e)return
|
231
235
|
const i=this.dropdown_content,s=i.clientHeight,n=i.scrollTop||0,o=e.offsetHeight,r=e.getBoundingClientRect().top-i.getBoundingClientRect().top+n
|
232
236
|
r+o>s+n?this.scroll(r-s+o,t):r<n&&this.scroll(r,t)}scroll(e,t){const i=this.dropdown_content
|
233
|
-
t&&(i.style.scrollBehavior=t),i.scrollTop=e,i.style.scrollBehavior=""}clearActiveOption(){this.activeOption&&(
|
237
|
+
t&&(i.style.scrollBehavior=t),i.scrollTop=e,i.style.scrollBehavior=""}clearActiveOption(){this.activeOption&&(R(this.activeOption,"active"),Q(this.activeOption,{"aria-selected":null})),this.activeOption=null,Q(this.focus_node,{"aria-activedescendant":null})}selectAll(){const e=this
|
234
238
|
if("single"===e.settings.mode)return
|
235
239
|
const t=e.controlChildren()
|
236
|
-
t.length&&(e.
|
237
|
-
e.control.contains(e.control_input)&&(
|
238
|
-
e.isDisabled||(e.ignoreFocus=!0,e.control_input.offsetWidth?e.control_input.focus():e.focus_node.focus(),setTimeout((()=>{e.ignoreFocus=!1,e.onFocus()}),0))}blur(){this.focus_node.blur(),this.onBlur()}getScoreFunction(e){return this.sifter.getScoreFunction(e,this.getSearchOptions())}getSearchOptions(){var e=this.settings,t=e.sortField
|
240
|
+
t.length&&(e.inputState(),e.close(),e.activeItems=t,E(t,(t=>{e.setActiveItemClass(t)})))}inputState(){var e=this
|
241
|
+
e.control.contains(e.control_input)&&(Q(e.control_input,{placeholder:e.settings.placeholder}),e.activeItems.length>0||!e.isFocused&&e.settings.hidePlaceholder&&e.items.length>0?(e.setTextboxValue(),e.isInputHidden=!0):(e.settings.hidePlaceholder&&e.items.length>0&&Q(e.control_input,{placeholder:""}),e.isInputHidden=!1),e.wrapper.classList.toggle("input-hidden",e.isInputHidden))}inputValue(){return this.control_input.value.trim()}focus(){var e=this
|
242
|
+
e.isDisabled||e.isReadOnly||(e.ignoreFocus=!0,e.control_input.offsetWidth?e.control_input.focus():e.focus_node.focus(),setTimeout((()=>{e.ignoreFocus=!1,e.onFocus()}),0))}blur(){this.focus_node.blur(),this.onBlur()}getScoreFunction(e){return this.sifter.getScoreFunction(e,this.getSearchOptions())}getSearchOptions(){var e=this.settings,t=e.sortField
|
239
243
|
return"string"==typeof e.sortField&&(t=[{field:e.sortField}]),{fields:e.searchField,conjunction:e.searchConjunction,sort:t,nesting:e.nesting}}search(e){var t,i,s=this,n=this.getSearchOptions()
|
240
244
|
if(s.settings.score&&"function"!=typeof(i=s.settings.score.call(s,e)))throw new Error('Tom Select "score" setting must be a function that returns a function')
|
241
|
-
return e!==s.lastQuery?(s.lastQuery=e,t=s.sifter.search(e,Object.assign(n,{score:i})),s.currentResults=t):t=Object.assign({},s.currentResults),s.settings.hideSelected&&(t.items=t.items.filter((e=>{let t=
|
245
|
+
return e!==s.lastQuery?(s.lastQuery=e,t=s.sifter.search(e,Object.assign(n,{score:i})),s.currentResults=t):t=Object.assign({},s.currentResults),s.settings.hideSelected&&(t.items=t.items.filter((e=>{let t=X(e.id)
|
242
246
|
return!(t&&-1!==s.items.indexOf(t))}))),t}refreshOptions(e=!0){var t,i,s,n,o,r,l,a,c,d
|
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=(e,t)=>{let i=u[e]
|
253
|
+
if(void 0!==i){let e=p[i]
|
254
|
+
if(void 0!==e)return[i,e.fragment]}let s=document.createDocumentFragment()
|
255
|
+
return i=p.length,p.push({fragment:s,order:t,optgroup:e}),[i,s]}
|
256
|
+
for(t=0;t<n;t++){let e=v.items[t]
|
248
257
|
if(!e)continue
|
249
258
|
let n=e.id,l=h.options[n]
|
250
259
|
if(void 0===l)continue
|
251
|
-
let a=
|
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 e=
|
254
|
-
void 0===
|
255
|
-
|
260
|
+
let a=Y(n),d=h.getOption(a,!0)
|
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 e=l.$order,t=h.optgroups[o]
|
263
|
+
void 0===t?o="":e=t.$order
|
264
|
+
const[s,a]=b(o,e)
|
265
|
+
i>0&&(d=d.cloneNode(!0),Q(d,{id:l.$id+"-clone-"+i,"aria-selected":null}),d.classList.add("ts-cloned"),R(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(((e,t)=>e.order-t.order)),l=document.createDocumentFragment(),E(p,(e=>{let t=e.fragment,i=e.optgroup
|
256
267
|
if(!t||!t.children.length)return
|
257
|
-
let
|
258
|
-
if(void 0!==
|
259
|
-
|
260
|
-
let n=h.render("optgroup",{group:
|
261
|
-
|
262
|
-
t.replaceChild(e.firstChild,e),t.normalize()})),
|
263
|
-
var
|
264
|
-
return t&&(
|
265
|
-
if(h.loading?
|
266
|
-
d&&!h.settings.addPrecedence&&(e=1),
|
267
|
-
e&&!h.isOpen&&(h.open(),h.scrollToOption(
|
268
|
+
let s=h.optgroups[i]
|
269
|
+
if(void 0!==s){let e=document.createDocumentFragment(),i=h.render("optgroup_header",s)
|
270
|
+
le(e,i),le(e,t)
|
271
|
+
let n=h.render("optgroup",{group:s,options:e})
|
272
|
+
le(l,n)}else le(l,t)})),O.innerHTML="",le(O,l),h.settings.highlight&&(w=O.querySelectorAll("span.highlight"),Array.prototype.forEach.call(w,(function(e){var t=e.parentNode
|
273
|
+
t.replaceChild(e.firstChild,e),t.normalize()})),v.query.length&&v.tokens.length&&E(v.tokens,(e=>{U(O,e.regex)})))
|
274
|
+
var _=e=>{let t=h.render(e,{input:g})
|
275
|
+
return t&&(y=!0,O.insertBefore(t,O.firstChild)),t}
|
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 e=0
|
277
|
+
d&&!h.settings.addPrecedence&&(e=1),m=h.selectable()[e]}}else d&&(m=d)
|
278
|
+
e&&!h.isOpen&&(h.open(),h.scrollToOption(m,"auto")),h.setActiveOption(m)}else h.clearActiveOption(),e&&h.isOpen&&h.close(!1)}selectable(){return this.dropdown_content.querySelectorAll("[data-selectable]")}addOption(e,t=!1){const i=this
|
268
279
|
if(Array.isArray(e))return i.addOptions(e,t),!1
|
269
|
-
const s=
|
270
|
-
return null!==s&&!i.options.hasOwnProperty(s)&&(e.$order=e.$order||++i.order,e.$id=i.inputId+"-opt-"+e.$order,i.options[s]=e,i.lastQuery=null,t&&(i.userOptions[s]=t,i.trigger("option_add",s,e)),s)}addOptions(e,t=!1){E(e,(e=>{this.addOption(e,t)}))}registerOption(e){return this.addOption(e)}registerOptionGroup(e){var t=
|
280
|
+
const s=X(e[i.settings.valueField])
|
281
|
+
return null!==s&&!i.options.hasOwnProperty(s)&&(e.$order=e.$order||++i.order,e.$id=i.inputId+"-opt-"+e.$order,i.options[s]=e,i.lastQuery=null,t&&(i.userOptions[s]=t,i.trigger("option_add",s,e)),s)}addOptions(e,t=!1){E(e,(e=>{this.addOption(e,t)}))}registerOption(e){return this.addOption(e)}registerOptionGroup(e){var t=X(e[this.settings.optgroupValueField])
|
271
282
|
return null!==t&&(e.$order=e.$order||++this.order,this.optgroups[t]=e,t)}addOptionGroup(e,t){var i
|
272
283
|
t[this.settings.optgroupValueField]=e,(i=this.registerOptionGroup(t))&&this.trigger("optgroup_add",i,t)}removeOptionGroup(e){this.optgroups.hasOwnProperty(e)&&(delete this.optgroups[e],this.clearCache(),this.trigger("optgroup_remove",e))}clearOptionGroups(){this.optgroups={},this.clearCache(),this.trigger("optgroup_clear")}updateOption(e,t){const i=this
|
273
284
|
var s,n
|
274
|
-
const o=
|
285
|
+
const o=X(e),r=X(t[i.settings.valueField])
|
275
286
|
if(null===o)return
|
276
287
|
const l=i.options[o]
|
277
288
|
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(t.$order=t.$order||l.$order,delete i.options[o],i.uncacheValue(r),i.options[r]=t,a){if(i.dropdown_content.contains(a)){const e=i._render("option",t)
|
281
|
-
|
282
|
-
e=
|
292
|
+
G(a,e),i.activeOption===a&&i.setActiveOption(e)}a.remove()}c&&(-1!==(n=i.items.indexOf(o))&&i.items.splice(n,1,r),s=i._render("item",t),c.classList.contains("active")&&D(s,"active"),G(c,s)),i.lastQuery=null}removeOption(e,t){const i=this
|
293
|
+
e=Y(e),i.uncacheValue(e),delete i.userOptions[e],delete i.options[e],i.lastQuery=null,i.trigger("option_remove",e),i.removeItem(e,t)}clearOptions(e){const t=(e||this.clearFilter).bind(this)
|
283
294
|
this.loadedSearches={},this.userOptions={},this.clearCache()
|
284
295
|
const i={}
|
285
|
-
E(this.options,((e,s)=>{t(e,s)&&(i[s]=e)})),this.options=this.sifter.items=i,this.lastQuery=null,this.trigger("option_clear")}clearFilter(e,t){return this.items.indexOf(t)>=0}getOption(e,t=!1){const i=
|
296
|
+
E(this.options,((e,s)=>{t(e,s)&&(i[s]=e)})),this.options=this.sifter.items=i,this.lastQuery=null,this.trigger("option_clear")}clearFilter(e,t){return this.items.indexOf(t)>=0}getOption(e,t=!1){const i=X(e)
|
286
297
|
if(null===i)return null
|
287
298
|
const s=this.options[i]
|
288
299
|
if(null!=s){if(s.$div)return s.$div
|
@@ -291,22 +302,22 @@ if(!e)return null
|
|
291
302
|
s="item"==i?this.controlChildren():this.dropdown_content.querySelectorAll("[data-selectable]")
|
292
303
|
for(let i=0;i<s.length;i++)if(s[i]==e)return t>0?s[i+1]:s[i-1]
|
293
304
|
return null}getItem(e){if("object"==typeof e)return e
|
294
|
-
var t=
|
295
|
-
return null!==t?this.control.querySelector(`[data-value="${
|
305
|
+
var t=X(e)
|
306
|
+
return null!==t?this.control.querySelector(`[data-value="${re(t)}"]`):null}addItems(e,t){var i=this,s=Array.isArray(e)?e:[e]
|
296
307
|
const n=(s=s.filter((e=>-1===i.items.indexOf(e))))[s.length-1]
|
297
|
-
s.forEach((e=>{i.isPending=e!==n,i.addItem(e,t)}))}addItem(e,t){
|
298
|
-
const n=this,o=n.settings.mode,r=
|
308
|
+
s.forEach((e=>{i.isPending=e!==n,i.addItem(e,t)}))}addItem(e,t){te(this,t?[]:["change","dropdown_close"],(()=>{var i,s
|
309
|
+
const n=this,o=n.settings.mode,r=X(e)
|
299
310
|
if((!r||-1===n.items.indexOf(r)||("single"===o&&n.close(),"single"!==o&&n.settings.duplicates))&&null!==r&&n.options.hasOwnProperty(r)&&("single"===o&&n.clear(t),"multi"!==o||!n.isFull())){if(i=n._render("item",n.options[r]),n.control.contains(i)&&(i=i.cloneNode(!0)),s=n.isFull(),n.items.splice(n.caretPos,0,r),n.insertAtCaret(i),n.isSetup){if(!n.isPending&&n.settings.hideSelected){let e=n.getOption(r),t=n.getAdjacent(e,1)
|
300
311
|
t&&n.setActiveOption(t)}n.isPending||n.settings.closeAfterSelect||n.refreshOptions(n.isFocused&&"single"!==o),0!=n.settings.closeAfterSelect&&n.isFull()?n.close():n.isPending||n.positionDropdown(),n.trigger("item_add",r,i),n.isPending||n.updateOriginalInput({silent:t})}(!n.isPending||!s&&n.isFull())&&(n.inputState(),n.refreshState())}}))}removeItem(e=null,t){const i=this
|
301
312
|
if(!(e=i.getItem(e)))return
|
302
313
|
var s,n
|
303
314
|
const o=e.dataset.value
|
304
|
-
s=
|
315
|
+
s=K(e),e.remove(),e.classList.contains("active")&&(n=i.activeItems.indexOf(e),i.activeItems.splice(n,1),R(e,"active")),i.items.splice(s,1),i.lastQuery=null,!i.settings.persist&&i.userOptions.hasOwnProperty(o)&&i.removeOption(o,t),s<i.caretPos&&i.setCaret(i.caretPos-1),i.updateOriginalInput({silent:t}),i.refreshState(),i.positionDropdown(),i.trigger("item_remove",o,e)}createItem(e=null,t=(()=>{})){3===arguments.length&&(t=arguments[2]),"function"!=typeof t&&(t=()=>{})
|
305
316
|
var i,s=this,n=s.caretPos
|
306
317
|
if(e=e||s.inputValue(),!s.canCreate(e))return t(),!1
|
307
318
|
s.lock()
|
308
319
|
var o=!1,r=e=>{if(s.unlock(),!e||"object"!=typeof e)return t()
|
309
|
-
var i=
|
320
|
+
var i=X(e[s.settings.valueField])
|
310
321
|
if("string"!=typeof i)return t()
|
311
322
|
s.setTextboxValue(),s.addOption(e,!0),s.setCaret(n),s.addItem(i),t(e),o=!0}
|
312
323
|
return i="function"==typeof s.settings.create?s.settings.create.call(this,e,r):{[s.settings.labelField]:e,[s.settings.valueField]:e},o||r(i),!0}refreshItems(){var e=this
|
@@ -316,95 +327,103 @@ const t=e.isFull(),i=e.isLocked
|
|
316
327
|
e.wrapper.classList.toggle("rtl",e.rtl)
|
317
328
|
const s=e.wrapper.classList
|
318
329
|
var n
|
319
|
-
s.toggle("focus",e.isFocused),s.toggle("disabled",e.isDisabled),s.toggle("required",e.isRequired),s.toggle("invalid",!e.isValid),s.toggle("locked",i),s.toggle("full",t),s.toggle("input-active",e.isFocused&&!e.isInputHidden),s.toggle("dropdown-active",e.isOpen),s.toggle("has-options",(n=e.options,0===Object.keys(n).length)),s.toggle("has-items",e.items.length>0)}refreshValidityState(){var e=this
|
330
|
+
s.toggle("focus",e.isFocused),s.toggle("disabled",e.isDisabled),s.toggle("readonly",e.isReadOnly),s.toggle("required",e.isRequired),s.toggle("invalid",!e.isValid),s.toggle("locked",i),s.toggle("full",t),s.toggle("input-active",e.isFocused&&!e.isInputHidden),s.toggle("dropdown-active",e.isOpen),s.toggle("has-options",(n=e.options,0===Object.keys(n).length)),s.toggle("has-items",e.items.length>0)}refreshValidityState(){var e=this
|
320
331
|
e.input.validity&&(e.isValid=e.input.validity.valid,e.isInvalid=!e.isValid)}isFull(){return null!==this.settings.maxItems&&this.items.length>=this.settings.maxItems}updateOriginalInput(e={}){const t=this
|
321
332
|
var i,s
|
322
333
|
const n=t.input.querySelector('option[value=""]')
|
323
|
-
if(t.is_select_tag){const
|
324
|
-
function
|
334
|
+
if(t.is_select_tag){const o=[],r=t.input.querySelectorAll("option:checked").length
|
335
|
+
function l(e,i,s){return e||(e=j('<option value="'+Z(i)+'">'+Z(s)+"</option>")),e!=n&&t.input.append(e),o.push(e),(e!=n||r>0)&&(e.selected=!0),e}t.input.querySelectorAll("option:checked").forEach((e=>{e.selected=!1})),0==t.items.length&&"single"==t.settings.mode?l(n,"",""):t.items.forEach((e=>{if(i=t.options[e],s=i[t.settings.labelField]||"",o.includes(i.$option)){l(t.input.querySelector(`option[value="${re(e)}"]:not(:checked)`),e,s)}else i.$option=l(i.$option,e,s)}))}else t.input.value=t.getValue()
|
325
336
|
t.isSetup&&(e.silent||t.trigger("change",t.getValue()))}open(){var e=this
|
326
|
-
e.isLocked||e.isOpen||"multi"===e.settings.mode&&e.isFull()||(e.isOpen=!0,
|
327
|
-
e&&(t.setTextboxValue(),"single"===t.settings.mode&&t.items.length&&t.
|
328
|
-
|
337
|
+
e.isLocked||e.isOpen||"multi"===e.settings.mode&&e.isFull()||(e.isOpen=!0,Q(e.focus_node,{"aria-expanded":"true"}),e.refreshState(),q(e.dropdown,{visibility:"hidden",display:"block"}),e.positionDropdown(),q(e.dropdown,{visibility:"visible",display:"block"}),e.focus(),e.trigger("dropdown_open",e.dropdown))}close(e=!0){var t=this,i=t.isOpen
|
338
|
+
e&&(t.setTextboxValue(),"single"===t.settings.mode&&t.items.length&&t.inputState()),t.isOpen=!1,Q(t.focus_node,{"aria-expanded":"false"}),q(t.dropdown,{display:"none"}),t.settings.hideSelected&&t.clearActiveOption(),t.refreshState(),i&&t.trigger("dropdown_close",t.dropdown)}positionDropdown(){if("body"===this.settings.dropdownParent){var e=this.control,t=e.getBoundingClientRect(),i=e.offsetHeight+t.top+window.scrollY,s=t.left+window.scrollX
|
339
|
+
q(this.dropdown,{width:t.width+"px",top:i+"px",left:s+"px"})}}clear(e){var t=this
|
329
340
|
if(t.items.length){var i=t.controlChildren()
|
330
|
-
E(i,(e=>{t.removeItem(e,!0)})),t.
|
341
|
+
E(i,(e=>{t.removeItem(e,!0)})),t.inputState(),e||t.updateOriginalInput(),t.trigger("clear")}}insertAtCaret(e){const t=this,i=t.caretPos,s=t.control
|
331
342
|
s.insertBefore(e,s.children[i]||null),t.setCaret(i+1)}deleteSelection(e){var t,i,s,n,o,r=this
|
332
343
|
t=e&&8===e.keyCode?-1:1,i={start:(o=r.control_input).selectionStart||0,length:(o.selectionEnd||0)-(o.selectionStart||0)}
|
333
344
|
const l=[]
|
334
|
-
if(r.activeItems.length)n=
|
345
|
+
if(r.activeItems.length)n=B(r.activeItems,t),s=K(n),t>0&&s++,E(r.activeItems,(e=>l.push(e)))
|
335
346
|
else if((r.isFocused||"single"===r.settings.mode)&&r.items.length){const e=r.controlChildren()
|
336
347
|
let s
|
337
348
|
t<0&&0===i.start&&0===i.length?s=e[r.caretPos-1]:t>0&&i.start===r.inputValue().length&&(s=e[r.caretPos]),void 0!==s&&l.push(s)}if(!r.shouldDelete(l,e))return!1
|
338
|
-
for(
|
339
|
-
return r.
|
349
|
+
for(ie(e,!0),void 0!==s&&r.setCaret(s);l.length;)r.removeItem(l.pop())
|
350
|
+
return r.inputState(),r.positionDropdown(),r.refreshOptions(!1),!0}shouldDelete(e,t){const i=e.map((e=>e.dataset.value))
|
340
351
|
return!(!i.length||"function"==typeof this.settings.onDelete&&!1===this.settings.onDelete(i,t))}advanceSelection(e,t){var i,s,n=this
|
341
|
-
n.rtl&&(e*=-1),n.inputValue().length||(
|
352
|
+
n.rtl&&(e*=-1),n.inputValue().length||(ne(J,t)||ne("shiftKey",t)?(s=(i=n.getLastActive(e))?i.classList.contains("active")?n.getAdjacent(i,e,"item"):i:e>0?n.control_input.nextElementSibling:n.control_input.previousElementSibling)&&(s.classList.contains("active")&&n.removeActiveItem(i),n.setActiveItemClass(s)):n.moveCaret(e))}moveCaret(e){}getLastActive(e){let t=this.control.querySelector(".last-active")
|
342
353
|
if(t)return t
|
343
354
|
var i=this.control.querySelectorAll(".active")
|
344
|
-
return i?
|
345
|
-
e.
|
346
|
-
e.input.disabled=!1,e.control_input.disabled=!1,e.focus_node.tabIndex=e.tabIndex,e.isDisabled=!1,e.unlock()}destroy(){var e=this,t=e.revertSettings
|
347
|
-
e.trigger("destroy"),e.off(),e.wrapper.remove(),e.dropdown.remove(),e.input.innerHTML=t.innerHTML,e.input.tabIndex=t.tabIndex,z(e.input,"tomselected","ts-hidden-accessible"),e._destroy(),delete e.input.tomselect}render(e,t){var i,s
|
355
|
+
return i?B(i,e):void 0}setCaret(e){this.caretPos=this.items.length}controlChildren(){return Array.from(this.control.querySelectorAll("[data-ts-item]"))}lock(){this.setLocked(!0)}unlock(){this.setLocked(!1)}setLocked(e=this.isReadOnly||this.isDisabled){this.isLocked=e,this.refreshState()}disable(){this.setDisabled(!0),this.close()}enable(){this.setDisabled(!1)}setDisabled(e){this.focus_node.tabIndex=e?-1:this.tabIndex,this.isDisabled=e,this.input.disabled=e,this.control_input.disabled=e,this.setLocked()}setReadOnly(e){this.isReadOnly=e,this.input.readOnly=e,this.control_input.readOnly=e,this.setLocked()}destroy(){var e=this,t=e.revertSettings
|
356
|
+
e.trigger("destroy"),e.off(),e.wrapper.remove(),e.dropdown.remove(),e.input.innerHTML=t.innerHTML,e.input.tabIndex=t.tabIndex,R(e.input,"tomselected","ts-hidden-accessible"),e._destroy(),delete e.input.tomselect}render(e,t){var i,s
|
348
357
|
const n=this
|
349
358
|
if("function"!=typeof this.settings.render[e])return null
|
350
|
-
if(!(s=n.settings.render[e].call(this,t,
|
351
|
-
if(s=
|
352
|
-
|
359
|
+
if(!(s=n.settings.render[e].call(this,t,Z)))return null
|
360
|
+
if(s=j(s),"option"===e||"option_create"===e?t[n.settings.disabledField]?Q(s,{"aria-disabled":"true"}):Q(s,{"data-selectable":""}):"optgroup"===e&&(i=t.group[n.settings.optgroupValueField],Q(s,{"data-group":i}),t.group[n.settings.disabledField]&&Q(s,{"data-disabled":""})),"option"===e||"item"===e){const i=Y(t[n.settings.valueField])
|
361
|
+
Q(s,{"data-value":i}),"item"===e?(D(s,n.settings.itemClass),Q(s,{"data-ts-item":""})):(D(s,n.settings.optionClass),Q(s,{role:"option",id:t.$id}),t.$div=s,n.options[i]=t)}return s}_render(e,t){const i=this.render(e,t)
|
353
362
|
if(null==i)throw"HTMLElement expected"
|
354
363
|
return i}clearCache(){E(this.options,(e=>{e.$div&&(e.$div.remove(),delete e.$div)}))}uncacheValue(e){const t=this.getOption(e)
|
355
364
|
t&&t.remove()}canCreate(e){return this.settings.create&&e.length>0&&this.settings.createFilter.call(this,e)}hook(e,t,i){var s=this,n=s[t]
|
356
365
|
s[t]=function(){var t,o
|
357
|
-
return"after"===e&&(t=n.apply(s,arguments)),o=i.apply(s,arguments),"instead"===e?o:("before"===e&&(t=n.apply(s,arguments)),t)}}}return
|
358
|
-
|
359
|
-
|
360
|
-
t
|
361
|
-
e.
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
t.
|
370
|
-
|
371
|
-
|
372
|
-
if("multi"
|
373
|
-
e.
|
374
|
-
|
375
|
-
|
366
|
+
return"after"===e&&(t=n.apply(s,arguments)),o=i.apply(s,arguments),"instead"===e?o:("before"===e&&(t=n.apply(s,arguments)),t)}}}return de.define("change_listener",(function(){se(this.input,"change",(()=>{this.sync()}))})),de.define("checkbox_options",(function(e){var t=this,i=t.onOptionSelect
|
367
|
+
t.settings.hideSelected=!1
|
368
|
+
const s=Object.assign({className:"tomselect-checkbox",checkedClassNames:void 0,uncheckedClassNames:void 0},e)
|
369
|
+
var n=function(e,t){t?(e.checked=!0,s.uncheckedClassNames&&e.classList.remove(...s.uncheckedClassNames),s.checkedClassNames&&e.classList.add(...s.checkedClassNames)):(e.checked=!1,s.checkedClassNames&&e.classList.remove(...s.checkedClassNames),s.uncheckedClassNames&&e.classList.add(...s.uncheckedClassNames))},o=function(e){setTimeout((()=>{var t=e.querySelector("input."+s.className)
|
370
|
+
t instanceof HTMLInputElement&&n(t,e.classList.contains("selected"))}),1)}
|
371
|
+
t.hook("after","setupTemplates",(()=>{var e=t.settings.render.option
|
372
|
+
t.settings.render.option=(i,o)=>{var r=j(e.call(t,i,o)),l=document.createElement("input")
|
373
|
+
s.className&&l.classList.add(s.className),l.addEventListener("click",(function(e){ie(e)})),l.type="checkbox"
|
374
|
+
const a=X(i[t.settings.valueField])
|
375
|
+
return n(l,!!(a&&t.items.indexOf(a)>-1)),r.prepend(l),r}})),t.on("item_remove",(e=>{var i=t.getOption(e)
|
376
|
+
i&&(i.classList.remove("selected"),o(i))})),t.on("item_add",(e=>{var i=t.getOption(e)
|
377
|
+
i&&o(i)})),t.hook("instead","onOptionSelect",((e,s)=>{if(s.classList.contains("selected"))return s.classList.remove("selected"),t.removeItem(s.dataset.value),t.refreshOptions(),void ie(e,!0)
|
378
|
+
i.call(t,e,s),o(s)}))})),de.define("clear_button",(function(e){const t=this,i=Object.assign({className:"clear-button",title:"Clear All",html:e=>`<div class="${e.className}" title="${e.title}">⨯</div>`},e)
|
379
|
+
t.on("initialize",(()=>{var e=j(i.html(i))
|
380
|
+
e.addEventListener("click",(e=>{t.isLocked||(t.clear(),"single"===t.settings.mode&&t.settings.allowEmptyOption&&t.addItem(""),e.preventDefault(),e.stopPropagation())})),t.control.appendChild(e)}))})),de.define("drag_drop",(function(){var e=this
|
381
|
+
if("multi"!==e.settings.mode)return
|
382
|
+
var t=e.lock,i=e.unlock
|
383
|
+
let s,n=!0
|
384
|
+
e.hook("after","setupTemplates",(()=>{var t=e.settings.render.item
|
385
|
+
e.settings.render.item=(i,o)=>{const r=j(t.call(e,i,o))
|
386
|
+
Q(r,{draggable:"true"})
|
387
|
+
const l=e=>{e.preventDefault(),r.classList.add("ts-drag-over"),a(r,s)},a=(e,t)=>{var i,s,n
|
388
|
+
void 0!==t&&(((e,t)=>{do{var i
|
389
|
+
if(e==(t=null==(i=t)?void 0:i.previousElementSibling))return!0}while(t&&t.previousElementSibling)
|
390
|
+
return!1})(t,r)?(s=t,null==(n=(i=e).parentNode)||n.insertBefore(s,i.nextSibling)):((e,t)=>{var i
|
391
|
+
null==(i=e.parentNode)||i.insertBefore(t,e)})(e,t))}
|
392
|
+
return se(r,"mousedown",(e=>{n||ie(e),e.stopPropagation()})),se(r,"dragstart",(e=>{s=r,setTimeout((()=>{r.classList.add("ts-dragging")}),0)})),se(r,"dragenter",l),se(r,"dragover",l),se(r,"dragleave",(()=>{r.classList.remove("ts-drag-over")})),se(r,"dragend",(()=>{var t
|
393
|
+
document.querySelectorAll(".ts-drag-over").forEach((e=>e.classList.remove("ts-drag-over"))),null==(t=s)||t.classList.remove("ts-dragging"),s=void 0
|
376
394
|
var i=[]
|
377
|
-
|
378
|
-
t.
|
379
|
-
|
395
|
+
e.control.querySelectorAll("[data-value]").forEach((e=>{if(e.dataset.value){let t=e.dataset.value
|
396
|
+
t&&i.push(t)}})),e.setValue(i)})),r}})),e.hook("instead","lock",(()=>(n=!1,t.call(e)))),e.hook("instead","unlock",(()=>(n=!0,i.call(e))))})),de.define("dropdown_header",(function(e){const t=this,i=Object.assign({title:"Untitled",headerClass:"dropdown-header",titleRowClass:"dropdown-header-title",labelClass:"dropdown-header-label",closeClass:"dropdown-header-close",html:e=>'<div class="'+e.headerClass+'"><div class="'+e.titleRowClass+'"><span class="'+e.labelClass+'">'+e.title+'</span><a class="'+e.closeClass+'">×</a></div></div>'},e)
|
397
|
+
t.on("initialize",(()=>{var e=j(i.html(i)),s=e.querySelector("."+i.closeClass)
|
398
|
+
s&&s.addEventListener("click",(e=>{ie(e,!0),t.close()})),t.dropdown.insertBefore(e,t.dropdown.firstChild)}))})),de.define("caret_position",(function(){var e=this
|
380
399
|
e.hook("instead","setCaret",(t=>{"single"!==e.settings.mode&&e.control.contains(e.control_input)?(t=Math.max(0,Math.min(e.items.length,t)))==e.caretPos||e.isPending||e.controlChildren().forEach(((i,s)=>{s<t?e.control_input.insertAdjacentElement("beforebegin",i):e.control.appendChild(i)})):t=e.items.length,e.caretPos=t})),e.hook("instead","moveCaret",(t=>{if(!e.isFocused)return
|
381
400
|
const i=e.getLastActive(t)
|
382
|
-
if(i){const s=
|
383
|
-
e.setCaret(t>0?s+1:s),e.setActiveItem(),
|
384
|
-
e.settings.shouldOpen=!0,e.hook("before","setup",(()=>{e.focus_node=e.control,
|
385
|
-
const t=
|
401
|
+
if(i){const s=K(i)
|
402
|
+
e.setCaret(t>0?s+1:s),e.setActiveItem(),R(i,"last-active")}else e.setCaret(e.caretPos+t)}))})),de.define("dropdown_input",(function(){const e=this
|
403
|
+
e.settings.shouldOpen=!0,e.hook("before","setup",(()=>{e.focus_node=e.control,D(e.control_input,"dropdown-input")
|
404
|
+
const t=j('<div class="dropdown-input-wrap">')
|
386
405
|
t.append(e.control_input),e.dropdown.insertBefore(t,e.dropdown.firstChild)
|
387
|
-
const i=
|
388
|
-
i.placeholder=e.settings.placeholder||"",e.control.append(i)})),e.on("initialize",(()=>{e.control_input.addEventListener("keydown",(t=>{switch(t.keyCode){case 27:return e.isOpen&&(
|
406
|
+
const i=j('<input class="items-placeholder" tabindex="-1" />')
|
407
|
+
i.placeholder=e.settings.placeholder||"",e.control.append(i)})),e.on("initialize",(()=>{e.control_input.addEventListener("keydown",(t=>{switch(t.keyCode){case 27:return e.isOpen&&(ie(t,!0),e.close()),void e.clearActiveItems()
|
389
408
|
case 9:e.focus_node.tabIndex=-1}return e.onKeyDown.call(e,t)})),e.on("blur",(()=>{e.focus_node.tabIndex=e.isDisabled?-1:e.tabIndex})),e.on("dropdown_open",(()=>{e.control_input.focus()}))
|
390
409
|
const t=e.onBlur
|
391
|
-
e.hook("instead","onBlur",(i=>{if(!i||i.relatedTarget!=e.control_input)return t.call(e)})),
|
410
|
+
e.hook("instead","onBlur",(i=>{if(!i||i.relatedTarget!=e.control_input)return t.call(e)})),se(e.control_input,"blur",(()=>e.onBlur())),e.hook("before","close",(()=>{e.isOpen&&e.focus_node.focus({preventScroll:!0})}))}))})),de.define("input_autogrow",(function(){var e=this
|
392
411
|
e.on("initialize",(()=>{var t=document.createElement("span"),i=e.control_input
|
393
412
|
t.style.cssText="position:absolute; top:-99999px; left:-99999px; width:auto; padding:0; white-space:pre; ",e.wrapper.appendChild(t)
|
394
413
|
for(const e of["letterSpacing","fontSize","fontFamily","fontWeight","textTransform"])t.style[e]=i.style[e]
|
395
414
|
var s=()=>{t.textContent=i.value,i.style.width=t.clientWidth+"px"}
|
396
|
-
s(),e.on("update item_add item_remove",s),
|
397
|
-
this.hook("instead","deleteSelection",(i=>!!e.activeItems.length&&t.call(e,i)))})),
|
415
|
+
s(),e.on("update item_add item_remove",s),se(i,"input",s),se(i,"keyup",s),se(i,"blur",s),se(i,"update",s)}))})),de.define("no_backspace_delete",(function(){var e=this,t=e.deleteSelection
|
416
|
+
this.hook("instead","deleteSelection",(i=>!!e.activeItems.length&&t.call(e,i)))})),de.define("no_active_items",(function(){this.hook("instead","setActiveItem",(()=>{})),this.hook("instead","selectAll",(()=>{}))})),de.define("optgroup_columns",(function(){var e=this,t=e.onKeyDown
|
398
417
|
e.hook("instead","onKeyDown",(i=>{var s,n,o,r
|
399
418
|
if(!e.isOpen||37!==i.keyCode&&39!==i.keyCode)return t.call(e,i)
|
400
|
-
e.ignoreHover=!0,r=
|
419
|
+
e.ignoreHover=!0,r=z(e.activeOption,"[data-group]"),s=K(e.activeOption,"[data-selectable]"),r&&(r=37===i.keyCode?r.previousSibling:r.nextSibling)&&(n=(o=r.querySelectorAll("[data-selectable]"))[Math.min(o.length-1,s)])&&e.setActiveOption(n)}))})),de.define("remove_button",(function(e){const t=Object.assign({label:"×",title:"Remove",className:"remove",append:!0},e)
|
401
420
|
var i=this
|
402
|
-
if(t.append){var s='<a href="javascript:void(0)" class="'+t.className+'" tabindex="-1" title="'+
|
421
|
+
if(t.append){var s='<a href="javascript:void(0)" class="'+t.className+'" tabindex="-1" title="'+Z(t.title)+'">'+t.label+"</a>"
|
403
422
|
i.hook("after","setupTemplates",(()=>{var e=i.settings.render.item
|
404
|
-
i.settings.render.item=(t,n)=>{var o=
|
405
|
-
return o.appendChild(r),
|
423
|
+
i.settings.render.item=(t,n)=>{var o=j(e.call(i,t,n)),r=j(s)
|
424
|
+
return o.appendChild(r),se(r,"mousedown",(e=>{ie(e,!0)})),se(r,"click",(e=>{i.isLocked||(ie(e,!0),i.isLocked||i.shouldDelete([o],e)&&(i.removeItem(o),i.refreshOptions(!1),i.inputState()))})),o}}))}})),de.define("restore_on_backspace",(function(e){const t=this,i=Object.assign({text:e=>e[t.settings.labelField]},e)
|
406
425
|
t.on("item_remove",(function(e){if(t.isFocused&&""===t.control_input.value.trim()){var s=t.options[e]
|
407
|
-
s&&t.setTextboxValue(i.text.call(t,s))}}))})),
|
426
|
+
s&&t.setTextboxValue(i.text.call(t,s))}}))})),de.define("virtual_scroll",(function(){const e=this,t=e.canLoad,i=e.clearActiveOption,s=e.loadCallback
|
408
427
|
var n,o,r={},l=!1,a=[]
|
409
428
|
if(e.settings.shouldLoadMore||(e.settings.shouldLoadMore=()=>{if(n.clientHeight/(n.scrollHeight-n.scrollTop)>.9)return!0
|
410
429
|
if(e.activeOption){var t=e.selectable()
|
@@ -412,10 +431,10 @@ if(Array.from(t).indexOf(e.activeOption)>=t.length-2)return!0}return!1}),!e.sett
|
|
412
431
|
e.settings.sortField=[{field:"$order"},{field:"$score"}]
|
413
432
|
const c=t=>!("number"==typeof e.settings.maxOptions&&n.children.length>=e.settings.maxOptions)&&!(!(t in r)||!r[t]),d=(t,i)=>e.items.indexOf(i)>=0||a.indexOf(i)>=0
|
414
433
|
e.setNextUrl=(e,t)=>{r[e]=t},e.getUrl=t=>{if(t in r){const e=r[t]
|
415
|
-
return r[t]=!1,e}return
|
434
|
+
return r[t]=!1,e}return e.clearPagination(),e.settings.firstUrl.call(e,t)},e.clearPagination=()=>{r={}},e.hook("instead","clearActiveOption",(()=>{if(!l)return i.call(e)})),e.hook("instead","canLoad",(i=>i in r?c(i):t.call(e,i))),e.hook("instead","loadCallback",((t,i)=>{if(l){if(o){const i=t[0]
|
416
435
|
void 0!==i&&(o.dataset.value=i[e.settings.valueField])}}else e.clearOptions(d)
|
417
436
|
s.call(e,t,i),l=!1})),e.hook("after","refreshOptions",(()=>{const t=e.lastValue
|
418
437
|
var i
|
419
|
-
c(t)?(i=e.render("loading_more",{query:t}))&&(i.setAttribute("data-selectable",""),o=i):t in r&&!n.querySelector(".no-results")&&(i=e.render("no_more_results",{query:t})),i&&(
|
438
|
+
c(t)?(i=e.render("loading_more",{query:t}))&&(i.setAttribute("data-selectable",""),o=i):t in r&&!n.querySelector(".no-results")&&(i=e.render("no_more_results",{query:t})),i&&(D(i,e.settings.optionClass),n.append(i))})),e.on("initialize",(()=>{a=Object.keys(e.options),n=e.dropdown_content,e.settings.render=Object.assign({},{loading_more:()=>'<div class="loading-more-results">Loading more results ... </div>',no_more_results:()=>'<div class="no-more-results">No more results</div>'},e.settings.render),n.addEventListener("scroll",(()=>{e.settings.shouldLoadMore.call(e)&&c(e.lastValue)&&(l||(l=!0,e.load.call(e,e.lastValue)))}))}))})),de}))
|
420
439
|
var tomSelect=function(e,t){return new TomSelect(e,t)}
|
421
440
|
//# sourceMappingURL=tom-select.complete.min.js.map
|