@night-owl-elite/vue-select 1.3.14 → 1.3.15
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 +274 -204
- package/dist/vue-select.umd.js +1 -1
- package/package.json +1 -1
package/dist/vue-select.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
@keyframes spin-
|
|
1
|
+
@keyframes spin-d347d13a{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.svg-icon-spin[data-v-d347d13a]{animation:spin-d347d13a 1s linear infinite}.list-group-item[data-v-9766821f]{cursor:pointer;border:0;border-radius:0;padding-top:.5rem;padding-bottom:.5rem}.list-group-item.is-disabled[data-v-9766821f]{cursor:not-allowed;opacity:.65}.expander-icon[data-v-9766821f]{width:1rem;height:1rem;flex-shrink:0;transition:transform .2s ease-in-out;color:#6c757d}.expander-placeholder[data-v-9766821f]{display:inline-block;width:1rem;flex-shrink:0}.rotate-90[data-v-9766821f]{transform:rotate(90deg)}.item-content[data-v-9766821f]{flex-grow:1}.tree-select-main[data-v-20a84e1a]{--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}.tree-select-display-text[data-v-20a84e1a]{flex:1;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.clear-icon[data-v-20a84e1a]{cursor:pointer;opacity:.6;transition:opacity .2s ease}.clear-icon[data-v-20a84e1a]:hover{opacity:1}.transition-transform[data-v-20a84e1a]{transition:transform .2s ease-in-out}.rotate-180[data-v-20a84e1a]{transform:rotate(180deg)}.tree-select-dropdown[data-v-20a84e1a]{position:absolute;background:#fff;border:1px solid rgba(0,0,0,.15);border-radius:.375rem}.tree-select-body[data-v-20a84e1a]::-webkit-scrollbar{width:6px}.tree-select-body[data-v-20a84e1a]::-webkit-scrollbar-track{background:#f1f1f1;border-radius:3px}.tree-select-body[data-v-20a84e1a]::-webkit-scrollbar-thumb{background:#c1c1c1;border-radius:3px}.tree-select-body[data-v-20a84e1a]::-webkit-scrollbar-thumb:hover{background:#a8a8a8}.is-loading[data-v-20a84e1a]{cursor:wait}.loading-icon[data-v-20a84e1a]{opacity:.7}.btn-xl[data-v-20a84e1a]{padding:.75rem 1.5rem;font-size:1.25rem;border-radius:var(--bs-border-radius-lg)}.form-control-xl[data-v-20a84e1a]{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)}@media (max-width: 576px){.tree-select-dropdown[data-v-20a84e1a]{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 b, createElementBlock as u, openBlock as i, normalizeClass as L, createCommentVNode as
|
|
2
|
-
import { createPopper as
|
|
3
|
-
const
|
|
1
|
+
import { computed as b, createElementBlock as u, openBlock as i, normalizeClass as L, createCommentVNode as f, createElementVNode as m, resolveComponent as me, normalizeStyle as fe, createBlock as M, withModifiers as Z, renderSlot as R, Fragment as F, renderList as j, withCtx as ae, ref as B, onMounted as he, onUnmounted as ve, watch as ge, toDisplayString as O, withDirectives as le, vModelText as ye, vModelSelect as pe, createVNode as P, createTextVNode as ne, nextTick as se } from "vue";
|
|
2
|
+
import { createPopper as be } from "@popperjs/core";
|
|
3
|
+
const U = (t, A) => {
|
|
4
4
|
const l = t.__vccOpts || t;
|
|
5
|
-
for (const [
|
|
6
|
-
l[
|
|
5
|
+
for (const [v, r] of A)
|
|
6
|
+
l[v] = r;
|
|
7
7
|
return l;
|
|
8
|
-
},
|
|
8
|
+
}, xe = { key: 0 }, Se = { key: 1 }, ke = { key: 2 }, we = { key: 3 }, Le = { key: 4 }, Ve = { key: 5 }, Ie = { key: 6 }, Be = {
|
|
9
9
|
__name: "SvgIcon",
|
|
10
10
|
props: {
|
|
11
11
|
name: {
|
|
@@ -14,10 +14,10 @@ const P = (t, B) => {
|
|
|
14
14
|
}
|
|
15
15
|
},
|
|
16
16
|
setup(t) {
|
|
17
|
-
const
|
|
18
|
-
"svg-icon-spin":
|
|
17
|
+
const A = t, l = b(() => ({
|
|
18
|
+
"svg-icon-spin": A.name === "spinner"
|
|
19
19
|
}));
|
|
20
|
-
return (
|
|
20
|
+
return (v, r) => (i(), u("svg", {
|
|
21
21
|
xmlns: "http://www.w3.org/2000/svg",
|
|
22
22
|
viewBox: "0 0 24 24",
|
|
23
23
|
fill: "currentColor",
|
|
@@ -25,30 +25,42 @@ const P = (t, B) => {
|
|
|
25
25
|
height: "1em",
|
|
26
26
|
class: L(l.value)
|
|
27
27
|
}, [
|
|
28
|
-
t.name === "spinner" ? (i(), u("g",
|
|
29
|
-
|
|
30
|
-
]))) :
|
|
31
|
-
t.name === "times" ? (i(), u("g",
|
|
32
|
-
|
|
33
|
-
]))) :
|
|
34
|
-
t.name === "chevron-down" ? (i(), u("g",
|
|
35
|
-
|
|
36
|
-
]))) :
|
|
37
|
-
t.name === "chevron-right" ? (i(), u("g",
|
|
38
|
-
|
|
39
|
-
]))) :
|
|
40
|
-
t.name === "search" ? (i(), u("g",
|
|
41
|
-
|
|
42
|
-
]))) :
|
|
28
|
+
t.name === "spinner" ? (i(), u("g", xe, r[0] || (r[0] = [
|
|
29
|
+
m("path", { d: "M12,4V2A10,10,0,0,0,2,12H4A8,8,0,0,1,12,4Z" }, null, -1)
|
|
30
|
+
]))) : f("", !0),
|
|
31
|
+
t.name === "times" ? (i(), u("g", Se, r[1] || (r[1] = [
|
|
32
|
+
m("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
|
+
]))) : f("", !0),
|
|
34
|
+
t.name === "chevron-down" ? (i(), u("g", ke, r[2] || (r[2] = [
|
|
35
|
+
m("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
|
+
]))) : f("", !0),
|
|
37
|
+
t.name === "chevron-right" ? (i(), u("g", we, r[3] || (r[3] = [
|
|
38
|
+
m("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
|
+
]))) : f("", !0),
|
|
40
|
+
t.name === "search" ? (i(), u("g", Le, r[4] || (r[4] = [
|
|
41
|
+
m("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
|
+
]))) : f("", !0),
|
|
43
|
+
t.name === "asc" ? (i(), u("g", Ve, r[5] || (r[5] = [
|
|
44
|
+
m("path", {
|
|
45
|
+
fill: "currentColor",
|
|
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
|
+
}, null, -1)
|
|
48
|
+
]))) : f("", !0),
|
|
49
|
+
t.name === "desc" ? (i(), u("g", Ie, r[6] || (r[6] = [
|
|
50
|
+
m("path", {
|
|
51
|
+
fill: "currentColor",
|
|
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
|
+
}, null, -1)
|
|
54
|
+
]))) : f("", !0)
|
|
43
55
|
], 2));
|
|
44
56
|
}
|
|
45
|
-
},
|
|
57
|
+
}, C = /* @__PURE__ */ U(Be, [["__scopeId", "data-v-d347d13a"]]), $e = { class: "tree-select-item-wrapper" }, Ce = {
|
|
46
58
|
key: 1,
|
|
47
59
|
class: "expander-placeholder"
|
|
48
|
-
},
|
|
60
|
+
}, Ae = ["checked", ".indeterminate", "disabled"], ze = { class: "item-content" }, Me = {
|
|
49
61
|
key: 0,
|
|
50
62
|
class: "children-wrapper"
|
|
51
|
-
},
|
|
63
|
+
}, Ee = {
|
|
52
64
|
__name: "TreeSelectItem",
|
|
53
65
|
props: {
|
|
54
66
|
item: { type: Object, required: !0 },
|
|
@@ -64,50 +76,50 @@ const P = (t, B) => {
|
|
|
64
76
|
disableBranchNode: { type: Boolean, default: !1 }
|
|
65
77
|
},
|
|
66
78
|
emits: ["select", "toggle-expand"],
|
|
67
|
-
setup(t, { emit:
|
|
68
|
-
const l = t,
|
|
79
|
+
setup(t, { emit: A }) {
|
|
80
|
+
const l = t, v = (d) => d[l.optionValue] || d.id || d.value, r = (d) => !l.disabledKey || !d ? !1 : d.hasOwnProperty(l.disabledKey) && d[l.disabledKey] !== null, p = b(() => l.item.children && l.item.children.length > 0), x = b(() => l.expandedItems.has(v(l.item))), S = b(() => l.selectedItems.includes(v(l.item))), V = (d) => {
|
|
69
81
|
let c = [];
|
|
70
|
-
return d.children && d.children.forEach((
|
|
71
|
-
c.push(
|
|
82
|
+
return d.children && d.children.forEach(($) => {
|
|
83
|
+
c.push(v($)), c.push(...V($));
|
|
72
84
|
}), c;
|
|
73
|
-
},
|
|
85
|
+
}, z = b(() => !l.multiple || !l.selectAll || !p.value || S.value ? !1 : V(l.item).some((c) => l.selectedItems.includes(c)));
|
|
74
86
|
return (d, c) => {
|
|
75
|
-
const
|
|
76
|
-
return i(), u("div",
|
|
77
|
-
|
|
87
|
+
const $ = me("TreeSelectItem", !0);
|
|
88
|
+
return i(), u("div", $e, [
|
|
89
|
+
m("div", {
|
|
78
90
|
class: L(["list-group-item list-group-item-action d-flex align-items-center gap-2", {
|
|
79
|
-
"bg-primary text-white":
|
|
80
|
-
"is-disabled text-muted bg-light":
|
|
91
|
+
"bg-primary text-white": S.value && (t.selectMode === "highlight" || !t.multiple) && !r(t.item) && !(t.disableBranchNode && p.value),
|
|
92
|
+
"is-disabled text-muted bg-light": r(t.item)
|
|
81
93
|
}]),
|
|
82
|
-
style:
|
|
83
|
-
onClick: c[2] || (c[2] = (
|
|
94
|
+
style: fe({ "padding-left": `${t.level * 1.5 + 1}rem` }),
|
|
95
|
+
onClick: c[2] || (c[2] = (I) => r(t.item) || t.disableBranchNode && p.value ? null : d.$emit("select", t.item))
|
|
84
96
|
}, [
|
|
85
|
-
|
|
97
|
+
p.value ? (i(), M(C, {
|
|
86
98
|
key: 0,
|
|
87
99
|
name: "chevron-right",
|
|
88
100
|
class: L(["expander-icon", { "rotate-90": x.value }]),
|
|
89
|
-
onClick: c[0] || (c[0] =
|
|
90
|
-
}, null, 8, ["class"])) : (i(), u("span",
|
|
91
|
-
t.multiple && t.selectMode === "checkbox" && !(t.disableBranchNode &&
|
|
101
|
+
onClick: c[0] || (c[0] = Z((I) => d.$emit("toggle-expand", v(t.item)), ["stop"]))
|
|
102
|
+
}, null, 8, ["class"])) : (i(), u("span", Ce)),
|
|
103
|
+
t.multiple && t.selectMode === "checkbox" && !(t.disableBranchNode && p.value) ? (i(), u("input", {
|
|
92
104
|
key: 2,
|
|
93
105
|
type: "checkbox",
|
|
94
106
|
class: "form-check-input",
|
|
95
|
-
checked:
|
|
96
|
-
".indeterminate":
|
|
97
|
-
disabled:
|
|
98
|
-
onClick: c[1] || (c[1] =
|
|
99
|
-
}, null, 40,
|
|
100
|
-
|
|
101
|
-
|
|
107
|
+
checked: S.value,
|
|
108
|
+
".indeterminate": z.value,
|
|
109
|
+
disabled: r(t.item),
|
|
110
|
+
onClick: c[1] || (c[1] = Z((I) => d.$emit("select", t.item), ["stop"]))
|
|
111
|
+
}, null, 40, Ae)) : f("", !0),
|
|
112
|
+
m("div", ze, [
|
|
113
|
+
R(d.$slots, "default", {
|
|
102
114
|
item: t.item,
|
|
103
115
|
level: t.level
|
|
104
116
|
}, void 0, !0)
|
|
105
117
|
])
|
|
106
118
|
], 6),
|
|
107
|
-
|
|
108
|
-
(i(!0), u(
|
|
109
|
-
key:
|
|
110
|
-
item:
|
|
119
|
+
p.value && x.value ? (i(), u("div", Me, [
|
|
120
|
+
(i(!0), u(F, null, j(t.item.children, (I) => (i(), M($, {
|
|
121
|
+
key: v(I),
|
|
122
|
+
item: I,
|
|
111
123
|
level: t.level + 1,
|
|
112
124
|
"selected-items": t.selectedItems,
|
|
113
125
|
"expanded-items": t.expandedItems,
|
|
@@ -118,41 +130,41 @@ const P = (t, B) => {
|
|
|
118
130
|
"option-value": t.optionValue,
|
|
119
131
|
"disabled-key": t.disabledKey,
|
|
120
132
|
"disable-branch-node": t.disableBranchNode,
|
|
121
|
-
onSelect: c[3] || (c[3] = (
|
|
122
|
-
onToggleExpand: c[4] || (c[4] = (
|
|
133
|
+
onSelect: c[3] || (c[3] = (k) => d.$emit("select", k)),
|
|
134
|
+
onToggleExpand: c[4] || (c[4] = (k) => d.$emit("toggle-expand", k))
|
|
123
135
|
}, {
|
|
124
|
-
default:
|
|
125
|
-
|
|
126
|
-
item:
|
|
127
|
-
level:
|
|
136
|
+
default: ae(({ item: k, level: g }) => [
|
|
137
|
+
R(d.$slots, "default", {
|
|
138
|
+
item: k,
|
|
139
|
+
level: g
|
|
128
140
|
}, void 0, !0)
|
|
129
141
|
]),
|
|
130
142
|
_: 2
|
|
131
143
|
}, 1032, ["item", "level", "selected-items", "expanded-items", "multiple", "select-all", "select-mode", "option-label", "option-value", "disabled-key", "disable-branch-node"]))), 128))
|
|
132
|
-
])) :
|
|
144
|
+
])) : f("", !0)
|
|
133
145
|
]);
|
|
134
146
|
};
|
|
135
147
|
}
|
|
136
|
-
},
|
|
137
|
-
key: 0,
|
|
138
|
-
class: "p-2 border-bottom"
|
|
139
|
-
}, Ae = {
|
|
148
|
+
}, Ke = /* @__PURE__ */ U(Ee, [["__scopeId", "data-v-9766821f"]]), Ne = { class: "tree-select-wrapper" }, qe = ["disabled"], Te = { class: "tree-select-display-text text-truncate me-2 text-start" }, De = { class: "d-flex align-items-center gap-2" }, He = { class: "p-2 border-bottom d-flex flex-column gap-2" }, Oe = {
|
|
140
149
|
key: 1,
|
|
150
|
+
class: "d-flex align-items-center gap-2"
|
|
151
|
+
}, Pe = ["value"], Ze = ["disabled"], Re = {
|
|
152
|
+
key: 0,
|
|
141
153
|
class: "p-4 text-muted text-center"
|
|
142
|
-
},
|
|
143
|
-
key:
|
|
154
|
+
}, Fe = {
|
|
155
|
+
key: 1,
|
|
144
156
|
class: "tree-select-body",
|
|
145
157
|
style: { "max-height": "300px", "overflow-y": "auto" }
|
|
146
|
-
},
|
|
158
|
+
}, je = {
|
|
147
159
|
key: 0,
|
|
148
160
|
class: "list-group list-group-flush"
|
|
149
|
-
},
|
|
161
|
+
}, Ue = {
|
|
150
162
|
class: "d-flex align-items-center gap-2",
|
|
151
163
|
style: { "white-space": "wrap" }
|
|
152
|
-
},
|
|
164
|
+
}, We = {
|
|
153
165
|
key: 1,
|
|
154
166
|
class: "p-3 text-muted text-center"
|
|
155
|
-
},
|
|
167
|
+
}, Ge = {
|
|
156
168
|
__name: "TreeSelectMain",
|
|
157
169
|
props: {
|
|
158
170
|
modelValue: {
|
|
@@ -170,7 +182,6 @@ const P = (t, B) => {
|
|
|
170
182
|
selectMode: {
|
|
171
183
|
type: String,
|
|
172
184
|
default: "checkbox",
|
|
173
|
-
// 'checkbox' or 'highlight'
|
|
174
185
|
validator: (t) => ["checkbox", "highlight"].includes(t)
|
|
175
186
|
},
|
|
176
187
|
placeholder: {
|
|
@@ -225,114 +236,145 @@ const P = (t, B) => {
|
|
|
225
236
|
type: String,
|
|
226
237
|
default: "sm",
|
|
227
238
|
validator: (t) => ["sm", "md", "lg", "xl"].includes(t)
|
|
239
|
+
},
|
|
240
|
+
sortable: {
|
|
241
|
+
type: Boolean,
|
|
242
|
+
default: !1
|
|
243
|
+
},
|
|
244
|
+
sortOptions: {
|
|
245
|
+
type: Array,
|
|
246
|
+
default: () => []
|
|
247
|
+
// e.g., [{ value: 'name', label: 'Name' }, { value: 'details.id', label: 'ID' }]
|
|
248
|
+
},
|
|
249
|
+
defaultSortKey: {
|
|
250
|
+
type: String,
|
|
251
|
+
default: null
|
|
252
|
+
},
|
|
253
|
+
defaultSortDirection: {
|
|
254
|
+
type: String,
|
|
255
|
+
default: "asc",
|
|
256
|
+
validator: (t) => ["asc", "desc"].includes(t)
|
|
228
257
|
}
|
|
229
258
|
},
|
|
230
259
|
emits: ["update:modelValue", "change"],
|
|
231
|
-
setup(t, { emit:
|
|
232
|
-
const l = t,
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
260
|
+
setup(t, { emit: A }) {
|
|
261
|
+
const l = t, v = A, r = B(null), p = B(null), x = B(""), S = B(!1), V = B(/* @__PURE__ */ new Set()), z = B(null), d = B(l.defaultSortKey), c = B(l.defaultSortDirection), $ = b(() => l.size === "sm" ? "btn-sm" : l.size === "lg" ? "btn-lg" : l.size === "xl" ? "btn-xl" : ""), I = b(() => l.size === "sm" ? "form-control-sm" : l.size === "lg" ? "form-control-lg" : l.size === "xl" ? "form-control-xl" : ""), k = (e) => e[l.optionLabel] || e.label || e.name || "", g = (e) => e[l.optionValue] || e.id || e.value, N = (e) => !l.disabledKey || !e ? !1 : e.hasOwnProperty(l.disabledKey) && e[l.disabledKey] !== null, w = (e) => e.children && e.children.length > 0, W = (e, s) => {
|
|
262
|
+
if (s)
|
|
263
|
+
return s.split(".").reduce((n, a) => n && n[a], e);
|
|
264
|
+
}, G = (e, s = l.items) => {
|
|
265
|
+
for (const n of s) {
|
|
266
|
+
if (g(n) === e) return n;
|
|
267
|
+
if (w(n)) {
|
|
268
|
+
const a = G(e, n.children);
|
|
269
|
+
if (a) return a;
|
|
238
270
|
}
|
|
239
271
|
}
|
|
240
272
|
return null;
|
|
241
|
-
},
|
|
242
|
-
const
|
|
243
|
-
return
|
|
244
|
-
|
|
245
|
-
}),
|
|
246
|
-
},
|
|
247
|
-
for (const
|
|
248
|
-
if (
|
|
249
|
-
if (
|
|
250
|
-
const
|
|
251
|
-
if (
|
|
273
|
+
}, J = (e) => {
|
|
274
|
+
const s = [];
|
|
275
|
+
return w(e) && e.children.forEach((n) => {
|
|
276
|
+
N(n) || (s.push(g(n)), s.push(...J(n)));
|
|
277
|
+
}), s;
|
|
278
|
+
}, Q = (e, s = l.items, n = []) => {
|
|
279
|
+
for (const a of s) {
|
|
280
|
+
if (g(a) === e) return n;
|
|
281
|
+
if (w(a)) {
|
|
282
|
+
const o = Q(e, a.children, [...n, g(a)]);
|
|
283
|
+
if (o) return o;
|
|
252
284
|
}
|
|
253
285
|
}
|
|
254
286
|
return null;
|
|
255
|
-
},
|
|
287
|
+
}, q = b(() => {
|
|
256
288
|
const e = new Set(Array.isArray(l.modelValue) ? l.modelValue : [l.modelValue].filter(Boolean));
|
|
257
289
|
if (l.multiple && l.selectAll) {
|
|
258
|
-
const
|
|
259
|
-
n.forEach((
|
|
260
|
-
if (
|
|
261
|
-
const
|
|
262
|
-
|
|
290
|
+
const s = (n) => {
|
|
291
|
+
n.forEach((a) => {
|
|
292
|
+
if (w(a)) {
|
|
293
|
+
const o = a.children.filter((h) => !N(h));
|
|
294
|
+
o.length > 0 && o.every((h) => e.has(g(h))) && e.add(g(a)), s(a.children);
|
|
263
295
|
}
|
|
264
296
|
});
|
|
265
297
|
};
|
|
266
|
-
|
|
298
|
+
s(l.items);
|
|
267
299
|
}
|
|
268
300
|
return Array.from(e);
|
|
269
|
-
}),
|
|
270
|
-
for (const
|
|
271
|
-
const
|
|
272
|
-
if (
|
|
273
|
-
if (
|
|
274
|
-
const
|
|
275
|
-
if (
|
|
301
|
+
}), T = (e, s = l.items, n = []) => {
|
|
302
|
+
for (const a of s) {
|
|
303
|
+
const o = [...n, k(a)];
|
|
304
|
+
if (g(a) === e) return o;
|
|
305
|
+
if (w(a)) {
|
|
306
|
+
const y = T(e, a.children, o);
|
|
307
|
+
if (y) return y;
|
|
276
308
|
}
|
|
277
309
|
}
|
|
278
310
|
return null;
|
|
279
|
-
},
|
|
311
|
+
}, X = (e) => {
|
|
280
312
|
if (!e || e.length === 0) return "";
|
|
281
|
-
const
|
|
282
|
-
return
|
|
283
|
-
},
|
|
313
|
+
const s = e.join(" → ");
|
|
314
|
+
return s.length <= 40 ? s : e.length > 2 ? `${e[0]} → ... → ${e[e.length - 1]}` : s;
|
|
315
|
+
}, ie = b(() => {
|
|
284
316
|
const e = Array.isArray(l.modelValue) ? l.modelValue : [l.modelValue].filter(Boolean);
|
|
285
317
|
if (e.length === 0) return l.placeholder;
|
|
286
318
|
if (l.multiple) {
|
|
287
319
|
if (e.length === 1) {
|
|
288
|
-
const n =
|
|
289
|
-
return n ?
|
|
320
|
+
const n = T(e[0]);
|
|
321
|
+
return n ? X(n) : e[0];
|
|
290
322
|
}
|
|
291
323
|
return `${e.length} items selected`;
|
|
292
324
|
}
|
|
293
|
-
const
|
|
294
|
-
return
|
|
295
|
-
}),
|
|
296
|
-
const
|
|
297
|
-
let
|
|
298
|
-
return
|
|
299
|
-
}).filter(Boolean),
|
|
325
|
+
const s = T(e[0]);
|
|
326
|
+
return s ? X(s) : e[0];
|
|
327
|
+
}), Y = (e, s) => e.map((n) => {
|
|
328
|
+
const a = k(n).toLowerCase().includes(s);
|
|
329
|
+
let o = [];
|
|
330
|
+
return w(n) && (o = Y(n.children, s)), a || o.length > 0 ? { ...n, children: o } : null;
|
|
331
|
+
}).filter(Boolean), _ = (e, s, n) => !e || !s ? e : [...e].sort((o, y) => {
|
|
332
|
+
const h = W(o, s), E = W(y, s);
|
|
333
|
+
if (h == null) return 1;
|
|
334
|
+
if (E == null) return -1;
|
|
335
|
+
let K = 0;
|
|
336
|
+
return typeof h == "string" && typeof E == "string" ? K = h.localeCompare(E) : h > E ? K = 1 : h < E && (K = -1), n === "desc" ? K * -1 : K;
|
|
337
|
+
}).map((o) => w(o) ? { ...o, children: _(o.children, s, n) } : o), D = b(() => {
|
|
338
|
+
const e = x.value.trim() ? Y(l.items, x.value.toLowerCase()) : l.items;
|
|
339
|
+
return !l.sortable || !d.value ? e : _(e, d.value, c.value);
|
|
340
|
+
}), oe = (e) => {
|
|
300
341
|
if (l.disableBranchNodes && e.children && e.children.length > 0) {
|
|
301
|
-
const
|
|
302
|
-
|
|
342
|
+
const o = e[l.optionValue] || e.id || e.value;
|
|
343
|
+
ee(o);
|
|
303
344
|
return;
|
|
304
345
|
}
|
|
305
|
-
if (
|
|
306
|
-
const
|
|
307
|
-
let n = new Set(
|
|
346
|
+
if (N(e)) return;
|
|
347
|
+
const s = g(e);
|
|
348
|
+
let n = new Set(q.value);
|
|
308
349
|
if (l.multiple) {
|
|
309
|
-
const
|
|
310
|
-
if (l.selectAll &&
|
|
311
|
-
const
|
|
312
|
-
|
|
350
|
+
const o = n.has(s);
|
|
351
|
+
if (l.selectAll && w(e)) {
|
|
352
|
+
const y = J(e);
|
|
353
|
+
o ? (n.delete(s), y.forEach((h) => n.delete(h))) : (n.add(s), y.forEach((h) => n.add(h)));
|
|
313
354
|
} else
|
|
314
|
-
|
|
355
|
+
o ? (n.delete(s), l.selectAll && Q(s)?.forEach((h) => n.delete(h))) : n.add(s);
|
|
315
356
|
} else
|
|
316
|
-
n = /* @__PURE__ */ new Set([
|
|
317
|
-
let
|
|
318
|
-
l.multiple && l.excludeFromSelectedListKey && (
|
|
319
|
-
const
|
|
320
|
-
return !
|
|
321
|
-
})),
|
|
322
|
-
},
|
|
357
|
+
n = /* @__PURE__ */ new Set([s]), H();
|
|
358
|
+
let a = Array.from(n);
|
|
359
|
+
l.multiple && l.excludeFromSelectedListKey && (a = a.filter((o) => {
|
|
360
|
+
const y = G(o);
|
|
361
|
+
return !y || !y[l.excludeFromSelectedListKey];
|
|
362
|
+
})), v("update:modelValue", l.multiple ? a : a[0] || null), v("change", l.multiple ? a : a[0] || null);
|
|
363
|
+
}, ee = (e) => {
|
|
323
364
|
V.value.has(e) ? V.value.delete(e) : V.value.add(e);
|
|
324
|
-
},
|
|
365
|
+
}, re = () => {
|
|
366
|
+
c.value = c.value === "asc" ? "desc" : "asc";
|
|
367
|
+
}, de = () => {
|
|
325
368
|
const e = l.multiple ? [] : null;
|
|
326
|
-
|
|
327
|
-
},
|
|
328
|
-
l.disabled || (
|
|
369
|
+
v("update:modelValue", e), v("change", e);
|
|
370
|
+
}, ue = async () => {
|
|
371
|
+
l.disabled || (S.value = !0, await se(), r.value && p.value && (z.value = be(p.value, r.value, {
|
|
329
372
|
placement: "bottom-start",
|
|
330
373
|
strategy: "fixed",
|
|
331
374
|
modifiers: [
|
|
332
375
|
{ name: "offset", options: { offset: [0, 4] } },
|
|
333
376
|
{ name: "preventOverflow", options: { padding: 8 } },
|
|
334
377
|
{ name: "flip", options: { fallbackPlacements: ["top-start"] } },
|
|
335
|
-
// Add this 'sameWidth' modifier
|
|
336
378
|
{
|
|
337
379
|
name: "sameWidth",
|
|
338
380
|
enabled: !0,
|
|
@@ -346,30 +388,30 @@ const P = (t, B) => {
|
|
|
346
388
|
}
|
|
347
389
|
}
|
|
348
390
|
]
|
|
349
|
-
})), l.searchable && (await
|
|
350
|
-
},
|
|
351
|
-
|
|
352
|
-
},
|
|
353
|
-
!
|
|
391
|
+
})), l.searchable && (await se(), r.value?.querySelector(".tree-search-input")?.focus()));
|
|
392
|
+
}, H = () => {
|
|
393
|
+
S.value = !1, x.value = "", z.value?.destroy(), z.value = null;
|
|
394
|
+
}, ce = () => S.value ? H() : ue(), te = (e) => {
|
|
395
|
+
!p.value?.contains(e.target) && !r.value?.contains(e.target) && H();
|
|
354
396
|
};
|
|
355
|
-
return
|
|
356
|
-
document.removeEventListener("click",
|
|
357
|
-
}),
|
|
397
|
+
return he(() => document.addEventListener("click", te)), ve(() => {
|
|
398
|
+
document.removeEventListener("click", te), z.value?.destroy();
|
|
399
|
+
}), ge(x, (e) => {
|
|
358
400
|
if (e.trim()) {
|
|
359
|
-
const
|
|
360
|
-
n.forEach((
|
|
361
|
-
|
|
401
|
+
const s = (n) => {
|
|
402
|
+
n.forEach((a) => {
|
|
403
|
+
w(a) && (V.value.add(g(a)), s(a.children));
|
|
362
404
|
});
|
|
363
405
|
};
|
|
364
|
-
|
|
406
|
+
s(D.value);
|
|
365
407
|
}
|
|
366
|
-
}), (e,
|
|
367
|
-
|
|
408
|
+
}), (e, s) => (i(), u("div", Ne, [
|
|
409
|
+
m("button", {
|
|
368
410
|
ref_key: "triggerRef",
|
|
369
|
-
ref:
|
|
411
|
+
ref: p,
|
|
370
412
|
type: "button",
|
|
371
413
|
class: L(["btn tree-select-trigger w-100 d-flex justify-content-between align-items-center tree-select-main", [
|
|
372
|
-
|
|
414
|
+
$.value,
|
|
373
415
|
{
|
|
374
416
|
"btn-outline-secondary": !t.isInvalid,
|
|
375
417
|
"border-danger": t.isInvalid,
|
|
@@ -378,60 +420,88 @@ const P = (t, B) => {
|
|
|
378
420
|
}
|
|
379
421
|
]]),
|
|
380
422
|
disabled: t.disabled || t.isLoading,
|
|
381
|
-
onClick:
|
|
423
|
+
onClick: ce
|
|
382
424
|
}, [
|
|
383
|
-
|
|
384
|
-
|
|
425
|
+
m("span", Te, [
|
|
426
|
+
m("span", null, O(t.isLoading ? "Loading data..." : ie.value), 1)
|
|
385
427
|
]),
|
|
386
|
-
|
|
387
|
-
t.isLoading ? (i(),
|
|
428
|
+
m("div", De, [
|
|
429
|
+
t.isLoading ? (i(), M(C, {
|
|
388
430
|
key: 0,
|
|
389
431
|
name: "spinner",
|
|
390
432
|
class: "loading-icon"
|
|
391
|
-
})) :
|
|
392
|
-
t.showClearButton &&
|
|
433
|
+
})) : f("", !0),
|
|
434
|
+
t.showClearButton && q.value.length > 0 && !t.disabled && !t.isLoading ? (i(), M(C, {
|
|
393
435
|
key: 1,
|
|
394
436
|
name: "times",
|
|
395
|
-
onClick:
|
|
437
|
+
onClick: Z(de, ["stop"]),
|
|
396
438
|
class: "clear-icon"
|
|
397
|
-
})) :
|
|
398
|
-
t.isLoading ?
|
|
439
|
+
})) : f("", !0),
|
|
440
|
+
t.isLoading ? f("", !0) : (i(), M(C, {
|
|
399
441
|
key: 2,
|
|
400
442
|
name: "chevron-down",
|
|
401
|
-
class: L(["transition-transform", { "rotate-180":
|
|
443
|
+
class: L(["transition-transform", { "rotate-180": S.value }])
|
|
402
444
|
}, null, 8, ["class"]))
|
|
403
445
|
])
|
|
404
|
-
], 10,
|
|
405
|
-
|
|
446
|
+
], 10, qe),
|
|
447
|
+
S.value ? (i(), u("div", {
|
|
406
448
|
key: 0,
|
|
407
449
|
ref_key: "dropdownRef",
|
|
408
|
-
ref:
|
|
450
|
+
ref: r,
|
|
409
451
|
class: "tree-select-dropdown card shadow-lg border-0",
|
|
410
452
|
style: { "z-index": "1050" }
|
|
411
453
|
}, [
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
454
|
+
m("div", He, [
|
|
455
|
+
t.searchable ? le((i(), u("input", {
|
|
456
|
+
key: 0,
|
|
457
|
+
"onUpdate:modelValue": s[0] || (s[0] = (n) => x.value = n),
|
|
415
458
|
type: "text",
|
|
416
|
-
class: L(["form-control tree-search-input",
|
|
459
|
+
class: L(["form-control tree-search-input", I.value]),
|
|
417
460
|
placeholder: "Search..."
|
|
418
|
-
}, null, 2), [
|
|
419
|
-
[
|
|
420
|
-
])
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
461
|
+
}, null, 2)), [
|
|
462
|
+
[ye, x.value]
|
|
463
|
+
]) : f("", !0),
|
|
464
|
+
t.sortable && t.sortOptions.length > 0 ? (i(), u("div", Oe, [
|
|
465
|
+
le(m("select", {
|
|
466
|
+
"onUpdate:modelValue": s[1] || (s[1] = (n) => d.value = n),
|
|
467
|
+
class: L(["form-select flex-grow-1", I.value])
|
|
468
|
+
}, [
|
|
469
|
+
s[2] || (s[2] = m("option", {
|
|
470
|
+
value: null,
|
|
471
|
+
disabled: ""
|
|
472
|
+
}, "Sort by...", -1)),
|
|
473
|
+
(i(!0), u(F, null, j(t.sortOptions, (n) => (i(), u("option", {
|
|
474
|
+
key: n.value,
|
|
475
|
+
value: n.value
|
|
476
|
+
}, O(n.label), 9, Pe))), 128))
|
|
477
|
+
], 2), [
|
|
478
|
+
[pe, d.value]
|
|
479
|
+
]),
|
|
480
|
+
m("button", {
|
|
481
|
+
type: "button",
|
|
482
|
+
class: L(["btn btn-outline-secondary", $.value]),
|
|
483
|
+
disabled: !d.value,
|
|
484
|
+
onClick: re
|
|
485
|
+
}, [
|
|
486
|
+
P(C, {
|
|
487
|
+
name: c.value === "asc" ? "asc" : "desc"
|
|
488
|
+
}, null, 8, ["name"])
|
|
489
|
+
], 10, Ze)
|
|
490
|
+
])) : f("", !0)
|
|
491
|
+
]),
|
|
492
|
+
t.isLoading ? (i(), u("div", Re, [
|
|
493
|
+
P(C, {
|
|
424
494
|
name: "spinner",
|
|
425
495
|
class: "me-2"
|
|
426
496
|
}),
|
|
427
|
-
|
|
428
|
-
])) : (i(), u("div",
|
|
429
|
-
|
|
430
|
-
(i(!0), u(
|
|
431
|
-
key:
|
|
497
|
+
s[3] || (s[3] = m("span", null, "Loading...", -1))
|
|
498
|
+
])) : (i(), u("div", Fe, [
|
|
499
|
+
D.value.length > 0 ? (i(), u("div", je, [
|
|
500
|
+
(i(!0), u(F, null, j(D.value, (n) => (i(), M(Ke, {
|
|
501
|
+
key: g(n),
|
|
432
502
|
item: n,
|
|
433
503
|
level: 0,
|
|
434
|
-
"selected-items":
|
|
504
|
+
"selected-items": q.value,
|
|
435
505
|
"expanded-items": V.value,
|
|
436
506
|
multiple: t.multiple,
|
|
437
507
|
"select-all": t.selectAll,
|
|
@@ -440,42 +510,42 @@ const P = (t, B) => {
|
|
|
440
510
|
"option-value": t.optionValue,
|
|
441
511
|
"disabled-key": t.disabledKey,
|
|
442
512
|
"disable-branch-node": t.disableBranchNodes,
|
|
443
|
-
onSelect:
|
|
444
|
-
onToggleExpand:
|
|
513
|
+
onSelect: oe,
|
|
514
|
+
onToggleExpand: ee
|
|
445
515
|
}, {
|
|
446
|
-
default:
|
|
447
|
-
|
|
448
|
-
item:
|
|
449
|
-
level:
|
|
516
|
+
default: ae(({ item: a, level: o }) => [
|
|
517
|
+
R(e.$slots, "default", {
|
|
518
|
+
item: a,
|
|
519
|
+
level: o
|
|
450
520
|
}, () => [
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
521
|
+
m("div", Ue, [
|
|
522
|
+
ne(O(k(a)) + " ", 1),
|
|
523
|
+
a.icon ? (i(), u("i", {
|
|
454
524
|
key: 0,
|
|
455
|
-
class: L(
|
|
456
|
-
}, null, 2)) :
|
|
525
|
+
class: L(a.icon)
|
|
526
|
+
}, null, 2)) : f("", !0)
|
|
457
527
|
])
|
|
458
528
|
], !0)
|
|
459
529
|
]),
|
|
460
530
|
_: 2
|
|
461
531
|
}, 1032, ["item", "selected-items", "expanded-items", "multiple", "select-all", "select-mode", "option-label", "option-value", "disabled-key", "disable-branch-node"]))), 128))
|
|
462
|
-
])) : (i(), u("div",
|
|
463
|
-
|
|
532
|
+
])) : (i(), u("div", We, [
|
|
533
|
+
P(C, {
|
|
464
534
|
name: "search",
|
|
465
535
|
class: "me-1"
|
|
466
536
|
}),
|
|
467
|
-
|
|
537
|
+
s[4] || (s[4] = ne(" No items found ", -1))
|
|
468
538
|
]))
|
|
469
539
|
]))
|
|
470
|
-
], 512)) :
|
|
540
|
+
], 512)) : f("", !0)
|
|
471
541
|
]));
|
|
472
542
|
}
|
|
473
|
-
},
|
|
543
|
+
}, Je = /* @__PURE__ */ U(Ge, [["__scopeId", "data-v-20a84e1a"]]), Ye = {
|
|
474
544
|
install(t) {
|
|
475
|
-
t.component("VSelect",
|
|
545
|
+
t.component("VSelect", Je);
|
|
476
546
|
}
|
|
477
547
|
};
|
|
478
548
|
export {
|
|
479
|
-
|
|
480
|
-
|
|
549
|
+
Je as VSelect,
|
|
550
|
+
Ye as default
|
|
481
551
|
};
|
package/dist/vue-select.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(g,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):(g=typeof globalThis<"u"?globalThis:g||self,e(g.VueSelect={},g.Vue,g.Popper))})(this,function(g,e,O){"use strict";const C=(l,E)=>{const n=l.__vccOpts||l;for(const[u,s]of E)n[u]=s;return n},j={key:0},Z={key:1},F={key:2},R={key:3},W={key:4},S=C({__name:"SvgIcon",props:{name:{type:String,required:!0}},setup(l){const E=l,n=e.computed(()=>({"svg-icon-spin":E.name==="spinner"}));return(u,s)=>(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",j,s[0]||(s[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",Z,s[1]||(s[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",F,s[2]||(s[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",R,s[3]||(s[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",W,s[4]||(s[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)],2))}},[["__scopeId","data-v-ef3cb04b"]]),U={class:"tree-select-item-wrapper"},H={key:1,class:"expander-placeholder"},G=["checked",".indeterminate","disabled"],J={class:"item-content"},Q={key:0,class:"children-wrapper"},X=C({__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:E}){const n=l,u=r=>r[n.optionValue]||r.id||r.value,s=r=>!n.disabledKey||!r?!1:r.hasOwnProperty(n.disabledKey)&&r[n.disabledKey]!==null,f=e.computed(()=>n.item.children&&n.item.children.length>0),y=e.computed(()=>n.expandedItems.has(u(n.item))),k=e.computed(()=>n.selectedItems.includes(u(n.item))),V=r=>{let c=[];return r.children&&r.children.forEach(x=>{c.push(u(x)),c.push(...V(x))}),c},w=e.computed(()=>!n.multiple||!n.selectAll||!f.value||k.value?!1:V(n.item).some(c=>n.selectedItems.includes(c)));return(r,c)=>{const x=e.resolveComponent("TreeSelectItem",!0);return e.openBlock(),e.createElementBlock("div",U,[e.createElementVNode("div",{class:e.normalizeClass(["list-group-item list-group-item-action d-flex align-items-center gap-2",{"bg-primary text-white":k.value&&(l.selectMode==="highlight"||!l.multiple)&&!s(l.item)&&!(l.disableBranchNode&&f.value),"is-disabled text-muted bg-light":s(l.item)}]),style:e.normalizeStyle({"padding-left":`${l.level*1.5+1}rem`}),onClick:c[2]||(c[2]=m=>s(l.item)||l.disableBranchNode&&f.value?null:r.$emit("select",l.item))},[f.value?(e.openBlock(),e.createBlock(S,{key:0,name:"chevron-right",class:e.normalizeClass(["expander-icon",{"rotate-90":y.value}]),onClick:c[0]||(c[0]=e.withModifiers(m=>r.$emit("toggle-expand",u(l.item)),["stop"]))},null,8,["class"])):(e.openBlock(),e.createElementBlock("span",H)),l.multiple&&l.selectMode==="checkbox"&&!(l.disableBranchNode&&f.value)?(e.openBlock(),e.createElementBlock("input",{key:2,type:"checkbox",class:"form-check-input",checked:k.value,".indeterminate":w.value,disabled:s(l.item),onClick:c[1]||(c[1]=e.withModifiers(m=>r.$emit("select",l.item),["stop"]))},null,40,G)):e.createCommentVNode("",!0),e.createElementVNode("div",J,[e.renderSlot(r.$slots,"default",{item:l.item,level:l.level},void 0,!0)])],6),f.value&&y.value?(e.openBlock(),e.createElementBlock("div",Q,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.item.children,m=>(e.openBlock(),e.createBlock(x,{key:u(m),item:m,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:c[3]||(c[3]=b=>r.$emit("select",b)),onToggleExpand:c[4]||(c[4]=b=>r.$emit("toggle-expand",b))},{default:e.withCtx(({item:b,level:p})=>[e.renderSlot(r.$slots,"default",{item:b,level:p},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-9766821f"]]),Y={class:"tree-select-wrapper"},v=["disabled"],_={class:"tree-select-display-text text-truncate me-2 text-start"},ee={class:"d-flex align-items-center gap-2"},te={key:0,class:"p-2 border-bottom"},le={key:1,class:"p-4 text-muted text-center"},ne={key:2,class:"tree-select-body",style:{"max-height":"300px","overflow-y":"auto"}},oe={key:0,class:"list-group list-group-flush"},ae={class:"d-flex align-items-center gap-2",style:{"white-space":"wrap"}},ie={key:1,class:"p-3 text-muted text-center"},A=C({__name:"TreeSelectMain",props:{modelValue:{type:[String,Number,Array],default:null},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},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)}},emits:["update:modelValue","change"],setup(l,{emit:E}){const n=l,u=E,s=e.ref(null),f=e.ref(null),y=e.ref(""),k=e.ref(!1),V=e.ref(new Set),w=e.ref(null),r=e.computed(()=>n.size==="sm"?"btn-sm":n.size==="lg"?"btn-lg":n.size==="xl"?"btn-xl":""),c=e.computed(()=>n.size==="sm"?"form-control-sm":n.size==="lg"?"form-control-lg":n.size==="xl"?"form-control-xl":""),x=t=>t[n.optionLabel]||t.label||t.name||"",m=t=>t[n.optionValue]||t.id||t.value,b=t=>!n.disabledKey||!t?!1:t.hasOwnProperty(n.disabledKey)&&t[n.disabledKey]!==null,p=t=>t.children&&t.children.length>0,M=(t,a=n.items)=>{for(const o of a){if(m(o)===t)return o;if(p(o)){const i=M(t,o.children);if(i)return i}}return null},z=t=>{const a=[];return p(t)&&t.children.forEach(o=>{b(o)||(a.push(m(o)),a.push(...z(o)))}),a},T=(t,a=n.items,o=[])=>{for(const i of a){if(m(i)===t)return o;if(p(i)){const d=T(t,i.children,[...o,m(i)]);if(d)return d}}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(i=>{if(p(i)){const d=i.children.filter(B=>!b(B));d.length>0&&d.every(B=>t.has(m(B)))&&t.add(m(i)),a(i.children)}})};a(n.items)}return Array.from(t)}),L=(t,a=n.items,o=[])=>{for(const i of a){const d=[...o,x(i)];if(m(i)===t)return d;if(p(i)){const h=L(t,i.children,d);if(h)return h}}return null},q=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=Array.isArray(n.modelValue)?n.modelValue:[n.modelValue].filter(Boolean);if(t.length===0)return n.placeholder;if(n.multiple){if(t.length===1){const o=L(t[0]);return o?q(o):t[0]}return`${t.length} items selected`}const a=L(t[0]);return a?q(a):t[0]}),K=(t,a)=>t.map(o=>{const i=x(o).toLowerCase().includes(a);let d=[];return p(o)&&(d=K(o.children,a)),i||d.length>0?{...o,children:d}:null}).filter(Boolean),I=e.computed(()=>y.value.trim()?K(n.items,y.value.toLowerCase()):n.items),de=t=>{if(n.disableBranchNodes&&t.children&&t.children.length>0){const d=t[n.optionValue]||t.id||t.value;P(d);return}if(b(t))return;const a=m(t);let o=new Set(N.value);if(n.multiple){const d=o.has(a);if(n.selectAll&&p(t)){const h=z(t);d?(o.delete(a),h.forEach(B=>o.delete(B))):(o.add(a),h.forEach(B=>o.add(B)))}else d?(o.delete(a),n.selectAll&&T(a)?.forEach(B=>o.delete(B))):o.add(a)}else o=new Set([a]),$();let i=Array.from(o);n.multiple&&n.excludeFromSelectedListKey&&(i=i.filter(d=>{const h=M(d);return!h||!h[n.excludeFromSelectedListKey]})),u("update:modelValue",n.multiple?i:i[0]||null),u("change",n.multiple?i:i[0]||null)},P=t=>{V.value.has(t)?V.value.delete(t):V.value.add(t)},ce=()=>{const t=n.multiple?[]:null;u("update:modelValue",t),u("change",t)},me=async()=>{n.disabled||(k.value=!0,await e.nextTick(),s.value&&f.value&&(w.value=O.createPopper(f.value,s.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(),s.value?.querySelector(".tree-search-input")?.focus()))},$=()=>{k.value=!1,y.value="",w.value?.destroy(),w.value=null},ue=()=>k.value?$():me(),D=t=>{!f.value?.contains(t.target)&&!s.value?.contains(t.target)&&$()};return e.onMounted(()=>document.addEventListener("click",D)),e.onUnmounted(()=>{document.removeEventListener("click",D),w.value?.destroy()}),e.watch(y,t=>{if(t.trim()){const a=o=>{o.forEach(i=>{p(i)&&(V.value.add(m(i)),a(i.children))})};a(I.value)}}),(t,a)=>(e.openBlock(),e.createElementBlock("div",Y,[e.createElementVNode("button",{ref_key:"triggerRef",ref:f,type:"button",class:e.normalizeClass(["btn tree-select-trigger w-100 d-flex justify-content-between align-items-center tree-select-main",[r.value,{"btn-outline-secondary":!l.isInvalid,"border-danger":l.isInvalid,disabled:l.disabled||l.isLoading,"is-loading":l.isLoading}]]),disabled:l.disabled||l.isLoading,onClick:ue},[e.createElementVNode("span",_,[e.createElementVNode("span",null,e.toDisplayString(l.isLoading?"Loading data...":re.value),1)]),e.createElementVNode("div",ee,[l.isLoading?(e.openBlock(),e.createBlock(S,{key:0,name:"spinner",class:"loading-icon"})):e.createCommentVNode("",!0),l.showClearButton&&N.value.length>0&&!l.disabled&&!l.isLoading?(e.openBlock(),e.createBlock(S,{key:1,name:"times",onClick:e.withModifiers(ce,["stop"]),class:"clear-icon"})):e.createCommentVNode("",!0),l.isLoading?e.createCommentVNode("",!0):(e.openBlock(),e.createBlock(S,{key:2,name:"chevron-down",class:e.normalizeClass(["transition-transform",{"rotate-180":k.value}])},null,8,["class"]))])],10,v),k.value?(e.openBlock(),e.createElementBlock("div",{key:0,ref_key:"dropdownRef",ref:s,class:"tree-select-dropdown card shadow-lg border-0",style:{"z-index":"1050"}},[l.searchable?(e.openBlock(),e.createElementBlock("div",te,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":a[0]||(a[0]=o=>y.value=o),type:"text",class:e.normalizeClass(["form-control tree-search-input",c.value]),placeholder:"Search..."},null,2),[[e.vModelText,y.value]])])):e.createCommentVNode("",!0),l.isLoading?(e.openBlock(),e.createElementBlock("div",le,[e.createVNode(S,{name:"spinner",class:"me-2"}),a[1]||(a[1]=e.createElementVNode("span",null,"Loading...",-1))])):(e.openBlock(),e.createElementBlock("div",ne,[I.value.length>0?(e.openBlock(),e.createElementBlock("div",oe,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(I.value,o=>(e.openBlock(),e.createBlock(X,{key:m(o),item:o,level:0,"selected-items":N.value,"expanded-items":V.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:de,onToggleExpand:P},{default:e.withCtx(({item:i,level:d})=>[e.renderSlot(t.$slots,"default",{item:i,level:d},()=>[e.createElementVNode("div",ae,[e.createTextVNode(e.toDisplayString(x(i))+" ",1),i.icon?(e.openBlock(),e.createElementBlock("i",{key:0,class:e.normalizeClass(i.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",ie,[e.createVNode(S,{name:"search",class:"me-1"}),a[2]||(a[2]=e.createTextVNode(" No items found ",-1))]))]))],512)):e.createCommentVNode("",!0)]))}},[["__scopeId","data-v-5e70d4e4"]]),se={install(l){l.component("VSelect",A)}};g.VSelect=A,g.default=se,Object.defineProperties(g,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
1
|
+
(function(g,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):(g=typeof globalThis<"u"?globalThis:g||self,e(g.VueSelect={},g.Vue,g.Popper))})(this,(function(g,e,U){"use strict";const I=(l,C)=>{const n=l.__vccOpts||l;for(const[u,i]of C)n[u]=i;return n},W={key:0},G={key:1},J={key:2},Q={key:3},X={key:4},Y={key:5},v={key:6},x=I({__name:"SvgIcon",props:{name:{type:String,required:!0}},setup(l){const C=l,n=e.computed(()=>({"svg-icon-spin":C.name==="spinner"}));return(u,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",W,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",G,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",J,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",Q,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",X,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",Y,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",v,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)],2))}},[["__scopeId","data-v-d347d13a"]]),_={class:"tree-select-item-wrapper"},ee={key:1,class:"expander-placeholder"},te=["checked",".indeterminate","disabled"],le={class:"item-content"},ne={key:0,class:"children-wrapper"},oe=I({__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:C}){const n=l,u=d=>d[n.optionValue]||d.id||d.value,i=d=>!n.disabledKey||!d?!1:d.hasOwnProperty(n.disabledKey)&&d[n.disabledKey]!==null,h=e.computed(()=>n.item.children&&n.item.children.length>0),y=e.computed(()=>n.expandedItems.has(u(n.item))),k=e.computed(()=>n.selectedItems.includes(u(n.item))),V=d=>{let c=[];return d.children&&d.children.forEach(E=>{c.push(u(E)),c.push(...V(E))}),c},N=e.computed(()=>!n.multiple||!n.selectAll||!h.value||k.value?!1:V(n.item).some(c=>n.selectedItems.includes(c)));return(d,c)=>{const E=e.resolveComponent("TreeSelectItem",!0);return e.openBlock(),e.createElementBlock("div",_,[e.createElementVNode("div",{class:e.normalizeClass(["list-group-item list-group-item-action d-flex align-items-center gap-2",{"bg-primary text-white":k.value&&(l.selectMode==="highlight"||!l.multiple)&&!i(l.item)&&!(l.disableBranchNode&&h.value),"is-disabled text-muted bg-light":i(l.item)}]),style:e.normalizeStyle({"padding-left":`${l.level*1.5+1}rem`}),onClick:c[2]||(c[2]=S=>i(l.item)||l.disableBranchNode&&h.value?null:d.$emit("select",l.item))},[h.value?(e.openBlock(),e.createBlock(x,{key:0,name:"chevron-right",class:e.normalizeClass(["expander-icon",{"rotate-90":y.value}]),onClick:c[0]||(c[0]=e.withModifiers(S=>d.$emit("toggle-expand",u(l.item)),["stop"]))},null,8,["class"])):(e.openBlock(),e.createElementBlock("span",ee)),l.multiple&&l.selectMode==="checkbox"&&!(l.disableBranchNode&&h.value)?(e.openBlock(),e.createElementBlock("input",{key:2,type:"checkbox",class:"form-check-input",checked:k.value,".indeterminate":N.value,disabled:i(l.item),onClick:c[1]||(c[1]=e.withModifiers(S=>d.$emit("select",l.item),["stop"]))},null,40,te)):e.createCommentVNode("",!0),e.createElementVNode("div",le,[e.renderSlot(d.$slots,"default",{item:l.item,level:l.level},void 0,!0)])],6),h.value&&y.value?(e.openBlock(),e.createElementBlock("div",ne,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.item.children,S=>(e.openBlock(),e.createBlock(E,{key:u(S),item:S,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:c[3]||(c[3]=b=>d.$emit("select",b)),onToggleExpand:c[4]||(c[4]=b=>d.$emit("toggle-expand",b))},{default:e.withCtx(({item:b,level:f})=>[e.renderSlot(d.$slots,"default",{item:b,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-9766821f"]]),ae={class:"tree-select-wrapper"},re=["disabled"],se={class:"tree-select-display-text text-truncate me-2 text-start"},ie={class:"d-flex align-items-center gap-2"},de={class:"p-2 border-bottom d-flex flex-column gap-2"},ce={key:1,class:"d-flex align-items-center gap-2"},me=["value"],ue=["disabled"],fe={key:0,class:"p-4 text-muted text-center"},pe={key:1,class:"tree-select-body",style:{"max-height":"300px","overflow-y":"auto"}},he={key:0,class:"list-group list-group-flush"},ge={class:"d-flex align-items-center gap-2",style:{"white-space":"wrap"}},ye={key:1,class:"p-3 text-muted text-center"},K=I({__name:"TreeSelectMain",props:{modelValue:{type:[String,Number,Array],default:null},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},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)}},emits:["update:modelValue","change"],setup(l,{emit:C}){const n=l,u=C,i=e.ref(null),h=e.ref(null),y=e.ref(""),k=e.ref(!1),V=e.ref(new Set),N=e.ref(null),d=e.ref(n.defaultSortKey),c=e.ref(n.defaultSortDirection),E=e.computed(()=>n.size==="sm"?"btn-sm":n.size==="lg"?"btn-lg":n.size==="xl"?"btn-xl":""),S=e.computed(()=>n.size==="sm"?"form-control-sm":n.size==="lg"?"form-control-lg":n.size==="xl"?"form-control-xl":""),b=t=>t[n.optionLabel]||t.label||t.name||"",f=t=>t[n.optionValue]||t.id||t.value,$=t=>!n.disabledKey||!t?!1:t.hasOwnProperty(n.disabledKey)&&t[n.disabledKey]!==null,B=t=>t.children&&t.children.length>0,q=(t,a)=>{if(a)return a.split(".").reduce((o,r)=>o&&o[r],t)},D=(t,a=n.items)=>{for(const o of a){if(f(o)===t)return o;if(B(o)){const r=D(t,o.children);if(r)return r}}return null},P=t=>{const a=[];return B(t)&&t.children.forEach(o=>{$(o)||(a.push(f(o)),a.push(...P(o)))}),a},H=(t,a=n.items,o=[])=>{for(const r of a){if(f(r)===t)return o;if(B(r)){const s=H(t,r.children,[...o,f(r)]);if(s)return s}}return null},z=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(B(r)){const s=r.children.filter(m=>!$(m));s.length>0&&s.every(m=>t.has(f(m)))&&t.add(f(r)),a(r.children)}})};a(n.items)}return Array.from(t)}),A=(t,a=n.items,o=[])=>{for(const r of a){const s=[...o,b(r)];if(f(r)===t)return s;if(B(r)){const p=A(t,r.children,s);if(p)return p}}return null},O=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},be=e.computed(()=>{const t=Array.isArray(n.modelValue)?n.modelValue:[n.modelValue].filter(Boolean);if(t.length===0)return n.placeholder;if(n.multiple){if(t.length===1){const o=A(t[0]);return o?O(o):t[0]}return`${t.length} items selected`}const a=A(t[0]);return a?O(a):t[0]}),j=(t,a)=>t.map(o=>{const r=b(o).toLowerCase().includes(a);let s=[];return B(o)&&(s=j(o.children,a)),r||s.length>0?{...o,children:s}:null}).filter(Boolean),F=(t,a,o)=>!t||!a?t:[...t].sort((s,p)=>{const m=q(s,a),w=q(p,a);if(m==null)return 1;if(w==null)return-1;let L=0;return typeof m=="string"&&typeof w=="string"?L=m.localeCompare(w):m>w?L=1:m<w&&(L=-1),o==="desc"?L*-1:L}).map(s=>B(s)?{...s,children:F(s.children,a,o)}:s),M=e.computed(()=>{const t=y.value.trim()?j(n.items,y.value.toLowerCase()):n.items;return!n.sortable||!d.value?t:F(t,d.value,c.value)}),Be=t=>{if(n.disableBranchNodes&&t.children&&t.children.length>0){const s=t[n.optionValue]||t.id||t.value;Z(s);return}if($(t))return;const a=f(t);let o=new Set(z.value);if(n.multiple){const s=o.has(a);if(n.selectAll&&B(t)){const p=P(t);s?(o.delete(a),p.forEach(m=>o.delete(m))):(o.add(a),p.forEach(m=>o.add(m)))}else s?(o.delete(a),n.selectAll&&H(a)?.forEach(m=>o.delete(m))):o.add(a)}else o=new Set([a]),T();let r=Array.from(o);n.multiple&&n.excludeFromSelectedListKey&&(r=r.filter(s=>{const p=D(s);return!p||!p[n.excludeFromSelectedListKey]})),u("update:modelValue",n.multiple?r:r[0]||null),u("change",n.multiple?r:r[0]||null)},Z=t=>{V.value.has(t)?V.value.delete(t):V.value.add(t)},Ve=()=>{c.value=c.value==="asc"?"desc":"asc"},Se=()=>{const t=n.multiple?[]:null;u("update:modelValue",t),u("change",t)},xe=async()=>{n.disabled||(k.value=!0,await e.nextTick(),i.value&&h.value&&(N.value=U.createPopper(h.value,i.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(),i.value?.querySelector(".tree-search-input")?.focus()))},T=()=>{k.value=!1,y.value="",N.value?.destroy(),N.value=null},Ee=()=>k.value?T():xe(),R=t=>{!h.value?.contains(t.target)&&!i.value?.contains(t.target)&&T()};return e.onMounted(()=>document.addEventListener("click",R)),e.onUnmounted(()=>{document.removeEventListener("click",R),N.value?.destroy()}),e.watch(y,t=>{if(t.trim()){const a=o=>{o.forEach(r=>{B(r)&&(V.value.add(f(r)),a(r.children))})};a(M.value)}}),(t,a)=>(e.openBlock(),e.createElementBlock("div",ae,[e.createElementVNode("button",{ref_key:"triggerRef",ref:h,type:"button",class:e.normalizeClass(["btn tree-select-trigger w-100 d-flex justify-content-between align-items-center tree-select-main",[E.value,{"btn-outline-secondary":!l.isInvalid,"border-danger":l.isInvalid,disabled:l.disabled||l.isLoading,"is-loading":l.isLoading}]]),disabled:l.disabled||l.isLoading,onClick:Ee},[e.createElementVNode("span",se,[e.createElementVNode("span",null,e.toDisplayString(l.isLoading?"Loading data...":be.value),1)]),e.createElementVNode("div",ie,[l.isLoading?(e.openBlock(),e.createBlock(x,{key:0,name:"spinner",class:"loading-icon"})):e.createCommentVNode("",!0),l.showClearButton&&z.value.length>0&&!l.disabled&&!l.isLoading?(e.openBlock(),e.createBlock(x,{key:1,name:"times",onClick:e.withModifiers(Se,["stop"]),class:"clear-icon"})):e.createCommentVNode("",!0),l.isLoading?e.createCommentVNode("",!0):(e.openBlock(),e.createBlock(x,{key:2,name:"chevron-down",class:e.normalizeClass(["transition-transform",{"rotate-180":k.value}])},null,8,["class"]))])],10,re),k.value?(e.openBlock(),e.createElementBlock("div",{key:0,ref_key:"dropdownRef",ref:i,class:"tree-select-dropdown card shadow-lg border-0",style:{"z-index":"1050"}},[e.createElementVNode("div",de,[l.searchable?e.withDirectives((e.openBlock(),e.createElementBlock("input",{key:0,"onUpdate:modelValue":a[0]||(a[0]=o=>y.value=o),type:"text",class:e.normalizeClass(["form-control tree-search-input",S.value]),placeholder:"Search..."},null,2)),[[e.vModelText,y.value]]):e.createCommentVNode("",!0),l.sortable&&l.sortOptions.length>0?(e.openBlock(),e.createElementBlock("div",ce,[e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":a[1]||(a[1]=o=>d.value=o),class:e.normalizeClass(["form-select flex-grow-1",S.value])},[a[2]||(a[2]=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,me))),128))],2),[[e.vModelSelect,d.value]]),e.createElementVNode("button",{type:"button",class:e.normalizeClass(["btn btn-outline-secondary",E.value]),disabled:!d.value,onClick:Ve},[e.createVNode(x,{name:c.value==="asc"?"asc":"desc"},null,8,["name"])],10,ue)])):e.createCommentVNode("",!0)]),l.isLoading?(e.openBlock(),e.createElementBlock("div",fe,[e.createVNode(x,{name:"spinner",class:"me-2"}),a[3]||(a[3]=e.createElementVNode("span",null,"Loading...",-1))])):(e.openBlock(),e.createElementBlock("div",pe,[M.value.length>0?(e.openBlock(),e.createElementBlock("div",he,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(M.value,o=>(e.openBlock(),e.createBlock(oe,{key:f(o),item:o,level:0,"selected-items":z.value,"expanded-items":V.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:Be,onToggleExpand:Z},{default:e.withCtx(({item:r,level:s})=>[e.renderSlot(t.$slots,"default",{item:r,level:s},()=>[e.createElementVNode("div",ge,[e.createTextVNode(e.toDisplayString(b(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",ye,[e.createVNode(x,{name:"search",class:"me-1"}),a[4]||(a[4]=e.createTextVNode(" No items found ",-1))]))]))],512)):e.createCommentVNode("",!0)]))}},[["__scopeId","data-v-20a84e1a"]]),ke={install(l){l.component("VSelect",K)}};g.VSelect=K,g.default=ke,Object.defineProperties(g,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
|