Skip to content

Commit 15e0932

Browse files
committed
refactor(DatePicker): improve types and docs
1 parent 26df8bf commit 15e0932

File tree

8 files changed

+924
-974
lines changed

8 files changed

+924
-974
lines changed

components/date-picker/__docs__/index.en-us.md

+203-101
Large diffs are not rendered by default.

components/date-picker/__docs__/index.md

+200-181
Large diffs are not rendered by default.

components/date-picker/date-picker.tsx

+3-113
Original file line numberDiff line numberDiff line change
@@ -36,158 +36,46 @@ class DatePicker extends Component<DatePickerProps, DatePickerState> {
3636
...ConfigProvider.propTypes,
3737
prefix: PropTypes.string,
3838
rtl: PropTypes.bool,
39-
/**
40-
* 输入框内置标签
41-
*/
4239
label: PropTypes.node,
43-
/**
44-
* 输入框状态
45-
*/
4640
state: PropTypes.oneOf(['success', 'loading', 'error']),
47-
/**
48-
* 输入提示
49-
*/
5041
placeholder: PropTypes.string,
51-
/**
52-
* 默认展现的月
53-
* @returns \{MomentObject\} 返回包含指定月份的 moment 对象实例
54-
*/
5542
defaultVisibleMonth: PropTypes.func,
5643
onVisibleMonthChange: PropTypes.func,
57-
/**
58-
* 日期值(受控)moment 对象
59-
*/
6044
value: checkDateValue,
61-
/**
62-
* 初始日期值,moment 对象
63-
*/
6445
defaultValue: checkDateValue,
65-
/**
66-
* 日期值的格式(用于限定用户输入和展示)
67-
*/
6846
format: PropTypes.string,
69-
/**
70-
* 是否使用时间控件,传入 TimePicker 的属性 \{ defaultValue, format, ... \}
71-
*/
7247
showTime: PropTypes.oneOfType([PropTypes.object, PropTypes.bool]),
73-
/**
74-
* 每次选择日期时是否重置时间(仅在 showTime 开启时有效)
75-
*/
7648
resetTime: PropTypes.bool,
77-
/**
78-
* 禁用日期函数
79-
*/
8049
disabledDate: PropTypes.func,
81-
/**
82-
* 自定义面板页脚
83-
*/
8450
footerRender: PropTypes.func,
85-
/**
86-
* 日期值改变时的回调
87-
*/
8851
onChange: PropTypes.func,
89-
/**
90-
* 点击确认按钮时的回调
91-
*/
9252
onOk: PropTypes.func,
93-
/**
94-
* 输入框尺寸
95-
*/
9653
size: PropTypes.oneOf(['small', 'medium', 'large']),
97-
/**
98-
* 是否禁用
99-
*/
10054
disabled: PropTypes.bool,
101-
/**
102-
* 是否显示清空按钮
103-
*/
10455
hasClear: PropTypes.bool,
105-
/**
106-
* 弹层显示状态
107-
*/
10856
visible: PropTypes.bool,
109-
/**
110-
* 弹层默认是否显示
111-
*/
11257
defaultVisible: PropTypes.bool,
113-
/**
114-
* 弹层展示状态变化时的回调
115-
*/
11658
onVisibleChange: PropTypes.func,
117-
/**
118-
* 弹层触发方式
119-
*/
12059
popupTriggerType: PropTypes.oneOf(['click', 'hover']),
121-
/**
122-
* 弹层对齐方式,具体含义见 OverLay 文档
123-
*/
12460
popupAlign: PropTypes.string,
125-
/**
126-
* 弹层容器
127-
*/
12861
popupContainer: PropTypes.any,
129-
/**
130-
* 弹层自定义样式
131-
*/
13262
popupStyle: PropTypes.object,
133-
/**
134-
* 弹层自定义样式类
135-
*/
13663
popupClassName: PropTypes.string,
137-
/**
138-
* 弹层其他属性
139-
*/
14064
popupProps: PropTypes.object,
141-
/**
142-
* 是否跟随滚动
143-
*/
14465
followTrigger: PropTypes.bool,
145-
/**
146-
* 输入框其他属性
147-
*/
14866
inputProps: PropTypes.object,
149-
/**
150-
* 自定义日期渲染函数
151-
*/
15267
dateCellRender: PropTypes.func,
153-
/**
154-
* 自定义月份渲染函数
155-
*/
15668
monthCellRender: PropTypes.func,
157-
/**
158-
* 自定义年份渲染函数
159-
*/
160-
yearCellRender: PropTypes.func, // 兼容 0.x yearCellRender
161-
/**
162-
* 日期输入框的 aria-label 属性
163-
*/
69+
yearCellRender: PropTypes.func,
16470
dateInputAriaLabel: PropTypes.string,
165-
/**
166-
* 时间输入框的 aria-label 属性
167-
*/
16871
timeInputAriaLabel: PropTypes.string,
169-
/**
170-
* 是否为预览态
171-
*/
17272
isPreview: PropTypes.bool,
173-
/**
174-
* 预览态模式下渲染的内容
175-
*/
17673
renderPreview: PropTypes.func,
17774
locale: PropTypes.object,
17875
className: PropTypes.string,
17976
name: PropTypes.string,
180-
/**
181-
* 自定义弹层组件
182-
*/
18377
popupComponent: PropTypes.elementType,
184-
/**
185-
* 自定义弹层内容
186-
*/
18778
popupContent: PropTypes.node,
188-
/**
189-
* 禁用日期选择器的日期模式切换
190-
*/
19179
disableChangeMode: PropTypes.bool,
19280
yearRange: PropTypes.arrayOf(PropTypes.number),
19381
};
@@ -211,6 +99,8 @@ class DatePicker extends Component<DatePickerProps, DatePickerState> {
21199
onOk: func.noop,
212100
};
213101

102+
static displayName = 'DatePicker';
103+
214104
readonly props: InnerDatePickerProps;
215105

216106
constructor(props: DatePickerProps) {

components/date-picker/month-picker.tsx

+1-85
Original file line numberDiff line numberDiff line change
@@ -33,118 +33,34 @@ class MonthPicker extends Component<MonthPickerProps, MonthPickerState> {
3333
...ConfigProvider.propTypes,
3434
prefix: PropTypes.string,
3535
rtl: PropTypes.bool,
36-
/**
37-
* 输入框内置标签
38-
*/
3936
label: PropTypes.node,
40-
/**
41-
* 输入框状态
42-
*/
4337
state: PropTypes.oneOf(['success', 'loading', 'error']),
44-
/**
45-
* 输入提示
46-
*/
4738
placeholder: PropTypes.string,
48-
/**
49-
* 默认展现的年
50-
*/
5139
defaultVisibleYear: PropTypes.func,
52-
/**
53-
* 日期值(受控)moment 对象
54-
*/
5540
value: checkDateValue,
56-
/**
57-
* 初始日期值,moment 对象
58-
*/
5941
defaultValue: checkDateValue,
60-
/**
61-
* 日期值的格式(用于限定用户输入和展示)
62-
*/
6342
format: PropTypes.string,
64-
/**
65-
* 禁用日期函数
66-
*/
6743
disabledDate: PropTypes.func,
68-
/**
69-
* 自定义面板页脚
70-
*/
7144
footerRender: PropTypes.func,
72-
/**
73-
* 日期值改变时的回调
74-
*/
7545
onChange: PropTypes.func,
76-
/**
77-
* 输入框尺寸
78-
*/
7946
size: PropTypes.oneOf(['small', 'medium', 'large']),
80-
/**
81-
* 是否禁用
82-
*/
8347
disabled: PropTypes.bool,
84-
/**
85-
* 是否显示清空按钮
86-
*/
8748
hasClear: PropTypes.bool,
88-
/**
89-
* 弹层显示状态
90-
*/
9149
visible: PropTypes.bool,
92-
/**
93-
* 弹层默认是否显示
94-
*/
9550
defaultVisible: PropTypes.bool,
96-
/**
97-
* 弹层展示状态变化时的回调
98-
*/
9951
onVisibleChange: PropTypes.func,
100-
/**
101-
* 弹层触发方式
102-
*/
10352
popupTriggerType: PropTypes.oneOf(['click', 'hover']),
104-
/**
105-
* 弹层对齐方式,具体含义见 OverLay 文档
106-
*/
10753
popupAlign: PropTypes.string,
108-
/**
109-
* 弹层容器
110-
*/
11154
popupContainer: PropTypes.any,
112-
/**
113-
* 弹层自定义样式
114-
*/
11555
popupStyle: PropTypes.object,
116-
/**
117-
* 弹层自定义样式类
118-
*/
11956
popupClassName: PropTypes.string,
120-
/**
121-
* 弹层其他属性
122-
*/
12357
popupProps: PropTypes.object,
124-
/**
125-
* 是否跟随滚动
126-
*/
12758
followTrigger: PropTypes.bool,
128-
/**
129-
* 输入框其他属性
130-
*/
13159
inputProps: PropTypes.object,
132-
/**
133-
* 自定义月份渲染函数
134-
*/
13560
monthCellRender: PropTypes.func,
136-
yearCellRender: PropTypes.func, // 兼容 0.x yearCellRender
137-
/**
138-
* 日期输入框的 aria-label 属性
139-
*/
61+
yearCellRender: PropTypes.func,
14062
dateInputAriaLabel: PropTypes.string,
141-
/**
142-
* 是否为预览态
143-
*/
14463
isPreview: PropTypes.bool,
145-
/**
146-
* 预览态模式下渲染的内容
147-
*/
14864
renderPreview: PropTypes.func,
14965
locale: PropTypes.object,
15066
className: PropTypes.string,

0 commit comments

Comments
 (0)