@douyinfe/semi-foundation 2.56.3-alpha.0 → 2.56.3
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/lib/cjs/tree/treeUtil.d.ts +1 -1
- package/lib/cjs/treeSelect/foundation.d.ts +4 -0
- package/lib/cjs/treeSelect/foundation.js +32 -2
- package/lib/cjs/upload/constants.d.ts +1 -1
- package/lib/cjs/upload/foundation.js +26 -22
- package/lib/es/tree/treeUtil.d.ts +1 -1
- package/lib/es/treeSelect/foundation.d.ts +4 -0
- package/lib/es/treeSelect/foundation.js +32 -2
- package/lib/es/upload/constants.d.ts +1 -1
- package/lib/es/upload/foundation.js +26 -22
- package/package.json +3 -3
- package/treeSelect/foundation.ts +31 -3
- package/upload/foundation.ts +22 -22
|
@@ -83,6 +83,6 @@ export declare function getValueOrKey(data: any, keyMaps?: KeyMapProps): any;
|
|
|
83
83
|
export declare function normalizeValue(value: any, withObject: boolean, keyMaps?: KeyMapProps): any;
|
|
84
84
|
export declare function updateKeys(keySet: Set<string> | string[], keyEntities: KeyEntities): string[];
|
|
85
85
|
export declare function calcDisabledKeys(keyEntities: KeyEntities, keyMaps?: KeyMapProps): Set<string>;
|
|
86
|
-
export declare function calcDropRelativePosition(event: any, treeNode: any):
|
|
86
|
+
export declare function calcDropRelativePosition(event: any, treeNode: any): 1 | -1 | 0;
|
|
87
87
|
export declare function getDragNodesKeys(key: string, keyEntities: KeyEntities): string[];
|
|
88
88
|
export declare function calcDropActualPosition(pos: string, relativeDropPos: any): any;
|
|
@@ -107,6 +107,8 @@ export interface TreeSelectAdapter<P = Record<string, any>, S = Record<string, a
|
|
|
107
107
|
updateInputFocus: (bool: boolean) => void;
|
|
108
108
|
updateLoadKeys: (data: BasicTreeNodeData, resolve: (value?: any) => void) => void;
|
|
109
109
|
updateIsFocus: (bool: boolean) => void;
|
|
110
|
+
setClearInputFlag: (flag: boolean) => void;
|
|
111
|
+
getClearInputFlag: () => boolean;
|
|
110
112
|
}
|
|
111
113
|
export default class TreeSelectFoundation<P = Record<string, any>, S = Record<string, any>> extends BaseFoundation<TreeSelectAdapter<P, S>, P, S> {
|
|
112
114
|
constructor(adapter: TreeSelectAdapter<P, S>);
|
|
@@ -183,4 +185,6 @@ export default class TreeSelectFoundation<P = Record<string, any>, S = Record<st
|
|
|
183
185
|
*/
|
|
184
186
|
handleInputTriggerFocus(): void;
|
|
185
187
|
setLoadKeys(data: BasicTreeNodeData, resolve: (value?: any) => void): void;
|
|
188
|
+
handlePopoverVisibleChange(isVisible: boolean): void;
|
|
189
|
+
handleAfterClose(): void;
|
|
186
190
|
}
|
|
@@ -443,7 +443,7 @@ class TreeSelectFoundation extends _foundation.default {
|
|
|
443
443
|
} = this.getProps();
|
|
444
444
|
const newExpandedKeys = new Set(expandedKeys);
|
|
445
445
|
const isExpandControlled = this._isExpandControlled();
|
|
446
|
-
const expandedOptsKeys = (0, _treeUtil.findAncestorKeys)(selectedKeys, keyEntities);
|
|
446
|
+
const expandedOptsKeys = (0, _treeUtil.findAncestorKeys)(selectedKeys, keyEntities, false);
|
|
447
447
|
expandedOptsKeys.forEach(item => newExpandedKeys.add(item));
|
|
448
448
|
const newFlattenNodes = (0, _treeUtil.flattenTreeData)(treeData, newExpandedKeys, keyMaps);
|
|
449
449
|
this._adapter.updateState({
|
|
@@ -480,7 +480,7 @@ class TreeSelectFoundation extends _foundation.default {
|
|
|
480
480
|
let newFlattenNodes = [];
|
|
481
481
|
let filteredShownKeys = new Set([]);
|
|
482
482
|
if (!sugInput) {
|
|
483
|
-
expandedOptsKeys = (0, _treeUtil.findAncestorKeys)(selectedKeys, keyEntities);
|
|
483
|
+
expandedOptsKeys = (0, _treeUtil.findAncestorKeys)(selectedKeys, keyEntities, false);
|
|
484
484
|
expandedOptsKeys.forEach(item => newExpandedKeys.add(item));
|
|
485
485
|
newFlattenNodes = (0, _treeUtil.flattenTreeData)(treeData, newExpandedKeys, keyMaps);
|
|
486
486
|
} else {
|
|
@@ -783,5 +783,35 @@ class TreeSelectFoundation extends _foundation.default {
|
|
|
783
783
|
setLoadKeys(data, resolve) {
|
|
784
784
|
this._adapter.updateLoadKeys(data, resolve);
|
|
785
785
|
}
|
|
786
|
+
handlePopoverVisibleChange(isVisible) {
|
|
787
|
+
const {
|
|
788
|
+
filterTreeNode,
|
|
789
|
+
searchAutoFocus,
|
|
790
|
+
searchPosition
|
|
791
|
+
} = this.getProps();
|
|
792
|
+
const inputValue = this.getState('inputValue');
|
|
793
|
+
// 将 inputValue 清空,如果有选中值的话,选中项能够快速回显
|
|
794
|
+
// Clear the inputValue. If there is a selected value, the selected item can be quickly echoed.
|
|
795
|
+
if (isVisible === false && filterTreeNode) {
|
|
796
|
+
inputValue && this._adapter.setClearInputFlag(true);
|
|
797
|
+
this.clearInputValue();
|
|
798
|
+
}
|
|
799
|
+
if (filterTreeNode && searchPosition === _constants.strings.SEARCH_POSITION_DROPDOWN && isVisible && searchAutoFocus) {
|
|
800
|
+
this.focusInput(true);
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
handleAfterClose() {
|
|
804
|
+
// flattenNode 的变化将导致弹出层面板中的选项数目变化
|
|
805
|
+
// 在弹层完全收起之后,再通过 clearInput 重新计算 state 中的 expandedKey, flattenNode
|
|
806
|
+
// 防止在弹出层未收起时弹层面板中选项数目变化导致视觉上出现弹层闪动问题
|
|
807
|
+
// Changes to flattenNode will cause the number of options in the popup panel to change
|
|
808
|
+
// After the pop-up layer is completely closed, recalculate the expandedKey and flattenNode in the state through clearInput.
|
|
809
|
+
// Prevent the pop-up layer from flickering visually due to changes in the number of options in the pop-up panel when the pop-up layer is not collapsed.
|
|
810
|
+
const {
|
|
811
|
+
filterTreeNode
|
|
812
|
+
} = this.getProps();
|
|
813
|
+
const shouldClear = this._adapter.getClearInputFlag();
|
|
814
|
+
filterTreeNode && shouldClear && this.clearInput();
|
|
815
|
+
}
|
|
786
816
|
}
|
|
787
817
|
exports.default = TreeSelectFoundation;
|
|
@@ -18,7 +18,7 @@ declare const strings: {
|
|
|
18
18
|
DRAG_AREA_ILLEGAL: string;
|
|
19
19
|
TRIGGER_AUTO: "auto";
|
|
20
20
|
TRIGGER_CUSTOM: "custom";
|
|
21
|
-
UPLOAD_TRIGGER: ("
|
|
21
|
+
UPLOAD_TRIGGER: ("auto" | "custom")[];
|
|
22
22
|
VALIDATE_STATUS: readonly ["default", "error", "warning", "success"];
|
|
23
23
|
PROMPT_POSITION: readonly ["left", "right", "bottom"];
|
|
24
24
|
};
|
|
@@ -66,7 +66,7 @@ class UploadFoundation extends _foundation.default {
|
|
|
66
66
|
addOnPasting
|
|
67
67
|
} = this.getProps();
|
|
68
68
|
this.releaseMemory();
|
|
69
|
-
if (
|
|
69
|
+
if (!disabled) {
|
|
70
70
|
this.unbindPastingHandler();
|
|
71
71
|
}
|
|
72
72
|
}
|
|
@@ -949,27 +949,31 @@ class UploadFoundation extends _foundation.default {
|
|
|
949
949
|
handlePasting(e) {
|
|
950
950
|
const isMac = this._adapter.isMac();
|
|
951
951
|
const isCombineKeydown = isMac ? e.metaKey : e.ctrlKey;
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
//
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
952
|
+
const {
|
|
953
|
+
addOnPasting
|
|
954
|
+
} = this.getProps();
|
|
955
|
+
if (addOnPasting) {
|
|
956
|
+
if (isCombineKeydown && e.code === 'KeyV' && e.target === document.body) {
|
|
957
|
+
// https://github.com/microsoft/TypeScript/issues/33923
|
|
958
|
+
const permissionName = 'clipboard-read';
|
|
959
|
+
// The main thread should not be blocked by clipboard, so callback writing is required here. No await here
|
|
960
|
+
navigator.permissions.query({
|
|
961
|
+
name: permissionName
|
|
962
|
+
}).then(result => {
|
|
963
|
+
if (result.state === 'granted' || result.state === 'prompt') {
|
|
964
|
+
// user has authorized or will authorize
|
|
965
|
+
navigator.clipboard.read().then(clipboardItems => {
|
|
966
|
+
// Process the data read from the pasteboard
|
|
967
|
+
// Check the returned data type to determine if it is image data, and process accordingly
|
|
968
|
+
this.readFileFromClipboard(clipboardItems);
|
|
969
|
+
});
|
|
970
|
+
} else {
|
|
971
|
+
this._adapter.notifyPastingError(result);
|
|
972
|
+
}
|
|
973
|
+
}).catch(error => {
|
|
974
|
+
this._adapter.notifyPastingError(error);
|
|
975
|
+
});
|
|
976
|
+
}
|
|
973
977
|
}
|
|
974
978
|
}
|
|
975
979
|
bindPastingHandler() {
|
|
@@ -83,6 +83,6 @@ export declare function getValueOrKey(data: any, keyMaps?: KeyMapProps): any;
|
|
|
83
83
|
export declare function normalizeValue(value: any, withObject: boolean, keyMaps?: KeyMapProps): any;
|
|
84
84
|
export declare function updateKeys(keySet: Set<string> | string[], keyEntities: KeyEntities): string[];
|
|
85
85
|
export declare function calcDisabledKeys(keyEntities: KeyEntities, keyMaps?: KeyMapProps): Set<string>;
|
|
86
|
-
export declare function calcDropRelativePosition(event: any, treeNode: any):
|
|
86
|
+
export declare function calcDropRelativePosition(event: any, treeNode: any): 1 | -1 | 0;
|
|
87
87
|
export declare function getDragNodesKeys(key: string, keyEntities: KeyEntities): string[];
|
|
88
88
|
export declare function calcDropActualPosition(pos: string, relativeDropPos: any): any;
|
|
@@ -107,6 +107,8 @@ export interface TreeSelectAdapter<P = Record<string, any>, S = Record<string, a
|
|
|
107
107
|
updateInputFocus: (bool: boolean) => void;
|
|
108
108
|
updateLoadKeys: (data: BasicTreeNodeData, resolve: (value?: any) => void) => void;
|
|
109
109
|
updateIsFocus: (bool: boolean) => void;
|
|
110
|
+
setClearInputFlag: (flag: boolean) => void;
|
|
111
|
+
getClearInputFlag: () => boolean;
|
|
110
112
|
}
|
|
111
113
|
export default class TreeSelectFoundation<P = Record<string, any>, S = Record<string, any>> extends BaseFoundation<TreeSelectAdapter<P, S>, P, S> {
|
|
112
114
|
constructor(adapter: TreeSelectAdapter<P, S>);
|
|
@@ -183,4 +185,6 @@ export default class TreeSelectFoundation<P = Record<string, any>, S = Record<st
|
|
|
183
185
|
*/
|
|
184
186
|
handleInputTriggerFocus(): void;
|
|
185
187
|
setLoadKeys(data: BasicTreeNodeData, resolve: (value?: any) => void): void;
|
|
188
|
+
handlePopoverVisibleChange(isVisible: boolean): void;
|
|
189
|
+
handleAfterClose(): void;
|
|
186
190
|
}
|
|
@@ -436,7 +436,7 @@ export default class TreeSelectFoundation extends BaseFoundation {
|
|
|
436
436
|
} = this.getProps();
|
|
437
437
|
const newExpandedKeys = new Set(expandedKeys);
|
|
438
438
|
const isExpandControlled = this._isExpandControlled();
|
|
439
|
-
const expandedOptsKeys = findAncestorKeys(selectedKeys, keyEntities);
|
|
439
|
+
const expandedOptsKeys = findAncestorKeys(selectedKeys, keyEntities, false);
|
|
440
440
|
expandedOptsKeys.forEach(item => newExpandedKeys.add(item));
|
|
441
441
|
const newFlattenNodes = flattenTreeData(treeData, newExpandedKeys, keyMaps);
|
|
442
442
|
this._adapter.updateState({
|
|
@@ -473,7 +473,7 @@ export default class TreeSelectFoundation extends BaseFoundation {
|
|
|
473
473
|
let newFlattenNodes = [];
|
|
474
474
|
let filteredShownKeys = new Set([]);
|
|
475
475
|
if (!sugInput) {
|
|
476
|
-
expandedOptsKeys = findAncestorKeys(selectedKeys, keyEntities);
|
|
476
|
+
expandedOptsKeys = findAncestorKeys(selectedKeys, keyEntities, false);
|
|
477
477
|
expandedOptsKeys.forEach(item => newExpandedKeys.add(item));
|
|
478
478
|
newFlattenNodes = flattenTreeData(treeData, newExpandedKeys, keyMaps);
|
|
479
479
|
} else {
|
|
@@ -776,4 +776,34 @@ export default class TreeSelectFoundation extends BaseFoundation {
|
|
|
776
776
|
setLoadKeys(data, resolve) {
|
|
777
777
|
this._adapter.updateLoadKeys(data, resolve);
|
|
778
778
|
}
|
|
779
|
+
handlePopoverVisibleChange(isVisible) {
|
|
780
|
+
const {
|
|
781
|
+
filterTreeNode,
|
|
782
|
+
searchAutoFocus,
|
|
783
|
+
searchPosition
|
|
784
|
+
} = this.getProps();
|
|
785
|
+
const inputValue = this.getState('inputValue');
|
|
786
|
+
// 将 inputValue 清空,如果有选中值的话,选中项能够快速回显
|
|
787
|
+
// Clear the inputValue. If there is a selected value, the selected item can be quickly echoed.
|
|
788
|
+
if (isVisible === false && filterTreeNode) {
|
|
789
|
+
inputValue && this._adapter.setClearInputFlag(true);
|
|
790
|
+
this.clearInputValue();
|
|
791
|
+
}
|
|
792
|
+
if (filterTreeNode && searchPosition === strings.SEARCH_POSITION_DROPDOWN && isVisible && searchAutoFocus) {
|
|
793
|
+
this.focusInput(true);
|
|
794
|
+
}
|
|
795
|
+
}
|
|
796
|
+
handleAfterClose() {
|
|
797
|
+
// flattenNode 的变化将导致弹出层面板中的选项数目变化
|
|
798
|
+
// 在弹层完全收起之后,再通过 clearInput 重新计算 state 中的 expandedKey, flattenNode
|
|
799
|
+
// 防止在弹出层未收起时弹层面板中选项数目变化导致视觉上出现弹层闪动问题
|
|
800
|
+
// Changes to flattenNode will cause the number of options in the popup panel to change
|
|
801
|
+
// After the pop-up layer is completely closed, recalculate the expandedKey and flattenNode in the state through clearInput.
|
|
802
|
+
// Prevent the pop-up layer from flickering visually due to changes in the number of options in the pop-up panel when the pop-up layer is not collapsed.
|
|
803
|
+
const {
|
|
804
|
+
filterTreeNode
|
|
805
|
+
} = this.getProps();
|
|
806
|
+
const shouldClear = this._adapter.getClearInputFlag();
|
|
807
|
+
filterTreeNode && shouldClear && this.clearInput();
|
|
808
|
+
}
|
|
779
809
|
}
|
|
@@ -18,7 +18,7 @@ declare const strings: {
|
|
|
18
18
|
DRAG_AREA_ILLEGAL: string;
|
|
19
19
|
TRIGGER_AUTO: "auto";
|
|
20
20
|
TRIGGER_CUSTOM: "custom";
|
|
21
|
-
UPLOAD_TRIGGER: ("
|
|
21
|
+
UPLOAD_TRIGGER: ("auto" | "custom")[];
|
|
22
22
|
VALIDATE_STATUS: readonly ["default", "error", "warning", "success"];
|
|
23
23
|
PROMPT_POSITION: readonly ["left", "right", "bottom"];
|
|
24
24
|
};
|
|
@@ -59,7 +59,7 @@ class UploadFoundation extends BaseFoundation {
|
|
|
59
59
|
addOnPasting
|
|
60
60
|
} = this.getProps();
|
|
61
61
|
this.releaseMemory();
|
|
62
|
-
if (
|
|
62
|
+
if (!disabled) {
|
|
63
63
|
this.unbindPastingHandler();
|
|
64
64
|
}
|
|
65
65
|
}
|
|
@@ -942,27 +942,31 @@ class UploadFoundation extends BaseFoundation {
|
|
|
942
942
|
handlePasting(e) {
|
|
943
943
|
const isMac = this._adapter.isMac();
|
|
944
944
|
const isCombineKeydown = isMac ? e.metaKey : e.ctrlKey;
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
//
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
945
|
+
const {
|
|
946
|
+
addOnPasting
|
|
947
|
+
} = this.getProps();
|
|
948
|
+
if (addOnPasting) {
|
|
949
|
+
if (isCombineKeydown && e.code === 'KeyV' && e.target === document.body) {
|
|
950
|
+
// https://github.com/microsoft/TypeScript/issues/33923
|
|
951
|
+
const permissionName = 'clipboard-read';
|
|
952
|
+
// The main thread should not be blocked by clipboard, so callback writing is required here. No await here
|
|
953
|
+
navigator.permissions.query({
|
|
954
|
+
name: permissionName
|
|
955
|
+
}).then(result => {
|
|
956
|
+
if (result.state === 'granted' || result.state === 'prompt') {
|
|
957
|
+
// user has authorized or will authorize
|
|
958
|
+
navigator.clipboard.read().then(clipboardItems => {
|
|
959
|
+
// Process the data read from the pasteboard
|
|
960
|
+
// Check the returned data type to determine if it is image data, and process accordingly
|
|
961
|
+
this.readFileFromClipboard(clipboardItems);
|
|
962
|
+
});
|
|
963
|
+
} else {
|
|
964
|
+
this._adapter.notifyPastingError(result);
|
|
965
|
+
}
|
|
966
|
+
}).catch(error => {
|
|
967
|
+
this._adapter.notifyPastingError(error);
|
|
968
|
+
});
|
|
969
|
+
}
|
|
966
970
|
}
|
|
967
971
|
}
|
|
968
972
|
bindPastingHandler() {
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@douyinfe/semi-foundation",
|
|
3
|
-
"version": "2.56.3
|
|
3
|
+
"version": "2.56.3",
|
|
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.56.3
|
|
10
|
+
"@douyinfe/semi-animation": "2.56.3",
|
|
11
11
|
"async-validator": "^3.5.0",
|
|
12
12
|
"classnames": "^2.2.6",
|
|
13
13
|
"date-fns": "^2.29.3",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"*.scss",
|
|
25
25
|
"*.css"
|
|
26
26
|
],
|
|
27
|
-
"gitHead": "
|
|
27
|
+
"gitHead": "933e2bf0c8d66a690b83d0410656ba4cdf265537",
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@babel/plugin-transform-runtime": "^7.15.8",
|
|
30
30
|
"@babel/preset-env": "^7.15.8",
|
package/treeSelect/foundation.ts
CHANGED
|
@@ -199,7 +199,9 @@ export interface TreeSelectAdapter<P = Record<string, any>, S = Record<string, a
|
|
|
199
199
|
notifyLoad: (newLoadedKeys: Set<string>, data: BasicTreeNodeData) => void;
|
|
200
200
|
updateInputFocus: (bool: boolean) => void;
|
|
201
201
|
updateLoadKeys: (data: BasicTreeNodeData, resolve: (value?: any) => void) => void;
|
|
202
|
-
updateIsFocus: (bool: boolean) => void
|
|
202
|
+
updateIsFocus: (bool: boolean) => void;
|
|
203
|
+
setClearInputFlag: (flag: boolean) => void;
|
|
204
|
+
getClearInputFlag: () => boolean
|
|
203
205
|
}
|
|
204
206
|
|
|
205
207
|
export default class TreeSelectFoundation<P = Record<string, any>, S = Record<string, any>> extends BaseFoundation<TreeSelectAdapter<P, S>, P, S> {
|
|
@@ -588,7 +590,7 @@ export default class TreeSelectFoundation<P = Record<string, any>, S = Record<st
|
|
|
588
590
|
const { keyMaps } = this.getProps();
|
|
589
591
|
const newExpandedKeys: Set<string> = new Set(expandedKeys);
|
|
590
592
|
const isExpandControlled = this._isExpandControlled();
|
|
591
|
-
const expandedOptsKeys = findAncestorKeys(selectedKeys, keyEntities);
|
|
593
|
+
const expandedOptsKeys = findAncestorKeys(selectedKeys, keyEntities, false);
|
|
592
594
|
expandedOptsKeys.forEach(item => newExpandedKeys.add(item));
|
|
593
595
|
const newFlattenNodes = flattenTreeData(treeData, newExpandedKeys, keyMaps);
|
|
594
596
|
|
|
@@ -616,7 +618,7 @@ export default class TreeSelectFoundation<P = Record<string, any>, S = Record<st
|
|
|
616
618
|
let newFlattenNodes = [];
|
|
617
619
|
let filteredShownKeys = new Set([]);
|
|
618
620
|
if (!sugInput) {
|
|
619
|
-
expandedOptsKeys = findAncestorKeys(selectedKeys, keyEntities);
|
|
621
|
+
expandedOptsKeys = findAncestorKeys(selectedKeys, keyEntities, false);
|
|
620
622
|
expandedOptsKeys.forEach(item => newExpandedKeys.add(item));
|
|
621
623
|
newFlattenNodes = flattenTreeData(treeData, newExpandedKeys, keyMaps);
|
|
622
624
|
} else {
|
|
@@ -883,4 +885,30 @@ export default class TreeSelectFoundation<P = Record<string, any>, S = Record<st
|
|
|
883
885
|
setLoadKeys(data: BasicTreeNodeData, resolve: (value?: any) => void) {
|
|
884
886
|
this._adapter.updateLoadKeys(data, resolve);
|
|
885
887
|
}
|
|
888
|
+
|
|
889
|
+
handlePopoverVisibleChange(isVisible: boolean) {
|
|
890
|
+
const { filterTreeNode, searchAutoFocus, searchPosition } = this.getProps();
|
|
891
|
+
const inputValue = this.getState('inputValue');
|
|
892
|
+
// 将 inputValue 清空,如果有选中值的话,选中项能够快速回显
|
|
893
|
+
// Clear the inputValue. If there is a selected value, the selected item can be quickly echoed.
|
|
894
|
+
if (isVisible === false && filterTreeNode) {
|
|
895
|
+
inputValue && this._adapter.setClearInputFlag(true);
|
|
896
|
+
this.clearInputValue();
|
|
897
|
+
}
|
|
898
|
+
if (filterTreeNode && searchPosition === strings.SEARCH_POSITION_DROPDOWN && isVisible && searchAutoFocus) {
|
|
899
|
+
this.focusInput(true);
|
|
900
|
+
}
|
|
901
|
+
}
|
|
902
|
+
|
|
903
|
+
handleAfterClose() {
|
|
904
|
+
// flattenNode 的变化将导致弹出层面板中的选项数目变化
|
|
905
|
+
// 在弹层完全收起之后,再通过 clearInput 重新计算 state 中的 expandedKey, flattenNode
|
|
906
|
+
// 防止在弹出层未收起时弹层面板中选项数目变化导致视觉上出现弹层闪动问题
|
|
907
|
+
// Changes to flattenNode will cause the number of options in the popup panel to change
|
|
908
|
+
// After the pop-up layer is completely closed, recalculate the expandedKey and flattenNode in the state through clearInput.
|
|
909
|
+
// Prevent the pop-up layer from flickering visually due to changes in the number of options in the pop-up panel when the pop-up layer is not collapsed.
|
|
910
|
+
const { filterTreeNode } = this.getProps();
|
|
911
|
+
const shouldClear = this._adapter.getClearInputFlag();
|
|
912
|
+
filterTreeNode && shouldClear && this.clearInput();
|
|
913
|
+
}
|
|
886
914
|
}
|
package/upload/foundation.ts
CHANGED
|
@@ -107,7 +107,7 @@ class UploadFoundation<P = Record<string, any>, S = Record<string, any>> extends
|
|
|
107
107
|
destroy() {
|
|
108
108
|
const { disabled, addOnPasting } = this.getProps();
|
|
109
109
|
this.releaseMemory();
|
|
110
|
-
if (
|
|
110
|
+
if (!disabled) {
|
|
111
111
|
this.unbindPastingHandler();
|
|
112
112
|
}
|
|
113
113
|
}
|
|
@@ -884,31 +884,31 @@ class UploadFoundation<P = Record<string, any>, S = Record<string, any>> extends
|
|
|
884
884
|
handlePasting(e: any) {
|
|
885
885
|
const isMac = this._adapter.isMac();
|
|
886
886
|
const isCombineKeydown = isMac ? e.metaKey : e.ctrlKey;
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
.
|
|
894
|
-
.
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
.read()
|
|
900
|
-
.then(clipboardItems => {
|
|
887
|
+
const { addOnPasting } = this.getProps();
|
|
888
|
+
|
|
889
|
+
if (addOnPasting) {
|
|
890
|
+
if (isCombineKeydown && e.code === 'KeyV' && e.target === document.body) {
|
|
891
|
+
// https://github.com/microsoft/TypeScript/issues/33923
|
|
892
|
+
const permissionName = 'clipboard-read' as PermissionName;
|
|
893
|
+
// The main thread should not be blocked by clipboard, so callback writing is required here. No await here
|
|
894
|
+
navigator.permissions
|
|
895
|
+
.query({ name: permissionName })
|
|
896
|
+
.then(result => {
|
|
897
|
+
if (result.state === 'granted' || result.state === 'prompt') {
|
|
898
|
+
// user has authorized or will authorize
|
|
899
|
+
navigator.clipboard.read().then(clipboardItems => {
|
|
901
900
|
// Process the data read from the pasteboard
|
|
902
901
|
// Check the returned data type to determine if it is image data, and process accordingly
|
|
903
902
|
this.readFileFromClipboard(clipboardItems);
|
|
904
903
|
});
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
904
|
+
} else {
|
|
905
|
+
this._adapter.notifyPastingError(result);
|
|
906
|
+
}
|
|
907
|
+
})
|
|
908
|
+
.catch(error => {
|
|
909
|
+
this._adapter.notifyPastingError(error);
|
|
910
|
+
});
|
|
911
|
+
}
|
|
912
912
|
}
|
|
913
913
|
}
|
|
914
914
|
|