@douyinfe/semi-foundation 2.2.0 → 2.2.1

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.
@@ -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
  // 年月选择
@@ -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, dates: Date[]) {
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
- const { value, cachedSelectedValue } = this._adapter.getStates();
338
- const newCachedSelectedValue = Array.isArray(dates) && dates.length ? dates : value;
339
- if (!isEqual(newCachedSelectedValue, cachedSelectedValue)) {
340
- this._adapter.updateCachedSelectedValue(newCachedSelectedValue);
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: Date[] = []) {
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, dates);
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
- this._updateValueAndInput('' as any, true);
438
+ // if clear input, set input to `''`
439
+ this._updateValueAndInput('' as any, true, '');
420
440
  } else {
421
441
  this._updateValueAndInput(stateValue);
422
442
  }
@@ -89,6 +89,8 @@ export default class InputFoundation extends BaseFoundation<DateInputAdapter> {
89
89
  }
90
90
 
91
91
  handleRangeInputClear(e: any) {
92
+ // prevent trigger click outside
93
+ this.stopPropagation(e);
92
94
  this._adapter.notifyRangeInputClear(e);
93
95
  }
94
96
 
@@ -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;
@@ -98,6 +98,12 @@
98
98
  text-align: right;
99
99
  background-color: var(--semi-color-fill-0);
100
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
+ }
101
107
  .semi-datepicker-yam {
102
108
  position: absolute;
103
109
  top: 0;
@@ -705,6 +711,16 @@
705
711
  padding-left: 8px;
706
712
  text-align: left;
707
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
+ }
708
724
  .semi-rtl .semi-datepicker-day-offsetrange-start .semi-datepicker-day-main,
709
725
  .semi-portal-rtl .semi-datepicker-day-offsetrange-start .semi-datepicker-day-main {
710
726
  border-radius: 0 var(--semi-border-radius-small) var(--semi-border-radius-small) 0;
@@ -740,12 +756,20 @@
740
756
  margin-right: 8px;
741
757
  }
742
758
  .semi-rtl .semi-datepicker-navigation .semi-icon-chevron_left,
743
- .semi-rtl .semi-datepicker-navigation .semi-icon-chevron_right, .semi-rtl .semi-datepicker-yam .semi-icon-chevron_left,
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,
744
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,
745
765
  .semi-portal-rtl .semi-datepicker-navigation .semi-icon-chevron_left,
746
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,
747
769
  .semi-portal-rtl .semi-datepicker-yam .semi-icon-chevron_left,
748
- .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 {
749
773
  transform: scaleX(-1);
750
774
  }
751
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, dates: Date[]): void;
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
@@ -250,12 +250,10 @@ class DatePickerFoundation extends _foundation.default {
250
250
  * 2. set cachedSelectedValue using given dates(in needConfirm mode)
251
251
  * - directly closePanel without click confirm will set cachedSelectedValue to state value
252
252
  * - 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
253
  */
256
254
 
257
255
 
258
- rangeTypeSideEffectsWhenClosePanel(inputValue, dates) {
256
+ rangeTypeSideEffectsWhenClosePanel(inputValue, willUpdateDates) {
259
257
  if (this._isRangeType()) {
260
258
  this._adapter.setRangeInputFocus(false);
261
259
  /**
@@ -265,17 +263,36 @@ class DatePickerFoundation extends _foundation.default {
265
263
 
266
264
 
267
265
  this.handleInputBlur(inputValue);
266
+ this.resetCachedSelectedValue(willUpdateDates);
267
+ }
268
+ }
269
+ /**
270
+ * clear input value when selected date is not confirmed
271
+ */
268
272
 
269
- const {
270
- value,
271
- cachedSelectedValue
272
- } = this._adapter.getStates();
273
273
 
274
- const newCachedSelectedValue = (0, _isArray.default)(dates) && dates.length ? dates : value;
274
+ needConfirmSideEffectsWhenClosePanel(willUpdateDates) {
275
+ if (this._adapter.needConfirm() && !this._isRangeType()) {
276
+ /**
277
+ * if `null` input element will show `cachedSelectedValue` formatted value(format in DateInput render)
278
+ * if `` input element will show `` directly
279
+ */
280
+ this._adapter.updateInputValue(null);
275
281
 
276
- if (!(0, _isEqual2.default)(newCachedSelectedValue, cachedSelectedValue)) {
277
- this._adapter.updateCachedSelectedValue(newCachedSelectedValue);
278
- }
282
+ this.resetCachedSelectedValue(willUpdateDates);
283
+ }
284
+ }
285
+
286
+ resetCachedSelectedValue(willUpdateDates) {
287
+ const {
288
+ value,
289
+ cachedSelectedValue
290
+ } = this._adapter.getStates();
291
+
292
+ const newCachedSelectedValue = (0, _isArray.default)(willUpdateDates) ? willUpdateDates : value;
293
+
294
+ if (!(0, _isEqual2.default)(newCachedSelectedValue, cachedSelectedValue)) {
295
+ this._adapter.updateCachedSelectedValue(newCachedSelectedValue);
279
296
  }
280
297
  }
281
298
  /**
@@ -294,7 +311,14 @@ class DatePickerFoundation extends _foundation.default {
294
311
 
295
312
  closePanel(e) {
296
313
  let inputValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
297
- let dates = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
314
+ let dates = arguments.length > 2 ? arguments[2] : undefined;
315
+
316
+ const {
317
+ value,
318
+ cachedSelectedValue
319
+ } = this._adapter.getStates();
320
+
321
+ const willUpdateDates = (0, _isNullOrUndefined.default)(dates) ? this._adapter.needConfirm() ? value : cachedSelectedValue : dates;
298
322
 
299
323
  if (!this._isControlledComponent('open')) {
300
324
  this._adapter.togglePanel(false);
@@ -303,7 +327,8 @@ class DatePickerFoundation extends _foundation.default {
303
327
  } // range type picker, closing panel requires the following side effects
304
328
 
305
329
 
306
- this.rangeTypeSideEffectsWhenClosePanel(inputValue, dates);
330
+ this.rangeTypeSideEffectsWhenClosePanel(inputValue, willUpdateDates);
331
+ this.needConfirmSideEffectsWhenClosePanel(willUpdateDates);
307
332
 
308
333
  this._adapter.notifyOpenChange(false);
309
334
 
@@ -365,7 +390,8 @@ class DatePickerFoundation extends _foundation.default {
365
390
  if (parsedResult && parsedResult.length) {
366
391
  this._updateValueAndInput(parsedResult, input === '');
367
392
  } else if (input === '') {
368
- this._updateValueAndInput('', true);
393
+ // if clear input, set input to `''`
394
+ this._updateValueAndInput('', true, '');
369
395
  } else {
370
396
  this._updateValueAndInput(stateValue);
371
397
  }
@@ -56,6 +56,9 @@ class InputFoundation extends _foundation.default {
56
56
  }
57
57
 
58
58
  handleRangeInputClear(e) {
59
+ // prevent trigger click outside
60
+ this.stopPropagation(e);
61
+
59
62
  this._adapter.notifyRangeInputClear(e);
60
63
  }
61
64
 
@@ -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;
@@ -52,12 +52,10 @@
52
52
  color: var(--semi-color-text-0);
53
53
  width: 100%;
54
54
  }
55
- .semi-table-middle .semi-table-thead > .semi-table-row > .semi-table-row-head,
56
55
  .semi-table-middle .semi-table-tbody > .semi-table-row > .semi-table-row-cell {
57
56
  padding-top: 12px;
58
57
  padding-bottom: 12px;
59
58
  }
60
- .semi-table-small .semi-table-thead > .semi-table-row > .semi-table-row-head,
61
59
  .semi-table-small .semi-table-tbody > .semi-table-row > .semi-table-row-cell {
62
60
  padding-top: 8px;
63
61
  padding-bottom: 8px;
@@ -25,7 +25,6 @@ $module: #{$prefix}-table;
25
25
  }
26
26
 
27
27
  &-middle {
28
- .#{$module}-thead > .#{$module}-row > .#{$module}-row-head,
29
28
  .#{$module}-tbody > .#{$module}-row > .#{$module}-row-cell {
30
29
  padding-top: $spacing-table_middle-paddingY;
31
30
  padding-bottom: $spacing-table_middle-paddingY;
@@ -33,7 +32,6 @@ $module: #{$prefix}-table;
33
32
  }
34
33
 
35
34
  &-small {
36
- .#{$module}-thead > .#{$module}-row > .#{$module}-row-head,
37
35
  .#{$module}-tbody > .#{$module}-row > .#{$module}-row-cell {
38
36
  padding-top: $spacing-table_small-paddingY;
39
37
  padding-bottom: $spacing-table_small-paddingY;
@@ -98,6 +98,12 @@
98
98
  text-align: right;
99
99
  background-color: var(--semi-color-fill-0);
100
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
+ }
101
107
  .semi-datepicker-yam {
102
108
  position: absolute;
103
109
  top: 0;
@@ -705,6 +711,16 @@
705
711
  padding-left: 8px;
706
712
  text-align: left;
707
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
+ }
708
724
  .semi-rtl .semi-datepicker-day-offsetrange-start .semi-datepicker-day-main,
709
725
  .semi-portal-rtl .semi-datepicker-day-offsetrange-start .semi-datepicker-day-main {
710
726
  border-radius: 0 var(--semi-border-radius-small) var(--semi-border-radius-small) 0;
@@ -740,12 +756,20 @@
740
756
  margin-right: 8px;
741
757
  }
742
758
  .semi-rtl .semi-datepicker-navigation .semi-icon-chevron_left,
743
- .semi-rtl .semi-datepicker-navigation .semi-icon-chevron_right, .semi-rtl .semi-datepicker-yam .semi-icon-chevron_left,
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,
744
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,
745
765
  .semi-portal-rtl .semi-datepicker-navigation .semi-icon-chevron_left,
746
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,
747
769
  .semi-portal-rtl .semi-datepicker-yam .semi-icon-chevron_left,
748
- .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 {
749
773
  transform: scaleX(-1);
750
774
  }
751
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, dates: Date[]): void;
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
@@ -212,12 +212,10 @@ export default class DatePickerFoundation extends BaseFoundation {
212
212
  * 2. set cachedSelectedValue using given dates(in needConfirm mode)
213
213
  * - directly closePanel without click confirm will set cachedSelectedValue to state value
214
214
  * - select one date(which means that the selection value is incomplete) and click confirm also set cachedSelectedValue to state value
215
- * @param {String} inputValue
216
- * @param {Date[]} dates
217
215
  */
218
216
 
219
217
 
220
- rangeTypeSideEffectsWhenClosePanel(inputValue, dates) {
218
+ rangeTypeSideEffectsWhenClosePanel(inputValue, willUpdateDates) {
221
219
  if (this._isRangeType()) {
222
220
  this._adapter.setRangeInputFocus(false);
223
221
  /**
@@ -227,17 +225,36 @@ export default class DatePickerFoundation extends BaseFoundation {
227
225
 
228
226
 
229
227
  this.handleInputBlur(inputValue);
228
+ this.resetCachedSelectedValue(willUpdateDates);
229
+ }
230
+ }
231
+ /**
232
+ * clear input value when selected date is not confirmed
233
+ */
230
234
 
231
- const {
232
- value,
233
- cachedSelectedValue
234
- } = this._adapter.getStates();
235
235
 
236
- const newCachedSelectedValue = _Array$isArray(dates) && dates.length ? dates : value;
236
+ needConfirmSideEffectsWhenClosePanel(willUpdateDates) {
237
+ if (this._adapter.needConfirm() && !this._isRangeType()) {
238
+ /**
239
+ * if `null` input element will show `cachedSelectedValue` formatted value(format in DateInput render)
240
+ * if `` input element will show `` directly
241
+ */
242
+ this._adapter.updateInputValue(null);
237
243
 
238
- if (!_isEqual(newCachedSelectedValue, cachedSelectedValue)) {
239
- this._adapter.updateCachedSelectedValue(newCachedSelectedValue);
240
- }
244
+ this.resetCachedSelectedValue(willUpdateDates);
245
+ }
246
+ }
247
+
248
+ resetCachedSelectedValue(willUpdateDates) {
249
+ const {
250
+ value,
251
+ cachedSelectedValue
252
+ } = this._adapter.getStates();
253
+
254
+ const newCachedSelectedValue = _Array$isArray(willUpdateDates) ? willUpdateDates : value;
255
+
256
+ if (!_isEqual(newCachedSelectedValue, cachedSelectedValue)) {
257
+ this._adapter.updateCachedSelectedValue(newCachedSelectedValue);
241
258
  }
242
259
  }
243
260
  /**
@@ -256,7 +273,14 @@ export default class DatePickerFoundation extends BaseFoundation {
256
273
 
257
274
  closePanel(e) {
258
275
  let inputValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
259
- let dates = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
276
+ let dates = arguments.length > 2 ? arguments[2] : undefined;
277
+
278
+ const {
279
+ value,
280
+ cachedSelectedValue
281
+ } = this._adapter.getStates();
282
+
283
+ const willUpdateDates = isNullOrUndefined(dates) ? this._adapter.needConfirm() ? value : cachedSelectedValue : dates;
260
284
 
261
285
  if (!this._isControlledComponent('open')) {
262
286
  this._adapter.togglePanel(false);
@@ -265,7 +289,8 @@ export default class DatePickerFoundation extends BaseFoundation {
265
289
  } // range type picker, closing panel requires the following side effects
266
290
 
267
291
 
268
- this.rangeTypeSideEffectsWhenClosePanel(inputValue, dates);
292
+ this.rangeTypeSideEffectsWhenClosePanel(inputValue, willUpdateDates);
293
+ this.needConfirmSideEffectsWhenClosePanel(willUpdateDates);
269
294
 
270
295
  this._adapter.notifyOpenChange(false);
271
296
 
@@ -327,7 +352,8 @@ export default class DatePickerFoundation extends BaseFoundation {
327
352
  if (parsedResult && parsedResult.length) {
328
353
  this._updateValueAndInput(parsedResult, input === '');
329
354
  } else if (input === '') {
330
- this._updateValueAndInput('', true);
355
+ // if clear input, set input to `''`
356
+ this._updateValueAndInput('', true, '');
331
357
  } else {
332
358
  this._updateValueAndInput(stateValue);
333
359
  }
@@ -40,6 +40,9 @@ export default class InputFoundation extends BaseFoundation {
40
40
  }
41
41
 
42
42
  handleRangeInputClear(e) {
43
+ // prevent trigger click outside
44
+ this.stopPropagation(e);
45
+
43
46
  this._adapter.notifyRangeInputClear(e);
44
47
  }
45
48
 
@@ -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;
@@ -52,12 +52,10 @@
52
52
  color: var(--semi-color-text-0);
53
53
  width: 100%;
54
54
  }
55
- .semi-table-middle .semi-table-thead > .semi-table-row > .semi-table-row-head,
56
55
  .semi-table-middle .semi-table-tbody > .semi-table-row > .semi-table-row-cell {
57
56
  padding-top: 12px;
58
57
  padding-bottom: 12px;
59
58
  }
60
- .semi-table-small .semi-table-thead > .semi-table-row > .semi-table-row-head,
61
59
  .semi-table-small .semi-table-tbody > .semi-table-row > .semi-table-row-cell {
62
60
  padding-top: 8px;
63
61
  padding-bottom: 8px;
@@ -25,7 +25,6 @@ $module: #{$prefix}-table;
25
25
  }
26
26
 
27
27
  &-middle {
28
- .#{$module}-thead > .#{$module}-row > .#{$module}-row-head,
29
28
  .#{$module}-tbody > .#{$module}-row > .#{$module}-row-cell {
30
29
  padding-top: $spacing-table_middle-paddingY;
31
30
  padding-bottom: $spacing-table_middle-paddingY;
@@ -33,7 +32,6 @@ $module: #{$prefix}-table;
33
32
  }
34
33
 
35
34
  &-small {
36
- .#{$module}-thead > .#{$module}-row > .#{$module}-row-head,
37
35
  .#{$module}-tbody > .#{$module}-row > .#{$module}-row-cell {
38
36
  padding-top: $spacing-table_small-paddingY;
39
37
  padding-bottom: $spacing-table_small-paddingY;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@douyinfe/semi-foundation",
3
- "version": "2.2.0",
3
+ "version": "2.2.1",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "build:lib": "node ./scripts/compileLib.js",
@@ -8,7 +8,7 @@
8
8
  },
9
9
  "dependencies": {
10
10
  "@babel/runtime-corejs3": "^7.15.4",
11
- "@douyinfe/semi-animation": "2.2.0",
11
+ "@douyinfe/semi-animation": "2.2.1",
12
12
  "async-validator": "^3.5.0",
13
13
  "classnames": "^2.2.6",
14
14
  "date-fns": "^2.9.0",
@@ -24,7 +24,7 @@
24
24
  "*.scss",
25
25
  "*.css"
26
26
  ],
27
- "gitHead": "f47324c727f9ca85ceb44649c4227b75876c4596",
27
+ "gitHead": "6d8bb9dd22bf199225fa2a0dda4f8524a4b97f6f",
28
28
  "devDependencies": {
29
29
  "@babel/plugin-proposal-decorators": "^7.15.8",
30
30
  "@babel/plugin-transform-runtime": "^7.15.8",
package/table/table.scss CHANGED
@@ -25,7 +25,6 @@ $module: #{$prefix}-table;
25
25
  }
26
26
 
27
27
  &-middle {
28
- .#{$module}-thead > .#{$module}-row > .#{$module}-row-head,
29
28
  .#{$module}-tbody > .#{$module}-row > .#{$module}-row-cell {
30
29
  padding-top: $spacing-table_middle-paddingY;
31
30
  padding-bottom: $spacing-table_middle-paddingY;
@@ -33,7 +32,6 @@ $module: #{$prefix}-table;
33
32
  }
34
33
 
35
34
  &-small {
36
- .#{$module}-thead > .#{$module}-row > .#{$module}-row-head,
37
35
  .#{$module}-tbody > .#{$module}-row > .#{$module}-row-cell {
38
36
  padding-top: $spacing-table_small-paddingY;
39
37
  padding-bottom: $spacing-table_small-paddingY;