@lvce-editor/text-search-worker 3.27.0 → 3.28.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.
@@ -1653,7 +1653,7 @@ const focusSearchValueNext = state => {
1653
1653
  };
1654
1654
 
1655
1655
  const CheckBox = 'checkbox';
1656
- const None = 'none';
1656
+ const None$1 = 'none';
1657
1657
  const Status = 'status';
1658
1658
  const Tree = 'tree';
1659
1659
  const TreeItem$1 = 'treeitem';
@@ -1732,7 +1732,7 @@ const getIconVirtualDom = (icon, type = Div) => {
1732
1732
  return {
1733
1733
  type,
1734
1734
  className: mergeClassNames(MaskIcon, `MaskIcon${icon}`),
1735
- role: None,
1735
+ role: None$1,
1736
1736
  childCount: 0
1737
1737
  };
1738
1738
  };
@@ -1880,6 +1880,10 @@ const getActions = () => {
1880
1880
  }];
1881
1881
  };
1882
1882
 
1883
+ const None = 0;
1884
+ const Collapsed = 1;
1885
+ const Expanded = 2;
1886
+
1883
1887
  // TODO this should be in FileSystem module
1884
1888
  const pathBaseName = path => {
1885
1889
  return path.slice(path.lastIndexOf('/') + 1);
@@ -1908,7 +1912,6 @@ const getDisplayResult = (result, fileIcons, fileIconIndex, itemHeight, i, setSi
1908
1912
  const baseName = pathBaseName(path);
1909
1913
  return {
1910
1914
  title: absolutePath,
1911
- type: File,
1912
1915
  text: baseName,
1913
1916
  icon: fileIcons[fileIconIndex],
1914
1917
  posInSet,
@@ -1921,12 +1924,11 @@ const getDisplayResult = (result, fileIcons, fileIconIndex, itemHeight, i, setSi
1921
1924
  depth: 0,
1922
1925
  matchCount: 0,
1923
1926
  focused,
1924
- expanded: !collapsedPaths.includes(path)
1927
+ expanded: collapsedPaths.includes(path) ? Collapsed : Expanded
1925
1928
  };
1926
1929
  case Match:
1927
1930
  return {
1928
1931
  title: text,
1929
- type: Match,
1930
1932
  text: text,
1931
1933
  icon: '',
1932
1934
  posInSet,
@@ -1939,7 +1941,7 @@ const getDisplayResult = (result, fileIcons, fileIconIndex, itemHeight, i, setSi
1939
1941
  depth: 1,
1940
1942
  matchCount: 0,
1941
1943
  focused,
1942
- expanded: false
1944
+ expanded: None
1943
1945
  };
1944
1946
  default:
1945
1947
  throw new Error('unexpected search result type');
@@ -2098,7 +2100,7 @@ const getOutSideButtonsDom = outsideButtons => {
2098
2100
  preNodes: [{
2099
2101
  type: Div,
2100
2102
  className: SearchFieldContainer,
2101
- role: None,
2103
+ role: None$1,
2102
2104
  childCount: 1 + outsideButtons.length
2103
2105
  }],
2104
2106
  postNodes: outsideButtons.flatMap(getSearchFieldButtonVirtualDom)
@@ -2114,7 +2116,7 @@ const getSearchFieldVirtualDom = (name, placeholder, onInput, insideButtons, out
2114
2116
  const dom = [...preNodes, {
2115
2117
  type: Div,
2116
2118
  className: searchFieldClassName,
2117
- role: None,
2119
+ role: None$1,
2118
2120
  childCount: 2
2119
2121
  }, {
2120
2122
  type: TextArea,
@@ -2230,12 +2232,12 @@ const getSearchHeaderTopVirtualDom = (flags, searchInputErrorMessage = '') => {
2230
2232
  const dom = [{
2231
2233
  type: Div,
2232
2234
  className: SearchHeaderTop,
2233
- role: None,
2235
+ role: None$1,
2234
2236
  childCount: 2
2235
2237
  }, ...getSearchToggleVirtualDom(flags), {
2236
2238
  type: Div,
2237
2239
  className: SearchHeaderTopRight,
2238
- role: None,
2240
+ role: None$1,
2239
2241
  childCount: flags & ReplaceExpanded ? 2 : 1
2240
2242
  }, ...getSearchFieldVirtualDom(SearchValue, 'Search', HandleInput, inputActions.inside, inputActions.outside, '', Boolean(searchInputErrorMessage))];
2241
2243
  if (flags & ReplaceExpanded) {
@@ -2248,7 +2250,7 @@ const getSearchHeaderVirtualDom = (flags, message, searchInputErrorMessage) => {
2248
2250
  const dom = [{
2249
2251
  type: Div,
2250
2252
  className: SearchHeader,
2251
- role: None,
2253
+ role: None$1,
2252
2254
  childCount: 2,
2253
2255
  onClick: HandleHeaderClick,
2254
2256
  onFocusIn: HandleHeaderFocusIn
@@ -2292,7 +2294,7 @@ const getFileIconVirtualDom = icon => {
2292
2294
  type: Img,
2293
2295
  className: FileIcon,
2294
2296
  src: icon,
2295
- role: None,
2297
+ role: None$1,
2296
2298
  childCount: 0
2297
2299
  };
2298
2300
  };
@@ -2340,9 +2342,30 @@ const getLabelVirtualDom = (displayText, matchLength, matchStart, replacement) =
2340
2342
 
2341
2343
  const PaddingRight = '12px';
2342
2344
 
2345
+ const getPaddingLeft = depth => {
2346
+ return `${Number(depth) + 1}rem`; // TODO use classname and dynamic css
2347
+ };
2348
+ const getClassName = focused => {
2349
+ if (focused) {
2350
+ return TreeItem + ' ' + TreeItemActive;
2351
+ }
2352
+ return TreeItem;
2353
+ };
2354
+
2355
+ // TODO instead of setting string, support enum in virtual dom and send enum to renderer process
2356
+ // which converts it to a boolean
2357
+ const getAriaExpanded = expanded => {
2358
+ switch (expanded) {
2359
+ case Collapsed:
2360
+ return 'false';
2361
+ case Expanded:
2362
+ return 'true';
2363
+ default:
2364
+ return undefined;
2365
+ }
2366
+ };
2343
2367
  const getSearchResultVirtualDom = rowInfo => {
2344
2368
  const {
2345
- type,
2346
2369
  matchStart,
2347
2370
  matchLength,
2348
2371
  text: displayText,
@@ -2359,7 +2382,7 @@ const getSearchResultVirtualDom = rowInfo => {
2359
2382
  const treeItem = {
2360
2383
  type: Div,
2361
2384
  role: TreeItem$1,
2362
- className: TreeItem,
2385
+ className: getClassName(focused),
2363
2386
  title,
2364
2387
  ariaSetSize: setSize,
2365
2388
  ariaLevel: depth,
@@ -2367,27 +2390,20 @@ const getSearchResultVirtualDom = rowInfo => {
2367
2390
  ariaLabel: title,
2368
2391
  ariaDescription: '',
2369
2392
  childCount: 1,
2370
- paddingLeft: `${Number(depth) + 1}rem`,
2371
- // TODO use classname and dynamic css
2372
- paddingRight: PaddingRight
2393
+ paddingLeft: getPaddingLeft(depth),
2394
+ paddingRight: PaddingRight,
2395
+ ariaExpanded: getAriaExpanded(expanded)
2373
2396
  };
2374
- if (focused) {
2375
- treeItem.className += ' ' + TreeItemActive;
2376
- }
2377
- switch (type) {
2378
- case File:
2379
- treeItem.ariaExpanded = `${expanded}`;
2380
- break;
2381
- }
2382
2397
  const dom = [];
2383
2398
  dom.push(treeItem);
2384
- if (type === File) {
2399
+ if (expanded === Expanded) {
2400
+ // TODO move childcount computation to getDisplaySearchresults
2401
+ // TODO add chevronIcon and fileIcon properties to getDisplaySearchResults
2385
2402
  treeItem.childCount += 2;
2386
- if (expanded) {
2387
- dom.push(chevronDownVirtualDom, getFileIconVirtualDom(icon));
2388
- } else {
2389
- dom.push(chevronRightVirtualDom, getFileIconVirtualDom(icon));
2390
- }
2403
+ dom.push(chevronDownVirtualDom, getFileIconVirtualDom(icon));
2404
+ } else if (expanded === Collapsed) {
2405
+ treeItem.childCount += 2;
2406
+ dom.push(chevronRightVirtualDom, getFileIconVirtualDom(icon));
2391
2407
  }
2392
2408
  dom.push(...getLabelVirtualDom(displayText, matchLength, matchStart, replacement));
2393
2409
  if (matchCount) {
@@ -3271,7 +3287,7 @@ const getFilteredResults = (results, collapsedPaths) => {
3271
3287
  isExcluded = false;
3272
3288
  }
3273
3289
  }
3274
- if (!isExcluded) {
3290
+ if (result.type === Match && !isExcluded) {
3275
3291
  filteredResults.push(result);
3276
3292
  }
3277
3293
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/text-search-worker",
3
- "version": "3.27.0",
3
+ "version": "3.28.0",
4
4
  "description": "Text Search Worker",
5
5
  "main": "dist/textSearchWorkerMain.js",
6
6
  "type": "module",