@odoo/o-spreadsheet 17.2.3 → 17.2.4

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.
@@ -3,9 +3,9 @@
3
3
  /**
4
4
  * This file is generated by o-spreadsheet build tools. Do not edit it.
5
5
  * @see https://github.com/odoo/o-spreadsheet
6
- * @version 17.2.3
7
- * @date 2024-04-10T12:28:36.552Z
8
- * @hash ab5e22d
6
+ * @version 17.2.4
7
+ * @date 2024-04-18T16:41:38.407Z
8
+ * @hash 0c66038
9
9
  */
10
10
 
11
11
  (function (exports, owl) {
@@ -2508,6 +2508,15 @@
2508
2508
  }
2509
2509
  return generateMatrix(matrix.length, matrix[0].length, (col, row) => fn(matrix[col][row]));
2510
2510
  }
2511
+ function matrixForEach(matrix, fn) {
2512
+ const numberOfCols = matrix.length;
2513
+ const numberOfRows = matrix[0]?.length ?? 0;
2514
+ for (let col = 0; col < numberOfCols; col++) {
2515
+ for (let row = 0; row < numberOfRows; row++) {
2516
+ fn(matrix[col][row]);
2517
+ }
2518
+ }
2519
+ }
2511
2520
  function transposeMatrix(matrix) {
2512
2521
  if (!matrix.length) {
2513
2522
  return [];
@@ -18635,7 +18644,7 @@ stores.inject(MyMetaStore, storeInstance);
18635
18644
  }
18636
18645
  const descr = addMetaInfoFromArg(addDescr);
18637
18646
  validateArguments(descr.args);
18638
- this.mapping[name] = addErrorHandling(addResultHandling(addInputHandling(descr)), name);
18647
+ this.mapping[name] = addErrorHandling(addResultHandling(addInputHandling(descr), name), name);
18639
18648
  super.add(name, descr);
18640
18649
  return this;
18641
18650
  }
@@ -18674,9 +18683,7 @@ stores.inject(MyMetaStore, storeInstance);
18674
18683
  // so we fallback to a generic error
18675
18684
  if (hasStringValue(e) && isEvaluationError(e.value)) {
18676
18685
  if (hasStringMessage(e)) {
18677
- if (e.message?.includes("[[FUNCTION_NAME]]")) {
18678
- e.message = e.message.replace("[[FUNCTION_NAME]]", functionName);
18679
- }
18686
+ replaceFunctionNamePlaceholder(e, functionName);
18680
18687
  }
18681
18688
  return e;
18682
18689
  }
@@ -18691,21 +18698,29 @@ stores.inject(MyMetaStore, storeInstance);
18691
18698
  return (obj?.message !== undefined &&
18692
18699
  typeof obj.message === "string");
18693
18700
  }
18694
- function addResultHandling(compute) {
18695
- return function (...args) {
18701
+ function addResultHandling(compute, functionName) {
18702
+ return function computeWithResultHandling(...args) {
18696
18703
  const result = compute.apply(this, args);
18697
18704
  if (!isMatrix(result)) {
18698
18705
  if (typeof result === "object" && result !== null && "value" in result) {
18706
+ replaceFunctionNamePlaceholder(result, functionName);
18699
18707
  return result;
18700
18708
  }
18701
18709
  return { value: result };
18702
18710
  }
18703
18711
  if (typeof result[0][0] === "object" && result[0][0] !== null && "value" in result[0][0]) {
18712
+ matrixForEach(result, (result) => replaceFunctionNamePlaceholder(result, functionName));
18704
18713
  return result;
18705
18714
  }
18706
18715
  return matrixMap(result, (row) => ({ value: row }));
18707
18716
  };
18708
18717
  }
18718
+ function replaceFunctionNamePlaceholder(fPayload, functionName) {
18719
+ // for performance reasons: change in place and only if needed
18720
+ if (fPayload.message?.includes("[[FUNCTION_NAME]]")) {
18721
+ fPayload.message = fPayload.message.replace("[[FUNCTION_NAME]]", functionName);
18722
+ }
18723
+ }
18709
18724
  const functionRegistry = new FunctionRegistry();
18710
18725
  for (let category of categories) {
18711
18726
  const fns = category.functions;
@@ -19473,7 +19488,7 @@ stores.inject(MyMetaStore, storeInstance);
19473
19488
  const xLabel = tooltipItem.dataset?.label || tooltipItem.label;
19474
19489
  // tooltipItem.parsed.y can be an object or a number for pie charts
19475
19490
  const yLabel = tooltipItem.parsed.y ?? tooltipItem.parsed;
19476
- const toolTipFormat = !format && yLabel > 1000 ? "#,##" : format;
19491
+ const toolTipFormat = !format && Math.abs(yLabel) >= 1000 ? "#,##" : format;
19477
19492
  const yLabelStr = formatValue(yLabel, { format: toolTipFormat, locale });
19478
19493
  return xLabel ? `${xLabel}: ${yLabelStr}` : yLabelStr;
19479
19494
  },
@@ -19773,7 +19788,10 @@ stores.inject(MyMetaStore, storeInstance);
19773
19788
  if (isNaN(value))
19774
19789
  return value;
19775
19790
  const { locale, format } = localeFormat;
19776
- return formatValue(value, { locale, format: !format && value > 1000 ? "#,##" : format });
19791
+ return formatValue(value, {
19792
+ locale,
19793
+ format: !format && Math.abs(value) >= 1000 ? "#,##" : format,
19794
+ });
19777
19795
  },
19778
19796
  },
19779
19797
  },
@@ -20294,7 +20312,10 @@ stores.inject(MyMetaStore, storeInstance);
20294
20312
  if (isNaN(value))
20295
20313
  return value;
20296
20314
  const { locale, format } = localeFormat;
20297
- return formatValue(value, { locale, format: !format && value > 1000 ? "#,##" : format });
20315
+ return formatValue(value, {
20316
+ locale,
20317
+ format: !format && Math.abs(value) >= 1000 ? "#,##" : format,
20318
+ });
20298
20319
  },
20299
20320
  },
20300
20321
  },
@@ -20634,7 +20655,7 @@ stores.inject(MyMetaStore, storeInstance);
20634
20655
  const percentage = calculatePercentage(data, dataIndex);
20635
20656
  const xLabel = tooltipItem.label || tooltipItem.dataset.label;
20636
20657
  const yLabel = tooltipItem.parsed.y ?? tooltipItem.parsed;
20637
- const toolTipFormat = !format && yLabel > 1000 ? "#,##" : format;
20658
+ const toolTipFormat = !format && yLabel >= 1000 ? "#,##" : format;
20638
20659
  const yLabelStr = formatValue(yLabel, { format: toolTipFormat, locale });
20639
20660
  return xLabel ? `${xLabel}: ${yLabelStr} (${percentage}%)` : `${yLabelStr} (${percentage}%)`;
20640
20661
  };
@@ -22886,6 +22907,7 @@ stores.inject(MyMetaStore, storeInstance);
22886
22907
  this.save();
22887
22908
  }
22888
22909
  ev.stopPropagation();
22910
+ ev.preventDefault();
22889
22911
  break;
22890
22912
  case "Escape":
22891
22913
  this.cancel();
@@ -33162,6 +33184,10 @@ stores.inject(MyMetaStore, storeInstance);
33162
33184
  height: 0px;
33163
33185
  }
33164
33186
  }
33187
+ .o-figure-container {
33188
+ -webkit-user-select: none; // safari
33189
+ user-select: none;
33190
+ }
33165
33191
  `;
33166
33192
  /**
33167
33193
  * Each figure ⭐ is positioned inside a container `div` placed and sized
@@ -52085,7 +52111,7 @@ stores.inject(MyMetaStore, storeInstance);
52085
52111
  "isFilterActive",
52086
52112
  ];
52087
52113
  filterValues = {};
52088
- hiddenRows = new Set();
52114
+ hiddenRows = {};
52089
52115
  isEvaluationDirty = false;
52090
52116
  allowDispatch(cmd) {
52091
52117
  switch (cmd.type) {
@@ -52129,11 +52155,11 @@ stores.inject(MyMetaStore, storeInstance);
52129
52155
  case "UNFOLD_HEADER_GROUP":
52130
52156
  case "FOLD_ALL_HEADER_GROUPS":
52131
52157
  case "UNFOLD_ALL_HEADER_GROUPS":
52132
- this.updateHiddenRows();
52158
+ this.updateHiddenRows(cmd.sheetId);
52133
52159
  break;
52134
52160
  case "UPDATE_FILTER":
52135
52161
  this.updateFilter(cmd);
52136
- this.updateHiddenRows();
52162
+ this.updateHiddenRows(cmd.sheetId);
52137
52163
  break;
52138
52164
  case "DUPLICATE_SHEET":
52139
52165
  const filterValues = {};
@@ -52153,15 +52179,14 @@ stores.inject(MyMetaStore, storeInstance);
52153
52179
  }
52154
52180
  finalize() {
52155
52181
  if (this.isEvaluationDirty) {
52156
- this.updateHiddenRows();
52182
+ for (const sheetId of this.getters.getSheetIds()) {
52183
+ this.updateHiddenRows(sheetId);
52184
+ }
52157
52185
  this.isEvaluationDirty = false;
52158
52186
  }
52159
52187
  }
52160
52188
  isRowFiltered(sheetId, row) {
52161
- if (sheetId !== this.getters.getActiveSheetId()) {
52162
- return false;
52163
- }
52164
- return this.hiddenRows.has(row);
52189
+ return !!this.hiddenRows[sheetId]?.has(row);
52165
52190
  }
52166
52191
  getFilterHiddenValues(position) {
52167
52192
  const id = this.getters.getFilterId(position);
@@ -52188,8 +52213,7 @@ stores.inject(MyMetaStore, storeInstance);
52188
52213
  this.filterValues[sheetId] = {};
52189
52214
  this.filterValues[sheetId][id] = hiddenValues;
52190
52215
  }
52191
- updateHiddenRows() {
52192
- const sheetId = this.getters.getActiveSheetId();
52216
+ updateHiddenRows(sheetId) {
52193
52217
  const filters = this.getters
52194
52218
  .getFilters(sheetId)
52195
52219
  .sort((filter1, filter2) => filter1.rangeWithHeaders.zone.top - filter2.rangeWithHeaders.zone.top);
@@ -52211,7 +52235,7 @@ stores.inject(MyMetaStore, storeInstance);
52211
52235
  }
52212
52236
  }
52213
52237
  }
52214
- this.hiddenRows = hiddenRows;
52238
+ this.hiddenRows[sheetId] = hiddenRows;
52215
52239
  }
52216
52240
  getCellValueAsString(sheetId, col, row) {
52217
52241
  const value = this.getters.getEvaluatedCell({ sheetId, col, row }).formattedValue;
@@ -53330,13 +53354,14 @@ stores.inject(MyMetaStore, storeInstance);
53330
53354
  }
53331
53355
  }
53332
53356
  handleEvent(event) {
53357
+ const sheetId = this.getters.getActiveSheetId();
53333
53358
  if (event.options.scrollIntoView) {
53334
53359
  let { col, row } = findCellInNewZone(event.previousAnchor.zone, event.anchor.zone);
53335
53360
  if (event.mode === "updateAnchor") {
53336
53361
  const oldZone = event.previousAnchor.zone;
53337
53362
  const newZone = event.anchor.zone;
53338
53363
  // altering a zone should not move the viewport in a dimension that wasn't changed
53339
- const { top, bottom, left, right } = this.getters.getActiveMainViewport();
53364
+ const { top, bottom, left, right } = this.getMainInternalViewport(sheetId);
53340
53365
  if (oldZone.left === newZone.left && oldZone.right === newZone.right) {
53341
53366
  col = left > col || col > right ? left : col;
53342
53367
  }
@@ -53344,7 +53369,6 @@ stores.inject(MyMetaStore, storeInstance);
53344
53369
  row = top > row || row > bottom ? top : row;
53345
53370
  }
53346
53371
  }
53347
- const sheetId = this.getters.getActiveSheetId();
53348
53372
  col = Math.min(col, this.getters.getNumberCols(sheetId) - 1);
53349
53373
  row = Math.min(row, this.getters.getNumberRows(sheetId) - 1);
53350
53374
  if (!this.sheetsWithDirtyViewports.has(sheetId)) {
@@ -53381,16 +53405,16 @@ stores.inject(MyMetaStore, storeInstance);
53381
53405
  this.setSheetViewOffset(cmd.offsetX, cmd.offsetY);
53382
53406
  break;
53383
53407
  case "SHIFT_VIEWPORT_DOWN":
53384
- const { top } = this.getActiveMainViewport();
53385
53408
  const sheetId = this.getters.getActiveSheetId();
53386
- const shiftedOffsetY = this.clipOffsetY(this.getters.getRowDimensions(sheetId, top).start + this.sheetViewHeight);
53387
- this.shiftVertically(shiftedOffsetY);
53409
+ const { top, viewportHeight, offsetCorrectionY } = this.getMainInternalViewport(sheetId);
53410
+ const topRowDims = this.getters.getRowDimensions(sheetId, top);
53411
+ this.shiftVertically(topRowDims.start + viewportHeight - offsetCorrectionY);
53388
53412
  break;
53389
53413
  case "SHIFT_VIEWPORT_UP": {
53390
- const { top } = this.getActiveMainViewport();
53391
53414
  const sheetId = this.getters.getActiveSheetId();
53392
- const shiftedOffsetY = this.clipOffsetY(this.getters.getRowDimensions(sheetId, top).end - this.sheetViewHeight);
53393
- this.shiftVertically(shiftedOffsetY);
53415
+ const { top, viewportHeight, offsetCorrectionY } = this.getMainInternalViewport(sheetId);
53416
+ const topRowDims = this.getters.getRowDimensions(sheetId, top);
53417
+ this.shiftVertically(topRowDims.end - offsetCorrectionY - viewportHeight);
53394
53418
  break;
53395
53419
  }
53396
53420
  case "REMOVE_TABLE":
@@ -53813,17 +53837,6 @@ stores.inject(MyMetaStore, storeInstance);
53813
53837
  const { maxOffsetX, maxOffsetY } = this.getMaximumSheetOffset();
53814
53838
  Object.values(this.getSubViewports(sheetId)).forEach((viewport) => viewport.setViewportOffset(clip(offsetX, 0, maxOffsetX), clip(offsetY, 0, maxOffsetY)));
53815
53839
  }
53816
- /**
53817
- * Clip the vertical offset within the allowed range.
53818
- * Not above the sheet, nor below the sheet.
53819
- */
53820
- clipOffsetY(offsetY) {
53821
- const { height } = this.getMainViewportRect();
53822
- const maxOffset = height - this.sheetViewHeight;
53823
- offsetY = Math.min(offsetY, maxOffset);
53824
- offsetY = Math.max(offsetY, 0);
53825
- return offsetY;
53826
- }
53827
53840
  getViewportOffset(sheetId) {
53828
53841
  return {
53829
53842
  x: this.viewports[sheetId]?.bottomRight.offsetScrollbarX || 0,
@@ -53879,12 +53892,15 @@ stores.inject(MyMetaStore, storeInstance);
53879
53892
  * viewport top.
53880
53893
  */
53881
53894
  shiftVertically(offset) {
53882
- const { top } = this.getActiveMainViewport();
53895
+ const sheetId = this.getters.getActiveSheetId();
53896
+ const { top } = this.getMainInternalViewport(sheetId);
53883
53897
  const { scrollX } = this.getActiveSheetScrollInfo();
53884
53898
  this.setSheetViewOffset(scrollX, offset);
53885
53899
  const { anchor } = this.getters.getSelection();
53886
- const deltaRow = this.getActiveMainViewport().top - top;
53887
- this.selection.selectCell(anchor.cell.col, anchor.cell.row + deltaRow);
53900
+ if (anchor.cell.row >= this.getters.getPaneDivisions(sheetId).ySplit) {
53901
+ const deltaRow = this.getMainInternalViewport(sheetId).top - top;
53902
+ this.selection.selectCell(anchor.cell.col, anchor.cell.row + deltaRow);
53903
+ }
53888
53904
  }
53889
53905
  getVisibleFigures() {
53890
53906
  const sheetId = this.getters.getActiveSheetId();
@@ -54803,7 +54819,6 @@ stores.inject(MyMetaStore, storeInstance);
54803
54819
  cursor: pointer;
54804
54820
  }
54805
54821
  `;
54806
- let tKey = 1;
54807
54822
  class SpreadsheetDashboard extends owl.Component {
54808
54823
  static template = "o-spreadsheet-SpreadsheetDashboard";
54809
54824
  static props = {};
@@ -54882,13 +54897,9 @@ stores.inject(MyMetaStore, storeInstance);
54882
54897
  coordinates: rect,
54883
54898
  position: { col, row },
54884
54899
  action,
54885
- // we can't rely on position only because a row or a column could
54886
- // be inserted at any time.
54887
- tKey: `${tKey}-${col}-${row}`,
54888
54900
  });
54889
54901
  }
54890
54902
  }
54891
- tKey++;
54892
54903
  return cells;
54893
54904
  }
54894
54905
  getClickableAction(position) {
@@ -60228,9 +60239,9 @@ stores.inject(MyMetaStore, storeInstance);
60228
60239
  exports.tokenize = tokenize;
60229
60240
 
60230
60241
 
60231
- __info__.version = "17.2.3";
60232
- __info__.date = "2024-04-10T12:28:36.552Z";
60233
- __info__.hash = "ab5e22d";
60242
+ __info__.version = "17.2.4";
60243
+ __info__.date = "2024-04-18T16:41:38.407Z";
60244
+ __info__.hash = "0c66038";
60234
60245
 
60235
60246
 
60236
60247
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);