@ui-schema/react
Version:
Schema-driven UI generator for React using JSON Schema. Build powerful form and interface generators with headless components and hooks.
33 lines (32 loc) • 1.6 kB
TypeScript
import { StoreKeys } from '@ui-schema/ui-schema/ValueStore';
import { ValidateFn } from '@ui-schema/ui-schema/Validate';
import type { PropsWithChildren } from 'react';
import { Translator } from '@ui-schema/ui-schema/Translator';
import { NextWidgetPlugin } from '@ui-schema/react/WidgetEngine';
import { BindingTypeGeneric } from '@ui-schema/react/Widget';
export interface UIMetaContextInternal<W = BindingTypeGeneric, P = {}> extends UIMetaContext<W> {
Next: NextWidgetPlugin<P>;
}
export interface UIMetaContext<W = BindingTypeGeneric> extends UIMetaContextBinding<W>, UIMetaContextBase {
}
export interface UIMetaContextBase {
/**
* Used to make labels for widgets from `title` schema keyword, error messages from error codes
* and more to display understandable text to the user.
*/
t: Translator;
/**
* Validator function to use where needed.
*/
validate?: ValidateFn;
/**
* If supplied, used by design system to generate `name` attributes on input elements.
*/
keysToName?: KeysToName;
}
export type KeysToName = (storeKeys: StoreKeys) => string;
export interface UIMetaContextBinding<W = BindingTypeGeneric> {
binding?: W;
}
export declare function UIMetaProvider<C extends {}, W extends BindingTypeGeneric = BindingTypeGeneric>({ children, ...props }: PropsWithChildren<UIMetaContext<W> & Omit<NoInfer<C>, keyof UIMetaContext<W> | 'children'>>): import("react/jsx-runtime").JSX.Element;
export declare const useUIMeta: <C extends UIMetaContextInternal<any, any> = UIMetaContextInternal<BindingTypeGeneric, {}>>() => C;