@douyinfe/semi-foundation 2.1.6-alpha.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.
Files changed (90) hide show
  1. package/cascader/cascader.scss +1 -1
  2. package/cascader/constants.ts +4 -0
  3. package/cascader/foundation.ts +29 -15
  4. package/cascader/util.ts +13 -0
  5. package/datePicker/_utils/parser.ts +4 -3
  6. package/datePicker/datePicker.scss +29 -0
  7. package/datePicker/foundation.ts +31 -11
  8. package/datePicker/inputFoundation.ts +2 -0
  9. package/datePicker/monthsGridFoundation.ts +101 -8
  10. package/datePicker/rtl.scss +15 -1
  11. package/datePicker/variables.scss +2 -0
  12. package/gulpfile.js +3 -1
  13. package/lib/cjs/cascader/cascader.css +2 -2
  14. package/lib/cjs/cascader/cascader.scss +1 -1
  15. package/lib/cjs/cascader/constants.d.ts +3 -0
  16. package/lib/cjs/cascader/constants.js +6 -1
  17. package/lib/cjs/cascader/foundation.d.ts +4 -1
  18. package/lib/cjs/cascader/foundation.js +24 -11
  19. package/lib/cjs/cascader/util.d.ts +1 -0
  20. package/lib/cjs/cascader/util.js +17 -0
  21. package/lib/cjs/datePicker/_utils/parser.d.ts +6 -1
  22. package/lib/cjs/datePicker/_utils/parser.js +3 -1
  23. package/lib/cjs/datePicker/datePicker.css +32 -3
  24. package/lib/cjs/datePicker/datePicker.scss +29 -0
  25. package/lib/cjs/datePicker/foundation.d.ts +6 -3
  26. package/lib/cjs/datePicker/foundation.js +40 -14
  27. package/lib/cjs/datePicker/inputFoundation.js +3 -0
  28. package/lib/cjs/datePicker/monthsGridFoundation.d.ts +35 -3
  29. package/lib/cjs/datePicker/monthsGridFoundation.js +139 -6
  30. package/lib/cjs/datePicker/rtl.scss +15 -1
  31. package/lib/cjs/datePicker/variables.scss +2 -0
  32. package/lib/cjs/navigation/navigation.css +0 -1
  33. package/lib/cjs/notification/notification.css +8 -4
  34. package/lib/cjs/notification/notification.scss +9 -5
  35. package/lib/cjs/notification/variables.scss +1 -0
  36. package/lib/cjs/select/foundation.d.ts +10 -1
  37. package/lib/cjs/select/foundation.js +11 -9
  38. package/lib/cjs/table/table.css +0 -2
  39. package/lib/cjs/table/table.scss +0 -2
  40. package/lib/cjs/tree/treeUtil.js +14 -14
  41. package/lib/cjs/upload/foundation.d.ts +1 -0
  42. package/lib/cjs/upload/foundation.js +106 -0
  43. package/lib/cjs/upload/rtl.scss +0 -4
  44. package/lib/cjs/upload/upload.css +30 -18
  45. package/lib/cjs/upload/upload.scss +31 -8
  46. package/lib/cjs/upload/variables.scss +5 -1
  47. package/lib/es/cascader/cascader.css +2 -2
  48. package/lib/es/cascader/cascader.scss +1 -1
  49. package/lib/es/cascader/constants.d.ts +3 -0
  50. package/lib/es/cascader/constants.js +6 -1
  51. package/lib/es/cascader/foundation.d.ts +4 -1
  52. package/lib/es/cascader/foundation.js +24 -12
  53. package/lib/es/cascader/util.d.ts +1 -0
  54. package/lib/es/cascader/util.js +14 -0
  55. package/lib/es/datePicker/_utils/parser.d.ts +6 -1
  56. package/lib/es/datePicker/_utils/parser.js +3 -1
  57. package/lib/es/datePicker/datePicker.css +32 -3
  58. package/lib/es/datePicker/datePicker.scss +29 -0
  59. package/lib/es/datePicker/foundation.d.ts +6 -3
  60. package/lib/es/datePicker/foundation.js +40 -14
  61. package/lib/es/datePicker/inputFoundation.js +3 -0
  62. package/lib/es/datePicker/monthsGridFoundation.d.ts +35 -3
  63. package/lib/es/datePicker/monthsGridFoundation.js +139 -6
  64. package/lib/es/datePicker/rtl.scss +15 -1
  65. package/lib/es/datePicker/variables.scss +2 -0
  66. package/lib/es/navigation/navigation.css +0 -1
  67. package/lib/es/notification/notification.css +8 -4
  68. package/lib/es/notification/notification.scss +9 -5
  69. package/lib/es/notification/variables.scss +1 -0
  70. package/lib/es/select/foundation.d.ts +10 -1
  71. package/lib/es/select/foundation.js +12 -9
  72. package/lib/es/table/table.css +0 -2
  73. package/lib/es/table/table.scss +0 -2
  74. package/lib/es/tree/treeUtil.js +13 -12
  75. package/lib/es/upload/foundation.d.ts +1 -0
  76. package/lib/es/upload/foundation.js +107 -0
  77. package/lib/es/upload/rtl.scss +0 -4
  78. package/lib/es/upload/upload.css +30 -18
  79. package/lib/es/upload/upload.scss +31 -8
  80. package/lib/es/upload/variables.scss +5 -1
  81. package/notification/notification.scss +9 -5
  82. package/notification/variables.scss +1 -0
  83. package/package.json +4 -4
  84. package/select/foundation.ts +11 -9
  85. package/table/table.scss +0 -2
  86. package/tree/treeUtil.ts +6 -2
  87. package/upload/foundation.ts +81 -0
  88. package/upload/rtl.scss +0 -4
  89. package/upload/upload.scss +31 -8
  90. package/upload/variables.scss +5 -1
@@ -116,7 +116,7 @@ $module: #{$prefix}-cascader;
116
116
  margin-left: 0;
117
117
  }
118
118
 
119
- &-disabled {
119
+ &-disabled.#{$prefix}-tag {
120
120
  color: $color-cascader_input_disabled-text-default;
121
121
  cursor: not-allowed;
122
122
 
@@ -9,6 +9,9 @@ declare const strings: {
9
9
  readonly IS_VALUE: "isValue";
10
10
  readonly SHOW_NEXT_BY_CLICK: "click";
11
11
  readonly SHOW_NEXT_BY_HOVER: "hover";
12
+ readonly LEAF_ONLY_MERGE_TYPE: "leafOnly";
13
+ readonly AUTO_MERGE_VALUE_MERGE_TYPE: "autoMergeValue";
14
+ readonly NONE_MERGE_TYPE: "none";
12
15
  };
13
16
  declare const numbers: {};
14
17
  export { cssClasses, strings, numbers };
@@ -9,7 +9,12 @@ const strings = {
9
9
  IS_KEY: 'isKey',
10
10
  IS_VALUE: 'isValue',
11
11
  SHOW_NEXT_BY_CLICK: 'click',
12
- SHOW_NEXT_BY_HOVER: 'hover'
12
+ SHOW_NEXT_BY_HOVER: 'hover',
13
+
14
+ /* Merge Type */
15
+ LEAF_ONLY_MERGE_TYPE: 'leafOnly',
16
+ AUTO_MERGE_VALUE_MERGE_TYPE: 'autoMergeValue',
17
+ NONE_MERGE_TYPE: 'none'
13
18
  };
14
19
  const numbers = {};
15
20
  export { cssClasses, strings, numbers };
@@ -57,6 +57,7 @@ export interface BasicScrollPanelProps {
57
57
  export interface BasicCascaderProps {
58
58
  mouseEnterDelay?: number;
59
59
  mouseLeaveDelay?: number;
60
+ separator?: string;
60
61
  arrowIcon?: any;
61
62
  changeOnSelect?: boolean;
62
63
  multiple?: boolean;
@@ -96,6 +97,8 @@ export interface BasicCascaderProps {
96
97
  topSlot?: any;
97
98
  showNext?: ShowNextType;
98
99
  disableStrictly?: boolean;
100
+ leafOnly?: boolean;
101
+ enableLeafClick?: boolean;
99
102
  onClear?: () => void;
100
103
  triggerRender?: (props: BasicTriggerRenderProps) => any;
101
104
  onListScroll?: (e: any, panel: BasicScrollPanelProps) => void;
@@ -125,7 +128,7 @@ export interface BasicCascaderInnerData {
125
128
  isHovering: boolean;
126
129
  checkedKeys: Set<string>;
127
130
  halfCheckedKeys: Set<string>;
128
- mergedCheckedKeys: Set<string>;
131
+ resolvedCheckedKeys: Set<string>;
129
132
  loadedKeys: Set<string>;
130
133
  loadingKeys: Set<string>;
131
134
  loading: boolean;
@@ -22,7 +22,8 @@ import _sortInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instanc
22
22
  import _parseInt from "@babel/runtime-corejs3/core-js-stable/parse-int";
23
23
  import BaseFoundation from '../base/foundation';
24
24
  import { filter, findAncestorKeys, calcCheckedKeysForUnchecked, calcCheckedKeysForChecked, calcCheckedKeys, findDescendantKeys, normalizeKeyList } from '../tree/treeUtil';
25
- import { convertDataToEntities, findKeysForValues, normalizedArr, isValid } from './util'; // eslint-disable-next-line max-len
25
+ import { convertDataToEntities, findKeysForValues, normalizedArr, isValid, calcMergeType } from './util';
26
+ import { strings } from './constants'; // eslint-disable-next-line max-len
26
27
 
27
28
  export default class CascaderFoundation extends BaseFoundation {
28
29
  constructor(adapter) {
@@ -535,10 +536,12 @@ export default class CascaderFoundation extends BaseFoundation {
535
536
  }
536
537
 
537
538
  _defaultRenderText(path, displayRender) {
539
+ const separator = this.getProp('separator');
540
+
538
541
  if (displayRender && typeof displayRender === 'function') {
539
542
  return displayRender(path);
540
543
  } else {
541
- return path.join(' / ');
544
+ return path.join(separator);
542
545
  }
543
546
  }
544
547
 
@@ -612,7 +615,8 @@ export default class CascaderFoundation extends BaseFoundation {
612
615
  const {
613
616
  changeOnSelect: allowChange,
614
617
  filterLeafOnly,
615
- multiple
618
+ multiple,
619
+ enableLeafClick
616
620
  } = this.getProps();
617
621
  const {
618
622
  keyEntities,
@@ -646,6 +650,10 @@ export default class CascaderFoundation extends BaseFoundation {
646
650
  this._adapter.updateStates({
647
651
  activeKeys: new _Set(activeKeys)
648
652
  });
653
+
654
+ if (isLeaf && enableLeafClick) {
655
+ this.onItemCheckboxClick(item);
656
+ }
649
657
  } else {
650
658
  this._adapter.notifySelect(data.value);
651
659
 
@@ -695,12 +703,13 @@ export default class CascaderFoundation extends BaseFoundation {
695
703
  const {
696
704
  checkedKeys,
697
705
  keyEntities,
698
- mergedCheckedKeys
706
+ resolvedCheckedKeys
699
707
  } = this.getStates();
700
708
  const {
701
709
  autoMergeValue,
702
710
  max,
703
- disableStrictly
711
+ disableStrictly,
712
+ leafOnly
704
713
  } = this.getProps(); // prev checked status
705
714
 
706
715
  const prevCheckedStatus = checkedKeys.has(key); // next checked status
@@ -711,16 +720,19 @@ export default class CascaderFoundation extends BaseFoundation {
711
720
  checkedKeys: curCheckedKeys,
712
721
  halfCheckedKeys: curHalfCheckedKeys
713
722
  } = disableStrictly ? this.calcNonDisabedCheckedKeys(key, curCheckedStatus) : this.calcCheckedKeys(key, curCheckedStatus);
714
- const curMergedCheckedKeys = new _Set(normalizeKeyList(curCheckedKeys, keyEntities));
715
- const curRealCheckedKeys = autoMergeValue ? curMergedCheckedKeys : curCheckedKeys;
723
+ const mergeType = calcMergeType(autoMergeValue, leafOnly);
724
+ const isLeafOnlyMerge = mergeType === strings.LEAF_ONLY_MERGE_TYPE;
725
+ const isNoneMerge = mergeType === strings.NONE_MERGE_TYPE;
726
+ const curResolvedCheckedKeys = new _Set(normalizeKeyList(curCheckedKeys, keyEntities, isLeafOnlyMerge));
727
+ const curRealCheckedKeys = isNoneMerge ? curCheckedKeys : curResolvedCheckedKeys;
716
728
 
717
729
  if (_isNumber(max)) {
718
- if (autoMergeValue) {
730
+ if (!isNoneMerge) {
719
731
  // When it exceeds max, the quantity is allowed to be reduced, and no further increase is allowed
720
- if (mergedCheckedKeys.size < curMergedCheckedKeys.size && curMergedCheckedKeys.size > max) {
732
+ if (resolvedCheckedKeys.size < curResolvedCheckedKeys.size && curResolvedCheckedKeys.size > max) {
721
733
  const checkedEntities = [];
722
734
 
723
- _forEachInstanceProperty(curMergedCheckedKeys).call(curMergedCheckedKeys, itemKey => {
735
+ _forEachInstanceProperty(curResolvedCheckedKeys).call(curResolvedCheckedKeys, itemKey => {
724
736
  checkedEntities.push(keyEntities[itemKey]);
725
737
  });
726
738
 
@@ -748,7 +760,7 @@ export default class CascaderFoundation extends BaseFoundation {
748
760
  this._adapter.updateStates({
749
761
  checkedKeys: curCheckedKeys,
750
762
  halfCheckedKeys: curHalfCheckedKeys,
751
- mergedCheckedKeys: curMergedCheckedKeys
763
+ resolvedCheckedKeys: curResolvedCheckedKeys
752
764
  });
753
765
  } // The click event during multiple selection will definitely cause the checked state of node to change,
754
766
  // so there is no need to judge the value to change.
@@ -911,7 +923,7 @@ export default class CascaderFoundation extends BaseFoundation {
911
923
  newState.halfCheckedKeys = new _Set([]);
912
924
  newState.selectedKeys = new _Set([]);
913
925
  newState.activeKeys = new _Set([]);
914
- newState.mergedCheckedKeys = new _Set([]);
926
+ newState.resolvedCheckedKeys = new _Set([]);
915
927
 
916
928
  this._adapter.notifyChange([]);
917
929
  } else {
@@ -2,3 +2,4 @@ export declare function isValid(val: any): boolean;
2
2
  export declare function normalizedArr(val: any): any[];
3
3
  export declare function convertDataToEntities(dataNodes: any): any;
4
4
  export declare function findKeysForValues(value: any, keyEntities: any): any[];
5
+ export declare function calcMergeType(autoMergeValue: boolean, leafOnly: boolean): string;
@@ -8,6 +8,7 @@ import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js-stable/inst
8
8
  import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
9
9
  import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
10
10
  import _Object$values from "@babel/runtime-corejs3/core-js-stable/object/values";
11
+ import { strings } from './constants';
11
12
 
12
13
  function getPosition(level, index) {
13
14
  var _context;
@@ -88,4 +89,17 @@ export function findKeysForValues(value, keyEntities) {
88
89
  const res = _mapInstanceProperty(_context2 = _filterInstanceProperty(_context3 = _Object$values(keyEntities)).call(_context3, item => _isEqual(item.valuePath, valuePath))).call(_context2, item => item.key);
89
90
 
90
91
  return res;
92
+ }
93
+ export function calcMergeType(autoMergeValue, leafOnly) {
94
+ let mergeType;
95
+
96
+ if (leafOnly) {
97
+ mergeType = strings.LEAF_ONLY_MERGE_TYPE;
98
+ } else if (autoMergeValue) {
99
+ mergeType = strings.AUTO_MERGE_VALUE_MERGE_TYPE;
100
+ } else {
101
+ mergeType = strings.NONE_MERGE_TYPE;
102
+ }
103
+
104
+ return mergeType;
91
105
  }
@@ -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?: any): Date | null;
9
+ export declare function compatiableParse(value: string, formatToken?: string, baseDate?: Date, locale?: Locale): Date | null;
@@ -26,7 +26,9 @@ export function compatiableParse(value, formatToken, baseDate, locale) {
26
26
  result = new Date(Date.parse(value));
27
27
  }
28
28
 
29
- if (!isValid(result)) {
29
+ const yearInvalid = isValid(result) && String(result.getFullYear()).length > 4;
30
+
31
+ if (!isValid(result) || yearInvalid) {
30
32
  result = null;
31
33
  }
32
34
  }
@@ -1,4 +1,3 @@
1
- @charset "UTF-8";
2
1
  /* shadow */
3
2
  /* sizing */
4
3
  /* spacing */
@@ -72,6 +71,9 @@
72
71
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, sans-serif;
73
72
  min-height: 24px;
74
73
  }
74
+ .semi-datepicker-month-grid[x-panel-yearandmonth-open-type=left] .semi-datepicker-weeks, .semi-datepicker-month-grid[x-panel-yearandmonth-open-type=right] .semi-datepicker-weeks {
75
+ min-height: 216px;
76
+ }
75
77
  .semi-datepicker-panel-yam {
76
78
  max-width: 284px;
77
79
  }
@@ -96,6 +98,12 @@
96
98
  text-align: right;
97
99
  background-color: var(--semi-color-fill-0);
98
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
+ }
99
107
  .semi-datepicker-yam {
100
108
  position: absolute;
101
109
  top: 0;
@@ -561,6 +569,9 @@
561
569
  .semi-datepicker-compact .semi-datepicker-month-grid .semi-scrolllist-item-wheel .semi-scrolllist-shade-post {
562
570
  margin-top: 17px;
563
571
  }
572
+ .semi-datepicker-compact .semi-datepicker-month-grid[x-panel-yearandmonth-open-type=left] .semi-datepicker-weeks, .semi-datepicker-compact .semi-datepicker-month-grid[x-panel-yearandmonth-open-type=right] .semi-datepicker-weeks {
573
+ min-height: 168px;
574
+ }
564
575
  .semi-datepicker-compact.semi-datepicker-panel-yam .semi-scrolllist {
565
576
  font-size: 12px;
566
577
  line-height: 16px;
@@ -700,6 +711,16 @@
700
711
  padding-left: 8px;
701
712
  text-align: left;
702
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
+ }
703
724
  .semi-rtl .semi-datepicker-day-offsetrange-start .semi-datepicker-day-main,
704
725
  .semi-portal-rtl .semi-datepicker-day-offsetrange-start .semi-datepicker-day-main {
705
726
  border-radius: 0 var(--semi-border-radius-small) var(--semi-border-radius-small) 0;
@@ -735,12 +756,20 @@
735
756
  margin-right: 8px;
736
757
  }
737
758
  .semi-rtl .semi-datepicker-navigation .semi-icon-chevron_left,
738
- .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,
739
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,
740
765
  .semi-portal-rtl .semi-datepicker-navigation .semi-icon-chevron_left,
741
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,
742
769
  .semi-portal-rtl .semi-datepicker-yam .semi-icon-chevron_left,
743
- .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 {
744
773
  transform: scaleX(-1);
745
774
  }
746
775
  .semi-rtl .semi-datepicker-range-input-prefix,
@@ -94,6 +94,15 @@ $module: #{$prefix}-datepicker;
94
94
  min-height: $height-datepicker_timepicker_header_min;
95
95
  }
96
96
  }
97
+
98
+ // 为了防止 scrollList 因为 weeks 变化高度发生变化导致年月可能发生滚动
99
+ // In order to prevent scrollList from scrolling due to changes in the height of weeks, the year and month may be scrolled
100
+ &[x-panel-yearandmonth-open-type="left"],
101
+ &[x-panel-yearandmonth-open-type="right"] {
102
+ .#{$module}-weeks {
103
+ min-height: 6 * $width-datepicker_day;
104
+ }
105
+ }
97
106
  }
98
107
 
99
108
  // 年月选择器
@@ -131,6 +140,17 @@ $module: #{$prefix}-datepicker;
131
140
  padding-bottom: $spacing-datepicker_footer-paddingBottom;
132
141
  text-align: right;
133
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
+ }
134
154
  }
135
155
 
136
156
  // 年月选择
@@ -833,6 +853,15 @@ $module: #{$prefix}-datepicker;
833
853
  }
834
854
  }
835
855
  }
856
+
857
+ // 为了防止 scrollList 因为 weeks 变化高度发生变化导致年月可能发生滚动
858
+ // In order to prevent scrollList from scrolling due to changes in the height of weeks, the year and month may be scrolled
859
+ &[x-panel-yearandmonth-open-type="left"],
860
+ &[x-panel-yearandmonth-open-type="right"] {
861
+ .#{$module}-weeks {
862
+ min-height: 6 * $width-datepicker_day_compact;
863
+ }
864
+ }
836
865
  }
837
866
 
838
867
  // 年月选择器
@@ -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
 
@@ -13,6 +13,7 @@ interface MonthsGridElementProps {
13
13
  renderFullDate?: () => React.ReactNode;
14
14
  }
15
15
  export declare type PanelType = 'left' | 'right';
16
+ export declare type YearMonthChangeType = 'prevMonth' | 'nextMonth' | 'prevYear' | 'nextYear';
16
17
  export interface MonthsGridFoundationProps extends MonthsGridElementProps {
17
18
  type?: Type;
18
19
  defaultValue?: ValueType;
@@ -104,11 +105,34 @@ export default class MonthsGridFoundation extends BaseFoundation<MonthsGridAdapt
104
105
  _initDateTimePickerFromValue(values: BaseValueType[]): void;
105
106
  _initDateTimeRangePickerFormValue(values: BaseValueType[]): void;
106
107
  destroy(): void;
108
+ /**
109
+ * sync change another panel month when change months from the else yam panel
110
+ * call it when
111
+ * - current change panel targe date month is same with another panel date
112
+ *
113
+ * @example
114
+ * - panelType=right, target=new Date('2022-09-01') and left panel is in '2022-09' => call it, left panel minus one month to '2022-08'
115
+ * - panelType=left, target=new Date('2021-12-01') and right panel is in '2021-12' => call it, right panel add one month to '2021-01'
116
+ */
117
+ handleSyncChangeMonths(options: {
118
+ panelType: PanelType;
119
+ target: Date;
120
+ }): void;
121
+ /**
122
+ * Get the target date based on the panel type and switch type
123
+ */
124
+ getTargetChangeDate(options: {
125
+ panelType: PanelType;
126
+ switchType: YearMonthChangeType;
127
+ }): Date;
128
+ /**
129
+ * Change month by yam panel
130
+ */
107
131
  toMonth(panelType: PanelType, target: Date): void;
108
132
  toYear(panelType: PanelType, target: Date): void;
109
133
  toYearMonth(panelType: PanelType, target: Date): void;
110
134
  isRangeType(type?: Type): boolean;
111
- handleSwitchMonth(switchType: 'prevMonth' | 'nextMonth', panelType: PanelType): void;
135
+ handleSwitchMonthOrYear(switchType: YearMonthChangeType, panelType: PanelType): void;
112
136
  prevMonth(panelType: PanelType): void;
113
137
  nextMonth(panelType: PanelType): void;
114
138
  prevYear(panelType: PanelType): void;
@@ -158,13 +182,13 @@ export default class MonthsGridFoundation extends BaseFoundation<MonthsGridAdapt
158
182
  notifyValue: any;
159
183
  notifyDate: any;
160
184
  };
161
- handleYearOrMonthChange(type: 'prevMonth' | 'nextMonth' | 'prevYear' | 'nextYear', panelType?: PanelType, step?: number, notSeparateInRange?: boolean): void;
185
+ handleYearOrMonthChange(type: YearMonthChangeType, panelType?: PanelType, step?: number, notSeparateInRange?: boolean): void;
162
186
  /**
163
187
  * You have chosen to switch the year and month in the future to directly update the Date without closing the date panel
164
188
  * @param {*} type
165
189
  * @param {*} targetDate
166
190
  */
167
- updateDateAfterChangeYM(type: 'prevMonth' | 'nextMonth' | 'prevYear' | 'nextYear', targetDate: Date): void;
191
+ updateDateAfterChangeYM(type: YearMonthChangeType, targetDate: Date): void;
168
192
  _isMultiple(): boolean;
169
193
  _isRange(): void;
170
194
  handleDayClick(day: MonthDayInfo, panelType: PanelType): void;
@@ -214,5 +238,13 @@ export default class MonthsGridFoundation extends BaseFoundation<MonthsGridAdapt
214
238
  showYearPicker(panelType: PanelType): void;
215
239
  showTimePicker(panelType: PanelType, opt?: boolean): void;
216
240
  showDatePanel(panelType: PanelType): void;
241
+ /**
242
+ * Get year and month panel open type
243
+ *
244
+ * It is useful info to set minHeight of weeks.
245
+ * - When yam open type is 'left' or 'right', weeks minHeight should be set
246
+ * If the minHeight is not set, the change of the number of weeks will cause the scrollList to be unstable
247
+ */
248
+ getYAMOpenType(): "left" | "right" | "none" | "both";
217
249
  }
218
250
  export {};