@odoo/o-spreadsheet 16.4.27 → 16.4.28

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.
@@ -523,7 +523,7 @@
523
523
  }
524
524
  // Generate new Id if the item didn't exist in the dictionary
525
525
  const ids = Object.keys(itemsDic);
526
- const maxId = ids.length === 0 ? 0 : Math.max(...ids.map((id) => parseInt(id, 10)));
526
+ const maxId = ids.length === 0 ? 0 : largeMax(ids.map((id) => parseInt(id, 10)));
527
527
  itemsDic[maxId + 1] = item;
528
528
  return maxId + 1;
529
529
  }
@@ -739,6 +739,34 @@
739
739
  const newArray = [...array];
740
740
  newArray.splice(index, 0, ...items);
741
741
  return newArray;
742
+ }
743
+ /**
744
+ * Alternative to Math.max that works with large arrays.
745
+ * Typically useful for arrays bigger than 100k elements.
746
+ */
747
+ function largeMax(array) {
748
+ let len = array.length;
749
+ if (len < 100000)
750
+ return Math.max(...array);
751
+ let max = -Infinity;
752
+ while (len--) {
753
+ max = array[len] > max ? array[len] : max;
754
+ }
755
+ return max;
756
+ }
757
+ /**
758
+ * Alternative to Math.min that works with large arrays.
759
+ * Typically useful for arrays bigger than 100k elements.
760
+ */
761
+ function largeMin(array) {
762
+ let len = array.length;
763
+ if (len < 100000)
764
+ return Math.min(...array);
765
+ let min = +Infinity;
766
+ while (len--) {
767
+ min = array[len] < min ? array[len] : min;
768
+ }
769
+ return min;
742
770
  }
743
771
 
744
772
  const RBA_REGEX = /rgba?\(|\s+|\)/gi;
@@ -16335,10 +16363,10 @@
16335
16363
  }
16336
16364
  }
16337
16365
  return {
16338
- labels: Object.keys(labelMap),
16366
+ labels: Array.from(labelSet),
16339
16367
  dataSetsValues: datasets.map((dataset, indexOfDataset) => ({
16340
16368
  ...dataset,
16341
- data: Object.values(labelMap).map((dataOfLabel) => dataOfLabel[indexOfDataset]),
16369
+ data: Array.from(labelSet).map((label) => labelMap[label][indexOfDataset]),
16342
16370
  })),
16343
16371
  };
16344
16372
  }
@@ -17059,7 +17087,7 @@
17059
17087
  return undefined;
17060
17088
  }
17061
17089
  const labelsTimestamps = labelDates.map((date) => date.getTime());
17062
- const period = Math.max(...labelsTimestamps) - Math.min(...labelsTimestamps);
17090
+ const period = largeMax(labelsTimestamps) - largeMin(labelsTimestamps);
17063
17091
  const minUnit = getFormatMinDisplayUnit(format);
17064
17092
  if (UNIT_LENGTH.second >= UNIT_LENGTH[minUnit] && Milliseconds.inSeconds(period) < 180) {
17065
17093
  return "second";
@@ -17501,7 +17529,7 @@
17501
17529
  }
17502
17530
  function getPieColors(colors, dataSetsValues) {
17503
17531
  const pieColors = [];
17504
- const maxLength = Math.max(...dataSetsValues.map((ds) => ds.data.length));
17532
+ const maxLength = largeMax(dataSetsValues.map((ds) => ds.data.length));
17505
17533
  for (let i = 0; i <= maxLength; i++) {
17506
17534
  pieColors.push(colors.next());
17507
17535
  }
@@ -18318,8 +18346,8 @@
18318
18346
  let last;
18319
18347
  const activesRows = env.model.getters.getActiveRows();
18320
18348
  if (activesRows.size !== 0) {
18321
- first = Math.min(...activesRows);
18322
- last = Math.max(...activesRows);
18349
+ first = largeMin([...activesRows]);
18350
+ last = largeMax([...activesRows]);
18323
18351
  }
18324
18352
  else {
18325
18353
  const zone = env.model.getters.getSelectedZones()[0];
@@ -18347,8 +18375,8 @@
18347
18375
  let last;
18348
18376
  const activeCols = env.model.getters.getActiveCols();
18349
18377
  if (activeCols.size !== 0) {
18350
- first = Math.min(...activeCols);
18351
- last = Math.max(...activeCols);
18378
+ first = largeMin([...activeCols]);
18379
+ last = largeMax([...activeCols]);
18352
18380
  }
18353
18381
  else {
18354
18382
  const zone = env.model.getters.getSelectedZones()[0];
@@ -18376,8 +18404,8 @@
18376
18404
  let last;
18377
18405
  const activesRows = env.model.getters.getActiveRows();
18378
18406
  if (activesRows.size !== 0) {
18379
- first = Math.min(...activesRows);
18380
- last = Math.max(...activesRows);
18407
+ first = largeMin([...activesRows]);
18408
+ last = largeMax([...activesRows]);
18381
18409
  }
18382
18410
  else {
18383
18411
  const zone = env.model.getters.getSelectedZones()[0];
@@ -18418,8 +18446,8 @@
18418
18446
  let last;
18419
18447
  const activeCols = env.model.getters.getActiveCols();
18420
18448
  if (activeCols.size !== 0) {
18421
- first = Math.min(...activeCols);
18422
- last = Math.max(...activeCols);
18449
+ first = largeMin([...activeCols]);
18450
+ last = largeMax([...activeCols]);
18423
18451
  }
18424
18452
  else {
18425
18453
  const zone = env.model.getters.getSelectedZones()[0];
@@ -18460,7 +18488,7 @@
18460
18488
  let row;
18461
18489
  let quantity;
18462
18490
  if (activeRows.size) {
18463
- row = Math.min(...activeRows);
18491
+ row = largeMin([...activeRows]);
18464
18492
  quantity = activeRows.size;
18465
18493
  }
18466
18494
  else {
@@ -18481,7 +18509,7 @@
18481
18509
  let row;
18482
18510
  let quantity;
18483
18511
  if (activeRows.size) {
18484
- row = Math.max(...activeRows);
18512
+ row = largeMax([...activeRows]);
18485
18513
  quantity = activeRows.size;
18486
18514
  }
18487
18515
  else {
@@ -18502,7 +18530,7 @@
18502
18530
  let column;
18503
18531
  let quantity;
18504
18532
  if (activeCols.size) {
18505
- column = Math.min(...activeCols);
18533
+ column = largeMin([...activeCols]);
18506
18534
  quantity = activeCols.size;
18507
18535
  }
18508
18536
  else {
@@ -18523,7 +18551,7 @@
18523
18551
  let column;
18524
18552
  let quantity;
18525
18553
  if (activeCols.size) {
18526
- column = Math.max(...activeCols);
18554
+ column = largeMax([...activeCols]);
18527
18555
  quantity = activeCols.size;
18528
18556
  }
18529
18557
  else {
@@ -29037,7 +29065,7 @@
29037
29065
  function getSheetDims(sheet) {
29038
29066
  const dims = [0, 0];
29039
29067
  for (let row of sheet.rows) {
29040
- dims[0] = Math.max(dims[0], ...row.cells.map((cell) => toCartesian(cell.xc).col));
29068
+ dims[0] = Math.max(dims[0], largeMax(row.cells.map((cell) => toCartesian(cell.xc).col)));
29041
29069
  dims[1] = Math.max(dims[1], row.index);
29042
29070
  }
29043
29071
  dims[0] = Math.max(dims[0], EXCEL_IMPORT_DEFAULT_NUMBER_OF_COLS);
@@ -33534,7 +33562,7 @@
33534
33562
  if (hiddenElements.size >= elements) {
33535
33563
  return 69 /* CommandResult.TooManyHiddenElements */;
33536
33564
  }
33537
- else if (Math.min(...cmd.elements) < 0 || Math.max(...cmd.elements) > elements) {
33565
+ else if (largeMin(cmd.elements) < 0 || largeMax(cmd.elements) > elements) {
33538
33566
  return 89 /* CommandResult.InvalidHeaderIndex */;
33539
33567
  }
33540
33568
  else {
@@ -34328,8 +34356,8 @@
34328
34356
  let newRange = range;
34329
34357
  let changeType = "NONE";
34330
34358
  for (let group of groups) {
34331
- const min = Math.min(...group);
34332
- const max = Math.max(...group);
34359
+ const min = largeMin(group);
34360
+ const max = largeMax(group);
34333
34361
  if (range.zone[start] <= min && min <= range.zone[end]) {
34334
34362
  const toRemove = Math.min(range.zone[end], max) - min + 1;
34335
34363
  changeType = "RESIZE";
@@ -34756,7 +34784,7 @@
34756
34784
  const elements = cmd.dimension === "COL"
34757
34785
  ? this.getNumberCols(cmd.sheetId)
34758
34786
  : this.getNumberRows(cmd.sheetId);
34759
- if (Math.min(...cmd.elements) < 0 || Math.max(...cmd.elements) > elements) {
34787
+ if (largeMin(cmd.elements) < 0 || largeMax(cmd.elements) > elements) {
34760
34788
  return 89 /* CommandResult.InvalidHeaderIndex */;
34761
34789
  }
34762
34790
  else if (this.checkElementsIncludeAllNonFrozenHeaders(cmd.sheetId, cmd.dimension, cmd.elements)) {
@@ -37632,13 +37660,13 @@
37632
37660
  .map((cell) => cell.value);
37633
37661
  switch (threshold.type) {
37634
37662
  case "value":
37635
- const result = functionName === "max" ? Math.max(...rangeValues) : Math.min(...rangeValues);
37663
+ const result = functionName === "max" ? largeMax(rangeValues) : largeMin(rangeValues);
37636
37664
  return result;
37637
37665
  case "number":
37638
37666
  return Number(threshold.value);
37639
37667
  case "percentage":
37640
- const min = Math.min(...rangeValues);
37641
- const max = Math.max(...rangeValues);
37668
+ const min = largeMin(rangeValues);
37669
+ const max = largeMax(rangeValues);
37642
37670
  const delta = max - min;
37643
37671
  return min + (delta * Number(threshold.value)) / 100;
37644
37672
  case "percentile":
@@ -38521,13 +38549,13 @@
38521
38549
  const cells = this.getters.getEvaluatedCellsInZone(sheet.id, zone);
38522
38550
  const cellPositions = range(end, -1, -1);
38523
38551
  const invalidCells = cellPositions.filter((position) => cells[position] && !cells[position].isAutoSummable);
38524
- const maxValidPosition = Math.max(...invalidCells);
38552
+ const maxValidPosition = largeMax(invalidCells);
38525
38553
  const numberSequences = groupConsecutive(cellPositions.filter((position) => this.isNumber(cells[position])));
38526
38554
  const firstSequence = numberSequences[0] || [];
38527
- if (Math.max(...firstSequence) < maxValidPosition) {
38555
+ if (largeMax(firstSequence) < maxValidPosition) {
38528
38556
  return Infinity;
38529
38557
  }
38530
- return Math.min(...firstSequence);
38558
+ return largeMin(firstSequence);
38531
38559
  }
38532
38560
  shouldFindData(sheetId, zone) {
38533
38561
  return this.getters.isEmpty(sheetId, zone) || this.getters.isSingleCellOrMerge(sheetId, zone);
@@ -40116,7 +40144,7 @@
40116
40144
  * column of the current viewport
40117
40145
  */
40118
40146
  getColDimensionsInViewport(sheetId, col) {
40119
- const left = Math.min(...this.getters.getSheetViewVisibleCols());
40147
+ const left = largeMin(this.getters.getSheetViewVisibleCols());
40120
40148
  const start = this.getters.getColRowOffsetInViewport("COL", left, col);
40121
40149
  const size = this.getters.getColSize(sheetId, col);
40122
40150
  const isColHidden = this.getters.isColHidden(sheetId, col);
@@ -40131,7 +40159,7 @@
40131
40159
  * of the current viewport
40132
40160
  */
40133
40161
  getRowDimensionsInViewport(sheetId, row) {
40134
- const top = Math.min(...this.getters.getSheetViewVisibleRows());
40162
+ const top = largeMin(this.getters.getSheetViewVisibleRows());
40135
40163
  const start = this.getters.getColRowOffsetInViewport("ROW", top, row);
40136
40164
  const size = this.getters.getRowSize(sheetId, row);
40137
40165
  const isRowHidden = this.getters.isRowHidden(sheetId, row);
@@ -41628,7 +41656,7 @@
41628
41656
  getColMaxWidth(sheetId, index) {
41629
41657
  const cellsPositions = positions(this.getters.getColsZone(sheetId, index, index));
41630
41658
  const sizes = cellsPositions.map((position) => this.getCellWidth({ sheetId, ...position }));
41631
- return Math.max(0, ...sizes);
41659
+ return Math.max(0, largeMax(sizes));
41632
41660
  }
41633
41661
  /**
41634
41662
  * Check that any "sheetId" in the command matches an existing
@@ -42930,7 +42958,7 @@
42930
42958
  }
42931
42959
  getPasteZone(target) {
42932
42960
  const height = this.values.length;
42933
- const width = Math.max(...this.values.map((a) => a.length));
42961
+ const width = largeMax(this.values.map((a) => a.length));
42934
42962
  const { left: activeCol, top: activeRow } = target[0];
42935
42963
  return {
42936
42964
  top: activeRow,
@@ -46151,12 +46179,14 @@
46151
46179
  this.editionState = "initializing";
46152
46180
  }
46153
46181
  stopEdition() {
46154
- if (!this.state.isEditing)
46182
+ const input = this.sheetNameRef.el;
46183
+ if (!this.state.isEditing || !input)
46155
46184
  return;
46156
46185
  this.state.isEditing = false;
46157
46186
  this.editionState = "initializing";
46158
- this.sheetNameRef.el?.blur();
46187
+ input.blur();
46159
46188
  const inputValue = this.getInputContent() || "";
46189
+ input.innerText = inputValue;
46160
46190
  interactiveRenameSheet(this.env, this.props.sheetId, inputValue, () => this.startEdition());
46161
46191
  }
46162
46192
  cancelEdition() {
@@ -46618,7 +46648,7 @@
46618
46648
  this.sheetListRef.el.scrollTo({ top: 0, left: scroll, behavior: "smooth" });
46619
46649
  }
46620
46650
  onSheetMouseDown(sheetId, event) {
46621
- if (event.button !== 0)
46651
+ if (event.button !== 0 || this.env.model.getters.isReadonly())
46622
46652
  return;
46623
46653
  this.closeMenu();
46624
46654
  const mouseX = event.clientX;
@@ -49822,7 +49852,7 @@
49822
49852
  }
49823
49853
  function addDoughnutChart(chart, chartSheetIndex, data, { holeSize } = { holeSize: 50 }) {
49824
49854
  const colors = new ChartColors();
49825
- const maxLength = Math.max(...chart.dataSets.map((ds) => getRangeSize(ds.range, chartSheetIndex, data)));
49855
+ const maxLength = largeMax(chart.dataSets.map((ds) => getRangeSize(ds.range, chartSheetIndex, data)));
49826
49856
  const doughnutColors = range(0, maxLength).map(() => toXlsxHexColor(colors.next()));
49827
49857
  const dataSetsNodes = [];
49828
49858
  for (const [dsIndex, dataset] of Object.entries(chart.dataSets).reverse()) {
@@ -51753,9 +51783,9 @@
51753
51783
  Object.defineProperty(exports, '__esModule', { value: true });
51754
51784
 
51755
51785
 
51756
- __info__.version = '16.4.27';
51757
- __info__.date = '2024-03-25T09:41:12.743Z';
51758
- __info__.hash = '42e4252';
51786
+ __info__.version = '16.4.28';
51787
+ __info__.date = '2024-04-05T13:59:39.997Z';
51788
+ __info__.hash = '7127826';
51759
51789
 
51760
51790
 
51761
51791
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);