@hydrateless/react 0.6.0 → 0.7.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 +2 -2
- package/dist/index.d.ts +89 -20
- package/dist/index.js +18 -18
- package/package.json +3 -3
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
|
|
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
|
|
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
|
package/dist/index.d.ts
CHANGED
|
@@ -58,6 +58,7 @@ declare const useTocEnhancer: <T extends HTMLElement = HTMLElement>(options?: En
|
|
|
58
58
|
api: react.RefObject<null>;
|
|
59
59
|
};
|
|
60
60
|
|
|
61
|
+
/** Props for {@link Accordion}. */
|
|
61
62
|
interface AccordionProps extends HTMLAttributes<HTMLDivElement> {
|
|
62
63
|
/** Allow more than one panel to stay open at a time. */
|
|
63
64
|
allowMultiple?: boolean;
|
|
@@ -75,26 +76,30 @@ interface AccordionProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
75
76
|
* (`value` + `onValueChange`).
|
|
76
77
|
*/
|
|
77
78
|
declare function Accordion({ allowMultiple, value, defaultValue, onValueChange, children, ...rest }: AccordionProps): react.JSX.Element;
|
|
79
|
+
/** Props for {@link AccordionItem}. */
|
|
78
80
|
interface AccordionItemProps extends Omit<HTMLAttributes<HTMLDetailsElement>, 'title'> {
|
|
79
81
|
summary: ReactNode;
|
|
80
82
|
/** Stable value identifying this item; defaults to its index. */
|
|
81
83
|
value?: string;
|
|
82
84
|
defaultOpen?: boolean;
|
|
83
85
|
}
|
|
86
|
+
/** A single collapsible item within an {@link Accordion}, rendered as a native `<details>`. */
|
|
84
87
|
declare function AccordionItem({ summary, value, defaultOpen, children, ...rest }: AccordionItemProps): react.JSX.Element;
|
|
85
88
|
|
|
89
|
+
/** Props for {@link Disclosure}. */
|
|
86
90
|
interface DisclosureProps extends Omit<HTMLAttributes<HTMLDetailsElement>, 'title'> {
|
|
87
91
|
summary: ReactNode;
|
|
88
92
|
defaultOpen?: boolean;
|
|
89
93
|
}
|
|
90
94
|
/**
|
|
91
|
-
* A single expandable section. Purely presentational
|
|
95
|
+
* A single expandable section. Purely presentational: native `<details>`
|
|
92
96
|
* handles open/close, so no enhancer is required for a lone disclosure. Use
|
|
93
97
|
* `useEnhancer(enhanceDisclosure)` on a wrapper if you need a mutually
|
|
94
98
|
* exclusive group.
|
|
95
99
|
*/
|
|
96
100
|
declare function Disclosure({ summary, defaultOpen, className, children, ...rest }: DisclosureProps): react.JSX.Element;
|
|
97
101
|
|
|
102
|
+
/** Props for {@link Tabs}. */
|
|
98
103
|
interface TabsProps extends HTMLAttributes<HTMLDivElement> {
|
|
99
104
|
/** `manual` (default): arrows move focus, Enter/Space activates. `automatic`: arrows activate immediately. */
|
|
100
105
|
activation?: EnhanceTabsOptions['activation'];
|
|
@@ -125,19 +130,23 @@ interface TabsProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
125
130
|
* ```
|
|
126
131
|
*/
|
|
127
132
|
declare function Tabs({ activation, orientation, value, defaultValue, onValueChange, children, ...rest }: TabsProps): react.JSX.Element;
|
|
133
|
+
/** Props for {@link TabList}. */
|
|
128
134
|
type TabListProps = HTMLAttributes<HTMLDivElement>;
|
|
129
135
|
/** The row of tab triggers. Renders `role="tablist"`. */
|
|
130
136
|
declare function TabList({ children, ...rest }: TabListProps): react.JSX.Element;
|
|
137
|
+
/** Props for {@link Tab}. */
|
|
131
138
|
interface TabProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
132
139
|
/** Stable value identifying this tab; defaults to its index. */
|
|
133
140
|
value?: string;
|
|
134
141
|
}
|
|
135
142
|
/** A single tab trigger. Renders `role="tab"`. */
|
|
136
143
|
declare function Tab({ children, type, value, ...rest }: TabProps): react.JSX.Element;
|
|
144
|
+
/** Props for {@link TabPanel}. */
|
|
137
145
|
type TabPanelProps = HTMLAttributes<HTMLDivElement>;
|
|
138
146
|
/** Content for the matching tab. Renders `role="tabpanel"`. */
|
|
139
147
|
declare function TabPanel({ children, ...rest }: TabPanelProps): react.JSX.Element;
|
|
140
148
|
|
|
149
|
+
/** Props for {@link Dropdown}. */
|
|
141
150
|
interface DropdownProps extends HTMLAttributes<HTMLDivElement> {
|
|
142
151
|
placement?: EnhanceDropdownOptions['placement'];
|
|
143
152
|
/** Controlled open state (pair with `onOpenChange`). */
|
|
@@ -165,22 +174,27 @@ interface DropdownProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
165
174
|
* ```
|
|
166
175
|
*/
|
|
167
176
|
declare function Dropdown({ placement, open, defaultOpen, onOpenChange, children, ...rest }: DropdownProps): react.JSX.Element;
|
|
177
|
+
/** Props for {@link DropdownTrigger}. */
|
|
168
178
|
type DropdownTriggerProps = ButtonHTMLAttributes<HTMLButtonElement>;
|
|
169
179
|
/** The button that opens the menu. */
|
|
170
180
|
declare function DropdownTrigger({ children, type, ...rest }: DropdownTriggerProps): react.JSX.Element;
|
|
181
|
+
/** Props for {@link DropdownMenu}. */
|
|
171
182
|
type DropdownMenuProps = HTMLAttributes<HTMLUListElement>;
|
|
172
183
|
/** The menu surface; holds `<DropdownItem>` and `<DropdownSeparator>`. */
|
|
173
184
|
declare function DropdownMenu({ children, ...rest }: DropdownMenuProps): react.JSX.Element;
|
|
185
|
+
/** Props for {@link DropdownItem}. */
|
|
174
186
|
interface DropdownItemProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
175
187
|
/** Convenience handler fired on click; you can also pass `onClick`. */
|
|
176
188
|
onSelect?: () => void;
|
|
177
189
|
}
|
|
178
190
|
/** A selectable menu item (`role="menuitem"`). */
|
|
179
191
|
declare function DropdownItem({ children, onSelect, onClick, type, ...rest }: DropdownItemProps): react.JSX.Element;
|
|
192
|
+
/** Props for {@link DropdownSeparator}. */
|
|
180
193
|
type DropdownSeparatorProps = Omit<LiHTMLAttributes<HTMLLIElement>, 'role'>;
|
|
181
194
|
/** A visual divider between groups of items. */
|
|
182
195
|
declare function DropdownSeparator(props: DropdownSeparatorProps): react.JSX.Element;
|
|
183
196
|
|
|
197
|
+
/** Props for {@link Menu}. */
|
|
184
198
|
interface MenuProps extends HTMLAttributes<HTMLUListElement> {
|
|
185
199
|
orientation?: EnhanceMenuOptions['orientation'];
|
|
186
200
|
}
|
|
@@ -197,6 +211,7 @@ interface MenuProps extends HTMLAttributes<HTMLUListElement> {
|
|
|
197
211
|
* ```
|
|
198
212
|
*/
|
|
199
213
|
declare function Menu({ orientation, children, ...rest }: MenuProps): react.JSX.Element;
|
|
214
|
+
/** Props for {@link MenuItem}. */
|
|
200
215
|
interface MenuItemProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'href' | 'type'> {
|
|
201
216
|
/** Render as a link instead of a button. */
|
|
202
217
|
href?: string;
|
|
@@ -213,6 +228,7 @@ interface MenuItemProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'h
|
|
|
213
228
|
*/
|
|
214
229
|
declare function MenuItem({ href, onSelect, onClick, submenu, anchorProps, children, ...rest }: MenuItemProps): react.JSX.Element;
|
|
215
230
|
|
|
231
|
+
/** Props for {@link Modal}. */
|
|
216
232
|
interface ModalProps extends Omit<HTMLAttributes<HTMLDialogElement>, 'title'> {
|
|
217
233
|
open: boolean;
|
|
218
234
|
/** Called after the dialog opens or closes (Escape, backdrop, close buttons). */
|
|
@@ -235,6 +251,7 @@ interface ModalProps extends Omit<HTMLAttributes<HTMLDialogElement>, 'title'> {
|
|
|
235
251
|
* ```
|
|
236
252
|
*/
|
|
237
253
|
declare function Modal({ open, onOpenChange, closeOnBackdrop, className, children, ...rest }: ModalProps): react.JSX.Element;
|
|
254
|
+
/** Props shared by the {@link Modal} section components. */
|
|
238
255
|
type ModalSectionProps = HTMLAttributes<HTMLDivElement>;
|
|
239
256
|
/** Modal heading region; its content labels the dialog for assistive tech. */
|
|
240
257
|
declare function ModalHeader({ className, ...rest }: ModalSectionProps): react.JSX.Element;
|
|
@@ -243,6 +260,7 @@ declare function ModalBody({ className, ...rest }: ModalSectionProps): react.JSX
|
|
|
243
260
|
/** Modal actions region. */
|
|
244
261
|
declare function ModalFooter({ className, ...rest }: ModalSectionProps): react.JSX.Element;
|
|
245
262
|
|
|
263
|
+
/** Props for {@link Drawer}. */
|
|
246
264
|
interface DrawerProps extends Omit<HTMLAttributes<HTMLDialogElement>, 'title'> {
|
|
247
265
|
open: boolean;
|
|
248
266
|
/** Called after the drawer opens or closes (Escape, backdrop, close buttons). */
|
|
@@ -257,6 +275,7 @@ interface DrawerProps extends Omit<HTMLAttributes<HTMLDialogElement>, 'title'> {
|
|
|
257
275
|
* `<DrawerHeader>`, `<DrawerBody>`, and `<DrawerFooter>`.
|
|
258
276
|
*/
|
|
259
277
|
declare function Drawer({ open, onOpenChange, side, closeOnBackdrop, className, children, ...rest }: DrawerProps): react.JSX.Element;
|
|
278
|
+
/** Props shared by the {@link Drawer} section components. */
|
|
260
279
|
type DrawerSectionProps = HTMLAttributes<HTMLDivElement>;
|
|
261
280
|
/** Drawer heading region. */
|
|
262
281
|
declare function DrawerHeader({ className, ...rest }: DrawerSectionProps): react.JSX.Element;
|
|
@@ -265,20 +284,23 @@ declare function DrawerBody({ className, ...rest }: DrawerSectionProps): react.J
|
|
|
265
284
|
/** Drawer actions region. */
|
|
266
285
|
declare function DrawerFooter({ className, ...rest }: DrawerSectionProps): react.JSX.Element;
|
|
267
286
|
|
|
287
|
+
/** Props for {@link Popover}. */
|
|
268
288
|
interface PopoverProps extends HTMLAttributes<HTMLDivElement> {
|
|
269
289
|
open: boolean;
|
|
270
|
-
/** Called when Escape or
|
|
290
|
+
/** Called when the browser's light-dismiss (Escape or outside click) closes it. */
|
|
271
291
|
onOpenChange?: (open: boolean) => void;
|
|
272
292
|
children?: ReactNode;
|
|
273
293
|
}
|
|
274
294
|
/**
|
|
275
|
-
* Controlled floating content
|
|
276
|
-
*
|
|
277
|
-
*
|
|
278
|
-
*
|
|
295
|
+
* Controlled floating content built on the native Popover API. The surface
|
|
296
|
+
* lives in the top layer with light-dismiss and Escape handled by the browser;
|
|
297
|
+
* visibility follows the `open` prop and `onOpenChange` fires when the browser
|
|
298
|
+
* dismisses it. Pair it with your own trigger button (toggling `open`) and
|
|
299
|
+
* position it with the `hydrateless/popover.css` styles.
|
|
279
300
|
*/
|
|
280
301
|
declare function Popover({ open, onOpenChange, children, ...rest }: PopoverProps): react.JSX.Element;
|
|
281
302
|
|
|
303
|
+
/** Props for {@link Tooltip}. */
|
|
282
304
|
interface TooltipProps {
|
|
283
305
|
/** The hint text shown on hover/focus. */
|
|
284
306
|
label: ReactNode;
|
|
@@ -292,6 +314,7 @@ interface TooltipProps {
|
|
|
292
314
|
*/
|
|
293
315
|
declare function Tooltip({ label, children, id }: TooltipProps): react.JSX.Element;
|
|
294
316
|
|
|
317
|
+
/** Props for {@link Breadcrumb}. */
|
|
295
318
|
type BreadcrumbProps = HTMLAttributes<HTMLElement>;
|
|
296
319
|
/**
|
|
297
320
|
* Semantic breadcrumb navigation (`<nav> > <ol>`). CSS-only, no enhancer.
|
|
@@ -305,6 +328,7 @@ type BreadcrumbProps = HTMLAttributes<HTMLElement>;
|
|
|
305
328
|
* ```
|
|
306
329
|
*/
|
|
307
330
|
declare function Breadcrumb({ children, ...rest }: BreadcrumbProps): react.JSX.Element;
|
|
331
|
+
/** Props for {@link BreadcrumbItem}. */
|
|
308
332
|
interface BreadcrumbItemProps extends Omit<LiHTMLAttributes<HTMLLIElement>, 'children'> {
|
|
309
333
|
href?: string;
|
|
310
334
|
/** Marks the current page; renders a non-link with `aria-current="page"`. */
|
|
@@ -315,18 +339,21 @@ interface BreadcrumbItemProps extends Omit<LiHTMLAttributes<HTMLLIElement>, 'chi
|
|
|
315
339
|
/** A single crumb. Renders a link unless `current` (or no `href`) is set. */
|
|
316
340
|
declare function BreadcrumbItem({ href, current, anchorProps, children, ...rest }: BreadcrumbItemProps): react.JSX.Element;
|
|
317
341
|
|
|
342
|
+
/** Props for {@link Switch}. */
|
|
318
343
|
interface SwitchProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'type'> {
|
|
319
344
|
children?: ReactNode;
|
|
320
345
|
}
|
|
321
346
|
/** Toggle switch built on a native checkbox. CSS-only. */
|
|
322
347
|
declare function Switch({ children, className, ...rest }: SwitchProps): react.JSX.Element;
|
|
323
348
|
|
|
349
|
+
/** Props for {@link SkipLink}. */
|
|
324
350
|
type SkipLinkProps = AnchorHTMLAttributes<HTMLAnchorElement> & {
|
|
325
351
|
children?: ReactNode;
|
|
326
352
|
};
|
|
327
353
|
/** Accessibility skip-navigation link, visually hidden until focused. */
|
|
328
354
|
declare function SkipLink({ children, className, ...rest }: SkipLinkProps): react.JSX.Element;
|
|
329
355
|
|
|
356
|
+
/** Props for {@link Toc}. */
|
|
330
357
|
interface TocProps extends HTMLAttributes<HTMLElement> {
|
|
331
358
|
/** CSS selector for the content root to scan for headings. */
|
|
332
359
|
contentSelector?: string;
|
|
@@ -338,6 +365,7 @@ interface TocProps extends HTMLAttributes<HTMLElement> {
|
|
|
338
365
|
/** Auto-generated table of contents with optional scroll-spy. */
|
|
339
366
|
declare function Toc({ contentSelector, headings, scrollSpy, ...rest }: TocProps): react.JSX.Element;
|
|
340
367
|
|
|
368
|
+
/** Props for {@link ToastRegion}. */
|
|
341
369
|
type ToastRegionProps = HTMLAttributes<HTMLDivElement>;
|
|
342
370
|
/**
|
|
343
371
|
* The polite live region toasts render into. Render once near the root of
|
|
@@ -351,6 +379,7 @@ declare function ToastRegion(props: ToastRegionProps): react.JSX.Element;
|
|
|
351
379
|
*/
|
|
352
380
|
declare function useToast(): ToastApi;
|
|
353
381
|
|
|
382
|
+
/** Props for {@link Combobox}. */
|
|
354
383
|
interface ComboboxProps extends Omit<HTMLAttributes<HTMLDivElement>, 'onChange'> {
|
|
355
384
|
filter?: EnhanceComboboxOptions['filter'];
|
|
356
385
|
autoHighlight?: EnhanceComboboxOptions['autoHighlight'];
|
|
@@ -379,21 +408,25 @@ interface ComboboxProps extends Omit<HTMLAttributes<HTMLDivElement>, 'onChange'>
|
|
|
379
408
|
* ```
|
|
380
409
|
*/
|
|
381
410
|
declare function Combobox({ filter, autoHighlight, value, defaultValue, onValueChange, children, ...rest }: ComboboxProps): react.JSX.Element;
|
|
411
|
+
/** Props for {@link ComboboxInput}. */
|
|
382
412
|
interface ComboboxInputProps extends InputHTMLAttributes<HTMLInputElement> {
|
|
383
413
|
/** Apply the `hl-input` style. Defaults to `true`. */
|
|
384
414
|
styled?: boolean;
|
|
385
415
|
}
|
|
386
416
|
/** The combobox text field. */
|
|
387
417
|
declare function ComboboxInput({ styled, className, ...rest }: ComboboxInputProps): react.JSX.Element;
|
|
418
|
+
/** Props for {@link ComboboxList}. */
|
|
388
419
|
type ComboboxListProps = HTMLAttributes<HTMLUListElement>;
|
|
389
420
|
/** The option popup (`role="listbox"`). */
|
|
390
421
|
declare function ComboboxList({ children, ...rest }: ComboboxListProps): react.JSX.Element;
|
|
422
|
+
/** Props for {@link ComboboxOption}. */
|
|
391
423
|
interface ComboboxOptionProps extends Omit<LiHTMLAttributes<HTMLLIElement>, 'value'> {
|
|
392
424
|
value: string;
|
|
393
425
|
}
|
|
394
426
|
/** A selectable option. The `value` is committed on selection. */
|
|
395
427
|
declare function ComboboxOption({ value, children, ...rest }: ComboboxOptionProps): react.JSX.Element;
|
|
396
428
|
|
|
429
|
+
/** Props for {@link Command}. */
|
|
397
430
|
interface CommandProps extends Omit<HTMLAttributes<HTMLDivElement>, 'onSelect'> {
|
|
398
431
|
/** Lowercased key that opens the palette's dialog with Cmd/Ctrl. */
|
|
399
432
|
hotkey?: string;
|
|
@@ -407,20 +440,24 @@ interface CommandProps extends Omit<HTMLAttributes<HTMLDivElement>, 'onSelect'>
|
|
|
407
440
|
* runs the active item on Enter. Place inside a `<dialog>` to use `hotkey`.
|
|
408
441
|
*/
|
|
409
442
|
declare function Command({ hotkey, onSelect, children, ...rest }: CommandProps): react.JSX.Element;
|
|
443
|
+
/** Props for {@link CommandInput}. */
|
|
410
444
|
interface CommandInputProps extends InputHTMLAttributes<HTMLInputElement> {
|
|
411
445
|
styled?: boolean;
|
|
412
446
|
}
|
|
413
447
|
/** The palette search field. */
|
|
414
448
|
declare function CommandInput({ styled, className, ...rest }: CommandInputProps): react.JSX.Element;
|
|
449
|
+
/** Props for {@link CommandList}. */
|
|
415
450
|
type CommandListProps = HTMLAttributes<HTMLDivElement>;
|
|
416
451
|
/** The scrollable list of commands (`role="listbox"`). */
|
|
417
452
|
declare function CommandList({ children, ...rest }: CommandListProps): react.JSX.Element;
|
|
453
|
+
/** Props for {@link CommandGroup}. */
|
|
418
454
|
interface CommandGroupProps extends HTMLAttributes<HTMLDivElement> {
|
|
419
455
|
/** Optional heading shown above the grouped items. */
|
|
420
456
|
label?: ReactNode;
|
|
421
457
|
}
|
|
422
458
|
/** A labelled group of commands. */
|
|
423
459
|
declare function CommandGroup({ label, children, ...rest }: CommandGroupProps): react.JSX.Element;
|
|
460
|
+
/** Props for {@link CommandItem}. */
|
|
424
461
|
interface CommandItemProps extends Omit<HTMLAttributes<HTMLDivElement>, 'onSelect'> {
|
|
425
462
|
value: string;
|
|
426
463
|
/** Extra search terms for filtering. */
|
|
@@ -430,10 +467,12 @@ interface CommandItemProps extends Omit<HTMLAttributes<HTMLDivElement>, 'onSelec
|
|
|
430
467
|
}
|
|
431
468
|
/** A runnable command (`role="option"`). */
|
|
432
469
|
declare function CommandItem({ value, keywords, icon, children, ...rest }: CommandItemProps): react.JSX.Element;
|
|
470
|
+
/** Props for {@link CommandEmpty}. */
|
|
433
471
|
type CommandEmptyProps = HTMLAttributes<HTMLDivElement>;
|
|
434
472
|
/** Shown when no commands match the query. */
|
|
435
473
|
declare function CommandEmpty({ children, ...rest }: CommandEmptyProps): react.JSX.Element;
|
|
436
474
|
|
|
475
|
+
/** Props for {@link Input}. */
|
|
437
476
|
interface InputProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'size'> {
|
|
438
477
|
size?: 'sm' | 'md' | 'lg';
|
|
439
478
|
invalid?: boolean;
|
|
@@ -441,17 +480,20 @@ interface InputProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'size'>
|
|
|
441
480
|
/** Text input styled with the `hl-input` primitive. */
|
|
442
481
|
declare const Input: react.ForwardRefExoticComponent<InputProps & react.RefAttributes<HTMLInputElement>>;
|
|
443
482
|
|
|
483
|
+
/** Props for {@link Textarea}. */
|
|
444
484
|
interface TextareaProps extends TextareaHTMLAttributes<HTMLTextAreaElement> {
|
|
445
485
|
invalid?: boolean;
|
|
446
486
|
}
|
|
447
487
|
/** Multi-line text input styled with the `hl-textarea` primitive. */
|
|
448
488
|
declare const Textarea: react.ForwardRefExoticComponent<TextareaProps & react.RefAttributes<HTMLTextAreaElement>>;
|
|
449
489
|
|
|
490
|
+
/** A single option in a {@link Select}. */
|
|
450
491
|
interface SelectOption {
|
|
451
492
|
label: ReactNode;
|
|
452
493
|
value: string;
|
|
453
494
|
disabled?: boolean;
|
|
454
495
|
}
|
|
496
|
+
/** Props for {@link Select}. */
|
|
455
497
|
interface SelectProps extends Omit<SelectHTMLAttributes<HTMLSelectElement>, 'size'> {
|
|
456
498
|
size?: 'sm' | 'md' | 'lg';
|
|
457
499
|
invalid?: boolean;
|
|
@@ -465,18 +507,21 @@ interface SelectProps extends Omit<SelectHTMLAttributes<HTMLSelectElement>, 'siz
|
|
|
465
507
|
*/
|
|
466
508
|
declare const Select: react.ForwardRefExoticComponent<SelectProps & react.RefAttributes<HTMLSelectElement>>;
|
|
467
509
|
|
|
510
|
+
/** Props for {@link Checkbox}. */
|
|
468
511
|
interface CheckboxProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'type'> {
|
|
469
512
|
children?: ReactNode;
|
|
470
513
|
}
|
|
471
514
|
/** Checkbox built on a native `<input type="checkbox">`, label-wrapped. */
|
|
472
515
|
declare const Checkbox: react.ForwardRefExoticComponent<CheckboxProps & react.RefAttributes<HTMLInputElement>>;
|
|
473
516
|
|
|
517
|
+
/** Props for {@link Radio}. */
|
|
474
518
|
interface RadioProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'type'> {
|
|
475
519
|
children?: ReactNode;
|
|
476
520
|
value: string;
|
|
477
521
|
}
|
|
478
522
|
/** A single radio built on a native `<input type="radio">`, label-wrapped. */
|
|
479
523
|
declare const Radio: react.ForwardRefExoticComponent<RadioProps & react.RefAttributes<HTMLInputElement>>;
|
|
524
|
+
/** Props for {@link RadioGroup}. */
|
|
480
525
|
interface RadioGroupProps extends Omit<HTMLAttributes<HTMLDivElement>, 'onChange'> {
|
|
481
526
|
name?: string;
|
|
482
527
|
value?: string;
|
|
@@ -488,6 +533,7 @@ interface RadioGroupProps extends Omit<HTMLAttributes<HTMLDivElement>, 'onChange
|
|
|
488
533
|
*/
|
|
489
534
|
declare function RadioGroup({ name, value, onValueChange, className, children, ...rest }: RadioGroupProps): react.JSX.Element;
|
|
490
535
|
|
|
536
|
+
/** Props for {@link Field}. */
|
|
491
537
|
interface FieldProps extends HTMLAttributes<HTMLDivElement> {
|
|
492
538
|
id?: string;
|
|
493
539
|
invalid?: boolean;
|
|
@@ -509,6 +555,7 @@ declare function useField(): {
|
|
|
509
555
|
'aria-describedby': string | undefined;
|
|
510
556
|
'aria-invalid': true | undefined;
|
|
511
557
|
};
|
|
558
|
+
/** Props for {@link FieldLabel}. */
|
|
512
559
|
type FieldLabelProps = LabelHTMLAttributes<HTMLLabelElement>;
|
|
513
560
|
/** Label bound to the enclosing field's control via `htmlFor`. */
|
|
514
561
|
declare function FieldLabel({ className, children, ...rest }: FieldLabelProps): react.JSX.Element;
|
|
@@ -516,17 +563,20 @@ declare function FieldLabel({ className, children, ...rest }: FieldLabelProps):
|
|
|
516
563
|
declare function FieldHelp({ className, children, ...rest }: HTMLAttributes<HTMLParagraphElement>): react.JSX.Element;
|
|
517
564
|
/** Validation message; renders nothing unless given content. */
|
|
518
565
|
declare function FieldError({ className, children, ...rest }: HTMLAttributes<HTMLParagraphElement>): react.JSX.Element | null;
|
|
566
|
+
/** Props for {@link Fieldset}. */
|
|
519
567
|
interface FieldsetProps extends HTMLAttributes<HTMLFieldSetElement> {
|
|
520
568
|
legend?: ReactNode;
|
|
521
569
|
}
|
|
522
570
|
/** Grouped fields with an optional legend. */
|
|
523
571
|
declare function Fieldset({ legend, className, children, ...rest }: FieldsetProps): react.JSX.Element;
|
|
524
572
|
|
|
573
|
+
/** A single option in a {@link SegmentedControl}. */
|
|
525
574
|
interface SegmentedOption {
|
|
526
575
|
label: ReactNode;
|
|
527
576
|
value: string;
|
|
528
577
|
disabled?: boolean;
|
|
529
578
|
}
|
|
579
|
+
/** Props for {@link SegmentedControl}. */
|
|
530
580
|
interface SegmentedControlProps extends Omit<HTMLAttributes<HTMLDivElement>, 'onChange'> {
|
|
531
581
|
options: SegmentedOption[];
|
|
532
582
|
value?: string;
|
|
@@ -536,16 +586,18 @@ interface SegmentedControlProps extends Omit<HTMLAttributes<HTMLDivElement>, 'on
|
|
|
536
586
|
size?: 'sm' | 'md' | 'lg';
|
|
537
587
|
}
|
|
538
588
|
/**
|
|
539
|
-
* Segmented control
|
|
589
|
+
* Segmented control: `hl-segmented` radiogroup. Controlled via `value` or
|
|
540
590
|
* uncontrolled via `defaultValue`. Built on native radios for free keyboard
|
|
541
591
|
* navigation.
|
|
542
592
|
*/
|
|
543
593
|
declare function SegmentedControl({ options, value, defaultValue, onValueChange, name, size, className, ...rest }: SegmentedControlProps): react.JSX.Element;
|
|
544
594
|
|
|
595
|
+
/** Props for {@link Slider}. */
|
|
545
596
|
type SliderProps = Omit<InputHTMLAttributes<HTMLInputElement>, 'type'>;
|
|
546
|
-
/** Range slider primitive
|
|
597
|
+
/** Range slider primitive: `<input type="range" class="hl-slider">`. */
|
|
547
598
|
declare const Slider: react.ForwardRefExoticComponent<SliderProps & react.RefAttributes<HTMLInputElement>>;
|
|
548
599
|
|
|
600
|
+
/** Props for {@link Button}. */
|
|
549
601
|
interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
550
602
|
variant?: 'solid' | 'soft' | 'outline' | 'ghost' | 'link';
|
|
551
603
|
intent?: 'neutral' | 'primary' | 'danger' | 'success' | 'warning' | 'info';
|
|
@@ -557,39 +609,49 @@ interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
|
557
609
|
/** Show a spinner and disable interaction. */
|
|
558
610
|
loading?: boolean;
|
|
559
611
|
}
|
|
560
|
-
/** Button primitive
|
|
612
|
+
/** Button primitive: `hl-button` with intent/variant/size modifiers. */
|
|
561
613
|
declare const Button: react.ForwardRefExoticComponent<ButtonProps & react.RefAttributes<HTMLButtonElement>>;
|
|
562
614
|
|
|
615
|
+
/** Props for {@link Alert}. */
|
|
563
616
|
interface AlertProps extends Omit<HTMLAttributes<HTMLDivElement>, 'title'> {
|
|
564
617
|
intent?: 'info' | 'success' | 'warning' | 'danger' | 'neutral';
|
|
565
618
|
title?: ReactNode;
|
|
566
619
|
/** Leading icon, rendered before the body. */
|
|
567
620
|
icon?: ReactNode;
|
|
568
621
|
}
|
|
569
|
-
/** Alert primitive
|
|
622
|
+
/** Alert primitive: `hl-alert` with intent, optional icon + title. */
|
|
570
623
|
declare const Alert: react.ForwardRefExoticComponent<AlertProps & react.RefAttributes<HTMLDivElement>>;
|
|
571
624
|
|
|
625
|
+
/** Props for {@link Badge}. */
|
|
572
626
|
interface BadgeProps extends HTMLAttributes<HTMLSpanElement> {
|
|
573
627
|
intent?: 'neutral' | 'primary' | 'danger' | 'success' | 'warning' | 'info';
|
|
574
628
|
variant?: 'soft' | 'solid' | 'outline';
|
|
575
629
|
size?: 'sm' | 'md';
|
|
576
630
|
}
|
|
577
|
-
/** Badge primitive
|
|
631
|
+
/** Badge primitive: `hl-badge` with intent/variant/size modifiers. */
|
|
578
632
|
declare const Badge: react.ForwardRefExoticComponent<BadgeProps & react.RefAttributes<HTMLSpanElement>>;
|
|
579
633
|
|
|
634
|
+
/** Props for {@link Card}. */
|
|
580
635
|
interface CardProps extends HTMLAttributes<HTMLDivElement> {
|
|
581
636
|
/** Hover/active elevation for clickable cards. */
|
|
582
637
|
interactive?: boolean;
|
|
583
638
|
}
|
|
584
|
-
/** Card container
|
|
639
|
+
/** Card container: `hl-card`. Compose with the Card.* parts. */
|
|
585
640
|
declare const Card: react.ForwardRefExoticComponent<CardProps & react.RefAttributes<HTMLDivElement>>;
|
|
641
|
+
/** Props shared by the {@link Card} section components. */
|
|
586
642
|
type CardSectionProps = HTMLAttributes<HTMLDivElement>;
|
|
643
|
+
/** Header region of a {@link Card}. */
|
|
587
644
|
declare const CardHeader: react.ForwardRefExoticComponent<CardSectionProps & react.RefAttributes<HTMLDivElement>>;
|
|
645
|
+
/** Body region of a {@link Card}. */
|
|
588
646
|
declare const CardBody: react.ForwardRefExoticComponent<CardSectionProps & react.RefAttributes<HTMLDivElement>>;
|
|
647
|
+
/** Footer region of a {@link Card}. */
|
|
589
648
|
declare const CardFooter: react.ForwardRefExoticComponent<CardSectionProps & react.RefAttributes<HTMLDivElement>>;
|
|
649
|
+
/** Title heading of a {@link Card}. */
|
|
590
650
|
declare const CardTitle: react.ForwardRefExoticComponent<HTMLAttributes<HTMLHeadingElement> & react.RefAttributes<HTMLHeadingElement>>;
|
|
651
|
+
/** Description text of a {@link Card}. */
|
|
591
652
|
declare const CardDescription: react.ForwardRefExoticComponent<HTMLAttributes<HTMLParagraphElement> & react.RefAttributes<HTMLParagraphElement>>;
|
|
592
653
|
|
|
654
|
+
/** Props for {@link Avatar}. */
|
|
593
655
|
interface AvatarProps extends HTMLAttributes<HTMLSpanElement> {
|
|
594
656
|
src?: string;
|
|
595
657
|
alt?: string;
|
|
@@ -598,12 +660,14 @@ interface AvatarProps extends HTMLAttributes<HTMLSpanElement> {
|
|
|
598
660
|
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
599
661
|
shape?: 'circle' | 'square';
|
|
600
662
|
}
|
|
601
|
-
/** Avatar primitive
|
|
663
|
+
/** Avatar primitive: `hl-avatar` with image + graceful fallback. */
|
|
602
664
|
declare const Avatar: react.ForwardRefExoticComponent<AvatarProps & react.RefAttributes<HTMLSpanElement>>;
|
|
665
|
+
/** Props for {@link AvatarGroup}. */
|
|
603
666
|
type AvatarGroupProps = HTMLAttributes<HTMLDivElement>;
|
|
604
667
|
/** Overlapping stack of avatars. */
|
|
605
668
|
declare const AvatarGroup: react.ForwardRefExoticComponent<AvatarGroupProps & react.RefAttributes<HTMLDivElement>>;
|
|
606
669
|
|
|
670
|
+
/** Props for {@link Progress}. */
|
|
607
671
|
interface ProgressProps extends Omit<ProgressHTMLAttributes<HTMLProgressElement>, 'value'> {
|
|
608
672
|
/** Omit for an indeterminate bar. */
|
|
609
673
|
value?: number;
|
|
@@ -611,25 +675,28 @@ interface ProgressProps extends Omit<ProgressHTMLAttributes<HTMLProgressElement>
|
|
|
611
675
|
intent?: 'primary' | 'success' | 'warning' | 'danger' | 'info';
|
|
612
676
|
size?: 'sm' | 'md' | 'lg';
|
|
613
677
|
}
|
|
614
|
-
/** Progress primitive
|
|
678
|
+
/** Progress primitive: native `<progress class="hl-progress">`. */
|
|
615
679
|
declare const Progress: react.ForwardRefExoticComponent<ProgressProps & react.RefAttributes<HTMLProgressElement>>;
|
|
616
680
|
|
|
681
|
+
/** Props for {@link Spinner}. */
|
|
617
682
|
interface SpinnerProps extends HTMLAttributes<HTMLSpanElement> {
|
|
618
683
|
size?: 'sm' | 'md' | 'lg' | 'xl';
|
|
619
684
|
/** Accessible label; announced via `role="status"`. */
|
|
620
685
|
label?: string;
|
|
621
686
|
}
|
|
622
|
-
/** Spinner primitive
|
|
687
|
+
/** Spinner primitive: `hl-spinner`. Inherits `currentColor`. */
|
|
623
688
|
declare const Spinner: react.ForwardRefExoticComponent<SpinnerProps & react.RefAttributes<HTMLSpanElement>>;
|
|
624
689
|
|
|
690
|
+
/** Props for {@link Skeleton}. */
|
|
625
691
|
interface SkeletonProps extends HTMLAttributes<HTMLSpanElement> {
|
|
626
692
|
variant?: 'rect' | 'text' | 'circle';
|
|
627
693
|
width?: string | number;
|
|
628
694
|
height?: string | number;
|
|
629
695
|
}
|
|
630
|
-
/** Skeleton placeholder primitive
|
|
696
|
+
/** Skeleton placeholder primitive: `hl-skeleton`. */
|
|
631
697
|
declare const Skeleton: react.ForwardRefExoticComponent<SkeletonProps & react.RefAttributes<HTMLSpanElement>>;
|
|
632
698
|
|
|
699
|
+
/** Props for {@link Pagination}. */
|
|
633
700
|
interface PaginationProps extends Omit<HTMLAttributes<HTMLElement>, 'onChange'> {
|
|
634
701
|
page: number;
|
|
635
702
|
count: number;
|
|
@@ -641,19 +708,21 @@ interface PaginationProps extends Omit<HTMLAttributes<HTMLElement>, 'onChange'>
|
|
|
641
708
|
prevLabel?: ReactNode;
|
|
642
709
|
nextLabel?: ReactNode;
|
|
643
710
|
}
|
|
644
|
-
/** Pagination primitive
|
|
711
|
+
/** Pagination primitive: `hl-pagination` with smart ellipsis truncation. */
|
|
645
712
|
declare function Pagination({ page, count, onPageChange, siblingCount, showControls, prevLabel, nextLabel, className, ...rest }: PaginationProps): react.JSX.Element;
|
|
646
713
|
|
|
714
|
+
/** Props for {@link Kbd}. */
|
|
647
715
|
type KbdProps = HTMLAttributes<HTMLElement>;
|
|
648
|
-
/** Keyboard key primitive
|
|
716
|
+
/** Keyboard key primitive: `<kbd class="hl-kbd">`. */
|
|
649
717
|
declare const Kbd: react.ForwardRefExoticComponent<KbdProps & react.RefAttributes<HTMLElement>>;
|
|
650
718
|
|
|
719
|
+
/** Props for {@link Separator}. */
|
|
651
720
|
interface SeparatorProps extends HTMLAttributes<HTMLHRElement> {
|
|
652
721
|
orientation?: 'horizontal' | 'vertical';
|
|
653
|
-
/** Purely decorative
|
|
722
|
+
/** Purely decorative: removes it from the accessibility tree. */
|
|
654
723
|
decorative?: boolean;
|
|
655
724
|
}
|
|
656
|
-
/** Separator primitive
|
|
725
|
+
/** Separator primitive: `<hr class="hl-separator">`. */
|
|
657
726
|
declare const Separator: react.ForwardRefExoticComponent<SeparatorProps & react.RefAttributes<HTMLHRElement>>;
|
|
658
727
|
|
|
659
728
|
/** Join truthy class names into a single string. */
|
package/dist/index.js
CHANGED
|
@@ -344,19 +344,19 @@ function DrawerFooter({ className, ...rest }) {
|
|
|
344
344
|
}
|
|
345
345
|
|
|
346
346
|
// src/Popover.tsx
|
|
347
|
-
import { useEffect as useEffect9
|
|
348
|
-
import {
|
|
347
|
+
import { useEffect as useEffect9 } from "react";
|
|
348
|
+
import { enhancePopover } from "@hydrateless/enhancers";
|
|
349
349
|
import { jsx as jsx8 } from "react/jsx-runtime";
|
|
350
350
|
function Popover({ open, onOpenChange, children, ...rest }) {
|
|
351
|
-
const ref = useRef6(null);
|
|
352
351
|
const onOpenChangeRef = useLatest(onOpenChange);
|
|
352
|
+
const { ref, api } = useEnhancer(
|
|
353
|
+
(el) => enhancePopover(el, { onOpenChange: (next) => onOpenChangeRef.current?.(next) }),
|
|
354
|
+
[]
|
|
355
|
+
);
|
|
353
356
|
useEffect9(() => {
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
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 });
|
|
357
|
+
api.current?.setOpen(open);
|
|
358
|
+
}, [open, api]);
|
|
359
|
+
return /* @__PURE__ */ jsx8("div", { ...rest, ref, "data-hl-popover": true, popover: "auto", role: "dialog", children });
|
|
360
360
|
}
|
|
361
361
|
|
|
362
362
|
// src/Tooltip.tsx
|
|
@@ -365,14 +365,14 @@ import {
|
|
|
365
365
|
isValidElement,
|
|
366
366
|
useEffect as useEffect10,
|
|
367
367
|
useId,
|
|
368
|
-
useRef as
|
|
368
|
+
useRef as useRef6
|
|
369
369
|
} from "react";
|
|
370
370
|
import { enhanceTooltip as enhanceTooltip2 } from "@hydrateless/enhancers";
|
|
371
371
|
import { jsx as jsx9, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
372
372
|
function Tooltip({ label, children, id }) {
|
|
373
373
|
const generatedId = useId().replace(/:/g, "");
|
|
374
374
|
const tipId = id ?? `hl-tip-${generatedId}`;
|
|
375
|
-
const ref =
|
|
375
|
+
const ref = useRef6(null);
|
|
376
376
|
useEffect10(() => {
|
|
377
377
|
if (!ref.current) return;
|
|
378
378
|
return enhanceTooltip2(ref.current).destroy;
|
|
@@ -418,11 +418,11 @@ function SkipLink({ children = "Skip to content", className, ...rest }) {
|
|
|
418
418
|
}
|
|
419
419
|
|
|
420
420
|
// src/Toc.tsx
|
|
421
|
-
import { useEffect as useEffect11, useRef as
|
|
421
|
+
import { useEffect as useEffect11, useRef as useRef7 } from "react";
|
|
422
422
|
import { enhanceToc as enhanceToc2 } from "@hydrateless/enhancers";
|
|
423
423
|
import { jsx as jsx13 } from "react/jsx-runtime";
|
|
424
424
|
function Toc({ contentSelector, headings, scrollSpy, ...rest }) {
|
|
425
|
-
const ref =
|
|
425
|
+
const ref = useRef7(null);
|
|
426
426
|
useEffect11(() => {
|
|
427
427
|
if (!ref.current) return;
|
|
428
428
|
return enhanceToc2(ref.current.ownerDocument, { contentSelector, headings, scrollSpy }).destroy;
|
|
@@ -431,7 +431,7 @@ function Toc({ contentSelector, headings, scrollSpy, ...rest }) {
|
|
|
431
431
|
}
|
|
432
432
|
|
|
433
433
|
// src/Toast.tsx
|
|
434
|
-
import { useEffect as useEffect12, useRef as
|
|
434
|
+
import { useEffect as useEffect12, useRef as useRef8 } from "react";
|
|
435
435
|
import { enhanceToast } from "@hydrateless/enhancers";
|
|
436
436
|
import { jsx as jsx14 } from "react/jsx-runtime";
|
|
437
437
|
var sharedApi = null;
|
|
@@ -447,7 +447,7 @@ var facade = {
|
|
|
447
447
|
dismiss: (toast) => ensureApi().dismiss(toast)
|
|
448
448
|
};
|
|
449
449
|
function ToastRegion(props) {
|
|
450
|
-
const ref =
|
|
450
|
+
const ref = useRef8(null);
|
|
451
451
|
useEffect12(() => {
|
|
452
452
|
if (!ref.current) return;
|
|
453
453
|
const handle = enhanceToast(ref.current.ownerDocument);
|
|
@@ -509,13 +509,13 @@ function ComboboxOption({ value, children, ...rest }) {
|
|
|
509
509
|
// src/Command.tsx
|
|
510
510
|
import {
|
|
511
511
|
useEffect as useEffect14,
|
|
512
|
-
useRef as
|
|
512
|
+
useRef as useRef9
|
|
513
513
|
} from "react";
|
|
514
514
|
import { enhanceCommand } from "@hydrateless/enhancers";
|
|
515
515
|
import { jsx as jsx16, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
516
516
|
function Command({ hotkey, onSelect, children, ...rest }) {
|
|
517
|
-
const ref =
|
|
518
|
-
const onSelectRef =
|
|
517
|
+
const ref = useRef9(null);
|
|
518
|
+
const onSelectRef = useRef9(onSelect);
|
|
519
519
|
onSelectRef.current = onSelect;
|
|
520
520
|
useEffect14(() => {
|
|
521
521
|
const el = ref.current;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hydrateless/react",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "React bindings for Hydrateless
|
|
3
|
+
"version": "0.7.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.
|
|
31
|
+
"@hydrateless/enhancers": "^0.7.0"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
34
34
|
"react": ">=18"
|