@web-utils/form-ui 1.0.0-beta104 → 1.0.0-beta106

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,1361 +0,0 @@
1
- import { allProps as e } from "../props/vue-tree-select.mjs";
2
- import { Fragment as t, Teleport as n, Transition as r, TransitionGroup as i, computed as a, createElementBlock as o, createElementVNode as s, createTextVNode as c, createVNode as l, inject as u, isVNode as d, mergeProps as f, nextTick as p, onBeforeUnmount as m, onMounted as h, onUnmounted as g, openBlock as _, ref as v, useTemplateRef as y, watch as b } from "vue";
3
- import { isPromise as x } from "@web-utils/core";
4
- import { debounce as S, last as C, noop as w, once as T } from "lodash-es";
5
- //#region src/components/tree-select/utils/index.ts
6
- var E = w, D = (e) => function(t, ...n) {
7
- t.type === "mousedown" && t.button === 0 && e.call(this, t, ...n);
8
- }, O = (e, t) => {
9
- let n = e.getBoundingClientRect(), r = t.getBoundingClientRect(), i = t.offsetHeight / 3;
10
- r.bottom + i > n.bottom ? e.scrollTop = Math.min(t.offsetTop + t.clientHeight - e.offsetHeight + i, e.scrollHeight) : r.top - i < n.top && (e.scrollTop = Math.max(t.offsetTop - i, 0));
11
- };
12
- function k(e) {
13
- let t = [], n = e.parentNode;
14
- for (; n && n.nodeName !== "BODY" && n.nodeType === document.ELEMENT_NODE;) A(n) && t.push(n), n = n.parentNode;
15
- return t.push(window), t;
16
- }
17
- function A(e) {
18
- if (!e) return !1;
19
- let { overflow: t, overflowX: n, overflowY: r } = getComputedStyle(e);
20
- return /(auto|scroll|overlay)/.test(t + r + n);
21
- }
22
- function ee(e, t) {
23
- let n = k(e);
24
- return window.addEventListener("resize", t, { passive: !0 }), n.forEach((e) => {
25
- e.addEventListener("scroll", t, { passive: !0 });
26
- }), function() {
27
- window.removeEventListener("resize", t), n.forEach((e) => {
28
- e.removeEventListener("scroll", t);
29
- });
30
- };
31
- }
32
- var j = (e) => Number.isNaN(e), M = () => ({});
33
- function N(e) {
34
- return typeof e != "object" || !e ? !1 : Object.getPrototypeOf(e) === Object.prototype;
35
- }
36
- function te(e, t, n) {
37
- N(n) ? (e[t] || (e[t] = {}), P(e[t], n)) : e[t] = n;
38
- }
39
- function P(e, t) {
40
- if (N(t)) {
41
- let n = Object.keys(t);
42
- for (let r = 0, i = n.length; r < i; r++) te(e, n[r], t[n[r]]);
43
- }
44
- return e;
45
- }
46
- function F(e, t, n) {
47
- for (let r = 0, i = e.length; r < i; r++) if (t.call(n, e[r], r, e)) return e[r];
48
- }
49
- function I(e, t) {
50
- let n = e.indexOf(t);
51
- n !== -1 && e.splice(n, 1);
52
- }
53
- function L(e, t) {
54
- return e.indexOf(t) !== -1;
55
- }
56
- function R(e, t) {
57
- if (e.length !== t.length) return !0;
58
- for (let n = 0; n < e.length; n++) if (e[n] !== t[n]) return !0;
59
- return !1;
60
- }
61
- function ne(e, t) {
62
- let n = t.length, r = e.length;
63
- if (r > n) return !1;
64
- if (r === n) return e === t;
65
- outer: for (let i = 0, a = 0; i < r; i++) {
66
- let r = e.charCodeAt(i);
67
- for (; a < n;) if (t.charCodeAt(a++) === r) continue outer;
68
- return !1;
69
- }
70
- return !0;
71
- }
72
- var z, B = [], re = 100;
73
- function ie() {
74
- z = window.setInterval(() => {
75
- B.forEach(V);
76
- }, re);
77
- }
78
- function ae() {
79
- z && clearInterval(z), z = null;
80
- }
81
- function V(e) {
82
- let { $el: t, listener: n, lastWidth: r, lastHeight: i } = e, a = t.offsetWidth, o = t.offsetHeight;
83
- (r !== a || i !== o) && (e.lastWidth = a, e.lastHeight = o, n({
84
- width: a,
85
- height: o
86
- }));
87
- }
88
- function oe(e, t) {
89
- let n = {
90
- $el: e,
91
- listener: t,
92
- lastWidth: null,
93
- lastHeight: null
94
- };
95
- return B.push(n), V(n), ie(), () => {
96
- I(B, n), B.length || ae();
97
- };
98
- }
99
- function se(e, t) {
100
- let n = document.createElement("_"), r = n.appendChild(document.createElement("_")), i = n.appendChild(document.createElement("_")), a = r.appendChild(document.createElement("_")), o, s;
101
- return r.style.cssText = n.style.cssText = "height:100%;left:0;opacity:0;overflow:hidden;pointer-events:none;position:absolute;top:0;transition:0s;width:100%;z-index:-1", a.style.cssText = i.style.cssText = "display:block;height:100%;transition:0s;width:100%", a.style.width = a.style.height = "200%", e.appendChild(n), c(), u;
102
- function c() {
103
- l();
104
- let a = e.offsetWidth, u = e.offsetHeight;
105
- (a !== o || u !== s) && (o = a, s = u, i.style.width = `${a * 2}px`, i.style.height = `${u * 2}px`, n.scrollLeft = n.scrollWidth, n.scrollTop = n.scrollHeight, r.scrollLeft = r.scrollWidth, r.scrollTop = r.scrollHeight, t({
106
- width: a,
107
- height: u
108
- })), r.addEventListener("scroll", c), n.addEventListener("scroll", c);
109
- }
110
- function l() {
111
- r.removeEventListener("scroll", c), n.removeEventListener("scroll", c);
112
- }
113
- function u() {
114
- l(), e.removeChild(n);
115
- }
116
- }
117
- function ce(e, t) {
118
- let n = document.documentMode === 9, r = !0, i = (n ? oe : se)(e, (...e) => r || t(...e));
119
- return r = !1, i;
120
- }
121
- //#endregion
122
- //#region src/components/tree-select/constants.ts
123
- var H = "ALL_CHILDREN", U = "ALL_DESCENDANTS", W = "LEAF_CHILDREN", G = "LEAF_DESCENDANTS", le = "LOAD_ROOT_OPTIONS", ue = "LOAD_CHILDREN_OPTIONS", de = "ASYNC_SEARCH", K = {
124
- BACKSPACE: 8,
125
- ENTER: 13,
126
- ESCAPE: 27,
127
- END: 35,
128
- HOME: 36,
129
- ARROW_LEFT: 37,
130
- ARROW_UP: 38,
131
- ARROW_RIGHT: 39,
132
- ARROW_DOWN: 40,
133
- DELETE: 46
134
- }, fe = process.env.NODE_ENV === "development" ? 10 : /* istanbul ignore next */ 200, q = Symbol("vueTreeSelect");
135
- //#endregion
136
- //#region src/components/tree-select/components/VueTreeSelectHiddenFields.vue?vue&type=script&lang.jsx
137
- function pe(e) {
138
- // istanbul ignore next
139
- return typeof e == "string" ? e :
140
- // istanbul ignore else
141
- e != null && !j(e) ? JSON.stringify(e) : "";
142
- }
143
- //#endregion
144
- //#region src/components/tree-select/components/VueTreeSelectHiddenFields.vue
145
- var me = {
146
- name: "VueTreeSelectHiddenFields",
147
- setup() {
148
- let e = u(q);
149
- return () => {
150
- if (!e.name || e.disabled || !e.hasValue) return null;
151
- let t = e.internalValue.map(pe);
152
- return e.multiple && e.joinValues && (t = [t.join(e.delimiter)]), t.map((t, n) => l("input", {
153
- type: "hidden",
154
- name: e.name,
155
- value: t,
156
- key: `hidden-field-${n}`
157
- }, null));
158
- };
159
- }
160
- }, he = [
161
- K.ENTER,
162
- K.END,
163
- K.HOME,
164
- K.ARROW_LEFT,
165
- K.ARROW_UP,
166
- K.ARROW_RIGHT,
167
- K.ARROW_DOWN
168
- ], ge = {
169
- name: "VueTreeSelectInput",
170
- setup(e, { expose: t }) {
171
- let n = u(q), r = v(""), i = v(5), o = y("sizer"), s = y("input"), c = () => {
172
- n.trigger.searchQuery = r.value;
173
- }, d = S(c, fe, {
174
- leading: !0,
175
- trailing: !0
176
- }), m = a(() => n.searchable && !n.disabled && n.multiple), h = a(() => ({ width: m.value ? `${i.value}px` : null })), g = () => {
177
- if (!n.disabled) {
178
- var e;
179
- (e = s.value) == null || e.focus();
180
- }
181
- }, _ = () => {
182
- var e;
183
- (e = s.value) == null || e.blur();
184
- }, x = () => {
185
- // istanbul ignore else
186
- n.trigger.isFocused = !0, n.openOnFocus && n.openMenu();
187
- }, C = () => {
188
- let e = n.getMenu();
189
- // istanbul ignore next
190
- if (e && document.activeElement === e) return g();
191
- n.trigger.isFocused = !1, n.closeMenu();
192
- }, w = (e) => {
193
- let { value: t } = e.target;
194
- r.value = t, t ? d() : (d.cancel(), c());
195
- }, T = () => {
196
- w({ target: { value: "" } });
197
- }, E = (e) => {
198
- let t = "which" in e ? e.which : /* istanbul ignore next */ e.keyCode;
199
- if (!(e.ctrlKey || e.shiftKey || e.altKey || e.metaKey)) {
200
- if (!n.menu.isOpen && L(he, t)) return e.preventDefault(), n.openMenu();
201
- switch (t) {
202
- case K.BACKSPACE:
203
- n.backspaceRemoves && !r.value.length && n.removeLastValue();
204
- break;
205
- case K.ENTER: {
206
- if (e.preventDefault(), n.menu.current === null) return;
207
- let t = n.getNode(n.menu.current);
208
- if (t.isBranch && n.disableBranchNodes) return;
209
- n.select(t);
210
- break;
211
- }
212
- case K.ESCAPE:
213
- r.value.length ? T() : n.menu.isOpen && n.closeMenu();
214
- break;
215
- case K.END:
216
- e.preventDefault(), n.highlightLastOption();
217
- break;
218
- case K.HOME:
219
- e.preventDefault(), n.highlightFirstOption();
220
- break;
221
- case K.ARROW_LEFT: {
222
- let t = n.getNode(n.menu.current);
223
- t.isBranch && n.shouldExpand(t) ? (e.preventDefault(), n.toggleExpanded(t)) : !t.isRootNode && (t.isLeaf || t.isBranch && !n.shouldExpand(t)) && (e.preventDefault(), n.setCurrentHighlightedOption(t.parentNode));
224
- break;
225
- }
226
- case K.ARROW_UP:
227
- e.preventDefault(), n.highlightPrevOption();
228
- break;
229
- case K.ARROW_RIGHT: {
230
- let t = n.getNode(n.menu.current);
231
- t.isBranch && !n.shouldExpand(t) && (e.preventDefault(), n.toggleExpanded(t));
232
- break;
233
- }
234
- case K.ARROW_DOWN:
235
- e.preventDefault(), n.highlightNextOption();
236
- break;
237
- case K.DELETE:
238
- n.deleteRemoves && !r.value.length && n.removeLastValue();
239
- break;
240
- default:
241
- // istanbul ignore else
242
- n.openMenu();
243
- }
244
- }
245
- }, D = (e) => {
246
- // istanbul ignore next
247
- r.value.length && e.stopPropagation();
248
- }, O = () => l("input", {
249
- ref: "input",
250
- class: "vue-treeselect__input",
251
- type: "text",
252
- autocomplete: "off",
253
- tabIndex: n.tabIndex,
254
- required: n.required && !n.hasValue,
255
- value: r.value,
256
- style: h.value,
257
- onFocus: x,
258
- onInput: w,
259
- onBlur: C,
260
- onKeydown: E,
261
- onMousedown: D
262
- }, null), k = () => l("div", {
263
- ref: "sizer",
264
- class: "vue-treeselect__sizer"
265
- }, [r.value]), A = () => {
266
- var e;
267
- i.value = Math.max(5, ((e = o.value) == null ? void 0 : e.scrollWidth) + 15);
268
- };
269
- return b(() => n.trigger.searchQuery, (e) => {
270
- r.value = e;
271
- }), b(r, () => {
272
- // istanbul ignore else
273
- m.value && p(A);
274
- }), t({
275
- blur: _,
276
- focus: g
277
- }), () => {
278
- let e = {}, t = [];
279
- return n.searchable && !n.disabled && (t.push(O()), m.value && t.push(k())), n.searchable || P(e, {
280
- on: {
281
- focus: x,
282
- blur: C,
283
- keydown: E
284
- },
285
- ref: "input"
286
- }), !n.searchable && !n.disabled && P(e, { attrs: { tabIndex: n.tabIndex } }), l("div", f({ class: "vue-treeselect__input-container" }, e), [t]);
287
- };
288
- }
289
- }, _e = {
290
- name: "VueTreeSelectPlaceholder",
291
- setup() {
292
- let e = u(q);
293
- return () => l("div", { class: {
294
- "vue-treeselect__placeholder": !0,
295
- "vue-treeselect-helper-zoom-effect-off": !0,
296
- "vue-treeselect-helper-hide": e.hasValue || e.trigger.searchQuery
297
- } }, [e.placeholder]);
298
- }
299
- }, ve = {
300
- name: "VueTreeSelectSingleValue",
301
- setup(e, { expose: n }) {
302
- let r = u(q);
303
- return n({ input: y("input") }), () => {
304
- let e = r.selectedNodes[0];
305
- return l(t, null, [
306
- r.hasValue && !r.trigger.searchQuery ? l("div", { class: "vue-treeselect__single-value" }, [r.$slots["value-label"] ? r.$slots["value-label"]({ node: e }) : e.label]) : null,
307
- l(_e, null, null),
308
- l(ge, { ref: "input" }, null)
309
- ]);
310
- };
311
- }
312
- }, ye = {
313
- xmlns: "http://www.w3.org/2000/svg",
314
- viewBox: "0 0 348.333 348.333"
315
- }, be = /* @__PURE__ */ Object.assign({ name: "VueTreeSelectDelete" }, {
316
- __name: "VueTreeSelectDelete",
317
- setup(e) {
318
- return (e, t) => (_(), o("svg", ye, [...t[0] || (t[0] = [s("path", { d: "M336.559 68.611L231.016 174.165l105.543 105.549c15.699 15.705 15.699 41.145 0 56.85-7.844 7.844-18.128 11.769-28.407 11.769-10.296 0-20.581-3.919-28.419-11.769L174.167 231.003 68.609 336.563c-7.843 7.844-18.128 11.769-28.416 11.769-10.285 0-20.563-3.919-28.413-11.769-15.699-15.698-15.699-41.139 0-56.85l105.54-105.549L11.774 68.611c-15.699-15.699-15.699-41.145 0-56.844 15.696-15.687 41.127-15.687 56.829 0l105.563 105.554L279.721 11.767c15.705-15.687 41.139-15.687 56.832 0 15.705 15.699 15.705 41.145.006 56.844z" }, null, -1)])]));
319
- }
320
- }), xe = {
321
- name: "VueTreeSelectMultiValueItem",
322
- props: { node: {
323
- type: Object,
324
- required: !0
325
- } },
326
- setup(e) {
327
- let t = u(q), n = D(() => {
328
- t.select(e.node);
329
- });
330
- return () => l("div", { class: "vue-treeselect__multi-value-item-container" }, [l("div", {
331
- class: {
332
- "vue-treeselect__multi-value-item": !0,
333
- "vue-treeselect__multi-value-item-disabled": e.node.isDisabled,
334
- "vue-treeselect__multi-value-item-new": e.node.isNew
335
- },
336
- onMousedown: n
337
- }, [l("span", { class: "vue-treeselect__multi-value-label" }, [t.$slots["value-label"] ? t.$slots["value-label"]({ node: e.node }) : e.node.label]), l("span", { class: "vue-treeselect__icon vue-treeselect__value-remove" }, [l(be, null, null)])])]);
338
- }
339
- }, Se = {
340
- name: "VueTreeSelectMultiValue",
341
- setup(e, { expose: t }) {
342
- let n = u(q), r = { props: {
343
- tag: "div",
344
- name: "vue-treeselect__multi-value-item--transition",
345
- appear: !0
346
- } }, a = () => n.internalValue.slice(0, n.limit).map(n.getNode).map((e) => l(xe, {
347
- key: `multi-value-item-${e.id}`,
348
- node: e
349
- }, null)), o = () => {
350
- let e = n.internalValue.length - n.limit;
351
- return e <= 0 ? null : l("div", {
352
- class: "vue-treeselect__limit-tip vue-treeselect-helper-zoom-effect-off",
353
- key: "exceed-limit-tip"
354
- }, [l("span", { class: "vue-treeselect__limit-tip-text" }, [n.limitText(e)])]);
355
- };
356
- return t({ input: y("input") }), () => l(i, f({ class: "vue-treeselect__multi-value" }, r), { default: () => [
357
- a(),
358
- o(),
359
- l(_e, { key: "placeholder" }, null),
360
- l(ge, {
361
- ref: "input",
362
- key: "input"
363
- }, null)
364
- ] });
365
- }
366
- }, Ce = {
367
- xmlns: "http://www.w3.org/2000/svg",
368
- viewBox: "0 0 292.362 292.362"
369
- }, we = /* @__PURE__ */ Object.assign({ name: "VueTreeSelectArrow" }, {
370
- __name: "VueTreeSelectArrow",
371
- setup(e) {
372
- return (e, t) => (_(), o("svg", Ce, [...t[0] || (t[0] = [s("path", { d: "M286.935 69.377c-3.614-3.617-7.898-5.424-12.848-5.424H18.274c-4.952 0-9.233 1.807-12.85 5.424C1.807 72.998 0 77.279 0 82.228c0 4.948 1.807 9.229 5.424 12.847l127.907 127.907c3.621 3.617 7.902 5.428 12.85 5.428s9.233-1.811 12.847-5.428L286.935 95.074c3.613-3.617 5.427-7.898 5.427-12.847 0-4.948-1.814-9.229-5.427-12.85z" }, null, -1)])]));
373
- }
374
- }), Te = {
375
- name: "VueTreeSelectControl",
376
- setup(e, { expose: t }) {
377
- let n = u(q), r = a(() => n.hasValue && n.internalValue.some((e) => !n.getNode(e).isDisabled)), i = a(() => n.clearable && !n.disabled && n.hasValue && (r.value || n.allowClearingDisabled)), o = a(() => n.alwaysOpen ? !n.menu.isOpen : !0), s = D((e) => {
378
- e.preventDefault(), e.stopPropagation(), n.focusInput(), n.toggleMenu();
379
- }), c = () => {
380
- let e = n.multiple ? n.clearAllText : n.clearValueText;
381
- return i.value ? l("div", {
382
- class: "vue-treeselect__x-container",
383
- title: e,
384
- onMousedown: f
385
- }, [l(be, { class: "vue-treeselect__x" }, null)]) : null;
386
- }, d = () => {
387
- let e = {
388
- "vue-treeselect__control-arrow": !0,
389
- "vue-treeselect__control-arrow--rotated": n.menu.isOpen
390
- };
391
- return o.value ? l("div", {
392
- class: "vue-treeselect__control-arrow-container",
393
- onMousedown: s
394
- }, [l(we, { class: e }, null)]) : null;
395
- }, f = D((e) => {
396
- e.stopPropagation(), e.preventDefault();
397
- let t = n.beforeClearAll(), r = (e) => {
398
- e && n.clear();
399
- };
400
- x(t) ? t.then(r) : setTimeout(() => r(t), 0);
401
- });
402
- return t({
403
- container: y("container"),
404
- valueContainer: y("value-container")
405
- }), () => {
406
- let e = n.single ? ve : Se;
407
- return l("div", {
408
- class: "vue-treeselect__control",
409
- onMousedown: n.handleMouseDown
410
- }, [
411
- l("div", {
412
- class: "vue-treeselect__value-container",
413
- ref: "container"
414
- }, [l(e, { ref: "value-container" }, null)]),
415
- c(),
416
- d()
417
- ]);
418
- };
419
- }
420
- };
421
- //#endregion
422
- //#region src/components/tree-select/components/VueTreeSelectTip.jsx
423
- function J(e, { slots: t }) {
424
- var n;
425
- return l("div", { class: `vue-treeselect__tip vue-treeselect__${e.type}-tip` }, [l("div", { class: "vue-treeselect__icon-container" }, [l("span", { class: `vue-treeselect__icon-${e.icon}` }, null)]), l("span", { class: `vue-treeselect__tip-text vue-treeselect__${e.type}-tip-text` }, [(n = t.default) == null ? void 0 : n.call(t)])]);
426
- }
427
- J.props = {
428
- type: {
429
- type: String,
430
- required: !0
431
- },
432
- icon: {
433
- type: String,
434
- required: !0
435
- }
436
- }, J.inheritAttrs = !1;
437
- //#endregion
438
- //#region src/components/tree-select/components/VueTreeSelectOption.vue?vue&type=script&lang.jsx
439
- function Ee(e) {
440
- return typeof e == "function" || Object.prototype.toString.call(e) === "[object Object]" && !d(e);
441
- }
442
- var Y, X, Z, De = {
443
- name: "VueTreeSelectOption",
444
- props: { node: {
445
- type: Object,
446
- required: !0
447
- } },
448
- setup(e) {
449
- let t = u(q), n = a(() => e.node.isBranch && t.shouldExpand(e.node)), i = a(() => t.shouldShowOptionInMenu(e.node)), o = () => l("div", {
450
- class: {
451
- "vue-treeselect__option": !0,
452
- "vue-treeselect__option--disabled": e.node.isDisabled,
453
- "vue-treeselect__option--selected": t.isSelected(e.node),
454
- "vue-treeselect__option--highlight": e.node.isHighlighted,
455
- "vue-treeselect__option--matched": t.localSearch.active && e.node.isMatched,
456
- "vue-treeselect__option--hide": !i.value
457
- },
458
- onMouseenter: b,
459
- "data-id": e.node.id
460
- }, [d(), f([p([m()]), h()])]), s = () => n.value ? l("div", { class: "vue-treeselect__list" }, [
461
- g(),
462
- _(),
463
- v(),
464
- y()
465
- ]) : null, d = () => {
466
- if (t.shouldFlattenOptions && i.value) return null;
467
- if (e.node.isBranch) {
468
- let e = { props: {
469
- name: "vue-treeselect__option-arrow--prepare",
470
- appear: !0
471
- } }, t = {
472
- "vue-treeselect__option-arrow": !0,
473
- "vue-treeselect__option-arrow--rotated": n.value
474
- };
475
- return l("div", {
476
- class: "vue-treeselect__option-arrow-container",
477
- onMousedown: x
478
- }, [l(r, e, { default: () => [l(we, { class: t }, null)] })]);
479
- }
480
- return t.hasBranchNodes ? (Y || (Y = l("div", { class: "vue-treeselect__option-arrow-placeholder" }, [c("\xA0")])), Y) : null;
481
- }, f = (e) => l("div", {
482
- class: "vue-treeselect__label-container",
483
- onMousedown: S
484
- }, [e]), p = (n) => t.single || t.disableBranchNodes && e.node.isBranch ? null : l("div", { class: "vue-treeselect__checkbox-container" }, [n]), m = () => {
485
- let n = t.forest.checkedStateMap[e.node.id], r = {
486
- "vue-treeselect__checkbox": !0,
487
- "vue-treeselect__checkbox--checked": n === 2,
488
- "vue-treeselect__checkbox--indeterminate": n === 1,
489
- "vue-treeselect__checkbox--unchecked": n === 0,
490
- "vue-treeselect__checkbox--disabled": e.node.isDisabled
491
- };
492
- return X || (X = l("span", { class: "vue-treeselect__check-mark" }, null)), Z || (Z = l("span", { class: "vue-treeselect__minus-mark" }, null)), l("span", { class: r }, [X, Z]);
493
- }, h = () => {
494
- let n = e.node.isBranch && (t.localSearch.active ? t.showCountOnSearchComputed : t.showCount), r = n ? t.localSearch.active ? t.localSearch.countMap[e.node.id][t.showCountOf] : e.node.count[t.showCountOf] : NaN, i = "vue-treeselect__label", a = "vue-treeselect__count", o = t.$slots["option-label"];
495
- return o ? o({
496
- node: e.node,
497
- shouldShowCount: n,
498
- count: r,
499
- labelClassName: i,
500
- countClassName: a
501
- }) : l("label", { class: i }, [e.node.label, n && l("span", { class: a }, [
502
- c("("),
503
- r,
504
- c(")")
505
- ])]);
506
- }, g = () => e.node.childrenStates.isLoaded ? e.node.children.map((e) => l(De, {
507
- node: e,
508
- key: e.id
509
- }, null)) : null, _ = () => !e.node.childrenStates.isLoaded || e.node.children.length ? null : l(J, {
510
- type: "no-children",
511
- icon: "warning"
512
- }, { default: () => [t.noChildrenText] }), v = () => e.node.childrenStates.isLoading ? l(J, {
513
- type: "loading",
514
- icon: "loader"
515
- }, { default: () => [t.loadingText] }) : null, y = () => e.node.childrenStates.loadingError ? l(J, {
516
- type: "error",
517
- icon: "error"
518
- }, { default: () => [e.node.childrenStates.loadingError, l("a", {
519
- class: "vue-treeselect__retry",
520
- title: t.retryTitle,
521
- onMousedown: C
522
- }, [t.retryText])] }) : null, b = (n) => {
523
- n.target === n.currentTarget && t.setCurrentHighlightedOption(e.node, !1);
524
- }, x = D(() => {
525
- t.toggleExpanded(e.node);
526
- }), S = D(() => {
527
- e.node.isBranch && t.disableBranchNodes ? t.toggleExpanded(e.node) : t.select(e.node);
528
- }), C = D(() => {
529
- t.loadChildrenOptions(e.node);
530
- });
531
- return () => {
532
- let n;
533
- return l("div", { class: {
534
- "vue-treeselect__list-item": !0,
535
- [`vue-treeselect__indent-level-${t.shouldFlattenOptions ? 0 : e.node.level}`]: !0
536
- } }, [o(), e.node.isBranch && l(r, { name: "vue-treeselect__list--transition" }, Ee(n = s()) ? n : { default: () => [n] })]);
537
- };
538
- }
539
- };
540
- //#endregion
541
- //#region src/components/tree-select/components/VueTreeSelectMenu.vue?vue&type=script&lang.jsx
542
- function Oe(e) {
543
- return typeof e == "function" || Object.prototype.toString.call(e) === "[object Object]" && !d(e);
544
- }
545
- var ke = {
546
- top: "top",
547
- bottom: "bottom",
548
- above: "top",
549
- below: "bottom"
550
- }, Ae = {
551
- name: "VueTreeSelectMenu",
552
- setup() {
553
- let e = u(q), t = null, n = null, i = a(() => ({ maxHeight: `${e.maxHeight}px` })), o = a(() => ({ zIndex: e.appendToBody ? null : e.zIndex })), s = () => e.menu.isOpen ? l("div", {
554
- ref: "menu",
555
- class: "vue-treeselect__menu",
556
- onMousedown: e.handleMouseDown,
557
- style: i.value
558
- }, [
559
- c(),
560
- e.async ? _() : e.localSearch.active ? m() : f(),
561
- d()
562
- ]) : null, c = () => {
563
- let t = e.$slots["before-list"];
564
- return t ? t() : null;
565
- }, d = () => {
566
- let t = e.$slots["after-list"];
567
- return t ? t() : null;
568
- }, f = () => e.rootOptionsStates.isLoading ? x() : e.rootOptionsStates.loadingError ? S() : e.rootOptionsStates.isLoaded && e.forest.normalizedOptions.length === 0 ? w() : v(), m = () => e.rootOptionsStates.isLoading ? x() : e.rootOptionsStates.loadingError ? S() : e.rootOptionsStates.isLoaded && e.forest.normalizedOptions.length === 0 ? w() : e.localSearch.noResults ? T() : v(), _ = () => {
569
- let t = e.getRemoteSearchEntry(), n = e.trigger.searchQuery === "" && !e.defaultOptions, r = n ? !1 : t.isLoaded && t.options.length === 0;
570
- return n ? y() : t.isLoading ? x() : t.loadingError ? C() : r ? T() : v();
571
- }, v = () => l("div", { class: "vue-treeselect__list" }, [e.forest.normalizedOptions.map((e) => l(De, {
572
- node: e,
573
- key: e.id
574
- }, null))]), y = () => l(J, {
575
- type: "search-prompt",
576
- icon: "warning"
577
- }, { default: () => [e.searchPromptText] }), x = () => l(J, {
578
- type: "loading",
579
- icon: "loader"
580
- }, { default: () => [e.loadingText] }), S = () => l(J, {
581
- type: "error",
582
- icon: "error"
583
- }, { default: () => [e.rootOptionsStates.loadingError, l("a", {
584
- class: "vue-treeselect__retry",
585
- onClick: e.loadRootOptions,
586
- title: e.retryTitle
587
- }, [e.retryText])] }), C = () => {
588
- let t = e.getRemoteSearchEntry();
589
- return l(J, {
590
- type: "error",
591
- icon: "error"
592
- }, { default: () => [t.loadingError, l("a", {
593
- class: "vue-treeselect__retry",
594
- onClick: e.handleRemoteSearch,
595
- title: e.retryTitle
596
- }, [e.retryText])] });
597
- }, w = () => l(J, {
598
- type: "no-options",
599
- icon: "warning"
600
- }, { default: () => [e.noOptionsText] }), T = () => l(J, {
601
- type: "no-results",
602
- icon: "warning"
603
- }, { default: () => [e.noResultsText] }), E = () => {
604
- O(), k(), A();
605
- }, D = () => {
606
- j(), M();
607
- }, O = () => {
608
- if (!e.menu.isOpen) return;
609
- let t = e.getMenu(), n = e.getControl(), r = t.getBoundingClientRect(), i = n.getBoundingClientRect(), a = r.height, o = window.innerHeight, s = i.top, c = window.innerHeight - i.bottom, l = i.top >= 0 && i.top <= o || i.top < 0 && i.bottom > 0, u = c > a + 40, d = s > a + 40;
610
- l ? e.openDirection === "auto" ? u || !d ? e.menu.placement = "bottom" : e.menu.placement = "top" : e.menu.placement = ke[e.openDirection] : e.closeMenu();
611
- }, k = () => {
612
- let n = e.getMenu();
613
- t || (t = { remove: ce(n, O) });
614
- }, A = () => {
615
- let t = e.getControl();
616
- n || (n = { remove: ee(t, O) });
617
- }, j = () => {
618
- t && (t.remove(), t = null);
619
- }, M = () => {
620
- n && (n.remove(), n = null);
621
- };
622
- return b(() => e.menu.isOpen, (e) => {
623
- e ? p(E) : D();
624
- }), h(() => {
625
- e.menu.isOpen && p(E);
626
- }), g(() => {
627
- D();
628
- }), () => {
629
- let e;
630
- return l("div", {
631
- ref: "menu-container",
632
- class: "vue-treeselect__menu-container",
633
- style: o.value
634
- }, [l(r, { name: "vue-treeselect__menu--transition" }, Oe(e = s()) ? e : { default: () => [e] })]);
635
- };
636
- }
637
- }, je = {
638
- name: "VueTreeSelectPortalTarget",
639
- setup() {
640
- let e = u(q), t = y("el"), n = y("menu"), r = null, i = null, a = () => {
641
- let r = e.getControl().getBoundingClientRect(), i = t.value.getBoundingClientRect(), a = e.menu.placement === "bottom" ? r.height : 0, o = `${Math.round(r.left - i.left)}px`, s = `${Math.round(r.top - i.top + a)}px`, c = n.value.$refs["menu-container"].style, l = F([
642
- "transform",
643
- "webkitTransform",
644
- "MozTransform",
645
- "msTransform"
646
- ], (e) => e in document.body.style);
647
- c[l] = `translate(${o}, ${s})`;
648
- }, o = () => {
649
- let t = e.getControl();
650
- r || (r = { remove: ee(t, a) });
651
- }, s = () => {
652
- let n = e.getControl().getBoundingClientRect();
653
- t.value.style.width = `${n.width}px`;
654
- }, c = () => {
655
- let t = e.getControl();
656
- i || (i = { remove: ce(t, () => {
657
- s(), a();
658
- }) });
659
- }, d = () => {
660
- r && (r.remove(), r = null);
661
- }, f = () => {
662
- i && (i.remove(), i = null);
663
- }, p = () => {
664
- d(), f();
665
- }, g = () => {
666
- s(), a(), o(), c();
667
- };
668
- return b(() => e.menu.isOpen, (e) => {
669
- e ? g() : p();
670
- }), b(() => e.menu.placement, () => {
671
- a();
672
- }), h(() => {
673
- e.menu.isOpen && g();
674
- }), m(() => {
675
- p();
676
- }), () => l("div", {
677
- ref: "el",
678
- class: ["vue-treeselect__portal-target", e.wrapperClass],
679
- style: { zIndex: e.zIndex },
680
- "data-instance-id": e.getInstanceId()
681
- }, [l(Ae, { ref: "menu" }, null)]);
682
- }
683
- }, Me = {
684
- name: "VueTreeSelectMenuPortal",
685
- setup(e, { expose: t }) {
686
- return t({ portalTarget: y("portalTarget") }), () => l(n, { to: "body" }, { default: () => [l(je, { ref: "portalTarget" }, null)] });
687
- }
688
- };
689
- //#endregion
690
- //#region src/components/tree-select/VueTreeSelect.vue?vue&type=script&lang.jsx
691
- function Ne(e, t) {
692
- let n = 0;
693
- do {
694
- if (e.level < n) return -1;
695
- if (t.level < n) return 1;
696
- if (e.index[n] !== t.index[n]) return e.index[n] - t.index[n];
697
- n++;
698
- } while (!0);
699
- }
700
- function Pe(e, t) {
701
- return e.level === t.level ? Ne(e, t) : e.level - t.level;
702
- }
703
- function Q() {
704
- return {
705
- isLoaded: !1,
706
- isLoading: !1,
707
- loadingError: ""
708
- };
709
- }
710
- function Fe(e) {
711
- // istanbul ignore next
712
- return typeof e == "string" ? e : typeof e == "number" && !j(e) ? `${e}` : "";
713
- }
714
- function Ie(e, t, n) {
715
- return e ? ne(t, n) : L(n, t);
716
- }
717
- function $(e) {
718
- return e.message || String(e);
719
- }
720
- //#endregion
721
- //#region src/components/tree-select/VueTreeSelect.vue
722
- var Le = {
723
- name: "VueTreeSelect",
724
- provide() {
725
- return { [q]: this };
726
- },
727
- props: {
728
- ...e,
729
- disabled: {
730
- type: Boolean,
731
- default: void 0
732
- },
733
- placeholder: String
734
- },
735
- emits: [
736
- "update:modelValue",
737
- "search-change",
738
- "close",
739
- "open",
740
- "deselect",
741
- "select"
742
- ],
743
- data() {
744
- return {
745
- trigger: {
746
- isFocused: !1,
747
- searchQuery: ""
748
- },
749
- menu: {
750
- isOpen: !1,
751
- current: null,
752
- lastScrollPosition: 0,
753
- placement: "bottom"
754
- },
755
- forest: {
756
- normalizedOptions: [],
757
- nodeMap: M(),
758
- checkedStateMap: M(),
759
- selectedNodeIds: this.extractCheckedNodeIdsFromValue(),
760
- selectedNodeMap: M()
761
- },
762
- rootOptionsStates: Q(),
763
- localSearch: {
764
- active: !1,
765
- noResults: !0,
766
- countMap: M()
767
- },
768
- remoteSearch: M()
769
- };
770
- },
771
- computed: {
772
- selectedNodes() {
773
- return this.forest.selectedNodeIds.map(this.getNode);
774
- },
775
- internalValue() {
776
- let e;
777
- // istanbul ignore else
778
- if (this.single || this.flat || this.disableBranchNodes || this.valueConsistsOf === "ALL") e = this.forest.selectedNodeIds.slice();
779
- else if (this.valueConsistsOf === "BRANCH_PRIORITY") e = this.forest.selectedNodeIds.filter((e) => {
780
- let t = this.getNode(e);
781
- return t.isRootNode ? !0 : !this.isSelected(t.parentNode);
782
- });
783
- else if (this.valueConsistsOf === "LEAF_PRIORITY") e = this.forest.selectedNodeIds.filter((e) => {
784
- let t = this.getNode(e);
785
- return t.isLeaf ? !0 : t.children.length === 0;
786
- });
787
- else if (this.valueConsistsOf === "ALL_WITH_INDETERMINATE") {
788
- let t = [];
789
- e = this.forest.selectedNodeIds.slice(), this.selectedNodes.forEach((n) => {
790
- n.ancestors.forEach((n) => {
791
- L(t, n.id) || L(e, n.id) || t.push(n.id);
792
- });
793
- }), e.push(...t);
794
- }
795
- return this.sortValueBy === "LEVEL" ? e.sort((e, t) => Pe(this.getNode(e), this.getNode(t))) : this.sortValueBy === "INDEX" && e.sort((e, t) => Ne(this.getNode(e), this.getNode(t))), e;
796
- },
797
- hasValue() {
798
- return this.internalValue.length > 0;
799
- },
800
- single() {
801
- return !this.multiple;
802
- },
803
- visibleOptionIds() {
804
- let e = [];
805
- return this.traverseAllNodesByIndex((t) => {
806
- if ((!this.localSearch.active || this.shouldOptionBeIncludedInSearchResult(t)) && e.push(t.id), t.isBranch && !this.shouldExpand(t)) return !1;
807
- }), e;
808
- },
809
- hasVisibleOptions() {
810
- return this.visibleOptionIds.length !== 0;
811
- },
812
- showCountOnSearchComputed() {
813
- return typeof this.showCountOnSearch == "boolean" ? this.showCountOnSearch : this.showCount;
814
- },
815
- hasBranchNodes() {
816
- return this.forest.normalizedOptions.some((e) => e.isBranch);
817
- },
818
- shouldFlattenOptions() {
819
- return this.localSearch.active && this.flattenSearchResults;
820
- },
821
- wrapperClass() {
822
- return {
823
- "vue-treeselect": !0,
824
- "vue-treeselect--single": this.single,
825
- "vue-treeselect--multi": this.multiple,
826
- "vue-treeselect--searchable": this.searchable,
827
- "vue-treeselect--disabled": this.disabled,
828
- "vue-treeselect--focused": this.trigger.isFocused,
829
- "vue-treeselect--has-value": this.hasValue,
830
- "vue-treeselect--open": this.menu.isOpen,
831
- "vue-treeselect--open-above": this.menu.placement === "top",
832
- "vue-treeselect--open-below": this.menu.placement === "bottom",
833
- "vue-treeselect--branch-nodes-disabled": this.disableBranchNodes,
834
- "vue-treeselect--append-to-body": this.appendToBody
835
- };
836
- }
837
- },
838
- watch: {
839
- alwaysOpen(e) {
840
- e ? this.openMenu() : this.closeMenu();
841
- },
842
- branchNodesFirst() {
843
- this.initialize();
844
- },
845
- disabled(e) {
846
- e && this.menu.isOpen ? this.closeMenu() : !e && !this.menu.isOpen && this.alwaysOpen && this.openMenu();
847
- },
848
- flat() {
849
- this.initialize();
850
- },
851
- internalValue(e, t) {
852
- R(e, t) && this.$emit("update:modelValue", this.getValue(), this.getInstanceId());
853
- },
854
- matchKeys() {
855
- this.initialize();
856
- },
857
- multiple(e) {
858
- // istanbul ignore else
859
- e && this.buildForestState();
860
- },
861
- options: {
862
- handler() {
863
- this.async || (this.initialize(), this.rootOptionsStates.isLoaded = Array.isArray(this.options));
864
- },
865
- deep: !0,
866
- immediate: !0
867
- },
868
- "trigger.searchQuery"() {
869
- this.async ? this.handleRemoteSearch() : this.handleLocalSearch(), this.$emit("search-change", this.trigger.searchQuery, this.getInstanceId());
870
- },
871
- value() {
872
- let e = this.extractCheckedNodeIdsFromValue();
873
- R(e, this.internalValue) && this.fixSelectedNodeIds(e);
874
- }
875
- },
876
- created() {
877
- this.verifyProps(), this.resetFlags();
878
- },
879
- mounted() {
880
- this.autoFocus && this.focusInput(), !this.options && !this.async && this.autoLoadRootOptions && this.loadRootOptions(), this.alwaysOpen && this.openMenu(), this.async && this.defaultOptions && this.handleRemoteSearch();
881
- },
882
- beforeUnmount() {
883
- // istanbul ignore next
884
- this.toggleClickOutsideEvent(!1);
885
- },
886
- methods: {
887
- verifyProps() {
888
- E(() => this.async ? this.searchable : !0, () => "For async search mode, the value of \"searchable\" prop must be true."), this.options == null && !this.loadOptions && E(() => !1, () => "Are you meant to dynamically load options? You need to use \"loadOptions\" prop."), this.flat && E(() => this.multiple, () => "You are using flat mode. But you forgot to add \"multiple=true\"?"), this.flat || [
889
- "autoSelectAncestors",
890
- "autoSelectDescendants",
891
- "autoDeselectAncestors",
892
- "autoDeselectDescendants"
893
- ].forEach((e) => {
894
- E(() => !this[e], () => `"${e}" only applies to flat mode.`);
895
- });
896
- },
897
- resetFlags() {
898
- this._blurOnSelect = !1;
899
- },
900
- initialize() {
901
- let e = this.async ? this.getRemoteSearchEntry().options : this.options;
902
- if (Array.isArray(e)) {
903
- let t = this.forest.nodeMap;
904
- this.forest.nodeMap = M(), this.keepDataOfSelectedNodes(t), this.forest.normalizedOptions = this.normalize(null, e, t), this.fixSelectedNodeIds(this.internalValue);
905
- } else this.forest.normalizedOptions = [];
906
- },
907
- getInstanceId() {
908
- return this.instanceId == null ? this.id : this.instanceId;
909
- },
910
- getValue() {
911
- if (this.valueFormat === "id") return this.multiple ? this.internalValue.slice() : this.internalValue[0];
912
- let e = this.internalValue.map((e) => this.getNode(e).raw);
913
- return this.multiple ? e : e[0];
914
- },
915
- getNode(e) {
916
- return E(() => e != null, () => `Invalid node id: ${e}`), e == null ? null : e in this.forest.nodeMap ? this.forest.nodeMap[e] : this.createFallbackNode(e);
917
- },
918
- createFallbackNode(e) {
919
- let t = this.extractNodeFromValue(e), n = {
920
- id: e,
921
- label: this.enhancedNormalizer(t).label || `${e} (unknown)`,
922
- ancestors: [],
923
- parentNode: null,
924
- isFallbackNode: !0,
925
- isRootNode: !0,
926
- isLeaf: !0,
927
- isBranch: !1,
928
- isDisabled: !1,
929
- isNew: !1,
930
- index: [-1],
931
- level: 0,
932
- raw: t
933
- };
934
- return this.forest.nodeMap[e] = n;
935
- },
936
- extractCheckedNodeIdsFromValue() {
937
- return this.modelValue == null ? [] : this.valueFormat === "id" ? this.multiple ? this.modelValue.slice() : [this.modelValue] : (this.multiple ? this.modelValue : [this.modelValue]).map((e) => this.enhancedNormalizer(e)).map((e) => e.id);
938
- },
939
- extractNodeFromValue(e) {
940
- let t = { id: e };
941
- return this.valueFormat === "id" ? t : F(this.multiple ? Array.isArray(this.modelValue) ? this.modelValue : [] : this.modelValue ? [this.modelValue] : [], (t) => t && this.enhancedNormalizer(t).id === e) || t;
942
- },
943
- fixSelectedNodeIds(e) {
944
- let t = [];
945
- // istanbul ignore else
946
- if (this.single || this.flat || this.disableBranchNodes || this.valueConsistsOf === "ALL") t = e;
947
- else if (this.valueConsistsOf === "BRANCH_PRIORITY") e.forEach((e) => {
948
- t.push(e);
949
- let n = this.getNode(e);
950
- n.isBranch && this.traverseDescendantsBFS(n, (e) => {
951
- t.push(e.id);
952
- });
953
- });
954
- else if (this.valueConsistsOf === "LEAF_PRIORITY") {
955
- let n = M(), r = e.slice();
956
- for (; r.length;) {
957
- let e = r.shift(), i = this.getNode(e);
958
- t.push(e), !i.isRootNode && (i.parentNode.id in n || (n[i.parentNode.id] = i.parentNode.children.length), --n[i.parentNode.id] === 0 && r.push(i.parentNode.id));
959
- }
960
- } else if (this.valueConsistsOf === "ALL_WITH_INDETERMINATE") {
961
- let n = M(), r = e.filter((e) => {
962
- let t = this.getNode(e);
963
- return t.isLeaf || t.children.length === 0;
964
- });
965
- for (; r.length;) {
966
- let e = r.shift(), i = this.getNode(e);
967
- t.push(e), !i.isRootNode && (i.parentNode.id in n || (n[i.parentNode.id] = i.parentNode.children.length), --n[i.parentNode.id] === 0 && r.push(i.parentNode.id));
968
- }
969
- }
970
- R(this.forest.selectedNodeIds, t) && (this.forest.selectedNodeIds = t), this.buildForestState();
971
- },
972
- keepDataOfSelectedNodes(e) {
973
- this.forest.selectedNodeIds.forEach((t) => {
974
- if (!e[t]) return;
975
- let n = {
976
- ...e[t],
977
- isFallbackNode: !0
978
- };
979
- this.forest.nodeMap[t] = n;
980
- });
981
- },
982
- isSelected(e) {
983
- return this.forest.selectedNodeMap[e.id] === !0;
984
- },
985
- traverseDescendantsBFS(e, t) {
986
- // istanbul ignore if
987
- if (!e.isBranch) return;
988
- let n = e.children.slice();
989
- for (; n.length;) {
990
- let e = n[0];
991
- e.isBranch && n.push(...e.children), t(e), n.shift();
992
- }
993
- },
994
- traverseDescendantsDFS(e, t) {
995
- e.isBranch && e.children.forEach((e) => {
996
- this.traverseDescendantsDFS(e, t), t(e);
997
- });
998
- },
999
- traverseAllNodesDFS(e) {
1000
- this.forest.normalizedOptions.forEach((t) => {
1001
- this.traverseDescendantsDFS(t, e), e(t);
1002
- });
1003
- },
1004
- traverseAllNodesByIndex(e) {
1005
- let t = (n) => {
1006
- n.children.forEach((n) => {
1007
- e(n) !== !1 && n.isBranch && t(n);
1008
- });
1009
- };
1010
- t({ children: this.forest.normalizedOptions });
1011
- },
1012
- toggleClickOutsideEvent(e) {
1013
- e ? document.addEventListener("mousedown", this.handleClickOutside, !1) : document.removeEventListener("mousedown", this.handleClickOutside, !1);
1014
- },
1015
- getContainer() {
1016
- return this.$refs.control.container;
1017
- },
1018
- getInput() {
1019
- return this.$refs.control.valueContainer.input;
1020
- },
1021
- focusInput() {
1022
- this.getInput().focus();
1023
- },
1024
- blurInput() {
1025
- this.getInput().blur();
1026
- },
1027
- handleMouseDown: D(function(e) {
1028
- e.preventDefault(), e.stopPropagation(), !this.disabled && (this.getContainer().contains(e.target) && !this.menu.isOpen && (this.openOnClick || this.trigger.isFocused) && this.openMenu(), this._blurOnSelect ? this.blurInput() : this.focusInput(), this.resetFlags());
1029
- }),
1030
- handleClickOutside(e) {
1031
- // istanbul ignore else
1032
- this.$refs.wrapper && !this.$refs.wrapper.contains(e.target) && (this.blurInput(), this.closeMenu());
1033
- },
1034
- handleLocalSearch() {
1035
- let { searchQuery: e } = this.trigger, t = () => this.resetHighlightedOptionWhenNecessary(!0);
1036
- if (!e) return this.localSearch.active = !1, t();
1037
- this.localSearch.active = !0, this.localSearch.noResults = !0, this.traverseAllNodesDFS((e) => {
1038
- e.isBranch && (e.isExpandedOnSearch = !1, e.showAllChildrenOnSearch = !1, e.isMatched = !1, e.hasMatchedDescendants = !1, this.localSearch.countMap[e.id] = {
1039
- [H]: 0,
1040
- [U]: 0,
1041
- [W]: 0,
1042
- [G]: 0
1043
- });
1044
- });
1045
- let n = e.trim().toLocaleLowerCase(), r = n.replace(/\s+/g, " ").split(" ");
1046
- this.traverseAllNodesDFS((e) => {
1047
- this.searchNested && r.length > 1 ? e.isMatched = r.every((t) => Ie(!1, t, e.nestedSearchLabel)) : e.isMatched = this.matchKeys.some((t) => Ie(!this.disableFuzzyMatching, n, e.lowerCased[t])), e.isMatched && (this.localSearch.noResults = !1, e.ancestors.forEach((e) => this.localSearch.countMap[e.id][U]++), e.isLeaf && e.ancestors.forEach((e) => this.localSearch.countMap[e.id][G]++), e.parentNode !== null && (this.localSearch.countMap[e.parentNode.id][H] += 1, e.isLeaf && (this.localSearch.countMap[e.parentNode.id][W] += 1))), (e.isMatched || e.isBranch && e.isExpandedOnSearch) && e.parentNode !== null && (e.parentNode.isExpandedOnSearch = !0, e.parentNode.hasMatchedDescendants = !0);
1048
- }), t();
1049
- },
1050
- handleRemoteSearch() {
1051
- let { searchQuery: e } = this.trigger, t = this.getRemoteSearchEntry(), n = () => {
1052
- this.initialize(), this.resetHighlightedOptionWhenNecessary(!0);
1053
- };
1054
- if ((e === "" || this.cacheOptions) && t.isLoaded) return n();
1055
- this.callLoadOptionsProp({
1056
- action: de,
1057
- args: { searchQuery: e },
1058
- isPending() {
1059
- return t.isLoading;
1060
- },
1061
- start: () => {
1062
- t.isLoading = !0, t.isLoaded = !1, t.loadingError = "";
1063
- },
1064
- succeed: (r) => {
1065
- t.isLoaded = !0, t.options = r, this.trigger.searchQuery === e && n();
1066
- },
1067
- fail: (e) => {
1068
- t.loadingError = $(e);
1069
- },
1070
- end: () => {
1071
- t.isLoading = !1;
1072
- }
1073
- });
1074
- },
1075
- getRemoteSearchEntry() {
1076
- let { searchQuery: e } = this.trigger, t = this.remoteSearch[e] || {
1077
- ...Q(),
1078
- options: []
1079
- };
1080
- if (this.$watch(() => t.options, () => {
1081
- this.trigger.searchQuery === e && this.initialize();
1082
- }, { deep: !0 }), e === "") {
1083
- if (Array.isArray(this.defaultOptions)) return t.options = this.defaultOptions, t.isLoaded = !0, t;
1084
- if (this.defaultOptions !== !0) return t.isLoaded = !0, t;
1085
- }
1086
- return this.remoteSearch[e] || (this.remoteSearch[e] = t), t;
1087
- },
1088
- shouldExpand(e) {
1089
- return this.localSearch.active ? e.isExpandedOnSearch : e.isExpanded;
1090
- },
1091
- shouldOptionBeIncludedInSearchResult(e) {
1092
- return !!(e.isMatched || e.isBranch && e.hasMatchedDescendants && !this.flattenSearchResults || !e.isRootNode && e.parentNode.showAllChildrenOnSearch);
1093
- },
1094
- shouldShowOptionInMenu(e) {
1095
- return !(this.localSearch.active && !this.shouldOptionBeIncludedInSearchResult(e));
1096
- },
1097
- getControl() {
1098
- return this.$refs.control.$el;
1099
- },
1100
- getMenu() {
1101
- let e = (this.appendToBody ? this.$refs.portal.portalTarget : this).$refs.menu.$refs.menu;
1102
- return e && e.nodeName !== "#comment" ? e : null;
1103
- },
1104
- setCurrentHighlightedOption(e, t = !0) {
1105
- let n = this.menu.current;
1106
- if (n != null && n in this.forest.nodeMap && (this.forest.nodeMap[n].isHighlighted = !1), this.menu.current = e.id, e.isHighlighted = !0, this.menu.isOpen && t) {
1107
- let t = () => {
1108
- let t = this.getMenu(), n = t.querySelector(`.vue-treeselect__option[data-id="${e.id}"]`);
1109
- n && O(t, n);
1110
- };
1111
- this.getMenu() ? t() :
1112
- // istanbul ignore next
1113
- this.$nextTick(t);
1114
- }
1115
- },
1116
- resetHighlightedOptionWhenNecessary(e = !1) {
1117
- let { current: t } = this.menu;
1118
- (e || t == null || !(t in this.forest.nodeMap) || !this.shouldShowOptionInMenu(this.getNode(t))) && this.highlightFirstOption();
1119
- },
1120
- highlightFirstOption() {
1121
- if (!this.hasVisibleOptions) return;
1122
- let e = this.visibleOptionIds[0];
1123
- this.setCurrentHighlightedOption(this.getNode(e));
1124
- },
1125
- highlightPrevOption() {
1126
- if (!this.hasVisibleOptions) return;
1127
- let e = this.visibleOptionIds.indexOf(this.menu.current) - 1;
1128
- if (e === -1) return this.highlightLastOption();
1129
- this.setCurrentHighlightedOption(this.getNode(this.visibleOptionIds[e]));
1130
- },
1131
- highlightNextOption() {
1132
- if (!this.hasVisibleOptions) return;
1133
- let e = this.visibleOptionIds.indexOf(this.menu.current) + 1;
1134
- if (e === this.visibleOptionIds.length) return this.highlightFirstOption();
1135
- this.setCurrentHighlightedOption(this.getNode(this.visibleOptionIds[e]));
1136
- },
1137
- highlightLastOption() {
1138
- if (!this.hasVisibleOptions) return;
1139
- let e = C(this.visibleOptionIds);
1140
- this.setCurrentHighlightedOption(this.getNode(e));
1141
- },
1142
- resetSearchQuery() {
1143
- this.trigger.searchQuery = "";
1144
- },
1145
- closeMenu() {
1146
- !this.menu.isOpen || !this.disabled && this.alwaysOpen || (this.saveMenuScrollPosition(), this.menu.isOpen = !1, this.toggleClickOutsideEvent(!1), this.resetSearchQuery(), this.$emit("close", this.getValue(), this.getInstanceId()));
1147
- },
1148
- openMenu() {
1149
- this.disabled || this.menu.isOpen || (this.menu.isOpen = !0, this.$nextTick(this.resetHighlightedOptionWhenNecessary), this.$nextTick(this.restoreMenuScrollPosition), !this.options && !this.async && this.loadRootOptions(), this.toggleClickOutsideEvent(!0), this.$emit("open", this.getInstanceId()));
1150
- },
1151
- toggleMenu() {
1152
- this.menu.isOpen ? this.closeMenu() : this.openMenu();
1153
- },
1154
- toggleExpanded(e) {
1155
- let t;
1156
- this.localSearch.active ? (t = e.isExpandedOnSearch = !e.isExpandedOnSearch, t && (e.showAllChildrenOnSearch = !0)) : t = e.isExpanded = !e.isExpanded, t && !e.childrenStates.isLoaded && this.loadChildrenOptions(e);
1157
- },
1158
- buildForestState() {
1159
- let e = M();
1160
- this.forest.selectedNodeIds.forEach((t) => {
1161
- e[t] = !0;
1162
- }), this.forest.selectedNodeMap = e;
1163
- let t = M();
1164
- this.multiple && (this.traverseAllNodesByIndex((e) => {
1165
- t[e.id] = 0;
1166
- }), this.selectedNodes.forEach((e) => {
1167
- t[e.id] = 2, !this.flat && !this.disableBranchNodes && e.ancestors.forEach((e) => {
1168
- this.isSelected(e) || (t[e.id] = 1);
1169
- });
1170
- })), this.forest.checkedStateMap = t;
1171
- },
1172
- enhancedNormalizer(e) {
1173
- return {
1174
- ...e,
1175
- ...this.normalizer(e, this.getInstanceId())
1176
- };
1177
- },
1178
- normalize(e, t, n) {
1179
- let r = t.map((e) => [this.enhancedNormalizer(e), e]).map(([t, r], i) => {
1180
- this.checkDuplication(t), this.verifyNodeShape(t);
1181
- let { id: a, label: o, children: s, isDefaultExpanded: c } = t, l = e === null, u = l ? 0 : e.level + 1, d = Array.isArray(s) || s === null, f = !d, p = !!t.isDisabled || !this.flat && !l && e.isDisabled, m = !!t.isNew, h = this.matchKeys.reduce((e, n) => ({
1182
- ...e,
1183
- [n]: Fe(t[n]).toLocaleLowerCase()
1184
- }), {}), g = l ? h.label : `${e.nestedSearchLabel} ${h.label}`;
1185
- this.forest.nodeMap[a] = M();
1186
- let _ = this.forest.nodeMap[a];
1187
- if (_.id = a, _.label = o, _.level = u, _.ancestors = l ? [] : [e].concat(e.ancestors), _.index = (l ? [] : e.index).concat(i), _.parentNode = e, _.lowerCased = h, _.nestedSearchLabel = g, _.isDisabled = p, _.isNew = m, _.isMatched = !1, _.isHighlighted = !1, _.isBranch = d, _.isLeaf = f, _.isRootNode = l, _.raw = r, d) {
1188
- let e = Array.isArray(s);
1189
- _.childrenStates = {
1190
- ...Q(),
1191
- isLoaded: e
1192
- }, _.isExpanded = typeof c == "boolean" ? c : u < this.defaultExpandLevel, _.hasMatchedDescendants = !1, _.hasDisabledDescendants = !1, _.isExpandedOnSearch = !1, _.showAllChildrenOnSearch = !1, _.count = {
1193
- [H]: 0,
1194
- [U]: 0,
1195
- [W]: 0,
1196
- [G]: 0
1197
- }, _.children = e ? this.normalize(_, s, n) : [], c === !0 && _.ancestors.forEach((e) => {
1198
- e.isExpanded = !0;
1199
- }), !e && typeof this.loadOptions != "function" ? E(() => !1, () => "Unloaded branch node detected. \"loadOptions\" prop is required to load its children.") : !e && _.isExpanded && this.loadChildrenOptions(_);
1200
- }
1201
- if (_.ancestors.forEach((e) => e.count[U]++), f && _.ancestors.forEach((e) => e.count[G]++), l || (e.count[H] += 1, f && (e.count[W] += 1), p && (e.hasDisabledDescendants = !0)), n && n[a]) {
1202
- let e = n[a];
1203
- _.isMatched = e.isMatched, _.showAllChildrenOnSearch = e.showAllChildrenOnSearch, _.isHighlighted = e.isHighlighted, e.isBranch && _.isBranch && (_.isExpanded = e.isExpanded, _.isExpandedOnSearch = e.isExpandedOnSearch, e.childrenStates.isLoaded && !_.childrenStates.isLoaded ? _.isExpanded = !1 : _.childrenStates = { ...e.childrenStates });
1204
- }
1205
- return _;
1206
- });
1207
- if (this.branchNodesFirst) {
1208
- let e = r.filter((e) => e.isBranch), t = r.filter((e) => e.isLeaf);
1209
- r = e.concat(t);
1210
- }
1211
- return r;
1212
- },
1213
- loadRootOptions() {
1214
- this.callLoadOptionsProp({
1215
- action: le,
1216
- isPending: () => this.rootOptionsStates.isLoading,
1217
- start: () => {
1218
- this.rootOptionsStates.isLoading = !0, this.rootOptionsStates.loadingError = "";
1219
- },
1220
- succeed: () => {
1221
- this.rootOptionsStates.isLoaded = !0, this.$nextTick(() => {
1222
- this.resetHighlightedOptionWhenNecessary(!0);
1223
- });
1224
- },
1225
- fail: (e) => {
1226
- this.rootOptionsStates.loadingError = $(e);
1227
- },
1228
- end: () => {
1229
- this.rootOptionsStates.isLoading = !1;
1230
- }
1231
- });
1232
- },
1233
- loadChildrenOptions(e) {
1234
- let { id: t, raw: n } = e;
1235
- this.callLoadOptionsProp({
1236
- action: ue,
1237
- args: { parentNode: n },
1238
- isPending: () => this.getNode(t).childrenStates.isLoading,
1239
- start: () => {
1240
- this.getNode(t).childrenStates.isLoading = !0, this.getNode(t).childrenStates.loadingError = "";
1241
- },
1242
- succeed: () => {
1243
- this.getNode(t).childrenStates.isLoaded = !0;
1244
- },
1245
- fail: (e) => {
1246
- this.getNode(t).childrenStates.loadingError = $(e);
1247
- },
1248
- end: () => {
1249
- this.getNode(t).childrenStates.isLoading = !1;
1250
- }
1251
- });
1252
- },
1253
- callLoadOptionsProp({ action: e, args: t, isPending: n, start: r, succeed: i, fail: a, end: o }) {
1254
- if (!this.loadOptions || n()) return;
1255
- r();
1256
- let s = T((e, t) => {
1257
- e ? a(e) : i(t), o();
1258
- }), c = this.loadOptions({
1259
- id: this.getInstanceId(),
1260
- instanceId: this.getInstanceId(),
1261
- action: e,
1262
- ...t,
1263
- callback: s
1264
- });
1265
- x(c) && c.then(() => {
1266
- s();
1267
- }, (e) => {
1268
- s(e);
1269
- }).catch((e) => {
1270
- // istanbul ignore next
1271
- console.error(e);
1272
- });
1273
- },
1274
- checkDuplication(e) {
1275
- E(() => !(e.id in this.forest.nodeMap && !this.forest.nodeMap[e.id].isFallbackNode), () => `Detected duplicate presence of node id ${JSON.stringify(e.id)}. Their labels are "${this.forest.nodeMap[e.id].label}" and "${e.label}" respectively.`);
1276
- },
1277
- verifyNodeShape(e) {
1278
- E(() => !(e.children === void 0 && e.isBranch === !0), () => "Are you meant to declare an unloaded branch node? `isBranch: true` is no longer supported, please use `children: null` instead.");
1279
- },
1280
- select(e) {
1281
- if (this.disabled || e.isDisabled) return;
1282
- this.single && this.clear();
1283
- let t = this.multiple && !this.flat ? this.forest.checkedStateMap[e.id] === 0 : !this.isSelected(e);
1284
- t ? this._selectNode(e) : this._deselectNode(e), this.buildForestState(), t ? this.$emit("select", e.raw, this.getInstanceId()) : this.$emit("deselect", e.raw, this.getInstanceId()), this.localSearch.active && t && (this.single || this.clearOnSelect) && this.resetSearchQuery(), this.single && this.closeOnSelect && (this.closeMenu(), this.searchable && (this._blurOnSelect = !0));
1285
- },
1286
- clear() {
1287
- this.hasValue && (this.single || this.allowClearingDisabled ? this.forest.selectedNodeIds = [] : this.forest.selectedNodeIds = this.forest.selectedNodeIds.filter((e) => this.getNode(e).isDisabled), this.buildForestState());
1288
- },
1289
- _selectNode(e) {
1290
- if (this.single || this.disableBranchNodes) return this.addValue(e);
1291
- if (this.flat) {
1292
- this.addValue(e), this.autoSelectAncestors ? e.ancestors.forEach((e) => {
1293
- !this.isSelected(e) && !e.isDisabled && this.addValue(e);
1294
- }) : this.autoSelectDescendants && this.traverseDescendantsBFS(e, (e) => {
1295
- !this.isSelected(e) && !e.isDisabled && this.addValue(e);
1296
- });
1297
- return;
1298
- }
1299
- let t = e.isLeaf || !e.hasDisabledDescendants || this.allowSelectingDisabledDescendants;
1300
- if (t && this.addValue(e), e.isBranch && this.traverseDescendantsBFS(e, (e) => {
1301
- (!e.isDisabled || this.allowSelectingDisabledDescendants) && this.addValue(e);
1302
- }), t) {
1303
- let t = e;
1304
- for (; (t = t.parentNode) !== null && t.children.every(this.isSelected);) this.addValue(t);
1305
- }
1306
- },
1307
- _deselectNode(e) {
1308
- if (this.disableBranchNodes) return this.removeValue(e);
1309
- if (this.flat) {
1310
- this.removeValue(e), this.autoDeselectAncestors ? e.ancestors.forEach((e) => {
1311
- this.isSelected(e) && !e.isDisabled && this.removeValue(e);
1312
- }) : this.autoDeselectDescendants && this.traverseDescendantsBFS(e, (e) => {
1313
- this.isSelected(e) && !e.isDisabled && this.removeValue(e);
1314
- });
1315
- return;
1316
- }
1317
- let t = !1;
1318
- if (e.isBranch && this.traverseDescendantsDFS(e, (e) => {
1319
- (!e.isDisabled || this.allowSelectingDisabledDescendants) && (this.removeValue(e), t = !0);
1320
- }), e.isLeaf || t || e.children.length === 0) {
1321
- this.removeValue(e);
1322
- let t = e;
1323
- for (; (t = t.parentNode) !== null && this.isSelected(t);) this.removeValue(t);
1324
- }
1325
- },
1326
- addValue(e) {
1327
- this.forest.selectedNodeIds.push(e.id), this.forest.selectedNodeMap[e.id] = !0;
1328
- },
1329
- removeValue(e) {
1330
- I(this.forest.selectedNodeIds, e.id), delete this.forest.selectedNodeMap[e.id];
1331
- },
1332
- removeLastValue() {
1333
- if (!this.hasValue) return;
1334
- if (this.single) return this.clear();
1335
- let e = C(this.internalValue), t = this.getNode(e);
1336
- this.select(t);
1337
- },
1338
- saveMenuScrollPosition() {
1339
- let e = this.getMenu();
1340
- // istanbul ignore else
1341
- e && (this.menu.lastScrollPosition = e.scrollTop);
1342
- },
1343
- restoreMenuScrollPosition() {
1344
- let e = this.getMenu();
1345
- // istanbul ignore else
1346
- e && (e.scrollTop = this.menu.lastScrollPosition);
1347
- }
1348
- },
1349
- render() {
1350
- return l("div", {
1351
- ref: "wrapper",
1352
- class: this.wrapperClass
1353
- }, [
1354
- l(me, null, null),
1355
- l(Te, { ref: "control" }, null),
1356
- this.appendToBody ? l(Me, { ref: "portal" }, null) : l(Ae, { ref: "menu" }, null)
1357
- ]);
1358
- }
1359
- };
1360
- //#endregion
1361
- export { Le as t };