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