UNPKG

@mitcsutt/kiln-forms

Version:

Kiln forms: typed React forms on TanStack Form, in component or JSON schema mode, rendered through kiln-ui

42 lines (41 loc) • 1.48 kB
import { type ReactNode } from 'react'; import { type TabsVariant } from '@mitcsutt/kiln-ui'; import type { ScopeNamesProps } from '../internal/types.js'; export interface FormTabsProps { /** Accessible name of the tablist. */ label: string; value?: string; defaultValue?: string; onValueChange?: (value: string) => void; variant?: TabsVariant; children: ReactNode; } export interface FormTabProps extends ScopeNamesProps { value: string; label: ReactNode; children: ReactNode; } /** One tab: registers its trigger with `FormTabs` and scopes its fields. */ export declare function FormTab({ value, label, scopeNames, children }: FormTabProps): import("react").JSX.Element; /** * Fields split across tabs, with an error count on each tab and every field kept mounted. * * @remarks * `FormTabs` splits a form across tabs. Each tab's trigger shows how many errors are inside it, * and hidden panels stay mounted, so their fields still validate on submit and keep their values. * On an invalid submit, focus goes to the first error, switching to its tab. * * @example In a schema * ```json * { * "layout": "tabs", * "label": "Member details", * "children": [{ "layout": "tab", "value": "person", "label": "Person", "children": [] }] * } * ``` */ declare function FormTabsRoot(props: FormTabsProps): import("react").JSX.Element; export declare const FormTabs: typeof FormTabsRoot & { Tab: typeof FormTab; }; export {};