@hydrateless/react 0.4.0 → 0.5.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 (3) hide show
  1. package/dist/index.d.ts +212 -87
  2. package/dist/index.js +269 -197
  3. package/package.json +2 -2
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as react from 'react';
2
- import { DependencyList, RefObject, HTMLAttributes, ReactNode, ReactElement, InputHTMLAttributes, AnchorHTMLAttributes, TextareaHTMLAttributes, SelectHTMLAttributes, LabelHTMLAttributes, ButtonHTMLAttributes, ProgressHTMLAttributes } from 'react';
3
- import { Disposer, EnhanceTocOptions, ToastApi } from '@hydrateless/enhancers';
2
+ import { DependencyList, RefObject, HTMLAttributes, ReactNode, ButtonHTMLAttributes, LiHTMLAttributes, AnchorHTMLAttributes, ReactElement, InputHTMLAttributes, TextareaHTMLAttributes, SelectHTMLAttributes, LabelHTMLAttributes, ProgressHTMLAttributes } from 'react';
3
+ import { Disposer, EnhanceTocOptions, EnhanceTabsOptions, EnhanceDropdownOptions, EnhanceMenuOptions, ToastApi, EnhanceComboboxOptions } from '@hydrateless/enhancers';
4
4
  export { Disposer } from '@hydrateless/enhancers';
5
5
 
6
6
  /**
@@ -54,62 +54,154 @@ interface DisclosureProps extends Omit<HTMLAttributes<HTMLDetailsElement>, 'titl
54
54
  */
55
55
  declare function Disclosure({ summary, defaultOpen, children, ...rest }: DisclosureProps): react.JSX.Element;
56
56
 
57
- interface TabItem {
58
- label: ReactNode;
59
- content: ReactNode;
60
- }
61
57
  interface TabsProps extends HTMLAttributes<HTMLDivElement> {
62
- items: TabItem[];
58
+ /** `manual` (default): arrows move focus, Enter/Space activates. `automatic`: arrows activate immediately. */
59
+ activation?: EnhanceTabsOptions['activation'];
60
+ orientation?: EnhanceTabsOptions['orientation'];
63
61
  }
64
62
  /**
65
- * Tabbed interface. The enhancer wires ARIA roles, roving tabindex, and arrow
66
- * key navigation once the markup is rendered.
63
+ * Tabbed interface root. Compose with `<TabList>`, `<Tab>`, and `<TabPanel>`.
64
+ * The enhancer wires ARIA roles, roving tabindex, and arrow-key navigation
65
+ * once the markup is mounted.
66
+ *
67
+ * ```tsx
68
+ * <Tabs>
69
+ * <TabList>
70
+ * <Tab>Overview</Tab>
71
+ * <Tab>Install</Tab>
72
+ * </TabList>
73
+ * <TabPanel>Zero runtime by default.</TabPanel>
74
+ * <TabPanel>npm install hydrateless</TabPanel>
75
+ * </Tabs>
76
+ * ```
67
77
  */
68
- declare function Tabs({ items, ...rest }: TabsProps): react.JSX.Element;
78
+ declare function Tabs({ activation, orientation, children, ...rest }: TabsProps): react.JSX.Element;
79
+ type TabListProps = HTMLAttributes<HTMLDivElement>;
80
+ /** The row of tab triggers. Renders `role="tablist"`. */
81
+ declare function TabList({ children, ...rest }: TabListProps): react.JSX.Element;
82
+ type TabProps = ButtonHTMLAttributes<HTMLButtonElement>;
83
+ /** A single tab trigger. Renders `role="tab"`. */
84
+ declare function Tab({ children, type, ...rest }: TabProps): react.JSX.Element;
85
+ type TabPanelProps = HTMLAttributes<HTMLDivElement>;
86
+ /** Content for the matching tab. Renders `role="tabpanel"`. */
87
+ declare function TabPanel({ children, ...rest }: TabPanelProps): react.JSX.Element;
69
88
 
70
- interface DropdownItem {
71
- label: ReactNode;
89
+ interface DropdownProps extends HTMLAttributes<HTMLDivElement> {
90
+ placement?: EnhanceDropdownOptions['placement'];
91
+ }
92
+ /**
93
+ * Button-triggered menu following the WAI-ARIA menu-button pattern. Compose with
94
+ * `<DropdownTrigger>`, `<DropdownMenu>`, `<DropdownItem>`, and
95
+ * `<DropdownSeparator>`. The enhancer adds keyboard navigation, typeahead, and
96
+ * `aria-expanded`/`role` wiring.
97
+ *
98
+ * ```tsx
99
+ * <Dropdown>
100
+ * <DropdownTrigger>Actions</DropdownTrigger>
101
+ * <DropdownMenu>
102
+ * <DropdownItem onSelect={edit}>Edit</DropdownItem>
103
+ * <DropdownSeparator />
104
+ * <DropdownItem onSelect={remove}>Delete</DropdownItem>
105
+ * </DropdownMenu>
106
+ * </Dropdown>
107
+ * ```
108
+ */
109
+ declare function Dropdown({ placement, children, ...rest }: DropdownProps): react.JSX.Element;
110
+ type DropdownTriggerProps = ButtonHTMLAttributes<HTMLButtonElement>;
111
+ /** The button that opens the menu. */
112
+ declare function DropdownTrigger({ children, type, ...rest }: DropdownTriggerProps): react.JSX.Element;
113
+ type DropdownMenuProps = HTMLAttributes<HTMLUListElement>;
114
+ /** The menu surface; holds `<DropdownItem>` and `<DropdownSeparator>`. */
115
+ declare function DropdownMenu({ children, ...rest }: DropdownMenuProps): react.JSX.Element;
116
+ interface DropdownItemProps extends ButtonHTMLAttributes<HTMLButtonElement> {
117
+ /** Convenience handler fired on click; you can also pass `onClick`. */
72
118
  onSelect?: () => void;
73
- separator?: boolean;
74
- disabled?: boolean;
75
119
  }
76
- interface DropdownProps extends HTMLAttributes<HTMLDivElement> {
77
- trigger: ReactNode;
78
- items: DropdownItem[];
120
+ /** A selectable menu item (`role="menuitem"`). */
121
+ declare function DropdownItem({ children, onSelect, onClick, type, ...rest }: DropdownItemProps): react.JSX.Element;
122
+ type DropdownSeparatorProps = Omit<LiHTMLAttributes<HTMLLIElement>, 'role'>;
123
+ /** A visual divider between groups of items. */
124
+ declare function DropdownSeparator(props: DropdownSeparatorProps): react.JSX.Element;
125
+
126
+ interface MenuProps extends HTMLAttributes<HTMLUListElement> {
127
+ orientation?: EnhanceMenuOptions['orientation'];
79
128
  }
80
129
  /**
81
- * Button-triggered menu following the WAI-ARIA menu pattern. The enhancer adds
82
- * keyboard navigation, typeahead, and `aria-expanded`/`role` wiring.
130
+ * Menubar / navigation menu with single-level submenus. Compose with
131
+ * `<MenuItem>`; nest items by passing a `submenu`. The enhancer wires roving
132
+ * tabindex, orientation-aware arrow navigation, and submenu toggling.
133
+ *
134
+ * ```tsx
135
+ * <Menu orientation="horizontal">
136
+ * <MenuItem href="/">Home</MenuItem>
137
+ * <MenuItem submenu={<><MenuItem href="/docs">Docs</MenuItem></>}>Resources</MenuItem>
138
+ * </Menu>
139
+ * ```
83
140
  */
84
- declare function Dropdown({ trigger, items, ...rest }: DropdownProps): react.JSX.Element;
141
+ declare function Menu({ orientation, children, ...rest }: MenuProps): react.JSX.Element;
142
+ interface MenuItemProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'href' | 'type'> {
143
+ /** Render as a link instead of a button. */
144
+ href?: string;
145
+ /** Convenience handler fired on activation. */
146
+ onSelect?: () => void;
147
+ /** Nested `<MenuItem>`s; renders a single-level submenu. */
148
+ submenu?: ReactNode;
149
+ /** Extra attributes for the `<a>` when `href` is set. */
150
+ anchorProps?: AnchorHTMLAttributes<HTMLAnchorElement>;
151
+ }
152
+ /**
153
+ * A menu entry. Children are the label; pass `submenu` to nest a flyout. With
154
+ * `href` it renders an anchor, otherwise a button.
155
+ */
156
+ declare function MenuItem({ href, onSelect, onClick, submenu, anchorProps, children, ...rest }: MenuItemProps): react.JSX.Element;
85
157
 
86
158
  interface ModalProps extends Omit<HTMLAttributes<HTMLDialogElement>, 'title' | 'onClick'> {
87
159
  open: boolean;
88
160
  onClose?: () => void;
89
- title?: ReactNode;
90
- footer?: ReactNode;
91
161
  closeOnBackdrop?: boolean;
92
162
  }
93
163
  /**
94
164
  * Controlled dialog overlay. Driven by the `open` prop via the native
95
- * `<dialog>` element, which provides focus containment in the top layer. Wire
96
- * `onClose` so Escape and backdrop clicks can update your state.
165
+ * `<dialog>` element, which provides focus containment in the top layer. Compose
166
+ * with `<ModalHeader>`, `<ModalBody>`, and `<ModalFooter>`. Wire `onClose` so
167
+ * Escape and backdrop clicks can update your state.
168
+ *
169
+ * ```tsx
170
+ * <Modal open={open} onClose={close}>
171
+ * <ModalHeader>Confirm</ModalHeader>
172
+ * <ModalBody>Are you sure?</ModalBody>
173
+ * <ModalFooter><Button onClick={close}>Close</Button></ModalFooter>
174
+ * </Modal>
175
+ * ```
97
176
  */
98
- declare function Modal({ open, onClose, title, footer, closeOnBackdrop, className, children, ...rest }: ModalProps): react.JSX.Element;
177
+ declare function Modal({ open, onClose, closeOnBackdrop, className, children, ...rest }: ModalProps): react.JSX.Element;
178
+ type ModalSectionProps = HTMLAttributes<HTMLDivElement>;
179
+ /** Modal heading region; its content labels the dialog for assistive tech. */
180
+ declare function ModalHeader({ className, ...rest }: ModalSectionProps): react.JSX.Element;
181
+ /** Modal main content region. */
182
+ declare function ModalBody({ className, ...rest }: ModalSectionProps): react.JSX.Element;
183
+ /** Modal actions region. */
184
+ declare function ModalFooter({ className, ...rest }: ModalSectionProps): react.JSX.Element;
99
185
 
100
186
  interface DrawerProps extends Omit<HTMLAttributes<HTMLDialogElement>, 'title' | 'onClick'> {
101
187
  open: boolean;
102
188
  onClose?: () => void;
103
189
  side?: 'left' | 'right';
104
- title?: ReactNode;
105
- footer?: ReactNode;
106
190
  closeOnBackdrop?: boolean;
107
191
  }
108
192
  /**
109
193
  * Controlled off-canvas panel built on the native `<dialog>` element. Mirrors
110
- * {@link Modal} but slides in from the chosen `side`.
194
+ * {@link Modal} but slides in from the chosen `side`. Compose with
195
+ * `<DrawerHeader>`, `<DrawerBody>`, and `<DrawerFooter>`.
111
196
  */
112
- declare function Drawer({ open, onClose, side, title, footer, closeOnBackdrop, className, children, ...rest }: DrawerProps): react.JSX.Element;
197
+ declare function Drawer({ open, onClose, side, closeOnBackdrop, className, children, ...rest }: DrawerProps): react.JSX.Element;
198
+ type DrawerSectionProps = HTMLAttributes<HTMLDivElement>;
199
+ /** Drawer heading region. */
200
+ declare function DrawerHeader({ className, ...rest }: DrawerSectionProps): react.JSX.Element;
201
+ /** Drawer main content region. */
202
+ declare function DrawerBody({ className, ...rest }: DrawerSectionProps): react.JSX.Element;
203
+ /** Drawer actions region. */
204
+ declare function DrawerFooter({ className, ...rest }: DrawerSectionProps): react.JSX.Element;
113
205
 
114
206
  interface PopoverProps extends HTMLAttributes<HTMLDivElement> {
115
207
  open: boolean;
@@ -135,16 +227,28 @@ interface TooltipProps {
135
227
  */
136
228
  declare function Tooltip({ label, children, id }: TooltipProps): react.JSX.Element;
137
229
 
138
- interface BreadcrumbItem {
139
- label: ReactNode;
230
+ type BreadcrumbProps = HTMLAttributes<HTMLElement>;
231
+ /**
232
+ * Semantic breadcrumb navigation (`<nav> > <ol>`). CSS-only, no enhancer.
233
+ * Compose with `<BreadcrumbItem>`.
234
+ *
235
+ * ```tsx
236
+ * <Breadcrumb>
237
+ * <BreadcrumbItem href="/">Home</BreadcrumbItem>
238
+ * <BreadcrumbItem current>Components</BreadcrumbItem>
239
+ * </Breadcrumb>
240
+ * ```
241
+ */
242
+ declare function Breadcrumb({ children, ...rest }: BreadcrumbProps): react.JSX.Element;
243
+ interface BreadcrumbItemProps extends Omit<LiHTMLAttributes<HTMLLIElement>, 'children'> {
140
244
  href?: string;
245
+ /** Marks the current page; renders a non-link with `aria-current="page"`. */
141
246
  current?: boolean;
247
+ children?: ReactNode;
248
+ anchorProps?: AnchorHTMLAttributes<HTMLAnchorElement>;
142
249
  }
143
- interface BreadcrumbProps extends HTMLAttributes<HTMLElement> {
144
- items: BreadcrumbItem[];
145
- }
146
- /** Semantic breadcrumb navigation (`<nav> > <ol>`). CSS-only, no enhancer. */
147
- declare function Breadcrumb({ items, ...rest }: BreadcrumbProps): react.JSX.Element;
250
+ /** A single crumb. Renders a link unless `current` (or no `href`) is set. */
251
+ declare function BreadcrumbItem({ href, current, anchorProps, children, ...rest }: BreadcrumbItemProps): react.JSX.Element;
148
252
 
149
253
  interface SwitchProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'type'> {
150
254
  children?: ReactNode;
@@ -180,65 +284,82 @@ declare function ToastProvider({ children }: ToastProviderProps): react.JSX.Elem
180
284
  /** Access the toast API. Must be called within a {@link ToastProvider}. */
181
285
  declare function useToast(): ToastApi;
182
286
 
183
- interface MenuItemDef {
184
- label: ReactNode;
185
- href?: string;
186
- onSelect?: () => void;
187
- disabled?: boolean;
188
- items?: MenuItemDef[];
189
- }
190
- interface MenuProps extends HTMLAttributes<HTMLUListElement> {
191
- items: MenuItemDef[];
192
- orientation?: 'horizontal' | 'vertical';
193
- }
194
- /**
195
- * Menubar / navigation menu. The enhancer wires roving tabindex, arrow
196
- * navigation, and single-level submenu toggling per the WAI-ARIA menubar
197
- * pattern.
198
- */
199
- declare function Menu({ items, orientation, ...rest }: MenuProps): react.JSX.Element;
200
-
201
- interface ComboboxOption {
202
- value: string;
203
- label?: ReactNode;
204
- }
205
287
  interface ComboboxProps extends Omit<HTMLAttributes<HTMLDivElement>, 'onChange'> {
206
- options: ComboboxOption[];
207
- defaultValue?: string;
208
- placeholder?: string;
288
+ filter?: EnhanceComboboxOptions['filter'];
289
+ autoHighlight?: EnhanceComboboxOptions['autoHighlight'];
290
+ /** Fires with the committed value when an option is selected. */
209
291
  onValueChange?: (value: string) => void;
210
- inputProps?: Omit<InputHTMLAttributes<HTMLInputElement>, 'role'>;
211
292
  }
212
293
  /**
213
- * Editable combobox (input + listbox). The enhancer adds filtering,
214
- * `aria-activedescendant` navigation, and selection; `onValueChange` fires when
215
- * an option is committed.
294
+ * Editable combobox (input + listbox) implementing the APG pattern. Compose with
295
+ * `<ComboboxInput>`, `<ComboboxList>`, and `<ComboboxOption>`. The enhancer adds
296
+ * filtering, `aria-activedescendant` navigation, and selection.
297
+ *
298
+ * ```tsx
299
+ * <Combobox onValueChange={setValue}>
300
+ * <ComboboxInput placeholder="Search…" />
301
+ * <ComboboxList>
302
+ * <ComboboxOption value="apple">Apple</ComboboxOption>
303
+ * <ComboboxOption value="banana">Banana</ComboboxOption>
304
+ * </ComboboxList>
305
+ * </Combobox>
306
+ * ```
216
307
  */
217
- declare function Combobox({ options, defaultValue, placeholder, onValueChange, inputProps, ...rest }: ComboboxProps): react.JSX.Element;
218
-
219
- interface CommandItemDef {
308
+ declare function Combobox({ filter, autoHighlight, onValueChange, children, ...rest }: ComboboxProps): react.JSX.Element;
309
+ interface ComboboxInputProps extends InputHTMLAttributes<HTMLInputElement> {
310
+ /** Apply the `hl-input` style. Defaults to `true`. */
311
+ styled?: boolean;
312
+ }
313
+ /** The combobox text field. */
314
+ declare function ComboboxInput({ styled, className, ...rest }: ComboboxInputProps): react.JSX.Element;
315
+ type ComboboxListProps = HTMLAttributes<HTMLUListElement>;
316
+ /** The option popup (`role="listbox"`). */
317
+ declare function ComboboxList({ children, ...rest }: ComboboxListProps): react.JSX.Element;
318
+ interface ComboboxOptionProps extends Omit<LiHTMLAttributes<HTMLLIElement>, 'value'> {
220
319
  value: string;
221
- label: ReactNode;
222
- keywords?: string;
223
- group?: string;
224
- icon?: ReactNode;
225
- href?: string;
226
- onSelect?: () => void;
227
320
  }
321
+ /** A selectable option. The `value` is committed on selection. */
322
+ declare function ComboboxOption({ value, children, ...rest }: ComboboxOptionProps): react.JSX.Element;
323
+
228
324
  interface CommandProps extends Omit<HTMLAttributes<HTMLDivElement>, 'onSelect'> {
229
- items: CommandItemDef[];
230
- placeholder?: string;
231
- emptyLabel?: ReactNode;
232
325
  /** Lowercased key that opens the palette's dialog with Cmd/Ctrl. */
233
326
  hotkey?: string;
327
+ /** Fires with the chosen item's value when a command runs. */
234
328
  onSelect?: (value: string) => void;
235
329
  }
236
330
  /**
237
- * Command palette. The enhancer filters items (text + keywords), provides arrow
238
- * navigation and an empty state, and runs the active item on Enter; `onSelect`
239
- * receives the chosen item's value. Place inside a `<dialog>` to use `hotkey`.
331
+ * Command palette. Compose with `<CommandInput>`, `<CommandList>`,
332
+ * `<CommandGroup>`, `<CommandItem>`, and `<CommandEmpty>`. The enhancer filters
333
+ * items (text + keywords), provides arrow navigation and an empty state, and
334
+ * runs the active item on Enter. Place inside a `<dialog>` to use `hotkey`.
240
335
  */
241
- declare function Command({ items, placeholder, emptyLabel, hotkey, onSelect, ...rest }: CommandProps): react.JSX.Element;
336
+ declare function Command({ hotkey, onSelect, children, ...rest }: CommandProps): react.JSX.Element;
337
+ interface CommandInputProps extends InputHTMLAttributes<HTMLInputElement> {
338
+ styled?: boolean;
339
+ }
340
+ /** The palette search field. */
341
+ declare function CommandInput({ styled, className, ...rest }: CommandInputProps): react.JSX.Element;
342
+ type CommandListProps = HTMLAttributes<HTMLDivElement>;
343
+ /** The scrollable list of commands (`role="listbox"`). */
344
+ declare function CommandList({ children, ...rest }: CommandListProps): react.JSX.Element;
345
+ interface CommandGroupProps extends HTMLAttributes<HTMLDivElement> {
346
+ /** Optional heading shown above the grouped items. */
347
+ label?: ReactNode;
348
+ }
349
+ /** A labelled group of commands. */
350
+ declare function CommandGroup({ label, children, ...rest }: CommandGroupProps): react.JSX.Element;
351
+ interface CommandItemProps extends Omit<HTMLAttributes<HTMLDivElement>, 'onSelect'> {
352
+ value: string;
353
+ /** Extra search terms for filtering. */
354
+ keywords?: string;
355
+ /** Leading icon node. */
356
+ icon?: ReactNode;
357
+ }
358
+ /** A runnable command (`role="option"`). */
359
+ declare function CommandItem({ value, keywords, icon, children, ...rest }: CommandItemProps): react.JSX.Element;
360
+ type CommandEmptyProps = HTMLAttributes<HTMLDivElement>;
361
+ /** Shown when no commands match the query. */
362
+ declare function CommandEmpty({ children, ...rest }: CommandEmptyProps): react.JSX.Element;
242
363
 
243
364
  interface InputProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'size'> {
244
365
  size?: 'sm' | 'md' | 'lg';
@@ -301,8 +422,9 @@ interface FieldProps extends HTMLAttributes<HTMLDivElement> {
301
422
  }
302
423
  /**
303
424
  * Layout + accessibility wrapper for a form control. Provides a shared id so
304
- * `<Label>`, `<Help>`, and `<Error>` wire up `htmlFor`/`aria-describedby`
305
- * automatically; spread {@link useField}'s result onto your control.
425
+ * `<FieldLabel>`, `<FieldHelp>`, and `<FieldError>` wire up
426
+ * `htmlFor`/`aria-describedby` automatically; spread {@link useField}'s result
427
+ * onto your control.
306
428
  */
307
429
  declare function Field({ id, invalid, required, className, children, ...rest }: FieldProps): react.JSX.Element;
308
430
  /**
@@ -314,11 +436,11 @@ declare function useField(): {
314
436
  'aria-describedby': string | undefined;
315
437
  'aria-invalid': true | undefined;
316
438
  };
317
- type LabelProps = LabelHTMLAttributes<HTMLLabelElement>;
439
+ type FieldLabelProps = LabelHTMLAttributes<HTMLLabelElement>;
318
440
  /** Label bound to the enclosing field's control via `htmlFor`. */
319
- declare function Label({ className, children, ...rest }: LabelProps): react.JSX.Element;
441
+ declare function FieldLabel({ className, children, ...rest }: FieldLabelProps): react.JSX.Element;
320
442
  /** Supplementary help text, referenced by the control's `aria-describedby`. */
321
- declare function Help({ className, children, ...rest }: HTMLAttributes<HTMLParagraphElement>): react.JSX.Element;
443
+ declare function FieldHelp({ className, children, ...rest }: HTMLAttributes<HTMLParagraphElement>): react.JSX.Element;
322
444
  /** Validation message; renders nothing unless given content. */
323
445
  declare function FieldError({ className, children, ...rest }: HTMLAttributes<HTMLParagraphElement>): react.JSX.Element | null;
324
446
  interface FieldsetProps extends HTMLAttributes<HTMLFieldSetElement> {
@@ -461,4 +583,7 @@ interface SeparatorProps extends HTMLAttributes<HTMLHRElement> {
461
583
  /** Separator primitive — `<hr class="hl-separator">`. */
462
584
  declare const Separator: react.ForwardRefExoticComponent<SeparatorProps & react.RefAttributes<HTMLHRElement>>;
463
585
 
464
- export { Accordion, AccordionItem, type AccordionItemProps, type AccordionProps, Alert, type AlertProps, Avatar, AvatarGroup, type AvatarGroupProps, type AvatarProps, Badge, type BadgeProps, Breadcrumb, type BreadcrumbItem, type BreadcrumbProps, Button, type ButtonProps, Card, CardBody, CardDescription, CardFooter, CardHeader, type CardProps, type CardSectionProps, CardTitle, Checkbox, type CheckboxProps, Combobox, type ComboboxOption, type ComboboxProps, Command, type CommandItemDef, type CommandProps, Disclosure, type DisclosureProps, Drawer, type DrawerProps, Dropdown, type DropdownItem, type DropdownProps, Field, FieldError, type FieldProps, Fieldset, type FieldsetProps, Help, Input, type InputProps, Kbd, type KbdProps, Label, type LabelProps, Menu, type MenuItemDef, type MenuProps, Modal, type ModalProps, 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, type TabItem, Tabs, type TabsProps, Textarea, type TextareaProps, ToastProvider, type ToastProviderProps, Toc, type TocProps, Tooltip, type TooltipProps, useAccordion, useDisclosureGroup, useDropdown, useEnhancer, useField, useModalGroup, useTabs, useToast, useTocEnhancer, useTooltip };
586
+ /** Join truthy class names into a single string. */
587
+ declare function cx(...classes: Array<string | false | null | undefined>): string;
588
+
589
+ 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, ToastProvider, type ToastProviderProps, Toc, type TocProps, Tooltip, type TooltipProps, cx, useAccordion, useDisclosureGroup, useDropdown, useEnhancer, useField, useModalGroup, useTabs, useToast, useTocEnhancer, useTooltip };
package/dist/index.js CHANGED
@@ -76,67 +76,144 @@ function Disclosure({ summary, defaultOpen = false, children, ...rest }) {
76
76
  // src/Tabs.tsx
77
77
  import { useEffect as useEffect4, useRef as useRef4 } from "react";
78
78
  import { enhanceTabs as enhanceTabs2 } from "@hydrateless/enhancers";
79
- import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
80
- function Tabs({ items, ...rest }) {
79
+ import { jsx as jsx3 } from "react/jsx-runtime";
80
+ function Tabs({ activation, orientation, children, ...rest }) {
81
81
  const ref = useRef4(null);
82
82
  useEffect4(() => {
83
83
  if (!ref.current) return;
84
- return enhanceTabs2(ref.current);
85
- }, [items.length]);
86
- return /* @__PURE__ */ jsxs3("div", { ...rest, "data-hl-tabs": true, ref, children: [
87
- /* @__PURE__ */ jsx3("div", { role: "tablist", children: items.map((item, i) => /* @__PURE__ */ jsx3("button", { type: "button", role: "tab", children: item.label }, i)) }),
88
- items.map((item, i) => /* @__PURE__ */ jsx3("div", { role: "tabpanel", children: item.content }, i))
89
- ] });
84
+ return enhanceTabs2(ref.current, { activation, orientation });
85
+ }, [activation, orientation]);
86
+ return /* @__PURE__ */ jsx3("div", { ...rest, "data-hl-tabs": true, ref, children });
87
+ }
88
+ function TabList({ children, ...rest }) {
89
+ return /* @__PURE__ */ jsx3("div", { ...rest, role: "tablist", children });
90
+ }
91
+ function Tab({ children, type, ...rest }) {
92
+ return /* @__PURE__ */ jsx3("button", { ...rest, type: type ?? "button", role: "tab", children });
93
+ }
94
+ function TabPanel({ children, ...rest }) {
95
+ return /* @__PURE__ */ jsx3("div", { ...rest, role: "tabpanel", children });
90
96
  }
91
97
 
92
98
  // src/Dropdown.tsx
93
- import { useEffect as useEffect5, useRef as useRef5 } from "react";
99
+ import {
100
+ useEffect as useEffect5,
101
+ useRef as useRef5
102
+ } from "react";
94
103
  import { enhanceDropdown as enhanceDropdown2 } from "@hydrateless/enhancers";
95
- import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
96
- function Dropdown({ trigger, items, ...rest }) {
104
+ import { jsx as jsx4 } from "react/jsx-runtime";
105
+ function Dropdown({ placement, children, ...rest }) {
97
106
  const ref = useRef5(null);
98
107
  useEffect5(() => {
99
108
  if (!ref.current) return;
100
- return enhanceDropdown2(ref.current);
101
- }, [items.length]);
102
- return /* @__PURE__ */ jsxs4("div", { ...rest, "data-hl-dropdown": true, ref, children: [
103
- /* @__PURE__ */ jsx4("button", { type: "button", "data-hl-dropdown-trigger": true, children: trigger }),
104
- /* @__PURE__ */ jsx4("ul", { "data-hl-dropdown-menu": true, children: items.map(
105
- (item, i) => item.separator ? /* @__PURE__ */ jsx4("li", { role: "separator" }, i) : /* @__PURE__ */ jsx4("li", { children: /* @__PURE__ */ jsx4(
106
- "button",
107
- {
108
- type: "button",
109
- role: "menuitem",
110
- onClick: item.onSelect,
111
- disabled: item.disabled,
112
- children: item.label
113
- }
114
- ) }, i)
115
- ) })
109
+ return enhanceDropdown2(ref.current, { placement });
110
+ }, [placement]);
111
+ return /* @__PURE__ */ jsx4("div", { ...rest, "data-hl-dropdown": true, ref, children });
112
+ }
113
+ function DropdownTrigger({ children, type, ...rest }) {
114
+ return /* @__PURE__ */ jsx4("button", { ...rest, type: type ?? "button", "data-hl-dropdown-trigger": true, children });
115
+ }
116
+ function DropdownMenu({ children, ...rest }) {
117
+ return /* @__PURE__ */ jsx4("ul", { ...rest, "data-hl-dropdown-menu": true, children });
118
+ }
119
+ function DropdownItem({ children, onSelect, onClick, type, ...rest }) {
120
+ return /* @__PURE__ */ jsx4("li", { children: /* @__PURE__ */ jsx4(
121
+ "button",
122
+ {
123
+ ...rest,
124
+ type: type ?? "button",
125
+ role: "menuitem",
126
+ onClick: (e) => {
127
+ onSelect?.();
128
+ onClick?.(e);
129
+ },
130
+ children
131
+ }
132
+ ) });
133
+ }
134
+ function DropdownSeparator(props) {
135
+ return /* @__PURE__ */ jsx4("li", { ...props, role: "separator" });
136
+ }
137
+
138
+ // src/Menu.tsx
139
+ import {
140
+ useEffect as useEffect6,
141
+ useRef as useRef6
142
+ } from "react";
143
+ import { enhanceMenu } from "@hydrateless/enhancers";
144
+ import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
145
+ function Menu({ orientation = "horizontal", children, ...rest }) {
146
+ const ref = useRef6(null);
147
+ useEffect6(() => {
148
+ if (!ref.current) return;
149
+ return enhanceMenu(ref.current, { orientation });
150
+ }, [orientation]);
151
+ return /* @__PURE__ */ jsx5(
152
+ "ul",
153
+ {
154
+ ...rest,
155
+ ref,
156
+ "data-hl-menu": true,
157
+ role: orientation === "vertical" ? "menu" : "menubar",
158
+ "aria-orientation": orientation,
159
+ children
160
+ }
161
+ );
162
+ }
163
+ function MenuItem({
164
+ href,
165
+ onSelect,
166
+ onClick,
167
+ submenu,
168
+ anchorProps,
169
+ children,
170
+ ...rest
171
+ }) {
172
+ const hasSubmenu = submenu != null;
173
+ return /* @__PURE__ */ jsxs3("li", { role: "none", children: [
174
+ href && !hasSubmenu ? /* @__PURE__ */ jsx5("a", { ...anchorProps, role: "menuitem", href, children }) : /* @__PURE__ */ jsx5(
175
+ "button",
176
+ {
177
+ ...rest,
178
+ type: "button",
179
+ role: "menuitem",
180
+ onClick: (e) => {
181
+ onSelect?.();
182
+ onClick?.(e);
183
+ },
184
+ children
185
+ }
186
+ ),
187
+ hasSubmenu && /* @__PURE__ */ jsx5("ul", { role: "menu", "data-hl-menu-submenu": true, hidden: true, children: submenu })
116
188
  ] });
117
189
  }
118
190
 
119
191
  // src/Modal.tsx
120
- import { useEffect as useEffect6, useRef as useRef6 } from "react";
121
- import { jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
192
+ import { useEffect as useEffect7, useRef as useRef7 } from "react";
193
+
194
+ // src/util.ts
195
+ function cx(...classes) {
196
+ return classes.filter(Boolean).join(" ");
197
+ }
198
+
199
+ // src/Modal.tsx
200
+ import { jsx as jsx6 } from "react/jsx-runtime";
122
201
  function Modal({
123
202
  open,
124
203
  onClose,
125
- title,
126
- footer,
127
204
  closeOnBackdrop = true,
128
205
  className,
129
206
  children,
130
207
  ...rest
131
208
  }) {
132
- const ref = useRef6(null);
133
- useEffect6(() => {
209
+ const ref = useRef7(null);
210
+ useEffect7(() => {
134
211
  const dialog = ref.current;
135
212
  if (!dialog) return;
136
213
  if (open && !dialog.open) dialog.showModal();
137
214
  else if (!open && dialog.open) dialog.close();
138
215
  }, [open]);
139
- useEffect6(() => {
216
+ useEffect7(() => {
140
217
  const dialog = ref.current;
141
218
  if (!dialog) return;
142
219
  const handleClose = () => onClose?.();
@@ -146,44 +223,47 @@ function Modal({
146
223
  const handleClick = (e) => {
147
224
  if (closeOnBackdrop && e.target === ref.current) onClose?.();
148
225
  };
149
- return /* @__PURE__ */ jsxs5(
226
+ return /* @__PURE__ */ jsx6(
150
227
  "dialog",
151
228
  {
152
229
  ...rest,
153
230
  ref,
154
- className: ["hydrateless-modal", className].filter(Boolean).join(" "),
231
+ className: cx("hydrateless-modal", className),
155
232
  onClick: handleClick,
156
- children: [
157
- title != null && /* @__PURE__ */ jsx5("div", { className: "hl-modal-header", children: title }),
158
- /* @__PURE__ */ jsx5("div", { className: "hl-modal-body", children }),
159
- footer != null && /* @__PURE__ */ jsx5("div", { className: "hl-modal-footer", children: footer })
160
- ]
233
+ children
161
234
  }
162
235
  );
163
236
  }
237
+ function ModalHeader({ className, ...rest }) {
238
+ return /* @__PURE__ */ jsx6("div", { ...rest, className: cx("hl-modal-header", className) });
239
+ }
240
+ function ModalBody({ className, ...rest }) {
241
+ return /* @__PURE__ */ jsx6("div", { ...rest, className: cx("hl-modal-body", className) });
242
+ }
243
+ function ModalFooter({ className, ...rest }) {
244
+ return /* @__PURE__ */ jsx6("div", { ...rest, className: cx("hl-modal-footer", className) });
245
+ }
164
246
 
165
247
  // src/Drawer.tsx
166
- import { useEffect as useEffect7, useRef as useRef7 } from "react";
167
- import { jsx as jsx6, jsxs as jsxs6 } from "react/jsx-runtime";
248
+ import { useEffect as useEffect8, useRef as useRef8 } from "react";
249
+ import { jsx as jsx7 } from "react/jsx-runtime";
168
250
  function Drawer({
169
251
  open,
170
252
  onClose,
171
253
  side = "right",
172
- title,
173
- footer,
174
254
  closeOnBackdrop = true,
175
255
  className,
176
256
  children,
177
257
  ...rest
178
258
  }) {
179
- const ref = useRef7(null);
180
- useEffect7(() => {
259
+ const ref = useRef8(null);
260
+ useEffect8(() => {
181
261
  const dialog = ref.current;
182
262
  if (!dialog) return;
183
263
  if (open && !dialog.open) dialog.showModal();
184
264
  else if (!open && dialog.open) dialog.close();
185
265
  }, [open]);
186
- useEffect7(() => {
266
+ useEffect8(() => {
187
267
  const dialog = ref.current;
188
268
  if (!dialog) return;
189
269
  const handleClose = () => onClose?.();
@@ -193,44 +273,49 @@ function Drawer({
193
273
  const handleClick = (e) => {
194
274
  if (closeOnBackdrop && e.target === ref.current) onClose?.();
195
275
  };
196
- return /* @__PURE__ */ jsxs6(
276
+ return /* @__PURE__ */ jsx7(
197
277
  "dialog",
198
278
  {
199
279
  ...rest,
200
280
  ref,
201
281
  "data-side": side,
202
- className: ["hydrateless-drawer", className].filter(Boolean).join(" "),
282
+ className: cx("hydrateless-drawer", className),
203
283
  onClick: handleClick,
204
- children: [
205
- title != null && /* @__PURE__ */ jsx6("div", { className: "hl-drawer-header", children: title }),
206
- /* @__PURE__ */ jsx6("div", { className: "hl-drawer-body", children }),
207
- footer != null && /* @__PURE__ */ jsx6("div", { className: "hl-drawer-footer", children: footer })
208
- ]
284
+ children
209
285
  }
210
286
  );
211
287
  }
288
+ function DrawerHeader({ className, ...rest }) {
289
+ return /* @__PURE__ */ jsx7("div", { ...rest, className: cx("hl-drawer-header", className) });
290
+ }
291
+ function DrawerBody({ className, ...rest }) {
292
+ return /* @__PURE__ */ jsx7("div", { ...rest, className: cx("hl-drawer-body", className) });
293
+ }
294
+ function DrawerFooter({ className, ...rest }) {
295
+ return /* @__PURE__ */ jsx7("div", { ...rest, className: cx("hl-drawer-footer", className) });
296
+ }
212
297
 
213
298
  // src/Popover.tsx
214
- import { jsx as jsx7 } from "react/jsx-runtime";
299
+ import { jsx as jsx8 } from "react/jsx-runtime";
215
300
  function Popover({ open, children, ...rest }) {
216
- return /* @__PURE__ */ jsx7("div", { ...rest, "data-hl-popover": true, role: "dialog", hidden: !open, children });
301
+ return /* @__PURE__ */ jsx8("div", { ...rest, "data-hl-popover": true, role: "dialog", hidden: !open, children });
217
302
  }
218
303
 
219
304
  // src/Tooltip.tsx
220
305
  import {
221
306
  cloneElement,
222
307
  isValidElement,
223
- useEffect as useEffect8,
308
+ useEffect as useEffect9,
224
309
  useId,
225
- useRef as useRef8
310
+ useRef as useRef9
226
311
  } from "react";
227
312
  import { enhanceTooltip as enhanceTooltip2 } from "@hydrateless/enhancers";
228
- import { jsx as jsx8, jsxs as jsxs7 } from "react/jsx-runtime";
313
+ import { jsx as jsx9, jsxs as jsxs4 } from "react/jsx-runtime";
229
314
  function Tooltip({ label, children, id }) {
230
315
  const generatedId = useId().replace(/:/g, "");
231
316
  const tipId = id ?? `hl-tip-${generatedId}`;
232
- const ref = useRef8(null);
233
- useEffect8(() => {
317
+ const ref = useRef9(null);
318
+ useEffect9(() => {
234
319
  if (!ref.current) return;
235
320
  return enhanceTooltip2(ref.current);
236
321
  }, [tipId]);
@@ -238,60 +323,69 @@ function Tooltip({ label, children, id }) {
238
323
  "data-hl-tooltip": tipId,
239
324
  "aria-describedby": tipId
240
325
  }) : children;
241
- return /* @__PURE__ */ jsxs7("span", { ref, style: { position: "relative", display: "inline-block" }, children: [
326
+ return /* @__PURE__ */ jsxs4("span", { ref, style: { position: "relative", display: "inline-block" }, children: [
242
327
  trigger,
243
- /* @__PURE__ */ jsx8("span", { id: tipId, role: "tooltip", hidden: true, children: label })
328
+ /* @__PURE__ */ jsx9("span", { id: tipId, role: "tooltip", hidden: true, children: label })
244
329
  ] });
245
330
  }
246
331
 
247
332
  // src/Breadcrumb.tsx
248
- import { jsx as jsx9 } from "react/jsx-runtime";
249
- function Breadcrumb({ items, ...rest }) {
250
- return /* @__PURE__ */ jsx9("nav", { ...rest, "data-hl-breadcrumb": true, "aria-label": rest["aria-label"] ?? "Breadcrumb", children: /* @__PURE__ */ jsx9("ol", { children: items.map((item, i) => /* @__PURE__ */ jsx9("li", { children: item.current || !item.href ? /* @__PURE__ */ jsx9("span", { "aria-current": item.current ? "page" : void 0, children: item.label }) : /* @__PURE__ */ jsx9("a", { href: item.href, children: item.label }) }, i)) }) });
333
+ import { jsx as jsx10 } from "react/jsx-runtime";
334
+ function Breadcrumb({ children, ...rest }) {
335
+ return /* @__PURE__ */ jsx10("nav", { ...rest, "data-hl-breadcrumb": true, "aria-label": rest["aria-label"] ?? "Breadcrumb", children: /* @__PURE__ */ jsx10("ol", { children }) });
336
+ }
337
+ function BreadcrumbItem({
338
+ href,
339
+ current,
340
+ anchorProps,
341
+ children,
342
+ ...rest
343
+ }) {
344
+ return /* @__PURE__ */ jsx10("li", { ...rest, children: current || !href ? /* @__PURE__ */ jsx10("span", { "aria-current": current ? "page" : void 0, children }) : /* @__PURE__ */ jsx10("a", { ...anchorProps, href, children }) });
251
345
  }
252
346
 
253
347
  // src/Switch.tsx
254
- import { jsx as jsx10, jsxs as jsxs8 } from "react/jsx-runtime";
348
+ import { jsx as jsx11, jsxs as jsxs5 } from "react/jsx-runtime";
255
349
  function Switch({ children, className, ...rest }) {
256
- return /* @__PURE__ */ jsxs8("label", { "data-hl-switch": true, className, children: [
257
- /* @__PURE__ */ jsx10("input", { type: "checkbox", role: "switch", ...rest }),
350
+ return /* @__PURE__ */ jsxs5("label", { "data-hl-switch": true, className, children: [
351
+ /* @__PURE__ */ jsx11("input", { type: "checkbox", role: "switch", ...rest }),
258
352
  children
259
353
  ] });
260
354
  }
261
355
 
262
356
  // src/SkipLink.tsx
263
- import { jsx as jsx11 } from "react/jsx-runtime";
357
+ import { jsx as jsx12 } from "react/jsx-runtime";
264
358
  function SkipLink({ children = "Skip to content", className, ...rest }) {
265
- return /* @__PURE__ */ jsx11("a", { ...rest, className: ["a11y-skip-link", className].filter(Boolean).join(" "), children });
359
+ return /* @__PURE__ */ jsx12("a", { ...rest, className: ["a11y-skip-link", className].filter(Boolean).join(" "), children });
266
360
  }
267
361
 
268
362
  // src/Toc.tsx
269
- import { useEffect as useEffect9, useRef as useRef9 } from "react";
363
+ import { useEffect as useEffect10, useRef as useRef10 } from "react";
270
364
  import { enhanceToc as enhanceToc2 } from "@hydrateless/enhancers";
271
- import { jsx as jsx12 } from "react/jsx-runtime";
365
+ import { jsx as jsx13 } from "react/jsx-runtime";
272
366
  function Toc({ contentSelector, headings, scrollSpy, ...rest }) {
273
- const ref = useRef9(null);
274
- useEffect9(() => {
367
+ const ref = useRef10(null);
368
+ useEffect10(() => {
275
369
  if (!ref.current) return;
276
370
  return enhanceToc2(ref.current.ownerDocument, { contentSelector, headings, scrollSpy });
277
371
  }, [contentSelector, headings, scrollSpy]);
278
- return /* @__PURE__ */ jsx12("nav", { ...rest, "data-hl-toc": true, ref });
372
+ return /* @__PURE__ */ jsx13("nav", { ...rest, "data-hl-toc": true, ref });
279
373
  }
280
374
 
281
375
  // src/Toast.tsx
282
- import { createContext, useContext, useEffect as useEffect10, useRef as useRef10 } from "react";
376
+ import { createContext, useContext, useEffect as useEffect11, useRef as useRef11 } from "react";
283
377
  import { enhanceToast } from "@hydrateless/enhancers";
284
- import { jsx as jsx13, jsxs as jsxs9 } from "react/jsx-runtime";
378
+ import { jsx as jsx14, jsxs as jsxs6 } from "react/jsx-runtime";
285
379
  var ToastContext = createContext(null);
286
380
  function ToastProvider({ children }) {
287
- const apiRef = useRef10(null);
288
- const facade = useRef10({
381
+ const apiRef = useRef11(null);
382
+ const facade = useRef11({
289
383
  show: (message, options) => apiRef.current ? apiRef.current.show(message, options) : document.createElement("div"),
290
384
  dismiss: (toast) => apiRef.current?.dismiss(toast),
291
385
  destroy: () => apiRef.current?.destroy()
292
386
  });
293
- const regionRef = useRef10(null);
294
- useEffect10(() => {
387
+ const regionRef = useRef11(null);
388
+ useEffect11(() => {
295
389
  const region = regionRef.current;
296
390
  if (!region) return;
297
391
  const api = enhanceToast(region.ownerDocument);
@@ -301,9 +395,9 @@ function ToastProvider({ children }) {
301
395
  apiRef.current = null;
302
396
  };
303
397
  }, []);
304
- return /* @__PURE__ */ jsxs9(ToastContext.Provider, { value: facade.current, children: [
398
+ return /* @__PURE__ */ jsxs6(ToastContext.Provider, { value: facade.current, children: [
305
399
  children,
306
- /* @__PURE__ */ jsx13("div", { "data-hl-toast-region": true, ref: regionRef })
400
+ /* @__PURE__ */ jsx14("div", { "data-hl-toast-region": true, ref: regionRef })
307
401
  ] });
308
402
  }
309
403
  function useToast() {
@@ -314,48 +408,18 @@ function useToast() {
314
408
  return ctx;
315
409
  }
316
410
 
317
- // src/Menu.tsx
318
- import { useEffect as useEffect11, useRef as useRef11 } from "react";
319
- import { enhanceMenu } from "@hydrateless/enhancers";
320
- import { jsx as jsx14, jsxs as jsxs10 } from "react/jsx-runtime";
321
- function renderItems(items) {
322
- return items.map((item, i) => /* @__PURE__ */ jsxs10("li", { role: "none", children: [
323
- item.href && !item.items ? /* @__PURE__ */ jsx14("a", { role: "menuitem", href: item.href, children: item.label }) : /* @__PURE__ */ jsx14("button", { type: "button", role: "menuitem", onClick: item.onSelect, disabled: item.disabled, children: item.label }),
324
- item.items && /* @__PURE__ */ jsx14("ul", { role: "menu", "data-hl-menu-submenu": true, hidden: true, children: renderItems(item.items) })
325
- ] }, i));
326
- }
327
- function Menu({ items, orientation = "horizontal", ...rest }) {
328
- const ref = useRef11(null);
329
- useEffect11(() => {
330
- if (!ref.current) return;
331
- return enhanceMenu(ref.current, { orientation });
332
- }, [items, orientation]);
333
- return /* @__PURE__ */ jsx14(
334
- "ul",
335
- {
336
- ...rest,
337
- ref,
338
- "data-hl-menu": true,
339
- role: orientation === "vertical" ? "menu" : "menubar",
340
- "aria-orientation": orientation,
341
- children: renderItems(items)
342
- }
343
- );
344
- }
345
-
346
411
  // src/Combobox.tsx
347
412
  import {
348
413
  useEffect as useEffect12,
349
414
  useRef as useRef12
350
415
  } from "react";
351
416
  import { enhanceCombobox } from "@hydrateless/enhancers";
352
- import { jsx as jsx15, jsxs as jsxs11 } from "react/jsx-runtime";
417
+ import { jsx as jsx15 } from "react/jsx-runtime";
353
418
  function Combobox({
354
- options,
355
- defaultValue,
356
- placeholder,
419
+ filter,
420
+ autoHighlight,
357
421
  onValueChange,
358
- inputProps,
422
+ children,
359
423
  ...rest
360
424
  }) {
361
425
  const ref = useRef12(null);
@@ -364,90 +428,74 @@ function Combobox({
364
428
  useEffect12(() => {
365
429
  const el = ref.current;
366
430
  if (!el) return;
367
- const dispose = enhanceCombobox(el);
431
+ const dispose = enhanceCombobox(el, { filter, autoHighlight });
368
432
  const handler = (e) => onChangeRef.current?.(e.detail.value);
369
433
  el.addEventListener("hl:select", handler);
370
434
  return () => {
371
435
  el.removeEventListener("hl:select", handler);
372
436
  dispose();
373
437
  };
374
- }, [options.length]);
375
- return /* @__PURE__ */ jsxs11("div", { ...rest, ref, "data-hl-combobox": true, children: [
376
- /* @__PURE__ */ jsx15(
377
- "input",
378
- {
379
- ...inputProps,
380
- className: ["hl-input", inputProps?.className].filter(Boolean).join(" "),
381
- placeholder,
382
- defaultValue
383
- }
384
- ),
385
- /* @__PURE__ */ jsx15("ul", { role: "listbox", hidden: true, children: options.map((option) => /* @__PURE__ */ jsx15("li", { role: "option", "data-hl-value": option.value, children: option.label ?? option.value }, option.value)) })
386
- ] });
438
+ }, [filter, autoHighlight]);
439
+ return /* @__PURE__ */ jsx15("div", { ...rest, ref, "data-hl-combobox": true, children });
440
+ }
441
+ function ComboboxInput({ styled = true, className, ...rest }) {
442
+ return /* @__PURE__ */ jsx15("input", { ...rest, className: cx(styled && "hl-input", className) });
443
+ }
444
+ function ComboboxList({ children, ...rest }) {
445
+ return /* @__PURE__ */ jsx15("ul", { ...rest, role: "listbox", hidden: true, children });
446
+ }
447
+ function ComboboxOption({ value, children, ...rest }) {
448
+ return /* @__PURE__ */ jsx15("li", { ...rest, role: "option", "data-hl-value": value, children: children ?? value });
387
449
  }
388
450
 
389
451
  // src/Command.tsx
390
- import { useEffect as useEffect13, useRef as useRef13 } from "react";
452
+ import {
453
+ useEffect as useEffect13,
454
+ useRef as useRef13
455
+ } from "react";
391
456
  import { enhanceCommand } from "@hydrateless/enhancers";
392
- import { jsx as jsx16, jsxs as jsxs12 } from "react/jsx-runtime";
393
- function groupItems(items) {
394
- const groups = /* @__PURE__ */ new Map();
395
- for (const item of items) {
396
- const key = item.group ?? "";
397
- const bucket = groups.get(key) ?? [];
398
- bucket.push(item);
399
- groups.set(key, bucket);
400
- }
401
- return [...groups.entries()];
402
- }
403
- function Command({
404
- items,
405
- placeholder = "Type a command\u2026",
406
- emptyLabel = "No results found.",
407
- hotkey,
408
- onSelect,
409
- ...rest
410
- }) {
457
+ import { jsx as jsx16, jsxs as jsxs7 } from "react/jsx-runtime";
458
+ function Command({ hotkey, onSelect, children, ...rest }) {
411
459
  const ref = useRef13(null);
412
460
  const onSelectRef = useRef13(onSelect);
413
461
  onSelectRef.current = onSelect;
414
462
  useEffect13(() => {
415
463
  const el = ref.current;
416
464
  if (!el) return;
417
- const dispose = enhanceCommand(el);
465
+ const dispose = enhanceCommand(el, { hotkey });
418
466
  const handler = (e) => {
419
- const { value, item } = e.detail;
420
- const def = items.find((entry) => entry.value === (item.dataset.hlValue ?? value));
421
- def?.onSelect?.();
422
- onSelectRef.current?.(def?.value ?? value);
467
+ const { value } = e.detail;
468
+ onSelectRef.current?.(value);
423
469
  };
424
470
  el.addEventListener("hl:command", handler);
425
471
  return () => {
426
472
  el.removeEventListener("hl:command", handler);
427
473
  dispose();
428
474
  };
429
- }, [items]);
430
- return /* @__PURE__ */ jsxs12("div", { ...rest, ref, "data-hl-command": true, "data-hl-command-hotkey": hotkey, children: [
431
- /* @__PURE__ */ jsx16("input", { className: "hl-input", "data-hl-command-input": true, placeholder }),
432
- /* @__PURE__ */ jsx16("div", { "data-hl-command-empty": true, hidden: true, children: emptyLabel }),
433
- /* @__PURE__ */ jsx16("div", { "data-hl-command-list": true, role: "listbox", children: groupItems(items).map(([group, groupEntries]) => /* @__PURE__ */ jsxs12("div", { "data-hl-command-group": true, children: [
434
- group && /* @__PURE__ */ jsx16("div", { className: "hl-command-group-label", role: "presentation", children: group }),
435
- groupEntries.map((item) => /* @__PURE__ */ jsxs12(
436
- "div",
437
- {
438
- role: "option",
439
- "data-hl-value": item.value,
440
- "data-hl-keywords": item.keywords,
441
- children: [
442
- item.icon,
443
- /* @__PURE__ */ jsx16("span", { children: item.label })
444
- ]
445
- },
446
- item.value
447
- ))
448
- ] }, group || "_")) })
475
+ }, [hotkey]);
476
+ return /* @__PURE__ */ jsx16("div", { ...rest, ref, "data-hl-command": true, "data-hl-command-hotkey": hotkey, children });
477
+ }
478
+ function CommandInput({ styled = true, className, ...rest }) {
479
+ return /* @__PURE__ */ jsx16("input", { ...rest, className: cx(styled && "hl-input", className), "data-hl-command-input": true });
480
+ }
481
+ function CommandList({ children, ...rest }) {
482
+ return /* @__PURE__ */ jsx16("div", { ...rest, "data-hl-command-list": true, role: "listbox", children });
483
+ }
484
+ function CommandGroup({ label, children, ...rest }) {
485
+ return /* @__PURE__ */ jsxs7("div", { ...rest, "data-hl-command-group": true, children: [
486
+ label != null && /* @__PURE__ */ jsx16("div", { className: "hl-command-group-label", role: "presentation", children: label }),
487
+ children
488
+ ] });
489
+ }
490
+ function CommandItem({ value, keywords, icon, children, ...rest }) {
491
+ return /* @__PURE__ */ jsxs7("div", { ...rest, role: "option", "data-hl-value": value, "data-hl-keywords": keywords, children: [
492
+ icon,
493
+ /* @__PURE__ */ jsx16("span", { children })
449
494
  ] });
450
495
  }
496
+ function CommandEmpty({ children = "No results found.", ...rest }) {
497
+ return /* @__PURE__ */ jsx16("div", { ...rest, "data-hl-command-empty": true, hidden: true, children });
498
+ }
451
499
 
452
500
  // src/Input.tsx
453
501
  import { forwardRef } from "react";
@@ -502,9 +550,9 @@ var Select = forwardRef3(function Select2({ size, invalid, options, className, c
502
550
 
503
551
  // src/Checkbox.tsx
504
552
  import { forwardRef as forwardRef4 } from "react";
505
- import { jsx as jsx20, jsxs as jsxs13 } from "react/jsx-runtime";
553
+ import { jsx as jsx20, jsxs as jsxs8 } from "react/jsx-runtime";
506
554
  var Checkbox = forwardRef4(function Checkbox2({ children, className, ...rest }, ref) {
507
- return /* @__PURE__ */ jsxs13("label", { className: ["hl-checkbox", className].filter(Boolean).join(" "), children: [
555
+ return /* @__PURE__ */ jsxs8("label", { className: ["hl-checkbox", className].filter(Boolean).join(" "), children: [
508
556
  /* @__PURE__ */ jsx20("input", { ...rest, ref, type: "checkbox" }),
509
557
  children != null && /* @__PURE__ */ jsx20("span", { children })
510
558
  ] });
@@ -516,12 +564,12 @@ import {
516
564
  forwardRef as forwardRef5,
517
565
  useContext as useContext2
518
566
  } from "react";
519
- import { jsx as jsx21, jsxs as jsxs14 } from "react/jsx-runtime";
567
+ import { jsx as jsx21, jsxs as jsxs9 } from "react/jsx-runtime";
520
568
  var RadioGroupContext = createContext2(null);
521
569
  var Radio = forwardRef5(function Radio2({ children, className, value, ...rest }, ref) {
522
570
  const group = useContext2(RadioGroupContext);
523
571
  const checked = group ? group.value === value : rest.checked;
524
- return /* @__PURE__ */ jsxs14("label", { className: ["hl-radio", className].filter(Boolean).join(" "), children: [
572
+ return /* @__PURE__ */ jsxs9("label", { className: ["hl-radio", className].filter(Boolean).join(" "), children: [
525
573
  /* @__PURE__ */ jsx21(
526
574
  "input",
527
575
  {
@@ -565,7 +613,7 @@ import {
565
613
  useContext as useContext3,
566
614
  useId as useId2
567
615
  } from "react";
568
- import { jsx as jsx22, jsxs as jsxs15 } from "react/jsx-runtime";
616
+ import { jsx as jsx22, jsxs as jsxs10 } from "react/jsx-runtime";
569
617
  var FieldContext = createContext3(null);
570
618
  function Field({
571
619
  id,
@@ -610,8 +658,8 @@ function useField() {
610
658
  "aria-invalid": ctx.invalid || void 0
611
659
  };
612
660
  }
613
- function Label({ className, children, ...rest }) {
614
- const ctx = useFieldContext("Label");
661
+ function FieldLabel({ className, children, ...rest }) {
662
+ const ctx = useFieldContext("FieldLabel");
615
663
  return /* @__PURE__ */ jsx22(
616
664
  "label",
617
665
  {
@@ -623,8 +671,8 @@ function Label({ className, children, ...rest }) {
623
671
  }
624
672
  );
625
673
  }
626
- function Help({ className, children, ...rest }) {
627
- const ctx = useFieldContext("Help");
674
+ function FieldHelp({ className, children, ...rest }) {
675
+ const ctx = useFieldContext("FieldHelp");
628
676
  return /* @__PURE__ */ jsx22("p", { ...rest, id: ctx.helpId, className: ["hl-help", className].filter(Boolean).join(" "), children });
629
677
  }
630
678
  function FieldError({ className, children, ...rest }) {
@@ -642,7 +690,7 @@ function FieldError({ className, children, ...rest }) {
642
690
  );
643
691
  }
644
692
  function Fieldset({ legend, className, children, ...rest }) {
645
- return /* @__PURE__ */ jsxs15("fieldset", { ...rest, className: ["hl-fieldset", className].filter(Boolean).join(" "), children: [
693
+ return /* @__PURE__ */ jsxs10("fieldset", { ...rest, className: ["hl-fieldset", className].filter(Boolean).join(" "), children: [
646
694
  legend != null && /* @__PURE__ */ jsx22("legend", { className: "hl-legend", children: legend }),
647
695
  children
648
696
  ] });
@@ -650,7 +698,7 @@ function Fieldset({ legend, className, children, ...rest }) {
650
698
 
651
699
  // src/SegmentedControl.tsx
652
700
  import { useId as useId3, useState } from "react";
653
- import { jsx as jsx23, jsxs as jsxs16 } from "react/jsx-runtime";
701
+ import { jsx as jsx23, jsxs as jsxs11 } from "react/jsx-runtime";
654
702
  function SegmentedControl({
655
703
  options,
656
704
  value,
@@ -676,7 +724,7 @@ function SegmentedControl({
676
724
  role: "radiogroup",
677
725
  className: ["hl-segmented", className].filter(Boolean).join(" "),
678
726
  "data-hl-size": size,
679
- children: options.map((option) => /* @__PURE__ */ jsxs16("label", { className: "hl-segmented-item", children: [
727
+ children: options.map((option) => /* @__PURE__ */ jsxs11("label", { className: "hl-segmented-item", children: [
680
728
  /* @__PURE__ */ jsx23(
681
729
  "input",
682
730
  {
@@ -735,9 +783,9 @@ var Button = forwardRef7(function Button2({ variant, intent, size, block, icon,
735
783
 
736
784
  // src/Alert.tsx
737
785
  import { forwardRef as forwardRef8 } from "react";
738
- import { jsx as jsx26, jsxs as jsxs17 } from "react/jsx-runtime";
786
+ import { jsx as jsx26, jsxs as jsxs12 } from "react/jsx-runtime";
739
787
  var Alert = forwardRef8(function Alert2({ intent, title, icon, className, children, ...rest }, ref) {
740
- return /* @__PURE__ */ jsxs17(
788
+ return /* @__PURE__ */ jsxs12(
741
789
  "div",
742
790
  {
743
791
  ...rest,
@@ -747,7 +795,7 @@ var Alert = forwardRef8(function Alert2({ intent, title, icon, className, childr
747
795
  "data-hl-intent": intent,
748
796
  children: [
749
797
  icon,
750
- /* @__PURE__ */ jsxs17("div", { className: "hl-alert-body", children: [
798
+ /* @__PURE__ */ jsxs12("div", { className: "hl-alert-body", children: [
751
799
  title != null && /* @__PURE__ */ jsx26("p", { className: "hl-alert-title", children: title }),
752
800
  children
753
801
  ] })
@@ -894,7 +942,7 @@ var Skeleton = forwardRef14(function Skeleton2({ variant, width, height, classNa
894
942
  });
895
943
 
896
944
  // src/Pagination.tsx
897
- import { jsx as jsx33, jsxs as jsxs18 } from "react/jsx-runtime";
945
+ import { jsx as jsx33, jsxs as jsxs13 } from "react/jsx-runtime";
898
946
  var ELLIPSIS = "ellipsis";
899
947
  function range(start, end) {
900
948
  return Array.from({ length: end - start + 1 }, (_, i) => start + i);
@@ -935,7 +983,7 @@ function Pagination({
935
983
  ...rest,
936
984
  className: ["hl-pagination", className].filter(Boolean).join(" "),
937
985
  "aria-label": rest["aria-label"] ?? "Pagination",
938
- children: /* @__PURE__ */ jsxs18("ul", { children: [
986
+ children: /* @__PURE__ */ jsxs13("ul", { children: [
939
987
  showControls && /* @__PURE__ */ jsx33("li", { children: /* @__PURE__ */ jsx33(
940
988
  "button",
941
989
  {
@@ -1007,6 +1055,7 @@ export {
1007
1055
  AvatarGroup,
1008
1056
  Badge,
1009
1057
  Breadcrumb,
1058
+ BreadcrumbItem,
1010
1059
  Button,
1011
1060
  Card,
1012
1061
  CardBody,
@@ -1016,19 +1065,38 @@ export {
1016
1065
  CardTitle,
1017
1066
  Checkbox,
1018
1067
  Combobox,
1068
+ ComboboxInput,
1069
+ ComboboxList,
1070
+ ComboboxOption,
1019
1071
  Command,
1072
+ CommandEmpty,
1073
+ CommandGroup,
1074
+ CommandInput,
1075
+ CommandItem,
1076
+ CommandList,
1020
1077
  Disclosure,
1021
1078
  Drawer,
1079
+ DrawerBody,
1080
+ DrawerFooter,
1081
+ DrawerHeader,
1022
1082
  Dropdown,
1083
+ DropdownItem,
1084
+ DropdownMenu,
1085
+ DropdownSeparator,
1086
+ DropdownTrigger,
1023
1087
  Field,
1024
1088
  FieldError,
1089
+ FieldHelp,
1090
+ FieldLabel,
1025
1091
  Fieldset,
1026
- Help,
1027
1092
  Input,
1028
1093
  Kbd,
1029
- Label,
1030
1094
  Menu,
1095
+ MenuItem,
1031
1096
  Modal,
1097
+ ModalBody,
1098
+ ModalFooter,
1099
+ ModalHeader,
1032
1100
  Pagination,
1033
1101
  Popover,
1034
1102
  Progress,
@@ -1042,11 +1110,15 @@ export {
1042
1110
  Slider,
1043
1111
  Spinner,
1044
1112
  Switch,
1113
+ Tab,
1114
+ TabList,
1115
+ TabPanel,
1045
1116
  Tabs,
1046
1117
  Textarea,
1047
1118
  ToastProvider,
1048
1119
  Toc,
1049
1120
  Tooltip,
1121
+ cx,
1050
1122
  useAccordion,
1051
1123
  useDisclosureGroup,
1052
1124
  useDropdown,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hydrateless/react",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "React bindings for Hydrateless — hooks and components that wire the framework-agnostic enhancers.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -28,7 +28,7 @@
28
28
  "test": "vitest run"
29
29
  },
30
30
  "dependencies": {
31
- "@hydrateless/enhancers": "^0.4.0"
31
+ "@hydrateless/enhancers": "^0.5.0"
32
32
  },
33
33
  "peerDependencies": {
34
34
  "react": ">=18"