@opensig/opendesign
Version:
<p align="center"><img src="../docs/public/opendesign-logo-light.png"/></p> <h1 align="center">opendesign</h1> <p align="center">一个 Vue 3 组件库</p> <p align="center"><b>皮肤可定制,使用 TypeScript</b></p>
40 lines (39 loc) • 1.51 kB
TypeScript
import { Ref } 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?: (inputValue: string, lastValidInputValue: string) => string;
format?: (value: string) => string;
maxLength?: Ref<number | undefined>;
minLength?: Ref<number | undefined>;
calculateLength?: (value: string) => number;
inputOnOutlimit?: 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 | undefined, HTMLInputElement | undefined>;
clearValue: () => void;
inputValueLength: import('vue').ComputedRef<number>;
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;
};