@autobest-ui/components 2.1.1 → 2.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/input-number/ControlArrow.d.ts +7 -0
- package/esm/input-number/ControlArrow.js +34 -0
- package/esm/input-number/constants.d.ts +2 -0
- package/esm/input-number/constants.js +4 -0
- package/esm/input-number/index.d.ts +79 -96
- package/esm/input-number/index.js +221 -457
- package/esm/input-number/style/index.css +1 -1
- package/esm/input-number/style/index.scss +50 -67
- package/esm/style.css +1 -1
- package/lib/input-number/ControlArrow.d.ts +7 -0
- package/lib/input-number/ControlArrow.js +43 -0
- package/lib/input-number/constants.d.ts +2 -0
- package/lib/input-number/constants.js +12 -0
- package/lib/input-number/index.d.ts +79 -96
- package/lib/input-number/index.js +225 -458
- package/lib/input-number/style/index.css +1 -1
- package/lib/input-number/style/index.scss +50 -67
- package/lib/style.css +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
function ArrowIcon(props) {
|
|
4
|
+
return /*#__PURE__*/React.createElement("svg", {
|
|
5
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
6
|
+
viewBox: "0 0 8 16",
|
|
7
|
+
xmlnsXlink: "http://www.w3.org/1999/xlink",
|
|
8
|
+
width: "1em",
|
|
9
|
+
height: "1em",
|
|
10
|
+
fill: "currentColor",
|
|
11
|
+
style: {
|
|
12
|
+
transform: "rotate(".concat(props.rotateDeg, "deg)")
|
|
13
|
+
}
|
|
14
|
+
}, /*#__PURE__*/React.createElement("path", {
|
|
15
|
+
d: "M0 0l8 8-8 8V0z",
|
|
16
|
+
fillRule: "evenodd"
|
|
17
|
+
}));
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export default function ControlArrow(props) {
|
|
21
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
22
|
+
className: "".concat(props.cls, "-arrow")
|
|
23
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
24
|
+
className: "".concat(props.cls, "-up"),
|
|
25
|
+
onMouseDown: props.onKeyup
|
|
26
|
+
}, /*#__PURE__*/React.createElement(ArrowIcon, {
|
|
27
|
+
rotateDeg: -90
|
|
28
|
+
})), /*#__PURE__*/React.createElement("span", {
|
|
29
|
+
className: "".concat(props.cls, "-down"),
|
|
30
|
+
onMouseDown: props.onKeydown
|
|
31
|
+
}, /*#__PURE__*/React.createElement(ArrowIcon, {
|
|
32
|
+
rotateDeg: 90
|
|
33
|
+
})));
|
|
34
|
+
}
|
|
@@ -1,26 +1,22 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
interface
|
|
4
|
-
(value: string, name?: string): void;
|
|
5
|
-
}
|
|
6
|
-
interface ChangeEvent {
|
|
7
|
-
target: {
|
|
8
|
-
value: string | number;
|
|
9
|
-
};
|
|
10
|
-
}
|
|
11
|
-
export interface InputNumberProps extends Omit<React.InputHTMLAttributes<any>, 'onChange'> {
|
|
2
|
+
import { AddListenerEventHandler } from '@autobest-ui/utils';
|
|
3
|
+
export interface InputNumberProps extends Omit<React.InputHTMLAttributes<any>, 'onChange' | 'onBlur' | 'onFocus'> {
|
|
12
4
|
/**
|
|
13
|
-
*
|
|
5
|
+
* 输入框默认值,用于非受控组件,配合ref使用
|
|
14
6
|
*/
|
|
15
|
-
|
|
7
|
+
defaultValue?: number | string;
|
|
8
|
+
/**
|
|
9
|
+
* 输入框中的值
|
|
10
|
+
*/
|
|
11
|
+
value?: number | string;
|
|
16
12
|
/**
|
|
17
13
|
* input样式
|
|
18
14
|
*/
|
|
19
15
|
className?: string;
|
|
20
16
|
/**
|
|
21
|
-
*
|
|
17
|
+
* 输入框的别名
|
|
22
18
|
*/
|
|
23
|
-
|
|
19
|
+
name?: string;
|
|
24
20
|
/**
|
|
25
21
|
* 最小值
|
|
26
22
|
*/
|
|
@@ -30,116 +26,103 @@ export interface InputNumberProps extends Omit<React.InputHTMLAttributes<any>, '
|
|
|
30
26
|
*/
|
|
31
27
|
max?: number;
|
|
32
28
|
/**
|
|
33
|
-
*
|
|
34
|
-
* 注:packMultiple不允许传小数
|
|
29
|
+
* 数值精度, 0 => 整数, null => 没有限制
|
|
35
30
|
*/
|
|
36
|
-
|
|
31
|
+
precision?: number;
|
|
37
32
|
/**
|
|
38
33
|
* 输入框是否可以操作
|
|
39
34
|
*/
|
|
40
35
|
disabled?: boolean;
|
|
41
36
|
/**
|
|
42
|
-
*
|
|
37
|
+
* 是否使用上下控制按钮
|
|
43
38
|
*/
|
|
44
|
-
|
|
39
|
+
controls?: boolean;
|
|
45
40
|
/**
|
|
46
|
-
*
|
|
41
|
+
* 每次改变的大小,作用在上下控制按钮上
|
|
47
42
|
*/
|
|
48
|
-
|
|
43
|
+
step?: number;
|
|
49
44
|
/**
|
|
50
|
-
*
|
|
45
|
+
* 是否启用键盘上下快捷行为
|
|
51
46
|
*/
|
|
52
|
-
|
|
47
|
+
keyboard?: boolean;
|
|
53
48
|
/**
|
|
54
|
-
*
|
|
55
|
-
*/
|
|
56
|
-
name?: string;
|
|
57
|
-
/**
|
|
58
|
-
* 防抖时间 单位: ms
|
|
49
|
+
* 值修改后的回调函数,用于修改value属性
|
|
59
50
|
*/
|
|
60
|
-
|
|
51
|
+
onChange?: (parserValue: number | undefined, name?: string) => void;
|
|
61
52
|
/**
|
|
62
|
-
*
|
|
53
|
+
* 值发生改变将会触发,onChange是不合法将不在触发,只在最后onBlur时再触发一次
|
|
54
|
+
* 该方法主要用在用户输入内容判断上,不要在此方法中执行修改value的操作
|
|
63
55
|
*/
|
|
64
|
-
|
|
56
|
+
onContinualChange?: (originalValue: string | number | undefined, parserValue: number | undefined, name?: string) => void;
|
|
65
57
|
/**
|
|
66
|
-
*
|
|
58
|
+
* 获得焦点的回调函数
|
|
67
59
|
*/
|
|
68
|
-
|
|
60
|
+
onFocus?: (parserValue: number | undefined, name?: string) => void;
|
|
69
61
|
/**
|
|
70
|
-
*
|
|
62
|
+
* 失去焦点的回调函数
|
|
71
63
|
*/
|
|
72
|
-
|
|
64
|
+
onBlur?: (parserValue: number | undefined, name?: string) => void;
|
|
73
65
|
}
|
|
74
66
|
interface InputNumberStates {
|
|
75
|
-
|
|
76
|
-
|
|
67
|
+
originalValueStr: string | undefined;
|
|
68
|
+
parserValue: number | undefined;
|
|
69
|
+
isEnterInput: boolean;
|
|
70
|
+
isFocusInput: boolean;
|
|
77
71
|
}
|
|
78
|
-
interface
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
72
|
+
interface InputNumberPropsWithRef extends InputNumberProps {
|
|
73
|
+
/**
|
|
74
|
+
* 此属性可以忽略, storybook问题
|
|
75
|
+
*/
|
|
76
|
+
upperRef: React.Ref<HTMLInputElement>;
|
|
83
77
|
}
|
|
84
|
-
declare class
|
|
78
|
+
export declare class InputNumberNotRef extends React.Component<InputNumberPropsWithRef, InputNumberStates> {
|
|
79
|
+
prefixCls: string;
|
|
80
|
+
inputRef: React.RefObject<HTMLInputElement>;
|
|
81
|
+
keyboardHandler: AddListenerEventHandler;
|
|
85
82
|
static defaultProps: {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
digital: number;
|
|
91
|
-
padDigital: boolean;
|
|
92
|
-
delay: number;
|
|
93
|
-
visibleButton: boolean;
|
|
83
|
+
defaultValue: string;
|
|
84
|
+
controls: boolean;
|
|
85
|
+
step: number;
|
|
86
|
+
keyboard: boolean;
|
|
94
87
|
};
|
|
95
|
-
constructor(props:
|
|
96
|
-
|
|
97
|
-
changePackMultipleValueDebounce: ReturnType<typeof debounce>;
|
|
98
|
-
padDigitalDebounce: ReturnType<typeof debounce>;
|
|
99
|
-
addLocationInfo: LocationInfo;
|
|
100
|
-
subLocationInfo: LocationInfo;
|
|
101
|
-
mouseUpHandler: AddListenerEventHandler;
|
|
102
|
-
mouseMoveHandler: AddListenerEventHandler;
|
|
103
|
-
componentDidMount(): void;
|
|
88
|
+
constructor(props: InputNumberPropsWithRef);
|
|
89
|
+
static getDerivedStateFromProps(nextProps: InputNumberPropsWithRef, prevStates: InputNumberStates): InputNumberStates;
|
|
104
90
|
componentWillUnmount(): void;
|
|
105
|
-
|
|
106
|
-
|
|
91
|
+
/**
|
|
92
|
+
* 解析用户输入的内容,并返回解析后的结果
|
|
93
|
+
* @param originalValue
|
|
94
|
+
*/
|
|
95
|
+
getParserOriginalValue: (originalValue: string) => string | undefined;
|
|
96
|
+
/**
|
|
97
|
+
* 键盘和点击上下按钮更新value值
|
|
98
|
+
* @param isUp
|
|
99
|
+
*/
|
|
100
|
+
changeValueWithStep: (isUp: boolean) => void;
|
|
101
|
+
/**
|
|
102
|
+
* 设置input焦点
|
|
103
|
+
*/
|
|
104
|
+
setInputFocus: () => void;
|
|
105
|
+
onKeyboard: (ev: KeyboardEvent) => void;
|
|
106
|
+
onFocus: (ev: {
|
|
107
|
+
target: HTMLInputElement;
|
|
108
|
+
}) => void;
|
|
109
|
+
onBlur: (ev: {
|
|
110
|
+
target: HTMLInputElement;
|
|
111
|
+
}) => void;
|
|
112
|
+
/**
|
|
113
|
+
* 修改value值的回调
|
|
114
|
+
* 注:value值当不在合法时,将不再触发onChange
|
|
115
|
+
* 在输入结束后(onBlur时),触发最后一次
|
|
116
|
+
* @param ev
|
|
117
|
+
*/
|
|
118
|
+
onChangeValue: (ev: {
|
|
119
|
+
target: HTMLInputElement;
|
|
120
|
+
}) => void;
|
|
121
|
+
onKeyup: (ev: React.MouseEvent) => void;
|
|
122
|
+
onKeydown: (ev: React.MouseEvent) => void;
|
|
107
123
|
onMouseEnter: () => void;
|
|
108
124
|
onMouseLeave: () => void;
|
|
109
|
-
onMouseMove: (ev: React.MouseEvent) => void;
|
|
110
|
-
onMouseDown: (ev: React.MouseEvent) => void;
|
|
111
|
-
onMouseUp: () => void;
|
|
112
|
-
addMouseMoveListener: () => void;
|
|
113
|
-
addMouseUpListener: () => void;
|
|
114
|
-
getElement: () => {
|
|
115
|
-
inputEl: HTMLInputElement;
|
|
116
|
-
addBtnEl: HTMLDivElement;
|
|
117
|
-
subBtnEl: HTMLDivElement;
|
|
118
|
-
};
|
|
119
|
-
getMouseElement: (ev: React.MouseEvent) => {
|
|
120
|
-
isAdd: boolean;
|
|
121
|
-
isSub: boolean;
|
|
122
|
-
};
|
|
123
|
-
isInside: (ev: React.MouseEvent, locationInfo: LocationInfo) => boolean;
|
|
124
|
-
getLocationInfo: () => void;
|
|
125
|
-
getCurrentValue: (value: string) => number;
|
|
126
|
-
getPadDigitalValue: (value: string) => string;
|
|
127
|
-
onChangePackMultipleValue: (value: string) => void;
|
|
128
|
-
onPadDigital: (value: any) => void;
|
|
129
|
-
getPadDigitalDebounce: () => {
|
|
130
|
-
(...arg: any[]): void;
|
|
131
|
-
cancel(): void;
|
|
132
|
-
};
|
|
133
|
-
getChangePackMultipleValueDebounce: () => {
|
|
134
|
-
(...arg: any[]): void;
|
|
135
|
-
cancel(): void;
|
|
136
|
-
};
|
|
137
|
-
callback: (value: string, ignoreDelay?: any) => void;
|
|
138
|
-
onValueChange: (ev: ChangeEvent, ignoreDelay?: any) => void;
|
|
139
|
-
getValueCalculate: (value: number, offset: number) => number;
|
|
140
|
-
onAdd: () => void;
|
|
141
|
-
onSub: () => void;
|
|
142
|
-
renderButton: () => JSX.Element;
|
|
143
125
|
render(): JSX.Element;
|
|
144
126
|
}
|
|
127
|
+
declare const InputNumber: React.ComponentType<InputNumberProps>;
|
|
145
128
|
export default InputNumber;
|