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