@tsed/react-formio 3.0.0-rc.22 → 3.0.0-rc.24
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/all.js +1 -2
- package/dist/all.js.map +1 -1
- package/dist/atoms/icon/Icon.js +4 -4
- package/dist/atoms/icon/Icon.js.map +1 -1
- package/dist/chunks/_baseClone.js +1 -0
- package/dist/chunks/choices.js +2984 -0
- package/dist/chunks/choices.js.map +1 -0
- package/dist/chunks/clsx.js +17 -0
- package/dist/chunks/clsx.js.map +1 -0
- package/dist/chunks/index.js +59969 -36
- package/dist/chunks/index.js.map +1 -1
- package/dist/contexts/FormioContext.js +1 -1
- package/dist/hooks/useI18n.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/molecules/button/Button.js +4 -4
- package/dist/molecules/button/Button.js.map +1 -1
- package/dist/molecules/card/Card.js +4 -4
- package/dist/molecules/card/Card.js.map +1 -1
- package/dist/molecules/forms/form-control/FormControl.js +1 -1
- package/dist/molecules/forms/form-control/FormControl.js.map +1 -1
- package/dist/molecules/forms/input-tags/components/ChoicesTags.d.ts +1 -1
- package/dist/molecules/forms/input-tags/components/ChoicesTags.js +1 -1
- package/dist/molecules/forms/input-tags/components/ChoicesTags.js.map +1 -1
- package/dist/molecules/forms/select/components/ChoicesSelect.d.ts +1 -1
- package/dist/molecules/forms/select/components/ChoicesSelect.js +54 -47
- package/dist/molecules/forms/select/components/ChoicesSelect.js.map +1 -1
- package/dist/molecules/forms/select/components/HtmlSelect.js +8 -8
- package/dist/molecules/forms/select/components/HtmlSelect.js.map +1 -1
- package/dist/molecules/forms/select/components/choices.template.d.ts +27 -2
- package/dist/molecules/forms/select/components/choices.template.js +1085 -1086
- package/dist/molecules/forms/select/components/choices.template.js.map +1 -1
- package/dist/molecules/forms/select/hooks/useOptions.d.ts +1 -1
- package/dist/molecules/forms/select/hooks/useOptions.js +15 -15
- package/dist/molecules/forms/select/hooks/useOptions.js.map +1 -1
- package/dist/molecules/loader/Loader.js +2 -5
- package/dist/molecules/loader/Loader.js.map +1 -1
- package/dist/molecules/pagination/Pagination.js +8 -8
- package/dist/molecules/pagination/Pagination.js.map +1 -1
- package/dist/molecules/pagination/PaginationButton.js +4 -4
- package/dist/molecules/pagination/PaginationButton.js.map +1 -1
- package/dist/molecules/table/Table.js +1 -1
- package/dist/molecules/table/Table.js.map +1 -1
- package/dist/molecules/table/components/DefaultCellHeader.js +1 -1
- package/dist/molecules/table/components/DefaultCellHeader.js.map +1 -1
- package/dist/molecules/table/components/DefaultOperationButton.js +1 -1
- package/dist/molecules/table/components/DefaultOperationButton.js.map +1 -1
- package/dist/molecules/table/filters/Filters.d.ts +2 -2
- package/dist/molecules/table/hooks/useTable.d.ts +1 -1
- package/dist/molecules/table/hooks/useUniqValues.d.ts +6 -2
- package/dist/molecules/table/hooks/useUniqValues.js.map +1 -1
- package/dist/molecules/table/utils/mapFormToColumns.js +27 -28
- package/dist/molecules/table/utils/mapFormToColumns.js.map +1 -1
- package/dist/molecules/tabs/Tab.js +1 -1
- package/dist/molecules/tabs/Tab.js.map +1 -1
- package/dist/molecules/tabs/TabPanel.js +4 -4
- package/dist/molecules/tabs/TabPanel.js.map +1 -1
- package/dist/molecules/tabs/Tabs.js +1 -1
- package/dist/molecules/tabs/Tabs.js.map +1 -1
- package/dist/organisms/form/actions/FormAction.js +1 -1
- package/dist/organisms/form/builder/FormEdit.js +1 -1
- package/dist/organisms/form/builder/FormEdit.js.map +1 -1
- package/dist/organisms/form/builder/useFormBuilder.js +1 -1
- package/dist/organisms/form/useForm.js +1 -1
- package/dist/organisms/modal/RemoveModal.js +1 -1
- package/dist/organisms/modal/RemoveModal.js.map +1 -1
- package/dist/organisms/table/actions/ActionsTable.js +1 -1
- package/dist/organisms/table/actions/ActionsTable.js.map +1 -1
- package/dist/organisms/table/forms/components/FormsCell.js +1 -1
- package/dist/organisms/table/forms/components/FormsCell.js.map +1 -1
- package/dist/utils/iconClass.js +1 -1
- package/package.json +4 -4
- package/src/atoms/icon/Icon.tsx +1 -1
- package/src/molecules/button/Button.tsx +1 -1
- package/src/molecules/card/Card.tsx +2 -2
- package/src/molecules/forms/form-control/FormControl.tsx +2 -2
- package/src/molecules/forms/input-tags/components/ChoicesTags.tsx +1 -1
- package/src/molecules/forms/select/components/ChoicesSelect.stories.tsx +134 -2
- package/src/molecules/forms/select/components/ChoicesSelect.tsx +12 -5
- package/src/molecules/forms/select/components/HtmlSelect.tsx +1 -1
- package/src/molecules/forms/select/components/choices.template.tsx +51 -29
- package/src/molecules/forms/select/hooks/useOptions.ts +1 -5
- package/src/molecules/loader/Loader.tsx +3 -7
- package/src/molecules/pagination/Pagination.tsx +5 -5
- package/src/molecules/pagination/PaginationButton.tsx +2 -2
- package/src/molecules/table/Table.tsx +2 -2
- package/src/molecules/table/components/DefaultCellHeader.tsx +3 -3
- package/src/molecules/table/components/DefaultOperationButton.tsx +1 -1
- package/src/molecules/table/filters/Filters.ts +2 -2
- package/src/molecules/table/hooks/useUniqValues.tsx +7 -3
- package/src/molecules/table/utils/mapFormToColumns.tsx +4 -4
- package/src/molecules/tabs/Tab.tsx +3 -3
- package/src/molecules/tabs/TabPanel.tsx +2 -2
- package/src/molecules/tabs/Tabs.tsx +2 -2
- package/src/organisms/form/builder/FormEdit.tsx +2 -2
- package/src/organisms/modal/RemoveModal.tsx +3 -3
- package/src/organisms/table/actions/ActionsTable.tsx +2 -2
- package/src/organisms/table/forms/components/FormsCell.tsx +1 -1
- package/dist/chunks/index2.js +0 -57535
- package/dist/chunks/index2.js.map +0 -1
|
@@ -0,0 +1,2984 @@
|
|
|
1
|
+
/*! choices.js v11.2.1 | © 2026 Josh Johnson | https://github.com/Choices-js/Choices#readme */
|
|
2
|
+
var le = function(i, e) {
|
|
3
|
+
return le = Object.setPrototypeOf || {
|
|
4
|
+
__proto__: []
|
|
5
|
+
} instanceof Array && function(t, s) {
|
|
6
|
+
t.__proto__ = s;
|
|
7
|
+
} || function(t, s) {
|
|
8
|
+
for (var n in s) Object.prototype.hasOwnProperty.call(s, n) && (t[n] = s[n]);
|
|
9
|
+
}, le(i, e);
|
|
10
|
+
};
|
|
11
|
+
function Re(i, e) {
|
|
12
|
+
if (typeof e != "function" && e !== null) throw new TypeError("Class extends value " + String(e) + " is not a constructor or null");
|
|
13
|
+
le(i, e);
|
|
14
|
+
function t() {
|
|
15
|
+
this.constructor = i;
|
|
16
|
+
}
|
|
17
|
+
i.prototype = e === null ? Object.create(e) : (t.prototype = e.prototype, new t());
|
|
18
|
+
}
|
|
19
|
+
var A = function() {
|
|
20
|
+
return A = Object.assign || function(e) {
|
|
21
|
+
for (var t, s = 1, n = arguments.length; s < n; s++) {
|
|
22
|
+
t = arguments[s];
|
|
23
|
+
for (var r in t) Object.prototype.hasOwnProperty.call(t, r) && (e[r] = t[r]);
|
|
24
|
+
}
|
|
25
|
+
return e;
|
|
26
|
+
}, A.apply(this, arguments);
|
|
27
|
+
};
|
|
28
|
+
function Je(i, e, t) {
|
|
29
|
+
for (var s = 0, n = e.length, r; s < n; s++)
|
|
30
|
+
(r || !(s in e)) && (r || (r = Array.prototype.slice.call(e, 0, s)), r[s] = e[s]);
|
|
31
|
+
return i.concat(r || Array.prototype.slice.call(e));
|
|
32
|
+
}
|
|
33
|
+
var E = {
|
|
34
|
+
ADD_CHOICE: "ADD_CHOICE",
|
|
35
|
+
REMOVE_CHOICE: "REMOVE_CHOICE",
|
|
36
|
+
FILTER_CHOICES: "FILTER_CHOICES",
|
|
37
|
+
ACTIVATE_CHOICES: "ACTIVATE_CHOICES",
|
|
38
|
+
CLEAR_CHOICES: "CLEAR_CHOICES",
|
|
39
|
+
ADD_GROUP: "ADD_GROUP",
|
|
40
|
+
ADD_ITEM: "ADD_ITEM",
|
|
41
|
+
REMOVE_ITEM: "REMOVE_ITEM",
|
|
42
|
+
HIGHLIGHT_ITEM: "HIGHLIGHT_ITEM"
|
|
43
|
+
}, w = {
|
|
44
|
+
showDropdown: "showDropdown",
|
|
45
|
+
hideDropdown: "hideDropdown",
|
|
46
|
+
change: "change",
|
|
47
|
+
choice: "choice",
|
|
48
|
+
search: "search",
|
|
49
|
+
addItem: "addItem",
|
|
50
|
+
removeItem: "removeItem",
|
|
51
|
+
highlightItem: "highlightItem",
|
|
52
|
+
highlightChoice: "highlightChoice",
|
|
53
|
+
unhighlightItem: "unhighlightItem"
|
|
54
|
+
}, I = {
|
|
55
|
+
TAB_KEY: 9,
|
|
56
|
+
SHIFT_KEY: 16,
|
|
57
|
+
BACK_KEY: 46,
|
|
58
|
+
DELETE_KEY: 8,
|
|
59
|
+
ENTER_KEY: 13,
|
|
60
|
+
A_KEY: 65,
|
|
61
|
+
ESC_KEY: 27,
|
|
62
|
+
UP_KEY: 38,
|
|
63
|
+
DOWN_KEY: 40,
|
|
64
|
+
PAGE_UP_KEY: 33,
|
|
65
|
+
PAGE_DOWN_KEY: 34
|
|
66
|
+
}, Qe = ["fuseOptions", "classNames"], H = {
|
|
67
|
+
Text: "text",
|
|
68
|
+
SelectOne: "select-one",
|
|
69
|
+
SelectMultiple: "select-multiple"
|
|
70
|
+
}, ye = function(i) {
|
|
71
|
+
return {
|
|
72
|
+
type: E.ADD_CHOICE,
|
|
73
|
+
choice: i
|
|
74
|
+
};
|
|
75
|
+
}, Ze = function(i) {
|
|
76
|
+
return {
|
|
77
|
+
type: E.REMOVE_CHOICE,
|
|
78
|
+
choice: i
|
|
79
|
+
};
|
|
80
|
+
}, et = function(i) {
|
|
81
|
+
return {
|
|
82
|
+
type: E.FILTER_CHOICES,
|
|
83
|
+
results: i
|
|
84
|
+
};
|
|
85
|
+
}, tt = function(i) {
|
|
86
|
+
return {
|
|
87
|
+
type: E.ACTIVATE_CHOICES,
|
|
88
|
+
active: i
|
|
89
|
+
};
|
|
90
|
+
}, it = function(i) {
|
|
91
|
+
return {
|
|
92
|
+
type: E.ADD_GROUP,
|
|
93
|
+
group: i
|
|
94
|
+
};
|
|
95
|
+
}, be = function(i) {
|
|
96
|
+
return {
|
|
97
|
+
type: E.ADD_ITEM,
|
|
98
|
+
item: i
|
|
99
|
+
};
|
|
100
|
+
}, Ee = function(i) {
|
|
101
|
+
return {
|
|
102
|
+
type: E.REMOVE_ITEM,
|
|
103
|
+
item: i
|
|
104
|
+
};
|
|
105
|
+
}, Z = function(i, e) {
|
|
106
|
+
return {
|
|
107
|
+
type: E.HIGHLIGHT_ITEM,
|
|
108
|
+
item: i,
|
|
109
|
+
highlighted: e
|
|
110
|
+
};
|
|
111
|
+
}, st = function(i, e) {
|
|
112
|
+
return Math.floor(Math.random() * (e - i) + i);
|
|
113
|
+
}, Ce = function(i) {
|
|
114
|
+
return Array.from({ length: i }, function() {
|
|
115
|
+
return st(0, 36).toString(36);
|
|
116
|
+
}).join("");
|
|
117
|
+
}, nt = function(i, e) {
|
|
118
|
+
var t = i.id || i.name && "".concat(i.name, "-").concat(Ce(2)) || Ce(4);
|
|
119
|
+
return t = t.replace(/(:|\.|\[|\]|,)/g, ""), t = "".concat(e, "-").concat(t), t;
|
|
120
|
+
}, rt = function(i, e, t) {
|
|
121
|
+
t === void 0 && (t = 1);
|
|
122
|
+
for (var s = "".concat(t > 0 ? "next" : "previous", "ElementSibling"), n = i[s]; n; ) {
|
|
123
|
+
if (n.matches(e))
|
|
124
|
+
return n;
|
|
125
|
+
n = n[s];
|
|
126
|
+
}
|
|
127
|
+
return null;
|
|
128
|
+
}, Se = function(i, e, t) {
|
|
129
|
+
t === void 0 && (t = 1);
|
|
130
|
+
var s;
|
|
131
|
+
return t > 0 ? s = e.scrollTop + e.offsetHeight >= i.offsetTop + i.offsetHeight : s = i.offsetTop >= e.scrollTop, s;
|
|
132
|
+
}, J = function(i) {
|
|
133
|
+
if (typeof i != "string") {
|
|
134
|
+
if (i == null)
|
|
135
|
+
return "";
|
|
136
|
+
if (typeof i == "object") {
|
|
137
|
+
if ("raw" in i)
|
|
138
|
+
return J(i.raw);
|
|
139
|
+
if ("trusted" in i)
|
|
140
|
+
return i.trusted;
|
|
141
|
+
}
|
|
142
|
+
return i;
|
|
143
|
+
}
|
|
144
|
+
return i.replace(/&/g, "&").replace(/>/g, ">").replace(/</g, "<").replace(/'/g, "'").replace(/"/g, """);
|
|
145
|
+
}, ot = (function() {
|
|
146
|
+
var i = document.createElement("div");
|
|
147
|
+
return function(e) {
|
|
148
|
+
i.innerHTML = e.trim();
|
|
149
|
+
for (var t = i.children[0]; i.firstChild; )
|
|
150
|
+
i.removeChild(i.firstChild);
|
|
151
|
+
return t;
|
|
152
|
+
};
|
|
153
|
+
})(), Ie = function(i) {
|
|
154
|
+
return typeof i == "function" ? i() : i;
|
|
155
|
+
}, N = function(i) {
|
|
156
|
+
if (typeof i == "string")
|
|
157
|
+
return i;
|
|
158
|
+
if (typeof i == "object") {
|
|
159
|
+
if ("trusted" in i)
|
|
160
|
+
return i.trusted;
|
|
161
|
+
if ("raw" in i)
|
|
162
|
+
return i.raw;
|
|
163
|
+
}
|
|
164
|
+
return "";
|
|
165
|
+
}, Ke = function(i) {
|
|
166
|
+
if (typeof i == "string")
|
|
167
|
+
return i;
|
|
168
|
+
if (typeof i == "object") {
|
|
169
|
+
if ("escaped" in i)
|
|
170
|
+
return i.escaped;
|
|
171
|
+
if ("trusted" in i)
|
|
172
|
+
return i.trusted;
|
|
173
|
+
}
|
|
174
|
+
return "";
|
|
175
|
+
}, M = function(i, e) {
|
|
176
|
+
return {
|
|
177
|
+
id: i.id,
|
|
178
|
+
highlighted: i.highlighted,
|
|
179
|
+
labelClass: i.labelClass,
|
|
180
|
+
labelDescription: N(i.labelDescription),
|
|
181
|
+
customProperties: i.customProperties,
|
|
182
|
+
disabled: i.disabled,
|
|
183
|
+
active: i.active,
|
|
184
|
+
label: i.label,
|
|
185
|
+
placeholder: i.placeholder,
|
|
186
|
+
value: i.value,
|
|
187
|
+
groupValue: i.group ? i.group.label : void 0,
|
|
188
|
+
element: i.element,
|
|
189
|
+
keyCode: e
|
|
190
|
+
};
|
|
191
|
+
}, X = function(i, e, t) {
|
|
192
|
+
return typeof i == "function" ? i(J(e), N(e), t) : i;
|
|
193
|
+
}, me = function(i, e) {
|
|
194
|
+
return i ? Ke(e) : J(e);
|
|
195
|
+
}, F = function(i, e, t) {
|
|
196
|
+
i.innerHTML = me(e, t);
|
|
197
|
+
}, at = function(i, e) {
|
|
198
|
+
var t = i.value, s = i.label, n = s === void 0 ? t : s, r = e.value, o = e.label, a = o === void 0 ? r : o;
|
|
199
|
+
return N(n).localeCompare(N(a), [], {
|
|
200
|
+
sensitivity: "base",
|
|
201
|
+
ignorePunctuation: !0,
|
|
202
|
+
numeric: !0
|
|
203
|
+
});
|
|
204
|
+
}, lt = function(i, e) {
|
|
205
|
+
return i.rank - e.rank;
|
|
206
|
+
}, ct = function(i, e, t) {
|
|
207
|
+
t === void 0 && (t = null);
|
|
208
|
+
var s = new CustomEvent(e, {
|
|
209
|
+
detail: t,
|
|
210
|
+
bubbles: !0,
|
|
211
|
+
cancelable: !0
|
|
212
|
+
});
|
|
213
|
+
return i.dispatchEvent(s);
|
|
214
|
+
}, ht = function(i, e) {
|
|
215
|
+
var t = Object.keys(i).sort(), s = Object.keys(e).sort();
|
|
216
|
+
return t.filter(function(n) {
|
|
217
|
+
return s.indexOf(n) < 0;
|
|
218
|
+
});
|
|
219
|
+
}, ie = function(i) {
|
|
220
|
+
return Array.isArray(i) ? i : [i];
|
|
221
|
+
}, W = function(i) {
|
|
222
|
+
return i && Array.isArray(i) ? i.map(function(e) {
|
|
223
|
+
return ".".concat(e);
|
|
224
|
+
}).join("") : ".".concat(i);
|
|
225
|
+
}, _ = function(i, e) {
|
|
226
|
+
var t;
|
|
227
|
+
(t = i.classList).add.apply(t, ie(e));
|
|
228
|
+
}, L = function(i, e) {
|
|
229
|
+
var t;
|
|
230
|
+
(t = i.classList).remove.apply(t, ie(e));
|
|
231
|
+
}, ut = function(i) {
|
|
232
|
+
if (typeof i < "u")
|
|
233
|
+
try {
|
|
234
|
+
return JSON.parse(i);
|
|
235
|
+
} catch {
|
|
236
|
+
return i;
|
|
237
|
+
}
|
|
238
|
+
return {};
|
|
239
|
+
}, dt = function(i, e, t) {
|
|
240
|
+
var s = i.itemEl;
|
|
241
|
+
s && (L(s, t), _(s, e));
|
|
242
|
+
}, ft = (
|
|
243
|
+
/** @class */
|
|
244
|
+
(function() {
|
|
245
|
+
function i(e) {
|
|
246
|
+
var t = e.element, s = e.type, n = e.classNames;
|
|
247
|
+
this.element = t, this.classNames = n, this.type = s, this.isActive = !1;
|
|
248
|
+
}
|
|
249
|
+
return i.prototype.show = function() {
|
|
250
|
+
return _(this.element, this.classNames.activeState), this.element.setAttribute("aria-expanded", "true"), this.isActive = !0, this;
|
|
251
|
+
}, i.prototype.hide = function() {
|
|
252
|
+
return L(this.element, this.classNames.activeState), this.element.setAttribute("aria-expanded", "false"), this.isActive = !1, this;
|
|
253
|
+
}, i;
|
|
254
|
+
})()
|
|
255
|
+
), we = (
|
|
256
|
+
/** @class */
|
|
257
|
+
(function() {
|
|
258
|
+
function i(e) {
|
|
259
|
+
var t = e.element, s = e.type, n = e.classNames, r = e.position;
|
|
260
|
+
this.element = t, this.classNames = n, this.type = s, this.position = r, this.isOpen = !1, this.isFlipped = !1, this.isDisabled = !1, this.isLoading = !1;
|
|
261
|
+
}
|
|
262
|
+
return i.prototype.shouldFlip = function(e, t) {
|
|
263
|
+
var s = !1;
|
|
264
|
+
return this.position === "auto" ? s = this.element.getBoundingClientRect().top - t >= 0 && !window.matchMedia("(min-height: ".concat(e + 1, "px)")).matches : this.position === "top" && (s = !0), s;
|
|
265
|
+
}, i.prototype.setActiveDescendant = function(e) {
|
|
266
|
+
this.element.setAttribute("aria-activedescendant", e);
|
|
267
|
+
}, i.prototype.removeActiveDescendant = function() {
|
|
268
|
+
this.element.removeAttribute("aria-activedescendant");
|
|
269
|
+
}, i.prototype.open = function(e, t) {
|
|
270
|
+
_(this.element, this.classNames.openState), this.element.setAttribute("aria-expanded", "true"), this.isOpen = !0, this.shouldFlip(e, t) && (_(this.element, this.classNames.flippedState), this.isFlipped = !0);
|
|
271
|
+
}, i.prototype.close = function() {
|
|
272
|
+
L(this.element, this.classNames.openState), this.element.setAttribute("aria-expanded", "false"), this.removeActiveDescendant(), this.isOpen = !1, this.isFlipped && (L(this.element, this.classNames.flippedState), this.isFlipped = !1);
|
|
273
|
+
}, i.prototype.addFocusState = function() {
|
|
274
|
+
_(this.element, this.classNames.focusState);
|
|
275
|
+
}, i.prototype.removeFocusState = function() {
|
|
276
|
+
L(this.element, this.classNames.focusState);
|
|
277
|
+
}, i.prototype.addInvalidState = function() {
|
|
278
|
+
_(this.element, this.classNames.invalidState);
|
|
279
|
+
}, i.prototype.removeInvalidState = function() {
|
|
280
|
+
L(this.element, this.classNames.invalidState);
|
|
281
|
+
}, i.prototype.enable = function() {
|
|
282
|
+
L(this.element, this.classNames.disabledState), this.element.removeAttribute("aria-disabled"), this.type === H.SelectOne && this.element.setAttribute("tabindex", "0"), this.isDisabled = !1;
|
|
283
|
+
}, i.prototype.disable = function() {
|
|
284
|
+
_(this.element, this.classNames.disabledState), this.element.setAttribute("aria-disabled", "true"), this.type === H.SelectOne && this.element.setAttribute("tabindex", "-1"), this.isDisabled = !0;
|
|
285
|
+
}, i.prototype.wrap = function(e) {
|
|
286
|
+
var t = this.element, s = e.parentNode;
|
|
287
|
+
s && (e.nextSibling ? s.insertBefore(t, e.nextSibling) : s.appendChild(t)), t.appendChild(e);
|
|
288
|
+
}, i.prototype.unwrap = function(e) {
|
|
289
|
+
var t = this.element, s = t.parentNode;
|
|
290
|
+
s && (s.insertBefore(e, t), s.removeChild(t));
|
|
291
|
+
}, i.prototype.addLoadingState = function() {
|
|
292
|
+
_(this.element, this.classNames.loadingState), this.element.setAttribute("aria-busy", "true"), this.isLoading = !0;
|
|
293
|
+
}, i.prototype.removeLoadingState = function() {
|
|
294
|
+
L(this.element, this.classNames.loadingState), this.element.removeAttribute("aria-busy"), this.isLoading = !1;
|
|
295
|
+
}, i;
|
|
296
|
+
})()
|
|
297
|
+
), pt = (
|
|
298
|
+
/** @class */
|
|
299
|
+
(function() {
|
|
300
|
+
function i(e) {
|
|
301
|
+
var t = e.element, s = e.type, n = e.classNames, r = e.preventPaste;
|
|
302
|
+
this.element = t, this.type = s, this.classNames = n, this.preventPaste = r, this.isFocussed = this.element.isEqualNode(document.activeElement), this.isDisabled = t.disabled, this._onPaste = this._onPaste.bind(this), this._onInput = this._onInput.bind(this), this._onFocus = this._onFocus.bind(this), this._onBlur = this._onBlur.bind(this);
|
|
303
|
+
}
|
|
304
|
+
return Object.defineProperty(i.prototype, "placeholder", {
|
|
305
|
+
set: function(e) {
|
|
306
|
+
this.element.placeholder = e;
|
|
307
|
+
},
|
|
308
|
+
enumerable: !1,
|
|
309
|
+
configurable: !0
|
|
310
|
+
}), Object.defineProperty(i.prototype, "value", {
|
|
311
|
+
get: function() {
|
|
312
|
+
return this.element.value;
|
|
313
|
+
},
|
|
314
|
+
set: function(e) {
|
|
315
|
+
this.element.value = e;
|
|
316
|
+
},
|
|
317
|
+
enumerable: !1,
|
|
318
|
+
configurable: !0
|
|
319
|
+
}), i.prototype.addEventListeners = function() {
|
|
320
|
+
var e = this.element;
|
|
321
|
+
e.addEventListener("paste", this._onPaste), e.addEventListener("input", this._onInput, {
|
|
322
|
+
passive: !0
|
|
323
|
+
}), e.addEventListener("focus", this._onFocus, {
|
|
324
|
+
passive: !0
|
|
325
|
+
}), e.addEventListener("blur", this._onBlur, {
|
|
326
|
+
passive: !0
|
|
327
|
+
});
|
|
328
|
+
}, i.prototype.removeEventListeners = function() {
|
|
329
|
+
var e = this.element;
|
|
330
|
+
e.removeEventListener("input", this._onInput), e.removeEventListener("paste", this._onPaste), e.removeEventListener("focus", this._onFocus), e.removeEventListener("blur", this._onBlur);
|
|
331
|
+
}, i.prototype.enable = function() {
|
|
332
|
+
var e = this.element;
|
|
333
|
+
e.removeAttribute("disabled"), this.isDisabled = !1;
|
|
334
|
+
}, i.prototype.disable = function() {
|
|
335
|
+
var e = this.element;
|
|
336
|
+
e.setAttribute("disabled", ""), this.isDisabled = !0;
|
|
337
|
+
}, i.prototype.focus = function() {
|
|
338
|
+
this.isFocussed || this.element.focus();
|
|
339
|
+
}, i.prototype.blur = function() {
|
|
340
|
+
this.isFocussed && this.element.blur();
|
|
341
|
+
}, i.prototype.clear = function(e) {
|
|
342
|
+
return e === void 0 && (e = !0), this.element.value = "", e && this.setWidth(), this;
|
|
343
|
+
}, i.prototype.setWidth = function() {
|
|
344
|
+
var e = this.element;
|
|
345
|
+
e.style.minWidth = "".concat(e.placeholder.length + 1, "ch"), e.style.width = "".concat(e.value.length + 1, "ch");
|
|
346
|
+
}, i.prototype.setActiveDescendant = function(e) {
|
|
347
|
+
this.element.setAttribute("aria-activedescendant", e);
|
|
348
|
+
}, i.prototype.removeActiveDescendant = function() {
|
|
349
|
+
this.element.removeAttribute("aria-activedescendant");
|
|
350
|
+
}, i.prototype._onInput = function() {
|
|
351
|
+
this.type !== H.SelectOne && this.setWidth();
|
|
352
|
+
}, i.prototype._onPaste = function(e) {
|
|
353
|
+
this.preventPaste && e.preventDefault();
|
|
354
|
+
}, i.prototype._onFocus = function() {
|
|
355
|
+
this.isFocussed = !0;
|
|
356
|
+
}, i.prototype._onBlur = function() {
|
|
357
|
+
this.isFocussed = !1;
|
|
358
|
+
}, i;
|
|
359
|
+
})()
|
|
360
|
+
), mt = 4, Ae = (
|
|
361
|
+
/** @class */
|
|
362
|
+
(function() {
|
|
363
|
+
function i(e) {
|
|
364
|
+
var t = e.element;
|
|
365
|
+
this.element = t, this.scrollPos = this.element.scrollTop, this.height = this.element.offsetHeight;
|
|
366
|
+
}
|
|
367
|
+
return i.prototype.prepend = function(e) {
|
|
368
|
+
var t = this.element.firstElementChild;
|
|
369
|
+
t ? this.element.insertBefore(e, t) : this.element.append(e);
|
|
370
|
+
}, i.prototype.scrollToTop = function() {
|
|
371
|
+
this.element.scrollTop = 0;
|
|
372
|
+
}, i.prototype.scrollToChildElement = function(e, t) {
|
|
373
|
+
var s = this;
|
|
374
|
+
if (e) {
|
|
375
|
+
var n = this.element.offsetHeight, r = this.element.scrollTop + n, o = e.offsetHeight, a = e.offsetTop + o, l = t > 0 ? this.element.scrollTop + a - r : e.offsetTop;
|
|
376
|
+
requestAnimationFrame(function() {
|
|
377
|
+
s._animateScroll(l, t);
|
|
378
|
+
});
|
|
379
|
+
}
|
|
380
|
+
}, i.prototype._scrollDown = function(e, t, s) {
|
|
381
|
+
var n = (s - e) / t, r = n > 1 ? n : 1;
|
|
382
|
+
this.element.scrollTop = e + r;
|
|
383
|
+
}, i.prototype._scrollUp = function(e, t, s) {
|
|
384
|
+
var n = (e - s) / t, r = n > 1 ? n : 1;
|
|
385
|
+
this.element.scrollTop = e - r;
|
|
386
|
+
}, i.prototype._animateScroll = function(e, t) {
|
|
387
|
+
var s = this, n = mt, r = this.element.scrollTop, o = !1;
|
|
388
|
+
t > 0 ? (this._scrollDown(r, n, e), r < e && (o = !0)) : (this._scrollUp(r, n, e), r > e && (o = !0)), o && requestAnimationFrame(function() {
|
|
389
|
+
s._animateScroll(e, t);
|
|
390
|
+
});
|
|
391
|
+
}, i;
|
|
392
|
+
})()
|
|
393
|
+
), He = (
|
|
394
|
+
/** @class */
|
|
395
|
+
(function() {
|
|
396
|
+
function i(e) {
|
|
397
|
+
var t = e.element, s = e.classNames;
|
|
398
|
+
this.element = t, this.classNames = s, this.isDisabled = !1;
|
|
399
|
+
}
|
|
400
|
+
return Object.defineProperty(i.prototype, "isActive", {
|
|
401
|
+
get: function() {
|
|
402
|
+
return this.element.dataset.choice === "active";
|
|
403
|
+
},
|
|
404
|
+
enumerable: !1,
|
|
405
|
+
configurable: !0
|
|
406
|
+
}), Object.defineProperty(i.prototype, "dir", {
|
|
407
|
+
get: function() {
|
|
408
|
+
return this.element.dir;
|
|
409
|
+
},
|
|
410
|
+
enumerable: !1,
|
|
411
|
+
configurable: !0
|
|
412
|
+
}), Object.defineProperty(i.prototype, "value", {
|
|
413
|
+
get: function() {
|
|
414
|
+
return this.element.value;
|
|
415
|
+
},
|
|
416
|
+
set: function(e) {
|
|
417
|
+
this.element.setAttribute("value", e), this.element.value = e;
|
|
418
|
+
},
|
|
419
|
+
enumerable: !1,
|
|
420
|
+
configurable: !0
|
|
421
|
+
}), i.prototype.conceal = function() {
|
|
422
|
+
var e = this.element;
|
|
423
|
+
_(e, this.classNames.input), e.hidden = !0, e.tabIndex = -1;
|
|
424
|
+
var t = e.getAttribute("style");
|
|
425
|
+
t && e.setAttribute("data-choice-orig-style", t), e.setAttribute("data-choice", "active");
|
|
426
|
+
}, i.prototype.reveal = function() {
|
|
427
|
+
var e = this.element;
|
|
428
|
+
L(e, this.classNames.input), e.hidden = !1, e.removeAttribute("tabindex");
|
|
429
|
+
var t = e.getAttribute("data-choice-orig-style");
|
|
430
|
+
t ? (e.removeAttribute("data-choice-orig-style"), e.setAttribute("style", t)) : e.removeAttribute("style"), e.removeAttribute("data-choice");
|
|
431
|
+
}, i.prototype.enable = function() {
|
|
432
|
+
this.element.removeAttribute("disabled"), this.element.disabled = !1, this.isDisabled = !1;
|
|
433
|
+
}, i.prototype.disable = function() {
|
|
434
|
+
this.element.setAttribute("disabled", ""), this.element.disabled = !0, this.isDisabled = !0;
|
|
435
|
+
}, i.prototype.triggerEvent = function(e, t) {
|
|
436
|
+
ct(this.element, e, t || {});
|
|
437
|
+
}, i;
|
|
438
|
+
})()
|
|
439
|
+
), vt = (
|
|
440
|
+
/** @class */
|
|
441
|
+
(function(i) {
|
|
442
|
+
Re(e, i);
|
|
443
|
+
function e() {
|
|
444
|
+
return i !== null && i.apply(this, arguments) || this;
|
|
445
|
+
}
|
|
446
|
+
return e;
|
|
447
|
+
})(He)
|
|
448
|
+
), z = function(i, e) {
|
|
449
|
+
return e === void 0 && (e = !0), typeof i > "u" ? e : !!i;
|
|
450
|
+
}, je = function(i) {
|
|
451
|
+
if (typeof i == "string" && (i = i.split(" ").filter(function(e) {
|
|
452
|
+
return e.length;
|
|
453
|
+
})), Array.isArray(i) && i.length)
|
|
454
|
+
return i;
|
|
455
|
+
}, D = function(i, e, t) {
|
|
456
|
+
if (t === void 0 && (t = !0), typeof i == "string") {
|
|
457
|
+
var s = J(i), n = t || s === i ? i : { escaped: s, raw: i }, r = D({
|
|
458
|
+
value: i,
|
|
459
|
+
label: n,
|
|
460
|
+
selected: !0
|
|
461
|
+
}, !1);
|
|
462
|
+
return r;
|
|
463
|
+
}
|
|
464
|
+
var o = i;
|
|
465
|
+
if ("choices" in o) {
|
|
466
|
+
if (!e)
|
|
467
|
+
throw new TypeError("optGroup is not allowed");
|
|
468
|
+
var a = o, l = a.choices.map(function(d) {
|
|
469
|
+
return D(d, !1);
|
|
470
|
+
}), h = {
|
|
471
|
+
id: 0,
|
|
472
|
+
// actual ID will be assigned during _addGroup
|
|
473
|
+
label: N(a.label) || a.value,
|
|
474
|
+
active: !!l.length,
|
|
475
|
+
disabled: !!a.disabled,
|
|
476
|
+
choices: l
|
|
477
|
+
};
|
|
478
|
+
return h;
|
|
479
|
+
}
|
|
480
|
+
var c = o, u = {
|
|
481
|
+
id: 0,
|
|
482
|
+
// actual ID will be assigned during _addChoice
|
|
483
|
+
group: null,
|
|
484
|
+
// actual group will be assigned during _addGroup but before _addChoice
|
|
485
|
+
score: 0,
|
|
486
|
+
// used in search
|
|
487
|
+
rank: 0,
|
|
488
|
+
// used in search, stable sort order
|
|
489
|
+
value: c.value,
|
|
490
|
+
label: c.label || c.value,
|
|
491
|
+
active: z(c.active),
|
|
492
|
+
selected: z(c.selected, !1),
|
|
493
|
+
disabled: z(c.disabled, !1),
|
|
494
|
+
placeholder: z(c.placeholder, !1),
|
|
495
|
+
highlighted: !1,
|
|
496
|
+
labelClass: je(c.labelClass),
|
|
497
|
+
labelDescription: c.labelDescription,
|
|
498
|
+
customProperties: c.customProperties
|
|
499
|
+
};
|
|
500
|
+
return u;
|
|
501
|
+
}, _t = function(i) {
|
|
502
|
+
return i.tagName === "INPUT";
|
|
503
|
+
}, Ve = function(i) {
|
|
504
|
+
return i.tagName === "SELECT";
|
|
505
|
+
}, gt = function(i) {
|
|
506
|
+
return i.tagName === "OPTION";
|
|
507
|
+
}, yt = function(i) {
|
|
508
|
+
return i.tagName === "OPTGROUP";
|
|
509
|
+
}, bt = (
|
|
510
|
+
/** @class */
|
|
511
|
+
(function(i) {
|
|
512
|
+
Re(e, i);
|
|
513
|
+
function e(t) {
|
|
514
|
+
var s = t.element, n = t.classNames, r = t.template, o = t.extractPlaceholder, a = i.call(this, { element: s, classNames: n }) || this;
|
|
515
|
+
return a.template = r, a.extractPlaceholder = o, a;
|
|
516
|
+
}
|
|
517
|
+
return Object.defineProperty(e.prototype, "placeholderOption", {
|
|
518
|
+
get: function() {
|
|
519
|
+
return this.element.querySelector('option[value=""]') || // Backward compatibility layer for the non-standard placeholder attribute supported in older versions.
|
|
520
|
+
this.element.querySelector("option[placeholder]");
|
|
521
|
+
},
|
|
522
|
+
enumerable: !1,
|
|
523
|
+
configurable: !0
|
|
524
|
+
}), e.prototype.addOptions = function(t) {
|
|
525
|
+
var s = this, n = document.createDocumentFragment();
|
|
526
|
+
t.forEach(function(r) {
|
|
527
|
+
var o = r;
|
|
528
|
+
if (!o.element) {
|
|
529
|
+
var a = s.template(o);
|
|
530
|
+
n.appendChild(a), o.element = a;
|
|
531
|
+
}
|
|
532
|
+
}), this.element.appendChild(n);
|
|
533
|
+
}, e.prototype.optionsAsChoices = function() {
|
|
534
|
+
var t = this, s = [];
|
|
535
|
+
return this.element.querySelectorAll(":scope > option, :scope > optgroup").forEach(function(n) {
|
|
536
|
+
gt(n) ? s.push(t._optionToChoice(n)) : yt(n) && s.push(t._optgroupToChoice(n));
|
|
537
|
+
}), s;
|
|
538
|
+
}, e.prototype._optionToChoice = function(t) {
|
|
539
|
+
return !t.hasAttribute("value") && t.hasAttribute("placeholder") && (t.setAttribute("value", ""), t.value = ""), {
|
|
540
|
+
id: 0,
|
|
541
|
+
group: null,
|
|
542
|
+
score: 0,
|
|
543
|
+
rank: 0,
|
|
544
|
+
value: t.value,
|
|
545
|
+
// https://developer.mozilla.org/en-US/docs/Web/HTML/Element/option
|
|
546
|
+
// This attribute is text for the label indicating the meaning of the option. If the `label` attribute isn't defined, its value is that of the element text content (ie `innerText`).
|
|
547
|
+
label: t.label,
|
|
548
|
+
element: t,
|
|
549
|
+
active: !0,
|
|
550
|
+
// this returns true if nothing is selected on initial load, which will break placeholder support
|
|
551
|
+
selected: this.extractPlaceholder ? t.selected : t.hasAttribute("selected"),
|
|
552
|
+
disabled: t.disabled,
|
|
553
|
+
highlighted: !1,
|
|
554
|
+
placeholder: this.extractPlaceholder && (!t.value || t.hasAttribute("placeholder")),
|
|
555
|
+
labelClass: typeof t.dataset.labelClass < "u" ? je(t.dataset.labelClass) : void 0,
|
|
556
|
+
labelDescription: typeof t.dataset.labelDescription < "u" ? { trusted: t.dataset.labelDescription } : void 0,
|
|
557
|
+
customProperties: ut(t.dataset.customProperties)
|
|
558
|
+
};
|
|
559
|
+
}, e.prototype._optgroupToChoice = function(t) {
|
|
560
|
+
var s = this, n = t.querySelectorAll("option"), r = Array.from(n).map(function(o) {
|
|
561
|
+
return s._optionToChoice(o);
|
|
562
|
+
});
|
|
563
|
+
return {
|
|
564
|
+
id: 0,
|
|
565
|
+
label: t.label || "",
|
|
566
|
+
element: t,
|
|
567
|
+
active: !!r.length,
|
|
568
|
+
disabled: t.disabled,
|
|
569
|
+
choices: r
|
|
570
|
+
};
|
|
571
|
+
}, e;
|
|
572
|
+
})(He)
|
|
573
|
+
), Et = {
|
|
574
|
+
containerOuter: ["choices"],
|
|
575
|
+
containerInner: ["choices__inner"],
|
|
576
|
+
input: ["choices__input"],
|
|
577
|
+
inputCloned: ["choices__input--cloned"],
|
|
578
|
+
list: ["choices__list"],
|
|
579
|
+
listItems: ["choices__list--multiple"],
|
|
580
|
+
listSingle: ["choices__list--single"],
|
|
581
|
+
listDropdown: ["choices__list--dropdown"],
|
|
582
|
+
item: ["choices__item"],
|
|
583
|
+
itemSelectable: ["choices__item--selectable"],
|
|
584
|
+
itemDisabled: ["choices__item--disabled"],
|
|
585
|
+
itemChoice: ["choices__item--choice"],
|
|
586
|
+
description: ["choices__description"],
|
|
587
|
+
placeholder: ["choices__placeholder"],
|
|
588
|
+
group: ["choices__group"],
|
|
589
|
+
groupHeading: ["choices__heading"],
|
|
590
|
+
button: ["choices__button"],
|
|
591
|
+
activeState: ["is-active"],
|
|
592
|
+
focusState: ["is-focused"],
|
|
593
|
+
openState: ["is-open"],
|
|
594
|
+
disabledState: ["is-disabled"],
|
|
595
|
+
highlightedState: ["is-highlighted"],
|
|
596
|
+
selectedState: ["is-selected"],
|
|
597
|
+
flippedState: ["is-flipped"],
|
|
598
|
+
loadingState: ["is-loading"],
|
|
599
|
+
invalidState: ["is-invalid"],
|
|
600
|
+
notice: ["choices__notice"],
|
|
601
|
+
addChoice: ["choices__item--selectable", "add-choice"],
|
|
602
|
+
noResults: ["has-no-results"],
|
|
603
|
+
noChoices: ["has-no-choices"]
|
|
604
|
+
}, Oe = {
|
|
605
|
+
items: [],
|
|
606
|
+
choices: [],
|
|
607
|
+
silent: !1,
|
|
608
|
+
renderChoiceLimit: -1,
|
|
609
|
+
maxItemCount: -1,
|
|
610
|
+
closeDropdownOnSelect: "auto",
|
|
611
|
+
singleModeForMultiSelect: !1,
|
|
612
|
+
addChoices: !1,
|
|
613
|
+
addItems: !0,
|
|
614
|
+
addItemFilter: function(i) {
|
|
615
|
+
return !!i && i !== "";
|
|
616
|
+
},
|
|
617
|
+
removeItems: !0,
|
|
618
|
+
removeItemButton: !1,
|
|
619
|
+
removeItemButtonAlignLeft: !1,
|
|
620
|
+
editItems: !1,
|
|
621
|
+
allowHTML: !1,
|
|
622
|
+
allowHtmlUserInput: !1,
|
|
623
|
+
duplicateItemsAllowed: !0,
|
|
624
|
+
delimiter: ",",
|
|
625
|
+
paste: !0,
|
|
626
|
+
searchEnabled: !0,
|
|
627
|
+
searchChoices: !0,
|
|
628
|
+
searchDisabledChoices: !1,
|
|
629
|
+
searchFloor: 1,
|
|
630
|
+
searchResultLimit: 4,
|
|
631
|
+
searchFields: ["label", "value"],
|
|
632
|
+
position: "auto",
|
|
633
|
+
resetScrollPosition: !0,
|
|
634
|
+
shouldSort: !0,
|
|
635
|
+
shouldSortItems: !1,
|
|
636
|
+
sorter: at,
|
|
637
|
+
shadowRoot: null,
|
|
638
|
+
placeholder: !0,
|
|
639
|
+
placeholderValue: null,
|
|
640
|
+
searchPlaceholderValue: null,
|
|
641
|
+
prependValue: null,
|
|
642
|
+
appendValue: null,
|
|
643
|
+
renderSelectedChoices: "auto",
|
|
644
|
+
searchRenderSelectedChoices: !0,
|
|
645
|
+
loadingText: "Loading...",
|
|
646
|
+
noResultsText: "No results found",
|
|
647
|
+
noChoicesText: "No choices to choose from",
|
|
648
|
+
itemSelectText: "Press to select",
|
|
649
|
+
uniqueItemText: "Only unique values can be added",
|
|
650
|
+
customAddItemText: "Only values matching specific conditions can be added",
|
|
651
|
+
addItemText: function(i) {
|
|
652
|
+
return 'Press Enter to add <b>"'.concat(i, '"</b>');
|
|
653
|
+
},
|
|
654
|
+
removeItemIconText: function() {
|
|
655
|
+
return "Remove item";
|
|
656
|
+
},
|
|
657
|
+
removeItemLabelText: function(i, e, t) {
|
|
658
|
+
return "Remove item: ".concat(t ? J(t.label) : i);
|
|
659
|
+
},
|
|
660
|
+
maxItemText: function(i) {
|
|
661
|
+
return "Only ".concat(i, " values can be added");
|
|
662
|
+
},
|
|
663
|
+
valueComparer: function(i, e) {
|
|
664
|
+
return i === e;
|
|
665
|
+
},
|
|
666
|
+
fuseOptions: {
|
|
667
|
+
includeScore: !0
|
|
668
|
+
},
|
|
669
|
+
labelId: "",
|
|
670
|
+
callbackOnInit: null,
|
|
671
|
+
callbackOnCreateTemplates: null,
|
|
672
|
+
classNames: Et,
|
|
673
|
+
appendGroupInSearch: !1
|
|
674
|
+
}, Te = function(i) {
|
|
675
|
+
var e = i.itemEl;
|
|
676
|
+
e && (e.remove(), i.itemEl = void 0);
|
|
677
|
+
};
|
|
678
|
+
function Ct(i, e, t) {
|
|
679
|
+
var s = i, n = !0;
|
|
680
|
+
switch (e.type) {
|
|
681
|
+
case E.ADD_ITEM: {
|
|
682
|
+
e.item.selected = !0;
|
|
683
|
+
var r = e.item.element;
|
|
684
|
+
r && (r.selected = !0, r.setAttribute("selected", "")), s.push(e.item);
|
|
685
|
+
break;
|
|
686
|
+
}
|
|
687
|
+
case E.REMOVE_ITEM: {
|
|
688
|
+
e.item.selected = !1;
|
|
689
|
+
var r = e.item.element;
|
|
690
|
+
if (r) {
|
|
691
|
+
r.selected = !1, r.removeAttribute("selected");
|
|
692
|
+
var o = r.parentElement;
|
|
693
|
+
o && Ve(o) && o.type === H.SelectOne && (o.value = "");
|
|
694
|
+
}
|
|
695
|
+
Te(e.item), s = s.filter(function(c) {
|
|
696
|
+
return c.id !== e.item.id;
|
|
697
|
+
});
|
|
698
|
+
break;
|
|
699
|
+
}
|
|
700
|
+
case E.REMOVE_CHOICE: {
|
|
701
|
+
Te(e.choice), s = s.filter(function(h) {
|
|
702
|
+
return h.id !== e.choice.id;
|
|
703
|
+
});
|
|
704
|
+
break;
|
|
705
|
+
}
|
|
706
|
+
case E.HIGHLIGHT_ITEM: {
|
|
707
|
+
var a = e.highlighted, l = s.find(function(h) {
|
|
708
|
+
return h.id === e.item.id;
|
|
709
|
+
});
|
|
710
|
+
l && l.highlighted !== a && (l.highlighted = a, t && dt(l, a ? t.classNames.highlightedState : t.classNames.selectedState, a ? t.classNames.selectedState : t.classNames.highlightedState));
|
|
711
|
+
break;
|
|
712
|
+
}
|
|
713
|
+
default: {
|
|
714
|
+
n = !1;
|
|
715
|
+
break;
|
|
716
|
+
}
|
|
717
|
+
}
|
|
718
|
+
return { state: s, update: n };
|
|
719
|
+
}
|
|
720
|
+
function St(i, e) {
|
|
721
|
+
var t = i, s = !0;
|
|
722
|
+
switch (e.type) {
|
|
723
|
+
case E.ADD_GROUP: {
|
|
724
|
+
t.push(e.group);
|
|
725
|
+
break;
|
|
726
|
+
}
|
|
727
|
+
case E.CLEAR_CHOICES: {
|
|
728
|
+
t = [];
|
|
729
|
+
break;
|
|
730
|
+
}
|
|
731
|
+
default: {
|
|
732
|
+
s = !1;
|
|
733
|
+
break;
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
return { state: t, update: s };
|
|
737
|
+
}
|
|
738
|
+
function It(i, e, t) {
|
|
739
|
+
var s = i, n = !0;
|
|
740
|
+
switch (e.type) {
|
|
741
|
+
case E.ADD_CHOICE: {
|
|
742
|
+
s.push(e.choice);
|
|
743
|
+
break;
|
|
744
|
+
}
|
|
745
|
+
case E.REMOVE_CHOICE: {
|
|
746
|
+
e.choice.choiceEl = void 0, e.choice.group && (e.choice.group.choices = e.choice.group.choices.filter(function(o) {
|
|
747
|
+
return o.id !== e.choice.id;
|
|
748
|
+
})), s = s.filter(function(o) {
|
|
749
|
+
return o.id !== e.choice.id;
|
|
750
|
+
});
|
|
751
|
+
break;
|
|
752
|
+
}
|
|
753
|
+
case E.ADD_ITEM:
|
|
754
|
+
case E.REMOVE_ITEM: {
|
|
755
|
+
e.item.choiceEl = void 0;
|
|
756
|
+
break;
|
|
757
|
+
}
|
|
758
|
+
case E.FILTER_CHOICES: {
|
|
759
|
+
var r = [];
|
|
760
|
+
e.results.forEach(function(o) {
|
|
761
|
+
r[o.item.id] = o;
|
|
762
|
+
}), s.forEach(function(o) {
|
|
763
|
+
var a = r[o.id];
|
|
764
|
+
a !== void 0 ? (o.score = a.score, o.rank = a.rank, o.active = !0) : (o.score = 0, o.rank = 0, o.active = !1), t && t.appendGroupInSearch && (o.choiceEl = void 0);
|
|
765
|
+
});
|
|
766
|
+
break;
|
|
767
|
+
}
|
|
768
|
+
case E.ACTIVATE_CHOICES: {
|
|
769
|
+
s.forEach(function(o) {
|
|
770
|
+
o.active = e.active, t && t.appendGroupInSearch && (o.choiceEl = void 0);
|
|
771
|
+
});
|
|
772
|
+
break;
|
|
773
|
+
}
|
|
774
|
+
case E.CLEAR_CHOICES: {
|
|
775
|
+
s = [];
|
|
776
|
+
break;
|
|
777
|
+
}
|
|
778
|
+
default: {
|
|
779
|
+
n = !1;
|
|
780
|
+
break;
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
return { state: s, update: n };
|
|
784
|
+
}
|
|
785
|
+
var xe = {
|
|
786
|
+
groups: St,
|
|
787
|
+
items: Ct,
|
|
788
|
+
choices: It
|
|
789
|
+
}, wt = (
|
|
790
|
+
/** @class */
|
|
791
|
+
(function() {
|
|
792
|
+
function i(e) {
|
|
793
|
+
this._state = this.defaultState, this._listeners = [], this._txn = 0, this._context = e;
|
|
794
|
+
}
|
|
795
|
+
return Object.defineProperty(i.prototype, "defaultState", {
|
|
796
|
+
// eslint-disable-next-line class-methods-use-this
|
|
797
|
+
get: function() {
|
|
798
|
+
return {
|
|
799
|
+
groups: [],
|
|
800
|
+
items: [],
|
|
801
|
+
choices: []
|
|
802
|
+
};
|
|
803
|
+
},
|
|
804
|
+
enumerable: !1,
|
|
805
|
+
configurable: !0
|
|
806
|
+
}), i.prototype.changeSet = function(e) {
|
|
807
|
+
return {
|
|
808
|
+
groups: e,
|
|
809
|
+
items: e,
|
|
810
|
+
choices: e
|
|
811
|
+
};
|
|
812
|
+
}, i.prototype.reset = function() {
|
|
813
|
+
this._state = this.defaultState;
|
|
814
|
+
var e = this.changeSet(!0);
|
|
815
|
+
this._txn ? this._changeSet = e : this._listeners.forEach(function(t) {
|
|
816
|
+
return t(e);
|
|
817
|
+
});
|
|
818
|
+
}, i.prototype.subscribe = function(e) {
|
|
819
|
+
return this._listeners.push(e), this;
|
|
820
|
+
}, i.prototype.dispatch = function(e) {
|
|
821
|
+
var t = this, s = this._state, n = !1, r = this._changeSet || this.changeSet(!1);
|
|
822
|
+
Object.keys(xe).forEach(function(o) {
|
|
823
|
+
var a = xe[o](s[o], e, t._context);
|
|
824
|
+
a.update && (n = !0, r[o] = !0, s[o] = a.state);
|
|
825
|
+
}), n && (this._txn ? this._changeSet = r : this._listeners.forEach(function(o) {
|
|
826
|
+
return o(r);
|
|
827
|
+
}));
|
|
828
|
+
}, i.prototype.withTxn = function(e) {
|
|
829
|
+
this._txn++;
|
|
830
|
+
try {
|
|
831
|
+
e();
|
|
832
|
+
} finally {
|
|
833
|
+
if (this._txn = Math.max(0, this._txn - 1), !this._txn) {
|
|
834
|
+
var t = this._changeSet;
|
|
835
|
+
t && (this._changeSet = void 0, this._listeners.forEach(function(s) {
|
|
836
|
+
return s(t);
|
|
837
|
+
}));
|
|
838
|
+
}
|
|
839
|
+
}
|
|
840
|
+
}, Object.defineProperty(i.prototype, "state", {
|
|
841
|
+
/**
|
|
842
|
+
* Get store object
|
|
843
|
+
*/
|
|
844
|
+
get: function() {
|
|
845
|
+
return this._state;
|
|
846
|
+
},
|
|
847
|
+
enumerable: !1,
|
|
848
|
+
configurable: !0
|
|
849
|
+
}), Object.defineProperty(i.prototype, "items", {
|
|
850
|
+
/**
|
|
851
|
+
* Get items from store
|
|
852
|
+
*/
|
|
853
|
+
get: function() {
|
|
854
|
+
return this.state.items;
|
|
855
|
+
},
|
|
856
|
+
enumerable: !1,
|
|
857
|
+
configurable: !0
|
|
858
|
+
}), Object.defineProperty(i.prototype, "highlightedActiveItems", {
|
|
859
|
+
/**
|
|
860
|
+
* Get highlighted items from store
|
|
861
|
+
*/
|
|
862
|
+
get: function() {
|
|
863
|
+
return this.items.filter(function(e) {
|
|
864
|
+
return e.active && e.highlighted;
|
|
865
|
+
});
|
|
866
|
+
},
|
|
867
|
+
enumerable: !1,
|
|
868
|
+
configurable: !0
|
|
869
|
+
}), Object.defineProperty(i.prototype, "choices", {
|
|
870
|
+
/**
|
|
871
|
+
* Get choices from store
|
|
872
|
+
*/
|
|
873
|
+
get: function() {
|
|
874
|
+
return this.state.choices;
|
|
875
|
+
},
|
|
876
|
+
enumerable: !1,
|
|
877
|
+
configurable: !0
|
|
878
|
+
}), Object.defineProperty(i.prototype, "activeChoices", {
|
|
879
|
+
/**
|
|
880
|
+
* Get active choices from store
|
|
881
|
+
*/
|
|
882
|
+
get: function() {
|
|
883
|
+
return this.choices.filter(function(e) {
|
|
884
|
+
return e.active;
|
|
885
|
+
});
|
|
886
|
+
},
|
|
887
|
+
enumerable: !1,
|
|
888
|
+
configurable: !0
|
|
889
|
+
}), Object.defineProperty(i.prototype, "searchableChoices", {
|
|
890
|
+
/**
|
|
891
|
+
* Get choices that can be searched (excluding placeholders or disabled choices)
|
|
892
|
+
*/
|
|
893
|
+
get: function() {
|
|
894
|
+
var e = this._context;
|
|
895
|
+
return this.choices.filter(function(t) {
|
|
896
|
+
return !t.placeholder && (e.searchDisabledChoices || !t.disabled);
|
|
897
|
+
});
|
|
898
|
+
},
|
|
899
|
+
enumerable: !1,
|
|
900
|
+
configurable: !0
|
|
901
|
+
}), Object.defineProperty(i.prototype, "groups", {
|
|
902
|
+
/**
|
|
903
|
+
* Get groups from store
|
|
904
|
+
*/
|
|
905
|
+
get: function() {
|
|
906
|
+
return this.state.groups;
|
|
907
|
+
},
|
|
908
|
+
enumerable: !1,
|
|
909
|
+
configurable: !0
|
|
910
|
+
}), Object.defineProperty(i.prototype, "activeGroups", {
|
|
911
|
+
/**
|
|
912
|
+
* Get active groups from store
|
|
913
|
+
*/
|
|
914
|
+
get: function() {
|
|
915
|
+
var e = this;
|
|
916
|
+
return this.state.groups.filter(function(t) {
|
|
917
|
+
var s = t.active && !t.disabled, n = e.state.choices.some(function(r) {
|
|
918
|
+
return r.active && !r.disabled;
|
|
919
|
+
});
|
|
920
|
+
return s && n;
|
|
921
|
+
}, []);
|
|
922
|
+
},
|
|
923
|
+
enumerable: !1,
|
|
924
|
+
configurable: !0
|
|
925
|
+
}), i.prototype.inTxn = function() {
|
|
926
|
+
return this._txn > 0;
|
|
927
|
+
}, i.prototype.getChoiceById = function(e) {
|
|
928
|
+
return this.activeChoices.find(function(t) {
|
|
929
|
+
return t.id === e;
|
|
930
|
+
});
|
|
931
|
+
}, i.prototype.getGroupById = function(e) {
|
|
932
|
+
return this.groups.find(function(t) {
|
|
933
|
+
return t.id === e;
|
|
934
|
+
});
|
|
935
|
+
}, i;
|
|
936
|
+
})()
|
|
937
|
+
), S = {
|
|
938
|
+
noChoices: "no-choices",
|
|
939
|
+
noResults: "no-results",
|
|
940
|
+
addChoice: "add-choice",
|
|
941
|
+
generic: ""
|
|
942
|
+
};
|
|
943
|
+
function At(i, e, t) {
|
|
944
|
+
return (e = Tt(e)) in i ? Object.defineProperty(i, e, {
|
|
945
|
+
value: t,
|
|
946
|
+
enumerable: !0,
|
|
947
|
+
configurable: !0,
|
|
948
|
+
writable: !0
|
|
949
|
+
}) : i[e] = t, i;
|
|
950
|
+
}
|
|
951
|
+
function Le(i, e) {
|
|
952
|
+
var t = Object.keys(i);
|
|
953
|
+
if (Object.getOwnPropertySymbols) {
|
|
954
|
+
var s = Object.getOwnPropertySymbols(i);
|
|
955
|
+
e && (s = s.filter(function(n) {
|
|
956
|
+
return Object.getOwnPropertyDescriptor(i, n).enumerable;
|
|
957
|
+
})), t.push.apply(t, s);
|
|
958
|
+
}
|
|
959
|
+
return t;
|
|
960
|
+
}
|
|
961
|
+
function U(i) {
|
|
962
|
+
for (var e = 1; e < arguments.length; e++) {
|
|
963
|
+
var t = arguments[e] != null ? arguments[e] : {};
|
|
964
|
+
e % 2 ? Le(Object(t), !0).forEach(function(s) {
|
|
965
|
+
At(i, s, t[s]);
|
|
966
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(i, Object.getOwnPropertyDescriptors(t)) : Le(Object(t)).forEach(function(s) {
|
|
967
|
+
Object.defineProperty(i, s, Object.getOwnPropertyDescriptor(t, s));
|
|
968
|
+
});
|
|
969
|
+
}
|
|
970
|
+
return i;
|
|
971
|
+
}
|
|
972
|
+
function Ot(i, e) {
|
|
973
|
+
if (typeof i != "object" || !i) return i;
|
|
974
|
+
var t = i[Symbol.toPrimitive];
|
|
975
|
+
if (t !== void 0) {
|
|
976
|
+
var s = t.call(i, e);
|
|
977
|
+
if (typeof s != "object") return s;
|
|
978
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
979
|
+
}
|
|
980
|
+
return (e === "string" ? String : Number)(i);
|
|
981
|
+
}
|
|
982
|
+
function Tt(i) {
|
|
983
|
+
var e = Ot(i, "string");
|
|
984
|
+
return typeof e == "symbol" ? e : e + "";
|
|
985
|
+
}
|
|
986
|
+
function k(i) {
|
|
987
|
+
return Array.isArray ? Array.isArray(i) : We(i) === "[object Array]";
|
|
988
|
+
}
|
|
989
|
+
function xt(i) {
|
|
990
|
+
if (typeof i == "string")
|
|
991
|
+
return i;
|
|
992
|
+
let e = i + "";
|
|
993
|
+
return e == "0" && 1 / i == -1 / 0 ? "-0" : e;
|
|
994
|
+
}
|
|
995
|
+
function Lt(i) {
|
|
996
|
+
return i == null ? "" : xt(i);
|
|
997
|
+
}
|
|
998
|
+
function P(i) {
|
|
999
|
+
return typeof i == "string";
|
|
1000
|
+
}
|
|
1001
|
+
function Be(i) {
|
|
1002
|
+
return typeof i == "number";
|
|
1003
|
+
}
|
|
1004
|
+
function Mt(i) {
|
|
1005
|
+
return i === !0 || i === !1 || Dt(i) && We(i) == "[object Boolean]";
|
|
1006
|
+
}
|
|
1007
|
+
function Ge(i) {
|
|
1008
|
+
return typeof i == "object";
|
|
1009
|
+
}
|
|
1010
|
+
function Dt(i) {
|
|
1011
|
+
return Ge(i) && i !== null;
|
|
1012
|
+
}
|
|
1013
|
+
function O(i) {
|
|
1014
|
+
return i != null;
|
|
1015
|
+
}
|
|
1016
|
+
function re(i) {
|
|
1017
|
+
return !i.trim().length;
|
|
1018
|
+
}
|
|
1019
|
+
function We(i) {
|
|
1020
|
+
return i == null ? i === void 0 ? "[object Undefined]" : "[object Null]" : Object.prototype.toString.call(i);
|
|
1021
|
+
}
|
|
1022
|
+
const Nt = "Incorrect 'index' type", Pt = (i) => `Invalid value for key ${i}`, Ft = (i) => `Pattern length exceeds max of ${i}.`, kt = (i) => `Missing ${i} property in key`, Rt = (i) => `Property 'weight' in key '${i}' must be a positive integer`, Me = Object.prototype.hasOwnProperty;
|
|
1023
|
+
class Kt {
|
|
1024
|
+
constructor(e) {
|
|
1025
|
+
this._keys = [], this._keyMap = {};
|
|
1026
|
+
let t = 0;
|
|
1027
|
+
e.forEach((s) => {
|
|
1028
|
+
let n = Ue(s);
|
|
1029
|
+
this._keys.push(n), this._keyMap[n.id] = n, t += n.weight;
|
|
1030
|
+
}), this._keys.forEach((s) => {
|
|
1031
|
+
s.weight /= t;
|
|
1032
|
+
});
|
|
1033
|
+
}
|
|
1034
|
+
get(e) {
|
|
1035
|
+
return this._keyMap[e];
|
|
1036
|
+
}
|
|
1037
|
+
keys() {
|
|
1038
|
+
return this._keys;
|
|
1039
|
+
}
|
|
1040
|
+
toJSON() {
|
|
1041
|
+
return JSON.stringify(this._keys);
|
|
1042
|
+
}
|
|
1043
|
+
}
|
|
1044
|
+
function Ue(i) {
|
|
1045
|
+
let e = null, t = null, s = null, n = 1, r = null;
|
|
1046
|
+
if (P(i) || k(i))
|
|
1047
|
+
s = i, e = De(i), t = ce(i);
|
|
1048
|
+
else {
|
|
1049
|
+
if (!Me.call(i, "name"))
|
|
1050
|
+
throw new Error(kt("name"));
|
|
1051
|
+
const o = i.name;
|
|
1052
|
+
if (s = o, Me.call(i, "weight") && (n = i.weight, n <= 0))
|
|
1053
|
+
throw new Error(Rt(o));
|
|
1054
|
+
e = De(o), t = ce(o), r = i.getFn;
|
|
1055
|
+
}
|
|
1056
|
+
return {
|
|
1057
|
+
path: e,
|
|
1058
|
+
id: t,
|
|
1059
|
+
weight: n,
|
|
1060
|
+
src: s,
|
|
1061
|
+
getFn: r
|
|
1062
|
+
};
|
|
1063
|
+
}
|
|
1064
|
+
function De(i) {
|
|
1065
|
+
return k(i) ? i : i.split(".");
|
|
1066
|
+
}
|
|
1067
|
+
function ce(i) {
|
|
1068
|
+
return k(i) ? i.join(".") : i;
|
|
1069
|
+
}
|
|
1070
|
+
function Ht(i, e) {
|
|
1071
|
+
let t = [], s = !1;
|
|
1072
|
+
const n = (r, o, a) => {
|
|
1073
|
+
if (O(r))
|
|
1074
|
+
if (!o[a])
|
|
1075
|
+
t.push(r);
|
|
1076
|
+
else {
|
|
1077
|
+
let l = o[a];
|
|
1078
|
+
const h = r[l];
|
|
1079
|
+
if (!O(h))
|
|
1080
|
+
return;
|
|
1081
|
+
if (a === o.length - 1 && (P(h) || Be(h) || Mt(h)))
|
|
1082
|
+
t.push(Lt(h));
|
|
1083
|
+
else if (k(h)) {
|
|
1084
|
+
s = !0;
|
|
1085
|
+
for (let c = 0, u = h.length; c < u; c += 1)
|
|
1086
|
+
n(h[c], o, a + 1);
|
|
1087
|
+
} else o.length && n(h, o, a + 1);
|
|
1088
|
+
}
|
|
1089
|
+
};
|
|
1090
|
+
return n(i, P(e) ? e.split(".") : e, 0), s ? t : t[0];
|
|
1091
|
+
}
|
|
1092
|
+
const jt = {
|
|
1093
|
+
// Whether the matches should be included in the result set. When `true`, each record in the result
|
|
1094
|
+
// set will include the indices of the matched characters.
|
|
1095
|
+
// These can consequently be used for highlighting purposes.
|
|
1096
|
+
includeMatches: !1,
|
|
1097
|
+
// When `true`, the matching function will continue to the end of a search pattern even if
|
|
1098
|
+
// a perfect match has already been located in the string.
|
|
1099
|
+
findAllMatches: !1,
|
|
1100
|
+
// Minimum number of characters that must be matched before a result is considered a match
|
|
1101
|
+
minMatchCharLength: 1
|
|
1102
|
+
}, Vt = {
|
|
1103
|
+
// When `true`, the algorithm continues searching to the end of the input even if a perfect
|
|
1104
|
+
// match is found before the end of the same input.
|
|
1105
|
+
isCaseSensitive: !1,
|
|
1106
|
+
// When true, the matching function will continue to the end of a search pattern even if
|
|
1107
|
+
includeScore: !1,
|
|
1108
|
+
// List of properties that will be searched. This also supports nested properties.
|
|
1109
|
+
keys: [],
|
|
1110
|
+
// Whether to sort the result list, by score
|
|
1111
|
+
shouldSort: !0,
|
|
1112
|
+
// Default sort function: sort by ascending score, ascending index
|
|
1113
|
+
sortFn: (i, e) => i.score === e.score ? i.idx < e.idx ? -1 : 1 : i.score < e.score ? -1 : 1
|
|
1114
|
+
}, Bt = {
|
|
1115
|
+
// Approximately where in the text is the pattern expected to be found?
|
|
1116
|
+
location: 0,
|
|
1117
|
+
// At what point does the match algorithm give up. A threshold of '0.0' requires a perfect match
|
|
1118
|
+
// (of both letters and location), a threshold of '1.0' would match anything.
|
|
1119
|
+
threshold: 0.6,
|
|
1120
|
+
// Determines how close the match must be to the fuzzy location (specified above).
|
|
1121
|
+
// An exact letter match which is 'distance' characters away from the fuzzy location
|
|
1122
|
+
// would score as a complete mismatch. A distance of '0' requires the match be at
|
|
1123
|
+
// the exact location specified, a threshold of '1000' would require a perfect match
|
|
1124
|
+
// to be within 800 characters of the fuzzy location to be found using a 0.8 threshold.
|
|
1125
|
+
distance: 100
|
|
1126
|
+
}, Gt = {
|
|
1127
|
+
// When `true`, it enables the use of unix-like search commands
|
|
1128
|
+
useExtendedSearch: !1,
|
|
1129
|
+
// The get function to use when fetching an object's properties.
|
|
1130
|
+
// The default will search nested paths *ie foo.bar.baz*
|
|
1131
|
+
getFn: Ht,
|
|
1132
|
+
// When `true`, search will ignore `location` and `distance`, so it won't matter
|
|
1133
|
+
// where in the string the pattern appears.
|
|
1134
|
+
// More info: https://fusejs.io/concepts/scoring-theory.html#fuzziness-score
|
|
1135
|
+
ignoreLocation: !1,
|
|
1136
|
+
// When `true`, the calculation for the relevance score (used for sorting) will
|
|
1137
|
+
// ignore the field-length norm.
|
|
1138
|
+
// More info: https://fusejs.io/concepts/scoring-theory.html#field-length-norm
|
|
1139
|
+
ignoreFieldNorm: !1,
|
|
1140
|
+
// The weight to determine how much field length norm effects scoring.
|
|
1141
|
+
fieldNormWeight: 1
|
|
1142
|
+
};
|
|
1143
|
+
var v = U(U(U(U({}, Vt), jt), Bt), Gt);
|
|
1144
|
+
const Wt = /[^ ]+/g;
|
|
1145
|
+
function Ut(i = 1, e = 3) {
|
|
1146
|
+
const t = /* @__PURE__ */ new Map(), s = Math.pow(10, e);
|
|
1147
|
+
return {
|
|
1148
|
+
get(n) {
|
|
1149
|
+
const r = n.match(Wt).length;
|
|
1150
|
+
if (t.has(r))
|
|
1151
|
+
return t.get(r);
|
|
1152
|
+
const o = 1 / Math.pow(r, 0.5 * i), a = parseFloat(Math.round(o * s) / s);
|
|
1153
|
+
return t.set(r, a), a;
|
|
1154
|
+
},
|
|
1155
|
+
clear() {
|
|
1156
|
+
t.clear();
|
|
1157
|
+
}
|
|
1158
|
+
};
|
|
1159
|
+
}
|
|
1160
|
+
class ve {
|
|
1161
|
+
constructor({
|
|
1162
|
+
getFn: e = v.getFn,
|
|
1163
|
+
fieldNormWeight: t = v.fieldNormWeight
|
|
1164
|
+
} = {}) {
|
|
1165
|
+
this.norm = Ut(t, 3), this.getFn = e, this.isCreated = !1, this.setIndexRecords();
|
|
1166
|
+
}
|
|
1167
|
+
setSources(e = []) {
|
|
1168
|
+
this.docs = e;
|
|
1169
|
+
}
|
|
1170
|
+
setIndexRecords(e = []) {
|
|
1171
|
+
this.records = e;
|
|
1172
|
+
}
|
|
1173
|
+
setKeys(e = []) {
|
|
1174
|
+
this.keys = e, this._keysMap = {}, e.forEach((t, s) => {
|
|
1175
|
+
this._keysMap[t.id] = s;
|
|
1176
|
+
});
|
|
1177
|
+
}
|
|
1178
|
+
create() {
|
|
1179
|
+
this.isCreated || !this.docs.length || (this.isCreated = !0, P(this.docs[0]) ? this.docs.forEach((e, t) => {
|
|
1180
|
+
this._addString(e, t);
|
|
1181
|
+
}) : this.docs.forEach((e, t) => {
|
|
1182
|
+
this._addObject(e, t);
|
|
1183
|
+
}), this.norm.clear());
|
|
1184
|
+
}
|
|
1185
|
+
// Adds a doc to the end of the index
|
|
1186
|
+
add(e) {
|
|
1187
|
+
const t = this.size();
|
|
1188
|
+
P(e) ? this._addString(e, t) : this._addObject(e, t);
|
|
1189
|
+
}
|
|
1190
|
+
// Removes the doc at the specified index of the index
|
|
1191
|
+
removeAt(e) {
|
|
1192
|
+
this.records.splice(e, 1);
|
|
1193
|
+
for (let t = e, s = this.size(); t < s; t += 1)
|
|
1194
|
+
this.records[t].i -= 1;
|
|
1195
|
+
}
|
|
1196
|
+
getValueForItemAtKeyId(e, t) {
|
|
1197
|
+
return e[this._keysMap[t]];
|
|
1198
|
+
}
|
|
1199
|
+
size() {
|
|
1200
|
+
return this.records.length;
|
|
1201
|
+
}
|
|
1202
|
+
_addString(e, t) {
|
|
1203
|
+
if (!O(e) || re(e))
|
|
1204
|
+
return;
|
|
1205
|
+
let s = {
|
|
1206
|
+
v: e,
|
|
1207
|
+
i: t,
|
|
1208
|
+
n: this.norm.get(e)
|
|
1209
|
+
};
|
|
1210
|
+
this.records.push(s);
|
|
1211
|
+
}
|
|
1212
|
+
_addObject(e, t) {
|
|
1213
|
+
let s = {
|
|
1214
|
+
i: t,
|
|
1215
|
+
$: {}
|
|
1216
|
+
};
|
|
1217
|
+
this.keys.forEach((n, r) => {
|
|
1218
|
+
let o = n.getFn ? n.getFn(e) : this.getFn(e, n.path);
|
|
1219
|
+
if (O(o)) {
|
|
1220
|
+
if (k(o)) {
|
|
1221
|
+
let a = [];
|
|
1222
|
+
const l = [{
|
|
1223
|
+
nestedArrIndex: -1,
|
|
1224
|
+
value: o
|
|
1225
|
+
}];
|
|
1226
|
+
for (; l.length; ) {
|
|
1227
|
+
const {
|
|
1228
|
+
nestedArrIndex: h,
|
|
1229
|
+
value: c
|
|
1230
|
+
} = l.pop();
|
|
1231
|
+
if (O(c))
|
|
1232
|
+
if (P(c) && !re(c)) {
|
|
1233
|
+
let u = {
|
|
1234
|
+
v: c,
|
|
1235
|
+
i: h,
|
|
1236
|
+
n: this.norm.get(c)
|
|
1237
|
+
};
|
|
1238
|
+
a.push(u);
|
|
1239
|
+
} else k(c) && c.forEach((u, d) => {
|
|
1240
|
+
l.push({
|
|
1241
|
+
nestedArrIndex: d,
|
|
1242
|
+
value: u
|
|
1243
|
+
});
|
|
1244
|
+
});
|
|
1245
|
+
}
|
|
1246
|
+
s.$[r] = a;
|
|
1247
|
+
} else if (P(o) && !re(o)) {
|
|
1248
|
+
let a = {
|
|
1249
|
+
v: o,
|
|
1250
|
+
n: this.norm.get(o)
|
|
1251
|
+
};
|
|
1252
|
+
s.$[r] = a;
|
|
1253
|
+
}
|
|
1254
|
+
}
|
|
1255
|
+
}), this.records.push(s);
|
|
1256
|
+
}
|
|
1257
|
+
toJSON() {
|
|
1258
|
+
return {
|
|
1259
|
+
keys: this.keys,
|
|
1260
|
+
records: this.records
|
|
1261
|
+
};
|
|
1262
|
+
}
|
|
1263
|
+
}
|
|
1264
|
+
function $e(i, e, {
|
|
1265
|
+
getFn: t = v.getFn,
|
|
1266
|
+
fieldNormWeight: s = v.fieldNormWeight
|
|
1267
|
+
} = {}) {
|
|
1268
|
+
const n = new ve({
|
|
1269
|
+
getFn: t,
|
|
1270
|
+
fieldNormWeight: s
|
|
1271
|
+
});
|
|
1272
|
+
return n.setKeys(i.map(Ue)), n.setSources(e), n.create(), n;
|
|
1273
|
+
}
|
|
1274
|
+
function $t(i, {
|
|
1275
|
+
getFn: e = v.getFn,
|
|
1276
|
+
fieldNormWeight: t = v.fieldNormWeight
|
|
1277
|
+
} = {}) {
|
|
1278
|
+
const {
|
|
1279
|
+
keys: s,
|
|
1280
|
+
records: n
|
|
1281
|
+
} = i, r = new ve({
|
|
1282
|
+
getFn: e,
|
|
1283
|
+
fieldNormWeight: t
|
|
1284
|
+
});
|
|
1285
|
+
return r.setKeys(s), r.setIndexRecords(n), r;
|
|
1286
|
+
}
|
|
1287
|
+
function ee(i, {
|
|
1288
|
+
errors: e = 0,
|
|
1289
|
+
currentLocation: t = 0,
|
|
1290
|
+
expectedLocation: s = 0,
|
|
1291
|
+
distance: n = v.distance,
|
|
1292
|
+
ignoreLocation: r = v.ignoreLocation
|
|
1293
|
+
} = {}) {
|
|
1294
|
+
const o = e / i.length;
|
|
1295
|
+
if (r)
|
|
1296
|
+
return o;
|
|
1297
|
+
const a = Math.abs(s - t);
|
|
1298
|
+
return n ? o + a / n : a ? 1 : o;
|
|
1299
|
+
}
|
|
1300
|
+
function Yt(i = [], e = v.minMatchCharLength) {
|
|
1301
|
+
let t = [], s = -1, n = -1, r = 0;
|
|
1302
|
+
for (let o = i.length; r < o; r += 1) {
|
|
1303
|
+
let a = i[r];
|
|
1304
|
+
a && s === -1 ? s = r : !a && s !== -1 && (n = r - 1, n - s + 1 >= e && t.push([s, n]), s = -1);
|
|
1305
|
+
}
|
|
1306
|
+
return i[r - 1] && r - s >= e && t.push([s, r - 1]), t;
|
|
1307
|
+
}
|
|
1308
|
+
const V = 32;
|
|
1309
|
+
function qt(i, e, t, {
|
|
1310
|
+
location: s = v.location,
|
|
1311
|
+
distance: n = v.distance,
|
|
1312
|
+
threshold: r = v.threshold,
|
|
1313
|
+
findAllMatches: o = v.findAllMatches,
|
|
1314
|
+
minMatchCharLength: a = v.minMatchCharLength,
|
|
1315
|
+
includeMatches: l = v.includeMatches,
|
|
1316
|
+
ignoreLocation: h = v.ignoreLocation
|
|
1317
|
+
} = {}) {
|
|
1318
|
+
if (e.length > V)
|
|
1319
|
+
throw new Error(Ft(V));
|
|
1320
|
+
const c = e.length, u = i.length, d = Math.max(0, Math.min(s, u));
|
|
1321
|
+
let m = r, f = d;
|
|
1322
|
+
const p = a > 1 || l, g = p ? Array(u) : [];
|
|
1323
|
+
let y;
|
|
1324
|
+
for (; (y = i.indexOf(e, f)) > -1; ) {
|
|
1325
|
+
let T = ee(e, {
|
|
1326
|
+
currentLocation: y,
|
|
1327
|
+
expectedLocation: d,
|
|
1328
|
+
distance: n,
|
|
1329
|
+
ignoreLocation: h
|
|
1330
|
+
});
|
|
1331
|
+
if (m = Math.min(T, m), f = y + c, p) {
|
|
1332
|
+
let R = 0;
|
|
1333
|
+
for (; R < c; )
|
|
1334
|
+
g[y + R] = 1, R += 1;
|
|
1335
|
+
}
|
|
1336
|
+
}
|
|
1337
|
+
f = -1;
|
|
1338
|
+
let b = [], C = 1, B = c + u;
|
|
1339
|
+
const Y = 1 << c - 1;
|
|
1340
|
+
for (let T = 0; T < c; T += 1) {
|
|
1341
|
+
let R = 0, K = B;
|
|
1342
|
+
for (; R < K; )
|
|
1343
|
+
ee(e, {
|
|
1344
|
+
errors: T,
|
|
1345
|
+
currentLocation: d + K,
|
|
1346
|
+
expectedLocation: d,
|
|
1347
|
+
distance: n,
|
|
1348
|
+
ignoreLocation: h
|
|
1349
|
+
}) <= m ? R = K : B = K, K = Math.floor((B - R) / 2 + R);
|
|
1350
|
+
B = K;
|
|
1351
|
+
let _e = Math.max(1, d - K + 1), ne = o ? u : Math.min(d + K, u) + c, G = Array(ne + 2);
|
|
1352
|
+
G[ne + 1] = (1 << T) - 1;
|
|
1353
|
+
for (let x = ne; x >= _e; x -= 1) {
|
|
1354
|
+
let Q = x - 1, ge = t[i.charAt(Q)];
|
|
1355
|
+
if (p && (g[Q] = +!!ge), G[x] = (G[x + 1] << 1 | 1) & ge, T && (G[x] |= (b[x + 1] | b[x]) << 1 | 1 | b[x + 1]), G[x] & Y && (C = ee(e, {
|
|
1356
|
+
errors: T,
|
|
1357
|
+
currentLocation: Q,
|
|
1358
|
+
expectedLocation: d,
|
|
1359
|
+
distance: n,
|
|
1360
|
+
ignoreLocation: h
|
|
1361
|
+
}), C <= m)) {
|
|
1362
|
+
if (m = C, f = Q, f <= d)
|
|
1363
|
+
break;
|
|
1364
|
+
_e = Math.max(1, 2 * d - f);
|
|
1365
|
+
}
|
|
1366
|
+
}
|
|
1367
|
+
if (ee(e, {
|
|
1368
|
+
errors: T + 1,
|
|
1369
|
+
currentLocation: d,
|
|
1370
|
+
expectedLocation: d,
|
|
1371
|
+
distance: n,
|
|
1372
|
+
ignoreLocation: h
|
|
1373
|
+
}) > m)
|
|
1374
|
+
break;
|
|
1375
|
+
b = G;
|
|
1376
|
+
}
|
|
1377
|
+
const se = {
|
|
1378
|
+
isMatch: f >= 0,
|
|
1379
|
+
// Count exact matches (those with a score of 0) to be "almost" exact
|
|
1380
|
+
score: Math.max(1e-3, C)
|
|
1381
|
+
};
|
|
1382
|
+
if (p) {
|
|
1383
|
+
const T = Yt(g, a);
|
|
1384
|
+
T.length ? l && (se.indices = T) : se.isMatch = !1;
|
|
1385
|
+
}
|
|
1386
|
+
return se;
|
|
1387
|
+
}
|
|
1388
|
+
function zt(i) {
|
|
1389
|
+
let e = {};
|
|
1390
|
+
for (let t = 0, s = i.length; t < s; t += 1) {
|
|
1391
|
+
const n = i.charAt(t);
|
|
1392
|
+
e[n] = (e[n] || 0) | 1 << s - t - 1;
|
|
1393
|
+
}
|
|
1394
|
+
return e;
|
|
1395
|
+
}
|
|
1396
|
+
class Ye {
|
|
1397
|
+
constructor(e, {
|
|
1398
|
+
location: t = v.location,
|
|
1399
|
+
threshold: s = v.threshold,
|
|
1400
|
+
distance: n = v.distance,
|
|
1401
|
+
includeMatches: r = v.includeMatches,
|
|
1402
|
+
findAllMatches: o = v.findAllMatches,
|
|
1403
|
+
minMatchCharLength: a = v.minMatchCharLength,
|
|
1404
|
+
isCaseSensitive: l = v.isCaseSensitive,
|
|
1405
|
+
ignoreLocation: h = v.ignoreLocation
|
|
1406
|
+
} = {}) {
|
|
1407
|
+
if (this.options = {
|
|
1408
|
+
location: t,
|
|
1409
|
+
threshold: s,
|
|
1410
|
+
distance: n,
|
|
1411
|
+
includeMatches: r,
|
|
1412
|
+
findAllMatches: o,
|
|
1413
|
+
minMatchCharLength: a,
|
|
1414
|
+
isCaseSensitive: l,
|
|
1415
|
+
ignoreLocation: h
|
|
1416
|
+
}, this.pattern = l ? e : e.toLowerCase(), this.chunks = [], !this.pattern.length)
|
|
1417
|
+
return;
|
|
1418
|
+
const c = (d, m) => {
|
|
1419
|
+
this.chunks.push({
|
|
1420
|
+
pattern: d,
|
|
1421
|
+
alphabet: zt(d),
|
|
1422
|
+
startIndex: m
|
|
1423
|
+
});
|
|
1424
|
+
}, u = this.pattern.length;
|
|
1425
|
+
if (u > V) {
|
|
1426
|
+
let d = 0;
|
|
1427
|
+
const m = u % V, f = u - m;
|
|
1428
|
+
for (; d < f; )
|
|
1429
|
+
c(this.pattern.substr(d, V), d), d += V;
|
|
1430
|
+
if (m) {
|
|
1431
|
+
const p = u - V;
|
|
1432
|
+
c(this.pattern.substr(p), p);
|
|
1433
|
+
}
|
|
1434
|
+
} else
|
|
1435
|
+
c(this.pattern, 0);
|
|
1436
|
+
}
|
|
1437
|
+
searchIn(e) {
|
|
1438
|
+
const {
|
|
1439
|
+
isCaseSensitive: t,
|
|
1440
|
+
includeMatches: s
|
|
1441
|
+
} = this.options;
|
|
1442
|
+
if (t || (e = e.toLowerCase()), this.pattern === e) {
|
|
1443
|
+
let f = {
|
|
1444
|
+
isMatch: !0,
|
|
1445
|
+
score: 0
|
|
1446
|
+
};
|
|
1447
|
+
return s && (f.indices = [[0, e.length - 1]]), f;
|
|
1448
|
+
}
|
|
1449
|
+
const {
|
|
1450
|
+
location: n,
|
|
1451
|
+
distance: r,
|
|
1452
|
+
threshold: o,
|
|
1453
|
+
findAllMatches: a,
|
|
1454
|
+
minMatchCharLength: l,
|
|
1455
|
+
ignoreLocation: h
|
|
1456
|
+
} = this.options;
|
|
1457
|
+
let c = [], u = 0, d = !1;
|
|
1458
|
+
this.chunks.forEach(({
|
|
1459
|
+
pattern: f,
|
|
1460
|
+
alphabet: p,
|
|
1461
|
+
startIndex: g
|
|
1462
|
+
}) => {
|
|
1463
|
+
const {
|
|
1464
|
+
isMatch: y,
|
|
1465
|
+
score: b,
|
|
1466
|
+
indices: C
|
|
1467
|
+
} = qt(e, f, p, {
|
|
1468
|
+
location: n + g,
|
|
1469
|
+
distance: r,
|
|
1470
|
+
threshold: o,
|
|
1471
|
+
findAllMatches: a,
|
|
1472
|
+
minMatchCharLength: l,
|
|
1473
|
+
includeMatches: s,
|
|
1474
|
+
ignoreLocation: h
|
|
1475
|
+
});
|
|
1476
|
+
y && (d = !0), u += b, y && C && (c = [...c, ...C]);
|
|
1477
|
+
});
|
|
1478
|
+
let m = {
|
|
1479
|
+
isMatch: d,
|
|
1480
|
+
score: d ? u / this.chunks.length : 1
|
|
1481
|
+
};
|
|
1482
|
+
return d && s && (m.indices = c), m;
|
|
1483
|
+
}
|
|
1484
|
+
}
|
|
1485
|
+
class j {
|
|
1486
|
+
constructor(e) {
|
|
1487
|
+
this.pattern = e;
|
|
1488
|
+
}
|
|
1489
|
+
static isMultiMatch(e) {
|
|
1490
|
+
return Ne(e, this.multiRegex);
|
|
1491
|
+
}
|
|
1492
|
+
static isSingleMatch(e) {
|
|
1493
|
+
return Ne(e, this.singleRegex);
|
|
1494
|
+
}
|
|
1495
|
+
search() {
|
|
1496
|
+
}
|
|
1497
|
+
}
|
|
1498
|
+
function Ne(i, e) {
|
|
1499
|
+
const t = i.match(e);
|
|
1500
|
+
return t ? t[1] : null;
|
|
1501
|
+
}
|
|
1502
|
+
class Xt extends j {
|
|
1503
|
+
constructor(e) {
|
|
1504
|
+
super(e);
|
|
1505
|
+
}
|
|
1506
|
+
static get type() {
|
|
1507
|
+
return "exact";
|
|
1508
|
+
}
|
|
1509
|
+
static get multiRegex() {
|
|
1510
|
+
return /^="(.*)"$/;
|
|
1511
|
+
}
|
|
1512
|
+
static get singleRegex() {
|
|
1513
|
+
return /^=(.*)$/;
|
|
1514
|
+
}
|
|
1515
|
+
search(e) {
|
|
1516
|
+
const t = e === this.pattern;
|
|
1517
|
+
return {
|
|
1518
|
+
isMatch: t,
|
|
1519
|
+
score: t ? 0 : 1,
|
|
1520
|
+
indices: [0, this.pattern.length - 1]
|
|
1521
|
+
};
|
|
1522
|
+
}
|
|
1523
|
+
}
|
|
1524
|
+
class Jt extends j {
|
|
1525
|
+
constructor(e) {
|
|
1526
|
+
super(e);
|
|
1527
|
+
}
|
|
1528
|
+
static get type() {
|
|
1529
|
+
return "inverse-exact";
|
|
1530
|
+
}
|
|
1531
|
+
static get multiRegex() {
|
|
1532
|
+
return /^!"(.*)"$/;
|
|
1533
|
+
}
|
|
1534
|
+
static get singleRegex() {
|
|
1535
|
+
return /^!(.*)$/;
|
|
1536
|
+
}
|
|
1537
|
+
search(e) {
|
|
1538
|
+
const s = e.indexOf(this.pattern) === -1;
|
|
1539
|
+
return {
|
|
1540
|
+
isMatch: s,
|
|
1541
|
+
score: s ? 0 : 1,
|
|
1542
|
+
indices: [0, e.length - 1]
|
|
1543
|
+
};
|
|
1544
|
+
}
|
|
1545
|
+
}
|
|
1546
|
+
class Qt extends j {
|
|
1547
|
+
constructor(e) {
|
|
1548
|
+
super(e);
|
|
1549
|
+
}
|
|
1550
|
+
static get type() {
|
|
1551
|
+
return "prefix-exact";
|
|
1552
|
+
}
|
|
1553
|
+
static get multiRegex() {
|
|
1554
|
+
return /^\^"(.*)"$/;
|
|
1555
|
+
}
|
|
1556
|
+
static get singleRegex() {
|
|
1557
|
+
return /^\^(.*)$/;
|
|
1558
|
+
}
|
|
1559
|
+
search(e) {
|
|
1560
|
+
const t = e.startsWith(this.pattern);
|
|
1561
|
+
return {
|
|
1562
|
+
isMatch: t,
|
|
1563
|
+
score: t ? 0 : 1,
|
|
1564
|
+
indices: [0, this.pattern.length - 1]
|
|
1565
|
+
};
|
|
1566
|
+
}
|
|
1567
|
+
}
|
|
1568
|
+
class Zt extends j {
|
|
1569
|
+
constructor(e) {
|
|
1570
|
+
super(e);
|
|
1571
|
+
}
|
|
1572
|
+
static get type() {
|
|
1573
|
+
return "inverse-prefix-exact";
|
|
1574
|
+
}
|
|
1575
|
+
static get multiRegex() {
|
|
1576
|
+
return /^!\^"(.*)"$/;
|
|
1577
|
+
}
|
|
1578
|
+
static get singleRegex() {
|
|
1579
|
+
return /^!\^(.*)$/;
|
|
1580
|
+
}
|
|
1581
|
+
search(e) {
|
|
1582
|
+
const t = !e.startsWith(this.pattern);
|
|
1583
|
+
return {
|
|
1584
|
+
isMatch: t,
|
|
1585
|
+
score: t ? 0 : 1,
|
|
1586
|
+
indices: [0, e.length - 1]
|
|
1587
|
+
};
|
|
1588
|
+
}
|
|
1589
|
+
}
|
|
1590
|
+
class ei extends j {
|
|
1591
|
+
constructor(e) {
|
|
1592
|
+
super(e);
|
|
1593
|
+
}
|
|
1594
|
+
static get type() {
|
|
1595
|
+
return "suffix-exact";
|
|
1596
|
+
}
|
|
1597
|
+
static get multiRegex() {
|
|
1598
|
+
return /^"(.*)"\$$/;
|
|
1599
|
+
}
|
|
1600
|
+
static get singleRegex() {
|
|
1601
|
+
return /^(.*)\$$/;
|
|
1602
|
+
}
|
|
1603
|
+
search(e) {
|
|
1604
|
+
const t = e.endsWith(this.pattern);
|
|
1605
|
+
return {
|
|
1606
|
+
isMatch: t,
|
|
1607
|
+
score: t ? 0 : 1,
|
|
1608
|
+
indices: [e.length - this.pattern.length, e.length - 1]
|
|
1609
|
+
};
|
|
1610
|
+
}
|
|
1611
|
+
}
|
|
1612
|
+
class ti extends j {
|
|
1613
|
+
constructor(e) {
|
|
1614
|
+
super(e);
|
|
1615
|
+
}
|
|
1616
|
+
static get type() {
|
|
1617
|
+
return "inverse-suffix-exact";
|
|
1618
|
+
}
|
|
1619
|
+
static get multiRegex() {
|
|
1620
|
+
return /^!"(.*)"\$$/;
|
|
1621
|
+
}
|
|
1622
|
+
static get singleRegex() {
|
|
1623
|
+
return /^!(.*)\$$/;
|
|
1624
|
+
}
|
|
1625
|
+
search(e) {
|
|
1626
|
+
const t = !e.endsWith(this.pattern);
|
|
1627
|
+
return {
|
|
1628
|
+
isMatch: t,
|
|
1629
|
+
score: t ? 0 : 1,
|
|
1630
|
+
indices: [0, e.length - 1]
|
|
1631
|
+
};
|
|
1632
|
+
}
|
|
1633
|
+
}
|
|
1634
|
+
class qe extends j {
|
|
1635
|
+
constructor(e, {
|
|
1636
|
+
location: t = v.location,
|
|
1637
|
+
threshold: s = v.threshold,
|
|
1638
|
+
distance: n = v.distance,
|
|
1639
|
+
includeMatches: r = v.includeMatches,
|
|
1640
|
+
findAllMatches: o = v.findAllMatches,
|
|
1641
|
+
minMatchCharLength: a = v.minMatchCharLength,
|
|
1642
|
+
isCaseSensitive: l = v.isCaseSensitive,
|
|
1643
|
+
ignoreLocation: h = v.ignoreLocation
|
|
1644
|
+
} = {}) {
|
|
1645
|
+
super(e), this._bitapSearch = new Ye(e, {
|
|
1646
|
+
location: t,
|
|
1647
|
+
threshold: s,
|
|
1648
|
+
distance: n,
|
|
1649
|
+
includeMatches: r,
|
|
1650
|
+
findAllMatches: o,
|
|
1651
|
+
minMatchCharLength: a,
|
|
1652
|
+
isCaseSensitive: l,
|
|
1653
|
+
ignoreLocation: h
|
|
1654
|
+
});
|
|
1655
|
+
}
|
|
1656
|
+
static get type() {
|
|
1657
|
+
return "fuzzy";
|
|
1658
|
+
}
|
|
1659
|
+
static get multiRegex() {
|
|
1660
|
+
return /^"(.*)"$/;
|
|
1661
|
+
}
|
|
1662
|
+
static get singleRegex() {
|
|
1663
|
+
return /^(.*)$/;
|
|
1664
|
+
}
|
|
1665
|
+
search(e) {
|
|
1666
|
+
return this._bitapSearch.searchIn(e);
|
|
1667
|
+
}
|
|
1668
|
+
}
|
|
1669
|
+
class ze extends j {
|
|
1670
|
+
constructor(e) {
|
|
1671
|
+
super(e);
|
|
1672
|
+
}
|
|
1673
|
+
static get type() {
|
|
1674
|
+
return "include";
|
|
1675
|
+
}
|
|
1676
|
+
static get multiRegex() {
|
|
1677
|
+
return /^'"(.*)"$/;
|
|
1678
|
+
}
|
|
1679
|
+
static get singleRegex() {
|
|
1680
|
+
return /^'(.*)$/;
|
|
1681
|
+
}
|
|
1682
|
+
search(e) {
|
|
1683
|
+
let t = 0, s;
|
|
1684
|
+
const n = [], r = this.pattern.length;
|
|
1685
|
+
for (; (s = e.indexOf(this.pattern, t)) > -1; )
|
|
1686
|
+
t = s + r, n.push([s, t - 1]);
|
|
1687
|
+
const o = !!n.length;
|
|
1688
|
+
return {
|
|
1689
|
+
isMatch: o,
|
|
1690
|
+
score: o ? 0 : 1,
|
|
1691
|
+
indices: n
|
|
1692
|
+
};
|
|
1693
|
+
}
|
|
1694
|
+
}
|
|
1695
|
+
const he = [Xt, ze, Qt, Zt, ti, ei, Jt, qe], Pe = he.length, ii = / +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/, si = "|";
|
|
1696
|
+
function ni(i, e = {}) {
|
|
1697
|
+
return i.split(si).map((t) => {
|
|
1698
|
+
let s = t.trim().split(ii).filter((r) => r && !!r.trim()), n = [];
|
|
1699
|
+
for (let r = 0, o = s.length; r < o; r += 1) {
|
|
1700
|
+
const a = s[r];
|
|
1701
|
+
let l = !1, h = -1;
|
|
1702
|
+
for (; !l && ++h < Pe; ) {
|
|
1703
|
+
const c = he[h];
|
|
1704
|
+
let u = c.isMultiMatch(a);
|
|
1705
|
+
u && (n.push(new c(u, e)), l = !0);
|
|
1706
|
+
}
|
|
1707
|
+
if (!l)
|
|
1708
|
+
for (h = -1; ++h < Pe; ) {
|
|
1709
|
+
const c = he[h];
|
|
1710
|
+
let u = c.isSingleMatch(a);
|
|
1711
|
+
if (u) {
|
|
1712
|
+
n.push(new c(u, e));
|
|
1713
|
+
break;
|
|
1714
|
+
}
|
|
1715
|
+
}
|
|
1716
|
+
}
|
|
1717
|
+
return n;
|
|
1718
|
+
});
|
|
1719
|
+
}
|
|
1720
|
+
const ri = /* @__PURE__ */ new Set([qe.type, ze.type]);
|
|
1721
|
+
class oi {
|
|
1722
|
+
constructor(e, {
|
|
1723
|
+
isCaseSensitive: t = v.isCaseSensitive,
|
|
1724
|
+
includeMatches: s = v.includeMatches,
|
|
1725
|
+
minMatchCharLength: n = v.minMatchCharLength,
|
|
1726
|
+
ignoreLocation: r = v.ignoreLocation,
|
|
1727
|
+
findAllMatches: o = v.findAllMatches,
|
|
1728
|
+
location: a = v.location,
|
|
1729
|
+
threshold: l = v.threshold,
|
|
1730
|
+
distance: h = v.distance
|
|
1731
|
+
} = {}) {
|
|
1732
|
+
this.query = null, this.options = {
|
|
1733
|
+
isCaseSensitive: t,
|
|
1734
|
+
includeMatches: s,
|
|
1735
|
+
minMatchCharLength: n,
|
|
1736
|
+
findAllMatches: o,
|
|
1737
|
+
ignoreLocation: r,
|
|
1738
|
+
location: a,
|
|
1739
|
+
threshold: l,
|
|
1740
|
+
distance: h
|
|
1741
|
+
}, this.pattern = t ? e : e.toLowerCase(), this.query = ni(this.pattern, this.options);
|
|
1742
|
+
}
|
|
1743
|
+
static condition(e, t) {
|
|
1744
|
+
return t.useExtendedSearch;
|
|
1745
|
+
}
|
|
1746
|
+
searchIn(e) {
|
|
1747
|
+
const t = this.query;
|
|
1748
|
+
if (!t)
|
|
1749
|
+
return {
|
|
1750
|
+
isMatch: !1,
|
|
1751
|
+
score: 1
|
|
1752
|
+
};
|
|
1753
|
+
const {
|
|
1754
|
+
includeMatches: s,
|
|
1755
|
+
isCaseSensitive: n
|
|
1756
|
+
} = this.options;
|
|
1757
|
+
e = n ? e : e.toLowerCase();
|
|
1758
|
+
let r = 0, o = [], a = 0;
|
|
1759
|
+
for (let l = 0, h = t.length; l < h; l += 1) {
|
|
1760
|
+
const c = t[l];
|
|
1761
|
+
o.length = 0, r = 0;
|
|
1762
|
+
for (let u = 0, d = c.length; u < d; u += 1) {
|
|
1763
|
+
const m = c[u], {
|
|
1764
|
+
isMatch: f,
|
|
1765
|
+
indices: p,
|
|
1766
|
+
score: g
|
|
1767
|
+
} = m.search(e);
|
|
1768
|
+
if (f) {
|
|
1769
|
+
if (r += 1, a += g, s) {
|
|
1770
|
+
const y = m.constructor.type;
|
|
1771
|
+
ri.has(y) ? o = [...o, ...p] : o.push(p);
|
|
1772
|
+
}
|
|
1773
|
+
} else {
|
|
1774
|
+
a = 0, r = 0, o.length = 0;
|
|
1775
|
+
break;
|
|
1776
|
+
}
|
|
1777
|
+
}
|
|
1778
|
+
if (r) {
|
|
1779
|
+
let u = {
|
|
1780
|
+
isMatch: !0,
|
|
1781
|
+
score: a / r
|
|
1782
|
+
};
|
|
1783
|
+
return s && (u.indices = o), u;
|
|
1784
|
+
}
|
|
1785
|
+
}
|
|
1786
|
+
return {
|
|
1787
|
+
isMatch: !1,
|
|
1788
|
+
score: 1
|
|
1789
|
+
};
|
|
1790
|
+
}
|
|
1791
|
+
}
|
|
1792
|
+
const ue = [];
|
|
1793
|
+
function ai(...i) {
|
|
1794
|
+
ue.push(...i);
|
|
1795
|
+
}
|
|
1796
|
+
function de(i, e) {
|
|
1797
|
+
for (let t = 0, s = ue.length; t < s; t += 1) {
|
|
1798
|
+
let n = ue[t];
|
|
1799
|
+
if (n.condition(i, e))
|
|
1800
|
+
return new n(i, e);
|
|
1801
|
+
}
|
|
1802
|
+
return new Ye(i, e);
|
|
1803
|
+
}
|
|
1804
|
+
const te = {
|
|
1805
|
+
AND: "$and",
|
|
1806
|
+
OR: "$or"
|
|
1807
|
+
}, fe = {
|
|
1808
|
+
PATH: "$path",
|
|
1809
|
+
PATTERN: "$val"
|
|
1810
|
+
}, pe = (i) => !!(i[te.AND] || i[te.OR]), li = (i) => !!i[fe.PATH], ci = (i) => !k(i) && Ge(i) && !pe(i), Fe = (i) => ({
|
|
1811
|
+
[te.AND]: Object.keys(i).map((e) => ({
|
|
1812
|
+
[e]: i[e]
|
|
1813
|
+
}))
|
|
1814
|
+
});
|
|
1815
|
+
function Xe(i, e, {
|
|
1816
|
+
auto: t = !0
|
|
1817
|
+
} = {}) {
|
|
1818
|
+
const s = (n) => {
|
|
1819
|
+
let r = Object.keys(n);
|
|
1820
|
+
const o = li(n);
|
|
1821
|
+
if (!o && r.length > 1 && !pe(n))
|
|
1822
|
+
return s(Fe(n));
|
|
1823
|
+
if (ci(n)) {
|
|
1824
|
+
const l = o ? n[fe.PATH] : r[0], h = o ? n[fe.PATTERN] : n[l];
|
|
1825
|
+
if (!P(h))
|
|
1826
|
+
throw new Error(Pt(l));
|
|
1827
|
+
const c = {
|
|
1828
|
+
keyId: ce(l),
|
|
1829
|
+
pattern: h
|
|
1830
|
+
};
|
|
1831
|
+
return t && (c.searcher = de(h, e)), c;
|
|
1832
|
+
}
|
|
1833
|
+
let a = {
|
|
1834
|
+
children: [],
|
|
1835
|
+
operator: r[0]
|
|
1836
|
+
};
|
|
1837
|
+
return r.forEach((l) => {
|
|
1838
|
+
const h = n[l];
|
|
1839
|
+
k(h) && h.forEach((c) => {
|
|
1840
|
+
a.children.push(s(c));
|
|
1841
|
+
});
|
|
1842
|
+
}), a;
|
|
1843
|
+
};
|
|
1844
|
+
return pe(i) || (i = Fe(i)), s(i);
|
|
1845
|
+
}
|
|
1846
|
+
function hi(i, {
|
|
1847
|
+
ignoreFieldNorm: e = v.ignoreFieldNorm
|
|
1848
|
+
}) {
|
|
1849
|
+
i.forEach((t) => {
|
|
1850
|
+
let s = 1;
|
|
1851
|
+
t.matches.forEach(({
|
|
1852
|
+
key: n,
|
|
1853
|
+
norm: r,
|
|
1854
|
+
score: o
|
|
1855
|
+
}) => {
|
|
1856
|
+
const a = n ? n.weight : null;
|
|
1857
|
+
s *= Math.pow(o === 0 && a ? Number.EPSILON : o, (a || 1) * (e ? 1 : r));
|
|
1858
|
+
}), t.score = s;
|
|
1859
|
+
});
|
|
1860
|
+
}
|
|
1861
|
+
function ui(i, e) {
|
|
1862
|
+
const t = i.matches;
|
|
1863
|
+
e.matches = [], O(t) && t.forEach((s) => {
|
|
1864
|
+
if (!O(s.indices) || !s.indices.length)
|
|
1865
|
+
return;
|
|
1866
|
+
const {
|
|
1867
|
+
indices: n,
|
|
1868
|
+
value: r
|
|
1869
|
+
} = s;
|
|
1870
|
+
let o = {
|
|
1871
|
+
indices: n,
|
|
1872
|
+
value: r
|
|
1873
|
+
};
|
|
1874
|
+
s.key && (o.key = s.key.src), s.idx > -1 && (o.refIndex = s.idx), e.matches.push(o);
|
|
1875
|
+
});
|
|
1876
|
+
}
|
|
1877
|
+
function di(i, e) {
|
|
1878
|
+
e.score = i.score;
|
|
1879
|
+
}
|
|
1880
|
+
function fi(i, e, {
|
|
1881
|
+
includeMatches: t = v.includeMatches,
|
|
1882
|
+
includeScore: s = v.includeScore
|
|
1883
|
+
} = {}) {
|
|
1884
|
+
const n = [];
|
|
1885
|
+
return t && n.push(ui), s && n.push(di), i.map((r) => {
|
|
1886
|
+
const {
|
|
1887
|
+
idx: o
|
|
1888
|
+
} = r, a = {
|
|
1889
|
+
item: e[o],
|
|
1890
|
+
refIndex: o
|
|
1891
|
+
};
|
|
1892
|
+
return n.length && n.forEach((l) => {
|
|
1893
|
+
l(r, a);
|
|
1894
|
+
}), a;
|
|
1895
|
+
});
|
|
1896
|
+
}
|
|
1897
|
+
class $ {
|
|
1898
|
+
constructor(e, t = {}, s) {
|
|
1899
|
+
this.options = U(U({}, v), t), this.options.useExtendedSearch, this._keyStore = new Kt(this.options.keys), this.setCollection(e, s);
|
|
1900
|
+
}
|
|
1901
|
+
setCollection(e, t) {
|
|
1902
|
+
if (this._docs = e, t && !(t instanceof ve))
|
|
1903
|
+
throw new Error(Nt);
|
|
1904
|
+
this._myIndex = t || $e(this.options.keys, this._docs, {
|
|
1905
|
+
getFn: this.options.getFn,
|
|
1906
|
+
fieldNormWeight: this.options.fieldNormWeight
|
|
1907
|
+
});
|
|
1908
|
+
}
|
|
1909
|
+
add(e) {
|
|
1910
|
+
O(e) && (this._docs.push(e), this._myIndex.add(e));
|
|
1911
|
+
}
|
|
1912
|
+
remove(e = () => !1) {
|
|
1913
|
+
const t = [];
|
|
1914
|
+
for (let s = 0, n = this._docs.length; s < n; s += 1) {
|
|
1915
|
+
const r = this._docs[s];
|
|
1916
|
+
e(r, s) && (this.removeAt(s), s -= 1, n -= 1, t.push(r));
|
|
1917
|
+
}
|
|
1918
|
+
return t;
|
|
1919
|
+
}
|
|
1920
|
+
removeAt(e) {
|
|
1921
|
+
this._docs.splice(e, 1), this._myIndex.removeAt(e);
|
|
1922
|
+
}
|
|
1923
|
+
getIndex() {
|
|
1924
|
+
return this._myIndex;
|
|
1925
|
+
}
|
|
1926
|
+
search(e, {
|
|
1927
|
+
limit: t = -1
|
|
1928
|
+
} = {}) {
|
|
1929
|
+
const {
|
|
1930
|
+
includeMatches: s,
|
|
1931
|
+
includeScore: n,
|
|
1932
|
+
shouldSort: r,
|
|
1933
|
+
sortFn: o,
|
|
1934
|
+
ignoreFieldNorm: a
|
|
1935
|
+
} = this.options;
|
|
1936
|
+
let l = P(e) ? P(this._docs[0]) ? this._searchStringList(e) : this._searchObjectList(e) : this._searchLogical(e);
|
|
1937
|
+
return hi(l, {
|
|
1938
|
+
ignoreFieldNorm: a
|
|
1939
|
+
}), r && l.sort(o), Be(t) && t > -1 && (l = l.slice(0, t)), fi(l, this._docs, {
|
|
1940
|
+
includeMatches: s,
|
|
1941
|
+
includeScore: n
|
|
1942
|
+
});
|
|
1943
|
+
}
|
|
1944
|
+
_searchStringList(e) {
|
|
1945
|
+
const t = de(e, this.options), {
|
|
1946
|
+
records: s
|
|
1947
|
+
} = this._myIndex, n = [];
|
|
1948
|
+
return s.forEach(({
|
|
1949
|
+
v: r,
|
|
1950
|
+
i: o,
|
|
1951
|
+
n: a
|
|
1952
|
+
}) => {
|
|
1953
|
+
if (!O(r))
|
|
1954
|
+
return;
|
|
1955
|
+
const {
|
|
1956
|
+
isMatch: l,
|
|
1957
|
+
score: h,
|
|
1958
|
+
indices: c
|
|
1959
|
+
} = t.searchIn(r);
|
|
1960
|
+
l && n.push({
|
|
1961
|
+
item: r,
|
|
1962
|
+
idx: o,
|
|
1963
|
+
matches: [{
|
|
1964
|
+
score: h,
|
|
1965
|
+
value: r,
|
|
1966
|
+
norm: a,
|
|
1967
|
+
indices: c
|
|
1968
|
+
}]
|
|
1969
|
+
});
|
|
1970
|
+
}), n;
|
|
1971
|
+
}
|
|
1972
|
+
_searchLogical(e) {
|
|
1973
|
+
const t = Xe(e, this.options), s = (a, l, h) => {
|
|
1974
|
+
if (!a.children) {
|
|
1975
|
+
const {
|
|
1976
|
+
keyId: u,
|
|
1977
|
+
searcher: d
|
|
1978
|
+
} = a, m = this._findMatches({
|
|
1979
|
+
key: this._keyStore.get(u),
|
|
1980
|
+
value: this._myIndex.getValueForItemAtKeyId(l, u),
|
|
1981
|
+
searcher: d
|
|
1982
|
+
});
|
|
1983
|
+
return m && m.length ? [{
|
|
1984
|
+
idx: h,
|
|
1985
|
+
item: l,
|
|
1986
|
+
matches: m
|
|
1987
|
+
}] : [];
|
|
1988
|
+
}
|
|
1989
|
+
const c = [];
|
|
1990
|
+
for (let u = 0, d = a.children.length; u < d; u += 1) {
|
|
1991
|
+
const m = a.children[u], f = s(m, l, h);
|
|
1992
|
+
if (f.length)
|
|
1993
|
+
c.push(...f);
|
|
1994
|
+
else if (a.operator === te.AND)
|
|
1995
|
+
return [];
|
|
1996
|
+
}
|
|
1997
|
+
return c;
|
|
1998
|
+
}, n = this._myIndex.records, r = {}, o = [];
|
|
1999
|
+
return n.forEach(({
|
|
2000
|
+
$: a,
|
|
2001
|
+
i: l
|
|
2002
|
+
}) => {
|
|
2003
|
+
if (O(a)) {
|
|
2004
|
+
let h = s(t, a, l);
|
|
2005
|
+
h.length && (r[l] || (r[l] = {
|
|
2006
|
+
idx: l,
|
|
2007
|
+
item: a,
|
|
2008
|
+
matches: []
|
|
2009
|
+
}, o.push(r[l])), h.forEach(({
|
|
2010
|
+
matches: c
|
|
2011
|
+
}) => {
|
|
2012
|
+
r[l].matches.push(...c);
|
|
2013
|
+
}));
|
|
2014
|
+
}
|
|
2015
|
+
}), o;
|
|
2016
|
+
}
|
|
2017
|
+
_searchObjectList(e) {
|
|
2018
|
+
const t = de(e, this.options), {
|
|
2019
|
+
keys: s,
|
|
2020
|
+
records: n
|
|
2021
|
+
} = this._myIndex, r = [];
|
|
2022
|
+
return n.forEach(({
|
|
2023
|
+
$: o,
|
|
2024
|
+
i: a
|
|
2025
|
+
}) => {
|
|
2026
|
+
if (!O(o))
|
|
2027
|
+
return;
|
|
2028
|
+
let l = [];
|
|
2029
|
+
s.forEach((h, c) => {
|
|
2030
|
+
l.push(...this._findMatches({
|
|
2031
|
+
key: h,
|
|
2032
|
+
value: o[c],
|
|
2033
|
+
searcher: t
|
|
2034
|
+
}));
|
|
2035
|
+
}), l.length && r.push({
|
|
2036
|
+
idx: a,
|
|
2037
|
+
item: o,
|
|
2038
|
+
matches: l
|
|
2039
|
+
});
|
|
2040
|
+
}), r;
|
|
2041
|
+
}
|
|
2042
|
+
_findMatches({
|
|
2043
|
+
key: e,
|
|
2044
|
+
value: t,
|
|
2045
|
+
searcher: s
|
|
2046
|
+
}) {
|
|
2047
|
+
if (!O(t))
|
|
2048
|
+
return [];
|
|
2049
|
+
let n = [];
|
|
2050
|
+
if (k(t))
|
|
2051
|
+
t.forEach(({
|
|
2052
|
+
v: r,
|
|
2053
|
+
i: o,
|
|
2054
|
+
n: a
|
|
2055
|
+
}) => {
|
|
2056
|
+
if (!O(r))
|
|
2057
|
+
return;
|
|
2058
|
+
const {
|
|
2059
|
+
isMatch: l,
|
|
2060
|
+
score: h,
|
|
2061
|
+
indices: c
|
|
2062
|
+
} = s.searchIn(r);
|
|
2063
|
+
l && n.push({
|
|
2064
|
+
score: h,
|
|
2065
|
+
key: e,
|
|
2066
|
+
value: r,
|
|
2067
|
+
idx: o,
|
|
2068
|
+
norm: a,
|
|
2069
|
+
indices: c
|
|
2070
|
+
});
|
|
2071
|
+
});
|
|
2072
|
+
else {
|
|
2073
|
+
const {
|
|
2074
|
+
v: r,
|
|
2075
|
+
n: o
|
|
2076
|
+
} = t, {
|
|
2077
|
+
isMatch: a,
|
|
2078
|
+
score: l,
|
|
2079
|
+
indices: h
|
|
2080
|
+
} = s.searchIn(r);
|
|
2081
|
+
a && n.push({
|
|
2082
|
+
score: l,
|
|
2083
|
+
key: e,
|
|
2084
|
+
value: r,
|
|
2085
|
+
norm: o,
|
|
2086
|
+
indices: h
|
|
2087
|
+
});
|
|
2088
|
+
}
|
|
2089
|
+
return n;
|
|
2090
|
+
}
|
|
2091
|
+
}
|
|
2092
|
+
$.version = "7.0.0";
|
|
2093
|
+
$.createIndex = $e;
|
|
2094
|
+
$.parseIndex = $t;
|
|
2095
|
+
$.config = v;
|
|
2096
|
+
$.parseQuery = Xe;
|
|
2097
|
+
ai(oi);
|
|
2098
|
+
var pi = (
|
|
2099
|
+
/** @class */
|
|
2100
|
+
(function() {
|
|
2101
|
+
function i(e) {
|
|
2102
|
+
this._haystack = [], this._fuseOptions = A(A({}, e.fuseOptions), { keys: Je([], e.searchFields), includeMatches: !0 });
|
|
2103
|
+
}
|
|
2104
|
+
return i.prototype.index = function(e) {
|
|
2105
|
+
this._haystack = e, this._fuse && this._fuse.setCollection(e);
|
|
2106
|
+
}, i.prototype.reset = function() {
|
|
2107
|
+
this._haystack = [], this._fuse = void 0;
|
|
2108
|
+
}, i.prototype.isEmptyIndex = function() {
|
|
2109
|
+
return !this._haystack.length;
|
|
2110
|
+
}, i.prototype.search = function(e) {
|
|
2111
|
+
this._fuse || (this._fuse = new $(this._haystack, this._fuseOptions));
|
|
2112
|
+
var t = this._fuse.search(e);
|
|
2113
|
+
return t.map(function(s, n) {
|
|
2114
|
+
return {
|
|
2115
|
+
item: s.item,
|
|
2116
|
+
score: s.score || 0,
|
|
2117
|
+
rank: n + 1
|
|
2118
|
+
// If value.score is used for sorting, this can create non-stable sorts!
|
|
2119
|
+
};
|
|
2120
|
+
});
|
|
2121
|
+
}, i;
|
|
2122
|
+
})()
|
|
2123
|
+
);
|
|
2124
|
+
function mi(i) {
|
|
2125
|
+
return new pi(i);
|
|
2126
|
+
}
|
|
2127
|
+
var vi = function(i) {
|
|
2128
|
+
for (var e in i)
|
|
2129
|
+
if (Object.prototype.hasOwnProperty.call(i, e))
|
|
2130
|
+
return !1;
|
|
2131
|
+
return !0;
|
|
2132
|
+
}, oe = function(i, e, t) {
|
|
2133
|
+
var s = i.dataset, n = e.customProperties, r = e.labelClass, o = e.labelDescription;
|
|
2134
|
+
r && (s.labelClass = ie(r).join(" ")), o && (s.labelDescription = N(o)), t && n && (typeof n == "string" ? s.customProperties = n : typeof n == "object" && !vi(n) && (s.customProperties = JSON.stringify(n)));
|
|
2135
|
+
}, ke = function(i, e, t) {
|
|
2136
|
+
var s = e && i.querySelector("label[for='".concat(e, "']")), n = s && s.innerText;
|
|
2137
|
+
n && t.setAttribute("aria-label", n);
|
|
2138
|
+
}, _i = {
|
|
2139
|
+
containerOuter: function(i, e, t, s, n, r, o) {
|
|
2140
|
+
var a = i.classNames.containerOuter, l = document.createElement("div");
|
|
2141
|
+
return _(l, a), l.dataset.type = r, e && (l.dir = e), s && (l.tabIndex = 0), t && (l.setAttribute("role", n ? "combobox" : "listbox"), n ? l.setAttribute("aria-autocomplete", "list") : o || ke(this._docRoot, this.passedElement.element.id, l), l.setAttribute("aria-haspopup", "true"), l.setAttribute("aria-expanded", "false")), o && l.setAttribute("aria-labelledby", o), l;
|
|
2142
|
+
},
|
|
2143
|
+
containerInner: function(i) {
|
|
2144
|
+
var e = i.classNames.containerInner, t = document.createElement("div");
|
|
2145
|
+
return _(t, e), t;
|
|
2146
|
+
},
|
|
2147
|
+
itemList: function(i, e) {
|
|
2148
|
+
var t = i.searchEnabled, s = i.classNames, n = s.list, r = s.listSingle, o = s.listItems, a = document.createElement("div");
|
|
2149
|
+
return _(a, n), _(a, e ? r : o), this._isSelectElement && t && a.setAttribute("role", "listbox"), a;
|
|
2150
|
+
},
|
|
2151
|
+
placeholder: function(i, e) {
|
|
2152
|
+
var t = i.allowHTML, s = i.classNames.placeholder, n = document.createElement("div");
|
|
2153
|
+
return _(n, s), F(n, t, e), n;
|
|
2154
|
+
},
|
|
2155
|
+
item: function(i, e, t) {
|
|
2156
|
+
var s = i.allowHTML, n = i.removeItemButtonAlignLeft, r = i.removeItemIconText, o = i.removeItemLabelText, a = i.classNames, l = a.item, h = a.button, c = a.highlightedState, u = a.itemSelectable, d = a.placeholder, m = N(e.value), f = document.createElement("div");
|
|
2157
|
+
if (_(f, l), e.labelClass) {
|
|
2158
|
+
var p = document.createElement("span");
|
|
2159
|
+
F(p, s, e.label), _(p, e.labelClass), f.appendChild(p);
|
|
2160
|
+
} else
|
|
2161
|
+
F(f, s, e.label);
|
|
2162
|
+
if (f.dataset.item = "", f.dataset.id = e.id, f.dataset.value = m, oe(f, e, !0), (e.disabled || this.containerOuter.isDisabled) && f.setAttribute("aria-disabled", "true"), this._isSelectElement && (f.setAttribute("aria-selected", "true"), f.setAttribute("role", "option")), e.placeholder && (_(f, d), f.dataset.placeholder = ""), _(f, e.highlighted ? c : u), t) {
|
|
2163
|
+
e.disabled && L(f, u), f.dataset.deletable = "";
|
|
2164
|
+
var g = document.createElement("button");
|
|
2165
|
+
g.type = "button", _(g, h);
|
|
2166
|
+
var y = M(e);
|
|
2167
|
+
F(g, !0, X(r, e.value, y));
|
|
2168
|
+
var b = X(o, e.value, y);
|
|
2169
|
+
b && g.setAttribute("aria-label", b), g.dataset.button = "", n ? f.insertAdjacentElement("afterbegin", g) : f.appendChild(g);
|
|
2170
|
+
}
|
|
2171
|
+
return f;
|
|
2172
|
+
},
|
|
2173
|
+
choiceList: function(i, e) {
|
|
2174
|
+
var t = i.classNames.list, s = document.createElement("div");
|
|
2175
|
+
return _(s, t), e || s.setAttribute("aria-multiselectable", "true"), s.setAttribute("role", "listbox"), s;
|
|
2176
|
+
},
|
|
2177
|
+
choiceGroup: function(i, e) {
|
|
2178
|
+
var t = i.allowHTML, s = i.classNames, n = s.group, r = s.groupHeading, o = s.itemDisabled, a = e.id, l = e.label, h = e.disabled, c = N(l), u = document.createElement("div");
|
|
2179
|
+
_(u, n), h && _(u, o), u.setAttribute("role", "group"), u.dataset.group = "", u.dataset.id = a, u.dataset.value = c, h && u.setAttribute("aria-disabled", "true");
|
|
2180
|
+
var d = document.createElement("div");
|
|
2181
|
+
return _(d, r), F(d, t, l || ""), u.appendChild(d), u;
|
|
2182
|
+
},
|
|
2183
|
+
choice: function(i, e, t, s) {
|
|
2184
|
+
var n = i.allowHTML, r = i.classNames, o = r.item, a = r.itemChoice, l = r.itemSelectable, h = r.selectedState, c = r.itemDisabled, u = r.description, d = r.placeholder, m = e.label, f = N(e.value), p = document.createElement("div");
|
|
2185
|
+
p.id = e.elementId, _(p, o), _(p, a), s && typeof m == "string" && (m = me(n, m), m += " (".concat(s, ")"), m = { trusted: m });
|
|
2186
|
+
var g = p;
|
|
2187
|
+
if (e.labelClass) {
|
|
2188
|
+
var y = document.createElement("span");
|
|
2189
|
+
F(y, n, m), _(y, e.labelClass), g = y, p.appendChild(y);
|
|
2190
|
+
} else
|
|
2191
|
+
F(p, n, m);
|
|
2192
|
+
if (e.labelDescription) {
|
|
2193
|
+
var b = "".concat(e.elementId, "-description");
|
|
2194
|
+
g.setAttribute("aria-describedby", b);
|
|
2195
|
+
var C = document.createElement("span");
|
|
2196
|
+
F(C, n, e.labelDescription), C.id = b, _(C, u), p.appendChild(C);
|
|
2197
|
+
}
|
|
2198
|
+
return e.selected && _(p, h), e.placeholder && _(p, d), p.setAttribute("role", e.group ? "treeitem" : "option"), p.dataset.choice = "", p.dataset.id = e.id, p.dataset.value = f, t && (p.dataset.selectText = t), e.group && (p.dataset.groupId = "".concat(e.group.id)), oe(p, e, !1), e.disabled ? (_(p, c), p.dataset.choiceDisabled = "", p.setAttribute("aria-disabled", "true")) : (_(p, l), p.dataset.choiceSelectable = "", p.setAttribute("aria-selected", e.selected ? "true" : "false")), p;
|
|
2199
|
+
},
|
|
2200
|
+
input: function(i, e) {
|
|
2201
|
+
var t = i.classNames, s = t.input, n = t.inputCloned, r = i.labelId, o = document.createElement("input");
|
|
2202
|
+
return o.type = "search", _(o, s), _(o, n), o.autocomplete = "off", o.autocapitalize = "off", o.spellcheck = !1, o.setAttribute("aria-autocomplete", "list"), e ? o.setAttribute("aria-label", e) : r || ke(this._docRoot, this.passedElement.element.id, o), o;
|
|
2203
|
+
},
|
|
2204
|
+
dropdown: function(i) {
|
|
2205
|
+
var e = i.classNames, t = e.list, s = e.listDropdown, n = document.createElement("div");
|
|
2206
|
+
return _(n, t), _(n, s), n.setAttribute("aria-expanded", "false"), n;
|
|
2207
|
+
},
|
|
2208
|
+
notice: function(i, e, t) {
|
|
2209
|
+
var s = i.classNames, n = s.item, r = s.itemChoice, o = s.addChoice, a = s.noResults, l = s.noChoices, h = s.notice;
|
|
2210
|
+
t === void 0 && (t = S.generic);
|
|
2211
|
+
var c = document.createElement("div");
|
|
2212
|
+
switch (F(c, !0, e), _(c, n), _(c, r), _(c, h), t) {
|
|
2213
|
+
case S.addChoice:
|
|
2214
|
+
_(c, o);
|
|
2215
|
+
break;
|
|
2216
|
+
case S.noResults:
|
|
2217
|
+
_(c, a);
|
|
2218
|
+
break;
|
|
2219
|
+
case S.noChoices:
|
|
2220
|
+
_(c, l);
|
|
2221
|
+
break;
|
|
2222
|
+
}
|
|
2223
|
+
return t === S.addChoice && (c.dataset.choiceSelectable = "", c.dataset.choice = ""), c;
|
|
2224
|
+
},
|
|
2225
|
+
option: function(i) {
|
|
2226
|
+
var e = N(i.label), t = new Option(e, i.value, !1, i.selected);
|
|
2227
|
+
return oe(t, i, !0), t.disabled = i.disabled, i.selected && t.setAttribute("selected", ""), t;
|
|
2228
|
+
}
|
|
2229
|
+
}, gi = "-ms-scroll-limit" in document.documentElement.style && "-ms-ime-align" in document.documentElement.style, yi = {}, ae = function(i) {
|
|
2230
|
+
if (i)
|
|
2231
|
+
return i.dataset.id ? parseInt(i.dataset.id, 10) : void 0;
|
|
2232
|
+
}, q = "[data-choice-selectable]", Ei = (
|
|
2233
|
+
/** @class */
|
|
2234
|
+
(function() {
|
|
2235
|
+
function i(e, t) {
|
|
2236
|
+
e === void 0 && (e = "[data-choice]"), t === void 0 && (t = {});
|
|
2237
|
+
var s = this;
|
|
2238
|
+
this.initialisedOK = void 0, this._hasNonChoicePlaceholder = !1, this._lastAddedChoiceId = 0, this._lastAddedGroupId = 0;
|
|
2239
|
+
var n = i.defaults;
|
|
2240
|
+
this.config = A(A(A({}, n.allOptions), n.options), t), Qe.forEach(function(y) {
|
|
2241
|
+
s.config[y] = A(A(A({}, n.allOptions[y]), n.options[y]), t[y]);
|
|
2242
|
+
});
|
|
2243
|
+
var r = this.config;
|
|
2244
|
+
r.silent || this._validateConfig();
|
|
2245
|
+
var o = r.shadowRoot || document.documentElement;
|
|
2246
|
+
this._docRoot = o;
|
|
2247
|
+
var a = typeof e == "string" ? o.querySelector(e) : e;
|
|
2248
|
+
if (!a || typeof a != "object" || !(_t(a) || Ve(a)))
|
|
2249
|
+
throw TypeError(!a && typeof e == "string" ? "Selector ".concat(e, " failed to find an element") : "Expected one of the following types text|select-one|select-multiple");
|
|
2250
|
+
var l = a.type, h = l === H.Text;
|
|
2251
|
+
(h || r.maxItemCount !== 1) && (r.singleModeForMultiSelect = !1), r.singleModeForMultiSelect && (l = H.SelectMultiple);
|
|
2252
|
+
var c = l === H.SelectOne, u = l === H.SelectMultiple, d = c || u;
|
|
2253
|
+
if (this._elementType = l, this._isTextElement = h, this._isSelectOneElement = c, this._isSelectMultipleElement = u, this._isSelectElement = c || u, this._canAddUserChoices = h && r.addItems || d && r.addChoices, typeof r.renderSelectedChoices != "boolean" && (r.renderSelectedChoices = r.renderSelectedChoices === "always" || c), r.closeDropdownOnSelect === "auto" ? r.closeDropdownOnSelect = h || c || r.singleModeForMultiSelect : r.closeDropdownOnSelect = z(r.closeDropdownOnSelect), r.placeholder && (r.placeholderValue ? this._hasNonChoicePlaceholder = !0 : a.dataset.placeholder && (this._hasNonChoicePlaceholder = !0, r.placeholderValue = a.dataset.placeholder)), t.addItemFilter && typeof t.addItemFilter != "function") {
|
|
2254
|
+
var m = t.addItemFilter instanceof RegExp ? t.addItemFilter : new RegExp(t.addItemFilter);
|
|
2255
|
+
r.addItemFilter = m.test.bind(m);
|
|
2256
|
+
}
|
|
2257
|
+
if (this._isTextElement)
|
|
2258
|
+
this.passedElement = new vt({
|
|
2259
|
+
element: a,
|
|
2260
|
+
classNames: r.classNames
|
|
2261
|
+
});
|
|
2262
|
+
else {
|
|
2263
|
+
var f = a;
|
|
2264
|
+
this.passedElement = new bt({
|
|
2265
|
+
element: f,
|
|
2266
|
+
classNames: r.classNames,
|
|
2267
|
+
template: function(y) {
|
|
2268
|
+
return s._templates.option(y);
|
|
2269
|
+
},
|
|
2270
|
+
extractPlaceholder: r.placeholder && !this._hasNonChoicePlaceholder
|
|
2271
|
+
});
|
|
2272
|
+
}
|
|
2273
|
+
if (this.initialised = !1, this._store = new wt(r), this._currentValue = "", r.searchEnabled = !h && r.searchEnabled, this._canSearch = r.searchEnabled, this._isScrollingOnIe = !1, this._highlightPosition = 0, this._wasTap = !0, this._placeholderValue = this._generatePlaceholderValue(), this._baseId = nt(a, "choices-"), this._direction = a.dir, !this._direction) {
|
|
2274
|
+
var p = window.getComputedStyle(a).direction, g = window.getComputedStyle(document.documentElement).direction;
|
|
2275
|
+
p !== g && (this._direction = p);
|
|
2276
|
+
}
|
|
2277
|
+
if (this._idNames = {
|
|
2278
|
+
itemChoice: "item-choice"
|
|
2279
|
+
}, this._templates = n.templates, this._render = this._render.bind(this), this._onFocus = this._onFocus.bind(this), this._onBlur = this._onBlur.bind(this), this._onKeyUp = this._onKeyUp.bind(this), this._onKeyDown = this._onKeyDown.bind(this), this._onInput = this._onInput.bind(this), this._onClick = this._onClick.bind(this), this._onTouchMove = this._onTouchMove.bind(this), this._onTouchEnd = this._onTouchEnd.bind(this), this._onMouseDown = this._onMouseDown.bind(this), this._onMouseOver = this._onMouseOver.bind(this), this._onFormReset = this._onFormReset.bind(this), this._onSelectKey = this._onSelectKey.bind(this), this._onEnterKey = this._onEnterKey.bind(this), this._onEscapeKey = this._onEscapeKey.bind(this), this._onDirectionKey = this._onDirectionKey.bind(this), this._onDeleteKey = this._onDeleteKey.bind(this), this._onChange = this._onChange.bind(this), this._onInvalid = this._onInvalid.bind(this), this.passedElement.isActive) {
|
|
2280
|
+
r.silent || console.warn("Trying to initialise Choices on element already initialised", { element: e }), this.initialised = !0, this.initialisedOK = !1;
|
|
2281
|
+
return;
|
|
2282
|
+
}
|
|
2283
|
+
this.init(), this._initialItems = this._store.items.map(function(y) {
|
|
2284
|
+
return y.value;
|
|
2285
|
+
});
|
|
2286
|
+
}
|
|
2287
|
+
return Object.defineProperty(i, "defaults", {
|
|
2288
|
+
get: function() {
|
|
2289
|
+
return Object.preventExtensions({
|
|
2290
|
+
get options() {
|
|
2291
|
+
return yi;
|
|
2292
|
+
},
|
|
2293
|
+
get allOptions() {
|
|
2294
|
+
return Oe;
|
|
2295
|
+
},
|
|
2296
|
+
get templates() {
|
|
2297
|
+
return _i;
|
|
2298
|
+
}
|
|
2299
|
+
});
|
|
2300
|
+
},
|
|
2301
|
+
enumerable: !1,
|
|
2302
|
+
configurable: !0
|
|
2303
|
+
}), i.prototype.init = function() {
|
|
2304
|
+
if (!(this.initialised || this.initialisedOK !== void 0)) {
|
|
2305
|
+
this._searcher = mi(this.config), this._loadChoices(), this._createTemplates(), this._createElements(), this._createStructure(), this._isTextElement && !this.config.addItems || this.passedElement.element.hasAttribute("disabled") || this.passedElement.element.closest("fieldset:disabled") ? this.disable() : (this.enable(), this._addEventListeners()), this._initStore(), this.initialised = !0, this.initialisedOK = !0;
|
|
2306
|
+
var e = this.config.callbackOnInit;
|
|
2307
|
+
typeof e == "function" && e.call(this);
|
|
2308
|
+
}
|
|
2309
|
+
}, i.prototype.destroy = function() {
|
|
2310
|
+
this.initialised && (this._removeEventListeners(), this.passedElement.reveal(), this.containerOuter.unwrap(this.passedElement.element), this._store._listeners = [], this.clearStore(!1), this._stopSearch(), this._templates = i.defaults.templates, this.initialised = !1, this.initialisedOK = void 0);
|
|
2311
|
+
}, i.prototype.enable = function() {
|
|
2312
|
+
return this.passedElement.isDisabled && this.passedElement.enable(), this.containerOuter.isDisabled && (this._addEventListeners(), this.input.enable(), this.containerOuter.enable()), this;
|
|
2313
|
+
}, i.prototype.disable = function() {
|
|
2314
|
+
return this.passedElement.isDisabled || this.passedElement.disable(), this.containerOuter.isDisabled || (this._removeEventListeners(), this.input.disable(), this.containerOuter.disable()), this;
|
|
2315
|
+
}, i.prototype.highlightItem = function(e, t) {
|
|
2316
|
+
if (t === void 0 && (t = !0), !e || !e.id)
|
|
2317
|
+
return this;
|
|
2318
|
+
var s = this._store.items.find(function(n) {
|
|
2319
|
+
return n.id === e.id;
|
|
2320
|
+
});
|
|
2321
|
+
return !s || s.highlighted ? this : (this._store.dispatch(Z(s, !0)), t && this.passedElement.triggerEvent(w.highlightItem, M(s)), this);
|
|
2322
|
+
}, i.prototype.unhighlightItem = function(e, t) {
|
|
2323
|
+
if (t === void 0 && (t = !0), !e || !e.id)
|
|
2324
|
+
return this;
|
|
2325
|
+
var s = this._store.items.find(function(n) {
|
|
2326
|
+
return n.id === e.id;
|
|
2327
|
+
});
|
|
2328
|
+
return !s || !s.highlighted ? this : (this._store.dispatch(Z(s, !1)), t && this.passedElement.triggerEvent(w.unhighlightItem, M(s)), this);
|
|
2329
|
+
}, i.prototype.highlightAll = function() {
|
|
2330
|
+
var e = this;
|
|
2331
|
+
return this._store.withTxn(function() {
|
|
2332
|
+
e._store.items.forEach(function(t) {
|
|
2333
|
+
t.highlighted || (e._store.dispatch(Z(t, !0)), e.passedElement.triggerEvent(w.highlightItem, M(t)));
|
|
2334
|
+
});
|
|
2335
|
+
}), this;
|
|
2336
|
+
}, i.prototype.unhighlightAll = function() {
|
|
2337
|
+
var e = this;
|
|
2338
|
+
return this._store.withTxn(function() {
|
|
2339
|
+
e._store.items.forEach(function(t) {
|
|
2340
|
+
t.highlighted && (e._store.dispatch(Z(t, !1)), e.passedElement.triggerEvent(w.highlightItem, M(t)));
|
|
2341
|
+
});
|
|
2342
|
+
}), this;
|
|
2343
|
+
}, i.prototype.removeActiveItemsByValue = function(e) {
|
|
2344
|
+
var t = this;
|
|
2345
|
+
return this._store.withTxn(function() {
|
|
2346
|
+
t._store.items.filter(function(s) {
|
|
2347
|
+
return s.value === e;
|
|
2348
|
+
}).forEach(function(s) {
|
|
2349
|
+
return t._removeItem(s);
|
|
2350
|
+
});
|
|
2351
|
+
}), this;
|
|
2352
|
+
}, i.prototype.removeActiveItems = function(e) {
|
|
2353
|
+
var t = this;
|
|
2354
|
+
return this._store.withTxn(function() {
|
|
2355
|
+
t._store.items.filter(function(s) {
|
|
2356
|
+
var n = s.id;
|
|
2357
|
+
return n !== e;
|
|
2358
|
+
}).forEach(function(s) {
|
|
2359
|
+
return t._removeItem(s);
|
|
2360
|
+
});
|
|
2361
|
+
}), this;
|
|
2362
|
+
}, i.prototype.removeHighlightedItems = function(e) {
|
|
2363
|
+
var t = this;
|
|
2364
|
+
return e === void 0 && (e = !1), this._store.withTxn(function() {
|
|
2365
|
+
t._store.highlightedActiveItems.forEach(function(s) {
|
|
2366
|
+
t._removeItem(s), e && t._triggerChange(s.value);
|
|
2367
|
+
});
|
|
2368
|
+
}), this;
|
|
2369
|
+
}, i.prototype.showDropdown = function(e) {
|
|
2370
|
+
var t = this;
|
|
2371
|
+
return this.dropdown.isActive ? this : (e === void 0 && (e = !this._canSearch), requestAnimationFrame(function() {
|
|
2372
|
+
t.dropdown.show();
|
|
2373
|
+
var s = t.dropdown.element.getBoundingClientRect();
|
|
2374
|
+
t.containerOuter.open(s.bottom, s.height), e || t.input.focus(), t.passedElement.triggerEvent(w.showDropdown);
|
|
2375
|
+
var n = t.choiceList.element.querySelector(W(t.config.classNames.selectedState));
|
|
2376
|
+
n !== null && !Se(n, t.choiceList.element) && n.scrollIntoView();
|
|
2377
|
+
}), this);
|
|
2378
|
+
}, i.prototype.hideDropdown = function(e) {
|
|
2379
|
+
var t = this;
|
|
2380
|
+
return this.dropdown.isActive ? (this._removeHighlightedChoices(), requestAnimationFrame(function() {
|
|
2381
|
+
t.dropdown.hide(), t.containerOuter.close(), !e && t._canSearch && (t.input.removeActiveDescendant(), t.input.blur()), t.passedElement.triggerEvent(w.hideDropdown);
|
|
2382
|
+
}), this) : this;
|
|
2383
|
+
}, i.prototype.getValue = function(e) {
|
|
2384
|
+
var t = this._store.items.map(function(s) {
|
|
2385
|
+
return e ? s.value : M(s);
|
|
2386
|
+
});
|
|
2387
|
+
return this._isSelectOneElement || this.config.singleModeForMultiSelect ? t[0] : t;
|
|
2388
|
+
}, i.prototype.setValue = function(e) {
|
|
2389
|
+
var t = this;
|
|
2390
|
+
return this.initialisedOK ? (this._store.withTxn(function() {
|
|
2391
|
+
e.forEach(function(s) {
|
|
2392
|
+
s && t._addChoice(D(s, !1));
|
|
2393
|
+
});
|
|
2394
|
+
}), this._searcher.reset(), this) : (this._warnChoicesInitFailed("setValue"), this);
|
|
2395
|
+
}, i.prototype.setChoiceByValue = function(e) {
|
|
2396
|
+
var t = this;
|
|
2397
|
+
return this.initialisedOK ? this._isTextElement ? this : (this._store.withTxn(function() {
|
|
2398
|
+
var s = Array.isArray(e) ? e : [e];
|
|
2399
|
+
s.forEach(function(n) {
|
|
2400
|
+
return t._findAndSelectChoiceByValue(n);
|
|
2401
|
+
}), t.unhighlightAll();
|
|
2402
|
+
}), this._searcher.reset(), this) : (this._warnChoicesInitFailed("setChoiceByValue"), this);
|
|
2403
|
+
}, i.prototype.setChoices = function(e, t, s, n, r, o) {
|
|
2404
|
+
var a = this;
|
|
2405
|
+
if (e === void 0 && (e = []), t === void 0 && (t = "value"), s === void 0 && (s = "label"), n === void 0 && (n = !1), r === void 0 && (r = !0), o === void 0 && (o = !1), !this.initialisedOK)
|
|
2406
|
+
return this._warnChoicesInitFailed("setChoices"), this;
|
|
2407
|
+
if (!this._isSelectElement)
|
|
2408
|
+
throw new TypeError("setChoices can't be used with INPUT based Choices");
|
|
2409
|
+
if (typeof t != "string" || !t)
|
|
2410
|
+
throw new TypeError("value parameter must be a name of 'value' field in passed objects");
|
|
2411
|
+
if (typeof e == "function") {
|
|
2412
|
+
var l = e(this);
|
|
2413
|
+
if (typeof Promise == "function" && l instanceof Promise)
|
|
2414
|
+
return new Promise(function(h) {
|
|
2415
|
+
return requestAnimationFrame(h);
|
|
2416
|
+
}).then(function() {
|
|
2417
|
+
return a._handleLoadingState(!0);
|
|
2418
|
+
}).then(function() {
|
|
2419
|
+
return l;
|
|
2420
|
+
}).then(function(h) {
|
|
2421
|
+
return a.setChoices(h, t, s, n, r, o);
|
|
2422
|
+
}).catch(function(h) {
|
|
2423
|
+
a.config.silent || console.error(h);
|
|
2424
|
+
}).then(function() {
|
|
2425
|
+
return a._handleLoadingState(!1);
|
|
2426
|
+
}).then(function() {
|
|
2427
|
+
return a;
|
|
2428
|
+
});
|
|
2429
|
+
if (!Array.isArray(l))
|
|
2430
|
+
throw new TypeError(".setChoices first argument function must return either array of choices or Promise, got: ".concat(typeof l));
|
|
2431
|
+
return this.setChoices(l, t, s, !1);
|
|
2432
|
+
}
|
|
2433
|
+
if (!Array.isArray(e))
|
|
2434
|
+
throw new TypeError(".setChoices must be called either with array of choices with a function resulting into Promise of array of choices");
|
|
2435
|
+
return this.containerOuter.removeLoadingState(), this._store.withTxn(function() {
|
|
2436
|
+
r && (a._isSearching = !1), n && a.clearChoices(!0, o);
|
|
2437
|
+
var h = t === "value", c = s === "label";
|
|
2438
|
+
e.forEach(function(u) {
|
|
2439
|
+
if ("choices" in u) {
|
|
2440
|
+
var d = u;
|
|
2441
|
+
c || (d = A(A({}, d), { label: d[s] })), a._addGroup(D(d, !0));
|
|
2442
|
+
} else {
|
|
2443
|
+
var m = u;
|
|
2444
|
+
(!c || !h) && (m = A(A({}, m), { value: m[t], label: m[s] }));
|
|
2445
|
+
var f = D(m, !1);
|
|
2446
|
+
a._addChoice(f), f.placeholder && !a._hasNonChoicePlaceholder && (a._placeholderValue = Ke(f.label));
|
|
2447
|
+
}
|
|
2448
|
+
}), a.unhighlightAll();
|
|
2449
|
+
}), this._searcher.reset(), this;
|
|
2450
|
+
}, i.prototype.refresh = function(e, t, s) {
|
|
2451
|
+
var n = this;
|
|
2452
|
+
return e === void 0 && (e = !1), t === void 0 && (t = !1), s === void 0 && (s = !1), this._isSelectElement ? (this._store.withTxn(function() {
|
|
2453
|
+
var r = n.passedElement.optionsAsChoices(), o = {};
|
|
2454
|
+
s || n._store.items.forEach(function(l) {
|
|
2455
|
+
l.id && l.active && l.selected && (o[l.value] = !0);
|
|
2456
|
+
}), n.clearStore(!1);
|
|
2457
|
+
var a = function(l) {
|
|
2458
|
+
s ? n._store.dispatch(Ee(l)) : o[l.value] && (l.selected = !0);
|
|
2459
|
+
};
|
|
2460
|
+
r.forEach(function(l) {
|
|
2461
|
+
if ("choices" in l) {
|
|
2462
|
+
l.choices.forEach(a);
|
|
2463
|
+
return;
|
|
2464
|
+
}
|
|
2465
|
+
a(l);
|
|
2466
|
+
}), n._addPredefinedChoices(r, t, e), n._isSearching && n._searchChoices(n.input.value);
|
|
2467
|
+
}), this) : (this.config.silent || console.warn("refresh method can only be used on choices backed by a <select> element"), this);
|
|
2468
|
+
}, i.prototype.removeChoice = function(e) {
|
|
2469
|
+
var t = this._store.choices.find(function(s) {
|
|
2470
|
+
return s.value === e;
|
|
2471
|
+
});
|
|
2472
|
+
return t ? (this._clearNotice(), this._store.dispatch(Ze(t)), this._searcher.reset(), t.selected && this.passedElement.triggerEvent(w.removeItem, M(t)), this) : this;
|
|
2473
|
+
}, i.prototype.clearChoices = function(e, t) {
|
|
2474
|
+
var s = this;
|
|
2475
|
+
return e === void 0 && (e = !0), t === void 0 && (t = !1), e && (t ? this.passedElement.element.replaceChildren("") : this.passedElement.element.querySelectorAll(":not([selected])").forEach(function(n) {
|
|
2476
|
+
n.remove();
|
|
2477
|
+
})), this.itemList.element.replaceChildren(""), this.choiceList.element.replaceChildren(""), this._clearNotice(), this._store.withTxn(function() {
|
|
2478
|
+
var n = t ? [] : s._store.items;
|
|
2479
|
+
s._store.reset(), n.forEach(function(r) {
|
|
2480
|
+
s._store.dispatch(ye(r)), s._store.dispatch(be(r));
|
|
2481
|
+
});
|
|
2482
|
+
}), this._searcher.reset(), this;
|
|
2483
|
+
}, i.prototype.clearStore = function(e) {
|
|
2484
|
+
return e === void 0 && (e = !0), this.clearChoices(e, !0), this._stopSearch(), this._lastAddedChoiceId = 0, this._lastAddedGroupId = 0, this;
|
|
2485
|
+
}, i.prototype.clearInput = function() {
|
|
2486
|
+
var e = !this._isSelectOneElement;
|
|
2487
|
+
return this.input.clear(e), this._stopSearch(), this;
|
|
2488
|
+
}, i.prototype._validateConfig = function() {
|
|
2489
|
+
var e = this.config, t = ht(e, Oe);
|
|
2490
|
+
t.length && console.warn("Unknown config option(s) passed", t.join(", ")), e.allowHTML && e.allowHtmlUserInput && (e.addItems && console.warn("Warning: allowHTML/allowHtmlUserInput/addItems all being true is strongly not recommended and may lead to XSS attacks"), e.addChoices && console.warn("Warning: allowHTML/allowHtmlUserInput/addChoices all being true is strongly not recommended and may lead to XSS attacks"));
|
|
2491
|
+
}, i.prototype._render = function(e) {
|
|
2492
|
+
e === void 0 && (e = { choices: !0, groups: !0, items: !0 }), !this._store.inTxn() && (this._isSelectElement && (e.choices || e.groups) && this._renderChoices(), e.items && this._renderItems());
|
|
2493
|
+
}, i.prototype._renderChoices = function() {
|
|
2494
|
+
var e = this;
|
|
2495
|
+
if (this._canAddItems()) {
|
|
2496
|
+
var t = this, s = t.config, n = t._isSearching, r = this._store, o = r.activeGroups, a = r.activeChoices, l = n ? s.searchResultLimit : s.renderChoiceLimit;
|
|
2497
|
+
if (this._isSelectElement) {
|
|
2498
|
+
var h = a.filter(function(g) {
|
|
2499
|
+
return !g.element;
|
|
2500
|
+
});
|
|
2501
|
+
h.length && this.passedElement.addOptions(h);
|
|
2502
|
+
}
|
|
2503
|
+
var c = document.createDocumentFragment(), u = function(g) {
|
|
2504
|
+
return g.filter(function(y) {
|
|
2505
|
+
return !y.placeholder && (n ? (s.searchRenderSelectedChoices || !y.selected) && !!y.rank : s.renderSelectedChoices || !y.selected);
|
|
2506
|
+
});
|
|
2507
|
+
}, d = s.appendGroupInSearch && n, m = !1, f = null, p = function(g, y) {
|
|
2508
|
+
n ? g.sort(lt) : s.shouldSort && g.sort(s.sorter);
|
|
2509
|
+
var b = g.length;
|
|
2510
|
+
b = !y && l > 0 && b > l ? l : b, b--, g.every(function(C, B) {
|
|
2511
|
+
var Y = C.choiceEl || e._templates.choice(s, C, s.itemSelectText, d && C.group ? C.group.label : void 0);
|
|
2512
|
+
return C.choiceEl = Y, c.appendChild(Y), n || !C.selected ? m = !0 : f || (f = Y), B < b;
|
|
2513
|
+
});
|
|
2514
|
+
};
|
|
2515
|
+
a.length && (s.resetScrollPosition && requestAnimationFrame(function() {
|
|
2516
|
+
return e.choiceList.scrollToTop();
|
|
2517
|
+
}), !this._hasNonChoicePlaceholder && !n && this._isSelectOneElement && p(a.filter(function(g) {
|
|
2518
|
+
return g.placeholder && !g.group;
|
|
2519
|
+
}), !1), o.length && !n ? (s.shouldSort && o.sort(s.sorter), p(a.filter(function(g) {
|
|
2520
|
+
return !g.placeholder && !g.group;
|
|
2521
|
+
}), !1), o.forEach(function(g) {
|
|
2522
|
+
var y = u(g.choices);
|
|
2523
|
+
if (y.length) {
|
|
2524
|
+
if (g.label) {
|
|
2525
|
+
var b = g.groupEl || e._templates.choiceGroup(e.config, g);
|
|
2526
|
+
g.groupEl = b, b.remove(), c.appendChild(b);
|
|
2527
|
+
}
|
|
2528
|
+
p(y, !0);
|
|
2529
|
+
}
|
|
2530
|
+
})) : p(u(a), !1)), !m && (n || !c.children.length || !s.renderSelectedChoices) && (this._notice || (this._notice = {
|
|
2531
|
+
text: Ie(n ? s.noResultsText : s.noChoicesText),
|
|
2532
|
+
type: n ? S.noResults : S.noChoices
|
|
2533
|
+
}), c.replaceChildren("")), this._renderNotice(c), this.choiceList.element.replaceChildren(c), this._highlightChoice(f);
|
|
2534
|
+
}
|
|
2535
|
+
}, i.prototype._renderItems = function() {
|
|
2536
|
+
var e = this, t = this._store.items || [], s = this.itemList.element, n = this.config, r = document.createDocumentFragment(), o = function(u) {
|
|
2537
|
+
return s.querySelector('[data-item][data-id="'.concat(u.id, '"]'));
|
|
2538
|
+
}, a = function(u) {
|
|
2539
|
+
var d = u.itemEl;
|
|
2540
|
+
d && d.parentElement || (d = o(u) || e._templates.item(n, u, n.removeItemButton), u.itemEl = d, r.appendChild(d));
|
|
2541
|
+
};
|
|
2542
|
+
t.forEach(a);
|
|
2543
|
+
var l = !!r.childNodes.length;
|
|
2544
|
+
if (this._isSelectOneElement) {
|
|
2545
|
+
var h = s.children.length;
|
|
2546
|
+
if (l || h > 1) {
|
|
2547
|
+
var c = s.querySelector(W(n.classNames.placeholder));
|
|
2548
|
+
c && c.remove();
|
|
2549
|
+
} else !l && !h && this._placeholderValue && (l = !0, a(D({
|
|
2550
|
+
selected: !0,
|
|
2551
|
+
value: "",
|
|
2552
|
+
label: this._placeholderValue,
|
|
2553
|
+
placeholder: !0
|
|
2554
|
+
}, !1)));
|
|
2555
|
+
}
|
|
2556
|
+
l && (s.append(r), n.shouldSortItems && !this._isSelectOneElement && (t.sort(n.sorter), t.forEach(function(u) {
|
|
2557
|
+
var d = o(u);
|
|
2558
|
+
d && (d.remove(), r.append(d));
|
|
2559
|
+
}), s.append(r))), this._isTextElement && (this.passedElement.value = t.map(function(u) {
|
|
2560
|
+
var d = u.value;
|
|
2561
|
+
return d;
|
|
2562
|
+
}).join(n.delimiter));
|
|
2563
|
+
}, i.prototype._displayNotice = function(e, t, s) {
|
|
2564
|
+
s === void 0 && (s = !0);
|
|
2565
|
+
var n = this._notice;
|
|
2566
|
+
if (n && (n.type === t && n.text === e || n.type === S.addChoice && (t === S.noResults || t === S.noChoices))) {
|
|
2567
|
+
s && this.showDropdown(!0);
|
|
2568
|
+
return;
|
|
2569
|
+
}
|
|
2570
|
+
this._clearNotice(), this._notice = e ? {
|
|
2571
|
+
text: e,
|
|
2572
|
+
type: t
|
|
2573
|
+
} : void 0, this._renderNotice(), s && e && this.showDropdown(!0);
|
|
2574
|
+
}, i.prototype._clearNotice = function() {
|
|
2575
|
+
if (this._notice) {
|
|
2576
|
+
var e = this.choiceList.element.querySelector(W(this.config.classNames.notice));
|
|
2577
|
+
e && e.remove(), this._notice = void 0;
|
|
2578
|
+
}
|
|
2579
|
+
}, i.prototype._renderNotice = function(e) {
|
|
2580
|
+
var t = this._notice;
|
|
2581
|
+
if (t) {
|
|
2582
|
+
var s = this._templates.notice(this.config, t.text, t.type);
|
|
2583
|
+
e ? e.append(s) : this.choiceList.prepend(s);
|
|
2584
|
+
}
|
|
2585
|
+
}, i.prototype._getChoiceForOutput = function(e, t) {
|
|
2586
|
+
return M(e, t);
|
|
2587
|
+
}, i.prototype._triggerChange = function(e) {
|
|
2588
|
+
e != null && this.passedElement.triggerEvent(w.change, {
|
|
2589
|
+
value: e
|
|
2590
|
+
});
|
|
2591
|
+
}, i.prototype._handleButtonAction = function(e) {
|
|
2592
|
+
var t = this, s = this._store.items;
|
|
2593
|
+
if (!(!s.length || !this.config.removeItems || !this.config.removeItemButton)) {
|
|
2594
|
+
var n = e && ae(e.closest("[data-id]")), r = n && s.find(function(o) {
|
|
2595
|
+
return o.id === n;
|
|
2596
|
+
});
|
|
2597
|
+
r && this._store.withTxn(function() {
|
|
2598
|
+
if (t._removeItem(r), t._triggerChange(r.value), t._isSelectOneElement && !t._hasNonChoicePlaceholder) {
|
|
2599
|
+
var o = (t.config.shouldSort ? t._store.choices.reverse() : t._store.choices).find(function(a) {
|
|
2600
|
+
return a.placeholder;
|
|
2601
|
+
});
|
|
2602
|
+
o && (t._addItem(o), t.unhighlightAll(), o.value && t._triggerChange(o.value));
|
|
2603
|
+
}
|
|
2604
|
+
});
|
|
2605
|
+
}
|
|
2606
|
+
}, i.prototype._handleItemAction = function(e, t) {
|
|
2607
|
+
var s = this;
|
|
2608
|
+
t === void 0 && (t = !1);
|
|
2609
|
+
var n = this._store.items;
|
|
2610
|
+
if (!(!n.length || !this.config.removeItems || this._isSelectOneElement)) {
|
|
2611
|
+
var r = ae(e);
|
|
2612
|
+
r && (n.forEach(function(o) {
|
|
2613
|
+
o.id === r && !o.highlighted ? s.highlightItem(o) : !t && o.highlighted && s.unhighlightItem(o);
|
|
2614
|
+
}), this.input.focus());
|
|
2615
|
+
}
|
|
2616
|
+
}, i.prototype._handleChoiceAction = function(e) {
|
|
2617
|
+
var t = this, s = ae(e), n = s && this._store.getChoiceById(s);
|
|
2618
|
+
if (!n || n.disabled)
|
|
2619
|
+
return !1;
|
|
2620
|
+
var r = this.dropdown.isActive;
|
|
2621
|
+
if (!n.selected) {
|
|
2622
|
+
if (!this._canAddItems())
|
|
2623
|
+
return !0;
|
|
2624
|
+
this._store.withTxn(function() {
|
|
2625
|
+
t._addItem(n, !0, !0), t.clearInput(), t.unhighlightAll();
|
|
2626
|
+
}), this._triggerChange(n.value);
|
|
2627
|
+
}
|
|
2628
|
+
return r && this.config.closeDropdownOnSelect && (this.hideDropdown(!0), this.containerOuter.element.focus()), !0;
|
|
2629
|
+
}, i.prototype._handleBackspace = function(e) {
|
|
2630
|
+
var t = this.config;
|
|
2631
|
+
if (!(!t.removeItems || !e.length)) {
|
|
2632
|
+
var s = e[e.length - 1], n = e.some(function(r) {
|
|
2633
|
+
return r.highlighted;
|
|
2634
|
+
});
|
|
2635
|
+
t.editItems && !n && s ? (this.input.value = s.value, this.input.setWidth(), this._removeItem(s), this._triggerChange(s.value)) : (n || this.highlightItem(s, !1), this.removeHighlightedItems(!0));
|
|
2636
|
+
}
|
|
2637
|
+
}, i.prototype._loadChoices = function() {
|
|
2638
|
+
var e, t = this, s = this.config;
|
|
2639
|
+
if (this._isTextElement) {
|
|
2640
|
+
if (this._presetChoices = s.items.map(function(o) {
|
|
2641
|
+
return D(o, !1);
|
|
2642
|
+
}), this.passedElement.value) {
|
|
2643
|
+
var n = this.passedElement.value.split(s.delimiter).map(function(o) {
|
|
2644
|
+
return D(o, !1, t.config.allowHtmlUserInput);
|
|
2645
|
+
});
|
|
2646
|
+
this._presetChoices = this._presetChoices.concat(n);
|
|
2647
|
+
}
|
|
2648
|
+
this._presetChoices.forEach(function(o) {
|
|
2649
|
+
o.selected = !0;
|
|
2650
|
+
});
|
|
2651
|
+
} else if (this._isSelectElement) {
|
|
2652
|
+
this._presetChoices = s.choices.map(function(o) {
|
|
2653
|
+
return D(o, !0);
|
|
2654
|
+
});
|
|
2655
|
+
var r = this.passedElement.optionsAsChoices();
|
|
2656
|
+
r && (e = this._presetChoices).push.apply(e, r);
|
|
2657
|
+
}
|
|
2658
|
+
}, i.prototype._handleLoadingState = function(e) {
|
|
2659
|
+
e === void 0 && (e = !0);
|
|
2660
|
+
var t = this.itemList.element;
|
|
2661
|
+
e ? (this.disable(), this.containerOuter.addLoadingState(), this._isSelectOneElement ? t.replaceChildren(this._templates.placeholder(this.config, this.config.loadingText)) : this.input.placeholder = this.config.loadingText) : (this.enable(), this.containerOuter.removeLoadingState(), this._isSelectOneElement ? (t.replaceChildren(""), this._render()) : this.input.placeholder = this._placeholderValue || "");
|
|
2662
|
+
}, i.prototype._handleSearch = function(e) {
|
|
2663
|
+
if (this.input.isFocussed)
|
|
2664
|
+
if (e !== null && typeof e < "u" && e.length >= this.config.searchFloor) {
|
|
2665
|
+
var t = this.config.searchChoices ? this._searchChoices(e) : 0;
|
|
2666
|
+
t !== null && this.passedElement.triggerEvent(w.search, {
|
|
2667
|
+
value: e,
|
|
2668
|
+
resultCount: t
|
|
2669
|
+
});
|
|
2670
|
+
} else this._store.choices.some(function(s) {
|
|
2671
|
+
return !s.active;
|
|
2672
|
+
}) && this._stopSearch();
|
|
2673
|
+
}, i.prototype._canAddItems = function() {
|
|
2674
|
+
var e = this.config, t = e.maxItemCount, s = e.maxItemText;
|
|
2675
|
+
return !e.singleModeForMultiSelect && t > 0 && t <= this._store.items.length ? (this.choiceList.element.replaceChildren(""), this._notice = void 0, this._displayNotice(typeof s == "function" ? s(t) : s, S.addChoice), !1) : (this._notice && this._notice.type === S.addChoice && this._clearNotice(), !0);
|
|
2676
|
+
}, i.prototype._canCreateItem = function(e) {
|
|
2677
|
+
var t = this.config, s = !0, n = "";
|
|
2678
|
+
if (s && typeof t.addItemFilter == "function" && !t.addItemFilter(e) && (s = !1, n = X(t.customAddItemText, e, void 0)), s) {
|
|
2679
|
+
var r = this._store.choices.find(function(o) {
|
|
2680
|
+
return t.valueComparer(o.value, e);
|
|
2681
|
+
});
|
|
2682
|
+
if (r) {
|
|
2683
|
+
if (this._isSelectElement)
|
|
2684
|
+
return this._displayNotice("", S.addChoice), !1;
|
|
2685
|
+
t.duplicateItemsAllowed || (s = !1, n = X(t.uniqueItemText, e, void 0));
|
|
2686
|
+
}
|
|
2687
|
+
}
|
|
2688
|
+
return s && (n = X(t.addItemText, e, void 0)), n && this._displayNotice(n, S.addChoice), s;
|
|
2689
|
+
}, i.prototype._searchChoices = function(e) {
|
|
2690
|
+
var t = e.trim().replace(/\s{2,}/, " ");
|
|
2691
|
+
if (!t.length || t === this._currentValue)
|
|
2692
|
+
return null;
|
|
2693
|
+
var s = this._searcher;
|
|
2694
|
+
s.isEmptyIndex() && s.index(this._store.searchableChoices);
|
|
2695
|
+
var n = s.search(t);
|
|
2696
|
+
this._currentValue = t, this._highlightPosition = 0, this._isSearching = !0;
|
|
2697
|
+
var r = this._notice, o = r && r.type;
|
|
2698
|
+
return o !== S.addChoice && (n.length ? this._clearNotice() : this._displayNotice(Ie(this.config.noResultsText), S.noResults)), this._store.dispatch(et(n)), n.length;
|
|
2699
|
+
}, i.prototype._stopSearch = function() {
|
|
2700
|
+
this._isSearching && (this._currentValue = "", this._isSearching = !1, this._clearNotice(), this._store.dispatch(tt(!0)), this.passedElement.triggerEvent(w.search, {
|
|
2701
|
+
value: "",
|
|
2702
|
+
resultCount: 0
|
|
2703
|
+
}));
|
|
2704
|
+
}, i.prototype._addEventListeners = function() {
|
|
2705
|
+
var e = this._docRoot, t = this.containerOuter.element, s = this.input.element, n = this.passedElement.element;
|
|
2706
|
+
e.addEventListener("touchend", this._onTouchEnd, !0), t.addEventListener("keydown", this._onKeyDown, !0), t.addEventListener("mousedown", this._onMouseDown, !0), e.addEventListener("click", this._onClick, { passive: !0 }), e.addEventListener("touchmove", this._onTouchMove, {
|
|
2707
|
+
passive: !0
|
|
2708
|
+
}), this.dropdown.element.addEventListener("mouseover", this._onMouseOver, {
|
|
2709
|
+
passive: !0
|
|
2710
|
+
}), this._isSelectOneElement && (t.addEventListener("focus", this._onFocus, {
|
|
2711
|
+
passive: !0
|
|
2712
|
+
}), t.addEventListener("blur", this._onBlur, {
|
|
2713
|
+
passive: !0
|
|
2714
|
+
})), s.addEventListener("keyup", this._onKeyUp, {
|
|
2715
|
+
passive: !0
|
|
2716
|
+
}), s.addEventListener("input", this._onInput, {
|
|
2717
|
+
passive: !0
|
|
2718
|
+
}), s.addEventListener("focus", this._onFocus, {
|
|
2719
|
+
passive: !0
|
|
2720
|
+
}), s.addEventListener("blur", this._onBlur, {
|
|
2721
|
+
passive: !0
|
|
2722
|
+
}), s.form && s.form.addEventListener("reset", this._onFormReset, {
|
|
2723
|
+
passive: !0
|
|
2724
|
+
}), n.hasAttribute("required") && (n.addEventListener("change", this._onChange, {
|
|
2725
|
+
passive: !0
|
|
2726
|
+
}), n.addEventListener("invalid", this._onInvalid, {
|
|
2727
|
+
passive: !0
|
|
2728
|
+
})), this.input.addEventListeners();
|
|
2729
|
+
}, i.prototype._removeEventListeners = function() {
|
|
2730
|
+
var e = this._docRoot, t = this.containerOuter.element, s = this.input.element, n = this.passedElement.element;
|
|
2731
|
+
e.removeEventListener("touchend", this._onTouchEnd, !0), t.removeEventListener("keydown", this._onKeyDown, !0), t.removeEventListener("mousedown", this._onMouseDown, !0), e.removeEventListener("click", this._onClick), e.removeEventListener("touchmove", this._onTouchMove), this.dropdown.element.removeEventListener("mouseover", this._onMouseOver), this._isSelectOneElement && (t.removeEventListener("focus", this._onFocus), t.removeEventListener("blur", this._onBlur)), s.removeEventListener("keyup", this._onKeyUp), s.removeEventListener("input", this._onInput), s.removeEventListener("focus", this._onFocus), s.removeEventListener("blur", this._onBlur), s.form && s.form.removeEventListener("reset", this._onFormReset), n.hasAttribute("required") && (n.removeEventListener("change", this._onChange), n.removeEventListener("invalid", this._onInvalid)), this.input.removeEventListeners();
|
|
2732
|
+
}, i.prototype._onKeyDown = function(e) {
|
|
2733
|
+
var t = e.keyCode, s = this.dropdown.isActive, n = e.key.length === 1 || e.key.length === 2 && e.key.charCodeAt(0) >= 55296 || e.key === "Unidentified";
|
|
2734
|
+
switch (!this._isTextElement && !s && t !== I.ESC_KEY && t !== I.TAB_KEY && t !== I.SHIFT_KEY && (this.showDropdown(), !this.input.isFocussed && n && (this.input.value += e.key, e.key === " " && e.preventDefault())), t) {
|
|
2735
|
+
case I.A_KEY:
|
|
2736
|
+
return this._onSelectKey(e, this.itemList.element.hasChildNodes());
|
|
2737
|
+
case I.ENTER_KEY:
|
|
2738
|
+
return this._onEnterKey(e, s);
|
|
2739
|
+
case I.ESC_KEY:
|
|
2740
|
+
return this._onEscapeKey(e, s);
|
|
2741
|
+
case I.UP_KEY:
|
|
2742
|
+
case I.PAGE_UP_KEY:
|
|
2743
|
+
case I.DOWN_KEY:
|
|
2744
|
+
case I.PAGE_DOWN_KEY:
|
|
2745
|
+
return this._onDirectionKey(e, s);
|
|
2746
|
+
case I.DELETE_KEY:
|
|
2747
|
+
case I.BACK_KEY:
|
|
2748
|
+
return this._onDeleteKey(e, this._store.items, this.input.isFocussed);
|
|
2749
|
+
}
|
|
2750
|
+
}, i.prototype._onKeyUp = function() {
|
|
2751
|
+
this._canSearch = this.config.searchEnabled;
|
|
2752
|
+
}, i.prototype._onInput = function() {
|
|
2753
|
+
var e = this.input.value;
|
|
2754
|
+
if (!e) {
|
|
2755
|
+
this._isTextElement ? this.hideDropdown(!0) : this._stopSearch();
|
|
2756
|
+
return;
|
|
2757
|
+
}
|
|
2758
|
+
this._canAddItems() && (this._canSearch && this._handleSearch(e), this._canAddUserChoices && (this._canCreateItem(e), this._isSelectElement && (this._highlightPosition = 0, this._highlightChoice())));
|
|
2759
|
+
}, i.prototype._onSelectKey = function(e, t) {
|
|
2760
|
+
if ((e.ctrlKey || e.metaKey) && t) {
|
|
2761
|
+
this._canSearch = !1;
|
|
2762
|
+
var s = this.config.removeItems && !this.input.value && this.input.element === document.activeElement;
|
|
2763
|
+
s && this.highlightAll();
|
|
2764
|
+
}
|
|
2765
|
+
}, i.prototype._onEnterKey = function(e, t) {
|
|
2766
|
+
var s = this, n = this.input.value, r = e.target;
|
|
2767
|
+
if (e.preventDefault(), r && r.hasAttribute("data-button")) {
|
|
2768
|
+
this._handleButtonAction(r);
|
|
2769
|
+
return;
|
|
2770
|
+
}
|
|
2771
|
+
if (!t) {
|
|
2772
|
+
(this._isSelectElement || this._notice) && this.showDropdown();
|
|
2773
|
+
return;
|
|
2774
|
+
}
|
|
2775
|
+
var o = this.dropdown.element.querySelector(W(this.config.classNames.highlightedState));
|
|
2776
|
+
if (!(o && this._handleChoiceAction(o))) {
|
|
2777
|
+
if (!r || !n) {
|
|
2778
|
+
this.hideDropdown(!0);
|
|
2779
|
+
return;
|
|
2780
|
+
}
|
|
2781
|
+
if (this._canAddItems()) {
|
|
2782
|
+
var a = !1;
|
|
2783
|
+
this._store.withTxn(function() {
|
|
2784
|
+
if (a = s._findAndSelectChoiceByValue(n, !0), !a) {
|
|
2785
|
+
if (!s._canAddUserChoices || !s._canCreateItem(n))
|
|
2786
|
+
return;
|
|
2787
|
+
s._addChoice(D(n, !1, s.config.allowHtmlUserInput), !0, !0), a = !0;
|
|
2788
|
+
}
|
|
2789
|
+
s.clearInput(), s.unhighlightAll();
|
|
2790
|
+
}), a && (this._triggerChange(n), this.config.closeDropdownOnSelect && this.hideDropdown(!0));
|
|
2791
|
+
}
|
|
2792
|
+
}
|
|
2793
|
+
}, i.prototype._onEscapeKey = function(e, t) {
|
|
2794
|
+
t && (e.stopPropagation(), this.hideDropdown(!0), this._stopSearch(), this.containerOuter.element.focus());
|
|
2795
|
+
}, i.prototype._onDirectionKey = function(e, t) {
|
|
2796
|
+
var s = e.keyCode;
|
|
2797
|
+
if (t || this._isSelectOneElement) {
|
|
2798
|
+
this.showDropdown(), this._canSearch = !1;
|
|
2799
|
+
var n = s === I.DOWN_KEY || s === I.PAGE_DOWN_KEY ? 1 : -1, r = e.metaKey || s === I.PAGE_DOWN_KEY || s === I.PAGE_UP_KEY, o = void 0;
|
|
2800
|
+
if (r)
|
|
2801
|
+
n > 0 ? o = this.dropdown.element.querySelector("".concat(q, ":last-of-type")) : o = this.dropdown.element.querySelector(q);
|
|
2802
|
+
else {
|
|
2803
|
+
var a = this.dropdown.element.querySelector(W(this.config.classNames.highlightedState));
|
|
2804
|
+
a ? o = rt(a, q, n) : o = this.dropdown.element.querySelector(q);
|
|
2805
|
+
}
|
|
2806
|
+
o && (Se(o, this.choiceList.element, n) || this.choiceList.scrollToChildElement(o, n), this._highlightChoice(o)), e.preventDefault();
|
|
2807
|
+
}
|
|
2808
|
+
}, i.prototype._onDeleteKey = function(e, t, s) {
|
|
2809
|
+
!this._isSelectOneElement && !e.target.value && s && (this._handleBackspace(t), e.preventDefault());
|
|
2810
|
+
}, i.prototype._onTouchMove = function() {
|
|
2811
|
+
this._wasTap && (this._wasTap = !1);
|
|
2812
|
+
}, i.prototype._onTouchEnd = function(e) {
|
|
2813
|
+
var t = (e || e.touches[0]).target, s = this._wasTap && this.containerOuter.element.contains(t);
|
|
2814
|
+
if (s) {
|
|
2815
|
+
var n = t === this.containerOuter.element || t === this.containerInner.element;
|
|
2816
|
+
n && (this._isTextElement ? this.input.focus() : this._isSelectMultipleElement && this.showDropdown()), e.stopPropagation();
|
|
2817
|
+
}
|
|
2818
|
+
this._wasTap = !0;
|
|
2819
|
+
}, i.prototype._onMouseDown = function(e) {
|
|
2820
|
+
var t = e.target;
|
|
2821
|
+
if (t instanceof Element) {
|
|
2822
|
+
if (gi && this.choiceList.element.contains(t)) {
|
|
2823
|
+
var s = this.choiceList.element.firstElementChild;
|
|
2824
|
+
this._isScrollingOnIe = this._direction === "ltr" ? e.offsetX >= s.offsetWidth : e.offsetX < s.offsetLeft;
|
|
2825
|
+
}
|
|
2826
|
+
if (t !== this.input.element) {
|
|
2827
|
+
var n = t.closest("[data-button],[data-item],[data-choice]");
|
|
2828
|
+
n instanceof HTMLElement && ("button" in n.dataset ? this._handleButtonAction(n) : "item" in n.dataset ? this._handleItemAction(n, e.shiftKey) : "choice" in n.dataset && this._handleChoiceAction(n)), e.preventDefault();
|
|
2829
|
+
}
|
|
2830
|
+
}
|
|
2831
|
+
}, i.prototype._onMouseOver = function(e) {
|
|
2832
|
+
var t = e.target;
|
|
2833
|
+
t instanceof HTMLElement && "choice" in t.dataset && this._highlightChoice(t);
|
|
2834
|
+
}, i.prototype._onClick = function(e) {
|
|
2835
|
+
var t = e.target, s = this.containerOuter, n = s.element.contains(t);
|
|
2836
|
+
n ? !this.dropdown.isActive && !s.isDisabled ? this._isTextElement ? document.activeElement !== this.input.element && this.input.focus() : (this.showDropdown(), s.element.focus()) : this._isSelectOneElement && t !== this.input.element && !this.dropdown.element.contains(t) && this.hideDropdown() : (s.removeFocusState(), this.hideDropdown(!0), this.unhighlightAll());
|
|
2837
|
+
}, i.prototype._onFocus = function(e) {
|
|
2838
|
+
var t = e.target, s = this.containerOuter, n = t && s.element.contains(t);
|
|
2839
|
+
if (n) {
|
|
2840
|
+
var r = t === this.input.element;
|
|
2841
|
+
this._isTextElement ? r && s.addFocusState() : this._isSelectMultipleElement ? r && (this.showDropdown(!0), s.addFocusState()) : (s.addFocusState(), r && this.showDropdown(!0));
|
|
2842
|
+
}
|
|
2843
|
+
}, i.prototype._onBlur = function(e) {
|
|
2844
|
+
var t = e.target, s = this.containerOuter, n = t && s.element.contains(t);
|
|
2845
|
+
n && !this._isScrollingOnIe ? t === this.input.element ? (s.removeFocusState(), this.hideDropdown(!0), (this._isTextElement || this._isSelectMultipleElement) && this.unhighlightAll()) : t === this.containerOuter.element && (s.removeFocusState(), this.config.searchEnabled || this.hideDropdown(!0)) : (this._isScrollingOnIe = !1, this.input.element.focus());
|
|
2846
|
+
}, i.prototype._onFormReset = function() {
|
|
2847
|
+
var e = this;
|
|
2848
|
+
this._store.withTxn(function() {
|
|
2849
|
+
e.clearInput(), e.hideDropdown(), e.refresh(!1, !1, !0), e._initialItems.length && e.setChoiceByValue(e._initialItems);
|
|
2850
|
+
});
|
|
2851
|
+
}, i.prototype._onChange = function(e) {
|
|
2852
|
+
e.target.checkValidity() && this.containerOuter.removeInvalidState();
|
|
2853
|
+
}, i.prototype._onInvalid = function() {
|
|
2854
|
+
this.containerOuter.addInvalidState();
|
|
2855
|
+
}, i.prototype._removeHighlightedChoices = function() {
|
|
2856
|
+
var e = this.config.classNames.highlightedState, t = Array.from(this.dropdown.element.querySelectorAll(W(e)));
|
|
2857
|
+
t.forEach(function(s) {
|
|
2858
|
+
L(s, e), s.setAttribute("aria-selected", "false");
|
|
2859
|
+
});
|
|
2860
|
+
}, i.prototype._highlightChoice = function(e) {
|
|
2861
|
+
e === void 0 && (e = null);
|
|
2862
|
+
var t = Array.from(this.dropdown.element.querySelectorAll(q));
|
|
2863
|
+
if (t.length) {
|
|
2864
|
+
var s = e, n = this.config.classNames.highlightedState;
|
|
2865
|
+
this._removeHighlightedChoices(), s ? this._highlightPosition = t.indexOf(s) : (t.length > this._highlightPosition ? s = t[this._highlightPosition] : s = t[t.length - 1], s || (s = t[0])), _(s, n), s.setAttribute("aria-selected", "true"), this.passedElement.triggerEvent(w.highlightChoice, {
|
|
2866
|
+
el: s
|
|
2867
|
+
}), this.dropdown.isActive && (this.input.setActiveDescendant(s.id), this.containerOuter.setActiveDescendant(s.id));
|
|
2868
|
+
}
|
|
2869
|
+
}, i.prototype._addItem = function(e, t, s) {
|
|
2870
|
+
if (t === void 0 && (t = !0), s === void 0 && (s = !1), !e.id)
|
|
2871
|
+
throw new TypeError("item.id must be set before _addItem is called for a choice/item");
|
|
2872
|
+
if ((this.config.singleModeForMultiSelect || this._isSelectOneElement) && this.removeActiveItems(e.id), this._store.dispatch(be(e)), t) {
|
|
2873
|
+
var n = M(e);
|
|
2874
|
+
this.passedElement.triggerEvent(w.addItem, n), s && this.passedElement.triggerEvent(w.choice, n);
|
|
2875
|
+
}
|
|
2876
|
+
}, i.prototype._removeItem = function(e) {
|
|
2877
|
+
if (e.id) {
|
|
2878
|
+
this._store.dispatch(Ee(e));
|
|
2879
|
+
var t = this._notice;
|
|
2880
|
+
t && t.type === S.noChoices && this._clearNotice(), this.passedElement.triggerEvent(w.removeItem, M(e));
|
|
2881
|
+
}
|
|
2882
|
+
}, i.prototype._addChoice = function(e, t, s) {
|
|
2883
|
+
if (t === void 0 && (t = !0), s === void 0 && (s = !1), e.id)
|
|
2884
|
+
throw new TypeError("Can not re-add a choice which has already been added");
|
|
2885
|
+
var n = this.config;
|
|
2886
|
+
if (!(!n.duplicateItemsAllowed && this._store.choices.find(function(a) {
|
|
2887
|
+
return n.valueComparer(a.value, e.value);
|
|
2888
|
+
}))) {
|
|
2889
|
+
this._lastAddedChoiceId++, e.id = this._lastAddedChoiceId, e.elementId = "".concat(this._baseId, "-").concat(this._idNames.itemChoice, "-").concat(e.id);
|
|
2890
|
+
var r = n.prependValue, o = n.appendValue;
|
|
2891
|
+
r && (e.value = r + e.value), o && (e.value += o.toString()), (r || o) && e.element && (e.element.value = e.value), this._clearNotice(), this._store.dispatch(ye(e)), e.selected && this._addItem(e, t, s);
|
|
2892
|
+
}
|
|
2893
|
+
}, i.prototype._addGroup = function(e, t) {
|
|
2894
|
+
var s = this;
|
|
2895
|
+
if (t === void 0 && (t = !0), e.id)
|
|
2896
|
+
throw new TypeError("Can not re-add a group which has already been added");
|
|
2897
|
+
this._store.dispatch(it(e)), e.choices && (this._lastAddedGroupId++, e.id = this._lastAddedGroupId, e.choices.forEach(function(n) {
|
|
2898
|
+
n.group = e, e.disabled && (n.disabled = !0), s._addChoice(n, t);
|
|
2899
|
+
}));
|
|
2900
|
+
}, i.prototype._createTemplates = function() {
|
|
2901
|
+
var e = this, t = this.config.callbackOnCreateTemplates, s = {};
|
|
2902
|
+
typeof t == "function" && (s = t.call(this, ot, me, ie));
|
|
2903
|
+
var n = {};
|
|
2904
|
+
Object.keys(this._templates).forEach(function(r) {
|
|
2905
|
+
r in s ? n[r] = s[r].bind(e) : n[r] = e._templates[r].bind(e);
|
|
2906
|
+
}), this._templates = n;
|
|
2907
|
+
}, i.prototype._createElements = function() {
|
|
2908
|
+
var e = this._templates, t = this, s = t.config, n = t._isSelectOneElement, r = s.position, o = s.classNames, a = this._elementType;
|
|
2909
|
+
this.containerOuter = new we({
|
|
2910
|
+
element: e.containerOuter(s, this._direction, this._isSelectElement, n, s.searchEnabled, a, s.labelId),
|
|
2911
|
+
classNames: o,
|
|
2912
|
+
type: a,
|
|
2913
|
+
position: r
|
|
2914
|
+
}), this.containerInner = new we({
|
|
2915
|
+
element: e.containerInner(s),
|
|
2916
|
+
classNames: o,
|
|
2917
|
+
type: a,
|
|
2918
|
+
position: r
|
|
2919
|
+
}), this.input = new pt({
|
|
2920
|
+
element: e.input(s, this._placeholderValue),
|
|
2921
|
+
classNames: o,
|
|
2922
|
+
type: a,
|
|
2923
|
+
preventPaste: !s.paste
|
|
2924
|
+
}), this.choiceList = new Ae({
|
|
2925
|
+
element: e.choiceList(s, n)
|
|
2926
|
+
}), this.itemList = new Ae({
|
|
2927
|
+
element: e.itemList(s, n)
|
|
2928
|
+
}), this.dropdown = new ft({
|
|
2929
|
+
element: e.dropdown(s),
|
|
2930
|
+
classNames: o,
|
|
2931
|
+
type: a
|
|
2932
|
+
});
|
|
2933
|
+
}, i.prototype._createStructure = function() {
|
|
2934
|
+
var e = this, t = e.containerInner, s = e.containerOuter, n = e.passedElement, r = this.dropdown.element;
|
|
2935
|
+
n.conceal(), t.wrap(n.element), s.wrap(t.element), s.element.appendChild(t.element), s.element.appendChild(r), t.element.appendChild(this.itemList.element), r.appendChild(this.choiceList.element), this._isSelectOneElement ? (this.input.placeholder = this.config.searchPlaceholderValue || "", this.config.searchEnabled && r.insertBefore(this.input.element, r.firstChild)) : ((!this._isSelectMultipleElement || this.config.searchEnabled) && t.element.appendChild(this.input.element), this._placeholderValue && (this.input.placeholder = this._placeholderValue), this.input.setWidth()), this._highlightPosition = 0, this._isSearching = !1;
|
|
2936
|
+
}, i.prototype._initStore = function() {
|
|
2937
|
+
var e = this;
|
|
2938
|
+
this._store.subscribe(this._render).withTxn(function() {
|
|
2939
|
+
e._addPredefinedChoices(e._presetChoices, e._isSelectOneElement && !e._hasNonChoicePlaceholder, !1);
|
|
2940
|
+
}), (!this._store.choices.length || this._isSelectOneElement && this._hasNonChoicePlaceholder) && this._render();
|
|
2941
|
+
}, i.prototype._addPredefinedChoices = function(e, t, s) {
|
|
2942
|
+
var n = this;
|
|
2943
|
+
if (t === void 0 && (t = !1), s === void 0 && (s = !0), t) {
|
|
2944
|
+
var r = e.findIndex(function(o) {
|
|
2945
|
+
return o.selected;
|
|
2946
|
+
}) === -1;
|
|
2947
|
+
r && e.some(function(o) {
|
|
2948
|
+
return o.disabled || "choices" in o ? !1 : (o.selected = !0, !0);
|
|
2949
|
+
});
|
|
2950
|
+
}
|
|
2951
|
+
e.forEach(function(o) {
|
|
2952
|
+
"choices" in o ? n._isSelectElement && n._addGroup(o, s) : n._addChoice(o, s);
|
|
2953
|
+
});
|
|
2954
|
+
}, i.prototype._findAndSelectChoiceByValue = function(e, t) {
|
|
2955
|
+
var s = this;
|
|
2956
|
+
t === void 0 && (t = !1);
|
|
2957
|
+
var n = this._store.choices.find(function(r) {
|
|
2958
|
+
return s.config.valueComparer(r.value, e);
|
|
2959
|
+
});
|
|
2960
|
+
return n && !n.disabled && !n.selected ? (this._addItem(n, !0, t), !0) : !1;
|
|
2961
|
+
}, i.prototype._generatePlaceholderValue = function() {
|
|
2962
|
+
var e = this.config;
|
|
2963
|
+
if (!e.placeholder)
|
|
2964
|
+
return null;
|
|
2965
|
+
if (this._hasNonChoicePlaceholder)
|
|
2966
|
+
return e.placeholderValue;
|
|
2967
|
+
if (this._isSelectElement) {
|
|
2968
|
+
var t = this.passedElement.placeholderOption;
|
|
2969
|
+
return t ? t.text : null;
|
|
2970
|
+
}
|
|
2971
|
+
return null;
|
|
2972
|
+
}, i.prototype._warnChoicesInitFailed = function(e) {
|
|
2973
|
+
if (!this.config.silent)
|
|
2974
|
+
if (this.initialised) {
|
|
2975
|
+
if (!this.initialisedOK)
|
|
2976
|
+
throw new TypeError("".concat(e, " called for an element which has multiple instances of Choices initialised on it"));
|
|
2977
|
+
} else throw new TypeError("".concat(e, " called on a non-initialised instance of Choices"));
|
|
2978
|
+
}, i.version = "11.2.1", i;
|
|
2979
|
+
})()
|
|
2980
|
+
);
|
|
2981
|
+
export {
|
|
2982
|
+
Ei as C
|
|
2983
|
+
};
|
|
2984
|
+
//# sourceMappingURL=choices.js.map
|