treeselectjs 0.13.3 → 0.14.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 +55 -13
- package/dist/treeselectjs.css +1 -1
- package/dist/treeselectjs.d.ts +79 -2
- package/dist/treeselectjs.mjs +872 -828
- package/dist/treeselectjs.umd.js +1 -1
- package/package.json +15 -10
package/dist/treeselectjs.mjs
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const ve = {
|
|
1
|
+
function c(i, ...e) {
|
|
2
|
+
i && i.classList.add(...e);
|
|
3
|
+
}
|
|
4
|
+
function u(i, ...e) {
|
|
5
|
+
i && i.classList.remove(...e);
|
|
6
|
+
}
|
|
7
|
+
const N = {
|
|
9
8
|
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>',
|
|
10
9
|
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>',
|
|
11
10
|
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>',
|
|
@@ -14,221 +13,240 @@ const ve = {
|
|
|
14
13
|
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>',
|
|
15
14
|
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>',
|
|
16
15
|
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>'
|
|
17
|
-
},
|
|
16
|
+
}, g = (i, e) => {
|
|
18
17
|
if (e.innerHTML = "", typeof i == "string")
|
|
19
18
|
e.innerHTML = i;
|
|
20
19
|
else {
|
|
21
20
|
const t = i.cloneNode(!0);
|
|
22
21
|
e.appendChild(t);
|
|
23
22
|
}
|
|
24
|
-
},
|
|
23
|
+
}, O = (i) => {
|
|
25
24
|
const e = i ? { ...i } : {};
|
|
26
|
-
return Object.keys(
|
|
27
|
-
e[t] || (e[t] =
|
|
25
|
+
return Object.keys(N).forEach((t) => {
|
|
26
|
+
e[t] || (e[t] = N[t]);
|
|
28
27
|
}), e;
|
|
29
|
-
},
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
}, ne = (i) => i.reduce((e, { name: t }, s) => (e += t, s < i.length - 1 && (e += ", "), e), "");
|
|
29
|
+
class ae {
|
|
30
|
+
// Props
|
|
31
|
+
value;
|
|
32
|
+
showTags;
|
|
33
|
+
tagsCountText;
|
|
34
|
+
clearable;
|
|
35
|
+
isAlwaysOpened;
|
|
36
|
+
searchable;
|
|
37
|
+
placeholder;
|
|
38
|
+
disabled;
|
|
39
|
+
isSingleSelect;
|
|
40
|
+
id;
|
|
41
|
+
ariaLabel;
|
|
42
|
+
iconElements;
|
|
43
|
+
// InnerState
|
|
44
|
+
isOpened;
|
|
45
|
+
searchText;
|
|
46
|
+
srcElement;
|
|
47
|
+
// PrivateInnerState
|
|
48
|
+
#e;
|
|
49
|
+
#t;
|
|
50
|
+
#l;
|
|
51
|
+
#s;
|
|
52
|
+
// Callbacks
|
|
53
|
+
inputCallback;
|
|
54
|
+
searchCallback;
|
|
55
|
+
openCallback;
|
|
56
|
+
closeCallback;
|
|
57
|
+
keydownCallback;
|
|
58
|
+
focusCallback;
|
|
59
|
+
nameChangeCallback;
|
|
32
60
|
constructor({
|
|
33
61
|
value: e,
|
|
34
62
|
showTags: t,
|
|
35
63
|
tagsCountText: s,
|
|
36
64
|
clearable: l,
|
|
37
|
-
isAlwaysOpened:
|
|
38
|
-
searchable:
|
|
39
|
-
placeholder:
|
|
40
|
-
disabled:
|
|
41
|
-
isSingleSelect:
|
|
42
|
-
id:
|
|
43
|
-
ariaLabel:
|
|
44
|
-
iconElements:
|
|
45
|
-
inputCallback:
|
|
46
|
-
searchCallback:
|
|
47
|
-
openCallback:
|
|
48
|
-
closeCallback:
|
|
49
|
-
keydownCallback:
|
|
50
|
-
focusCallback:
|
|
51
|
-
nameChangeCallback:
|
|
65
|
+
isAlwaysOpened: n,
|
|
66
|
+
searchable: a,
|
|
67
|
+
placeholder: r,
|
|
68
|
+
disabled: p,
|
|
69
|
+
isSingleSelect: h,
|
|
70
|
+
id: o,
|
|
71
|
+
ariaLabel: d,
|
|
72
|
+
iconElements: m,
|
|
73
|
+
inputCallback: b,
|
|
74
|
+
searchCallback: f,
|
|
75
|
+
openCallback: C,
|
|
76
|
+
closeCallback: E,
|
|
77
|
+
keydownCallback: k,
|
|
78
|
+
focusCallback: w,
|
|
79
|
+
nameChangeCallback: y
|
|
52
80
|
}) {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
c(this, "clearable");
|
|
59
|
-
c(this, "isAlwaysOpened");
|
|
60
|
-
c(this, "searchable");
|
|
61
|
-
c(this, "placeholder");
|
|
62
|
-
c(this, "disabled");
|
|
63
|
-
c(this, "isSingleSelect");
|
|
64
|
-
c(this, "id");
|
|
65
|
-
c(this, "ariaLabel");
|
|
66
|
-
c(this, "iconElements");
|
|
67
|
-
// InnerState
|
|
68
|
-
c(this, "isOpened");
|
|
69
|
-
c(this, "searchText");
|
|
70
|
-
c(this, "srcElement");
|
|
71
|
-
// PrivateInnerState
|
|
72
|
-
g(this, _);
|
|
73
|
-
g(this, S);
|
|
74
|
-
g(this, D);
|
|
75
|
-
g(this, x);
|
|
76
|
-
// Callbacks
|
|
77
|
-
c(this, "inputCallback");
|
|
78
|
-
c(this, "searchCallback");
|
|
79
|
-
c(this, "openCallback");
|
|
80
|
-
c(this, "closeCallback");
|
|
81
|
-
c(this, "keydownCallback");
|
|
82
|
-
c(this, "focusCallback");
|
|
83
|
-
c(this, "nameChangeCallback");
|
|
84
|
-
this.value = e, this.showTags = t, this.tagsCountText = s, this.searchable = u, this.placeholder = f, this.clearable = l, this.isAlwaysOpened = r, this.disabled = w, this.isSingleSelect = k, this.id = E, this.ariaLabel = C, this.iconElements = v, this.isOpened = !1, this.searchText = "", b(this, _, a(this, h, Ie).call(this)), b(this, S, a(this, h, Ve).call(this)), b(this, D, a(this, h, Ge).call(this)), b(this, x, null), this.inputCallback = L, this.searchCallback = T, this.openCallback = N, this.closeCallback = H, this.keydownCallback = W, this.focusCallback = R, this.nameChangeCallback = Q, this.srcElement = a(this, h, Te).call(this, {
|
|
85
|
-
htmlTagsSection: n(this, _),
|
|
86
|
-
htmlEditControl: n(this, S),
|
|
87
|
-
htmlOperators: n(this, D)
|
|
88
|
-
}), a(this, h, Se).call(this);
|
|
81
|
+
this.value = e, this.showTags = t, this.tagsCountText = s, this.searchable = a, this.placeholder = r, this.clearable = l, this.isAlwaysOpened = n, this.disabled = p, this.isSingleSelect = h, this.id = o, this.ariaLabel = d, this.iconElements = m, this.isOpened = !1, this.searchText = "", this.#e = this.#w(), this.#t = this.#S(), this.#l = this.#f(), this.#s = null, this.inputCallback = b, this.searchCallback = f, this.openCallback = C, this.closeCallback = E, this.keydownCallback = k, this.focusCallback = w, this.nameChangeCallback = y, this.srcElement = this.#d({
|
|
82
|
+
htmlTagsSection: this.#e,
|
|
83
|
+
htmlEditControl: this.#t,
|
|
84
|
+
htmlOperators: this.#l
|
|
85
|
+
}), this.#a();
|
|
89
86
|
}
|
|
90
87
|
// Public methods
|
|
91
88
|
focus() {
|
|
92
|
-
setTimeout(() =>
|
|
89
|
+
setTimeout(() => this.#t.focus(), 0);
|
|
93
90
|
}
|
|
94
91
|
blur() {
|
|
95
|
-
this.isOpened &&
|
|
92
|
+
this.isOpened && this.#c(), this.clearSearch(), this.#t.blur();
|
|
96
93
|
}
|
|
97
94
|
updateValue(e) {
|
|
98
|
-
this.value = e,
|
|
95
|
+
this.value = e, this.#i(), this.#n();
|
|
99
96
|
}
|
|
100
97
|
removeItem(e) {
|
|
101
|
-
this.value = this.value.filter((t) => t.id !== e),
|
|
98
|
+
this.value = this.value.filter((t) => t.id !== e), this.#E(), this.#i(), this.#n();
|
|
102
99
|
}
|
|
103
100
|
clear() {
|
|
104
|
-
this.value = [],
|
|
101
|
+
this.value = [], this.#E(), this.#i(), this.clearSearch();
|
|
105
102
|
}
|
|
106
103
|
openClose() {
|
|
107
|
-
|
|
104
|
+
this.#c();
|
|
108
105
|
}
|
|
109
106
|
clearSearch() {
|
|
110
|
-
this.searchText = "", this.searchCallback(""),
|
|
107
|
+
this.searchText = "", this.searchCallback(""), this.#n();
|
|
111
108
|
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
a(this, h, j).call(this), a(this, h, U).call(this), a(this, h, xe).call(this);
|
|
116
|
-
}, j = function() {
|
|
117
|
-
if (n(this, _).innerHTML = "", this.showTags) {
|
|
118
|
-
n(this, _).append(...a(this, h, Ne).call(this));
|
|
119
|
-
const e = Zt(this.value);
|
|
120
|
-
this.nameChangeCallback(e);
|
|
121
|
-
} else {
|
|
122
|
-
const e = a(this, h, Pe).call(this);
|
|
123
|
-
n(this, _).appendChild(e), this.nameChangeCallback(e.innerText);
|
|
124
|
-
}
|
|
125
|
-
n(this, _).appendChild(n(this, S));
|
|
126
|
-
}, xe = function() {
|
|
127
|
-
const e = [];
|
|
128
|
-
n(this, D).innerHTML = "", this.clearable && e.push(a(this, h, Me).call(this)), this.isAlwaysOpened || e.push(a(this, h, Fe).call(this, this.isOpened)), e.length && n(this, D).append(...e);
|
|
129
|
-
}, ye = function() {
|
|
130
|
-
if (!this.isAlwaysOpened && n(this, x)) {
|
|
131
|
-
const e = this.isOpened ? this.iconElements.arrowUp : this.iconElements.arrowDown;
|
|
132
|
-
O(e, n(this, x));
|
|
133
|
-
}
|
|
134
|
-
}, U = function() {
|
|
135
|
-
var e;
|
|
136
|
-
(e = this.value) != null && e.length ? (n(this, S).removeAttribute("placeholder"), this.srcElement.classList.remove("treeselect-input--value-not-selected")) : (n(this, S).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, S).value = this.searchText;
|
|
137
|
-
}, B = function() {
|
|
138
|
-
this.isOpened = !this.isOpened, a(this, h, ye).call(this), this.isOpened ? this.openCallback() : this.closeCallback();
|
|
139
|
-
}, Te = function({
|
|
140
|
-
htmlTagsSection: e,
|
|
141
|
-
htmlEditControl: t,
|
|
142
|
-
htmlOperators: s
|
|
143
|
-
}) {
|
|
144
|
-
const l = document.createElement("div");
|
|
145
|
-
return l.classList.add("treeselect-input"), l.setAttribute("tabindex", "-1"), l.addEventListener("mousedown", (r) => a(this, h, Ae).call(this, r)), l.addEventListener("focus", () => this.focusCallback(), !0), e.appendChild(t), l.append(e, s), l;
|
|
146
|
-
}, Ae = function(e) {
|
|
147
|
-
e.stopPropagation(), this.isOpened || a(this, h, B).call(this), this.focus();
|
|
148
|
-
}, Ie = function() {
|
|
149
|
-
const e = document.createElement("div");
|
|
150
|
-
return e.classList.add("treeselect-input__tags"), e;
|
|
151
|
-
}, Ne = function() {
|
|
152
|
-
return this.value.map((e) => {
|
|
153
|
-
const t = document.createElement("div");
|
|
154
|
-
t.classList.add("treeselect-input__tags-element"), t.setAttribute("tabindex", "-1"), t.setAttribute("tag-id", e.id.toString()), t.setAttribute("title", e.name);
|
|
155
|
-
const s = a(this, h, Oe).call(this, e.name), l = a(this, h, He).call(this);
|
|
156
|
-
return t.addEventListener("mousedown", (r) => a(this, h, _e).call(this, r, e.id)), t.append(s, l), t;
|
|
157
|
-
});
|
|
158
|
-
}, _e = function(e, t) {
|
|
159
|
-
e.preventDefault(), e.stopPropagation(), this.removeItem(t), this.focus();
|
|
160
|
-
}, Oe = function(e) {
|
|
161
|
-
const t = document.createElement("span");
|
|
162
|
-
return t.classList.add("treeselect-input__tags-name"), t.textContent = e, t;
|
|
163
|
-
}, He = function() {
|
|
164
|
-
const e = document.createElement("span");
|
|
165
|
-
return e.classList.add("treeselect-input__tags-cross"), O(this.iconElements.cross, e), e;
|
|
166
|
-
}, Pe = function() {
|
|
167
|
-
const e = document.createElement("span");
|
|
168
|
-
if (e.classList.add("treeselect-input__tags-count"), !this.value.length)
|
|
169
|
-
return e.textContent = "", e.setAttribute("title", ""), e;
|
|
170
|
-
const t = this.value.length === 1 ? this.value[0].name : `${this.value.length} ${this.tagsCountText}`;
|
|
171
|
-
return e.textContent = t, e.setAttribute("title", t), e;
|
|
172
|
-
}, Ve = function() {
|
|
173
|
-
const e = document.createElement("input");
|
|
174
|
-
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) => a(this, h, Be).call(this, t)), e.addEventListener("input", (t) => a(this, h, De).call(this, t, e)), e;
|
|
175
|
-
}, Be = function(e) {
|
|
176
|
-
e.stopPropagation();
|
|
177
|
-
const t = e.key;
|
|
178
|
-
t === "Backspace" && !this.searchText.length && this.value.length && !this.showTags && this.clear(), t === "Backspace" && !this.searchText.length && this.value.length && this.removeItem(this.value[this.value.length - 1].id), e.code === "Space" && (!this.searchText || !this.searchable) && a(this, h, B).call(this), (t === "Enter" || t === "ArrowDown" || t === "ArrowUp") && e.preventDefault(), this.keydownCallback(e), t !== "Tab" && this.focus();
|
|
179
|
-
}, De = function(e, t) {
|
|
180
|
-
e.stopPropagation();
|
|
181
|
-
const s = this.searchText, l = t.value.trim();
|
|
182
|
-
if (s.length === 0 && l.length === 0) {
|
|
183
|
-
t.value = "";
|
|
184
|
-
return;
|
|
109
|
+
// Private methods
|
|
110
|
+
#a() {
|
|
111
|
+
this.#i(), this.#n(), this.#r();
|
|
185
112
|
}
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
}
|
|
210
|
-
|
|
113
|
+
#i() {
|
|
114
|
+
if (this.#e.innerHTML = "", this.showTags) {
|
|
115
|
+
this.#e.append(...this.#k());
|
|
116
|
+
const e = ne(this.value);
|
|
117
|
+
this.nameChangeCallback(e);
|
|
118
|
+
} else {
|
|
119
|
+
const e = this.#L();
|
|
120
|
+
this.#e.appendChild(e), this.nameChangeCallback(e.innerText);
|
|
121
|
+
}
|
|
122
|
+
this.#e.appendChild(this.#t);
|
|
123
|
+
}
|
|
124
|
+
#r() {
|
|
125
|
+
const e = [];
|
|
126
|
+
this.#l.innerHTML = "", this.clearable && e.push(this.#g()), this.isAlwaysOpened || e.push(this.#C(this.isOpened)), e.length && this.#l.append(...e);
|
|
127
|
+
}
|
|
128
|
+
#o() {
|
|
129
|
+
if (!this.isAlwaysOpened && this.#s) {
|
|
130
|
+
const e = this.isOpened ? this.iconElements.arrowUp : this.iconElements.arrowDown;
|
|
131
|
+
g(e, this.#s);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
#n() {
|
|
135
|
+
this.value?.length ? (this.#t.removeAttribute("placeholder"), u(this.srcElement, "treeselect-input--value-not-selected")) : (this.#t.setAttribute("placeholder", this.placeholder), c(this.srcElement, "treeselect-input--value-not-selected")), this.searchable ? u(this.srcElement, "treeselect-input--unsearchable") : c(this.srcElement, "treeselect-input--unsearchable"), this.isSingleSelect ? c(this.srcElement, "treeselect-input--is-single-select") : u(this.srcElement, "treeselect-input--is-single-select"), this.#t.value = this.searchText;
|
|
136
|
+
}
|
|
137
|
+
#c() {
|
|
138
|
+
this.isOpened = !this.isOpened, this.#o(), this.isOpened ? this.openCallback() : this.closeCallback();
|
|
139
|
+
}
|
|
140
|
+
#d({
|
|
141
|
+
htmlTagsSection: e,
|
|
142
|
+
htmlEditControl: t,
|
|
143
|
+
htmlOperators: s
|
|
144
|
+
}) {
|
|
145
|
+
const l = document.createElement("div");
|
|
146
|
+
return l.classList.add("treeselect-input"), l.setAttribute("tabindex", "-1"), l.addEventListener("mousedown", (n) => this.#u(n)), l.addEventListener("focus", () => this.focusCallback(), !0), e.appendChild(t), l.append(e, s), l;
|
|
147
|
+
}
|
|
148
|
+
#u(e) {
|
|
149
|
+
e.stopPropagation(), this.isOpened || this.#c(), this.focus();
|
|
150
|
+
}
|
|
151
|
+
#w() {
|
|
152
|
+
const e = document.createElement("div");
|
|
153
|
+
return e.classList.add("treeselect-input__tags"), e;
|
|
154
|
+
}
|
|
155
|
+
#k() {
|
|
156
|
+
return this.value.map((e) => {
|
|
157
|
+
const t = document.createElement("div");
|
|
158
|
+
t.classList.add("treeselect-input__tags-element"), t.setAttribute("tabindex", "-1"), t.setAttribute("tag-id", e.id.toString()), t.setAttribute("title", e.name);
|
|
159
|
+
const s = this.#m(e.name), l = this.#p();
|
|
160
|
+
return t.addEventListener("mousedown", (n) => this.#v(n, e.id)), t.append(s, l), t;
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
#v(e, t) {
|
|
164
|
+
e.preventDefault(), e.stopPropagation(), this.removeItem(t), this.focus();
|
|
165
|
+
}
|
|
166
|
+
#m(e) {
|
|
167
|
+
const t = document.createElement("span");
|
|
168
|
+
return t.classList.add("treeselect-input__tags-name"), t.textContent = e, t;
|
|
169
|
+
}
|
|
170
|
+
#p() {
|
|
171
|
+
const e = document.createElement("span");
|
|
172
|
+
return e.classList.add("treeselect-input__tags-cross"), g(this.iconElements.cross, e), e;
|
|
173
|
+
}
|
|
174
|
+
#L() {
|
|
175
|
+
const e = document.createElement("span");
|
|
176
|
+
if (e.classList.add("treeselect-input__tags-count"), !this.value.length)
|
|
177
|
+
return e.textContent = "", e.setAttribute("title", ""), e;
|
|
178
|
+
const t = this.value.length === 1 ? this.value[0].name : `${this.value.length} ${this.tagsCountText}`;
|
|
179
|
+
return e.textContent = t, e.setAttribute("title", t), e;
|
|
180
|
+
}
|
|
181
|
+
#S() {
|
|
182
|
+
const e = document.createElement("input");
|
|
183
|
+
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) => this.#x(t)), e.addEventListener("input", (t) => this.#y(t, e)), e;
|
|
184
|
+
}
|
|
185
|
+
#x(e) {
|
|
186
|
+
e.stopPropagation();
|
|
187
|
+
const t = e.key;
|
|
188
|
+
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) && this.#c(), (t === "Enter" || t === "ArrowDown" || t === "ArrowUp") && e.preventDefault(), this.keydownCallback(e), t !== "Tab" && this.focus();
|
|
189
|
+
}
|
|
190
|
+
#y(e, t) {
|
|
191
|
+
e.stopPropagation();
|
|
192
|
+
const s = this.searchText, l = t.value.trim();
|
|
193
|
+
if (s.length === 0 && l.length === 0) {
|
|
194
|
+
t.value = "";
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
if (this.searchable) {
|
|
198
|
+
const n = e.target.value;
|
|
199
|
+
this.searchCallback(n), this.isOpened || this.#c();
|
|
200
|
+
} else
|
|
201
|
+
t.value = "";
|
|
202
|
+
this.searchText = t.value;
|
|
203
|
+
}
|
|
204
|
+
#f() {
|
|
205
|
+
const e = document.createElement("div");
|
|
206
|
+
return e.classList.add("treeselect-input__operators"), e;
|
|
207
|
+
}
|
|
208
|
+
#g() {
|
|
209
|
+
const e = document.createElement("span");
|
|
210
|
+
return e.classList.add("treeselect-input__clear"), e.setAttribute("tabindex", "-1"), g(this.iconElements.clear, e), e.addEventListener("mousedown", (t) => this.#b(t)), e;
|
|
211
|
+
}
|
|
212
|
+
#b(e) {
|
|
213
|
+
e.preventDefault(), e.stopPropagation(), (this.searchText.length || this.value.length) && this.clear(), this.focus();
|
|
214
|
+
}
|
|
215
|
+
#C(e) {
|
|
216
|
+
this.#s = document.createElement("span"), this.#s.classList.add("treeselect-input__arrow");
|
|
217
|
+
const t = e ? this.iconElements.arrowUp : this.iconElements.arrowDown;
|
|
218
|
+
return g(t, this.#s), this.#s.addEventListener("mousedown", (s) => this.#h(s)), this.#s;
|
|
219
|
+
}
|
|
220
|
+
#h(e) {
|
|
221
|
+
e.stopPropagation(), e.preventDefault(), this.focus(), this.#c();
|
|
222
|
+
}
|
|
223
|
+
// Emits
|
|
224
|
+
#E() {
|
|
225
|
+
this.inputCallback(this.value);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
const P = "No results found...", re = "Search...", oe = "elements selected", ce = 350, S = 20, he = 5, D = ({
|
|
211
229
|
newValue: i,
|
|
212
230
|
optionsTreeMap: e,
|
|
213
231
|
isSingleSelect: t,
|
|
214
232
|
isIndependentNodes: s
|
|
215
233
|
}) => {
|
|
216
|
-
|
|
217
|
-
const l = i.map((
|
|
218
|
-
if (t && l.length &&
|
|
219
|
-
|
|
234
|
+
pe(e);
|
|
235
|
+
const l = i.map((a) => e.get(a) ?? null).filter((a) => a !== null && !a.disabled), [n] = l;
|
|
236
|
+
if (t && l.length && n) {
|
|
237
|
+
n.checked = !0;
|
|
220
238
|
return;
|
|
221
239
|
}
|
|
222
|
-
l.forEach((
|
|
223
|
-
|
|
224
|
-
const
|
|
225
|
-
option:
|
|
240
|
+
l.forEach((a) => {
|
|
241
|
+
a.checked = !0;
|
|
242
|
+
const r = T({
|
|
243
|
+
option: a,
|
|
226
244
|
optionsTreeMap: e,
|
|
227
245
|
isIndependentNodes: s
|
|
228
246
|
});
|
|
229
|
-
|
|
247
|
+
a.checked = r;
|
|
230
248
|
});
|
|
231
|
-
},
|
|
249
|
+
}, T = ({
|
|
232
250
|
option: { id: i, checked: e },
|
|
233
251
|
optionsTreeMap: t,
|
|
234
252
|
isIndependentNodes: s
|
|
@@ -238,207 +256,206 @@ const We = ({
|
|
|
238
256
|
return !1;
|
|
239
257
|
if (s)
|
|
240
258
|
return l.checked = !l.disabled && e, l.checked;
|
|
241
|
-
const
|
|
259
|
+
const n = V({
|
|
242
260
|
checked: e,
|
|
243
261
|
currentOption: l,
|
|
244
262
|
optionsTreeMap: t
|
|
245
263
|
});
|
|
246
|
-
return
|
|
264
|
+
return B({
|
|
247
265
|
childOption: l,
|
|
248
266
|
optionsTreeMap: t
|
|
249
|
-
}),
|
|
250
|
-
},
|
|
267
|
+
}), n;
|
|
268
|
+
}, V = ({
|
|
251
269
|
checked: i,
|
|
252
270
|
currentOption: e,
|
|
253
271
|
optionsTreeMap: t
|
|
254
272
|
}) => {
|
|
255
273
|
if (!e.isGroup)
|
|
256
274
|
return e.checked = !e.disabled && i, e.isPartialChecked = !1, e.checked;
|
|
257
|
-
const s =
|
|
258
|
-
return !i || e.disabled || e.isPartialChecked ? (e.checked = !1, e.isPartialChecked = !1,
|
|
275
|
+
const s = v({ id: e.id, optionsTreeMap: t });
|
|
276
|
+
return !i || e.disabled || e.isPartialChecked ? (e.checked = !1, e.isPartialChecked = !1, I({
|
|
259
277
|
option: e,
|
|
260
278
|
children: s,
|
|
261
279
|
optionsTreeMap: t
|
|
262
|
-
}), e.checked) :
|
|
280
|
+
}), e.checked) : G({
|
|
263
281
|
children: s,
|
|
264
282
|
optionsTreeMap: t
|
|
265
|
-
}) ?
|
|
266
|
-
|
|
283
|
+
}) ? M(s) ? (e.checked = !1, e.isPartialChecked = !1, e.disabled = !0, e.checked) : (e.checked = !1, e.isPartialChecked = !0, s.forEach((r) => {
|
|
284
|
+
V({
|
|
267
285
|
checked: i,
|
|
268
|
-
currentOption:
|
|
286
|
+
currentOption: r,
|
|
269
287
|
optionsTreeMap: t
|
|
270
288
|
});
|
|
271
|
-
}), e.checked) : (e.checked = !0, e.isPartialChecked = !1,
|
|
289
|
+
}), e.checked) : (e.checked = !0, e.isPartialChecked = !1, I({
|
|
272
290
|
option: e,
|
|
273
291
|
children: s,
|
|
274
292
|
optionsTreeMap: t
|
|
275
293
|
}), e.checked);
|
|
276
|
-
},
|
|
294
|
+
}, B = ({
|
|
277
295
|
childOption: i,
|
|
278
296
|
optionsTreeMap: e
|
|
279
297
|
}) => {
|
|
280
298
|
const t = e.get(i.childOf) ?? null;
|
|
281
|
-
t !== null && (
|
|
299
|
+
t !== null && (de({ parentOption: t, optionsTreeMap: e }), B({
|
|
282
300
|
childOption: t,
|
|
283
301
|
optionsTreeMap: e
|
|
284
302
|
}));
|
|
285
|
-
},
|
|
303
|
+
}, de = ({
|
|
286
304
|
parentOption: i,
|
|
287
305
|
optionsTreeMap: e
|
|
288
306
|
}) => {
|
|
289
|
-
const t =
|
|
290
|
-
if (
|
|
307
|
+
const t = v({ id: i.id, optionsTreeMap: e });
|
|
308
|
+
if (M(t)) {
|
|
291
309
|
i.checked = !1, i.isPartialChecked = !1, i.disabled = !0;
|
|
292
310
|
return;
|
|
293
311
|
}
|
|
294
|
-
if (
|
|
312
|
+
if (ue(t)) {
|
|
295
313
|
i.checked = !0, i.isPartialChecked = !1;
|
|
296
314
|
return;
|
|
297
315
|
}
|
|
298
|
-
if (
|
|
316
|
+
if (me(t)) {
|
|
299
317
|
i.checked = !1, i.isPartialChecked = !0;
|
|
300
318
|
return;
|
|
301
319
|
}
|
|
302
320
|
i.checked = !1, i.isPartialChecked = !1;
|
|
303
|
-
},
|
|
321
|
+
}, I = ({
|
|
304
322
|
option: { checked: i, disabled: e },
|
|
305
323
|
children: t,
|
|
306
324
|
optionsTreeMap: s
|
|
307
325
|
}) => {
|
|
308
326
|
t.forEach((l) => {
|
|
309
327
|
l.disabled = e || l.disabled, l.checked = i && !l.disabled, l.isPartialChecked = !1;
|
|
310
|
-
const
|
|
311
|
-
|
|
328
|
+
const n = v({ id: l.id, optionsTreeMap: s });
|
|
329
|
+
I({
|
|
312
330
|
option: { checked: i, disabled: e },
|
|
313
|
-
children:
|
|
331
|
+
children: n,
|
|
314
332
|
optionsTreeMap: s
|
|
315
333
|
});
|
|
316
334
|
});
|
|
317
|
-
},
|
|
335
|
+
}, G = ({
|
|
318
336
|
children: i,
|
|
319
337
|
optionsTreeMap: e
|
|
320
338
|
}) => i.some((s) => s.disabled) ? !0 : i.some((s) => {
|
|
321
339
|
if (!s.isGroup)
|
|
322
340
|
return !1;
|
|
323
|
-
const l =
|
|
324
|
-
return
|
|
325
|
-
}),
|
|
341
|
+
const l = v({ id: s.id, optionsTreeMap: e });
|
|
342
|
+
return G({ children: l, optionsTreeMap: e });
|
|
343
|
+
}), M = (i) => i.every((e) => !!e.disabled), ue = (i) => i.every((e) => e.checked), me = (i) => i.some((e) => e.checked || e.isPartialChecked), pe = (i) => {
|
|
326
344
|
i.forEach((e) => {
|
|
327
345
|
e.checked = !1, e.isPartialChecked = !1;
|
|
328
346
|
});
|
|
329
|
-
},
|
|
347
|
+
}, fe = ({
|
|
330
348
|
options: i,
|
|
331
349
|
openLevel: e,
|
|
332
350
|
isIndependentNodes: t
|
|
333
351
|
}) => {
|
|
334
352
|
const s = { level: 0, groupId: "" }, l = /* @__PURE__ */ new Map();
|
|
335
|
-
return
|
|
353
|
+
return F({
|
|
336
354
|
optionsTreeMap: l,
|
|
337
355
|
options: i,
|
|
338
356
|
openLevel: e,
|
|
339
357
|
groupId: s.groupId,
|
|
340
358
|
level: s.level
|
|
341
|
-
}),
|
|
342
|
-
},
|
|
359
|
+
}), Ce({ optionsTreeMap: l, isIndependentNodes: t }), l;
|
|
360
|
+
}, F = ({
|
|
343
361
|
optionsTreeMap: i,
|
|
344
362
|
options: e,
|
|
345
363
|
openLevel: t,
|
|
346
364
|
groupId: s,
|
|
347
365
|
level: l
|
|
348
366
|
}) => {
|
|
349
|
-
e.forEach((
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
name: r.name,
|
|
367
|
+
e.forEach((n) => {
|
|
368
|
+
const a = (n.children?.length ?? 0) > 0, r = l >= t && a, p = l > t, h = n.children?.map((d) => d.value) ?? [], o = n.value;
|
|
369
|
+
i.has(o) && console.error(
|
|
370
|
+
`Validation: You have duplicated option value: ${o}! You should use unique values. Duplicates will lead to unexpected behavior.`
|
|
371
|
+
), i.set(o, {
|
|
372
|
+
id: o,
|
|
373
|
+
name: n.name,
|
|
357
374
|
childOf: s,
|
|
358
|
-
isGroup:
|
|
375
|
+
isGroup: a,
|
|
359
376
|
checked: !1,
|
|
360
377
|
isPartialChecked: !1,
|
|
361
378
|
level: l,
|
|
362
|
-
isClosed:
|
|
363
|
-
hidden:
|
|
364
|
-
disabled:
|
|
365
|
-
isGroupSelectable: !
|
|
366
|
-
children:
|
|
379
|
+
isClosed: r,
|
|
380
|
+
hidden: p,
|
|
381
|
+
disabled: n.disabled ?? !1,
|
|
382
|
+
isGroupSelectable: !a || (n.isGroupSelectable ?? !0),
|
|
383
|
+
children: h,
|
|
367
384
|
// Html elements will be added during their creation
|
|
368
385
|
checkboxHtmlElement: null,
|
|
369
386
|
itemHtmlElement: null,
|
|
370
387
|
arrowItemHtmlElement: null,
|
|
371
388
|
checkboxIconHtmlElement: null
|
|
372
|
-
}),
|
|
389
|
+
}), a && F({
|
|
373
390
|
optionsTreeMap: i,
|
|
374
|
-
options:
|
|
391
|
+
options: n.children,
|
|
375
392
|
openLevel: t,
|
|
376
|
-
groupId:
|
|
393
|
+
groupId: o,
|
|
377
394
|
level: l + 1
|
|
378
395
|
});
|
|
379
396
|
});
|
|
380
|
-
},
|
|
397
|
+
}, ge = (i, e) => i === null ? null : e.get(i) ?? e.get(parseInt(i)) ?? null, v = ({
|
|
381
398
|
id: i,
|
|
382
399
|
optionsTreeMap: e
|
|
383
400
|
}) => {
|
|
384
401
|
const t = e.get(i) ?? null;
|
|
385
402
|
return t === null ? [] : t.children.reduce((s, l) => {
|
|
386
|
-
const
|
|
387
|
-
return
|
|
403
|
+
const n = e.get(l) ?? null;
|
|
404
|
+
return n !== null && s.push(n), s;
|
|
388
405
|
}, []);
|
|
389
|
-
},
|
|
406
|
+
}, be = (i) => {
|
|
390
407
|
const e = [], t = [], s = [];
|
|
391
|
-
i.forEach((
|
|
392
|
-
|
|
408
|
+
i.forEach((n) => {
|
|
409
|
+
n.checked && (s.push(n), n.isGroup ? t.push(n) : e.push(n));
|
|
393
410
|
});
|
|
394
|
-
const l = s.filter((
|
|
411
|
+
const l = s.filter((n) => !t.some(({ id: a }) => a === n.childOf));
|
|
395
412
|
return { ungroupedNodes: e, groupedNodes: l, allNodes: s };
|
|
396
|
-
},
|
|
413
|
+
}, Ce = ({
|
|
397
414
|
optionsTreeMap: i,
|
|
398
415
|
isIndependentNodes: e
|
|
399
416
|
}) => {
|
|
400
417
|
const t = [];
|
|
401
418
|
i.forEach((s) => {
|
|
402
419
|
s.disabled && t.push(s);
|
|
403
|
-
}), t.forEach(
|
|
404
|
-
({
|
|
420
|
+
}), t.forEach(({ id: s }) => {
|
|
421
|
+
T({
|
|
405
422
|
option: { id: s, checked: !1 },
|
|
406
423
|
optionsTreeMap: i,
|
|
407
424
|
isIndependentNodes: e
|
|
408
|
-
})
|
|
409
|
-
);
|
|
410
|
-
}, X = (i, { id: e, isClosed: t }) => {
|
|
411
|
-
K({ id: e, optionsTreeMap: i }).forEach((l) => {
|
|
412
|
-
l.hidden = t ?? !1, l.isGroup && !l.isClosed && X(i, { id: l.id, isClosed: t });
|
|
425
|
+
});
|
|
413
426
|
});
|
|
414
|
-
},
|
|
427
|
+
}, L = (i, { id: e, isClosed: t }) => {
|
|
428
|
+
v({ id: e, optionsTreeMap: i }).forEach((l) => {
|
|
429
|
+
l.hidden = t ?? !1, l.isGroup && !l.isClosed && L(i, { id: l.id, isClosed: t });
|
|
430
|
+
});
|
|
431
|
+
}, Ee = (i, e) => {
|
|
415
432
|
if (e) {
|
|
416
|
-
|
|
433
|
+
we(i);
|
|
417
434
|
return;
|
|
418
435
|
}
|
|
419
436
|
i.forEach((t) => {
|
|
420
|
-
t.checked &&
|
|
437
|
+
t.checked && A(t.childOf, i), t.isGroup && !t.disabled && (t.checked || t.isPartialChecked) && (t.isClosed = !1, L(i, t));
|
|
421
438
|
});
|
|
422
|
-
},
|
|
439
|
+
}, we = (i) => {
|
|
423
440
|
let e = null;
|
|
424
441
|
for (const [t, s] of i)
|
|
425
442
|
if (s.checked && !s.disabled) {
|
|
426
443
|
e = s;
|
|
427
444
|
break;
|
|
428
445
|
}
|
|
429
|
-
e && (e.isGroup && (e.isClosed = !1,
|
|
430
|
-
},
|
|
446
|
+
e && (e.isGroup && (e.isClosed = !1, L(i, e)), A(e.childOf, i));
|
|
447
|
+
}, A = (i, e) => {
|
|
431
448
|
const t = e.get(i) ?? null;
|
|
432
|
-
t && (t.isClosed = !1,
|
|
433
|
-
},
|
|
449
|
+
t && (t.isClosed = !1, L(e, t), A(t.childOf, e));
|
|
450
|
+
}, ke = (i, e) => {
|
|
434
451
|
i.forEach((t) => {
|
|
435
452
|
const s = t.name.toLowerCase().includes(e.toLowerCase());
|
|
436
|
-
s && (t.isGroup && (t.isClosed = !0), t.childOf &&
|
|
453
|
+
s && (t.isGroup && (t.isClosed = !0), t.childOf && R(t.childOf, i)), t.hidden = !s;
|
|
437
454
|
});
|
|
438
|
-
},
|
|
455
|
+
}, R = (i, e) => {
|
|
439
456
|
const t = e.get(i) ?? null;
|
|
440
|
-
t && (t.hidden = !1, t.isClosed = !1,
|
|
441
|
-
},
|
|
457
|
+
t && (t.hidden = !1, t.isClosed = !1, R(t.childOf, e));
|
|
458
|
+
}, ve = ({
|
|
442
459
|
optionsTreeMap: i,
|
|
443
460
|
beforeSearchStateMap: e
|
|
444
461
|
}) => {
|
|
@@ -446,7 +463,7 @@ const We = ({
|
|
|
446
463
|
const s = e.get(t.id);
|
|
447
464
|
s && (t.hidden = s.hidden, t.isClosed = s.isClosed);
|
|
448
465
|
}), e.clear();
|
|
449
|
-
},
|
|
466
|
+
}, Le = ({
|
|
450
467
|
optionsTreeMap: i,
|
|
451
468
|
beforeSearchStateMap: e
|
|
452
469
|
}) => {
|
|
@@ -456,45 +473,45 @@ const We = ({
|
|
|
456
473
|
isClosed: t.isClosed
|
|
457
474
|
});
|
|
458
475
|
});
|
|
459
|
-
},
|
|
476
|
+
}, Se = (i) => new IntersectionObserver(
|
|
460
477
|
(e) => {
|
|
461
478
|
e.forEach((t) => {
|
|
462
479
|
t.target.classList.toggle("treeselect-list__item--scroll-not-visible", !t.isIntersecting);
|
|
463
480
|
});
|
|
464
481
|
},
|
|
465
482
|
{ root: i, threshold: 0.5 }
|
|
466
|
-
),
|
|
483
|
+
), xe = ({
|
|
467
484
|
optionsTreeMap: i,
|
|
468
485
|
emptyListHtmlElement: e,
|
|
469
486
|
iconElements: t,
|
|
470
487
|
previousSingleSelectedValue: s,
|
|
471
488
|
rtl: l
|
|
472
489
|
}) => {
|
|
473
|
-
i.forEach((
|
|
474
|
-
const
|
|
475
|
-
|
|
476
|
-
}),
|
|
477
|
-
},
|
|
490
|
+
i.forEach((n) => {
|
|
491
|
+
const a = n.checkboxHtmlElement;
|
|
492
|
+
a && (a.checked = n.checked), Ae({ option: n, previousSingleSelectedValue: s }), _e(n), Ne(n), Oe({ option: n, iconElements: t }), He(n), ye({ option: n, optionsTreeMap: i, rtl: l }), Pe({ option: n, iconElements: t }), De(n);
|
|
493
|
+
}), Ie({ optionsTreeMap: i, emptyListHtmlElement: e });
|
|
494
|
+
}, ye = ({
|
|
478
495
|
option: i,
|
|
479
496
|
optionsTreeMap: e,
|
|
480
497
|
rtl: t
|
|
481
498
|
}) => {
|
|
482
|
-
const s = i.level === 0
|
|
483
|
-
let
|
|
499
|
+
const s = i.level === 0;
|
|
500
|
+
let l = "0";
|
|
484
501
|
if (s) {
|
|
485
|
-
let
|
|
486
|
-
for (const [
|
|
487
|
-
if (
|
|
488
|
-
|
|
502
|
+
let a = !1;
|
|
503
|
+
for (const [p, h] of e)
|
|
504
|
+
if (h.isGroup && h.level === i.level) {
|
|
505
|
+
a = !0;
|
|
489
506
|
break;
|
|
490
507
|
}
|
|
491
|
-
const
|
|
492
|
-
|
|
508
|
+
const r = !i.isGroup && a ? `${S}px` : `${he}px`;
|
|
509
|
+
l = i.isGroup ? "0" : r;
|
|
493
510
|
} else
|
|
494
|
-
|
|
495
|
-
const
|
|
496
|
-
|
|
497
|
-
},
|
|
511
|
+
l = i.isGroup ? `${i.level * S}px` : `${i.level * S + S}px`;
|
|
512
|
+
const n = i.itemHtmlElement;
|
|
513
|
+
n && (t ? n.style.paddingRight = l : n.style.paddingLeft = l, n.setAttribute("level", i.level.toString()), n.setAttribute("group", i.isGroup.toString()));
|
|
514
|
+
}, Ie = ({
|
|
498
515
|
optionsTreeMap: i,
|
|
499
516
|
emptyListHtmlElement: e
|
|
500
517
|
}) => {
|
|
@@ -504,690 +521,717 @@ const We = ({
|
|
|
504
521
|
t = !0;
|
|
505
522
|
break;
|
|
506
523
|
}
|
|
507
|
-
e
|
|
508
|
-
},
|
|
524
|
+
e?.classList.toggle("treeselect-list__empty--hidden", t);
|
|
525
|
+
}, Te = (i, e) => {
|
|
509
526
|
e && Object.keys(e).forEach((t) => {
|
|
510
527
|
const s = e[t];
|
|
511
528
|
typeof s == "string" && i.setAttribute(t, s);
|
|
512
529
|
});
|
|
513
|
-
},
|
|
530
|
+
}, Ae = ({
|
|
514
531
|
option: i,
|
|
515
532
|
previousSingleSelectedValue: e
|
|
516
533
|
}) => {
|
|
517
534
|
const t = i.itemHtmlElement;
|
|
518
|
-
t
|
|
535
|
+
t?.classList.toggle("treeselect-list__item--checked", i.checked);
|
|
519
536
|
const s = Array.isArray(e) && e[0] === i.id && !i.disabled;
|
|
520
|
-
t
|
|
521
|
-
},
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
e == null || e.classList.toggle("treeselect-list__item--disabled", i.disabled);
|
|
527
|
-
}, ws = ({ option: i, iconElements: e }) => {
|
|
537
|
+
t?.classList.toggle("treeselect-list__item--single-selected", s);
|
|
538
|
+
}, _e = (i) => {
|
|
539
|
+
i.itemHtmlElement?.classList.toggle("treeselect-list__item--partial-checked", i.isPartialChecked);
|
|
540
|
+
}, Ne = (i) => {
|
|
541
|
+
i.itemHtmlElement?.classList.toggle("treeselect-list__item--disabled", i.disabled);
|
|
542
|
+
}, Oe = ({ option: i, iconElements: e }) => {
|
|
528
543
|
const t = i.arrowItemHtmlElement;
|
|
529
544
|
if (i.isGroup && t) {
|
|
530
545
|
const s = i.isClosed ? e.arrowRight : e.arrowDown;
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
},
|
|
536
|
-
const e = i.itemHtmlElement;
|
|
537
|
-
e == null || e.classList.toggle("treeselect-list__item--hidden", i.hidden);
|
|
538
|
-
}, ks = ({ option: i, iconElements: e }) => {
|
|
546
|
+
g(s, t), i.itemHtmlElement?.classList.toggle("treeselect-list__item--closed", i.isClosed);
|
|
547
|
+
}
|
|
548
|
+
}, He = (i) => {
|
|
549
|
+
i.itemHtmlElement?.classList.toggle("treeselect-list__item--hidden", i.hidden);
|
|
550
|
+
}, Pe = ({ option: i, iconElements: e }) => {
|
|
539
551
|
const t = i.checkboxIconHtmlElement;
|
|
540
|
-
t && (i.checked ?
|
|
541
|
-
},
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
}, Ss = ({
|
|
552
|
+
t && (i.checked ? g(e.check, t) : i.isPartialChecked ? g(e.partialCheck, t) : t.innerHTML = "");
|
|
553
|
+
}, De = (i) => {
|
|
554
|
+
i.itemHtmlElement?.classList.toggle("treeselect-list__item--non-selectable-group", !i.isGroupSelectable);
|
|
555
|
+
}, Ve = ({
|
|
545
556
|
newValue: i,
|
|
546
557
|
optionsTreeMap: e,
|
|
547
558
|
isSingleSelect: t,
|
|
548
559
|
expandSelected: s,
|
|
549
560
|
isFirstValueUpdate: l,
|
|
550
|
-
isIndependentNodes:
|
|
561
|
+
isIndependentNodes: n
|
|
551
562
|
}) => {
|
|
552
|
-
|
|
563
|
+
D({
|
|
553
564
|
newValue: i,
|
|
554
565
|
optionsTreeMap: e,
|
|
555
566
|
isSingleSelect: t,
|
|
556
|
-
isIndependentNodes:
|
|
557
|
-
}), l && s &&
|
|
567
|
+
isIndependentNodes: n
|
|
568
|
+
}), l && s && Ee(e, t);
|
|
558
569
|
};
|
|
559
|
-
|
|
560
|
-
|
|
570
|
+
class Be {
|
|
571
|
+
// Props
|
|
572
|
+
options;
|
|
573
|
+
value;
|
|
574
|
+
openLevel;
|
|
575
|
+
listSlotHtmlComponent;
|
|
576
|
+
tagsSortFn;
|
|
577
|
+
emptyText;
|
|
578
|
+
isSingleSelect;
|
|
579
|
+
showCount;
|
|
580
|
+
disabledBranchNode;
|
|
581
|
+
expandSelected;
|
|
582
|
+
isIndependentNodes;
|
|
583
|
+
rtl;
|
|
584
|
+
listClassName;
|
|
585
|
+
isBoostedRendering;
|
|
586
|
+
iconElements;
|
|
587
|
+
// InnerState
|
|
588
|
+
searchText;
|
|
589
|
+
intersectionItemsObserver;
|
|
590
|
+
selectedNodes;
|
|
591
|
+
optionsTreeMap;
|
|
592
|
+
beforeSearchStateMap;
|
|
593
|
+
emptyListHtmlElement;
|
|
594
|
+
srcElement;
|
|
595
|
+
// Callbacks
|
|
596
|
+
inputCallback;
|
|
597
|
+
arrowClickCallback;
|
|
598
|
+
mouseupCallback;
|
|
599
|
+
// PrivateInnerState
|
|
600
|
+
#e = null;
|
|
601
|
+
#t = !0;
|
|
602
|
+
#l = [];
|
|
603
|
+
#s = !0;
|
|
561
604
|
constructor({
|
|
562
605
|
options: e,
|
|
563
606
|
value: t,
|
|
564
607
|
openLevel: s,
|
|
565
608
|
listSlotHtmlComponent: l,
|
|
566
|
-
tagsSortFn:
|
|
567
|
-
emptyText:
|
|
568
|
-
isSingleSelect:
|
|
569
|
-
iconElements:
|
|
570
|
-
showCount:
|
|
571
|
-
disabledBranchNode:
|
|
572
|
-
expandSelected:
|
|
573
|
-
isIndependentNodes:
|
|
574
|
-
rtl:
|
|
575
|
-
listClassName:
|
|
576
|
-
isBoostedRendering:
|
|
577
|
-
inputCallback:
|
|
578
|
-
arrowClickCallback:
|
|
579
|
-
mouseupCallback:
|
|
609
|
+
tagsSortFn: n,
|
|
610
|
+
emptyText: a,
|
|
611
|
+
isSingleSelect: r,
|
|
612
|
+
iconElements: p,
|
|
613
|
+
showCount: h,
|
|
614
|
+
disabledBranchNode: o,
|
|
615
|
+
expandSelected: d,
|
|
616
|
+
isIndependentNodes: m,
|
|
617
|
+
rtl: b,
|
|
618
|
+
listClassName: f,
|
|
619
|
+
isBoostedRendering: C,
|
|
620
|
+
inputCallback: E,
|
|
621
|
+
arrowClickCallback: k,
|
|
622
|
+
mouseupCallback: w
|
|
580
623
|
}) {
|
|
581
|
-
|
|
582
|
-
// Props
|
|
583
|
-
c(this, "options");
|
|
584
|
-
c(this, "value");
|
|
585
|
-
c(this, "openLevel");
|
|
586
|
-
c(this, "listSlotHtmlComponent");
|
|
587
|
-
c(this, "tagsSortFn");
|
|
588
|
-
c(this, "emptyText");
|
|
589
|
-
c(this, "isSingleSelect");
|
|
590
|
-
c(this, "showCount");
|
|
591
|
-
c(this, "disabledBranchNode");
|
|
592
|
-
c(this, "expandSelected");
|
|
593
|
-
c(this, "isIndependentNodes");
|
|
594
|
-
c(this, "rtl");
|
|
595
|
-
c(this, "listClassName");
|
|
596
|
-
c(this, "isBoostedRendering");
|
|
597
|
-
c(this, "iconElements");
|
|
598
|
-
// InnerState
|
|
599
|
-
c(this, "searchText");
|
|
600
|
-
c(this, "intersectionItemsObserver");
|
|
601
|
-
c(this, "selectedNodes");
|
|
602
|
-
c(this, "optionsTreeMap");
|
|
603
|
-
c(this, "beforeSearchStateMap");
|
|
604
|
-
c(this, "emptyListHtmlElement");
|
|
605
|
-
c(this, "srcElement");
|
|
606
|
-
// Callbacks
|
|
607
|
-
c(this, "inputCallback");
|
|
608
|
-
c(this, "arrowClickCallback");
|
|
609
|
-
c(this, "mouseupCallback");
|
|
610
|
-
// PrivateInnerState
|
|
611
|
-
g(this, G, null);
|
|
612
|
-
g(this, P, !0);
|
|
613
|
-
g(this, M, []);
|
|
614
|
-
g(this, Y, !0);
|
|
615
|
-
this.options = e, this.value = t, this.openLevel = s ?? 0, this.listSlotHtmlComponent = l ?? null, this.tagsSortFn = r ?? null, this.emptyText = u ?? "No results found...", this.isSingleSelect = f ?? !1, this.showCount = k ?? !1, this.disabledBranchNode = E ?? !1, this.expandSelected = C ?? !1, this.isIndependentNodes = v ?? !1, this.rtl = L ?? !1, this.listClassName = T ?? "", this.isBoostedRendering = N, this.iconElements = w, this.searchText = "", this.intersectionItemsObserver = null, this.selectedNodes = { nodes: [], groupedNodes: [], allNodes: [] }, this.optionsTreeMap = is({
|
|
624
|
+
this.options = e, this.value = t, this.openLevel = s ?? 0, this.listSlotHtmlComponent = l ?? null, this.tagsSortFn = n ?? null, this.emptyText = a ?? P, this.isSingleSelect = r ?? !1, this.showCount = h ?? !1, this.disabledBranchNode = o ?? !1, this.expandSelected = d ?? !1, this.isIndependentNodes = m ?? !1, this.rtl = b ?? !1, this.listClassName = f ?? "", this.isBoostedRendering = C, this.iconElements = p, this.searchText = "", this.intersectionItemsObserver = null, this.selectedNodes = { nodes: [], groupedNodes: [], allNodes: [] }, this.optionsTreeMap = fe({
|
|
616
625
|
options: this.options,
|
|
617
626
|
openLevel: this.openLevel,
|
|
618
627
|
isIndependentNodes: this.isIndependentNodes
|
|
619
|
-
}), this.beforeSearchStateMap = /* @__PURE__ */ new Map(), this.emptyListHtmlElement = null, this.srcElement =
|
|
628
|
+
}), this.beforeSearchStateMap = /* @__PURE__ */ new Map(), this.emptyListHtmlElement = null, this.srcElement = this.#o(), this.inputCallback = E, this.arrowClickCallback = k, this.mouseupCallback = w;
|
|
620
629
|
}
|
|
621
630
|
// Public methods
|
|
622
631
|
updateValue(e) {
|
|
623
|
-
this.value = e,
|
|
632
|
+
this.value = e, this.#l = this.isSingleSelect ? this.value : [], Ve({
|
|
624
633
|
newValue: e,
|
|
625
634
|
optionsTreeMap: this.optionsTreeMap,
|
|
626
635
|
isSingleSelect: this.isSingleSelect,
|
|
627
636
|
expandSelected: this.expandSelected,
|
|
628
|
-
isFirstValueUpdate:
|
|
637
|
+
isFirstValueUpdate: this.#s,
|
|
629
638
|
isIndependentNodes: this.isIndependentNodes
|
|
630
|
-
}), a(
|
|
639
|
+
}), this.#a(), this.#s = !1, this.#_();
|
|
631
640
|
}
|
|
632
641
|
updateSearchValue(e) {
|
|
633
642
|
if (e === this.searchText)
|
|
634
643
|
return;
|
|
635
644
|
const t = this.searchText === "" && e !== "";
|
|
636
|
-
this.searchText = e, t &&
|
|
645
|
+
this.searchText = e, t && Le({
|
|
637
646
|
beforeSearchStateMap: this.beforeSearchStateMap,
|
|
638
647
|
optionsTreeMap: this.optionsTreeMap
|
|
639
|
-
}), this.searchText === "" &&
|
|
648
|
+
}), this.searchText === "" && ve({
|
|
640
649
|
beforeSearchStateMap: this.beforeSearchStateMap,
|
|
641
650
|
optionsTreeMap: this.optionsTreeMap
|
|
642
|
-
}), this.searchText &&
|
|
651
|
+
}), this.searchText && ke(this.optionsTreeMap, e), this.#a(), this.focusFirstListElement();
|
|
643
652
|
}
|
|
644
653
|
callKeyAction(e) {
|
|
645
|
-
|
|
654
|
+
this.#t = !1;
|
|
646
655
|
const t = this.srcElement.querySelector(".treeselect-list__item--focused");
|
|
647
|
-
if (t
|
|
656
|
+
if (t?.classList.contains("treeselect-list__item--hidden"))
|
|
648
657
|
return;
|
|
649
658
|
const l = e.key;
|
|
650
|
-
l === "Enter" && t && t.dispatchEvent(new Event("mousedown")), (l === "ArrowLeft" || l === "ArrowRight") &&
|
|
659
|
+
l === "Enter" && t && t.dispatchEvent(new Event("mousedown")), (l === "ArrowLeft" || l === "ArrowRight") && this.#i(t, e), (l === "ArrowDown" || l === "ArrowUp") && this.#r(t, l);
|
|
651
660
|
}
|
|
652
661
|
focusFirstListElement() {
|
|
653
|
-
const e = "treeselect-list__item--focused", t = this.srcElement.querySelector(`.${e}`), s =
|
|
662
|
+
const e = "treeselect-list__item--focused", t = this.srcElement.querySelector(`.${e}`), s = this.#h();
|
|
654
663
|
if (!s.length)
|
|
655
664
|
return;
|
|
656
|
-
t && t
|
|
665
|
+
t && u(t, e);
|
|
657
666
|
const [l] = s;
|
|
658
|
-
l
|
|
667
|
+
c(l, e);
|
|
659
668
|
}
|
|
660
669
|
isLastFocusedElementExist() {
|
|
661
|
-
return !!
|
|
670
|
+
return !!this.#e;
|
|
662
671
|
}
|
|
663
672
|
destroy() {
|
|
664
673
|
this.intersectionItemsObserver && this.intersectionItemsObserver.disconnect();
|
|
665
674
|
}
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
}
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
return;
|
|
679
|
-
const s = t.key, r = e.querySelector(".treeselect-list__item-checkbox").getAttribute("input-id"), u = ls(r, this.optionsTreeMap), f = u.arrowItemHtmlElement;
|
|
680
|
-
s === "ArrowLeft" && !u.isClosed && u.isGroup && (f.dispatchEvent(new Event("mousedown")), t.preventDefault()), s === "ArrowRight" && u.isClosed && u.isGroup && (f.dispatchEvent(new Event("mousedown")), t.preventDefault());
|
|
681
|
-
}, Ze = function(e, t) {
|
|
682
|
-
var r;
|
|
683
|
-
const s = a(this, o, ne).call(this);
|
|
684
|
-
if (!s.length)
|
|
685
|
-
return;
|
|
686
|
-
const l = "treeselect-list__item--focused";
|
|
687
|
-
if (e) {
|
|
688
|
-
const u = s.findIndex((N) => N.classList.contains(l));
|
|
689
|
-
s[u].classList.remove(l);
|
|
690
|
-
const w = t === "ArrowDown" ? u + 1 : u - 1, k = t === "ArrowDown" ? 0 : s.length - 1, E = !s[w], C = s[w] ?? s[k];
|
|
691
|
-
C.classList.add(l);
|
|
692
|
-
const v = this.srcElement.getBoundingClientRect(), L = C.getBoundingClientRect();
|
|
693
|
-
if (E && t === "ArrowDown") {
|
|
694
|
-
this.srcElement.scroll(0, 0);
|
|
675
|
+
// Private methods
|
|
676
|
+
#a() {
|
|
677
|
+
xe({
|
|
678
|
+
optionsTreeMap: this.optionsTreeMap,
|
|
679
|
+
emptyListHtmlElement: this.emptyListHtmlElement,
|
|
680
|
+
iconElements: this.iconElements,
|
|
681
|
+
previousSingleSelectedValue: this.#l,
|
|
682
|
+
rtl: this.rtl
|
|
683
|
+
});
|
|
684
|
+
}
|
|
685
|
+
#i(e, t) {
|
|
686
|
+
if (!e)
|
|
695
687
|
return;
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
688
|
+
const s = t.key, n = (e.querySelector(".treeselect-list__item-checkbox") ?? null)?.getAttribute("input-id") ?? null, a = ge(n, this.optionsTreeMap) ?? null, r = a?.arrowItemHtmlElement ?? null;
|
|
689
|
+
a === null || r === null || (s === "ArrowLeft" && !a.isClosed && a.isGroup && (r.dispatchEvent(new Event("mousedown")), t.preventDefault()), s === "ArrowRight" && a.isClosed && a.isGroup && (r.dispatchEvent(new Event("mousedown")), t.preventDefault()));
|
|
690
|
+
}
|
|
691
|
+
#r(e, t) {
|
|
692
|
+
const s = this.#h();
|
|
693
|
+
if (!s.length)
|
|
699
694
|
return;
|
|
695
|
+
const l = "treeselect-list__item--focused";
|
|
696
|
+
if (e) {
|
|
697
|
+
const n = s.findIndex((f) => f.classList.contains(l)), a = s[n];
|
|
698
|
+
u(a, l);
|
|
699
|
+
const r = t === "ArrowDown" ? n + 1 : n - 1, p = t === "ArrowDown" ? 0 : s.length - 1, h = !s[r], o = s[r] ?? s[p];
|
|
700
|
+
c(o, l);
|
|
701
|
+
const d = this.srcElement.getBoundingClientRect(), m = o.getBoundingClientRect();
|
|
702
|
+
if (h && t === "ArrowDown") {
|
|
703
|
+
this.srcElement.scroll(0, 0);
|
|
704
|
+
return;
|
|
705
|
+
}
|
|
706
|
+
if (h && t === "ArrowUp") {
|
|
707
|
+
this.srcElement.scroll(0, this.srcElement.scrollHeight);
|
|
708
|
+
return;
|
|
709
|
+
}
|
|
710
|
+
const b = this.listSlotHtmlComponent?.clientHeight ?? 0;
|
|
711
|
+
if (d.y + d.height < m.y + m.height + b) {
|
|
712
|
+
this.srcElement.scroll(0, this.srcElement.scrollTop + m.height);
|
|
713
|
+
return;
|
|
714
|
+
}
|
|
715
|
+
if (d.y > m.y) {
|
|
716
|
+
this.srcElement.scroll(0, this.srcElement.scrollTop - m.height);
|
|
717
|
+
return;
|
|
718
|
+
}
|
|
719
|
+
} else {
|
|
720
|
+
const [n] = s;
|
|
721
|
+
c(n, l);
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
#o() {
|
|
725
|
+
const e = this.#n(), t = this.#u(this.options);
|
|
726
|
+
e.append(...t);
|
|
727
|
+
const s = this.#k();
|
|
728
|
+
e.append(s);
|
|
729
|
+
const l = this.#w();
|
|
730
|
+
return l && e.append(l), e;
|
|
731
|
+
}
|
|
732
|
+
#n() {
|
|
733
|
+
const e = document.createElement("div");
|
|
734
|
+
if (e.classList.add("treeselect-list"), this.listClassName.length > 0) {
|
|
735
|
+
const t = this.listClassName.split(" ");
|
|
736
|
+
e.classList.add(...t);
|
|
737
|
+
}
|
|
738
|
+
return this.isSingleSelect && e.classList.add("treeselect-list--single-select"), this.disabledBranchNode && e.classList.add("treeselect-list--disabled-branch-node"), e.addEventListener("mouseout", (t) => this.#c(t)), e.addEventListener("mousemove", () => this.#d()), e.addEventListener("mouseup", () => this.mouseupCallback(), !0), this.isBoostedRendering && (this.intersectionItemsObserver = Se(e)), e;
|
|
739
|
+
}
|
|
740
|
+
#c(e) {
|
|
741
|
+
e.stopPropagation(), this.#e && this.#t && c(this.#e, "treeselect-list__item--focused");
|
|
742
|
+
}
|
|
743
|
+
#d() {
|
|
744
|
+
this.#t = !0;
|
|
745
|
+
}
|
|
746
|
+
#u(e) {
|
|
747
|
+
return e.reduce((t, s) => {
|
|
748
|
+
if (s.children?.length) {
|
|
749
|
+
const n = this.#v(s), a = this.#u(s.children);
|
|
750
|
+
return n.append(...a), t.push(n), t;
|
|
751
|
+
}
|
|
752
|
+
const l = this.#m(s, !1);
|
|
753
|
+
return t.push(l), t;
|
|
754
|
+
}, []);
|
|
755
|
+
}
|
|
756
|
+
#w() {
|
|
757
|
+
if (!this.listSlotHtmlComponent)
|
|
758
|
+
return null;
|
|
759
|
+
const e = document.createElement("div");
|
|
760
|
+
return e.classList.add("treeselect-list__slot"), e.appendChild(this.listSlotHtmlComponent), e;
|
|
761
|
+
}
|
|
762
|
+
#k() {
|
|
763
|
+
const e = document.createElement("div");
|
|
764
|
+
e.classList.add("treeselect-list__empty"), e.setAttribute("title", this.emptyText);
|
|
765
|
+
const t = document.createElement("span");
|
|
766
|
+
t.classList.add("treeselect-list__empty-icon"), g(this.iconElements.attention, t);
|
|
767
|
+
const s = document.createElement("span");
|
|
768
|
+
return s.classList.add("treeselect-list__empty-text"), s.textContent = this.emptyText, e.append(t, s), this.emptyListHtmlElement = e, e;
|
|
769
|
+
}
|
|
770
|
+
#v(e) {
|
|
771
|
+
const t = document.createElement("div");
|
|
772
|
+
t.setAttribute("group-container-id", e.value.toString()), t.classList.add("treeselect-list__group-container");
|
|
773
|
+
const s = this.#m(e, !0);
|
|
774
|
+
return t.appendChild(s), t;
|
|
775
|
+
}
|
|
776
|
+
#m(e, t) {
|
|
777
|
+
const s = this.#p(e);
|
|
778
|
+
if (t) {
|
|
779
|
+
const a = this.#y(e);
|
|
780
|
+
s.appendChild(a), s.classList.add("treeselect-list__item--group");
|
|
700
781
|
}
|
|
701
|
-
const
|
|
702
|
-
|
|
703
|
-
|
|
782
|
+
const l = this.#g(e), n = this.#b(e, t);
|
|
783
|
+
return s.append(l, n), s;
|
|
784
|
+
}
|
|
785
|
+
#p(e) {
|
|
786
|
+
const t = document.createElement("div");
|
|
787
|
+
t.setAttribute("tabindex", "-1"), t.setAttribute("title", e.name), Te(t, e.htmlAttr), t.classList.add("treeselect-list__item"), t.addEventListener("mouseover", () => this.#L(t), !0), t.addEventListener("mouseout", () => this.#S(t), !0), t.addEventListener("mousedown", (l) => this.#x(l, e)), this.intersectionItemsObserver && this.intersectionItemsObserver.observe(t);
|
|
788
|
+
const s = this.optionsTreeMap.get(e.value);
|
|
789
|
+
return s && (s.itemHtmlElement = t), t;
|
|
790
|
+
}
|
|
791
|
+
#L(e) {
|
|
792
|
+
this.#t && this.#A(!0, e);
|
|
793
|
+
}
|
|
794
|
+
#S(e) {
|
|
795
|
+
this.#t && (this.#A(!1, e), this.#e = e);
|
|
796
|
+
}
|
|
797
|
+
#x(e, t) {
|
|
798
|
+
e.preventDefault(), e.stopPropagation();
|
|
799
|
+
const s = this.optionsTreeMap.get(t.value) ?? null;
|
|
800
|
+
if (s?.disabled)
|
|
704
801
|
return;
|
|
802
|
+
const l = s?.checkboxHtmlElement;
|
|
803
|
+
l && (l.checked = !l.checked, this.#E(l, t));
|
|
804
|
+
}
|
|
805
|
+
#y(e) {
|
|
806
|
+
const t = document.createElement("span");
|
|
807
|
+
t.setAttribute("tabindex", "-1"), t.classList.add("treeselect-list__item-icon"), g(this.iconElements.arrowDown, t), t.addEventListener("mousedown", (l) => this.#f(l, e));
|
|
808
|
+
const s = this.optionsTreeMap.get(e.value);
|
|
809
|
+
return s && (s.arrowItemHtmlElement = t), t;
|
|
810
|
+
}
|
|
811
|
+
#f(e, t) {
|
|
812
|
+
e.preventDefault(), e.stopPropagation(), this.#T(t);
|
|
813
|
+
}
|
|
814
|
+
#g(e) {
|
|
815
|
+
const t = document.createElement("div");
|
|
816
|
+
t.classList.add("treeselect-list__item-checkbox-container");
|
|
817
|
+
const s = document.createElement("span");
|
|
818
|
+
s.classList.add("treeselect-list__item-checkbox-icon"), s.innerHTML = "";
|
|
819
|
+
const l = document.createElement("input");
|
|
820
|
+
l.setAttribute("tabindex", "-1"), l.setAttribute("type", "checkbox"), l.setAttribute("input-id", e.value.toString()), l.classList.add("treeselect-list__item-checkbox"), t.append(s, l);
|
|
821
|
+
const n = this.optionsTreeMap.get(e.value);
|
|
822
|
+
return n && (n.checkboxHtmlElement = l, n.checkboxIconHtmlElement = s), t;
|
|
823
|
+
}
|
|
824
|
+
#b(e, t) {
|
|
825
|
+
const s = document.createElement("label");
|
|
826
|
+
if (s.textContent = e.name, s.classList.add("treeselect-list__item-label"), t && this.showCount) {
|
|
827
|
+
const l = this.#C(e);
|
|
828
|
+
s.appendChild(l);
|
|
705
829
|
}
|
|
706
|
-
|
|
707
|
-
|
|
830
|
+
return s;
|
|
831
|
+
}
|
|
832
|
+
#C(e) {
|
|
833
|
+
const t = document.createElement("span"), s = this.optionsTreeMap.get(e.value)?.children ?? [];
|
|
834
|
+
return t.textContent = `(${s.length})`, t.classList.add("treeselect-list__item-label-counter"), t;
|
|
835
|
+
}
|
|
836
|
+
#h() {
|
|
837
|
+
const e = [];
|
|
838
|
+
return this.optionsTreeMap.forEach((t) => {
|
|
839
|
+
!t.hidden && t.itemHtmlElement && e.push(t.itemHtmlElement);
|
|
840
|
+
}), e;
|
|
841
|
+
}
|
|
842
|
+
// Actions
|
|
843
|
+
#E(e, t) {
|
|
844
|
+
const s = this.optionsTreeMap.get(t.value) ?? null;
|
|
845
|
+
if (s === null)
|
|
846
|
+
return;
|
|
847
|
+
const l = s.isGroupSelectable ?? !0;
|
|
848
|
+
if (s.isGroup && (this.disabledBranchNode || !l)) {
|
|
849
|
+
s.arrowItemHtmlElement?.dispatchEvent(new Event("mousedown"));
|
|
708
850
|
return;
|
|
709
851
|
}
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
}, et = function(e) {
|
|
729
|
-
e.stopPropagation(), n(this, G) && n(this, P) && n(this, G).classList.add("treeselect-list__item--focused");
|
|
730
|
-
}, tt = function() {
|
|
731
|
-
b(this, P, !0);
|
|
732
|
-
}, ie = function(e) {
|
|
733
|
-
return e.reduce((t, s) => {
|
|
734
|
-
var r;
|
|
735
|
-
if ((r = s.children) != null && r.length) {
|
|
736
|
-
const u = a(this, o, lt).call(this, s), f = a(this, o, ie).call(this, s.children);
|
|
737
|
-
return u.append(...f), t.push(u), t;
|
|
852
|
+
if (this.isSingleSelect) {
|
|
853
|
+
const [n] = this.#l;
|
|
854
|
+
if (s.id === n)
|
|
855
|
+
return;
|
|
856
|
+
this.#l = [s.id], D({
|
|
857
|
+
newValue: [s.id],
|
|
858
|
+
optionsTreeMap: this.optionsTreeMap,
|
|
859
|
+
isSingleSelect: this.isSingleSelect,
|
|
860
|
+
isIndependentNodes: this.isIndependentNodes
|
|
861
|
+
});
|
|
862
|
+
} else {
|
|
863
|
+
s.checked = e.checked;
|
|
864
|
+
const n = T({
|
|
865
|
+
option: s,
|
|
866
|
+
optionsTreeMap: this.optionsTreeMap,
|
|
867
|
+
isIndependentNodes: this.isIndependentNodes
|
|
868
|
+
});
|
|
869
|
+
e.checked = n;
|
|
738
870
|
}
|
|
739
|
-
|
|
740
|
-
return t.push(l), t;
|
|
741
|
-
}, []);
|
|
742
|
-
}, st = function() {
|
|
743
|
-
if (!this.listSlotHtmlComponent)
|
|
744
|
-
return null;
|
|
745
|
-
const e = document.createElement("div");
|
|
746
|
-
return e.classList.add("treeselect-list__slot"), e.appendChild(this.listSlotHtmlComponent), e;
|
|
747
|
-
}, it = function() {
|
|
748
|
-
const e = document.createElement("div");
|
|
749
|
-
e.classList.add("treeselect-list__empty"), e.setAttribute("title", this.emptyText);
|
|
750
|
-
const t = document.createElement("span");
|
|
751
|
-
t.classList.add("treeselect-list__empty-icon"), O(this.iconElements.attention, t);
|
|
752
|
-
const s = document.createElement("span");
|
|
753
|
-
return s.classList.add("treeselect-list__empty-text"), s.textContent = this.emptyText, e.append(t, s), this.emptyListHtmlElement = e, e;
|
|
754
|
-
}, lt = function(e) {
|
|
755
|
-
const t = document.createElement("div");
|
|
756
|
-
t.setAttribute("group-container-id", e.value.toString()), t.classList.add("treeselect-list__group-container");
|
|
757
|
-
const s = a(this, o, le).call(this, e, !0);
|
|
758
|
-
return t.appendChild(s), t;
|
|
759
|
-
}, le = function(e, t) {
|
|
760
|
-
const s = a(this, o, nt).call(this, e);
|
|
761
|
-
if (t) {
|
|
762
|
-
const u = a(this, o, ot).call(this, e);
|
|
763
|
-
s.appendChild(u), s.classList.add("treeselect-list__item--group");
|
|
764
|
-
}
|
|
765
|
-
const l = a(this, o, dt).call(this, e), r = a(this, o, ut).call(this, e, t);
|
|
766
|
-
return s.append(l, r), s;
|
|
767
|
-
}, nt = function(e) {
|
|
768
|
-
const t = document.createElement("div");
|
|
769
|
-
t.setAttribute("tabindex", "-1"), t.setAttribute("title", e.name), gs(t, e.htmlAttr), t.classList.add("treeselect-list__item"), t.addEventListener("mouseover", () => a(this, o, at).call(this, t), !0), t.addEventListener("mouseout", () => a(this, o, rt).call(this, t), !0), t.addEventListener("mousedown", (l) => a(this, o, ct).call(this, l, e)), this.intersectionItemsObserver && this.intersectionItemsObserver.observe(t);
|
|
770
|
-
const s = this.optionsTreeMap.get(e.value);
|
|
771
|
-
return s && (s.itemHtmlElement = t), t;
|
|
772
|
-
}, at = function(e) {
|
|
773
|
-
n(this, P) && a(this, o, ae).call(this, !0, e);
|
|
774
|
-
}, rt = function(e) {
|
|
775
|
-
n(this, P) && (a(this, o, ae).call(this, !1, e), b(this, G, e));
|
|
776
|
-
}, ct = function(e, t) {
|
|
777
|
-
e.preventDefault(), e.stopPropagation();
|
|
778
|
-
const s = this.optionsTreeMap.get(t.value) ?? null;
|
|
779
|
-
if (s != null && s.disabled)
|
|
780
|
-
return;
|
|
781
|
-
const l = s == null ? void 0 : s.checkboxHtmlElement;
|
|
782
|
-
l && (l.checked = !l.checked, a(this, o, pt).call(this, l, t));
|
|
783
|
-
}, ot = function(e) {
|
|
784
|
-
const t = document.createElement("span");
|
|
785
|
-
t.setAttribute("tabindex", "-1"), t.classList.add("treeselect-list__item-icon"), O(this.iconElements.arrowDown, t), t.addEventListener("mousedown", (l) => a(this, o, ht).call(this, l, e));
|
|
786
|
-
const s = this.optionsTreeMap.get(e.value);
|
|
787
|
-
return s && (s.arrowItemHtmlElement = t), t;
|
|
788
|
-
}, ht = function(e, t) {
|
|
789
|
-
e.preventDefault(), e.stopPropagation(), a(this, o, ft).call(this, t);
|
|
790
|
-
}, dt = function(e) {
|
|
791
|
-
const t = document.createElement("div");
|
|
792
|
-
t.classList.add("treeselect-list__item-checkbox-container");
|
|
793
|
-
const s = document.createElement("span");
|
|
794
|
-
s.classList.add("treeselect-list__item-checkbox-icon"), s.innerHTML = "";
|
|
795
|
-
const l = document.createElement("input");
|
|
796
|
-
l.setAttribute("tabindex", "-1"), l.setAttribute("type", "checkbox"), l.setAttribute("input-id", e.value.toString()), l.classList.add("treeselect-list__item-checkbox"), t.append(s, l);
|
|
797
|
-
const r = this.optionsTreeMap.get(e.value);
|
|
798
|
-
return r && (r.checkboxHtmlElement = l, r.checkboxIconHtmlElement = s), t;
|
|
799
|
-
}, ut = function(e, t) {
|
|
800
|
-
const s = document.createElement("label");
|
|
801
|
-
if (s.textContent = e.name, s.classList.add("treeselect-list__item-label"), t && this.showCount) {
|
|
802
|
-
const l = a(this, o, mt).call(this, e);
|
|
803
|
-
s.appendChild(l);
|
|
804
|
-
}
|
|
805
|
-
return s;
|
|
806
|
-
}, mt = function(e) {
|
|
807
|
-
var l;
|
|
808
|
-
const t = document.createElement("span"), s = ((l = this.optionsTreeMap.get(e.value)) == null ? void 0 : l.children) ?? [];
|
|
809
|
-
return t.textContent = `(${s.length})`, t.classList.add("treeselect-list__item-label-counter"), t;
|
|
810
|
-
}, ne = function() {
|
|
811
|
-
const e = [];
|
|
812
|
-
return this.optionsTreeMap.forEach((t) => {
|
|
813
|
-
!t.hidden && t.itemHtmlElement && e.push(t.itemHtmlElement);
|
|
814
|
-
}), e;
|
|
815
|
-
}, // Actions
|
|
816
|
-
pt = function(e, t) {
|
|
817
|
-
const s = this.optionsTreeMap.get(t.value) ?? null;
|
|
818
|
-
if (s === null)
|
|
819
|
-
return;
|
|
820
|
-
const l = s.isGroupSelectable ?? !0;
|
|
821
|
-
if (s.isGroup && (this.disabledBranchNode || !l)) {
|
|
822
|
-
const r = s.arrowItemHtmlElement;
|
|
823
|
-
r == null || r.dispatchEvent(new Event("mousedown"));
|
|
824
|
-
return;
|
|
871
|
+
this.#a(), this.#N();
|
|
825
872
|
}
|
|
826
|
-
|
|
827
|
-
const
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
});
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
}
|
|
857
|
-
|
|
858
|
-
}, re = function() {
|
|
859
|
-
const { ungroupedNodes: e, groupedNodes: t, allNodes: s } = ns(this.optionsTreeMap);
|
|
860
|
-
this.selectedNodes = {
|
|
861
|
-
nodes: a(this, o, J).call(this, e),
|
|
862
|
-
groupedNodes: a(this, o, J).call(this, t),
|
|
863
|
-
allNodes: a(this, o, J).call(this, s)
|
|
864
|
-
};
|
|
865
|
-
}, // Emits
|
|
866
|
-
gt = function() {
|
|
867
|
-
a(this, o, re).call(this), this.inputCallback(this.selectedNodes), this.value = this.selectedNodes.nodes.map((e) => e.id);
|
|
868
|
-
};
|
|
869
|
-
const Le = ({
|
|
873
|
+
#T(e) {
|
|
874
|
+
const t = this.optionsTreeMap.get(e.value) ?? null;
|
|
875
|
+
t !== null && (t.isClosed = !t.isClosed, L(this.optionsTreeMap, t), this.#a(), this.arrowClickCallback(t.id, t.isClosed));
|
|
876
|
+
}
|
|
877
|
+
#A(e, t) {
|
|
878
|
+
const s = "treeselect-list__item--focused";
|
|
879
|
+
if (e) {
|
|
880
|
+
const l = Array.from(this.srcElement.querySelectorAll(`.${s}`));
|
|
881
|
+
l.length && l.forEach((n) => {
|
|
882
|
+
u(n, s);
|
|
883
|
+
}), c(t, s);
|
|
884
|
+
} else
|
|
885
|
+
u(t, s);
|
|
886
|
+
}
|
|
887
|
+
#I(e) {
|
|
888
|
+
const t = this.tagsSortFn ?? null;
|
|
889
|
+
return t === null ? e : [...e].sort((s, l) => t({ value: s.id, name: s.name }, { value: l.id, name: l.name }));
|
|
890
|
+
}
|
|
891
|
+
#_() {
|
|
892
|
+
const { ungroupedNodes: e, groupedNodes: t, allNodes: s } = be(this.optionsTreeMap);
|
|
893
|
+
this.selectedNodes = {
|
|
894
|
+
nodes: this.#I(e),
|
|
895
|
+
groupedNodes: this.#I(t),
|
|
896
|
+
allNodes: this.#I(s)
|
|
897
|
+
};
|
|
898
|
+
}
|
|
899
|
+
// Emits
|
|
900
|
+
#N() {
|
|
901
|
+
this.#_(), this.inputCallback(this.selectedNodes), this.value = this.selectedNodes.nodes.map((e) => e.id);
|
|
902
|
+
}
|
|
903
|
+
}
|
|
904
|
+
const H = ({
|
|
870
905
|
parentHtmlContainer: i,
|
|
871
906
|
staticList: e,
|
|
872
907
|
appendToBody: t,
|
|
873
908
|
isSingleSelect: s,
|
|
874
909
|
value: l,
|
|
875
|
-
direction:
|
|
910
|
+
direction: n
|
|
876
911
|
}) => {
|
|
877
|
-
i || 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(l) && console.error("Validation: if you use isSingleSelect prop, you should pass a single value!"), !s && !Array.isArray(l) && console.error("Validation: you should pass an array as a value!"),
|
|
878
|
-
},
|
|
912
|
+
i || 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(l) && console.error("Validation: if you use isSingleSelect prop, you should pass a single value!"), !s && !Array.isArray(l) && console.error("Validation: you should pass an array as a value!"), n && n !== "auto" && n !== "bottom" && n !== "top" && console.error("Validation: you should pass (auto | top | bottom | undefined) as a value for the direction prop!");
|
|
913
|
+
}, x = (i) => i.map((e) => e.id), Ge = (i) => i == null ? [] : Array.isArray(i) ? i : [i], Me = (i, e) => {
|
|
879
914
|
if (e) {
|
|
880
915
|
const [t] = i;
|
|
881
916
|
return t ?? null;
|
|
882
917
|
}
|
|
883
918
|
return i;
|
|
884
919
|
};
|
|
885
|
-
|
|
886
|
-
|
|
920
|
+
class Fe {
|
|
921
|
+
// Props
|
|
922
|
+
parentHtmlContainer;
|
|
923
|
+
/** Current value: single id (single select), array of ids (multi), or null. */
|
|
924
|
+
value;
|
|
925
|
+
options;
|
|
926
|
+
openLevel;
|
|
927
|
+
appendToBody;
|
|
928
|
+
alwaysOpen;
|
|
929
|
+
showTags;
|
|
930
|
+
tagsCountText;
|
|
931
|
+
tagsSortFn;
|
|
932
|
+
clearable;
|
|
933
|
+
searchable;
|
|
934
|
+
placeholder;
|
|
935
|
+
grouped;
|
|
936
|
+
isGroupedValue;
|
|
937
|
+
listSlotHtmlComponent;
|
|
938
|
+
disabled;
|
|
939
|
+
emptyText;
|
|
940
|
+
staticList;
|
|
941
|
+
id;
|
|
942
|
+
ariaLabel;
|
|
943
|
+
isSingleSelect;
|
|
944
|
+
showCount;
|
|
945
|
+
disabledBranchNode;
|
|
946
|
+
direction;
|
|
947
|
+
expandSelected;
|
|
948
|
+
saveScrollPosition;
|
|
949
|
+
isIndependentNodes;
|
|
950
|
+
rtl;
|
|
951
|
+
listClassName;
|
|
952
|
+
isBoostedRendering;
|
|
953
|
+
iconElements;
|
|
954
|
+
inputCallback;
|
|
955
|
+
openCallback;
|
|
956
|
+
closeCallback;
|
|
957
|
+
nameChangeCallback;
|
|
958
|
+
searchCallback;
|
|
959
|
+
openCloseGroupCallback;
|
|
960
|
+
// InnerState
|
|
961
|
+
ungroupedValue;
|
|
962
|
+
groupedValue;
|
|
963
|
+
allValue;
|
|
964
|
+
/** True when the dropdown list is open. */
|
|
965
|
+
isListOpened;
|
|
966
|
+
/** Selected option label (single select). */
|
|
967
|
+
selectedName;
|
|
968
|
+
/** Root DOM element of the treeselect (null after destroy). */
|
|
969
|
+
srcElement;
|
|
970
|
+
// Components
|
|
971
|
+
#e = null;
|
|
972
|
+
#t = null;
|
|
973
|
+
// Resize props
|
|
974
|
+
#l = null;
|
|
975
|
+
// List position scroll
|
|
976
|
+
#s = 0;
|
|
977
|
+
// Timer for search text
|
|
978
|
+
#a = 0;
|
|
979
|
+
// Outside listeners
|
|
980
|
+
#i = null;
|
|
981
|
+
#r = null;
|
|
982
|
+
#o = null;
|
|
983
|
+
#n = null;
|
|
984
|
+
/**
|
|
985
|
+
* @param params - Configuration and callbacks; only parentHtmlContainer is required
|
|
986
|
+
*/
|
|
887
987
|
constructor({
|
|
888
988
|
parentHtmlContainer: e,
|
|
889
989
|
value: t,
|
|
890
990
|
options: s,
|
|
891
991
|
openLevel: l,
|
|
892
|
-
appendToBody:
|
|
893
|
-
alwaysOpen:
|
|
894
|
-
showTags:
|
|
895
|
-
tagsCountText:
|
|
896
|
-
tagsSortFn:
|
|
897
|
-
clearable:
|
|
898
|
-
searchable:
|
|
899
|
-
placeholder:
|
|
900
|
-
grouped:
|
|
901
|
-
isGroupedValue:
|
|
902
|
-
listSlotHtmlComponent:
|
|
903
|
-
disabled:
|
|
904
|
-
emptyText:
|
|
905
|
-
staticList:
|
|
906
|
-
id:
|
|
907
|
-
ariaLabel:
|
|
908
|
-
isSingleSelect:
|
|
909
|
-
showCount:
|
|
910
|
-
disabledBranchNode:
|
|
911
|
-
direction:
|
|
912
|
-
expandSelected:
|
|
913
|
-
saveScrollPosition:
|
|
914
|
-
isIndependentNodes:
|
|
915
|
-
rtl:
|
|
916
|
-
listClassName:
|
|
917
|
-
isBoostedRendering:
|
|
918
|
-
iconElements:
|
|
919
|
-
inputCallback:
|
|
920
|
-
openCallback:
|
|
921
|
-
closeCallback:
|
|
922
|
-
nameChangeCallback:
|
|
923
|
-
searchCallback:
|
|
924
|
-
openCloseGroupCallback:
|
|
992
|
+
appendToBody: n,
|
|
993
|
+
alwaysOpen: a,
|
|
994
|
+
showTags: r,
|
|
995
|
+
tagsCountText: p,
|
|
996
|
+
tagsSortFn: h,
|
|
997
|
+
clearable: o,
|
|
998
|
+
searchable: d,
|
|
999
|
+
placeholder: m,
|
|
1000
|
+
grouped: b,
|
|
1001
|
+
isGroupedValue: f,
|
|
1002
|
+
listSlotHtmlComponent: C,
|
|
1003
|
+
disabled: E,
|
|
1004
|
+
emptyText: k,
|
|
1005
|
+
staticList: w,
|
|
1006
|
+
id: y,
|
|
1007
|
+
ariaLabel: U,
|
|
1008
|
+
isSingleSelect: _,
|
|
1009
|
+
showCount: $,
|
|
1010
|
+
disabledBranchNode: W,
|
|
1011
|
+
direction: j,
|
|
1012
|
+
expandSelected: Y,
|
|
1013
|
+
saveScrollPosition: z,
|
|
1014
|
+
isIndependentNodes: q,
|
|
1015
|
+
rtl: X,
|
|
1016
|
+
listClassName: K,
|
|
1017
|
+
isBoostedRendering: Z,
|
|
1018
|
+
iconElements: J,
|
|
1019
|
+
inputCallback: Q,
|
|
1020
|
+
openCallback: ee,
|
|
1021
|
+
closeCallback: te,
|
|
1022
|
+
nameChangeCallback: se,
|
|
1023
|
+
searchCallback: ie,
|
|
1024
|
+
openCloseGroupCallback: le
|
|
925
1025
|
}) {
|
|
926
|
-
|
|
927
|
-
// Props
|
|
928
|
-
c(this, "parentHtmlContainer");
|
|
929
|
-
c(this, "value");
|
|
930
|
-
c(this, "options");
|
|
931
|
-
c(this, "openLevel");
|
|
932
|
-
c(this, "appendToBody");
|
|
933
|
-
c(this, "alwaysOpen");
|
|
934
|
-
c(this, "showTags");
|
|
935
|
-
c(this, "tagsCountText");
|
|
936
|
-
c(this, "tagsSortFn");
|
|
937
|
-
c(this, "clearable");
|
|
938
|
-
c(this, "searchable");
|
|
939
|
-
c(this, "placeholder");
|
|
940
|
-
c(this, "grouped");
|
|
941
|
-
c(this, "isGroupedValue");
|
|
942
|
-
c(this, "listSlotHtmlComponent");
|
|
943
|
-
c(this, "disabled");
|
|
944
|
-
c(this, "emptyText");
|
|
945
|
-
c(this, "staticList");
|
|
946
|
-
c(this, "id");
|
|
947
|
-
c(this, "ariaLabel");
|
|
948
|
-
c(this, "isSingleSelect");
|
|
949
|
-
c(this, "showCount");
|
|
950
|
-
c(this, "disabledBranchNode");
|
|
951
|
-
c(this, "direction");
|
|
952
|
-
c(this, "expandSelected");
|
|
953
|
-
c(this, "saveScrollPosition");
|
|
954
|
-
c(this, "isIndependentNodes");
|
|
955
|
-
c(this, "rtl");
|
|
956
|
-
c(this, "listClassName");
|
|
957
|
-
c(this, "isBoostedRendering");
|
|
958
|
-
c(this, "iconElements");
|
|
959
|
-
c(this, "inputCallback");
|
|
960
|
-
c(this, "openCallback");
|
|
961
|
-
c(this, "closeCallback");
|
|
962
|
-
c(this, "nameChangeCallback");
|
|
963
|
-
c(this, "searchCallback");
|
|
964
|
-
c(this, "openCloseGroupCallback");
|
|
965
|
-
// InnerState
|
|
966
|
-
c(this, "ungroupedValue");
|
|
967
|
-
c(this, "groupedValue");
|
|
968
|
-
c(this, "allValue");
|
|
969
|
-
c(this, "isListOpened");
|
|
970
|
-
c(this, "selectedName");
|
|
971
|
-
c(this, "srcElement");
|
|
972
|
-
// Components
|
|
973
|
-
g(this, m, null);
|
|
974
|
-
g(this, p, null);
|
|
975
|
-
// Resize props
|
|
976
|
-
g(this, F, null);
|
|
977
|
-
// List position scroll
|
|
978
|
-
g(this, q, 0);
|
|
979
|
-
// Timer for search text
|
|
980
|
-
g(this, $, 0);
|
|
981
|
-
// Outside listeners
|
|
982
|
-
g(this, A, null);
|
|
983
|
-
g(this, I, null);
|
|
984
|
-
g(this, y, null);
|
|
985
|
-
g(this, V, null);
|
|
986
|
-
Le({
|
|
1026
|
+
H({
|
|
987
1027
|
parentHtmlContainer: e,
|
|
988
1028
|
value: t,
|
|
989
|
-
staticList:
|
|
990
|
-
appendToBody:
|
|
991
|
-
isSingleSelect:
|
|
992
|
-
}), this.parentHtmlContainer = e, this.value = [], this.options = s ?? [], this.openLevel = l ?? 0, this.appendToBody =
|
|
1029
|
+
staticList: w,
|
|
1030
|
+
appendToBody: n,
|
|
1031
|
+
isSingleSelect: _
|
|
1032
|
+
}), this.parentHtmlContainer = e, this.value = [], this.options = s ?? [], this.openLevel = l ?? 0, this.appendToBody = n ?? !1, this.alwaysOpen = !!(a && !E), this.showTags = r ?? !0, this.tagsCountText = p ?? oe, this.tagsSortFn = h ?? null, this.clearable = o ?? !0, this.searchable = d ?? !0, this.placeholder = m ?? re, this.grouped = b ?? !0, this.isGroupedValue = f ?? !1, this.listSlotHtmlComponent = C ?? null, this.disabled = E ?? !1, this.emptyText = k ?? P, this.staticList = !!(w && !this.appendToBody), this.id = y ?? "", this.ariaLabel = U ?? "", this.isSingleSelect = _ ?? !1, this.showCount = $ ?? !1, this.disabledBranchNode = W ?? !1, this.direction = j ?? "auto", this.expandSelected = Y ?? !1, this.saveScrollPosition = z ?? !0, this.isIndependentNodes = q ?? !1, this.rtl = X ?? !1, this.listClassName = K ?? "", this.isBoostedRendering = Z ?? !1, this.iconElements = O(J), this.inputCallback = Q, this.openCallback = ee, this.closeCallback = te, this.nameChangeCallback = se, this.searchCallback = ie, this.openCloseGroupCallback = le, this.ungroupedValue = [], this.groupedValue = [], this.allValue = [], this.isListOpened = !1, this.selectedName = "", this.srcElement = null, this.#c(t);
|
|
993
1033
|
}
|
|
1034
|
+
/** Renders the treeselect into parentHtmlContainer. Call after constructor or to re-mount. */
|
|
994
1035
|
mount() {
|
|
995
|
-
|
|
1036
|
+
H({
|
|
996
1037
|
parentHtmlContainer: this.parentHtmlContainer,
|
|
997
1038
|
value: this.value,
|
|
998
1039
|
staticList: this.staticList,
|
|
999
1040
|
appendToBody: this.appendToBody,
|
|
1000
1041
|
isSingleSelect: this.isSingleSelect
|
|
1001
|
-
}), this.iconElements =
|
|
1042
|
+
}), this.iconElements = O(this.iconElements), this.#c(this.value);
|
|
1043
|
+
}
|
|
1044
|
+
#c(e) {
|
|
1045
|
+
this.destroy();
|
|
1046
|
+
const { container: t, list: s, input: l } = this.#u();
|
|
1047
|
+
this.srcElement = t, this.#e = s, this.#t = l, this.#i = this.scrollWindowHandler.bind(this), this.#r = this.scrollWindowHandler.bind(this), this.#o = this.focusWindowHandler.bind(this), this.#n = this.blurWindowHandler.bind(this), this.alwaysOpen && this.#t?.openClose(), this.disabled ? c(this.srcElement, "treeselect--disabled") : u(this.srcElement, "treeselect--disabled"), this.updateValue(e ?? this.value);
|
|
1002
1048
|
}
|
|
1049
|
+
/** Sets the current value (single id, array of ids, or null). Updates UI and callbacks. */
|
|
1003
1050
|
updateValue(e) {
|
|
1004
|
-
const t =
|
|
1005
|
-
s && (s.updateValue(t),
|
|
1051
|
+
const t = Ge(e), s = this.#e;
|
|
1052
|
+
s && (s.updateValue(t), this.#p(s?.selectedNodes));
|
|
1006
1053
|
}
|
|
1054
|
+
/** Removes the component from DOM and clears listeners. Call before removing the container. */
|
|
1007
1055
|
destroy() {
|
|
1008
|
-
|
|
1009
|
-
this.srcElement && (a(this, d, de).call(this), this.srcElement.innerHTML = "", this.srcElement = null, a(this, d, fe).call(this, !0), (e = n(this, m)) == null || e.destroy());
|
|
1056
|
+
this.srcElement && (this.#f(), this.srcElement.innerHTML = "", this.srcElement = null, this.#h(!0), this.#e?.destroy(), clearTimeout(this.#a));
|
|
1010
1057
|
}
|
|
1058
|
+
/** Moves focus to the treeselect input. */
|
|
1011
1059
|
focus() {
|
|
1012
|
-
|
|
1060
|
+
this.#t && this.#t.focus();
|
|
1013
1061
|
}
|
|
1062
|
+
/** Opens the list if closed, closes if open. */
|
|
1014
1063
|
toggleOpenClose() {
|
|
1015
|
-
|
|
1064
|
+
this.#t && (this.#t.openClose(), this.#t.focus());
|
|
1065
|
+
}
|
|
1066
|
+
#d({
|
|
1067
|
+
groupedNodes: e,
|
|
1068
|
+
nodes: t,
|
|
1069
|
+
allNodes: s
|
|
1070
|
+
}) {
|
|
1071
|
+
this.ungroupedValue = t ? x(t) : [], this.groupedValue = e ? x(e) : [], this.allValue = s ? x(s) : [];
|
|
1072
|
+
let l = [];
|
|
1073
|
+
this.isIndependentNodes || this.isSingleSelect ? l = this.allValue : this.isGroupedValue ? l = this.groupedValue : l = this.ungroupedValue, this.value = Me(l, this.isSingleSelect);
|
|
1074
|
+
}
|
|
1075
|
+
#u() {
|
|
1076
|
+
const e = this.parentHtmlContainer;
|
|
1077
|
+
e.classList.add("treeselect");
|
|
1078
|
+
const t = new Be({
|
|
1079
|
+
value: [],
|
|
1080
|
+
// updateValue method calls in initMount method to set actual value
|
|
1081
|
+
options: this.options,
|
|
1082
|
+
openLevel: this.openLevel,
|
|
1083
|
+
listSlotHtmlComponent: this.listSlotHtmlComponent,
|
|
1084
|
+
tagsSortFn: this.tagsSortFn,
|
|
1085
|
+
emptyText: this.emptyText,
|
|
1086
|
+
isSingleSelect: this.isSingleSelect,
|
|
1087
|
+
showCount: this.showCount,
|
|
1088
|
+
disabledBranchNode: this.disabledBranchNode,
|
|
1089
|
+
expandSelected: this.expandSelected,
|
|
1090
|
+
isIndependentNodes: this.isIndependentNodes,
|
|
1091
|
+
rtl: this.rtl,
|
|
1092
|
+
listClassName: this.listClassName,
|
|
1093
|
+
isBoostedRendering: this.isBoostedRendering,
|
|
1094
|
+
iconElements: this.iconElements,
|
|
1095
|
+
inputCallback: (l) => this.#L(l),
|
|
1096
|
+
arrowClickCallback: (l, n) => this.#S(l, n),
|
|
1097
|
+
mouseupCallback: () => this.#t?.focus()
|
|
1098
|
+
}), s = new ae({
|
|
1099
|
+
value: [],
|
|
1100
|
+
// updateValue method calls in initMount method to set actual value
|
|
1101
|
+
showTags: this.showTags,
|
|
1102
|
+
tagsCountText: this.tagsCountText,
|
|
1103
|
+
clearable: this.clearable,
|
|
1104
|
+
isAlwaysOpened: this.alwaysOpen,
|
|
1105
|
+
searchable: this.searchable,
|
|
1106
|
+
placeholder: this.placeholder,
|
|
1107
|
+
disabled: this.disabled,
|
|
1108
|
+
isSingleSelect: this.isSingleSelect,
|
|
1109
|
+
id: this.id,
|
|
1110
|
+
ariaLabel: this.ariaLabel,
|
|
1111
|
+
iconElements: this.iconElements,
|
|
1112
|
+
inputCallback: (l) => this.#w(l),
|
|
1113
|
+
searchCallback: (l) => this.#v(l),
|
|
1114
|
+
openCallback: () => this.#y(),
|
|
1115
|
+
closeCallback: () => this.#f(),
|
|
1116
|
+
keydownCallback: (l) => this.#k(l),
|
|
1117
|
+
focusCallback: () => this.#m(),
|
|
1118
|
+
nameChangeCallback: (l) => this.#x(l)
|
|
1119
|
+
});
|
|
1120
|
+
return this.rtl && (e.setAttribute("dir", "rtl"), t.srcElement.setAttribute("dir", "rtl")), this.appendToBody && (this.#l = new ResizeObserver(() => this.updateListPosition())), e.append(s.srcElement), { container: e, list: t, input: s };
|
|
1121
|
+
}
|
|
1122
|
+
#w(e) {
|
|
1123
|
+
const t = x(e);
|
|
1124
|
+
this.#e?.updateValue(t);
|
|
1125
|
+
const s = this.#e?.selectedNodes ?? {};
|
|
1126
|
+
this.#d(s), this.#T();
|
|
1127
|
+
}
|
|
1128
|
+
#k(e) {
|
|
1129
|
+
this.isListOpened && this.#e?.callKeyAction(e);
|
|
1130
|
+
}
|
|
1131
|
+
#v(e) {
|
|
1132
|
+
this.#a && clearTimeout(this.#a), this.#a = window.setTimeout(() => {
|
|
1133
|
+
this.#e?.updateSearchValue(e), this.updateListPosition();
|
|
1134
|
+
}, ce), this.#N(e);
|
|
1135
|
+
}
|
|
1136
|
+
#m() {
|
|
1137
|
+
this.#b(!0), this.#o && this.#n && (document.addEventListener("mousedown", this.#o, !0), document.addEventListener("focus", this.#o, !0), window.addEventListener("blur", this.#n, { capture: !1 }));
|
|
1138
|
+
}
|
|
1139
|
+
#p(e) {
|
|
1140
|
+
if (!e)
|
|
1141
|
+
return;
|
|
1142
|
+
let t = [];
|
|
1143
|
+
this.isIndependentNodes || this.isSingleSelect ? t = e.allNodes : this.grouped ? t = e.groupedNodes : t = e.nodes, this.#t?.updateValue(t), this.#d(e);
|
|
1144
|
+
}
|
|
1145
|
+
#L(e) {
|
|
1146
|
+
this.#p(e), this.isSingleSelect && !this.alwaysOpen && (this.#t?.openClose(), this.#t?.clearSearch()), this.#t?.focus(), this.#T();
|
|
1147
|
+
}
|
|
1148
|
+
#S(e, t) {
|
|
1149
|
+
this.#t?.focus(), this.updateListPosition(), this.#O(e, t);
|
|
1150
|
+
}
|
|
1151
|
+
#x(e) {
|
|
1152
|
+
this.selectedName !== e && (this.selectedName = e, this.#A());
|
|
1153
|
+
}
|
|
1154
|
+
#y() {
|
|
1155
|
+
this.isListOpened = !0, this.#i && this.#r && (window.addEventListener("scroll", this.#i, !0), window.addEventListener("resize", this.#r)), !(!this.#e || !this.srcElement) && (this.appendToBody ? (document.body.appendChild(this.#e.srcElement), this.#l?.observe(this.srcElement)) : this.srcElement.appendChild(this.#e.srcElement), this.updateListPosition(), this.#C(!0), this.#E(), this.#I());
|
|
1156
|
+
}
|
|
1157
|
+
#f() {
|
|
1158
|
+
this.alwaysOpen || (this.isListOpened = !1, this.#i && this.#r && (window.removeEventListener("scroll", this.#i, !0), window.removeEventListener("resize", this.#r)), !this.#e || !this.srcElement) || !(this.appendToBody ? document.body.contains(this.#e.srcElement) : this.srcElement.contains(this.#e.srcElement)) || (this.#s = this.#e.srcElement.scrollTop, this.appendToBody ? (document.body.removeChild(this.#e.srcElement), this.#l?.disconnect()) : this.srcElement.removeChild(this.#e.srcElement), this.#C(!1), this.#_());
|
|
1159
|
+
}
|
|
1160
|
+
#g(e, t) {
|
|
1161
|
+
if (!this.#e || !this.#t)
|
|
1162
|
+
return;
|
|
1163
|
+
const s = t ? "treeselect-list--top-to-body" : "treeselect-list--top", l = t ? "treeselect-list--bottom-to-body" : "treeselect-list--bottom";
|
|
1164
|
+
e ? (c(this.#e.srcElement, s), u(this.#e.srcElement, l), c(this.#t.srcElement, "treeselect-input--top"), u(this.#t.srcElement, "treeselect-input--bottom")) : (u(this.#e.srcElement, s), c(this.#e.srcElement, l), u(this.#t.srcElement, "treeselect-input--top"), c(this.#t.srcElement, "treeselect-input--bottom"));
|
|
1165
|
+
}
|
|
1166
|
+
#b(e) {
|
|
1167
|
+
!this.#t || !this.#e || (e ? (c(this.#t.srcElement, "treeselect-input--focused"), c(this.#e.srcElement, "treeselect-list--focused")) : (u(this.#t.srcElement, "treeselect-input--focused"), u(this.#e.srcElement, "treeselect-list--focused")));
|
|
1168
|
+
}
|
|
1169
|
+
#C(e) {
|
|
1170
|
+
e ? c(this.#t?.srcElement, "treeselect-input--opened") : u(this.#t?.srcElement, "treeselect-input--opened"), this.staticList ? c(this.#e?.srcElement, "treeselect-list--static") : u(this.#e?.srcElement, "treeselect-list--static");
|
|
1171
|
+
}
|
|
1172
|
+
#h(e) {
|
|
1173
|
+
!this.#i || !this.#r || !this.#o || !this.#n || ((!this.alwaysOpen || e) && (window.removeEventListener("scroll", this.#i, !0), window.removeEventListener("resize", this.#r)), document.removeEventListener("mousedown", this.#o, !0), document.removeEventListener("focus", this.#o, !0), window.removeEventListener("blur", this.#n, { capture: !1 }));
|
|
1174
|
+
}
|
|
1175
|
+
#E() {
|
|
1176
|
+
const e = this.#e?.isLastFocusedElementExist();
|
|
1177
|
+
this.saveScrollPosition && e ? this.#e?.srcElement.scroll(0, this.#s) : this.#e?.focusFirstListElement();
|
|
1016
1178
|
}
|
|
1017
1179
|
// Outside Listeners
|
|
1018
1180
|
scrollWindowHandler() {
|
|
1019
1181
|
this.updateListPosition();
|
|
1020
1182
|
}
|
|
1021
1183
|
focusWindowHandler(e) {
|
|
1022
|
-
var l, r;
|
|
1023
1184
|
let t = e.target;
|
|
1024
|
-
t
|
|
1185
|
+
t?.shadowRoot && e.composedPath().length > 0 && (t = e.composedPath()[0]), this.srcElement?.contains(t) || this.#e?.srcElement.contains(t) || this.blurWindowHandler();
|
|
1025
1186
|
}
|
|
1026
1187
|
blurWindowHandler() {
|
|
1027
|
-
|
|
1028
|
-
(e = n(this, p)) == null || e.blur(), a(this, d, fe).call(this, !1), a(this, d, me).call(this, !1);
|
|
1188
|
+
this.#t?.blur(), this.#h(!1), this.#b(!1);
|
|
1029
1189
|
}
|
|
1030
1190
|
// Update direction of the list. Support appendToBody and standard mode with absolute
|
|
1031
1191
|
updateListPosition() {
|
|
1032
|
-
|
|
1033
|
-
const e = this.srcElement, t = (T = n(this, m)) == null ? void 0 : T.srcElement;
|
|
1192
|
+
const e = this.srcElement, t = this.#e?.srcElement;
|
|
1034
1193
|
if (!e || !t)
|
|
1035
1194
|
return;
|
|
1036
1195
|
if (this.staticList) {
|
|
1037
|
-
t.setAttribute("direction", "bottom"),
|
|
1196
|
+
t.setAttribute("direction", "bottom"), this.#g(!1, this.appendToBody);
|
|
1038
1197
|
return;
|
|
1039
1198
|
}
|
|
1040
1199
|
const { height: s } = t.getBoundingClientRect(), {
|
|
1041
1200
|
x: l,
|
|
1042
|
-
y:
|
|
1043
|
-
height:
|
|
1044
|
-
width:
|
|
1045
|
-
} = e.getBoundingClientRect(),
|
|
1046
|
-
let
|
|
1047
|
-
if (this.direction !== "auto" && (
|
|
1201
|
+
y: n,
|
|
1202
|
+
height: a,
|
|
1203
|
+
width: r
|
|
1204
|
+
} = e.getBoundingClientRect(), p = window.innerHeight, h = n, o = p - n - a;
|
|
1205
|
+
let d = h > o && h >= s && o < s;
|
|
1206
|
+
if (this.direction !== "auto" && (d = this.direction === "top"), this.appendToBody) {
|
|
1048
1207
|
(t.style.top !== "0px" || t.style.left !== "0px") && (t.style.top = "0px", t.style.left = "0px");
|
|
1049
|
-
const
|
|
1050
|
-
t.style.transform = `translate(${
|
|
1208
|
+
const f = l + window.scrollX, C = d ? n + window.scrollY - s : n + window.scrollY + a;
|
|
1209
|
+
t.style.transform = `translate(${f}px,${C}px)`, t.style.width = `${r}px`;
|
|
1051
1210
|
}
|
|
1052
|
-
const
|
|
1053
|
-
t.getAttribute("direction") !==
|
|
1211
|
+
const m = d ? "top" : "bottom";
|
|
1212
|
+
t.getAttribute("direction") !== m && (t.setAttribute("direction", m), this.#g(d, this.appendToBody));
|
|
1213
|
+
}
|
|
1214
|
+
// Emits
|
|
1215
|
+
#T() {
|
|
1216
|
+
this.srcElement?.dispatchEvent(new CustomEvent("input", { detail: this.value })), this.inputCallback && this.inputCallback(this.value);
|
|
1217
|
+
}
|
|
1218
|
+
#A() {
|
|
1219
|
+
this.srcElement?.dispatchEvent(new CustomEvent("name-change", { detail: this.selectedName })), this.nameChangeCallback && this.nameChangeCallback(this.selectedName);
|
|
1220
|
+
}
|
|
1221
|
+
#I() {
|
|
1222
|
+
this.alwaysOpen || (this.srcElement?.dispatchEvent(new CustomEvent("open", { detail: this.value })), this.openCallback && this.openCallback(this.value));
|
|
1223
|
+
}
|
|
1224
|
+
#_() {
|
|
1225
|
+
this.alwaysOpen || (this.srcElement?.dispatchEvent(new CustomEvent("close", { detail: this.value })), this.closeCallback && this.closeCallback(this.value));
|
|
1226
|
+
}
|
|
1227
|
+
#N(e) {
|
|
1228
|
+
const t = e?.trim() ?? "";
|
|
1229
|
+
this.srcElement?.dispatchEvent(new CustomEvent("search", { detail: t })), this.searchCallback && this.searchCallback(t);
|
|
1230
|
+
}
|
|
1231
|
+
#O(e, t) {
|
|
1232
|
+
this.srcElement?.dispatchEvent(new CustomEvent("open-close-group", { detail: { groupId: e, isClosed: t } })), this.openCloseGroupCallback && this.openCloseGroupCallback(e, t);
|
|
1054
1233
|
}
|
|
1055
1234
|
}
|
|
1056
|
-
m = new WeakMap(), p = new WeakMap(), F = new WeakMap(), q = new WeakMap(), $ = new WeakMap(), A = new WeakMap(), I = new WeakMap(), y = new WeakMap(), V = new WeakMap(), d = new WeakSet(), ce = function(e) {
|
|
1057
|
-
var r;
|
|
1058
|
-
this.destroy();
|
|
1059
|
-
const { container: t, list: s, input: l } = a(this, d, bt).call(this);
|
|
1060
|
-
this.srcElement = t, b(this, m, s), b(this, p, l), b(this, A, this.scrollWindowHandler.bind(this)), b(this, I, this.scrollWindowHandler.bind(this)), b(this, y, this.focusWindowHandler.bind(this)), b(this, V, this.blurWindowHandler.bind(this)), this.alwaysOpen && ((r = n(this, p)) == null || r.openClose()), this.disabled ? this.srcElement.classList.add("treeselect--disabled") : this.srcElement.classList.remove("treeselect--disabled"), this.updateValue(e ?? this.value);
|
|
1061
|
-
}, oe = function({
|
|
1062
|
-
groupedNodes: e,
|
|
1063
|
-
nodes: t,
|
|
1064
|
-
allNodes: s
|
|
1065
|
-
}) {
|
|
1066
|
-
this.ungroupedValue = t ? Z(t) : [], this.groupedValue = e ? Z(e) : [], this.allValue = s ? Z(s) : [];
|
|
1067
|
-
let l = [];
|
|
1068
|
-
this.isIndependentNodes || this.isSingleSelect ? l = this.allValue : this.isGroupedValue ? l = this.groupedValue : l = this.ungroupedValue, this.value = Ts(l, this.isSingleSelect);
|
|
1069
|
-
}, bt = function() {
|
|
1070
|
-
const e = this.parentHtmlContainer;
|
|
1071
|
-
e.classList.add("treeselect");
|
|
1072
|
-
const t = new xs({
|
|
1073
|
-
value: [],
|
|
1074
|
-
// updateValue method calls in initMount method to set actual value
|
|
1075
|
-
options: this.options,
|
|
1076
|
-
openLevel: this.openLevel,
|
|
1077
|
-
listSlotHtmlComponent: this.listSlotHtmlComponent,
|
|
1078
|
-
tagsSortFn: this.tagsSortFn,
|
|
1079
|
-
emptyText: this.emptyText,
|
|
1080
|
-
isSingleSelect: this.isSingleSelect,
|
|
1081
|
-
showCount: this.showCount,
|
|
1082
|
-
disabledBranchNode: this.disabledBranchNode,
|
|
1083
|
-
expandSelected: this.expandSelected,
|
|
1084
|
-
isIndependentNodes: this.isIndependentNodes,
|
|
1085
|
-
rtl: this.rtl,
|
|
1086
|
-
listClassName: this.listClassName,
|
|
1087
|
-
isBoostedRendering: this.isBoostedRendering,
|
|
1088
|
-
iconElements: this.iconElements,
|
|
1089
|
-
inputCallback: (l) => a(this, d, kt).call(this, l),
|
|
1090
|
-
arrowClickCallback: (l, r) => a(this, d, Lt).call(this, l, r),
|
|
1091
|
-
mouseupCallback: () => {
|
|
1092
|
-
var l;
|
|
1093
|
-
return (l = n(this, p)) == null ? void 0 : l.focus();
|
|
1094
|
-
}
|
|
1095
|
-
}), s = new Jt({
|
|
1096
|
-
value: [],
|
|
1097
|
-
// updateValue method calls in initMount method to set actual value
|
|
1098
|
-
showTags: this.showTags,
|
|
1099
|
-
tagsCountText: this.tagsCountText,
|
|
1100
|
-
clearable: this.clearable,
|
|
1101
|
-
isAlwaysOpened: this.alwaysOpen,
|
|
1102
|
-
searchable: this.searchable,
|
|
1103
|
-
placeholder: this.placeholder,
|
|
1104
|
-
disabled: this.disabled,
|
|
1105
|
-
isSingleSelect: this.isSingleSelect,
|
|
1106
|
-
id: this.id,
|
|
1107
|
-
ariaLabel: this.ariaLabel,
|
|
1108
|
-
iconElements: this.iconElements,
|
|
1109
|
-
inputCallback: (l) => a(this, d, Ct).call(this, l),
|
|
1110
|
-
searchCallback: (l) => a(this, d, wt).call(this, l),
|
|
1111
|
-
openCallback: () => a(this, d, xt).call(this),
|
|
1112
|
-
closeCallback: () => a(this, d, de).call(this),
|
|
1113
|
-
keydownCallback: (l) => a(this, d, Et).call(this, l),
|
|
1114
|
-
focusCallback: () => a(this, d, vt).call(this),
|
|
1115
|
-
nameChangeCallback: (l) => a(this, d, St).call(this, l)
|
|
1116
|
-
});
|
|
1117
|
-
return this.rtl && (e.setAttribute("dir", "rtl"), t.srcElement.setAttribute("dir", "rtl")), this.appendToBody && b(this, F, new ResizeObserver(() => this.updateListPosition())), e.append(s.srcElement), { container: e, list: t, input: s };
|
|
1118
|
-
}, Ct = function(e) {
|
|
1119
|
-
var l, r;
|
|
1120
|
-
const t = Z(e);
|
|
1121
|
-
(l = n(this, m)) == null || l.updateValue(t);
|
|
1122
|
-
const s = ((r = n(this, m)) == null ? void 0 : r.selectedNodes) ?? {};
|
|
1123
|
-
a(this, d, oe).call(this, s), a(this, d, ge).call(this);
|
|
1124
|
-
}, Et = function(e) {
|
|
1125
|
-
var t;
|
|
1126
|
-
this.isListOpened && ((t = n(this, m)) == null || t.callKeyAction(e));
|
|
1127
|
-
}, wt = function(e) {
|
|
1128
|
-
n(this, $) && clearTimeout(n(this, $)), b(this, $, window.setTimeout(() => {
|
|
1129
|
-
var t;
|
|
1130
|
-
(t = n(this, m)) == null || t.updateSearchValue(e), this.updateListPosition();
|
|
1131
|
-
}, 350)), a(this, d, Nt).call(this, e);
|
|
1132
|
-
}, vt = function() {
|
|
1133
|
-
a(this, d, me).call(this, !0), n(this, y) && n(this, y) && n(this, V) && (document.addEventListener("mousedown", n(this, y), !0), document.addEventListener("focus", n(this, y), !0), window.addEventListener("blur", n(this, V), { capture: !1 }));
|
|
1134
|
-
}, he = function(e) {
|
|
1135
|
-
var s;
|
|
1136
|
-
if (!e)
|
|
1137
|
-
return;
|
|
1138
|
-
let t = [];
|
|
1139
|
-
this.isIndependentNodes || this.isSingleSelect ? t = e.allNodes : this.grouped ? t = e.groupedNodes : t = e.nodes, (s = n(this, p)) == null || s.updateValue(t), a(this, d, oe).call(this, e);
|
|
1140
|
-
}, kt = function(e) {
|
|
1141
|
-
var t, s, l;
|
|
1142
|
-
a(this, d, he).call(this, e), this.isSingleSelect && !this.alwaysOpen && ((t = n(this, p)) == null || t.openClose(), (s = n(this, p)) == null || s.clearSearch()), (l = n(this, p)) == null || l.focus(), a(this, d, ge).call(this);
|
|
1143
|
-
}, Lt = function(e, t) {
|
|
1144
|
-
var s;
|
|
1145
|
-
(s = n(this, p)) == null || s.focus(), this.updateListPosition(), a(this, d, _t).call(this, e, t);
|
|
1146
|
-
}, St = function(e) {
|
|
1147
|
-
this.selectedName !== e && (this.selectedName = e, a(this, d, Tt).call(this));
|
|
1148
|
-
}, xt = function() {
|
|
1149
|
-
var e;
|
|
1150
|
-
this.isListOpened = !0, n(this, A) && n(this, I) && (window.addEventListener("scroll", n(this, A), !0), window.addEventListener("resize", n(this, I))), !(!n(this, m) || !this.srcElement) && (this.appendToBody ? (document.body.appendChild(n(this, m).srcElement), (e = n(this, F)) == null || e.observe(this.srcElement)) : this.srcElement.appendChild(n(this, m).srcElement), this.updateListPosition(), a(this, d, pe).call(this, !0), a(this, d, yt).call(this), a(this, d, At).call(this));
|
|
1151
|
-
}, de = function() {
|
|
1152
|
-
var t;
|
|
1153
|
-
this.alwaysOpen || (this.isListOpened = !1, n(this, A) && n(this, I) && (window.removeEventListener("scroll", n(this, A), !0), window.removeEventListener("resize", n(this, I))), !n(this, m) || !this.srcElement) || !(this.appendToBody ? document.body.contains(n(this, m).srcElement) : this.srcElement.contains(n(this, m).srcElement)) || (b(this, q, n(this, m).srcElement.scrollTop), this.appendToBody ? (document.body.removeChild(n(this, m).srcElement), (t = n(this, F)) == null || t.disconnect()) : this.srcElement.removeChild(n(this, m).srcElement), a(this, d, pe).call(this, !1), a(this, d, It).call(this));
|
|
1154
|
-
}, ue = function(e, t) {
|
|
1155
|
-
if (!n(this, m) || !n(this, p))
|
|
1156
|
-
return;
|
|
1157
|
-
const s = t ? "treeselect-list--top-to-body" : "treeselect-list--top", l = t ? "treeselect-list--bottom-to-body" : "treeselect-list--bottom";
|
|
1158
|
-
e ? (n(this, m).srcElement.classList.add(s), n(this, m).srcElement.classList.remove(l), n(this, p).srcElement.classList.add("treeselect-input--top"), n(this, p).srcElement.classList.remove("treeselect-input--bottom")) : (n(this, m).srcElement.classList.remove(s), n(this, m).srcElement.classList.add(l), n(this, p).srcElement.classList.remove("treeselect-input--top"), n(this, p).srcElement.classList.add("treeselect-input--bottom"));
|
|
1159
|
-
}, me = function(e) {
|
|
1160
|
-
!n(this, p) || !n(this, m) || (e ? (n(this, p).srcElement.classList.add("treeselect-input--focused"), n(this, m).srcElement.classList.add("treeselect-list--focused")) : (n(this, p).srcElement.classList.remove("treeselect-input--focused"), n(this, m).srcElement.classList.remove("treeselect-list--focused")));
|
|
1161
|
-
}, pe = function(e) {
|
|
1162
|
-
var t, s, l, r;
|
|
1163
|
-
e ? (t = n(this, p)) == null || t.srcElement.classList.add("treeselect-input--opened") : (s = n(this, p)) == null || s.srcElement.classList.remove("treeselect-input--opened"), this.staticList ? (l = n(this, m)) == null || l.srcElement.classList.add("treeselect-list--static") : (r = n(this, m)) == null || r.srcElement.classList.remove("treeselect-list--static");
|
|
1164
|
-
}, fe = function(e) {
|
|
1165
|
-
!n(this, A) || !n(this, I) || !n(this, y) || !n(this, V) || ((!this.alwaysOpen || e) && (window.removeEventListener("scroll", n(this, A), !0), window.removeEventListener("resize", n(this, I))), document.removeEventListener("mousedown", n(this, y), !0), document.removeEventListener("focus", n(this, y), !0), window.removeEventListener("blur", n(this, V), { capture: !1 }));
|
|
1166
|
-
}, yt = function() {
|
|
1167
|
-
var t, s, l;
|
|
1168
|
-
const e = (t = n(this, m)) == null ? void 0 : t.isLastFocusedElementExist();
|
|
1169
|
-
this.saveScrollPosition && e ? (s = n(this, m)) == null || s.srcElement.scroll(0, n(this, q)) : (l = n(this, m)) == null || l.focusFirstListElement();
|
|
1170
|
-
}, // Emits
|
|
1171
|
-
ge = function() {
|
|
1172
|
-
var e;
|
|
1173
|
-
(e = this.srcElement) == null || e.dispatchEvent(new CustomEvent("input", { detail: this.value })), this.inputCallback && this.inputCallback(this.value);
|
|
1174
|
-
}, Tt = function() {
|
|
1175
|
-
var e;
|
|
1176
|
-
(e = this.srcElement) == null || e.dispatchEvent(new CustomEvent("name-change", { detail: this.selectedName })), this.nameChangeCallback && this.nameChangeCallback(this.selectedName);
|
|
1177
|
-
}, At = function() {
|
|
1178
|
-
var e;
|
|
1179
|
-
this.alwaysOpen || ((e = this.srcElement) == null || e.dispatchEvent(new CustomEvent("open", { detail: this.value })), this.openCallback && this.openCallback(this.value));
|
|
1180
|
-
}, It = function() {
|
|
1181
|
-
var e;
|
|
1182
|
-
this.alwaysOpen || ((e = this.srcElement) == null || e.dispatchEvent(new CustomEvent("close", { detail: this.value })), this.closeCallback && this.closeCallback(this.value));
|
|
1183
|
-
}, Nt = function(e) {
|
|
1184
|
-
var s;
|
|
1185
|
-
const t = (e == null ? void 0 : e.trim()) ?? "";
|
|
1186
|
-
(s = this.srcElement) == null || s.dispatchEvent(new CustomEvent("search", { detail: t })), this.searchCallback && this.searchCallback(t);
|
|
1187
|
-
}, _t = function(e, t) {
|
|
1188
|
-
var s;
|
|
1189
|
-
(s = this.srcElement) == null || s.dispatchEvent(new CustomEvent("open-close-group", { detail: { groupId: e, isClosed: t } })), this.openCloseGroupCallback && this.openCloseGroupCallback(e, t);
|
|
1190
|
-
};
|
|
1191
1235
|
export {
|
|
1192
|
-
|
|
1236
|
+
Fe as default
|
|
1193
1237
|
};
|