@weni/unnnic-system 3.36.0 → 3.36.1-alpha.0
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/components/MultiSelect/MultiSelectOption.css +1 -1
- package/dist/components/MultiSelect/MultiSelectOption.vue.mjs +2 -2
- package/dist/components/MultiSelect/MultiSelectOption.vue2.mjs +41 -15
- package/dist/components/MultiSelect/MultiSelectTreeOptions.css +1 -0
- package/dist/components/MultiSelect/MultiSelectTreeOptions.vue.mjs +7 -0
- package/dist/components/MultiSelect/MultiSelectTreeOptions.vue2.mjs +50 -0
- package/dist/components/MultiSelect/index.css +1 -1
- package/dist/components/MultiSelect/index.vue.mjs +2 -2
- package/dist/components/MultiSelect/index.vue2.mjs +126 -114
- package/dist/composables/useMultiSelectRows.mjs +74 -0
- package/dist/composables/useMultiSelectSelection.mjs +44 -0
- package/dist/composables/useSelectBase.mjs +44 -39
- package/dist/composables/useSelectKeyboard.mjs +70 -35
- package/dist/composables/useTreeExpansion.mjs +24 -0
- package/dist/lib/tree-selection.mjs +66 -0
- package/dist/locales/en.json.mjs +9 -5
- package/dist/style.css +4 -2
- package/dist/unnnic.umd.js +19 -19
- package/package.json +2 -2
- package/src/components/MultiSelect/MultiSelectOption.vue +66 -3
- package/src/components/MultiSelect/MultiSelectTreeOptions.vue +73 -0
- package/src/components/MultiSelect/__tests__/MultiSelect.spec.js +556 -0
- package/src/components/MultiSelect/__tests__/MultiSelectOption.spec.js +55 -1
- package/src/components/MultiSelect/__tests__/__snapshots__/MultiSelectOption.spec.js.snap +5 -0
- package/src/components/MultiSelect/index.vue +57 -50
- package/src/components/Select/_select-shared.scss +8 -0
- package/src/components/Select/types.ts +1 -0
- package/src/composables/useMultiSelectRows.ts +121 -0
- package/src/composables/useMultiSelectSelection.ts +97 -0
- package/src/composables/useSelectBase.ts +40 -16
- package/src/composables/useSelectKeyboard.ts +92 -18
- package/src/composables/useTreeExpansion.ts +44 -0
- package/src/lib/__tests__/tree-selection.spec.ts +141 -0
- package/src/lib/tree-selection.ts +156 -0
- package/src/locales/en.json +3 -1
- package/src/stories/MultiSelect.stories.js +62 -1
|
@@ -1,21 +1,28 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { useInfiniteScroll as
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
1
|
+
import { defineComponent as Q, useTemplateRef as P, computed as R, ref as X, watch as Y, nextTick as S, openBlock as n, createElementBlock as r, createVNode as s, unref as o, withCtx as v, normalizeStyle as Z, createElementVNode as ee, createBlock as g, createCommentVNode as C, toDisplayString as te, Fragment as w, renderList as oe } from "vue";
|
|
2
|
+
import { useInfiniteScroll as le } from "../../node_modules/@vueuse/core/dist/index.mjs";
|
|
3
|
+
import B from "../Input/Input.vue.mjs";
|
|
4
|
+
import ne from "../IconLoading/IconLoading.vue.mjs";
|
|
5
|
+
import ie from "./MultiSelectOption.vue.mjs";
|
|
6
|
+
import ae from "./MultiSelectTreeOptions.vue.mjs";
|
|
7
|
+
import { useSelectBase as re } from "../../composables/useSelectBase.mjs";
|
|
8
|
+
import { useSelectKeyboard as se } from "../../composables/useSelectKeyboard.mjs";
|
|
9
|
+
import { useMultiSelectSelection as ce } from "../../composables/useMultiSelectSelection.mjs";
|
|
10
|
+
import { useMultiSelectRows as ue } from "../../composables/useMultiSelectRows.mjs";
|
|
11
|
+
import { filterTreeOptions as de } from "../../lib/tree-selection.mjs";
|
|
12
|
+
import pe from "../ui/popover/Popover.vue.mjs";
|
|
13
|
+
import fe from "../ui/popover/PopoverTrigger.vue.mjs";
|
|
14
|
+
import me from "../ui/popover/PopoverContent.vue.mjs";
|
|
11
15
|
import '../ui/popover/PopoverContent.css';/* empty css */
|
|
12
|
-
const
|
|
16
|
+
const he = { class: "unnnic-multi-select" }, Se = {
|
|
13
17
|
key: 1,
|
|
14
18
|
class: "unnnic-multi-select__content-no-results"
|
|
15
|
-
},
|
|
16
|
-
key:
|
|
19
|
+
}, ve = {
|
|
20
|
+
key: 1,
|
|
21
|
+
class: "unnnic-multi-select__options"
|
|
22
|
+
}, ge = {
|
|
23
|
+
key: 2,
|
|
17
24
|
class: "unnnic-multi-select__infinite-loading"
|
|
18
|
-
},
|
|
25
|
+
}, Ee = /* @__PURE__ */ Q({
|
|
19
26
|
name: "UnnnicMultiSelect",
|
|
20
27
|
__name: "index",
|
|
21
28
|
props: {
|
|
@@ -41,162 +48,167 @@ const oe = { class: "unnnic-multi-select" }, ae = {
|
|
|
41
48
|
returnObject: { type: Boolean, default: !1 }
|
|
42
49
|
},
|
|
43
50
|
emits: ["update:modelValue", "update:search", "scroll-end"],
|
|
44
|
-
setup(
|
|
45
|
-
const e =
|
|
46
|
-
|
|
51
|
+
setup(M, { expose: E, emit: U }) {
|
|
52
|
+
const e = M, c = U, _ = P("multiSelectInputRef"), u = P("contentRef"), l = re(e, "multi", _, u, {
|
|
53
|
+
filterOptions: de
|
|
54
|
+
}), d = l.openPopover, z = l.popoverContentCustomStyles, A = l.inputWidthString, b = l.filteredOptions, {
|
|
55
|
+
isTreeMode: y,
|
|
56
|
+
getCheckState: T,
|
|
57
|
+
toggleOption: V,
|
|
58
|
+
toggle: $,
|
|
59
|
+
displayItems: p
|
|
60
|
+
} = ce(e, c), {
|
|
61
|
+
optionGroups: H,
|
|
62
|
+
visibleRows: k,
|
|
63
|
+
toggleExpanded: j,
|
|
64
|
+
resetExpanded: D,
|
|
65
|
+
handleArrowRight: F,
|
|
66
|
+
handleArrowLeft: N
|
|
67
|
+
} = ue(e, {
|
|
68
|
+
filteredOptions: l.filteredOptions,
|
|
69
|
+
isSearchActive: l.isSearchActive,
|
|
70
|
+
matchesSearch: l.matchesSearch,
|
|
71
|
+
getCheckState: T
|
|
72
|
+
});
|
|
73
|
+
function f(t) {
|
|
47
74
|
l.openPopover.value = t;
|
|
48
75
|
}
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
const t = e.modelValue.slice();
|
|
52
|
-
return e.options.filter(
|
|
53
|
-
(o) => t.includes(o[e.itemValue])
|
|
54
|
-
);
|
|
55
|
-
}), O = b(
|
|
56
|
-
() => h.value.map((t) => t[e.itemLabel]).join(", ")
|
|
76
|
+
const x = R(
|
|
77
|
+
() => p.value.map((t) => t[e.itemLabel]).join(", ")
|
|
57
78
|
);
|
|
58
|
-
function
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
function P(t) {
|
|
62
|
-
return e.returnObject ? e.modelValue.some(
|
|
63
|
-
(o) => o[e.itemValue] === t[e.itemValue]
|
|
64
|
-
) : e.modelValue.includes(t[e.itemValue]);
|
|
79
|
+
function L(t) {
|
|
80
|
+
c("update:search", t);
|
|
65
81
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
u("update:modelValue", a);
|
|
70
|
-
} else {
|
|
71
|
-
const a = e.returnObject ? e.modelValue.filter(
|
|
72
|
-
(s) => s[e.itemValue] !== t[e.itemValue]
|
|
73
|
-
) : e.modelValue.filter((s) => s !== t[e.itemValue]);
|
|
74
|
-
u("update:modelValue", a);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
const S = ee(
|
|
78
|
-
() => l.filteredOptions.value,
|
|
79
|
-
(t) => {
|
|
80
|
-
if (t.disabled) return;
|
|
81
|
-
const o = P(t);
|
|
82
|
-
I(t, !o);
|
|
83
|
-
},
|
|
82
|
+
const m = se(
|
|
83
|
+
() => k.value.map((t) => t.option),
|
|
84
|
+
$,
|
|
84
85
|
{
|
|
85
86
|
closeOnSelect: !1,
|
|
86
|
-
closePopover: () =>
|
|
87
|
-
openPopoverRef: l.openPopover
|
|
87
|
+
closePopover: () => f(!1),
|
|
88
|
+
openPopoverRef: l.openPopover,
|
|
89
|
+
toggleOnSpace: y,
|
|
90
|
+
onArrowRight: F,
|
|
91
|
+
onArrowLeft: N
|
|
88
92
|
}
|
|
89
93
|
);
|
|
90
|
-
|
|
91
|
-
const
|
|
92
|
-
function
|
|
94
|
+
m.setupKeydownBinding();
|
|
95
|
+
const O = m.focusedOptionIndex, i = X(!1);
|
|
96
|
+
function K(t) {
|
|
93
97
|
return !e.infiniteScroll || !l.openPopover.value || i.value || !e.infiniteScrollCanLoadMore() || !t || typeof t != "object" || !("clientHeight" in t) ? !1 : t.clientHeight > 0;
|
|
94
98
|
}
|
|
95
|
-
const
|
|
99
|
+
const W = R(
|
|
96
100
|
() => {
|
|
97
101
|
var t;
|
|
98
|
-
return ((t =
|
|
102
|
+
return ((t = u.value) == null ? void 0 : t.closest(".unnnic-popover")) ?? u.value;
|
|
99
103
|
}
|
|
100
|
-
), { reset:
|
|
101
|
-
|
|
104
|
+
), { reset: h } = le(
|
|
105
|
+
W,
|
|
102
106
|
() => {
|
|
103
|
-
i.value || (i.value = !0,
|
|
107
|
+
i.value || (i.value = !0, c("scroll-end"));
|
|
104
108
|
},
|
|
105
109
|
{
|
|
106
110
|
distance: e.infiniteScrollDistance,
|
|
107
|
-
canLoadMore:
|
|
111
|
+
canLoadMore: K
|
|
108
112
|
}
|
|
109
113
|
);
|
|
110
|
-
|
|
114
|
+
Y(l.openPopover, (t) => {
|
|
111
115
|
if (!t) {
|
|
112
|
-
|
|
116
|
+
L(""), i.value = !1, D();
|
|
113
117
|
return;
|
|
114
118
|
}
|
|
115
|
-
|
|
119
|
+
m.focusedOptionIndex.value = -1, e.infiniteScroll && S(() => h());
|
|
116
120
|
});
|
|
117
|
-
function
|
|
118
|
-
i.value = !1, l.openPopover.value && e.infiniteScroll &&
|
|
121
|
+
function G() {
|
|
122
|
+
i.value = !1, l.openPopover.value && e.infiniteScroll && S(() => h());
|
|
119
123
|
}
|
|
120
|
-
function
|
|
121
|
-
i.value = !1,
|
|
124
|
+
function q() {
|
|
125
|
+
i.value = !1, S(() => h());
|
|
122
126
|
}
|
|
123
|
-
return
|
|
124
|
-
openPopover:
|
|
125
|
-
setOpenPopover:
|
|
126
|
-
filteredOptions:
|
|
127
|
+
return E({
|
|
128
|
+
openPopover: d,
|
|
129
|
+
setOpenPopover: f,
|
|
130
|
+
filteredOptions: b,
|
|
127
131
|
calculatedPopoverHeight: l.calculatedPopoverHeight,
|
|
128
|
-
selectedItems:
|
|
129
|
-
inputValue:
|
|
132
|
+
selectedItems: p,
|
|
133
|
+
inputValue: x,
|
|
130
134
|
infiniteScrollLoading: i,
|
|
131
|
-
finishInfiniteScroll:
|
|
132
|
-
resetInfiniteScroll:
|
|
133
|
-
}), (t,
|
|
134
|
-
|
|
135
|
-
open:
|
|
136
|
-
"onUpdate:open":
|
|
135
|
+
finishInfiniteScroll: G,
|
|
136
|
+
resetInfiniteScroll: q
|
|
137
|
+
}), (t, I) => (n(), r("div", he, [
|
|
138
|
+
s(o(pe), {
|
|
139
|
+
open: o(d),
|
|
140
|
+
"onUpdate:open": f
|
|
137
141
|
}, {
|
|
138
|
-
default:
|
|
139
|
-
|
|
140
|
-
default:
|
|
141
|
-
|
|
142
|
+
default: v(() => [
|
|
143
|
+
s(o(fe), { class: "w-full" }, {
|
|
144
|
+
default: v(() => [
|
|
145
|
+
s(B, {
|
|
142
146
|
ref_key: "multiSelectInputRef",
|
|
143
|
-
ref:
|
|
144
|
-
modelValue:
|
|
147
|
+
ref: _,
|
|
148
|
+
modelValue: x.value,
|
|
145
149
|
class: "unnnic-multi-select__input",
|
|
146
150
|
readonly: "",
|
|
147
151
|
useFocusProp: "",
|
|
148
|
-
focus:
|
|
152
|
+
focus: o(d),
|
|
149
153
|
size: e.size,
|
|
150
154
|
placeholder: e.placeholder,
|
|
151
155
|
label: e.label,
|
|
152
156
|
errors: e.errors,
|
|
153
157
|
message: e.message,
|
|
154
|
-
iconRight:
|
|
158
|
+
iconRight: o(d) ? "keyboard_arrow_up" : "keyboard_arrow_down",
|
|
155
159
|
disabled: e.disabled,
|
|
156
|
-
showClear: !!
|
|
157
|
-
onClear:
|
|
160
|
+
showClear: !!o(p).length && e.clearable,
|
|
161
|
+
onClear: I[0] || (I[0] = (a) => c("update:modelValue", []))
|
|
158
162
|
}, null, 8, ["modelValue", "focus", "size", "placeholder", "label", "errors", "message", "iconRight", "disabled", "showClear"])
|
|
159
163
|
]),
|
|
160
164
|
_: 1
|
|
161
165
|
}),
|
|
162
|
-
|
|
166
|
+
s(o(me), {
|
|
163
167
|
align: "start",
|
|
164
168
|
class: "h-full",
|
|
165
|
-
style:
|
|
166
|
-
width:
|
|
169
|
+
style: Z(o(z)),
|
|
170
|
+
width: o(A)
|
|
167
171
|
}, {
|
|
168
|
-
default:
|
|
169
|
-
|
|
172
|
+
default: v(() => [
|
|
173
|
+
ee("div", {
|
|
170
174
|
ref_key: "contentRef",
|
|
171
|
-
ref:
|
|
175
|
+
ref: u,
|
|
172
176
|
class: "unnnic-multi-select__content"
|
|
173
177
|
}, [
|
|
174
|
-
e.enableSearch ? (
|
|
178
|
+
e.enableSearch ? (n(), g(B, {
|
|
175
179
|
key: 0,
|
|
176
180
|
class: "unnnic-multi-select__input-search",
|
|
177
181
|
modelValue: e.search,
|
|
178
182
|
placeholder: t.$t("search"),
|
|
179
183
|
iconLeft: "search",
|
|
180
|
-
"onUpdate:modelValue":
|
|
181
|
-
}, null, 8, ["modelValue", "placeholder"])) :
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
184
|
+
"onUpdate:modelValue": L
|
|
185
|
+
}, null, 8, ["modelValue", "placeholder"])) : C("", !0),
|
|
186
|
+
o(b).length === 0 ? (n(), r("p", Se, te(t.$t("without_results")), 1)) : (n(), r(w, { key: 2 }, [
|
|
187
|
+
o(y) ? (n(), g(ae, {
|
|
188
|
+
key: 0,
|
|
189
|
+
groups: o(H),
|
|
190
|
+
itemLabel: e.itemLabel,
|
|
191
|
+
itemValue: e.itemValue,
|
|
192
|
+
focusedIndex: o(O),
|
|
193
|
+
onSelect: o(V),
|
|
194
|
+
onExpand: o(j)
|
|
195
|
+
}, null, 8, ["groups", "itemLabel", "itemValue", "focusedIndex", "onSelect", "onExpand"])) : (n(), r("div", ve, [
|
|
196
|
+
(n(!0), r(w, null, oe(o(k), (a) => (n(), g(ie, {
|
|
197
|
+
key: String(a.option[e.itemValue]),
|
|
198
|
+
"data-option-index": a.index,
|
|
199
|
+
label: String(a.option[e.itemLabel] ?? ""),
|
|
200
|
+
active: a.checkState,
|
|
201
|
+
focused: o(O) === a.index,
|
|
202
|
+
disabled: a.option.disabled,
|
|
203
|
+
"onUpdate:modelValue": (J) => o(V)(a.option, J)
|
|
192
204
|
}, null, 8, ["data-option-index", "label", "active", "focused", "disabled", "onUpdate:modelValue"]))), 128))
|
|
193
|
-
]),
|
|
194
|
-
e.infiniteScroll && i.value ? (
|
|
195
|
-
|
|
205
|
+
])),
|
|
206
|
+
e.infiniteScroll && i.value ? (n(), r("div", ge, [
|
|
207
|
+
s(ne, {
|
|
196
208
|
scheme: "fg-base",
|
|
197
209
|
size: "sm"
|
|
198
210
|
})
|
|
199
|
-
])) :
|
|
211
|
+
])) : C("", !0)
|
|
200
212
|
], 64))
|
|
201
213
|
], 512)
|
|
202
214
|
]),
|
|
@@ -209,5 +221,5 @@ const oe = { class: "unnnic-multi-select" }, ae = {
|
|
|
209
221
|
}
|
|
210
222
|
});
|
|
211
223
|
export {
|
|
212
|
-
|
|
224
|
+
Ee as default
|
|
213
225
|
};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { computed as c, toValue as w } from "vue";
|
|
2
|
+
import { getVisibleChildren as V } from "../lib/tree-selection.mjs";
|
|
3
|
+
import { useTreeExpansion as C } from "./useTreeExpansion.mjs";
|
|
4
|
+
function S(x, {
|
|
5
|
+
filteredOptions: h,
|
|
6
|
+
isSearchActive: m,
|
|
7
|
+
matchesSearch: E,
|
|
8
|
+
getCheckState: a
|
|
9
|
+
}) {
|
|
10
|
+
const i = C(m);
|
|
11
|
+
function s(n) {
|
|
12
|
+
return n[x.itemValue];
|
|
13
|
+
}
|
|
14
|
+
const l = c(() => {
|
|
15
|
+
let n = 0;
|
|
16
|
+
return w(h).map((e) => {
|
|
17
|
+
const r = V(e, E), u = r.length > 0, d = u && i.isExpanded(s(e)), p = {
|
|
18
|
+
option: e,
|
|
19
|
+
parent: null,
|
|
20
|
+
level: 1,
|
|
21
|
+
hasChildren: u,
|
|
22
|
+
isExpanded: d,
|
|
23
|
+
checkState: a(e),
|
|
24
|
+
index: n++
|
|
25
|
+
};
|
|
26
|
+
return d ? [
|
|
27
|
+
p,
|
|
28
|
+
...r.map(
|
|
29
|
+
(f) => ({
|
|
30
|
+
option: f,
|
|
31
|
+
parent: e,
|
|
32
|
+
level: 2,
|
|
33
|
+
hasChildren: !1,
|
|
34
|
+
isExpanded: !1,
|
|
35
|
+
checkState: a(f),
|
|
36
|
+
index: n++
|
|
37
|
+
})
|
|
38
|
+
)
|
|
39
|
+
] : [p];
|
|
40
|
+
});
|
|
41
|
+
}), t = c(() => l.value.flat());
|
|
42
|
+
function o(n, e) {
|
|
43
|
+
i.setExpanded(s(n), e);
|
|
44
|
+
}
|
|
45
|
+
function v(n) {
|
|
46
|
+
const e = t.value[n];
|
|
47
|
+
if (e != null && e.hasChildren) {
|
|
48
|
+
if (e.isExpanded) return n + 1;
|
|
49
|
+
o(e.option, !0);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
function g(n) {
|
|
53
|
+
const e = t.value[n];
|
|
54
|
+
if (e) {
|
|
55
|
+
if (e.isExpanded) {
|
|
56
|
+
o(e.option, !1);
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
if (e.parent)
|
|
60
|
+
return t.value.findIndex((r) => r.option === e.parent);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return {
|
|
64
|
+
optionGroups: l,
|
|
65
|
+
visibleRows: t,
|
|
66
|
+
toggleExpanded: o,
|
|
67
|
+
resetExpanded: i.reset,
|
|
68
|
+
handleArrowRight: v,
|
|
69
|
+
handleArrowLeft: g
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
export {
|
|
73
|
+
S as useMultiSelectRows
|
|
74
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { computed as l } from "vue";
|
|
2
|
+
import { isTreeOptions as S, withImpliedChildren as h, getDisplayOptions as y, toggleOptionValue as b, getCheckState as C, flattenTreeOptions as I } from "../lib/tree-selection.mjs";
|
|
3
|
+
function k(e, f) {
|
|
4
|
+
const c = l(() => S(e.options));
|
|
5
|
+
function n(t) {
|
|
6
|
+
return t[e.itemValue];
|
|
7
|
+
}
|
|
8
|
+
const a = l(
|
|
9
|
+
() => Array.isArray(e.modelValue) ? e.modelValue : [e.modelValue]
|
|
10
|
+
), g = l(
|
|
11
|
+
() => e.returnObject ? a.value.map(n) : a.value
|
|
12
|
+
), r = l(
|
|
13
|
+
() => h(e.options, g.value, n)
|
|
14
|
+
), m = l(() => new Set(r.value));
|
|
15
|
+
function V(t) {
|
|
16
|
+
if (!e.returnObject) return t;
|
|
17
|
+
const o = [
|
|
18
|
+
...I(e.options),
|
|
19
|
+
...a.value
|
|
20
|
+
], i = new Map(o.map((u) => [n(u), u]));
|
|
21
|
+
return t.map((u) => i.get(u));
|
|
22
|
+
}
|
|
23
|
+
function s(t) {
|
|
24
|
+
return C(t, m.value, n);
|
|
25
|
+
}
|
|
26
|
+
function d(t, o) {
|
|
27
|
+
const i = b(
|
|
28
|
+
e.options,
|
|
29
|
+
r.value,
|
|
30
|
+
t,
|
|
31
|
+
o,
|
|
32
|
+
n
|
|
33
|
+
);
|
|
34
|
+
f("update:modelValue", V(i));
|
|
35
|
+
}
|
|
36
|
+
function v(t) {
|
|
37
|
+
t.disabled || d(t, s(t) !== !0);
|
|
38
|
+
}
|
|
39
|
+
const O = l(() => e.returnObject && !c.value ? e.modelValue : y(e.options, m.value, n));
|
|
40
|
+
return { isTreeMode: c, getCheckState: s, toggleOption: d, toggle: v, displayItems: O };
|
|
41
|
+
}
|
|
42
|
+
export {
|
|
43
|
+
k as useMultiSelectSelection
|
|
44
|
+
};
|
|
@@ -1,63 +1,68 @@
|
|
|
1
|
-
import { ref as
|
|
2
|
-
import { useElementSize as
|
|
3
|
-
function
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
|
|
1
|
+
import { ref as G, computed as s } from "vue";
|
|
2
|
+
import { useElementSize as P } from "../node_modules/@vueuse/core/dist/index.mjs";
|
|
3
|
+
function A(e, d, l, f, {
|
|
4
|
+
filterOptions: m = (a, c) => a.filter(c)
|
|
5
|
+
} = {}) {
|
|
6
|
+
const a = G(!1), { width: c } = P(l), S = s(() => `${c.value}px`), r = s(
|
|
7
|
+
() => e.enableSearch && !!e.search
|
|
8
|
+
);
|
|
9
|
+
function u(t) {
|
|
10
|
+
if (!r.value) return !0;
|
|
11
|
+
const o = e.search.toLowerCase(), n = String(t[e.itemLabel] ?? "").toLowerCase().includes(o), i = String(t[e.itemValue] ?? "").toLowerCase().includes(o);
|
|
12
|
+
return n || i;
|
|
13
|
+
}
|
|
14
|
+
const h = s(
|
|
15
|
+
() => r.value ? m(e.options, u) : e.options
|
|
16
|
+
);
|
|
17
|
+
function L(t) {
|
|
15
18
|
const {
|
|
16
19
|
optionsLength: o,
|
|
17
|
-
optionsLines:
|
|
20
|
+
optionsLines: n,
|
|
18
21
|
enableSearch: i,
|
|
19
|
-
variant:
|
|
20
|
-
} =
|
|
22
|
+
variant: H
|
|
23
|
+
} = t;
|
|
21
24
|
if (o === 0) return "unset";
|
|
22
|
-
if (
|
|
23
|
-
const
|
|
24
|
-
return `${i ?
|
|
25
|
+
if (H === "single") {
|
|
26
|
+
const w = 37 * n, C = i ? 1 : 2, g = w + 32 + (4 * n - C);
|
|
27
|
+
return `${i ? g + 45 + 1 : g}px`;
|
|
25
28
|
}
|
|
26
|
-
const
|
|
27
|
-
return `${i ?
|
|
29
|
+
const b = i ? 16 : 0, v = 22 * n + (24 * n - 2);
|
|
30
|
+
return `${i ? v + 51 + b : v}px`;
|
|
28
31
|
}
|
|
29
32
|
const p = s(
|
|
30
33
|
() => {
|
|
31
|
-
var
|
|
34
|
+
var t;
|
|
32
35
|
return L({
|
|
33
|
-
optionsLength: ((
|
|
34
|
-
optionsLines:
|
|
35
|
-
enableSearch:
|
|
36
|
-
variant:
|
|
36
|
+
optionsLength: ((t = e.options) == null ? void 0 : t.length) ?? 0,
|
|
37
|
+
optionsLines: e.optionsLines,
|
|
38
|
+
enableSearch: e.enableSearch,
|
|
39
|
+
variant: d
|
|
37
40
|
});
|
|
38
41
|
}
|
|
39
|
-
),
|
|
40
|
-
var
|
|
41
|
-
const
|
|
42
|
+
), x = s(() => {
|
|
43
|
+
var n;
|
|
44
|
+
const t = ((n = h.value) == null ? void 0 : n.length) === 0, o = p.value;
|
|
42
45
|
return {
|
|
43
46
|
overflow: "auto",
|
|
44
47
|
display: "flex",
|
|
45
48
|
flexDirection: "column",
|
|
46
49
|
minHeight: o,
|
|
47
|
-
maxHeight:
|
|
48
|
-
height:
|
|
50
|
+
maxHeight: t ? "unset" : o,
|
|
51
|
+
height: t ? o : "unset"
|
|
49
52
|
};
|
|
50
53
|
});
|
|
51
54
|
return {
|
|
52
|
-
openPopover:
|
|
53
|
-
triggerRef:
|
|
54
|
-
contentRef:
|
|
55
|
-
inputWidthString:
|
|
55
|
+
openPopover: a,
|
|
56
|
+
triggerRef: l,
|
|
57
|
+
contentRef: f,
|
|
58
|
+
inputWidthString: S,
|
|
56
59
|
calculatedPopoverHeight: p,
|
|
57
|
-
popoverContentCustomStyles:
|
|
58
|
-
|
|
60
|
+
popoverContentCustomStyles: x,
|
|
61
|
+
isSearchActive: r,
|
|
62
|
+
matchesSearch: u,
|
|
63
|
+
filteredOptions: h
|
|
59
64
|
};
|
|
60
65
|
}
|
|
61
66
|
export {
|
|
62
|
-
|
|
67
|
+
A as useSelectBase
|
|
63
68
|
};
|