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

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.38
2
+ * @gingkoo/pandora-explorer v0.0.1-alpha.39
3
3
  */
4
4
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
5
5
  import cx$1 from 'classnames';
@@ -5310,6 +5310,19 @@ function TableItem(props) {
5310
5310
  autoFocus: true,
5311
5311
  defaultValue: param[v?.key],
5312
5312
  placeholder: '\u8BF7\u8F93\u5165',
5313
+ onKeyDown: e => {
5314
+ if (e.key === 'Enter' || e.keyCode === 13) {
5315
+ if (props.create_file) {
5316
+ onRename?.(e.target?.value);
5317
+ return;
5318
+ }
5319
+ if (e.target?.value === param[v?.key]) {
5320
+ onRename?.(false);
5321
+ return;
5322
+ }
5323
+ onRename?.(e.target?.value);
5324
+ }
5325
+ },
5313
5326
  onFocus: e => {
5314
5327
  let i = param[v?.key]?.lastIndexOf('.');
5315
5328
  if (props?.suffix == 'folder') {
@@ -5405,6 +5418,11 @@ var TreeItem = (props => {
5405
5418
  autoFocus: true,
5406
5419
  value: title,
5407
5420
  placeholder: '\u8BF7\u8F93\u5165',
5421
+ onKeyDown: e => {
5422
+ if (e.key === 'Enter' || e.keyCode === 13) {
5423
+ onRename?.(title);
5424
+ }
5425
+ },
5408
5426
  onFocus: e => {
5409
5427
  let i = title.lastIndexOf('.');
5410
5428
  if (props?.suffix == 'folder') {
@@ -6228,7 +6246,29 @@ function Tile(props) {
6228
6246
  e.target.setSelectionRange(0, i);
6229
6247
  }
6230
6248
  },
6249
+ onKeyDown: e => {
6250
+ if (e.key === 'Enter' || e.keyCode === 13) {
6251
+ if (props.create_file) {
6252
+ onRename?.(v.key, e.target?.value, v);
6253
+ return;
6254
+ }
6255
+ if (e.target?.value === v.title) {
6256
+ setRekey(null);
6257
+ return;
6258
+ }
6259
+ onRename?.(v.key, e.target.value, v);
6260
+ setRekey(null);
6261
+ }
6262
+ },
6231
6263
  onBlur: e => {
6264
+ if (props.create_file) {
6265
+ onRename?.(v.key, e.target?.value, v);
6266
+ return;
6267
+ }
6268
+ if (e.target?.value === v.title) {
6269
+ setRekey(null);
6270
+ return;
6271
+ }
6232
6272
  onRename?.(v.key, e.target.value, v);
6233
6273
  setRekey(null);
6234
6274
  },
@@ -6475,20 +6515,48 @@ const SelectBox = props => {
6475
6515
  setIsDragFile(false);
6476
6516
  e.preventDefault();
6477
6517
  e.stopPropagation();
6478
- const files = [...e.dataTransfer.files];
6518
+ const items = e.dataTransfer.items;
6519
+ let files = [];
6520
+ let empty = [];
6521
+ const traverseFileTree = (item, path = '') => {
6522
+ if (item.isFile) {
6523
+ item.file(file => {
6524
+ files = [...files, file];
6525
+ });
6526
+ } else if (item.isDirectory) {
6527
+ const dirReader = item.createReader();
6528
+ dirReader.readEntries(async entries => {
6529
+ if (!entries.length) {
6530
+ empty.push(path + item.name + '/');
6531
+ } else {
6532
+ for (let i = 0; i < entries.length; i++) {
6533
+ traverseFileTree(entries[i], path + item.name + '/');
6534
+ }
6535
+ }
6536
+ });
6537
+ }
6538
+ };
6539
+ for (let i = 0; i < items.length; i++) {
6540
+ const item = items[i].webkitGetAsEntry();
6541
+ if (item) {
6542
+ traverseFileTree(item, '');
6543
+ }
6544
+ }
6479
6545
  let data = isSelectTarget(e, 'folder', 'remove');
6480
6546
  let key = null;
6481
6547
  if (ref.current.contains(e.target)) {
6482
6548
  key = store.curInfo;
6483
6549
  ref.current.style.cssText = `
6484
- border:2px solid transparent;
6485
- `;
6486
- }
6487
- if (typeof data?.[0] == 'string' && store?.dataMap?.[data?.[0]]) {
6488
- key = store?.dataMap?.[data?.[0]];
6550
+ border:2px solid transparent;
6551
+ `;
6489
6552
  }
6490
- if (!key) return;
6491
- typeof onUpload === 'function' && onUpload(files, key);
6553
+ setTimeout(() => {
6554
+ if (typeof data?.[0] == 'string' && store?.dataMap?.[data?.[0]]) {
6555
+ key = store?.dataMap?.[data?.[0]];
6556
+ }
6557
+ if (!key) return;
6558
+ typeof onUpload === 'function' && onUpload(files, key, empty);
6559
+ }, 500);
6492
6560
  };
6493
6561
  function handleDragEnter(e) {
6494
6562
  e.preventDefault();
@@ -7696,9 +7764,11 @@ const Explorer = /*#__PURE__*/forwardRef((props, ref) => {
7696
7764
  if (!curInfo) return;
7697
7765
  let input = document.createElement('input');
7698
7766
  input.type = 'file';
7767
+ input.multiple = true;
7699
7768
  input?.click();
7700
7769
  input.onchange = async e => {
7701
- await props?.onUpload?.(e.target.files[0], curInfo);
7770
+ const files = Array.from(e.target.files);
7771
+ await props?.onUpload?.(files, curInfo);
7702
7772
  loadData?.(curInfo?.key);
7703
7773
  };
7704
7774
  }