Skip to content

Commit 796b660

Browse files
authored
chore: update DatePicker types (#2730)
1 parent 90de3f3 commit 796b660

File tree

5 files changed

+172
-56
lines changed

5 files changed

+172
-56
lines changed

types/date-picker/common.d.ts

Lines changed: 63 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,91 +2,136 @@
22
// Definitions by: akki-jat <https://github.com/akki-jat>
33
// Definitions: https://github.com/vueComponent/ant-design-vue/types
44

5-
import { AntdComponent } from '../component';
65
import { Moment } from 'moment';
6+
import { VNodeChild } from 'vue';
7+
import { AntdComponent } from '../component';
78

8-
export declare class DatepickerCommon extends AntdComponent {
9+
export declare class DatepickerProps {
910
/**
1011
* Whether to show clear button
1112
* @default true
1213
* @type boolean
1314
*/
14-
allowClear: boolean;
15+
allowClear?: boolean;
1516

1617
/**
1718
* get focus when component mounted
1819
* @default false
1920
* @type boolean
2021
*/
21-
autofocus: boolean;
22+
autofocus?: boolean;
2223

2324
/**
2425
* custom rendering function for date cells by setting a scoped slot
25-
* @type any (slot="dateRender" slot-scope="current, today")
26+
* @type VNodeChild | JSX.Element (slot="dateRender" slot-scope="current, today")
2627
*/
27-
dateRender: any;
28+
dateRender?: VNodeChild | JSX.Element;
2829

2930
/**
3031
* determine whether the DatePicker is disabled
3132
* @default false
3233
* @type boolean
3334
*/
34-
disabled: boolean;
35+
disabled?: boolean;
3536

3637
/**
3738
* specify the date that cannot be selected
3839
* @type Function
3940
*/
40-
disabledDate: (currentDate: Moment) => boolean;
41+
disabledDate?: (currentDate?: Moment) => boolean;
4142

4243
/**
4344
* to set the container of the floating layer, while the default is to create a div element in body
4445
* @type Function
4546
*/
46-
getCalendarContainer: (trigger: any) => any;
47+
getCalendarContainer?: (trigger?: any) => HTMLElement;
4748

4849
/**
4950
* localization configuration
5051
* @type any
5152
*/
52-
locale: any;
53+
locale?: object;
54+
55+
/**
56+
* picker panel mode *(Cannot select year or month anymore?
57+
* @see https://antdv.com/docs/vue/faq#When-set-mode-to-DatePicker/RangePicker,-cannot-select-year-or-month-anymore?
58+
*/
59+
mode?: 'time' | 'date' | 'month' | 'year' | 'decade';
5360

5461
/**
5562
* open state of picker
5663
* @type boolean
5764
*/
58-
open: boolean;
65+
open?: boolean;
5966

6067
/**
6168
* placeholder of date input
6269
* @type string | string[]
6370
*/
64-
placeholder: string | string[];
71+
placeholder?: string | string[];
6572

6673
/**
6774
* to customize the style of the popup calendar
6875
* @type object
6976
*/
70-
popupStyle: object;
77+
popupStyle?: object;
7178

7279
/**
7380
* to customize the className of the popup calendar
7481
* @type string
7582
*/
76-
dropdownClassName: string;
83+
dropdownClassName?: string;
7784

7885
/**
7986
* determine the size of the input box, the height of large and small, are 40px and 24px respectively, while default size is 32px
8087
* @type string
8188
*/
82-
size: 'large' | 'small' | 'default';
89+
size?: 'large' | 'small' | 'default';
8390

8491
/**
8592
* The custom suffix icon
8693
* @type any (VNode | slot)
8794
*/
88-
suffixIcon: any;
95+
suffixIcon?: VNodeChild | JSX.Element;
96+
97+
/**
98+
* Set the readonly attribute of the input tag (avoids virtual keyboard on touch devices)
99+
* @version 1.5.4
100+
*/
101+
inputReadOnly?: boolean;
102+
103+
/**
104+
* this value will be merged into placement's config, please refer to the settings
105+
* @see https://github.com/yiminghe/dom-align
106+
* @version 1.5.4
107+
*/
108+
align?: object;
109+
110+
/**
111+
* optional, format of binding value. If not specified, the binding value will be a Date object
112+
* @version 1.5.4
113+
*/
114+
valueFormat?: string;
115+
116+
/**
117+
* a callback function, can be executed whether the popup calendar is popped up or closed
118+
*/
119+
onOpenChange?: (status?: any) => void;
89120

90-
inputReadOnly: boolean;
91-
valueFormat: string;
121+
/**
122+
* callback when picker panel mode is changed
123+
*/
124+
onPanelChange?: (value?: any, mode?: any) => void;
125+
}
126+
127+
export declare class DatepickerMethod extends AntdComponent {
128+
/**
129+
* remove focus
130+
*/
131+
blur(): void;
132+
133+
/**
134+
* get focus
135+
*/
136+
focus(): void;
92137
}

types/date-picker/date-picker.d.ts

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,56 +2,53 @@
22
// Definitions by: akki-jat <https://github.com/akki-jat>
33
// Definitions: https://github.com/vueComponent/ant-design-vue/types
44

5-
import { DatepickerCommon } from './common';
5+
import { DatepickerProps, DatepickerMethod } from './common';
66
import { Moment } from 'moment';
77
import { RangePicker } from './range-picker';
88
import { MonthPicker } from './month-picker';
99
import { WeekPicker } from './week-picker';
10+
import { VNodeChild } from 'vue';
1011

11-
export declare class DatePicker extends DatepickerCommon {
12-
static RangePicker: typeof RangePicker;
13-
static MonthPicker: typeof MonthPicker;
14-
static WeekPicker: typeof WeekPicker;
15-
12+
declare class DatePickerProps extends DatepickerProps {
1613
/**
1714
* Defualt Value
1815
* @description to set default date
1916
* @default undefined
2017
* @type Moment
2118
*/
22-
defaultValue: Moment | string;
19+
defaultValue?: Moment | string;
2320

2421
/**
2522
* Default Picker Value
2623
* @description to set default picker date
2724
* @default undefined
2825
* @type Moment
2926
*/
30-
defaultPickerValue: Moment | string;
27+
defaultPickerValue?: Moment | string;
3128

3229
/**
3330
* Disabled Time
3431
* @description to specify the time that cannot be selected
3532
* @default undefined
3633
* @type Function (function(date))
3734
*/
38-
disabledTime: Function;
35+
disabledTime?: Function;
3936

4037
/**
4138
* Format
4239
* @description to set the date format, refer to moment.js http://momentjs.com
4340
* @default 'YYYY-MM-DD'
4441
* @type string
4542
*/
46-
format: string;
43+
format?: string;
4744

4845
/**
4946
* Render Extra Footer
5047
* @description render extra footer in panel by setting a scoped slot
5148
* @default undefined
5249
* @type any (slot="renderExtraFooter")
5350
*/
54-
renderExtraFooter: any;
51+
renderExtraFooter?: VNodeChild | JSX.Element;
5552

5653
/**
5754
* Show Time
@@ -61,21 +58,39 @@ export declare class DatePicker extends DatepickerCommon {
6158
* @default TimePicker Options
6259
* @type object | boolean
6360
*/
64-
showTime: object | boolean;
61+
showTime?: object | boolean;
6562

6663
/**
6764
* Show Today
6865
* @description whether to show "Today" button
6966
* @default true
7067
* @type boolean
7168
*/
72-
showToday: boolean;
69+
showToday?: boolean;
7370

7471
/**
7572
* Value
7673
* @description to set date
7774
* @default undefined
7875
* @type Moment
7976
*/
80-
value: Moment | string;
77+
value?: Moment | string;
78+
79+
/**
80+
* a callback function, can be executed when the selected time is changing
81+
*/
82+
onChange?: (date?: Moment | string, dateString?: string) => void;
83+
84+
/**
85+
* callback when click ok button
86+
*/
87+
onOk?: () => void;
88+
}
89+
90+
export declare class DatePicker extends DatepickerMethod {
91+
static RangePicker: typeof RangePicker;
92+
static MonthPicker: typeof MonthPicker;
93+
static WeekPicker: typeof WeekPicker;
94+
95+
$props: DatePickerProps;
8196
}

types/date-picker/month-picker.d.ts

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,45 +2,55 @@
22
// Definitions by: akki-jat <https://github.com/akki-jat>
33
// Definitions: https://github.com/vueComponent/ant-design-vue/types
44

5-
import { DatepickerCommon } from './common';
5+
import { DatepickerMethod, DatepickerProps } from './common';
66
import { Moment } from 'moment';
7+
import { VNodeChild } from 'vue';
78

8-
export declare class MonthPicker extends DatepickerCommon {
9+
declare class MonthPickerProps extends DatepickerProps {
910
/**
1011
* to set default date
1112
* @type Moment
1213
*/
13-
defaultValue: Moment | string;
14+
defaultValue?: Moment | string;
1415

1516
/**
1617
* to set default picker date
1718
* @type Moment
1819
*/
19-
defaultPickerValue: Moment | string;
20+
defaultPickerValue?: Moment | string;
2021

2122
/**
2223
* to set the date format, When an array is provided, all values are used for parsing and first value for display. refer to moment.js
2324
* @default 'YYYY-MM'
2425
* @type string | string[]
2526
* @see http://momentjs.com
2627
*/
27-
format: string | string[];
28+
format?: string | string[];
2829

2930
/**
3031
* Custom month cell content render method by setting a scoped slot
3132
* @type Function (slot="monthCellContentRender", slot-scope="date, locale")
3233
*/
33-
monthCellContentRender: Function;
34+
monthCellContentRender?: Function | VNodeChild | JSX.Element;
3435

3536
/**
3637
* render extra footer in panel by setting a scoped slot
3738
* @type any (slot="renderExtraFooter")
3839
*/
39-
renderExtraFooter: any;
40+
renderExtraFooter?: Function | VNodeChild | JSX.Element;
4041

4142
/**
4243
* to set date
4344
* @type Moment
4445
*/
45-
value: Moment | string;
46+
value?: Moment | string;
47+
48+
/**
49+
* a callback function, can be executed when the selected time is changing
50+
*/
51+
onChange?: (date?: Moment | string, dateString?: string) => void;
52+
}
53+
54+
export declare class MonthPicker extends DatepickerMethod {
55+
$props: MonthPickerProps;
4656
}

0 commit comments

Comments
 (0)