1 | 'use strict';
|
2 |
|
3 | exports.__esModule = true;
|
4 |
|
5 | var _extends2 = require('babel-runtime/helpers/extends');
|
6 |
|
7 | var _extends3 = _interopRequireDefault(_extends2);
|
8 |
|
9 | var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
|
10 |
|
11 | var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
|
12 |
|
13 | var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');
|
14 |
|
15 | var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
|
16 |
|
17 | var _inherits2 = require('babel-runtime/helpers/inherits');
|
18 |
|
19 | var _inherits3 = _interopRequireDefault(_inherits2);
|
20 |
|
21 | var _class, _temp;
|
22 |
|
23 | var _react = require('react');
|
24 |
|
25 | var _react2 = _interopRequireDefault(_react);
|
26 |
|
27 | var _propTypes = require('prop-types');
|
28 |
|
29 | var _propTypes2 = _interopRequireDefault(_propTypes);
|
30 |
|
31 | var _classnames = require('classnames');
|
32 |
|
33 | var _classnames2 = _interopRequireDefault(_classnames);
|
34 |
|
35 | var _bignumber = require('bignumber.js');
|
36 |
|
37 | var _bignumber2 = _interopRequireDefault(_bignumber);
|
38 |
|
39 | var _reactLifecyclesCompat = require('react-lifecycles-compat');
|
40 |
|
41 | var _icon = require('../icon');
|
42 |
|
43 | var _icon2 = _interopRequireDefault(_icon);
|
44 |
|
45 | var _button = require('../button');
|
46 |
|
47 | var _button2 = _interopRequireDefault(_button);
|
48 |
|
49 | var _input = require('../input');
|
50 |
|
51 | var _input2 = _interopRequireDefault(_input);
|
52 |
|
53 | var _util = require('../util');
|
54 |
|
55 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
56 |
|
57 | var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || Math.pow(2, 53) - 1;
|
58 | var MIN_SAFE_INTEGER = Number.MIN_SAFE_INTEGER || -Math.pow(2, 53) + 1;
|
59 |
|
60 | var isNil = _util.obj.isNil;
|
61 |
|
62 |
|
63 | var NumberPicker = (_temp = _class = function (_React$Component) {
|
64 | (0, _inherits3.default)(NumberPicker, _React$Component);
|
65 |
|
66 | function NumberPicker(props) {
|
67 | (0, _classCallCheck3.default)(this, NumberPicker);
|
68 |
|
69 | var _this = (0, _possibleConstructorReturn3.default)(this, _React$Component.call(this, props));
|
70 |
|
71 | var defaultValue = props.defaultValue,
|
72 | stringMode = props.stringMode;
|
73 |
|
74 |
|
75 | var value = void 0;
|
76 | if ('value' in props) {
|
77 | value = props.value;
|
78 | } else {
|
79 | value = defaultValue;
|
80 | }
|
81 | value = value === undefined || value === null ? '' : stringMode ? '' + value : value;
|
82 | _this.state = {
|
83 | value: value,
|
84 | hasFocused: false,
|
85 | onlyDisplay: false,
|
86 | displayValue: value,
|
87 | max: stringMode ? Infinity : MAX_SAFE_INTEGER,
|
88 | min: stringMode ? -Infinity : MIN_SAFE_INTEGER
|
89 | };
|
90 | return _this;
|
91 | }
|
92 |
|
93 | NumberPicker.getDerivedStateFromProps = function getDerivedStateFromProps(nextProps, prevState) {
|
94 |
|
95 | if (prevState.onlyDisplay) {
|
96 | return {
|
97 | value: prevState.value,
|
98 | displayValue: prevState.displayValue,
|
99 | onlyDisplay: false
|
100 | };
|
101 | }
|
102 |
|
103 | var state = {};
|
104 | var value = nextProps.value,
|
105 | stringMode = nextProps.stringMode;
|
106 |
|
107 |
|
108 | if ('value' in nextProps && '' + nextProps.value !== '' + prevState.value) {
|
109 | var newValue = value === undefined || value === null ? '' : stringMode ? '' + value : value;
|
110 | state.value = newValue;
|
111 |
|
112 | if (prevState.displayValue === '' || Number(prevState.displayValue) !== nextProps.value) {
|
113 | state.displayValue = newValue;
|
114 | }
|
115 | }
|
116 |
|
117 |
|
118 | var min = nextProps.min,
|
119 | max = nextProps.max;
|
120 |
|
121 | if ('min' in nextProps && min !== prevState.min) {
|
122 | state.min = !isNil(min) ? min : stringMode ? Infinity : MIN_SAFE_INTEGER;
|
123 | }
|
124 |
|
125 | if ('max' in nextProps && max !== prevState.max) {
|
126 | state.max = !isNil(max) ? max : stringMode ? Infinity : MAX_SAFE_INTEGER;
|
127 | }
|
128 |
|
129 | if (Object.keys(state).length) {
|
130 | return state;
|
131 | }
|
132 |
|
133 | return null;
|
134 | };
|
135 |
|
136 | NumberPicker.prototype.isGreaterThan = function isGreaterThan(v1, v2) {
|
137 | var stringMode = this.props.stringMode;
|
138 |
|
139 | if (stringMode) return (0, _bignumber2.default)(v1).isGreaterThan((0, _bignumber2.default)(v2));
|
140 | return Number(v1) > Number(v2);
|
141 | };
|
142 |
|
143 | NumberPicker.prototype.correctBoundary = function correctBoundary(value) {
|
144 | var _state = this.state,
|
145 | max = _state.max,
|
146 | min = _state.min;
|
147 |
|
148 | return this.isGreaterThan(min, value) ? min : this.isGreaterThan(value, max) ? max : value;
|
149 | };
|
150 |
|
151 | NumberPicker.prototype.setFocus = function setFocus(status) {
|
152 | var format = this.props.format;
|
153 |
|
154 |
|
155 | if (typeof format === 'function') {
|
156 | this.setState({
|
157 | hasFocused: status
|
158 | });
|
159 | }
|
160 | };
|
161 |
|
162 | NumberPicker.prototype.onFocus = function onFocus(e) {
|
163 | var onFocus = this.props.onFocus;
|
164 |
|
165 | this.setFocus(true);
|
166 |
|
167 | for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
168 | args[_key - 1] = arguments[_key];
|
169 | }
|
170 |
|
171 | onFocus && onFocus.apply(undefined, [e].concat(args));
|
172 | };
|
173 |
|
174 | NumberPicker.prototype.onBlur = function onBlur(e) {
|
175 | var _props = this.props,
|
176 | editable = _props.editable,
|
177 | stringMode = _props.stringMode;
|
178 |
|
179 | var displayValue = '' + this.state.displayValue;
|
180 |
|
181 |
|
182 | if (editable === true && !isNaN(displayValue) && !this.shouldFireOnChange(displayValue) && !this.withinMinMax(displayValue)) {
|
183 | var valueCorrected = this.correctValue(displayValue);
|
184 | valueCorrected = stringMode ? (0, _bignumber2.default)(valueCorrected).toFixed(this.getPrecision()) : valueCorrected;
|
185 | if (this.state.value !== valueCorrected) {
|
186 | this.setValue({ value: valueCorrected, e: e });
|
187 | }
|
188 | this.setDisplayValue({ displayValue: valueCorrected });
|
189 | } else {
|
190 | this.setDisplayValue({ displayValue: this.state.value });
|
191 | }
|
192 |
|
193 | this.setFocus(false);
|
194 | var onBlur = this.props.onBlur;
|
195 |
|
196 | for (var _len2 = arguments.length, args = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
197 | args[_key2 - 1] = arguments[_key2];
|
198 | }
|
199 |
|
200 | onBlur && onBlur.apply(undefined, [e].concat(args));
|
201 | };
|
202 |
|
203 | NumberPicker.prototype.withinMinMax = function withinMinMax(value) {
|
204 | var _state2 = this.state,
|
205 | max = _state2.max,
|
206 | min = _state2.min;
|
207 |
|
208 | if (isNaN(value) || this.isGreaterThan(value, max) || this.isGreaterThan(min, value)) return false;
|
209 | return true;
|
210 | };
|
211 |
|
212 | NumberPicker.prototype.setDisplayValue = function setDisplayValue(_ref) {
|
213 | var displayValue = _ref.displayValue,
|
214 | _ref$onlyDisplay = _ref.onlyDisplay,
|
215 | onlyDisplay = _ref$onlyDisplay === undefined ? false : _ref$onlyDisplay;
|
216 |
|
217 | this.setState({ displayValue: displayValue, onlyDisplay: onlyDisplay });
|
218 | };
|
219 |
|
220 | NumberPicker.prototype.getDisplayValue = function getDisplayValue() {
|
221 | var _state3 = this.state,
|
222 | displayValue = _state3.displayValue,
|
223 | hasFocused = _state3.hasFocused;
|
224 | var format = this.props.format;
|
225 |
|
226 |
|
227 | return typeof format === 'function' && !hasFocused ? format(displayValue) :
|
228 | typeof displayValue === 'number' && 1 / displayValue === -Infinity ? '-0' : displayValue;
|
229 | };
|
230 |
|
231 | NumberPicker.prototype.shouldFireOnChange = function shouldFireOnChange(value) {
|
232 |
|
233 | if (isNaN(value) || !this.withinMinMax(value)) {
|
234 | return false;
|
235 | }
|
236 | return true;
|
237 | };
|
238 |
|
239 | NumberPicker.prototype.onChange = function onChange(value, e) {
|
240 |
|
241 | value = value.replace('。', '.').trim();
|
242 | var onlyDisplay = false;
|
243 | if (this.props.editable === true && this.shouldFireOnChange(value)) {
|
244 | var valueCorrected = this.correctValue(value);
|
245 | if (this.state.value !== valueCorrected) {
|
246 | this.setValue({ value: valueCorrected, e: e });
|
247 | }
|
248 | } else {
|
249 | onlyDisplay = true;
|
250 | }
|
251 |
|
252 |
|
253 |
|
254 |
|
255 | this.setDisplayValue({ displayValue: value, onlyDisplay: onlyDisplay });
|
256 | };
|
257 |
|
258 | NumberPicker.prototype.correctValue = function correctValue(value) {
|
259 | var val = value;
|
260 |
|
261 |
|
262 | if (val !== '') {
|
263 |
|
264 | var precisionSet = this.getPrecision();
|
265 | var precisionCurrent = value.length - value.indexOf('.') - 1;
|
266 | var dotIndex = value.indexOf('.');
|
267 |
|
268 | var cutPosition = precisionSet !== 0 ? dotIndex + 1 + precisionSet : dotIndex + precisionSet;
|
269 | if (dotIndex > -1 && precisionCurrent > precisionSet) val = val.substr(0, cutPosition);
|
270 |
|
271 |
|
272 | val = this.correctBoundary(val);
|
273 | val = this.props.stringMode ? (0, _bignumber2.default)(val).toFixed() : Number(val);
|
274 | }
|
275 |
|
276 | if (isNaN(val)) val = this.state.value;
|
277 |
|
278 | if ('' + val !== '' + value) {
|
279 |
|
280 | if (!/\.[0-9]*0+$/g.test(value)) {
|
281 | this.props.onCorrect({
|
282 | currentValue: val,
|
283 | oldValue: value
|
284 | });
|
285 | }
|
286 | }
|
287 |
|
288 | return val;
|
289 | };
|
290 |
|
291 | NumberPicker.prototype.setValue = function setValue(_ref2) {
|
292 | var value = _ref2.value,
|
293 | e = _ref2.e,
|
294 | triggerType = _ref2.triggerType;
|
295 |
|
296 | if (!('value' in this.props) || value === this.props.value) {
|
297 | this.setState({
|
298 | value: value
|
299 | });
|
300 | }
|
301 |
|
302 | this.props.onChange(isNaN(value) || value === '' ? undefined : value, (0, _extends3.default)({}, e, {
|
303 | triggerType: triggerType
|
304 | }));
|
305 | };
|
306 |
|
307 | NumberPicker.prototype.getPrecision = function getPrecision() {
|
308 | var stepString = this.props.step.toString();
|
309 | if (stepString.indexOf('e-') >= 0) {
|
310 | return parseInt(stepString.slice(stepString.indexOf('e-')), 10);
|
311 | }
|
312 | var precision = 0;
|
313 | if (stepString.indexOf('.') >= 0) {
|
314 | precision = stepString.length - stepString.indexOf('.') - 1;
|
315 | }
|
316 |
|
317 | return Math.max(precision, this.props.precision);
|
318 | };
|
319 |
|
320 | NumberPicker.prototype.getPrecisionFactor = function getPrecisionFactor() {
|
321 | var precision = this.getPrecision();
|
322 | return Math.pow(10, precision);
|
323 | };
|
324 |
|
325 | NumberPicker.prototype.onKeyDown = function onKeyDown(e) {
|
326 | var _props2;
|
327 |
|
328 | if (e.keyCode === 38) {
|
329 | this.up(false, e);
|
330 | } else if (e.keyCode === 40) {
|
331 | this.down(false, e);
|
332 | }
|
333 |
|
334 | for (var _len3 = arguments.length, args = Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
|
335 | args[_key3 - 1] = arguments[_key3];
|
336 | }
|
337 |
|
338 | (_props2 = this.props).onKeyDown.apply(_props2, [e].concat(args));
|
339 | };
|
340 |
|
341 | NumberPicker.prototype.up = function up(disabled, e) {
|
342 | this.step('up', disabled, e);
|
343 | };
|
344 |
|
345 | NumberPicker.prototype.down = function down(disabled, e) {
|
346 | this.step('down', disabled, e);
|
347 | };
|
348 |
|
349 | NumberPicker.prototype.step = function step(type, disabled, e) {
|
350 | if (e) {
|
351 | e.preventDefault();
|
352 | }
|
353 |
|
354 | var onDisabled = this.props.onDisabled;
|
355 |
|
356 | if (disabled) {
|
357 | return onDisabled(e);
|
358 | }
|
359 |
|
360 | var value = this.state.value;
|
361 |
|
362 | if (isNaN(value)) {
|
363 | return;
|
364 | }
|
365 |
|
366 | if (value === '' && !this.props.stringMode) {
|
367 | value = 0;
|
368 | }
|
369 |
|
370 | var val = this[type + 'Step'](value);
|
371 | val = this.correctBoundary(val);
|
372 |
|
373 | if (!('value' in this.props)) {
|
374 | this.setDisplayValue({ displayValue: val });
|
375 | }
|
376 |
|
377 | this.setValue({ value: val, e: e, triggerType: type });
|
378 | };
|
379 |
|
380 | NumberPicker.prototype.upStep = function upStep(val) {
|
381 | var _props3 = this.props,
|
382 | step = _props3.step,
|
383 | stringMode = _props3.stringMode;
|
384 |
|
385 | var precisionFactor = this.getPrecisionFactor();
|
386 | if (typeof val === 'number' && !stringMode) {
|
387 | var result = (precisionFactor * val + precisionFactor * step) / precisionFactor;
|
388 | return this.hackChrome(result);
|
389 | }
|
390 | return (0, _bignumber2.default)(val || '0').plus(step).toFixed(this.getPrecision());
|
391 | };
|
392 |
|
393 | NumberPicker.prototype.downStep = function downStep(val) {
|
394 | var _props4 = this.props,
|
395 | step = _props4.step,
|
396 | stringMode = _props4.stringMode;
|
397 |
|
398 | var precisionFactor = this.getPrecisionFactor();
|
399 | if (typeof val === 'number' && !stringMode) {
|
400 | var result = (precisionFactor * val - precisionFactor * step) / precisionFactor;
|
401 | return this.hackChrome(result);
|
402 | }
|
403 | return (0, _bignumber2.default)(val || '0').minus(step).toFixed(this.getPrecision());
|
404 | };
|
405 |
|
406 | |
407 |
|
408 |
|
409 |
|
410 |
|
411 |
|
412 |
|
413 |
|
414 | NumberPicker.prototype.hackChrome = function hackChrome(value) {
|
415 | var precision = this.getPrecision();
|
416 | if (precision > 0) {
|
417 | return Number(Number(value).toFixed(precision));
|
418 | }
|
419 | return value;
|
420 | };
|
421 |
|
422 | NumberPicker.prototype.focus = function focus() {
|
423 | this.inputRef.getInstance().focus();
|
424 | };
|
425 |
|
426 | NumberPicker.prototype.saveInputRef = function saveInputRef(ref) {
|
427 | this.inputRef = ref;
|
428 | };
|
429 |
|
430 | NumberPicker.prototype.getInputNode = function getInputNode() {
|
431 | return this.inputRef;
|
432 | };
|
433 |
|
434 | NumberPicker.prototype.handleMouseDown = function handleMouseDown(e) {
|
435 | e.preventDefault();
|
436 | };
|
437 |
|
438 | NumberPicker.prototype.render = function render() {
|
439 | var _classNames, _classNames2;
|
440 |
|
441 | var _props5 = this.props,
|
442 | device = _props5.device,
|
443 | prefix = _props5.prefix,
|
444 | rtl = _props5.rtl,
|
445 | disabled = _props5.disabled,
|
446 | style = _props5.style,
|
447 | className = _props5.className,
|
448 | size = _props5.size,
|
449 | autoFocus = _props5.autoFocus,
|
450 | editable = _props5.editable,
|
451 | state = _props5.state,
|
452 | label = _props5.label,
|
453 | _props5$upBtnProps = _props5.upBtnProps,
|
454 | upBtnProps = _props5$upBtnProps === undefined ? {} : _props5$upBtnProps,
|
455 | _props5$downBtnProps = _props5.downBtnProps,
|
456 | downBtnProps = _props5$downBtnProps === undefined ? {} : _props5$downBtnProps,
|
457 | innerAfter = _props5.innerAfter,
|
458 | isPreview = _props5.isPreview,
|
459 | renderPreview = _props5.renderPreview,
|
460 | hasTrigger = _props5.hasTrigger,
|
461 | alwaysShowTrigger = _props5.alwaysShowTrigger;
|
462 | var _state4 = this.state,
|
463 | max = _state4.max,
|
464 | min = _state4.min;
|
465 |
|
466 | var type = device === 'phone' || this.props.type === 'inline' ? 'inline' : 'normal';
|
467 |
|
468 | var prefixCls = prefix + 'number-picker';
|
469 |
|
470 | var cls = (0, _classnames2.default)((_classNames = {}, _classNames[prefixCls] = true, _classNames[prefixCls + '-' + type] = type, _classNames['' + prefix + size] = true, _classNames[prefixCls + '-show-trigger'] = alwaysShowTrigger, _classNames[prefixCls + '-no-trigger'] = !hasTrigger, _classNames[prefix + 'disabled'] = disabled, _classNames[className] = className, _classNames));
|
471 |
|
472 | var upDisabled = false;
|
473 | var downDisabled = false;
|
474 | var value = this.state.value;
|
475 | if (!isNaN(value)) {
|
476 | if (!this.isGreaterThan(max, value)) {
|
477 | upDisabled = true;
|
478 | }
|
479 | if (this.isGreaterThan(min, value) || min === value) {
|
480 | downDisabled = true;
|
481 | }
|
482 | }
|
483 |
|
484 | var extra = null,
|
485 | innerAfterClassName = null,
|
486 | addonBefore = null,
|
487 | addonAfter = null;
|
488 | if (type === 'normal') {
|
489 | extra = _react2.default.createElement(
|
490 | 'span',
|
491 | { className: prefixCls + '-handler' },
|
492 | _react2.default.createElement(
|
493 | _button2.default,
|
494 | (0, _extends3.default)({}, upBtnProps, {
|
495 | onMouseDown: this.handleMouseDown,
|
496 | disabled: disabled,
|
497 | className: (upBtnProps.className || '') + ' ' + (upDisabled ? 'disabled' : ''),
|
498 | onClick: this.up.bind(this, upDisabled),
|
499 | tabIndex: -1
|
500 | }),
|
501 | _react2.default.createElement(_icon2.default, { type: 'arrow-up', className: prefixCls + '-up-icon' })
|
502 | ),
|
503 | _react2.default.createElement(
|
504 | _button2.default,
|
505 | (0, _extends3.default)({}, downBtnProps, {
|
506 | onMouseDown: this.handleMouseDown,
|
507 | disabled: disabled,
|
508 | className: (downBtnProps.className || '') + ' ' + (downDisabled ? 'disabled' : ''),
|
509 | onClick: this.down.bind(this, downDisabled),
|
510 | tabIndex: -1
|
511 | }),
|
512 | _react2.default.createElement(_icon2.default, { type: 'arrow-down', className: prefixCls + '-down-icon' })
|
513 | )
|
514 | );
|
515 | } else {
|
516 | addonBefore = _react2.default.createElement(
|
517 | _button2.default,
|
518 | (0, _extends3.default)({}, downBtnProps, {
|
519 | size: size,
|
520 | disabled: disabled,
|
521 | className: (downBtnProps.className || '') + ' ' + (downDisabled ? 'disabled' : ''),
|
522 | onClick: this.down.bind(this, downDisabled),
|
523 | tabIndex: -1
|
524 | }),
|
525 | _react2.default.createElement(_icon2.default, { type: 'minus', className: prefixCls + '-minus-icon' })
|
526 | );
|
527 | addonAfter = _react2.default.createElement(
|
528 | _button2.default,
|
529 | (0, _extends3.default)({}, upBtnProps, {
|
530 | size: size,
|
531 | disabled: disabled,
|
532 | className: (upBtnProps.className || '') + ' ' + (upDisabled ? 'disabled' : ''),
|
533 | onClick: this.up.bind(this, upDisabled),
|
534 | tabIndex: -1
|
535 | }),
|
536 | _react2.default.createElement(_icon2.default, { type: 'add', className: prefixCls + '-add-icon' })
|
537 | );
|
538 | }
|
539 |
|
540 | var others = _util.obj.pickOthers(NumberPicker.propTypes, this.props);
|
541 | var dataAttrs = _util.obj.pickAttrsWith(this.props, 'data-');
|
542 |
|
543 | var previewCls = (0, _classnames2.default)((_classNames2 = {}, _classNames2[prefix + 'form-preview'] = true, _classNames2[className] = !!className, _classNames2));
|
544 |
|
545 | if (isPreview) {
|
546 | if (typeof renderPreview === 'function') {
|
547 | return _react2.default.createElement(
|
548 | 'div',
|
549 | (0, _extends3.default)({}, others, { style: style, className: previewCls }),
|
550 | renderPreview(this.getDisplayValue(), this.props)
|
551 | );
|
552 | }
|
553 | return _react2.default.createElement(
|
554 | 'p',
|
555 | (0, _extends3.default)({}, others, { style: { style: style }, className: previewCls }),
|
556 | this.getDisplayValue(),
|
557 | '\xA0',
|
558 | innerAfter
|
559 | );
|
560 | }
|
561 |
|
562 | return _react2.default.createElement(
|
563 | 'span',
|
564 | (0, _extends3.default)({ className: cls, style: style, dir: rtl ? 'rtl' : undefined }, dataAttrs),
|
565 | _react2.default.createElement(_input2.default, (0, _extends3.default)({}, others, {
|
566 | hasClear: false,
|
567 | 'aria-valuemax': max,
|
568 | 'aria-valuemin': min,
|
569 | state: state === 'error' ? 'error' : null,
|
570 | onBlur: this.onBlur.bind(this),
|
571 | onFocus: this.onFocus.bind(this),
|
572 | onKeyDown: this.onKeyDown.bind(this),
|
573 | autoFocus: autoFocus,
|
574 | readOnly: !editable,
|
575 | value: this.getDisplayValue(),
|
576 | disabled: disabled,
|
577 | size: size,
|
578 | onChange: this.onChange.bind(this),
|
579 | ref: this.saveInputRef.bind(this),
|
580 | label: label,
|
581 | innerAfter: innerAfter,
|
582 | extra: hasTrigger ? extra : null,
|
583 | addonBefore: addonBefore,
|
584 | addonAfter: addonAfter,
|
585 | composition: true
|
586 | }))
|
587 | );
|
588 | };
|
589 |
|
590 | return NumberPicker;
|
591 | }(_react2.default.Component), _class.propTypes = {
|
592 | |
593 |
|
594 |
|
595 | prefix: _propTypes2.default.string,
|
596 | |
597 |
|
598 |
|
599 |
|
600 | type: _propTypes2.default.oneOf(['normal', 'inline']),
|
601 | |
602 |
|
603 |
|
604 | size: _propTypes2.default.oneOf(['large', 'medium', 'small']),
|
605 | |
606 |
|
607 |
|
608 | value: _propTypes2.default.oneOfType([_propTypes2.default.number, _propTypes2.default.string]),
|
609 | |
610 |
|
611 |
|
612 | defaultValue: _propTypes2.default.oneOfType([_propTypes2.default.number, _propTypes2.default.string]),
|
613 | |
614 |
|
615 |
|
616 | disabled: _propTypes2.default.bool,
|
617 | |
618 |
|
619 |
|
620 | step: _propTypes2.default.oneOfType([_propTypes2.default.number, _propTypes2.default.string]),
|
621 | |
622 |
|
623 |
|
624 | precision: _propTypes2.default.number,
|
625 | |
626 |
|
627 |
|
628 | editable: _propTypes2.default.bool,
|
629 | |
630 |
|
631 |
|
632 | autoFocus: _propTypes2.default.bool,
|
633 | |
634 |
|
635 |
|
636 |
|
637 |
|
638 | onChange: _propTypes2.default.func,
|
639 | |
640 |
|
641 |
|
642 |
|
643 | onKeyDown: _propTypes2.default.func,
|
644 | |
645 |
|
646 |
|
647 |
|
648 | onFocus: _propTypes2.default.func,
|
649 | |
650 |
|
651 |
|
652 |
|
653 | onBlur: _propTypes2.default.func,
|
654 | |
655 |
|
656 |
|
657 |
|
658 | onCorrect: _propTypes2.default.func,
|
659 | onDisabled: _propTypes2.default.func,
|
660 | |
661 |
|
662 |
|
663 | max: _propTypes2.default.oneOfType([_propTypes2.default.number, _propTypes2.default.string]),
|
664 | |
665 |
|
666 |
|
667 | min: _propTypes2.default.oneOfType([_propTypes2.default.number, _propTypes2.default.string]),
|
668 | |
669 |
|
670 |
|
671 | className: _propTypes2.default.string,
|
672 | |
673 |
|
674 |
|
675 | style: _propTypes2.default.object,
|
676 | state: _propTypes2.default.oneOf(['error']),
|
677 | |
678 |
|
679 |
|
680 |
|
681 |
|
682 | format: _propTypes2.default.func,
|
683 | |
684 |
|
685 |
|
686 | upBtnProps: _propTypes2.default.object,
|
687 | |
688 |
|
689 |
|
690 | downBtnProps: _propTypes2.default.object,
|
691 | |
692 |
|
693 |
|
694 | label: _propTypes2.default.node,
|
695 | |
696 |
|
697 |
|
698 | innerAfter: _propTypes2.default.node,
|
699 | rtl: _propTypes2.default.bool,
|
700 | |
701 |
|
702 |
|
703 | isPreview: _propTypes2.default.bool,
|
704 | |
705 |
|
706 |
|
707 |
|
708 |
|
709 |
|
710 | renderPreview: _propTypes2.default.func,
|
711 | |
712 |
|
713 |
|
714 | device: _propTypes2.default.oneOf(['phone', 'tablet', 'desktop']),
|
715 | |
716 |
|
717 |
|
718 | hasTrigger: _propTypes2.default.bool,
|
719 | |
720 |
|
721 |
|
722 | alwaysShowTrigger: _propTypes2.default.bool,
|
723 | |
724 |
|
725 |
|
726 |
|
727 | stringMode: _propTypes2.default.bool
|
728 | }, _class.defaultProps = {
|
729 | prefix: 'next-',
|
730 |
|
731 |
|
732 | type: 'normal',
|
733 | size: 'medium',
|
734 | step: 1,
|
735 | style: {},
|
736 | precision: 0,
|
737 | editable: true,
|
738 | onChange: _util.func.noop,
|
739 | onKeyDown: _util.func.noop,
|
740 | onBlur: _util.func.noop,
|
741 | onCorrect: _util.func.noop,
|
742 | onDisabled: _util.func.noop,
|
743 | hasTrigger: true,
|
744 | alwaysShowTrigger: false,
|
745 | stringMode: false
|
746 | }, _temp);
|
747 | NumberPicker.displayName = 'NumberPicker';
|
748 | exports.default = (0, _reactLifecyclesCompat.polyfill)(NumberPicker);
|
749 | module.exports = exports['default']; |
\ | No newline at end of file |