UNPKG

11.5 kBTypeScriptView Raw
1/// <reference types="react" />
2import { Moment } from 'moment';
3import * as React from 'react';
4import CommonProps from '../util';
5import { PopupProps } from '../overlay';
6import { InputProps } from '../input';
7
8interface HTMLAttributesWeak extends React.HTMLAttributes<HTMLElement> {
9 defaultValue?: any;
10 onChange?: any;
11}
12
13export interface MonthPickerProps extends HTMLAttributesWeak, CommonProps {
14 name?: string;
15 /**
16 * 输入框内置标签
17 */
18 label?: React.ReactNode;
19
20 /**
21 * 输入框状态
22 */
23 state?: 'success' | 'loading' | 'error';
24
25 /**
26 * 输入提示
27 */
28 placeholder?: string;
29
30 /**
31 * 默认展现的年
32 */
33 defaultVisibleYear?: () => void;
34
35 /**
36 * 日期值(受控)moment 对象
37 */
38 value?: any;
39
40 /**
41 * 初始日期值,moment 对象
42 */
43 defaultValue?: any;
44
45 /**
46 * 日期值的格式(用于限定用户输入和展示)
47 */
48 format?: string;
49
50 /**
51 * 禁用日期函数
52 */
53 disabledDate?: (date: Moment, view: string) => boolean;
54
55 /**
56 * 自定义面板页脚
57 */
58 footerRender?: () => React.ReactNode;
59
60 /**
61 * 日期值改变时的回调
62 */
63 onChange?: (value: any | string) => void;
64
65 /**
66 * 输入框尺寸
67 */
68 size?: 'small' | 'medium' | 'large';
69
70 /**
71 * 是否禁用
72 */
73 disabled?: boolean;
74
75 /**
76 * 是否显示清空按钮
77 */
78 hasClear?: boolean;
79
80 /**
81 * 弹层显示状态
82 */
83 visible?: boolean;
84
85 /**
86 * 弹层默认是否显示
87 */
88 defaultVisible?: boolean;
89
90 /**
91 * 弹层展示状态变化时的回调
92 */
93 onVisibleChange?: (visible: boolean, reason: string) => void;
94
95 /**
96 * 弹层触发方式
97 */
98 popupTriggerType?: 'click' | 'hover';
99
100 /**
101 * 弹层对齐方式, 具体含义见 OverLay文档
102 */
103 popupAlign?: string;
104
105 /**
106 * 弹层容器
107 */
108 popupContainer?: string | HTMLElement | ((target: HTMLElement) => HTMLElement);
109
110 /**
111 * 弹层自定义样式
112 */
113 popupStyle?: React.CSSProperties;
114
115 /**
116 * 弹层自定义样式类
117 */
118 popupClassName?: string;
119
120 /**
121 * 弹层其他属性
122 */
123 popupProps?: PopupProps;
124
125 /**
126 * 输入框其他属性
127 */
128 inputProps?: InputProps;
129
130 /**
131 * 自定义月份渲染函数
132 */
133 monthCellRender?: (calendarDate: any) => React.ReactNode;
134
135 /**
136 * 日期输入框的 aria-label 属性
137 */
138 dateInputAriaLabel?: string;
139}
140
141
142export class MonthPicker extends React.Component<MonthPickerProps, any> {}
143
144interface HTMLAttributesWeak extends React.HTMLAttributes<HTMLElement> {
145 defaultValue?: any;
146 onChange?: any;
147 placeholder?: any;
148}
149
150export interface RangePickerProps extends HTMLAttributesWeak, CommonProps {
151 name?: string;
152 type?: 'date' | 'month' | 'year',
153
154 /**
155 * 默认展示的起始月份
156 */
157 defaultVisibleMonth?: () => void;
158
159 /**
160 * 输入提示
161 */
162 placeholder?: Array<string> | string;
163
164 /**
165 * 日期范围值数组 [moment, moment]
166 */
167 value?: Array<any>;
168
169 /**
170 * 初始的日期范围值数组 [moment, moment]
171 */
172 defaultValue?: Array<any>;
173
174 /**
175 * 日期格式
176 */
177 format?: string;
178
179 /**
180 * 是否使用时间控件,支持传入 TimePicker 的属性
181 */
182 showTime?: any | boolean;
183
184 /**
185 * 每次选择是否重置时间(仅在 showTime 开启时有效)
186 */
187 resetTime?: boolean;
188
189 /**
190 * 禁用日期函数
191 */
192 disabledDate?: (date: Moment, view: string) => boolean;
193
194 /**
195 * 自定义面板页脚
196 */
197 footerRender?: () => React.ReactNode;
198
199 /**
200 * 日期范围值改变时的回调 [ MomentObject|String, MomentObject|String ]
201 */
202 onChange?: (value: Array<any>) => void;
203
204 /**
205 * 点击确认按钮时的回调 返回开始时间和结束时间`[ MomentObject|String, MomentObject|String ]`
206 */
207 onOk?: (value: Array<any>) => void;
208
209 /**
210 * 输入框内置标签
211 */
212 label?: React.ReactNode;
213
214 /**
215 * 输入框状态
216 */
217 state?: 'error' | 'loading' | 'success';
218
219 /**
220 * 输入框尺寸
221 */
222 size?: 'small' | 'medium' | 'large';
223
224 /**
225 * 是否禁用
226 */
227 disabled?: boolean;
228
229 /**
230 * 是否显示清空按钮
231 */
232 hasClear?: boolean;
233
234 /**
235 * 弹层显示状态
236 */
237 visible?: boolean;
238
239 /**
240 * 弹层默认是否显示
241 */
242 defaultVisible?: boolean;
243
244 /**
245 * 弹层展示状态变化时的回调
246 */
247 onVisibleChange?: (visible: boolean, reason: string) => void;
248
249 /**
250 * 弹层触发方式
251 */
252 popupTriggerType?: 'click' | 'hover';
253
254 /**
255 * 弹层对齐方式, 具体含义见 OverLay文档
256 */
257 popupAlign?: string;
258
259 /**
260 * 弹层容器
261 */
262 popupContainer?: string | HTMLElement | ((target: HTMLElement) => HTMLElement);
263
264 /**
265 * 弹层自定义样式
266 */
267 popupStyle?: React.CSSProperties;
268
269 /**
270 * 弹层自定义样式类
271 */
272 popupClassName?: string;
273
274 /**
275 * 弹层其他属性
276 */
277 popupProps?: PopupProps;
278
279 /**
280 * 输入框其他属性
281 */
282 inputProps?: InputProps;
283
284 /**
285 * 自定义日期单元格渲染
286 */
287 dateCellRender?: () => void;
288
289 /**
290 * 开始日期输入框的 aria-label 属性
291 */
292 startDateInputAriaLabel?: string;
293
294 /**
295 * 开始时间输入框的 aria-label 属性
296 */
297 startTimeInputAriaLabel?: string;
298
299 /**
300 * 结束日期输入框的 aria-label 属性
301 */
302 endDateInputAriaLabel?: string;
303
304 /**
305 * 结束时间输入框的 aria-label 属性
306 */
307 endTimeInputAriaLabel?: string;
308}
309
310export class RangePicker extends React.Component<RangePickerProps, any> {}
311
312interface HTMLAttributesWeak extends React.HTMLAttributes<HTMLElement> {
313 defaultValue?: any;
314 onChange?: any;
315}
316
317export interface YearPickerProps extends HTMLAttributesWeak, CommonProps {
318 name?: string;
319 /**
320 * 输入框内置标签
321 */
322 label?: React.ReactNode;
323
324 /**
325 * 输入框状态
326 */
327 state?: 'success' | 'loading' | 'error';
328
329 /**
330 * 输入提示
331 */
332 placeholder?: string;
333
334 /**
335 * 日期值(受控)moment 对象
336 */
337 value?: any;
338
339 /**
340 * 初始日期值,moment 对象
341 */
342 defaultValue?: any;
343
344 /**
345 * 日期值的格式(用于限定用户输入和展示)
346 */
347 format?: string;
348
349 /**
350 * 禁用日期函数
351 */
352 disabledDate?: (date: Moment, view: string) => boolean;
353
354 /**
355 * 自定义面板页脚
356 */
357 footerRender?: () => React.ReactNode;
358
359 /**
360 * 日期值改变时的回调
361 */
362 onChange?: (value: {} | string) => void;
363
364 /**
365 * 输入框尺寸
366 */
367 size?: 'small' | 'medium' | 'large';
368
369 /**
370 * 是否禁用
371 */
372 disabled?: boolean;
373
374 /**
375 * 是否显示清空按钮
376 */
377 hasClear?: boolean;
378
379 /**
380 * 弹层显示状态
381 */
382 visible?: boolean;
383
384 /**
385 * 弹层默认是否显示
386 */
387 defaultVisible?: boolean;
388
389 /**
390 * 弹层展示状态变化时的回调
391 */
392 onVisibleChange?: (visible: boolean, reason: string) => void;
393
394 /**
395 * 弹层触发方式
396 */
397 popupTriggerType?: 'click' | 'hover';
398
399 /**
400 * 弹层对齐方式, 具体含义见 OverLay文档
401 */
402 popupAlign?: string;
403
404 /**
405 * 弹层容器
406 */
407 popupContainer?: string | HTMLElement | ((target: HTMLElement) => HTMLElement);
408
409 /**
410 * 弹层自定义样式
411 */
412 popupStyle?: React.CSSProperties;
413
414 /**
415 * 弹层自定义样式类
416 */
417 popupClassName?: string;
418
419 /**
420 * 弹层其他属性
421 */
422 popupProps?: PopupProps;
423
424 /**
425 * 输入框其他属性
426 */
427 inputProps?: InputProps;
428
429 /**
430 * 日期输入框的 aria-label 属性
431 */
432 dateInputAriaLabel?: string;
433}
434
435export class YearPicker extends React.Component<YearPickerProps, any> {}
436interface HTMLAttributesWeak extends React.HTMLAttributes<HTMLElement> {
437 defaultValue?: any;
438 onChange?: any;
439}
440
441export interface DatePickerProps extends HTMLAttributesWeak, CommonProps {
442 name?: string;
443 /**
444 * 输入框内置标签
445 */
446 label?: React.ReactNode;
447
448 /**
449 * 输入框状态
450 */
451 state?: 'success' | 'loading' | 'error';
452
453 /**
454 * 输入提示
455 */
456 placeholder?: string;
457
458 /**
459 * 默认展现的月
460 */
461 defaultVisibleMonth?: () => void;
462
463 /**
464 * 日期值(受控)moment 对象
465 */
466 value?: any;
467
468 /**
469 * 初始日期值,moment 对象
470 */
471 defaultValue?: any;
472
473 /**
474 * 日期值的格式(用于限定用户输入和展示)
475 */
476 format?: string;
477
478 /**
479 * 是否使用时间控件,传入 TimePicker 的属性 { defaultValue, format, ... }
480 */
481 showTime?: any | boolean;
482
483 /**
484 * 每次选择日期时是否重置时间(仅在 showTime 开启时有效)
485 */
486 resetTime?: boolean;
487
488 /**
489 * 禁用日期函数
490 */
491 disabledDate?: (date: Moment, view: string) => boolean;
492
493 /**
494 * 自定义面板页脚
495 */
496 footerRender?: () => React.ReactNode;
497
498 /**
499 * 日期值改变时的回调
500 */
501 onChange?: (value: {} | string) => void;
502
503 /**
504 * 点击确认按钮时的回调
505 */
506 onOk?: (value: {} | string) => void;
507
508 /**
509 * 输入框尺寸
510 */
511 size?: 'small' | 'medium' | 'large';
512
513 /**
514 * 是否禁用
515 */
516 disabled?: boolean;
517
518 /**
519 * 是否显示清空按钮
520 */
521 hasClear?: boolean;
522
523 /**
524 * 弹层显示状态
525 */
526 visible?: boolean;
527
528 /**
529 * 弹层默认是否显示
530 */
531 defaultVisible?: boolean;
532
533 /**
534 * 弹层展示状态变化时的回调
535 */
536 onVisibleChange?: (visible: boolean, reason: string) => void;
537
538 /**
539 * 弹层触发方式
540 */
541 popupTriggerType?: 'click' | 'hover';
542
543 /**
544 * 弹层对齐方式,具体含义见 OverLay文档
545 */
546 popupAlign?: string;
547
548 /**
549 * 弹层容器
550 */
551 popupContainer?: string | HTMLElement | ((target: HTMLElement) => HTMLElement);
552
553 /**
554 * 弹层自定义样式
555 */
556 popupStyle?: React.CSSProperties;
557
558 /**
559 * 弹层自定义样式类
560 */
561 popupClassName?: string;
562
563 /**
564 * 弹层其他属性
565 */
566 popupProps?: PopupProps;
567
568 /**
569 * 输入框其他属性
570 */
571 inputProps?: InputProps;
572
573 /**
574 * 自定义日期渲染函数
575 */
576 dateCellRender?: (value: {}) => React.ReactNode;
577
578 /**
579 * 自定义月份渲染函数
580 */
581 monthCellRender?: (calendarDate: {}) => React.ReactNode;
582
583 /**
584 * 日期输入框的 aria-label 属性
585 */
586 dateInputAriaLabel?: string;
587
588 /**
589 * 时间输入框的 aria-label 属性
590 */
591 timeInputAriaLabel?: string;
592
593 /**
594 * 是否为预览态
595 */
596 isPreview?: boolean;
597
598 renderPreview?: (value: any) => React.ReactNode;
599}
600
601export default class DatePicker extends React.Component<DatePickerProps, any> {
602 static MonthPicker: typeof MonthPicker;
603 static RangePicker: typeof RangePicker;
604 static YearPicker: typeof YearPicker;
605 static WeekPicker: React.ComponentType<DatePickerProps>;
606}