@odoo/o-spreadsheet 17.2.1 → 17.2.2

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.1
7
- * @date 2024-03-25T09:41:58.737Z
8
- * @hash f97284c
6
+ * @version 17.2.2
7
+ * @date 2024-04-05T14:01:19.824Z
8
+ * @hash c15836d
9
9
  */
10
10
 
11
11
  (function (exports, owl) {
@@ -465,7 +465,7 @@
465
465
  }
466
466
  // Generate new Id if the item didn't exist in the dictionary
467
467
  const ids = Object.keys(itemsDic);
468
- const maxId = ids.length === 0 ? 0 : Math.max(...ids.map((id) => parseInt(id, 10)));
468
+ const maxId = ids.length === 0 ? 0 : largeMax(ids.map((id) => parseInt(id, 10)));
469
469
  itemsDic[maxId + 1] = item;
470
470
  return maxId + 1;
471
471
  }
@@ -685,6 +685,34 @@
685
685
  }
686
686
  return RegExp(searchValue, flags);
687
687
  }
688
+ /**
689
+ * Alternative to Math.max that works with large arrays.
690
+ * Typically useful for arrays bigger than 100k elements.
691
+ */
692
+ function largeMax(array) {
693
+ let len = array.length;
694
+ if (len < 100000)
695
+ return Math.max(...array);
696
+ let max = -Infinity;
697
+ while (len--) {
698
+ max = array[len] > max ? array[len] : max;
699
+ }
700
+ return max;
701
+ }
702
+ /**
703
+ * Alternative to Math.min that works with large arrays.
704
+ * Typically useful for arrays bigger than 100k elements.
705
+ */
706
+ function largeMin(array) {
707
+ let len = array.length;
708
+ if (len < 100000)
709
+ return Math.min(...array);
710
+ let min = +Infinity;
711
+ while (len--) {
712
+ min = array[len] < min ? array[len] : min;
713
+ }
714
+ return min;
715
+ }
688
716
 
689
717
  const RBA_REGEX = /rgba?\(|\s+|\)/gi;
690
718
  const HEX_MATCH = /^#([A-F\d]{2}){3,4}$/;
@@ -4544,8 +4572,9 @@
4544
4572
  * Get the default height of the cell given its style.
4545
4573
  */
4546
4574
  function getDefaultCellHeight(ctx, cell, colSize) {
4547
- if (!cell || !cell.content)
4575
+ if (!cell || (!cell.isFormula && !cell.content)) {
4548
4576
  return DEFAULT_CELL_HEIGHT;
4577
+ }
4549
4578
  const maxWidth = cell.style?.wrapping === "wrap" ? colSize - 2 * MIN_CELL_TEXT_MARGIN : undefined;
4550
4579
  const numberOfLines = cell.isFormula
4551
4580
  ? 1
@@ -9939,11 +9968,11 @@ stores.inject(MyMetaStore, storeInstance);
9939
9968
  }
9940
9969
  else {
9941
9970
  const range = this.getters.getRangeFromSheetXC(position.sheetId, rule.criterion.values[0]);
9942
- values = this.getters
9971
+ values = Array.from(new Set(this.getters
9943
9972
  .getRangeValues(range)
9944
9973
  .filter(isNotNull)
9945
9974
  .map((value) => value.toString())
9946
- .filter((val) => val !== "");
9975
+ .filter((val) => val !== "")));
9947
9976
  }
9948
9977
  return values.map((value) => ({ text: value }));
9949
9978
  },
@@ -19390,10 +19419,10 @@ stores.inject(MyMetaStore, storeInstance);
19390
19419
  }
19391
19420
  }
19392
19421
  return {
19393
- labels: Object.keys(labelMap),
19422
+ labels: Array.from(labelSet),
19394
19423
  dataSetsValues: datasets.map((dataset, indexOfDataset) => ({
19395
19424
  ...dataset,
19396
- data: Object.values(labelMap).map((dataOfLabel) => dataOfLabel[indexOfDataset]),
19425
+ data: Array.from(labelSet).map((label) => labelMap[label][indexOfDataset]),
19397
19426
  })),
19398
19427
  };
19399
19428
  }
@@ -20125,7 +20154,7 @@ stores.inject(MyMetaStore, storeInstance);
20125
20154
  return undefined;
20126
20155
  }
20127
20156
  const labelsTimestamps = labelDates.map((date) => date.getTime());
20128
- const period = Math.max(...labelsTimestamps) - Math.min(...labelsTimestamps);
20157
+ const period = largeMax(labelsTimestamps) - largeMin(labelsTimestamps);
20129
20158
  const minUnit = getFormatMinDisplayUnit(format);
20130
20159
  if (UNIT_LENGTH.second >= UNIT_LENGTH[minUnit] && Milliseconds.inSeconds(period) < 180) {
20131
20160
  return "second";
@@ -20613,7 +20642,7 @@ stores.inject(MyMetaStore, storeInstance);
20613
20642
  }
20614
20643
  function getPieColors(colors, dataSetsValues) {
20615
20644
  const pieColors = [];
20616
- const maxLength = Math.max(...dataSetsValues.map((ds) => ds.data.length));
20645
+ const maxLength = largeMax(dataSetsValues.map((ds) => ds.data.length));
20617
20646
  for (let i = 0; i <= maxLength; i++) {
20618
20647
  pieColors.push(colors.next());
20619
20648
  }
@@ -23418,8 +23447,8 @@ stores.inject(MyMetaStore, storeInstance);
23418
23447
  let last;
23419
23448
  const activesRows = env.model.getters.getActiveRows();
23420
23449
  if (activesRows.size !== 0) {
23421
- first = Math.min(...activesRows);
23422
- last = Math.max(...activesRows);
23450
+ first = largeMin([...activesRows]);
23451
+ last = largeMax([...activesRows]);
23423
23452
  }
23424
23453
  else {
23425
23454
  const zone = env.model.getters.getSelectedZones()[0];
@@ -23447,8 +23476,8 @@ stores.inject(MyMetaStore, storeInstance);
23447
23476
  let last;
23448
23477
  const activeCols = env.model.getters.getActiveCols();
23449
23478
  if (activeCols.size !== 0) {
23450
- first = Math.min(...activeCols);
23451
- last = Math.max(...activeCols);
23479
+ first = largeMin([...activeCols]);
23480
+ last = largeMax([...activeCols]);
23452
23481
  }
23453
23482
  else {
23454
23483
  const zone = env.model.getters.getSelectedZones()[0];
@@ -23476,8 +23505,8 @@ stores.inject(MyMetaStore, storeInstance);
23476
23505
  let last;
23477
23506
  const activesRows = env.model.getters.getActiveRows();
23478
23507
  if (activesRows.size !== 0) {
23479
- first = Math.min(...activesRows);
23480
- last = Math.max(...activesRows);
23508
+ first = largeMin([...activesRows]);
23509
+ last = largeMax([...activesRows]);
23481
23510
  }
23482
23511
  else {
23483
23512
  const zone = env.model.getters.getSelectedZones()[0];
@@ -23518,8 +23547,8 @@ stores.inject(MyMetaStore, storeInstance);
23518
23547
  let last;
23519
23548
  const activeCols = env.model.getters.getActiveCols();
23520
23549
  if (activeCols.size !== 0) {
23521
- first = Math.min(...activeCols);
23522
- last = Math.max(...activeCols);
23550
+ first = largeMin([...activeCols]);
23551
+ last = largeMax([...activeCols]);
23523
23552
  }
23524
23553
  else {
23525
23554
  const zone = env.model.getters.getSelectedZones()[0];
@@ -23560,7 +23589,7 @@ stores.inject(MyMetaStore, storeInstance);
23560
23589
  let row;
23561
23590
  let quantity;
23562
23591
  if (activeRows.size) {
23563
- row = Math.min(...activeRows);
23592
+ row = largeMin([...activeRows]);
23564
23593
  quantity = activeRows.size;
23565
23594
  }
23566
23595
  else {
@@ -23581,7 +23610,7 @@ stores.inject(MyMetaStore, storeInstance);
23581
23610
  let row;
23582
23611
  let quantity;
23583
23612
  if (activeRows.size) {
23584
- row = Math.max(...activeRows);
23613
+ row = largeMax([...activeRows]);
23585
23614
  quantity = activeRows.size;
23586
23615
  }
23587
23616
  else {
@@ -23602,7 +23631,7 @@ stores.inject(MyMetaStore, storeInstance);
23602
23631
  let column;
23603
23632
  let quantity;
23604
23633
  if (activeCols.size) {
23605
- column = Math.min(...activeCols);
23634
+ column = largeMin([...activeCols]);
23606
23635
  quantity = activeCols.size;
23607
23636
  }
23608
23637
  else {
@@ -23623,7 +23652,7 @@ stores.inject(MyMetaStore, storeInstance);
23623
23652
  let column;
23624
23653
  let quantity;
23625
23654
  if (activeCols.size) {
23626
- column = Math.max(...activeCols);
23655
+ column = largeMax([...activeCols]);
23627
23656
  quantity = activeCols.size;
23628
23657
  }
23629
23658
  else {
@@ -30222,7 +30251,11 @@ stores.inject(MyMetaStore, storeInstance);
30222
30251
  const composerStore = useStore(ComposerStore);
30223
30252
  // The feature makes no sense if we are editing a cell, because then the selection isn't active
30224
30253
  // Stop the edition when the panel is mounted, and close the panel if the user start editing a cell
30225
- owl.useEffect(this.props.onCloseSidePanel, () => [composerStore.editionMode]);
30254
+ owl.useEffect((editionMode) => {
30255
+ if (editionMode !== "inactive") {
30256
+ this.props.onCloseSidePanel();
30257
+ }
30258
+ }, () => [composerStore.editionMode]);
30226
30259
  owl.onMounted(() => {
30227
30260
  composerStore.stopEdition();
30228
30261
  });
@@ -32018,6 +32051,12 @@ stores.inject(MyMetaStore, storeInstance);
32018
32051
  owl.useEffect(() => {
32019
32052
  this.processContent();
32020
32053
  });
32054
+ owl.onPatched(() => {
32055
+ // Required because typing '=SUM' and double-clicking another cell leaves ShowProvider/ShowDescription true
32056
+ if (this.composerStore.editionMode === "inactive") {
32057
+ this.processTokenAtCursor();
32058
+ }
32059
+ });
32021
32060
  }
32022
32061
  // ---------------------------------------------------------------------------
32023
32062
  // Handlers
@@ -33998,11 +34037,6 @@ stores.inject(MyMetaStore, storeInstance);
33998
34037
  height: 10000px;
33999
34038
  background-color: ${SELECTION_BORDER_COLOR};
34000
34039
  }
34001
- .o-unhide-buttons {
34002
- width: fit-content;
34003
- gap: 5px;
34004
- transform: translate(-50%, 0);
34005
- }
34006
34040
  .o-unhide:hover {
34007
34041
  z-index: ${ComponentsImportance.Grid + 1};
34008
34042
  background-color: lightgrey;
@@ -34164,10 +34198,6 @@ stores.inject(MyMetaStore, storeInstance);
34164
34198
  height: 1px;
34165
34199
  background-color: ${SELECTION_BORDER_COLOR};
34166
34200
  }
34167
- .o-unhide-buttons {
34168
- height: fit-content;
34169
- transform: translate(0, -50%);
34170
- }
34171
34201
  .o-unhide:hover {
34172
34202
  z-index: ${ComponentsImportance.Grid + 1};
34173
34203
  background-color: lightgrey;
@@ -37861,7 +37891,7 @@ stores.inject(MyMetaStore, storeInstance);
37861
37891
  function getSheetDims(sheet) {
37862
37892
  const dims = [0, 0];
37863
37893
  for (let row of sheet.rows) {
37864
- dims[0] = Math.max(dims[0], ...row.cells.map((cell) => toCartesian(cell.xc).col));
37894
+ dims[0] = Math.max(dims[0], largeMax(row.cells.map((cell) => toCartesian(cell.xc).col)));
37865
37895
  dims[1] = Math.max(dims[1], row.index);
37866
37896
  }
37867
37897
  dims[0] = Math.max(dims[0], EXCEL_IMPORT_DEFAULT_NUMBER_OF_COLS);
@@ -42368,6 +42398,9 @@ stores.inject(MyMetaStore, storeInstance);
42368
42398
  if (newRule.criterion.type === "isBoolean") {
42369
42399
  this.setCenterStyleToBooleanCells(newRule);
42370
42400
  }
42401
+ else if (newRule.criterion.type === "isValueInList") {
42402
+ newRule.criterion.values = Array.from(new Set(newRule.criterion.values));
42403
+ }
42371
42404
  const adaptedRules = this.removeRangesFromRules(sheetId, newRule.ranges, rules);
42372
42405
  const ruleIndex = adaptedRules.findIndex((rule) => rule.id === newRule.id);
42373
42406
  if (ruleIndex !== -1) {
@@ -42764,7 +42797,7 @@ stores.inject(MyMetaStore, storeInstance);
42764
42797
  if (hiddenElements.size >= elements) {
42765
42798
  return "TooManyHiddenElements" /* CommandResult.TooManyHiddenElements */;
42766
42799
  }
42767
- else if (Math.min(...cmd.elements) < 0 || Math.max(...cmd.elements) > elements) {
42800
+ else if (largeMin(cmd.elements) < 0 || largeMax(cmd.elements) > elements) {
42768
42801
  return "InvalidHeaderIndex" /* CommandResult.InvalidHeaderIndex */;
42769
42802
  }
42770
42803
  else {
@@ -43582,8 +43615,8 @@ stores.inject(MyMetaStore, storeInstance);
43582
43615
  let newRange = range;
43583
43616
  let changeType = "NONE";
43584
43617
  for (let group of groups) {
43585
- const min = Math.min(...group);
43586
- const max = Math.max(...group);
43618
+ const min = largeMin(group);
43619
+ const max = largeMax(group);
43587
43620
  if (range.zone[start] <= min && min <= range.zone[end]) {
43588
43621
  const toRemove = Math.min(range.zone[end], max) - min + 1;
43589
43622
  changeType = "RESIZE";
@@ -44032,8 +44065,8 @@ stores.inject(MyMetaStore, storeInstance);
44032
44065
  }
44033
44066
  return "Success" /* CommandResult.Success */;
44034
44067
  case "REMOVE_COLUMNS_ROWS": {
44035
- const min = Math.min(...cmd.elements);
44036
- const max = Math.max(...cmd.elements);
44068
+ const min = largeMin(cmd.elements);
44069
+ const max = largeMax(cmd.elements);
44037
44070
  if (min < 0 || !this.doesHeaderExist(cmd.sheetId, cmd.dimension, max)) {
44038
44071
  return "InvalidHeaderIndex" /* CommandResult.InvalidHeaderIndex */;
44039
44072
  }
@@ -47497,7 +47530,7 @@ stores.inject(MyMetaStore, storeInstance);
47497
47530
  ? getItemId(newFormat, data.formats)
47498
47531
  : exportedCellData.format;
47499
47532
  let content;
47500
- if (formulaCell instanceof FormulaCellWithDependencies) {
47533
+ if (isFormula && formulaCell instanceof FormulaCellWithDependencies) {
47501
47534
  content = formulaCell.contentWithFixedReferences;
47502
47535
  }
47503
47536
  else {
@@ -47946,13 +47979,13 @@ stores.inject(MyMetaStore, storeInstance);
47946
47979
  .map((cell) => cell.value);
47947
47980
  switch (threshold.type) {
47948
47981
  case "value":
47949
- const result = functionName === "max" ? Math.max(...rangeValues) : Math.min(...rangeValues);
47982
+ const result = functionName === "max" ? largeMax(rangeValues) : largeMin(rangeValues);
47950
47983
  return result;
47951
47984
  case "number":
47952
47985
  return Number(threshold.value);
47953
47986
  case "percentage":
47954
- const min = Math.min(...rangeValues);
47955
- const max = Math.max(...rangeValues);
47987
+ const min = largeMin(rangeValues);
47988
+ const max = largeMax(rangeValues);
47956
47989
  const delta = max - min;
47957
47990
  return min + (delta * Number(threshold.value)) / 100;
47958
47991
  case "percentile":
@@ -49025,13 +49058,13 @@ stores.inject(MyMetaStore, storeInstance);
49025
49058
  const cells = this.getters.getEvaluatedCellsInZone(sheet.id, zone);
49026
49059
  const cellPositions = range(end, -1, -1);
49027
49060
  const invalidCells = cellPositions.filter((position) => cells[position] && !cells[position].isAutoSummable);
49028
- const maxValidPosition = Math.max(...invalidCells);
49061
+ const maxValidPosition = largeMax(invalidCells);
49029
49062
  const numberSequences = groupConsecutive(cellPositions.filter((position) => this.isNumber(cells[position])));
49030
49063
  const firstSequence = numberSequences[0] || [];
49031
- if (Math.max(...firstSequence) < maxValidPosition) {
49064
+ if (largeMax(firstSequence) < maxValidPosition) {
49032
49065
  return Infinity;
49033
49066
  }
49034
- return Math.min(...firstSequence);
49067
+ return largeMin(firstSequence);
49035
49068
  }
49036
49069
  shouldFindData(sheetId, zone) {
49037
49070
  return this.getters.isEmpty(sheetId, zone) || this.getters.isSingleCellOrMerge(sheetId, zone);
@@ -50772,7 +50805,7 @@ stores.inject(MyMetaStore, storeInstance);
50772
50805
  getColMaxWidth(sheetId, index) {
50773
50806
  const cellsPositions = positions(this.getters.getColsZone(sheetId, index, index));
50774
50807
  const sizes = cellsPositions.map((position) => this.getCellWidth({ sheetId, ...position }));
50775
- return Math.max(0, ...sizes);
50808
+ return Math.max(0, largeMax(sizes));
50776
50809
  }
50777
50810
  /**
50778
50811
  * Check that any "sheetId" in the command matches an existing
@@ -53668,7 +53701,7 @@ stores.inject(MyMetaStore, storeInstance);
53668
53701
  * column of the current viewport
53669
53702
  */
53670
53703
  getColDimensionsInViewport(sheetId, col) {
53671
- const left = Math.min(...this.getters.getSheetViewVisibleCols());
53704
+ const left = largeMin(this.getters.getSheetViewVisibleCols());
53672
53705
  const start = this.getters.getColRowOffsetInViewport("COL", left, col);
53673
53706
  const size = this.getters.getColSize(sheetId, col);
53674
53707
  const isColHidden = this.getters.isColHidden(sheetId, col);
@@ -53683,7 +53716,7 @@ stores.inject(MyMetaStore, storeInstance);
53683
53716
  * of the current viewport
53684
53717
  */
53685
53718
  getRowDimensionsInViewport(sheetId, row) {
53686
- const top = Math.min(...this.getters.getSheetViewVisibleRows());
53719
+ const top = largeMin(this.getters.getSheetViewVisibleRows());
53687
53720
  const start = this.getters.getColRowOffsetInViewport("ROW", top, row);
53688
53721
  const size = this.getters.getRowSize(sheetId, row);
53689
53722
  const isRowHidden = this.getters.isRowHidden(sheetId, row);
@@ -54396,12 +54429,14 @@ stores.inject(MyMetaStore, storeInstance);
54396
54429
  this.editionState = "initializing";
54397
54430
  }
54398
54431
  stopEdition() {
54399
- if (!this.state.isEditing)
54432
+ const input = this.sheetNameRef.el;
54433
+ if (!this.state.isEditing || !input)
54400
54434
  return;
54401
54435
  this.state.isEditing = false;
54402
54436
  this.editionState = "initializing";
54403
- this.sheetNameRef.el?.blur();
54437
+ input.blur();
54404
54438
  const inputValue = this.getInputContent() || "";
54439
+ input.innerText = inputValue;
54405
54440
  interactiveRenameSheet(this.env, this.props.sheetId, inputValue, () => this.startEdition());
54406
54441
  }
54407
54442
  cancelEdition() {
@@ -54692,7 +54727,7 @@ stores.inject(MyMetaStore, storeInstance);
54692
54727
  this.sheetListRef.el.scrollTo({ top: 0, left: scroll, behavior: "smooth" });
54693
54728
  }
54694
54729
  onSheetMouseDown(sheetId, event) {
54695
- if (event.button !== 0)
54730
+ if (event.button !== 0 || this.env.model.getters.isReadonly())
54696
54731
  return;
54697
54732
  this.closeMenu();
54698
54733
  const visibleSheets = this.getVisibleSheets();
@@ -58146,7 +58181,7 @@ stores.inject(MyMetaStore, storeInstance);
58146
58181
  }
58147
58182
  function addDoughnutChart(chart, chartSheetIndex, data, { holeSize } = { holeSize: 50 }) {
58148
58183
  const colors = new ChartColors();
58149
- const maxLength = Math.max(...chart.dataSets.map((ds) => getRangeSize(ds.range, chartSheetIndex, data)));
58184
+ const maxLength = largeMax(chart.dataSets.map((ds) => getRangeSize(ds.range, chartSheetIndex, data)));
58150
58185
  const doughnutColors = range(0, maxLength).map(() => toXlsxHexColor(colors.next()));
58151
58186
  const dataSetsNodes = [];
58152
58187
  for (const [dsIndex, dataset] of Object.entries(chart.dataSets).reverse()) {
@@ -60176,9 +60211,9 @@ stores.inject(MyMetaStore, storeInstance);
60176
60211
  exports.tokenize = tokenize;
60177
60212
 
60178
60213
 
60179
- __info__.version = "17.2.1";
60180
- __info__.date = "2024-03-25T09:41:58.737Z";
60181
- __info__.hash = "f97284c";
60214
+ __info__.version = "17.2.2";
60215
+ __info__.date = "2024-04-05T14:01:19.824Z";
60216
+ __info__.hash = "c15836d";
60182
60217
 
60183
60218
 
60184
60219
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);