anvilui 0.0.0-stage → 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 (148) hide show
  1. package/AGENTS.md +483 -0
  2. package/LICENSE +21 -0
  3. package/README.md +128 -2
  4. package/bin/anvilui.mjs +83 -0
  5. package/dist/colors/colors.d.ts +24 -0
  6. package/dist/components/Accordion/Accordion.d.ts +36 -0
  7. package/dist/components/AnimatedNumber/AnimatedNumber.d.ts +17 -0
  8. package/dist/components/AnvilRoot/AnvilContext.d.ts +34 -0
  9. package/dist/components/AnvilRoot/AnvilRoot.d.ts +56 -0
  10. package/dist/components/AppBar/AppBar.d.ts +45 -0
  11. package/dist/components/Avatar/Avatar.d.ts +27 -0
  12. package/dist/components/Avatar/AvatarGroupContext.d.ts +1 -0
  13. package/dist/components/AvatarGroup/AvatarGroup.d.ts +25 -0
  14. package/dist/components/Badge/Badge.d.ts +23 -0
  15. package/dist/components/BottomSheet/BottomSheet.d.ts +41 -0
  16. package/dist/components/Button/Button.d.ts +35 -0
  17. package/dist/components/Calendar/Calendar.d.ts +19 -0
  18. package/dist/components/Card/Card.d.ts +57 -0
  19. package/dist/components/Carousel/Carousel.d.ts +21 -0
  20. package/dist/components/Checkbox/Checkbox.d.ts +14 -0
  21. package/dist/components/Chip/Chip.d.ts +46 -0
  22. package/dist/components/Combobox/Combobox.d.ts +42 -0
  23. package/dist/components/Confetti/Confetti.d.ts +31 -0
  24. package/dist/components/ContextMenu/ContextMenu.d.ts +24 -0
  25. package/dist/components/DateInput/DateInput.d.ts +37 -0
  26. package/dist/components/Dialog/Dialog.d.ts +56 -0
  27. package/dist/components/Divider/Divider.d.ts +24 -0
  28. package/dist/components/FAB/FAB.d.ts +28 -0
  29. package/dist/components/FAB/magnet.d.ts +2 -0
  30. package/dist/components/FABMenu/FABMenu.d.ts +55 -0
  31. package/dist/components/Field/Field.d.ts +36 -0
  32. package/dist/components/FloatingToolbar/FloatingToolbar.d.ts +37 -0
  33. package/dist/components/HoldButton/HoldButton.d.ts +18 -0
  34. package/dist/components/Icon/Icon.d.ts +21 -0
  35. package/dist/components/IconButton/IconButton.d.ts +22 -0
  36. package/dist/components/Input/Input.d.ts +24 -0
  37. package/dist/components/Kbd/Kbd.d.ts +21 -0
  38. package/dist/components/List/List.d.ts +35 -0
  39. package/dist/components/Menu/Menu.d.ts +54 -0
  40. package/dist/components/Menubar/Menubar.d.ts +17 -0
  41. package/dist/components/NavigationBar/NavigationBar.d.ts +30 -0
  42. package/dist/components/NavigationDrawer/NavigationDrawer.d.ts +52 -0
  43. package/dist/components/NavigationList/NavigationList.d.ts +27 -0
  44. package/dist/components/NavigationRail/NavigationRail.d.ts +48 -0
  45. package/dist/components/PinInput/PinInput.d.ts +31 -0
  46. package/dist/components/Popover/Popover.d.ts +49 -0
  47. package/dist/components/PreviewCard/PreviewCard.d.ts +31 -0
  48. package/dist/components/Progress/Progress.d.ts +29 -0
  49. package/dist/components/RadioGroup/RadioGroup.d.ts +19 -0
  50. package/dist/components/Search/Search.d.ts +39 -0
  51. package/dist/components/Select/Select.d.ts +38 -0
  52. package/dist/components/Skeleton/Skeleton.d.ts +20 -0
  53. package/dist/components/Slider/Slider.d.ts +31 -0
  54. package/dist/components/Snackbar/Snackbar.d.ts +35 -0
  55. package/dist/components/SplitButton/SplitButton.d.ts +16 -0
  56. package/dist/components/SquigglyWave/SquigglyWave.d.ts +36 -0
  57. package/dist/components/Sticker/Sticker.d.ts +21 -0
  58. package/dist/components/Switch/Switch.d.ts +15 -0
  59. package/dist/components/Table/Table.d.ts +36 -0
  60. package/dist/components/Tabs/Tabs.d.ts +32 -0
  61. package/dist/components/Textarea/Textarea.d.ts +24 -0
  62. package/dist/components/TimePicker/TimePicker.d.ts +45 -0
  63. package/dist/components/Toggle/Toggle.d.ts +41 -0
  64. package/dist/components/ToggleGroup/ToggleGroup.d.ts +50 -0
  65. package/dist/components/Tooltip/Tooltip.d.ts +23 -0
  66. package/dist/components/Typography/Typography.d.ts +22 -0
  67. package/dist/datetime.d.ts +12 -0
  68. package/dist/dev.d.ts +15 -0
  69. package/dist/index.cjs +5419 -0
  70. package/dist/index.cjs.map +1 -0
  71. package/dist/index.css +3724 -0
  72. package/dist/index.css.map +1 -0
  73. package/dist/index.d.ts +129 -0
  74. package/dist/index.js +5299 -0
  75. package/dist/index.js.map +1 -0
  76. package/dist/morph.d.ts +64 -0
  77. package/dist/themes/baseTheme.d.ts +5 -0
  78. package/dist/themes/createTheme.d.ts +22 -0
  79. package/dist/themes/monochromeTheme.d.ts +5 -0
  80. package/dist/themes/toCssVariables.d.ts +2 -0
  81. package/dist/themes/types.d.ts +60 -0
  82. package/dist/tokens/baseTokens.d.ts +6 -0
  83. package/dist/tokens/toCssVariables.d.ts +2 -0
  84. package/dist/tokens/types.d.ts +80 -0
  85. package/dist/utils.d.ts +4 -0
  86. package/docs/accordion.md +47 -0
  87. package/docs/animated-number.md +31 -0
  88. package/docs/app-bar.md +53 -0
  89. package/docs/avatar-group.md +35 -0
  90. package/docs/avatar.md +34 -0
  91. package/docs/badge.md +41 -0
  92. package/docs/bottom-sheet.md +65 -0
  93. package/docs/button.md +63 -0
  94. package/docs/calendar.md +26 -0
  95. package/docs/card.md +71 -0
  96. package/docs/carousel.md +43 -0
  97. package/docs/checkbox.md +37 -0
  98. package/docs/chip.md +48 -0
  99. package/docs/combobox.md +72 -0
  100. package/docs/composition.md +80 -0
  101. package/docs/confetti.md +30 -0
  102. package/docs/context-menu.md +42 -0
  103. package/docs/date-input.md +41 -0
  104. package/docs/dialog.md +106 -0
  105. package/docs/divider.md +31 -0
  106. package/docs/fab-menu.md +55 -0
  107. package/docs/fab.md +43 -0
  108. package/docs/field.md +59 -0
  109. package/docs/floating-toolbar.md +48 -0
  110. package/docs/forms.md +81 -0
  111. package/docs/hold-button.md +32 -0
  112. package/docs/icon-button.md +54 -0
  113. package/docs/icons.md +38 -0
  114. package/docs/input.md +50 -0
  115. package/docs/kbd.md +25 -0
  116. package/docs/list.md +65 -0
  117. package/docs/llms-index.md +82 -0
  118. package/docs/menu.md +88 -0
  119. package/docs/menubar.md +34 -0
  120. package/docs/morph.md +51 -0
  121. package/docs/navigation-bar.md +48 -0
  122. package/docs/navigation-drawer.md +72 -0
  123. package/docs/navigation-list.md +40 -0
  124. package/docs/navigation-rail.md +53 -0
  125. package/docs/pin-input.md +38 -0
  126. package/docs/popover.md +78 -0
  127. package/docs/preview-card.md +40 -0
  128. package/docs/progress.md +37 -0
  129. package/docs/radio-group.md +47 -0
  130. package/docs/search.md +77 -0
  131. package/docs/select.md +64 -0
  132. package/docs/setup.md +106 -0
  133. package/docs/skeleton.md +33 -0
  134. package/docs/slider.md +49 -0
  135. package/docs/snackbar.md +50 -0
  136. package/docs/split-button.md +44 -0
  137. package/docs/sticker.md +27 -0
  138. package/docs/switch.md +44 -0
  139. package/docs/table.md +66 -0
  140. package/docs/tabs.md +51 -0
  141. package/docs/textarea.md +23 -0
  142. package/docs/theming.md +182 -0
  143. package/docs/time-picker.md +38 -0
  144. package/docs/toggle-group.md +70 -0
  145. package/docs/toggle.md +49 -0
  146. package/docs/tooltip.md +42 -0
  147. package/docs/typography.md +41 -0
  148. package/package.json +65 -5
@@ -0,0 +1,24 @@
1
+ import type { ComponentProps, ReactNode } from 'react';
2
+ import { Input as BaseInput } from '@base-ui/react/input';
3
+ import '../Input/input.css';
4
+ import './textarea.css';
5
+ export type TextareaProps = Omit<ComponentProps<'textarea'>, 'className'> & Pick<BaseInput.Props, 'onValueChange'> & {
6
+ /** Floating label. Sits on the first line and moves onto the border once it has focus or a value. */
7
+ label?: ReactNode;
8
+ /**
9
+ * `small` has less padding, and its label works like a placeholder: it
10
+ * hides once there's text instead of moving onto the border. @default 'normal'
11
+ */
12
+ size?: 'small' | 'normal';
13
+ /** Applied to the outer wrapper, so width and margins work as expected. */
14
+ className?: string;
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
+ */
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;
@@ -0,0 +1,50 @@
1
+ import { Radio as BaseRadio } from '@base-ui/react/radio';
2
+ import { RadioGroup as BaseRadioGroup } from '@base-ui/react/radio-group';
3
+ import { ToggleGroup as BaseToggleGroup } from '@base-ui/react/toggle-group';
4
+ import type { MaterialSymbol } from 'material-symbols';
5
+ import { ColorProps } from '../../colors/colors';
6
+ import './toggle-group.css';
7
+ type ToggleGroupCommonProps = ColorProps & {
8
+ /** Same heights as `Button`. @default 'normal' */
9
+ size?: 'small' | 'normal' | 'big';
10
+ };
11
+ export type ToggleGroupProps<Value = any> = ToggleGroupCommonProps & ((BaseRadioGroup.Props<Value> & {
12
+ /**
13
+ * Let several segments be on at once. `value` is then an array
14
+ * of strings. Without it, `value` is a single value, not an
15
+ * array. @default false
16
+ */
17
+ multiple?: false;
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
+ */
24
+ multiple: true;
25
+ }));
26
+ /**
27
+ * A segmented control: buttons in a row. By default exactly one is selected,
28
+ * with a pill that stretches over to it. With `multiple`, each one toggles on
29
+ * and off. Use it for 2-5 short options; for longer lists or forms, use
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>
37
+ */
38
+ export declare function ToggleGroup<Value>({ size, color, fillType, multiple, children, className, ref, ...props }: ToggleGroupProps<Value>): import("react").JSX.Element;
39
+ export type ToggleGroupItemProps<Value = any> = BaseRadio.Root.Props<Value> & {
40
+ /** Material Symbol shown before the label. */
41
+ startIcon?: MaterialSymbol;
42
+ /** Material Symbol shown after the label. */
43
+ endIcon?: MaterialSymbol;
44
+ };
45
+ /**
46
+ * One option in a `ToggleGroup`. Requires a `value` (a string when the
47
+ * group is `multiple`).
48
+ */
49
+ export declare function ToggleGroupItem<Value>({ startIcon, endIcon, children, className, value, ...props }: ToggleGroupItemProps<Value>): import("react").JSX.Element;
50
+ export {};
@@ -0,0 +1,23 @@
1
+ import { type ReactElement, type ReactNode } from 'react';
2
+ import { Tooltip as BaseTooltip } from '@base-ui/react/tooltip';
3
+ import './tooltip.css';
4
+ export type TooltipProps = Omit<BaseTooltip.Root.Props, 'children'> & Pick<BaseTooltip.Trigger.Props, 'delay' | 'closeDelay'> & Pick<BaseTooltip.Positioner.Props, 'side' | 'align' | 'sideOffset' | 'alignOffset'> & Pick<BaseTooltip.Popup.Props, 'className'> & {
5
+ /** Text shown in the tooltip. Keep it short; nothing in it can be clicked. */
6
+ label: ReactNode;
7
+ /**
8
+ * The element the tooltip describes. It must take a ref and pass its
9
+ * props through, as the library's components do.
10
+ */
11
+ children: ReactElement;
12
+ };
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
+ */
23
+ export declare function Tooltip({ label, children, delay, closeDelay, side, align, sideOffset, alignOffset, className, ...props }: TooltipProps): import("react").JSX.Element;
@@ -0,0 +1,22 @@
1
+ import './typography.css';
2
+ export type TypographyType = 'body' | 'caption' | 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
3
+ export type TypographyTag = 'p' | 'span' | 'div' | 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
4
+ export type TypographyProps = React.ComponentProps<'p'> & {
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
+ */
10
+ type?: TypographyType;
11
+ /** The HTML tag, when it should differ from the look (e.g. an h2 styled as h6). */
12
+ as?: TypographyTag;
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
+ */
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;