@autobest-ui/components 2.9.2 → 2.10.0-alpha.0

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.
Files changed (107) hide show
  1. package/esm/affix/index.d.ts +3 -3
  2. package/esm/affix/index.js +2 -2
  3. package/esm/carousel/index.d.ts +2 -2
  4. package/esm/carousel/index.js +1 -1
  5. package/esm/checkbox/Checkbox.d.ts +60 -0
  6. package/esm/checkbox/Checkbox.js +120 -0
  7. package/esm/checkbox/CheckboxGroup.d.ts +16 -0
  8. package/esm/checkbox/CheckboxGroup.js +57 -0
  9. package/esm/checkbox/index.d.ts +4 -52
  10. package/esm/checkbox/index.js +2 -114
  11. package/esm/checkbox/style/index.css +1 -1
  12. package/esm/ellipsis/index.d.ts +1 -8
  13. package/esm/ellipsis/index.js +9 -9
  14. package/esm/ellipsis/style/index.css +1 -1
  15. package/esm/index.d.ts +6 -3
  16. package/esm/index.js +4 -2
  17. package/esm/input/Input.d.ts +13 -1
  18. package/esm/input/Input.js +64 -4
  19. package/esm/input/TextArea.d.ts +8 -0
  20. package/esm/input/TextArea.js +43 -12
  21. package/esm/input-number/getParserOriginalValue.d.ts +26 -0
  22. package/esm/input-number/getParserOriginalValue.js +73 -0
  23. package/esm/input-number/index.d.ts +20 -7
  24. package/esm/input-number/index.js +60 -48
  25. package/esm/modal/index.d.ts +3 -3
  26. package/esm/modal/index.js +2 -2
  27. package/esm/move/index.d.ts +6 -6
  28. package/esm/move/index.js +5 -5
  29. package/esm/popover/index.d.ts +1 -1
  30. package/esm/popover/index.js +7 -2
  31. package/esm/radio/Radio.d.ts +4 -0
  32. package/esm/radio/Radio.js +80 -0
  33. package/esm/radio/RadioGroup.d.ts +16 -0
  34. package/esm/radio/RadioGroup.js +106 -0
  35. package/esm/radio/context.d.ts +5 -0
  36. package/esm/radio/context.js +4 -0
  37. package/esm/radio/index.d.ts +3 -0
  38. package/esm/radio/index.js +2 -0
  39. package/esm/radio/interface.d.ts +17 -0
  40. package/esm/radio/interface.js +1 -0
  41. package/esm/radio/style/index.css +1 -0
  42. package/esm/select/index.d.ts +2 -2
  43. package/esm/select/index.js +1 -1
  44. package/esm/style.css +1 -1
  45. package/esm/table/body/CheckIcon.js +1 -1
  46. package/esm/table/header/CheckIcon.js +1 -1
  47. package/esm/table/index.d.ts +2 -2
  48. package/esm/table/index.js +2 -1
  49. package/esm/table/style/index.css +1 -1
  50. package/esm/tabs/index.d.ts +2 -2
  51. package/esm/tabs/index.js +1 -1
  52. package/esm/trigger/index.d.ts +5 -5
  53. package/esm/trigger/index.js +5 -5
  54. package/lib/affix/index.d.ts +3 -3
  55. package/lib/affix/index.js +2 -2
  56. package/lib/carousel/index.d.ts +2 -2
  57. package/lib/carousel/index.js +1 -1
  58. package/lib/checkbox/Checkbox.d.ts +60 -0
  59. package/lib/checkbox/Checkbox.js +128 -0
  60. package/lib/checkbox/CheckboxGroup.d.ts +16 -0
  61. package/lib/checkbox/CheckboxGroup.js +65 -0
  62. package/lib/checkbox/index.d.ts +4 -52
  63. package/lib/checkbox/index.js +13 -115
  64. package/lib/checkbox/style/index.css +1 -1
  65. package/lib/ellipsis/index.d.ts +1 -8
  66. package/lib/ellipsis/index.js +9 -9
  67. package/lib/ellipsis/style/index.css +1 -1
  68. package/lib/index.d.ts +6 -3
  69. package/lib/index.js +40 -2
  70. package/lib/input/Input.d.ts +13 -1
  71. package/lib/input/Input.js +64 -4
  72. package/lib/input/TextArea.d.ts +8 -0
  73. package/lib/input/TextArea.js +43 -12
  74. package/lib/input-number/getParserOriginalValue.d.ts +26 -0
  75. package/lib/input-number/getParserOriginalValue.js +79 -0
  76. package/lib/input-number/index.d.ts +20 -7
  77. package/lib/input-number/index.js +59 -47
  78. package/lib/modal/index.d.ts +3 -3
  79. package/lib/modal/index.js +2 -2
  80. package/lib/move/index.d.ts +6 -6
  81. package/lib/move/index.js +5 -5
  82. package/lib/popover/index.d.ts +1 -1
  83. package/lib/popover/index.js +7 -2
  84. package/lib/radio/Radio.d.ts +4 -0
  85. package/lib/radio/Radio.js +91 -0
  86. package/lib/radio/RadioGroup.d.ts +16 -0
  87. package/lib/radio/RadioGroup.js +117 -0
  88. package/lib/radio/context.d.ts +5 -0
  89. package/lib/radio/context.js +15 -0
  90. package/lib/radio/index.d.ts +3 -0
  91. package/lib/radio/index.js +20 -0
  92. package/lib/radio/interface.d.ts +17 -0
  93. package/lib/radio/interface.js +5 -0
  94. package/lib/radio/style/index.css +1 -0
  95. package/lib/select/index.d.ts +2 -2
  96. package/lib/select/index.js +1 -1
  97. package/lib/style.css +1 -1
  98. package/lib/table/body/CheckIcon.js +2 -2
  99. package/lib/table/header/CheckIcon.js +2 -2
  100. package/lib/table/index.d.ts +2 -2
  101. package/lib/table/index.js +2 -1
  102. package/lib/table/style/index.css +1 -1
  103. package/lib/tabs/index.d.ts +2 -2
  104. package/lib/tabs/index.js +1 -1
  105. package/lib/trigger/index.d.ts +5 -5
  106. package/lib/trigger/index.js +5 -5
  107. package/package.json +5 -4
@@ -33,7 +33,8 @@ var __assign = this && this.__assign || function () {
33
33
  return __assign.apply(this, arguments);
34
34
  };
35
35
  import React from 'react';
36
- import { composeRef, isEmptyObject } from '@autobest-ui/utils';
36
+ import { isEmptyObject, isBlank } from '@autobest-ui/utils';
37
+ import { composeRef } from '@autobest-ui/components';
37
38
  import Adorn from './Adorn';
38
39
  var InputNotRef = /** @class */function (_super) {
39
40
  __extends(InputNotRef, _super);
@@ -47,6 +48,53 @@ var InputNotRef = /** @class */function (_super) {
47
48
  _this.getFileInfo = function (element) {
48
49
  return element && element.files && element.files.length ? element.files[0] : undefined;
49
50
  };
51
+ /**
52
+ * 在触发了onChange的前提下,如果当前为失焦状态,则触发一次onBlur
53
+ * @param value
54
+ */
55
+ _this.onBlurOnMounted = function (value) {
56
+ var _a = _this.props,
57
+ onBlur = _a.onBlur,
58
+ autoFocus = _a.autoFocus,
59
+ name = _a.name;
60
+ if (!onBlur || autoFocus || document.activeElement === _this.inputRef.current) {
61
+ return;
62
+ }
63
+ onBlur(value, name);
64
+ };
65
+ _this.checkCurrentValue = function () {
66
+ if (!_this.inputRef.current) {
67
+ return;
68
+ }
69
+ if (_this.isFileUpload()) {
70
+ var file = _this.getFileInfo(_this.inputRef.current);
71
+ if (file) {
72
+ var _a = _this.props,
73
+ name_1 = _a.name,
74
+ onChange = _a.onChange;
75
+ if (onChange) {
76
+ onChange(file, name_1);
77
+ }
78
+ _this.onBlurOnMounted(file);
79
+ }
80
+ return;
81
+ }
82
+ var value = _this.inputRef.current.value;
83
+ if (!isBlank(value) && _this.state.value !== value) {
84
+ var _b = _this.props,
85
+ name_2 = _b.name,
86
+ onChange = _b.onChange;
87
+ if (onChange) {
88
+ onChange(value, name_2);
89
+ _this.onBlurOnMounted(value);
90
+ return;
91
+ }
92
+ _this.setState({
93
+ value: value
94
+ });
95
+ _this.onBlurOnMounted(value);
96
+ }
97
+ };
50
98
  /**
51
99
  * 修改value值的回调
52
100
  * @param ev
@@ -138,6 +186,10 @@ var InputNotRef = /** @class */function (_super) {
138
186
  }
139
187
  element.focus();
140
188
  }
189
+ if (this.props.checkValueOnMounted) {
190
+ // ssr在网络慢时,用户在js文件加载完前修改input框的会导致不触发onChange
191
+ this.checkCurrentValue();
192
+ }
141
193
  };
142
194
  InputNotRef.prototype.render = function () {
143
195
  var cls = this.prefixCls;
@@ -151,7 +203,10 @@ var InputNotRef = /** @class */function (_super) {
151
203
  className = _a.className,
152
204
  prefix = _a.prefix,
153
205
  suffix = _a.suffix,
154
- maxLength = _a.maxLength;
206
+ maxLength = _a.maxLength,
207
+ title = _a.title,
208
+ onKeyUp = _a.onKeyUp,
209
+ name = _a.name;
155
210
  var value = this.state.value;
156
211
  var isFileUpload = this.isFileUpload();
157
212
  return /*#__PURE__*/React.createElement(Adorn, {
@@ -171,14 +226,19 @@ var InputNotRef = /** @class */function (_super) {
171
226
  accept: accept,
172
227
  maxLength: maxLength,
173
228
  style: style,
229
+ name: name,
174
230
  value: isFileUpload ? undefined : value || '',
175
231
  onChange: this.onChange,
176
- onKeyDown: this.onKeyDown
232
+ onKeyDown: this.onKeyDown,
233
+ title: title,
234
+ onKeyUp: onKeyUp,
235
+ "aria-label": this.props['aria-label']
177
236
  }));
178
237
  };
179
238
  InputNotRef.defaultProps = {
180
239
  defaultValue: '',
181
- type: 'text'
240
+ type: 'text',
241
+ checkValueOnMounted: false
182
242
  };
183
243
  return InputNotRef;
184
244
  }(React.Component);
@@ -33,6 +33,11 @@ export interface TextAreaProps extends Omit<AdornProps, 'prefixCls' | 'children'
33
33
  * 用户触发keydown时的回调,主要用于键盘监听
34
34
  */
35
35
  onKeyDown?: (event: React.KeyboardEvent<HTMLTextAreaElement>, name?: string) => void;
36
+ /**
37
+ * 在网络慢时,组件已经渲染js文件还未加载,用户此时修改input框会不触发onChange事件
38
+ * 需要在组件加载后检测输入框内容,触发一次onChange
39
+ */
40
+ checkValueOnMounted?: boolean;
36
41
  }
37
42
  interface TextareaStates {
38
43
  value: string | undefined;
@@ -51,10 +56,13 @@ export declare class TextAreaNotRef extends React.Component<TextAreaPropsWithRef
51
56
  defaultValue: string;
52
57
  rows: number;
53
58
  maxlength: number;
59
+ checkValueOnMounted: boolean;
54
60
  };
55
61
  constructor(props: TextAreaPropsWithRef);
56
62
  static getDerivedStateFromProps(nextProps: TextAreaPropsWithRef, prevStates: TextareaStates): TextareaStates;
57
63
  componentDidMount(): void;
64
+ changeValue: (value: any, onBlurAfterChange?: boolean) => void;
65
+ checkCurrentValue: () => void;
58
66
  /**
59
67
  * 修改value值的回调
60
68
  * @param ev
@@ -33,7 +33,8 @@ var __assign = this && this.__assign || function () {
33
33
  return __assign.apply(this, arguments);
34
34
  };
35
35
  import React from 'react';
36
- import { composeRef, isBlank, isEmptyObject } from '@autobest-ui/utils';
36
+ import { composeRef } from '@autobest-ui/components';
37
+ import { isBlank, isEmptyObject } from '@autobest-ui/utils';
37
38
  import Adorn from './Adorn';
38
39
  function getValueLength(value) {
39
40
  return isBlank(value) ? 0 : value.length;
@@ -44,15 +45,10 @@ var TextAreaNotRef = /** @class */function (_super) {
44
45
  var _this = _super.call(this, props) || this;
45
46
  _this.prefixCls = 'ab-textarea';
46
47
  _this.textareaRef = /*#__PURE__*/React.createRef();
47
- /**
48
- * 修改value值的回调
49
- * @param ev
50
- */
51
- _this.onChange = function (ev) {
52
- if (_this.props.disabled) {
53
- return;
48
+ _this.changeValue = function (value, onBlurAfterChange) {
49
+ if (onBlurAfterChange === void 0) {
50
+ onBlurAfterChange = false;
54
51
  }
55
- var value = ev.target.value;
56
52
  if (_this.props.maxLength > 0) {
57
53
  var currentLength = getValueLength(value);
58
54
  if (_this.props.maxLength && currentLength > _this.props.maxLength) {
@@ -64,14 +60,43 @@ var TextAreaNotRef = /** @class */function (_super) {
64
60
  }
65
61
  var _a = _this.props,
66
62
  onChange = _a.onChange,
67
- name = _a.name;
63
+ name = _a.name,
64
+ onBlur = _a.onBlur;
68
65
  if (onChange) {
69
66
  onChange(value, name);
67
+ if (onBlurAfterChange && onBlur) {
68
+ onBlur(value, name);
69
+ }
70
70
  return;
71
71
  }
72
72
  _this.setState({
73
73
  value: value
74
74
  });
75
+ if (onBlurAfterChange && onBlur) {
76
+ onBlur(value, name);
77
+ }
78
+ };
79
+ _this.checkCurrentValue = function () {
80
+ if (!_this.textareaRef.current) {
81
+ return;
82
+ }
83
+ var value = _this.textareaRef.current.value;
84
+ if (!isBlank(value) && _this.state.value !== value) {
85
+ var autoFocus = _this.props.autoFocus;
86
+ // 在值改变了的前提下,如果当前为失焦状态,则触发一次onBlur
87
+ _this.changeValue(value, !autoFocus && document.activeElement !== _this.textareaRef.current);
88
+ }
89
+ };
90
+ /**
91
+ * 修改value值的回调
92
+ * @param ev
93
+ */
94
+ _this.onChange = function (ev) {
95
+ if (_this.props.disabled) {
96
+ return;
97
+ }
98
+ var value = ev.target.value;
99
+ _this.changeValue(value);
75
100
  };
76
101
  _this.onFocus = function (ev) {
77
102
  var _a = _this.props,
@@ -129,6 +154,9 @@ var TextAreaNotRef = /** @class */function (_super) {
129
154
  }
130
155
  element.focus();
131
156
  }
157
+ if (this.props.checkValueOnMounted) {
158
+ this.checkCurrentValue();
159
+ }
132
160
  };
133
161
  TextAreaNotRef.prototype.renderSuffix = function () {
134
162
  var maxLength = this.props.maxLength;
@@ -147,7 +175,8 @@ var TextAreaNotRef = /** @class */function (_super) {
147
175
  className = _a.className,
148
176
  prefix = _a.prefix,
149
177
  rows = _a.rows,
150
- maxLength = _a.maxLength;
178
+ maxLength = _a.maxLength,
179
+ name = _a.name;
151
180
  var value = this.state.value;
152
181
  return /*#__PURE__*/React.createElement(Adorn, {
153
182
  prefixCls: cls,
@@ -164,6 +193,7 @@ var TextAreaNotRef = /** @class */function (_super) {
164
193
  rows: rows,
165
194
  disabled: disabled,
166
195
  maxLength: maxLength,
196
+ name: name,
167
197
  style: style,
168
198
  value: value || '',
169
199
  onChange: this.onChange,
@@ -173,7 +203,8 @@ var TextAreaNotRef = /** @class */function (_super) {
173
203
  TextAreaNotRef.defaultProps = {
174
204
  defaultValue: '',
175
205
  rows: 5,
176
- maxlength: 0
206
+ maxlength: 0,
207
+ checkValueOnMounted: false
177
208
  };
178
209
  return TextAreaNotRef;
179
210
  }(React.Component);
@@ -0,0 +1,26 @@
1
+ interface GetParserOriginalValueParams {
2
+ originalValue: string | number;
3
+ prevParserValue: string | number;
4
+ trimStartZero?: boolean;
5
+ precision?: number;
6
+ isRounding?: boolean;
7
+ min?: number;
8
+ max?: number;
9
+ skipError?: boolean;
10
+ }
11
+ /**
12
+ *
13
+ * @param originalValueParam
14
+ * @param trimStartZero
15
+ * @param prevParserValue
16
+ * @param precision
17
+ * @param isRounding
18
+ * @param min
19
+ * @param max
20
+ * @param skipError 遇到首位0、小于最小值、大于最大值问题,不对value进行处理,输出控制台警告
21
+ */
22
+ export default function ({ originalValue: originalValueParam, trimStartZero, prevParserValue, precision, isRounding, min, max, skipError }: GetParserOriginalValueParams): {
23
+ parserValueStr: string | undefined;
24
+ parserValue: string | number | undefined;
25
+ };
26
+ export {};
@@ -0,0 +1,73 @@
1
+ import { getNumberFromString, isBlank, toFixed } from '@autobest-ui/utils';
2
+ import { FirstZeroReg, NumberReg } from './constants';
3
+ function consoleError(msg) {
4
+ if (process.env.NODE_ENV === 'development') {
5
+ // eslint-disable-next-line no-console
6
+ console.error(msg);
7
+ }
8
+ }
9
+ function getValueBetweenMinAndMax(value, min, max, skipError) {
10
+ var currentValue = parseFloat(value);
11
+ if (!isBlank(min) && currentValue < min) {
12
+ if (!skipError) {
13
+ return min;
14
+ }
15
+ consoleError('Value is smaller than min');
16
+ }
17
+ if (!isBlank(max) && currentValue > max) {
18
+ if (!skipError) {
19
+ return max;
20
+ }
21
+ consoleError('Value is greater than max');
22
+ }
23
+ return currentValue;
24
+ }
25
+ /**
26
+ *
27
+ * @param originalValueParam
28
+ * @param trimStartZero
29
+ * @param prevParserValue
30
+ * @param precision
31
+ * @param isRounding
32
+ * @param min
33
+ * @param max
34
+ * @param skipError 遇到首位0、小于最小值、大于最大值问题,不对value进行处理,输出控制台警告
35
+ */
36
+ export default function (_a) {
37
+ var originalValueParam = _a.originalValue,
38
+ trimStartZero = _a.trimStartZero,
39
+ prevParserValue = _a.prevParserValue,
40
+ precision = _a.precision,
41
+ isRounding = _a.isRounding,
42
+ min = _a.min,
43
+ max = _a.max,
44
+ skipError = _a.skipError;
45
+ // 输入为空
46
+ if (isBlank(originalValueParam)) {
47
+ return {
48
+ parserValueStr: undefined,
49
+ parserValue: undefined
50
+ };
51
+ }
52
+ var originalValue = typeof originalValueParam === 'number' ? originalValueParam.toString() : originalValueParam;
53
+ var hasFirstZero = FirstZeroReg.test(originalValue);
54
+ if (!NumberReg.test(originalValue) || trimStartZero && hasFirstZero) {
55
+ if (!skipError) {
56
+ return {
57
+ parserValueStr: isBlank(prevParserValue) ? undefined : prevParserValue.toString(),
58
+ parserValue: prevParserValue
59
+ };
60
+ }
61
+ consoleError('Value has first 0');
62
+ }
63
+ var currentValue = getValueBetweenMinAndMax(originalValue, min, max, skipError);
64
+ var parserString = toFixed(currentValue, precision, isRounding);
65
+ if (hasFirstZero) {
66
+ // 补齐首位0
67
+ parserString = parserString.padStart(originalValue.split('.')[0].length, '0');
68
+ }
69
+ return {
70
+ parserValueStr: parserString,
71
+ parserValue: hasFirstZero ? parserString : getNumberFromString(parserString)
72
+ };
73
+ }
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
- import { AddListenerEventHandler } from '@autobest-ui/utils';
2
+ import { AddListenerEventRemoveHandler } from '@autobest-ui/utils';
3
3
  import { InputProps, InputValue } from '../input/Input';
4
- export interface InputNumberProps extends Omit<InputProps<number>, 'value' | 'defaultValue' | 'suffix' | 'onKeyDown'> {
4
+ export interface InputNumberProps extends Omit<InputProps<number | string>, 'value' | 'defaultValue' | 'suffix' | 'onKeyDown'> {
5
5
  /**
6
6
  * 输入框默认值,用于非受控组件,配合ref使用
7
7
  */
@@ -42,15 +42,23 @@ export interface InputNumberProps extends Omit<InputProps<number>, 'value' | 'de
42
42
  * 值发生改变将会触发,onChange是不合法将不在触发,只在最后onBlur时再触发一次
43
43
  * 该方法主要用在用户输入内容判断上,不要在此方法中执行修改value的操作
44
44
  */
45
- onContinualChange?: (originalValue: string | number | undefined, parserValue: number | undefined, name?: string) => void;
45
+ onContinualChange?: (originalValue: string | number | undefined, parserValue: string | number | undefined, name?: string) => void;
46
46
  /**
47
47
  * 用户触发keydown时的回调,主要用于键盘监听
48
48
  */
49
- onKeyDown?: (event: React.KeyboardEvent<HTMLInputElement>, parserValue: number | undefined, name?: string) => void;
49
+ onKeyDown?: (event: React.KeyboardEvent<HTMLInputElement>, parserValue: string | number | undefined, name?: string) => void;
50
+ /**
51
+ * 是否过滤开头的0,默认true过滤
52
+ */
53
+ trimStartZero?: boolean;
54
+ /**
55
+ * 处理用户输入值时是否要四舍五入,默认true
56
+ */
57
+ isRounding?: boolean;
50
58
  }
51
59
  interface InputNumberStates {
52
60
  originalValueStr: string | undefined;
53
- parserValue: number | undefined;
61
+ parserValue: string | number | undefined;
54
62
  }
55
63
  interface InputNumberPropsWithRef extends InputNumberProps {
56
64
  /**
@@ -61,12 +69,14 @@ interface InputNumberPropsWithRef extends InputNumberProps {
61
69
  export declare class InputNumberNotRef extends React.Component<InputNumberPropsWithRef, InputNumberStates> {
62
70
  prefixCls: string;
63
71
  inputRef: React.RefObject<HTMLInputElement>;
64
- keyboardHandler: AddListenerEventHandler;
72
+ keyboardHandler: AddListenerEventRemoveHandler;
65
73
  static defaultProps: {
66
74
  defaultValue: string;
67
75
  controls: boolean;
68
76
  step: number;
69
77
  keyboard: boolean;
78
+ trimStartZero: boolean;
79
+ isRounding: boolean;
70
80
  };
71
81
  constructor(props: InputNumberPropsWithRef);
72
82
  static getDerivedStateFromProps(nextProps: InputNumberPropsWithRef, prevStates: InputNumberStates): InputNumberStates;
@@ -75,7 +85,10 @@ export declare class InputNumberNotRef extends React.Component<InputNumberPropsW
75
85
  * 解析用户输入的内容,并返回解析后的结果
76
86
  * @param originalValue
77
87
  */
78
- getParserOriginalValue: (originalValue: string) => string | undefined;
88
+ getParserOriginalValue: (originalValue: string) => {
89
+ parserValueStr: string;
90
+ parserValue: string | number;
91
+ };
79
92
  /**
80
93
  * 键盘和点击上下按钮更新value值
81
94
  * @param isUp
@@ -34,10 +34,12 @@ var __assign = this && this.__assign || function () {
34
34
  };
35
35
  import React from 'react';
36
36
  import classNames from 'classnames';
37
- import { isBlank, composeRef, toFixed, isEmptyObject, addEventListener, getNumberFromString } from '@autobest-ui/utils';
37
+ import { composeRef } from '@autobest-ui/components';
38
+ import { isBlank, isEmptyObject, addEventListener } from '@autobest-ui/utils';
38
39
  import Input from '../input/Input';
39
- import { FirstZeroReg, NumberReg } from './constants';
40
+ import { FirstZeroReg } from './constants';
40
41
  import ControlArrow from './ControlArrow';
42
+ import getParserOriginalValue from './getParserOriginalValue';
41
43
  var InputNumberNotRef = /** @class */function (_super) {
42
44
  __extends(InputNumberNotRef, _super);
43
45
  function InputNumberNotRef(props) {
@@ -49,25 +51,10 @@ var InputNumberNotRef = /** @class */function (_super) {
49
51
  * @param originalValue
50
52
  */
51
53
  _this.getParserOriginalValue = function (originalValue) {
52
- // 输入为空
53
- if (isBlank(originalValue)) {
54
- return undefined;
55
- }
56
- if (!NumberReg.test(originalValue) || FirstZeroReg.test(originalValue)) {
57
- return isBlank(_this.state.parserValue) ? undefined : _this.state.parserValue.toString();
58
- }
59
- var _a = _this.props,
60
- min = _a.min,
61
- max = _a.max,
62
- precision = _a.precision;
63
- var currentValue = parseFloat(originalValue);
64
- if (!isBlank(min) && currentValue < min) {
65
- currentValue = min;
66
- }
67
- if (!isBlank(max) && currentValue > max) {
68
- currentValue = max;
69
- }
70
- return toFixed(currentValue, precision);
54
+ return getParserOriginalValue(__assign(__assign({}, _this.props), {
55
+ originalValue: originalValue,
56
+ prevParserValue: _this.state.parserValue
57
+ }));
71
58
  };
72
59
  /**
73
60
  * 键盘和点击上下按钮更新value值
@@ -75,14 +62,20 @@ var InputNumberNotRef = /** @class */function (_super) {
75
62
  */
76
63
  _this.changeValueWithStep = function (isUp) {
77
64
  var step = _this.props.step;
78
- var prevValue = _this.state.parserValue ? _this.state.parserValue : 0;
65
+ var prevParserValue = _this.state.parserValue;
66
+ var prevValue = prevParserValue ? typeof prevParserValue === 'number' ? prevParserValue : parseFloat(prevParserValue) : 0;
79
67
  var keyboardValue = isUp ? prevValue + step : prevValue - step;
80
- var parserValueStr = _this.getParserOriginalValue(keyboardValue.toString());
81
- var parserValue = getNumberFromString(parserValueStr);
82
- var _a = _this.props,
83
- name = _a.name,
84
- onChange = _a.onChange,
85
- onContinualChange = _a.onContinualChange;
68
+ var keyboardValueStr = keyboardValue.toString();
69
+ if (typeof prevParserValue === 'string' && FirstZeroReg.test(prevParserValue)) {
70
+ keyboardValueStr = keyboardValueStr.padStart(prevParserValue.length, '0');
71
+ }
72
+ var _a = _this.getParserOriginalValue(keyboardValueStr),
73
+ parserValueStr = _a.parserValueStr,
74
+ parserValue = _a.parserValue;
75
+ var _b = _this.props,
76
+ name = _b.name,
77
+ onChange = _b.onChange,
78
+ onContinualChange = _b.onContinualChange;
86
79
  if (prevValue !== parserValue) {
87
80
  if (onContinualChange) {
88
81
  onContinualChange(parserValueStr, parserValue, name);
@@ -123,14 +116,13 @@ var InputNumberNotRef = /** @class */function (_super) {
123
116
  }
124
117
  var onFocus = _this.props.onFocus;
125
118
  if (onFocus) {
126
- var parserValueStr = _this.getParserOriginalValue(originalValueStr);
127
- var parserValue = getNumberFromString(parserValueStr);
119
+ var parserValue = _this.getParserOriginalValue(originalValueStr).parserValue;
128
120
  onFocus(parserValue, name);
129
121
  }
130
122
  };
131
123
  _this.onBlur = function (originalValueStr, name) {
132
124
  if (_this.keyboardHandler) {
133
- _this.keyboardHandler.remove();
125
+ _this.keyboardHandler();
134
126
  _this.keyboardHandler = null;
135
127
  }
136
128
  if (_this.props.disabled) {
@@ -140,8 +132,9 @@ var InputNumberNotRef = /** @class */function (_super) {
140
132
  onBlur = _a.onBlur,
141
133
  onChange = _a.onChange,
142
134
  onContinualChange = _a.onContinualChange;
143
- var parserValueStr = _this.getParserOriginalValue(originalValueStr);
144
- var parserValue = getNumberFromString(parserValueStr);
135
+ var _b = _this.getParserOriginalValue(originalValueStr),
136
+ parserValueStr = _b.parserValueStr,
137
+ parserValue = _b.parserValue;
145
138
  _this.setState({
146
139
  originalValueStr: parserValueStr
147
140
  });
@@ -171,11 +164,12 @@ var InputNumberNotRef = /** @class */function (_super) {
171
164
  if (_this.props.disabled) {
172
165
  return;
173
166
  }
174
- var parserValueStr = _this.getParserOriginalValue(originalValueStr);
175
- var parserValue = getNumberFromString(parserValueStr);
176
- var _a = _this.props,
177
- onChange = _a.onChange,
178
- onContinualChange = _a.onContinualChange;
167
+ var _a = _this.getParserOriginalValue(originalValueStr),
168
+ parserValueStr = _a.parserValueStr,
169
+ parserValue = _a.parserValue;
170
+ var _b = _this.props,
171
+ onChange = _b.onChange,
172
+ onContinualChange = _b.onContinualChange;
179
173
  if (onContinualChange) {
180
174
  onContinualChange(originalValueStr, parserValue, name);
181
175
  }
@@ -219,10 +213,16 @@ var InputNumberNotRef = /** @class */function (_super) {
219
213
  onKeyDown(ev, _this.state.parserValue, name);
220
214
  }
221
215
  };
222
- var defaultValueStr = toFixed(props.defaultValue, props.precision);
216
+ var _a = getParserOriginalValue(__assign(__assign({}, props), {
217
+ originalValue: props.defaultValue,
218
+ prevParserValue: undefined,
219
+ skipError: true
220
+ })),
221
+ parserValueStr = _a.parserValueStr,
222
+ parserValue = _a.parserValue;
223
223
  _this.state = {
224
- originalValueStr: defaultValueStr,
225
- parserValue: getNumberFromString(defaultValueStr)
224
+ originalValueStr: parserValueStr,
225
+ parserValue: parserValue
226
226
  };
227
227
  return _this;
228
228
  }
@@ -233,9 +233,15 @@ var InputNumberNotRef = /** @class */function (_super) {
233
233
  if (nextProps.value !== prevStates.parserValue && (
234
234
  // 兼容外部传入空string/null的情况, 只有当一个值非空时,才会重新重置State信息
235
235
  !isBlank(nextProps.value) || !isBlank(prevStates.parserValue))) {
236
- var fixedValueStr = toFixed(nextProps.value, nextProps.precision);
237
- nextState.parserValue = getNumberFromString(fixedValueStr);
238
- nextState.originalValueStr = fixedValueStr;
236
+ var _a = getParserOriginalValue(__assign(__assign({}, nextProps), {
237
+ originalValue: nextProps.value,
238
+ prevParserValue: prevStates.parserValue,
239
+ skipError: true
240
+ })),
241
+ parserValueStr = _a.parserValueStr,
242
+ parserValue = _a.parserValue;
243
+ nextState.parserValue = parserValue;
244
+ nextState.originalValueStr = parserValueStr;
239
245
  }
240
246
  }
241
247
  if (isEmptyObject(nextState)) {
@@ -245,7 +251,7 @@ var InputNumberNotRef = /** @class */function (_super) {
245
251
  };
246
252
  InputNumberNotRef.prototype.componentWillUnmount = function () {
247
253
  if (this.keyboardHandler) {
248
- this.keyboardHandler.remove();
254
+ this.keyboardHandler();
249
255
  this.keyboardHandler = null;
250
256
  }
251
257
  };
@@ -260,7 +266,9 @@ var InputNumberNotRef = /** @class */function (_super) {
260
266
  disabled = _b.disabled,
261
267
  style = _b.style,
262
268
  prefix = _b.prefix,
263
- controls = _b.controls;
269
+ controls = _b.controls,
270
+ checkValueOnMounted = _b.checkValueOnMounted,
271
+ maxLength = _b.maxLength;
264
272
  var originalValueStr = this.state.originalValueStr;
265
273
  return /*#__PURE__*/React.createElement(Input, {
266
274
  ref: composeRef(this.inputRef, upperRef),
@@ -279,14 +287,18 @@ var InputNumberNotRef = /** @class */function (_super) {
279
287
  cls: cls,
280
288
  onUp: this.onUp,
281
289
  onDown: this.onDown
282
- }) : null
290
+ }) : null,
291
+ checkValueOnMounted: checkValueOnMounted,
292
+ maxLength: maxLength
283
293
  });
284
294
  };
285
295
  InputNumberNotRef.defaultProps = {
286
296
  defaultValue: '',
287
297
  controls: true,
288
298
  step: 1,
289
- keyboard: true
299
+ keyboard: true,
300
+ trimStartZero: true,
301
+ isRounding: true
290
302
  };
291
303
  return InputNumberNotRef;
292
304
  }(React.Component);
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { AddListenerEventHandler } from '@autobest-ui/utils';
2
+ import { AddListenerEventRemoveHandler } from '@autobest-ui/utils';
3
3
  declare type PrevPopupSize = {
4
4
  width: number;
5
5
  height: number;
@@ -92,8 +92,8 @@ declare class Modal extends React.Component<ModalProps, ModalStates> {
92
92
  maskClosable: boolean;
93
93
  hiddenScroll: boolean;
94
94
  };
95
- clickOutsideHandler: AddListenerEventHandler | null;
96
- touchOutsideHandler: AddListenerEventHandler | null;
95
+ clickOutsideHandler: AddListenerEventRemoveHandler;
96
+ touchOutsideHandler: AddListenerEventRemoveHandler;
97
97
  popupTimer: any;
98
98
  affixTimer: any;
99
99
  popupRef: React.RefObject<HTMLDivElement>;
@@ -258,11 +258,11 @@ var Modal = /** @class */function (_super) {
258
258
  Modal.prototype.clearOutsideHandler = function () {
259
259
  this.clearPopupTimer();
260
260
  if (this.clickOutsideHandler) {
261
- this.clickOutsideHandler.remove();
261
+ this.clickOutsideHandler();
262
262
  this.clickOutsideHandler = null;
263
263
  }
264
264
  if (this.touchOutsideHandler) {
265
- this.touchOutsideHandler.remove();
265
+ this.touchOutsideHandler();
266
266
  this.touchOutsideHandler = null;
267
267
  }
268
268
  };
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { AddListenerEventHandler } from '@autobest-ui/utils';
2
+ import { AddListenerEventRemoveHandler } from '@autobest-ui/utils';
3
3
  import { Position } from './utils';
4
4
  export interface MoveProps {
5
5
  /**
@@ -82,11 +82,11 @@ declare class Move extends React.Component<MoveProps> {
82
82
  isTouchScale: boolean;
83
83
  isForceUpdatePlacement: boolean;
84
84
  moveRef: React.RefObject<HTMLElement>;
85
- resizeHandler: AddListenerEventHandler | null;
86
- startHandler: AddListenerEventHandler | null;
87
- mousewheelHandler: AddListenerEventHandler | null;
88
- moveHandler: AddListenerEventHandler | null;
89
- endHandler: AddListenerEventHandler | null;
85
+ resizeHandler: AddListenerEventRemoveHandler;
86
+ startHandler: AddListenerEventRemoveHandler;
87
+ mousewheelHandler: AddListenerEventRemoveHandler;
88
+ moveHandler: AddListenerEventRemoveHandler;
89
+ endHandler: AddListenerEventRemoveHandler;
90
90
  updateTimer: any;
91
91
  componentDidMount(): void;
92
92
  componentDidUpdate(prevProps?: MoveProps): void;