diff options
author | yiminghe <yiminghe@gmail.com> | 2015-12-21 17:14:48 +0800 |
---|---|---|
committer | yiminghe <yiminghe@gmail.com> | 2015-12-21 17:14:48 +0800 |
commit | 89b84f104138888b074334e76bc1dc7002f2d061 (patch) | |
tree | 052a86cd9c38588dc9bdfe675baf25f27798e90b /examples/common.js | |
parent | 70e9ca03bb946357ea1fc7edba8d9e3b31e0d5ca (diff) | |
download | time-picker-89b84f104138888b074334e76bc1dc7002f2d061.tar.gz time-picker-89b84f104138888b074334e76bc1dc7002f2d061.tar.zst time-picker-89b84f104138888b074334e76bc1dc7002f2d061.zip |
Updates
Diffstat (limited to 'examples/common.js')
-rw-r--r-- | examples/common.js | 268 |
1 files changed, 206 insertions, 62 deletions
diff --git a/examples/common.js b/examples/common.js index 7550a6c..d89a09d 100644 --- a/examples/common.js +++ b/examples/common.js | |||
@@ -30,7 +30,7 @@ | |||
30 | /******/ // "0" means "already loaded" | 30 | /******/ // "0" means "already loaded" |
31 | /******/ // Array means "loading", array contains callbacks | 31 | /******/ // Array means "loading", array contains callbacks |
32 | /******/ var installedChunks = { | 32 | /******/ var installedChunks = { |
33 | /******/ 2:0 | 33 | /******/ 4:0 |
34 | /******/ }; | 34 | /******/ }; |
35 | /******/ | 35 | /******/ |
36 | /******/ // The require function | 36 | /******/ // The require function |
@@ -76,7 +76,7 @@ | |||
76 | /******/ script.charset = 'utf-8'; | 76 | /******/ script.charset = 'utf-8'; |
77 | /******/ script.async = true; | 77 | /******/ script.async = true; |
78 | /******/ | 78 | /******/ |
79 | /******/ script.src = __webpack_require__.p + "" + chunkId + "." + ({"0":"pick-time","1":"value-and-defaultValue"}[chunkId]||chunkId) + ".js"; | 79 | /******/ script.src = __webpack_require__.p + "" + chunkId + "." + ({"0":"disabled","1":"hidden","2":"pick-time","3":"value-and-defaultValue"}[chunkId]||chunkId) + ".js"; |
80 | /******/ head.appendChild(script); | 80 | /******/ head.appendChild(script); |
81 | /******/ } | 81 | /******/ } |
82 | /******/ }; | 82 | /******/ }; |
@@ -22297,7 +22297,7 @@ | |||
22297 | 22297 | ||
22298 | var _modulePanel2 = _interopRequireDefault(_modulePanel); | 22298 | var _modulePanel2 = _interopRequireDefault(_modulePanel); |
22299 | 22299 | ||
22300 | var _utilPlacements = __webpack_require__(225); | 22300 | var _utilPlacements = __webpack_require__(226); |
22301 | 22301 | ||
22302 | var _utilPlacements2 = _interopRequireDefault(_utilPlacements); | 22302 | var _utilPlacements2 = _interopRequireDefault(_utilPlacements); |
22303 | 22303 | ||
@@ -22305,7 +22305,7 @@ | |||
22305 | 22305 | ||
22306 | var _mixinCommonMixin2 = _interopRequireDefault(_mixinCommonMixin); | 22306 | var _mixinCommonMixin2 = _interopRequireDefault(_mixinCommonMixin); |
22307 | 22307 | ||
22308 | var _utilIndex = __webpack_require__(226); | 22308 | var _utilIndex = __webpack_require__(227); |
22309 | 22309 | ||
22310 | var _gregorianCalendarLibLocaleEn_US = __webpack_require__(164); | 22310 | var _gregorianCalendarLibLocaleEn_US = __webpack_require__(164); |
22311 | 22311 | ||
@@ -22340,9 +22340,10 @@ | |||
22340 | style: _react.PropTypes.object, | 22340 | style: _react.PropTypes.object, |
22341 | className: _react.PropTypes.string, | 22341 | className: _react.PropTypes.string, |
22342 | showSecond: _react.PropTypes.bool, | 22342 | showSecond: _react.PropTypes.bool, |
22343 | hourOptions: _react.PropTypes.array, | 22343 | disabledHours: _react.PropTypes.func, |
22344 | minuteOptions: _react.PropTypes.array, | 22344 | disabledMinutes: _react.PropTypes.func, |
22345 | secondOptions: _react.PropTypes.array, | 22345 | disabledSeconds: _react.PropTypes.func, |
22346 | hideDisabledOptions: _react.PropTypes.bool, | ||
22346 | onChange: _react.PropTypes.func, | 22347 | onChange: _react.PropTypes.func, |
22347 | onOpen: _react.PropTypes.func, | 22348 | onOpen: _react.PropTypes.func, |
22348 | onClose: _react.PropTypes.func | 22349 | onClose: _react.PropTypes.func |
@@ -22360,6 +22361,10 @@ | |||
22360 | allowEmpty: true, | 22361 | allowEmpty: true, |
22361 | showHour: true, | 22362 | showHour: true, |
22362 | showSecond: true, | 22363 | showSecond: true, |
22364 | disabledHours: noop, | ||
22365 | disabledMinutes: noop, | ||
22366 | disabledSeconds: noop, | ||
22367 | hideDisabledOptions: false, | ||
22363 | placement: 'bottomLeft', | 22368 | placement: 'bottomLeft', |
22364 | onChange: noop, | 22369 | onChange: noop, |
22365 | onOpen: noop, | 22370 | onOpen: noop, |
@@ -22465,9 +22470,10 @@ | |||
22465 | var defaultValue = _props2.defaultValue; | 22470 | var defaultValue = _props2.defaultValue; |
22466 | var locale = _props2.locale; | 22471 | var locale = _props2.locale; |
22467 | var placeholder = _props2.placeholder; | 22472 | var placeholder = _props2.placeholder; |
22468 | var hourOptions = _props2.hourOptions; | 22473 | var disabledHours = _props2.disabledHours; |
22469 | var minuteOptions = _props2.minuteOptions; | 22474 | var disabledMinutes = _props2.disabledMinutes; |
22470 | var secondOptions = _props2.secondOptions; | 22475 | var disabledSeconds = _props2.disabledSeconds; |
22476 | var hideDisabledOptions = _props2.hideDisabledOptions; | ||
22471 | var allowEmpty = _props2.allowEmpty; | 22477 | var allowEmpty = _props2.allowEmpty; |
22472 | var showHour = _props2.showHour; | 22478 | var showHour = _props2.showHour; |
22473 | var showSecond = _props2.showSecond; | 22479 | var showSecond = _props2.showSecond; |
@@ -22497,9 +22503,10 @@ | |||
22497 | allowEmpty: allowEmpty, | 22503 | allowEmpty: allowEmpty, |
22498 | formatter: this.getFormatter(), | 22504 | formatter: this.getFormatter(), |
22499 | placeholder: placeholder, | 22505 | placeholder: placeholder, |
22500 | hourOptions: hourOptions, | 22506 | disabledHours: disabledHours, |
22501 | minuteOptions: minuteOptions, | 22507 | disabledMinutes: disabledMinutes, |
22502 | secondOptions: secondOptions | 22508 | disabledSeconds: disabledSeconds, |
22509 | hideDisabledOptions: hideDisabledOptions | ||
22503 | }); | 22510 | }); |
22504 | }, | 22511 | }, |
22505 | 22512 | ||
@@ -27332,16 +27339,18 @@ | |||
27332 | 27339 | ||
27333 | var _Header2 = _interopRequireDefault(_Header); | 27340 | var _Header2 = _interopRequireDefault(_Header); |
27334 | 27341 | ||
27335 | var _Combobox = __webpack_require__(223); | 27342 | var _Combobox = __webpack_require__(224); |
27336 | 27343 | ||
27337 | var _Combobox2 = _interopRequireDefault(_Combobox); | 27344 | var _Combobox2 = _interopRequireDefault(_Combobox); |
27338 | 27345 | ||
27339 | function noop() {} | 27346 | function noop() {} |
27340 | 27347 | ||
27341 | function generateOptions(length) { | 27348 | function generateOptions(length, disabledOptions, hideDisabledOptions) { |
27342 | var arr = []; | 27349 | var arr = []; |
27343 | for (var i = 0; i < length; i++) { | 27350 | for (var value = 0; value < length; value++) { |
27344 | arr.push(i); | 27351 | if (!disabledOptions || disabledOptions.indexOf(value) < 0 || !hideDisabledOptions) { |
27352 | arr.push(value); | ||
27353 | } | ||
27345 | } | 27354 | } |
27346 | return arr; | 27355 | return arr; |
27347 | } | 27356 | } |
@@ -27356,9 +27365,10 @@ | |||
27356 | placeholder: _react.PropTypes.string, | 27365 | placeholder: _react.PropTypes.string, |
27357 | gregorianCalendarLocale: _react.PropTypes.object, | 27366 | gregorianCalendarLocale: _react.PropTypes.object, |
27358 | formatter: _react.PropTypes.object, | 27367 | formatter: _react.PropTypes.object, |
27359 | hourOptions: _react.PropTypes.array, | 27368 | disabledHours: _react.PropTypes.func, |
27360 | minuteOptions: _react.PropTypes.array, | 27369 | disabledMinutes: _react.PropTypes.func, |
27361 | secondOptions: _react.PropTypes.array, | 27370 | disabledSeconds: _react.PropTypes.func, |
27371 | hideDisabledOptions: _react.PropTypes.bool, | ||
27362 | onChange: _react.PropTypes.func, | 27372 | onChange: _react.PropTypes.func, |
27363 | onEsc: _react.PropTypes.func, | 27373 | onEsc: _react.PropTypes.func, |
27364 | allowEmpty: _react.PropTypes.bool, | 27374 | allowEmpty: _react.PropTypes.bool, |
@@ -27371,9 +27381,6 @@ | |||
27371 | 27381 | ||
27372 | getDefaultProps: function getDefaultProps() { | 27382 | getDefaultProps: function getDefaultProps() { |
27373 | return { | 27383 | return { |
27374 | hourOptions: generateOptions(24), | ||
27375 | minuteOptions: generateOptions(60), | ||
27376 | secondOptions: generateOptions(60), | ||
27377 | onChange: noop, | 27384 | onChange: noop, |
27378 | onClear: noop | 27385 | onClear: noop |
27379 | }; | 27386 | }; |
@@ -27381,7 +27388,8 @@ | |||
27381 | 27388 | ||
27382 | getInitialState: function getInitialState() { | 27389 | getInitialState: function getInitialState() { |
27383 | return { | 27390 | return { |
27384 | value: this.props.value | 27391 | value: this.props.value, |
27392 | selectionRange: [] | ||
27385 | }; | 27393 | }; |
27386 | }, | 27394 | }, |
27387 | 27395 | ||
@@ -27403,14 +27411,19 @@ | |||
27403 | this.props.onClear(); | 27411 | this.props.onClear(); |
27404 | }, | 27412 | }, |
27405 | 27413 | ||
27414 | onCurrentSelectPanelChange: function onCurrentSelectPanelChange(currentSelectPanel) { | ||
27415 | this.setState({ currentSelectPanel: currentSelectPanel }); | ||
27416 | }, | ||
27417 | |||
27406 | render: function render() { | 27418 | render: function render() { |
27407 | var _props = this.props; | 27419 | var _props = this.props; |
27408 | var locale = _props.locale; | 27420 | var locale = _props.locale; |
27409 | var prefixCls = _props.prefixCls; | 27421 | var prefixCls = _props.prefixCls; |
27410 | var placeholder = _props.placeholder; | 27422 | var placeholder = _props.placeholder; |
27411 | var hourOptions = _props.hourOptions; | 27423 | var disabledHours = _props.disabledHours; |
27412 | var minuteOptions = _props.minuteOptions; | 27424 | var disabledMinutes = _props.disabledMinutes; |
27413 | var secondOptions = _props.secondOptions; | 27425 | var disabledSeconds = _props.disabledSeconds; |
27426 | var hideDisabledOptions = _props.hideDisabledOptions; | ||
27414 | var allowEmpty = _props.allowEmpty; | 27427 | var allowEmpty = _props.allowEmpty; |
27415 | var showHour = _props.showHour; | 27428 | var showHour = _props.showHour; |
27416 | var showSecond = _props.showSecond; | 27429 | var showSecond = _props.showSecond; |
@@ -27418,6 +27431,13 @@ | |||
27418 | var gregorianCalendarLocale = _props.gregorianCalendarLocale; | 27431 | var gregorianCalendarLocale = _props.gregorianCalendarLocale; |
27419 | 27432 | ||
27420 | var value = this.state.value; | 27433 | var value = this.state.value; |
27434 | var disabledHourOptions = disabledHours(); | ||
27435 | var disabledMinuteOptions = disabledMinutes(value ? value.getHourOfDay() : null); | ||
27436 | var disabledSecondOptions = disabledSeconds(value ? value.getHourOfDay() : null, value ? value.getMinutes() : null); | ||
27437 | var hourOptions = generateOptions(24, disabledHourOptions, hideDisabledOptions); | ||
27438 | var minuteOptions = generateOptions(60, disabledMinuteOptions, hideDisabledOptions); | ||
27439 | var secondOptions = generateOptions(60, disabledSecondOptions, hideDisabledOptions); | ||
27440 | |||
27421 | return _react2['default'].createElement( | 27441 | return _react2['default'].createElement( |
27422 | 'div', | 27442 | 'div', |
27423 | { className: prefixCls + '-inner' }, | 27443 | { className: prefixCls + '-inner' }, |
@@ -27426,12 +27446,16 @@ | |||
27426 | gregorianCalendarLocale: gregorianCalendarLocale, | 27446 | gregorianCalendarLocale: gregorianCalendarLocale, |
27427 | locale: locale, | 27447 | locale: locale, |
27428 | value: value, | 27448 | value: value, |
27449 | currentSelectPanel: this.state.currentSelectPanel, | ||
27429 | onEsc: this.props.onEsc, | 27450 | onEsc: this.props.onEsc, |
27430 | formatter: formatter, | 27451 | formatter: formatter, |
27431 | placeholder: placeholder, | 27452 | placeholder: placeholder, |
27432 | hourOptions: hourOptions, | 27453 | hourOptions: hourOptions, |
27433 | minuteOptions: minuteOptions, | 27454 | minuteOptions: minuteOptions, |
27434 | secondOptions: secondOptions, | 27455 | secondOptions: secondOptions, |
27456 | disabledHours: disabledHours, | ||
27457 | disabledMinutes: disabledMinutes, | ||
27458 | disabledSeconds: disabledSeconds, | ||
27435 | onChange: this.onChange, | 27459 | onChange: this.onChange, |
27436 | onClear: this.onClear, | 27460 | onClear: this.onClear, |
27437 | allowEmpty: allowEmpty | 27461 | allowEmpty: allowEmpty |
@@ -27446,7 +27470,11 @@ | |||
27446 | showSecond: showSecond, | 27470 | showSecond: showSecond, |
27447 | hourOptions: hourOptions, | 27471 | hourOptions: hourOptions, |
27448 | minuteOptions: minuteOptions, | 27472 | minuteOptions: minuteOptions, |
27449 | secondOptions: secondOptions | 27473 | secondOptions: secondOptions, |
27474 | disabledHours: disabledHours, | ||
27475 | disabledMinutes: disabledMinutes, | ||
27476 | disabledSeconds: disabledSeconds, | ||
27477 | onCurrentSelectPanelChange: this.onCurrentSelectPanelChange | ||
27450 | }) | 27478 | }) |
27451 | ); | 27479 | ); |
27452 | } | 27480 | } |
@@ -27526,6 +27554,10 @@ | |||
27526 | 27554 | ||
27527 | var _react2 = _interopRequireDefault(_react); | 27555 | var _react2 = _interopRequireDefault(_react); |
27528 | 27556 | ||
27557 | var _utilSelection = __webpack_require__(223); | ||
27558 | |||
27559 | var _utilSelection2 = _interopRequireDefault(_utilSelection); | ||
27560 | |||
27529 | var Header = _react2['default'].createClass({ | 27561 | var Header = _react2['default'].createClass({ |
27530 | displayName: 'Header', | 27562 | displayName: 'Header', |
27531 | 27563 | ||
@@ -27540,10 +27572,14 @@ | |||
27540 | hourOptions: _react.PropTypes.array, | 27572 | hourOptions: _react.PropTypes.array, |
27541 | minuteOptions: _react.PropTypes.array, | 27573 | minuteOptions: _react.PropTypes.array, |
27542 | secondOptions: _react.PropTypes.array, | 27574 | secondOptions: _react.PropTypes.array, |
27575 | disabledHours: _react.PropTypes.func, | ||
27576 | disabledMinutes: _react.PropTypes.func, | ||
27577 | disabledSeconds: _react.PropTypes.func, | ||
27543 | onChange: _react.PropTypes.func, | 27578 | onChange: _react.PropTypes.func, |
27544 | onClear: _react.PropTypes.func, | 27579 | onClear: _react.PropTypes.func, |
27545 | onEsc: _react.PropTypes.func, | 27580 | onEsc: _react.PropTypes.func, |
27546 | allowEmpty: _react.PropTypes.bool | 27581 | allowEmpty: _react.PropTypes.bool, |
27582 | currentSelectPanel: _react.PropTypes.string | ||
27547 | }, | 27583 | }, |
27548 | 27584 | ||
27549 | getInitialState: function getInitialState() { | 27585 | getInitialState: function getInitialState() { |
@@ -27555,11 +27591,7 @@ | |||
27555 | }, | 27591 | }, |
27556 | 27592 | ||
27557 | componentDidMount: function componentDidMount() { | 27593 | componentDidMount: function componentDidMount() { |
27558 | var _this = this; | 27594 | this.timer = setTimeout(this.selectRange, 0); |
27559 | |||
27560 | this.timer = setTimeout(function () { | ||
27561 | _this.refs.input.focus(); | ||
27562 | }, 0); | ||
27563 | }, | 27595 | }, |
27564 | 27596 | ||
27565 | componentWillReceiveProps: function componentWillReceiveProps(nextProps) { | 27597 | componentWillReceiveProps: function componentWillReceiveProps(nextProps) { |
@@ -27570,6 +27602,10 @@ | |||
27570 | }); | 27602 | }); |
27571 | }, | 27603 | }, |
27572 | 27604 | ||
27605 | componentDidUpdate: function componentDidUpdate() { | ||
27606 | this.timer = setTimeout(this.selectRange, 0); | ||
27607 | }, | ||
27608 | |||
27573 | componentWillUnmount: function componentWillUnmount() { | 27609 | componentWillUnmount: function componentWillUnmount() { |
27574 | clearTimeout(this.timer); | 27610 | clearTimeout(this.timer); |
27575 | }, | 27611 | }, |
@@ -27586,6 +27622,9 @@ | |||
27586 | var hourOptions = _props.hourOptions; | 27622 | var hourOptions = _props.hourOptions; |
27587 | var minuteOptions = _props.minuteOptions; | 27623 | var minuteOptions = _props.minuteOptions; |
27588 | var secondOptions = _props.secondOptions; | 27624 | var secondOptions = _props.secondOptions; |
27625 | var disabledHours = _props.disabledHours; | ||
27626 | var disabledMinutes = _props.disabledMinutes; | ||
27627 | var disabledSeconds = _props.disabledSeconds; | ||
27589 | var onChange = _props.onChange; | 27628 | var onChange = _props.onChange; |
27590 | var allowEmpty = _props.allowEmpty; | 27629 | var allowEmpty = _props.allowEmpty; |
27591 | 27630 | ||
@@ -27604,6 +27643,7 @@ | |||
27604 | } | 27643 | } |
27605 | 27644 | ||
27606 | if (value) { | 27645 | if (value) { |
27646 | // if time value not allowed, response warning. | ||
27607 | if (hourOptions.indexOf(value.getHourOfDay()) < 0 || minuteOptions.indexOf(value.getMinutes()) < 0 || secondOptions.indexOf(value.getSeconds()) < 0) { | 27647 | if (hourOptions.indexOf(value.getHourOfDay()) < 0 || minuteOptions.indexOf(value.getMinutes()) < 0 || secondOptions.indexOf(value.getSeconds()) < 0) { |
27608 | this.setState({ | 27648 | this.setState({ |
27609 | invalid: true | 27649 | invalid: true |
@@ -27611,6 +27651,17 @@ | |||
27611 | return; | 27651 | return; |
27612 | } | 27652 | } |
27613 | 27653 | ||
27654 | // if time value is disabled, response warning. | ||
27655 | var disabledHourOptions = disabledHours(); | ||
27656 | var disabledMinuteOptions = disabledMinutes(value.getHourOfDay()); | ||
27657 | var disabledSecondOptions = disabledSeconds(value.getHourOfDay(), value.getMinutes()); | ||
27658 | if (disabledHourOptions && disabledHourOptions.indexOf(value.getHourOfDay()) >= 0 || disabledMinuteOptions && disabledMinuteOptions.indexOf(value.getMinutes()) >= 0 || disabledSecondOptions && disabledSecondOptions.indexOf(value.getSeconds()) >= 0) { | ||
27659 | this.setState({ | ||
27660 | invalid: true | ||
27661 | }); | ||
27662 | return; | ||
27663 | } | ||
27664 | |||
27614 | if (originalValue && value) { | 27665 | if (originalValue && value) { |
27615 | if (originalValue.getHourOfDay() !== value.getHourOfDay() || originalValue.getMinutes() !== value.getMinutes() || originalValue.getSeconds() !== value.getSeconds()) { | 27666 | if (originalValue.getHourOfDay() !== value.getHourOfDay() || originalValue.getMinutes() !== value.getMinutes() || originalValue.getSeconds() !== value.getSeconds()) { |
27616 | onChange(value); | 27667 | onChange(value); |
@@ -27677,6 +27728,27 @@ | |||
27677 | placeholder: placeholder, onChange: this.onInputChange }); | 27728 | placeholder: placeholder, onChange: this.onInputChange }); |
27678 | }, | 27729 | }, |
27679 | 27730 | ||
27731 | selectRange: function selectRange() { | ||
27732 | this.refs.input.focus(); | ||
27733 | if (this.props.currentSelectPanel && this.refs.input.value) { | ||
27734 | var selectionRangeStart = 0; | ||
27735 | var selectionRangeEnd = 0; | ||
27736 | if (this.props.currentSelectPanel === 'hour') { | ||
27737 | selectionRangeStart = 0; | ||
27738 | selectionRangeEnd = this.refs.input.value.indexOf(':'); | ||
27739 | } else if (this.props.currentSelectPanel === 'minute') { | ||
27740 | selectionRangeStart = this.refs.input.value.indexOf(':') + 1; | ||
27741 | selectionRangeEnd = this.refs.input.value.lastIndexOf(':'); | ||
27742 | } else if (this.props.currentSelectPanel === 'second') { | ||
27743 | selectionRangeStart = this.refs.input.value.lastIndexOf(':') + 1; | ||
27744 | selectionRangeEnd = this.refs.input.value.length; | ||
27745 | } | ||
27746 | if (selectionRangeEnd - selectionRangeStart === 2) { | ||
27747 | (0, _utilSelection2['default'])(this.refs.input, selectionRangeStart, selectionRangeEnd); | ||
27748 | } | ||
27749 | } | ||
27750 | }, | ||
27751 | |||
27680 | render: function render() { | 27752 | render: function render() { |
27681 | var prefixCls = this.props.prefixCls; | 27753 | var prefixCls = this.props.prefixCls; |
27682 | 27754 | ||
@@ -27694,6 +27766,37 @@ | |||
27694 | 27766 | ||
27695 | /***/ }, | 27767 | /***/ }, |
27696 | /* 223 */ | 27768 | /* 223 */ |
27769 | /***/ function(module, exports) { | ||
27770 | |||
27771 | 'use strict'; | ||
27772 | |||
27773 | Object.defineProperty(exports, '__esModule', { | ||
27774 | value: true | ||
27775 | }); | ||
27776 | exports['default'] = createSelection; | ||
27777 | |||
27778 | function createSelection(field, start, end) { | ||
27779 | if (field.createTextRange) { | ||
27780 | var selRange = field.createTextRange(); | ||
27781 | selRange.collapse(true); | ||
27782 | selRange.moveStart('character', start); | ||
27783 | selRange.moveEnd('character', end); | ||
27784 | selRange.select(); | ||
27785 | field.focus(); | ||
27786 | } else if (field.setSelectionRange) { | ||
27787 | field.focus(); | ||
27788 | field.setSelectionRange(start, end); | ||
27789 | } else if (typeof field.selectionStart !== 'undefined') { | ||
27790 | field.selectionStart = start; | ||
27791 | field.selectionEnd = end; | ||
27792 | field.focus(); | ||
27793 | } | ||
27794 | } | ||
27795 | |||
27796 | module.exports = exports['default']; | ||
27797 | |||
27798 | /***/ }, | ||
27799 | /* 224 */ | ||
27697 | /***/ function(module, exports, __webpack_require__) { | 27800 | /***/ function(module, exports, __webpack_require__) { |
27698 | 27801 | ||
27699 | 'use strict'; | 27802 | 'use strict'; |
@@ -27708,7 +27811,7 @@ | |||
27708 | 27811 | ||
27709 | var _react2 = _interopRequireDefault(_react); | 27812 | var _react2 = _interopRequireDefault(_react); |
27710 | 27813 | ||
27711 | var _Select = __webpack_require__(224); | 27814 | var _Select = __webpack_require__(225); |
27712 | 27815 | ||
27713 | var _Select2 = _interopRequireDefault(_Select); | 27816 | var _Select2 = _interopRequireDefault(_Select); |
27714 | 27817 | ||
@@ -27716,11 +27819,21 @@ | |||
27716 | 27819 | ||
27717 | var _gregorianCalendar2 = _interopRequireDefault(_gregorianCalendar); | 27820 | var _gregorianCalendar2 = _interopRequireDefault(_gregorianCalendar); |
27718 | 27821 | ||
27719 | var formatOption = function formatOption(option) { | 27822 | var formatOption = function formatOption(option, disabledOptions) { |
27823 | var value = '' + option; | ||
27720 | if (option < 10) { | 27824 | if (option < 10) { |
27721 | return '0' + option; | 27825 | value = '0' + option; |
27826 | } | ||
27827 | |||
27828 | var disabled = false; | ||
27829 | if (disabledOptions && disabledOptions.indexOf(option) >= 0) { | ||
27830 | disabled = true; | ||
27722 | } | 27831 | } |
27723 | return '' + option; | 27832 | |
27833 | return { | ||
27834 | value: value, | ||
27835 | disabled: disabled | ||
27836 | }; | ||
27724 | }; | 27837 | }; |
27725 | 27838 | ||
27726 | var Combobox = _react2['default'].createClass({ | 27839 | var Combobox = _react2['default'].createClass({ |
@@ -27736,7 +27849,11 @@ | |||
27736 | showSecond: _react.PropTypes.bool, | 27849 | showSecond: _react.PropTypes.bool, |
27737 | hourOptions: _react.PropTypes.array, | 27850 | hourOptions: _react.PropTypes.array, |
27738 | minuteOptions: _react.PropTypes.array, | 27851 | minuteOptions: _react.PropTypes.array, |
27739 | secondOptions: _react.PropTypes.array | 27852 | secondOptions: _react.PropTypes.array, |
27853 | disabledHours: _react.PropTypes.func, | ||
27854 | disabledMinutes: _react.PropTypes.func, | ||
27855 | disabledSeconds: _react.PropTypes.func, | ||
27856 | onCurrentSelectPanelChange: _react.PropTypes.func | ||
27740 | }, | 27857 | }, |
27741 | 27858 | ||
27742 | onItemChange: function onItemChange(type, itemValue) { | 27859 | onItemChange: function onItemChange(type, itemValue) { |
@@ -27758,23 +27875,31 @@ | |||
27758 | onChange(value); | 27875 | onChange(value); |
27759 | }, | 27876 | }, |
27760 | 27877 | ||
27878 | onEnterSelectPanel: function onEnterSelectPanel(range) { | ||
27879 | this.props.onCurrentSelectPanelChange(range); | ||
27880 | }, | ||
27881 | |||
27761 | getHourSelect: function getHourSelect(hour) { | 27882 | getHourSelect: function getHourSelect(hour) { |
27762 | var _props = this.props; | 27883 | var _props = this.props; |
27763 | var prefixCls = _props.prefixCls; | 27884 | var prefixCls = _props.prefixCls; |
27764 | var hourOptions = _props.hourOptions; | 27885 | var hourOptions = _props.hourOptions; |
27886 | var disabledHours = _props.disabledHours; | ||
27765 | var showHour = _props.showHour; | 27887 | var showHour = _props.showHour; |
27766 | 27888 | ||
27767 | if (!showHour) { | 27889 | if (!showHour) { |
27768 | return null; | 27890 | return null; |
27769 | } | 27891 | } |
27892 | var disabledOptions = disabledHours(); | ||
27893 | |||
27770 | return _react2['default'].createElement(_Select2['default'], { | 27894 | return _react2['default'].createElement(_Select2['default'], { |
27771 | prefixCls: prefixCls, | 27895 | prefixCls: prefixCls, |
27772 | options: hourOptions.map(function (option) { | 27896 | options: hourOptions.map(function (option) { |
27773 | return formatOption(option); | 27897 | return formatOption(option, disabledOptions); |
27774 | }), | 27898 | }), |
27775 | selectedIndex: hourOptions.indexOf(hour), | 27899 | selectedIndex: hourOptions.indexOf(hour), |
27776 | type: 'hour', | 27900 | type: 'hour', |
27777 | onSelect: this.onItemChange | 27901 | onSelect: this.onItemChange, |
27902 | onMouseEnter: this.onEnterSelectPanel.bind(this, 'hour') | ||
27778 | }); | 27903 | }); |
27779 | }, | 27904 | }, |
27780 | 27905 | ||
@@ -27782,35 +27907,45 @@ | |||
27782 | var _props2 = this.props; | 27907 | var _props2 = this.props; |
27783 | var prefixCls = _props2.prefixCls; | 27908 | var prefixCls = _props2.prefixCls; |
27784 | var minuteOptions = _props2.minuteOptions; | 27909 | var minuteOptions = _props2.minuteOptions; |
27910 | var disabledMinutes = _props2.disabledMinutes; | ||
27911 | |||
27912 | var value = this.props.value || this.getNow(); | ||
27913 | var disabledOptions = disabledMinutes(value.getHourOfDay()); | ||
27785 | 27914 | ||
27786 | return _react2['default'].createElement(_Select2['default'], { | 27915 | return _react2['default'].createElement(_Select2['default'], { |
27787 | prefixCls: prefixCls, | 27916 | prefixCls: prefixCls, |
27788 | options: minuteOptions.map(function (option) { | 27917 | options: minuteOptions.map(function (option) { |
27789 | return formatOption(option); | 27918 | return formatOption(option, disabledOptions); |
27790 | }), | 27919 | }), |
27791 | selectedIndex: minuteOptions.indexOf(minute), | 27920 | selectedIndex: minuteOptions.indexOf(minute), |
27792 | type: 'minute', | 27921 | type: 'minute', |
27793 | onSelect: this.onItemChange | 27922 | onSelect: this.onItemChange, |
27923 | onMouseEnter: this.onEnterSelectPanel.bind(this, 'minute') | ||
27794 | }); | 27924 | }); |
27795 | }, | 27925 | }, |
27796 | 27926 | ||
27797 | getSectionSelect: function getSectionSelect(second) { | 27927 | getSecondSelect: function getSecondSelect(second) { |
27798 | var _props3 = this.props; | 27928 | var _props3 = this.props; |
27799 | var prefixCls = _props3.prefixCls; | 27929 | var prefixCls = _props3.prefixCls; |
27800 | var secondOptions = _props3.secondOptions; | 27930 | var secondOptions = _props3.secondOptions; |
27931 | var disabledSeconds = _props3.disabledSeconds; | ||
27801 | var showSecond = _props3.showSecond; | 27932 | var showSecond = _props3.showSecond; |
27802 | 27933 | ||
27803 | if (!showSecond) { | 27934 | if (!showSecond) { |
27804 | return null; | 27935 | return null; |
27805 | } | 27936 | } |
27937 | var value = this.props.value || this.getNow(); | ||
27938 | var disabledOptions = disabledSeconds(value.getHourOfDay(), value.getMinutes()); | ||
27939 | |||
27806 | return _react2['default'].createElement(_Select2['default'], { | 27940 | return _react2['default'].createElement(_Select2['default'], { |
27807 | prefixCls: prefixCls, | 27941 | prefixCls: prefixCls, |
27808 | options: secondOptions.map(function (option) { | 27942 | options: secondOptions.map(function (option) { |
27809 | return formatOption(option); | 27943 | return formatOption(option, disabledOptions); |
27810 | }), | 27944 | }), |
27811 | selectedIndex: secondOptions.indexOf(second), | 27945 | selectedIndex: secondOptions.indexOf(second), |
27812 | type: 'second', | 27946 | type: 'second', |
27813 | onSelect: this.onItemChange | 27947 | onSelect: this.onItemChange, |
27948 | onMouseEnter: this.onEnterSelectPanel.bind(this, 'second') | ||
27814 | }); | 27949 | }); |
27815 | }, | 27950 | }, |
27816 | 27951 | ||
@@ -27833,7 +27968,7 @@ | |||
27833 | { className: prefixCls + '-combobox' }, | 27968 | { className: prefixCls + '-combobox' }, |
27834 | this.getHourSelect(value.getHourOfDay()), | 27969 | this.getHourSelect(value.getHourOfDay()), |
27835 | this.getMinuteSelect(value.getMinutes()), | 27970 | this.getMinuteSelect(value.getMinutes()), |
27836 | this.getSectionSelect(value.getSeconds()) | 27971 | this.getSecondSelect(value.getSeconds()) |
27837 | ); | 27972 | ); |
27838 | } | 27973 | } |
27839 | }); | 27974 | }); |
@@ -27842,7 +27977,7 @@ | |||
27842 | module.exports = exports['default']; | 27977 | module.exports = exports['default']; |
27843 | 27978 | ||
27844 | /***/ }, | 27979 | /***/ }, |
27845 | /* 224 */ | 27980 | /* 225 */ |
27846 | /***/ function(module, exports, __webpack_require__) { | 27981 | /***/ function(module, exports, __webpack_require__) { |
27847 | 27982 | ||
27848 | 'use strict'; | 27983 | 'use strict'; |
@@ -27895,7 +28030,8 @@ | |||
27895 | gregorianCalendarLocale: _react.PropTypes.object, | 28030 | gregorianCalendarLocale: _react.PropTypes.object, |
27896 | selectedIndex: _react.PropTypes.number, | 28031 | selectedIndex: _react.PropTypes.number, |
27897 | type: _react.PropTypes.string, | 28032 | type: _react.PropTypes.string, |
27898 | onSelect: _react.PropTypes.func | 28033 | onSelect: _react.PropTypes.func, |
28034 | onMouseEnter: _react.PropTypes.func | ||
27899 | }, | 28035 | }, |
27900 | 28036 | ||
27901 | componentDidMount: function componentDidMount() { | 28037 | componentDidMount: function componentDidMount() { |
@@ -27903,9 +28039,11 @@ | |||
27903 | this.scrollToSelected(0); | 28039 | this.scrollToSelected(0); |
27904 | }, | 28040 | }, |
27905 | 28041 | ||
27906 | componentDidUpdate: function componentDidUpdate() { | 28042 | componentDidUpdate: function componentDidUpdate(prevProps) { |
27907 | // smooth scroll to selected option | 28043 | // smooth scroll to selected option |
27908 | this.scrollToSelected(120); | 28044 | if (prevProps.selectedIndex !== this.props.selectedIndex) { |
28045 | this.scrollToSelected(120); | ||
28046 | } | ||
27909 | }, | 28047 | }, |
27910 | 28048 | ||
27911 | onSelect: function onSelect(value) { | 28049 | onSelect: function onSelect(value) { |
@@ -27925,12 +28063,17 @@ | |||
27925 | var prefixCls = _props2.prefixCls; | 28063 | var prefixCls = _props2.prefixCls; |
27926 | 28064 | ||
27927 | return options.map(function (item, index) { | 28065 | return options.map(function (item, index) { |
27928 | var selected = selectedIndex === index; | 28066 | var _classnames; |
27929 | var cls = (0, _classnames3['default'])(_defineProperty({}, prefixCls + '-select-option-selected', selected)); | 28067 | |
28068 | var cls = (0, _classnames3['default'])((_classnames = {}, _defineProperty(_classnames, prefixCls + '-select-option-selected', selectedIndex === index), _defineProperty(_classnames, prefixCls + '-select-option-disabled', item.disabled), _classnames)); | ||
28069 | var onclick = null; | ||
28070 | if (!item.disabled) { | ||
28071 | onclick = _this.onSelect.bind(_this, +item.value); | ||
28072 | } | ||
27930 | return _react2['default'].createElement( | 28073 | return _react2['default'].createElement( |
27931 | 'li', | 28074 | 'li', |
27932 | { className: cls, key: index, onClick: _this.onSelect.bind(_this, +item) }, | 28075 | { className: cls, key: index, onClick: onclick, disabled: item.disabled }, |
27933 | item | 28076 | item.value |
27934 | ); | 28077 | ); |
27935 | }); | 28078 | }); |
27936 | }, | 28079 | }, |
@@ -27944,7 +28087,7 @@ | |||
27944 | index = 0; | 28087 | index = 0; |
27945 | } | 28088 | } |
27946 | var topOption = list.children[index]; | 28089 | var topOption = list.children[index]; |
27947 | var to = topOption.offsetTop - select.offsetTop; | 28090 | var to = topOption.offsetTop; |
27948 | scrollTo(select, to, duration); | 28091 | scrollTo(select, to, duration); |
27949 | }, | 28092 | }, |
27950 | 28093 | ||
@@ -27957,7 +28100,8 @@ | |||
27957 | 28100 | ||
27958 | return _react2['default'].createElement( | 28101 | return _react2['default'].createElement( |
27959 | 'div', | 28102 | 'div', |
27960 | { className: prefixCls + '-select' }, | 28103 | { className: prefixCls + '-select', |
28104 | onMouseEnter: this.props.onMouseEnter }, | ||
27961 | _react2['default'].createElement( | 28105 | _react2['default'].createElement( |
27962 | 'ul', | 28106 | 'ul', |
27963 | { ref: 'list' }, | 28107 | { ref: 'list' }, |
@@ -27971,7 +28115,7 @@ | |||
27971 | module.exports = exports['default']; | 28115 | module.exports = exports['default']; |
27972 | 28116 | ||
27973 | /***/ }, | 28117 | /***/ }, |
27974 | /* 225 */ | 28118 | /* 226 */ |
27975 | /***/ function(module, exports) { | 28119 | /***/ function(module, exports) { |
27976 | 28120 | ||
27977 | 'use strict'; | 28121 | 'use strict'; |
@@ -28017,7 +28161,7 @@ | |||
28017 | module.exports = exports['default']; | 28161 | module.exports = exports['default']; |
28018 | 28162 | ||
28019 | /***/ }, | 28163 | /***/ }, |
28020 | /* 226 */ | 28164 | /* 227 */ |
28021 | /***/ function(module, exports, __webpack_require__) { | 28165 | /***/ function(module, exports, __webpack_require__) { |
28022 | 28166 | ||
28023 | 'use strict'; | 28167 | 'use strict'; |
@@ -28041,7 +28185,7 @@ | |||
28041 | } | 28185 | } |
28042 | 28186 | ||
28043 | /***/ }, | 28187 | /***/ }, |
28044 | /* 227 */ | 28188 | /* 228 */ |
28045 | /***/ function(module, exports, __webpack_require__) { | 28189 | /***/ function(module, exports, __webpack_require__) { |
28046 | 28190 | ||
28047 | 'use strict'; | 28191 | 'use strict'; |
@@ -28052,7 +28196,7 @@ | |||
28052 | 28196 | ||
28053 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | 28197 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } |
28054 | 28198 | ||
28055 | var _gregorianCalendarFormatLibLocaleZh_CN = __webpack_require__(228); | 28199 | var _gregorianCalendarFormatLibLocaleZh_CN = __webpack_require__(229); |
28056 | 28200 | ||
28057 | var _gregorianCalendarFormatLibLocaleZh_CN2 = _interopRequireDefault(_gregorianCalendarFormatLibLocaleZh_CN); | 28201 | var _gregorianCalendarFormatLibLocaleZh_CN2 = _interopRequireDefault(_gregorianCalendarFormatLibLocaleZh_CN); |
28058 | 28202 | ||
@@ -28063,7 +28207,7 @@ | |||
28063 | module.exports = exports['default']; | 28207 | module.exports = exports['default']; |
28064 | 28208 | ||
28065 | /***/ }, | 28209 | /***/ }, |
28066 | /* 228 */ | 28210 | /* 229 */ |
28067 | /***/ function(module, exports) { | 28211 | /***/ function(module, exports) { |
28068 | 28212 | ||
28069 | 'use strict'; | 28213 | 'use strict'; |