@lvce-editor/file-search-worker 5.10.0 → 5.11.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/fileSearchWorkerMain.js +105 -15
- package/package.json +1 -1
|
@@ -940,7 +940,7 @@ const create$1 = ({
|
|
|
940
940
|
scrollBarActive: false
|
|
941
941
|
};
|
|
942
942
|
};
|
|
943
|
-
const getListHeight = (height, headerHeight) => {
|
|
943
|
+
const getListHeight$1 = (height, headerHeight) => {
|
|
944
944
|
if (headerHeight) {
|
|
945
945
|
return height - headerHeight;
|
|
946
946
|
}
|
|
@@ -955,7 +955,7 @@ const setDeltaY = (state, deltaY) => {
|
|
|
955
955
|
height,
|
|
956
956
|
headerHeight
|
|
957
957
|
} = state;
|
|
958
|
-
const listHeight = getListHeight(height, headerHeight);
|
|
958
|
+
const listHeight = getListHeight$1(height, headerHeight);
|
|
959
959
|
const itemsLength = items.length;
|
|
960
960
|
const finalDeltaY = itemsLength * itemHeight - listHeight;
|
|
961
961
|
if (deltaY < 0) {
|
|
@@ -1709,6 +1709,23 @@ const getFilterValue = (id, value) => {
|
|
|
1709
1709
|
return filterValue;
|
|
1710
1710
|
};
|
|
1711
1711
|
|
|
1712
|
+
const getFinalDeltaY = (height, itemHeight, itemsLength) => {
|
|
1713
|
+
const contentHeight = itemsLength * itemHeight;
|
|
1714
|
+
const finalDeltaY = Math.max(contentHeight - height, 0);
|
|
1715
|
+
return finalDeltaY;
|
|
1716
|
+
};
|
|
1717
|
+
|
|
1718
|
+
const getListHeight = (itemsLength, itemHeight, maxHeight) => {
|
|
1719
|
+
number(itemsLength);
|
|
1720
|
+
number(itemHeight);
|
|
1721
|
+
number(maxHeight);
|
|
1722
|
+
if (itemsLength === 0) {
|
|
1723
|
+
return itemHeight;
|
|
1724
|
+
}
|
|
1725
|
+
const totalHeight = itemsLength * itemHeight;
|
|
1726
|
+
return Math.min(totalHeight, maxHeight);
|
|
1727
|
+
};
|
|
1728
|
+
|
|
1712
1729
|
const getColorThemeNames = async () => {
|
|
1713
1730
|
return invoke$1(/* Ajax.getJson */'ColorTheme.getColorThemeNames');
|
|
1714
1731
|
};
|
|
@@ -2279,7 +2296,9 @@ const setValue = async (state, newValue) => {
|
|
|
2279
2296
|
value,
|
|
2280
2297
|
minLineY,
|
|
2281
2298
|
maxLineY,
|
|
2282
|
-
fileIconCache
|
|
2299
|
+
fileIconCache,
|
|
2300
|
+
itemHeight,
|
|
2301
|
+
height
|
|
2283
2302
|
} = state;
|
|
2284
2303
|
if (value === newValue) {
|
|
2285
2304
|
return state;
|
|
@@ -2295,6 +2314,8 @@ const setValue = async (state, newValue) => {
|
|
|
2295
2314
|
newFileIconCache,
|
|
2296
2315
|
icons
|
|
2297
2316
|
} = await getQuickPickFileIcons(sliced, fileIconCache);
|
|
2317
|
+
const listHeight = getListHeight(items.length, itemHeight, height);
|
|
2318
|
+
const finalDeltaY = getFinalDeltaY(listHeight, itemHeight, items.length);
|
|
2298
2319
|
return {
|
|
2299
2320
|
...state,
|
|
2300
2321
|
picks: newPicks,
|
|
@@ -2303,7 +2324,8 @@ const setValue = async (state, newValue) => {
|
|
|
2303
2324
|
inputSource: Script,
|
|
2304
2325
|
value: newValue,
|
|
2305
2326
|
icons,
|
|
2306
|
-
fileIconCache: newFileIconCache
|
|
2327
|
+
fileIconCache: newFileIconCache,
|
|
2328
|
+
finalDeltaY
|
|
2307
2329
|
};
|
|
2308
2330
|
};
|
|
2309
2331
|
|
|
@@ -2479,7 +2501,9 @@ const loadContent = async state => {
|
|
|
2479
2501
|
const {
|
|
2480
2502
|
uri,
|
|
2481
2503
|
args,
|
|
2482
|
-
fileIconCache
|
|
2504
|
+
fileIconCache,
|
|
2505
|
+
itemHeight,
|
|
2506
|
+
height
|
|
2483
2507
|
} = state;
|
|
2484
2508
|
const id = getQuickPickProviderId(uri);
|
|
2485
2509
|
const value = getDefaultValue(id);
|
|
@@ -2497,6 +2521,8 @@ const loadContent = async state => {
|
|
|
2497
2521
|
newFileIconCache,
|
|
2498
2522
|
icons
|
|
2499
2523
|
} = await getQuickPickFileIcons(sliced, fileIconCache);
|
|
2524
|
+
const listHeight = getListHeight(items.length, itemHeight, height);
|
|
2525
|
+
const finalDeltaY = getFinalDeltaY(listHeight, itemHeight, items.length);
|
|
2500
2526
|
return {
|
|
2501
2527
|
...state,
|
|
2502
2528
|
picks: newPicks,
|
|
@@ -2511,7 +2537,8 @@ const loadContent = async state => {
|
|
|
2511
2537
|
focused: true,
|
|
2512
2538
|
fileIconCache: newFileIconCache,
|
|
2513
2539
|
icons,
|
|
2514
|
-
providerId: id
|
|
2540
|
+
providerId: id,
|
|
2541
|
+
finalDeltaY
|
|
2515
2542
|
};
|
|
2516
2543
|
};
|
|
2517
2544
|
|
|
@@ -2526,6 +2553,13 @@ const getVisible$1 = (items, minLineY, maxLineY, icons) => {
|
|
|
2526
2553
|
return protoVisibleItems;
|
|
2527
2554
|
};
|
|
2528
2555
|
|
|
2556
|
+
const getScrollBarSize = (size, contentSize, minimumSliderSize) => {
|
|
2557
|
+
if (size >= contentSize) {
|
|
2558
|
+
return 0;
|
|
2559
|
+
}
|
|
2560
|
+
return Math.max(Math.round(size ** 2 / contentSize), minimumSliderSize);
|
|
2561
|
+
};
|
|
2562
|
+
|
|
2529
2563
|
const emptyHighlightSections = [];
|
|
2530
2564
|
|
|
2531
2565
|
const getHighlightSections = (highlights, label) => {
|
|
@@ -2576,14 +2610,31 @@ const getVisible = (setSize, protoVisibleItems, minLineY, focusedIndex) => {
|
|
|
2576
2610
|
return visibleItems;
|
|
2577
2611
|
};
|
|
2578
2612
|
|
|
2613
|
+
const getScrollBarOffset = (delta, finalDelta, size, scrollBarSize) => {
|
|
2614
|
+
const scrollBarOffset = delta / finalDelta * (size - scrollBarSize);
|
|
2615
|
+
return scrollBarOffset;
|
|
2616
|
+
};
|
|
2617
|
+
const getScrollBarY = getScrollBarOffset;
|
|
2618
|
+
|
|
2579
2619
|
const createQuickPickViewModel = (oldState, newState) => {
|
|
2580
2620
|
const protoVisibleItems = getVisible$1(newState.items, newState.minLineY, newState.maxLineY, newState.icons);
|
|
2581
2621
|
const visibleItems = getVisible(newState.items.length, protoVisibleItems, newState.minLineY, newState.focusedIndex);
|
|
2582
2622
|
const oldFocusedIndex = oldState.focusedIndex - oldState.minLineY;
|
|
2583
2623
|
const newFocusedIndex = newState.focusedIndex - newState.minLineY;
|
|
2584
|
-
const
|
|
2585
|
-
const
|
|
2586
|
-
|
|
2624
|
+
const itemCount = newState.items.length;
|
|
2625
|
+
const {
|
|
2626
|
+
itemHeight,
|
|
2627
|
+
deltaY,
|
|
2628
|
+
finalDeltaY,
|
|
2629
|
+
minimumSliderSize,
|
|
2630
|
+
headerHeight,
|
|
2631
|
+
height
|
|
2632
|
+
} = newState;
|
|
2633
|
+
const listHeight = getListHeight(itemCount, itemHeight, height);
|
|
2634
|
+
const contentHeight = itemCount * itemHeight;
|
|
2635
|
+
const scrollBarHeight = getScrollBarSize(listHeight, contentHeight, minimumSliderSize);
|
|
2636
|
+
const scrollBarY = getScrollBarY(deltaY, finalDeltaY, height - headerHeight, scrollBarHeight);
|
|
2637
|
+
const roundedScrollBarY = Math.round(scrollBarY);
|
|
2587
2638
|
return {
|
|
2588
2639
|
visibleItems,
|
|
2589
2640
|
value: newState.value,
|
|
@@ -2592,7 +2643,9 @@ const createQuickPickViewModel = (oldState, newState) => {
|
|
|
2592
2643
|
height,
|
|
2593
2644
|
oldFocusedIndex,
|
|
2594
2645
|
newFocusedIndex,
|
|
2595
|
-
uid: newState.uid
|
|
2646
|
+
uid: newState.uid,
|
|
2647
|
+
scrollBarHeight,
|
|
2648
|
+
scrollBarTop: roundedScrollBarY
|
|
2596
2649
|
};
|
|
2597
2650
|
};
|
|
2598
2651
|
|
|
@@ -2626,9 +2679,12 @@ const ListBox = 'listbox';
|
|
|
2626
2679
|
const None = 'none';
|
|
2627
2680
|
const Option = 'option';
|
|
2628
2681
|
|
|
2682
|
+
const ContainContent = 'ContainContent';
|
|
2629
2683
|
const FileIcon = 'FileIcon';
|
|
2630
2684
|
const InputBox = 'InputBox';
|
|
2631
2685
|
const Label = 'Label';
|
|
2686
|
+
const List = 'List';
|
|
2687
|
+
const ListItems = 'ListItems';
|
|
2632
2688
|
const MaskIcon = 'MaskIcon';
|
|
2633
2689
|
const QuickPick$1 = 'QuickPick';
|
|
2634
2690
|
const QuickPickHeader = 'QuickPickHeader';
|
|
@@ -2637,9 +2693,11 @@ const QuickPickItem = 'QuickPickItem';
|
|
|
2637
2693
|
const QuickPickItemActive$1 = 'QuickPickItemActive';
|
|
2638
2694
|
const QuickPickItemDescription = 'QuickPickItemDescription';
|
|
2639
2695
|
const QuickPickItemLabel = 'QuickPickItemLabel';
|
|
2640
|
-
const QuickPickItems$1 = 'QuickPickItems';
|
|
2641
2696
|
const QuickPickMaskIcon = 'QuickPickMaskIcon';
|
|
2642
2697
|
const QuickPickStatus = 'QuickPickStatus';
|
|
2698
|
+
const ScrollBar = 'ScrollBar';
|
|
2699
|
+
const ScrollBarSmall = 'ScrollBarSmall';
|
|
2700
|
+
const ScrollBarThumb = 'ScrollBarThumb';
|
|
2643
2701
|
const Viewlet = 'Viewlet';
|
|
2644
2702
|
|
|
2645
2703
|
const HandleWheel = 'handleWheel';
|
|
@@ -2810,8 +2868,36 @@ const getQuickPickItemsVirtualDom = visibleItems => {
|
|
|
2810
2868
|
return dom;
|
|
2811
2869
|
};
|
|
2812
2870
|
|
|
2813
|
-
const
|
|
2871
|
+
const px = value => {
|
|
2872
|
+
return `${value}px`;
|
|
2873
|
+
};
|
|
2874
|
+
const position = (x, y) => {
|
|
2875
|
+
return `${x}px ${y}px`;
|
|
2876
|
+
};
|
|
2877
|
+
|
|
2878
|
+
const getScrollBarVirtualDom = (scrollBarHeight, scrollBarTop) => {
|
|
2879
|
+
const shouldShowScrollbar = scrollBarHeight > 0;
|
|
2880
|
+
if (!shouldShowScrollbar) {
|
|
2881
|
+
return [];
|
|
2882
|
+
}
|
|
2883
|
+
const heightString = px(scrollBarHeight);
|
|
2884
|
+
const translateString = position(0, scrollBarTop);
|
|
2885
|
+
return [{
|
|
2886
|
+
type: Div,
|
|
2887
|
+
className: mergeClassNames(ScrollBar, ScrollBarSmall),
|
|
2888
|
+
childCount: 1
|
|
2889
|
+
}, {
|
|
2890
|
+
type: Div,
|
|
2891
|
+
className: ScrollBarThumb,
|
|
2892
|
+
childCount: 0,
|
|
2893
|
+
height: heightString,
|
|
2894
|
+
translate: translateString
|
|
2895
|
+
}];
|
|
2896
|
+
};
|
|
2897
|
+
|
|
2898
|
+
const getQuickPickVirtualDom = (visibleItems, scrollBarHeight, scrollBarTop) => {
|
|
2814
2899
|
const quickOpen$1 = quickOpen();
|
|
2900
|
+
const shouldShowScrollbar = scrollBarHeight > 0;
|
|
2815
2901
|
return [{
|
|
2816
2902
|
type: Div,
|
|
2817
2903
|
className: mergeClassNames(Viewlet, QuickPick$1),
|
|
@@ -2820,18 +2906,22 @@ const getQuickPickVirtualDom = visibleItems => {
|
|
|
2820
2906
|
ariaLabel: quickOpen$1
|
|
2821
2907
|
}, ...getQuickPickHeaderVirtualDom(), {
|
|
2822
2908
|
type: Div,
|
|
2823
|
-
className:
|
|
2909
|
+
className: mergeClassNames(List, ContainContent),
|
|
2824
2910
|
id: QuickPickItems,
|
|
2825
2911
|
role: ListBox,
|
|
2826
2912
|
ariaActivedescendant: QuickPickItemActive,
|
|
2827
2913
|
onWheel: HandleWheel,
|
|
2828
2914
|
onPointerDown: HandlePointerDown,
|
|
2915
|
+
childCount: shouldShowScrollbar ? 2 : 1
|
|
2916
|
+
}, {
|
|
2917
|
+
type: Div,
|
|
2918
|
+
className: mergeClassNames(ListItems, ContainContent),
|
|
2829
2919
|
childCount: visibleItems.length
|
|
2830
|
-
}, ...getQuickPickItemsVirtualDom(visibleItems)];
|
|
2920
|
+
}, ...getQuickPickItemsVirtualDom(visibleItems), ...getScrollBarVirtualDom(scrollBarHeight, scrollBarTop)];
|
|
2831
2921
|
};
|
|
2832
2922
|
|
|
2833
2923
|
const renderItems = newState => {
|
|
2834
|
-
const dom = getQuickPickVirtualDom(newState.visibleItems);
|
|
2924
|
+
const dom = getQuickPickVirtualDom(newState.visibleItems, newState.scrollBarHeight, newState.scrollBarTop);
|
|
2835
2925
|
return ['Viewlet.setDom2', dom];
|
|
2836
2926
|
};
|
|
2837
2927
|
|