From 02de449a0474765a4796fa607e7e3922252f574f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B4=96=E9=B9=B0?= Date: Fri, 13 Nov 2015 11:33:48 +0800 Subject: release 0.1.0 --- src/module/Combobox.jsx | 95 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 src/module/Combobox.jsx (limited to 'src/module/Combobox.jsx') diff --git a/src/module/Combobox.jsx b/src/module/Combobox.jsx new file mode 100644 index 0000000..e6fe5ed --- /dev/null +++ b/src/module/Combobox.jsx @@ -0,0 +1,95 @@ +import React, {PropTypes} from 'react'; +import Select from './Select'; + +const formatOption = (option) => { + if (option < 10) { + return `0${option}`; + } + return `${option}`; +}; + +const Combobox = React.createClass({ + propTypes: { + formatter: PropTypes.object, + prefixCls: PropTypes.string, + value: PropTypes.object, + onChange: PropTypes.func, + showHour: PropTypes.bool, + showSecond: PropTypes.bool, + hourOptions: PropTypes.array, + minuteOptions: PropTypes.array, + secondOptions: PropTypes.array, + }, + + onItemChange(type, itemValue) { + const { value, onChange } = this.props; + let index = 4; + if (type === 'minute') { + index = 5; + } else if (type === 'second') { + index = 6; + } + value.fields[index] = itemValue; + onChange(value); + }, + + getHourSelect(hour) { + const { prefixCls, hourOptions, showHour } = this.props; + if (!showHour) { + return null; + } + return ( + formatOption(option))} + selectedIndex={minuteOptions.indexOf(minute)} + type="minute" + onSelect={this.onItemChange} + /> + ); + }, + + getSectionSelect(second) { + const { prefixCls, secondOptions, showSecond } = this.props; + if (!showSecond) { + return null; + } + return ( +