@lvce-editor/explorer-view 3.26.0 → 4.0.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.
@@ -2730,9 +2730,9 @@ const text = data => {
2730
2730
  };
2731
2731
  };
2732
2732
 
2733
- const getTreeItemClassName = (isSelected, isFocused, isDropping, useChevrons, depth) => {
2733
+ const getTreeItemClassName = (isSelected, isFocused, isDropping, useChevrons, indent) => {
2734
2734
  let className = TreeItem$1;
2735
- className = mergeClassNames(className, `Indent-${depth}`);
2735
+ className = mergeClassNames(className, `Indent-${indent}`);
2736
2736
  if (isSelected || isFocused) {
2737
2737
  className = mergeClassNames(className, TreeItemActive);
2738
2738
  }
@@ -2742,9 +2742,9 @@ const getTreeItemClassName = (isSelected, isFocused, isDropping, useChevrons, de
2742
2742
  return className;
2743
2743
  };
2744
2744
 
2745
- const defaultIndent$1 = 1;
2745
+ const defaultIndent$1 = 12;
2746
2746
  const getTreeItemIndent = depth => {
2747
- return `${depth * defaultIndent$1}rem`;
2747
+ return depth * defaultIndent$1;
2748
2748
  };
2749
2749
 
2750
2750
  // TODO make all of these variable configurable
@@ -2756,7 +2756,7 @@ const chevronSize = 22;
2756
2756
  const getTreeItemIndentWithChevron = (depth, chevron) => {
2757
2757
  // TODO use numeric value here, convert to string value in renderer process
2758
2758
  const extraSpace = chevron ? 0 : chevronSize;
2759
- return `${depth * defaultIndent + extraSpace + defaultPaddingLeft}px`;
2759
+ return depth * defaultIndent + extraSpace + defaultPaddingLeft;
2760
2760
  };
2761
2761
 
2762
2762
  const ariaExpandedValues = [undefined, 'true', 'false'];
@@ -2783,7 +2783,8 @@ const getVisibleExplorerItems = (items, minLineY, maxLineY, focusedIndex, editin
2783
2783
  const isCut = cutItems.includes(item.path);
2784
2784
  const isDropping = dropTargets.includes(i);
2785
2785
  const isIgnored = sourceControlIgnoredUris.includes(item.path);
2786
- const className = getTreeItemClassName(isSelected, isFocused, isDropping, useChevrons, item.depth); // TODO compute classname in dom function
2786
+ const indent = indentFn(item.depth, chevron);
2787
+ const className = getTreeItemClassName(isSelected, isFocused, isDropping, useChevrons, indent);
2787
2788
  const expanded = getExpandedType(item.type);
2788
2789
  const ariaExpanded = ariaExpandedValues[expanded];
2789
2790
  const isEditing = i === editingIndex;
@@ -2792,7 +2793,6 @@ const getVisibleExplorerItems = (items, minLineY, maxLineY, focusedIndex, editin
2792
2793
  icon = editingIcon;
2793
2794
  chevron = getEditingChevron(item.type);
2794
2795
  }
2795
- const indent = indentFn(item.depth, chevron);
2796
2796
  visible.push({
2797
2797
  ...item,
2798
2798
  posInSet: item.posInSet ?? i + 1,
@@ -2846,7 +2846,7 @@ const wrapListItemCommand = fn => {
2846
2846
  const intermediate = get(id);
2847
2847
  set$1(id, intermediate.oldState, updatedState);
2848
2848
  const maxLineY = getExplorerMaxLineY(minLineY, height, itemHeight, items.length);
2849
- if (items === intermediate.newState.items && minLineY === intermediate.newState.minLineY && editingIcon === intermediate.newState.editingIcon && cutItems === intermediate.newState.cutItems && editingErrorMessage === intermediate.newState.editingErrorMessage) {
2849
+ if (items === intermediate.newState.items && minLineY === intermediate.newState.minLineY && editingIcon === intermediate.newState.editingIcon && cutItems === intermediate.newState.cutItems && editingErrorMessage === intermediate.newState.editingErrorMessage && dropTargets === intermediate.newState.dropTargets) {
2850
2850
  return;
2851
2851
  }
2852
2852
  const visible = items.slice(minLineY, maxLineY);
@@ -2986,7 +2986,10 @@ const create = (id, uri, x, y, width, height, args, parentUid, platform = 0) =>
2986
2986
  };
2987
2987
 
2988
2988
  const isEqual$6 = (oldState, newState) => {
2989
- return oldState.scrollBarHeight === newState.scrollBarHeight && oldState.scrollBarActive === newState.scrollBarActive && oldState.maxIndent === newState.maxIndent;
2989
+ // TODO compute css more optimized
2990
+ // maybe only when items change, and even then not
2991
+ // always, but only when it affects the css
2992
+ return oldState.scrollBarHeight === newState.scrollBarHeight && oldState.scrollBarActive === newState.scrollBarActive && oldState.maxIndent === newState.maxIndent && oldState.visibleExplorerItems === newState.visibleExplorerItems;
2990
2993
  };
2991
2994
 
2992
2995
  const isEqual$5 = (oldState, newState) => {
@@ -3116,8 +3119,9 @@ const getChildDirentsRecursively = async (dirent, pathSeparator) => {
3116
3119
 
3117
3120
  const getParentEndIndex = (dirents, index) => {
3118
3121
  const dirent = dirents[index];
3122
+ const depth = dirent.depth;
3119
3123
  let endIndex = index + 1;
3120
- while (endIndex < dirents.length && dirents[endIndex].depth > dirent.depth) {
3124
+ while (endIndex < dirents.length && dirents[endIndex].depth > depth) {
3121
3125
  endIndex++;
3122
3126
  }
3123
3127
  return endIndex;
@@ -4078,7 +4082,7 @@ const canBeDroppedInto = dirent => {
4078
4082
 
4079
4083
  const countInRange = (start, end) => {
4080
4084
  const items = [];
4081
- for (let i = start; i < end; i++) {
4085
+ for (let i = start; i <= end; i++) {
4082
4086
  items.push(i);
4083
4087
  }
4084
4088
  return items;
@@ -5416,22 +5420,39 @@ const renameDirent = async state => {
5416
5420
  };
5417
5421
  };
5418
5422
 
5419
- const renderCss = (oldState, newState) => {
5420
- const {
5421
- scrollBarHeight,
5422
- uid,
5423
- maxIndent
5424
- } = newState;
5423
+ const getCss = (scrollBarHeight, uniqueIndents) => {
5424
+ // TODO each visible item should have an indent property
5425
5425
  const rules = [`.Explorer {
5426
5426
  --ScrollBarThumbHeight: ${scrollBarHeight}px;
5427
- `];
5428
- for (let i = 0; i < maxIndent; i++) {
5429
- const indent = getTreeItemIndent(i);
5430
- rules.push(`.Indent-${i} {
5431
- padding-left: ${indent};
5427
+ }`];
5428
+ for (const item of uniqueIndents) {
5429
+ rules.push(`.Indent-${item} {
5430
+ padding-left: ${item}px;
5432
5431
  }`);
5433
5432
  }
5434
5433
  const css = rules.join('\n');
5434
+ return css;
5435
+ };
5436
+
5437
+ const getUnique = items => {
5438
+ const seens = [];
5439
+ for (const item of items) {
5440
+ if (!seens.includes(item)) {
5441
+ seens.push(item);
5442
+ }
5443
+ }
5444
+ return seens;
5445
+ };
5446
+
5447
+ const renderCss = (oldState, newState) => {
5448
+ const {
5449
+ scrollBarHeight,
5450
+ uid,
5451
+ visibleExplorerItems
5452
+ } = newState;
5453
+ const indents = visibleExplorerItems.map(item => item.indent);
5454
+ const uniqueIndents = getUnique(indents);
5455
+ const css = getCss(scrollBarHeight, uniqueIndents);
5435
5456
  return [SetCss, uid, css];
5436
5457
  };
5437
5458
 
@@ -5665,7 +5686,6 @@ const getExplorerItemVirtualDom = item => {
5665
5686
  hasEditingError,
5666
5687
  icon,
5667
5688
  id,
5668
- indent,
5669
5689
  isEditing,
5670
5690
  name,
5671
5691
  path,
@@ -5686,7 +5706,6 @@ const getExplorerItemVirtualDom = item => {
5686
5706
  ariaSetSize: setSize,
5687
5707
  ariaLevel: depth,
5688
5708
  childCount: 2 + chevronDom.length,
5689
- paddingLeft: indent,
5690
5709
  ariaLabel: name,
5691
5710
  ariaExpanded,
5692
5711
  ariaDescription: '',
@@ -6312,8 +6331,6 @@ const commandMap = {
6312
6331
  'Explorer.focusFirst': wrapListItemCommand(focusFirst),
6313
6332
  'Explorer.focusIndex': wrapListItemCommand(focusIndex),
6314
6333
  'Explorer.focusLast': wrapListItemCommand(focusLast),
6315
- 'Explorer.handleDragStart': wrapListItemCommand(handleDragStart),
6316
- 'Explorer.handleDragOverIndex': wrapListItemCommand(handleDragOverIndex),
6317
6334
  'Explorer.focusNext': wrapListItemCommand(focusNext),
6318
6335
  'Explorer.focusNone': wrapListItemCommand(focusNone),
6319
6336
  'Explorer.focusPrevious': wrapListItemCommand(focusPrevious),
@@ -6322,7 +6339,6 @@ const commandMap = {
6322
6339
  'Explorer.getMouseActions': getMouseActions,
6323
6340
  'Explorer.handleArrowLeft': wrapListItemCommand(handleArrowLeft),
6324
6341
  'Explorer.handleArrowRight': wrapListItemCommand(handleArrowRight),
6325
- 'Explorer.handleEscape': wrapListItemCommand(handleEscape),
6326
6342
  'Explorer.handleBlur': wrapListItemCommand(handleBlur),
6327
6343
  'Explorer.handleClick': wrapListItemCommand(handleClick),
6328
6344
  'Explorer.handleClickAt': wrapListItemCommand(handleClickAt),
@@ -6335,7 +6351,10 @@ const commandMap = {
6335
6351
  'Explorer.handleCut': wrapListItemCommand(handleCut),
6336
6352
  'Explorer.handleDragLeave': wrapListItemCommand(handleDragLeave),
6337
6353
  'Explorer.handleDragOver': wrapListItemCommand(handleDragOver),
6354
+ 'Explorer.handleDragOverIndex': wrapListItemCommand(handleDragOverIndex),
6355
+ 'Explorer.handleDragStart': wrapListItemCommand(handleDragStart),
6338
6356
  'Explorer.handleDrop': wrapListItemCommand(handleDrop),
6357
+ 'Explorer.handleEscape': wrapListItemCommand(handleEscape),
6339
6358
  'Explorer.handleFocus': wrapListItemCommand(handleFocus),
6340
6359
  'Explorer.handleIconThemeChange': wrapListItemCommand(handleIconThemeChange),
6341
6360
  'Explorer.handleInputBlur': wrapListItemCommand(handleInputBlur),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/explorer-view",
3
- "version": "3.26.0",
3
+ "version": "4.0.0",
4
4
  "description": "Explorer Worker",
5
5
  "repository": {
6
6
  "type": "git",