@lvce-editor/explorer-view 4.12.0 → 5.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.
@@ -2610,7 +2610,8 @@ const create = (id, uri, x, y, width, height, args, parentUid, platform = 0) =>
2610
2610
  maxIndent: 0,
2611
2611
  errorMessageLeft: 0,
2612
2612
  errorMessageTop: 0,
2613
- visibleExplorerItems: []
2613
+ visibleExplorerItems: [],
2614
+ errorMessageWidth: 0
2614
2615
  };
2615
2616
  set(state.uid, state, state);
2616
2617
  return state;
@@ -2625,7 +2626,7 @@ const isEqual$6 = (oldState, newState) => {
2625
2626
  // TODO compute css more optimized
2626
2627
  // maybe only when items change, and even then not
2627
2628
  // always, but only when it affects the css
2628
- return oldState.errorMessageLeft === newState.errorMessageLeft && oldState.errorMessageTop === newState.errorMessageTop && oldState.maxIndent === newState.maxIndent && oldState.scrollBarActive === newState.scrollBarActive && oldState.scrollBarHeight === newState.scrollBarHeight && oldState.visibleExplorerItems === newState.visibleExplorerItems;
2629
+ return oldState.errorMessageLeft === newState.errorMessageLeft && oldState.errorMessageTop === newState.errorMessageTop && oldState.maxIndent === newState.maxIndent && oldState.scrollBarActive === newState.scrollBarActive && oldState.scrollBarHeight === newState.scrollBarHeight && oldState.visibleExplorerItems === newState.visibleExplorerItems && oldState.editingErrorMessage === newState.editingErrorMessage;
2629
2630
  };
2630
2631
 
2631
2632
  const isEqual$5 = (oldState, newState) => {
@@ -4962,6 +4963,10 @@ const confirmDelete = async paths => {
4962
4963
  return result === true;
4963
4964
  };
4964
4965
 
4966
+ const showErrorAlert = async errorMessage => {
4967
+ await confirm(errorMessage);
4968
+ };
4969
+
4965
4970
  const removeDirent = async state => {
4966
4971
  const {
4967
4972
  items,
@@ -4988,7 +4993,7 @@ const removeDirent = async state => {
4988
4993
  // TODO use bulk edit and explorer refresh
4989
4994
  const errorMessage = await applyFileOperations(fileOperations);
4990
4995
  if (errorMessage) {
4991
- await confirm(errorMessage);
4996
+ await showErrorAlert(errorMessage);
4992
4997
  return state;
4993
4998
  }
4994
4999
  const newState = await refresh(state);
@@ -5070,16 +5075,28 @@ const getIndentRule = indent => {
5070
5075
  padding-left: ${indent}px;
5071
5076
  }`;
5072
5077
  };
5073
- const getCss = (scrollBarHeight, uniqueIndents, errorMessageLeft, errorMessageTop) => {
5078
+ const getCss = (scrollBarHeight, uniqueIndents, errorMessageLeft, errorMessageTop, errorMessageWidth) => {
5074
5079
  const rules = [`.Explorer {
5075
5080
  --ScrollBarThumbHeight: ${scrollBarHeight}px;
5076
5081
  --ErrorMessageTop: ${errorMessageTop}px;
5077
5082
  --ErrorMessageLeft: ${errorMessageLeft}px;
5083
+ --ErrorMessageWidth: ${errorMessageWidth}px;
5078
5084
  }`, ...uniqueIndents.map(getIndentRule)];
5079
5085
  const css = rules.join('\n');
5080
5086
  return css;
5081
5087
  };
5082
5088
 
5089
+ const getErrorMessagePosition = (itemHeight, focusedIndex, minLineY, depth, indent, fileIconWidth, padding, width) => {
5090
+ const top = itemHeight * (focusedIndex - minLineY + 1);
5091
+ const left = depth * indent + fileIconWidth + padding;
5092
+ const errorMessageWidth = width - left;
5093
+ return {
5094
+ top,
5095
+ left,
5096
+ errorMessageWidth
5097
+ };
5098
+ };
5099
+
5083
5100
  const getUnique = items => {
5084
5101
  const seens = [];
5085
5102
  for (const item of items) {
@@ -5092,15 +5109,29 @@ const getUnique = items => {
5092
5109
 
5093
5110
  const renderCss = (oldState, newState) => {
5094
5111
  const {
5112
+ width,
5113
+ items,
5095
5114
  scrollBarHeight,
5096
5115
  uid,
5097
5116
  visibleExplorerItems,
5098
- errorMessageLeft,
5099
- errorMessageTop
5117
+ itemHeight,
5118
+ focusedIndex,
5119
+ minLineY
5100
5120
  } = newState;
5101
5121
  const indents = visibleExplorerItems.map(item => item.indent);
5102
5122
  const uniqueIndents = getUnique(indents);
5103
- const css = getCss(scrollBarHeight, uniqueIndents, errorMessageLeft, errorMessageTop);
5123
+ const indent = 8;
5124
+ const padding = 10;
5125
+ const fileIconWidth = 16;
5126
+ const defaultPaddingLeft = 0;
5127
+ const chevronSpace = 22;
5128
+ const depth = items[focusedIndex]?.depth || 0;
5129
+ const {
5130
+ top,
5131
+ left,
5132
+ errorMessageWidth
5133
+ } = getErrorMessagePosition(itemHeight, focusedIndex, minLineY, depth, indent, fileIconWidth, padding + defaultPaddingLeft + chevronSpace, width);
5134
+ const css = getCss(scrollBarHeight, uniqueIndents, left, top, errorMessageWidth);
5104
5135
  return [SetCss, uid, css];
5105
5136
  };
5106
5137
 
@@ -5180,15 +5211,6 @@ const renderFocusContext = (oldState, newState) => {
5180
5211
  return [];
5181
5212
  };
5182
5213
 
5183
- const getErrorMessagePosition = (itemHeight, focusedIndex, minLineY, depth, indent, fileIconWidth, padding) => {
5184
- const top = itemHeight * (focusedIndex - minLineY + 1);
5185
- const left = depth * indent + fileIconWidth + padding;
5186
- return {
5187
- top,
5188
- left
5189
- };
5190
- };
5191
-
5192
5214
  const None = 'none';
5193
5215
  const ToolBar = 'toolbar';
5194
5216
  const Tree = 'tree';
@@ -5200,16 +5222,14 @@ const Input = 6;
5200
5222
  const Img = 17;
5201
5223
  const P = 50;
5202
5224
 
5203
- const getErrorMessageDom = (errorMessage, errorMessageLeft, errorMessageTop) => {
5225
+ const getErrorMessageDom = errorMessage => {
5204
5226
  if (!errorMessage) {
5205
5227
  return [];
5206
5228
  }
5207
- const translateString = position(errorMessageLeft, errorMessageTop);
5208
5229
  return [{
5209
5230
  type: Div,
5210
5231
  className: mergeClassNames(ExplorerErrorMessage),
5211
- childCount: 1,
5212
- translate: translateString
5232
+ childCount: 1
5213
5233
  }, text(errorMessage)];
5214
5234
  };
5215
5235
 
@@ -5440,14 +5460,14 @@ const getChildCount = (scrollBarDomLength, errorDomLength) => {
5440
5460
  }
5441
5461
  return childCount;
5442
5462
  };
5443
- const getExplorerVirtualDom = (visibleItems, focusedIndex, root, isWide, focused, dropTargets, height, contentHeight, scrollTop, errorMessage, errorMessageTop, errorMessageLeft) => {
5463
+ const getExplorerVirtualDom = (visibleItems, focusedIndex, root, isWide, focused, dropTargets, height, contentHeight, scrollTop, errorMessage) => {
5444
5464
  if (!root) {
5445
5465
  return getExplorerWelcomeVirtualDom(isWide);
5446
5466
  }
5447
5467
  const scrollBarHeight = getScrollBarSize(height, contentHeight, 20);
5448
5468
  const scrollBarTop = getScrollBarTop(height, contentHeight, scrollTop);
5449
5469
  const scrollBarDom = getScrollBarVirtualDom(scrollBarHeight, scrollBarTop);
5450
- const errorDom = getErrorMessageDom(errorMessage, errorMessageLeft, errorMessageTop);
5470
+ const errorDom = getErrorMessageDom(errorMessage);
5451
5471
  const childCount = getChildCount(scrollBarDom.length, errorDom.length);
5452
5472
  const parentNode = {
5453
5473
  type: Div,
@@ -5469,24 +5489,13 @@ const renderItems = (oldState, newState) => {
5469
5489
  height,
5470
5490
  itemHeight,
5471
5491
  items,
5472
- minLineY,
5473
5492
  root,
5474
5493
  width
5475
5494
  } = newState;
5476
5495
  const visibleDirents = newState.visibleExplorerItems;
5477
5496
  const isWide = width > 450;
5478
5497
  const contentHeight = items.length * itemHeight;
5479
- const depth = items[focusedIndex]?.depth || 0;
5480
- const indent = 8;
5481
- const padding = 10;
5482
- const fileIconWidth = 16;
5483
- const defaultPaddingLeft = 0;
5484
- const chevronSpace = 22;
5485
- const {
5486
- top,
5487
- left
5488
- } = getErrorMessagePosition(itemHeight, focusedIndex, minLineY, depth, indent, fileIconWidth, padding + defaultPaddingLeft + chevronSpace);
5489
- const dom = getExplorerVirtualDom(visibleDirents, focusedIndex, root, isWide, focused, dropTargets, height, contentHeight, deltaY, editingErrorMessage, top, left);
5498
+ const dom = getExplorerVirtualDom(visibleDirents, focusedIndex, root, isWide, focused, dropTargets, height, contentHeight, deltaY, editingErrorMessage);
5490
5499
  return [SetDom2, dom];
5491
5500
  };
5492
5501
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/explorer-view",
3
- "version": "4.12.0",
3
+ "version": "5.0.0",
4
4
  "description": "Explorer Worker",
5
5
  "repository": {
6
6
  "type": "git",