UNPKG

kwikid-forms

Version:

KwikID's JSON Configuration based Forms Renderer and Builder

47 lines (46 loc) 2.36 kB
/** Where a configured key should be read from. */ export declare type FormsStorageSource = "reduxData" | "localStorage"; /** * Default when utilityFlags.isEliminateBrowserStorage is not set (undefined). * Legacy hosts keep localStorage; set the flag to true for reduxData-only reads. */ export declare const DEFAULT_FORMS_ELIMINATE_BROWSER_STORAGE = false; export interface FormsStorageKeyConfig { /** Omit to use FormsStorageConfig.defaultSource (one source per client). */ source?: FormsStorageSource; /** Storage key (defaults to the logical id passed to resolve). */ key?: string; /** Try multiple keys in order (e.g. language). */ keys?: string[]; fallback?: string; } /** * Host supplies via userConfig.formsStorage, or derived from utilityFlags. * Per-key `source` is optional — falls back to defaultSource (same idea as toolkit * BROWSER_STORAGE: { type, key } with a single type for the client). * Example (eliminate mode — set via utilityFlags or defaultSource): * { * "defaultSource": "reduxData", * "session_id": { "key": "session_id" }, * "language": { "keys": ["lng", "lang", "selectedLang"], "fallback": "en" }, * "formKey": { "key": "formKey" } * } */ export interface FormsStorageConfig { defaultSource?: FormsStorageSource; session_id?: FormsStorageKeyConfig; language?: FormsStorageKeyConfig; formKey?: FormsStorageKeyConfig; [logicalKey: string]: FormsStorageKeyConfig | FormsStorageSource | undefined; } /** Legacy default: localStorage until host sets utilityFlags.isEliminateBrowserStorage. */ export declare const DEFAULT_FORMS_STORAGE_CONFIG: FormsStorageConfig; /** Merge userConfig.formsStorage with defaults; map utilityFlags when present. */ export declare function resolveFormsStorageConfig(userConfig?: any): FormsStorageConfig; /** Resolve a string value for a logical or explicit storage key. */ export declare function resolveFormsStorageString(logicalKey: string, reduxData?: Record<string, unknown>, config?: FormsStorageConfig): string | null; /** * Resolve a structured value (form config blob, eNachForm, etc.). * Supports the same logical key / keys[] / key alias config as resolveFormsStorageString. */ export declare function resolveFormsStorageObject(logicalKey: string, reduxData?: Record<string, unknown>, config?: FormsStorageConfig): any;