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