treeselectjs 0.9.3 → 0.11.0

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.
@@ -1,1015 +1,1028 @@
1
- var oi = Object.defineProperty;
2
- var ri = (l, e, t) => e in l ? oi(l, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : l[e] = t;
3
- var c = (l, e, t) => (ri(l, typeof e != "symbol" ? e + "" : e, t), t), kt = (l, e, t) => {
4
- if (!e.has(l))
5
- throw TypeError("Cannot " + t);
6
- };
7
- var n = (l, e, t) => (kt(l, e, "read from private field"), t ? t.call(l) : e.get(l)), r = (l, e, t) => {
8
- if (e.has(l))
9
- throw TypeError("Cannot add the same private member more than once");
10
- e instanceof WeakSet ? e.add(l) : e.set(l, t);
11
- }, m = (l, e, t, s) => (kt(l, e, "write to private field"), s ? s.call(l, t) : e.set(l, t), t);
12
- var o = (l, e, t) => (kt(l, e, "access private method"), t);
13
- const Pt = {
14
- arrowUp: '<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 25 25" fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M18 15l-6-6-6 6"/></svg>',
15
- arrowDown: '<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 25 25" fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M6 9l6 6 6-6"/></svg>',
16
- arrowRight: '<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 25 25" fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M9 18l6-6-6-6"/></svg>',
17
- attention: '<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 25 25" fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"></path><line x1="12" y1="9" x2="12" y2="13"></line><line x1="12" y1="17" x2="12.01" y2="17"></line></svg>',
18
- clear: '<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 25 25" fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"></circle><line x1="15" y1="9" x2="9" y2="15"></line><line x1="9" y1="9" x2="15" y2="15"></line></svg>',
19
- cross: '<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 25 25" fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="18" y1="6" x2="6" y2="18"></line><line x1="6" y1="6" x2="18" y2="18"></line></svg>',
20
- check: '<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 25 25" fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="20 6 9 17 4 12"></polyline></svg>',
21
- partialCheck: '<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 25 25" fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="5" y1="12" x2="19" y2="12"></line></svg>'
22
- }, O = (l, e) => {
23
- if (e.innerHTML = "", typeof l == "string")
24
- e.innerHTML = l;
25
- else {
26
- const t = l.cloneNode(!0);
27
- e.appendChild(t);
28
- }
29
- }, Bt = (l) => {
30
- const e = l ? { ...l } : {};
31
- return Object.keys(Pt).forEach((t) => {
32
- e[t] || (e[t] = Pt[t]);
33
- }), e;
34
- }, ci = (l) => l.reduce((e, { name: t }, s) => (e += t, s < l.length - 1 && (e += ", "), e), "");
35
- var T, E, D, v, ue, Ht, H, R, pe, Gt, me, Mt, G, U, N, V, fe, Ft, Ce, qt, be, jt, ge, $t, ke, Wt, we, Rt, Ee, Ut, ve, zt, Le, Yt, ye, Kt, xe, Xt, Se, Jt, _e, Zt, Ae, Qt, Te, es, Ne, ts, z, wt;
36
- class hi {
37
- constructor({
38
- value: e,
39
- showTags: t,
40
- tagsCountText: s,
41
- clearable: i,
42
- isAlwaysOpened: a,
43
- searchable: h,
44
- placeholder: p,
45
- disabled: f,
46
- isSingleSelect: C,
47
- id: b,
48
- ariaLabel: g,
49
- iconElements: k,
50
- inputCallback: w,
51
- searchCallback: y,
52
- openCallback: I,
53
- closeCallback: W,
54
- keydownCallback: ae,
55
- focusCallback: bt,
56
- blurCallback: gt,
57
- nameChangeCallback: oe
58
- }) {
59
- // Private methods
60
- r(this, ue);
61
- r(this, H);
62
- r(this, pe);
63
- r(this, me);
64
- r(this, G);
65
- r(this, N);
66
- r(this, fe);
67
- r(this, Ce);
68
- r(this, be);
69
- r(this, ge);
70
- r(this, ke);
71
- r(this, we);
72
- r(this, Ee);
73
- r(this, ve);
74
- r(this, Le);
75
- r(this, ye);
76
- r(this, xe);
77
- r(this, Se);
78
- r(this, _e);
79
- r(this, Ae);
80
- r(this, Te);
81
- r(this, Ne);
82
- // Emits
83
- r(this, z);
84
- // Props
85
- c(this, "value");
86
- c(this, "showTags");
87
- c(this, "tagsCountText");
88
- c(this, "clearable");
89
- c(this, "isAlwaysOpened");
90
- c(this, "searchable");
91
- c(this, "placeholder");
92
- c(this, "disabled");
93
- c(this, "isSingleSelect");
94
- c(this, "id");
95
- c(this, "ariaLabel");
96
- c(this, "iconElements");
97
- // InnerState
98
- c(this, "isOpened");
99
- c(this, "searchText");
100
- c(this, "srcElement");
101
- // PrivateInnerState
102
- r(this, T, void 0);
103
- r(this, E, void 0);
104
- r(this, D, void 0);
105
- r(this, v, void 0);
106
- // Callbacks
107
- c(this, "inputCallback");
108
- c(this, "searchCallback");
109
- c(this, "openCallback");
110
- c(this, "closeCallback");
111
- c(this, "keydownCallback");
112
- c(this, "focusCallback");
113
- c(this, "blurCallback");
114
- c(this, "nameChangeCallback");
115
- this.value = e, this.showTags = t, this.tagsCountText = s, this.searchable = h, this.placeholder = p, this.clearable = i, this.isAlwaysOpened = a, this.disabled = f, this.isSingleSelect = C, this.id = b, this.ariaLabel = g, this.iconElements = k, this.isOpened = !1, this.searchText = "", m(this, T, o(this, be, jt).call(this)), m(this, E, o(this, Le, Yt).call(this)), m(this, D, o(this, Se, Jt).call(this)), m(this, v, null), this.inputCallback = w, this.searchCallback = y, this.openCallback = I, this.closeCallback = W, this.keydownCallback = ae, this.focusCallback = bt, this.blurCallback = gt, this.nameChangeCallback = oe, this.srcElement = o(this, fe, Ft).call(this, n(this, T), n(this, E), n(this, D)), o(this, ue, Ht).call(this);
116
- }
117
- // Public methods
118
- focus() {
119
- setTimeout(() => n(this, E).focus(), 0);
120
- }
121
- blur() {
122
- this.isOpened && o(this, N, V).call(this), this.clearSearch(), n(this, E).blur();
123
- }
124
- updateValue(e) {
125
- this.value = e, o(this, H, R).call(this), o(this, G, U).call(this);
126
- }
127
- removeItem(e) {
128
- this.value = this.value.filter((t) => t.id !== e), o(this, z, wt).call(this), o(this, H, R).call(this), o(this, G, U).call(this);
129
- }
130
- clear() {
131
- this.value = [], o(this, z, wt).call(this), o(this, H, R).call(this), this.clearSearch();
132
- }
133
- openClose() {
134
- o(this, N, V).call(this);
135
- }
136
- clearSearch() {
137
- this.searchText = "", this.searchCallback(""), o(this, G, U).call(this);
138
- }
139
- }
140
- T = new WeakMap(), E = new WeakMap(), D = new WeakMap(), v = new WeakMap(), ue = new WeakSet(), Ht = function() {
141
- o(this, H, R).call(this), o(this, G, U).call(this), o(this, pe, Gt).call(this);
142
- }, H = new WeakSet(), R = function() {
143
- if (n(this, T).innerHTML = "", this.showTags) {
144
- n(this, T).append(...o(this, ge, $t).call(this));
145
- const e = ci(this.value);
146
- this.nameChangeCallback(e);
147
- } else {
148
- const e = o(this, ve, zt).call(this);
149
- n(this, T).appendChild(e), this.nameChangeCallback(e.innerText);
150
- }
151
- n(this, T).appendChild(n(this, E));
152
- }, pe = new WeakSet(), Gt = function() {
153
- const e = [];
154
- n(this, D).innerHTML = "", this.clearable && e.push(o(this, _e, Zt).call(this)), this.isAlwaysOpened || e.push(o(this, Te, es).call(this, this.isOpened)), e.length && n(this, D).append(...e);
155
- }, me = new WeakSet(), Mt = function() {
156
- if (!this.isAlwaysOpened && n(this, v)) {
157
- const e = this.isOpened ? this.iconElements.arrowUp : this.iconElements.arrowDown;
158
- O(e, n(this, v));
159
- }
160
- }, G = new WeakSet(), U = function() {
161
- var e;
162
- (e = this.value) != null && e.length ? (n(this, E).removeAttribute("placeholder"), this.srcElement.classList.remove("treeselect-input--value-not-selected")) : (n(this, E).setAttribute("placeholder", this.placeholder), this.srcElement.classList.add("treeselect-input--value-not-selected")), this.searchable ? this.srcElement.classList.remove("treeselect-input--unsearchable") : this.srcElement.classList.add("treeselect-input--unsearchable"), this.isSingleSelect ? this.srcElement.classList.add("treeselect-input--is-single-select") : this.srcElement.classList.remove("treeselect-input--is-single-select"), n(this, E).value = this.searchText;
163
- }, N = new WeakSet(), V = function() {
164
- this.isOpened = !this.isOpened, o(this, me, Mt).call(this), this.isOpened ? this.openCallback() : this.closeCallback();
165
- }, fe = new WeakSet(), Ft = function(e, t, s) {
166
- const i = document.createElement("div");
167
- return i.classList.add("treeselect-input"), i.setAttribute("tabindex", "-1"), i.addEventListener("mousedown", (a) => o(this, Ce, qt).call(this, a)), i.addEventListener("focus", () => this.focusCallback(), !0), i.addEventListener("blur", () => this.blurCallback(), !0), e.appendChild(t), i.append(e, s), i;
168
- }, Ce = new WeakSet(), qt = function(e) {
169
- e.stopPropagation(), this.isOpened || o(this, N, V).call(this), this.focus();
170
- }, be = new WeakSet(), jt = function() {
171
- const e = document.createElement("div");
172
- return e.classList.add("treeselect-input__tags"), e;
173
- }, ge = new WeakSet(), $t = function() {
174
- return this.value.map((e) => {
175
- const t = document.createElement("div");
176
- t.classList.add("treeselect-input__tags-element"), t.setAttribute("tabindex", "-1"), t.setAttribute("tag-id", e.id.toString()), t.setAttribute("title", e.name);
177
- const s = o(this, we, Rt).call(this, e.name), i = o(this, Ee, Ut).call(this);
178
- return t.addEventListener("mousedown", (a) => o(this, ke, Wt).call(this, a, e.id)), t.append(s, i), t;
179
- });
180
- }, ke = new WeakSet(), Wt = function(e, t) {
181
- e.preventDefault(), e.stopPropagation(), this.removeItem(t), this.focus();
182
- }, we = new WeakSet(), Rt = function(e) {
183
- const t = document.createElement("span");
184
- return t.classList.add("treeselect-input__tags-name"), t.textContent = e, t;
185
- }, Ee = new WeakSet(), Ut = function() {
186
- const e = document.createElement("span");
187
- return e.classList.add("treeselect-input__tags-cross"), O(this.iconElements.cross, e), e;
188
- }, ve = new WeakSet(), zt = function() {
189
- const e = document.createElement("span");
190
- if (e.classList.add("treeselect-input__tags-count"), !this.value.length)
191
- return e.textContent = "", e.setAttribute("title", ""), e;
192
- const t = this.value.length === 1 ? this.value[0].name : `${this.value.length} ${this.tagsCountText}`;
193
- return e.textContent = t, e.setAttribute("title", t), e;
194
- }, Le = new WeakSet(), Yt = function() {
195
- const e = document.createElement("input");
196
- return e.classList.add("treeselect-input__edit"), this.id && e.setAttribute("id", this.id), (!this.searchable || this.disabled) && e.setAttribute("readonly", "readonly"), this.disabled && e.setAttribute("tabindex", "-1"), this.ariaLabel.length && e.setAttribute("aria-label", this.ariaLabel), e.addEventListener("keydown", (t) => o(this, ye, Kt).call(this, t)), e.addEventListener("input", (t) => o(this, xe, Xt).call(this, t, e)), e;
197
- }, ye = new WeakSet(), Kt = function(e) {
198
- e.stopPropagation();
199
- const t = e.key;
200
- t === "Backspace" && !this.searchText.length && this.value.length && !this.showTags && this.clear(), t === "Backspace" && !this.searchText.length && this.value.length && this.removeItem(this.value[this.value.length - 1].id), e.code === "Space" && (!this.searchText || !this.searchable) && o(this, N, V).call(this), (t === "Enter" || t === "ArrowDown" || t === "ArrowUp") && e.preventDefault(), this.keydownCallback(e), t !== "Tab" && this.focus();
201
- }, xe = new WeakSet(), Xt = function(e, t) {
202
- e.stopPropagation();
203
- const s = this.searchText, i = t.value.trim();
204
- if (s.length === 0 && i.length === 0) {
205
- t.value = "";
206
- return;
207
- }
208
- if (this.searchable) {
209
- const a = e.target.value;
210
- this.searchCallback(a), this.isOpened || o(this, N, V).call(this);
211
- } else
212
- t.value = "";
213
- this.searchText = t.value;
214
- }, Se = new WeakSet(), Jt = function() {
215
- const e = document.createElement("div");
216
- return e.classList.add("treeselect-input__operators"), e;
217
- }, _e = new WeakSet(), Zt = function() {
218
- const e = document.createElement("span");
219
- return e.classList.add("treeselect-input__clear"), e.setAttribute("tabindex", "-1"), O(this.iconElements.clear, e), e.addEventListener("mousedown", (t) => o(this, Ae, Qt).call(this, t)), e;
220
- }, Ae = new WeakSet(), Qt = function(e) {
221
- e.preventDefault(), e.stopPropagation(), (this.searchText.length || this.value.length) && this.clear(), this.focus();
222
- }, Te = new WeakSet(), es = function(e) {
223
- m(this, v, document.createElement("span")), n(this, v).classList.add("treeselect-input__arrow");
224
- const t = e ? this.iconElements.arrowUp : this.iconElements.arrowDown;
225
- return O(t, n(this, v)), n(this, v).addEventListener("mousedown", (s) => o(this, Ne, ts).call(this, s)), n(this, v);
226
- }, Ne = new WeakSet(), ts = function(e) {
227
- e.stopPropagation(), e.preventDefault(), this.focus(), o(this, N, V).call(this);
228
- }, z = new WeakSet(), wt = function() {
229
- this.inputCallback(this.value);
230
- };
231
- const ss = (l, e, t, s) => {
232
- mi(e);
233
- const i = e.filter((a) => !a.disabled && l.some((h) => h === a.id));
234
- if (t && i.length) {
235
- i[0].checked = !0;
236
- return;
237
- }
238
- i.forEach((a) => {
239
- a.checked = !0;
240
- const h = It(a, e, s);
241
- a.checked = h;
242
- });
243
- }, It = ({ id: l, checked: e }, t, s) => {
244
- const i = t.find((h) => h.id === l);
245
- if (!i)
246
- return !1;
247
- if (s)
248
- return i.checked = i.disabled ? !1 : !!e, i.checked;
249
- const a = is(!!e, i, t);
250
- return ls(i, t), a;
251
- }, is = (l, e, t) => {
252
- if (!e.isGroup)
253
- return e.checked = e.disabled ? !1 : !!l, e.isPartialChecked = !1, e.checked;
254
- const s = t.filter((p) => p.childOf === e.id);
255
- return !l || e.disabled || e.isPartialChecked ? (e.checked = !1, e.isPartialChecked = !1, Et(e, s, t), e.checked) : ns(s, t) ? as(s) ? (e.checked = !1, e.isPartialChecked = !1, e.disabled = !0, e.checked) : (e.checked = !1, e.isPartialChecked = !0, s.forEach((p) => {
256
- is(l, p, t);
257
- }), e.checked) : (e.checked = !0, e.isPartialChecked = !1, Et(e, s, t), e.checked);
258
- }, ls = (l, e) => {
259
- const t = e.find((s) => s.id === l.childOf);
260
- t && (di(t, e), ls(t, e));
261
- }, di = (l, e) => {
262
- const t = ft(l, e);
263
- if (as(t)) {
264
- l.checked = !1, l.isPartialChecked = !1, l.disabled = !0;
265
- return;
266
- }
267
- if (ui(t)) {
268
- l.checked = !0, l.isPartialChecked = !1;
269
- return;
270
- }
271
- if (pi(t)) {
272
- l.checked = !1, l.isPartialChecked = !0;
273
- return;
274
- }
275
- l.checked = !1, l.isPartialChecked = !1;
276
- }, Et = ({ checked: l, disabled: e }, t, s) => {
277
- t.forEach((i) => {
278
- i.disabled = !!e || !!i.disabled, i.checked = !!l && !i.disabled, i.isPartialChecked = !1;
279
- const a = ft(i, s);
280
- Et({ checked: l, disabled: e }, a, s);
281
- });
282
- }, ns = (l, e) => l.some((i) => i.disabled) ? !0 : l.some((i) => {
283
- if (i.isGroup) {
284
- const a = ft(i, e);
285
- return ns(a, e);
286
- }
287
- return !1;
288
- }), as = (l) => l.every((e) => !!e.disabled), ui = (l) => l.every((e) => !!e.checked), pi = (l) => l.some((e) => !!e.checked || !!e.isPartialChecked), mi = (l) => {
289
- l.forEach((e) => {
290
- e.checked = !1, e.isPartialChecked = !1;
291
- });
292
- }, fi = (l, e, t) => {
293
- const s = { level: 0, groupId: "" }, i = os(l, e, s.groupId, s.level);
294
- return bi(i, t);
295
- }, os = (l, e, t, s) => l.reduce((i, a) => {
296
- var C;
297
- const h = !!((C = a.children) != null && C.length), p = s >= e && h, f = s > e;
298
- if (i.push({
299
- id: a.value,
300
- name: a.name,
301
- childOf: t,
302
- isGroup: h,
303
- checked: !1,
304
- isPartialChecked: !1,
305
- level: s,
306
- isClosed: p,
307
- hidden: f,
308
- disabled: a.disabled ?? !1
309
- }), h) {
310
- const b = os(a.children, e, a.value, s + 1);
311
- i.push(...b);
312
- }
313
- return i;
314
- }, []), ft = ({ id: l }, e) => e.filter((t) => t.childOf === l), Ci = (l) => {
315
- const { ungroupedNodes: e, allGroupedNodes: t, allNodes: s } = l.reduce(
316
- (a, h) => (h.checked && (a.allNodes.push(h), h.isGroup ? a.allGroupedNodes.push(h) : a.ungroupedNodes.push(h)), a),
317
- {
318
- ungroupedNodes: [],
319
- allGroupedNodes: [],
320
- allNodes: []
321
- }
322
- ), i = s.filter((a) => !t.some(({ id: h }) => h === a.childOf));
323
- return { ungroupedNodes: e, groupedNodes: i, allNodes: s };
324
- }, bi = (l, e) => (l.filter((s) => !!s.disabled).forEach(
325
- ({ id: s }) => It({ id: s, checked: !1 }, l, e)
326
- ), l), Ct = (l, { id: e, isClosed: t }) => {
327
- ft({ id: e }, l).forEach((i) => {
328
- i.hidden = t ?? !1, i.isGroup && !i.isClosed && Ct(l, { id: i.id, isClosed: t });
329
- });
330
- }, gi = (l) => {
331
- l.filter((e) => e.isGroup && !e.disabled && (e.checked || e.isPartialChecked)).forEach((e) => {
332
- e.isClosed = !1, Ct(l, e);
333
- });
334
- }, ki = (l, e) => {
335
- const t = wi(l, e);
336
- l.forEach((s) => {
337
- t.some(({ id: a }) => a === s.id) ? (s.isGroup && (s.isClosed = !1, Ct(l, s)), s.hidden = !1) : s.hidden = !0;
338
- });
339
- }, wi = (l, e) => l.reduce((t, s) => {
340
- if (s.name.toLowerCase().includes(e.toLowerCase())) {
341
- if (t.push(s), s.isGroup) {
342
- const a = rs(s.id, l);
343
- t.push(...a);
344
- }
345
- if (s.childOf) {
346
- const a = cs(s.childOf, l);
347
- t.push(...a);
348
- }
349
- }
350
- return t;
351
- }, []), rs = (l, e) => e.reduce((t, s) => (s.childOf === l && (t.push(s), s.isGroup && t.push(...rs(s.id, e))), t), []), cs = (l, e) => e.reduce((t, s) => (s.id === l && (t.push(s), s.childOf && t.push(...cs(s.childOf, e))), t), []), Ei = (l) => {
352
- const { duplications: e } = l.reduce(
353
- (t, s) => (t.allItems.some((i) => i.toString() === s.id.toString()) && t.duplications.push(s.id), t.allItems.push(s.id), t),
354
- {
355
- duplications: [],
356
- allItems: []
357
- }
358
- );
359
- e.length && console.error(`Validation: You have duplicated values: ${e.join(", ")}! You should use unique values.`);
360
- }, vi = (l, e, t, s, i, a, h, p, f) => {
361
- ss(l, e, i, f), p && h && gi(e), ce(e, t, s, a);
362
- }, ce = (l, e, t, s) => {
363
- l.forEach((i) => {
364
- const a = e.querySelector(`[input-id="${i.id}"]`), h = A(a);
365
- a.checked = i.checked, Li(i, h, s), yi(i, h), xi(i, h), Si(i, h, t), _i(i, h), Ti(i, h, l), Ai(i, a, t);
366
- }), Ni(l, e);
367
- }, Li = (l, e, t) => {
368
- l.checked ? e.classList.add("treeselect-list__item--checked") : e.classList.remove("treeselect-list__item--checked"), Array.isArray(t) && t[0] === l.id && !l.disabled ? e.classList.add("treeselect-list__item--single-selected") : e.classList.remove("treeselect-list__item--single-selected");
369
- }, yi = (l, e) => {
370
- l.isPartialChecked ? e.classList.add("treeselect-list__item--partial-checked") : e.classList.remove("treeselect-list__item--partial-checked");
371
- }, xi = (l, e) => {
372
- l.disabled ? e.classList.add("treeselect-list__item--disabled") : e.classList.remove("treeselect-list__item--disabled");
373
- }, Si = (l, e, t) => {
374
- if (l.isGroup) {
375
- const s = e.querySelector(".treeselect-list__item-icon"), i = l.isClosed ? t.arrowRight : t.arrowDown;
376
- O(i, s), l.isClosed ? e.classList.add("treeselect-list__item--closed") : e.classList.remove("treeselect-list__item--closed");
377
- }
378
- }, _i = (l, e) => {
379
- l.hidden ? e.classList.add("treeselect-list__item--hidden") : e.classList.remove("treeselect-list__item--hidden");
380
- }, Ai = (l, e, t) => {
381
- const i = e.parentNode.querySelector(".treeselect-list__item-checkbox-icon");
382
- l.checked ? O(t.check, i) : l.isPartialChecked ? O(t.partialCheck, i) : i.innerHTML = "";
383
- }, Ti = (l, e, t) => {
384
- const s = l.level === 0, i = 20, a = 5;
385
- if (s) {
386
- const h = t.some((f) => f.isGroup && f.level === l.level), p = !l.isGroup && h ? `${i}px` : `${a}px`;
387
- e.style.paddingLeft = l.isGroup ? "0" : p;
388
- } else
389
- e.style.paddingLeft = l.isGroup ? `${l.level * i}px` : `${l.level * i + i}px`;
390
- e.setAttribute("level", l.level.toString()), e.setAttribute("group", l.isGroup.toString());
391
- }, Ni = (l, e) => {
392
- const t = l.some((i) => !i.hidden), s = e.querySelector(".treeselect-list__empty");
393
- t ? s.classList.add("treeselect-list__empty--hidden") : s.classList.remove("treeselect-list__empty--hidden");
394
- }, A = (l) => l.parentNode.parentNode, Vt = (l, e) => e.find((t) => t.id.toString() === l), Oi = (l) => A(l).querySelector(".treeselect-list__item-icon"), Ii = (l, e) => {
395
- e && Object.keys(e).forEach((t) => {
396
- const s = e[t];
397
- typeof s == "string" && l.setAttribute(t, s);
398
- });
399
- };
400
- var M, P, x, Y, Oe, hs, Ie, ds, Pe, us, Be, ps, Ve, ms, De, fs, K, vt, He, Cs, Ge, bs, Me, gs, X, Lt, Fe, ks, qe, ws, je, Es, $e, vs, We, Ls, Re, ys, Ue, xs, ze, Ss, Ye, _s, Ke, As, Xe, Ts, J, yt, Z, xt, Je, Ns;
401
- class Pi {
402
- constructor({
403
- options: e,
404
- value: t,
405
- openLevel: s,
406
- listSlotHtmlComponent: i,
407
- emptyText: a,
408
- isSingleSelect: h,
409
- iconElements: p,
410
- showCount: f,
411
- disabledBranchNode: C,
412
- expandSelected: b,
413
- isIndependentNodes: g,
414
- inputCallback: k,
415
- arrowClickCallback: w,
416
- mouseupCallback: y
417
- }) {
418
- // Private methods
419
- r(this, Oe);
420
- r(this, Ie);
421
- r(this, Pe);
422
- r(this, Be);
423
- r(this, Ve);
424
- r(this, De);
425
- r(this, K);
426
- r(this, He);
427
- r(this, Ge);
428
- r(this, Me);
429
- r(this, X);
430
- r(this, Fe);
431
- r(this, qe);
432
- r(this, je);
433
- r(this, $e);
434
- r(this, We);
435
- r(this, Re);
436
- r(this, Ue);
437
- r(this, ze);
438
- r(this, Ye);
439
- // Actions
440
- r(this, Ke);
441
- r(this, Xe);
442
- r(this, J);
443
- r(this, Z);
444
- // Emits
445
- r(this, Je);
446
- // Props
447
- c(this, "options");
448
- c(this, "value");
449
- c(this, "openLevel");
450
- c(this, "listSlotHtmlComponent");
451
- c(this, "emptyText");
452
- c(this, "isSingleSelect");
453
- c(this, "showCount");
454
- c(this, "disabledBranchNode");
455
- c(this, "expandSelected");
456
- c(this, "isIndependentNodes");
457
- c(this, "iconElements");
458
- // InnerState
459
- c(this, "searchText");
460
- c(this, "flattedOptions");
461
- c(this, "flattedOptionsBeforeSearch");
462
- c(this, "selectedNodes");
463
- c(this, "srcElement");
464
- // Callbacks
465
- c(this, "inputCallback");
466
- c(this, "arrowClickCallback");
467
- c(this, "mouseupCallback");
468
- // PrivateInnerState
469
- r(this, M, null);
470
- r(this, P, !0);
471
- r(this, x, []);
472
- r(this, Y, !0);
473
- this.options = e, this.value = t, this.openLevel = s ?? 0, this.listSlotHtmlComponent = i ?? null, this.emptyText = a ?? "No results found...", this.isSingleSelect = h ?? !1, this.showCount = f ?? !1, this.disabledBranchNode = C ?? !1, this.expandSelected = b ?? !1, this.isIndependentNodes = g ?? !1, this.iconElements = p, this.searchText = "", this.flattedOptions = fi(this.options, this.openLevel, this.isIndependentNodes), this.flattedOptionsBeforeSearch = this.flattedOptions, this.selectedNodes = { nodes: [], groupedNodes: [], allNodes: [] }, this.srcElement = o(this, Pe, us).call(this), this.inputCallback = k, this.arrowClickCallback = w, this.mouseupCallback = y, Ei(this.flattedOptions);
474
- }
475
- // Public methods
476
- updateValue(e) {
477
- this.value = e, m(this, x, this.isSingleSelect ? this.value : []), vi(
478
- e,
479
- this.flattedOptions,
480
- this.srcElement,
481
- this.iconElements,
482
- this.isSingleSelect,
483
- n(this, x),
484
- this.expandSelected,
485
- n(this, Y),
486
- this.isIndependentNodes
487
- ), m(this, Y, !1), o(this, Z, xt).call(this);
488
- }
489
- updateSearchValue(e) {
490
- if (e === this.searchText)
491
- return;
492
- const t = this.searchText === "" && e !== "";
493
- this.searchText = e, t && (this.flattedOptionsBeforeSearch = JSON.parse(JSON.stringify(this.flattedOptions))), this.searchText === "" && (this.flattedOptions = this.flattedOptionsBeforeSearch.map((s) => {
494
- const i = this.flattedOptions.find((a) => a.id === s.id);
495
- return i.isClosed = s.isClosed, i.hidden = s.hidden, i;
496
- }), this.flattedOptionsBeforeSearch = []), this.searchText && ki(this.flattedOptions, e), ce(this.flattedOptions, this.srcElement, this.iconElements, n(this, x)), this.focusFirstListElement();
497
- }
498
- callKeyAction(e) {
499
- m(this, P, !1);
500
- const t = this.srcElement.querySelector(".treeselect-list__item--focused");
501
- if (t == null ? void 0 : t.classList.contains("treeselect-list__item--hidden"))
502
- return;
503
- const i = e.key;
504
- i === "Enter" && t && t.dispatchEvent(new Event("mousedown")), (i === "ArrowLeft" || i === "ArrowRight") && o(this, Oe, hs).call(this, t, e), (i === "ArrowDown" || i === "ArrowUp") && o(this, Ie, ds).call(this, t, i);
505
- }
506
- focusFirstListElement() {
507
- const e = "treeselect-list__item--focused", t = this.srcElement.querySelector(`.${e}`), s = Array.from(this.srcElement.querySelectorAll(".treeselect-list__item-checkbox")).filter(
508
- (a) => window.getComputedStyle(A(a)).display !== "none"
509
- );
510
- if (!s.length)
511
- return;
512
- t && t.classList.remove(e), A(s[0]).classList.add(e);
513
- }
514
- isLastFocusedElementExist() {
515
- return !!n(this, M);
516
- }
517
- }
518
- M = new WeakMap(), P = new WeakMap(), x = new WeakMap(), Y = new WeakMap(), Oe = new WeakSet(), hs = function(e, t) {
519
- if (!e)
520
- return;
521
- const s = t.key, a = e.querySelector(".treeselect-list__item-checkbox").getAttribute("input-id"), h = Vt(a, this.flattedOptions), p = e.querySelector(".treeselect-list__item-icon");
522
- s === "ArrowLeft" && !h.isClosed && h.isGroup && (p.dispatchEvent(new Event("mousedown")), t.preventDefault()), s === "ArrowRight" && h.isClosed && h.isGroup && (p.dispatchEvent(new Event("mousedown")), t.preventDefault());
523
- }, Ie = new WeakSet(), ds = function(e, t) {
524
- var i;
525
- const s = Array.from(this.srcElement.querySelectorAll(".treeselect-list__item-checkbox")).filter(
526
- (a) => window.getComputedStyle(A(a)).display !== "none"
527
- );
528
- if (s.length)
529
- if (!e)
530
- A(s[0]).classList.add("treeselect-list__item--focused");
531
- else {
532
- const a = s.findIndex(
533
- (I) => A(I).classList.contains("treeselect-list__item--focused")
534
- );
535
- A(s[a]).classList.remove("treeselect-list__item--focused");
536
- const p = t === "ArrowDown" ? a + 1 : a - 1, f = t === "ArrowDown" ? 0 : s.length - 1, C = s[p] ?? s[f], b = !s[p], g = A(C);
537
- g.classList.add("treeselect-list__item--focused");
538
- const k = this.srcElement.getBoundingClientRect(), w = g.getBoundingClientRect();
539
- if (b && t === "ArrowDown") {
540
- this.srcElement.scroll(0, 0);
541
- return;
542
- }
543
- if (b && t === "ArrowUp") {
544
- this.srcElement.scroll(0, this.srcElement.scrollHeight);
545
- return;
546
- }
547
- const y = ((i = this.listSlotHtmlComponent) == null ? void 0 : i.clientHeight) ?? 0;
548
- if (k.y + k.height < w.y + w.height + y) {
549
- this.srcElement.scroll(0, this.srcElement.scrollTop + w.height);
550
- return;
551
- }
552
- if (k.y > w.y) {
553
- this.srcElement.scroll(0, this.srcElement.scrollTop - w.height);
554
- return;
555
- }
556
- }
557
- }, Pe = new WeakSet(), us = function() {
558
- const e = o(this, Be, ps).call(this), t = o(this, K, vt).call(this, this.options);
559
- e.append(...t);
560
- const s = o(this, Ge, bs).call(this);
561
- e.append(s);
562
- const i = o(this, He, Cs).call(this);
563
- return i && e.append(i), e;
564
- }, Be = new WeakSet(), ps = function() {
565
- const e = document.createElement("div");
566
- return e.classList.add("treeselect-list"), this.isSingleSelect && e.classList.add("treeselect-list--single-select"), this.disabledBranchNode && e.classList.add("treeselect-list--disabled-branch-node"), e.addEventListener("mouseout", (t) => o(this, Ve, ms).call(this, t)), e.addEventListener("mousemove", () => o(this, De, fs).call(this)), e.addEventListener("mouseup", () => this.mouseupCallback(), !0), e;
567
- }, Ve = new WeakSet(), ms = function(e) {
568
- e.stopPropagation(), n(this, M) && n(this, P) && n(this, M).classList.add("treeselect-list__item--focused");
569
- }, De = new WeakSet(), fs = function() {
570
- m(this, P, !0);
571
- }, K = new WeakSet(), vt = function(e) {
572
- return e.reduce((t, s) => {
573
- var a;
574
- if ((a = s.children) != null && a.length) {
575
- const h = o(this, Me, gs).call(this, s), p = o(this, K, vt).call(this, s.children);
576
- return h.append(...p), t.push(h), t;
577
- }
578
- const i = o(this, X, Lt).call(this, s, !1);
579
- return t.push(i), t;
580
- }, []);
581
- }, He = new WeakSet(), Cs = function() {
582
- if (!this.listSlotHtmlComponent)
583
- return null;
584
- const e = document.createElement("div");
585
- return e.classList.add("treeselect-list__slot"), e.appendChild(this.listSlotHtmlComponent), e;
586
- }, Ge = new WeakSet(), bs = function() {
587
- const e = document.createElement("div");
588
- e.classList.add("treeselect-list__empty"), e.setAttribute("title", this.emptyText);
589
- const t = document.createElement("span");
590
- t.classList.add("treeselect-list__empty-icon"), O(this.iconElements.attention, t);
591
- const s = document.createElement("span");
592
- return s.classList.add("treeselect-list__empty-text"), s.textContent = this.emptyText, e.append(t, s), e;
593
- }, Me = new WeakSet(), gs = function(e) {
594
- const t = document.createElement("div");
595
- t.setAttribute("group-container-id", e.value.toString()), t.classList.add("treeselect-list__group-container");
596
- const s = o(this, X, Lt).call(this, e, !0);
597
- return t.appendChild(s), t;
598
- }, X = new WeakSet(), Lt = function(e, t) {
599
- const s = o(this, Fe, ks).call(this, e);
600
- if (t) {
601
- const h = o(this, We, Ls).call(this);
602
- s.appendChild(h), s.classList.add("treeselect-list__item--group");
603
- }
604
- const i = o(this, Ue, xs).call(this, e), a = o(this, ze, Ss).call(this, e, t);
605
- return s.append(i, a), s;
606
- }, Fe = new WeakSet(), ks = function(e) {
607
- const t = document.createElement("div");
608
- return Ii(t, e.htmlAttr), t.setAttribute("tabindex", "-1"), t.setAttribute("title", e.name), t.classList.add("treeselect-list__item"), t.addEventListener("mouseover", () => o(this, qe, ws).call(this, t), !0), t.addEventListener("mouseout", () => o(this, je, Es).call(this, t), !0), t.addEventListener("mousedown", (s) => o(this, $e, vs).call(this, s, e)), t;
609
- }, qe = new WeakSet(), ws = function(e) {
610
- n(this, P) && o(this, J, yt).call(this, !0, e);
611
- }, je = new WeakSet(), Es = function(e) {
612
- n(this, P) && (o(this, J, yt).call(this, !1, e), m(this, M, e));
613
- }, $e = new WeakSet(), vs = function(e, t) {
614
- var a;
615
- if (e.preventDefault(), e.stopPropagation(), (a = this.flattedOptions.find((h) => h.id === t.value)) == null ? void 0 : a.disabled)
616
- return;
617
- const i = e.target.querySelector(".treeselect-list__item-checkbox");
618
- i.checked = !i.checked, o(this, Ke, As).call(this, i, t);
619
- }, We = new WeakSet(), Ls = function() {
620
- const e = document.createElement("span");
621
- return e.setAttribute("tabindex", "-1"), e.classList.add("treeselect-list__item-icon"), O(this.iconElements.arrowDown, e), e.addEventListener("mousedown", (t) => o(this, Re, ys).call(this, t)), e;
622
- }, Re = new WeakSet(), ys = function(e) {
623
- e.preventDefault(), e.stopPropagation(), o(this, Xe, Ts).call(this, e);
624
- }, Ue = new WeakSet(), xs = function(e) {
625
- const t = document.createElement("div");
626
- t.classList.add("treeselect-list__item-checkbox-container");
627
- const s = document.createElement("span");
628
- s.classList.add("treeselect-list__item-checkbox-icon"), s.innerHTML = "";
629
- const i = document.createElement("input");
630
- return i.setAttribute("tabindex", "-1"), i.setAttribute("type", "checkbox"), i.setAttribute("input-id", e.value.toString()), i.classList.add("treeselect-list__item-checkbox"), t.append(s, i), t;
631
- }, ze = new WeakSet(), Ss = function(e, t) {
632
- const s = document.createElement("label");
633
- if (s.textContent = e.name, s.classList.add("treeselect-list__item-label"), t && this.showCount) {
634
- const i = o(this, Ye, _s).call(this, e);
635
- s.appendChild(i);
636
- }
637
- return s;
638
- }, Ye = new WeakSet(), _s = function(e) {
639
- const t = document.createElement("span"), s = this.flattedOptions.filter((i) => i.childOf === e.value);
640
- return t.textContent = `(${s.length})`, t.classList.add("treeselect-list__item-label-counter"), t;
641
- }, Ke = new WeakSet(), As = function(e, t) {
642
- const s = this.flattedOptions.find((i) => i.id === t.value);
643
- if (s) {
644
- if (s != null && s.isGroup && this.disabledBranchNode) {
645
- const i = Oi(e);
646
- i == null || i.dispatchEvent(new Event("mousedown"));
647
- return;
648
- }
649
- if (this.isSingleSelect) {
650
- const [i] = n(this, x);
651
- if (s.id === i)
652
- return;
653
- m(this, x, [s.id]), ss([s.id], this.flattedOptions, this.isSingleSelect, this.isIndependentNodes);
654
- } else {
655
- s.checked = e.checked;
656
- const i = It(s, this.flattedOptions, this.isIndependentNodes);
657
- e.checked = i;
658
- }
659
- ce(this.flattedOptions, this.srcElement, this.iconElements, n(this, x)), o(this, Je, Ns).call(this);
660
- }
661
- }, Xe = new WeakSet(), Ts = function(e) {
662
- var a, h;
663
- const t = (h = (a = e.target) == null ? void 0 : a.parentNode) == null ? void 0 : h.querySelector("[input-id]"), s = (t == null ? void 0 : t.getAttribute("input-id")) ?? null, i = Vt(s, this.flattedOptions);
664
- i && (i.isClosed = !i.isClosed, Ct(this.flattedOptions, i), ce(this.flattedOptions, this.srcElement, this.iconElements, n(this, x)), this.arrowClickCallback(i.id, i.isClosed));
665
- }, J = new WeakSet(), yt = function(e, t) {
666
- const s = "treeselect-list__item--focused";
667
- if (e) {
668
- const i = Array.from(this.srcElement.querySelectorAll(`.${s}`));
669
- i.length && i.forEach((a) => a.classList.remove(s)), t.classList.add(s);
670
- } else
671
- t.classList.remove(s);
672
- }, Z = new WeakSet(), xt = function() {
673
- const { ungroupedNodes: e, groupedNodes: t, allNodes: s } = Ci(this.flattedOptions);
674
- this.selectedNodes = { nodes: e, groupedNodes: t, allNodes: s };
675
- }, Je = new WeakSet(), Ns = function() {
676
- o(this, Z, xt).call(this), this.inputCallback(this.selectedNodes), this.value = this.selectedNodes.nodes.map((e) => e.id);
677
- };
678
- const Dt = ({
679
- parentHtmlContainer: l,
680
- staticList: e,
681
- appendToBody: t,
682
- isSingleSelect: s,
683
- value: i,
684
- direction: a
685
- }) => {
686
- l || console.error("Validation: parentHtmlContainer prop is required!"), e && t && console.error("Validation: You should set staticList to false if you use appendToBody!"), s && Array.isArray(i) && console.error("Validation: if you use isSingleSelect prop, you should pass a single value!"), !s && !Array.isArray(i) && console.error("Validation: you should pass an array as a value!"), a && a !== "auto" && a !== "bottom" && a !== "top" && console.error("Validation: you should pass (auto | top | bottom | undefined) as a value for the direction prop!");
687
- }, re = (l) => l.map((e) => e.id), Bi = (l) => l ? Array.isArray(l) ? l : [l] : [], Vi = (l, e) => {
688
- if (e) {
689
- const [t] = l;
690
- return t ?? null;
691
- }
692
- return l;
693
- };
694
- var d, u, F, Q, q, S, _, L, B, ee, St, te, _t, Ze, Os, Qe, Is, et, Ps, tt, Bs, st, Vs, it, Ds, se, At, lt, Hs, nt, Gs, at, Ms, ot, Fs, ie, Tt, rt, qs, j, he, le, Nt, $, de, ct, js, ne, Ot, ht, $s, dt, Ws, ut, Rs, pt, Us, mt, zs;
695
- class Hi {
696
- constructor({
697
- parentHtmlContainer: e,
698
- value: t,
699
- options: s,
700
- openLevel: i,
701
- appendToBody: a,
702
- alwaysOpen: h,
703
- showTags: p,
704
- tagsCountText: f,
705
- clearable: C,
706
- searchable: b,
707
- placeholder: g,
708
- grouped: k,
709
- isGroupedValue: w,
710
- listSlotHtmlComponent: y,
711
- disabled: I,
712
- emptyText: W,
713
- staticList: ae,
714
- id: bt,
715
- ariaLabel: gt,
716
- isSingleSelect: oe,
717
- showCount: Ys,
718
- disabledBranchNode: Ks,
719
- direction: Xs,
720
- expandSelected: Js,
721
- saveScrollPosition: Zs,
722
- isIndependentNodes: Qs,
723
- iconElements: ei,
724
- inputCallback: ti,
725
- openCallback: si,
726
- closeCallback: ii,
727
- nameChangeCallback: li,
728
- searchCallback: ni,
729
- openCloseGroupCallback: ai
730
- }) {
731
- r(this, ee);
732
- r(this, te);
733
- r(this, Ze);
734
- r(this, Qe);
735
- r(this, et);
736
- r(this, tt);
737
- r(this, st);
738
- r(this, it);
739
- r(this, se);
740
- r(this, lt);
741
- r(this, nt);
742
- r(this, at);
743
- r(this, ot);
744
- r(this, ie);
745
- r(this, rt);
746
- r(this, j);
747
- r(this, le);
748
- r(this, $);
749
- r(this, ct);
750
- // Emits
751
- r(this, ne);
752
- r(this, ht);
753
- r(this, dt);
754
- r(this, ut);
755
- r(this, pt);
756
- r(this, mt);
757
- // Props
758
- c(this, "parentHtmlContainer");
759
- c(this, "value");
760
- c(this, "options");
761
- c(this, "openLevel");
762
- c(this, "appendToBody");
763
- c(this, "alwaysOpen");
764
- c(this, "showTags");
765
- c(this, "tagsCountText");
766
- c(this, "clearable");
767
- c(this, "searchable");
768
- c(this, "placeholder");
769
- c(this, "grouped");
770
- c(this, "isGroupedValue");
771
- c(this, "listSlotHtmlComponent");
772
- c(this, "disabled");
773
- c(this, "emptyText");
774
- c(this, "staticList");
775
- c(this, "id");
776
- c(this, "ariaLabel");
777
- c(this, "isSingleSelect");
778
- c(this, "showCount");
779
- c(this, "disabledBranchNode");
780
- c(this, "direction");
781
- c(this, "expandSelected");
782
- c(this, "saveScrollPosition");
783
- c(this, "isIndependentNodes");
784
- c(this, "iconElements");
785
- c(this, "inputCallback");
786
- c(this, "openCallback");
787
- c(this, "closeCallback");
788
- c(this, "nameChangeCallback");
789
- c(this, "searchCallback");
790
- c(this, "openCloseGroupCallback");
791
- // InnerState
792
- c(this, "ungroupedValue");
793
- c(this, "groupedValue");
794
- c(this, "allValue");
795
- c(this, "isListOpened");
796
- c(this, "selectedName");
797
- c(this, "srcElement");
798
- // Components
799
- r(this, d, null);
800
- r(this, u, null);
801
- // Resize props
802
- r(this, F, null);
803
- // List position scroll
804
- r(this, Q, 0);
805
- // Timer for search text
806
- r(this, q, 0);
807
- // Outside listeners
808
- r(this, S, null);
809
- r(this, _, null);
810
- r(this, L, null);
811
- r(this, B, null);
812
- Dt({
813
- parentHtmlContainer: e,
814
- value: t,
815
- staticList: ae,
816
- appendToBody: a,
817
- isSingleSelect: oe
818
- }), this.parentHtmlContainer = e, this.value = [], this.options = s ?? [], this.openLevel = i ?? 0, this.appendToBody = a ?? !1, this.alwaysOpen = !!(h && !I), this.showTags = p ?? !0, this.tagsCountText = f ?? "elements selected", this.clearable = C ?? !0, this.searchable = b ?? !0, this.placeholder = g ?? "Search...", this.grouped = k ?? !0, this.isGroupedValue = w ?? !1, this.listSlotHtmlComponent = y ?? null, this.disabled = I ?? !1, this.emptyText = W ?? "No results found...", this.staticList = !!(ae && !this.appendToBody), this.id = bt ?? "", this.ariaLabel = gt ?? "", this.isSingleSelect = oe ?? !1, this.showCount = Ys ?? !1, this.disabledBranchNode = Ks ?? !1, this.direction = Xs ?? "auto", this.expandSelected = Js ?? !1, this.saveScrollPosition = Zs ?? !0, this.isIndependentNodes = Qs ?? !1, this.iconElements = Bt(ei), this.inputCallback = ti, this.openCallback = si, this.closeCallback = ii, this.nameChangeCallback = li, this.searchCallback = ni, this.openCloseGroupCallback = ai, this.ungroupedValue = [], this.groupedValue = [], this.allValue = [], this.isListOpened = !1, this.selectedName = "", this.srcElement = null, o(this, ee, St).call(this, t);
819
- }
820
- mount() {
821
- Dt({
822
- parentHtmlContainer: this.parentHtmlContainer,
823
- value: this.value,
824
- staticList: this.staticList,
825
- appendToBody: this.appendToBody,
826
- isSingleSelect: this.isSingleSelect
827
- }), this.iconElements = Bt(this.iconElements), o(this, ee, St).call(this, this.value);
828
- }
829
- updateValue(e) {
830
- const t = Bi(e), s = n(this, d);
831
- s && (s.updateValue(t), o(this, se, At).call(this, s == null ? void 0 : s.selectedNodes));
832
- }
833
- destroy() {
834
- this.srcElement && (o(this, ie, Tt).call(this), this.srcElement.innerHTML = "", this.srcElement = null, o(this, $, de).call(this, !0));
835
- }
836
- focus() {
837
- n(this, u) && n(this, u).focus();
838
- }
839
- toggleOpenClose() {
840
- n(this, u) && (n(this, u).openClose(), n(this, u).focus());
841
- }
842
- // Outside Listeners
843
- scrollWindowHandler() {
844
- this.updateListPosition();
845
- }
846
- focusWindowHandler(e) {
847
- var s, i, a;
848
- ((s = this.srcElement) == null ? void 0 : s.contains(e.target)) || ((i = n(this, d)) == null ? void 0 : i.srcElement.contains(e.target)) || ((a = n(this, u)) == null || a.blur(), o(this, $, de).call(this, !1), o(this, j, he).call(this, !1));
849
- }
850
- blurWindowHandler() {
851
- var e;
852
- (e = n(this, u)) == null || e.blur(), o(this, $, de).call(this, !1), o(this, j, he).call(this, !1);
853
- }
854
- // Update direction of the list. Support appendToBody and standard mode with absolute
855
- updateListPosition() {
856
- var y;
857
- const e = this.srcElement, t = (y = n(this, d)) == null ? void 0 : y.srcElement;
858
- if (!e || !t)
859
- return;
860
- const { height: s } = t.getBoundingClientRect(), {
861
- x: i,
862
- y: a,
863
- height: h,
864
- width: p
865
- } = e.getBoundingClientRect(), f = window.innerHeight, C = a, b = f - a - h;
866
- let g = C > b && C >= s && b < s;
867
- if (this.direction !== "auto" && (g = this.direction === "top"), this.appendToBody) {
868
- (t.style.top !== "0px" || t.style.left !== "0px") && (t.style.top = "0px", t.style.left = "0px");
869
- const I = i + window.scrollX, W = g ? a + window.scrollY - s : a + window.scrollY + h;
870
- t.style.transform = `translate(${I}px,${W}px)`, t.style.width = `${p}px`;
871
- }
872
- const k = g ? "top" : "bottom";
873
- t.getAttribute("direction") !== k && (t.setAttribute("direction", k), o(this, rt, qs).call(this, g, this.appendToBody));
874
- }
875
- }
876
- d = new WeakMap(), u = new WeakMap(), F = new WeakMap(), Q = new WeakMap(), q = new WeakMap(), S = new WeakMap(), _ = new WeakMap(), L = new WeakMap(), B = new WeakMap(), ee = new WeakSet(), St = function(e) {
877
- var a;
878
- this.destroy();
879
- const { container: t, list: s, input: i } = o(this, Ze, Os).call(this);
880
- this.srcElement = t, m(this, d, s), m(this, u, i), m(this, S, this.scrollWindowHandler.bind(this)), m(this, _, this.scrollWindowHandler.bind(this)), m(this, L, this.focusWindowHandler.bind(this)), m(this, B, this.blurWindowHandler.bind(this)), this.alwaysOpen && ((a = n(this, u)) == null || a.openClose()), this.disabled ? this.srcElement.classList.add("treeselect--disabled") : this.srcElement.classList.remove("treeselect--disabled"), this.updateValue(e ?? this.value);
881
- }, te = new WeakSet(), _t = function({
882
- groupedNodes: e,
883
- nodes: t,
884
- allNodes: s
885
- }) {
886
- this.ungroupedValue = t ? re(t) : [], this.groupedValue = e ? re(e) : [], this.allValue = s ? re(s) : [];
887
- let i = [];
888
- this.isIndependentNodes || this.isSingleSelect ? i = this.allValue : this.isGroupedValue ? i = this.groupedValue : i = this.ungroupedValue, this.value = Vi(i, this.isSingleSelect);
889
- }, Ze = new WeakSet(), Os = function() {
890
- const e = this.parentHtmlContainer;
891
- e.classList.add("treeselect");
892
- const t = new Pi({
893
- value: [],
894
- // updateValue method calls in initMount method to set actual value
895
- options: this.options,
896
- openLevel: this.openLevel,
897
- listSlotHtmlComponent: this.listSlotHtmlComponent,
898
- emptyText: this.emptyText,
899
- isSingleSelect: this.isSingleSelect,
900
- showCount: this.showCount,
901
- disabledBranchNode: this.disabledBranchNode,
902
- expandSelected: this.expandSelected,
903
- isIndependentNodes: this.isIndependentNodes,
904
- iconElements: this.iconElements,
905
- inputCallback: (i) => o(this, lt, Hs).call(this, i),
906
- arrowClickCallback: (i, a) => o(this, nt, Gs).call(this, i, a),
907
- mouseupCallback: () => {
908
- var i;
909
- return (i = n(this, u)) == null ? void 0 : i.focus();
910
- }
911
- }), s = new hi({
912
- value: [],
913
- // updateValue method calls in initMount method to set actual value
914
- showTags: this.showTags,
915
- tagsCountText: this.tagsCountText,
916
- clearable: this.clearable,
917
- isAlwaysOpened: this.alwaysOpen,
918
- searchable: this.searchable,
919
- placeholder: this.placeholder,
920
- disabled: this.disabled,
921
- isSingleSelect: this.isSingleSelect,
922
- id: this.id,
923
- ariaLabel: this.ariaLabel,
924
- iconElements: this.iconElements,
925
- inputCallback: (i) => o(this, Qe, Is).call(this, i),
926
- searchCallback: (i) => o(this, tt, Bs).call(this, i),
927
- openCallback: () => o(this, ot, Fs).call(this),
928
- closeCallback: () => o(this, ie, Tt).call(this),
929
- keydownCallback: (i) => o(this, et, Ps).call(this, i),
930
- focusCallback: () => o(this, st, Vs).call(this),
931
- blurCallback: () => o(this, it, Ds).call(this),
932
- nameChangeCallback: (i) => o(this, at, Ms).call(this, i)
933
- });
934
- return this.appendToBody && m(this, F, new ResizeObserver(() => this.updateListPosition())), e.append(s.srcElement), { container: e, list: t, input: s };
935
- }, Qe = new WeakSet(), Is = function(e) {
936
- var i, a;
937
- const t = re(e);
938
- (i = n(this, d)) == null || i.updateValue(t);
939
- const s = ((a = n(this, d)) == null ? void 0 : a.selectedNodes) ?? {};
940
- o(this, te, _t).call(this, s), o(this, ne, Ot).call(this);
941
- }, et = new WeakSet(), Ps = function(e) {
942
- var t;
943
- this.isListOpened && ((t = n(this, d)) == null || t.callKeyAction(e));
944
- }, tt = new WeakSet(), Bs = function(e) {
945
- n(this, q) && clearTimeout(n(this, q)), m(this, q, window.setTimeout(() => {
946
- var t;
947
- (t = n(this, d)) == null || t.updateSearchValue(e), this.updateListPosition();
948
- }, 350)), o(this, pt, Us).call(this, e);
949
- }, st = new WeakSet(), Vs = function() {
950
- o(this, j, he).call(this, !0), n(this, L) && n(this, L) && n(this, B) && (document.addEventListener("mousedown", n(this, L), !0), document.addEventListener("focus", n(this, L), !0), window.addEventListener("blur", n(this, B)));
951
- }, it = new WeakSet(), Ds = function() {
952
- setTimeout(() => {
953
- var s, i;
954
- const e = (s = n(this, u)) == null ? void 0 : s.srcElement.contains(document.activeElement), t = (i = n(this, d)) == null ? void 0 : i.srcElement.contains(document.activeElement);
955
- !e && !t && this.blurWindowHandler();
956
- }, 1);
957
- }, se = new WeakSet(), At = function(e) {
958
- var s;
959
- if (!e)
960
- return;
961
- let t = [];
962
- this.isIndependentNodes || this.isSingleSelect ? t = e.allNodes : this.grouped ? t = e.groupedNodes : t = e.nodes, (s = n(this, u)) == null || s.updateValue(t), o(this, te, _t).call(this, e);
963
- }, lt = new WeakSet(), Hs = function(e) {
964
- var t, s, i;
965
- o(this, se, At).call(this, e), this.isSingleSelect && !this.alwaysOpen && ((t = n(this, u)) == null || t.openClose(), (s = n(this, u)) == null || s.clearSearch()), (i = n(this, u)) == null || i.focus(), o(this, ne, Ot).call(this);
966
- }, nt = new WeakSet(), Gs = function(e, t) {
967
- var s;
968
- (s = n(this, u)) == null || s.focus(), this.updateListPosition(), o(this, mt, zs).call(this, e, t);
969
- }, at = new WeakSet(), Ms = function(e) {
970
- this.selectedName !== e && (this.selectedName = e, o(this, ht, $s).call(this));
971
- }, ot = new WeakSet(), Fs = function() {
972
- var e;
973
- this.isListOpened = !0, n(this, S) && n(this, _) && (window.addEventListener("scroll", n(this, S), !0), window.addEventListener("resize", n(this, _))), !(!n(this, d) || !this.srcElement) && (this.appendToBody ? (document.body.appendChild(n(this, d).srcElement), (e = n(this, F)) == null || e.observe(this.srcElement)) : this.srcElement.appendChild(n(this, d).srcElement), this.updateListPosition(), o(this, le, Nt).call(this, !0), o(this, ct, js).call(this), o(this, dt, Ws).call(this));
974
- }, ie = new WeakSet(), Tt = function() {
975
- var t;
976
- this.alwaysOpen || (this.isListOpened = !1, n(this, S) && n(this, _) && (window.removeEventListener("scroll", n(this, S), !0), window.removeEventListener("resize", n(this, _))), !n(this, d) || !this.srcElement) || !(this.appendToBody ? document.body.contains(n(this, d).srcElement) : this.srcElement.contains(n(this, d).srcElement)) || (m(this, Q, n(this, d).srcElement.scrollTop), this.appendToBody ? (document.body.removeChild(n(this, d).srcElement), (t = n(this, F)) == null || t.disconnect()) : this.srcElement.removeChild(n(this, d).srcElement), o(this, le, Nt).call(this, !1), o(this, ut, Rs).call(this));
977
- }, rt = new WeakSet(), qs = function(e, t) {
978
- if (!n(this, d) || !n(this, u))
979
- return;
980
- const s = t ? "treeselect-list--top-to-body" : "treeselect-list--top", i = t ? "treeselect-list--bottom-to-body" : "treeselect-list--bottom";
981
- e ? (n(this, d).srcElement.classList.add(s), n(this, d).srcElement.classList.remove(i), n(this, u).srcElement.classList.add("treeselect-input--top"), n(this, u).srcElement.classList.remove("treeselect-input--bottom")) : (n(this, d).srcElement.classList.remove(s), n(this, d).srcElement.classList.add(i), n(this, u).srcElement.classList.remove("treeselect-input--top"), n(this, u).srcElement.classList.add("treeselect-input--bottom"));
982
- }, j = new WeakSet(), he = function(e) {
983
- !n(this, u) || !n(this, d) || (e ? (n(this, u).srcElement.classList.add("treeselect-input--focused"), n(this, d).srcElement.classList.add("treeselect-list--focused")) : (n(this, u).srcElement.classList.remove("treeselect-input--focused"), n(this, d).srcElement.classList.remove("treeselect-list--focused")));
984
- }, le = new WeakSet(), Nt = function(e) {
985
- var t, s, i, a;
986
- e ? (t = n(this, u)) == null || t.srcElement.classList.add("treeselect-input--opened") : (s = n(this, u)) == null || s.srcElement.classList.remove("treeselect-input--opened"), this.staticList ? (i = n(this, d)) == null || i.srcElement.classList.add("treeselect-list--static") : (a = n(this, d)) == null || a.srcElement.classList.remove("treeselect-list--static");
987
- }, $ = new WeakSet(), de = function(e) {
988
- !n(this, S) || !n(this, _) || !n(this, L) || !n(this, B) || ((!this.alwaysOpen || e) && (window.removeEventListener("scroll", n(this, S), !0), window.removeEventListener("resize", n(this, _))), document.removeEventListener("mousedown", n(this, L), !0), document.removeEventListener("focus", n(this, L), !0), window.removeEventListener("blur", n(this, B)));
989
- }, ct = new WeakSet(), js = function() {
990
- var t, s, i;
991
- const e = (t = n(this, d)) == null ? void 0 : t.isLastFocusedElementExist();
992
- this.saveScrollPosition && e ? (s = n(this, d)) == null || s.srcElement.scroll(0, n(this, Q)) : (i = n(this, d)) == null || i.focusFirstListElement();
993
- }, ne = new WeakSet(), Ot = function() {
994
- var e;
995
- (e = this.srcElement) == null || e.dispatchEvent(new CustomEvent("input", { detail: this.value })), this.inputCallback && this.inputCallback(this.value);
996
- }, ht = new WeakSet(), $s = function() {
997
- var e;
998
- (e = this.srcElement) == null || e.dispatchEvent(new CustomEvent("name-change", { detail: this.selectedName })), this.nameChangeCallback && this.nameChangeCallback(this.selectedName);
999
- }, dt = new WeakSet(), Ws = function() {
1000
- var e;
1001
- this.alwaysOpen || ((e = this.srcElement) == null || e.dispatchEvent(new CustomEvent("open", { detail: this.value })), this.openCallback && this.openCallback(this.value));
1002
- }, ut = new WeakSet(), Rs = function() {
1003
- var e;
1004
- this.alwaysOpen || ((e = this.srcElement) == null || e.dispatchEvent(new CustomEvent("close", { detail: this.value })), this.closeCallback && this.closeCallback(this.value));
1005
- }, pt = new WeakSet(), Us = function(e) {
1006
- var s;
1007
- const t = (e == null ? void 0 : e.trim()) ?? "";
1008
- (s = this.srcElement) == null || s.dispatchEvent(new CustomEvent("search", { detail: t })), this.searchCallback && this.searchCallback(t);
1009
- }, mt = new WeakSet(), zs = function(e, t) {
1010
- var s;
1011
- (s = this.srcElement) == null || s.dispatchEvent(new CustomEvent("open-close-group", { detail: { groupId: e, isClosed: t } })), this.openCloseGroupCallback && this.openCloseGroupCallback(e, t);
1012
- };
1013
- export {
1014
- Hi as default
1015
- };
1
+ var ci = Object.defineProperty;
2
+ var hi = (l, e, t) => e in l ? ci(l, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : l[e] = t;
3
+ var c = (l, e, t) => (hi(l, typeof e != "symbol" ? e + "" : e, t), t), kt = (l, e, t) => {
4
+ if (!e.has(l))
5
+ throw TypeError("Cannot " + t);
6
+ };
7
+ var n = (l, e, t) => (kt(l, e, "read from private field"), t ? t.call(l) : e.get(l)), r = (l, e, t) => {
8
+ if (e.has(l))
9
+ throw TypeError("Cannot add the same private member more than once");
10
+ e instanceof WeakSet ? e.add(l) : e.set(l, t);
11
+ }, m = (l, e, t, s) => (kt(l, e, "write to private field"), s ? s.call(l, t) : e.set(l, t), t);
12
+ var o = (l, e, t) => (kt(l, e, "access private method"), t);
13
+ const Pt = {
14
+ arrowUp: '<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 25 25" fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M18 15l-6-6-6 6"/></svg>',
15
+ arrowDown: '<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 25 25" fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M6 9l6 6 6-6"/></svg>',
16
+ arrowRight: '<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 25 25" fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M9 18l6-6-6-6"/></svg>',
17
+ attention: '<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 25 25" fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"></path><line x1="12" y1="9" x2="12" y2="13"></line><line x1="12" y1="17" x2="12.01" y2="17"></line></svg>',
18
+ clear: '<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 25 25" fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"></circle><line x1="15" y1="9" x2="9" y2="15"></line><line x1="9" y1="9" x2="15" y2="15"></line></svg>',
19
+ cross: '<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 25 25" fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="18" y1="6" x2="6" y2="18"></line><line x1="6" y1="6" x2="18" y2="18"></line></svg>',
20
+ check: '<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 25 25" fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="20 6 9 17 4 12"></polyline></svg>',
21
+ partialCheck: '<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 25 25" fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="5" y1="12" x2="19" y2="12"></line></svg>'
22
+ }, I = (l, e) => {
23
+ if (e.innerHTML = "", typeof l == "string")
24
+ e.innerHTML = l;
25
+ else {
26
+ const t = l.cloneNode(!0);
27
+ e.appendChild(t);
28
+ }
29
+ }, Bt = (l) => {
30
+ const e = l ? { ...l } : {};
31
+ return Object.keys(Pt).forEach((t) => {
32
+ e[t] || (e[t] = Pt[t]);
33
+ }), e;
34
+ }, di = (l) => l.reduce((e, { name: t }, s) => (e += t, s < l.length - 1 && (e += ", "), e), "");
35
+ var T, E, H, v, ue, Ht, G, W, pe, Gt, me, Mt, M, U, O, D, fe, Ft, Ce, qt, be, jt, ge, Rt, ke, $t, we, Wt, Ee, Ut, ve, zt, Le, Yt, ye, Kt, xe, Xt, Se, Jt, _e, Zt, Ae, Qt, Ne, es, Te, ts, z, wt;
36
+ class ui {
37
+ constructor({
38
+ value: e,
39
+ showTags: t,
40
+ tagsCountText: s,
41
+ clearable: i,
42
+ isAlwaysOpened: a,
43
+ searchable: h,
44
+ placeholder: d,
45
+ disabled: b,
46
+ isSingleSelect: f,
47
+ id: C,
48
+ ariaLabel: g,
49
+ iconElements: k,
50
+ inputCallback: w,
51
+ searchCallback: y,
52
+ openCallback: x,
53
+ closeCallback: V,
54
+ keydownCallback: ae,
55
+ focusCallback: bt,
56
+ blurCallback: gt,
57
+ nameChangeCallback: oe
58
+ }) {
59
+ // Private methods
60
+ r(this, ue);
61
+ r(this, G);
62
+ r(this, pe);
63
+ r(this, me);
64
+ r(this, M);
65
+ r(this, O);
66
+ r(this, fe);
67
+ r(this, Ce);
68
+ r(this, be);
69
+ r(this, ge);
70
+ r(this, ke);
71
+ r(this, we);
72
+ r(this, Ee);
73
+ r(this, ve);
74
+ r(this, Le);
75
+ r(this, ye);
76
+ r(this, xe);
77
+ r(this, Se);
78
+ r(this, _e);
79
+ r(this, Ae);
80
+ r(this, Ne);
81
+ r(this, Te);
82
+ // Emits
83
+ r(this, z);
84
+ // Props
85
+ c(this, "value");
86
+ c(this, "showTags");
87
+ c(this, "tagsCountText");
88
+ c(this, "clearable");
89
+ c(this, "isAlwaysOpened");
90
+ c(this, "searchable");
91
+ c(this, "placeholder");
92
+ c(this, "disabled");
93
+ c(this, "isSingleSelect");
94
+ c(this, "id");
95
+ c(this, "ariaLabel");
96
+ c(this, "iconElements");
97
+ // InnerState
98
+ c(this, "isOpened");
99
+ c(this, "searchText");
100
+ c(this, "srcElement");
101
+ // PrivateInnerState
102
+ r(this, T, void 0);
103
+ r(this, E, void 0);
104
+ r(this, H, void 0);
105
+ r(this, v, void 0);
106
+ // Callbacks
107
+ c(this, "inputCallback");
108
+ c(this, "searchCallback");
109
+ c(this, "openCallback");
110
+ c(this, "closeCallback");
111
+ c(this, "keydownCallback");
112
+ c(this, "focusCallback");
113
+ c(this, "blurCallback");
114
+ c(this, "nameChangeCallback");
115
+ this.value = e, this.showTags = t, this.tagsCountText = s, this.searchable = h, this.placeholder = d, this.clearable = i, this.isAlwaysOpened = a, this.disabled = b, this.isSingleSelect = f, this.id = C, this.ariaLabel = g, this.iconElements = k, this.isOpened = !1, this.searchText = "", m(this, T, o(this, be, jt).call(this)), m(this, E, o(this, Le, Yt).call(this)), m(this, H, o(this, Se, Jt).call(this)), m(this, v, null), this.inputCallback = w, this.searchCallback = y, this.openCallback = x, this.closeCallback = V, this.keydownCallback = ae, this.focusCallback = bt, this.blurCallback = gt, this.nameChangeCallback = oe, this.srcElement = o(this, fe, Ft).call(this, n(this, T), n(this, E), n(this, H)), o(this, ue, Ht).call(this);
116
+ }
117
+ // Public methods
118
+ focus() {
119
+ setTimeout(() => n(this, E).focus(), 0);
120
+ }
121
+ blur() {
122
+ this.isOpened && o(this, O, D).call(this), this.clearSearch(), n(this, E).blur();
123
+ }
124
+ updateValue(e) {
125
+ this.value = e, o(this, G, W).call(this), o(this, M, U).call(this);
126
+ }
127
+ removeItem(e) {
128
+ this.value = this.value.filter((t) => t.id !== e), o(this, z, wt).call(this), o(this, G, W).call(this), o(this, M, U).call(this);
129
+ }
130
+ clear() {
131
+ this.value = [], o(this, z, wt).call(this), o(this, G, W).call(this), this.clearSearch();
132
+ }
133
+ openClose() {
134
+ o(this, O, D).call(this);
135
+ }
136
+ clearSearch() {
137
+ this.searchText = "", this.searchCallback(""), o(this, M, U).call(this);
138
+ }
139
+ }
140
+ T = new WeakMap(), E = new WeakMap(), H = new WeakMap(), v = new WeakMap(), ue = new WeakSet(), Ht = function() {
141
+ o(this, G, W).call(this), o(this, M, U).call(this), o(this, pe, Gt).call(this);
142
+ }, G = new WeakSet(), W = function() {
143
+ if (n(this, T).innerHTML = "", this.showTags) {
144
+ n(this, T).append(...o(this, ge, Rt).call(this));
145
+ const e = di(this.value);
146
+ this.nameChangeCallback(e);
147
+ } else {
148
+ const e = o(this, ve, zt).call(this);
149
+ n(this, T).appendChild(e), this.nameChangeCallback(e.innerText);
150
+ }
151
+ n(this, T).appendChild(n(this, E));
152
+ }, pe = new WeakSet(), Gt = function() {
153
+ const e = [];
154
+ n(this, H).innerHTML = "", this.clearable && e.push(o(this, _e, Zt).call(this)), this.isAlwaysOpened || e.push(o(this, Ne, es).call(this, this.isOpened)), e.length && n(this, H).append(...e);
155
+ }, me = new WeakSet(), Mt = function() {
156
+ if (!this.isAlwaysOpened && n(this, v)) {
157
+ const e = this.isOpened ? this.iconElements.arrowUp : this.iconElements.arrowDown;
158
+ I(e, n(this, v));
159
+ }
160
+ }, M = new WeakSet(), U = function() {
161
+ var e;
162
+ (e = this.value) != null && e.length ? (n(this, E).removeAttribute("placeholder"), this.srcElement.classList.remove("treeselect-input--value-not-selected")) : (n(this, E).setAttribute("placeholder", this.placeholder), this.srcElement.classList.add("treeselect-input--value-not-selected")), this.searchable ? this.srcElement.classList.remove("treeselect-input--unsearchable") : this.srcElement.classList.add("treeselect-input--unsearchable"), this.isSingleSelect ? this.srcElement.classList.add("treeselect-input--is-single-select") : this.srcElement.classList.remove("treeselect-input--is-single-select"), n(this, E).value = this.searchText;
163
+ }, O = new WeakSet(), D = function() {
164
+ this.isOpened = !this.isOpened, o(this, me, Mt).call(this), this.isOpened ? this.openCallback() : this.closeCallback();
165
+ }, fe = new WeakSet(), Ft = function(e, t, s) {
166
+ const i = document.createElement("div");
167
+ return i.classList.add("treeselect-input"), i.setAttribute("tabindex", "-1"), i.addEventListener("mousedown", (a) => o(this, Ce, qt).call(this, a)), i.addEventListener("focus", () => this.focusCallback(), !0), i.addEventListener("blur", () => this.blurCallback(), !0), e.appendChild(t), i.append(e, s), i;
168
+ }, Ce = new WeakSet(), qt = function(e) {
169
+ e.stopPropagation(), this.isOpened || o(this, O, D).call(this), this.focus();
170
+ }, be = new WeakSet(), jt = function() {
171
+ const e = document.createElement("div");
172
+ return e.classList.add("treeselect-input__tags"), e;
173
+ }, ge = new WeakSet(), Rt = function() {
174
+ return this.value.map((e) => {
175
+ const t = document.createElement("div");
176
+ t.classList.add("treeselect-input__tags-element"), t.setAttribute("tabindex", "-1"), t.setAttribute("tag-id", e.id.toString()), t.setAttribute("title", e.name);
177
+ const s = o(this, we, Wt).call(this, e.name), i = o(this, Ee, Ut).call(this);
178
+ return t.addEventListener("mousedown", (a) => o(this, ke, $t).call(this, a, e.id)), t.append(s, i), t;
179
+ });
180
+ }, ke = new WeakSet(), $t = function(e, t) {
181
+ e.preventDefault(), e.stopPropagation(), this.removeItem(t), this.focus();
182
+ }, we = new WeakSet(), Wt = function(e) {
183
+ const t = document.createElement("span");
184
+ return t.classList.add("treeselect-input__tags-name"), t.textContent = e, t;
185
+ }, Ee = new WeakSet(), Ut = function() {
186
+ const e = document.createElement("span");
187
+ return e.classList.add("treeselect-input__tags-cross"), I(this.iconElements.cross, e), e;
188
+ }, ve = new WeakSet(), zt = function() {
189
+ const e = document.createElement("span");
190
+ if (e.classList.add("treeselect-input__tags-count"), !this.value.length)
191
+ return e.textContent = "", e.setAttribute("title", ""), e;
192
+ const t = this.value.length === 1 ? this.value[0].name : `${this.value.length} ${this.tagsCountText}`;
193
+ return e.textContent = t, e.setAttribute("title", t), e;
194
+ }, Le = new WeakSet(), Yt = function() {
195
+ const e = document.createElement("input");
196
+ return e.classList.add("treeselect-input__edit"), this.id && e.setAttribute("id", this.id), (!this.searchable || this.disabled) && e.setAttribute("readonly", "readonly"), this.disabled && e.setAttribute("tabindex", "-1"), this.ariaLabel.length && e.setAttribute("aria-label", this.ariaLabel), e.addEventListener("keydown", (t) => o(this, ye, Kt).call(this, t)), e.addEventListener("input", (t) => o(this, xe, Xt).call(this, t, e)), e;
197
+ }, ye = new WeakSet(), Kt = function(e) {
198
+ e.stopPropagation();
199
+ const t = e.key;
200
+ t === "Backspace" && !this.searchText.length && this.value.length && !this.showTags && this.clear(), t === "Backspace" && !this.searchText.length && this.value.length && this.removeItem(this.value[this.value.length - 1].id), e.code === "Space" && (!this.searchText || !this.searchable) && o(this, O, D).call(this), (t === "Enter" || t === "ArrowDown" || t === "ArrowUp") && e.preventDefault(), this.keydownCallback(e), t !== "Tab" && this.focus();
201
+ }, xe = new WeakSet(), Xt = function(e, t) {
202
+ e.stopPropagation();
203
+ const s = this.searchText, i = t.value.trim();
204
+ if (s.length === 0 && i.length === 0) {
205
+ t.value = "";
206
+ return;
207
+ }
208
+ if (this.searchable) {
209
+ const a = e.target.value;
210
+ this.searchCallback(a), this.isOpened || o(this, O, D).call(this);
211
+ } else
212
+ t.value = "";
213
+ this.searchText = t.value;
214
+ }, Se = new WeakSet(), Jt = function() {
215
+ const e = document.createElement("div");
216
+ return e.classList.add("treeselect-input__operators"), e;
217
+ }, _e = new WeakSet(), Zt = function() {
218
+ const e = document.createElement("span");
219
+ return e.classList.add("treeselect-input__clear"), e.setAttribute("tabindex", "-1"), I(this.iconElements.clear, e), e.addEventListener("mousedown", (t) => o(this, Ae, Qt).call(this, t)), e;
220
+ }, Ae = new WeakSet(), Qt = function(e) {
221
+ e.preventDefault(), e.stopPropagation(), (this.searchText.length || this.value.length) && this.clear(), this.focus();
222
+ }, Ne = new WeakSet(), es = function(e) {
223
+ m(this, v, document.createElement("span")), n(this, v).classList.add("treeselect-input__arrow");
224
+ const t = e ? this.iconElements.arrowUp : this.iconElements.arrowDown;
225
+ return I(t, n(this, v)), n(this, v).addEventListener("mousedown", (s) => o(this, Te, ts).call(this, s)), n(this, v);
226
+ }, Te = new WeakSet(), ts = function(e) {
227
+ e.stopPropagation(), e.preventDefault(), this.focus(), o(this, O, D).call(this);
228
+ }, z = new WeakSet(), wt = function() {
229
+ this.inputCallback(this.value);
230
+ };
231
+ const ss = (l, e, t, s) => {
232
+ Ci(e);
233
+ const i = e.filter((a) => !a.disabled && l.some((h) => h === a.id));
234
+ if (t && i.length) {
235
+ i[0].checked = !0;
236
+ return;
237
+ }
238
+ i.forEach((a) => {
239
+ a.checked = !0;
240
+ const h = It(a, e, s);
241
+ a.checked = h;
242
+ });
243
+ }, It = ({ id: l, checked: e }, t, s) => {
244
+ const i = t.find((h) => h.id === l);
245
+ if (!i)
246
+ return !1;
247
+ if (s)
248
+ return i.checked = i.disabled ? !1 : !!e, i.checked;
249
+ const a = is(!!e, i, t);
250
+ return ls(i, t), a;
251
+ }, is = (l, e, t) => {
252
+ if (!e.isGroup)
253
+ return e.checked = e.disabled ? !1 : !!l, e.isPartialChecked = !1, e.checked;
254
+ const s = t.filter((d) => d.childOf === e.id);
255
+ return !l || e.disabled || e.isPartialChecked ? (e.checked = !1, e.isPartialChecked = !1, Et(e, s, t), e.checked) : ns(s, t) ? as(s) ? (e.checked = !1, e.isPartialChecked = !1, e.disabled = !0, e.checked) : (e.checked = !1, e.isPartialChecked = !0, s.forEach((d) => {
256
+ is(l, d, t);
257
+ }), e.checked) : (e.checked = !0, e.isPartialChecked = !1, Et(e, s, t), e.checked);
258
+ }, ls = (l, e) => {
259
+ const t = e.find((s) => s.id === l.childOf);
260
+ t && (pi(t, e), ls(t, e));
261
+ }, pi = (l, e) => {
262
+ const t = ft(l, e);
263
+ if (as(t)) {
264
+ l.checked = !1, l.isPartialChecked = !1, l.disabled = !0;
265
+ return;
266
+ }
267
+ if (mi(t)) {
268
+ l.checked = !0, l.isPartialChecked = !1;
269
+ return;
270
+ }
271
+ if (fi(t)) {
272
+ l.checked = !1, l.isPartialChecked = !0;
273
+ return;
274
+ }
275
+ l.checked = !1, l.isPartialChecked = !1;
276
+ }, Et = ({ checked: l, disabled: e }, t, s) => {
277
+ t.forEach((i) => {
278
+ i.disabled = !!e || !!i.disabled, i.checked = !!l && !i.disabled, i.isPartialChecked = !1;
279
+ const a = ft(i, s);
280
+ Et({ checked: l, disabled: e }, a, s);
281
+ });
282
+ }, ns = (l, e) => l.some((i) => i.disabled) ? !0 : l.some((i) => {
283
+ if (i.isGroup) {
284
+ const a = ft(i, e);
285
+ return ns(a, e);
286
+ }
287
+ return !1;
288
+ }), as = (l) => l.every((e) => !!e.disabled), mi = (l) => l.every((e) => !!e.checked), fi = (l) => l.some((e) => !!e.checked || !!e.isPartialChecked), Ci = (l) => {
289
+ l.forEach((e) => {
290
+ e.checked = !1, e.isPartialChecked = !1;
291
+ });
292
+ }, bi = (l, e, t) => {
293
+ const s = { level: 0, groupId: "" }, i = os(l, e, s.groupId, s.level);
294
+ return ki(i, t);
295
+ }, os = (l, e, t, s) => l.reduce((i, a) => {
296
+ var f;
297
+ const h = !!((f = a.children) != null && f.length), d = s >= e && h, b = s > e;
298
+ if (i.push({
299
+ id: a.value,
300
+ name: a.name,
301
+ childOf: t,
302
+ isGroup: h,
303
+ checked: !1,
304
+ isPartialChecked: !1,
305
+ level: s,
306
+ isClosed: d,
307
+ hidden: b,
308
+ disabled: a.disabled ?? !1
309
+ }), h) {
310
+ const C = os(a.children, e, a.value, s + 1);
311
+ i.push(...C);
312
+ }
313
+ return i;
314
+ }, []), ft = ({ id: l }, e) => e.filter((t) => t.childOf === l), gi = (l) => {
315
+ const { ungroupedNodes: e, allGroupedNodes: t, allNodes: s } = l.reduce(
316
+ (a, h) => (h.checked && (a.allNodes.push(h), h.isGroup ? a.allGroupedNodes.push(h) : a.ungroupedNodes.push(h)), a),
317
+ {
318
+ ungroupedNodes: [],
319
+ allGroupedNodes: [],
320
+ allNodes: []
321
+ }
322
+ ), i = s.filter((a) => !t.some(({ id: h }) => h === a.childOf));
323
+ return { ungroupedNodes: e, groupedNodes: i, allNodes: s };
324
+ }, ki = (l, e) => (l.filter((s) => !!s.disabled).forEach(
325
+ ({ id: s }) => It({ id: s, checked: !1 }, l, e)
326
+ ), l), Ct = (l, { id: e, isClosed: t }) => {
327
+ ft({ id: e }, l).forEach((i) => {
328
+ i.hidden = t ?? !1, i.isGroup && !i.isClosed && Ct(l, { id: i.id, isClosed: t });
329
+ });
330
+ }, wi = (l) => {
331
+ l.filter((e) => e.isGroup && !e.disabled && (e.checked || e.isPartialChecked)).forEach((e) => {
332
+ e.isClosed = !1, Ct(l, e);
333
+ });
334
+ }, Ei = (l, e) => {
335
+ const t = vi(l, e);
336
+ l.forEach((s) => {
337
+ t.some(({ id: a }) => a === s.id) ? (s.isGroup && (s.isClosed = !1, Ct(l, s)), s.hidden = !1) : s.hidden = !0;
338
+ });
339
+ }, vi = (l, e) => l.reduce((t, s) => {
340
+ if (s.name.toLowerCase().includes(e.toLowerCase())) {
341
+ if (t.push(s), s.isGroup) {
342
+ const a = rs(s.id, l);
343
+ t.push(...a);
344
+ }
345
+ if (s.childOf) {
346
+ const a = cs(s.childOf, l);
347
+ t.push(...a);
348
+ }
349
+ }
350
+ return t;
351
+ }, []), rs = (l, e) => e.reduce((t, s) => (s.childOf === l && (t.push(s), s.isGroup && t.push(...rs(s.id, e))), t), []), cs = (l, e) => e.reduce((t, s) => (s.id === l && (t.push(s), s.childOf && t.push(...cs(s.childOf, e))), t), []), Li = (l) => {
352
+ const { duplications: e } = l.reduce(
353
+ (t, s) => (t.allItems.some((i) => i.toString() === s.id.toString()) && t.duplications.push(s.id), t.allItems.push(s.id), t),
354
+ {
355
+ duplications: [],
356
+ allItems: []
357
+ }
358
+ );
359
+ e.length && console.error(`Validation: You have duplicated values: ${e.join(", ")}! You should use unique values.`);
360
+ }, yi = (l, e, t, s, i, a, h, d, b, f) => {
361
+ ss(l, e, i, b), d && h && wi(e), ce(e, t, s, a, f);
362
+ }, ce = (l, e, t, s, i) => {
363
+ l.forEach((a) => {
364
+ const h = e.querySelector(`[input-id="${a.id}"]`), d = N(h);
365
+ h.checked = a.checked, xi(a, d, s), Si(a, d), _i(a, d), Ai(a, d, t), Ni(a, d), Oi(a, d, l, i), Ti(a, h, t);
366
+ }), Ii(l, e);
367
+ }, xi = (l, e, t) => {
368
+ l.checked ? e.classList.add("treeselect-list__item--checked") : e.classList.remove("treeselect-list__item--checked"), Array.isArray(t) && t[0] === l.id && !l.disabled ? e.classList.add("treeselect-list__item--single-selected") : e.classList.remove("treeselect-list__item--single-selected");
369
+ }, Si = (l, e) => {
370
+ l.isPartialChecked ? e.classList.add("treeselect-list__item--partial-checked") : e.classList.remove("treeselect-list__item--partial-checked");
371
+ }, _i = (l, e) => {
372
+ l.disabled ? e.classList.add("treeselect-list__item--disabled") : e.classList.remove("treeselect-list__item--disabled");
373
+ }, Ai = (l, e, t) => {
374
+ if (l.isGroup) {
375
+ const s = e.querySelector(".treeselect-list__item-icon"), i = l.isClosed ? t.arrowRight : t.arrowDown;
376
+ I(i, s), l.isClosed ? e.classList.add("treeselect-list__item--closed") : e.classList.remove("treeselect-list__item--closed");
377
+ }
378
+ }, Ni = (l, e) => {
379
+ l.hidden ? e.classList.add("treeselect-list__item--hidden") : e.classList.remove("treeselect-list__item--hidden");
380
+ }, Ti = (l, e, t) => {
381
+ const i = e.parentNode.querySelector(".treeselect-list__item-checkbox-icon");
382
+ l.checked ? I(t.check, i) : l.isPartialChecked ? I(t.partialCheck, i) : i.innerHTML = "";
383
+ }, Oi = (l, e, t, s) => {
384
+ const i = l.level === 0, a = 20, h = 5;
385
+ if (i) {
386
+ const d = t.some((C) => C.isGroup && C.level === l.level), b = !l.isGroup && d ? `${a}px` : `${h}px`, f = l.isGroup ? "0" : b;
387
+ s ? e.style.paddingRight = f : e.style.paddingLeft = f;
388
+ } else {
389
+ const d = l.isGroup ? `${l.level * a}px` : `${l.level * a + a}px`;
390
+ s ? e.style.paddingRight = d : e.style.paddingLeft = d;
391
+ }
392
+ e.setAttribute("level", l.level.toString()), e.setAttribute("group", l.isGroup.toString());
393
+ }, Ii = (l, e) => {
394
+ const t = l.some((i) => !i.hidden), s = e.querySelector(".treeselect-list__empty");
395
+ t ? s.classList.add("treeselect-list__empty--hidden") : s.classList.remove("treeselect-list__empty--hidden");
396
+ }, N = (l) => l.parentNode.parentNode, Vt = (l, e) => e.find((t) => t.id.toString() === l), Pi = (l) => N(l).querySelector(".treeselect-list__item-icon"), Bi = (l, e) => {
397
+ e && Object.keys(e).forEach((t) => {
398
+ const s = e[t];
399
+ typeof s == "string" && l.setAttribute(t, s);
400
+ });
401
+ };
402
+ var F, P, S, Y, Oe, hs, Ie, ds, Pe, us, Be, ps, Ve, ms, De, fs, K, vt, He, Cs, Ge, bs, Me, gs, X, Lt, Fe, ks, qe, ws, je, Es, Re, vs, $e, Ls, We, ys, Ue, xs, ze, Ss, Ye, _s, Ke, As, Xe, Ns, J, yt, Z, xt, Je, Ts;
403
+ class Vi {
404
+ constructor({
405
+ options: e,
406
+ value: t,
407
+ openLevel: s,
408
+ listSlotHtmlComponent: i,
409
+ emptyText: a,
410
+ isSingleSelect: h,
411
+ iconElements: d,
412
+ showCount: b,
413
+ disabledBranchNode: f,
414
+ expandSelected: C,
415
+ isIndependentNodes: g,
416
+ rtl: k,
417
+ listClassName: w,
418
+ inputCallback: y,
419
+ arrowClickCallback: x,
420
+ mouseupCallback: V
421
+ }) {
422
+ // Private methods
423
+ r(this, Oe);
424
+ r(this, Ie);
425
+ r(this, Pe);
426
+ r(this, Be);
427
+ r(this, Ve);
428
+ r(this, De);
429
+ r(this, K);
430
+ r(this, He);
431
+ r(this, Ge);
432
+ r(this, Me);
433
+ r(this, X);
434
+ r(this, Fe);
435
+ r(this, qe);
436
+ r(this, je);
437
+ r(this, Re);
438
+ r(this, $e);
439
+ r(this, We);
440
+ r(this, Ue);
441
+ r(this, ze);
442
+ r(this, Ye);
443
+ // Actions
444
+ r(this, Ke);
445
+ r(this, Xe);
446
+ r(this, J);
447
+ r(this, Z);
448
+ // Emits
449
+ r(this, Je);
450
+ // Props
451
+ c(this, "options");
452
+ c(this, "value");
453
+ c(this, "openLevel");
454
+ c(this, "listSlotHtmlComponent");
455
+ c(this, "emptyText");
456
+ c(this, "isSingleSelect");
457
+ c(this, "showCount");
458
+ c(this, "disabledBranchNode");
459
+ c(this, "expandSelected");
460
+ c(this, "isIndependentNodes");
461
+ c(this, "rtl");
462
+ c(this, "listClassName");
463
+ c(this, "iconElements");
464
+ // InnerState
465
+ c(this, "searchText");
466
+ c(this, "flattedOptions");
467
+ c(this, "flattedOptionsBeforeSearch");
468
+ c(this, "selectedNodes");
469
+ c(this, "srcElement");
470
+ // Callbacks
471
+ c(this, "inputCallback");
472
+ c(this, "arrowClickCallback");
473
+ c(this, "mouseupCallback");
474
+ // PrivateInnerState
475
+ r(this, F, null);
476
+ r(this, P, !0);
477
+ r(this, S, []);
478
+ r(this, Y, !0);
479
+ this.options = e, this.value = t, this.openLevel = s ?? 0, this.listSlotHtmlComponent = i ?? null, this.emptyText = a ?? "No results found...", this.isSingleSelect = h ?? !1, this.showCount = b ?? !1, this.disabledBranchNode = f ?? !1, this.expandSelected = C ?? !1, this.isIndependentNodes = g ?? !1, this.rtl = k ?? !1, this.listClassName = w ?? "", this.iconElements = d, this.searchText = "", this.flattedOptions = bi(this.options, this.openLevel, this.isIndependentNodes), this.flattedOptionsBeforeSearch = this.flattedOptions, this.selectedNodes = { nodes: [], groupedNodes: [], allNodes: [] }, this.srcElement = o(this, Pe, us).call(this), this.inputCallback = y, this.arrowClickCallback = x, this.mouseupCallback = V, Li(this.flattedOptions);
480
+ }
481
+ // Public methods
482
+ updateValue(e) {
483
+ this.value = e, m(this, S, this.isSingleSelect ? this.value : []), yi(
484
+ e,
485
+ this.flattedOptions,
486
+ this.srcElement,
487
+ this.iconElements,
488
+ this.isSingleSelect,
489
+ n(this, S),
490
+ this.expandSelected,
491
+ n(this, Y),
492
+ this.isIndependentNodes,
493
+ this.rtl
494
+ ), m(this, Y, !1), o(this, Z, xt).call(this);
495
+ }
496
+ updateSearchValue(e) {
497
+ if (e === this.searchText)
498
+ return;
499
+ const t = this.searchText === "" && e !== "";
500
+ this.searchText = e, t && (this.flattedOptionsBeforeSearch = JSON.parse(JSON.stringify(this.flattedOptions))), this.searchText === "" && (this.flattedOptions = this.flattedOptionsBeforeSearch.map((s) => {
501
+ const i = this.flattedOptions.find((a) => a.id === s.id);
502
+ return i.isClosed = s.isClosed, i.hidden = s.hidden, i;
503
+ }), this.flattedOptionsBeforeSearch = []), this.searchText && Ei(this.flattedOptions, e), ce(this.flattedOptions, this.srcElement, this.iconElements, n(this, S), this.rtl), this.focusFirstListElement();
504
+ }
505
+ callKeyAction(e) {
506
+ m(this, P, !1);
507
+ const t = this.srcElement.querySelector(".treeselect-list__item--focused");
508
+ if (t == null ? void 0 : t.classList.contains("treeselect-list__item--hidden"))
509
+ return;
510
+ const i = e.key;
511
+ i === "Enter" && t && t.dispatchEvent(new Event("mousedown")), (i === "ArrowLeft" || i === "ArrowRight") && o(this, Oe, hs).call(this, t, e), (i === "ArrowDown" || i === "ArrowUp") && o(this, Ie, ds).call(this, t, i);
512
+ }
513
+ focusFirstListElement() {
514
+ const e = "treeselect-list__item--focused", t = this.srcElement.querySelector(`.${e}`), s = Array.from(this.srcElement.querySelectorAll(".treeselect-list__item-checkbox")).filter(
515
+ (a) => window.getComputedStyle(N(a)).display !== "none"
516
+ );
517
+ if (!s.length)
518
+ return;
519
+ t && t.classList.remove(e), N(s[0]).classList.add(e);
520
+ }
521
+ isLastFocusedElementExist() {
522
+ return !!n(this, F);
523
+ }
524
+ }
525
+ F = new WeakMap(), P = new WeakMap(), S = new WeakMap(), Y = new WeakMap(), Oe = new WeakSet(), hs = function(e, t) {
526
+ if (!e)
527
+ return;
528
+ const s = t.key, a = e.querySelector(".treeselect-list__item-checkbox").getAttribute("input-id"), h = Vt(a, this.flattedOptions), d = e.querySelector(".treeselect-list__item-icon");
529
+ s === "ArrowLeft" && !h.isClosed && h.isGroup && (d.dispatchEvent(new Event("mousedown")), t.preventDefault()), s === "ArrowRight" && h.isClosed && h.isGroup && (d.dispatchEvent(new Event("mousedown")), t.preventDefault());
530
+ }, Ie = new WeakSet(), ds = function(e, t) {
531
+ var i;
532
+ const s = Array.from(this.srcElement.querySelectorAll(".treeselect-list__item-checkbox")).filter(
533
+ (a) => window.getComputedStyle(N(a)).display !== "none"
534
+ );
535
+ if (s.length)
536
+ if (!e)
537
+ N(s[0]).classList.add("treeselect-list__item--focused");
538
+ else {
539
+ const a = s.findIndex(
540
+ (x) => N(x).classList.contains("treeselect-list__item--focused")
541
+ );
542
+ N(s[a]).classList.remove("treeselect-list__item--focused");
543
+ const d = t === "ArrowDown" ? a + 1 : a - 1, b = t === "ArrowDown" ? 0 : s.length - 1, f = s[d] ?? s[b], C = !s[d], g = N(f);
544
+ g.classList.add("treeselect-list__item--focused");
545
+ const k = this.srcElement.getBoundingClientRect(), w = g.getBoundingClientRect();
546
+ if (C && t === "ArrowDown") {
547
+ this.srcElement.scroll(0, 0);
548
+ return;
549
+ }
550
+ if (C && t === "ArrowUp") {
551
+ this.srcElement.scroll(0, this.srcElement.scrollHeight);
552
+ return;
553
+ }
554
+ const y = ((i = this.listSlotHtmlComponent) == null ? void 0 : i.clientHeight) ?? 0;
555
+ if (k.y + k.height < w.y + w.height + y) {
556
+ this.srcElement.scroll(0, this.srcElement.scrollTop + w.height);
557
+ return;
558
+ }
559
+ if (k.y > w.y) {
560
+ this.srcElement.scroll(0, this.srcElement.scrollTop - w.height);
561
+ return;
562
+ }
563
+ }
564
+ }, Pe = new WeakSet(), us = function() {
565
+ const e = o(this, Be, ps).call(this), t = o(this, K, vt).call(this, this.options);
566
+ e.append(...t);
567
+ const s = o(this, Ge, bs).call(this);
568
+ e.append(s);
569
+ const i = o(this, He, Cs).call(this);
570
+ return i && e.append(i), e;
571
+ }, Be = new WeakSet(), ps = function() {
572
+ const e = document.createElement("div");
573
+ return e.classList.add("treeselect-list"), this.listClassName.length > 0 && e.classList.add(this.listClassName), this.isSingleSelect && e.classList.add("treeselect-list--single-select"), this.disabledBranchNode && e.classList.add("treeselect-list--disabled-branch-node"), e.addEventListener("mouseout", (t) => o(this, Ve, ms).call(this, t)), e.addEventListener("mousemove", () => o(this, De, fs).call(this)), e.addEventListener("mouseup", () => this.mouseupCallback(), !0), e;
574
+ }, Ve = new WeakSet(), ms = function(e) {
575
+ e.stopPropagation(), n(this, F) && n(this, P) && n(this, F).classList.add("treeselect-list__item--focused");
576
+ }, De = new WeakSet(), fs = function() {
577
+ m(this, P, !0);
578
+ }, K = new WeakSet(), vt = function(e) {
579
+ return e.reduce((t, s) => {
580
+ var a;
581
+ if ((a = s.children) != null && a.length) {
582
+ const h = o(this, Me, gs).call(this, s), d = o(this, K, vt).call(this, s.children);
583
+ return h.append(...d), t.push(h), t;
584
+ }
585
+ const i = o(this, X, Lt).call(this, s, !1);
586
+ return t.push(i), t;
587
+ }, []);
588
+ }, He = new WeakSet(), Cs = function() {
589
+ if (!this.listSlotHtmlComponent)
590
+ return null;
591
+ const e = document.createElement("div");
592
+ return e.classList.add("treeselect-list__slot"), e.appendChild(this.listSlotHtmlComponent), e;
593
+ }, Ge = new WeakSet(), bs = function() {
594
+ const e = document.createElement("div");
595
+ e.classList.add("treeselect-list__empty"), e.setAttribute("title", this.emptyText);
596
+ const t = document.createElement("span");
597
+ t.classList.add("treeselect-list__empty-icon"), I(this.iconElements.attention, t);
598
+ const s = document.createElement("span");
599
+ return s.classList.add("treeselect-list__empty-text"), s.textContent = this.emptyText, e.append(t, s), e;
600
+ }, Me = new WeakSet(), gs = function(e) {
601
+ const t = document.createElement("div");
602
+ t.setAttribute("group-container-id", e.value.toString()), t.classList.add("treeselect-list__group-container");
603
+ const s = o(this, X, Lt).call(this, e, !0);
604
+ return t.appendChild(s), t;
605
+ }, X = new WeakSet(), Lt = function(e, t) {
606
+ const s = o(this, Fe, ks).call(this, e);
607
+ if (t) {
608
+ const h = o(this, $e, Ls).call(this);
609
+ s.appendChild(h), s.classList.add("treeselect-list__item--group");
610
+ }
611
+ const i = o(this, Ue, xs).call(this, e), a = o(this, ze, Ss).call(this, e, t);
612
+ return s.append(i, a), s;
613
+ }, Fe = new WeakSet(), ks = function(e) {
614
+ const t = document.createElement("div");
615
+ return Bi(t, e.htmlAttr), t.setAttribute("tabindex", "-1"), t.setAttribute("title", e.name), t.classList.add("treeselect-list__item"), t.addEventListener("mouseover", () => o(this, qe, ws).call(this, t), !0), t.addEventListener("mouseout", () => o(this, je, Es).call(this, t), !0), t.addEventListener("mousedown", (s) => o(this, Re, vs).call(this, s, e)), t;
616
+ }, qe = new WeakSet(), ws = function(e) {
617
+ n(this, P) && o(this, J, yt).call(this, !0, e);
618
+ }, je = new WeakSet(), Es = function(e) {
619
+ n(this, P) && (o(this, J, yt).call(this, !1, e), m(this, F, e));
620
+ }, Re = new WeakSet(), vs = function(e, t) {
621
+ var a;
622
+ if (e.preventDefault(), e.stopPropagation(), (a = this.flattedOptions.find((h) => h.id === t.value)) == null ? void 0 : a.disabled)
623
+ return;
624
+ const i = e.target.querySelector(".treeselect-list__item-checkbox");
625
+ i.checked = !i.checked, o(this, Ke, As).call(this, i, t);
626
+ }, $e = new WeakSet(), Ls = function() {
627
+ const e = document.createElement("span");
628
+ return e.setAttribute("tabindex", "-1"), e.classList.add("treeselect-list__item-icon"), I(this.iconElements.arrowDown, e), e.addEventListener("mousedown", (t) => o(this, We, ys).call(this, t)), e;
629
+ }, We = new WeakSet(), ys = function(e) {
630
+ e.preventDefault(), e.stopPropagation(), o(this, Xe, Ns).call(this, e);
631
+ }, Ue = new WeakSet(), xs = function(e) {
632
+ const t = document.createElement("div");
633
+ t.classList.add("treeselect-list__item-checkbox-container");
634
+ const s = document.createElement("span");
635
+ s.classList.add("treeselect-list__item-checkbox-icon"), s.innerHTML = "";
636
+ const i = document.createElement("input");
637
+ return i.setAttribute("tabindex", "-1"), i.setAttribute("type", "checkbox"), i.setAttribute("input-id", e.value.toString()), i.classList.add("treeselect-list__item-checkbox"), t.append(s, i), t;
638
+ }, ze = new WeakSet(), Ss = function(e, t) {
639
+ const s = document.createElement("label");
640
+ if (s.textContent = e.name, s.classList.add("treeselect-list__item-label"), t && this.showCount) {
641
+ const i = o(this, Ye, _s).call(this, e);
642
+ s.appendChild(i);
643
+ }
644
+ return s;
645
+ }, Ye = new WeakSet(), _s = function(e) {
646
+ const t = document.createElement("span"), s = this.flattedOptions.filter((i) => i.childOf === e.value);
647
+ return t.textContent = `(${s.length})`, t.classList.add("treeselect-list__item-label-counter"), t;
648
+ }, Ke = new WeakSet(), As = function(e, t) {
649
+ const s = this.flattedOptions.find((i) => i.id === t.value);
650
+ if (s) {
651
+ if (s != null && s.isGroup && this.disabledBranchNode) {
652
+ const i = Pi(e);
653
+ i == null || i.dispatchEvent(new Event("mousedown"));
654
+ return;
655
+ }
656
+ if (this.isSingleSelect) {
657
+ const [i] = n(this, S);
658
+ if (s.id === i)
659
+ return;
660
+ m(this, S, [s.id]), ss([s.id], this.flattedOptions, this.isSingleSelect, this.isIndependentNodes);
661
+ } else {
662
+ s.checked = e.checked;
663
+ const i = It(s, this.flattedOptions, this.isIndependentNodes);
664
+ e.checked = i;
665
+ }
666
+ ce(this.flattedOptions, this.srcElement, this.iconElements, n(this, S), this.rtl), o(this, Je, Ts).call(this);
667
+ }
668
+ }, Xe = new WeakSet(), Ns = function(e) {
669
+ var a, h;
670
+ const t = (h = (a = e.target) == null ? void 0 : a.parentNode) == null ? void 0 : h.querySelector("[input-id]"), s = (t == null ? void 0 : t.getAttribute("input-id")) ?? null, i = Vt(s, this.flattedOptions);
671
+ i && (i.isClosed = !i.isClosed, Ct(this.flattedOptions, i), ce(this.flattedOptions, this.srcElement, this.iconElements, n(this, S), this.rtl), this.arrowClickCallback(i.id, i.isClosed));
672
+ }, J = new WeakSet(), yt = function(e, t) {
673
+ const s = "treeselect-list__item--focused";
674
+ if (e) {
675
+ const i = Array.from(this.srcElement.querySelectorAll(`.${s}`));
676
+ i.length && i.forEach((a) => a.classList.remove(s)), t.classList.add(s);
677
+ } else
678
+ t.classList.remove(s);
679
+ }, Z = new WeakSet(), xt = function() {
680
+ const { ungroupedNodes: e, groupedNodes: t, allNodes: s } = gi(this.flattedOptions);
681
+ this.selectedNodes = { nodes: e, groupedNodes: t, allNodes: s };
682
+ }, Je = new WeakSet(), Ts = function() {
683
+ o(this, Z, xt).call(this), this.inputCallback(this.selectedNodes), this.value = this.selectedNodes.nodes.map((e) => e.id);
684
+ };
685
+ const Dt = ({
686
+ parentHtmlContainer: l,
687
+ staticList: e,
688
+ appendToBody: t,
689
+ isSingleSelect: s,
690
+ value: i,
691
+ direction: a
692
+ }) => {
693
+ l || console.error("Validation: parentHtmlContainer prop is required!"), e && t && console.error("Validation: You should set staticList to false if you use appendToBody!"), s && Array.isArray(i) && console.error("Validation: if you use isSingleSelect prop, you should pass a single value!"), !s && !Array.isArray(i) && console.error("Validation: you should pass an array as a value!"), a && a !== "auto" && a !== "bottom" && a !== "top" && console.error("Validation: you should pass (auto | top | bottom | undefined) as a value for the direction prop!");
694
+ }, re = (l) => l.map((e) => e.id), Di = (l) => l ? Array.isArray(l) ? l : [l] : [], Hi = (l, e) => {
695
+ if (e) {
696
+ const [t] = l;
697
+ return t ?? null;
698
+ }
699
+ return l;
700
+ };
701
+ var u, p, q, Q, j, _, A, L, B, ee, St, te, _t, Ze, Os, Qe, Is, et, Ps, tt, Bs, st, Vs, it, Ds, se, At, lt, Hs, nt, Gs, at, Ms, ot, Fs, ie, Nt, rt, qs, R, he, le, Tt, $, de, ct, js, ne, Ot, ht, Rs, dt, $s, ut, Ws, pt, Us, mt, zs;
702
+ class Mi {
703
+ constructor({
704
+ parentHtmlContainer: e,
705
+ value: t,
706
+ options: s,
707
+ openLevel: i,
708
+ appendToBody: a,
709
+ alwaysOpen: h,
710
+ showTags: d,
711
+ tagsCountText: b,
712
+ clearable: f,
713
+ searchable: C,
714
+ placeholder: g,
715
+ grouped: k,
716
+ isGroupedValue: w,
717
+ listSlotHtmlComponent: y,
718
+ disabled: x,
719
+ emptyText: V,
720
+ staticList: ae,
721
+ id: bt,
722
+ ariaLabel: gt,
723
+ isSingleSelect: oe,
724
+ showCount: Ys,
725
+ disabledBranchNode: Ks,
726
+ direction: Xs,
727
+ expandSelected: Js,
728
+ saveScrollPosition: Zs,
729
+ isIndependentNodes: Qs,
730
+ rtl: ei,
731
+ listClassName: ti,
732
+ iconElements: si,
733
+ inputCallback: ii,
734
+ openCallback: li,
735
+ closeCallback: ni,
736
+ nameChangeCallback: ai,
737
+ searchCallback: oi,
738
+ openCloseGroupCallback: ri
739
+ }) {
740
+ r(this, ee);
741
+ r(this, te);
742
+ r(this, Ze);
743
+ r(this, Qe);
744
+ r(this, et);
745
+ r(this, tt);
746
+ r(this, st);
747
+ r(this, it);
748
+ r(this, se);
749
+ r(this, lt);
750
+ r(this, nt);
751
+ r(this, at);
752
+ r(this, ot);
753
+ r(this, ie);
754
+ r(this, rt);
755
+ r(this, R);
756
+ r(this, le);
757
+ r(this, $);
758
+ r(this, ct);
759
+ // Emits
760
+ r(this, ne);
761
+ r(this, ht);
762
+ r(this, dt);
763
+ r(this, ut);
764
+ r(this, pt);
765
+ r(this, mt);
766
+ // Props
767
+ c(this, "parentHtmlContainer");
768
+ c(this, "value");
769
+ c(this, "options");
770
+ c(this, "openLevel");
771
+ c(this, "appendToBody");
772
+ c(this, "alwaysOpen");
773
+ c(this, "showTags");
774
+ c(this, "tagsCountText");
775
+ c(this, "clearable");
776
+ c(this, "searchable");
777
+ c(this, "placeholder");
778
+ c(this, "grouped");
779
+ c(this, "isGroupedValue");
780
+ c(this, "listSlotHtmlComponent");
781
+ c(this, "disabled");
782
+ c(this, "emptyText");
783
+ c(this, "staticList");
784
+ c(this, "id");
785
+ c(this, "ariaLabel");
786
+ c(this, "isSingleSelect");
787
+ c(this, "showCount");
788
+ c(this, "disabledBranchNode");
789
+ c(this, "direction");
790
+ c(this, "expandSelected");
791
+ c(this, "saveScrollPosition");
792
+ c(this, "isIndependentNodes");
793
+ c(this, "rtl");
794
+ c(this, "listClassName");
795
+ c(this, "iconElements");
796
+ c(this, "inputCallback");
797
+ c(this, "openCallback");
798
+ c(this, "closeCallback");
799
+ c(this, "nameChangeCallback");
800
+ c(this, "searchCallback");
801
+ c(this, "openCloseGroupCallback");
802
+ // InnerState
803
+ c(this, "ungroupedValue");
804
+ c(this, "groupedValue");
805
+ c(this, "allValue");
806
+ c(this, "isListOpened");
807
+ c(this, "selectedName");
808
+ c(this, "srcElement");
809
+ // Components
810
+ r(this, u, null);
811
+ r(this, p, null);
812
+ // Resize props
813
+ r(this, q, null);
814
+ // List position scroll
815
+ r(this, Q, 0);
816
+ // Timer for search text
817
+ r(this, j, 0);
818
+ // Outside listeners
819
+ r(this, _, null);
820
+ r(this, A, null);
821
+ r(this, L, null);
822
+ r(this, B, null);
823
+ Dt({
824
+ parentHtmlContainer: e,
825
+ value: t,
826
+ staticList: ae,
827
+ appendToBody: a,
828
+ isSingleSelect: oe
829
+ }), this.parentHtmlContainer = e, this.value = [], this.options = s ?? [], this.openLevel = i ?? 0, this.appendToBody = a ?? !1, this.alwaysOpen = !!(h && !x), this.showTags = d ?? !0, this.tagsCountText = b ?? "elements selected", this.clearable = f ?? !0, this.searchable = C ?? !0, this.placeholder = g ?? "Search...", this.grouped = k ?? !0, this.isGroupedValue = w ?? !1, this.listSlotHtmlComponent = y ?? null, this.disabled = x ?? !1, this.emptyText = V ?? "No results found...", this.staticList = !!(ae && !this.appendToBody), this.id = bt ?? "", this.ariaLabel = gt ?? "", this.isSingleSelect = oe ?? !1, this.showCount = Ys ?? !1, this.disabledBranchNode = Ks ?? !1, this.direction = Xs ?? "auto", this.expandSelected = Js ?? !1, this.saveScrollPosition = Zs ?? !0, this.isIndependentNodes = Qs ?? !1, this.rtl = ei ?? !1, this.listClassName = ti ?? "", this.iconElements = Bt(si), this.inputCallback = ii, this.openCallback = li, this.closeCallback = ni, this.nameChangeCallback = ai, this.searchCallback = oi, this.openCloseGroupCallback = ri, this.ungroupedValue = [], this.groupedValue = [], this.allValue = [], this.isListOpened = !1, this.selectedName = "", this.srcElement = null, o(this, ee, St).call(this, t);
830
+ }
831
+ mount() {
832
+ Dt({
833
+ parentHtmlContainer: this.parentHtmlContainer,
834
+ value: this.value,
835
+ staticList: this.staticList,
836
+ appendToBody: this.appendToBody,
837
+ isSingleSelect: this.isSingleSelect
838
+ }), this.iconElements = Bt(this.iconElements), o(this, ee, St).call(this, this.value);
839
+ }
840
+ updateValue(e) {
841
+ const t = Di(e), s = n(this, u);
842
+ s && (s.updateValue(t), o(this, se, At).call(this, s == null ? void 0 : s.selectedNodes));
843
+ }
844
+ destroy() {
845
+ this.srcElement && (o(this, ie, Nt).call(this), this.srcElement.innerHTML = "", this.srcElement = null, o(this, $, de).call(this, !0));
846
+ }
847
+ focus() {
848
+ n(this, p) && n(this, p).focus();
849
+ }
850
+ toggleOpenClose() {
851
+ n(this, p) && (n(this, p).openClose(), n(this, p).focus());
852
+ }
853
+ // Outside Listeners
854
+ scrollWindowHandler() {
855
+ this.updateListPosition();
856
+ }
857
+ focusWindowHandler(e) {
858
+ var s, i, a;
859
+ ((s = this.srcElement) == null ? void 0 : s.contains(e.target)) || ((i = n(this, u)) == null ? void 0 : i.srcElement.contains(e.target)) || ((a = n(this, p)) == null || a.blur(), o(this, $, de).call(this, !1), o(this, R, he).call(this, !1));
860
+ }
861
+ blurWindowHandler() {
862
+ var e;
863
+ (e = n(this, p)) == null || e.blur(), o(this, $, de).call(this, !1), o(this, R, he).call(this, !1);
864
+ }
865
+ // Update direction of the list. Support appendToBody and standard mode with absolute
866
+ updateListPosition() {
867
+ var y;
868
+ const e = this.srcElement, t = (y = n(this, u)) == null ? void 0 : y.srcElement;
869
+ if (!e || !t)
870
+ return;
871
+ const { height: s } = t.getBoundingClientRect(), {
872
+ x: i,
873
+ y: a,
874
+ height: h,
875
+ width: d
876
+ } = e.getBoundingClientRect(), b = window.innerHeight, f = a, C = b - a - h;
877
+ let g = f > C && f >= s && C < s;
878
+ if (this.direction !== "auto" && (g = this.direction === "top"), this.appendToBody) {
879
+ (t.style.top !== "0px" || t.style.left !== "0px") && (t.style.top = "0px", t.style.left = "0px");
880
+ const x = i + window.scrollX, V = g ? a + window.scrollY - s : a + window.scrollY + h;
881
+ t.style.transform = `translate(${x}px,${V}px)`, t.style.width = `${d}px`;
882
+ }
883
+ const k = g ? "top" : "bottom";
884
+ t.getAttribute("direction") !== k && (t.setAttribute("direction", k), o(this, rt, qs).call(this, g, this.appendToBody));
885
+ }
886
+ }
887
+ u = new WeakMap(), p = new WeakMap(), q = new WeakMap(), Q = new WeakMap(), j = new WeakMap(), _ = new WeakMap(), A = new WeakMap(), L = new WeakMap(), B = new WeakMap(), ee = new WeakSet(), St = function(e) {
888
+ var a;
889
+ this.destroy();
890
+ const { container: t, list: s, input: i } = o(this, Ze, Os).call(this);
891
+ this.srcElement = t, m(this, u, s), m(this, p, i), m(this, _, this.scrollWindowHandler.bind(this)), m(this, A, this.scrollWindowHandler.bind(this)), m(this, L, this.focusWindowHandler.bind(this)), m(this, B, this.blurWindowHandler.bind(this)), this.alwaysOpen && ((a = n(this, p)) == null || a.openClose()), this.disabled ? this.srcElement.classList.add("treeselect--disabled") : this.srcElement.classList.remove("treeselect--disabled"), this.updateValue(e ?? this.value);
892
+ }, te = new WeakSet(), _t = function({
893
+ groupedNodes: e,
894
+ nodes: t,
895
+ allNodes: s
896
+ }) {
897
+ this.ungroupedValue = t ? re(t) : [], this.groupedValue = e ? re(e) : [], this.allValue = s ? re(s) : [];
898
+ let i = [];
899
+ this.isIndependentNodes || this.isSingleSelect ? i = this.allValue : this.isGroupedValue ? i = this.groupedValue : i = this.ungroupedValue, this.value = Hi(i, this.isSingleSelect);
900
+ }, Ze = new WeakSet(), Os = function() {
901
+ const e = this.parentHtmlContainer;
902
+ e.classList.add("treeselect"), this.rtl && e.setAttribute("dir", "rtl");
903
+ const t = new Vi({
904
+ value: [],
905
+ // updateValue method calls in initMount method to set actual value
906
+ options: this.options,
907
+ openLevel: this.openLevel,
908
+ listSlotHtmlComponent: this.listSlotHtmlComponent,
909
+ emptyText: this.emptyText,
910
+ isSingleSelect: this.isSingleSelect,
911
+ showCount: this.showCount,
912
+ disabledBranchNode: this.disabledBranchNode,
913
+ expandSelected: this.expandSelected,
914
+ isIndependentNodes: this.isIndependentNodes,
915
+ rtl: this.rtl,
916
+ listClassName: this.listClassName,
917
+ iconElements: this.iconElements,
918
+ inputCallback: (i) => o(this, lt, Hs).call(this, i),
919
+ arrowClickCallback: (i, a) => o(this, nt, Gs).call(this, i, a),
920
+ mouseupCallback: () => {
921
+ var i;
922
+ return (i = n(this, p)) == null ? void 0 : i.focus();
923
+ }
924
+ }), s = new ui({
925
+ value: [],
926
+ // updateValue method calls in initMount method to set actual value
927
+ showTags: this.showTags,
928
+ tagsCountText: this.tagsCountText,
929
+ clearable: this.clearable,
930
+ isAlwaysOpened: this.alwaysOpen,
931
+ searchable: this.searchable,
932
+ placeholder: this.placeholder,
933
+ disabled: this.disabled,
934
+ isSingleSelect: this.isSingleSelect,
935
+ id: this.id,
936
+ ariaLabel: this.ariaLabel,
937
+ iconElements: this.iconElements,
938
+ inputCallback: (i) => o(this, Qe, Is).call(this, i),
939
+ searchCallback: (i) => o(this, tt, Bs).call(this, i),
940
+ openCallback: () => o(this, ot, Fs).call(this),
941
+ closeCallback: () => o(this, ie, Nt).call(this),
942
+ keydownCallback: (i) => o(this, et, Ps).call(this, i),
943
+ focusCallback: () => o(this, st, Vs).call(this),
944
+ blurCallback: () => o(this, it, Ds).call(this),
945
+ nameChangeCallback: (i) => o(this, at, Ms).call(this, i)
946
+ });
947
+ return this.appendToBody && m(this, q, new ResizeObserver(() => this.updateListPosition())), e.append(s.srcElement), { container: e, list: t, input: s };
948
+ }, Qe = new WeakSet(), Is = function(e) {
949
+ var i, a;
950
+ const t = re(e);
951
+ (i = n(this, u)) == null || i.updateValue(t);
952
+ const s = ((a = n(this, u)) == null ? void 0 : a.selectedNodes) ?? {};
953
+ o(this, te, _t).call(this, s), o(this, ne, Ot).call(this);
954
+ }, et = new WeakSet(), Ps = function(e) {
955
+ var t;
956
+ this.isListOpened && ((t = n(this, u)) == null || t.callKeyAction(e));
957
+ }, tt = new WeakSet(), Bs = function(e) {
958
+ n(this, j) && clearTimeout(n(this, j)), m(this, j, window.setTimeout(() => {
959
+ var t;
960
+ (t = n(this, u)) == null || t.updateSearchValue(e), this.updateListPosition();
961
+ }, 350)), o(this, pt, Us).call(this, e);
962
+ }, st = new WeakSet(), Vs = function() {
963
+ o(this, R, he).call(this, !0), n(this, L) && n(this, L) && n(this, B) && (document.addEventListener("mousedown", n(this, L), !0), document.addEventListener("focus", n(this, L), !0), window.addEventListener("blur", n(this, B)));
964
+ }, it = new WeakSet(), Ds = function() {
965
+ setTimeout(() => {
966
+ var s, i;
967
+ const e = (s = n(this, p)) == null ? void 0 : s.srcElement.contains(document.activeElement), t = (i = n(this, u)) == null ? void 0 : i.srcElement.contains(document.activeElement);
968
+ !e && !t && this.blurWindowHandler();
969
+ }, 1);
970
+ }, se = new WeakSet(), At = function(e) {
971
+ var s;
972
+ if (!e)
973
+ return;
974
+ let t = [];
975
+ this.isIndependentNodes || this.isSingleSelect ? t = e.allNodes : this.grouped ? t = e.groupedNodes : t = e.nodes, (s = n(this, p)) == null || s.updateValue(t), o(this, te, _t).call(this, e);
976
+ }, lt = new WeakSet(), Hs = function(e) {
977
+ var t, s, i;
978
+ o(this, se, At).call(this, e), this.isSingleSelect && !this.alwaysOpen && ((t = n(this, p)) == null || t.openClose(), (s = n(this, p)) == null || s.clearSearch()), (i = n(this, p)) == null || i.focus(), o(this, ne, Ot).call(this);
979
+ }, nt = new WeakSet(), Gs = function(e, t) {
980
+ var s;
981
+ (s = n(this, p)) == null || s.focus(), this.updateListPosition(), o(this, mt, zs).call(this, e, t);
982
+ }, at = new WeakSet(), Ms = function(e) {
983
+ this.selectedName !== e && (this.selectedName = e, o(this, ht, Rs).call(this));
984
+ }, ot = new WeakSet(), Fs = function() {
985
+ var e;
986
+ this.isListOpened = !0, n(this, _) && n(this, A) && (window.addEventListener("scroll", n(this, _), !0), window.addEventListener("resize", n(this, A))), !(!n(this, u) || !this.srcElement) && (this.appendToBody ? (document.body.appendChild(n(this, u).srcElement), (e = n(this, q)) == null || e.observe(this.srcElement)) : this.srcElement.appendChild(n(this, u).srcElement), this.updateListPosition(), o(this, le, Tt).call(this, !0), o(this, ct, js).call(this), o(this, dt, $s).call(this));
987
+ }, ie = new WeakSet(), Nt = function() {
988
+ var t;
989
+ this.alwaysOpen || (this.isListOpened = !1, n(this, _) && n(this, A) && (window.removeEventListener("scroll", n(this, _), !0), window.removeEventListener("resize", n(this, A))), !n(this, u) || !this.srcElement) || !(this.appendToBody ? document.body.contains(n(this, u).srcElement) : this.srcElement.contains(n(this, u).srcElement)) || (m(this, Q, n(this, u).srcElement.scrollTop), this.appendToBody ? (document.body.removeChild(n(this, u).srcElement), (t = n(this, q)) == null || t.disconnect()) : this.srcElement.removeChild(n(this, u).srcElement), o(this, le, Tt).call(this, !1), o(this, ut, Ws).call(this));
990
+ }, rt = new WeakSet(), qs = function(e, t) {
991
+ if (!n(this, u) || !n(this, p))
992
+ return;
993
+ const s = t ? "treeselect-list--top-to-body" : "treeselect-list--top", i = t ? "treeselect-list--bottom-to-body" : "treeselect-list--bottom";
994
+ e ? (n(this, u).srcElement.classList.add(s), n(this, u).srcElement.classList.remove(i), n(this, p).srcElement.classList.add("treeselect-input--top"), n(this, p).srcElement.classList.remove("treeselect-input--bottom")) : (n(this, u).srcElement.classList.remove(s), n(this, u).srcElement.classList.add(i), n(this, p).srcElement.classList.remove("treeselect-input--top"), n(this, p).srcElement.classList.add("treeselect-input--bottom"));
995
+ }, R = new WeakSet(), he = function(e) {
996
+ !n(this, p) || !n(this, u) || (e ? (n(this, p).srcElement.classList.add("treeselect-input--focused"), n(this, u).srcElement.classList.add("treeselect-list--focused")) : (n(this, p).srcElement.classList.remove("treeselect-input--focused"), n(this, u).srcElement.classList.remove("treeselect-list--focused")));
997
+ }, le = new WeakSet(), Tt = function(e) {
998
+ var t, s, i, a;
999
+ e ? (t = n(this, p)) == null || t.srcElement.classList.add("treeselect-input--opened") : (s = n(this, p)) == null || s.srcElement.classList.remove("treeselect-input--opened"), this.staticList ? (i = n(this, u)) == null || i.srcElement.classList.add("treeselect-list--static") : (a = n(this, u)) == null || a.srcElement.classList.remove("treeselect-list--static");
1000
+ }, $ = new WeakSet(), de = function(e) {
1001
+ !n(this, _) || !n(this, A) || !n(this, L) || !n(this, B) || ((!this.alwaysOpen || e) && (window.removeEventListener("scroll", n(this, _), !0), window.removeEventListener("resize", n(this, A))), document.removeEventListener("mousedown", n(this, L), !0), document.removeEventListener("focus", n(this, L), !0), window.removeEventListener("blur", n(this, B)));
1002
+ }, ct = new WeakSet(), js = function() {
1003
+ var t, s, i;
1004
+ const e = (t = n(this, u)) == null ? void 0 : t.isLastFocusedElementExist();
1005
+ this.saveScrollPosition && e ? (s = n(this, u)) == null || s.srcElement.scroll(0, n(this, Q)) : (i = n(this, u)) == null || i.focusFirstListElement();
1006
+ }, ne = new WeakSet(), Ot = function() {
1007
+ var e;
1008
+ (e = this.srcElement) == null || e.dispatchEvent(new CustomEvent("input", { detail: this.value })), this.inputCallback && this.inputCallback(this.value);
1009
+ }, ht = new WeakSet(), Rs = function() {
1010
+ var e;
1011
+ (e = this.srcElement) == null || e.dispatchEvent(new CustomEvent("name-change", { detail: this.selectedName })), this.nameChangeCallback && this.nameChangeCallback(this.selectedName);
1012
+ }, dt = new WeakSet(), $s = function() {
1013
+ var e;
1014
+ this.alwaysOpen || ((e = this.srcElement) == null || e.dispatchEvent(new CustomEvent("open", { detail: this.value })), this.openCallback && this.openCallback(this.value));
1015
+ }, ut = new WeakSet(), Ws = function() {
1016
+ var e;
1017
+ this.alwaysOpen || ((e = this.srcElement) == null || e.dispatchEvent(new CustomEvent("close", { detail: this.value })), this.closeCallback && this.closeCallback(this.value));
1018
+ }, pt = new WeakSet(), Us = function(e) {
1019
+ var s;
1020
+ const t = (e == null ? void 0 : e.trim()) ?? "";
1021
+ (s = this.srcElement) == null || s.dispatchEvent(new CustomEvent("search", { detail: t })), this.searchCallback && this.searchCallback(t);
1022
+ }, mt = new WeakSet(), zs = function(e, t) {
1023
+ var s;
1024
+ (s = this.srcElement) == null || s.dispatchEvent(new CustomEvent("open-close-group", { detail: { groupId: e, isClosed: t } })), this.openCloseGroupCallback && this.openCloseGroupCallback(e, t);
1025
+ };
1026
+ export {
1027
+ Mi as default
1028
+ };