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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ReactNode } from 'react';
|
|
1
|
+
import { type CSSProperties, type ReactNode, type Ref } from 'react';
|
|
2
2
|
import { Autocomplete as BaseAutocomplete } from '@base-ui/react/autocomplete';
|
|
3
3
|
import type { MaterialSymbol } from 'material-symbols';
|
|
4
4
|
import '../Menu/menu.css';
|
|
@@ -6,31 +6,47 @@ import './search.css';
|
|
|
6
6
|
export type SearchProps<Item> = Omit<BaseAutocomplete.Root.Props<Item>, 'children' | 'items'> & {
|
|
7
7
|
/** The suggestions. Filtered against what's typed. */
|
|
8
8
|
items?: readonly Item[];
|
|
9
|
-
/**
|
|
10
|
-
|
|
9
|
+
/**
|
|
10
|
+
* Renders each suggestion, e.g. `(item) => <SearchItem key={item} value={item}>{item}</SearchItem>`.
|
|
11
|
+
* Leave it out for a plain search bar with no suggestion list.
|
|
12
|
+
*/
|
|
13
|
+
children?: (item: Item, index: number) => ReactNode;
|
|
11
14
|
/** Hint text inside the bar, e.g. "Search mail". */
|
|
12
15
|
placeholder?: string;
|
|
13
16
|
/** There's no visible label, so the input needs a name for screen readers. */
|
|
14
17
|
'aria-label': string;
|
|
15
18
|
/** Shown in the popup when nothing matches. Without it, the popup hides. */
|
|
16
19
|
empty?: ReactNode;
|
|
20
|
+
/**
|
|
21
|
+
* The bar's background. Use `'container'` when the bar sits on a
|
|
22
|
+
* `surface` panel, like a navigation drawer, so it doesn't blend in.
|
|
23
|
+
* @default 'surface'
|
|
24
|
+
*/
|
|
25
|
+
color?: 'surface' | 'container';
|
|
17
26
|
/** Accessible name of the clear button. @default 'Clear' */
|
|
18
27
|
clearLabel?: string;
|
|
19
28
|
/** Applied to the bar, so width and margins work as expected. */
|
|
20
29
|
className?: string;
|
|
30
|
+
/** Applied to the bar, with `className`. */
|
|
31
|
+
style?: CSSProperties;
|
|
32
|
+
/** The text `<input>`. */
|
|
33
|
+
ref?: Ref<HTMLInputElement>;
|
|
34
|
+
/** The text `<input>`'s id. */
|
|
35
|
+
id?: string;
|
|
21
36
|
};
|
|
22
37
|
/**
|
|
23
38
|
* Material 3 search bar with a list of suggestions under it. Pass `items`
|
|
24
39
|
* and it filters them as you type. The typed text is `value` /
|
|
25
|
-
* `defaultValue` / `onValueChange`. Children
|
|
26
|
-
*
|
|
40
|
+
* `defaultValue` / `onValueChange`. Children are a function that renders one
|
|
41
|
+
* suggestion; without them it's a plain search bar that never opens a list.
|
|
27
42
|
*
|
|
28
43
|
* @example
|
|
44
|
+
* <Search aria-label="Filter people" value={query} onValueChange={setQuery} />
|
|
29
45
|
* <Search aria-label="Search mail" placeholder="Search mail" items={recent} value={query} onValueChange={setQuery}>
|
|
30
46
|
* {(item: string) => <SearchItem key={item} value={item} startIcon="history">{item}</SearchItem>}
|
|
31
47
|
* </Search>
|
|
32
48
|
*/
|
|
33
|
-
export declare function Search<Item>({ children, placeholder, 'aria-label': ariaLabel, empty, clearLabel, className, ...
|
|
49
|
+
export declare function Search<Item>({ children, placeholder, 'aria-label': ariaLabel, empty, color, clearLabel, className, style, ref, id, ...allProps }: SearchProps<Item>): import("react").JSX.Element;
|
|
34
50
|
export type SearchItemProps = BaseAutocomplete.Item.Props & {
|
|
35
51
|
/** Material Symbol before the text, e.g. `history` for a recent search. */
|
|
36
52
|
startIcon?: MaterialSymbol;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ReactNode } from 'react';
|
|
1
|
+
import { type CSSProperties, type ReactNode, type Ref } from 'react';
|
|
2
2
|
import { Select as BaseSelect } from '@base-ui/react/select';
|
|
3
3
|
import '../Input/input.css';
|
|
4
4
|
import '../Menu/menu.css';
|
|
@@ -15,6 +15,10 @@ export type SelectProps<Value, Multiple extends boolean | undefined = false> = B
|
|
|
15
15
|
size?: 'small' | 'normal';
|
|
16
16
|
/** Applied to the outer wrapper, so width and margins work as expected. */
|
|
17
17
|
className?: string;
|
|
18
|
+
/** Applied to the outer wrapper, with `className`. */
|
|
19
|
+
style?: CSSProperties;
|
|
20
|
+
/** The field's button (the part that opens the list). */
|
|
21
|
+
ref?: Ref<HTMLButtonElement>;
|
|
18
22
|
};
|
|
19
23
|
/**
|
|
20
24
|
* A dropdown to pick one option (or several, with `multiple`). Put
|
|
@@ -32,7 +36,7 @@ export type SelectProps<Value, Multiple extends boolean | undefined = false> = B
|
|
|
32
36
|
* ))}
|
|
33
37
|
* </Select>
|
|
34
38
|
*/
|
|
35
|
-
export declare function Select<Value, Multiple extends boolean | undefined = false>({ label, placeholder, size, className, children, ...
|
|
39
|
+
export declare function Select<Value, Multiple extends boolean | undefined = false>({ label, placeholder, size, className, style, ref, children, ...allProps }: SelectProps<Value, Multiple>): import("react").JSX.Element;
|
|
36
40
|
export type SelectItemProps = BaseSelect.Item.Props;
|
|
37
41
|
/** One option in a `Select`. Needs a `value`; children are its label. */
|
|
38
42
|
export declare function SelectItem({ className, children, ...props }: SelectItemProps): import("react").JSX.Element;
|
|
@@ -5,7 +5,7 @@ export type SkeletonProps = React.ComponentProps<'span'> & {
|
|
|
5
5
|
* a rounded box (images, cards). Set the size with `style`.
|
|
6
6
|
* @default 'text'
|
|
7
7
|
*/
|
|
8
|
-
|
|
8
|
+
type?: 'text' | 'circular' | 'rectangular';
|
|
9
9
|
/** Fades in and out while loading. @default 'pulse' */
|
|
10
10
|
animation?: 'pulse' | 'none';
|
|
11
11
|
};
|
|
@@ -14,7 +14,7 @@ export type SkeletonProps = React.ComponentProps<'span'> & {
|
|
|
14
14
|
* put `aria-busy` on the region that's loading.
|
|
15
15
|
*
|
|
16
16
|
* @example
|
|
17
|
-
* <Skeleton
|
|
17
|
+
* <Skeleton type="circular" style={{ width: 40, height: 40 }} />
|
|
18
18
|
* <Skeleton style={{ width: '60%' }} />
|
|
19
19
|
*/
|
|
20
|
-
export declare function Skeleton({
|
|
20
|
+
export declare function Skeleton({ type, animation, className, ...props }: SkeletonProps): import("react").JSX.Element;
|
|
@@ -7,9 +7,16 @@ export type SliderProps<Value extends number | readonly number[] = number | read
|
|
|
7
7
|
showValue?: boolean;
|
|
8
8
|
/**
|
|
9
9
|
* Thin track with the selected part drawn as a moving wave, like a
|
|
10
|
-
* squiggly `Progress`. Horizontal only.
|
|
10
|
+
* squiggly `Progress`. Horizontal only. Changing it animates between the
|
|
11
|
+
* wave and the plain track, e.g. `squiggly={playing}`. @default false
|
|
11
12
|
*/
|
|
12
13
|
squiggly?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Names each handle of a range, e.g.
|
|
16
|
+
* `(i) => (i === 0 ? 'Minimum price' : 'Maximum price')`. Without it,
|
|
17
|
+
* every handle gets the same name.
|
|
18
|
+
*/
|
|
19
|
+
getAriaLabel?: (index: number) => string;
|
|
13
20
|
} & ({
|
|
14
21
|
/** Visible label above the slider. */
|
|
15
22
|
label: ReactNode;
|
|
@@ -28,4 +35,4 @@ export type SliderProps<Value extends number | readonly number[] = number | read
|
|
|
28
35
|
* <Slider label="Volume" defaultValue={50} />
|
|
29
36
|
* <Slider aria-label="Price" value={range} onValueChange={setRange} min={0} max={500} />
|
|
30
37
|
*/
|
|
31
|
-
export declare function Slider<Value extends number | readonly number[]>({ label, 'aria-label': ariaLabel, showValue, squiggly, className, ...props }: SliderProps<Value>): import("react").JSX.Element;
|
|
38
|
+
export declare function Slider<Value extends number | readonly number[]>({ label, 'aria-label': ariaLabel, showValue, squiggly, getAriaLabel, className, ...props }: SliderProps<Value>): import("react").JSX.Element;
|
|
@@ -8,8 +8,6 @@ export type WaveSpan = {
|
|
|
8
8
|
rest?: [number, number][];
|
|
9
9
|
/** Draw the `rest` pieces as waves in step with the main one, not flat. */
|
|
10
10
|
restWave?: boolean;
|
|
11
|
-
/** Draw the stop dot at the far end. */
|
|
12
|
-
dot?: boolean;
|
|
13
11
|
/** Jump straight to `from`/`to` instead of easing toward them. */
|
|
14
12
|
snap?: boolean;
|
|
15
13
|
};
|
|
@@ -27,10 +25,34 @@ export type SquigglyWaveProps = {
|
|
|
27
25
|
still?: boolean;
|
|
28
26
|
/** Run top to bottom instead of left to right. @default false */
|
|
29
27
|
vertical?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Ease into a straight line as thick as `--avl-wave-flat-stroke`, ready
|
|
30
|
+
* to be swapped for the plain track. Needs `still` off. @default false
|
|
31
|
+
*/
|
|
32
|
+
flat?: boolean;
|
|
33
|
+
/** Start out flat, to ease into a wave from the plain track. */
|
|
34
|
+
startFlat?: boolean;
|
|
35
|
+
/** Called once the wave has gone fully flat. */
|
|
36
|
+
onFlat?: () => void;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Keeps a squiggly part's wave mounted while it flattens out, so turning
|
|
40
|
+
* `squiggly` off eases into the plain track instead of jumping, and turning
|
|
41
|
+
* it on eases out of it. Spread `wave` onto SquigglyWave, and draw the plain
|
|
42
|
+
* track when `show` is false.
|
|
43
|
+
*/
|
|
44
|
+
export declare function useWaveMorph(squiggly: boolean): {
|
|
45
|
+
show: boolean;
|
|
46
|
+
wave: {
|
|
47
|
+
flat: boolean;
|
|
48
|
+
startFlat: boolean;
|
|
49
|
+
onFlat: () => void;
|
|
50
|
+
};
|
|
30
51
|
};
|
|
31
52
|
/**
|
|
32
53
|
* One continuous wave drawn to an exact length, so it has no seams and gets
|
|
33
|
-
* round ends. Redrawn every frame to ripple
|
|
34
|
-
* with reduced motion it holds still and
|
|
54
|
+
* round ends. Redrawn every frame to ripple, to ease toward its new span and
|
|
55
|
+
* to flatten out or back (`flat`); with reduced motion it holds still and
|
|
56
|
+
* jumps.
|
|
35
57
|
*/
|
|
36
58
|
export declare function SquigglyWave(props: SquigglyWaveProps): import("react").JSX.Element;
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import type { ComponentProps, ReactNode } from 'react';
|
|
1
|
+
import type { ComponentProps, CSSProperties, ReactNode } from 'react';
|
|
2
2
|
import { Input as BaseInput } from '@base-ui/react/input';
|
|
3
3
|
import '../Input/input.css';
|
|
4
4
|
import './textarea.css';
|
|
5
|
-
export type TextareaProps = Omit<ComponentProps<'textarea'>, 'className'
|
|
5
|
+
export type TextareaProps = Omit<ComponentProps<'textarea'>, 'className' | 'style'> & {
|
|
6
|
+
/** Applied to the outer wrapper, with `className`. */
|
|
7
|
+
style?: CSSProperties;
|
|
8
|
+
} & Pick<BaseInput.Props, 'onValueChange'> & {
|
|
6
9
|
/** Floating label. Sits on the first line and moves onto the border once it has focus or a value. */
|
|
7
10
|
label?: ReactNode;
|
|
8
11
|
/**
|
|
@@ -21,4 +24,4 @@ export type TextareaProps = Omit<ComponentProps<'textarea'>, 'className'> & Pick
|
|
|
21
24
|
* @example
|
|
22
25
|
* <Textarea label="Bio" rows={4} defaultValue="" />
|
|
23
26
|
*/
|
|
24
|
-
export declare function Textarea({ label, size, className, placeholder, ...props }: TextareaProps): import("react").JSX.Element;
|
|
27
|
+
export declare function Textarea({ label, size, className, style, placeholder, ...props }: TextareaProps): import("react").JSX.Element;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { type ReactNode } from 'react';
|
|
1
|
+
import { type ReactNode, type Ref } from 'react';
|
|
2
2
|
import { type PopoverProps } from '../Popover/Popover';
|
|
3
3
|
import '../Input/input.css';
|
|
4
4
|
import '../Select/select.css';
|
|
5
5
|
import './time-picker.css';
|
|
6
|
-
export type TimePickerProps = Omit<React.ComponentProps<'div'>, 'children' | 'defaultValue'> & Pick<PopoverProps, 'open' | 'defaultOpen' | 'onOpenChange'> & {
|
|
6
|
+
export type TimePickerProps = Omit<React.ComponentProps<'div'>, 'children' | 'defaultValue' | 'ref'> & Pick<PopoverProps, 'open' | 'defaultOpen' | 'onOpenChange'> & {
|
|
7
7
|
/**
|
|
8
8
|
* `dial`: tap or drag a clock face, hour then minute.
|
|
9
9
|
* `input`: type into the hour and minute boxes. @default 'dial'
|
|
@@ -13,8 +13,8 @@ export type TimePickerProps = Omit<React.ComponentProps<'div'>, 'children' | 'de
|
|
|
13
13
|
value?: string | null;
|
|
14
14
|
/** Starting time when `value` isn't controlled. @default null */
|
|
15
15
|
defaultValue?: string | null;
|
|
16
|
-
/** Called with the new `"HH:mm"` on every change. */
|
|
17
|
-
onValueChange?: (value: string) => void;
|
|
16
|
+
/** Called with the new `"HH:mm"` on every change, or `null` once it's cleared. */
|
|
17
|
+
onValueChange?: (value: string | null) => void;
|
|
18
18
|
/** 12 shows AM/PM. @default the user's locale */
|
|
19
19
|
hourCycle?: 12 | 24;
|
|
20
20
|
/** @default false */
|
|
@@ -26,6 +26,8 @@ export type TimePickerProps = Omit<React.ComponentProps<'div'>, 'children' | 'de
|
|
|
26
26
|
size?: 'small' | 'normal';
|
|
27
27
|
/** Submits the value with a form, as `"HH:mm"`. */
|
|
28
28
|
name?: string;
|
|
29
|
+
/** The field's button (the part that opens the picker). */
|
|
30
|
+
ref?: Ref<HTMLButtonElement>;
|
|
29
31
|
} & ({
|
|
30
32
|
/** Floating label, like Input's. */
|
|
31
33
|
label: ReactNode;
|
|
@@ -42,4 +44,4 @@ export type TimePickerProps = Omit<React.ComponentProps<'div'>, 'children' | 'de
|
|
|
42
44
|
* @example
|
|
43
45
|
* <TimePicker label="Alarm" defaultValue="07:30" onValueChange={setTime} />
|
|
44
46
|
*/
|
|
45
|
-
export declare function TimePicker({ type, value: valueProp, defaultValue, onValueChange, hourCycle, label, 'aria-label': ariaLabel, disabled, size, name, open, defaultOpen, onOpenChange, className, ...
|
|
47
|
+
export declare function TimePicker({ type, value: valueProp, defaultValue, onValueChange, hourCycle, label, 'aria-label': ariaLabel, disabled, size, name, open, defaultOpen, onOpenChange, className, ref, id, ...allProps }: TimePickerProps): import("react").JSX.Element;
|
|
@@ -28,7 +28,8 @@ export type ToggleProps = Omit<BaseToggle.Props, 'children'> & ColorProps & {
|
|
|
28
28
|
children?: never;
|
|
29
29
|
startIcon?: never;
|
|
30
30
|
endIcon?: never;
|
|
31
|
-
|
|
31
|
+
/** 32px, 40px or 48px, like `IconButton`. @default 'normal' */
|
|
32
|
+
size?: 'small' | 'normal' | 'big';
|
|
32
33
|
});
|
|
33
34
|
/**
|
|
34
35
|
* A button that stays on or off, like Bold or Favorite. Holds its state
|
|
@@ -8,7 +8,7 @@ type ToggleGroupCommonProps = ColorProps & {
|
|
|
8
8
|
/** Same heights as `Button`. @default 'normal' */
|
|
9
9
|
size?: 'small' | 'normal' | 'big';
|
|
10
10
|
};
|
|
11
|
-
export type ToggleGroupProps<Value =
|
|
11
|
+
export type ToggleGroupProps<Value = unknown> = ToggleGroupCommonProps & ((BaseRadioGroup.Props<Value> & {
|
|
12
12
|
/**
|
|
13
13
|
* Let several segments be on at once. `value` is then an array
|
|
14
14
|
* of strings. Without it, `value` is a single value, not an
|
|
@@ -36,7 +36,7 @@ export type ToggleGroupProps<Value = any> = ToggleGroupCommonProps & ((BaseRadio
|
|
|
36
36
|
* </ToggleGroup>
|
|
37
37
|
*/
|
|
38
38
|
export declare function ToggleGroup<Value>({ size, color, fillType, multiple, children, className, ref, ...props }: ToggleGroupProps<Value>): import("react").JSX.Element;
|
|
39
|
-
export type ToggleGroupItemProps<Value =
|
|
39
|
+
export type ToggleGroupItemProps<Value = unknown> = BaseRadio.Root.Props<Value> & {
|
|
40
40
|
/** Material Symbol shown before the label. */
|
|
41
41
|
startIcon?: MaterialSymbol;
|
|
42
42
|
/** Material Symbol shown after the label. */
|
package/dist/dev.d.ts
CHANGED
|
@@ -8,8 +8,13 @@ export declare const POPUP_OUTSIDE_ROOT = "Its popup portals to <body>, outside
|
|
|
8
8
|
export declare const OUTSIDE_ROOT = "The theme variables only exist inside AnvilRoot, so it shows without colors, spacing or fonts.";
|
|
9
9
|
/** Components need AnvilRoot for the theme and as the portal target. */
|
|
10
10
|
export declare function checkRoot(found: boolean, component: string, reason?: string): void;
|
|
11
|
-
|
|
11
|
+
export declare const NO_TEXT = "It shows no text, so screen readers need an `aria-label`.";
|
|
12
|
+
export declare const UNNAMED_GROUP = "Screen readers announce the group without saying what it's for: give it an `aria-label`.";
|
|
13
|
+
export declare const UNNAMED_NAV = "Screen readers list it as just \"navigation\": give it an `aria-label` to tell it apart from other navigation.";
|
|
14
|
+
/** A `<fieldset>` with a `<legend>` already names the group of controls inside it. */
|
|
15
|
+
export declare function inNamedFieldset(el: Element | null): boolean;
|
|
16
|
+
/** For controls and groups with no visible name: it must come from aria-label. */
|
|
12
17
|
export declare function checkName(props: {
|
|
13
18
|
'aria-label'?: unknown;
|
|
14
19
|
'aria-labelledby'?: unknown;
|
|
15
|
-
}, component: string, example: string, doc: string): void;
|
|
20
|
+
}, component: string, example: string, doc: string, reason?: string): void;
|