fix: Add some missing TypeScript prop definititions and clean up date-picker definitions (#16342)

* Add some missing TypeScript prop definitition, clean up date-picker definitions

* use DatePickerMode instead of redundant enumeration of modes

* decade was  missing from the list of modes

See https://codesandbox.io/s/388xplj646
- activate DatePicker
- click on year in header
- click on years in header
- "decade" is printed on footer as mode for renderExtraFooter()

* add decade as possible value for mode prop
This commit is contained in:
Sebastian Busch 2019-05-03 15:55:18 +02:00 committed by zombieJ
parent 0350544de1
commit 4af2b62cb5
6 changed files with 13 additions and 10 deletions

View File

@ -24,6 +24,8 @@ export interface AbstractCheckboxProps<T> {
tabIndex?: number; tabIndex?: number;
name?: string; name?: string;
children?: React.ReactNode; children?: React.ReactNode;
id?: string;
autoFocus?: boolean;
} }
export interface CheckboxProps extends AbstractCheckboxProps<CheckboxChangeEvent> { export interface CheckboxProps extends AbstractCheckboxProps<CheckboxChangeEvent> {

View File

@ -56,7 +56,7 @@ The following APIs are shared by DatePicker, MonthPicker, RangePicker, WeekPicke
| dropdownClassName | to customize the className of the popup calendar | string | - | | dropdownClassName | to customize the className of the popup calendar | string | - |
| getCalendarContainer | to set the container of the floating layer, while the default is to create a `div` element in `body` | function(trigger) | - | | getCalendarContainer | to set the container of the floating layer, while the default is to create a `div` element in `body` | function(trigger) | - |
| locale | localization configuration | object | [default](https://github.com/ant-design/ant-design/blob/master/components/date-picker/locale/example.json) | | locale | localization configuration | object | [default](https://github.com/ant-design/ant-design/blob/master/components/date-picker/locale/example.json) |
| mode | picker panel mode | `time|date|month|year` | 'date' | | mode | picker panel mode | `time|date|month|year|decade` | 'date' |
| open | open state of picker | boolean | - | | open | open state of picker | boolean | - |
| placeholder | placeholder of date input | string\|RangePicker\[] | - | | placeholder | placeholder of date input | string\|RangePicker\[] | - |
| popupStyle | to customize the style of the popup calendar | object | {} | | popupStyle | to customize the style of the popup calendar | object | {} |

View File

@ -82,7 +82,7 @@ moment.locale('zh-cn');
| defaultPickerValue | 默认面板日期 | [moment](http://momentjs.com/) | 无 | | defaultPickerValue | 默认面板日期 | [moment](http://momentjs.com/) | 无 |
| disabledTime | 不可选择的时间 | function(date) | 无 | | disabledTime | 不可选择的时间 | function(date) | 无 |
| format | 设置日期格式,为数组时支持多格式匹配,展示以第一个为准。配置参考 [moment.js](http://momentjs.com/) | string \| string[] | "YYYY-MM-DD" | | format | 设置日期格式,为数组时支持多格式匹配,展示以第一个为准。配置参考 [moment.js](http://momentjs.com/) | string \| string[] | "YYYY-MM-DD" |
| mode | 日期面板的状态 | `time|date|month|year` | 'date' | | mode | 日期面板的状态 | `time|date|month|year|decade` | 'date' |
| renderExtraFooter | 在面板中添加额外的页脚 | (mode) => React.ReactNode | - | | renderExtraFooter | 在面板中添加额外的页脚 | (mode) => React.ReactNode | - |
| showTime | 增加时间选择功能 | Object\|boolean | [TimePicker Options](/components/time-picker/#API) | | showTime | 增加时间选择功能 | Object\|boolean | [TimePicker Options](/components/time-picker/#API) |
| showTime.defaultValue | 设置用户选择日期时默认的时分秒,[例子](#components-date-picker-demo-disabled-date) | [moment](http://momentjs.com/) | moment() | | showTime.defaultValue | 设置用户选择日期时默认的时分秒,[例子](#components-date-picker-demo-disabled-date) | [moment](http://momentjs.com/) | moment() |

View File

@ -23,21 +23,22 @@ export interface PickerProps {
onOpenChange?: (status: boolean) => void; onOpenChange?: (status: boolean) => void;
disabledDate?: (current: moment.Moment | undefined) => boolean; disabledDate?: (current: moment.Moment | undefined) => boolean;
dateRender?: (current: moment.Moment, today: moment.Moment) => React.ReactNode; dateRender?: (current: moment.Moment, today: moment.Moment) => React.ReactNode;
autoFocus?: boolean;
} }
export interface SinglePickerProps { export interface SinglePickerProps {
value?: moment.Moment; value?: moment.Moment;
defaultValue?: moment.Moment; defaultValue?: moment.Moment;
defaultPickerValue?: moment.Moment; defaultPickerValue?: moment.Moment;
renderExtraFooter?: (mode: 'date' | 'month' | 'year' | 'decade') => React.ReactNode; placeholder?: string;
renderExtraFooter?: (mode: DatePickerMode) => React.ReactNode;
onChange?: (date: moment.Moment, dateString: string) => void; onChange?: (date: moment.Moment, dateString: string) => void;
} }
const DatePickerModes = tuple('time', 'date', 'month', 'year'); const DatePickerModes = tuple('time', 'date', 'month', 'year', 'decade');
export type DatePickerMode = (typeof DatePickerModes)[number]; export type DatePickerMode = (typeof DatePickerModes)[number];
export interface DatePickerProps extends PickerProps, SinglePickerProps { export interface DatePickerProps extends PickerProps, SinglePickerProps {
className?: string;
showTime?: TimePickerProps | boolean; showTime?: TimePickerProps | boolean;
showToday?: boolean; showToday?: boolean;
open?: boolean; open?: boolean;
@ -51,13 +52,11 @@ export interface DatePickerProps extends PickerProps, SinglePickerProps {
onOpenChange?: (status: boolean) => void; onOpenChange?: (status: boolean) => void;
onPanelChange?: (value: moment.Moment | undefined, mode: DatePickerMode) => void; onPanelChange?: (value: moment.Moment | undefined, mode: DatePickerMode) => void;
onOk?: (selectedTime: moment.Moment) => void; onOk?: (selectedTime: moment.Moment) => void;
placeholder?: string;
mode?: DatePickerMode; mode?: DatePickerMode;
} }
export interface MonthPickerProps extends PickerProps, SinglePickerProps { export interface MonthPickerProps extends PickerProps, SinglePickerProps {
className?: string; // - currently no own props -
placeholder?: string;
} }
export type RangePickerValue = export type RangePickerValue =
@ -76,6 +75,7 @@ export interface RangePickerProps extends PickerProps {
onCalendarChange?: (dates: RangePickerValue, dateStrings: [string, string]) => void; onCalendarChange?: (dates: RangePickerValue, dateStrings: [string, string]) => void;
onOk?: (selectedTime: RangePickerPresetRange) => void; onOk?: (selectedTime: RangePickerPresetRange) => void;
showTime?: TimePickerProps | boolean; showTime?: TimePickerProps | boolean;
showToday?: boolean;
ranges?: { ranges?: {
[range: string]: RangePickerPresetRange; [range: string]: RangePickerPresetRange;
}; };
@ -95,8 +95,7 @@ export interface RangePickerProps extends PickerProps {
} }
export interface WeekPickerProps extends PickerProps, SinglePickerProps { export interface WeekPickerProps extends PickerProps, SinglePickerProps {
className?: string; // - currently no own props -
placeholder?: string;
} }
export interface DatePickerDecorator extends React.ClassicComponentClass<DatePickerProps> { export interface DatePickerDecorator extends React.ClassicComponentClass<DatePickerProps> {

View File

@ -21,6 +21,7 @@ export interface SwitchProps {
loading?: boolean; loading?: boolean;
autoFocus?: boolean; autoFocus?: boolean;
style?: React.CSSProperties; style?: React.CSSProperties;
title?: string;
} }
export default class Switch extends React.Component<SwitchProps, {}> { export default class Switch extends React.Component<SwitchProps, {}> {

View File

@ -61,6 +61,7 @@ export interface AbstractTooltipProps {
children?: React.ReactNode; children?: React.ReactNode;
// align is a more higher api // align is a more higher api
align?: TooltipAlignConfig; align?: TooltipAlignConfig;
destroyTooltipOnHide?: boolean;
} }
export type RenderFunction = () => React.ReactNode; export type RenderFunction = () => React.ReactNode;