@douyinfe/semi-foundation 2.2.0-beta.0 → 2.2.2
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/parser.ts +4 -3
- package/datePicker/datePicker.scss +11 -0
- package/datePicker/foundation.ts +33 -15
- package/datePicker/inputFoundation.ts +2 -0
- package/datePicker/monthsGridFoundation.ts +10 -3
- package/datePicker/rtl.scss +15 -1
- package/datePicker/variables.scss +2 -0
- package/gulpfile.js +3 -1
- package/inputNumber/foundation.ts +3 -2
- package/lib/cjs/datePicker/_utils/parser.d.ts +6 -1
- package/lib/cjs/datePicker/_utils/parser.js +3 -1
- package/lib/cjs/datePicker/datePicker.css +26 -3
- package/lib/cjs/datePicker/datePicker.scss +11 -0
- package/lib/cjs/datePicker/foundation.d.ts +6 -3
- package/lib/cjs/datePicker/foundation.js +42 -18
- package/lib/cjs/datePicker/inputFoundation.js +3 -0
- package/lib/cjs/datePicker/monthsGridFoundation.d.ts +1 -0
- package/lib/cjs/datePicker/monthsGridFoundation.js +16 -3
- package/lib/cjs/datePicker/rtl.scss +15 -1
- package/lib/cjs/datePicker/variables.scss +2 -0
- package/lib/cjs/inputNumber/foundation.d.ts +2 -2
- package/lib/cjs/inputNumber/foundation.js +3 -1
- package/lib/cjs/navigation/navigation.css +0 -1
- package/lib/cjs/notification/notification.css +8 -4
- package/lib/cjs/notification/notification.scss +9 -5
- package/lib/cjs/notification/variables.scss +1 -0
- package/lib/cjs/select/foundation.d.ts +10 -1
- package/lib/cjs/select/foundation.js +11 -9
- package/lib/cjs/table/table.css +0 -2
- package/lib/cjs/table/table.scss +0 -2
- package/lib/es/datePicker/_utils/parser.d.ts +6 -1
- package/lib/es/datePicker/_utils/parser.js +3 -1
- package/lib/es/datePicker/datePicker.css +26 -3
- package/lib/es/datePicker/datePicker.scss +11 -0
- package/lib/es/datePicker/foundation.d.ts +6 -3
- package/lib/es/datePicker/foundation.js +42 -18
- package/lib/es/datePicker/inputFoundation.js +3 -0
- package/lib/es/datePicker/monthsGridFoundation.d.ts +1 -0
- package/lib/es/datePicker/monthsGridFoundation.js +15 -3
- package/lib/es/datePicker/rtl.scss +15 -1
- package/lib/es/datePicker/variables.scss +2 -0
- package/lib/es/inputNumber/foundation.d.ts +2 -2
- package/lib/es/inputNumber/foundation.js +3 -1
- package/lib/es/navigation/navigation.css +0 -1
- package/lib/es/notification/notification.css +8 -4
- package/lib/es/notification/notification.scss +9 -5
- package/lib/es/notification/variables.scss +1 -0
- package/lib/es/select/foundation.d.ts +10 -1
- package/lib/es/select/foundation.js +12 -9
- package/lib/es/table/table.css +0 -2
- package/lib/es/table/table.scss +0 -2
- package/notification/notification.scss +9 -5
- package/notification/variables.scss +1 -0
- package/package.json +4 -4
- package/select/foundation.ts +11 -9
- package/table/table.scss +0 -2
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @file
|
|
3
3
|
* Various date-related analysis methods
|
|
4
4
|
*/
|
|
5
|
-
import { isValid, parseISO, parse } from 'date-fns';
|
|
5
|
+
import { isValid, parseISO, parse, Locale } from 'date-fns';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Parsing value to Date object
|
|
@@ -11,7 +11,7 @@ export function compatiableParse(
|
|
|
11
11
|
value: string,
|
|
12
12
|
formatToken?: string,
|
|
13
13
|
baseDate?: Date,
|
|
14
|
-
locale?:
|
|
14
|
+
locale?: Locale
|
|
15
15
|
): Date | null {
|
|
16
16
|
let result = null;
|
|
17
17
|
if (value) {
|
|
@@ -25,7 +25,8 @@ export function compatiableParse(
|
|
|
25
25
|
if (!isValid(result)) {
|
|
26
26
|
result = new Date(Date.parse(value));
|
|
27
27
|
}
|
|
28
|
-
|
|
28
|
+
const yearInvalid = isValid(result) && String(result.getFullYear()).length > 4;
|
|
29
|
+
if (!isValid(result) || yearInvalid) {
|
|
29
30
|
result = null;
|
|
30
31
|
}
|
|
31
32
|
}
|
|
@@ -140,6 +140,17 @@ $module: #{$prefix}-datepicker;
|
|
|
140
140
|
padding-bottom: $spacing-datepicker_footer-paddingBottom;
|
|
141
141
|
text-align: right;
|
|
142
142
|
background-color: $color-datepicker_footer-bg-default;
|
|
143
|
+
|
|
144
|
+
.#{$prefix}-button {
|
|
145
|
+
// cancel button
|
|
146
|
+
&:first-of-type {
|
|
147
|
+
margin-right: $spacing-datepicker_footer_cancel_button-marginRight;
|
|
148
|
+
}
|
|
149
|
+
// confirm button
|
|
150
|
+
&:nth-of-type(2) {
|
|
151
|
+
margin-right: $spacing-datepicker_footer_confirm_button-marginRight;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
143
154
|
}
|
|
144
155
|
|
|
145
156
|
// 年月选择
|
package/datePicker/foundation.ts
CHANGED
|
@@ -323,10 +323,8 @@ export default class DatePickerFoundation extends BaseFoundation<DatePickerAdapt
|
|
|
323
323
|
* 2. set cachedSelectedValue using given dates(in needConfirm mode)
|
|
324
324
|
* - directly closePanel without click confirm will set cachedSelectedValue to state value
|
|
325
325
|
* - select one date(which means that the selection value is incomplete) and click confirm also set cachedSelectedValue to state value
|
|
326
|
-
* @param {String} inputValue
|
|
327
|
-
* @param {Date[]} dates
|
|
328
326
|
*/
|
|
329
|
-
rangeTypeSideEffectsWhenClosePanel(inputValue: string,
|
|
327
|
+
rangeTypeSideEffectsWhenClosePanel(inputValue: string, willUpdateDates: Date[]) {
|
|
330
328
|
if (this._isRangeType()) {
|
|
331
329
|
this._adapter.setRangeInputFocus(false);
|
|
332
330
|
/**
|
|
@@ -334,11 +332,29 @@ export default class DatePickerFoundation extends BaseFoundation<DatePickerAdapt
|
|
|
334
332
|
* when inputValue is null, picker value will back to last selected value
|
|
335
333
|
*/
|
|
336
334
|
this.handleInputBlur(inputValue);
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
335
|
+
this.resetCachedSelectedValue(willUpdateDates);
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
/**
|
|
340
|
+
* clear input value when selected date is not confirmed
|
|
341
|
+
*/
|
|
342
|
+
needConfirmSideEffectsWhenClosePanel(willUpdateDates: Date[] | null | undefined) {
|
|
343
|
+
if (this._adapter.needConfirm() && !this._isRangeType()) {
|
|
344
|
+
/**
|
|
345
|
+
* if `null` input element will show `cachedSelectedValue` formatted value(format in DateInput render)
|
|
346
|
+
* if `` input element will show `` directly
|
|
347
|
+
*/
|
|
348
|
+
this._adapter.updateInputValue(null);
|
|
349
|
+
this.resetCachedSelectedValue(willUpdateDates);
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
resetCachedSelectedValue(willUpdateDates?: Date[]) {
|
|
354
|
+
const { value, cachedSelectedValue } = this._adapter.getStates();
|
|
355
|
+
const newCachedSelectedValue = Array.isArray(willUpdateDates) ? willUpdateDates : value;
|
|
356
|
+
if (!isEqual(newCachedSelectedValue, cachedSelectedValue)) {
|
|
357
|
+
this._adapter.updateCachedSelectedValue(newCachedSelectedValue);
|
|
342
358
|
}
|
|
343
359
|
}
|
|
344
360
|
|
|
@@ -354,13 +370,16 @@ export default class DatePickerFoundation extends BaseFoundation<DatePickerAdapt
|
|
|
354
370
|
* @param {String} inputValue
|
|
355
371
|
* @param {Date[]} dates
|
|
356
372
|
*/
|
|
357
|
-
closePanel(e?: any, inputValue: string = null, dates
|
|
373
|
+
closePanel(e?: any, inputValue: string = null, dates?: Date[]) {
|
|
374
|
+
const { value, cachedSelectedValue } = this._adapter.getStates();
|
|
375
|
+
const willUpdateDates = isNullOrUndefined(dates) ? this._adapter.needConfirm() ? value : cachedSelectedValue : dates;
|
|
358
376
|
if (!this._isControlledComponent('open')) {
|
|
359
377
|
this._adapter.togglePanel(false);
|
|
360
378
|
this._adapter.unregisterClickOutSide();
|
|
361
379
|
}
|
|
362
380
|
// range type picker, closing panel requires the following side effects
|
|
363
|
-
this.rangeTypeSideEffectsWhenClosePanel(inputValue,
|
|
381
|
+
this.rangeTypeSideEffectsWhenClosePanel(inputValue, willUpdateDates as Date[]);
|
|
382
|
+
this.needConfirmSideEffectsWhenClosePanel(willUpdateDates as Date[]);
|
|
364
383
|
this._adapter.notifyOpenChange(false);
|
|
365
384
|
this._adapter.notifyBlur(e);
|
|
366
385
|
}
|
|
@@ -416,7 +435,8 @@ export default class DatePickerFoundation extends BaseFoundation<DatePickerAdapt
|
|
|
416
435
|
if (parsedResult && parsedResult.length) {
|
|
417
436
|
this._updateValueAndInput(parsedResult, input === '');
|
|
418
437
|
} else if (input === '') {
|
|
419
|
-
|
|
438
|
+
// if clear input, set input to `''`
|
|
439
|
+
this._updateValueAndInput('' as any, true, '');
|
|
420
440
|
} else {
|
|
421
441
|
this._updateValueAndInput(stateValue);
|
|
422
442
|
}
|
|
@@ -725,7 +745,7 @@ export default class DatePickerFoundation extends BaseFoundation<DatePickerAdapt
|
|
|
725
745
|
let inputValue;
|
|
726
746
|
if (!this._someDateDisabled(changedDates)) {
|
|
727
747
|
inputValue = this._isMultiple() ? this.formatMultipleDates(dates) : this.formatDates(dates);
|
|
728
|
-
const isRangeTypeAndInputIncomplete = this._isRangeType() && (
|
|
748
|
+
const isRangeTypeAndInputIncomplete = this._isRangeType() && !this._isRangeValueComplete(dates);
|
|
729
749
|
/**
|
|
730
750
|
* If the input is incomplete when under control, the notifyChange is not triggered because
|
|
731
751
|
* You need to update the value of the input box, otherwise there will be a problem that a date is selected but the input box does not show the date #1357
|
|
@@ -1004,11 +1024,9 @@ export default class DatePickerFoundation extends BaseFoundation<DatePickerAdapt
|
|
|
1004
1024
|
};
|
|
1005
1025
|
|
|
1006
1026
|
_isRangeValueComplete = (value: Date[] | Date) => {
|
|
1007
|
-
let result =
|
|
1027
|
+
let result = false;
|
|
1008
1028
|
if (Array.isArray(value)) {
|
|
1009
1029
|
result = !value.some(date => isNullOrUndefined(date));
|
|
1010
|
-
} else {
|
|
1011
|
-
result = false;
|
|
1012
1030
|
}
|
|
1013
1031
|
return result;
|
|
1014
1032
|
};
|
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
import { isBefore, isValidDate, getDefaultFormatToken, getFullDateOffset } from './_utils/index';
|
|
17
17
|
import { formatFullDate, WeekStartNumber } from './_utils/getMonthTable';
|
|
18
18
|
import { compatiableParse } from './_utils/parser';
|
|
19
|
-
import { includes, isSet, isEqual } from 'lodash';
|
|
19
|
+
import { includes, isSet, isEqual, isFunction } from 'lodash';
|
|
20
20
|
import { zonedTimeToUtc } from '../utils/date-fns-extra';
|
|
21
21
|
import { getDefaultFormatTokenByType } from './_utils/getDefaultFormatToken';
|
|
22
22
|
import isNullOrUndefined from '../utils/isNullOrUndefined';
|
|
@@ -85,6 +85,7 @@ export interface MonthsGridFoundationProps extends MonthsGridElementProps {
|
|
|
85
85
|
setRangeInputFocus?: (rangeInputFocus: 'rangeStart' | 'rangeEnd') => void;
|
|
86
86
|
isAnotherPanelHasOpened?: (currentRangeInput: 'rangeStart' | 'rangeEnd') => boolean;
|
|
87
87
|
focusRecordsRef?: any;
|
|
88
|
+
triggerRender?: (props: Record<string, any>) => any;
|
|
88
89
|
}
|
|
89
90
|
|
|
90
91
|
export interface MonthInfo {
|
|
@@ -636,7 +637,7 @@ export default class MonthsGridFoundation extends BaseFoundation<MonthsGridAdapt
|
|
|
636
637
|
|
|
637
638
|
handleRangeSelected(day: MonthDayInfo) {
|
|
638
639
|
let { rangeStart, rangeEnd } = this.getStates();
|
|
639
|
-
const { startDateOffset, endDateOffset, type, dateFnsLocale, rangeInputFocus } = this.getProps();
|
|
640
|
+
const { startDateOffset, endDateOffset, type, dateFnsLocale, rangeInputFocus, triggerRender } = this._adapter.getProps();
|
|
640
641
|
const { fullDate } = day;
|
|
641
642
|
let rangeStartReset = false;
|
|
642
643
|
let rangeEndReset = false;
|
|
@@ -712,7 +713,13 @@ export default class MonthsGridFoundation extends BaseFoundation<MonthsGridAdapt
|
|
|
712
713
|
date = [start, end];
|
|
713
714
|
}
|
|
714
715
|
}
|
|
715
|
-
|
|
716
|
+
/**
|
|
717
|
+
* no need to check focus then
|
|
718
|
+
* - dateRange and isDateRangeAndHasOffset
|
|
719
|
+
* - dateRange and triggerRender
|
|
720
|
+
*/
|
|
721
|
+
const needCheckFocusRecord = !(type === 'dateRange' && (isDateRangeAndHasOffset || isFunction(triggerRender)));
|
|
722
|
+
this._adapter.notifySelectedChange(date, { needCheckFocusRecord });
|
|
716
723
|
}
|
|
717
724
|
}
|
|
718
725
|
|
package/datePicker/rtl.scss
CHANGED
|
@@ -9,6 +9,18 @@ $module: #{$prefix}-datepicker;
|
|
|
9
9
|
padding-right: 0;
|
|
10
10
|
padding-left: $spacing-datepicker_footer-paddingRight;
|
|
11
11
|
text-align: left;
|
|
12
|
+
|
|
13
|
+
.#{$prefix}-button {
|
|
14
|
+
&:first-of-type {
|
|
15
|
+
margin-left: 0;
|
|
16
|
+
margin-right: 0;
|
|
17
|
+
}
|
|
18
|
+
// confirm button
|
|
19
|
+
&:nth-of-type(2) {
|
|
20
|
+
margin-right: $spacing-datepicker_footer_cancel_button-marginRight;
|
|
21
|
+
margin-left: 0;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
12
24
|
}
|
|
13
25
|
|
|
14
26
|
&-day {
|
|
@@ -66,7 +78,9 @@ $module: #{$prefix}-datepicker;
|
|
|
66
78
|
&-yam {
|
|
67
79
|
// rtl 对箭头进行翻转
|
|
68
80
|
.#{$prefix}-icon-chevron_left,
|
|
69
|
-
.#{$prefix}-icon-chevron_right
|
|
81
|
+
.#{$prefix}-icon-chevron_right,
|
|
82
|
+
.#{$prefix}-icon-double_chevron_left,
|
|
83
|
+
.#{$prefix}-icon-double_chevron_right {
|
|
70
84
|
transform: scaleX(-1);
|
|
71
85
|
}
|
|
72
86
|
}
|
|
@@ -33,6 +33,8 @@ $spacing-datepicker_scrolllist_body-padding: 0; // 时间选择滚动菜单内
|
|
|
33
33
|
$spacing-datepicker_footer-paddingTop: 10px; // 确认选择 footer 顶部内边距
|
|
34
34
|
$spacing-datepicker_footer-paddingBottom: 10px; // 确认选择 footer 底部内边距
|
|
35
35
|
$spacing-datepicker_footer-paddingRight: 8px; // 确认选择 footer 右侧内边距
|
|
36
|
+
$spacing-datepicker_footer_cancel_button-marginRight: 12px; // 确认选择 footer 取消按钮右外边距
|
|
37
|
+
$spacing-datepicker_footer_confirm_button-marginRight: 8px; // 确认选择 footer 确认按钮右外边距
|
|
36
38
|
$spacing-datepicker_navigation-paddingY: $spacing-base-tight; // 年月切换 header 垂直内边距
|
|
37
39
|
$spacing-datepicker_navigation-paddingX: $spacing-base; // 年月切换 header 水平内边距
|
|
38
40
|
$spacing-datepicker_month-padding: $spacing-base;
|
package/gulpfile.js
CHANGED
|
@@ -52,7 +52,9 @@ gulp.task('compileScss', function compileScss() {
|
|
|
52
52
|
cb(null, chunk);
|
|
53
53
|
}
|
|
54
54
|
))
|
|
55
|
-
.pipe(sass(
|
|
55
|
+
.pipe(sass({
|
|
56
|
+
charset: false
|
|
57
|
+
}).on('error', sass.logError))
|
|
56
58
|
.pipe(gulp.dest('lib/es'))
|
|
57
59
|
.pipe(gulp.dest('lib/cjs'));
|
|
58
60
|
});
|
|
@@ -126,6 +126,7 @@ class InputNumberFoundation extends BaseFoundation<InputNumberAdapter> {
|
|
|
126
126
|
}
|
|
127
127
|
this._adapter.recordCursorPosition();
|
|
128
128
|
this._adapter.setFocusing(true, null);
|
|
129
|
+
this._adapter.setClickUpOrDown(false);
|
|
129
130
|
this._adapter.notifyFocus(e);
|
|
130
131
|
}
|
|
131
132
|
|
|
@@ -425,11 +426,11 @@ class InputNumberFoundation extends BaseFoundation<InputNumberAdapter> {
|
|
|
425
426
|
|
|
426
427
|
/**
|
|
427
428
|
* format number to string
|
|
428
|
-
* @param {number} value
|
|
429
|
+
* @param {string|number} value
|
|
429
430
|
* @param {boolean} needAdjustPrec
|
|
430
431
|
* @returns {string}
|
|
431
432
|
*/
|
|
432
|
-
doFormat(value = 0, needAdjustPrec = true): string {
|
|
433
|
+
doFormat(value: string | number = 0, needAdjustPrec = true): string {
|
|
433
434
|
// if (typeof value === 'string') {
|
|
434
435
|
// return value;
|
|
435
436
|
// }
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file
|
|
3
|
+
* Various date-related analysis methods
|
|
4
|
+
*/
|
|
5
|
+
import { Locale } from 'date-fns';
|
|
1
6
|
/**
|
|
2
7
|
* Parsing value to Date object
|
|
3
8
|
*/
|
|
4
|
-
export declare function compatiableParse(value: string, formatToken?: string, baseDate?: Date, locale?:
|
|
9
|
+
export declare function compatiableParse(value: string, formatToken?: string, baseDate?: Date, locale?: Locale): Date | null;
|
|
@@ -37,7 +37,9 @@ function compatiableParse(value, formatToken, baseDate, locale) {
|
|
|
37
37
|
result = new Date(Date.parse(value));
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
|
|
40
|
+
const yearInvalid = (0, _dateFns.isValid)(result) && String(result.getFullYear()).length > 4;
|
|
41
|
+
|
|
42
|
+
if (!(0, _dateFns.isValid)(result) || yearInvalid) {
|
|
41
43
|
result = null;
|
|
42
44
|
}
|
|
43
45
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
@charset "UTF-8";
|
|
2
1
|
/* shadow */
|
|
3
2
|
/* sizing */
|
|
4
3
|
/* spacing */
|
|
@@ -99,6 +98,12 @@
|
|
|
99
98
|
text-align: right;
|
|
100
99
|
background-color: var(--semi-color-fill-0);
|
|
101
100
|
}
|
|
101
|
+
.semi-datepicker-footer .semi-button:first-of-type {
|
|
102
|
+
margin-right: 12px;
|
|
103
|
+
}
|
|
104
|
+
.semi-datepicker-footer .semi-button:nth-of-type(2) {
|
|
105
|
+
margin-right: 8px;
|
|
106
|
+
}
|
|
102
107
|
.semi-datepicker-yam {
|
|
103
108
|
position: absolute;
|
|
104
109
|
top: 0;
|
|
@@ -706,6 +711,16 @@
|
|
|
706
711
|
padding-left: 8px;
|
|
707
712
|
text-align: left;
|
|
708
713
|
}
|
|
714
|
+
.semi-rtl .semi-datepicker-footer .semi-button:first-of-type,
|
|
715
|
+
.semi-portal-rtl .semi-datepicker-footer .semi-button:first-of-type {
|
|
716
|
+
margin-left: 0;
|
|
717
|
+
margin-right: 0;
|
|
718
|
+
}
|
|
719
|
+
.semi-rtl .semi-datepicker-footer .semi-button:nth-of-type(2),
|
|
720
|
+
.semi-portal-rtl .semi-datepicker-footer .semi-button:nth-of-type(2) {
|
|
721
|
+
margin-right: 12px;
|
|
722
|
+
margin-left: 0;
|
|
723
|
+
}
|
|
709
724
|
.semi-rtl .semi-datepicker-day-offsetrange-start .semi-datepicker-day-main,
|
|
710
725
|
.semi-portal-rtl .semi-datepicker-day-offsetrange-start .semi-datepicker-day-main {
|
|
711
726
|
border-radius: 0 var(--semi-border-radius-small) var(--semi-border-radius-small) 0;
|
|
@@ -741,12 +756,20 @@
|
|
|
741
756
|
margin-right: 8px;
|
|
742
757
|
}
|
|
743
758
|
.semi-rtl .semi-datepicker-navigation .semi-icon-chevron_left,
|
|
744
|
-
.semi-rtl .semi-datepicker-navigation .semi-icon-chevron_right,
|
|
759
|
+
.semi-rtl .semi-datepicker-navigation .semi-icon-chevron_right,
|
|
760
|
+
.semi-rtl .semi-datepicker-navigation .semi-icon-double_chevron_left,
|
|
761
|
+
.semi-rtl .semi-datepicker-navigation .semi-icon-double_chevron_right, .semi-rtl .semi-datepicker-yam .semi-icon-chevron_left,
|
|
745
762
|
.semi-rtl .semi-datepicker-yam .semi-icon-chevron_right,
|
|
763
|
+
.semi-rtl .semi-datepicker-yam .semi-icon-double_chevron_left,
|
|
764
|
+
.semi-rtl .semi-datepicker-yam .semi-icon-double_chevron_right,
|
|
746
765
|
.semi-portal-rtl .semi-datepicker-navigation .semi-icon-chevron_left,
|
|
747
766
|
.semi-portal-rtl .semi-datepicker-navigation .semi-icon-chevron_right,
|
|
767
|
+
.semi-portal-rtl .semi-datepicker-navigation .semi-icon-double_chevron_left,
|
|
768
|
+
.semi-portal-rtl .semi-datepicker-navigation .semi-icon-double_chevron_right,
|
|
748
769
|
.semi-portal-rtl .semi-datepicker-yam .semi-icon-chevron_left,
|
|
749
|
-
.semi-portal-rtl .semi-datepicker-yam .semi-icon-chevron_right
|
|
770
|
+
.semi-portal-rtl .semi-datepicker-yam .semi-icon-chevron_right,
|
|
771
|
+
.semi-portal-rtl .semi-datepicker-yam .semi-icon-double_chevron_left,
|
|
772
|
+
.semi-portal-rtl .semi-datepicker-yam .semi-icon-double_chevron_right {
|
|
750
773
|
transform: scaleX(-1);
|
|
751
774
|
}
|
|
752
775
|
.semi-rtl .semi-datepicker-range-input-prefix,
|
|
@@ -140,6 +140,17 @@ $module: #{$prefix}-datepicker;
|
|
|
140
140
|
padding-bottom: $spacing-datepicker_footer-paddingBottom;
|
|
141
141
|
text-align: right;
|
|
142
142
|
background-color: $color-datepicker_footer-bg-default;
|
|
143
|
+
|
|
144
|
+
.#{$prefix}-button {
|
|
145
|
+
// cancel button
|
|
146
|
+
&:first-of-type {
|
|
147
|
+
margin-right: $spacing-datepicker_footer_cancel_button-marginRight;
|
|
148
|
+
}
|
|
149
|
+
// confirm button
|
|
150
|
+
&:nth-of-type(2) {
|
|
151
|
+
margin-right: $spacing-datepicker_footer_confirm_button-marginRight;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
143
154
|
}
|
|
144
155
|
|
|
145
156
|
// 年月选择
|
|
@@ -201,10 +201,13 @@ export default class DatePickerFoundation extends BaseFoundation<DatePickerAdapt
|
|
|
201
201
|
* 2. set cachedSelectedValue using given dates(in needConfirm mode)
|
|
202
202
|
* - directly closePanel without click confirm will set cachedSelectedValue to state value
|
|
203
203
|
* - select one date(which means that the selection value is incomplete) and click confirm also set cachedSelectedValue to state value
|
|
204
|
-
* @param {String} inputValue
|
|
205
|
-
* @param {Date[]} dates
|
|
206
204
|
*/
|
|
207
|
-
rangeTypeSideEffectsWhenClosePanel(inputValue: string,
|
|
205
|
+
rangeTypeSideEffectsWhenClosePanel(inputValue: string, willUpdateDates: Date[]): void;
|
|
206
|
+
/**
|
|
207
|
+
* clear input value when selected date is not confirmed
|
|
208
|
+
*/
|
|
209
|
+
needConfirmSideEffectsWhenClosePanel(willUpdateDates: Date[] | null | undefined): void;
|
|
210
|
+
resetCachedSelectedValue(willUpdateDates?: Date[]): void;
|
|
208
211
|
/**
|
|
209
212
|
* timing to call closePanel
|
|
210
213
|
* 1. click confirm button
|
|
@@ -96,12 +96,10 @@ class DatePickerFoundation extends _foundation.default {
|
|
|
96
96
|
};
|
|
97
97
|
|
|
98
98
|
this._isRangeValueComplete = value => {
|
|
99
|
-
let result =
|
|
99
|
+
let result = false;
|
|
100
100
|
|
|
101
101
|
if ((0, _isArray.default)(value)) {
|
|
102
102
|
result = !(0, _some.default)(value).call(value, date => (0, _isNullOrUndefined.default)(date));
|
|
103
|
-
} else {
|
|
104
|
-
result = false;
|
|
105
103
|
}
|
|
106
104
|
|
|
107
105
|
return result;
|
|
@@ -250,12 +248,10 @@ class DatePickerFoundation extends _foundation.default {
|
|
|
250
248
|
* 2. set cachedSelectedValue using given dates(in needConfirm mode)
|
|
251
249
|
* - directly closePanel without click confirm will set cachedSelectedValue to state value
|
|
252
250
|
* - select one date(which means that the selection value is incomplete) and click confirm also set cachedSelectedValue to state value
|
|
253
|
-
* @param {String} inputValue
|
|
254
|
-
* @param {Date[]} dates
|
|
255
251
|
*/
|
|
256
252
|
|
|
257
253
|
|
|
258
|
-
rangeTypeSideEffectsWhenClosePanel(inputValue,
|
|
254
|
+
rangeTypeSideEffectsWhenClosePanel(inputValue, willUpdateDates) {
|
|
259
255
|
if (this._isRangeType()) {
|
|
260
256
|
this._adapter.setRangeInputFocus(false);
|
|
261
257
|
/**
|
|
@@ -265,17 +261,36 @@ class DatePickerFoundation extends _foundation.default {
|
|
|
265
261
|
|
|
266
262
|
|
|
267
263
|
this.handleInputBlur(inputValue);
|
|
264
|
+
this.resetCachedSelectedValue(willUpdateDates);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* clear input value when selected date is not confirmed
|
|
269
|
+
*/
|
|
268
270
|
|
|
269
|
-
const {
|
|
270
|
-
value,
|
|
271
|
-
cachedSelectedValue
|
|
272
|
-
} = this._adapter.getStates();
|
|
273
271
|
|
|
274
|
-
|
|
272
|
+
needConfirmSideEffectsWhenClosePanel(willUpdateDates) {
|
|
273
|
+
if (this._adapter.needConfirm() && !this._isRangeType()) {
|
|
274
|
+
/**
|
|
275
|
+
* if `null` input element will show `cachedSelectedValue` formatted value(format in DateInput render)
|
|
276
|
+
* if `` input element will show `` directly
|
|
277
|
+
*/
|
|
278
|
+
this._adapter.updateInputValue(null);
|
|
275
279
|
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
280
|
+
this.resetCachedSelectedValue(willUpdateDates);
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
resetCachedSelectedValue(willUpdateDates) {
|
|
285
|
+
const {
|
|
286
|
+
value,
|
|
287
|
+
cachedSelectedValue
|
|
288
|
+
} = this._adapter.getStates();
|
|
289
|
+
|
|
290
|
+
const newCachedSelectedValue = (0, _isArray.default)(willUpdateDates) ? willUpdateDates : value;
|
|
291
|
+
|
|
292
|
+
if (!(0, _isEqual2.default)(newCachedSelectedValue, cachedSelectedValue)) {
|
|
293
|
+
this._adapter.updateCachedSelectedValue(newCachedSelectedValue);
|
|
279
294
|
}
|
|
280
295
|
}
|
|
281
296
|
/**
|
|
@@ -294,7 +309,14 @@ class DatePickerFoundation extends _foundation.default {
|
|
|
294
309
|
|
|
295
310
|
closePanel(e) {
|
|
296
311
|
let inputValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
297
|
-
let dates = arguments.length > 2
|
|
312
|
+
let dates = arguments.length > 2 ? arguments[2] : undefined;
|
|
313
|
+
|
|
314
|
+
const {
|
|
315
|
+
value,
|
|
316
|
+
cachedSelectedValue
|
|
317
|
+
} = this._adapter.getStates();
|
|
318
|
+
|
|
319
|
+
const willUpdateDates = (0, _isNullOrUndefined.default)(dates) ? this._adapter.needConfirm() ? value : cachedSelectedValue : dates;
|
|
298
320
|
|
|
299
321
|
if (!this._isControlledComponent('open')) {
|
|
300
322
|
this._adapter.togglePanel(false);
|
|
@@ -303,7 +325,8 @@ class DatePickerFoundation extends _foundation.default {
|
|
|
303
325
|
} // range type picker, closing panel requires the following side effects
|
|
304
326
|
|
|
305
327
|
|
|
306
|
-
this.rangeTypeSideEffectsWhenClosePanel(inputValue,
|
|
328
|
+
this.rangeTypeSideEffectsWhenClosePanel(inputValue, willUpdateDates);
|
|
329
|
+
this.needConfirmSideEffectsWhenClosePanel(willUpdateDates);
|
|
307
330
|
|
|
308
331
|
this._adapter.notifyOpenChange(false);
|
|
309
332
|
|
|
@@ -365,7 +388,8 @@ class DatePickerFoundation extends _foundation.default {
|
|
|
365
388
|
if (parsedResult && parsedResult.length) {
|
|
366
389
|
this._updateValueAndInput(parsedResult, input === '');
|
|
367
390
|
} else if (input === '') {
|
|
368
|
-
|
|
391
|
+
// if clear input, set input to `''`
|
|
392
|
+
this._updateValueAndInput('', true, '');
|
|
369
393
|
} else {
|
|
370
394
|
this._updateValueAndInput(stateValue);
|
|
371
395
|
}
|
|
@@ -729,7 +753,7 @@ class DatePickerFoundation extends _foundation.default {
|
|
|
729
753
|
|
|
730
754
|
if (!this._someDateDisabled(changedDates)) {
|
|
731
755
|
inputValue = this._isMultiple() ? this.formatMultipleDates(dates) : this.formatDates(dates);
|
|
732
|
-
const isRangeTypeAndInputIncomplete = this._isRangeType() &&
|
|
756
|
+
const isRangeTypeAndInputIncomplete = this._isRangeType() && !this._isRangeValueComplete(dates);
|
|
733
757
|
/**
|
|
734
758
|
* If the input is incomplete when under control, the notifyChange is not triggered because
|
|
735
759
|
* You need to update the value of the input box, otherwise there will be a problem that a date is selected but the input box does not show the date #1357
|
|
@@ -53,6 +53,7 @@ export interface MonthsGridFoundationProps extends MonthsGridElementProps {
|
|
|
53
53
|
setRangeInputFocus?: (rangeInputFocus: 'rangeStart' | 'rangeEnd') => void;
|
|
54
54
|
isAnotherPanelHasOpened?: (currentRangeInput: 'rangeStart' | 'rangeEnd') => boolean;
|
|
55
55
|
focusRecordsRef?: any;
|
|
56
|
+
triggerRender?: (props: Record<string, any>) => any;
|
|
56
57
|
}
|
|
57
58
|
export interface MonthInfo {
|
|
58
59
|
pickerDate: Date;
|
|
@@ -28,6 +28,8 @@ var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-sta
|
|
|
28
28
|
|
|
29
29
|
var _trim = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/trim"));
|
|
30
30
|
|
|
31
|
+
var _isFunction2 = _interopRequireDefault(require("lodash/isFunction"));
|
|
32
|
+
|
|
31
33
|
var _isEqual2 = _interopRequireDefault(require("lodash/isEqual"));
|
|
32
34
|
|
|
33
35
|
var _isSet2 = _interopRequireDefault(require("lodash/isSet"));
|
|
@@ -731,13 +733,16 @@ class MonthsGridFoundation extends _foundation.default {
|
|
|
731
733
|
rangeStart,
|
|
732
734
|
rangeEnd
|
|
733
735
|
} = this.getStates();
|
|
736
|
+
|
|
734
737
|
const {
|
|
735
738
|
startDateOffset,
|
|
736
739
|
endDateOffset,
|
|
737
740
|
type,
|
|
738
741
|
dateFnsLocale,
|
|
739
|
-
rangeInputFocus
|
|
740
|
-
|
|
742
|
+
rangeInputFocus,
|
|
743
|
+
triggerRender
|
|
744
|
+
} = this._adapter.getProps();
|
|
745
|
+
|
|
741
746
|
const {
|
|
742
747
|
fullDate
|
|
743
748
|
} = day;
|
|
@@ -818,9 +823,17 @@ class MonthsGridFoundation extends _foundation.default {
|
|
|
818
823
|
date = [start, end];
|
|
819
824
|
}
|
|
820
825
|
}
|
|
826
|
+
/**
|
|
827
|
+
* no need to check focus then
|
|
828
|
+
* - dateRange and isDateRangeAndHasOffset
|
|
829
|
+
* - dateRange and triggerRender
|
|
830
|
+
*/
|
|
831
|
+
|
|
832
|
+
|
|
833
|
+
const needCheckFocusRecord = !(type === 'dateRange' && (isDateRangeAndHasOffset || (0, _isFunction2.default)(triggerRender)));
|
|
821
834
|
|
|
822
835
|
this._adapter.notifySelectedChange(date, {
|
|
823
|
-
needCheckFocusRecord
|
|
836
|
+
needCheckFocusRecord
|
|
824
837
|
});
|
|
825
838
|
}
|
|
826
839
|
}
|
|
@@ -9,6 +9,18 @@ $module: #{$prefix}-datepicker;
|
|
|
9
9
|
padding-right: 0;
|
|
10
10
|
padding-left: $spacing-datepicker_footer-paddingRight;
|
|
11
11
|
text-align: left;
|
|
12
|
+
|
|
13
|
+
.#{$prefix}-button {
|
|
14
|
+
&:first-of-type {
|
|
15
|
+
margin-left: 0;
|
|
16
|
+
margin-right: 0;
|
|
17
|
+
}
|
|
18
|
+
// confirm button
|
|
19
|
+
&:nth-of-type(2) {
|
|
20
|
+
margin-right: $spacing-datepicker_footer_cancel_button-marginRight;
|
|
21
|
+
margin-left: 0;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
12
24
|
}
|
|
13
25
|
|
|
14
26
|
&-day {
|
|
@@ -66,7 +78,9 @@ $module: #{$prefix}-datepicker;
|
|
|
66
78
|
&-yam {
|
|
67
79
|
// rtl 对箭头进行翻转
|
|
68
80
|
.#{$prefix}-icon-chevron_left,
|
|
69
|
-
.#{$prefix}-icon-chevron_right
|
|
81
|
+
.#{$prefix}-icon-chevron_right,
|
|
82
|
+
.#{$prefix}-icon-double_chevron_left,
|
|
83
|
+
.#{$prefix}-icon-double_chevron_right {
|
|
70
84
|
transform: scaleX(-1);
|
|
71
85
|
}
|
|
72
86
|
}
|
|
@@ -33,6 +33,8 @@ $spacing-datepicker_scrolllist_body-padding: 0; // 时间选择滚动菜单内
|
|
|
33
33
|
$spacing-datepicker_footer-paddingTop: 10px; // 确认选择 footer 顶部内边距
|
|
34
34
|
$spacing-datepicker_footer-paddingBottom: 10px; // 确认选择 footer 底部内边距
|
|
35
35
|
$spacing-datepicker_footer-paddingRight: 8px; // 确认选择 footer 右侧内边距
|
|
36
|
+
$spacing-datepicker_footer_cancel_button-marginRight: 12px; // 确认选择 footer 取消按钮右外边距
|
|
37
|
+
$spacing-datepicker_footer_confirm_button-marginRight: 8px; // 确认选择 footer 确认按钮右外边距
|
|
36
38
|
$spacing-datepicker_navigation-paddingY: $spacing-base-tight; // 年月切换 header 垂直内边距
|
|
37
39
|
$spacing-datepicker_navigation-paddingX: $spacing-base; // 年月切换 header 水平内边距
|
|
38
40
|
$spacing-datepicker_month-padding: $spacing-base;
|
|
@@ -63,11 +63,11 @@ declare class InputNumberFoundation extends BaseFoundation<InputNumberAdapter> {
|
|
|
63
63
|
_adjustPrec(num: string | number): string;
|
|
64
64
|
/**
|
|
65
65
|
* format number to string
|
|
66
|
-
* @param {number} value
|
|
66
|
+
* @param {string|number} value
|
|
67
67
|
* @param {boolean} needAdjustPrec
|
|
68
68
|
* @returns {string}
|
|
69
69
|
*/
|
|
70
|
-
doFormat(value?: number, needAdjustPrec?: boolean): string;
|
|
70
|
+
doFormat(value?: string | number, needAdjustPrec?: boolean): string;
|
|
71
71
|
/**
|
|
72
72
|
*
|
|
73
73
|
* @param {number} current
|
|
@@ -140,6 +140,8 @@ class InputNumberFoundation extends _foundation.default {
|
|
|
140
140
|
|
|
141
141
|
this._adapter.setFocusing(true, null);
|
|
142
142
|
|
|
143
|
+
this._adapter.setClickUpOrDown(false);
|
|
144
|
+
|
|
143
145
|
this._adapter.notifyFocus(e);
|
|
144
146
|
}
|
|
145
147
|
/**
|
|
@@ -476,7 +478,7 @@ class InputNumberFoundation extends _foundation.default {
|
|
|
476
478
|
}
|
|
477
479
|
/**
|
|
478
480
|
* format number to string
|
|
479
|
-
* @param {number} value
|
|
481
|
+
* @param {string|number} value
|
|
480
482
|
* @param {boolean} needAdjustPrec
|
|
481
483
|
* @returns {string}
|
|
482
484
|
*/
|