mirror of
https://github.com/element-plus/element-plus.git
synced 2026-03-13 07:51:17 +08:00
59 lines
1.2 KiB
TypeScript
59 lines
1.2 KiB
TypeScript
import { componentSizes } from '@element-plus/constants'
|
|
import {
|
|
buildProps,
|
|
definePropType,
|
|
isArray,
|
|
isBoolean,
|
|
isString,
|
|
} from '@element-plus/utils'
|
|
|
|
import type { ExtractPropTypes } from 'vue'
|
|
import type { FormItemProp } from './form-item'
|
|
import type { FormRules } from '@element-plus/tokens'
|
|
|
|
export const formProps = buildProps({
|
|
model: Object,
|
|
rules: {
|
|
type: definePropType<FormRules>(Object),
|
|
},
|
|
labelPosition: String,
|
|
labelWidth: {
|
|
type: [String, Number],
|
|
default: '',
|
|
},
|
|
labelSuffix: {
|
|
type: String,
|
|
default: '',
|
|
},
|
|
inline: Boolean,
|
|
inlineMessage: Boolean,
|
|
statusIcon: Boolean,
|
|
showMessage: {
|
|
type: Boolean,
|
|
default: true,
|
|
},
|
|
size: {
|
|
type: String,
|
|
values: componentSizes,
|
|
},
|
|
disabled: Boolean,
|
|
validateOnRuleChange: {
|
|
type: Boolean,
|
|
default: true,
|
|
},
|
|
hideRequiredAsterisk: {
|
|
type: Boolean,
|
|
default: false,
|
|
},
|
|
scrollToError: Boolean,
|
|
} as const)
|
|
export type FormProps = ExtractPropTypes<typeof formProps>
|
|
|
|
export const formEmits = {
|
|
validate: (prop: FormItemProp, isValid: boolean, message: string) =>
|
|
(isArray(prop) || isString(prop)) &&
|
|
isBoolean(isValid) &&
|
|
isString(message),
|
|
}
|
|
export type FormEmits = typeof formEmits
|