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