@ui-schema/react
Version:
Schema-driven UI generator for React using JSON Schema. Build powerful form and interface generators with headless components and hooks.
72 lines (71 loc) • 2.52 kB
TypeScript
import * as React from 'react';
import type { List, Map, MapOf } from 'immutable';
import type { onChangeHandler, UIStoreType } from './UIStore.js';
import { UIStoreActionsContext, UIStoreActions } from '@ui-schema/react/UIStoreActions';
export interface UIStoreContext<D = any> {
store: UIStoreType<D> | undefined;
showValidity?: boolean;
}
/**
* @deprecated will be removed in a future version
*/
export declare const UIConfigProvider: React.ComponentType<React.PropsWithChildren<{}>>;
export declare function UIStoreProvider<C extends {} = {}, D = any, A = UIStoreActions>({ children, showValidity, onChange, store, ...props }: React.PropsWithChildren<UIStoreContext<D> & UIStoreActionsContext<A> & C>): React.ReactElement;
export declare const useUIStore: <D extends unknown = any>() => UIStoreContext<D>;
/**
* @deprecated will be removed in a future version
*/
export declare function useUIConfig<U extends {} = {}>(): U;
export interface WithOnChange<A = UIStoreActions> {
onChange: onChangeHandler<A>;
}
/**
* @todo normalize with `WithValue` once finalized stricter widget/plugin props overall
*/
export interface WithValuePlain {
value: unknown;
internalValue: unknown;
}
/**
* @deprecated use `WithValuePlain` + `WithOnChange` instead, which is also included in `WidgetProps` now
*/
export interface WithValue<A = UIStoreActions> {
/**
* @todo switch to `unknown`
*/
value: any | undefined;
/**
* @todo switch to `unknown`
*/
internalValue: any | undefined;
showValidity?: UIStoreContext['showValidity'];
onChange: onChangeHandler<A>;
}
/**
* @todo remove this typing, `WithValue` should be used with type guards
* @deprecated use `WithValuePlain` instead
*/
export interface WithScalarValue<A = UIStoreActions> {
value: string | number | boolean | undefined | null;
internalValue: any;
showValidity?: UIStoreContext['showValidity'];
onChange: onChangeHandler<A>;
}
export type Validity = MapOf<{
valid?: boolean;
children?: ValidityChildren;
errors?: unknown;
}>;
/**
* @todo make stricter, with immutable leads to `error TS2615: Type of property 'children' circularly references itself in mapped type`
*/
type ValidityChildren = Map<string, any> | List<any>;
/**
* @deprecated will be removed in a future version
*/
export interface WithValidity<A = UIStoreActions> {
validity: Validity | undefined;
onChange: onChangeHandler<A>;
showValidity?: UIStoreContext['showValidity'];
}
export {};