shineout 1.9.5 → 1.10.0-rc.3

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 (59) hide show
  1. package/css/Button/styles/button.css +20 -8
  2. package/css/Checkbox/styles/checkinput.css +38 -1
  3. package/css/Form/styles/form.css +21 -12
  4. package/css/Input/Input.js +125 -45
  5. package/css/Input/Number.js +45 -17
  6. package/css/Input/index.d.ts +62 -10
  7. package/css/Rate/Rate.js +12 -2
  8. package/css/Rate/styles/rate.css +24 -3
  9. package/css/Slider/Container.js +8 -1
  10. package/css/Slider/Slider.js +3 -1
  11. package/css/Slider/styles/slider.css +103 -0
  12. package/css/Textarea/Textarea.js +3 -1
  13. package/css/hoc/delay.js +7 -1
  14. package/css/hoc/inputBorder.js +1 -1
  15. package/css/index.d.ts +1 -1
  16. package/css/index.js +1 -1
  17. package/css/utils/cleanProps.js +1 -1
  18. package/dist/shineout.js +296 -156
  19. package/dist/shineout.js.map +1 -1
  20. package/dist/shineout.min.js +1 -1
  21. package/dist/theme.antd.css +1 -1
  22. package/dist/theme.antd2.css +1 -1
  23. package/dist/theme.default.css +1 -1
  24. package/dist/theme.shineout.css +1 -1
  25. package/es/Button/styles/button.less +29 -10
  26. package/es/Checkbox/styles/checkinput.less +38 -3
  27. package/es/Form/styles/form.less +18 -15
  28. package/es/Input/Input.js +125 -45
  29. package/es/Input/Number.js +45 -17
  30. package/es/Input/index.d.ts +62 -10
  31. package/es/Rate/Rate.js +11 -2
  32. package/es/Rate/styles/rate.less +21 -1
  33. package/es/Slider/Container.js +7 -1
  34. package/es/Slider/Slider.js +2 -1
  35. package/es/Slider/styles/slider.less +84 -1
  36. package/es/Textarea/Textarea.js +2 -1
  37. package/es/hoc/delay.js +7 -1
  38. package/es/hoc/inputBorder.js +1 -1
  39. package/es/index.d.ts +1 -1
  40. package/es/index.js +1 -1
  41. package/es/utils/cleanProps.js +1 -1
  42. package/lib/Button/styles/button.less +29 -10
  43. package/lib/Checkbox/styles/checkinput.less +38 -3
  44. package/lib/Form/styles/form.less +18 -15
  45. package/lib/Input/Input.js +125 -45
  46. package/lib/Input/Number.js +45 -17
  47. package/lib/Input/index.d.ts +62 -10
  48. package/lib/Rate/Rate.js +12 -2
  49. package/lib/Rate/styles/rate.less +21 -1
  50. package/lib/Slider/Container.js +8 -1
  51. package/lib/Slider/Slider.js +3 -1
  52. package/lib/Slider/styles/slider.less +84 -1
  53. package/lib/Textarea/Textarea.js +3 -1
  54. package/lib/hoc/delay.js +7 -1
  55. package/lib/hoc/inputBorder.js +1 -1
  56. package/lib/index.d.ts +1 -1
  57. package/lib/index.js +1 -1
  58. package/lib/utils/cleanProps.js +1 -1
  59. package/package.json +1 -1
@@ -22,8 +22,13 @@
22
22
  }
23
23
  .so-button-spin {
24
24
  display: inline-block;
25
+ }
26
+ .so-button-spin:not(.so-button-rtl *) {
25
27
  margin-right: var(--button-spin-margin, 8px);
26
28
  }
29
+ .so-button-rtl .so-button-spin {
30
+ margin-left: var(--button-spin-margin, 8px);
31
+ }
27
32
  .so-button:hover,
28
33
  .so-button:focus {
29
34
  z-index: 10;
@@ -38,9 +43,12 @@
38
43
  background-image: none;
39
44
  outline: 0;
40
45
  }
41
- .so-button + .so-button {
46
+ .so-button + .so-button:not(.so-button + .so-button-rtl) {
42
47
  margin-left: var(--button-margin-left, 12px);
43
48
  }
49
+ .so-button + .so-button-rtl {
50
+ margin-right: var(--button-margin-left, 12px);
51
+ }
44
52
  .so-button[disabled],
45
53
  fieldset[disabled] .so-button {
46
54
  position: relative;
@@ -872,10 +880,15 @@ fieldset[disabled] .so-button-link:focus {
872
880
  }
873
881
  .so-button-group .so-button {
874
882
  position: relative;
875
- margin-left: 0px;
876
883
  border-right-width: 0;
877
884
  border-left-width: 0;
878
885
  }
886
+ .so-button-group .so-button:not(.so-button-group .so-button-rtl) {
887
+ margin-left: 0px;
888
+ }
889
+ .so-button-group .so-button-rtl {
890
+ margin-right: 0px;
891
+ }
879
892
  .so-button-group .so-button:before {
880
893
  position: absolute;
881
894
  top: 50%;
@@ -893,23 +906,22 @@ fieldset[disabled] .so-button-link:focus {
893
906
  left: auto;
894
907
  right: 0;
895
908
  }
896
- .so-button-group .so-button:first-child {
909
+ .so-button-group .so-button:first-child:not(.so-button-rtl) {
897
910
  margin-left: 0;
898
911
  border-left-width: 1px;
899
912
  }
900
- .so-button-group-rtl.so-button-group .so-button:first-child {
913
+ .so-button-group .so-button:first-child.so-button-rtl {
901
914
  border-right-width: 1px;
902
- border-left-width: 0;
915
+ margin-right: 0;
903
916
  }
904
917
  .so-button-group .so-button:first-child:before {
905
918
  display: none;
906
919
  }
907
- .so-button-group .so-button:last-child {
920
+ .so-button-group .so-button:last-child:not(.so-button-rtl) {
908
921
  border-right-width: 1px;
909
922
  }
910
- .so-button-group-rtl.so-button-group .so-button:last-child {
923
+ .so-button-group .so-button:last-child.so-button-rtl {
911
924
  border-left-width: 1px;
912
- border-right-width: 0;
913
925
  }
914
926
  .so-button-group .so-button:not(:first-child):not(:last-child) {
915
927
  border-radius: 0;
@@ -334,6 +334,10 @@ fieldset[disabled] .so-checkinput-button .so-checkinput.so-checkinput-checked:ac
334
334
  -webkit-transition: all 0.36s cubic-bezier(0.78, 0.14, 0.15, 0.86);
335
335
  transition: all 0.36s cubic-bezier(0.78, 0.14, 0.15, 0.86);
336
336
  }
337
+ .so-checkinput-rtl.so-checkinput-switch {
338
+ padding-left: 4px;
339
+ padding-right: var(--switch-indicator-size, 24px);
340
+ }
337
341
  .so-checkinput-switch input {
338
342
  width: 0;
339
343
  height: 0;
@@ -355,6 +359,10 @@ fieldset[disabled] .so-checkinput-button .so-checkinput.so-checkinput-checked:ac
355
359
  -webkit-box-shadow: 0 1px 4px var(--gray-500, #adb5bd);
356
360
  box-shadow: 0 1px 4px var(--gray-500, #adb5bd);
357
361
  }
362
+ .so-checkinput-rtl .so-checkinput-switch-indicator {
363
+ left: auto;
364
+ right: var(--switch-indicator-padding-horizontal, 0px);
365
+ }
358
366
  .so-checkinput-switch-children {
359
367
  font-size: 12px;
360
368
  color: #fff;
@@ -365,24 +373,45 @@ fieldset[disabled] .so-checkinput-button .so-checkinput.so-checkinput-checked:ac
365
373
  padding-left: 4px;
366
374
  background: var(--switch-checked-bg, var(--primary-color-fade-50, rgba(51, 153, 255, 0.5)));
367
375
  }
376
+ .so-checkinput-rtl.so-checkinput-checked.so-checkinput-switch {
377
+ padding-left: var(--switch-indicator-size, 24px);
378
+ padding-right: 4px;
379
+ }
368
380
  .so-checkinput-checked.so-checkinput-switch .so-checkinput-switch-indicator {
369
381
  -webkit-box-shadow: var(--switch-checked-box-shadow, 0 1px 4px var(--primary-color-fade-50, rgba(51, 153, 255, 0.5)));
370
382
  box-shadow: var(--switch-checked-box-shadow, 0 1px 4px var(--primary-color-fade-50, rgba(51, 153, 255, 0.5)));
383
+ background: var(--switch-indicator-checked-bg, var(--primary-color, #3399ff));
384
+ }
385
+ .so-checkinput-checked.so-checkinput-switch .so-checkinput-switch-indicator:not(.so-checkinput-rtl *) {
371
386
  left: 100%;
372
387
  margin-left: var(--switch-indicator-padding-horizontal-negative, 0px);
373
388
  -webkit-transform: translateX(-100%);
374
389
  -ms-transform: translateX(-100%);
375
390
  transform: translateX(-100%);
376
- background: var(--switch-indicator-checked-bg, var(--primary-color, #3399ff));
391
+ }
392
+ .so-checkinput-rtl.so-checkinput-checked.so-checkinput-switch .so-checkinput-switch-indicator {
393
+ right: 100%;
394
+ margin-right: var(--switch-indicator-padding-horizontal-negative, 0px);
395
+ -webkit-transform: translateX(100%);
396
+ -ms-transform: translateX(100%);
397
+ transform: translateX(100%);
377
398
  }
378
399
  .so-checkinput-checked.so-checkinput-small.so-checkinput-switch {
379
400
  padding-left: 0;
380
401
  padding-right: var(--switch-small-indicator-size, 16px);
381
402
  }
403
+ .so-checkinput-rtl.so-checkinput-checked.so-checkinput-small.so-checkinput-switch {
404
+ padding-left: var(--switch-small-indicator-size, 16px);
405
+ padding-right: 0;
406
+ }
382
407
  .so-checkinput-checked.so-checkinput-large.so-checkinput-switch {
383
408
  padding-left: 0;
384
409
  padding-right: var(--switch-large-indicator-size, 32px);
385
410
  }
411
+ .so-checkinput-rtl.so-checkinput-checked.so-checkinput-large.so-checkinput-switch {
412
+ padding-left: var(--switch-large-indicator-size, 32px);
413
+ padding-right: 0;
414
+ }
386
415
  .so-checkinput-small.so-checkinput-switch {
387
416
  min-width: 28px;
388
417
  height: var(--switch-small-bg-height, 10px);
@@ -391,6 +420,10 @@ fieldset[disabled] .so-checkinput-button .so-checkinput.so-checkinput-checked:ac
391
420
  padding-left: var(--switch-small-indicator-size, 16px);
392
421
  padding-right: 0;
393
422
  }
423
+ .so-checkinput-rtl.so-checkinput-small.so-checkinput-switch {
424
+ padding-right: var(--switch-small-indicator-size, 16px);
425
+ padding-left: 0;
426
+ }
394
427
  .so-checkinput-small.so-checkinput-switch .so-checkinput-switch-indicator {
395
428
  width: var(--switch-small-indicator-size, 16px);
396
429
  height: var(--switch-small-indicator-size, 16px);
@@ -406,6 +439,10 @@ fieldset[disabled] .so-checkinput-button .so-checkinput.so-checkinput-checked:ac
406
439
  padding-left: var(--switch-large-indicator-size, 32px);
407
440
  padding-right: 0;
408
441
  }
442
+ .so-checkinput-rtl.so-checkinput-large.so-checkinput-switch {
443
+ padding-right: var(--switch-large-indicator-size, 32px);
444
+ padding-left: 0;
445
+ }
409
446
  .so-checkinput-large.so-checkinput-switch .so-checkinput-switch-indicator {
410
447
  width: var(--switch-large-indicator-size, 32px);
411
448
  height: var(--switch-large-indicator-size, 32px);
@@ -253,6 +253,15 @@
253
253
  -ms-transform: rotate(315deg);
254
254
  transform: rotate(315deg);
255
255
  }
256
+ .so-input-rtl .so-input-clear-wrapper .so-input-clear {
257
+ right: auto;
258
+ left: 8px;
259
+ }
260
+ .so-input-rtl .so-input-clear-wrapper .so-input-clear:after,
261
+ .so-input-rtl .so-input-clear-wrapper .so-input-clear:before {
262
+ left: auto;
263
+ right: 3px;
264
+ }
256
265
  .so-input-inline {
257
266
  display: inline-block;
258
267
  display: -webkit-inline-box;
@@ -286,14 +295,22 @@
286
295
  margin: auto 0;
287
296
  background: transparent;
288
297
  }
289
- .so-input-group > span:first-child,
290
- .so-input-group > i:first-child {
298
+ .so-input-group > span:first-child:not(.so-input-rtl *),
299
+ .so-input-group > i:first-child:not(.so-input-rtl *) {
291
300
  padding-left: 12px;
292
301
  }
293
- .so-input-group > span:last-child,
294
- .so-input-group > i:last-child {
302
+ .so-input-rtl.so-input-group > span:first-child,
303
+ .so-input-rtl.so-input-group > i:first-child {
304
+ padding-right: 12px;
305
+ }
306
+ .so-input-group > span:last-child:not(.so-input-rtl *),
307
+ .so-input-group > i:last-child:not(.so-input-rtl *) {
295
308
  padding-right: 8px;
296
309
  }
310
+ .so-input-rtl.so-input-group > span:last-child,
311
+ .so-input-rtl.so-input-group > i:last-child {
312
+ padding-left: 8px;
313
+ }
297
314
  .so-input-group > b {
298
315
  display: -webkit-box;
299
316
  display: -ms-flexbox;
@@ -743,14 +760,6 @@ textarea.so-input-textarea-resize {
743
760
  left: auto;
744
761
  right: 3px;
745
762
  }
746
- .so-input.so-input-rtl.so-input-group > span:first-child,
747
- .so-input.so-input-rtl.so-input-group > i:first-child {
748
- padding-right: 12px;
749
- }
750
- .so-input.so-input-rtl.so-input-group > span:last-child,
751
- .so-input.so-input-rtl.so-input-group > i:last-child {
752
- padding-left: 8px;
753
- }
754
763
  .so-input.so-input-rtl .so-input-number-up,
755
764
  .so-input.so-input-rtl .so-input-number-down {
756
765
  left: 0;
@@ -33,6 +33,15 @@ var _styles2 = require("./styles");
33
33
 
34
34
  var _InputTitle = _interopRequireDefault(require("../InputTitle"));
35
35
 
36
+ function regLength(size) {
37
+ return /\d+/.test(size) && size > 0 ? "{0," + size + "}" : '*';
38
+ }
39
+
40
+ function fillNumber(val) {
41
+ return val.replace(/^(-)?(\.\d+)(?!=\.).*/g, '$10$2') // eslint-disable-next-line no-useless-escape
42
+ .replace(/(?<=-|^)0+(?=0\.?|[^0\.])/g, '').replace(/\.$/, '');
43
+ }
44
+
36
45
  var Input =
37
46
  /*#__PURE__*/
38
47
  function (_PureComponent) {
@@ -54,6 +63,7 @@ function (_PureComponent) {
54
63
  _this.handleKeyDown = _this.handleKeyDown.bind((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this)));
55
64
  _this.handleKeyUp = _this.handleKeyUp.bind((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this)));
56
65
  _this.handleBlur = _this.handleBlur.bind((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this)));
66
+ _this.handleAutoSelect = _this.handleAutoSelect.bind((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this)));
57
67
  _this.bindRef = _this.bindRef.bind((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this)));
58
68
  return _this;
59
69
  }
@@ -66,16 +76,69 @@ function (_PureComponent) {
66
76
  if (forwardedRef) forwardedRef(el);
67
77
  };
68
78
 
69
- _proto.invalidNumber = function invalidNumber(value) {
79
+ _proto.isValidNumber = function isValidNumber(val) {
80
+ var numType = this.props.numType;
81
+ var noNeg = numType === 'non-negative' || numType === 'positive';
82
+ var regExp = new RegExp("^(" + (noNeg ? '' : '-') + ")?\\d*\\.?\\d*$", 'g');
83
+ return regExp.test(val);
84
+ };
85
+
86
+ _proto.formatValue = function formatValue(val) {
87
+ var value = val;
70
88
  var _this$props = this.props,
89
+ type = _this$props.type,
71
90
  digits = _this$props.digits,
72
- type = _this$props.type;
91
+ integerLimit = _this$props.integerLimit,
92
+ numType = _this$props.numType;
93
+ var noNeg = numType === 'non-negative' || numType === 'positive';
94
+ if (type !== 'number') return value;
95
+ var regExp = new RegExp("^(" + (noNeg ? '' : '-') + ")?(\\d" + regLength(integerLimit) + ")(" + (digits !== 0 ? "\\.\\d" + regLength(digits) : '') + ")?.*$", 'g');
96
+ value = value.replace(regExp, '$1$2$3');
97
+ return value;
98
+ };
99
+
100
+ _proto.fixValue = function fixValue(val) {
101
+ var _this$props2 = this.props,
102
+ type = _this$props2.type,
103
+ digits = _this$props2.digits,
104
+ autoFix = _this$props2.autoFix,
105
+ cancelChange = _this$props2.cancelChange,
106
+ numType = _this$props2.numType;
107
+ if (type !== 'number' || val === '') return val;
108
+ if (/^[.-]+$/.test(val)) return '';
109
+ var fixVal = fillNumber(val);
110
+ if (numType === 'positive' && fixVal <= 0) return '';
111
+
112
+ if (digits !== undefined && autoFix) {
113
+ if (digits > 0) {
114
+ fixVal = parseFloat(fixVal).toFixed(digits);
115
+ } else {
116
+ fixVal = parseInt(fixVal, 10).toString();
117
+ }
118
+
119
+ if (cancelChange) cancelChange();
120
+ }
121
+
122
+ return fixVal;
123
+ };
124
+
125
+ _proto.invalidNumber = function invalidNumber(value) {
126
+ var _this$props3 = this.props,
127
+ digits = _this$props3.digits,
128
+ type = _this$props3.type,
129
+ integerLimit = _this$props3.integerLimit;
73
130
  if (type !== 'number') return false;
74
- var reg = '^-?\\d*';
131
+ var reg = '^-?';
132
+
133
+ if (!integerLimit) {
134
+ reg += "\\d*";
135
+ } else if (integerLimit > 0) {
136
+ reg += "\\d{0," + integerLimit + "}";
137
+ }
75
138
 
76
139
  if (digits === undefined) {
77
140
  reg += '\\.?\\d*';
78
- } else if (digits > 0) {
141
+ } else if (digits >= 0) {
79
142
  reg += "\\.?\\d{0," + digits + "}";
80
143
  }
81
144
 
@@ -85,10 +148,9 @@ function (_PureComponent) {
85
148
  };
86
149
 
87
150
  _proto.handleChange = function handleChange(e, clearClick) {
88
- var _this$props2 = this.props,
89
- type = _this$props2.type,
90
- clearable = _this$props2.clearable,
91
- digits = _this$props2.digits;
151
+ var _this$props4 = this.props,
152
+ type = _this$props4.type,
153
+ clearable = _this$props4.clearable;
92
154
 
93
155
  if (clearClick) {
94
156
  this.ref.focus();
@@ -102,20 +164,16 @@ function (_PureComponent) {
102
164
  return;
103
165
  }
104
166
 
105
- if (type === 'number' && typeof value !== 'number') value = String(value).replace(/。/g, '.');
167
+ if (type === 'number') {
168
+ if (typeof value !== 'number') {
169
+ value = String(value).replace(/。/g, '.');
170
+ }
106
171
 
107
- if (this.invalidNumber(value)) {
108
- // For numbers with a decimal point, use toFixed to correct the number of decimal points.
109
- if (digits >= 0 && /^-?\d*\.?\d*$/.test(value)) {
110
- if (digits === 0) {
111
- value = value === '.' ? '' : Number(value).toFixed(digits);
112
- } else {
113
- value = Number(value).toFixed(digits + 1).slice(0, -1);
114
- }
115
- } else {
116
- // digits <= 0 || not of number
172
+ if (!this.isValidNumber(value)) {
117
173
  return;
118
174
  }
175
+
176
+ value = this.formatValue(value);
119
177
  }
120
178
 
121
179
  this.props.onChange(value);
@@ -128,9 +186,9 @@ function (_PureComponent) {
128
186
  };
129
187
 
130
188
  _proto.handleKeyUp = function handleKeyUp(e) {
131
- var _this$props3 = this.props,
132
- onKeyUp = _this$props3.onKeyUp,
133
- onEnterPress = _this$props3.onEnterPress;
189
+ var _this$props5 = this.props,
190
+ onKeyUp = _this$props5.onKeyUp,
191
+ onEnterPress = _this$props5.onEnterPress;
134
192
 
135
193
  if (this.enterPress && e.keyCode === 13 && onEnterPress) {
136
194
  onEnterPress(e.target.value, e);
@@ -142,18 +200,34 @@ function (_PureComponent) {
142
200
 
143
201
  _proto.handleBlur = function handleBlur(e) {
144
202
  var value = e.target.value;
145
- var _this$props4 = this.props,
146
- forceChange = _this$props4.forceChange,
147
- onBlur = _this$props4.onBlur,
148
- clearToUndefined = _this$props4.clearToUndefined;
203
+ var _this$props6 = this.props,
204
+ forceChange = _this$props6.forceChange,
205
+ onBlur = _this$props6.onBlur,
206
+ clearToUndefined = _this$props6.clearToUndefined,
207
+ cancelChange = _this$props6.cancelChange;
208
+ if (cancelChange) cancelChange();
209
+ var newVal = this.fixValue(value);
149
210
  if (onBlur) onBlur(e);
150
- if (this.invalidNumber(value)) return;
211
+ if (this.invalidNumber(newVal)) return;
151
212
 
152
- if (clearToUndefined && value === '' && this.props.value === undefined) {
213
+ if (clearToUndefined && newVal === '' && this.props.value === undefined) {
153
214
  return;
154
215
  }
155
216
 
156
- if (forceChange) forceChange(value);
217
+ if (forceChange) forceChange(newVal);
218
+ };
219
+
220
+ _proto.handleAutoSelect = function handleAutoSelect(event) {
221
+ var onFocus = this.props.onFocus;
222
+ var autoSelect = this.props.autoSelect;
223
+
224
+ if (autoSelect) {
225
+ event.currentTarget.select();
226
+ }
227
+
228
+ if (typeof onFocus === 'function') {
229
+ onFocus(event);
230
+ }
157
231
  };
158
232
 
159
233
  _proto.renderInfo = function renderInfo() {
@@ -176,21 +250,21 @@ function (_PureComponent) {
176
250
  };
177
251
 
178
252
  _proto.render = function render() {
179
- var _this$props5 = this.props,
180
- type = _this$props5.type,
181
- defaultValue = _this$props5.defaultValue,
182
- digits = _this$props5.digits,
183
- className = _this$props5.className,
184
- clearable = _this$props5.clearable,
185
- htmlName = _this$props5.htmlName,
186
- forceChange = _this$props5.forceChange,
187
- onEnterPress = _this$props5.onEnterPress,
188
- forwardedRef = _this$props5.forwardedRef,
189
- innerTitle = _this$props5.innerTitle,
190
- inputFocus = _this$props5.inputFocus,
191
- clearToUndefined = _this$props5.clearToUndefined,
192
- placeholder = _this$props5.placeholder,
193
- other = (0, _objectWithoutPropertiesLoose2.default)(_this$props5, ["type", "defaultValue", "digits", "className", "clearable", "htmlName", "forceChange", "onEnterPress", "forwardedRef", "innerTitle", "inputFocus", "clearToUndefined", "placeholder"]);
253
+ var _this$props7 = this.props,
254
+ type = _this$props7.type,
255
+ defaultValue = _this$props7.defaultValue,
256
+ digits = _this$props7.digits,
257
+ className = _this$props7.className,
258
+ clearable = _this$props7.clearable,
259
+ htmlName = _this$props7.htmlName,
260
+ forceChange = _this$props7.forceChange,
261
+ onEnterPress = _this$props7.onEnterPress,
262
+ forwardedRef = _this$props7.forwardedRef,
263
+ innerTitle = _this$props7.innerTitle,
264
+ inputFocus = _this$props7.inputFocus,
265
+ clearToUndefined = _this$props7.clearToUndefined,
266
+ placeholder = _this$props7.placeholder,
267
+ other = (0, _objectWithoutPropertiesLoose2.default)(_this$props7, ["type", "defaultValue", "digits", "className", "clearable", "htmlName", "forceChange", "onEnterPress", "forwardedRef", "innerTitle", "inputFocus", "clearToUndefined", "placeholder"]);
194
268
  var value = this.props.value == null || this.props.value === undefined ? '' : this.props.value;
195
269
  var needClearUndefined = clearToUndefined && this.props.value !== undefined;
196
270
  var showClear = !other.disabled && clearable && (value !== '' || needClearUndefined);
@@ -212,7 +286,8 @@ function (_PureComponent) {
212
286
  onChange: this.handleChange,
213
287
  onKeyDown: this.handleKeyDown,
214
288
  onKeyUp: this.handleKeyUp,
215
- onBlur: this.handleBlur
289
+ onBlur: this.handleBlur,
290
+ onFocus: this.handleAutoSelect
216
291
  }))), showClear && _react.default.createElement(_clear.default, {
217
292
  onClick: this.handleChange,
218
293
  key: "close",
@@ -227,10 +302,15 @@ Input.propTypes = {
227
302
  className: _propTypes.default.string,
228
303
  defaultValue: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]),
229
304
  digits: _propTypes.default.number,
305
+ integerLimit: _propTypes.default.number,
306
+ numType: _propTypes.default.string,
307
+ autoSelect: _propTypes.default.bool,
308
+ autoFix: _propTypes.default.bool,
230
309
  forceChange: _propTypes.default.func,
231
310
  htmlName: _propTypes.default.string,
232
311
  onBlur: _propTypes.default.func,
233
312
  onChange: _propTypes.default.func.isRequired,
313
+ cancelChange: _propTypes.default.func,
234
314
  onEnterPress: _propTypes.default.func,
235
315
  type: _propTypes.default.string,
236
316
  value: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]),
@@ -69,17 +69,25 @@ function (_PureComponent) {
69
69
  return;
70
70
  }
71
71
 
72
- if (typeof this.props.digits === 'number') {
73
- value = parseFloat(value.toFixed(this.props.digits));
72
+ var _this$props = this.props,
73
+ digits = _this$props.digits,
74
+ step = _this$props.step,
75
+ numType = _this$props.numType,
76
+ allowNull = _this$props.allowNull;
77
+
78
+ if (numType === 'positive' && value <= 0) {
79
+ value = allowNull ? null : undefined;
80
+ } else if (typeof digits === 'number') {
81
+ value = parseFloat(value.toFixed(digits));
74
82
  } else {
75
- var stepStr = this.props.step.toString();
83
+ var stepStr = step.toString();
76
84
  var dot = stepStr.lastIndexOf('.');
77
85
  if (dot >= 0) value = parseFloat(value.toFixed(stepStr.length - dot));
78
86
  }
79
87
 
80
- var _this$props = this.props,
81
- min = _this$props.min,
82
- max = _this$props.max;
88
+ var _this$props2 = this.props,
89
+ min = _this$props2.min,
90
+ max = _this$props2.max;
83
91
  if (max !== undefined && value > max) value = max;
84
92
  if (min !== undefined && value < min) value = min;
85
93
 
@@ -115,7 +123,24 @@ function (_PureComponent) {
115
123
  var value = parseFloat(("" + (val || '')).replace(/,/g, '')); // eslint-disable-next-line
116
124
 
117
125
  if (isNaN(value)) value = 0;
118
- this.handleChange((0, _numbers.sub)(value, mod), true);
126
+ var _this$props3 = this.props,
127
+ numType = _this$props3.numType,
128
+ integerLimit = _this$props3.integerLimit;
129
+ var calculateVal = (0, _numbers.sub)(value, mod);
130
+
131
+ if (numType === 'positive' && calculateVal <= 0) {
132
+ return;
133
+ }
134
+
135
+ if (numType === 'non-negative' && calculateVal < 0) {
136
+ return;
137
+ }
138
+
139
+ if (integerLimit && String(parseInt(calculateVal, 10)).length > integerLimit) {
140
+ return;
141
+ }
142
+
143
+ this.handleChange(calculateVal, true);
119
144
  };
120
145
 
121
146
  _proto.longPress = function longPress(mod) {
@@ -191,11 +216,11 @@ function (_PureComponent) {
191
216
  };
192
217
 
193
218
  _proto.renderRTL = function renderRTL() {
194
- var _this$props2 = this.props,
195
- onChange = _this$props2.onChange,
196
- allowNull = _this$props2.allowNull,
197
- hideArrow = _this$props2.hideArrow,
198
- other = (0, _objectWithoutPropertiesLoose2.default)(_this$props2, ["onChange", "allowNull", "hideArrow"]);
219
+ var _this$props4 = this.props,
220
+ onChange = _this$props4.onChange,
221
+ allowNull = _this$props4.allowNull,
222
+ hideArrow = _this$props4.hideArrow,
223
+ other = (0, _objectWithoutPropertiesLoose2.default)(_this$props4, ["onChange", "allowNull", "hideArrow"]);
199
224
  return [].concat(this.renderArrowGroup(), [_react.default.createElement(_Input.default, (0, _extends2.default)({
200
225
  key: "input"
201
226
  }, other, {
@@ -211,11 +236,11 @@ function (_PureComponent) {
211
236
  };
212
237
 
213
238
  _proto.render = function render() {
214
- var _this$props3 = this.props,
215
- onChange = _this$props3.onChange,
216
- allowNull = _this$props3.allowNull,
217
- hideArrow = _this$props3.hideArrow,
218
- other = (0, _objectWithoutPropertiesLoose2.default)(_this$props3, ["onChange", "allowNull", "hideArrow"]);
239
+ var _this$props5 = this.props,
240
+ onChange = _this$props5.onChange,
241
+ allowNull = _this$props5.allowNull,
242
+ hideArrow = _this$props5.hideArrow,
243
+ other = (0, _objectWithoutPropertiesLoose2.default)(_this$props5, ["onChange", "allowNull", "hideArrow"]);
219
244
  var rtl = (0, _config.isRTL)();
220
245
 
221
246
  if (rtl) {
@@ -249,6 +274,9 @@ Number.propTypes = {
249
274
  onChange: _propTypes.default.func.isRequired,
250
275
  step: _propTypes.default.number,
251
276
  digits: _propTypes.default.number,
277
+ integerLimit: _propTypes.default.number,
278
+ numType: _propTypes.default.string,
279
+ autoSelect: _propTypes.default.bool,
252
280
  allowNull: _propTypes.default.bool,
253
281
  hideArrow: _propTypes.default.bool,
254
282
  clearToUndefined: _propTypes.default.bool,
@@ -3,6 +3,7 @@ import { PopoverProps } from '../Popover'
3
3
  import { StandardProps, RegularAttributes, FormItemStandardProps, CommonProps } from '../@types/common'
4
4
 
5
5
  type ReactNode = React.ReactNode;
6
+ export type numType = "positive" | "non-negative";
6
7
 
7
8
  export interface InputProps<Value> extends
8
9
  StandardProps,
@@ -188,7 +189,67 @@ FormItemStandardProps<Value> {
188
189
  * default: -
189
190
  *
190
191
  */
191
- clearToUndefined?: boolean
192
+ clearToUndefined?: boolean,
193
+
194
+ /**
195
+ * the digits of number 仅在type = number 下生效
196
+ *
197
+ * Decimal place limit (valid when type is number)
198
+ *
199
+ * default: -
200
+ */
201
+ digits?: number;
202
+
203
+ /**
204
+ * 整数位数限制, 仅在type = number 下生效
205
+ *
206
+ * Integer bit limit (valid when type is number)
207
+ *
208
+ * default: -
209
+ *
210
+ */
211
+ integerLimit?: number,
212
+
213
+ /**
214
+ * 设置数字类型 支持 'positive' 和 'non-negative', 仅在type = number 下生效
215
+ *
216
+ * Number type supports 'positive' and 'non-negative', only works when type = number
217
+ *
218
+ * default: -
219
+ *
220
+ */
221
+ numType?: numType,
222
+
223
+ /**
224
+ * 非负数,仅在type = number 下生效
225
+ *
226
+ * nonnegative number (valid when type is number)
227
+ *
228
+ * default: -
229
+ *
230
+ */
231
+ nonnegative?: boolean,
232
+
233
+ /**
234
+ * 鼠标点击后自动全选数据
235
+ *
236
+ * Automatically select all data after mouse click
237
+ *
238
+ * default: false
239
+ *
240
+ */
241
+ autoSelect?: boolean,
242
+
243
+ /**
244
+ * 失焦后自动按照 digits 精度限制补足 (type 为 number 时生效)
245
+ *
246
+ * Automatically fill up according to the precision limit of digits after out of focus
247
+ *
248
+ * default: false
249
+ *
250
+ */
251
+ autoFix?: boolean,
252
+
192
253
  }
193
254
 
194
255
  export interface InputNumberProps <Value> extends InputProps<Value> {
@@ -220,15 +281,6 @@ export interface InputNumberProps <Value> extends InputProps<Value> {
220
281
  */
221
282
  step?: number;
222
283
 
223
- /**
224
- * the digits of number
225
- *
226
- * 数值的精度
227
- *
228
- * default: -
229
- */
230
- digits?: number;
231
-
232
284
  /**
233
285
  * allow value is null
234
286
  *