UNPKG

@aliretail/react-materials-components

Version:
25 lines (24 loc) 1.11 kB
import * as React from 'react'; import { Rule } from '@alifd/field/types'; declare type State = 'error' | 'loading' | 'success' | 'warning' | undefined; interface FormComponentProps<V> { state?: State; onChange?: (value: V, ...args: any[]) => void; } interface EnhancedComponentProps<V> { value?: V; rules?: Rule[]; onChange?: (value: V, ...args: any[]) => void; containerClassName?: string; containerStyle?: React.CSSProperties; } /** form item 上的校验规则 */ export declare const validate: (scope: string) => Promise<void>, pass: (scope: string) => Promise<void>; /** * 集成表单组件的error提示 * @param FormComponent 表单组件(实现 value、onChange 的组件) * @param scope 创建校验的作用域 * @returns 带 error 提示的表单组件 */ export declare const withFormError: <V_1 extends unknown, P extends object>(FormComponent: React.ComponentType<FormComponentProps<V_1> & Pick<P, Exclude<keyof P, "onChange" | "state">>>, scope?: string) => React.FC<EnhancedComponentProps<V_1> & Pick<P, Exclude<keyof P, "value" | "onChange">>>; export {};