anvilui 0.3.0 → 0.4.1
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 +11 -7
- package/dist/components/AnvilRoot/AnvilRoot.d.ts +2 -2
- package/dist/components/DateInput/DateInput.d.ts +1 -1
- package/dist/components/FABMenu/FABMenu.d.ts +4 -1
- package/dist/components/FloatingToolbar/FloatingToolbar.d.ts +1 -1
- 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/RadioGroup/RadioGroup.d.ts +1 -1
- package/dist/components/Skeleton/Skeleton.d.ts +3 -3
- package/dist/components/Slider/Slider.d.ts +7 -1
- package/dist/dev.d.ts +7 -2
- package/dist/index.cjs +308 -108
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +7 -1
- package/dist/index.css.map +1 -1
- package/dist/index.js +286 -75
- package/dist/index.js.map +1 -1
- package/dist/utils.d.ts +1 -1
- package/docs/avatar.md +1 -1
- package/docs/calendar.md +1 -1
- package/docs/fab-menu.md +1 -0
- package/docs/forms.md +1 -1
- package/docs/llms-index.md +1 -0
- package/docs/navigation-bar.md +1 -1
- package/docs/navigation-rail.md +1 -1
- package/docs/radio-group.md +1 -1
- package/docs/skeleton.md +33 -33
- package/docs/slider.md +2 -0
- package/docs/styling.md +40 -0
- package/docs/theming.md +2 -2
- package/docs/time-picker.md +1 -1
- package/package.json +1 -1
package/dist/utils.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
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
4
|
export declare function splitControlProps<P extends object>(props: P): {
|
|
5
5
|
control: Record<string, unknown>;
|
|
6
6
|
rest: P;
|
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/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/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,7 +71,7 @@ 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
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).
|
package/docs/llms-index.md
CHANGED
|
@@ -6,6 +6,7 @@ One line per page. Start with [../AGENTS.md](../AGENTS.md). Paths are relative t
|
|
|
6
6
|
|
|
7
7
|
- [setup.md](setup.md): install, `anvilui/styles.css`, `AnvilRoot`, fonts, Next.js, theme CSS variables
|
|
8
8
|
- [theming.md](theming.md): AnvilRoot props, color mode, `useAnvil`, `createTheme`, theme roles, design tokens
|
|
9
|
+
- [styling.md](styling.md): custom CSS, which classes and CSS variables are public and stable, which are internal
|
|
9
10
|
- [composition.md](composition.md): `render` instead of `asChild`, refs, className, controlled/uncontrolled props
|
|
10
11
|
- [forms.md](forms.md): building forms, `Field` validation, `FormData`, submit buttons
|
|
11
12
|
- [icons.md](icons.md): Material Symbols names, `Icon`, which props take icon names
|
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/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
|
|
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
|
@@ -13,6 +13,7 @@ import type { SliderProps } from 'anvilui'
|
|
|
13
13
|
| --- | --- | --- | --- |
|
|
14
14
|
| `label` | `ReactNode` | | Visible label above. Either this or `aria-label`. |
|
|
15
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. |
|
|
16
17
|
| `value` / `defaultValue` | `number` or `number[]` | | An array makes a range with that many handles. |
|
|
17
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. |
|
|
18
19
|
| `onValueCommitted` | `(value, details) => void` | | On release. |
|
|
@@ -37,6 +38,7 @@ export function Example() {
|
|
|
37
38
|
<Slider label="Volume" value={volume} onValueChange={setVolume} />
|
|
38
39
|
<Slider
|
|
39
40
|
aria-label="Price"
|
|
41
|
+
getAriaLabel={(i) => (i === 0 ? 'Minimum price' : 'Maximum price')}
|
|
40
42
|
value={price}
|
|
41
43
|
onValueChange={setPrice}
|
|
42
44
|
min={0}
|
package/docs/styling.md
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# Customizing styles
|
|
2
|
+
|
|
3
|
+
What you can rely on when you style AnvilUI with your own CSS, and what can change in any release.
|
|
4
|
+
|
|
5
|
+
Reach for these in order: props (`color`, `fillType`, `size`), then the theme and tokens ([theming.md](theming.md)), then `className` / `style` on the component, and only then CSS against the public hooks below.
|
|
6
|
+
|
|
7
|
+
## Public: stable until a major version
|
|
8
|
+
|
|
9
|
+
| Hook | Examples | Notes |
|
|
10
|
+
| --- | --- | --- |
|
|
11
|
+
| Theme color variables | `--avl-color-primary`, `--avl-color-on-primary`, `--avl-color-surface`, `--avl-color-divider` | One per theme role (see [theming.md](theming.md)). Defined inside `AnvilRoot`. |
|
|
12
|
+
| Token variables | `--avl-spacing-x1` … `x20`, `--avl-radius-*`, `--avl-font-*`, `--avl-font-size-*`, `--avl-shadow-*`, `--avl-ease-*`, `--avl-outline-size`, `--avl-disabled-opacity` | One per key in `DesignTokens`. |
|
|
13
|
+
| Each component's root class | `.avl-button`, `.avl-card`, `.avl-menu-item`, `.avl-search-item` | `avl-` plus the component's name in kebab-case, on the element that gets `className`. `AnvilRoot` uses `.avl-root`. Components that render no element of their own (`Dialog`, `Menu`, `Popover`, `BottomSheet`, ...) have none: style their parts (`.avl-dialog-popup` is `DialogPopup`'s root class). |
|
|
14
|
+
| State attributes | `[data-checked]`, `[data-pressed]`, `[data-disabled]`, `[data-popup-open]` | Set by Base UI. Each part's attributes are in its Base UI docs (`node_modules/@base-ui/react/docs/react/components/`). |
|
|
15
|
+
|
|
16
|
+
A public variable or class that gets renamed keeps working under its old name for at least one minor version before it's removed.
|
|
17
|
+
|
|
18
|
+
## Internal: can change in any release
|
|
19
|
+
|
|
20
|
+
- Classes for parts and variants: `.avl-switch-thumb`, `.avl-button-size-big`, `.avl-color-tonal`, `.avl-fill-outlined`. Use the props instead (`size`, `color`, `fillType`).
|
|
21
|
+
- Component variables: `--avl-button-height`, `--avl-nested-color-main`, `--avl-sticker-tilt`, ...
|
|
22
|
+
- The elements inside a component: wrappers, their order, which tag they are.
|
|
23
|
+
- Visual details. Spacing, motion and shades are tuned in normal releases.
|
|
24
|
+
|
|
25
|
+
## Example
|
|
26
|
+
|
|
27
|
+
```css
|
|
28
|
+
/* Your own class next to the root class, so it wins without !important */
|
|
29
|
+
.promo.avl-card {
|
|
30
|
+
background: var(--avl-color-primary-container);
|
|
31
|
+
border-radius: var(--avl-radius-large);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/* State from Base UI */
|
|
35
|
+
.avl-switch[data-disabled] {
|
|
36
|
+
opacity: 0.3;
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
AnvilUI's rules are one or two classes. If yours loses, add the root class to it as above, or load your CSS after `anvilui/styles.css`.
|
package/docs/theming.md
CHANGED
|
@@ -37,7 +37,7 @@ import type {
|
|
|
37
37
|
| `darkTheme` | `Theme` | `baseDarkTheme` | Colors in dark mode. |
|
|
38
38
|
| `tokens` | `Partial<DesignTokens>` | `baseDesignTokens` | Spacing, radius, fonts, motion, shadows. Each category you pass **replaces** the whole default category. |
|
|
39
39
|
|
|
40
|
-
AnvilRoot renders a `<div
|
|
40
|
+
AnvilRoot renders a `<div>`, and other `<div>` props (`style`, `id`, `ref`, `data-*`, ...) go on it. There is no `theme` prop: use `lightTheme` / `darkTheme`.
|
|
41
41
|
|
|
42
42
|
## Color mode
|
|
43
43
|
|
|
@@ -100,7 +100,7 @@ export function App() {
|
|
|
100
100
|
|
|
101
101
|
- `createTheme(primaryHex, { tonal?: hex })` returns `{ light: Theme, dark: Theme }`. Hex only (`'#0B6E4F'` or `'#0B6'`); other formats throw.
|
|
102
102
|
- `createThemeFromImage(img | File | Blob | url)` returns `Promise<ThemePair>`, browser only. URLs must allow CORS.
|
|
103
|
-
- Each role keeps the lightness of the base theme, so text stays readable; only hue and colorfulness change. Error, warning and success colors stay the same.
|
|
103
|
+
- Each role keeps the lightness of the base theme, so text stays readable; only hue and colorfulness change. Error, warning and success colors stay the same, except that a green primary makes `success` blue and a red or orange primary makes `error` pink, and a yellow or gold primary makes `warning` orange, so status colors stay distinct from the brand.
|
|
104
104
|
- Tweak one role by spreading: `{ ...brand.light, primary: '#…' }`.
|
|
105
105
|
- To switch themes at runtime, keep them in state and pass them as `lightTheme` / `darkTheme`.
|
|
106
106
|
- Ready-made: `baseLightTheme` / `baseDarkTheme` (purple, the default), `monochromeLightTheme` / `monochromeDarkTheme`.
|
package/docs/time-picker.md
CHANGED
|
@@ -14,7 +14,7 @@ import type { TimePickerProps } from 'anvilui'
|
|
|
14
14
|
| `type` | `'dial' \| 'input'` | `'dial'` | |
|
|
15
15
|
| `hourCycle` | `12 \| 24` | user's locale | 12 shows AM/PM. |
|
|
16
16
|
| `label` | `ReactNode` | | Either this or `aria-label`. |
|
|
17
|
-
| `name` | `string` | | Submits `"HH:mm"` with a form. |
|
|
17
|
+
| `name` | `string` | | Submits `"HH:mm"` with a form. Put it on TimePicker itself: it doesn't work inside a `Field`. |
|
|
18
18
|
| `size` | `'small' \| 'normal'` | `'normal'` | |
|
|
19
19
|
| `disabled` | `boolean` | `false` | |
|
|
20
20
|
| `open` / `defaultOpen` / `onOpenChange` | | | The popup. |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "anvilui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "Material 3 Expressive for React, pushed further: playful, accessible components built on Base UI. Ships agent docs in AGENTS.md and docs/.",
|
|
5
5
|
"author": "itayvak",
|
|
6
6
|
"license": "MIT",
|