import { Record, Map, List, OrderedMap, RecordOf } from 'immutable'; import { UIStoreActions, UIStoreUpdaterData } from '@ui-schema/react/UIStoreActions'; import { StoreKeys as ValueStoreKeys } from '@ui-schema/ui-schema/ValueStore'; import { SchemaTypesType } from '@ui-schema/ui-schema/CommonTypings'; import { Validity } from './UIStoreProvider.js'; export type Values = List | string | number | boolean | Map | OrderedMap; export type ValuesJS = any[] | string | number | boolean | Object; export interface UIStoreStateData { values: D; internals: UIStoreInternalsType | undefined; validity: UIStoreValidityType | undefined; meta: Map; } export interface UIStoreState extends UIStoreStateData { valuesToJS: () => ValuesJS; getValues: () => D; getInternals: () => UIStoreInternalsType | undefined; getValidity: () => UIStoreValidityType | undefined; extractValues: (storeKeys: StoreKeys) => { value: V | undefined; internalValue: UIStoreInternalsType | undefined; }; extractValidity: (storeKeys: StoreKeys) => Validity | undefined; } export type UIStoreTypeFactory = Record.Factory>; export type UIStoreType = RecordOf>; /** * Internals store tree. * * Nested with `.children` and a storeKeys value is scoped to `.self`. */ export type UIStoreInternalsType = Map; export type UIStoreValidityType = Map; export type UIStoreUpdaterFn = (data: D) => D; export type onChangeHandler = (actions: A[] | A) => void; export type StoreKeyType = string | number; export type StoreKeys = ValueStoreKeys; export declare const UIStore: UIStoreTypeFactory; export declare const createStore: (values: D) => UIStoreType; /** * @todo support multiple types #68 * @todo include non-evaluating default handling here #118 ? * - would rely on the whole schema * - would work only for basic `default` without conditionals * - could reuse the resource system for walking the schema, instead of the validator */ export declare const createEmptyStore: (type?: SchemaTypesType) => UIStoreType; export declare const prependKey: | StoreKeyType[] = ValueStoreKeys | StoreKeyType[]>(storeKeys: S, key: O) => S; export declare const shouldDeleteOnEmpty: (value: any, force: boolean | undefined, type: string | string[] | List | undefined) => boolean; export declare const addNestKey: (storeKeysNestedKey: string, storeKeys: (string | number)[] | List) => List;