@gingkoo/pandora-explorer 0.1.2 → 0.1.4
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/es/components/tree/index.d.ts +1 -1
- package/lib/es/index.js +132 -65
- package/lib/es/index.js.map +1 -1
- package/lib/es/types.d.ts +1 -0
- package/package.json +1 -1
|
@@ -39,5 +39,5 @@ export interface TreeProps {
|
|
|
39
39
|
onExpand?: (data: string[]) => void;
|
|
40
40
|
[key: string]: any;
|
|
41
41
|
}
|
|
42
|
-
declare const _default: React.ForwardRefExoticComponent<React.RefAttributes<unknown>>;
|
|
42
|
+
declare const _default: React.ForwardRefExoticComponent<Omit<TreeProps, "ref"> & React.RefAttributes<unknown>>;
|
|
43
43
|
export default _default;
|
package/lib/es/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @gingkoo/pandora-explorer v0.1.
|
|
2
|
+
* @gingkoo/pandora-explorer v0.1.4
|
|
3
3
|
*/
|
|
4
4
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
5
5
|
import cx$1 from 'classnames';
|
|
@@ -6202,7 +6202,9 @@ var Tree = /*#__PURE__*/forwardRef((props, _ref) => {
|
|
|
6202
6202
|
v.stopPropagation();
|
|
6203
6203
|
onDblclick && onDblclick?.(node.key, node);
|
|
6204
6204
|
},
|
|
6205
|
+
// filterTreeNode={searchFiles ? (v) => v.key.includes(searchFiles) : undefined}
|
|
6205
6206
|
titleRender: v => {
|
|
6207
|
+
// if (searchFiles && !v.key.includes(searchFiles)) return null;
|
|
6206
6208
|
if (v.key == '_ending') {
|
|
6207
6209
|
return jsx("div", {
|
|
6208
6210
|
style: {
|
|
@@ -8761,6 +8763,67 @@ const Layout$1 = props => {
|
|
|
8761
8763
|
x: 0,
|
|
8762
8764
|
y: 0
|
|
8763
8765
|
});
|
|
8766
|
+
const curList = useMemo(() => {
|
|
8767
|
+
if (!store?.searchFiles) return store.curlist;
|
|
8768
|
+
const expandedKeys = new Set();
|
|
8769
|
+
function searchTree(treeData, searchText) {
|
|
8770
|
+
if (!searchText) return {
|
|
8771
|
+
tree: treeData,
|
|
8772
|
+
expandedKeys: []
|
|
8773
|
+
};
|
|
8774
|
+
const result = [];
|
|
8775
|
+
treeData.forEach(node => {
|
|
8776
|
+
const {
|
|
8777
|
+
matchedNode,
|
|
8778
|
+
keys
|
|
8779
|
+
} = searchNode(node, searchText.toLowerCase());
|
|
8780
|
+
if (matchedNode) {
|
|
8781
|
+
result.push(matchedNode);
|
|
8782
|
+
keys.forEach(key => expandedKeys.add(key));
|
|
8783
|
+
}
|
|
8784
|
+
});
|
|
8785
|
+
return {
|
|
8786
|
+
tree: result,
|
|
8787
|
+
expandedKeys: Array.from(expandedKeys)
|
|
8788
|
+
};
|
|
8789
|
+
}
|
|
8790
|
+
function searchNode(node, searchText, pathKeys = []) {
|
|
8791
|
+
// 检查当前节点是否匹配
|
|
8792
|
+
const currentPath = [...pathKeys, node.key];
|
|
8793
|
+
const isMatched = node.name.toLowerCase().includes(searchText);
|
|
8794
|
+
// 如果有子节点,递归检查子节点
|
|
8795
|
+
let matchedChildren = [];
|
|
8796
|
+
let childExpandedKeys = [];
|
|
8797
|
+
if (node.children && node.children.length > 0) {
|
|
8798
|
+
node.children.forEach(child => {
|
|
8799
|
+
const {
|
|
8800
|
+
matchedNode,
|
|
8801
|
+
keys
|
|
8802
|
+
} = searchNode(child, searchText, currentPath);
|
|
8803
|
+
if (matchedNode) {
|
|
8804
|
+
matchedChildren.push(matchedNode);
|
|
8805
|
+
keys.forEach(key => childExpandedKeys.push(key));
|
|
8806
|
+
}
|
|
8807
|
+
});
|
|
8808
|
+
}
|
|
8809
|
+
if (isMatched || matchedChildren.length > 0) {
|
|
8810
|
+
return {
|
|
8811
|
+
matchedNode: {
|
|
8812
|
+
...node,
|
|
8813
|
+
children: isMatched ? node.children : matchedChildren
|
|
8814
|
+
},
|
|
8815
|
+
keys: isMatched ? currentPath : childExpandedKeys
|
|
8816
|
+
};
|
|
8817
|
+
}
|
|
8818
|
+
return {
|
|
8819
|
+
matchedNode: null,
|
|
8820
|
+
keys: []
|
|
8821
|
+
};
|
|
8822
|
+
}
|
|
8823
|
+
const result = searchTree(store.curlist, store.searchFiles);
|
|
8824
|
+
store.setExpandkey(result.expandedKeys);
|
|
8825
|
+
return result.tree;
|
|
8826
|
+
}, [store.curlist, store?.searchFiles]);
|
|
8764
8827
|
function Loading() {
|
|
8765
8828
|
return jsx("div", {
|
|
8766
8829
|
className: 'explorer-columns-loading',
|
|
@@ -8813,6 +8876,68 @@ const Layout$1 = props => {
|
|
|
8813
8876
|
function setRename(key) {
|
|
8814
8877
|
store.setReName(key);
|
|
8815
8878
|
}
|
|
8879
|
+
function renderTree() {
|
|
8880
|
+
if (store?.menutype !== 'table') return jsx(Fragment, {});
|
|
8881
|
+
return jsx(Tree, {
|
|
8882
|
+
ref: tree_srcoll,
|
|
8883
|
+
type: 'table',
|
|
8884
|
+
treeData: curList,
|
|
8885
|
+
checks: checks,
|
|
8886
|
+
activeKey: props?.activeFile,
|
|
8887
|
+
rename: store.reamekey,
|
|
8888
|
+
selectedKeys: [props?.activeFile || store.curSelect],
|
|
8889
|
+
expandedKeys: store.expandkey,
|
|
8890
|
+
loadedKeys: store.loadkey,
|
|
8891
|
+
columns: store.columns,
|
|
8892
|
+
checkType: store.checkType,
|
|
8893
|
+
isEdit: store.isEdit,
|
|
8894
|
+
isDelect: store.isDelect,
|
|
8895
|
+
isDownload: store.isDownload,
|
|
8896
|
+
isUpload: store.isDownload,
|
|
8897
|
+
selectedSuffix: store.selectedSuffix,
|
|
8898
|
+
height: height - 24,
|
|
8899
|
+
width: width,
|
|
8900
|
+
animation: false,
|
|
8901
|
+
showLine: false,
|
|
8902
|
+
isOpenMenu: isOpenMenu,
|
|
8903
|
+
icon: store.getIcons,
|
|
8904
|
+
openMenu: store.openMenu,
|
|
8905
|
+
closeMenu: store.closeMenu,
|
|
8906
|
+
isload: true,
|
|
8907
|
+
ischeck: truncate,
|
|
8908
|
+
onScroll: v => {
|
|
8909
|
+
scroll.current = v;
|
|
8910
|
+
setScroll(v);
|
|
8911
|
+
},
|
|
8912
|
+
onChecks: arr => {
|
|
8913
|
+
onCheck?.(arr);
|
|
8914
|
+
},
|
|
8915
|
+
onSelect: v => {
|
|
8916
|
+
if (v?.type == 'folder' && v.expanded) {
|
|
8917
|
+
store.setCurSelectFile(v.key);
|
|
8918
|
+
}
|
|
8919
|
+
if (isdarg) return;
|
|
8920
|
+
store.setCurSelect(v.key);
|
|
8921
|
+
},
|
|
8922
|
+
onRename: onRename,
|
|
8923
|
+
onMenuClick: onMenuClick,
|
|
8924
|
+
onDblclick: _onDblclick,
|
|
8925
|
+
loadData: loadNode,
|
|
8926
|
+
loadMenu: loadMenu,
|
|
8927
|
+
setRename: v => {
|
|
8928
|
+
setRename(v);
|
|
8929
|
+
},
|
|
8930
|
+
onLoad: v => {
|
|
8931
|
+
store.setLoadKey(v);
|
|
8932
|
+
},
|
|
8933
|
+
onExpand: v => {
|
|
8934
|
+
store.setExpandkey(v);
|
|
8935
|
+
},
|
|
8936
|
+
onChange: v => {
|
|
8937
|
+
store.setCurList(v);
|
|
8938
|
+
}
|
|
8939
|
+
});
|
|
8940
|
+
}
|
|
8816
8941
|
return jsxs("div", {
|
|
8817
8942
|
className: 'file-continer-main',
|
|
8818
8943
|
onClick: () => {
|
|
@@ -8897,65 +9022,7 @@ const Layout$1 = props => {
|
|
|
8897
9022
|
onChange: v => {
|
|
8898
9023
|
store.setCurList(v);
|
|
8899
9024
|
}
|
|
8900
|
-
}), store?.menutype == '
|
|
8901
|
-
ref: tree_srcoll,
|
|
8902
|
-
type: 'table',
|
|
8903
|
-
checks: checks,
|
|
8904
|
-
activeKey: props?.activeFile,
|
|
8905
|
-
rename: store.reamekey,
|
|
8906
|
-
selectedKeys: [props?.activeFile || store.curSelect],
|
|
8907
|
-
expandedKeys: store.expandkey,
|
|
8908
|
-
loadedKeys: store.loadkey,
|
|
8909
|
-
treeData: store.curlist,
|
|
8910
|
-
columns: store.columns,
|
|
8911
|
-
checkType: store.checkType,
|
|
8912
|
-
isEdit: store.isEdit,
|
|
8913
|
-
isDelect: store.isDelect,
|
|
8914
|
-
isDownload: store.isDownload,
|
|
8915
|
-
isUpload: store.isDownload,
|
|
8916
|
-
selectedSuffix: store.selectedSuffix,
|
|
8917
|
-
height: height - 24,
|
|
8918
|
-
width: width,
|
|
8919
|
-
animation: false,
|
|
8920
|
-
showLine: false,
|
|
8921
|
-
isOpenMenu: isOpenMenu,
|
|
8922
|
-
icon: store.getIcons,
|
|
8923
|
-
openMenu: store.openMenu,
|
|
8924
|
-
closeMenu: store.closeMenu,
|
|
8925
|
-
isload: true,
|
|
8926
|
-
ischeck: truncate,
|
|
8927
|
-
onScroll: v => {
|
|
8928
|
-
scroll.current = v;
|
|
8929
|
-
setScroll(v);
|
|
8930
|
-
},
|
|
8931
|
-
onChecks: arr => {
|
|
8932
|
-
onCheck?.(arr);
|
|
8933
|
-
},
|
|
8934
|
-
onSelect: v => {
|
|
8935
|
-
if (v?.type == 'folder' && v.expanded) {
|
|
8936
|
-
store.setCurSelectFile(v.key);
|
|
8937
|
-
}
|
|
8938
|
-
if (isdarg) return;
|
|
8939
|
-
store.setCurSelect(v.key);
|
|
8940
|
-
},
|
|
8941
|
-
onRename: onRename,
|
|
8942
|
-
onMenuClick: onMenuClick,
|
|
8943
|
-
onDblclick: _onDblclick,
|
|
8944
|
-
loadData: loadNode,
|
|
8945
|
-
loadMenu: loadMenu,
|
|
8946
|
-
setRename: v => {
|
|
8947
|
-
setRename(v);
|
|
8948
|
-
},
|
|
8949
|
-
onLoad: v => {
|
|
8950
|
-
store.setLoadKey(v);
|
|
8951
|
-
},
|
|
8952
|
-
onExpand: v => {
|
|
8953
|
-
store.setExpandkey(v);
|
|
8954
|
-
},
|
|
8955
|
-
onChange: v => {
|
|
8956
|
-
store.setCurList(v);
|
|
8957
|
-
}
|
|
8958
|
-
}), store?.menutype == 'tile' && jsx(Tile, {
|
|
9025
|
+
}), renderTree(), store?.menutype == 'tile' && jsx(Tile, {
|
|
8959
9026
|
ref: tile_srcoll,
|
|
8960
9027
|
width: width,
|
|
8961
9028
|
store: store,
|
|
@@ -9425,6 +9492,7 @@ const Explorer = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
9425
9492
|
selectedSuffix,
|
|
9426
9493
|
multiple = true,
|
|
9427
9494
|
filelist,
|
|
9495
|
+
searchFiles,
|
|
9428
9496
|
expandkey: _expandkey,
|
|
9429
9497
|
createFile,
|
|
9430
9498
|
onCopy,
|
|
@@ -9493,11 +9561,9 @@ const Explorer = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
9493
9561
|
updateCurlist(key || '');
|
|
9494
9562
|
},
|
|
9495
9563
|
createFolder: createFolder,
|
|
9496
|
-
setNavSelect:
|
|
9497
|
-
if (
|
|
9498
|
-
setCurInfo(
|
|
9499
|
-
key
|
|
9500
|
-
});
|
|
9564
|
+
setNavSelect: params => {
|
|
9565
|
+
if (params) {
|
|
9566
|
+
setCurInfo(params);
|
|
9501
9567
|
}
|
|
9502
9568
|
}
|
|
9503
9569
|
}));
|
|
@@ -10150,6 +10216,7 @@ const Explorer = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
10150
10216
|
control,
|
|
10151
10217
|
nav_expandkey,
|
|
10152
10218
|
menutype,
|
|
10219
|
+
searchFiles: searchFiles,
|
|
10153
10220
|
pathDisplay,
|
|
10154
10221
|
columns: columns || defaultColumns,
|
|
10155
10222
|
loading,
|