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.
- package/AGENTS.md +483 -0
- package/LICENSE +21 -0
- package/README.md +128 -2
- package/bin/anvilui.mjs +83 -0
- package/dist/colors/colors.d.ts +24 -0
- package/dist/components/Accordion/Accordion.d.ts +36 -0
- package/dist/components/AnimatedNumber/AnimatedNumber.d.ts +17 -0
- package/dist/components/AnvilRoot/AnvilContext.d.ts +34 -0
- package/dist/components/AnvilRoot/AnvilRoot.d.ts +56 -0
- package/dist/components/AppBar/AppBar.d.ts +45 -0
- package/dist/components/Avatar/Avatar.d.ts +27 -0
- package/dist/components/Avatar/AvatarGroupContext.d.ts +1 -0
- package/dist/components/AvatarGroup/AvatarGroup.d.ts +25 -0
- package/dist/components/Badge/Badge.d.ts +23 -0
- package/dist/components/BottomSheet/BottomSheet.d.ts +41 -0
- package/dist/components/Button/Button.d.ts +35 -0
- package/dist/components/Calendar/Calendar.d.ts +19 -0
- package/dist/components/Card/Card.d.ts +57 -0
- package/dist/components/Carousel/Carousel.d.ts +21 -0
- package/dist/components/Checkbox/Checkbox.d.ts +14 -0
- package/dist/components/Chip/Chip.d.ts +46 -0
- package/dist/components/Combobox/Combobox.d.ts +42 -0
- package/dist/components/Confetti/Confetti.d.ts +31 -0
- package/dist/components/ContextMenu/ContextMenu.d.ts +24 -0
- package/dist/components/DateInput/DateInput.d.ts +37 -0
- package/dist/components/Dialog/Dialog.d.ts +56 -0
- package/dist/components/Divider/Divider.d.ts +24 -0
- package/dist/components/FAB/FAB.d.ts +28 -0
- package/dist/components/FAB/magnet.d.ts +2 -0
- package/dist/components/FABMenu/FABMenu.d.ts +55 -0
- package/dist/components/Field/Field.d.ts +36 -0
- package/dist/components/FloatingToolbar/FloatingToolbar.d.ts +37 -0
- package/dist/components/HoldButton/HoldButton.d.ts +18 -0
- package/dist/components/Icon/Icon.d.ts +21 -0
- package/dist/components/IconButton/IconButton.d.ts +22 -0
- package/dist/components/Input/Input.d.ts +24 -0
- package/dist/components/Kbd/Kbd.d.ts +21 -0
- package/dist/components/List/List.d.ts +35 -0
- package/dist/components/Menu/Menu.d.ts +54 -0
- package/dist/components/Menubar/Menubar.d.ts +17 -0
- package/dist/components/NavigationBar/NavigationBar.d.ts +30 -0
- package/dist/components/NavigationDrawer/NavigationDrawer.d.ts +52 -0
- package/dist/components/NavigationList/NavigationList.d.ts +27 -0
- package/dist/components/NavigationRail/NavigationRail.d.ts +48 -0
- package/dist/components/PinInput/PinInput.d.ts +31 -0
- package/dist/components/Popover/Popover.d.ts +49 -0
- package/dist/components/PreviewCard/PreviewCard.d.ts +31 -0
- package/dist/components/Progress/Progress.d.ts +29 -0
- package/dist/components/RadioGroup/RadioGroup.d.ts +19 -0
- package/dist/components/Search/Search.d.ts +39 -0
- package/dist/components/Select/Select.d.ts +38 -0
- package/dist/components/Skeleton/Skeleton.d.ts +20 -0
- package/dist/components/Slider/Slider.d.ts +31 -0
- package/dist/components/Snackbar/Snackbar.d.ts +35 -0
- package/dist/components/SplitButton/SplitButton.d.ts +16 -0
- package/dist/components/SquigglyWave/SquigglyWave.d.ts +36 -0
- package/dist/components/Sticker/Sticker.d.ts +21 -0
- package/dist/components/Switch/Switch.d.ts +15 -0
- package/dist/components/Table/Table.d.ts +36 -0
- package/dist/components/Tabs/Tabs.d.ts +32 -0
- package/dist/components/Textarea/Textarea.d.ts +24 -0
- package/dist/components/TimePicker/TimePicker.d.ts +45 -0
- package/dist/components/Toggle/Toggle.d.ts +41 -0
- package/dist/components/ToggleGroup/ToggleGroup.d.ts +50 -0
- package/dist/components/Tooltip/Tooltip.d.ts +23 -0
- package/dist/components/Typography/Typography.d.ts +22 -0
- package/dist/datetime.d.ts +12 -0
- package/dist/dev.d.ts +15 -0
- package/dist/index.cjs +5419 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.css +3724 -0
- package/dist/index.css.map +1 -0
- package/dist/index.d.ts +129 -0
- package/dist/index.js +5299 -0
- package/dist/index.js.map +1 -0
- package/dist/morph.d.ts +64 -0
- package/dist/themes/baseTheme.d.ts +5 -0
- package/dist/themes/createTheme.d.ts +22 -0
- package/dist/themes/monochromeTheme.d.ts +5 -0
- package/dist/themes/toCssVariables.d.ts +2 -0
- package/dist/themes/types.d.ts +60 -0
- package/dist/tokens/baseTokens.d.ts +6 -0
- package/dist/tokens/toCssVariables.d.ts +2 -0
- package/dist/tokens/types.d.ts +80 -0
- package/dist/utils.d.ts +4 -0
- package/docs/accordion.md +47 -0
- package/docs/animated-number.md +31 -0
- package/docs/app-bar.md +53 -0
- package/docs/avatar-group.md +35 -0
- package/docs/avatar.md +34 -0
- package/docs/badge.md +41 -0
- package/docs/bottom-sheet.md +65 -0
- package/docs/button.md +63 -0
- package/docs/calendar.md +26 -0
- package/docs/card.md +71 -0
- package/docs/carousel.md +43 -0
- package/docs/checkbox.md +37 -0
- package/docs/chip.md +48 -0
- package/docs/combobox.md +72 -0
- package/docs/composition.md +80 -0
- package/docs/confetti.md +30 -0
- package/docs/context-menu.md +42 -0
- package/docs/date-input.md +41 -0
- package/docs/dialog.md +106 -0
- package/docs/divider.md +31 -0
- package/docs/fab-menu.md +55 -0
- package/docs/fab.md +43 -0
- package/docs/field.md +59 -0
- package/docs/floating-toolbar.md +48 -0
- package/docs/forms.md +81 -0
- package/docs/hold-button.md +32 -0
- package/docs/icon-button.md +54 -0
- package/docs/icons.md +38 -0
- package/docs/input.md +50 -0
- package/docs/kbd.md +25 -0
- package/docs/list.md +65 -0
- package/docs/llms-index.md +82 -0
- package/docs/menu.md +88 -0
- package/docs/menubar.md +34 -0
- package/docs/morph.md +51 -0
- package/docs/navigation-bar.md +48 -0
- package/docs/navigation-drawer.md +72 -0
- package/docs/navigation-list.md +40 -0
- package/docs/navigation-rail.md +53 -0
- package/docs/pin-input.md +38 -0
- package/docs/popover.md +78 -0
- package/docs/preview-card.md +40 -0
- package/docs/progress.md +37 -0
- package/docs/radio-group.md +47 -0
- package/docs/search.md +77 -0
- package/docs/select.md +64 -0
- package/docs/setup.md +106 -0
- package/docs/skeleton.md +33 -0
- package/docs/slider.md +49 -0
- package/docs/snackbar.md +50 -0
- package/docs/split-button.md +44 -0
- package/docs/sticker.md +27 -0
- package/docs/switch.md +44 -0
- package/docs/table.md +66 -0
- package/docs/tabs.md +51 -0
- package/docs/textarea.md +23 -0
- package/docs/theming.md +182 -0
- package/docs/time-picker.md +38 -0
- package/docs/toggle-group.md +70 -0
- package/docs/toggle.md +49 -0
- package/docs/tooltip.md +42 -0
- package/docs/typography.md +41 -0
- 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;
|