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