{"version":3,"file":"form.mjs","sources":["../../../../packages/tokens/form.ts"],"sourcesContent":["import type { InjectionKey, SetupContext, UnwrapRef } from 'vue'\nimport type {\n  RuleItem,\n  ValidateError,\n  ValidateFieldsError,\n} from 'async-validator'\nimport type { ComponentSize } from '@element-plus/constants'\nimport type {\n  FormEmits,\n  FormItemProp,\n  FormItemProps,\n  FormItemValidateState,\n  FormLabelWidthContext,\n  FormProps,\n} from '@element-plus/components/form'\nimport type { Arrayable } from '@element-plus/utils'\n\nexport interface FormItemRule extends RuleItem {\n  trigger?: Arrayable<string>\n}\nexport type FormRules = Partial<Record<string, Arrayable<FormItemRule>>>\n\nexport type FormValidationResult = Promise<boolean>\nexport type FormValidateCallback = (\n  isValid: boolean,\n  invalidFields?: ValidateFieldsError\n) => void\nexport interface FormValidateFailure {\n  errors: ValidateError[] | null\n  fields: ValidateFieldsError\n}\n\nexport type FormContext = FormProps &\n  UnwrapRef<FormLabelWidthContext> & {\n    emit: SetupContext<FormEmits>['emit']\n\n    // expose\n    addField: (field: FormItemContext) => void\n    removeField: (field: FormItemContext) => void\n    resetFields: (props?: Arrayable<FormItemProp>) => void\n    clearValidate: (props?: Arrayable<FormItemProp>) => void\n    validateField: (\n      props?: Arrayable<FormItemProp>,\n      callback?: FormValidateCallback\n    ) => FormValidationResult\n  }\n\nexport interface FormItemContext extends FormItemProps {\n  $el: HTMLDivElement | undefined\n  size: ComponentSize\n  validateState: FormItemValidateState\n  isGroup: boolean\n  labelId: string\n  inputIds: string[]\n  addInputId: (id: string) => void\n  removeInputId: (id: string) => void\n  validate: (\n    trigger: string,\n    callback?: FormValidateCallback\n  ) => FormValidationResult\n  resetField(): void\n  clearValidate(): void\n}\n\nexport const formContextKey: InjectionKey<FormContext> =\n  Symbol('formContextKey')\nexport const formItemContextKey: InjectionKey<FormItemContext> =\n  Symbol('formItemContextKey')\n"],"names":[],"mappings":"AAAY,MAAC,cAAc,GAAG,MAAM,CAAC,gBAAgB,EAAE;AAC3C,MAAC,kBAAkB,GAAG,MAAM,CAAC,oBAAoB;;;;"}