@lvce-editor/extension-search-view 4.11.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)
@@ -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,
@@ -2671,42 +2708,6 @@ const getAllExtensions = platform => {
2671
2708
  return getAllExtensions$1(platform);
2672
2709
  };
2673
2710
 
2674
- const HandleClearSearchResults = 1;
2675
- const HandleClickFilter = 2;
2676
- const HandleContextMenu = 3;
2677
- const HandleExtensionsInput = 4;
2678
- const HandleFocus = 5;
2679
- const HandlePointerDown = 7;
2680
- const HandleScrollBarMove = 9;
2681
- const HandleScrollBarPointerCaptureLost = 10;
2682
- const HandleScrollBarPointerDown = 11;
2683
- const HandleTouchEnd = 12;
2684
- const HandleTouchMove = 13;
2685
- const HandleTouchStart = 14;
2686
- const HandleWheel = 15;
2687
- const HandleHeaderContextMenu = 16;
2688
-
2689
- const getInputActions = newState => {
2690
- const {
2691
- searchValue
2692
- } = newState;
2693
- const clearEnabled = searchValue.length > 0;
2694
- const actions = [{
2695
- onClick: HandleClearSearchResults,
2696
- icon: `MaskIcon${ClearAll}`,
2697
- title: clearExtensionSearchResults(),
2698
- type: Button,
2699
- enabled: clearEnabled
2700
- }, {
2701
- icon: `MaskIcon${Filter}`,
2702
- title: filter(),
2703
- type: Button,
2704
- onClick: HandleClickFilter,
2705
- enabled: true
2706
- }];
2707
- return actions;
2708
- };
2709
-
2710
2711
  const Small = 1;
2711
2712
  const Normal = 2;
2712
2713
  const Large = 3;
@@ -2871,13 +2872,11 @@ const loadContent = async (state, savedState) => {
2871
2872
  const allExtensions = await getAllExtensions(platform);
2872
2873
  const size = getViewletSize(width);
2873
2874
  const normalized = normalizeExtension(allExtensions, platform, assetDir);
2874
- const inputActions = getInputActions(state);
2875
2875
  const updatedState = await handleInput({
2876
2876
  ...state,
2877
2877
  allExtensions: normalized,
2878
2878
  size,
2879
2879
  inputSource: Script,
2880
- inputActions,
2881
2880
  deltaY
2882
2881
  }, searchValue, Script);
2883
2882
  return updatedState;
@@ -3033,7 +3032,7 @@ const getExtensionHeaderVirtualDom = (placeholder, actions) => {
3033
3032
  };
3034
3033
 
3035
3034
  const renderHeader = newState => {
3036
- const actions = getInputActions(newState);
3035
+ const actions = getInputActions(newState.searchValue.length > 0);
3037
3036
  const dom = getExtensionHeaderVirtualDom(newState.placeholder, actions);
3038
3037
  return ['setHeaderDom', dom];
3039
3038
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/extension-search-view",
3
- "version": "4.11.0",
3
+ "version": "4.12.0",
4
4
  "description": "Extension Search View Worker",
5
5
  "repository": {
6
6
  "type": "git",