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