slim-select 3.6.1 → 4.0.1
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/README.md +166 -147
- package/dist/animations.d.ts +37 -0
- package/dist/classes.d.ts +5 -0
- package/dist/events.d.ts +26 -0
- package/dist/helpers.d.ts +19 -0
- package/dist/index.d.ts +14 -8
- package/dist/lifecycle.d.ts +53 -0
- package/dist/mutations.d.ts +31 -0
- package/dist/react/index.js +998 -487
- package/dist/react/index.umd.js +1 -6
- package/dist/react/react.d.ts +1 -2
- package/dist/render.d.ts +58 -4
- package/dist/settings.d.ts +4 -1
- package/dist/slimselect.cjs.js +1 -1
- package/dist/slimselect.cjs.js.map +1 -1
- package/dist/slimselect.css +1 -1
- package/dist/slimselect.css.map +1 -1
- package/dist/slimselect.es.js +969 -292
- package/dist/slimselect.es.js.map +1 -1
- package/dist/slimselect.iife.js +1 -1
- package/dist/slimselect.iife.js.map +1 -1
- package/dist/slimselect.js +1 -1
- package/dist/slimselect.js.map +1 -1
- package/dist/src/docs/nav.d.ts +20 -0
- package/dist/store.d.ts +13 -4
- package/dist/sync.d.ts +78 -0
- package/dist/vue/helpers.d.ts +2 -0
- package/dist/vue/index.js +1000 -299
- package/dist/vue/index.umd.js +1 -1
- package/package.json +12 -9
- package/src/slim-select/slimselect.scss +223 -67
package/dist/vue/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { createElementBlock as e, defineComponent as t,
|
|
1
|
+
import { createElementBlock as e, defineComponent as t, isReactive as n, isRef as r, openBlock as i, toRaw as a, unref as o } from "vue";
|
|
2
2
|
//#region src/slim-select/classes.ts
|
|
3
|
-
var
|
|
3
|
+
var s = class {
|
|
4
4
|
main;
|
|
5
5
|
placeholder;
|
|
6
6
|
values;
|
|
@@ -38,6 +38,11 @@ var i = class {
|
|
|
38
38
|
option;
|
|
39
39
|
optionDelete;
|
|
40
40
|
highlighted;
|
|
41
|
+
modalOverlay;
|
|
42
|
+
modalDialog;
|
|
43
|
+
modalTitle;
|
|
44
|
+
modalClose;
|
|
45
|
+
modalContent;
|
|
41
46
|
mainOpen;
|
|
42
47
|
close;
|
|
43
48
|
selected;
|
|
@@ -47,18 +52,132 @@ var i = class {
|
|
|
47
52
|
constructor(e) {
|
|
48
53
|
e ||= {};
|
|
49
54
|
let t = (e = "", t = "") => `${e} ${t}`.trim();
|
|
50
|
-
this.main = t("ss-main", e.main), this.placeholder = t("ss-placeholder", e.placeholder), this.values = t("ss-values", e.values), this.single = t("ss-single", e.single), this.multiString = t("ss-multi-string", e.multiString), this.max = t("ss-max", e.max), this.value = t("ss-value", e.value), this.valueText = t("ss-value-text", e.valueText), this.valueDelete = t("ss-value-delete", e.valueDelete), this.valueOut = t("ss-value-out", e.valueOut), this.deselect = t("ss-deselect", e.deselect), this.deselectPath = e.deselectPath || "M10,10 L90,90 M10,90 L90,10", this.arrow = t("ss-arrow", e.arrow), this.arrowClose = e.arrowClose || "M10,30 L50,70 L90,30", this.arrowOpen = e.arrowOpen || "M10,70 L50,30 L90,70", this.content = t("ss-content", e.content), this.contentOpen = t("ss-open", e.contentOpen), this.dirAbove = t("ss-dir-above", e.dirAbove), this.dirBelow = t("ss-dir-below", e.dirBelow), this.search = t("ss-search", e.search), this.searchHighlighter = t("ss-search-highlight", e.searchHighlighter), this.searching = t("ss-searching", e.searching), this.status = t("ss-status", e.status), this.addable = t("ss-addable", e.addable), this.addablePath = e.addablePath || "M50,10 L50,90 M10,50 L90,50", this.list = t("ss-list", e.list), this.optgroup = t("ss-optgroup", e.optgroup), this.optgroupLabel = t("ss-optgroup-label", e.optgroupLabel), this.optgroupLabelText = t("ss-optgroup-label-text", e.optgroupLabelText), this.optgroupActions = t("ss-optgroup-actions", e.optgroupActions), this.optgroupSelectAll = t("ss-selectall", e.optgroupSelectAll), this.optgroupSelectAllBox = e.optgroupSelectAllBox || "M60,10 L10,10 L10,90 L90,90 L90,50", this.optgroupSelectAllCheck = e.optgroupSelectAllCheck || "M30,45 L50,70 L90,10", this.optgroupClosable = t("ss-closable", e.optgroupClosable), this.option = t("ss-option", e.option), this.optionDelete = e.optionDelete || "M10,10 L90,90 M10,90 L90,10", this.highlighted = t("ss-highlighted", e.highlighted), this.mainOpen = t("ss-open", e.mainOpen), this.close = t("ss-close", e.close), this.selected = t("ss-selected", e.selected), this.error = t("ss-error", e.error), this.disabled = t("ss-disabled", e.disabled), this.hide = t("ss-hide", e.hide);
|
|
55
|
+
this.main = t("ss-main", e.main), this.placeholder = t("ss-placeholder", e.placeholder), this.values = t("ss-values", e.values), this.single = t("ss-single", e.single), this.multiString = t("ss-multi-string", e.multiString), this.max = t("ss-max", e.max), this.value = t("ss-value", e.value), this.valueText = t("ss-value-text", e.valueText), this.valueDelete = t("ss-value-delete", e.valueDelete), this.valueOut = t("ss-value-out", e.valueOut), this.deselect = t("ss-deselect", e.deselect), this.deselectPath = e.deselectPath || "M10,10 L90,90 M10,90 L90,10", this.arrow = t("ss-arrow", e.arrow), this.arrowClose = e.arrowClose || "M10,30 L50,70 L90,30", this.arrowOpen = e.arrowOpen || "M10,70 L50,30 L90,70", this.content = t("ss-content", e.content), this.contentOpen = t("ss-open", e.contentOpen), this.dirAbove = t("ss-dir-above", e.dirAbove), this.dirBelow = t("ss-dir-below", e.dirBelow), this.search = t("ss-search", e.search), this.searchHighlighter = t("ss-search-highlight", e.searchHighlighter), this.searching = t("ss-searching", e.searching), this.status = t("ss-status", e.status), this.addable = t("ss-addable", e.addable), this.addablePath = e.addablePath || "M50,10 L50,90 M10,50 L90,50", this.list = t("ss-list", e.list), this.optgroup = t("ss-optgroup", e.optgroup), this.optgroupLabel = t("ss-optgroup-label", e.optgroupLabel), this.optgroupLabelText = t("ss-optgroup-label-text", e.optgroupLabelText), this.optgroupActions = t("ss-optgroup-actions", e.optgroupActions), this.optgroupSelectAll = t("ss-selectall", e.optgroupSelectAll), this.optgroupSelectAllBox = e.optgroupSelectAllBox || "M60,10 L10,10 L10,90 L90,90 L90,50", this.optgroupSelectAllCheck = e.optgroupSelectAllCheck || "M30,45 L50,70 L90,10", this.optgroupClosable = t("ss-closable", e.optgroupClosable), this.option = t("ss-option", e.option), this.optionDelete = e.optionDelete || "M10,10 L90,90 M10,90 L90,10", this.highlighted = t("ss-highlighted", e.highlighted), this.modalOverlay = t("ss-modal-overlay", e.modalOverlay), this.modalDialog = t("ss-modal-dialog", e.modalDialog), this.modalTitle = t("ss-modal-title", e.modalTitle), this.modalClose = t("ss-modal-close", e.modalClose), this.modalContent = t("ss-modal-content", e.modalContent), this.mainOpen = t("ss-open", e.mainOpen), this.close = t("ss-close", e.close), this.selected = t("ss-selected", e.selected), this.error = t("ss-error", e.error), this.disabled = t("ss-disabled", e.disabled), this.hide = t("ss-hide", e.hide);
|
|
51
56
|
}
|
|
52
57
|
getFirst(e) {
|
|
53
58
|
return this[e].split(" ")[0];
|
|
54
59
|
}
|
|
60
|
+
}, c = 200, l = ["transform", "opacity"];
|
|
61
|
+
function u(e, t = c) {
|
|
62
|
+
let n = e.trim();
|
|
63
|
+
if (!n) return t;
|
|
64
|
+
if (n.endsWith("ms")) {
|
|
65
|
+
let e = parseFloat(n);
|
|
66
|
+
return Number.isNaN(e) ? t : e;
|
|
67
|
+
}
|
|
68
|
+
if (n.endsWith("s")) {
|
|
69
|
+
let e = parseFloat(n);
|
|
70
|
+
return Number.isNaN(e) ? t : e * 1e3;
|
|
71
|
+
}
|
|
72
|
+
let r = parseFloat(n);
|
|
73
|
+
return Number.isNaN(r) ? t : r;
|
|
74
|
+
}
|
|
75
|
+
function d(e, t = c) {
|
|
76
|
+
return u(getComputedStyle(e).getPropertyValue("--ss-animation-timing").trim(), t);
|
|
77
|
+
}
|
|
78
|
+
function f(e, t, n = c) {
|
|
79
|
+
let r = d(e, n) + 50;
|
|
80
|
+
return t === void 0 ? r : Math.max(r, t);
|
|
81
|
+
}
|
|
82
|
+
function p() {
|
|
83
|
+
return typeof window > "u" || typeof window.matchMedia != "function" ? !1 : window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
84
|
+
}
|
|
85
|
+
function m(e) {
|
|
86
|
+
return e === void 0 ? null : new Set(Array.isArray(e) ? e : [e]);
|
|
87
|
+
}
|
|
88
|
+
function h(e, t, n = c, r) {
|
|
89
|
+
if (p() || r?.aborted) return Promise.resolve();
|
|
90
|
+
let i = m(t);
|
|
91
|
+
return new Promise((t) => {
|
|
92
|
+
let a = null, o = !1, s = () => {
|
|
93
|
+
o || (o = !0, e.removeEventListener("transitionend", l), r?.removeEventListener("abort", c), a && clearTimeout(a), t());
|
|
94
|
+
}, c = () => s(), l = (t) => {
|
|
95
|
+
t.target === e && (i && (!i.has(t.propertyName) || (i.delete(t.propertyName), i.size > 0)) || s());
|
|
96
|
+
};
|
|
97
|
+
r?.addEventListener("abort", c, { once: !0 }), e.addEventListener("transitionend", l), a = setTimeout(s, n);
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
function g(e, t, n = c, r) {
|
|
101
|
+
return p() || r?.aborted ? Promise.resolve() : new Promise((i) => {
|
|
102
|
+
let a = null, o = !1, s = () => {
|
|
103
|
+
o || (o = !0, e.removeEventListener("animationend", l), r?.removeEventListener("abort", c), a && clearTimeout(a), i());
|
|
104
|
+
}, c = () => s(), l = (n) => {
|
|
105
|
+
n.target === e && (t && n.animationName !== t || s());
|
|
106
|
+
};
|
|
107
|
+
r?.addEventListener("abort", c, { once: !0 }), e.addEventListener("animationend", l), a = setTimeout(s, n);
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
//#endregion
|
|
111
|
+
//#region src/slim-select/settings.ts
|
|
112
|
+
var _ = class {
|
|
113
|
+
id = "";
|
|
114
|
+
style = "";
|
|
115
|
+
class = [];
|
|
116
|
+
isMultiple = !1;
|
|
117
|
+
isOpen = !1;
|
|
118
|
+
isFullOpen = !1;
|
|
119
|
+
disabled;
|
|
120
|
+
alwaysOpen;
|
|
121
|
+
showSearch;
|
|
122
|
+
focusSearch;
|
|
123
|
+
keepSearch;
|
|
124
|
+
ariaLabel;
|
|
125
|
+
searchPlaceholder;
|
|
126
|
+
searchText;
|
|
127
|
+
searchingText;
|
|
128
|
+
resultsText;
|
|
129
|
+
deselectText;
|
|
130
|
+
removeText;
|
|
131
|
+
searchHighlight;
|
|
132
|
+
closeOnSelect;
|
|
133
|
+
contentLocation;
|
|
134
|
+
contentPosition;
|
|
135
|
+
contentWidth;
|
|
136
|
+
openPosition;
|
|
137
|
+
placeholderText;
|
|
138
|
+
allowDeselect;
|
|
139
|
+
hideSelected;
|
|
140
|
+
multiString;
|
|
141
|
+
keepOrder;
|
|
142
|
+
showOptionTooltips;
|
|
143
|
+
minSelected;
|
|
144
|
+
maxSelected;
|
|
145
|
+
timeoutDelay;
|
|
146
|
+
maxValuesShown;
|
|
147
|
+
maxValuesMessage;
|
|
148
|
+
addableText;
|
|
149
|
+
modal;
|
|
150
|
+
modalTitle;
|
|
151
|
+
constructor(e) {
|
|
152
|
+
e ||= {}, this.id = "ss-" + x(), this.style = e.style || "", this.class = e.class || [], this.disabled = e.disabled === void 0 ? !1 : e.disabled, this.alwaysOpen = e.alwaysOpen === void 0 ? !1 : e.alwaysOpen, this.showSearch = e.showSearch === void 0 ? !0 : e.showSearch, this.focusSearch = e.focusSearch === void 0 ? !0 : e.focusSearch, this.keepSearch = e.keepSearch === void 0 ? !1 : e.keepSearch, this.ariaLabel = e.ariaLabel || "Combobox", this.searchPlaceholder = e.searchPlaceholder || "Search...", this.searchText = e.searchText || "No Results", this.searchingText = e.searchingText || "Searching...", this.resultsText = e.resultsText || "{count} results available", this.deselectText = e.deselectText || "Clear", this.removeText = e.removeText || "Remove", this.searchHighlight = e.searchHighlight === void 0 ? !1 : e.searchHighlight, this.closeOnSelect = e.closeOnSelect === void 0 ? !0 : e.closeOnSelect, this.contentLocation = e.contentLocation || document.body, this.contentPosition = e.contentPosition || "absolute", this.contentWidth = e.contentWidth || "", this.openPosition = e.openPosition || "auto", this.placeholderText = e.placeholderText === void 0 ? "Select Value" : e.placeholderText, this.allowDeselect = e.allowDeselect === void 0 ? !1 : e.allowDeselect, this.hideSelected = e.hideSelected === void 0 ? !1 : e.hideSelected, this.multiString = e.multiString === void 0 ? !1 : e.multiString, this.keepOrder = e.keepOrder === void 0 ? !1 : e.keepOrder, this.showOptionTooltips = e.showOptionTooltips === void 0 ? !1 : e.showOptionTooltips, this.minSelected = e.minSelected || 0, this.maxSelected = e.maxSelected || 1e3, this.timeoutDelay = e.timeoutDelay || 200, this.maxValuesShown = e.maxValuesShown || 20, this.maxValuesMessage = e.maxValuesMessage || "{number} selected", this.addableText = e.addableText || "Press \"Enter\" to add {value}", this.modal = e.modal || "mobile", this.modalTitle = e.modalTitle || "";
|
|
153
|
+
}
|
|
55
154
|
};
|
|
56
155
|
//#endregion
|
|
57
156
|
//#region src/slim-select/helpers.ts
|
|
58
|
-
function
|
|
157
|
+
function v(e) {
|
|
158
|
+
if (!e) return {};
|
|
159
|
+
let t = {};
|
|
160
|
+
for (let n of Object.keys(e)) {
|
|
161
|
+
let r = e[n];
|
|
162
|
+
r !== void 0 && (t[n] = r);
|
|
163
|
+
}
|
|
164
|
+
return t;
|
|
165
|
+
}
|
|
166
|
+
function y(e) {
|
|
167
|
+
let t = e.cloneNode(!0);
|
|
168
|
+
return t.querySelectorAll("select, option, optgroup, textarea, input, button").forEach((e) => e.remove()), t.textContent?.replace(/\s+/g, " ").trim() || "";
|
|
169
|
+
}
|
|
170
|
+
function b(e) {
|
|
171
|
+
if (e.labels && e.labels.length > 0) {
|
|
172
|
+
let t = Array.from(e.labels).map(y).filter(Boolean);
|
|
173
|
+
if (t.length > 0) return [...new Set(t)].join(" ");
|
|
174
|
+
}
|
|
175
|
+
return e.getAttribute("aria-label")?.trim() || "";
|
|
176
|
+
}
|
|
177
|
+
function x() {
|
|
59
178
|
return Math.random().toString(36).substring(2, 10);
|
|
60
179
|
}
|
|
61
|
-
function
|
|
180
|
+
function S(e, t) {
|
|
62
181
|
function n(e, n) {
|
|
63
182
|
return n && e && e.classList && e.classList.contains(n) || n && e && e.dataset && e.dataset.id && e.dataset.id === t ? e : null;
|
|
64
183
|
}
|
|
@@ -67,7 +186,7 @@ function o(e, t) {
|
|
|
67
186
|
}
|
|
68
187
|
return n(e, t) || r(e, t);
|
|
69
188
|
}
|
|
70
|
-
function
|
|
189
|
+
function C(e, t = 50, n = !1) {
|
|
71
190
|
let r;
|
|
72
191
|
return function(...i) {
|
|
73
192
|
let a = self, o = () => {
|
|
@@ -76,16 +195,180 @@ function s(e, t = 50, n = !1) {
|
|
|
76
195
|
clearTimeout(r), r = setTimeout(o, t), s && e.apply(a, i);
|
|
77
196
|
};
|
|
78
197
|
}
|
|
79
|
-
function
|
|
80
|
-
|
|
198
|
+
function w(e, t) {
|
|
199
|
+
if (e.length !== t.length) return !1;
|
|
200
|
+
let n = [...e].sort(), r = [...t].sort();
|
|
201
|
+
return n.every((e, t) => e === r[t]);
|
|
202
|
+
}
|
|
203
|
+
var T = [
|
|
204
|
+
"id",
|
|
205
|
+
"value",
|
|
206
|
+
"text",
|
|
207
|
+
"html",
|
|
208
|
+
"defaultSelected",
|
|
209
|
+
"selected",
|
|
210
|
+
"display",
|
|
211
|
+
"disabled",
|
|
212
|
+
"placeholder",
|
|
213
|
+
"class",
|
|
214
|
+
"style",
|
|
215
|
+
"mandatory"
|
|
216
|
+
];
|
|
217
|
+
function E(e, t) {
|
|
218
|
+
let n = Object.keys(e), r = Object.keys(t);
|
|
219
|
+
if (n.length !== r.length) return !1;
|
|
220
|
+
for (let r of n) if (e[r] !== t[r]) return !1;
|
|
221
|
+
return !0;
|
|
81
222
|
}
|
|
82
|
-
function
|
|
223
|
+
function D(e, t) {
|
|
224
|
+
switch (t) {
|
|
225
|
+
case "id": return e.id || "";
|
|
226
|
+
case "value": return e.value === void 0 ? e.text || "" : e.value || "";
|
|
227
|
+
case "text": return e.text || "";
|
|
228
|
+
case "html": return e.html || "";
|
|
229
|
+
case "defaultSelected": return e.defaultSelected ?? !1;
|
|
230
|
+
case "selected": return e.selected ?? !1;
|
|
231
|
+
case "display": return e.display ?? !0;
|
|
232
|
+
case "disabled": return e.disabled ?? !1;
|
|
233
|
+
case "placeholder": return e.placeholder ?? !1;
|
|
234
|
+
case "class": return e.class || "";
|
|
235
|
+
case "style": return e.style || "";
|
|
236
|
+
case "mandatory": return e.mandatory ?? !1;
|
|
237
|
+
default: return e.data || {};
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
function O(e) {
|
|
241
|
+
return !!e && typeof e == "object" && "label" in e && "options" in e;
|
|
242
|
+
}
|
|
243
|
+
function k(e, t) {
|
|
244
|
+
for (let n of T) if (D(e, n) !== D(t, n)) return !1;
|
|
245
|
+
return E(e.data || {}, t.data || {});
|
|
246
|
+
}
|
|
247
|
+
function A(e, t) {
|
|
248
|
+
let n = (e) => ({
|
|
249
|
+
id: e.id || "",
|
|
250
|
+
label: e.label || "",
|
|
251
|
+
selectAll: e.selectAll ?? !1,
|
|
252
|
+
closable: e.closable || "off"
|
|
253
|
+
}), r = n(e), i = n(t);
|
|
254
|
+
if (r.id !== i.id || r.label !== i.label || r.selectAll !== i.selectAll || r.closable !== i.closable) return !1;
|
|
255
|
+
let a = e.options || [], o = t.options || [];
|
|
256
|
+
if (a.length !== o.length) return !1;
|
|
257
|
+
for (let e = 0; e < a.length; e++) if (!k(a[e], o[e])) return !1;
|
|
258
|
+
return !0;
|
|
259
|
+
}
|
|
260
|
+
function j(e, t) {
|
|
261
|
+
if (e === t) return !0;
|
|
262
|
+
if (e.length !== t.length) return !1;
|
|
263
|
+
for (let n = 0; n < e.length; n++) {
|
|
264
|
+
let r = e[n], i = t[n], a = O(r);
|
|
265
|
+
if (a !== O(i)) return !1;
|
|
266
|
+
if (a) {
|
|
267
|
+
if (!A(r, i)) return !1;
|
|
268
|
+
continue;
|
|
269
|
+
}
|
|
270
|
+
if (!k(r, i)) return !1;
|
|
271
|
+
}
|
|
272
|
+
return !0;
|
|
273
|
+
}
|
|
274
|
+
function M(e) {
|
|
83
275
|
let t = e.replace(/[A-Z\u00C0-\u00D6\u00D8-\u00DE]/g, (e) => "-" + e.toLowerCase());
|
|
84
276
|
return e[0] === e[0].toUpperCase() ? t.substring(1) : t;
|
|
85
277
|
}
|
|
278
|
+
function N(e, t = typeof window < "u" ? window.innerWidth : 768) {
|
|
279
|
+
return e === "on" ? !0 : e === "mobile" ? t < 768 : !1;
|
|
280
|
+
}
|
|
86
281
|
//#endregion
|
|
87
|
-
//#region src/slim-select/
|
|
88
|
-
var
|
|
282
|
+
//#region src/slim-select/events.ts
|
|
283
|
+
var P = class {
|
|
284
|
+
handlers;
|
|
285
|
+
attached = !1;
|
|
286
|
+
constructor(e) {
|
|
287
|
+
this.handlers = e;
|
|
288
|
+
}
|
|
289
|
+
attach(e) {
|
|
290
|
+
this.attached || (this.attached = !0, window.addEventListener("resize", this.resizeHandler, !1), e.listenScroll && window.addEventListener("scroll", this.scrollHandler, !1), document.addEventListener("visibilitychange", this.visibilityHandler));
|
|
291
|
+
}
|
|
292
|
+
attachDocumentClick() {
|
|
293
|
+
document.addEventListener("click", this.handlers.onDocumentClick);
|
|
294
|
+
}
|
|
295
|
+
detachDocumentClick() {
|
|
296
|
+
document.removeEventListener("click", this.handlers.onDocumentClick);
|
|
297
|
+
}
|
|
298
|
+
detach(e) {
|
|
299
|
+
this.attached && (this.attached = !1, this.detachDocumentClick(), window.removeEventListener("resize", this.resizeHandler, !1), e.listenScroll && window.removeEventListener("scroll", this.scrollHandler, !1), document.removeEventListener("visibilitychange", this.visibilityHandler));
|
|
300
|
+
}
|
|
301
|
+
resizeHandler = C(() => {
|
|
302
|
+
this.handlers.onWindowResize();
|
|
303
|
+
});
|
|
304
|
+
scrollHandler = C(() => {
|
|
305
|
+
this.handlers.onWindowScroll();
|
|
306
|
+
});
|
|
307
|
+
visibilityHandler = () => {
|
|
308
|
+
this.handlers.onVisibilityChange();
|
|
309
|
+
};
|
|
310
|
+
}, F = class {
|
|
311
|
+
handlers;
|
|
312
|
+
options;
|
|
313
|
+
state = "closed";
|
|
314
|
+
pendingTimer = null;
|
|
315
|
+
waitResolvers = [];
|
|
316
|
+
generation = 0;
|
|
317
|
+
animationAbort = null;
|
|
318
|
+
constructor(e, t) {
|
|
319
|
+
this.handlers = e, this.options = t;
|
|
320
|
+
}
|
|
321
|
+
get isOpen() {
|
|
322
|
+
return this.state === "opening" || this.state === "open";
|
|
323
|
+
}
|
|
324
|
+
get isFullOpen() {
|
|
325
|
+
return this.state === "open";
|
|
326
|
+
}
|
|
327
|
+
async requestOpen() {
|
|
328
|
+
if (this.state === "opening" || this.state === "open") return;
|
|
329
|
+
this.cancelPending();
|
|
330
|
+
let e = ++this.generation;
|
|
331
|
+
if (this.handlers.beforeOpen && this.handlers.beforeOpen(), this.state = "opening", await this.waitForPhase("open", e), e !== this.generation) {
|
|
332
|
+
this.state === "opening" && (this.state = "closed");
|
|
333
|
+
return;
|
|
334
|
+
}
|
|
335
|
+
this.state = "open", this.handlers.afterOpen && this.handlers.afterOpen(), this.handlers.onOpenReady && this.handlers.onOpenReady();
|
|
336
|
+
}
|
|
337
|
+
async requestClose() {
|
|
338
|
+
if (this.state === "closed" || this.state === "closing") return;
|
|
339
|
+
this.cancelPending();
|
|
340
|
+
let e = ++this.generation;
|
|
341
|
+
this.handlers.beforeClose && this.handlers.beforeClose(), this.state = "closing", await this.waitForPhase("close", e), e === this.generation && (this.state = "closed", this.handlers.afterClose && this.handlers.afterClose(), this.handlers.onCloseReady && this.handlers.onCloseReady());
|
|
342
|
+
}
|
|
343
|
+
cancelPending() {
|
|
344
|
+
this.generation++, this.animationAbort?.abort(), this.animationAbort = null, this.pendingTimer &&= (clearTimeout(this.pendingTimer), null);
|
|
345
|
+
let e = this.waitResolvers.splice(0);
|
|
346
|
+
for (let t of e) t();
|
|
347
|
+
}
|
|
348
|
+
destroy() {
|
|
349
|
+
this.cancelPending(), this.state = "closed";
|
|
350
|
+
}
|
|
351
|
+
waitForPhase(e, t) {
|
|
352
|
+
return new Promise((t) => {
|
|
353
|
+
let n = !1, r = () => {
|
|
354
|
+
if (n) return;
|
|
355
|
+
n = !0;
|
|
356
|
+
let e = this.waitResolvers.indexOf(r);
|
|
357
|
+
e !== -1 && this.waitResolvers.splice(e, 1), t();
|
|
358
|
+
};
|
|
359
|
+
if (this.waitResolvers.push(r), this.options.waitForAnimation) {
|
|
360
|
+
let t = new AbortController();
|
|
361
|
+
this.animationAbort = t, this.options.waitForAnimation(e, t.signal).catch(() => void 0).finally(() => {
|
|
362
|
+
this.animationAbort === t && (this.animationAbort = null), r();
|
|
363
|
+
});
|
|
364
|
+
} else this.pendingTimer = setTimeout(() => {
|
|
365
|
+
this.pendingTimer = null, r();
|
|
366
|
+
}, this.options.timeoutDelay);
|
|
367
|
+
}).then(() => {
|
|
368
|
+
this.generation;
|
|
369
|
+
});
|
|
370
|
+
}
|
|
371
|
+
}, I = class {
|
|
89
372
|
id;
|
|
90
373
|
value;
|
|
91
374
|
text;
|
|
@@ -100,34 +383,34 @@ var u = class {
|
|
|
100
383
|
data;
|
|
101
384
|
mandatory;
|
|
102
385
|
constructor(e) {
|
|
103
|
-
this.id = !e.id || e.id === "" ?
|
|
386
|
+
this.id = !e.id || e.id === "" ? x() : e.id, this.value = e.value === void 0 ? e.text || "" : e.value || "", this.text = e.text || "", this.html = e.html || "", this.defaultSelected = e.defaultSelected === void 0 ? !1 : e.defaultSelected, this.selected = e.selected === void 0 ? !1 : e.selected, this.display = e.display === void 0 ? !0 : e.display, this.disabled = e.disabled === void 0 ? !1 : e.disabled, this.mandatory = e.mandatory === void 0 ? !1 : e.mandatory, this.placeholder = e.placeholder === void 0 ? !1 : e.placeholder, this.class = e.class || "", this.style = e.style || "", this.data = v(e.data);
|
|
104
387
|
}
|
|
105
|
-
},
|
|
388
|
+
}, L = class {
|
|
106
389
|
id;
|
|
107
390
|
label;
|
|
108
391
|
selectAll;
|
|
109
|
-
selectAllText;
|
|
110
392
|
closable;
|
|
111
393
|
options;
|
|
112
394
|
constructor(e) {
|
|
113
|
-
if (this.id = !e.id || e.id === "" ?
|
|
395
|
+
if (this.id = !e.id || e.id === "" ? x() : e.id, this.label = e.label || "", this.selectAll = e.selectAll === void 0 ? !1 : e.selectAll, this.closable = e.closable || "off", this.options = [], e.options) for (let t of e.options) this.options.push(new I(t));
|
|
114
396
|
}
|
|
115
|
-
},
|
|
397
|
+
}, R = class {
|
|
116
398
|
selectType = "single";
|
|
117
399
|
data = [];
|
|
118
400
|
selectedOrder = [];
|
|
401
|
+
catalog = null;
|
|
119
402
|
constructor(e, t) {
|
|
120
|
-
this.selectType = e, this.setData(t);
|
|
403
|
+
this.selectType = e, this.setData(t), this.snapshotCatalog();
|
|
121
404
|
}
|
|
122
405
|
validateDataArray(e) {
|
|
123
406
|
if (!Array.isArray(e)) return /* @__PURE__ */ Error("Data must be an array");
|
|
124
|
-
for (let t of e) if (t) if (t instanceof
|
|
407
|
+
for (let t of e) if (t) if (t instanceof L || "label" in t) {
|
|
125
408
|
if (!("label" in t)) return /* @__PURE__ */ Error("Optgroup must have a label");
|
|
126
409
|
if ("options" in t && t.options) for (let e of t.options) {
|
|
127
410
|
let t = this.validateOption(e);
|
|
128
411
|
if (t) return t;
|
|
129
412
|
}
|
|
130
|
-
} else if (t instanceof
|
|
413
|
+
} else if (t instanceof I || "text" in t) {
|
|
131
414
|
let e = this.validateOption(t);
|
|
132
415
|
if (e) return e;
|
|
133
416
|
} else return /* @__PURE__ */ Error("Data object must be a valid optgroup or option");
|
|
@@ -140,64 +423,81 @@ var u = class {
|
|
|
140
423
|
let t = [];
|
|
141
424
|
return e.forEach((e) => {
|
|
142
425
|
if (e) {
|
|
143
|
-
if (e instanceof
|
|
426
|
+
if (e instanceof L || "label" in e) {
|
|
144
427
|
let n = [];
|
|
145
428
|
"options" in e && e.options && e.options.forEach((e) => {
|
|
146
|
-
n.push(new
|
|
147
|
-
}), n.length > 0 && t.push(new
|
|
429
|
+
n.push(new I(e));
|
|
430
|
+
}), n.length > 0 && t.push(new L(e));
|
|
148
431
|
}
|
|
149
|
-
(e instanceof
|
|
432
|
+
(e instanceof I || "text" in e) && t.push(new I(e));
|
|
150
433
|
}
|
|
151
434
|
}), t;
|
|
152
435
|
}
|
|
436
|
+
snapshotCatalog() {
|
|
437
|
+
this.catalog = this.cloneData(this.data);
|
|
438
|
+
}
|
|
439
|
+
getCatalogData() {
|
|
440
|
+
return this.cloneData(this.catalog ?? this.data);
|
|
441
|
+
}
|
|
442
|
+
cloneData(e) {
|
|
443
|
+
return e.map((e) => e instanceof L ? new L({
|
|
444
|
+
id: e.id,
|
|
445
|
+
label: e.label,
|
|
446
|
+
selectAll: e.selectAll,
|
|
447
|
+
closable: e.closable,
|
|
448
|
+
options: e.options.map((e) => new I(e instanceof I ? { ...e } : e))
|
|
449
|
+
}) : new I({ ...e }));
|
|
450
|
+
}
|
|
451
|
+
optionMatchesSelected(e, t) {
|
|
452
|
+
return e.id === t.id ? !0 : t.value !== "" && e.value !== "" && e.value === t.value;
|
|
453
|
+
}
|
|
454
|
+
findOptionInData(e, t) {
|
|
455
|
+
for (let n of e) {
|
|
456
|
+
if (n instanceof I) {
|
|
457
|
+
if (this.optionMatchesSelected(n, t)) return n;
|
|
458
|
+
continue;
|
|
459
|
+
}
|
|
460
|
+
for (let e of n.options) if (this.optionMatchesSelected(e, t)) return e;
|
|
461
|
+
}
|
|
462
|
+
return null;
|
|
463
|
+
}
|
|
153
464
|
setData(e, t = !1) {
|
|
154
465
|
let n = this.partialToFullData(e), r = [];
|
|
155
466
|
if (t) {
|
|
156
467
|
r = this.getSelectedOptions();
|
|
157
468
|
let e = [];
|
|
158
469
|
r.forEach((t) => {
|
|
159
|
-
|
|
160
|
-
for (let e of n) {
|
|
161
|
-
if (e instanceof u && e.id === t.id) {
|
|
162
|
-
r = !0;
|
|
163
|
-
break;
|
|
164
|
-
}
|
|
165
|
-
if (e instanceof d) {
|
|
166
|
-
for (let n of e.options) if (n.id === t.id) {
|
|
167
|
-
r = !0;
|
|
168
|
-
break;
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
r || e.push(t);
|
|
470
|
+
this.findOptionInData(n, t) || e.push(t);
|
|
173
471
|
}), this.data = [...e, ...n];
|
|
472
|
+
let t = this.selectType === "single" && r.length === 0, i = r.map((e) => {
|
|
473
|
+
let t = this.findOptionInData(this.data, e);
|
|
474
|
+
return t ? t.id : e.id;
|
|
475
|
+
});
|
|
476
|
+
this.setSelectedBy("id", i, t);
|
|
174
477
|
} else this.data = n;
|
|
175
|
-
|
|
176
|
-
let e = t && r.length === 0;
|
|
177
|
-
this.setSelectedBy("id", this.getSelected(), e);
|
|
178
|
-
}
|
|
478
|
+
!t && this.selectType === "single" && this.setSelectedBy("id", this.getSelected(), !1);
|
|
179
479
|
}
|
|
180
|
-
getData() {
|
|
181
|
-
return this.filter(null, !0);
|
|
480
|
+
getData(e = !0) {
|
|
481
|
+
return this.filter(null, !0, e);
|
|
182
482
|
}
|
|
183
|
-
getDataOptions() {
|
|
184
|
-
return this.filter(null, !1);
|
|
483
|
+
getDataOptions(e = !0) {
|
|
484
|
+
return this.filter(null, !1, e);
|
|
185
485
|
}
|
|
186
486
|
addOption(e, t = !1) {
|
|
187
487
|
if (t) {
|
|
188
|
-
let t = [new
|
|
488
|
+
let t = [new I(e)];
|
|
189
489
|
this.setData(t.concat(this.getData()));
|
|
190
|
-
} else this.setData(this.getData().concat(new
|
|
490
|
+
} else this.setData(this.getData().concat(new I(e)));
|
|
191
491
|
}
|
|
192
492
|
setSelectedBy(e, t, n = !1) {
|
|
193
493
|
let r = null, i = !1, a = [];
|
|
194
494
|
for (let n of this.data) {
|
|
195
|
-
if (n instanceof
|
|
495
|
+
if (n instanceof L) for (let o of n.options) {
|
|
196
496
|
r ||= o;
|
|
197
497
|
let n = o[e] || "";
|
|
198
498
|
o.selected = i ? !1 : t.includes(n), o.selected && (a.push(o), this.selectType === "single" && (i = !0));
|
|
199
499
|
}
|
|
200
|
-
n instanceof
|
|
500
|
+
n instanceof I && (r ||= n, n.selected = i ? !1 : t.includes(n[e]), n.selected && (a.push(n), this.selectType === "single" && (i = !0)));
|
|
201
501
|
}
|
|
202
502
|
this.selectType === "single" && r && !i && !n && (r.selected = !0, a.push(r));
|
|
203
503
|
let o = t.map((t) => a.find((n) => n[e] === t)?.id || "");
|
|
@@ -210,41 +510,56 @@ var u = class {
|
|
|
210
510
|
return this.getSelectedOptions().map((e) => e.value);
|
|
211
511
|
}
|
|
212
512
|
getSelectedOptions() {
|
|
213
|
-
|
|
513
|
+
let e = [];
|
|
514
|
+
for (let t of this.data) if (t instanceof L) for (let n of t.options) n.selected && e.push(n);
|
|
515
|
+
else t.selected && e.push(t);
|
|
516
|
+
return e;
|
|
214
517
|
}
|
|
215
518
|
getOptgroupByID(e) {
|
|
216
|
-
for (let t of this.data) if (t instanceof
|
|
519
|
+
for (let t of this.data) if (t instanceof L && t.id === e) return t;
|
|
217
520
|
return null;
|
|
218
521
|
}
|
|
219
522
|
getOptionByID(e) {
|
|
220
|
-
let t
|
|
221
|
-
|
|
523
|
+
for (let t of this.data) if (t instanceof L) {
|
|
524
|
+
for (let n of t.options) if (n.id === e) return n;
|
|
525
|
+
} else if (t.id === e) return t;
|
|
526
|
+
return null;
|
|
222
527
|
}
|
|
223
528
|
getSelectType() {
|
|
224
529
|
return this.selectType;
|
|
225
530
|
}
|
|
226
531
|
getFirstOption() {
|
|
227
532
|
let e = null;
|
|
228
|
-
for (let t of this.data) if (t instanceof
|
|
533
|
+
for (let t of this.data) if (t instanceof L ? e = t.options[0] : t instanceof I && (e = t), e) break;
|
|
229
534
|
return e;
|
|
230
535
|
}
|
|
231
536
|
search(e, t) {
|
|
232
|
-
return e = e.trim(), e === "" ? this.getData() : this.filter((n) => t(n, e), !0);
|
|
537
|
+
return e = e.trim(), e === "" ? this.getData(!1) : this.filter((n) => t(n, e), !0, !1);
|
|
233
538
|
}
|
|
234
|
-
|
|
235
|
-
let n =
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
539
|
+
createOptgroupView(e, t) {
|
|
540
|
+
let n = new L({
|
|
541
|
+
id: e.id,
|
|
542
|
+
label: e.label,
|
|
543
|
+
selectAll: e.selectAll,
|
|
544
|
+
closable: e.closable,
|
|
545
|
+
options: []
|
|
546
|
+
});
|
|
547
|
+
return n.options = t, n;
|
|
548
|
+
}
|
|
549
|
+
filter(e, t, n = !0) {
|
|
550
|
+
let r = [];
|
|
551
|
+
return this.data.forEach((i) => {
|
|
552
|
+
if (i instanceof L) {
|
|
553
|
+
let a = [];
|
|
554
|
+
if (i.options.forEach((i) => {
|
|
555
|
+
(!e || e(i)) && (t ? a.push(n ? new I(i) : i) : r.push(n ? new I(i) : i));
|
|
556
|
+
}), a.length > 0) if (n) {
|
|
557
|
+
let e = new L(i);
|
|
558
|
+
e.options = a, r.push(e);
|
|
559
|
+
} else r.push(this.createOptgroupView(i, a));
|
|
245
560
|
}
|
|
246
|
-
|
|
247
|
-
}),
|
|
561
|
+
i instanceof I && (!e || e(i)) && r.push(n ? new I(i) : i);
|
|
562
|
+
}), r;
|
|
248
563
|
}
|
|
249
564
|
selectedOrderOptions(e) {
|
|
250
565
|
let t = [];
|
|
@@ -261,18 +576,25 @@ var u = class {
|
|
|
261
576
|
}), n || t.push(e);
|
|
262
577
|
}), t;
|
|
263
578
|
}
|
|
264
|
-
},
|
|
579
|
+
}, z = class {
|
|
265
580
|
settings;
|
|
266
581
|
store;
|
|
267
582
|
callbacks;
|
|
268
583
|
lastSelectedOption;
|
|
269
584
|
lastRenderedOptions;
|
|
270
|
-
|
|
585
|
+
optionsListIsFullData = !1;
|
|
586
|
+
lastSearchFilterTerm = "";
|
|
271
587
|
main;
|
|
272
588
|
content;
|
|
273
589
|
classes;
|
|
590
|
+
positionObserver = null;
|
|
591
|
+
positionObserverRaf = 0;
|
|
592
|
+
modalElements = null;
|
|
593
|
+
modalSessionActive = null;
|
|
594
|
+
bodyScrollLocked = !1;
|
|
595
|
+
savedBodyOverflow = "";
|
|
274
596
|
constructor(e, t, n, r) {
|
|
275
|
-
this.store = n, this.settings = e, this.classes = t, this.callbacks = r, this.lastSelectedOption = null, this.lastRenderedOptions = [], this.main = this.mainDiv(), this.content = this.contentDiv(), this.updateClassStyles(), this.updateAriaAttributes(), this.settings.contentPosition !== "relative" && (this.content.main.style.top = "-9999px", this.content.main.style.left = "-9999px", this.content.main.style.margin = "0", this.content.main.style.width = "auto"), this.settings.contentLocation && this.settings.contentLocation.appendChild(this.content.main);
|
|
597
|
+
this.store = n, this.settings = e, this.classes = t, this.callbacks = r, this.lastSelectedOption = null, this.lastRenderedOptions = [], this.main = this.mainDiv(), this.content = this.contentDiv(), this.updateClassStyles(), this.updateAriaAttributes(), this.settings.contentPosition !== "relative" && (this.content.main.style.top = "-9999px", this.content.main.style.left = "-9999px", this.content.main.style.margin = "0", this.content.main.style.width = "auto"), this.settings.contentLocation && this.settings.contentLocation.appendChild(this.content.main), this.settings.modal !== "off" && !this.settings.alwaysOpen && (this.modalElements = this.createModalElements(), document.body.appendChild(this.modalElements.overlay));
|
|
276
598
|
}
|
|
277
599
|
addClasses(e, t) {
|
|
278
600
|
if (!t || t.trim() === "") return;
|
|
@@ -291,29 +613,76 @@ var u = class {
|
|
|
291
613
|
this.addClasses(this.main.main, this.classes.disabled), this.main.main.setAttribute("aria-disabled", "true"), this.content.search.input.disabled = !0;
|
|
292
614
|
}
|
|
293
615
|
open() {
|
|
294
|
-
this.main.arrow.path.setAttribute("d", this.classes.arrowOpen), this.main.main.setAttribute("aria-expanded", "true")
|
|
295
|
-
let e = this.
|
|
296
|
-
|
|
616
|
+
this.main.arrow.path.setAttribute("d", this.classes.arrowOpen), this.main.main.setAttribute("aria-expanded", "true");
|
|
617
|
+
let e = this.resolveModalView();
|
|
618
|
+
if (!e) {
|
|
619
|
+
let e = this.settings.openPosition === "up" ? this.classes.dirAbove : this.classes.dirBelow;
|
|
620
|
+
this.addClasses(this.main.main, e), this.addClasses(this.content.main, e);
|
|
621
|
+
}
|
|
622
|
+
this.addClasses(this.content.main, this.classes.contentOpen), this.content.search.input.removeAttribute("aria-hidden"), e ? this.showModal() : this.moveContent();
|
|
297
623
|
let t = this.store.getSelectedOptions();
|
|
298
624
|
if (t.length) {
|
|
299
625
|
let e = t[t.length - 1].id, n = this.content.list.querySelector("[data-id=\"" + e + "\"]");
|
|
300
626
|
n && this.ensureElementInView(this.content.list, n);
|
|
301
627
|
}
|
|
302
628
|
}
|
|
629
|
+
isModalViewActive() {
|
|
630
|
+
return this.modalSessionActive === !0;
|
|
631
|
+
}
|
|
632
|
+
resolveModalView() {
|
|
633
|
+
return this.settings.alwaysOpen || this.settings.modal === "off" || !this.modalElements ? !1 : (this.modalSessionActive === null && (this.modalSessionActive = N(this.settings.modal)), this.modalSessionActive);
|
|
634
|
+
}
|
|
635
|
+
createModalElements() {
|
|
636
|
+
let e = document.createElement("div");
|
|
637
|
+
this.addClasses(e, this.classes.modalOverlay), this.addClasses(e, this.classes.hide), e.dataset.id = this.settings.id;
|
|
638
|
+
let t = document.createElement("div");
|
|
639
|
+
this.addClasses(t, this.classes.modalDialog), t.setAttribute("role", "dialog"), t.setAttribute("aria-modal", "true");
|
|
640
|
+
let n = null;
|
|
641
|
+
this.settings.modalTitle ? (n = document.createElement("div"), this.addClasses(n, this.classes.modalTitle), n.id = `${this.settings.id}-modal-title`, n.textContent = this.settings.modalTitle, t.setAttribute("aria-labelledby", n.id)) : t.setAttribute("aria-label", this.settings.ariaLabel);
|
|
642
|
+
let r = document.createElement("button");
|
|
643
|
+
r.type = "button", this.addClasses(r, this.classes.modalClose), r.setAttribute("aria-label", "Close"), r.onclick = (e) => {
|
|
644
|
+
e.stopPropagation(), this.callbacks.close();
|
|
645
|
+
};
|
|
646
|
+
let i = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
647
|
+
i.setAttribute("viewBox", "0 0 100 100");
|
|
648
|
+
let a = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
649
|
+
return a.setAttribute("d", this.classes.deselectPath), i.appendChild(a), r.appendChild(i), e.onclick = (t) => {
|
|
650
|
+
t.target === e && this.callbacks.close();
|
|
651
|
+
}, n && t.appendChild(n), e.appendChild(t), {
|
|
652
|
+
overlay: e,
|
|
653
|
+
dialog: t,
|
|
654
|
+
closeButton: r,
|
|
655
|
+
title: n
|
|
656
|
+
};
|
|
657
|
+
}
|
|
658
|
+
showModal() {
|
|
659
|
+
this.modalElements && (this.modalElements.dialog.appendChild(this.content.main), this.addClasses(this.content.main, this.classes.modalContent), this.content.main.appendChild(this.modalElements.closeButton), this.content.main.style.top = "", this.content.main.style.left = "", this.content.main.style.margin = "", this.content.main.style.width = "", this.removeClasses(this.modalElements.overlay, this.classes.hide), requestAnimationFrame(() => {
|
|
660
|
+
this.modalElements && this.addClasses(this.modalElements.overlay, this.classes.contentOpen);
|
|
661
|
+
}), this.lockBodyScroll());
|
|
662
|
+
}
|
|
663
|
+
lockBodyScroll() {
|
|
664
|
+
this.bodyScrollLocked ||= (this.savedBodyOverflow = document.body.style.overflow, document.body.style.overflow = "hidden", !0);
|
|
665
|
+
}
|
|
666
|
+
unlockBodyScroll() {
|
|
667
|
+
this.bodyScrollLocked && (document.body.style.overflow = this.savedBodyOverflow, this.bodyScrollLocked = !1, this.savedBodyOverflow = "");
|
|
668
|
+
}
|
|
669
|
+
restoreContentOffscreen() {
|
|
670
|
+
this.settings.contentLocation && this.settings.contentLocation.appendChild(this.content.main), this.settings.contentPosition !== "relative" && (this.content.main.style.top = "-9999px", this.content.main.style.left = "-9999px", this.content.main.style.margin = "0", this.content.main.style.width = "auto");
|
|
671
|
+
}
|
|
672
|
+
finalizeModalClose() {
|
|
673
|
+
this.modalElements && this.content.main.parentElement === this.modalElements.dialog && (this.addClasses(this.modalElements.overlay, this.classes.hide), this.removeClasses(this.modalElements.overlay, this.classes.contentOpen), this.removeClasses(this.content.main, this.classes.modalContent), this.restoreContentOffscreen(), this.unlockBodyScroll());
|
|
674
|
+
}
|
|
675
|
+
waitForAnimation(e, t) {
|
|
676
|
+
let n = f(this.content.main, this.settings.timeoutDelay);
|
|
677
|
+
return h(this.content.main, l, n, t);
|
|
678
|
+
}
|
|
303
679
|
close() {
|
|
304
|
-
this.main.main.setAttribute("aria-expanded", "false"), this.main.arrow.path.setAttribute("d", this.classes.arrowClose)
|
|
305
|
-
let e = this.
|
|
306
|
-
this.
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
getAnimationTiming() {
|
|
311
|
-
let e = getComputedStyle(this.content.main).getPropertyValue("--ss-animation-timing").trim();
|
|
312
|
-
if (e) {
|
|
313
|
-
if (e.endsWith("ms")) return parseFloat(e);
|
|
314
|
-
if (e.endsWith("s")) return parseFloat(e) * 1e3;
|
|
315
|
-
}
|
|
316
|
-
return 200;
|
|
680
|
+
this.main.main.setAttribute("aria-expanded", "false"), this.main.arrow.path.setAttribute("d", this.classes.arrowClose);
|
|
681
|
+
let e = this.modalSessionActive === !0;
|
|
682
|
+
this.removeClasses(this.content.main, this.classes.contentOpen), e || (this.removeClasses(this.main.main, this.classes.dirAbove), this.removeClasses(this.main.main, this.classes.dirBelow)), e && this.modalElements && this.removeClasses(this.modalElements.overlay, this.classes.contentOpen), this.modalSessionActive = null, this.content.search.input.setAttribute("aria-hidden", "true"), this.main.main.removeAttribute("aria-activedescendant");
|
|
683
|
+
}
|
|
684
|
+
clearDirectionClasses() {
|
|
685
|
+
this.removeClasses(this.main.main, this.classes.dirAbove), this.removeClasses(this.main.main, this.classes.dirBelow), this.removeClasses(this.content.main, this.classes.dirAbove), this.removeClasses(this.content.main, this.classes.dirBelow);
|
|
317
686
|
}
|
|
318
687
|
updateClassStyles() {
|
|
319
688
|
if (this.main.main.className = "", this.main.main.removeAttribute("style"), this.content.main.className = "", this.content.main.removeAttribute("style"), this.addClasses(this.main.main, this.classes.main), this.addClasses(this.content.main, this.classes.content), this.settings.style !== "" && (this.main.main.style.cssText = this.settings.style, this.content.main.style.cssText = this.settings.style), this.settings.class.length) for (let e of this.settings.class) e.trim() !== "" && (this.main.main.classList.add(e.trim()), this.content.main.classList.add(e.trim()));
|
|
@@ -346,11 +715,17 @@ var u = class {
|
|
|
346
715
|
let n = document.createElement("div");
|
|
347
716
|
this.addClasses(n, this.classes.deselect), n.setAttribute("role", "button"), n.setAttribute("aria-label", this.settings.deselectText), n.setAttribute("tabindex", "0");
|
|
348
717
|
let r = this.store?.getSelectedOptions();
|
|
349
|
-
!this.settings.allowDeselect || this.settings.isMultiple && r && r.length <= 0 ? this.addClasses(n, this.classes.hide) : this.removeClasses(n, this.classes.hide), n.onclick = (e) => {
|
|
350
|
-
if (e.stopPropagation(), this.settings.disabled) return;
|
|
351
|
-
let t = !0, n = this.store.getSelectedOptions();
|
|
352
|
-
if (this.
|
|
353
|
-
|
|
718
|
+
!this.settings.allowDeselect || this.settings.isMultiple && r && r.length <= 0 || this.isAtMinSelected() ? this.addClasses(n, this.classes.hide) : this.removeClasses(n, this.classes.hide), n.onclick = (e) => {
|
|
719
|
+
if (e.stopPropagation(), this.settings.disabled || this.settings.isMultiple && this.isAtMinSelected()) return;
|
|
720
|
+
let t = !0, n = this.store.getSelectedOptions(), r = [], i = "";
|
|
721
|
+
if (this.settings.isMultiple) {
|
|
722
|
+
let e = this.settings.minSelected, t = this.store.getSelected();
|
|
723
|
+
if (e > 0 && t.length > e) i = this.getMinimumSelectionIds(), r = n.filter((e) => i.includes(e.id));
|
|
724
|
+
else if (e <= 0) i = [];
|
|
725
|
+
else return;
|
|
726
|
+
}
|
|
727
|
+
if (this.callbacks.beforeChange && (t = this.callbacks.beforeChange(r, n) === !0), t) {
|
|
728
|
+
if (this.settings.isMultiple) this.callbacks.setSelected(i, !1), this.updateDeselectAll();
|
|
354
729
|
else {
|
|
355
730
|
let e = this.store.getFirstOption(), t = e ? e.id : "";
|
|
356
731
|
this.callbacks.setSelected(t, !1);
|
|
@@ -385,7 +760,7 @@ var u = class {
|
|
|
385
760
|
e !== "click" && this.main.main.focus({ preventScroll: !0 });
|
|
386
761
|
}
|
|
387
762
|
placeholder() {
|
|
388
|
-
let e = this.store.filter((e) => e.placeholder, !1), t = this.settings.placeholderText;
|
|
763
|
+
let e = this.store.filter((e) => e.placeholder, !1, !1), t = this.settings.placeholderText;
|
|
389
764
|
e.length && (e[0].html === "" ? e[0].text !== "" && (t = e[0].text) : t = e[0].html);
|
|
390
765
|
let n = document.createElement("div");
|
|
391
766
|
return this.addClasses(n, this.classes.placeholder), n.innerHTML = t, n;
|
|
@@ -398,7 +773,7 @@ var u = class {
|
|
|
398
773
|
this.renderMultipleValues(), this.updateDeselectAll();
|
|
399
774
|
}
|
|
400
775
|
renderSingleValue() {
|
|
401
|
-
let e = this.store.filter((e) => e.selected && !e.placeholder, !1), t = e.length > 0 ? e[0] : null;
|
|
776
|
+
let e = this.store.filter((e) => e.selected && !e.placeholder, !1, !1), t = e.length > 0 ? e[0] : null;
|
|
402
777
|
if (!t) this.main.values.innerHTML = this.placeholder().outerHTML;
|
|
403
778
|
else {
|
|
404
779
|
let e = document.createElement("div");
|
|
@@ -407,7 +782,7 @@ var u = class {
|
|
|
407
782
|
!this.settings.allowDeselect || !e.length ? this.addClasses(this.main.deselect.main, this.classes.hide) : this.removeClasses(this.main.deselect.main, this.classes.hide);
|
|
408
783
|
}
|
|
409
784
|
renderMultipleValues() {
|
|
410
|
-
let e = this.main.values.childNodes, t = this.store.filter((e) => e.selected && e.display, !1);
|
|
785
|
+
let e = this.main.values.childNodes, t = this.store.filter((e) => e.selected && e.display, !1, !1);
|
|
411
786
|
if (t.length === 0) {
|
|
412
787
|
this.main.values.innerHTML = this.placeholder().outerHTML;
|
|
413
788
|
return;
|
|
@@ -436,15 +811,29 @@ var u = class {
|
|
|
436
811
|
let i = e[r], a = i.getAttribute("data-id");
|
|
437
812
|
a && (t.filter((e) => e.id === a, !1).length || n.push(i));
|
|
438
813
|
}
|
|
439
|
-
|
|
814
|
+
let r = f(this.content.main, this.settings.timeoutDelay);
|
|
815
|
+
for (let e of n) this.addClasses(e, this.classes.valueOut), g(e, "ss-valueOut", r).then(() => {
|
|
440
816
|
this.main.values.hasChildNodes() && this.main.values.contains(e) && this.main.values.removeChild(e);
|
|
441
|
-
}
|
|
817
|
+
});
|
|
442
818
|
e = this.main.values.childNodes;
|
|
443
819
|
for (let n = 0; n < t.length; n++) {
|
|
444
820
|
let r = !0;
|
|
445
821
|
for (let i = 0; i < e.length; i++) t[n].id === String(e[i].dataset.id) && (r = !1);
|
|
446
822
|
r && (this.settings.keepOrder || e.length === 0 ? this.main.values.appendChild(this.multipleValue(t[n])) : n === 0 ? this.main.values.insertBefore(this.multipleValue(t[n]), e[n]) : e[n - 1].insertAdjacentElement("afterend", this.multipleValue(t[n])));
|
|
447
823
|
}
|
|
824
|
+
this.updateMultipleValueDeleteVisibility();
|
|
825
|
+
}
|
|
826
|
+
isAtMinSelected() {
|
|
827
|
+
return this.settings.isMultiple && this.settings.minSelected > 0 && this.store.getSelectedOptions().length <= this.settings.minSelected;
|
|
828
|
+
}
|
|
829
|
+
getMinimumSelectionIds() {
|
|
830
|
+
let e = this.store.getSelectedOptions();
|
|
831
|
+
return this.settings.keepOrder && (e = this.store.selectedOrderOptions(e)), e.slice(0, this.settings.minSelected).map((e) => e.id);
|
|
832
|
+
}
|
|
833
|
+
updateMultipleValueDeleteVisibility() {
|
|
834
|
+
if (!this.settings.isMultiple || this.settings.multiString) return;
|
|
835
|
+
let e = !this.isAtMinSelected(), t = this.main.values.querySelectorAll("." + this.classes.getFirst("valueDelete"));
|
|
836
|
+
for (let n of t) e ? this.removeClasses(n, this.classes.hide) : this.addClasses(n, this.classes.hide);
|
|
448
837
|
}
|
|
449
838
|
multipleValue(e) {
|
|
450
839
|
let t = document.createElement("div");
|
|
@@ -452,16 +841,16 @@ var u = class {
|
|
|
452
841
|
let n = document.createElement("div");
|
|
453
842
|
if (this.addClasses(n, this.classes.valueText), n.textContent = e.text, t.appendChild(n), !e.mandatory) {
|
|
454
843
|
let n = document.createElement("div");
|
|
455
|
-
this.addClasses(n, this.classes.valueDelete), n.setAttribute("tabindex", "0"), n.setAttribute("role", "button"), n.setAttribute("aria-label", `${this.settings.removeText} ${e.text}`), n.onclick = (t) => {
|
|
844
|
+
this.addClasses(n, this.classes.valueDelete), n.setAttribute("tabindex", "0"), n.setAttribute("role", "button"), n.setAttribute("aria-label", `${this.settings.removeText} ${e.text}`), this.isAtMinSelected() && this.addClasses(n, this.classes.hide), n.onclick = (t) => {
|
|
456
845
|
if (t.preventDefault(), t.stopPropagation(), this.settings.disabled) return;
|
|
457
846
|
let n = !0, r = this.store.getSelectedOptions(), i = r.filter((t) => t.selected && t.id !== e.id, !0);
|
|
458
847
|
if (!(this.settings.minSelected && i.length < this.settings.minSelected) && (this.callbacks.beforeChange && (n = this.callbacks.beforeChange(i, r) === !0), n)) {
|
|
459
848
|
let e = [];
|
|
460
849
|
for (let t of i) {
|
|
461
|
-
if (t instanceof
|
|
462
|
-
t instanceof
|
|
850
|
+
if (t instanceof L) for (let n of t.options) n.id && e.push(n.id);
|
|
851
|
+
t instanceof I && e.push(t.id);
|
|
463
852
|
}
|
|
464
|
-
this.callbacks.setSelected(e, !1), this.settings.closeOnSelect && this.callbacks.close(), this.callbacks.afterChange && this.callbacks.afterChange(i), this.updateDeselectAll();
|
|
853
|
+
this.callbacks.setSelected(e, !1), this.settings.closeOnSelect && this.callbacks.close(), this.callbacks.afterChange && this.callbacks.afterChange(i), this.updateDeselectAll(), this.updateMultipleValueDeleteVisibility();
|
|
465
854
|
}
|
|
466
855
|
};
|
|
467
856
|
let r = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
@@ -492,18 +881,39 @@ var u = class {
|
|
|
492
881
|
this.settings.showSearch && (this.content.status.textContent = e);
|
|
493
882
|
}
|
|
494
883
|
moveContent() {
|
|
495
|
-
if (this.
|
|
496
|
-
this.
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
this.
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
this.
|
|
504
|
-
|
|
884
|
+
if (!this.isModalViewActive()) {
|
|
885
|
+
if (this.settings.contentPosition === "relative") {
|
|
886
|
+
this.moveContentBelow();
|
|
887
|
+
return;
|
|
888
|
+
}
|
|
889
|
+
if (this.settings.openPosition === "down") {
|
|
890
|
+
this.moveContentBelow();
|
|
891
|
+
return;
|
|
892
|
+
} else if (this.settings.openPosition === "up") {
|
|
893
|
+
this.moveContentAbove();
|
|
894
|
+
return;
|
|
895
|
+
}
|
|
896
|
+
this.putContent() === "up" ? this.moveContentAbove() : this.moveContentBelow();
|
|
505
897
|
}
|
|
506
|
-
|
|
898
|
+
}
|
|
899
|
+
startPositionTracking() {
|
|
900
|
+
this.settings.contentPosition !== "absolute" || this.isModalViewActive() || (this.stopPositionTracking(), !(typeof ResizeObserver > "u") && (this.positionObserver = new ResizeObserver(() => {
|
|
901
|
+
this.settings.isOpen && (cancelAnimationFrame(this.positionObserverRaf), this.positionObserverRaf = requestAnimationFrame(() => {
|
|
902
|
+
this.moveContent();
|
|
903
|
+
}));
|
|
904
|
+
}), this.observePositionTargets()));
|
|
905
|
+
}
|
|
906
|
+
stopPositionTracking() {
|
|
907
|
+
cancelAnimationFrame(this.positionObserverRaf), this.positionObserver?.disconnect(), this.positionObserver = null;
|
|
908
|
+
}
|
|
909
|
+
observePositionTargets() {
|
|
910
|
+
if (!this.positionObserver) return;
|
|
911
|
+
let e = /* @__PURE__ */ new Set(), t = (t) => {
|
|
912
|
+
!t || e.has(t) || (e.add(t), this.positionObserver.observe(t));
|
|
913
|
+
};
|
|
914
|
+
t(this.main.main), t(this.content.main);
|
|
915
|
+
let n = this.main.main.parentElement, r = this.settings.contentLocation;
|
|
916
|
+
for (let e = 0; n && e < 8 && (t(n), n !== r); e++) n = n.parentElement;
|
|
507
917
|
}
|
|
508
918
|
searchDiv() {
|
|
509
919
|
let e = document.createElement("div"), t = document.createElement("input"), n = document.createElement("div");
|
|
@@ -512,7 +922,7 @@ var u = class {
|
|
|
512
922
|
main: e,
|
|
513
923
|
input: t
|
|
514
924
|
};
|
|
515
|
-
if (this.settings.showSearch || (this.addClasses(e, this.classes.hide), t.readOnly = !0), t.type = "search", t.placeholder = this.settings.searchPlaceholder, t.tabIndex = -1, t.setAttribute("aria-label", this.settings.searchPlaceholder), t.setAttribute("aria-autocomplete", "list"), t.setAttribute("autocapitalize", "off"), t.setAttribute("autocomplete", "off"), t.setAttribute("autocorrect", "off"), t.setAttribute("aria-hidden", "true"), t.oninput =
|
|
925
|
+
if (this.settings.showSearch || (this.addClasses(e, this.classes.hide), t.readOnly = !0), t.type = "search", t.placeholder = this.settings.searchPlaceholder, t.tabIndex = -1, t.setAttribute("aria-label", this.settings.searchPlaceholder), t.setAttribute("aria-autocomplete", "list"), t.setAttribute("autocapitalize", "off"), t.setAttribute("autocomplete", "off"), t.setAttribute("autocorrect", "off"), t.setAttribute("aria-hidden", "true"), t.oninput = C((e) => {
|
|
516
926
|
this.callbacks.search(e.target.value);
|
|
517
927
|
}, 100), t.onkeydown = (e) => {
|
|
518
928
|
switch (e.key) {
|
|
@@ -541,14 +951,17 @@ var u = class {
|
|
|
541
951
|
return;
|
|
542
952
|
}
|
|
543
953
|
let n = (e) => {
|
|
544
|
-
let t = new
|
|
954
|
+
let t = new I(e);
|
|
545
955
|
if (this.callbacks.addOption(t), this.settings.isMultiple) {
|
|
546
956
|
let e = this.store.getSelected();
|
|
547
957
|
e.push(t.id), this.callbacks.setSelected(e, !0);
|
|
548
958
|
} else this.callbacks.setSelected([t.id], !0);
|
|
549
|
-
this.callbacks.search(""), this.settings.closeOnSelect
|
|
550
|
-
this.
|
|
551
|
-
|
|
959
|
+
if (this.callbacks.search(""), this.settings.closeOnSelect) {
|
|
960
|
+
let e = d(this.content.main);
|
|
961
|
+
setTimeout(() => {
|
|
962
|
+
this.callbacks.close();
|
|
963
|
+
}, e);
|
|
964
|
+
}
|
|
552
965
|
}, r = this.callbacks.addable(t);
|
|
553
966
|
r === !1 || r == null || (r instanceof Promise ? r.then((e) => {
|
|
554
967
|
typeof e == "string" ? n({
|
|
@@ -616,17 +1029,18 @@ var u = class {
|
|
|
616
1029
|
return e.id = t, e.dataset.id = t, e;
|
|
617
1030
|
}
|
|
618
1031
|
renderError(e) {
|
|
619
|
-
this.content.list.innerHTML = "";
|
|
1032
|
+
this.optionsListIsFullData = !1, this.content.list.innerHTML = "";
|
|
620
1033
|
let t = document.createElement("div");
|
|
621
1034
|
this.addClasses(t, this.classes.error), t.textContent = e, this.content.list.appendChild(t);
|
|
622
1035
|
}
|
|
623
1036
|
renderSearching() {
|
|
624
|
-
this.content.list.innerHTML = "";
|
|
1037
|
+
this.optionsListIsFullData = !1, this.content.list.innerHTML = "";
|
|
625
1038
|
let e = document.createElement("div");
|
|
626
1039
|
this.addClasses(e, this.classes.searching), e.textContent = this.settings.searchingText, this.content.list.appendChild(e), this.announce(this.settings.searchingText);
|
|
627
1040
|
}
|
|
628
1041
|
renderOptions(e) {
|
|
629
|
-
if (this.lastRenderedOptions = e.map((e) => e instanceof
|
|
1042
|
+
if (this.lastSearchFilterTerm = "", this.lastRenderedOptions = e.map((e) => e instanceof I ? [e] : e.options.map((e) => new I(e))).flat(), this.content.list.innerHTML = "", e.length === 0) {
|
|
1043
|
+
this.optionsListIsFullData = !1;
|
|
630
1044
|
let e = document.createElement("div");
|
|
631
1045
|
if (this.addClasses(e, this.classes.search), this.callbacks.addable) {
|
|
632
1046
|
let t = this.settings.addableText.replace("{value}", this.content.search.input.value);
|
|
@@ -635,7 +1049,7 @@ var u = class {
|
|
|
635
1049
|
this.content.list.appendChild(e);
|
|
636
1050
|
return;
|
|
637
1051
|
}
|
|
638
|
-
this.settings.allowDeselect && !this.settings.isMultiple && (this.store.filter((e) => e.placeholder, !1).length || this.store.addOption(new
|
|
1052
|
+
this.settings.allowDeselect && !this.settings.isMultiple && (this.store.filter((e) => e.placeholder, !1, !1).length || this.store.addOption(new I({
|
|
639
1053
|
text: "",
|
|
640
1054
|
value: "",
|
|
641
1055
|
selected: !1,
|
|
@@ -643,7 +1057,7 @@ var u = class {
|
|
|
643
1057
|
}), !0));
|
|
644
1058
|
let t = document.createDocumentFragment();
|
|
645
1059
|
for (let n of e) {
|
|
646
|
-
if (n instanceof
|
|
1060
|
+
if (n instanceof L) {
|
|
647
1061
|
let e = document.createElement("div");
|
|
648
1062
|
this.addClasses(e, this.classes.optgroup);
|
|
649
1063
|
let r = document.createElement("div");
|
|
@@ -654,14 +1068,10 @@ var u = class {
|
|
|
654
1068
|
if (this.addClasses(a, this.classes.optgroupActions), r.appendChild(a), this.settings.isMultiple && n.selectAll) {
|
|
655
1069
|
let e = document.createElement("div");
|
|
656
1070
|
this.addClasses(e, this.classes.optgroupSelectAll);
|
|
657
|
-
let t =
|
|
658
|
-
for (let e of n.options) if (!e.selected) {
|
|
659
|
-
t = !1;
|
|
660
|
-
break;
|
|
661
|
-
}
|
|
1071
|
+
let t = this.isOptgroupAllSelected(n.options);
|
|
662
1072
|
t && this.addClasses(e, this.classes.selected);
|
|
663
1073
|
let r = document.createElement("span");
|
|
664
|
-
r.textContent =
|
|
1074
|
+
r.textContent = this.optgroupSelectAllLabel(t), e.appendChild(r);
|
|
665
1075
|
let i = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
666
1076
|
i.setAttribute("viewBox", "0 0 100 100"), e.appendChild(i);
|
|
667
1077
|
let o = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
@@ -669,18 +1079,18 @@ var u = class {
|
|
|
669
1079
|
let s = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
670
1080
|
s.setAttribute("d", this.classes.optgroupSelectAllCheck), i.appendChild(s), e.addEventListener("click", (e) => {
|
|
671
1081
|
e.preventDefault(), e.stopPropagation();
|
|
672
|
-
let
|
|
673
|
-
if (t) {
|
|
674
|
-
let e =
|
|
1082
|
+
let t = this.store.getSelected();
|
|
1083
|
+
if (this.isOptgroupAllSelected(n.options, new Set(t))) {
|
|
1084
|
+
let e = t.filter((e) => {
|
|
675
1085
|
for (let t of n.options) if (e === t.id) return !1;
|
|
676
1086
|
return !0;
|
|
677
1087
|
});
|
|
678
1088
|
this.callbacks.setSelected(e, !0);
|
|
679
1089
|
return;
|
|
680
1090
|
} else {
|
|
681
|
-
let e = n.options.map((e) => e.id).filter((e) => e !== void 0),
|
|
682
|
-
for (let e of n.options) e.id && !this.store.getOptionByID(e.id) && this.callbacks.addOption(new
|
|
683
|
-
this.callbacks.setSelected(
|
|
1091
|
+
let e = n.options.map((e) => e.id).filter((e) => e !== void 0), r = t.concat(e);
|
|
1092
|
+
for (let e of n.options) e.id && !this.store.getOptionByID(e.id) && this.callbacks.addOption(new I(e));
|
|
1093
|
+
this.callbacks.setSelected(r, !0);
|
|
684
1094
|
return;
|
|
685
1095
|
}
|
|
686
1096
|
}), a.appendChild(e);
|
|
@@ -691,16 +1101,136 @@ var u = class {
|
|
|
691
1101
|
let i = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
692
1102
|
i.setAttribute("viewBox", "0 0 100 100"), this.addClasses(i, this.classes.arrow), t.appendChild(i);
|
|
693
1103
|
let o = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
694
|
-
i.appendChild(o), n.options.some((e) => e.selected) || this.content.search.input.value.trim() !== "" ? (this.addClasses(t, this.classes.mainOpen), o.setAttribute("d", this.classes.arrowOpen)) : n.closable === "open" ? (this.addClasses(e, this.classes.mainOpen), o.setAttribute("d", this.classes.arrowOpen)) : n.closable === "close" && (this.addClasses(e, this.classes.close), o.setAttribute("d", this.classes.arrowClose)), r.addEventListener("click", (
|
|
695
|
-
|
|
1104
|
+
i.appendChild(o), n.options.some((e) => e.selected) || this.content.search.input.value.trim() !== "" ? (this.addClasses(t, this.classes.mainOpen), o.setAttribute("d", this.classes.arrowOpen)) : n.closable === "open" ? (this.addClasses(e, this.classes.mainOpen), o.setAttribute("d", this.classes.arrowOpen)) : n.closable === "close" && (this.addClasses(e, this.classes.close), o.setAttribute("d", this.classes.arrowClose)), r.addEventListener("click", (n) => {
|
|
1105
|
+
n.preventDefault(), n.stopPropagation(), this.isClosableOptgroupOpen(e, t) ? (this.removeClasses(e, this.classes.mainOpen), this.removeClasses(t, this.classes.mainOpen), this.addClasses(e, this.classes.close), o.setAttribute("d", this.classes.arrowClose)) : (this.closeOtherClosableOptgroups(e), this.removeClasses(e, this.classes.close), this.removeClasses(t, this.classes.mainOpen), this.addClasses(e, this.classes.mainOpen), o.setAttribute("d", this.classes.arrowOpen));
|
|
696
1106
|
}), a.appendChild(t);
|
|
697
1107
|
}
|
|
698
1108
|
e.appendChild(r);
|
|
699
|
-
for (let r of n.options) e.appendChild(this.option(new
|
|
1109
|
+
for (let r of n.options) e.appendChild(this.option(new I(r))), t.appendChild(e);
|
|
1110
|
+
}
|
|
1111
|
+
n instanceof I && t.appendChild(this.option(n));
|
|
1112
|
+
}
|
|
1113
|
+
this.content.list.appendChild(t), this.setOptionsListFullData(e), this.announce(this.settings.resultsText.replace("{count}", String(this.lastRenderedOptions.length)));
|
|
1114
|
+
}
|
|
1115
|
+
canFilterOptionsInPlace() {
|
|
1116
|
+
return this.optionsListIsFullData ? this.content.list.querySelector("." + this.classes.getFirst("option")) !== null : !1;
|
|
1117
|
+
}
|
|
1118
|
+
resetSearchFilterState() {
|
|
1119
|
+
this.lastSearchFilterTerm = "";
|
|
1120
|
+
}
|
|
1121
|
+
filterOptionsInPlace(e, t) {
|
|
1122
|
+
let n = e.trim();
|
|
1123
|
+
if (n === this.lastSearchFilterTerm) return;
|
|
1124
|
+
this.lastSearchFilterTerm = n;
|
|
1125
|
+
let r = [], i = this.content.list.querySelectorAll("." + this.classes.getFirst("option"));
|
|
1126
|
+
for (let e of i) {
|
|
1127
|
+
let i = e.dataset.id;
|
|
1128
|
+
if (!i) continue;
|
|
1129
|
+
let a = this.store.getOptionByID(i);
|
|
1130
|
+
if (!a) continue;
|
|
1131
|
+
let o = a.placeholder || !a.display || a.selected && this.settings.hideSelected, s = t(a, n);
|
|
1132
|
+
o || !s ? (this.addClasses(e, this.classes.hide), this.removeClasses(e, this.classes.highlighted)) : (this.removeClasses(e, this.classes.hide), this.setOptionElementContent(e, a, n), r.push(a)), a.selected ? (this.addClasses(e, this.classes.selected), e.setAttribute("aria-selected", "true")) : (this.removeClasses(e, this.classes.selected), e.setAttribute("aria-selected", "false"));
|
|
1133
|
+
}
|
|
1134
|
+
this.lastRenderedOptions = r, this.updateOptgroupVisibilityAfterSearch(n), r.length === 0 ? this.updateSearchResultsMessage(0, n) : (this.removeListSearchMessage(), this.announce(this.settings.resultsText.replace("{count}", String(r.length)))), this.updateOptgroupSelectAllStates();
|
|
1135
|
+
}
|
|
1136
|
+
setOptionsListFullData(e) {
|
|
1137
|
+
let t = this.store.getDataOptions(!1), n = e.map((e) => e instanceof I ? [e] : e.options.map((e) => new I(e))).flat();
|
|
1138
|
+
if (n.length !== t.length) {
|
|
1139
|
+
this.optionsListIsFullData = !1;
|
|
1140
|
+
return;
|
|
1141
|
+
}
|
|
1142
|
+
let r = new Set(t.map((e) => e.id));
|
|
1143
|
+
this.optionsListIsFullData = n.every((e) => r.has(e.id));
|
|
1144
|
+
}
|
|
1145
|
+
isClosableOptgroupOpen(e, t) {
|
|
1146
|
+
return e.classList.contains(this.classes.getFirst("close")) ? !1 : e.classList.contains(this.classes.getFirst("mainOpen")) || t.classList.contains(this.classes.getFirst("mainOpen"));
|
|
1147
|
+
}
|
|
1148
|
+
closeClosableOptgroup(e) {
|
|
1149
|
+
let t = e.querySelector("." + this.classes.getFirst("optgroupClosable"));
|
|
1150
|
+
if (!t || e.classList.contains(this.classes.getFirst("close"))) return;
|
|
1151
|
+
this.removeClasses(e, this.classes.mainOpen), this.removeClasses(t, this.classes.mainOpen), this.addClasses(e, this.classes.close);
|
|
1152
|
+
let n = t.querySelector("path");
|
|
1153
|
+
n && n.setAttribute("d", this.classes.arrowClose);
|
|
1154
|
+
}
|
|
1155
|
+
closeOtherClosableOptgroups(e) {
|
|
1156
|
+
let t = this.content.list.querySelectorAll("." + this.classes.getFirst("optgroup"));
|
|
1157
|
+
for (let n of t) n !== e && this.closeClosableOptgroup(n);
|
|
1158
|
+
}
|
|
1159
|
+
updateOptgroupVisibilityAfterSearch(e) {
|
|
1160
|
+
let t = this.content.list.querySelectorAll("." + this.classes.getFirst("optgroup"));
|
|
1161
|
+
for (let n of t) {
|
|
1162
|
+
let t = n.querySelectorAll("." + this.classes.getFirst("option")), r = !1;
|
|
1163
|
+
for (let e of t) if (!e.classList.contains(this.classes.getFirst("hide"))) {
|
|
1164
|
+
r = !0;
|
|
1165
|
+
break;
|
|
1166
|
+
}
|
|
1167
|
+
if (!r) {
|
|
1168
|
+
this.addClasses(n, this.classes.hide);
|
|
1169
|
+
continue;
|
|
1170
|
+
}
|
|
1171
|
+
this.removeClasses(n, this.classes.hide), e !== "" && (this.removeClasses(n, this.classes.close), this.addClasses(n, this.classes.mainOpen));
|
|
1172
|
+
}
|
|
1173
|
+
}
|
|
1174
|
+
updateSearchResultsMessage(e, t) {
|
|
1175
|
+
if (this.removeListSearchMessage(), e > 0) return;
|
|
1176
|
+
let n = document.createElement("div");
|
|
1177
|
+
if (this.addClasses(n, this.classes.search), this.callbacks.addable) {
|
|
1178
|
+
let e = this.settings.addableText.replace("{value}", t);
|
|
1179
|
+
n.innerHTML = e, this.announce(e);
|
|
1180
|
+
} else n.innerHTML = this.settings.searchText, this.announce(this.settings.searchText);
|
|
1181
|
+
this.content.list.appendChild(n);
|
|
1182
|
+
}
|
|
1183
|
+
removeListSearchMessage() {
|
|
1184
|
+
this.content.list.querySelectorAll("." + this.classes.getFirst("search")).forEach((e) => e.remove());
|
|
1185
|
+
}
|
|
1186
|
+
setOptionElementContent(e, t, n) {
|
|
1187
|
+
let r = n.trim();
|
|
1188
|
+
this.settings.searchHighlight && r !== "" ? e.innerHTML = this.highlightText(t.html === "" ? t.text : t.html, r, this.classes.searchHighlighter) : t.html === "" ? e.textContent = t.text : e.innerHTML = t.html, this.settings.showOptionTooltips && e.textContent ? e.setAttribute("title", e.textContent) : e.removeAttribute("title");
|
|
1189
|
+
}
|
|
1190
|
+
hasRenderedOptions() {
|
|
1191
|
+
return this.content.list.querySelector("." + this.classes.getFirst("option")) !== null;
|
|
1192
|
+
}
|
|
1193
|
+
canUpdateOptionSelectionInPlace() {
|
|
1194
|
+
return this.content.search.input.value.trim() === "" ? this.hasRenderedOptions() : !1;
|
|
1195
|
+
}
|
|
1196
|
+
updateOptionSelection() {
|
|
1197
|
+
let e = new Set(this.store.getSelected()), t = this.content.list.querySelectorAll("." + this.classes.getFirst("option")), n = null;
|
|
1198
|
+
for (let r of t) {
|
|
1199
|
+
let t = r.dataset.id;
|
|
1200
|
+
if (!t) continue;
|
|
1201
|
+
let i = this.store.getOptionByID(t);
|
|
1202
|
+
if (!i) continue;
|
|
1203
|
+
let a = e.has(t);
|
|
1204
|
+
a ? (this.addClasses(r, this.classes.selected), r.setAttribute("aria-selected", "true"), n = r) : (this.removeClasses(r, this.classes.selected), r.setAttribute("aria-selected", "false")), this.settings.hideSelected && (a ? this.addClasses(r, this.classes.hide) : (this.removeClasses(r, this.classes.hide), i.display || this.addClasses(r, this.classes.hide)));
|
|
1205
|
+
}
|
|
1206
|
+
!this.settings.isMultiple && n ? this.main.main.setAttribute("aria-activedescendant", n.id) : !this.settings.isMultiple && e.size === 0 && this.main.main.removeAttribute("aria-activedescendant"), this.updateOptgroupSelectAllStates();
|
|
1207
|
+
}
|
|
1208
|
+
updateOptgroupSelectAllStates() {
|
|
1209
|
+
if (!this.settings.isMultiple) return;
|
|
1210
|
+
let e = new Set(this.store.getSelected()), t = this.content.list.querySelectorAll("." + this.classes.getFirst("optgroup"));
|
|
1211
|
+
for (let n of t) {
|
|
1212
|
+
let t = n.querySelector("." + this.classes.getFirst("optgroupSelectAll"));
|
|
1213
|
+
if (!t) continue;
|
|
1214
|
+
let r = n.querySelectorAll("." + this.classes.getFirst("option")), i = r.length > 0;
|
|
1215
|
+
for (let t of r) {
|
|
1216
|
+
let n = t.dataset.id;
|
|
1217
|
+
if (!n || !e.has(n)) {
|
|
1218
|
+
i = !1;
|
|
1219
|
+
break;
|
|
1220
|
+
}
|
|
700
1221
|
}
|
|
701
|
-
|
|
1222
|
+
i ? this.addClasses(t, this.classes.selected) : this.removeClasses(t, this.classes.selected);
|
|
1223
|
+
let a = t.querySelector("span");
|
|
1224
|
+
a && (a.textContent = this.optgroupSelectAllLabel(i));
|
|
702
1225
|
}
|
|
703
|
-
|
|
1226
|
+
}
|
|
1227
|
+
optgroupSelectAllLabel(e) {
|
|
1228
|
+
return e ? "Unselect All" : "Select All";
|
|
1229
|
+
}
|
|
1230
|
+
isOptgroupAllSelected(e, t) {
|
|
1231
|
+
if (e.length === 0) return !1;
|
|
1232
|
+
for (let n of e) if (!(t ? n.id && t.has(n.id) : n.selected)) return !1;
|
|
1233
|
+
return !0;
|
|
704
1234
|
}
|
|
705
1235
|
option(e) {
|
|
706
1236
|
if (e.placeholder) {
|
|
@@ -710,7 +1240,7 @@ var u = class {
|
|
|
710
1240
|
let t = document.createElement("div");
|
|
711
1241
|
return t.dataset.id = e.id, t.id = this.settings.id + "-" + e.id, this.addClasses(t, this.classes.option), t.setAttribute("role", "option"), e.class && e.class.split(" ").forEach((e) => {
|
|
712
1242
|
t.classList.add(e);
|
|
713
|
-
}), e.style && (t.style.cssText = e.style), this.
|
|
1243
|
+
}), e.style && (t.style.cssText = e.style), this.setOptionElementContent(t, e, this.content.search.input.value), e.display || this.addClasses(t, this.classes.hide), e.disabled && this.addClasses(t, this.classes.disabled), e.selected && this.settings.hideSelected && this.addClasses(t, this.classes.hide), e.selected ? (this.addClasses(t, this.classes.selected), t.setAttribute("aria-selected", "true"), this.main.main.setAttribute("aria-activedescendant", t.id)) : (this.removeClasses(t, this.classes.selected), t.setAttribute("aria-selected", "false")), t.addEventListener("click", (t) => {
|
|
714
1244
|
t.preventDefault(), t.stopPropagation();
|
|
715
1245
|
let n = this.store.getSelected(), r = t.currentTarget, i = String(r.dataset.id), a = t.ctrlKey || t.metaKey;
|
|
716
1246
|
if (e.disabled || !this.settings.isMultiple && e.selected && !this.settings.allowDeselect || e.selected && e.mandatory || this.settings.isMultiple && this.settings.maxSelected <= n.length && !e.selected || this.settings.isMultiple && this.settings.minSelected >= n.length && e.selected && !a) return;
|
|
@@ -733,7 +1263,7 @@ var u = class {
|
|
|
733
1263
|
}), t;
|
|
734
1264
|
}
|
|
735
1265
|
destroy() {
|
|
736
|
-
this.
|
|
1266
|
+
this.stopPositionTracking(), this.modalElements &&= (this.unlockBodyScroll(), this.content.main.parentElement === this.modalElements.dialog && this.restoreContentOffscreen(), this.modalElements.overlay.remove(), null), this.main.main.remove(), this.content.main.remove();
|
|
737
1267
|
}
|
|
738
1268
|
highlightText(e, t, n) {
|
|
739
1269
|
let r = t.trim();
|
|
@@ -801,10 +1331,34 @@ var u = class {
|
|
|
801
1331
|
}
|
|
802
1332
|
updateDeselectAll() {
|
|
803
1333
|
if (!this.store || !this.settings) return;
|
|
804
|
-
let e = this.store.getSelectedOptions(), t = e && e.length > 0, n = this.settings.isMultiple, r = this.settings.allowDeselect, i = this.main.deselect.main,
|
|
805
|
-
r && !(n && !t) ? this.removeClasses(
|
|
1334
|
+
let e = this.store.getSelectedOptions(), t = e && e.length > 0, n = this.settings.isMultiple, r = this.settings.allowDeselect, i = this.isAtMinSelected(), a = this.main.deselect.main, o = this.classes.hide;
|
|
1335
|
+
r && !(n && !t) && !i ? this.removeClasses(a, o) : this.addClasses(a, o);
|
|
1336
|
+
}
|
|
1337
|
+
};
|
|
1338
|
+
//#endregion
|
|
1339
|
+
//#region src/slim-select/mutations.ts
|
|
1340
|
+
function B(e, t) {
|
|
1341
|
+
let n = {
|
|
1342
|
+
classChanged: !1,
|
|
1343
|
+
disabledChanged: !1,
|
|
1344
|
+
optgroupOptionChanged: !1,
|
|
1345
|
+
selectionChanged: !1
|
|
1346
|
+
};
|
|
1347
|
+
for (let r of e) {
|
|
1348
|
+
if (r.target === t && (r.attributeName === "disabled" && (n.disabledChanged = !0), r.attributeName === "class" && (n.classChanged = !0), r.type === "childList")) {
|
|
1349
|
+
for (let e of Array.from(r.addedNodes)) if (e.nodeName === "OPTION" && e.value === t.value) {
|
|
1350
|
+
n.selectionChanged = !0;
|
|
1351
|
+
break;
|
|
1352
|
+
}
|
|
1353
|
+
n.optgroupOptionChanged = !0;
|
|
1354
|
+
}
|
|
1355
|
+
(r.target.nodeName === "OPTGROUP" || r.target.nodeName === "OPTION") && (n.optgroupOptionChanged = !0);
|
|
806
1356
|
}
|
|
807
|
-
|
|
1357
|
+
return n;
|
|
1358
|
+
}
|
|
1359
|
+
//#endregion
|
|
1360
|
+
//#region src/slim-select/select.ts
|
|
1361
|
+
var V = class {
|
|
808
1362
|
select;
|
|
809
1363
|
onValueChange;
|
|
810
1364
|
onClassChange;
|
|
@@ -866,29 +1420,19 @@ var u = class {
|
|
|
866
1420
|
}
|
|
867
1421
|
observeCall(e) {
|
|
868
1422
|
if (!this.listen) return;
|
|
869
|
-
let
|
|
870
|
-
for (let a of e) {
|
|
871
|
-
if (a.target === this.select && (a.attributeName === "disabled" && (n = !0), a.attributeName === "class" && (t = !0), a.type === "childList")) {
|
|
872
|
-
for (let e of Array.from(a.addedNodes)) if (e.nodeName === "OPTION" && e.value === this.select.value) {
|
|
873
|
-
i = !0;
|
|
874
|
-
break;
|
|
875
|
-
}
|
|
876
|
-
r = !0;
|
|
877
|
-
}
|
|
878
|
-
(a.target.nodeName === "OPTGROUP" || a.target.nodeName === "OPTION") && (r = !0);
|
|
879
|
-
}
|
|
1423
|
+
let { classChanged: t, disabledChanged: n, optgroupOptionChanged: r, selectionChanged: i } = B(e, this.select), a = i;
|
|
880
1424
|
if (t && this.onClassChange && this.onClassChange(this.select.className.split(" ")), n && this.onDisabledChange && (this.changeListen(!1), this.onDisabledChange(this.select.disabled), this.changeListen(!0)), r && this.onOptionsChange) {
|
|
881
1425
|
if (this.isUpdating) {
|
|
882
1426
|
if (this.select.options.length > 0) {
|
|
883
1427
|
let e = this.getData();
|
|
884
1428
|
e.length > 0 && (this.pendingOptionsChange = e);
|
|
885
1429
|
}
|
|
886
|
-
|
|
1430
|
+
a && this.select.dispatchEvent(new Event("change"));
|
|
887
1431
|
return;
|
|
888
1432
|
}
|
|
889
|
-
this.changeListen(!1), this.onOptionsChange(this.getData()), this.changeListen(!0);
|
|
1433
|
+
this.changeListen(!1), this.onOptionsChange(this.getData()), this.changeListen(!0), a = !1;
|
|
890
1434
|
}
|
|
891
|
-
|
|
1435
|
+
a && this.select.dispatchEvent(new Event("change"));
|
|
892
1436
|
}
|
|
893
1437
|
getData() {
|
|
894
1438
|
let e = [], t = this.select.childNodes;
|
|
@@ -900,7 +1444,6 @@ var u = class {
|
|
|
900
1444
|
id: e.id,
|
|
901
1445
|
label: e.label,
|
|
902
1446
|
selectAll: e.dataset ? e.dataset.selectall === "true" : !1,
|
|
903
|
-
selectAllText: e.dataset ? e.dataset.selectalltext : "Select all",
|
|
904
1447
|
closable: e.dataset ? e.dataset.closable : "off",
|
|
905
1448
|
options: []
|
|
906
1449
|
}, n = e.childNodes;
|
|
@@ -921,7 +1464,7 @@ var u = class {
|
|
|
921
1464
|
placeholder: e.dataset.placeholder === "true",
|
|
922
1465
|
class: e.className,
|
|
923
1466
|
style: e.style.cssText,
|
|
924
|
-
data: e.dataset
|
|
1467
|
+
data: v(e.dataset)
|
|
925
1468
|
};
|
|
926
1469
|
}
|
|
927
1470
|
getSelectedOptions() {
|
|
@@ -960,7 +1503,8 @@ var u = class {
|
|
|
960
1503
|
t.selected = e.includes(t.id);
|
|
961
1504
|
}
|
|
962
1505
|
}
|
|
963
|
-
this.
|
|
1506
|
+
let n = this.getSelectedOptions();
|
|
1507
|
+
this.select.multiple || (this.select.value = n.length === 1 ? n[0].value : ""), this.changeListen(!0);
|
|
964
1508
|
}
|
|
965
1509
|
setSelectedByValue(e) {
|
|
966
1510
|
this.changeListen(!1);
|
|
@@ -978,7 +1522,8 @@ var u = class {
|
|
|
978
1522
|
t.selected = e.includes(t.value);
|
|
979
1523
|
}
|
|
980
1524
|
}
|
|
981
|
-
this.
|
|
1525
|
+
let n = this.getSelectedOptions();
|
|
1526
|
+
this.select.multiple || (this.select.value = n.length === 1 ? n[0].value : ""), this.changeListen(!0);
|
|
982
1527
|
}
|
|
983
1528
|
updateSelect(e, t, n) {
|
|
984
1529
|
this.changeListen(!1), e && (this.select.dataset.id = e), t && (this.select.style.cssText = t), n && (this.select.className = "", n.forEach((e) => {
|
|
@@ -988,7 +1533,7 @@ var u = class {
|
|
|
988
1533
|
updateOptions(e) {
|
|
989
1534
|
if (!(!e || e.length === 0)) {
|
|
990
1535
|
this.isUpdating = !0, this.pendingOptionsChange = null, this.changeListen(!1), this.select.innerHTML = "";
|
|
991
|
-
for (let t of e) t instanceof
|
|
1536
|
+
for (let t of e) t instanceof L && this.select.appendChild(this.createOptgroup(t)), t instanceof I && this.select.appendChild(this.createOption(t));
|
|
992
1537
|
if (this.select.dispatchEvent(new Event("change", { bubbles: !0 })), this.changeListen(!0), this.isUpdating = !1, this.pendingOptionsChange !== null) {
|
|
993
1538
|
let e = this.pendingOptionsChange;
|
|
994
1539
|
e.length > 0 && this.onOptionsChange ? (this.pendingOptionsChange = null, this.changeListen(!1), this.onOptionsChange(e), this.changeListen(!0)) : this.pendingOptionsChange = null;
|
|
@@ -1005,7 +1550,7 @@ var u = class {
|
|
|
1005
1550
|
return t.id = e.id, t.value = e.value, t.textContent = e.text, e.html !== "" && t.setAttribute("data-html", e.html), t.defaultSelected = e.defaultSelected, t.selected = e.selected, e.disabled && (t.disabled = !0), e.display || (t.style.display = "none"), e.placeholder && t.setAttribute("data-placeholder", "true"), e.mandatory && t.setAttribute("data-mandatory", "true"), e.class && e.class.split(" ").forEach((e) => {
|
|
1006
1551
|
t.classList.add(e);
|
|
1007
1552
|
}), e.data && typeof e.data == "object" && Object.keys(e.data).forEach((n) => {
|
|
1008
|
-
t.setAttribute("data-" +
|
|
1553
|
+
t.setAttribute("data-" + M(n), e.data[n]);
|
|
1009
1554
|
}), t;
|
|
1010
1555
|
}
|
|
1011
1556
|
setupLabelHandlers() {
|
|
@@ -1022,7 +1567,7 @@ var u = class {
|
|
|
1022
1567
|
Array.from(new Set(e)).forEach((e) => {
|
|
1023
1568
|
if (e.__slimSelectLabelHandler) return;
|
|
1024
1569
|
let t = (e) => {
|
|
1025
|
-
let t = e.target, n =
|
|
1570
|
+
let t = e.target, n = S(t, this.select.dataset.id);
|
|
1026
1571
|
e.preventDefault(), !n && this.onLabelClick && this.onLabelClick();
|
|
1027
1572
|
};
|
|
1028
1573
|
e.__slimSelectLabelHandler = t, e.addEventListener("click", t, {
|
|
@@ -1050,56 +1595,118 @@ var u = class {
|
|
|
1050
1595
|
destroy() {
|
|
1051
1596
|
this.changeListen(!1), this.select.removeEventListener("change", this.valueChange), this.preventNativeSelect &&= (this.select.removeEventListener("click", this.preventNativeSelect, { capture: !0 }), null), this.preventNativeSelectMousedown &&= (this.select.removeEventListener("mousedown", this.preventNativeSelectMousedown, { capture: !0 }), null), this.preventNativeSelectFocus &&= (this.select.removeEventListener("focus", this.preventNativeSelectFocus, { capture: !0 }), null), this.restoreAriaHiddenOnBlur &&= (this.select.removeEventListener("blur", this.restoreAriaHiddenOnBlur, { capture: !0 }), null), this.observer &&= (this.observer.disconnect(), null), this.removeLabelHandlers(), delete this.select.dataset.id, this.showUI();
|
|
1052
1597
|
}
|
|
1053
|
-
}
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
contentLocation;
|
|
1076
|
-
contentPosition;
|
|
1077
|
-
contentWidth;
|
|
1078
|
-
openPosition;
|
|
1079
|
-
placeholderText;
|
|
1080
|
-
allowDeselect;
|
|
1081
|
-
hideSelected;
|
|
1082
|
-
multiString;
|
|
1083
|
-
keepOrder;
|
|
1084
|
-
showOptionTooltips;
|
|
1085
|
-
minSelected;
|
|
1086
|
-
maxSelected;
|
|
1087
|
-
timeoutDelay;
|
|
1088
|
-
maxValuesShown;
|
|
1089
|
-
maxValuesMessage;
|
|
1090
|
-
addableText;
|
|
1598
|
+
};
|
|
1599
|
+
//#endregion
|
|
1600
|
+
//#region src/slim-select/sync.ts
|
|
1601
|
+
function H(e, t) {
|
|
1602
|
+
return j(e.getData(!1), t);
|
|
1603
|
+
}
|
|
1604
|
+
function U(e, t) {
|
|
1605
|
+
let n = Array.isArray(t) ? t : [t], r = e.getDataOptions(!1), i = [];
|
|
1606
|
+
for (let e of n) {
|
|
1607
|
+
if (r.find((t) => t.id == e)) {
|
|
1608
|
+
i.push(e);
|
|
1609
|
+
continue;
|
|
1610
|
+
}
|
|
1611
|
+
for (let t of r.filter((t) => t.value == e)) i.push(t.id);
|
|
1612
|
+
}
|
|
1613
|
+
return i;
|
|
1614
|
+
}
|
|
1615
|
+
var W = class {
|
|
1616
|
+
deps;
|
|
1617
|
+
queue = [];
|
|
1618
|
+
flushScheduled = !1;
|
|
1619
|
+
isSyncing = !1;
|
|
1091
1620
|
constructor(e) {
|
|
1092
|
-
|
|
1621
|
+
this.deps = e;
|
|
1622
|
+
}
|
|
1623
|
+
enqueue(e) {
|
|
1624
|
+
if (this.queue.push(e), e.source === "native") {
|
|
1625
|
+
this.flushScheduled || (this.flushScheduled = !0, queueMicrotask(() => this.flush()));
|
|
1626
|
+
return;
|
|
1627
|
+
}
|
|
1628
|
+
this.isSyncing || this.flush();
|
|
1629
|
+
}
|
|
1630
|
+
flush() {
|
|
1631
|
+
if (this.flushScheduled = !1, this.queue.length === 0) return;
|
|
1632
|
+
let e = this.coalesceBatch(this.queue);
|
|
1633
|
+
this.queue = [], this.isSyncing = !0;
|
|
1634
|
+
try {
|
|
1635
|
+
for (let t of e) this.applyChange(t);
|
|
1636
|
+
} finally {
|
|
1637
|
+
this.isSyncing = !1, this.queue.length > 0 && this.flush();
|
|
1638
|
+
}
|
|
1639
|
+
}
|
|
1640
|
+
coalesceBatch(e) {
|
|
1641
|
+
let t = e.some((e) => e.type === "structure"), n = e.some((e) => e.type === "addOption");
|
|
1642
|
+
if (t || n) {
|
|
1643
|
+
let t = e.filter((e) => e.type === "structure" || e.type === "addOption"), n = t[t.length - 1];
|
|
1644
|
+
return n?.type === "structure" ? [n] : t;
|
|
1645
|
+
}
|
|
1646
|
+
let r = e.filter((e) => e.type === "selection");
|
|
1647
|
+
return r.length > 0 ? [r[r.length - 1]] : e;
|
|
1648
|
+
}
|
|
1649
|
+
applyChange(e) {
|
|
1650
|
+
switch (e.type) {
|
|
1651
|
+
case "structure":
|
|
1652
|
+
this.applyStructure(e.data, e.source, e.preserveSelection, e.isSearchResult);
|
|
1653
|
+
break;
|
|
1654
|
+
case "selection":
|
|
1655
|
+
this.applySelection(e.values, e.source, e.runAfterChange !== !1);
|
|
1656
|
+
break;
|
|
1657
|
+
case "addOption":
|
|
1658
|
+
this.applyAddOption(e.option);
|
|
1659
|
+
break;
|
|
1660
|
+
}
|
|
1093
1661
|
}
|
|
1094
|
-
|
|
1662
|
+
applyStructure(e, t, n = !1, r = !1) {
|
|
1663
|
+
let { store: i, select: a, render: o, events: s } = this.deps;
|
|
1664
|
+
if (H(i, e)) return;
|
|
1665
|
+
let c = i.getSelected(), l = i.validateDataArray(e);
|
|
1666
|
+
if (l) {
|
|
1667
|
+
s.error ? s.error(l) : this.deps.onError && this.deps.onError(l);
|
|
1668
|
+
return;
|
|
1669
|
+
}
|
|
1670
|
+
i.setData(e, n);
|
|
1671
|
+
let u = i.getData(!1);
|
|
1672
|
+
r || i.snapshotCatalog(), a.updateOptions(u), o.renderValues(), o.renderOptions(u), s.afterChange && !w(c, i.getSelected()) && s.afterChange(i.getSelectedOptions());
|
|
1673
|
+
}
|
|
1674
|
+
applySelection(e, t, n) {
|
|
1675
|
+
let { store: r, select: i, render: a, events: o } = this.deps, s = r.getSelected(), c = U(r, e);
|
|
1676
|
+
if (w(s, c)) return;
|
|
1677
|
+
r.setSelectedBy("id", c), i.setSelectedByValue(r.getSelectedValues()), a.renderValues();
|
|
1678
|
+
let l = a.content.search.input.value.trim();
|
|
1679
|
+
l === "" ? a.canUpdateOptionSelectionInPlace() ? a.updateOptionSelection() : a.renderOptions(r.getData(!1)) : a.hasRenderedOptions() ? a.updateOptionSelection() : this.deps.search && this.deps.search(l), n && o.afterChange && !w(s, r.getSelected()) && o.afterChange(r.getSelectedOptions());
|
|
1680
|
+
}
|
|
1681
|
+
applyAddOption(e) {
|
|
1682
|
+
let { store: t, select: n, render: r, events: i } = this.deps, a = t.getSelected(), o = r.content.search.input.value.trim() !== "" && !!this.deps.search, s = e.value ?? e.text ?? "", c = (e) => {
|
|
1683
|
+
for (let t of e) {
|
|
1684
|
+
if (t instanceof L) {
|
|
1685
|
+
if (t.options.some((e) => (e.value ?? e.text) === s)) return !0;
|
|
1686
|
+
continue;
|
|
1687
|
+
}
|
|
1688
|
+
if ((t.value ?? t.text) === s) return !0;
|
|
1689
|
+
}
|
|
1690
|
+
return !1;
|
|
1691
|
+
};
|
|
1692
|
+
if (!c(t.getData(!1))) if (o) {
|
|
1693
|
+
let n = t.getCatalogData();
|
|
1694
|
+
c(n) || t.setData([...n, new I(e)], !0), t.snapshotCatalog();
|
|
1695
|
+
} else t.addOption(e), t.snapshotCatalog();
|
|
1696
|
+
let l = t.getData(!1);
|
|
1697
|
+
n.updateOptions(l), r.renderValues(), r.renderOptions(l), i.afterChange && !w(a, t.getSelected()) && i.afterChange(t.getSelectedOptions());
|
|
1698
|
+
}
|
|
1699
|
+
}, G = class {
|
|
1095
1700
|
selectEl;
|
|
1096
1701
|
settings;
|
|
1097
1702
|
cssClasses;
|
|
1098
1703
|
select;
|
|
1099
1704
|
store;
|
|
1100
1705
|
render;
|
|
1101
|
-
|
|
1102
|
-
|
|
1706
|
+
sync;
|
|
1707
|
+
lifecycle;
|
|
1708
|
+
globalEvents;
|
|
1709
|
+
searchGeneration = 0;
|
|
1103
1710
|
events = {
|
|
1104
1711
|
search: void 0,
|
|
1105
1712
|
searchFilter: (e, t) => e.text.toLowerCase().indexOf(t.toLowerCase()) !== -1,
|
|
@@ -1120,46 +1727,96 @@ var u = class {
|
|
|
1120
1727
|
e.events && e.events.error && e.events.error(/* @__PURE__ */ Error("Element isnt of type select"));
|
|
1121
1728
|
return;
|
|
1122
1729
|
}
|
|
1123
|
-
this.selectEl.dataset.ssid && this.destroy(), this.settings = new
|
|
1730
|
+
this.selectEl.dataset.ssid && this.destroy(), this.settings = new _(e.settings), this.cssClasses = new s(e.cssClasses);
|
|
1124
1731
|
let t = [
|
|
1125
1732
|
"beforeOpen",
|
|
1126
1733
|
"afterOpen",
|
|
1127
1734
|
"beforeClose",
|
|
1128
1735
|
"afterClose"
|
|
1129
1736
|
];
|
|
1130
|
-
for (let n in e.events) e.events.hasOwnProperty(n) && (t.indexOf(n) === -1 ? this.events[n] = e.events[n] : this.events[n] =
|
|
1131
|
-
this.settings.disabled = e.settings?.disabled ? e.settings.disabled : this.selectEl.disabled, this.settings.isMultiple = this.selectEl.multiple, this.settings.style = this.selectEl.style.cssText, this.settings.class = this.selectEl.className.split(" "), this.select = new
|
|
1132
|
-
this.setSelected(e.map((e) => e.id));
|
|
1133
|
-
}, this.select.onClassChange = (e) => {
|
|
1737
|
+
for (let n in e.events) e.events.hasOwnProperty(n) && (t.indexOf(n) === -1 ? this.events[n] = e.events[n] : this.events[n] = C(e.events[n], 100));
|
|
1738
|
+
this.settings.disabled = e.settings?.disabled ? e.settings.disabled : this.selectEl.disabled, this.settings.isMultiple = this.selectEl.multiple, this.settings.style = this.selectEl.style.cssText, this.settings.class = this.selectEl.className.split(" "), this.select = new V(this.selectEl), this.selectEl.id || (this.selectEl.id = this.settings.id), this.select.updateSelect(this.settings.id, this.settings.style, this.settings.class), this.select.hideUI(), this.select.onClassChange = (e) => {
|
|
1134
1739
|
this.settings.class = e, this.render.updateClassStyles();
|
|
1135
1740
|
}, this.select.onDisabledChange = (e) => {
|
|
1136
1741
|
e ? this.disable() : this.enable();
|
|
1137
|
-
}, this.select.onOptionsChange = (e) => {
|
|
1138
|
-
this.setData(e || []);
|
|
1139
1742
|
}, this.select.onLabelClick = () => {
|
|
1140
1743
|
this.settings.disabled || (this.settings.isOpen ? this.close() : this.open());
|
|
1141
1744
|
};
|
|
1142
1745
|
let n = e.data ? e.data : this.select.getData();
|
|
1143
|
-
this.store = new
|
|
1746
|
+
this.store = new R(this.settings.isMultiple ? "multiple" : "single", n), e.data && this.select.updateOptions(this.store.getData());
|
|
1144
1747
|
let r = {
|
|
1145
1748
|
open: this.open.bind(this),
|
|
1146
1749
|
close: this.close.bind(this),
|
|
1147
1750
|
addable: this.events.addable ? this.events.addable : void 0,
|
|
1148
|
-
setSelected:
|
|
1149
|
-
|
|
1751
|
+
setSelected: (e, t) => {
|
|
1752
|
+
this.sync.enqueue({
|
|
1753
|
+
type: "selection",
|
|
1754
|
+
values: e,
|
|
1755
|
+
source: "ui",
|
|
1756
|
+
runAfterChange: t
|
|
1757
|
+
});
|
|
1758
|
+
},
|
|
1759
|
+
addOption: (e) => {
|
|
1760
|
+
this.sync.enqueue({
|
|
1761
|
+
type: "addOption",
|
|
1762
|
+
option: e,
|
|
1763
|
+
source: "ui"
|
|
1764
|
+
});
|
|
1765
|
+
},
|
|
1150
1766
|
search: this.search.bind(this),
|
|
1151
1767
|
beforeChange: this.events.beforeChange,
|
|
1152
1768
|
afterChange: this.events.afterChange
|
|
1153
1769
|
};
|
|
1154
|
-
this.render = new
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1770
|
+
this.settings.modalTitle = e.settings?.modalTitle ?? b(this.selectEl), this.render = new z(this.settings, this.cssClasses, this.store, r), this.settings.timeoutDelay = f(this.render.content.main, e.settings?.timeoutDelay), this.sync = new W({
|
|
1771
|
+
select: this.select,
|
|
1772
|
+
store: this.store,
|
|
1773
|
+
render: this.render,
|
|
1774
|
+
events: this.events,
|
|
1775
|
+
search: this.search.bind(this)
|
|
1776
|
+
}), this.select.onValueChange = (e) => {
|
|
1777
|
+
this.sync.enqueue({
|
|
1778
|
+
type: "selection",
|
|
1779
|
+
values: e.map((e) => e.id),
|
|
1780
|
+
source: "native"
|
|
1781
|
+
});
|
|
1782
|
+
}, this.select.onOptionsChange = (e) => {
|
|
1783
|
+
this.sync.enqueue({
|
|
1784
|
+
type: "structure",
|
|
1785
|
+
data: e || [],
|
|
1786
|
+
source: "native"
|
|
1787
|
+
});
|
|
1788
|
+
}, this.lifecycle = new F({
|
|
1789
|
+
beforeOpen: this.events.beforeOpen,
|
|
1790
|
+
afterOpen: this.events.afterOpen,
|
|
1791
|
+
beforeClose: this.events.beforeClose,
|
|
1792
|
+
afterClose: () => {
|
|
1793
|
+
this.render.clearDirectionClasses(), this.render.finalizeModalClose(), this.events.afterClose && this.events.afterClose();
|
|
1794
|
+
},
|
|
1795
|
+
onOpenReady: () => this.globalEvents.attachDocumentClick(),
|
|
1796
|
+
onCloseReady: () => this.globalEvents.detachDocumentClick()
|
|
1797
|
+
}, {
|
|
1798
|
+
timeoutDelay: this.settings.timeoutDelay,
|
|
1799
|
+
waitForAnimation: (e, t) => this.render.waitForAnimation(e, t)
|
|
1800
|
+
}), this.globalEvents = new P({
|
|
1801
|
+
onDocumentClick: this.documentClick.bind(this),
|
|
1802
|
+
onWindowResize: () => {
|
|
1803
|
+
!this.settings.isOpen && !this.settings.isFullOpen || this.render.moveContent();
|
|
1804
|
+
},
|
|
1805
|
+
onWindowScroll: () => {
|
|
1806
|
+
!this.settings.isOpen && !this.settings.isFullOpen || this.render.moveContent();
|
|
1807
|
+
},
|
|
1808
|
+
onVisibilityChange: () => {
|
|
1809
|
+
document.hidden && this.close();
|
|
1810
|
+
}
|
|
1811
|
+
}), this.render.renderValues(), this.render.renderOptions(this.store.getData(!1));
|
|
1812
|
+
let i = this.selectEl.getAttribute("aria-label"), a = this.selectEl.getAttribute("aria-labelledby");
|
|
1813
|
+
if (i) this.render.main.main.setAttribute("aria-label", i);
|
|
1814
|
+
else if (a) this.render.main.main.removeAttribute("aria-label"), this.render.main.main.setAttribute("aria-labelledby", a);
|
|
1158
1815
|
else if (this.selectEl.labels && this.selectEl.labels.length > 0) {
|
|
1159
1816
|
let e = Array.from(this.selectEl.labels).map((e, t) => (e.id ||= `${this.settings.id}-label-${t}`, e.id));
|
|
1160
1817
|
this.render.main.main.removeAttribute("aria-label"), this.render.main.main.setAttribute("aria-labelledby", e.join(" "));
|
|
1161
1818
|
}
|
|
1162
|
-
this.selectEl.parentNode && this.selectEl.parentNode.insertBefore(this.render.main.main, this.selectEl.nextSibling),
|
|
1819
|
+
this.selectEl.parentNode && this.selectEl.parentNode.insertBefore(this.render.main.main, this.selectEl.nextSibling), this.globalEvents.attach({ listenScroll: this.settings.openPosition === "auto" }), this.settings.disabled && this.disable(), this.settings.alwaysOpen && this.open(), this.select.setupLabelHandlers(), this.selectEl.slim = this;
|
|
1163
1820
|
}
|
|
1164
1821
|
enable() {
|
|
1165
1822
|
this.settings.disabled = !1, this.select.enable(), this.render.enable();
|
|
@@ -1171,87 +1828,129 @@ var u = class {
|
|
|
1171
1828
|
return this.store.getData();
|
|
1172
1829
|
}
|
|
1173
1830
|
setData(e) {
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
}
|
|
1179
|
-
this.store.setData(e);
|
|
1180
|
-
let r = this.store.getData();
|
|
1181
|
-
this.select.updateOptions(r), this.render.renderValues(), this.render.renderOptions(r), this.events.afterChange && !c(t, this.store.getSelected()) && this.events.afterChange(this.store.getSelectedOptions());
|
|
1831
|
+
this.sync.enqueue({
|
|
1832
|
+
type: "structure",
|
|
1833
|
+
data: e,
|
|
1834
|
+
source: "api"
|
|
1835
|
+
});
|
|
1182
1836
|
}
|
|
1183
1837
|
getSelected() {
|
|
1184
1838
|
let e = this.store.getSelectedOptions();
|
|
1185
1839
|
return this.settings.keepOrder && (e = this.store.selectedOrderOptions(e)), e.map((e) => e.value);
|
|
1186
1840
|
}
|
|
1187
1841
|
setSelected(e, t = !0) {
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
continue;
|
|
1195
|
-
}
|
|
1196
|
-
for (let e of r.filter((e) => e.value == t)) i.push(e.id);
|
|
1197
|
-
}
|
|
1198
|
-
this.store.setSelectedBy("id", i);
|
|
1199
|
-
let a = this.store.getData();
|
|
1200
|
-
this.select.updateOptions(a), this.render.renderValues(), this.render.content.search.input.value === "" ? this.render.renderOptions(a) : this.search(this.render.content.search.input.value), t && this.events.afterChange && !c(n, this.store.getSelected()) && this.events.afterChange(this.store.getSelectedOptions());
|
|
1842
|
+
this.sync.enqueue({
|
|
1843
|
+
type: "selection",
|
|
1844
|
+
values: e,
|
|
1845
|
+
source: "api",
|
|
1846
|
+
runAfterChange: t
|
|
1847
|
+
});
|
|
1201
1848
|
}
|
|
1202
1849
|
addOption(e) {
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1850
|
+
this.sync.enqueue({
|
|
1851
|
+
type: "addOption",
|
|
1852
|
+
option: e,
|
|
1853
|
+
source: "api"
|
|
1854
|
+
});
|
|
1207
1855
|
}
|
|
1208
1856
|
open() {
|
|
1209
|
-
this.settings.disabled || this.settings.isOpen
|
|
1210
|
-
|
|
1211
|
-
|
|
1857
|
+
if (this.settings.disabled || this.settings.isOpen) return;
|
|
1858
|
+
this.lifecycle.cancelPending(), this.render.open(), this.settings.showSearch && this.settings.focusSearch && this.render.searchFocus(), this.settings.isOpen = !0, this.lifecycle.requestOpen().then(() => {
|
|
1859
|
+
this.settings.isOpen && (this.settings.isFullOpen = this.lifecycle.isFullOpen, this.settings.isOpen = this.lifecycle.isOpen);
|
|
1860
|
+
}), this.settings.contentPosition === "absolute" && !this.render.isModalViewActive() && this.render.startPositionTracking();
|
|
1861
|
+
let e = this.render.content.search.input.value.trim();
|
|
1862
|
+
e !== "" && this.search(e);
|
|
1212
1863
|
}
|
|
1213
1864
|
close(e = null) {
|
|
1214
|
-
!this.settings.isOpen || this.settings.alwaysOpen || (this.
|
|
1215
|
-
this.
|
|
1216
|
-
}
|
|
1865
|
+
!this.settings.isOpen || this.settings.alwaysOpen || (this.lifecycle.cancelPending(), this.render.close(), !this.settings.keepSearch && this.render.content.search.input.value !== "" && (this.sync.flush(), this.search("")), this.render.mainFocus(e), this.settings.isOpen = !1, this.settings.isFullOpen = !1, this.lifecycle.requestClose().then(() => {
|
|
1866
|
+
this.settings.isOpen || (this.settings.isOpen = this.lifecycle.isOpen, this.settings.isFullOpen = this.lifecycle.isFullOpen);
|
|
1867
|
+
}), this.render.stopPositionTracking());
|
|
1217
1868
|
}
|
|
1218
1869
|
search(e) {
|
|
1219
|
-
|
|
1220
|
-
|
|
1870
|
+
let t = e.trim();
|
|
1871
|
+
if (this.render.content.search.input.value !== t && (this.render.content.search.input.value = t), t === "") {
|
|
1872
|
+
this.clearSearch();
|
|
1221
1873
|
return;
|
|
1222
1874
|
}
|
|
1223
|
-
if (
|
|
1224
|
-
|
|
1225
|
-
this.render.renderOptions(t);
|
|
1875
|
+
if (this.events.search) {
|
|
1876
|
+
this.runApiSearch(t);
|
|
1226
1877
|
return;
|
|
1227
1878
|
}
|
|
1879
|
+
this.runLocalSearch(t);
|
|
1880
|
+
}
|
|
1881
|
+
clearSearch() {
|
|
1882
|
+
if (this.searchGeneration++, !this.events.search && this.render.canFilterOptionsInPlace()) {
|
|
1883
|
+
this.render.filterOptionsInPlace("", this.events.searchFilter), this.render.resetSearchFilterState();
|
|
1884
|
+
return;
|
|
1885
|
+
}
|
|
1886
|
+
this.render.resetSearchFilterState(), this.sync.enqueue({
|
|
1887
|
+
type: "structure",
|
|
1888
|
+
data: this.store.getCatalogData(),
|
|
1889
|
+
source: "api",
|
|
1890
|
+
preserveSelection: !0
|
|
1891
|
+
});
|
|
1892
|
+
}
|
|
1893
|
+
runLocalSearch(e) {
|
|
1894
|
+
if (this.render.canFilterOptionsInPlace()) {
|
|
1895
|
+
this.render.filterOptionsInPlace(e, this.events.searchFilter);
|
|
1896
|
+
return;
|
|
1897
|
+
}
|
|
1898
|
+
let t = this.store.search(e, this.events.searchFilter);
|
|
1899
|
+
this.render.renderOptions(t);
|
|
1900
|
+
}
|
|
1901
|
+
runApiSearch(e) {
|
|
1902
|
+
let t = ++this.searchGeneration;
|
|
1228
1903
|
this.render.renderSearching();
|
|
1229
|
-
let
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1904
|
+
let n = this.events.search(e, this.store.getSelectedOptions(), this.store.getCatalogData()), r = (n) => {
|
|
1905
|
+
t === this.searchGeneration && this.render.content.search.input.value.trim() === e && this.sync.enqueue({
|
|
1906
|
+
type: "structure",
|
|
1907
|
+
data: n,
|
|
1908
|
+
source: "api",
|
|
1909
|
+
preserveSelection: !0,
|
|
1910
|
+
isSearchResult: !0
|
|
1911
|
+
});
|
|
1912
|
+
};
|
|
1913
|
+
if (n instanceof Promise) {
|
|
1914
|
+
n.then(r).catch((e) => {
|
|
1915
|
+
t === this.searchGeneration && this.render.renderError(typeof e == "string" ? e : e.message);
|
|
1235
1916
|
});
|
|
1236
1917
|
return;
|
|
1237
|
-
}
|
|
1918
|
+
}
|
|
1919
|
+
if (Array.isArray(n)) {
|
|
1920
|
+
r(n);
|
|
1921
|
+
return;
|
|
1922
|
+
}
|
|
1923
|
+
this.render.renderError("Search event must return a promise or an array of data");
|
|
1238
1924
|
}
|
|
1239
1925
|
destroy() {
|
|
1240
|
-
this.
|
|
1926
|
+
this.lifecycle.destroy(), this.render.stopPositionTracking(), this.globalEvents.detach({ listenScroll: this.settings.openPosition === "auto" }), this.store.setData([]), this.render.destroy(), this.select.destroy();
|
|
1241
1927
|
}
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
}
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1928
|
+
documentClick(e) {
|
|
1929
|
+
this.settings.isOpen && e.target && !S(e.target, this.settings.id) && this.close(e.type);
|
|
1930
|
+
}
|
|
1931
|
+
};
|
|
1932
|
+
//#endregion
|
|
1933
|
+
//#region src/slim-select/vue/helpers.ts
|
|
1934
|
+
function K(e) {
|
|
1935
|
+
let t = /* @__PURE__ */ new WeakMap(), i = (e) => {
|
|
1936
|
+
if (r(e) && (e = o(e)), n(e) && (e = a(e)), typeof e != "object" || !e) return e;
|
|
1937
|
+
if (t.has(e)) return t.get(e);
|
|
1938
|
+
if (Array.isArray(e)) {
|
|
1939
|
+
let n = [];
|
|
1940
|
+
t.set(e, n);
|
|
1941
|
+
for (let t of e) n.push(i(t));
|
|
1942
|
+
return n;
|
|
1943
|
+
}
|
|
1944
|
+
let s = {};
|
|
1945
|
+
t.set(e, s);
|
|
1946
|
+
for (let t of Object.keys(e)) s[t] = i(e[t]);
|
|
1947
|
+
return s;
|
|
1253
1948
|
};
|
|
1254
|
-
|
|
1949
|
+
return i(e);
|
|
1950
|
+
}
|
|
1951
|
+
//#endregion
|
|
1952
|
+
//#region src/slim-select/vue/vue.vue?vue&type=script&lang.ts
|
|
1953
|
+
var q = t({
|
|
1255
1954
|
name: "SlimSelect",
|
|
1256
1955
|
props: {
|
|
1257
1956
|
modelValue: { type: [
|
|
@@ -1263,7 +1962,10 @@ var u = class {
|
|
|
1263
1962
|
type: Boolean,
|
|
1264
1963
|
default: !1
|
|
1265
1964
|
},
|
|
1266
|
-
data: {
|
|
1965
|
+
data: {
|
|
1966
|
+
type: Array,
|
|
1967
|
+
required: !0
|
|
1968
|
+
},
|
|
1267
1969
|
settings: { type: Object },
|
|
1268
1970
|
events: {
|
|
1269
1971
|
type: Object,
|
|
@@ -1272,25 +1974,24 @@ var u = class {
|
|
|
1272
1974
|
},
|
|
1273
1975
|
emits: ["update:modelValue"],
|
|
1274
1976
|
data() {
|
|
1275
|
-
return {
|
|
1977
|
+
return {
|
|
1978
|
+
slim: null,
|
|
1979
|
+
lastAppliedData: null
|
|
1980
|
+
};
|
|
1276
1981
|
},
|
|
1277
1982
|
mounted() {
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1983
|
+
let e = {
|
|
1984
|
+
select: this.$refs.slim,
|
|
1985
|
+
data: this.data
|
|
1986
|
+
};
|
|
1987
|
+
this.settings && (e.settings = this.settings);
|
|
1281
1988
|
let t = this.events?.afterChange;
|
|
1282
1989
|
e.events = {
|
|
1283
1990
|
...this.events,
|
|
1284
1991
|
afterChange: (e) => {
|
|
1285
1992
|
this.handleAfterChange(e, t);
|
|
1286
1993
|
}
|
|
1287
|
-
}, this.slim = new
|
|
1288
|
-
},
|
|
1289
|
-
updated() {
|
|
1290
|
-
if (this.slim && !this.data) {
|
|
1291
|
-
let e = this.slim.getSelected(), t = Array.isArray(this.value) ? this.value : [this.value];
|
|
1292
|
-
JSON.stringify(e.sort()) !== JSON.stringify(t.sort()) && this.syncModelValueToSlimSelect(!1);
|
|
1293
|
-
}
|
|
1994
|
+
}, this.slim = new G(e), this.lastAppliedData = structuredClone(K(this.data)), this.syncModelValueToSlimSelect(!1);
|
|
1294
1995
|
},
|
|
1295
1996
|
beforeUnmount() {
|
|
1296
1997
|
this.slim && this.slim.destroy();
|
|
@@ -1301,7 +2002,7 @@ var u = class {
|
|
|
1301
2002
|
} },
|
|
1302
2003
|
data: {
|
|
1303
2004
|
handler: function(e) {
|
|
1304
|
-
this.slim && this.slim.setData(e);
|
|
2005
|
+
this.slim && (this.lastAppliedData !== null && j(this.lastAppliedData, a(e)) || (this.slim.setData(e), this.lastAppliedData = structuredClone(K(e)), this.syncModelValueToSlimSelect(!1)));
|
|
1305
2006
|
},
|
|
1306
2007
|
deep: !0
|
|
1307
2008
|
}
|
|
@@ -1320,7 +2021,7 @@ var u = class {
|
|
|
1320
2021
|
},
|
|
1321
2022
|
handleAfterChange(e, t) {
|
|
1322
2023
|
if (!this.slim) return;
|
|
1323
|
-
let n = this.multiple ? e.map((e) => e.value) : e.length > 0 ? e[0].value : "", r = this.getCleanValue(this.$props.modelValue), i = this.slim.store.getDataOptions(), a = Array.isArray(r) ? r.length > 0 && r.every((e) => i.some((t) => t.value === e)) : r !== "" && i.some((e) => e.value === r), o = Array.isArray(n) ? n.length > 0 && n.every((e) => i.some((t) => t.value === e)) : n !== "" && i.some((e) => e.value === n);
|
|
2024
|
+
let n = this.multiple ? e.map((e) => e.value) : e.length > 0 ? e[0].value : "", r = this.getCleanValue(this.$props.modelValue), i = this.slim.store.getDataOptions(!1), a = Array.isArray(r) ? r.length > 0 && r.every((e) => i.some((t) => t.value === e)) : r !== "" && i.some((e) => e.value === r), o = Array.isArray(n) ? n.length > 0 && n.every((e) => i.some((t) => t.value === e)) : n !== "" && i.some((e) => e.value === n);
|
|
1324
2025
|
(Array.isArray(n) && Array.isArray(this.value) ? JSON.stringify(n.sort()) !== JSON.stringify(this.value.sort()) : this.value !== n) && (a || o) && (this.value = n), t && t(e);
|
|
1325
2026
|
},
|
|
1326
2027
|
getCleanValue(e) {
|
|
@@ -1341,19 +2042,19 @@ var u = class {
|
|
|
1341
2042
|
this.slim.setSelected(t, e);
|
|
1342
2043
|
}
|
|
1343
2044
|
}
|
|
1344
|
-
}),
|
|
2045
|
+
}), J = (e, t) => {
|
|
1345
2046
|
let n = e.__vccOpts || e;
|
|
1346
2047
|
for (let [e, r] of t) n[e] = r;
|
|
1347
2048
|
return n;
|
|
1348
|
-
},
|
|
1349
|
-
function
|
|
1350
|
-
return
|
|
2049
|
+
}, Y = ["multiple"];
|
|
2050
|
+
function X(t, n, r, a, o, s) {
|
|
2051
|
+
return i(), e("select", {
|
|
1351
2052
|
multiple: t.multiple,
|
|
1352
2053
|
ref: "slim"
|
|
1353
|
-
},
|
|
2054
|
+
}, null, 8, Y);
|
|
1354
2055
|
}
|
|
1355
2056
|
//#endregion
|
|
1356
2057
|
//#region src/slim-select/vue/index.ts
|
|
1357
|
-
var
|
|
2058
|
+
var Z = /* @__PURE__ */ J(q, [["render", X]]);
|
|
1358
2059
|
//#endregion
|
|
1359
|
-
export {
|
|
2060
|
+
export { L as Optgroup, I as Option, _ as Settings, Z as default };
|