@prometa/sleek 0.0.4 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/index.d.ts +1 -1
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/sleek-select.d.ts +2 -0
- package/dist/components/sleek-select.d.ts.map +1 -0
- package/dist/components.cjs +1 -1
- package/dist/components.js +1 -1
- package/dist/main.d.ts +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/sleek-select.cjs +1 -0
- package/dist/sleek-select.js +2555 -0
- package/package.json +3 -2
|
@@ -0,0 +1,2555 @@
|
|
|
1
|
+
var Ut = Object.defineProperty;
|
|
2
|
+
var Ct = (i) => {
|
|
3
|
+
throw TypeError(i);
|
|
4
|
+
};
|
|
5
|
+
var $t = (i, t, e) => t in i ? Ut(i, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[t] = e;
|
|
6
|
+
var k = (i, t, e) => $t(i, typeof t != "symbol" ? t + "" : t, e), ct = (i, t, e) => t.has(i) || Ct("Cannot " + e);
|
|
7
|
+
var G = (i, t, e) => (ct(i, t, "read from private field"), e ? e.call(i) : t.get(i)), F = (i, t, e) => t.has(i) ? Ct("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(i) : t.set(i, e), N = (i, t, e, n) => (ct(i, t, "write to private field"), n ? n.call(i, e) : t.set(i, e), e), yt = (i, t, e) => (ct(i, t, "access private method"), e);
|
|
8
|
+
import { snakeToCamel as Pt } from "./chartjs-chart.js";
|
|
9
|
+
import { t as qt } from "./utils.js";
|
|
10
|
+
function at(i, t) {
|
|
11
|
+
i.split(/\s+/).forEach((e) => {
|
|
12
|
+
t(e);
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
class te {
|
|
16
|
+
constructor() {
|
|
17
|
+
this._events = {};
|
|
18
|
+
}
|
|
19
|
+
on(t, e) {
|
|
20
|
+
at(t, (n) => {
|
|
21
|
+
const s = this._events[n] || [];
|
|
22
|
+
s.push(e), this._events[n] = s;
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
off(t, e) {
|
|
26
|
+
var n = arguments.length;
|
|
27
|
+
if (n === 0) {
|
|
28
|
+
this._events = {};
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
at(t, (s) => {
|
|
32
|
+
if (n === 1) {
|
|
33
|
+
delete this._events[s];
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
const o = this._events[s];
|
|
37
|
+
o !== void 0 && (o.splice(o.indexOf(e), 1), this._events[s] = o);
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
trigger(t, ...e) {
|
|
41
|
+
var n = this;
|
|
42
|
+
at(t, (s) => {
|
|
43
|
+
const o = n._events[s];
|
|
44
|
+
o !== void 0 && o.forEach((r) => {
|
|
45
|
+
r.apply(n, e);
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
function ee(i) {
|
|
51
|
+
return i.plugins = {}, class extends i {
|
|
52
|
+
constructor() {
|
|
53
|
+
super(...arguments), this.plugins = {
|
|
54
|
+
names: [],
|
|
55
|
+
settings: {},
|
|
56
|
+
requested: {},
|
|
57
|
+
loaded: {}
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Registers a plugin.
|
|
62
|
+
*
|
|
63
|
+
* @param {function} fn
|
|
64
|
+
*/
|
|
65
|
+
static define(t, e) {
|
|
66
|
+
i.plugins[t] = {
|
|
67
|
+
name: t,
|
|
68
|
+
fn: e
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Initializes the listed plugins (with options).
|
|
73
|
+
* Acceptable formats:
|
|
74
|
+
*
|
|
75
|
+
* List (without options):
|
|
76
|
+
* ['a', 'b', 'c']
|
|
77
|
+
*
|
|
78
|
+
* List (with options):
|
|
79
|
+
* [{'name': 'a', options: {}}, {'name': 'b', options: {}}]
|
|
80
|
+
*
|
|
81
|
+
* Hash (with options):
|
|
82
|
+
* {'a': { ... }, 'b': { ... }, 'c': { ... }}
|
|
83
|
+
*
|
|
84
|
+
* @param {array|object} plugins
|
|
85
|
+
*/
|
|
86
|
+
initializePlugins(t) {
|
|
87
|
+
var e, n;
|
|
88
|
+
const s = this, o = [];
|
|
89
|
+
if (Array.isArray(t))
|
|
90
|
+
t.forEach((r) => {
|
|
91
|
+
typeof r == "string" ? o.push(r) : (s.plugins.settings[r.name] = r.options, o.push(r.name));
|
|
92
|
+
});
|
|
93
|
+
else if (t)
|
|
94
|
+
for (e in t)
|
|
95
|
+
t.hasOwnProperty(e) && (s.plugins.settings[e] = t[e], o.push(e));
|
|
96
|
+
for (; n = o.shift(); )
|
|
97
|
+
s.require(n);
|
|
98
|
+
}
|
|
99
|
+
loadPlugin(t) {
|
|
100
|
+
var e = this, n = e.plugins, s = i.plugins[t];
|
|
101
|
+
if (!i.plugins.hasOwnProperty(t))
|
|
102
|
+
throw new Error('Unable to find "' + t + '" plugin');
|
|
103
|
+
n.requested[t] = !0, n.loaded[t] = s.fn.apply(e, [e.plugins.settings[t] || {}]), n.names.push(t);
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Initializes a plugin.
|
|
107
|
+
*
|
|
108
|
+
*/
|
|
109
|
+
require(t) {
|
|
110
|
+
var e = this, n = e.plugins;
|
|
111
|
+
if (!e.plugins.loaded.hasOwnProperty(t)) {
|
|
112
|
+
if (n.requested[t])
|
|
113
|
+
throw new Error('Plugin has circular dependency ("' + t + '")');
|
|
114
|
+
e.loadPlugin(t);
|
|
115
|
+
}
|
|
116
|
+
return n.loaded[t];
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
const lt = (i) => (i = i.filter(Boolean), i.length < 2 ? i[0] || "" : ne(i) == 1 ? "[" + i.join("") + "]" : "(?:" + i.join("|") + ")"), Ft = (i) => {
|
|
121
|
+
if (!ie(i))
|
|
122
|
+
return i.join("");
|
|
123
|
+
let t = "", e = 0;
|
|
124
|
+
const n = () => {
|
|
125
|
+
e > 1 && (t += "{" + e + "}");
|
|
126
|
+
};
|
|
127
|
+
return i.forEach((s, o) => {
|
|
128
|
+
if (s === i[o - 1]) {
|
|
129
|
+
e++;
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
n(), t += s, e = 1;
|
|
133
|
+
}), n(), t;
|
|
134
|
+
}, St = (i) => {
|
|
135
|
+
let t = Array.from(i);
|
|
136
|
+
return lt(t);
|
|
137
|
+
}, ie = (i) => new Set(i).size !== i.length, Q = (i) => (i + "").replace(/([\$\(\)\*\+\.\?\[\]\^\{\|\}\\])/gu, "\\$1"), ne = (i) => i.reduce((t, e) => Math.max(t, se(e)), 0), se = (i) => Array.from(i).length, Kt = (i) => {
|
|
138
|
+
if (i.length === 1)
|
|
139
|
+
return [[i]];
|
|
140
|
+
let t = [];
|
|
141
|
+
const e = i.substring(1);
|
|
142
|
+
return Kt(e).forEach(function(s) {
|
|
143
|
+
let o = s.slice(0);
|
|
144
|
+
o[0] = i.charAt(0) + o[0], t.push(o), o = s.slice(0), o.unshift(i.charAt(0)), t.push(o);
|
|
145
|
+
}), t;
|
|
146
|
+
}, re = [[0, 65535]], oe = "[̀-ͯ·ʾʼ]";
|
|
147
|
+
let nt, xt;
|
|
148
|
+
const le = 3, vt = {}, Zt = {
|
|
149
|
+
"/": "⁄∕",
|
|
150
|
+
0: "߀",
|
|
151
|
+
a: "ⱥɐɑ",
|
|
152
|
+
aa: "ꜳ",
|
|
153
|
+
ae: "æǽǣ",
|
|
154
|
+
ao: "ꜵ",
|
|
155
|
+
au: "ꜷ",
|
|
156
|
+
av: "ꜹꜻ",
|
|
157
|
+
ay: "ꜽ",
|
|
158
|
+
b: "ƀɓƃ",
|
|
159
|
+
c: "ꜿƈȼↄ",
|
|
160
|
+
d: "đɗɖᴅƌꮷԁɦ",
|
|
161
|
+
e: "ɛǝᴇɇ",
|
|
162
|
+
f: "ꝼƒ",
|
|
163
|
+
g: "ǥɠꞡᵹꝿɢ",
|
|
164
|
+
h: "ħⱨⱶɥ",
|
|
165
|
+
i: "ɨı",
|
|
166
|
+
j: "ɉȷ",
|
|
167
|
+
k: "ƙⱪꝁꝃꝅꞣ",
|
|
168
|
+
l: "łƚɫⱡꝉꝇꞁɭ",
|
|
169
|
+
m: "ɱɯϻ",
|
|
170
|
+
n: "ꞥƞɲꞑᴎлԉ",
|
|
171
|
+
o: "øǿɔɵꝋꝍᴑ",
|
|
172
|
+
oe: "œ",
|
|
173
|
+
oi: "ƣ",
|
|
174
|
+
oo: "ꝏ",
|
|
175
|
+
ou: "ȣ",
|
|
176
|
+
p: "ƥᵽꝑꝓꝕρ",
|
|
177
|
+
q: "ꝗꝙɋ",
|
|
178
|
+
r: "ɍɽꝛꞧꞃ",
|
|
179
|
+
s: "ßȿꞩꞅʂ",
|
|
180
|
+
t: "ŧƭʈⱦꞇ",
|
|
181
|
+
th: "þ",
|
|
182
|
+
tz: "ꜩ",
|
|
183
|
+
u: "ʉ",
|
|
184
|
+
v: "ʋꝟʌ",
|
|
185
|
+
vy: "ꝡ",
|
|
186
|
+
w: "ⱳ",
|
|
187
|
+
y: "ƴɏỿ",
|
|
188
|
+
z: "ƶȥɀⱬꝣ",
|
|
189
|
+
hv: "ƕ"
|
|
190
|
+
};
|
|
191
|
+
for (let i in Zt) {
|
|
192
|
+
let t = Zt[i] || "";
|
|
193
|
+
for (let e = 0; e < t.length; e++) {
|
|
194
|
+
let n = t.substring(e, e + 1);
|
|
195
|
+
vt[n] = i;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
const ce = new RegExp(Object.keys(vt).join("|") + "|" + oe, "gu"), ae = (i) => {
|
|
199
|
+
nt === void 0 && (nt = pe(re));
|
|
200
|
+
}, wt = (i, t = "NFKD") => i.normalize(t), st = (i) => Array.from(i).reduce(
|
|
201
|
+
/**
|
|
202
|
+
* @param {string} result
|
|
203
|
+
* @param {string} char
|
|
204
|
+
*/
|
|
205
|
+
(t, e) => t + de(e),
|
|
206
|
+
""
|
|
207
|
+
), de = (i) => (i = wt(i).toLowerCase().replace(ce, (t) => vt[t] || ""), wt(i, "NFC"));
|
|
208
|
+
function* ue(i) {
|
|
209
|
+
for (const [t, e] of i)
|
|
210
|
+
for (let n = t; n <= e; n++) {
|
|
211
|
+
let s = String.fromCharCode(n), o = st(s);
|
|
212
|
+
o != s.toLowerCase() && (o.length > le || o.length != 0 && (yield { folded: o, composed: s, code_point: n }));
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
const ge = (i) => {
|
|
216
|
+
const t = {}, e = (n, s) => {
|
|
217
|
+
const o = t[n] || /* @__PURE__ */ new Set(), r = new RegExp("^" + St(o) + "$", "iu");
|
|
218
|
+
s.match(r) || (o.add(Q(s)), t[n] = o);
|
|
219
|
+
};
|
|
220
|
+
for (let n of ue(i))
|
|
221
|
+
e(n.folded, n.folded), e(n.folded, n.composed);
|
|
222
|
+
return t;
|
|
223
|
+
}, pe = (i) => {
|
|
224
|
+
const t = ge(i), e = {};
|
|
225
|
+
let n = [];
|
|
226
|
+
for (let o in t) {
|
|
227
|
+
let r = t[o];
|
|
228
|
+
r && (e[o] = St(r)), o.length > 1 && n.push(Q(o));
|
|
229
|
+
}
|
|
230
|
+
n.sort((o, r) => r.length - o.length);
|
|
231
|
+
const s = lt(n);
|
|
232
|
+
return xt = new RegExp("^" + s, "u"), e;
|
|
233
|
+
}, he = (i, t = 1) => {
|
|
234
|
+
let e = 0;
|
|
235
|
+
return i = i.map((n) => (nt[n] && (e += n.length), nt[n] || n)), e >= t ? Ft(i) : "";
|
|
236
|
+
}, me = (i, t = 1) => (t = Math.max(t, i.length - 1), lt(Kt(i).map((e) => he(e, t)))), Lt = (i, t = !0) => {
|
|
237
|
+
let e = i.length > 1 ? 1 : 0;
|
|
238
|
+
return lt(i.map((n) => {
|
|
239
|
+
let s = [];
|
|
240
|
+
const o = t ? n.length() : n.length() - 1;
|
|
241
|
+
for (let r = 0; r < o; r++)
|
|
242
|
+
s.push(me(n.substrs[r] || "", e));
|
|
243
|
+
return Ft(s);
|
|
244
|
+
}));
|
|
245
|
+
}, fe = (i, t) => {
|
|
246
|
+
for (const e of t) {
|
|
247
|
+
if (e.start != i.start || e.end != i.end || e.substrs.join("") !== i.substrs.join(""))
|
|
248
|
+
continue;
|
|
249
|
+
let n = i.parts;
|
|
250
|
+
const s = (r) => {
|
|
251
|
+
for (const l of n) {
|
|
252
|
+
if (l.start === r.start && l.substr === r.substr)
|
|
253
|
+
return !1;
|
|
254
|
+
if (!(r.length == 1 || l.length == 1) && (r.start < l.start && r.end > l.start || l.start < r.start && l.end > r.start))
|
|
255
|
+
return !0;
|
|
256
|
+
}
|
|
257
|
+
return !1;
|
|
258
|
+
};
|
|
259
|
+
if (!(e.parts.filter(s).length > 0))
|
|
260
|
+
return !0;
|
|
261
|
+
}
|
|
262
|
+
return !1;
|
|
263
|
+
};
|
|
264
|
+
class rt {
|
|
265
|
+
constructor() {
|
|
266
|
+
k(this, "parts");
|
|
267
|
+
k(this, "substrs");
|
|
268
|
+
k(this, "start");
|
|
269
|
+
k(this, "end");
|
|
270
|
+
this.parts = [], this.substrs = [], this.start = 0, this.end = 0;
|
|
271
|
+
}
|
|
272
|
+
add(t) {
|
|
273
|
+
t && (this.parts.push(t), this.substrs.push(t.substr), this.start = Math.min(t.start, this.start), this.end = Math.max(t.end, this.end));
|
|
274
|
+
}
|
|
275
|
+
last() {
|
|
276
|
+
return this.parts[this.parts.length - 1];
|
|
277
|
+
}
|
|
278
|
+
length() {
|
|
279
|
+
return this.parts.length;
|
|
280
|
+
}
|
|
281
|
+
clone(t, e) {
|
|
282
|
+
let n = new rt(), s = JSON.parse(JSON.stringify(this.parts)), o = s.pop();
|
|
283
|
+
for (const a of s)
|
|
284
|
+
n.add(a);
|
|
285
|
+
let r = e.substr.substring(0, t - o.start), l = r.length;
|
|
286
|
+
return n.add({ start: o.start, end: o.start + l, length: l, substr: r }), n;
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
const be = (i) => {
|
|
290
|
+
ae(), i = st(i);
|
|
291
|
+
let t = "", e = [new rt()];
|
|
292
|
+
for (let n = 0; n < i.length; n++) {
|
|
293
|
+
let o = i.substring(n).match(xt);
|
|
294
|
+
const r = i.substring(n, n + 1), l = o ? o[0] : null;
|
|
295
|
+
let a = [], c = /* @__PURE__ */ new Set();
|
|
296
|
+
for (const d of e) {
|
|
297
|
+
const u = d.last();
|
|
298
|
+
if (!u || u.length == 1 || u.end <= n)
|
|
299
|
+
if (l) {
|
|
300
|
+
const p = l.length;
|
|
301
|
+
d.add({ start: n, end: n + p, length: p, substr: l }), c.add("1");
|
|
302
|
+
} else
|
|
303
|
+
d.add({ start: n, end: n + 1, length: 1, substr: r }), c.add("2");
|
|
304
|
+
else if (l) {
|
|
305
|
+
let p = d.clone(n, u);
|
|
306
|
+
const y = l.length;
|
|
307
|
+
p.add({ start: n, end: n + y, length: y, substr: l }), a.push(p);
|
|
308
|
+
} else
|
|
309
|
+
c.add("3");
|
|
310
|
+
}
|
|
311
|
+
if (a.length > 0) {
|
|
312
|
+
a = a.sort((d, u) => d.length() - u.length());
|
|
313
|
+
for (let d of a)
|
|
314
|
+
fe(d, e) || e.push(d);
|
|
315
|
+
continue;
|
|
316
|
+
}
|
|
317
|
+
if (n > 0 && c.size == 1 && !c.has("3")) {
|
|
318
|
+
t += Lt(e, !1);
|
|
319
|
+
let d = new rt();
|
|
320
|
+
const u = e[0];
|
|
321
|
+
u && d.add(u.last()), e = [d];
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
return t += Lt(e, !0), t;
|
|
325
|
+
}, ve = (i, t) => {
|
|
326
|
+
if (i)
|
|
327
|
+
return i[t];
|
|
328
|
+
}, Ie = (i, t) => {
|
|
329
|
+
if (i) {
|
|
330
|
+
for (var e, n = t.split("."); (e = n.shift()) && (i = i[e]); )
|
|
331
|
+
;
|
|
332
|
+
return i;
|
|
333
|
+
}
|
|
334
|
+
}, dt = (i, t, e) => {
|
|
335
|
+
var n, s;
|
|
336
|
+
return !i || (i = i + "", t.regex == null) || (s = i.search(t.regex), s === -1) ? 0 : (n = t.string.length / i.length, s === 0 && (n += 0.5), n * e);
|
|
337
|
+
}, ut = (i, t) => {
|
|
338
|
+
var e = i[t];
|
|
339
|
+
if (typeof e == "function")
|
|
340
|
+
return e;
|
|
341
|
+
e && !Array.isArray(e) && (i[t] = [e]);
|
|
342
|
+
}, P = (i, t) => {
|
|
343
|
+
if (Array.isArray(i))
|
|
344
|
+
i.forEach(t);
|
|
345
|
+
else
|
|
346
|
+
for (var e in i)
|
|
347
|
+
i.hasOwnProperty(e) && t(i[e], e);
|
|
348
|
+
}, Ce = (i, t) => typeof i == "number" && typeof t == "number" ? i > t ? 1 : i < t ? -1 : 0 : (i = st(i + "").toLowerCase(), t = st(t + "").toLowerCase(), i > t ? 1 : t > i ? -1 : 0);
|
|
349
|
+
class ye {
|
|
350
|
+
/**
|
|
351
|
+
* Textually searches arrays and hashes of objects
|
|
352
|
+
* by property (or multiple properties). Designed
|
|
353
|
+
* specifically for autocomplete.
|
|
354
|
+
*
|
|
355
|
+
*/
|
|
356
|
+
constructor(t, e) {
|
|
357
|
+
k(this, "items");
|
|
358
|
+
// []|{};
|
|
359
|
+
k(this, "settings");
|
|
360
|
+
this.items = t, this.settings = e || { diacritics: !0 };
|
|
361
|
+
}
|
|
362
|
+
/**
|
|
363
|
+
* Splits a search string into an array of individual
|
|
364
|
+
* regexps to be used to match results.
|
|
365
|
+
*
|
|
366
|
+
*/
|
|
367
|
+
tokenize(t, e, n) {
|
|
368
|
+
if (!t || !t.length)
|
|
369
|
+
return [];
|
|
370
|
+
const s = [], o = t.split(/\s+/);
|
|
371
|
+
var r;
|
|
372
|
+
return n && (r = new RegExp("^(" + Object.keys(n).map(Q).join("|") + "):(.*)$")), o.forEach((l) => {
|
|
373
|
+
let a, c = null, d = null;
|
|
374
|
+
r && (a = l.match(r)) && (c = a[1], l = a[2]), l.length > 0 && (this.settings.diacritics ? d = be(l) || null : d = Q(l), d && e && (d = "\\b" + d)), s.push({
|
|
375
|
+
string: l,
|
|
376
|
+
regex: d ? new RegExp(d, "iu") : null,
|
|
377
|
+
field: c
|
|
378
|
+
});
|
|
379
|
+
}), s;
|
|
380
|
+
}
|
|
381
|
+
/**
|
|
382
|
+
* Returns a function to be used to score individual results.
|
|
383
|
+
*
|
|
384
|
+
* Good matches will have a higher score than poor matches.
|
|
385
|
+
* If an item is not a match, 0 will be returned by the function.
|
|
386
|
+
*
|
|
387
|
+
* @returns {T.ScoreFn}
|
|
388
|
+
*/
|
|
389
|
+
getScoreFunction(t, e) {
|
|
390
|
+
var n = this.prepareSearch(t, e);
|
|
391
|
+
return this._getScoreFunction(n);
|
|
392
|
+
}
|
|
393
|
+
/**
|
|
394
|
+
* @returns {T.ScoreFn}
|
|
395
|
+
*
|
|
396
|
+
*/
|
|
397
|
+
_getScoreFunction(t) {
|
|
398
|
+
const e = t.tokens, n = e.length;
|
|
399
|
+
if (!n)
|
|
400
|
+
return function() {
|
|
401
|
+
return 0;
|
|
402
|
+
};
|
|
403
|
+
const s = t.options.fields, o = t.weights, r = s.length, l = t.getAttrFn;
|
|
404
|
+
if (!r)
|
|
405
|
+
return function() {
|
|
406
|
+
return 1;
|
|
407
|
+
};
|
|
408
|
+
const a = /* @__PURE__ */ function() {
|
|
409
|
+
return r === 1 ? function(c, d) {
|
|
410
|
+
const u = s[0].field;
|
|
411
|
+
return dt(l(d, u), c, o[u] || 1);
|
|
412
|
+
} : function(c, d) {
|
|
413
|
+
var u = 0;
|
|
414
|
+
if (c.field) {
|
|
415
|
+
const p = l(d, c.field);
|
|
416
|
+
!c.regex && p ? u += 1 / r : u += dt(p, c, 1);
|
|
417
|
+
} else
|
|
418
|
+
P(o, (p, y) => {
|
|
419
|
+
u += dt(l(d, y), c, p);
|
|
420
|
+
});
|
|
421
|
+
return u / r;
|
|
422
|
+
};
|
|
423
|
+
}();
|
|
424
|
+
return n === 1 ? function(c) {
|
|
425
|
+
return a(e[0], c);
|
|
426
|
+
} : t.options.conjunction === "and" ? function(c) {
|
|
427
|
+
var d, u = 0;
|
|
428
|
+
for (let p of e) {
|
|
429
|
+
if (d = a(p, c), d <= 0)
|
|
430
|
+
return 0;
|
|
431
|
+
u += d;
|
|
432
|
+
}
|
|
433
|
+
return u / n;
|
|
434
|
+
} : function(c) {
|
|
435
|
+
var d = 0;
|
|
436
|
+
return P(e, (u) => {
|
|
437
|
+
d += a(u, c);
|
|
438
|
+
}), d / n;
|
|
439
|
+
};
|
|
440
|
+
}
|
|
441
|
+
/**
|
|
442
|
+
* Returns a function that can be used to compare two
|
|
443
|
+
* results, for sorting purposes. If no sorting should
|
|
444
|
+
* be performed, `null` will be returned.
|
|
445
|
+
*
|
|
446
|
+
* @return function(a,b)
|
|
447
|
+
*/
|
|
448
|
+
getSortFunction(t, e) {
|
|
449
|
+
var n = this.prepareSearch(t, e);
|
|
450
|
+
return this._getSortFunction(n);
|
|
451
|
+
}
|
|
452
|
+
_getSortFunction(t) {
|
|
453
|
+
var e, n = [];
|
|
454
|
+
const s = this, o = t.options, r = !t.query && o.sort_empty ? o.sort_empty : o.sort;
|
|
455
|
+
if (typeof r == "function")
|
|
456
|
+
return r.bind(this);
|
|
457
|
+
const l = function(c, d) {
|
|
458
|
+
return c === "$score" ? d.score : t.getAttrFn(s.items[d.id], c);
|
|
459
|
+
};
|
|
460
|
+
if (r)
|
|
461
|
+
for (let c of r)
|
|
462
|
+
(t.query || c.field !== "$score") && n.push(c);
|
|
463
|
+
if (t.query) {
|
|
464
|
+
e = !0;
|
|
465
|
+
for (let c of n)
|
|
466
|
+
if (c.field === "$score") {
|
|
467
|
+
e = !1;
|
|
468
|
+
break;
|
|
469
|
+
}
|
|
470
|
+
e && n.unshift({ field: "$score", direction: "desc" });
|
|
471
|
+
} else
|
|
472
|
+
n = n.filter((c) => c.field !== "$score");
|
|
473
|
+
return n.length ? function(c, d) {
|
|
474
|
+
var u, p;
|
|
475
|
+
for (let y of n)
|
|
476
|
+
if (p = y.field, u = (y.direction === "desc" ? -1 : 1) * Ce(l(p, c), l(p, d)), u)
|
|
477
|
+
return u;
|
|
478
|
+
return 0;
|
|
479
|
+
} : null;
|
|
480
|
+
}
|
|
481
|
+
/**
|
|
482
|
+
* Parses a search query and returns an object
|
|
483
|
+
* with tokens and fields ready to be populated
|
|
484
|
+
* with results.
|
|
485
|
+
*
|
|
486
|
+
*/
|
|
487
|
+
prepareSearch(t, e) {
|
|
488
|
+
const n = {};
|
|
489
|
+
var s = Object.assign({}, e);
|
|
490
|
+
if (ut(s, "sort"), ut(s, "sort_empty"), s.fields) {
|
|
491
|
+
ut(s, "fields");
|
|
492
|
+
const o = [];
|
|
493
|
+
s.fields.forEach((r) => {
|
|
494
|
+
typeof r == "string" && (r = { field: r, weight: 1 }), o.push(r), n[r.field] = "weight" in r ? r.weight : 1;
|
|
495
|
+
}), s.fields = o;
|
|
496
|
+
}
|
|
497
|
+
return {
|
|
498
|
+
options: s,
|
|
499
|
+
query: t.toLowerCase().trim(),
|
|
500
|
+
tokens: this.tokenize(t, s.respect_word_boundaries, n),
|
|
501
|
+
total: 0,
|
|
502
|
+
items: [],
|
|
503
|
+
weights: n,
|
|
504
|
+
getAttrFn: s.nesting ? Ie : ve
|
|
505
|
+
};
|
|
506
|
+
}
|
|
507
|
+
/**
|
|
508
|
+
* Searches through all items and returns a sorted array of matches.
|
|
509
|
+
*
|
|
510
|
+
*/
|
|
511
|
+
search(t, e) {
|
|
512
|
+
var n = this, s, o;
|
|
513
|
+
o = this.prepareSearch(t, e), e = o.options, t = o.query;
|
|
514
|
+
const r = e.score || n._getScoreFunction(o);
|
|
515
|
+
t.length ? P(n.items, (a, c) => {
|
|
516
|
+
s = r(a), (e.filter === !1 || s > 0) && o.items.push({ score: s, id: c });
|
|
517
|
+
}) : P(n.items, (a, c) => {
|
|
518
|
+
o.items.push({ score: 1, id: c });
|
|
519
|
+
});
|
|
520
|
+
const l = n._getSortFunction(o);
|
|
521
|
+
return l && o.items.sort(l), o.total = o.items.length, typeof e.limit == "number" && (o.items = o.items.slice(0, e.limit)), o;
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
const H = (i) => typeof i > "u" || i === null ? null : it(i), it = (i) => typeof i == "boolean" ? i ? "1" : "0" : i + "", gt = (i) => (i + "").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """), Ze = (i, t) => t > 0 ? window.setTimeout(i, t) : (i.call(null), null), we = (i, t) => {
|
|
525
|
+
var e;
|
|
526
|
+
return function(n, s) {
|
|
527
|
+
var o = this;
|
|
528
|
+
e && (o.loading = Math.max(o.loading - 1, 0), clearTimeout(e)), e = setTimeout(function() {
|
|
529
|
+
e = null, o.loadedSearches[n] = !0, i.call(o, n, s);
|
|
530
|
+
}, t);
|
|
531
|
+
};
|
|
532
|
+
}, Wt = (i, t, e) => {
|
|
533
|
+
var n, s = i.trigger, o = {};
|
|
534
|
+
i.trigger = function() {
|
|
535
|
+
var r = arguments[0];
|
|
536
|
+
if (t.indexOf(r) !== -1)
|
|
537
|
+
o[r] = arguments;
|
|
538
|
+
else
|
|
539
|
+
return s.apply(i, arguments);
|
|
540
|
+
}, e.apply(i, []), i.trigger = s;
|
|
541
|
+
for (n of t)
|
|
542
|
+
n in o && s.apply(i, o[n]);
|
|
543
|
+
}, Le = (i) => ({
|
|
544
|
+
start: i.selectionStart || 0,
|
|
545
|
+
length: (i.selectionEnd || 0) - (i.selectionStart || 0)
|
|
546
|
+
}), W = (i, t = !1) => {
|
|
547
|
+
i && (i.preventDefault(), t && i.stopPropagation());
|
|
548
|
+
}, X = (i, t, e, n) => {
|
|
549
|
+
i.addEventListener(t, e, n);
|
|
550
|
+
}, S = (i, t) => {
|
|
551
|
+
if (!t || !t[i])
|
|
552
|
+
return !1;
|
|
553
|
+
var e = (t.altKey ? 1 : 0) + (t.ctrlKey ? 1 : 0) + (t.shiftKey ? 1 : 0) + (t.metaKey ? 1 : 0);
|
|
554
|
+
return e === 1;
|
|
555
|
+
}, pt = (i, t) => {
|
|
556
|
+
const e = i.getAttribute("id");
|
|
557
|
+
return e || (i.setAttribute("id", t), t);
|
|
558
|
+
}, Gt = (i) => i.replace(/[\\"']/g, "\\$&"), K = (i, t) => {
|
|
559
|
+
t && i.append(t);
|
|
560
|
+
}, A = (i, t) => {
|
|
561
|
+
if (Array.isArray(i))
|
|
562
|
+
i.forEach(t);
|
|
563
|
+
else
|
|
564
|
+
for (var e in i)
|
|
565
|
+
i.hasOwnProperty(e) && t(i[e], e);
|
|
566
|
+
}, R = (i) => {
|
|
567
|
+
if (i.jquery)
|
|
568
|
+
return i[0];
|
|
569
|
+
if (i instanceof HTMLElement)
|
|
570
|
+
return i;
|
|
571
|
+
if (Dt(i)) {
|
|
572
|
+
var t = document.createElement("template");
|
|
573
|
+
return t.innerHTML = i.trim(), t.content.firstChild;
|
|
574
|
+
}
|
|
575
|
+
return document.querySelector(i);
|
|
576
|
+
}, Dt = (i) => typeof i == "string" && i.indexOf("<") > -1, We = (i) => i.replace(/['"\\]/g, "\\$&"), ht = (i, t) => {
|
|
577
|
+
var e = document.createEvent("HTMLEvents");
|
|
578
|
+
e.initEvent(t, !0, !1), i.dispatchEvent(e);
|
|
579
|
+
}, q = (i, t) => {
|
|
580
|
+
Object.assign(i.style, t);
|
|
581
|
+
}, J = (i, ...t) => {
|
|
582
|
+
var e = _t(t);
|
|
583
|
+
i = jt(i), i.map((n) => {
|
|
584
|
+
e.map((s) => {
|
|
585
|
+
n.classList.add(s);
|
|
586
|
+
});
|
|
587
|
+
});
|
|
588
|
+
}, V = (i, ...t) => {
|
|
589
|
+
var e = _t(t);
|
|
590
|
+
i = jt(i), i.map((n) => {
|
|
591
|
+
e.map((s) => {
|
|
592
|
+
n.classList.remove(s);
|
|
593
|
+
});
|
|
594
|
+
});
|
|
595
|
+
}, _t = (i) => {
|
|
596
|
+
var t = [];
|
|
597
|
+
return A(i, (e) => {
|
|
598
|
+
typeof e == "string" && (e = e.trim().split(/[\t\n\f\r\s]/)), Array.isArray(e) && (t = t.concat(e));
|
|
599
|
+
}), t.filter(Boolean);
|
|
600
|
+
}, jt = (i) => (Array.isArray(i) || (i = [i]), i), mt = (i, t, e) => {
|
|
601
|
+
if (!(e && !e.contains(i)))
|
|
602
|
+
for (; i && i.matches; ) {
|
|
603
|
+
if (i.matches(t))
|
|
604
|
+
return i;
|
|
605
|
+
i = i.parentNode;
|
|
606
|
+
}
|
|
607
|
+
}, At = (i, t = 0) => t > 0 ? i[i.length - 1] : i[0], Ge = (i) => Object.keys(i).length === 0, Bt = (i, t) => {
|
|
608
|
+
if (!i)
|
|
609
|
+
return -1;
|
|
610
|
+
t = t || i.nodeName;
|
|
611
|
+
for (var e = 0; i = i.previousElementSibling; )
|
|
612
|
+
i.matches(t) && e++;
|
|
613
|
+
return e;
|
|
614
|
+
}, w = (i, t) => {
|
|
615
|
+
A(t, (e, n) => {
|
|
616
|
+
e == null ? i.removeAttribute(n) : i.setAttribute(n, "" + e);
|
|
617
|
+
});
|
|
618
|
+
}, ft = (i, t) => {
|
|
619
|
+
i.parentNode && i.parentNode.replaceChild(t, i);
|
|
620
|
+
}, Ae = (i, t) => {
|
|
621
|
+
if (t === null)
|
|
622
|
+
return;
|
|
623
|
+
if (typeof t == "string") {
|
|
624
|
+
if (!t.length)
|
|
625
|
+
return;
|
|
626
|
+
t = new RegExp(t, "i");
|
|
627
|
+
}
|
|
628
|
+
const e = (o) => {
|
|
629
|
+
var r = o.data.match(t);
|
|
630
|
+
if (r && o.data.length > 0) {
|
|
631
|
+
var l = document.createElement("span");
|
|
632
|
+
l.className = "highlight";
|
|
633
|
+
var a = o.splitText(r.index);
|
|
634
|
+
a.splitText(r[0].length);
|
|
635
|
+
var c = a.cloneNode(!0);
|
|
636
|
+
return l.appendChild(c), ft(a, l), 1;
|
|
637
|
+
}
|
|
638
|
+
return 0;
|
|
639
|
+
}, n = (o) => {
|
|
640
|
+
o.nodeType === 1 && o.childNodes && !/(script|style)/i.test(o.tagName) && (o.className !== "highlight" || o.tagName !== "SPAN") && Array.from(o.childNodes).forEach((r) => {
|
|
641
|
+
s(r);
|
|
642
|
+
});
|
|
643
|
+
}, s = (o) => o.nodeType === 3 ? e(o) : (n(o), 0);
|
|
644
|
+
s(i);
|
|
645
|
+
}, Be = (i) => {
|
|
646
|
+
var t = i.querySelectorAll("span.highlight");
|
|
647
|
+
Array.prototype.forEach.call(t, function(e) {
|
|
648
|
+
var n = e.parentNode;
|
|
649
|
+
n.replaceChild(e.firstChild, e), n.normalize();
|
|
650
|
+
});
|
|
651
|
+
}, Xe = 65, Ye = 13, Je = 27, Oe = 37, He = 38, Me = 39, Re = 40, Xt = 8, Ne = 46, Yt = 9, Ve = typeof navigator > "u" ? !1 : /Mac/.test(navigator.userAgent), tt = Ve ? "metaKey" : "ctrlKey", Jt = {
|
|
652
|
+
options: [],
|
|
653
|
+
optgroups: [],
|
|
654
|
+
plugins: [],
|
|
655
|
+
delimiter: ",",
|
|
656
|
+
splitOn: null,
|
|
657
|
+
// regexp or string for splitting up values from a paste command
|
|
658
|
+
persist: !0,
|
|
659
|
+
diacritics: !0,
|
|
660
|
+
create: null,
|
|
661
|
+
createOnBlur: !1,
|
|
662
|
+
createFilter: null,
|
|
663
|
+
highlight: !0,
|
|
664
|
+
openOnFocus: !0,
|
|
665
|
+
shouldOpen: null,
|
|
666
|
+
maxOptions: 50,
|
|
667
|
+
maxItems: null,
|
|
668
|
+
hideSelected: null,
|
|
669
|
+
duplicates: !1,
|
|
670
|
+
addPrecedence: !1,
|
|
671
|
+
selectOnTab: !1,
|
|
672
|
+
preload: null,
|
|
673
|
+
allowEmptyOption: !1,
|
|
674
|
+
//closeAfterSelect: false,
|
|
675
|
+
refreshThrottle: 300,
|
|
676
|
+
loadThrottle: 300,
|
|
677
|
+
loadingClass: "loading",
|
|
678
|
+
dataAttr: null,
|
|
679
|
+
//'data-data',
|
|
680
|
+
optgroupField: "optgroup",
|
|
681
|
+
valueField: "value",
|
|
682
|
+
labelField: "text",
|
|
683
|
+
disabledField: "disabled",
|
|
684
|
+
optgroupLabelField: "label",
|
|
685
|
+
optgroupValueField: "value",
|
|
686
|
+
lockOptgroupOrder: !1,
|
|
687
|
+
sortField: "$order",
|
|
688
|
+
searchField: ["text"],
|
|
689
|
+
searchConjunction: "and",
|
|
690
|
+
mode: null,
|
|
691
|
+
wrapperClass: "ts-wrapper",
|
|
692
|
+
controlClass: "ts-control",
|
|
693
|
+
dropdownClass: "ts-dropdown",
|
|
694
|
+
dropdownContentClass: "ts-dropdown-content",
|
|
695
|
+
itemClass: "item",
|
|
696
|
+
optionClass: "option",
|
|
697
|
+
dropdownParent: null,
|
|
698
|
+
controlInput: '<input type="text" autocomplete="off" size="1" />',
|
|
699
|
+
copyClassesToDropdown: !1,
|
|
700
|
+
placeholder: null,
|
|
701
|
+
hidePlaceholder: null,
|
|
702
|
+
shouldLoad: function(i) {
|
|
703
|
+
return i.length > 0;
|
|
704
|
+
},
|
|
705
|
+
/*
|
|
706
|
+
load : null, // function(query, callback) { ... }
|
|
707
|
+
score : null, // function(search) { ... }
|
|
708
|
+
onInitialize : null, // function() { ... }
|
|
709
|
+
onChange : null, // function(value) { ... }
|
|
710
|
+
onItemAdd : null, // function(value, $item) { ... }
|
|
711
|
+
onItemRemove : null, // function(value) { ... }
|
|
712
|
+
onClear : null, // function() { ... }
|
|
713
|
+
onOptionAdd : null, // function(value, data) { ... }
|
|
714
|
+
onOptionRemove : null, // function(value) { ... }
|
|
715
|
+
onOptionClear : null, // function() { ... }
|
|
716
|
+
onOptionGroupAdd : null, // function(id, data) { ... }
|
|
717
|
+
onOptionGroupRemove : null, // function(id) { ... }
|
|
718
|
+
onOptionGroupClear : null, // function() { ... }
|
|
719
|
+
onDropdownOpen : null, // function(dropdown) { ... }
|
|
720
|
+
onDropdownClose : null, // function(dropdown) { ... }
|
|
721
|
+
onType : null, // function(str) { ... }
|
|
722
|
+
onDelete : null, // function(values) { ... }
|
|
723
|
+
*/
|
|
724
|
+
render: {
|
|
725
|
+
/*
|
|
726
|
+
item: null,
|
|
727
|
+
optgroup: null,
|
|
728
|
+
optgroup_header: null,
|
|
729
|
+
option: null,
|
|
730
|
+
option_create: null
|
|
731
|
+
*/
|
|
732
|
+
}
|
|
733
|
+
};
|
|
734
|
+
function Ot(i, t) {
|
|
735
|
+
var e = Object.assign({}, Jt, t), n = e.dataAttr, s = e.labelField, o = e.valueField, r = e.disabledField, l = e.optgroupField, a = e.optgroupLabelField, c = e.optgroupValueField, d = i.tagName.toLowerCase(), u = i.getAttribute("placeholder") || i.getAttribute("data-placeholder");
|
|
736
|
+
if (!u && !e.allowEmptyOption) {
|
|
737
|
+
let b = i.querySelector('option[value=""]');
|
|
738
|
+
b && (u = b.textContent);
|
|
739
|
+
}
|
|
740
|
+
var p = {
|
|
741
|
+
placeholder: u,
|
|
742
|
+
options: [],
|
|
743
|
+
optgroups: [],
|
|
744
|
+
items: [],
|
|
745
|
+
maxItems: null
|
|
746
|
+
}, y = () => {
|
|
747
|
+
var b, Z = p.options, I = {}, h = 1;
|
|
748
|
+
let L = 0;
|
|
749
|
+
var M = (f) => {
|
|
750
|
+
var v = Object.assign({}, f.dataset), m = n && v[n];
|
|
751
|
+
return typeof m == "string" && m.length && (v = Object.assign(v, JSON.parse(m))), v;
|
|
752
|
+
}, E = (f, v) => {
|
|
753
|
+
var m = H(f.value);
|
|
754
|
+
if (m != null && !(!m && !e.allowEmptyOption)) {
|
|
755
|
+
if (I.hasOwnProperty(m)) {
|
|
756
|
+
if (v) {
|
|
757
|
+
var B = I[m][l];
|
|
758
|
+
B ? Array.isArray(B) ? B.push(v) : I[m][l] = [B, v] : I[m][l] = v;
|
|
759
|
+
}
|
|
760
|
+
} else {
|
|
761
|
+
var C = M(f);
|
|
762
|
+
C[s] = C[s] || f.textContent, C[o] = C[o] || m, C[r] = C[r] || f.disabled, C[l] = C[l] || v, C.$option = f, C.$order = C.$order || ++L, I[m] = C, Z.push(C);
|
|
763
|
+
}
|
|
764
|
+
f.selected && p.items.push(m);
|
|
765
|
+
}
|
|
766
|
+
}, D = (f) => {
|
|
767
|
+
var v, m;
|
|
768
|
+
m = M(f), m[a] = m[a] || f.getAttribute("label") || "", m[c] = m[c] || h++, m[r] = m[r] || f.disabled, m.$order = m.$order || ++L, p.optgroups.push(m), v = m[c], A(f.children, (B) => {
|
|
769
|
+
E(B, v);
|
|
770
|
+
});
|
|
771
|
+
};
|
|
772
|
+
p.maxItems = i.hasAttribute("multiple") ? null : 1, A(i.children, (f) => {
|
|
773
|
+
b = f.tagName.toLowerCase(), b === "optgroup" ? D(f) : b === "option" && E(f);
|
|
774
|
+
});
|
|
775
|
+
}, g = () => {
|
|
776
|
+
const b = i.getAttribute(n);
|
|
777
|
+
if (b)
|
|
778
|
+
p.options = JSON.parse(b), A(p.options, (I) => {
|
|
779
|
+
p.items.push(I[o]);
|
|
780
|
+
});
|
|
781
|
+
else {
|
|
782
|
+
var Z = i.value.trim() || "";
|
|
783
|
+
if (!e.allowEmptyOption && !Z.length)
|
|
784
|
+
return;
|
|
785
|
+
const I = Z.split(e.delimiter);
|
|
786
|
+
A(I, (h) => {
|
|
787
|
+
const L = {};
|
|
788
|
+
L[s] = h, L[o] = h, p.options.push(L);
|
|
789
|
+
}), p.items = I;
|
|
790
|
+
}
|
|
791
|
+
};
|
|
792
|
+
return d === "select" ? y() : g(), Object.assign({}, Jt, p, t);
|
|
793
|
+
}
|
|
794
|
+
var Ht = 0;
|
|
795
|
+
class Y extends ee(te) {
|
|
796
|
+
constructor(t, e) {
|
|
797
|
+
super(), this.order = 0, this.isOpen = !1, this.isDisabled = !1, this.isReadOnly = !1, 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.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, Ht++;
|
|
798
|
+
var n, s = R(t);
|
|
799
|
+
if (s.tomselect)
|
|
800
|
+
throw new Error("Tom Select already initialized on this element");
|
|
801
|
+
s.tomselect = this;
|
|
802
|
+
var o = window.getComputedStyle && window.getComputedStyle(s, null);
|
|
803
|
+
n = o.getPropertyValue("direction");
|
|
804
|
+
const r = Ot(s, e);
|
|
805
|
+
this.settings = r, this.input = s, this.tabIndex = s.tabIndex || 0, this.is_select_tag = s.tagName.toLowerCase() === "select", this.rtl = /rtl/i.test(n), this.inputId = pt(s, "tomselect-" + Ht), this.isRequired = s.required, this.sifter = new ye(this.options, { diacritics: r.diacritics }), r.mode = r.mode || (r.maxItems === 1 ? "single" : "multi"), typeof r.hideSelected != "boolean" && (r.hideSelected = r.mode === "multi"), typeof r.hidePlaceholder != "boolean" && (r.hidePlaceholder = r.mode !== "multi");
|
|
806
|
+
var l = r.createFilter;
|
|
807
|
+
typeof l != "function" && (typeof l == "string" && (l = new RegExp(l)), l instanceof RegExp ? r.createFilter = (Z) => l.test(Z) : r.createFilter = (Z) => this.settings.duplicates || !this.options[Z]), this.initializePlugins(r.plugins), this.setupCallbacks(), this.setupTemplates();
|
|
808
|
+
const a = R("<div>"), c = R("<div>"), d = this._render("dropdown"), u = R('<div role="listbox" tabindex="-1">'), p = this.input.getAttribute("class") || "", y = r.mode;
|
|
809
|
+
var g;
|
|
810
|
+
if (J(a, r.wrapperClass, p, y), J(c, r.controlClass), K(a, c), J(d, r.dropdownClass, y), r.copyClassesToDropdown && J(d, p), J(u, r.dropdownContentClass), K(d, u), R(r.dropdownParent || a).appendChild(d), Dt(r.controlInput)) {
|
|
811
|
+
g = R(r.controlInput);
|
|
812
|
+
var b = ["autocorrect", "autocapitalize", "autocomplete", "spellcheck"];
|
|
813
|
+
A(b, (Z) => {
|
|
814
|
+
s.getAttribute(Z) && w(g, { [Z]: s.getAttribute(Z) });
|
|
815
|
+
}), g.tabIndex = -1, c.appendChild(g), this.focus_node = g;
|
|
816
|
+
} else r.controlInput ? (g = R(r.controlInput), this.focus_node = g) : (g = R("<input/>"), this.focus_node = c);
|
|
817
|
+
this.wrapper = a, this.dropdown = d, this.dropdown_content = u, this.control = c, this.control_input = g, this.setup();
|
|
818
|
+
}
|
|
819
|
+
/**
|
|
820
|
+
* set up event bindings.
|
|
821
|
+
*
|
|
822
|
+
*/
|
|
823
|
+
setup() {
|
|
824
|
+
const t = this, e = t.settings, n = t.control_input, s = t.dropdown, o = t.dropdown_content, r = t.wrapper, l = t.control, a = t.input, c = t.focus_node, d = { passive: !0 }, u = t.inputId + "-ts-dropdown";
|
|
825
|
+
w(o, {
|
|
826
|
+
id: u
|
|
827
|
+
}), w(c, {
|
|
828
|
+
role: "combobox",
|
|
829
|
+
"aria-haspopup": "listbox",
|
|
830
|
+
"aria-expanded": "false",
|
|
831
|
+
"aria-controls": u
|
|
832
|
+
});
|
|
833
|
+
const p = pt(c, t.inputId + "-ts-control"), y = "label[for='" + We(t.inputId) + "']", g = document.querySelector(y), b = t.focus.bind(t);
|
|
834
|
+
if (g) {
|
|
835
|
+
X(g, "click", b), w(g, { for: p });
|
|
836
|
+
const h = pt(g, t.inputId + "-ts-label");
|
|
837
|
+
w(c, { "aria-labelledby": h }), w(o, { "aria-labelledby": h });
|
|
838
|
+
}
|
|
839
|
+
if (r.style.width = a.style.width, t.plugins.names.length) {
|
|
840
|
+
const h = "plugin-" + t.plugins.names.join(" plugin-");
|
|
841
|
+
J([r, s], h);
|
|
842
|
+
}
|
|
843
|
+
(e.maxItems === null || e.maxItems > 1) && t.is_select_tag && w(a, { multiple: "multiple" }), e.placeholder && w(n, { placeholder: e.placeholder }), !e.splitOn && e.delimiter && (e.splitOn = new RegExp("\\s*" + Q(e.delimiter) + "+\\s*")), e.load && e.loadThrottle && (e.load = we(e.load, e.loadThrottle)), X(s, "mousemove", () => {
|
|
844
|
+
t.ignoreHover = !1;
|
|
845
|
+
}), X(s, "mouseenter", (h) => {
|
|
846
|
+
var L = mt(h.target, "[data-selectable]", s);
|
|
847
|
+
L && t.onOptionHover(h, L);
|
|
848
|
+
}, { capture: !0 }), X(s, "click", (h) => {
|
|
849
|
+
const L = mt(h.target, "[data-selectable]");
|
|
850
|
+
L && (t.onOptionSelect(h, L), W(h, !0));
|
|
851
|
+
}), X(l, "click", (h) => {
|
|
852
|
+
var L = mt(h.target, "[data-ts-item]", l);
|
|
853
|
+
if (L && t.onItemSelect(h, L)) {
|
|
854
|
+
W(h, !0);
|
|
855
|
+
return;
|
|
856
|
+
}
|
|
857
|
+
n.value == "" && (t.onClick(), W(h, !0));
|
|
858
|
+
}), X(c, "keydown", (h) => t.onKeyDown(h)), X(n, "keypress", (h) => t.onKeyPress(h)), X(n, "input", (h) => t.onInput(h)), X(c, "blur", (h) => t.onBlur(h)), X(c, "focus", (h) => t.onFocus(h)), X(n, "paste", (h) => t.onPaste(h));
|
|
859
|
+
const Z = (h) => {
|
|
860
|
+
const L = h.composedPath()[0];
|
|
861
|
+
if (!r.contains(L) && !s.contains(L)) {
|
|
862
|
+
t.isFocused && t.blur(), t.inputState();
|
|
863
|
+
return;
|
|
864
|
+
}
|
|
865
|
+
L == n && t.isOpen ? h.stopPropagation() : W(h, !0);
|
|
866
|
+
}, I = () => {
|
|
867
|
+
t.isOpen && t.positionDropdown();
|
|
868
|
+
};
|
|
869
|
+
X(document, "mousedown", Z), X(window, "scroll", I, d), X(window, "resize", I, d), this._destroy = () => {
|
|
870
|
+
document.removeEventListener("mousedown", Z), window.removeEventListener("scroll", I), window.removeEventListener("resize", I), g && g.removeEventListener("click", b);
|
|
871
|
+
}, this.revertSettings = {
|
|
872
|
+
innerHTML: a.innerHTML,
|
|
873
|
+
tabIndex: a.tabIndex
|
|
874
|
+
}, a.tabIndex = -1, a.insertAdjacentElement("afterend", t.wrapper), t.sync(!1), e.items = [], delete e.optgroups, delete e.options, X(a, "invalid", () => {
|
|
875
|
+
t.isValid && (t.isValid = !1, t.isInvalid = !0, t.refreshState());
|
|
876
|
+
}), 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), J(a, "tomselected", "ts-hidden-accessible"), t.trigger("initialize"), e.preload === !0 && t.preload();
|
|
877
|
+
}
|
|
878
|
+
/**
|
|
879
|
+
* Register options and optgroups
|
|
880
|
+
*
|
|
881
|
+
*/
|
|
882
|
+
setupOptions(t = [], e = []) {
|
|
883
|
+
this.addOptions(t), A(e, (n) => {
|
|
884
|
+
this.registerOptionGroup(n);
|
|
885
|
+
});
|
|
886
|
+
}
|
|
887
|
+
/**
|
|
888
|
+
* Sets up default rendering functions.
|
|
889
|
+
*/
|
|
890
|
+
setupTemplates() {
|
|
891
|
+
var t = this, e = t.settings.labelField, n = t.settings.optgroupLabelField, s = {
|
|
892
|
+
optgroup: (o) => {
|
|
893
|
+
let r = document.createElement("div");
|
|
894
|
+
return r.className = "optgroup", r.appendChild(o.options), r;
|
|
895
|
+
},
|
|
896
|
+
optgroup_header: (o, r) => '<div class="optgroup-header">' + r(o[n]) + "</div>",
|
|
897
|
+
option: (o, r) => "<div>" + r(o[e]) + "</div>",
|
|
898
|
+
item: (o, r) => "<div>" + r(o[e]) + "</div>",
|
|
899
|
+
option_create: (o, r) => '<div class="create">Add <strong>' + r(o.input) + "</strong>…</div>",
|
|
900
|
+
no_results: () => '<div class="no-results">No results found</div>',
|
|
901
|
+
loading: () => '<div class="spinner"></div>',
|
|
902
|
+
not_loading: () => {
|
|
903
|
+
},
|
|
904
|
+
dropdown: () => "<div></div>"
|
|
905
|
+
};
|
|
906
|
+
t.settings.render = Object.assign({}, s, t.settings.render);
|
|
907
|
+
}
|
|
908
|
+
/**
|
|
909
|
+
* Maps fired events to callbacks provided
|
|
910
|
+
* in the settings used when creating the control.
|
|
911
|
+
*/
|
|
912
|
+
setupCallbacks() {
|
|
913
|
+
var t, e, n = {
|
|
914
|
+
initialize: "onInitialize",
|
|
915
|
+
change: "onChange",
|
|
916
|
+
item_add: "onItemAdd",
|
|
917
|
+
item_remove: "onItemRemove",
|
|
918
|
+
item_select: "onItemSelect",
|
|
919
|
+
clear: "onClear",
|
|
920
|
+
option_add: "onOptionAdd",
|
|
921
|
+
option_remove: "onOptionRemove",
|
|
922
|
+
option_clear: "onOptionClear",
|
|
923
|
+
optgroup_add: "onOptionGroupAdd",
|
|
924
|
+
optgroup_remove: "onOptionGroupRemove",
|
|
925
|
+
optgroup_clear: "onOptionGroupClear",
|
|
926
|
+
dropdown_open: "onDropdownOpen",
|
|
927
|
+
dropdown_close: "onDropdownClose",
|
|
928
|
+
type: "onType",
|
|
929
|
+
load: "onLoad",
|
|
930
|
+
focus: "onFocus",
|
|
931
|
+
blur: "onBlur"
|
|
932
|
+
};
|
|
933
|
+
for (t in n)
|
|
934
|
+
e = this.settings[n[t]], e && this.on(t, e);
|
|
935
|
+
}
|
|
936
|
+
/**
|
|
937
|
+
* Sync the Tom Select instance with the original input or select
|
|
938
|
+
*
|
|
939
|
+
*/
|
|
940
|
+
sync(t = !0) {
|
|
941
|
+
const e = this, n = t ? Ot(e.input, { delimiter: e.settings.delimiter }) : e.settings;
|
|
942
|
+
e.setupOptions(n.options, n.optgroups), e.setValue(n.items || [], !0), e.lastQuery = null;
|
|
943
|
+
}
|
|
944
|
+
/**
|
|
945
|
+
* Triggered when the main control element
|
|
946
|
+
* has a click event.
|
|
947
|
+
*
|
|
948
|
+
*/
|
|
949
|
+
onClick() {
|
|
950
|
+
var t = this;
|
|
951
|
+
if (t.activeItems.length > 0) {
|
|
952
|
+
t.clearActiveItems(), t.focus();
|
|
953
|
+
return;
|
|
954
|
+
}
|
|
955
|
+
t.isFocused && t.isOpen ? t.blur() : t.focus();
|
|
956
|
+
}
|
|
957
|
+
/**
|
|
958
|
+
* @deprecated v1.7
|
|
959
|
+
*
|
|
960
|
+
*/
|
|
961
|
+
onMouseDown() {
|
|
962
|
+
}
|
|
963
|
+
/**
|
|
964
|
+
* Triggered when the value of the control has been changed.
|
|
965
|
+
* This should propagate the event to the original DOM
|
|
966
|
+
* input / select element.
|
|
967
|
+
*/
|
|
968
|
+
onChange() {
|
|
969
|
+
ht(this.input, "input"), ht(this.input, "change");
|
|
970
|
+
}
|
|
971
|
+
/**
|
|
972
|
+
* Triggered on <input> paste.
|
|
973
|
+
*
|
|
974
|
+
*/
|
|
975
|
+
onPaste(t) {
|
|
976
|
+
var e = this;
|
|
977
|
+
if (e.isInputHidden || e.isLocked) {
|
|
978
|
+
W(t);
|
|
979
|
+
return;
|
|
980
|
+
}
|
|
981
|
+
e.settings.splitOn && setTimeout(() => {
|
|
982
|
+
var n = e.inputValue();
|
|
983
|
+
if (n.match(e.settings.splitOn)) {
|
|
984
|
+
var s = n.trim().split(e.settings.splitOn);
|
|
985
|
+
A(s, (o) => {
|
|
986
|
+
H(o) && (this.options[o] ? e.addItem(o) : e.createItem(o));
|
|
987
|
+
});
|
|
988
|
+
}
|
|
989
|
+
}, 0);
|
|
990
|
+
}
|
|
991
|
+
/**
|
|
992
|
+
* Triggered on <input> keypress.
|
|
993
|
+
*
|
|
994
|
+
*/
|
|
995
|
+
onKeyPress(t) {
|
|
996
|
+
var e = this;
|
|
997
|
+
if (e.isLocked) {
|
|
998
|
+
W(t);
|
|
999
|
+
return;
|
|
1000
|
+
}
|
|
1001
|
+
var n = String.fromCharCode(t.keyCode || t.which);
|
|
1002
|
+
if (e.settings.create && e.settings.mode === "multi" && n === e.settings.delimiter) {
|
|
1003
|
+
e.createItem(), W(t);
|
|
1004
|
+
return;
|
|
1005
|
+
}
|
|
1006
|
+
}
|
|
1007
|
+
/**
|
|
1008
|
+
* Triggered on <input> keydown.
|
|
1009
|
+
*
|
|
1010
|
+
*/
|
|
1011
|
+
onKeyDown(t) {
|
|
1012
|
+
var e = this;
|
|
1013
|
+
if (e.ignoreHover = !0, e.isLocked) {
|
|
1014
|
+
t.keyCode !== Yt && W(t);
|
|
1015
|
+
return;
|
|
1016
|
+
}
|
|
1017
|
+
switch (t.keyCode) {
|
|
1018
|
+
// ctrl+A: select all
|
|
1019
|
+
case Xe:
|
|
1020
|
+
if (S(tt, t) && e.control_input.value == "") {
|
|
1021
|
+
W(t), e.selectAll();
|
|
1022
|
+
return;
|
|
1023
|
+
}
|
|
1024
|
+
break;
|
|
1025
|
+
// esc: close dropdown
|
|
1026
|
+
case Je:
|
|
1027
|
+
e.isOpen && (W(t, !0), e.close()), e.clearActiveItems();
|
|
1028
|
+
return;
|
|
1029
|
+
// down: open dropdown or move selection down
|
|
1030
|
+
case Re:
|
|
1031
|
+
if (!e.isOpen && e.hasOptions)
|
|
1032
|
+
e.open();
|
|
1033
|
+
else if (e.activeOption) {
|
|
1034
|
+
let n = e.getAdjacent(e.activeOption, 1);
|
|
1035
|
+
n && e.setActiveOption(n);
|
|
1036
|
+
}
|
|
1037
|
+
W(t);
|
|
1038
|
+
return;
|
|
1039
|
+
// up: move selection up
|
|
1040
|
+
case He:
|
|
1041
|
+
if (e.activeOption) {
|
|
1042
|
+
let n = e.getAdjacent(e.activeOption, -1);
|
|
1043
|
+
n && e.setActiveOption(n);
|
|
1044
|
+
}
|
|
1045
|
+
W(t);
|
|
1046
|
+
return;
|
|
1047
|
+
// return: select active option
|
|
1048
|
+
case Ye:
|
|
1049
|
+
e.canSelect(e.activeOption) ? (e.onOptionSelect(t, e.activeOption), W(t)) : (e.settings.create && e.createItem() || document.activeElement == e.control_input && e.isOpen) && W(t);
|
|
1050
|
+
return;
|
|
1051
|
+
// left: modifiy item selection to the left
|
|
1052
|
+
case Oe:
|
|
1053
|
+
e.advanceSelection(-1, t);
|
|
1054
|
+
return;
|
|
1055
|
+
// right: modifiy item selection to the right
|
|
1056
|
+
case Me:
|
|
1057
|
+
e.advanceSelection(1, t);
|
|
1058
|
+
return;
|
|
1059
|
+
// tab: select active option and/or create item
|
|
1060
|
+
case Yt:
|
|
1061
|
+
e.settings.selectOnTab && (e.canSelect(e.activeOption) && (e.onOptionSelect(t, e.activeOption), W(t)), e.settings.create && e.createItem() && W(t));
|
|
1062
|
+
return;
|
|
1063
|
+
// delete|backspace: delete items
|
|
1064
|
+
case Xt:
|
|
1065
|
+
case Ne:
|
|
1066
|
+
e.deleteSelection(t);
|
|
1067
|
+
return;
|
|
1068
|
+
}
|
|
1069
|
+
e.isInputHidden && !S(tt, t) && W(t);
|
|
1070
|
+
}
|
|
1071
|
+
/**
|
|
1072
|
+
* Triggered on <input> keyup.
|
|
1073
|
+
*
|
|
1074
|
+
*/
|
|
1075
|
+
onInput(t) {
|
|
1076
|
+
if (this.isLocked)
|
|
1077
|
+
return;
|
|
1078
|
+
const e = this.inputValue();
|
|
1079
|
+
if (this.lastValue !== e) {
|
|
1080
|
+
if (this.lastValue = e, e == "") {
|
|
1081
|
+
this._onInput();
|
|
1082
|
+
return;
|
|
1083
|
+
}
|
|
1084
|
+
this.refreshTimeout && window.clearTimeout(this.refreshTimeout), this.refreshTimeout = Ze(() => {
|
|
1085
|
+
this.refreshTimeout = null, this._onInput();
|
|
1086
|
+
}, this.settings.refreshThrottle);
|
|
1087
|
+
}
|
|
1088
|
+
}
|
|
1089
|
+
_onInput() {
|
|
1090
|
+
const t = this.lastValue;
|
|
1091
|
+
this.settings.shouldLoad.call(this, t) && this.load(t), this.refreshOptions(), this.trigger("type", t);
|
|
1092
|
+
}
|
|
1093
|
+
/**
|
|
1094
|
+
* Triggered when the user rolls over
|
|
1095
|
+
* an option in the autocomplete dropdown menu.
|
|
1096
|
+
*
|
|
1097
|
+
*/
|
|
1098
|
+
onOptionHover(t, e) {
|
|
1099
|
+
this.ignoreHover || this.setActiveOption(e, !1);
|
|
1100
|
+
}
|
|
1101
|
+
/**
|
|
1102
|
+
* Triggered on <input> focus.
|
|
1103
|
+
*
|
|
1104
|
+
*/
|
|
1105
|
+
onFocus(t) {
|
|
1106
|
+
var e = this, n = e.isFocused;
|
|
1107
|
+
if (e.isDisabled || e.isReadOnly) {
|
|
1108
|
+
e.blur(), W(t);
|
|
1109
|
+
return;
|
|
1110
|
+
}
|
|
1111
|
+
e.ignoreFocus || (e.isFocused = !0, e.settings.preload === "focus" && e.preload(), n || e.trigger("focus"), e.activeItems.length || (e.inputState(), e.refreshOptions(!!e.settings.openOnFocus)), e.refreshState());
|
|
1112
|
+
}
|
|
1113
|
+
/**
|
|
1114
|
+
* Triggered on <input> blur.
|
|
1115
|
+
*
|
|
1116
|
+
*/
|
|
1117
|
+
onBlur(t) {
|
|
1118
|
+
if (document.hasFocus() !== !1) {
|
|
1119
|
+
var e = this;
|
|
1120
|
+
if (e.isFocused) {
|
|
1121
|
+
e.isFocused = !1, e.ignoreFocus = !1;
|
|
1122
|
+
var n = () => {
|
|
1123
|
+
e.close(), e.setActiveItem(), e.setCaret(e.items.length), e.trigger("blur");
|
|
1124
|
+
};
|
|
1125
|
+
e.settings.create && e.settings.createOnBlur ? e.createItem(null, n) : n();
|
|
1126
|
+
}
|
|
1127
|
+
}
|
|
1128
|
+
}
|
|
1129
|
+
/**
|
|
1130
|
+
* Triggered when the user clicks on an option
|
|
1131
|
+
* in the autocomplete dropdown menu.
|
|
1132
|
+
*
|
|
1133
|
+
*/
|
|
1134
|
+
onOptionSelect(t, e) {
|
|
1135
|
+
var n, s = this;
|
|
1136
|
+
e.parentElement && e.parentElement.matches("[data-disabled]") || (e.classList.contains("create") ? s.createItem(null, () => {
|
|
1137
|
+
s.settings.closeAfterSelect && s.close();
|
|
1138
|
+
}) : (n = e.dataset.value, typeof n < "u" && (s.lastQuery = null, s.addItem(n), s.settings.closeAfterSelect && s.close(), !s.settings.hideSelected && t.type && /click/.test(t.type) && s.setActiveOption(e))));
|
|
1139
|
+
}
|
|
1140
|
+
/**
|
|
1141
|
+
* Return true if the given option can be selected
|
|
1142
|
+
*
|
|
1143
|
+
*/
|
|
1144
|
+
canSelect(t) {
|
|
1145
|
+
return !!(this.isOpen && t && this.dropdown_content.contains(t));
|
|
1146
|
+
}
|
|
1147
|
+
/**
|
|
1148
|
+
* Triggered when the user clicks on an item
|
|
1149
|
+
* that has been selected.
|
|
1150
|
+
*
|
|
1151
|
+
*/
|
|
1152
|
+
onItemSelect(t, e) {
|
|
1153
|
+
var n = this;
|
|
1154
|
+
return !n.isLocked && n.settings.mode === "multi" ? (W(t), n.setActiveItem(e, t), !0) : !1;
|
|
1155
|
+
}
|
|
1156
|
+
/**
|
|
1157
|
+
* Determines whether or not to invoke
|
|
1158
|
+
* the user-provided option provider / loader
|
|
1159
|
+
*
|
|
1160
|
+
* Note, there is a subtle difference between
|
|
1161
|
+
* this.canLoad() and this.settings.shouldLoad();
|
|
1162
|
+
*
|
|
1163
|
+
* - settings.shouldLoad() is a user-input validator.
|
|
1164
|
+
* When false is returned, the not_loading template
|
|
1165
|
+
* will be added to the dropdown
|
|
1166
|
+
*
|
|
1167
|
+
* - canLoad() is lower level validator that checks
|
|
1168
|
+
* the Tom Select instance. There is no inherent user
|
|
1169
|
+
* feedback when canLoad returns false
|
|
1170
|
+
*
|
|
1171
|
+
*/
|
|
1172
|
+
canLoad(t) {
|
|
1173
|
+
return !(!this.settings.load || this.loadedSearches.hasOwnProperty(t));
|
|
1174
|
+
}
|
|
1175
|
+
/**
|
|
1176
|
+
* Invokes the user-provided option provider / loader.
|
|
1177
|
+
*
|
|
1178
|
+
*/
|
|
1179
|
+
load(t) {
|
|
1180
|
+
const e = this;
|
|
1181
|
+
if (!e.canLoad(t))
|
|
1182
|
+
return;
|
|
1183
|
+
J(e.wrapper, e.settings.loadingClass), e.loading++;
|
|
1184
|
+
const n = e.loadCallback.bind(e);
|
|
1185
|
+
e.settings.load.call(e, t, n);
|
|
1186
|
+
}
|
|
1187
|
+
/**
|
|
1188
|
+
* Invoked by the user-provided option provider
|
|
1189
|
+
*
|
|
1190
|
+
*/
|
|
1191
|
+
loadCallback(t, e) {
|
|
1192
|
+
const n = this;
|
|
1193
|
+
n.loading = Math.max(n.loading - 1, 0), n.lastQuery = null, n.clearActiveOption(), n.setupOptions(t, e), n.refreshOptions(n.isFocused && !n.isInputHidden), n.loading || V(n.wrapper, n.settings.loadingClass), n.trigger("load", t, e);
|
|
1194
|
+
}
|
|
1195
|
+
preload() {
|
|
1196
|
+
var t = this.wrapper.classList;
|
|
1197
|
+
t.contains("preloaded") || (t.add("preloaded"), this.load(""));
|
|
1198
|
+
}
|
|
1199
|
+
/**
|
|
1200
|
+
* Sets the input field of the control to the specified value.
|
|
1201
|
+
*
|
|
1202
|
+
*/
|
|
1203
|
+
setTextboxValue(t = "") {
|
|
1204
|
+
var e = this.control_input, n = e.value !== t;
|
|
1205
|
+
n && (e.value = t, ht(e, "update"), this.lastValue = t);
|
|
1206
|
+
}
|
|
1207
|
+
/**
|
|
1208
|
+
* Returns the value of the control. If multiple items
|
|
1209
|
+
* can be selected (e.g. <select multiple>), this returns
|
|
1210
|
+
* an array. If only one item can be selected, this
|
|
1211
|
+
* returns a string.
|
|
1212
|
+
*
|
|
1213
|
+
*/
|
|
1214
|
+
getValue() {
|
|
1215
|
+
return this.is_select_tag && this.input.hasAttribute("multiple") ? this.items : this.items.join(this.settings.delimiter);
|
|
1216
|
+
}
|
|
1217
|
+
/**
|
|
1218
|
+
* Resets the selected items to the given value.
|
|
1219
|
+
*
|
|
1220
|
+
*/
|
|
1221
|
+
setValue(t, e) {
|
|
1222
|
+
var n = e ? [] : ["change"];
|
|
1223
|
+
Wt(this, n, () => {
|
|
1224
|
+
this.clear(e), this.addItems(t, e);
|
|
1225
|
+
});
|
|
1226
|
+
}
|
|
1227
|
+
/**
|
|
1228
|
+
* Resets the number of max items to the given value
|
|
1229
|
+
*
|
|
1230
|
+
*/
|
|
1231
|
+
setMaxItems(t) {
|
|
1232
|
+
t === 0 && (t = null), this.settings.maxItems = t, this.refreshState();
|
|
1233
|
+
}
|
|
1234
|
+
/**
|
|
1235
|
+
* Sets the selected item.
|
|
1236
|
+
*
|
|
1237
|
+
*/
|
|
1238
|
+
setActiveItem(t, e) {
|
|
1239
|
+
var n = this, s, o, r, l, a, c;
|
|
1240
|
+
if (n.settings.mode !== "single") {
|
|
1241
|
+
if (!t) {
|
|
1242
|
+
n.clearActiveItems(), n.isFocused && n.inputState();
|
|
1243
|
+
return;
|
|
1244
|
+
}
|
|
1245
|
+
if (s = e && e.type.toLowerCase(), s === "click" && S("shiftKey", e) && n.activeItems.length) {
|
|
1246
|
+
for (c = n.getLastActive(), r = Array.prototype.indexOf.call(n.control.children, c), l = Array.prototype.indexOf.call(n.control.children, t), r > l && (a = r, r = l, l = a), o = r; o <= l; o++)
|
|
1247
|
+
t = n.control.children[o], n.activeItems.indexOf(t) === -1 && n.setActiveItemClass(t);
|
|
1248
|
+
W(e);
|
|
1249
|
+
} else s === "click" && S(tt, e) || s === "keydown" && S("shiftKey", e) ? t.classList.contains("active") ? n.removeActiveItem(t) : n.setActiveItemClass(t) : (n.clearActiveItems(), n.setActiveItemClass(t));
|
|
1250
|
+
n.inputState(), n.isFocused || n.focus();
|
|
1251
|
+
}
|
|
1252
|
+
}
|
|
1253
|
+
/**
|
|
1254
|
+
* Set the active and last-active classes
|
|
1255
|
+
*
|
|
1256
|
+
*/
|
|
1257
|
+
setActiveItemClass(t) {
|
|
1258
|
+
const e = this, n = e.control.querySelector(".last-active");
|
|
1259
|
+
n && V(n, "last-active"), J(t, "active last-active"), e.trigger("item_select", t), e.activeItems.indexOf(t) == -1 && e.activeItems.push(t);
|
|
1260
|
+
}
|
|
1261
|
+
/**
|
|
1262
|
+
* Remove active item
|
|
1263
|
+
*
|
|
1264
|
+
*/
|
|
1265
|
+
removeActiveItem(t) {
|
|
1266
|
+
var e = this.activeItems.indexOf(t);
|
|
1267
|
+
this.activeItems.splice(e, 1), V(t, "active");
|
|
1268
|
+
}
|
|
1269
|
+
/**
|
|
1270
|
+
* Clears all the active items
|
|
1271
|
+
*
|
|
1272
|
+
*/
|
|
1273
|
+
clearActiveItems() {
|
|
1274
|
+
V(this.activeItems, "active"), this.activeItems = [];
|
|
1275
|
+
}
|
|
1276
|
+
/**
|
|
1277
|
+
* Sets the selected item in the dropdown menu
|
|
1278
|
+
* of available options.
|
|
1279
|
+
*
|
|
1280
|
+
*/
|
|
1281
|
+
setActiveOption(t, e = !0) {
|
|
1282
|
+
t !== this.activeOption && (this.clearActiveOption(), t && (this.activeOption = t, w(this.focus_node, { "aria-activedescendant": t.getAttribute("id") }), w(t, { "aria-selected": "true" }), J(t, "active"), e && this.scrollToOption(t)));
|
|
1283
|
+
}
|
|
1284
|
+
/**
|
|
1285
|
+
* Sets the dropdown_content scrollTop to display the option
|
|
1286
|
+
*
|
|
1287
|
+
*/
|
|
1288
|
+
scrollToOption(t, e) {
|
|
1289
|
+
if (!t)
|
|
1290
|
+
return;
|
|
1291
|
+
const n = this.dropdown_content, s = n.clientHeight, o = n.scrollTop || 0, r = t.offsetHeight, l = t.getBoundingClientRect().top - n.getBoundingClientRect().top + o;
|
|
1292
|
+
l + r > s + o ? this.scroll(l - s + r, e) : l < o && this.scroll(l, e);
|
|
1293
|
+
}
|
|
1294
|
+
/**
|
|
1295
|
+
* Scroll the dropdown to the given position
|
|
1296
|
+
*
|
|
1297
|
+
*/
|
|
1298
|
+
scroll(t, e) {
|
|
1299
|
+
const n = this.dropdown_content;
|
|
1300
|
+
e && (n.style.scrollBehavior = e), n.scrollTop = t, n.style.scrollBehavior = "";
|
|
1301
|
+
}
|
|
1302
|
+
/**
|
|
1303
|
+
* Clears the active option
|
|
1304
|
+
*
|
|
1305
|
+
*/
|
|
1306
|
+
clearActiveOption() {
|
|
1307
|
+
this.activeOption && (V(this.activeOption, "active"), w(this.activeOption, { "aria-selected": null })), this.activeOption = null, w(this.focus_node, { "aria-activedescendant": null });
|
|
1308
|
+
}
|
|
1309
|
+
/**
|
|
1310
|
+
* Selects all items (CTRL + A).
|
|
1311
|
+
*/
|
|
1312
|
+
selectAll() {
|
|
1313
|
+
const t = this;
|
|
1314
|
+
if (t.settings.mode === "single")
|
|
1315
|
+
return;
|
|
1316
|
+
const e = t.controlChildren();
|
|
1317
|
+
e.length && (t.inputState(), t.close(), t.activeItems = e, A(e, (n) => {
|
|
1318
|
+
t.setActiveItemClass(n);
|
|
1319
|
+
}));
|
|
1320
|
+
}
|
|
1321
|
+
/**
|
|
1322
|
+
* Determines if the control_input should be in a hidden or visible state
|
|
1323
|
+
*
|
|
1324
|
+
*/
|
|
1325
|
+
inputState() {
|
|
1326
|
+
var t = this;
|
|
1327
|
+
t.control.contains(t.control_input) && (w(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 && w(t.control_input, { placeholder: "" }), t.isInputHidden = !1), t.wrapper.classList.toggle("input-hidden", t.isInputHidden));
|
|
1328
|
+
}
|
|
1329
|
+
/**
|
|
1330
|
+
* Get the input value
|
|
1331
|
+
*/
|
|
1332
|
+
inputValue() {
|
|
1333
|
+
return this.control_input.value.trim();
|
|
1334
|
+
}
|
|
1335
|
+
/**
|
|
1336
|
+
* Gives the control focus.
|
|
1337
|
+
*/
|
|
1338
|
+
focus() {
|
|
1339
|
+
var t = this;
|
|
1340
|
+
t.isDisabled || t.isReadOnly || (t.ignoreFocus = !0, t.control_input.offsetWidth ? t.control_input.focus() : t.focus_node.focus(), setTimeout(() => {
|
|
1341
|
+
t.ignoreFocus = !1, t.onFocus();
|
|
1342
|
+
}, 0));
|
|
1343
|
+
}
|
|
1344
|
+
/**
|
|
1345
|
+
* Forces the control out of focus.
|
|
1346
|
+
*
|
|
1347
|
+
*/
|
|
1348
|
+
blur() {
|
|
1349
|
+
this.focus_node.blur(), this.onBlur();
|
|
1350
|
+
}
|
|
1351
|
+
/**
|
|
1352
|
+
* Returns a function that scores an object
|
|
1353
|
+
* to show how good of a match it is to the
|
|
1354
|
+
* provided query.
|
|
1355
|
+
*
|
|
1356
|
+
* @return {function}
|
|
1357
|
+
*/
|
|
1358
|
+
getScoreFunction(t) {
|
|
1359
|
+
return this.sifter.getScoreFunction(t, this.getSearchOptions());
|
|
1360
|
+
}
|
|
1361
|
+
/**
|
|
1362
|
+
* Returns search options for sifter (the system
|
|
1363
|
+
* for scoring and sorting results).
|
|
1364
|
+
*
|
|
1365
|
+
* @see https://github.com/orchidjs/sifter.js
|
|
1366
|
+
* @return {object}
|
|
1367
|
+
*/
|
|
1368
|
+
getSearchOptions() {
|
|
1369
|
+
var t = this.settings, e = t.sortField;
|
|
1370
|
+
return typeof t.sortField == "string" && (e = [{ field: t.sortField }]), {
|
|
1371
|
+
fields: t.searchField,
|
|
1372
|
+
conjunction: t.searchConjunction,
|
|
1373
|
+
sort: e,
|
|
1374
|
+
nesting: t.nesting
|
|
1375
|
+
};
|
|
1376
|
+
}
|
|
1377
|
+
/**
|
|
1378
|
+
* Searches through available options and returns
|
|
1379
|
+
* a sorted array of matches.
|
|
1380
|
+
*
|
|
1381
|
+
*/
|
|
1382
|
+
search(t) {
|
|
1383
|
+
var e, n, s = this, o = this.getSearchOptions();
|
|
1384
|
+
if (s.settings.score && (n = s.settings.score.call(s, t), typeof n != "function"))
|
|
1385
|
+
throw new Error('Tom Select "score" setting must be a function that returns a function');
|
|
1386
|
+
return t !== s.lastQuery ? (s.lastQuery = t, e = s.sifter.search(t, Object.assign(o, { score: n })), s.currentResults = e) : e = Object.assign({}, s.currentResults), s.settings.hideSelected && (e.items = e.items.filter((r) => {
|
|
1387
|
+
let l = H(r.id);
|
|
1388
|
+
return !(l && s.items.indexOf(l) !== -1);
|
|
1389
|
+
})), e;
|
|
1390
|
+
}
|
|
1391
|
+
/**
|
|
1392
|
+
* Refreshes the list of available options shown
|
|
1393
|
+
* in the autocomplete dropdown menu.
|
|
1394
|
+
*
|
|
1395
|
+
*/
|
|
1396
|
+
refreshOptions(t = !0) {
|
|
1397
|
+
var e, n, s, o, r, l, a, c, d, u;
|
|
1398
|
+
const p = {}, y = [];
|
|
1399
|
+
var g = this, b = g.inputValue();
|
|
1400
|
+
const Z = b === g.lastQuery || b == "" && g.lastQuery == null;
|
|
1401
|
+
var I = g.search(b), h = null, L = g.settings.shouldOpen || !1, M = g.dropdown_content;
|
|
1402
|
+
Z && (h = g.activeOption, h && (d = h.closest("[data-group]"))), o = I.items.length, typeof g.settings.maxOptions == "number" && (o = Math.min(o, g.settings.maxOptions)), o > 0 && (L = !0);
|
|
1403
|
+
const E = (f, v) => {
|
|
1404
|
+
let m = p[f];
|
|
1405
|
+
if (m !== void 0) {
|
|
1406
|
+
let C = y[m];
|
|
1407
|
+
if (C !== void 0)
|
|
1408
|
+
return [m, C.fragment];
|
|
1409
|
+
}
|
|
1410
|
+
let B = document.createDocumentFragment();
|
|
1411
|
+
return m = y.length, y.push({ fragment: B, order: v, optgroup: f }), [m, B];
|
|
1412
|
+
};
|
|
1413
|
+
for (e = 0; e < o; e++) {
|
|
1414
|
+
let f = I.items[e];
|
|
1415
|
+
if (!f)
|
|
1416
|
+
continue;
|
|
1417
|
+
let v = f.id, m = g.options[v];
|
|
1418
|
+
if (m === void 0)
|
|
1419
|
+
continue;
|
|
1420
|
+
let B = it(v), C = g.getOption(B, !0);
|
|
1421
|
+
for (g.settings.hideSelected || C.classList.toggle("selected", g.items.includes(B)), r = m[g.settings.optgroupField] || "", l = Array.isArray(r) ? r : [r], n = 0, s = l && l.length; n < s; n++) {
|
|
1422
|
+
r = l[n];
|
|
1423
|
+
let U = m.$order, $ = g.optgroups[r];
|
|
1424
|
+
$ === void 0 ? r = "" : U = $.$order;
|
|
1425
|
+
const [Qt, Et] = E(r, U);
|
|
1426
|
+
n > 0 && (C = C.cloneNode(!0), w(C, { id: m.$id + "-clone-" + n, "aria-selected": null }), C.classList.add("ts-cloned"), V(C, "active"), g.activeOption && g.activeOption.dataset.value == v && d && d.dataset.group === r.toString() && (h = C)), Et.appendChild(C), r != "" && (p[r] = Qt);
|
|
1427
|
+
}
|
|
1428
|
+
}
|
|
1429
|
+
g.settings.lockOptgroupOrder && y.sort((f, v) => f.order - v.order), a = document.createDocumentFragment(), A(y, (f) => {
|
|
1430
|
+
let v = f.fragment, m = f.optgroup;
|
|
1431
|
+
if (!v || !v.children.length)
|
|
1432
|
+
return;
|
|
1433
|
+
let B = g.optgroups[m];
|
|
1434
|
+
if (B !== void 0) {
|
|
1435
|
+
let C = document.createDocumentFragment(), U = g.render("optgroup_header", B);
|
|
1436
|
+
K(C, U), K(C, v);
|
|
1437
|
+
let $ = g.render("optgroup", { group: B, options: C });
|
|
1438
|
+
K(a, $);
|
|
1439
|
+
} else
|
|
1440
|
+
K(a, v);
|
|
1441
|
+
}), M.innerHTML = "", K(M, a), g.settings.highlight && (Be(M), I.query.length && I.tokens.length && A(I.tokens, (f) => {
|
|
1442
|
+
Ae(M, f.regex);
|
|
1443
|
+
}));
|
|
1444
|
+
var D = (f) => {
|
|
1445
|
+
let v = g.render(f, { input: b });
|
|
1446
|
+
return v && (L = !0, M.insertBefore(v, M.firstChild)), v;
|
|
1447
|
+
};
|
|
1448
|
+
if (g.loading ? D("loading") : g.settings.shouldLoad.call(g, b) ? I.items.length === 0 && D("no_results") : D("not_loading"), c = g.canCreate(b), c && (u = D("option_create")), g.hasOptions = I.items.length > 0 || c, L) {
|
|
1449
|
+
if (I.items.length > 0) {
|
|
1450
|
+
if (!h && g.settings.mode === "single" && g.items[0] != null && (h = g.getOption(g.items[0])), !M.contains(h)) {
|
|
1451
|
+
let f = 0;
|
|
1452
|
+
u && !g.settings.addPrecedence && (f = 1), h = g.selectable()[f];
|
|
1453
|
+
}
|
|
1454
|
+
} else u && (h = u);
|
|
1455
|
+
t && !g.isOpen && (g.open(), g.scrollToOption(h, "auto")), g.setActiveOption(h);
|
|
1456
|
+
} else
|
|
1457
|
+
g.clearActiveOption(), t && g.isOpen && g.close(!1);
|
|
1458
|
+
}
|
|
1459
|
+
/**
|
|
1460
|
+
* Return list of selectable options
|
|
1461
|
+
*
|
|
1462
|
+
*/
|
|
1463
|
+
selectable() {
|
|
1464
|
+
return this.dropdown_content.querySelectorAll("[data-selectable]");
|
|
1465
|
+
}
|
|
1466
|
+
/**
|
|
1467
|
+
* Adds an available option. If it already exists,
|
|
1468
|
+
* nothing will happen. Note: this does not refresh
|
|
1469
|
+
* the options list dropdown (use `refreshOptions`
|
|
1470
|
+
* for that).
|
|
1471
|
+
*
|
|
1472
|
+
* Usage:
|
|
1473
|
+
*
|
|
1474
|
+
* this.addOption(data)
|
|
1475
|
+
*
|
|
1476
|
+
*/
|
|
1477
|
+
addOption(t, e = !1) {
|
|
1478
|
+
const n = this;
|
|
1479
|
+
if (Array.isArray(t))
|
|
1480
|
+
return n.addOptions(t, e), !1;
|
|
1481
|
+
const s = H(t[n.settings.valueField]);
|
|
1482
|
+
return s === null || n.options.hasOwnProperty(s) ? !1 : (t.$order = t.$order || ++n.order, t.$id = n.inputId + "-opt-" + t.$order, n.options[s] = t, n.lastQuery = null, e && (n.userOptions[s] = e, n.trigger("option_add", s, t)), s);
|
|
1483
|
+
}
|
|
1484
|
+
/**
|
|
1485
|
+
* Add multiple options
|
|
1486
|
+
*
|
|
1487
|
+
*/
|
|
1488
|
+
addOptions(t, e = !1) {
|
|
1489
|
+
A(t, (n) => {
|
|
1490
|
+
this.addOption(n, e);
|
|
1491
|
+
});
|
|
1492
|
+
}
|
|
1493
|
+
/**
|
|
1494
|
+
* @deprecated 1.7.7
|
|
1495
|
+
*/
|
|
1496
|
+
registerOption(t) {
|
|
1497
|
+
return this.addOption(t);
|
|
1498
|
+
}
|
|
1499
|
+
/**
|
|
1500
|
+
* Registers an option group to the pool of option groups.
|
|
1501
|
+
*
|
|
1502
|
+
* @return {boolean|string}
|
|
1503
|
+
*/
|
|
1504
|
+
registerOptionGroup(t) {
|
|
1505
|
+
var e = H(t[this.settings.optgroupValueField]);
|
|
1506
|
+
return e === null ? !1 : (t.$order = t.$order || ++this.order, this.optgroups[e] = t, e);
|
|
1507
|
+
}
|
|
1508
|
+
/**
|
|
1509
|
+
* Registers a new optgroup for options
|
|
1510
|
+
* to be bucketed into.
|
|
1511
|
+
*
|
|
1512
|
+
*/
|
|
1513
|
+
addOptionGroup(t, e) {
|
|
1514
|
+
var n;
|
|
1515
|
+
e[this.settings.optgroupValueField] = t, (n = this.registerOptionGroup(e)) && this.trigger("optgroup_add", n, e);
|
|
1516
|
+
}
|
|
1517
|
+
/**
|
|
1518
|
+
* Removes an existing option group.
|
|
1519
|
+
*
|
|
1520
|
+
*/
|
|
1521
|
+
removeOptionGroup(t) {
|
|
1522
|
+
this.optgroups.hasOwnProperty(t) && (delete this.optgroups[t], this.clearCache(), this.trigger("optgroup_remove", t));
|
|
1523
|
+
}
|
|
1524
|
+
/**
|
|
1525
|
+
* Clears all existing option groups.
|
|
1526
|
+
*/
|
|
1527
|
+
clearOptionGroups() {
|
|
1528
|
+
this.optgroups = {}, this.clearCache(), this.trigger("optgroup_clear");
|
|
1529
|
+
}
|
|
1530
|
+
/**
|
|
1531
|
+
* Updates an option available for selection. If
|
|
1532
|
+
* it is visible in the selected items or options
|
|
1533
|
+
* dropdown, it will be re-rendered automatically.
|
|
1534
|
+
*
|
|
1535
|
+
*/
|
|
1536
|
+
updateOption(t, e) {
|
|
1537
|
+
const n = this;
|
|
1538
|
+
var s, o;
|
|
1539
|
+
const r = H(t), l = H(e[n.settings.valueField]);
|
|
1540
|
+
if (r === null)
|
|
1541
|
+
return;
|
|
1542
|
+
const a = n.options[r];
|
|
1543
|
+
if (a == null)
|
|
1544
|
+
return;
|
|
1545
|
+
if (typeof l != "string")
|
|
1546
|
+
throw new Error("Value must be set in option data");
|
|
1547
|
+
const c = n.getOption(r), d = n.getItem(r);
|
|
1548
|
+
if (e.$order = e.$order || a.$order, delete n.options[r], n.uncacheValue(l), n.options[l] = e, c) {
|
|
1549
|
+
if (n.dropdown_content.contains(c)) {
|
|
1550
|
+
const u = n._render("option", e);
|
|
1551
|
+
ft(c, u), n.activeOption === c && n.setActiveOption(u);
|
|
1552
|
+
}
|
|
1553
|
+
c.remove();
|
|
1554
|
+
}
|
|
1555
|
+
d && (o = n.items.indexOf(r), o !== -1 && n.items.splice(o, 1, l), s = n._render("item", e), d.classList.contains("active") && J(s, "active"), ft(d, s)), n.lastQuery = null;
|
|
1556
|
+
}
|
|
1557
|
+
/**
|
|
1558
|
+
* Removes a single option.
|
|
1559
|
+
*
|
|
1560
|
+
*/
|
|
1561
|
+
removeOption(t, e) {
|
|
1562
|
+
const n = this;
|
|
1563
|
+
t = it(t), n.uncacheValue(t), delete n.userOptions[t], delete n.options[t], n.lastQuery = null, n.trigger("option_remove", t), n.removeItem(t, e);
|
|
1564
|
+
}
|
|
1565
|
+
/**
|
|
1566
|
+
* Clears all options.
|
|
1567
|
+
*/
|
|
1568
|
+
clearOptions(t) {
|
|
1569
|
+
const e = (t || this.clearFilter).bind(this);
|
|
1570
|
+
this.loadedSearches = {}, this.userOptions = {}, this.clearCache();
|
|
1571
|
+
const n = {};
|
|
1572
|
+
A(this.options, (s, o) => {
|
|
1573
|
+
e(s, o) && (n[o] = s);
|
|
1574
|
+
}), this.options = this.sifter.items = n, this.lastQuery = null, this.trigger("option_clear");
|
|
1575
|
+
}
|
|
1576
|
+
/**
|
|
1577
|
+
* Used by clearOptions() to decide whether or not an option should be removed
|
|
1578
|
+
* Return true to keep an option, false to remove
|
|
1579
|
+
*
|
|
1580
|
+
*/
|
|
1581
|
+
clearFilter(t, e) {
|
|
1582
|
+
return this.items.indexOf(e) >= 0;
|
|
1583
|
+
}
|
|
1584
|
+
/**
|
|
1585
|
+
* Returns the dom element of the option
|
|
1586
|
+
* matching the given value.
|
|
1587
|
+
*
|
|
1588
|
+
*/
|
|
1589
|
+
getOption(t, e = !1) {
|
|
1590
|
+
const n = H(t);
|
|
1591
|
+
if (n === null)
|
|
1592
|
+
return null;
|
|
1593
|
+
const s = this.options[n];
|
|
1594
|
+
if (s != null) {
|
|
1595
|
+
if (s.$div)
|
|
1596
|
+
return s.$div;
|
|
1597
|
+
if (e)
|
|
1598
|
+
return this._render("option", s);
|
|
1599
|
+
}
|
|
1600
|
+
return null;
|
|
1601
|
+
}
|
|
1602
|
+
/**
|
|
1603
|
+
* Returns the dom element of the next or previous dom element of the same type
|
|
1604
|
+
* Note: adjacent options may not be adjacent DOM elements (optgroups)
|
|
1605
|
+
*
|
|
1606
|
+
*/
|
|
1607
|
+
getAdjacent(t, e, n = "option") {
|
|
1608
|
+
var s = this, o;
|
|
1609
|
+
if (!t)
|
|
1610
|
+
return null;
|
|
1611
|
+
n == "item" ? o = s.controlChildren() : o = s.dropdown_content.querySelectorAll("[data-selectable]");
|
|
1612
|
+
for (let r = 0; r < o.length; r++)
|
|
1613
|
+
if (o[r] == t)
|
|
1614
|
+
return e > 0 ? o[r + 1] : o[r - 1];
|
|
1615
|
+
return null;
|
|
1616
|
+
}
|
|
1617
|
+
/**
|
|
1618
|
+
* Returns the dom element of the item
|
|
1619
|
+
* matching the given value.
|
|
1620
|
+
*
|
|
1621
|
+
*/
|
|
1622
|
+
getItem(t) {
|
|
1623
|
+
if (typeof t == "object")
|
|
1624
|
+
return t;
|
|
1625
|
+
var e = H(t);
|
|
1626
|
+
return e !== null ? this.control.querySelector(`[data-value="${Gt(e)}"]`) : null;
|
|
1627
|
+
}
|
|
1628
|
+
/**
|
|
1629
|
+
* "Selects" multiple items at once. Adds them to the list
|
|
1630
|
+
* at the current caret position.
|
|
1631
|
+
*
|
|
1632
|
+
*/
|
|
1633
|
+
addItems(t, e) {
|
|
1634
|
+
var n = this, s = Array.isArray(t) ? t : [t];
|
|
1635
|
+
s = s.filter((r) => n.items.indexOf(r) === -1);
|
|
1636
|
+
const o = s[s.length - 1];
|
|
1637
|
+
s.forEach((r) => {
|
|
1638
|
+
n.isPending = r !== o, n.addItem(r, e);
|
|
1639
|
+
});
|
|
1640
|
+
}
|
|
1641
|
+
/**
|
|
1642
|
+
* "Selects" an item. Adds it to the list
|
|
1643
|
+
* at the current caret position.
|
|
1644
|
+
*
|
|
1645
|
+
*/
|
|
1646
|
+
addItem(t, e) {
|
|
1647
|
+
var n = e ? [] : ["change", "dropdown_close"];
|
|
1648
|
+
Wt(this, n, () => {
|
|
1649
|
+
var s, o;
|
|
1650
|
+
const r = this, l = r.settings.mode, a = H(t);
|
|
1651
|
+
if (!(a && r.items.indexOf(a) !== -1 && (l === "single" && r.close(), l === "single" || !r.settings.duplicates)) && !(a === null || !r.options.hasOwnProperty(a)) && (l === "single" && r.clear(e), !(l === "multi" && r.isFull()))) {
|
|
1652
|
+
if (s = r._render("item", r.options[a]), r.control.contains(s) && (s = s.cloneNode(!0)), o = r.isFull(), r.items.splice(r.caretPos, 0, a), r.insertAtCaret(s), r.isSetup) {
|
|
1653
|
+
if (!r.isPending && r.settings.hideSelected) {
|
|
1654
|
+
let c = r.getOption(a), d = r.getAdjacent(c, 1);
|
|
1655
|
+
d && r.setActiveOption(d);
|
|
1656
|
+
}
|
|
1657
|
+
!r.isPending && !r.settings.closeAfterSelect && r.refreshOptions(r.isFocused && l !== "single"), r.settings.closeAfterSelect != !1 && r.isFull() ? r.close() : r.isPending || r.positionDropdown(), r.trigger("item_add", a, s), r.isPending || r.updateOriginalInput({ silent: e });
|
|
1658
|
+
}
|
|
1659
|
+
(!r.isPending || !o && r.isFull()) && (r.inputState(), r.refreshState());
|
|
1660
|
+
}
|
|
1661
|
+
});
|
|
1662
|
+
}
|
|
1663
|
+
/**
|
|
1664
|
+
* Removes the selected item matching
|
|
1665
|
+
* the provided value.
|
|
1666
|
+
*
|
|
1667
|
+
*/
|
|
1668
|
+
removeItem(t = null, e) {
|
|
1669
|
+
const n = this;
|
|
1670
|
+
if (t = n.getItem(t), !t)
|
|
1671
|
+
return;
|
|
1672
|
+
var s, o;
|
|
1673
|
+
const r = t.dataset.value;
|
|
1674
|
+
s = Bt(t), t.remove(), t.classList.contains("active") && (o = n.activeItems.indexOf(t), n.activeItems.splice(o, 1), V(t, "active")), n.items.splice(s, 1), n.lastQuery = null, !n.settings.persist && n.userOptions.hasOwnProperty(r) && n.removeOption(r, e), s < n.caretPos && n.setCaret(n.caretPos - 1), n.updateOriginalInput({ silent: e }), n.refreshState(), n.positionDropdown(), n.trigger("item_remove", r, t);
|
|
1675
|
+
}
|
|
1676
|
+
/**
|
|
1677
|
+
* Invokes the `create` method provided in the
|
|
1678
|
+
* TomSelect options that should provide the data
|
|
1679
|
+
* for the new item, given the user input.
|
|
1680
|
+
*
|
|
1681
|
+
* Once this completes, it will be added
|
|
1682
|
+
* to the item list.
|
|
1683
|
+
*
|
|
1684
|
+
*/
|
|
1685
|
+
createItem(t = null, e = () => {
|
|
1686
|
+
}) {
|
|
1687
|
+
arguments.length === 3 && (e = arguments[2]), typeof e != "function" && (e = () => {
|
|
1688
|
+
});
|
|
1689
|
+
var n = this, s = n.caretPos, o;
|
|
1690
|
+
if (t = t || n.inputValue(), !n.canCreate(t))
|
|
1691
|
+
return e(), !1;
|
|
1692
|
+
n.lock();
|
|
1693
|
+
var r = !1, l = (a) => {
|
|
1694
|
+
if (n.unlock(), !a || typeof a != "object")
|
|
1695
|
+
return e();
|
|
1696
|
+
var c = H(a[n.settings.valueField]);
|
|
1697
|
+
if (typeof c != "string")
|
|
1698
|
+
return e();
|
|
1699
|
+
n.setTextboxValue(), n.addOption(a, !0), n.setCaret(s), n.addItem(c), e(a), r = !0;
|
|
1700
|
+
};
|
|
1701
|
+
return typeof n.settings.create == "function" ? o = n.settings.create.call(this, t, l) : o = {
|
|
1702
|
+
[n.settings.labelField]: t,
|
|
1703
|
+
[n.settings.valueField]: t
|
|
1704
|
+
}, r || l(o), !0;
|
|
1705
|
+
}
|
|
1706
|
+
/**
|
|
1707
|
+
* Re-renders the selected item lists.
|
|
1708
|
+
*/
|
|
1709
|
+
refreshItems() {
|
|
1710
|
+
var t = this;
|
|
1711
|
+
t.lastQuery = null, t.isSetup && t.addItems(t.items), t.updateOriginalInput(), t.refreshState();
|
|
1712
|
+
}
|
|
1713
|
+
/**
|
|
1714
|
+
* Updates all state-dependent attributes
|
|
1715
|
+
* and CSS classes.
|
|
1716
|
+
*/
|
|
1717
|
+
refreshState() {
|
|
1718
|
+
const t = this;
|
|
1719
|
+
t.refreshValidityState();
|
|
1720
|
+
const e = t.isFull(), n = t.isLocked;
|
|
1721
|
+
t.wrapper.classList.toggle("rtl", t.rtl);
|
|
1722
|
+
const s = t.wrapper.classList;
|
|
1723
|
+
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", n), s.toggle("full", e), s.toggle("input-active", t.isFocused && !t.isInputHidden), s.toggle("dropdown-active", t.isOpen), s.toggle("has-options", Ge(t.options)), s.toggle("has-items", t.items.length > 0);
|
|
1724
|
+
}
|
|
1725
|
+
/**
|
|
1726
|
+
* Update the `required` attribute of both input and control input.
|
|
1727
|
+
*
|
|
1728
|
+
* The `required` property needs to be activated on the control input
|
|
1729
|
+
* for the error to be displayed at the right place. `required` also
|
|
1730
|
+
* needs to be temporarily deactivated on the input since the input is
|
|
1731
|
+
* hidden and can't show errors.
|
|
1732
|
+
*/
|
|
1733
|
+
refreshValidityState() {
|
|
1734
|
+
var t = this;
|
|
1735
|
+
t.input.validity && (t.isValid = t.input.validity.valid, t.isInvalid = !t.isValid);
|
|
1736
|
+
}
|
|
1737
|
+
/**
|
|
1738
|
+
* Determines whether or not more items can be added
|
|
1739
|
+
* to the control without exceeding the user-defined maximum.
|
|
1740
|
+
*
|
|
1741
|
+
* @returns {boolean}
|
|
1742
|
+
*/
|
|
1743
|
+
isFull() {
|
|
1744
|
+
return this.settings.maxItems !== null && this.items.length >= this.settings.maxItems;
|
|
1745
|
+
}
|
|
1746
|
+
/**
|
|
1747
|
+
* Refreshes the original <select> or <input>
|
|
1748
|
+
* element to reflect the current state.
|
|
1749
|
+
*
|
|
1750
|
+
*/
|
|
1751
|
+
updateOriginalInput(t = {}) {
|
|
1752
|
+
const e = this;
|
|
1753
|
+
var n, s;
|
|
1754
|
+
const o = e.input.querySelector('option[value=""]');
|
|
1755
|
+
if (e.is_select_tag) {
|
|
1756
|
+
let a = function(c, d, u) {
|
|
1757
|
+
return c || (c = R('<option value="' + gt(d) + '">' + gt(u) + "</option>")), c != o && e.input.append(c), r.push(c), (c != o || l > 0) && (c.selected = !0), c;
|
|
1758
|
+
};
|
|
1759
|
+
const r = [], l = e.input.querySelectorAll("option:checked").length;
|
|
1760
|
+
e.input.querySelectorAll("option:checked").forEach((c) => {
|
|
1761
|
+
c.selected = !1;
|
|
1762
|
+
}), e.items.length == 0 && e.settings.mode == "single" ? a(o, "", "") : e.items.forEach((c) => {
|
|
1763
|
+
if (n = e.options[c], s = n[e.settings.labelField] || "", r.includes(n.$option)) {
|
|
1764
|
+
const d = e.input.querySelector(`option[value="${Gt(c)}"]:not(:checked)`);
|
|
1765
|
+
a(d, c, s);
|
|
1766
|
+
} else
|
|
1767
|
+
n.$option = a(n.$option, c, s);
|
|
1768
|
+
});
|
|
1769
|
+
} else
|
|
1770
|
+
e.input.value = e.getValue();
|
|
1771
|
+
e.isSetup && (t.silent || e.trigger("change", e.getValue()));
|
|
1772
|
+
}
|
|
1773
|
+
/**
|
|
1774
|
+
* Shows the autocomplete dropdown containing
|
|
1775
|
+
* the available options.
|
|
1776
|
+
*/
|
|
1777
|
+
open() {
|
|
1778
|
+
var t = this;
|
|
1779
|
+
t.isLocked || t.isOpen || t.settings.mode === "multi" && t.isFull() || (t.isOpen = !0, w(t.focus_node, { "aria-expanded": "true" }), t.refreshState(), q(t.dropdown, { visibility: "hidden", display: "block" }), t.positionDropdown(), q(t.dropdown, { visibility: "visible", display: "block" }), t.focus(), t.trigger("dropdown_open", t.dropdown));
|
|
1780
|
+
}
|
|
1781
|
+
/**
|
|
1782
|
+
* Closes the autocomplete dropdown menu.
|
|
1783
|
+
*/
|
|
1784
|
+
close(t = !0) {
|
|
1785
|
+
var e = this, n = e.isOpen;
|
|
1786
|
+
t && (e.setTextboxValue(), e.settings.mode === "single" && e.items.length && e.inputState()), e.isOpen = !1, w(e.focus_node, { "aria-expanded": "false" }), q(e.dropdown, { display: "none" }), e.settings.hideSelected && e.clearActiveOption(), e.refreshState(), n && e.trigger("dropdown_close", e.dropdown);
|
|
1787
|
+
}
|
|
1788
|
+
/**
|
|
1789
|
+
* Calculates and applies the appropriate
|
|
1790
|
+
* position of the dropdown if dropdownParent = 'body'.
|
|
1791
|
+
* Otherwise, position is determined by css
|
|
1792
|
+
*/
|
|
1793
|
+
positionDropdown() {
|
|
1794
|
+
if (this.settings.dropdownParent === "body") {
|
|
1795
|
+
var t = this.control, e = t.getBoundingClientRect(), n = t.offsetHeight + e.top + window.scrollY, s = e.left + window.scrollX;
|
|
1796
|
+
q(this.dropdown, {
|
|
1797
|
+
width: e.width + "px",
|
|
1798
|
+
top: n + "px",
|
|
1799
|
+
left: s + "px"
|
|
1800
|
+
});
|
|
1801
|
+
}
|
|
1802
|
+
}
|
|
1803
|
+
/**
|
|
1804
|
+
* Resets / clears all selected items
|
|
1805
|
+
* from the control.
|
|
1806
|
+
*
|
|
1807
|
+
*/
|
|
1808
|
+
clear(t) {
|
|
1809
|
+
var e = this;
|
|
1810
|
+
if (e.items.length) {
|
|
1811
|
+
var n = e.controlChildren();
|
|
1812
|
+
A(n, (s) => {
|
|
1813
|
+
e.removeItem(s, !0);
|
|
1814
|
+
}), e.inputState(), t || e.updateOriginalInput(), e.trigger("clear");
|
|
1815
|
+
}
|
|
1816
|
+
}
|
|
1817
|
+
/**
|
|
1818
|
+
* A helper method for inserting an element
|
|
1819
|
+
* at the current caret position.
|
|
1820
|
+
*
|
|
1821
|
+
*/
|
|
1822
|
+
insertAtCaret(t) {
|
|
1823
|
+
const e = this, n = e.caretPos, s = e.control;
|
|
1824
|
+
s.insertBefore(t, s.children[n] || null), e.setCaret(n + 1);
|
|
1825
|
+
}
|
|
1826
|
+
/**
|
|
1827
|
+
* Removes the current selected item(s).
|
|
1828
|
+
*
|
|
1829
|
+
*/
|
|
1830
|
+
deleteSelection(t) {
|
|
1831
|
+
var e, n, s, o, r = this;
|
|
1832
|
+
e = t && t.keyCode === Xt ? -1 : 1, n = Le(r.control_input);
|
|
1833
|
+
const l = [];
|
|
1834
|
+
if (r.activeItems.length)
|
|
1835
|
+
o = At(r.activeItems, e), s = Bt(o), e > 0 && s++, A(r.activeItems, (a) => l.push(a));
|
|
1836
|
+
else if ((r.isFocused || r.settings.mode === "single") && r.items.length) {
|
|
1837
|
+
const a = r.controlChildren();
|
|
1838
|
+
let c;
|
|
1839
|
+
e < 0 && n.start === 0 && n.length === 0 ? c = a[r.caretPos - 1] : e > 0 && n.start === r.inputValue().length && (c = a[r.caretPos]), c !== void 0 && l.push(c);
|
|
1840
|
+
}
|
|
1841
|
+
if (!r.shouldDelete(l, t))
|
|
1842
|
+
return !1;
|
|
1843
|
+
for (W(t, !0), typeof s < "u" && r.setCaret(s); l.length; )
|
|
1844
|
+
r.removeItem(l.pop());
|
|
1845
|
+
return r.inputState(), r.positionDropdown(), r.refreshOptions(!1), !0;
|
|
1846
|
+
}
|
|
1847
|
+
/**
|
|
1848
|
+
* Return true if the items should be deleted
|
|
1849
|
+
*/
|
|
1850
|
+
shouldDelete(t, e) {
|
|
1851
|
+
const n = t.map((s) => s.dataset.value);
|
|
1852
|
+
return !(!n.length || typeof this.settings.onDelete == "function" && this.settings.onDelete(n, e) === !1);
|
|
1853
|
+
}
|
|
1854
|
+
/**
|
|
1855
|
+
* Selects the previous / next item (depending on the `direction` argument).
|
|
1856
|
+
*
|
|
1857
|
+
* > 0 - right
|
|
1858
|
+
* < 0 - left
|
|
1859
|
+
*
|
|
1860
|
+
*/
|
|
1861
|
+
advanceSelection(t, e) {
|
|
1862
|
+
var n, s, o = this;
|
|
1863
|
+
o.rtl && (t *= -1), !o.inputValue().length && (S(tt, e) || S("shiftKey", e) ? (n = o.getLastActive(t), n ? n.classList.contains("active") ? s = o.getAdjacent(n, t, "item") : s = n : t > 0 ? s = o.control_input.nextElementSibling : s = o.control_input.previousElementSibling, s && (s.classList.contains("active") && o.removeActiveItem(n), o.setActiveItemClass(s))) : o.moveCaret(t));
|
|
1864
|
+
}
|
|
1865
|
+
moveCaret(t) {
|
|
1866
|
+
}
|
|
1867
|
+
/**
|
|
1868
|
+
* Get the last active item
|
|
1869
|
+
*
|
|
1870
|
+
*/
|
|
1871
|
+
getLastActive(t) {
|
|
1872
|
+
let e = this.control.querySelector(".last-active");
|
|
1873
|
+
if (e)
|
|
1874
|
+
return e;
|
|
1875
|
+
var n = this.control.querySelectorAll(".active");
|
|
1876
|
+
if (n)
|
|
1877
|
+
return At(n, t);
|
|
1878
|
+
}
|
|
1879
|
+
/**
|
|
1880
|
+
* Moves the caret to the specified index.
|
|
1881
|
+
*
|
|
1882
|
+
* The input must be moved by leaving it in place and moving the
|
|
1883
|
+
* siblings, due to the fact that focus cannot be restored once lost
|
|
1884
|
+
* on mobile webkit devices
|
|
1885
|
+
*
|
|
1886
|
+
*/
|
|
1887
|
+
setCaret(t) {
|
|
1888
|
+
this.caretPos = this.items.length;
|
|
1889
|
+
}
|
|
1890
|
+
/**
|
|
1891
|
+
* Return list of item dom elements
|
|
1892
|
+
*
|
|
1893
|
+
*/
|
|
1894
|
+
controlChildren() {
|
|
1895
|
+
return Array.from(this.control.querySelectorAll("[data-ts-item]"));
|
|
1896
|
+
}
|
|
1897
|
+
/**
|
|
1898
|
+
* Disables user input on the control. Used while
|
|
1899
|
+
* items are being asynchronously created.
|
|
1900
|
+
*/
|
|
1901
|
+
lock() {
|
|
1902
|
+
this.setLocked(!0);
|
|
1903
|
+
}
|
|
1904
|
+
/**
|
|
1905
|
+
* Re-enables user input on the control.
|
|
1906
|
+
*/
|
|
1907
|
+
unlock() {
|
|
1908
|
+
this.setLocked(!1);
|
|
1909
|
+
}
|
|
1910
|
+
/**
|
|
1911
|
+
* Disable or enable user input on the control
|
|
1912
|
+
*/
|
|
1913
|
+
setLocked(t = this.isReadOnly || this.isDisabled) {
|
|
1914
|
+
this.isLocked = t, this.refreshState();
|
|
1915
|
+
}
|
|
1916
|
+
/**
|
|
1917
|
+
* Disables user input on the control completely.
|
|
1918
|
+
* While disabled, it cannot receive focus.
|
|
1919
|
+
*/
|
|
1920
|
+
disable() {
|
|
1921
|
+
this.setDisabled(!0), this.close();
|
|
1922
|
+
}
|
|
1923
|
+
/**
|
|
1924
|
+
* Enables the control so that it can respond
|
|
1925
|
+
* to focus and user input.
|
|
1926
|
+
*/
|
|
1927
|
+
enable() {
|
|
1928
|
+
this.setDisabled(!1);
|
|
1929
|
+
}
|
|
1930
|
+
setDisabled(t) {
|
|
1931
|
+
this.focus_node.tabIndex = t ? -1 : this.tabIndex, this.isDisabled = t, this.input.disabled = t, this.control_input.disabled = t, this.setLocked();
|
|
1932
|
+
}
|
|
1933
|
+
setReadOnly(t) {
|
|
1934
|
+
this.isReadOnly = t, this.input.readOnly = t, this.control_input.readOnly = t, this.setLocked();
|
|
1935
|
+
}
|
|
1936
|
+
/**
|
|
1937
|
+
* Completely destroys the control and
|
|
1938
|
+
* unbinds all event listeners so that it can
|
|
1939
|
+
* be garbage collected.
|
|
1940
|
+
*/
|
|
1941
|
+
destroy() {
|
|
1942
|
+
var t = this, e = t.revertSettings;
|
|
1943
|
+
t.trigger("destroy"), t.off(), t.wrapper.remove(), t.dropdown.remove(), t.input.innerHTML = e.innerHTML, t.input.tabIndex = e.tabIndex, V(t.input, "tomselected", "ts-hidden-accessible"), t._destroy(), delete t.input.tomselect;
|
|
1944
|
+
}
|
|
1945
|
+
/**
|
|
1946
|
+
* A helper method for rendering "item" and
|
|
1947
|
+
* "option" templates, given the data.
|
|
1948
|
+
*
|
|
1949
|
+
*/
|
|
1950
|
+
render(t, e) {
|
|
1951
|
+
var n, s;
|
|
1952
|
+
const o = this;
|
|
1953
|
+
if (typeof this.settings.render[t] != "function" || (s = o.settings.render[t].call(this, e, gt), !s))
|
|
1954
|
+
return null;
|
|
1955
|
+
if (s = R(s), t === "option" || t === "option_create" ? e[o.settings.disabledField] ? w(s, { "aria-disabled": "true" }) : w(s, { "data-selectable": "" }) : t === "optgroup" && (n = e.group[o.settings.optgroupValueField], w(s, { "data-group": n }), e.group[o.settings.disabledField] && w(s, { "data-disabled": "" })), t === "option" || t === "item") {
|
|
1956
|
+
const r = it(e[o.settings.valueField]);
|
|
1957
|
+
w(s, { "data-value": r }), t === "item" ? (J(s, o.settings.itemClass), w(s, { "data-ts-item": "" })) : (J(s, o.settings.optionClass), w(s, {
|
|
1958
|
+
role: "option",
|
|
1959
|
+
id: e.$id
|
|
1960
|
+
}), e.$div = s, o.options[r] = e);
|
|
1961
|
+
}
|
|
1962
|
+
return s;
|
|
1963
|
+
}
|
|
1964
|
+
/**
|
|
1965
|
+
* Type guarded rendering
|
|
1966
|
+
*
|
|
1967
|
+
*/
|
|
1968
|
+
_render(t, e) {
|
|
1969
|
+
const n = this.render(t, e);
|
|
1970
|
+
if (n == null)
|
|
1971
|
+
throw "HTMLElement expected";
|
|
1972
|
+
return n;
|
|
1973
|
+
}
|
|
1974
|
+
/**
|
|
1975
|
+
* Clears the render cache for a template. If
|
|
1976
|
+
* no template is given, clears all render
|
|
1977
|
+
* caches.
|
|
1978
|
+
*
|
|
1979
|
+
*/
|
|
1980
|
+
clearCache() {
|
|
1981
|
+
A(this.options, (t) => {
|
|
1982
|
+
t.$div && (t.$div.remove(), delete t.$div);
|
|
1983
|
+
});
|
|
1984
|
+
}
|
|
1985
|
+
/**
|
|
1986
|
+
* Removes a value from item and option caches
|
|
1987
|
+
*
|
|
1988
|
+
*/
|
|
1989
|
+
uncacheValue(t) {
|
|
1990
|
+
const e = this.getOption(t);
|
|
1991
|
+
e && e.remove();
|
|
1992
|
+
}
|
|
1993
|
+
/**
|
|
1994
|
+
* Determines whether or not to display the
|
|
1995
|
+
* create item prompt, given a user input.
|
|
1996
|
+
*
|
|
1997
|
+
*/
|
|
1998
|
+
canCreate(t) {
|
|
1999
|
+
return this.settings.create && t.length > 0 && this.settings.createFilter.call(this, t);
|
|
2000
|
+
}
|
|
2001
|
+
/**
|
|
2002
|
+
* Wraps this.`method` so that `new_fn` can be invoked 'before', 'after', or 'instead' of the original method
|
|
2003
|
+
*
|
|
2004
|
+
* this.hook('instead','onKeyDown',function( arg1, arg2 ...){
|
|
2005
|
+
*
|
|
2006
|
+
* });
|
|
2007
|
+
*/
|
|
2008
|
+
hook(t, e, n) {
|
|
2009
|
+
var s = this, o = s[e];
|
|
2010
|
+
s[e] = function() {
|
|
2011
|
+
var r, l;
|
|
2012
|
+
return t === "after" && (r = o.apply(s, arguments)), l = n.apply(s, arguments), t === "instead" ? l : (t === "before" && (r = o.apply(s, arguments)), r);
|
|
2013
|
+
};
|
|
2014
|
+
}
|
|
2015
|
+
}
|
|
2016
|
+
const ze = (i, t, e, n) => {
|
|
2017
|
+
i.addEventListener(t, e, n);
|
|
2018
|
+
};
|
|
2019
|
+
function ke() {
|
|
2020
|
+
ze(this.input, "change", () => {
|
|
2021
|
+
this.sync();
|
|
2022
|
+
});
|
|
2023
|
+
}
|
|
2024
|
+
const Fe = (i) => typeof i > "u" || i === null ? null : Se(i), Se = (i) => typeof i == "boolean" ? i ? "1" : "0" : i + "", Mt = (i, t = !1) => {
|
|
2025
|
+
i && (i.preventDefault(), t && i.stopPropagation());
|
|
2026
|
+
}, Ke = (i) => {
|
|
2027
|
+
if (i.jquery)
|
|
2028
|
+
return i[0];
|
|
2029
|
+
if (i instanceof HTMLElement)
|
|
2030
|
+
return i;
|
|
2031
|
+
if (xe(i)) {
|
|
2032
|
+
var t = document.createElement("template");
|
|
2033
|
+
return t.innerHTML = i.trim(), t.content.firstChild;
|
|
2034
|
+
}
|
|
2035
|
+
return document.querySelector(i);
|
|
2036
|
+
}, xe = (i) => typeof i == "string" && i.indexOf("<") > -1;
|
|
2037
|
+
function De(i) {
|
|
2038
|
+
var t = this, e = t.onOptionSelect;
|
|
2039
|
+
t.settings.hideSelected = !1;
|
|
2040
|
+
const n = Object.assign({
|
|
2041
|
+
// so that the user may add different ones as well
|
|
2042
|
+
className: "tomselect-checkbox",
|
|
2043
|
+
// the following default to the historic plugin's values
|
|
2044
|
+
checkedClassNames: void 0,
|
|
2045
|
+
uncheckedClassNames: void 0
|
|
2046
|
+
}, i);
|
|
2047
|
+
var s = function(l, a) {
|
|
2048
|
+
a ? (l.checked = !0, n.uncheckedClassNames && l.classList.remove(...n.uncheckedClassNames), n.checkedClassNames && l.classList.add(...n.checkedClassNames)) : (l.checked = !1, n.checkedClassNames && l.classList.remove(...n.checkedClassNames), n.uncheckedClassNames && l.classList.add(...n.uncheckedClassNames));
|
|
2049
|
+
}, o = function(l) {
|
|
2050
|
+
setTimeout(() => {
|
|
2051
|
+
var a = l.querySelector("input." + n.className);
|
|
2052
|
+
a instanceof HTMLInputElement && s(a, l.classList.contains("selected"));
|
|
2053
|
+
}, 1);
|
|
2054
|
+
};
|
|
2055
|
+
t.hook("after", "setupTemplates", () => {
|
|
2056
|
+
var r = t.settings.render.option;
|
|
2057
|
+
t.settings.render.option = (l, a) => {
|
|
2058
|
+
var c = Ke(r.call(t, l, a)), d = document.createElement("input");
|
|
2059
|
+
n.className && d.classList.add(n.className), d.addEventListener("click", function(p) {
|
|
2060
|
+
Mt(p);
|
|
2061
|
+
}), d.type = "checkbox";
|
|
2062
|
+
const u = Fe(l[t.settings.valueField]);
|
|
2063
|
+
return s(d, !!(u && t.items.indexOf(u) > -1)), c.prepend(d), c;
|
|
2064
|
+
};
|
|
2065
|
+
}), t.on("item_remove", (r) => {
|
|
2066
|
+
var l = t.getOption(r);
|
|
2067
|
+
l && (l.classList.remove("selected"), o(l));
|
|
2068
|
+
}), t.on("item_add", (r) => {
|
|
2069
|
+
var l = t.getOption(r);
|
|
2070
|
+
l && o(l);
|
|
2071
|
+
}), t.hook("instead", "onOptionSelect", (r, l) => {
|
|
2072
|
+
if (l.classList.contains("selected")) {
|
|
2073
|
+
l.classList.remove("selected"), t.removeItem(l.dataset.value), t.refreshOptions(), Mt(r, !0);
|
|
2074
|
+
return;
|
|
2075
|
+
}
|
|
2076
|
+
e.call(t, r, l), o(l);
|
|
2077
|
+
});
|
|
2078
|
+
}
|
|
2079
|
+
const _e = (i) => {
|
|
2080
|
+
if (i.jquery)
|
|
2081
|
+
return i[0];
|
|
2082
|
+
if (i instanceof HTMLElement)
|
|
2083
|
+
return i;
|
|
2084
|
+
if (je(i)) {
|
|
2085
|
+
var t = document.createElement("template");
|
|
2086
|
+
return t.innerHTML = i.trim(), t.content.firstChild;
|
|
2087
|
+
}
|
|
2088
|
+
return document.querySelector(i);
|
|
2089
|
+
}, je = (i) => typeof i == "string" && i.indexOf("<") > -1;
|
|
2090
|
+
function Te(i) {
|
|
2091
|
+
const t = this, e = Object.assign({
|
|
2092
|
+
className: "clear-button",
|
|
2093
|
+
title: "Clear All",
|
|
2094
|
+
html: (n) => `<div class="${n.className}" title="${n.title}">⨯</div>`
|
|
2095
|
+
}, i);
|
|
2096
|
+
t.on("initialize", () => {
|
|
2097
|
+
var n = _e(e.html(e));
|
|
2098
|
+
n.addEventListener("click", (s) => {
|
|
2099
|
+
t.isLocked || (t.clear(), t.settings.mode === "single" && t.settings.allowEmptyOption && t.addItem(""), s.preventDefault(), s.stopPropagation());
|
|
2100
|
+
}), t.control.appendChild(n);
|
|
2101
|
+
});
|
|
2102
|
+
}
|
|
2103
|
+
const Qe = (i, t = !1) => {
|
|
2104
|
+
i && (i.preventDefault(), t && i.stopPropagation());
|
|
2105
|
+
}, _ = (i, t, e, n) => {
|
|
2106
|
+
i.addEventListener(t, e, n);
|
|
2107
|
+
}, Ee = (i, t) => {
|
|
2108
|
+
if (Array.isArray(i))
|
|
2109
|
+
i.forEach(t);
|
|
2110
|
+
else
|
|
2111
|
+
for (var e in i)
|
|
2112
|
+
i.hasOwnProperty(e) && t(i[e], e);
|
|
2113
|
+
}, Ue = (i) => {
|
|
2114
|
+
if (i.jquery)
|
|
2115
|
+
return i[0];
|
|
2116
|
+
if (i instanceof HTMLElement)
|
|
2117
|
+
return i;
|
|
2118
|
+
if ($e(i)) {
|
|
2119
|
+
var t = document.createElement("template");
|
|
2120
|
+
return t.innerHTML = i.trim(), t.content.firstChild;
|
|
2121
|
+
}
|
|
2122
|
+
return document.querySelector(i);
|
|
2123
|
+
}, $e = (i) => typeof i == "string" && i.indexOf("<") > -1, Pe = (i, t) => {
|
|
2124
|
+
Ee(t, (e, n) => {
|
|
2125
|
+
e == null ? i.removeAttribute(n) : i.setAttribute(n, "" + e);
|
|
2126
|
+
});
|
|
2127
|
+
}, qe = (i, t) => {
|
|
2128
|
+
var e;
|
|
2129
|
+
(e = i.parentNode) == null || e.insertBefore(t, i.nextSibling);
|
|
2130
|
+
}, ti = (i, t) => {
|
|
2131
|
+
var e;
|
|
2132
|
+
(e = i.parentNode) == null || e.insertBefore(t, i);
|
|
2133
|
+
}, ei = (i, t) => {
|
|
2134
|
+
do {
|
|
2135
|
+
var e;
|
|
2136
|
+
if (t = (e = t) == null ? void 0 : e.previousElementSibling, i == t)
|
|
2137
|
+
return !0;
|
|
2138
|
+
} while (t && t.previousElementSibling);
|
|
2139
|
+
return !1;
|
|
2140
|
+
};
|
|
2141
|
+
function ii() {
|
|
2142
|
+
var i = this;
|
|
2143
|
+
if (i.settings.mode !== "multi") return;
|
|
2144
|
+
var t = i.lock, e = i.unlock;
|
|
2145
|
+
let n = !0, s;
|
|
2146
|
+
i.hook("after", "setupTemplates", () => {
|
|
2147
|
+
var o = i.settings.render.item;
|
|
2148
|
+
i.settings.render.item = (r, l) => {
|
|
2149
|
+
const a = Ue(o.call(i, r, l));
|
|
2150
|
+
Pe(a, {
|
|
2151
|
+
draggable: "true"
|
|
2152
|
+
});
|
|
2153
|
+
const c = (b) => {
|
|
2154
|
+
n || Qe(b), b.stopPropagation();
|
|
2155
|
+
}, d = (b) => {
|
|
2156
|
+
s = a, setTimeout(() => {
|
|
2157
|
+
a.classList.add("ts-dragging");
|
|
2158
|
+
}, 0);
|
|
2159
|
+
}, u = (b) => {
|
|
2160
|
+
b.preventDefault(), a.classList.add("ts-drag-over"), y(a, s);
|
|
2161
|
+
}, p = () => {
|
|
2162
|
+
a.classList.remove("ts-drag-over");
|
|
2163
|
+
}, y = (b, Z) => {
|
|
2164
|
+
Z !== void 0 && (ei(Z, a) ? qe(b, Z) : ti(b, Z));
|
|
2165
|
+
}, g = () => {
|
|
2166
|
+
var b;
|
|
2167
|
+
document.querySelectorAll(".ts-drag-over").forEach((I) => I.classList.remove("ts-drag-over")), (b = s) == null || b.classList.remove("ts-dragging"), s = void 0;
|
|
2168
|
+
var Z = [];
|
|
2169
|
+
i.control.querySelectorAll("[data-value]").forEach((I) => {
|
|
2170
|
+
if (I.dataset.value) {
|
|
2171
|
+
let h = I.dataset.value;
|
|
2172
|
+
h && Z.push(h);
|
|
2173
|
+
}
|
|
2174
|
+
}), i.setValue(Z);
|
|
2175
|
+
};
|
|
2176
|
+
return _(a, "mousedown", c), _(a, "dragstart", d), _(a, "dragenter", u), _(a, "dragover", u), _(a, "dragleave", p), _(a, "dragend", g), a;
|
|
2177
|
+
};
|
|
2178
|
+
}), i.hook("instead", "lock", () => (n = !1, t.call(i))), i.hook("instead", "unlock", () => (n = !0, e.call(i)));
|
|
2179
|
+
}
|
|
2180
|
+
const ni = (i, t = !1) => {
|
|
2181
|
+
i && (i.preventDefault(), t && i.stopPropagation());
|
|
2182
|
+
}, si = (i) => {
|
|
2183
|
+
if (i.jquery)
|
|
2184
|
+
return i[0];
|
|
2185
|
+
if (i instanceof HTMLElement)
|
|
2186
|
+
return i;
|
|
2187
|
+
if (ri(i)) {
|
|
2188
|
+
var t = document.createElement("template");
|
|
2189
|
+
return t.innerHTML = i.trim(), t.content.firstChild;
|
|
2190
|
+
}
|
|
2191
|
+
return document.querySelector(i);
|
|
2192
|
+
}, ri = (i) => typeof i == "string" && i.indexOf("<") > -1;
|
|
2193
|
+
function oi(i) {
|
|
2194
|
+
const t = this, e = Object.assign({
|
|
2195
|
+
title: "Untitled",
|
|
2196
|
+
headerClass: "dropdown-header",
|
|
2197
|
+
titleRowClass: "dropdown-header-title",
|
|
2198
|
+
labelClass: "dropdown-header-label",
|
|
2199
|
+
closeClass: "dropdown-header-close",
|
|
2200
|
+
html: (n) => '<div class="' + n.headerClass + '"><div class="' + n.titleRowClass + '"><span class="' + n.labelClass + '">' + n.title + '</span><a class="' + n.closeClass + '">×</a></div></div>'
|
|
2201
|
+
}, i);
|
|
2202
|
+
t.on("initialize", () => {
|
|
2203
|
+
var n = si(e.html(e)), s = n.querySelector("." + e.closeClass);
|
|
2204
|
+
s && s.addEventListener("click", (o) => {
|
|
2205
|
+
ni(o, !0), t.close();
|
|
2206
|
+
}), t.dropdown.insertBefore(n, t.dropdown.firstChild);
|
|
2207
|
+
});
|
|
2208
|
+
}
|
|
2209
|
+
const li = (i, t) => {
|
|
2210
|
+
if (Array.isArray(i))
|
|
2211
|
+
i.forEach(t);
|
|
2212
|
+
else
|
|
2213
|
+
for (var e in i)
|
|
2214
|
+
i.hasOwnProperty(e) && t(i[e], e);
|
|
2215
|
+
}, ci = (i, ...t) => {
|
|
2216
|
+
var e = ai(t);
|
|
2217
|
+
i = di(i), i.map((n) => {
|
|
2218
|
+
e.map((s) => {
|
|
2219
|
+
n.classList.remove(s);
|
|
2220
|
+
});
|
|
2221
|
+
});
|
|
2222
|
+
}, ai = (i) => {
|
|
2223
|
+
var t = [];
|
|
2224
|
+
return li(i, (e) => {
|
|
2225
|
+
typeof e == "string" && (e = e.trim().split(/[\t\n\f\r\s]/)), Array.isArray(e) && (t = t.concat(e));
|
|
2226
|
+
}), t.filter(Boolean);
|
|
2227
|
+
}, di = (i) => (Array.isArray(i) || (i = [i]), i), ui = (i, t) => {
|
|
2228
|
+
if (!i) return -1;
|
|
2229
|
+
t = t || i.nodeName;
|
|
2230
|
+
for (var e = 0; i = i.previousElementSibling; )
|
|
2231
|
+
i.matches(t) && e++;
|
|
2232
|
+
return e;
|
|
2233
|
+
};
|
|
2234
|
+
function gi() {
|
|
2235
|
+
var i = this;
|
|
2236
|
+
i.hook("instead", "setCaret", (t) => {
|
|
2237
|
+
i.settings.mode === "single" || !i.control.contains(i.control_input) ? t = i.items.length : (t = Math.max(0, Math.min(i.items.length, t)), t != i.caretPos && !i.isPending && i.controlChildren().forEach((e, n) => {
|
|
2238
|
+
n < t ? i.control_input.insertAdjacentElement("beforebegin", e) : i.control.appendChild(e);
|
|
2239
|
+
})), i.caretPos = t;
|
|
2240
|
+
}), i.hook("instead", "moveCaret", (t) => {
|
|
2241
|
+
if (!i.isFocused) return;
|
|
2242
|
+
const e = i.getLastActive(t);
|
|
2243
|
+
if (e) {
|
|
2244
|
+
const n = ui(e);
|
|
2245
|
+
i.setCaret(t > 0 ? n + 1 : n), i.setActiveItem(), ci(e, "last-active");
|
|
2246
|
+
} else
|
|
2247
|
+
i.setCaret(i.caretPos + t);
|
|
2248
|
+
});
|
|
2249
|
+
}
|
|
2250
|
+
const pi = 27, hi = 9, mi = (i, t = !1) => {
|
|
2251
|
+
i && (i.preventDefault(), t && i.stopPropagation());
|
|
2252
|
+
}, fi = (i, t, e, n) => {
|
|
2253
|
+
i.addEventListener(t, e, n);
|
|
2254
|
+
}, bi = (i, t) => {
|
|
2255
|
+
if (Array.isArray(i))
|
|
2256
|
+
i.forEach(t);
|
|
2257
|
+
else
|
|
2258
|
+
for (var e in i)
|
|
2259
|
+
i.hasOwnProperty(e) && t(i[e], e);
|
|
2260
|
+
}, Rt = (i) => {
|
|
2261
|
+
if (i.jquery)
|
|
2262
|
+
return i[0];
|
|
2263
|
+
if (i instanceof HTMLElement)
|
|
2264
|
+
return i;
|
|
2265
|
+
if (vi(i)) {
|
|
2266
|
+
var t = document.createElement("template");
|
|
2267
|
+
return t.innerHTML = i.trim(), t.content.firstChild;
|
|
2268
|
+
}
|
|
2269
|
+
return document.querySelector(i);
|
|
2270
|
+
}, vi = (i) => typeof i == "string" && i.indexOf("<") > -1, Ii = (i, ...t) => {
|
|
2271
|
+
var e = Ci(t);
|
|
2272
|
+
i = yi(i), i.map((n) => {
|
|
2273
|
+
e.map((s) => {
|
|
2274
|
+
n.classList.add(s);
|
|
2275
|
+
});
|
|
2276
|
+
});
|
|
2277
|
+
}, Ci = (i) => {
|
|
2278
|
+
var t = [];
|
|
2279
|
+
return bi(i, (e) => {
|
|
2280
|
+
typeof e == "string" && (e = e.trim().split(/[\t\n\f\r\s]/)), Array.isArray(e) && (t = t.concat(e));
|
|
2281
|
+
}), t.filter(Boolean);
|
|
2282
|
+
}, yi = (i) => (Array.isArray(i) || (i = [i]), i);
|
|
2283
|
+
function Zi() {
|
|
2284
|
+
const i = this;
|
|
2285
|
+
i.settings.shouldOpen = !0, i.hook("before", "setup", () => {
|
|
2286
|
+
i.focus_node = i.control, Ii(i.control_input, "dropdown-input");
|
|
2287
|
+
const t = Rt('<div class="dropdown-input-wrap">');
|
|
2288
|
+
t.append(i.control_input), i.dropdown.insertBefore(t, i.dropdown.firstChild);
|
|
2289
|
+
const e = Rt('<input class="items-placeholder" tabindex="-1" />');
|
|
2290
|
+
e.placeholder = i.settings.placeholder || "", i.control.append(e);
|
|
2291
|
+
}), i.on("initialize", () => {
|
|
2292
|
+
i.control_input.addEventListener("keydown", (e) => {
|
|
2293
|
+
switch (e.keyCode) {
|
|
2294
|
+
case pi:
|
|
2295
|
+
i.isOpen && (mi(e, !0), i.close()), i.clearActiveItems();
|
|
2296
|
+
return;
|
|
2297
|
+
case hi:
|
|
2298
|
+
i.focus_node.tabIndex = -1;
|
|
2299
|
+
break;
|
|
2300
|
+
}
|
|
2301
|
+
return i.onKeyDown.call(i, e);
|
|
2302
|
+
}), i.on("blur", () => {
|
|
2303
|
+
i.focus_node.tabIndex = i.isDisabled ? -1 : i.tabIndex;
|
|
2304
|
+
}), i.on("dropdown_open", () => {
|
|
2305
|
+
i.control_input.focus();
|
|
2306
|
+
});
|
|
2307
|
+
const t = i.onBlur;
|
|
2308
|
+
i.hook("instead", "onBlur", (e) => {
|
|
2309
|
+
if (!(e && e.relatedTarget == i.control_input))
|
|
2310
|
+
return t.call(i);
|
|
2311
|
+
}), fi(i.control_input, "blur", () => i.onBlur()), i.hook("before", "close", () => {
|
|
2312
|
+
i.isOpen && i.focus_node.focus({
|
|
2313
|
+
preventScroll: !0
|
|
2314
|
+
});
|
|
2315
|
+
});
|
|
2316
|
+
});
|
|
2317
|
+
}
|
|
2318
|
+
const et = (i, t, e, n) => {
|
|
2319
|
+
i.addEventListener(t, e, n);
|
|
2320
|
+
};
|
|
2321
|
+
function wi() {
|
|
2322
|
+
var i = this;
|
|
2323
|
+
i.on("initialize", () => {
|
|
2324
|
+
var t = document.createElement("span"), e = i.control_input;
|
|
2325
|
+
t.style.cssText = "position:absolute; top:-99999px; left:-99999px; width:auto; padding:0; white-space:pre; ", i.wrapper.appendChild(t);
|
|
2326
|
+
var n = ["letterSpacing", "fontSize", "fontFamily", "fontWeight", "textTransform"];
|
|
2327
|
+
for (const o of n)
|
|
2328
|
+
t.style[o] = e.style[o];
|
|
2329
|
+
var s = () => {
|
|
2330
|
+
t.textContent = e.value, e.style.width = t.clientWidth + "px";
|
|
2331
|
+
};
|
|
2332
|
+
s(), i.on("update item_add item_remove", s), et(e, "input", s), et(e, "keyup", s), et(e, "blur", s), et(e, "update", s);
|
|
2333
|
+
});
|
|
2334
|
+
}
|
|
2335
|
+
function Li() {
|
|
2336
|
+
var i = this, t = i.deleteSelection;
|
|
2337
|
+
this.hook("instead", "deleteSelection", (e) => i.activeItems.length ? t.call(i, e) : !1);
|
|
2338
|
+
}
|
|
2339
|
+
function Wi() {
|
|
2340
|
+
this.hook("instead", "setActiveItem", () => {
|
|
2341
|
+
}), this.hook("instead", "selectAll", () => {
|
|
2342
|
+
});
|
|
2343
|
+
}
|
|
2344
|
+
const Nt = 37, Gi = 39, Ai = (i, t, e) => {
|
|
2345
|
+
for (; i && i.matches; ) {
|
|
2346
|
+
if (i.matches(t))
|
|
2347
|
+
return i;
|
|
2348
|
+
i = i.parentNode;
|
|
2349
|
+
}
|
|
2350
|
+
}, Bi = (i, t) => {
|
|
2351
|
+
if (!i) return -1;
|
|
2352
|
+
t = t || i.nodeName;
|
|
2353
|
+
for (var e = 0; i = i.previousElementSibling; )
|
|
2354
|
+
i.matches(t) && e++;
|
|
2355
|
+
return e;
|
|
2356
|
+
};
|
|
2357
|
+
function Xi() {
|
|
2358
|
+
var i = this, t = i.onKeyDown;
|
|
2359
|
+
i.hook("instead", "onKeyDown", (e) => {
|
|
2360
|
+
var n, s, o, r;
|
|
2361
|
+
if (!i.isOpen || !(e.keyCode === Nt || e.keyCode === Gi))
|
|
2362
|
+
return t.call(i, e);
|
|
2363
|
+
i.ignoreHover = !0, r = Ai(i.activeOption, "[data-group]"), n = Bi(i.activeOption, "[data-selectable]"), r && (e.keyCode === Nt ? r = r.previousSibling : r = r.nextSibling, r && (o = r.querySelectorAll("[data-selectable]"), s = o[Math.min(o.length - 1, n)], s && i.setActiveOption(s)));
|
|
2364
|
+
});
|
|
2365
|
+
}
|
|
2366
|
+
const Yi = (i) => (i + "").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """), Vt = (i, t = !1) => {
|
|
2367
|
+
i && (i.preventDefault(), t && i.stopPropagation());
|
|
2368
|
+
}, zt = (i, t, e, n) => {
|
|
2369
|
+
i.addEventListener(t, e, n);
|
|
2370
|
+
}, kt = (i) => {
|
|
2371
|
+
if (i.jquery)
|
|
2372
|
+
return i[0];
|
|
2373
|
+
if (i instanceof HTMLElement)
|
|
2374
|
+
return i;
|
|
2375
|
+
if (Ji(i)) {
|
|
2376
|
+
var t = document.createElement("template");
|
|
2377
|
+
return t.innerHTML = i.trim(), t.content.firstChild;
|
|
2378
|
+
}
|
|
2379
|
+
return document.querySelector(i);
|
|
2380
|
+
}, Ji = (i) => typeof i == "string" && i.indexOf("<") > -1;
|
|
2381
|
+
function Oi(i) {
|
|
2382
|
+
const t = Object.assign({
|
|
2383
|
+
label: "×",
|
|
2384
|
+
title: "Remove",
|
|
2385
|
+
className: "remove",
|
|
2386
|
+
append: !0
|
|
2387
|
+
}, i);
|
|
2388
|
+
var e = this;
|
|
2389
|
+
if (t.append) {
|
|
2390
|
+
var n = '<a href="javascript:void(0)" class="' + t.className + '" tabindex="-1" title="' + Yi(t.title) + '">' + t.label + "</a>";
|
|
2391
|
+
e.hook("after", "setupTemplates", () => {
|
|
2392
|
+
var s = e.settings.render.item;
|
|
2393
|
+
e.settings.render.item = (o, r) => {
|
|
2394
|
+
var l = kt(s.call(e, o, r)), a = kt(n);
|
|
2395
|
+
return l.appendChild(a), zt(a, "mousedown", (c) => {
|
|
2396
|
+
Vt(c, !0);
|
|
2397
|
+
}), zt(a, "click", (c) => {
|
|
2398
|
+
e.isLocked || (Vt(c, !0), !e.isLocked && e.shouldDelete([l], c) && (e.removeItem(l), e.refreshOptions(!1), e.inputState()));
|
|
2399
|
+
}), l;
|
|
2400
|
+
};
|
|
2401
|
+
});
|
|
2402
|
+
}
|
|
2403
|
+
}
|
|
2404
|
+
function Hi(i) {
|
|
2405
|
+
const t = this, e = Object.assign({
|
|
2406
|
+
text: (n) => n[t.settings.labelField]
|
|
2407
|
+
}, i);
|
|
2408
|
+
t.on("item_remove", function(n) {
|
|
2409
|
+
if (t.isFocused && t.control_input.value.trim() === "") {
|
|
2410
|
+
var s = t.options[n];
|
|
2411
|
+
s && t.setTextboxValue(e.text.call(t, s));
|
|
2412
|
+
}
|
|
2413
|
+
});
|
|
2414
|
+
}
|
|
2415
|
+
const Mi = (i, t) => {
|
|
2416
|
+
if (Array.isArray(i))
|
|
2417
|
+
i.forEach(t);
|
|
2418
|
+
else
|
|
2419
|
+
for (var e in i)
|
|
2420
|
+
i.hasOwnProperty(e) && t(i[e], e);
|
|
2421
|
+
}, Ri = (i, ...t) => {
|
|
2422
|
+
var e = Ni(t);
|
|
2423
|
+
i = Vi(i), i.map((n) => {
|
|
2424
|
+
e.map((s) => {
|
|
2425
|
+
n.classList.add(s);
|
|
2426
|
+
});
|
|
2427
|
+
});
|
|
2428
|
+
}, Ni = (i) => {
|
|
2429
|
+
var t = [];
|
|
2430
|
+
return Mi(i, (e) => {
|
|
2431
|
+
typeof e == "string" && (e = e.trim().split(/[\t\n\f\r\s]/)), Array.isArray(e) && (t = t.concat(e));
|
|
2432
|
+
}), t.filter(Boolean);
|
|
2433
|
+
}, Vi = (i) => (Array.isArray(i) || (i = [i]), i);
|
|
2434
|
+
function zi() {
|
|
2435
|
+
const i = this, t = i.canLoad, e = i.clearActiveOption, n = i.loadCallback;
|
|
2436
|
+
var s = {}, o, r = !1, l, a = [];
|
|
2437
|
+
if (i.settings.shouldLoadMore || (i.settings.shouldLoadMore = () => {
|
|
2438
|
+
if (o.clientHeight / (o.scrollHeight - o.scrollTop) > 0.9)
|
|
2439
|
+
return !0;
|
|
2440
|
+
if (i.activeOption) {
|
|
2441
|
+
var p = i.selectable(), y = Array.from(p).indexOf(i.activeOption);
|
|
2442
|
+
if (y >= p.length - 2)
|
|
2443
|
+
return !0;
|
|
2444
|
+
}
|
|
2445
|
+
return !1;
|
|
2446
|
+
}), !i.settings.firstUrl)
|
|
2447
|
+
throw "virtual_scroll plugin requires a firstUrl() method";
|
|
2448
|
+
i.settings.sortField = [{
|
|
2449
|
+
field: "$order"
|
|
2450
|
+
}, {
|
|
2451
|
+
field: "$score"
|
|
2452
|
+
}];
|
|
2453
|
+
const c = (u) => typeof i.settings.maxOptions == "number" && o.children.length >= i.settings.maxOptions ? !1 : !!(u in s && s[u]), d = (u, p) => i.items.indexOf(p) >= 0 || a.indexOf(p) >= 0;
|
|
2454
|
+
i.setNextUrl = (u, p) => {
|
|
2455
|
+
s[u] = p;
|
|
2456
|
+
}, i.getUrl = (u) => {
|
|
2457
|
+
if (u in s) {
|
|
2458
|
+
const p = s[u];
|
|
2459
|
+
return s[u] = !1, p;
|
|
2460
|
+
}
|
|
2461
|
+
return i.clearPagination(), i.settings.firstUrl.call(i, u);
|
|
2462
|
+
}, i.clearPagination = () => {
|
|
2463
|
+
s = {};
|
|
2464
|
+
}, i.hook("instead", "clearActiveOption", () => {
|
|
2465
|
+
if (!r)
|
|
2466
|
+
return e.call(i);
|
|
2467
|
+
}), i.hook("instead", "canLoad", (u) => u in s ? c(u) : t.call(i, u)), i.hook("instead", "loadCallback", (u, p) => {
|
|
2468
|
+
if (!r)
|
|
2469
|
+
i.clearOptions(d);
|
|
2470
|
+
else if (l) {
|
|
2471
|
+
const y = u[0];
|
|
2472
|
+
y !== void 0 && (l.dataset.value = y[i.settings.valueField]);
|
|
2473
|
+
}
|
|
2474
|
+
n.call(i, u, p), r = !1;
|
|
2475
|
+
}), i.hook("after", "refreshOptions", () => {
|
|
2476
|
+
const u = i.lastValue;
|
|
2477
|
+
var p;
|
|
2478
|
+
c(u) ? (p = i.render("loading_more", {
|
|
2479
|
+
query: u
|
|
2480
|
+
}), p && (p.setAttribute("data-selectable", ""), l = p)) : u in s && !o.querySelector(".no-results") && (p = i.render("no_more_results", {
|
|
2481
|
+
query: u
|
|
2482
|
+
})), p && (Ri(p, i.settings.optionClass), o.append(p));
|
|
2483
|
+
}), i.on("initialize", () => {
|
|
2484
|
+
a = Object.keys(i.options), o = i.dropdown_content, i.settings.render = Object.assign({}, {
|
|
2485
|
+
loading_more: () => '<div class="loading-more-results">Loading more results ... </div>',
|
|
2486
|
+
no_more_results: () => '<div class="no-more-results">No more results</div>'
|
|
2487
|
+
}, i.settings.render), o.addEventListener("scroll", () => {
|
|
2488
|
+
i.settings.shouldLoadMore.call(i) && c(i.lastValue) && (r || (r = !0, i.load.call(i, i.lastValue)));
|
|
2489
|
+
});
|
|
2490
|
+
});
|
|
2491
|
+
}
|
|
2492
|
+
Y.define("change_listener", ke);
|
|
2493
|
+
Y.define("checkbox_options", De);
|
|
2494
|
+
Y.define("clear_button", Te);
|
|
2495
|
+
Y.define("drag_drop", ii);
|
|
2496
|
+
Y.define("dropdown_header", oi);
|
|
2497
|
+
Y.define("caret_position", gi);
|
|
2498
|
+
Y.define("dropdown_input", Zi);
|
|
2499
|
+
Y.define("input_autogrow", wi);
|
|
2500
|
+
Y.define("no_backspace_delete", Li);
|
|
2501
|
+
Y.define("no_active_items", Wi);
|
|
2502
|
+
Y.define("optgroup_columns", Xi);
|
|
2503
|
+
Y.define("remove_button", Oi);
|
|
2504
|
+
Y.define("restore_on_backspace", Hi);
|
|
2505
|
+
Y.define("virtual_scroll", zi);
|
|
2506
|
+
const ki = new URL("data:text/css;base64,LyoqCiAqIFRvbSBTZWxlY3QgQm9vdHN0cmFwIDUKICovCi8qKgogKiB0b20tc2VsZWN0LmNzcyAodjIuNC4zKQogKiBDb3B5cmlnaHQgKGMpIGNvbnRyaWJ1dG9ycwogKgogKiBMaWNlbnNlZCB1bmRlciB0aGUgQXBhY2hlIExpY2Vuc2UsIFZlcnNpb24gMi4wICh0aGUgIkxpY2Vuc2UiKTsgeW91IG1heSBub3QgdXNlIHRoaXMKICogZmlsZSBleGNlcHQgaW4gY29tcGxpYW5jZSB3aXRoIHRoZSBMaWNlbnNlLiBZb3UgbWF5IG9idGFpbiBhIGNvcHkgb2YgdGhlIExpY2Vuc2UgYXQ6CiAqIGh0dHA6Ly93d3cuYXBhY2hlLm9yZy9saWNlbnNlcy9MSUNFTlNFLTIuMAogKgogKiBVbmxlc3MgcmVxdWlyZWQgYnkgYXBwbGljYWJsZSBsYXcgb3IgYWdyZWVkIHRvIGluIHdyaXRpbmcsIHNvZnR3YXJlIGRpc3RyaWJ1dGVkIHVuZGVyCiAqIHRoZSBMaWNlbnNlIGlzIGRpc3RyaWJ1dGVkIG9uIGFuICJBUyBJUyIgQkFTSVMsIFdJVEhPVVQgV0FSUkFOVElFUyBPUiBDT05ESVRJT05TIE9GCiAqIEFOWSBLSU5ELCBlaXRoZXIgZXhwcmVzcyBvciBpbXBsaWVkLiBTZWUgdGhlIExpY2Vuc2UgZm9yIHRoZSBzcGVjaWZpYyBsYW5ndWFnZQogKiBnb3Zlcm5pbmcgcGVybWlzc2lvbnMgYW5kIGxpbWl0YXRpb25zIHVuZGVyIHRoZSBMaWNlbnNlLgogKgogKi8KLnRzLWNvbnRy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q6bm90KC5kaXNhYmxlZCkgLnRzLWNvbnRyb2wsIC50cy13cmFwcGVyLmZvcm0tc2VsZWN0Om5vdCguZGlzYWJsZWQpLnNpbmdsZS5pbnB1dC1hY3RpdmUgLnRzLWNvbnRyb2wgewogIGJhY2tncm91bmQ6IHRyYW5zcGFyZW50ICFpbXBvcnRhbnQ7Cn0KCi5pbnB1dC1ncm91cCA+IC50cy13cmFwcGVyIHsKICBmbGV4LWdyb3c6IDE7CiAgd2lkdGg6IDElOwp9Ci5pbnB1dC1ncm91cCA+IC50cy13cmFwcGVyOm5vdCg6bnRoLWNoaWxkKDIpKSA+IC50cy1jb250cm9sIHsKICBib3JkZXItdG9wLWxlZnQtcmFkaXVzOiAwOwogIGJvcmRlci1ib3R0b20tbGVmdC1yYWRpdXM6IDA7Cn0KLmlucHV0LWdyb3VwID4gLnRzLXdyYXBwZXI6bm90KDpsYXN0LWNoaWxkKSA+IC50cy1jb250cm9sIHsKICBib3JkZXItdG9wLXJpZ2h0LXJhZGl1czogMDsKICBib3JkZXItYm90dG9tLXJpZ2h0LXJhZGl1czogMDsKfQovKiMgc291cmNlTWFwcGluZ1VSTD10b20tc2VsZWN0LmJvb3RzdHJhcDUuY3NzLm1hcCAqLw==", import.meta.url);
|
|
2507
|
+
var O, j, x, z, T, ot, Tt;
|
|
2508
|
+
const It = class It extends HTMLElement {
|
|
2509
|
+
constructor() {
|
|
2510
|
+
super();
|
|
2511
|
+
F(this, ot);
|
|
2512
|
+
F(this, O);
|
|
2513
|
+
F(this, j);
|
|
2514
|
+
F(this, x);
|
|
2515
|
+
F(this, z);
|
|
2516
|
+
F(this, T, {});
|
|
2517
|
+
N(this, O, document.createElement("select")), N(this, j, this.attachShadow({ mode: "open" })), N(this, x, this.attachInternals());
|
|
2518
|
+
}
|
|
2519
|
+
connectedCallback() {
|
|
2520
|
+
this.hasAttribute("name") && (G(this, O).name = this.getAttribute("name")), this.hasAttribute("multiple") && G(this, O).setAttribute("multiple", "");
|
|
2521
|
+
const e = document.createElement("link");
|
|
2522
|
+
e.setAttribute("rel", "stylesheet"), e.setAttribute("href", ki.href), G(this, j).appendChild(G(this, O)), G(this, j).appendChild(e);
|
|
2523
|
+
try {
|
|
2524
|
+
N(this, T, this.getAttributeNames().filter(
|
|
2525
|
+
(n) => n === "options" || n === "value-field" || n === "label-field" || n === "search-field" || n === "items" || n === "optgroup-field" || n === "optgroups"
|
|
2526
|
+
).reduce((n, s) => {
|
|
2527
|
+
const o = s.split("."), r = o.pop(), l = this.getAttribute(s), a = o.reduce((c, d) => (d in c || (c[d] = {}), c[d]), n);
|
|
2528
|
+
return a[Pt(r)] = qt(l), n;
|
|
2529
|
+
}, {}));
|
|
2530
|
+
} catch (n) {
|
|
2531
|
+
console.error("Invalid options JSON:", n), N(this, T, {});
|
|
2532
|
+
}
|
|
2533
|
+
this.tomSelect = new Y(G(this, O), {
|
|
2534
|
+
...G(this, T),
|
|
2535
|
+
plugins: ["remove_button", "clear_button"],
|
|
2536
|
+
highlight: !0
|
|
2537
|
+
}), N(this, z, G(this, O).value), G(this, x).setFormValue(G(this, z)), G(this, O).addEventListener("change", (n) => yt(this, ot, Tt).call(this, n));
|
|
2538
|
+
}
|
|
2539
|
+
get value() {
|
|
2540
|
+
return G(this, z);
|
|
2541
|
+
}
|
|
2542
|
+
set value(e) {
|
|
2543
|
+
N(this, z, e), G(this, O).value = e, G(this, x).setFormValue(e);
|
|
2544
|
+
}
|
|
2545
|
+
};
|
|
2546
|
+
O = new WeakMap(), j = new WeakMap(), x = new WeakMap(), z = new WeakMap(), T = new WeakMap(), ot = new WeakSet(), Tt = function(e) {
|
|
2547
|
+
const n = Array.from(G(this, O).selectedOptions).map((o) => o.value);
|
|
2548
|
+
N(this, z, n);
|
|
2549
|
+
const s = new FormData();
|
|
2550
|
+
for (const o of n)
|
|
2551
|
+
s.append(G(this, O).name, o);
|
|
2552
|
+
G(this, x).setFormValue(s);
|
|
2553
|
+
}, It.formAssociated = !0;
|
|
2554
|
+
let bt = It;
|
|
2555
|
+
customElements.define("sleek-select", bt);
|