@night-owl-elite/vue-select 1.3.14 → 1.3.16

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.
@@ -1 +1 @@
1
- @keyframes spin-ef3cb04b{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.svg-icon-spin[data-v-ef3cb04b]{animation:spin-ef3cb04b 1s linear infinite}.list-group-item[data-v-9766821f]{cursor:pointer;border:0;border-radius:0;padding-top:.5rem;padding-bottom:.5rem}.list-group-item.is-disabled[data-v-9766821f]{cursor:not-allowed;opacity:.65}.expander-icon[data-v-9766821f]{width:1rem;height:1rem;flex-shrink:0;transition:transform .2s ease-in-out;color:#6c757d}.expander-placeholder[data-v-9766821f]{display:inline-block;width:1rem;flex-shrink:0}.rotate-90[data-v-9766821f]{transform:rotate(90deg)}.item-content[data-v-9766821f]{flex-grow:1}.tree-select-main[data-v-5e70d4e4]{--bs-form-select-bg-img: none;display:block;width:100%;font-weight:400;line-height:1.5;color:var(--bs-body-color);appearance:none;background-color:var(--bs-body-bg);border:var(--bs-border-width) solid var(--bs-border-color);transition:border-color .15s ease-in-out,box-shadow .15s ease-in-out}.tree-select-display-text[data-v-5e70d4e4]{flex:1;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.clear-icon[data-v-5e70d4e4]{cursor:pointer;opacity:.6;transition:opacity .2s ease}.clear-icon[data-v-5e70d4e4]:hover{opacity:1}.transition-transform[data-v-5e70d4e4]{transition:transform .2s ease-in-out}.rotate-180[data-v-5e70d4e4]{transform:rotate(180deg)}.tree-select-dropdown[data-v-5e70d4e4]{position:absolute;background:#fff;border:1px solid rgba(0,0,0,.15);border-radius:.375rem}.tree-select-body[data-v-5e70d4e4]::-webkit-scrollbar{width:6px}.tree-select-body[data-v-5e70d4e4]::-webkit-scrollbar-track{background:#f1f1f1;border-radius:3px}.tree-select-body[data-v-5e70d4e4]::-webkit-scrollbar-thumb{background:#c1c1c1;border-radius:3px}.tree-select-body[data-v-5e70d4e4]::-webkit-scrollbar-thumb:hover{background:#a8a8a8}.is-loading[data-v-5e70d4e4]{cursor:wait}.loading-icon[data-v-5e70d4e4]{opacity:.7}.btn-xl[data-v-5e70d4e4]{padding:.75rem 1.5rem;font-size:1.25rem;border-radius:var(--bs-border-radius-lg)}.form-control-xl[data-v-5e70d4e4]{min-height:calc(1.5em + 1.5rem + (var(--bs-border-width) * 2));padding:.75rem 1.5rem;font-size:1.25rem;border-radius:var(--bs-border-radius-lg)}@media (max-width: 576px){.tree-select-dropdown[data-v-5e70d4e4]{max-width:90vw;left:0!important;right:0!important;margin:0 auto}}
1
+ @keyframes spin-d347d13a{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.svg-icon-spin[data-v-d347d13a]{animation:spin-d347d13a 1s linear infinite}.list-group-item[data-v-9766821f]{cursor:pointer;border:0;border-radius:0;padding-top:.5rem;padding-bottom:.5rem}.list-group-item.is-disabled[data-v-9766821f]{cursor:not-allowed;opacity:.65}.expander-icon[data-v-9766821f]{width:1rem;height:1rem;flex-shrink:0;transition:transform .2s ease-in-out;color:#6c757d}.expander-placeholder[data-v-9766821f]{display:inline-block;width:1rem;flex-shrink:0}.rotate-90[data-v-9766821f]{transform:rotate(90deg)}.item-content[data-v-9766821f]{flex-grow:1}.tree-select-main[data-v-a9a04e35]{--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-a9a04e35]{flex:1;overflow:hidden}.clear-icon[data-v-a9a04e35]{cursor:pointer;opacity:.6;transition:opacity .2s ease}.clear-icon[data-v-a9a04e35]:hover{opacity:1}.transition-transform[data-v-a9a04e35]{transition:transform .2s ease-in-out}.rotate-180[data-v-a9a04e35]{transform:rotate(180deg)}.tree-select-dropdown[data-v-a9a04e35]{position:absolute;background:#fff;border:1px solid rgba(0,0,0,.15);border-radius:.375rem}.is-loading[data-v-a9a04e35]{cursor:wait}.loading-icon[data-v-a9a04e35]{animation:spin-a9a04e35 1s linear infinite}@keyframes spin-a9a04e35{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.btn-xl[data-v-a9a04e35]{padding:.75rem 1.5rem;font-size:1.25rem;border-radius:var(--bs-border-radius-lg)}.form-control-xl[data-v-a9a04e35]{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-a9a04e35]::-webkit-scrollbar{width:6px}.tree-select-body[data-v-a9a04e35]::-webkit-scrollbar-track{background:#f1f1f1;border-radius:3px}.tree-select-body[data-v-a9a04e35]::-webkit-scrollbar-thumb{background:#c1c1c1;border-radius:3px}.tree-select-body[data-v-a9a04e35]::-webkit-scrollbar-thumb:hover{background:#a8a8a8}.tree-select-main.has-chips[data-v-a9a04e35]{height:auto;min-height:calc(1.5em + .5rem + calc(var(--bs-border-width) * 2))}.tree-select-main.has-chips.btn-lg[data-v-a9a04e35]{min-height:calc(1.5em + 1rem + calc(var(--bs-border-width) * 2))}.tree-select-main.has-chips.btn-xl[data-v-a9a04e35]{min-height:calc(1.5em + 1.5rem + calc(var(--bs-border-width) * 2))}.chips-container[data-v-a9a04e35]{display:flex;flex-wrap:wrap;gap:.25rem;max-height:8rem;overflow-y:auto}.chip[data-v-a9a04e35]{display:inline-flex;align-items:center;padding:.2em .6em}.chip-remove[data-v-a9a04e35]{width:.8em;height:.8em;margin-left:.4em;cursor:pointer;opacity:.7;transition:opacity .2s}.chip-remove[data-v-a9a04e35]:hover{opacity:1}.more-button[data-v-a9a04e35]{font-size:.75em;line-height:1;padding:.3em .5em}.more-popover[data-v-a9a04e35]{width:250px;max-width:80vw;max-height:200px;overflow-y:auto;font-size:.9rem}@media (max-width: 576px){.tree-select-dropdown[data-v-a9a04e35]{max-width:90vw;left:0!important;right:0!important;margin:0 auto}}
@@ -1,11 +1,11 @@
1
- import { computed as b, createElementBlock as u, openBlock as i, normalizeClass as L, createCommentVNode as g, createElementVNode as f, resolveComponent as ae, normalizeStyle as se, createBlock as E, withModifiers as z, renderSlot as T, Fragment as Q, renderList as X, withCtx as Y, ref as C, onMounted as ie, onUnmounted as oe, watch as de, toDisplayString as U, withDirectives as re, vModelText as ue, createVNode as H, createTextVNode as G, nextTick as J } from "vue";
2
- import { createPopper as ce } from "@popperjs/core";
3
- const P = (t, B) => {
1
+ import { computed as y, createElementBlock as o, openBlock as i, normalizeClass as B, createCommentVNode as m, createElementVNode as f, resolveComponent as Ce, normalizeStyle as Ve, createBlock as P, withModifiers as K, renderSlot as _, Fragment as O, renderList as R, withCtx as ve, ref as b, onMounted as Le, onUnmounted as Ie, watch as $e, toDisplayString as A, createTextVNode as X, createVNode as H, withDirectives as fe, vModelText as Be, vModelSelect as Me, nextTick as Y } from "vue";
2
+ import { createPopper as me } from "@popperjs/core";
3
+ const ee = (t, z) => {
4
4
  const l = t.__vccOpts || t;
5
- for (const [h, o] of B)
6
- l[h] = o;
5
+ for (const [v, d] of z)
6
+ l[v] = d;
7
7
  return l;
8
- }, me = { key: 0 }, fe = { key: 1 }, he = { key: 2 }, ge = { key: 3 }, ve = { key: 4 }, ye = {
8
+ }, Ae = { key: 0 }, ze = { key: 1 }, Ee = { key: 2 }, Ne = { key: 3 }, Pe = { key: 4 }, Ke = { key: 5 }, De = { key: 6 }, Te = {
9
9
  __name: "SvgIcon",
10
10
  props: {
11
11
  name: {
@@ -14,41 +14,53 @@ const P = (t, B) => {
14
14
  }
15
15
  },
16
16
  setup(t) {
17
- const B = t, l = b(() => ({
18
- "svg-icon-spin": B.name === "spinner"
17
+ const z = t, l = y(() => ({
18
+ "svg-icon-spin": z.name === "spinner"
19
19
  }));
20
- return (h, o) => (i(), u("svg", {
20
+ return (v, d) => (i(), o("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: L(l.value)
26
+ class: B(l.value)
27
27
  }, [
28
- t.name === "spinner" ? (i(), u("g", me, o[0] || (o[0] = [
28
+ t.name === "spinner" ? (i(), o("g", Ae, d[0] || (d[0] = [
29
29
  f("path", { d: "M12,4V2A10,10,0,0,0,2,12H4A8,8,0,0,1,12,4Z" }, null, -1)
30
- ]))) : g("", !0),
31
- t.name === "times" ? (i(), u("g", fe, o[1] || (o[1] = [
30
+ ]))) : m("", !0),
31
+ t.name === "times" ? (i(), o("g", ze, d[1] || (d[1] = [
32
32
  f("path", { d: "M13.41,12l4.3-4.29a1,1,0,1,0-1.42-1.42L12,10.59,7.71,6.29A1,1,0,0,0,6.29,7.71L10.59,12l-4.3,4.29a1,1,0,0,0,0,1.42,1,1,0,0,0,1.42,0L12,13.41l4.29,4.3a1,1,0,0,0,1.42,0,1,1,0,0,0,0-1.42Z" }, null, -1)
33
- ]))) : g("", !0),
34
- t.name === "chevron-down" ? (i(), u("g", he, o[2] || (o[2] = [
33
+ ]))) : m("", !0),
34
+ t.name === "chevron-down" ? (i(), o("g", Ee, d[2] || (d[2] = [
35
35
  f("path", { d: "M17,9.17a1,1,0,0,0-1.41,0L12,12.71,8.46,9.17a1,1,0,0,0-1.41,0,1,1,0,0,0,0,1.42l4.24,4.24a1,1,0,0,0,1.42,0L17,10.59A1,1,0,0,0,17,9.17Z" }, null, -1)
36
- ]))) : g("", !0),
37
- t.name === "chevron-right" ? (i(), u("g", ge, o[3] || (o[3] = [
36
+ ]))) : m("", !0),
37
+ t.name === "chevron-right" ? (i(), o("g", Ne, d[3] || (d[3] = [
38
38
  f("path", { d: "M10.83,12l-4.24,4.24a1,1,0,0,0,1.41,1.41L13.66,12,8,6.34A1,1,0,0,0,6.59,7.76Z" }, null, -1)
39
- ]))) : g("", !0),
40
- t.name === "search" ? (i(), u("g", ve, o[4] || (o[4] = [
39
+ ]))) : m("", !0),
40
+ t.name === "search" ? (i(), o("g", Pe, d[4] || (d[4] = [
41
41
  f("path", { d: "M21.71,20.29,18,16.61A9,9,0,1,0,16.61,18l3.68,3.68a1,1,0,0,0,1.42,0A1,1,0,0,0,21.71,20.29ZM11,18a7,7,0,1,1,7-7A7,7,0,0,1,11,18Z" }, null, -1)
42
- ]))) : g("", !0)
42
+ ]))) : m("", !0),
43
+ t.name === "asc" ? (i(), o("g", Ke, d[5] || (d[5] = [
44
+ f("path", {
45
+ fill: "currentColor",
46
+ d: "M4.869 11H2.667L6 3h2l3.333 8H9.131l-.41-1H5.28zm1.23-3h1.803L7 5.8zm12.9 8V3h-2v13h-3l4 5l4-5zm-8-3H3v2h4.855L3 19v2h8v-2H6.146L11 15z"
47
+ }, null, -1)
48
+ ]))) : m("", !0),
49
+ t.name === "desc" ? (i(), o("g", De, d[6] || (d[6] = [
50
+ f("path", {
51
+ fill: "currentColor",
52
+ d: "M4.869 11H2.667L6 3h2l3.333 8H9.131l-.41-1H5.28zm1.23-3h1.803L7 5.8zm15.9 0l-4-5l-4 5h3v13h2V8zm-11 5H3v2h4.855L3 19v2h8v-2H6.146L11 15z"
53
+ }, null, -1)
54
+ ]))) : m("", !0)
43
55
  ], 2));
44
56
  }
45
- }, A = /* @__PURE__ */ P(ye, [["__scopeId", "data-v-ef3cb04b"]]), pe = { class: "tree-select-item-wrapper" }, be = {
57
+ }, $ = /* @__PURE__ */ ee(Te, [["__scopeId", "data-v-d347d13a"]]), qe = { class: "tree-select-item-wrapper" }, He = {
46
58
  key: 1,
47
59
  class: "expander-placeholder"
48
- }, xe = ["checked", ".indeterminate", "disabled"], ke = { class: "item-content" }, Se = {
60
+ }, Oe = ["checked", ".indeterminate", "disabled"], Re = { class: "item-content" }, Ze = {
49
61
  key: 0,
50
62
  class: "children-wrapper"
51
- }, we = {
63
+ }, je = {
52
64
  __name: "TreeSelectItem",
53
65
  props: {
54
66
  item: { type: Object, required: !0 },
@@ -64,50 +76,50 @@ const P = (t, B) => {
64
76
  disableBranchNode: { type: Boolean, default: !1 }
65
77
  },
66
78
  emits: ["select", "toggle-expand"],
67
- setup(t, { emit: B }) {
68
- const l = t, h = (d) => d[l.optionValue] || d.id || d.value, o = (d) => !l.disabledKey || !d ? !1 : d.hasOwnProperty(l.disabledKey) && d[l.disabledKey] !== null, v = b(() => l.item.children && l.item.children.length > 0), x = b(() => l.expandedItems.has(h(l.item))), k = b(() => l.selectedItems.includes(h(l.item))), V = (d) => {
79
+ setup(t, { emit: z }) {
80
+ const l = t, v = (u) => u[l.optionValue] || u.id || u.value, d = (u) => !l.disabledKey || !u ? !1 : u.hasOwnProperty(l.disabledKey) && u[l.disabledKey] !== null, x = y(() => l.item.children && l.item.children.length > 0), C = y(() => l.expandedItems.has(v(l.item))), S = y(() => l.selectedItems.includes(v(l.item))), M = (u) => {
69
81
  let c = [];
70
- return d.children && d.children.forEach((I) => {
71
- c.push(h(I)), c.push(...V(I));
82
+ return u.children && u.children.forEach((V) => {
83
+ c.push(v(V)), c.push(...M(V));
72
84
  }), c;
73
- }, $ = b(() => !l.multiple || !l.selectAll || !v.value || k.value ? !1 : V(l.item).some((c) => l.selectedItems.includes(c)));
74
- return (d, c) => {
75
- const I = ae("TreeSelectItem", !0);
76
- return i(), u("div", pe, [
85
+ }, E = y(() => !l.multiple || !l.selectAll || !x.value || S.value ? !1 : M(l.item).some((c) => l.selectedItems.includes(c)));
86
+ return (u, c) => {
87
+ const V = Ce("TreeSelectItem", !0);
88
+ return i(), o("div", qe, [
77
89
  f("div", {
78
- class: L(["list-group-item list-group-item-action d-flex align-items-center gap-2", {
79
- "bg-primary text-white": k.value && (t.selectMode === "highlight" || !t.multiple) && !o(t.item) && !(t.disableBranchNode && v.value),
80
- "is-disabled text-muted bg-light": o(t.item)
90
+ class: B(["list-group-item list-group-item-action d-flex align-items-center gap-2", {
91
+ "bg-primary text-white": S.value && (t.selectMode === "highlight" || !t.multiple) && !d(t.item) && !(t.disableBranchNode && x.value),
92
+ "is-disabled text-muted bg-light": d(t.item)
81
93
  }]),
82
- style: se({ "padding-left": `${t.level * 1.5 + 1}rem` }),
83
- onClick: c[2] || (c[2] = (m) => o(t.item) || t.disableBranchNode && v.value ? null : d.$emit("select", t.item))
94
+ style: Ve({ "padding-left": `${t.level * 1.5 + 1}rem` }),
95
+ onClick: c[2] || (c[2] = (w) => d(t.item) || t.disableBranchNode && x.value ? null : u.$emit("select", t.item))
84
96
  }, [
85
- v.value ? (i(), E(A, {
97
+ x.value ? (i(), P($, {
86
98
  key: 0,
87
99
  name: "chevron-right",
88
- class: L(["expander-icon", { "rotate-90": x.value }]),
89
- onClick: c[0] || (c[0] = z((m) => d.$emit("toggle-expand", h(t.item)), ["stop"]))
90
- }, null, 8, ["class"])) : (i(), u("span", be)),
91
- t.multiple && t.selectMode === "checkbox" && !(t.disableBranchNode && v.value) ? (i(), u("input", {
100
+ class: B(["expander-icon", { "rotate-90": C.value }]),
101
+ onClick: c[0] || (c[0] = K((w) => u.$emit("toggle-expand", v(t.item)), ["stop"]))
102
+ }, null, 8, ["class"])) : (i(), o("span", He)),
103
+ t.multiple && t.selectMode === "checkbox" && !(t.disableBranchNode && x.value) ? (i(), o("input", {
92
104
  key: 2,
93
105
  type: "checkbox",
94
106
  class: "form-check-input",
95
- checked: k.value,
96
- ".indeterminate": $.value,
97
- disabled: o(t.item),
98
- onClick: c[1] || (c[1] = z((m) => d.$emit("select", t.item), ["stop"]))
99
- }, null, 40, xe)) : g("", !0),
100
- f("div", ke, [
101
- T(d.$slots, "default", {
107
+ checked: S.value,
108
+ ".indeterminate": E.value,
109
+ disabled: d(t.item),
110
+ onClick: c[1] || (c[1] = K((w) => u.$emit("select", t.item), ["stop"]))
111
+ }, null, 40, Oe)) : m("", !0),
112
+ f("div", Re, [
113
+ _(u.$slots, "default", {
102
114
  item: t.item,
103
115
  level: t.level
104
116
  }, void 0, !0)
105
117
  ])
106
118
  ], 6),
107
- v.value && x.value ? (i(), u("div", Se, [
108
- (i(!0), u(Q, null, X(t.item.children, (m) => (i(), E(I, {
109
- key: h(m),
110
- item: m,
119
+ x.value && C.value ? (i(), o("div", Ze, [
120
+ (i(!0), o(O, null, R(t.item.children, (w) => (i(), P(V, {
121
+ key: v(w),
122
+ item: w,
111
123
  level: t.level + 1,
112
124
  "selected-items": t.selectedItems,
113
125
  "expanded-items": t.expandedItems,
@@ -118,47 +130,61 @@ const P = (t, B) => {
118
130
  "option-value": t.optionValue,
119
131
  "disabled-key": t.disabledKey,
120
132
  "disable-branch-node": t.disableBranchNode,
121
- onSelect: c[3] || (c[3] = (S) => d.$emit("select", S)),
122
- onToggleExpand: c[4] || (c[4] = (S) => d.$emit("toggle-expand", S))
133
+ onSelect: c[3] || (c[3] = (k) => u.$emit("select", k)),
134
+ onToggleExpand: c[4] || (c[4] = (k) => u.$emit("toggle-expand", k))
123
135
  }, {
124
- default: Y(({ item: S, level: y }) => [
125
- T(d.$slots, "default", {
126
- item: S,
127
- level: y
136
+ default: ve(({ item: k, level: N }) => [
137
+ _(u.$slots, "default", {
138
+ item: k,
139
+ level: N
128
140
  }, void 0, !0)
129
141
  ]),
130
142
  _: 2
131
143
  }, 1032, ["item", "level", "selected-items", "expanded-items", "multiple", "select-all", "select-mode", "option-label", "option-value", "disabled-key", "disable-branch-node"]))), 128))
132
- ])) : g("", !0)
144
+ ])) : m("", !0)
133
145
  ]);
134
146
  };
135
147
  }
136
- }, Ve = /* @__PURE__ */ P(we, [["__scopeId", "data-v-9766821f"]]), Ie = { class: "tree-select-wrapper" }, Le = ["disabled"], Be = { class: "tree-select-display-text text-truncate me-2 text-start" }, $e = { class: "d-flex align-items-center gap-2" }, Ce = {
148
+ }, Fe = /* @__PURE__ */ ee(je, [["__scopeId", "data-v-9766821f"]]), Ue = { class: "tree-select-wrapper" }, We = ["disabled"], Ge = { class: "tree-select-display-container" }, Je = {
137
149
  key: 0,
138
- class: "p-2 border-bottom"
139
- }, Ae = {
150
+ class: "text-truncate"
151
+ }, Qe = { key: 1 }, Xe = {
152
+ key: 0,
153
+ class: "text-muted"
154
+ }, Ye = {
155
+ key: 1,
156
+ class: "chips-container"
157
+ }, _e = { class: "d-flex align-items-center gap-2" }, et = { class: "list-group list-group-flush" }, tt = { class: "text-truncate me-2" }, lt = { class: "p-2 border-bottom d-flex flex-column gap-2" }, nt = {
140
158
  key: 1,
159
+ class: "d-flex align-items-center gap-2"
160
+ }, st = ["value"], at = ["disabled"], it = {
161
+ key: 0,
141
162
  class: "p-4 text-muted text-center"
142
- }, Ee = {
143
- key: 2,
163
+ }, ot = {
164
+ key: 1,
144
165
  class: "tree-select-body",
145
166
  style: { "max-height": "300px", "overflow-y": "auto" }
146
- }, Me = {
167
+ }, rt = {
147
168
  key: 0,
148
169
  class: "list-group list-group-flush"
149
- }, Ne = {
170
+ }, dt = {
150
171
  class: "d-flex align-items-center gap-2",
151
172
  style: { "white-space": "wrap" }
152
- }, Ke = {
173
+ }, ut = {
153
174
  key: 1,
154
175
  class: "p-3 text-muted text-center"
155
- }, qe = {
176
+ }, ct = {
156
177
  __name: "TreeSelectMain",
157
178
  props: {
158
179
  modelValue: {
159
180
  type: [String, Number, Array],
160
181
  default: null
161
182
  },
183
+ displayMode: {
184
+ type: String,
185
+ default: "text",
186
+ validator: (t) => ["text", "chips"].includes(t)
187
+ },
162
188
  items: {
163
189
  type: Array,
164
190
  default: () => []
@@ -170,7 +196,6 @@ const P = (t, B) => {
170
196
  selectMode: {
171
197
  type: String,
172
198
  default: "checkbox",
173
- // 'checkbox' or 'highlight'
174
199
  validator: (t) => ["checkbox", "highlight"].includes(t)
175
200
  },
176
201
  placeholder: {
@@ -225,114 +250,158 @@ const P = (t, B) => {
225
250
  type: String,
226
251
  default: "sm",
227
252
  validator: (t) => ["sm", "md", "lg", "xl"].includes(t)
253
+ },
254
+ sortable: {
255
+ type: Boolean,
256
+ default: !1
257
+ },
258
+ sortOptions: {
259
+ type: Array,
260
+ default: () => []
261
+ // e.g., [{ value: 'name', label: 'Name' }, { value: 'details.id', label: 'ID' }]
262
+ },
263
+ defaultSortKey: {
264
+ type: String,
265
+ default: null
266
+ },
267
+ defaultSortDirection: {
268
+ type: String,
269
+ default: "asc",
270
+ validator: (t) => ["asc", "desc"].includes(t)
271
+ },
272
+ maxVisibleChipsDisplay: {
273
+ type: Number,
274
+ default: 3
228
275
  }
229
276
  },
230
277
  emits: ["update:modelValue", "change"],
231
- setup(t, { emit: B }) {
232
- const l = t, h = B, o = C(null), v = C(null), x = C(""), k = C(!1), V = C(/* @__PURE__ */ new Set()), $ = C(null), d = b(() => l.size === "sm" ? "btn-sm" : l.size === "lg" ? "btn-lg" : l.size === "xl" ? "btn-xl" : ""), c = b(() => l.size === "sm" ? "form-control-sm" : l.size === "lg" ? "form-control-lg" : l.size === "xl" ? "form-control-xl" : ""), I = (e) => e[l.optionLabel] || e.label || e.name || "", m = (e) => e[l.optionValue] || e.id || e.value, S = (e) => !l.disabledKey || !e ? !1 : e.hasOwnProperty(l.disabledKey) && e[l.disabledKey] !== null, y = (e) => e.children && e.children.length > 0, D = (e, a = l.items) => {
233
- for (const n of a) {
234
- if (m(n) === e) return n;
235
- if (y(n)) {
236
- const s = D(e, n.children);
237
- if (s) return s;
278
+ setup(t, { emit: z }) {
279
+ const l = t, v = z, d = b(null), x = b(null), C = b(""), S = b(!1), M = b(/* @__PURE__ */ new Set()), E = b(null), u = b(l.defaultSortKey), c = b(l.defaultSortDirection), V = b(null), w = b(null), k = b(!1), N = b(null), te = y(() => l.size === "sm" ? "btn-sm" : l.size === "lg" ? "btn-lg" : l.size === "xl" ? "btn-xl" : ""), le = y(() => l.size === "sm" ? "form-control-sm" : l.size === "lg" ? "form-control-lg" : l.size === "xl" ? "form-control-xl" : ""), D = (e) => e && (e[l.optionLabel] || e.label || e.name) || "", p = (e) => e ? e[l.optionValue] || e.id || e.value : null, j = (e) => !l.disabledKey || !e ? !1 : e.hasOwnProperty(l.disabledKey) && e[l.disabledKey] !== null, L = (e) => e.children && e.children.length > 0, ne = (e, s) => {
280
+ if (s)
281
+ return s.split(".").reduce((n, a) => n && n[a], e);
282
+ }, F = (e, s = l.items) => {
283
+ for (const n of s) {
284
+ if (p(n) === e) return n;
285
+ if (L(n)) {
286
+ const a = F(e, n.children);
287
+ if (a) return a;
238
288
  }
239
289
  }
240
290
  return null;
241
- }, O = (e) => {
242
- const a = [];
243
- return y(e) && e.children.forEach((n) => {
244
- S(n) || (a.push(m(n)), a.push(...O(n)));
245
- }), a;
246
- }, Z = (e, a = l.items, n = []) => {
247
- for (const s of a) {
248
- if (m(s) === e) return n;
249
- if (y(s)) {
250
- const r = Z(e, s.children, [...n, m(s)]);
291
+ }, se = (e) => {
292
+ const s = [];
293
+ return L(e) && e.children.forEach((n) => {
294
+ j(n) || (s.push(p(n)), s.push(...se(n)));
295
+ }), s;
296
+ }, U = (e, s = l.items, n = []) => {
297
+ for (const a of s) {
298
+ if (p(a) === e) return n;
299
+ if (L(a)) {
300
+ const r = U(e, a.children, [...n, p(a)]);
251
301
  if (r) return r;
252
302
  }
253
303
  }
254
304
  return null;
255
- }, M = b(() => {
305
+ }, I = y(() => {
256
306
  const e = new Set(Array.isArray(l.modelValue) ? l.modelValue : [l.modelValue].filter(Boolean));
257
307
  if (l.multiple && l.selectAll) {
258
- const a = (n) => {
259
- n.forEach((s) => {
260
- if (y(s)) {
261
- const r = s.children.filter((w) => !S(w));
262
- r.length > 0 && r.every((w) => e.has(m(w))) && e.add(m(s)), a(s.children);
308
+ const s = (n) => {
309
+ n.forEach((a) => {
310
+ if (L(a)) {
311
+ const r = a.children.filter((h) => !j(h));
312
+ r.length > 0 && r.every((h) => e.has(p(h))) && e.add(p(a)), s(a.children);
263
313
  }
264
314
  });
265
315
  };
266
- a(l.items);
316
+ s(l.items);
267
317
  }
268
318
  return Array.from(e);
269
- }), N = (e, a = l.items, n = []) => {
270
- for (const s of a) {
271
- const r = [...n, I(s)];
272
- if (m(s) === e) return r;
273
- if (y(s)) {
274
- const p = N(e, s.children, r);
275
- if (p) return p;
319
+ }), W = (e, s = l.items, n = []) => {
320
+ for (const a of s) {
321
+ const r = [...n, D(a)];
322
+ if (p(a) === e) return r;
323
+ if (L(a)) {
324
+ const g = W(e, a.children, r);
325
+ if (g) return g;
276
326
  }
277
327
  }
278
328
  return null;
279
- }, F = (e) => {
329
+ }, ae = (e) => {
280
330
  if (!e || e.length === 0) return "";
281
- const a = e.join(" → ");
282
- return a.length <= 40 ? a : e.length > 2 ? `${e[0]} → ... → ${e[e.length - 1]}` : a;
283
- }, _ = b(() => {
284
- const e = Array.isArray(l.modelValue) ? l.modelValue : [l.modelValue].filter(Boolean);
331
+ const s = e.join(" → ");
332
+ return s.length <= 40 ? s : e.length > 2 ? `${e[0]} → ... → ${e[e.length - 1]}` : s;
333
+ }, he = y(() => {
334
+ const e = I.value;
285
335
  if (e.length === 0) return l.placeholder;
286
336
  if (l.multiple) {
287
337
  if (e.length === 1) {
288
- const n = N(e[0]);
289
- return n ? F(n) : e[0];
338
+ const n = W(e[0]);
339
+ return n ? ae(n) : e[0];
290
340
  }
291
341
  return `${e.length} items selected`;
292
342
  }
293
- const a = N(e[0]);
294
- return a ? F(a) : e[0];
295
- }), R = (e, a) => e.map((n) => {
296
- const s = I(n).toLowerCase().includes(a);
343
+ const s = W(e[0]);
344
+ return s ? ae(s) : e[0];
345
+ }), G = y(() => !l.multiple || I.value.length === 0 ? [] : I.value.map((e) => F(e)).filter(Boolean)), ge = y(() => G.value.slice(0, l.maxVisibleChipsDisplay)), ie = y(() => {
346
+ const e = G.value.length - l.maxVisibleChipsDisplay;
347
+ return e > 0 ? e : 0;
348
+ }), oe = (e, s) => e.map((n) => {
349
+ const a = D(n).toLowerCase().includes(s);
297
350
  let r = [];
298
- return y(n) && (r = R(n.children, a)), s || r.length > 0 ? { ...n, children: r } : null;
299
- }).filter(Boolean), K = b(() => x.value.trim() ? R(l.items, x.value.toLowerCase()) : l.items), ee = (e) => {
351
+ return L(n) && (r = oe(n.children, s)), a || r.length > 0 ? { ...n, children: r } : null;
352
+ }).filter(Boolean), re = (e, s, n) => !e || !s ? e : [...e].sort((r, g) => {
353
+ const h = ne(r, s), T = ne(g, s);
354
+ if (h == null) return 1;
355
+ if (T == null) return -1;
356
+ let q = 0;
357
+ return typeof h == "string" && typeof T == "string" ? q = h.localeCompare(T) : h > T ? q = 1 : h < T && (q = -1), n === "desc" ? q * -1 : q;
358
+ }).map((r) => L(r) ? { ...r, children: re(r.children, s, n) } : r), J = y(() => {
359
+ const e = C.value.trim() ? oe(l.items, C.value.toLowerCase()) : l.items;
360
+ return !l.sortable || !u.value ? e : re(e, u.value, c.value);
361
+ }), pe = (e) => {
300
362
  if (l.disableBranchNodes && e.children && e.children.length > 0) {
301
363
  const r = e[l.optionValue] || e.id || e.value;
302
- j(r);
364
+ ue(r);
303
365
  return;
304
366
  }
305
- if (S(e)) return;
306
- const a = m(e);
307
- let n = new Set(M.value);
367
+ if (j(e)) return;
368
+ const s = p(e);
369
+ let n = new Set(I.value);
308
370
  if (l.multiple) {
309
- const r = n.has(a);
310
- if (l.selectAll && y(e)) {
311
- const p = O(e);
312
- r ? (n.delete(a), p.forEach((w) => n.delete(w))) : (n.add(a), p.forEach((w) => n.add(w)));
371
+ const r = n.has(s);
372
+ if (l.selectAll && L(e)) {
373
+ const g = se(e);
374
+ r ? (n.delete(s), g.forEach((h) => n.delete(h))) : (n.add(s), g.forEach((h) => n.add(h)));
313
375
  } else
314
- r ? (n.delete(a), l.selectAll && Z(a)?.forEach((w) => n.delete(w))) : n.add(a);
376
+ r ? (n.delete(s), l.selectAll && U(s)?.forEach((h) => n.delete(h))) : n.add(s);
315
377
  } else
316
- n = /* @__PURE__ */ new Set([a]), q();
317
- let s = Array.from(n);
318
- l.multiple && l.excludeFromSelectedListKey && (s = s.filter((r) => {
319
- const p = D(r);
320
- return !p || !p[l.excludeFromSelectedListKey];
321
- })), h("update:modelValue", l.multiple ? s : s[0] || null), h("change", l.multiple ? s : s[0] || null);
322
- }, j = (e) => {
323
- V.value.has(e) ? V.value.delete(e) : V.value.add(e);
324
- }, te = () => {
378
+ n = /* @__PURE__ */ new Set([s]), Q();
379
+ let a = Array.from(n);
380
+ l.multiple && l.excludeFromSelectedListKey && (a = a.filter((r) => {
381
+ const g = F(r);
382
+ return !g || !g[l.excludeFromSelectedListKey];
383
+ })), v("update:modelValue", l.multiple ? a : a[0] || null), v("change", l.multiple ? a : a[0] || null);
384
+ }, de = (e) => {
385
+ if (l.disabled || !e) return;
386
+ const s = p(e), n = new Set(I.value);
387
+ n.delete(s), l.selectAll && U(s)?.forEach((g) => n.delete(g));
388
+ const a = Array.from(n);
389
+ v("update:modelValue", a), v("change", a);
390
+ }, ue = (e) => {
391
+ M.value.has(e) ? M.value.delete(e) : M.value.add(e);
392
+ }, ye = () => {
393
+ c.value = c.value === "asc" ? "desc" : "asc";
394
+ }, be = () => {
325
395
  const e = l.multiple ? [] : null;
326
- h("update:modelValue", e), h("change", e);
327
- }, le = async () => {
328
- l.disabled || (k.value = !0, await J(), o.value && v.value && ($.value = ce(v.value, o.value, {
396
+ v("update:modelValue", e), v("change", e), Z();
397
+ }, xe = async () => {
398
+ l.disabled || (Z(), S.value = !0, await Y(), d.value && x.value && (E.value = me(x.value, d.value, {
329
399
  placement: "bottom-start",
330
400
  strategy: "fixed",
331
401
  modifiers: [
332
402
  { name: "offset", options: { offset: [0, 4] } },
333
403
  { name: "preventOverflow", options: { padding: 8 } },
334
404
  { name: "flip", options: { fallbackPlacements: ["top-start"] } },
335
- // Add this 'sameWidth' modifier
336
405
  {
337
406
  name: "sameWidth",
338
407
  enabled: !0,
@@ -346,93 +415,173 @@ const P = (t, B) => {
346
415
  }
347
416
  }
348
417
  ]
349
- })), l.searchable && (await J(), o.value?.querySelector(".tree-search-input")?.focus()));
350
- }, q = () => {
351
- k.value = !1, x.value = "", $.value?.destroy(), $.value = null;
352
- }, ne = () => k.value ? q() : le(), W = (e) => {
353
- !v.value?.contains(e.target) && !o.value?.contains(e.target) && q();
418
+ })), l.searchable && (await Y(), d.value?.querySelector(".tree-search-input")?.focus()));
419
+ }, Q = () => {
420
+ S.value = !1, C.value = "", E.value?.destroy(), E.value = null;
421
+ }, ke = () => S.value ? Q() : xe(), Se = async () => {
422
+ l.disabled || (k.value = !0, await Y(), w.value && V.value && (N.value = me(V.value, w.value, {
423
+ placement: "bottom-end",
424
+ strategy: "fixed",
425
+ modifiers: [{ name: "offset", options: { offset: [0, 4] } }]
426
+ })));
427
+ }, Z = () => {
428
+ k.value = !1, N.value?.destroy(), N.value = null;
429
+ }, we = () => k.value ? Z() : Se(), ce = (e) => {
430
+ S.value && !x.value?.contains(e.target) && !d.value?.contains(e.target) && Q(), k.value && !V.value?.contains(e.target) && !w.value?.contains(e.target) && Z();
354
431
  };
355
- return ie(() => document.addEventListener("click", W)), oe(() => {
356
- document.removeEventListener("click", W), $.value?.destroy();
357
- }), de(x, (e) => {
432
+ return Le(() => document.addEventListener("click", ce)), Ie(() => {
433
+ document.removeEventListener("click", ce), E.value?.destroy(), N.value?.destroy();
434
+ }), $e(C, (e) => {
358
435
  if (e.trim()) {
359
- const a = (n) => {
360
- n.forEach((s) => {
361
- y(s) && (V.value.add(m(s)), a(s.children));
436
+ const s = (n) => {
437
+ n.forEach((a) => {
438
+ L(a) && (M.value.add(p(a)), s(a.children));
362
439
  });
363
440
  };
364
- a(K.value);
441
+ s(J.value);
365
442
  }
366
- }), (e, a) => (i(), u("div", Ie, [
443
+ }), (e, s) => (i(), o("div", Ue, [
367
444
  f("button", {
368
445
  ref_key: "triggerRef",
369
- ref: v,
446
+ ref: x,
370
447
  type: "button",
371
- class: L(["btn tree-select-trigger w-100 d-flex justify-content-between align-items-center tree-select-main", [
372
- d.value,
448
+ class: B(["btn tree-select-trigger w-100 d-flex justify-content-between align-items-center tree-select-main", [
449
+ te.value,
373
450
  {
374
451
  "btn-outline-secondary": !t.isInvalid,
375
452
  "border-danger": t.isInvalid,
376
453
  disabled: t.disabled || t.isLoading,
377
- "is-loading": t.isLoading
454
+ "is-loading": t.isLoading,
455
+ "has-chips": t.multiple && t.displayMode === "chips" && I.value.length > 0
378
456
  }
379
457
  ]]),
380
458
  disabled: t.disabled || t.isLoading,
381
- onClick: ne
459
+ onClick: ke
382
460
  }, [
383
- f("span", Be, [
384
- f("span", null, U(t.isLoading ? "Loading data..." : _.value), 1)
461
+ f("div", Ge, [
462
+ !t.multiple || t.displayMode === "text" ? (i(), o("span", Je, A(t.isLoading ? "Loading data..." : he.value), 1)) : t.multiple && t.displayMode === "chips" ? (i(), o("div", Qe, [
463
+ I.value.length === 0 ? (i(), o("span", Xe, A(t.placeholder), 1)) : (i(), o("div", Ye, [
464
+ (i(!0), o(O, null, R(ge.value, (n) => (i(), o("span", {
465
+ key: p(n),
466
+ class: "badge text-bg-primary chip bg-primary"
467
+ }, [
468
+ X(A(D(n)) + " ", 1),
469
+ H($, {
470
+ name: "times",
471
+ class: "chip-remove",
472
+ onClick: K((a) => de(n), ["stop"])
473
+ }, null, 8, ["onClick"])
474
+ ]))), 128)),
475
+ ie.value > 0 ? (i(), o("button", {
476
+ key: 0,
477
+ ref_key: "moreTriggerRef",
478
+ ref: V,
479
+ type: "button",
480
+ class: "btn btn-sm btn-light more-button",
481
+ onClick: K(we, ["stop"])
482
+ }, " +" + A(ie.value), 513)) : m("", !0)
483
+ ]))
484
+ ])) : m("", !0)
385
485
  ]),
386
- f("div", $e, [
387
- t.isLoading ? (i(), E(A, {
486
+ f("div", _e, [
487
+ t.isLoading ? (i(), P($, {
388
488
  key: 0,
389
489
  name: "spinner",
390
490
  class: "loading-icon"
391
- })) : g("", !0),
392
- t.showClearButton && M.value.length > 0 && !t.disabled && !t.isLoading ? (i(), E(A, {
491
+ })) : m("", !0),
492
+ t.showClearButton && I.value.length > 0 && !t.disabled && !t.isLoading ? (i(), P($, {
393
493
  key: 1,
394
494
  name: "times",
395
- onClick: z(te, ["stop"]),
495
+ onClick: K(be, ["stop"]),
396
496
  class: "clear-icon"
397
- })) : g("", !0),
398
- t.isLoading ? g("", !0) : (i(), E(A, {
497
+ })) : m("", !0),
498
+ t.isLoading ? m("", !0) : (i(), P($, {
399
499
  key: 2,
400
500
  name: "chevron-down",
401
- class: L(["transition-transform", { "rotate-180": k.value }])
501
+ class: B(["transition-transform", { "rotate-180": S.value }])
402
502
  }, null, 8, ["class"]))
403
503
  ])
404
- ], 10, Le),
405
- k.value ? (i(), u("div", {
504
+ ], 10, We),
505
+ k.value ? (i(), o("div", {
406
506
  key: 0,
507
+ ref_key: "morePopoverRef",
508
+ ref: w,
509
+ class: "card shadow-lg border-0 more-popover",
510
+ style: { "z-index": "1060" }
511
+ }, [
512
+ f("div", et, [
513
+ (i(!0), o(O, null, R(G.value, (n) => (i(), o("div", {
514
+ key: p(n),
515
+ class: "list-group-item d-flex justify-content-between align-items-center py-1 px-2"
516
+ }, [
517
+ f("small", tt, A(D(n)), 1),
518
+ H($, {
519
+ name: "times",
520
+ class: "chip-remove flex-shrink-0",
521
+ onClick: K((a) => de(n), ["stop"])
522
+ }, null, 8, ["onClick"])
523
+ ]))), 128))
524
+ ])
525
+ ], 512)) : m("", !0),
526
+ S.value ? (i(), o("div", {
527
+ key: 1,
407
528
  ref_key: "dropdownRef",
408
- ref: o,
529
+ ref: d,
409
530
  class: "tree-select-dropdown card shadow-lg border-0",
410
531
  style: { "z-index": "1050" }
411
532
  }, [
412
- t.searchable ? (i(), u("div", Ce, [
413
- re(f("input", {
414
- "onUpdate:modelValue": a[0] || (a[0] = (n) => x.value = n),
533
+ f("div", lt, [
534
+ t.searchable ? fe((i(), o("input", {
535
+ key: 0,
536
+ "onUpdate:modelValue": s[0] || (s[0] = (n) => C.value = n),
415
537
  type: "text",
416
- class: L(["form-control tree-search-input", c.value]),
538
+ class: B(["form-control tree-search-input", le.value]),
417
539
  placeholder: "Search..."
418
- }, null, 2), [
419
- [ue, x.value]
420
- ])
421
- ])) : g("", !0),
422
- t.isLoading ? (i(), u("div", Ae, [
423
- H(A, {
540
+ }, null, 2)), [
541
+ [Be, C.value]
542
+ ]) : m("", !0),
543
+ t.sortable && t.sortOptions.length > 0 ? (i(), o("div", nt, [
544
+ fe(f("select", {
545
+ "onUpdate:modelValue": s[1] || (s[1] = (n) => u.value = n),
546
+ class: B(["form-select flex-grow-1", le.value])
547
+ }, [
548
+ s[2] || (s[2] = f("option", {
549
+ value: null,
550
+ disabled: ""
551
+ }, "Sort by...", -1)),
552
+ (i(!0), o(O, null, R(t.sortOptions, (n) => (i(), o("option", {
553
+ key: n.value,
554
+ value: n.value
555
+ }, A(n.label), 9, st))), 128))
556
+ ], 2), [
557
+ [Me, u.value]
558
+ ]),
559
+ f("button", {
560
+ type: "button",
561
+ class: B(["btn btn-outline-secondary", te.value]),
562
+ disabled: !u.value,
563
+ onClick: ye
564
+ }, [
565
+ H($, {
566
+ name: c.value === "asc" ? "asc" : "desc"
567
+ }, null, 8, ["name"])
568
+ ], 10, at)
569
+ ])) : m("", !0)
570
+ ]),
571
+ t.isLoading ? (i(), o("div", it, [
572
+ H($, {
424
573
  name: "spinner",
425
574
  class: "me-2"
426
575
  }),
427
- a[1] || (a[1] = f("span", null, "Loading...", -1))
428
- ])) : (i(), u("div", Ee, [
429
- K.value.length > 0 ? (i(), u("div", Me, [
430
- (i(!0), u(Q, null, X(K.value, (n) => (i(), E(Ve, {
431
- key: m(n),
576
+ s[3] || (s[3] = f("span", null, "Loading...", -1))
577
+ ])) : (i(), o("div", ot, [
578
+ J.value.length > 0 ? (i(), o("div", rt, [
579
+ (i(!0), o(O, null, R(J.value, (n) => (i(), P(Fe, {
580
+ key: p(n),
432
581
  item: n,
433
582
  level: 0,
434
- "selected-items": M.value,
435
- "expanded-items": V.value,
583
+ "selected-items": I.value,
584
+ "expanded-items": M.value,
436
585
  multiple: t.multiple,
437
586
  "select-all": t.selectAll,
438
587
  "select-mode": t.selectMode,
@@ -440,42 +589,42 @@ const P = (t, B) => {
440
589
  "option-value": t.optionValue,
441
590
  "disabled-key": t.disabledKey,
442
591
  "disable-branch-node": t.disableBranchNodes,
443
- onSelect: ee,
444
- onToggleExpand: j
592
+ onSelect: pe,
593
+ onToggleExpand: ue
445
594
  }, {
446
- default: Y(({ item: s, level: r }) => [
447
- T(e.$slots, "default", {
448
- item: s,
595
+ default: ve(({ item: a, level: r }) => [
596
+ _(e.$slots, "default", {
597
+ item: a,
449
598
  level: r
450
599
  }, () => [
451
- f("div", Ne, [
452
- G(U(I(s)) + " ", 1),
453
- s.icon ? (i(), u("i", {
600
+ f("div", dt, [
601
+ X(A(D(a)) + " ", 1),
602
+ a.icon ? (i(), o("i", {
454
603
  key: 0,
455
- class: L(s.icon)
456
- }, null, 2)) : g("", !0)
604
+ class: B(a.icon)
605
+ }, null, 2)) : m("", !0)
457
606
  ])
458
607
  ], !0)
459
608
  ]),
460
609
  _: 2
461
610
  }, 1032, ["item", "selected-items", "expanded-items", "multiple", "select-all", "select-mode", "option-label", "option-value", "disabled-key", "disable-branch-node"]))), 128))
462
- ])) : (i(), u("div", Ke, [
463
- H(A, {
611
+ ])) : (i(), o("div", ut, [
612
+ H($, {
464
613
  name: "search",
465
614
  class: "me-1"
466
615
  }),
467
- a[2] || (a[2] = G(" No items found ", -1))
616
+ s[4] || (s[4] = X(" No items found ", -1))
468
617
  ]))
469
618
  ]))
470
- ], 512)) : g("", !0)
619
+ ], 512)) : m("", !0)
471
620
  ]));
472
621
  }
473
- }, ze = /* @__PURE__ */ P(qe, [["__scopeId", "data-v-5e70d4e4"]]), De = {
622
+ }, ft = /* @__PURE__ */ ee(ct, [["__scopeId", "data-v-a9a04e35"]]), ht = {
474
623
  install(t) {
475
- t.component("VSelect", ze);
624
+ t.component("VSelect", ft);
476
625
  }
477
626
  };
478
627
  export {
479
- ze as VSelect,
480
- De as default
628
+ ft as VSelect,
629
+ ht as default
481
630
  };
@@ -1 +1 @@
1
- (function(g,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue"),require("@popperjs/core")):typeof define=="function"&&define.amd?define(["exports","vue","@popperjs/core"],e):(g=typeof globalThis<"u"?globalThis:g||self,e(g.VueSelect={},g.Vue,g.Popper))})(this,function(g,e,O){"use strict";const C=(l,E)=>{const n=l.__vccOpts||l;for(const[u,s]of E)n[u]=s;return n},j={key:0},Z={key:1},F={key:2},R={key:3},W={key:4},S=C({__name:"SvgIcon",props:{name:{type:String,required:!0}},setup(l){const E=l,n=e.computed(()=>({"svg-icon-spin":E.name==="spinner"}));return(u,s)=>(e.openBlock(),e.createElementBlock("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",width:"1em",height:"1em",class:e.normalizeClass(n.value)},[l.name==="spinner"?(e.openBlock(),e.createElementBlock("g",j,s[0]||(s[0]=[e.createElementVNode("path",{d:"M12,4V2A10,10,0,0,0,2,12H4A8,8,0,0,1,12,4Z"},null,-1)]))):e.createCommentVNode("",!0),l.name==="times"?(e.openBlock(),e.createElementBlock("g",Z,s[1]||(s[1]=[e.createElementVNode("path",{d:"M13.41,12l4.3-4.29a1,1,0,1,0-1.42-1.42L12,10.59,7.71,6.29A1,1,0,0,0,6.29,7.71L10.59,12l-4.3,4.29a1,1,0,0,0,0,1.42,1,1,0,0,0,1.42,0L12,13.41l4.29,4.3a1,1,0,0,0,1.42,0,1,1,0,0,0,0-1.42Z"},null,-1)]))):e.createCommentVNode("",!0),l.name==="chevron-down"?(e.openBlock(),e.createElementBlock("g",F,s[2]||(s[2]=[e.createElementVNode("path",{d:"M17,9.17a1,1,0,0,0-1.41,0L12,12.71,8.46,9.17a1,1,0,0,0-1.41,0,1,1,0,0,0,0,1.42l4.24,4.24a1,1,0,0,0,1.42,0L17,10.59A1,1,0,0,0,17,9.17Z"},null,-1)]))):e.createCommentVNode("",!0),l.name==="chevron-right"?(e.openBlock(),e.createElementBlock("g",R,s[3]||(s[3]=[e.createElementVNode("path",{d:"M10.83,12l-4.24,4.24a1,1,0,0,0,1.41,1.41L13.66,12,8,6.34A1,1,0,0,0,6.59,7.76Z"},null,-1)]))):e.createCommentVNode("",!0),l.name==="search"?(e.openBlock(),e.createElementBlock("g",W,s[4]||(s[4]=[e.createElementVNode("path",{d:"M21.71,20.29,18,16.61A9,9,0,1,0,16.61,18l3.68,3.68a1,1,0,0,0,1.42,0A1,1,0,0,0,21.71,20.29ZM11,18a7,7,0,1,1,7-7A7,7,0,0,1,11,18Z"},null,-1)]))):e.createCommentVNode("",!0)],2))}},[["__scopeId","data-v-ef3cb04b"]]),U={class:"tree-select-item-wrapper"},H={key:1,class:"expander-placeholder"},G=["checked",".indeterminate","disabled"],J={class:"item-content"},Q={key:0,class:"children-wrapper"},X=C({__name:"TreeSelectItem",props:{item:{type:Object,required:!0},level:{type:Number,required:!0},selectedItems:{type:Array,required:!0},expandedItems:{type:Set,required:!0},multiple:{type:Boolean,required:!0},selectAll:{type:Boolean,required:!0},selectMode:{type:String,required:!0},optionLabel:{type:String,required:!0},optionValue:{type:String,required:!0},disabledKey:{type:String,default:null},disableBranchNode:{type:Boolean,default:!1}},emits:["select","toggle-expand"],setup(l,{emit:E}){const n=l,u=r=>r[n.optionValue]||r.id||r.value,s=r=>!n.disabledKey||!r?!1:r.hasOwnProperty(n.disabledKey)&&r[n.disabledKey]!==null,f=e.computed(()=>n.item.children&&n.item.children.length>0),y=e.computed(()=>n.expandedItems.has(u(n.item))),k=e.computed(()=>n.selectedItems.includes(u(n.item))),V=r=>{let c=[];return r.children&&r.children.forEach(x=>{c.push(u(x)),c.push(...V(x))}),c},w=e.computed(()=>!n.multiple||!n.selectAll||!f.value||k.value?!1:V(n.item).some(c=>n.selectedItems.includes(c)));return(r,c)=>{const x=e.resolveComponent("TreeSelectItem",!0);return e.openBlock(),e.createElementBlock("div",U,[e.createElementVNode("div",{class:e.normalizeClass(["list-group-item list-group-item-action d-flex align-items-center gap-2",{"bg-primary text-white":k.value&&(l.selectMode==="highlight"||!l.multiple)&&!s(l.item)&&!(l.disableBranchNode&&f.value),"is-disabled text-muted bg-light":s(l.item)}]),style:e.normalizeStyle({"padding-left":`${l.level*1.5+1}rem`}),onClick:c[2]||(c[2]=m=>s(l.item)||l.disableBranchNode&&f.value?null:r.$emit("select",l.item))},[f.value?(e.openBlock(),e.createBlock(S,{key:0,name:"chevron-right",class:e.normalizeClass(["expander-icon",{"rotate-90":y.value}]),onClick:c[0]||(c[0]=e.withModifiers(m=>r.$emit("toggle-expand",u(l.item)),["stop"]))},null,8,["class"])):(e.openBlock(),e.createElementBlock("span",H)),l.multiple&&l.selectMode==="checkbox"&&!(l.disableBranchNode&&f.value)?(e.openBlock(),e.createElementBlock("input",{key:2,type:"checkbox",class:"form-check-input",checked:k.value,".indeterminate":w.value,disabled:s(l.item),onClick:c[1]||(c[1]=e.withModifiers(m=>r.$emit("select",l.item),["stop"]))},null,40,G)):e.createCommentVNode("",!0),e.createElementVNode("div",J,[e.renderSlot(r.$slots,"default",{item:l.item,level:l.level},void 0,!0)])],6),f.value&&y.value?(e.openBlock(),e.createElementBlock("div",Q,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.item.children,m=>(e.openBlock(),e.createBlock(x,{key:u(m),item:m,level:l.level+1,"selected-items":l.selectedItems,"expanded-items":l.expandedItems,multiple:l.multiple,"select-all":l.selectAll,"select-mode":l.selectMode,"option-label":l.optionLabel,"option-value":l.optionValue,"disabled-key":l.disabledKey,"disable-branch-node":l.disableBranchNode,onSelect:c[3]||(c[3]=b=>r.$emit("select",b)),onToggleExpand:c[4]||(c[4]=b=>r.$emit("toggle-expand",b))},{default:e.withCtx(({item:b,level:p})=>[e.renderSlot(r.$slots,"default",{item:b,level:p},void 0,!0)]),_:2},1032,["item","level","selected-items","expanded-items","multiple","select-all","select-mode","option-label","option-value","disabled-key","disable-branch-node"]))),128))])):e.createCommentVNode("",!0)])}}},[["__scopeId","data-v-9766821f"]]),Y={class:"tree-select-wrapper"},v=["disabled"],_={class:"tree-select-display-text text-truncate me-2 text-start"},ee={class:"d-flex align-items-center gap-2"},te={key:0,class:"p-2 border-bottom"},le={key:1,class:"p-4 text-muted text-center"},ne={key:2,class:"tree-select-body",style:{"max-height":"300px","overflow-y":"auto"}},oe={key:0,class:"list-group list-group-flush"},ae={class:"d-flex align-items-center gap-2",style:{"white-space":"wrap"}},ie={key:1,class:"p-3 text-muted text-center"},A=C({__name:"TreeSelectMain",props:{modelValue:{type:[String,Number,Array],default:null},items:{type:Array,default:()=>[]},multiple:{type:Boolean,default:!1},selectMode:{type:String,default:"checkbox",validator:l=>["checkbox","highlight"].includes(l)},placeholder:{type:String,default:"Select item..."},isInvalid:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},searchable:{type:Boolean,default:!0},isLoading:{type:Boolean,default:!1},showClearButton:{type:Boolean,default:!0},selectAll:{type:Boolean,default:!1},optionLabel:{type:String,default:"value"},optionValue:{type:String,default:"code"},disabledKey:{type:String,default:null},excludeFromSelectedListKey:{type:String,default:null},disableBranchNodes:{type:Boolean,default:!1},size:{type:String,default:"sm",validator:l=>["sm","md","lg","xl"].includes(l)}},emits:["update:modelValue","change"],setup(l,{emit:E}){const n=l,u=E,s=e.ref(null),f=e.ref(null),y=e.ref(""),k=e.ref(!1),V=e.ref(new Set),w=e.ref(null),r=e.computed(()=>n.size==="sm"?"btn-sm":n.size==="lg"?"btn-lg":n.size==="xl"?"btn-xl":""),c=e.computed(()=>n.size==="sm"?"form-control-sm":n.size==="lg"?"form-control-lg":n.size==="xl"?"form-control-xl":""),x=t=>t[n.optionLabel]||t.label||t.name||"",m=t=>t[n.optionValue]||t.id||t.value,b=t=>!n.disabledKey||!t?!1:t.hasOwnProperty(n.disabledKey)&&t[n.disabledKey]!==null,p=t=>t.children&&t.children.length>0,M=(t,a=n.items)=>{for(const o of a){if(m(o)===t)return o;if(p(o)){const i=M(t,o.children);if(i)return i}}return null},z=t=>{const a=[];return p(t)&&t.children.forEach(o=>{b(o)||(a.push(m(o)),a.push(...z(o)))}),a},T=(t,a=n.items,o=[])=>{for(const i of a){if(m(i)===t)return o;if(p(i)){const d=T(t,i.children,[...o,m(i)]);if(d)return d}}return null},N=e.computed(()=>{const t=new Set(Array.isArray(n.modelValue)?n.modelValue:[n.modelValue].filter(Boolean));if(n.multiple&&n.selectAll){const a=o=>{o.forEach(i=>{if(p(i)){const d=i.children.filter(B=>!b(B));d.length>0&&d.every(B=>t.has(m(B)))&&t.add(m(i)),a(i.children)}})};a(n.items)}return Array.from(t)}),L=(t,a=n.items,o=[])=>{for(const i of a){const d=[...o,x(i)];if(m(i)===t)return d;if(p(i)){const h=L(t,i.children,d);if(h)return h}}return null},q=t=>{if(!t||t.length===0)return"";const a=t.join(" → ");return a.length<=40?a:t.length>2?`${t[0]} → ... → ${t[t.length-1]}`:a},re=e.computed(()=>{const t=Array.isArray(n.modelValue)?n.modelValue:[n.modelValue].filter(Boolean);if(t.length===0)return n.placeholder;if(n.multiple){if(t.length===1){const o=L(t[0]);return o?q(o):t[0]}return`${t.length} items selected`}const a=L(t[0]);return a?q(a):t[0]}),K=(t,a)=>t.map(o=>{const i=x(o).toLowerCase().includes(a);let d=[];return p(o)&&(d=K(o.children,a)),i||d.length>0?{...o,children:d}:null}).filter(Boolean),I=e.computed(()=>y.value.trim()?K(n.items,y.value.toLowerCase()):n.items),de=t=>{if(n.disableBranchNodes&&t.children&&t.children.length>0){const d=t[n.optionValue]||t.id||t.value;P(d);return}if(b(t))return;const a=m(t);let o=new Set(N.value);if(n.multiple){const d=o.has(a);if(n.selectAll&&p(t)){const h=z(t);d?(o.delete(a),h.forEach(B=>o.delete(B))):(o.add(a),h.forEach(B=>o.add(B)))}else d?(o.delete(a),n.selectAll&&T(a)?.forEach(B=>o.delete(B))):o.add(a)}else o=new Set([a]),$();let i=Array.from(o);n.multiple&&n.excludeFromSelectedListKey&&(i=i.filter(d=>{const h=M(d);return!h||!h[n.excludeFromSelectedListKey]})),u("update:modelValue",n.multiple?i:i[0]||null),u("change",n.multiple?i:i[0]||null)},P=t=>{V.value.has(t)?V.value.delete(t):V.value.add(t)},ce=()=>{const t=n.multiple?[]:null;u("update:modelValue",t),u("change",t)},me=async()=>{n.disabled||(k.value=!0,await e.nextTick(),s.value&&f.value&&(w.value=O.createPopper(f.value,s.value,{placement:"bottom-start",strategy:"fixed",modifiers:[{name:"offset",options:{offset:[0,4]}},{name:"preventOverflow",options:{padding:8}},{name:"flip",options:{fallbackPlacements:["top-start"]}},{name:"sameWidth",enabled:!0,phase:"beforeWrite",requires:["computeStyles"],fn:({state:t})=>{t.styles.popper.width=`${t.rects.reference.width}px`},effect:({state:t})=>{t.elements.popper.style.width=`${t.elements.reference.offsetWidth}px`}}]})),n.searchable&&(await e.nextTick(),s.value?.querySelector(".tree-search-input")?.focus()))},$=()=>{k.value=!1,y.value="",w.value?.destroy(),w.value=null},ue=()=>k.value?$():me(),D=t=>{!f.value?.contains(t.target)&&!s.value?.contains(t.target)&&$()};return e.onMounted(()=>document.addEventListener("click",D)),e.onUnmounted(()=>{document.removeEventListener("click",D),w.value?.destroy()}),e.watch(y,t=>{if(t.trim()){const a=o=>{o.forEach(i=>{p(i)&&(V.value.add(m(i)),a(i.children))})};a(I.value)}}),(t,a)=>(e.openBlock(),e.createElementBlock("div",Y,[e.createElementVNode("button",{ref_key:"triggerRef",ref:f,type:"button",class:e.normalizeClass(["btn tree-select-trigger w-100 d-flex justify-content-between align-items-center tree-select-main",[r.value,{"btn-outline-secondary":!l.isInvalid,"border-danger":l.isInvalid,disabled:l.disabled||l.isLoading,"is-loading":l.isLoading}]]),disabled:l.disabled||l.isLoading,onClick:ue},[e.createElementVNode("span",_,[e.createElementVNode("span",null,e.toDisplayString(l.isLoading?"Loading data...":re.value),1)]),e.createElementVNode("div",ee,[l.isLoading?(e.openBlock(),e.createBlock(S,{key:0,name:"spinner",class:"loading-icon"})):e.createCommentVNode("",!0),l.showClearButton&&N.value.length>0&&!l.disabled&&!l.isLoading?(e.openBlock(),e.createBlock(S,{key:1,name:"times",onClick:e.withModifiers(ce,["stop"]),class:"clear-icon"})):e.createCommentVNode("",!0),l.isLoading?e.createCommentVNode("",!0):(e.openBlock(),e.createBlock(S,{key:2,name:"chevron-down",class:e.normalizeClass(["transition-transform",{"rotate-180":k.value}])},null,8,["class"]))])],10,v),k.value?(e.openBlock(),e.createElementBlock("div",{key:0,ref_key:"dropdownRef",ref:s,class:"tree-select-dropdown card shadow-lg border-0",style:{"z-index":"1050"}},[l.searchable?(e.openBlock(),e.createElementBlock("div",te,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":a[0]||(a[0]=o=>y.value=o),type:"text",class:e.normalizeClass(["form-control tree-search-input",c.value]),placeholder:"Search..."},null,2),[[e.vModelText,y.value]])])):e.createCommentVNode("",!0),l.isLoading?(e.openBlock(),e.createElementBlock("div",le,[e.createVNode(S,{name:"spinner",class:"me-2"}),a[1]||(a[1]=e.createElementVNode("span",null,"Loading...",-1))])):(e.openBlock(),e.createElementBlock("div",ne,[I.value.length>0?(e.openBlock(),e.createElementBlock("div",oe,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(I.value,o=>(e.openBlock(),e.createBlock(X,{key:m(o),item:o,level:0,"selected-items":N.value,"expanded-items":V.value,multiple:l.multiple,"select-all":l.selectAll,"select-mode":l.selectMode,"option-label":l.optionLabel,"option-value":l.optionValue,"disabled-key":l.disabledKey,"disable-branch-node":l.disableBranchNodes,onSelect:de,onToggleExpand:P},{default:e.withCtx(({item:i,level:d})=>[e.renderSlot(t.$slots,"default",{item:i,level:d},()=>[e.createElementVNode("div",ae,[e.createTextVNode(e.toDisplayString(x(i))+" ",1),i.icon?(e.openBlock(),e.createElementBlock("i",{key:0,class:e.normalizeClass(i.icon)},null,2)):e.createCommentVNode("",!0)])],!0)]),_:2},1032,["item","selected-items","expanded-items","multiple","select-all","select-mode","option-label","option-value","disabled-key","disable-branch-node"]))),128))])):(e.openBlock(),e.createElementBlock("div",ie,[e.createVNode(S,{name:"search",class:"me-1"}),a[2]||(a[2]=e.createTextVNode(" No items found ",-1))]))]))],512)):e.createCommentVNode("",!0)]))}},[["__scopeId","data-v-5e70d4e4"]]),se={install(l){l.component("VSelect",A)}};g.VSelect=A,g.default=se,Object.defineProperties(g,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
1
+ (function(b,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):(b=typeof globalThis<"u"?globalThis:b||self,e(b.VueSelect={},b.Vue,b.Popper))})(this,(function(b,e,R){"use strict";const A=(l,N)=>{const n=l.__vccOpts||l;for(const[m,i]of N)n[m]=i;return n},ee={key:0},te={key:1},le={key:2},ne={key:3},oe={key:4},ae={key:5},re={key:6},B=A({__name:"SvgIcon",props:{name:{type:String,required:!0}},setup(l){const N=l,n=e.computed(()=>({"svg-icon-spin":N.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",ee,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",te,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",le,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",ne,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",oe,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",ae,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",re,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"]]),se={class:"tree-select-item-wrapper"},ie={key:1,class:"expander-placeholder"},ce=["checked",".indeterminate","disabled"],de={class:"item-content"},me={key:0,class:"children-wrapper"},ue=A({__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:N}){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,h=e.computed(()=>n.item.children&&n.item.children.length>0),V=e.computed(()=>n.expandedItems.has(m(n.item))),y=e.computed(()=>n.selectedItems.includes(m(n.item))),C=c=>{let d=[];return c.children&&c.children.forEach(x=>{d.push(m(x)),d.push(...C(x))}),d},w=e.computed(()=>!n.multiple||!n.selectAll||!h.value||y.value?!1:C(n.item).some(d=>n.selectedItems.includes(d)));return(c,d)=>{const x=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":y.value&&(l.selectMode==="highlight"||!l.multiple)&&!i(l.item)&&!(l.disableBranchNode&&h.value),"is-disabled text-muted bg-light":i(l.item)}]),style:e.normalizeStyle({"padding-left":`${l.level*1.5+1}rem`}),onClick:d[2]||(d[2]=k=>i(l.item)||l.disableBranchNode&&h.value?null:c.$emit("select",l.item))},[h.value?(e.openBlock(),e.createBlock(B,{key:0,name:"chevron-right",class:e.normalizeClass(["expander-icon",{"rotate-90":V.value}]),onClick:d[0]||(d[0]=e.withModifiers(k=>c.$emit("toggle-expand",m(l.item)),["stop"]))},null,8,["class"])):(e.openBlock(),e.createElementBlock("span",ie)),l.multiple&&l.selectMode==="checkbox"&&!(l.disableBranchNode&&h.value)?(e.openBlock(),e.createElementBlock("input",{key:2,type:"checkbox",class:"form-check-input",checked:y.value,".indeterminate":w.value,disabled:i(l.item),onClick:d[1]||(d[1]=e.withModifiers(k=>c.$emit("select",l.item),["stop"]))},null,40,ce)):e.createCommentVNode("",!0),e.createElementVNode("div",de,[e.renderSlot(c.$slots,"default",{item:l.item,level:l.level},void 0,!0)])],6),h.value&&V.value?(e.openBlock(),e.createElementBlock("div",me,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.item.children,k=>(e.openBlock(),e.createBlock(x,{key:m(k),item:k,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]=g=>c.$emit("select",g)),onToggleExpand:d[4]||(d[4]=g=>c.$emit("toggle-expand",g))},{default:e.withCtx(({item:g,level:L})=>[e.renderSlot(c.$slots,"default",{item:g,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"]]),fe={class:"tree-select-wrapper"},pe=["disabled"],he={class:"tree-select-display-container"},ge={key:0,class:"text-truncate"},ye={key:1},ke={key:0,class:"text-muted"},be={key:1,class:"chips-container"},Be={class:"d-flex align-items-center gap-2"},Ve={class:"list-group list-group-flush"},xe={class:"text-truncate me-2"},Se={class:"p-2 border-bottom d-flex flex-column gap-2"},Ee={key:1,class:"d-flex align-items-center gap-2"},Ce=["value"],Ne=["disabled"],we={key:0,class:"p-4 text-muted text-center"},Le={key:1,class:"tree-select-body",style:{"max-height":"300px","overflow-y":"auto"}},Ie={key:0,class:"list-group list-group-flush"},Me={class:"d-flex align-items-center gap-2",style:{"white-space":"wrap"}},$e={key:1,class:"p-3 text-muted text-center"},j=A({__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},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}},emits:["update:modelValue","change"],setup(l,{emit:N}){const n=l,m=N,i=e.ref(null),h=e.ref(null),V=e.ref(""),y=e.ref(!1),C=e.ref(new Set),w=e.ref(null),c=e.ref(n.defaultSortKey),d=e.ref(n.defaultSortDirection),x=e.ref(null),k=e.ref(null),g=e.ref(!1),L=e.ref(null),F=e.computed(()=>n.size==="sm"?"btn-sm":n.size==="lg"?"btn-lg":n.size==="xl"?"btn-xl":""),Z=e.computed(()=>n.size==="sm"?"form-control-sm":n.size==="lg"?"form-control-lg":n.size==="xl"?"form-control-xl":""),I=t=>t&&(t[n.optionLabel]||t.label||t.name)||"",p=t=>t?t[n.optionValue]||t.id||t.value:null,D=t=>!n.disabledKey||!t?!1:t.hasOwnProperty(n.disabledKey)&&t[n.disabledKey]!==null,S=t=>t.children&&t.children.length>0,U=(t,a)=>{if(a)return a.split(".").reduce((o,r)=>o&&o[r],t)},T=(t,a=n.items)=>{for(const o of a){if(p(o)===t)return o;if(S(o)){const r=T(t,o.children);if(r)return r}}return null},W=t=>{const a=[];return S(t)&&t.children.forEach(o=>{D(o)||(a.push(p(o)),a.push(...W(o)))}),a},P=(t,a=n.items,o=[])=>{for(const r of a){if(p(r)===t)return o;if(S(r)){const s=P(t,r.children,[...o,p(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(S(r)){const s=r.children.filter(u=>!D(u));s.length>0&&s.every(u=>t.has(p(u)))&&t.add(p(r)),a(r.children)}})};a(n.items)}return Array.from(t)}),K=(t,a=n.items,o=[])=>{for(const r of a){const s=[...o,I(r)];if(p(r)===t)return s;if(S(r)){const f=K(t,r.children,s);if(f)return f}}return null},G=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},Ae=e.computed(()=>{const t=E.value;if(t.length===0)return n.placeholder;if(n.multiple){if(t.length===1){const o=K(t[0]);return o?G(o):t[0]}return`${t.length} items selected`}const a=K(t[0]);return a?G(a):t[0]}),q=e.computed(()=>!n.multiple||E.value.length===0?[]:E.value.map(t=>T(t)).filter(Boolean)),De=e.computed(()=>q.value.slice(0,n.maxVisibleChipsDisplay)),J=e.computed(()=>{const t=q.value.length-n.maxVisibleChipsDisplay;return t>0?t:0}),Q=(t,a)=>t.map(o=>{const r=I(o).toLowerCase().includes(a);let s=[];return S(o)&&(s=Q(o.children,a)),r||s.length>0?{...o,children:s}:null}).filter(Boolean),X=(t,a,o)=>!t||!a?t:[...t].sort((s,f)=>{const u=U(s,a),M=U(f,a);if(u==null)return 1;if(M==null)return-1;let $=0;return typeof u=="string"&&typeof M=="string"?$=u.localeCompare(M):u>M?$=1:u<M&&($=-1),o==="desc"?$*-1:$}).map(s=>S(s)?{...s,children:X(s.children,a,o)}:s),O=e.computed(()=>{const t=V.value.trim()?Q(n.items,V.value.toLowerCase()):n.items;return!n.sortable||!c.value?t:X(t,c.value,d.value)}),Te=t=>{if(n.disableBranchNodes&&t.children&&t.children.length>0){const s=t[n.optionValue]||t.id||t.value;v(s);return}if(D(t))return;const a=p(t);let o=new Set(E.value);if(n.multiple){const s=o.has(a);if(n.selectAll&&S(t)){const f=W(t);s?(o.delete(a),f.forEach(u=>o.delete(u))):(o.add(a),f.forEach(u=>o.add(u)))}else s?(o.delete(a),n.selectAll&&P(a)?.forEach(u=>o.delete(u))):o.add(a)}else o=new Set([a]),H();let r=Array.from(o);n.multiple&&n.excludeFromSelectedListKey&&(r=r.filter(s=>{const f=T(s);return!f||!f[n.excludeFromSelectedListKey]})),m("update:modelValue",n.multiple?r:r[0]||null),m("change",n.multiple?r:r[0]||null)},Y=t=>{if(n.disabled||!t)return;const a=p(t),o=new Set(E.value);o.delete(a),n.selectAll&&P(a)?.forEach(f=>o.delete(f));const r=Array.from(o);m("update:modelValue",r),m("change",r)},v=t=>{C.value.has(t)?C.value.delete(t):C.value.add(t)},Pe=()=>{d.value=d.value==="asc"?"desc":"asc"},Ke=()=>{const t=n.multiple?[]:null;m("update:modelValue",t),m("change",t),z()},qe=async()=>{n.disabled||(z(),y.value=!0,await e.nextTick(),i.value&&h.value&&(w.value=R.createPopper(h.value,i.value,{placement:"bottom-start",strategy:"fixed",modifiers:[{name:"offset",options:{offset:[0,4]}},{name:"preventOverflow",options:{padding:8}},{name:"flip",options:{fallbackPlacements:["top-start"]}},{name:"sameWidth",enabled:!0,phase:"beforeWrite",requires:["computeStyles"],fn:({state:t})=>{t.styles.popper.width=`${t.rects.reference.width}px`},effect:({state:t})=>{t.elements.popper.style.width=`${t.elements.reference.offsetWidth}px`}}]})),n.searchable&&(await e.nextTick(),i.value?.querySelector(".tree-search-input")?.focus()))},H=()=>{y.value=!1,V.value="",w.value?.destroy(),w.value=null},Oe=()=>y.value?H():qe(),He=async()=>{n.disabled||(g.value=!0,await e.nextTick(),k.value&&x.value&&(L.value=R.createPopper(x.value,k.value,{placement:"bottom-end",strategy:"fixed",modifiers:[{name:"offset",options:{offset:[0,4]}}]})))},z=()=>{g.value=!1,L.value?.destroy(),L.value=null},Re=()=>g.value?z():He(),_=t=>{y.value&&!h.value?.contains(t.target)&&!i.value?.contains(t.target)&&H(),g.value&&!x.value?.contains(t.target)&&!k.value?.contains(t.target)&&z()};return e.onMounted(()=>document.addEventListener("click",_)),e.onUnmounted(()=>{document.removeEventListener("click",_),w.value?.destroy(),L.value?.destroy()}),e.watch(V,t=>{if(t.trim()){const a=o=>{o.forEach(r=>{S(r)&&(C.value.add(p(r)),a(r.children))})};a(O.value)}}),(t,a)=>(e.openBlock(),e.createElementBlock("div",fe,[e.createElementVNode("button",{ref_key:"triggerRef",ref:h,type:"button",class:e.normalizeClass(["btn tree-select-trigger w-100 d-flex justify-content-between align-items-center tree-select-main",[F.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}]]),disabled:l.disabled||l.isLoading,onClick:Oe},[e.createElementVNode("div",he,[!l.multiple||l.displayMode==="text"?(e.openBlock(),e.createElementBlock("span",ge,e.toDisplayString(l.isLoading?"Loading data...":Ae.value),1)):l.multiple&&l.displayMode==="chips"?(e.openBlock(),e.createElementBlock("div",ye,[E.value.length===0?(e.openBlock(),e.createElementBlock("span",ke,e.toDisplayString(l.placeholder),1)):(e.openBlock(),e.createElementBlock("div",be,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(De.value,o=>(e.openBlock(),e.createElementBlock("span",{key:p(o),class:"badge text-bg-primary chip bg-primary"},[e.createTextVNode(e.toDisplayString(I(o))+" ",1),e.createVNode(B,{name:"times",class:"chip-remove",onClick:e.withModifiers(r=>Y(o),["stop"])},null,8,["onClick"])]))),128)),J.value>0?(e.openBlock(),e.createElementBlock("button",{key:0,ref_key:"moreTriggerRef",ref:x,type:"button",class:"btn btn-sm btn-light more-button",onClick:e.withModifiers(Re,["stop"])}," +"+e.toDisplayString(J.value),513)):e.createCommentVNode("",!0)]))])):e.createCommentVNode("",!0)]),e.createElementVNode("div",Be,[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(Ke,["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":y.value}])},null,8,["class"]))])],10,pe),g.value?(e.openBlock(),e.createElementBlock("div",{key:0,ref_key:"morePopoverRef",ref:k,class:"card shadow-lg border-0 more-popover",style:{"z-index":"1060"}},[e.createElementVNode("div",Ve,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(q.value,o=>(e.openBlock(),e.createElementBlock("div",{key:p(o),class:"list-group-item d-flex justify-content-between align-items-center py-1 px-2"},[e.createElementVNode("small",xe,e.toDisplayString(I(o)),1),e.createVNode(B,{name:"times",class:"chip-remove flex-shrink-0",onClick:e.withModifiers(r=>Y(o),["stop"])},null,8,["onClick"])]))),128))])],512)):e.createCommentVNode("",!0),y.value?(e.openBlock(),e.createElementBlock("div",{key:1,ref_key:"dropdownRef",ref:i,class:"tree-select-dropdown card shadow-lg border-0",style:{"z-index":"1050"}},[e.createElementVNode("div",Se,[l.searchable?e.withDirectives((e.openBlock(),e.createElementBlock("input",{key:0,"onUpdate:modelValue":a[0]||(a[0]=o=>V.value=o),type:"text",class:e.normalizeClass(["form-control tree-search-input",Z.value]),placeholder:"Search..."},null,2)),[[e.vModelText,V.value]]):e.createCommentVNode("",!0),l.sortable&&l.sortOptions.length>0?(e.openBlock(),e.createElementBlock("div",Ee,[e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":a[1]||(a[1]=o=>c.value=o),class:e.normalizeClass(["form-select flex-grow-1",Z.value])},[a[2]||(a[2]=e.createElementVNode("option",{value:null,disabled:""},"Sort by...",-1)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.sortOptions,o=>(e.openBlock(),e.createElementBlock("option",{key:o.value,value:o.value},e.toDisplayString(o.label),9,Ce))),128))],2),[[e.vModelSelect,c.value]]),e.createElementVNode("button",{type:"button",class:e.normalizeClass(["btn btn-outline-secondary",F.value]),disabled:!c.value,onClick:Pe},[e.createVNode(B,{name:d.value==="asc"?"asc":"desc"},null,8,["name"])],10,Ne)])):e.createCommentVNode("",!0)]),l.isLoading?(e.openBlock(),e.createElementBlock("div",we,[e.createVNode(B,{name:"spinner",class:"me-2"}),a[3]||(a[3]=e.createElementVNode("span",null,"Loading...",-1))])):(e.openBlock(),e.createElementBlock("div",Le,[O.value.length>0?(e.openBlock(),e.createElementBlock("div",Ie,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(O.value,o=>(e.openBlock(),e.createBlock(ue,{key:p(o),item:o,level:0,"selected-items":E.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:Te,onToggleExpand:v},{default:e.withCtx(({item:r,level:s})=>[e.renderSlot(t.$slots,"default",{item:r,level:s},()=>[e.createElementVNode("div",Me,[e.createTextVNode(e.toDisplayString(I(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",$e,[e.createVNode(B,{name:"search",class:"me-1"}),a[4]||(a[4]=e.createTextVNode(" No items found ",-1))]))]))],512)):e.createCommentVNode("",!0)]))}},[["__scopeId","data-v-a9a04e35"]]),ze={install(l){l.component("VSelect",j)}};b.VSelect=j,b.default=ze,Object.defineProperties(b,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "@night-owl-elite/vue-select",
3
3
  "private": false,
4
- "version": "1.3.14",
4
+ "version": "1.3.16",
5
5
  "type": "module",
6
6
  "main": "./dist/vue-select.umd.js",
7
7
  "module": "./dist/vue-select.es.js",
8
+ "types": "./dist/vue-select.d.ts",
8
9
  "scripts": {
9
10
  "dev": "vite",
10
11
  "build": "vite build",
@@ -12,6 +13,7 @@
12
13
  },
13
14
  "exports": {
14
15
  ".": {
16
+ "types": "./dist/vue-select.d.ts",
15
17
  "import": "./dist/vue-select.es.js",
16
18
  "require": "./dist/vue-select.umd.js"
17
19
  },
@@ -27,7 +29,9 @@
27
29
  },
28
30
  "devDependencies": {
29
31
  "@vitejs/plugin-vue": "^6.0.0",
30
- "vite": "^7.0.4"
32
+ "vite": "^7.0.4",
33
+ "typescript": "^5.5.3",
34
+ "vite-plugin-dts": "^4.5.4"
31
35
  },
32
36
  "peerDependencies": {
33
37
  "vue": "^3.2.0",
package/dist/vite.svg DELETED
@@ -1 +0,0 @@
1
- <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>