@gingkoo/pandora-explorer 0.1.10 → 0.1.11-alpha.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.
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import './index.less';
3
2
  export declare const IconsMap: Map<string, import("react/jsx-runtime").JSX.Element>;
4
3
  export declare function FavoriteSvg(): import("react/jsx-runtime").JSX.Element;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  export declare function getMenu(key: string): import("react").ComponentType<{}>;
3
2
  export declare function registerMenu(key: string, component: any): void;
4
3
  export declare function addMenuItem(key: string | string[], menu: any[]): void;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { Key, FlattenNode } from '../interface';
3
2
  export declare function findExpandedKeys(prev?: Key[], next?: Key[]): {
4
3
  add: boolean;
package/lib/es/css.d.ts CHANGED
@@ -1,10 +1,10 @@
1
- export declare const flush: () => void, hydrate: (ids: string[]) => void, cx: (...classNames: import("@emotion/css/create-instance").ClassNamesArg[]) => string, merge: (className: string) => string, getRegisteredStyles: (registeredStyles: string[], className: string) => string, injectGlobal: {
2
- (template: TemplateStringsArray, ...args: import("@emotion/css/create-instance").CSSInterpolation[]): void;
3
- (...args: import("@emotion/css/create-instance").CSSInterpolation[]): void;
1
+ export declare const flush: () => void, hydrate: (ids: Array<string>) => void, cx: (...classNames: Array<import("@emotion/css/create-instance").ClassNamesArg>) => string, merge: (className: string) => string, getRegisteredStyles: (registeredStyles: Array<string>, className: string) => string, injectGlobal: {
2
+ (template: TemplateStringsArray, ...args: Array<import("@emotion/css/create-instance").CSSInterpolation>): void;
3
+ (...args: Array<import("@emotion/css/create-instance").CSSInterpolation>): void;
4
4
  }, keyframes: {
5
- (template: TemplateStringsArray, ...args: import("@emotion/css/create-instance").CSSInterpolation[]): string;
6
- (...args: import("@emotion/css/create-instance").CSSInterpolation[]): string;
5
+ (template: TemplateStringsArray, ...args: Array<import("@emotion/css/create-instance").CSSInterpolation>): string;
6
+ (...args: Array<import("@emotion/css/create-instance").CSSInterpolation>): string;
7
7
  }, css: {
8
- (template: TemplateStringsArray, ...args: import("@emotion/css/create-instance").CSSInterpolation[]): string;
9
- (...args: import("@emotion/css/create-instance").CSSInterpolation[]): string;
8
+ (template: TemplateStringsArray, ...args: Array<import("@emotion/css/create-instance").CSSInterpolation>): string;
9
+ (...args: Array<import("@emotion/css/create-instance").CSSInterpolation>): string;
10
10
  }, sheet: import("@emotion/css/create-instance").CSSStyleSheet, cache: import("@emotion/css/create-instance").EmotionCache;
package/lib/es/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @gingkoo/pandora-explorer v0.1.10
2
+ * @gingkoo/pandora-explorer v0.1.11-alpha.2
3
3
  */
4
4
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
5
5
  import cx$1 from 'classnames';
@@ -933,7 +933,7 @@ function UploadSvg() {
933
933
  });
934
934
  }
935
935
 
936
- var css_248z$d = ".explorer-container .frame-explorer-main {\n width: 100%;\n height: 100%;\n overflow: hidden;\n}\n.explorer-container .frame-explorer-main .frame-left {\n position: relative;\n border-right: 1px solid rgba(100, 100, 100, 0.1);\n height: 100%;\n}\n.explorer-container .frame-explorer-main .frame-left::after {\n position: absolute;\n content: ' ';\n top: 50%;\n right: 1px;\n width: 1px;\n height: 18px;\n margin-left: -1px;\n margin-top: -9px;\n border: 1px solid #ddd;\n border-top: none;\n border-bottom: none;\n backdrop-filter: none;\n border-radius: 0;\n background: transparent;\n box-sizing: content-box;\n -webkit-backdrop-filter: blur(10px);\n z-index: 2;\n}\n.explorer-container .frame-explorer-main .frame-right {\n border-right: 1px solid #f5f5f5;\n height: 100%;\n}\n.explorer-container .frame-explorer-main .frame-right .frame-header {\n width: 100%;\n height: 85px;\n min-width: 400px;\n position: relative;\n background: #fff;\n}\n.explorer-container .frame-explorer-main .frame-right .frame-main {\n position: relative;\n height: 100%;\n}\n.explorer-container .app-wrapper {\n height: 100%;\n}\n.explorer-label-icon {\n display: inline-block;\n position: relative;\n box-sizing: border-box !important;\n}\n.explorer-label-icon > div {\n position: relative;\n width: 100%;\n height: 100%;\n border-radius: 50% !important;\n}\n.explorer-label-icon > div::after {\n width: 40%;\n height: 40%;\n border-radius: 50%;\n content: ' ';\n background: linear-gradient(45deg, #ffffff7d, #ffffff00);\n margin-top: 4px;\n position: absolute;\n right: 15%;\n top: 15%;\n}\n";
936
+ var css_248z$d = ".explorer-container .frame-explorer-main {\n width: 100%;\n height: 100%;\n overflow: hidden;\n}\n.explorer-container .frame-explorer-main .frame-left {\n position: relative;\n border-right: 1px solid rgba(100, 100, 100, 0.1);\n height: 100%;\n}\n.explorer-container .frame-explorer-main .frame-left::after {\n position: absolute;\n content: ' ';\n top: 50%;\n right: 1px;\n width: 1px;\n height: 18px;\n margin-left: -1px;\n margin-top: -9px;\n border: 1px solid #ddd;\n border-top: none;\n border-bottom: none;\n backdrop-filter: none;\n border-radius: 0;\n background: transparent;\n box-sizing: content-box;\n -webkit-backdrop-filter: blur(10px);\n z-index: 2;\n}\n.explorer-container .frame-explorer-main .frame-right {\n border-right: 1px solid #f5f5f5;\n height: 100%;\n}\n.explorer-container .frame-explorer-main .frame-right .frame-header {\n width: 100%;\n height: 85px;\n min-width: 400px;\n position: relative;\n background: #fff;\n}\n.explorer-container .frame-explorer-main .frame-right .frame-main {\n position: relative;\n height: 100%;\n}\n.explorer-container .app-wrapper {\n height: 100%;\n}\n.explorer-container .rc-tree-list-holder-inner::-webkit-scrollbar {\n display: none;\n width: 0;\n height: 0;\n}\n.explorer-label-icon {\n display: inline-block;\n position: relative;\n box-sizing: border-box !important;\n}\n.explorer-label-icon > div {\n position: relative;\n width: 100%;\n height: 100%;\n border-radius: 50% !important;\n}\n.explorer-label-icon > div::after {\n width: 40%;\n height: 40%;\n border-radius: 50%;\n content: ' ';\n background: linear-gradient(45deg, #ffffff7d, #ffffff00);\n margin-top: 4px;\n position: absolute;\n right: 15%;\n top: 15%;\n}\n";
937
937
  styleInject(css_248z$d);
938
938
 
939
939
  const {
@@ -1291,9 +1291,6 @@ var css_248z$9 = "._dropdown_menu {\n background: #fff;\n min-width: 45px;\n
1291
1291
  styleInject(css_248z$9);
1292
1292
 
1293
1293
  function returnDocument(element) {
1294
- if (element) {
1295
- return element.ownerDocument;
1296
- }
1297
1294
  return window.document;
1298
1295
  }
1299
1296
  function Dropdown(props) {
@@ -1889,7 +1886,7 @@ function menuIcon(icon) {
1889
1886
  suffix: icon
1890
1887
  }, 'explorer-menu-icon');
1891
1888
  }
1892
- if ( /*#__PURE__*/React__default.isValidElement(icon)) {
1889
+ if (/*#__PURE__*/React__default.isValidElement(icon)) {
1893
1890
  return jsx("span", {
1894
1891
  className: 'explorer-menu-icon x-icon',
1895
1892
  children: icon
@@ -4352,9 +4349,7 @@ function cleanConductCheck(keys, halfKeys, levelEntities, maxLevel, syntheticGet
4352
4349
  */
4353
4350
  function conductCheck(keyList, checked, keyEntities, getCheckDisabled) {
4354
4351
  let syntheticGetCheckDisabled;
4355
- if (getCheckDisabled) {
4356
- syntheticGetCheckDisabled = getCheckDisabled;
4357
- } else {
4352
+ {
4358
4353
  syntheticGetCheckDisabled = isCheckDisabled;
4359
4354
  }
4360
4355
  // We only handle exist keys
@@ -5003,7 +4998,6 @@ let Tree$1 = class Tree extends React.Component {
5003
4998
  checkedKeys,
5004
4999
  halfCheckedKeys
5005
5000
  } = conductCheck(Array.from(keySet), {
5006
- checked: false,
5007
5001
  halfCheckedKeys
5008
5002
  }, keyEntities));
5009
5003
  }
@@ -5758,7 +5752,7 @@ function TableItem(props) {
5758
5752
  });
5759
5753
  }
5760
5754
 
5761
- var TreeItem = (props => {
5755
+ var TreeItem = props => {
5762
5756
  const {
5763
5757
  onRename,
5764
5758
  onMenuClick,
@@ -5872,7 +5866,7 @@ var TreeItem = (props => {
5872
5866
  })]
5873
5867
  })
5874
5868
  });
5875
- });
5869
+ };
5876
5870
 
5877
5871
  var css_248z$6 = ".explorer-notdata {\n display: flex;\n height: 100%;\n justify-content: center;\n}\n.explorer-notdata .tree-empty {\n position: relative;\n top: 100px;\n width: 200px;\n height: 135px;\n text-align: center;\n}\n.explorer-notdata .tree-empty .empty-svg {\n width: 200px;\n height: 115px;\n overflow: hidden;\n}\n.explorer-notdata .tree-empty > span {\n display: inline-block;\n background: rgba(160, 160, 160, 0.1);\n padding: 3px 10px;\n border-radius: 10px;\n font-size: 0.9em;\n margin-top: 10px;\n line-height: 1;\n color: #999;\n user-select: none;\n}\n";
5878
5872
  styleInject(css_248z$6);
@@ -6085,7 +6079,7 @@ var Tree = /*#__PURE__*/forwardRef((props, _ref) => {
6085
6079
  //树s的懒加载
6086
6080
  const getNewTreeData = (treeData, curKey, child, level) => {
6087
6081
  const loop = (data, levelkey) => {
6088
- if (level < 1 || curKey.length - 3 > level * 2) return;
6082
+ if (curKey.length - 3 > level * 2) return;
6089
6083
  data.forEach((item, index) => {
6090
6084
  let l = levelkey + `-${index}`;
6091
6085
  if (curKey.indexOf(l) === 0) {
@@ -9544,14 +9538,15 @@ const Explorer = /*#__PURE__*/forwardRef((props, ref) => {
9544
9538
  const [menutype, setMenutype] = useState('tile');
9545
9539
  const [infoshow, setInfoShow] = useState(false);
9546
9540
  const [loading, setLoading] = useState(ApiStatusEnum.READY);
9547
- useState(100);
9548
- useState(1);
9541
+ const [pageNum, setPageNum] = useState(100);
9542
+ const [curpage, setCurPage] = useState(1);
9549
9543
  const [totalNum, setTotalNum] = useState(0);
9550
9544
  const [shift, setShift] = useState(false);
9551
9545
  const [control, setControl] = useState(false);
9552
9546
  const box = useRef(null);
9553
9547
  const boxMenu = useRef(null);
9554
9548
  const menu = useRef(null);
9549
+ const expandedKeysRef = useRef([]);
9555
9550
  useImperativeHandle(ref, () => ({
9556
9551
  removeLog: () => {
9557
9552
  //清空日志
@@ -9571,8 +9566,8 @@ const Explorer = /*#__PURE__*/forwardRef((props, ref) => {
9571
9566
  await loadData(curInfo?.key || '', undefined, closeload);
9572
9567
  }
9573
9568
  },
9574
- updateCurListNode: key => {
9575
- updateCurlist(key || '');
9569
+ updateCurListNode: async key => {
9570
+ await updateCurlist(key || '');
9576
9571
  },
9577
9572
  createFolder: createFolder,
9578
9573
  setNavSelect: params => {
@@ -9700,7 +9695,7 @@ const Explorer = /*#__PURE__*/forwardRef((props, ref) => {
9700
9695
  useEffect(() => {
9701
9696
  if (isNavtab) {
9702
9697
  if (!curlist?.length) {
9703
- setCurList(data || []);
9698
+ setCurList(data?.[0]?.children || []);
9704
9699
  }
9705
9700
  } else {
9706
9701
  if (!curInfo) {
@@ -9712,7 +9707,7 @@ const Explorer = /*#__PURE__*/forwardRef((props, ref) => {
9712
9707
  }, [data, isNavtab]);
9713
9708
  //切换当前 文件目录时 需要清空的内容
9714
9709
  useEffect(() => {
9715
- if (!curInfo?.key) return;
9710
+ if (!curInfo?.key || curInfo?.key == 'root') return;
9716
9711
  setExpandkey([]);
9717
9712
  onExpand?.([]);
9718
9713
  setCurSelect(null);
@@ -9722,9 +9717,10 @@ const Explorer = /*#__PURE__*/forwardRef((props, ref) => {
9722
9717
  onChangeCurMap?.(dataMap);
9723
9718
  }, [dataMap]);
9724
9719
  useEffect(() => {
9725
- if (props?.expandedKeys) {
9726
- setExpandNavKey(cloneDeep(props?.expandedKeys) || []);
9727
- }
9720
+ const expandedKeys = cloneDeep(props?.expandedKeys) || [];
9721
+ if (_$3.isEqual(expandedKeysRef.current, expandedKeys)) return;
9722
+ expandedKeysRef.current = expandedKeys;
9723
+ setExpandNavKey(expandedKeys);
9728
9724
  }, [props.expandedKeys]);
9729
9725
  /* ************ 加载更新数据 **************** */
9730
9726
  async function loadData(key, param, closeload = true) {
@@ -9739,6 +9735,9 @@ const Explorer = /*#__PURE__*/forwardRef((props, ref) => {
9739
9735
  }
9740
9736
  //清空加载过的结点记录
9741
9737
  setLoadKey([]);
9738
+ // console.log('🚀 ~ data?.current:', key);
9739
+ // console.log('🚀 ~ data?.fileList:', data?.fileList);
9740
+ // console.log('🚀 ~ data?.current:', data?.current);
9742
9741
  setCurList(data?.fileList || []);
9743
9742
  setCurInfo(data?.current || {});
9744
9743
  setTotalNum(data?.totalNum || 0);
@@ -9752,6 +9751,56 @@ const Explorer = /*#__PURE__*/forwardRef((props, ref) => {
9752
9751
  let data = await props.loadData?.(key);
9753
9752
  return data?.fileList || [];
9754
9753
  }
9754
+ async function hydrateExpandedList(list = [], expandedKeys = []) {
9755
+ const expandedKeySet = new Set(expandedKeys);
9756
+ const result = [];
9757
+ for (const item of list) {
9758
+ const next = cloneDeep(item);
9759
+ if (next?.type == 'folder' && next?.key && expandedKeySet.has(next.key)) {
9760
+ const data = await props.loadData?.(next.key);
9761
+ next.children = await hydrateExpandedList(data?.fileList || [], expandedKeys);
9762
+ next.api = true;
9763
+ next.isLeaf = false;
9764
+ }
9765
+ result.push(next);
9766
+ }
9767
+ return result;
9768
+ }
9769
+ async function loadExpandedData(key, expandedKeys = []) {
9770
+ if (!props.loadData) return null;
9771
+ const data = await props.loadData?.(key);
9772
+ if (!data || data.status == 'Err') return null;
9773
+ return {
9774
+ ...data,
9775
+ fileList: await hydrateExpandedList(data?.fileList || [], expandedKeys)
9776
+ };
9777
+ }
9778
+ async function refreshCurrentList(key, expandedKeys = expandkey) {
9779
+ const data = await loadExpandedData(key || curInfo?.key || '', expandedKeys);
9780
+ if (!data) return false;
9781
+ setCurList(data?.fileList || []);
9782
+ setCurInfo(data?.current || {});
9783
+ setTotalNum(data?.totalNum || 0);
9784
+ setLoadKey(expandedKeys);
9785
+ setExpandkey(expandedKeys);
9786
+ return true;
9787
+ }
9788
+ async function refreshNavData(expandedKeys = nav_expandkey) {
9789
+ if (!onChange || !Array.isArray(data)) return;
9790
+ const tree = await hydrateExpandedList(data || [], expandedKeys);
9791
+ onChange(tree);
9792
+ setNavLoadKey(expandedKeys);
9793
+ setExpandNavKey(expandedKeys);
9794
+ }
9795
+ async function refreshAfterMove() {
9796
+ const currentExpandKeys = cloneDeep(expandkey || []);
9797
+ const navExpandKeys = cloneDeep(nav_expandkey || []);
9798
+ setLoading(ApiStatusEnum.LOADING);
9799
+ await Promise.all([refreshCurrentList(curInfo?.key || '', currentExpandKeys), refreshNavData(navExpandKeys)]);
9800
+ setCurSelect(null);
9801
+ setCurSelectFile(null);
9802
+ setLoading(ApiStatusEnum.READY);
9803
+ }
9755
9804
  // 直接通过 刷新数节点 达到刷新效果
9756
9805
  const reloadNode = (key, params) => {
9757
9806
  let isfix = false;
@@ -9813,35 +9862,19 @@ const Explorer = /*#__PURE__*/forwardRef((props, ref) => {
9813
9862
  item.children = arr;
9814
9863
  return item;
9815
9864
  };
9816
- const updateinfo = (item, params) => {
9817
- return {
9818
- ...item,
9819
- ...params
9820
- };
9821
- };
9822
- const delNode = (arr, index) => {
9823
- arr.splice(index, 1);
9824
- return arr;
9825
- };
9826
9865
  const filterData = (data, key) => {
9827
9866
  let arr = data;
9828
9867
  let i = 0;
9829
- let del_index = null;
9830
9868
  while (i < arr.length) {
9831
9869
  let item = arr[i];
9832
9870
  if (key == item.key) {
9833
- if (type == 'add') item = addNode(item, params);
9834
- if (type == 'update') item = updateinfo(item, params);
9835
- if (type == 'del') del_index = i;
9871
+ item = addNode(item, params);
9836
9872
  }
9837
9873
  if (Array.isArray(item.children)) {
9838
9874
  item.children = filterData(item.children, key);
9839
9875
  }
9840
9876
  i++;
9841
9877
  }
9842
- if (type == 'del' && typeof del_index == 'number') {
9843
- arr = delNode(arr, del_index);
9844
- }
9845
9878
  return arr || [];
9846
9879
  };
9847
9880
  let datas = filterData(cloneDeep(data) || [], key);
@@ -9870,29 +9903,7 @@ const Explorer = /*#__PURE__*/forwardRef((props, ref) => {
9870
9903
  onChange?.(arr);
9871
9904
  }
9872
9905
  async function updateCurlist(key) {
9873
- let data = [];
9874
- data = await reduceGetTreeData(curlist, key || curInfo?.key || '', expandkey);
9875
- setCurList(data);
9876
- }
9877
- async function reduceGetTreeData(data, key, expand) {
9878
- let res = await loadNode(key);
9879
- const newData = [];
9880
- // @ts-ignore
9881
- await data.myforeach(async v => {
9882
- let obj = _$3.cloneDeep(v);
9883
- if (expand.includes(obj.key)) {
9884
- obj.children = await reduceGetTreeData(obj.children || [], obj.key, expand);
9885
- }
9886
- if (obj.type == 'file') {
9887
- let match = res.filter(it => it.key === obj.key);
9888
- if (match.length) {
9889
- newData.push(match[0]);
9890
- return null;
9891
- }
9892
- }
9893
- newData.push(obj);
9894
- });
9895
- return newData;
9906
+ await refreshCurrentList(key || curInfo?.key || '', expandkey);
9896
9907
  }
9897
9908
  /* ************ 功能方法 **************** */
9898
9909
  async function uploadFile(param) {
@@ -10224,7 +10235,10 @@ const Explorer = /*#__PURE__*/forwardRef((props, ref) => {
10224
10235
  data.push(dataMap?.[v]);
10225
10236
  }
10226
10237
  });
10227
- _onMoveFile?.(data, info);
10238
+ if (!_onMoveFile) return;
10239
+ const result = await _onMoveFile?.(data, info);
10240
+ if (result === false) return;
10241
+ await refreshAfterMove();
10228
10242
  }
10229
10243
  return jsx(ExampleContext.Provider, {
10230
10244
  value: {