@odoo/o-spreadsheet 16.3.29 → 16.3.31

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.
@@ -1017,7 +1017,7 @@
1017
1017
  }
1018
1018
  // Generate new Id if the item didn't exist in the dictionary
1019
1019
  const ids = Object.keys(itemsDic);
1020
- const maxId = ids.length === 0 ? 0 : Math.max(...ids.map((id) => parseInt(id, 10)));
1020
+ const maxId = ids.length === 0 ? 0 : largeMax(ids.map((id) => parseInt(id, 10)));
1021
1021
  itemsDic[maxId + 1] = item;
1022
1022
  return maxId + 1;
1023
1023
  }
@@ -1209,6 +1209,34 @@
1209
1209
  }
1210
1210
  }
1211
1211
  return true;
1212
+ }
1213
+ /**
1214
+ * Alternative to Math.max that works with large arrays.
1215
+ * Typically useful for arrays bigger than 100k elements.
1216
+ */
1217
+ function largeMax(array) {
1218
+ let len = array.length;
1219
+ if (len < 100000)
1220
+ return Math.max(...array);
1221
+ let max = -Infinity;
1222
+ while (len--) {
1223
+ max = array[len] > max ? array[len] : max;
1224
+ }
1225
+ return max;
1226
+ }
1227
+ /**
1228
+ * Alternative to Math.min that works with large arrays.
1229
+ * Typically useful for arrays bigger than 100k elements.
1230
+ */
1231
+ function largeMin(array) {
1232
+ let len = array.length;
1233
+ if (len < 100000)
1234
+ return Math.min(...array);
1235
+ let min = +Infinity;
1236
+ while (len--) {
1237
+ min = array[len] < min ? array[len] : min;
1238
+ }
1239
+ return min;
1212
1240
  }
1213
1241
 
1214
1242
  const RBA_REGEX = /rgba?\(|\s+|\)/gi;
@@ -6820,10 +6848,10 @@
6820
6848
  }
6821
6849
  }
6822
6850
  return {
6823
- labels: Object.keys(labelMap),
6851
+ labels: Array.from(labelSet),
6824
6852
  dataSetsValues: datasets.map((dataset, indexOfDataset) => ({
6825
6853
  ...dataset,
6826
- data: Object.values(labelMap).map((dataOfLabel) => dataOfLabel[indexOfDataset]),
6854
+ data: Array.from(labelSet).map((label) => labelMap[label][indexOfDataset]),
6827
6855
  })),
6828
6856
  };
6829
6857
  }
@@ -7540,7 +7568,7 @@
7540
7568
  return undefined;
7541
7569
  }
7542
7570
  const labelsTimestamps = labelDates.map((date) => date.getTime());
7543
- const period = Math.max(...labelsTimestamps) - Math.min(...labelsTimestamps);
7571
+ const period = largeMax(labelsTimestamps) - largeMin(labelsTimestamps);
7544
7572
  const minUnit = getFormatMinDisplayUnit(format);
7545
7573
  if (UNIT_LENGTH.second >= UNIT_LENGTH[minUnit] && Milliseconds.inSeconds(period) < 180) {
7546
7574
  return "second";
@@ -7980,7 +8008,7 @@
7980
8008
  }
7981
8009
  function getPieColors(colors, dataSetsValues) {
7982
8010
  const pieColors = [];
7983
- const maxLength = Math.max(...dataSetsValues.map((ds) => ds.data.length));
8011
+ const maxLength = largeMax(dataSetsValues.map((ds) => ds.data.length));
7984
8012
  for (let i = 0; i <= maxLength; i++) {
7985
8013
  pieColors.push(colors.next());
7986
8014
  }
@@ -8943,8 +8971,8 @@
8943
8971
  let last;
8944
8972
  const activesRows = env.model.getters.getActiveRows();
8945
8973
  if (activesRows.size !== 0) {
8946
- first = Math.min(...activesRows);
8947
- last = Math.max(...activesRows);
8974
+ first = largeMin([...activesRows]);
8975
+ last = largeMax([...activesRows]);
8948
8976
  }
8949
8977
  else {
8950
8978
  const zone = env.model.getters.getSelectedZones()[0];
@@ -8972,8 +9000,8 @@
8972
9000
  let last;
8973
9001
  const activeCols = env.model.getters.getActiveCols();
8974
9002
  if (activeCols.size !== 0) {
8975
- first = Math.min(...activeCols);
8976
- last = Math.max(...activeCols);
9003
+ first = largeMin([...activeCols]);
9004
+ last = largeMax([...activeCols]);
8977
9005
  }
8978
9006
  else {
8979
9007
  const zone = env.model.getters.getSelectedZones()[0];
@@ -9001,8 +9029,8 @@
9001
9029
  let last;
9002
9030
  const activesRows = env.model.getters.getActiveRows();
9003
9031
  if (activesRows.size !== 0) {
9004
- first = Math.min(...activesRows);
9005
- last = Math.max(...activesRows);
9032
+ first = largeMin([...activesRows]);
9033
+ last = largeMax([...activesRows]);
9006
9034
  }
9007
9035
  else {
9008
9036
  const zone = env.model.getters.getSelectedZones()[0];
@@ -9043,8 +9071,8 @@
9043
9071
  let last;
9044
9072
  const activeCols = env.model.getters.getActiveCols();
9045
9073
  if (activeCols.size !== 0) {
9046
- first = Math.min(...activeCols);
9047
- last = Math.max(...activeCols);
9074
+ first = largeMin([...activeCols]);
9075
+ last = largeMax([...activeCols]);
9048
9076
  }
9049
9077
  else {
9050
9078
  const zone = env.model.getters.getSelectedZones()[0];
@@ -9127,7 +9155,7 @@
9127
9155
  let row;
9128
9156
  let quantity;
9129
9157
  if (activeRows.size) {
9130
- row = Math.min(...activeRows);
9158
+ row = largeMin([...activeRows]);
9131
9159
  quantity = activeRows.size;
9132
9160
  }
9133
9161
  else {
@@ -9159,7 +9187,7 @@
9159
9187
  let row;
9160
9188
  let quantity;
9161
9189
  if (activeRows.size) {
9162
- row = Math.max(...activeRows);
9190
+ row = largeMax([...activeRows]);
9163
9191
  quantity = activeRows.size;
9164
9192
  }
9165
9193
  else {
@@ -9204,7 +9232,7 @@
9204
9232
  let column;
9205
9233
  let quantity;
9206
9234
  if (activeCols.size) {
9207
- column = Math.min(...activeCols);
9235
+ column = largeMin([...activeCols]);
9208
9236
  quantity = activeCols.size;
9209
9237
  }
9210
9238
  else {
@@ -9238,7 +9266,7 @@
9238
9266
  let column;
9239
9267
  let quantity;
9240
9268
  if (activeCols.size) {
9241
- column = Math.max(...activeCols);
9269
+ column = largeMax([...activeCols]);
9242
9270
  quantity = activeCols.size;
9243
9271
  }
9244
9272
  else {
@@ -16546,14 +16574,19 @@
16546
16574
  children: [allFunctionListMenuBuilder],
16547
16575
  };
16548
16576
  function allFunctionListMenuBuilder() {
16549
- const fnNames = functionRegistry.getKeys();
16577
+ const fnNames = functionRegistry.getKeys().filter((key) => !functionRegistry.get(key).hidden);
16550
16578
  return createFormulaFunctions(fnNames);
16551
16579
  }
16552
16580
  const categoriesFunctionListMenuBuilder = () => {
16553
16581
  const functions = functionRegistry.content;
16554
- const categories = [...new Set(functionRegistry.getAll().map((fn) => fn.category))].filter(isDefined$1);
16582
+ const categories = [
16583
+ ...new Set(functionRegistry
16584
+ .getAll()
16585
+ .filter((fn) => !fn.hidden)
16586
+ .map((fn) => fn.category)),
16587
+ ].filter(isDefined$1);
16555
16588
  return categories.sort().map((category, i) => {
16556
- const functionsInCategory = Object.keys(functions).filter((key) => functions[key].category === category);
16589
+ const functionsInCategory = Object.keys(functions).filter((key) => functions[key].category === category && !functions[key].hidden);
16557
16590
  return {
16558
16591
  name: category,
16559
16592
  children: createFormulaFunctions(functionsInCategory),
@@ -20213,6 +20246,9 @@
20213
20246
  el?.focus({ preventScroll: true });
20214
20247
  }
20215
20248
  }, () => [this.env.model.getters.getSelectedFigureId(), this.props.figure.id, this.figureRef.el]);
20249
+ owl.onWillUnmount(() => {
20250
+ this.props.onFigureDeleted();
20251
+ });
20216
20252
  }
20217
20253
  clickAnchor(dirX, dirY, ev) {
20218
20254
  this.props.onClickAnchor(dirX, dirY, ev);
@@ -20231,6 +20267,7 @@
20231
20267
  this.props.onFigureDeleted();
20232
20268
  ev.stopPropagation();
20233
20269
  ev.preventDefault();
20270
+ ev.stopPropagation();
20234
20271
  break;
20235
20272
  case "ArrowDown":
20236
20273
  case "ArrowLeft":
@@ -20251,6 +20288,7 @@
20251
20288
  });
20252
20289
  ev.stopPropagation();
20253
20290
  ev.preventDefault();
20291
+ ev.stopPropagation();
20254
20292
  break;
20255
20293
  }
20256
20294
  }
@@ -21059,6 +21097,10 @@
21059
21097
  if (!this.isKeyStillDown) {
21060
21098
  this.processContent();
21061
21099
  }
21100
+ // Required because typing '=SUM' and double-clicking another cell leaves ShowProvider and ShowDescription true
21101
+ if (this.env.model.getters.getEditionMode() === "inactive") {
21102
+ this.processTokenAtCursor();
21103
+ }
21062
21104
  });
21063
21105
  }
21064
21106
  // ---------------------------------------------------------------------------
@@ -26912,7 +26954,7 @@
26912
26954
  function getSheetDims(sheet) {
26913
26955
  const dims = [0, 0];
26914
26956
  for (let row of sheet.rows) {
26915
- dims[0] = Math.max(dims[0], ...row.cells.map((cell) => toCartesian(cell.xc).col));
26957
+ dims[0] = Math.max(dims[0], largeMax(row.cells.map((cell) => toCartesian(cell.xc).col)));
26916
26958
  dims[1] = Math.max(dims[1], row.index);
26917
26959
  }
26918
26960
  dims[0] = Math.max(dims[0], EXCEL_IMPORT_DEFAULT_NUMBER_OF_COLS);
@@ -31199,7 +31241,7 @@
31199
31241
  for (let headerIndex of [...cmd.elements].sort((a, b) => b - a)) {
31200
31242
  sizes.splice(headerIndex, 1);
31201
31243
  }
31202
- const min = Math.min(...cmd.elements);
31244
+ const min = largeMin(cmd.elements);
31203
31245
  sizes = sizes.map((size, row) => {
31204
31246
  if (cmd.dimension === "ROW" && row >= min) {
31205
31247
  // invalidate sizes
@@ -31426,7 +31468,7 @@
31426
31468
  if (hiddenElements.size >= elements) {
31427
31469
  return 67 /* CommandResult.TooManyHiddenElements */;
31428
31470
  }
31429
- else if (Math.min(...cmd.elements) < 0 || Math.max(...cmd.elements) > elements) {
31471
+ else if (largeMin(cmd.elements) < 0 || largeMax(cmd.elements) > elements) {
31430
31472
  return 87 /* CommandResult.InvalidHeaderIndex */;
31431
31473
  }
31432
31474
  else {
@@ -32199,8 +32241,8 @@
32199
32241
  let newRange = range;
32200
32242
  let changeType = "NONE";
32201
32243
  for (let group of groups) {
32202
- const min = Math.min(...group);
32203
- const max = Math.max(...group);
32244
+ const min = largeMin(group);
32245
+ const max = largeMax(group);
32204
32246
  if (range.zone[start] <= min && min <= range.zone[end]) {
32205
32247
  const toRemove = Math.min(range.zone[end], max) - min + 1;
32206
32248
  changeType = "RESIZE";
@@ -32631,7 +32673,7 @@
32631
32673
  const elements = cmd.dimension === "COL"
32632
32674
  ? this.getNumberCols(cmd.sheetId)
32633
32675
  : this.getNumberRows(cmd.sheetId);
32634
- if (Math.min(...cmd.elements) < 0 || Math.max(...cmd.elements) > elements) {
32676
+ if (largeMin(cmd.elements) < 0 || largeMax(cmd.elements) > elements) {
32635
32677
  return 87 /* CommandResult.InvalidHeaderIndex */;
32636
32678
  }
32637
32679
  else if (this.checkElementsIncludeAllNonFrozenHeaders(cmd.sheetId, cmd.dimension, cmd.elements)) {
@@ -34133,13 +34175,13 @@
34133
34175
  .map((cell) => cell.value);
34134
34176
  switch (threshold.type) {
34135
34177
  case "value":
34136
- const result = functionName === "max" ? Math.max(...rangeValues) : Math.min(...rangeValues);
34178
+ const result = functionName === "max" ? largeMax(rangeValues) : largeMin(rangeValues);
34137
34179
  return result;
34138
34180
  case "number":
34139
34181
  return Number(threshold.value);
34140
34182
  case "percentage":
34141
- const min = Math.min(...rangeValues);
34142
- const max = Math.max(...rangeValues);
34183
+ const min = largeMin(rangeValues);
34184
+ const max = largeMax(rangeValues);
34143
34185
  const delta = max - min;
34144
34186
  return min + (delta * Number(threshold.value)) / 100;
34145
34187
  case "percentile":
@@ -36089,13 +36131,13 @@
36089
36131
  const cells = this.getters.getEvaluatedCellsInZone(sheet.id, zone);
36090
36132
  const cellPositions = range(end, -1, -1);
36091
36133
  const invalidCells = cellPositions.filter((position) => cells[position] && !cells[position].isAutoSummable);
36092
- const maxValidPosition = Math.max(...invalidCells);
36134
+ const maxValidPosition = largeMax(invalidCells);
36093
36135
  const numberSequences = groupConsecutive(cellPositions.filter((position) => this.isNumber(cells[position])));
36094
36136
  const firstSequence = numberSequences[0] || [];
36095
- if (Math.max(...firstSequence) < maxValidPosition) {
36137
+ if (largeMax(firstSequence) < maxValidPosition) {
36096
36138
  return Infinity;
36097
36139
  }
36098
- return Math.min(...firstSequence);
36140
+ return largeMin(firstSequence);
36099
36141
  }
36100
36142
  shouldFindData(sheetId, zone) {
36101
36143
  return this.getters.isEmpty(sheetId, zone) || this.getters.isSingleCellOrMerge(sheetId, zone);
@@ -37680,7 +37722,7 @@
37680
37722
  * column of the current viewport
37681
37723
  */
37682
37724
  getColDimensionsInViewport(sheetId, col) {
37683
- const left = Math.min(...this.getters.getSheetViewVisibleCols());
37725
+ const left = largeMin(this.getters.getSheetViewVisibleCols());
37684
37726
  const start = this.getters.getColRowOffsetInViewport("COL", left, col);
37685
37727
  const size = this.getters.getColSize(sheetId, col);
37686
37728
  const isColHidden = this.getters.isColHidden(sheetId, col);
@@ -37695,7 +37737,7 @@
37695
37737
  * of the current viewport
37696
37738
  */
37697
37739
  getRowDimensionsInViewport(sheetId, row) {
37698
- const top = Math.min(...this.getters.getSheetViewVisibleRows());
37740
+ const top = largeMin(this.getters.getSheetViewVisibleRows());
37699
37741
  const start = this.getters.getColRowOffsetInViewport("ROW", top, row);
37700
37742
  const size = this.getters.getRowSize(sheetId, row);
37701
37743
  const isRowHidden = this.getters.isRowHidden(sheetId, row);
@@ -39223,7 +39265,7 @@
39223
39265
  getColMaxWidth(sheetId, index) {
39224
39266
  const cellsPositions = positions(this.getters.getColsZone(sheetId, index, index));
39225
39267
  const sizes = cellsPositions.map((position) => this.getCellWidth({ sheetId, ...position }));
39226
- return Math.max(0, ...sizes);
39268
+ return Math.max(0, largeMax(sizes));
39227
39269
  }
39228
39270
  splitWordToSpecificWidth(ctx, word, width, style) {
39229
39271
  const wordWidth = computeTextWidth(ctx, word, style);
@@ -41680,6 +41722,7 @@
41680
41722
  this.gridSelection.zones = this.gridSelection.zones.map((z) => this.getters.expandZone(sheetId, z));
41681
41723
  this.gridSelection.anchor.zone = this.getters.expandZone(sheetId, this.gridSelection.anchor.zone);
41682
41724
  this.setSelectionMixin(this.gridSelection.anchor, this.gridSelection.zones);
41725
+ this.selectedFigureId = null;
41683
41726
  break;
41684
41727
  }
41685
41728
  /** Any change to the selection has to be reflected in the selection processor. */
@@ -42485,12 +42528,14 @@
42485
42528
  this.editionState = "initializing";
42486
42529
  }
42487
42530
  stopEdition() {
42488
- if (!this.state.isEditing)
42531
+ const input = this.sheetNameRef.el;
42532
+ if (!this.state.isEditing || !input)
42489
42533
  return;
42490
42534
  this.state.isEditing = false;
42491
42535
  this.editionState = "initializing";
42492
- this.sheetNameRef.el?.blur();
42536
+ input.blur();
42493
42537
  const inputValue = this.getInputContent() || "";
42538
+ input.innerText = inputValue;
42494
42539
  interactiveRenameSheet(this.env, this.props.sheetId, inputValue, () => this.startEdition());
42495
42540
  }
42496
42541
  cancelEdition() {
@@ -42951,7 +42996,7 @@
42951
42996
  this.sheetListRef.el.scrollTo({ top: 0, left: scroll, behavior: "smooth" });
42952
42997
  }
42953
42998
  onSheetMouseDown(sheetId, event) {
42954
- if (event.button !== 0)
42999
+ if (event.button !== 0 || this.env.model.getters.isReadonly())
42955
43000
  return;
42956
43001
  this.closeMenu();
42957
43002
  const mouseX = event.clientX;
@@ -46125,7 +46170,7 @@
46125
46170
  }
46126
46171
  function addDoughnutChart(chart, chartSheetIndex, data, { holeSize } = { holeSize: 50 }) {
46127
46172
  const colors = new ChartColors();
46128
- const maxLength = Math.max(...chart.dataSets.map((ds) => getRangeSize(ds.range, chartSheetIndex, data)));
46173
+ const maxLength = largeMax(chart.dataSets.map((ds) => getRangeSize(ds.range, chartSheetIndex, data)));
46129
46174
  const doughnutColors = range(0, maxLength).map(() => toXlsxHexColor(colors.next()));
46130
46175
  const dataSetsNodes = [];
46131
46176
  for (const [dsIndex, dataset] of Object.entries(chart.dataSets).reverse()) {
@@ -48048,9 +48093,9 @@
48048
48093
  Object.defineProperty(exports, '__esModule', { value: true });
48049
48094
 
48050
48095
 
48051
- __info__.version = '16.3.29';
48052
- __info__.date = '2024-03-15T10:57:27.142Z';
48053
- __info__.hash = 'd86234a';
48096
+ __info__.version = '16.3.31';
48097
+ __info__.date = '2024-04-05T13:57:05.657Z';
48098
+ __info__.hash = '052efd4';
48054
48099
 
48055
48100
 
48056
48101
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);