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