@bridge-ui/vue 0.0.1-beta.4 → 0.0.1-beta.6
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/Divider/composables/useDivider.js +1 -1
- package/dist/Components/List/List.vue.d.ts +0 -1
- package/dist/Components/List/List.vue_vue_type_script_setup_true_lang.js +2 -3
- package/dist/Components/List/composables/useList.d.ts +3 -9
- package/dist/Components/List/composables/useList.js +21 -25
- package/dist/Components/List/index.d.ts +1 -1
- package/dist/Components/List/list.types.d.ts +1 -8
- package/dist/Components/ListItem/ListItem.vue.d.ts +0 -1
- package/dist/Components/ListItem/ListItem.vue_vue_type_script_setup_true_lang.js +21 -22
- package/dist/Components/ListItem/composables/useListItem.d.ts +18 -18
- package/dist/Components/ListItem/composables/useListItem.js +100 -68
- package/dist/Components/ListItem/index.d.ts +1 -1
- package/dist/Components/ListItem/listItem.types.d.ts +24 -8
- package/dist/Components/ListSection/composables/useListSection.d.ts +1 -3
- package/dist/Components/ListSection/composables/useListSection.js +6 -5
- package/dist/Components/Listbox/Listbox.vue.d.ts +5 -2
- package/dist/Components/Listbox/Listbox.vue_vue_type_script_setup_true_lang.js +101 -62
- package/dist/Components/Listbox/index.d.ts +2 -1
- package/dist/Components/Listbox/index.js +3 -2
- package/dist/Components/Listbox/listbox.types.d.ts +21 -4
- package/dist/Components/Listbox/listboxInjectionKey.d.ts +23 -0
- package/dist/Components/Listbox/listboxInjectionKey.js +4 -0
- package/dist/Components/Menu/Menu.vue.d.ts +2 -2
- package/dist/Components/Menu/composables/useMenu.d.ts +1 -3
- package/dist/Components/Menu/composables/useMenu.js +2 -2
- package/dist/Components/Modal/composables/useModal.d.ts +1 -1
- package/dist/Components/Select/Select.vue_vue_type_script_setup_true_lang.js +68 -57
- package/dist/Components/Select/SelectOption.vue_vue_type_script_setup_true_lang.js +2 -0
- package/dist/Components/Select/composables/useSelect.d.ts +5 -1
- package/dist/Components/Select/composables/useSelect.js +187 -154
- package/dist/Components/Select/select.types.d.ts +12 -5
- package/dist/augments.d.ts +2 -3
- package/dist/index.d.ts +2 -2
- package/dist/index.js +5 -5
- package/package.json +2 -2
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Ref, SetupContext } from 'vue';
|
|
2
|
+
import { ListboxEntry } from '@bridge-ui/core';
|
|
2
3
|
import { FormFieldOwnProps } from '../../FormField/formField.types';
|
|
3
4
|
import { SelectClasses, SelectEmits, SelectOption, SelectOwnProps, SelectValue } from '../select.types';
|
|
4
5
|
export declare function useSelect(props: SelectOwnProps, model: Ref<null | undefined | SelectValue | SelectValue[]>, triggerRef: Ref<null | HTMLInputElement | HTMLTextAreaElement>, emit: SetupContext<SelectEmits>["emit"], declarativeOptions: Ref<SelectOption[]>): {
|
|
@@ -728,6 +729,7 @@ export declare function useSelect(props: SelectOwnProps, model: Ref<null | undef
|
|
|
728
729
|
isSelected: (value: SelectValue) => boolean;
|
|
729
730
|
loading: boolean;
|
|
730
731
|
multiple: boolean;
|
|
732
|
+
entries: ListboxEntry[];
|
|
731
733
|
options: import('@bridge-ui/core').ListboxOption[];
|
|
732
734
|
labelledBy: string;
|
|
733
735
|
highlightedIndex: number;
|
|
@@ -737,12 +739,12 @@ export declare function useSelect(props: SelectOwnProps, model: Ref<null | undef
|
|
|
737
739
|
classes?: import('../../Listbox').ListboxClasses;
|
|
738
740
|
customProps?: import('../../Listbox').ListboxCustomProps;
|
|
739
741
|
disableAutoFocus: boolean;
|
|
740
|
-
placement?: import('@floating-ui/utils').Placement;
|
|
741
742
|
disableMaxHeight: boolean;
|
|
742
743
|
emptyMessage: string;
|
|
743
744
|
hideEmptyMessage: boolean;
|
|
744
745
|
loadingMessage: string;
|
|
745
746
|
maxHeight: string;
|
|
747
|
+
placement?: import('@floating-ui/utils').Placement;
|
|
746
748
|
showCheckmark?: boolean;
|
|
747
749
|
}>;
|
|
748
750
|
clearIconSize: import('vue').ComputedRef<keyof import('@bridge-ui/core').IconSize>;
|
|
@@ -750,7 +752,9 @@ export declare function useSelect(props: SelectOwnProps, model: Ref<null | undef
|
|
|
750
752
|
visibleOptions: import('vue').ComputedRef<import('@bridge-ui/core').ListboxOption[]>;
|
|
751
753
|
isSearchActive: import('vue').ComputedRef<boolean>;
|
|
752
754
|
selectedOptions: import('vue').ComputedRef<import('@bridge-ui/core').ListboxOption[]>;
|
|
755
|
+
hasComposedList: import('vue').ComputedRef<boolean>;
|
|
753
756
|
highlightedIndex: Ref<number, number>;
|
|
757
|
+
handleRegisteredOptionsChange: (options: SelectOption[]) => void;
|
|
754
758
|
emptyMessage: import('vue').ComputedRef<string>;
|
|
755
759
|
hideEmptyMessage: import('vue').ComputedRef<boolean>;
|
|
756
760
|
loadingMessage: import('vue').ComputedRef<string>;
|
|
@@ -2,13 +2,13 @@ import { hasNamedSlot as e } from "../../../Utils/slotOrProp.js";
|
|
|
2
2
|
import { mergePartBind as t, resolveFieldAdornmentIconSize as n, useBridgeUIComponent as r, useBridgeUIMergedRegistryClasses as ee } from "../../../Utils/index.js";
|
|
3
3
|
import { formFieldBridgeKeys as te, useFormField as i } from "../../FormField/composables/useFormField.js";
|
|
4
4
|
import { useListboxNavigation as ne } from "../../Listbox/composables/useListboxNavigation.js";
|
|
5
|
-
import { computed as a, nextTick as
|
|
6
|
-
import { get as
|
|
7
|
-
import { adjustAutosizeTextareaHeight as
|
|
8
|
-
import { ChevronsUpDown as
|
|
9
|
-
import { colorProps as
|
|
5
|
+
import { Comment as re, Text as ie, computed as a, nextTick as ae, onBeforeUnmount as oe, onMounted as se, ref as o, useAttrs as ce, useId as le, useSlots as ue, watch as s } from "vue";
|
|
6
|
+
import { get as c, isNil as de, omit as fe } from "es-toolkit/compat";
|
|
7
|
+
import { adjustAutosizeTextareaHeight as pe, cn as l, createSelectAsyncSearch as me, filterListboxEntries as he, flattenListboxOptions as u, mergeBridgeUILayeredClasses as d, normalizeListboxEntries as f, normalizeSelectOptions as ge, resolveSelectAsyncDebounce as _e, resolveSelectAsyncOptions as ve, selectValuesEqual as p, splitComponentProps as ye } from "@bridge-ui/core";
|
|
8
|
+
import { ChevronsUpDown as be } from "@lucide/vue";
|
|
9
|
+
import { colorProps as xe, invalidatedProps as Se } from "@bridge-ui/core/Components/Listbox";
|
|
10
10
|
//#region src/Components/Select/composables/useSelect.ts
|
|
11
|
-
var
|
|
11
|
+
var Ce = [
|
|
12
12
|
"classes",
|
|
13
13
|
"loading",
|
|
14
14
|
"options",
|
|
@@ -29,66 +29,92 @@ var _e = [
|
|
|
29
29
|
"minItemsForSearch",
|
|
30
30
|
"optionDescription"
|
|
31
31
|
];
|
|
32
|
-
function
|
|
33
|
-
let
|
|
34
|
-
bridgeKeys:
|
|
32
|
+
function m(m, h, g, _, we) {
|
|
33
|
+
let Te = ce(), v = ue(), y = le(), b = o(!1), x = o(""), S = o(-1), C = o(null), w = o(!1), T = o([]), E = null, D = o([]), O = a(() => ye({
|
|
34
|
+
bridgeKeys: Ce,
|
|
35
35
|
props: {
|
|
36
|
-
...
|
|
37
|
-
...
|
|
36
|
+
...Te,
|
|
37
|
+
...m
|
|
38
38
|
}
|
|
39
|
-
})), k = a(() => O.value.componentProps), A = a(() => ({ classes: k.value.classes })), { components: j, entry:
|
|
39
|
+
})), k = a(() => O.value.componentProps), A = a(() => ({ classes: k.value.classes })), { components: j, entry: Ee } = r({
|
|
40
40
|
componentName: "Select",
|
|
41
41
|
props: () => A.value
|
|
42
42
|
}), M = ee({
|
|
43
|
-
entry:
|
|
43
|
+
entry: Ee,
|
|
44
44
|
props: () => A.value
|
|
45
45
|
}), N = a(() => !!k.value.multiple), P = a(() => ({
|
|
46
46
|
optionLabel: k.value.optionLabel ?? "label",
|
|
47
47
|
optionValue: k.value.optionValue ?? "value",
|
|
48
48
|
optionDescription: k.value.optionDescription ?? "description"
|
|
49
|
-
})), F = a(() =>
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}),
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
49
|
+
})), F = a(() => we.value.length > 0 ? we.value.map((e) => ({
|
|
50
|
+
option: e,
|
|
51
|
+
type: "option"
|
|
52
|
+
})) : f(k.value.options, P.value)), De = a(() => u(F.value)), I = o([]);
|
|
53
|
+
function Oe(e) {
|
|
54
|
+
if (!e || typeof e != "object") return !1;
|
|
55
|
+
let t = e.type;
|
|
56
|
+
if (!t || typeof t != "object") return !1;
|
|
57
|
+
let n = t.name, r = t.__name;
|
|
58
|
+
return n === "SelectOption" || r === "SelectOption";
|
|
59
|
+
}
|
|
60
|
+
function ke() {
|
|
61
|
+
return e(v, "default") ? (v.default?.({}) ?? []).some((e) => {
|
|
62
|
+
if (!e || typeof e != "object") return !1;
|
|
63
|
+
let t = e.type;
|
|
64
|
+
return t === re || t === ie || t === void 0 || typeof t == "symbol" ? !1 : !Oe(e);
|
|
65
|
+
}) : !1;
|
|
66
|
+
}
|
|
67
|
+
let L = a(() => ke() && !k.value.options?.length), R = a(() => {
|
|
68
|
+
if (L.value) return [];
|
|
69
|
+
if (T.value.length > 0) {
|
|
70
|
+
let e = f(T.value, P.value);
|
|
71
|
+
return k.value.flipOptions ? [...e].reverse() : e;
|
|
72
|
+
}
|
|
73
|
+
return k.value.flipOptions ? [...F.value].reverse().map((e) => e.type === "section" ? {
|
|
74
|
+
...e,
|
|
75
|
+
options: [...e.options].reverse()
|
|
76
|
+
} : e) : F.value;
|
|
77
|
+
}), Ae = a(() => L.value ? I.value : u(R.value)), z = a(() => {
|
|
78
|
+
let e = h.value;
|
|
79
|
+
return N.value ? Array.isArray(e) ? e : [] : !de(e) && e !== "" ? [e] : [];
|
|
80
|
+
}), B = a(() => {
|
|
56
81
|
let e = /* @__PURE__ */ new Map();
|
|
57
|
-
for (let t of [...
|
|
58
|
-
return
|
|
82
|
+
for (let t of [...Ae.value, ...D.value]) e.set(t.value, t);
|
|
83
|
+
return z.value.map((t) => e.get(t) ?? {
|
|
59
84
|
value: t,
|
|
60
85
|
label: String(t)
|
|
61
86
|
});
|
|
62
|
-
}),
|
|
63
|
-
if (
|
|
87
|
+
}), je = a(() => z.value.length > 0), Me = a(() => k.value.clearable !== !1), V = a(() => !!k.value.asyncData), H = a(() => {
|
|
88
|
+
if (V.value || k.value.searchable) return !0;
|
|
64
89
|
let e = k.value.minItemsForSearch ?? 11;
|
|
65
|
-
return
|
|
66
|
-
}),
|
|
67
|
-
if (
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
90
|
+
return De.value.length >= e;
|
|
91
|
+
}), U = a(() => b.value && H.value), Ne = a(() => !!k.value.loading || w.value), Pe = a(() => {
|
|
92
|
+
if (L.value) return [];
|
|
93
|
+
if (!U.value || !x.value.trim()) return R.value;
|
|
94
|
+
let e = x.value.trim().toLowerCase();
|
|
95
|
+
return he(R.value, (t) => t.label.toLowerCase().includes(e));
|
|
96
|
+
}), W = a(() => L.value ? I.value : u(Pe.value)), G = ne(() => W.value, S, y), Fe = a(() => m.readonly || m.disabled ? !0 : !U.value), Ie = a(() => U.value || N.value ? x.value : B.value[0]?.label ?? ""), Le = (e) => {
|
|
97
|
+
C.value = e instanceof HTMLElement ? e : null;
|
|
72
98
|
};
|
|
73
|
-
function
|
|
99
|
+
function Re(e) {
|
|
74
100
|
e.preventDefault();
|
|
75
101
|
}
|
|
76
|
-
function
|
|
77
|
-
if (
|
|
102
|
+
function ze(e) {
|
|
103
|
+
if (m.disabled || m.readonly) return;
|
|
78
104
|
let t = e.target;
|
|
79
105
|
if (!t.closest("[data-select-clear]") && !(t.closest(".wrapper-start-slot") || t.closest(".wrapper-end-slot"))) {
|
|
80
|
-
if (!
|
|
106
|
+
if (!b.value) {
|
|
81
107
|
Z();
|
|
82
108
|
return;
|
|
83
109
|
}
|
|
84
|
-
|
|
110
|
+
U.value || (Q(), g.value?.focus({ preventScroll: !0 }));
|
|
85
111
|
}
|
|
86
112
|
}
|
|
87
|
-
let
|
|
88
|
-
let n =
|
|
113
|
+
let Be = a(() => {
|
|
114
|
+
let n = ye({
|
|
89
115
|
bridgeKeys: te,
|
|
90
|
-
props:
|
|
91
|
-
}).componentProps, r = n.endIcon ?? (e(
|
|
116
|
+
props: fe(O.value.inheritedAttrs, ["class"])
|
|
117
|
+
}).componentProps, r = n.endIcon ?? (e(v, "end") ? void 0 : be), { listbox: ee, ...i } = n.customProps ?? {};
|
|
92
118
|
return {
|
|
93
119
|
...n,
|
|
94
120
|
endIcon: r,
|
|
@@ -96,13 +122,13 @@ function h(h, g, _, v, y) {
|
|
|
96
122
|
customProps: {
|
|
97
123
|
...i,
|
|
98
124
|
container: t(i.container, {}, {
|
|
99
|
-
ref:
|
|
100
|
-
onClick:
|
|
101
|
-
class:
|
|
125
|
+
ref: Le,
|
|
126
|
+
onClick: ze,
|
|
127
|
+
class: l({ "cursor-pointer": !m.disabled && !m.readonly && !U.value })
|
|
102
128
|
})
|
|
103
129
|
}
|
|
104
130
|
};
|
|
105
|
-
}),
|
|
131
|
+
}), Ve = a(() => m.customProps?.listbox), K = i(() => Be.value, {
|
|
106
132
|
size: "md",
|
|
107
133
|
rounded: "md",
|
|
108
134
|
color: "primary",
|
|
@@ -112,81 +138,81 @@ function h(h, g, _, v, y) {
|
|
|
112
138
|
likeInput: () => N.value,
|
|
113
139
|
control: () => N.value ? "textarea" : "input"
|
|
114
140
|
}), q = (e) => {
|
|
115
|
-
!e || !N.value ||
|
|
141
|
+
!e || !N.value || pe(e);
|
|
116
142
|
};
|
|
117
143
|
function J(e) {
|
|
118
|
-
return
|
|
144
|
+
return z.value.some((t) => p(t, e));
|
|
119
145
|
}
|
|
120
146
|
function Y(e) {
|
|
121
|
-
|
|
147
|
+
h.value = e;
|
|
122
148
|
}
|
|
123
149
|
function X(e) {
|
|
124
150
|
if (N.value) {
|
|
125
151
|
let t = Array.isArray(e) ? e : [];
|
|
126
|
-
|
|
152
|
+
_("update:modelValue", t), _("change", t);
|
|
127
153
|
return;
|
|
128
154
|
}
|
|
129
155
|
let t = e ?? "";
|
|
130
|
-
|
|
156
|
+
_("update:modelValue", t), _("change", t);
|
|
131
157
|
}
|
|
132
158
|
function Z() {
|
|
133
|
-
|
|
159
|
+
m.disabled || m.readonly || b.value || (b.value = !0, x.value = "", G.highlightCurrentSelection(J), _("open"), V.value && k.value.asyncData && E?.searchImmediate(""));
|
|
134
160
|
}
|
|
135
161
|
function Q() {
|
|
136
|
-
E?.cancel(),
|
|
162
|
+
E?.cancel(), b.value && (b.value = !1, x.value = "", S.value = -1, _("close"));
|
|
137
163
|
}
|
|
138
|
-
function
|
|
164
|
+
function $(e) {
|
|
139
165
|
if (!e.disabled) {
|
|
140
166
|
if (N.value) {
|
|
141
|
-
let t = [...
|
|
142
|
-
n >= 0 ? (t.splice(n, 1),
|
|
143
|
-
q(
|
|
167
|
+
let t = [...z.value], n = t.findIndex((t) => p(t, e.value));
|
|
168
|
+
n >= 0 ? (t.splice(n, 1), _("deselect", e)) : (t.push(e.value), _("select", e)), Y(t), X(t), x.value = "", S.value = -1, ae(() => {
|
|
169
|
+
q(g.value), g.value?.focus({ preventScroll: !0 });
|
|
144
170
|
});
|
|
145
171
|
return;
|
|
146
172
|
}
|
|
147
|
-
Y(e.value), X(e.value),
|
|
173
|
+
Y(e.value), X(e.value), _("select", e), Q();
|
|
148
174
|
}
|
|
149
175
|
}
|
|
150
|
-
function
|
|
151
|
-
e?.preventDefault(), e?.stopPropagation(), N.value ? (Y([]), X([])) : (Y(null), X(null)),
|
|
176
|
+
function He(e) {
|
|
177
|
+
e?.preventDefault(), e?.stopPropagation(), N.value ? (Y([]), X([])) : (Y(null), X(null)), _("clear"), Q();
|
|
152
178
|
}
|
|
153
|
-
function
|
|
179
|
+
function Ue(e, t) {
|
|
154
180
|
if (t.preventDefault(), t.stopPropagation(), !N.value) return;
|
|
155
|
-
let n =
|
|
156
|
-
Y(n), X(n),
|
|
181
|
+
let n = z.value.filter((t) => !p(t, e.value));
|
|
182
|
+
Y(n), X(n), _("deselect", e), ae(() => q(g.value));
|
|
157
183
|
}
|
|
158
|
-
function
|
|
184
|
+
function We() {
|
|
159
185
|
let e = G.getHighlightedOption();
|
|
160
|
-
e &&
|
|
186
|
+
e && $(e);
|
|
161
187
|
}
|
|
162
|
-
function
|
|
163
|
-
|
|
188
|
+
function Ge(e) {
|
|
189
|
+
x.value = e.target.value, _("search", x.value), b.value || Z(), G.resetHighlight(), V.value && E?.searchDebounced(x.value);
|
|
164
190
|
}
|
|
165
|
-
function
|
|
166
|
-
if (!(
|
|
191
|
+
function Ke(e) {
|
|
192
|
+
if (!(m.disabled || m.readonly)) switch (e.key) {
|
|
167
193
|
case "ArrowDown":
|
|
168
|
-
e.preventDefault(),
|
|
194
|
+
e.preventDefault(), b.value ? G.moveHighlight(1) : Z();
|
|
169
195
|
break;
|
|
170
196
|
case "ArrowUp":
|
|
171
|
-
e.preventDefault(),
|
|
197
|
+
e.preventDefault(), b.value ? G.moveHighlight(-1) : Z();
|
|
172
198
|
break;
|
|
173
199
|
case "Enter":
|
|
174
|
-
e.preventDefault(),
|
|
200
|
+
e.preventDefault(), b.value ? We() : Z();
|
|
175
201
|
break;
|
|
176
202
|
case "Escape":
|
|
177
203
|
e.preventDefault(), Q();
|
|
178
204
|
break;
|
|
179
205
|
case "Home":
|
|
180
|
-
|
|
206
|
+
b.value && (e.preventDefault(), G.highlightFirst());
|
|
181
207
|
break;
|
|
182
208
|
case "End":
|
|
183
|
-
|
|
209
|
+
b.value && (e.preventDefault(), G.highlightLast());
|
|
184
210
|
break;
|
|
185
211
|
case "Backspace":
|
|
186
|
-
if (N.value && !
|
|
212
|
+
if (N.value && !x.value && B.value.length > 0) {
|
|
187
213
|
e.preventDefault();
|
|
188
|
-
let t =
|
|
189
|
-
t &&
|
|
214
|
+
let t = B.value.at(-1);
|
|
215
|
+
t && Ue(t, e);
|
|
190
216
|
}
|
|
191
217
|
break;
|
|
192
218
|
case "Tab":
|
|
@@ -195,133 +221,140 @@ function h(h, g, _, v, y) {
|
|
|
195
221
|
default: break;
|
|
196
222
|
}
|
|
197
223
|
}
|
|
198
|
-
async function
|
|
224
|
+
async function qe(e) {
|
|
199
225
|
let t = k.value.asyncData;
|
|
200
226
|
if (t) {
|
|
201
227
|
w.value = !0;
|
|
202
228
|
try {
|
|
203
|
-
let { options: n, resolvedSelected: r } = await
|
|
229
|
+
let { options: n, resolvedSelected: r } = await ve(t, e, z.value, (e) => ge(e, P.value));
|
|
204
230
|
r.length > 0 && (D.value = r), T.value = n;
|
|
205
231
|
} finally {
|
|
206
232
|
w.value = !1;
|
|
207
233
|
}
|
|
208
234
|
}
|
|
209
235
|
}
|
|
210
|
-
async function
|
|
236
|
+
async function Je() {
|
|
211
237
|
let e = k.value.asyncData;
|
|
212
|
-
!e?.resolve ||
|
|
238
|
+
!e?.resolve || z.value.length === 0 || (D.value = ge(await e.resolve(z.value), P.value));
|
|
213
239
|
}
|
|
214
|
-
let
|
|
215
|
-
let e =
|
|
240
|
+
let Ye = a(() => {
|
|
241
|
+
let e = c(d(xe, c(j.value, [
|
|
216
242
|
"Listbox",
|
|
217
243
|
"customProps",
|
|
218
244
|
"color"
|
|
219
245
|
])), K.merged.value.color ?? "primary");
|
|
220
|
-
return K.invalidated.value ? d(
|
|
246
|
+
return K.invalidated.value ? d(Se, c(j.value, [
|
|
221
247
|
"Listbox",
|
|
222
248
|
"customProps",
|
|
223
249
|
"invalidated"
|
|
224
250
|
])) : e;
|
|
225
|
-
}),
|
|
226
|
-
let e = !
|
|
251
|
+
}), Xe = a(() => Ye.value?.value), Ze = a(() => {
|
|
252
|
+
let e = !m.disabled && !m.readonly && !U.value, n = !m.disabled && !m.readonly && U.value && H.value, r = je.value && !N.value && !U.value;
|
|
227
253
|
return t({
|
|
228
254
|
role: "combobox",
|
|
229
|
-
value:
|
|
230
|
-
"aria-controls":
|
|
231
|
-
"aria-expanded":
|
|
232
|
-
readonly:
|
|
233
|
-
onKeydown:
|
|
255
|
+
value: Ie.value,
|
|
256
|
+
"aria-controls": y,
|
|
257
|
+
"aria-expanded": b.value,
|
|
258
|
+
readonly: Fe.value,
|
|
259
|
+
onKeydown: Ke,
|
|
234
260
|
placeholder: k.value.placeholder,
|
|
235
|
-
"aria-autocomplete":
|
|
236
|
-
"aria-activedescendant":
|
|
261
|
+
"aria-autocomplete": H.value ? "list" : void 0,
|
|
262
|
+
"aria-activedescendant": b.value ? G.activeDescendantId.value : void 0,
|
|
237
263
|
...N.value ? {
|
|
238
264
|
rows: 1,
|
|
239
265
|
onInput: (e) => {
|
|
240
|
-
|
|
266
|
+
Ge(e), q(e.target);
|
|
241
267
|
}
|
|
242
|
-
} : { onInput:
|
|
243
|
-
}, K.inputBind.value,
|
|
268
|
+
} : { onInput: Ge }
|
|
269
|
+
}, K.inputBind.value, l({
|
|
244
270
|
"cursor-text": n,
|
|
245
271
|
"cursor-pointer": e,
|
|
246
272
|
"resize-none overflow-hidden": N.value,
|
|
247
|
-
[
|
|
273
|
+
[l(Xe.value, M.value.value) ?? ""]: r
|
|
248
274
|
}));
|
|
249
275
|
});
|
|
250
|
-
|
|
251
|
-
|
|
276
|
+
s(() => [
|
|
277
|
+
b.value,
|
|
252
278
|
N.value,
|
|
253
|
-
|
|
279
|
+
g.value
|
|
254
280
|
], () => {
|
|
255
|
-
q(
|
|
256
|
-
}, { immediate: !0 }),
|
|
257
|
-
|
|
258
|
-
}, { immediate: !0 }),
|
|
259
|
-
if (E?.cancel(), T.value = [],
|
|
281
|
+
q(g.value);
|
|
282
|
+
}, { immediate: !0 }), s(() => h.value, () => {
|
|
283
|
+
Je();
|
|
284
|
+
}, { immediate: !0 }), s(() => k.value.asyncData, (e) => {
|
|
285
|
+
if (E?.cancel(), T.value = [], Je(), !e) {
|
|
260
286
|
E = null;
|
|
261
287
|
return;
|
|
262
288
|
}
|
|
263
|
-
E =
|
|
264
|
-
}, { immediate: !0 }),
|
|
289
|
+
E = me((e) => void qe(e), _e(e));
|
|
290
|
+
}, { immediate: !0 }), oe(() => {
|
|
265
291
|
E?.cancel();
|
|
266
|
-
}),
|
|
267
|
-
q(
|
|
292
|
+
}), se(() => {
|
|
293
|
+
q(g.value);
|
|
268
294
|
});
|
|
269
|
-
let
|
|
295
|
+
let Qe = a(() => n(K.merged.value.size)), $e = a(() => t({}, {}, {
|
|
296
|
+
tabindex: 0,
|
|
297
|
+
role: "button",
|
|
298
|
+
"data-select-clear": !0,
|
|
299
|
+
onMousedown: Re,
|
|
300
|
+
class: l({
|
|
301
|
+
"inline-flex shrink-0 cursor-pointer items-center justify-center rounded-sm transition-colors duration-150": !0,
|
|
302
|
+
[Ye.value?.clear ?? ""]: !0,
|
|
303
|
+
[M.value.clear ?? ""]: !0
|
|
304
|
+
})
|
|
305
|
+
})), et = a(() => ({
|
|
306
|
+
disableAutoFocus: !0,
|
|
307
|
+
maxHeight: m.maxHeight,
|
|
308
|
+
size: K.merged.value.size,
|
|
309
|
+
color: K.merged.value.color,
|
|
310
|
+
disableMaxHeight: m.disableMaxHeight === !0,
|
|
311
|
+
emptyMessage: k.value.emptyMessage ?? "No options",
|
|
312
|
+
hideEmptyMessage: k.value.hideEmptyMessage === !0,
|
|
313
|
+
loadingMessage: k.value.loadingMessage ?? "Loading...",
|
|
314
|
+
...Ve.value,
|
|
315
|
+
listboxId: y,
|
|
316
|
+
isSelected: J,
|
|
317
|
+
loading: Ne.value,
|
|
318
|
+
multiple: N.value,
|
|
319
|
+
entries: Pe.value,
|
|
320
|
+
options: W.value,
|
|
321
|
+
labelledBy: K.controlId.value,
|
|
322
|
+
highlightedIndex: S.value,
|
|
323
|
+
invalidated: K.invalidated.value
|
|
324
|
+
}));
|
|
325
|
+
function tt(e) {
|
|
326
|
+
let t = I.value;
|
|
327
|
+
t.length === e.length && t.every((t, n) => String(t.value) === String(e[n]?.value)) || (I.value = e);
|
|
328
|
+
}
|
|
270
329
|
return {
|
|
271
|
-
open:
|
|
272
|
-
slots:
|
|
273
|
-
hasValue:
|
|
330
|
+
open: b,
|
|
331
|
+
slots: v,
|
|
332
|
+
hasValue: je,
|
|
274
333
|
multiple: N,
|
|
275
|
-
listboxId:
|
|
334
|
+
listboxId: y,
|
|
276
335
|
formField: K,
|
|
277
|
-
isLoading:
|
|
278
|
-
clearable:
|
|
279
|
-
clearBind:
|
|
280
|
-
tabindex: 0,
|
|
281
|
-
role: "button",
|
|
282
|
-
"data-select-clear": !0,
|
|
283
|
-
onMousedown: Ee,
|
|
284
|
-
class: u({
|
|
285
|
-
"inline-flex shrink-0 cursor-pointer items-center justify-center rounded-sm transition-colors duration-150": !0,
|
|
286
|
-
[$.value?.clear ?? ""]: !0,
|
|
287
|
-
[M.value.clear ?? ""]: !0
|
|
288
|
-
})
|
|
289
|
-
})),
|
|
336
|
+
isLoading: Ne,
|
|
337
|
+
clearable: Me,
|
|
338
|
+
clearBind: $e,
|
|
290
339
|
isSelected: J,
|
|
291
|
-
clearValue:
|
|
292
|
-
removeChip:
|
|
293
|
-
triggerBind:
|
|
294
|
-
selectOption:
|
|
295
|
-
containerRef:
|
|
296
|
-
listboxProps:
|
|
297
|
-
|
|
298
|
-
maxHeight: h.maxHeight,
|
|
299
|
-
size: K.merged.value.size,
|
|
300
|
-
color: K.merged.value.color,
|
|
301
|
-
disableMaxHeight: h.disableMaxHeight === !0,
|
|
302
|
-
emptyMessage: k.value.emptyMessage ?? "No options",
|
|
303
|
-
hideEmptyMessage: k.value.hideEmptyMessage === !0,
|
|
304
|
-
loadingMessage: k.value.loadingMessage ?? "Loading...",
|
|
305
|
-
...ke.value,
|
|
306
|
-
listboxId: b,
|
|
307
|
-
isSelected: J,
|
|
308
|
-
loading: U.value,
|
|
309
|
-
multiple: N.value,
|
|
310
|
-
options: W.value,
|
|
311
|
-
labelledBy: K.controlId.value,
|
|
312
|
-
highlightedIndex: C.value,
|
|
313
|
-
invalidated: K.invalidated.value
|
|
314
|
-
})),
|
|
315
|
-
clearIconSize: Be,
|
|
340
|
+
clearValue: He,
|
|
341
|
+
removeChip: Ue,
|
|
342
|
+
triggerBind: Ze,
|
|
343
|
+
selectOption: $,
|
|
344
|
+
containerRef: C,
|
|
345
|
+
listboxProps: et,
|
|
346
|
+
clearIconSize: Qe,
|
|
316
347
|
mergedClasses: M,
|
|
317
348
|
visibleOptions: W,
|
|
318
|
-
isSearchActive:
|
|
319
|
-
selectedOptions:
|
|
320
|
-
|
|
349
|
+
isSearchActive: U,
|
|
350
|
+
selectedOptions: B,
|
|
351
|
+
hasComposedList: L,
|
|
352
|
+
highlightedIndex: S,
|
|
353
|
+
handleRegisteredOptionsChange: tt,
|
|
321
354
|
emptyMessage: a(() => k.value.emptyMessage ?? "No options"),
|
|
322
355
|
hideEmptyMessage: a(() => k.value.hideEmptyMessage === !0),
|
|
323
356
|
loadingMessage: a(() => k.value.loadingMessage ?? "Loading...")
|
|
324
357
|
};
|
|
325
358
|
}
|
|
326
359
|
//#endregion
|
|
327
|
-
export {
|
|
360
|
+
export { m as useSelect };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { InputHTMLAttributes, Slot, TextareaHTMLAttributes } from 'vue';
|
|
2
|
-
import { MergeHtmlProps, SelectAsyncData, SelectModel, SelectOption,
|
|
2
|
+
import { ListboxOptionsInput, MergeHtmlProps, SelectAsyncData, SelectModel, SelectOption, SelectValue } from '@bridge-ui/core';
|
|
3
3
|
import { FormFieldClasses, FormFieldCustomProps, FormFieldOwnProps, FormFieldSlots } from '../FormField/formField.types';
|
|
4
4
|
import { ListboxOwnProps } from '../Listbox/listbox.types';
|
|
5
|
-
export type { SelectAsyncData, SelectModel, SelectOption, SelectOptionInput, SelectOptionLike, SelectValue, } from '@bridge-ui/core';
|
|
5
|
+
export type { ListboxOptionGroup, ListboxOptionsInput, SelectAsyncData, SelectModel, SelectOption, SelectOptionInput, SelectOptionLike, SelectValue, } from '@bridge-ui/core';
|
|
6
6
|
export interface SelectClasses extends FormFieldClasses {
|
|
7
7
|
/**
|
|
8
8
|
* The classes to apply to selected chips (multiple mode).
|
|
@@ -174,9 +174,10 @@ export interface SelectOwnProps extends Omit<FormFieldOwnProps, "field"> {
|
|
|
174
174
|
*/
|
|
175
175
|
optionLabel?: string;
|
|
176
176
|
/**
|
|
177
|
-
* The list of options to display.
|
|
177
|
+
* The list of options to display. May include section groups
|
|
178
|
+
* (`{ title, options, sticky? }`).
|
|
178
179
|
*/
|
|
179
|
-
options?:
|
|
180
|
+
options?: ListboxOptionsInput;
|
|
180
181
|
/**
|
|
181
182
|
* Key used to read the value from option objects.
|
|
182
183
|
*
|
|
@@ -209,6 +210,12 @@ export interface SelectSlots extends FormFieldSlots {
|
|
|
209
210
|
chip?: Slot<{
|
|
210
211
|
option: SelectOption;
|
|
211
212
|
}>;
|
|
213
|
+
/**
|
|
214
|
+
* Composed dropdown content (`ListSection` / `ListItem` with `value`).
|
|
215
|
+
* When set (and not using declarative `SelectOption` children), replaces
|
|
216
|
+
* mapped `options` inside the listbox.
|
|
217
|
+
*/
|
|
218
|
+
default?: Slot;
|
|
212
219
|
/**
|
|
213
220
|
* Custom empty-state content.
|
|
214
221
|
*/
|
|
@@ -218,7 +225,7 @@ export interface SelectSlots extends FormFieldSlots {
|
|
|
218
225
|
*/
|
|
219
226
|
loading?: Slot;
|
|
220
227
|
/**
|
|
221
|
-
* Custom option item content.
|
|
228
|
+
* Custom option item content when rendering from the `options` prop.
|
|
222
229
|
*/
|
|
223
230
|
option?: Slot<{
|
|
224
231
|
option: SelectOption;
|
package/dist/augments.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ import { FormFieldClasses, FormFieldProps } from './Components/FormField';
|
|
|
11
11
|
import { IconProps } from './Components/Icon';
|
|
12
12
|
import { LabelClasses, LabelProps } from './Components/Label';
|
|
13
13
|
import { LinkClasses, LinkProps } from './Components/Link';
|
|
14
|
-
import { ListClasses
|
|
14
|
+
import { ListClasses } from './Components/List';
|
|
15
15
|
import { ListItemClasses, ListItemProps } from './Components/ListItem';
|
|
16
16
|
import { ListSectionClasses } from './Components/ListSection';
|
|
17
17
|
import { MenuClasses, MenuProps } from './Components/Menu';
|
|
@@ -78,11 +78,10 @@ declare module "@bridge-ui/core" {
|
|
|
78
78
|
}
|
|
79
79
|
interface ListConfigOverrides {
|
|
80
80
|
classes: ListClasses;
|
|
81
|
-
defaultProps: Partial<Pick<ListProps, "padding">>;
|
|
82
81
|
}
|
|
83
82
|
interface ListItemConfigOverrides {
|
|
84
83
|
classes: ListItemClasses;
|
|
85
|
-
defaultProps: Partial<Pick<ListItemProps, "role" | "
|
|
84
|
+
defaultProps: Partial<Pick<ListItemProps, "role" | "selectedIcon">>;
|
|
86
85
|
}
|
|
87
86
|
interface ListSectionConfigOverrides {
|
|
88
87
|
classes: ListSectionClasses;
|
package/dist/index.d.ts
CHANGED
|
@@ -25,11 +25,11 @@ export type { LabelClasses, LabelOwnProps, LabelProps, LabelSizeOverrides, } fro
|
|
|
25
25
|
export { Link, useLink } from './Components/Link';
|
|
26
26
|
export type { LinkClasses, LinkColorOverrides, LinkCustomProps, LinkOwnProps, LinkProps, LinkSizeOverrides, LinkSlots, LinkUnderlineOverrides, } from './Components/Link';
|
|
27
27
|
export { List, useList } from './Components/List';
|
|
28
|
-
export type { ListClasses, ListContextValue, ListCustomProps, ListOwnProps,
|
|
28
|
+
export type { ListClasses, ListContextValue, ListCustomProps, ListOwnProps, ListProps, } from './Components/List';
|
|
29
29
|
export { Listbox, findFirstEnabledOptionIndex, findLastEnabledOptionIndex, getListboxActiveDescendantId, getListboxOptionId, moveListboxHighlight, useListbox, useListboxNavigation, } from './Components/Listbox';
|
|
30
30
|
export type { ListboxClasses, ListboxColorOverrides, ListboxCustomProps, ListboxEmits, ListboxOption, ListboxOwnProps, ListboxProps, ListboxSlots, ListboxValue, } from './Components/Listbox';
|
|
31
31
|
export { ListItem } from './Components/ListItem';
|
|
32
|
-
export type {
|
|
32
|
+
export type { ListItemClasses, ListItemCustomProps, ListItemOwnProps, ListItemProps, ListItemSlots, } from './Components/ListItem';
|
|
33
33
|
export { ListSection } from './Components/ListSection';
|
|
34
34
|
export type { ListSectionClasses, ListSectionCustomProps, ListSectionOwnProps, ListSectionProps, ListSectionSlots, } from './Components/ListSection';
|
|
35
35
|
export { Menu, useMenu } from './Components/Menu';
|
package/dist/index.js
CHANGED
|
@@ -29,10 +29,10 @@ import O from "./Components/List/List.js";
|
|
|
29
29
|
import { useListbox as k } from "./Components/Listbox/composables/useListbox.js";
|
|
30
30
|
import { findFirstEnabledOptionIndex as A, findLastEnabledOptionIndex as j, getListboxActiveDescendantId as M, getListboxOptionId as N, moveListboxHighlight as P, useListboxNavigation as F } from "./Components/Listbox/composables/useListboxNavigation.js";
|
|
31
31
|
import I from "./Components/ListItem/ListItem.js";
|
|
32
|
-
import
|
|
33
|
-
import R from "./Components/Menu/
|
|
34
|
-
import z from "./Components/
|
|
35
|
-
import B from "./Components/
|
|
32
|
+
import L from "./Components/ListSection/ListSection.js";
|
|
33
|
+
import { useMenu as R } from "./Components/Menu/composables/useMenu.js";
|
|
34
|
+
import z from "./Components/Menu/Menu.js";
|
|
35
|
+
import B from "./Components/Listbox/Listbox.js";
|
|
36
36
|
import { useModal as V } from "./Components/Modal/composables/useModal.js";
|
|
37
37
|
import H from "./Components/Modal/Modal.js";
|
|
38
38
|
import { useNumberField as U } from "./Components/NumberField/composables/useNumberField.js";
|
|
@@ -56,4 +56,4 @@ import oe from "./Components/TextField/TextField.js";
|
|
|
56
56
|
import se from "./Provider/BridgeUIProvider.js";
|
|
57
57
|
import { createBridgeUI as ce } from "./Provider/createBridgeUI.js";
|
|
58
58
|
import { BRIDGE_UI_DEFAULT_GLOBAL as le, cn as ue, mergeBridgeUIComponents as de, mergeBridgeUIGlobal as fe, resolveBridgeUIOptions as pe } from "@bridge-ui/core";
|
|
59
|
-
export { a as Alert, o as Avatar, le as BRIDGE_UI_DEFAULT_GLOBAL, c as Badge, se as BridgeUIProvider, u as Button, f as Card, g as Checkbox, v as Chip, b as Divider, m as FormControl, S as FormField, i as Icon, w as Label, E as Link, O as List, I as ListItem,
|
|
59
|
+
export { a as Alert, o as Avatar, le as BRIDGE_UI_DEFAULT_GLOBAL, c as Badge, se as BridgeUIProvider, u as Button, f as Card, g as Checkbox, v as Chip, b as Divider, m as FormControl, S as FormField, i as Icon, w as Label, E as Link, O as List, I as ListItem, L as ListSection, B as Listbox, z as Menu, H as Modal, W as NumberField, K as PasswordField, J as Radio, Y as Select, X as SelectOption, Q as Skeleton, ee as Snackbar, ne as Switch, oe as TextField, ie as Textarea, ue as cn, ce as createBridgeUI, A as findFirstEnabledOptionIndex, j as findLastEnabledOptionIndex, M as getListboxActiveDescendantId, N as getListboxOptionId, de as mergeBridgeUIComponents, fe as mergeBridgeUIGlobal, P as moveListboxHighlight, pe as resolveBridgeUIOptions, r as useAlert, s as useBadge, e as useBridgeUI, t as useBridgeUIComponent, n as useBridgeUIMergedRegistryClasses, l as useButton, d as useCard, h as useCheckbox, _ as useChip, y as useDivider, p as useFormControl, x as useFormField, C as useLabel, T as useLink, D as useList, k as useListbox, F as useListboxNavigation, R as useMenu, V as useModal, U as useNumberField, G as usePasswordField, q as useRadio, Z as useSkeleton, $ as useSnackbar, te as useSwitch, ae as useTextField, re as useTextarea };
|