UNPKG

@opensig/opendesign

Version:

44 lines (43 loc) 1.8 kB
import { Ref, VNode } from 'vue'; export type UseInputEmitsT = { (e: 'change', value: string, lastValue: string): void; (e: 'input', evt: Event, value: string): void; (e: 'focus', evt: FocusEvent): void; (e: 'blur', evt: FocusEvent): void; (e: 'clear', evt?: Event): void; (e: 'pressEnter', evt: KeyboardEvent): void; }; export interface InputOptionT { modelValue?: Ref<string | undefined>; defaultValue?: string; emits: UseInputEmitsT; emitUpdate: (value: string) => void; validate?: (value: string) => boolean; valueOnInvalidChange?: boolean | ((inputValue: string, lastValidInputValue: string) => string); format?: (value: string) => string; maxLength?: Ref<number | undefined>; minLength?: Ref<number | undefined>; showLength?: Ref<'always' | 'auto' | 'never' | ((length: number) => string | VNode)>; calculateLength?: (value: string) => number; inputOnOutlimit?: Ref<boolean | undefined>; onlyNumericInput?: Ref<boolean | undefined>; } /** * 输入框 */ export declare function useInput(options: InputOptionT): { realValue: import('vue').ComputedRef<string>; displayValue: import('vue').ComputedRef<string>; isValid: Ref<boolean, boolean>; inputEl: Ref<HTMLInputElement | HTMLTextAreaElement | undefined, HTMLInputElement | HTMLTextAreaElement | undefined>; clearValue: () => void; isFocus: Ref<boolean, boolean>; inputValueLength: import('vue').ComputedRef<number>; isShowLength: import('vue').ComputedRef<boolean>; isOutLengthLimit: import('vue').ComputedRef<boolean>; handleInput: (e: Event) => void; handleFocus: (e: FocusEvent) => void; handleBlur: (e: FocusEvent) => void; handlePressEnter: (e: KeyboardEvent) => void; handleClear: (e: Event) => void; };