@odoo/o-spreadsheet 15.0.18 → 15.0.20

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.
@@ -2990,6 +2990,34 @@
2990
2990
  }
2991
2991
  }
2992
2992
  return true;
2993
+ }
2994
+ /**
2995
+ * Alternative to Math.max that works with large arrays.
2996
+ * Typically useful for arrays bigger than 100k elements.
2997
+ */
2998
+ function largeMax(array) {
2999
+ let len = array.length;
3000
+ if (len < 100000)
3001
+ return Math.max(...array);
3002
+ let max = -Infinity;
3003
+ while (len--) {
3004
+ max = array[len] > max ? array[len] : max;
3005
+ }
3006
+ return max;
3007
+ }
3008
+ /**
3009
+ * Alternative to Math.min that works with large arrays.
3010
+ * Typically useful for arrays bigger than 100k elements.
3011
+ */
3012
+ function largeMin(array) {
3013
+ let len = array.length;
3014
+ if (len < 100000)
3015
+ return Math.min(...array);
3016
+ let min = +Infinity;
3017
+ while (len--) {
3018
+ min = array[len] < min ? array[len] : min;
3019
+ }
3020
+ return min;
2993
3021
  }
2994
3022
 
2995
3023
  /**
@@ -3607,9 +3635,10 @@
3607
3635
  * https://stackoverflow.com/questions/105034/create-guid-uuid-in-javascript
3608
3636
  * */
3609
3637
  class UuidGenerator {
3610
- constructor() {
3638
+ constructor(isFast = false) {
3611
3639
  this.isFastIdStrategy = false;
3612
3640
  this.fastIdStart = 0;
3641
+ this.setIsFastStrategy(isFast);
3613
3642
  }
3614
3643
  setIsFastStrategy(isFast) {
3615
3644
  this.isFastIdStrategy = isFast;
@@ -9520,6 +9549,7 @@
9520
9549
  constructor() {
9521
9550
  super(...arguments);
9522
9551
  this.cells = {};
9552
+ this.cellUuidGenerator = new UuidGenerator(true);
9523
9553
  this.createCell = cellFactory(this.getters);
9524
9554
  }
9525
9555
  adaptRanges(applyChange, sheetId) {
@@ -9699,7 +9729,7 @@
9699
9729
  }
9700
9730
  importCell(sheet, cellData, normalizedStyles) {
9701
9731
  const style = (cellData.style && normalizedStyles[cellData.style]) || undefined;
9702
- const cellId = this.uuidGenerator.uuidv4();
9732
+ const cellId = this.cellUuidGenerator.uuidv4();
9703
9733
  const properties = { format: cellData === null || cellData === void 0 ? void 0 : cellData.format, style };
9704
9734
  return this.createCell(cellId, (cellData === null || cellData === void 0 ? void 0 : cellData.content) || "", properties, sheet.id);
9705
9735
  }
@@ -9882,7 +9912,7 @@
9882
9912
  }
9883
9913
  return;
9884
9914
  }
9885
- const cellId = (before === null || before === void 0 ? void 0 : before.id) || this.uuidGenerator.uuidv4();
9915
+ const cellId = (before === null || before === void 0 ? void 0 : before.id) || this.cellUuidGenerator.uuidv4();
9886
9916
  const didContentChange = hasContent;
9887
9917
  const properties = { format, style };
9888
9918
  const cell = this.createCell(cellId, afterContent, properties, sheet.id);
@@ -10716,6 +10746,9 @@
10716
10746
  this.figures[cmd.sheetId] = {};
10717
10747
  break;
10718
10748
  case "DELETE_SHEET":
10749
+ this.getters.getFigures(cmd.sheetId).forEach((figure) => {
10750
+ this.dispatch("DELETE_FIGURE", { id: figure.id, sheetId: cmd.sheetId });
10751
+ });
10719
10752
  this.deleteSheet(cmd.sheetId);
10720
10753
  break;
10721
10754
  case "CREATE_FIGURE":
@@ -12026,8 +12059,8 @@
12026
12059
  getImportedSheetSize(data) {
12027
12060
  const positions = Object.keys(data.cells).map(toCartesian);
12028
12061
  return {
12029
- rowNumber: Math.max(data.rowNumber, ...new Set(positions.map(([col, row]) => row + 1))),
12030
- colNumber: Math.max(data.colNumber, ...new Set(positions.map(([col, row]) => col + 1))),
12062
+ rowNumber: Math.max(data.rowNumber, largeMax(positions.map(([col, row]) => row + 1))),
12063
+ colNumber: Math.max(data.colNumber, largeMax(positions.map(([col, row]) => col + 1))),
12031
12064
  };
12032
12065
  }
12033
12066
  // ----------------------------------------------------
@@ -12564,8 +12597,8 @@
12564
12597
  let last;
12565
12598
  const activesRows = env.getters.getActiveRows();
12566
12599
  if (activesRows.size !== 0) {
12567
- first = Math.min(...activesRows);
12568
- last = Math.max(...activesRows);
12600
+ first = largeMin([...activesRows]);
12601
+ last = largeMax([...activesRows]);
12569
12602
  }
12570
12603
  else {
12571
12604
  const zone = env.getters.getSelectedZones()[0];
@@ -12590,8 +12623,8 @@
12590
12623
  let last;
12591
12624
  const activeCols = env.getters.getActiveCols();
12592
12625
  if (activeCols.size !== 0) {
12593
- first = Math.min(...activeCols);
12594
- last = Math.max(...activeCols);
12626
+ first = largeMin([...activeCols]);
12627
+ last = largeMax([...activeCols]);
12595
12628
  }
12596
12629
  else {
12597
12630
  const zone = env.getters.getSelectedZones()[0];
@@ -12616,8 +12649,8 @@
12616
12649
  let last;
12617
12650
  const activesRows = env.getters.getActiveRows();
12618
12651
  if (activesRows.size !== 0) {
12619
- first = Math.min(...activesRows);
12620
- last = Math.max(...activesRows);
12652
+ first = largeMin([...activesRows]);
12653
+ last = largeMax([...activesRows]);
12621
12654
  }
12622
12655
  else {
12623
12656
  const zone = env.getters.getSelectedZones()[0];
@@ -12648,8 +12681,8 @@
12648
12681
  let last;
12649
12682
  const activeCols = env.getters.getActiveCols();
12650
12683
  if (activeCols.size !== 0) {
12651
- first = Math.min(...activeCols);
12652
- last = Math.max(...activeCols);
12684
+ first = largeMin([...activeCols]);
12685
+ last = largeMax([...activeCols]);
12653
12686
  }
12654
12687
  else {
12655
12688
  const zone = env.getters.getSelectedZones()[0];
@@ -12714,7 +12747,7 @@
12714
12747
  let row;
12715
12748
  let quantity;
12716
12749
  if (activeRows.size) {
12717
- row = Math.min(...activeRows);
12750
+ row = largeMin([...activeRows]);
12718
12751
  quantity = activeRows.size;
12719
12752
  }
12720
12753
  else {
@@ -12746,7 +12779,7 @@
12746
12779
  let row;
12747
12780
  let quantity;
12748
12781
  if (activeRows.size) {
12749
- row = Math.max(...activeRows);
12782
+ row = largeMax([...activeRows]);
12750
12783
  quantity = activeRows.size;
12751
12784
  }
12752
12785
  else {
@@ -12787,7 +12820,7 @@
12787
12820
  let column;
12788
12821
  let quantity;
12789
12822
  if (activeCols.size) {
12790
- column = Math.min(...activeCols);
12823
+ column = largeMin([...activeCols]);
12791
12824
  quantity = activeCols.size;
12792
12825
  }
12793
12826
  else {
@@ -12821,7 +12854,7 @@
12821
12854
  let column;
12822
12855
  let quantity;
12823
12856
  if (activeCols.size) {
12824
- column = Math.max(...activeCols);
12857
+ column = largeMax([...activeCols]);
12825
12858
  quantity = activeCols.size;
12826
12859
  }
12827
12860
  else {
@@ -16563,13 +16596,13 @@
16563
16596
  const cells = mapCellsInZone(zone, sheet, (cell) => cell, undefined).flat();
16564
16597
  const cellPositions = range(end, -1, -1);
16565
16598
  const invalidCells = cellPositions.filter((position) => { var _a; return cells[position] && !((_a = cells[position]) === null || _a === void 0 ? void 0 : _a.isAutoSummable); });
16566
- const maxValidPosition = Math.max(...invalidCells);
16599
+ const maxValidPosition = largeMax(invalidCells);
16567
16600
  const numberSequences = groupConsecutive(cellPositions.filter((position) => this.isNumber(cells[position])));
16568
16601
  const firstSequence = numberSequences[0] || [];
16569
- if (Math.max(...firstSequence) < maxValidPosition) {
16602
+ if (largeMax(firstSequence) < maxValidPosition) {
16570
16603
  return Infinity;
16571
16604
  }
16572
- return Math.min(...firstSequence);
16605
+ return largeMin(firstSequence);
16573
16606
  }
16574
16607
  shouldFindData(sheetId, zone) {
16575
16608
  return this.getters.isEmpty(sheetId, zone) || this.getters.isSingleCellOrMerge(sheetId, zone);
@@ -22260,13 +22293,13 @@
22260
22293
  getColMaxWidth(sheetId, index) {
22261
22294
  const cells = this.getters.getColCells(sheetId, index);
22262
22295
  const sizes = cells.map((cell) => this.getCellWidth(cell));
22263
- return Math.max(0, ...sizes);
22296
+ return Math.max(0, largeMax(sizes));
22264
22297
  }
22265
22298
  getRowMaxHeight(sheetId, index) {
22266
22299
  const sheet = this.getters.getSheet(sheetId);
22267
22300
  const cells = Object.values(sheet.rows[index].cells);
22268
22301
  const sizes = cells.map((cell) => this.getCellHeight(cell));
22269
- return Math.max(0, ...sizes);
22302
+ return Math.max(0, largeMax(sizes));
22270
22303
  }
22271
22304
  interactiveRenameSheet(sheetId, title) {
22272
22305
  const placeholder = this.getters.getSheetName(sheetId);
@@ -23685,8 +23718,8 @@
23685
23718
  let newRange = range;
23686
23719
  let changeType = "NONE";
23687
23720
  for (let group of groups) {
23688
- const min = Math.min(...group);
23689
- const max = Math.max(...group);
23721
+ const min = largeMin(group);
23722
+ const max = largeMax(group);
23690
23723
  if (range.zone[start] <= min && min <= range.zone[end]) {
23691
23724
  const toRemove = Math.min(range.zone[end], max) - min + 1;
23692
23725
  changeType = "RESIZE";
@@ -31504,9 +31537,9 @@
31504
31537
  Object.defineProperty(exports, '__esModule', { value: true });
31505
31538
 
31506
31539
 
31507
- __info__.version = '15.0.18';
31508
- __info__.date = '2024-02-02T13:41:26.005Z';
31509
- __info__.hash = 'd1605d8';
31540
+ __info__.version = '15.0.20';
31541
+ __info__.date = '2024-04-05T13:56:04.792Z';
31542
+ __info__.hash = '09e95ef';
31510
31543
 
31511
31544
 
31512
31545
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);