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/docs/menubar.md
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Menubar
|
|
2
|
+
|
|
3
|
+
A row of menus, like File / Edit / View. Put one `Menu` per entry inside.
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import { Menubar, Menu, MenuTrigger, MenuPopup, MenuItem } from 'anvilui'
|
|
7
|
+
import type { MenubarProps } from 'anvilui' // Base UI Menubar props
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
```tsx
|
|
11
|
+
import { Menu, Menubar, MenuItem, MenuPopup, MenuTrigger } from 'anvilui'
|
|
12
|
+
|
|
13
|
+
export function Example() {
|
|
14
|
+
return (
|
|
15
|
+
<Menubar>
|
|
16
|
+
<Menu>
|
|
17
|
+
<MenuTrigger>File</MenuTrigger>
|
|
18
|
+
<MenuPopup>
|
|
19
|
+
<MenuItem>New</MenuItem>
|
|
20
|
+
<MenuItem>Save</MenuItem>
|
|
21
|
+
</MenuPopup>
|
|
22
|
+
</Menu>
|
|
23
|
+
<Menu>
|
|
24
|
+
<MenuTrigger>Edit</MenuTrigger>
|
|
25
|
+
<MenuPopup>
|
|
26
|
+
<MenuItem>Undo</MenuItem>
|
|
27
|
+
</MenuPopup>
|
|
28
|
+
</Menu>
|
|
29
|
+
</Menubar>
|
|
30
|
+
)
|
|
31
|
+
}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Inside a Menubar, plain `MenuTrigger`s are styled as menubar entries; don't pass `render={<Button />}`.
|
package/docs/morph.md
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# morph and morphBetween
|
|
2
|
+
|
|
3
|
+
Animate one element growing into another while the view changes (Material's container transform), using View Transitions.
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import { morph, morphBetween } from 'anvilui'
|
|
7
|
+
import type { MorphOptions } from 'anvilui'
|
|
8
|
+
|
|
9
|
+
morph(id: string, update: () => void, options?: MorphOptions): Promise<void>
|
|
10
|
+
morphBetween(from: HTMLElement, update: () => void, getTo: () => HTMLElement | null, options?: MorphOptions): Promise<void>
|
|
11
|
+
type MorphOptions = { duration?: number /* ms */; easing?: string }
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
```tsx
|
|
15
|
+
import { useState } from 'react'
|
|
16
|
+
import { Button, Card, CardTitle, morph } from 'anvilui'
|
|
17
|
+
|
|
18
|
+
const albums = [
|
|
19
|
+
{ id: 'a1', title: 'Blue' },
|
|
20
|
+
{ id: 'a2', title: 'Red' },
|
|
21
|
+
]
|
|
22
|
+
|
|
23
|
+
export function Albums() {
|
|
24
|
+
const [open, setOpen] = useState<string | null>(null)
|
|
25
|
+
|
|
26
|
+
if (open) {
|
|
27
|
+
return (
|
|
28
|
+
<Card data-morph-id={open} style={{ minHeight: 300 }}>
|
|
29
|
+
<Button onClick={() => morph(open, () => setOpen(null))}>
|
|
30
|
+
Back
|
|
31
|
+
</Button>
|
|
32
|
+
</Card>
|
|
33
|
+
)
|
|
34
|
+
}
|
|
35
|
+
return albums.map((a) => (
|
|
36
|
+
<Card
|
|
37
|
+
key={a.id}
|
|
38
|
+
clickable
|
|
39
|
+
data-morph-id={a.id}
|
|
40
|
+
onClick={() => morph(a.id, () => setOpen(a.id))}
|
|
41
|
+
>
|
|
42
|
+
<CardTitle>{a.title}</CardTitle>
|
|
43
|
+
</Card>
|
|
44
|
+
))
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
- Give both elements the same `data-morph-id`.
|
|
49
|
+
- `update` must change the view **synchronously** (set state, or `navigate(to, { flushSync: true })` in React Router).
|
|
50
|
+
- Without View Transitions support, or with reduced motion, `update` just runs.
|
|
51
|
+
- `Dialog` and `Popover` take `morph` (boolean) to do this between their trigger and popup.
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# NavigationBar
|
|
2
|
+
|
|
3
|
+
Bottom navigation for small screens: 3–5 top-level destinations. You position it (e.g. `position: sticky; bottom: 0`).
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import { NavigationBar, NavigationBarItem } from 'anvilui'
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
| Part | Renders | Props |
|
|
10
|
+
| --- | --- | --- |
|
|
11
|
+
| `NavigationBar` | `<nav>` | Give it `aria-label`. |
|
|
12
|
+
| `NavigationBarItem` | `<a>` | `icon: MaterialSymbol` (required), `label: string` (required), `active?: boolean` (sets `aria-current="page"`), `href`, `render` (router link) |
|
|
13
|
+
|
|
14
|
+
Items are links, not tabs: there's no `value` / `onValueChange`. Mark the current one with `active`.
|
|
15
|
+
|
|
16
|
+
```tsx
|
|
17
|
+
import { NavigationBar, NavigationBarItem } from 'anvilui'
|
|
18
|
+
|
|
19
|
+
export function Example({ path }: { path: string }) {
|
|
20
|
+
return (
|
|
21
|
+
<NavigationBar
|
|
22
|
+
aria-label="Main"
|
|
23
|
+
style={{ position: 'sticky', bottom: 0 }}
|
|
24
|
+
>
|
|
25
|
+
<NavigationBarItem
|
|
26
|
+
icon="home"
|
|
27
|
+
label="Home"
|
|
28
|
+
href="/"
|
|
29
|
+
active={path === '/'}
|
|
30
|
+
/>
|
|
31
|
+
<NavigationBarItem
|
|
32
|
+
icon="search"
|
|
33
|
+
label="Search"
|
|
34
|
+
href="/search"
|
|
35
|
+
active={path === '/search'}
|
|
36
|
+
/>
|
|
37
|
+
<NavigationBarItem
|
|
38
|
+
icon="person"
|
|
39
|
+
label="Profile"
|
|
40
|
+
href="/profile"
|
|
41
|
+
active={path === '/profile'}
|
|
42
|
+
/>
|
|
43
|
+
</NavigationBar>
|
|
44
|
+
)
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
With React Router: `<NavigationBarItem icon="home" label="Home" render={<Link to="/" />} active={...} />`. For client-side state instead of URLs, use `render={<button type="button" onClick={...} />}`.
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# NavigationDrawer
|
|
2
|
+
|
|
3
|
+
Side navigation that slides in over the page, for small screens.
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import {
|
|
7
|
+
NavigationDrawer,
|
|
8
|
+
NavigationDrawerTrigger,
|
|
9
|
+
NavigationDrawerPopup,
|
|
10
|
+
NavigationDrawerTitle,
|
|
11
|
+
NavigationDrawerItem,
|
|
12
|
+
} from 'anvilui'
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
| Part | Renders | Props |
|
|
16
|
+
| --- | --- | --- |
|
|
17
|
+
| `NavigationDrawer` | nothing (state) | `open` / `defaultOpen` / `onOpenChange` |
|
|
18
|
+
| `NavigationDrawerTrigger` | bare `<button>` | `render={<IconButton icon="menu" aria-label="Open navigation" />}` |
|
|
19
|
+
| `NavigationDrawerPopup` | portal + backdrop + panel | Put the title first, then items. |
|
|
20
|
+
| `NavigationDrawerTitle` | `<h2>` | Names the drawer. |
|
|
21
|
+
| `NavigationDrawerItem` | `<a>` that closes the drawer | `icon` (required), `label: string` (required), `active`, `end: ReactNode` (e.g. a count), `href`, `render` |
|
|
22
|
+
|
|
23
|
+
For in-page switching: `render={<button type="button" onClick={() => setView('trash')} />}`; it still closes the drawer.
|
|
24
|
+
|
|
25
|
+
```tsx
|
|
26
|
+
import {
|
|
27
|
+
AppBar,
|
|
28
|
+
IconButton,
|
|
29
|
+
NavigationDrawer,
|
|
30
|
+
NavigationDrawerItem,
|
|
31
|
+
NavigationDrawerPopup,
|
|
32
|
+
NavigationDrawerTitle,
|
|
33
|
+
NavigationDrawerTrigger,
|
|
34
|
+
} from 'anvilui'
|
|
35
|
+
|
|
36
|
+
export function Example() {
|
|
37
|
+
return (
|
|
38
|
+
<AppBar
|
|
39
|
+
label="Mail"
|
|
40
|
+
start={
|
|
41
|
+
<NavigationDrawer>
|
|
42
|
+
<NavigationDrawerTrigger
|
|
43
|
+
render={
|
|
44
|
+
<IconButton
|
|
45
|
+
icon="menu"
|
|
46
|
+
aria-label="Open navigation"
|
|
47
|
+
fillType="text"
|
|
48
|
+
color="container"
|
|
49
|
+
/>
|
|
50
|
+
}
|
|
51
|
+
/>
|
|
52
|
+
<NavigationDrawerPopup>
|
|
53
|
+
<NavigationDrawerTitle>Mail</NavigationDrawerTitle>
|
|
54
|
+
<NavigationDrawerItem
|
|
55
|
+
icon="inbox"
|
|
56
|
+
label="Inbox"
|
|
57
|
+
href="/inbox"
|
|
58
|
+
active
|
|
59
|
+
end="12"
|
|
60
|
+
/>
|
|
61
|
+
<NavigationDrawerItem
|
|
62
|
+
icon="send"
|
|
63
|
+
label="Sent"
|
|
64
|
+
href="/sent"
|
|
65
|
+
/>
|
|
66
|
+
</NavigationDrawerPopup>
|
|
67
|
+
</NavigationDrawer>
|
|
68
|
+
}
|
|
69
|
+
/>
|
|
70
|
+
)
|
|
71
|
+
}
|
|
72
|
+
```
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# NavigationList
|
|
2
|
+
|
|
3
|
+
A column of text-only navigation links, like a docs or settings sidebar.
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import { NavigationList, NavigationListItem } from 'anvilui'
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
| Part | Renders | Props |
|
|
10
|
+
| --- | --- | --- |
|
|
11
|
+
| `NavigationList` | `<nav>` | `aria-label` |
|
|
12
|
+
| `NavigationListItem` | `<a>` | `label: string` (required; not children), `active`, `href`, `render` |
|
|
13
|
+
|
|
14
|
+
```tsx
|
|
15
|
+
import { NavigationList, NavigationListItem } from 'anvilui'
|
|
16
|
+
|
|
17
|
+
export function SettingsNav({ section }: { section: string }) {
|
|
18
|
+
return (
|
|
19
|
+
<NavigationList aria-label="Settings">
|
|
20
|
+
<NavigationListItem
|
|
21
|
+
label="Profile"
|
|
22
|
+
href="#profile"
|
|
23
|
+
active={section === 'profile'}
|
|
24
|
+
/>
|
|
25
|
+
<NavigationListItem
|
|
26
|
+
label="Notifications"
|
|
27
|
+
href="#notifications"
|
|
28
|
+
active={section === 'notifications'}
|
|
29
|
+
/>
|
|
30
|
+
<NavigationListItem
|
|
31
|
+
label="Billing"
|
|
32
|
+
href="#billing"
|
|
33
|
+
active={section === 'billing'}
|
|
34
|
+
/>
|
|
35
|
+
</NavigationList>
|
|
36
|
+
)
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
For in-page switching without URLs: `render={<button type="button" onClick={() => setSection('billing')} />}`.
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# NavigationRail
|
|
2
|
+
|
|
3
|
+
Side navigation for medium and large screens. Collapsed: icons with small labels; expanded: labels beside icons.
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import {
|
|
7
|
+
NavigationRail,
|
|
8
|
+
NavigationRailToggle,
|
|
9
|
+
NavigationRailItem,
|
|
10
|
+
} from 'anvilui'
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
| Part | Renders | Props |
|
|
14
|
+
| --- | --- | --- |
|
|
15
|
+
| `NavigationRail` | `<nav>` (96px wide, `height: 100%`) | `aria-label`; `expanded` / `defaultExpanded` (false) / `onExpandedChange(expanded)` |
|
|
16
|
+
| `NavigationRailToggle` | `IconButton` (menu icon) | `aria-label` required. Must be inside the rail. |
|
|
17
|
+
| `NavigationRailItem` | `<a>` | `icon` (required), `label: string` (required), `active`, `end` (short badge text, e.g. a count), `href`, `render` |
|
|
18
|
+
|
|
19
|
+
```tsx
|
|
20
|
+
import {
|
|
21
|
+
NavigationRail,
|
|
22
|
+
NavigationRailItem,
|
|
23
|
+
NavigationRailToggle,
|
|
24
|
+
} from 'anvilui'
|
|
25
|
+
|
|
26
|
+
export function Layout({ children }: { children: React.ReactNode }) {
|
|
27
|
+
return (
|
|
28
|
+
<div style={{ display: 'flex', height: '100vh' }}>
|
|
29
|
+
<NavigationRail aria-label="Main">
|
|
30
|
+
<NavigationRailToggle aria-label="Toggle navigation" />
|
|
31
|
+
<NavigationRailItem
|
|
32
|
+
icon="inbox"
|
|
33
|
+
label="Inbox"
|
|
34
|
+
href="/inbox"
|
|
35
|
+
active
|
|
36
|
+
end="12"
|
|
37
|
+
/>
|
|
38
|
+
<NavigationRailItem icon="send" label="Sent" href="/sent" />
|
|
39
|
+
<NavigationRailItem
|
|
40
|
+
icon="settings"
|
|
41
|
+
label="Settings"
|
|
42
|
+
href="/settings"
|
|
43
|
+
/>
|
|
44
|
+
</NavigationRail>
|
|
45
|
+
<main style={{ flex: 1, overflow: 'auto' }}>{children}</main>
|
|
46
|
+
</div>
|
|
47
|
+
)
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
In-page switching without URLs: `render={<button type="button" onClick={() => setView('inbox')} />}` with `active={view === 'inbox'}`. No `nativeButton` needed.
|
|
52
|
+
|
|
53
|
+
On small screens use [NavigationDrawer](navigation-drawer.md) or [NavigationBar](navigation-bar.md) instead.
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# PinInput
|
|
2
|
+
|
|
3
|
+
One box per character, for verification codes and PINs. `length` is required.
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import { PinInput } from 'anvilui'
|
|
7
|
+
import type { PinInputProps } from 'anvilui'
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
| Prop | Type | Default | Description |
|
|
11
|
+
| --- | --- | --- | --- |
|
|
12
|
+
| `length` | `number` | required | Number of boxes. |
|
|
13
|
+
| `label` | `ReactNode` | | Either this or `aria-label`. |
|
|
14
|
+
| `value` / `defaultValue` | `string` | | |
|
|
15
|
+
| `onValueChange` | `(value: string, details) => void` | | |
|
|
16
|
+
| `onValueComplete` | `(value: string, details) => void` | | When every box is filled. |
|
|
17
|
+
| `validationType` | `'numeric' \| 'alpha' \| 'alphanumeric' \| 'none'` | `'numeric'` | |
|
|
18
|
+
| `mask` | `boolean` | `false` | Hide characters. |
|
|
19
|
+
| `fillType` | `'filled' \| 'outlined'` | `'outlined'` | |
|
|
20
|
+
| `size` | `'small' \| 'normal'` | `'normal'` | |
|
|
21
|
+
| `name`, `disabled`, `required`, `autoSubmit` | | | |
|
|
22
|
+
| `className` | `string` | | On the wrapper. |
|
|
23
|
+
|
|
24
|
+
```tsx
|
|
25
|
+
import { PinInput } from 'anvilui'
|
|
26
|
+
|
|
27
|
+
export function Example() {
|
|
28
|
+
return (
|
|
29
|
+
<PinInput
|
|
30
|
+
label="Verification code"
|
|
31
|
+
length={6}
|
|
32
|
+
onValueComplete={(code) => console.log(code)}
|
|
33
|
+
/>
|
|
34
|
+
)
|
|
35
|
+
}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Base UI docs: `node_modules/@base-ui/react/docs/react/components/otp-field.md`.
|
package/docs/popover.md
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# Popover
|
|
2
|
+
|
|
3
|
+
A floating panel anchored to its trigger, for content users interact with.
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import {
|
|
7
|
+
Popover,
|
|
8
|
+
PopoverTrigger,
|
|
9
|
+
PopoverPopup,
|
|
10
|
+
PopoverTitle,
|
|
11
|
+
PopoverDescription,
|
|
12
|
+
PopoverClose,
|
|
13
|
+
} from 'anvilui'
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
| Part | Renders | Props |
|
|
17
|
+
| --- | --- | --- |
|
|
18
|
+
| `Popover` | nothing (state) | `open` / `defaultOpen` / `onOpenChange`, `modal`, `morph` |
|
|
19
|
+
| `PopoverTrigger` | bare `<button>` | `render={<Button />}`; `openOnHover`, `delay` |
|
|
20
|
+
| `PopoverPopup` | portal + positioner + panel | `side` (`'top' \| 'bottom' \| 'left' \| 'right' \| 'inline-start' \| 'inline-end'`, default `'bottom'`), `align` (`'start' \| 'center' \| 'end'`), `sideOffset` (4), `alignOffset`, `anchor` |
|
|
21
|
+
| `PopoverTitle` | `<h2>` | `render={<h3 />}` to change level |
|
|
22
|
+
| `PopoverDescription` | `<p>` | |
|
|
23
|
+
| `PopoverClose` | bare `<button>` | `render={<IconButton icon="close" aria-label="Close" />}` |
|
|
24
|
+
|
|
25
|
+
There is no `PopoverContent`; `side` / `align` go on `PopoverPopup`.
|
|
26
|
+
|
|
27
|
+
```tsx
|
|
28
|
+
import {
|
|
29
|
+
Button,
|
|
30
|
+
IconButton,
|
|
31
|
+
Input,
|
|
32
|
+
Popover,
|
|
33
|
+
PopoverClose,
|
|
34
|
+
PopoverPopup,
|
|
35
|
+
PopoverTitle,
|
|
36
|
+
PopoverTrigger,
|
|
37
|
+
} from 'anvilui'
|
|
38
|
+
|
|
39
|
+
export function Example() {
|
|
40
|
+
return (
|
|
41
|
+
<Popover>
|
|
42
|
+
<PopoverTrigger
|
|
43
|
+
render={<Button fillType="outlined" startIcon="filter_list" />}
|
|
44
|
+
>
|
|
45
|
+
Filters
|
|
46
|
+
</PopoverTrigger>
|
|
47
|
+
<PopoverPopup
|
|
48
|
+
side="bottom"
|
|
49
|
+
align="start"
|
|
50
|
+
style={{ display: 'grid', gap: 12, width: 280 }}
|
|
51
|
+
>
|
|
52
|
+
<div
|
|
53
|
+
style={{
|
|
54
|
+
display: 'flex',
|
|
55
|
+
justifyContent: 'space-between',
|
|
56
|
+
alignItems: 'center',
|
|
57
|
+
}}
|
|
58
|
+
>
|
|
59
|
+
<PopoverTitle>Filters</PopoverTitle>
|
|
60
|
+
<PopoverClose
|
|
61
|
+
render={
|
|
62
|
+
<IconButton
|
|
63
|
+
icon="close"
|
|
64
|
+
aria-label="Close"
|
|
65
|
+
fillType="text"
|
|
66
|
+
color="container"
|
|
67
|
+
/>
|
|
68
|
+
}
|
|
69
|
+
/>
|
|
70
|
+
</div>
|
|
71
|
+
<Input label="Min price" type="number" />
|
|
72
|
+
</PopoverPopup>
|
|
73
|
+
</Popover>
|
|
74
|
+
)
|
|
75
|
+
}
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
For a hint on hover use [Tooltip](tooltip.md); for a hover preview of a link, [PreviewCard](preview-card.md).
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# PreviewCard
|
|
2
|
+
|
|
3
|
+
A card shown while hovering or focusing a link. Hover-only: nothing inside should need clicking (use [Popover](popover.md) for that).
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import { PreviewCard, PreviewCardTrigger, PreviewCardPopup } from 'anvilui'
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
| Part | Renders | Props |
|
|
10
|
+
| --- | --- | --- |
|
|
11
|
+
| `PreviewCard` | nothing (state) | `open` / `defaultOpen` / `onOpenChange` |
|
|
12
|
+
| `PreviewCardTrigger` | `<a>` | `href`, `delay`, `closeDelay`; `render={<Link to="..." />}` for routers |
|
|
13
|
+
| `PreviewCardPopup` | portal + positioner + card | `side`, `align`, `sideOffset` (8), `alignOffset` |
|
|
14
|
+
|
|
15
|
+
```tsx
|
|
16
|
+
import {
|
|
17
|
+
Avatar,
|
|
18
|
+
PreviewCard,
|
|
19
|
+
PreviewCardPopup,
|
|
20
|
+
PreviewCardTrigger,
|
|
21
|
+
Typography,
|
|
22
|
+
} from 'anvilui'
|
|
23
|
+
|
|
24
|
+
export function Example() {
|
|
25
|
+
return (
|
|
26
|
+
<Typography>
|
|
27
|
+
Written by{' '}
|
|
28
|
+
<PreviewCard>
|
|
29
|
+
<PreviewCardTrigger href="/users/ada">@ada</PreviewCardTrigger>
|
|
30
|
+
<PreviewCardPopup
|
|
31
|
+
style={{ display: 'flex', gap: 12, alignItems: 'center' }}
|
|
32
|
+
>
|
|
33
|
+
<Avatar name="Ada Lovelace" />
|
|
34
|
+
<span>Ada Lovelace · 12 posts</span>
|
|
35
|
+
</PreviewCardPopup>
|
|
36
|
+
</PreviewCard>
|
|
37
|
+
</Typography>
|
|
38
|
+
)
|
|
39
|
+
}
|
|
40
|
+
```
|
package/docs/progress.md
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Progress
|
|
2
|
+
|
|
3
|
+
A bar or ring showing progress. Needs `label` or `aria-label`.
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import { Progress } from 'anvilui'
|
|
7
|
+
import type { ProgressProps } from 'anvilui'
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
| Prop | Type | Default | Description |
|
|
11
|
+
| --- | --- | --- | --- |
|
|
12
|
+
| `value` | `number \| null` | | `null` = indeterminate (spinning / sweeping). Required by Base UI: pass `null` explicitly for loading. |
|
|
13
|
+
| `min` / `max` | `number` | `0` / `100` | |
|
|
14
|
+
| `type` | `'linear' \| 'circular' \| 'inline'` | `'linear'` | `inline` is a ring the size of the text. |
|
|
15
|
+
| `squiggly` | `boolean` | `false` | Wavy bar (linear only). |
|
|
16
|
+
| `label` | `ReactNode` | | Visible label. Either this or `aria-label`. |
|
|
17
|
+
| `aria-label` | `string` | | |
|
|
18
|
+
|
|
19
|
+
There is no `Spinner` / `CircularProgress` / `LinearProgress`: use `<Progress type="circular" value={null} aria-label="Loading" />`. For a loading button, use `<Button loading>`.
|
|
20
|
+
|
|
21
|
+
```tsx
|
|
22
|
+
import { Progress } from 'anvilui'
|
|
23
|
+
|
|
24
|
+
export function Example({ uploaded }: { uploaded: number }) {
|
|
25
|
+
return (
|
|
26
|
+
<div style={{ display: 'grid', gap: 16, width: 300 }}>
|
|
27
|
+
<Progress label="Uploading" value={uploaded} />
|
|
28
|
+
<Progress aria-label="Loading" value={null} squiggly />
|
|
29
|
+
<Progress type="circular" aria-label="Loading" value={null} />
|
|
30
|
+
<span>
|
|
31
|
+
Syncing{' '}
|
|
32
|
+
<Progress type="inline" aria-label="Syncing" value={null} />
|
|
33
|
+
</span>
|
|
34
|
+
</div>
|
|
35
|
+
)
|
|
36
|
+
}
|
|
37
|
+
```
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# RadioGroup, Radio
|
|
2
|
+
|
|
3
|
+
Pick exactly one option. State lives on the group; each `Radio` has a `value`. **`Radio` has no `label` prop**: wrap it in a `<label>`.
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import { RadioGroup, Radio } from 'anvilui'
|
|
7
|
+
import type { RadioGroupProps, RadioProps } from 'anvilui'
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
## RadioGroup props (Base UI RadioGroup)
|
|
11
|
+
|
|
12
|
+
| Prop | Type | Description |
|
|
13
|
+
| --- | --- | --- |
|
|
14
|
+
| `value` / `defaultValue` | `Value` | The picked radio's value. |
|
|
15
|
+
| `onValueChange` | `(value: Value, details) => void` | |
|
|
16
|
+
| `name`, `required`, `disabled`, `readOnly` | | |
|
|
17
|
+
| `aria-label` / `aria-labelledby` | `string` | Name the group. |
|
|
18
|
+
|
|
19
|
+
## Radio props (Base UI Radio.Root)
|
|
20
|
+
|
|
21
|
+
`value: Value` (required), `disabled?: boolean`.
|
|
22
|
+
|
|
23
|
+
```tsx
|
|
24
|
+
import { useState } from 'react'
|
|
25
|
+
import { Radio, RadioGroup } from 'anvilui'
|
|
26
|
+
|
|
27
|
+
export function Example() {
|
|
28
|
+
const [plan, setPlan] = useState('free')
|
|
29
|
+
return (
|
|
30
|
+
<RadioGroup
|
|
31
|
+
aria-label="Plan"
|
|
32
|
+
value={plan}
|
|
33
|
+
onValueChange={setPlan}
|
|
34
|
+
style={{ display: 'grid', gap: 8 }}
|
|
35
|
+
>
|
|
36
|
+
<label style={{ display: 'flex', gap: 8, alignItems: 'center' }}>
|
|
37
|
+
<Radio value="free" /> Free
|
|
38
|
+
</label>
|
|
39
|
+
<label style={{ display: 'flex', gap: 8, alignItems: 'center' }}>
|
|
40
|
+
<Radio value="pro" /> Pro
|
|
41
|
+
</label>
|
|
42
|
+
</RadioGroup>
|
|
43
|
+
)
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
For a compact row of 2–5 options, [ToggleGroup](toggle-group.md) looks better.
|
package/docs/search.md
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# Search, SearchItem
|
|
2
|
+
|
|
3
|
+
A Material 3 search bar with a suggestion list. `aria-label` is required. **Children are a render function** over `items`. The value is the typed text.
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import { Search, SearchItem } from 'anvilui'
|
|
7
|
+
import type { SearchProps, SearchItemProps } from 'anvilui'
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
## Search props
|
|
11
|
+
|
|
12
|
+
| Prop | Type | Default | Description |
|
|
13
|
+
| --- | --- | --- | --- |
|
|
14
|
+
| `aria-label` | `string` | required | |
|
|
15
|
+
| `children` | `(item: Item, index: number) => ReactNode` | required | Renders one `SearchItem`. |
|
|
16
|
+
| `items` | `readonly Item[]` | | Suggestions, filtered as you type. Pass `[]` for none. |
|
|
17
|
+
| `value` / `defaultValue` | `string` | | The typed text. |
|
|
18
|
+
| `onValueChange` | `(text: string, details) => void` | | |
|
|
19
|
+
| `placeholder` | `string` | | |
|
|
20
|
+
| `empty` | `ReactNode` | | Shown when nothing matches. |
|
|
21
|
+
| `clearLabel` | `string` | `'Clear'` | Name of the clear button. |
|
|
22
|
+
| `className` | `string` | | On the bar. |
|
|
23
|
+
| `itemToStringValue`, `filter`, `limit`, `openOnInputClick` | | | Base UI Autocomplete.Root props. |
|
|
24
|
+
|
|
25
|
+
## SearchItem props
|
|
26
|
+
|
|
27
|
+
`value: Item` (required), `startIcon?: MaterialSymbol`, `children`.
|
|
28
|
+
|
|
29
|
+
```tsx
|
|
30
|
+
import { useState } from 'react'
|
|
31
|
+
import { Search, SearchItem } from 'anvilui'
|
|
32
|
+
|
|
33
|
+
const recent = ['invoices', 'travel', 'receipts']
|
|
34
|
+
|
|
35
|
+
export function Example() {
|
|
36
|
+
const [query, setQuery] = useState('')
|
|
37
|
+
return (
|
|
38
|
+
<Search
|
|
39
|
+
aria-label="Search mail"
|
|
40
|
+
placeholder="Search mail"
|
|
41
|
+
items={recent}
|
|
42
|
+
value={query}
|
|
43
|
+
onValueChange={setQuery}
|
|
44
|
+
>
|
|
45
|
+
{(item: string) => (
|
|
46
|
+
<SearchItem key={item} value={item} startIcon="history">
|
|
47
|
+
{item}
|
|
48
|
+
</SearchItem>
|
|
49
|
+
)}
|
|
50
|
+
</Search>
|
|
51
|
+
)
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
To filter a page's own content with no suggestion list, pass `items={[]}` and a render function that returns `null`, then filter your data with the typed text:
|
|
56
|
+
|
|
57
|
+
```tsx
|
|
58
|
+
import { useState } from 'react'
|
|
59
|
+
import { List, ListItem, Search } from 'anvilui'
|
|
60
|
+
|
|
61
|
+
const people = ['Ada Lovelace', 'Alan Turing', 'Grace Hopper']
|
|
62
|
+
|
|
63
|
+
export function FilterExample() {
|
|
64
|
+
const [query, setQuery] = useState('')
|
|
65
|
+
const shown = people.filter((p) => p.toLowerCase().includes(query.toLowerCase()))
|
|
66
|
+
return (
|
|
67
|
+
<>
|
|
68
|
+
<Search aria-label="Filter people" placeholder="Filter people" items={[]} value={query} onValueChange={setQuery}>
|
|
69
|
+
{() => null}
|
|
70
|
+
</Search>
|
|
71
|
+
<List>
|
|
72
|
+
{shown.map((p) => <ListItem key={p} label={p} />)}
|
|
73
|
+
</List>
|
|
74
|
+
</>
|
|
75
|
+
)
|
|
76
|
+
}
|
|
77
|
+
```
|