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