anvilui 0.2.0 → 0.4.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 +34 -33
- package/README.md +42 -89
- package/dist/components/AnvilRoot/AnvilRoot.d.ts +2 -2
- package/dist/components/Combobox/Combobox.d.ts +8 -2
- package/dist/components/DateInput/DateInput.d.ts +5 -3
- package/dist/components/FABMenu/FABMenu.d.ts +4 -1
- package/dist/components/IconButton/IconButton.d.ts +5 -3
- package/dist/components/Input/Input.d.ts +5 -3
- package/dist/components/NavigationBar/NavigationBar.d.ts +1 -1
- package/dist/components/NavigationList/NavigationList.d.ts +1 -1
- package/dist/components/NavigationRail/NavigationRail.d.ts +1 -1
- package/dist/components/PinInput/PinInput.d.ts +5 -3
- package/dist/components/Progress/Progress.d.ts +4 -1
- package/dist/components/RadioGroup/RadioGroup.d.ts +3 -3
- package/dist/components/Search/Search.d.ts +22 -6
- package/dist/components/Select/Select.d.ts +6 -2
- package/dist/components/Skeleton/Skeleton.d.ts +3 -3
- package/dist/components/Slider/Slider.d.ts +9 -2
- package/dist/components/SquigglyWave/SquigglyWave.d.ts +26 -4
- package/dist/components/Textarea/Textarea.d.ts +6 -3
- package/dist/components/TimePicker/TimePicker.d.ts +7 -5
- package/dist/components/Toggle/Toggle.d.ts +2 -1
- package/dist/components/ToggleGroup/ToggleGroup.d.ts +2 -2
- package/dist/dev.d.ts +7 -2
- package/dist/index.cjs +528 -155
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +55 -26
- package/dist/index.css.map +1 -1
- package/dist/index.js +533 -141
- package/dist/index.js.map +1 -1
- package/dist/themes/types.d.ts +0 -4
- package/dist/utils.d.ts +5 -1
- package/docs/avatar.md +1 -1
- package/docs/badge.md +41 -41
- package/docs/calendar.md +1 -1
- package/docs/combobox.md +2 -1
- package/docs/composition.md +1 -1
- package/docs/date-input.md +4 -3
- package/docs/fab-menu.md +1 -0
- package/docs/forms.md +2 -2
- package/docs/icon-button.md +3 -2
- package/docs/input.md +1 -0
- package/docs/morph.md +4 -1
- package/docs/navigation-bar.md +1 -1
- package/docs/navigation-rail.md +1 -1
- package/docs/pin-input.md +1 -1
- package/docs/progress.md +37 -37
- package/docs/radio-group.md +18 -1
- package/docs/search.md +7 -7
- package/docs/select.md +3 -2
- package/docs/skeleton.md +33 -33
- package/docs/slider.md +51 -49
- package/docs/textarea.md +1 -1
- package/docs/theming.md +3 -2
- package/docs/time-picker.md +4 -3
- package/docs/toggle-group.md +1 -1
- package/docs/toggle.md +2 -2
- package/package.json +2 -2
package/dist/themes/types.d.ts
CHANGED
|
@@ -13,10 +13,6 @@ export type Theme = {
|
|
|
13
13
|
surface: string;
|
|
14
14
|
/** Text and icons on `surface`. */
|
|
15
15
|
onSurface: string;
|
|
16
|
-
/** @deprecated Renamed to `surface`. Still read if that's missing. */
|
|
17
|
-
surfaceVariant?: string;
|
|
18
|
-
/** @deprecated Renamed to `onSurface`. Still read if that's missing. */
|
|
19
|
-
onSurfaceVariant?: string;
|
|
20
16
|
/** Borders of inputs and outlined controls. */
|
|
21
17
|
outline: string;
|
|
22
18
|
/** Thin lines between content: dividers, table lines, tab underlines. */
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import type { Ref, RefCallback } from 'react';
|
|
2
2
|
export declare function cx(...parts: (string | false | null | undefined)[]): string;
|
|
3
|
-
export declare function withClass<State>(base: string, className: string | ((state: State) => string | undefined) | undefined): (state: State) => string;
|
|
3
|
+
export declare function withClass<State>(base: string | ((state: State) => string), className: string | ((state: State) => string | undefined) | undefined): (state: State) => string;
|
|
4
|
+
export declare function splitControlProps<P extends object>(props: P): {
|
|
5
|
+
control: Record<string, unknown>;
|
|
6
|
+
rest: P;
|
|
7
|
+
};
|
|
4
8
|
export declare function mergeRefs<T>(...refs: (Ref<T> | undefined)[]): RefCallback<T>;
|
package/docs/avatar.md
CHANGED
|
@@ -17,7 +17,7 @@ import type { AvatarProps } from 'anvilui'
|
|
|
17
17
|
| `fillType` | `'filled' \| 'outlined' \| 'text'` | `'filled'` | |
|
|
18
18
|
| `children` | `ReactNode` | | Replaces the fallback. |
|
|
19
19
|
|
|
20
|
-
No `alt` prop: use `name
|
|
20
|
+
No `alt` prop: use `name` (an `aria-label` also names it, without showing initials). Leave `name` out when the name is shown next to it.
|
|
21
21
|
|
|
22
22
|
```tsx
|
|
23
23
|
import { Avatar } from 'anvilui'
|
package/docs/badge.md
CHANGED
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
# Badge
|
|
2
|
-
|
|
3
|
-
A dot or count on the corner of what it wraps, or inline on its own. Error-colored by default. Hidden from screen readers.
|
|
4
|
-
|
|
5
|
-
```ts
|
|
6
|
-
import { Badge } from 'anvilui'
|
|
7
|
-
```
|
|
8
|
-
|
|
9
|
-
| Prop | Type | Default | Description |
|
|
10
|
-
| --- | --- | --- | --- |
|
|
11
|
-
| `count` | `number` | | Omit for a dot; `0` hides it. |
|
|
12
|
-
| `max` | `number` | `999` | Above shows "999+". |
|
|
13
|
-
| `color` | `ComponentColor` | `'error'` | |
|
|
14
|
-
| `children` | `ReactNode` | | What it sits on. |
|
|
15
|
-
|
|
16
|
-
No `content` / `badgeContent` / `variant`.
|
|
17
|
-
|
|
18
|
-
```tsx
|
|
19
|
-
import { Badge, Icon, IconButton } from 'anvilui'
|
|
20
|
-
|
|
21
|
-
export function Example() {
|
|
22
|
-
return (
|
|
23
|
-
<>
|
|
24
|
-
<Badge count={3}>
|
|
25
|
-
<IconButton
|
|
26
|
-
icon="mail"
|
|
27
|
-
aria-label="Inbox, 3 unread"
|
|
28
|
-
fillType="text"
|
|
29
|
-
color="container"
|
|
30
|
-
/>
|
|
31
|
-
</Badge>
|
|
32
|
-
<Badge>
|
|
33
|
-
<Icon name="notifications" />
|
|
34
|
-
</Badge>
|
|
35
|
-
<Badge count={12} color="primary" />
|
|
36
|
-
</>
|
|
37
|
-
)
|
|
38
|
-
}
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
Put the count in the wrapped element's `aria-label` too. On a non-interactive icon, label the icon: `<Badge count={4}><Icon name="chat_bubble" aria-label="4 comments" /></Badge>`.
|
|
1
|
+
# Badge
|
|
2
|
+
|
|
3
|
+
A dot or count on the corner of what it wraps, or inline on its own. Error-colored by default. Hidden from screen readers.
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import { Badge } from 'anvilui'
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
| Prop | Type | Default | Description |
|
|
10
|
+
| --- | --- | --- | --- |
|
|
11
|
+
| `count` | `number` | | Omit for a dot; `0` hides it. |
|
|
12
|
+
| `max` | `number` | `999` | Above shows "999+". |
|
|
13
|
+
| `color` | `ComponentColor` | `'error'` | |
|
|
14
|
+
| `children` | `ReactNode` | | What it sits on. |
|
|
15
|
+
|
|
16
|
+
No `content` / `badgeContent` / `variant`.
|
|
17
|
+
|
|
18
|
+
```tsx
|
|
19
|
+
import { Badge, Icon, IconButton } from 'anvilui'
|
|
20
|
+
|
|
21
|
+
export function Example() {
|
|
22
|
+
return (
|
|
23
|
+
<>
|
|
24
|
+
<Badge count={3}>
|
|
25
|
+
<IconButton
|
|
26
|
+
icon="mail"
|
|
27
|
+
aria-label="Inbox, 3 unread"
|
|
28
|
+
fillType="text"
|
|
29
|
+
color="container"
|
|
30
|
+
/>
|
|
31
|
+
</Badge>
|
|
32
|
+
<Badge>
|
|
33
|
+
<Icon name="notifications" />
|
|
34
|
+
</Badge>
|
|
35
|
+
<Badge count={12} color="primary" />
|
|
36
|
+
</>
|
|
37
|
+
)
|
|
38
|
+
}
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Put the count in the wrapped element's `aria-label` too. On a non-interactive icon, label the icon: `<Badge count={4}><Icon name="chat_bubble" aria-label="4 comments" /></Badge>`.
|
package/docs/calendar.md
CHANGED
|
@@ -9,7 +9,7 @@ import type { CalendarProps } from 'anvilui'
|
|
|
9
9
|
|
|
10
10
|
| Prop | Type | Default | Description |
|
|
11
11
|
| --- | --- | --- | --- |
|
|
12
|
-
| `value` / `defaultValue` | `string \| null` | `null` | |
|
|
12
|
+
| `value` / `defaultValue` | `string \| null` | `null` | The grid shows this date's month, and moves when `value` changes. |
|
|
13
13
|
| `onValueChange` | `(value: string) => void` | | |
|
|
14
14
|
| other | `<div>` props | | |
|
|
15
15
|
|
package/docs/combobox.md
CHANGED
|
@@ -21,7 +21,8 @@ import type { ComboboxProps, ComboboxItemProps } from 'anvilui'
|
|
|
21
21
|
| `placeholder` | `string` | | |
|
|
22
22
|
| `empty` | `ReactNode` | | Shown when nothing matches; without it the popup hides. |
|
|
23
23
|
| `size` | `'small' \| 'normal'` | `'normal'` | |
|
|
24
|
-
| `className
|
|
24
|
+
| `className`, `style` | | | On the field wrapper. |
|
|
25
|
+
| `ref`, `id`, `aria-*`, `data-*` | | | On the text `<input>`. |
|
|
25
26
|
| `name`, `disabled`, `required`, `filter`, `limit` | | | Base UI Combobox.Root props. |
|
|
26
27
|
|
|
27
28
|
## ComboboxItem props
|
package/docs/composition.md
CHANGED
|
@@ -57,7 +57,7 @@ export function Example() {
|
|
|
57
57
|
|
|
58
58
|
- Every component takes `ref` (React 19 `ref` prop) and passes unknown props to its main element.
|
|
59
59
|
- `className` is merged with the library's classes, never replaced. On Base UI-based parts it can also be a function of state: `className={(state) => state.open ? 'open' : ''}`.
|
|
60
|
-
- **Field-like components
|
|
60
|
+
- **Field-like components split their props** (`Input`, `Textarea`, `DateInput`, `Select`, `Combobox`, `Search`, `TimePicker`, `PinInput`): `className` and `style` go on the outer wrapper, so width and margins work; `ref`, `id`, `aria-*` and `data-*` go on the control. The control is the `<input>` / `<textarea>`, or the button for `Select` and `TimePicker`. `PinInput`'s `ref` is its group of boxes.
|
|
61
61
|
- `Tooltip` puts `className` on the bubble. `FABMenu` puts it on the FAB.
|
|
62
62
|
|
|
63
63
|
## State props
|
package/docs/date-input.md
CHANGED
|
@@ -13,7 +13,8 @@ import type { DateInputProps } from 'anvilui'
|
|
|
13
13
|
| `onValueChange` | `(value: string \| null) => void` | | `null` when cleared. |
|
|
14
14
|
| `label` | `ReactNode` | | Either this or `aria-label`. |
|
|
15
15
|
| `size` | `'small' \| 'normal'` | `'normal'` | |
|
|
16
|
-
| `
|
|
16
|
+
| `name` | `string` | | Submits `"YYYY-MM-DD"` with the form (also when the name comes from a `Field`). |
|
|
17
|
+
| `className`, `style` | | | On the wrapper; `ref` and other props go on the `<input>`. |
|
|
17
18
|
| `disabled`, `required`, `id`, `onBlur` | | | On the `<input>`. |
|
|
18
19
|
|
|
19
20
|
No `min` / `max` / disabled dates.
|
|
@@ -30,9 +31,9 @@ export function Example() {
|
|
|
30
31
|
label="Start date"
|
|
31
32
|
value={start}
|
|
32
33
|
onValueChange={setStart}
|
|
34
|
+
name="start"
|
|
33
35
|
/>
|
|
34
|
-
{/*
|
|
35
|
-
<input type="hidden" name="start" value={start ?? ''} />
|
|
36
|
+
{/* Submits start=2026-11-06, not the text shown in the field */}
|
|
36
37
|
</form>
|
|
37
38
|
)
|
|
38
39
|
}
|
package/docs/fab-menu.md
CHANGED
|
@@ -21,6 +21,7 @@ import type { FABMenuProps, FABMenuItemProps } from 'anvilui'
|
|
|
21
21
|
| `align` | `'start' \| 'center' \| 'end'` | `'end'` | |
|
|
22
22
|
| `sticky` | `boolean` | `true` | |
|
|
23
23
|
| `className` | `string` | | Goes on the FAB. |
|
|
24
|
+
| `ref` | `Ref<HTMLButtonElement>` | | The FAB's `<button>`. |
|
|
24
25
|
| `open` / `defaultOpen` / `onOpenChange` | | | Base UI Menu.Root state. |
|
|
25
26
|
|
|
26
27
|
## FABMenuItem props
|
package/docs/forms.md
CHANGED
|
@@ -71,9 +71,9 @@ Rules:
|
|
|
71
71
|
- Put the `name` on `Field` (or on the control when there's no Field).
|
|
72
72
|
- Native rules (`required`, `type="email"`, `minLength`, `pattern`, …) block a plain `<form>`'s submit and show in `FieldError`. This includes `<Checkbox required />` and `<DateInput required />`.
|
|
73
73
|
- Custom rules: `validate={(value) => value ? null : 'Required'}` returns an error string or `null`. A failing `validate` blocks submit once it has run, so on a plain `<form>` use `validationMode="onBlur"` or `"onChange"` with it (the default is `"onSubmit"`). Keep a final check in `onSubmit` for anything that must hold.
|
|
74
|
-
- Controls that work inside `Field`: `Input`, `Textarea`, `DateInput`, `Select`, `Combobox`, `Checkbox`, `Switch`, `RadioGroup`, `Slider`.
|
|
74
|
+
- Controls that work inside `Field`: `Input`, `Textarea`, `DateInput`, `Select`, `Combobox`, `Checkbox`, `Switch`, `RadioGroup`, `Slider`. Not `TimePicker`: the Field's `name`, `disabled` and validation don't reach it, so give it its own `name` and `disabled`.
|
|
75
75
|
- `Button loading` disables the button, so it also blocks repeat submits.
|
|
76
|
-
- `Select` with `name` submits the item's `value`, not its label.
|
|
76
|
+
- `Select` with `name` submits the item's `value`, not its label. `DateInput` submits `"YYYY-MM-DD"` and `TimePicker` `"HH:mm"`, not the text they show.
|
|
77
77
|
- Server errors: `<Field invalid>` plus `<FieldError match>` with your message (`match` true shows it whenever the field is invalid).
|
|
78
78
|
- Values: `DateInput` and `Calendar` use `"YYYY-MM-DD"`, `TimePicker` `"HH:mm"`, `Slider` a number (or `number[]`).
|
|
79
79
|
- There is no form library integration and no `Form` component. A plain `<form>` works. With react-hook-form, use controlled props (`value` + `onValueChange` / `checked` + `onCheckedChange`) in `Controller`.
|
package/docs/icon-button.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# IconButton
|
|
2
2
|
|
|
3
|
-
A round
|
|
3
|
+
A round button with only an icon. `aria-label` is required.
|
|
4
4
|
|
|
5
5
|
```ts
|
|
6
6
|
import { IconButton } from 'anvilui'
|
|
@@ -15,9 +15,10 @@ import type { IconButtonProps } from 'anvilui'
|
|
|
15
15
|
| `aria-label` | `string` | required | What the button does. |
|
|
16
16
|
| `fillType` | `'filled' \| 'outlined' \| 'text'` | `'filled'` | |
|
|
17
17
|
| `color` | `ComponentColor` | `'primary'` | |
|
|
18
|
+
| `size` | `'small' \| 'normal' \| 'big'` | `'normal'` | 32, 40 or 48px, like `Button`. |
|
|
18
19
|
| `disabled` | `boolean` | `false` | |
|
|
19
20
|
|
|
20
|
-
Takes no `children
|
|
21
|
+
Takes no `children`. Also takes Base UI Button props and `<button>` attributes.
|
|
21
22
|
|
|
22
23
|
## Example
|
|
23
24
|
|
package/docs/input.md
CHANGED
|
@@ -17,6 +17,7 @@ import type { InputProps } from 'anvilui'
|
|
|
17
17
|
| `onValueChange` | `(value: string, details) => void` | | The string. |
|
|
18
18
|
| `onChange` | `ChangeEventHandler<HTMLInputElement>` | | The native event also works. |
|
|
19
19
|
| `className` | `string` | | On the **wrapper** `<label>` (width, margins). |
|
|
20
|
+
| `style` | `CSSProperties` | | On the wrapper too. |
|
|
20
21
|
| `ref` | | | On the `<input>`. |
|
|
21
22
|
| everything else | `<input>` attributes | | `type`, `name`, `placeholder`, `required`, `disabled`, `autoComplete`, … go on the `<input>`. |
|
|
22
23
|
|
package/docs/morph.md
CHANGED
|
@@ -46,6 +46,9 @@ export function Albums() {
|
|
|
46
46
|
```
|
|
47
47
|
|
|
48
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).
|
|
49
|
+
- `update` must change the view **synchronously** (set state, or `navigate(to, { flushSync: true })` in React Router). A view that waits on data or a lazy route has nothing to morph into yet.
|
|
50
|
+
- The box's size, position, background, corners and shadow animate; the content crossfades.
|
|
51
|
+
- It returns a promise that resolves when the morph ends, e.g. to move focus: `await morph(id, close); row.focus()`.
|
|
52
|
+
- `duration` and `easing` default to the theme's `easeLength.slow` and `ease.smooth`.
|
|
50
53
|
- Without View Transitions support, or with reduced motion, `update` just runs.
|
|
51
54
|
- `Dialog` and `Popover` take `morph` (boolean) to do this between their trigger and popup.
|
package/docs/navigation-bar.md
CHANGED
|
@@ -9,7 +9,7 @@ import { NavigationBar, NavigationBarItem } from 'anvilui'
|
|
|
9
9
|
| Part | Renders | Props |
|
|
10
10
|
| --- | --- | --- |
|
|
11
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) |
|
|
12
|
+
| `NavigationBarItem` | `<a>` | `icon: MaterialSymbol` (required), `label: string` (required; not children), `active?: boolean` (sets `aria-current="page"`), `href`, `render` (router link) |
|
|
13
13
|
|
|
14
14
|
Items are links, not tabs: there's no `value` / `onValueChange`. Mark the current one with `active`.
|
|
15
15
|
|
package/docs/navigation-rail.md
CHANGED
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
| --- | --- | --- |
|
|
15
15
|
| `NavigationRail` | `<nav>` (96px wide, `height: 100%`) | `aria-label`; `expanded` / `defaultExpanded` (false) / `onExpandedChange(expanded)` |
|
|
16
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` |
|
|
17
|
+
| `NavigationRailItem` | `<a>` | `icon` (required), `label: string` (required; not children), `active`, `end` (short badge text, e.g. a count), `href`, `render` |
|
|
18
18
|
|
|
19
19
|
```tsx
|
|
20
20
|
import {
|
package/docs/pin-input.md
CHANGED
|
@@ -19,7 +19,7 @@ import type { PinInputProps } from 'anvilui'
|
|
|
19
19
|
| `fillType` | `'filled' \| 'outlined'` | `'outlined'` | |
|
|
20
20
|
| `size` | `'small' \| 'normal'` | `'normal'` | |
|
|
21
21
|
| `name`, `disabled`, `required`, `autoSubmit` | | | |
|
|
22
|
-
| `className
|
|
22
|
+
| `className`, `style` | | | On the wrapper; `ref` goes on the group of boxes. |
|
|
23
23
|
|
|
24
24
|
```tsx
|
|
25
25
|
import { PinInput } from 'anvilui'
|
package/docs/progress.md
CHANGED
|
@@ -1,37 +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
|
-
```
|
|
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
|
+
```
|
package/docs/radio-group.md
CHANGED
|
@@ -14,7 +14,7 @@ import type { RadioGroupProps, RadioProps } from 'anvilui'
|
|
|
14
14
|
| `value` / `defaultValue` | `Value` | The picked radio's value. |
|
|
15
15
|
| `onValueChange` | `(value: Value, details) => void` | |
|
|
16
16
|
| `name`, `required`, `disabled`, `readOnly` | | |
|
|
17
|
-
| `aria-label` / `aria-labelledby` | `string` | Name the group
|
|
17
|
+
| `aria-label` / `aria-labelledby` | `string` | Name the group, or put it in a `<fieldset>` with a `<legend>`. |
|
|
18
18
|
|
|
19
19
|
## Radio props (Base UI Radio.Root)
|
|
20
20
|
|
|
@@ -44,4 +44,21 @@ export function Example() {
|
|
|
44
44
|
}
|
|
45
45
|
```
|
|
46
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
|
+
|
|
47
64
|
For a compact row of 2–5 options, [ToggleGroup](toggle-group.md) looks better.
|
package/docs/search.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Search, SearchItem
|
|
2
2
|
|
|
3
|
-
A Material 3 search bar with
|
|
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
4
|
|
|
5
5
|
```ts
|
|
6
6
|
import { Search, SearchItem } from 'anvilui'
|
|
@@ -12,14 +12,16 @@ import type { SearchProps, SearchItemProps } from 'anvilui'
|
|
|
12
12
|
| Prop | Type | Default | Description |
|
|
13
13
|
| --- | --- | --- | --- |
|
|
14
14
|
| `aria-label` | `string` | required | |
|
|
15
|
-
| `children` | `(item: Item, index: number) => ReactNode` |
|
|
15
|
+
| `children` | `(item: Item, index: number) => ReactNode` | | Renders one `SearchItem`. Leave out for a plain search bar. |
|
|
16
16
|
| `items` | `readonly Item[]` | | Suggestions, filtered as you type. Pass `[]` for none. |
|
|
17
17
|
| `value` / `defaultValue` | `string` | | The typed text. |
|
|
18
18
|
| `onValueChange` | `(text: string, details) => void` | | |
|
|
19
19
|
| `placeholder` | `string` | | |
|
|
20
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`. |
|
|
21
22
|
| `clearLabel` | `string` | `'Clear'` | Name of the clear button. |
|
|
22
|
-
| `className
|
|
23
|
+
| `className`, `style` | | | On the bar. |
|
|
24
|
+
| `ref`, `id`, `aria-*`, `data-*` | | | On the text `<input>`. |
|
|
23
25
|
| `itemToStringValue`, `filter`, `limit`, `openOnInputClick` | | | Base UI Autocomplete.Root props. |
|
|
24
26
|
|
|
25
27
|
## SearchItem props
|
|
@@ -52,7 +54,7 @@ export function Example() {
|
|
|
52
54
|
}
|
|
53
55
|
```
|
|
54
56
|
|
|
55
|
-
To filter a page's own content
|
|
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:
|
|
56
58
|
|
|
57
59
|
```tsx
|
|
58
60
|
import { useState } from 'react'
|
|
@@ -65,9 +67,7 @@ export function FilterExample() {
|
|
|
65
67
|
const shown = people.filter((p) => p.toLowerCase().includes(query.toLowerCase()))
|
|
66
68
|
return (
|
|
67
69
|
<>
|
|
68
|
-
<Search aria-label="Filter people" placeholder="Filter people"
|
|
69
|
-
{() => null}
|
|
70
|
-
</Search>
|
|
70
|
+
<Search aria-label="Filter people" placeholder="Filter people" value={query} onValueChange={setQuery} />
|
|
71
71
|
<List>
|
|
72
72
|
{shown.map((p) => <ListItem key={p} label={p} />)}
|
|
73
73
|
</List>
|
package/docs/select.md
CHANGED
|
@@ -22,9 +22,10 @@ import type { SelectProps, SelectItemProps } from 'anvilui'
|
|
|
22
22
|
| `name`, `required`, `disabled`, `readOnly` | | | |
|
|
23
23
|
| `open` / `defaultOpen` / `onOpenChange` | | | |
|
|
24
24
|
| `itemToStringLabel` | `(value) => string` | | For object values. |
|
|
25
|
-
| `className
|
|
25
|
+
| `className`, `style` | | | On the field wrapper. |
|
|
26
|
+
| `ref`, `id`, `aria-*`, `data-*` | | | On the field's button. |
|
|
26
27
|
|
|
27
|
-
|
|
28
|
+
Everything else goes to Base UI `Select.Root`. Base UI docs: `node_modules/@base-ui/react/docs/react/components/select.md`.
|
|
28
29
|
|
|
29
30
|
## SelectItem props
|
|
30
31
|
|
package/docs/skeleton.md
CHANGED
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
# Skeleton
|
|
2
|
-
|
|
3
|
-
A pulsing placeholder while content loads. Hidden from screen readers; put `aria-busy` on the loading region.
|
|
4
|
-
|
|
5
|
-
```ts
|
|
6
|
-
import { Skeleton } from 'anvilui'
|
|
7
|
-
```
|
|
8
|
-
|
|
9
|
-
| Prop | Type | Default | Description |
|
|
10
|
-
| --- | --- | --- | --- |
|
|
11
|
-
| `
|
|
12
|
-
| `animation` | `'pulse' \| 'none'` | `'pulse'` | |
|
|
13
|
-
|
|
14
|
-
Size it with `style` (`width`, `height`). No `width` / `height` props. Renders a `<span>`.
|
|
15
|
-
|
|
16
|
-
```tsx
|
|
17
|
-
import { Skeleton } from 'anvilui'
|
|
18
|
-
|
|
19
|
-
export function Example() {
|
|
20
|
-
return (
|
|
21
|
-
<div
|
|
22
|
-
aria-busy="true"
|
|
23
|
-
style={{ display: 'flex', gap: 12, alignItems: 'center' }}
|
|
24
|
-
>
|
|
25
|
-
<Skeleton
|
|
26
|
-
<div style={{ display: 'grid', gap: 4, flex: 1 }}>
|
|
27
|
-
<Skeleton style={{ width: '40%' }} />
|
|
28
|
-
<Skeleton style={{ width: '70%' }} />
|
|
29
|
-
</div>
|
|
30
|
-
</div>
|
|
31
|
-
)
|
|
32
|
-
}
|
|
33
|
-
```
|
|
1
|
+
# Skeleton
|
|
2
|
+
|
|
3
|
+
A pulsing placeholder while content loads. Hidden from screen readers; put `aria-busy` on the loading region.
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import { Skeleton } from 'anvilui'
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
| Prop | Type | Default | Description |
|
|
10
|
+
| --- | --- | --- | --- |
|
|
11
|
+
| `type` | `'text' \| 'circular' \| 'rectangular'` | `'text'` | The shape. Not `variant`. |
|
|
12
|
+
| `animation` | `'pulse' \| 'none'` | `'pulse'` | |
|
|
13
|
+
|
|
14
|
+
Size it with `style` (`width`, `height`). No `width` / `height` props. Renders a `<span>`.
|
|
15
|
+
|
|
16
|
+
```tsx
|
|
17
|
+
import { Skeleton } from 'anvilui'
|
|
18
|
+
|
|
19
|
+
export function Example() {
|
|
20
|
+
return (
|
|
21
|
+
<div
|
|
22
|
+
aria-busy="true"
|
|
23
|
+
style={{ display: 'flex', gap: 12, alignItems: 'center' }}
|
|
24
|
+
>
|
|
25
|
+
<Skeleton type="circular" style={{ width: 40, height: 40 }} />
|
|
26
|
+
<div style={{ display: 'grid', gap: 4, flex: 1 }}>
|
|
27
|
+
<Skeleton style={{ width: '40%' }} />
|
|
28
|
+
<Skeleton style={{ width: '70%' }} />
|
|
29
|
+
</div>
|
|
30
|
+
</div>
|
|
31
|
+
)
|
|
32
|
+
}
|
|
33
|
+
```
|
package/docs/slider.md
CHANGED
|
@@ -1,49 +1,51 @@
|
|
|
1
|
-
# Slider
|
|
2
|
-
|
|
3
|
-
Pick a number, or a range with several handles. Needs `label` or `aria-label`.
|
|
4
|
-
|
|
5
|
-
```ts
|
|
6
|
-
import { Slider } from 'anvilui'
|
|
7
|
-
import type { SliderProps } from 'anvilui'
|
|
8
|
-
```
|
|
9
|
-
|
|
10
|
-
## Props
|
|
11
|
-
|
|
12
|
-
| Prop | Type | Default | Description |
|
|
13
|
-
| --- | --- | --- | --- |
|
|
14
|
-
| `label` | `ReactNode` | | Visible label above. Either this or `aria-label`. |
|
|
15
|
-
| `aria-label` | `string` | | |
|
|
16
|
-
| `
|
|
17
|
-
| `
|
|
18
|
-
| `
|
|
19
|
-
| `
|
|
20
|
-
| `
|
|
21
|
-
| `
|
|
22
|
-
| `
|
|
23
|
-
| `
|
|
24
|
-
| `
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
import {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const [
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
<Slider
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
1
|
+
# Slider
|
|
2
|
+
|
|
3
|
+
Pick a number, or a range with several handles. Needs `label` or `aria-label`.
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import { Slider } from 'anvilui'
|
|
7
|
+
import type { SliderProps } from 'anvilui'
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
## Props
|
|
11
|
+
|
|
12
|
+
| Prop | Type | Default | Description |
|
|
13
|
+
| --- | --- | --- | --- |
|
|
14
|
+
| `label` | `ReactNode` | | Visible label above. Either this or `aria-label`. |
|
|
15
|
+
| `aria-label` | `string` | | |
|
|
16
|
+
| `getAriaLabel` | `(index: number) => string` | | Names each handle of a range ("Minimum price", "Maximum price"). Without it, every handle gets the same name. |
|
|
17
|
+
| `value` / `defaultValue` | `number` or `number[]` | | An array makes a range with that many handles. |
|
|
18
|
+
| `onValueChange` | `(value, details) => void` | | While dragging. Gets the value, not an event: `number` when `value` is a number, `number[]` when it's an array, so a `useState` setter can be passed directly. |
|
|
19
|
+
| `onValueCommitted` | `(value, details) => void` | | On release. |
|
|
20
|
+
| `min` / `max` / `step` | `number` | `0` / `100` / `1` | |
|
|
21
|
+
| `showValue` | `boolean` | `true` | Value bubble while dragging or focused. |
|
|
22
|
+
| `squiggly` | `boolean` | `false` | Wavy track (horizontal only). Changing it animates: the wave flattens into the plain track and back, e.g. `squiggly={playing}` on a media seek bar. |
|
|
23
|
+
| `orientation` | `'horizontal' \| 'vertical'` | `'horizontal'` | Vertical is 160px tall; set height via `className`. |
|
|
24
|
+
| `format` | `Intl.NumberFormatOptions` | | Formats the bubble. |
|
|
25
|
+
| `disabled`, `name` | | | |
|
|
26
|
+
|
|
27
|
+
Base UI docs: `node_modules/@base-ui/react/docs/react/components/slider.md`.
|
|
28
|
+
|
|
29
|
+
```tsx
|
|
30
|
+
import { useState } from 'react'
|
|
31
|
+
import { Slider } from 'anvilui'
|
|
32
|
+
|
|
33
|
+
export function Example() {
|
|
34
|
+
const [volume, setVolume] = useState(40)
|
|
35
|
+
const [price, setPrice] = useState([20, 80])
|
|
36
|
+
return (
|
|
37
|
+
<div style={{ display: 'grid', gap: 24, width: 300 }}>
|
|
38
|
+
<Slider label="Volume" value={volume} onValueChange={setVolume} />
|
|
39
|
+
<Slider
|
|
40
|
+
aria-label="Price"
|
|
41
|
+
getAriaLabel={(i) => (i === 0 ? 'Minimum price' : 'Maximum price')}
|
|
42
|
+
value={price}
|
|
43
|
+
onValueChange={setPrice}
|
|
44
|
+
min={0}
|
|
45
|
+
max={200}
|
|
46
|
+
format={{ style: 'currency', currency: 'USD' }}
|
|
47
|
+
/>
|
|
48
|
+
</div>
|
|
49
|
+
)
|
|
50
|
+
}
|
|
51
|
+
```
|
package/docs/textarea.md
CHANGED
|
@@ -12,7 +12,7 @@ import type { TextareaProps } from 'anvilui'
|
|
|
12
12
|
| `label` | `ReactNode` | | Floating label. |
|
|
13
13
|
| `size` | `'small' \| 'normal'` | `'normal'` | |
|
|
14
14
|
| `onValueChange` | `(value: string, details) => void` | | Or native `onChange`. |
|
|
15
|
-
| `className
|
|
15
|
+
| `className`, `style` | | | On the wrapper; `ref` and other props go on the `<textarea>`. |
|
|
16
16
|
|
|
17
17
|
```tsx
|
|
18
18
|
import { Textarea } from 'anvilui'
|