treeselectjs 0.12.3 → 0.13.0

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