Browse Source

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
pull/16419/head
Sebastian Busch 6 years ago
committed by zombieJ
parent
commit
4af2b62cb5
  1. 2
      components/checkbox/Checkbox.tsx
  2. 2
      components/date-picker/index.en-US.md
  3. 2
      components/date-picker/index.zh-CN.md
  4. 15
      components/date-picker/interface.tsx
  5. 1
      components/switch/index.tsx
  6. 1
      components/tooltip/index.tsx

2
components/checkbox/Checkbox.tsx

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

2
components/date-picker/index.en-US.md

@ -56,7 +56,7 @@ The following APIs are shared by DatePicker, MonthPicker, RangePicker, WeekPicke
| 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) | - |
| 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 | - |
| placeholder | placeholder of date input | string\|RangePicker\[] | - |
| popupStyle | to customize the style of the popup calendar | object | {} |

2
components/date-picker/index.zh-CN.md

@ -82,7 +82,7 @@ moment.locale('zh-cn');
| defaultPickerValue | 默认面板日期 | [moment](http://momentjs.com/) | 无 |
| disabledTime | 不可选择的时间 | function(date) | 无 |
| 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 | - |
| showTime | 增加时间选择功能 | Object\|boolean | [TimePicker Options](/components/time-picker/#API) |
| showTime.defaultValue | 设置用户选择日期时默认的时分秒,[例子](#components-date-picker-demo-disabled-date) | [moment](http://momentjs.com/) | moment() |

15
components/date-picker/interface.tsx

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

1
components/switch/index.tsx

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

1
components/tooltip/index.tsx

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

Loading…
Cancel
Save