@lvce-editor/extension-search-view 4.10.0 → 4.12.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.
|
@@ -1241,6 +1241,46 @@ const getFinalDeltaY = (height, itemHeight, itemsLength) => {
|
|
|
1241
1241
|
return finalDeltaY;
|
|
1242
1242
|
};
|
|
1243
1243
|
|
|
1244
|
+
const Button = 1;
|
|
1245
|
+
|
|
1246
|
+
const HandleClearSearchResults = 1;
|
|
1247
|
+
const HandleClickFilter = 2;
|
|
1248
|
+
const HandleContextMenu = 3;
|
|
1249
|
+
const HandleExtensionsInput = 4;
|
|
1250
|
+
const HandleFocus = 5;
|
|
1251
|
+
const HandlePointerDown = 7;
|
|
1252
|
+
const HandleScrollBarMove = 9;
|
|
1253
|
+
const HandleScrollBarPointerCaptureLost = 10;
|
|
1254
|
+
const HandleScrollBarPointerDown = 11;
|
|
1255
|
+
const HandleTouchEnd = 12;
|
|
1256
|
+
const HandleTouchMove = 13;
|
|
1257
|
+
const HandleTouchStart = 14;
|
|
1258
|
+
const HandleWheel = 15;
|
|
1259
|
+
const HandleHeaderContextMenu = 16;
|
|
1260
|
+
|
|
1261
|
+
const ClearAll = 'ClearAll';
|
|
1262
|
+
const Filter = 'Filter';
|
|
1263
|
+
const Refresh = 'Refresh';
|
|
1264
|
+
const Ellipsis = 'Ellipsis';
|
|
1265
|
+
|
|
1266
|
+
const getInputActions = hasValue => {
|
|
1267
|
+
const clearEnabled = hasValue;
|
|
1268
|
+
const actions = [{
|
|
1269
|
+
onClick: HandleClearSearchResults,
|
|
1270
|
+
icon: `MaskIcon${ClearAll}`,
|
|
1271
|
+
title: clearExtensionSearchResults(),
|
|
1272
|
+
type: Button,
|
|
1273
|
+
enabled: clearEnabled
|
|
1274
|
+
}, {
|
|
1275
|
+
icon: `MaskIcon${Filter}`,
|
|
1276
|
+
title: filter(),
|
|
1277
|
+
type: Button,
|
|
1278
|
+
onClick: HandleClickFilter,
|
|
1279
|
+
enabled: true
|
|
1280
|
+
}];
|
|
1281
|
+
return actions;
|
|
1282
|
+
};
|
|
1283
|
+
|
|
1244
1284
|
const getListHeight = (itemsLength, itemHeight, maxHeight) => {
|
|
1245
1285
|
number(itemsLength);
|
|
1246
1286
|
number(itemHeight);
|
|
@@ -1421,6 +1461,8 @@ const searchExtensions = async (extensions, value, platform, assetDir) => {
|
|
|
1421
1461
|
// TODO debounce
|
|
1422
1462
|
const handleInput = async (state, value, inputSource = User) => {
|
|
1423
1463
|
try {
|
|
1464
|
+
const hasValue = value.length > 0;
|
|
1465
|
+
const inputActions = getInputActions(hasValue);
|
|
1424
1466
|
const {
|
|
1425
1467
|
allExtensions,
|
|
1426
1468
|
itemHeight,
|
|
@@ -1447,7 +1489,8 @@ const handleInput = async (state, value, inputSource = User) => {
|
|
|
1447
1489
|
placeholder: searchExtensionsInMarketPlace(),
|
|
1448
1490
|
scrollBarHeight: 0,
|
|
1449
1491
|
searchValue: value,
|
|
1450
|
-
inputSource
|
|
1492
|
+
inputSource,
|
|
1493
|
+
inputActions
|
|
1451
1494
|
};
|
|
1452
1495
|
}
|
|
1453
1496
|
const total = items.length;
|
|
@@ -1471,7 +1514,8 @@ const handleInput = async (state, value, inputSource = User) => {
|
|
|
1471
1514
|
scrollBarHeight,
|
|
1472
1515
|
scrollBarY,
|
|
1473
1516
|
searchValue: value,
|
|
1474
|
-
inputSource
|
|
1517
|
+
inputSource,
|
|
1518
|
+
inputActions
|
|
1475
1519
|
};
|
|
1476
1520
|
|
|
1477
1521
|
// TODO handle out of order responses (a bit complicated)
|
|
@@ -2052,7 +2096,7 @@ const isEqual$2 = (oldState, newState) => {
|
|
|
2052
2096
|
};
|
|
2053
2097
|
|
|
2054
2098
|
const isEqual$1 = (oldState, newState) => {
|
|
2055
|
-
return oldState.items === newState.items && oldState.minLineY === newState.minLineY && oldState.maxLineY === newState.maxLineY && oldState.deltaY === newState.deltaY && oldState.focusedIndex === newState.focusedIndex && oldState.message === newState.message && oldState.inputActions === newState.inputActions && oldState.placeholder === newState.placeholder;
|
|
2099
|
+
return oldState.items === newState.items && oldState.minLineY === newState.minLineY && oldState.maxLineY === newState.maxLineY && oldState.deltaY === newState.deltaY && oldState.focusedIndex === newState.focusedIndex && oldState.message === newState.message && oldState.inputActions === newState.inputActions && oldState.placeholder === newState.placeholder && oldState.scrollBarHeight === newState.scrollBarHeight;
|
|
2056
2100
|
};
|
|
2057
2101
|
|
|
2058
2102
|
const isEqual = (oldState, newState) => {
|
|
@@ -2244,13 +2288,6 @@ const focusPreviousPage = state => {
|
|
|
2244
2288
|
return focusIndex(state, indexPreviousPage);
|
|
2245
2289
|
};
|
|
2246
2290
|
|
|
2247
|
-
const Button = 1;
|
|
2248
|
-
|
|
2249
|
-
const ClearAll = 'ClearAll';
|
|
2250
|
-
const Filter = 'Filter';
|
|
2251
|
-
const Refresh = 'Refresh';
|
|
2252
|
-
const Ellipsis = 'Ellipsis';
|
|
2253
|
-
|
|
2254
2291
|
const getActions = () => {
|
|
2255
2292
|
return [{
|
|
2256
2293
|
type: Button,
|
|
@@ -2345,12 +2382,12 @@ const getMenuEntries = () => {
|
|
|
2345
2382
|
id: 'copy',
|
|
2346
2383
|
label: copy(),
|
|
2347
2384
|
flags: None$1,
|
|
2348
|
-
command: '
|
|
2385
|
+
command: 'Extensions.copyExtensionInfo'
|
|
2349
2386
|
}, {
|
|
2350
2387
|
id: 'copyExtensionId',
|
|
2351
2388
|
label: copyExtensionId$1(),
|
|
2352
2389
|
flags: None$1,
|
|
2353
|
-
command: '
|
|
2390
|
+
command: 'Extensions.copyExtensionId'
|
|
2354
2391
|
}];
|
|
2355
2392
|
};
|
|
2356
2393
|
|
|
@@ -2473,6 +2510,10 @@ const handleFocus = async state => {
|
|
|
2473
2510
|
};
|
|
2474
2511
|
};
|
|
2475
2512
|
|
|
2513
|
+
const handleHeaderContextMenu = async state => {
|
|
2514
|
+
return state;
|
|
2515
|
+
};
|
|
2516
|
+
|
|
2476
2517
|
// TODO show error / warning when installment fails / times out
|
|
2477
2518
|
const handleInstall = async (state, id) => {
|
|
2478
2519
|
return state;
|
|
@@ -2535,8 +2576,8 @@ const setDeltaY = (state, value) => {
|
|
|
2535
2576
|
}
|
|
2536
2577
|
// TODO when it only moves by one px, extensions don't need to be rerendered, only negative margin
|
|
2537
2578
|
const minLineY = Math.floor(newDeltaY / itemHeight);
|
|
2538
|
-
const maxLineY = minLineY + getNumberOfVisibleItems$1(listHeight, itemHeight);
|
|
2539
2579
|
const total = items.length;
|
|
2580
|
+
const maxLineY = Math.min(minLineY + getNumberOfVisibleItems$1(listHeight, itemHeight), total);
|
|
2540
2581
|
const contentHeight = total * itemHeight;
|
|
2541
2582
|
const scrollBarHeight = getScrollBarSize(listHeight, contentHeight, minimumSliderSize);
|
|
2542
2583
|
const scrollBarY = getScrollBarY$1(newDeltaY, finalDeltaY, height - headerHeight, scrollBarHeight);
|
|
@@ -2667,41 +2708,6 @@ const getAllExtensions = platform => {
|
|
|
2667
2708
|
return getAllExtensions$1(platform);
|
|
2668
2709
|
};
|
|
2669
2710
|
|
|
2670
|
-
const HandleClearSearchResults = 1;
|
|
2671
|
-
const HandleClickFilter = 2;
|
|
2672
|
-
const HandleContextMenu = 3;
|
|
2673
|
-
const HandleExtensionsInput = 4;
|
|
2674
|
-
const HandleFocus = 5;
|
|
2675
|
-
const HandlePointerDown = 7;
|
|
2676
|
-
const HandleScrollBarMove = 9;
|
|
2677
|
-
const HandleScrollBarPointerCaptureLost = 10;
|
|
2678
|
-
const HandleScrollBarPointerDown = 11;
|
|
2679
|
-
const HandleTouchEnd = 12;
|
|
2680
|
-
const HandleTouchMove = 13;
|
|
2681
|
-
const HandleTouchStart = 14;
|
|
2682
|
-
const HandleWheel = 15;
|
|
2683
|
-
|
|
2684
|
-
const getInputActions = newState => {
|
|
2685
|
-
const {
|
|
2686
|
-
searchValue
|
|
2687
|
-
} = newState;
|
|
2688
|
-
const clearEnabled = searchValue.length > 0;
|
|
2689
|
-
const actions = [{
|
|
2690
|
-
onClick: HandleClearSearchResults,
|
|
2691
|
-
icon: `MaskIcon${ClearAll}`,
|
|
2692
|
-
title: clearExtensionSearchResults(),
|
|
2693
|
-
type: Button,
|
|
2694
|
-
enabled: clearEnabled
|
|
2695
|
-
}, {
|
|
2696
|
-
icon: `MaskIcon${Filter}`,
|
|
2697
|
-
title: filter(),
|
|
2698
|
-
type: Button,
|
|
2699
|
-
onClick: HandleClickFilter,
|
|
2700
|
-
enabled: true
|
|
2701
|
-
}];
|
|
2702
|
-
return actions;
|
|
2703
|
-
};
|
|
2704
|
-
|
|
2705
2711
|
const Small = 1;
|
|
2706
2712
|
const Normal = 2;
|
|
2707
2713
|
const Large = 3;
|
|
@@ -2866,13 +2872,11 @@ const loadContent = async (state, savedState) => {
|
|
|
2866
2872
|
const allExtensions = await getAllExtensions(platform);
|
|
2867
2873
|
const size = getViewletSize(width);
|
|
2868
2874
|
const normalized = normalizeExtension(allExtensions, platform, assetDir);
|
|
2869
|
-
const inputActions = getInputActions(state);
|
|
2870
2875
|
const updatedState = await handleInput({
|
|
2871
2876
|
...state,
|
|
2872
2877
|
allExtensions: normalized,
|
|
2873
2878
|
size,
|
|
2874
2879
|
inputSource: Script,
|
|
2875
|
-
inputActions,
|
|
2876
2880
|
deltaY
|
|
2877
2881
|
}, searchValue, Script);
|
|
2878
2882
|
return updatedState;
|
|
@@ -2944,7 +2948,7 @@ const SearchField = 'SearchField';
|
|
|
2944
2948
|
const SearchFieldButton = 'SearchFieldButton';
|
|
2945
2949
|
const SearchFieldButtons = 'SearchFieldButtons';
|
|
2946
2950
|
const SearchFieldContainer = 'SearchFieldContainer';
|
|
2947
|
-
const
|
|
2951
|
+
const SearchFieldButtonDisabled = 'SearchFieldButtonDisabled';
|
|
2948
2952
|
const Viewlet = 'Viewlet';
|
|
2949
2953
|
|
|
2950
2954
|
const List = 'list';
|
|
@@ -2952,7 +2956,7 @@ const ListItem = 'listitem';
|
|
|
2952
2956
|
const None = 'none';
|
|
2953
2957
|
const ToolBar = 'toolbar';
|
|
2954
2958
|
|
|
2955
|
-
const disabledClassName = mergeClassNames(SearchFieldButton,
|
|
2959
|
+
const disabledClassName = mergeClassNames(SearchFieldButton, SearchFieldButtonDisabled);
|
|
2956
2960
|
const getClassName$1 = enabled => {
|
|
2957
2961
|
if (enabled) {
|
|
2958
2962
|
return SearchFieldButton;
|
|
@@ -3020,14 +3024,15 @@ const getSearchFieldVirtualDom = (name, placeholder, onInput, insideButtons, out
|
|
|
3020
3024
|
const parentNode = {
|
|
3021
3025
|
type: Div,
|
|
3022
3026
|
className: ExtensionHeader,
|
|
3023
|
-
childCount: 1
|
|
3027
|
+
childCount: 1,
|
|
3028
|
+
onContextMenu: HandleHeaderContextMenu
|
|
3024
3029
|
};
|
|
3025
3030
|
const getExtensionHeaderVirtualDom = (placeholder, actions) => {
|
|
3026
|
-
return [parentNode, ...getSearchFieldVirtualDom(
|
|
3031
|
+
return [parentNode, ...getSearchFieldVirtualDom(Extensions$1, placeholder, HandleExtensionsInput, actions, [])];
|
|
3027
3032
|
};
|
|
3028
3033
|
|
|
3029
3034
|
const renderHeader = newState => {
|
|
3030
|
-
const actions = getInputActions(newState);
|
|
3035
|
+
const actions = getInputActions(newState.searchValue.length > 0);
|
|
3031
3036
|
const dom = getExtensionHeaderVirtualDom(newState.placeholder, actions);
|
|
3032
3037
|
return ['setHeaderDom', dom];
|
|
3033
3038
|
};
|
|
@@ -3365,6 +3370,10 @@ const renderEventListeners = () => {
|
|
|
3365
3370
|
name: HandleContextMenu,
|
|
3366
3371
|
params: ['handleContextMenu', Button$1, ClientX, ClientY],
|
|
3367
3372
|
preventDefault: true
|
|
3373
|
+
}, {
|
|
3374
|
+
name: HandleHeaderContextMenu,
|
|
3375
|
+
params: ['handleHeaderContextMenu'],
|
|
3376
|
+
preventDefault: true
|
|
3368
3377
|
}, {
|
|
3369
3378
|
name: HandlePointerDown,
|
|
3370
3379
|
params: ['handleClickAt', Button$1, ClientX, ClientY],
|
|
@@ -3399,6 +3408,40 @@ const renderEventListeners = () => {
|
|
|
3399
3408
|
}];
|
|
3400
3409
|
};
|
|
3401
3410
|
|
|
3411
|
+
const resize = async (state, dimensions) => {
|
|
3412
|
+
const {
|
|
3413
|
+
items,
|
|
3414
|
+
itemHeight,
|
|
3415
|
+
headerHeight,
|
|
3416
|
+
minimumSliderSize
|
|
3417
|
+
} = state;
|
|
3418
|
+
const {
|
|
3419
|
+
x,
|
|
3420
|
+
y,
|
|
3421
|
+
width,
|
|
3422
|
+
height
|
|
3423
|
+
} = dimensions;
|
|
3424
|
+
const total = items.length;
|
|
3425
|
+
const listHeight = getListHeight(total, itemHeight, height);
|
|
3426
|
+
const contentHeight = total * itemHeight;
|
|
3427
|
+
const scrollBarHeight = getScrollBarSize(height, contentHeight, minimumSliderSize);
|
|
3428
|
+
const numberOfVisible = getNumberOfVisibleItems$1(listHeight, itemHeight);
|
|
3429
|
+
const maxLineY = Math.min(numberOfVisible, total);
|
|
3430
|
+
const finalDeltaY = getFinalDeltaY(listHeight, itemHeight, total);
|
|
3431
|
+
const scrollBarY = getScrollBarY$1(0, finalDeltaY, height - headerHeight, scrollBarHeight);
|
|
3432
|
+
return {
|
|
3433
|
+
...state,
|
|
3434
|
+
finalDeltaY,
|
|
3435
|
+
height,
|
|
3436
|
+
maxLineY,
|
|
3437
|
+
scrollBarHeight,
|
|
3438
|
+
scrollBarY,
|
|
3439
|
+
width,
|
|
3440
|
+
x,
|
|
3441
|
+
y
|
|
3442
|
+
};
|
|
3443
|
+
};
|
|
3444
|
+
|
|
3402
3445
|
const saveState = state => {
|
|
3403
3446
|
const {
|
|
3404
3447
|
searchValue,
|
|
@@ -3442,6 +3485,7 @@ const commandMap = {
|
|
|
3442
3485
|
'SearchExtensions.focusIndex': wrapCommand(focusIndex),
|
|
3443
3486
|
'SearchExtensions.focusLast': wrapCommand(focusLast),
|
|
3444
3487
|
'SearchExtensions.focusNext': wrapCommand(focusNext),
|
|
3488
|
+
'SearchExtensions.handleHeaderContextMenu': wrapCommand(handleHeaderContextMenu),
|
|
3445
3489
|
'SearchExtensions.focusNextPage': wrapCommand(focusNextPage),
|
|
3446
3490
|
'SearchExtensions.focusPrevious': wrapCommand(focusPrevious),
|
|
3447
3491
|
'SearchExtensions.focusPreviousPage': wrapCommand(focusPreviousPage),
|
|
@@ -3479,7 +3523,8 @@ const commandMap = {
|
|
|
3479
3523
|
'SearchExtensions.selectIndex': wrapCommand(selectIndex),
|
|
3480
3524
|
'SearchExtensions.setDeltaY': wrapCommand(setDeltaY),
|
|
3481
3525
|
'SearchExtensions.terminate': terminate,
|
|
3482
|
-
'SearchExtensions.toggleSuggest': wrapCommand(toggleSuggest)
|
|
3526
|
+
'SearchExtensions.toggleSuggest': wrapCommand(toggleSuggest),
|
|
3527
|
+
'SearchExtensions.resize': wrapCommand(resize)
|
|
3483
3528
|
};
|
|
3484
3529
|
|
|
3485
3530
|
const listen = async () => {
|