UNPKG

ssc-grid

Version:

React grid component for SSC 3.0

65 lines (55 loc) 1.86 kB
import _classCallCheck from 'babel-runtime/helpers/classCallCheck'; import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn'; import _inherits from 'babel-runtime/helpers/inherits'; import React, { Component } from 'react'; import PropTypes from 'prop-types'; import { default as ReactBootstrapDatePicker } from 'react-bootstrap-date-picker'; /** * DatePicker控件 */ var DatePicker = function (_Component) { _inherits(DatePicker, _Component); function DatePicker(props) { _classCallCheck(this, DatePicker); var _this = _possibleConstructorReturn(this, _Component.call(this, props)); _this.state = {}; return _this; } DatePicker.prototype.handleChange = function handleChange(event) { if (this.props.onChange) { this.props.onChange(event); } }; DatePicker.prototype.render = function render() { var _props = this.props, id = _props.id, value = _props.value, dateFormat = _props.dateFormat; return React.createElement(ReactBootstrapDatePicker, { id: id, value: value, dayLabels: ['日', '一', '二', '三', '四', '五', '六'], monthLabels: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'], dateFormat: dateFormat, onChange: this.handleChange.bind(this) }); }; return DatePicker; }(Component); DatePicker.displayName = 'DatePicker'; DatePicker.defaultProps = { dateFormat: 'YYYY-MM-DD' }; DatePicker.propTypes = { id: PropTypes.string, /** * value */ value: PropTypes.string, /** * 日期格式,支持如下集中格式 * <pre><code>'MM/DD/YYYY', 'DD/MM/YYYY', 'YYYY/MM/DD', 'DD-MM-YYYY'</code></pre> */ dateFormat: PropTypes.string, onChange: PropTypes.func }; export default DatePicker;