import type * as React from 'react'; import type { PrimitivePropsWithRef } from '../utils/primitive.cjs'; /** * Step status: completed, current, incomplete, error (announces form failures separately), or disabled. */ export type StepStatus = 'completed' | 'current' | 'error' | 'incomplete' | 'disabled'; /** Layout axis of a {@link Stepper} list. */ export type StepperOrientation = 'horizontal' | 'vertical'; /** * Navigation mode: `'linear'` restricts to completed, current, and next incomplete steps; `'non-linear'` allows any non-disabled step. */ export type StepperNavigationMode = 'linear' | 'non-linear'; /** @internal One registered step tracked for navigation-mode decisions. */ export interface StepperItemState { value: string; completed: boolean; disabled: boolean; error: boolean; } /** @internal Shared state distributed from Stepper to its parts via context. */ export interface StepperContextValue { value?: string | undefined; orientation: StepperOrientation; navigationMode: StepperNavigationMode; /** The visually-hidden text announced for a given status. */ statusLabel: (status: StepStatus) => string; /** Registered steps, in mount (DOM) order. */ items: StepperItemState[]; registerItem: (item: StepperItemState) => void; unregisterItem: (value: string) => void; /** Whether a trigger for `value` may activate its step under the current navigation mode. */ canActivate: (value: string) => boolean; /** Activates `value` if {@link StepperContextValue.canActivate} allows it; a no-op otherwise. */ activate: (value: string) => void; } /** One entry of {@link StepperProps.items} — a single step. */ export interface StepperStep { /** Rendered in the trigger; names the step. */ label: React.ReactNode; /** * Supporting copy rendered under the step trigger. * @default undefined — no description is rendered. */ description?: React.ReactNode | undefined; } /** Props for the {@link Stepper} root. */ export interface StepperProps extends PrimitivePropsWithRef<'ol'> { /** * Stepper to render as derived `StepperItem`/`StepperTrigger` pairs keyed by positional index; ignored when `children` is given. * @default undefined — nothing is derived; compose the steps as `children`. */ items?: StepperStep[] | undefined; /** * Index of the current step in `items`, deriving earlier steps as `completed`; a controlled prop, pair with `onValueChange`. * @default undefined — no step is current, and only the first is reachable. */ current?: number | undefined; /** * Current step's value, for controlled usage; pair with `onValueChange`. * @default undefined — uncontrolled, tracks its own current step internally. */ value?: string | undefined; /** * Initially current step's value, for uncontrolled usage. * @default undefined — no step is current until one is activated. */ defaultValue?: string | undefined; /** * Fires when the current step changes; never fires for activations blocked by navigation mode or disabled steps. * @default undefined — no-op. */ onValueChange?: ((value: string) => void) | undefined; /** * Layout axis, exposed as `data-orientation`; a styling hook only, with no ARIA orientation or arrow-key handling. * @default 'horizontal' */ orientation?: StepperOrientation | undefined; /** * `'linear'` restricts to completed, current, and next incomplete steps; `'non-linear'` allows any non-disabled step. * @default 'linear' */ navigationMode?: StepperNavigationMode | undefined; /** * Visually-hidden status text for a completed step. * @default 'Completed' */ completedLabel?: string | undefined; /** * Visually-hidden status text for the current step. * @default 'Current step' */ currentLabel?: string | undefined; /** * Visually-hidden status text for a step that is neither completed nor current. * @default 'Not completed' */ incompleteLabel?: string | undefined; /** * Visually-hidden status text for a disabled step. * @default 'Disabled' */ disabledLabel?: string | undefined; /** * Visually-hidden status text for a step in an error state. * @default 'Error' */ errorLabel?: string | undefined; } /** Props for a single {@link StepperItem}; `asChild` is unavailable because it injects a visually-hidden status element `Slot` cannot merge. */ export interface StepperItemProps extends Omit, 'asChild'> { /** Unique identifier matched against the root's `value` and a `StepperTrigger`'s `value`. */ value: string; /** * Whether this step is completed, driving `data-state` and, in linear mode, which steps a trigger may activate. * @default false */ completed?: boolean | undefined; /** * Whether this step can be activated; a disabled step's trigger leaves the tab order and refuses activation without moving the linear frontier. * @default false */ disabled?: boolean | undefined; /** * Whether this step is in an error state, driving `data-state="error"` and the `errorLabel` status text; ranks below `current`. * @default false */ error?: boolean | undefined; } /** Props for a single {@link StepperTrigger} button. */ export interface StepperTriggerProps extends PrimitivePropsWithRef<'button'> { /** The owning `StepperItem`'s `value` — the step this trigger activates. */ value: string; }