import type { ExtractPropTypes, PropType } from 'vue'; import PropTypes from '../_util/vue-types'; import type { SizeType } from '../config-provider'; import type { VueNode } from '../_util/type'; import { stringType } from '../_util/type'; import type { ChangeEventHandler, CompositionEventHandler, FocusEventHandler, KeyboardEventHandler, MouseEventHandler, } from '../_util/EventInterface'; import type { InputStatus } from '../_util/statusUtils'; import type { InputFocusOptions } from './utils/commonUtils'; export const inputDefaultValue = Symbol() as unknown as string; export const commonInputProps = () => { return { addonBefore: PropTypes.any, addonAfter: PropTypes.any, prefix: PropTypes.any, suffix: PropTypes.any, clearIcon: PropTypes.any, affixWrapperClassName: String, groupClassName: String, wrapperClassName: String, inputClassName: String, allowClear: { type: Boolean, default: undefined }, }; }; export const baseInputProps = () => { return { ...commonInputProps(), value: { type: [String, Number, Symbol] as PropType, default: undefined, }, defaultValue: { type: [String, Number, Symbol] as PropType, default: undefined, }, inputElement: PropTypes.any, prefixCls: String, disabled: { type: Boolean, default: undefined }, focused: { type: Boolean, default: undefined }, triggerFocus: Function as PropType<() => void>, readonly: { type: Boolean, default: undefined }, handleReset: Function as PropType, hidden: { type: Boolean, default: undefined }, }; }; export const inputProps = () => ({ ...baseInputProps(), id: String, placeholder: { type: [String, Number] as PropType, }, autocomplete: String, type: stringType< | 'button' | 'checkbox' | 'color' | 'date' | 'datetime-local' | 'email' | 'file' | 'hidden' | 'image' | 'month' | 'number' | 'password' | 'radio' | 'range' | 'reset' | 'search' | 'submit' | 'tel' | 'text' | 'time' | 'url' | 'week' >('text'), name: String, size: { type: String as PropType }, autofocus: { type: Boolean, default: undefined }, lazy: { type: Boolean, default: true }, maxlength: Number, loading: { type: Boolean, default: undefined }, bordered: { type: Boolean, default: undefined }, showCount: { type: [Boolean, Object] as PropType }, htmlSize: Number, onPressEnter: Function as PropType, onKeydown: Function as PropType, onKeyup: Function as PropType, onFocus: Function as PropType, onBlur: Function as PropType, onChange: Function as PropType, onInput: Function as PropType, 'onUpdate:value': Function as PropType<(val: string) => void>, onCompositionstart: Function as PropType, onCompositionend: Function as PropType, valueModifiers: Object, hidden: { type: Boolean, default: undefined }, status: String as PropType, }); export type InputProps = Partial>>; export interface ShowCountProps { formatter: (args: { count: number; maxlength?: number; value?: string }) => VueNode; } export interface InputRef { focus: (options?: InputFocusOptions) => void; blur: () => void; setSelectionRange: ( start: number, end: number, direction?: 'forward' | 'backward' | 'none', ) => void; select: () => void; input: HTMLInputElement | null; }