@odoo/o-spreadsheet 17.1.9 → 17.1.10

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.
@@ -2,9 +2,9 @@
2
2
  /**
3
3
  * This file is generated by o-spreadsheet build tools. Do not edit it.
4
4
  * @see https://github.com/odoo/o-spreadsheet
5
- * @version 17.1.9
6
- * @date 2024-03-25T09:43:27.017Z
7
- * @hash 5fb076e
5
+ * @version 17.1.10
6
+ * @date 2024-04-05T14:00:03.890Z
7
+ * @hash edc821c
8
8
  */
9
9
 
10
10
  (function (exports, owl) {
@@ -459,7 +459,7 @@
459
459
  }
460
460
  // Generate new Id if the item didn't exist in the dictionary
461
461
  const ids = Object.keys(itemsDic);
462
- const maxId = ids.length === 0 ? 0 : Math.max(...ids.map((id) => parseInt(id, 10)));
462
+ const maxId = ids.length === 0 ? 0 : largeMax(ids.map((id) => parseInt(id, 10)));
463
463
  itemsDic[maxId + 1] = item;
464
464
  return maxId + 1;
465
465
  }
@@ -676,6 +676,34 @@
676
676
  }
677
677
  return value >= min && value <= max;
678
678
  }
679
+ /**
680
+ * Alternative to Math.max that works with large arrays.
681
+ * Typically useful for arrays bigger than 100k elements.
682
+ */
683
+ function largeMax(array) {
684
+ let len = array.length;
685
+ if (len < 100000)
686
+ return Math.max(...array);
687
+ let max = -Infinity;
688
+ while (len--) {
689
+ max = array[len] > max ? array[len] : max;
690
+ }
691
+ return max;
692
+ }
693
+ /**
694
+ * Alternative to Math.min that works with large arrays.
695
+ * Typically useful for arrays bigger than 100k elements.
696
+ */
697
+ function largeMin(array) {
698
+ let len = array.length;
699
+ if (len < 100000)
700
+ return Math.min(...array);
701
+ let min = +Infinity;
702
+ while (len--) {
703
+ min = array[len] < min ? array[len] : min;
704
+ }
705
+ return min;
706
+ }
679
707
 
680
708
  const RBA_REGEX = /rgba?\(|\s+|\)/gi;
681
709
  const HEX_MATCH = /^#([A-F\d]{2}){3,4}$/;
@@ -4478,8 +4506,9 @@
4478
4506
  * Get the default height of the cell given its style.
4479
4507
  */
4480
4508
  function getDefaultCellHeight(ctx, cell, colSize) {
4481
- if (!cell || !cell.content)
4509
+ if (!cell || (!cell.isFormula && !cell.content)) {
4482
4510
  return DEFAULT_CELL_HEIGHT;
4511
+ }
4483
4512
  const maxWidth = cell.style?.wrapping === "wrap" ? colSize - 2 * MIN_CELL_TEXT_MARGIN : undefined;
4484
4513
  const numberOfLines = cell.isFormula
4485
4514
  ? 1
@@ -8381,10 +8410,10 @@
8381
8410
  }
8382
8411
  }
8383
8412
  return {
8384
- labels: Object.keys(labelMap),
8413
+ labels: Array.from(labelSet),
8385
8414
  dataSetsValues: datasets.map((dataset, indexOfDataset) => ({
8386
8415
  ...dataset,
8387
- data: Object.values(labelMap).map((dataOfLabel) => dataOfLabel[indexOfDataset]),
8416
+ data: Array.from(labelSet).map((label) => labelMap[label][indexOfDataset]),
8388
8417
  })),
8389
8418
  };
8390
8419
  }
@@ -9136,7 +9165,7 @@
9136
9165
  return undefined;
9137
9166
  }
9138
9167
  const labelsTimestamps = labelDates.map((date) => date.getTime());
9139
- const period = Math.max(...labelsTimestamps) - Math.min(...labelsTimestamps);
9168
+ const period = largeMax(labelsTimestamps) - largeMin(labelsTimestamps);
9140
9169
  const minUnit = getFormatMinDisplayUnit(format);
9141
9170
  if (UNIT_LENGTH.second >= UNIT_LENGTH[minUnit] && Milliseconds.inSeconds(period) < 180) {
9142
9171
  return "second";
@@ -9608,7 +9637,7 @@
9608
9637
  }
9609
9638
  function getPieColors(colors, dataSetsValues) {
9610
9639
  const pieColors = [];
9611
- const maxLength = Math.max(...dataSetsValues.map((ds) => ds.data.length));
9640
+ const maxLength = largeMax(dataSetsValues.map((ds) => ds.data.length));
9612
9641
  for (let i = 0; i <= maxLength; i++) {
9613
9642
  pieColors.push(colors.next());
9614
9643
  }
@@ -10532,8 +10561,8 @@
10532
10561
  let last;
10533
10562
  const activesRows = env.model.getters.getActiveRows();
10534
10563
  if (activesRows.size !== 0) {
10535
- first = Math.min(...activesRows);
10536
- last = Math.max(...activesRows);
10564
+ first = largeMin([...activesRows]);
10565
+ last = largeMax([...activesRows]);
10537
10566
  }
10538
10567
  else {
10539
10568
  const zone = env.model.getters.getSelectedZones()[0];
@@ -10561,8 +10590,8 @@
10561
10590
  let last;
10562
10591
  const activeCols = env.model.getters.getActiveCols();
10563
10592
  if (activeCols.size !== 0) {
10564
- first = Math.min(...activeCols);
10565
- last = Math.max(...activeCols);
10593
+ first = largeMin([...activeCols]);
10594
+ last = largeMax([...activeCols]);
10566
10595
  }
10567
10596
  else {
10568
10597
  const zone = env.model.getters.getSelectedZones()[0];
@@ -10590,8 +10619,8 @@
10590
10619
  let last;
10591
10620
  const activesRows = env.model.getters.getActiveRows();
10592
10621
  if (activesRows.size !== 0) {
10593
- first = Math.min(...activesRows);
10594
- last = Math.max(...activesRows);
10622
+ first = largeMin([...activesRows]);
10623
+ last = largeMax([...activesRows]);
10595
10624
  }
10596
10625
  else {
10597
10626
  const zone = env.model.getters.getSelectedZones()[0];
@@ -10632,8 +10661,8 @@
10632
10661
  let last;
10633
10662
  const activeCols = env.model.getters.getActiveCols();
10634
10663
  if (activeCols.size !== 0) {
10635
- first = Math.min(...activeCols);
10636
- last = Math.max(...activeCols);
10664
+ first = largeMin([...activeCols]);
10665
+ last = largeMax([...activeCols]);
10637
10666
  }
10638
10667
  else {
10639
10668
  const zone = env.model.getters.getSelectedZones()[0];
@@ -10674,7 +10703,7 @@
10674
10703
  let row;
10675
10704
  let quantity;
10676
10705
  if (activeRows.size) {
10677
- row = Math.min(...activeRows);
10706
+ row = largeMin([...activeRows]);
10678
10707
  quantity = activeRows.size;
10679
10708
  }
10680
10709
  else {
@@ -10695,7 +10724,7 @@
10695
10724
  let row;
10696
10725
  let quantity;
10697
10726
  if (activeRows.size) {
10698
- row = Math.max(...activeRows);
10727
+ row = largeMax([...activeRows]);
10699
10728
  quantity = activeRows.size;
10700
10729
  }
10701
10730
  else {
@@ -10716,7 +10745,7 @@
10716
10745
  let column;
10717
10746
  let quantity;
10718
10747
  if (activeCols.size) {
10719
- column = Math.min(...activeCols);
10748
+ column = largeMin([...activeCols]);
10720
10749
  quantity = activeCols.size;
10721
10750
  }
10722
10751
  else {
@@ -10737,7 +10766,7 @@
10737
10766
  let column;
10738
10767
  let quantity;
10739
10768
  if (activeCols.size) {
10740
- column = Math.max(...activeCols);
10769
+ column = largeMax([...activeCols]);
10741
10770
  quantity = activeCols.size;
10742
10771
  }
10743
10772
  else {
@@ -29218,11 +29247,6 @@
29218
29247
  height: 10000px;
29219
29248
  background-color: ${SELECTION_BORDER_COLOR};
29220
29249
  }
29221
- .o-unhide-buttons {
29222
- width: fit-content;
29223
- gap: 5px;
29224
- transform: translate(-50%, 0);
29225
- }
29226
29250
  .o-unhide:hover {
29227
29251
  z-index: ${ComponentsImportance.Grid + 1};
29228
29252
  background-color: lightgrey;
@@ -29384,10 +29408,6 @@
29384
29408
  height: 1px;
29385
29409
  background-color: ${SELECTION_BORDER_COLOR};
29386
29410
  }
29387
- .o-unhide-buttons {
29388
- height: fit-content;
29389
- transform: translate(0, -50%);
29390
- }
29391
29411
  .o-unhide:hover {
29392
29412
  z-index: ${ComponentsImportance.Grid + 1};
29393
29413
  background-color: lightgrey;
@@ -32328,7 +32348,7 @@
32328
32348
  function getSheetDims(sheet) {
32329
32349
  const dims = [0, 0];
32330
32350
  for (let row of sheet.rows) {
32331
- dims[0] = Math.max(dims[0], ...row.cells.map((cell) => toCartesian(cell.xc).col));
32351
+ dims[0] = Math.max(dims[0], largeMax(row.cells.map((cell) => toCartesian(cell.xc).col)));
32332
32352
  dims[1] = Math.max(dims[1], row.index);
32333
32353
  }
32334
32354
  dims[0] = Math.max(dims[0], EXCEL_IMPORT_DEFAULT_NUMBER_OF_COLS);
@@ -37228,6 +37248,9 @@
37228
37248
  if (newRule.criterion.type === "isBoolean") {
37229
37249
  this.setCenterStyleToBooleanCells(newRule);
37230
37250
  }
37251
+ else if (newRule.criterion.type === "isValueInList") {
37252
+ newRule.criterion.values = Array.from(new Set(newRule.criterion.values));
37253
+ }
37231
37254
  const adaptedRules = this.removeRangesFromRules(sheetId, newRule.ranges, rules);
37232
37255
  const ruleIndex = adaptedRules.findIndex((rule) => rule.id === newRule.id);
37233
37256
  if (ruleIndex !== -1) {
@@ -37954,7 +37977,7 @@
37954
37977
  if (hiddenElements.size >= elements) {
37955
37978
  return "TooManyHiddenElements" /* CommandResult.TooManyHiddenElements */;
37956
37979
  }
37957
- else if (Math.min(...cmd.elements) < 0 || Math.max(...cmd.elements) > elements) {
37980
+ else if (largeMin(cmd.elements) < 0 || largeMax(cmd.elements) > elements) {
37958
37981
  return "InvalidHeaderIndex" /* CommandResult.InvalidHeaderIndex */;
37959
37982
  }
37960
37983
  else {
@@ -38769,8 +38792,8 @@
38769
38792
  let newRange = range;
38770
38793
  let changeType = "NONE";
38771
38794
  for (let group of groups) {
38772
- const min = Math.min(...group);
38773
- const max = Math.max(...group);
38795
+ const min = largeMin(group);
38796
+ const max = largeMax(group);
38774
38797
  if (range.zone[start] <= min && min <= range.zone[end]) {
38775
38798
  const toRemove = Math.min(range.zone[end], max) - min + 1;
38776
38799
  changeType = "RESIZE";
@@ -39193,8 +39216,8 @@
39193
39216
  }
39194
39217
  return "Success" /* CommandResult.Success */;
39195
39218
  case "REMOVE_COLUMNS_ROWS": {
39196
- const min = Math.min(...cmd.elements);
39197
- const max = Math.max(...cmd.elements);
39219
+ const min = largeMin(cmd.elements);
39220
+ const max = largeMax(cmd.elements);
39198
39221
  if (min < 0 || !this.doesHeaderExist(cmd.sheetId, cmd.dimension, max)) {
39199
39222
  return "InvalidHeaderIndex" /* CommandResult.InvalidHeaderIndex */;
39200
39223
  }
@@ -42102,7 +42125,7 @@
42102
42125
  ? getItemId(newFormat, data.formats)
42103
42126
  : exportedCellData.format;
42104
42127
  let content;
42105
- if (formulaCell instanceof FormulaCellWithDependencies) {
42128
+ if (isFormula && formulaCell instanceof FormulaCellWithDependencies) {
42106
42129
  content = formulaCell.contentWithFixedReferences;
42107
42130
  }
42108
42131
  else {
@@ -42523,13 +42546,13 @@
42523
42546
  .map((cell) => cell.value);
42524
42547
  switch (threshold.type) {
42525
42548
  case "value":
42526
- const result = functionName === "max" ? Math.max(...rangeValues) : Math.min(...rangeValues);
42549
+ const result = functionName === "max" ? largeMax(rangeValues) : largeMin(rangeValues);
42527
42550
  return result;
42528
42551
  case "number":
42529
42552
  return Number(threshold.value);
42530
42553
  case "percentage":
42531
- const min = Math.min(...rangeValues);
42532
- const max = Math.max(...rangeValues);
42554
+ const min = largeMin(rangeValues);
42555
+ const max = largeMax(rangeValues);
42533
42556
  const delta = max - min;
42534
42557
  return min + (delta * Number(threshold.value)) / 100;
42535
42558
  case "percentile":
@@ -43571,13 +43594,13 @@
43571
43594
  const cells = this.getters.getEvaluatedCellsInZone(sheet.id, zone);
43572
43595
  const cellPositions = range(end, -1, -1);
43573
43596
  const invalidCells = cellPositions.filter((position) => cells[position] && !cells[position].isAutoSummable);
43574
- const maxValidPosition = Math.max(...invalidCells);
43597
+ const maxValidPosition = largeMax(invalidCells);
43575
43598
  const numberSequences = groupConsecutive(cellPositions.filter((position) => this.isNumber(cells[position])));
43576
43599
  const firstSequence = numberSequences[0] || [];
43577
- if (Math.max(...firstSequence) < maxValidPosition) {
43600
+ if (largeMax(firstSequence) < maxValidPosition) {
43578
43601
  return Infinity;
43579
43602
  }
43580
- return Math.min(...firstSequence);
43603
+ return largeMin(firstSequence);
43581
43604
  }
43582
43605
  shouldFindData(sheetId, zone) {
43583
43606
  return this.getters.isEmpty(sheetId, zone) || this.getters.isSingleCellOrMerge(sheetId, zone);
@@ -46070,7 +46093,7 @@
46070
46093
  * column of the current viewport
46071
46094
  */
46072
46095
  getColDimensionsInViewport(sheetId, col) {
46073
- const left = Math.min(...this.getters.getSheetViewVisibleCols());
46096
+ const left = largeMin(this.getters.getSheetViewVisibleCols());
46074
46097
  const start = this.getters.getColRowOffsetInViewport("COL", left, col);
46075
46098
  const size = this.getters.getColSize(sheetId, col);
46076
46099
  const isColHidden = this.getters.isColHidden(sheetId, col);
@@ -46085,7 +46108,7 @@
46085
46108
  * of the current viewport
46086
46109
  */
46087
46110
  getRowDimensionsInViewport(sheetId, row) {
46088
- const top = Math.min(...this.getters.getSheetViewVisibleRows());
46111
+ const top = largeMin(this.getters.getSheetViewVisibleRows());
46089
46112
  const start = this.getters.getColRowOffsetInViewport("ROW", top, row);
46090
46113
  const size = this.getters.getRowSize(sheetId, row);
46091
46114
  const isRowHidden = this.getters.isRowHidden(sheetId, row);
@@ -47468,7 +47491,7 @@
47468
47491
  getColMaxWidth(sheetId, index) {
47469
47492
  const cellsPositions = positions(this.getters.getColsZone(sheetId, index, index));
47470
47493
  const sizes = cellsPositions.map((position) => this.getCellWidth({ sheetId, ...position }));
47471
- return Math.max(0, ...sizes);
47494
+ return Math.max(0, largeMax(sizes));
47472
47495
  }
47473
47496
  /**
47474
47497
  * Check that any "sheetId" in the command matches an existing
@@ -48235,7 +48258,7 @@
48235
48258
  }
48236
48259
  getPasteZone(target) {
48237
48260
  const height = this.values.length;
48238
- const width = Math.max(...this.values.map((a) => a.length));
48261
+ const width = largeMax(this.values.map((a) => a.length));
48239
48262
  const { left: activeCol, top: activeRow } = target[0];
48240
48263
  return {
48241
48264
  top: activeRow,
@@ -49181,11 +49204,11 @@
49181
49204
  }
49182
49205
  else {
49183
49206
  const range = this.getters.getRangeFromSheetXC(this.sheetId, rule.criterion.values[0]);
49184
- values = this.getters
49207
+ values = Array.from(new Set(this.getters
49185
49208
  .getRangeValues(range)
49186
49209
  .filter(isNotNull)
49187
49210
  .map((value) => value.toString())
49188
- .filter((val) => val !== "");
49211
+ .filter((val) => val !== "")));
49189
49212
  }
49190
49213
  const composerContent = this.getCurrentContent();
49191
49214
  if (composerContent && composerContent !== this.getInitialComposerContent()) {
@@ -51617,12 +51640,14 @@
51617
51640
  this.editionState = "initializing";
51618
51641
  }
51619
51642
  stopEdition() {
51620
- if (!this.state.isEditing)
51643
+ const input = this.sheetNameRef.el;
51644
+ if (!this.state.isEditing || !input)
51621
51645
  return;
51622
51646
  this.state.isEditing = false;
51623
51647
  this.editionState = "initializing";
51624
- this.sheetNameRef.el?.blur();
51648
+ input.blur();
51625
51649
  const inputValue = this.getInputContent() || "";
51650
+ input.innerText = inputValue;
51626
51651
  interactiveRenameSheet(this.env, this.props.sheetId, inputValue, () => this.startEdition());
51627
51652
  }
51628
51653
  cancelEdition() {
@@ -51913,7 +51938,7 @@
51913
51938
  this.sheetListRef.el.scrollTo({ top: 0, left: scroll, behavior: "smooth" });
51914
51939
  }
51915
51940
  onSheetMouseDown(sheetId, event) {
51916
- if (event.button !== 0)
51941
+ if (event.button !== 0 || this.env.model.getters.isReadonly())
51917
51942
  return;
51918
51943
  this.closeMenu();
51919
51944
  const visibleSheets = this.getVisibleSheets();
@@ -55367,7 +55392,7 @@
55367
55392
  }
55368
55393
  function addDoughnutChart(chart, chartSheetIndex, data, { holeSize } = { holeSize: 50 }) {
55369
55394
  const colors = new ChartColors();
55370
- const maxLength = Math.max(...chart.dataSets.map((ds) => getRangeSize(ds.range, chartSheetIndex, data)));
55395
+ const maxLength = largeMax(chart.dataSets.map((ds) => getRangeSize(ds.range, chartSheetIndex, data)));
55371
55396
  const doughnutColors = range(0, maxLength).map(() => toXlsxHexColor(colors.next()));
55372
55397
  const dataSetsNodes = [];
55373
55398
  for (const [dsIndex, dataset] of Object.entries(chart.dataSets).reverse()) {
@@ -57331,9 +57356,9 @@
57331
57356
  exports.tokenize = tokenize;
57332
57357
 
57333
57358
 
57334
- __info__.version = "17.1.9";
57335
- __info__.date = "2024-03-25T09:43:27.017Z";
57336
- __info__.hash = "5fb076e";
57359
+ __info__.version = "17.1.10";
57360
+ __info__.date = "2024-04-05T14:00:03.890Z";
57361
+ __info__.hash = "edc821c";
57337
57362
 
57338
57363
 
57339
57364
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);