@gingkoo/pandora-explorer 0.0.1-alpha.52 → 0.0.1-alpha.54

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/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @gingkoo/pandora-explorer v0.0.1-alpha.52
2
+ * @gingkoo/pandora-explorer v0.0.1-alpha.54
3
3
  */
4
4
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
5
5
  import cx$1 from 'classnames';
@@ -1538,7 +1538,6 @@ function Dropdown(props) {
1538
1538
  },
1539
1539
  onClick: e => {
1540
1540
  if (trigger == 'click') {
1541
- e.stopPropagation();
1542
1541
  let x = 0;
1543
1542
  let y = 0;
1544
1543
  x = e.nativeEvent.clientX + 5;
@@ -5305,12 +5304,12 @@ function TableItem(props) {
5305
5304
  onRename?.(e.target?.value);
5306
5305
  return;
5307
5306
  }
5308
- if (e.target?.value === param[v?.key]) {
5309
- onRename?.(false);
5310
- return;
5311
- }
5312
5307
  onRename?.(e.target?.value);
5313
5308
  }
5309
+ if (e.key === 'Escape') {
5310
+ onRename?.(false);
5311
+ return;
5312
+ }
5314
5313
  },
5315
5314
  onFocus: e => {
5316
5315
  let i = param[v?.key]?.lastIndexOf('.');
@@ -5385,6 +5384,9 @@ var TreeItem = (props => {
5385
5384
  menudata = getMenu('');
5386
5385
  }
5387
5386
  return jsx("div", {
5387
+ style: {
5388
+ height: '100%'
5389
+ },
5388
5390
  onContextMenu: e => {
5389
5391
  e.preventDefault();
5390
5392
  let x = 0;
@@ -5417,6 +5419,9 @@ var TreeItem = (props => {
5417
5419
  if (e.key === 'Enter' || e.keyCode === 13) {
5418
5420
  onRename?.(title);
5419
5421
  }
5422
+ if (e.key === 'Escape') {
5423
+ onRename?.(false);
5424
+ }
5420
5425
  },
5421
5426
  onFocus: e => {
5422
5427
  let i = title.lastIndexOf('.');
@@ -5435,30 +5440,35 @@ var TreeItem = (props => {
5435
5440
  })
5436
5441
  }) : jsxs("div", {
5437
5442
  className: 'explorer-tree-node',
5438
- onClick: () => {},
5439
5443
  children: [jsx("div", {
5440
5444
  className: 'node-title',
5441
5445
  children: title || ''
5442
5446
  }), jsx("div", {
5443
5447
  className: 'node-menu',
5444
- children: props?.menu !== false && jsx(Dropdown, {
5445
- trigger: 'click',
5446
- placement: 'right',
5447
- dropdownRender: ({
5448
- onClone
5449
- }) => {
5450
- return jsx(Menu, {
5451
- menu: menudata,
5452
- onChange: v => {
5453
- onClone && onClone();
5454
- onMenuClick && onMenuClick(v);
5455
- }
5448
+ children: props?.menu !== false && jsx("div", {
5449
+ className: 'node-menu-icon',
5450
+ onClick: e => {
5451
+ e.stopPropagation();
5452
+ let x = 0;
5453
+ let y = 0;
5454
+ x = e.nativeEvent.clientX + 5;
5455
+ y = e.nativeEvent.clientY + 5;
5456
+ props?.openMenu({
5457
+ x,
5458
+ y,
5459
+ content: jsx(Menu, {
5460
+ menu: menudata,
5461
+ loadMenu: loadMenu,
5462
+ onChange: async v => {
5463
+ onMenuClick && onMenuClick(v);
5464
+ props?.closeMenu?.();
5465
+ }
5466
+ })
5467
+ }, {
5468
+ key: props.id
5456
5469
  });
5457
5470
  },
5458
- children: jsx("div", {
5459
- className: 'node-menu-icon',
5460
- children: jsx(CaretRight, {})
5461
- })
5471
+ children: jsx(CaretRight, {})
5462
5472
  })
5463
5473
  })]
5464
5474
  })
@@ -7684,9 +7694,9 @@ const Explorer = /*#__PURE__*/forwardRef((props, ref) => {
7684
7694
  };
7685
7695
  }, []);
7686
7696
  useLayoutEffect(() => {
7687
- document.addEventListener('keydown', handleKeyDown);
7697
+ window.addEventListener('keydown', handleKeyDown);
7688
7698
  return () => {
7689
- document.removeEventListener('keydown', handleKeyDown);
7699
+ window.removeEventListener('keydown', handleKeyDown);
7690
7700
  };
7691
7701
  }, [curSelect, dataMap]);
7692
7702
  const handleKeyDown = e => {
@@ -7699,17 +7709,17 @@ const Explorer = /*#__PURE__*/forwardRef((props, ref) => {
7699
7709
  if (e.altKey && e.key === '1') {
7700
7710
  setMenutype('tile');
7701
7711
  }
7702
- if (e.altKey && e.key === 'c') {
7712
+ if ((e.ctrlKey || e.metaKey) && e.key === 'c') {
7703
7713
  if (curSelect && dataMap?.[curSelect]) {
7704
7714
  onCopy?.(dataMap?.[curSelect]);
7705
7715
  }
7706
7716
  }
7707
- if (e.altKey && e.key === 'x') {
7717
+ if ((e.ctrlKey || e.metaKey) && e.key === 'x') {
7708
7718
  if (curSelect && dataMap?.[curSelect]) {
7709
7719
  onCopy?.(dataMap?.[curSelect]);
7710
7720
  }
7711
7721
  }
7712
- if (e.altKey && e.key === 'v') {
7722
+ if ((e.ctrlKey || e.metaKey) && e.key === 'v') {
7713
7723
  if (curSelect && dataMap?.[curSelect]) {
7714
7724
  onCopy?.(dataMap?.[curSelect]);
7715
7725
  }
@@ -7808,7 +7818,6 @@ const Explorer = /*#__PURE__*/forwardRef((props, ref) => {
7808
7818
  return data?.fileList || [];
7809
7819
  }
7810
7820
  const reloadNode = key => {
7811
- setNavLoadKey(nav_loadKey.filter(v => v !== key));
7812
7821
  const addData = (data, key) => {
7813
7822
  let arr = data;
7814
7823
  let i = 0;
@@ -7828,6 +7837,9 @@ const Explorer = /*#__PURE__*/forwardRef((props, ref) => {
7828
7837
  };
7829
7838
  let arr = addData(data || [], key);
7830
7839
  onChange?.(arr);
7840
+ setTimeout(() => {
7841
+ setNavLoadKey(nav_loadKey.filter(v => v !== key));
7842
+ }, 100);
7831
7843
  };
7832
7844
  function updata(id, param) {
7833
7845
  const fixData = (data, id, param) => {
@@ -7855,6 +7867,27 @@ const Explorer = /*#__PURE__*/forwardRef((props, ref) => {
7855
7867
  //创建和重名
7856
7868
  async function onRename(key, value, info, type) {
7857
7869
  if (info.create_file) {
7870
+ const delata = data => {
7871
+ let arr = data;
7872
+ let filter = [];
7873
+ let i = 0;
7874
+ while (i < arr.length) {
7875
+ let item = arr[i];
7876
+ if (!item?.create_file) {
7877
+ filter.push(item);
7878
+ }
7879
+ if (Array.isArray(item.children)) {
7880
+ item.children = delata(item.children);
7881
+ }
7882
+ i++;
7883
+ }
7884
+ return filter || [];
7885
+ };
7886
+ if (value === false) {
7887
+ let arr = delata(curlist);
7888
+ setCurList(arr);
7889
+ return;
7890
+ }
7858
7891
  if (curInfo) {
7859
7892
  await createFile?.(value, curInfo);
7860
7893
  curInfo?.key && loadData(curInfo?.key);
@@ -7963,9 +7996,7 @@ const Explorer = /*#__PURE__*/forwardRef((props, ref) => {
7963
7996
  async function onMenuClick(key, param, type) {
7964
7997
  if (key == 'remove') {
7965
7998
  await onDelect?.(param);
7966
- if (param.key === curInfo?.key) {
7967
- data && loadData(data[0].key);
7968
- }
7999
+ data && loadData(data[0].key);
7969
8000
  if (type == 'menu') {
7970
8001
  reloadNode(param.parentPath);
7971
8002
  }
@@ -7981,6 +8012,7 @@ const Explorer = /*#__PURE__*/forwardRef((props, ref) => {
7981
8012
  }
7982
8013
  if (key == 'paste') {
7983
8014
  onPaste?.(param);
8015
+ curInfo?.key && loadData(curInfo.key);
7984
8016
  reloadNode(param.key);
7985
8017
  return;
7986
8018
  }