@douyinfe/semi-foundation 2.6.0 → 2.7.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.
- package/button/button.scss +14 -6
- package/datePicker/_utils/formatter.ts +2 -2
- package/datePicker/_utils/getInsetInputFormatToken.ts +42 -0
- package/datePicker/_utils/getInsetInputValueFromInsetInputStr.ts +60 -0
- package/datePicker/constants.ts +2 -0
- package/datePicker/datePicker.scss +136 -3
- package/datePicker/foundation.ts +92 -15
- package/datePicker/inputFoundation.ts +133 -4
- package/datePicker/monthsGridFoundation.ts +4 -0
- package/datePicker/rtl.scss +8 -0
- package/datePicker/variables.scss +30 -0
- package/lib/cjs/button/button.css +5 -5
- package/lib/cjs/button/button.scss +14 -6
- package/lib/cjs/datePicker/_utils/formatter.d.ts +2 -2
- package/lib/cjs/datePicker/_utils/getInsetInputFormatToken.d.ts +20 -0
- package/lib/cjs/datePicker/_utils/getInsetInputFormatToken.js +61 -0
- package/lib/cjs/datePicker/_utils/getInsetInputValueFromInsetInputStr.d.ts +31 -0
- package/lib/cjs/datePicker/_utils/getInsetInputValueFromInsetInputStr.js +76 -0
- package/lib/cjs/datePicker/constants.d.ts +2 -0
- package/lib/cjs/datePicker/constants.js +4 -3
- package/lib/cjs/datePicker/datePicker.css +104 -2
- package/lib/cjs/datePicker/datePicker.scss +136 -3
- package/lib/cjs/datePicker/foundation.d.ts +30 -7
- package/lib/cjs/datePicker/foundation.js +122 -9
- package/lib/cjs/datePicker/inputFoundation.d.ts +73 -3
- package/lib/cjs/datePicker/inputFoundation.js +196 -3
- package/lib/cjs/datePicker/monthsGridFoundation.d.ts +1 -0
- package/lib/cjs/datePicker/monthsGridFoundation.js +4 -2
- package/lib/cjs/datePicker/rtl.scss +8 -0
- package/lib/cjs/datePicker/variables.scss +30 -0
- package/lib/cjs/tooltip/foundation.js +8 -8
- package/lib/cjs/treeSelect/foundation.d.ts +3 -2
- package/lib/cjs/treeSelect/foundation.js +28 -15
- package/lib/es/button/button.css +5 -5
- package/lib/es/button/button.scss +14 -6
- package/lib/es/datePicker/_utils/formatter.d.ts +2 -2
- package/lib/es/datePicker/_utils/getInsetInputFormatToken.d.ts +20 -0
- package/lib/es/datePicker/_utils/getInsetInputFormatToken.js +48 -0
- package/lib/es/datePicker/_utils/getInsetInputValueFromInsetInputStr.d.ts +31 -0
- package/lib/es/datePicker/_utils/getInsetInputValueFromInsetInputStr.js +66 -0
- package/lib/es/datePicker/constants.d.ts +2 -0
- package/lib/es/datePicker/constants.js +4 -3
- package/lib/es/datePicker/datePicker.css +104 -2
- package/lib/es/datePicker/datePicker.scss +136 -3
- package/lib/es/datePicker/foundation.d.ts +30 -7
- package/lib/es/datePicker/foundation.js +120 -9
- package/lib/es/datePicker/inputFoundation.d.ts +73 -3
- package/lib/es/datePicker/inputFoundation.js +192 -4
- package/lib/es/datePicker/monthsGridFoundation.d.ts +1 -0
- package/lib/es/datePicker/monthsGridFoundation.js +4 -2
- package/lib/es/datePicker/rtl.scss +8 -0
- package/lib/es/datePicker/variables.scss +30 -0
- package/lib/es/tooltip/foundation.js +8 -8
- package/lib/es/treeSelect/foundation.d.ts +3 -2
- package/lib/es/treeSelect/foundation.js +27 -15
- package/package.json +3 -3
- package/tooltip/foundation.ts +8 -8
- package/treeSelect/foundation.ts +26 -19
|
@@ -520,25 +520,25 @@ export default class Tooltip extends BaseFoundation {
|
|
|
520
520
|
break;
|
|
521
521
|
|
|
522
522
|
case 'leftTopOver':
|
|
523
|
-
left = triggerRect.left;
|
|
524
|
-
top = triggerRect.top;
|
|
523
|
+
left = triggerRect.left - SPACING;
|
|
524
|
+
top = triggerRect.top - SPACING;
|
|
525
525
|
break;
|
|
526
526
|
|
|
527
527
|
case 'rightTopOver':
|
|
528
|
-
left = triggerRect.right;
|
|
529
|
-
top = triggerRect.top;
|
|
528
|
+
left = triggerRect.right + SPACING;
|
|
529
|
+
top = triggerRect.top - SPACING;
|
|
530
530
|
translateX = -1;
|
|
531
531
|
break;
|
|
532
532
|
|
|
533
533
|
case 'leftBottomOver':
|
|
534
|
-
left = triggerRect.left;
|
|
535
|
-
top = triggerRect.bottom;
|
|
534
|
+
left = triggerRect.left - SPACING;
|
|
535
|
+
top = triggerRect.bottom + SPACING;
|
|
536
536
|
translateY = -1;
|
|
537
537
|
break;
|
|
538
538
|
|
|
539
539
|
case 'rightBottomOver':
|
|
540
|
-
left = triggerRect.right;
|
|
541
|
-
top = triggerRect.bottom;
|
|
540
|
+
left = triggerRect.right + SPACING;
|
|
541
|
+
top = triggerRect.bottom + SPACING;
|
|
542
542
|
translateX = -1;
|
|
543
543
|
translateY = -1;
|
|
544
544
|
break;
|
|
@@ -27,7 +27,7 @@ export interface BasicOnChange {
|
|
|
27
27
|
(node: BasicTreeNodeData[] | BasicTreeNodeData, e: any): void;
|
|
28
28
|
(value: BasicTreeNodeData['value'] | Array<BasicTreeNodeData['value']>, node: BasicTreeNodeData[] | BasicTreeNodeData, e: any): void;
|
|
29
29
|
}
|
|
30
|
-
export interface BasicTreeSelectProps extends Pick<BasicTreeProps, 'virtualize' | 'renderFullLabel' | 'renderLabel' | 'autoExpandParent' | 'className' | 'defaultExpandAll' | 'defaultExpandedKeys' | 'defaultValue' | 'disabled' | 'emptyContent' | 'expandAction' | 'expandedKeys' | 'filterTreeNode' | 'labelEllipsis' | 'leafOnly' | 'multiple' | 'onChangeWithObject' | 'showClear' | 'showFilteredOnly' | 'style' | 'treeData' | 'treeNodeFilterProp' | 'value' | 'onExpand' | '
|
|
30
|
+
export interface BasicTreeSelectProps extends Pick<BasicTreeProps, 'virtualize' | 'renderFullLabel' | 'renderLabel' | 'autoExpandParent' | 'className' | 'defaultExpandAll' | 'defaultExpandedKeys' | 'defaultValue' | 'disabled' | 'emptyContent' | 'expandAction' | 'expandedKeys' | 'filterTreeNode' | 'labelEllipsis' | 'leafOnly' | 'multiple' | 'onChangeWithObject' | 'showClear' | 'showFilteredOnly' | 'style' | 'treeData' | 'treeNodeFilterProp' | 'value' | 'onExpand' | 'expandAll' | 'disableStrictly' | 'aria-label' | 'checkRelation'> {
|
|
31
31
|
motion?: Motion;
|
|
32
32
|
mouseEnterDelay?: number;
|
|
33
33
|
mouseLeaveDelay?: number;
|
|
@@ -63,6 +63,7 @@ export interface BasicTreeSelectProps extends Pick<BasicTreeProps, 'virtualize'
|
|
|
63
63
|
renderSelectedItem?: BasicRenderSelectedItem;
|
|
64
64
|
getPopupContainer?: () => HTMLElement;
|
|
65
65
|
onBlur?: (e: any) => void;
|
|
66
|
+
onSearch?: (sunInput: string, filteredExpandedKeys: string[]) => void;
|
|
66
67
|
onChange?: BasicOnChange;
|
|
67
68
|
onFocus?: (e: any) => void;
|
|
68
69
|
onVisibleChange?: (isVisible: boolean) => void;
|
|
@@ -84,7 +85,7 @@ export interface TreeSelectAdapter<P = Record<string, any>, S = Record<string, a
|
|
|
84
85
|
rePositionDropdown: () => void;
|
|
85
86
|
updateState: (states: Partial<BasicTreeSelectInnerData>) => void;
|
|
86
87
|
notifySelect: (selectedKeys: string, selected: boolean, selectedNode: BasicTreeNodeData) => void;
|
|
87
|
-
notifySearch: (input: string) => void;
|
|
88
|
+
notifySearch: (input: string, filteredExpandedKeys: string[]) => void;
|
|
88
89
|
cacheFlattenNodes: (bool: boolean) => void;
|
|
89
90
|
openMenu: () => void;
|
|
90
91
|
closeMenu: (cb?: () => void) => void;
|
|
@@ -14,6 +14,7 @@ import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance
|
|
|
14
14
|
import _Array$isArray from "@babel/runtime-corejs3/core-js-stable/array/is-array";
|
|
15
15
|
import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
|
|
16
16
|
import _Object$values from "@babel/runtime-corejs3/core-js-stable/object/values";
|
|
17
|
+
import _Array$from from "@babel/runtime-corejs3/core-js-stable/array/from";
|
|
17
18
|
import _someInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/some";
|
|
18
19
|
import _everyInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/every";
|
|
19
20
|
import { strings } from '../treeSelect/constants';
|
|
@@ -159,7 +160,7 @@ export default class TreeSelectFoundation extends BaseFoundation {
|
|
|
159
160
|
const isSearching = Boolean(inputValue);
|
|
160
161
|
const treeNodeProps = {
|
|
161
162
|
eventKey: key,
|
|
162
|
-
expanded: isSearching ? filteredExpandedKeys.has(key) : expandedKeys.has(key),
|
|
163
|
+
expanded: isSearching && !this._isExpandControlled() ? filteredExpandedKeys.has(key) : expandedKeys.has(key),
|
|
163
164
|
selected: _includesInstanceProperty(selectedKeys).call(selectedKeys, key),
|
|
164
165
|
checked: realChecked,
|
|
165
166
|
halfChecked: realHalfChecked,
|
|
@@ -446,20 +447,25 @@ export default class TreeSelectFoundation extends BaseFoundation {
|
|
|
446
447
|
|
|
447
448
|
clearInput() {
|
|
448
449
|
const {
|
|
450
|
+
flattenNodes,
|
|
449
451
|
expandedKeys,
|
|
450
452
|
selectedKeys,
|
|
451
453
|
keyEntities,
|
|
452
454
|
treeData
|
|
453
455
|
} = this.getStates();
|
|
456
|
+
const newExpandedKeys = new _Set(expandedKeys);
|
|
457
|
+
|
|
458
|
+
const isExpandControlled = this._isExpandControlled();
|
|
459
|
+
|
|
454
460
|
const expandedOptsKeys = findAncestorKeys(selectedKeys, keyEntities);
|
|
455
461
|
|
|
456
|
-
_forEachInstanceProperty(expandedOptsKeys).call(expandedOptsKeys, item =>
|
|
462
|
+
_forEachInstanceProperty(expandedOptsKeys).call(expandedOptsKeys, item => newExpandedKeys.add(item));
|
|
457
463
|
|
|
458
|
-
const
|
|
464
|
+
const newFlattenNodes = flattenTreeData(treeData, newExpandedKeys);
|
|
459
465
|
|
|
460
466
|
this._adapter.updateState({
|
|
461
|
-
expandedKeys,
|
|
462
|
-
flattenNodes,
|
|
467
|
+
expandedKeys: isExpandControlled ? expandedKeys : newExpandedKeys,
|
|
468
|
+
flattenNodes: isExpandControlled ? flattenNodes : newFlattenNodes,
|
|
463
469
|
inputValue: '',
|
|
464
470
|
motionKeys: new _Set([]),
|
|
465
471
|
filteredKeys: new _Set([]),
|
|
@@ -473,6 +479,7 @@ export default class TreeSelectFoundation extends BaseFoundation {
|
|
|
473
479
|
this._adapter.updateInputValue(sugInput);
|
|
474
480
|
|
|
475
481
|
const {
|
|
482
|
+
flattenNodes,
|
|
476
483
|
expandedKeys,
|
|
477
484
|
selectedKeys,
|
|
478
485
|
keyEntities,
|
|
@@ -483,17 +490,18 @@ export default class TreeSelectFoundation extends BaseFoundation {
|
|
|
483
490
|
filterTreeNode,
|
|
484
491
|
treeNodeFilterProp
|
|
485
492
|
} = this.getProps();
|
|
493
|
+
const newExpandedKeys = new _Set(expandedKeys);
|
|
486
494
|
let filteredOptsKeys = [];
|
|
487
495
|
let expandedOptsKeys = [];
|
|
488
|
-
let
|
|
496
|
+
let newFlattenNodes = [];
|
|
489
497
|
let filteredShownKeys = new _Set([]);
|
|
490
498
|
|
|
491
499
|
if (!sugInput) {
|
|
492
500
|
expandedOptsKeys = findAncestorKeys(selectedKeys, keyEntities);
|
|
493
501
|
|
|
494
|
-
_forEachInstanceProperty(expandedOptsKeys).call(expandedOptsKeys, item =>
|
|
502
|
+
_forEachInstanceProperty(expandedOptsKeys).call(expandedOptsKeys, item => newExpandedKeys.add(item));
|
|
495
503
|
|
|
496
|
-
|
|
504
|
+
newFlattenNodes = flattenTreeData(treeData, newExpandedKeys);
|
|
497
505
|
} else {
|
|
498
506
|
var _context3, _context4;
|
|
499
507
|
|
|
@@ -506,17 +514,19 @@ export default class TreeSelectFoundation extends BaseFoundation {
|
|
|
506
514
|
expandedOptsKeys = findAncestorKeys(filteredOptsKeys, keyEntities, false);
|
|
507
515
|
const shownChildKeys = findDescendantKeys(filteredOptsKeys, keyEntities, true);
|
|
508
516
|
filteredShownKeys = new _Set([...shownChildKeys, ...expandedOptsKeys]);
|
|
509
|
-
|
|
517
|
+
newFlattenNodes = flattenTreeData(treeData, new _Set(expandedOptsKeys), showFilteredOnly && filteredShownKeys);
|
|
510
518
|
}
|
|
511
519
|
|
|
512
|
-
|
|
520
|
+
const newFilteredExpandedKeys = new _Set(expandedOptsKeys);
|
|
521
|
+
|
|
522
|
+
this._adapter.notifySearch(sugInput, _Array$from(newFilteredExpandedKeys));
|
|
513
523
|
|
|
514
524
|
this._adapter.updateState({
|
|
515
|
-
expandedKeys,
|
|
516
|
-
flattenNodes,
|
|
525
|
+
expandedKeys: this._isExpandControlled() ? expandedKeys : newExpandedKeys,
|
|
526
|
+
flattenNodes: this._isExpandControlled() ? flattenNodes : newFlattenNodes,
|
|
517
527
|
motionKeys: new _Set([]),
|
|
518
528
|
filteredKeys: new _Set(filteredOptsKeys),
|
|
519
|
-
filteredExpandedKeys:
|
|
529
|
+
filteredExpandedKeys: newFilteredExpandedKeys,
|
|
520
530
|
filteredShownKeys
|
|
521
531
|
});
|
|
522
532
|
}
|
|
@@ -760,7 +770,9 @@ export default class TreeSelectFoundation extends BaseFoundation {
|
|
|
760
770
|
return;
|
|
761
771
|
}
|
|
762
772
|
|
|
763
|
-
|
|
773
|
+
const isExpandControlled = this._isExpandControlled();
|
|
774
|
+
|
|
775
|
+
if (isSearching && !isExpandControlled) {
|
|
764
776
|
this.handleNodeExpandInSearch(e, treeNode);
|
|
765
777
|
return;
|
|
766
778
|
}
|
|
@@ -788,7 +800,7 @@ export default class TreeSelectFoundation extends BaseFoundation {
|
|
|
788
800
|
|
|
789
801
|
this._adapter.cacheFlattenNodes(motionType === 'hide' && this._isAnimated());
|
|
790
802
|
|
|
791
|
-
if (!
|
|
803
|
+
if (!isExpandControlled) {
|
|
792
804
|
const flattenNodes = flattenTreeData(treeData, expandedKeys);
|
|
793
805
|
const motionKeys = this._isAnimated() ? getMotionKeys(eventKey, expandedKeys, keyEntities) : [];
|
|
794
806
|
const newState = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@douyinfe/semi-foundation",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.7.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.
|
|
11
|
+
"@douyinfe/semi-animation": "2.7.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": "
|
|
27
|
+
"gitHead": "d0dbd6f932a74386b429dedbc32ae92d9e0af7b9",
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@babel/plugin-proposal-decorators": "^7.15.8",
|
|
30
30
|
"@babel/plugin-transform-runtime": "^7.15.8",
|
package/tooltip/foundation.ts
CHANGED
|
@@ -426,22 +426,22 @@ export default class Tooltip<P = Record<string, any>, S = Record<string, any>> e
|
|
|
426
426
|
translateY = -1;
|
|
427
427
|
break;
|
|
428
428
|
case 'leftTopOver':
|
|
429
|
-
left = triggerRect.left;
|
|
430
|
-
top = triggerRect.top;
|
|
429
|
+
left = triggerRect.left - SPACING;
|
|
430
|
+
top = triggerRect.top - SPACING;
|
|
431
431
|
break;
|
|
432
432
|
case 'rightTopOver':
|
|
433
|
-
left = triggerRect.right;
|
|
434
|
-
top = triggerRect.top;
|
|
433
|
+
left = triggerRect.right + SPACING;
|
|
434
|
+
top = triggerRect.top - SPACING;
|
|
435
435
|
translateX = -1;
|
|
436
436
|
break;
|
|
437
437
|
case 'leftBottomOver':
|
|
438
|
-
left = triggerRect.left;
|
|
439
|
-
top = triggerRect.bottom;
|
|
438
|
+
left = triggerRect.left - SPACING;
|
|
439
|
+
top = triggerRect.bottom + SPACING;
|
|
440
440
|
translateY = -1;
|
|
441
441
|
break;
|
|
442
442
|
case 'rightBottomOver':
|
|
443
|
-
left = triggerRect.right;
|
|
444
|
-
top = triggerRect.bottom;
|
|
443
|
+
left = triggerRect.right + SPACING;
|
|
444
|
+
top = triggerRect.bottom + SPACING;
|
|
445
445
|
translateX = -1;
|
|
446
446
|
translateY = -1;
|
|
447
447
|
break;
|
package/treeSelect/foundation.ts
CHANGED
|
@@ -91,7 +91,6 @@ export interface BasicTreeSelectProps extends Pick<BasicTreeProps,
|
|
|
91
91
|
| 'treeNodeFilterProp'
|
|
92
92
|
| 'value'
|
|
93
93
|
| 'onExpand'
|
|
94
|
-
| 'onSearch'
|
|
95
94
|
| 'expandAll'
|
|
96
95
|
| 'disableStrictly'
|
|
97
96
|
| 'aria-label'
|
|
@@ -133,6 +132,7 @@ export interface BasicTreeSelectProps extends Pick<BasicTreeProps,
|
|
|
133
132
|
getPopupContainer?: () => HTMLElement;
|
|
134
133
|
// triggerRender?: (props: BasicTriggerRenderProps) => any;
|
|
135
134
|
onBlur?: (e: any) => void;
|
|
135
|
+
onSearch?: (sunInput: string, filteredExpandedKeys: string[]) => void;
|
|
136
136
|
onChange?: BasicOnChange;
|
|
137
137
|
onFocus?: (e: any) => void;
|
|
138
138
|
onVisibleChange?: (isVisible: boolean) => void;
|
|
@@ -175,7 +175,7 @@ export interface TreeSelectAdapter<P = Record<string, any>, S = Record<string, a
|
|
|
175
175
|
rePositionDropdown: () => void;
|
|
176
176
|
updateState: (states: Partial<BasicTreeSelectInnerData>) => void;
|
|
177
177
|
notifySelect: (selectedKeys: string, selected: boolean, selectedNode: BasicTreeNodeData) => void;
|
|
178
|
-
notifySearch: (input: string) => void;
|
|
178
|
+
notifySearch: (input: string, filteredExpandedKeys: string[]) => void;
|
|
179
179
|
cacheFlattenNodes: (bool: boolean) => void;
|
|
180
180
|
openMenu: () => void;
|
|
181
181
|
closeMenu: (cb?: () => void) => void;
|
|
@@ -302,7 +302,9 @@ export default class TreeSelectFoundation<P = Record<string, any>, S = Record<st
|
|
|
302
302
|
const isSearching = Boolean(inputValue);
|
|
303
303
|
const treeNodeProps: BasicTreeNodeProps = {
|
|
304
304
|
eventKey: key,
|
|
305
|
-
expanded: isSearching
|
|
305
|
+
expanded: isSearching && !this._isExpandControlled()
|
|
306
|
+
? filteredExpandedKeys.has(key)
|
|
307
|
+
: expandedKeys.has(key),
|
|
306
308
|
selected: selectedKeys.includes(key),
|
|
307
309
|
checked: realChecked,
|
|
308
310
|
halfChecked: realHalfChecked,
|
|
@@ -515,14 +517,16 @@ export default class TreeSelectFoundation<P = Record<string, any>, S = Record<st
|
|
|
515
517
|
}
|
|
516
518
|
|
|
517
519
|
clearInput() {
|
|
518
|
-
const { expandedKeys, selectedKeys, keyEntities, treeData } = this.getStates();
|
|
520
|
+
const { flattenNodes, expandedKeys, selectedKeys, keyEntities, treeData } = this.getStates();
|
|
521
|
+
const newExpandedKeys: Set<string> = new Set(expandedKeys);
|
|
522
|
+
const isExpandControlled = this._isExpandControlled();
|
|
519
523
|
const expandedOptsKeys = findAncestorKeys(selectedKeys, keyEntities);
|
|
520
|
-
expandedOptsKeys.forEach(item =>
|
|
521
|
-
const
|
|
524
|
+
expandedOptsKeys.forEach(item => newExpandedKeys.add(item));
|
|
525
|
+
const newFlattenNodes = flattenTreeData(treeData, newExpandedKeys);
|
|
522
526
|
|
|
523
527
|
this._adapter.updateState({
|
|
524
|
-
expandedKeys,
|
|
525
|
-
flattenNodes,
|
|
528
|
+
expandedKeys: isExpandControlled ? expandedKeys : newExpandedKeys,
|
|
529
|
+
flattenNodes: isExpandControlled ? flattenNodes : newFlattenNodes,
|
|
526
530
|
inputValue: '',
|
|
527
531
|
motionKeys: new Set([]),
|
|
528
532
|
filteredKeys: new Set([]),
|
|
@@ -534,16 +538,17 @@ export default class TreeSelectFoundation<P = Record<string, any>, S = Record<st
|
|
|
534
538
|
handleInputChange(sugInput: string) {
|
|
535
539
|
// Input is used as controlled component
|
|
536
540
|
this._adapter.updateInputValue(sugInput);
|
|
537
|
-
const { expandedKeys, selectedKeys, keyEntities, treeData } = this.getStates();
|
|
541
|
+
const { flattenNodes, expandedKeys, selectedKeys, keyEntities, treeData } = this.getStates();
|
|
538
542
|
const { showFilteredOnly, filterTreeNode, treeNodeFilterProp } = this.getProps();
|
|
543
|
+
const newExpandedKeys: Set<string> = new Set(expandedKeys);
|
|
539
544
|
let filteredOptsKeys: string[] = [];
|
|
540
545
|
let expandedOptsKeys = [];
|
|
541
|
-
let
|
|
546
|
+
let newFlattenNodes = [];
|
|
542
547
|
let filteredShownKeys = new Set([]);
|
|
543
548
|
if (!sugInput) {
|
|
544
549
|
expandedOptsKeys = findAncestorKeys(selectedKeys, keyEntities);
|
|
545
|
-
expandedOptsKeys.forEach(item =>
|
|
546
|
-
|
|
550
|
+
expandedOptsKeys.forEach(item => newExpandedKeys.add(item));
|
|
551
|
+
newFlattenNodes = flattenTreeData(treeData, newExpandedKeys);
|
|
547
552
|
} else {
|
|
548
553
|
filteredOptsKeys = Object.values(keyEntities)
|
|
549
554
|
.filter((item: BasicKeyEntity) => {
|
|
@@ -554,15 +559,16 @@ export default class TreeSelectFoundation<P = Record<string, any>, S = Record<st
|
|
|
554
559
|
expandedOptsKeys = findAncestorKeys(filteredOptsKeys, keyEntities, false);
|
|
555
560
|
const shownChildKeys = findDescendantKeys(filteredOptsKeys, keyEntities, true);
|
|
556
561
|
filteredShownKeys = new Set([...shownChildKeys, ...expandedOptsKeys]);
|
|
557
|
-
|
|
562
|
+
newFlattenNodes = flattenTreeData(treeData, new Set(expandedOptsKeys), showFilteredOnly && filteredShownKeys);
|
|
558
563
|
}
|
|
559
|
-
|
|
564
|
+
const newFilteredExpandedKeys = new Set(expandedOptsKeys);
|
|
565
|
+
this._adapter.notifySearch(sugInput, Array.from(newFilteredExpandedKeys));
|
|
560
566
|
this._adapter.updateState({
|
|
561
|
-
expandedKeys,
|
|
562
|
-
flattenNodes,
|
|
567
|
+
expandedKeys: this._isExpandControlled() ? expandedKeys : newExpandedKeys,
|
|
568
|
+
flattenNodes: this._isExpandControlled() ? flattenNodes : newFlattenNodes,
|
|
563
569
|
motionKeys: new Set([]),
|
|
564
570
|
filteredKeys: new Set(filteredOptsKeys),
|
|
565
|
-
filteredExpandedKeys:
|
|
571
|
+
filteredExpandedKeys: newFilteredExpandedKeys,
|
|
566
572
|
filteredShownKeys,
|
|
567
573
|
});
|
|
568
574
|
}
|
|
@@ -724,7 +730,8 @@ export default class TreeSelectFoundation<P = Record<string, any>, S = Record<st
|
|
|
724
730
|
return;
|
|
725
731
|
}
|
|
726
732
|
|
|
727
|
-
|
|
733
|
+
const isExpandControlled = this._isExpandControlled();
|
|
734
|
+
if (isSearching && !isExpandControlled) {
|
|
728
735
|
this.handleNodeExpandInSearch(e, treeNode);
|
|
729
736
|
return;
|
|
730
737
|
}
|
|
@@ -742,7 +749,7 @@ export default class TreeSelectFoundation<P = Record<string, any>, S = Record<st
|
|
|
742
749
|
}
|
|
743
750
|
this._adapter.cacheFlattenNodes(motionType === 'hide' && this._isAnimated());
|
|
744
751
|
|
|
745
|
-
if (!
|
|
752
|
+
if (!isExpandControlled) {
|
|
746
753
|
const flattenNodes = flattenTreeData(treeData, expandedKeys);
|
|
747
754
|
const motionKeys = this._isAnimated() ? getMotionKeys(eventKey, expandedKeys, keyEntities) : [];
|
|
748
755
|
const newState = {
|