anvilui 0.1.0 → 0.3.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 (144) hide show
  1. package/AGENTS.md +483 -0
  2. package/README.md +60 -40
  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 +48 -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 +39 -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 +14 -1
  35. package/dist/components/Input/Input.d.ts +14 -3
  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 +33 -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 +12 -2
  48. package/dist/components/RadioGroup/RadioGroup.d.ts +14 -2
  49. package/dist/components/Search/Search.d.ts +55 -0
  50. package/dist/components/Select/Select.d.ts +21 -4
  51. package/dist/components/Skeleton/Skeleton.d.ts +20 -0
  52. package/dist/components/Slider/Slider.d.ts +7 -1
  53. package/dist/components/Snackbar/Snackbar.d.ts +7 -2
  54. package/dist/components/SplitButton/SplitButton.d.ts +13 -0
  55. package/dist/components/SquigglyWave/SquigglyWave.d.ts +26 -4
  56. package/dist/components/Sticker/Sticker.d.ts +21 -0
  57. package/dist/components/Switch/Switch.d.ts +11 -0
  58. package/dist/components/Table/Table.d.ts +36 -0
  59. package/dist/components/Tabs/Tabs.d.ts +17 -0
  60. package/dist/components/Textarea/Textarea.d.ts +14 -3
  61. package/dist/components/TimePicker/TimePicker.d.ts +47 -0
  62. package/dist/components/Toggle/Toggle.d.ts +42 -0
  63. package/dist/components/ToggleGroup/ToggleGroup.d.ts +16 -4
  64. package/dist/components/Tooltip/Tooltip.d.ts +10 -1
  65. package/dist/components/Typography/Typography.d.ts +13 -1
  66. package/dist/datetime.d.ts +12 -0
  67. package/dist/dev.d.ts +15 -0
  68. package/dist/index.cjs +3365 -654
  69. package/dist/index.cjs.map +1 -1
  70. package/dist/index.css +1443 -367
  71. package/dist/index.css.map +1 -1
  72. package/dist/index.d.ts +50 -4
  73. package/dist/index.js +3362 -667
  74. package/dist/index.js.map +1 -1
  75. package/dist/themes/baseTheme.d.ts +2 -0
  76. package/dist/themes/createTheme.d.ts +22 -0
  77. package/dist/themes/monochromeTheme.d.ts +2 -0
  78. package/dist/themes/types.d.ts +13 -8
  79. package/dist/tokens/baseTokens.d.ts +4 -0
  80. package/dist/tokens/types.d.ts +34 -0
  81. package/dist/utils.d.ts +4 -0
  82. package/docs/accordion.md +47 -0
  83. package/docs/animated-number.md +31 -0
  84. package/docs/app-bar.md +53 -0
  85. package/docs/avatar-group.md +35 -0
  86. package/docs/avatar.md +34 -0
  87. package/docs/badge.md +41 -0
  88. package/docs/bottom-sheet.md +65 -0
  89. package/docs/button.md +63 -0
  90. package/docs/calendar.md +26 -0
  91. package/docs/card.md +71 -0
  92. package/docs/carousel.md +43 -0
  93. package/docs/checkbox.md +37 -0
  94. package/docs/chip.md +48 -0
  95. package/docs/combobox.md +73 -0
  96. package/docs/composition.md +80 -0
  97. package/docs/confetti.md +30 -0
  98. package/docs/context-menu.md +42 -0
  99. package/docs/date-input.md +42 -0
  100. package/docs/dialog.md +106 -0
  101. package/docs/divider.md +31 -0
  102. package/docs/fab-menu.md +55 -0
  103. package/docs/fab.md +43 -0
  104. package/docs/field.md +59 -0
  105. package/docs/floating-toolbar.md +48 -0
  106. package/docs/forms.md +81 -0
  107. package/docs/hold-button.md +32 -0
  108. package/docs/icon-button.md +55 -0
  109. package/docs/icons.md +38 -0
  110. package/docs/input.md +51 -0
  111. package/docs/kbd.md +25 -0
  112. package/docs/list.md +65 -0
  113. package/docs/llms-index.md +82 -0
  114. package/docs/menu.md +88 -0
  115. package/docs/menubar.md +34 -0
  116. package/docs/morph.md +54 -0
  117. package/docs/navigation-bar.md +48 -0
  118. package/docs/navigation-drawer.md +72 -0
  119. package/docs/navigation-list.md +40 -0
  120. package/docs/navigation-rail.md +53 -0
  121. package/docs/pin-input.md +38 -0
  122. package/docs/popover.md +78 -0
  123. package/docs/preview-card.md +40 -0
  124. package/docs/progress.md +37 -0
  125. package/docs/radio-group.md +64 -0
  126. package/docs/search.md +77 -0
  127. package/docs/select.md +65 -0
  128. package/docs/setup.md +106 -0
  129. package/docs/skeleton.md +33 -0
  130. package/docs/slider.md +49 -0
  131. package/docs/snackbar.md +50 -0
  132. package/docs/split-button.md +44 -0
  133. package/docs/sticker.md +27 -0
  134. package/docs/switch.md +44 -0
  135. package/docs/table.md +66 -0
  136. package/docs/tabs.md +51 -0
  137. package/docs/textarea.md +23 -0
  138. package/docs/theming.md +183 -0
  139. package/docs/time-picker.md +39 -0
  140. package/docs/toggle-group.md +70 -0
  141. package/docs/toggle.md +49 -0
  142. package/docs/tooltip.md +42 -0
  143. package/docs/typography.md +41 -0
  144. package/package.json +25 -5
@@ -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
- export type ToggleGroupProps<Value = any> = ToggleGroupCommonProps & ((BaseRadioGroup.Props<Value> & {
11
+ export type ToggleGroupProps<Value = unknown> = 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,9 +28,15 @@ 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
- export type ToggleGroupItemProps<Value = any> = BaseRadio.Root.Props<Value> & {
39
+ export type ToggleGroupItemProps<Value = unknown> = BaseRadio.Root.Props<Value> & {
28
40
  /** Material Symbol shown before the label. */
29
41
  startIcon?: MaterialSymbol;
30
42
  /** Material Symbol shown after the label. */
@@ -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;