@mitcsutt/kiln-forms
Version:
Kiln forms: typed React forms on TanStack Form, in component or JSON schema mode, rendered through kiln-ui
58 lines (57 loc) • 2.44 kB
TypeScript
import { type ReactNode } from 'react';
import type { StandardSchemaV1 } from '@tanstack/react-form';
import type { HeadingLevel, ScopeNamesProps } from '../internal/types.js';
export interface FormStepsProps {
/** Accessible name for the step indicator. */
label?: string;
/** Controlled current step — deep-linkable (a router search param). */
value?: string;
defaultValue?: string;
onValueChange?: (step: string) => void;
/** `true` (default): going forward validates every step in between. */
linear?: boolean;
/** `'auto'` (default) renders Back / Next / Submit in an `ActionBar`; `'none'` for custom chrome (`useFormSteps`). */
nav?: 'auto' | 'none';
backLabel?: string;
nextLabel?: string;
submitLabel?: string;
/** Heading level of each step's title. Default 3. */
headingLevel?: HeadingLevel;
/** Below this breakpoint the Stepper collapses to one line: `messages.stepCompact` + the step title. */
compactBelow?: 'sm' | 'md';
children: ReactNode;
}
export interface FormStepProps extends ScopeNamesProps {
value: string;
title: ReactNode;
description?: ReactNode;
/** Extra validation for this step; issues are filtered to this step's fields. */
schema?: StandardSchemaV1;
children: ReactNode;
}
/** One step: a `section` with a focusable heading, scoped for validation, counts and reveal. */
export declare function FormStep({ scopeNames, ...props }: FormStepProps): import("react").JSX.Element;
/**
* A form split into steps, validated one step at a time, with focus and announcements handled.
*
* @remarks
* `FormSteps` shows a {@link Stepper | Stepper} and one step at a time, with Back and Next.
* **Next** validates the current step's fields; if any are invalid it stays, shows their errors
* and focuses the first. Otherwise it moves on, focuses the new step's heading and announces "Step
* 2 of 3". On the last step, Next submits the form. The final submit validates every step, and an
* error in an earlier step takes you back to it.
*
* @example In a schema
* ```json
* {
* "layout": "steps",
* "label": "Booking",
* "children": [{ "layout": "step", "value": "route", "title": "Route", "children": [] }]
* }
* ```
*/
declare function FormStepsRoot(props: FormStepsProps): import("react").JSX.Element;
export declare const FormSteps: typeof FormStepsRoot & {
Step: typeof FormStep;
};
export {};