UNPKG

@mitcsutt/kiln-forms

Version:

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

48 lines (47 loc) • 1.66 kB
import type { ReactNode } from 'react'; import { type GridColumns, type GridSpan, type Responsive, type Space } from '@mitcsutt/kiln-ui'; export interface FormGridProps { /** Default `{ base: 1, md: 2 }`: one column on phones, two from `md`. */ columns?: Responsive<GridColumns>; /** Default `5`. */ gap?: Responsive<Space>; rowGap?: Responsive<Space>; children: ReactNode; } export interface FormGridItemProps { span?: Responsive<GridSpan>; /** Column to start at — an offset instead of a spacer cell. */ start?: Responsive<GridColumns>; children: ReactNode; } /** A cell that spans columns or starts at a column. */ export declare function FormGridItem({ span, start, children }: FormGridItemProps): import("react").JSX.Element; /** * Fields in columns that collapse on small screens, with items that span. * * @remarks * `FormGrid` lays fields out in columns: two from `md` up by default, one below. `FormGridItem` * spans columns or starts at one, both responsive. Spacers are `start` offsets; there's no string * matrix of field names. * * @example In a schema * ```json * { * "layout": "grid", * "columns": { "base": 1, "md": 3 }, * "children": [ * { * "layout": "gridItem", * "span": { "base": 1, "md": 3 }, * "children": [{ "kind": "text", "name": "street", "label": "Street" }] * }, * { "kind": "text", "name": "postcode", "label": "Postcode" } * ] * } * ``` */ declare function FormGridRoot(props: FormGridProps): import("react").JSX.Element; export declare const FormGrid: typeof FormGridRoot & { Item: typeof FormGridItem; }; export {};