@gingkoo/pandora-explorer 0.0.1-alpha.39 → 0.0.1-alpha.40

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.39
2
+ * @gingkoo/pandora-explorer v0.0.1-alpha.40
3
3
  */
4
4
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
5
5
  import cx$1 from 'classnames';
@@ -5384,7 +5384,11 @@ var TreeItem = (props => {
5384
5384
  onMenuClick,
5385
5385
  loadMenu
5386
5386
  } = props;
5387
- const [title, setTitle] = useState(props.title);
5387
+ const [title, setTitle] = useState('');
5388
+ console.log(props, 12);
5389
+ useEffect(() => {
5390
+ setTitle(props.title);
5391
+ }, [props.title]);
5388
5392
  let menudata = [];
5389
5393
  if (getMenu(props.id)) {
5390
5394
  menudata = getMenu(props.id);
@@ -5814,6 +5818,7 @@ var Tree = (props => {
5814
5818
  return;
5815
5819
  }
5816
5820
  onRename && onRename(v.key, value, v);
5821
+ setRename(null);
5817
5822
  },
5818
5823
  onMenuClick: menu => {
5819
5824
  if (menu == 'rename') {
@@ -5977,7 +5982,6 @@ const ExplorerMenu = props => {
5977
5982
  } = props;
5978
5983
  const store = useContext(ExampleContext);
5979
5984
  const [eventKey, setEventKey] = useState([]);
5980
- const [loadKey, setLoadKey] = useState([]);
5981
5985
  const [select, setSelect] = useState('');
5982
5986
  useEffect(() => {
5983
5987
  setEventKey(expandedKeys);
@@ -5996,7 +6000,7 @@ const ExplorerMenu = props => {
5996
6000
  isload: true,
5997
6001
  treeData: data,
5998
6002
  height: height,
5999
- loadedKeys: loadKey,
6003
+ loadedKeys: store.nav_loadKey,
6000
6004
  expandedKeys: eventKey,
6001
6005
  selectedKeys: [select],
6002
6006
  icon: (v, className) => {
@@ -6027,9 +6031,9 @@ const ExplorerMenu = props => {
6027
6031
  return true;
6028
6032
  },
6029
6033
  onLoad: key => {
6030
- setLoadKey(key);
6034
+ store.setNavLoadKey(key);
6031
6035
  },
6032
- setLoadKey: setLoadKey,
6036
+ setLoadKey: store.setNavLoadKey,
6033
6037
  onExpand: v => {
6034
6038
  setEventKey(v);
6035
6039
  }
@@ -7608,6 +7612,7 @@ const Explorer = /*#__PURE__*/forwardRef((props, ref) => {
7608
7612
  checkType,
7609
7613
  checkMode = 'file',
7610
7614
  createFile,
7615
+ onChange,
7611
7616
  loadData: _loadData,
7612
7617
  onRename: _onRename
7613
7618
  } = props;
@@ -7623,6 +7628,7 @@ const Explorer = /*#__PURE__*/forwardRef((props, ref) => {
7623
7628
  const [logindex, setLogIndex] = useState(0); //前进
7624
7629
  const [log, setLog] = useState([]); //后退
7625
7630
  const [loadkey, setLoadKey] = useState([]);
7631
+ const [nav_loadKey, setNavLoadKey] = useState([]);
7626
7632
  const [menutype, setMenutype] = useState('tile');
7627
7633
  const [infoshow, setInfoShow] = useState(false);
7628
7634
  const [loading, setLoading] = useState(ApiStatusEnum.READY);
@@ -7759,6 +7765,7 @@ const Explorer = /*#__PURE__*/forwardRef((props, ref) => {
7759
7765
  await _onRename?.(key, value, info);
7760
7766
  }
7761
7767
  curInfo?.key && loadData(curInfo?.key);
7768
+ updata(key, 'title', value);
7762
7769
  }
7763
7770
  async function uploadFile() {
7764
7771
  if (!curInfo) return;
@@ -7835,7 +7842,48 @@ const Explorer = /*#__PURE__*/forwardRef((props, ref) => {
7835
7842
  create_file: true
7836
7843
  });
7837
7844
  setCurList(list);
7845
+ curInfo?.key && reloadNode(curInfo?.key);
7846
+ }
7847
+ function updata(id, key, param) {
7848
+ const fixData = (data, id, key, param) => {
7849
+ let arr = data;
7850
+ let i = 0;
7851
+ while (i < arr.length) {
7852
+ let item = arr[i];
7853
+ if (item.key == id) {
7854
+ item[key] = param;
7855
+ }
7856
+ if (Array.isArray(item.children)) {
7857
+ item.children = fixData(item.children, id, key, param);
7858
+ }
7859
+ i++;
7860
+ }
7861
+ return arr || [];
7862
+ };
7863
+ let arr = fixData(data || [], id, key, param);
7864
+ onChange?.(arr);
7838
7865
  }
7866
+ const reloadNode = key => {
7867
+ setLoadKey(nav_loadKey.filter(v => v !== key));
7868
+ const addData = (data, key) => {
7869
+ let arr = data;
7870
+ let i = 0;
7871
+ while (i < arr.length) {
7872
+ let item = arr[i];
7873
+ if (item.key == key) {
7874
+ item.isLeaf = false;
7875
+ item.children = [];
7876
+ }
7877
+ if (Array.isArray(item.children)) {
7878
+ item.children = addData(item.children, key);
7879
+ }
7880
+ i++;
7881
+ }
7882
+ return arr || [];
7883
+ };
7884
+ let arr = addData(data || [], key);
7885
+ onChange?.(arr);
7886
+ };
7839
7887
  return jsx(ExampleContext.Provider, {
7840
7888
  value: {
7841
7889
  //data
@@ -7857,11 +7905,13 @@ const Explorer = /*#__PURE__*/forwardRef((props, ref) => {
7857
7905
  curSelect,
7858
7906
  curSelectFile,
7859
7907
  loadkey,
7908
+ nav_loadKey,
7860
7909
  //icon
7861
7910
  getIcons: Icons,
7862
7911
  loadMenu: props.loadMenu,
7863
7912
  uploadFile,
7864
7913
  createFolder,
7914
+ reloadNode,
7865
7915
  //set
7866
7916
  setLog,
7867
7917
  setLogIndex,
@@ -7875,7 +7925,8 @@ const Explorer = /*#__PURE__*/forwardRef((props, ref) => {
7875
7925
  setReName,
7876
7926
  setCurSelect,
7877
7927
  setCurSelectFile,
7878
- setLoadKey
7928
+ setLoadKey,
7929
+ setNavLoadKey
7879
7930
  },
7880
7931
  children: jsx("div", {
7881
7932
  className: 'explorer-container',