UNPKG

4.3 kBTypeScriptView Raw
1/// <reference types="react" />
2import * as React from 'react';
3import CommonProps from '../util';
4import { Dayjs, ConfigType } from 'dayjs';
5import { PopupProps } from '../overlay';
6import { InputProps } from '../input';
7
8export default class DatePicker extends React.Component<DatePickerProps, any> {
9 static RangePicker: typeof RangePicker;
10 static MonthPicker: typeof MonthPicker;
11 static YearPicker: typeof YearPicker;
12 static WeekPicker: typeof WeekPicker;
13 static QuarterPicker: typeof QuarterPicker;
14}
15
16export class YearPicker extends React.Component<DatePickerProps, any> {
17 mode: 'year';
18}
19export class MonthPicker extends React.Component<DatePickerProps, any> {
20 mode: 'month';
21}
22export class WeekPicker extends React.Component<DatePickerProps, any> {
23 mode: 'week';
24}
25export class QuarterPicker extends React.Component<DatePickerProps, any> {
26 mode: 'quarter';
27}
28export class RangePicker extends React.Component<RangePickerProps, any> {
29 type: 'range';
30}
31interface HTMLAttributesWeak extends React.HTMLAttributes<HTMLElement> {
32 defaultValue?: any;
33 onChange?: any;
34}
35export interface DatePickerProps extends HTMLAttributesWeak, CommonProps {
36 type?: 'date' | 'range';
37 name?: string;
38 mode?: 'date' | 'month' | 'week' | 'quarter' | 'year';
39 value?: ConfigType;
40 defaultValue?: ConfigType;
41 defaultPanelValue?: Dayjs;
42 disabledDate?: (value: Dayjs, mode: 'date' | 'month' | 'week' | 'quarter' | 'year') => boolean;
43 extraFooterRender?: React.ReactNode | (() => React.ReactNode);
44 preset?: object | Array<object>;
45 showTime?: boolean;
46 showOk?: boolean;
47 resetTime?: boolean;
48 timePanelProps?: object;
49 disabledTime?: object;
50
51 onOk?: (value: Dayjs, strVal: string) => void;
52 onChange?: (value: Dayjs, strVal: string) => void;
53 onVisibleChange?: (visible: boolean) => void;
54 onPanelChange?: (panelValue: Dayjs, mode: 'date' | 'month' | 'week' | 'quarter' | 'year') => void;
55
56 format?: string | ((value: Dayjs) => string);
57 /**
58 * 输出格式:控制 onChangeonOk 事件的输出值格式
59 * - string 类型:根据时间格式进行转换
60 * - function 类型:((value: Dayjs, strVal: string) => any)
61 *
62 * @version 1.23
63 */
64 outputFormat?: string | ((value: Dayjs, strVal: string) => any);
65 disabled?: boolean;
66 state?: 'success' | 'loading' | 'error';
67 size?: 'small' | 'medium' | 'large';
68 hasBorder?: boolean;
69 inputProps?: InputProps;
70 inputReadOnly?: boolean;
71 hasClear?: boolean;
72 label?: React.ReactNode;
73 separator?: React.ReactNode;
74 placeholder?: string;
75
76 visible?: boolean;
77 defaultVisible?: boolean;
78 popupTriggerType?: 'click' | 'hover';
79 popupAlign?: string;
80 popupContainer?: string | HTMLElement | ((target: HTMLElement) => HTMLElement);
81 popupStyle?: React.CSSProperties;
82 popupClassName?: string;
83 popupProps?: PopupProps;
84 followTrigger?: boolean;
85 popupComponent?: React.Component;
86 dateCellRender?: (value: Dayjs) => React.ReactNode;
87 monthCellRender?: (value: Dayjs) => React.ReactNode;
88 dateInputAriaLabel?: string;
89 isPreview?: boolean;
90 renderPreview?: (value: Dayjs) => React.ReactNode;
91}
92
93export interface RangePickerProps
94 extends Omit<
95 DatePickerProps,
96 | 'value'
97 | 'placeholder'
98 | 'defaultValue'
99 | 'format'
100 | 'onOk'
101 | 'onChange'
102 | 'dateInputAriaLabel'
103 | 'disabled'
104 | 'outputFormat'
105 > {
106 value?: Array<ConfigType>;
107 defaultValue?: Array<ConfigType>;
108 format?: string | ((value: Dayjs) => string) | Array<string> | Array<(value: Dayjs) => string>;
109 onOk?: (value: Array<Dayjs>, strVal: Array<string>) => void;
110 onChange?: (value: Array<Dayjs>, strVal: Array<string>) => void;
111 /**
112 * 输出格式:控制 onChange、onOk 事件的输出值格式
113 * - string 类型:根据时间格式进行转换
114 * - function 类型:((value: Dayjs, strVal: string) => any)
115 *
116 * @version 1.23
117 */
118 outputFormat?: string | ((value: Dayjs) => string) | Array<string> | Array<(value: Dayjs) => string>;
119 placeholder?: string | Array<string>;
120 dateInputAriaLabel?: Array<string> | string;
121 disabled?: boolean | boolean[];
122}