import { z } from 'zod'; import { CompactNode } from '../compact/types'; import { PropsObject, PropSpec } from './props'; import { SxKeyDoc, SxSchema } from './sx'; /** `text: true` = may hold text instead of child nodes. */ export type NodeContent = { kind: 'text'; } | { kind: 'none'; } | { kind: 'nodes'; accepts?: readonly string[]; min?: number; text?: boolean; }; export type RuleContext = { typographyPresets?: { fontSize: string | number; lineHeight: string | number; }[]; variableKeys?: string[]; /** Names of the consumer's forms (`resources.forms`), which `name` of a form node may reference. */ formNames?: string[]; }; /** * `path` is relative to the node, e.g. `'children[1]'` or `'props.sx.fontSize'`. `related` lists other node-relative * paths the issue is about (e.g. the paired `props.sx.lineHeight`): a proposal that writes any of them owns the issue. */ export type RuleIssue = { path: string; message: string; related?: string[]; }; export type NodeRule = { description: string; check(node: CompactNode, ctx: RuleContext): RuleIssue[]; }; export type NodeSchemaDef

= Record, X extends SxSchema | undefined = SxSchema | undefined> = { resolvedName: string; description: string; canvas: boolean; content: NodeContent; /** `undefined` = any parent. */ parents?: readonly string[]; /** Tổ tiên ở độ sâu bất kỳ: `someOf` = phải có ít nhất một tổ tiên thuộc danh sách; `noneOf` = không tổ tiên nào thuộc danh sách. */ ancestors?: { someOf?: readonly string[]; noneOf?: readonly string[]; }; props?: P; sx?: X; rules?: NodeRule[]; writable?: boolean; /** Guidance for the AI on when to use the node. */ usage?: string; }; export type NodeSchemaDocs = { props: { name: string; values: string; responsive: boolean; description: string; }[]; sx: SxKeyDoc[]; }; export type NodeSchema = NodeSchemaDef & { writable: boolean; propsSchema: T; docs: NodeSchemaDocs; }; export type SchemaProps = z.infer; /** * Compile-time check for schema files: `type _Check = Assignable, XProps>`. * Pair it with `type _Keys = Assignable, keyof XProps>`: the first check accepts a * misspelled prop key when the other keys match, and the second catches it. `_Keys` is one-way and cannot see sx keys. */ export type Assignable = true; type NodeProps

, X> = X extends SxSchema ? P & { sx: X; } : P; /** `writable` defaults to true; `propsSchema` holds `props` plus `sx`. */ export declare function defineNodeSchema

= Record, X extends SxSchema | undefined = undefined>(def: NodeSchemaDef): NodeSchema>>; export {};