@orca-fe/pocket
Version:
UI components by orca-team
37 lines (36 loc) • 1.34 kB
TypeScript
import type { ReactElement, ReactNode } from 'react';
import React from 'react';
import CommonStore from '../common-store';
type NamePath = string | string[];
declare class FormStore<T = any> extends CommonStore<any> {
constructor();
setFieldsValue(value: Partial<T>): void;
setFieldValue(key: NamePath, value: any): Partial<any>;
getFieldsValue(): T;
getFieldValue(key: NamePath): any;
}
export type SimpleFormContextType = {
form: FormStore;
changeValue: (key: NamePath, value: any) => void;
};
export declare const SimpleFormContext: React.Context<SimpleFormContextType>;
export interface SimpleFormProps<T extends Record<string, any>> {
initialValues?: Partial<T>;
onValuesChange?: (changed: Partial<T>, value: T) => void;
children?: ReactNode;
form?: FormStore<T>;
}
declare const SimpleForm: {
<T extends Record<string, any>>(props: SimpleFormProps<T>): import("react/jsx-runtime").JSX.Element;
useForm: (_form?: FormStore) => FormStore<any>[];
Item: (props: SimpleFormItemProps) => import("react/jsx-runtime").JSX.Element;
Context: React.Context<SimpleFormContextType>;
useFormInstance(): FormStore<any>;
};
export default SimpleForm;
export type SimpleFormItemProps = {
name?: NamePath;
valuePropName?: string;
trigger?: string;
children?: ReactElement;
};