Browse Source

add onTypeChange

pull/519/head
血诺 9 years ago
parent
commit
62bc47300a
  1. 6
      components/calendar/demo/basic.md
  2. 4
      components/calendar/index.jsx

6
components/calendar/demo/basic.md

@ -39,9 +39,11 @@ function getDateData(value) {
function onChange(value) { function onChange(value) {
console.log('change'); console.log('change');
} }
function onTypeChange(type) {
console.log('Type change: %s.', type);
}
ReactDOM.render( ReactDOM.render(
<div style={{ width: 290, border: '1px solid #d9d9d9', borderRadius: 4 }}><Calendar getDateData={getDateData} onChange={onChange} type="date" /></div> <div style={{ width: 290, border: '1px solid #d9d9d9', borderRadius: 4 }}><Calendar getDateData={getDateData} onChange={onChange} onTypeChange={onTypeChange} type="date" /></div>
, document.getElementById('components-calendar-demo-basic')); , document.getElementById('components-calendar-demo-basic'));
```` ````

4
components/calendar/index.jsx

@ -80,7 +80,9 @@ class NoticeCalendar extends Component {
} }
} }
setType(type) { setType(type) {
const oldType = this.state.type;
this.setState({ type }); this.setState({ type });
this.props.onTypeChange(type, oldType);
} }
onPanelChange(value) { onPanelChange(value) {
if (this.state.type === 'month') { if (this.state.type === 'month') {
@ -131,6 +133,7 @@ NoticeCalendar.propTypes = {
className: PropTypes.string, className: PropTypes.string,
style: PropTypes.object, style: PropTypes.object,
onChange: PropTypes.func, onChange: PropTypes.func,
onTypeChange: PropTypes.func,
}; };
NoticeCalendar.defaultProps = { NoticeCalendar.defaultProps = {
locale: CalendarLocale, locale: CalendarLocale,
@ -139,6 +142,7 @@ NoticeCalendar.defaultProps = {
fullscreen: false, fullscreen: false,
prefixCls: PREFIX_CLS, prefixCls: PREFIX_CLS,
onChange: noop, onChange: noop,
onTypeChange: noop,
type: 'date', type: 'date',
}; };

Loading…
Cancel
Save