@gingkoo/pandora-explorer 0.0.1-alpha.51 → 0.0.1-alpha.53

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,13 +1,13 @@
1
1
  /**
2
- * @gingkoo/pandora-explorer v0.0.1-alpha.51
2
+ * @gingkoo/pandora-explorer v0.0.1-alpha.53
3
3
  */
4
4
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
5
5
  import cx$1 from 'classnames';
6
6
  import * as React from 'react';
7
7
  import React__default, { createContext, useRef, useState, useImperativeHandle, useEffect, useMemo, useLayoutEffect, useContext, createElement, forwardRef } from 'react';
8
+ import { createRoot } from 'react-dom/client';
8
9
  import createEmotion from '@emotion/css/create-instance';
9
10
  import { cx as cx$2 } from '@emotion/css';
10
- import { createRoot } from 'react-dom/client';
11
11
  import { cloneDeep, truncate } from 'lodash';
12
12
  import KeyCode from 'rc-util/lib/KeyCode';
13
13
  import pickAttrs from 'rc-util/lib/pickAttrs';
@@ -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;
@@ -1585,30 +1584,9 @@ const ExplorerHead = props => {
1585
1584
  const pathInputRef = useRef(null);
1586
1585
  const [path, setPath] = useState('');
1587
1586
  const [pathFocus, setFocus] = useState(false);
1588
- useLayoutEffect(() => {
1589
- document.addEventListener('keydown', handleKeyDown);
1590
- return () => {
1591
- document.removeEventListener('keydown', handleKeyDown);
1592
- };
1593
- }, [path, pathFocus]);
1594
1587
  useEffect(() => {
1595
1588
  setPath(store?.curInfo?.pathDisplay || '');
1596
1589
  }, [store?.curInfo?.pathDisplay]);
1597
- const handleKeyDown = e => {
1598
- if (e.altKey && e.key === '3') {
1599
- store?.setMenutype('column');
1600
- }
1601
- if (e.altKey && e.key === '2') {
1602
- store?.setMenutype('table');
1603
- }
1604
- if (e.altKey && e.key === '1') {
1605
- store?.setMenutype('tile');
1606
- }
1607
- if (pathFocus && (e.key === 'Enter' || e.keyCode === 13)) {
1608
- loadData?.(path);
1609
- setFocus(false);
1610
- }
1611
- };
1612
1590
  const Breadcrumb = useMemo(() => {
1613
1591
  let arr = [];
1614
1592
  let path = store?.curInfo?.pathDisplay || '';
@@ -1731,6 +1709,12 @@ const ExplorerHead = props => {
1731
1709
  },
1732
1710
  className: 'path',
1733
1711
  spellCheck: 'false',
1712
+ onKeyDown: e => {
1713
+ if (pathFocus && (e.key === 'Enter' || e.keyCode === 13)) {
1714
+ loadData?.(path);
1715
+ setFocus(false);
1716
+ }
1717
+ },
1734
1718
  onBlur: v => {
1735
1719
  loadData?.(v.target.value);
1736
1720
  setFocus(false);
@@ -5229,17 +5213,17 @@ function TableItem(props) {
5229
5213
  loadMenu,
5230
5214
  ...param
5231
5215
  } = props;
5232
- return jsx(Dropdown, {
5233
- trigger: 'contextMenu',
5234
- style: {
5235
- height: '100%'
5236
- },
5216
+ return jsx("div", {
5217
+ className: cx$1('explorer-tree-row'),
5218
+ "data-id": id,
5219
+ "data-type": props.type,
5237
5220
  onContextMenu: e => {
5238
5221
  e.stopPropagation();
5239
- },
5240
- dropdownRender: ({
5241
- onClone
5242
- }) => {
5222
+ e.preventDefault();
5223
+ let x = 0;
5224
+ let y = 0;
5225
+ x = e.nativeEvent.clientX + 5;
5226
+ y = e.nativeEvent.clientY + 5;
5243
5227
  if (!props.isOpenMenu) return;
5244
5228
  let menudata = [];
5245
5229
  if (getMenu(props.id)) {
@@ -5249,133 +5233,134 @@ function TableItem(props) {
5249
5233
  } else {
5250
5234
  menudata = getMenu('');
5251
5235
  }
5252
- return jsx(Menu, {
5253
- menu: menudata,
5254
- loadMenu: loadMenu,
5255
- onChange: async v => {
5256
- onClone && onClone();
5257
- onMenuClick && onMenuClick(v);
5258
- }
5236
+ props?.openMenu({
5237
+ x,
5238
+ y,
5239
+ content: jsx(Menu, {
5240
+ menu: menudata,
5241
+ loadMenu: loadMenu,
5242
+ onChange: async v => {
5243
+ onMenuClick && onMenuClick(v);
5244
+ props?.closeMenu?.();
5245
+ }
5246
+ })
5247
+ }, {
5248
+ key: props.id
5259
5249
  });
5260
5250
  },
5261
- children: jsx("div", {
5262
- className: cx$1('explorer-tree-row'),
5263
- "data-id": id,
5264
- "data-type": props.type,
5265
- children: columns.map((v, i) => {
5266
- let x = width[i] - (i ? 0 : 58 + 8) + (i ? 10 : 0);
5267
- if (i == 0 && typeof param.level === 'number') {
5268
- x = x - param.level * 16;
5269
- }
5270
- if (typeof v?.render === 'function') {
5271
- return jsxs("div", {
5272
- className: cx$1('row-item'),
5273
- style: width[i] ? {
5274
- flex: `0 0 ${x}px`,
5275
- width: x + 'px'
5276
- } : {},
5277
- children: [jsxs("div", {
5278
- className: 'row-item-content',
5279
- children: [" ", v.render?.(param, v.key)]
5280
- }), !i && jsx("div", {
5281
- children: jsx("div", {
5282
- className: cx$1('row-item-check', {
5283
- active: active
5284
- }),
5285
- onMouseDown: e => {
5286
- e.stopPropagation();
5287
- },
5288
- onClick: e => {
5289
- e.stopPropagation();
5290
- e.preventDefault();
5291
- onCheck?.();
5292
- },
5293
- children: jsx("span", {
5294
- className: 'btn-check',
5295
- children: jsx(CircleCheckSvg, {})
5296
- })
5297
- })
5298
- })]
5299
- }, i);
5300
- }
5301
- if (rename && v.key == 'title') {
5302
- return jsx("div", {
5303
- className: cx$1('row-item'),
5304
- style: width[i] ? {
5305
- flex: `0 0 ${x}px`,
5306
- width: x + 'px'
5307
- } : {},
5308
- children: jsx("div", {
5309
- className: 'row-item-content',
5310
- children: jsx("input", {
5311
- className: 'node-input',
5312
- autoFocus: true,
5313
- defaultValue: param[v?.key],
5314
- placeholder: '\u8BF7\u8F93\u5165',
5315
- onKeyDown: e => {
5316
- if (e.key === 'Enter' || e.keyCode === 13) {
5317
- if (props.create_file) {
5318
- onRename?.(e.target?.value);
5319
- return;
5320
- }
5321
- if (e.target?.value === param[v?.key]) {
5322
- onRename?.(false);
5323
- return;
5324
- }
5325
- onRename?.(e.target?.value);
5326
- }
5327
- },
5328
- onFocus: e => {
5329
- let i = param[v?.key]?.lastIndexOf('.');
5330
- if (props?.suffix == 'folder') {
5331
- e.target.setSelectionRange(0, param[v?.key]?.length);
5332
- } else if (i !== -1) {
5333
- e.target.setSelectionRange(0, i);
5334
- }
5335
- },
5336
- onBlur: e => {
5337
- if (props.create_file) {
5338
- onRename?.(e.target.value);
5339
- return;
5340
- }
5341
- if (e.target.value === param[v?.key]) {
5342
- onRename?.(false);
5343
- return;
5344
- }
5345
- onRename?.(e.target.value);
5346
- }
5347
- })
5348
- })
5349
- }, i);
5350
- }
5251
+ children: columns.map((v, i) => {
5252
+ let x = width[i] - (i ? 0 : 58 + 8) + (i ? 10 : 0);
5253
+ if (i == 0 && typeof param.level === 'number') {
5254
+ x = x - param.level * 16;
5255
+ }
5256
+ if (typeof v?.render === 'function') {
5351
5257
  return jsxs("div", {
5352
5258
  className: cx$1('row-item'),
5353
5259
  style: width[i] ? {
5354
5260
  flex: `0 0 ${x}px`,
5355
5261
  width: x + 'px'
5356
5262
  } : {},
5357
- children: [jsx("div", {
5263
+ children: [jsxs("div", {
5358
5264
  className: 'row-item-content',
5359
- children: param[v?.key] || ''
5265
+ children: [" ", v.render?.(param, v.key)]
5360
5266
  }), !i && jsx("div", {
5361
- className: cx$1('row-item-check', {
5362
- active: active
5363
- }),
5364
- onMouseDown: e => {
5365
- e.stopPropagation();
5366
- },
5367
- onClick: e => {
5368
- e.stopPropagation();
5369
- e.preventDefault();
5370
- onCheck?.();
5371
- },
5372
- children: jsx("span", {
5373
- className: 'btn-check',
5374
- children: jsx(CircleCheckSvg, {})
5267
+ children: jsx("div", {
5268
+ className: cx$1('row-item-check', {
5269
+ active: active
5270
+ }),
5271
+ onMouseDown: e => {
5272
+ e.stopPropagation();
5273
+ },
5274
+ onClick: e => {
5275
+ e.stopPropagation();
5276
+ e.preventDefault();
5277
+ onCheck?.();
5278
+ },
5279
+ children: jsx("span", {
5280
+ className: 'btn-check',
5281
+ children: jsx(CircleCheckSvg, {})
5282
+ })
5375
5283
  })
5376
5284
  })]
5377
5285
  }, i);
5378
- })
5286
+ }
5287
+ if (rename && v.key == 'title') {
5288
+ return jsx("div", {
5289
+ className: cx$1('row-item'),
5290
+ style: width[i] ? {
5291
+ flex: `0 0 ${x}px`,
5292
+ width: x + 'px'
5293
+ } : {},
5294
+ children: jsx("div", {
5295
+ className: 'row-item-content',
5296
+ children: jsx("input", {
5297
+ className: 'node-input',
5298
+ autoFocus: true,
5299
+ defaultValue: param[v?.key],
5300
+ placeholder: '\u8BF7\u8F93\u5165',
5301
+ onKeyDown: e => {
5302
+ if (e.key === 'Enter' || e.keyCode === 13) {
5303
+ if (props.create_file) {
5304
+ onRename?.(e.target?.value);
5305
+ return;
5306
+ }
5307
+ onRename?.(e.target?.value);
5308
+ }
5309
+ if (e.key === 'Escape') {
5310
+ onRename?.(false);
5311
+ return;
5312
+ }
5313
+ },
5314
+ onFocus: e => {
5315
+ let i = param[v?.key]?.lastIndexOf('.');
5316
+ if (props?.suffix == 'folder') {
5317
+ e.target.setSelectionRange(0, param[v?.key]?.length);
5318
+ } else if (i !== -1) {
5319
+ e.target.setSelectionRange(0, i);
5320
+ }
5321
+ },
5322
+ onBlur: e => {
5323
+ if (props.create_file) {
5324
+ onRename?.(e.target.value);
5325
+ return;
5326
+ }
5327
+ if (e.target.value === param[v?.key]) {
5328
+ onRename?.(false);
5329
+ return;
5330
+ }
5331
+ onRename?.(e.target.value);
5332
+ }
5333
+ })
5334
+ })
5335
+ }, i);
5336
+ }
5337
+ return jsxs("div", {
5338
+ className: cx$1('row-item'),
5339
+ style: width[i] ? {
5340
+ flex: `0 0 ${x}px`,
5341
+ width: x + 'px'
5342
+ } : {},
5343
+ children: [jsx("div", {
5344
+ className: 'row-item-content',
5345
+ children: param[v?.key] || ''
5346
+ }), !i && jsx("div", {
5347
+ className: cx$1('row-item-check', {
5348
+ active: active
5349
+ }),
5350
+ onMouseDown: e => {
5351
+ e.stopPropagation();
5352
+ },
5353
+ onClick: e => {
5354
+ e.stopPropagation();
5355
+ e.preventDefault();
5356
+ onCheck?.();
5357
+ },
5358
+ children: jsx("span", {
5359
+ className: 'btn-check',
5360
+ children: jsx(CircleCheckSvg, {})
5361
+ })
5362
+ })]
5363
+ }, i);
5379
5364
  })
5380
5365
  });
5381
5366
  }
@@ -5398,22 +5383,29 @@ var TreeItem = (props => {
5398
5383
  } else {
5399
5384
  menudata = getMenu('');
5400
5385
  }
5401
- return jsx(Dropdown, {
5402
- trigger: 'contextMenu',
5386
+ return jsx("div", {
5403
5387
  style: {
5404
5388
  height: '100%'
5405
5389
  },
5406
- dropdownRender: ({
5407
- onClone
5408
- }) => {
5409
- if (props?.menu === false) return;
5410
- return jsx(Menu, {
5411
- menu: menudata,
5412
- loadMenu: loadMenu,
5413
- onChange: async v => {
5414
- onClone && onClone();
5415
- onMenuClick && onMenuClick(v);
5416
- }
5390
+ onContextMenu: e => {
5391
+ e.preventDefault();
5392
+ let x = 0;
5393
+ let y = 0;
5394
+ x = e.nativeEvent.clientX + 5;
5395
+ y = e.nativeEvent.clientY + 5;
5396
+ props?.openMenu({
5397
+ x,
5398
+ y,
5399
+ content: jsx(Menu, {
5400
+ menu: menudata,
5401
+ loadMenu: loadMenu,
5402
+ onChange: async v => {
5403
+ onMenuClick && onMenuClick(v);
5404
+ props?.closeMenu?.();
5405
+ }
5406
+ })
5407
+ }, {
5408
+ key: props.id
5417
5409
  });
5418
5410
  },
5419
5411
  children: props.rename ? jsx("div", {
@@ -5427,6 +5419,9 @@ var TreeItem = (props => {
5427
5419
  if (e.key === 'Enter' || e.keyCode === 13) {
5428
5420
  onRename?.(title);
5429
5421
  }
5422
+ if (e.key === 'Escape') {
5423
+ onRename?.(false);
5424
+ }
5430
5425
  },
5431
5426
  onFocus: e => {
5432
5427
  let i = title.lastIndexOf('.');
@@ -5445,30 +5440,35 @@ var TreeItem = (props => {
5445
5440
  })
5446
5441
  }) : jsxs("div", {
5447
5442
  className: 'explorer-tree-node',
5448
- onClick: () => {},
5449
5443
  children: [jsx("div", {
5450
5444
  className: 'node-title',
5451
5445
  children: title || ''
5452
5446
  }), jsx("div", {
5453
5447
  className: 'node-menu',
5454
- children: props?.menu !== false && jsx(Dropdown, {
5455
- trigger: 'click',
5456
- placement: 'right',
5457
- dropdownRender: ({
5458
- onClone
5459
- }) => {
5460
- return jsx(Menu, {
5461
- menu: menudata,
5462
- onChange: v => {
5463
- onClone && onClone();
5464
- onMenuClick && onMenuClick(v);
5465
- }
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
5466
5469
  });
5467
5470
  },
5468
- children: jsx("div", {
5469
- className: 'node-menu-icon',
5470
- children: jsx(CaretRight, {})
5471
- })
5471
+ children: jsx(CaretRight, {})
5472
5472
  })
5473
5473
  })]
5474
5474
  })
@@ -5883,6 +5883,7 @@ var Tree = (props => {
5883
5883
  },
5884
5884
  onClick: e => {
5885
5885
  e.stopPropagation();
5886
+ props?.closeMenu();
5886
5887
  },
5887
5888
  onLoad: v => {
5888
5889
  if (v.length == loadedKeys?.length) return;
@@ -5999,6 +6000,10 @@ const ExplorerMenu = props => {
5999
6000
  function onMenuClick(key, data) {
6000
6001
  _onMenuClick(key, data, 'menu');
6001
6002
  }
6003
+ const openMenu = (props, param) => {
6004
+ setSelect(param.key);
6005
+ store.openMenu(props);
6006
+ };
6002
6007
  return jsx("div", {
6003
6008
  className: 'frame-left',
6004
6009
  onContextMenu: e => {
@@ -6020,6 +6025,8 @@ const ExplorerMenu = props => {
6020
6025
  loadMenu: loadMenu,
6021
6026
  onChange: onChange,
6022
6027
  onRename: onRename,
6028
+ openMenu: openMenu,
6029
+ closeMenu: store.closeMenu,
6023
6030
  onSelect: v => {
6024
6031
  if (v.key === store.curInfo?.key) return;
6025
6032
  store.setPathDisplay(v?.pathDisplay);
@@ -6176,7 +6183,7 @@ function Tile(props) {
6176
6183
  menudata = getMenu('');
6177
6184
  }
6178
6185
  let isname = rekey == v.key || v?.create_file;
6179
- return jsx("div", {
6186
+ return jsxs("div", {
6180
6187
  "data-id": v.key,
6181
6188
  "data-type": v.type,
6182
6189
  className: cx$1('file', {
@@ -6199,79 +6206,68 @@ function Tile(props) {
6199
6206
  onDoubleClick: () => {
6200
6207
  onDblclick?.(v.key, v);
6201
6208
  },
6202
- children: jsxs(Dropdown, {
6203
- trigger: 'contextMenu',
6204
- onContextMenu: e => {
6205
- e.stopPropagation();
6206
- },
6207
- dropdownRender: ({
6208
- onClone
6209
- }) => {
6210
- return jsx(Menu, {
6209
+ onContextMenu: e => {
6210
+ e.preventDefault();
6211
+ e.stopPropagation();
6212
+ let x = 0;
6213
+ let y = 0;
6214
+ x = e.nativeEvent.clientX + 5;
6215
+ y = e.nativeEvent.clientY + 5;
6216
+ props.openMenu({
6217
+ x: x,
6218
+ y: y,
6219
+ content: jsx(Menu, {
6211
6220
  menu: menudata,
6212
6221
  loadMenu: loadMenu,
6213
6222
  onChange: key => {
6214
6223
  if (key == 'rename') {
6215
6224
  setRekey(v.key);
6216
- onClone();
6217
6225
  return;
6218
6226
  }
6219
6227
  onMenuClick?.(key, v);
6220
- onClone();
6228
+ props.closeMenu();
6221
6229
  }
6222
- });
6230
+ })
6231
+ }, v);
6232
+ },
6233
+ children: [jsx("i", {
6234
+ className: cx$1('path-ico'),
6235
+ style: {
6236
+ width: w + 'px',
6237
+ height: w - w / 10 + 'px'
6223
6238
  },
6224
- children: [jsx("i", {
6225
- className: cx$1('path-ico'),
6239
+ children: v.type === 'folder' || !v?.pic ? icons(v, 'x-item-icon', {
6240
+ width: w + 'px',
6241
+ height: w + 'px',
6242
+ lineHeight: w + 'px'
6243
+ }) : jsx("img", {
6244
+ className: 'picture-show',
6245
+ draggable: 'false',
6246
+ src: v.pic,
6226
6247
  style: {
6227
6248
  width: w + 'px',
6228
- height: w - w / 10 + 'px'
6229
- },
6230
- children: v.type === 'folder' || !v?.pic ? icons(v, 'x-item-icon', {
6231
- width: w + 'px',
6232
- height: w + 'px',
6233
- lineHeight: w + 'px'
6234
- }) : jsx("img", {
6235
- className: 'picture-show',
6236
- draggable: 'false',
6237
- src: v.pic,
6238
- style: {
6239
- width: w + 'px',
6240
- height: w + 'px'
6249
+ height: w + 'px'
6250
+ }
6251
+ })
6252
+ }), jsx("div", {
6253
+ className: 'title-type-name',
6254
+ style: {
6255
+ width: w + 'px'
6256
+ },
6257
+ children: isname ? jsx("textarea", {
6258
+ autoFocus: true,
6259
+ rows: 3,
6260
+ defaultValue: v.title,
6261
+ onFocus: e => {
6262
+ let i = v.title.lastIndexOf('.');
6263
+ if (props?.suffix == 'folder') {
6264
+ e.target.setSelectionRange(0, v.title.length);
6265
+ } else if (i !== -1) {
6266
+ e.target.setSelectionRange(0, i);
6241
6267
  }
6242
- })
6243
- }), jsx("div", {
6244
- className: 'title-type-name',
6245
- style: {
6246
- width: w + 'px'
6247
6268
  },
6248
- children: isname ? jsx("textarea", {
6249
- autoFocus: true,
6250
- rows: 3,
6251
- defaultValue: v.title,
6252
- onFocus: e => {
6253
- let i = v.title.lastIndexOf('.');
6254
- if (props?.suffix == 'folder') {
6255
- e.target.setSelectionRange(0, v.title.length);
6256
- } else if (i !== -1) {
6257
- e.target.setSelectionRange(0, i);
6258
- }
6259
- },
6260
- onKeyDown: e => {
6261
- if (e.key === 'Enter' || e.keyCode === 13) {
6262
- if (props.create_file) {
6263
- onRename?.(v.key, e.target?.value, v);
6264
- return;
6265
- }
6266
- if (e.target?.value === v.title) {
6267
- setRekey(null);
6268
- return;
6269
- }
6270
- onRename?.(v.key, e.target.value, v);
6271
- setRekey(null);
6272
- }
6273
- },
6274
- onBlur: e => {
6269
+ onKeyDown: e => {
6270
+ if (e.key === 'Enter' || e.keyCode === 13) {
6275
6271
  if (props.create_file) {
6276
6272
  onRename?.(v.key, e.target?.value, v);
6277
6273
  return;
@@ -6282,16 +6278,28 @@ function Tile(props) {
6282
6278
  }
6283
6279
  onRename?.(v.key, e.target.value, v);
6284
6280
  setRekey(null);
6285
- },
6286
- onMouseDown: e => {
6287
- e.stopPropagation();
6288
6281
  }
6289
- }) : jsx("span", {
6290
- className: 'title',
6291
- children: v.title
6292
- })
6293
- })]
6294
- })
6282
+ },
6283
+ onBlur: e => {
6284
+ if (props.create_file) {
6285
+ onRename?.(v.key, e.target?.value, v);
6286
+ return;
6287
+ }
6288
+ if (e.target?.value === v.title) {
6289
+ setRekey(null);
6290
+ return;
6291
+ }
6292
+ onRename?.(v.key, e.target.value, v);
6293
+ setRekey(null);
6294
+ },
6295
+ onMouseDown: e => {
6296
+ e.stopPropagation();
6297
+ }
6298
+ }) : jsx("span", {
6299
+ className: 'title',
6300
+ children: v.title
6301
+ })
6302
+ })]
6295
6303
  }, v.key);
6296
6304
  })
6297
6305
  }, index);
@@ -6431,10 +6439,11 @@ const SelectBox = props => {
6431
6439
  clientX: x,
6432
6440
  clientY: y
6433
6441
  } = e;
6442
+ //动画
6434
6443
  if (!time && cur?.current?.length && isDrag) {
6435
6444
  cur.current?.map((v, i) => {
6436
6445
  v.style.cssText = `
6437
- position: absolute;
6446
+ position: absolute;
6438
6447
  transition: 0.3s;
6439
6448
  top:${y + i * 3}px;
6440
6449
  left:${x + i * 3}px;
@@ -6445,23 +6454,22 @@ const SelectBox = props => {
6445
6454
  cur.current = [];
6446
6455
  }, 200);
6447
6456
  }
6457
+ //移动
6448
6458
  if (isDrag && selects.length) {
6449
6459
  if (target.current) {
6450
6460
  target.current.style.cssText = `
6451
- position: absolute;
6452
- top:${y}px;
6453
- left:${x}px;
6454
- `;
6461
+ position: absolute;
6462
+ top:${y}px;
6463
+ left:${x}px;
6464
+ `;
6455
6465
  }
6456
6466
  } else {
6467
+ //选框
6457
6468
  createBox(e);
6458
6469
  }
6459
6470
  }
6460
6471
  //鼠标松开
6461
6472
  function handleBodyMouseup() {
6462
- if (isDclick.current) {
6463
- clearTimeout(isDclick.current);
6464
- }
6465
6473
  if (target.current) {
6466
6474
  empty();
6467
6475
  } else {
@@ -6486,7 +6494,7 @@ const SelectBox = props => {
6486
6494
  }, 300);
6487
6495
  }
6488
6496
  }
6489
- //拖动时
6497
+ //拖动文件
6490
6498
  const handleDragOver = e => {
6491
6499
  e.preventDefault();
6492
6500
  const {
@@ -6848,109 +6856,104 @@ const SelectBox = props => {
6848
6856
  })
6849
6857
  });
6850
6858
  }
6851
- return jsx(Dropdown, {
6852
- style: {
6853
- height: '100%'
6859
+ return jsxs("div", {
6860
+ ref: ref,
6861
+ className: cx$1(`file-select-box ${className}`),
6862
+ onDragLeave: e => {
6863
+ e.preventDefault();
6854
6864
  },
6855
- trigger: 'contextMenu',
6856
- dropdownRender: ({
6857
- onClone
6858
- }) => {
6859
- return jsx(Menu, {
6860
- menu: menudata,
6861
- loadMenu: v => {
6862
- let menu = loadMenu(v);
6863
- if (menu?.key == 'rename') return undefined;
6864
- if (menu?.key == 'copy') return undefined;
6865
- return menu;
6866
- },
6867
- onChange: key => {
6868
- if (key == 'update') {
6869
- if (store?.curInfo) {
6870
- loadData(store?.curInfo?.key);
6871
- }
6872
- onClone();
6873
- return;
6874
- }
6875
- if (key == 'file-upload') {
6876
- store.uploadFile();
6877
- onClone();
6878
- return;
6879
- }
6880
- if (key == 'create') {
6881
- store.createFolder();
6882
- onClone();
6883
- return;
6865
+ onDoubleClick: () => {
6866
+ clearTimeout(isDclick.current);
6867
+ },
6868
+ onMouseDown: e => {
6869
+ let type = isSelectTarget(e, checkType);
6870
+ if (checks.includes(type?.[0])) {
6871
+ //右键不能今天拖动
6872
+ if (e.button === 2) return;
6873
+ if (!isDrag && checkMode == 'check') {
6874
+ isDclick.current = setTimeout(() => {
6875
+ let arr = checks.filter(v => v !== type?.[0]);
6876
+ setSelect(arr);
6877
+ onChange(arr);
6878
+ }, 200);
6879
+ }
6880
+ time = null;
6881
+ isDrag && createVDom(e);
6882
+ return;
6883
+ }
6884
+ //在区域未选中
6885
+ if (Array.isArray(type)) {
6886
+ if (checkMode == 'check') {
6887
+ if (!checks.includes(type?.[0])) {
6888
+ let arr = [...selects, ...type];
6889
+ setSelect(arr);
6890
+ onChange(arr);
6884
6891
  }
6885
- onMenuClick?.(key, store.curInfo);
6886
- onClone();
6892
+ } else {
6893
+ setSelect(type);
6894
+ onChange(type);
6887
6895
  }
6896
+ }
6897
+ isDclick.current = null;
6898
+ if (type) return;
6899
+ if (selects.length) {
6900
+ if (checkMode !== 'check') {
6901
+ setSelect([]);
6902
+ onChange([]);
6903
+ empty();
6904
+ }
6905
+ }
6906
+ //创建选取
6907
+ clickRef.current = false;
6908
+ isSelectBoxes && setStageClickInfo({
6909
+ show: true,
6910
+ x: e.clientX,
6911
+ y: e.clientY
6888
6912
  });
6889
6913
  },
6890
- children: jsxs("div", {
6891
- ref: ref,
6892
- className: cx$1(`file-select-box ${className}`),
6893
- onDragLeave: e => {
6894
- e.preventDefault();
6895
- e.stopPropagation();
6896
- },
6897
- onMouseDown: e => {
6898
- // if (e.button === 2) return;
6899
- if (isDclick.current) {
6900
- clearTimeout(isDclick.current);
6901
- isDclick.current = null;
6902
- } else {
6903
- let type = isSelectTarget(e, checkType);
6904
- isDclick.current = setTimeout(() => {
6905
- //选中
6906
- if (checks.includes(type?.[0])) {
6907
- //右键不能今天拖动
6908
- if (e.button === 2) return;
6909
- if (!isDrag && checkMode == 'check') {
6910
- let arr = checks.filter(v => v !== type?.[0]);
6911
- setSelect(arr);
6912
- onChange(arr);
6914
+ onContextMenu: e => {
6915
+ let x = 0;
6916
+ let y = 0;
6917
+ x = e.nativeEvent.clientX + 5;
6918
+ y = e.nativeEvent.clientY + 5;
6919
+ store.openMenu({
6920
+ x: x,
6921
+ y: y,
6922
+ content: jsx(Menu, {
6923
+ menu: menudata,
6924
+ loadMenu: v => {
6925
+ let menu = loadMenu(v);
6926
+ if (menu?.key == 'rename') return undefined;
6927
+ if (menu?.key == 'copy') return undefined;
6928
+ return menu;
6929
+ },
6930
+ onChange: key => {
6931
+ if (key == 'update') {
6932
+ if (store?.curInfo) {
6933
+ loadData(store?.curInfo?.key);
6913
6934
  }
6914
- time = null;
6915
- isDrag && createVDom(e);
6935
+ store.closeMenu();
6916
6936
  return;
6917
6937
  }
6918
- //在区域未选中
6919
- if (Array.isArray(type)) {
6920
- if (checkMode == 'check') {
6921
- if (!checks.includes(type?.[0])) {
6922
- let arr = [...selects, ...type];
6923
- setSelect(arr);
6924
- onChange(arr);
6925
- }
6926
- } else {
6927
- setSelect(type);
6928
- onChange(type);
6929
- }
6938
+ if (key == 'file-upload') {
6939
+ store.uploadFile();
6940
+ store.closeMenu();
6941
+ return;
6930
6942
  }
6931
- isDclick.current = null;
6932
- }, 200);
6933
- if (type) return;
6934
- if (selects.length) {
6935
- if (checkMode !== 'check') {
6936
- setSelect([]);
6937
- onChange([]);
6938
- empty();
6943
+ if (key == 'create') {
6944
+ store.createFolder();
6945
+ store.closeMenu();
6946
+ return;
6939
6947
  }
6948
+ onMenuClick?.(key, store.curInfo);
6949
+ store.closeMenu();
6940
6950
  }
6941
- //创建选取
6942
- clickRef.current = false;
6943
- isSelectBoxes && setStageClickInfo({
6944
- show: true,
6945
- x: e.clientX,
6946
- y: e.clientY
6947
- });
6948
- }
6949
- },
6950
- children: [props.children, /*#__PURE__*/ReactDOM.createPortal(jsx("div", {
6951
- ref: selectionRef
6952
- }), document.body)]
6953
- })
6951
+ })
6952
+ }, store?.curInfo);
6953
+ },
6954
+ children: [props.children, /*#__PURE__*/ReactDOM.createPortal(jsx("div", {
6955
+ ref: selectionRef
6956
+ }), document.body)]
6954
6957
  });
6955
6958
  };
6956
6959
 
@@ -7233,7 +7236,7 @@ const Layout$1 = props => {
7233
7236
  const [expandkey, setExpandkey] = useState([]);
7234
7237
  useEffect(() => {
7235
7238
  setExpandkey([]);
7236
- }, [store.curInfo?.key]);
7239
+ }, [store?.curInfo?.key]);
7237
7240
  function Loading() {
7238
7241
  return jsx("div", {
7239
7242
  className: 'explorer-columns-loading',
@@ -7342,6 +7345,8 @@ const Layout$1 = props => {
7342
7345
  showLine: false,
7343
7346
  isOpenMenu: isOpenMenu,
7344
7347
  icon: store.getIcons,
7348
+ openMenu: store.openMenu,
7349
+ closeMenu: store.closeMenu,
7345
7350
  isload: true,
7346
7351
  ischeck: truncate,
7347
7352
  onChecks: arr => {
@@ -7382,6 +7387,8 @@ const Layout$1 = props => {
7382
7387
  data: store.curlist,
7383
7388
  icons: store.getIcons,
7384
7389
  checks: checks,
7390
+ openMenu: store.openMenu,
7391
+ closeMenu: store.closeMenu,
7385
7392
  onSelect: (key, v) => {
7386
7393
  store.setCurSelect(v.key);
7387
7394
  },
@@ -7650,6 +7657,9 @@ const Explorer = /*#__PURE__*/forwardRef((props, ref) => {
7650
7657
  const [menutype, setMenutype] = useState('tile');
7651
7658
  const [infoshow, setInfoShow] = useState(false);
7652
7659
  const [loading, setLoading] = useState(ApiStatusEnum.READY);
7660
+ const box = useRef(null);
7661
+ const boxMenu = useRef(null);
7662
+ const menu = useRef(null);
7653
7663
  useImperativeHandle(ref, () => ({
7654
7664
  removeLog: () => {
7655
7665
  //清空日志
@@ -7674,6 +7684,52 @@ const Explorer = /*#__PURE__*/forwardRef((props, ref) => {
7674
7684
  }
7675
7685
  }
7676
7686
  }));
7687
+ /* ************ 挂载监听 **************** */
7688
+ useEffect(() => {
7689
+ window.addEventListener('click', closeMenu);
7690
+ window.addEventListener('click', closeMenu);
7691
+ return () => {
7692
+ window.removeEventListener('click', closeMenu, false);
7693
+ window.removeEventListener('contextmenu', closeMenu, true);
7694
+ };
7695
+ }, []);
7696
+ useLayoutEffect(() => {
7697
+ window.addEventListener('keydown', handleKeyDown);
7698
+ return () => {
7699
+ window.removeEventListener('keydown', handleKeyDown);
7700
+ };
7701
+ }, [curSelect, dataMap]);
7702
+ const handleKeyDown = e => {
7703
+ if (e.altKey && e.key === '3') {
7704
+ setMenutype('column');
7705
+ }
7706
+ if (e.altKey && e.key === '2') {
7707
+ setMenutype('table');
7708
+ }
7709
+ if (e.altKey && e.key === '1') {
7710
+ setMenutype('tile');
7711
+ }
7712
+ if (e.ctrlKey && e.key === 'c') {
7713
+ if (curSelect && dataMap?.[curSelect]) {
7714
+ onCopy?.(dataMap?.[curSelect]);
7715
+ }
7716
+ }
7717
+ if (e.ctrlKey && e.key === 'x') {
7718
+ if (curSelect && dataMap?.[curSelect]) {
7719
+ onCopy?.(dataMap?.[curSelect]);
7720
+ }
7721
+ }
7722
+ if (e.ctrlKey && e.key === 'v') {
7723
+ if (curSelect && dataMap?.[curSelect]) {
7724
+ onCopy?.(dataMap?.[curSelect]);
7725
+ }
7726
+ }
7727
+ };
7728
+ const closeMenu = () => {
7729
+ boxMenu.current?.remove?.();
7730
+ boxMenu.current = null;
7731
+ menu.current = null;
7732
+ };
7677
7733
  const Icons = (v, className, style) => {
7678
7734
  const IconMap = new Map([['favorite', jsx(FavoriteSvg, {})], ['space', jsx(SpaceSvg, {})], ['netdisk', jsx(NetdiskSvg, {})], ['album', jsx(AlbumSvg, {})], ['recycle', jsx(RecycleSvg, {})], ['recently', jsx(RecentlySvg, {})], ['coordination', jsx(LinkSvg, {})], ['text', jsx(TextSvg, {})], ['share', jsx(ShareLinkSvg, {})]]);
7679
7735
  if (v?.label) {
@@ -7737,6 +7793,7 @@ const Explorer = /*#__PURE__*/forwardRef((props, ref) => {
7737
7793
  let map = addLevel(curlist, {});
7738
7794
  setDataMap(map);
7739
7795
  }, [curlist]);
7796
+ /* ************ 加载更新数据 **************** */
7740
7797
  async function loadData(key, param) {
7741
7798
  setLoading(ApiStatusEnum.LOADING);
7742
7799
  let data = (await props.loadData?.(key, param)) || {};
@@ -7760,9 +7817,76 @@ const Explorer = /*#__PURE__*/forwardRef((props, ref) => {
7760
7817
  let data = await props.loadData?.(key);
7761
7818
  return data?.fileList || [];
7762
7819
  }
7820
+ const reloadNode = key => {
7821
+ setNavLoadKey(nav_loadKey.filter(v => v !== key));
7822
+ const addData = (data, key) => {
7823
+ let arr = data;
7824
+ let i = 0;
7825
+ while (i < arr.length) {
7826
+ let item = arr[i];
7827
+ if (item.key == key) {
7828
+ item.api = true;
7829
+ item.isLeaf = false;
7830
+ item.children = [];
7831
+ }
7832
+ if (Array.isArray(item.children)) {
7833
+ item.children = addData(item.children, key);
7834
+ }
7835
+ i++;
7836
+ }
7837
+ return arr || [];
7838
+ };
7839
+ let arr = addData(data || [], key);
7840
+ onChange?.(arr);
7841
+ };
7842
+ function updata(id, param) {
7843
+ const fixData = (data, id, param) => {
7844
+ let arr = data;
7845
+ let i = 0;
7846
+ while (i < arr.length) {
7847
+ let item = arr[i];
7848
+ if (item.key == id) {
7849
+ let _arr = Object.keys(param);
7850
+ _arr.map(v => {
7851
+ item[v] = param[v];
7852
+ });
7853
+ }
7854
+ if (Array.isArray(item.children)) {
7855
+ item.children = fixData(item.children, id, param);
7856
+ }
7857
+ i++;
7858
+ }
7859
+ return arr || [];
7860
+ };
7861
+ let arr = fixData(data || [], id, param);
7862
+ onChange?.(arr);
7863
+ }
7864
+ /* ************ 功能方法 **************** */
7763
7865
  //创建和重名
7764
7866
  async function onRename(key, value, info, type) {
7765
7867
  if (info.create_file) {
7868
+ const delata = data => {
7869
+ let arr = data;
7870
+ let filter = [];
7871
+ let i = 0;
7872
+ while (i < arr.length) {
7873
+ let item = arr[i];
7874
+ if (!item?.create_file) {
7875
+ filter.push(item);
7876
+ }
7877
+ if (Array.isArray(item.children)) {
7878
+ item.children = delata(item.children);
7879
+ }
7880
+ i++;
7881
+ }
7882
+ return filter || [];
7883
+ };
7884
+ if (value === false) {
7885
+ let arr = delata(curlist);
7886
+ console.log(arr, 123);
7887
+ setCurList(arr);
7888
+ return;
7889
+ }
7766
7890
  if (curInfo) {
7767
7891
  await createFile?.(value, curInfo);
7768
7892
  curInfo?.key && loadData(curInfo?.key);
@@ -7868,50 +7992,6 @@ const Explorer = /*#__PURE__*/forwardRef((props, ref) => {
7868
7992
  });
7869
7993
  setCurList(list);
7870
7994
  }
7871
- function updata(id, param) {
7872
- const fixData = (data, id, param) => {
7873
- let arr = data;
7874
- let i = 0;
7875
- while (i < arr.length) {
7876
- let item = arr[i];
7877
- if (item.key == id) {
7878
- let _arr = Object.keys(param);
7879
- _arr.map(v => {
7880
- item[v] = param[v];
7881
- });
7882
- }
7883
- if (Array.isArray(item.children)) {
7884
- item.children = fixData(item.children, id, param);
7885
- }
7886
- i++;
7887
- }
7888
- return arr || [];
7889
- };
7890
- let arr = fixData(data || [], id, param);
7891
- onChange?.(arr);
7892
- }
7893
- const reloadNode = key => {
7894
- setNavLoadKey(nav_loadKey.filter(v => v !== key));
7895
- const addData = (data, key) => {
7896
- let arr = data;
7897
- let i = 0;
7898
- while (i < arr.length) {
7899
- let item = arr[i];
7900
- if (item.key == key) {
7901
- item.api = true;
7902
- item.isLeaf = false;
7903
- item.children = [];
7904
- }
7905
- if (Array.isArray(item.children)) {
7906
- item.children = addData(item.children, key);
7907
- }
7908
- i++;
7909
- }
7910
- return arr || [];
7911
- };
7912
- let arr = addData(data || [], key);
7913
- onChange?.(arr);
7914
- };
7915
7995
  async function onMenuClick(key, param, type) {
7916
7996
  if (key == 'remove') {
7917
7997
  await onDelect?.(param);
@@ -7937,7 +8017,64 @@ const Explorer = /*#__PURE__*/forwardRef((props, ref) => {
7937
8017
  return;
7938
8018
  }
7939
8019
  _onMenuClick?.(key, param);
7940
- console.log('运行');
8020
+ }
8021
+ function openMenu(props, param) {
8022
+ if (param?.key) ;
8023
+ closeMenu();
8024
+ let {
8025
+ x = 0,
8026
+ y = 0,
8027
+ className = '',
8028
+ placement,
8029
+ content
8030
+ } = props;
8031
+ let _menu = null;
8032
+ _menu = document.createElement('div');
8033
+ menu.current = createRoot(_menu);
8034
+ if (boxMenu.current) {
8035
+ boxMenu.current?.appendChild(menu);
8036
+ } else {
8037
+ let body = document.querySelector('body');
8038
+ let _body = document.createElement('div');
8039
+ _body.className = `_explorer-menu ${className}`;
8040
+ _body.style.cssText = `
8041
+ position:absolute;
8042
+ top: 0px;
8043
+ left: 0px;
8044
+ widht:0px;
8045
+ height: 0px;
8046
+ z-index:110;
8047
+ `;
8048
+ boxMenu.current = _body;
8049
+ _body?.appendChild(_menu);
8050
+ body?.appendChild(_body);
8051
+ }
8052
+ let _box = box.current.getBoundingClientRect();
8053
+ _menu.style.cssText = `
8054
+ position:absolute;
8055
+ top: -100px;
8056
+ left: -100px;
8057
+ background: #fff;
8058
+ opacity: 0;
8059
+ `;
8060
+ _box.bottom;
8061
+ _box.top;
8062
+ menu.current.render(content);
8063
+ setTimeout(() => {
8064
+ let cur = _menu.getBoundingClientRect();
8065
+ if (cur.height + y > _box.bottom) {
8066
+ y = y - cur.height - 10;
8067
+ }
8068
+ if (cur.width + x > _box.right) {
8069
+ x = x - cur.width - 10;
8070
+ }
8071
+ _menu.style.cssText = `
8072
+ position:absolute;
8073
+ top: ${y}px;
8074
+ left:${x}px;
8075
+ background: #fff;
8076
+ `;
8077
+ }, 100);
7941
8078
  }
7942
8079
  return jsx(ExampleContext.Provider, {
7943
8080
  value: {
@@ -7967,6 +8104,8 @@ const Explorer = /*#__PURE__*/forwardRef((props, ref) => {
7967
8104
  uploadFile,
7968
8105
  createFolder,
7969
8106
  reloadNode,
8107
+ openMenu,
8108
+ closeMenu,
7970
8109
  //set
7971
8110
  setLog,
7972
8111
  setLogIndex,
@@ -7985,6 +8124,7 @@ const Explorer = /*#__PURE__*/forwardRef((props, ref) => {
7985
8124
  },
7986
8125
  children: jsx("div", {
7987
8126
  className: 'explorer-container',
8127
+ ref: box,
7988
8128
  children: jsx(Layout, {
7989
8129
  ...props,
7990
8130
  loadData: loadData,