@hydrateless/react 0.6.0 → 0.8.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.
package/README.md CHANGED
@@ -10,7 +10,7 @@ enhancers, with automatic cleanup on unmount.
10
10
  npm install hydrateless @hydrateless/react
11
11
  ```
12
12
 
13
- Import the CSS once (e.g. in your root):
13
+ Import the CSS once (e.g., in your root):
14
14
 
15
15
  ```ts
16
16
  import 'hydrateless/hydrateless.css';
@@ -59,7 +59,7 @@ const [open, setOpen] = useState(false);
59
59
 
60
60
  ### Toasts
61
61
 
62
- `useToast()` works anywhere — no provider required. Render `<ToastRegion />`
62
+ `useToast()` works anywhere, no provider required. Render `<ToastRegion />`
63
63
  once if you want to control where toasts appear:
64
64
 
65
65
  ```tsx
@@ -90,7 +90,7 @@ function CustomTabs() {
90
90
  ```
91
91
 
92
92
  Convenience hooks: `useTabs`, `useDropdown`, `useTooltip`, `useAccordion`,
93
- `useDisclosureGroup`, `useModalGroup`, `useTocEnhancer`.
93
+ `useModalGroup`, `useTocEnhancer`.
94
94
 
95
95
  ## License
96
96
 
package/dist/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import * as react from 'react';
2
2
  import { DependencyList, RefObject, HTMLAttributes, ReactNode, ButtonHTMLAttributes, LiHTMLAttributes, AnchorHTMLAttributes, ReactElement, InputHTMLAttributes, TextareaHTMLAttributes, SelectHTMLAttributes, LabelHTMLAttributes, ProgressHTMLAttributes } from 'react';
3
3
  import * as _hydrateless_enhancers from '@hydrateless/enhancers';
4
- import { EnhancerHandle, AccordionApi, DropdownApi, TabsApi, EnhanceTocOptions, TooltipApi, EnhanceTabsOptions, EnhanceDropdownOptions, EnhanceMenuOptions, ToastApi, EnhanceComboboxOptions } from '@hydrateless/enhancers';
5
- export { AccordionApi, ComboboxApi, Disposer, DrawerApi, DropdownApi, EnhancerHandle, ModalApi, PopoverApi, TabsApi, ToastApi, TooltipApi } from '@hydrateless/enhancers';
4
+ import { EnhancerHandle, AccordionApi, DropdownApi, TabsApi, EnhanceTocOptions, TocApi, TooltipApi, EnhanceTabsOptions, EnhanceDropdownOptions, EnhanceMenuOptions, ToastApi, EnhanceComboboxOptions } from '@hydrateless/enhancers';
5
+ export { AccordionApi, ComboboxApi, CommandApi, DisclosureApi, Disposer, DrawerApi, DropdownApi, EnhancerHandle, MenuApi, ModalApi, PopoverApi, TabsApi, ToastApi, TocApi, TooltipApi } from '@hydrateless/enhancers';
6
6
 
7
7
  /**
8
8
  * Attach any Hydrateless enhancer to a DOM node for the lifetime of a
@@ -42,11 +42,6 @@ declare const useAccordion: <T extends HTMLElement = HTMLDivElement>(allowMultip
42
42
  ref: react.RefObject<T | null>;
43
43
  api: react.RefObject<AccordionApi | null>;
44
44
  };
45
- /** Ref hook that groups `[data-hl-disclosure]` elements for mutual exclusivity. */
46
- declare const useDisclosureGroup: <T extends HTMLElement = HTMLElement>(allowMultiple?: boolean) => {
47
- ref: react.RefObject<T | null>;
48
- api: react.RefObject<null>;
49
- };
50
45
  /** Ref hook that wires modal openers/closers + focus trap within a container. */
51
46
  declare const useModalGroup: <T extends HTMLElement = HTMLElement>(closeOnBackdrop?: boolean) => {
52
47
  ref: react.RefObject<T | null>;
@@ -55,9 +50,10 @@ declare const useModalGroup: <T extends HTMLElement = HTMLElement>(closeOnBackdr
55
50
  /** Ref hook that builds a table of contents from the surrounding document. */
56
51
  declare const useTocEnhancer: <T extends HTMLElement = HTMLElement>(options?: EnhanceTocOptions) => {
57
52
  ref: react.RefObject<T | null>;
58
- api: react.RefObject<null>;
53
+ api: react.RefObject<TocApi | null>;
59
54
  };
60
55
 
56
+ /** Props for {@link Accordion}. */
61
57
  interface AccordionProps extends HTMLAttributes<HTMLDivElement> {
62
58
  /** Allow more than one panel to stay open at a time. */
63
59
  allowMultiple?: boolean;
@@ -75,26 +71,40 @@ interface AccordionProps extends HTMLAttributes<HTMLDivElement> {
75
71
  * (`value` + `onValueChange`).
76
72
  */
77
73
  declare function Accordion({ allowMultiple, value, defaultValue, onValueChange, children, ...rest }: AccordionProps): react.JSX.Element;
74
+ /** Props for {@link AccordionItem}. */
78
75
  interface AccordionItemProps extends Omit<HTMLAttributes<HTMLDetailsElement>, 'title'> {
79
76
  summary: ReactNode;
80
77
  /** Stable value identifying this item; defaults to its index. */
81
78
  value?: string;
82
79
  defaultOpen?: boolean;
83
80
  }
81
+ /** A single collapsible item within an {@link Accordion}, rendered as a native `<details>`. */
84
82
  declare function AccordionItem({ summary, value, defaultOpen, children, ...rest }: AccordionItemProps): react.JSX.Element;
85
83
 
84
+ /** Props for {@link Disclosure}. */
86
85
  interface DisclosureProps extends Omit<HTMLAttributes<HTMLDetailsElement>, 'title'> {
87
86
  summary: ReactNode;
87
+ /** Controlled open state (pair with `onOpenChange`). */
88
+ open?: boolean;
89
+ /** Open the disclosure initially for uncontrolled usage. */
88
90
  defaultOpen?: boolean;
91
+ /** Called after the disclosure opens or closes. */
92
+ onOpenChange?: (open: boolean) => void;
93
+ /**
94
+ * Group name. Disclosures sharing a `name` are exclusive: the browser closes
95
+ * the others when one opens, with no JavaScript.
96
+ */
97
+ name?: string;
89
98
  }
90
99
  /**
91
- * A single expandable section. Purely presentational — native `<details>`
92
- * handles open/close, so no enhancer is required for a lone disclosure. Use
93
- * `useEnhancer(enhanceDisclosure)` on a wrapper if you need a mutually
94
- * exclusive group.
100
+ * A single expandable section built on native `<details>`, which handles
101
+ * open/close (and exclusive groups, via the `name` attribute) on its own.
102
+ * Open state works uncontrolled (`defaultOpen`) or controlled (`open` +
103
+ * `onOpenChange`).
95
104
  */
96
- declare function Disclosure({ summary, defaultOpen, className, children, ...rest }: DisclosureProps): react.JSX.Element;
105
+ declare function Disclosure({ summary, open, defaultOpen, onOpenChange, name, className, children, ...rest }: DisclosureProps): react.JSX.Element;
97
106
 
107
+ /** Props for {@link Tabs}. */
98
108
  interface TabsProps extends HTMLAttributes<HTMLDivElement> {
99
109
  /** `manual` (default): arrows move focus, Enter/Space activates. `automatic`: arrows activate immediately. */
100
110
  activation?: EnhanceTabsOptions['activation'];
@@ -125,19 +135,23 @@ interface TabsProps extends HTMLAttributes<HTMLDivElement> {
125
135
  * ```
126
136
  */
127
137
  declare function Tabs({ activation, orientation, value, defaultValue, onValueChange, children, ...rest }: TabsProps): react.JSX.Element;
138
+ /** Props for {@link TabList}. */
128
139
  type TabListProps = HTMLAttributes<HTMLDivElement>;
129
140
  /** The row of tab triggers. Renders `role="tablist"`. */
130
141
  declare function TabList({ children, ...rest }: TabListProps): react.JSX.Element;
142
+ /** Props for {@link Tab}. */
131
143
  interface TabProps extends ButtonHTMLAttributes<HTMLButtonElement> {
132
144
  /** Stable value identifying this tab; defaults to its index. */
133
145
  value?: string;
134
146
  }
135
147
  /** A single tab trigger. Renders `role="tab"`. */
136
148
  declare function Tab({ children, type, value, ...rest }: TabProps): react.JSX.Element;
149
+ /** Props for {@link TabPanel}. */
137
150
  type TabPanelProps = HTMLAttributes<HTMLDivElement>;
138
151
  /** Content for the matching tab. Renders `role="tabpanel"`. */
139
152
  declare function TabPanel({ children, ...rest }: TabPanelProps): react.JSX.Element;
140
153
 
154
+ /** Props for {@link Dropdown}. */
141
155
  interface DropdownProps extends HTMLAttributes<HTMLDivElement> {
142
156
  placement?: EnhanceDropdownOptions['placement'];
143
157
  /** Controlled open state (pair with `onOpenChange`). */
@@ -165,29 +179,39 @@ interface DropdownProps extends HTMLAttributes<HTMLDivElement> {
165
179
  * ```
166
180
  */
167
181
  declare function Dropdown({ placement, open, defaultOpen, onOpenChange, children, ...rest }: DropdownProps): react.JSX.Element;
182
+ /** Props for {@link DropdownTrigger}. */
168
183
  type DropdownTriggerProps = ButtonHTMLAttributes<HTMLButtonElement>;
169
184
  /** The button that opens the menu. */
170
185
  declare function DropdownTrigger({ children, type, ...rest }: DropdownTriggerProps): react.JSX.Element;
186
+ /** Props for {@link DropdownMenu}. */
171
187
  type DropdownMenuProps = HTMLAttributes<HTMLUListElement>;
172
188
  /** The menu surface; holds `<DropdownItem>` and `<DropdownSeparator>`. */
173
189
  declare function DropdownMenu({ children, ...rest }: DropdownMenuProps): react.JSX.Element;
190
+ /** Props for {@link DropdownItem}. */
174
191
  interface DropdownItemProps extends ButtonHTMLAttributes<HTMLButtonElement> {
175
192
  /** Convenience handler fired on click; you can also pass `onClick`. */
176
193
  onSelect?: () => void;
177
194
  }
178
195
  /** A selectable menu item (`role="menuitem"`). */
179
196
  declare function DropdownItem({ children, onSelect, onClick, type, ...rest }: DropdownItemProps): react.JSX.Element;
197
+ /** Props for {@link DropdownSeparator}. */
180
198
  type DropdownSeparatorProps = Omit<LiHTMLAttributes<HTMLLIElement>, 'role'>;
181
199
  /** A visual divider between groups of items. */
182
200
  declare function DropdownSeparator(props: DropdownSeparatorProps): react.JSX.Element;
183
201
 
184
- interface MenuProps extends HTMLAttributes<HTMLUListElement> {
202
+ /** Props for {@link Menu}. */
203
+ interface MenuProps extends Omit<HTMLAttributes<HTMLUListElement>, 'onSelect'> {
185
204
  orientation?: EnhanceMenuOptions['orientation'];
205
+ /** Called with the open submenu's value (or `null`) after every change. */
206
+ onOpenChange?: (value: string | null) => void;
207
+ /** Called with the item's value when a leaf menu item is activated. */
208
+ onSelect?: (value: string) => void;
186
209
  }
187
210
  /**
188
- * Menubar / navigation menu with single-level submenus. Compose with
189
- * `<MenuItem>`; nest items by passing a `submenu`. The enhancer wires roving
190
- * tabindex, orientation-aware arrow navigation, and submenu toggling.
211
+ * Menubar / navigation menu with single-level submenus rendered in the top
212
+ * layer. Compose with `<MenuItem>`; nest items by passing a `submenu`. The
213
+ * enhancer wires roving tabindex, orientation-aware arrow navigation, and
214
+ * submenu toggling.
191
215
  *
192
216
  * ```tsx
193
217
  * <Menu orientation="horizontal">
@@ -196,10 +220,13 @@ interface MenuProps extends HTMLAttributes<HTMLUListElement> {
196
220
  * </Menu>
197
221
  * ```
198
222
  */
199
- declare function Menu({ orientation, children, ...rest }: MenuProps): react.JSX.Element;
200
- interface MenuItemProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'href' | 'type'> {
223
+ declare function Menu({ orientation, onOpenChange, onSelect, children, ...rest }: MenuProps): react.JSX.Element;
224
+ /** Props for {@link MenuItem}. */
225
+ interface MenuItemProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'href' | 'type' | 'value'> {
201
226
  /** Render as a link instead of a button. */
202
227
  href?: string;
228
+ /** Stable value identifying this item; defaults to its label text. */
229
+ value?: string;
203
230
  /** Convenience handler fired on activation. */
204
231
  onSelect?: () => void;
205
232
  /** Nested `<MenuItem>`s; renders a single-level submenu. */
@@ -211,20 +238,25 @@ interface MenuItemProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'h
211
238
  * A menu entry. Children are the label; pass `submenu` to nest a flyout. With
212
239
  * `href` it renders an anchor, otherwise a button.
213
240
  */
214
- declare function MenuItem({ href, onSelect, onClick, submenu, anchorProps, children, ...rest }: MenuItemProps): react.JSX.Element;
241
+ declare function MenuItem({ href, value, onSelect, onClick, submenu, anchorProps, children, ...rest }: MenuItemProps): react.JSX.Element;
215
242
 
243
+ /** Props for {@link Modal}. */
216
244
  interface ModalProps extends Omit<HTMLAttributes<HTMLDialogElement>, 'title'> {
217
- open: boolean;
245
+ /** Controlled open state (pair with `onOpenChange`). */
246
+ open?: boolean;
247
+ /** Open the dialog initially for uncontrolled usage. */
248
+ defaultOpen?: boolean;
218
249
  /** Called after the dialog opens or closes (Escape, backdrop, close buttons). */
219
250
  onOpenChange?: (open: boolean) => void;
220
251
  closeOnBackdrop?: boolean;
221
252
  }
222
253
  /**
223
- * Controlled dialog overlay. Driven by the `open` prop via the native
224
- * `<dialog>` element and the modal enhancer, which adds a focus trap, body
225
- * scroll-lock, and a background `inert` barrier. Compose with `<ModalHeader>`,
226
- * `<ModalBody>`, and `<ModalFooter>`. Wire `onOpenChange` so Escape and
227
- * backdrop clicks can update your state.
254
+ * Dialog overlay built on the native `<dialog>` element and the modal
255
+ * enhancer, which adds a focus trap, body scroll-lock, and a background
256
+ * `inert` barrier. Compose with `<ModalHeader>`, `<ModalBody>`, and
257
+ * `<ModalFooter>`. Open state works uncontrolled (`defaultOpen`, or a
258
+ * `command="show-modal"` invoker button) or controlled (`open` +
259
+ * `onOpenChange`).
228
260
  *
229
261
  * ```tsx
230
262
  * <Modal open={open} onOpenChange={setOpen}>
@@ -234,7 +266,8 @@ interface ModalProps extends Omit<HTMLAttributes<HTMLDialogElement>, 'title'> {
234
266
  * </Modal>
235
267
  * ```
236
268
  */
237
- declare function Modal({ open, onOpenChange, closeOnBackdrop, className, children, ...rest }: ModalProps): react.JSX.Element;
269
+ declare function Modal({ open, defaultOpen, onOpenChange, closeOnBackdrop, className, children, ...rest }: ModalProps): react.JSX.Element;
270
+ /** Props shared by the {@link Modal} section components. */
238
271
  type ModalSectionProps = HTMLAttributes<HTMLDivElement>;
239
272
  /** Modal heading region; its content labels the dialog for assistive tech. */
240
273
  declare function ModalHeader({ className, ...rest }: ModalSectionProps): react.JSX.Element;
@@ -243,20 +276,27 @@ declare function ModalBody({ className, ...rest }: ModalSectionProps): react.JSX
243
276
  /** Modal actions region. */
244
277
  declare function ModalFooter({ className, ...rest }: ModalSectionProps): react.JSX.Element;
245
278
 
279
+ /** Props for {@link Drawer}. */
246
280
  interface DrawerProps extends Omit<HTMLAttributes<HTMLDialogElement>, 'title'> {
247
- open: boolean;
281
+ /** Controlled open state (pair with `onOpenChange`). */
282
+ open?: boolean;
283
+ /** Open the drawer initially for uncontrolled usage. */
284
+ defaultOpen?: boolean;
248
285
  /** Called after the drawer opens or closes (Escape, backdrop, close buttons). */
249
286
  onOpenChange?: (open: boolean) => void;
250
287
  side?: 'left' | 'right';
251
288
  closeOnBackdrop?: boolean;
252
289
  }
253
290
  /**
254
- * Controlled off-canvas panel built on the native `<dialog>` element and the
255
- * drawer enhancer (focus trap, scroll-lock, background `inert`). Mirrors
291
+ * Off-canvas panel built on the native `<dialog>` element and the drawer
292
+ * enhancer (focus trap, scroll-lock, background `inert`). Mirrors
256
293
  * {@link Modal} but slides in from the chosen `side`. Compose with
257
- * `<DrawerHeader>`, `<DrawerBody>`, and `<DrawerFooter>`.
294
+ * `<DrawerHeader>`, `<DrawerBody>`, and `<DrawerFooter>`. Open state works
295
+ * uncontrolled (`defaultOpen`, or an invoker button) or controlled (`open` +
296
+ * `onOpenChange`).
258
297
  */
259
- declare function Drawer({ open, onOpenChange, side, closeOnBackdrop, className, children, ...rest }: DrawerProps): react.JSX.Element;
298
+ declare function Drawer({ open, defaultOpen, onOpenChange, side, closeOnBackdrop, className, children, ...rest }: DrawerProps): react.JSX.Element;
299
+ /** Props shared by the {@link Drawer} section components. */
260
300
  type DrawerSectionProps = HTMLAttributes<HTMLDivElement>;
261
301
  /** Drawer heading region. */
262
302
  declare function DrawerHeader({ className, ...rest }: DrawerSectionProps): react.JSX.Element;
@@ -265,20 +305,26 @@ declare function DrawerBody({ className, ...rest }: DrawerSectionProps): react.J
265
305
  /** Drawer actions region. */
266
306
  declare function DrawerFooter({ className, ...rest }: DrawerSectionProps): react.JSX.Element;
267
307
 
308
+ /** Props for {@link Popover}. */
268
309
  interface PopoverProps extends HTMLAttributes<HTMLDivElement> {
269
- open: boolean;
270
- /** Called when Escape or an outside click requests dismissal. */
310
+ /** Controlled open state (pair with `onOpenChange`). */
311
+ open?: boolean;
312
+ /** Show the popover initially for uncontrolled usage. */
313
+ defaultOpen?: boolean;
314
+ /** Called when the browser's light-dismiss (Escape or outside click) closes it. */
271
315
  onOpenChange?: (open: boolean) => void;
272
316
  children?: ReactNode;
273
317
  }
274
318
  /**
275
- * Controlled floating content. Visibility follows the `open` prop; wire
276
- * `onOpenChange` to let Escape and outside clicks request dismissal. Pair it
277
- * with your own trigger button (toggling `open`) and position it with the
319
+ * Floating content built on the native Popover API. The surface lives in the
320
+ * top layer with light-dismiss and Escape handled by the browser; visibility
321
+ * works uncontrolled (`defaultOpen`, or a `popovertarget` trigger button) or
322
+ * controlled (`open` + `onOpenChange`). Position it with the
278
323
  * `hydrateless/popover.css` styles.
279
324
  */
280
- declare function Popover({ open, onOpenChange, children, ...rest }: PopoverProps): react.JSX.Element;
325
+ declare function Popover({ open, defaultOpen, onOpenChange, children, ...rest }: PopoverProps): react.JSX.Element;
281
326
 
327
+ /** Props for {@link Tooltip}. */
282
328
  interface TooltipProps {
283
329
  /** The hint text shown on hover/focus. */
284
330
  label: ReactNode;
@@ -292,6 +338,7 @@ interface TooltipProps {
292
338
  */
293
339
  declare function Tooltip({ label, children, id }: TooltipProps): react.JSX.Element;
294
340
 
341
+ /** Props for {@link Breadcrumb}. */
295
342
  type BreadcrumbProps = HTMLAttributes<HTMLElement>;
296
343
  /**
297
344
  * Semantic breadcrumb navigation (`<nav> > <ol>`). CSS-only, no enhancer.
@@ -305,6 +352,7 @@ type BreadcrumbProps = HTMLAttributes<HTMLElement>;
305
352
  * ```
306
353
  */
307
354
  declare function Breadcrumb({ children, ...rest }: BreadcrumbProps): react.JSX.Element;
355
+ /** Props for {@link BreadcrumbItem}. */
308
356
  interface BreadcrumbItemProps extends Omit<LiHTMLAttributes<HTMLLIElement>, 'children'> {
309
357
  href?: string;
310
358
  /** Marks the current page; renders a non-link with `aria-current="page"`. */
@@ -315,18 +363,21 @@ interface BreadcrumbItemProps extends Omit<LiHTMLAttributes<HTMLLIElement>, 'chi
315
363
  /** A single crumb. Renders a link unless `current` (or no `href`) is set. */
316
364
  declare function BreadcrumbItem({ href, current, anchorProps, children, ...rest }: BreadcrumbItemProps): react.JSX.Element;
317
365
 
366
+ /** Props for {@link Switch}. */
318
367
  interface SwitchProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'type'> {
319
368
  children?: ReactNode;
320
369
  }
321
370
  /** Toggle switch built on a native checkbox. CSS-only. */
322
371
  declare function Switch({ children, className, ...rest }: SwitchProps): react.JSX.Element;
323
372
 
373
+ /** Props for {@link SkipLink}. */
324
374
  type SkipLinkProps = AnchorHTMLAttributes<HTMLAnchorElement> & {
325
375
  children?: ReactNode;
326
376
  };
327
377
  /** Accessibility skip-navigation link, visually hidden until focused. */
328
378
  declare function SkipLink({ children, className, ...rest }: SkipLinkProps): react.JSX.Element;
329
379
 
380
+ /** Props for {@link Toc}. */
330
381
  interface TocProps extends HTMLAttributes<HTMLElement> {
331
382
  /** CSS selector for the content root to scan for headings. */
332
383
  contentSelector?: string;
@@ -338,6 +389,7 @@ interface TocProps extends HTMLAttributes<HTMLElement> {
338
389
  /** Auto-generated table of contents with optional scroll-spy. */
339
390
  declare function Toc({ contentSelector, headings, scrollSpy, ...rest }: TocProps): react.JSX.Element;
340
391
 
392
+ /** Props for {@link ToastRegion}. */
341
393
  type ToastRegionProps = HTMLAttributes<HTMLDivElement>;
342
394
  /**
343
395
  * The polite live region toasts render into. Render once near the root of
@@ -351,6 +403,7 @@ declare function ToastRegion(props: ToastRegionProps): react.JSX.Element;
351
403
  */
352
404
  declare function useToast(): ToastApi;
353
405
 
406
+ /** Props for {@link Combobox}. */
354
407
  interface ComboboxProps extends Omit<HTMLAttributes<HTMLDivElement>, 'onChange'> {
355
408
  filter?: EnhanceComboboxOptions['filter'];
356
409
  autoHighlight?: EnhanceComboboxOptions['autoHighlight'];
@@ -379,21 +432,25 @@ interface ComboboxProps extends Omit<HTMLAttributes<HTMLDivElement>, 'onChange'>
379
432
  * ```
380
433
  */
381
434
  declare function Combobox({ filter, autoHighlight, value, defaultValue, onValueChange, children, ...rest }: ComboboxProps): react.JSX.Element;
435
+ /** Props for {@link ComboboxInput}. */
382
436
  interface ComboboxInputProps extends InputHTMLAttributes<HTMLInputElement> {
383
437
  /** Apply the `hl-input` style. Defaults to `true`. */
384
438
  styled?: boolean;
385
439
  }
386
440
  /** The combobox text field. */
387
441
  declare function ComboboxInput({ styled, className, ...rest }: ComboboxInputProps): react.JSX.Element;
442
+ /** Props for {@link ComboboxList}. */
388
443
  type ComboboxListProps = HTMLAttributes<HTMLUListElement>;
389
444
  /** The option popup (`role="listbox"`). */
390
445
  declare function ComboboxList({ children, ...rest }: ComboboxListProps): react.JSX.Element;
446
+ /** Props for {@link ComboboxOption}. */
391
447
  interface ComboboxOptionProps extends Omit<LiHTMLAttributes<HTMLLIElement>, 'value'> {
392
448
  value: string;
393
449
  }
394
450
  /** A selectable option. The `value` is committed on selection. */
395
451
  declare function ComboboxOption({ value, children, ...rest }: ComboboxOptionProps): react.JSX.Element;
396
452
 
453
+ /** Props for {@link Command}. */
397
454
  interface CommandProps extends Omit<HTMLAttributes<HTMLDivElement>, 'onSelect'> {
398
455
  /** Lowercased key that opens the palette's dialog with Cmd/Ctrl. */
399
456
  hotkey?: string;
@@ -407,20 +464,24 @@ interface CommandProps extends Omit<HTMLAttributes<HTMLDivElement>, 'onSelect'>
407
464
  * runs the active item on Enter. Place inside a `<dialog>` to use `hotkey`.
408
465
  */
409
466
  declare function Command({ hotkey, onSelect, children, ...rest }: CommandProps): react.JSX.Element;
467
+ /** Props for {@link CommandInput}. */
410
468
  interface CommandInputProps extends InputHTMLAttributes<HTMLInputElement> {
411
469
  styled?: boolean;
412
470
  }
413
471
  /** The palette search field. */
414
472
  declare function CommandInput({ styled, className, ...rest }: CommandInputProps): react.JSX.Element;
473
+ /** Props for {@link CommandList}. */
415
474
  type CommandListProps = HTMLAttributes<HTMLDivElement>;
416
475
  /** The scrollable list of commands (`role="listbox"`). */
417
476
  declare function CommandList({ children, ...rest }: CommandListProps): react.JSX.Element;
477
+ /** Props for {@link CommandGroup}. */
418
478
  interface CommandGroupProps extends HTMLAttributes<HTMLDivElement> {
419
479
  /** Optional heading shown above the grouped items. */
420
480
  label?: ReactNode;
421
481
  }
422
482
  /** A labelled group of commands. */
423
483
  declare function CommandGroup({ label, children, ...rest }: CommandGroupProps): react.JSX.Element;
484
+ /** Props for {@link CommandItem}. */
424
485
  interface CommandItemProps extends Omit<HTMLAttributes<HTMLDivElement>, 'onSelect'> {
425
486
  value: string;
426
487
  /** Extra search terms for filtering. */
@@ -430,10 +491,12 @@ interface CommandItemProps extends Omit<HTMLAttributes<HTMLDivElement>, 'onSelec
430
491
  }
431
492
  /** A runnable command (`role="option"`). */
432
493
  declare function CommandItem({ value, keywords, icon, children, ...rest }: CommandItemProps): react.JSX.Element;
494
+ /** Props for {@link CommandEmpty}. */
433
495
  type CommandEmptyProps = HTMLAttributes<HTMLDivElement>;
434
496
  /** Shown when no commands match the query. */
435
497
  declare function CommandEmpty({ children, ...rest }: CommandEmptyProps): react.JSX.Element;
436
498
 
499
+ /** Props for {@link Input}. */
437
500
  interface InputProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'size'> {
438
501
  size?: 'sm' | 'md' | 'lg';
439
502
  invalid?: boolean;
@@ -441,17 +504,20 @@ interface InputProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'size'>
441
504
  /** Text input styled with the `hl-input` primitive. */
442
505
  declare const Input: react.ForwardRefExoticComponent<InputProps & react.RefAttributes<HTMLInputElement>>;
443
506
 
507
+ /** Props for {@link Textarea}. */
444
508
  interface TextareaProps extends TextareaHTMLAttributes<HTMLTextAreaElement> {
445
509
  invalid?: boolean;
446
510
  }
447
511
  /** Multi-line text input styled with the `hl-textarea` primitive. */
448
512
  declare const Textarea: react.ForwardRefExoticComponent<TextareaProps & react.RefAttributes<HTMLTextAreaElement>>;
449
513
 
514
+ /** A single option in a {@link Select}. */
450
515
  interface SelectOption {
451
516
  label: ReactNode;
452
517
  value: string;
453
518
  disabled?: boolean;
454
519
  }
520
+ /** Props for {@link Select}. */
455
521
  interface SelectProps extends Omit<SelectHTMLAttributes<HTMLSelectElement>, 'size'> {
456
522
  size?: 'sm' | 'md' | 'lg';
457
523
  invalid?: boolean;
@@ -465,18 +531,21 @@ interface SelectProps extends Omit<SelectHTMLAttributes<HTMLSelectElement>, 'siz
465
531
  */
466
532
  declare const Select: react.ForwardRefExoticComponent<SelectProps & react.RefAttributes<HTMLSelectElement>>;
467
533
 
534
+ /** Props for {@link Checkbox}. */
468
535
  interface CheckboxProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'type'> {
469
536
  children?: ReactNode;
470
537
  }
471
538
  /** Checkbox built on a native `<input type="checkbox">`, label-wrapped. */
472
539
  declare const Checkbox: react.ForwardRefExoticComponent<CheckboxProps & react.RefAttributes<HTMLInputElement>>;
473
540
 
541
+ /** Props for {@link Radio}. */
474
542
  interface RadioProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'type'> {
475
543
  children?: ReactNode;
476
544
  value: string;
477
545
  }
478
546
  /** A single radio built on a native `<input type="radio">`, label-wrapped. */
479
547
  declare const Radio: react.ForwardRefExoticComponent<RadioProps & react.RefAttributes<HTMLInputElement>>;
548
+ /** Props for {@link RadioGroup}. */
480
549
  interface RadioGroupProps extends Omit<HTMLAttributes<HTMLDivElement>, 'onChange'> {
481
550
  name?: string;
482
551
  value?: string;
@@ -488,6 +557,7 @@ interface RadioGroupProps extends Omit<HTMLAttributes<HTMLDivElement>, 'onChange
488
557
  */
489
558
  declare function RadioGroup({ name, value, onValueChange, className, children, ...rest }: RadioGroupProps): react.JSX.Element;
490
559
 
560
+ /** Props for {@link Field}. */
491
561
  interface FieldProps extends HTMLAttributes<HTMLDivElement> {
492
562
  id?: string;
493
563
  invalid?: boolean;
@@ -509,6 +579,7 @@ declare function useField(): {
509
579
  'aria-describedby': string | undefined;
510
580
  'aria-invalid': true | undefined;
511
581
  };
582
+ /** Props for {@link FieldLabel}. */
512
583
  type FieldLabelProps = LabelHTMLAttributes<HTMLLabelElement>;
513
584
  /** Label bound to the enclosing field's control via `htmlFor`. */
514
585
  declare function FieldLabel({ className, children, ...rest }: FieldLabelProps): react.JSX.Element;
@@ -516,17 +587,20 @@ declare function FieldLabel({ className, children, ...rest }: FieldLabelProps):
516
587
  declare function FieldHelp({ className, children, ...rest }: HTMLAttributes<HTMLParagraphElement>): react.JSX.Element;
517
588
  /** Validation message; renders nothing unless given content. */
518
589
  declare function FieldError({ className, children, ...rest }: HTMLAttributes<HTMLParagraphElement>): react.JSX.Element | null;
590
+ /** Props for {@link Fieldset}. */
519
591
  interface FieldsetProps extends HTMLAttributes<HTMLFieldSetElement> {
520
592
  legend?: ReactNode;
521
593
  }
522
594
  /** Grouped fields with an optional legend. */
523
595
  declare function Fieldset({ legend, className, children, ...rest }: FieldsetProps): react.JSX.Element;
524
596
 
597
+ /** A single option in a {@link SegmentedControl}. */
525
598
  interface SegmentedOption {
526
599
  label: ReactNode;
527
600
  value: string;
528
601
  disabled?: boolean;
529
602
  }
603
+ /** Props for {@link SegmentedControl}. */
530
604
  interface SegmentedControlProps extends Omit<HTMLAttributes<HTMLDivElement>, 'onChange'> {
531
605
  options: SegmentedOption[];
532
606
  value?: string;
@@ -536,16 +610,18 @@ interface SegmentedControlProps extends Omit<HTMLAttributes<HTMLDivElement>, 'on
536
610
  size?: 'sm' | 'md' | 'lg';
537
611
  }
538
612
  /**
539
- * Segmented control — `hl-segmented` radiogroup. Controlled via `value` or
613
+ * Segmented control: `hl-segmented` radiogroup. Controlled via `value` or
540
614
  * uncontrolled via `defaultValue`. Built on native radios for free keyboard
541
615
  * navigation.
542
616
  */
543
617
  declare function SegmentedControl({ options, value, defaultValue, onValueChange, name, size, className, ...rest }: SegmentedControlProps): react.JSX.Element;
544
618
 
619
+ /** Props for {@link Slider}. */
545
620
  type SliderProps = Omit<InputHTMLAttributes<HTMLInputElement>, 'type'>;
546
- /** Range slider primitive — `<input type="range" class="hl-slider">`. */
621
+ /** Range slider primitive: `<input type="range" class="hl-slider">`. */
547
622
  declare const Slider: react.ForwardRefExoticComponent<SliderProps & react.RefAttributes<HTMLInputElement>>;
548
623
 
624
+ /** Props for {@link Button}. */
549
625
  interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
550
626
  variant?: 'solid' | 'soft' | 'outline' | 'ghost' | 'link';
551
627
  intent?: 'neutral' | 'primary' | 'danger' | 'success' | 'warning' | 'info';
@@ -557,39 +633,49 @@ interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
557
633
  /** Show a spinner and disable interaction. */
558
634
  loading?: boolean;
559
635
  }
560
- /** Button primitive — `hl-button` with intent/variant/size modifiers. */
636
+ /** Button primitive: `hl-button` with intent/variant/size modifiers. */
561
637
  declare const Button: react.ForwardRefExoticComponent<ButtonProps & react.RefAttributes<HTMLButtonElement>>;
562
638
 
639
+ /** Props for {@link Alert}. */
563
640
  interface AlertProps extends Omit<HTMLAttributes<HTMLDivElement>, 'title'> {
564
641
  intent?: 'info' | 'success' | 'warning' | 'danger' | 'neutral';
565
642
  title?: ReactNode;
566
643
  /** Leading icon, rendered before the body. */
567
644
  icon?: ReactNode;
568
645
  }
569
- /** Alert primitive — `hl-alert` with intent, optional icon + title. */
646
+ /** Alert primitive: `hl-alert` with intent, optional icon + title. */
570
647
  declare const Alert: react.ForwardRefExoticComponent<AlertProps & react.RefAttributes<HTMLDivElement>>;
571
648
 
649
+ /** Props for {@link Badge}. */
572
650
  interface BadgeProps extends HTMLAttributes<HTMLSpanElement> {
573
651
  intent?: 'neutral' | 'primary' | 'danger' | 'success' | 'warning' | 'info';
574
652
  variant?: 'soft' | 'solid' | 'outline';
575
653
  size?: 'sm' | 'md';
576
654
  }
577
- /** Badge primitive — `hl-badge` with intent/variant/size modifiers. */
655
+ /** Badge primitive: `hl-badge` with intent/variant/size modifiers. */
578
656
  declare const Badge: react.ForwardRefExoticComponent<BadgeProps & react.RefAttributes<HTMLSpanElement>>;
579
657
 
658
+ /** Props for {@link Card}. */
580
659
  interface CardProps extends HTMLAttributes<HTMLDivElement> {
581
660
  /** Hover/active elevation for clickable cards. */
582
661
  interactive?: boolean;
583
662
  }
584
- /** Card container — `hl-card`. Compose with the Card.* parts. */
663
+ /** Card container: `hl-card`. Compose with the Card.* parts. */
585
664
  declare const Card: react.ForwardRefExoticComponent<CardProps & react.RefAttributes<HTMLDivElement>>;
665
+ /** Props shared by the {@link Card} section components. */
586
666
  type CardSectionProps = HTMLAttributes<HTMLDivElement>;
667
+ /** Header region of a {@link Card}. */
587
668
  declare const CardHeader: react.ForwardRefExoticComponent<CardSectionProps & react.RefAttributes<HTMLDivElement>>;
669
+ /** Body region of a {@link Card}. */
588
670
  declare const CardBody: react.ForwardRefExoticComponent<CardSectionProps & react.RefAttributes<HTMLDivElement>>;
671
+ /** Footer region of a {@link Card}. */
589
672
  declare const CardFooter: react.ForwardRefExoticComponent<CardSectionProps & react.RefAttributes<HTMLDivElement>>;
673
+ /** Title heading of a {@link Card}. */
590
674
  declare const CardTitle: react.ForwardRefExoticComponent<HTMLAttributes<HTMLHeadingElement> & react.RefAttributes<HTMLHeadingElement>>;
675
+ /** Description text of a {@link Card}. */
591
676
  declare const CardDescription: react.ForwardRefExoticComponent<HTMLAttributes<HTMLParagraphElement> & react.RefAttributes<HTMLParagraphElement>>;
592
677
 
678
+ /** Props for {@link Avatar}. */
593
679
  interface AvatarProps extends HTMLAttributes<HTMLSpanElement> {
594
680
  src?: string;
595
681
  alt?: string;
@@ -598,12 +684,14 @@ interface AvatarProps extends HTMLAttributes<HTMLSpanElement> {
598
684
  size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
599
685
  shape?: 'circle' | 'square';
600
686
  }
601
- /** Avatar primitive — `hl-avatar` with image + graceful fallback. */
687
+ /** Avatar primitive: `hl-avatar` with image + graceful fallback. */
602
688
  declare const Avatar: react.ForwardRefExoticComponent<AvatarProps & react.RefAttributes<HTMLSpanElement>>;
689
+ /** Props for {@link AvatarGroup}. */
603
690
  type AvatarGroupProps = HTMLAttributes<HTMLDivElement>;
604
691
  /** Overlapping stack of avatars. */
605
692
  declare const AvatarGroup: react.ForwardRefExoticComponent<AvatarGroupProps & react.RefAttributes<HTMLDivElement>>;
606
693
 
694
+ /** Props for {@link Progress}. */
607
695
  interface ProgressProps extends Omit<ProgressHTMLAttributes<HTMLProgressElement>, 'value'> {
608
696
  /** Omit for an indeterminate bar. */
609
697
  value?: number;
@@ -611,25 +699,28 @@ interface ProgressProps extends Omit<ProgressHTMLAttributes<HTMLProgressElement>
611
699
  intent?: 'primary' | 'success' | 'warning' | 'danger' | 'info';
612
700
  size?: 'sm' | 'md' | 'lg';
613
701
  }
614
- /** Progress primitive — native `<progress class="hl-progress">`. */
702
+ /** Progress primitive: native `<progress class="hl-progress">`. */
615
703
  declare const Progress: react.ForwardRefExoticComponent<ProgressProps & react.RefAttributes<HTMLProgressElement>>;
616
704
 
705
+ /** Props for {@link Spinner}. */
617
706
  interface SpinnerProps extends HTMLAttributes<HTMLSpanElement> {
618
707
  size?: 'sm' | 'md' | 'lg' | 'xl';
619
708
  /** Accessible label; announced via `role="status"`. */
620
709
  label?: string;
621
710
  }
622
- /** Spinner primitive — `hl-spinner`. Inherits `currentColor`. */
711
+ /** Spinner primitive: `hl-spinner`. Inherits `currentColor`. */
623
712
  declare const Spinner: react.ForwardRefExoticComponent<SpinnerProps & react.RefAttributes<HTMLSpanElement>>;
624
713
 
714
+ /** Props for {@link Skeleton}. */
625
715
  interface SkeletonProps extends HTMLAttributes<HTMLSpanElement> {
626
716
  variant?: 'rect' | 'text' | 'circle';
627
717
  width?: string | number;
628
718
  height?: string | number;
629
719
  }
630
- /** Skeleton placeholder primitive — `hl-skeleton`. */
720
+ /** Skeleton placeholder primitive: `hl-skeleton`. */
631
721
  declare const Skeleton: react.ForwardRefExoticComponent<SkeletonProps & react.RefAttributes<HTMLSpanElement>>;
632
722
 
723
+ /** Props for {@link Pagination}. */
633
724
  interface PaginationProps extends Omit<HTMLAttributes<HTMLElement>, 'onChange'> {
634
725
  page: number;
635
726
  count: number;
@@ -641,22 +732,24 @@ interface PaginationProps extends Omit<HTMLAttributes<HTMLElement>, 'onChange'>
641
732
  prevLabel?: ReactNode;
642
733
  nextLabel?: ReactNode;
643
734
  }
644
- /** Pagination primitive — `hl-pagination` with smart ellipsis truncation. */
735
+ /** Pagination primitive: `hl-pagination` with smart ellipsis truncation. */
645
736
  declare function Pagination({ page, count, onPageChange, siblingCount, showControls, prevLabel, nextLabel, className, ...rest }: PaginationProps): react.JSX.Element;
646
737
 
738
+ /** Props for {@link Kbd}. */
647
739
  type KbdProps = HTMLAttributes<HTMLElement>;
648
- /** Keyboard key primitive — `<kbd class="hl-kbd">`. */
740
+ /** Keyboard key primitive: `<kbd class="hl-kbd">`. */
649
741
  declare const Kbd: react.ForwardRefExoticComponent<KbdProps & react.RefAttributes<HTMLElement>>;
650
742
 
743
+ /** Props for {@link Separator}. */
651
744
  interface SeparatorProps extends HTMLAttributes<HTMLHRElement> {
652
745
  orientation?: 'horizontal' | 'vertical';
653
- /** Purely decorative — removes it from the accessibility tree. */
746
+ /** Purely decorative: removes it from the accessibility tree. */
654
747
  decorative?: boolean;
655
748
  }
656
- /** Separator primitive — `<hr class="hl-separator">`. */
749
+ /** Separator primitive: `<hr class="hl-separator">`. */
657
750
  declare const Separator: react.ForwardRefExoticComponent<SeparatorProps & react.RefAttributes<HTMLHRElement>>;
658
751
 
659
752
  /** Join truthy class names into a single string. */
660
753
  declare function cx(...classes: Array<string | false | null | undefined>): string;
661
754
 
662
- export { Accordion, AccordionItem, type AccordionItemProps, type AccordionProps, Alert, type AlertProps, Avatar, AvatarGroup, type AvatarGroupProps, type AvatarProps, Badge, type BadgeProps, Breadcrumb, BreadcrumbItem, type BreadcrumbItemProps, type BreadcrumbProps, Button, type ButtonProps, Card, CardBody, CardDescription, CardFooter, CardHeader, type CardProps, type CardSectionProps, CardTitle, Checkbox, type CheckboxProps, Combobox, ComboboxInput, type ComboboxInputProps, ComboboxList, type ComboboxListProps, ComboboxOption, type ComboboxOptionProps, type ComboboxProps, Command, CommandEmpty, type CommandEmptyProps, CommandGroup, type CommandGroupProps, CommandInput, type CommandInputProps, CommandItem, type CommandItemProps, CommandList, type CommandListProps, type CommandProps, Disclosure, type DisclosureProps, Drawer, DrawerBody, DrawerFooter, DrawerHeader, type DrawerProps, type DrawerSectionProps, Dropdown, DropdownItem, type DropdownItemProps, DropdownMenu, type DropdownMenuProps, type DropdownProps, DropdownSeparator, type DropdownSeparatorProps, DropdownTrigger, type DropdownTriggerProps, Field, FieldError, FieldHelp, FieldLabel, type FieldLabelProps, type FieldProps, Fieldset, type FieldsetProps, Input, type InputProps, Kbd, type KbdProps, Menu, MenuItem, type MenuItemProps, type MenuProps, Modal, ModalBody, ModalFooter, ModalHeader, type ModalProps, type ModalSectionProps, Pagination, type PaginationProps, Popover, type PopoverProps, Progress, type ProgressProps, Radio, RadioGroup, type RadioGroupProps, type RadioProps, SegmentedControl, type SegmentedControlProps, type SegmentedOption, Select, type SelectOption, type SelectProps, Separator, type SeparatorProps, Skeleton, type SkeletonProps, SkipLink, type SkipLinkProps, Slider, type SliderProps, Spinner, type SpinnerProps, Switch, type SwitchProps, Tab, TabList, type TabListProps, TabPanel, type TabPanelProps, type TabProps, Tabs, type TabsProps, Textarea, type TextareaProps, ToastRegion, type ToastRegionProps, Toc, type TocProps, Tooltip, type TooltipProps, cx, useAccordion, useDisclosureGroup, useDropdown, useEnhancer, useField, useModalGroup, useTabs, useToast, useTocEnhancer, useTooltip };
755
+ export { Accordion, AccordionItem, type AccordionItemProps, type AccordionProps, Alert, type AlertProps, Avatar, AvatarGroup, type AvatarGroupProps, type AvatarProps, Badge, type BadgeProps, Breadcrumb, BreadcrumbItem, type BreadcrumbItemProps, type BreadcrumbProps, Button, type ButtonProps, Card, CardBody, CardDescription, CardFooter, CardHeader, type CardProps, type CardSectionProps, CardTitle, Checkbox, type CheckboxProps, Combobox, ComboboxInput, type ComboboxInputProps, ComboboxList, type ComboboxListProps, ComboboxOption, type ComboboxOptionProps, type ComboboxProps, Command, CommandEmpty, type CommandEmptyProps, CommandGroup, type CommandGroupProps, CommandInput, type CommandInputProps, CommandItem, type CommandItemProps, CommandList, type CommandListProps, type CommandProps, Disclosure, type DisclosureProps, Drawer, DrawerBody, DrawerFooter, DrawerHeader, type DrawerProps, type DrawerSectionProps, Dropdown, DropdownItem, type DropdownItemProps, DropdownMenu, type DropdownMenuProps, type DropdownProps, DropdownSeparator, type DropdownSeparatorProps, DropdownTrigger, type DropdownTriggerProps, Field, FieldError, FieldHelp, FieldLabel, type FieldLabelProps, type FieldProps, Fieldset, type FieldsetProps, Input, type InputProps, Kbd, type KbdProps, Menu, MenuItem, type MenuItemProps, type MenuProps, Modal, ModalBody, ModalFooter, ModalHeader, type ModalProps, type ModalSectionProps, Pagination, type PaginationProps, Popover, type PopoverProps, Progress, type ProgressProps, Radio, RadioGroup, type RadioGroupProps, type RadioProps, SegmentedControl, type SegmentedControlProps, type SegmentedOption, Select, type SelectOption, type SelectProps, Separator, type SeparatorProps, Skeleton, type SkeletonProps, SkipLink, type SkipLinkProps, Slider, type SliderProps, Spinner, type SpinnerProps, Switch, type SwitchProps, Tab, TabList, type TabListProps, TabPanel, type TabPanelProps, type TabProps, Tabs, type TabsProps, Textarea, type TextareaProps, ToastRegion, type ToastRegionProps, Toc, type TocProps, Tooltip, type TooltipProps, cx, useAccordion, useDropdown, useEnhancer, useField, useModalGroup, useTabs, useToast, useTocEnhancer, useTooltip };
package/dist/index.js CHANGED
@@ -19,7 +19,6 @@ function useEnhancer(enhance, deps = []) {
19
19
  // src/hooks.ts
20
20
  import {
21
21
  enhanceAccordion,
22
- enhanceDisclosure,
23
22
  enhanceDropdown,
24
23
  enhanceModal,
25
24
  enhanceTabs,
@@ -30,7 +29,6 @@ var useTabs = () => useEnhancer((el) => enhanceTabs(el));
30
29
  var useDropdown = () => useEnhancer((el) => enhanceDropdown(el));
31
30
  var useTooltip = () => useEnhancer((el) => enhanceTooltip(el));
32
31
  var useAccordion = (allowMultiple = false) => useEnhancer((el) => enhanceAccordion(el, { allowMultiple }), [allowMultiple]);
33
- var useDisclosureGroup = (allowMultiple = false) => useEnhancer((el) => enhanceDisclosure(el, { allowMultiple }), [allowMultiple]);
34
32
  var useModalGroup = (closeOnBackdrop = true) => useEnhancer((el) => enhanceModal(el, { closeOnBackdrop }), [closeOnBackdrop]);
35
33
  var useTocEnhancer = (options) => useEnhancer(
36
34
  (el) => enhanceToc(el.ownerDocument, options),
@@ -95,23 +93,45 @@ function AccordionItem({
95
93
  }
96
94
 
97
95
  // src/Disclosure.tsx
98
- import { useEffect as useEffect3, useRef as useRef4 } from "react";
96
+ import { useEffect as useEffect3 } from "react";
97
+ import { enhanceDisclosure } from "@hydrateless/enhancers";
99
98
  import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
100
99
  function Disclosure({
101
100
  summary,
102
- defaultOpen = false,
101
+ open,
102
+ defaultOpen,
103
+ onOpenChange,
104
+ name,
103
105
  className,
104
106
  children,
105
107
  ...rest
106
108
  }) {
107
- const ref = useRef4(null);
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
+ );
108
118
  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
- ] });
119
+ if (open != null) api.current?.setOpen(open);
120
+ }, [open, api]);
121
+ return /* @__PURE__ */ jsxs2(
122
+ "details",
123
+ {
124
+ ...rest,
125
+ name,
126
+ className: cx("hl-disclosure", className),
127
+ "data-hl-disclosure": true,
128
+ ref,
129
+ children: [
130
+ /* @__PURE__ */ jsx2("summary", { children: summary }),
131
+ /* @__PURE__ */ jsx2("div", { className: "hl-disclosure-panel", children })
132
+ ]
133
+ }
134
+ );
115
135
  }
116
136
 
117
137
  // src/Tabs.tsx
@@ -210,18 +230,25 @@ function DropdownSeparator(props) {
210
230
  }
211
231
 
212
232
  // src/Menu.tsx
213
- import {
214
- useEffect as useEffect6,
215
- useRef as useRef5
216
- } from "react";
217
233
  import { enhanceMenu } from "@hydrateless/enhancers";
218
234
  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]);
235
+ function Menu({
236
+ orientation = "horizontal",
237
+ onOpenChange,
238
+ onSelect,
239
+ children,
240
+ ...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
+ }),
250
+ [orientation]
251
+ );
225
252
  return /* @__PURE__ */ jsx5(
226
253
  "ul",
227
254
  {
@@ -236,6 +263,7 @@ function Menu({ orientation = "horizontal", children, ...rest }) {
236
263
  }
237
264
  function MenuItem({
238
265
  href,
266
+ value,
239
267
  onSelect,
240
268
  onClick,
241
269
  submenu,
@@ -245,12 +273,13 @@ function MenuItem({
245
273
  }) {
246
274
  const hasSubmenu = submenu != null;
247
275
  return /* @__PURE__ */ jsxs3("li", { role: "none", children: [
248
- href && !hasSubmenu ? /* @__PURE__ */ jsx5("a", { ...anchorProps, role: "menuitem", href, children }) : /* @__PURE__ */ jsx5(
276
+ href && !hasSubmenu ? /* @__PURE__ */ jsx5("a", { ...anchorProps, role: "menuitem", href, "data-hl-value": value, children }) : /* @__PURE__ */ jsx5(
249
277
  "button",
250
278
  {
251
279
  ...rest,
252
280
  type: "button",
253
281
  role: "menuitem",
282
+ "data-hl-value": value,
254
283
  onClick: (e) => {
255
284
  onSelect?.();
256
285
  onClick?.(e);
@@ -263,11 +292,12 @@ function MenuItem({
263
292
  }
264
293
 
265
294
  // src/Modal.tsx
266
- import { useEffect as useEffect7 } from "react";
295
+ import { useEffect as useEffect6 } from "react";
267
296
  import { enhanceModal as enhanceModal2 } from "@hydrateless/enhancers";
268
297
  import { jsx as jsx6 } from "react/jsx-runtime";
269
298
  function Modal({
270
299
  open,
300
+ defaultOpen,
271
301
  onOpenChange,
272
302
  closeOnBackdrop = true,
273
303
  className,
@@ -275,15 +305,17 @@ function Modal({
275
305
  ...rest
276
306
  }) {
277
307
  const onOpenChangeRef = useLatest(onOpenChange);
308
+ const initialOpenRef = useLatest(open ?? defaultOpen);
278
309
  const { ref, api } = useEnhancer(
279
310
  (el) => enhanceModal2(el, {
280
311
  closeOnBackdrop,
312
+ defaultOpen: initialOpenRef.current,
281
313
  onOpenChange: (next) => onOpenChangeRef.current?.(next)
282
314
  }),
283
315
  [closeOnBackdrop]
284
316
  );
285
- useEffect7(() => {
286
- api.current?.setOpen(open);
317
+ useEffect6(() => {
318
+ if (open != null) api.current?.setOpen(open);
287
319
  }, [open, api]);
288
320
  return /* @__PURE__ */ jsx6("dialog", { ...rest, ref, "data-hl-modal": true, className: cx("hl-modal", className), children });
289
321
  }
@@ -298,11 +330,12 @@ function ModalFooter({ className, ...rest }) {
298
330
  }
299
331
 
300
332
  // src/Drawer.tsx
301
- import { useEffect as useEffect8 } from "react";
333
+ import { useEffect as useEffect7 } from "react";
302
334
  import { enhanceDrawer } from "@hydrateless/enhancers";
303
335
  import { jsx as jsx7 } from "react/jsx-runtime";
304
336
  function Drawer({
305
337
  open,
338
+ defaultOpen,
306
339
  onOpenChange,
307
340
  side = "right",
308
341
  closeOnBackdrop = true,
@@ -311,15 +344,17 @@ function Drawer({
311
344
  ...rest
312
345
  }) {
313
346
  const onOpenChangeRef = useLatest(onOpenChange);
347
+ const initialOpenRef = useLatest(open ?? defaultOpen);
314
348
  const { ref, api } = useEnhancer(
315
349
  (el) => enhanceDrawer(el, {
316
350
  closeOnBackdrop,
351
+ defaultOpen: initialOpenRef.current,
317
352
  onOpenChange: (next) => onOpenChangeRef.current?.(next)
318
353
  }),
319
354
  [closeOnBackdrop]
320
355
  );
321
- useEffect8(() => {
322
- api.current?.setOpen(open);
356
+ useEffect7(() => {
357
+ if (open != null) api.current?.setOpen(open);
323
358
  }, [open, api]);
324
359
  return /* @__PURE__ */ jsx7(
325
360
  "dialog",
@@ -344,36 +379,40 @@ function DrawerFooter({ className, ...rest }) {
344
379
  }
345
380
 
346
381
  // src/Popover.tsx
347
- import { useEffect as useEffect9, useRef as useRef6 } from "react";
348
- import { onClickOutside, onEscape, combine } from "@hydrateless/enhancers";
382
+ import { useEffect as useEffect8 } from "react";
383
+ import { enhancePopover } from "@hydrateless/enhancers";
349
384
  import { jsx as jsx8 } from "react/jsx-runtime";
350
- function Popover({ open, onOpenChange, children, ...rest }) {
351
- const ref = useRef6(null);
385
+ function Popover({ open, defaultOpen, onOpenChange, children, ...rest }) {
352
386
  const onOpenChangeRef = useLatest(onOpenChange);
353
- useEffect9(() => {
354
- const el = ref.current;
355
- if (!el || !open) return;
356
- const dismiss = () => onOpenChangeRef.current?.(false);
357
- return combine([onClickOutside(el, dismiss), onEscape(dismiss, el.ownerDocument)]);
358
- }, [open, onOpenChangeRef]);
359
- return /* @__PURE__ */ jsx8("div", { ...rest, ref, "data-hl-popover": true, role: "dialog", hidden: !open, children });
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
+ []
394
+ );
395
+ useEffect8(() => {
396
+ if (open != null) api.current?.setOpen(open);
397
+ }, [open, api]);
398
+ return /* @__PURE__ */ jsx8("div", { ...rest, ref, "data-hl-popover": true, popover: "auto", role: "dialog", children });
360
399
  }
361
400
 
362
401
  // src/Tooltip.tsx
363
402
  import {
364
403
  cloneElement,
365
404
  isValidElement,
366
- useEffect as useEffect10,
405
+ useEffect as useEffect9,
367
406
  useId,
368
- useRef as useRef7
407
+ useRef as useRef4
369
408
  } from "react";
370
409
  import { enhanceTooltip as enhanceTooltip2 } from "@hydrateless/enhancers";
371
410
  import { jsx as jsx9, jsxs as jsxs4 } from "react/jsx-runtime";
372
411
  function Tooltip({ label, children, id }) {
373
412
  const generatedId = useId().replace(/:/g, "");
374
413
  const tipId = id ?? `hl-tip-${generatedId}`;
375
- const ref = useRef7(null);
376
- useEffect10(() => {
414
+ const ref = useRef4(null);
415
+ useEffect9(() => {
377
416
  if (!ref.current) return;
378
417
  return enhanceTooltip2(ref.current).destroy;
379
418
  }, [tipId]);
@@ -418,12 +457,12 @@ function SkipLink({ children = "Skip to content", className, ...rest }) {
418
457
  }
419
458
 
420
459
  // src/Toc.tsx
421
- import { useEffect as useEffect11, useRef as useRef8 } from "react";
460
+ import { useEffect as useEffect10, useRef as useRef5 } from "react";
422
461
  import { enhanceToc as enhanceToc2 } from "@hydrateless/enhancers";
423
462
  import { jsx as jsx13 } from "react/jsx-runtime";
424
463
  function Toc({ contentSelector, headings, scrollSpy, ...rest }) {
425
- const ref = useRef8(null);
426
- useEffect11(() => {
464
+ const ref = useRef5(null);
465
+ useEffect10(() => {
427
466
  if (!ref.current) return;
428
467
  return enhanceToc2(ref.current.ownerDocument, { contentSelector, headings, scrollSpy }).destroy;
429
468
  }, [contentSelector, headings, scrollSpy]);
@@ -431,7 +470,7 @@ function Toc({ contentSelector, headings, scrollSpy, ...rest }) {
431
470
  }
432
471
 
433
472
  // src/Toast.tsx
434
- import { useEffect as useEffect12, useRef as useRef9 } from "react";
473
+ import { useEffect as useEffect11, useRef as useRef6 } from "react";
435
474
  import { enhanceToast } from "@hydrateless/enhancers";
436
475
  import { jsx as jsx14 } from "react/jsx-runtime";
437
476
  var sharedApi = null;
@@ -447,8 +486,8 @@ var facade = {
447
486
  dismiss: (toast) => ensureApi().dismiss(toast)
448
487
  };
449
488
  function ToastRegion(props) {
450
- const ref = useRef9(null);
451
- useEffect12(() => {
489
+ const ref = useRef6(null);
490
+ useEffect11(() => {
452
491
  if (!ref.current) return;
453
492
  const handle = enhanceToast(ref.current.ownerDocument);
454
493
  sharedApi = handle.api;
@@ -465,7 +504,7 @@ function useToast() {
465
504
 
466
505
  // src/Combobox.tsx
467
506
  import {
468
- useEffect as useEffect13
507
+ useEffect as useEffect12
469
508
  } from "react";
470
509
  import {
471
510
  enhanceCombobox
@@ -491,7 +530,7 @@ function Combobox({
491
530
  }),
492
531
  [filter, autoHighlight]
493
532
  );
494
- useEffect13(() => {
533
+ useEffect12(() => {
495
534
  if (value != null) api.current?.setValue(value);
496
535
  }, [value, api]);
497
536
  return /* @__PURE__ */ jsx15("div", { ...rest, ref, "data-hl-combobox": true, children });
@@ -508,16 +547,16 @@ function ComboboxOption({ value, children, ...rest }) {
508
547
 
509
548
  // src/Command.tsx
510
549
  import {
511
- useEffect as useEffect14,
512
- useRef as useRef10
550
+ useEffect as useEffect13,
551
+ useRef as useRef7
513
552
  } from "react";
514
553
  import { enhanceCommand } from "@hydrateless/enhancers";
515
554
  import { jsx as jsx16, jsxs as jsxs6 } from "react/jsx-runtime";
516
555
  function Command({ hotkey, onSelect, children, ...rest }) {
517
- const ref = useRef10(null);
518
- const onSelectRef = useRef10(onSelect);
556
+ const ref = useRef7(null);
557
+ const onSelectRef = useRef7(onSelect);
519
558
  onSelectRef.current = onSelect;
520
- useEffect14(() => {
559
+ useEffect13(() => {
521
560
  const el = ref.current;
522
561
  if (!el) return;
523
562
  const handle = enhanceCommand(el, {
@@ -683,9 +722,7 @@ function Field({
683
722
  helpId: `${baseId}-help`,
684
723
  errorId: `${baseId}-error`,
685
724
  invalid,
686
- required,
687
- hasHelp: true,
688
- hasError: invalid
725
+ required
689
726
  };
690
727
  return /* @__PURE__ */ jsx22(FieldContext.Provider, { value, children: /* @__PURE__ */ jsx22(
691
728
  "div",
@@ -704,7 +741,7 @@ function useFieldContext(component) {
704
741
  }
705
742
  function useField() {
706
743
  const ctx = useFieldContext("useField");
707
- const describedBy = [ctx.hasHelp ? ctx.helpId : null, ctx.invalid ? ctx.errorId : null].filter(Boolean).join(" ");
744
+ const describedBy = [ctx.helpId, ctx.invalid ? ctx.errorId : null].filter(Boolean).join(" ");
708
745
  return {
709
746
  id: ctx.id,
710
747
  "aria-describedby": describedBy || void 0,
@@ -1173,7 +1210,6 @@ export {
1173
1210
  Tooltip,
1174
1211
  cx,
1175
1212
  useAccordion,
1176
- useDisclosureGroup,
1177
1213
  useDropdown,
1178
1214
  useEnhancer,
1179
1215
  useField,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@hydrateless/react",
3
- "version": "0.6.0",
4
- "description": "React bindings for Hydrateless — hooks and components that wire the framework-agnostic enhancers.",
3
+ "version": "0.8.0",
4
+ "description": "React bindings for Hydrateless: hooks and components that wire the framework-agnostic enhancers.",
5
5
  "license": "MIT",
6
6
  "repository": {
7
7
  "type": "git",
@@ -28,7 +28,7 @@
28
28
  "test": "vitest run"
29
29
  },
30
30
  "dependencies": {
31
- "@hydrateless/enhancers": "^0.6.0"
31
+ "@hydrateless/enhancers": "^0.8.0"
32
32
  },
33
33
  "peerDependencies": {
34
34
  "react": ">=18"