@mitcsutt/kiln-forms
Version:
Kiln forms: typed React forms on TanStack Form, in component or JSON schema mode, rendered through kiln-ui
21 lines (20 loc) • 1.17 kB
TypeScript
import type { UntypedFieldNode, UntypedNode } from './types.js';
export declare const DISABLED = 1;
export declare const READ_ONLY = 2;
export declare const EXCLUDED = 4;
export declare const REQUIRED = 8;
/**
* A field node's state as one bit set: static `disabled` / `readOnly` /
* `excluded` / `required` props, their `*When` conditions, and `compute` (always read-only). The
* renderer subscribes to it with one primitive selector (§12.3) and `toStandardSchema` reads the
* same function, so client and server agree on which fields are active. `inherited` = the
* `layoutFlags` of the field's ancestors.
*/
export declare function fieldFlags(node: UntypedFieldNode, values: unknown, context: Record<string, unknown>, inherited?: number): number;
/**
* The flags a layout node passes down to every field under it: a `section` with
* `readOnly: true` makes its fields read-only on the client, so the server must skip them too.
*/
export declare function layoutFlags(node: UntypedNode): number;
/** Whether a field node has any condition-driven flag (else its flags never change). */
export declare function hasConditionFlags(node: UntypedFieldNode): boolean;