From 4acbf95c7d2693d73b0c8c021ad892b6529d4c06 Mon Sep 17 00:00:00 2001 From: MG12 Date: Tue, 17 Nov 2015 22:16:15 +0800 Subject: remove TimePanel and merge it to TimePicker --- src/TimePanel.jsx | 121 ------------------------------------------------------ 1 file changed, 121 deletions(-) delete mode 100644 src/TimePanel.jsx (limited to 'src/TimePanel.jsx') diff --git a/src/TimePanel.jsx b/src/TimePanel.jsx deleted file mode 100644 index 110ca1e..0000000 --- a/src/TimePanel.jsx +++ /dev/null @@ -1,121 +0,0 @@ -import React, {PropTypes} from 'react'; -import classnames from 'classnames'; -import CommonMixin from './mixin/CommonMixin'; -import Header from './module/Header'; -import Combobox from './module/Combobox'; - -function noop() { -} - -function generateOptions(length) { - return Array.apply(null, {length: length}).map((item, index) => { - return index; - }); -} - -const TimePanel = React.createClass({ - propTypes: { - prefixCls: PropTypes.string, - defaultValue: PropTypes.object, - locale: PropTypes.object, - placeholder: PropTypes.string, - formatter: PropTypes.object, - hourOptions: PropTypes.array, - minuteOptions: PropTypes.array, - secondOptions: PropTypes.array, - onChange: PropTypes.func, - onClear: PropTypes.func, - }, - - mixins: [CommonMixin], - - getDefaultProps() { - return { - hourOptions: generateOptions(24), - minuteOptions: generateOptions(60), - secondOptions: generateOptions(60), - onChange: noop, - onClear: noop, - }; - }, - - getInitialState() { - return { - value: this.props.defaultValue, - }; - }, - - componentWillMount() { - const formatter = this.props.formatter; - const pattern = formatter.originalPattern; - if (pattern === 'HH:mm') { - this.showSecond = false; - } else if (pattern === 'mm:ss') { - this.showHour = false; - } - }, - - onChange(newValue) { - this.setState({ value: newValue }); - this.props.onChange(newValue); - }, - - onClear() { - this.props.onClear(); - }, - - getPlaceholder(placeholder) { - if (placeholder) { - return placeholder; - } - - const { locale } = this.props; - if (!this.showHour) { - return locale.placeholdermmss; - } else if (!this.showSecond) { - return locale.placeholderHHmm; - } - return locale.placeholderHHmmss; - }, - - showHour: true, - showSecond: true, - - render() { - const { locale, prefixCls, defaultValue, placeholder, hourOptions, minuteOptions, secondOptions } = this.props; - const value = this.state.value || defaultValue; - const cls = classnames({ 'narrow': !this.showHour || !this.showSecond }); - - return ( -
-
- -
- ); - }, -}); - -export default TimePanel; -- cgit v1.2.3