@douyinfe/semi-foundation 2.49.1 → 2.49.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -328,6 +328,9 @@ class SelectFoundation extends _foundation.default {
328
328
  const newOptions = this._filterOption(options, sugInput).filter(item => !item._inputCreateOnly);
329
329
  this._adapter.updateOptions(newOptions);
330
330
  this.toggle2SearchInput(true);
331
+ } else {
332
+ // whether it is a filter or not, isFocus is guaranteed to be true when open
333
+ this._adapter.updateFocusState(true);
331
334
  }
332
335
  this._adapter.openMenu();
333
336
  this._setDropdownWidth();
@@ -337,7 +340,6 @@ class SelectFoundation extends _foundation.default {
337
340
  this.close(e);
338
341
  this._notifyBlur(e);
339
342
  this._adapter.updateFocusState(false);
340
- this._adapter.unregisterClickOutsideHandler();
341
343
  });
342
344
  }
343
345
  toggle2SearchInput(isShow) {
@@ -356,6 +358,7 @@ class SelectFoundation extends _foundation.default {
356
358
  // this.unBindKeyBoardEvent();
357
359
  // this._notifyBlur(e);
358
360
  // this._adapter.updateFocusState(false);
361
+ this._adapter.unregisterClickOutsideHandler();
359
362
  const isFilterable = this._isFilterable();
360
363
  if (isFilterable) {
361
364
  this.toggle2SearchInput(false);
@@ -1042,7 +1045,6 @@ class SelectFoundation extends _foundation.default {
1042
1045
  this._adapter.setIsFocusInContainer(false);
1043
1046
  }
1044
1047
  handleTriggerBlur(e) {
1045
- this._adapter.updateFocusState(false);
1046
1048
  const {
1047
1049
  filter,
1048
1050
  autoFocus
@@ -1055,6 +1057,7 @@ class SelectFoundation extends _foundation.default {
1055
1057
  // But when autoFocus or the panel is close, because clickOutsideHandler is not register or unregister, you need to listen for the trigger's blur and trigger the notify callback
1056
1058
  if (isFocus && !isOpen) {
1057
1059
  this._notifyBlur(e);
1060
+ this._adapter.updateFocusState(false);
1058
1061
  }
1059
1062
  }
1060
1063
  handleInputBlur(e) {
@@ -84,6 +84,10 @@ $basicType: #{$module}-basic;
84
84
  display: flex;
85
85
  flex-flow: column nowrap;
86
86
 
87
+ .#{$item}-icon {
88
+ box-sizing: content-box;
89
+ }
90
+
87
91
  &.#{$module}-small {
88
92
  .#{$item} {
89
93
  .#{$item}-content {
@@ -204,6 +204,9 @@
204
204
  display: flex;
205
205
  flex-flow: column nowrap;
206
206
  }
207
+ .semi-steps-basic.semi-steps-vertical .semi-steps-item-icon {
208
+ box-sizing: content-box;
209
+ }
207
210
  .semi-steps-basic.semi-steps-vertical.semi-steps-small .semi-steps-item .semi-steps-item-content {
208
211
  min-height: 40px;
209
212
  }
@@ -75,7 +75,7 @@ export interface BasicTreeSelectProps extends Pick<BasicTreeProps, 'virtualize'
75
75
  onVisibleChange?: (isVisible: boolean) => void;
76
76
  onLoad?: (keys: Set<string>, data: BasicTreeNodeData) => void;
77
77
  }
78
- export interface BasicTreeSelectInnerData extends Pick<BasicTreeInnerData, 'keyEntities' | 'treeData' | 'flattenNodes' | 'selectedKeys' | 'checkedKeys' | 'halfCheckedKeys' | 'motionKeys' | 'motionType' | 'expandedKeys' | 'filteredKeys' | 'filteredExpandedKeys' | 'filteredShownKeys' | 'cachedKeyValuePairs' | 'inputValue' | 'disabledKeys' | 'loadedKeys' | 'loadingKeys' | 'realCheckedKeys'> {
78
+ export interface BasicTreeSelectInnerData extends Pick<BasicTreeInnerData, 'keyEntities' | 'treeData' | 'flattenNodes' | 'cachedFlattenNodes' | 'selectedKeys' | 'checkedKeys' | 'halfCheckedKeys' | 'motionKeys' | 'motionType' | 'expandedKeys' | 'filteredKeys' | 'filteredExpandedKeys' | 'filteredShownKeys' | 'cachedKeyValuePairs' | 'inputValue' | 'disabledKeys' | 'loadedKeys' | 'loadingKeys' | 'realCheckedKeys'> {
79
79
  inputTriggerFocus: boolean;
80
80
  isOpen: boolean;
81
81
  rePosKey: number;
@@ -135,6 +135,7 @@ export default class TreeSelectFoundation<P = Record<string, any>, S = Record<st
135
135
  _notifyMultipleChange(key: string[], e: any): void;
136
136
  _notifyChange(key: any, e: any): void;
137
137
  _registerClickOutsideHandler: (e: any) => void;
138
+ clearInputValue: () => void;
138
139
  _notifyFocus(e: any): void;
139
140
  handleTriggerFocus(e: any): void;
140
141
  _notifyBlur(e: any): void;
@@ -26,6 +26,12 @@ class TreeSelectFoundation extends _foundation.default {
26
26
  this.close(e);
27
27
  });
28
28
  };
29
+ this.clearInputValue = () => {
30
+ const {
31
+ inputValue
32
+ } = this.getStates();
33
+ inputValue && this._adapter.updateInputValue('');
34
+ };
29
35
  }
30
36
  init() {
31
37
  const {
@@ -177,7 +183,7 @@ class TreeSelectFoundation extends _foundation.default {
177
183
  const isSearching = Boolean(inputValue);
178
184
  const treeNodeProps = {
179
185
  eventKey: key,
180
- expanded: isSearching && !this._isExpandControlled() ? filteredExpandedKeys.has(key) : expandedKeys.has(key),
186
+ expanded: isSearching ? filteredExpandedKeys.has(key) : expandedKeys.has(key),
181
187
  selected: selectedKeys.includes(key),
182
188
  checked: realChecked,
183
189
  halfChecked: realHalfChecked,
@@ -450,8 +456,8 @@ class TreeSelectFoundation extends _foundation.default {
450
456
  expandedOptsKeys.forEach(item => newExpandedKeys.add(item));
451
457
  const newFlattenNodes = (0, _treeUtil.flattenTreeData)(treeData, newExpandedKeys, keyMaps);
452
458
  this._adapter.updateState({
453
- expandedKeys: isExpandControlled ? expandedKeys : newExpandedKeys,
454
- flattenNodes: isExpandControlled ? flattenNodes : newFlattenNodes,
459
+ expandedKeys: newExpandedKeys,
460
+ flattenNodes: newFlattenNodes,
455
461
  inputValue: '',
456
462
  motionKeys: new Set([]),
457
463
  filteredKeys: new Set([]),
@@ -500,8 +506,8 @@ class TreeSelectFoundation extends _foundation.default {
500
506
  const newFilteredExpandedKeys = new Set(expandedOptsKeys);
501
507
  this._adapter.notifySearch(sugInput, Array.from(newFilteredExpandedKeys));
502
508
  this._adapter.updateState({
503
- expandedKeys: this._isExpandControlled() ? expandedKeys : newExpandedKeys,
504
- flattenNodes: this._isExpandControlled() ? flattenNodes : newFlattenNodes,
509
+ expandedKeys: newExpandedKeys,
510
+ flattenNodes: newFlattenNodes,
505
511
  motionKeys: new Set([]),
506
512
  filteredKeys: new Set(filteredOptsKeys),
507
513
  filteredExpandedKeys: newFilteredExpandedKeys,
@@ -709,7 +715,7 @@ class TreeSelectFoundation extends _foundation.default {
709
715
  return;
710
716
  }
711
717
  const isExpandControlled = this._isExpandControlled();
712
- if (isSearching && !isExpandControlled) {
718
+ if (isSearching) {
713
719
  this.handleNodeExpandInSearch(e, treeNode);
714
720
  return;
715
721
  }
@@ -319,6 +319,9 @@ export default class SelectFoundation extends BaseFoundation {
319
319
  const newOptions = this._filterOption(options, sugInput).filter(item => !item._inputCreateOnly);
320
320
  this._adapter.updateOptions(newOptions);
321
321
  this.toggle2SearchInput(true);
322
+ } else {
323
+ // whether it is a filter or not, isFocus is guaranteed to be true when open
324
+ this._adapter.updateFocusState(true);
322
325
  }
323
326
  this._adapter.openMenu();
324
327
  this._setDropdownWidth();
@@ -328,7 +331,6 @@ export default class SelectFoundation extends BaseFoundation {
328
331
  this.close(e);
329
332
  this._notifyBlur(e);
330
333
  this._adapter.updateFocusState(false);
331
- this._adapter.unregisterClickOutsideHandler();
332
334
  });
333
335
  }
334
336
  toggle2SearchInput(isShow) {
@@ -347,6 +349,7 @@ export default class SelectFoundation extends BaseFoundation {
347
349
  // this.unBindKeyBoardEvent();
348
350
  // this._notifyBlur(e);
349
351
  // this._adapter.updateFocusState(false);
352
+ this._adapter.unregisterClickOutsideHandler();
350
353
  const isFilterable = this._isFilterable();
351
354
  if (isFilterable) {
352
355
  this.toggle2SearchInput(false);
@@ -1033,7 +1036,6 @@ export default class SelectFoundation extends BaseFoundation {
1033
1036
  this._adapter.setIsFocusInContainer(false);
1034
1037
  }
1035
1038
  handleTriggerBlur(e) {
1036
- this._adapter.updateFocusState(false);
1037
1039
  const {
1038
1040
  filter,
1039
1041
  autoFocus
@@ -1046,6 +1048,7 @@ export default class SelectFoundation extends BaseFoundation {
1046
1048
  // But when autoFocus or the panel is close, because clickOutsideHandler is not register or unregister, you need to listen for the trigger's blur and trigger the notify callback
1047
1049
  if (isFocus && !isOpen) {
1048
1050
  this._notifyBlur(e);
1051
+ this._adapter.updateFocusState(false);
1049
1052
  }
1050
1053
  }
1051
1054
  handleInputBlur(e) {
@@ -84,6 +84,10 @@ $basicType: #{$module}-basic;
84
84
  display: flex;
85
85
  flex-flow: column nowrap;
86
86
 
87
+ .#{$item}-icon {
88
+ box-sizing: content-box;
89
+ }
90
+
87
91
  &.#{$module}-small {
88
92
  .#{$item} {
89
93
  .#{$item}-content {
@@ -204,6 +204,9 @@
204
204
  display: flex;
205
205
  flex-flow: column nowrap;
206
206
  }
207
+ .semi-steps-basic.semi-steps-vertical .semi-steps-item-icon {
208
+ box-sizing: content-box;
209
+ }
207
210
  .semi-steps-basic.semi-steps-vertical.semi-steps-small .semi-steps-item .semi-steps-item-content {
208
211
  min-height: 40px;
209
212
  }
@@ -75,7 +75,7 @@ export interface BasicTreeSelectProps extends Pick<BasicTreeProps, 'virtualize'
75
75
  onVisibleChange?: (isVisible: boolean) => void;
76
76
  onLoad?: (keys: Set<string>, data: BasicTreeNodeData) => void;
77
77
  }
78
- export interface BasicTreeSelectInnerData extends Pick<BasicTreeInnerData, 'keyEntities' | 'treeData' | 'flattenNodes' | 'selectedKeys' | 'checkedKeys' | 'halfCheckedKeys' | 'motionKeys' | 'motionType' | 'expandedKeys' | 'filteredKeys' | 'filteredExpandedKeys' | 'filteredShownKeys' | 'cachedKeyValuePairs' | 'inputValue' | 'disabledKeys' | 'loadedKeys' | 'loadingKeys' | 'realCheckedKeys'> {
78
+ export interface BasicTreeSelectInnerData extends Pick<BasicTreeInnerData, 'keyEntities' | 'treeData' | 'flattenNodes' | 'cachedFlattenNodes' | 'selectedKeys' | 'checkedKeys' | 'halfCheckedKeys' | 'motionKeys' | 'motionType' | 'expandedKeys' | 'filteredKeys' | 'filteredExpandedKeys' | 'filteredShownKeys' | 'cachedKeyValuePairs' | 'inputValue' | 'disabledKeys' | 'loadedKeys' | 'loadingKeys' | 'realCheckedKeys'> {
79
79
  inputTriggerFocus: boolean;
80
80
  isOpen: boolean;
81
81
  rePosKey: number;
@@ -135,6 +135,7 @@ export default class TreeSelectFoundation<P = Record<string, any>, S = Record<st
135
135
  _notifyMultipleChange(key: string[], e: any): void;
136
136
  _notifyChange(key: any, e: any): void;
137
137
  _registerClickOutsideHandler: (e: any) => void;
138
+ clearInputValue: () => void;
138
139
  _notifyFocus(e: any): void;
139
140
  handleTriggerFocus(e: any): void;
140
141
  _notifyBlur(e: any): void;
@@ -19,6 +19,12 @@ export default class TreeSelectFoundation extends BaseFoundation {
19
19
  this.close(e);
20
20
  });
21
21
  };
22
+ this.clearInputValue = () => {
23
+ const {
24
+ inputValue
25
+ } = this.getStates();
26
+ inputValue && this._adapter.updateInputValue('');
27
+ };
22
28
  }
23
29
  init() {
24
30
  const {
@@ -170,7 +176,7 @@ export default class TreeSelectFoundation extends BaseFoundation {
170
176
  const isSearching = Boolean(inputValue);
171
177
  const treeNodeProps = {
172
178
  eventKey: key,
173
- expanded: isSearching && !this._isExpandControlled() ? filteredExpandedKeys.has(key) : expandedKeys.has(key),
179
+ expanded: isSearching ? filteredExpandedKeys.has(key) : expandedKeys.has(key),
174
180
  selected: selectedKeys.includes(key),
175
181
  checked: realChecked,
176
182
  halfChecked: realHalfChecked,
@@ -443,8 +449,8 @@ export default class TreeSelectFoundation extends BaseFoundation {
443
449
  expandedOptsKeys.forEach(item => newExpandedKeys.add(item));
444
450
  const newFlattenNodes = flattenTreeData(treeData, newExpandedKeys, keyMaps);
445
451
  this._adapter.updateState({
446
- expandedKeys: isExpandControlled ? expandedKeys : newExpandedKeys,
447
- flattenNodes: isExpandControlled ? flattenNodes : newFlattenNodes,
452
+ expandedKeys: newExpandedKeys,
453
+ flattenNodes: newFlattenNodes,
448
454
  inputValue: '',
449
455
  motionKeys: new Set([]),
450
456
  filteredKeys: new Set([]),
@@ -493,8 +499,8 @@ export default class TreeSelectFoundation extends BaseFoundation {
493
499
  const newFilteredExpandedKeys = new Set(expandedOptsKeys);
494
500
  this._adapter.notifySearch(sugInput, Array.from(newFilteredExpandedKeys));
495
501
  this._adapter.updateState({
496
- expandedKeys: this._isExpandControlled() ? expandedKeys : newExpandedKeys,
497
- flattenNodes: this._isExpandControlled() ? flattenNodes : newFlattenNodes,
502
+ expandedKeys: newExpandedKeys,
503
+ flattenNodes: newFlattenNodes,
498
504
  motionKeys: new Set([]),
499
505
  filteredKeys: new Set(filteredOptsKeys),
500
506
  filteredExpandedKeys: newFilteredExpandedKeys,
@@ -702,7 +708,7 @@ export default class TreeSelectFoundation extends BaseFoundation {
702
708
  return;
703
709
  }
704
710
  const isExpandControlled = this._isExpandControlled();
705
- if (isSearching && !isExpandControlled) {
711
+ if (isSearching) {
706
712
  this.handleNodeExpandInSearch(e, treeNode);
707
713
  return;
708
714
  }
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@douyinfe/semi-foundation",
3
- "version": "2.49.1",
3
+ "version": "2.49.2",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "build:lib": "node ./scripts/compileLib.js",
7
7
  "prepublishOnly": "npm run build:lib"
8
8
  },
9
9
  "dependencies": {
10
- "@douyinfe/semi-animation": "2.49.1",
10
+ "@douyinfe/semi-animation": "2.49.2",
11
11
  "async-validator": "^3.5.0",
12
12
  "classnames": "^2.2.6",
13
13
  "date-fns": "^2.29.3",
@@ -23,7 +23,7 @@
23
23
  "*.scss",
24
24
  "*.css"
25
25
  ],
26
- "gitHead": "5a1affe04071d02da9ef9dd990bb19c5d39d0462",
26
+ "gitHead": "faf1323ac8375fe0c85ed8cef0d2abab45341dc7",
27
27
  "devDependencies": {
28
28
  "@babel/plugin-transform-runtime": "^7.15.8",
29
29
  "@babel/preset-env": "^7.15.8",
@@ -352,6 +352,9 @@ export default class SelectFoundation extends BaseFoundation<SelectAdapter> {
352
352
  const newOptions = this._filterOption(options, sugInput).filter(item => !item._inputCreateOnly);
353
353
  this._adapter.updateOptions(newOptions);
354
354
  this.toggle2SearchInput(true);
355
+ } else {
356
+ // whether it is a filter or not, isFocus is guaranteed to be true when open
357
+ this._adapter.updateFocusState(true);
355
358
  }
356
359
  this._adapter.openMenu();
357
360
  this._setDropdownWidth();
@@ -363,7 +366,6 @@ export default class SelectFoundation extends BaseFoundation<SelectAdapter> {
363
366
  this.close(e);
364
367
  this._notifyBlur(e);
365
368
  this._adapter.updateFocusState(false);
366
- this._adapter.unregisterClickOutsideHandler();
367
369
  });
368
370
  }
369
371
 
@@ -385,6 +387,7 @@ export default class SelectFoundation extends BaseFoundation<SelectAdapter> {
385
387
  // this.unBindKeyBoardEvent();
386
388
  // this._notifyBlur(e);
387
389
  // this._adapter.updateFocusState(false);
390
+ this._adapter.unregisterClickOutsideHandler();
388
391
 
389
392
  const isFilterable = this._isFilterable();
390
393
  if (isFilterable) {
@@ -1053,13 +1056,13 @@ export default class SelectFoundation extends BaseFoundation<SelectAdapter> {
1053
1056
  }
1054
1057
 
1055
1058
  handleTriggerBlur(e: FocusEvent) {
1056
- this._adapter.updateFocusState(false);
1057
1059
  const { filter, autoFocus } = this.getProps();
1058
1060
  const { isOpen, isFocus } = this.getStates();
1059
1061
  // Under normal circumstances, blur will be accompanied by clickOutsideHandler, so the notify of blur can be called uniformly in clickOutsideHandler
1060
1062
  // But when autoFocus or the panel is close, because clickOutsideHandler is not register or unregister, you need to listen for the trigger's blur and trigger the notify callback
1061
1063
  if (isFocus && !isOpen) {
1062
1064
  this._notifyBlur(e);
1065
+ this._adapter.updateFocusState(false);
1063
1066
  }
1064
1067
  }
1065
1068
 
@@ -84,6 +84,10 @@ $basicType: #{$module}-basic;
84
84
  display: flex;
85
85
  flex-flow: column nowrap;
86
86
 
87
+ .#{$item}-icon {
88
+ box-sizing: content-box;
89
+ }
90
+
87
91
  &.#{$module}-small {
88
92
  .#{$item} {
89
93
  .#{$item}-content {
@@ -150,6 +150,7 @@ export interface BasicTreeSelectInnerData extends Pick<BasicTreeInnerData,
150
150
  'keyEntities'
151
151
  | 'treeData'
152
152
  | 'flattenNodes'
153
+ | 'cachedFlattenNodes'
153
154
  | 'selectedKeys'
154
155
  | 'checkedKeys'
155
156
  | 'halfCheckedKeys'
@@ -346,9 +347,7 @@ export default class TreeSelectFoundation<P = Record<string, any>, S = Record<st
346
347
  const isSearching = Boolean(inputValue);
347
348
  const treeNodeProps: BasicTreeNodeProps = {
348
349
  eventKey: key,
349
- expanded: isSearching && !this._isExpandControlled()
350
- ? filteredExpandedKeys.has(key)
351
- : expandedKeys.has(key),
350
+ expanded: isSearching ? filteredExpandedKeys.has(key) : expandedKeys.has(key),
352
351
  selected: selectedKeys.includes(key),
353
352
  checked: realChecked,
354
353
  halfChecked: realHalfChecked,
@@ -444,6 +443,11 @@ export default class TreeSelectFoundation<P = Record<string, any>, S = Record<st
444
443
  });
445
444
  }
446
445
 
446
+ clearInputValue = () => {
447
+ const { inputValue } = this.getStates();
448
+ inputValue && this._adapter.updateInputValue('');
449
+ }
450
+
447
451
  // Scenes that may trigger focus:
448
452
  // 1、click selection
449
453
  _notifyFocus(e: any) {
@@ -597,8 +601,8 @@ export default class TreeSelectFoundation<P = Record<string, any>, S = Record<st
597
601
  const newFlattenNodes = flattenTreeData(treeData, newExpandedKeys, keyMaps);
598
602
 
599
603
  this._adapter.updateState({
600
- expandedKeys: isExpandControlled ? expandedKeys : newExpandedKeys,
601
- flattenNodes: isExpandControlled ? flattenNodes : newFlattenNodes,
604
+ expandedKeys: newExpandedKeys,
605
+ flattenNodes: newFlattenNodes,
602
606
  inputValue: '',
603
607
  motionKeys: new Set([]),
604
608
  filteredKeys: new Set([]),
@@ -637,8 +641,8 @@ export default class TreeSelectFoundation<P = Record<string, any>, S = Record<st
637
641
  const newFilteredExpandedKeys = new Set(expandedOptsKeys);
638
642
  this._adapter.notifySearch(sugInput, Array.from(newFilteredExpandedKeys));
639
643
  this._adapter.updateState({
640
- expandedKeys: this._isExpandControlled() ? expandedKeys : newExpandedKeys,
641
- flattenNodes: this._isExpandControlled() ? flattenNodes : newFlattenNodes,
644
+ expandedKeys: newExpandedKeys,
645
+ flattenNodes: newFlattenNodes,
642
646
  motionKeys: new Set([]),
643
647
  filteredKeys: new Set(filteredOptsKeys),
644
648
  filteredExpandedKeys: newFilteredExpandedKeys,
@@ -808,7 +812,7 @@ export default class TreeSelectFoundation<P = Record<string, any>, S = Record<st
808
812
  }
809
813
 
810
814
  const isExpandControlled = this._isExpandControlled();
811
- if (isSearching && !isExpandControlled) {
815
+ if (isSearching) {
812
816
  this.handleNodeExpandInSearch(e, treeNode);
813
817
  return;
814
818
  }