@@ -5,11 +5,12 @@ import StepHandler from './StepHandler';
5
5
import { getNumberPrecision , num2str , validateNumber } from './utils/numberUtil' ;
6
6
import useCursor from './hooks/useCursor' ;
7
7
import useFrame from './hooks/useFrame' ;
8
- import type { HTMLAttributes , PropType } from 'vue' ;
8
+ import type { HTMLAttributes } from 'vue' ;
9
9
import { watch , computed , ref , defineComponent } from 'vue' ;
10
10
import type { ChangeEvent , KeyboardEventHandler } from '../../_util/EventInterface' ;
11
11
import KeyCode from '../../_util/KeyCode' ;
12
12
import classNames from '../../_util/classNames' ;
13
+ import { booleanType , stringType , someType , functionType } from '../../_util/type' ;
13
14
14
15
/**
15
16
* We support `stringMode` which need handle correct type when user call in onChange
@@ -36,46 +37,42 @@ const getDecimalIfValidate = (value: ValueType) => {
36
37
37
38
export const inputNumberProps = ( ) => ( {
38
39
/** value will show as string */
39
- stringMode : { type : Boolean as PropType < boolean > } ,
40
-
41
- defaultValue : { type : [ String , Number ] as PropType < ValueType > } ,
42
- value : { type : [ String , Number ] as PropType < ValueType > } ,
43
-
44
- prefixCls : { type : String as PropType < string > } ,
45
- min : { type : [ String , Number ] as PropType < ValueType > } ,
46
- max : { type : [ String , Number ] as PropType < ValueType > } ,
47
- step : { type : [ String , Number ] as PropType < ValueType > , default : 1 } ,
48
- tabindex : { type : Number as PropType < number > } ,
49
- controls : { type : Boolean as PropType < boolean > , default : true } ,
50
- readonly : { type : Boolean as PropType < boolean > } ,
51
- disabled : { type : Boolean as PropType < boolean > } ,
52
- autofocus : { type : Boolean as PropType < boolean > } ,
53
- keyboard : { type : Boolean as PropType < boolean > , default : true } ,
40
+ stringMode : booleanType ( ) ,
41
+
42
+ defaultValue : someType < ValueType > ( [ String , Number ] ) ,
43
+ value : someType < ValueType > ( [ String , Number ] ) ,
44
+
45
+ prefixCls : stringType < string > ( ) ,
46
+ min : someType < ValueType > ( [ String , Number ] ) ,
47
+ max : someType < ValueType > ( [ String , Number ] ) ,
48
+ step : someType < ValueType > ( [ String , Number ] , 1 ) ,
49
+ tabindex : Number ,
50
+ controls : booleanType ( true ) ,
51
+ readonly : booleanType ( ) ,
52
+ disabled : booleanType ( ) ,
53
+ autofocus : booleanType ( ) ,
54
+ keyboard : booleanType ( true ) ,
54
55
55
56
/** Parse display value to validate number */
56
- parser : { type : Function as PropType < ( displayValue : string | undefined ) => ValueType > } ,
57
+ parser : functionType < ( displayValue : string | undefined ) => ValueType > ( ) ,
57
58
/** Transform `value` to display value show in input */
58
- formatter : {
59
- type : Function as PropType <
59
+ formatter :
60
+ functionType <
60
61
( value : ValueType | undefined , info : { userTyping : boolean ; input : string } ) => string
61
- > ,
62
- } ,
62
+ > ( ) ,
63
63
/** Syntactic sugar of `formatter`. Config precision of display. */
64
- precision : { type : Number as PropType < number > } ,
64
+ precision : Number ,
65
65
/** Syntactic sugar of `formatter`. Config decimal separator of display. */
66
- decimalSeparator : { type : String as PropType < string > } ,
66
+ decimalSeparator : String ,
67
67
68
- onInput : { type : Function as PropType < ( text : string ) => void > } ,
69
- onChange : { type : Function as PropType < ( value : ValueType ) => void > } ,
70
- onPressEnter : { type : Function as PropType < KeyboardEventHandler > } ,
68
+ onInput : functionType < ( text : string ) => void > ( ) ,
69
+ onChange : functionType < ( value : ValueType ) => void > ( ) ,
70
+ onPressEnter : functionType < KeyboardEventHandler > ( ) ,
71
71
72
- onStep : {
73
- type : Function as PropType <
74
- ( value : ValueType , info : { offset : ValueType ; type : 'up' | 'down' } ) => void
75
- > ,
76
- } ,
77
- onBlur : { type : Function as PropType < ( e : FocusEvent ) => void > } ,
78
- onFocus : { type : Function as PropType < ( e : FocusEvent ) => void > } ,
72
+ onStep :
73
+ functionType < ( value : ValueType , info : { offset : ValueType ; type : 'up' | 'down' } ) => void > ( ) ,
74
+ onBlur : functionType < ( e : FocusEvent ) => void > ( ) ,
75
+ onFocus : functionType < ( e : FocusEvent ) => void > ( ) ,
79
76
} ) ;
80
77
81
78
export default defineComponent ( {
0 commit comments