asheeui 0.6.10 → 0.6.13

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 (39) hide show
  1. package/dist/components/accordion/Accordion.js +7 -7
  2. package/dist/components/autocomplete/Autocomplete.d.ts +5 -5
  3. package/dist/components/autocomplete/Autocomplete.d.ts.map +1 -1
  4. package/dist/components/autocomplete/Autocomplete.js +42 -41
  5. package/dist/components/carousel/Carousel.js +43 -43
  6. package/dist/components/chip/Chip.js +8 -8
  7. package/dist/components/date-picker/Calendar.d.ts +6 -1
  8. package/dist/components/date-picker/Calendar.d.ts.map +1 -1
  9. package/dist/components/date-picker/Calendar.js +30 -30
  10. package/dist/components/date-picker/DatePicker.d.ts +7 -6
  11. package/dist/components/date-picker/DatePicker.d.ts.map +1 -1
  12. package/dist/components/date-picker/DatePicker.js +166 -155
  13. package/dist/components/date-picker/date-picker-config.d.ts +12 -1
  14. package/dist/components/date-picker/date-picker-config.d.ts.map +1 -1
  15. package/dist/components/marquee/Marquee.js +22 -22
  16. package/dist/components/multi-select/MultiSelect.d.ts +5 -5
  17. package/dist/components/multi-select/MultiSelect.d.ts.map +1 -1
  18. package/dist/components/multi-select/MultiSelect.js +45 -44
  19. package/dist/components/select/Select.d.ts +5 -5
  20. package/dist/components/select/Select.d.ts.map +1 -1
  21. package/dist/components/select/Select.js +117 -114
  22. package/dist/components/select-menu/SelectMenu.d.ts +20 -11
  23. package/dist/components/select-menu/SelectMenu.d.ts.map +1 -1
  24. package/dist/components/select-menu/SelectMenu.js +146 -109
  25. package/dist/components/select-menu/select-menu-config.d.ts +8 -4
  26. package/dist/components/select-menu/select-menu-config.d.ts.map +1 -1
  27. package/dist/components/select-menu/select-menu-config.js +1 -1
  28. package/dist/components/select-menu/use-select-floating.d.ts +46 -17
  29. package/dist/components/select-menu/use-select-floating.d.ts.map +1 -1
  30. package/dist/components/select-menu/use-select-floating.js +36 -22
  31. package/dist/components/toast/ToastItem.js +30 -30
  32. package/dist/components/toast/ToastProvider.d.ts +5 -5
  33. package/dist/components/toast/ToastProvider.d.ts.map +1 -1
  34. package/dist/components/toast/ToastProvider.js +66 -66
  35. package/dist/index.d.ts +1 -0
  36. package/dist/index.d.ts.map +1 -1
  37. package/dist/theme/controller.d.ts.map +1 -1
  38. package/dist/theme/controller.js +14 -16
  39. package/package.json +3 -20
@@ -1,161 +1,198 @@
1
1
  "use client";
2
- import { jsx as a, jsxs as V } from "react/jsx-runtime";
3
- import { FloatingFocusManager as X } from "@floating-ui/react";
4
- import { useState as Y, useEffect as Z, useMemo as $ } from "react";
5
- import { createPortal as n } from "react-dom";
6
- import { CheckIcon as u } from "../../icons/CheckIcon.js";
7
- import { SearchIcon as m } from "../../icons/SearchIcon.js";
8
- import { useAsheeConfig as p } from "../../libs/context.js";
9
- import { resolveCascade as r, resolveRadiusKey as C } from "../../utils/resolve-token.js";
10
- import { Button as g } from "../button/Button.js";
11
- import { Input as P } from "../input/Input.js";
2
+ import { jsx as l, jsxs as A, Fragment as Z } from "react/jsx-runtime";
3
+ import { FloatingFocusManager as u, FloatingPortal as m } from "@floating-ui/react";
4
+ import { useState as p, useEffect as g, useMemo as C, memo as P } from "react";
5
+ import { CheckIcon as tt } from "../../icons/CheckIcon.js";
6
+ import { SearchIcon as et } from "../../icons/SearchIcon.js";
7
+ import { useAsheeConfig as lt } from "../../libs/context.js";
8
+ import { resolveCascade as a, resolveRadiusKey as ot } from "../../utils/resolve-token.js";
9
+ import { Button as rt } from "../button/Button.js";
10
+ import { Input as at } from "../input/Input.js";
12
11
  import { FALLBACK_SELECT_MENU_CONFIG as d } from "./select-menu-config.js";
13
- import { cn as tt } from "../../utils/cn.js";
14
- const lt = ({
15
- isOpen: s,
16
- context: A,
17
- floatingStyles: F,
18
- getFloatingProps: L,
19
- setFloatingRef: M,
20
- options: v = [],
21
- selectedValues: E = [],
22
- onSelectMenuOption: Q,
23
- isSearch: y = !0,
24
- searchPlaceholder: T = "Search...",
25
- searchInputName: j = "select-menu-search",
26
- searchQuery: K,
27
- onSearchChange: b,
28
- belowList: h,
29
- menuConfig: l,
12
+ import { cn as dt } from "../../utils/cn.js";
13
+ const ct = P(function({
14
+ filteredOptions: v,
15
+ selectedValues: w,
16
+ onSelectMenuOption: x,
17
+ renderOption: b,
18
+ itemVariant: I,
19
+ itemColor: i,
20
+ activeItemVariant: f,
21
+ activeItemColor: N,
22
+ radius: s,
23
+ size: S
24
+ }) {
25
+ const V = (o) => w.includes(o);
26
+ return v.length === 0 ? /* @__PURE__ */ l("div", { className: "px-3 py-4 text-xs text-foreground/70 text-center", children: "No options found" }) : /* @__PURE__ */ l(Z, { children: v.map((o) => {
27
+ const c = V(o.value);
28
+ return b ? b(o, c) : /* @__PURE__ */ A(
29
+ rt,
30
+ {
31
+ variant: c ? f : I,
32
+ color: c ? N : i,
33
+ radius: s,
34
+ size: S,
35
+ isDisabled: o.disabled,
36
+ onClick: () => x(o),
37
+ className: "w-full justify-between font-normal text-left transition-colors truncate",
38
+ children: [
39
+ /* @__PURE__ */ l("span", { children: o.label }),
40
+ c && /* @__PURE__ */ l(tt, { className: "w-3.5 h-3.5 shrink-0 ml-2" })
41
+ ]
42
+ },
43
+ String(o.value)
44
+ );
45
+ }) });
46
+ }), it = ({
47
+ isOpen: y,
48
+ floatingStyles: v,
49
+ context: w,
50
+ getFloatingProps: x,
51
+ setFloatingRef: b,
52
+ isPositioned: I = !0,
53
+ options: i = [],
54
+ selectedValues: f = [],
55
+ onSelectMenuOption: N,
56
+ isSearch: s = !0,
57
+ searchPlaceholder: S = "Search...",
58
+ searchInputName: V = "select-menu-search",
59
+ searchQuery: o,
60
+ onSearchChange: c,
61
+ belowList: k,
62
+ menuConfig: e,
30
63
  menuProps: t = {},
31
- renderOption: x,
32
- initialFocus: R,
33
- returnFocus: _
64
+ renderOption: E,
65
+ initialFocus: Q,
66
+ returnFocus: R
34
67
  }) => {
35
- const c = p(), [B, D] = Y(""), i = K ?? B, G = (e) => {
36
- b ? b(e) : D(e);
37
- }, w = r(
68
+ const h = lt(), [j, K] = p(""), n = o ?? j, _ = (r) => {
69
+ c ? c(r) : K(r);
70
+ }, z = a(
38
71
  t == null ? void 0 : t.lockScroll,
39
- l == null ? void 0 : l.lockScroll,
72
+ e == null ? void 0 : e.lockScroll,
40
73
  void 0,
41
74
  d.lockScroll
42
- ), O = r(
75
+ ), B = a(
43
76
  t == null ? void 0 : t.portal,
44
- l == null ? void 0 : l.portal,
77
+ e == null ? void 0 : e.portal,
45
78
  void 0,
46
79
  d.portal
47
- ), I = r(
80
+ ), O = a(
48
81
  t == null ? void 0 : t.portalTarget,
49
- l == null ? void 0 : l.portalTarget,
82
+ e == null ? void 0 : e.portalTarget,
50
83
  void 0,
51
84
  typeof document < "u" ? document.body : null
52
85
  );
53
- Z(() => {
54
- if (!s || !w) return;
55
- const e = document.body.style.overflow, o = document.body.style.position, J = document.body.style.width;
56
- return document.body.style.overflow = "hidden", document.body.style.position = "fixed", document.body.style.width = "100%", () => {
57
- document.body.style.overflow = e, document.body.style.position = o, document.body.style.width = J;
86
+ g(() => {
87
+ if (!y || !z) return;
88
+ const r = window.scrollY, W = document.body.style.position, $ = document.body.style.top, q = document.body.style.left, H = document.body.style.right, J = document.body.style.width, X = document.body.style.overflow;
89
+ return document.body.style.position = "fixed", document.body.style.top = `-${r}px`, document.body.style.left = "0", document.body.style.right = "0", document.body.style.width = "100%", document.body.style.overflow = "hidden", () => {
90
+ document.body.style.position = W, document.body.style.top = $, document.body.style.left = q, document.body.style.right = H, document.body.style.width = J, document.body.style.overflow = X, window.scrollTo(0, r);
58
91
  };
59
- }, [s, w]);
60
- const N = $(() => !y || !i.trim() ? v : v.filter(
61
- (e) => e.label.toLowerCase().includes(i.toLowerCase())
62
- ), [v, y, i]), U = (e) => E.includes(e), W = r(
92
+ }, [y, z]);
93
+ const Y = C(() => !s || !n.trim() ? i : i.filter(
94
+ (r) => r.label.toLowerCase().includes(n.toLowerCase())
95
+ ), [i, s, n]), D = a(
63
96
  t == null ? void 0 : t.itemVariant,
64
- l == null ? void 0 : l.itemVariant,
97
+ e == null ? void 0 : e.itemVariant,
65
98
  void 0,
66
99
  d.itemVariant
67
- ), S = r(
100
+ ), L = a(
68
101
  t == null ? void 0 : t.itemColor,
69
- l == null ? void 0 : l.itemColor,
70
- c.defaultColor,
102
+ e == null ? void 0 : e.itemColor,
103
+ h.defaultColor,
71
104
  d.itemColor
72
- ), q = r(
105
+ ), G = a(
73
106
  t == null ? void 0 : t.activeItemVariant,
74
- l == null ? void 0 : l.activeItemVariant,
75
- c.defaultVariant,
107
+ e == null ? void 0 : e.activeItemVariant,
108
+ h.defaultVariant,
76
109
  d.activeItemVariant
77
- ), H = r(
110
+ ), U = a(
78
111
  t == null ? void 0 : t.activeItemColor,
79
- l == null ? void 0 : l.activeItemColor,
80
- c.defaultColor,
112
+ e == null ? void 0 : e.activeItemColor,
113
+ h.defaultColor,
81
114
  d.activeItemColor
82
- ), f = C(
115
+ ), F = ot(
83
116
  t == null ? void 0 : t.radius,
84
- l == null ? void 0 : l.radius,
85
- c.defaultRadius,
117
+ e == null ? void 0 : e.radius,
118
+ h.defaultRadius,
86
119
  d.radius
87
- ), k = r(
120
+ ), M = a(
88
121
  t == null ? void 0 : t.size,
89
- l == null ? void 0 : l.size,
122
+ e == null ? void 0 : e.size,
90
123
  void 0,
91
124
  d.size
92
125
  );
93
- if (!s) return null;
94
- const z = /* @__PURE__ */ a(
95
- X,
126
+ if (!y) return null;
127
+ const T = /* @__PURE__ */ l(
128
+ u,
96
129
  {
97
- context: A,
130
+ context: w,
98
131
  modal: !1,
99
- initialFocus: R,
100
- returnFocus: _,
101
- children: /* @__PURE__ */ V(
132
+ initialFocus: Q,
133
+ returnFocus: R,
134
+ children: /* @__PURE__ */ A(
102
135
  "div",
103
136
  {
104
- ref: M,
105
- style: { ...F },
106
- className: tt(
107
- "z-100 w-full outline-none max-h-60 shadow-xl bg-background border border-border p-1 flex flex-col gap-0.5 overflow-y-auto scrollable-hidden",
108
- "animate-in fade-in-0 zoom-in-95 slide-in-from-top-1 duration-150 ease-out",
137
+ ref: b,
138
+ style: { ...v },
139
+ className: dt(
140
+ "z-30 w-full outline-none max-h-60 shadow-xl bg-background border border-border p-1 flex flex-col gap-0.5 overflow-y-auto scrollable-hidden",
141
+ // Explicitly disable transitions on the floating element. Floating UI
142
+ // positions this node via a `transform` written on every scroll tick
143
+ // (through floatingStyles). If any transition — global, inherited, or
144
+ // otherwise — applies to `transform` on this element, the browser eases
145
+ // toward each new position instead of snapping to it, which compounds
146
+ // under rapid scroll ticks into a visible spring/bounce effect that
147
+ // worsens with scroll speed. transition-none guarantees position
148
+ // updates apply instantly.
149
+ "transition-none",
150
+ I ? "animate-in fade-in-0 zoom-in-95 slide-in-from-top-1 duration-150 ease-out" : "invisible opacity-0 pointer-events-none",
109
151
  t == null ? void 0 : t.className
110
152
  ),
111
- ...L(),
153
+ ...x(),
112
154
  children: [
113
- y && /* @__PURE__ */ a("div", { className: "w-full p-1 mb-1 sticky top-0 z-10 border-b border-border", children: /* @__PURE__ */ a(
114
- P,
155
+ s && /* @__PURE__ */ l("div", { className: "w-full p-1 mb-1 sticky top-0 z-10 border-b border-border", children: /* @__PURE__ */ l(
156
+ at,
115
157
  {
116
- name: j,
158
+ name: V,
117
159
  type: "text",
118
160
  variant: "bordered",
119
- radius: f,
120
- color: S,
121
- size: k,
122
- value: i,
123
- onChange: (e) => G(e.target.value),
124
- startContent: /* @__PURE__ */ a(m, { className: "w-3.5 h-3.5 text-foreground/70" }),
125
- placeholder: T,
161
+ radius: F,
162
+ color: L,
163
+ size: M,
164
+ value: n,
165
+ onChange: (r) => _(r.target.value),
166
+ startContent: /* @__PURE__ */ l(et, { className: "w-3.5 h-3.5 text-foreground/70" }),
167
+ placeholder: S,
126
168
  autoFocus: !0,
127
169
  className: "w-full pl-8 h-8 text-xs bg-secondary/30 border-none focus-visible:ring-0"
128
170
  }
129
171
  ) }),
130
- N.length === 0 ? /* @__PURE__ */ a("div", { className: "px-3 py-4 text-xs text-foreground/70 text-center", children: "No options found" }) : N.map((e) => {
131
- const o = U(e.value);
132
- return x ? x(e, o) : /* @__PURE__ */ V(
133
- g,
134
- {
135
- variant: o ? q : W,
136
- color: o ? H : S,
137
- radius: f,
138
- size: k,
139
- isDisabled: e.disabled,
140
- onClick: () => Q(e),
141
- className: "w-full justify-between font-normal text-left transition-colors truncate",
142
- children: [
143
- /* @__PURE__ */ a("span", { children: e.label }),
144
- o && /* @__PURE__ */ a(u, { className: "w-3.5 h-3.5 shrink-0 ml-2" })
145
- ]
146
- },
147
- String(e.value)
148
- );
149
- }),
150
- h && /* @__PURE__ */ a("div", { className: "border-t border-border pt-1 mt-1", children: h })
172
+ /* @__PURE__ */ l(
173
+ ct,
174
+ {
175
+ filteredOptions: Y,
176
+ selectedValues: f,
177
+ onSelectMenuOption: N,
178
+ renderOption: E,
179
+ itemVariant: D,
180
+ itemColor: L,
181
+ activeItemVariant: G,
182
+ activeItemColor: U,
183
+ radius: F,
184
+ size: M
185
+ }
186
+ ),
187
+ k && /* @__PURE__ */ l("div", { className: "border-t border-border pt-1 mt-1", children: k })
151
188
  ]
152
189
  }
153
190
  )
154
191
  }
155
192
  );
156
- return O && I ? n(z, I) : z;
193
+ return B ? /* @__PURE__ */ l(m, { root: O, children: T }) : T;
157
194
  };
158
- lt.displayName = "SelectMenu";
195
+ it.displayName = "SelectMenu";
159
196
  export {
160
- lt as SelectMenu
197
+ it as SelectMenu
161
198
  };
@@ -74,18 +74,22 @@ export interface MenuConfig {
74
74
  activeItemColor?: Color;
75
75
  /**
76
76
  * Whether to lock body scroll when the dropdown is open.
77
- * When true, the page behind the dropdown cannot scroll.
78
- * This prevents the page from scrolling while interacting with the dropdown.
77
+ * When true, the page behind the dropdown cannot scroll, using
78
+ * scroll-position-compensated `position: fixed` on `<body>` so the
79
+ * page doesn't jump. This prevents the page from scrolling while
80
+ * interacting with the dropdown.
79
81
  *
80
- * @default false
82
+ * @default true
81
83
  */
82
84
  lockScroll?: boolean;
83
85
  /**
84
- * Whether to render the menu in a React portal.
86
+ * Whether to render the menu through Floating UI's `FloatingPortal`.
85
87
  * When true, the menu is rendered at the document body level.
86
88
  * Defaults to true. This is typically controlled by the parent
87
89
  * component (Select, MultiSelect, Autocomplete) via their own
88
90
  * config or props.
91
+ *
92
+ * @see FloatingPortal - https://floating-ui.com/docs/FloatingPortal
89
93
  */
90
94
  portal?: boolean;
91
95
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"select-menu-config.d.ts","sourceRoot":"","sources":["../../../src/components/select-menu/select-menu-config.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEjE;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IAEvB;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB;;;OAGG;IACH,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED;;;GAGG;AACH,MAAM,WAAW,UAAU;IACzB;;;;;OAKG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;;;;OAKG;IACH,IAAI,CAAC,EAAE,IAAI,CAAC;IAEZ;;;;;OAKG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IAEtB;;;;;OAKG;IACH,SAAS,CAAC,EAAE,KAAK,CAAC;IAElB;;;;;OAKG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAE5B;;;;;OAKG;IACH,eAAe,CAAC,EAAE,KAAK,CAAC;IAExB;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB;;;;;;OAMG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IAEjB;;;;OAIG;IACH,YAAY,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC;CACnC;AAED;;;;GAIG;AACH,eAAO,MAAM,2BAA2B;YACtB,MAAM;UACR,IAAI;iBACM,OAAO;eACP,KAAK;uBACC,OAAO;qBACP,KAAK;;;CAGpC,CAAC"}
1
+ {"version":3,"file":"select-menu-config.d.ts","sourceRoot":"","sources":["../../../src/components/select-menu/select-menu-config.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEjE;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IAEvB;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB;;;OAGG;IACH,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED;;;GAGG;AACH,MAAM,WAAW,UAAU;IACzB;;;;;OAKG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;;;;OAKG;IACH,IAAI,CAAC,EAAE,IAAI,CAAC;IAEZ;;;;;OAKG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IAEtB;;;;;OAKG;IACH,SAAS,CAAC,EAAE,KAAK,CAAC;IAElB;;;;;OAKG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAE5B;;;;;OAKG;IACH,eAAe,CAAC,EAAE,KAAK,CAAC;IAExB;;;;;;;;OAQG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB;;;;;;;;OAQG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IAEjB;;;;OAIG;IACH,YAAY,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC;CACnC;AAED;;;;GAIG;AACH,eAAO,MAAM,2BAA2B;YACtB,MAAM;UACR,IAAI;iBACM,OAAO;eACP,KAAK;uBACC,OAAO;qBACP,KAAK;;;CAGpC,CAAC"}
@@ -6,7 +6,7 @@ const t = {
6
6
  itemColor: "primary",
7
7
  activeItemVariant: "faded",
8
8
  activeItemColor: "primary",
9
- lockScroll: !1,
9
+ lockScroll: !0,
10
10
  portal: !0
11
11
  };
12
12
  export {
@@ -1,7 +1,8 @@
1
- import { Placement, UseFloatingReturn } from '@floating-ui/react';
1
+ import { UseInteractionsReturn, Placement, useFloating } from '@floating-ui/react';
2
2
  /**
3
3
  * Configuration options for the useSelectFloating hook.
4
- * Controls the floating element's behavior, positioning, and size.
4
+ * Controls the floating element's behavior, positioning, size, and
5
+ * interaction wiring (click-to-open, dismiss, and ARIA role).
5
6
  */
6
7
  export interface UseSelectFloatingProps {
7
8
  /**
@@ -16,7 +17,8 @@ export interface UseSelectFloatingProps {
16
17
  onOpenChange: (open: boolean) => void;
17
18
  /**
18
19
  * Whether the floating element is disabled.
19
- * When true, the floating element does not open.
20
+ * When true, the floating element does not open and click interaction
21
+ * is disabled.
20
22
  *
21
23
  * @default false
22
24
  */
@@ -48,15 +50,39 @@ export interface UseSelectFloatingProps {
48
50
  * @default true
49
51
  */
50
52
  matchReferenceWidth?: boolean;
53
+ /**
54
+ * ARIA role applied to the floating element via useRole.
55
+ * "listbox" fits Select/MultiSelect/Autocomplete; a component like
56
+ * DatePicker reusing this hook can pass "dialog" instead.
57
+ *
58
+ * @default "listbox"
59
+ */
60
+ role?: "listbox" | "menu" | "dialog" | "tooltip" | "grid" | "tree";
61
+ }
62
+ /**
63
+ * Return value of useSelectFloating. Combines Floating UI's positioning
64
+ * context with the resolved interaction prop-getters, so consumers don't
65
+ * need to wire useClick/useDismiss/useRole/useInteractions themselves.
66
+ */
67
+ export interface UseSelectFloatingReturn<T extends HTMLElement> {
68
+ refs: ReturnType<typeof useFloating<T>>["refs"];
69
+ context: ReturnType<typeof useFloating<T>>["context"];
70
+ floatingStyles: React.CSSProperties;
71
+ isPositioned: boolean;
72
+ getReferenceProps: UseInteractionsReturn["getReferenceProps"];
73
+ getFloatingProps: UseInteractionsReturn["getFloatingProps"];
51
74
  }
52
75
  /**
53
- * Shared Floating UI positioning hook for dropdowns and menus.
54
- * Generic `T` allows passing `HTMLButtonElement`, `HTMLInputElement`, etc.
76
+ * Shared Floating UI positioning and interaction hook for dropdowns and
77
+ * menus. Generic `T` allows passing `HTMLButtonElement`, `HTMLInputElement`,
78
+ * etc.
55
79
  *
56
80
  * This hook configures Floating UI with sensible defaults for dropdown
57
- * components. It handles automatic position updates, viewport edge detection
58
- * via flip and shift middleware, and optional width matching of the
59
- * reference element.
81
+ * components: viewport edge detection via flip and shift middleware,
82
+ * optional width matching of the reference element, and the standard
83
+ * click-to-open / dismiss / ARIA role interaction set via useInteractions.
84
+ * Consumers get back ready-to-spread `getReferenceProps`/`getFloatingProps`
85
+ * instead of wiring useClick/useDismiss/useRole themselves.
60
86
  *
61
87
  * @param props - Configuration options for the floating element.
62
88
  * @param props.isOpen - Whether the floating element is open.
@@ -66,21 +92,24 @@ export interface UseSelectFloatingProps {
66
92
  * @param props.offsetDistance - Distance from reference in pixels. Defaults to 4.
67
93
  * @param props.padding - Viewport padding for shift middleware. Defaults to 8.
68
94
  * @param props.matchReferenceWidth - Whether to match reference width. Defaults to true.
69
- * @returns The Floating UI context including refs, styles, and middleware.
95
+ * @param props.role - ARIA role for the floating element. Defaults to "listbox".
96
+ * @returns Floating UI refs/context/styles plus `isPositioned` and the
97
+ * resolved `getReferenceProps`/`getFloatingProps` prop-getters.
70
98
  *
71
99
  * @example
72
100
  * ```tsx
73
- * const { refs, floatingStyles, context } = useSelectFloating({
74
- * isOpen,
75
- * onOpenChange: setIsOpen,
76
- * disabled: props.disabled,
77
- * });
101
+ * const { refs, context, floatingStyles, getReferenceProps, getFloatingProps } =
102
+ * useSelectFloating({
103
+ * isOpen,
104
+ * onOpenChange: setIsOpen,
105
+ * disabled: props.disabled,
106
+ * });
78
107
  *
79
108
  * return (
80
109
  * <>
81
- * <button ref={refs.setReference}>Toggle</button>
110
+ * <button ref={refs.setReference} {...getReferenceProps()}>Toggle</button>
82
111
  * {isOpen && (
83
- * <div ref={refs.setFloating} style={floatingStyles}>
112
+ * <div ref={refs.setFloating} style={floatingStyles} {...getFloatingProps()}>
84
113
  * Content
85
114
  * </div>
86
115
  * )}
@@ -91,5 +120,5 @@ export interface UseSelectFloatingProps {
91
120
  * @see useFloating - The underlying Floating UI hook.
92
121
  * @see Select - The select component that uses this hook.
93
122
  */
94
- export declare function useSelectFloating<T extends HTMLElement = HTMLElement>({ isOpen, onOpenChange, disabled, placement, offsetDistance, padding, matchReferenceWidth, }: UseSelectFloatingProps): UseFloatingReturn<T>;
123
+ export declare function useSelectFloating<T extends HTMLElement = HTMLElement>({ isOpen, onOpenChange, disabled, placement, offsetDistance, padding, matchReferenceWidth, role, }: UseSelectFloatingProps): UseSelectFloatingReturn<T>;
95
124
  //# sourceMappingURL=use-select-floating.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"use-select-floating.d.ts","sourceRoot":"","sources":["../../../src/components/select-menu/use-select-floating.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,EAKL,KAAK,SAAS,EAEd,KAAK,iBAAiB,EAEvB,MAAM,oBAAoB,CAAC;AAE5B;;;GAGG;AACH,MAAM,WAAW,sBAAsB;IACrC;;;OAGG;IACH,MAAM,EAAE,OAAO,CAAC;IAEhB;;;OAGG;IACH,YAAY,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IAEtC;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB;;;;;OAKG;IACH,SAAS,CAAC,EAAE,SAAS,CAAC;IAEtB;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;;;;OAKG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,WAAW,GAAG,WAAW,EAAE,EACrE,MAAM,EACN,YAAY,EACZ,QAAgB,EAChB,SAA0B,EAC1B,cAAkB,EAClB,OAAW,EACX,mBAA0B,GAC3B,EAAE,sBAAsB,GAAG,iBAAiB,CAAC,CAAC,CAAC,CAsB/C"}
1
+ {"version":3,"file":"use-select-floating.d.ts","sourceRoot":"","sources":["../../../src/components/select-menu/use-select-floating.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAChE,OAAO,EAIL,KAAK,SAAS,EAKd,WAAW,EAGZ,MAAM,oBAAoB,CAAC;AAE5B;;;;GAIG;AACH,MAAM,WAAW,sBAAsB;IACrC;;;OAGG;IACH,MAAM,EAAE,OAAO,CAAC;IAEhB;;;OAGG;IACH,YAAY,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IAEtC;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB;;;;;OAKG;IACH,SAAS,CAAC,EAAE,SAAS,CAAC;IAEtB;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;;;;OAKG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAE9B;;;;;;OAMG;IACH,IAAI,CAAC,EAAE,SAAS,GAAG,MAAM,GAAG,QAAQ,GAAG,SAAS,GAAG,MAAM,GAAG,MAAM,CAAC;CACpE;AAED;;;;GAIG;AACH,MAAM,WAAW,uBAAuB,CAAC,CAAC,SAAS,WAAW;IAC5D,IAAI,EAAE,UAAU,CAAC,OAAO,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;IAChD,OAAO,EAAE,UAAU,CAAC,OAAO,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;IACtD,cAAc,EAAE,KAAK,CAAC,aAAa,CAAC;IACpC,YAAY,EAAE,OAAO,CAAC;IACtB,iBAAiB,EAAE,qBAAqB,CAAC,mBAAmB,CAAC,CAAC;IAC9D,gBAAgB,EAAE,qBAAqB,CAAC,kBAAkB,CAAC,CAAC;CAC7D;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,WAAW,GAAG,WAAW,EAAE,EACrE,MAAM,EACN,YAAY,EACZ,QAAgB,EAChB,SAA0B,EAC1B,cAAkB,EAClB,OAAW,EACX,mBAA0B,EAC1B,IAAgB,GACjB,EAAE,sBAAsB,GAAG,uBAAuB,CAAC,CAAC,CAAC,CA2CrD"}
@@ -1,36 +1,50 @@
1
1
  "use client";
2
- import { useFloating as r, autoUpdate as f, offset as u, flip as g, shift as d, size as c } from "@floating-ui/react";
3
- function m({
4
- isOpen: i,
5
- onOpenChange: n,
2
+ import { useFloating as h, autoUpdate as y, offset as w, flip as P, shift as b, size as C, useClick as F, useDismiss as R, useRole as S, useInteractions as k } from "@floating-ui/react";
3
+ function O({
4
+ isOpen: n,
5
+ onOpenChange: l,
6
6
  disabled: o = !1,
7
7
  placement: a = "bottom-start",
8
- offsetDistance: l = 4,
9
- padding: s = 8,
10
- matchReferenceWidth: p = !0
8
+ offsetDistance: c = 4,
9
+ padding: r = 8,
10
+ matchReferenceWidth: f = !0,
11
+ role: g = "listbox"
11
12
  }) {
12
- return r({
13
- open: i,
14
- onOpenChange: (e) => !o && n(e),
13
+ const e = h({
14
+ open: n,
15
+ onOpenChange: (s) => !o && l(s),
15
16
  placement: a,
16
- whileElementsMounted: f,
17
+ strategy: "fixed",
18
+ whileElementsMounted: y,
17
19
  middleware: [
18
- u(l),
19
- g(),
20
- d({ padding: s }),
21
- c({
22
- apply({ availableHeight: e, elements: t }) {
23
- Object.assign(t.floating.style, {
24
- maxHeight: `${e}px`,
25
- ...p && {
26
- width: `${t.reference.getBoundingClientRect().width}px`
20
+ w(c),
21
+ P(),
22
+ b({ padding: r }),
23
+ C({
24
+ apply({ availableHeight: s, elements: i }) {
25
+ Object.assign(i.floating.style, {
26
+ maxHeight: `${s}px`,
27
+ ...f && {
28
+ width: `${i.reference.getBoundingClientRect().width}px`
27
29
  }
28
30
  });
29
31
  }
30
32
  })
31
33
  ]
32
- });
34
+ }), { context: t } = e, u = F(t, { enabled: !o }), p = R(t), d = S(t, { role: g }), { getReferenceProps: m, getFloatingProps: x } = k([
35
+ u,
36
+ p,
37
+ d
38
+ ]);
39
+ return {
40
+ refs: e.refs,
41
+ context: t,
42
+ floatingStyles: e.floatingStyles,
43
+ isPositioned: e.isPositioned,
44
+ getReferenceProps: m,
45
+ getFloatingProps: x
46
+ };
33
47
  }
34
48
  export {
35
- m as useSelectFloating
49
+ O as useSelectFloating
36
50
  };