anvilui 0.1.0 → 0.2.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 (142) hide show
  1. package/AGENTS.md +483 -0
  2. package/README.md +70 -3
  3. package/bin/anvilui.mjs +83 -0
  4. package/dist/colors/colors.d.ts +10 -2
  5. package/dist/components/Accordion/Accordion.d.ts +36 -0
  6. package/dist/components/AnimatedNumber/AnimatedNumber.d.ts +17 -0
  7. package/dist/components/AnvilRoot/AnvilContext.d.ts +22 -2
  8. package/dist/components/AnvilRoot/AnvilRoot.d.ts +44 -6
  9. package/dist/components/AppBar/AppBar.d.ts +13 -2
  10. package/dist/components/Avatar/Avatar.d.ts +6 -2
  11. package/dist/components/Avatar/AvatarGroupContext.d.ts +1 -0
  12. package/dist/components/AvatarGroup/AvatarGroup.d.ts +25 -0
  13. package/dist/components/Badge/Badge.d.ts +4 -0
  14. package/dist/components/BottomSheet/BottomSheet.d.ts +22 -0
  15. package/dist/components/Button/Button.d.ts +17 -0
  16. package/dist/components/Calendar/Calendar.d.ts +19 -0
  17. package/dist/components/Card/Card.d.ts +36 -0
  18. package/dist/components/Carousel/Carousel.d.ts +21 -0
  19. package/dist/components/Checkbox/Checkbox.d.ts +10 -0
  20. package/dist/components/Chip/Chip.d.ts +25 -2
  21. package/dist/components/Combobox/Combobox.d.ts +42 -0
  22. package/dist/components/Confetti/Confetti.d.ts +31 -0
  23. package/dist/components/ContextMenu/ContextMenu.d.ts +24 -0
  24. package/dist/components/DateInput/DateInput.d.ts +37 -0
  25. package/dist/components/Dialog/Dialog.d.ts +32 -0
  26. package/dist/components/Divider/Divider.d.ts +8 -0
  27. package/dist/components/FAB/FAB.d.ts +4 -0
  28. package/dist/components/FAB/magnet.d.ts +2 -0
  29. package/dist/components/FABMenu/FABMenu.d.ts +55 -0
  30. package/dist/components/Field/Field.d.ts +20 -0
  31. package/dist/components/FloatingToolbar/FloatingToolbar.d.ts +15 -0
  32. package/dist/components/HoldButton/HoldButton.d.ts +4 -1
  33. package/dist/components/Icon/Icon.d.ts +14 -0
  34. package/dist/components/IconButton/IconButton.d.ts +11 -0
  35. package/dist/components/Input/Input.d.ts +9 -0
  36. package/dist/components/Kbd/Kbd.d.ts +21 -0
  37. package/dist/components/List/List.d.ts +10 -1
  38. package/dist/components/Menu/Menu.d.ts +32 -0
  39. package/dist/components/Menubar/Menubar.d.ts +17 -0
  40. package/dist/components/NavigationBar/NavigationBar.d.ts +10 -0
  41. package/dist/components/NavigationDrawer/NavigationDrawer.d.ts +22 -0
  42. package/dist/components/NavigationList/NavigationList.d.ts +27 -0
  43. package/dist/components/NavigationRail/NavigationRail.d.ts +25 -9
  44. package/dist/components/PinInput/PinInput.d.ts +31 -0
  45. package/dist/components/Popover/Popover.d.ts +30 -2
  46. package/dist/components/PreviewCard/PreviewCard.d.ts +31 -0
  47. package/dist/components/Progress/Progress.d.ts +8 -1
  48. package/dist/components/RadioGroup/RadioGroup.d.ts +12 -0
  49. package/dist/components/Search/Search.d.ts +39 -0
  50. package/dist/components/Select/Select.d.ts +15 -2
  51. package/dist/components/Skeleton/Skeleton.d.ts +20 -0
  52. package/dist/components/Slider/Slider.d.ts +5 -0
  53. package/dist/components/Snackbar/Snackbar.d.ts +7 -2
  54. package/dist/components/SplitButton/SplitButton.d.ts +13 -0
  55. package/dist/components/Sticker/Sticker.d.ts +21 -0
  56. package/dist/components/Switch/Switch.d.ts +11 -0
  57. package/dist/components/Table/Table.d.ts +36 -0
  58. package/dist/components/Tabs/Tabs.d.ts +17 -0
  59. package/dist/components/Textarea/Textarea.d.ts +8 -0
  60. package/dist/components/TimePicker/TimePicker.d.ts +45 -0
  61. package/dist/components/Toggle/Toggle.d.ts +41 -0
  62. package/dist/components/ToggleGroup/ToggleGroup.d.ts +14 -2
  63. package/dist/components/Tooltip/Tooltip.d.ts +10 -1
  64. package/dist/components/Typography/Typography.d.ts +13 -1
  65. package/dist/datetime.d.ts +12 -0
  66. package/dist/dev.d.ts +15 -0
  67. package/dist/index.cjs +3105 -634
  68. package/dist/index.cjs.map +1 -1
  69. package/dist/index.css +1417 -364
  70. package/dist/index.css.map +1 -1
  71. package/dist/index.d.ts +50 -4
  72. package/dist/index.js +3038 -591
  73. package/dist/index.js.map +1 -1
  74. package/dist/themes/baseTheme.d.ts +2 -0
  75. package/dist/themes/createTheme.d.ts +22 -0
  76. package/dist/themes/monochromeTheme.d.ts +2 -0
  77. package/dist/themes/types.d.ts +15 -6
  78. package/dist/tokens/baseTokens.d.ts +4 -0
  79. package/dist/tokens/types.d.ts +34 -0
  80. package/docs/accordion.md +47 -0
  81. package/docs/animated-number.md +31 -0
  82. package/docs/app-bar.md +53 -0
  83. package/docs/avatar-group.md +35 -0
  84. package/docs/avatar.md +34 -0
  85. package/docs/badge.md +41 -0
  86. package/docs/bottom-sheet.md +65 -0
  87. package/docs/button.md +63 -0
  88. package/docs/calendar.md +26 -0
  89. package/docs/card.md +71 -0
  90. package/docs/carousel.md +43 -0
  91. package/docs/checkbox.md +37 -0
  92. package/docs/chip.md +48 -0
  93. package/docs/combobox.md +72 -0
  94. package/docs/composition.md +80 -0
  95. package/docs/confetti.md +30 -0
  96. package/docs/context-menu.md +42 -0
  97. package/docs/date-input.md +41 -0
  98. package/docs/dialog.md +106 -0
  99. package/docs/divider.md +31 -0
  100. package/docs/fab-menu.md +55 -0
  101. package/docs/fab.md +43 -0
  102. package/docs/field.md +59 -0
  103. package/docs/floating-toolbar.md +48 -0
  104. package/docs/forms.md +81 -0
  105. package/docs/hold-button.md +32 -0
  106. package/docs/icon-button.md +54 -0
  107. package/docs/icons.md +38 -0
  108. package/docs/input.md +50 -0
  109. package/docs/kbd.md +25 -0
  110. package/docs/list.md +65 -0
  111. package/docs/llms-index.md +82 -0
  112. package/docs/menu.md +88 -0
  113. package/docs/menubar.md +34 -0
  114. package/docs/morph.md +51 -0
  115. package/docs/navigation-bar.md +48 -0
  116. package/docs/navigation-drawer.md +72 -0
  117. package/docs/navigation-list.md +40 -0
  118. package/docs/navigation-rail.md +53 -0
  119. package/docs/pin-input.md +38 -0
  120. package/docs/popover.md +78 -0
  121. package/docs/preview-card.md +40 -0
  122. package/docs/progress.md +37 -0
  123. package/docs/radio-group.md +47 -0
  124. package/docs/search.md +77 -0
  125. package/docs/select.md +64 -0
  126. package/docs/setup.md +106 -0
  127. package/docs/skeleton.md +33 -0
  128. package/docs/slider.md +49 -0
  129. package/docs/snackbar.md +50 -0
  130. package/docs/split-button.md +44 -0
  131. package/docs/sticker.md +27 -0
  132. package/docs/switch.md +44 -0
  133. package/docs/table.md +66 -0
  134. package/docs/tabs.md +51 -0
  135. package/docs/textarea.md +23 -0
  136. package/docs/theming.md +182 -0
  137. package/docs/time-picker.md +38 -0
  138. package/docs/toggle-group.md +70 -0
  139. package/docs/toggle.md +49 -0
  140. package/docs/tooltip.md +42 -0
  141. package/docs/typography.md +41 -0
  142. package/package.json +25 -5
@@ -8,14 +8,42 @@ export type PopoverProps = BasePopover.Root.Props & {
8
8
  */
9
9
  morph?: boolean;
10
10
  };
11
+ /**
12
+ * A floating panel anchored to its trigger, for content users interact with
13
+ * (forms, details). Holds the open state: `open` / `defaultOpen` /
14
+ * `onOpenChange`. Parts: `PopoverTrigger`, `PopoverPopup` (includes portal
15
+ * and positioner; takes `side` / `align`), `PopoverTitle`,
16
+ * `PopoverDescription`, `PopoverClose`.
17
+ *
18
+ * @example
19
+ * <Popover>
20
+ * <PopoverTrigger render={<IconButton icon="info" aria-label="Details" />} />
21
+ * <PopoverPopup side="bottom" align="start">
22
+ * <PopoverTitle>Details</PopoverTitle>
23
+ * <PopoverDescription>Last edited today.</PopoverDescription>
24
+ * </PopoverPopup>
25
+ * </Popover>
26
+ */
11
27
  export declare function Popover({ morph, defaultOpen, ...props }: PopoverProps): import("react").JSX.Element;
12
28
  export type PopoverTriggerProps = BasePopover.Trigger.Props;
29
+ /** Opens the popover. Renders a bare `<button>`; pass `render={<Button />}` to use the library's. */
13
30
  export declare function PopoverTrigger({ className, ref, ...props }: PopoverTriggerProps): import("react").JSX.Element;
14
- export type PopoverPopupProps = BasePopover.Popup.Props & Pick<BasePopover.Positioner.Props, 'side' | 'align' | 'sideOffset' | 'alignOffset'>;
15
- export declare function PopoverPopup({ side, align, sideOffset, alignOffset, className, ref, ...props }: PopoverPopupProps): import("react").JSX.Element;
31
+ /** The panel. Also renders the portal and positioner, so it takes their placement props. */
32
+ export type PopoverPopupProps = BasePopover.Popup.Props & Pick<BasePopover.Positioner.Props, 'side' | 'align' | 'sideOffset' | 'alignOffset' | 'anchor'>;
33
+ /** The panel. Takes `side`, `align`, `sideOffset`, `alignOffset` and `anchor`. */
34
+ export declare function PopoverPopup({ anchor, side, align, sideOffset, alignOffset, className, ref, ...props }: PopoverPopupProps): import("react").JSX.Element;
16
35
  export type PopoverTitleProps = BasePopover.Title.Props;
36
+ /**
37
+ * Names the popup for screen readers. Renders an `<h2>`; pass
38
+ * `render={<h3 />}` (or another level) to fit the page's headings.
39
+ */
17
40
  export declare function PopoverTitle({ className, ...props }: PopoverTitleProps): import("react").JSX.Element;
18
41
  export type PopoverDescriptionProps = BasePopover.Description.Props;
42
+ /** Supporting text in the popover. */
19
43
  export declare function PopoverDescription({ className, ...props }: PopoverDescriptionProps): import("react").JSX.Element;
20
44
  export type PopoverCloseProps = BasePopover.Close.Props;
45
+ /**
46
+ * Closes the popover. Renders a bare `<button>`; pass `render={<Button />}`
47
+ * or `render={<IconButton ... />}` to use the library's.
48
+ */
21
49
  export declare function PopoverClose({ className, ...props }: PopoverCloseProps): import("react").JSX.Element;
@@ -0,0 +1,31 @@
1
+ import { PreviewCard as BasePreviewCard } from '@base-ui/react/preview-card';
2
+ import '../Menu/menu.css';
3
+ import '../Popover/popover.css';
4
+ import './preview-card.css';
5
+ /**
6
+ * A card that appears while hovering or focusing a link, showing a preview of
7
+ * where it goes. Put a `PreviewCardTrigger` and a `PreviewCardPopup` inside.
8
+ * Hover-only, so the popup must not hold anything a user needs to reach;
9
+ * use `Popover` for that.
10
+ */
11
+ export type PreviewCardProps = BasePreviewCard.Root.Props;
12
+ /**
13
+ * A card shown while hovering or focusing a link. Use `Popover` if the
14
+ * content has anything to click.
15
+ *
16
+ * @example
17
+ * <PreviewCard>
18
+ * <PreviewCardTrigger href="/users/ada">@ada</PreviewCardTrigger>
19
+ * <PreviewCardPopup>Ada Lovelace, 12 posts</PreviewCardPopup>
20
+ * </PreviewCard>
21
+ */
22
+ export declare function PreviewCard(props: PreviewCardProps): import("react").JSX.Element;
23
+ export type PreviewCardTriggerProps = BasePreviewCard.Trigger.Props;
24
+ /**
25
+ * The link. Renders an `<a>`, so give it `href`; pass `render={<Link />}`
26
+ * for a router link. `delay` / `closeDelay` set the hover timing.
27
+ */
28
+ export declare function PreviewCardTrigger({ className, ...props }: PreviewCardTriggerProps): import("react").JSX.Element;
29
+ export type PreviewCardPopupProps = BasePreviewCard.Popup.Props & Pick<BasePreviewCard.Positioner.Props, 'side' | 'align' | 'sideOffset' | 'alignOffset'>;
30
+ /** The card. Also renders the portal and positioner; takes `side` / `align`. */
31
+ export declare function PreviewCardPopup({ side, align, sideOffset, alignOffset, className, ...props }: PreviewCardPopupProps): import("react").JSX.Element;
@@ -18,5 +18,12 @@ export type ProgressProps = BaseProgress.Root.Props & {
18
18
  /** Accessible name, when there's no visible `label`. */
19
19
  'aria-label': string;
20
20
  });
21
- /** Pass `value={null}` while the amount of work is unknown. */
21
+ /**
22
+ * Shows how far along a task is: `value` from 0 to 100 (or `min`/`max`).
23
+ * Pass `value={null}` while the amount of work is unknown.
24
+ *
25
+ * @example
26
+ * <Progress label="Uploading" value={progress} />
27
+ * <Progress type="circular" aria-label="Loading" value={null} />
28
+ */
22
29
  export declare function Progress({ type, squiggly, label, className, style, children, ...props }: ProgressProps): import("react").JSX.Element;
@@ -2,6 +2,18 @@ import { Radio as BaseRadio } from '@base-ui/react/radio';
2
2
  import { RadioGroup as BaseRadioGroup } from '@base-ui/react/radio-group';
3
3
  import './radio-group.css';
4
4
  export type RadioGroupProps<Value = any> = BaseRadioGroup.Props<Value>;
5
+ /**
6
+ * A group of `Radio`s where exactly one is picked. State: `value` /
7
+ * `defaultValue` / `onValueChange` on the group; each `Radio` has a `value`.
8
+ * Give the group an `aria-label` or `aria-labelledby`.
9
+ *
10
+ * @example
11
+ * <RadioGroup aria-label="Plan" defaultValue="free">
12
+ * <label><Radio value="free" /> Free</label>
13
+ * <label><Radio value="pro" /> Pro</label>
14
+ * </RadioGroup>
15
+ */
5
16
  export declare function RadioGroup<Value>({ className, ...props }: RadioGroupProps<Value>): import("react").JSX.Element;
6
17
  export type RadioProps<Value = any> = BaseRadio.Root.Props<Value>;
18
+ /** One option in a `RadioGroup`. Needs a `value`. Wrap it in a `<label>` with its text. */
7
19
  export declare function Radio<Value>({ className, ...props }: RadioProps<Value>): import("react").JSX.Element;
@@ -0,0 +1,39 @@
1
+ import { type ReactNode } from 'react';
2
+ import { Autocomplete as BaseAutocomplete } from '@base-ui/react/autocomplete';
3
+ import type { MaterialSymbol } from 'material-symbols';
4
+ import '../Menu/menu.css';
5
+ import './search.css';
6
+ export type SearchProps<Item> = Omit<BaseAutocomplete.Root.Props<Item>, 'children' | 'items'> & {
7
+ /** The suggestions. Filtered against what's typed. */
8
+ items?: readonly Item[];
9
+ /** Renders each suggestion, e.g. `(item) => <SearchItem key={item} value={item}>{item}</SearchItem>`. */
10
+ children: (item: Item, index: number) => ReactNode;
11
+ /** Hint text inside the bar, e.g. "Search mail". */
12
+ placeholder?: string;
13
+ /** There's no visible label, so the input needs a name for screen readers. */
14
+ 'aria-label': string;
15
+ /** Shown in the popup when nothing matches. Without it, the popup hides. */
16
+ empty?: ReactNode;
17
+ /** Accessible name of the clear button. @default 'Clear' */
18
+ clearLabel?: string;
19
+ /** Applied to the bar, so width and margins work as expected. */
20
+ className?: string;
21
+ };
22
+ /**
23
+ * Material 3 search bar with a list of suggestions under it. Pass `items`
24
+ * and it filters them as you type. The typed text is `value` /
25
+ * `defaultValue` / `onValueChange`. Children must be a function that renders
26
+ * one suggestion.
27
+ *
28
+ * @example
29
+ * <Search aria-label="Search mail" placeholder="Search mail" items={recent} value={query} onValueChange={setQuery}>
30
+ * {(item: string) => <SearchItem key={item} value={item} startIcon="history">{item}</SearchItem>}
31
+ * </Search>
32
+ */
33
+ export declare function Search<Item>({ children, placeholder, 'aria-label': ariaLabel, empty, clearLabel, className, ...props }: SearchProps<Item>): import("react").JSX.Element;
34
+ export type SearchItemProps = BaseAutocomplete.Item.Props & {
35
+ /** Material Symbol before the text, e.g. `history` for a recent search. */
36
+ startIcon?: MaterialSymbol;
37
+ };
38
+ /** One suggestion in a `Search`. Needs a `value`. Picking it fills the bar with its text. */
39
+ export declare function SearchItem({ startIcon, className, children, ...props }: SearchItemProps): import("react").JSX.Element;
@@ -17,9 +17,22 @@ export type SelectProps<Value, Multiple extends boolean | undefined = false> = B
17
17
  className?: string;
18
18
  };
19
19
  /**
20
- * Put `SelectItem`s inside. Pass `items` (value → label) so the field shows
21
- * the selected item's label rather than its raw value.
20
+ * A dropdown to pick one option (or several, with `multiple`). Put
21
+ * `SelectItem`s inside. Pass `items` (value → label) so the field shows the
22
+ * selected item's label rather than its raw value. `onValueChange` gets the
23
+ * value, not an event. Other props go to Base UI's `Select.Root`, which
24
+ * renders no element: use `className` for styling the field.
25
+ *
26
+ * @example
27
+ * const fruits = { apple: 'Apple', banana: 'Banana' }
28
+ *
29
+ * <Select label="Fruit" items={fruits} value={fruit} onValueChange={setFruit}>
30
+ * {Object.entries(fruits).map(([value, label]) => (
31
+ * <SelectItem key={value} value={value}>{label}</SelectItem>
32
+ * ))}
33
+ * </Select>
22
34
  */
23
35
  export declare function Select<Value, Multiple extends boolean | undefined = false>({ label, placeholder, size, className, children, ...props }: SelectProps<Value, Multiple>): import("react").JSX.Element;
24
36
  export type SelectItemProps = BaseSelect.Item.Props;
37
+ /** One option in a `Select`. Needs a `value`; children are its label. */
25
38
  export declare function SelectItem({ className, children, ...props }: SelectItemProps): import("react").JSX.Element;
@@ -0,0 +1,20 @@
1
+ import './skeleton.css';
2
+ export type SkeletonProps = React.ComponentProps<'span'> & {
3
+ /**
4
+ * Shape of the placeholder: a line of text, a circle (avatars, icons) or
5
+ * a rounded box (images, cards). Set the size with `style`.
6
+ * @default 'text'
7
+ */
8
+ variant?: 'text' | 'circular' | 'rectangular';
9
+ /** Fades in and out while loading. @default 'pulse' */
10
+ animation?: 'pulse' | 'none';
11
+ };
12
+ /**
13
+ * A placeholder shown while content loads. It's hidden from screen readers:
14
+ * put `aria-busy` on the region that's loading.
15
+ *
16
+ * @example
17
+ * <Skeleton variant="circular" style={{ width: 40, height: 40 }} />
18
+ * <Skeleton style={{ width: '60%' }} />
19
+ */
20
+ export declare function Skeleton({ variant, animation, className, ...props }: SkeletonProps): import("react").JSX.Element;
@@ -22,5 +22,10 @@ export type SliderProps<Value extends number | readonly number[] = number | read
22
22
  /**
23
23
  * Pass an array as `value` / `defaultValue` for a range with several handles.
24
24
  * `orientation="vertical"` is 160px tall by default; set a height via `className`.
25
+ * `onValueChange` gets a number (or an array for a range), not an event.
26
+ *
27
+ * @example
28
+ * <Slider label="Volume" defaultValue={50} />
29
+ * <Slider aria-label="Price" value={range} onValueChange={setRange} min={0} max={500} />
25
30
  */
26
31
  export declare function Slider<Value extends number | readonly number[]>({ label, 'aria-label': ariaLabel, showValue, squiggly, className, ...props }: SliderProps<Value>): import("react").JSX.Element;
@@ -18,8 +18,13 @@ export type SnackbarOptions = {
18
18
  onClose?: () => void;
19
19
  };
20
20
  /**
21
- * Shows snackbars: `const snackbar = useSnackbar()`, then
22
- * `snackbar.show({ message: 'Saved' })`. Works anywhere inside `AnvilRoot`.
21
+ * Shows snackbars (toasts). There is no Snackbar or Toast component to
22
+ * render: AnvilRoot already renders the viewport. Works anywhere inside
23
+ * `AnvilRoot`.
24
+ *
25
+ * @example
26
+ * const snackbar = useSnackbar()
27
+ * snackbar.show({ message: 'Deleted', action: { label: 'Undo', onClick: undo } })
23
28
  */
24
29
  export declare function useSnackbar(): {
25
30
  /** Shows a snackbar at the bottom; open ones move up. Returns its id. */
@@ -1,3 +1,16 @@
1
1
  import './split-button.css';
2
2
  export type SplitButtonProps = React.ComponentProps<'div'>;
3
+ /**
4
+ * Joins `Button`s (and `IconButton`s) into one segmented group with shared
5
+ * rounded ends. Style each button yourself; the group only lays them out.
6
+ *
7
+ * @example
8
+ * <SplitButton>
9
+ * <Button>Save</Button>
10
+ * <Menu>
11
+ * <MenuTrigger render={<IconButton icon="arrow_drop_down" aria-label="More save options" />} />
12
+ * <MenuPopup>...</MenuPopup>
13
+ * </Menu>
14
+ * </SplitButton>
15
+ */
3
16
  export declare function SplitButton({ className, ...props }: SplitButtonProps): import("react").JSX.Element;
@@ -0,0 +1,21 @@
1
+ import type { ComponentProps } from 'react';
2
+ import type { MaterialSymbol } from 'material-symbols';
3
+ import { type ComponentColor } from '../../colors/colors';
4
+ import './sticker.css';
5
+ export type StickerProps = ComponentProps<'span'> & {
6
+ /** Color role from the theme. @default 'primary' */
7
+ color?: ComponentColor;
8
+ /** Material Symbol before the text. */
9
+ startIcon?: MaterialSymbol;
10
+ /** How far it's tilted, in degrees. Negative leans left. @default -4 */
11
+ tilt?: number;
12
+ };
13
+ /**
14
+ * A small tilted label that looks like a die-cut sticker ("NEW", "BETA",
15
+ * "50% off"). Straightens up on hover. Purely visual: its text is read
16
+ * like any other text.
17
+ *
18
+ * @example
19
+ * <Sticker color="warning" startIcon="bolt">NEW</Sticker>
20
+ */
21
+ export declare function Sticker({ color, startIcon, tilt, className, style, children, ...props }: StickerProps): import("react").JSX.Element;
@@ -1,4 +1,15 @@
1
1
  import { Switch as BaseSwitch } from '@base-ui/react/switch';
2
2
  import './switch.css';
3
3
  export type SwitchProps = BaseSwitch.Root.Props;
4
+ /**
5
+ * An on/off switch. State: `checked` / `defaultChecked` / `onCheckedChange`.
6
+ * It has no `label` prop: wrap it in a `<label>`, or put it in a `ListItem`'s
7
+ * `end` with `render={<label />}`.
8
+ *
9
+ * @example
10
+ * <label style={{ display: 'flex', gap: 8, alignItems: 'center' }}>
11
+ * <Switch checked={wifi} onCheckedChange={setWifi} />
12
+ * Wi-Fi
13
+ * </label>
14
+ */
4
15
  export declare function Switch({ className, ...props }: SwitchProps): import("react").JSX.Element;
@@ -0,0 +1,36 @@
1
+ import './table.css';
2
+ export type TableProps = React.ComponentProps<'table'>;
3
+ /**
4
+ * A styled HTML table. Each part renders its native element (`TableHead` is
5
+ * `<thead>`, `TableHeaderCell` is `<th>`), so it has no sorting or paging.
6
+ *
7
+ * @example
8
+ * <Table>
9
+ * <TableCaption>Invoices</TableCaption>
10
+ * <TableHead>
11
+ * <TableRow><TableHeaderCell>Number</TableHeaderCell><TableHeaderCell>Total</TableHeaderCell></TableRow>
12
+ * </TableHead>
13
+ * <TableBody>
14
+ * <TableRow><TableCell>#1001</TableCell><TableCell>$40</TableCell></TableRow>
15
+ * </TableBody>
16
+ * </Table>
17
+ */
18
+ export declare function Table({ className, ...props }: TableProps): import("react").JSX.Element;
19
+ export type TableCaptionProps = React.ComponentProps<'caption'>;
20
+ /** The table's accessible name. Without one, give `Table` an `aria-label`. */
21
+ export declare function TableCaption({ className, ...props }: TableCaptionProps): import("react").JSX.Element;
22
+ export type TableHeadProps = React.ComponentProps<'thead'>;
23
+ /** `<thead>`: the header rows. */
24
+ export declare function TableHead({ className, ...props }: TableHeadProps): import("react").JSX.Element;
25
+ export type TableBodyProps = React.ComponentProps<'tbody'>;
26
+ /** `<tbody>`: the data rows. */
27
+ export declare function TableBody({ className, ...props }: TableBodyProps): import("react").JSX.Element;
28
+ export type TableRowProps = React.ComponentProps<'tr'>;
29
+ /** `<tr>`. */
30
+ export declare function TableRow({ className, ...props }: TableRowProps): import("react").JSX.Element;
31
+ export type TableHeaderCellProps = React.ComponentProps<'th'>;
32
+ /** `<th>`, with `scope="col"` by default; pass `scope="row"` for a header at the start of a row. */
33
+ export declare function TableHeaderCell({ scope, className, ...props }: TableHeaderCellProps): import("react").JSX.Element;
34
+ export type TableCellProps = React.ComponentProps<'td'>;
35
+ /** `<td>`. */
36
+ export declare function TableCell({ className, ...props }: TableCellProps): import("react").JSX.Element;
@@ -3,13 +3,30 @@ import type { MaterialSymbol } from 'material-symbols';
3
3
  import './tabs.css';
4
4
  /** Holds the selected tab: `value` / `defaultValue` / `onValueChange`. Horizontal only. */
5
5
  export type TabsProps = Omit<BaseTabs.Root.Props, 'orientation'>;
6
+ /**
7
+ * Tabs. Put a `TabsList` of `TabsTab`s, then one `TabsPanel` per tab with
8
+ * the same `value`. There is no TabsTrigger or TabsContent.
9
+ *
10
+ * @example
11
+ * <Tabs defaultValue="account">
12
+ * <TabsList>
13
+ * <TabsTab value="account">Account</TabsTab>
14
+ * <TabsTab value="billing">Billing</TabsTab>
15
+ * </TabsList>
16
+ * <TabsPanel value="account">...</TabsPanel>
17
+ * <TabsPanel value="billing">...</TabsPanel>
18
+ * </Tabs>
19
+ */
6
20
  export declare function Tabs({ className, ...props }: TabsProps): import("react").JSX.Element;
7
21
  export type TabsListProps = BaseTabs.List.Props;
22
+ /** The row of tabs. Draws the sliding underline under the selected one. */
8
23
  export declare function TabsList({ className, children, ...props }: TabsListProps): import("react").JSX.Element;
9
24
  export type TabsTabProps = BaseTabs.Tab.Props & {
10
25
  /** Material Symbol shown above the label. */
11
26
  icon?: MaterialSymbol;
12
27
  };
28
+ /** One tab button. Give it a `value` matching its `TabsPanel`. */
13
29
  export declare function TabsTab({ icon, className, children, ...props }: TabsTabProps): import("react").JSX.Element;
14
30
  export type TabsPanelProps = BaseTabs.Panel.Props;
31
+ /** Content for one tab: give it the same `value` as its `TabsTab`. */
15
32
  export declare function TabsPanel({ className, ...props }: TabsPanelProps): import("react").JSX.Element;
@@ -13,4 +13,12 @@ export type TextareaProps = Omit<ComponentProps<'textarea'>, 'className'> & Pick
13
13
  /** Applied to the outer wrapper, so width and margins work as expected. */
14
14
  className?: string;
15
15
  };
16
+ /**
17
+ * A multi-line text field with a floating label. Same API as `Input`:
18
+ * `onChange` (event) or `onValueChange` (string); `className` goes on the
19
+ * wrapper, other props on the `<textarea>`.
20
+ *
21
+ * @example
22
+ * <Textarea label="Bio" rows={4} defaultValue="" />
23
+ */
16
24
  export declare function Textarea({ label, size, className, placeholder, ...props }: TextareaProps): import("react").JSX.Element;
@@ -0,0 +1,45 @@
1
+ import { type ReactNode } from 'react';
2
+ import { type PopoverProps } from '../Popover/Popover';
3
+ import '../Input/input.css';
4
+ import '../Select/select.css';
5
+ import './time-picker.css';
6
+ export type TimePickerProps = Omit<React.ComponentProps<'div'>, 'children' | 'defaultValue'> & Pick<PopoverProps, 'open' | 'defaultOpen' | 'onOpenChange'> & {
7
+ /**
8
+ * `dial`: tap or drag a clock face, hour then minute.
9
+ * `input`: type into the hour and minute boxes. @default 'dial'
10
+ */
11
+ type?: 'dial' | 'input';
12
+ /** The time as 24-hour `"HH:mm"` (like `<input type="time">`), or `null` for none. */
13
+ value?: string | null;
14
+ /** Starting time when `value` isn't controlled. @default null */
15
+ defaultValue?: string | null;
16
+ /** Called with the new `"HH:mm"` on every change. */
17
+ onValueChange?: (value: string) => void;
18
+ /** 12 shows AM/PM. @default the user's locale */
19
+ hourCycle?: 12 | 24;
20
+ /** @default false */
21
+ disabled?: boolean;
22
+ /**
23
+ * `small` is shorter, and its label works like a placeholder: it hides
24
+ * once a time is picked. @default 'normal'
25
+ */
26
+ size?: 'small' | 'normal';
27
+ /** Submits the value with a form, as `"HH:mm"`. */
28
+ name?: string;
29
+ } & ({
30
+ /** Floating label, like Input's. */
31
+ label: ReactNode;
32
+ 'aria-label'?: never;
33
+ } | {
34
+ label?: undefined;
35
+ /** Without a visible `label`, the field needs a name for screen readers. */
36
+ 'aria-label': string;
37
+ });
38
+ /**
39
+ * A field that opens a Material 3 time picker. The value is a 24-hour
40
+ * `"HH:mm"` string, the same format as `<input type="time">`.
41
+ *
42
+ * @example
43
+ * <TimePicker label="Alarm" defaultValue="07:30" onValueChange={setTime} />
44
+ */
45
+ export declare function TimePicker({ type, value: valueProp, defaultValue, onValueChange, hourCycle, label, 'aria-label': ariaLabel, disabled, size, name, open, defaultOpen, onOpenChange, className, ...props }: TimePickerProps): import("react").JSX.Element;
@@ -0,0 +1,41 @@
1
+ import type { ReactNode } from 'react';
2
+ import { Toggle as BaseToggle } from '@base-ui/react/toggle';
3
+ import type { MaterialSymbol } from 'material-symbols';
4
+ import { type ColorProps } from '../../colors/colors';
5
+ import '../Button/button.css';
6
+ import '../IconButton/icon-button.css';
7
+ import './toggle.css';
8
+ export type ToggleProps = Omit<BaseToggle.Props, 'children'> & ColorProps & {
9
+ /**
10
+ * Off, it's neutral in this fill type; on, it fills with `color`.
11
+ * @default 'filled'
12
+ */
13
+ fillType?: ColorProps['fillType'];
14
+ } & ({
15
+ /** The visible label. */
16
+ children: ReactNode;
17
+ /** Material Symbol before the label. */
18
+ startIcon?: MaterialSymbol;
19
+ /** Material Symbol after the label. */
20
+ endIcon?: MaterialSymbol;
21
+ /** Same heights as `Button`. @default 'normal' */
22
+ size?: 'small' | 'normal' | 'big';
23
+ icon?: never;
24
+ } | {
25
+ /** Material Symbol to show: makes it an icon toggle. Filled while on. */
26
+ icon: MaterialSymbol;
27
+ 'aria-label': string;
28
+ children?: never;
29
+ startIcon?: never;
30
+ endIcon?: never;
31
+ size?: never;
32
+ });
33
+ /**
34
+ * A button that stays on or off, like Bold or Favorite. Holds its state
35
+ * (`pressed` / `defaultPressed` / `onPressedChange`) and sets aria-pressed.
36
+ *
37
+ * @example
38
+ * <Toggle startIcon="format_bold" defaultPressed>Bold</Toggle>
39
+ * <Toggle icon="favorite" aria-label="Favorite" pressed={fav} onPressedChange={setFav} />
40
+ */
41
+ export declare function Toggle({ icon, startIcon, endIcon, size, color, fillType, children, className, ...props }: ToggleProps): import("react").JSX.Element;
@@ -5,16 +5,22 @@ import type { MaterialSymbol } from 'material-symbols';
5
5
  import { ColorProps } from '../../colors/colors';
6
6
  import './toggle-group.css';
7
7
  type ToggleGroupCommonProps = ColorProps & {
8
- /** @default 'normal' */
8
+ /** Same heights as `Button`. @default 'normal' */
9
9
  size?: 'small' | 'normal' | 'big';
10
10
  };
11
11
  export type ToggleGroupProps<Value = any> = ToggleGroupCommonProps & ((BaseRadioGroup.Props<Value> & {
12
12
  /**
13
13
  * Let several segments be on at once. `value` is then an array
14
- * of strings. @default false
14
+ * of strings. Without it, `value` is a single value, not an
15
+ * array. @default false
15
16
  */
16
17
  multiple?: false;
17
18
  }) | (BaseToggleGroup.Props<string> & {
19
+ /**
20
+ * Let several segments be on at once. `value` is then an array
21
+ * of strings. Without it, `value` is a single value, not an
22
+ * array. @default false
23
+ */
18
24
  multiple: true;
19
25
  }));
20
26
  /**
@@ -22,6 +28,12 @@ export type ToggleGroupProps<Value = any> = ToggleGroupCommonProps & ((BaseRadio
22
28
  * with a pill that stretches over to it. With `multiple`, each one toggles on
23
29
  * and off. Use it for 2-5 short options; for longer lists or forms, use
24
30
  * `RadioGroup` or checkboxes.
31
+ *
32
+ * @example
33
+ * <ToggleGroup aria-label="View" value={view} onValueChange={setView}>
34
+ * <ToggleGroupItem value="list" startIcon="list">List</ToggleGroupItem>
35
+ * <ToggleGroupItem value="grid" startIcon="grid_view">Grid</ToggleGroupItem>
36
+ * </ToggleGroup>
25
37
  */
26
38
  export declare function ToggleGroup<Value>({ size, color, fillType, multiple, children, className, ref, ...props }: ToggleGroupProps<Value>): import("react").JSX.Element;
27
39
  export type ToggleGroupItemProps<Value = any> = BaseRadio.Root.Props<Value> & {
@@ -10,5 +10,14 @@ export type TooltipProps = Omit<BaseTooltip.Root.Props, 'children'> & Pick<BaseT
10
10
  */
11
11
  children: ReactElement;
12
12
  };
13
- /** A short hint shown on hover or keyboard focus. `className` goes on the bubble. */
13
+ /**
14
+ * A short hint shown on hover or keyboard focus. One component, no parts:
15
+ * the text is `label`, and the single child element is the trigger.
16
+ * `className` goes on the bubble.
17
+ *
18
+ * @example
19
+ * <Tooltip label="Delete">
20
+ * <IconButton icon="delete" aria-label="Delete" />
21
+ * </Tooltip>
22
+ */
14
23
  export declare function Tooltip({ label, children, delay, closeDelay, side, align, sideOffset, alignOffset, className, ...props }: TooltipProps): import("react").JSX.Element;
@@ -2,9 +2,21 @@ import './typography.css';
2
2
  export type TypographyType = 'body' | 'caption' | 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
3
3
  export type TypographyTag = 'p' | 'span' | 'div' | 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
4
4
  export type TypographyProps = React.ComponentProps<'p'> & {
5
- /** The look. */
5
+ /**
6
+ * The look (what other libraries call `variant`). Also picks the tag:
7
+ * `h1`–`h6` render that heading, `body` a `<p>`, `caption` a `<span>`.
8
+ * @default 'body'
9
+ */
6
10
  type?: TypographyType;
7
11
  /** The HTML tag, when it should differ from the look (e.g. an h2 styled as h6). */
8
12
  as?: TypographyTag;
9
13
  };
14
+ /**
15
+ * Text in the theme's type scale.
16
+ *
17
+ * @example
18
+ * <Typography type="h1">Settings</Typography>
19
+ * <Typography type="h6" as="h2">Notifications</Typography>
20
+ * <Typography type="caption">Updated 2 min ago</Typography>
21
+ */
10
22
  export declare function Typography({ type, as, className, ...props }: TypographyProps): import("react").JSX.Element;
@@ -0,0 +1,12 @@
1
+ export declare const toIso: (d: Date) => string;
2
+ export declare function makeDate(y: number, m: number, d: number): Date | null;
3
+ export declare function fromIso(value: string | null | undefined): Date | null;
4
+ export type DateField = 'year' | 'month' | 'day';
5
+ export declare const fieldOrder: (fmt: Intl.DateTimeFormat) => DateField[];
6
+ export declare function placeholderFor(fmt: Intl.DateTimeFormat): string;
7
+ export declare function parseTyped(text: string, order: DateField[]): Date | null;
8
+ export type Time = {
9
+ h: number;
10
+ m: number;
11
+ };
12
+ export declare function parseTime(value: string | null | undefined): Time | null;
package/dist/dev.d.ts ADDED
@@ -0,0 +1,15 @@
1
+ /** Logs once per distinct message, so a list of 100 items logs one error. */
2
+ export declare function devError(message: string, fix: string, doc: string): void;
3
+ /** Base UI's `render` prop replaces Radix-style `asChild`. */
4
+ export declare function checkAsChild(props: object, component: string, doc: string, fix?: string): void;
5
+ /** A prop name borrowed from another library (`variant`, `label`, ...). */
6
+ export declare function checkProp(props: object, prop: string, component: string, instead: string, fix: string, doc: string): void;
7
+ export declare const POPUP_OUTSIDE_ROOT = "Its popup portals to <body>, outside the theme, so it shows unstyled.";
8
+ export declare const OUTSIDE_ROOT = "The theme variables only exist inside AnvilRoot, so it shows without colors, spacing or fonts.";
9
+ /** Components need AnvilRoot for the theme and as the portal target. */
10
+ export declare function checkRoot(found: boolean, component: string, reason?: string): void;
11
+ /** For controls with no visible text: their name must come from aria-label. */
12
+ export declare function checkName(props: {
13
+ 'aria-label'?: unknown;
14
+ 'aria-labelledby'?: unknown;
15
+ }, component: string, example: string, doc: string): void;