treeselectjs 0.8.4 → 0.8.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -4
- package/dist/treeselectjs.d.ts +19 -15
- package/dist/treeselectjs.mjs +181 -175
- package/dist/treeselectjs.umd.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -3,13 +3,14 @@
|
|
|
3
3
|
A multi-select js component with nested options.
|
|
4
4
|
|
|
5
5
|
- React wrapper - https://www.npmjs.com/package/react-treeselectjs
|
|
6
|
+
- Vue wrapper - https://www.npmjs.com/package/vue-treeselectjs
|
|
6
7
|
- Full key support (ArrowUp, ArrowDown, Space, ArrowLeft, ArrowRight, Enter)
|
|
7
8
|
- Screen sensitive direction
|
|
8
9
|
- Typescript support
|
|
9
10
|
|
|
10
11
|
Build data:
|
|
11
|
-
- treeselectjs.mjs 48.
|
|
12
|
-
- treeselectjs.umd.js 39.
|
|
12
|
+
- treeselectjs.mjs 48.92 kB │ gzip: 11.07 kB
|
|
13
|
+
- treeselectjs.umd.js 39.79 kB │ gzip: 10.17 kB
|
|
13
14
|
- treeselectjs.css 6.41 kB │ gzip: 1.27 kB
|
|
14
15
|
|
|
15
16
|
**Live Demo:** https://dipson88.github.io/treeselectjs/
|
|
@@ -29,8 +30,8 @@ import Treeselect from 'treeselectjs'
|
|
|
29
30
|
|
|
30
31
|
Import treeselectjs (UMD)
|
|
31
32
|
```
|
|
32
|
-
<script src="https://cdn.jsdelivr.net/npm/treeselectjs@0.8.
|
|
33
|
-
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/treeselectjs@0.8.
|
|
33
|
+
<script src="https://cdn.jsdelivr.net/npm/treeselectjs@0.8.6/dist/treeselectjs.umd.js"></script>
|
|
34
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/treeselectjs@0.8.6/dist/treeselectjs.css" />
|
|
34
35
|
...
|
|
35
36
|
<script>
|
|
36
37
|
...
|
package/dist/treeselectjs.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ export declare type IconsType = {
|
|
|
13
13
|
|
|
14
14
|
declare interface ITreeselect {
|
|
15
15
|
parentHtmlContainer: HTMLElement;
|
|
16
|
-
value:
|
|
16
|
+
value: ValueType;
|
|
17
17
|
options: OptionType[];
|
|
18
18
|
openLevel: number;
|
|
19
19
|
appendToBody: boolean;
|
|
@@ -42,12 +42,12 @@ declare interface ITreeselect {
|
|
|
42
42
|
isListOpened: boolean;
|
|
43
43
|
selectedName: string;
|
|
44
44
|
srcElement: HTMLElement | null;
|
|
45
|
-
inputCallback: ((value:
|
|
46
|
-
openCallback: ((value:
|
|
47
|
-
closeCallback: ((value:
|
|
45
|
+
inputCallback: ((value: ValueType) => void) | undefined;
|
|
46
|
+
openCallback: ((value: ValueType) => void) | undefined;
|
|
47
|
+
closeCallback: ((value: ValueType) => void) | undefined;
|
|
48
48
|
nameChangeCallback: ((name: string) => void) | undefined;
|
|
49
49
|
mount: () => void;
|
|
50
|
-
updateValue: (newValue:
|
|
50
|
+
updateValue: (newValue: ValueInputType) => void;
|
|
51
51
|
destroy: () => void;
|
|
52
52
|
focus: () => void;
|
|
53
53
|
toggleOpenClose: () => void;
|
|
@@ -55,7 +55,7 @@ declare interface ITreeselect {
|
|
|
55
55
|
|
|
56
56
|
export declare interface ITreeselectParams {
|
|
57
57
|
parentHtmlContainer: HTMLElement;
|
|
58
|
-
value?:
|
|
58
|
+
value?: ValueInputType;
|
|
59
59
|
options?: OptionType[];
|
|
60
60
|
openLevel?: number;
|
|
61
61
|
appendToBody?: boolean;
|
|
@@ -79,9 +79,9 @@ export declare interface ITreeselectParams {
|
|
|
79
79
|
expandSelected?: boolean;
|
|
80
80
|
saveScrollPosition?: boolean;
|
|
81
81
|
iconElements?: Partial<IconsType>;
|
|
82
|
-
inputCallback?: (value:
|
|
83
|
-
openCallback?: (value:
|
|
84
|
-
closeCallback?: (value:
|
|
82
|
+
inputCallback?: (value: ValueType) => void;
|
|
83
|
+
openCallback?: (value: ValueType) => void;
|
|
84
|
+
closeCallback?: (value: ValueType) => void;
|
|
85
85
|
nameChangeCallback?: (name: string) => void;
|
|
86
86
|
}
|
|
87
87
|
|
|
@@ -96,7 +96,7 @@ export declare type OptionType = {
|
|
|
96
96
|
declare class Treeselect implements ITreeselect {
|
|
97
97
|
#private;
|
|
98
98
|
parentHtmlContainer: HTMLElement;
|
|
99
|
-
value:
|
|
99
|
+
value: ValueType;
|
|
100
100
|
options: OptionType[];
|
|
101
101
|
openLevel: number;
|
|
102
102
|
appendToBody: boolean;
|
|
@@ -120,9 +120,9 @@ declare class Treeselect implements ITreeselect {
|
|
|
120
120
|
expandSelected: boolean;
|
|
121
121
|
saveScrollPosition: boolean;
|
|
122
122
|
iconElements: IconsType;
|
|
123
|
-
inputCallback: ((value:
|
|
124
|
-
openCallback: ((value:
|
|
125
|
-
closeCallback: ((value:
|
|
123
|
+
inputCallback: ((value: ValueType) => void) | undefined;
|
|
124
|
+
openCallback: ((value: ValueType) => void) | undefined;
|
|
125
|
+
closeCallback: ((value: ValueType) => void) | undefined;
|
|
126
126
|
nameChangeCallback: ((name: string) => void) | undefined;
|
|
127
127
|
ungroupedValue: ValueOptionType[];
|
|
128
128
|
groupedValue: ValueOptionType[];
|
|
@@ -131,7 +131,7 @@ declare class Treeselect implements ITreeselect {
|
|
|
131
131
|
srcElement: HTMLElement | null;
|
|
132
132
|
constructor({ parentHtmlContainer, value, options, openLevel, appendToBody, alwaysOpen, showTags, tagsCountText, clearable, searchable, placeholder, grouped, isGroupedValue, listSlotHtmlComponent, disabled, emptyText, staticList, id, isSingleSelect, showCount, disabledBranchNode, direction, expandSelected, saveScrollPosition, iconElements, inputCallback, openCallback, closeCallback, nameChangeCallback }: ITreeselectParams);
|
|
133
133
|
mount(): void;
|
|
134
|
-
updateValue(newValue:
|
|
134
|
+
updateValue(newValue: ValueInputType): void;
|
|
135
135
|
destroy(): void;
|
|
136
136
|
focus(): void;
|
|
137
137
|
toggleOpenClose(): void;
|
|
@@ -142,6 +142,10 @@ declare class Treeselect implements ITreeselect {
|
|
|
142
142
|
}
|
|
143
143
|
export default Treeselect;
|
|
144
144
|
|
|
145
|
-
export declare type
|
|
145
|
+
export declare type ValueInputType = ValueOptionType[] | ValueOptionType | null | undefined;
|
|
146
|
+
|
|
147
|
+
declare type ValueOptionType = string | number;
|
|
148
|
+
|
|
149
|
+
export declare type ValueType = ValueOptionType[] | ValueOptionType | null;
|
|
146
150
|
|
|
147
151
|
export { }
|
package/dist/treeselectjs.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var c = (l, e, t) => (
|
|
1
|
+
var Js = Object.defineProperty;
|
|
2
|
+
var Zs = (l, e, t) => e in l ? Js(l, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : l[e] = t;
|
|
3
|
+
var c = (l, e, t) => (Zs(l, typeof e != "symbol" ? e + "" : e, t), t), ft = (l, e, t) => {
|
|
4
4
|
if (!e.has(l))
|
|
5
5
|
throw TypeError("Cannot " + t);
|
|
6
6
|
};
|
|
@@ -26,14 +26,14 @@ const At = {
|
|
|
26
26
|
const t = l.cloneNode(!0);
|
|
27
27
|
e.appendChild(t);
|
|
28
28
|
}
|
|
29
|
-
},
|
|
29
|
+
}, Tt = (l) => {
|
|
30
30
|
const e = l ? { ...l } : {};
|
|
31
31
|
return Object.keys(At).forEach((t) => {
|
|
32
32
|
e[t] || (e[t] = At[t]);
|
|
33
33
|
}), e;
|
|
34
|
-
},
|
|
35
|
-
var A, E, I, v, he,
|
|
36
|
-
class
|
|
34
|
+
}, Qs = (l) => l.reduce((e, { name: t }, s) => (e += t, s < l.length - 1 && (e += ", "), e), "");
|
|
35
|
+
var A, E, I, v, he, Pt, H, U, ue, Bt, pe, Vt, G, z, T, D, me, Dt, fe, It, Ce, Ht, be, Gt, ge, Mt, we, Ft, ke, qt, Ee, jt, ve, $t, Le, Wt, ye, Rt, xe, Ut, Se, zt, _e, Yt, Ae, Kt, Te, Xt, Y, bt;
|
|
36
|
+
class ei {
|
|
37
37
|
constructor({
|
|
38
38
|
value: e,
|
|
39
39
|
showTags: t,
|
|
@@ -110,7 +110,7 @@ class Qs {
|
|
|
110
110
|
c(this, "focusCallback");
|
|
111
111
|
c(this, "blurCallback");
|
|
112
112
|
c(this, "nameChangeCallback");
|
|
113
|
-
this.value = e, this.showTags = t, this.tagsCountText = s, this.searchable = d, this.placeholder = u, this.clearable = i, this.isAlwaysOpened = o, this.disabled = f, this.isSingleSelect = C, this.id = b, this.iconElements = g, this.isOpened = !1, this.searchText = "", m(this, A, a(this, Ce,
|
|
113
|
+
this.value = e, this.showTags = t, this.tagsCountText = s, this.searchable = d, this.placeholder = u, this.clearable = i, this.isAlwaysOpened = o, this.disabled = f, this.isSingleSelect = C, this.id = b, this.iconElements = g, this.isOpened = !1, this.searchText = "", m(this, A, a(this, Ce, Ht).call(this)), m(this, E, a(this, ve, $t).call(this)), m(this, I, a(this, xe, Ut).call(this)), m(this, v, null), this.inputCallback = w, this.searchCallback = k, this.openCallback = O, this.closeCallback = P, this.keydownCallback = R, this.focusCallback = ne, this.blurCallback = mt, this.nameChangeCallback = oe, this.srcElement = a(this, me, Dt).call(this, n(this, A), n(this, E), n(this, I)), a(this, he, Pt).call(this);
|
|
114
114
|
}
|
|
115
115
|
// Public methods
|
|
116
116
|
focus() {
|
|
@@ -135,22 +135,22 @@ class Qs {
|
|
|
135
135
|
this.searchText = "", this.searchCallback(""), a(this, G, z).call(this);
|
|
136
136
|
}
|
|
137
137
|
}
|
|
138
|
-
A = new WeakMap(), E = new WeakMap(), I = new WeakMap(), v = new WeakMap(), he = new WeakSet(),
|
|
139
|
-
a(this, H, U).call(this), a(this, G, z).call(this), a(this, ue,
|
|
138
|
+
A = new WeakMap(), E = new WeakMap(), I = new WeakMap(), v = new WeakMap(), he = new WeakSet(), Pt = function() {
|
|
139
|
+
a(this, H, U).call(this), a(this, G, z).call(this), a(this, ue, Bt).call(this);
|
|
140
140
|
}, H = new WeakSet(), U = function() {
|
|
141
141
|
if (n(this, A).innerHTML = "", this.showTags) {
|
|
142
|
-
n(this, A).append(...a(this, be,
|
|
143
|
-
const e =
|
|
142
|
+
n(this, A).append(...a(this, be, Gt).call(this));
|
|
143
|
+
const e = Qs(this.value);
|
|
144
144
|
this.nameChangeCallback(e);
|
|
145
145
|
} else {
|
|
146
|
-
const e = a(this, Ee,
|
|
146
|
+
const e = a(this, Ee, jt).call(this);
|
|
147
147
|
n(this, A).appendChild(e), this.nameChangeCallback(e.innerText);
|
|
148
148
|
}
|
|
149
149
|
n(this, A).appendChild(n(this, E));
|
|
150
|
-
}, ue = new WeakSet(),
|
|
150
|
+
}, ue = new WeakSet(), Bt = function() {
|
|
151
151
|
const e = [];
|
|
152
|
-
n(this, I).innerHTML = "", this.clearable && e.push(a(this, Se,
|
|
153
|
-
}, pe = new WeakSet(),
|
|
152
|
+
n(this, I).innerHTML = "", this.clearable && e.push(a(this, Se, zt).call(this)), this.isAlwaysOpened || e.push(a(this, Ae, Kt).call(this, this.isOpened)), e.length && n(this, I).append(...e);
|
|
153
|
+
}, pe = new WeakSet(), Vt = function() {
|
|
154
154
|
if (!this.isAlwaysOpened && n(this, v)) {
|
|
155
155
|
const e = this.isOpened ? this.iconElements.arrowUp : this.iconElements.arrowDown;
|
|
156
156
|
N(e, n(this, v));
|
|
@@ -159,44 +159,44 @@ A = new WeakMap(), E = new WeakMap(), I = new WeakMap(), v = new WeakMap(), he =
|
|
|
159
159
|
var e;
|
|
160
160
|
(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;
|
|
161
161
|
}, T = new WeakSet(), D = function() {
|
|
162
|
-
this.isOpened = !this.isOpened, a(this, pe,
|
|
163
|
-
}, me = new WeakSet(),
|
|
162
|
+
this.isOpened = !this.isOpened, a(this, pe, Vt).call(this), this.isOpened ? this.openCallback() : this.closeCallback();
|
|
163
|
+
}, me = new WeakSet(), Dt = function(e, t, s) {
|
|
164
164
|
const i = document.createElement("div");
|
|
165
|
-
return i.classList.add("treeselect-input"), i.setAttribute("tabindex", "-1"), i.addEventListener("mousedown", (o) => a(this, fe,
|
|
166
|
-
}, fe = new WeakSet(),
|
|
165
|
+
return i.classList.add("treeselect-input"), i.setAttribute("tabindex", "-1"), i.addEventListener("mousedown", (o) => a(this, fe, It).call(this, o)), i.addEventListener("focus", () => this.focusCallback(), !0), i.addEventListener("blur", () => this.blurCallback(), !0), e.appendChild(t), i.append(e, s), i;
|
|
166
|
+
}, fe = new WeakSet(), It = function(e) {
|
|
167
167
|
e.stopPropagation(), this.isOpened || a(this, T, D).call(this), this.focus();
|
|
168
|
-
}, Ce = new WeakSet(),
|
|
168
|
+
}, Ce = new WeakSet(), Ht = function() {
|
|
169
169
|
const e = document.createElement("div");
|
|
170
170
|
return e.classList.add("treeselect-input__tags"), e;
|
|
171
|
-
}, be = new WeakSet(),
|
|
171
|
+
}, be = new WeakSet(), Gt = function() {
|
|
172
172
|
return this.value.map((e) => {
|
|
173
173
|
const t = document.createElement("div");
|
|
174
174
|
t.classList.add("treeselect-input__tags-element"), t.setAttribute("tabindex", "-1"), t.setAttribute("tag-id", e.id.toString()), t.setAttribute("title", e.name);
|
|
175
|
-
const s = a(this, we,
|
|
176
|
-
return t.addEventListener("mousedown", (o) => a(this, ge,
|
|
175
|
+
const s = a(this, we, Ft).call(this, e.name), i = a(this, ke, qt).call(this);
|
|
176
|
+
return t.addEventListener("mousedown", (o) => a(this, ge, Mt).call(this, o, e.id)), t.append(s, i), t;
|
|
177
177
|
});
|
|
178
|
-
}, ge = new WeakSet(),
|
|
178
|
+
}, ge = new WeakSet(), Mt = function(e, t) {
|
|
179
179
|
e.preventDefault(), e.stopPropagation(), this.removeItem(t), this.focus();
|
|
180
|
-
}, we = new WeakSet(),
|
|
180
|
+
}, we = new WeakSet(), Ft = function(e) {
|
|
181
181
|
const t = document.createElement("span");
|
|
182
182
|
return t.classList.add("treeselect-input__tags-name"), t.textContent = e, t;
|
|
183
|
-
}, ke = new WeakSet(),
|
|
183
|
+
}, ke = new WeakSet(), qt = function() {
|
|
184
184
|
const e = document.createElement("span");
|
|
185
185
|
return e.classList.add("treeselect-input__tags-cross"), N(this.iconElements.cross, e), e;
|
|
186
|
-
}, Ee = new WeakSet(),
|
|
186
|
+
}, Ee = new WeakSet(), jt = function() {
|
|
187
187
|
const e = document.createElement("span");
|
|
188
188
|
if (e.classList.add("treeselect-input__tags-count"), !this.value.length)
|
|
189
189
|
return e.textContent = "", e.setAttribute("title", ""), e;
|
|
190
190
|
const t = this.value.length === 1 ? this.value[0].name : `${this.value.length} ${this.tagsCountText}`;
|
|
191
191
|
return e.textContent = t, e.setAttribute("title", t), e;
|
|
192
|
-
}, ve = new WeakSet(),
|
|
192
|
+
}, ve = new WeakSet(), $t = function() {
|
|
193
193
|
const e = document.createElement("input");
|
|
194
|
-
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"), e.addEventListener("keydown", (t) => a(this, Le,
|
|
195
|
-
}, Le = new WeakSet(),
|
|
194
|
+
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"), e.addEventListener("keydown", (t) => a(this, Le, Wt).call(this, t)), e.addEventListener("input", (t) => a(this, ye, Rt).call(this, t, e)), e;
|
|
195
|
+
}, Le = new WeakSet(), Wt = function(e) {
|
|
196
196
|
e.stopPropagation();
|
|
197
197
|
const t = e.key;
|
|
198
198
|
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) && a(this, T, D).call(this), (t === "Enter" || t === "ArrowDown" || t === "ArrowUp") && e.preventDefault(), this.keydownCallback(e), t !== "Tab" && this.focus();
|
|
199
|
-
}, ye = new WeakSet(),
|
|
199
|
+
}, ye = new WeakSet(), Rt = function(e, t) {
|
|
200
200
|
e.stopPropagation();
|
|
201
201
|
const s = this.searchText, i = t.value.trim();
|
|
202
202
|
if (s.length === 0 && i.length === 0) {
|
|
@@ -209,25 +209,25 @@ A = new WeakMap(), E = new WeakMap(), I = new WeakMap(), v = new WeakMap(), he =
|
|
|
209
209
|
} else
|
|
210
210
|
t.value = "";
|
|
211
211
|
this.searchText = t.value;
|
|
212
|
-
}, xe = new WeakSet(),
|
|
212
|
+
}, xe = new WeakSet(), Ut = function() {
|
|
213
213
|
const e = document.createElement("div");
|
|
214
214
|
return e.classList.add("treeselect-input__operators"), e;
|
|
215
|
-
}, Se = new WeakSet(),
|
|
215
|
+
}, Se = new WeakSet(), zt = function() {
|
|
216
216
|
const e = document.createElement("span");
|
|
217
|
-
return e.classList.add("treeselect-input__clear"), e.setAttribute("tabindex", "-1"), N(this.iconElements.clear, e), e.addEventListener("mousedown", (t) => a(this, _e,
|
|
218
|
-
}, _e = new WeakSet(),
|
|
217
|
+
return e.classList.add("treeselect-input__clear"), e.setAttribute("tabindex", "-1"), N(this.iconElements.clear, e), e.addEventListener("mousedown", (t) => a(this, _e, Yt).call(this, t)), e;
|
|
218
|
+
}, _e = new WeakSet(), Yt = function(e) {
|
|
219
219
|
e.preventDefault(), e.stopPropagation(), (this.searchText.length || this.value.length) && this.clear(), this.focus();
|
|
220
|
-
}, Ae = new WeakSet(),
|
|
220
|
+
}, Ae = new WeakSet(), Kt = function(e) {
|
|
221
221
|
m(this, v, document.createElement("span")), n(this, v).classList.add("treeselect-input__arrow");
|
|
222
222
|
const t = e ? this.iconElements.arrowUp : this.iconElements.arrowDown;
|
|
223
|
-
return N(t, n(this, v)), n(this, v).addEventListener("mousedown", (s) => a(this, Te,
|
|
224
|
-
}, Te = new WeakSet(),
|
|
223
|
+
return N(t, n(this, v)), n(this, v).addEventListener("mousedown", (s) => a(this, Te, Xt).call(this, s)), n(this, v);
|
|
224
|
+
}, Te = new WeakSet(), Xt = function(e) {
|
|
225
225
|
e.stopPropagation(), e.preventDefault(), this.focus(), a(this, T, D).call(this);
|
|
226
226
|
}, Y = new WeakSet(), bt = function() {
|
|
227
227
|
this.inputCallback(this.value);
|
|
228
228
|
};
|
|
229
|
-
const
|
|
230
|
-
|
|
229
|
+
const Jt = (l, e, t) => {
|
|
230
|
+
li(e);
|
|
231
231
|
const s = e.filter((i) => !i.disabled && l.some((o) => o === i.id));
|
|
232
232
|
if (t && s.length) {
|
|
233
233
|
s[0].checked = !0;
|
|
@@ -242,29 +242,29 @@ const Kt = (l, e, t) => {
|
|
|
242
242
|
const s = t.find((o) => o.id === l);
|
|
243
243
|
if (!s)
|
|
244
244
|
return !1;
|
|
245
|
-
const i =
|
|
246
|
-
return
|
|
247
|
-
},
|
|
245
|
+
const i = Zt(!!e, s, t);
|
|
246
|
+
return Qt(s, t), i;
|
|
247
|
+
}, Zt = (l, e, t) => {
|
|
248
248
|
if (!e.isGroup)
|
|
249
249
|
return e.checked = e.disabled ? !1 : !!l, e.isPartialChecked = !1, e.checked;
|
|
250
250
|
const s = t.filter((u) => u.childOf === e.id);
|
|
251
|
-
return !l || e.disabled || e.isPartialChecked ? (e.checked = !1, e.isPartialChecked = !1, gt(e, s, t), e.checked) :
|
|
252
|
-
|
|
251
|
+
return !l || e.disabled || e.isPartialChecked ? (e.checked = !1, e.isPartialChecked = !1, gt(e, s, t), e.checked) : es(s, t) ? ts(s) ? (e.checked = !1, e.isPartialChecked = !1, e.disabled = !0, e.checked) : (e.checked = !1, e.isPartialChecked = !0, s.forEach((u) => {
|
|
252
|
+
Zt(l, u, t);
|
|
253
253
|
}), e.checked) : (e.checked = !0, e.isPartialChecked = !1, gt(e, s, t), e.checked);
|
|
254
|
-
},
|
|
254
|
+
}, Qt = (l, e) => {
|
|
255
255
|
const t = e.find((s) => s.id === l.childOf);
|
|
256
|
-
t && (
|
|
257
|
-
},
|
|
256
|
+
t && (ti(t, e), Qt(t, e));
|
|
257
|
+
}, ti = (l, e) => {
|
|
258
258
|
const t = ut(l, e);
|
|
259
|
-
if (
|
|
259
|
+
if (ts(t)) {
|
|
260
260
|
l.checked = !1, l.isPartialChecked = !1, l.disabled = !0;
|
|
261
261
|
return;
|
|
262
262
|
}
|
|
263
|
-
if (
|
|
263
|
+
if (si(t)) {
|
|
264
264
|
l.checked = !0, l.isPartialChecked = !1;
|
|
265
265
|
return;
|
|
266
266
|
}
|
|
267
|
-
if (
|
|
267
|
+
if (ii(t)) {
|
|
268
268
|
l.checked = !1, l.isPartialChecked = !0;
|
|
269
269
|
return;
|
|
270
270
|
}
|
|
@@ -275,20 +275,20 @@ const Kt = (l, e, t) => {
|
|
|
275
275
|
const o = ut(i, s);
|
|
276
276
|
gt({ checked: l, disabled: e }, o, s);
|
|
277
277
|
});
|
|
278
|
-
},
|
|
278
|
+
}, es = (l, e) => l.some((i) => i.disabled) ? !0 : l.some((i) => {
|
|
279
279
|
if (i.isGroup) {
|
|
280
280
|
const o = ut(i, e);
|
|
281
|
-
return
|
|
281
|
+
return es(o, e);
|
|
282
282
|
}
|
|
283
283
|
return !1;
|
|
284
|
-
}),
|
|
284
|
+
}), ts = (l) => l.every((e) => !!e.disabled), si = (l) => l.every((e) => !!e.checked), ii = (l) => l.some((e) => !!e.checked || !!e.isPartialChecked), li = (l) => {
|
|
285
285
|
l.forEach((e) => {
|
|
286
286
|
e.checked = !1, e.isPartialChecked = !1;
|
|
287
287
|
});
|
|
288
|
-
},
|
|
289
|
-
const i =
|
|
290
|
-
return
|
|
291
|
-
},
|
|
288
|
+
}, ni = (l, e, t = "", s = 0) => {
|
|
289
|
+
const i = ss(l, e, t, s);
|
|
290
|
+
return ai(i);
|
|
291
|
+
}, ss = (l, e, t, s) => l.reduce((i, o) => {
|
|
292
292
|
var C;
|
|
293
293
|
const d = !!((C = o.children) != null && C.length), u = s >= e && d, f = s > e;
|
|
294
294
|
if (i.push({
|
|
@@ -303,11 +303,11 @@ const Kt = (l, e, t) => {
|
|
|
303
303
|
hidden: f,
|
|
304
304
|
disabled: o.disabled ?? !1
|
|
305
305
|
}), d) {
|
|
306
|
-
const b =
|
|
306
|
+
const b = ss(o.children, e, o.value, s + 1);
|
|
307
307
|
i.push(...b);
|
|
308
308
|
}
|
|
309
309
|
return i;
|
|
310
|
-
}, []), ut = ({ id: l }, e) => e.filter((t) => t.childOf === l),
|
|
310
|
+
}, []), ut = ({ id: l }, e) => e.filter((t) => t.childOf === l), oi = (l) => {
|
|
311
311
|
const { ungroupedNodes: e, allGroupedNodes: t, allNodes: s } = l.reduce(
|
|
312
312
|
(o, d) => (d.checked && (o.allNodes.push(d), d.isGroup ? o.allGroupedNodes.push(d) : o.ungroupedNodes.push(d)), o),
|
|
313
313
|
{
|
|
@@ -317,32 +317,32 @@ const Kt = (l, e, t) => {
|
|
|
317
317
|
}
|
|
318
318
|
), i = s.filter((o) => !t.some(({ id: d }) => d === o.childOf));
|
|
319
319
|
return { ungroupedNodes: e, groupedNodes: i, allNodes: s };
|
|
320
|
-
},
|
|
320
|
+
}, ai = (l) => (l.filter((t) => !!t.disabled).forEach(({ id: t }) => _t({ id: t, checked: !1 }, l)), l), pt = (l, { id: e, isClosed: t }) => {
|
|
321
321
|
ut({ id: e }, l).forEach((i) => {
|
|
322
322
|
i.hidden = t ?? !1, i.isGroup && !i.isClosed && pt(l, { id: i.id, isClosed: t });
|
|
323
323
|
});
|
|
324
|
-
},
|
|
324
|
+
}, ri = (l) => {
|
|
325
325
|
l.filter((e) => e.isGroup && !e.disabled && (e.checked || e.isPartialChecked)).forEach((e) => {
|
|
326
326
|
e.isClosed = !1, pt(l, e);
|
|
327
327
|
});
|
|
328
|
-
},
|
|
329
|
-
const t =
|
|
328
|
+
}, ci = (l, e) => {
|
|
329
|
+
const t = di(l, e);
|
|
330
330
|
l.forEach((s) => {
|
|
331
331
|
t.some(({ id: o }) => o === s.id) ? (s.isGroup && (s.isClosed = !1, pt(l, s)), s.hidden = !1) : s.hidden = !0;
|
|
332
332
|
});
|
|
333
|
-
},
|
|
333
|
+
}, di = (l, e) => l.reduce((t, s) => {
|
|
334
334
|
if (s.name.toLowerCase().includes(e.toLowerCase())) {
|
|
335
335
|
if (t.push(s), s.isGroup) {
|
|
336
|
-
const o =
|
|
336
|
+
const o = is(s.id, l);
|
|
337
337
|
t.push(...o);
|
|
338
338
|
}
|
|
339
339
|
if (s.childOf) {
|
|
340
|
-
const o =
|
|
340
|
+
const o = ls(s.childOf, l);
|
|
341
341
|
t.push(...o);
|
|
342
342
|
}
|
|
343
343
|
}
|
|
344
344
|
return t;
|
|
345
|
-
}, []),
|
|
345
|
+
}, []), is = (l, e) => e.reduce((t, s) => (s.childOf === l && (t.push(s), s.isGroup && t.push(...is(s.id, e))), t), []), ls = (l, e) => e.reduce((t, s) => (s.id === l && (t.push(s), s.childOf && t.push(...ls(s.childOf, e))), t), []), hi = (l) => {
|
|
346
346
|
const { duplications: e } = l.reduce(
|
|
347
347
|
(t, s) => (t.allItems.some((i) => i.toString() === s.id.toString()) && t.duplications.push(s.id), t.allItems.push(s.id), t),
|
|
348
348
|
{
|
|
@@ -351,30 +351,30 @@ const Kt = (l, e, t) => {
|
|
|
351
351
|
}
|
|
352
352
|
);
|
|
353
353
|
e.length && console.error(`Validation: You have duplicated values: ${e.join(", ")}! You should use unique values.`);
|
|
354
|
-
},
|
|
355
|
-
|
|
354
|
+
}, ui = (l, e, t, s, i, o, d, u) => {
|
|
355
|
+
Jt(l, e, i), u && d && ri(e), ae(e, t, s, o);
|
|
356
356
|
}, ae = (l, e, t, s) => {
|
|
357
357
|
l.forEach((i) => {
|
|
358
358
|
const o = e.querySelector(`[input-id="${i.id}"]`), d = _(o);
|
|
359
|
-
o.checked = i.checked,
|
|
360
|
-
}),
|
|
361
|
-
},
|
|
359
|
+
o.checked = i.checked, pi(i, d, s), mi(i, d), fi(i, d), Ci(i, d, t), bi(i, d), wi(i, d, l), gi(i, o, t);
|
|
360
|
+
}), ki(l, e);
|
|
361
|
+
}, pi = (l, e, t) => {
|
|
362
362
|
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");
|
|
363
|
-
}, pi = (l, e) => {
|
|
364
|
-
l.isPartialChecked ? e.classList.add("treeselect-list__item--partial-checked") : e.classList.remove("treeselect-list__item--partial-checked");
|
|
365
363
|
}, mi = (l, e) => {
|
|
364
|
+
l.isPartialChecked ? e.classList.add("treeselect-list__item--partial-checked") : e.classList.remove("treeselect-list__item--partial-checked");
|
|
365
|
+
}, fi = (l, e) => {
|
|
366
366
|
l.disabled ? e.classList.add("treeselect-list__item--disabled") : e.classList.remove("treeselect-list__item--disabled");
|
|
367
|
-
},
|
|
367
|
+
}, Ci = (l, e, t) => {
|
|
368
368
|
if (l.isGroup) {
|
|
369
369
|
const s = e.querySelector(".treeselect-list__item-icon"), i = l.isClosed ? t.arrowRight : t.arrowDown;
|
|
370
370
|
N(i, s), l.isClosed ? e.classList.add("treeselect-list__item--closed") : e.classList.remove("treeselect-list__item--closed");
|
|
371
371
|
}
|
|
372
|
-
},
|
|
372
|
+
}, bi = (l, e) => {
|
|
373
373
|
l.hidden ? e.classList.add("treeselect-list__item--hidden") : e.classList.remove("treeselect-list__item--hidden");
|
|
374
|
-
},
|
|
374
|
+
}, gi = (l, e, t) => {
|
|
375
375
|
const i = e.parentNode.querySelector(".treeselect-list__item-checkbox-icon");
|
|
376
376
|
l.checked ? N(t.check, i) : l.isPartialChecked ? N(t.partialCheck, i) : i.innerHTML = "";
|
|
377
|
-
},
|
|
377
|
+
}, wi = (l, e, t) => {
|
|
378
378
|
const s = l.level === 0, i = 20, o = 5;
|
|
379
379
|
if (s) {
|
|
380
380
|
const d = t.some((f) => f.isGroup && f.level === l.level), u = !l.isGroup && d ? `${i}px` : `${o}px`;
|
|
@@ -382,17 +382,17 @@ const Kt = (l, e, t) => {
|
|
|
382
382
|
} else
|
|
383
383
|
e.style.paddingLeft = l.isGroup ? `${l.level * i}px` : `${l.level * i + i}px`;
|
|
384
384
|
e.setAttribute("level", l.level.toString()), e.setAttribute("group", l.isGroup.toString());
|
|
385
|
-
},
|
|
385
|
+
}, ki = (l, e) => {
|
|
386
386
|
const t = l.some((i) => !i.hidden), s = e.querySelector(".treeselect-list__empty");
|
|
387
387
|
t ? s.classList.add("treeselect-list__empty--hidden") : s.classList.remove("treeselect-list__empty--hidden");
|
|
388
|
-
}, _ = (l) => l.parentNode.parentNode,
|
|
388
|
+
}, _ = (l) => l.parentNode.parentNode, Nt = (l, e) => e.find((t) => t.id.toString() === l), Ei = (l) => _(l).querySelector(".treeselect-list__item-icon"), vi = (l, e) => {
|
|
389
389
|
e && Object.keys(e).forEach((t) => {
|
|
390
390
|
const s = e[t];
|
|
391
391
|
typeof s == "string" && l.setAttribute(t, s);
|
|
392
392
|
});
|
|
393
393
|
};
|
|
394
|
-
var M, B, y, K, Ne,
|
|
395
|
-
class
|
|
394
|
+
var M, B, y, K, Ne, ns, Oe, os, Pe, as, Be, rs, Ve, cs, De, ds, X, wt, Ie, hs, He, us, Ge, ps, J, kt, Me, ms, Fe, fs, qe, Cs, je, bs, $e, gs, We, ws, Re, ks, Ue, Es, ze, vs, Ye, Ls, Ke, ys, Z, Et, Q, vt, Xe, xs;
|
|
395
|
+
class Li {
|
|
396
396
|
constructor({
|
|
397
397
|
options: e,
|
|
398
398
|
value: t,
|
|
@@ -462,11 +462,11 @@ class vi {
|
|
|
462
462
|
r(this, B, !0);
|
|
463
463
|
r(this, y, []);
|
|
464
464
|
r(this, K, !0);
|
|
465
|
-
this.options = e, this.value = t, this.openLevel = s ?? 0, this.listSlotHtmlComponent = i ?? null, this.emptyText = o ?? "No results found...", this.isSingleSelect = d ?? !1, this.showCount = f ?? !1, this.disabledBranchNode = C ?? !1, this.expandSelected = b ?? !1, this.iconElements = u, this.searchText = "", this.flattedOptions =
|
|
465
|
+
this.options = e, this.value = t, this.openLevel = s ?? 0, this.listSlotHtmlComponent = i ?? null, this.emptyText = o ?? "No results found...", this.isSingleSelect = d ?? !1, this.showCount = f ?? !1, this.disabledBranchNode = C ?? !1, this.expandSelected = b ?? !1, this.iconElements = u, this.searchText = "", this.flattedOptions = ni(this.options, this.openLevel), this.flattedOptionsBeforeSearch = this.flattedOptions, this.selectedNodes = { nodes: [], groupedNodes: [] }, this.srcElement = a(this, Pe, as).call(this), this.inputCallback = g, this.arrowClickCallback = w, this.mouseupCallback = k, hi(this.flattedOptions);
|
|
466
466
|
}
|
|
467
467
|
// Public methods
|
|
468
468
|
updateValue(e) {
|
|
469
|
-
this.value = e, m(this, y, this.isSingleSelect ? this.value : []),
|
|
469
|
+
this.value = e, m(this, y, this.isSingleSelect ? this.value : []), ui(
|
|
470
470
|
e,
|
|
471
471
|
this.flattedOptions,
|
|
472
472
|
this.srcElement,
|
|
@@ -484,7 +484,7 @@ class vi {
|
|
|
484
484
|
this.searchText = e, t && (this.flattedOptionsBeforeSearch = JSON.parse(JSON.stringify(this.flattedOptions))), this.searchText === "" && (this.flattedOptions = this.flattedOptionsBeforeSearch.map((s) => {
|
|
485
485
|
const i = this.flattedOptions.find((o) => o.id === s.id);
|
|
486
486
|
return i.isClosed = s.isClosed, i.hidden = s.hidden, i;
|
|
487
|
-
}), this.flattedOptionsBeforeSearch = []), this.searchText &&
|
|
487
|
+
}), this.flattedOptionsBeforeSearch = []), this.searchText && ci(this.flattedOptions, e), ae(this.flattedOptions, this.srcElement, this.iconElements, n(this, y)), this.focusFirstListElement();
|
|
488
488
|
}
|
|
489
489
|
callKeyAction(e) {
|
|
490
490
|
m(this, B, !1);
|
|
@@ -492,7 +492,7 @@ class vi {
|
|
|
492
492
|
if (t == null ? void 0 : t.classList.contains("treeselect-list__item--hidden"))
|
|
493
493
|
return;
|
|
494
494
|
const i = e.key;
|
|
495
|
-
i === "Enter" && t && t.dispatchEvent(new Event("mousedown")), (i === "ArrowLeft" || i === "ArrowRight") && a(this, Ne,
|
|
495
|
+
i === "Enter" && t && t.dispatchEvent(new Event("mousedown")), (i === "ArrowLeft" || i === "ArrowRight") && a(this, Ne, ns).call(this, t, e), (i === "ArrowDown" || i === "ArrowUp") && a(this, Oe, os).call(this, t, i);
|
|
496
496
|
}
|
|
497
497
|
focusFirstListElement() {
|
|
498
498
|
const e = "treeselect-list__item--focused", t = this.srcElement.querySelector(`.${e}`), s = Array.from(this.srcElement.querySelectorAll(".treeselect-list__item-checkbox")).filter(
|
|
@@ -506,12 +506,12 @@ class vi {
|
|
|
506
506
|
return !!n(this, M);
|
|
507
507
|
}
|
|
508
508
|
}
|
|
509
|
-
M = new WeakMap(), B = new WeakMap(), y = new WeakMap(), K = new WeakMap(), Ne = new WeakSet(),
|
|
509
|
+
M = new WeakMap(), B = new WeakMap(), y = new WeakMap(), K = new WeakMap(), Ne = new WeakSet(), ns = function(e, t) {
|
|
510
510
|
if (!e)
|
|
511
511
|
return;
|
|
512
|
-
const s = t.key, o = e.querySelector(".treeselect-list__item-checkbox").getAttribute("input-id"), d =
|
|
512
|
+
const s = t.key, o = e.querySelector(".treeselect-list__item-checkbox").getAttribute("input-id"), d = Nt(o, this.flattedOptions), u = e.querySelector(".treeselect-list__item-icon");
|
|
513
513
|
s === "ArrowLeft" && !d.isClosed && d.isGroup && (u.dispatchEvent(new Event("mousedown")), t.preventDefault()), s === "ArrowRight" && d.isClosed && d.isGroup && (u.dispatchEvent(new Event("mousedown")), t.preventDefault());
|
|
514
|
-
}, Oe = new WeakSet(),
|
|
514
|
+
}, Oe = new WeakSet(), os = function(e, t) {
|
|
515
515
|
var i;
|
|
516
516
|
const s = Array.from(this.srcElement.querySelectorAll(".treeselect-list__item-checkbox")).filter(
|
|
517
517
|
(o) => window.getComputedStyle(_(o)).display !== "none"
|
|
@@ -545,95 +545,95 @@ M = new WeakMap(), B = new WeakMap(), y = new WeakMap(), K = new WeakMap(), Ne =
|
|
|
545
545
|
return;
|
|
546
546
|
}
|
|
547
547
|
}
|
|
548
|
-
}, Pe = new WeakSet(),
|
|
549
|
-
const e = a(this, Be,
|
|
548
|
+
}, Pe = new WeakSet(), as = function() {
|
|
549
|
+
const e = a(this, Be, rs).call(this), t = a(this, X, wt).call(this, this.options);
|
|
550
550
|
e.append(...t);
|
|
551
|
-
const s = a(this, He,
|
|
551
|
+
const s = a(this, He, us).call(this);
|
|
552
552
|
e.append(s);
|
|
553
|
-
const i = a(this, Ie,
|
|
553
|
+
const i = a(this, Ie, hs).call(this);
|
|
554
554
|
return i && e.append(i), e;
|
|
555
|
-
}, Be = new WeakSet(),
|
|
555
|
+
}, Be = new WeakSet(), rs = function() {
|
|
556
556
|
const e = document.createElement("div");
|
|
557
|
-
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) => a(this, Ve,
|
|
558
|
-
}, Ve = new WeakSet(),
|
|
557
|
+
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) => a(this, Ve, cs).call(this, t)), e.addEventListener("mousemove", () => a(this, De, ds).call(this)), e.addEventListener("mouseup", () => this.mouseupCallback(), !0), e;
|
|
558
|
+
}, Ve = new WeakSet(), cs = function(e) {
|
|
559
559
|
e.stopPropagation(), n(this, M) && n(this, B) && n(this, M).classList.add("treeselect-list__item--focused");
|
|
560
|
-
}, De = new WeakSet(),
|
|
560
|
+
}, De = new WeakSet(), ds = function() {
|
|
561
561
|
m(this, B, !0);
|
|
562
562
|
}, X = new WeakSet(), wt = function(e) {
|
|
563
563
|
return e.reduce((t, s) => {
|
|
564
564
|
var o;
|
|
565
565
|
if ((o = s.children) != null && o.length) {
|
|
566
|
-
const d = a(this, Ge,
|
|
566
|
+
const d = a(this, Ge, ps).call(this, s), u = a(this, X, wt).call(this, s.children);
|
|
567
567
|
return d.append(...u), t.push(d), t;
|
|
568
568
|
}
|
|
569
569
|
const i = a(this, J, kt).call(this, s, !1);
|
|
570
570
|
return t.push(i), t;
|
|
571
571
|
}, []);
|
|
572
|
-
}, Ie = new WeakSet(),
|
|
572
|
+
}, Ie = new WeakSet(), hs = function() {
|
|
573
573
|
if (!this.listSlotHtmlComponent)
|
|
574
574
|
return null;
|
|
575
575
|
const e = document.createElement("div");
|
|
576
576
|
return e.classList.add("treeselect-list__slot"), e.appendChild(this.listSlotHtmlComponent), e;
|
|
577
|
-
}, He = new WeakSet(),
|
|
577
|
+
}, He = new WeakSet(), us = function() {
|
|
578
578
|
const e = document.createElement("div");
|
|
579
579
|
e.classList.add("treeselect-list__empty"), e.setAttribute("title", this.emptyText);
|
|
580
580
|
const t = document.createElement("span");
|
|
581
581
|
t.classList.add("treeselect-list__empty-icon"), N(this.iconElements.attention, t);
|
|
582
582
|
const s = document.createElement("span");
|
|
583
583
|
return s.classList.add("treeselect-list__empty-text"), s.textContent = this.emptyText, e.append(t, s), e;
|
|
584
|
-
}, Ge = new WeakSet(),
|
|
584
|
+
}, Ge = new WeakSet(), ps = function(e) {
|
|
585
585
|
const t = document.createElement("div");
|
|
586
586
|
t.setAttribute("group-container-id", e.value.toString()), t.classList.add("treeselect-list__group-container");
|
|
587
587
|
const s = a(this, J, kt).call(this, e, !0);
|
|
588
588
|
return t.appendChild(s), t;
|
|
589
589
|
}, J = new WeakSet(), kt = function(e, t) {
|
|
590
|
-
const s = a(this, Me,
|
|
590
|
+
const s = a(this, Me, ms).call(this, e);
|
|
591
591
|
if (t) {
|
|
592
|
-
const d = a(this, $e,
|
|
592
|
+
const d = a(this, $e, gs).call(this);
|
|
593
593
|
s.appendChild(d), s.classList.add("treeselect-list__item--group");
|
|
594
594
|
}
|
|
595
|
-
const i = a(this, Re,
|
|
595
|
+
const i = a(this, Re, ks).call(this, e), o = a(this, Ue, Es).call(this, e, t);
|
|
596
596
|
return s.append(i, o), s;
|
|
597
|
-
}, Me = new WeakSet(),
|
|
597
|
+
}, Me = new WeakSet(), ms = function(e) {
|
|
598
598
|
const t = document.createElement("div");
|
|
599
|
-
return
|
|
600
|
-
}, Fe = new WeakSet(),
|
|
599
|
+
return vi(t, e.htmlAttr), t.setAttribute("tabindex", "-1"), t.setAttribute("title", e.name), t.classList.add("treeselect-list__item"), t.addEventListener("mouseover", () => a(this, Fe, fs).call(this, t), !0), t.addEventListener("mouseout", () => a(this, qe, Cs).call(this, t), !0), t.addEventListener("mousedown", (s) => a(this, je, bs).call(this, s, e)), t;
|
|
600
|
+
}, Fe = new WeakSet(), fs = function(e) {
|
|
601
601
|
n(this, B) && a(this, Z, Et).call(this, !0, e);
|
|
602
|
-
}, qe = new WeakSet(),
|
|
602
|
+
}, qe = new WeakSet(), Cs = function(e) {
|
|
603
603
|
n(this, B) && (a(this, Z, Et).call(this, !1, e), m(this, M, e));
|
|
604
|
-
}, je = new WeakSet(),
|
|
604
|
+
}, je = new WeakSet(), bs = function(e, t) {
|
|
605
605
|
var o;
|
|
606
606
|
if (e.preventDefault(), e.stopPropagation(), (o = this.flattedOptions.find((d) => d.id === t.value)) == null ? void 0 : o.disabled)
|
|
607
607
|
return;
|
|
608
608
|
const i = e.target.querySelector(".treeselect-list__item-checkbox");
|
|
609
|
-
i.checked = !i.checked, a(this, Ye,
|
|
610
|
-
}, $e = new WeakSet(),
|
|
609
|
+
i.checked = !i.checked, a(this, Ye, Ls).call(this, i, t);
|
|
610
|
+
}, $e = new WeakSet(), gs = function() {
|
|
611
611
|
const e = document.createElement("span");
|
|
612
|
-
return e.setAttribute("tabindex", "-1"), e.classList.add("treeselect-list__item-icon"), N(this.iconElements.arrowDown, e), e.addEventListener("mousedown", (t) => a(this, We,
|
|
613
|
-
}, We = new WeakSet(),
|
|
614
|
-
e.preventDefault(), e.stopPropagation(), a(this, Ke,
|
|
615
|
-
}, Re = new WeakSet(),
|
|
612
|
+
return e.setAttribute("tabindex", "-1"), e.classList.add("treeselect-list__item-icon"), N(this.iconElements.arrowDown, e), e.addEventListener("mousedown", (t) => a(this, We, ws).call(this, t)), e;
|
|
613
|
+
}, We = new WeakSet(), ws = function(e) {
|
|
614
|
+
e.preventDefault(), e.stopPropagation(), a(this, Ke, ys).call(this, e);
|
|
615
|
+
}, Re = new WeakSet(), ks = function(e) {
|
|
616
616
|
const t = document.createElement("div");
|
|
617
617
|
t.classList.add("treeselect-list__item-checkbox-container");
|
|
618
618
|
const s = document.createElement("span");
|
|
619
619
|
s.classList.add("treeselect-list__item-checkbox-icon"), s.innerHTML = "";
|
|
620
620
|
const i = document.createElement("input");
|
|
621
621
|
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;
|
|
622
|
-
}, Ue = new WeakSet(),
|
|
622
|
+
}, Ue = new WeakSet(), Es = function(e, t) {
|
|
623
623
|
const s = document.createElement("label");
|
|
624
624
|
if (s.textContent = e.name, s.classList.add("treeselect-list__item-label"), t && this.showCount) {
|
|
625
|
-
const i = a(this, ze,
|
|
625
|
+
const i = a(this, ze, vs).call(this, e);
|
|
626
626
|
s.appendChild(i);
|
|
627
627
|
}
|
|
628
628
|
return s;
|
|
629
|
-
}, ze = new WeakSet(),
|
|
629
|
+
}, ze = new WeakSet(), vs = function(e) {
|
|
630
630
|
const t = document.createElement("span"), s = this.flattedOptions.filter((i) => i.childOf === e.value);
|
|
631
631
|
return t.textContent = `(${s.length})`, t.classList.add("treeselect-list__item-label-counter"), t;
|
|
632
|
-
}, Ye = new WeakSet(),
|
|
632
|
+
}, Ye = new WeakSet(), Ls = function(e, t) {
|
|
633
633
|
const s = this.flattedOptions.find((i) => i.id === t.value);
|
|
634
634
|
if (s) {
|
|
635
635
|
if (s != null && s.isGroup && this.disabledBranchNode) {
|
|
636
|
-
const i =
|
|
636
|
+
const i = Ei(e);
|
|
637
637
|
i == null || i.dispatchEvent(new Event("mousedown"));
|
|
638
638
|
return;
|
|
639
639
|
}
|
|
@@ -641,17 +641,17 @@ M = new WeakMap(), B = new WeakMap(), y = new WeakMap(), K = new WeakMap(), Ne =
|
|
|
641
641
|
const [i] = n(this, y);
|
|
642
642
|
if (s.id === i)
|
|
643
643
|
return;
|
|
644
|
-
m(this, y, [s.id]),
|
|
644
|
+
m(this, y, [s.id]), Jt([s.id], this.flattedOptions, this.isSingleSelect);
|
|
645
645
|
} else {
|
|
646
646
|
s.checked = e.checked;
|
|
647
647
|
const i = _t(s, this.flattedOptions);
|
|
648
648
|
e.checked = i;
|
|
649
649
|
}
|
|
650
|
-
ae(this.flattedOptions, this.srcElement, this.iconElements, n(this, y)), a(this, Xe,
|
|
650
|
+
ae(this.flattedOptions, this.srcElement, this.iconElements, n(this, y)), a(this, Xe, xs).call(this);
|
|
651
651
|
}
|
|
652
|
-
}, Ke = new WeakSet(),
|
|
652
|
+
}, Ke = new WeakSet(), ys = function(e) {
|
|
653
653
|
var o, d;
|
|
654
|
-
const t = (d = (o = e.target) == null ? void 0 : o.parentNode) == null ? void 0 : d.querySelector("[input-id]"), s = (t == null ? void 0 : t.getAttribute("input-id")) ?? null, i =
|
|
654
|
+
const t = (d = (o = e.target) == null ? void 0 : o.parentNode) == null ? void 0 : d.querySelector("[input-id]"), s = (t == null ? void 0 : t.getAttribute("input-id")) ?? null, i = Nt(s, this.flattedOptions);
|
|
655
655
|
i && (i.isClosed = !i.isClosed, pt(this.flattedOptions, i), ae(this.flattedOptions, this.srcElement, this.iconElements, n(this, y)), this.arrowClickCallback());
|
|
656
656
|
}, Z = new WeakSet(), Et = function(e, t) {
|
|
657
657
|
const s = "treeselect-list__item--focused";
|
|
@@ -661,12 +661,12 @@ M = new WeakMap(), B = new WeakMap(), y = new WeakMap(), K = new WeakMap(), Ne =
|
|
|
661
661
|
} else
|
|
662
662
|
t.classList.remove(s);
|
|
663
663
|
}, Q = new WeakSet(), vt = function() {
|
|
664
|
-
const { ungroupedNodes: e, groupedNodes: t } =
|
|
664
|
+
const { ungroupedNodes: e, groupedNodes: t } = oi(this.flattedOptions);
|
|
665
665
|
this.selectedNodes = { nodes: e, groupedNodes: t };
|
|
666
|
-
}, Xe = new WeakSet(),
|
|
666
|
+
}, Xe = new WeakSet(), xs = function() {
|
|
667
667
|
a(this, Q, vt).call(this), this.inputCallback(this.selectedNodes), this.value = this.selectedNodes.nodes.map((e) => e.id);
|
|
668
668
|
};
|
|
669
|
-
const
|
|
669
|
+
const Ot = ({
|
|
670
670
|
parentHtmlContainer: l,
|
|
671
671
|
staticList: e,
|
|
672
672
|
appendToBody: t,
|
|
@@ -678,11 +678,11 @@ const Li = ({
|
|
|
678
678
|
}, Ct = (l) => l.map((e) => e.id), yi = (l) => l ? Array.isArray(l) ? l : [l] : [], xi = (l, e) => {
|
|
679
679
|
if (e) {
|
|
680
680
|
const [t] = l;
|
|
681
|
-
return t;
|
|
681
|
+
return t ?? null;
|
|
682
682
|
}
|
|
683
683
|
return l;
|
|
684
684
|
};
|
|
685
|
-
var h, p, F, ee, q, x, S, L, V, te, Lt, j, re, Je,
|
|
685
|
+
var h, p, F, ee, q, x, S, L, V, te, Lt, j, re, Je, Ss, Ze, _s, Qe, As, et, Ts, tt, Ns, st, Os, it, Ps, lt, Bs, nt, Vs, ot, Ds, se, yt, at, Is, $, ce, ie, xt, W, de, rt, Hs, le, St, ct, Gs, dt, Ms, ht, Fs;
|
|
686
686
|
class _i {
|
|
687
687
|
constructor({
|
|
688
688
|
parentHtmlContainer: e,
|
|
@@ -704,16 +704,16 @@ class _i {
|
|
|
704
704
|
staticList: ne,
|
|
705
705
|
id: mt,
|
|
706
706
|
isSingleSelect: oe,
|
|
707
|
-
showCount:
|
|
708
|
-
disabledBranchNode:
|
|
709
|
-
direction:
|
|
710
|
-
expandSelected:
|
|
711
|
-
saveScrollPosition:
|
|
712
|
-
iconElements:
|
|
713
|
-
inputCallback:
|
|
714
|
-
openCallback:
|
|
715
|
-
closeCallback:
|
|
716
|
-
nameChangeCallback:
|
|
707
|
+
showCount: qs,
|
|
708
|
+
disabledBranchNode: js,
|
|
709
|
+
direction: $s,
|
|
710
|
+
expandSelected: Ws,
|
|
711
|
+
saveScrollPosition: Rs,
|
|
712
|
+
iconElements: Us,
|
|
713
|
+
inputCallback: zs,
|
|
714
|
+
openCallback: Ys,
|
|
715
|
+
closeCallback: Ks,
|
|
716
|
+
nameChangeCallback: Xs
|
|
717
717
|
}) {
|
|
718
718
|
r(this, te);
|
|
719
719
|
r(this, j);
|
|
@@ -788,16 +788,22 @@ class _i {
|
|
|
788
788
|
r(this, S, null);
|
|
789
789
|
r(this, L, null);
|
|
790
790
|
r(this, V, null);
|
|
791
|
-
|
|
791
|
+
Ot({
|
|
792
792
|
parentHtmlContainer: e,
|
|
793
793
|
value: t,
|
|
794
794
|
staticList: ne,
|
|
795
795
|
appendToBody: o,
|
|
796
796
|
isSingleSelect: oe
|
|
797
|
-
}), this.parentHtmlContainer = e, this.value = [], this.options = s ?? [], this.openLevel = i ?? 0, this.appendToBody = o ?? !1, this.alwaysOpen = !!(d && !P), this.showTags = u ?? !0, this.tagsCountText = f ?? "elements selected", this.clearable = C ?? !0, this.searchable = b ?? !0, this.placeholder = g ?? "Search...", this.grouped = w ?? !0, this.isGroupedValue = k ?? !1, this.listSlotHtmlComponent = O ?? null, this.disabled = P ?? !1, this.emptyText = R ?? "No results found...", this.staticList = !!(ne && !this.appendToBody), this.id = mt ?? "", this.isSingleSelect = oe ?? !1, this.showCount =
|
|
797
|
+
}), this.parentHtmlContainer = e, this.value = [], this.options = s ?? [], this.openLevel = i ?? 0, this.appendToBody = o ?? !1, this.alwaysOpen = !!(d && !P), this.showTags = u ?? !0, this.tagsCountText = f ?? "elements selected", this.clearable = C ?? !0, this.searchable = b ?? !0, this.placeholder = g ?? "Search...", this.grouped = w ?? !0, this.isGroupedValue = k ?? !1, this.listSlotHtmlComponent = O ?? null, this.disabled = P ?? !1, this.emptyText = R ?? "No results found...", this.staticList = !!(ne && !this.appendToBody), this.id = mt ?? "", this.isSingleSelect = oe ?? !1, this.showCount = qs ?? !1, this.disabledBranchNode = js ?? !1, this.direction = $s ?? "auto", this.expandSelected = Ws ?? !1, this.saveScrollPosition = Rs ?? !0, this.iconElements = Tt(Us), this.inputCallback = zs, this.openCallback = Ys, this.closeCallback = Ks, this.nameChangeCallback = Xs, this.ungroupedValue = [], this.groupedValue = [], this.isListOpened = !1, this.selectedName = "", this.srcElement = null, a(this, te, Lt).call(this, t);
|
|
798
798
|
}
|
|
799
799
|
mount() {
|
|
800
|
-
|
|
800
|
+
Ot({
|
|
801
|
+
parentHtmlContainer: this.parentHtmlContainer,
|
|
802
|
+
value: this.value,
|
|
803
|
+
staticList: this.staticList,
|
|
804
|
+
appendToBody: this.appendToBody,
|
|
805
|
+
isSingleSelect: this.isSingleSelect
|
|
806
|
+
}), this.iconElements = Tt(this.iconElements), a(this, te, Lt).call(this, this.value);
|
|
801
807
|
}
|
|
802
808
|
updateValue(e) {
|
|
803
809
|
var s;
|
|
@@ -849,22 +855,22 @@ class _i {
|
|
|
849
855
|
t.style.transform = `translate(${P}px,${R}px)`, t.style.width = `${u}px`;
|
|
850
856
|
}
|
|
851
857
|
const w = g ? "top" : "bottom";
|
|
852
|
-
t.getAttribute("direction") !== w && (t.setAttribute("direction", w), a(this, at,
|
|
858
|
+
t.getAttribute("direction") !== w && (t.setAttribute("direction", w), a(this, at, Is).call(this, g, this.appendToBody));
|
|
853
859
|
}
|
|
854
860
|
}
|
|
855
861
|
h = new WeakMap(), p = new WeakMap(), F = new WeakMap(), ee = new WeakMap(), q = new WeakMap(), x = new WeakMap(), S = new WeakMap(), L = new WeakMap(), V = new WeakMap(), te = new WeakSet(), Lt = function(e) {
|
|
856
862
|
var o;
|
|
857
863
|
this.destroy();
|
|
858
|
-
const { container: t, list: s, input: i } = a(this, Je,
|
|
864
|
+
const { container: t, list: s, input: i } = a(this, Je, Ss).call(this);
|
|
859
865
|
this.srcElement = t, m(this, h, s), m(this, p, i), m(this, x, this.scrollWindowHandler.bind(this)), m(this, S, this.scrollWindowHandler.bind(this)), m(this, L, this.focusWindowHandler.bind(this)), m(this, V, this.blurWindowHandler.bind(this)), this.alwaysOpen && ((o = n(this, p)) == null || o.openClose()), this.disabled ? this.srcElement.classList.add("treeselect--disabled") : this.srcElement.classList.remove("treeselect--disabled"), this.updateValue(e ?? this.value);
|
|
860
866
|
}, j = new WeakSet(), re = function({ groupedNodes: e, nodes: t }) {
|
|
861
867
|
this.ungroupedValue = t ? Ct(t) : [], this.groupedValue = e ? Ct(e) : [];
|
|
862
868
|
const s = this.isGroupedValue || this.isSingleSelect ? this.groupedValue : this.ungroupedValue;
|
|
863
869
|
this.value = xi(s, this.isSingleSelect);
|
|
864
|
-
}, Je = new WeakSet(),
|
|
870
|
+
}, Je = new WeakSet(), Ss = function() {
|
|
865
871
|
const e = this.parentHtmlContainer;
|
|
866
872
|
e.classList.add("treeselect");
|
|
867
|
-
const t = new
|
|
873
|
+
const t = new Li({
|
|
868
874
|
options: this.options,
|
|
869
875
|
value: this.ungroupedValue,
|
|
870
876
|
openLevel: this.openLevel,
|
|
@@ -875,13 +881,13 @@ h = new WeakMap(), p = new WeakMap(), F = new WeakMap(), ee = new WeakMap(), q =
|
|
|
875
881
|
disabledBranchNode: this.disabledBranchNode,
|
|
876
882
|
expandSelected: this.expandSelected,
|
|
877
883
|
iconElements: this.iconElements,
|
|
878
|
-
inputCallback: (d) => a(this, it,
|
|
879
|
-
arrowClickCallback: () => a(this, lt,
|
|
884
|
+
inputCallback: (d) => a(this, it, Ps).call(this, d),
|
|
885
|
+
arrowClickCallback: () => a(this, lt, Bs).call(this),
|
|
880
886
|
mouseupCallback: () => {
|
|
881
887
|
var d;
|
|
882
888
|
return (d = n(this, p)) == null ? void 0 : d.focus();
|
|
883
889
|
}
|
|
884
|
-
}), { groupedNodes: s, nodes: i } = t.selectedNodes, o = new
|
|
890
|
+
}), { groupedNodes: s, nodes: i } = t.selectedNodes, o = new ei({
|
|
885
891
|
value: this.grouped || this.isSingleSelect ? s : i,
|
|
886
892
|
showTags: this.showTags,
|
|
887
893
|
tagsCountText: this.tagsCountText,
|
|
@@ -893,54 +899,54 @@ h = new WeakMap(), p = new WeakMap(), F = new WeakMap(), ee = new WeakMap(), q =
|
|
|
893
899
|
isSingleSelect: this.isSingleSelect,
|
|
894
900
|
id: this.id,
|
|
895
901
|
iconElements: this.iconElements,
|
|
896
|
-
inputCallback: (d) => a(this, Ze,
|
|
897
|
-
searchCallback: (d) => a(this, et,
|
|
898
|
-
openCallback: () => a(this, ot,
|
|
902
|
+
inputCallback: (d) => a(this, Ze, _s).call(this, d),
|
|
903
|
+
searchCallback: (d) => a(this, et, Ts).call(this, d),
|
|
904
|
+
openCallback: () => a(this, ot, Ds).call(this),
|
|
899
905
|
closeCallback: () => a(this, se, yt).call(this),
|
|
900
|
-
keydownCallback: (d) => a(this, Qe,
|
|
901
|
-
focusCallback: () => a(this, tt,
|
|
902
|
-
blurCallback: () => a(this, st,
|
|
903
|
-
nameChangeCallback: (d) => a(this, nt,
|
|
906
|
+
keydownCallback: (d) => a(this, Qe, As).call(this, d),
|
|
907
|
+
focusCallback: () => a(this, tt, Ns).call(this),
|
|
908
|
+
blurCallback: () => a(this, st, Os).call(this),
|
|
909
|
+
nameChangeCallback: (d) => a(this, nt, Vs).call(this, d)
|
|
904
910
|
});
|
|
905
911
|
return this.appendToBody && m(this, F, new ResizeObserver(() => this.updateListPosition())), e.append(o.srcElement), { container: e, list: t, input: o };
|
|
906
|
-
}, Ze = new WeakSet(),
|
|
912
|
+
}, Ze = new WeakSet(), _s = function(e) {
|
|
907
913
|
var o, d, u, f, C;
|
|
908
914
|
const t = Ct(e);
|
|
909
915
|
(o = n(this, h)) == null || o.updateValue(t);
|
|
910
916
|
const s = (u = (d = n(this, h)) == null ? void 0 : d.selectedNodes) == null ? void 0 : u.nodes, i = (C = (f = n(this, h)) == null ? void 0 : f.selectedNodes) == null ? void 0 : C.groupedNodes;
|
|
911
917
|
a(this, j, re).call(this, { groupedNodes: i, nodes: s }), a(this, le, St).call(this);
|
|
912
|
-
}, Qe = new WeakSet(),
|
|
918
|
+
}, Qe = new WeakSet(), As = function(e) {
|
|
913
919
|
var t;
|
|
914
920
|
this.isListOpened && ((t = n(this, h)) == null || t.callKeyAction(e));
|
|
915
|
-
}, et = new WeakSet(),
|
|
921
|
+
}, et = new WeakSet(), Ts = function(e) {
|
|
916
922
|
n(this, q) && clearTimeout(n(this, q)), m(this, q, setTimeout(() => {
|
|
917
923
|
var t;
|
|
918
924
|
(t = n(this, h)) == null || t.updateSearchValue(e), this.updateListPosition();
|
|
919
925
|
}, 350));
|
|
920
|
-
}, tt = new WeakSet(),
|
|
926
|
+
}, tt = new WeakSet(), Ns = function() {
|
|
921
927
|
a(this, $, ce).call(this, !0), n(this, L) && n(this, L) && n(this, V) && (document.addEventListener("mousedown", n(this, L), !0), document.addEventListener("focus", n(this, L), !0), window.addEventListener("blur", n(this, V)));
|
|
922
|
-
}, st = new WeakSet(),
|
|
928
|
+
}, st = new WeakSet(), Os = function() {
|
|
923
929
|
setTimeout(() => {
|
|
924
930
|
var s, i;
|
|
925
931
|
const e = (s = n(this, p)) == null ? void 0 : s.srcElement.contains(document.activeElement), t = (i = n(this, h)) == null ? void 0 : i.srcElement.contains(document.activeElement);
|
|
926
932
|
!e && !t && this.blurWindowHandler();
|
|
927
933
|
}, 1);
|
|
928
|
-
}, it = new WeakSet(),
|
|
934
|
+
}, it = new WeakSet(), Ps = function(e) {
|
|
929
935
|
var o, d, u, f;
|
|
930
936
|
const { groupedNodes: t, nodes: s } = e, i = this.grouped || this.isSingleSelect ? t : s;
|
|
931
937
|
(o = n(this, p)) == null || o.updateValue(i), a(this, j, re).call(this, { groupedNodes: t, nodes: s }), this.isSingleSelect && !this.alwaysOpen && ((d = n(this, p)) == null || d.openClose(), (u = n(this, p)) == null || u.clearSearch()), (f = n(this, p)) == null || f.focus(), a(this, le, St).call(this);
|
|
932
|
-
}, lt = new WeakSet(),
|
|
938
|
+
}, lt = new WeakSet(), Bs = function() {
|
|
933
939
|
var e;
|
|
934
940
|
(e = n(this, p)) == null || e.focus(), this.updateListPosition();
|
|
935
|
-
}, nt = new WeakSet(),
|
|
936
|
-
this.selectedName !== e && (this.selectedName = e, a(this, ct,
|
|
937
|
-
}, ot = new WeakSet(),
|
|
941
|
+
}, nt = new WeakSet(), Vs = function(e) {
|
|
942
|
+
this.selectedName !== e && (this.selectedName = e, a(this, ct, Gs).call(this));
|
|
943
|
+
}, ot = new WeakSet(), Ds = function() {
|
|
938
944
|
var e;
|
|
939
|
-
this.isListOpened = !0, n(this, x) && n(this, S) && (window.addEventListener("scroll", n(this, x), !0), window.addEventListener("resize", n(this, S))), !(!n(this, h) || !this.srcElement) && (this.appendToBody ? (document.body.appendChild(n(this, h).srcElement), (e = n(this, F)) == null || e.observe(this.srcElement)) : this.srcElement.appendChild(n(this, h).srcElement), this.updateListPosition(), a(this, ie, xt).call(this, !0), a(this, rt,
|
|
945
|
+
this.isListOpened = !0, n(this, x) && n(this, S) && (window.addEventListener("scroll", n(this, x), !0), window.addEventListener("resize", n(this, S))), !(!n(this, h) || !this.srcElement) && (this.appendToBody ? (document.body.appendChild(n(this, h).srcElement), (e = n(this, F)) == null || e.observe(this.srcElement)) : this.srcElement.appendChild(n(this, h).srcElement), this.updateListPosition(), a(this, ie, xt).call(this, !0), a(this, rt, Hs).call(this), a(this, dt, Ms).call(this));
|
|
940
946
|
}, se = new WeakSet(), yt = function() {
|
|
941
947
|
var t;
|
|
942
|
-
this.alwaysOpen || (this.isListOpened = !1, n(this, x) && n(this, S) && (window.removeEventListener("scroll", n(this, x), !0), window.removeEventListener("resize", n(this, S))), !n(this, h) || !this.srcElement) || !(this.appendToBody ? document.body.contains(n(this, h).srcElement) : this.srcElement.contains(n(this, h).srcElement)) || (m(this, ee, n(this, h).srcElement.scrollTop), this.appendToBody ? (document.body.removeChild(n(this, h).srcElement), (t = n(this, F)) == null || t.disconnect()) : this.srcElement.removeChild(n(this, h).srcElement), a(this, ie, xt).call(this, !1), a(this, ht,
|
|
943
|
-
}, at = new WeakSet(),
|
|
948
|
+
this.alwaysOpen || (this.isListOpened = !1, n(this, x) && n(this, S) && (window.removeEventListener("scroll", n(this, x), !0), window.removeEventListener("resize", n(this, S))), !n(this, h) || !this.srcElement) || !(this.appendToBody ? document.body.contains(n(this, h).srcElement) : this.srcElement.contains(n(this, h).srcElement)) || (m(this, ee, n(this, h).srcElement.scrollTop), this.appendToBody ? (document.body.removeChild(n(this, h).srcElement), (t = n(this, F)) == null || t.disconnect()) : this.srcElement.removeChild(n(this, h).srcElement), a(this, ie, xt).call(this, !1), a(this, ht, Fs).call(this));
|
|
949
|
+
}, at = new WeakSet(), Is = function(e, t) {
|
|
944
950
|
if (!n(this, h) || !n(this, p))
|
|
945
951
|
return;
|
|
946
952
|
const s = t ? "treeselect-list--top-to-body" : "treeselect-list--top", i = t ? "treeselect-list--bottom-to-body" : "treeselect-list--bottom";
|
|
@@ -952,20 +958,20 @@ h = new WeakMap(), p = new WeakMap(), F = new WeakMap(), ee = new WeakMap(), q =
|
|
|
952
958
|
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, h)) == null || i.srcElement.classList.add("treeselect-list--static") : (o = n(this, h)) == null || o.srcElement.classList.remove("treeselect-list--static");
|
|
953
959
|
}, W = new WeakSet(), de = function(e) {
|
|
954
960
|
!n(this, x) || !n(this, S) || !n(this, L) || !n(this, V) || ((!this.alwaysOpen || e) && (window.removeEventListener("scroll", n(this, x), !0), window.removeEventListener("resize", n(this, S))), document.removeEventListener("mousedown", n(this, L), !0), document.removeEventListener("focus", n(this, L), !0), window.removeEventListener("blur", n(this, V)));
|
|
955
|
-
}, rt = new WeakSet(),
|
|
961
|
+
}, rt = new WeakSet(), Hs = function() {
|
|
956
962
|
var t, s, i;
|
|
957
963
|
const e = (t = n(this, h)) == null ? void 0 : t.isLastFocusedElementExist();
|
|
958
964
|
this.saveScrollPosition && e ? (s = n(this, h)) == null || s.srcElement.scroll(0, n(this, ee)) : (i = n(this, h)) == null || i.focusFirstListElement();
|
|
959
965
|
}, le = new WeakSet(), St = function() {
|
|
960
966
|
var e;
|
|
961
967
|
(e = this.srcElement) == null || e.dispatchEvent(new CustomEvent("input", { detail: this.value })), this.inputCallback && this.inputCallback(this.value);
|
|
962
|
-
}, ct = new WeakSet(),
|
|
968
|
+
}, ct = new WeakSet(), Gs = function() {
|
|
963
969
|
var e;
|
|
964
970
|
(e = this.srcElement) == null || e.dispatchEvent(new CustomEvent("name-change", { detail: this.selectedName })), this.nameChangeCallback && this.nameChangeCallback(this.selectedName);
|
|
965
|
-
}, dt = new WeakSet(),
|
|
971
|
+
}, dt = new WeakSet(), Ms = function() {
|
|
966
972
|
var e;
|
|
967
973
|
this.alwaysOpen || ((e = this.srcElement) == null || e.dispatchEvent(new CustomEvent("open", { detail: this.value })), this.openCallback && this.openCallback(this.value));
|
|
968
|
-
}, ht = new WeakSet(),
|
|
974
|
+
}, ht = new WeakSet(), Fs = function() {
|
|
969
975
|
var e;
|
|
970
976
|
this.alwaysOpen || ((e = this.srcElement) == null || e.dispatchEvent(new CustomEvent("close", { detail: this.value })), this.closeCallback && this.closeCallback(this.value));
|
|
971
977
|
};
|
package/dist/treeselectjs.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(C,m){typeof exports=="object"&&typeof module<"u"?module.exports=m():typeof define=="function"&&define.amd?define(m):(C=typeof globalThis<"u"?globalThis:C||self,C.Treeselect=m())})(this,function(){var O,y,H,x,he,Ft,G,ne,ue,jt,pe,qt,M,oe,P,j,me,$t,fe,Wt,Ce,Rt,be,Ut,ge,zt,we,Yt,ke,Kt,Ee,Xt,ve,Jt,Le,Zt,ye,Qt,xe,es,Se,ts,_e,ss,Ae,is,Te,ls,z,vt,F,B,_,Y,Ne,ns,Oe,os,Pe,as,Be,rs,Ve,cs,De,ds,K,Lt,Ie,hs,He,us,Ge,ps,X,yt,Me,ms,Fe,fs,je,Cs,qe,bs,$e,gs,We,ws,Re,ks,Ue,Es,ze,vs,Ye,Ls,Ke,ys,J,xt,Z,St,Xe,xs,h,p,q,Q,$,A,T,S,V,ee,_t,W,mt,Je,Ss,Ze,_s,Qe,As,et,Ts,tt,Ns,st,Os,it,Ps,lt,Bs,nt,Vs,ot,Ds,te,At,at,Is,R,ft,se,Tt,U,Ct,rt,Hs,ie,Nt,ct,Gs,dt,Ms,ht,Fs;"use strict";var Si=Object.defineProperty;var _i=(C,m,f)=>m in C?Si(C,m,{enumerable:!0,configurable:!0,writable:!0,value:f}):C[m]=f;var c=(C,m,f)=>(_i(C,typeof m!="symbol"?m+"":m,f),f),Et=(C,m,f)=>{if(!m.has(C))throw TypeError("Cannot "+f)};var n=(C,m,f)=>(Et(C,m,"read from private field"),f?f.call(C):m.get(C)),r=(C,m,f)=>{if(m.has(C))throw TypeError("Cannot add the same private member more than once");m instanceof WeakSet?m.add(C):m.set(C,f)},b=(C,m,f,ae)=>(Et(C,m,"write to private field"),ae?ae.call(C,f):m.set(C,f),f);var a=(C,m,f)=>(Et(C,m,"access private method"),f);const C="",m={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>',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>',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>',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>',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>',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>',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>',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>'},f=(l,e)=>{if(e.innerHTML="",typeof l=="string")e.innerHTML=l;else{const t=l.cloneNode(!0);e.appendChild(t)}},ae=l=>{const e=l?{...l}:{};return Object.keys(m).forEach(t=>{e[t]||(e[t]=m[t])}),e},js=l=>l.reduce((e,{name:t},s)=>(e+=t,s<l.length-1&&(e+=", "),e),"");class qs{constructor({value:e,showTags:t,tagsCountText:s,clearable:i,isAlwaysOpened:o,searchable:d,placeholder:u,disabled:g,isSingleSelect:w,id:k,iconElements:E,inputCallback:v,searchCallback:L,openCallback:D,closeCallback:I,keydownCallback:le,focusCallback:ut,blurCallback:kt,nameChangeCallback:pt}){r(this,he);r(this,G);r(this,ue);r(this,pe);r(this,M);r(this,P);r(this,me);r(this,fe);r(this,Ce);r(this,be);r(this,ge);r(this,we);r(this,ke);r(this,Ee);r(this,ve);r(this,Le);r(this,ye);r(this,xe);r(this,Se);r(this,_e);r(this,Ae);r(this,Te);r(this,z);c(this,"value");c(this,"showTags");c(this,"tagsCountText");c(this,"clearable");c(this,"isAlwaysOpened");c(this,"searchable");c(this,"placeholder");c(this,"disabled");c(this,"isSingleSelect");c(this,"id");c(this,"iconElements");c(this,"isOpened");c(this,"searchText");c(this,"srcElement");r(this,O,void 0);r(this,y,void 0);r(this,H,void 0);r(this,x,void 0);c(this,"inputCallback");c(this,"searchCallback");c(this,"openCallback");c(this,"closeCallback");c(this,"keydownCallback");c(this,"focusCallback");c(this,"blurCallback");c(this,"nameChangeCallback");this.value=e,this.showTags=t,this.tagsCountText=s,this.searchable=d,this.placeholder=u,this.clearable=i,this.isAlwaysOpened=o,this.disabled=g,this.isSingleSelect=w,this.id=k,this.iconElements=E,this.isOpened=!1,this.searchText="",b(this,O,a(this,Ce,Rt).call(this)),b(this,y,a(this,ve,Jt).call(this)),b(this,H,a(this,xe,es).call(this)),b(this,x,null),this.inputCallback=v,this.searchCallback=L,this.openCallback=D,this.closeCallback=I,this.keydownCallback=le,this.focusCallback=ut,this.blurCallback=kt,this.nameChangeCallback=pt,this.srcElement=a(this,me,$t).call(this,n(this,O),n(this,y),n(this,H)),a(this,he,Ft).call(this)}focus(){setTimeout(()=>n(this,y).focus(),0)}blur(){this.isOpened&&a(this,P,j).call(this),this.clearSearch(),n(this,y).blur()}updateValue(e){this.value=e,a(this,G,ne).call(this),a(this,M,oe).call(this)}removeItem(e){this.value=this.value.filter(t=>t.id!==e),a(this,z,vt).call(this),a(this,G,ne).call(this),a(this,M,oe).call(this)}clear(){this.value=[],a(this,z,vt).call(this),a(this,G,ne).call(this),this.clearSearch()}openClose(){a(this,P,j).call(this)}clearSearch(){this.searchText="",this.searchCallback(""),a(this,M,oe).call(this)}}O=new WeakMap,y=new WeakMap,H=new WeakMap,x=new WeakMap,he=new WeakSet,Ft=function(){a(this,G,ne).call(this),a(this,M,oe).call(this),a(this,ue,jt).call(this)},G=new WeakSet,ne=function(){if(n(this,O).innerHTML="",this.showTags){n(this,O).append(...a(this,be,Ut).call(this));const e=js(this.value);this.nameChangeCallback(e)}else{const e=a(this,Ee,Xt).call(this);n(this,O).appendChild(e),this.nameChangeCallback(e.innerText)}n(this,O).appendChild(n(this,y))},ue=new WeakSet,jt=function(){const e=[];n(this,H).innerHTML="",this.clearable&&e.push(a(this,Se,ts).call(this)),this.isAlwaysOpened||e.push(a(this,Ae,is).call(this,this.isOpened)),e.length&&n(this,H).append(...e)},pe=new WeakSet,qt=function(){if(!this.isAlwaysOpened&&n(this,x)){const e=this.isOpened?this.iconElements.arrowUp:this.iconElements.arrowDown;f(e,n(this,x))}},M=new WeakSet,oe=function(){var e;(e=this.value)!=null&&e.length?(n(this,y).removeAttribute("placeholder"),this.srcElement.classList.remove("treeselect-input--value-not-selected")):(n(this,y).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,y).value=this.searchText},P=new WeakSet,j=function(){this.isOpened=!this.isOpened,a(this,pe,qt).call(this),this.isOpened?this.openCallback():this.closeCallback()},me=new WeakSet,$t=function(e,t,s){const i=document.createElement("div");return i.classList.add("treeselect-input"),i.setAttribute("tabindex","-1"),i.addEventListener("mousedown",o=>a(this,fe,Wt).call(this,o)),i.addEventListener("focus",()=>this.focusCallback(),!0),i.addEventListener("blur",()=>this.blurCallback(),!0),e.appendChild(t),i.append(e,s),i},fe=new WeakSet,Wt=function(e){e.stopPropagation(),this.isOpened||a(this,P,j).call(this),this.focus()},Ce=new WeakSet,Rt=function(){const e=document.createElement("div");return e.classList.add("treeselect-input__tags"),e},be=new WeakSet,Ut=function(){return this.value.map(e=>{const t=document.createElement("div");t.classList.add("treeselect-input__tags-element"),t.setAttribute("tabindex","-1"),t.setAttribute("tag-id",e.id.toString()),t.setAttribute("title",e.name);const s=a(this,we,Yt).call(this,e.name),i=a(this,ke,Kt).call(this);return t.addEventListener("mousedown",o=>a(this,ge,zt).call(this,o,e.id)),t.append(s,i),t})},ge=new WeakSet,zt=function(e,t){e.preventDefault(),e.stopPropagation(),this.removeItem(t),this.focus()},we=new WeakSet,Yt=function(e){const t=document.createElement("span");return t.classList.add("treeselect-input__tags-name"),t.textContent=e,t},ke=new WeakSet,Kt=function(){const e=document.createElement("span");return e.classList.add("treeselect-input__tags-cross"),f(this.iconElements.cross,e),e},Ee=new WeakSet,Xt=function(){const e=document.createElement("span");if(e.classList.add("treeselect-input__tags-count"),!this.value.length)return e.textContent="",e.setAttribute("title",""),e;const t=this.value.length===1?this.value[0].name:`${this.value.length} ${this.tagsCountText}`;return e.textContent=t,e.setAttribute("title",t),e},ve=new WeakSet,Jt=function(){const e=document.createElement("input");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"),e.addEventListener("keydown",t=>a(this,Le,Zt).call(this,t)),e.addEventListener("input",t=>a(this,ye,Qt).call(this,t,e)),e},Le=new WeakSet,Zt=function(e){e.stopPropagation();const t=e.key;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)&&a(this,P,j).call(this),(t==="Enter"||t==="ArrowDown"||t==="ArrowUp")&&e.preventDefault(),this.keydownCallback(e),t!=="Tab"&&this.focus()},ye=new WeakSet,Qt=function(e,t){e.stopPropagation();const s=this.searchText,i=t.value.trim();if(s.length===0&&i.length===0){t.value="";return}if(this.searchable){const o=e.target.value;this.searchCallback(o),this.isOpened||a(this,P,j).call(this)}else t.value="";this.searchText=t.value},xe=new WeakSet,es=function(){const e=document.createElement("div");return e.classList.add("treeselect-input__operators"),e},Se=new WeakSet,ts=function(){const e=document.createElement("span");return e.classList.add("treeselect-input__clear"),e.setAttribute("tabindex","-1"),f(this.iconElements.clear,e),e.addEventListener("mousedown",t=>a(this,_e,ss).call(this,t)),e},_e=new WeakSet,ss=function(e){e.preventDefault(),e.stopPropagation(),(this.searchText.length||this.value.length)&&this.clear(),this.focus()},Ae=new WeakSet,is=function(e){b(this,x,document.createElement("span")),n(this,x).classList.add("treeselect-input__arrow");const t=e?this.iconElements.arrowUp:this.iconElements.arrowDown;return f(t,n(this,x)),n(this,x).addEventListener("mousedown",s=>a(this,Te,ls).call(this,s)),n(this,x)},Te=new WeakSet,ls=function(e){e.stopPropagation(),e.preventDefault(),this.focus(),a(this,P,j).call(this)},z=new WeakSet,vt=function(){this.inputCallback(this.value)};const Ot=(l,e,t)=>{Us(e);const s=e.filter(i=>!i.disabled&&l.some(o=>o===i.id));if(t&&s.length){s[0].checked=!0;return}s.forEach(i=>{i.checked=!0;const o=bt(i,e);i.checked=o})},bt=({id:l,checked:e},t)=>{const s=t.find(o=>o.id===l);if(!s)return!1;const i=Pt(!!e,s,t);return Bt(s,t),i},Pt=(l,e,t)=>{if(!e.isGroup)return e.checked=e.disabled?!1:!!l,e.isPartialChecked=!1,e.checked;const s=t.filter(u=>u.childOf===e.id);return!l||e.disabled||e.isPartialChecked?(e.checked=!1,e.isPartialChecked=!1,gt(e,s,t),e.checked):Vt(s,t)?Dt(s)?(e.checked=!1,e.isPartialChecked=!1,e.disabled=!0,e.checked):(e.checked=!1,e.isPartialChecked=!0,s.forEach(u=>{Pt(l,u,t)}),e.checked):(e.checked=!0,e.isPartialChecked=!1,gt(e,s,t),e.checked)},Bt=(l,e)=>{const t=e.find(s=>s.id===l.childOf);t&&($s(t,e),Bt(t,e))},$s=(l,e)=>{const t=re(l,e);if(Dt(t)){l.checked=!1,l.isPartialChecked=!1,l.disabled=!0;return}if(Ws(t)){l.checked=!0,l.isPartialChecked=!1;return}if(Rs(t)){l.checked=!1,l.isPartialChecked=!0;return}l.checked=!1,l.isPartialChecked=!1},gt=({checked:l,disabled:e},t,s)=>{t.forEach(i=>{i.disabled=!!e||!!i.disabled,i.checked=!!l&&!i.disabled,i.isPartialChecked=!1;const o=re(i,s);gt({checked:l,disabled:e},o,s)})},Vt=(l,e)=>l.some(i=>i.disabled)?!0:l.some(i=>{if(i.isGroup){const o=re(i,e);return Vt(o,e)}return!1}),Dt=l=>l.every(e=>!!e.disabled),Ws=l=>l.every(e=>!!e.checked),Rs=l=>l.some(e=>!!e.checked||!!e.isPartialChecked),Us=l=>{l.forEach(e=>{e.checked=!1,e.isPartialChecked=!1})},zs=(l,e,t="",s=0)=>{const i=It(l,e,t,s);return Ks(i)},It=(l,e,t,s)=>l.reduce((i,o)=>{var w;const d=!!((w=o.children)!=null&&w.length),u=s>=e&&d,g=s>e;if(i.push({id:o.value,name:o.name,childOf:t,isGroup:d,checked:!1,isPartialChecked:!1,level:s,isClosed:u,hidden:g,disabled:o.disabled??!1}),d){const k=It(o.children,e,o.value,s+1);i.push(...k)}return i},[]),re=({id:l},e)=>e.filter(t=>t.childOf===l),Ys=l=>{const{ungroupedNodes:e,allGroupedNodes:t,allNodes:s}=l.reduce((o,d)=>(d.checked&&(o.allNodes.push(d),d.isGroup?o.allGroupedNodes.push(d):o.ungroupedNodes.push(d)),o),{ungroupedNodes:[],allGroupedNodes:[],allNodes:[]}),i=s.filter(o=>!t.some(({id:d})=>d===o.childOf));return{ungroupedNodes:e,groupedNodes:i,allNodes:s}},Ks=l=>(l.filter(t=>!!t.disabled).forEach(({id:t})=>bt({id:t,checked:!1},l)),l),ce=(l,{id:e,isClosed:t})=>{re({id:e},l).forEach(i=>{i.hidden=t??!1,i.isGroup&&!i.isClosed&&ce(l,{id:i.id,isClosed:t})})},Xs=l=>{l.filter(e=>e.isGroup&&!e.disabled&&(e.checked||e.isPartialChecked)).forEach(e=>{e.isClosed=!1,ce(l,e)})},Js=(l,e)=>{const t=Zs(l,e);l.forEach(s=>{t.some(({id:o})=>o===s.id)?(s.isGroup&&(s.isClosed=!1,ce(l,s)),s.hidden=!1):s.hidden=!0})},Zs=(l,e)=>l.reduce((t,s)=>{if(s.name.toLowerCase().includes(e.toLowerCase())){if(t.push(s),s.isGroup){const o=Ht(s.id,l);t.push(...o)}if(s.childOf){const o=Gt(s.childOf,l);t.push(...o)}}return t},[]),Ht=(l,e)=>e.reduce((t,s)=>(s.childOf===l&&(t.push(s),s.isGroup&&t.push(...Ht(s.id,e))),t),[]),Gt=(l,e)=>e.reduce((t,s)=>(s.id===l&&(t.push(s),s.childOf&&t.push(...Gt(s.childOf,e))),t),[]),Qs=l=>{const{duplications:e}=l.reduce((t,s)=>(t.allItems.some(i=>i.toString()===s.id.toString())&&t.duplications.push(s.id),t.allItems.push(s.id),t),{duplications:[],allItems:[]});e.length&&console.error(`Validation: You have duplicated values: ${e.join(", ")}! You should use unique values.`)},ei=(l,e,t,s,i,o,d,u)=>{Ot(l,e,i),u&&d&&Xs(e),de(e,t,s,o)},de=(l,e,t,s)=>{l.forEach(i=>{const o=e.querySelector(`[input-id="${i.id}"]`),d=N(o);o.checked=i.checked,ti(i,d,s),si(i,d),ii(i,d),li(i,d,t),ni(i,d),ai(i,d,l),oi(i,o,t)}),ri(l,e)},ti=(l,e,t)=>{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")},si=(l,e)=>{l.isPartialChecked?e.classList.add("treeselect-list__item--partial-checked"):e.classList.remove("treeselect-list__item--partial-checked")},ii=(l,e)=>{l.disabled?e.classList.add("treeselect-list__item--disabled"):e.classList.remove("treeselect-list__item--disabled")},li=(l,e,t)=>{if(l.isGroup){const s=e.querySelector(".treeselect-list__item-icon"),i=l.isClosed?t.arrowRight:t.arrowDown;f(i,s),l.isClosed?e.classList.add("treeselect-list__item--closed"):e.classList.remove("treeselect-list__item--closed")}},ni=(l,e)=>{l.hidden?e.classList.add("treeselect-list__item--hidden"):e.classList.remove("treeselect-list__item--hidden")},oi=(l,e,t)=>{const i=e.parentNode.querySelector(".treeselect-list__item-checkbox-icon");l.checked?f(t.check,i):l.isPartialChecked?f(t.partialCheck,i):i.innerHTML=""},ai=(l,e,t)=>{const s=l.level===0,i=20,o=5;if(s){const d=t.some(g=>g.isGroup&&g.level===l.level),u=!l.isGroup&&d?`${i}px`:`${o}px`;e.style.paddingLeft=l.isGroup?"0":u}else e.style.paddingLeft=l.isGroup?`${l.level*i}px`:`${l.level*i+i}px`;e.setAttribute("level",l.level.toString()),e.setAttribute("group",l.isGroup.toString())},ri=(l,e)=>{const t=l.some(i=>!i.hidden),s=e.querySelector(".treeselect-list__empty");t?s.classList.add("treeselect-list__empty--hidden"):s.classList.remove("treeselect-list__empty--hidden")},N=l=>l.parentNode.parentNode,Mt=(l,e)=>e.find(t=>t.id.toString()===l),ci=l=>N(l).querySelector(".treeselect-list__item-icon"),di=(l,e)=>{e&&Object.keys(e).forEach(t=>{const s=e[t];typeof s=="string"&&l.setAttribute(t,s)})};class hi{constructor({options:e,value:t,openLevel:s,listSlotHtmlComponent:i,emptyText:o,isSingleSelect:d,iconElements:u,showCount:g,disabledBranchNode:w,expandSelected:k,inputCallback:E,arrowClickCallback:v,mouseupCallback:L}){r(this,Ne);r(this,Oe);r(this,Pe);r(this,Be);r(this,Ve);r(this,De);r(this,K);r(this,Ie);r(this,He);r(this,Ge);r(this,X);r(this,Me);r(this,Fe);r(this,je);r(this,qe);r(this,$e);r(this,We);r(this,Re);r(this,Ue);r(this,ze);r(this,Ye);r(this,Ke);r(this,J);r(this,Z);r(this,Xe);c(this,"options");c(this,"value");c(this,"openLevel");c(this,"listSlotHtmlComponent");c(this,"emptyText");c(this,"isSingleSelect");c(this,"showCount");c(this,"disabledBranchNode");c(this,"expandSelected");c(this,"iconElements");c(this,"searchText");c(this,"flattedOptions");c(this,"flattedOptionsBeforeSearch");c(this,"selectedNodes");c(this,"srcElement");c(this,"inputCallback");c(this,"arrowClickCallback");c(this,"mouseupCallback");r(this,F,null);r(this,B,!0);r(this,_,[]);r(this,Y,!0);this.options=e,this.value=t,this.openLevel=s??0,this.listSlotHtmlComponent=i??null,this.emptyText=o??"No results found...",this.isSingleSelect=d??!1,this.showCount=g??!1,this.disabledBranchNode=w??!1,this.expandSelected=k??!1,this.iconElements=u,this.searchText="",this.flattedOptions=zs(this.options,this.openLevel),this.flattedOptionsBeforeSearch=this.flattedOptions,this.selectedNodes={nodes:[],groupedNodes:[]},this.srcElement=a(this,Pe,as).call(this),this.inputCallback=E,this.arrowClickCallback=v,this.mouseupCallback=L,Qs(this.flattedOptions)}updateValue(e){this.value=e,b(this,_,this.isSingleSelect?this.value:[]),ei(e,this.flattedOptions,this.srcElement,this.iconElements,this.isSingleSelect,n(this,_),this.expandSelected,n(this,Y)),b(this,Y,!1),a(this,Z,St).call(this)}updateSearchValue(e){if(e===this.searchText)return;const t=this.searchText===""&&e!=="";this.searchText=e,t&&(this.flattedOptionsBeforeSearch=JSON.parse(JSON.stringify(this.flattedOptions))),this.searchText===""&&(this.flattedOptions=this.flattedOptionsBeforeSearch.map(s=>{const i=this.flattedOptions.find(o=>o.id===s.id);return i.isClosed=s.isClosed,i.hidden=s.hidden,i}),this.flattedOptionsBeforeSearch=[]),this.searchText&&Js(this.flattedOptions,e),de(this.flattedOptions,this.srcElement,this.iconElements,n(this,_)),this.focusFirstListElement()}callKeyAction(e){b(this,B,!1);const t=this.srcElement.querySelector(".treeselect-list__item--focused");if(t==null?void 0:t.classList.contains("treeselect-list__item--hidden"))return;const i=e.key;i==="Enter"&&t&&t.dispatchEvent(new Event("mousedown")),(i==="ArrowLeft"||i==="ArrowRight")&&a(this,Ne,ns).call(this,t,e),(i==="ArrowDown"||i==="ArrowUp")&&a(this,Oe,os).call(this,t,i)}focusFirstListElement(){const e="treeselect-list__item--focused",t=this.srcElement.querySelector(`.${e}`),s=Array.from(this.srcElement.querySelectorAll(".treeselect-list__item-checkbox")).filter(o=>window.getComputedStyle(N(o)).display!=="none");if(!s.length)return;t&&t.classList.remove(e),N(s[0]).classList.add(e)}isLastFocusedElementExist(){return!!n(this,F)}}F=new WeakMap,B=new WeakMap,_=new WeakMap,Y=new WeakMap,Ne=new WeakSet,ns=function(e,t){if(!e)return;const s=t.key,o=e.querySelector(".treeselect-list__item-checkbox").getAttribute("input-id"),d=Mt(o,this.flattedOptions),u=e.querySelector(".treeselect-list__item-icon");s==="ArrowLeft"&&!d.isClosed&&d.isGroup&&(u.dispatchEvent(new Event("mousedown")),t.preventDefault()),s==="ArrowRight"&&d.isClosed&&d.isGroup&&(u.dispatchEvent(new Event("mousedown")),t.preventDefault())},Oe=new WeakSet,os=function(e,t){var i;const s=Array.from(this.srcElement.querySelectorAll(".treeselect-list__item-checkbox")).filter(o=>window.getComputedStyle(N(o)).display!=="none");if(s.length)if(!e)N(s[0]).classList.add("treeselect-list__item--focused");else{const o=s.findIndex(I=>N(I).classList.contains("treeselect-list__item--focused"));N(s[o]).classList.remove("treeselect-list__item--focused");const u=t==="ArrowDown"?o+1:o-1,g=t==="ArrowDown"?0:s.length-1,w=s[u]??s[g],k=!s[u],E=N(w);E.classList.add("treeselect-list__item--focused");const v=this.srcElement.getBoundingClientRect(),L=E.getBoundingClientRect();if(k&&t==="ArrowDown"){this.srcElement.scroll(0,0);return}if(k&&t==="ArrowUp"){this.srcElement.scroll(0,this.srcElement.scrollHeight);return}const D=((i=this.listSlotHtmlComponent)==null?void 0:i.clientHeight)??0;if(v.y+v.height<L.y+L.height+D){this.srcElement.scroll(0,this.srcElement.scrollTop+L.height);return}if(v.y>L.y){this.srcElement.scroll(0,this.srcElement.scrollTop-L.height);return}}},Pe=new WeakSet,as=function(){const e=a(this,Be,rs).call(this),t=a(this,K,Lt).call(this,this.options);e.append(...t);const s=a(this,He,us).call(this);e.append(s);const i=a(this,Ie,hs).call(this);return i&&e.append(i),e},Be=new WeakSet,rs=function(){const e=document.createElement("div");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=>a(this,Ve,cs).call(this,t)),e.addEventListener("mousemove",()=>a(this,De,ds).call(this)),e.addEventListener("mouseup",()=>this.mouseupCallback(),!0),e},Ve=new WeakSet,cs=function(e){e.stopPropagation(),n(this,F)&&n(this,B)&&n(this,F).classList.add("treeselect-list__item--focused")},De=new WeakSet,ds=function(){b(this,B,!0)},K=new WeakSet,Lt=function(e){return e.reduce((t,s)=>{var o;if((o=s.children)!=null&&o.length){const d=a(this,Ge,ps).call(this,s),u=a(this,K,Lt).call(this,s.children);return d.append(...u),t.push(d),t}const i=a(this,X,yt).call(this,s,!1);return t.push(i),t},[])},Ie=new WeakSet,hs=function(){if(!this.listSlotHtmlComponent)return null;const e=document.createElement("div");return e.classList.add("treeselect-list__slot"),e.appendChild(this.listSlotHtmlComponent),e},He=new WeakSet,us=function(){const e=document.createElement("div");e.classList.add("treeselect-list__empty"),e.setAttribute("title",this.emptyText);const t=document.createElement("span");t.classList.add("treeselect-list__empty-icon"),f(this.iconElements.attention,t);const s=document.createElement("span");return s.classList.add("treeselect-list__empty-text"),s.textContent=this.emptyText,e.append(t,s),e},Ge=new WeakSet,ps=function(e){const t=document.createElement("div");t.setAttribute("group-container-id",e.value.toString()),t.classList.add("treeselect-list__group-container");const s=a(this,X,yt).call(this,e,!0);return t.appendChild(s),t},X=new WeakSet,yt=function(e,t){const s=a(this,Me,ms).call(this,e);if(t){const d=a(this,$e,gs).call(this);s.appendChild(d),s.classList.add("treeselect-list__item--group")}const i=a(this,Re,ks).call(this,e),o=a(this,Ue,Es).call(this,e,t);return s.append(i,o),s},Me=new WeakSet,ms=function(e){const t=document.createElement("div");return di(t,e.htmlAttr),t.setAttribute("tabindex","-1"),t.setAttribute("title",e.name),t.classList.add("treeselect-list__item"),t.addEventListener("mouseover",()=>a(this,Fe,fs).call(this,t),!0),t.addEventListener("mouseout",()=>a(this,je,Cs).call(this,t),!0),t.addEventListener("mousedown",s=>a(this,qe,bs).call(this,s,e)),t},Fe=new WeakSet,fs=function(e){n(this,B)&&a(this,J,xt).call(this,!0,e)},je=new WeakSet,Cs=function(e){n(this,B)&&(a(this,J,xt).call(this,!1,e),b(this,F,e))},qe=new WeakSet,bs=function(e,t){var o;if(e.preventDefault(),e.stopPropagation(),(o=this.flattedOptions.find(d=>d.id===t.value))==null?void 0:o.disabled)return;const i=e.target.querySelector(".treeselect-list__item-checkbox");i.checked=!i.checked,a(this,Ye,Ls).call(this,i,t)},$e=new WeakSet,gs=function(){const e=document.createElement("span");return e.setAttribute("tabindex","-1"),e.classList.add("treeselect-list__item-icon"),f(this.iconElements.arrowDown,e),e.addEventListener("mousedown",t=>a(this,We,ws).call(this,t)),e},We=new WeakSet,ws=function(e){e.preventDefault(),e.stopPropagation(),a(this,Ke,ys).call(this,e)},Re=new WeakSet,ks=function(e){const t=document.createElement("div");t.classList.add("treeselect-list__item-checkbox-container");const s=document.createElement("span");s.classList.add("treeselect-list__item-checkbox-icon"),s.innerHTML="";const i=document.createElement("input");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},Ue=new WeakSet,Es=function(e,t){const s=document.createElement("label");if(s.textContent=e.name,s.classList.add("treeselect-list__item-label"),t&&this.showCount){const i=a(this,ze,vs).call(this,e);s.appendChild(i)}return s},ze=new WeakSet,vs=function(e){const t=document.createElement("span"),s=this.flattedOptions.filter(i=>i.childOf===e.value);return t.textContent=`(${s.length})`,t.classList.add("treeselect-list__item-label-counter"),t},Ye=new WeakSet,Ls=function(e,t){const s=this.flattedOptions.find(i=>i.id===t.value);if(s){if(s!=null&&s.isGroup&&this.disabledBranchNode){const i=ci(e);i==null||i.dispatchEvent(new Event("mousedown"));return}if(this.isSingleSelect){const[i]=n(this,_);if(s.id===i)return;b(this,_,[s.id]),Ot([s.id],this.flattedOptions,this.isSingleSelect)}else{s.checked=e.checked;const i=bt(s,this.flattedOptions);e.checked=i}de(this.flattedOptions,this.srcElement,this.iconElements,n(this,_)),a(this,Xe,xs).call(this)}},Ke=new WeakSet,ys=function(e){var o,d;const t=(d=(o=e.target)==null?void 0:o.parentNode)==null?void 0:d.querySelector("[input-id]"),s=(t==null?void 0:t.getAttribute("input-id"))??null,i=Mt(s,this.flattedOptions);i&&(i.isClosed=!i.isClosed,ce(this.flattedOptions,i),de(this.flattedOptions,this.srcElement,this.iconElements,n(this,_)),this.arrowClickCallback())},J=new WeakSet,xt=function(e,t){const s="treeselect-list__item--focused";if(e){const i=Array.from(this.srcElement.querySelectorAll(`.${s}`));i.length&&i.forEach(o=>o.classList.remove(s)),t.classList.add(s)}else t.classList.remove(s)},Z=new WeakSet,St=function(){const{ungroupedNodes:e,groupedNodes:t}=Ys(this.flattedOptions);this.selectedNodes={nodes:e,groupedNodes:t}},Xe=new WeakSet,xs=function(){a(this,Z,St).call(this),this.inputCallback(this.selectedNodes),this.value=this.selectedNodes.nodes.map(e=>e.id)};const ui=({parentHtmlContainer:l,staticList:e,appendToBody:t,isSingleSelect:s,value:i,direction:o})=>{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!"),o&&o!=="auto"&&o!=="bottom"&&o!=="top"&&console.error("Validation: you should pass (auto | top | bottom | undefined) as a value for the direction prop!")},wt=l=>l.map(e=>e.id),pi=l=>l?Array.isArray(l)?l:[l]:[],mi=(l,e)=>{if(e){const[t]=l;return t}return l};class fi{constructor({parentHtmlContainer:e,value:t,options:s,openLevel:i,appendToBody:o,alwaysOpen:d,showTags:u,tagsCountText:g,clearable:w,searchable:k,placeholder:E,grouped:v,isGroupedValue:L,listSlotHtmlComponent:D,disabled:I,emptyText:le,staticList:ut,id:kt,isSingleSelect:pt,showCount:Ci,disabledBranchNode:bi,direction:gi,expandSelected:wi,saveScrollPosition:ki,iconElements:Ei,inputCallback:vi,openCallback:Li,closeCallback:yi,nameChangeCallback:xi}){r(this,ee);r(this,W);r(this,Je);r(this,Ze);r(this,Qe);r(this,et);r(this,tt);r(this,st);r(this,it);r(this,lt);r(this,nt);r(this,ot);r(this,te);r(this,at);r(this,R);r(this,se);r(this,U);r(this,rt);r(this,ie);r(this,ct);r(this,dt);r(this,ht);c(this,"parentHtmlContainer");c(this,"value");c(this,"options");c(this,"openLevel");c(this,"appendToBody");c(this,"alwaysOpen");c(this,"showTags");c(this,"tagsCountText");c(this,"clearable");c(this,"searchable");c(this,"placeholder");c(this,"grouped");c(this,"isGroupedValue");c(this,"listSlotHtmlComponent");c(this,"disabled");c(this,"emptyText");c(this,"staticList");c(this,"id");c(this,"isSingleSelect");c(this,"showCount");c(this,"disabledBranchNode");c(this,"direction");c(this,"expandSelected");c(this,"saveScrollPosition");c(this,"iconElements");c(this,"inputCallback");c(this,"openCallback");c(this,"closeCallback");c(this,"nameChangeCallback");c(this,"ungroupedValue");c(this,"groupedValue");c(this,"isListOpened");c(this,"selectedName");c(this,"srcElement");r(this,h,null);r(this,p,null);r(this,q,null);r(this,Q,0);r(this,$,0);r(this,A,null);r(this,T,null);r(this,S,null);r(this,V,null);ui({parentHtmlContainer:e,value:t,staticList:ut,appendToBody:o,isSingleSelect:pt}),this.parentHtmlContainer=e,this.value=[],this.options=s??[],this.openLevel=i??0,this.appendToBody=o??!1,this.alwaysOpen=!!(d&&!I),this.showTags=u??!0,this.tagsCountText=g??"elements selected",this.clearable=w??!0,this.searchable=k??!0,this.placeholder=E??"Search...",this.grouped=v??!0,this.isGroupedValue=L??!1,this.listSlotHtmlComponent=D??null,this.disabled=I??!1,this.emptyText=le??"No results found...",this.staticList=!!(ut&&!this.appendToBody),this.id=kt??"",this.isSingleSelect=pt??!1,this.showCount=Ci??!1,this.disabledBranchNode=bi??!1,this.direction=gi??"auto",this.expandSelected=wi??!1,this.saveScrollPosition=ki??!0,this.iconElements=ae(Ei),this.inputCallback=vi,this.openCallback=Li,this.closeCallback=yi,this.nameChangeCallback=xi,this.ungroupedValue=[],this.groupedValue=[],this.isListOpened=!1,this.selectedName="",this.srcElement=null,a(this,ee,_t).call(this,t)}mount(){a(this,ee,_t).call(this,this.value)}updateValue(e){var s;const t=n(this,h);if(t){const i=pi(e);t.updateValue(i);const{groupedNodes:o,nodes:d}=t.selectedNodes,u=this.grouped||this.isSingleSelect?o:d;(s=n(this,p))==null||s.updateValue(u),a(this,W,mt).call(this,{groupedNodes:o,nodes:d})}}destroy(){this.srcElement&&(a(this,te,At).call(this),this.srcElement.innerHTML="",this.srcElement=null,a(this,U,Ct).call(this,!0))}focus(){n(this,p)&&n(this,p).focus()}toggleOpenClose(){n(this,p)&&(n(this,p).openClose(),n(this,p).focus())}scrollWindowHandler(){this.updateListPosition()}focusWindowHandler(e){var s,i,o;((s=this.srcElement)==null?void 0:s.contains(e.target))||((i=n(this,h))==null?void 0:i.srcElement.contains(e.target))||((o=n(this,p))==null||o.blur(),a(this,U,Ct).call(this,!1),a(this,R,ft).call(this,!1))}blurWindowHandler(){var e;(e=n(this,p))==null||e.blur(),a(this,U,Ct).call(this,!1),a(this,R,ft).call(this,!1)}updateListPosition(){var D;const e=this.srcElement,t=(D=n(this,h))==null?void 0:D.srcElement;if(!e||!t)return;const{height:s}=t.getBoundingClientRect(),{x:i,y:o,height:d,width:u}=e.getBoundingClientRect(),g=window.innerHeight,w=o,k=g-o-d;let E=w>k&&w>=s&&k<s;if(this.direction!=="auto"&&(E=this.direction==="top"),this.appendToBody){(t.style.top!=="0px"||t.style.left!=="0px")&&(t.style.top="0px",t.style.left="0px");const I=i+window.scrollX,le=E?o+window.scrollY-s:o+window.scrollY+d;t.style.transform=`translate(${I}px,${le}px)`,t.style.width=`${u}px`}const v=E?"top":"bottom";t.getAttribute("direction")!==v&&(t.setAttribute("direction",v),a(this,at,Is).call(this,E,this.appendToBody))}}return h=new WeakMap,p=new WeakMap,q=new WeakMap,Q=new WeakMap,$=new WeakMap,A=new WeakMap,T=new WeakMap,S=new WeakMap,V=new WeakMap,ee=new WeakSet,_t=function(e){var o;this.destroy();const{container:t,list:s,input:i}=a(this,Je,Ss).call(this);this.srcElement=t,b(this,h,s),b(this,p,i),b(this,A,this.scrollWindowHandler.bind(this)),b(this,T,this.scrollWindowHandler.bind(this)),b(this,S,this.focusWindowHandler.bind(this)),b(this,V,this.blurWindowHandler.bind(this)),this.alwaysOpen&&((o=n(this,p))==null||o.openClose()),this.disabled?this.srcElement.classList.add("treeselect--disabled"):this.srcElement.classList.remove("treeselect--disabled"),this.updateValue(e??this.value)},W=new WeakSet,mt=function({groupedNodes:e,nodes:t}){this.ungroupedValue=t?wt(t):[],this.groupedValue=e?wt(e):[];const s=this.isGroupedValue||this.isSingleSelect?this.groupedValue:this.ungroupedValue;this.value=mi(s,this.isSingleSelect)},Je=new WeakSet,Ss=function(){const e=this.parentHtmlContainer;e.classList.add("treeselect");const t=new hi({options:this.options,value:this.ungroupedValue,openLevel:this.openLevel,listSlotHtmlComponent:this.listSlotHtmlComponent,emptyText:this.emptyText,isSingleSelect:this.isSingleSelect,showCount:this.showCount,disabledBranchNode:this.disabledBranchNode,expandSelected:this.expandSelected,iconElements:this.iconElements,inputCallback:d=>a(this,it,Ps).call(this,d),arrowClickCallback:()=>a(this,lt,Bs).call(this),mouseupCallback:()=>{var d;return(d=n(this,p))==null?void 0:d.focus()}}),{groupedNodes:s,nodes:i}=t.selectedNodes,o=new qs({value:this.grouped||this.isSingleSelect?s:i,showTags:this.showTags,tagsCountText:this.tagsCountText,clearable:this.clearable,isAlwaysOpened:this.alwaysOpen,searchable:this.searchable,placeholder:this.placeholder,disabled:this.disabled,isSingleSelect:this.isSingleSelect,id:this.id,iconElements:this.iconElements,inputCallback:d=>a(this,Ze,_s).call(this,d),searchCallback:d=>a(this,et,Ts).call(this,d),openCallback:()=>a(this,ot,Ds).call(this),closeCallback:()=>a(this,te,At).call(this),keydownCallback:d=>a(this,Qe,As).call(this,d),focusCallback:()=>a(this,tt,Ns).call(this),blurCallback:()=>a(this,st,Os).call(this),nameChangeCallback:d=>a(this,nt,Vs).call(this,d)});return this.appendToBody&&b(this,q,new ResizeObserver(()=>this.updateListPosition())),e.append(o.srcElement),{container:e,list:t,input:o}},Ze=new WeakSet,_s=function(e){var o,d,u,g,w;const t=wt(e);(o=n(this,h))==null||o.updateValue(t);const s=(u=(d=n(this,h))==null?void 0:d.selectedNodes)==null?void 0:u.nodes,i=(w=(g=n(this,h))==null?void 0:g.selectedNodes)==null?void 0:w.groupedNodes;a(this,W,mt).call(this,{groupedNodes:i,nodes:s}),a(this,ie,Nt).call(this)},Qe=new WeakSet,As=function(e){var t;this.isListOpened&&((t=n(this,h))==null||t.callKeyAction(e))},et=new WeakSet,Ts=function(e){n(this,$)&&clearTimeout(n(this,$)),b(this,$,setTimeout(()=>{var t;(t=n(this,h))==null||t.updateSearchValue(e),this.updateListPosition()},350))},tt=new WeakSet,Ns=function(){a(this,R,ft).call(this,!0),n(this,S)&&n(this,S)&&n(this,V)&&(document.addEventListener("mousedown",n(this,S),!0),document.addEventListener("focus",n(this,S),!0),window.addEventListener("blur",n(this,V)))},st=new WeakSet,Os=function(){setTimeout(()=>{var s,i;const e=(s=n(this,p))==null?void 0:s.srcElement.contains(document.activeElement),t=(i=n(this,h))==null?void 0:i.srcElement.contains(document.activeElement);!e&&!t&&this.blurWindowHandler()},1)},it=new WeakSet,Ps=function(e){var o,d,u,g;const{groupedNodes:t,nodes:s}=e,i=this.grouped||this.isSingleSelect?t:s;(o=n(this,p))==null||o.updateValue(i),a(this,W,mt).call(this,{groupedNodes:t,nodes:s}),this.isSingleSelect&&!this.alwaysOpen&&((d=n(this,p))==null||d.openClose(),(u=n(this,p))==null||u.clearSearch()),(g=n(this,p))==null||g.focus(),a(this,ie,Nt).call(this)},lt=new WeakSet,Bs=function(){var e;(e=n(this,p))==null||e.focus(),this.updateListPosition()},nt=new WeakSet,Vs=function(e){this.selectedName!==e&&(this.selectedName=e,a(this,ct,Gs).call(this))},ot=new WeakSet,Ds=function(){var e;this.isListOpened=!0,n(this,A)&&n(this,T)&&(window.addEventListener("scroll",n(this,A),!0),window.addEventListener("resize",n(this,T))),!(!n(this,h)||!this.srcElement)&&(this.appendToBody?(document.body.appendChild(n(this,h).srcElement),(e=n(this,q))==null||e.observe(this.srcElement)):this.srcElement.appendChild(n(this,h).srcElement),this.updateListPosition(),a(this,se,Tt).call(this,!0),a(this,rt,Hs).call(this),a(this,dt,Ms).call(this))},te=new WeakSet,At=function(){var t;this.alwaysOpen||(this.isListOpened=!1,n(this,A)&&n(this,T)&&(window.removeEventListener("scroll",n(this,A),!0),window.removeEventListener("resize",n(this,T))),!n(this,h)||!this.srcElement)||!(this.appendToBody?document.body.contains(n(this,h).srcElement):this.srcElement.contains(n(this,h).srcElement))||(b(this,Q,n(this,h).srcElement.scrollTop),this.appendToBody?(document.body.removeChild(n(this,h).srcElement),(t=n(this,q))==null||t.disconnect()):this.srcElement.removeChild(n(this,h).srcElement),a(this,se,Tt).call(this,!1),a(this,ht,Fs).call(this))},at=new WeakSet,Is=function(e,t){if(!n(this,h)||!n(this,p))return;const s=t?"treeselect-list--top-to-body":"treeselect-list--top",i=t?"treeselect-list--bottom-to-body":"treeselect-list--bottom";e?(n(this,h).srcElement.classList.add(s),n(this,h).srcElement.classList.remove(i),n(this,p).srcElement.classList.add("treeselect-input--top"),n(this,p).srcElement.classList.remove("treeselect-input--bottom")):(n(this,h).srcElement.classList.remove(s),n(this,h).srcElement.classList.add(i),n(this,p).srcElement.classList.remove("treeselect-input--top"),n(this,p).srcElement.classList.add("treeselect-input--bottom"))},R=new WeakSet,ft=function(e){!n(this,p)||!n(this,h)||(e?(n(this,p).srcElement.classList.add("treeselect-input--focused"),n(this,h).srcElement.classList.add("treeselect-list--focused")):(n(this,p).srcElement.classList.remove("treeselect-input--focused"),n(this,h).srcElement.classList.remove("treeselect-list--focused")))},se=new WeakSet,Tt=function(e){var t,s,i,o;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,h))==null||i.srcElement.classList.add("treeselect-list--static"):(o=n(this,h))==null||o.srcElement.classList.remove("treeselect-list--static")},U=new WeakSet,Ct=function(e){!n(this,A)||!n(this,T)||!n(this,S)||!n(this,V)||((!this.alwaysOpen||e)&&(window.removeEventListener("scroll",n(this,A),!0),window.removeEventListener("resize",n(this,T))),document.removeEventListener("mousedown",n(this,S),!0),document.removeEventListener("focus",n(this,S),!0),window.removeEventListener("blur",n(this,V)))},rt=new WeakSet,Hs=function(){var t,s,i;const e=(t=n(this,h))==null?void 0:t.isLastFocusedElementExist();this.saveScrollPosition&&e?(s=n(this,h))==null||s.srcElement.scroll(0,n(this,Q)):(i=n(this,h))==null||i.focusFirstListElement()},ie=new WeakSet,Nt=function(){var e;(e=this.srcElement)==null||e.dispatchEvent(new CustomEvent("input",{detail:this.value})),this.inputCallback&&this.inputCallback(this.value)},ct=new WeakSet,Gs=function(){var e;(e=this.srcElement)==null||e.dispatchEvent(new CustomEvent("name-change",{detail:this.selectedName})),this.nameChangeCallback&&this.nameChangeCallback(this.selectedName)},dt=new WeakSet,Ms=function(){var e;this.alwaysOpen||((e=this.srcElement)==null||e.dispatchEvent(new CustomEvent("open",{detail:this.value})),this.openCallback&&this.openCallback(this.value))},ht=new WeakSet,Fs=function(){var e;this.alwaysOpen||((e=this.srcElement)==null||e.dispatchEvent(new CustomEvent("close",{detail:this.value})),this.closeCallback&&this.closeCallback(this.value))},fi});
|
|
1
|
+
(function(C,m){typeof exports=="object"&&typeof module<"u"?module.exports=m():typeof define=="function"&&define.amd?define(m):(C=typeof globalThis<"u"?globalThis:C||self,C.Treeselect=m())})(this,function(){var O,y,H,x,he,jt,G,oe,ue,qt,pe,$t,M,ae,P,j,me,Wt,fe,Rt,Ce,Ut,be,zt,ge,Yt,we,Kt,ke,Xt,Ee,Jt,ve,Zt,Le,Qt,ye,es,xe,ts,Se,ss,_e,is,Ae,ls,Te,ns,Y,vt,F,B,_,K,Ne,os,Oe,as,Pe,rs,Be,cs,Ve,ds,De,hs,X,Lt,Ie,us,He,ps,Ge,ms,J,yt,Me,fs,Fe,Cs,je,bs,qe,gs,$e,ws,We,ks,Re,Es,Ue,vs,ze,Ls,Ye,ys,Ke,xs,Z,xt,Q,St,Xe,Ss,h,p,q,ee,$,A,T,S,V,te,_t,W,mt,Je,_s,Ze,As,Qe,Ts,et,Ns,tt,Os,st,Ps,it,Bs,lt,Vs,nt,Ds,ot,Is,se,At,at,Hs,R,ft,ie,Tt,U,Ct,rt,Gs,le,Nt,ct,Ms,dt,Fs,ht,js;"use strict";var Si=Object.defineProperty;var _i=(C,m,f)=>m in C?Si(C,m,{enumerable:!0,configurable:!0,writable:!0,value:f}):C[m]=f;var c=(C,m,f)=>(_i(C,typeof m!="symbol"?m+"":m,f),f),Et=(C,m,f)=>{if(!m.has(C))throw TypeError("Cannot "+f)};var n=(C,m,f)=>(Et(C,m,"read from private field"),f?f.call(C):m.get(C)),r=(C,m,f)=>{if(m.has(C))throw TypeError("Cannot add the same private member more than once");m instanceof WeakSet?m.add(C):m.set(C,f)},b=(C,m,f,z)=>(Et(C,m,"write to private field"),z?z.call(C,f):m.set(C,f),f);var a=(C,m,f)=>(Et(C,m,"access private method"),f);const C="",m={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>',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>',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>',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>',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>',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>',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>',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>'},f=(l,e)=>{if(e.innerHTML="",typeof l=="string")e.innerHTML=l;else{const t=l.cloneNode(!0);e.appendChild(t)}},z=l=>{const e=l?{...l}:{};return Object.keys(m).forEach(t=>{e[t]||(e[t]=m[t])}),e},qs=l=>l.reduce((e,{name:t},s)=>(e+=t,s<l.length-1&&(e+=", "),e),"");class $s{constructor({value:e,showTags:t,tagsCountText:s,clearable:i,isAlwaysOpened:o,searchable:d,placeholder:u,disabled:g,isSingleSelect:w,id:k,iconElements:E,inputCallback:v,searchCallback:L,openCallback:D,closeCallback:I,keydownCallback:ne,focusCallback:ut,blurCallback:kt,nameChangeCallback:pt}){r(this,he);r(this,G);r(this,ue);r(this,pe);r(this,M);r(this,P);r(this,me);r(this,fe);r(this,Ce);r(this,be);r(this,ge);r(this,we);r(this,ke);r(this,Ee);r(this,ve);r(this,Le);r(this,ye);r(this,xe);r(this,Se);r(this,_e);r(this,Ae);r(this,Te);r(this,Y);c(this,"value");c(this,"showTags");c(this,"tagsCountText");c(this,"clearable");c(this,"isAlwaysOpened");c(this,"searchable");c(this,"placeholder");c(this,"disabled");c(this,"isSingleSelect");c(this,"id");c(this,"iconElements");c(this,"isOpened");c(this,"searchText");c(this,"srcElement");r(this,O,void 0);r(this,y,void 0);r(this,H,void 0);r(this,x,void 0);c(this,"inputCallback");c(this,"searchCallback");c(this,"openCallback");c(this,"closeCallback");c(this,"keydownCallback");c(this,"focusCallback");c(this,"blurCallback");c(this,"nameChangeCallback");this.value=e,this.showTags=t,this.tagsCountText=s,this.searchable=d,this.placeholder=u,this.clearable=i,this.isAlwaysOpened=o,this.disabled=g,this.isSingleSelect=w,this.id=k,this.iconElements=E,this.isOpened=!1,this.searchText="",b(this,O,a(this,Ce,Ut).call(this)),b(this,y,a(this,ve,Zt).call(this)),b(this,H,a(this,xe,ts).call(this)),b(this,x,null),this.inputCallback=v,this.searchCallback=L,this.openCallback=D,this.closeCallback=I,this.keydownCallback=ne,this.focusCallback=ut,this.blurCallback=kt,this.nameChangeCallback=pt,this.srcElement=a(this,me,Wt).call(this,n(this,O),n(this,y),n(this,H)),a(this,he,jt).call(this)}focus(){setTimeout(()=>n(this,y).focus(),0)}blur(){this.isOpened&&a(this,P,j).call(this),this.clearSearch(),n(this,y).blur()}updateValue(e){this.value=e,a(this,G,oe).call(this),a(this,M,ae).call(this)}removeItem(e){this.value=this.value.filter(t=>t.id!==e),a(this,Y,vt).call(this),a(this,G,oe).call(this),a(this,M,ae).call(this)}clear(){this.value=[],a(this,Y,vt).call(this),a(this,G,oe).call(this),this.clearSearch()}openClose(){a(this,P,j).call(this)}clearSearch(){this.searchText="",this.searchCallback(""),a(this,M,ae).call(this)}}O=new WeakMap,y=new WeakMap,H=new WeakMap,x=new WeakMap,he=new WeakSet,jt=function(){a(this,G,oe).call(this),a(this,M,ae).call(this),a(this,ue,qt).call(this)},G=new WeakSet,oe=function(){if(n(this,O).innerHTML="",this.showTags){n(this,O).append(...a(this,be,zt).call(this));const e=qs(this.value);this.nameChangeCallback(e)}else{const e=a(this,Ee,Jt).call(this);n(this,O).appendChild(e),this.nameChangeCallback(e.innerText)}n(this,O).appendChild(n(this,y))},ue=new WeakSet,qt=function(){const e=[];n(this,H).innerHTML="",this.clearable&&e.push(a(this,Se,ss).call(this)),this.isAlwaysOpened||e.push(a(this,Ae,ls).call(this,this.isOpened)),e.length&&n(this,H).append(...e)},pe=new WeakSet,$t=function(){if(!this.isAlwaysOpened&&n(this,x)){const e=this.isOpened?this.iconElements.arrowUp:this.iconElements.arrowDown;f(e,n(this,x))}},M=new WeakSet,ae=function(){var e;(e=this.value)!=null&&e.length?(n(this,y).removeAttribute("placeholder"),this.srcElement.classList.remove("treeselect-input--value-not-selected")):(n(this,y).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,y).value=this.searchText},P=new WeakSet,j=function(){this.isOpened=!this.isOpened,a(this,pe,$t).call(this),this.isOpened?this.openCallback():this.closeCallback()},me=new WeakSet,Wt=function(e,t,s){const i=document.createElement("div");return i.classList.add("treeselect-input"),i.setAttribute("tabindex","-1"),i.addEventListener("mousedown",o=>a(this,fe,Rt).call(this,o)),i.addEventListener("focus",()=>this.focusCallback(),!0),i.addEventListener("blur",()=>this.blurCallback(),!0),e.appendChild(t),i.append(e,s),i},fe=new WeakSet,Rt=function(e){e.stopPropagation(),this.isOpened||a(this,P,j).call(this),this.focus()},Ce=new WeakSet,Ut=function(){const e=document.createElement("div");return e.classList.add("treeselect-input__tags"),e},be=new WeakSet,zt=function(){return this.value.map(e=>{const t=document.createElement("div");t.classList.add("treeselect-input__tags-element"),t.setAttribute("tabindex","-1"),t.setAttribute("tag-id",e.id.toString()),t.setAttribute("title",e.name);const s=a(this,we,Kt).call(this,e.name),i=a(this,ke,Xt).call(this);return t.addEventListener("mousedown",o=>a(this,ge,Yt).call(this,o,e.id)),t.append(s,i),t})},ge=new WeakSet,Yt=function(e,t){e.preventDefault(),e.stopPropagation(),this.removeItem(t),this.focus()},we=new WeakSet,Kt=function(e){const t=document.createElement("span");return t.classList.add("treeselect-input__tags-name"),t.textContent=e,t},ke=new WeakSet,Xt=function(){const e=document.createElement("span");return e.classList.add("treeselect-input__tags-cross"),f(this.iconElements.cross,e),e},Ee=new WeakSet,Jt=function(){const e=document.createElement("span");if(e.classList.add("treeselect-input__tags-count"),!this.value.length)return e.textContent="",e.setAttribute("title",""),e;const t=this.value.length===1?this.value[0].name:`${this.value.length} ${this.tagsCountText}`;return e.textContent=t,e.setAttribute("title",t),e},ve=new WeakSet,Zt=function(){const e=document.createElement("input");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"),e.addEventListener("keydown",t=>a(this,Le,Qt).call(this,t)),e.addEventListener("input",t=>a(this,ye,es).call(this,t,e)),e},Le=new WeakSet,Qt=function(e){e.stopPropagation();const t=e.key;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)&&a(this,P,j).call(this),(t==="Enter"||t==="ArrowDown"||t==="ArrowUp")&&e.preventDefault(),this.keydownCallback(e),t!=="Tab"&&this.focus()},ye=new WeakSet,es=function(e,t){e.stopPropagation();const s=this.searchText,i=t.value.trim();if(s.length===0&&i.length===0){t.value="";return}if(this.searchable){const o=e.target.value;this.searchCallback(o),this.isOpened||a(this,P,j).call(this)}else t.value="";this.searchText=t.value},xe=new WeakSet,ts=function(){const e=document.createElement("div");return e.classList.add("treeselect-input__operators"),e},Se=new WeakSet,ss=function(){const e=document.createElement("span");return e.classList.add("treeselect-input__clear"),e.setAttribute("tabindex","-1"),f(this.iconElements.clear,e),e.addEventListener("mousedown",t=>a(this,_e,is).call(this,t)),e},_e=new WeakSet,is=function(e){e.preventDefault(),e.stopPropagation(),(this.searchText.length||this.value.length)&&this.clear(),this.focus()},Ae=new WeakSet,ls=function(e){b(this,x,document.createElement("span")),n(this,x).classList.add("treeselect-input__arrow");const t=e?this.iconElements.arrowUp:this.iconElements.arrowDown;return f(t,n(this,x)),n(this,x).addEventListener("mousedown",s=>a(this,Te,ns).call(this,s)),n(this,x)},Te=new WeakSet,ns=function(e){e.stopPropagation(),e.preventDefault(),this.focus(),a(this,P,j).call(this)},Y=new WeakSet,vt=function(){this.inputCallback(this.value)};const Ot=(l,e,t)=>{zs(e);const s=e.filter(i=>!i.disabled&&l.some(o=>o===i.id));if(t&&s.length){s[0].checked=!0;return}s.forEach(i=>{i.checked=!0;const o=bt(i,e);i.checked=o})},bt=({id:l,checked:e},t)=>{const s=t.find(o=>o.id===l);if(!s)return!1;const i=Pt(!!e,s,t);return Bt(s,t),i},Pt=(l,e,t)=>{if(!e.isGroup)return e.checked=e.disabled?!1:!!l,e.isPartialChecked=!1,e.checked;const s=t.filter(u=>u.childOf===e.id);return!l||e.disabled||e.isPartialChecked?(e.checked=!1,e.isPartialChecked=!1,gt(e,s,t),e.checked):Vt(s,t)?Dt(s)?(e.checked=!1,e.isPartialChecked=!1,e.disabled=!0,e.checked):(e.checked=!1,e.isPartialChecked=!0,s.forEach(u=>{Pt(l,u,t)}),e.checked):(e.checked=!0,e.isPartialChecked=!1,gt(e,s,t),e.checked)},Bt=(l,e)=>{const t=e.find(s=>s.id===l.childOf);t&&(Ws(t,e),Bt(t,e))},Ws=(l,e)=>{const t=re(l,e);if(Dt(t)){l.checked=!1,l.isPartialChecked=!1,l.disabled=!0;return}if(Rs(t)){l.checked=!0,l.isPartialChecked=!1;return}if(Us(t)){l.checked=!1,l.isPartialChecked=!0;return}l.checked=!1,l.isPartialChecked=!1},gt=({checked:l,disabled:e},t,s)=>{t.forEach(i=>{i.disabled=!!e||!!i.disabled,i.checked=!!l&&!i.disabled,i.isPartialChecked=!1;const o=re(i,s);gt({checked:l,disabled:e},o,s)})},Vt=(l,e)=>l.some(i=>i.disabled)?!0:l.some(i=>{if(i.isGroup){const o=re(i,e);return Vt(o,e)}return!1}),Dt=l=>l.every(e=>!!e.disabled),Rs=l=>l.every(e=>!!e.checked),Us=l=>l.some(e=>!!e.checked||!!e.isPartialChecked),zs=l=>{l.forEach(e=>{e.checked=!1,e.isPartialChecked=!1})},Ys=(l,e,t="",s=0)=>{const i=It(l,e,t,s);return Xs(i)},It=(l,e,t,s)=>l.reduce((i,o)=>{var w;const d=!!((w=o.children)!=null&&w.length),u=s>=e&&d,g=s>e;if(i.push({id:o.value,name:o.name,childOf:t,isGroup:d,checked:!1,isPartialChecked:!1,level:s,isClosed:u,hidden:g,disabled:o.disabled??!1}),d){const k=It(o.children,e,o.value,s+1);i.push(...k)}return i},[]),re=({id:l},e)=>e.filter(t=>t.childOf===l),Ks=l=>{const{ungroupedNodes:e,allGroupedNodes:t,allNodes:s}=l.reduce((o,d)=>(d.checked&&(o.allNodes.push(d),d.isGroup?o.allGroupedNodes.push(d):o.ungroupedNodes.push(d)),o),{ungroupedNodes:[],allGroupedNodes:[],allNodes:[]}),i=s.filter(o=>!t.some(({id:d})=>d===o.childOf));return{ungroupedNodes:e,groupedNodes:i,allNodes:s}},Xs=l=>(l.filter(t=>!!t.disabled).forEach(({id:t})=>bt({id:t,checked:!1},l)),l),ce=(l,{id:e,isClosed:t})=>{re({id:e},l).forEach(i=>{i.hidden=t??!1,i.isGroup&&!i.isClosed&&ce(l,{id:i.id,isClosed:t})})},Js=l=>{l.filter(e=>e.isGroup&&!e.disabled&&(e.checked||e.isPartialChecked)).forEach(e=>{e.isClosed=!1,ce(l,e)})},Zs=(l,e)=>{const t=Qs(l,e);l.forEach(s=>{t.some(({id:o})=>o===s.id)?(s.isGroup&&(s.isClosed=!1,ce(l,s)),s.hidden=!1):s.hidden=!0})},Qs=(l,e)=>l.reduce((t,s)=>{if(s.name.toLowerCase().includes(e.toLowerCase())){if(t.push(s),s.isGroup){const o=Ht(s.id,l);t.push(...o)}if(s.childOf){const o=Gt(s.childOf,l);t.push(...o)}}return t},[]),Ht=(l,e)=>e.reduce((t,s)=>(s.childOf===l&&(t.push(s),s.isGroup&&t.push(...Ht(s.id,e))),t),[]),Gt=(l,e)=>e.reduce((t,s)=>(s.id===l&&(t.push(s),s.childOf&&t.push(...Gt(s.childOf,e))),t),[]),ei=l=>{const{duplications:e}=l.reduce((t,s)=>(t.allItems.some(i=>i.toString()===s.id.toString())&&t.duplications.push(s.id),t.allItems.push(s.id),t),{duplications:[],allItems:[]});e.length&&console.error(`Validation: You have duplicated values: ${e.join(", ")}! You should use unique values.`)},ti=(l,e,t,s,i,o,d,u)=>{Ot(l,e,i),u&&d&&Js(e),de(e,t,s,o)},de=(l,e,t,s)=>{l.forEach(i=>{const o=e.querySelector(`[input-id="${i.id}"]`),d=N(o);o.checked=i.checked,si(i,d,s),ii(i,d),li(i,d),ni(i,d,t),oi(i,d),ri(i,d,l),ai(i,o,t)}),ci(l,e)},si=(l,e,t)=>{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")},ii=(l,e)=>{l.isPartialChecked?e.classList.add("treeselect-list__item--partial-checked"):e.classList.remove("treeselect-list__item--partial-checked")},li=(l,e)=>{l.disabled?e.classList.add("treeselect-list__item--disabled"):e.classList.remove("treeselect-list__item--disabled")},ni=(l,e,t)=>{if(l.isGroup){const s=e.querySelector(".treeselect-list__item-icon"),i=l.isClosed?t.arrowRight:t.arrowDown;f(i,s),l.isClosed?e.classList.add("treeselect-list__item--closed"):e.classList.remove("treeselect-list__item--closed")}},oi=(l,e)=>{l.hidden?e.classList.add("treeselect-list__item--hidden"):e.classList.remove("treeselect-list__item--hidden")},ai=(l,e,t)=>{const i=e.parentNode.querySelector(".treeselect-list__item-checkbox-icon");l.checked?f(t.check,i):l.isPartialChecked?f(t.partialCheck,i):i.innerHTML=""},ri=(l,e,t)=>{const s=l.level===0,i=20,o=5;if(s){const d=t.some(g=>g.isGroup&&g.level===l.level),u=!l.isGroup&&d?`${i}px`:`${o}px`;e.style.paddingLeft=l.isGroup?"0":u}else e.style.paddingLeft=l.isGroup?`${l.level*i}px`:`${l.level*i+i}px`;e.setAttribute("level",l.level.toString()),e.setAttribute("group",l.isGroup.toString())},ci=(l,e)=>{const t=l.some(i=>!i.hidden),s=e.querySelector(".treeselect-list__empty");t?s.classList.add("treeselect-list__empty--hidden"):s.classList.remove("treeselect-list__empty--hidden")},N=l=>l.parentNode.parentNode,Mt=(l,e)=>e.find(t=>t.id.toString()===l),di=l=>N(l).querySelector(".treeselect-list__item-icon"),hi=(l,e)=>{e&&Object.keys(e).forEach(t=>{const s=e[t];typeof s=="string"&&l.setAttribute(t,s)})};class ui{constructor({options:e,value:t,openLevel:s,listSlotHtmlComponent:i,emptyText:o,isSingleSelect:d,iconElements:u,showCount:g,disabledBranchNode:w,expandSelected:k,inputCallback:E,arrowClickCallback:v,mouseupCallback:L}){r(this,Ne);r(this,Oe);r(this,Pe);r(this,Be);r(this,Ve);r(this,De);r(this,X);r(this,Ie);r(this,He);r(this,Ge);r(this,J);r(this,Me);r(this,Fe);r(this,je);r(this,qe);r(this,$e);r(this,We);r(this,Re);r(this,Ue);r(this,ze);r(this,Ye);r(this,Ke);r(this,Z);r(this,Q);r(this,Xe);c(this,"options");c(this,"value");c(this,"openLevel");c(this,"listSlotHtmlComponent");c(this,"emptyText");c(this,"isSingleSelect");c(this,"showCount");c(this,"disabledBranchNode");c(this,"expandSelected");c(this,"iconElements");c(this,"searchText");c(this,"flattedOptions");c(this,"flattedOptionsBeforeSearch");c(this,"selectedNodes");c(this,"srcElement");c(this,"inputCallback");c(this,"arrowClickCallback");c(this,"mouseupCallback");r(this,F,null);r(this,B,!0);r(this,_,[]);r(this,K,!0);this.options=e,this.value=t,this.openLevel=s??0,this.listSlotHtmlComponent=i??null,this.emptyText=o??"No results found...",this.isSingleSelect=d??!1,this.showCount=g??!1,this.disabledBranchNode=w??!1,this.expandSelected=k??!1,this.iconElements=u,this.searchText="",this.flattedOptions=Ys(this.options,this.openLevel),this.flattedOptionsBeforeSearch=this.flattedOptions,this.selectedNodes={nodes:[],groupedNodes:[]},this.srcElement=a(this,Pe,rs).call(this),this.inputCallback=E,this.arrowClickCallback=v,this.mouseupCallback=L,ei(this.flattedOptions)}updateValue(e){this.value=e,b(this,_,this.isSingleSelect?this.value:[]),ti(e,this.flattedOptions,this.srcElement,this.iconElements,this.isSingleSelect,n(this,_),this.expandSelected,n(this,K)),b(this,K,!1),a(this,Q,St).call(this)}updateSearchValue(e){if(e===this.searchText)return;const t=this.searchText===""&&e!=="";this.searchText=e,t&&(this.flattedOptionsBeforeSearch=JSON.parse(JSON.stringify(this.flattedOptions))),this.searchText===""&&(this.flattedOptions=this.flattedOptionsBeforeSearch.map(s=>{const i=this.flattedOptions.find(o=>o.id===s.id);return i.isClosed=s.isClosed,i.hidden=s.hidden,i}),this.flattedOptionsBeforeSearch=[]),this.searchText&&Zs(this.flattedOptions,e),de(this.flattedOptions,this.srcElement,this.iconElements,n(this,_)),this.focusFirstListElement()}callKeyAction(e){b(this,B,!1);const t=this.srcElement.querySelector(".treeselect-list__item--focused");if(t==null?void 0:t.classList.contains("treeselect-list__item--hidden"))return;const i=e.key;i==="Enter"&&t&&t.dispatchEvent(new Event("mousedown")),(i==="ArrowLeft"||i==="ArrowRight")&&a(this,Ne,os).call(this,t,e),(i==="ArrowDown"||i==="ArrowUp")&&a(this,Oe,as).call(this,t,i)}focusFirstListElement(){const e="treeselect-list__item--focused",t=this.srcElement.querySelector(`.${e}`),s=Array.from(this.srcElement.querySelectorAll(".treeselect-list__item-checkbox")).filter(o=>window.getComputedStyle(N(o)).display!=="none");if(!s.length)return;t&&t.classList.remove(e),N(s[0]).classList.add(e)}isLastFocusedElementExist(){return!!n(this,F)}}F=new WeakMap,B=new WeakMap,_=new WeakMap,K=new WeakMap,Ne=new WeakSet,os=function(e,t){if(!e)return;const s=t.key,o=e.querySelector(".treeselect-list__item-checkbox").getAttribute("input-id"),d=Mt(o,this.flattedOptions),u=e.querySelector(".treeselect-list__item-icon");s==="ArrowLeft"&&!d.isClosed&&d.isGroup&&(u.dispatchEvent(new Event("mousedown")),t.preventDefault()),s==="ArrowRight"&&d.isClosed&&d.isGroup&&(u.dispatchEvent(new Event("mousedown")),t.preventDefault())},Oe=new WeakSet,as=function(e,t){var i;const s=Array.from(this.srcElement.querySelectorAll(".treeselect-list__item-checkbox")).filter(o=>window.getComputedStyle(N(o)).display!=="none");if(s.length)if(!e)N(s[0]).classList.add("treeselect-list__item--focused");else{const o=s.findIndex(I=>N(I).classList.contains("treeselect-list__item--focused"));N(s[o]).classList.remove("treeselect-list__item--focused");const u=t==="ArrowDown"?o+1:o-1,g=t==="ArrowDown"?0:s.length-1,w=s[u]??s[g],k=!s[u],E=N(w);E.classList.add("treeselect-list__item--focused");const v=this.srcElement.getBoundingClientRect(),L=E.getBoundingClientRect();if(k&&t==="ArrowDown"){this.srcElement.scroll(0,0);return}if(k&&t==="ArrowUp"){this.srcElement.scroll(0,this.srcElement.scrollHeight);return}const D=((i=this.listSlotHtmlComponent)==null?void 0:i.clientHeight)??0;if(v.y+v.height<L.y+L.height+D){this.srcElement.scroll(0,this.srcElement.scrollTop+L.height);return}if(v.y>L.y){this.srcElement.scroll(0,this.srcElement.scrollTop-L.height);return}}},Pe=new WeakSet,rs=function(){const e=a(this,Be,cs).call(this),t=a(this,X,Lt).call(this,this.options);e.append(...t);const s=a(this,He,ps).call(this);e.append(s);const i=a(this,Ie,us).call(this);return i&&e.append(i),e},Be=new WeakSet,cs=function(){const e=document.createElement("div");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=>a(this,Ve,ds).call(this,t)),e.addEventListener("mousemove",()=>a(this,De,hs).call(this)),e.addEventListener("mouseup",()=>this.mouseupCallback(),!0),e},Ve=new WeakSet,ds=function(e){e.stopPropagation(),n(this,F)&&n(this,B)&&n(this,F).classList.add("treeselect-list__item--focused")},De=new WeakSet,hs=function(){b(this,B,!0)},X=new WeakSet,Lt=function(e){return e.reduce((t,s)=>{var o;if((o=s.children)!=null&&o.length){const d=a(this,Ge,ms).call(this,s),u=a(this,X,Lt).call(this,s.children);return d.append(...u),t.push(d),t}const i=a(this,J,yt).call(this,s,!1);return t.push(i),t},[])},Ie=new WeakSet,us=function(){if(!this.listSlotHtmlComponent)return null;const e=document.createElement("div");return e.classList.add("treeselect-list__slot"),e.appendChild(this.listSlotHtmlComponent),e},He=new WeakSet,ps=function(){const e=document.createElement("div");e.classList.add("treeselect-list__empty"),e.setAttribute("title",this.emptyText);const t=document.createElement("span");t.classList.add("treeselect-list__empty-icon"),f(this.iconElements.attention,t);const s=document.createElement("span");return s.classList.add("treeselect-list__empty-text"),s.textContent=this.emptyText,e.append(t,s),e},Ge=new WeakSet,ms=function(e){const t=document.createElement("div");t.setAttribute("group-container-id",e.value.toString()),t.classList.add("treeselect-list__group-container");const s=a(this,J,yt).call(this,e,!0);return t.appendChild(s),t},J=new WeakSet,yt=function(e,t){const s=a(this,Me,fs).call(this,e);if(t){const d=a(this,$e,ws).call(this);s.appendChild(d),s.classList.add("treeselect-list__item--group")}const i=a(this,Re,Es).call(this,e),o=a(this,Ue,vs).call(this,e,t);return s.append(i,o),s},Me=new WeakSet,fs=function(e){const t=document.createElement("div");return hi(t,e.htmlAttr),t.setAttribute("tabindex","-1"),t.setAttribute("title",e.name),t.classList.add("treeselect-list__item"),t.addEventListener("mouseover",()=>a(this,Fe,Cs).call(this,t),!0),t.addEventListener("mouseout",()=>a(this,je,bs).call(this,t),!0),t.addEventListener("mousedown",s=>a(this,qe,gs).call(this,s,e)),t},Fe=new WeakSet,Cs=function(e){n(this,B)&&a(this,Z,xt).call(this,!0,e)},je=new WeakSet,bs=function(e){n(this,B)&&(a(this,Z,xt).call(this,!1,e),b(this,F,e))},qe=new WeakSet,gs=function(e,t){var o;if(e.preventDefault(),e.stopPropagation(),(o=this.flattedOptions.find(d=>d.id===t.value))==null?void 0:o.disabled)return;const i=e.target.querySelector(".treeselect-list__item-checkbox");i.checked=!i.checked,a(this,Ye,ys).call(this,i,t)},$e=new WeakSet,ws=function(){const e=document.createElement("span");return e.setAttribute("tabindex","-1"),e.classList.add("treeselect-list__item-icon"),f(this.iconElements.arrowDown,e),e.addEventListener("mousedown",t=>a(this,We,ks).call(this,t)),e},We=new WeakSet,ks=function(e){e.preventDefault(),e.stopPropagation(),a(this,Ke,xs).call(this,e)},Re=new WeakSet,Es=function(e){const t=document.createElement("div");t.classList.add("treeselect-list__item-checkbox-container");const s=document.createElement("span");s.classList.add("treeselect-list__item-checkbox-icon"),s.innerHTML="";const i=document.createElement("input");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},Ue=new WeakSet,vs=function(e,t){const s=document.createElement("label");if(s.textContent=e.name,s.classList.add("treeselect-list__item-label"),t&&this.showCount){const i=a(this,ze,Ls).call(this,e);s.appendChild(i)}return s},ze=new WeakSet,Ls=function(e){const t=document.createElement("span"),s=this.flattedOptions.filter(i=>i.childOf===e.value);return t.textContent=`(${s.length})`,t.classList.add("treeselect-list__item-label-counter"),t},Ye=new WeakSet,ys=function(e,t){const s=this.flattedOptions.find(i=>i.id===t.value);if(s){if(s!=null&&s.isGroup&&this.disabledBranchNode){const i=di(e);i==null||i.dispatchEvent(new Event("mousedown"));return}if(this.isSingleSelect){const[i]=n(this,_);if(s.id===i)return;b(this,_,[s.id]),Ot([s.id],this.flattedOptions,this.isSingleSelect)}else{s.checked=e.checked;const i=bt(s,this.flattedOptions);e.checked=i}de(this.flattedOptions,this.srcElement,this.iconElements,n(this,_)),a(this,Xe,Ss).call(this)}},Ke=new WeakSet,xs=function(e){var o,d;const t=(d=(o=e.target)==null?void 0:o.parentNode)==null?void 0:d.querySelector("[input-id]"),s=(t==null?void 0:t.getAttribute("input-id"))??null,i=Mt(s,this.flattedOptions);i&&(i.isClosed=!i.isClosed,ce(this.flattedOptions,i),de(this.flattedOptions,this.srcElement,this.iconElements,n(this,_)),this.arrowClickCallback())},Z=new WeakSet,xt=function(e,t){const s="treeselect-list__item--focused";if(e){const i=Array.from(this.srcElement.querySelectorAll(`.${s}`));i.length&&i.forEach(o=>o.classList.remove(s)),t.classList.add(s)}else t.classList.remove(s)},Q=new WeakSet,St=function(){const{ungroupedNodes:e,groupedNodes:t}=Ks(this.flattedOptions);this.selectedNodes={nodes:e,groupedNodes:t}},Xe=new WeakSet,Ss=function(){a(this,Q,St).call(this),this.inputCallback(this.selectedNodes),this.value=this.selectedNodes.nodes.map(e=>e.id)};const Ft=({parentHtmlContainer:l,staticList:e,appendToBody:t,isSingleSelect:s,value:i,direction:o})=>{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!"),o&&o!=="auto"&&o!=="bottom"&&o!=="top"&&console.error("Validation: you should pass (auto | top | bottom | undefined) as a value for the direction prop!")},wt=l=>l.map(e=>e.id),pi=l=>l?Array.isArray(l)?l:[l]:[],mi=(l,e)=>{if(e){const[t]=l;return t??null}return l};class fi{constructor({parentHtmlContainer:e,value:t,options:s,openLevel:i,appendToBody:o,alwaysOpen:d,showTags:u,tagsCountText:g,clearable:w,searchable:k,placeholder:E,grouped:v,isGroupedValue:L,listSlotHtmlComponent:D,disabled:I,emptyText:ne,staticList:ut,id:kt,isSingleSelect:pt,showCount:Ci,disabledBranchNode:bi,direction:gi,expandSelected:wi,saveScrollPosition:ki,iconElements:Ei,inputCallback:vi,openCallback:Li,closeCallback:yi,nameChangeCallback:xi}){r(this,te);r(this,W);r(this,Je);r(this,Ze);r(this,Qe);r(this,et);r(this,tt);r(this,st);r(this,it);r(this,lt);r(this,nt);r(this,ot);r(this,se);r(this,at);r(this,R);r(this,ie);r(this,U);r(this,rt);r(this,le);r(this,ct);r(this,dt);r(this,ht);c(this,"parentHtmlContainer");c(this,"value");c(this,"options");c(this,"openLevel");c(this,"appendToBody");c(this,"alwaysOpen");c(this,"showTags");c(this,"tagsCountText");c(this,"clearable");c(this,"searchable");c(this,"placeholder");c(this,"grouped");c(this,"isGroupedValue");c(this,"listSlotHtmlComponent");c(this,"disabled");c(this,"emptyText");c(this,"staticList");c(this,"id");c(this,"isSingleSelect");c(this,"showCount");c(this,"disabledBranchNode");c(this,"direction");c(this,"expandSelected");c(this,"saveScrollPosition");c(this,"iconElements");c(this,"inputCallback");c(this,"openCallback");c(this,"closeCallback");c(this,"nameChangeCallback");c(this,"ungroupedValue");c(this,"groupedValue");c(this,"isListOpened");c(this,"selectedName");c(this,"srcElement");r(this,h,null);r(this,p,null);r(this,q,null);r(this,ee,0);r(this,$,0);r(this,A,null);r(this,T,null);r(this,S,null);r(this,V,null);Ft({parentHtmlContainer:e,value:t,staticList:ut,appendToBody:o,isSingleSelect:pt}),this.parentHtmlContainer=e,this.value=[],this.options=s??[],this.openLevel=i??0,this.appendToBody=o??!1,this.alwaysOpen=!!(d&&!I),this.showTags=u??!0,this.tagsCountText=g??"elements selected",this.clearable=w??!0,this.searchable=k??!0,this.placeholder=E??"Search...",this.grouped=v??!0,this.isGroupedValue=L??!1,this.listSlotHtmlComponent=D??null,this.disabled=I??!1,this.emptyText=ne??"No results found...",this.staticList=!!(ut&&!this.appendToBody),this.id=kt??"",this.isSingleSelect=pt??!1,this.showCount=Ci??!1,this.disabledBranchNode=bi??!1,this.direction=gi??"auto",this.expandSelected=wi??!1,this.saveScrollPosition=ki??!0,this.iconElements=z(Ei),this.inputCallback=vi,this.openCallback=Li,this.closeCallback=yi,this.nameChangeCallback=xi,this.ungroupedValue=[],this.groupedValue=[],this.isListOpened=!1,this.selectedName="",this.srcElement=null,a(this,te,_t).call(this,t)}mount(){Ft({parentHtmlContainer:this.parentHtmlContainer,value:this.value,staticList:this.staticList,appendToBody:this.appendToBody,isSingleSelect:this.isSingleSelect}),this.iconElements=z(this.iconElements),a(this,te,_t).call(this,this.value)}updateValue(e){var s;const t=n(this,h);if(t){const i=pi(e);t.updateValue(i);const{groupedNodes:o,nodes:d}=t.selectedNodes,u=this.grouped||this.isSingleSelect?o:d;(s=n(this,p))==null||s.updateValue(u),a(this,W,mt).call(this,{groupedNodes:o,nodes:d})}}destroy(){this.srcElement&&(a(this,se,At).call(this),this.srcElement.innerHTML="",this.srcElement=null,a(this,U,Ct).call(this,!0))}focus(){n(this,p)&&n(this,p).focus()}toggleOpenClose(){n(this,p)&&(n(this,p).openClose(),n(this,p).focus())}scrollWindowHandler(){this.updateListPosition()}focusWindowHandler(e){var s,i,o;((s=this.srcElement)==null?void 0:s.contains(e.target))||((i=n(this,h))==null?void 0:i.srcElement.contains(e.target))||((o=n(this,p))==null||o.blur(),a(this,U,Ct).call(this,!1),a(this,R,ft).call(this,!1))}blurWindowHandler(){var e;(e=n(this,p))==null||e.blur(),a(this,U,Ct).call(this,!1),a(this,R,ft).call(this,!1)}updateListPosition(){var D;const e=this.srcElement,t=(D=n(this,h))==null?void 0:D.srcElement;if(!e||!t)return;const{height:s}=t.getBoundingClientRect(),{x:i,y:o,height:d,width:u}=e.getBoundingClientRect(),g=window.innerHeight,w=o,k=g-o-d;let E=w>k&&w>=s&&k<s;if(this.direction!=="auto"&&(E=this.direction==="top"),this.appendToBody){(t.style.top!=="0px"||t.style.left!=="0px")&&(t.style.top="0px",t.style.left="0px");const I=i+window.scrollX,ne=E?o+window.scrollY-s:o+window.scrollY+d;t.style.transform=`translate(${I}px,${ne}px)`,t.style.width=`${u}px`}const v=E?"top":"bottom";t.getAttribute("direction")!==v&&(t.setAttribute("direction",v),a(this,at,Hs).call(this,E,this.appendToBody))}}return h=new WeakMap,p=new WeakMap,q=new WeakMap,ee=new WeakMap,$=new WeakMap,A=new WeakMap,T=new WeakMap,S=new WeakMap,V=new WeakMap,te=new WeakSet,_t=function(e){var o;this.destroy();const{container:t,list:s,input:i}=a(this,Je,_s).call(this);this.srcElement=t,b(this,h,s),b(this,p,i),b(this,A,this.scrollWindowHandler.bind(this)),b(this,T,this.scrollWindowHandler.bind(this)),b(this,S,this.focusWindowHandler.bind(this)),b(this,V,this.blurWindowHandler.bind(this)),this.alwaysOpen&&((o=n(this,p))==null||o.openClose()),this.disabled?this.srcElement.classList.add("treeselect--disabled"):this.srcElement.classList.remove("treeselect--disabled"),this.updateValue(e??this.value)},W=new WeakSet,mt=function({groupedNodes:e,nodes:t}){this.ungroupedValue=t?wt(t):[],this.groupedValue=e?wt(e):[];const s=this.isGroupedValue||this.isSingleSelect?this.groupedValue:this.ungroupedValue;this.value=mi(s,this.isSingleSelect)},Je=new WeakSet,_s=function(){const e=this.parentHtmlContainer;e.classList.add("treeselect");const t=new ui({options:this.options,value:this.ungroupedValue,openLevel:this.openLevel,listSlotHtmlComponent:this.listSlotHtmlComponent,emptyText:this.emptyText,isSingleSelect:this.isSingleSelect,showCount:this.showCount,disabledBranchNode:this.disabledBranchNode,expandSelected:this.expandSelected,iconElements:this.iconElements,inputCallback:d=>a(this,it,Bs).call(this,d),arrowClickCallback:()=>a(this,lt,Vs).call(this),mouseupCallback:()=>{var d;return(d=n(this,p))==null?void 0:d.focus()}}),{groupedNodes:s,nodes:i}=t.selectedNodes,o=new $s({value:this.grouped||this.isSingleSelect?s:i,showTags:this.showTags,tagsCountText:this.tagsCountText,clearable:this.clearable,isAlwaysOpened:this.alwaysOpen,searchable:this.searchable,placeholder:this.placeholder,disabled:this.disabled,isSingleSelect:this.isSingleSelect,id:this.id,iconElements:this.iconElements,inputCallback:d=>a(this,Ze,As).call(this,d),searchCallback:d=>a(this,et,Ns).call(this,d),openCallback:()=>a(this,ot,Is).call(this),closeCallback:()=>a(this,se,At).call(this),keydownCallback:d=>a(this,Qe,Ts).call(this,d),focusCallback:()=>a(this,tt,Os).call(this),blurCallback:()=>a(this,st,Ps).call(this),nameChangeCallback:d=>a(this,nt,Ds).call(this,d)});return this.appendToBody&&b(this,q,new ResizeObserver(()=>this.updateListPosition())),e.append(o.srcElement),{container:e,list:t,input:o}},Ze=new WeakSet,As=function(e){var o,d,u,g,w;const t=wt(e);(o=n(this,h))==null||o.updateValue(t);const s=(u=(d=n(this,h))==null?void 0:d.selectedNodes)==null?void 0:u.nodes,i=(w=(g=n(this,h))==null?void 0:g.selectedNodes)==null?void 0:w.groupedNodes;a(this,W,mt).call(this,{groupedNodes:i,nodes:s}),a(this,le,Nt).call(this)},Qe=new WeakSet,Ts=function(e){var t;this.isListOpened&&((t=n(this,h))==null||t.callKeyAction(e))},et=new WeakSet,Ns=function(e){n(this,$)&&clearTimeout(n(this,$)),b(this,$,setTimeout(()=>{var t;(t=n(this,h))==null||t.updateSearchValue(e),this.updateListPosition()},350))},tt=new WeakSet,Os=function(){a(this,R,ft).call(this,!0),n(this,S)&&n(this,S)&&n(this,V)&&(document.addEventListener("mousedown",n(this,S),!0),document.addEventListener("focus",n(this,S),!0),window.addEventListener("blur",n(this,V)))},st=new WeakSet,Ps=function(){setTimeout(()=>{var s,i;const e=(s=n(this,p))==null?void 0:s.srcElement.contains(document.activeElement),t=(i=n(this,h))==null?void 0:i.srcElement.contains(document.activeElement);!e&&!t&&this.blurWindowHandler()},1)},it=new WeakSet,Bs=function(e){var o,d,u,g;const{groupedNodes:t,nodes:s}=e,i=this.grouped||this.isSingleSelect?t:s;(o=n(this,p))==null||o.updateValue(i),a(this,W,mt).call(this,{groupedNodes:t,nodes:s}),this.isSingleSelect&&!this.alwaysOpen&&((d=n(this,p))==null||d.openClose(),(u=n(this,p))==null||u.clearSearch()),(g=n(this,p))==null||g.focus(),a(this,le,Nt).call(this)},lt=new WeakSet,Vs=function(){var e;(e=n(this,p))==null||e.focus(),this.updateListPosition()},nt=new WeakSet,Ds=function(e){this.selectedName!==e&&(this.selectedName=e,a(this,ct,Ms).call(this))},ot=new WeakSet,Is=function(){var e;this.isListOpened=!0,n(this,A)&&n(this,T)&&(window.addEventListener("scroll",n(this,A),!0),window.addEventListener("resize",n(this,T))),!(!n(this,h)||!this.srcElement)&&(this.appendToBody?(document.body.appendChild(n(this,h).srcElement),(e=n(this,q))==null||e.observe(this.srcElement)):this.srcElement.appendChild(n(this,h).srcElement),this.updateListPosition(),a(this,ie,Tt).call(this,!0),a(this,rt,Gs).call(this),a(this,dt,Fs).call(this))},se=new WeakSet,At=function(){var t;this.alwaysOpen||(this.isListOpened=!1,n(this,A)&&n(this,T)&&(window.removeEventListener("scroll",n(this,A),!0),window.removeEventListener("resize",n(this,T))),!n(this,h)||!this.srcElement)||!(this.appendToBody?document.body.contains(n(this,h).srcElement):this.srcElement.contains(n(this,h).srcElement))||(b(this,ee,n(this,h).srcElement.scrollTop),this.appendToBody?(document.body.removeChild(n(this,h).srcElement),(t=n(this,q))==null||t.disconnect()):this.srcElement.removeChild(n(this,h).srcElement),a(this,ie,Tt).call(this,!1),a(this,ht,js).call(this))},at=new WeakSet,Hs=function(e,t){if(!n(this,h)||!n(this,p))return;const s=t?"treeselect-list--top-to-body":"treeselect-list--top",i=t?"treeselect-list--bottom-to-body":"treeselect-list--bottom";e?(n(this,h).srcElement.classList.add(s),n(this,h).srcElement.classList.remove(i),n(this,p).srcElement.classList.add("treeselect-input--top"),n(this,p).srcElement.classList.remove("treeselect-input--bottom")):(n(this,h).srcElement.classList.remove(s),n(this,h).srcElement.classList.add(i),n(this,p).srcElement.classList.remove("treeselect-input--top"),n(this,p).srcElement.classList.add("treeselect-input--bottom"))},R=new WeakSet,ft=function(e){!n(this,p)||!n(this,h)||(e?(n(this,p).srcElement.classList.add("treeselect-input--focused"),n(this,h).srcElement.classList.add("treeselect-list--focused")):(n(this,p).srcElement.classList.remove("treeselect-input--focused"),n(this,h).srcElement.classList.remove("treeselect-list--focused")))},ie=new WeakSet,Tt=function(e){var t,s,i,o;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,h))==null||i.srcElement.classList.add("treeselect-list--static"):(o=n(this,h))==null||o.srcElement.classList.remove("treeselect-list--static")},U=new WeakSet,Ct=function(e){!n(this,A)||!n(this,T)||!n(this,S)||!n(this,V)||((!this.alwaysOpen||e)&&(window.removeEventListener("scroll",n(this,A),!0),window.removeEventListener("resize",n(this,T))),document.removeEventListener("mousedown",n(this,S),!0),document.removeEventListener("focus",n(this,S),!0),window.removeEventListener("blur",n(this,V)))},rt=new WeakSet,Gs=function(){var t,s,i;const e=(t=n(this,h))==null?void 0:t.isLastFocusedElementExist();this.saveScrollPosition&&e?(s=n(this,h))==null||s.srcElement.scroll(0,n(this,ee)):(i=n(this,h))==null||i.focusFirstListElement()},le=new WeakSet,Nt=function(){var e;(e=this.srcElement)==null||e.dispatchEvent(new CustomEvent("input",{detail:this.value})),this.inputCallback&&this.inputCallback(this.value)},ct=new WeakSet,Ms=function(){var e;(e=this.srcElement)==null||e.dispatchEvent(new CustomEvent("name-change",{detail:this.selectedName})),this.nameChangeCallback&&this.nameChangeCallback(this.selectedName)},dt=new WeakSet,Fs=function(){var e;this.alwaysOpen||((e=this.srcElement)==null||e.dispatchEvent(new CustomEvent("open",{detail:this.value})),this.openCallback&&this.openCallback(this.value))},ht=new WeakSet,js=function(){var e;this.alwaysOpen||((e=this.srcElement)==null||e.dispatchEvent(new CustomEvent("close",{detail:this.value})),this.closeCallback&&this.closeCallback(this.value))},fi});
|