import { formProps, arrayFormProps, formListProps, groupFormProps, formItemProps, formComponentProps, formEmits, formItemEmits, arrayFormEmits, tabsFormEmits, stepsFormEmits } from './props'; import type { Ref, Slots } from 'vue'; import type { ButtonProps, ColProps, CollapseModelValue, FormItemProps, TabPaneName, TabPaneProps, CollapseItemProps, StepProps, FormInstance } from 'element-plus'; import type { IDefineProps, IDefineEmits, UnknownObject, ExternalParam, Mutable, ColumnProp, FormColumnChildren, ColumnComponent, ColumnCommonProp } from '../types/index'; export interface InvalidFields { [prop: string]: { message: string; field: string; }[]; } export interface FormColumn extends Mutable>>, Partial> { /** component name */ component?: string | ColumnComponent; /** props for component */ props?: UnknownObject & ColumnCommonProp; /** the type of sub-form */ type?: 'array'; /** sub-form */ children?: IFormColumns>; /** max number of sub-form */ max?: number; /** keys of model that passed to form */ prop: ColumnProp; /** whether to display the current column */ show?: boolean; /** * @deprecated The `modelKey` attribute will be removed in the next major version, please use `models` instead * * bind v-model arguments, default modelValue */ modelKey?: string | [string, string]; /** bind v-model arguments, support binding multiple arguments */ models?: Array<{ /** keys of model that passed to form */ prop: string; /** bind v-model arguments */ key: string; /** bind v-model event, default `onUpdate:${key}` */ event?: string; }>; } export type GroupFormType = 'group' | 'tabs' | 'collapse' | 'steps'; export interface GroupFormColumn extends Partial>, Partial>, Partial> { /** the type of group-form */ type: GroupFormType; /** keys of model that passed to form */ prop?: ColumnProp; /** the title of group-form */ label?: string; /** group-form */ children?: IFormColumns; /** whether to display the current column */ show?: boolean; } /** Form Columns Option */ export type IFormColumns = Array<(FormColumn | GroupFormColumn) & UnknownObject>; /** Form Menu Option */ export interface FormMenu { /** show submit button */ submit?: boolean; /** text of submit button */ submitText?: string; /** props of submit button */ submitProps?: Partial; /** show reset button */ reset?: boolean; /** text of reset button */ resetText?: string; /** props of reset button */ resetProps?: Partial; /** text of prev button */ prevText?: string; /** props of prev button */ prevProps?: Partial; /** text of next button */ nextText?: string; /** props of next button */ nextProps?: Partial; } /** Form Menu Option */ export type IFormMenuColumns = FormMenu; export type IFormSubmit = (done: () => void, isValid: boolean, invalidFields?: InvalidFields) => void; export interface IFormValidateCallback { (isValid: boolean, invalidFields?: InvalidFields): void; } export interface IFormValidateFieldCallback { (message?: string, invalidFields?: InvalidFields): void; } /** Form Expose Methods */ export type IFormExpose = FormInstance; export interface UseFormProvideConfig { props: IFormProps; emit: IFormEmits; slots: Readonly; formRef: Ref; /** disabled submit */ disabled: Ref; } export interface UseFormInjectEmitsCallback { addItem: (indexes: number[]) => void; removeItem: (indexes: number[]) => void; tabsChange: (name: TabPaneName) => void; collapseChange: (active: CollapseModelValue) => void; stepChange: (active: TabPaneName) => void; } export type IFormContext = UseFormProvideConfig & UseFormInjectEmitsCallback; export type IFormProps = IDefineProps; export type IArrayFormProps = IDefineProps; export type IFormListProps = IDefineProps; export type IGroupFormProps = IDefineProps; export type IFormItemProps = IDefineProps; export type IFormComponentProps = IDefineProps; export type IFormEmits = IDefineEmits; export type IFormItemEmits = IDefineEmits; export type IArrayFormEmits = IDefineEmits; export type ITabsFormEmits = IDefineEmits; export type IStepsFormEmits = IDefineEmits; /** * Type helper to make it easier to define columns * @param columns the columns of Form */ export declare function defineFormColumns(columns: IFormColumns): IFormColumns; /** * Type helper to make it easier to define menu columns * @param columns the columns of Form menu */ export declare function defineFormMenuColumns(columns: IFormMenuColumns): IFormMenuColumns; /** * Type helper to make it easier to define submit function * @param fun submit function */ export declare function defineFormSubmit(fun: IFormSubmit): IFormSubmit;