@douyinfe/semi-foundation 2.31.0-beta.0 → 2.31.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.
@@ -18,6 +18,11 @@ class CarouselFoundation<P = Record<string, any>, S = Record<string, any>> exten
18
18
  }
19
19
 
20
20
  _interval = null;
21
+ _forcePlay = false;
22
+
23
+ setForcePlay(forcePlay: boolean) {
24
+ this._forcePlay = forcePlay;
25
+ }
21
26
 
22
27
  play(interval: number): void {
23
28
  if (this._interval) {
@@ -105,7 +110,7 @@ class CarouselFoundation<P = Record<string, any>, S = Record<string, any>> exten
105
110
  getSwitchingTime(): number {
106
111
  const { autoPlay, speed } = this.getProps();
107
112
  const autoPlayType = typeof autoPlay;
108
- if (autoPlayType === 'boolean' && autoPlay){
113
+ if (autoPlayType === 'boolean'){
109
114
  return numbers.DEFAULT_INTERVAL + speed;
110
115
  }
111
116
  if (isObject(autoPlay)){
@@ -121,7 +126,8 @@ class CarouselFoundation<P = Record<string, any>, S = Record<string, any>> exten
121
126
  handleAutoPlay(): void {
122
127
  const { autoPlay } = this.getProps();
123
128
  const autoPlayType = typeof autoPlay;
124
- if ((autoPlayType === 'boolean' && autoPlay) || isObject(autoPlay)){
129
+ // when user manually call the play function, force play
130
+ if ((autoPlayType === 'boolean' && autoPlay) || isObject(autoPlay) || this._forcePlay){
125
131
  this.play(this.getSwitchingTime());
126
132
  }
127
133
  }
@@ -77,8 +77,7 @@ export default class PreviewImageFoundation<P = Record<string, any>, S = Record<
77
77
  }
78
78
 
79
79
  handleWindowResize = (): void => {
80
- const { setRatio } = this.getProps();
81
- const { ratio } = this.getProps();
80
+ const { ratio, setRatio } = this.getProps();
82
81
  const { originImageWidth, originImageHeight } = this._adapter.getOriginImageSize();
83
82
  if (originImageWidth && originImageHeight) {
84
83
  if (ratio !== "adaptation") {
@@ -41,12 +41,6 @@ export default class PreviewInnerFoundation<P = Record<string, any>, S = Record<
41
41
  this._adapter.enabledBodyScroll();
42
42
  }
43
43
 
44
- handleRatio(type: string) {
45
- this.setState({
46
- ratio: type,
47
- } as any);
48
- }
49
-
50
44
  handleViewVisibleChange = () => {
51
45
  const nowTime = new Date().getTime();
52
46
  const mouseActiveTime = this._adapter.getMouseActiveTime();
@@ -9,6 +9,8 @@ export interface CarouselAdapter<P = Record<string, any>, S = Record<string, any
9
9
  declare class CarouselFoundation<P = Record<string, any>, S = Record<string, any>> extends BaseFoundation<CarouselAdapter<P, S>, P, S> {
10
10
  constructor(adapter: CarouselAdapter<P, S>);
11
11
  _interval: any;
12
+ _forcePlay: boolean;
13
+ setForcePlay(forcePlay: boolean): void;
12
14
  play(interval: number): void;
13
15
  stop(): void;
14
16
  goTo(activeIndex: number): void;
@@ -19,6 +19,11 @@ class CarouselFoundation extends _foundation.default {
19
19
  constructor(adapter) {
20
20
  super(Object.assign({}, adapter));
21
21
  this._interval = null;
22
+ this._forcePlay = false;
23
+ }
24
+
25
+ setForcePlay(forcePlay) {
26
+ this._forcePlay = forcePlay;
22
27
  }
23
28
 
24
29
  play(interval) {
@@ -136,7 +141,7 @@ class CarouselFoundation extends _foundation.default {
136
141
  } = this.getProps();
137
142
  const autoPlayType = typeof autoPlay;
138
143
 
139
- if (autoPlayType === 'boolean' && autoPlay) {
144
+ if (autoPlayType === 'boolean') {
140
145
  return _constants.numbers.DEFAULT_INTERVAL + speed;
141
146
  }
142
147
 
@@ -155,9 +160,9 @@ class CarouselFoundation extends _foundation.default {
155
160
  const {
156
161
  autoPlay
157
162
  } = this.getProps();
158
- const autoPlayType = typeof autoPlay;
163
+ const autoPlayType = typeof autoPlay; // when user manually call the play function, force play
159
164
 
160
- if (autoPlayType === 'boolean' && autoPlay || (0, _isObject2.default)(autoPlay)) {
165
+ if (autoPlayType === 'boolean' && autoPlay || (0, _isObject2.default)(autoPlay) || this._forcePlay) {
161
166
  this.play(this.getSwitchingTime());
162
167
  }
163
168
  }
@@ -71,11 +71,9 @@ class PreviewImageFoundation extends _foundation.default {
71
71
 
72
72
  this.handleWindowResize = () => {
73
73
  const {
74
+ ratio,
74
75
  setRatio
75
76
  } = this.getProps();
76
- const {
77
- ratio
78
- } = this.getProps();
79
77
 
80
78
  const {
81
79
  originImageWidth,
@@ -26,7 +26,6 @@ export default class PreviewInnerFoundation<P = Record<string, any>, S = Record<
26
26
  constructor(adapter: PreviewInnerAdapter<P, S>);
27
27
  beforeShow(): void;
28
28
  afterHide(): void;
29
- handleRatio(type: string): void;
30
29
  handleViewVisibleChange: () => void;
31
30
  handleMouseMoveEvent: (e: any, event: string) => void;
32
31
  handleMouseMove: (e: any) => void;
@@ -334,12 +334,6 @@ class PreviewInnerFoundation extends _foundation.default {
334
334
  this._adapter.enabledBodyScroll();
335
335
  }
336
336
 
337
- handleRatio(type) {
338
- this.setState({
339
- ratio: type
340
- });
341
- }
342
-
343
337
  }
344
338
 
345
339
  exports.default = PreviewInnerFoundation;
@@ -23,7 +23,7 @@ export interface SelectAdapter<P = Record<string, any>, S = Record<string, any>>
23
23
  notifyClear(): void;
24
24
  updateInputValue(inputValue: string): void;
25
25
  focusInput(): void;
26
- notifySearch(inputValue: string): void;
26
+ notifySearch(inputValue: string, event?: any): void;
27
27
  registerKeyDown(handler: () => void): void;
28
28
  unregisterKeyDown(): void;
29
29
  notifyChange(value: string | BasicOptionProps | (string | BasicOptionProps)[]): void;
@@ -78,9 +78,9 @@ export default class SelectFoundation extends BaseFoundation<SelectAdapter> {
78
78
  clearSelected(): void;
79
79
  updateOptionsActiveStatus(selections: Map<any, any>, options?: BasicOptionProps[]): void;
80
80
  removeTag(item: BasicOptionProps): void;
81
- clearInput(): void;
81
+ clearInput(event?: any): void;
82
82
  focusInput(): void;
83
- handleInputChange(sugInput: string): void;
83
+ handleInputChange(sugInput: string, event: any): void;
84
84
  _filterOption(originalOptions: BasicOptionProps[], sugInput: string): BasicOptionProps[];
85
85
  _createOptionByInput(allowCreate: boolean, optionsAfterFilter: BasicOptionProps[], sugInput: string): BasicOptionProps[];
86
86
  bindKeyBoardEvent(): void;
@@ -461,7 +461,7 @@ class SelectFoundation extends _foundation.default {
461
461
 
462
462
  this._adapter.once('popoverClose', () => {
463
463
  if (isFilterable) {
464
- this.clearInput();
464
+ this.clearInput(e);
465
465
  }
466
466
 
467
467
  if (closeCb) {
@@ -579,7 +579,7 @@ class SelectFoundation extends _foundation.default {
579
579
 
580
580
  if (this._isFilterable()) {
581
581
  if (autoClearSearchValue) {
582
- this.clearInput();
582
+ this.clearInput(event);
583
583
  }
584
584
 
585
585
  this.focusInput();
@@ -599,7 +599,7 @@ class SelectFoundation extends _foundation.default {
599
599
  if (this._isFilterable()) {
600
600
  // When filter active,if autoClearSearchValue is true,reset input after select
601
601
  if (autoClearSearchValue) {
602
- this.clearInput(); // At the same time, the filtering of options is also cleared, in order to show all candidates
602
+ this.clearInput(event); // At the same time, the filtering of options is also cleared, in order to show all candidates
603
603
 
604
604
  const sugInput = '';
605
605
  options = this._filterOption(options, sugInput);
@@ -689,9 +689,10 @@ class SelectFoundation extends _foundation.default {
689
689
 
690
690
  this._notifyChange(selections);
691
691
  }
692
- }
692
+ } // The reason why event input is optional is that clearInput may be manually called by the user through ref
693
+
693
694
 
694
- clearInput() {
695
+ clearInput(event) {
695
696
  const {
696
697
  inputValue
697
698
  } = this.getStates(); // only when input is not null, select should notifySearch and updateOptions
@@ -699,7 +700,7 @@ class SelectFoundation extends _foundation.default {
699
700
  if (inputValue !== '') {
700
701
  this._adapter.updateInputValue('');
701
702
 
702
- this._adapter.notifySearch(''); // reset options filter
703
+ this._adapter.notifySearch('', event); // reset options filter
703
704
 
704
705
 
705
706
  const {
@@ -726,7 +727,7 @@ class SelectFoundation extends _foundation.default {
726
727
  this._adapter.setIsFocusInContainer(false);
727
728
  }
728
729
 
729
- handleInputChange(sugInput) {
730
+ handleInputChange(sugInput, event) {
730
731
  // Input is a controlled component, so the value needs to be updated
731
732
  this._adapter.updateInputValue(sugInput);
732
733
 
@@ -750,7 +751,7 @@ class SelectFoundation extends _foundation.default {
750
751
 
751
752
  this._adapter.updateOptions(optionsAfterFilter);
752
753
 
753
- this._adapter.notifySearch(sugInput); // In multi-select mode, the drop-down box is repositioned each time you enter, because it may cause a line break as the input changes
754
+ this._adapter.notifySearch(sugInput, event); // In multi-select mode, the drop-down box is repositioned each time you enter, because it may cause a line break as the input changes
754
755
 
755
756
 
756
757
  if (this._isMultiple()) {
@@ -1026,7 +1027,7 @@ class SelectFoundation extends _foundation.default {
1026
1027
  }
1027
1028
  } else {
1028
1029
  // there are no focusable elements inside the container, tab to next element and trigger blur
1029
- this.close();
1030
+ this.close(event);
1030
1031
 
1031
1032
  this._notifyBlur(event);
1032
1033
  }
@@ -1052,7 +1053,7 @@ class SelectFoundation extends _foundation.default {
1052
1053
  // focus in the last element in container, focus back to trigger and close panel
1053
1054
  this._focusTrigger();
1054
1055
 
1055
- this.close();
1056
+ this.close(event);
1056
1057
  (0, _a11y.handlePrevent)(event);
1057
1058
  }
1058
1059
  }
@@ -1064,7 +1065,7 @@ class SelectFoundation extends _foundation.default {
1064
1065
 
1065
1066
  if (!isFocusInContainer) {
1066
1067
  // focus in trigger, close the panel, shift tab to previe element and trigger blur
1067
- this.close();
1068
+ this.close(event);
1068
1069
 
1069
1070
  this._notifyBlur(event);
1070
1071
  } else if (activeElement === focusableElements[0]) {
@@ -1107,7 +1108,7 @@ class SelectFoundation extends _foundation.default {
1107
1108
  this.onSelect(selectedOption, focusIndex, event);
1108
1109
  }
1109
1110
  } else {
1110
- this.close();
1111
+ this.close(event);
1111
1112
  }
1112
1113
  }
1113
1114
  }
@@ -1286,7 +1287,7 @@ class SelectFoundation extends _foundation.default {
1286
1287
  } = this.getProps();
1287
1288
 
1288
1289
  if (filter) {
1289
- this.clearInput();
1290
+ this.clearInput(e);
1290
1291
  }
1291
1292
 
1292
1293
  this.clearSelected(); // prevent this click open dropdown
@@ -54,6 +54,9 @@ export interface TableAdapter<RecordType> extends DefaultAdapter {
54
54
  getCachedFilteredSortedDataSource: () => RecordType[];
55
55
  getCachedFilteredSortedRowKeys: () => BaseRowKeyType[];
56
56
  getCachedFilteredSortedRowKeysSet: () => Set<BaseRowKeyType>;
57
+ setAllDisabledRowKeys: (allDisabledRowKeys: BaseRowKeyType[]) => void;
58
+ getAllDisabledRowKeys: () => BaseRowKeyType[];
59
+ getAllDisabledRowKeysSet: () => Set<BaseRowKeyType>;
57
60
  notifyFilterDropdownVisibleChange: (visible: boolean, dataIndex: string) => void;
58
61
  notifyChange: (changeInfo: {
59
62
  pagination: BasePagination;
@@ -159,6 +162,7 @@ declare class TableFoundation<RecordType> extends BaseFoundation<TableAdapter<Re
159
162
  */
160
163
  setCachedFilteredSortedDataSource: (filteredSortedDataSource: RecordType[]) => void;
161
164
  destroy(): void;
165
+ setAllDisabledRowKeys(disabledRowKeys: any): void;
162
166
  handleClick(e: any): void;
163
167
  handleMouseEnter(e: any): void;
164
168
  handleMouseLeave(e: any): void;
@@ -166,12 +166,14 @@ class TableFoundation extends _foundation.default {
166
166
  } = this._adapter.getStates();
167
167
 
168
168
  const filteredSortedDataSource = this.getFilteredSortedDataSource(dataSource, queries);
169
+ const allDataDisabledRowKeys = this.getAllDisabledRowKeys(filteredSortedDataSource);
169
170
  const pageData = this.getCurrentPageData(filteredSortedDataSource);
170
171
  this.setAdapterPageData(pageData);
171
172
  this.initExpandedRowKeys(pageData);
172
173
  this.initSelectedRowKeys(pageData); // cache dataSource after mount, and then calculate it on demand
173
174
 
174
175
  this.setCachedFilteredSortedDataSource(filteredSortedDataSource);
176
+ this.setAllDisabledRowKeys(allDataDisabledRowKeys);
175
177
  }
176
178
 
177
179
  initExpandedRowKeys() {
@@ -525,6 +527,10 @@ class TableFoundation extends _foundation.default {
525
527
 
526
528
  destroy() {}
527
529
 
530
+ setAllDisabledRowKeys(disabledRowKeys) {
531
+ this._adapter.setAllDisabledRowKeys(disabledRowKeys);
532
+ }
533
+
528
534
  handleClick(e) {}
529
535
 
530
536
  handleMouseEnter(e) {}
@@ -774,8 +780,11 @@ class TableFoundation extends _foundation.default {
774
780
  const selectedRowKeysSet = this._getSelectedRowKeysSet();
775
781
 
776
782
  let allRowKeys = [...this._adapter.getCachedFilteredSortedRowKeys()];
777
- const disabledRowKeys = this.getAllDisabledRowKeys();
778
- const disabledRowKeysSet = new Set(disabledRowKeys);
783
+
784
+ const disabledRowKeys = this._adapter.getAllDisabledRowKeys();
785
+
786
+ const disabledRowKeysSet = this._adapter.getAllDisabledRowKeysSet();
787
+
779
788
  let changedRowKeys; // Select all, if not disabled && not in selectedRowKeys
780
789
 
781
790
  if (selected) {
@@ -1142,7 +1151,9 @@ class TableFoundation extends _foundation.default {
1142
1151
  handleClickFilterOrSorter(queries) {
1143
1152
  const dataSource = [...this.getProp('dataSource')];
1144
1153
  const sortedDataSource = this.getFilteredSortedDataSource(dataSource, queries);
1154
+ const allDataDisabledRowKeys = this.getAllDisabledRowKeys(sortedDataSource);
1145
1155
  this.setCachedFilteredSortedDataSource(sortedDataSource);
1156
+ this.setAllDisabledRowKeys(allDataDisabledRowKeys);
1146
1157
  const pageData = this.getCurrentPageData(sortedDataSource);
1147
1158
  this.setAdapterPageData(pageData);
1148
1159
  }
@@ -9,6 +9,8 @@ export interface CarouselAdapter<P = Record<string, any>, S = Record<string, any
9
9
  declare class CarouselFoundation<P = Record<string, any>, S = Record<string, any>> extends BaseFoundation<CarouselAdapter<P, S>, P, S> {
10
10
  constructor(adapter: CarouselAdapter<P, S>);
11
11
  _interval: any;
12
+ _forcePlay: boolean;
13
+ setForcePlay(forcePlay: boolean): void;
12
14
  play(interval: number): void;
13
15
  stop(): void;
14
16
  goTo(activeIndex: number): void;
@@ -7,6 +7,11 @@ class CarouselFoundation extends BaseFoundation {
7
7
  constructor(adapter) {
8
8
  super(Object.assign({}, adapter));
9
9
  this._interval = null;
10
+ this._forcePlay = false;
11
+ }
12
+
13
+ setForcePlay(forcePlay) {
14
+ this._forcePlay = forcePlay;
10
15
  }
11
16
 
12
17
  play(interval) {
@@ -124,7 +129,7 @@ class CarouselFoundation extends BaseFoundation {
124
129
  } = this.getProps();
125
130
  const autoPlayType = typeof autoPlay;
126
131
 
127
- if (autoPlayType === 'boolean' && autoPlay) {
132
+ if (autoPlayType === 'boolean') {
128
133
  return numbers.DEFAULT_INTERVAL + speed;
129
134
  }
130
135
 
@@ -143,9 +148,9 @@ class CarouselFoundation extends BaseFoundation {
143
148
  const {
144
149
  autoPlay
145
150
  } = this.getProps();
146
- const autoPlayType = typeof autoPlay;
151
+ const autoPlayType = typeof autoPlay; // when user manually call the play function, force play
147
152
 
148
- if (autoPlayType === 'boolean' && autoPlay || _isObject(autoPlay)) {
153
+ if (autoPlayType === 'boolean' && autoPlay || _isObject(autoPlay) || this._forcePlay) {
149
154
  this.play(this.getSwitchingTime());
150
155
  }
151
156
  }
@@ -57,11 +57,9 @@ export default class PreviewImageFoundation extends BaseFoundation {
57
57
 
58
58
  this.handleWindowResize = () => {
59
59
  const {
60
+ ratio,
60
61
  setRatio
61
62
  } = this.getProps();
62
- const {
63
- ratio
64
- } = this.getProps();
65
63
 
66
64
  const {
67
65
  originImageWidth,
@@ -26,7 +26,6 @@ export default class PreviewInnerFoundation<P = Record<string, any>, S = Record<
26
26
  constructor(adapter: PreviewInnerAdapter<P, S>);
27
27
  beforeShow(): void;
28
28
  afterHide(): void;
29
- handleRatio(type: string): void;
30
29
  handleViewVisibleChange: () => void;
31
30
  handleMouseMoveEvent: (e: any, event: string) => void;
32
31
  handleMouseMove: (e: any) => void;
@@ -321,10 +321,4 @@ export default class PreviewInnerFoundation extends BaseFoundation {
321
321
  this._adapter.enabledBodyScroll();
322
322
  }
323
323
 
324
- handleRatio(type) {
325
- this.setState({
326
- ratio: type
327
- });
328
- }
329
-
330
324
  }
@@ -23,7 +23,7 @@ export interface SelectAdapter<P = Record<string, any>, S = Record<string, any>>
23
23
  notifyClear(): void;
24
24
  updateInputValue(inputValue: string): void;
25
25
  focusInput(): void;
26
- notifySearch(inputValue: string): void;
26
+ notifySearch(inputValue: string, event?: any): void;
27
27
  registerKeyDown(handler: () => void): void;
28
28
  unregisterKeyDown(): void;
29
29
  notifyChange(value: string | BasicOptionProps | (string | BasicOptionProps)[]): void;
@@ -78,9 +78,9 @@ export default class SelectFoundation extends BaseFoundation<SelectAdapter> {
78
78
  clearSelected(): void;
79
79
  updateOptionsActiveStatus(selections: Map<any, any>, options?: BasicOptionProps[]): void;
80
80
  removeTag(item: BasicOptionProps): void;
81
- clearInput(): void;
81
+ clearInput(event?: any): void;
82
82
  focusInput(): void;
83
- handleInputChange(sugInput: string): void;
83
+ handleInputChange(sugInput: string, event: any): void;
84
84
  _filterOption(originalOptions: BasicOptionProps[], sugInput: string): BasicOptionProps[];
85
85
  _createOptionByInput(allowCreate: boolean, optionsAfterFilter: BasicOptionProps[], sugInput: string): BasicOptionProps[];
86
86
  bindKeyBoardEvent(): void;
@@ -439,7 +439,7 @@ export default class SelectFoundation extends BaseFoundation {
439
439
 
440
440
  this._adapter.once('popoverClose', () => {
441
441
  if (isFilterable) {
442
- this.clearInput();
442
+ this.clearInput(e);
443
443
  }
444
444
 
445
445
  if (closeCb) {
@@ -557,7 +557,7 @@ export default class SelectFoundation extends BaseFoundation {
557
557
 
558
558
  if (this._isFilterable()) {
559
559
  if (autoClearSearchValue) {
560
- this.clearInput();
560
+ this.clearInput(event);
561
561
  }
562
562
 
563
563
  this.focusInput();
@@ -577,7 +577,7 @@ export default class SelectFoundation extends BaseFoundation {
577
577
  if (this._isFilterable()) {
578
578
  // When filter active,if autoClearSearchValue is true,reset input after select
579
579
  if (autoClearSearchValue) {
580
- this.clearInput(); // At the same time, the filtering of options is also cleared, in order to show all candidates
580
+ this.clearInput(event); // At the same time, the filtering of options is also cleared, in order to show all candidates
581
581
 
582
582
  const sugInput = '';
583
583
  options = this._filterOption(options, sugInput);
@@ -667,9 +667,10 @@ export default class SelectFoundation extends BaseFoundation {
667
667
 
668
668
  this._notifyChange(selections);
669
669
  }
670
- }
670
+ } // The reason why event input is optional is that clearInput may be manually called by the user through ref
671
+
671
672
 
672
- clearInput() {
673
+ clearInput(event) {
673
674
  const {
674
675
  inputValue
675
676
  } = this.getStates(); // only when input is not null, select should notifySearch and updateOptions
@@ -677,7 +678,7 @@ export default class SelectFoundation extends BaseFoundation {
677
678
  if (inputValue !== '') {
678
679
  this._adapter.updateInputValue('');
679
680
 
680
- this._adapter.notifySearch(''); // reset options filter
681
+ this._adapter.notifySearch('', event); // reset options filter
681
682
 
682
683
 
683
684
  const {
@@ -704,7 +705,7 @@ export default class SelectFoundation extends BaseFoundation {
704
705
  this._adapter.setIsFocusInContainer(false);
705
706
  }
706
707
 
707
- handleInputChange(sugInput) {
708
+ handleInputChange(sugInput, event) {
708
709
  // Input is a controlled component, so the value needs to be updated
709
710
  this._adapter.updateInputValue(sugInput);
710
711
 
@@ -728,7 +729,7 @@ export default class SelectFoundation extends BaseFoundation {
728
729
 
729
730
  this._adapter.updateOptions(optionsAfterFilter);
730
731
 
731
- this._adapter.notifySearch(sugInput); // In multi-select mode, the drop-down box is repositioned each time you enter, because it may cause a line break as the input changes
732
+ this._adapter.notifySearch(sugInput, event); // In multi-select mode, the drop-down box is repositioned each time you enter, because it may cause a line break as the input changes
732
733
 
733
734
 
734
735
  if (this._isMultiple()) {
@@ -1004,7 +1005,7 @@ export default class SelectFoundation extends BaseFoundation {
1004
1005
  }
1005
1006
  } else {
1006
1007
  // there are no focusable elements inside the container, tab to next element and trigger blur
1007
- this.close();
1008
+ this.close(event);
1008
1009
 
1009
1010
  this._notifyBlur(event);
1010
1011
  }
@@ -1030,7 +1031,7 @@ export default class SelectFoundation extends BaseFoundation {
1030
1031
  // focus in the last element in container, focus back to trigger and close panel
1031
1032
  this._focusTrigger();
1032
1033
 
1033
- this.close();
1034
+ this.close(event);
1034
1035
  handlePrevent(event);
1035
1036
  }
1036
1037
  }
@@ -1042,7 +1043,7 @@ export default class SelectFoundation extends BaseFoundation {
1042
1043
 
1043
1044
  if (!isFocusInContainer) {
1044
1045
  // focus in trigger, close the panel, shift tab to previe element and trigger blur
1045
- this.close();
1046
+ this.close(event);
1046
1047
 
1047
1048
  this._notifyBlur(event);
1048
1049
  } else if (activeElement === focusableElements[0]) {
@@ -1085,7 +1086,7 @@ export default class SelectFoundation extends BaseFoundation {
1085
1086
  this.onSelect(selectedOption, focusIndex, event);
1086
1087
  }
1087
1088
  } else {
1088
- this.close();
1089
+ this.close(event);
1089
1090
  }
1090
1091
  }
1091
1092
  }
@@ -1264,7 +1265,7 @@ export default class SelectFoundation extends BaseFoundation {
1264
1265
  } = this.getProps();
1265
1266
 
1266
1267
  if (filter) {
1267
- this.clearInput();
1268
+ this.clearInput(e);
1268
1269
  }
1269
1270
 
1270
1271
  this.clearSelected(); // prevent this click open dropdown
@@ -54,6 +54,9 @@ export interface TableAdapter<RecordType> extends DefaultAdapter {
54
54
  getCachedFilteredSortedDataSource: () => RecordType[];
55
55
  getCachedFilteredSortedRowKeys: () => BaseRowKeyType[];
56
56
  getCachedFilteredSortedRowKeysSet: () => Set<BaseRowKeyType>;
57
+ setAllDisabledRowKeys: (allDisabledRowKeys: BaseRowKeyType[]) => void;
58
+ getAllDisabledRowKeys: () => BaseRowKeyType[];
59
+ getAllDisabledRowKeysSet: () => Set<BaseRowKeyType>;
57
60
  notifyFilterDropdownVisibleChange: (visible: boolean, dataIndex: string) => void;
58
61
  notifyChange: (changeInfo: {
59
62
  pagination: BasePagination;
@@ -159,6 +162,7 @@ declare class TableFoundation<RecordType> extends BaseFoundation<TableAdapter<Re
159
162
  */
160
163
  setCachedFilteredSortedDataSource: (filteredSortedDataSource: RecordType[]) => void;
161
164
  destroy(): void;
165
+ setAllDisabledRowKeys(disabledRowKeys: any): void;
162
166
  handleClick(e: any): void;
163
167
  handleMouseEnter(e: any): void;
164
168
  handleMouseLeave(e: any): void;
@@ -141,12 +141,14 @@ class TableFoundation extends BaseFoundation {
141
141
  } = this._adapter.getStates();
142
142
 
143
143
  const filteredSortedDataSource = this.getFilteredSortedDataSource(dataSource, queries);
144
+ const allDataDisabledRowKeys = this.getAllDisabledRowKeys(filteredSortedDataSource);
144
145
  const pageData = this.getCurrentPageData(filteredSortedDataSource);
145
146
  this.setAdapterPageData(pageData);
146
147
  this.initExpandedRowKeys(pageData);
147
148
  this.initSelectedRowKeys(pageData); // cache dataSource after mount, and then calculate it on demand
148
149
 
149
150
  this.setCachedFilteredSortedDataSource(filteredSortedDataSource);
151
+ this.setAllDisabledRowKeys(allDataDisabledRowKeys);
150
152
  }
151
153
 
152
154
  initExpandedRowKeys() {
@@ -508,6 +510,10 @@ class TableFoundation extends BaseFoundation {
508
510
 
509
511
  destroy() {}
510
512
 
513
+ setAllDisabledRowKeys(disabledRowKeys) {
514
+ this._adapter.setAllDisabledRowKeys(disabledRowKeys);
515
+ }
516
+
511
517
  handleClick(e) {}
512
518
 
513
519
  handleMouseEnter(e) {}
@@ -766,8 +772,11 @@ class TableFoundation extends BaseFoundation {
766
772
  const selectedRowKeysSet = this._getSelectedRowKeysSet();
767
773
 
768
774
  let allRowKeys = [...this._adapter.getCachedFilteredSortedRowKeys()];
769
- const disabledRowKeys = this.getAllDisabledRowKeys();
770
- const disabledRowKeysSet = new Set(disabledRowKeys);
775
+
776
+ const disabledRowKeys = this._adapter.getAllDisabledRowKeys();
777
+
778
+ const disabledRowKeysSet = this._adapter.getAllDisabledRowKeysSet();
779
+
771
780
  let changedRowKeys; // Select all, if not disabled && not in selectedRowKeys
772
781
 
773
782
  if (selected) {
@@ -1141,7 +1150,9 @@ class TableFoundation extends BaseFoundation {
1141
1150
  handleClickFilterOrSorter(queries) {
1142
1151
  const dataSource = [...this.getProp('dataSource')];
1143
1152
  const sortedDataSource = this.getFilteredSortedDataSource(dataSource, queries);
1153
+ const allDataDisabledRowKeys = this.getAllDisabledRowKeys(sortedDataSource);
1144
1154
  this.setCachedFilteredSortedDataSource(sortedDataSource);
1155
+ this.setAllDisabledRowKeys(allDataDisabledRowKeys);
1145
1156
  const pageData = this.getCurrentPageData(sortedDataSource);
1146
1157
  this.setAdapterPageData(pageData);
1147
1158
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@douyinfe/semi-foundation",
3
- "version": "2.31.0-beta.0",
3
+ "version": "2.31.1",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "build:lib": "node ./scripts/compileLib.js",
@@ -23,7 +23,7 @@
23
23
  "*.scss",
24
24
  "*.css"
25
25
  ],
26
- "gitHead": "8b378259f169ca3bfb9af17118e962d717efa685",
26
+ "gitHead": "00ded133e899ea816cbefe20eebcdb60fd983ecc",
27
27
  "devDependencies": {
28
28
  "@babel/plugin-transform-runtime": "^7.15.8",
29
29
  "@babel/preset-env": "^7.15.8",
@@ -32,7 +32,7 @@ export interface SelectAdapter<P = Record<string, any>, S = Record<string, any>>
32
32
  notifyClear(): void;
33
33
  updateInputValue(inputValue: string): void;
34
34
  focusInput(): void;
35
- notifySearch(inputValue: string): void;
35
+ notifySearch(inputValue: string, event?: any): void;
36
36
  registerKeyDown(handler: () => void): void;
37
37
  unregisterKeyDown(): void;
38
38
  notifyChange(value: string | BasicOptionProps | (string | BasicOptionProps)[]): void;
@@ -396,7 +396,7 @@ export default class SelectFoundation extends BaseFoundation<SelectAdapter> {
396
396
 
397
397
  this._adapter.once('popoverClose', () => {
398
398
  if (isFilterable) {
399
- this.clearInput();
399
+ this.clearInput(e);
400
400
  }
401
401
  if (closeCb) {
402
402
  closeCb();
@@ -467,7 +467,7 @@ export default class SelectFoundation extends BaseFoundation<SelectAdapter> {
467
467
  this._notifyChange(selections);
468
468
  if (this._isFilterable()) {
469
469
  if (autoClearSearchValue) {
470
- this.clearInput();
470
+ this.clearInput(event);
471
471
  }
472
472
  this.focusInput();
473
473
  }
@@ -482,7 +482,7 @@ export default class SelectFoundation extends BaseFoundation<SelectAdapter> {
482
482
  if (this._isFilterable()) {
483
483
  // When filter active,if autoClearSearchValue is true,reset input after select
484
484
  if (autoClearSearchValue) {
485
- this.clearInput();
485
+ this.clearInput(event);
486
486
  // At the same time, the filtering of options is also cleared, in order to show all candidates
487
487
  const sugInput = '';
488
488
  options = this._filterOption(options, sugInput);
@@ -550,12 +550,14 @@ export default class SelectFoundation extends BaseFoundation<SelectAdapter> {
550
550
  }
551
551
  }
552
552
 
553
- clearInput() {
553
+
554
+ // The reason why event input is optional is that clearInput may be manually called by the user through ref
555
+ clearInput(event?: any) {
554
556
  const { inputValue } = this.getStates();
555
557
  // only when input is not null, select should notifySearch and updateOptions
556
558
  if (inputValue !== ''){
557
559
  this._adapter.updateInputValue('');
558
- this._adapter.notifySearch('');
560
+ this._adapter.notifySearch('', event);
559
561
  // reset options filter
560
562
  const { options } = this.getStates();
561
563
  const { remote } = this.getProps();
@@ -573,7 +575,7 @@ export default class SelectFoundation extends BaseFoundation<SelectAdapter> {
573
575
  this._adapter.setIsFocusInContainer(false);
574
576
  }
575
577
 
576
- handleInputChange(sugInput: string) {
578
+ handleInputChange(sugInput: string, event: any) {
577
579
  // Input is a controlled component, so the value needs to be updated
578
580
  this._adapter.updateInputValue(sugInput);
579
581
  const { options, isOpen } = this.getStates();
@@ -589,7 +591,7 @@ export default class SelectFoundation extends BaseFoundation<SelectAdapter> {
589
591
  optionsAfterFilter = this._createOptionByInput(allowCreate, optionsAfterFilter, sugInput);
590
592
 
591
593
  this._adapter.updateOptions(optionsAfterFilter);
592
- this._adapter.notifySearch(sugInput);
594
+ this._adapter.notifySearch(sugInput, event);
593
595
  // In multi-select mode, the drop-down box is repositioned each time you enter, because it may cause a line break as the input changes
594
596
  if (this._isMultiple()) {
595
597
  this._adapter.rePositionDropdown();
@@ -809,7 +811,7 @@ export default class SelectFoundation extends BaseFoundation<SelectAdapter> {
809
811
  }
810
812
  } else {
811
813
  // there are no focusable elements inside the container, tab to next element and trigger blur
812
- this.close();
814
+ this.close(event);
813
815
  this._notifyBlur(event);
814
816
  }
815
817
  } else {
@@ -829,7 +831,7 @@ export default class SelectFoundation extends BaseFoundation<SelectAdapter> {
829
831
  } else if (activeElement === focusableElements[focusableElements.length - 1]) {
830
832
  // focus in the last element in container, focus back to trigger and close panel
831
833
  this._focusTrigger();
832
- this.close();
834
+ this.close(event);
833
835
  handlePrevent(event);
834
836
  }
835
837
  }
@@ -840,7 +842,7 @@ export default class SelectFoundation extends BaseFoundation<SelectAdapter> {
840
842
 
841
843
  if (!isFocusInContainer) {
842
844
  // focus in trigger, close the panel, shift tab to previe element and trigger blur
843
- this.close();
845
+ this.close(event);
844
846
  this._notifyBlur(event);
845
847
  } else if (activeElement === focusableElements[0]) {
846
848
  // focus in the first element in container, focus back to trigger
@@ -870,7 +872,7 @@ export default class SelectFoundation extends BaseFoundation<SelectAdapter> {
870
872
  this.onSelect(selectedOption, focusIndex, event);
871
873
  }
872
874
  } else {
873
- this.close();
875
+ this.close(event);
874
876
  }
875
877
  }
876
878
  }
@@ -1018,7 +1020,7 @@ export default class SelectFoundation extends BaseFoundation<SelectAdapter> {
1018
1020
  handleClearClick(e: MouseEvent) {
1019
1021
  const { filter } = this.getProps();
1020
1022
  if (filter) {
1021
- this.clearInput();
1023
+ this.clearInput(e);
1022
1024
  }
1023
1025
  this.clearSelected();
1024
1026
  // prevent this click open dropdown
@@ -82,6 +82,9 @@ export interface TableAdapter<RecordType> extends DefaultAdapter {
82
82
  getCachedFilteredSortedDataSource: () => RecordType[];
83
83
  getCachedFilteredSortedRowKeys: () => BaseRowKeyType[];
84
84
  getCachedFilteredSortedRowKeysSet: () => Set<BaseRowKeyType>;
85
+ setAllDisabledRowKeys: (allDisabledRowKeys: BaseRowKeyType[]) => void;
86
+ getAllDisabledRowKeys: () => BaseRowKeyType[];
87
+ getAllDisabledRowKeysSet: () => Set<BaseRowKeyType>;
85
88
  notifyFilterDropdownVisibleChange: (visible: boolean, dataIndex: string) => void;
86
89
  notifyChange: (changeInfo: { pagination: BasePagination; filters: BaseChangeInfoFilter<RecordType>[]; sorter: BaseChangeInfoSorter<RecordType>; extra: any }) => void;
87
90
  notifyExpand: (expanded?: boolean, record?: BaseIncludeGroupRecord<RecordType>, mouseEvent?: any) => void;
@@ -174,12 +177,14 @@ class TableFoundation<RecordType> extends BaseFoundation<TableAdapter<RecordType
174
177
  const dataSource = [...this.getProp('dataSource')];
175
178
  const { queries } = this._adapter.getStates();
176
179
  const filteredSortedDataSource = this.getFilteredSortedDataSource(dataSource, queries);
180
+ const allDataDisabledRowKeys = this.getAllDisabledRowKeys(filteredSortedDataSource);
177
181
  const pageData = this.getCurrentPageData(filteredSortedDataSource);
178
182
  this.setAdapterPageData(pageData);
179
183
  this.initExpandedRowKeys(pageData);
180
184
  this.initSelectedRowKeys(pageData);
181
185
  // cache dataSource after mount, and then calculate it on demand
182
186
  this.setCachedFilteredSortedDataSource(filteredSortedDataSource);
187
+ this.setAllDisabledRowKeys(allDataDisabledRowKeys);
183
188
  }
184
189
 
185
190
  initExpandedRowKeys({ groups }: { groups?: Map<string, RecordType[]> } = {}) {
@@ -553,6 +558,10 @@ class TableFoundation<RecordType> extends BaseFoundation<TableAdapter<RecordType
553
558
 
554
559
  destroy() { }
555
560
 
561
+ setAllDisabledRowKeys(disabledRowKeys) {
562
+ this._adapter.setAllDisabledRowKeys(disabledRowKeys);
563
+ }
564
+
556
565
  handleClick(e: any) { }
557
566
 
558
567
  handleMouseEnter(e: any) { }
@@ -784,8 +793,8 @@ class TableFoundation<RecordType> extends BaseFoundation<TableAdapter<RecordType
784
793
  let selectedRowKeys = [...curSelectedRowKeys];
785
794
  const selectedRowKeysSet = this._getSelectedRowKeysSet();
786
795
  let allRowKeys = [...this._adapter.getCachedFilteredSortedRowKeys()];
787
- const disabledRowKeys = this.getAllDisabledRowKeys();
788
- const disabledRowKeysSet = new Set(disabledRowKeys);
796
+ const disabledRowKeys = this._adapter.getAllDisabledRowKeys();
797
+ const disabledRowKeysSet = this._adapter.getAllDisabledRowKeysSet();
789
798
  let changedRowKeys;
790
799
 
791
800
  // Select all, if not disabled && not in selectedRowKeys
@@ -1130,7 +1139,9 @@ class TableFoundation<RecordType> extends BaseFoundation<TableAdapter<RecordType
1130
1139
  handleClickFilterOrSorter(queries: BaseColumnProps<RecordType>[]) {
1131
1140
  const dataSource = [...this.getProp('dataSource')];
1132
1141
  const sortedDataSource = this.getFilteredSortedDataSource(dataSource, queries);
1142
+ const allDataDisabledRowKeys = this.getAllDisabledRowKeys(sortedDataSource);
1133
1143
  this.setCachedFilteredSortedDataSource(sortedDataSource);
1144
+ this.setAllDisabledRowKeys(allDataDisabledRowKeys);
1134
1145
  const pageData = this.getCurrentPageData(sortedDataSource);
1135
1146
  this.setAdapterPageData(pageData);
1136
1147
  }