@douyinfe/semi-foundation 2.5.1 → 2.7.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/button/button.scss +11 -0
- package/button/variables.scss +4 -0
- package/cascader/foundation.ts +19 -0
- package/datePicker/_utils/formatter.ts +2 -2
- package/datePicker/_utils/getInsetInputFormatToken.ts +42 -0
- package/datePicker/_utils/getInsetInputValueFromInsetInputStr.ts +60 -0
- package/datePicker/constants.ts +2 -0
- package/datePicker/datePicker.scss +136 -3
- package/datePicker/foundation.ts +96 -19
- package/datePicker/inputFoundation.ts +133 -5
- package/datePicker/monthFoundation.ts +1 -0
- package/datePicker/monthsGridFoundation.ts +4 -0
- package/datePicker/rtl.scss +8 -0
- package/datePicker/variables.scss +30 -0
- package/lib/cjs/button/button.css +9 -0
- package/lib/cjs/button/button.scss +11 -0
- package/lib/cjs/button/variables.scss +4 -0
- package/lib/cjs/cascader/foundation.d.ts +19 -0
- package/lib/cjs/cascader/foundation.js +22 -0
- package/lib/cjs/datePicker/_utils/formatter.d.ts +2 -2
- package/lib/cjs/datePicker/_utils/getInsetInputFormatToken.d.ts +20 -0
- package/lib/cjs/datePicker/_utils/getInsetInputFormatToken.js +61 -0
- package/lib/cjs/datePicker/_utils/getInsetInputValueFromInsetInputStr.d.ts +31 -0
- package/lib/cjs/datePicker/_utils/getInsetInputValueFromInsetInputStr.js +76 -0
- package/lib/cjs/datePicker/constants.d.ts +2 -0
- package/lib/cjs/datePicker/constants.js +4 -3
- package/lib/cjs/datePicker/datePicker.css +104 -2
- package/lib/cjs/datePicker/datePicker.scss +136 -3
- package/lib/cjs/datePicker/foundation.d.ts +34 -11
- package/lib/cjs/datePicker/foundation.js +122 -9
- package/lib/cjs/datePicker/inputFoundation.d.ts +73 -4
- package/lib/cjs/datePicker/inputFoundation.js +196 -3
- package/lib/cjs/datePicker/monthFoundation.d.ts +1 -0
- package/lib/cjs/datePicker/monthsGridFoundation.d.ts +1 -0
- package/lib/cjs/datePicker/monthsGridFoundation.js +4 -2
- package/lib/cjs/datePicker/rtl.scss +8 -0
- package/lib/cjs/datePicker/variables.scss +30 -0
- package/lib/cjs/table/table.css +1 -1
- package/lib/cjs/table/table.scss +1 -1
- package/lib/cjs/table/variables.scss +1 -0
- package/lib/cjs/tag/tag.css +1 -0
- package/lib/cjs/tag/tag.scss +1 -0
- package/lib/cjs/tooltip/foundation.js +8 -8
- package/lib/cjs/treeSelect/foundation.d.ts +3 -2
- package/lib/cjs/treeSelect/foundation.js +28 -15
- package/lib/es/button/button.css +9 -0
- package/lib/es/button/button.scss +11 -0
- package/lib/es/button/variables.scss +4 -0
- package/lib/es/cascader/foundation.d.ts +19 -0
- package/lib/es/cascader/foundation.js +22 -1
- package/lib/es/datePicker/_utils/formatter.d.ts +2 -2
- package/lib/es/datePicker/_utils/getInsetInputFormatToken.d.ts +20 -0
- package/lib/es/datePicker/_utils/getInsetInputFormatToken.js +48 -0
- package/lib/es/datePicker/_utils/getInsetInputValueFromInsetInputStr.d.ts +31 -0
- package/lib/es/datePicker/_utils/getInsetInputValueFromInsetInputStr.js +66 -0
- package/lib/es/datePicker/constants.d.ts +2 -0
- package/lib/es/datePicker/constants.js +4 -3
- package/lib/es/datePicker/datePicker.css +104 -2
- package/lib/es/datePicker/datePicker.scss +136 -3
- package/lib/es/datePicker/foundation.d.ts +34 -11
- package/lib/es/datePicker/foundation.js +120 -9
- package/lib/es/datePicker/inputFoundation.d.ts +73 -4
- package/lib/es/datePicker/inputFoundation.js +192 -4
- package/lib/es/datePicker/monthFoundation.d.ts +1 -0
- package/lib/es/datePicker/monthsGridFoundation.d.ts +1 -0
- package/lib/es/datePicker/monthsGridFoundation.js +4 -2
- package/lib/es/datePicker/rtl.scss +8 -0
- package/lib/es/datePicker/variables.scss +30 -0
- package/lib/es/table/table.css +1 -1
- package/lib/es/table/table.scss +1 -1
- package/lib/es/table/variables.scss +1 -0
- package/lib/es/tag/tag.css +1 -0
- package/lib/es/tag/tag.scss +1 -0
- package/lib/es/tooltip/foundation.js +8 -8
- package/lib/es/treeSelect/foundation.d.ts +3 -2
- package/lib/es/treeSelect/foundation.js +27 -15
- package/package.json +3 -3
- package/table/table.scss +1 -1
- package/table/variables.scss +1 -0
- package/tag/tag.scss +1 -0
- package/tooltip/foundation.ts +8 -8
- package/treeSelect/foundation.ts +26 -19
|
@@ -6,6 +6,7 @@ $module: #{$prefix}-datepicker;
|
|
|
6
6
|
.#{$module} {
|
|
7
7
|
box-sizing: border-box;
|
|
8
8
|
display: inline-block;
|
|
9
|
+
vertical-align: top;
|
|
9
10
|
|
|
10
11
|
// 双月网格
|
|
11
12
|
|
|
@@ -45,6 +46,34 @@ $module: #{$prefix}-datepicker;
|
|
|
45
46
|
min-height: $height-datepicker_dateType_yamShowing_min;
|
|
46
47
|
}
|
|
47
48
|
|
|
49
|
+
&[x-insetInput=true] {
|
|
50
|
+
.#{$module}-month-grid-left,
|
|
51
|
+
.#{$module}-month-grid-right {
|
|
52
|
+
&[x-open-type=year] {
|
|
53
|
+
min-height: $height-datepicker_month_grid_yearType_insetInput;
|
|
54
|
+
}
|
|
55
|
+
&[x-open-type=time] {
|
|
56
|
+
min-height: $height-datepicker_month_grid_timeType_insetInput;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.#{$module}-navigation {
|
|
61
|
+
padding-top: $spacing-datepicker_navigation_insetInput-paddingY;
|
|
62
|
+
padding-bottom: $spacing-datepicker_navigation_insetInput-paddingY;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.#{$module}-tpk {
|
|
66
|
+
min-height: $height-datepicker_timeType_insetInput_tpk;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
&[x-type=dateTime],
|
|
70
|
+
&[x-type=dateTimeRange] {
|
|
71
|
+
.#{$module}-yam {
|
|
72
|
+
height: $height-datepicker_timeType_insetInput_yam;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
48
77
|
// 年月选择返回主面板
|
|
49
78
|
.#{$module}-yearmonth-header {
|
|
50
79
|
background: $color-datepicker_header-bg-default;
|
|
@@ -92,6 +121,7 @@ $module: #{$prefix}-datepicker;
|
|
|
92
121
|
|
|
93
122
|
@include font-size-regular;
|
|
94
123
|
min-height: $height-datepicker_timepicker_header_min;
|
|
124
|
+
line-height: $height-datepicker_timepicker_header_min;
|
|
95
125
|
}
|
|
96
126
|
}
|
|
97
127
|
|
|
@@ -581,6 +611,41 @@ $module: #{$prefix}-datepicker;
|
|
|
581
611
|
cursor: pointer;
|
|
582
612
|
}
|
|
583
613
|
|
|
614
|
+
&-inset-input {
|
|
615
|
+
&-wrapper {
|
|
616
|
+
display: flex;
|
|
617
|
+
flex-wrap: nowrap;
|
|
618
|
+
justify-content: space-between;
|
|
619
|
+
box-sizing: border-box;
|
|
620
|
+
column-gap: $spacing-datepicker_insetInput_wrapper-margin;
|
|
621
|
+
padding: $spacing-datepicker_insetInput_wrapper-paddingY $spacing-datepicker_insetInput_wrapper-paddingX;
|
|
622
|
+
padding-bottom: $spacing-datepicker_insetInput_wrapper-paddingBottom;
|
|
623
|
+
|
|
624
|
+
width: $width-datepicker_insetInput_date_type_wrapper;
|
|
625
|
+
&[x-type=dateRange],
|
|
626
|
+
&[x-type=dateTimeRange] {
|
|
627
|
+
width: $width-datepicker_insetInput_date_range_type_wrapper;
|
|
628
|
+
}
|
|
629
|
+
&[x-type=month] {
|
|
630
|
+
width: $width-datepicker_insetInput_month_type_wrapper;
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
.#{$prefix}-input-wrapper {
|
|
634
|
+
flex: 1;
|
|
635
|
+
flex-shrink: 0;
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
&-separator {
|
|
640
|
+
flex-grow: 0;
|
|
641
|
+
flex-shrink: 0;
|
|
642
|
+
height: $height-datepicker_insetInput_separator;
|
|
643
|
+
line-height: $height-datepicker_insetInput_separator;
|
|
644
|
+
padding: $spacing-datepicker_insetInput_separator-paddingY $spacing-datepicker_insetInput_separator-paddingX;
|
|
645
|
+
color: $color-datepicker_insetInput_separator;
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
|
|
584
649
|
&-range {
|
|
585
650
|
|
|
586
651
|
&-input {
|
|
@@ -862,6 +927,33 @@ $module: #{$prefix}-datepicker;
|
|
|
862
927
|
min-height: 6 * $width-datepicker_day_compact;
|
|
863
928
|
}
|
|
864
929
|
}
|
|
930
|
+
|
|
931
|
+
&[x-insetInput=true] {
|
|
932
|
+
.#{$module}-month-grid-left,
|
|
933
|
+
.#{$module}-month-grid-right {
|
|
934
|
+
&[x-open-type=year] {
|
|
935
|
+
min-height: $height-datepicker_tpk_compact;
|
|
936
|
+
}
|
|
937
|
+
&[x-open-type=time] {
|
|
938
|
+
min-height: $height-datepicker_tpk_compact;
|
|
939
|
+
}
|
|
940
|
+
}
|
|
941
|
+
|
|
942
|
+
.#{$module}-yam-showing {
|
|
943
|
+
min-height: $height-datepicker_tpk_compact;
|
|
944
|
+
}
|
|
945
|
+
|
|
946
|
+
.#{$module}-tpk {
|
|
947
|
+
min-height: $height-datepicker_insetInput_tpk_compact;
|
|
948
|
+
}
|
|
949
|
+
|
|
950
|
+
&[x-type=dateTime],
|
|
951
|
+
&[x-type=dateTimeRange] {
|
|
952
|
+
.#{$module}-yam {
|
|
953
|
+
height: $height-datepicker_timeType_insetInput_yam_compact;
|
|
954
|
+
}
|
|
955
|
+
}
|
|
956
|
+
}
|
|
865
957
|
}
|
|
866
958
|
|
|
867
959
|
// 年月选择器
|
|
@@ -1039,6 +1131,46 @@ $module: #{$prefix}-datepicker;
|
|
|
1039
1131
|
padding-right: $spacing-datepicker_footer_compact-paddintRight;
|
|
1040
1132
|
padding-bottom: $spacing-datepicker_footer_compact-paddintBottom;
|
|
1041
1133
|
}
|
|
1134
|
+
|
|
1135
|
+
.#{$module}-inset-input {
|
|
1136
|
+
&-wrapper {
|
|
1137
|
+
column-gap: $spacing-datepicker_insetInput_wrapper_compact-margin;
|
|
1138
|
+
padding: $spacing-datepicker_insetInput_wrapper_compact-paddingY $spacing-datepicker_insetInput_wrapper_compact-paddingX;
|
|
1139
|
+
padding-bottom: $spacing-datepicker_insetInput_wrapper_compact-paddingBottom;
|
|
1140
|
+
|
|
1141
|
+
width: $width-datepicker_insetInput_date_type_wrapper_compact;
|
|
1142
|
+
&[x-type=dateRange],
|
|
1143
|
+
&[x-type=dateTimeRange] {
|
|
1144
|
+
width: $width-datepicker_insetInput_date_range_type_wrapper_compact;
|
|
1145
|
+
padding-top: $spacing-datepicker_insetInput_wrapper_rangeType_compact-paddingTop;
|
|
1146
|
+
|
|
1147
|
+
.#{$prefix}-input-wrapper {
|
|
1148
|
+
margin-top: $spacing-datepicker_insetInput_wrapper_compact-paddingY;
|
|
1149
|
+
}
|
|
1150
|
+
}
|
|
1151
|
+
&[x-type=month] {
|
|
1152
|
+
width: $width-datepicker_insetInput_month_type_wrapper_compact;
|
|
1153
|
+
}
|
|
1154
|
+
|
|
1155
|
+
.#{$prefix}-input-wrapper {
|
|
1156
|
+
height: $height-datepicker_insetInput_wrapper_compact;
|
|
1157
|
+
box-sizing: border-box;
|
|
1158
|
+
|
|
1159
|
+
.#{$prefix}-input {
|
|
1160
|
+
font-size: $fontSize-datepicker_insetInput_compact-fontSize;
|
|
1161
|
+
line-height: $height-datepicker_insetInput_compact;
|
|
1162
|
+
height: $height-datepicker_insetInput_compact;
|
|
1163
|
+
vertical-align: top;
|
|
1164
|
+
}
|
|
1165
|
+
}
|
|
1166
|
+
}
|
|
1167
|
+
|
|
1168
|
+
&-separator {
|
|
1169
|
+
border-left: $width-datepicker-border solid $color-datepicker_border-bg-default;
|
|
1170
|
+
transform: translateX(50%);
|
|
1171
|
+
height: auto;
|
|
1172
|
+
}
|
|
1173
|
+
}
|
|
1042
1174
|
}
|
|
1043
1175
|
|
|
1044
1176
|
// 向上弹出时固定高度为6周 #1042
|
|
@@ -1046,8 +1178,10 @@ $module: #{$prefix}-datepicker;
|
|
|
1046
1178
|
|
|
1047
1179
|
&-wrapper {
|
|
1048
1180
|
|
|
1049
|
-
&[x-placement
|
|
1050
|
-
&[x-placement
|
|
1181
|
+
&[x-placement^="top"],
|
|
1182
|
+
&[x-placement="leftTop"],
|
|
1183
|
+
&[x-placement="rightTop"],
|
|
1184
|
+
&[x-placement*="BottomOver"] {
|
|
1051
1185
|
.#{$module} .#{$module}-weeks {
|
|
1052
1186
|
min-height: 6 * $width-datepicker_day;
|
|
1053
1187
|
}
|
|
@@ -1056,7 +1190,6 @@ $module: #{$prefix}-datepicker;
|
|
|
1056
1190
|
min-height: 6 * $width-datepicker_day_compact;
|
|
1057
1191
|
}
|
|
1058
1192
|
}
|
|
1059
|
-
|
|
1060
1193
|
}
|
|
1061
1194
|
}
|
|
1062
1195
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import BaseFoundation, { DefaultAdapter } from '../base/foundation';
|
|
3
3
|
import { strings } from './constants';
|
|
4
|
-
import { Type, DateInputFoundationProps } from './inputFoundation';
|
|
4
|
+
import { Type, DateInputFoundationProps, InsetInputValue } from './inputFoundation';
|
|
5
5
|
import { MonthsGridFoundationProps } from './monthsGridFoundation';
|
|
6
6
|
import { WeekStartNumber } from './_utils/getMonthTable';
|
|
7
7
|
import { ArrayElement, Motion } from '../utils/type';
|
|
@@ -70,6 +70,7 @@ export interface RenderProps {
|
|
|
70
70
|
renderFullDate?: RenderFullDateType;
|
|
71
71
|
triggerRender?: TriggerRenderType;
|
|
72
72
|
}
|
|
73
|
+
export declare type RangeType = 'rangeStart' | 'rangeEnd' | false;
|
|
73
74
|
export interface EventHandlerProps {
|
|
74
75
|
onCancel?: OnCancelType;
|
|
75
76
|
onChange?: OnChangeType;
|
|
@@ -78,7 +79,7 @@ export interface EventHandlerProps {
|
|
|
78
79
|
onConfirm?: OnConfirmType;
|
|
79
80
|
onBlur?: (e: any) => void;
|
|
80
81
|
onClear?: (e: any) => void;
|
|
81
|
-
onFocus?: (e: any, rangType:
|
|
82
|
+
onFocus?: (e: any, rangType: RangeType) => void;
|
|
82
83
|
onPresetClick?: OnPresetClickType;
|
|
83
84
|
}
|
|
84
85
|
export interface DatePickerFoundationProps extends ElementProps, RenderProps, EventHandlerProps {
|
|
@@ -130,17 +131,20 @@ export interface DatePickerFoundationProps extends ElementProps, RenderProps, Ev
|
|
|
130
131
|
dateFnsLocale?: any;
|
|
131
132
|
localeCode?: string;
|
|
132
133
|
rangeSeparator?: string;
|
|
134
|
+
insetInput?: boolean;
|
|
133
135
|
}
|
|
134
136
|
export interface DatePickerFoundationState {
|
|
135
137
|
panelShow: boolean;
|
|
136
138
|
isRange: boolean;
|
|
137
139
|
inputValue: string;
|
|
138
|
-
value:
|
|
139
|
-
cachedSelectedValue:
|
|
140
|
+
value: Date[];
|
|
141
|
+
cachedSelectedValue: Date[];
|
|
140
142
|
prevTimeZone: string | number;
|
|
141
143
|
motionEnd: boolean;
|
|
142
|
-
rangeInputFocus:
|
|
144
|
+
rangeInputFocus: RangeType;
|
|
143
145
|
autofocus: boolean;
|
|
146
|
+
insetInputValue: InsetInputValue;
|
|
147
|
+
triggerDisabled: boolean;
|
|
144
148
|
}
|
|
145
149
|
export { Type, DateInputFoundationProps };
|
|
146
150
|
export interface DatePickerAdapter extends DefaultAdapter<DatePickerFoundationProps, DatePickerFoundationState> {
|
|
@@ -155,9 +159,9 @@ export interface DatePickerAdapter extends DefaultAdapter<DatePickerFoundationPr
|
|
|
155
159
|
notifyConfirm: DatePickerFoundationProps['onConfirm'];
|
|
156
160
|
notifyOpenChange: DatePickerFoundationProps['onOpenChange'];
|
|
157
161
|
notifyPresetsClick: DatePickerFoundationProps['onPresetClick'];
|
|
158
|
-
updateValue: (value:
|
|
162
|
+
updateValue: (value: Date[]) => void;
|
|
159
163
|
updatePrevTimezone: (prevTimeZone: string | number) => void;
|
|
160
|
-
updateCachedSelectedValue: (cachedSelectedValue:
|
|
164
|
+
updateCachedSelectedValue: (cachedSelectedValue: Date[]) => void;
|
|
161
165
|
updateInputValue: (inputValue: string) => void;
|
|
162
166
|
needConfirm: () => boolean;
|
|
163
167
|
typeIsYearOrMonth: () => boolean;
|
|
@@ -165,6 +169,9 @@ export interface DatePickerAdapter extends DefaultAdapter<DatePickerFoundationPr
|
|
|
165
169
|
setRangeInputFocus: (rangeInputFocus: DatePickerFoundationState['rangeInputFocus']) => void;
|
|
166
170
|
couldPanelClosed: () => boolean;
|
|
167
171
|
isEventTarget: (e: any) => boolean;
|
|
172
|
+
updateInsetInputValue: (insetInputValue: InsetInputValue) => void;
|
|
173
|
+
setInsetInputFocus: () => void;
|
|
174
|
+
setTriggerDisabled: (disabled: boolean) => void;
|
|
168
175
|
}
|
|
169
176
|
/**
|
|
170
177
|
* The datePicker foundation.js is responsible for maintaining the date value and the input box value, as well as the callback of both
|
|
@@ -207,6 +214,10 @@ export default class DatePickerFoundation extends BaseFoundation<DatePickerAdapt
|
|
|
207
214
|
* clear input value when selected date is not confirmed
|
|
208
215
|
*/
|
|
209
216
|
needConfirmSideEffectsWhenClosePanel(willUpdateDates: Date[] | null | undefined): void;
|
|
217
|
+
/**
|
|
218
|
+
* clear inset input value when close panel
|
|
219
|
+
*/
|
|
220
|
+
clearInsetInputValue(): void;
|
|
210
221
|
resetCachedSelectedValue(willUpdateDates?: Date[]): void;
|
|
211
222
|
/**
|
|
212
223
|
* timing to call closePanel
|
|
@@ -233,6 +244,17 @@ export default class DatePickerFoundation extends BaseFoundation<DatePickerAdapt
|
|
|
233
244
|
* @param {Event} e
|
|
234
245
|
*/
|
|
235
246
|
handleInputChange(input: string, e: any): void;
|
|
247
|
+
/**
|
|
248
|
+
* inset input 变化时需要更新以下 state 状态
|
|
249
|
+
* - insetInputValue(总是)
|
|
250
|
+
* - inputValue(可以解析为合法日期时)
|
|
251
|
+
* - value(可以解析为合法日期时)
|
|
252
|
+
*/
|
|
253
|
+
handleInsetInputChange(options: {
|
|
254
|
+
insetInputStr: string;
|
|
255
|
+
format: string;
|
|
256
|
+
insetInputValue: InsetInputValue;
|
|
257
|
+
}): void;
|
|
236
258
|
/**
|
|
237
259
|
* Input box blur
|
|
238
260
|
* @param {String} input
|
|
@@ -250,7 +272,7 @@ export default class DatePickerFoundation extends BaseFoundation<DatePickerAdapt
|
|
|
250
272
|
* @param {String} range 'rangeStart' or 'rangeEnd', use when type is range
|
|
251
273
|
*/
|
|
252
274
|
handleInputFocus(e: any, range: 'rangeStart' | 'rangeEnd'): void;
|
|
253
|
-
handleSetRangeFocus(rangeInputFocus:
|
|
275
|
+
handleSetRangeFocus(rangeInputFocus: RangeType): void;
|
|
254
276
|
handleInputClear(e: any): void;
|
|
255
277
|
/**
|
|
256
278
|
* 范围选择清除按钮回调
|
|
@@ -269,7 +291,7 @@ export default class DatePickerFoundation extends BaseFoundation<DatePickerAdapt
|
|
|
269
291
|
* @param {string} input
|
|
270
292
|
* @returns {Date [] | '}
|
|
271
293
|
*/
|
|
272
|
-
parseInput(input?: string): Date[];
|
|
294
|
+
parseInput(input?: string, format?: string): Date[];
|
|
273
295
|
/**
|
|
274
296
|
* Parses the input when multiple is true, if valid,
|
|
275
297
|
* returns a list of time objects, otherwise returns an array
|
|
@@ -286,14 +308,14 @@ export default class DatePickerFoundation extends BaseFoundation<DatePickerAdapt
|
|
|
286
308
|
* @param {Date[]} dates
|
|
287
309
|
* @returns {string}
|
|
288
310
|
*/
|
|
289
|
-
formatDates(dates?: Date[]): string;
|
|
311
|
+
formatDates(dates?: Date[], customFormat?: string): string;
|
|
290
312
|
/**
|
|
291
313
|
* dates[] => string
|
|
292
314
|
*
|
|
293
315
|
* @param {Date[]} dates
|
|
294
316
|
* @returns {string}
|
|
295
317
|
*/
|
|
296
|
-
formatMultipleDates(dates?: Date[], separator?: string): string;
|
|
318
|
+
formatMultipleDates(dates?: Date[], separator?: string, customFormat?: string): string;
|
|
297
319
|
/**
|
|
298
320
|
* Update date value and the value of the input box
|
|
299
321
|
* 1. Select Update
|
|
@@ -414,4 +436,5 @@ export default class DatePickerFoundation extends BaseFoundation<DatePickerAdapt
|
|
|
414
436
|
* @returns
|
|
415
437
|
*/
|
|
416
438
|
handleTriggerWrapperClick(e: any): void;
|
|
439
|
+
handlePanelVisibleChange(visible: boolean): void;
|
|
417
440
|
}
|
|
@@ -64,6 +64,10 @@ var _constants = require("./constants");
|
|
|
64
64
|
|
|
65
65
|
var _constants2 = require("../input/constants");
|
|
66
66
|
|
|
67
|
+
var _getInsetInputFormatToken = _interopRequireDefault(require("./_utils/getInsetInputFormatToken"));
|
|
68
|
+
|
|
69
|
+
var _getInsetInputValueFromInsetInputStr = _interopRequireDefault(require("./_utils/getInsetInputValueFromInsetInputStr"));
|
|
70
|
+
|
|
67
71
|
/* eslint-disable no-nested-ternary */
|
|
68
72
|
|
|
69
73
|
/* eslint-disable max-len, max-depth, */
|
|
@@ -298,6 +302,20 @@ class DatePickerFoundation extends _foundation.default {
|
|
|
298
302
|
this.resetCachedSelectedValue(willUpdateDates);
|
|
299
303
|
}
|
|
300
304
|
}
|
|
305
|
+
/**
|
|
306
|
+
* clear inset input value when close panel
|
|
307
|
+
*/
|
|
308
|
+
|
|
309
|
+
|
|
310
|
+
clearInsetInputValue() {
|
|
311
|
+
const {
|
|
312
|
+
insetInput
|
|
313
|
+
} = this._adapter.getProps();
|
|
314
|
+
|
|
315
|
+
if (insetInput) {
|
|
316
|
+
this._adapter.updateInsetInputValue(null);
|
|
317
|
+
}
|
|
318
|
+
}
|
|
301
319
|
|
|
302
320
|
resetCachedSelectedValue(willUpdateDates) {
|
|
303
321
|
const {
|
|
@@ -345,6 +363,7 @@ class DatePickerFoundation extends _foundation.default {
|
|
|
345
363
|
|
|
346
364
|
this.rangeTypeSideEffectsWhenClosePanel(inputValue, willUpdateDates);
|
|
347
365
|
this.needConfirmSideEffectsWhenClosePanel(willUpdateDates);
|
|
366
|
+
this.clearInsetInputValue();
|
|
348
367
|
|
|
349
368
|
this._adapter.notifyOpenChange(false);
|
|
350
369
|
|
|
@@ -390,6 +409,52 @@ class DatePickerFoundation extends _foundation.default {
|
|
|
390
409
|
this._adapter.updateInputValue(input);
|
|
391
410
|
}
|
|
392
411
|
}
|
|
412
|
+
/**
|
|
413
|
+
* inset input 变化时需要更新以下 state 状态
|
|
414
|
+
* - insetInputValue(总是)
|
|
415
|
+
* - inputValue(可以解析为合法日期时)
|
|
416
|
+
* - value(可以解析为合法日期时)
|
|
417
|
+
*/
|
|
418
|
+
|
|
419
|
+
|
|
420
|
+
handleInsetInputChange(options) {
|
|
421
|
+
const {
|
|
422
|
+
insetInputStr,
|
|
423
|
+
format,
|
|
424
|
+
insetInputValue
|
|
425
|
+
} = options;
|
|
426
|
+
|
|
427
|
+
const _isMultiple = this._isMultiple();
|
|
428
|
+
|
|
429
|
+
const result = _isMultiple ? this.parseMultipleInput(insetInputStr, format) : this.parseInput(insetInputStr, format);
|
|
430
|
+
const {
|
|
431
|
+
value: stateValue
|
|
432
|
+
} = this.getStates();
|
|
433
|
+
|
|
434
|
+
if (result && result.length) {
|
|
435
|
+
const changedDates = this._getChangedDates(result);
|
|
436
|
+
|
|
437
|
+
if (!this._someDateDisabled(changedDates)) {
|
|
438
|
+
if (this._adapter.needConfirm()) {
|
|
439
|
+
this._adapter.updateCachedSelectedValue(result);
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
if (!(0, _isEqual2.default)(result, stateValue)) {
|
|
443
|
+
if (!this._isControlledComponent()) {
|
|
444
|
+
this._adapter.updateValue(result);
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
this._notifyChange(result);
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
const triggerInput = _isMultiple ? this.formatMultipleDates(result) : this.formatDates(result);
|
|
451
|
+
|
|
452
|
+
this._adapter.updateInputValue(triggerInput);
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
this._adapter.updateInsetInputValue(insetInputValue);
|
|
457
|
+
}
|
|
393
458
|
/**
|
|
394
459
|
* Input box blur
|
|
395
460
|
* @param {String} input
|
|
@@ -520,6 +585,7 @@ class DatePickerFoundation extends _foundation.default {
|
|
|
520
585
|
|
|
521
586
|
parseInput() {
|
|
522
587
|
let input = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
588
|
+
let format = arguments.length > 1 ? arguments[1] : undefined;
|
|
523
589
|
let result = []; // console.log(input);
|
|
524
590
|
|
|
525
591
|
const {
|
|
@@ -529,7 +595,7 @@ class DatePickerFoundation extends _foundation.default {
|
|
|
529
595
|
|
|
530
596
|
if (input && input.length) {
|
|
531
597
|
const type = this.getProp('type');
|
|
532
|
-
const formatToken = this.getProp('format') || (0, _getDefaultFormatToken.getDefaultFormatTokenByType)(type);
|
|
598
|
+
const formatToken = format || this.getProp('format') || (0, _getDefaultFormatToken.getDefaultFormatTokenByType)(type);
|
|
533
599
|
let parsedResult, formatedInput;
|
|
534
600
|
const nowDate = new Date();
|
|
535
601
|
|
|
@@ -622,12 +688,13 @@ class DatePickerFoundation extends _foundation.default {
|
|
|
622
688
|
|
|
623
689
|
formatDates() {
|
|
624
690
|
let dates = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
691
|
+
let customFormat = arguments.length > 1 ? arguments[1] : undefined;
|
|
625
692
|
let str = '';
|
|
626
693
|
const rangeSeparator = this.getProp('rangeSeparator');
|
|
627
694
|
|
|
628
695
|
if ((0, _isArray.default)(dates) && dates.length) {
|
|
629
696
|
const type = this.getProp('type');
|
|
630
|
-
const formatToken = this.getProp('format') || (0, _getDefaultFormatToken.getDefaultFormatTokenByType)(type);
|
|
697
|
+
const formatToken = customFormat || this.getProp('format') || (0, _getDefaultFormatToken.getDefaultFormatTokenByType)(type);
|
|
631
698
|
|
|
632
699
|
switch (type) {
|
|
633
700
|
case 'date':
|
|
@@ -677,6 +744,7 @@ class DatePickerFoundation extends _foundation.default {
|
|
|
677
744
|
formatMultipleDates() {
|
|
678
745
|
let dates = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
679
746
|
let separator = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _constants.strings.DEFAULT_SEPARATOR_MULTIPLE;
|
|
747
|
+
let customFormat = arguments.length > 2 ? arguments[2] : undefined;
|
|
680
748
|
const strs = [];
|
|
681
749
|
|
|
682
750
|
if ((0, _isArray.default)(dates) && dates.length) {
|
|
@@ -686,13 +754,13 @@ class DatePickerFoundation extends _foundation.default {
|
|
|
686
754
|
case 'date':
|
|
687
755
|
case 'dateTime':
|
|
688
756
|
case 'month':
|
|
689
|
-
(0, _forEach.default)(dates).call(dates, date => strs.push(this.formatDates([date])));
|
|
757
|
+
(0, _forEach.default)(dates).call(dates, date => strs.push(this.formatDates([date], customFormat)));
|
|
690
758
|
break;
|
|
691
759
|
|
|
692
760
|
case 'dateRange':
|
|
693
761
|
case 'dateTimeRange':
|
|
694
762
|
for (let i = 0; i < dates.length; i += 2) {
|
|
695
|
-
strs.push(this.formatDates((0, _slice.default)(dates).call(dates, i, i + 2)));
|
|
763
|
+
strs.push(this.formatDates((0, _slice.default)(dates).call(dates, i, i + 2), customFormat));
|
|
696
764
|
}
|
|
697
765
|
|
|
698
766
|
break;
|
|
@@ -742,7 +810,13 @@ class DatePickerFoundation extends _foundation.default {
|
|
|
742
810
|
|
|
743
811
|
|
|
744
812
|
handleSelectedChange(value, options) {
|
|
745
|
-
const
|
|
813
|
+
const {
|
|
814
|
+
type,
|
|
815
|
+
format,
|
|
816
|
+
rangeSeparator,
|
|
817
|
+
insetInput
|
|
818
|
+
} = this._adapter.getProps();
|
|
819
|
+
|
|
746
820
|
const {
|
|
747
821
|
value: stateValue
|
|
748
822
|
} = this.getStates();
|
|
@@ -767,10 +841,24 @@ class DatePickerFoundation extends _foundation.default {
|
|
|
767
841
|
|
|
768
842
|
const changedDates = this._getChangedDates(dates);
|
|
769
843
|
|
|
770
|
-
let inputValue;
|
|
844
|
+
let inputValue, insetInputValue;
|
|
771
845
|
|
|
772
846
|
if (!this._someDateDisabled(changedDates)) {
|
|
773
847
|
inputValue = this._isMultiple() ? this.formatMultipleDates(dates) : this.formatDates(dates);
|
|
848
|
+
|
|
849
|
+
if (insetInput) {
|
|
850
|
+
const insetInputFormatToken = (0, _getInsetInputFormatToken.default)({
|
|
851
|
+
format,
|
|
852
|
+
type
|
|
853
|
+
});
|
|
854
|
+
const insetInputStr = this._isMultiple() ? this.formatMultipleDates(dates, undefined, insetInputFormatToken) : this.formatDates(dates, insetInputFormatToken);
|
|
855
|
+
insetInputValue = (0, _getInsetInputValueFromInsetInputStr.default)({
|
|
856
|
+
inputValue: insetInputStr,
|
|
857
|
+
type,
|
|
858
|
+
rangeSeparator
|
|
859
|
+
});
|
|
860
|
+
}
|
|
861
|
+
|
|
774
862
|
const isRangeTypeAndInputIncomplete = this._isRangeType() && !this._isRangeValueComplete(dates);
|
|
775
863
|
/**
|
|
776
864
|
* If the input is incomplete when under control, the notifyChange is not triggered because
|
|
@@ -785,15 +873,23 @@ class DatePickerFoundation extends _foundation.default {
|
|
|
785
873
|
// do not change value when selected value is incomplete
|
|
786
874
|
this._adapter.updateInputValue(inputValue);
|
|
787
875
|
|
|
876
|
+
this._adapter.updateInsetInputValue(insetInputValue);
|
|
877
|
+
|
|
788
878
|
return;
|
|
789
879
|
} else {
|
|
790
|
-
(!controlled || fromPreset)
|
|
880
|
+
if (!controlled || fromPreset) {
|
|
881
|
+
this._updateValueAndInput(dates, true, inputValue);
|
|
882
|
+
|
|
883
|
+
this._adapter.updateInsetInputValue(insetInputValue);
|
|
884
|
+
}
|
|
791
885
|
}
|
|
792
886
|
}
|
|
793
887
|
|
|
794
888
|
if (!controlled && this._adapter.needConfirm()) {
|
|
795
889
|
// select date only change inputValue when needConfirm is true
|
|
796
|
-
this._adapter.updateInputValue(inputValue);
|
|
890
|
+
this._adapter.updateInputValue(inputValue);
|
|
891
|
+
|
|
892
|
+
this._adapter.updateInsetInputValue(insetInputValue); // if inputValue is not complete, don't notifyChange
|
|
797
893
|
|
|
798
894
|
|
|
799
895
|
if (isRangeTypeAndInputIncomplete) {
|
|
@@ -837,7 +933,7 @@ class DatePickerFoundation extends _foundation.default {
|
|
|
837
933
|
const {
|
|
838
934
|
cachedSelectedValue,
|
|
839
935
|
value
|
|
840
|
-
} = this.getStates();
|
|
936
|
+
} = this._adapter.getStates();
|
|
841
937
|
|
|
842
938
|
const isRangeValueComplete = this._isRangeValueComplete(cachedSelectedValue);
|
|
843
939
|
|
|
@@ -1204,6 +1300,23 @@ class DatePickerFoundation extends _foundation.default {
|
|
|
1204
1300
|
}
|
|
1205
1301
|
}
|
|
1206
1302
|
|
|
1303
|
+
handlePanelVisibleChange(visible) {
|
|
1304
|
+
if (visible) {
|
|
1305
|
+
this._adapter.setInsetInputFocus();
|
|
1306
|
+
/**
|
|
1307
|
+
* After the panel is closed, the trigger input is disabled
|
|
1308
|
+
* 面板关闭后,trigger input 禁用
|
|
1309
|
+
*/
|
|
1310
|
+
|
|
1311
|
+
|
|
1312
|
+
(0, _setTimeout2.default)(() => {
|
|
1313
|
+
this._adapter.setTriggerDisabled(true);
|
|
1314
|
+
}, 0);
|
|
1315
|
+
} else {
|
|
1316
|
+
this._adapter.setTriggerDisabled(false);
|
|
1317
|
+
}
|
|
1318
|
+
}
|
|
1319
|
+
|
|
1207
1320
|
}
|
|
1208
1321
|
|
|
1209
1322
|
exports.default = DatePickerFoundation;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import BaseFoundation, { DefaultAdapter } from '../base/foundation';
|
|
3
|
-
import { BaseValueType, ValidateStatus
|
|
3
|
+
import { BaseValueType, ValidateStatus } from './foundation';
|
|
4
|
+
import { strings } from './constants';
|
|
4
5
|
export declare type Type = 'date' | 'dateRange' | 'year' | 'month' | 'dateTime' | 'dateTimeRange';
|
|
5
6
|
export declare type RangeType = 'rangeStart' | 'rangeEnd';
|
|
7
|
+
export declare type PanelType = 'left' | 'right';
|
|
6
8
|
export interface DateInputEventHandlerProps {
|
|
7
9
|
onClick?: (e: any) => void;
|
|
8
10
|
onChange?: (value: string, e: any) => void;
|
|
@@ -12,6 +14,7 @@ export interface DateInputEventHandlerProps {
|
|
|
12
14
|
onClear?: (e: any) => void;
|
|
13
15
|
onRangeInputClear?: (e: any) => void;
|
|
14
16
|
onRangeEndTabPress?: (e: any) => void;
|
|
17
|
+
onInsetInputChange?: (options: InsetInputChangeProps) => void;
|
|
15
18
|
}
|
|
16
19
|
export interface DateInputElementProps {
|
|
17
20
|
insetLabel?: any;
|
|
@@ -19,10 +22,9 @@ export interface DateInputElementProps {
|
|
|
19
22
|
}
|
|
20
23
|
export interface DateInputFoundationProps extends DateInputElementProps, DateInputEventHandlerProps {
|
|
21
24
|
[x: string]: any;
|
|
22
|
-
value?:
|
|
25
|
+
value?: BaseValueType[];
|
|
23
26
|
disabled?: boolean;
|
|
24
27
|
type?: Type;
|
|
25
|
-
multiple?: boolean;
|
|
26
28
|
showClear?: boolean;
|
|
27
29
|
format?: string;
|
|
28
30
|
inputStyle?: React.CSSProperties;
|
|
@@ -30,11 +32,37 @@ export interface DateInputFoundationProps extends DateInputElementProps, DateInp
|
|
|
30
32
|
validateStatus?: ValidateStatus;
|
|
31
33
|
prefixCls?: string;
|
|
32
34
|
rangeSeparator?: string;
|
|
35
|
+
panelType?: PanelType;
|
|
36
|
+
insetInput?: boolean;
|
|
37
|
+
insetInputValue?: InsetInputValue;
|
|
38
|
+
density?: typeof strings.DENSITY_SET[number];
|
|
39
|
+
}
|
|
40
|
+
export interface InsetInputValue {
|
|
41
|
+
monthLeft: {
|
|
42
|
+
dateInput: string;
|
|
43
|
+
timeInput: string;
|
|
44
|
+
};
|
|
45
|
+
monthRight: {
|
|
46
|
+
dateInput: string;
|
|
47
|
+
timeInput: string;
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
export interface InsetInputChangeFoundationProps {
|
|
51
|
+
value: string;
|
|
52
|
+
insetInputValue: InsetInputValue;
|
|
53
|
+
event: any;
|
|
54
|
+
valuePath: string;
|
|
55
|
+
}
|
|
56
|
+
export interface InsetInputChangeProps {
|
|
57
|
+
insetInputStr: string;
|
|
58
|
+
format: string;
|
|
59
|
+
insetInputValue: InsetInputValue;
|
|
33
60
|
}
|
|
34
61
|
export interface DateInputAdapter extends DefaultAdapter {
|
|
35
62
|
updateIsFocusing: (isFocusing: boolean) => void;
|
|
36
63
|
notifyClick: DateInputFoundationProps['onClick'];
|
|
37
64
|
notifyChange: DateInputFoundationProps['onChange'];
|
|
65
|
+
notifyInsetInputChange: DateInputFoundationProps['onInsetInputChange'];
|
|
38
66
|
notifyEnter: DateInputFoundationProps['onEnterPress'];
|
|
39
67
|
notifyBlur: DateInputFoundationProps['onBlur'];
|
|
40
68
|
notifyClear: DateInputFoundationProps['onClear'];
|
|
@@ -55,5 +83,46 @@ export default class InputFoundation extends BaseFoundation<DateInputAdapter> {
|
|
|
55
83
|
handleRangeInputEnterPress(e: any, rangeInputValue: string): void;
|
|
56
84
|
handleRangeInputEndKeyPress(e: any): void;
|
|
57
85
|
handleRangeInputFocus(e: any, rangeType: RangeType): void;
|
|
58
|
-
formatShowText(value: BaseValueType[]): string;
|
|
86
|
+
formatShowText(value: BaseValueType[], customFormat?: string): string;
|
|
87
|
+
handleInsetInputChange(options: InsetInputChangeFoundationProps): void;
|
|
88
|
+
/**
|
|
89
|
+
* 只有传入的 format 符合 formatReg 时,才会使用用户传入的 format
|
|
90
|
+
* 否则会使用默认的 format 作为 placeholder
|
|
91
|
+
*
|
|
92
|
+
* The format passed in by the user will be used only if the incoming format conforms to formatReg
|
|
93
|
+
* Otherwise the default format will be used as placeholder
|
|
94
|
+
*/
|
|
95
|
+
getInsetInputPlaceholder(): {
|
|
96
|
+
datePlaceholder: any;
|
|
97
|
+
timePlaceholder: any;
|
|
98
|
+
};
|
|
99
|
+
/**
|
|
100
|
+
* 从当前日期值或 inputValue 中解析出 insetInputValue
|
|
101
|
+
*
|
|
102
|
+
* Parse out insetInputValue from current date value or inputValue
|
|
103
|
+
*/
|
|
104
|
+
getInsetInputValue({ value, insetInputValue }: {
|
|
105
|
+
value: BaseValueType[];
|
|
106
|
+
insetInputValue: InsetInputValue;
|
|
107
|
+
}): {
|
|
108
|
+
monthLeft: {
|
|
109
|
+
dateInput: string;
|
|
110
|
+
timeInput: string;
|
|
111
|
+
};
|
|
112
|
+
monthRight: {
|
|
113
|
+
dateInput: string;
|
|
114
|
+
timeInput: string;
|
|
115
|
+
};
|
|
116
|
+
};
|
|
117
|
+
concatInsetDateAndTime({ date, time }: {
|
|
118
|
+
date: any;
|
|
119
|
+
time: any;
|
|
120
|
+
}): string;
|
|
121
|
+
concatInsetDateRange({ rangeStart, rangeEnd }: {
|
|
122
|
+
rangeStart: any;
|
|
123
|
+
rangeEnd: any;
|
|
124
|
+
}): string;
|
|
125
|
+
concatInsetInputValue({ insetInputValue }: {
|
|
126
|
+
insetInputValue: InsetInputValue;
|
|
127
|
+
}): string;
|
|
59
128
|
}
|