@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.
Files changed (35) hide show
  1. package/dist/Components/Divider/composables/useDivider.js +1 -1
  2. package/dist/Components/List/List.vue.d.ts +0 -1
  3. package/dist/Components/List/List.vue_vue_type_script_setup_true_lang.js +2 -3
  4. package/dist/Components/List/composables/useList.d.ts +3 -9
  5. package/dist/Components/List/composables/useList.js +21 -25
  6. package/dist/Components/List/index.d.ts +1 -1
  7. package/dist/Components/List/list.types.d.ts +1 -8
  8. package/dist/Components/ListItem/ListItem.vue.d.ts +0 -1
  9. package/dist/Components/ListItem/ListItem.vue_vue_type_script_setup_true_lang.js +21 -22
  10. package/dist/Components/ListItem/composables/useListItem.d.ts +18 -18
  11. package/dist/Components/ListItem/composables/useListItem.js +100 -68
  12. package/dist/Components/ListItem/index.d.ts +1 -1
  13. package/dist/Components/ListItem/listItem.types.d.ts +24 -8
  14. package/dist/Components/ListSection/composables/useListSection.d.ts +1 -3
  15. package/dist/Components/ListSection/composables/useListSection.js +6 -5
  16. package/dist/Components/Listbox/Listbox.vue.d.ts +5 -2
  17. package/dist/Components/Listbox/Listbox.vue_vue_type_script_setup_true_lang.js +101 -62
  18. package/dist/Components/Listbox/index.d.ts +2 -1
  19. package/dist/Components/Listbox/index.js +3 -2
  20. package/dist/Components/Listbox/listbox.types.d.ts +21 -4
  21. package/dist/Components/Listbox/listboxInjectionKey.d.ts +23 -0
  22. package/dist/Components/Listbox/listboxInjectionKey.js +4 -0
  23. package/dist/Components/Menu/Menu.vue.d.ts +2 -2
  24. package/dist/Components/Menu/composables/useMenu.d.ts +1 -3
  25. package/dist/Components/Menu/composables/useMenu.js +2 -2
  26. package/dist/Components/Modal/composables/useModal.d.ts +1 -1
  27. package/dist/Components/Select/Select.vue_vue_type_script_setup_true_lang.js +68 -57
  28. package/dist/Components/Select/SelectOption.vue_vue_type_script_setup_true_lang.js +2 -0
  29. package/dist/Components/Select/composables/useSelect.d.ts +5 -1
  30. package/dist/Components/Select/composables/useSelect.js +187 -154
  31. package/dist/Components/Select/select.types.d.ts +12 -5
  32. package/dist/augments.d.ts +2 -3
  33. package/dist/index.d.ts +2 -2
  34. package/dist/index.js +5 -5
  35. 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 o, onBeforeUnmount as re, onMounted as ie, ref as s, useAttrs as ae, useId as oe, useSlots as se, watch as c } from "vue";
6
- import { get as l, isNil as ce, omit as le } from "es-toolkit/compat";
7
- import { adjustAutosizeTextareaHeight as ue, cn as u, createSelectAsyncSearch as de, mergeBridgeUILayeredClasses as d, normalizeSelectOptions as f, resolveSelectAsyncDebounce as fe, resolveSelectAsyncOptions as pe, selectValuesEqual as p, splitComponentProps as m } from "@bridge-ui/core";
8
- import { ChevronsUpDown as me } from "@lucide/vue";
9
- import { colorProps as he, invalidatedProps as ge } from "@bridge-ui/core/Components/Listbox";
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 _e = [
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 h(h, g, _, v, y) {
33
- let ve = ae(), ye = se(), b = oe(), x = s(!1), S = s(""), C = s(-1), be = s(null), w = s(!1), T = s([]), E = null, D = s([]), O = a(() => m({
34
- bridgeKeys: _e,
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
- ...ve,
37
- ...h
36
+ ...Te,
37
+ ...m
38
38
  }
39
- })), k = a(() => O.value.componentProps), A = a(() => ({ classes: k.value.classes })), { components: j, entry: xe } = r({
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: xe,
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(() => y.value.length > 0 ? y.value : f(k.value.options, P.value)), I = a(() => {
50
- let e = T.value.length > 0 ? T.value : F.value;
51
- return k.value.flipOptions ? [...e].reverse() : e;
52
- }), L = a(() => {
53
- let e = g.value;
54
- return N.value ? Array.isArray(e) ? e : [] : !ce(e) && e !== "" ? [e] : [];
55
- }), R = a(() => {
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 [...I.value, ...D.value]) e.set(t.value, t);
58
- return L.value.map((t) => e.get(t) ?? {
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
- }), z = a(() => L.value.length > 0), Se = a(() => k.value.clearable !== !1), B = a(() => !!k.value.asyncData), V = a(() => {
63
- if (B.value || k.value.searchable) return !0;
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 F.value.length >= e;
66
- }), H = a(() => x.value && V.value), U = a(() => !!k.value.loading || w.value), W = a(() => {
67
- if (!H.value || !S.value.trim()) return I.value;
68
- let e = S.value.trim().toLowerCase();
69
- return I.value.filter((t) => t.label.toLowerCase().includes(e));
70
- }), G = ne(() => W.value, C, b), Ce = a(() => h.readonly || h.disabled ? !0 : !H.value), we = a(() => H.value || N.value ? S.value : R.value[0]?.label ?? ""), Te = (e) => {
71
- be.value = e instanceof HTMLElement ? e : null;
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 Ee(e) {
99
+ function Re(e) {
74
100
  e.preventDefault();
75
101
  }
76
- function De(e) {
77
- if (h.disabled || h.readonly) return;
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 (!x.value) {
106
+ if (!b.value) {
81
107
  Z();
82
108
  return;
83
109
  }
84
- H.value || (Q(), _.value?.focus({ preventScroll: !0 }));
110
+ U.value || (Q(), g.value?.focus({ preventScroll: !0 }));
85
111
  }
86
112
  }
87
- let Oe = a(() => {
88
- let n = m({
113
+ let Be = a(() => {
114
+ let n = ye({
89
115
  bridgeKeys: te,
90
- props: le(O.value.inheritedAttrs, ["class"])
91
- }).componentProps, r = n.endIcon ?? (e(ye, "end") ? void 0 : me), { listbox: ee, ...i } = n.customProps ?? {};
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: Te,
100
- onClick: De,
101
- class: u({ "cursor-pointer": !h.disabled && !h.readonly && !H.value })
125
+ ref: Le,
126
+ onClick: ze,
127
+ class: l({ "cursor-pointer": !m.disabled && !m.readonly && !U.value })
102
128
  })
103
129
  }
104
130
  };
105
- }), ke = a(() => h.customProps?.listbox), K = i(() => Oe.value, {
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 || ue(e);
141
+ !e || !N.value || pe(e);
116
142
  };
117
143
  function J(e) {
118
- return L.value.some((t) => p(t, e));
144
+ return z.value.some((t) => p(t, e));
119
145
  }
120
146
  function Y(e) {
121
- g.value = e;
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
- v("update:modelValue", t), v("change", t);
152
+ _("update:modelValue", t), _("change", t);
127
153
  return;
128
154
  }
129
155
  let t = e ?? "";
130
- v("update:modelValue", t), v("change", t);
156
+ _("update:modelValue", t), _("change", t);
131
157
  }
132
158
  function Z() {
133
- h.disabled || h.readonly || x.value || (x.value = !0, S.value = "", G.highlightCurrentSelection(J), v("open"), B.value && k.value.asyncData && E?.searchImmediate(""));
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(), x.value && (x.value = !1, S.value = "", C.value = -1, v("close"));
162
+ E?.cancel(), b.value && (b.value = !1, x.value = "", S.value = -1, _("close"));
137
163
  }
138
- function Ae(e) {
164
+ function $(e) {
139
165
  if (!e.disabled) {
140
166
  if (N.value) {
141
- let t = [...L.value], n = t.findIndex((t) => p(t, e.value));
142
- n >= 0 ? (t.splice(n, 1), v("deselect", e)) : (t.push(e.value), v("select", e)), Y(t), X(t), S.value = "", C.value = -1, o(() => {
143
- q(_.value), _.value?.focus({ preventScroll: !0 });
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), v("select", e), Q();
173
+ Y(e.value), X(e.value), _("select", e), Q();
148
174
  }
149
175
  }
150
- function je(e) {
151
- e?.preventDefault(), e?.stopPropagation(), N.value ? (Y([]), X([])) : (Y(null), X(null)), v("clear"), Q();
176
+ function He(e) {
177
+ e?.preventDefault(), e?.stopPropagation(), N.value ? (Y([]), X([])) : (Y(null), X(null)), _("clear"), Q();
152
178
  }
153
- function Me(e, t) {
179
+ function Ue(e, t) {
154
180
  if (t.preventDefault(), t.stopPropagation(), !N.value) return;
155
- let n = L.value.filter((t) => !p(t, e.value));
156
- Y(n), X(n), v("deselect", e), o(() => q(_.value));
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 Ne() {
184
+ function We() {
159
185
  let e = G.getHighlightedOption();
160
- e && Ae(e);
186
+ e && $(e);
161
187
  }
162
- function Pe(e) {
163
- S.value = e.target.value, v("search", S.value), x.value || Z(), G.resetHighlight(), B.value && E?.searchDebounced(S.value);
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 Fe(e) {
166
- if (!(h.disabled || h.readonly)) switch (e.key) {
191
+ function Ke(e) {
192
+ if (!(m.disabled || m.readonly)) switch (e.key) {
167
193
  case "ArrowDown":
168
- e.preventDefault(), x.value ? G.moveHighlight(1) : Z();
194
+ e.preventDefault(), b.value ? G.moveHighlight(1) : Z();
169
195
  break;
170
196
  case "ArrowUp":
171
- e.preventDefault(), x.value ? G.moveHighlight(-1) : Z();
197
+ e.preventDefault(), b.value ? G.moveHighlight(-1) : Z();
172
198
  break;
173
199
  case "Enter":
174
- e.preventDefault(), x.value ? Ne() : Z();
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
- x.value && (e.preventDefault(), G.highlightFirst());
206
+ b.value && (e.preventDefault(), G.highlightFirst());
181
207
  break;
182
208
  case "End":
183
- x.value && (e.preventDefault(), G.highlightLast());
209
+ b.value && (e.preventDefault(), G.highlightLast());
184
210
  break;
185
211
  case "Backspace":
186
- if (N.value && !S.value && R.value.length > 0) {
212
+ if (N.value && !x.value && B.value.length > 0) {
187
213
  e.preventDefault();
188
- let t = R.value.at(-1);
189
- t && Me(t, e);
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 Ie(e) {
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 pe(t, e, L.value, (e) => f(e, P.value));
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 Le() {
236
+ async function Je() {
211
237
  let e = k.value.asyncData;
212
- !e?.resolve || L.value.length === 0 || (D.value = f(await e.resolve(L.value), P.value));
238
+ !e?.resolve || z.value.length === 0 || (D.value = ge(await e.resolve(z.value), P.value));
213
239
  }
214
- let $ = a(() => {
215
- let e = l(d(he, l(j.value, [
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(ge, l(j.value, [
246
+ return K.invalidated.value ? d(Se, c(j.value, [
221
247
  "Listbox",
222
248
  "customProps",
223
249
  "invalidated"
224
250
  ])) : e;
225
- }), Re = a(() => $.value?.value), ze = a(() => {
226
- let e = !h.disabled && !h.readonly && !H.value, n = !h.disabled && !h.readonly && H.value && V.value, r = z.value && !N.value && !H.value;
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: we.value,
230
- "aria-controls": b,
231
- "aria-expanded": x.value,
232
- readonly: Ce.value,
233
- onKeydown: Fe,
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": V.value ? "list" : void 0,
236
- "aria-activedescendant": x.value ? G.activeDescendantId.value : void 0,
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
- Pe(e), q(e.target);
266
+ Ge(e), q(e.target);
241
267
  }
242
- } : { onInput: Pe }
243
- }, K.inputBind.value, u({
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
- [u(Re.value, M.value.value) ?? ""]: r
273
+ [l(Xe.value, M.value.value) ?? ""]: r
248
274
  }));
249
275
  });
250
- c(() => [
251
- x.value,
276
+ s(() => [
277
+ b.value,
252
278
  N.value,
253
- _.value
279
+ g.value
254
280
  ], () => {
255
- q(_.value);
256
- }, { immediate: !0 }), c(() => g.value, () => {
257
- Le();
258
- }, { immediate: !0 }), c(() => k.value.asyncData, (e) => {
259
- if (E?.cancel(), T.value = [], Le(), !e) {
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 = de((e) => void Ie(e), fe(e));
264
- }, { immediate: !0 }), re(() => {
289
+ E = me((e) => void qe(e), _e(e));
290
+ }, { immediate: !0 }), oe(() => {
265
291
  E?.cancel();
266
- }), ie(() => {
267
- q(_.value);
292
+ }), se(() => {
293
+ q(g.value);
268
294
  });
269
- let Be = a(() => n(K.merged.value.size));
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: x,
272
- slots: ye,
273
- hasValue: z,
330
+ open: b,
331
+ slots: v,
332
+ hasValue: je,
274
333
  multiple: N,
275
- listboxId: b,
334
+ listboxId: y,
276
335
  formField: K,
277
- isLoading: U,
278
- clearable: Se,
279
- clearBind: a(() => t({}, {}, {
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: je,
292
- removeChip: Me,
293
- triggerBind: ze,
294
- selectOption: Ae,
295
- containerRef: be,
296
- listboxProps: a(() => ({
297
- disableAutoFocus: !0,
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: H,
319
- selectedOptions: R,
320
- highlightedIndex: C,
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 { h as useSelect };
360
+ export { m as useSelect };
@@ -1,8 +1,8 @@
1
1
  import { InputHTMLAttributes, Slot, TextareaHTMLAttributes } from 'vue';
2
- import { MergeHtmlProps, SelectAsyncData, SelectModel, SelectOption, SelectOptionInput, SelectValue } from '@bridge-ui/core';
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?: SelectOptionInput[];
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;
@@ -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, ListProps } from './Components/List';
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" | "align">>;
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, ListPaddingOverrides, ListProps, } from './Components/List';
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 { ListItemAlignOverrides, ListItemClasses, ListItemCustomProps, ListItemOwnProps, ListItemProps, ListItemSlots, } from './Components/ListItem';
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 { useMenu as L } from "./Components/Menu/composables/useMenu.js";
33
- import R from "./Components/Menu/Menu.js";
34
- import z from "./Components/Listbox/Listbox.js";
35
- import B from "./Components/ListSection/ListSection.js";
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, B as ListSection, z as Listbox, R 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, L 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 };
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 };