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
package/bin/anvilui.mjs
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// `npx anvilui setup-agents`: tells the project's AI coding agents to read
|
|
3
|
+
// the docs that ship in node_modules/anvilui. Only runs when called.
|
|
4
|
+
import fs from 'node:fs'
|
|
5
|
+
import path from 'node:path'
|
|
6
|
+
|
|
7
|
+
const MARKER = '<!-- anvilui-agent-docs -->'
|
|
8
|
+
const SNIPPET = `${MARKER}
|
|
9
|
+
## AnvilUI
|
|
10
|
+
|
|
11
|
+
This project uses the \`anvilui\` React component library. Its API differs from shadcn/ui, Radix and MUI, so don't guess it. Before writing or changing UI code that uses it, read \`node_modules/anvilui/AGENTS.md\`, then the page for each component you use in \`node_modules/anvilui/docs/\` (index: \`node_modules/anvilui/docs/llms-index.md\`). These docs match the installed version; prefer them over memory.
|
|
12
|
+
`
|
|
13
|
+
|
|
14
|
+
// Instruction files agents read, in the order we look for them
|
|
15
|
+
const KNOWN = [
|
|
16
|
+
'AGENTS.md',
|
|
17
|
+
'CLAUDE.md',
|
|
18
|
+
'.cursorrules',
|
|
19
|
+
'.github/copilot-instructions.md',
|
|
20
|
+
]
|
|
21
|
+
|
|
22
|
+
const HELP = `Usage: npx anvilui setup-agents [--file <path>]...
|
|
23
|
+
|
|
24
|
+
Adds a short note to your AI agent instruction files telling agents to read
|
|
25
|
+
node_modules/anvilui/AGENTS.md before writing code with AnvilUI.
|
|
26
|
+
|
|
27
|
+
With no --file, updates every one of ${KNOWN.join(', ')}
|
|
28
|
+
that exists in the current folder, or creates AGENTS.md if none do.
|
|
29
|
+
Files that already have the note are left alone.
|
|
30
|
+
|
|
31
|
+
--file <path> Update (or create) this file instead. Repeatable.
|
|
32
|
+
`
|
|
33
|
+
|
|
34
|
+
const [command, ...args] = process.argv.slice(2)
|
|
35
|
+
|
|
36
|
+
if (command !== 'setup-agents') {
|
|
37
|
+
process.stdout.write(HELP)
|
|
38
|
+
process.exit(
|
|
39
|
+
command === undefined || command === '--help' || command === '-h'
|
|
40
|
+
? 0
|
|
41
|
+
: 1
|
|
42
|
+
)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const files = []
|
|
46
|
+
for (let i = 0; i < args.length; i++) {
|
|
47
|
+
if (args[i] === '--file' && args[i + 1]) files.push(args[++i])
|
|
48
|
+
else if (args[i] === '--help' || args[i] === '-h') {
|
|
49
|
+
process.stdout.write(HELP)
|
|
50
|
+
process.exit(0)
|
|
51
|
+
} else {
|
|
52
|
+
process.stderr.write(`Unknown option: ${args[i]}\n\n${HELP}`)
|
|
53
|
+
process.exit(1)
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const cwd = process.cwd()
|
|
58
|
+
if (files.length === 0) {
|
|
59
|
+
files.push(...KNOWN.filter((f) => fs.existsSync(path.join(cwd, f))))
|
|
60
|
+
if (files.length === 0) files.push('AGENTS.md')
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
for (const file of files) {
|
|
64
|
+
const full = path.resolve(cwd, file)
|
|
65
|
+
const existing = fs.existsSync(full) ? fs.readFileSync(full, 'utf8') : null
|
|
66
|
+
if (existing?.includes(MARKER)) {
|
|
67
|
+
console.log(`unchanged ${file} (already has the AnvilUI note)`)
|
|
68
|
+
continue
|
|
69
|
+
}
|
|
70
|
+
fs.mkdirSync(path.dirname(full), { recursive: true })
|
|
71
|
+
if (existing === null) {
|
|
72
|
+
fs.writeFileSync(full, SNIPPET)
|
|
73
|
+
console.log(`created ${file}`)
|
|
74
|
+
} else {
|
|
75
|
+
const gap = existing.endsWith('\n\n')
|
|
76
|
+
? ''
|
|
77
|
+
: existing.endsWith('\n')
|
|
78
|
+
? '\n'
|
|
79
|
+
: '\n\n'
|
|
80
|
+
fs.appendFileSync(full, gap + SNIPPET)
|
|
81
|
+
console.log(`updated ${file}`)
|
|
82
|
+
}
|
|
83
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A color role from the theme. `primary` is the brand color, `tonal` a
|
|
3
|
+
* softer accent for selected and secondary actions, `container` the neutral
|
|
4
|
+
* one (use it for "secondary" or "default" buttons), and `surface` the
|
|
5
|
+
* background of navigation and popups. There is no `secondary`, `danger` or
|
|
6
|
+
* `destructive`: use `tonal` or `container`, and `error`.
|
|
7
|
+
*/
|
|
8
|
+
export type ComponentColor = 'primary' | 'tonal' | 'success' | 'warning' | 'error' | 'container' | 'surface';
|
|
9
|
+
/**
|
|
10
|
+
* How a color is applied. Takes the place of the `variant` prop other
|
|
11
|
+
* libraries use.
|
|
12
|
+
* - `filled`: solid background in the color
|
|
13
|
+
* - `outlined`: transparent with a border, text in the color
|
|
14
|
+
* - `text`: transparent, no border, text in the color
|
|
15
|
+
*/
|
|
16
|
+
export type ComponentFillType = 'filled' | 'outlined' | 'text';
|
|
17
|
+
/** The `color` and `fillType` props shared by colored components. */
|
|
18
|
+
export type ColorProps = {
|
|
19
|
+
/** Color role from the theme. @default 'primary' */
|
|
20
|
+
color?: ComponentColor;
|
|
21
|
+
/** How the color is applied. @default 'filled' */
|
|
22
|
+
fillType?: ComponentFillType;
|
|
23
|
+
};
|
|
24
|
+
export declare function colorClass(color?: ComponentColor, fillType?: ComponentFillType): string;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Accordion as BaseAccordion } from '@base-ui/react/accordion';
|
|
2
|
+
import './accordion.css';
|
|
3
|
+
/**
|
|
4
|
+
* A stack of sections that each expand to show their content. Fill it with
|
|
5
|
+
* `AccordionItem`s. Holds which are open (`value` / `defaultValue` /
|
|
6
|
+
* `onValueChange`); pass `multiple` to allow more than one at a time.
|
|
7
|
+
*/
|
|
8
|
+
export type AccordionProps = BaseAccordion.Root.Props;
|
|
9
|
+
/**
|
|
10
|
+
* A stack of expandable sections. `value` is an array of open item values
|
|
11
|
+
* (even when only one can be open). Pass `multiple` to allow several.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* <Accordion defaultValue={['shipping']}>
|
|
15
|
+
* <AccordionItem value="shipping">
|
|
16
|
+
* <AccordionTrigger>Shipping</AccordionTrigger>
|
|
17
|
+
* <AccordionPanel>Ships in 2 days.</AccordionPanel>
|
|
18
|
+
* </AccordionItem>
|
|
19
|
+
* </Accordion>
|
|
20
|
+
*/
|
|
21
|
+
export declare function Accordion({ className, ...props }: AccordionProps): import("react").JSX.Element;
|
|
22
|
+
export type AccordionItemProps = BaseAccordion.Item.Props;
|
|
23
|
+
/**
|
|
24
|
+
* One section: an `AccordionTrigger`, then an `AccordionPanel`. Give it a
|
|
25
|
+
* `value` to control it from the Accordion.
|
|
26
|
+
*/
|
|
27
|
+
export declare function AccordionItem({ className, ...props }: AccordionItemProps): import("react").JSX.Element;
|
|
28
|
+
export type AccordionTriggerProps = BaseAccordion.Trigger.Props & {
|
|
29
|
+
/** The heading level that wraps the button, to fit the page's outline. @default 'h3' */
|
|
30
|
+
as?: 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
|
|
31
|
+
};
|
|
32
|
+
/** The section's title row. Renders a button inside an `<h3>` (change with `as`). */
|
|
33
|
+
export declare function AccordionTrigger({ as: Heading, className, children, ...props }: AccordionTriggerProps): import("react").JSX.Element;
|
|
34
|
+
export type AccordionPanelProps = BaseAccordion.Panel.Props;
|
|
35
|
+
/** The section's content, shown while it's open. */
|
|
36
|
+
export declare function AccordionPanel({ className, children, ...props }: AccordionPanelProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import './animated-number.css';
|
|
2
|
+
export type AnimatedNumberProps = Omit<React.ComponentProps<'span'>, 'children'> & {
|
|
3
|
+
/** The number to show. Digits roll to the new value when it changes. */
|
|
4
|
+
value: number;
|
|
5
|
+
/** How to format the number: decimals, currency, percent, compact, ... */
|
|
6
|
+
format?: Intl.NumberFormatOptions;
|
|
7
|
+
/** Locale for formatting. @default the browser's */
|
|
8
|
+
locales?: Intl.LocalesArgument;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* A number whose digits roll like an odometer when `value` changes.
|
|
12
|
+
* Screen readers hear the formatted number, not the individual digits.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* <AnimatedNumber value={price} format={{ style: 'currency', currency: 'USD' }} />
|
|
16
|
+
*/
|
|
17
|
+
export declare function AnimatedNumber({ value, format, locales, className, ...props }: AnimatedNumberProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Dispatch, RefObject, SetStateAction } from 'react';
|
|
2
|
+
import { Theme } from '../../themes/types';
|
|
3
|
+
import { DesignTokens } from '../../tokens/types';
|
|
4
|
+
/** The mode actually shown. */
|
|
5
|
+
export type ColorType = 'light' | 'dark';
|
|
6
|
+
/** What the user picked; `'system'` follows the OS setting live. */
|
|
7
|
+
export type ColorModeSetting = ColorType | 'system';
|
|
8
|
+
type AnvilContextValues = {
|
|
9
|
+
/** The mode being shown, with `'system'` already resolved. */
|
|
10
|
+
colorMode: ColorType;
|
|
11
|
+
/** What was picked, which may be `'system'`. */
|
|
12
|
+
colorModeSetting: ColorModeSetting;
|
|
13
|
+
/** Changes the color mode, like a `useState` setter. Saved under `storageKey` if set. */
|
|
14
|
+
setColorMode: Dispatch<SetStateAction<ColorModeSetting>>;
|
|
15
|
+
/** The theme used in dark mode. */
|
|
16
|
+
darkTheme: Theme;
|
|
17
|
+
/** The theme used in light mode. */
|
|
18
|
+
lightTheme: Theme;
|
|
19
|
+
/** The design tokens in use, defaults filled in. */
|
|
20
|
+
tokens: DesignTokens;
|
|
21
|
+
rootRef: RefObject<HTMLDivElement | null>;
|
|
22
|
+
};
|
|
23
|
+
/** The raw context behind `useAnvil()`: `null` outside AnvilRoot. Prefer `useAnvil()`. */
|
|
24
|
+
export declare const AnvilContext: import("react").Context<AnvilContextValues | null>;
|
|
25
|
+
/**
|
|
26
|
+
* The current color mode, its setter, themes and tokens. Must be used inside
|
|
27
|
+
* `AnvilRoot`.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* const { colorMode, setColorMode } = useAnvil()
|
|
31
|
+
* <Switch checked={colorMode === 'dark'} onCheckedChange={(dark) => setColorMode(dark ? 'dark' : 'light')} />
|
|
32
|
+
*/
|
|
33
|
+
export declare function useAnvil(): AnvilContextValues;
|
|
34
|
+
export {};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { ColorModeSetting } from './AnvilContext';
|
|
3
|
+
import { Theme } from '../../themes/types';
|
|
4
|
+
import { DesignTokens } from '../../tokens/types';
|
|
5
|
+
import '../../colors/colors.css';
|
|
6
|
+
import './global.css';
|
|
7
|
+
export type AnvilRootProps = {
|
|
8
|
+
/** Your app. Every AnvilUI component must be somewhere inside. */
|
|
9
|
+
children: ReactNode;
|
|
10
|
+
/** Extra classes for the root element, e.g. to make it fill the viewport. */
|
|
11
|
+
className?: string;
|
|
12
|
+
/** Controlled color mode. Pair with `onColorModeChange`. */
|
|
13
|
+
colorMode?: ColorModeSetting;
|
|
14
|
+
/**
|
|
15
|
+
* Starting color mode when `colorMode` isn't controlled and nothing is
|
|
16
|
+
* saved under `storageKey`. `'system'` follows the OS setting live.
|
|
17
|
+
* @default 'system'
|
|
18
|
+
*/
|
|
19
|
+
defaultColorMode?: ColorModeSetting;
|
|
20
|
+
/** Called whenever the color mode is changed. */
|
|
21
|
+
onColorModeChange?: (colorMode: ColorModeSetting) => void;
|
|
22
|
+
/**
|
|
23
|
+
* When set, the color mode is saved in `localStorage` under this key and
|
|
24
|
+
* restored on the next visit. With server rendering, a small inline script
|
|
25
|
+
* applies it before the first paint, so there's no flash (a strict CSP
|
|
26
|
+
* must allow inline scripts for that).
|
|
27
|
+
*/
|
|
28
|
+
storageKey?: string;
|
|
29
|
+
/** Colors used in light mode. @default baseLightTheme */
|
|
30
|
+
lightTheme?: Theme;
|
|
31
|
+
/** Colors used in dark mode. @default baseDarkTheme */
|
|
32
|
+
darkTheme?: Theme;
|
|
33
|
+
/**
|
|
34
|
+
* Spacing, radius, font, motion and shadow tokens. Categories you pass
|
|
35
|
+
* replace the base ones; the rest keep their defaults.
|
|
36
|
+
* @default baseDesignTokens
|
|
37
|
+
*/
|
|
38
|
+
tokens?: Partial<DesignTokens>;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Required at the top of the app. Provides the theme, color mode, tooltip
|
|
42
|
+
* and snackbar providers, and the element that menus, dialogs and other
|
|
43
|
+
* popups portal into. Also import `'anvilui/styles.css'` once.
|
|
44
|
+
*
|
|
45
|
+
* Only the root's own box is themed; to color the whole page, make it fill
|
|
46
|
+
* the viewport via `className`.
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* import { AnvilRoot } from 'anvilui'
|
|
50
|
+
* import 'anvilui/styles.css'
|
|
51
|
+
*
|
|
52
|
+
* <AnvilRoot defaultColorMode="system" storageKey="color-mode">
|
|
53
|
+
* <App />
|
|
54
|
+
* </AnvilRoot>
|
|
55
|
+
*/
|
|
56
|
+
export declare function AnvilRoot(props: AnvilRootProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { ComponentProps, ReactNode } from 'react';
|
|
2
|
+
import type { ComponentColor, ComponentFillType } from '../../colors/colors';
|
|
3
|
+
import { type TypographyTag } from '../Typography/Typography';
|
|
4
|
+
import './app-bar.css';
|
|
5
|
+
export type AppBarProps = ComponentProps<'header'> & {
|
|
6
|
+
/** The page or screen title. */
|
|
7
|
+
label: ReactNode;
|
|
8
|
+
/**
|
|
9
|
+
* HTML tag for the title. A div by default; use `'h1'` when the bar's
|
|
10
|
+
* title is the page's main heading. @default 'div'
|
|
11
|
+
*/
|
|
12
|
+
labelAs?: TypographyTag;
|
|
13
|
+
/** Before the title, usually a navigation `IconButton` (menu or back). */
|
|
14
|
+
start?: ReactNode;
|
|
15
|
+
/** After the title, usually a few action `IconButton`s. */
|
|
16
|
+
end?: ReactNode;
|
|
17
|
+
/** `big` puts the title on its own, larger row below the buttons. @default 'normal' */
|
|
18
|
+
size?: 'normal' | 'big';
|
|
19
|
+
/** Center the title. Only for `size="normal"`. @default false */
|
|
20
|
+
centered?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Color role from the theme. The default `container` gives the bar the
|
|
23
|
+
* navigation color (the theme's `surface`), so it matches a
|
|
24
|
+
* NavigationRail or NavigationDrawer beside it. @default 'container'
|
|
25
|
+
*/
|
|
26
|
+
color?: ComponentColor;
|
|
27
|
+
/**
|
|
28
|
+
* `filled` gives the bar a solid background. `text` makes it colorless,
|
|
29
|
+
* the same color as the page. @default 'filled'
|
|
30
|
+
*/
|
|
31
|
+
fillType?: ComponentFillType;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* The bar across the top of a page or screen: title, navigation and actions.
|
|
35
|
+
* The title is the `label` prop, not children.
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* <AppBar
|
|
39
|
+
* label="Inbox"
|
|
40
|
+
* labelAs="h1"
|
|
41
|
+
* start={<IconButton icon="menu" aria-label="Menu" fillType="text" color="container" />}
|
|
42
|
+
* end={<IconButton icon="search" aria-label="Search" fillType="text" color="container" />}
|
|
43
|
+
* />
|
|
44
|
+
*/
|
|
45
|
+
export declare function AppBar({ label, labelAs, start, end, size, centered, color, fillType, className, ...props }: AppBarProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Avatar as BaseAvatar } from '@base-ui/react/avatar';
|
|
2
|
+
import type { MaterialSymbol } from 'material-symbols';
|
|
3
|
+
import { type ColorProps } from '../../colors/colors';
|
|
4
|
+
import './avatar.css';
|
|
5
|
+
export type AvatarProps = BaseAvatar.Root.Props & ColorProps & {
|
|
6
|
+
/** Image URL. While it loads, or if it fails, the fallback shows. */
|
|
7
|
+
src?: string;
|
|
8
|
+
/**
|
|
9
|
+
* The person's (or thing's) name. Read by screen readers, and its
|
|
10
|
+
* initials are the fallback: "Ada Lovelace" shows "AL". Leave it out
|
|
11
|
+
* when the name is already shown next to the avatar.
|
|
12
|
+
*/
|
|
13
|
+
name?: string;
|
|
14
|
+
/** Fallback icon when there's no `name`. @default 'person' */
|
|
15
|
+
icon?: MaterialSymbol;
|
|
16
|
+
/** 32px, 40px or 56px. @default 'normal', or the AvatarGroup's size */
|
|
17
|
+
size?: 'small' | 'normal' | 'big';
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* A picture, initials or an icon that stands for a person or thing.
|
|
21
|
+
* `children` replaces the initials/icon fallback.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* <Avatar name="Ada Lovelace" src="/ada.jpg" />
|
|
25
|
+
* <Avatar name="Ada Lovelace" color="tonal" size="big" />
|
|
26
|
+
*/
|
|
27
|
+
export declare function Avatar({ src, name, icon, size: sizeProp, color, fillType, className, children, ...props }: AvatarProps): import("react").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const AvatarGroupContext: import("react").Context<"big" | "normal" | "small" | null | undefined>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type ComponentProps } from 'react';
|
|
2
|
+
import { type AvatarProps } from '../Avatar/Avatar';
|
|
3
|
+
import './avatar-group.css';
|
|
4
|
+
export type AvatarGroupProps = ComponentProps<'div'> & {
|
|
5
|
+
/**
|
|
6
|
+
* Most avatars to show. Past it, the last spot becomes a "+N" counter,
|
|
7
|
+
* so the group never takes more than `max` spots. @default no limit
|
|
8
|
+
*/
|
|
9
|
+
max?: number;
|
|
10
|
+
/** Size of every avatar inside, unless one sets its own. @default 'normal' */
|
|
11
|
+
size?: AvatarProps['size'];
|
|
12
|
+
/** Spread the avatars apart on hover and keyboard focus. @default true */
|
|
13
|
+
fan?: boolean;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* A row of overlapping `Avatar`s that fans out on hover. Give it an
|
|
17
|
+
* `aria-label` ("Project members") so screen readers know what the
|
|
18
|
+
* avatars are.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* <AvatarGroup max={4} aria-label="Project members">
|
|
22
|
+
* {people.map((p) => <Avatar key={p.id} name={p.name} src={p.photo} />)}
|
|
23
|
+
* </AvatarGroup>
|
|
24
|
+
*/
|
|
25
|
+
export declare function AvatarGroup({ max, size, fan, className, children, ...props }: AvatarGroupProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { ComponentProps } from 'react';
|
|
2
|
+
import { type ComponentColor } from '../../colors/colors';
|
|
3
|
+
import './badge.css';
|
|
4
|
+
export type BadgeProps = ComponentProps<'span'> & {
|
|
5
|
+
/** Number to show. Leave out for a small dot; `0` hides the badge. */
|
|
6
|
+
count?: number;
|
|
7
|
+
/** Higher counts show as "999+". @default 999 */
|
|
8
|
+
max?: number;
|
|
9
|
+
/** Color role from the theme. @default 'error' */
|
|
10
|
+
color?: ComponentColor;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* A dot or count on the corner of what it wraps (an `Icon`, `IconButton`,
|
|
14
|
+
* `Avatar`, ...), or inline on its own when it wraps nothing.
|
|
15
|
+
*
|
|
16
|
+
* It's hidden from screen readers: put the count in the wrapped element's
|
|
17
|
+
* name too, e.g. `aria-label="Inbox, 3 unread"`.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* <Badge count={3}><IconButton icon="mail" aria-label="Inbox, 3 unread" /></Badge>
|
|
21
|
+
* <Badge><Icon name="notifications" /></Badge> // a dot
|
|
22
|
+
*/
|
|
23
|
+
export declare function Badge({ count, max, color, className, children, ...props }: BadgeProps): import("react").JSX.Element | null;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Drawer } from '@base-ui/react/drawer';
|
|
2
|
+
import './bottom-sheet.css';
|
|
3
|
+
/**
|
|
4
|
+
* A panel that slides up from the bottom; swipe it down or tap outside to
|
|
5
|
+
* close. Holds the open state (`open` / `defaultOpen` / `onOpenChange`).
|
|
6
|
+
* Pass `snapPoints` (e.g. `[0.5, 1]`) for a sheet that can stop part way.
|
|
7
|
+
*/
|
|
8
|
+
export type BottomSheetProps = Omit<Drawer.Root.Props, 'swipeDirection'>;
|
|
9
|
+
/**
|
|
10
|
+
* A panel that slides up from the bottom. Parts: `BottomSheetTrigger`,
|
|
11
|
+
* `BottomSheetPopup` (includes portal, backdrop and drag handle),
|
|
12
|
+
* `BottomSheetTitle`, `BottomSheetDescription`, `BottomSheetClose`.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* <BottomSheet>
|
|
16
|
+
* <BottomSheetTrigger render={<Button />}>Share</BottomSheetTrigger>
|
|
17
|
+
* <BottomSheetPopup>
|
|
18
|
+
* <BottomSheetTitle>Share</BottomSheetTitle>
|
|
19
|
+
* <List>...</List>
|
|
20
|
+
* </BottomSheetPopup>
|
|
21
|
+
* </BottomSheet>
|
|
22
|
+
*/
|
|
23
|
+
export declare function BottomSheet(props: BottomSheetProps): import("react").JSX.Element;
|
|
24
|
+
export type BottomSheetTriggerProps = Drawer.Trigger.Props;
|
|
25
|
+
/** Opens the sheet. Renders a bare `<button>`; pass `render={<Button />}` to use the library's. */
|
|
26
|
+
export declare function BottomSheetTrigger({ className, ...props }: BottomSheetTriggerProps): import("react").JSX.Element;
|
|
27
|
+
export type BottomSheetPopupProps = Drawer.Popup.Props;
|
|
28
|
+
/**
|
|
29
|
+
* The sheet. Also renders the portal, the dimmed backdrop and the drag
|
|
30
|
+
* handle. Its children scroll when the sheet is taller than the screen allows.
|
|
31
|
+
*/
|
|
32
|
+
export declare function BottomSheetPopup({ className, children, ...props }: BottomSheetPopupProps): import("react").JSX.Element;
|
|
33
|
+
export type BottomSheetTitleProps = Drawer.Title.Props;
|
|
34
|
+
/** Names the sheet for screen readers. Renders an `<h2>`. */
|
|
35
|
+
export declare function BottomSheetTitle({ className, ...props }: BottomSheetTitleProps): import("react").JSX.Element;
|
|
36
|
+
export type BottomSheetDescriptionProps = Drawer.Description.Props;
|
|
37
|
+
/** Supporting text under the title. */
|
|
38
|
+
export declare function BottomSheetDescription({ className, ...props }: BottomSheetDescriptionProps): import("react").JSX.Element;
|
|
39
|
+
export type BottomSheetCloseProps = Drawer.Close.Props;
|
|
40
|
+
/** Closes the sheet. Renders a bare `<button>`; pass `render={<Button />}` to use the library's. */
|
|
41
|
+
export declare function BottomSheetClose({ className, ...props }: BottomSheetCloseProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { ButtonProps as BaseButtonProps } from '@base-ui/react/button';
|
|
2
|
+
import type { MaterialSymbol } from 'material-symbols';
|
|
3
|
+
import { ComponentColor, ComponentFillType } from '../../colors/colors';
|
|
4
|
+
import './button.css';
|
|
5
|
+
export type ButtonProps = BaseButtonProps & {
|
|
6
|
+
/** Height and text size: 32px, 40px or 48px tall. @default 'normal' */
|
|
7
|
+
size?: 'small' | 'normal' | 'big';
|
|
8
|
+
/**
|
|
9
|
+
* How the color is applied: solid, bordered, or text only. This is the
|
|
10
|
+
* prop other libraries call `variant`. @default 'filled'
|
|
11
|
+
*/
|
|
12
|
+
fillType?: ComponentFillType;
|
|
13
|
+
/** Color role from the theme. @default 'primary' */
|
|
14
|
+
color?: ComponentColor;
|
|
15
|
+
/** Material Symbol name shown before the label, e.g. `'add'`. */
|
|
16
|
+
startIcon?: MaterialSymbol;
|
|
17
|
+
/** Material Symbol name shown after the label, e.g. `'arrow_forward'`. */
|
|
18
|
+
endIcon?: MaterialSymbol;
|
|
19
|
+
/**
|
|
20
|
+
* Shows a spinner in place of `startIcon` and ignores clicks. Pass the
|
|
21
|
+
* text to show meanwhile as children (`{saving ? 'Saving' : 'Save'}`);
|
|
22
|
+
* the button animates between the two widths. @default false
|
|
23
|
+
*/
|
|
24
|
+
loading?: boolean;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* A button with a text label and optional icons. Renders a `<button>`; for a
|
|
28
|
+
* link, pass `render={<a href="/x" />}` and `nativeButton={false}`.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* <Button startIcon="add" onClick={create}>New</Button>
|
|
32
|
+
* <Button fillType="outlined" color="error">Delete</Button>
|
|
33
|
+
* <Button loading={saving}>{saving ? 'Saving' : 'Save'}</Button>
|
|
34
|
+
*/
|
|
35
|
+
export declare function Button({ size, fillType, color, startIcon, endIcon, loading, disabled, children, className, ref, ...props }: ButtonProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import './calendar.css';
|
|
2
|
+
export type CalendarProps = Omit<React.ComponentProps<'div'>, 'defaultValue' | 'onChange'> & {
|
|
3
|
+
/** The picked date as `"YYYY-MM-DD"` (like `<input type="date">`), or `null` for none. */
|
|
4
|
+
value?: string | null;
|
|
5
|
+
/** Starting date when `value` isn't controlled. @default null */
|
|
6
|
+
defaultValue?: string | null;
|
|
7
|
+
/** Called with the picked `"YYYY-MM-DD"`. */
|
|
8
|
+
onValueChange?: (value: string) => void;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* A month grid to pick a date from. Arrow keys move by day and week, Page
|
|
12
|
+
* Up/Down by month (with Shift, by year), Home/End to the ends of the week.
|
|
13
|
+
* The first weekday and all names follow the user's locale. Values are
|
|
14
|
+
* `"YYYY-MM-DD"` strings, not `Date` objects.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* <Calendar value={date} onValueChange={setDate} />
|
|
18
|
+
*/
|
|
19
|
+
export declare function Calendar({ value: valueProp, defaultValue, onValueChange, className, ...props }: CalendarProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { ButtonProps as BaseButtonProps } from '@base-ui/react/button';
|
|
2
|
+
import { ComponentColor, ComponentFillType } from '../../colors/colors';
|
|
3
|
+
import { TypographyProps } from '../Typography/Typography';
|
|
4
|
+
import './card.css';
|
|
5
|
+
type CardStyleProps = {
|
|
6
|
+
/** How the color is applied. @default 'filled' */
|
|
7
|
+
fillType?: ComponentFillType;
|
|
8
|
+
/**
|
|
9
|
+
* Color role from the theme. Neutral by default, so primary buttons
|
|
10
|
+
* inside still stand out. @default 'container'
|
|
11
|
+
*/
|
|
12
|
+
color?: ComponentColor;
|
|
13
|
+
};
|
|
14
|
+
export type CardProps = (Omit<React.ComponentProps<'div'>, 'color'> & CardStyleProps & {
|
|
15
|
+
/**
|
|
16
|
+
* Make the whole card one button (or a link, with
|
|
17
|
+
* `render={<a href="..." />}`). Buttons and links inside still
|
|
18
|
+
* work on their own. @default false
|
|
19
|
+
*/
|
|
20
|
+
clickable?: false;
|
|
21
|
+
}) | (Omit<BaseButtonProps, 'color'> & CardStyleProps & {
|
|
22
|
+
/**
|
|
23
|
+
* Make the whole card one button (or a link, with
|
|
24
|
+
* `render={<a href="..." />}`). Buttons and links inside still
|
|
25
|
+
* work on their own. @default false
|
|
26
|
+
*/
|
|
27
|
+
clickable: true;
|
|
28
|
+
});
|
|
29
|
+
/**
|
|
30
|
+
* A rounded surface that groups related content. Compose it from
|
|
31
|
+
* `CardTitle`, `CardContent` and `CardActions` (there is no CardHeader or
|
|
32
|
+
* CardFooter). Neutral `container` color by default.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* <Card>
|
|
36
|
+
* <CardTitle as="h2">Storage</CardTitle>
|
|
37
|
+
* <CardContent>You've used 80% of your space.</CardContent>
|
|
38
|
+
* <CardActions>
|
|
39
|
+
* <Button fillType="text">Dismiss</Button>
|
|
40
|
+
* <Button>Upgrade</Button>
|
|
41
|
+
* </CardActions>
|
|
42
|
+
* </Card>
|
|
43
|
+
*/
|
|
44
|
+
export declare function Card(props: CardProps): import("react").JSX.Element;
|
|
45
|
+
export type CardTitleProps = TypographyProps;
|
|
46
|
+
/**
|
|
47
|
+
* The card's title. Looks like an h6 but renders a `<div>`: pass `as="h2"`
|
|
48
|
+
* (or the level that fits the page) to make it a heading.
|
|
49
|
+
*/
|
|
50
|
+
export declare function CardTitle({ type, as, className, ...props }: CardTitleProps): import("react").JSX.Element;
|
|
51
|
+
export type CardContentProps = React.ComponentProps<'div'>;
|
|
52
|
+
/** The card's body, with padding. */
|
|
53
|
+
export declare function CardContent({ className, ...props }: CardContentProps): import("react").JSX.Element;
|
|
54
|
+
export type CardActionsProps = React.ComponentProps<'div'>;
|
|
55
|
+
/** A row of buttons at the bottom of the card, aligned to the end. */
|
|
56
|
+
export declare function CardActions({ className, ...props }: CardActionsProps): import("react").JSX.Element;
|
|
57
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import './carousel.css';
|
|
2
|
+
export type CarouselProps = React.ComponentProps<'div'> & {
|
|
3
|
+
/** What the carousel shows, for screen readers ("Featured albums"). */
|
|
4
|
+
'aria-label': string;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* A horizontally scrolling row of `CarouselItem`s.
|
|
8
|
+
* Items running off an edge are masked with rounded corners instead of being
|
|
9
|
+
* cut off flat, and their content slides to stay centered in what's visible
|
|
10
|
+
* (in browsers with scroll-driven animations; Firefox cuts them off flat).
|
|
11
|
+
* With a mouse, it can be dragged and thrown like on a touch screen.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* <Carousel aria-label="Featured albums">
|
|
15
|
+
* {albums.map((a) => <CarouselItem key={a.id}><img src={a.cover} alt={a.title} /></CarouselItem>)}
|
|
16
|
+
* </Carousel>
|
|
17
|
+
*/
|
|
18
|
+
export declare function Carousel({ className, ref, children, ...props }: CarouselProps): import("react").JSX.Element;
|
|
19
|
+
export type CarouselItemProps = React.ComponentProps<'div'>;
|
|
20
|
+
/** One item in a `Carousel`. Set its width with CSS; 240px by default. */
|
|
21
|
+
export declare function CarouselItem({ className, children, ...props }: CarouselItemProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Checkbox as BaseCheckbox } from '@base-ui/react/checkbox';
|
|
2
|
+
import './checkbox.css';
|
|
3
|
+
export type CheckboxProps = BaseCheckbox.Root.Props;
|
|
4
|
+
/**
|
|
5
|
+
* A checkbox. State: `checked` / `defaultChecked` / `onCheckedChange`, plus
|
|
6
|
+
* `indeterminate`. It has no `label` prop: wrap it in a `<label>` with the text.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* <label style={{ display: 'flex', gap: 8, alignItems: 'center' }}>
|
|
10
|
+
* <Checkbox checked={agreed} onCheckedChange={setAgreed} />
|
|
11
|
+
* I agree to the terms
|
|
12
|
+
* </label>
|
|
13
|
+
*/
|
|
14
|
+
export declare function Checkbox({ className, ...props }: CheckboxProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { type ComponentProps } from 'react';
|
|
2
|
+
import { type ButtonProps as BaseButtonProps } from '@base-ui/react/button';
|
|
3
|
+
import { Toggle } from '@base-ui/react/toggle';
|
|
4
|
+
import type { MaterialSymbol } from 'material-symbols';
|
|
5
|
+
import './chip.css';
|
|
6
|
+
export type ChipProps = BaseButtonProps & {
|
|
7
|
+
/** Material Symbol before the label. */
|
|
8
|
+
startIcon?: MaterialSymbol;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* A compact button for suggestions and quick actions. For on/off filters
|
|
12
|
+
* use `FilterChip`; for removable values (tags) use `InputChip`.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* <Chip startIcon="event" onClick={addToCalendar}>Add to calendar</Chip>
|
|
16
|
+
*/
|
|
17
|
+
export declare function Chip({ startIcon, className, children, ...props }: ChipProps): import("react").JSX.Element;
|
|
18
|
+
export type FilterChipProps = Toggle.Props;
|
|
19
|
+
/**
|
|
20
|
+
* A chip that toggles on and off, showing a checkmark while on. State:
|
|
21
|
+
* `pressed` / `defaultPressed` / `onPressedChange`.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* <FilterChip pressed={vegan} onPressedChange={setVegan}>Vegan</FilterChip>
|
|
25
|
+
*/
|
|
26
|
+
export declare function FilterChip({ className, children, ...props }: FilterChipProps): import("react").JSX.Element;
|
|
27
|
+
export type InputChipProps = ComponentProps<'span'> & {
|
|
28
|
+
/** Called when the remove (×) button is clicked. */
|
|
29
|
+
onRemove: () => void;
|
|
30
|
+
/** Accessible name of the remove button, e.g. "Remove Alice". @default 'Remove' */
|
|
31
|
+
removeLabel?: string;
|
|
32
|
+
/** Material Symbol before the label. */
|
|
33
|
+
startIcon?: MaterialSymbol;
|
|
34
|
+
/** Disables the remove button and dims the chip. */
|
|
35
|
+
disabled?: boolean;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* A removable value, like a tag or recipient. Plays an exit animation, then
|
|
39
|
+
* calls `onRemove`: remove it from your list there.
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* {tags.map((t) => (
|
|
43
|
+
* <InputChip key={t} removeLabel={`Remove ${t}`} onRemove={() => setTags(tags.filter((x) => x !== t))}>{t}</InputChip>
|
|
44
|
+
* ))}
|
|
45
|
+
*/
|
|
46
|
+
export declare function InputChip({ onRemove, removeLabel, startIcon, disabled, className, ref, children, ...props }: InputChipProps): import("react").JSX.Element;
|