@night-owl-elite/vue-select 1.3.32 → 1.3.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/vue-select.css +1 -1
- package/dist/vue-select.es.js +254 -238
- package/dist/vue-select.umd.js +1 -1
- package/package.json +1 -1
package/dist/vue-select.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
@keyframes spin-89f9b7e1{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.svg-icon-spin[data-v-89f9b7e1]{animation:spin-89f9b7e1 1s linear infinite}.list-group-item[data-v-b319a2c7]{cursor:pointer;border:0;border-radius:0;padding-top:.5rem;padding-bottom:.5rem}.list-group-item.is-disabled[data-v-b319a2c7]{cursor:not-allowed;opacity:.65}.expander-icon[data-v-b319a2c7]{width:1rem;height:1rem;flex-shrink:0;transition:transform .2s ease-in-out;color:#6c757d}.expander-placeholder[data-v-b319a2c7]{display:inline-block;width:1rem;flex-shrink:0}.rotate-90[data-v-b319a2c7]{transform:rotate(90deg)}.item-content[data-v-b319a2c7]{flex-grow:1}.tree-select-main[data-v-
|
|
1
|
+
@keyframes spin-89f9b7e1{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.svg-icon-spin[data-v-89f9b7e1]{animation:spin-89f9b7e1 1s linear infinite}.list-group-item[data-v-b319a2c7]{cursor:pointer;border:0;border-radius:0;padding-top:.5rem;padding-bottom:.5rem}.list-group-item.is-disabled[data-v-b319a2c7]{cursor:not-allowed;opacity:.65}.expander-icon[data-v-b319a2c7]{width:1rem;height:1rem;flex-shrink:0;transition:transform .2s ease-in-out;color:#6c757d}.expander-placeholder[data-v-b319a2c7]{display:inline-block;width:1rem;flex-shrink:0}.rotate-90[data-v-b319a2c7]{transform:rotate(90deg)}.item-content[data-v-b319a2c7]{flex-grow:1}.tree-select-main[data-v-c318f0b9]{--bs-form-select-bg-img: none;display:block;width:100%;font-weight:400;line-height:1.5;color:var(--bs-body-color);appearance:none;background-color:var(--bs-body-bg);border:var(--bs-border-width) solid var(--bs-border-color);transition:border-color .15s ease-in-out,box-shadow .15s ease-in-out;text-align:left}.tree-select-display-container[data-v-c318f0b9]{flex:1;overflow:hidden}.transition-transform[data-v-c318f0b9]{transition:transform .2s ease-in-out}.rotate-180[data-v-c318f0b9]{transform:rotate(180deg)}.tree-select-dropdown[data-v-c318f0b9]{position:absolute;background:#fff;border:1px solid rgba(0,0,0,.15);border-radius:.375rem}.is-loading[data-v-c318f0b9]{cursor:wait}.loading-icon[data-v-c318f0b9]{animation:spin-c318f0b9 1s linear infinite}.clear-icon[data-v-c318f0b9]{cursor:pointer;opacity:.6;transition:opacity .2s ease}.clear-icon[data-v-c318f0b9]:hover{opacity:1}.tooltip-trigger-icon[data-v-c318f0b9]{cursor:pointer;opacity:.6;transition:opacity .2s ease;width:1em;height:1em}.tooltip-trigger-icon[data-v-c318f0b9]:hover{opacity:1}@keyframes spin-c318f0b9{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.btn-xl[data-v-c318f0b9]{padding:.75rem 1.5rem;font-size:1.25rem;border-radius:var(--bs-border-radius-lg)}.form-control-xl[data-v-c318f0b9]{min-height:calc(1.5em + 1.5rem + (var(--bs-border-width) * 2));padding:.75rem 1.5rem;font-size:1.25rem;border-radius:var(--bs-border-radius-lg)}.tree-select-body[data-v-c318f0b9]::-webkit-scrollbar{width:6px}.tree-select-body[data-v-c318f0b9]::-webkit-scrollbar-track{background:#f1f1f1;border-radius:3px}.tree-select-body[data-v-c318f0b9]::-webkit-scrollbar-thumb{background:#c1c1c1;border-radius:3px}.tree-select-body[data-v-c318f0b9]::-webkit-scrollbar-thumb:hover{background:#a8a8a8}.tree-select-main.disabled .more-button[data-v-c318f0b9]{pointer-events:auto;cursor:pointer}.tree-select-main.has-chips[data-v-c318f0b9]{height:auto;min-height:calc(1.5em + .5rem + calc(var(--bs-border-width) * 2))}.tree-select-main.has-chips.btn-lg[data-v-c318f0b9]{min-height:calc(1.5em + 1rem + calc(var(--bs-border-width) * 2))}.tree-select-main.has-chips.btn-xl[data-v-c318f0b9]{min-height:calc(1.5em + 1.5rem + calc(var(--bs-border-width) * 2))}.chips-container[data-v-c318f0b9]{display:flex;flex-wrap:wrap;gap:.25rem;max-height:8rem;overflow-y:auto}.chip[data-v-c318f0b9]{display:inline-flex;align-items:center;padding:.2em .6em}.chip-remove[data-v-c318f0b9]{width:.8em;height:.8em;margin-left:.4em;cursor:pointer;opacity:.7;transition:opacity .2s}.chip-remove[data-v-c318f0b9]:hover{opacity:1}.more-button[data-v-c318f0b9]{font-size:.75em;line-height:1;padding:.3em .5em}.more-popover[data-v-c318f0b9]{width:250px;max-width:80vw;max-height:200px;overflow-y:auto;font-size:.9rem}.tree-select-tooltip[data-v-c318f0b9]{background-color:var(--bs-body-bg);border:var(--bs-border-width) solid var(--bs-border-color);font-size:.875rem;max-width:400px;word-wrap:break-word;pointer-events:none}@media (max-width: 576px){.tree-select-dropdown[data-v-c318f0b9]{max-width:90vw;left:0!important;right:0!important;margin:0 auto}}
|
package/dist/vue-select.es.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { computed as
|
|
2
|
-
import { createPopper as
|
|
3
|
-
const
|
|
1
|
+
import { computed as k, createElementBlock as i, openBlock as a, normalizeClass as B, createCommentVNode as u, createElementVNode as h, resolveComponent as je, normalizeStyle as Ze, createBlock as z, withModifiers as S, renderSlot as re, Fragment as X, renderList as Y, withCtx as Ne, ref as g, watch as Be, onMounted as We, onUnmounted as Ue, withDirectives as he, withKeys as pe, toDisplayString as x, createTextVNode as Q, createVNode as ie, vModelText as Ge, vModelSelect as Je, vShow as Qe, nextTick as R } from "vue";
|
|
2
|
+
import { createPopper as ge } from "@popperjs/core";
|
|
3
|
+
const ye = (t, P) => {
|
|
4
4
|
const l = t.__vccOpts || t;
|
|
5
|
-
for (const [m, d] of
|
|
5
|
+
for (const [m, d] of P)
|
|
6
6
|
l[m] = d;
|
|
7
7
|
return l;
|
|
8
|
-
},
|
|
8
|
+
}, Xe = { key: 0 }, Ye = { key: 1 }, _e = { key: 2 }, et = { key: 3 }, tt = { key: 4 }, lt = { key: 5 }, nt = { key: 6 }, st = { key: 7 }, at = {
|
|
9
9
|
__name: "SvgIcon",
|
|
10
10
|
props: {
|
|
11
11
|
name: {
|
|
@@ -14,8 +14,8 @@ const pe = (t, D) => {
|
|
|
14
14
|
}
|
|
15
15
|
},
|
|
16
16
|
setup(t) {
|
|
17
|
-
const
|
|
18
|
-
"svg-icon-spin":
|
|
17
|
+
const P = t, l = k(() => ({
|
|
18
|
+
"svg-icon-spin": P.name === "spinner"
|
|
19
19
|
}));
|
|
20
20
|
return (m, d) => (a(), i("svg", {
|
|
21
21
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -23,47 +23,47 @@ const pe = (t, D) => {
|
|
|
23
23
|
fill: "currentColor",
|
|
24
24
|
width: "1em",
|
|
25
25
|
height: "1em",
|
|
26
|
-
class:
|
|
26
|
+
class: B(l.value)
|
|
27
27
|
}, [
|
|
28
|
-
t.name === "spinner" ? (a(), i("g",
|
|
28
|
+
t.name === "spinner" ? (a(), i("g", Xe, d[0] || (d[0] = [
|
|
29
29
|
h("path", { d: "M12,4V2A10,10,0,0,0,2,12H4A8,8,0,0,1,12,4Z" }, null, -1)
|
|
30
30
|
]))) : u("", !0),
|
|
31
|
-
t.name === "times" ? (a(), i("g",
|
|
31
|
+
t.name === "times" ? (a(), i("g", Ye, d[1] || (d[1] = [
|
|
32
32
|
h("path", { d: "M13.41,12l4.3-4.29a1,1,0,1,0-1.42-1.42L12,10.59,7.71,6.29A1,1,0,0,0,6.29,7.71L10.59,12l-4.3,4.29a1,1,0,0,0,0,1.42,1,1,0,0,0,1.42,0L12,13.41l4.29,4.3a1,1,0,0,0,1.42,0,1,1,0,0,0,0-1.42Z" }, null, -1)
|
|
33
33
|
]))) : u("", !0),
|
|
34
|
-
t.name === "chevron-down" ? (a(), i("g",
|
|
34
|
+
t.name === "chevron-down" ? (a(), i("g", _e, d[2] || (d[2] = [
|
|
35
35
|
h("path", { d: "M17,9.17a1,1,0,0,0-1.41,0L12,12.71,8.46,9.17a1,1,0,0,0-1.41,0,1,1,0,0,0,0,1.42l4.24,4.24a1,1,0,0,0,1.42,0L17,10.59A1,1,0,0,0,17,9.17Z" }, null, -1)
|
|
36
36
|
]))) : u("", !0),
|
|
37
|
-
t.name === "chevron-right" ? (a(), i("g",
|
|
37
|
+
t.name === "chevron-right" ? (a(), i("g", et, d[3] || (d[3] = [
|
|
38
38
|
h("path", { d: "M10.83,12l-4.24,4.24a1,1,0,0,0,1.41,1.41L13.66,12,8,6.34A1,1,0,0,0,6.59,7.76Z" }, null, -1)
|
|
39
39
|
]))) : u("", !0),
|
|
40
|
-
t.name === "search" ? (a(), i("g",
|
|
40
|
+
t.name === "search" ? (a(), i("g", tt, d[4] || (d[4] = [
|
|
41
41
|
h("path", { d: "M21.71,20.29,18,16.61A9,9,0,1,0,16.61,18l3.68,3.68a1,1,0,0,0,1.42,0A1,1,0,0,0,21.71,20.29ZM11,18a7,7,0,1,1,7-7A7,7,0,0,1,11,18Z" }, null, -1)
|
|
42
42
|
]))) : u("", !0),
|
|
43
|
-
t.name === "asc" ? (a(), i("g",
|
|
43
|
+
t.name === "asc" ? (a(), i("g", lt, d[5] || (d[5] = [
|
|
44
44
|
h("path", {
|
|
45
45
|
fill: "currentColor",
|
|
46
46
|
d: "M4.869 11H2.667L6 3h2l3.333 8H9.131l-.41-1H5.28zm1.23-3h1.803L7 5.8zm12.9 8V3h-2v13h-3l4 5l4-5zm-8-3H3v2h4.855L3 19v2h8v-2H6.146L11 15z"
|
|
47
47
|
}, null, -1)
|
|
48
48
|
]))) : u("", !0),
|
|
49
|
-
t.name === "desc" ? (a(), i("g",
|
|
49
|
+
t.name === "desc" ? (a(), i("g", nt, d[6] || (d[6] = [
|
|
50
50
|
h("path", {
|
|
51
51
|
fill: "currentColor",
|
|
52
52
|
d: "M4.869 11H2.667L6 3h2l3.333 8H9.131l-.41-1H5.28zm1.23-3h1.803L7 5.8zm15.9 0l-4-5l-4 5h3v13h2V8zm-11 5H3v2h4.855L3 19v2h8v-2H6.146L11 15z"
|
|
53
53
|
}, null, -1)
|
|
54
54
|
]))) : u("", !0),
|
|
55
|
-
t.name === "info-circle" ? (a(), i("g",
|
|
55
|
+
t.name === "info-circle" ? (a(), i("g", st, d[7] || (d[7] = [
|
|
56
56
|
h("path", { d: "M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-6h2v6zm0-8h-2V7h2v2z" }, null, -1)
|
|
57
57
|
]))) : u("", !0)
|
|
58
58
|
], 2));
|
|
59
59
|
}
|
|
60
|
-
}, A = /* @__PURE__ */
|
|
60
|
+
}, A = /* @__PURE__ */ ye(at, [["__scopeId", "data-v-89f9b7e1"]]), ot = { class: "tree-select-item-wrapper" }, it = {
|
|
61
61
|
key: 1,
|
|
62
62
|
class: "expander-placeholder"
|
|
63
|
-
},
|
|
63
|
+
}, rt = ["checked", ".indeterminate", "disabled"], dt = { class: "item-content" }, ut = {
|
|
64
64
|
key: 0,
|
|
65
65
|
class: "children-wrapper"
|
|
66
|
-
},
|
|
66
|
+
}, ct = {
|
|
67
67
|
__name: "TreeSelectItem",
|
|
68
68
|
props: {
|
|
69
69
|
item: { type: Object, required: !0 },
|
|
@@ -79,48 +79,48 @@ const pe = (t, D) => {
|
|
|
79
79
|
disableBranchNode: { type: Boolean, default: !1 }
|
|
80
80
|
},
|
|
81
81
|
emits: ["select", "toggle-expand"],
|
|
82
|
-
setup(t, { emit:
|
|
83
|
-
const l = t, m = (c) => c[l.optionValue] || c.id || c.value, d = (c) => !l.disabledKey || !c ? !1 : c.hasOwnProperty(l.disabledKey) && c[l.disabledKey] !== null, C =
|
|
82
|
+
setup(t, { emit: P }) {
|
|
83
|
+
const l = t, m = (c) => c[l.optionValue] || c.id || c.value, d = (c) => !l.disabledKey || !c ? !1 : c.hasOwnProperty(l.disabledKey) && c[l.disabledKey] !== null, C = k(() => l.item.children && l.item.children.length > 0), N = k(() => l.expandedItems.has(m(l.item))), y = k(() => l.selectedItems.includes(m(l.item))), $ = (c) => {
|
|
84
84
|
let p = [];
|
|
85
85
|
return c.children && c.children.forEach((M) => {
|
|
86
86
|
p.push(m(M)), p.push(...$(M));
|
|
87
87
|
}), p;
|
|
88
|
-
},
|
|
88
|
+
}, K = k(() => !l.multiple || !l.selectAll || !C.value || y.value ? !1 : $(l.item).some((p) => l.selectedItems.includes(p)));
|
|
89
89
|
return (c, p) => {
|
|
90
|
-
const M =
|
|
91
|
-
return a(), i("div",
|
|
90
|
+
const M = je("TreeSelectItem", !0);
|
|
91
|
+
return a(), i("div", ot, [
|
|
92
92
|
h("div", {
|
|
93
|
-
class:
|
|
94
|
-
"bg-primary text-white":
|
|
93
|
+
class: B(["list-group-item list-group-item-action d-flex align-items-center gap-2", {
|
|
94
|
+
"bg-primary text-white": y.value && (t.selectMode === "highlight" || !t.multiple) && !d(t.item) && !(t.disableBranchNode && C.value),
|
|
95
95
|
"is-disabled text-muted bg-light": d(t.item)
|
|
96
96
|
}]),
|
|
97
|
-
style:
|
|
97
|
+
style: Ze({ "padding-left": `${t.level * 1.5 + 1}rem` }),
|
|
98
98
|
onClick: p[2] || (p[2] = (w) => d(t.item) ? null : c.$emit("select", t.item))
|
|
99
99
|
}, [
|
|
100
|
-
C.value ? (a(),
|
|
100
|
+
C.value ? (a(), z(A, {
|
|
101
101
|
key: 0,
|
|
102
102
|
name: "chevron-right",
|
|
103
|
-
class:
|
|
103
|
+
class: B(["expander-icon", { "rotate-90": N.value }]),
|
|
104
104
|
onClick: p[0] || (p[0] = S((w) => c.$emit("toggle-expand", m(t.item)), ["stop"]))
|
|
105
|
-
}, null, 8, ["class"])) : (a(), i("span",
|
|
105
|
+
}, null, 8, ["class"])) : (a(), i("span", it)),
|
|
106
106
|
t.multiple && t.selectMode === "checkbox" && !(t.disableBranchNode && C.value) ? (a(), i("input", {
|
|
107
107
|
key: 2,
|
|
108
108
|
type: "checkbox",
|
|
109
109
|
class: "form-check-input",
|
|
110
|
-
checked:
|
|
111
|
-
".indeterminate":
|
|
110
|
+
checked: y.value,
|
|
111
|
+
".indeterminate": K.value,
|
|
112
112
|
disabled: d(t.item),
|
|
113
113
|
onClick: p[1] || (p[1] = S((w) => c.$emit("select", t.item), ["stop"]))
|
|
114
|
-
}, null, 40,
|
|
115
|
-
h("div",
|
|
116
|
-
|
|
114
|
+
}, null, 40, rt)) : u("", !0),
|
|
115
|
+
h("div", dt, [
|
|
116
|
+
re(c.$slots, "default", {
|
|
117
117
|
item: t.item,
|
|
118
118
|
level: t.level
|
|
119
119
|
}, void 0, !0)
|
|
120
120
|
])
|
|
121
121
|
], 6),
|
|
122
|
-
C.value &&
|
|
123
|
-
(a(!0), i(
|
|
122
|
+
C.value && N.value ? (a(), i("div", ut, [
|
|
123
|
+
(a(!0), i(X, null, Y(t.item.children, (w) => (a(), z(M, {
|
|
124
124
|
key: m(w),
|
|
125
125
|
item: w,
|
|
126
126
|
level: t.level + 1,
|
|
@@ -136,10 +136,10 @@ const pe = (t, D) => {
|
|
|
136
136
|
onSelect: p[3] || (p[3] = (I) => c.$emit("select", I)),
|
|
137
137
|
onToggleExpand: p[4] || (p[4] = (I) => c.$emit("toggle-expand", I))
|
|
138
138
|
}, {
|
|
139
|
-
default:
|
|
140
|
-
|
|
139
|
+
default: Ne(({ item: I, level: _ }) => [
|
|
140
|
+
re(c.$slots, "default", {
|
|
141
141
|
item: I,
|
|
142
|
-
level:
|
|
142
|
+
level: _
|
|
143
143
|
}, void 0, !0)
|
|
144
144
|
]),
|
|
145
145
|
_: 2
|
|
@@ -148,35 +148,35 @@ const pe = (t, D) => {
|
|
|
148
148
|
]);
|
|
149
149
|
};
|
|
150
150
|
}
|
|
151
|
-
},
|
|
151
|
+
}, ft = /* @__PURE__ */ ye(ct, [["__scopeId", "data-v-b319a2c7"]]), mt = ["onKeydown"], vt = { class: "tree-select-display-container" }, ht = {
|
|
152
152
|
key: 0,
|
|
153
153
|
class: "d-flex align-items-center justify-content-start w-100"
|
|
154
|
-
},
|
|
154
|
+
}, pt = ["title"], gt = { key: 1 }, yt = {
|
|
155
155
|
key: 0,
|
|
156
156
|
class: "text-muted"
|
|
157
|
-
},
|
|
157
|
+
}, bt = {
|
|
158
158
|
key: 1,
|
|
159
159
|
class: "chips-container"
|
|
160
|
-
},
|
|
160
|
+
}, kt = { class: "d-flex align-items-center gap-2" }, wt = { class: "list-group list-group-flush" }, xt = { class: "text-wrap text-start me-2" }, St = { class: "p-2 border-bottom d-flex flex-column gap-2" }, Ct = ["onKeydown"], Vt = {
|
|
161
161
|
key: 1,
|
|
162
162
|
class: "d-flex align-items-center gap-2"
|
|
163
|
-
},
|
|
163
|
+
}, Lt = ["value"], It = ["disabled"], At = {
|
|
164
164
|
key: 0,
|
|
165
165
|
class: "p-4 text-muted text-center"
|
|
166
|
-
},
|
|
166
|
+
}, $t = {
|
|
167
167
|
key: 1,
|
|
168
168
|
class: "tree-select-body",
|
|
169
169
|
style: { "max-height": "300px", "overflow-y": "auto" }
|
|
170
|
-
},
|
|
170
|
+
}, Mt = {
|
|
171
171
|
key: 0,
|
|
172
172
|
class: "list-group list-group-flush"
|
|
173
|
-
},
|
|
173
|
+
}, Bt = {
|
|
174
174
|
class: "d-flex align-items-center gap-2",
|
|
175
175
|
style: { "white-space": "wrap" }
|
|
176
|
-
},
|
|
176
|
+
}, Nt = {
|
|
177
177
|
key: 1,
|
|
178
178
|
class: "p-3 text-muted text-center"
|
|
179
|
-
},
|
|
179
|
+
}, Tt = { key: 0 }, zt = { key: 0 }, Kt = { key: 1 }, Et = { key: 0 }, Dt = { key: 1 }, Pt = {
|
|
180
180
|
__name: "TreeSelectMain",
|
|
181
181
|
props: {
|
|
182
182
|
modelValue: {
|
|
@@ -303,30 +303,38 @@ const pe = (t, D) => {
|
|
|
303
303
|
}
|
|
304
304
|
},
|
|
305
305
|
emits: ["update:modelValue", "change", "clear", "deselect", "select", "focus", "blur", "add-new"],
|
|
306
|
-
setup(t, { emit:
|
|
307
|
-
const l = t, m =
|
|
308
|
-
const s =
|
|
306
|
+
setup(t, { emit: P }) {
|
|
307
|
+
const l = t, m = P, d = g(null), C = g(null), N = g(null), y = g(""), $ = g(!1), K = g(/* @__PURE__ */ new Set()), c = g(null), p = g(null), M = g(null), w = g(!1), I = g(null), _ = g(null), q = g(!1), E = g(l.defaultSortKey), H = g(l.defaultSortDirection), F = g(null), ee = g(null), j = g(!1), te = g(null), be = k(() => l.size === "sm" ? "btn-sm" : l.size === "lg" ? "btn-lg" : l.size === "xl" ? "btn-xl" : ""), ke = k(() => l.size === "sm" ? "form-control-sm" : l.size === "lg" ? "form-control-lg" : l.size === "xl" ? "form-control-xl" : ""), Te = k(() => se.value === 0 ? [] : ne.value.slice(l.maxVisibleChipsDisplay)), Z = k(() => !l.multiple || !l.excludeFromSelectedListKey ? T.value : T.value.filter((e) => {
|
|
308
|
+
const s = W(e);
|
|
309
309
|
return !s || !s[l.excludeFromSelectedListKey];
|
|
310
|
-
})),
|
|
311
|
-
const e =
|
|
310
|
+
})), we = k(() => {
|
|
311
|
+
const e = Z.value;
|
|
312
312
|
if (e.length === 0) return l.placeholder;
|
|
313
313
|
if (l.multiple) {
|
|
314
314
|
if (e.length === 1) {
|
|
315
|
-
const n =
|
|
315
|
+
const n = U(e[0]);
|
|
316
316
|
return n ? n.join(" → ") : e[0];
|
|
317
317
|
}
|
|
318
318
|
return `${e.length} items selected`;
|
|
319
319
|
}
|
|
320
|
-
const s =
|
|
320
|
+
const s = U(e[0]);
|
|
321
321
|
return s ? s.join(" → ") : e[0];
|
|
322
|
-
}),
|
|
322
|
+
}), xe = async () => {
|
|
323
|
+
await R();
|
|
324
|
+
const e = _.value;
|
|
325
|
+
if (l.multiple || l.displayMode === "chips" || Z.value.length === 0 || !e) {
|
|
326
|
+
q.value = !1;
|
|
327
|
+
return;
|
|
328
|
+
}
|
|
329
|
+
q.value = e.scrollWidth > e.clientWidth;
|
|
330
|
+
}, O = (e) => e && (e[l.optionLabel] || e.label || e.name) || "", b = (e) => e ? e[l.optionValue] || e.id || e.value : null, de = (e) => !l.disabledKey || !e ? !1 : e.hasOwnProperty(l.disabledKey) && e[l.disabledKey] !== null, V = (e) => e.children && e.children.length > 0, le = (e, s) => {
|
|
323
331
|
if (s)
|
|
324
332
|
return s.split(".").reduce((n, o) => n && n[o], e);
|
|
325
|
-
},
|
|
333
|
+
}, W = (e, s = l.items) => {
|
|
326
334
|
for (const n of s) {
|
|
327
|
-
if (
|
|
335
|
+
if (b(n) === e) return n;
|
|
328
336
|
if (V(n)) {
|
|
329
|
-
const o =
|
|
337
|
+
const o = W(e, n.children);
|
|
330
338
|
if (o) return o;
|
|
331
339
|
}
|
|
332
340
|
}
|
|
@@ -334,96 +342,96 @@ const pe = (t, D) => {
|
|
|
334
342
|
}, ue = (e) => {
|
|
335
343
|
const s = [];
|
|
336
344
|
return V(e) && e.children.forEach((n) => {
|
|
337
|
-
de(n) || (s.push(
|
|
345
|
+
de(n) || (s.push(b(n)), s.push(...ue(n)));
|
|
338
346
|
}), s;
|
|
339
347
|
}, ce = (e, s = l.items, n = []) => {
|
|
340
348
|
for (const o of s) {
|
|
341
|
-
if (
|
|
349
|
+
if (b(o) === e) return n;
|
|
342
350
|
if (V(o)) {
|
|
343
|
-
const r = ce(e, o.children, [...n,
|
|
351
|
+
const r = ce(e, o.children, [...n, b(o)]);
|
|
344
352
|
if (r) return r;
|
|
345
353
|
}
|
|
346
354
|
}
|
|
347
355
|
return null;
|
|
348
|
-
}, T =
|
|
356
|
+
}, T = k(() => {
|
|
349
357
|
const e = new Set(Array.isArray(l.modelValue) ? l.modelValue : [l.modelValue].filter(Boolean));
|
|
350
358
|
if (l.multiple && l.selectAll) {
|
|
351
359
|
const s = (n) => {
|
|
352
360
|
n.forEach((o) => {
|
|
353
361
|
if (V(o)) {
|
|
354
362
|
const r = o.children.filter((v) => !de(v));
|
|
355
|
-
r.length > 0 && r.every((v) => e.has(
|
|
363
|
+
r.length > 0 && r.every((v) => e.has(b(v))) && e.add(b(o)), s(o.children);
|
|
356
364
|
}
|
|
357
365
|
});
|
|
358
366
|
};
|
|
359
367
|
s(l.items);
|
|
360
368
|
}
|
|
361
369
|
return Array.from(e);
|
|
362
|
-
}),
|
|
370
|
+
}), U = (e, s = l.items, n = []) => {
|
|
363
371
|
for (const o of s) {
|
|
364
372
|
const r = [...n, O(o)];
|
|
365
|
-
if (
|
|
373
|
+
if (b(o) === e) return r;
|
|
366
374
|
if (V(o)) {
|
|
367
|
-
const f =
|
|
375
|
+
const f = U(e, o.children, r);
|
|
368
376
|
if (f) return f;
|
|
369
377
|
}
|
|
370
378
|
}
|
|
371
379
|
return null;
|
|
372
|
-
},
|
|
380
|
+
}, Se = (e) => {
|
|
373
381
|
if (!e || e.length === 0) return "";
|
|
374
382
|
const s = e.join(" → ");
|
|
375
383
|
return s.length <= 40 ? s : e.length > 2 ? `${e[0]} → ... → ${e[e.length - 1]}` : s;
|
|
376
|
-
},
|
|
377
|
-
const e =
|
|
384
|
+
}, fe = k(() => {
|
|
385
|
+
const e = Z.value;
|
|
378
386
|
if (e.length === 0) return l.placeholder;
|
|
379
387
|
if (l.multiple) {
|
|
380
388
|
if (e.length === 1) {
|
|
381
|
-
const n =
|
|
382
|
-
return n ?
|
|
389
|
+
const n = U(e[0]);
|
|
390
|
+
return n ? Se(n) : e[0];
|
|
383
391
|
}
|
|
384
392
|
return `${e.length} items selected`;
|
|
385
393
|
}
|
|
386
|
-
const s =
|
|
387
|
-
return s ?
|
|
388
|
-
}),
|
|
389
|
-
if (!l.multiple ||
|
|
390
|
-
const e =
|
|
391
|
-
if (!l.sortable || !
|
|
394
|
+
const s = U(e[0]);
|
|
395
|
+
return s ? Se(s) : e[0];
|
|
396
|
+
}), ne = k(() => {
|
|
397
|
+
if (!l.multiple || Z.value.length === 0) return [];
|
|
398
|
+
const e = Z.value.map((o) => W(o)).filter(Boolean);
|
|
399
|
+
if (!l.sortable || !E.value)
|
|
392
400
|
return e;
|
|
393
|
-
const s =
|
|
401
|
+
const s = E.value, n = H.value;
|
|
394
402
|
return [...e].sort((o, r) => {
|
|
395
|
-
const f =
|
|
403
|
+
const f = le(o, s), v = le(r, s);
|
|
396
404
|
if (f == null) return 1;
|
|
397
405
|
if (v == null) return -1;
|
|
398
406
|
let L = 0;
|
|
399
407
|
return typeof f == "string" && typeof v == "string" ? L = f.localeCompare(v) : f > v ? L = 1 : f < v && (L = -1), n === "desc" ? L * -1 : L;
|
|
400
408
|
});
|
|
401
|
-
}),
|
|
402
|
-
const e =
|
|
409
|
+
}), Ce = k(() => ne.value.slice(0, l.maxVisibleChipsDisplay)), se = k(() => {
|
|
410
|
+
const e = ne.value.length - l.maxVisibleChipsDisplay;
|
|
403
411
|
return e > 0 ? e : 0;
|
|
404
|
-
}),
|
|
412
|
+
}), Ve = (e, s) => e.map((n) => {
|
|
405
413
|
const o = O(n).toLowerCase().includes(s);
|
|
406
414
|
if (!V(n))
|
|
407
415
|
return o ? n : null;
|
|
408
|
-
const r =
|
|
416
|
+
const r = Ve(n.children, s);
|
|
409
417
|
return o ? { ...n, children: n.children } : r.length > 0 ? { ...n, children: r } : null;
|
|
410
|
-
}).filter(Boolean),
|
|
411
|
-
const v =
|
|
418
|
+
}).filter(Boolean), Le = (e, s, n) => !e || !s ? e : [...e].sort((r, f) => {
|
|
419
|
+
const v = le(r, s), L = le(f, s);
|
|
412
420
|
if (v == null) return 1;
|
|
413
421
|
if (L == null) return -1;
|
|
414
|
-
let
|
|
415
|
-
return typeof v == "string" && typeof L == "string" ?
|
|
416
|
-
}).map((r) => V(r) ? { ...r, children:
|
|
417
|
-
const e =
|
|
418
|
-
return !l.sortable || !
|
|
419
|
-
}),
|
|
422
|
+
let J = 0;
|
|
423
|
+
return typeof v == "string" && typeof L == "string" ? J = v.localeCompare(L) : v > L ? J = 1 : v < L && (J = -1), n === "desc" ? J * -1 : J;
|
|
424
|
+
}).map((r) => V(r) ? { ...r, children: Le(r.children, s, n) } : r), ae = k(() => {
|
|
425
|
+
const e = y.value.trim() ? Ve(l.items, y.value.toLowerCase()) : l.items;
|
|
426
|
+
return !l.sortable || !E.value ? e : Le(e, E.value, H.value);
|
|
427
|
+
}), ze = (e) => {
|
|
420
428
|
if (l.disableBranchNodes && V(e)) {
|
|
421
|
-
const r =
|
|
422
|
-
|
|
429
|
+
const r = b(e);
|
|
430
|
+
Ie(r);
|
|
423
431
|
return;
|
|
424
432
|
}
|
|
425
433
|
if (de(e)) return;
|
|
426
|
-
const s =
|
|
434
|
+
const s = b(e);
|
|
427
435
|
let n = new Set(T.value);
|
|
428
436
|
if (l.multiple) {
|
|
429
437
|
const r = n.has(s);
|
|
@@ -433,37 +441,37 @@ const pe = (t, D) => {
|
|
|
433
441
|
} else
|
|
434
442
|
r ? (n.delete(s), l.selectAll && ce(s)?.forEach((v) => n.delete(v))) : n.add(s);
|
|
435
443
|
} else {
|
|
436
|
-
const r = l.modelValue, f =
|
|
437
|
-
r === f ? (n.clear(), m("deselect", e)) : (n.clear(), n.add(f), r != null &&
|
|
438
|
-
|
|
444
|
+
const r = l.modelValue, f = b(e);
|
|
445
|
+
r === f ? (n.clear(), m("deselect", e)) : (n.clear(), n.add(f), r != null && W(r), m("select", e)), l.closeOnSelect && D(), R(() => {
|
|
446
|
+
N.value?.focus();
|
|
439
447
|
});
|
|
440
448
|
}
|
|
441
449
|
let o = Array.from(n);
|
|
442
450
|
l.multiple && l.excludeFromSelectedListKey && (o = o.filter((r) => {
|
|
443
|
-
const f =
|
|
451
|
+
const f = W(r);
|
|
444
452
|
return !f || !f[l.excludeFromSelectedListKey];
|
|
445
453
|
})), m("update:modelValue", l.multiple ? o : o[0] || null), m("change", l.multiple ? o : o[0] || null);
|
|
446
|
-
},
|
|
454
|
+
}, me = (e) => {
|
|
447
455
|
if (l.disabled || !e) return;
|
|
448
|
-
const s =
|
|
456
|
+
const s = b(e), n = new Set(T.value);
|
|
449
457
|
n.delete(s), l.selectAll && (l.deselectAll && V(e) && ue(e).forEach((v) => n.delete(v)), ce(s)?.forEach((f) => n.delete(f)));
|
|
450
458
|
const o = Array.from(n);
|
|
451
459
|
m("update:modelValue", o), m("change", o);
|
|
452
|
-
},
|
|
453
|
-
|
|
454
|
-
},
|
|
455
|
-
|
|
456
|
-
},
|
|
460
|
+
}, Ie = (e) => {
|
|
461
|
+
K.value.has(e) ? K.value.delete(e) : K.value.add(e);
|
|
462
|
+
}, Ke = () => {
|
|
463
|
+
H.value = H.value === "asc" ? "desc" : "asc";
|
|
464
|
+
}, Ee = () => {
|
|
457
465
|
const e = l.multiple ? [] : null;
|
|
458
|
-
m("clear"), m("update:modelValue", e), m("change", e),
|
|
459
|
-
},
|
|
460
|
-
!l.allowAddNew || !
|
|
461
|
-
},
|
|
462
|
-
l.allowAddNew && l.addNewMode === "enter" &&
|
|
463
|
-
},
|
|
466
|
+
m("clear"), m("update:modelValue", e), m("change", e), G();
|
|
467
|
+
}, Ae = () => {
|
|
468
|
+
!l.allowAddNew || !y.value.trim() || (m("add-new", y.value.trim()), D());
|
|
469
|
+
}, De = () => {
|
|
470
|
+
l.allowAddNew && l.addNewMode === "enter" && y.value.trim() && ae.value.length === 0 && Ae();
|
|
471
|
+
}, Pe = (e) => {
|
|
464
472
|
m("focus", e);
|
|
465
|
-
},
|
|
466
|
-
l.disabled || (
|
|
473
|
+
}, Oe = async () => {
|
|
474
|
+
l.disabled || (G(), $.value = !0, oe(), await R(), C.value && N.value && (c.value = ge(N.value, C.value, {
|
|
467
475
|
placement: "bottom-start",
|
|
468
476
|
strategy: "fixed",
|
|
469
477
|
modifiers: [
|
|
@@ -483,57 +491,62 @@ const pe = (t, D) => {
|
|
|
483
491
|
}
|
|
484
492
|
}
|
|
485
493
|
]
|
|
486
|
-
})), l.searchable && (await
|
|
487
|
-
},
|
|
488
|
-
$.value = !1,
|
|
489
|
-
},
|
|
490
|
-
|
|
494
|
+
})), l.searchable && (await R(), C.value?.querySelector(".tree-search-input")?.focus()));
|
|
495
|
+
}, D = () => {
|
|
496
|
+
$.value = !1, y.value = "", c.value?.destroy(), c.value = null, m("blur", l.modelValue);
|
|
497
|
+
}, ve = () => $.value ? D() : Oe(), Re = async () => {
|
|
498
|
+
D(), oe(), j.value = !0, await R(), ee.value && F.value && (te.value = ge(F.value, ee.value, {
|
|
491
499
|
placement: "bottom-end",
|
|
492
500
|
strategy: "fixed",
|
|
493
501
|
modifiers: [{ name: "offset", options: { offset: [0, 4] } }]
|
|
494
502
|
}));
|
|
495
|
-
},
|
|
496
|
-
|
|
497
|
-
},
|
|
498
|
-
$.value && !
|
|
499
|
-
},
|
|
500
|
-
d.value?.contains(e.relatedTarget) ||
|
|
501
|
-
},
|
|
502
|
-
!
|
|
503
|
+
}, G = () => {
|
|
504
|
+
j.value = !1, te.value?.destroy(), te.value = null;
|
|
505
|
+
}, $e = () => j.value ? G() : Re(), Me = (e) => {
|
|
506
|
+
$.value && !N.value?.contains(e.target) && !C.value?.contains(e.target) && D(), j.value && !F.value?.contains(e.target) && !ee.value?.contains(e.target) && G(), w.value && !I.value?.$el?.contains(e.target) && !p.value?.contains(e.target) && oe();
|
|
507
|
+
}, qe = (e) => {
|
|
508
|
+
d.value?.contains(e.relatedTarget) || D();
|
|
509
|
+
}, He = async () => {
|
|
510
|
+
!q.value || w.value || (D(), G(), w.value = !0, await R(), p.value && I.value && (M.value = ge(I.value.$el, p.value, {
|
|
511
|
+
// ⬅️ 5b. USE $el
|
|
503
512
|
placement: "top",
|
|
504
513
|
strategy: "fixed",
|
|
505
514
|
modifiers: [{ name: "offset", options: { offset: [0, 8] } }]
|
|
506
515
|
})));
|
|
507
|
-
},
|
|
508
|
-
w.value ?
|
|
509
|
-
},
|
|
516
|
+
}, Fe = () => {
|
|
517
|
+
w.value ? oe() : He();
|
|
518
|
+
}, oe = () => {
|
|
510
519
|
w.value = !1, M.value?.destroy(), M.value = null;
|
|
511
520
|
};
|
|
512
|
-
return
|
|
513
|
-
document.removeEventListener("click", Ie), c.value?.destroy(), _.value?.destroy(), M.value?.destroy();
|
|
514
|
-
}), Ze(g, (e) => {
|
|
521
|
+
return Be(y, (e) => {
|
|
515
522
|
if (e.trim()) {
|
|
516
523
|
const s = (n) => {
|
|
517
524
|
n.forEach((o) => {
|
|
518
|
-
V(o) && (
|
|
525
|
+
V(o) && (K.value.add(b(o)), s(o.children));
|
|
519
526
|
});
|
|
520
527
|
};
|
|
521
|
-
s(
|
|
528
|
+
s(ae.value);
|
|
522
529
|
}
|
|
530
|
+
}), Be(fe, () => {
|
|
531
|
+
xe();
|
|
532
|
+
}), We(() => {
|
|
533
|
+
document.addEventListener("click", Me), xe();
|
|
534
|
+
}), Ue(() => {
|
|
535
|
+
document.removeEventListener("click", Me), c.value?.destroy(), te.value?.destroy(), M.value?.destroy();
|
|
523
536
|
}), (e, s) => (a(), i("div", {
|
|
524
537
|
ref_key: "wrapperRef",
|
|
525
538
|
ref: d,
|
|
526
539
|
class: "tree-select-wrapper",
|
|
527
|
-
onFocusin:
|
|
528
|
-
onFocusout:
|
|
540
|
+
onFocusin: Pe,
|
|
541
|
+
onFocusout: qe
|
|
529
542
|
}, [
|
|
530
543
|
h("div", {
|
|
531
544
|
ref_key: "triggerRef",
|
|
532
|
-
ref:
|
|
545
|
+
ref: N,
|
|
533
546
|
role: "button",
|
|
534
547
|
tabindex: "0",
|
|
535
|
-
class:
|
|
536
|
-
|
|
548
|
+
class: B(["btn tree-select-trigger w-100 d-flex justify-content-between align-items-center tree-select-main", [
|
|
549
|
+
be.value,
|
|
537
550
|
{
|
|
538
551
|
"btn-outline-secondary": !t.isInvalid,
|
|
539
552
|
"border-danger": t.isInvalid,
|
|
@@ -542,101 +555,103 @@ const pe = (t, D) => {
|
|
|
542
555
|
"has-chips": t.multiple && t.displayMode === "chips" && T.value.length > 0
|
|
543
556
|
}
|
|
544
557
|
]]),
|
|
545
|
-
onClick:
|
|
558
|
+
onClick: ve,
|
|
546
559
|
onKeydown: [
|
|
547
|
-
|
|
548
|
-
|
|
560
|
+
pe(S(ve, ["prevent"]), ["enter"]),
|
|
561
|
+
pe(S(ve, ["prevent"]), ["space"])
|
|
549
562
|
]
|
|
550
563
|
}, [
|
|
551
|
-
h("div",
|
|
552
|
-
|
|
553
|
-
selectedItems:
|
|
554
|
-
displayText:
|
|
564
|
+
h("div", vt, [
|
|
565
|
+
re(e.$slots, "display", {
|
|
566
|
+
selectedItems: ne.value,
|
|
567
|
+
displayText: fe.value,
|
|
555
568
|
placeholder: t.placeholder,
|
|
556
569
|
isLoading: t.isLoading,
|
|
557
|
-
removeItem:
|
|
570
|
+
removeItem: me,
|
|
558
571
|
getItemLabel: O,
|
|
559
|
-
getItemValue:
|
|
560
|
-
visibleChips:
|
|
561
|
-
hiddenChipsCount:
|
|
562
|
-
toggleMorePopover:
|
|
563
|
-
moreTriggerRef:
|
|
572
|
+
getItemValue: b,
|
|
573
|
+
visibleChips: Ce.value,
|
|
574
|
+
hiddenChipsCount: se.value,
|
|
575
|
+
toggleMorePopover: $e,
|
|
576
|
+
moreTriggerRef: F.value
|
|
564
577
|
}, () => [
|
|
565
|
-
!t.multiple || t.displayMode === "text" ? (a(), i("div",
|
|
578
|
+
!t.multiple || t.displayMode === "text" ? (a(), i("div", ht, [
|
|
566
579
|
h("span", {
|
|
580
|
+
ref_key: "textDisplaySpanRef",
|
|
581
|
+
ref: _,
|
|
567
582
|
class: "text-truncate",
|
|
568
|
-
title:
|
|
569
|
-
}, x(t.isLoading ? "Loading data..." :
|
|
570
|
-
|
|
583
|
+
title: q.value ? we.value : ""
|
|
584
|
+
}, x(t.isLoading ? "Loading data..." : fe.value), 9, pt),
|
|
585
|
+
q.value && !t.isLoading ? (a(), z(A, {
|
|
571
586
|
key: 0,
|
|
572
587
|
ref_key: "tooltipTriggerIconRef",
|
|
573
588
|
ref: I,
|
|
574
589
|
name: "info-circle",
|
|
575
590
|
class: "tooltip-trigger-icon ms-2 flex-shrink-0",
|
|
576
|
-
onClick: S(
|
|
591
|
+
onClick: S(Fe, ["stop"])
|
|
577
592
|
}, null, 512)) : u("", !0)
|
|
578
|
-
])) : t.multiple && t.displayMode === "chips" ? (a(), i("div",
|
|
579
|
-
T.value.length === 0 ? (a(), i("span",
|
|
580
|
-
(a(!0), i(
|
|
581
|
-
key:
|
|
593
|
+
])) : t.multiple && t.displayMode === "chips" ? (a(), i("div", gt, [
|
|
594
|
+
T.value.length === 0 ? (a(), i("span", yt, x(t.placeholder), 1)) : (a(), i("div", bt, [
|
|
595
|
+
(a(!0), i(X, null, Y(Ce.value, (n) => (a(), i("span", {
|
|
596
|
+
key: b(n),
|
|
582
597
|
class: "badge text-bg-primary chip bg-primary"
|
|
583
598
|
}, [
|
|
584
|
-
|
|
585
|
-
|
|
599
|
+
Q(x(O(n)) + " ", 1),
|
|
600
|
+
ie(A, {
|
|
586
601
|
name: "times",
|
|
587
602
|
class: "chip-remove",
|
|
588
|
-
onClick: S((o) =>
|
|
603
|
+
onClick: S((o) => me(n), ["stop"])
|
|
589
604
|
}, null, 8, ["onClick"])
|
|
590
605
|
]))), 128)),
|
|
591
|
-
|
|
606
|
+
se.value > 0 ? (a(), i("button", {
|
|
592
607
|
key: 0,
|
|
593
608
|
ref_key: "moreTriggerRef",
|
|
594
|
-
ref:
|
|
609
|
+
ref: F,
|
|
595
610
|
type: "button",
|
|
596
611
|
class: "btn btn-sm btn-light more-button",
|
|
597
|
-
onClick: S(
|
|
598
|
-
}, " +" + x(
|
|
612
|
+
onClick: S($e, ["stop"])
|
|
613
|
+
}, " +" + x(se.value), 513)) : u("", !0)
|
|
599
614
|
]))
|
|
600
615
|
])) : u("", !0)
|
|
601
616
|
], !0)
|
|
602
617
|
]),
|
|
603
|
-
h("div",
|
|
604
|
-
t.isLoading ? (a(),
|
|
618
|
+
h("div", kt, [
|
|
619
|
+
t.isLoading ? (a(), z(A, {
|
|
605
620
|
key: 0,
|
|
606
621
|
name: "spinner",
|
|
607
622
|
class: "loading-icon"
|
|
608
623
|
})) : u("", !0),
|
|
609
|
-
t.showClearButton && T.value.length > 0 && !t.disabled && !t.isLoading ? (a(),
|
|
624
|
+
t.showClearButton && T.value.length > 0 && !t.disabled && !t.isLoading ? (a(), z(A, {
|
|
610
625
|
key: 1,
|
|
611
626
|
name: "times",
|
|
612
|
-
onClick: S(
|
|
627
|
+
onClick: S(Ee, ["stop"]),
|
|
613
628
|
class: "clear-icon"
|
|
614
629
|
})) : u("", !0),
|
|
615
|
-
t.isLoading ? u("", !0) : (a(),
|
|
630
|
+
t.isLoading ? u("", !0) : (a(), z(A, {
|
|
616
631
|
key: 2,
|
|
617
632
|
name: "chevron-down",
|
|
618
|
-
class:
|
|
633
|
+
class: B(["transition-transform", { "rotate-180": $.value }])
|
|
619
634
|
}, null, 8, ["class"]))
|
|
620
635
|
])
|
|
621
|
-
], 42,
|
|
622
|
-
|
|
636
|
+
], 42, mt),
|
|
637
|
+
j.value ? (a(), i("div", {
|
|
623
638
|
key: 0,
|
|
624
639
|
ref_key: "morePopoverRef",
|
|
625
|
-
ref:
|
|
640
|
+
ref: ee,
|
|
626
641
|
class: "card shadow-lg border-0 more-popover",
|
|
627
642
|
style: { "z-index": "1060" }
|
|
628
643
|
}, [
|
|
629
|
-
h("div",
|
|
630
|
-
(a(!0), i(
|
|
631
|
-
key:
|
|
644
|
+
h("div", wt, [
|
|
645
|
+
(a(!0), i(X, null, Y(Te.value, (n) => (a(), i("div", {
|
|
646
|
+
key: b(n),
|
|
632
647
|
class: "list-group-item d-flex justify-content-between align-items-center py-1 px-2"
|
|
633
648
|
}, [
|
|
634
|
-
h("small",
|
|
635
|
-
t.disabled ? u("", !0) : (a(),
|
|
649
|
+
h("small", xt, x(O(n)), 1),
|
|
650
|
+
t.disabled ? u("", !0) : (a(), z(A, {
|
|
636
651
|
key: 0,
|
|
637
652
|
name: "times",
|
|
638
653
|
class: "chip-remove flex-shrink-0",
|
|
639
|
-
onClick: S((o) =>
|
|
654
|
+
onClick: S((o) => me(n), ["stop"])
|
|
640
655
|
}, null, 8, ["onClick"]))
|
|
641
656
|
]))), 128))
|
|
642
657
|
])
|
|
@@ -652,59 +667,59 @@ const pe = (t, D) => {
|
|
|
652
667
|
}, ["stop"])),
|
|
653
668
|
style: { "z-index": "1050" }
|
|
654
669
|
}, [
|
|
655
|
-
h("div",
|
|
656
|
-
t.searchable ?
|
|
670
|
+
h("div", St, [
|
|
671
|
+
t.searchable ? he((a(), i("input", {
|
|
657
672
|
key: 0,
|
|
658
|
-
"onUpdate:modelValue": s[0] || (s[0] = (n) =>
|
|
673
|
+
"onUpdate:modelValue": s[0] || (s[0] = (n) => y.value = n),
|
|
659
674
|
type: "text",
|
|
660
|
-
class:
|
|
675
|
+
class: B(["form-control tree-search-input", ke.value]),
|
|
661
676
|
placeholder: "Search...",
|
|
662
|
-
onKeydown:
|
|
663
|
-
}, null, 42,
|
|
664
|
-
[
|
|
677
|
+
onKeydown: pe(S(De, ["prevent"]), ["enter"])
|
|
678
|
+
}, null, 42, Ct)), [
|
|
679
|
+
[Ge, y.value]
|
|
665
680
|
]) : u("", !0),
|
|
666
|
-
t.sortable && t.sortOptions.length > 0 ? (a(), i("div",
|
|
667
|
-
|
|
668
|
-
"onUpdate:modelValue": s[1] || (s[1] = (n) =>
|
|
669
|
-
class:
|
|
681
|
+
t.sortable && t.sortOptions.length > 0 ? (a(), i("div", Vt, [
|
|
682
|
+
he(h("select", {
|
|
683
|
+
"onUpdate:modelValue": s[1] || (s[1] = (n) => E.value = n),
|
|
684
|
+
class: B(["form-select flex-grow-1", ke.value])
|
|
670
685
|
}, [
|
|
671
686
|
s[4] || (s[4] = h("option", {
|
|
672
687
|
value: null,
|
|
673
688
|
disabled: ""
|
|
674
689
|
}, "Sort by...", -1)),
|
|
675
|
-
(a(!0), i(
|
|
690
|
+
(a(!0), i(X, null, Y(t.sortOptions, (n) => (a(), i("option", {
|
|
676
691
|
key: n.value,
|
|
677
692
|
value: n.value
|
|
678
|
-
}, x(n.label), 9,
|
|
693
|
+
}, x(n.label), 9, Lt))), 128))
|
|
679
694
|
], 2), [
|
|
680
|
-
[
|
|
695
|
+
[Je, E.value]
|
|
681
696
|
]),
|
|
682
697
|
h("button", {
|
|
683
698
|
type: "button",
|
|
684
|
-
class:
|
|
685
|
-
disabled: !
|
|
686
|
-
onClick:
|
|
699
|
+
class: B(["btn btn-outline-secondary", be.value]),
|
|
700
|
+
disabled: !E.value,
|
|
701
|
+
onClick: Ke
|
|
687
702
|
}, [
|
|
688
|
-
|
|
689
|
-
name:
|
|
703
|
+
ie(A, {
|
|
704
|
+
name: H.value === "asc" ? "asc" : "desc"
|
|
690
705
|
}, null, 8, ["name"])
|
|
691
|
-
], 10,
|
|
706
|
+
], 10, It)
|
|
692
707
|
])) : u("", !0)
|
|
693
708
|
]),
|
|
694
|
-
t.isLoading ? (a(), i("div",
|
|
695
|
-
|
|
709
|
+
t.isLoading ? (a(), i("div", At, [
|
|
710
|
+
ie(A, {
|
|
696
711
|
name: "spinner",
|
|
697
712
|
class: "me-2"
|
|
698
713
|
}),
|
|
699
714
|
s[5] || (s[5] = h("span", null, "Loading...", -1))
|
|
700
|
-
])) : (a(), i("div",
|
|
701
|
-
|
|
702
|
-
(a(!0), i(
|
|
703
|
-
key:
|
|
715
|
+
])) : (a(), i("div", $t, [
|
|
716
|
+
ae.value.length > 0 ? (a(), i("div", Mt, [
|
|
717
|
+
(a(!0), i(X, null, Y(ae.value, (n) => (a(), z(ft, {
|
|
718
|
+
key: b(n),
|
|
704
719
|
item: n,
|
|
705
720
|
level: 0,
|
|
706
721
|
"selected-items": T.value,
|
|
707
|
-
"expanded-items":
|
|
722
|
+
"expanded-items": K.value,
|
|
708
723
|
multiple: t.multiple,
|
|
709
724
|
"select-all": t.selectAll,
|
|
710
725
|
"select-mode": t.selectMode,
|
|
@@ -712,65 +727,66 @@ const pe = (t, D) => {
|
|
|
712
727
|
"option-value": t.optionValue,
|
|
713
728
|
"disabled-key": t.disabledKey,
|
|
714
729
|
"disable-branch-node": t.disableBranchNodes,
|
|
715
|
-
onSelect:
|
|
716
|
-
onToggleExpand:
|
|
730
|
+
onSelect: ze,
|
|
731
|
+
onToggleExpand: Ie
|
|
717
732
|
}, {
|
|
718
|
-
default:
|
|
719
|
-
|
|
733
|
+
default: Ne(({ item: o, level: r }) => [
|
|
734
|
+
re(e.$slots, "default", {
|
|
720
735
|
item: o,
|
|
721
736
|
level: r
|
|
722
737
|
}, () => [
|
|
723
|
-
h("div",
|
|
724
|
-
|
|
738
|
+
h("div", Bt, [
|
|
739
|
+
Q(x(O(o)) + " ", 1),
|
|
725
740
|
o.icon ? (a(), i("i", {
|
|
726
741
|
key: 0,
|
|
727
|
-
class:
|
|
742
|
+
class: B(o.icon)
|
|
728
743
|
}, null, 2)) : u("", !0)
|
|
729
744
|
])
|
|
730
745
|
], !0)
|
|
731
746
|
]),
|
|
732
747
|
_: 2
|
|
733
748
|
}, 1032, ["item", "selected-items", "expanded-items", "multiple", "select-all", "select-mode", "option-label", "option-value", "disabled-key", "disable-branch-node"]))), 128))
|
|
734
|
-
])) : (a(), i("div",
|
|
735
|
-
t.allowAddNew ? (a(), i("div",
|
|
749
|
+
])) : (a(), i("div", Nt, [
|
|
750
|
+
t.allowAddNew ? (a(), i("div", Tt, [
|
|
736
751
|
t.addNewMode === "button" ? (a(), i("button", {
|
|
737
752
|
key: 0,
|
|
738
753
|
type: "button",
|
|
739
754
|
class: "btn btn-success btn-sm w-100",
|
|
740
|
-
onClick:
|
|
755
|
+
onClick: Ae
|
|
741
756
|
}, [
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
])) : t.addNewMode === "enter" ? (a(), i("span",
|
|
745
|
-
|
|
746
|
-
|
|
757
|
+
Q(' No items found "Click" to ' + x(t.addNewLabel) + " ", 1),
|
|
758
|
+
y.value.trim() ? (a(), i("span", zt, ' : "' + x(y.value) + '" ', 1)) : u("", !0)
|
|
759
|
+
])) : t.addNewMode === "enter" ? (a(), i("span", Kt, [
|
|
760
|
+
Q(' No items found "Press Enter" to ' + x(t.addNewLabel) + " ", 1),
|
|
761
|
+
y.value.trim() ? (a(), i("span", Et, ' : "' + x(y.value) + '" ', 1)) : u("", !0)
|
|
747
762
|
])) : u("", !0)
|
|
748
|
-
])) : (a(), i("div",
|
|
749
|
-
|
|
763
|
+
])) : (a(), i("div", Dt, [
|
|
764
|
+
ie(A, {
|
|
750
765
|
name: "search",
|
|
751
766
|
class: "me-1"
|
|
752
767
|
}),
|
|
753
|
-
s[6] || (s[6] =
|
|
768
|
+
s[6] || (s[6] = Q(" No items found ", -1))
|
|
754
769
|
]))
|
|
755
770
|
]))
|
|
756
771
|
]))
|
|
757
772
|
], 544)) : u("", !0),
|
|
758
|
-
|
|
759
|
-
key: 2,
|
|
773
|
+
he(h("div", {
|
|
760
774
|
ref_key: "tooltipRef",
|
|
761
775
|
ref: p,
|
|
762
776
|
class: "tree-select-tooltip card shadow-sm py-1 px-2",
|
|
763
777
|
role: "tooltip",
|
|
764
778
|
style: { "z-index": "1070" }
|
|
765
|
-
}, x(
|
|
779
|
+
}, x(we.value), 513), [
|
|
780
|
+
[Qe, w.value]
|
|
781
|
+
])
|
|
766
782
|
], 544));
|
|
767
783
|
}
|
|
768
|
-
},
|
|
784
|
+
}, Ot = /* @__PURE__ */ ye(Pt, [["__scopeId", "data-v-c318f0b9"]]), Ht = {
|
|
769
785
|
install(t) {
|
|
770
|
-
t.component("VSelect",
|
|
786
|
+
t.component("VSelect", Ot);
|
|
771
787
|
}
|
|
772
788
|
};
|
|
773
789
|
export {
|
|
774
|
-
|
|
775
|
-
|
|
790
|
+
Ot as VSelect,
|
|
791
|
+
Ht as default
|
|
776
792
|
};
|
package/dist/vue-select.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(w,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue"),require("@popperjs/core")):typeof define=="function"&&define.amd?define(["exports","vue","@popperjs/core"],e):(w=typeof globalThis<"u"?globalThis:w||self,e(w.VueSelect={},w.Vue,w.Popper))})(this,(function(w,e,G){"use strict";const J=(l,I)=>{const n=l.__vccOpts||l;for(const[m,i]of I)n[m]=i;return n},pe={key:0},he={key:1},ge={key:2},ye={key:3},ke={key:4},be={key:5},Be={key:6},Ve={key:7},B=J({__name:"SvgIcon",props:{name:{type:String,required:!0}},setup(l){const I=l,n=e.computed(()=>({"svg-icon-spin":I.name==="spinner"}));return(m,i)=>(e.openBlock(),e.createElementBlock("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",width:"1em",height:"1em",class:e.normalizeClass(n.value)},[l.name==="spinner"?(e.openBlock(),e.createElementBlock("g",pe,i[0]||(i[0]=[e.createElementVNode("path",{d:"M12,4V2A10,10,0,0,0,2,12H4A8,8,0,0,1,12,4Z"},null,-1)]))):e.createCommentVNode("",!0),l.name==="times"?(e.openBlock(),e.createElementBlock("g",he,i[1]||(i[1]=[e.createElementVNode("path",{d:"M13.41,12l4.3-4.29a1,1,0,1,0-1.42-1.42L12,10.59,7.71,6.29A1,1,0,0,0,6.29,7.71L10.59,12l-4.3,4.29a1,1,0,0,0,0,1.42,1,1,0,0,0,1.42,0L12,13.41l4.29,4.3a1,1,0,0,0,1.42,0,1,1,0,0,0,0-1.42Z"},null,-1)]))):e.createCommentVNode("",!0),l.name==="chevron-down"?(e.openBlock(),e.createElementBlock("g",ge,i[2]||(i[2]=[e.createElementVNode("path",{d:"M17,9.17a1,1,0,0,0-1.41,0L12,12.71,8.46,9.17a1,1,0,0,0-1.41,0,1,1,0,0,0,0,1.42l4.24,4.24a1,1,0,0,0,1.42,0L17,10.59A1,1,0,0,0,17,9.17Z"},null,-1)]))):e.createCommentVNode("",!0),l.name==="chevron-right"?(e.openBlock(),e.createElementBlock("g",ye,i[3]||(i[3]=[e.createElementVNode("path",{d:"M10.83,12l-4.24,4.24a1,1,0,0,0,1.41,1.41L13.66,12,8,6.34A1,1,0,0,0,6.59,7.76Z"},null,-1)]))):e.createCommentVNode("",!0),l.name==="search"?(e.openBlock(),e.createElementBlock("g",ke,i[4]||(i[4]=[e.createElementVNode("path",{d:"M21.71,20.29,18,16.61A9,9,0,1,0,16.61,18l3.68,3.68a1,1,0,0,0,1.42,0A1,1,0,0,0,21.71,20.29ZM11,18a7,7,0,1,1,7-7A7,7,0,0,1,11,18Z"},null,-1)]))):e.createCommentVNode("",!0),l.name==="asc"?(e.openBlock(),e.createElementBlock("g",be,i[5]||(i[5]=[e.createElementVNode("path",{fill:"currentColor",d:"M4.869 11H2.667L6 3h2l3.333 8H9.131l-.41-1H5.28zm1.23-3h1.803L7 5.8zm12.9 8V3h-2v13h-3l4 5l4-5zm-8-3H3v2h4.855L3 19v2h8v-2H6.146L11 15z"},null,-1)]))):e.createCommentVNode("",!0),l.name==="desc"?(e.openBlock(),e.createElementBlock("g",Be,i[6]||(i[6]=[e.createElementVNode("path",{fill:"currentColor",d:"M4.869 11H2.667L6 3h2l3.333 8H9.131l-.41-1H5.28zm1.23-3h1.803L7 5.8zm15.9 0l-4-5l-4 5h3v13h2V8zm-11 5H3v2h4.855L3 19v2h8v-2H6.146L11 15z"},null,-1)]))):e.createCommentVNode("",!0),l.name==="info-circle"?(e.openBlock(),e.createElementBlock("g",Ve,i[7]||(i[7]=[e.createElementVNode("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-6h2v6zm0-8h-2V7h2v2z"},null,-1)]))):e.createCommentVNode("",!0)],2))}},[["__scopeId","data-v-89f9b7e1"]]),we={class:"tree-select-item-wrapper"},xe={key:1,class:"expander-placeholder"},Ce=["checked",".indeterminate","disabled"],Se={class:"item-content"},Ee={key:0,class:"children-wrapper"},Ne=J({__name:"TreeSelectItem",props:{item:{type:Object,required:!0},level:{type:Number,required:!0},selectedItems:{type:Array,required:!0},expandedItems:{type:Set,required:!0},multiple:{type:Boolean,required:!0},selectAll:{type:Boolean,required:!0},selectMode:{type:String,required:!0},optionLabel:{type:String,required:!0},optionValue:{type:String,required:!0},disabledKey:{type:String,default:null},disableBranchNode:{type:Boolean,default:!1}},emits:["select","toggle-expand"],setup(l,{emit:I}){const n=l,m=c=>c[n.optionValue]||c.id||c.value,i=c=>!n.disabledKey||!c?!1:c.hasOwnProperty(n.disabledKey)&&c[n.disabledKey]!==null,y=e.computed(()=>n.item.children&&n.item.children.length>0),E=e.computed(()=>n.expandedItems.has(m(n.item))),p=e.computed(()=>n.selectedItems.includes(m(n.item))),x=c=>{let f=[];return c.children&&c.children.forEach(C=>{f.push(m(C)),f.push(...x(C))}),f},L=e.computed(()=>!n.multiple||!n.selectAll||!y.value||p.value?!1:x(n.item).some(f=>n.selectedItems.includes(f)));return(c,f)=>{const C=e.resolveComponent("TreeSelectItem",!0);return e.openBlock(),e.createElementBlock("div",we,[e.createElementVNode("div",{class:e.normalizeClass(["list-group-item list-group-item-action d-flex align-items-center gap-2",{"bg-primary text-white":p.value&&(l.selectMode==="highlight"||!l.multiple)&&!i(l.item)&&!(l.disableBranchNode&&y.value),"is-disabled text-muted bg-light":i(l.item)}]),style:e.normalizeStyle({"padding-left":`${l.level*1.5+1}rem`}),onClick:f[2]||(f[2]=g=>i(l.item)?null:c.$emit("select",l.item))},[y.value?(e.openBlock(),e.createBlock(B,{key:0,name:"chevron-right",class:e.normalizeClass(["expander-icon",{"rotate-90":E.value}]),onClick:f[0]||(f[0]=e.withModifiers(g=>c.$emit("toggle-expand",m(l.item)),["stop"]))},null,8,["class"])):(e.openBlock(),e.createElementBlock("span",xe)),l.multiple&&l.selectMode==="checkbox"&&!(l.disableBranchNode&&y.value)?(e.openBlock(),e.createElementBlock("input",{key:2,type:"checkbox",class:"form-check-input",checked:p.value,".indeterminate":L.value,disabled:i(l.item),onClick:f[1]||(f[1]=e.withModifiers(g=>c.$emit("select",l.item),["stop"]))},null,40,Ce)):e.createCommentVNode("",!0),e.createElementVNode("div",Se,[e.renderSlot(c.$slots,"default",{item:l.item,level:l.level},void 0,!0)])],6),y.value&&E.value?(e.openBlock(),e.createElementBlock("div",Ee,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.item.children,g=>(e.openBlock(),e.createBlock(C,{key:m(g),item:g,level:l.level+1,"selected-items":l.selectedItems,"expanded-items":l.expandedItems,multiple:l.multiple,"select-all":l.selectAll,"select-mode":l.selectMode,"option-label":l.optionLabel,"option-value":l.optionValue,"disabled-key":l.disabledKey,"disable-branch-node":l.disableBranchNode,onSelect:f[3]||(f[3]=V=>c.$emit("select",V)),onToggleExpand:f[4]||(f[4]=V=>c.$emit("toggle-expand",V))},{default:e.withCtx(({item:V,level:S})=>[e.renderSlot(c.$slots,"default",{item:V,level:S},void 0,!0)]),_:2},1032,["item","level","selected-items","expanded-items","multiple","select-all","select-mode","option-label","option-value","disabled-key","disable-branch-node"]))),128))])):e.createCommentVNode("",!0)])}}},[["__scopeId","data-v-b319a2c7"]]),Le=["onKeydown"],Me={class:"tree-select-display-container"},Ie={key:0,class:"d-flex align-items-center justify-content-start w-100"},$e=["title"],Ae={key:1},Te={key:0,class:"text-muted"},ze={key:1,class:"chips-container"},De={class:"d-flex align-items-center gap-2"},Ke={class:"list-group list-group-flush"},Pe={class:"text-wrap text-start me-2"},Oe={class:"p-2 border-bottom d-flex flex-column gap-2"},qe=["onKeydown"],Fe={key:1,class:"d-flex align-items-center gap-2"},Re=["value"],je=["disabled"],He={key:0,class:"p-4 text-muted text-center"},Ze={key:1,class:"tree-select-body",style:{"max-height":"300px","overflow-y":"auto"}},Ue={key:0,class:"list-group list-group-flush"},We={class:"d-flex align-items-center gap-2",style:{"white-space":"wrap"}},Ge={key:1,class:"p-3 text-muted text-center"},Je={key:0},Qe={key:0},Xe={key:1},Ye={key:0},ve={key:1},le=J({__name:"TreeSelectMain",props:{modelValue:{type:[String,Number,Array],default:null},displayMode:{type:String,default:"text",validator:l=>["text","chips"].includes(l)},items:{type:Array,default:()=>[]},multiple:{type:Boolean,default:!1},selectMode:{type:String,default:"checkbox",validator:l=>["checkbox","highlight"].includes(l)},placeholder:{type:String,default:"Select item..."},isInvalid:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},searchable:{type:Boolean,default:!0},isLoading:{type:Boolean,default:!1},showClearButton:{type:Boolean,default:!0},selectAll:{type:Boolean,default:!1},deselectAll:{type:Boolean,default:!0},canDeselect:{type:Boolean,default:!0},optionLabel:{type:String,default:"value"},optionValue:{type:String,default:"code"},disabledKey:{type:String,default:null},excludeFromSelectedListKey:{type:String,default:null},disableBranchNodes:{type:Boolean,default:!1},size:{type:String,default:"sm",validator:l=>["sm","md","lg","xl"].includes(l)},sortable:{type:Boolean,default:!1},sortOptions:{type:Array,default:()=>[]},defaultSortKey:{type:String,default:null},defaultSortDirection:{type:String,default:"asc",validator:l=>["asc","desc"].includes(l)},maxVisibleChipsDisplay:{type:Number,default:3},closeOnSelect:{type:Boolean,default:!0},allowAddNew:{type:Boolean,default:!1},addNewMode:{type:String,default:"button",validator:l=>["button","enter"].includes(l)},addNewLabel:{type:String,default:"Add new record"}},emits:["update:modelValue","change","clear","deselect","select","focus","blur","add-new"],setup(l,{emit:I}){const n=l,m=I,i=e.ref(null),y=e.ref(null),E=e.ref(null),p=e.ref(""),x=e.ref(!1),L=e.ref(new Set),c=e.ref(null),f=e.ref(null),C=e.ref(null),g=e.ref(!1),V=e.ref(null),S=e.ref(n.defaultSortKey),A=e.ref(n.defaultSortDirection),T=e.ref(null),F=e.ref(null),z=e.ref(!1),R=e.ref(null),ne=e.computed(()=>n.size==="sm"?"btn-sm":n.size==="lg"?"btn-lg":n.size==="xl"?"btn-xl":""),oe=e.computed(()=>n.size==="sm"?"form-control-sm":n.size==="lg"?"form-control-lg":n.size==="xl"?"form-control-xl":""),et=e.computed(()=>Z.value===0?[]:H.value.slice(n.maxVisibleChipsDisplay)),D=e.computed(()=>!n.multiple||!n.excludeFromSelectedListKey?N.value:N.value.filter(t=>{const a=K(t);return!a||!a[n.excludeFromSelectedListKey]})),Q=e.computed(()=>{const t=D.value;if(t.length===0)return n.placeholder;if(n.multiple){if(t.length===1){const o=P(t[0]);return o?o.join(" → "):t[0]}return`${t.length} items selected`}const a=P(t[0]);return a?a.join(" → "):t[0]}),X=e.computed(()=>n.multiple||n.displayMode==="chips"||D.value.length===0?!1:Q.value.length>40),$=t=>t&&(t[n.optionLabel]||t.label||t.name)||"",h=t=>t?t[n.optionValue]||t.id||t.value:null,Y=t=>!n.disabledKey||!t?!1:t.hasOwnProperty(n.disabledKey)&&t[n.disabledKey]!==null,k=t=>t.children&&t.children.length>0,j=(t,a)=>{if(a)return a.split(".").reduce((o,r)=>o&&o[r],t)},K=(t,a=n.items)=>{for(const o of a){if(h(o)===t)return o;if(k(o)){const r=K(t,o.children);if(r)return r}}return null},v=t=>{const a=[];return k(t)&&t.children.forEach(o=>{Y(o)||(a.push(h(o)),a.push(...v(o)))}),a},_=(t,a=n.items,o=[])=>{for(const r of a){if(h(r)===t)return o;if(k(r)){const s=_(t,r.children,[...o,h(r)]);if(s)return s}}return null},N=e.computed(()=>{const t=new Set(Array.isArray(n.modelValue)?n.modelValue:[n.modelValue].filter(Boolean));if(n.multiple&&n.selectAll){const a=o=>{o.forEach(r=>{if(k(r)){const s=r.children.filter(u=>!Y(u));s.length>0&&s.every(u=>t.has(h(u)))&&t.add(h(r)),a(r.children)}})};a(n.items)}return Array.from(t)}),P=(t,a=n.items,o=[])=>{for(const r of a){const s=[...o,$(r)];if(h(r)===t)return s;if(k(r)){const d=P(t,r.children,s);if(d)return d}}return null},ae=t=>{if(!t||t.length===0)return"";const a=t.join(" → ");return a.length<=40?a:t.length>2?`${t[0]} → ... → ${t[t.length-1]}`:a},re=e.computed(()=>{const t=D.value;if(t.length===0)return n.placeholder;if(n.multiple){if(t.length===1){const o=P(t[0]);return o?ae(o):t[0]}return`${t.length} items selected`}const a=P(t[0]);return a?ae(a):t[0]}),H=e.computed(()=>{if(!n.multiple||D.value.length===0)return[];const t=D.value.map(r=>K(r)).filter(Boolean);if(!n.sortable||!S.value)return t;const a=S.value,o=A.value;return[...t].sort((r,s)=>{const d=j(r,a),u=j(s,a);if(d==null)return 1;if(u==null)return-1;let b=0;return typeof d=="string"&&typeof u=="string"?b=d.localeCompare(u):d>u?b=1:d<u&&(b=-1),o==="desc"?b*-1:b})}),se=e.computed(()=>H.value.slice(0,n.maxVisibleChipsDisplay)),Z=e.computed(()=>{const t=H.value.length-n.maxVisibleChipsDisplay;return t>0?t:0}),ie=(t,a)=>t.map(o=>{const r=$(o).toLowerCase().includes(a);if(!k(o))return r?o:null;const s=ie(o.children,a);return r?{...o,children:o.children}:s.length>0?{...o,children:s}:null}).filter(Boolean),ce=(t,a,o)=>!t||!a?t:[...t].sort((s,d)=>{const u=j(s,a),b=j(d,a);if(u==null)return 1;if(b==null)return-1;let q=0;return typeof u=="string"&&typeof b=="string"?q=u.localeCompare(b):u>b?q=1:u<b&&(q=-1),o==="desc"?q*-1:q}).map(s=>k(s)?{...s,children:ce(s.children,a,o)}:s),U=e.computed(()=>{const t=p.value.trim()?ie(n.items,p.value.toLowerCase()):n.items;return!n.sortable||!S.value?t:ce(t,S.value,A.value)}),tt=t=>{if(n.disableBranchNodes&&k(t)){const s=h(t);de(s);return}if(Y(t))return;const a=h(t);let o=new Set(N.value);if(n.multiple){const s=o.has(a);if(n.selectAll&&k(t)){const d=v(t);s?(o.delete(a),m("deselect",t),n.deselectAll&&d.forEach(u=>o.delete(u))):(o.add(a),d.forEach(u=>o.add(u)),m("select",t))}else s?(o.delete(a),n.selectAll&&_(a)?.forEach(u=>o.delete(u))):o.add(a)}else{const s=n.modelValue,d=h(t);s===d?(o.clear(),m("deselect",t)):(o.clear(),o.add(d),s!=null&&K(s),m("select",t)),n.closeOnSelect&&M(),e.nextTick(()=>{E.value?.focus()})}let r=Array.from(o);n.multiple&&n.excludeFromSelectedListKey&&(r=r.filter(s=>{const d=K(s);return!d||!d[n.excludeFromSelectedListKey]})),m("update:modelValue",n.multiple?r:r[0]||null),m("change",n.multiple?r:r[0]||null)},ee=t=>{if(n.disabled||!t)return;const a=h(t),o=new Set(N.value);o.delete(a),n.selectAll&&(n.deselectAll&&k(t)&&v(t).forEach(u=>o.delete(u)),_(a)?.forEach(d=>o.delete(d)));const r=Array.from(o);m("update:modelValue",r),m("change",r)},de=t=>{L.value.has(t)?L.value.delete(t):L.value.add(t)},lt=()=>{A.value=A.value==="asc"?"desc":"asc"},nt=()=>{const t=n.multiple?[]:null;m("clear"),m("update:modelValue",t),m("change",t),O()},me=()=>{!n.allowAddNew||!p.value.trim()||(m("add-new",p.value.trim()),M())},ot=()=>{n.allowAddNew&&n.addNewMode==="enter"&&p.value.trim()&&U.value.length===0&&me()},at=t=>{m("focus",t)},rt=async()=>{n.disabled||(O(),x.value=!0,W(),await e.nextTick(),y.value&&E.value&&(c.value=G.createPopper(E.value,y.value,{placement:"bottom-start",strategy:"fixed",modifiers:[{name:"offset",options:{offset:[0,4]}},{name:"preventOverflow",options:{padding:8}},{name:"flip",options:{fallbackPlacements:["top-start"]}},{name:"sameWidth",enabled:!0,phase:"beforeWrite",requires:["computeStyles"],fn:({state:t})=>{t.styles.popper.width=`${t.rects.reference.width}px`},effect:({state:t})=>{t.elements.popper.style.width=`${t.elements.reference.offsetWidth}px`}}]})),n.searchable&&(await e.nextTick(),y.value?.querySelector(".tree-search-input")?.focus()))},M=()=>{x.value=!1,p.value="",c.value?.destroy(),c.value=null,m("blur",n.modelValue)},te=()=>x.value?M():rt(),st=async()=>{M(),W(),z.value=!0,await e.nextTick(),F.value&&T.value&&(R.value=G.createPopper(T.value,F.value,{placement:"bottom-end",strategy:"fixed",modifiers:[{name:"offset",options:{offset:[0,4]}}]}))},O=()=>{z.value=!1,R.value?.destroy(),R.value=null},ue=()=>z.value?O():st(),fe=t=>{x.value&&!E.value?.contains(t.target)&&!y.value?.contains(t.target)&&M(),z.value&&!T.value?.contains(t.target)&&!F.value?.contains(t.target)&&O(),g.value&&!V.value?.$el?.contains(t.target)&&!f.value?.contains(t.target)&&W()},it=t=>{i.value?.contains(t.relatedTarget)||M()},ct=async()=>{!X.value||g.value||(M(),O(),g.value=!0,await e.nextTick(),f.value&&V.value&&(C.value=G.createPopper(V.value,f.value,{placement:"top",strategy:"fixed",modifiers:[{name:"offset",options:{offset:[0,8]}}]})))},dt=()=>{g.value?W():ct()},W=()=>{g.value=!1,C.value?.destroy(),C.value=null};return e.onMounted(()=>document.addEventListener("click",fe)),e.onUnmounted(()=>{document.removeEventListener("click",fe),c.value?.destroy(),R.value?.destroy(),C.value?.destroy()}),e.watch(p,t=>{if(t.trim()){const a=o=>{o.forEach(r=>{k(r)&&(L.value.add(h(r)),a(r.children))})};a(U.value)}}),(t,a)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"wrapperRef",ref:i,class:"tree-select-wrapper",onFocusin:at,onFocusout:it},[e.createElementVNode("div",{ref_key:"triggerRef",ref:E,role:"button",tabindex:"0",class:e.normalizeClass(["btn tree-select-trigger w-100 d-flex justify-content-between align-items-center tree-select-main",[ne.value,{"btn-outline-secondary":!l.isInvalid,"border-danger":l.isInvalid,disabled:l.disabled||l.isLoading,"is-loading":l.isLoading,"has-chips":l.multiple&&l.displayMode==="chips"&&N.value.length>0}]]),onClick:te,onKeydown:[e.withKeys(e.withModifiers(te,["prevent"]),["enter"]),e.withKeys(e.withModifiers(te,["prevent"]),["space"])]},[e.createElementVNode("div",Me,[e.renderSlot(t.$slots,"display",{selectedItems:H.value,displayText:re.value,placeholder:l.placeholder,isLoading:l.isLoading,removeItem:ee,getItemLabel:$,getItemValue:h,visibleChips:se.value,hiddenChipsCount:Z.value,toggleMorePopover:ue,moreTriggerRef:T.value},()=>[!l.multiple||l.displayMode==="text"?(e.openBlock(),e.createElementBlock("div",Ie,[e.createElementVNode("span",{class:"text-truncate",title:X.value?Q.value:""},e.toDisplayString(l.isLoading?"Loading data...":re.value),9,$e),X.value&&!l.isLoading?(e.openBlock(),e.createBlock(B,{key:0,ref_key:"tooltipTriggerIconRef",ref:V,name:"info-circle",class:"tooltip-trigger-icon ms-2 flex-shrink-0",onClick:e.withModifiers(dt,["stop"])},null,512)):e.createCommentVNode("",!0)])):l.multiple&&l.displayMode==="chips"?(e.openBlock(),e.createElementBlock("div",Ae,[N.value.length===0?(e.openBlock(),e.createElementBlock("span",Te,e.toDisplayString(l.placeholder),1)):(e.openBlock(),e.createElementBlock("div",ze,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(se.value,o=>(e.openBlock(),e.createElementBlock("span",{key:h(o),class:"badge text-bg-primary chip bg-primary"},[e.createTextVNode(e.toDisplayString($(o))+" ",1),e.createVNode(B,{name:"times",class:"chip-remove",onClick:e.withModifiers(r=>ee(o),["stop"])},null,8,["onClick"])]))),128)),Z.value>0?(e.openBlock(),e.createElementBlock("button",{key:0,ref_key:"moreTriggerRef",ref:T,type:"button",class:"btn btn-sm btn-light more-button",onClick:e.withModifiers(ue,["stop"])}," +"+e.toDisplayString(Z.value),513)):e.createCommentVNode("",!0)]))])):e.createCommentVNode("",!0)],!0)]),e.createElementVNode("div",De,[l.isLoading?(e.openBlock(),e.createBlock(B,{key:0,name:"spinner",class:"loading-icon"})):e.createCommentVNode("",!0),l.showClearButton&&N.value.length>0&&!l.disabled&&!l.isLoading?(e.openBlock(),e.createBlock(B,{key:1,name:"times",onClick:e.withModifiers(nt,["stop"]),class:"clear-icon"})):e.createCommentVNode("",!0),l.isLoading?e.createCommentVNode("",!0):(e.openBlock(),e.createBlock(B,{key:2,name:"chevron-down",class:e.normalizeClass(["transition-transform",{"rotate-180":x.value}])},null,8,["class"]))])],42,Le),z.value?(e.openBlock(),e.createElementBlock("div",{key:0,ref_key:"morePopoverRef",ref:F,class:"card shadow-lg border-0 more-popover",style:{"z-index":"1060"}},[e.createElementVNode("div",Ke,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(et.value,o=>(e.openBlock(),e.createElementBlock("div",{key:h(o),class:"list-group-item d-flex justify-content-between align-items-center py-1 px-2"},[e.createElementVNode("small",Pe,e.toDisplayString($(o)),1),l.disabled?e.createCommentVNode("",!0):(e.openBlock(),e.createBlock(B,{key:0,name:"times",class:"chip-remove flex-shrink-0",onClick:e.withModifiers(r=>ee(o),["stop"])},null,8,["onClick"]))]))),128))])],512)):e.createCommentVNode("",!0),x.value?(e.openBlock(),e.createElementBlock("div",{key:1,ref_key:"dropdownRef",ref:y,class:"tree-select-dropdown card shadow-lg border-0",onMousedown:a[2]||(a[2]=e.withModifiers(()=>{},["prevent"])),onClick:a[3]||(a[3]=e.withModifiers(()=>{},["stop"])),style:{"z-index":"1050"}},[e.createElementVNode("div",Oe,[l.searchable?e.withDirectives((e.openBlock(),e.createElementBlock("input",{key:0,"onUpdate:modelValue":a[0]||(a[0]=o=>p.value=o),type:"text",class:e.normalizeClass(["form-control tree-search-input",oe.value]),placeholder:"Search...",onKeydown:e.withKeys(e.withModifiers(ot,["prevent"]),["enter"])},null,42,qe)),[[e.vModelText,p.value]]):e.createCommentVNode("",!0),l.sortable&&l.sortOptions.length>0?(e.openBlock(),e.createElementBlock("div",Fe,[e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":a[1]||(a[1]=o=>S.value=o),class:e.normalizeClass(["form-select flex-grow-1",oe.value])},[a[4]||(a[4]=e.createElementVNode("option",{value:null,disabled:""},"Sort by...",-1)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.sortOptions,o=>(e.openBlock(),e.createElementBlock("option",{key:o.value,value:o.value},e.toDisplayString(o.label),9,Re))),128))],2),[[e.vModelSelect,S.value]]),e.createElementVNode("button",{type:"button",class:e.normalizeClass(["btn btn-outline-secondary",ne.value]),disabled:!S.value,onClick:lt},[e.createVNode(B,{name:A.value==="asc"?"asc":"desc"},null,8,["name"])],10,je)])):e.createCommentVNode("",!0)]),l.isLoading?(e.openBlock(),e.createElementBlock("div",He,[e.createVNode(B,{name:"spinner",class:"me-2"}),a[5]||(a[5]=e.createElementVNode("span",null,"Loading...",-1))])):(e.openBlock(),e.createElementBlock("div",Ze,[U.value.length>0?(e.openBlock(),e.createElementBlock("div",Ue,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(U.value,o=>(e.openBlock(),e.createBlock(Ne,{key:h(o),item:o,level:0,"selected-items":N.value,"expanded-items":L.value,multiple:l.multiple,"select-all":l.selectAll,"select-mode":l.selectMode,"option-label":l.optionLabel,"option-value":l.optionValue,"disabled-key":l.disabledKey,"disable-branch-node":l.disableBranchNodes,onSelect:tt,onToggleExpand:de},{default:e.withCtx(({item:r,level:s})=>[e.renderSlot(t.$slots,"default",{item:r,level:s},()=>[e.createElementVNode("div",We,[e.createTextVNode(e.toDisplayString($(r))+" ",1),r.icon?(e.openBlock(),e.createElementBlock("i",{key:0,class:e.normalizeClass(r.icon)},null,2)):e.createCommentVNode("",!0)])],!0)]),_:2},1032,["item","selected-items","expanded-items","multiple","select-all","select-mode","option-label","option-value","disabled-key","disable-branch-node"]))),128))])):(e.openBlock(),e.createElementBlock("div",Ge,[l.allowAddNew?(e.openBlock(),e.createElementBlock("div",Je,[l.addNewMode==="button"?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"btn btn-success btn-sm w-100",onClick:me},[e.createTextVNode(' No items found "Click" to '+e.toDisplayString(l.addNewLabel)+" ",1),p.value.trim()?(e.openBlock(),e.createElementBlock("span",Qe,' : "'+e.toDisplayString(p.value)+'" ',1)):e.createCommentVNode("",!0)])):l.addNewMode==="enter"?(e.openBlock(),e.createElementBlock("span",Xe,[e.createTextVNode(' No items found "Press Enter" to '+e.toDisplayString(l.addNewLabel)+" ",1),p.value.trim()?(e.openBlock(),e.createElementBlock("span",Ye,' : "'+e.toDisplayString(p.value)+'" ',1)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)])):(e.openBlock(),e.createElementBlock("div",ve,[e.createVNode(B,{name:"search",class:"me-1"}),a[6]||(a[6]=e.createTextVNode(" No items found ",-1))]))]))]))],544)):e.createCommentVNode("",!0),g.value?(e.openBlock(),e.createElementBlock("div",{key:2,ref_key:"tooltipRef",ref:f,class:"tree-select-tooltip card shadow-sm py-1 px-2",role:"tooltip",style:{"z-index":"1070"}},e.toDisplayString(Q.value),513)):e.createCommentVNode("",!0)],544))}},[["__scopeId","data-v-9ede757e"]]),_e={install(l){l.component("VSelect",le)}};w.VSelect=le,w.default=_e,Object.defineProperties(w,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
|
|
1
|
+
(function(w,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue"),require("@popperjs/core")):typeof define=="function"&&define.amd?define(["exports","vue","@popperjs/core"],e):(w=typeof globalThis<"u"?globalThis:w||self,e(w.VueSelect={},w.Vue,w.Popper))})(this,(function(w,e,Q){"use strict";const X=(l,I)=>{const n=l.__vccOpts||l;for(const[m,i]of I)n[m]=i;return n},ge={key:0},ye={key:1},ke={key:2},be={key:3},Be={key:4},Ve={key:5},we={key:6},xe={key:7},B=X({__name:"SvgIcon",props:{name:{type:String,required:!0}},setup(l){const I=l,n=e.computed(()=>({"svg-icon-spin":I.name==="spinner"}));return(m,i)=>(e.openBlock(),e.createElementBlock("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",width:"1em",height:"1em",class:e.normalizeClass(n.value)},[l.name==="spinner"?(e.openBlock(),e.createElementBlock("g",ge,i[0]||(i[0]=[e.createElementVNode("path",{d:"M12,4V2A10,10,0,0,0,2,12H4A8,8,0,0,1,12,4Z"},null,-1)]))):e.createCommentVNode("",!0),l.name==="times"?(e.openBlock(),e.createElementBlock("g",ye,i[1]||(i[1]=[e.createElementVNode("path",{d:"M13.41,12l4.3-4.29a1,1,0,1,0-1.42-1.42L12,10.59,7.71,6.29A1,1,0,0,0,6.29,7.71L10.59,12l-4.3,4.29a1,1,0,0,0,0,1.42,1,1,0,0,0,1.42,0L12,13.41l4.29,4.3a1,1,0,0,0,1.42,0,1,1,0,0,0,0-1.42Z"},null,-1)]))):e.createCommentVNode("",!0),l.name==="chevron-down"?(e.openBlock(),e.createElementBlock("g",ke,i[2]||(i[2]=[e.createElementVNode("path",{d:"M17,9.17a1,1,0,0,0-1.41,0L12,12.71,8.46,9.17a1,1,0,0,0-1.41,0,1,1,0,0,0,0,1.42l4.24,4.24a1,1,0,0,0,1.42,0L17,10.59A1,1,0,0,0,17,9.17Z"},null,-1)]))):e.createCommentVNode("",!0),l.name==="chevron-right"?(e.openBlock(),e.createElementBlock("g",be,i[3]||(i[3]=[e.createElementVNode("path",{d:"M10.83,12l-4.24,4.24a1,1,0,0,0,1.41,1.41L13.66,12,8,6.34A1,1,0,0,0,6.59,7.76Z"},null,-1)]))):e.createCommentVNode("",!0),l.name==="search"?(e.openBlock(),e.createElementBlock("g",Be,i[4]||(i[4]=[e.createElementVNode("path",{d:"M21.71,20.29,18,16.61A9,9,0,1,0,16.61,18l3.68,3.68a1,1,0,0,0,1.42,0A1,1,0,0,0,21.71,20.29ZM11,18a7,7,0,1,1,7-7A7,7,0,0,1,11,18Z"},null,-1)]))):e.createCommentVNode("",!0),l.name==="asc"?(e.openBlock(),e.createElementBlock("g",Ve,i[5]||(i[5]=[e.createElementVNode("path",{fill:"currentColor",d:"M4.869 11H2.667L6 3h2l3.333 8H9.131l-.41-1H5.28zm1.23-3h1.803L7 5.8zm12.9 8V3h-2v13h-3l4 5l4-5zm-8-3H3v2h4.855L3 19v2h8v-2H6.146L11 15z"},null,-1)]))):e.createCommentVNode("",!0),l.name==="desc"?(e.openBlock(),e.createElementBlock("g",we,i[6]||(i[6]=[e.createElementVNode("path",{fill:"currentColor",d:"M4.869 11H2.667L6 3h2l3.333 8H9.131l-.41-1H5.28zm1.23-3h1.803L7 5.8zm15.9 0l-4-5l-4 5h3v13h2V8zm-11 5H3v2h4.855L3 19v2h8v-2H6.146L11 15z"},null,-1)]))):e.createCommentVNode("",!0),l.name==="info-circle"?(e.openBlock(),e.createElementBlock("g",xe,i[7]||(i[7]=[e.createElementVNode("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-6h2v6zm0-8h-2V7h2v2z"},null,-1)]))):e.createCommentVNode("",!0)],2))}},[["__scopeId","data-v-89f9b7e1"]]),Se={class:"tree-select-item-wrapper"},Ce={key:1,class:"expander-placeholder"},Ee=["checked",".indeterminate","disabled"],Ne={class:"item-content"},Le={key:0,class:"children-wrapper"},Me=X({__name:"TreeSelectItem",props:{item:{type:Object,required:!0},level:{type:Number,required:!0},selectedItems:{type:Array,required:!0},expandedItems:{type:Set,required:!0},multiple:{type:Boolean,required:!0},selectAll:{type:Boolean,required:!0},selectMode:{type:String,required:!0},optionLabel:{type:String,required:!0},optionValue:{type:String,required:!0},disabledKey:{type:String,default:null},disableBranchNode:{type:Boolean,default:!1}},emits:["select","toggle-expand"],setup(l,{emit:I}){const n=l,m=c=>c[n.optionValue]||c.id||c.value,i=c=>!n.disabledKey||!c?!1:c.hasOwnProperty(n.disabledKey)&&c[n.disabledKey]!==null,y=e.computed(()=>n.item.children&&n.item.children.length>0),C=e.computed(()=>n.expandedItems.has(m(n.item))),p=e.computed(()=>n.selectedItems.includes(m(n.item))),x=c=>{let f=[];return c.children&&c.children.forEach(S=>{f.push(m(S)),f.push(...x(S))}),f},N=e.computed(()=>!n.multiple||!n.selectAll||!y.value||p.value?!1:x(n.item).some(f=>n.selectedItems.includes(f)));return(c,f)=>{const S=e.resolveComponent("TreeSelectItem",!0);return e.openBlock(),e.createElementBlock("div",Se,[e.createElementVNode("div",{class:e.normalizeClass(["list-group-item list-group-item-action d-flex align-items-center gap-2",{"bg-primary text-white":p.value&&(l.selectMode==="highlight"||!l.multiple)&&!i(l.item)&&!(l.disableBranchNode&&y.value),"is-disabled text-muted bg-light":i(l.item)}]),style:e.normalizeStyle({"padding-left":`${l.level*1.5+1}rem`}),onClick:f[2]||(f[2]=g=>i(l.item)?null:c.$emit("select",l.item))},[y.value?(e.openBlock(),e.createBlock(B,{key:0,name:"chevron-right",class:e.normalizeClass(["expander-icon",{"rotate-90":C.value}]),onClick:f[0]||(f[0]=e.withModifiers(g=>c.$emit("toggle-expand",m(l.item)),["stop"]))},null,8,["class"])):(e.openBlock(),e.createElementBlock("span",Ce)),l.multiple&&l.selectMode==="checkbox"&&!(l.disableBranchNode&&y.value)?(e.openBlock(),e.createElementBlock("input",{key:2,type:"checkbox",class:"form-check-input",checked:p.value,".indeterminate":N.value,disabled:i(l.item),onClick:f[1]||(f[1]=e.withModifiers(g=>c.$emit("select",l.item),["stop"]))},null,40,Ee)):e.createCommentVNode("",!0),e.createElementVNode("div",Ne,[e.renderSlot(c.$slots,"default",{item:l.item,level:l.level},void 0,!0)])],6),y.value&&C.value?(e.openBlock(),e.createElementBlock("div",Le,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.item.children,g=>(e.openBlock(),e.createBlock(S,{key:m(g),item:g,level:l.level+1,"selected-items":l.selectedItems,"expanded-items":l.expandedItems,multiple:l.multiple,"select-all":l.selectAll,"select-mode":l.selectMode,"option-label":l.optionLabel,"option-value":l.optionValue,"disabled-key":l.disabledKey,"disable-branch-node":l.disableBranchNode,onSelect:f[3]||(f[3]=V=>c.$emit("select",V)),onToggleExpand:f[4]||(f[4]=V=>c.$emit("toggle-expand",V))},{default:e.withCtx(({item:V,level:F})=>[e.renderSlot(c.$slots,"default",{item:V,level:F},void 0,!0)]),_:2},1032,["item","level","selected-items","expanded-items","multiple","select-all","select-mode","option-label","option-value","disabled-key","disable-branch-node"]))),128))])):e.createCommentVNode("",!0)])}}},[["__scopeId","data-v-b319a2c7"]]),Ie=["onKeydown"],$e={class:"tree-select-display-container"},Ae={key:0,class:"d-flex align-items-center justify-content-start w-100"},Te=["title"],ze={key:1},De={key:0,class:"text-muted"},Ke={key:1,class:"chips-container"},Pe={class:"d-flex align-items-center gap-2"},Oe={class:"list-group list-group-flush"},Re={class:"text-wrap text-start me-2"},qe={class:"p-2 border-bottom d-flex flex-column gap-2"},Fe=["onKeydown"],je={key:1,class:"d-flex align-items-center gap-2"},He=["value"],Ze=["disabled"],We={key:0,class:"p-4 text-muted text-center"},Ue={key:1,class:"tree-select-body",style:{"max-height":"300px","overflow-y":"auto"}},Ge={key:0,class:"list-group list-group-flush"},Je={class:"d-flex align-items-center gap-2",style:{"white-space":"wrap"}},Qe={key:1,class:"p-3 text-muted text-center"},Xe={key:0},Ye={key:0},ve={key:1},_e={key:0},et={key:1},ne=X({__name:"TreeSelectMain",props:{modelValue:{type:[String,Number,Array],default:null},displayMode:{type:String,default:"text",validator:l=>["text","chips"].includes(l)},items:{type:Array,default:()=>[]},multiple:{type:Boolean,default:!1},selectMode:{type:String,default:"checkbox",validator:l=>["checkbox","highlight"].includes(l)},placeholder:{type:String,default:"Select item..."},isInvalid:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},searchable:{type:Boolean,default:!0},isLoading:{type:Boolean,default:!1},showClearButton:{type:Boolean,default:!0},selectAll:{type:Boolean,default:!1},deselectAll:{type:Boolean,default:!0},canDeselect:{type:Boolean,default:!0},optionLabel:{type:String,default:"value"},optionValue:{type:String,default:"code"},disabledKey:{type:String,default:null},excludeFromSelectedListKey:{type:String,default:null},disableBranchNodes:{type:Boolean,default:!1},size:{type:String,default:"sm",validator:l=>["sm","md","lg","xl"].includes(l)},sortable:{type:Boolean,default:!1},sortOptions:{type:Array,default:()=>[]},defaultSortKey:{type:String,default:null},defaultSortDirection:{type:String,default:"asc",validator:l=>["asc","desc"].includes(l)},maxVisibleChipsDisplay:{type:Number,default:3},closeOnSelect:{type:Boolean,default:!0},allowAddNew:{type:Boolean,default:!1},addNewMode:{type:String,default:"button",validator:l=>["button","enter"].includes(l)},addNewLabel:{type:String,default:"Add new record"}},emits:["update:modelValue","change","clear","deselect","select","focus","blur","add-new"],setup(l,{emit:I}){const n=l,m=I,i=e.ref(null),y=e.ref(null),C=e.ref(null),p=e.ref(""),x=e.ref(!1),N=e.ref(new Set),c=e.ref(null),f=e.ref(null),S=e.ref(null),g=e.ref(!1),V=e.ref(null),F=e.ref(null),A=e.ref(!1),L=e.ref(n.defaultSortKey),T=e.ref(n.defaultSortDirection),z=e.ref(null),j=e.ref(null),D=e.ref(!1),H=e.ref(null),oe=e.computed(()=>n.size==="sm"?"btn-sm":n.size==="lg"?"btn-lg":n.size==="xl"?"btn-xl":""),ae=e.computed(()=>n.size==="sm"?"form-control-sm":n.size==="lg"?"form-control-lg":n.size==="xl"?"form-control-xl":""),lt=e.computed(()=>U.value===0?[]:W.value.slice(n.maxVisibleChipsDisplay)),K=e.computed(()=>!n.multiple||!n.excludeFromSelectedListKey?E.value:E.value.filter(t=>{const a=P(t);return!a||!a[n.excludeFromSelectedListKey]})),re=e.computed(()=>{const t=K.value;if(t.length===0)return n.placeholder;if(n.multiple){if(t.length===1){const o=O(t[0]);return o?o.join(" → "):t[0]}return`${t.length} items selected`}const a=O(t[0]);return a?a.join(" → "):t[0]}),se=async()=>{await e.nextTick();const t=F.value;if(n.multiple||n.displayMode==="chips"||K.value.length===0||!t){A.value=!1;return}A.value=t.scrollWidth>t.clientWidth},$=t=>t&&(t[n.optionLabel]||t.label||t.name)||"",h=t=>t?t[n.optionValue]||t.id||t.value:null,Y=t=>!n.disabledKey||!t?!1:t.hasOwnProperty(n.disabledKey)&&t[n.disabledKey]!==null,k=t=>t.children&&t.children.length>0,Z=(t,a)=>{if(a)return a.split(".").reduce((o,r)=>o&&o[r],t)},P=(t,a=n.items)=>{for(const o of a){if(h(o)===t)return o;if(k(o)){const r=P(t,o.children);if(r)return r}}return null},v=t=>{const a=[];return k(t)&&t.children.forEach(o=>{Y(o)||(a.push(h(o)),a.push(...v(o)))}),a},_=(t,a=n.items,o=[])=>{for(const r of a){if(h(r)===t)return o;if(k(r)){const s=_(t,r.children,[...o,h(r)]);if(s)return s}}return null},E=e.computed(()=>{const t=new Set(Array.isArray(n.modelValue)?n.modelValue:[n.modelValue].filter(Boolean));if(n.multiple&&n.selectAll){const a=o=>{o.forEach(r=>{if(k(r)){const s=r.children.filter(u=>!Y(u));s.length>0&&s.every(u=>t.has(h(u)))&&t.add(h(r)),a(r.children)}})};a(n.items)}return Array.from(t)}),O=(t,a=n.items,o=[])=>{for(const r of a){const s=[...o,$(r)];if(h(r)===t)return s;if(k(r)){const d=O(t,r.children,s);if(d)return d}}return null},ie=t=>{if(!t||t.length===0)return"";const a=t.join(" → ");return a.length<=40?a:t.length>2?`${t[0]} → ... → ${t[t.length-1]}`:a},ee=e.computed(()=>{const t=K.value;if(t.length===0)return n.placeholder;if(n.multiple){if(t.length===1){const o=O(t[0]);return o?ie(o):t[0]}return`${t.length} items selected`}const a=O(t[0]);return a?ie(a):t[0]}),W=e.computed(()=>{if(!n.multiple||K.value.length===0)return[];const t=K.value.map(r=>P(r)).filter(Boolean);if(!n.sortable||!L.value)return t;const a=L.value,o=T.value;return[...t].sort((r,s)=>{const d=Z(r,a),u=Z(s,a);if(d==null)return 1;if(u==null)return-1;let b=0;return typeof d=="string"&&typeof u=="string"?b=d.localeCompare(u):d>u?b=1:d<u&&(b=-1),o==="desc"?b*-1:b})}),ce=e.computed(()=>W.value.slice(0,n.maxVisibleChipsDisplay)),U=e.computed(()=>{const t=W.value.length-n.maxVisibleChipsDisplay;return t>0?t:0}),de=(t,a)=>t.map(o=>{const r=$(o).toLowerCase().includes(a);if(!k(o))return r?o:null;const s=de(o.children,a);return r?{...o,children:o.children}:s.length>0?{...o,children:s}:null}).filter(Boolean),me=(t,a,o)=>!t||!a?t:[...t].sort((s,d)=>{const u=Z(s,a),b=Z(d,a);if(u==null)return 1;if(b==null)return-1;let q=0;return typeof u=="string"&&typeof b=="string"?q=u.localeCompare(b):u>b?q=1:u<b&&(q=-1),o==="desc"?q*-1:q}).map(s=>k(s)?{...s,children:me(s.children,a,o)}:s),G=e.computed(()=>{const t=p.value.trim()?de(n.items,p.value.toLowerCase()):n.items;return!n.sortable||!L.value?t:me(t,L.value,T.value)}),nt=t=>{if(n.disableBranchNodes&&k(t)){const s=h(t);ue(s);return}if(Y(t))return;const a=h(t);let o=new Set(E.value);if(n.multiple){const s=o.has(a);if(n.selectAll&&k(t)){const d=v(t);s?(o.delete(a),m("deselect",t),n.deselectAll&&d.forEach(u=>o.delete(u))):(o.add(a),d.forEach(u=>o.add(u)),m("select",t))}else s?(o.delete(a),n.selectAll&&_(a)?.forEach(u=>o.delete(u))):o.add(a)}else{const s=n.modelValue,d=h(t);s===d?(o.clear(),m("deselect",t)):(o.clear(),o.add(d),s!=null&&P(s),m("select",t)),n.closeOnSelect&&M(),e.nextTick(()=>{C.value?.focus()})}let r=Array.from(o);n.multiple&&n.excludeFromSelectedListKey&&(r=r.filter(s=>{const d=P(s);return!d||!d[n.excludeFromSelectedListKey]})),m("update:modelValue",n.multiple?r:r[0]||null),m("change",n.multiple?r:r[0]||null)},te=t=>{if(n.disabled||!t)return;const a=h(t),o=new Set(E.value);o.delete(a),n.selectAll&&(n.deselectAll&&k(t)&&v(t).forEach(u=>o.delete(u)),_(a)?.forEach(d=>o.delete(d)));const r=Array.from(o);m("update:modelValue",r),m("change",r)},ue=t=>{N.value.has(t)?N.value.delete(t):N.value.add(t)},ot=()=>{T.value=T.value==="asc"?"desc":"asc"},at=()=>{const t=n.multiple?[]:null;m("clear"),m("update:modelValue",t),m("change",t),R()},fe=()=>{!n.allowAddNew||!p.value.trim()||(m("add-new",p.value.trim()),M())},rt=()=>{n.allowAddNew&&n.addNewMode==="enter"&&p.value.trim()&&G.value.length===0&&fe()},st=t=>{m("focus",t)},it=async()=>{n.disabled||(R(),x.value=!0,J(),await e.nextTick(),y.value&&C.value&&(c.value=Q.createPopper(C.value,y.value,{placement:"bottom-start",strategy:"fixed",modifiers:[{name:"offset",options:{offset:[0,4]}},{name:"preventOverflow",options:{padding:8}},{name:"flip",options:{fallbackPlacements:["top-start"]}},{name:"sameWidth",enabled:!0,phase:"beforeWrite",requires:["computeStyles"],fn:({state:t})=>{t.styles.popper.width=`${t.rects.reference.width}px`},effect:({state:t})=>{t.elements.popper.style.width=`${t.elements.reference.offsetWidth}px`}}]})),n.searchable&&(await e.nextTick(),y.value?.querySelector(".tree-search-input")?.focus()))},M=()=>{x.value=!1,p.value="",c.value?.destroy(),c.value=null,m("blur",n.modelValue)},le=()=>x.value?M():it(),ct=async()=>{M(),J(),D.value=!0,await e.nextTick(),j.value&&z.value&&(H.value=Q.createPopper(z.value,j.value,{placement:"bottom-end",strategy:"fixed",modifiers:[{name:"offset",options:{offset:[0,4]}}]}))},R=()=>{D.value=!1,H.value?.destroy(),H.value=null},pe=()=>D.value?R():ct(),he=t=>{x.value&&!C.value?.contains(t.target)&&!y.value?.contains(t.target)&&M(),D.value&&!z.value?.contains(t.target)&&!j.value?.contains(t.target)&&R(),g.value&&!V.value?.$el?.contains(t.target)&&!f.value?.contains(t.target)&&J()},dt=t=>{i.value?.contains(t.relatedTarget)||M()},mt=async()=>{!A.value||g.value||(M(),R(),g.value=!0,await e.nextTick(),f.value&&V.value&&(S.value=Q.createPopper(V.value.$el,f.value,{placement:"top",strategy:"fixed",modifiers:[{name:"offset",options:{offset:[0,8]}}]})))},ut=()=>{g.value?J():mt()},J=()=>{g.value=!1,S.value?.destroy(),S.value=null};return e.watch(p,t=>{if(t.trim()){const a=o=>{o.forEach(r=>{k(r)&&(N.value.add(h(r)),a(r.children))})};a(G.value)}}),e.watch(ee,()=>{se()}),e.onMounted(()=>{document.addEventListener("click",he),se()}),e.onUnmounted(()=>{document.removeEventListener("click",he),c.value?.destroy(),H.value?.destroy(),S.value?.destroy()}),(t,a)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"wrapperRef",ref:i,class:"tree-select-wrapper",onFocusin:st,onFocusout:dt},[e.createElementVNode("div",{ref_key:"triggerRef",ref:C,role:"button",tabindex:"0",class:e.normalizeClass(["btn tree-select-trigger w-100 d-flex justify-content-between align-items-center tree-select-main",[oe.value,{"btn-outline-secondary":!l.isInvalid,"border-danger":l.isInvalid,disabled:l.disabled||l.isLoading,"is-loading":l.isLoading,"has-chips":l.multiple&&l.displayMode==="chips"&&E.value.length>0}]]),onClick:le,onKeydown:[e.withKeys(e.withModifiers(le,["prevent"]),["enter"]),e.withKeys(e.withModifiers(le,["prevent"]),["space"])]},[e.createElementVNode("div",$e,[e.renderSlot(t.$slots,"display",{selectedItems:W.value,displayText:ee.value,placeholder:l.placeholder,isLoading:l.isLoading,removeItem:te,getItemLabel:$,getItemValue:h,visibleChips:ce.value,hiddenChipsCount:U.value,toggleMorePopover:pe,moreTriggerRef:z.value},()=>[!l.multiple||l.displayMode==="text"?(e.openBlock(),e.createElementBlock("div",Ae,[e.createElementVNode("span",{ref_key:"textDisplaySpanRef",ref:F,class:"text-truncate",title:A.value?re.value:""},e.toDisplayString(l.isLoading?"Loading data...":ee.value),9,Te),A.value&&!l.isLoading?(e.openBlock(),e.createBlock(B,{key:0,ref_key:"tooltipTriggerIconRef",ref:V,name:"info-circle",class:"tooltip-trigger-icon ms-2 flex-shrink-0",onClick:e.withModifiers(ut,["stop"])},null,512)):e.createCommentVNode("",!0)])):l.multiple&&l.displayMode==="chips"?(e.openBlock(),e.createElementBlock("div",ze,[E.value.length===0?(e.openBlock(),e.createElementBlock("span",De,e.toDisplayString(l.placeholder),1)):(e.openBlock(),e.createElementBlock("div",Ke,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(ce.value,o=>(e.openBlock(),e.createElementBlock("span",{key:h(o),class:"badge text-bg-primary chip bg-primary"},[e.createTextVNode(e.toDisplayString($(o))+" ",1),e.createVNode(B,{name:"times",class:"chip-remove",onClick:e.withModifiers(r=>te(o),["stop"])},null,8,["onClick"])]))),128)),U.value>0?(e.openBlock(),e.createElementBlock("button",{key:0,ref_key:"moreTriggerRef",ref:z,type:"button",class:"btn btn-sm btn-light more-button",onClick:e.withModifiers(pe,["stop"])}," +"+e.toDisplayString(U.value),513)):e.createCommentVNode("",!0)]))])):e.createCommentVNode("",!0)],!0)]),e.createElementVNode("div",Pe,[l.isLoading?(e.openBlock(),e.createBlock(B,{key:0,name:"spinner",class:"loading-icon"})):e.createCommentVNode("",!0),l.showClearButton&&E.value.length>0&&!l.disabled&&!l.isLoading?(e.openBlock(),e.createBlock(B,{key:1,name:"times",onClick:e.withModifiers(at,["stop"]),class:"clear-icon"})):e.createCommentVNode("",!0),l.isLoading?e.createCommentVNode("",!0):(e.openBlock(),e.createBlock(B,{key:2,name:"chevron-down",class:e.normalizeClass(["transition-transform",{"rotate-180":x.value}])},null,8,["class"]))])],42,Ie),D.value?(e.openBlock(),e.createElementBlock("div",{key:0,ref_key:"morePopoverRef",ref:j,class:"card shadow-lg border-0 more-popover",style:{"z-index":"1060"}},[e.createElementVNode("div",Oe,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(lt.value,o=>(e.openBlock(),e.createElementBlock("div",{key:h(o),class:"list-group-item d-flex justify-content-between align-items-center py-1 px-2"},[e.createElementVNode("small",Re,e.toDisplayString($(o)),1),l.disabled?e.createCommentVNode("",!0):(e.openBlock(),e.createBlock(B,{key:0,name:"times",class:"chip-remove flex-shrink-0",onClick:e.withModifiers(r=>te(o),["stop"])},null,8,["onClick"]))]))),128))])],512)):e.createCommentVNode("",!0),x.value?(e.openBlock(),e.createElementBlock("div",{key:1,ref_key:"dropdownRef",ref:y,class:"tree-select-dropdown card shadow-lg border-0",onMousedown:a[2]||(a[2]=e.withModifiers(()=>{},["prevent"])),onClick:a[3]||(a[3]=e.withModifiers(()=>{},["stop"])),style:{"z-index":"1050"}},[e.createElementVNode("div",qe,[l.searchable?e.withDirectives((e.openBlock(),e.createElementBlock("input",{key:0,"onUpdate:modelValue":a[0]||(a[0]=o=>p.value=o),type:"text",class:e.normalizeClass(["form-control tree-search-input",ae.value]),placeholder:"Search...",onKeydown:e.withKeys(e.withModifiers(rt,["prevent"]),["enter"])},null,42,Fe)),[[e.vModelText,p.value]]):e.createCommentVNode("",!0),l.sortable&&l.sortOptions.length>0?(e.openBlock(),e.createElementBlock("div",je,[e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":a[1]||(a[1]=o=>L.value=o),class:e.normalizeClass(["form-select flex-grow-1",ae.value])},[a[4]||(a[4]=e.createElementVNode("option",{value:null,disabled:""},"Sort by...",-1)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.sortOptions,o=>(e.openBlock(),e.createElementBlock("option",{key:o.value,value:o.value},e.toDisplayString(o.label),9,He))),128))],2),[[e.vModelSelect,L.value]]),e.createElementVNode("button",{type:"button",class:e.normalizeClass(["btn btn-outline-secondary",oe.value]),disabled:!L.value,onClick:ot},[e.createVNode(B,{name:T.value==="asc"?"asc":"desc"},null,8,["name"])],10,Ze)])):e.createCommentVNode("",!0)]),l.isLoading?(e.openBlock(),e.createElementBlock("div",We,[e.createVNode(B,{name:"spinner",class:"me-2"}),a[5]||(a[5]=e.createElementVNode("span",null,"Loading...",-1))])):(e.openBlock(),e.createElementBlock("div",Ue,[G.value.length>0?(e.openBlock(),e.createElementBlock("div",Ge,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(G.value,o=>(e.openBlock(),e.createBlock(Me,{key:h(o),item:o,level:0,"selected-items":E.value,"expanded-items":N.value,multiple:l.multiple,"select-all":l.selectAll,"select-mode":l.selectMode,"option-label":l.optionLabel,"option-value":l.optionValue,"disabled-key":l.disabledKey,"disable-branch-node":l.disableBranchNodes,onSelect:nt,onToggleExpand:ue},{default:e.withCtx(({item:r,level:s})=>[e.renderSlot(t.$slots,"default",{item:r,level:s},()=>[e.createElementVNode("div",Je,[e.createTextVNode(e.toDisplayString($(r))+" ",1),r.icon?(e.openBlock(),e.createElementBlock("i",{key:0,class:e.normalizeClass(r.icon)},null,2)):e.createCommentVNode("",!0)])],!0)]),_:2},1032,["item","selected-items","expanded-items","multiple","select-all","select-mode","option-label","option-value","disabled-key","disable-branch-node"]))),128))])):(e.openBlock(),e.createElementBlock("div",Qe,[l.allowAddNew?(e.openBlock(),e.createElementBlock("div",Xe,[l.addNewMode==="button"?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"btn btn-success btn-sm w-100",onClick:fe},[e.createTextVNode(' No items found "Click" to '+e.toDisplayString(l.addNewLabel)+" ",1),p.value.trim()?(e.openBlock(),e.createElementBlock("span",Ye,' : "'+e.toDisplayString(p.value)+'" ',1)):e.createCommentVNode("",!0)])):l.addNewMode==="enter"?(e.openBlock(),e.createElementBlock("span",ve,[e.createTextVNode(' No items found "Press Enter" to '+e.toDisplayString(l.addNewLabel)+" ",1),p.value.trim()?(e.openBlock(),e.createElementBlock("span",_e,' : "'+e.toDisplayString(p.value)+'" ',1)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)])):(e.openBlock(),e.createElementBlock("div",et,[e.createVNode(B,{name:"search",class:"me-1"}),a[6]||(a[6]=e.createTextVNode(" No items found ",-1))]))]))]))],544)):e.createCommentVNode("",!0),e.withDirectives(e.createElementVNode("div",{ref_key:"tooltipRef",ref:f,class:"tree-select-tooltip card shadow-sm py-1 px-2",role:"tooltip",style:{"z-index":"1070"}},e.toDisplayString(re.value),513),[[e.vShow,g.value]])],544))}},[["__scopeId","data-v-c318f0b9"]]),tt={install(l){l.component("VSelect",ne)}};w.VSelect=ne,w.default=tt,Object.defineProperties(w,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
|