@lvce-editor/explorer-view 2.2.0 → 2.3.0
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/dist/explorerViewWorkerMain.js +42 -20
- package/package.json +1 -1
|
@@ -1384,7 +1384,7 @@ const DiffFocus = {
|
|
|
1384
1384
|
|
|
1385
1385
|
const diffType = RenderItems;
|
|
1386
1386
|
const isEqual$1 = (oldState, newState) => {
|
|
1387
|
-
return oldState.items === newState.items && oldState.minLineY === newState.minLineY && oldState.maxLineY === newState.maxLineY && oldState.focusedIndex === newState.focusedIndex && oldState.editingIndex === newState.editingIndex && oldState.editingType === newState.editingType && oldState.editingValue === newState.editingValue && oldState.width === newState.width && oldState.focused === newState.focused;
|
|
1387
|
+
return oldState.items === newState.items && oldState.minLineY === newState.minLineY && oldState.maxLineY === newState.maxLineY && oldState.focusedIndex === newState.focusedIndex && oldState.editingIndex === newState.editingIndex && oldState.editingType === newState.editingType && oldState.editingValue === newState.editingValue && oldState.width === newState.width && oldState.focused === newState.focused && oldState.dropTargets === newState.dropTargets;
|
|
1388
1388
|
};
|
|
1389
1389
|
|
|
1390
1390
|
const DiffItems = {
|
|
@@ -2567,13 +2567,15 @@ const canBeDroppedInto = dirent => {
|
|
|
2567
2567
|
}
|
|
2568
2568
|
};
|
|
2569
2569
|
|
|
2570
|
+
const dropTargetFull = [-1];
|
|
2571
|
+
|
|
2570
2572
|
const getNewDropTargets = (state, x, y) => {
|
|
2571
2573
|
const {
|
|
2572
2574
|
items
|
|
2573
2575
|
} = state;
|
|
2574
2576
|
const index = getIndexFromPosition(state, x, y);
|
|
2575
2577
|
if (index === -1) {
|
|
2576
|
-
return
|
|
2578
|
+
return dropTargetFull;
|
|
2577
2579
|
}
|
|
2578
2580
|
const item = items[index];
|
|
2579
2581
|
if (!canBeDroppedInto(item)) {
|
|
@@ -2721,6 +2723,7 @@ const handleDropIntoFolder = async (state, dirent, index, files) => {
|
|
|
2721
2723
|
pathSeparator,
|
|
2722
2724
|
items
|
|
2723
2725
|
} = state;
|
|
2726
|
+
// @ts-ignore
|
|
2724
2727
|
for (const file of files) {
|
|
2725
2728
|
// TODO path basename
|
|
2726
2729
|
const baseName = file;
|
|
@@ -2747,7 +2750,7 @@ const handleDropIntoFile = (state, dirent, index, files) => {
|
|
|
2747
2750
|
// @ts-ignore
|
|
2748
2751
|
return handleDropIndex(parentIndex);
|
|
2749
2752
|
};
|
|
2750
|
-
const handleDropIndex = async (state,
|
|
2753
|
+
const handleDropIndex = async (state, files, index) => {
|
|
2751
2754
|
const {
|
|
2752
2755
|
items
|
|
2753
2756
|
} = state;
|
|
@@ -2766,15 +2769,20 @@ const handleDropIndex = async (state, index, files) => {
|
|
|
2766
2769
|
}
|
|
2767
2770
|
};
|
|
2768
2771
|
|
|
2772
|
+
const getDropHandler = index => {
|
|
2773
|
+
switch (index) {
|
|
2774
|
+
case -1:
|
|
2775
|
+
return handleDropRoot;
|
|
2776
|
+
default:
|
|
2777
|
+
return handleDropIndex;
|
|
2778
|
+
}
|
|
2779
|
+
};
|
|
2769
2780
|
const handleDrop = async (state, x, y, files) => {
|
|
2770
2781
|
try {
|
|
2771
2782
|
const index = getIndexFromPosition(state, x, y);
|
|
2772
|
-
|
|
2773
|
-
|
|
2774
|
-
|
|
2775
|
-
default:
|
|
2776
|
-
return await handleDropIndex(state, index, files);
|
|
2777
|
-
}
|
|
2783
|
+
const fn = getDropHandler(index);
|
|
2784
|
+
const result = await fn(state, files, index);
|
|
2785
|
+
return result;
|
|
2778
2786
|
} catch (error) {
|
|
2779
2787
|
throw new VError(error, 'Failed to drop files');
|
|
2780
2788
|
}
|
|
@@ -3345,6 +3353,8 @@ const ButtonPrimary = 'ButtonPrimary';
|
|
|
3345
3353
|
const ButtonWide = 'ButtonWide';
|
|
3346
3354
|
const Chevron = 'Chevron';
|
|
3347
3355
|
const Explorer = 'Explorer';
|
|
3356
|
+
const Empty = '';
|
|
3357
|
+
const ExplorerDropTarget = 'DropTarget';
|
|
3348
3358
|
const FileIcon = 'FileIcon';
|
|
3349
3359
|
const FocusOutline = 'FocusOutline';
|
|
3350
3360
|
const IconButton = 'IconButton';
|
|
@@ -3379,6 +3389,7 @@ const HandleListFocus = 'handleListFocus';
|
|
|
3379
3389
|
const HandlePointerDown = 'handlePointerDown';
|
|
3380
3390
|
const HandleWheel = 'handleWheel';
|
|
3381
3391
|
const HandleDragOver = 'handleDragOver';
|
|
3392
|
+
const HandleDrop = 'handleDrop';
|
|
3382
3393
|
|
|
3383
3394
|
const mergeClassNames = (...classNames) => {
|
|
3384
3395
|
return classNames.filter(Boolean).join(' ');
|
|
@@ -3509,26 +3520,32 @@ const getActiveDescendant = focusedIndex => {
|
|
|
3509
3520
|
}
|
|
3510
3521
|
return undefined;
|
|
3511
3522
|
};
|
|
3512
|
-
const
|
|
3523
|
+
const getClassName = (focused, focusedIndex, dropTarget) => {
|
|
3524
|
+
const extraClass1 = focused && focusedIndex === -1 ? FocusOutline : Empty;
|
|
3525
|
+
const extraClass2 = dropTarget === dropTargetFull ? ExplorerDropTarget : Empty;
|
|
3526
|
+
const className = mergeClassNames(Viewlet, Explorer, extraClass1, extraClass2);
|
|
3527
|
+
return className;
|
|
3528
|
+
};
|
|
3529
|
+
const getExplorerVirtualDom = (visibleItems, focusedIndex, root, isWide, focused, dropTargets) => {
|
|
3513
3530
|
if (!root) {
|
|
3514
3531
|
return getExplorerWelcomeVirtualDom(isWide);
|
|
3515
3532
|
}
|
|
3516
|
-
const extraClass = focused && focusedIndex === -1 ? FocusOutline : '';
|
|
3517
3533
|
const dom = [{
|
|
3518
3534
|
type: Div,
|
|
3519
|
-
className:
|
|
3535
|
+
className: getClassName(focused, focusedIndex, dropTargets),
|
|
3520
3536
|
tabIndex: 0,
|
|
3521
3537
|
role: Tree,
|
|
3522
3538
|
ariaLabel: filesExplorer(),
|
|
3523
3539
|
childCount: visibleItems.length,
|
|
3524
3540
|
ariaActiveDescendant: getActiveDescendant(focusedIndex),
|
|
3525
|
-
onFocus: HandleListFocus,
|
|
3526
3541
|
onBlur: HandleListBlur,
|
|
3542
|
+
onClick: HandleClick,
|
|
3527
3543
|
onContextMenu: HandleContextMenu,
|
|
3544
|
+
onDragOver: HandleDragOver,
|
|
3545
|
+
onDrop: HandleDrop,
|
|
3546
|
+
onFocus: HandleListFocus,
|
|
3528
3547
|
onPointerDown: HandlePointerDown,
|
|
3529
|
-
onWheel: HandleWheel
|
|
3530
|
-
onClick: HandleClick,
|
|
3531
|
-
onDragOver: HandleDragOver
|
|
3548
|
+
onWheel: HandleWheel
|
|
3532
3549
|
}, ...visibleItems.flatMap(getExplorerItemVirtualDom)];
|
|
3533
3550
|
return dom;
|
|
3534
3551
|
};
|
|
@@ -3586,7 +3603,7 @@ const getTreeItemIndentWithChevron = (depth, chevron) => {
|
|
|
3586
3603
|
};
|
|
3587
3604
|
|
|
3588
3605
|
const ariaExpandedValues = [undefined, 'true', 'false'];
|
|
3589
|
-
const getVisibleExplorerItems = (items, minLineY, maxLineY, focusedIndex, editingIndex, editingType, editingValue, icons, useChevrons) => {
|
|
3606
|
+
const getVisibleExplorerItems = (items, minLineY, maxLineY, focusedIndex, editingIndex, editingType, editingValue, icons, useChevrons, dropTargets) => {
|
|
3590
3607
|
const visible = [];
|
|
3591
3608
|
const indentFn = useChevrons ? getTreeItemIndentWithChevron : getTreeItemIndent;
|
|
3592
3609
|
let iconIndex = 0;
|
|
@@ -3597,7 +3614,7 @@ const getVisibleExplorerItems = (items, minLineY, maxLineY, focusedIndex, editin
|
|
|
3597
3614
|
const indent = indentFn(item.depth, chevron);
|
|
3598
3615
|
const isFocused = i === focusedIndex;
|
|
3599
3616
|
const id = isFocused ? 'TreeItemActive' : undefined;
|
|
3600
|
-
const className = isFocused ? TreeItem
|
|
3617
|
+
const className = isFocused ? mergeClassNames(TreeItem, TreeItemActive) : TreeItem;
|
|
3601
3618
|
const expanded = getExpandedType(item.type);
|
|
3602
3619
|
const ariaExpanded = ariaExpandedValues[expanded];
|
|
3603
3620
|
visible.push({
|
|
@@ -3633,7 +3650,7 @@ const getVisibleExplorerItems = (items, minLineY, maxLineY, focusedIndex, editin
|
|
|
3633
3650
|
const renderItems = (oldState, newState) => {
|
|
3634
3651
|
const visibleDirents = getVisibleExplorerItems(newState.items, newState.minLineY, newState.maxLineY, newState.focusedIndex, newState.editingIndex, newState.editingType, newState.editingValue, newState.icons, newState.useChevrons);
|
|
3635
3652
|
const isWide = newState.width > 450;
|
|
3636
|
-
const dom = getExplorerVirtualDom(visibleDirents, newState.focusedIndex, newState.root, isWide, newState.focused);
|
|
3653
|
+
const dom = getExplorerVirtualDom(visibleDirents, newState.focusedIndex, newState.root, isWide, newState.focused, newState.dropTargets);
|
|
3637
3654
|
return ['Viewlet.setDom2', dom];
|
|
3638
3655
|
};
|
|
3639
3656
|
|
|
@@ -3792,7 +3809,12 @@ const renderEventListeners = () => {
|
|
|
3792
3809
|
passive: true
|
|
3793
3810
|
}, {
|
|
3794
3811
|
name: HandleDragOver,
|
|
3795
|
-
params: ['handleDragOver', 'event.clientX', 'event.clientY']
|
|
3812
|
+
params: ['handleDragOver', 'event.clientX', 'event.clientY'],
|
|
3813
|
+
preventDefault: true
|
|
3814
|
+
}, {
|
|
3815
|
+
name: HandleDrop,
|
|
3816
|
+
params: ['handleDrop', 'event.clientX', 'event.clientY', 'event.dataTransfer.files'],
|
|
3817
|
+
preventDefault: true
|
|
3796
3818
|
}];
|
|
3797
3819
|
};
|
|
3798
3820
|
|