@vitorfba/vue-treeselect 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2604 +0,0 @@
1
- import { createVNode as r, mergeProps as Pe, openBlock as V, createElementBlock as j, createElementVNode as $, normalizeClass as se, renderSlot as je, createTextVNode as Q, resolveComponent as H, defineComponent as Ue, createBlock as Qe, Teleport as Ke } from "vue";
2
- var F = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
3
- function C(e) {
4
- return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
5
- }
6
- function qe(e, t) {
7
- var n = t.length, s = e.length;
8
- if (s > n)
9
- return !1;
10
- if (s === n)
11
- return e === t;
12
- e: for (var i = 0, o = 0; i < s; i++) {
13
- for (var a = e.charCodeAt(i); o < n; )
14
- if (t.charCodeAt(o++) === a)
15
- continue e;
16
- return !1;
17
- }
18
- return !0;
19
- }
20
- var Ye = qe;
21
- const Xe = /* @__PURE__ */ C(Ye);
22
- function Ge() {
23
- }
24
- var Je = Ge;
25
- const Ze = /* @__PURE__ */ C(Je), y = process.env.NODE_ENV === "production" ? (
26
- /* istanbul ignore next */
27
- Ze
28
- ) : function(t, n) {
29
- if (!t()) {
30
- const s = ["[Vue-Treeselect Warning]"].concat(n());
31
- console.error(...s);
32
- }
33
- };
34
- function w(e) {
35
- return function(n, ...s) {
36
- n.type === "mousedown" && n.button === 0 && e.call(this, n, ...s);
37
- };
38
- }
39
- function et(e, t) {
40
- const n = e.getBoundingClientRect(), s = t.getBoundingClientRect(), i = t.offsetHeight / 3;
41
- s.bottom + i > n.bottom ? e.scrollTop = Math.min(
42
- t.offsetTop + t.clientHeight - e.offsetHeight + i,
43
- e.scrollHeight
44
- ) : s.top - i < n.top && (e.scrollTop = Math.max(t.offsetTop - i, 0));
45
- }
46
- function tt(e) {
47
- var t = typeof e;
48
- return e != null && (t == "object" || t == "function");
49
- }
50
- var Ce = tt, nt = typeof F == "object" && F && F.Object === Object && F, st = nt, it = st, rt = typeof self == "object" && self && self.Object === Object && self, ot = it || rt || Function("return this")(), Le = ot, at = Le, lt = function() {
51
- return at.Date.now();
52
- }, ct = lt, ut = /\s/;
53
- function ht(e) {
54
- for (var t = e.length; t-- && ut.test(e.charAt(t)); )
55
- ;
56
- return t;
57
- }
58
- var dt = ht, ft = dt, pt = /^\s+/;
59
- function gt(e) {
60
- return e && e.slice(0, ft(e) + 1).replace(pt, "");
61
- }
62
- var mt = gt, vt = Le, St = vt.Symbol, Me = St, ce = Me, Te = Object.prototype, bt = Te.hasOwnProperty, Ot = Te.toString, x = ce ? ce.toStringTag : void 0;
63
- function yt(e) {
64
- var t = bt.call(e, x), n = e[x];
65
- try {
66
- e[x] = void 0;
67
- var s = !0;
68
- } catch {
69
- }
70
- var i = Ot.call(e);
71
- return s && (t ? e[x] = n : delete e[x]), i;
72
- }
73
- var _t = yt, Nt = Object.prototype, Et = Nt.toString;
74
- function wt(e) {
75
- return Et.call(e);
76
- }
77
- var Ct = wt, ue = Me, Lt = _t, Mt = Ct, Tt = "[object Null]", Dt = "[object Undefined]", he = ue ? ue.toStringTag : void 0;
78
- function It(e) {
79
- return e == null ? e === void 0 ? Dt : Tt : he && he in Object(e) ? Lt(e) : Mt(e);
80
- }
81
- var xt = It;
82
- function Rt(e) {
83
- return e != null && typeof e == "object";
84
- }
85
- var At = Rt, Bt = xt, $t = At, Vt = "[object Symbol]";
86
- function kt(e) {
87
- return typeof e == "symbol" || $t(e) && Bt(e) == Vt;
88
- }
89
- var zt = kt, Ft = mt, de = Ce, Wt = zt, fe = NaN, Ht = /^[-+]0x[0-9a-f]+$/i, Pt = /^0b[01]+$/i, jt = /^0o[0-7]+$/i, Ut = parseInt;
90
- function Qt(e) {
91
- if (typeof e == "number")
92
- return e;
93
- if (Wt(e))
94
- return fe;
95
- if (de(e)) {
96
- var t = typeof e.valueOf == "function" ? e.valueOf() : e;
97
- e = de(t) ? t + "" : t;
98
- }
99
- if (typeof e != "string")
100
- return e === 0 ? e : +e;
101
- e = Ft(e);
102
- var n = Pt.test(e);
103
- return n || jt.test(e) ? Ut(e.slice(2), n ? 2 : 8) : Ht.test(e) ? fe : +e;
104
- }
105
- var De = Qt, Kt = Ce, K = ct, pe = De, qt = "Expected a function", Yt = Math.max, Xt = Math.min;
106
- function Gt(e, t, n) {
107
- var s, i, o, a, c, d, f = 0, m = !1, p = !1, v = !0;
108
- if (typeof e != "function")
109
- throw new TypeError(qt);
110
- t = pe(t) || 0, Kt(n) && (m = !!n.leading, p = "maxWait" in n, o = p ? Yt(pe(n.maxWait) || 0, t) : o, v = "trailing" in n ? !!n.trailing : v);
111
- function N(u) {
112
- var O = s, I = i;
113
- return s = i = void 0, f = u, a = e.apply(I, O), a;
114
- }
115
- function D(u) {
116
- return f = u, c = setTimeout(L, t), m ? N(u) : a;
117
- }
118
- function k(u) {
119
- var O = u - d, I = u - f, le = t - O;
120
- return p ? Xt(le, o - I) : le;
121
- }
122
- function z(u) {
123
- var O = u - d, I = u - f;
124
- return d === void 0 || O >= t || O < 0 || p && I >= o;
125
- }
126
- function L() {
127
- var u = K();
128
- if (z(u))
129
- return M(u);
130
- c = setTimeout(L, k(u));
131
- }
132
- function M(u) {
133
- return c = void 0, v && s ? N(u) : (s = i = void 0, a);
134
- }
135
- function U() {
136
- c !== void 0 && clearTimeout(c), f = 0, s = d = i = c = void 0;
137
- }
138
- function l() {
139
- return c === void 0 ? a : M(K());
140
- }
141
- function h() {
142
- var u = K(), O = z(u);
143
- if (s = arguments, i = this, d = u, O) {
144
- if (c === void 0)
145
- return D(d);
146
- if (p)
147
- return clearTimeout(c), c = setTimeout(L, t), N(d);
148
- }
149
- return c === void 0 && (c = setTimeout(L, t)), a;
150
- }
151
- return h.cancel = U, h.flush = l, h;
152
- }
153
- var Jt = Gt;
154
- const Zt = /* @__PURE__ */ C(Jt);
155
- var en = function(e, t) {
156
- var n = document.createElement("_"), s = n.appendChild(document.createElement("_")), i = n.appendChild(document.createElement("_")), o = s.appendChild(document.createElement("_")), a = void 0, c = void 0;
157
- return s.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", o.style.cssText = i.style.cssText = "display:block;height:100%;transition:0s;width:100%", o.style.width = o.style.height = "200%", e.appendChild(n), d(), m;
158
- function d() {
159
- f();
160
- var p = e.offsetWidth, v = e.offsetHeight;
161
- (p !== a || v !== c) && (a = p, c = v, i.style.width = p * 2 + "px", i.style.height = v * 2 + "px", n.scrollLeft = n.scrollWidth, n.scrollTop = n.scrollHeight, s.scrollLeft = s.scrollWidth, s.scrollTop = s.scrollHeight, t({ width: p, height: v })), s.addEventListener("scroll", d), n.addEventListener("scroll", d);
162
- }
163
- function f() {
164
- s.removeEventListener("scroll", d), n.removeEventListener("scroll", d);
165
- }
166
- function m() {
167
- f(), e.removeChild(n);
168
- }
169
- };
170
- function Ie(e, t) {
171
- const n = e.indexOf(t);
172
- n !== -1 && e.splice(n, 1);
173
- }
174
- let ie;
175
- const P = [], tn = 100;
176
- function nn() {
177
- ie = setInterval(() => {
178
- P.forEach(xe);
179
- }, tn);
180
- }
181
- function sn() {
182
- clearInterval(ie), ie = null;
183
- }
184
- function xe(e) {
185
- const { $el: t, listener: n, lastWidth: s, lastHeight: i } = e, o = t.offsetWidth, a = t.offsetHeight;
186
- (s !== o || i !== a) && (e.lastWidth = o, e.lastHeight = a, n({ width: o, height: a }));
187
- }
188
- function rn(e, t) {
189
- const n = {
190
- $el: e,
191
- listener: t,
192
- lastWidth: null,
193
- lastHeight: null
194
- }, s = () => {
195
- Ie(P, n), P.length || sn();
196
- };
197
- return P.push(n), xe(n), nn(), s;
198
- }
199
- function ge(e, t) {
200
- const n = document.documentMode === 9;
201
- let s = !0;
202
- const a = (n ? rn : en)(e, (...c) => s || t(...c));
203
- return s = !1, a;
204
- }
205
- function on(e) {
206
- const t = [];
207
- let n = e.parentNode;
208
- for (; n && n.nodeName !== "BODY" && n.nodeType === document.ELEMENT_NODE; )
209
- an(n) && t.push(n), n = n.parentNode;
210
- return t.push(window), t;
211
- }
212
- function an(e) {
213
- const { overflow: t, overflowX: n, overflowY: s } = getComputedStyle(e);
214
- return /(auto|scroll|overlay)/.test(t + s + n);
215
- }
216
- function me(e, t) {
217
- const n = on(e);
218
- return window.addEventListener("resize", t, { passive: !0 }), n.forEach((s) => {
219
- s.addEventListener("scroll", t, { passive: !0 });
220
- }), function() {
221
- window.removeEventListener("resize", t, { passive: !0 }), n.forEach((i) => {
222
- i.removeEventListener("scroll", t, { passive: !0 });
223
- });
224
- };
225
- }
226
- function Re(e) {
227
- return e !== e;
228
- }
229
- function Ae(e) {
230
- return !!e && (typeof e == "object" || typeof e == "function") && typeof e.then == "function";
231
- }
232
- var ln = De, ve = 1 / 0, cn = 17976931348623157e292;
233
- function un(e) {
234
- if (!e)
235
- return e === 0 ? e : 0;
236
- if (e = ln(e), e === ve || e === -ve) {
237
- var t = e < 0 ? -1 : 1;
238
- return t * cn;
239
- }
240
- return e === e ? e : 0;
241
- }
242
- var hn = un, dn = hn;
243
- function fn(e) {
244
- var t = dn(e), n = t % 1;
245
- return t === t ? n ? t - n : t : 0;
246
- }
247
- var pn = fn, gn = pn, mn = "Expected a function";
248
- function vn(e, t) {
249
- var n;
250
- if (typeof t != "function")
251
- throw new TypeError(mn);
252
- return e = gn(e), function() {
253
- return --e > 0 && (n = t.apply(this, arguments)), e <= 1 && (t = void 0), n;
254
- };
255
- }
256
- var Sn = vn, bn = Sn;
257
- function On(e) {
258
- return bn(2, e);
259
- }
260
- var yn = On;
261
- const _n = /* @__PURE__ */ C(yn);
262
- function Nn(e) {
263
- return e;
264
- }
265
- var En = Nn;
266
- const wn = /* @__PURE__ */ C(En);
267
- function Cn(e) {
268
- return function() {
269
- return e;
270
- };
271
- }
272
- var Ln = Cn;
273
- const Se = /* @__PURE__ */ C(Ln), S = () => /* @__PURE__ */ Object.create(null);
274
- function Be(e) {
275
- return e == null || typeof e != "object" ? !1 : Object.getPrototypeOf(e) === Object.prototype;
276
- }
277
- function Mn(e, t, n) {
278
- Be(n) ? (e[t] || (e[t] = {}), re(e[t], n)) : e[t] = n;
279
- }
280
- function re(e, t) {
281
- if (Be(t)) {
282
- const n = Object.keys(t);
283
- for (let s = 0, i = n.length; s < i; s++)
284
- Mn(e, n[s], t[n[s]]);
285
- }
286
- return e;
287
- }
288
- function Tn(e) {
289
- var t = e == null ? 0 : e.length;
290
- return t ? e[t - 1] : void 0;
291
- }
292
- var Dn = Tn;
293
- const be = /* @__PURE__ */ C(Dn);
294
- function _(e, t) {
295
- return e.indexOf(t) !== -1;
296
- }
297
- function In(e, t, n) {
298
- for (let s = 0, i = e.length; s < i; s++)
299
- if (t.call(n, e[s], s, e)) return e[s];
300
- }
301
- function q(e, t) {
302
- if (e.length !== t.length) return !0;
303
- for (let n = 0; n < e.length; n++)
304
- if (e[n] !== t[n]) return !0;
305
- return !1;
306
- }
307
- const E = null, oe = 0, $e = 1, Ve = 2, T = "ALL_CHILDREN", R = "ALL_DESCENDANTS", A = "LEAF_CHILDREN", B = "LEAF_DESCENDANTS", xn = "LOAD_ROOT_OPTIONS", Rn = "LOAD_CHILDREN_OPTIONS", An = "ASYNC_SEARCH", Y = "ALL", W = "BRANCH_PRIORITY", X = "LEAF_PRIORITY", G = "ALL_WITH_INDETERMINATE", Oe = "ORDER_SELECTED", ye = "LEVEL", _e = "INDEX", g = {
308
- BACKSPACE: 8,
309
- ENTER: 13,
310
- ESCAPE: 27,
311
- END: 35,
312
- HOME: 36,
313
- ARROW_LEFT: 37,
314
- ARROW_UP: 38,
315
- ARROW_RIGHT: 39,
316
- ARROW_DOWN: 40,
317
- DELETE: 46
318
- }, Bn = process.env.NODE_ENV === "testing" ? (
319
- /* to speed up unit testing */
320
- 10
321
- ) : (
322
- /* istanbul ignore next */
323
- 200
324
- ), Ne = 5, Ee = 40;
325
- function ke(e, t) {
326
- let n = 0;
327
- do {
328
- if (e.level < n) return -1;
329
- if (t.level < n) return 1;
330
- if (e.index[n] !== t.index[n]) return e.index[n] - t.index[n];
331
- n++;
332
- } while (!0);
333
- }
334
- function $n(e, t) {
335
- return e.level === t.level ? ke(e, t) : e.level - t.level;
336
- }
337
- function J() {
338
- return {
339
- isLoaded: !1,
340
- isLoading: !1,
341
- loadingError: ""
342
- };
343
- }
344
- function Vn(e) {
345
- return typeof e == "string" ? e : typeof e == "number" && !Re(e) ? e + "" : "";
346
- }
347
- function we(e, t, n) {
348
- return e ? Xe(t, n) : _(n, t);
349
- }
350
- function Z(e) {
351
- return e.message || /* istanbul ignore next */
352
- String(e);
353
- }
354
- let kn = 0;
355
- const zn = {
356
- provide() {
357
- return {
358
- // Enable access to the instance of root component of vue-treeselect
359
- // across hierarchy.
360
- instance: this
361
- };
362
- },
363
- emits: ["update:modelValue", "updated", "search-change", "close", "open", "select", "deselect"],
364
- props: {
365
- /**
366
- * Whether to allow resetting value even if there are disabled selected nodes.
367
- */
368
- allowClearingDisabled: {
369
- type: Boolean,
370
- default: !1
371
- },
372
- /**
373
- * When an ancestor node is selected/deselected, whether its disabled descendants should be selected/deselected.
374
- * You may want to use this in conjunction with `allowClearingDisabled` prop.
375
- */
376
- allowSelectingDisabledDescendants: {
377
- type: Boolean,
378
- default: !1
379
- },
380
- /**
381
- * Whether the menu should be always open.
382
- */
383
- alwaysOpen: {
384
- type: Boolean,
385
- default: !1
386
- },
387
- /**
388
- * Append the menu to <body />?
389
- */
390
- appendToBody: {
391
- type: Boolean,
392
- default: !1
393
- },
394
- /**
395
- * Whether to enable async search mode.
396
- */
397
- async: {
398
- type: Boolean,
399
- default: !1
400
- },
401
- /**
402
- * Automatically focus the component on mount?
403
- */
404
- autoFocus: {
405
- type: Boolean,
406
- default: !1
407
- },
408
- /**
409
- * Automatically load root options on mount. When set to `false`, root options will be loaded when the menu is opened.
410
- */
411
- autoLoadRootOptions: {
412
- type: Boolean,
413
- default: !0
414
- },
415
- /**
416
- * When user deselects a node, automatically deselect its ancestors. Applies to flat mode only.
417
- */
418
- autoDeselectAncestors: {
419
- type: Boolean,
420
- default: !1
421
- },
422
- /**
423
- * When user deselects a node, automatically deselect its descendants. Applies to flat mode only.
424
- */
425
- autoDeselectDescendants: {
426
- type: Boolean,
427
- default: !1
428
- },
429
- /**
430
- * When user selects a node, automatically select its ancestors. Applies to flat mode only.
431
- */
432
- autoSelectAncestors: {
433
- type: Boolean,
434
- default: !1
435
- },
436
- /**
437
- * When user selects a node, automatically select its descendants. Applies to flat mode only.
438
- */
439
- autoSelectDescendants: {
440
- type: Boolean,
441
- default: !1
442
- },
443
- /**
444
- * Whether pressing backspace key removes the last item if there is no text input.
445
- */
446
- backspaceRemoves: {
447
- type: Boolean,
448
- default: !0
449
- },
450
- /**
451
- * Function that processes before clearing all input fields.
452
- * Return `false` to prevent value from being cleared.
453
- * @type {function(): (boolean|Promise<boolean>)}
454
- */
455
- beforeClearAll: {
456
- type: Function,
457
- default: Se(!0)
458
- },
459
- /**
460
- * Show branch nodes before leaf nodes?
461
- */
462
- branchNodesFirst: {
463
- type: Boolean,
464
- default: !1
465
- },
466
- /**
467
- * Should cache results of every search request?
468
- */
469
- cacheOptions: {
470
- type: Boolean,
471
- default: !0
472
- },
473
- /**
474
- * Show an "×" button that resets value?
475
- */
476
- clearable: {
477
- type: Boolean,
478
- default: !0
479
- },
480
- /**
481
- * Title for the "×" button when `multiple: true`.
482
- */
483
- clearAllText: {
484
- type: String,
485
- default: "Clear all"
486
- },
487
- /**
488
- * Whether to clear the search input after selecting.
489
- * Use only when `multiple` is `true`.
490
- * For single-select mode, it **always** clears the input after selecting an option regardless of the prop value.
491
- */
492
- clearOnSelect: {
493
- type: Boolean,
494
- default: !1
495
- },
496
- /**
497
- * Title for the "×" button.
498
- */
499
- clearValueText: {
500
- type: String,
501
- default: "Clear value"
502
- },
503
- /**
504
- * Whether to close the menu after selecting an option?
505
- * Use only when `multiple` is `true`.
506
- */
507
- closeOnSelect: {
508
- type: Boolean,
509
- default: !0
510
- },
511
- /**
512
- * How many levels of branch nodes should be automatically expanded when loaded.
513
- * Set `Infinity` to make all branch nodes expanded by default.
514
- */
515
- defaultExpandLevel: {
516
- type: Number,
517
- default: 0
518
- },
519
- /**
520
- * The default set of options to show before the user starts searching. Used for async search mode.
521
- * When set to `true`, the results for search query as a empty string will be autoloaded.
522
- * @type {boolean|node[]}
523
- */
524
- defaultOptions: {
525
- default: !1
526
- },
527
- /**
528
- * Whether pressing delete key removes the last item if there is no text input.
529
- */
530
- deleteRemoves: {
531
- type: Boolean,
532
- default: !0
533
- },
534
- /**
535
- * Delimiter to use to join multiple values for the hidden field value.
536
- */
537
- delimiter: {
538
- type: String,
539
- default: ","
540
- },
541
- /**
542
- * Only show the nodes that match the search value directly, excluding its ancestors.
543
- *
544
- * @type {Object}
545
- */
546
- flattenSearchResults: {
547
- type: Boolean,
548
- default: !1
549
- },
550
- /**
551
- * Prevent branch nodes from being selected?
552
- */
553
- disableBranchNodes: {
554
- type: Boolean,
555
- default: !1
556
- },
557
- /**
558
- * Disable the control?
559
- */
560
- disabled: {
561
- type: Boolean,
562
- default: !1
563
- },
564
- /**
565
- * Disable the fuzzy matching functionality?
566
- */
567
- disableFuzzyMatching: {
568
- type: Boolean,
569
- default: !1
570
- },
571
- /**
572
- * Whether to enable flat mode or not. Non-flat mode (default) means:
573
- * - Whenever a branch node gets checked, all its children will be checked too
574
- * - Whenever a branch node has all children checked, the branch node itself will be checked too
575
- * Set `true` to disable this mechanism
576
- */
577
- flat: {
578
- type: Boolean,
579
- default: !1
580
- },
581
- /**
582
- * Will be passed with all events as the last param.
583
- * Useful for identifying events origin.
584
- */
585
- instanceId: {
586
- // Add two trailing "$" to distinguish from explictly specified ids.
587
- default: () => `${kn++}$$`,
588
- type: [String, Number]
589
- },
590
- /**
591
- * Joins multiple values into a single form field with the `delimiter` (legacy mode).
592
- */
593
- joinValues: {
594
- type: Boolean,
595
- default: !1
596
- },
597
- /**
598
- * Limit the display of selected options.
599
- * The rest will be hidden within the limitText string.
600
- */
601
- limit: {
602
- type: Number,
603
- default: 1 / 0
604
- },
605
- /**
606
- * Function that processes the message shown when selected elements pass the defined limit.
607
- * @type {function(number): string}
608
- */
609
- limitText: {
610
- type: Function,
611
- default: function(t) {
612
- return `and ${t} more`;
613
- }
614
- },
615
- /**
616
- * Text displayed when loading options.
617
- */
618
- loadingText: {
619
- type: String,
620
- default: "Loading..."
621
- },
622
- /**
623
- * Used for dynamically loading options.
624
- * @type {function({action: string, callback: (function((Error|string)=): void), parentNode: node=, instanceId}): void}
625
- */
626
- loadOptions: {
627
- type: Function
628
- },
629
- /**
630
- * Which node properties to filter on.
631
- */
632
- matchKeys: {
633
- type: Array,
634
- default: Se(["label"])
635
- },
636
- /**
637
- * Sets `maxHeight` style value of the menu.
638
- */
639
- maxHeight: {
640
- type: Number,
641
- default: 300
642
- },
643
- /**
644
- * Set `true` to allow selecting multiple options (a.k.a., multi-select mode).
645
- */
646
- multiple: {
647
- type: Boolean,
648
- default: !1
649
- },
650
- /**
651
- * Generates a hidden <input /> tag with this field name for html forms.
652
- */
653
- name: {
654
- type: String
655
- },
656
- /**
657
- * Text displayed when a branch node has no children.
658
- */
659
- noChildrenText: {
660
- type: String,
661
- default: "No sub-options."
662
- },
663
- /**
664
- * Text displayed when there are no available options.
665
- */
666
- noOptionsText: {
667
- type: String,
668
- default: "No options available."
669
- },
670
- /**
671
- * Text displayed when there are no matching search results.
672
- */
673
- noResultsText: {
674
- type: String,
675
- default: "No results found..."
676
- },
677
- /**
678
- * Used for normalizing source data.
679
- * @type {function(node, instanceId): node}
680
- */
681
- normalizer: {
682
- type: Function,
683
- default: wn
684
- },
685
- /**
686
- * By default (`auto`), the menu will open below the control. If there is not
687
- * enough space, vue-treeselect will automatically flip the menu.
688
- * You can use one of other four options to force the menu to be always opened
689
- * to specified direction.
690
- * Acceptable values:
691
- * - `"auto"`
692
- * - `"below"`
693
- * - `"bottom"`
694
- * - `"above"`
695
- * - `"top"`
696
- */
697
- openDirection: {
698
- type: String,
699
- default: "auto",
700
- validator(e) {
701
- return _(["auto", "top", "bottom", "above", "below"], e);
702
- }
703
- },
704
- /**
705
- * Whether to automatically open the menu when the control is clicked.
706
- */
707
- openOnClick: {
708
- type: Boolean,
709
- default: !0
710
- },
711
- /**
712
- * Whether to automatically open the menu when the control is focused.
713
- */
714
- openOnFocus: {
715
- type: Boolean,
716
- default: !1
717
- },
718
- /**
719
- * Array of available options.
720
- * @type {node[]}
721
- */
722
- options: {
723
- type: Array
724
- },
725
- /**
726
- * Field placeholder, displayed when there's no value.
727
- */
728
- placeholder: {
729
- type: String,
730
- default: "Select..."
731
- },
732
- /**
733
- * Applies HTML5 required attribute when needed.
734
- */
735
- required: {
736
- type: Boolean,
737
- default: !1
738
- },
739
- /**
740
- * Text displayed asking user whether to retry loading children options.
741
- */
742
- retryText: {
743
- type: String,
744
- default: "Retry?"
745
- },
746
- /**
747
- * Title for the retry button.
748
- */
749
- retryTitle: {
750
- type: String,
751
- default: "Click to retry"
752
- },
753
- /**
754
- * Enable searching feature?
755
- */
756
- searchable: {
757
- type: Boolean,
758
- default: !0
759
- },
760
- /**
761
- * Search in ancestor nodes too.
762
- */
763
- searchNested: {
764
- type: Boolean,
765
- default: !1
766
- },
767
- /**
768
- * Text tip to prompt for async search.
769
- */
770
- searchPromptText: {
771
- type: String,
772
- default: "Type to search..."
773
- },
774
- /**
775
- * Whether to show a children count next to the label of each branch node.
776
- */
777
- showCount: {
778
- type: Boolean,
779
- default: !1
780
- },
781
- /**
782
- * Used in conjunction with `showCount` to specify which type of count number should be displayed.
783
- * Acceptable values:
784
- * - "ALL_CHILDREN"
785
- * - "ALL_DESCENDANTS"
786
- * - "LEAF_CHILDREN"
787
- * - "LEAF_DESCENDANTS"
788
- */
789
- showCountOf: {
790
- type: String,
791
- default: T,
792
- validator(e) {
793
- return _([T, R, A, B], e);
794
- }
795
- },
796
- /**
797
- * Whether to show children count when searching.
798
- * Fallbacks to the value of `showCount` when not specified.
799
- * @type {boolean}
800
- */
801
- showCountOnSearch: null,
802
- /**
803
- * In which order the selected options should be displayed in trigger & sorted in `value` array.
804
- * Used for multi-select mode only.
805
- * Acceptable values:
806
- * - "ORDER_SELECTED"
807
- * - "LEVEL"
808
- * - "INDEX"
809
- */
810
- sortValueBy: {
811
- type: String,
812
- default: Oe,
813
- validator(e) {
814
- return _([Oe, ye, _e], e);
815
- }
816
- },
817
- /**
818
- * Tab index of the control.
819
- */
820
- tabIndex: {
821
- type: Number,
822
- default: 0
823
- },
824
- /**
825
- * The value of the control.
826
- * Should be `id` or `node` object for single-select mode, or an array of `id` or `node` object for multi-select mode.
827
- * Its format depends on the `valueFormat` prop.
828
- * For most cases, just use `v-model` instead.
829
- * @type {?Array}
830
- */
831
- modelValue: null,
832
- value: null,
833
- /**
834
- * Which kind of nodes should be included in the `value` array in multi-select mode.
835
- * Acceptable values:
836
- * - "ALL" - Any node that is checked will be included in the `value` array
837
- * - "BRANCH_PRIORITY" (default) - If a branch node is checked, all its descendants will be excluded in the `value` array
838
- * - "LEAF_PRIORITY" - If a branch node is checked, this node itself and its branch descendants will be excluded from the `value` array but its leaf descendants will be included
839
- * - "ALL_WITH_INDETERMINATE" - Any node that is checked will be included in the `value` array, plus indeterminate nodes
840
- */
841
- valueConsistsOf: {
842
- type: String,
843
- default: W,
844
- validator(e) {
845
- return _([Y, W, X, G], e);
846
- }
847
- },
848
- /**
849
- * Format of `value` prop.
850
- * Note that, when set to `"object"`, only `id` & `label` properties are required in each `node` object in `value` prop.
851
- * Acceptable values:
852
- * - "id"
853
- * - "object"
854
- */
855
- valueFormat: {
856
- type: String,
857
- default: "id"
858
- },
859
- /**
860
- * z-index of the menu.
861
- */
862
- zIndex: {
863
- type: [Number, String],
864
- default: 999
865
- }
866
- },
867
- data() {
868
- return {
869
- trigger: {
870
- // Is the control focused?
871
- isFocused: !1,
872
- // User entered search query - value of the input.
873
- searchQuery: ""
874
- },
875
- menu: {
876
- // Is the menu opened?
877
- isOpen: !1,
878
- // Id of current highlighted option.
879
- current: null,
880
- // The scroll position before last menu closing.
881
- lastScrollPosition: 0,
882
- // Which direction to open the menu.
883
- placement: "bottom"
884
- },
885
- forest: {
886
- // Normalized options.
887
- normalizedOptions: [],
888
- // <id, node> map for quick look-up.
889
- nodeMap: S(),
890
- // <id, checkedState> map, used for multi-select mode.
891
- checkedStateMap: S(),
892
- // Id list of all selected options.
893
- selectedNodeIds: this.extractCheckedNodeIdsFromValue(),
894
- // <id, true> map for fast checking:
895
- // if (forest.selectedNodeIds.indexOf(id) !== -1) forest.selectedNodeMap[id] === true
896
- selectedNodeMap: S()
897
- },
898
- // States of root options.
899
- rootOptionsStates: J(),
900
- localSearch: {
901
- // Has user entered any query to search local options?
902
- active: !1,
903
- // Has any options matched the search query?
904
- noResults: !0,
905
- // <id, countObject> map for counting matched children/descendants.
906
- countMap: S()
907
- },
908
- // <searchQuery, remoteSearchEntry> map.
909
- remoteSearch: S()
910
- };
911
- },
912
- computed: {
913
- /* eslint-disable valid-jsdoc */
914
- /**
915
- * Normalized nodes that have been selected.
916
- * @type {node[]}
917
- */
918
- selectedNodes() {
919
- return this.forest.selectedNodeIds.map(this.getNode);
920
- },
921
- /**
922
- * Id list of selected nodes with `sortValueBy` prop applied.
923
- * @type {nodeId[]}
924
- */
925
- internalValue() {
926
- let e;
927
- if (this.single || this.flat || this.disableBranchNodes || this.valueConsistsOf === Y)
928
- e = this.forest.selectedNodeIds.slice();
929
- else if (this.valueConsistsOf === W)
930
- e = this.forest.selectedNodeIds.filter((t) => {
931
- const n = this.getNode(t);
932
- return n.isRootNode ? !0 : !this.isSelected(n.parentNode);
933
- });
934
- else if (this.valueConsistsOf === X)
935
- e = this.forest.selectedNodeIds.filter((t) => {
936
- const n = this.getNode(t);
937
- return n.isLeaf ? !0 : n.children.length === 0;
938
- });
939
- else if (this.valueConsistsOf === G) {
940
- const t = [];
941
- e = this.forest.selectedNodeIds.slice(), this.selectedNodes.forEach((n) => {
942
- n.ancestors.forEach((s) => {
943
- _(t, s.id) || _(e, s.id) || t.push(s.id);
944
- });
945
- }), e.push(...t);
946
- }
947
- return this.sortValueBy === ye ? e.sort((t, n) => $n(this.getNode(t), this.getNode(n))) : this.sortValueBy === _e && e.sort((t, n) => ke(this.getNode(t), this.getNode(n))), e;
948
- },
949
- /**
950
- * Has any option been selected?
951
- * @type {boolean}
952
- */
953
- hasValue() {
954
- return this.internalValue.length > 0;
955
- },
956
- /**
957
- * Single-select mode?
958
- * @type {boolean}
959
- */
960
- single() {
961
- return !this.multiple;
962
- },
963
- /**
964
- * Id list of nodes displayed in the menu. Nodes that are considered NOT visible:
965
- * - descendants of a collapsed branch node
966
- * - in local search mode, nodes that are not matched, unless
967
- * - it's a branch node and has matched descendants
968
- * - it's a leaf node and its parent node is explicitly set to show all children
969
- * @type {id[]}
970
- */
971
- visibleOptionIds() {
972
- const e = [];
973
- return this.traverseAllNodesByIndex((t) => {
974
- if ((!this.localSearch.active || this.shouldOptionBeIncludedInSearchResult(t)) && e.push(t.id), t.isBranch && !this.shouldExpand(t))
975
- return !1;
976
- }), e;
977
- },
978
- /**
979
- * Has any option should be displayed in the menu?
980
- * @type {boolean}
981
- */
982
- hasVisibleOptions() {
983
- return this.visibleOptionIds.length !== 0;
984
- },
985
- /**
986
- * Should show children count when searching?
987
- * @type {boolean}
988
- */
989
- showCountOnSearchComputed() {
990
- return typeof this.showCountOnSearch == "boolean" ? this.showCountOnSearch : this.showCount;
991
- },
992
- /**
993
- * Is there any branch node?
994
- * @type {boolean}
995
- */
996
- hasBranchNodes() {
997
- return this.forest.normalizedOptions.some((e) => e.isBranch);
998
- },
999
- shouldFlattenOptions() {
1000
- return this.localSearch.active && this.flattenSearchResults;
1001
- }
1002
- /* eslint-enable valid-jsdoc */
1003
- },
1004
- watch: {
1005
- alwaysOpen(e) {
1006
- e ? this.openMenu() : this.closeMenu();
1007
- },
1008
- branchNodesFirst() {
1009
- this.initialize();
1010
- },
1011
- disabled(e) {
1012
- e && this.menu.isOpen ? this.closeMenu() : !e && !this.menu.isOpen && this.alwaysOpen && this.openMenu();
1013
- },
1014
- flat() {
1015
- this.initialize();
1016
- },
1017
- internalValue(e, t) {
1018
- q(e, t) && (this.$emit("update:modelValue", this.getValue(), this.getInstanceId()), this.$emit("updated", this.getValue(), this.getInstanceId()));
1019
- },
1020
- matchKeys() {
1021
- this.initialize();
1022
- },
1023
- multiple(e) {
1024
- e && this.buildForestState();
1025
- },
1026
- options: {
1027
- handler() {
1028
- this.async || (this.initialize(), this.rootOptionsStates.isLoaded = Array.isArray(this.options));
1029
- },
1030
- deep: !0,
1031
- immediate: !0
1032
- },
1033
- "trigger.searchQuery"() {
1034
- this.async ? this.handleRemoteSearch() : this.handleLocalSearch(), this.$emit("search-change", this.trigger.searchQuery, this.getInstanceId());
1035
- },
1036
- value() {
1037
- const e = this.extractCheckedNodeIdsFromValue();
1038
- q(e, this.internalValue) && this.fixSelectedNodeIds(e);
1039
- }
1040
- },
1041
- methods: {
1042
- verifyProps() {
1043
- y(
1044
- () => this.async ? this.searchable : !0,
1045
- () => 'For async search mode, the value of "searchable" prop must be true.'
1046
- ), this.options == null && !this.loadOptions && y(
1047
- () => !1,
1048
- () => 'Are you meant to dynamically load options? You need to use "loadOptions" prop.'
1049
- ), this.flat && y(
1050
- () => this.multiple,
1051
- () => 'You are using flat mode. But you forgot to add "multiple=true"?'
1052
- ), this.flat || [
1053
- "autoSelectAncestors",
1054
- "autoSelectDescendants",
1055
- "autoDeselectAncestors",
1056
- "autoDeselectDescendants"
1057
- ].forEach((t) => {
1058
- y(
1059
- () => !this[t],
1060
- () => `"${t}" only applies to flat mode.`
1061
- );
1062
- });
1063
- },
1064
- resetFlags() {
1065
- this._blurOnSelect = !1;
1066
- },
1067
- initialize() {
1068
- const e = this.async ? this.getRemoteSearchEntry().options : this.options;
1069
- if (Array.isArray(e)) {
1070
- const t = this.forest.nodeMap;
1071
- this.forest.nodeMap = S(), this.keepDataOfSelectedNodes(t), this.forest.normalizedOptions = this.normalize(E, e, t), this.fixSelectedNodeIds(this.internalValue);
1072
- } else
1073
- this.forest.normalizedOptions = [];
1074
- },
1075
- getInstanceId() {
1076
- return this.instanceId == null ? this.id : this.instanceId;
1077
- },
1078
- getValue() {
1079
- if (this.valueFormat === "id")
1080
- return this.multiple ? this.internalValue.slice() : this.internalValue[0];
1081
- const e = this.internalValue.map((t) => this.getNode(t).raw);
1082
- return this.multiple ? e : e[0];
1083
- },
1084
- getNode(e) {
1085
- return y(
1086
- () => e != null,
1087
- () => `Invalid node id: ${e}`
1088
- ), e == null ? null : e in this.forest.nodeMap ? this.forest.nodeMap[e] : this.createFallbackNode(e);
1089
- },
1090
- createFallbackNode(e) {
1091
- const t = this.extractNodeFromValue(e), n = this.enhancedNormalizer(t).label || `${e} (unknown)`, s = {
1092
- id: e,
1093
- label: n,
1094
- ancestors: [],
1095
- parentNode: E,
1096
- isFallbackNode: !0,
1097
- isRootNode: !0,
1098
- isLeaf: !0,
1099
- isBranch: !1,
1100
- isDisabled: !1,
1101
- isUnselectable: !1,
1102
- isNew: !1,
1103
- index: [-1],
1104
- level: 0,
1105
- raw: t
1106
- };
1107
- return this.forest.nodeMap[e] = s;
1108
- },
1109
- extractCheckedNodeIdsFromValue() {
1110
- return this.value === null || this.value === void 0 ? [] : this.valueFormat === "id" ? this.multiple ? this.value.slice() : [this.value] : (this.multiple ? this.value : [this.value]).map((e) => this.enhancedNormalizer(e)).map((e) => e.id);
1111
- },
1112
- extractNodeFromValue(e) {
1113
- const t = { id: e };
1114
- if (this.valueFormat === "id")
1115
- return t;
1116
- const n = this.multiple ? Array.isArray(this.value) ? this.value : [] : this.value ? [this.value] : [];
1117
- return In(
1118
- n,
1119
- (i) => i && this.enhancedNormalizer(i).id === e
1120
- ) || t;
1121
- },
1122
- fixSelectedNodeIds(e) {
1123
- let t = [];
1124
- if (this.single || this.flat || this.disableBranchNodes || this.valueConsistsOf === Y)
1125
- t = e;
1126
- else if (this.valueConsistsOf === W)
1127
- e.forEach((s) => {
1128
- t.push(s);
1129
- const i = this.getNode(s);
1130
- i.isBranch && this.traverseDescendantsBFS(i, (o) => {
1131
- t.push(o.id);
1132
- });
1133
- });
1134
- else if (this.valueConsistsOf === X) {
1135
- const s = S(), i = e.slice();
1136
- for (; i.length; ) {
1137
- const o = i.shift(), a = this.getNode(o);
1138
- t.push(o), !a.isRootNode && (a.parentNode.id in s || (s[a.parentNode.id] = a.parentNode.children.length), --s[a.parentNode.id] === 0 && i.push(a.parentNode.id));
1139
- }
1140
- } else if (this.valueConsistsOf === G) {
1141
- const s = S(), i = e.filter((o) => {
1142
- const a = this.getNode(o);
1143
- return a.isLeaf || a.children.length === 0;
1144
- });
1145
- for (; i.length; ) {
1146
- const o = i.shift(), a = this.getNode(o);
1147
- t.push(o), !a.isRootNode && (a.parentNode.id in s || (s[a.parentNode.id] = a.parentNode.children.length), --s[a.parentNode.id] === 0 && i.push(a.parentNode.id));
1148
- }
1149
- }
1150
- q(this.forest.selectedNodeIds, t) && (this.forest.selectedNodeIds = t), this.buildForestState();
1151
- },
1152
- keepDataOfSelectedNodes(e) {
1153
- this.forest.selectedNodeIds.forEach((t) => {
1154
- if (!e[t]) return;
1155
- const n = {
1156
- ...e[t],
1157
- isFallbackNode: !0
1158
- };
1159
- this.forest.nodeMap[t] = n;
1160
- });
1161
- },
1162
- isSelected(e) {
1163
- return this.forest.selectedNodeMap[e.id] === !0;
1164
- },
1165
- traverseDescendantsBFS(e, t) {
1166
- if (!e.isBranch) return;
1167
- const n = e.children.slice();
1168
- for (; n.length; ) {
1169
- const s = n[0];
1170
- s.isBranch && n.push(...s.children), t(s), n.shift();
1171
- }
1172
- },
1173
- traverseDescendantsDFS(e, t) {
1174
- e.isBranch && e.children.forEach((n) => {
1175
- this.traverseDescendantsDFS(n, t), t(n);
1176
- });
1177
- },
1178
- traverseAllNodesDFS(e) {
1179
- this.forest.normalizedOptions.forEach((t) => {
1180
- this.traverseDescendantsDFS(t, e), e(t);
1181
- });
1182
- },
1183
- traverseAllNodesByIndex(e) {
1184
- const t = (n) => {
1185
- n.children.forEach((s) => {
1186
- e(s) !== !1 && s.isBranch && t(s);
1187
- });
1188
- };
1189
- t({ children: this.forest.normalizedOptions });
1190
- },
1191
- toggleClickOutsideEvent(e) {
1192
- e ? document.addEventListener("mousedown", this.handleClickOutside, !1) : document.removeEventListener("mousedown", this.handleClickOutside, !1);
1193
- },
1194
- getValueContainer() {
1195
- return this.$refs.control.$refs["value-container"];
1196
- },
1197
- getInput() {
1198
- return this.getValueContainer().$refs.input;
1199
- },
1200
- focusInput() {
1201
- this.getInput().focus();
1202
- },
1203
- blurInput() {
1204
- this.getInput().blur();
1205
- },
1206
- handleMouseDown: w(function(t) {
1207
- if (t.preventDefault(), t.stopPropagation(), this.disabled) return;
1208
- this.getValueContainer().$el.contains(t.target) && !this.menu.isOpen && (this.openOnClick || this.trigger.isFocused) && this.openMenu(), this._blurOnSelect ? this.blurInput() : this.focusInput(), this.resetFlags();
1209
- }),
1210
- handleClickOutside(e) {
1211
- this.$refs.wrapper && !this.$refs.wrapper.contains(e.target) && (this.blurInput(), this.closeMenu());
1212
- },
1213
- handleLocalSearch() {
1214
- const { searchQuery: e } = this.trigger, t = () => this.resetHighlightedOptionWhenNecessary(!0);
1215
- if (!e)
1216
- return this.localSearch.active = !1, t();
1217
- this.localSearch.active = !0, this.localSearch.noResults = !0, this.traverseAllNodesDFS((i) => {
1218
- i.isBranch && (i.isExpandedOnSearch = !1, i.showAllChildrenOnSearch = !1, i.isMatched = !1, i.hasMatchedDescendants = !1, this.localSearch.countMap[i.id] = {
1219
- [T]: 0,
1220
- [R]: 0,
1221
- [A]: 0,
1222
- [B]: 0
1223
- });
1224
- });
1225
- const n = e.trim().toLocaleLowerCase(), s = n.replace(/\s+/g, " ").split(" ");
1226
- this.traverseAllNodesDFS((i) => {
1227
- this.searchNested && s.length > 1 ? i.isMatched = s.every(
1228
- (o) => we(!1, o, i.nestedSearchLabel)
1229
- ) : i.isMatched = this.matchKeys.some(
1230
- (o) => we(!this.disableFuzzyMatching, n, i.lowerCased[o])
1231
- ), i.isMatched && (this.localSearch.noResults = !1, i.ancestors.forEach((o) => this.localSearch.countMap[o.id][R]++), i.isLeaf && i.ancestors.forEach((o) => this.localSearch.countMap[o.id][B]++), i.parentNode !== E && (this.localSearch.countMap[i.parentNode.id][T] += 1, i.isLeaf && (this.localSearch.countMap[i.parentNode.id][A] += 1))), (i.isMatched || i.isBranch && i.isExpandedOnSearch) && i.parentNode !== E && (i.parentNode.isExpandedOnSearch = !0, i.parentNode.hasMatchedDescendants = !0);
1232
- }), t();
1233
- },
1234
- handleRemoteSearch() {
1235
- const { searchQuery: e } = this.trigger, t = this.getRemoteSearchEntry(), n = () => {
1236
- this.initialize(), this.resetHighlightedOptionWhenNecessary(!0);
1237
- };
1238
- if ((e === "" || this.cacheOptions) && t.isLoaded)
1239
- return n();
1240
- this.callLoadOptionsProp({
1241
- action: An,
1242
- args: { searchQuery: e },
1243
- isPending() {
1244
- return t.isLoading;
1245
- },
1246
- start: () => {
1247
- t.isLoading = !0, t.isLoaded = !1, t.loadingError = "";
1248
- },
1249
- succeed: (s) => {
1250
- t.isLoaded = !0, t.options = s, this.trigger.searchQuery === e && n();
1251
- },
1252
- fail: (s) => {
1253
- t.loadingError = Z(s);
1254
- },
1255
- end: () => {
1256
- t.isLoading = !1;
1257
- }
1258
- });
1259
- },
1260
- getRemoteSearchEntry() {
1261
- const { searchQuery: e } = this.trigger, t = this.remoteSearch[e] || {
1262
- ...J(),
1263
- options: []
1264
- };
1265
- if (this.$watch(
1266
- () => t.options,
1267
- () => {
1268
- this.trigger.searchQuery === e && this.initialize();
1269
- },
1270
- { deep: !0 }
1271
- ), e === "") {
1272
- if (Array.isArray(this.defaultOptions))
1273
- return t.options = this.defaultOptions, t.isLoaded = !0, t;
1274
- if (this.defaultOptions !== !0)
1275
- return t.isLoaded = !0, t;
1276
- }
1277
- return this.remoteSearch[e] || (this.remoteSearch[e] = t), t;
1278
- },
1279
- shouldExpand(e) {
1280
- return this.localSearch.active ? e.isExpandedOnSearch : e.isExpanded;
1281
- },
1282
- shouldOptionBeIncludedInSearchResult(e) {
1283
- return !!(e.isMatched || e.isBranch && e.hasMatchedDescendants && !this.flattenSearchResults || !e.isRootNode && e.parentNode.showAllChildrenOnSearch);
1284
- },
1285
- shouldShowOptionInMenu(e) {
1286
- return !(this.localSearch.active && !this.shouldOptionBeIncludedInSearchResult(e));
1287
- },
1288
- getControl() {
1289
- var e;
1290
- return (e = this.$refs.control) == null ? void 0 : e.$el;
1291
- },
1292
- getMenu() {
1293
- var t, n;
1294
- const e = (n = (t = this.$refs.menu) == null ? void 0 : t.$refs) == null ? void 0 : n.menu;
1295
- return e && e.nodeName !== "#comment" ? e : null;
1296
- },
1297
- setCurrentHighlightedOption(e, t = !0) {
1298
- const n = this.menu.current;
1299
- 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) {
1300
- const s = () => {
1301
- const i = this.getMenu(), o = i.querySelector(`.vue-treeselect__option[data-id="${e.id}"]`);
1302
- o && et(i, o);
1303
- };
1304
- this.getMenu() ? s() : this.$nextTick(s);
1305
- }
1306
- },
1307
- resetHighlightedOptionWhenNecessary(e = !1) {
1308
- const { current: t } = this.menu;
1309
- (e || t == null || !(t in this.forest.nodeMap) || !this.shouldShowOptionInMenu(this.getNode(t))) && this.highlightFirstOption();
1310
- },
1311
- highlightFirstOption() {
1312
- if (!this.hasVisibleOptions) return;
1313
- const e = this.visibleOptionIds[0];
1314
- this.setCurrentHighlightedOption(this.getNode(e));
1315
- },
1316
- highlightPrevOption() {
1317
- if (!this.hasVisibleOptions) return;
1318
- const e = this.visibleOptionIds.indexOf(this.menu.current) - 1;
1319
- if (e === -1) return this.highlightLastOption();
1320
- this.setCurrentHighlightedOption(this.getNode(this.visibleOptionIds[e]));
1321
- },
1322
- highlightNextOption() {
1323
- if (!this.hasVisibleOptions) return;
1324
- const e = this.visibleOptionIds.indexOf(this.menu.current) + 1;
1325
- if (e === this.visibleOptionIds.length) return this.highlightFirstOption();
1326
- this.setCurrentHighlightedOption(this.getNode(this.visibleOptionIds[e]));
1327
- },
1328
- highlightLastOption() {
1329
- if (!this.hasVisibleOptions) return;
1330
- const e = be(this.visibleOptionIds);
1331
- this.setCurrentHighlightedOption(this.getNode(e));
1332
- },
1333
- resetSearchQuery() {
1334
- this.trigger.searchQuery = "";
1335
- },
1336
- closeMenu() {
1337
- !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()));
1338
- },
1339
- openMenu() {
1340
- 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()));
1341
- },
1342
- toggleMenu() {
1343
- this.menu.isOpen ? this.closeMenu() : this.openMenu();
1344
- },
1345
- toggleExpanded(e) {
1346
- let t;
1347
- this.localSearch.active ? (t = e.isExpandedOnSearch = !e.isExpandedOnSearch, t && (e.showAllChildrenOnSearch = !0)) : t = e.isExpanded = !e.isExpanded, t && !e.childrenStates.isLoaded && this.loadChildrenOptions(e);
1348
- },
1349
- buildForestState() {
1350
- const e = S();
1351
- this.forest.selectedNodeIds.forEach((n) => {
1352
- e[n] = !0;
1353
- }), this.forest.selectedNodeMap = e;
1354
- const t = S();
1355
- this.multiple && (this.traverseAllNodesByIndex((n) => {
1356
- t[n.id] = oe;
1357
- }), this.selectedNodes.forEach((n) => {
1358
- t[n.id] = Ve, !this.flat && !this.disableBranchNodes && n.ancestors.forEach((s) => {
1359
- this.isSelected(s) || (t[s.id] = $e);
1360
- });
1361
- })), this.forest.checkedStateMap = t;
1362
- },
1363
- enhancedNormalizer(e) {
1364
- return {
1365
- ...e,
1366
- ...this.normalizer(e, this.getInstanceId())
1367
- };
1368
- },
1369
- normalize(e, t, n) {
1370
- let s = t.map((i) => [this.enhancedNormalizer(i), i]).map(([i, o], a) => {
1371
- this.checkDuplication(i), this.verifyNodeShape(i);
1372
- const { id: c, label: d, children: f, isDefaultExpanded: m } = i, p = e === E, v = p ? 0 : e.level + 1, N = Array.isArray(f) || f === null, D = !N, k = !!i.isDisabled || !this.flat && !p && e.isDisabled, z = !!i.isUnselectable, L = !!i.isNew, M = this.matchKeys.reduce((h, u) => ({
1373
- ...h,
1374
- [u]: Vn(i[u]).toLocaleLowerCase()
1375
- }), {}), U = p ? M.label : e.nestedSearchLabel + " " + M.label;
1376
- this.forest.nodeMap[c] = S();
1377
- const l = this.forest.nodeMap[c];
1378
- if (l.id = c, l.label = d, l.level = v, l.ancestors = p ? [] : [e].concat(e.ancestors), l.index = (p ? [] : e.index).concat(a), l.parentNode = e, l.lowerCased = M, l.nestedSearchLabel = U, l.isDisabled = k, l.isUnselectable = z, l.isNew = L, l.isMatched = !1, l.isHighlighted = !1, l.isBranch = N, l.isLeaf = D, l.isRootNode = p, l.raw = o, N) {
1379
- const h = Array.isArray(f);
1380
- l.childrenStates = { ...J(), isLoaded: h }, l.isExpanded = typeof m == "boolean" ? m : v < this.defaultExpandLevel, l.hasMatchedDescendants = !1, l.hasDisabledDescendants = !1, l.isExpandedOnSearch = !1, l.showAllChildrenOnSearch = !1, l.count = {
1381
- [T]: 0,
1382
- [R]: 0,
1383
- [A]: 0,
1384
- [B]: 0
1385
- }, l.children = h ? this.normalize(l, f, n) : [], m === !0 && l.ancestors.forEach((u) => {
1386
- u.isExpanded = !0;
1387
- }), !h && typeof this.loadOptions != "function" ? y(
1388
- () => !1,
1389
- () => 'Unloaded branch node detected. "loadOptions" prop is required to load its children.'
1390
- ) : !h && l.isExpanded && this.loadChildrenOptions(l);
1391
- }
1392
- if (l.ancestors.forEach((h) => h.count[R]++), D && l.ancestors.forEach((h) => h.count[B]++), p || (e.count[T] += 1, D && (e.count[A] += 1), k && (e.hasDisabledDescendants = !0)), n && n[c]) {
1393
- const h = n[c];
1394
- l.isMatched = h.isMatched, l.showAllChildrenOnSearch = h.showAllChildrenOnSearch, l.isHighlighted = h.isHighlighted, h.isBranch && l.isBranch && (l.isExpanded = h.isExpanded, l.isExpandedOnSearch = h.isExpandedOnSearch, h.childrenStates.isLoaded && !l.childrenStates.isLoaded ? l.isExpanded = !1 : l.childrenStates = { ...h.childrenStates });
1395
- }
1396
- return l;
1397
- });
1398
- if (this.branchNodesFirst) {
1399
- const i = s.filter((a) => a.isBranch), o = s.filter((a) => a.isLeaf);
1400
- s = i.concat(o);
1401
- }
1402
- return s;
1403
- },
1404
- loadRootOptions() {
1405
- this.callLoadOptionsProp({
1406
- action: xn,
1407
- isPending: () => this.rootOptionsStates.isLoading,
1408
- start: () => {
1409
- this.rootOptionsStates.isLoading = !0, this.rootOptionsStates.loadingError = "";
1410
- },
1411
- succeed: () => {
1412
- this.rootOptionsStates.isLoaded = !0, this.$nextTick(() => {
1413
- this.resetHighlightedOptionWhenNecessary(!0);
1414
- });
1415
- },
1416
- fail: (e) => {
1417
- this.rootOptionsStates.loadingError = Z(e);
1418
- },
1419
- end: () => {
1420
- this.rootOptionsStates.isLoading = !1;
1421
- }
1422
- });
1423
- },
1424
- loadChildrenOptions(e) {
1425
- const { id: t, raw: n } = e;
1426
- this.callLoadOptionsProp({
1427
- action: Rn,
1428
- args: {
1429
- // We always pass the raw node instead of the normalized node to any
1430
- // callback provided by the user of this component.
1431
- // Because the shape of the raw node is more likely to be closing to
1432
- // what the back-end API service of the application needs.
1433
- parentNode: n
1434
- },
1435
- isPending: () => this.getNode(t).childrenStates.isLoading,
1436
- start: () => {
1437
- this.getNode(t).childrenStates.isLoading = !0, this.getNode(t).childrenStates.loadingError = "";
1438
- },
1439
- succeed: () => {
1440
- this.getNode(t).childrenStates.isLoaded = !0;
1441
- },
1442
- fail: (s) => {
1443
- this.getNode(t).childrenStates.loadingError = Z(s);
1444
- },
1445
- end: () => {
1446
- this.getNode(t).childrenStates.isLoading = !1;
1447
- }
1448
- });
1449
- },
1450
- callLoadOptionsProp({ action: e, args: t, isPending: n, start: s, succeed: i, fail: o, end: a }) {
1451
- if (!this.loadOptions || n())
1452
- return;
1453
- s();
1454
- const c = _n((f, m) => {
1455
- f ? o(f) : i(m), a();
1456
- }), d = this.loadOptions({
1457
- id: this.getInstanceId(),
1458
- instanceId: this.getInstanceId(),
1459
- action: e,
1460
- ...t,
1461
- callback: c
1462
- });
1463
- Ae(d) && d.then(() => {
1464
- c();
1465
- }, (f) => {
1466
- c(f);
1467
- }).catch((f) => {
1468
- console.error(f);
1469
- });
1470
- },
1471
- checkDuplication(e) {
1472
- y(
1473
- () => !(e.id in this.forest.nodeMap && !this.forest.nodeMap[e.id].isFallbackNode),
1474
- () => `Detected duplicate presence of node id ${JSON.stringify(e.id)}. Their labels are "${this.forest.nodeMap[e.id].label}" and "${e.label}" respectively.`
1475
- );
1476
- },
1477
- verifyNodeShape(e) {
1478
- y(
1479
- () => !(e.children === void 0 && e.isBranch === !0),
1480
- () => "Are you meant to declare an unloaded branch node? `isBranch: true` is no longer supported, please use `children: null` instead."
1481
- );
1482
- },
1483
- select(e) {
1484
- if (this.disabled || e.isDisabled || e.isUnselectable)
1485
- return;
1486
- this.single && this.clear();
1487
- const t = this.multiple && !this.flat ? this.forest.checkedStateMap[e.id] === oe : !this.isSelected(e);
1488
- 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));
1489
- },
1490
- clear() {
1491
- this.hasValue && (this.single || this.allowClearingDisabled ? this.forest.selectedNodeIds = [] : this.forest.selectedNodeIds = this.forest.selectedNodeIds.filter(
1492
- (e) => this.getNode(e).isDisabled || this.getNode(e).isUnselectable
1493
- ), this.buildForestState());
1494
- },
1495
- // This is meant to be called only by `select()`.
1496
- _selectNode(e) {
1497
- if (this.single || this.disableBranchNodes)
1498
- return this.addValue(e);
1499
- if (this.flat) {
1500
- this.addValue(e), this.autoSelectAncestors ? e.ancestors.forEach((n) => {
1501
- !this.isSelected(n) && !n.isDisabled && !n.isUnselectable && this.addValue(n);
1502
- }) : this.autoSelectDescendants && this.traverseDescendantsBFS(e, (n) => {
1503
- !this.isSelected(n) && !n.isDisabled && !n.isUnselectable && this.addValue(n);
1504
- });
1505
- return;
1506
- }
1507
- const t = e.isLeaf || /* node.isBranch && */
1508
- !e.hasDisabledDescendants || /* node.isBranch && */
1509
- this.allowSelectingDisabledDescendants;
1510
- if (t && this.addValue(e), e.isBranch && this.traverseDescendantsBFS(e, (n) => {
1511
- (!n.isDisabled || !n.isUnselectable || this.allowSelectingDisabledDescendants) && this.addValue(n);
1512
- }), t) {
1513
- let n = e;
1514
- for (; (n = n.parentNode) !== E && n.children.every(this.isSelected); )
1515
- this.addValue(n);
1516
- }
1517
- },
1518
- // This is meant to be called only by `select()`.
1519
- _deselectNode(e) {
1520
- if (this.disableBranchNodes)
1521
- return this.removeValue(e);
1522
- if (this.flat) {
1523
- this.removeValue(e), this.autoDeselectAncestors ? e.ancestors.forEach((n) => {
1524
- this.isSelected(n) && !n.isDisabled && !n.isUnselectable && this.removeValue(n);
1525
- }) : this.autoDeselectDescendants && this.traverseDescendantsBFS(e, (n) => {
1526
- this.isSelected(n) && !n.isDisabled && !n.isUnselectable && this.removeValue(n);
1527
- });
1528
- return;
1529
- }
1530
- let t = !1;
1531
- if (e.isBranch && this.traverseDescendantsDFS(e, (n) => {
1532
- (!n.isDisabled || !n.isUnselectable || this.allowSelectingDisabledDescendants) && (this.removeValue(n), t = !0);
1533
- }), e.isLeaf || /* node.isBranch && */
1534
- t || /* node.isBranch && */
1535
- e.children.length === 0) {
1536
- this.removeValue(e);
1537
- let n = e;
1538
- for (; (n = n.parentNode) !== E && this.isSelected(n); )
1539
- this.removeValue(n);
1540
- }
1541
- },
1542
- addValue(e) {
1543
- this.forest.selectedNodeIds.push(e.id), this.forest.selectedNodeMap[e.id] = !0;
1544
- },
1545
- removeValue(e) {
1546
- Ie(this.forest.selectedNodeIds, e.id), delete this.forest.selectedNodeMap[e.id];
1547
- },
1548
- removeLastValue() {
1549
- if (!this.hasValue) return;
1550
- if (this.single) return this.clear();
1551
- const e = be(this.internalValue), t = this.getNode(e);
1552
- this.select(t);
1553
- },
1554
- saveMenuScrollPosition() {
1555
- const e = this.getMenu();
1556
- e && (this.menu.lastScrollPosition = e.scrollTop);
1557
- },
1558
- restoreMenuScrollPosition() {
1559
- const e = this.getMenu();
1560
- e && (e.scrollTop = this.menu.lastScrollPosition);
1561
- }
1562
- },
1563
- created() {
1564
- this.verifyProps(), this.resetFlags();
1565
- },
1566
- mounted() {
1567
- this.autoFocus && this.focusInput(), !this.options && !this.async && this.autoLoadRootOptions && this.loadRootOptions(), this.alwaysOpen && this.openMenu(), this.async && this.defaultOptions && this.handleRemoteSearch();
1568
- },
1569
- unmounted() {
1570
- this.toggleClickOutsideEvent(!1);
1571
- }
1572
- };
1573
- function Fn(e) {
1574
- return typeof e == "string" ? e : e != null && !Re(e) ? JSON.stringify(e) : "";
1575
- }
1576
- const Wn = {
1577
- name: "vue-treeselect--hidden-fields",
1578
- inject: ["instance"],
1579
- render() {
1580
- const {
1581
- instance: e
1582
- } = this;
1583
- if (!e || !("name" in e) || !e.name || e.disabled || !e.hasValue) return null;
1584
- let t = e.internalValue.map(Fn);
1585
- return e.multiple && e.joinValues && (t = [t.join(e.delimiter)]), t.map((n, s) => r("input", {
1586
- type: "hidden",
1587
- name: e.name,
1588
- value: n,
1589
- key: "hidden-field-" + s
1590
- }, null));
1591
- }
1592
- }, Hn = [g.ENTER, g.END, g.HOME, g.ARROW_LEFT, g.ARROW_UP, g.ARROW_RIGHT, g.ARROW_DOWN], ze = {
1593
- name: "vue-treeselect--input",
1594
- inject: ["instance"],
1595
- data: () => ({
1596
- inputWidth: Ne,
1597
- value: ""
1598
- }),
1599
- computed: {
1600
- needAutoSize() {
1601
- const {
1602
- instance: e
1603
- } = this;
1604
- return e.searchable && !e.disabled && e.multiple;
1605
- },
1606
- inputStyle() {
1607
- return {
1608
- width: this.needAutoSize ? `${this.inputWidth}px` : null
1609
- };
1610
- }
1611
- },
1612
- watch: {
1613
- "instance.trigger.searchQuery"(e) {
1614
- this.value = e;
1615
- },
1616
- value() {
1617
- this.needAutoSize && this.$nextTick(this.updateInputWidth);
1618
- }
1619
- },
1620
- created() {
1621
- this.debouncedCallback = Zt(this.updateSearchQuery, Bn, {
1622
- leading: !0,
1623
- trailing: !0
1624
- });
1625
- },
1626
- methods: {
1627
- clear() {
1628
- this.onInput({
1629
- target: {
1630
- value: ""
1631
- }
1632
- });
1633
- },
1634
- focus() {
1635
- const {
1636
- instance: e
1637
- } = this;
1638
- e.disabled || this.$refs.input && this.$refs.input.focus();
1639
- },
1640
- blur() {
1641
- this.$refs.input && this.$refs.input.blur();
1642
- },
1643
- onFocus() {
1644
- const {
1645
- instance: e
1646
- } = this;
1647
- e.trigger.isFocused = !0, e.openOnFocus && e.openMenu();
1648
- },
1649
- onBlur() {
1650
- const {
1651
- instance: e
1652
- } = this, t = e.getMenu();
1653
- if (t && document.activeElement === t)
1654
- return this.focus();
1655
- e.trigger.isFocused = !1, e.closeMenu();
1656
- },
1657
- onInput(e) {
1658
- const {
1659
- value: t
1660
- } = e.target;
1661
- this.value = t, t ? this.debouncedCallback() : (this.debouncedCallback.cancel(), this.updateSearchQuery());
1662
- },
1663
- // 用 keyUp 事件存在一个问题,删除输入框最后一个字符也会导致取消选中最后一项
1664
- onKeyDown(e) {
1665
- const {
1666
- instance: t
1667
- } = this, n = "which" in e ? e.which : (
1668
- /* istanbul ignore next */
1669
- e.keyCode
1670
- );
1671
- if (!(e.ctrlKey || e.shiftKey || e.altKey || e.metaKey)) {
1672
- if (!t.menu.isOpen && _(Hn, n))
1673
- return e.preventDefault(), t.openMenu();
1674
- switch (n) {
1675
- case g.BACKSPACE: {
1676
- t.backspaceRemoves && !this.value.length && t.removeLastValue();
1677
- break;
1678
- }
1679
- case g.ENTER: {
1680
- if (e.preventDefault(), t.menu.current === null) return;
1681
- const s = t.getNode(t.menu.current);
1682
- if (s.isBranch && t.disableBranchNodes) return;
1683
- t.select(s);
1684
- break;
1685
- }
1686
- case g.ESCAPE: {
1687
- this.value.length ? this.clear() : t.menu.isOpen && t.closeMenu();
1688
- break;
1689
- }
1690
- case g.END: {
1691
- e.preventDefault(), t.highlightLastOption();
1692
- break;
1693
- }
1694
- case g.HOME: {
1695
- e.preventDefault(), t.highlightFirstOption();
1696
- break;
1697
- }
1698
- case g.ARROW_LEFT: {
1699
- const s = t.getNode(t.menu.current);
1700
- s.isBranch && t.shouldExpand(s) ? (e.preventDefault(), t.toggleExpanded(s)) : !s.isRootNode && (s.isLeaf || s.isBranch && !t.shouldExpand(s)) && (e.preventDefault(), t.setCurrentHighlightedOption(s.parentNode));
1701
- break;
1702
- }
1703
- case g.ARROW_UP: {
1704
- e.preventDefault(), t.highlightPrevOption();
1705
- break;
1706
- }
1707
- case g.ARROW_RIGHT: {
1708
- const s = t.getNode(t.menu.current);
1709
- s.isBranch && !t.shouldExpand(s) && (e.preventDefault(), t.toggleExpanded(s));
1710
- break;
1711
- }
1712
- case g.ARROW_DOWN: {
1713
- e.preventDefault(), t.highlightNextOption();
1714
- break;
1715
- }
1716
- case g.DELETE: {
1717
- t.deleteRemoves && !this.value.length && t.removeLastValue();
1718
- break;
1719
- }
1720
- default:
1721
- t.openMenu();
1722
- }
1723
- }
1724
- },
1725
- onMouseDown(e) {
1726
- this.value.length && e.stopPropagation();
1727
- },
1728
- renderInputContainer() {
1729
- const {
1730
- instance: e
1731
- } = this, t = {}, n = [];
1732
- return e.searchable && !e.disabled && (n.push(this.renderInput()), this.needAutoSize && n.push(this.renderSizer())), e.searchable || re(t, {
1733
- on: {
1734
- focus: this.onFocus,
1735
- blur: this.onBlur,
1736
- keydown: this.onKeyDown
1737
- },
1738
- ref: "input"
1739
- }), !e.searchable && !e.disabled && re(t, {
1740
- attrs: {
1741
- tabIndex: e.tabIndex
1742
- }
1743
- }), r("div", Pe({
1744
- class: "vue-treeselect__input-container"
1745
- }, t), [n]);
1746
- },
1747
- renderInput() {
1748
- const {
1749
- instance: e
1750
- } = this;
1751
- return r("input", {
1752
- ref: "input",
1753
- class: "vue-treeselect__input",
1754
- type: "text",
1755
- autocomplete: "off",
1756
- tabIndex: e.tabIndex,
1757
- required: e.required && !e.hasValue,
1758
- value: this.value,
1759
- style: this.inputStyle,
1760
- onFocus: this.onFocus,
1761
- onInput: this.onInput,
1762
- onBlur: this.onBlur,
1763
- onKeydown: this.onKeyDown,
1764
- onMousedown: this.onMouseDown
1765
- }, null);
1766
- },
1767
- renderSizer() {
1768
- return r("div", {
1769
- ref: "sizer",
1770
- class: "vue-treeselect__sizer"
1771
- }, [this.value]);
1772
- },
1773
- updateInputWidth() {
1774
- this.inputWidth = Math.max(Ne, this.$refs.sizer.scrollWidth + 15);
1775
- },
1776
- updateSearchQuery() {
1777
- const {
1778
- instance: e
1779
- } = this;
1780
- e.trigger.searchQuery = this.value;
1781
- }
1782
- },
1783
- render() {
1784
- return this.renderInputContainer();
1785
- }
1786
- }, Fe = {
1787
- name: "vue-treeselect--placeholder",
1788
- inject: ["instance"],
1789
- render() {
1790
- const {
1791
- instance: e
1792
- } = this, t = {
1793
- "vue-treeselect__placeholder": !0,
1794
- "vue-treeselect-helper-zoom-effect-off": !0,
1795
- "vue-treeselect-helper-hide": e.hasValue || e.trigger.searchQuery
1796
- };
1797
- return r("div", {
1798
- class: t
1799
- }, [e.placeholder]);
1800
- }
1801
- }, Pn = {
1802
- name: "vue-treeselect--single-value",
1803
- inject: ["instance"],
1804
- methods: {
1805
- renderSingleValueLabel() {
1806
- const {
1807
- instance: e
1808
- } = this, t = e.selectedNodes[0], n = e.$slots["value-label"];
1809
- return n ? n({
1810
- node: t
1811
- }) : t.label;
1812
- }
1813
- },
1814
- render() {
1815
- const {
1816
- instance: e,
1817
- $parent: {
1818
- renderValueContainer: t
1819
- }
1820
- } = this, n = e.hasValue && !e.trigger.searchQuery;
1821
- return t([n && r("div", {
1822
- class: "vue-treeselect__single-value"
1823
- }, [this.renderSingleValueLabel()]), r(Fe, null, null), r(ze, {
1824
- ref: "input"
1825
- }, null)]);
1826
- }
1827
- }, ae = (e, t) => {
1828
- const n = e.__vccOpts || e;
1829
- for (const [s, i] of t)
1830
- n[s] = i;
1831
- return n;
1832
- }, jn = {
1833
- name: "vue-treeselect--x"
1834
- }, Un = {
1835
- xmlns: "http://www.w3.org/2000/svg",
1836
- viewBox: "0 0 348.333 348.333"
1837
- };
1838
- function Qn(e, t, n, s, i, o) {
1839
- return V(), j("svg", Un, t[0] || (t[0] = [
1840
- $("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)
1841
- ]));
1842
- }
1843
- const We = /* @__PURE__ */ ae(jn, [["render", Qn]]), Kn = {
1844
- name: "vue-treeselect--multi-value-item",
1845
- inject: ["instance"],
1846
- props: {
1847
- node: {
1848
- type: Object,
1849
- required: !0
1850
- }
1851
- },
1852
- methods: {
1853
- handleMouseDown: w(function() {
1854
- const {
1855
- instance: t,
1856
- node: n
1857
- } = this;
1858
- t.select(n);
1859
- })
1860
- },
1861
- render() {
1862
- const {
1863
- instance: e,
1864
- node: t
1865
- } = this, n = {
1866
- "vue-treeselect__multi-value-item": !0,
1867
- "vue-treeselect__multi-value-item-disabled": t.isDisabled || t.isUnselectable,
1868
- "vue-treeselect__multi-value-item-new": t.isNew
1869
- }, s = e.$slots["value-label"], i = s ? s({
1870
- node: t
1871
- }) : t.label;
1872
- return r("div", {
1873
- class: "vue-treeselect__multi-value-item-container"
1874
- }, [r("div", {
1875
- class: n,
1876
- onMousedown: this.handleMouseDown
1877
- }, [r("span", {
1878
- class: "vue-treeselect__multi-value-label"
1879
- }, [i]), r("span", {
1880
- class: "vue-treeselect__icon vue-treeselect__value-remove"
1881
- }, [r(We, null, null)])])]);
1882
- }
1883
- }, qn = {
1884
- name: "vue-treeselect--multi-value",
1885
- inject: ["instance"],
1886
- methods: {
1887
- renderMultiValueItems() {
1888
- const {
1889
- instance: e
1890
- } = this;
1891
- return e.internalValue.slice(0, e.limit).map(e.getNode).map((t) => r(Kn, {
1892
- key: `multi-value-item-${t.id}`,
1893
- node: t
1894
- }, null));
1895
- },
1896
- renderExceedLimitTip() {
1897
- const {
1898
- instance: e
1899
- } = this, t = e.internalValue.length - e.limit;
1900
- return t <= 0 ? null : r("div", {
1901
- class: "vue-treeselect__limit-tip vue-treeselect-helper-zoom-effect-off",
1902
- key: "exceed-limit-tip"
1903
- }, [r("span", {
1904
- class: "vue-treeselect__limit-tip-text"
1905
- }, [e.limitText(t)])]);
1906
- }
1907
- },
1908
- render() {
1909
- const {
1910
- renderValueContainer: e
1911
- } = this.$parent;
1912
- return e(r("div", {
1913
- class: "vue-treeselect__multi-value",
1914
- name: "vue-treeselect__multi-value-item--transition"
1915
- }, [this.renderMultiValueItems(), this.renderExceedLimitTip(), r(Fe, {
1916
- key: "placeholder"
1917
- }, null), r(ze, {
1918
- ref: "input",
1919
- key: "input"
1920
- }, null)]));
1921
- }
1922
- }, Yn = {
1923
- name: "vue-treeselect--arrow"
1924
- }, Xn = {
1925
- xmlns: "http://www.w3.org/2000/svg",
1926
- viewBox: "0 0 292.362 292.362"
1927
- };
1928
- function Gn(e, t, n, s, i, o) {
1929
- return V(), j("svg", Xn, t[0] || (t[0] = [
1930
- $("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)
1931
- ]));
1932
- }
1933
- const He = /* @__PURE__ */ ae(Yn, [["render", Gn]]), Jn = {
1934
- name: "vue-treeselect--control",
1935
- inject: ["instance"],
1936
- computed: {
1937
- /* eslint-disable valid-jsdoc */
1938
- /**
1939
- * Should show the "×" button that resets value?
1940
- * @return {boolean}
1941
- */
1942
- shouldShowX() {
1943
- const {
1944
- instance: e
1945
- } = this;
1946
- return e.clearable && !e.disabled && e.hasValue && (this.hasUndisabledValue || e.allowClearingDisabled);
1947
- },
1948
- /**
1949
- * Should show the arrow button that toggles menu?
1950
- * @return {boolean}
1951
- */
1952
- shouldShowArrow() {
1953
- const {
1954
- instance: e
1955
- } = this;
1956
- return e.alwaysOpen ? !e.menu.isOpen : !0;
1957
- },
1958
- /**
1959
- * Has any undisabled option been selected?
1960
- * @type {boolean}
1961
- */
1962
- hasUndisabledValue() {
1963
- const {
1964
- instance: e
1965
- } = this;
1966
- return e.hasValue && e.internalValue.some((t) => !e.getNode(t).isDisabled || !e.getNode(t).isUnselectable);
1967
- }
1968
- /* eslint-enable valid-jsdoc */
1969
- },
1970
- methods: {
1971
- renderX() {
1972
- const {
1973
- instance: e
1974
- } = this, t = e.multiple ? e.clearAllText : e.clearValueText;
1975
- return this.shouldShowX ? r("div", {
1976
- class: "vue-treeselect__x-container",
1977
- title: t,
1978
- onMousedown: this.handleMouseDownOnX
1979
- }, [r(We, {
1980
- class: "vue-treeselect__x"
1981
- }, null)]) : null;
1982
- },
1983
- renderArrow() {
1984
- const {
1985
- instance: e
1986
- } = this, t = {
1987
- "vue-treeselect__control-arrow": !0,
1988
- "vue-treeselect__control-arrow--rotated": e.menu.isOpen
1989
- };
1990
- return this.shouldShowArrow ? r("div", {
1991
- class: "vue-treeselect__control-arrow-container",
1992
- onMousedown: this.handleMouseDownOnArrow
1993
- }, [r(He, {
1994
- class: t
1995
- }, null)]) : null;
1996
- },
1997
- handleMouseDownOnX: w(function(t) {
1998
- t.stopPropagation(), t.preventDefault();
1999
- const {
2000
- instance: n
2001
- } = this, s = n.beforeClearAll(), i = (o) => {
2002
- o && n.clear();
2003
- };
2004
- Ae(s) ? s.then(i) : setTimeout(() => i(s), 0);
2005
- }),
2006
- handleMouseDownOnArrow: w(function(t) {
2007
- t.preventDefault(), t.stopPropagation();
2008
- const {
2009
- instance: n
2010
- } = this;
2011
- n.focusInput(), n.toggleMenu();
2012
- }),
2013
- // This is meant to be called by child `<Value />` component.
2014
- renderValueContainer(e) {
2015
- return r("div", {
2016
- class: "vue-treeselect__value-container"
2017
- }, [e]);
2018
- }
2019
- },
2020
- render() {
2021
- const {
2022
- instance: e
2023
- } = this, t = e.single ? Pn : qn;
2024
- return r("div", {
2025
- class: "vue-treeselect__control",
2026
- onMousedown: e.handleMouseDown
2027
- }, [r(t, {
2028
- ref: "value-container"
2029
- }, null), this.renderX(), this.renderArrow()]);
2030
- }
2031
- }, Zn = { class: "vue-treeselect__icon-container" }, es = { class: "`vue-treeselect__tip-text vue-treeselect__${type}-tip-text`" }, b = /* @__PURE__ */ Object.assign({
2032
- name: "vue-treeselect--tip"
2033
- }, {
2034
- __name: "Tip",
2035
- props: {
2036
- type: {
2037
- type: String,
2038
- required: !0
2039
- },
2040
- icon: {
2041
- type: String,
2042
- required: !0
2043
- }
2044
- },
2045
- setup(e) {
2046
- return (t, n) => (V(), j("div", {
2047
- class: se(`vue-treeselect__tip vue-treeselect__${e.type}-tip`)
2048
- }, [
2049
- $("div", Zn, [
2050
- $("span", {
2051
- class: se(`vue-treeselect__icon-${e.icon}`)
2052
- }, null, 2)
2053
- ]),
2054
- $("span", es, [
2055
- je(t.$slots, "default")
2056
- ])
2057
- ], 2));
2058
- }
2059
- });
2060
- let ee, te, ne;
2061
- const ts = {
2062
- name: "vue-treeselect--option",
2063
- inject: ["instance"],
2064
- props: {
2065
- node: {
2066
- type: Object,
2067
- required: !0
2068
- }
2069
- },
2070
- computed: {
2071
- shouldExpand() {
2072
- const {
2073
- instance: e,
2074
- node: t
2075
- } = this;
2076
- return t.isBranch && e.shouldExpand(t);
2077
- },
2078
- shouldShow() {
2079
- const {
2080
- instance: e,
2081
- node: t
2082
- } = this;
2083
- return e.shouldShowOptionInMenu(t);
2084
- }
2085
- },
2086
- methods: {
2087
- renderOption() {
2088
- const {
2089
- instance: e,
2090
- node: t
2091
- } = this, n = {
2092
- "vue-treeselect__option": !0,
2093
- "vue-treeselect__option--disabled": t.isDisabled,
2094
- "vue-treeselect__option--unselectable": t.isUnselectable,
2095
- "vue-treeselect__option--selected": e.isSelected(t),
2096
- "vue-treeselect__option--highlight": t.isHighlighted,
2097
- "vue-treeselect__option--matched": e.localSearch.active && t.isMatched,
2098
- "vue-treeselect__option--hide": !this.shouldShow
2099
- };
2100
- return r("div", {
2101
- class: n,
2102
- onMouseenter: this.handleMouseEnterOption,
2103
- "data-id": t.id
2104
- }, [this.renderArrow(), this.renderLabelContainer([this.renderCheckboxContainer([this.renderCheckbox()]), this.renderLabel()])]);
2105
- },
2106
- renderSubOptionsList() {
2107
- return this.shouldExpand ? r("div", {
2108
- class: "vue-treeselect__list"
2109
- }, [this.renderSubOptions(), this.renderNoChildrenTip(), this.renderLoadingChildrenTip(), this.renderLoadingChildrenErrorTip()]) : null;
2110
- },
2111
- renderArrow() {
2112
- const {
2113
- instance: e,
2114
- node: t
2115
- } = this;
2116
- if (e.shouldFlattenOptions && this.shouldShow) return null;
2117
- if (t.isBranch) {
2118
- const n = {
2119
- "vue-treeselect__option-arrow": !0,
2120
- "vue-treeselect__option-arrow--rotated": this.shouldExpand
2121
- };
2122
- return r("div", {
2123
- class: "vue-treeselect__option-arrow-container",
2124
- onMousedown: this.handleMouseDownOnArrow
2125
- }, [r("div", {
2126
- name: "vue-treeselect__option-arrow--prepare"
2127
- }, [r(He, {
2128
- class: n
2129
- }, null)])]);
2130
- }
2131
- return (
2132
- /*node.isLeaf && */
2133
- e.hasBranchNodes ? (ee || (ee = r("div", {
2134
- class: "vue-treeselect__option-arrow-placeholder"
2135
- }, [Q(" ")])), ee) : null
2136
- );
2137
- },
2138
- renderLabelContainer(e) {
2139
- return r("div", {
2140
- class: "vue-treeselect__label-container",
2141
- onMousedown: this.handleMouseDownOnLabelContainer
2142
- }, [e]);
2143
- },
2144
- renderCheckboxContainer(e) {
2145
- const {
2146
- instance: t,
2147
- node: n
2148
- } = this;
2149
- return t.single || t.disableBranchNodes && n.isBranch ? null : r("div", {
2150
- class: "vue-treeselect__checkbox-container"
2151
- }, [e]);
2152
- },
2153
- renderCheckbox() {
2154
- const {
2155
- instance: e,
2156
- node: t
2157
- } = this, n = e.forest.checkedStateMap[t.id], s = {
2158
- "vue-treeselect__checkbox": !0,
2159
- "vue-treeselect__checkbox--checked": n === Ve,
2160
- "vue-treeselect__checkbox--indeterminate": n === $e,
2161
- "vue-treeselect__checkbox--unchecked": n === oe,
2162
- "vue-treeselect__checkbox--disabled": t.isDisabled,
2163
- "vue-treeselect__checkbox--unselectable": t.isUnselectable
2164
- };
2165
- return te || (te = r("span", {
2166
- class: "vue-treeselect__check-mark"
2167
- }, null)), ne || (ne = r("span", {
2168
- class: "vue-treeselect__minus-mark"
2169
- }, null)), r("span", {
2170
- class: s
2171
- }, [te, ne]);
2172
- },
2173
- renderLabel() {
2174
- const {
2175
- instance: e,
2176
- node: t
2177
- } = this, n = t.isBranch && (e.localSearch.active ? e.showCountOnSearchComputed : e.showCount), s = n ? e.localSearch.active ? e.localSearch.countMap[t.id][e.showCountOf] : t.count[e.showCountOf] : NaN, i = "vue-treeselect__label", o = "vue-treeselect__count", a = e.$slots["option-label"];
2178
- return a ? a({
2179
- node: t,
2180
- shouldShowCount: n,
2181
- count: s,
2182
- labelClassName: i,
2183
- countClassName: o
2184
- }) : r("label", {
2185
- class: i
2186
- }, [t.label, n && r("span", {
2187
- class: o
2188
- }, [Q("("), s, Q(")")])]);
2189
- },
2190
- renderSubOptions() {
2191
- const {
2192
- node: e
2193
- } = this;
2194
- return e.childrenStates.isLoaded ? e.children.map((t) => r(H("vue-treeselect--option"), {
2195
- node: t,
2196
- key: t.id
2197
- }, null)) : null;
2198
- },
2199
- renderNoChildrenTip() {
2200
- const {
2201
- instance: e,
2202
- node: t
2203
- } = this;
2204
- return !t.childrenStates.isLoaded || t.children.length ? null : r(b, {
2205
- type: "no-children",
2206
- icon: "warning"
2207
- }, {
2208
- default: () => [e.noChildrenText]
2209
- });
2210
- },
2211
- renderLoadingChildrenTip() {
2212
- const {
2213
- instance: e,
2214
- node: t
2215
- } = this;
2216
- return t.childrenStates.isLoading ? r(b, {
2217
- type: "loading",
2218
- icon: "loader"
2219
- }, {
2220
- default: () => [e.loadingText]
2221
- }) : null;
2222
- },
2223
- renderLoadingChildrenErrorTip() {
2224
- const {
2225
- instance: e,
2226
- node: t
2227
- } = this;
2228
- return t.childrenStates.loadingError ? r(b, {
2229
- type: "error",
2230
- icon: "error"
2231
- }, {
2232
- default: () => [t.childrenStates.loadingError, r("a", {
2233
- class: "vue-treeselect__retry",
2234
- title: e.retryTitle,
2235
- onMousedown: this.handleMouseDownOnRetry
2236
- }, [e.retryText])]
2237
- }) : null;
2238
- },
2239
- handleMouseEnterOption(e) {
2240
- const {
2241
- instance: t,
2242
- node: n
2243
- } = this;
2244
- e.target === e.currentTarget && t.setCurrentHighlightedOption(n, !1);
2245
- },
2246
- handleMouseDownOnArrow: w(function() {
2247
- const {
2248
- instance: t,
2249
- node: n
2250
- } = this;
2251
- t.toggleExpanded(n);
2252
- }),
2253
- handleMouseDownOnLabelContainer: w(function() {
2254
- const {
2255
- instance: t,
2256
- node: n
2257
- } = this;
2258
- n.isBranch && (n.isUnselectable || t.disableBranchNodes) ? t.toggleExpanded(n) : t.select(n);
2259
- }),
2260
- handleMouseDownOnRetry: w(function() {
2261
- const {
2262
- instance: t,
2263
- node: n
2264
- } = this;
2265
- t.loadChildrenOptions(n);
2266
- })
2267
- },
2268
- render() {
2269
- const {
2270
- node: e
2271
- } = this, n = {
2272
- "vue-treeselect__list-item": !0,
2273
- [`vue-treeselect__indent-level-${this.instance.shouldFlattenOptions ? 0 : e.level}`]: !0
2274
- };
2275
- return r("div", {
2276
- class: n
2277
- }, [this.renderOption(), e.isBranch ? r("div", null, [this.renderSubOptionsList()]) : ""]);
2278
- }
2279
- }, ns = {
2280
- top: "top",
2281
- bottom: "bottom",
2282
- above: "top",
2283
- below: "bottom"
2284
- }, ss = {
2285
- name: "vue-treeselect--menu",
2286
- inject: ["instance"],
2287
- data() {
2288
- return {
2289
- controlResizeAndScrollEventListeners: null,
2290
- controlSizeWatcher: null,
2291
- menuSizeWatcher: null,
2292
- menuResizeAndScrollEventListeners: null
2293
- };
2294
- },
2295
- computed: {
2296
- classes() {
2297
- let e = {
2298
- "vue-treeselect__menu-container": !0
2299
- };
2300
- return this.instance.appendToBody && (e["vue-treeselect__portal-target"] = !0), e;
2301
- },
2302
- menuStyle() {
2303
- const {
2304
- instance: e
2305
- } = this;
2306
- return {
2307
- maxHeight: e.maxHeight + "px"
2308
- };
2309
- },
2310
- menuContainerStyle() {
2311
- const {
2312
- instance: e
2313
- } = this;
2314
- return {
2315
- zIndex: e.appendToBody ? null : e.zIndex
2316
- };
2317
- }
2318
- },
2319
- watch: {
2320
- "instance.menu.placement"() {
2321
- this.instance.appendToBody && this.updateMenuContainerOffset();
2322
- },
2323
- "instance.menu.isOpen": {
2324
- handler(e) {
2325
- e ? (this.$nextTick(this.onMenuOpen), this.instance.appendToBody && this.setupHandlers()) : (this.onMenuClose(), this.instance.appendToBody && this.removeHandlers());
2326
- },
2327
- immediate: !0
2328
- }
2329
- },
2330
- created() {
2331
- this.menuSizeWatcher = null, this.menuResizeAndScrollEventListeners = null;
2332
- },
2333
- mounted() {
2334
- },
2335
- unmounted() {
2336
- this.onMenuClose(), this.instance.appendToBody && this.removeHandlers();
2337
- },
2338
- methods: {
2339
- renderMenu() {
2340
- const {
2341
- instance: e
2342
- } = this;
2343
- return e.menu.isOpen ? r("div", {
2344
- ref: "menu",
2345
- class: "vue-treeselect__menu",
2346
- onMousedown: e.handleMouseDown,
2347
- style: this.menuStyle
2348
- }, [this.renderBeforeList(), e.async ? this.renderAsyncSearchMenuInner() : e.localSearch.active ? this.renderLocalSearchMenuInner() : this.renderNormalMenuInner(), this.renderAfterList()]) : null;
2349
- },
2350
- renderBeforeList() {
2351
- const {
2352
- instance: e
2353
- } = this, t = e.$slots["before-list"];
2354
- return t ? t() : null;
2355
- },
2356
- renderAfterList() {
2357
- const {
2358
- instance: e
2359
- } = this, t = e.$slots["after-list"];
2360
- return t ? t() : null;
2361
- },
2362
- renderNormalMenuInner() {
2363
- const {
2364
- instance: e
2365
- } = this;
2366
- return e.rootOptionsStates.isLoading ? this.renderLoadingOptionsTip() : e.rootOptionsStates.loadingError ? this.renderLoadingRootOptionsErrorTip() : e.rootOptionsStates.isLoaded && e.forest.normalizedOptions.length === 0 ? this.renderNoAvailableOptionsTip() : this.renderOptionList();
2367
- },
2368
- renderLocalSearchMenuInner() {
2369
- const {
2370
- instance: e
2371
- } = this;
2372
- return e.rootOptionsStates.isLoading ? this.renderLoadingOptionsTip() : e.rootOptionsStates.loadingError ? this.renderLoadingRootOptionsErrorTip() : e.rootOptionsStates.isLoaded && e.forest.normalizedOptions.length === 0 ? this.renderNoAvailableOptionsTip() : e.localSearch.noResults ? this.renderNoResultsTip() : this.renderOptionList();
2373
- },
2374
- renderAsyncSearchMenuInner() {
2375
- const {
2376
- instance: e
2377
- } = this, t = e.getRemoteSearchEntry(), n = e.trigger.searchQuery === "" && !e.defaultOptions, s = n ? !1 : t.isLoaded && t.options.length === 0;
2378
- return n ? this.renderSearchPromptTip() : t.isLoading ? this.renderLoadingOptionsTip() : t.loadingError ? this.renderAsyncSearchLoadingErrorTip() : s ? this.renderNoResultsTip() : this.renderOptionList();
2379
- },
2380
- renderOptionList() {
2381
- const {
2382
- instance: e
2383
- } = this;
2384
- return r("div", {
2385
- class: "vue-treeselect__list"
2386
- }, [e.forest.normalizedOptions.map((t) => r(ts, {
2387
- node: t,
2388
- key: t.id
2389
- }, null))]);
2390
- },
2391
- renderSearchPromptTip() {
2392
- const {
2393
- instance: e
2394
- } = this;
2395
- return r(b, {
2396
- type: "search-prompt",
2397
- icon: "warning"
2398
- }, {
2399
- default: () => [e.searchPromptText]
2400
- });
2401
- },
2402
- renderLoadingOptionsTip() {
2403
- const {
2404
- instance: e
2405
- } = this;
2406
- return r(b, {
2407
- type: "loading",
2408
- icon: "loader"
2409
- }, {
2410
- default: () => [e.loadingText]
2411
- });
2412
- },
2413
- renderLoadingRootOptionsErrorTip() {
2414
- const {
2415
- instance: e
2416
- } = this;
2417
- return r(b, {
2418
- type: "error",
2419
- icon: "error"
2420
- }, {
2421
- default: () => [e.rootOptionsStates.loadingError, r("a", {
2422
- class: "vue-treeselect__retry",
2423
- onClick: e.loadRootOptions,
2424
- title: e.retryTitle
2425
- }, [e.retryText])]
2426
- });
2427
- },
2428
- renderAsyncSearchLoadingErrorTip() {
2429
- const {
2430
- instance: e
2431
- } = this, t = e.getRemoteSearchEntry();
2432
- return r(b, {
2433
- type: "error",
2434
- icon: "error"
2435
- }, {
2436
- default: () => [t.loadingError, r("a", {
2437
- class: "vue-treeselect__retry",
2438
- onClick: e.handleRemoteSearch,
2439
- title: e.retryTitle
2440
- }, [e.retryText])]
2441
- });
2442
- },
2443
- renderNoAvailableOptionsTip() {
2444
- const {
2445
- instance: e
2446
- } = this;
2447
- return r(b, {
2448
- type: "no-options",
2449
- icon: "warning"
2450
- }, {
2451
- default: () => [e.noOptionsText]
2452
- });
2453
- },
2454
- renderNoResultsTip() {
2455
- const {
2456
- instance: e
2457
- } = this;
2458
- return r(b, {
2459
- type: "no-results",
2460
- icon: "warning"
2461
- }, {
2462
- default: () => [e.noResultsText]
2463
- });
2464
- },
2465
- onMenuOpen() {
2466
- this.adjustMenuOpenDirection(), this.setupMenuSizeWatcher(), this.setupMenuResizeAndScrollEventListeners(), this.instance.appendToBody && this.updateMenuContainerOffset();
2467
- },
2468
- onMenuClose() {
2469
- this.removeMenuSizeWatcher(), this.removeMenuResizeAndScrollEventListeners();
2470
- },
2471
- adjustMenuOpenDirection() {
2472
- const {
2473
- instance: e
2474
- } = this;
2475
- if (!e.menu.isOpen) return;
2476
- const t = e.getMenu(), n = e.getControl(), s = t.getBoundingClientRect(), i = n.getBoundingClientRect(), o = s.height, a = window.innerHeight, c = i.top, d = window.innerHeight - i.bottom, f = i.top >= 0 && i.top <= a || i.top < 0 && i.bottom > 0, m = d > o + Ee, p = c > o + Ee;
2477
- f ? e.openDirection !== "auto" ? e.menu.placement = ns[e.openDirection] : m || !p ? e.menu.placement = "bottom" : e.menu.placement = "top" : e.closeMenu();
2478
- },
2479
- setupMenuSizeWatcher() {
2480
- const {
2481
- instance: e
2482
- } = this, t = e.getMenu();
2483
- this.menuSizeWatcher || (this.menuSizeWatcher = {
2484
- remove: ge(t, this.adjustMenuOpenDirection)
2485
- });
2486
- },
2487
- setupMenuResizeAndScrollEventListeners() {
2488
- const {
2489
- instance: e
2490
- } = this, t = e.getControl();
2491
- this.menuResizeAndScrollEventListeners || (this.menuResizeAndScrollEventListeners = {
2492
- remove: me(t, this.adjustMenuOpenDirection)
2493
- });
2494
- },
2495
- removeMenuSizeWatcher() {
2496
- this.menuSizeWatcher && (this.menuSizeWatcher.remove(), this.menuSizeWatcher = null);
2497
- },
2498
- removeMenuResizeAndScrollEventListeners() {
2499
- this.menuResizeAndScrollEventListeners && (this.menuResizeAndScrollEventListeners.remove(), this.menuResizeAndScrollEventListeners = null);
2500
- },
2501
- // These functions are for appendToBody mode.
2502
- setupHandlers() {
2503
- this.updateWidth(), this.updateMenuContainerOffset(), this.setupControlResizeAndScrollEventListeners(), this.setupControlSizeWatcher();
2504
- },
2505
- removeHandlers() {
2506
- this.removeControlResizeAndScrollEventListeners(), this.removeControlSizeWatcher();
2507
- },
2508
- setupControlResizeAndScrollEventListeners() {
2509
- const {
2510
- instance: e
2511
- } = this, t = e.getControl();
2512
- this.controlResizeAndScrollEventListeners || (this.controlResizeAndScrollEventListeners = {
2513
- remove: me(t, this.updateMenuContainerOffset)
2514
- });
2515
- },
2516
- setupControlSizeWatcher() {
2517
- const {
2518
- instance: e
2519
- } = this, t = e.getControl();
2520
- this.controlSizeWatcher || (this.controlSizeWatcher = {
2521
- remove: ge(t, () => {
2522
- this.updateWidth(), this.updateMenuContainerOffset();
2523
- })
2524
- });
2525
- },
2526
- removeControlResizeAndScrollEventListeners() {
2527
- this.controlResizeAndScrollEventListeners && (this.controlResizeAndScrollEventListeners.remove(), this.controlResizeAndScrollEventListeners = null);
2528
- },
2529
- removeControlSizeWatcher() {
2530
- this.controlSizeWatcher && (this.controlSizeWatcher.remove(), this.controlSizeWatcher = null);
2531
- },
2532
- updateWidth() {
2533
- const {
2534
- instance: e
2535
- } = this, t = this.$el, s = e.getControl().getBoundingClientRect();
2536
- t && (t.style.width = s.width + "px");
2537
- },
2538
- updateMenuContainerOffset() {
2539
- const {
2540
- instance: e
2541
- } = this, t = e.getControl();
2542
- if (t) {
2543
- const n = t.getBoundingClientRect(), s = Math.round(n.left) + "px", i = Math.round(n.bottom + window.scrollY) + "px", o = this.$refs["menu-container"].style;
2544
- o.top = i, o.left = s;
2545
- }
2546
- }
2547
- },
2548
- render() {
2549
- return r("div", {
2550
- ref: "menu-container",
2551
- class: this.classes,
2552
- style: this.menuContainerStyle
2553
- }, [r("div", {
2554
- name: "vue-treeselect__menu--transition"
2555
- }, [this.renderMenu()])]);
2556
- }
2557
- }, is = Ue({
2558
- name: "vue-treeselect",
2559
- mixins: [zn],
2560
- components: {
2561
- HiddenFields: Wn,
2562
- Control: Jn,
2563
- Menu: ss
2564
- },
2565
- computed: {
2566
- wrapperClass() {
2567
- return {
2568
- "vue-treeselect": !0,
2569
- "vue-treeselect--single": this.single,
2570
- "vue-treeselect--multi": this.multiple,
2571
- "vue-treeselect--searchable": this.searchable,
2572
- "vue-treeselect--disabled": this.disabled,
2573
- "vue-treeselect--focused": this.trigger.isFocused,
2574
- "vue-treeselect--has-value": this.hasValue,
2575
- "vue-treeselect--open": this.menu.isOpen,
2576
- "vue-treeselect--open-above": this.menu.placement === "top",
2577
- "vue-treeselect--open-below": this.menu.placement === "bottom",
2578
- "vue-treeselect--branch-nodes-disabled": this.disableBranchNodes,
2579
- "vue-treeselect--append-to-body": this.appendToBody
2580
- };
2581
- }
2582
- }
2583
- });
2584
- function rs(e, t, n, s, i, o) {
2585
- const a = H("HiddenFields"), c = H("Control"), d = H("Menu");
2586
- return V(), j("div", {
2587
- ref: "wrapper",
2588
- class: se(e.wrapperClass)
2589
- }, [
2590
- r(a),
2591
- r(c, { ref: "control" }, null, 512),
2592
- (V(), Qe(Ke, {
2593
- disabled: !e.appendToBody,
2594
- to: "body"
2595
- }, [
2596
- r(d, { ref: "menu" }, null, 512)
2597
- ], 8, ["disabled"]))
2598
- ], 2);
2599
- }
2600
- const as = /* @__PURE__ */ ae(is, [["render", rs]]);
2601
- export {
2602
- as as Treeselect,
2603
- as as default
2604
- };