import { isString } from '@vue/shared' import { buildProps, definePropType, iconPropType, mutable, } from '@element-plus/utils' import { UPDATE_MODEL_EVENT } from '@element-plus/constants' import { useSizeProp } from '@element-plus/hooks' import type Input from './input.vue' import type { ExtractPropTypes, StyleValue } from 'vue' export type InputAutoSize = { minRows?: number; maxRows?: number } | boolean export const inputProps = buildProps({ id: { type: String, default: undefined, }, size: useSizeProp, disabled: Boolean, modelValue: { type: definePropType([ String, Number, Object, ]), default: '', }, type: { type: String, default: 'text', }, resize: { type: String, values: ['none', 'both', 'horizontal', 'vertical'], }, autosize: { type: definePropType([Boolean, Object]), default: false, }, autocomplete: { type: String, default: 'off', }, formatter: { type: Function, }, parser: { type: Function, }, placeholder: { type: String, }, form: { type: String, default: '', }, readonly: { type: Boolean, default: false, }, clearable: { type: Boolean, default: false, }, showPassword: { type: Boolean, default: false, }, showWordLimit: { type: Boolean, default: false, }, suffixIcon: { type: iconPropType, default: '', }, prefixIcon: { type: iconPropType, default: '', }, containerRole: { type: String, default: undefined, }, label: { type: String, default: undefined, }, tabindex: { type: [String, Number], default: 0, }, validateEvent: { type: Boolean, default: true, }, inputStyle: { type: definePropType([Object, Array, String]), default: () => mutable({} as const), }, } as const) export type InputProps = ExtractPropTypes export const inputEmits = { [UPDATE_MODEL_EVENT]: (value: string) => isString(value), input: (value: string) => isString(value), change: (value: string) => isString(value), focus: (evt: FocusEvent) => evt instanceof FocusEvent, blur: (evt: FocusEvent) => evt instanceof FocusEvent, clear: () => true, mouseleave: (evt: MouseEvent) => evt instanceof MouseEvent, mouseenter: (evt: MouseEvent) => evt instanceof MouseEvent, // NOTE: when autofill by browser, the keydown event is instanceof Event, not KeyboardEvent // relative bug report https://github.com/element-plus/element-plus/issues/6665 keydown: (evt: KeyboardEvent | Event) => evt instanceof Event, compositionstart: (evt: CompositionEvent) => evt instanceof CompositionEvent, compositionupdate: (evt: CompositionEvent) => evt instanceof CompositionEvent, compositionend: (evt: CompositionEvent) => evt instanceof CompositionEvent, } export type InputEmits = typeof inputEmits export type InputInstance = InstanceType