UNPKG

@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) • 1.69 kB
/** Pure value helpers shared by conditions, rules, analysis and the Standard Schema adapter. */ /** `guests[0].name` / `guests.0.name` → `['guests', 0, 'name']`. */ export declare function pathSegments(path: string): (string | number)[]; /** Joins a scope prefix and a relative name the way TanStack names fields. */ export declare function joinPath(prefix: string, name: string): string; /** Path segments that could reach or replace an object's prototype — never read or written. */ export declare const UNSAFE_PATH_SEGMENTS: readonly string[]; /** The first prototype-reaching segment of a path, if any. */ export declare function unsafePathSegment(path: string): string | undefined; /** * Reads a TanStack-style path (`a.b`, `a[0].b`, `a.0.b`). Missing segments → `undefined`. Only own * properties are read; `__proto__` / `prototype` / `constructor` segments read `undefined`. */ export declare function getPath(values: unknown, path: string): unknown; /** * Writes a path into a plain object, creating objects / arrays on the way. Mutates `target`. * Throws on `__proto__` / `prototype` / `constructor` segments (prototype pollution). */ export declare function setPath(target: Record<string, unknown>, path: string, value: unknown): void; /** Structural equality for JSON-like values (`Object.is` for primitives, so `NaN` equals `NaN`). */ export declare function deepEqual(a: unknown, b: unknown): boolean; /** §10.3 `empty`: `''`, `null`, `undefined` or `[]`. */ export declare function isEmptyValue(value: unknown): boolean; /** True for values that survive `JSON.stringify` → `JSON.parse` unchanged. */ export declare function isJson(value: unknown): boolean;