import type { FormProps, FormItemProps, IFormInstanceAPI, IuseForm, } from './form' import type { InputProps } from '@tarojs/components' import type { SwitchProps } from './switch' import type { RadioGroupProps } from './radio' import type { CheckboxGroupProps } from './checkbox' import type { SliderProps } from './slider' import { RateProps } from './rate' import { StepperProps } from './stepper' export type IFormRenderItemProps = | IMakeFormCompProps<'input' | 'inputNumber' | 'inputPrice', InputProps, T> | IMakeFormCompProps<'switch', SwitchProps, T> | IMakeFormCompProps<'radio', RadioGroupProps, T> | IMakeFormCompProps<'checkbox', CheckboxGroupProps, T> | IMakeFormCompProps<'slider', SliderProps, T> | IMakeFormCompProps<'rate', RateProps, T> | IMakeFormCompProps<'stepper', StepperProps, T> /** * @title 组件的props */ export type IMakeFormRenderProps = { /** * @description 注册组件 */ queryInit?: boolean config: CP[] defaultValues?: T /** * @description form实例 */ form: IFormInstanceAPI } & Omit export type IFormRenderProps = IMakeFormRenderProps< T, IFormRenderItemProps > /** * @title config的每一项 */ export interface IMakeFormCompProps extends Omit { /** * @description 对应组件的key */ type: Type /** * @description 传入组件的props */ props?: Props /** * @description 对应泛型对象的key表单字段 */ fields: keyof T | Array label: string /** * @description option选项,给checkebox、radio等组件使用 */ options?: { value: string name: string }[] } export interface IRegisterFormParams extends Omit { /** * @description 注册组件的key */ type: string /** * @description 注册组件 */ component: any /** * @description 转换组件的props, props为组件props, itemProps为formItem的props */ transformProps?: ( props: Record, itemProps: Record, ) => Record } export type IRegisterForm = (params: IRegisterFormParams) => void declare interface IFormRender { (props: IFormRenderProps): JSX.Element resiterComponent: IRegisterForm showComponents: () => Record useForm: IuseForm } declare const FormRender: IFormRender export { FormRender }