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

9
components/date-picker/index.tsx

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

Loading…
Cancel
Save