mirror of
https://github.com/element-plus/element-plus.git
synced 2024-12-21 02:50:11 +08:00
8f67fb7645
* feat(form): add scrollToField function * feat(components): complete scrollToField function Co-authored-by: linjie <linjie@zhuanzhuan.com>
55 lines
1.5 KiB
TypeScript
55 lines
1.5 KiB
TypeScript
import type { InjectionKey } from 'vue'
|
|
import type {
|
|
FieldErrorList,
|
|
} from 'async-validator'
|
|
import type { Emitter } from 'mitt'
|
|
import type { ComponentSize } from '@element-plus/utils/types'
|
|
|
|
export interface ElFormContext {
|
|
registerLabelWidth(width: number, oldWidth: number): void
|
|
deregisterLabelWidth(width: number): void
|
|
autoLabelWidth: string | undefined
|
|
formMitt: Emitter
|
|
emit: (evt: string, ...args: any[]) => void
|
|
labelSuffix: string
|
|
inline?: boolean
|
|
inlineMessage?: boolean
|
|
model?: Record<string, unknown>
|
|
size?: string
|
|
showMessage?: boolean
|
|
labelPosition?: string
|
|
labelWidth?: string | number
|
|
rules?: Record<string, unknown>
|
|
statusIcon?: boolean
|
|
hideRequiredAsterisk?: boolean
|
|
disabled?: boolean
|
|
}
|
|
|
|
export interface ValidateFieldCallback {
|
|
(isValid?: string, invalidFields?: FieldErrorList): void
|
|
}
|
|
|
|
export interface ElFormItemContext {
|
|
prop?: string
|
|
formItemMitt: Emitter
|
|
size?: ComponentSize
|
|
validateState: string
|
|
$el: HTMLDivElement
|
|
validate(trigger: string, callback?: ValidateFieldCallback): void
|
|
updateComputedLabelWidth(width: number): void
|
|
addValidateEvents(): void
|
|
removeValidateEvents(): void
|
|
resetField(): void
|
|
clearValidate(): void
|
|
}
|
|
|
|
// TODO: change it to symbol
|
|
export const elFormKey: InjectionKey<ElFormContext> = 'elForm' as any
|
|
|
|
export const elFormItemKey: InjectionKey<ElFormItemContext> = 'elFormItem' as any
|
|
|
|
export const elFormEvents = {
|
|
addField: 'el.form.addField',
|
|
removeField: 'el.form.removeField',
|
|
} as const
|