asheeui 0.6.12 → 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.
@@ -1,189 +1,198 @@
1
1
  "use client";
2
- import { jsx as l, jsxs as Q, Fragment as J } from "react/jsx-runtime";
3
- import { FloatingFocusManager as X, FloatingPortal as Y } from "@floating-ui/react";
4
- import { useState as Z, useEffect as $, useMemo as u, memo as m } from "react";
5
- import { CheckIcon as p } from "../../icons/CheckIcon.js";
6
- import { SearchIcon as C } from "../../icons/SearchIcon.js";
7
- import { useAsheeConfig as g } from "../../libs/context.js";
8
- import { resolveCascade as o, resolveRadiusKey as P } from "../../utils/resolve-token.js";
9
- import { Button as tt } from "../button/Button.js";
10
- import { Input as et } from "../input/Input.js";
11
- import { FALLBACK_SELECT_MENU_CONFIG as c } from "./select-menu-config.js";
12
- import { cn as lt } from "../../utils/cn.js";
13
- const rt = m(function({
14
- filteredOptions: y,
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";
11
+ import { FALLBACK_SELECT_MENU_CONFIG as d } from "./select-menu-config.js";
12
+ import { cn as dt } from "../../utils/cn.js";
13
+ const ct = P(function({
14
+ filteredOptions: v,
15
15
  selectedValues: w,
16
- onSelectMenuOption: I,
16
+ onSelectMenuOption: x,
17
17
  renderOption: b,
18
- itemVariant: N,
18
+ itemVariant: I,
19
19
  itemColor: i,
20
- activeItemVariant: S,
21
- activeItemColor: V,
20
+ activeItemVariant: f,
21
+ activeItemColor: N,
22
22
  radius: s,
23
- size: f
23
+ size: S
24
24
  }) {
25
- const k = (r) => w.includes(r);
26
- return y.length === 0 ? /* @__PURE__ */ l("div", { className: "px-3 py-4 text-xs text-foreground/70 text-center", children: "No options found" }) : /* @__PURE__ */ l(J, { children: y.map((r) => {
27
- const d = k(r.value);
28
- return b ? b(r, d) : /* @__PURE__ */ Q(
29
- tt,
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
30
  {
31
- variant: d ? S : N,
32
- color: d ? V : i,
31
+ variant: c ? f : I,
32
+ color: c ? N : i,
33
33
  radius: s,
34
- size: f,
35
- isDisabled: r.disabled,
36
- onClick: () => I(r),
34
+ size: S,
35
+ isDisabled: o.disabled,
36
+ onClick: () => x(o),
37
37
  className: "w-full justify-between font-normal text-left transition-colors truncate",
38
38
  children: [
39
- /* @__PURE__ */ l("span", { children: r.label }),
40
- d && /* @__PURE__ */ l(p, { className: "w-3.5 h-3.5 shrink-0 ml-2" })
39
+ /* @__PURE__ */ l("span", { children: o.label }),
40
+ c && /* @__PURE__ */ l(tt, { className: "w-3.5 h-3.5 shrink-0 ml-2" })
41
41
  ]
42
42
  },
43
- String(r.value)
43
+ String(o.value)
44
44
  );
45
45
  }) });
46
- }), at = ({
47
- isOpen: v,
48
- context: y,
49
- floatingStyles: w,
50
- getFloatingProps: I,
46
+ }), it = ({
47
+ isOpen: y,
48
+ floatingStyles: v,
49
+ context: w,
50
+ getFloatingProps: x,
51
51
  setFloatingRef: b,
52
- isPositioned: N = !0,
52
+ isPositioned: I = !0,
53
53
  options: i = [],
54
- selectedValues: S = [],
55
- onSelectMenuOption: V,
54
+ selectedValues: f = [],
55
+ onSelectMenuOption: N,
56
56
  isSearch: s = !0,
57
- searchPlaceholder: f = "Search...",
58
- searchInputName: k = "select-menu-search",
59
- searchQuery: r,
60
- onSearchChange: d,
61
- belowList: z,
57
+ searchPlaceholder: S = "Search...",
58
+ searchInputName: V = "select-menu-search",
59
+ searchQuery: o,
60
+ onSearchChange: c,
61
+ belowList: k,
62
62
  menuConfig: e,
63
63
  menuProps: t = {},
64
- renderOption: T,
65
- initialFocus: j,
66
- returnFocus: K
64
+ renderOption: E,
65
+ initialFocus: Q,
66
+ returnFocus: R
67
67
  }) => {
68
- const h = g(), [R, _] = Z(""), x = r ?? R, n = (a) => {
69
- d ? d(a) : _(a);
70
- }, F = o(
68
+ const h = lt(), [j, K] = p(""), n = o ?? j, _ = (r) => {
69
+ c ? c(r) : K(r);
70
+ }, z = a(
71
71
  t == null ? void 0 : t.lockScroll,
72
72
  e == null ? void 0 : e.lockScroll,
73
73
  void 0,
74
- c.lockScroll
75
- ), B = o(
74
+ d.lockScroll
75
+ ), B = a(
76
76
  t == null ? void 0 : t.portal,
77
77
  e == null ? void 0 : e.portal,
78
78
  void 0,
79
- c.portal
80
- ), O = o(
79
+ d.portal
80
+ ), O = a(
81
81
  t == null ? void 0 : t.portalTarget,
82
82
  e == null ? void 0 : e.portalTarget,
83
83
  void 0,
84
84
  typeof document < "u" ? document.body : null
85
85
  );
86
- $(() => {
87
- if (!v || !F) return;
88
- const a = document.body.style.overflow, q = document.body.style.position, H = document.body.style.width;
89
- return document.body.style.overflow = "hidden", document.body.style.position = "fixed", document.body.style.width = "100%", () => {
90
- document.body.style.overflow = a, document.body.style.position = q, document.body.style.width = H;
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);
91
91
  };
92
- }, [v, F]);
93
- const D = u(() => !s || !x.trim() ? i : i.filter(
94
- (a) => a.label.toLowerCase().includes(x.toLowerCase())
95
- ), [i, s, x]), G = o(
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(
96
96
  t == null ? void 0 : t.itemVariant,
97
97
  e == null ? void 0 : e.itemVariant,
98
98
  void 0,
99
- c.itemVariant
100
- ), L = o(
99
+ d.itemVariant
100
+ ), L = a(
101
101
  t == null ? void 0 : t.itemColor,
102
102
  e == null ? void 0 : e.itemColor,
103
103
  h.defaultColor,
104
- c.itemColor
105
- ), U = o(
104
+ d.itemColor
105
+ ), G = a(
106
106
  t == null ? void 0 : t.activeItemVariant,
107
107
  e == null ? void 0 : e.activeItemVariant,
108
108
  h.defaultVariant,
109
- c.activeItemVariant
110
- ), W = o(
109
+ d.activeItemVariant
110
+ ), U = a(
111
111
  t == null ? void 0 : t.activeItemColor,
112
112
  e == null ? void 0 : e.activeItemColor,
113
113
  h.defaultColor,
114
- c.activeItemColor
115
- ), M = P(
114
+ d.activeItemColor
115
+ ), F = ot(
116
116
  t == null ? void 0 : t.radius,
117
117
  e == null ? void 0 : e.radius,
118
118
  h.defaultRadius,
119
- c.radius
120
- ), A = o(
119
+ d.radius
120
+ ), M = a(
121
121
  t == null ? void 0 : t.size,
122
122
  e == null ? void 0 : e.size,
123
123
  void 0,
124
- c.size
124
+ d.size
125
125
  );
126
- if (!v) return null;
127
- const E = /* @__PURE__ */ l(
128
- X,
126
+ if (!y) return null;
127
+ const T = /* @__PURE__ */ l(
128
+ u,
129
129
  {
130
- context: y,
130
+ context: w,
131
131
  modal: !1,
132
- initialFocus: j,
133
- returnFocus: K,
134
- children: /* @__PURE__ */ Q(
132
+ initialFocus: Q,
133
+ returnFocus: R,
134
+ children: /* @__PURE__ */ A(
135
135
  "div",
136
136
  {
137
137
  ref: b,
138
- style: { ...w },
139
- className: lt(
138
+ style: { ...v },
139
+ className: dt(
140
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
- N ? "animate-in fade-in-0 zoom-in-95 slide-in-from-top-1 duration-150 ease-out" : "invisible opacity-0 pointer-events-none",
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",
142
151
  t == null ? void 0 : t.className
143
152
  ),
144
- ...I(),
153
+ ...x(),
145
154
  children: [
146
155
  s && /* @__PURE__ */ l("div", { className: "w-full p-1 mb-1 sticky top-0 z-10 border-b border-border", children: /* @__PURE__ */ l(
147
- et,
156
+ at,
148
157
  {
149
- name: k,
158
+ name: V,
150
159
  type: "text",
151
160
  variant: "bordered",
152
- radius: M,
161
+ radius: F,
153
162
  color: L,
154
- size: A,
155
- value: x,
156
- onChange: (a) => n(a.target.value),
157
- startContent: /* @__PURE__ */ l(C, { className: "w-3.5 h-3.5 text-foreground/70" }),
158
- placeholder: f,
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,
159
168
  autoFocus: !0,
160
169
  className: "w-full pl-8 h-8 text-xs bg-secondary/30 border-none focus-visible:ring-0"
161
170
  }
162
171
  ) }),
163
172
  /* @__PURE__ */ l(
164
- rt,
173
+ ct,
165
174
  {
166
- filteredOptions: D,
167
- selectedValues: S,
168
- onSelectMenuOption: V,
169
- renderOption: T,
170
- itemVariant: G,
175
+ filteredOptions: Y,
176
+ selectedValues: f,
177
+ onSelectMenuOption: N,
178
+ renderOption: E,
179
+ itemVariant: D,
171
180
  itemColor: L,
172
- activeItemVariant: U,
173
- activeItemColor: W,
174
- radius: M,
175
- size: A
181
+ activeItemVariant: G,
182
+ activeItemColor: U,
183
+ radius: F,
184
+ size: M
176
185
  }
177
186
  ),
178
- z && /* @__PURE__ */ l("div", { className: "border-t border-border pt-1 mt-1", children: z })
187
+ k && /* @__PURE__ */ l("div", { className: "border-t border-border pt-1 mt-1", children: k })
179
188
  ]
180
189
  }
181
190
  )
182
191
  }
183
192
  );
184
- return B ? /* @__PURE__ */ l(Y, { root: O, children: E }) : E;
193
+ return B ? /* @__PURE__ */ l(m, { root: O, children: T }) : T;
185
194
  };
186
- at.displayName = "SelectMenu";
195
+ it.displayName = "SelectMenu";
187
196
  export {
188
- at as SelectMenu
197
+ it as SelectMenu
189
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,17 +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. Positioning uses `strategy: "fixed"` with Floating
60
- * UI's event-driven `autoUpdate` tracking so portaled menus stay aligned
61
- * while the page scrolls without paying per-frame re-render cost.
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.
62
86
  *
63
87
  * @param props - Configuration options for the floating element.
64
88
  * @param props.isOpen - Whether the floating element is open.
@@ -68,22 +92,24 @@ export interface UseSelectFloatingProps {
68
92
  * @param props.offsetDistance - Distance from reference in pixels. Defaults to 4.
69
93
  * @param props.padding - Viewport padding for shift middleware. Defaults to 8.
70
94
  * @param props.matchReferenceWidth - Whether to match reference width. Defaults to true.
71
- * @returns The Floating UI context including refs, styles, middleware, and
72
- * the `isPositioned` flag for gating initial-render visibility.
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.
73
98
  *
74
99
  * @example
75
100
  * ```tsx
76
- * const { refs, floatingStyles, context } = useSelectFloating({
77
- * isOpen,
78
- * onOpenChange: setIsOpen,
79
- * disabled: props.disabled,
80
- * });
101
+ * const { refs, context, floatingStyles, getReferenceProps, getFloatingProps } =
102
+ * useSelectFloating({
103
+ * isOpen,
104
+ * onOpenChange: setIsOpen,
105
+ * disabled: props.disabled,
106
+ * });
81
107
  *
82
108
  * return (
83
109
  * <>
84
- * <button ref={refs.setReference}>Toggle</button>
110
+ * <button ref={refs.setReference} {...getReferenceProps()}>Toggle</button>
85
111
  * {isOpen && (
86
- * <div ref={refs.setFloating} style={floatingStyles}>
112
+ * <div ref={refs.setFloating} style={floatingStyles} {...getFloatingProps()}>
87
113
  * Content
88
114
  * </div>
89
115
  * )}
@@ -94,5 +120,5 @@ export interface UseSelectFloatingProps {
94
120
  * @see useFloating - The underlying Floating UI hook.
95
121
  * @see Select - The select component that uses this hook.
96
122
  */
97
- 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>;
98
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;;;;;;;;;GASG;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;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,CA6B/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,43 +1,50 @@
1
1
  "use client";
2
- import { useFloating as f, autoUpdate as p, offset as g, flip as u, 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: r = !0
8
+ offsetDistance: c = 4,
9
+ padding: r = 8,
10
+ matchReferenceWidth: f = !0,
11
+ role: g = "listbox"
11
12
  }) {
12
- return f({
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
17
  strategy: "fixed",
17
- // Event-driven tracking (ancestorScroll + ancestorResize, both on by
18
- // default) is sufficient to keep a fixed-strategy floating element
19
- // aligned during scroll, and far cheaper than polling every animation
20
- // frame. animationFrame:true doesn't fix scroll lag on its own — the
21
- // actual cost was re-rendering the option list on every tick; see
22
- // SelectMenuOptionsList in SelectMenu.tsx.
23
- whileElementsMounted: p,
18
+ whileElementsMounted: y,
24
19
  middleware: [
25
- g(l),
26
- u(),
27
- d({ padding: s }),
28
- c({
29
- apply({ availableHeight: e, elements: t }) {
30
- Object.assign(t.floating.style, {
31
- maxHeight: `${e}px`,
32
- ...r && {
33
- 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`
34
29
  }
35
30
  });
36
31
  }
37
32
  })
38
33
  ]
39
- });
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
+ };
40
47
  }
41
48
  export {
42
- m as useSelectFloating
49
+ O as useSelectFloating
43
50
  };
@@ -1 +1 @@
1
- {"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../../src/theme/controller.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEzC;;;;GAIG;AACH,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG,QAAQ,CAAC;AAElD;;GAEG;AACH,eAAO,MAAM,iBAAiB,gBAAgB,CAAC;AAa/C;;GAEG;AACH,KAAK,QAAQ,GAAG,MAAM,IAAI,CAAC;AAE3B;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;;OAIG;IACH,YAAY,EAAE,cAAc,CAAC;IAE7B;;;;OAIG;IACH,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;CAC3B;AAED;;;;;;GAMG;AACH,cAA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;;;;;OAKG;IACH,OAAO,CAAC,OAAO;IAKf;;;;;;OAMG;IACH,OAAO,CAAC,cAAc;CA+BvB;AAED;;;;GAIG;AACH,eAAO,MAAM,eAAe,iBAAwB,CAAC"}
@@ -1,8 +1,8 @@
1
1
  "use client";
2
2
  var r = Object.defineProperty;
3
- var c = (n, e, t) => e in n ? r(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
4
- var s = (n, e, t) => c(n, typeof e != "symbol" ? e + "" : e, t);
5
- const a = "ashee-theme", d = "(prefers-color-scheme: dark)", h = "theme-";
3
+ var d = (n, e, t) => e in n ? r(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
4
+ var s = (n, e, t) => d(n, typeof e != "symbol" ? e + "" : e, t);
5
+ const o = "ashee-theme", c = "(prefers-color-scheme: dark)", h = "theme-";
6
6
  class m {
7
7
  constructor() {
8
8
  /**
@@ -63,7 +63,7 @@ class m {
63
63
  */
64
64
  s(this, "setTheme", (e) => {
65
65
  const t = this.sanitize(e);
66
- this.selection = t, typeof window < "u" && window.localStorage.setItem(a, t), this.applySelection(), this.listeners.forEach((i) => {
66
+ this.selection = t, typeof window < "u" && window.localStorage.setItem(o, t), this.applySelection(), this.listeners.forEach((i) => {
67
67
  i();
68
68
  });
69
69
  });
@@ -101,7 +101,7 @@ class m {
101
101
  e();
102
102
  }));
103
103
  });
104
- typeof window > "u" || (this.mediaQuery = window.matchMedia(d), this.mediaQuery.addEventListener("change", this.handleSystemChange));
104
+ typeof window > "u" || (this.mediaQuery = window.matchMedia(c), this.mediaQuery.addEventListener("change", this.handleSystemChange));
105
105
  }
106
106
  /**
107
107
  * Seeds the controller with the resolved theme config and applies the theme.
@@ -112,20 +112,18 @@ class m {
112
112
  * - Never writes to storage (only `setTheme` persists user intent).
113
113
  */
114
114
  configure({ defaultTheme: e, themes: t }) {
115
- if (console.log("[Theme] configure called with:", { defaultTheme: e, themes: t }), this.defaultTheme = e, this.availableThemes = t, typeof window > "u") {
115
+ if (this.defaultTheme = e, this.availableThemes = t, typeof window > "u") {
116
116
  console.log(
117
117
  "[Theme] Running in non-browser environment, skipping localStorage operations."
118
118
  );
119
119
  return;
120
120
  }
121
- const i = window.localStorage.getItem(a);
122
- console.log("[Theme] Retrieved from localStorage:", i);
123
- const l = i !== null && this.isValid(i);
124
- console.log("[Theme] Is stored theme valid?", l), l || i !== null && (console.log(
121
+ const i = window.localStorage.getItem(o), l = i !== null && this.isValid(i);
122
+ l || i !== null && (console.log(
125
123
  "[Theme] Invalid stored theme, removing from localStorage."
126
- ), window.localStorage.removeItem(a)), this.selection = l ? i : e, console.log("[Theme] Final selection:", this.selection), this.applySelection(), console.log("[Theme] Applied selection."), this.listeners.forEach((o) => {
127
- o();
128
- }), console.log("[Theme] Notified all listeners.");
124
+ ), window.localStorage.removeItem(o)), this.selection = l ? i : e, this.applySelection(), this.listeners.forEach((a) => {
125
+ a();
126
+ });
129
127
  }
130
128
  /**
131
129
  * Validates a theme selection and returns a valid fallback if necessary.
@@ -169,13 +167,13 @@ class m {
169
167
  let t = this.resolve(e);
170
168
  if (this.availableThemes.length > 0 && !this.availableThemes.includes(t) && (t = this.availableThemes.includes(this.defaultTheme) ? this.defaultTheme : this.availableThemes[0]), this.resolved = t, typeof document > "u") return;
171
169
  const i = document.documentElement, l = `${h}${t}`;
172
- for (const o of Array.from(i.classList))
173
- o.startsWith(h) && i.classList.remove(o);
170
+ for (const a of Array.from(i.classList))
171
+ a.startsWith(h) && i.classList.remove(a);
174
172
  i.classList.add(l);
175
173
  }
176
174
  }
177
175
  const f = new m();
178
176
  export {
179
- a as THEME_STORAGE_KEY,
177
+ o as THEME_STORAGE_KEY,
180
178
  f as themeController
181
179
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "asheeui",
3
- "version": "0.6.12",
3
+ "version": "0.6.13",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",