@hydrateless/react 0.8.0 → 0.9.0

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 (4) hide show
  1. package/README.md +128 -19
  2. package/dist/index.d.ts +363 -184
  3. package/dist/index.js +800 -621
  4. package/package.json +4 -4
package/dist/index.js CHANGED
@@ -1,254 +1,341 @@
1
+ 'use client';
2
+
3
+ // src/useEnhancer.ts
4
+ import { useEffect, useRef as useRef2 } from "react";
5
+
6
+ // src/internal/useLatest.ts
7
+ import { useRef } from "react";
8
+ function useLatest(value) {
9
+ const ref = useRef(value);
10
+ ref.current = value;
11
+ return ref;
12
+ }
13
+
1
14
  // src/useEnhancer.ts
2
- import { useEffect, useRef } from "react";
3
- function useEnhancer(enhance, deps = []) {
4
- const ref = useRef(null);
5
- const api = useRef(null);
15
+ function useEnhancer(ref, enhancer, options, deps = []) {
16
+ const api = useRef2(null);
17
+ const latest = useLatest(options);
6
18
  useEffect(() => {
7
19
  const el = ref.current;
8
20
  if (!el) return;
9
- const handle = enhance(el);
21
+ const live = {};
22
+ for (const [key, value] of Object.entries(latest.current ?? {})) {
23
+ if (value === void 0) continue;
24
+ live[key] = typeof value === "function" ? (...args) => {
25
+ const fn = latest.current?.[key];
26
+ return typeof fn === "function" ? fn(...args) : void 0;
27
+ } : value;
28
+ }
29
+ const handle = enhancer(el, live);
10
30
  api.current = handle.api;
11
31
  return () => {
12
32
  api.current = null;
13
33
  handle.destroy();
14
34
  };
15
35
  }, deps);
16
- return { ref, api };
36
+ return api;
17
37
  }
18
38
 
19
- // src/hooks.ts
39
+ // src/Accordion.tsx
40
+ import { createContext as createContext2, forwardRef, useContext } from "react";
20
41
  import {
21
- enhanceAccordion,
22
- enhanceDropdown,
23
- enhanceModal,
24
- enhanceTabs,
25
- enhanceToc,
26
- enhanceTooltip
42
+ enhanceAccordion
27
43
  } from "@hydrateless/enhancers";
28
- var useTabs = () => useEnhancer((el) => enhanceTabs(el));
29
- var useDropdown = () => useEnhancer((el) => enhanceDropdown(el));
30
- var useTooltip = () => useEnhancer((el) => enhanceTooltip(el));
31
- var useAccordion = (allowMultiple = false) => useEnhancer((el) => enhanceAccordion(el, { allowMultiple }), [allowMultiple]);
32
- var useModalGroup = (closeOnBackdrop = true) => useEnhancer((el) => enhanceModal(el, { closeOnBackdrop }), [closeOnBackdrop]);
33
- var useTocEnhancer = (options) => useEnhancer(
34
- (el) => enhanceToc(el.ownerDocument, options),
35
- [options?.contentSelector, options?.headings, options?.scrollSpy]
36
- );
37
44
 
38
- // src/Accordion.tsx
39
- import { useEffect as useEffect2, useRef as useRef3 } from "react";
40
- import { enhanceAccordion as enhanceAccordion2 } from "@hydrateless/enhancers";
45
+ // src/internal/useControlled.ts
46
+ import { useCallback, useState } from "react";
47
+ function useControlled(controlled, defaultValue, onChange) {
48
+ const [internal, setInternal] = useState(defaultValue);
49
+ const isControlled = useLatest(controlled !== void 0);
50
+ const onChangeRef = useLatest(onChange);
51
+ const setValue = useCallback(
52
+ (next) => {
53
+ if (!isControlled.current) setInternal(next);
54
+ onChangeRef.current?.(next);
55
+ },
56
+ [isControlled, onChangeRef]
57
+ );
58
+ return [controlled !== void 0 ? controlled : internal, setValue];
59
+ }
41
60
 
42
- // src/util.ts
43
- import { useRef as useRef2 } from "react";
44
- function cx(...classes) {
45
- return classes.filter(Boolean).join(" ");
61
+ // src/internal/useSyncApi.ts
62
+ import { useEffect as useEffect2 } from "react";
63
+ function useSyncApi(api, value, sync) {
64
+ useEffect2(() => {
65
+ if (value !== void 0 && api.current) sync(api.current, value);
66
+ }, [value, api]);
46
67
  }
47
- function useLatest(value) {
48
- const ref = useRef2(value);
49
- ref.current = value;
68
+
69
+ // src/internal/useForwardedRef.ts
70
+ import { useImperativeHandle, useRef as useRef3 } from "react";
71
+ function useForwardedRef(forwarded) {
72
+ const ref = useRef3(null);
73
+ useImperativeHandle(forwarded, () => ref.current, []);
50
74
  return ref;
51
75
  }
52
76
 
77
+ // src/internal/indexChildren.ts
78
+ import { Children, createContext, createElement, isValidElement } from "react";
79
+ var IndexContext = createContext(0);
80
+ function indexChildren(children, type) {
81
+ let index = 0;
82
+ return Children.map(children, (child) => {
83
+ if (!isValidElement(child) || child.type !== type) return child;
84
+ return createElement(IndexContext.Provider, { value: index++, key: child.key }, child);
85
+ });
86
+ }
87
+
53
88
  // src/Accordion.tsx
54
89
  import { jsx, jsxs } from "react/jsx-runtime";
55
- function Accordion({
56
- allowMultiple = false,
57
- value,
58
- defaultValue,
59
- onValueChange,
60
- children,
61
- ...rest
62
- }) {
63
- const onValueChangeRef = useLatest(onValueChange);
64
- const initialValueRef = useLatest(value ?? defaultValue);
65
- const { ref, api } = useEnhancer(
66
- (el) => enhanceAccordion2(el, {
67
- allowMultiple,
68
- defaultValue: initialValueRef.current,
69
- onValueChange: (next) => onValueChangeRef.current?.(next)
70
- }),
90
+ var AccordionContext = createContext2([]);
91
+ var Accordion = forwardRef(function Accordion2({ allowMultiple = false, value: valueProp, defaultValue, onValueChange, children, ...rest }, forwardedRef) {
92
+ const ref = useForwardedRef(forwardedRef);
93
+ const [value = [], setValue] = useControlled(valueProp, defaultValue, onValueChange);
94
+ const api = useEnhancer(
95
+ ref,
96
+ enhanceAccordion,
97
+ { allowMultiple, defaultValue: value, onValueChange: setValue },
71
98
  [allowMultiple]
72
99
  );
73
- useEffect2(() => {
74
- if (value != null) api.current?.setValue(value);
75
- }, [value, api]);
76
- return /* @__PURE__ */ jsx("div", { ...rest, "data-hl-accordion": true, ref, children });
77
- }
78
- function AccordionItem({
79
- summary,
80
- value,
81
- defaultOpen = false,
82
- children,
83
- ...rest
84
- }) {
85
- const ref = useRef3(null);
86
- useEffect2(() => {
87
- if (ref.current && defaultOpen) ref.current.open = true;
88
- }, [defaultOpen]);
89
- return /* @__PURE__ */ jsxs("details", { ...rest, "data-hl-value": value, ref, children: [
90
- /* @__PURE__ */ jsx("summary", { children: summary }),
91
- /* @__PURE__ */ jsx("div", { className: "hl-accordion-panel", children })
92
- ] });
100
+ useSyncApi(api, valueProp, (api2, value2) => api2.setValue(value2));
101
+ return /* @__PURE__ */ jsx(AccordionContext.Provider, { value, children: /* @__PURE__ */ jsx("div", { ...rest, ref, "data-hl-accordion": true, children: indexChildren(children, AccordionItem) }) });
102
+ });
103
+ var AccordionItem = forwardRef(
104
+ function AccordionItem2({ summary, value, children, ...rest }, ref) {
105
+ const open = useContext(AccordionContext);
106
+ const index = useContext(IndexContext);
107
+ return /* @__PURE__ */ jsxs(
108
+ "details",
109
+ {
110
+ ...rest,
111
+ ref,
112
+ "data-hl-value": value,
113
+ open: open.includes(value ?? String(index)),
114
+ children: [
115
+ /* @__PURE__ */ jsx("summary", { children: summary }),
116
+ /* @__PURE__ */ jsx("div", { className: "hl-accordion-panel", children })
117
+ ]
118
+ }
119
+ );
120
+ }
121
+ );
122
+
123
+ // src/Disclosure.tsx
124
+ import { forwardRef as forwardRef2 } from "react";
125
+ import {
126
+ enhanceDisclosure
127
+ } from "@hydrateless/enhancers";
128
+
129
+ // src/util.ts
130
+ function cx(...classes) {
131
+ return classes.filter(Boolean).join(" ");
93
132
  }
94
133
 
95
134
  // src/Disclosure.tsx
96
- import { useEffect as useEffect3 } from "react";
97
- import { enhanceDisclosure } from "@hydrateless/enhancers";
98
135
  import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
99
- function Disclosure({
100
- summary,
101
- open,
102
- defaultOpen,
103
- onOpenChange,
104
- name,
105
- className,
106
- children,
107
- ...rest
108
- }) {
109
- const onOpenChangeRef = useLatest(onOpenChange);
110
- const initialOpenRef = useLatest(open ?? defaultOpen);
111
- const { ref, api } = useEnhancer(
112
- (el) => enhanceDisclosure(el, {
113
- defaultOpen: initialOpenRef.current,
114
- onOpenChange: (next) => onOpenChangeRef.current?.(next)
115
- }),
116
- []
117
- );
118
- useEffect3(() => {
119
- if (open != null) api.current?.setOpen(open);
120
- }, [open, api]);
136
+ var Disclosure = forwardRef2(function Disclosure2({ summary, open: openProp, defaultOpen, onOpenChange, name, className, children, ...rest }, forwardedRef) {
137
+ const ref = useForwardedRef(forwardedRef);
138
+ const [open, setOpen] = useControlled(openProp, defaultOpen ?? false, onOpenChange);
139
+ const api = useEnhancer(ref, enhanceDisclosure, {
140
+ defaultOpen: open,
141
+ onOpenChange: setOpen
142
+ });
143
+ useSyncApi(api, openProp, (api2, open2) => api2.setOpen(open2));
121
144
  return /* @__PURE__ */ jsxs2(
122
145
  "details",
123
146
  {
124
147
  ...rest,
148
+ ref,
125
149
  name,
150
+ open,
126
151
  className: cx("hl-disclosure", className),
127
152
  "data-hl-disclosure": true,
128
- ref,
129
153
  children: [
130
154
  /* @__PURE__ */ jsx2("summary", { children: summary }),
131
155
  /* @__PURE__ */ jsx2("div", { className: "hl-disclosure-panel", children })
132
156
  ]
133
157
  }
134
158
  );
135
- }
159
+ });
136
160
 
137
161
  // src/Tabs.tsx
138
- import { useEffect as useEffect4 } from "react";
139
- import { enhanceTabs as enhanceTabs2 } from "@hydrateless/enhancers";
162
+ import {
163
+ Children as Children2,
164
+ createContext as createContext3,
165
+ forwardRef as forwardRef3,
166
+ isValidElement as isValidElement2,
167
+ useContext as useContext2
168
+ } from "react";
169
+ import { enhanceTabs } from "@hydrateless/enhancers";
140
170
  import { jsx as jsx3 } from "react/jsx-runtime";
141
- function Tabs({
142
- activation,
143
- orientation,
144
- value,
145
- defaultValue,
146
- onValueChange,
147
- children,
148
- ...rest
149
- }) {
150
- const onValueChangeRef = useLatest(onValueChange);
151
- const initialValueRef = useLatest(value ?? defaultValue);
152
- const { ref, api } = useEnhancer(
153
- (el) => enhanceTabs2(el, {
154
- activation,
155
- orientation,
156
- defaultValue: initialValueRef.current,
157
- onValueChange: (next) => onValueChangeRef.current?.(next)
158
- }),
159
- [activation, orientation]
160
- );
161
- useEffect4(() => {
162
- if (value != null) api.current?.setValue(value);
163
- }, [value, api]);
164
- return /* @__PURE__ */ jsx3("div", { ...rest, "data-hl-tabs": true, ref, children });
165
- }
166
- function TabList({ children, ...rest }) {
167
- return /* @__PURE__ */ jsx3("div", { ...rest, role: "tablist", children });
171
+ var TabsContext = createContext3({ selected: void 0, selectedIndex: 0 });
172
+ function tabValues(children) {
173
+ const list = Children2.toArray(children).find((c) => isValidElement2(c) && c.type === TabList);
174
+ if (!isValidElement2(list)) return null;
175
+ return Children2.toArray(list.props.children).filter((c) => isValidElement2(c) && c.type === Tab).map((tab, i) => tab.props.value ?? String(i));
168
176
  }
169
- function Tab({ children, type, value, ...rest }) {
170
- return /* @__PURE__ */ jsx3("button", { ...rest, type: type ?? "button", role: "tab", "data-hl-value": value, children });
171
- }
172
- function TabPanel({ children, ...rest }) {
173
- return /* @__PURE__ */ jsx3("div", { ...rest, role: "tabpanel", children });
177
+ function useSelected(value) {
178
+ const { selected, selectedIndex } = useContext2(TabsContext);
179
+ const index = useContext2(IndexContext);
180
+ return value != null && selected != null ? value === selected : index === selectedIndex;
174
181
  }
182
+ var Tabs = forwardRef3(function Tabs2({ activation, orientation, value: valueProp, defaultValue, onValueChange, children, ...rest }, forwardedRef) {
183
+ const ref = useForwardedRef(forwardedRef);
184
+ const [selected, setValue] = useControlled(valueProp, defaultValue, onValueChange);
185
+ const api = useEnhancer(
186
+ ref,
187
+ enhanceTabs,
188
+ { activation, orientation, defaultValue: selected, onValueChange: setValue },
189
+ [activation, orientation]
190
+ );
191
+ useSyncApi(api, valueProp, (api2, value) => api2.setValue(value));
192
+ const values = tabValues(children);
193
+ const selectedIndex = selected == null ? 0 : values ? values.indexOf(selected) : Number(selected);
194
+ return /* @__PURE__ */ jsx3(TabsContext.Provider, { value: { selected, selectedIndex }, children: /* @__PURE__ */ jsx3("div", { ...rest, ref, "data-hl-tabs": true, children: indexChildren(children, TabPanel) }) });
195
+ });
196
+ var TabList = forwardRef3(function TabList2({ children, ...rest }, ref) {
197
+ return /* @__PURE__ */ jsx3("div", { ...rest, ref, role: "tablist", children: indexChildren(children, Tab) });
198
+ });
199
+ var Tab = forwardRef3(function Tab2({ children, type, value, ...rest }, ref) {
200
+ const selected = useSelected(value);
201
+ return /* @__PURE__ */ jsx3(
202
+ "button",
203
+ {
204
+ ...rest,
205
+ ref,
206
+ type: type ?? "button",
207
+ role: "tab",
208
+ "aria-selected": selected,
209
+ tabIndex: selected ? 0 : -1,
210
+ "data-hl-value": value,
211
+ children
212
+ }
213
+ );
214
+ });
215
+ var TabPanel = forwardRef3(function TabPanel2({ children, ...rest }, ref) {
216
+ const selected = useSelected(void 0);
217
+ return /* @__PURE__ */ jsx3("div", { ...rest, ref, role: "tabpanel", hidden: !selected, children });
218
+ });
175
219
 
176
220
  // src/Dropdown.tsx
177
221
  import {
178
- useEffect as useEffect5
222
+ createContext as createContext4,
223
+ forwardRef as forwardRef4,
224
+ useContext as useContext3
179
225
  } from "react";
180
226
  import {
181
- enhanceDropdown as enhanceDropdown2
227
+ enhanceDropdown
182
228
  } from "@hydrateless/enhancers";
229
+
230
+ // src/internal/useHlId.ts
231
+ import { useId } from "react";
232
+ function useHlId(prefix, id) {
233
+ const generated = useId();
234
+ return id ?? `hl-${prefix}-${generated.replace(/[^\w-]/g, "")}`;
235
+ }
236
+
237
+ // src/Dropdown.tsx
183
238
  import { jsx as jsx4 } from "react/jsx-runtime";
184
- function Dropdown({
239
+ var DropdownContext = createContext4(void 0);
240
+ var Dropdown = forwardRef4(function Dropdown2({
185
241
  placement,
186
- open,
242
+ closeOnSelect,
243
+ open: openProp,
187
244
  defaultOpen,
188
245
  onOpenChange,
246
+ onSelect,
189
247
  children,
190
248
  ...rest
191
- }) {
192
- const onOpenChangeRef = useLatest(onOpenChange);
193
- const initialOpenRef = useLatest(open ?? defaultOpen);
194
- const { ref, api } = useEnhancer(
195
- (el) => enhanceDropdown2(el, {
196
- placement,
197
- defaultOpen: initialOpenRef.current,
198
- onOpenChange: (next) => onOpenChangeRef.current?.(next)
199
- }),
200
- [placement]
249
+ }, forwardedRef) {
250
+ const ref = useForwardedRef(forwardedRef);
251
+ const menuId = useHlId("dropdown-menu");
252
+ const [open, setOpen] = useControlled(openProp, defaultOpen ?? false, onOpenChange);
253
+ const api = useEnhancer(
254
+ ref,
255
+ enhanceDropdown,
256
+ { placement, closeOnSelect, defaultOpen: open, onOpenChange: setOpen, onSelect },
257
+ [placement, closeOnSelect]
201
258
  );
202
- useEffect5(() => {
203
- if (open != null) api.current?.setOpen(open);
204
- }, [open, api]);
205
- return /* @__PURE__ */ jsx4("div", { ...rest, "data-hl-dropdown": true, ref, children });
206
- }
207
- function DropdownTrigger({ children, type, ...rest }) {
208
- return /* @__PURE__ */ jsx4("button", { ...rest, type: type ?? "button", "data-hl-dropdown-trigger": true, children });
209
- }
210
- function DropdownMenu({ children, ...rest }) {
211
- return /* @__PURE__ */ jsx4("ul", { ...rest, "data-hl-dropdown-menu": true, children });
212
- }
213
- function DropdownItem({ children, onSelect, onClick, type, ...rest }) {
214
- return /* @__PURE__ */ jsx4("li", { children: /* @__PURE__ */ jsx4(
259
+ useSyncApi(api, openProp, (api2, open2) => api2.setOpen(open2, { focus: !api2.open }));
260
+ return /* @__PURE__ */ jsx4(DropdownContext.Provider, { value: menuId, children: /* @__PURE__ */ jsx4("div", { ...rest, ref, "data-hl-dropdown": true, children }) });
261
+ });
262
+ var DropdownTrigger = forwardRef4(
263
+ function DropdownTrigger2({ children, type, ...rest }, ref) {
264
+ const menuId = useContext3(DropdownContext);
265
+ const target = { popovertarget: rest.popoverTarget ?? menuId };
266
+ return /* @__PURE__ */ jsx4(
267
+ "button",
268
+ {
269
+ ...rest,
270
+ ...target,
271
+ popoverTarget: void 0,
272
+ ref,
273
+ type: type ?? "button",
274
+ "data-hl-dropdown-trigger": true,
275
+ children
276
+ }
277
+ );
278
+ }
279
+ );
280
+ var DropdownMenu = forwardRef4(function DropdownMenu2({ id, children, ...rest }, ref) {
281
+ const menuId = useContext3(DropdownContext);
282
+ return /* @__PURE__ */ jsx4("ul", { ...rest, ref, id: id ?? menuId, popover: "auto", "data-hl-dropdown-menu": true, children });
283
+ });
284
+ var DropdownItem = forwardRef4(function DropdownItem2({ children, value, role = "menuitem", checked, disabled, type, ...rest }, ref) {
285
+ return /* @__PURE__ */ jsx4("li", { role: "none", children: /* @__PURE__ */ jsx4(
215
286
  "button",
216
287
  {
217
288
  ...rest,
289
+ ref,
218
290
  type: type ?? "button",
219
- role: "menuitem",
220
- onClick: (e) => {
221
- onSelect?.();
222
- onClick?.(e);
223
- },
291
+ role,
292
+ "aria-checked": role === "menuitem" ? void 0 : checked ?? false,
293
+ "aria-disabled": disabled || void 0,
294
+ disabled,
295
+ "data-hl-value": value,
224
296
  children
225
297
  }
226
298
  ) });
227
- }
228
- function DropdownSeparator(props) {
229
- return /* @__PURE__ */ jsx4("li", { ...props, role: "separator" });
230
- }
299
+ });
300
+ var DropdownGroup = forwardRef4(
301
+ function DropdownGroup2({ label, children, ...rest }, ref) {
302
+ return /* @__PURE__ */ jsx4("li", { role: "none", children: /* @__PURE__ */ jsx4("ul", { ...rest, ref, role: "group", "aria-label": label, children }) });
303
+ }
304
+ );
305
+ var DropdownSeparator = forwardRef4(
306
+ function DropdownSeparator2({ className, ...rest }, ref) {
307
+ return /* @__PURE__ */ jsx4("li", { ...rest, ref, role: "separator", className: cx("hl-dropdown-separator", className) });
308
+ }
309
+ );
231
310
 
232
311
  // src/Menu.tsx
312
+ import {
313
+ forwardRef as forwardRef5
314
+ } from "react";
233
315
  import { enhanceMenu } from "@hydrateless/enhancers";
234
316
  import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
235
- function Menu({
317
+ var Menu = forwardRef5(function Menu2({
236
318
  orientation = "horizontal",
237
- onOpenChange,
319
+ value: valueProp,
320
+ defaultValue,
321
+ onValueChange,
238
322
  onSelect,
239
323
  children,
240
324
  ...rest
241
- }) {
242
- const onOpenChangeRef = useLatest(onOpenChange);
243
- const onSelectRef = useLatest(onSelect);
244
- const { ref } = useEnhancer(
245
- (el) => enhanceMenu(el, {
246
- orientation,
247
- onOpenChange: (value) => onOpenChangeRef.current?.(value),
248
- onSelect: (value) => onSelectRef.current?.(value)
249
- }),
325
+ }, forwardedRef) {
326
+ const ref = useForwardedRef(forwardedRef);
327
+ const [value, setValue] = useControlled(
328
+ valueProp,
329
+ defaultValue ?? null,
330
+ onValueChange
331
+ );
332
+ const api = useEnhancer(
333
+ ref,
334
+ enhanceMenu,
335
+ { orientation, defaultValue: value, onValueChange: setValue, onSelect },
250
336
  [orientation]
251
337
  );
338
+ useSyncApi(api, valueProp, (api2, value2) => api2.setValue(value2));
252
339
  return /* @__PURE__ */ jsx5(
253
340
  "ul",
254
341
  {
@@ -260,219 +347,361 @@ function Menu({
260
347
  children
261
348
  }
262
349
  );
263
- }
264
- function MenuItem({
265
- href,
266
- value,
267
- onSelect,
268
- onClick,
269
- submenu,
270
- anchorProps,
271
- children,
272
- ...rest
273
- }) {
274
- const hasSubmenu = submenu != null;
350
+ });
351
+ var MenuItem = forwardRef5(function MenuItem2({ href, value, role = "menuitem", checked, disabled, anchorProps, children, ...rest }, ref) {
352
+ const shared = {
353
+ role,
354
+ "aria-checked": role === "menuitem" ? void 0 : checked ?? false,
355
+ "aria-disabled": disabled || void 0,
356
+ "data-hl-value": value
357
+ };
358
+ return /* @__PURE__ */ jsx5("li", { role: "none", children: href ? /* @__PURE__ */ jsx5("a", { ...anchorProps, ...shared, ref, href, children }) : /* @__PURE__ */ jsx5(
359
+ "button",
360
+ {
361
+ ...rest,
362
+ ...shared,
363
+ ref,
364
+ type: "button",
365
+ disabled,
366
+ children
367
+ }
368
+ ) });
369
+ });
370
+ var MenuSubmenu = forwardRef5(function MenuSubmenu2({ label, value, disabled, triggerProps, children, ...rest }, ref) {
275
371
  return /* @__PURE__ */ jsxs3("li", { role: "none", children: [
276
- href && !hasSubmenu ? /* @__PURE__ */ jsx5("a", { ...anchorProps, role: "menuitem", href, "data-hl-value": value, children }) : /* @__PURE__ */ jsx5(
372
+ /* @__PURE__ */ jsx5(
277
373
  "button",
278
374
  {
279
- ...rest,
375
+ ...triggerProps,
280
376
  type: "button",
281
377
  role: "menuitem",
378
+ "aria-disabled": disabled || void 0,
379
+ disabled,
282
380
  "data-hl-value": value,
283
- onClick: (e) => {
284
- onSelect?.();
285
- onClick?.(e);
286
- },
287
- children
381
+ children: label
288
382
  }
289
383
  ),
290
- hasSubmenu && /* @__PURE__ */ jsx5("ul", { role: "menu", "data-hl-menu-submenu": true, hidden: true, children: submenu })
384
+ /* @__PURE__ */ jsx5("ul", { ...rest, ref, role: "menu", "data-hl-menu-submenu": true, children })
291
385
  ] });
292
- }
386
+ });
293
387
 
294
388
  // src/Modal.tsx
295
- import { useEffect as useEffect6 } from "react";
296
- import { enhanceModal as enhanceModal2 } from "@hydrateless/enhancers";
389
+ import { forwardRef as forwardRef6 } from "react";
390
+ import { enhanceModal } from "@hydrateless/enhancers";
297
391
  import { jsx as jsx6 } from "react/jsx-runtime";
298
- function Modal({
299
- open,
392
+ var Modal = forwardRef6(function Modal2({
393
+ open: openProp,
300
394
  defaultOpen,
301
395
  onOpenChange,
302
396
  closeOnBackdrop = true,
303
397
  className,
304
398
  children,
305
399
  ...rest
306
- }) {
307
- const onOpenChangeRef = useLatest(onOpenChange);
308
- const initialOpenRef = useLatest(open ?? defaultOpen);
309
- const { ref, api } = useEnhancer(
310
- (el) => enhanceModal2(el, {
311
- closeOnBackdrop,
312
- defaultOpen: initialOpenRef.current,
313
- onOpenChange: (next) => onOpenChangeRef.current?.(next)
314
- }),
400
+ }, forwardedRef) {
401
+ const ref = useForwardedRef(forwardedRef);
402
+ const [open, setOpen] = useControlled(openProp, defaultOpen ?? false, onOpenChange);
403
+ const api = useEnhancer(
404
+ ref,
405
+ enhanceModal,
406
+ { closeOnBackdrop, defaultOpen: open, onOpenChange: setOpen },
315
407
  [closeOnBackdrop]
316
408
  );
317
- useEffect6(() => {
318
- if (open != null) api.current?.setOpen(open);
319
- }, [open, api]);
409
+ useSyncApi(api, openProp, (api2, open2) => api2.setOpen(open2));
320
410
  return /* @__PURE__ */ jsx6("dialog", { ...rest, ref, "data-hl-modal": true, className: cx("hl-modal", className), children });
321
- }
322
- function ModalHeader({ className, ...rest }) {
323
- return /* @__PURE__ */ jsx6("div", { ...rest, className: cx("hl-modal-header", className) });
324
- }
325
- function ModalBody({ className, ...rest }) {
326
- return /* @__PURE__ */ jsx6("div", { ...rest, className: cx("hl-modal-body", className) });
327
- }
328
- function ModalFooter({ className, ...rest }) {
329
- return /* @__PURE__ */ jsx6("div", { ...rest, className: cx("hl-modal-footer", className) });
330
- }
411
+ });
412
+ var ModalHeader = forwardRef6(function ModalHeader2({ className, ...rest }, ref) {
413
+ return /* @__PURE__ */ jsx6("div", { ...rest, ref, className: cx("hl-modal-header", className) });
414
+ });
415
+ var ModalBody = forwardRef6(function ModalBody2({ className, ...rest }, ref) {
416
+ return /* @__PURE__ */ jsx6("div", { ...rest, ref, className: cx("hl-modal-body", className) });
417
+ });
418
+ var ModalFooter = forwardRef6(function ModalFooter2({ className, ...rest }, ref) {
419
+ return /* @__PURE__ */ jsx6("div", { ...rest, ref, className: cx("hl-modal-footer", className) });
420
+ });
331
421
 
332
422
  // src/Drawer.tsx
333
- import { useEffect as useEffect7 } from "react";
423
+ import { forwardRef as forwardRef7 } from "react";
334
424
  import { enhanceDrawer } from "@hydrateless/enhancers";
335
425
  import { jsx as jsx7 } from "react/jsx-runtime";
336
- function Drawer({
337
- open,
426
+ var Drawer = forwardRef7(function Drawer2({
427
+ open: openProp,
338
428
  defaultOpen,
339
429
  onOpenChange,
340
- side = "right",
430
+ side = "end",
341
431
  closeOnBackdrop = true,
342
432
  className,
343
433
  children,
344
434
  ...rest
345
- }) {
346
- const onOpenChangeRef = useLatest(onOpenChange);
347
- const initialOpenRef = useLatest(open ?? defaultOpen);
348
- const { ref, api } = useEnhancer(
349
- (el) => enhanceDrawer(el, {
350
- closeOnBackdrop,
351
- defaultOpen: initialOpenRef.current,
352
- onOpenChange: (next) => onOpenChangeRef.current?.(next)
353
- }),
435
+ }, forwardedRef) {
436
+ const ref = useForwardedRef(forwardedRef);
437
+ const [open, setOpen] = useControlled(openProp, defaultOpen ?? false, onOpenChange);
438
+ const api = useEnhancer(
439
+ ref,
440
+ enhanceDrawer,
441
+ { closeOnBackdrop, defaultOpen: open, onOpenChange: setOpen },
354
442
  [closeOnBackdrop]
355
443
  );
356
- useEffect7(() => {
357
- if (open != null) api.current?.setOpen(open);
358
- }, [open, api]);
444
+ useSyncApi(api, openProp, (api2, open2) => api2.setOpen(open2));
359
445
  return /* @__PURE__ */ jsx7(
360
446
  "dialog",
361
447
  {
362
448
  ...rest,
363
449
  ref,
364
450
  "data-hl-drawer": true,
365
- "data-side": side,
451
+ "data-hl-side": side,
366
452
  className: cx("hl-drawer", className),
367
453
  children
368
454
  }
369
455
  );
370
- }
371
- function DrawerHeader({ className, ...rest }) {
372
- return /* @__PURE__ */ jsx7("div", { ...rest, className: cx("hl-drawer-header", className) });
373
- }
374
- function DrawerBody({ className, ...rest }) {
375
- return /* @__PURE__ */ jsx7("div", { ...rest, className: cx("hl-drawer-body", className) });
376
- }
377
- function DrawerFooter({ className, ...rest }) {
378
- return /* @__PURE__ */ jsx7("div", { ...rest, className: cx("hl-drawer-footer", className) });
379
- }
456
+ });
457
+ var DrawerHeader = forwardRef7(function DrawerHeader2({ className, ...rest }, ref) {
458
+ return /* @__PURE__ */ jsx7("div", { ...rest, ref, className: cx("hl-drawer-header", className) });
459
+ });
460
+ var DrawerBody = forwardRef7(function DrawerBody2({ className, ...rest }, ref) {
461
+ return /* @__PURE__ */ jsx7("div", { ...rest, ref, className: cx("hl-drawer-body", className) });
462
+ });
463
+ var DrawerFooter = forwardRef7(function DrawerFooter2({ className, ...rest }, ref) {
464
+ return /* @__PURE__ */ jsx7("div", { ...rest, ref, className: cx("hl-drawer-footer", className) });
465
+ });
380
466
 
381
467
  // src/Popover.tsx
382
- import { useEffect as useEffect8 } from "react";
383
- import { enhancePopover } from "@hydrateless/enhancers";
468
+ import { forwardRef as forwardRef8 } from "react";
469
+ import {
470
+ enhancePopover
471
+ } from "@hydrateless/enhancers";
384
472
  import { jsx as jsx8 } from "react/jsx-runtime";
385
- function Popover({ open, defaultOpen, onOpenChange, children, ...rest }) {
386
- const onOpenChangeRef = useLatest(onOpenChange);
387
- const initialOpenRef = useLatest(open ?? defaultOpen);
388
- const { ref, api } = useEnhancer(
389
- (el) => enhancePopover(el, {
390
- defaultOpen: initialOpenRef.current,
391
- onOpenChange: (next) => onOpenChangeRef.current?.(next)
392
- }),
393
- []
473
+ var Popover = forwardRef8(function Popover2({ open: openProp, defaultOpen, onOpenChange, placement, hover, children, ...rest }, forwardedRef) {
474
+ const ref = useForwardedRef(forwardedRef);
475
+ const [open, setOpen] = useControlled(openProp, defaultOpen ?? false, onOpenChange);
476
+ const api = useEnhancer(
477
+ ref,
478
+ enhancePopover,
479
+ {
480
+ placement,
481
+ triggerEvent: hover ? "hover" : "click",
482
+ defaultOpen: open,
483
+ onOpenChange: setOpen
484
+ },
485
+ [placement, hover]
394
486
  );
395
- useEffect8(() => {
396
- if (open != null) api.current?.setOpen(open);
397
- }, [open, api]);
487
+ useSyncApi(api, openProp, (api2, open2) => api2.setOpen(open2));
398
488
  return /* @__PURE__ */ jsx8("div", { ...rest, ref, "data-hl-popover": true, popover: "auto", role: "dialog", children });
399
- }
489
+ });
400
490
 
401
491
  // src/Tooltip.tsx
402
492
  import {
403
493
  cloneElement,
404
- isValidElement,
405
- useEffect as useEffect9,
406
- useId,
407
- useRef as useRef4
494
+ forwardRef as forwardRef9,
495
+ isValidElement as isValidElement3
408
496
  } from "react";
409
- import { enhanceTooltip as enhanceTooltip2 } from "@hydrateless/enhancers";
497
+ import {
498
+ enhanceTooltip
499
+ } from "@hydrateless/enhancers";
410
500
  import { jsx as jsx9, jsxs as jsxs4 } from "react/jsx-runtime";
411
- function Tooltip({ label, children, id }) {
412
- const generatedId = useId().replace(/:/g, "");
413
- const tipId = id ?? `hl-tip-${generatedId}`;
414
- const ref = useRef4(null);
415
- useEffect9(() => {
416
- if (!ref.current) return;
417
- return enhanceTooltip2(ref.current).destroy;
418
- }, [tipId]);
419
- const trigger = isValidElement(children) ? cloneElement(children, {
501
+ var Tooltip = forwardRef9(function Tooltip2({
502
+ content,
503
+ children,
504
+ placement,
505
+ showDelay,
506
+ hideDelay,
507
+ open: openProp,
508
+ onOpenChange,
509
+ id,
510
+ style,
511
+ ...rest
512
+ }, forwardedRef) {
513
+ const ref = useForwardedRef(forwardedRef);
514
+ const tipId = useHlId("tip");
515
+ const [, setOpen] = useControlled(openProp, false, onOpenChange);
516
+ const api = useEnhancer(
517
+ ref,
518
+ enhanceTooltip,
519
+ { placement, showDelay, hideDelay, onOpenChange: setOpen },
520
+ [placement, showDelay, hideDelay]
521
+ );
522
+ useSyncApi(api, openProp, (api2, open) => api2.setOpen(open));
523
+ const trigger = isValidElement3(children) ? cloneElement(children, {
420
524
  "data-hl-tooltip": tipId,
421
525
  "aria-describedby": tipId
422
526
  }) : children;
423
- return /* @__PURE__ */ jsxs4("span", { ref, style: { position: "relative", display: "inline-block" }, children: [
424
- trigger,
425
- /* @__PURE__ */ jsx9("span", { id: tipId, role: "tooltip", hidden: true, children: label })
426
- ] });
427
- }
527
+ return /* @__PURE__ */ jsxs4(
528
+ "span",
529
+ {
530
+ ...rest,
531
+ ref,
532
+ id,
533
+ style: { position: "relative", display: "inline-block", ...style },
534
+ children: [
535
+ trigger,
536
+ /* @__PURE__ */ jsx9("span", { id: tipId, role: "tooltip", children: content })
537
+ ]
538
+ }
539
+ );
540
+ });
428
541
 
429
542
  // src/Breadcrumb.tsx
543
+ import {
544
+ forwardRef as forwardRef10
545
+ } from "react";
430
546
  import { jsx as jsx10 } from "react/jsx-runtime";
431
- function Breadcrumb({ children, ...rest }) {
432
- return /* @__PURE__ */ jsx10("nav", { ...rest, "data-hl-breadcrumb": true, "aria-label": rest["aria-label"] ?? "Breadcrumb", children: /* @__PURE__ */ jsx10("ol", { children }) });
547
+ var Breadcrumb = forwardRef10(function Breadcrumb2({ children, ...rest }, ref) {
548
+ return /* @__PURE__ */ jsx10("nav", { ...rest, ref, "data-hl-breadcrumb": true, "aria-label": rest["aria-label"] ?? "Breadcrumb", children: /* @__PURE__ */ jsx10("ol", { children }) });
549
+ });
550
+ var BreadcrumbItem = forwardRef10(
551
+ function BreadcrumbItem2({ href, current, anchorProps, children, ...rest }, ref) {
552
+ return /* @__PURE__ */ jsx10("li", { ...rest, ref, children: current || !href ? /* @__PURE__ */ jsx10("span", { "aria-current": current ? "page" : void 0, children }) : /* @__PURE__ */ jsx10("a", { ...anchorProps, href, children }) });
553
+ }
554
+ );
555
+
556
+ // src/Switch.tsx
557
+ import { forwardRef as forwardRef12 } from "react";
558
+
559
+ // src/Field.tsx
560
+ import {
561
+ createContext as createContext5,
562
+ forwardRef as forwardRef11,
563
+ useContext as useContext4
564
+ } from "react";
565
+ import { jsx as jsx11, jsxs as jsxs5 } from "react/jsx-runtime";
566
+ var FieldContext = createContext5(null);
567
+ function useField() {
568
+ const ctx = useContext4(FieldContext);
569
+ if (!ctx) return null;
570
+ const describedBy = [ctx.helpId, ctx.invalid ? ctx.errorId : null].filter(Boolean).join(" ");
571
+ return {
572
+ id: ctx.id,
573
+ describedBy: describedBy || void 0,
574
+ invalid: ctx.invalid,
575
+ required: ctx.required
576
+ };
433
577
  }
434
- function BreadcrumbItem({
435
- href,
436
- current,
437
- anchorProps,
578
+ var Field = forwardRef11(function Field2({
579
+ id,
580
+ label,
581
+ description,
582
+ error,
583
+ invalid = false,
584
+ required = false,
585
+ className,
438
586
  children,
439
587
  ...rest
440
- }) {
441
- return /* @__PURE__ */ jsx10("li", { ...rest, children: current || !href ? /* @__PURE__ */ jsx10("span", { "aria-current": current ? "page" : void 0, children }) : /* @__PURE__ */ jsx10("a", { ...anchorProps, href, children }) });
588
+ }, ref) {
589
+ const baseId = useHlId("field");
590
+ const hasError = error != null && error !== false;
591
+ const value = {
592
+ id: baseId,
593
+ helpId: `${baseId}-help`,
594
+ errorId: `${baseId}-error`,
595
+ invalid: invalid || hasError,
596
+ required
597
+ };
598
+ return /* @__PURE__ */ jsx11(FieldContext.Provider, { value, children: /* @__PURE__ */ jsxs5(
599
+ "div",
600
+ {
601
+ ...rest,
602
+ ref,
603
+ id,
604
+ className: cx("hl-field", className),
605
+ "data-hl-invalid": value.invalid || void 0,
606
+ children: [
607
+ label != null && /* @__PURE__ */ jsx11(FieldLabel, { children: label }),
608
+ children,
609
+ description != null && /* @__PURE__ */ jsx11(FieldHelp, { children: description }),
610
+ hasError && /* @__PURE__ */ jsx11(FieldError, { children: error })
611
+ ]
612
+ }
613
+ ) });
614
+ });
615
+ var FieldLabel = forwardRef11(function FieldLabel2({ className, children, ...rest }, ref) {
616
+ const ctx = useContext4(FieldContext);
617
+ return /* @__PURE__ */ jsx11(
618
+ "label",
619
+ {
620
+ ...rest,
621
+ ref,
622
+ htmlFor: rest.htmlFor ?? ctx?.id,
623
+ className: cx("hl-label", className),
624
+ "data-hl-required": ctx?.required || void 0,
625
+ children
626
+ }
627
+ );
628
+ });
629
+ var FieldHelp = forwardRef11(function FieldHelp2({ className, children, ...rest }, ref) {
630
+ const ctx = useContext4(FieldContext);
631
+ return /* @__PURE__ */ jsx11("p", { ...rest, ref, id: rest.id ?? ctx?.helpId, className: cx("hl-help", className), children });
632
+ });
633
+ var FieldError = forwardRef11(function FieldError2({ className, children, ...rest }, ref) {
634
+ const ctx = useContext4(FieldContext);
635
+ if (children == null || children === false) return null;
636
+ return /* @__PURE__ */ jsx11(
637
+ "p",
638
+ {
639
+ ...rest,
640
+ ref,
641
+ id: rest.id ?? ctx?.errorId,
642
+ role: "alert",
643
+ className: cx("hl-error", className),
644
+ children
645
+ }
646
+ );
647
+ });
648
+ var Fieldset = forwardRef11(function Fieldset2({ legend, className, children, ...rest }, ref) {
649
+ return /* @__PURE__ */ jsxs5("fieldset", { ...rest, ref, className: cx("hl-fieldset", className), children: [
650
+ legend != null && /* @__PURE__ */ jsx11("legend", { className: "hl-legend", children: legend }),
651
+ children
652
+ ] });
653
+ });
654
+
655
+ // src/internal/useFieldControl.ts
656
+ function useFieldControl(props, invalid) {
657
+ const field = useField();
658
+ const isInvalid = invalid || props["aria-invalid"] || field?.invalid || void 0;
659
+ return {
660
+ ...props,
661
+ id: props.id ?? field?.id,
662
+ required: props.required ?? field?.required,
663
+ "aria-describedby": props["aria-describedby"] ?? field?.describedBy,
664
+ "aria-invalid": isInvalid
665
+ };
442
666
  }
443
667
 
444
668
  // src/Switch.tsx
445
- import { jsx as jsx11, jsxs as jsxs5 } from "react/jsx-runtime";
446
- function Switch({ children, className, ...rest }) {
447
- return /* @__PURE__ */ jsxs5("label", { "data-hl-switch": true, className, children: [
448
- /* @__PURE__ */ jsx11("input", { type: "checkbox", role: "switch", ...rest }),
669
+ import { jsx as jsx12, jsxs as jsxs6 } from "react/jsx-runtime";
670
+ var Switch = forwardRef12(function Switch2({ children, className, ...rest }, ref) {
671
+ const props = useFieldControl(rest);
672
+ return /* @__PURE__ */ jsxs6("label", { "data-hl-switch": true, className, children: [
673
+ /* @__PURE__ */ jsx12("input", { ...props, ref, type: "checkbox", role: "switch" }),
449
674
  children
450
675
  ] });
451
- }
676
+ });
452
677
 
453
678
  // src/SkipLink.tsx
454
- import { jsx as jsx12 } from "react/jsx-runtime";
455
- function SkipLink({ children = "Skip to content", className, ...rest }) {
456
- return /* @__PURE__ */ jsx12("a", { ...rest, className: cx("hl-skip-link", className), children });
457
- }
679
+ import { forwardRef as forwardRef13 } from "react";
680
+ import { jsx as jsx13 } from "react/jsx-runtime";
681
+ var SkipLink = forwardRef13(function SkipLink2({ children = "Skip to content", className, ...rest }, ref) {
682
+ return /* @__PURE__ */ jsx13("a", { ...rest, ref, className: cx("hl-skip-link", className), children });
683
+ });
458
684
 
459
685
  // src/Toc.tsx
460
- import { useEffect as useEffect10, useRef as useRef5 } from "react";
461
- import { enhanceToc as enhanceToc2 } from "@hydrateless/enhancers";
462
- import { jsx as jsx13 } from "react/jsx-runtime";
463
- function Toc({ contentSelector, headings, scrollSpy, ...rest }) {
464
- const ref = useRef5(null);
465
- useEffect10(() => {
466
- if (!ref.current) return;
467
- return enhanceToc2(ref.current.ownerDocument, { contentSelector, headings, scrollSpy }).destroy;
468
- }, [contentSelector, headings, scrollSpy]);
469
- return /* @__PURE__ */ jsx13("nav", { ...rest, "data-hl-toc": true, ref });
470
- }
686
+ import { forwardRef as forwardRef14 } from "react";
687
+ import { enhanceToc } from "@hydrateless/enhancers";
688
+ import { jsx as jsx14 } from "react/jsx-runtime";
689
+ var Toc = forwardRef14(function Toc2({ contentSelector, headings, scrollSpy, ...rest }, forwardedRef) {
690
+ const ref = useForwardedRef(forwardedRef);
691
+ useEnhancer(
692
+ ref,
693
+ // The content lives outside the nav, so scan from the document.
694
+ (nav, options) => enhanceToc(nav.ownerDocument, options),
695
+ { contentSelector, headings, scrollSpy },
696
+ [contentSelector, headings, scrollSpy]
697
+ );
698
+ return /* @__PURE__ */ jsx14("nav", { ...rest, ref, "data-hl-toc": true });
699
+ });
471
700
 
472
701
  // src/Toast.tsx
473
- import { useEffect as useEffect11, useRef as useRef6 } from "react";
702
+ import { forwardRef as forwardRef15 } from "react";
474
703
  import { enhanceToast } from "@hydrateless/enhancers";
475
- import { jsx as jsx14 } from "react/jsx-runtime";
704
+ import { jsx as jsx15 } from "react/jsx-runtime";
476
705
  var sharedApi = null;
477
706
  function ensureApi() {
478
707
  if (!sharedApi) {
@@ -485,184 +714,211 @@ var facade = {
485
714
  show: (message, options) => ensureApi().show(message, options),
486
715
  dismiss: (toast) => ensureApi().dismiss(toast)
487
716
  };
488
- function ToastRegion(props) {
489
- const ref = useRef6(null);
490
- useEffect11(() => {
491
- if (!ref.current) return;
492
- const handle = enhanceToast(ref.current.ownerDocument);
493
- sharedApi = handle.api;
494
- return () => {
495
- handle.destroy();
496
- sharedApi = null;
497
- };
498
- }, []);
499
- return /* @__PURE__ */ jsx14("div", { ...props, "data-hl-toast-region": true, ref });
500
- }
717
+ var ToastRegion = forwardRef15(function ToastRegion2({ duration, onOpenChange, ...props }, forwardedRef) {
718
+ const ref = useForwardedRef(forwardedRef);
719
+ useEnhancer(
720
+ ref,
721
+ (region, options) => {
722
+ const handle = enhanceToast(region.ownerDocument, options);
723
+ sharedApi = handle.api;
724
+ return {
725
+ ...handle,
726
+ destroy: () => {
727
+ handle.destroy();
728
+ sharedApi = null;
729
+ }
730
+ };
731
+ },
732
+ { duration, onOpenChange },
733
+ [duration]
734
+ );
735
+ return /* @__PURE__ */ jsx15("div", { ...props, ref, "data-hl-toast-region": true });
736
+ });
501
737
  function useToast() {
502
738
  return facade;
503
739
  }
504
740
 
505
741
  // src/Combobox.tsx
506
742
  import {
507
- useEffect as useEffect12
743
+ forwardRef as forwardRef16
508
744
  } from "react";
509
745
  import {
510
746
  enhanceCombobox
511
747
  } from "@hydrateless/enhancers";
512
- import { jsx as jsx15 } from "react/jsx-runtime";
513
- function Combobox({
748
+ import { jsx as jsx16 } from "react/jsx-runtime";
749
+ var Combobox = forwardRef16(function Combobox2({
514
750
  filter,
515
751
  autoHighlight,
516
- value,
752
+ value: valueProp,
517
753
  defaultValue,
518
754
  onValueChange,
755
+ open: openProp,
756
+ defaultOpen,
757
+ onOpenChange,
519
758
  children,
520
759
  ...rest
521
- }) {
522
- const onValueChangeRef = useLatest(onValueChange);
523
- const initialValueRef = useLatest(value ?? defaultValue);
524
- const { ref, api } = useEnhancer(
525
- (el) => enhanceCombobox(el, {
526
- filter,
527
- autoHighlight,
528
- defaultValue: initialValueRef.current,
529
- onValueChange: (next) => onValueChangeRef.current?.(next)
530
- }),
760
+ }, forwardedRef) {
761
+ const ref = useForwardedRef(forwardedRef);
762
+ const [value, setValue] = useControlled(valueProp, defaultValue, onValueChange);
763
+ const [, setOpen] = useControlled(openProp, defaultOpen ?? false, onOpenChange);
764
+ const api = useEnhancer(
765
+ ref,
766
+ enhanceCombobox,
767
+ { filter, autoHighlight, defaultValue: value, onValueChange: setValue, onOpenChange: setOpen },
531
768
  [filter, autoHighlight]
532
769
  );
533
- useEffect12(() => {
534
- if (value != null) api.current?.setValue(value);
535
- }, [value, api]);
536
- return /* @__PURE__ */ jsx15("div", { ...rest, ref, "data-hl-combobox": true, children });
537
- }
538
- function ComboboxInput({ styled = true, className, ...rest }) {
539
- return /* @__PURE__ */ jsx15("input", { ...rest, className: cx(styled && "hl-input", className) });
540
- }
541
- function ComboboxList({ children, ...rest }) {
542
- return /* @__PURE__ */ jsx15("ul", { ...rest, role: "listbox", hidden: true, children });
543
- }
544
- function ComboboxOption({ value, children, ...rest }) {
545
- return /* @__PURE__ */ jsx15("li", { ...rest, role: "option", "data-hl-value": value, children: children ?? value });
546
- }
770
+ useSyncApi(api, valueProp, (api2, value2) => api2.setValue(value2));
771
+ useSyncApi(api, openProp ?? defaultOpen, (api2, open) => api2.setOpen(open));
772
+ return /* @__PURE__ */ jsx16("div", { ...rest, ref, "data-hl-combobox": true, children });
773
+ });
774
+ var ComboboxInput = forwardRef16(
775
+ function ComboboxInput2({ styled = true, className, ...rest }, ref) {
776
+ const props = useFieldControl(rest);
777
+ return /* @__PURE__ */ jsx16("input", { ...props, ref, className: cx(styled && "hl-input", className) });
778
+ }
779
+ );
780
+ var ComboboxList = forwardRef16(function ComboboxList2({ children, ...rest }, ref) {
781
+ return /* @__PURE__ */ jsx16("ul", { ...rest, ref, role: "listbox", children });
782
+ });
783
+ var ComboboxOption = forwardRef16(
784
+ function ComboboxOption2({ value, disabled, children, ...rest }, ref) {
785
+ return /* @__PURE__ */ jsx16(
786
+ "li",
787
+ {
788
+ ...rest,
789
+ ref,
790
+ role: "option",
791
+ "aria-disabled": disabled || void 0,
792
+ "data-hl-value": value,
793
+ children: children ?? value
794
+ }
795
+ );
796
+ }
797
+ );
547
798
 
548
799
  // src/Command.tsx
800
+ import { forwardRef as forwardRef17 } from "react";
549
801
  import {
550
- useEffect as useEffect13,
551
- useRef as useRef7
552
- } from "react";
553
- import { enhanceCommand } from "@hydrateless/enhancers";
554
- import { jsx as jsx16, jsxs as jsxs6 } from "react/jsx-runtime";
555
- function Command({ hotkey, onSelect, children, ...rest }) {
556
- const ref = useRef7(null);
557
- const onSelectRef = useRef7(onSelect);
558
- onSelectRef.current = onSelect;
559
- useEffect13(() => {
560
- const el = ref.current;
561
- if (!el) return;
562
- const handle = enhanceCommand(el, {
563
- hotkey,
564
- onCommand: (value) => onSelectRef.current?.(value)
565
- });
566
- return handle.destroy;
567
- }, [hotkey]);
568
- return /* @__PURE__ */ jsx16("div", { ...rest, ref, "data-hl-command": true, "data-hl-command-hotkey": hotkey, children });
569
- }
570
- function CommandInput({ styled = true, className, ...rest }) {
571
- return /* @__PURE__ */ jsx16("input", { ...rest, className: cx(styled && "hl-input", className), "data-hl-command-input": true });
572
- }
573
- function CommandList({ children, ...rest }) {
574
- return /* @__PURE__ */ jsx16("div", { ...rest, "data-hl-command-list": true, role: "listbox", children });
575
- }
576
- function CommandGroup({ label, children, ...rest }) {
577
- return /* @__PURE__ */ jsxs6("div", { ...rest, "data-hl-command-group": true, children: [
578
- label != null && /* @__PURE__ */ jsx16("div", { className: "hl-command-group-label", role: "presentation", children: label }),
802
+ enhanceCommand
803
+ } from "@hydrateless/enhancers";
804
+ import { jsx as jsx17, jsxs as jsxs7 } from "react/jsx-runtime";
805
+ var Command = forwardRef17(function Command2({ hotkey, query: queryProp, defaultQuery, onQueryChange, onCommand, children, ...rest }, forwardedRef) {
806
+ const ref = useForwardedRef(forwardedRef);
807
+ const [query, setQuery] = useControlled(queryProp, defaultQuery, onQueryChange);
808
+ const api = useEnhancer(
809
+ ref,
810
+ enhanceCommand,
811
+ { hotkey, defaultValue: query, onValueChange: setQuery, onCommand },
812
+ [hotkey]
813
+ );
814
+ useSyncApi(api, queryProp, (api2, query2) => api2.setValue(query2));
815
+ return /* @__PURE__ */ jsx17("div", { ...rest, ref, "data-hl-command": true, "data-hl-command-hotkey": hotkey, children });
816
+ });
817
+ var CommandInput = forwardRef17(function CommandInput2({ styled = true, className, ...rest }, ref) {
818
+ return /* @__PURE__ */ jsx17(
819
+ "input",
820
+ {
821
+ ...rest,
822
+ ref,
823
+ className: cx(styled && "hl-input", className),
824
+ "data-hl-command-input": true
825
+ }
826
+ );
827
+ });
828
+ var CommandList = forwardRef17(function CommandList2({ children, ...rest }, ref) {
829
+ return /* @__PURE__ */ jsx17("div", { ...rest, ref, "data-hl-command-list": true, role: "listbox", children });
830
+ });
831
+ var CommandGroup = forwardRef17(function CommandGroup2({ label, children, ...rest }, ref) {
832
+ return /* @__PURE__ */ jsxs7("div", { ...rest, ref, "data-hl-command-group": true, children: [
833
+ label != null && /* @__PURE__ */ jsx17("div", { className: "hl-command-group-label", role: "presentation", children: label }),
579
834
  children
580
835
  ] });
581
- }
582
- function CommandItem({ value, keywords, icon, children, ...rest }) {
583
- return /* @__PURE__ */ jsxs6("div", { ...rest, role: "option", "data-hl-value": value, "data-hl-keywords": keywords, children: [
836
+ });
837
+ var CommandItem = forwardRef17(function CommandItem2({ value, keywords, icon, children, ...rest }, ref) {
838
+ return /* @__PURE__ */ jsxs7("div", { ...rest, ref, role: "option", "data-hl-value": value, "data-hl-keywords": keywords, children: [
584
839
  icon,
585
- /* @__PURE__ */ jsx16("span", { children })
840
+ /* @__PURE__ */ jsx17("span", { children })
586
841
  ] });
587
- }
588
- function CommandEmpty({ children = "No results found.", ...rest }) {
589
- return /* @__PURE__ */ jsx16("div", { ...rest, "data-hl-command-empty": true, hidden: true, children });
590
- }
842
+ });
843
+ var CommandEmpty = forwardRef17(function CommandEmpty2({ children = "No results found.", ...rest }, ref) {
844
+ return /* @__PURE__ */ jsx17("div", { ...rest, ref, "data-hl-command-empty": true, hidden: true, children });
845
+ });
591
846
 
592
847
  // src/Input.tsx
593
- import { forwardRef } from "react";
594
- import { jsx as jsx17 } from "react/jsx-runtime";
595
- var Input = forwardRef(function Input2({ size, invalid, className, ...rest }, ref) {
596
- return /* @__PURE__ */ jsx17(
848
+ import { forwardRef as forwardRef18 } from "react";
849
+ import { jsx as jsx18 } from "react/jsx-runtime";
850
+ var Input = forwardRef18(function Input2({ size, invalid, className, ...rest }, ref) {
851
+ const props = useFieldControl(rest, invalid);
852
+ return /* @__PURE__ */ jsx18(
597
853
  "input",
598
854
  {
599
- ...rest,
855
+ ...props,
600
856
  ref,
601
- className: ["hl-input", className].filter(Boolean).join(" "),
857
+ className: cx("hl-input", className),
602
858
  "data-hl-size": size,
603
- "data-hl-invalid": invalid || void 0,
604
- "aria-invalid": invalid || rest["aria-invalid"]
859
+ "data-hl-invalid": props["aria-invalid"] || void 0
605
860
  }
606
861
  );
607
862
  });
608
863
 
609
864
  // src/Textarea.tsx
610
- import { forwardRef as forwardRef2 } from "react";
611
- import { jsx as jsx18 } from "react/jsx-runtime";
612
- var Textarea = forwardRef2(function Textarea2({ invalid, className, ...rest }, ref) {
613
- return /* @__PURE__ */ jsx18(
865
+ import { forwardRef as forwardRef19 } from "react";
866
+ import { jsx as jsx19 } from "react/jsx-runtime";
867
+ var Textarea = forwardRef19(function Textarea2({ invalid, autosize, className, ...rest }, ref) {
868
+ const props = useFieldControl(rest, invalid);
869
+ return /* @__PURE__ */ jsx19(
614
870
  "textarea",
615
871
  {
616
- ...rest,
872
+ ...props,
617
873
  ref,
618
- className: ["hl-textarea", className].filter(Boolean).join(" "),
619
- "data-hl-invalid": invalid || void 0,
620
- "aria-invalid": invalid || rest["aria-invalid"]
874
+ className: cx("hl-textarea", className),
875
+ "data-hl-autosize": autosize || void 0,
876
+ "data-hl-invalid": props["aria-invalid"] || void 0
621
877
  }
622
878
  );
623
879
  });
624
880
 
625
881
  // src/Select.tsx
626
- import { forwardRef as forwardRef3 } from "react";
627
- import { jsx as jsx19 } from "react/jsx-runtime";
628
- var Select = forwardRef3(function Select2({ size, invalid, options, className, children, ...rest }, ref) {
629
- return /* @__PURE__ */ jsx19("span", { className: "hl-select-wrapper", children: /* @__PURE__ */ jsx19(
882
+ import { forwardRef as forwardRef20 } from "react";
883
+ import { jsx as jsx20 } from "react/jsx-runtime";
884
+ var Select = forwardRef20(function Select2({ size, invalid, options, className, children, ...rest }, ref) {
885
+ const props = useFieldControl(rest, invalid);
886
+ return /* @__PURE__ */ jsx20("span", { className: "hl-select-wrapper", children: /* @__PURE__ */ jsx20(
630
887
  "select",
631
888
  {
632
- ...rest,
889
+ ...props,
633
890
  ref,
634
- className: ["hl-select", className].filter(Boolean).join(" "),
891
+ className: cx("hl-select", className),
635
892
  "data-hl-size": size,
636
- "data-hl-invalid": invalid || void 0,
637
- "aria-invalid": invalid || rest["aria-invalid"],
638
- children: options ? options.map((option) => /* @__PURE__ */ jsx19("option", { value: option.value, disabled: option.disabled, children: option.label }, option.value)) : children
893
+ "data-hl-invalid": props["aria-invalid"] || void 0,
894
+ children: options ? options.map((option) => /* @__PURE__ */ jsx20("option", { value: option.value, disabled: option.disabled, children: option.label }, option.value)) : children
639
895
  }
640
896
  ) });
641
897
  });
642
898
 
643
899
  // src/Checkbox.tsx
644
- import { forwardRef as forwardRef4 } from "react";
645
- import { jsx as jsx20, jsxs as jsxs7 } from "react/jsx-runtime";
646
- var Checkbox = forwardRef4(function Checkbox2({ children, className, ...rest }, ref) {
647
- return /* @__PURE__ */ jsxs7("label", { className: ["hl-checkbox", className].filter(Boolean).join(" "), children: [
648
- /* @__PURE__ */ jsx20("input", { ...rest, ref, type: "checkbox" }),
649
- children != null && /* @__PURE__ */ jsx20("span", { children })
900
+ import { forwardRef as forwardRef21 } from "react";
901
+ import { jsx as jsx21, jsxs as jsxs8 } from "react/jsx-runtime";
902
+ var Checkbox = forwardRef21(function Checkbox2({ children, className, ...rest }, ref) {
903
+ const props = useFieldControl(rest);
904
+ return /* @__PURE__ */ jsxs8("label", { className: cx("hl-checkbox", className), children: [
905
+ /* @__PURE__ */ jsx21("input", { ...props, ref, type: "checkbox" }),
906
+ children != null && /* @__PURE__ */ jsx21("span", { children })
650
907
  ] });
651
908
  });
652
909
 
653
910
  // src/Radio.tsx
654
911
  import {
655
- createContext,
656
- forwardRef as forwardRef5,
657
- useContext
912
+ createContext as createContext6,
913
+ forwardRef as forwardRef22,
914
+ useContext as useContext5
658
915
  } from "react";
659
- import { jsx as jsx21, jsxs as jsxs8 } from "react/jsx-runtime";
660
- var RadioGroupContext = createContext(null);
661
- var Radio = forwardRef5(function Radio2({ children, className, value, ...rest }, ref) {
662
- const group = useContext(RadioGroupContext);
663
- const checked = group ? group.value === value : rest.checked;
664
- return /* @__PURE__ */ jsxs8("label", { className: ["hl-radio", className].filter(Boolean).join(" "), children: [
665
- /* @__PURE__ */ jsx21(
916
+ import { jsx as jsx22, jsxs as jsxs9 } from "react/jsx-runtime";
917
+ var RadioGroupContext = createContext6(null);
918
+ var Radio = forwardRef22(function Radio2({ children, className, value, ...rest }, ref) {
919
+ const group = useContext5(RadioGroupContext);
920
+ return /* @__PURE__ */ jsxs9("label", { className: cx("hl-radio", className), children: [
921
+ /* @__PURE__ */ jsx22(
666
922
  "input",
667
923
  {
668
924
  ...rest,
@@ -670,187 +926,92 @@ var Radio = forwardRef5(function Radio2({ children, className, value, ...rest },
670
926
  type: "radio",
671
927
  name: rest.name ?? group?.name,
672
928
  value,
673
- checked,
929
+ checked: group ? group.value === value : rest.checked,
674
930
  onChange: (e) => {
675
- group?.onValueChange?.(value);
931
+ group?.setValue(value);
676
932
  rest.onChange?.(e);
677
933
  }
678
934
  }
679
935
  ),
680
- children != null && /* @__PURE__ */ jsx21("span", { children })
936
+ children != null && /* @__PURE__ */ jsx22("span", { children })
681
937
  ] });
682
938
  });
683
- function RadioGroup({
939
+ var RadioGroup = forwardRef22(function RadioGroup2({
684
940
  name,
685
- value,
941
+ value: valueProp,
942
+ defaultValue,
686
943
  onValueChange,
944
+ orientation,
687
945
  className,
688
946
  children,
689
947
  ...rest
690
- }) {
691
- return /* @__PURE__ */ jsx21(RadioGroupContext.Provider, { value: { name, value, onValueChange }, children: /* @__PURE__ */ jsx21(
948
+ }, ref) {
949
+ const [value, setValue] = useControlled(valueProp, defaultValue, onValueChange);
950
+ const groupName = useHlId("radio", name);
951
+ return /* @__PURE__ */ jsx22(RadioGroupContext.Provider, { value: { name: groupName, value, setValue }, children: /* @__PURE__ */ jsx22(
692
952
  "div",
693
953
  {
694
954
  ...rest,
955
+ ref,
695
956
  role: "radiogroup",
696
- className: ["hl-radio-group", className].filter(Boolean).join(" "),
697
- children
698
- }
699
- ) });
700
- }
701
-
702
- // src/Field.tsx
703
- import {
704
- createContext as createContext2,
705
- useContext as useContext2,
706
- useId as useId2
707
- } from "react";
708
- import { jsx as jsx22, jsxs as jsxs9 } from "react/jsx-runtime";
709
- var FieldContext = createContext2(null);
710
- function Field({
711
- id,
712
- invalid = false,
713
- required = false,
714
- className,
715
- children,
716
- ...rest
717
- }) {
718
- const generated = useId2().replace(/:/g, "");
719
- const baseId = id ?? `hl-field-${generated}`;
720
- const value = {
721
- id: baseId,
722
- helpId: `${baseId}-help`,
723
- errorId: `${baseId}-error`,
724
- invalid,
725
- required
726
- };
727
- return /* @__PURE__ */ jsx22(FieldContext.Provider, { value, children: /* @__PURE__ */ jsx22(
728
- "div",
729
- {
730
- ...rest,
731
- className: ["hl-field", className].filter(Boolean).join(" "),
732
- "data-hl-invalid": invalid || void 0,
957
+ className: cx("hl-radio-group", className),
958
+ "data-hl-orientation": orientation,
959
+ "aria-orientation": orientation,
733
960
  children
734
961
  }
735
962
  ) });
736
- }
737
- function useFieldContext(component) {
738
- const ctx = useContext2(FieldContext);
739
- if (!ctx) throw new Error(`<${component}> must be used within a <Field>`);
740
- return ctx;
741
- }
742
- function useField() {
743
- const ctx = useFieldContext("useField");
744
- const describedBy = [ctx.helpId, ctx.invalid ? ctx.errorId : null].filter(Boolean).join(" ");
745
- return {
746
- id: ctx.id,
747
- "aria-describedby": describedBy || void 0,
748
- "aria-invalid": ctx.invalid || void 0
749
- };
750
- }
751
- function FieldLabel({ className, children, ...rest }) {
752
- const ctx = useFieldContext("FieldLabel");
753
- return /* @__PURE__ */ jsx22(
754
- "label",
755
- {
756
- ...rest,
757
- htmlFor: rest.htmlFor ?? ctx.id,
758
- className: ["hl-label", className].filter(Boolean).join(" "),
759
- "data-hl-required": ctx.required || void 0,
760
- children
761
- }
762
- );
763
- }
764
- function FieldHelp({ className, children, ...rest }) {
765
- const ctx = useFieldContext("FieldHelp");
766
- return /* @__PURE__ */ jsx22("p", { ...rest, id: ctx.helpId, className: ["hl-help", className].filter(Boolean).join(" "), children });
767
- }
768
- function FieldError({ className, children, ...rest }) {
769
- const ctx = useFieldContext("FieldError");
770
- if (children == null || children === false) return null;
771
- return /* @__PURE__ */ jsx22(
772
- "p",
773
- {
774
- ...rest,
775
- id: ctx.errorId,
776
- role: "alert",
777
- className: ["hl-error", className].filter(Boolean).join(" "),
778
- children
779
- }
780
- );
781
- }
782
- function Fieldset({ legend, className, children, ...rest }) {
783
- return /* @__PURE__ */ jsxs9("fieldset", { ...rest, className: ["hl-fieldset", className].filter(Boolean).join(" "), children: [
784
- legend != null && /* @__PURE__ */ jsx22("legend", { className: "hl-legend", children: legend }),
785
- children
786
- ] });
787
- }
963
+ });
788
964
 
789
965
  // src/SegmentedControl.tsx
790
- import { useId as useId3, useState } from "react";
966
+ import { forwardRef as forwardRef23 } from "react";
791
967
  import { jsx as jsx23, jsxs as jsxs10 } from "react/jsx-runtime";
792
- function SegmentedControl({
793
- options,
794
- value,
795
- defaultValue,
796
- onValueChange,
797
- name,
798
- size,
799
- className,
800
- ...rest
801
- }) {
802
- const generatedName = useId3();
803
- const groupName = name ?? generatedName;
804
- const [internal, setInternal] = useState(defaultValue ?? options[0]?.value);
805
- const current = value ?? internal;
806
- const select = (next) => {
807
- if (value === void 0) setInternal(next);
808
- onValueChange?.(next);
809
- };
810
- return /* @__PURE__ */ jsx23(
811
- "div",
812
- {
813
- ...rest,
814
- role: "radiogroup",
815
- className: ["hl-segmented", className].filter(Boolean).join(" "),
816
- "data-hl-size": size,
817
- children: options.map((option) => /* @__PURE__ */ jsxs10("label", { className: "hl-segmented-item", children: [
818
- /* @__PURE__ */ jsx23(
819
- "input",
820
- {
821
- type: "radio",
822
- name: groupName,
823
- value: option.value,
824
- checked: current === option.value,
825
- disabled: option.disabled,
826
- onChange: () => select(option.value)
827
- }
828
- ),
829
- /* @__PURE__ */ jsx23("span", { children: option.label })
830
- ] }, option.value))
831
- }
832
- );
833
- }
968
+ var SegmentedControl = forwardRef23(
969
+ function SegmentedControl2({ options, value: valueProp, defaultValue, onValueChange, name, size, className, ...rest }, ref) {
970
+ const [value, setValue] = useControlled(
971
+ valueProp,
972
+ defaultValue ?? options[0]?.value,
973
+ onValueChange
974
+ );
975
+ const groupName = useHlId("segmented", name);
976
+ return /* @__PURE__ */ jsx23(
977
+ "div",
978
+ {
979
+ ...rest,
980
+ ref,
981
+ role: "radiogroup",
982
+ className: cx("hl-segmented", className),
983
+ "data-hl-size": size,
984
+ children: options.map((option) => /* @__PURE__ */ jsxs10("label", { className: "hl-segmented-item", children: [
985
+ /* @__PURE__ */ jsx23(
986
+ "input",
987
+ {
988
+ type: "radio",
989
+ name: groupName,
990
+ value: option.value,
991
+ checked: value === option.value,
992
+ disabled: option.disabled,
993
+ onChange: () => setValue(option.value)
994
+ }
995
+ ),
996
+ /* @__PURE__ */ jsx23("span", { children: option.label })
997
+ ] }, option.value))
998
+ }
999
+ );
1000
+ }
1001
+ );
834
1002
 
835
1003
  // src/Slider.tsx
836
- import { forwardRef as forwardRef6 } from "react";
1004
+ import { forwardRef as forwardRef24 } from "react";
837
1005
  import { jsx as jsx24 } from "react/jsx-runtime";
838
- var Slider = forwardRef6(function Slider2({ className, ...rest }, ref) {
839
- return /* @__PURE__ */ jsx24(
840
- "input",
841
- {
842
- ...rest,
843
- ref,
844
- type: "range",
845
- className: ["hl-slider", className].filter(Boolean).join(" ")
846
- }
847
- );
1006
+ var Slider = forwardRef24(function Slider2({ className, ...rest }, ref) {
1007
+ const props = useFieldControl(rest);
1008
+ return /* @__PURE__ */ jsx24("input", { ...props, ref, type: "range", className: cx("hl-slider", className) });
848
1009
  });
849
1010
 
850
1011
  // src/Button.tsx
851
- import { forwardRef as forwardRef7 } from "react";
1012
+ import { forwardRef as forwardRef25 } from "react";
852
1013
  import { jsx as jsx25 } from "react/jsx-runtime";
853
- var Button = forwardRef7(function Button2({ variant, intent, size, block, icon, loading, className, children, disabled, type, ...rest }, ref) {
1014
+ var Button = forwardRef25(function Button2({ variant, intent, size, block, icon, loading, className, children, disabled, type, ...rest }, ref) {
854
1015
  return /* @__PURE__ */ jsx25(
855
1016
  "button",
856
1017
  {
@@ -872,9 +1033,9 @@ var Button = forwardRef7(function Button2({ variant, intent, size, block, icon,
872
1033
  });
873
1034
 
874
1035
  // src/Alert.tsx
875
- import { forwardRef as forwardRef8 } from "react";
1036
+ import { forwardRef as forwardRef26 } from "react";
876
1037
  import { jsx as jsx26, jsxs as jsxs11 } from "react/jsx-runtime";
877
- var Alert = forwardRef8(function Alert2({ intent, title, icon, className, children, ...rest }, ref) {
1038
+ var Alert = forwardRef26(function Alert2({ intent, title, icon, className, children, ...rest }, ref) {
878
1039
  return /* @__PURE__ */ jsxs11(
879
1040
  "div",
880
1041
  {
@@ -895,9 +1056,9 @@ var Alert = forwardRef8(function Alert2({ intent, title, icon, className, childr
895
1056
  });
896
1057
 
897
1058
  // src/Badge.tsx
898
- import { forwardRef as forwardRef9 } from "react";
1059
+ import { forwardRef as forwardRef27 } from "react";
899
1060
  import { jsx as jsx27 } from "react/jsx-runtime";
900
- var Badge = forwardRef9(function Badge2({ intent, variant, size, className, children, ...rest }, ref) {
1061
+ var Badge = forwardRef27(function Badge2({ intent, variant, size, className, children, ...rest }, ref) {
901
1062
  return /* @__PURE__ */ jsx27(
902
1063
  "span",
903
1064
  {
@@ -913,9 +1074,9 @@ var Badge = forwardRef9(function Badge2({ intent, variant, size, className, chil
913
1074
  });
914
1075
 
915
1076
  // src/Card.tsx
916
- import { forwardRef as forwardRef10 } from "react";
1077
+ import { forwardRef as forwardRef28 } from "react";
917
1078
  import { jsx as jsx28 } from "react/jsx-runtime";
918
- var Card = forwardRef10(function Card2({ interactive, className, children, ...rest }, ref) {
1079
+ var Card = forwardRef28(function Card2({ interactive, className, children, ...rest }, ref) {
919
1080
  return /* @__PURE__ */ jsx28(
920
1081
  "div",
921
1082
  {
@@ -927,21 +1088,21 @@ var Card = forwardRef10(function Card2({ interactive, className, children, ...re
927
1088
  }
928
1089
  );
929
1090
  });
930
- var CardHeader = forwardRef10(function CardHeader2({ className, ...rest }, ref) {
1091
+ var CardHeader = forwardRef28(function CardHeader2({ className, ...rest }, ref) {
931
1092
  return /* @__PURE__ */ jsx28("div", { ...rest, ref, className: ["hl-card-header", className].filter(Boolean).join(" ") });
932
1093
  });
933
- var CardBody = forwardRef10(function CardBody2({ className, ...rest }, ref) {
1094
+ var CardBody = forwardRef28(function CardBody2({ className, ...rest }, ref) {
934
1095
  return /* @__PURE__ */ jsx28("div", { ...rest, ref, className: ["hl-card-body", className].filter(Boolean).join(" ") });
935
1096
  });
936
- var CardFooter = forwardRef10(function CardFooter2({ className, ...rest }, ref) {
1097
+ var CardFooter = forwardRef28(function CardFooter2({ className, ...rest }, ref) {
937
1098
  return /* @__PURE__ */ jsx28("div", { ...rest, ref, className: ["hl-card-footer", className].filter(Boolean).join(" ") });
938
1099
  });
939
- var CardTitle = forwardRef10(
1100
+ var CardTitle = forwardRef28(
940
1101
  function CardTitle2({ className, ...rest }, ref) {
941
1102
  return /* @__PURE__ */ jsx28("h3", { ...rest, ref, className: ["hl-card-title", className].filter(Boolean).join(" ") });
942
1103
  }
943
1104
  );
944
- var CardDescription = forwardRef10(function CardDescription2({ className, ...rest }, ref) {
1105
+ var CardDescription = forwardRef28(function CardDescription2({ className, ...rest }, ref) {
945
1106
  return /* @__PURE__ */ jsx28(
946
1107
  "p",
947
1108
  {
@@ -953,9 +1114,9 @@ var CardDescription = forwardRef10(function CardDescription2({ className, ...res
953
1114
  });
954
1115
 
955
1116
  // src/Avatar.tsx
956
- import { forwardRef as forwardRef11, useState as useState2 } from "react";
1117
+ import { forwardRef as forwardRef29, useState as useState2 } from "react";
957
1118
  import { jsx as jsx29 } from "react/jsx-runtime";
958
- var Avatar = forwardRef11(function Avatar2({ src, alt = "", fallback, size, shape, className, children, ...rest }, ref) {
1119
+ var Avatar = forwardRef29(function Avatar2({ src, alt = "", fallback, size, shape, className, children, ...rest }, ref) {
959
1120
  const [failed, setFailed] = useState2(false);
960
1121
  const showImage = src && !failed;
961
1122
  return /* @__PURE__ */ jsx29(
@@ -970,14 +1131,14 @@ var Avatar = forwardRef11(function Avatar2({ src, alt = "", fallback, size, shap
970
1131
  }
971
1132
  );
972
1133
  });
973
- var AvatarGroup = forwardRef11(function AvatarGroup2({ className, children, ...rest }, ref) {
1134
+ var AvatarGroup = forwardRef29(function AvatarGroup2({ className, children, ...rest }, ref) {
974
1135
  return /* @__PURE__ */ jsx29("div", { ...rest, ref, className: ["hl-avatar-group", className].filter(Boolean).join(" "), children });
975
1136
  });
976
1137
 
977
1138
  // src/Progress.tsx
978
- import { forwardRef as forwardRef12 } from "react";
1139
+ import { forwardRef as forwardRef30 } from "react";
979
1140
  import { jsx as jsx30 } from "react/jsx-runtime";
980
- var Progress = forwardRef12(function Progress2({ value, max = 100, intent, size, className, ...rest }, ref) {
1141
+ var Progress = forwardRef30(function Progress2({ value, max = 100, intent, size, className, ...rest }, ref) {
981
1142
  return /* @__PURE__ */ jsx30(
982
1143
  "progress",
983
1144
  {
@@ -993,9 +1154,9 @@ var Progress = forwardRef12(function Progress2({ value, max = 100, intent, size,
993
1154
  });
994
1155
 
995
1156
  // src/Spinner.tsx
996
- import { forwardRef as forwardRef13 } from "react";
1157
+ import { forwardRef as forwardRef31 } from "react";
997
1158
  import { jsx as jsx31 } from "react/jsx-runtime";
998
- var Spinner = forwardRef13(function Spinner2({ size, label = "Loading", className, ...rest }, ref) {
1159
+ var Spinner = forwardRef31(function Spinner2({ size, label = "Loading", className, ...rest }, ref) {
999
1160
  return /* @__PURE__ */ jsx31(
1000
1161
  "span",
1001
1162
  {
@@ -1010,9 +1171,9 @@ var Spinner = forwardRef13(function Spinner2({ size, label = "Loading", classNam
1010
1171
  });
1011
1172
 
1012
1173
  // src/Skeleton.tsx
1013
- import { forwardRef as forwardRef14 } from "react";
1174
+ import { forwardRef as forwardRef32 } from "react";
1014
1175
  import { jsx as jsx32 } from "react/jsx-runtime";
1015
- var Skeleton = forwardRef14(function Skeleton2({ variant, width, height, className, style, ...rest }, ref) {
1176
+ var Skeleton = forwardRef32(function Skeleton2({ shape, width, height, className, style, ...rest }, ref) {
1016
1177
  const sizeStyle = {
1017
1178
  ...width != null && { inlineSize: width },
1018
1179
  ...height != null && { blockSize: height },
@@ -1023,8 +1184,8 @@ var Skeleton = forwardRef14(function Skeleton2({ variant, width, height, classNa
1023
1184
  {
1024
1185
  ...rest,
1025
1186
  ref,
1026
- className: ["hl-skeleton", className].filter(Boolean).join(" "),
1027
- "data-hl-variant": variant,
1187
+ className: cx("hl-skeleton", className),
1188
+ "data-hl-shape": shape,
1028
1189
  style: sizeStyle,
1029
1190
  "aria-hidden": "true"
1030
1191
  }
@@ -1032,6 +1193,7 @@ var Skeleton = forwardRef14(function Skeleton2({ variant, width, height, classNa
1032
1193
  });
1033
1194
 
1034
1195
  // src/Pagination.tsx
1196
+ import { forwardRef as forwardRef33 } from "react";
1035
1197
  import { jsx as jsx33, jsxs as jsxs12 } from "react/jsx-runtime";
1036
1198
  var ELLIPSIS = "ellipsis";
1037
1199
  function range(start, end) {
@@ -1052,7 +1214,7 @@ function paginationRange(page, count, siblingCount) {
1052
1214
  }
1053
1215
  return [1, ELLIPSIS, ...range(leftSibling, rightSibling), ELLIPSIS, count];
1054
1216
  }
1055
- function Pagination({
1217
+ var Pagination = forwardRef33(function Pagination2({
1056
1218
  page,
1057
1219
  count,
1058
1220
  onPageChange,
@@ -1062,7 +1224,7 @@ function Pagination({
1062
1224
  nextLabel = "\u203A",
1063
1225
  className,
1064
1226
  ...rest
1065
- }) {
1227
+ }, ref) {
1066
1228
  const items = paginationRange(page, count, siblingCount);
1067
1229
  const go = (target) => {
1068
1230
  if (target >= 1 && target <= count && target !== page) onPageChange?.(target);
@@ -1071,7 +1233,8 @@ function Pagination({
1071
1233
  "nav",
1072
1234
  {
1073
1235
  ...rest,
1074
- className: ["hl-pagination", className].filter(Boolean).join(" "),
1236
+ ref,
1237
+ className: cx("hl-pagination", className),
1075
1238
  "aria-label": rest["aria-label"] ?? "Pagination",
1076
1239
  children: /* @__PURE__ */ jsxs12("ul", { children: [
1077
1240
  showControls && /* @__PURE__ */ jsx33("li", { children: /* @__PURE__ */ jsx33(
@@ -1112,19 +1275,19 @@ function Pagination({
1112
1275
  ] })
1113
1276
  }
1114
1277
  );
1115
- }
1278
+ });
1116
1279
 
1117
1280
  // src/Kbd.tsx
1118
- import { forwardRef as forwardRef15 } from "react";
1281
+ import { forwardRef as forwardRef34 } from "react";
1119
1282
  import { jsx as jsx34 } from "react/jsx-runtime";
1120
- var Kbd = forwardRef15(function Kbd2({ className, children, ...rest }, ref) {
1283
+ var Kbd = forwardRef34(function Kbd2({ className, children, ...rest }, ref) {
1121
1284
  return /* @__PURE__ */ jsx34("kbd", { ...rest, ref, className: ["hl-kbd", className].filter(Boolean).join(" "), children });
1122
1285
  });
1123
1286
 
1124
1287
  // src/Separator.tsx
1125
- import { forwardRef as forwardRef16 } from "react";
1288
+ import { forwardRef as forwardRef35 } from "react";
1126
1289
  import { jsx as jsx35 } from "react/jsx-runtime";
1127
- var Separator = forwardRef16(function Separator2({ orientation = "horizontal", decorative, className, ...rest }, ref) {
1290
+ var Separator = forwardRef35(function Separator2({ orientation = "horizontal", decorative, className, ...rest }, ref) {
1128
1291
  return /* @__PURE__ */ jsx35(
1129
1292
  "hr",
1130
1293
  {
@@ -1137,6 +1300,25 @@ var Separator = forwardRef16(function Separator2({ orientation = "horizontal", d
1137
1300
  }
1138
1301
  );
1139
1302
  });
1303
+
1304
+ // src/Table.tsx
1305
+ import { forwardRef as forwardRef36 } from "react";
1306
+ import { jsx as jsx36 } from "react/jsx-runtime";
1307
+ var Table = forwardRef36(function Table2({ striped, hover, align, size, className, children, ...rest }, ref) {
1308
+ return /* @__PURE__ */ jsx36(
1309
+ "table",
1310
+ {
1311
+ ...rest,
1312
+ ref,
1313
+ className: cx("hl-table", className),
1314
+ "data-hl-striped": striped || void 0,
1315
+ "data-hl-hover": hover || void 0,
1316
+ "data-hl-align": align,
1317
+ "data-hl-size": size,
1318
+ children
1319
+ }
1320
+ );
1321
+ });
1140
1322
  export {
1141
1323
  Accordion,
1142
1324
  AccordionItem,
@@ -1170,6 +1352,7 @@ export {
1170
1352
  DrawerFooter,
1171
1353
  DrawerHeader,
1172
1354
  Dropdown,
1355
+ DropdownGroup,
1173
1356
  DropdownItem,
1174
1357
  DropdownMenu,
1175
1358
  DropdownSeparator,
@@ -1183,6 +1366,7 @@ export {
1183
1366
  Kbd,
1184
1367
  Menu,
1185
1368
  MenuItem,
1369
+ MenuSubmenu,
1186
1370
  Modal,
1187
1371
  ModalBody,
1188
1372
  ModalFooter,
@@ -1203,19 +1387,14 @@ export {
1203
1387
  Tab,
1204
1388
  TabList,
1205
1389
  TabPanel,
1390
+ Table,
1206
1391
  Tabs,
1207
1392
  Textarea,
1208
1393
  ToastRegion,
1209
1394
  Toc,
1210
1395
  Tooltip,
1211
1396
  cx,
1212
- useAccordion,
1213
- useDropdown,
1214
1397
  useEnhancer,
1215
1398
  useField,
1216
- useModalGroup,
1217
- useTabs,
1218
- useToast,
1219
- useTocEnhancer,
1220
- useTooltip
1399
+ useToast
1221
1400
  };