mirror of
https://gitee.com/element-plus/element-plus.git
synced 2024-12-14 09:20:51 +08:00
adf1ecf3eb
* fix(components): [el-form] validation with callbacks throws - Fix Form component's validation with callbacks still throws error - Fix FormItem component's validation with callbacks still throws error - Update test cases to make sure this functionality's integrity * Fix linter
54 lines
1.2 KiB
TypeScript
54 lines
1.2 KiB
TypeScript
import { componentSizes } from '@element-plus/constants'
|
|
import { buildProps, definePropType } from '@element-plus/utils'
|
|
|
|
import type { ExtractPropTypes } from 'vue'
|
|
import type { Arrayable } from '@element-plus/utils'
|
|
import type { FormItemRule } from '@element-plus/tokens'
|
|
|
|
export const formItemValidateStates = [
|
|
'',
|
|
'error',
|
|
'validating',
|
|
'success',
|
|
] as const
|
|
export type FormItemValidateState = typeof formItemValidateStates[number]
|
|
|
|
export type FormItemProp = Arrayable<string>
|
|
|
|
export const formItemProps = buildProps({
|
|
label: String,
|
|
labelWidth: {
|
|
type: [String, Number],
|
|
default: '',
|
|
},
|
|
prop: {
|
|
type: definePropType<FormItemProp>([String, Array]),
|
|
},
|
|
required: {
|
|
type: Boolean,
|
|
default: undefined,
|
|
},
|
|
rules: {
|
|
type: definePropType<Arrayable<FormItemRule>>([Object, Array]),
|
|
},
|
|
error: String,
|
|
validateStatus: {
|
|
type: String,
|
|
values: formItemValidateStates,
|
|
},
|
|
for: String,
|
|
inlineMessage: {
|
|
type: [String, Boolean],
|
|
default: '',
|
|
},
|
|
showMessage: {
|
|
type: Boolean,
|
|
default: true,
|
|
},
|
|
size: {
|
|
type: String,
|
|
values: componentSizes,
|
|
},
|
|
} as const)
|
|
export type FormItemProps = ExtractPropTypes<typeof formItemProps>
|