sonahang-ui 1.0.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/LICENSE +21 -0
- package/README.md +125 -0
- package/dist/components/Accordion/Accordion.d.ts +36 -0
- package/dist/components/Accordion/AccordionItem.d.ts +15 -0
- package/dist/components/Accordion/accordion.context.d.ts +18 -0
- package/dist/components/Accordion/index.d.ts +5 -0
- package/dist/components/Alert/Alert.d.ts +24 -0
- package/dist/components/Alert/alert.tokens.d.ts +2 -0
- package/dist/components/Alert/index.d.ts +4 -0
- package/dist/components/Avatar/Avatar.d.ts +17 -0
- package/dist/components/Avatar/AvatarGroup.d.ts +12 -0
- package/dist/components/Avatar/avatar.context.d.ts +7 -0
- package/dist/components/Avatar/avatar.tokens.d.ts +2 -0
- package/dist/components/Avatar/getInitials.d.ts +6 -0
- package/dist/components/Avatar/index.d.ts +6 -0
- package/dist/components/Breadcrumb/Breadcrumb.d.ts +19 -0
- package/dist/components/Breadcrumb/BreadcrumbItem.d.ts +25 -0
- package/dist/components/Breadcrumb/breadcrumb.context.d.ts +10 -0
- package/dist/components/Breadcrumb/index.d.ts +4 -0
- package/dist/components/Button/Button.d.ts +20 -0
- package/dist/components/Button/button.tokens.d.ts +4 -0
- package/dist/components/Button/buttonClassNames.d.ts +17 -0
- package/dist/components/Button/index.d.ts +6 -0
- package/dist/components/Checkbox/Checkbox.d.ts +24 -0
- package/dist/components/Checkbox/CheckboxGroup.d.ts +28 -0
- package/dist/components/Checkbox/checkbox.context.d.ts +17 -0
- package/dist/components/Checkbox/index.d.ts +4 -0
- package/dist/components/Chip/Chip.d.ts +21 -0
- package/dist/components/Chip/chip.tokens.d.ts +4 -0
- package/dist/components/Chip/index.d.ts +4 -0
- package/dist/components/CodeBlock/CodeBlock.d.ts +41 -0
- package/dist/components/CodeBlock/dedentCode.d.ts +12 -0
- package/dist/components/CodeBlock/index.d.ts +3 -0
- package/dist/components/Dialog/Dialog.d.ts +70 -0
- package/dist/components/Dialog/dialog.tokens.d.ts +8 -0
- package/dist/components/Dialog/index.d.ts +4 -0
- package/dist/components/Drawer/Drawer.d.ts +72 -0
- package/dist/components/Drawer/drawer.tokens.d.ts +10 -0
- package/dist/components/Drawer/index.d.ts +4 -0
- package/dist/components/Dropdown/Dropdown.d.ts +24 -0
- package/dist/components/Dropdown/DropdownItem.d.ts +16 -0
- package/dist/components/Dropdown/DropdownMenu.d.ts +13 -0
- package/dist/components/Dropdown/DropdownSeparator.d.ts +10 -0
- package/dist/components/Dropdown/DropdownTrigger.d.ts +8 -0
- package/dist/components/Dropdown/dropdown.context.d.ts +24 -0
- package/dist/components/Dropdown/index.d.ts +11 -0
- package/dist/components/EmptyState/EmptyState.d.ts +47 -0
- package/dist/components/EmptyState/index.d.ts +2 -0
- package/dist/components/FileDrop/FileDrop.d.ts +41 -0
- package/dist/components/FileDrop/index.d.ts +3 -0
- package/dist/components/FileDrop/isFileAccepted.d.ts +11 -0
- package/dist/components/Input/Input.d.ts +20 -0
- package/dist/components/Input/index.d.ts +2 -0
- package/dist/components/InputOtp/InputOtp.d.ts +39 -0
- package/dist/components/InputOtp/index.d.ts +4 -0
- package/dist/components/InputOtp/sanitizeOtpValue.d.ts +20 -0
- package/dist/components/MinMaxSlider/MinMaxSlider.d.ts +41 -0
- package/dist/components/MinMaxSlider/index.d.ts +2 -0
- package/dist/components/Pagination/Pagination.d.ts +41 -0
- package/dist/components/Pagination/getPaginationRange.d.ts +25 -0
- package/dist/components/Pagination/index.d.ts +4 -0
- package/dist/components/ProgressBar/ProgressBar.d.ts +34 -0
- package/dist/components/ProgressBar/index.d.ts +4 -0
- package/dist/components/ProgressBar/progressBar.tokens.d.ts +2 -0
- package/dist/components/Radio/Radio.d.ts +18 -0
- package/dist/components/Radio/RadioGroup.d.ts +28 -0
- package/dist/components/Radio/index.d.ts +4 -0
- package/dist/components/Radio/radio.context.d.ts +17 -0
- package/dist/components/RangeSlider/RangeSlider.d.ts +36 -0
- package/dist/components/RangeSlider/index.d.ts +2 -0
- package/dist/components/SegmentedControl/SegmentedControl.d.ts +39 -0
- package/dist/components/SegmentedControl/index.d.ts +2 -0
- package/dist/components/Select/Select.d.ts +39 -0
- package/dist/components/Select/index.d.ts +2 -0
- package/dist/components/Skeleton/Skeleton.d.ts +24 -0
- package/dist/components/Skeleton/index.d.ts +4 -0
- package/dist/components/Skeleton/skeleton.tokens.d.ts +4 -0
- package/dist/components/Spinner/Spinner.d.ts +22 -0
- package/dist/components/Spinner/index.d.ts +4 -0
- package/dist/components/Spinner/spinner.tokens.d.ts +2 -0
- package/dist/components/Stepper/Step.d.ts +20 -0
- package/dist/components/Stepper/Stepper.d.ts +25 -0
- package/dist/components/Stepper/index.d.ts +5 -0
- package/dist/components/Stepper/stepper.context.d.ts +14 -0
- package/dist/components/Switch/Switch.d.ts +22 -0
- package/dist/components/Switch/SwitchGroup.d.ts +30 -0
- package/dist/components/Switch/index.d.ts +4 -0
- package/dist/components/Switch/switch.context.d.ts +19 -0
- package/dist/components/Tabs/Tab.d.ts +10 -0
- package/dist/components/Tabs/TabList.d.ts +20 -0
- package/dist/components/Tabs/TabPanel.d.ts +16 -0
- package/dist/components/Tabs/Tabs.d.ts +22 -0
- package/dist/components/Tabs/index.d.ts +9 -0
- package/dist/components/Tabs/tabs.context.d.ts +24 -0
- package/dist/components/Tag/Tag.d.ts +10 -0
- package/dist/components/Tag/index.d.ts +4 -0
- package/dist/components/Tag/tag.tokens.d.ts +2 -0
- package/dist/components/Text/Text.d.ts +19 -0
- package/dist/components/Text/index.d.ts +4 -0
- package/dist/components/Text/text.tokens.d.ts +8 -0
- package/dist/components/Textarea/Textarea.d.ts +19 -0
- package/dist/components/Textarea/index.d.ts +2 -0
- package/dist/components/Tooltip/Tooltip.d.ts +44 -0
- package/dist/components/Tooltip/index.d.ts +4 -0
- package/dist/components/Tooltip/resolveTooltipPlacement.d.ts +39 -0
- package/dist/index.d.ts +82 -0
- package/dist/internal/bodyScrollLock.d.ts +2 -0
- package/dist/internal/portalInto.d.ts +7 -0
- package/dist/internal/useModalSurface.d.ts +27 -0
- package/dist/sonahang-ui.cjs +7 -0
- package/dist/sonahang-ui.cjs.map +1 -0
- package/dist/sonahang-ui.css +2 -0
- package/dist/sonahang-ui.js +2578 -0
- package/dist/sonahang-ui.js.map +1 -0
- package/dist/tokens/colors.d.ts +167 -0
- package/package.json +101 -0
- package/style.css.d.ts +17 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { HTMLAttributes, ReactNode } from "react";
|
|
2
|
+
import type { ProgressBarSize } from "./progressBar.tokens";
|
|
3
|
+
import "./ProgressBar.css";
|
|
4
|
+
export type ProgressBarProps = {
|
|
5
|
+
/**
|
|
6
|
+
* Progress so far, between `0` and `max`. Omit for an indeterminate bar —
|
|
7
|
+
* for work whose duration isn't known yet.
|
|
8
|
+
*/
|
|
9
|
+
value?: number;
|
|
10
|
+
/** Upper bound of `value`. Defaults to `100`. */
|
|
11
|
+
max?: number;
|
|
12
|
+
/** Visible label above the track. Provide this or `aria-label`. */
|
|
13
|
+
label?: ReactNode;
|
|
14
|
+
/** Shows the percentage beside the label. Ignored when indeterminate. */
|
|
15
|
+
showValue?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Formats the displayed value. Also drives `aria-valuetext`, so screen
|
|
18
|
+
* readers announce "3 of 8 files" rather than a bare percentage.
|
|
19
|
+
*/
|
|
20
|
+
formatValue?: (value: number, max: number) => string;
|
|
21
|
+
/** Track thickness. Defaults to `md`. */
|
|
22
|
+
size?: ProgressBarSize;
|
|
23
|
+
/** Accessible name when there's no visible `label`. */
|
|
24
|
+
"aria-label"?: string;
|
|
25
|
+
className?: string;
|
|
26
|
+
} & Omit<HTMLAttributes<HTMLDivElement>, "className" | "role">;
|
|
27
|
+
/**
|
|
28
|
+
* Horizontal progress indicator.
|
|
29
|
+
*
|
|
30
|
+
* Renders `role="progressbar"`, with `aria-valuenow` omitted when
|
|
31
|
+
* indeterminate — that absence is what tells assistive tech the duration
|
|
32
|
+
* isn't known, rather than it sitting at zero.
|
|
33
|
+
*/
|
|
34
|
+
export declare function ProgressBar({ value, max, label, showValue, formatValue, size, "aria-label": ariaLabel, className, ...props }: ProgressBarProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { InputHTMLAttributes, ReactNode } from "react";
|
|
2
|
+
import "./Radio.css";
|
|
3
|
+
export type RadioProps = {
|
|
4
|
+
/** Value this option represents. Required when inside a `RadioGroup`. */
|
|
5
|
+
value?: string;
|
|
6
|
+
/** Visible label sitting beside the control. */
|
|
7
|
+
label?: ReactNode;
|
|
8
|
+
/** Class for the wrapping `<label>`. Use `inputClassName` for the control. */
|
|
9
|
+
className?: string;
|
|
10
|
+
/** Class for the underlying `<input type="radio">`. */
|
|
11
|
+
inputClassName?: string;
|
|
12
|
+
} & Omit<InputHTMLAttributes<HTMLInputElement>, "type" | "value" | "className">;
|
|
13
|
+
/**
|
|
14
|
+
* A single radio option. Usually rendered inside a `RadioGroup`, which
|
|
15
|
+
* supplies the shared `name` and selection; works standalone too, in which
|
|
16
|
+
* case `name`/`checked`/`onChange` behave like a plain `<input type="radio">`.
|
|
17
|
+
*/
|
|
18
|
+
export declare function Radio({ value, label, className, inputClassName, name, checked, disabled, onChange, ...props }: RadioProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import "./Radio.css";
|
|
3
|
+
export type RadioGroupProps = {
|
|
4
|
+
children?: ReactNode;
|
|
5
|
+
/** Selected value — makes the group controlled. */
|
|
6
|
+
value?: string;
|
|
7
|
+
/** Initial selection when uncontrolled. */
|
|
8
|
+
defaultValue?: string;
|
|
9
|
+
/** Fired with the newly selected value. */
|
|
10
|
+
onChange?: (value: string) => void;
|
|
11
|
+
/** Visible label for the group. Provide this or `aria-label`. */
|
|
12
|
+
label?: ReactNode;
|
|
13
|
+
/** Hint shown below the options. Replaced by `error` when that's set. */
|
|
14
|
+
helperText?: ReactNode;
|
|
15
|
+
/** Validation message. Its presence also marks the group invalid. */
|
|
16
|
+
error?: ReactNode;
|
|
17
|
+
/** Radio group name. Auto-generated when omitted. */
|
|
18
|
+
name?: string;
|
|
19
|
+
/** Layout direction for the options. Defaults to `vertical`. */
|
|
20
|
+
orientation?: "vertical" | "horizontal";
|
|
21
|
+
/** Disables every option in the group. */
|
|
22
|
+
disabled?: boolean;
|
|
23
|
+
/** Accessible name when there's no visible `label`. */
|
|
24
|
+
"aria-label"?: string;
|
|
25
|
+
className?: string;
|
|
26
|
+
};
|
|
27
|
+
/** Groups `Radio` options, coordinating their shared name and selection. */
|
|
28
|
+
export declare function RadioGroup({ children, value, defaultValue, onChange, label, helperText, error, name, orientation, disabled, "aria-label": ariaLabel, className, }: RadioGroupProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export type RadioGroupContextValue = {
|
|
2
|
+
/** Shared `name`, which is what makes the browser treat them as one group. */
|
|
3
|
+
name: string;
|
|
4
|
+
/** Currently selected value in the group. */
|
|
5
|
+
value?: string;
|
|
6
|
+
/** Called with the newly selected value. */
|
|
7
|
+
onSelect: (value: string) => void;
|
|
8
|
+
/** Set when the whole group is disabled. */
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Lets `RadioGroup` coordinate its `Radio` children without cloning them.
|
|
13
|
+
* A `Radio` used outside a group falls back to its own props.
|
|
14
|
+
* Kept in its own module so the component files only export components
|
|
15
|
+
* (see the react-refresh rule in eslint.config.js).
|
|
16
|
+
*/
|
|
17
|
+
export declare const RadioGroupContext: import("react").Context<RadioGroupContextValue | undefined>;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { InputHTMLAttributes, ReactNode } from "react";
|
|
2
|
+
import "./RangeSlider.css";
|
|
3
|
+
export type RangeSliderProps = {
|
|
4
|
+
/** Visible label, associated with the slider via `htmlFor`/`id`. */
|
|
5
|
+
label?: ReactNode;
|
|
6
|
+
/** Hint shown below the slider. Replaced by `error` when that's set. */
|
|
7
|
+
helperText?: ReactNode;
|
|
8
|
+
/** Validation message. Its presence also marks the slider invalid. */
|
|
9
|
+
error?: ReactNode;
|
|
10
|
+
/** Current value — makes the slider controlled. */
|
|
11
|
+
value?: number;
|
|
12
|
+
/** Initial value when uncontrolled. Defaults to `min`. */
|
|
13
|
+
defaultValue?: number;
|
|
14
|
+
/** Fired with the new value. */
|
|
15
|
+
onChange?: (value: number) => void;
|
|
16
|
+
min?: number;
|
|
17
|
+
max?: number;
|
|
18
|
+
step?: number;
|
|
19
|
+
/** Shows the current value beside the label. */
|
|
20
|
+
showValue?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Formats the displayed value. Also drives `aria-valuetext`, so screen
|
|
23
|
+
* readers announce "$50" rather than a bare "50".
|
|
24
|
+
*/
|
|
25
|
+
formatValue?: (value: number) => string;
|
|
26
|
+
/** Class for the wrapper element. Use `inputClassName` for the input. */
|
|
27
|
+
className?: string;
|
|
28
|
+
/** Class for the underlying `<input type="range">`. */
|
|
29
|
+
inputClassName?: string;
|
|
30
|
+
} & Omit<InputHTMLAttributes<HTMLInputElement>, "type" | "value" | "defaultValue" | "onChange" | "min" | "max" | "step" | "className">;
|
|
31
|
+
/**
|
|
32
|
+
* Single-value slider built on the native `<input type="range">`, so
|
|
33
|
+
* `role="slider"`, the value announcements, keyboard stepping, and form
|
|
34
|
+
* submission all come from the platform.
|
|
35
|
+
*/
|
|
36
|
+
export declare function RangeSlider({ label, helperText, error, value, defaultValue, onChange, min, max, step, showValue, formatValue, className, inputClassName, id, disabled, "aria-describedby": ariaDescribedBy, ...props }: RangeSliderProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import "./SegmentedControl.css";
|
|
3
|
+
export type SegmentedControlOption = {
|
|
4
|
+
/** Value reported to `onChange` and submitted with a form. */
|
|
5
|
+
value: string;
|
|
6
|
+
/** Visible content for the segment. */
|
|
7
|
+
label: ReactNode;
|
|
8
|
+
/** Disables just this segment. */
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
};
|
|
11
|
+
export type SegmentedControlProps = {
|
|
12
|
+
/** The segments, in display order. */
|
|
13
|
+
options: SegmentedControlOption[];
|
|
14
|
+
/** Selected value — makes the component controlled. */
|
|
15
|
+
value?: string;
|
|
16
|
+
/** Initial selection when uncontrolled. */
|
|
17
|
+
defaultValue?: string;
|
|
18
|
+
/** Fired with the newly selected value. */
|
|
19
|
+
onChange?: (value: string) => void;
|
|
20
|
+
/** Visible label for the group. Provide this or `aria-label`. */
|
|
21
|
+
label?: ReactNode;
|
|
22
|
+
/** Radio group name. Auto-generated when omitted. */
|
|
23
|
+
name?: string;
|
|
24
|
+
/** Stretches the control to fill its container, splitting segments evenly. */
|
|
25
|
+
fullWidth?: boolean;
|
|
26
|
+
/** Disables every segment. */
|
|
27
|
+
disabled?: boolean;
|
|
28
|
+
/** Accessible name when there's no visible `label`. */
|
|
29
|
+
"aria-label"?: string;
|
|
30
|
+
className?: string;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Single-select control rendered as a row of blocks.
|
|
34
|
+
*
|
|
35
|
+
* Built on native `<input type="radio">` rather than `role="radio"` buttons,
|
|
36
|
+
* so arrow-key navigation, group semantics, and form submission all come
|
|
37
|
+
* from the platform instead of being reimplemented.
|
|
38
|
+
*/
|
|
39
|
+
export declare function SegmentedControl({ options, value, defaultValue, onChange, label, name, fullWidth, disabled, "aria-label": ariaLabel, className, }: SegmentedControlProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { ReactNode, SelectHTMLAttributes } from "react";
|
|
2
|
+
import "./Select.css";
|
|
3
|
+
export type SelectOption = {
|
|
4
|
+
value: string;
|
|
5
|
+
label: string;
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
};
|
|
8
|
+
export type SelectOptionGroup = {
|
|
9
|
+
label: string;
|
|
10
|
+
options: SelectOption[];
|
|
11
|
+
};
|
|
12
|
+
export type SelectProps = {
|
|
13
|
+
/** Visible label, associated with the select via `htmlFor`/`id`. */
|
|
14
|
+
label?: ReactNode;
|
|
15
|
+
/** Hint shown below the select. Replaced by `error` when that's set. */
|
|
16
|
+
helperText?: ReactNode;
|
|
17
|
+
/** Validation message. Its presence also marks the select invalid. */
|
|
18
|
+
error?: ReactNode;
|
|
19
|
+
/** Options to render. Omit and pass `children` to build them yourself. */
|
|
20
|
+
options?: (SelectOption | SelectOptionGroup)[];
|
|
21
|
+
/** Prompt shown while nothing is chosen. Rendered as an unselectable option. */
|
|
22
|
+
placeholder?: string;
|
|
23
|
+
/** Decorative icon rendered at the start of the field. */
|
|
24
|
+
icon?: ReactNode;
|
|
25
|
+
/** Class for the wrapper element. Use `selectClassName` for the control. */
|
|
26
|
+
className?: string;
|
|
27
|
+
/** Class for the underlying `<select>`. */
|
|
28
|
+
selectClassName?: string;
|
|
29
|
+
children?: ReactNode;
|
|
30
|
+
} & Omit<SelectHTMLAttributes<HTMLSelectElement>, "className">;
|
|
31
|
+
/**
|
|
32
|
+
* Dropdown built on the native `<select>`, so keyboard support, type-ahead,
|
|
33
|
+
* form submission, and the platform's own picker on mobile all come for free.
|
|
34
|
+
*
|
|
35
|
+
* The closed control is fully styled; the open list is drawn by the OS and
|
|
36
|
+
* can't be. A component that needs custom option rendering, search, or
|
|
37
|
+
* multi-select chips would be a different, much larger widget.
|
|
38
|
+
*/
|
|
39
|
+
export declare function Select({ label, helperText, error, options, placeholder, icon, className, selectClassName, children, id, required, disabled, multiple, "aria-describedby": ariaDescribedBy, ...props }: SelectProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { HTMLAttributes } from "react";
|
|
2
|
+
import type { SkeletonAnimation, SkeletonVariant } from "./skeleton.tokens";
|
|
3
|
+
import "./Skeleton.css";
|
|
4
|
+
export type SkeletonProps = {
|
|
5
|
+
/** Shape of the placeholder. Defaults to `text`. */
|
|
6
|
+
variant?: SkeletonVariant;
|
|
7
|
+
/** Width. A number is treated as pixels. */
|
|
8
|
+
width?: number | string;
|
|
9
|
+
/** Height. A number is treated as pixels. Circular falls back to `width`. */
|
|
10
|
+
height?: number | string;
|
|
11
|
+
/** Number of text lines to render. Only meaningful for `text`. */
|
|
12
|
+
lines?: number;
|
|
13
|
+
/** Placeholder motion. Defaults to `pulse`. */
|
|
14
|
+
animation?: SkeletonAnimation;
|
|
15
|
+
className?: string;
|
|
16
|
+
} & Omit<HTMLAttributes<HTMLDivElement>, "className">;
|
|
17
|
+
/**
|
|
18
|
+
* Placeholder shown while content loads.
|
|
19
|
+
*
|
|
20
|
+
* Hidden from assistive tech: a screen reader shouldn't announce a wall of
|
|
21
|
+
* empty boxes. The surrounding region is what should carry the loading state —
|
|
22
|
+
* `aria-busy`, or a `Spinner`/live region alongside it.
|
|
23
|
+
*/
|
|
24
|
+
export declare function Skeleton({ variant, width, height, lines, animation, className, ...props }: SkeletonProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const skeletonVariants: readonly ["text", "rectangular", "circular"];
|
|
2
|
+
export type SkeletonVariant = (typeof skeletonVariants)[number];
|
|
3
|
+
export declare const skeletonAnimations: readonly ["pulse", "wave", "none"];
|
|
4
|
+
export type SkeletonAnimation = (typeof skeletonAnimations)[number];
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { HTMLAttributes, ReactNode } from "react";
|
|
2
|
+
import type { SpinnerSize } from "./spinner.tokens";
|
|
3
|
+
import "./Spinner.css";
|
|
4
|
+
export type SpinnerProps = {
|
|
5
|
+
/** Size of the ring. Defaults to `md`. */
|
|
6
|
+
size?: SpinnerSize;
|
|
7
|
+
/**
|
|
8
|
+
* What's being waited on. Always in the accessibility tree — a spinner with
|
|
9
|
+
* no name announces nothing. Defaults to "Loading".
|
|
10
|
+
*/
|
|
11
|
+
label?: ReactNode;
|
|
12
|
+
/** Also renders the label visibly beside the ring. */
|
|
13
|
+
showLabel?: boolean;
|
|
14
|
+
className?: string;
|
|
15
|
+
} & Omit<HTMLAttributes<HTMLSpanElement>, "className" | "role">;
|
|
16
|
+
/**
|
|
17
|
+
* Indeterminate loading indicator.
|
|
18
|
+
*
|
|
19
|
+
* Takes its colour from `currentColor`, so it inherits whatever it's placed
|
|
20
|
+
* in — a button, a link, a paragraph — instead of needing a colour prop.
|
|
21
|
+
*/
|
|
22
|
+
export declare function Spinner({ size, label, showLabel, className, ...props }: SpinnerProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import type { StepStatus } from "./stepper.context";
|
|
3
|
+
import "./Stepper.css";
|
|
4
|
+
export type StepProps = {
|
|
5
|
+
/** Short name for the step. */
|
|
6
|
+
title: ReactNode;
|
|
7
|
+
/** Optional detail below the title. */
|
|
8
|
+
description?: ReactNode;
|
|
9
|
+
/** Overrides the status derived from position. */
|
|
10
|
+
status?: StepStatus;
|
|
11
|
+
/** Replaces the number or state glyph in the indicator. */
|
|
12
|
+
icon?: ReactNode;
|
|
13
|
+
/** Makes the step activatable, for going back to an earlier one. */
|
|
14
|
+
onClick?: () => void;
|
|
15
|
+
/** Prevents activation. Only meaningful alongside `onClick`. */
|
|
16
|
+
disabled?: boolean;
|
|
17
|
+
className?: string;
|
|
18
|
+
};
|
|
19
|
+
/** One step in a `Stepper`. */
|
|
20
|
+
export declare function Step({ title, description, status, icon, onClick, disabled, className, }: StepProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { HTMLAttributes, ReactNode } from "react";
|
|
2
|
+
import type { StepperOrientation } from "./stepper.context";
|
|
3
|
+
import "./Stepper.css";
|
|
4
|
+
export type StepperProps = {
|
|
5
|
+
children?: ReactNode;
|
|
6
|
+
/** Zero-based index of the step in progress. */
|
|
7
|
+
activeStep?: number;
|
|
8
|
+
/** Layout direction. Defaults to `horizontal`. */
|
|
9
|
+
orientation?: StepperOrientation;
|
|
10
|
+
/** Accessible name for the list. Defaults to "Progress". */
|
|
11
|
+
"aria-label"?: string;
|
|
12
|
+
className?: string;
|
|
13
|
+
} & Omit<HTMLAttributes<HTMLOListElement>, "className">;
|
|
14
|
+
/**
|
|
15
|
+
* Ordered progress through a multi-step flow.
|
|
16
|
+
*
|
|
17
|
+
* An `ol`, because the order is the meaning. Each step's status is derived
|
|
18
|
+
* from its position against `activeStep` — the position is what makes a step
|
|
19
|
+
* complete or upcoming, so callers shouldn't have to restate it.
|
|
20
|
+
*
|
|
21
|
+
* It's a progress indicator, not a `nav` landmark: steps are only navigation
|
|
22
|
+
* when they're given an `onClick`, and a landmark per progress bar would
|
|
23
|
+
* clutter the landmark list.
|
|
24
|
+
*/
|
|
25
|
+
export declare function Stepper({ children, activeStep, orientation, "aria-label": ariaLabel, className, ...props }: StepperProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export type StepperOrientation = "horizontal" | "vertical";
|
|
2
|
+
/** Derived from position against `activeStep`, unless a step overrides it. */
|
|
3
|
+
export type StepStatus = "complete" | "current" | "upcoming" | "error";
|
|
4
|
+
export type StepContextValue = {
|
|
5
|
+
/** Zero-based position, used for the default indicator number. */
|
|
6
|
+
index: number;
|
|
7
|
+
/** True for the final step, which has no connector after it. */
|
|
8
|
+
isLast: boolean;
|
|
9
|
+
status: StepStatus;
|
|
10
|
+
orientation: StepperOrientation;
|
|
11
|
+
};
|
|
12
|
+
export declare const StepContext: import("react").Context<StepContextValue | undefined>;
|
|
13
|
+
/** Reads the surrounding `Stepper`, failing loudly rather than silently. */
|
|
14
|
+
export declare function useStepContext(component: string): StepContextValue;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { InputHTMLAttributes, ReactNode } from "react";
|
|
2
|
+
import "./Switch.css";
|
|
3
|
+
export type SwitchProps = {
|
|
4
|
+
/** Value this switch represents. Required when inside a `SwitchGroup`. */
|
|
5
|
+
value?: string;
|
|
6
|
+
/** Visible label sitting beside the control. */
|
|
7
|
+
label?: ReactNode;
|
|
8
|
+
/** Which side the label sits on. Defaults to `right`, or the group's setting. */
|
|
9
|
+
labelPosition?: "left" | "right";
|
|
10
|
+
/** Class for the wrapping `<label>`. Use `inputClassName` for the control. */
|
|
11
|
+
className?: string;
|
|
12
|
+
/** Class for the underlying `<input>`. */
|
|
13
|
+
inputClassName?: string;
|
|
14
|
+
} & Omit<InputHTMLAttributes<HTMLInputElement>, "type" | "value" | "className">;
|
|
15
|
+
/**
|
|
16
|
+
* Boolean toggle for a setting that applies immediately.
|
|
17
|
+
*
|
|
18
|
+
* Renders a checkbox with `role="switch"`, so it's announced as on/off rather
|
|
19
|
+
* than checked/unchecked. Works standalone, or inside a `SwitchGroup` which
|
|
20
|
+
* supplies the shared name and selection.
|
|
21
|
+
*/
|
|
22
|
+
export declare function Switch({ value, label, labelPosition, className, inputClassName, name, checked, disabled, onChange, ...props }: SwitchProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import "./Switch.css";
|
|
3
|
+
export type SwitchGroupProps = {
|
|
4
|
+
children?: ReactNode;
|
|
5
|
+
/** Values of the switches that are on — makes the group controlled. */
|
|
6
|
+
value?: string[];
|
|
7
|
+
/** Initially-on switches when uncontrolled. */
|
|
8
|
+
defaultValue?: string[];
|
|
9
|
+
/** Fired with the full list of switches that are on. */
|
|
10
|
+
onChange?: (value: string[]) => void;
|
|
11
|
+
/** Visible label for the group. Provide this or `aria-label`. */
|
|
12
|
+
label?: ReactNode;
|
|
13
|
+
/** Hint shown below the switches. Replaced by `error` when that's set. */
|
|
14
|
+
helperText?: ReactNode;
|
|
15
|
+
/** Validation message. Its presence also marks the group invalid. */
|
|
16
|
+
error?: ReactNode;
|
|
17
|
+
/** Shared field name for the switches. Auto-generated when omitted. */
|
|
18
|
+
name?: string;
|
|
19
|
+
/** Layout direction for the switches. Defaults to `vertical`. */
|
|
20
|
+
orientation?: "vertical" | "horizontal";
|
|
21
|
+
/** Default label side for every switch in the group. Individual props win. */
|
|
22
|
+
labelPosition?: "left" | "right";
|
|
23
|
+
/** Disables every switch in the group. */
|
|
24
|
+
disabled?: boolean;
|
|
25
|
+
/** Accessible name when there's no visible `label`. */
|
|
26
|
+
"aria-label"?: string;
|
|
27
|
+
className?: string;
|
|
28
|
+
};
|
|
29
|
+
/** Groups `Switch` toggles, coordinating their shared name and state. */
|
|
30
|
+
export declare function SwitchGroup({ children, value, defaultValue, onChange, label, helperText, error, name, orientation, labelPosition, disabled, "aria-label": ariaLabel, className, }: SwitchGroupProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export type SwitchGroupContextValue = {
|
|
2
|
+
/** Shared `name`, so the switches submit together as one field. */
|
|
3
|
+
name: string;
|
|
4
|
+
/** Values of the switches currently on. Each toggles independently. */
|
|
5
|
+
value: string[];
|
|
6
|
+
/** Called with the switch's value when it's turned on or off. */
|
|
7
|
+
onToggle: (value: string, checked: boolean) => void;
|
|
8
|
+
/** Set when the whole group is disabled. */
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
/** Default label side for the group's switches. */
|
|
11
|
+
labelPosition?: "left" | "right";
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Lets `SwitchGroup` coordinate its `Switch` children without cloning them.
|
|
15
|
+
* A `Switch` used outside a group falls back to its own props.
|
|
16
|
+
* Kept in its own module so the component files only export components
|
|
17
|
+
* (see the react-refresh rule in eslint.config.js).
|
|
18
|
+
*/
|
|
19
|
+
export declare const SwitchGroupContext: import("react").Context<SwitchGroupContextValue | undefined>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ButtonHTMLAttributes, ReactNode } from "react";
|
|
2
|
+
import "./Tabs.css";
|
|
3
|
+
export type TabProps = {
|
|
4
|
+
/** Ties this tab to the `TabPanel` with the same value. */
|
|
5
|
+
value: string;
|
|
6
|
+
children?: ReactNode;
|
|
7
|
+
className?: string;
|
|
8
|
+
} & Omit<ButtonHTMLAttributes<HTMLButtonElement>, "value" | "className">;
|
|
9
|
+
/** A single tab. Must be rendered inside a `TabList`. */
|
|
10
|
+
export declare function Tab({ value, children, className, disabled, onClick, ...props }: TabProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { HTMLAttributes, ReactNode } from "react";
|
|
2
|
+
import "./Tabs.css";
|
|
3
|
+
export type TabListProps = {
|
|
4
|
+
children?: ReactNode;
|
|
5
|
+
/** Accessible name for the tab list. */
|
|
6
|
+
"aria-label"?: string;
|
|
7
|
+
className?: string;
|
|
8
|
+
} & Omit<HTMLAttributes<HTMLDivElement>, "className">;
|
|
9
|
+
/**
|
|
10
|
+
* Row (or column) of `Tab`s.
|
|
11
|
+
*
|
|
12
|
+
* Owns the keyboard behaviour the ARIA tabs pattern requires — arrow keys to
|
|
13
|
+
* move, Home/End to jump — because unlike radios there's no native element
|
|
14
|
+
* that provides it. Roving tabindex lives on `Tab` itself.
|
|
15
|
+
*
|
|
16
|
+
* Also owns the sliding selection indicator. Unlike `SegmentedControl`, whose
|
|
17
|
+
* segments are equal width and can be positioned with pure CSS, tabs are
|
|
18
|
+
* content-sized, so the selected tab has to be measured.
|
|
19
|
+
*/
|
|
20
|
+
export declare function TabList({ children, className, onKeyDown, ...props }: TabListProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { HTMLAttributes, ReactNode } from "react";
|
|
2
|
+
import "./Tabs.css";
|
|
3
|
+
export type TabPanelProps = {
|
|
4
|
+
/** Ties this panel to the `Tab` with the same value. */
|
|
5
|
+
value: string;
|
|
6
|
+
children?: ReactNode;
|
|
7
|
+
/**
|
|
8
|
+
* Keeps the panel mounted while hidden, preserving its state (scroll
|
|
9
|
+
* position, form input, in-flight requests). Off by default so unselected
|
|
10
|
+
* panels cost nothing.
|
|
11
|
+
*/
|
|
12
|
+
keepMounted?: boolean;
|
|
13
|
+
className?: string;
|
|
14
|
+
} & Omit<HTMLAttributes<HTMLDivElement>, "className">;
|
|
15
|
+
/** Content for the `Tab` with the same value. */
|
|
16
|
+
export declare function TabPanel({ value, children, keepMounted, className, ...props }: TabPanelProps): import("react").JSX.Element | null;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { HTMLAttributes, ReactNode } from "react";
|
|
2
|
+
import type { TabsActivation, TabsOrientation } from "./tabs.context";
|
|
3
|
+
import "./Tabs.css";
|
|
4
|
+
export type TabsProps = {
|
|
5
|
+
children?: ReactNode;
|
|
6
|
+
/** Selected tab value — makes the component controlled. */
|
|
7
|
+
value?: string;
|
|
8
|
+
/** Initially selected tab when uncontrolled. */
|
|
9
|
+
defaultValue?: string;
|
|
10
|
+
/** Fired with the newly selected tab's value. */
|
|
11
|
+
onChange?: (value: string) => void;
|
|
12
|
+
/** Layout direction. Defaults to `horizontal`. */
|
|
13
|
+
orientation?: TabsOrientation;
|
|
14
|
+
/** Whether arrowing to a tab selects it. Defaults to `automatic`. */
|
|
15
|
+
activation?: TabsActivation;
|
|
16
|
+
className?: string;
|
|
17
|
+
} & Omit<HTMLAttributes<HTMLDivElement>, "className" | "onChange">;
|
|
18
|
+
/**
|
|
19
|
+
* Root of the tabs widget: owns the selection and shares it with `TabList`,
|
|
20
|
+
* `Tab`, and `TabPanel` through context.
|
|
21
|
+
*/
|
|
22
|
+
export declare function Tabs({ children, value, defaultValue, onChange, orientation, activation, className, ...props }: TabsProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { Tabs } from "./Tabs";
|
|
2
|
+
export type { TabsProps } from "./Tabs";
|
|
3
|
+
export { TabList } from "./TabList";
|
|
4
|
+
export type { TabListProps } from "./TabList";
|
|
5
|
+
export { Tab } from "./Tab";
|
|
6
|
+
export type { TabProps } from "./Tab";
|
|
7
|
+
export { TabPanel } from "./TabPanel";
|
|
8
|
+
export type { TabPanelProps } from "./TabPanel";
|
|
9
|
+
export type { TabsOrientation, TabsActivation } from "./tabs.context";
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export type TabsOrientation = "horizontal" | "vertical";
|
|
2
|
+
/**
|
|
3
|
+
* `automatic` selects a tab as soon as it's focused — the ARIA-preferred
|
|
4
|
+
* behaviour when panels are cheap to render. `manual` moves focus with the
|
|
5
|
+
* arrow keys and only selects on Enter/Space, which is what you want when
|
|
6
|
+
* switching panels is expensive.
|
|
7
|
+
*/
|
|
8
|
+
export type TabsActivation = "automatic" | "manual";
|
|
9
|
+
export type TabsContextValue = {
|
|
10
|
+
/** Value of the currently selected tab. */
|
|
11
|
+
value: string | undefined;
|
|
12
|
+
/** Selects a tab by value. */
|
|
13
|
+
select: (value: string) => void;
|
|
14
|
+
/** Prefix for the generated tab/panel ids that tie the two together. */
|
|
15
|
+
baseId: string;
|
|
16
|
+
orientation: TabsOrientation;
|
|
17
|
+
activation: TabsActivation;
|
|
18
|
+
};
|
|
19
|
+
export declare const TabsContext: import("react").Context<TabsContextValue | undefined>;
|
|
20
|
+
/** Reads the surrounding `Tabs` context, failing loudly rather than silently. */
|
|
21
|
+
export declare function useTabsContext(component: string): TabsContextValue;
|
|
22
|
+
/** Ids are derived rather than registered, so tab and panel always agree. */
|
|
23
|
+
export declare const tabId: (baseId: string, value: string) => string;
|
|
24
|
+
export declare const panelId: (baseId: string, value: string) => string;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { HTMLAttributes, ReactNode } from "react";
|
|
2
|
+
import type { TagVariant } from "./tag.tokens";
|
|
3
|
+
import "./Tag.css";
|
|
4
|
+
export type TagProps = {
|
|
5
|
+
/** Visual style of the tag. Defaults to `primary`. */
|
|
6
|
+
variant?: TagVariant;
|
|
7
|
+
children?: ReactNode;
|
|
8
|
+
} & Omit<HTMLAttributes<HTMLSpanElement>, "children">;
|
|
9
|
+
/** Compact label for statuses, categories, and metadata. */
|
|
10
|
+
export declare function Tag({ variant, className, children, ...props }: TagProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ComponentPropsWithoutRef, ElementType, ReactNode } from 'react';
|
|
2
|
+
import type { TextColor, TextVariant, TextWeight } from './text.tokens';
|
|
3
|
+
import './Text.css';
|
|
4
|
+
type TextOwnProps<E extends ElementType> = {
|
|
5
|
+
/** Element to render. Defaults to the semantically correct tag for `variant`. */
|
|
6
|
+
as?: E;
|
|
7
|
+
/** Typography scale to apply. */
|
|
8
|
+
variant?: TextVariant;
|
|
9
|
+
/** Semantic color token to use. */
|
|
10
|
+
color?: TextColor;
|
|
11
|
+
/** Overrides the variant's default font weight. */
|
|
12
|
+
weight?: TextWeight;
|
|
13
|
+
align?: 'left' | 'center' | 'right';
|
|
14
|
+
children?: ReactNode;
|
|
15
|
+
};
|
|
16
|
+
export type TextProps<E extends ElementType = 'p'> = TextOwnProps<E> & Omit<ComponentPropsWithoutRef<E>, keyof TextOwnProps<E>>;
|
|
17
|
+
/** Typography primitive for the design system — renders any variant as any element. */
|
|
18
|
+
export declare function Text<E extends ElementType = 'p'>({ as, variant, color, weight, align, className, style, children, ...props }: TextProps<E>): import("react").JSX.Element;
|
|
19
|
+
export {};
|