Browse Source

Merge branch 'master' of github.com:ant-design/ant-design

pull/2833/head
afc163 8 years ago
parent
commit
50478936f0
  1. 7
      components/date-picker/createPicker.tsx
  2. 9
      components/date-picker/index.tsx

7
components/date-picker/createPicker.tsx

@ -6,6 +6,11 @@ import classNames from 'classnames';
import assign from 'object-assign';
import Icon from '../icon';
export interface PickerProps {
parseDateFromValue?: Function;
value?: string | Date;
}
export default function createPicker(TheCalendar) {
// use class typescript error
const CalenderWrapper = React.createClass({
@ -16,7 +21,7 @@ export default function createPicker(TheCalendar) {
};
},
componentWillReceiveProps(nextProps) {
componentWillReceiveProps(nextProps: PickerProps) {
if ('value' in nextProps) {
this.setState({
value: nextProps.parseDateFromValue(nextProps.value),

9
components/date-picker/index.tsx

@ -1,4 +1,5 @@
import * as React from 'react';
import assign from 'object-assign';
import RcCalendar from 'rc-calendar';
import MonthCalendar from 'rc-calendar/lib/MonthCalendar';
import createPicker from './createPicker';
@ -38,9 +39,11 @@ export interface RangePickerProps extends PickerProps {
onChange?: (dates: [Date, Date], dateStrings: [String, String]) => void;
showTime?: TimePickerProps;
}
DatePicker.RangePicker = wrapPicker(RangePicker) as React.ClassicComponentClass<RangePickerProps>;
DatePicker.Calendar = Calendar;
DatePicker.MonthPicker = MonthPicker;
assign(DatePicker, {
RangePicker: wrapPicker(RangePicker) as React.ClassicComponentClass<RangePickerProps>,
Calendar,
MonthPicker,
});
export default DatePicker;

Loading…
Cancel
Save