@douyinfe/semi-foundation 2.6.0 → 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/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 +92 -15
- package/datePicker/inputFoundation.ts +133 -4
- package/datePicker/monthsGridFoundation.ts +4 -0
- package/datePicker/rtl.scss +8 -0
- package/datePicker/variables.scss +30 -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 +30 -7
- package/lib/cjs/datePicker/foundation.js +122 -9
- package/lib/cjs/datePicker/inputFoundation.d.ts +73 -3
- package/lib/cjs/datePicker/inputFoundation.js +196 -3
- 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/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/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 +30 -7
- package/lib/es/datePicker/foundation.js +120 -9
- package/lib/es/datePicker/inputFoundation.d.ts +73 -3
- package/lib/es/datePicker/inputFoundation.js +192 -4
- 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/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/tooltip/foundation.ts +8 -8
- package/treeSelect/foundation.ts +26 -19
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
/* eslint-disable max-len */
|
|
2
|
+
import { cloneDeep, isObject, set } from 'lodash';
|
|
3
|
+
|
|
2
4
|
import BaseFoundation, { DefaultAdapter } from '../base/foundation';
|
|
3
|
-
import { BaseValueType, ValidateStatus
|
|
5
|
+
import { BaseValueType, ValidateStatus } from './foundation';
|
|
4
6
|
import { formatDateValues } from './_utils/formatter';
|
|
5
7
|
import { getDefaultFormatTokenByType } from './_utils/getDefaultFormatToken';
|
|
8
|
+
import getInsetInputFormatToken from './_utils/getInsetInputFormatToken';
|
|
9
|
+
import getInsetInputValueFromInsetInputStr from './_utils/getInsetInputValueFromInsetInputStr';
|
|
10
|
+
import { strings } from './constants';
|
|
6
11
|
|
|
7
12
|
const KEY_CODE_ENTER = 'Enter';
|
|
8
13
|
const KEY_CODE_TAB = 'Tab';
|
|
@@ -10,6 +15,7 @@ const KEY_CODE_TAB = 'Tab';
|
|
|
10
15
|
|
|
11
16
|
export type Type = 'date' | 'dateRange' | 'year' | 'month' | 'dateTime' | 'dateTimeRange';
|
|
12
17
|
export type RangeType = 'rangeStart' | 'rangeEnd';
|
|
18
|
+
export type PanelType = 'left' | 'right';
|
|
13
19
|
|
|
14
20
|
export interface DateInputEventHandlerProps {
|
|
15
21
|
onClick?: (e: any) => void;
|
|
@@ -20,6 +26,7 @@ export interface DateInputEventHandlerProps {
|
|
|
20
26
|
onClear?: (e: any) => void;
|
|
21
27
|
onRangeInputClear?: (e: any) => void;
|
|
22
28
|
onRangeEndTabPress?: (e: any) => void;
|
|
29
|
+
onInsetInputChange?: (options: InsetInputChangeProps) => void;
|
|
23
30
|
}
|
|
24
31
|
|
|
25
32
|
export interface DateInputElementProps {
|
|
@@ -29,7 +36,7 @@ export interface DateInputElementProps {
|
|
|
29
36
|
|
|
30
37
|
export interface DateInputFoundationProps extends DateInputElementProps, DateInputEventHandlerProps {
|
|
31
38
|
[x: string]: any;
|
|
32
|
-
value?:
|
|
39
|
+
value?: BaseValueType[];
|
|
33
40
|
disabled?: boolean;
|
|
34
41
|
type?: Type;
|
|
35
42
|
showClear?: boolean;
|
|
@@ -39,12 +46,41 @@ export interface DateInputFoundationProps extends DateInputElementProps, DateInp
|
|
|
39
46
|
validateStatus?: ValidateStatus;
|
|
40
47
|
prefixCls?: string;
|
|
41
48
|
rangeSeparator?: string;
|
|
49
|
+
panelType?: PanelType;
|
|
50
|
+
insetInput?: boolean;
|
|
51
|
+
insetInputValue?: InsetInputValue;
|
|
52
|
+
density?: typeof strings.DENSITY_SET[number];
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export interface InsetInputValue {
|
|
56
|
+
monthLeft: {
|
|
57
|
+
dateInput: string;
|
|
58
|
+
timeInput: string;
|
|
59
|
+
},
|
|
60
|
+
monthRight: {
|
|
61
|
+
dateInput: string;
|
|
62
|
+
timeInput: string;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export interface InsetInputChangeFoundationProps {
|
|
67
|
+
value: string;
|
|
68
|
+
insetInputValue: InsetInputValue;
|
|
69
|
+
event: any;
|
|
70
|
+
valuePath: string;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export interface InsetInputChangeProps {
|
|
74
|
+
insetInputStr: string;
|
|
75
|
+
format: string;
|
|
76
|
+
insetInputValue: InsetInputValue;
|
|
42
77
|
}
|
|
43
78
|
|
|
44
79
|
export interface DateInputAdapter extends DefaultAdapter {
|
|
45
80
|
updateIsFocusing: (isFocusing: boolean) => void;
|
|
46
81
|
notifyClick: DateInputFoundationProps['onClick'];
|
|
47
82
|
notifyChange: DateInputFoundationProps['onChange'];
|
|
83
|
+
notifyInsetInputChange: DateInputFoundationProps['onInsetInputChange'];
|
|
48
84
|
notifyEnter: DateInputFoundationProps['onEnterPress'];
|
|
49
85
|
notifyBlur: DateInputFoundationProps['onBlur'];
|
|
50
86
|
notifyClear: DateInputFoundationProps['onClear'];
|
|
@@ -109,9 +145,9 @@ export default class InputFoundation extends BaseFoundation<DateInputAdapter> {
|
|
|
109
145
|
this._adapter.notifyRangeInputFocus(e, rangeType);
|
|
110
146
|
}
|
|
111
147
|
|
|
112
|
-
formatShowText(value: BaseValueType[]) {
|
|
148
|
+
formatShowText(value: BaseValueType[], customFormat?: string) {
|
|
113
149
|
const { type, dateFnsLocale, format, rangeSeparator } = this._adapter.getProps();
|
|
114
|
-
const formatToken = format || getDefaultFormatTokenByType(type);
|
|
150
|
+
const formatToken = customFormat || format || getDefaultFormatTokenByType(type);
|
|
115
151
|
let text = '';
|
|
116
152
|
switch (type) {
|
|
117
153
|
case 'date':
|
|
@@ -134,4 +170,97 @@ export default class InputFoundation extends BaseFoundation<DateInputAdapter> {
|
|
|
134
170
|
}
|
|
135
171
|
return text;
|
|
136
172
|
}
|
|
173
|
+
|
|
174
|
+
handleInsetInputChange(options: InsetInputChangeFoundationProps) {
|
|
175
|
+
const { value, valuePath, insetInputValue } = options;
|
|
176
|
+
const { format, type } = this._adapter.getProps();
|
|
177
|
+
const insetFormatToken = getInsetInputFormatToken({ type, format });
|
|
178
|
+
const newInsetInputValue = set(cloneDeep(insetInputValue), valuePath, value);
|
|
179
|
+
const newInputValue = this.concatInsetInputValue({ insetInputValue: newInsetInputValue });
|
|
180
|
+
this._adapter.notifyInsetInputChange({ insetInputValue: newInsetInputValue, format: insetFormatToken, insetInputStr: newInputValue });
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* 只有传入的 format 符合 formatReg 时,才会使用用户传入的 format
|
|
185
|
+
* 否则会使用默认的 format 作为 placeholder
|
|
186
|
+
*
|
|
187
|
+
* The format passed in by the user will be used only if the incoming format conforms to formatReg
|
|
188
|
+
* Otherwise the default format will be used as placeholder
|
|
189
|
+
*/
|
|
190
|
+
getInsetInputPlaceholder() {
|
|
191
|
+
const { type, format } = this._adapter.getProps();
|
|
192
|
+
const insetInputFormat = getInsetInputFormatToken({ type, format });
|
|
193
|
+
let datePlaceholder, timePlaceholder;
|
|
194
|
+
|
|
195
|
+
switch (type) {
|
|
196
|
+
case 'date':
|
|
197
|
+
case 'month':
|
|
198
|
+
case 'dateRange':
|
|
199
|
+
datePlaceholder = insetInputFormat;
|
|
200
|
+
break;
|
|
201
|
+
case 'dateTime':
|
|
202
|
+
case 'dateTimeRange':
|
|
203
|
+
[datePlaceholder, timePlaceholder] = insetInputFormat.split(' ');
|
|
204
|
+
break;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
return ({
|
|
208
|
+
datePlaceholder,
|
|
209
|
+
timePlaceholder,
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* 从当前日期值或 inputValue 中解析出 insetInputValue
|
|
215
|
+
*
|
|
216
|
+
* Parse out insetInputValue from current date value or inputValue
|
|
217
|
+
*/
|
|
218
|
+
getInsetInputValue({ value, insetInputValue } : { value: BaseValueType[]; insetInputValue: InsetInputValue }) {
|
|
219
|
+
const { type, rangeSeparator, format } = this._adapter.getProps();
|
|
220
|
+
|
|
221
|
+
let inputValueStr = '';
|
|
222
|
+
if (isObject(insetInputValue)) {
|
|
223
|
+
inputValueStr = this.concatInsetInputValue({ insetInputValue });
|
|
224
|
+
} else {
|
|
225
|
+
const insetInputFormat = getInsetInputFormatToken({ format, type });
|
|
226
|
+
inputValueStr = this.formatShowText(value, insetInputFormat);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
const newInsetInputValue = getInsetInputValueFromInsetInputStr({ inputValue: inputValueStr, type, rangeSeparator });
|
|
230
|
+
return newInsetInputValue;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
concatInsetDateAndTime({ date, time }) {
|
|
234
|
+
return `${date} ${time}`;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
concatInsetDateRange({ rangeStart, rangeEnd }) {
|
|
238
|
+
const { rangeSeparator } = this._adapter.getProps();
|
|
239
|
+
return `${rangeStart}${rangeSeparator}${rangeEnd}`;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
concatInsetInputValue({ insetInputValue }: { insetInputValue: InsetInputValue }) {
|
|
243
|
+
const { type } = this._adapter.getProps();
|
|
244
|
+
let inputValue = '';
|
|
245
|
+
|
|
246
|
+
switch (type) {
|
|
247
|
+
case 'date':
|
|
248
|
+
case 'month':
|
|
249
|
+
inputValue = insetInputValue.monthLeft.dateInput;
|
|
250
|
+
break;
|
|
251
|
+
case 'dateRange':
|
|
252
|
+
inputValue = this.concatInsetDateRange({ rangeStart: insetInputValue.monthLeft.dateInput, rangeEnd: insetInputValue.monthRight.dateInput });
|
|
253
|
+
break;
|
|
254
|
+
case 'dateTime':
|
|
255
|
+
inputValue = this.concatInsetDateAndTime({ date: insetInputValue.monthLeft.dateInput, time: insetInputValue.monthLeft.timeInput });
|
|
256
|
+
break;
|
|
257
|
+
case 'dateTimeRange':
|
|
258
|
+
const rangeStart = this.concatInsetDateAndTime({ date: insetInputValue.monthLeft.dateInput, time: insetInputValue.monthLeft.timeInput });
|
|
259
|
+
const rangeEnd = this.concatInsetDateAndTime({ date: insetInputValue.monthRight.dateInput, time: insetInputValue.monthRight.timeInput });
|
|
260
|
+
inputValue = this.concatInsetDateRange({ rangeStart, rangeEnd });
|
|
261
|
+
break;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
return inputValue;
|
|
265
|
+
}
|
|
137
266
|
}
|
|
@@ -86,6 +86,7 @@ export interface MonthsGridFoundationProps extends MonthsGridElementProps {
|
|
|
86
86
|
isAnotherPanelHasOpened?: (currentRangeInput: 'rangeStart' | 'rangeEnd') => boolean;
|
|
87
87
|
focusRecordsRef?: any;
|
|
88
88
|
triggerRender?: (props: Record<string, any>) => any;
|
|
89
|
+
insetInput: boolean;
|
|
89
90
|
}
|
|
90
91
|
|
|
91
92
|
export interface MonthInfo {
|
|
@@ -218,6 +219,7 @@ export default class MonthsGridFoundation extends BaseFoundation<MonthsGridAdapt
|
|
|
218
219
|
_initDatePickerFromValue(values: BaseValueType[], refreshPicker = true) {
|
|
219
220
|
const monthLeft = this.getState('monthLeft');
|
|
220
221
|
const newMonthLeft = { ...monthLeft };
|
|
222
|
+
// REMOVE:
|
|
221
223
|
this._adapter.updateMonthOnLeft(newMonthLeft);
|
|
222
224
|
const newSelected = new Set<string>();
|
|
223
225
|
if (!this._isMultiple()) {
|
|
@@ -230,6 +232,7 @@ export default class MonthsGridFoundation extends BaseFoundation<MonthsGridAdapt
|
|
|
230
232
|
if (refreshPicker) {
|
|
231
233
|
this.handleShowDateAndTime(strings.PANEL_TYPE_LEFT, values[0] || newMonthLeft.pickerDate);
|
|
232
234
|
} else {
|
|
235
|
+
// FIXME:
|
|
233
236
|
this.handleShowDateAndTime(strings.PANEL_TYPE_LEFT, newMonthLeft.pickerDate);
|
|
234
237
|
}
|
|
235
238
|
this._adapter.updateDaySelected(newSelected);
|
|
@@ -534,6 +537,7 @@ export default class MonthsGridFoundation extends BaseFoundation<MonthsGridAdapt
|
|
|
534
537
|
) {
|
|
535
538
|
const { multiple, disabledDate } = this.getProps();
|
|
536
539
|
const { selected: selectedSet, rangeStart, rangeEnd } = this.getStates();
|
|
540
|
+
// FIXME:
|
|
537
541
|
const includeRange = ['dateRange', 'dateTimeRange'].includes(type);
|
|
538
542
|
const options = { closePanel: false };
|
|
539
543
|
if (!multiple && !includeRange && selectedSet.size) {
|
package/datePicker/rtl.scss
CHANGED
|
@@ -181,5 +181,13 @@ $module: #{$prefix}-datepicker;
|
|
|
181
181
|
padding-left: $spacing-datepicker_footer_compact-paddintRight;
|
|
182
182
|
padding-right: auto;
|
|
183
183
|
}
|
|
184
|
+
|
|
185
|
+
.#{$module}-inset-input {
|
|
186
|
+
&-separator {
|
|
187
|
+
border-right: $width-datepicker-border solid $color-datepicker_border-bg-default;
|
|
188
|
+
border-left: 0;
|
|
189
|
+
transform: translateX(-50%);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
184
192
|
}
|
|
185
193
|
}
|
|
@@ -23,6 +23,14 @@ $width-datepicker_quick_control-borderRadius: var(--semi-border-radius-medium);
|
|
|
23
23
|
$width-datepicker_slot-border: 1px; // 日期星期分割线宽度
|
|
24
24
|
$width-datepicker_range_input-border: $border-thickness-control-focus;
|
|
25
25
|
$width-datepicker_day_main-border: 1px;
|
|
26
|
+
$height-datepicker_timeType_insetInput_yam: 100%; // 时间面板高度 - 内嵌输入框
|
|
27
|
+
$height-datepicker_timeType_insetInput_tpk: 100%; // 时间面板高度 - 内嵌输入框
|
|
28
|
+
$width-datepicker_insetInput_date_type_wrapper: 284px; // 日期类型内嵌输入框宽度
|
|
29
|
+
$width-datepicker_insetInput_date_range_type_wrapper: $width-datepicker_insetInput_date_type_wrapper * 2; // 范围选择内嵌输入框宽度
|
|
30
|
+
$width-datepicker_insetInput_month_type_wrapper: 204px; // 月份类型内嵌输入框宽度
|
|
31
|
+
$height-datepicker_insetInput_separator: 32px;
|
|
32
|
+
$height-datepicker_month_grid_yearType_insetInput: 312px;
|
|
33
|
+
$height-datepicker_month_grid_timeType_insetInput: 314px;
|
|
26
34
|
|
|
27
35
|
// Spacing
|
|
28
36
|
$spacing-datepicker_day-marginX: ($width-datepicker_day - $width-datepicker_day_main) / 2; // 日期格子水平外边距
|
|
@@ -53,6 +61,14 @@ $spacing-datepicker_range_input_suffix-paddingLeft: 8px;
|
|
|
53
61
|
$spacing-datepicker_range_input_suffix-paddingRight: 12px;
|
|
54
62
|
$spacing-datepicker_range_input_clearbtn-paddingLeft: 8px;
|
|
55
63
|
$spacing-datepicker_range_input_clearbtn-paddingRight: 12px;
|
|
64
|
+
$spacing-datepicker_navigation_insetInput-paddingY: 8px; // 年月切换 header 垂直内边距 - 内嵌输入框
|
|
65
|
+
$spacing-datepicker_insetInput_wrapper-margin: 8px;
|
|
66
|
+
$spacing-datepicker_insetInput_wrapper-paddingY: 12px;
|
|
67
|
+
$spacing-datepicker_insetInput_wrapper-paddingX: 16px;
|
|
68
|
+
$spacing-datepicker_insetInput_wrapper-paddingBottom: 0;
|
|
69
|
+
$spacing-datepicker_insetInput_separator-paddingY: 0;
|
|
70
|
+
$spacing-datepicker_insetInput_separator-paddingX: 4px;
|
|
71
|
+
|
|
56
72
|
|
|
57
73
|
// Color
|
|
58
74
|
$color-datepicker_panel-bg-default: var(--semi-color-bg-3); // 日期选择器背景颜色
|
|
@@ -118,6 +134,7 @@ $color-datepicker_range_input_inputWrapper-bg-default: transparent;
|
|
|
118
134
|
$color-datepicker_range_input_inputWrapper-bg-focus: var(--semi-color-fill-1);
|
|
119
135
|
$color-datepicker_range_input_separator-text-active: var(--semi-color-text-0);
|
|
120
136
|
$color-datepicker_day_main-border: var(--semi-color-primary-active);
|
|
137
|
+
$color-datepicker_insetInput_separator: var(--semi-color-text-3);
|
|
121
138
|
|
|
122
139
|
// Font
|
|
123
140
|
$font-datepicker_range_input_prefix_suffix_clearbtn-fontWeight: 600;
|
|
@@ -144,9 +161,17 @@ $radius-datepicker_range_input_inputWrapper: var(--semi-border-radius-small);
|
|
|
144
161
|
$height-datepicker_range_input-default: 32px;
|
|
145
162
|
$height-datepicker_range_input-small: 24px;
|
|
146
163
|
$height-datepicker_range_input-large: 40px;
|
|
164
|
+
$width-datepicker_insetInput_date_type_wrapper_compact: 216px;
|
|
165
|
+
$width-datepicker_insetInput_date_range_type_wrapper_compact: $width-datepicker_insetInput_date_type_wrapper_compact * 2;
|
|
166
|
+
$width-datepicker_insetInput_month_type_wrapper_compact: 195px;
|
|
167
|
+
$height-datepicker_insetInput_tpk_compact: 100%;
|
|
168
|
+
$height-datepicker_timeType_insetInput_yam_compact: 100%;
|
|
169
|
+
$height-datepicker_insetInput_wrapper_compact: 28px;
|
|
147
170
|
|
|
148
171
|
$lineHeight-datepicker_compact: 20px;
|
|
149
172
|
$lineHeight-datepicker_weekday_item_compact: 28px;
|
|
173
|
+
$height-datepicker_insetInput_compact: 26px;
|
|
174
|
+
$fontSize-datepicker_insetInput_compact-fontSize: 12px;
|
|
150
175
|
|
|
151
176
|
$spacing-datepicker_switch_compact-padding: 6px;
|
|
152
177
|
$spacing-datepicker_day_compact-margin: ($width-datepicker_day_compact - $width-datepicker_day_main_compact) / 2;
|
|
@@ -163,6 +188,11 @@ $spacing-datepicker_footer_compact-paddintBottom: 10px;
|
|
|
163
188
|
$spacing-datepicker_footer_compact-paddintRight: 8px;
|
|
164
189
|
$spacing-datepicker_scrolllist_shade_pre_compact-marginTop: -17px;
|
|
165
190
|
$spacing-datepicker_scrolllist_shade_post_compact-marginTop: 17px;
|
|
191
|
+
$spacing-datepicker_insetInput_wrapper_compact-margin: 4px;
|
|
192
|
+
$spacing-datepicker_insetInput_wrapper_compact-paddingY: 8px;
|
|
193
|
+
$spacing-datepicker_insetInput_wrapper_compact-paddingX: 8px;
|
|
194
|
+
$spacing-datepicker_insetInput_wrapper_compact-paddingBottom: 0;
|
|
195
|
+
$spacing-datepicker_insetInput_wrapper_rangeType_compact-paddingTop: 0;
|
|
166
196
|
|
|
167
197
|
// Radius
|
|
168
198
|
$radius-datepicker_range_input: var(--semi-border-radius-small);
|
|
@@ -8,7 +8,7 @@ import { BaseValueType } from '../foundation';
|
|
|
8
8
|
* @returns {string}
|
|
9
9
|
*/
|
|
10
10
|
export declare function formatDateValues(values: BaseValueType[], formatToken: string, { groupInnerSeparator, groupSize, groupSeparator, }: {
|
|
11
|
-
groupInnerSeparator?:
|
|
11
|
+
groupInnerSeparator?: string;
|
|
12
12
|
groupSize?: number;
|
|
13
|
-
groupSeparator?:
|
|
13
|
+
groupSeparator?: string;
|
|
14
14
|
}, locale: any): string;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { strings } from '../constants';
|
|
2
|
+
/**
|
|
3
|
+
* 获取 insetInput 输入框的 placeholder
|
|
4
|
+
* Get the placeholder of the insetInput input
|
|
5
|
+
*
|
|
6
|
+
* If type is time related, we only recognize the format like `dateFormat timeFormat`
|
|
7
|
+
* - 'yyyy-MM-dd HH:mm:ss' // ok
|
|
8
|
+
* - 'yyyy-MM-dd HH:mm:ss' // bad format
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* 'yyyy-MM-dd' => 'yyyy-MM-dd'
|
|
12
|
+
* 'yyyy-MM' => 'yyyy-MM'
|
|
13
|
+
* 'yyyy-MM-dd HH:mm:ss' => 'yyyy-MM-dd HH:mm:ss'
|
|
14
|
+
* 'yyyy-MM-dd HH:mm' => 'yyyy-MM-dd HH:mm'
|
|
15
|
+
* 'Pp' => 'yyyy-MM-dd'
|
|
16
|
+
*/
|
|
17
|
+
export default function getInsetInputFormatToken(options: {
|
|
18
|
+
format: string;
|
|
19
|
+
type: typeof strings.TYPE_SET[number];
|
|
20
|
+
}): string;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
|
|
4
|
+
|
|
5
|
+
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
|
6
|
+
|
|
7
|
+
_Object$defineProperty(exports, "__esModule", {
|
|
8
|
+
value: true
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
exports.default = getInsetInputFormatToken;
|
|
12
|
+
|
|
13
|
+
var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat"));
|
|
14
|
+
|
|
15
|
+
var _getDefaultFormatToken = require("./getDefaultFormatToken");
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* 获取 insetInput 输入框的 placeholder
|
|
19
|
+
* Get the placeholder of the insetInput input
|
|
20
|
+
*
|
|
21
|
+
* If type is time related, we only recognize the format like `dateFormat timeFormat`
|
|
22
|
+
* - 'yyyy-MM-dd HH:mm:ss' // ok
|
|
23
|
+
* - 'yyyy-MM-dd HH:mm:ss' // bad format
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* 'yyyy-MM-dd' => 'yyyy-MM-dd'
|
|
27
|
+
* 'yyyy-MM' => 'yyyy-MM'
|
|
28
|
+
* 'yyyy-MM-dd HH:mm:ss' => 'yyyy-MM-dd HH:mm:ss'
|
|
29
|
+
* 'yyyy-MM-dd HH:mm' => 'yyyy-MM-dd HH:mm'
|
|
30
|
+
* 'Pp' => 'yyyy-MM-dd'
|
|
31
|
+
*/
|
|
32
|
+
function getInsetInputFormatToken(options) {
|
|
33
|
+
var _context;
|
|
34
|
+
|
|
35
|
+
const {
|
|
36
|
+
format,
|
|
37
|
+
type
|
|
38
|
+
} = options;
|
|
39
|
+
const dateReg = /([yMd]{0,4}[^a-z\s]*[yMd]{0,4}[^a-z\s]*[yMd]{0,4})/i;
|
|
40
|
+
const dateTimeReg = /([yMd]{0,4}[^a-z\s]*[yMd]{0,4}[^a-z\s]*[yMd]{0,4}) (H{0,2}[^a-z\s]*m{0,2}[^a-z\s]*s{0,2})/i;
|
|
41
|
+
const defaultToken = (0, _getDefaultFormatToken.getDefaultFormatTokenByType)(type);
|
|
42
|
+
let insetInputFormat;
|
|
43
|
+
|
|
44
|
+
switch (type) {
|
|
45
|
+
case 'dateTime':
|
|
46
|
+
case 'dateTimeRange':
|
|
47
|
+
const dateTimeResult = dateTimeReg.exec(format);
|
|
48
|
+
insetInputFormat = dateTimeResult && dateTimeResult[1] && dateTimeResult[2] ? (0, _concat.default)(_context = "".concat(dateTimeResult[1], " ")).call(_context, dateTimeResult[2]) : defaultToken;
|
|
49
|
+
break;
|
|
50
|
+
|
|
51
|
+
case 'date':
|
|
52
|
+
case 'month':
|
|
53
|
+
case 'dateRange':
|
|
54
|
+
default:
|
|
55
|
+
const dateResult = dateReg.exec(format);
|
|
56
|
+
insetInputFormat = dateResult && dateResult[1] || defaultToken;
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return insetInputFormat;
|
|
61
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { strings } from '../constants';
|
|
2
|
+
/**
|
|
3
|
+
* 从 insetInputStr 字符串解析出 insetInputValue 对象
|
|
4
|
+
* Parse the insetInputValue object from the insetInputStr string
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```
|
|
8
|
+
* '2022-02-01' => { monthLeft: { dateInput: '2022-02-01' } }
|
|
9
|
+
* '2022-02-01 00:00:00' => { monthLeft: { dateInput: '2022-02-01', timeInput: '00:00:00' } }
|
|
10
|
+
* '2022-02-01 00:00:00 ~ 2022-02-15 00:00:00' => { monthLeft: { dateInput: '2022-02-01', timeInput: '00:00:00'}, monthRight: { dateInput: '2022-02-15', timeInput: '00:00:00' } }
|
|
11
|
+
*
|
|
12
|
+
* '2022-0' => { monthLeft: { dateInput: '2022-0' } }
|
|
13
|
+
* '2022-02-01 00:00:' => { monthLeft: { dateInput: '2022-02-01', timeInput: '00:00:' } }
|
|
14
|
+
* '2022-02-01 00:00:00 ~ ' => { monthLeft: { dateInput: '2022-02-01', timeInput: '00:00:00'}, monthRight: { dateInput: '', timeInput: '' } }
|
|
15
|
+
* ' ~ 2022-02-15 00:00:00' => { monthLeft: { dateInput: '', timeInput: '' }, monthRight: { dateInput: '2022-02-15', timeInput: '00:00:00' } }
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export default function getInsetInputValueFromInsetInputStr(options: {
|
|
19
|
+
inputValue: string;
|
|
20
|
+
rangeSeparator: string;
|
|
21
|
+
type: typeof strings.TYPE_SET[number];
|
|
22
|
+
}): {
|
|
23
|
+
monthLeft: {
|
|
24
|
+
dateInput: string;
|
|
25
|
+
timeInput: string;
|
|
26
|
+
};
|
|
27
|
+
monthRight: {
|
|
28
|
+
dateInput: string;
|
|
29
|
+
timeInput: string;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
|
|
4
|
+
|
|
5
|
+
_Object$defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
exports.default = getInsetInputValueFromInsetInputStr;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* 从 insetInputStr 字符串解析出 insetInputValue 对象
|
|
13
|
+
* Parse the insetInputValue object from the insetInputStr string
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```
|
|
17
|
+
* '2022-02-01' => { monthLeft: { dateInput: '2022-02-01' } }
|
|
18
|
+
* '2022-02-01 00:00:00' => { monthLeft: { dateInput: '2022-02-01', timeInput: '00:00:00' } }
|
|
19
|
+
* '2022-02-01 00:00:00 ~ 2022-02-15 00:00:00' => { monthLeft: { dateInput: '2022-02-01', timeInput: '00:00:00'}, monthRight: { dateInput: '2022-02-15', timeInput: '00:00:00' } }
|
|
20
|
+
*
|
|
21
|
+
* '2022-0' => { monthLeft: { dateInput: '2022-0' } }
|
|
22
|
+
* '2022-02-01 00:00:' => { monthLeft: { dateInput: '2022-02-01', timeInput: '00:00:' } }
|
|
23
|
+
* '2022-02-01 00:00:00 ~ ' => { monthLeft: { dateInput: '2022-02-01', timeInput: '00:00:00'}, monthRight: { dateInput: '', timeInput: '' } }
|
|
24
|
+
* ' ~ 2022-02-15 00:00:00' => { monthLeft: { dateInput: '', timeInput: '' }, monthRight: { dateInput: '2022-02-15', timeInput: '00:00:00' } }
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
function getInsetInputValueFromInsetInputStr(options) {
|
|
28
|
+
const timeSeparator = ' ';
|
|
29
|
+
const {
|
|
30
|
+
inputValue = '',
|
|
31
|
+
rangeSeparator,
|
|
32
|
+
type
|
|
33
|
+
} = options;
|
|
34
|
+
let leftDateInput, leftTimeInput, rightDateInput, rightTimeInput;
|
|
35
|
+
const insetInputValue = {
|
|
36
|
+
monthLeft: {
|
|
37
|
+
dateInput: '',
|
|
38
|
+
timeInput: ''
|
|
39
|
+
},
|
|
40
|
+
monthRight: {
|
|
41
|
+
dateInput: '',
|
|
42
|
+
timeInput: ''
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
switch (type) {
|
|
47
|
+
case 'date':
|
|
48
|
+
case 'month':
|
|
49
|
+
insetInputValue.monthLeft.dateInput = inputValue;
|
|
50
|
+
break;
|
|
51
|
+
|
|
52
|
+
case 'dateRange':
|
|
53
|
+
[leftDateInput = '', rightDateInput = ''] = inputValue.split(rangeSeparator);
|
|
54
|
+
insetInputValue.monthLeft.dateInput = leftDateInput;
|
|
55
|
+
insetInputValue.monthRight.dateInput = rightDateInput;
|
|
56
|
+
break;
|
|
57
|
+
|
|
58
|
+
case 'dateTime':
|
|
59
|
+
[leftDateInput = '', leftTimeInput = ''] = inputValue.split(timeSeparator);
|
|
60
|
+
insetInputValue.monthLeft.dateInput = leftDateInput;
|
|
61
|
+
insetInputValue.monthLeft.timeInput = leftTimeInput;
|
|
62
|
+
break;
|
|
63
|
+
|
|
64
|
+
case 'dateTimeRange':
|
|
65
|
+
const [leftInput = '', rightInput = ''] = inputValue.split(rangeSeparator);
|
|
66
|
+
[leftDateInput = '', leftTimeInput = ''] = leftInput.split(timeSeparator);
|
|
67
|
+
[rightDateInput = '', rightTimeInput = ''] = rightInput.split(timeSeparator);
|
|
68
|
+
insetInputValue.monthLeft.dateInput = leftDateInput;
|
|
69
|
+
insetInputValue.monthLeft.timeInput = leftTimeInput;
|
|
70
|
+
insetInputValue.monthRight.dateInput = rightDateInput;
|
|
71
|
+
insetInputValue.monthRight.timeInput = rightTimeInput;
|
|
72
|
+
break;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return insetInputValue;
|
|
76
|
+
}
|
|
@@ -41,10 +41,12 @@ declare const strings: {
|
|
|
41
41
|
readonly PANEL_TYPE_RIGHT: "right";
|
|
42
42
|
readonly STATUS: readonly ["default", "error", "warning", "success"];
|
|
43
43
|
readonly POSITION_SET: readonly ["top", "topLeft", "topRight", "left", "leftTop", "leftBottom", "right", "rightTop", "rightBottom", "bottom", "bottomLeft", "bottomRight", "leftTopOver", "rightTopOver"];
|
|
44
|
+
readonly POSITION_INLINE_INPUT: "leftTopOver";
|
|
44
45
|
};
|
|
45
46
|
declare const numbers: {
|
|
46
47
|
readonly WEEK_START_ON: 0;
|
|
47
48
|
readonly WEEK_HEIGHT: 36;
|
|
48
49
|
readonly SPACING: number;
|
|
50
|
+
readonly SPACING_INSET_INPUT: 1;
|
|
49
51
|
};
|
|
50
52
|
export { cssClasses, strings, numbers };
|
|
@@ -63,13 +63,14 @@ const strings = (0, _assign.default)({
|
|
|
63
63
|
PANEL_TYPE_LEFT: 'left',
|
|
64
64
|
PANEL_TYPE_RIGHT: 'right',
|
|
65
65
|
STATUS: _constants.VALIDATE_STATUS,
|
|
66
|
-
POSITION_SET: _constants2.strings.POSITION_SET
|
|
66
|
+
POSITION_SET: _constants2.strings.POSITION_SET,
|
|
67
|
+
POSITION_INLINE_INPUT: 'leftTopOver'
|
|
67
68
|
}, formatToken);
|
|
68
69
|
exports.strings = strings;
|
|
69
70
|
const numbers = {
|
|
70
71
|
WEEK_START_ON: 0,
|
|
71
72
|
WEEK_HEIGHT: 36,
|
|
72
|
-
SPACING: _constants2.numbers.SPACING
|
|
73
|
-
|
|
73
|
+
SPACING: _constants2.numbers.SPACING,
|
|
74
|
+
SPACING_INSET_INPUT: 1
|
|
74
75
|
};
|
|
75
76
|
exports.numbers = numbers;
|