@mitcsutt/kiln-forms
Version:
Kiln forms: typed React forms on TanStack Form, in component or JSON schema mode, rendered through kiln-ui
26 lines (25 loc) • 2.29 kB
TypeScript
import type { UntypedCondition, UntypedContentNode, UntypedCustomNode, UntypedFieldNode, UntypedLayoutNode, UntypedNode, UntypedRepeaterNode } from './types.js';
export declare function isFieldNode(node: UntypedNode): node is UntypedFieldNode;
export declare function isRepeaterNode(node: UntypedNode): node is UntypedRepeaterNode;
export declare function isLayoutNode(node: UntypedNode): node is UntypedLayoutNode;
export declare function isContentNode(node: UntypedNode): node is UntypedContentNode;
export declare function isCustomNode(node: UntypedNode): node is UntypedCustomNode;
/** The nodes directly under a node (layout `children`, repeater `item`). */
export declare function childNodes(node: UntypedNode): readonly UntypedNode[];
/** Schema-only keys of a field node — everything else is passed to the field component. */
export declare const FIELD_SCHEMA_KEYS: readonly ["kind", "name", "id", "when", "whenAnimate", "rules", "warnRules", "defaultValue", "whenHidden", "disabledWhen", "readOnlyWhen", "excludeWhen", "requiredWhen", "optionsFrom", "resets", "compute"];
/** Schema-only keys of layout and repeater nodes. */
export declare const LAYOUT_SCHEMA_KEYS: readonly ["layout", "id", "when", "whenAnimate", "children", "item", "newItem", "rules", "whenHidden"];
/** Schema-only keys of content nodes. */
export declare const CONTENT_SCHEMA_KEYS: readonly ["content", "id", "when", "whenAnimate"];
/**
* The component props of a field node (`label`, `options`, `min`, …), schema keys removed, and
* option swatches a schema may not set dropped.
*/
export declare function fieldNodeProps(node: UntypedFieldNode): Record<string, unknown>;
/** The component props of a layout or repeater node (`title`, `columns`, `label`, …). Repeater keeps `name`. */
export declare function layoutNodeProps(node: UntypedLayoutNode | UntypedRepeaterNode): Record<string, unknown>;
/** The props of a content node (`text`, `level`, `tone`, `label`, …). */
export declare function contentNodeProps(node: UntypedContentNode): Record<string, unknown>;
/** Every condition a node carries, keyed by where it sits. */
export declare function nodeConditions(node: UntypedNode): Partial<Record<'when' | 'disabledWhen' | 'readOnlyWhen' | 'excludeWhen' | 'requiredWhen', UntypedCondition>>;