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.
- package/AGENTS.md +483 -0
- package/README.md +60 -40
- package/bin/anvilui.mjs +83 -0
- package/dist/colors/colors.d.ts +10 -2
- 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 +22 -2
- package/dist/components/AnvilRoot/AnvilRoot.d.ts +44 -6
- package/dist/components/AppBar/AppBar.d.ts +13 -2
- package/dist/components/Avatar/Avatar.d.ts +6 -2
- 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 +4 -0
- package/dist/components/BottomSheet/BottomSheet.d.ts +22 -0
- package/dist/components/Button/Button.d.ts +17 -0
- package/dist/components/Calendar/Calendar.d.ts +19 -0
- package/dist/components/Card/Card.d.ts +36 -0
- package/dist/components/Carousel/Carousel.d.ts +21 -0
- package/dist/components/Checkbox/Checkbox.d.ts +10 -0
- package/dist/components/Chip/Chip.d.ts +25 -2
- package/dist/components/Combobox/Combobox.d.ts +48 -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 +39 -0
- package/dist/components/Dialog/Dialog.d.ts +32 -0
- package/dist/components/Divider/Divider.d.ts +8 -0
- package/dist/components/FAB/FAB.d.ts +4 -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 +20 -0
- package/dist/components/FloatingToolbar/FloatingToolbar.d.ts +15 -0
- package/dist/components/HoldButton/HoldButton.d.ts +4 -1
- package/dist/components/Icon/Icon.d.ts +14 -0
- package/dist/components/IconButton/IconButton.d.ts +14 -1
- package/dist/components/Input/Input.d.ts +14 -3
- package/dist/components/Kbd/Kbd.d.ts +21 -0
- package/dist/components/List/List.d.ts +10 -1
- package/dist/components/Menu/Menu.d.ts +32 -0
- package/dist/components/Menubar/Menubar.d.ts +17 -0
- package/dist/components/NavigationBar/NavigationBar.d.ts +10 -0
- package/dist/components/NavigationDrawer/NavigationDrawer.d.ts +22 -0
- package/dist/components/NavigationList/NavigationList.d.ts +27 -0
- package/dist/components/NavigationRail/NavigationRail.d.ts +25 -9
- package/dist/components/PinInput/PinInput.d.ts +33 -0
- package/dist/components/Popover/Popover.d.ts +30 -2
- package/dist/components/PreviewCard/PreviewCard.d.ts +31 -0
- package/dist/components/Progress/Progress.d.ts +12 -2
- package/dist/components/RadioGroup/RadioGroup.d.ts +14 -2
- package/dist/components/Search/Search.d.ts +55 -0
- package/dist/components/Select/Select.d.ts +21 -4
- package/dist/components/Skeleton/Skeleton.d.ts +20 -0
- package/dist/components/Slider/Slider.d.ts +7 -1
- package/dist/components/Snackbar/Snackbar.d.ts +7 -2
- package/dist/components/SplitButton/SplitButton.d.ts +13 -0
- package/dist/components/SquigglyWave/SquigglyWave.d.ts +26 -4
- package/dist/components/Sticker/Sticker.d.ts +21 -0
- package/dist/components/Switch/Switch.d.ts +11 -0
- package/dist/components/Table/Table.d.ts +36 -0
- package/dist/components/Tabs/Tabs.d.ts +17 -0
- package/dist/components/Textarea/Textarea.d.ts +14 -3
- package/dist/components/TimePicker/TimePicker.d.ts +47 -0
- package/dist/components/Toggle/Toggle.d.ts +42 -0
- package/dist/components/ToggleGroup/ToggleGroup.d.ts +16 -4
- package/dist/components/Tooltip/Tooltip.d.ts +10 -1
- package/dist/components/Typography/Typography.d.ts +13 -1
- package/dist/datetime.d.ts +12 -0
- package/dist/dev.d.ts +15 -0
- package/dist/index.cjs +3365 -654
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +1443 -367
- package/dist/index.css.map +1 -1
- package/dist/index.d.ts +50 -4
- package/dist/index.js +3362 -667
- package/dist/index.js.map +1 -1
- package/dist/themes/baseTheme.d.ts +2 -0
- package/dist/themes/createTheme.d.ts +22 -0
- package/dist/themes/monochromeTheme.d.ts +2 -0
- package/dist/themes/types.d.ts +13 -8
- package/dist/tokens/baseTokens.d.ts +4 -0
- package/dist/tokens/types.d.ts +34 -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 +73 -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 +42 -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 +55 -0
- package/docs/icons.md +38 -0
- package/docs/input.md +51 -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 +54 -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 +64 -0
- package/docs/search.md +77 -0
- package/docs/select.md +65 -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 +183 -0
- package/docs/time-picker.md +39 -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 +25 -5
|
@@ -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`, `style` | | | On the wrapper; `ref` goes on the group of boxes. |
|
|
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). Changing it animates: the wave flattens into the plain bar and back. |
|
|
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,64 @@
|
|
|
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
|
+
The value type is inferred from `value` / `defaultValue`. With neither, or when you type the props yourself in a wrapper, it's `unknown`: pass the type as `RadioGroupProps<YourValue>`.
|
|
48
|
+
|
|
49
|
+
```tsx
|
|
50
|
+
import { Radio, RadioGroup, type RadioGroupProps } from 'anvilui'
|
|
51
|
+
|
|
52
|
+
type Plan = 'free' | 'pro'
|
|
53
|
+
|
|
54
|
+
export function PlanPicker(props: RadioGroupProps<Plan>) {
|
|
55
|
+
return (
|
|
56
|
+
<RadioGroup aria-label="Plan" {...props}>
|
|
57
|
+
<label><Radio value="free" /> Free</label>
|
|
58
|
+
<label><Radio value="pro" /> Pro</label>
|
|
59
|
+
</RadioGroup>
|
|
60
|
+
)
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
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 an optional suggestion list. `aria-label` is required. For suggestions, **children are a render function** over `items`; without children it's a plain search bar. 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` | | Renders one `SearchItem`. Leave out for a plain search bar. |
|
|
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
|
+
| `color` | `'surface' \| 'container'` | `'surface'` | The bar's background. Use `'container'` on a `surface` panel (drawer, sidebar) so the bar doesn't blend in. No other colors and no `fillType`. |
|
|
22
|
+
| `clearLabel` | `string` | `'Clear'` | Name of the clear button. |
|
|
23
|
+
| `className`, `style` | | | On the bar. |
|
|
24
|
+
| `ref`, `id`, `aria-*`, `data-*` | | | On the text `<input>`. |
|
|
25
|
+
| `itemToStringValue`, `filter`, `limit`, `openOnInputClick` | | | Base UI Autocomplete.Root props. |
|
|
26
|
+
|
|
27
|
+
## SearchItem props
|
|
28
|
+
|
|
29
|
+
`value: Item` (required), `startIcon?: MaterialSymbol`, `children`.
|
|
30
|
+
|
|
31
|
+
```tsx
|
|
32
|
+
import { useState } from 'react'
|
|
33
|
+
import { Search, SearchItem } from 'anvilui'
|
|
34
|
+
|
|
35
|
+
const recent = ['invoices', 'travel', 'receipts']
|
|
36
|
+
|
|
37
|
+
export function Example() {
|
|
38
|
+
const [query, setQuery] = useState('')
|
|
39
|
+
return (
|
|
40
|
+
<Search
|
|
41
|
+
aria-label="Search mail"
|
|
42
|
+
placeholder="Search mail"
|
|
43
|
+
items={recent}
|
|
44
|
+
value={query}
|
|
45
|
+
onValueChange={setQuery}
|
|
46
|
+
>
|
|
47
|
+
{(item: string) => (
|
|
48
|
+
<SearchItem key={item} value={item} startIcon="history">
|
|
49
|
+
{item}
|
|
50
|
+
</SearchItem>
|
|
51
|
+
)}
|
|
52
|
+
</Search>
|
|
53
|
+
)
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
To filter a page's own content, leave out `items` and children. It's then a plain search bar (with the clear button) that never opens a list; filter your data with the typed text:
|
|
58
|
+
|
|
59
|
+
```tsx
|
|
60
|
+
import { useState } from 'react'
|
|
61
|
+
import { List, ListItem, Search } from 'anvilui'
|
|
62
|
+
|
|
63
|
+
const people = ['Ada Lovelace', 'Alan Turing', 'Grace Hopper']
|
|
64
|
+
|
|
65
|
+
export function FilterExample() {
|
|
66
|
+
const [query, setQuery] = useState('')
|
|
67
|
+
const shown = people.filter((p) => p.toLowerCase().includes(query.toLowerCase()))
|
|
68
|
+
return (
|
|
69
|
+
<>
|
|
70
|
+
<Search aria-label="Filter people" placeholder="Filter people" value={query} onValueChange={setQuery} />
|
|
71
|
+
<List>
|
|
72
|
+
{shown.map((p) => <ListItem key={p} label={p} />)}
|
|
73
|
+
</List>
|
|
74
|
+
</>
|
|
75
|
+
)
|
|
76
|
+
}
|
|
77
|
+
```
|
package/docs/select.md
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# Select, SelectItem
|
|
2
|
+
|
|
3
|
+
A dropdown to pick one option (or several with `multiple`). Looks like `Input`.
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import { Select, SelectItem } from 'anvilui'
|
|
7
|
+
import type { SelectProps, SelectItemProps } from 'anvilui'
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
## Select props
|
|
11
|
+
|
|
12
|
+
| Prop | Type | Default | Description |
|
|
13
|
+
| --- | --- | --- | --- |
|
|
14
|
+
| `children` | `SelectItem`s | | |
|
|
15
|
+
| `items` | `Record<string, ReactNode>` or `{ value, label }[]` | | **Pass it** so the field shows the label, not the raw value. |
|
|
16
|
+
| `value` / `defaultValue` | `Value \| null` (array with `multiple`) | | |
|
|
17
|
+
| `onValueChange` | `(value: Value \| null, details) => void` | | The value, not an event. |
|
|
18
|
+
| `label` | `ReactNode` | | Floating label. |
|
|
19
|
+
| `placeholder` | `ReactNode` | | Shown when nothing is selected. |
|
|
20
|
+
| `size` | `'small' \| 'normal'` | `'normal'` | |
|
|
21
|
+
| `multiple` | `boolean` | `false` | |
|
|
22
|
+
| `name`, `required`, `disabled`, `readOnly` | | | |
|
|
23
|
+
| `open` / `defaultOpen` / `onOpenChange` | | | |
|
|
24
|
+
| `itemToStringLabel` | `(value) => string` | | For object values. |
|
|
25
|
+
| `className`, `style` | | | On the field wrapper. |
|
|
26
|
+
| `ref`, `id`, `aria-*`, `data-*` | | | On the field's button. |
|
|
27
|
+
|
|
28
|
+
Everything else goes to Base UI `Select.Root`. Base UI docs: `node_modules/@base-ui/react/docs/react/components/select.md`.
|
|
29
|
+
|
|
30
|
+
## SelectItem props
|
|
31
|
+
|
|
32
|
+
`value` (required), `children` (the label), `disabled`.
|
|
33
|
+
|
|
34
|
+
```tsx
|
|
35
|
+
import { useState } from 'react'
|
|
36
|
+
import { Select, SelectItem } from 'anvilui'
|
|
37
|
+
|
|
38
|
+
const countries = [
|
|
39
|
+
{ value: 'us', label: 'United States' },
|
|
40
|
+
{ value: 'fr', label: 'France' },
|
|
41
|
+
{ value: 'jp', label: 'Japan' },
|
|
42
|
+
]
|
|
43
|
+
|
|
44
|
+
export function Example() {
|
|
45
|
+
const [country, setCountry] = useState<string | null>('fr')
|
|
46
|
+
return (
|
|
47
|
+
<Select
|
|
48
|
+
label="Country"
|
|
49
|
+
items={countries}
|
|
50
|
+
value={country}
|
|
51
|
+
onValueChange={setCountry}
|
|
52
|
+
className="country-field"
|
|
53
|
+
>
|
|
54
|
+
{countries.map((c) => (
|
|
55
|
+
<SelectItem key={c.value} value={c.value}>
|
|
56
|
+
{c.label}
|
|
57
|
+
</SelectItem>
|
|
58
|
+
))}
|
|
59
|
+
</Select>
|
|
60
|
+
)
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
- No `SelectTrigger`, `SelectContent` or `SelectValue` parts: `Select` renders the field and the popup. Only items go inside.
|
|
65
|
+
- For a searchable list use [Combobox](combobox.md).
|