@odoo/o-spreadsheet 17.0.34 → 17.0.36

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.0.34
6
- * @date 2024-08-09T12:20:17.042Z
7
- * @hash 1573912
5
+ * @version 17.0.36
6
+ * @date 2024-08-26T13:49:04.635Z
7
+ * @hash 6d5069e
8
8
  */
9
9
 
10
10
  (function (exports, owl) {
@@ -1954,6 +1954,7 @@
1954
1954
  "UPDATE_CELL",
1955
1955
  "UPDATE_CELL_POSITION",
1956
1956
  "CLEAR_CELL",
1957
+ "CLEAR_CELLS",
1957
1958
  "DELETE_CONTENT",
1958
1959
  /** GRID SHAPE */
1959
1960
  "ADD_COLUMNS_ROWS",
@@ -35187,7 +35188,7 @@
35187
35188
  }
35188
35189
  function parseTokens(tokens) {
35189
35190
  tokens = tokens.filter((x) => x.type !== "SPACE");
35190
- if (tokens[0].value === "=") {
35191
+ if (tokens[0]?.value === "=") {
35191
35192
  tokens.splice(0, 1);
35192
35193
  }
35193
35194
  const result = parseExpression(tokens);
@@ -35777,6 +35778,9 @@
35777
35778
  format: "",
35778
35779
  });
35779
35780
  break;
35781
+ case "CLEAR_CELLS":
35782
+ this.clearCells(cmd.sheetId, cmd.target);
35783
+ break;
35780
35784
  }
35781
35785
  }
35782
35786
  /**
@@ -35815,6 +35819,25 @@
35815
35819
  }
35816
35820
  }
35817
35821
  }
35822
+ /**
35823
+ * Clear the styles, the format and the content of zones
35824
+ */
35825
+ clearCells(sheetId, zones) {
35826
+ for (const zone of zones) {
35827
+ for (let col = zone.left; col <= zone.right; col++) {
35828
+ for (let row = zone.top; row <= zone.bottom; row++) {
35829
+ this.dispatch("UPDATE_CELL", {
35830
+ sheetId: sheetId,
35831
+ col,
35832
+ row,
35833
+ content: "",
35834
+ style: null,
35835
+ format: "",
35836
+ });
35837
+ }
35838
+ }
35839
+ }
35840
+ }
35818
35841
  /**
35819
35842
  * Copy the style of the reference column/row to the new columns/rows.
35820
35843
  */
@@ -37514,7 +37537,10 @@
37514
37537
  handle(cmd) {
37515
37538
  switch (cmd.type) {
37516
37539
  case "CREATE_SHEET": {
37517
- this.history.update("sizes", cmd.sheetId, { COL: [], ROW: [] });
37540
+ this.history.update("sizes", cmd.sheetId, {
37541
+ COL: Array(this.getters.getNumberCols(cmd.sheetId)).fill(undefined),
37542
+ ROW: Array(this.getters.getNumberRows(cmd.sheetId)).fill(undefined),
37543
+ });
37518
37544
  break;
37519
37545
  }
37520
37546
  case "DUPLICATE_SHEET":
@@ -39547,19 +39573,23 @@
39547
39573
  }
39548
39574
  }
39549
39575
  moveCellOnColumnsDeletion(sheet, deletedColumn) {
39576
+ this.dispatch("CLEAR_CELLS", {
39577
+ sheetId: sheet.id,
39578
+ target: [
39579
+ {
39580
+ left: deletedColumn,
39581
+ top: 0,
39582
+ right: deletedColumn,
39583
+ bottom: sheet.rows.length - 1,
39584
+ },
39585
+ ],
39586
+ });
39550
39587
  for (let rowIndex = 0; rowIndex < sheet.rows.length; rowIndex++) {
39551
39588
  const row = sheet.rows[rowIndex];
39552
39589
  for (let i in row.cells) {
39553
39590
  const colIndex = Number(i);
39554
39591
  const cellId = row.cells[i];
39555
39592
  if (cellId) {
39556
- if (colIndex === deletedColumn) {
39557
- this.dispatch("CLEAR_CELL", {
39558
- sheetId: sheet.id,
39559
- col: colIndex,
39560
- row: rowIndex,
39561
- });
39562
- }
39563
39593
  if (colIndex > deletedColumn) {
39564
39594
  this.setNewPosition(cellId, sheet.id, colIndex - 1, rowIndex);
39565
39595
  }
@@ -39605,22 +39635,20 @@
39605
39635
  *
39606
39636
  */
39607
39637
  moveCellOnRowsDeletion(sheet, deleteFromRow, deleteToRow) {
39638
+ this.dispatch("CLEAR_CELLS", {
39639
+ sheetId: sheet.id,
39640
+ target: [
39641
+ {
39642
+ left: 0,
39643
+ top: deleteFromRow,
39644
+ right: this.getters.getNumberCols(sheet.id),
39645
+ bottom: deleteToRow,
39646
+ },
39647
+ ],
39648
+ });
39608
39649
  const numberRows = deleteToRow - deleteFromRow + 1;
39609
39650
  for (let rowIndex = 0; rowIndex < sheet.rows.length; rowIndex++) {
39610
39651
  const row = sheet.rows[rowIndex];
39611
- if (rowIndex >= deleteFromRow && rowIndex <= deleteToRow) {
39612
- for (let i in row.cells) {
39613
- const colIndex = Number(i);
39614
- const cellId = row.cells[i];
39615
- if (cellId) {
39616
- this.dispatch("CLEAR_CELL", {
39617
- sheetId: sheet.id,
39618
- col: colIndex,
39619
- row: rowIndex,
39620
- });
39621
- }
39622
- }
39623
- }
39624
39652
  if (rowIndex > deleteToRow) {
39625
39653
  for (let i in row.cells) {
39626
39654
  const colIndex = Number(i);
@@ -44456,7 +44484,7 @@
44456
44484
  */
44457
44485
  leave(data) {
44458
44486
  if (Object.keys(this.clients).length === 1 && this.processedRevisions.size) {
44459
- this.snapshot(data);
44487
+ this.snapshot(data());
44460
44488
  }
44461
44489
  delete this.clients[this.clientId];
44462
44490
  this.transportService.leave(this.clientId);
@@ -45127,13 +45155,10 @@
45127
45155
  * Clear the clipped zones: remove the cells and clear the formatting
45128
45156
  */
45129
45157
  clearClippedZones() {
45130
- for (const row of this.cells) {
45131
- for (const cell of row) {
45132
- if (cell?.cell) {
45133
- this.dispatch("CLEAR_CELL", cell.position);
45134
- }
45135
- }
45136
- }
45158
+ this.dispatch("CLEAR_CELLS", {
45159
+ sheetId: this.sheetId,
45160
+ target: this.zones,
45161
+ });
45137
45162
  this.dispatch("CLEAR_FORMATTING", {
45138
45163
  sheetId: this.sheetId,
45139
45164
  target: this.zones,
@@ -45182,9 +45207,7 @@
45182
45207
  const { sheetId, col, row } = target;
45183
45208
  const targetCell = this.getters.getEvaluatedCell(target);
45184
45209
  if (clipboardOption?.pasteOption === "onlyValue") {
45185
- const locale = this.getters.getLocale();
45186
- const content = formatValue(origin.evaluatedCell.value, { locale });
45187
- this.dispatch("UPDATE_CELL", { ...target, content });
45210
+ this.dispatch("UPDATE_CELL", { ...target, content: origin.evaluatedCell.value.toString() });
45188
45211
  return;
45189
45212
  }
45190
45213
  const targetBorders = this.getters.getCellBorder(target);
@@ -45481,9 +45504,7 @@
45481
45504
  bottom: rowIndex,
45482
45505
  }));
45483
45506
  const state = new ClipboardCellsState(rowsToKeep, "COPY", this.getters, this.dispatch, this.selection);
45484
- for (const { col, row } of positions(zone)) {
45485
- this.dispatch("CLEAR_CELL", { col, row, sheetId });
45486
- }
45507
+ this.dispatch("CLEAR_CELLS", { target: [zone], sheetId });
45487
45508
  const zonePasted = {
45488
45509
  left: zone.left,
45489
45510
  top: zone.top,
@@ -47555,6 +47576,9 @@
47555
47576
  if (showFormula && cell?.isFormula) {
47556
47577
  return localizeFormula(cell.content, this.getters.getLocale());
47557
47578
  }
47579
+ else if (showFormula && !cell?.content) {
47580
+ return "";
47581
+ }
47558
47582
  else {
47559
47583
  return this.getters.getEvaluatedCell(position).formattedValue;
47560
47584
  }
@@ -47750,6 +47774,7 @@
47750
47774
  const repeatCommandTransformRegistry = new Registry();
47751
47775
  repeatCommandTransformRegistry.add("UPDATE_CELL", genericRepeat);
47752
47776
  repeatCommandTransformRegistry.add("CLEAR_CELL", genericRepeat);
47777
+ repeatCommandTransformRegistry.add("CLEAR_CELLS", genericRepeat);
47753
47778
  repeatCommandTransformRegistry.add("DELETE_CONTENT", genericRepeat);
47754
47779
  repeatCommandTransformRegistry.add("ADD_MERGE", genericRepeat);
47755
47780
  repeatCommandTransformRegistry.add("REMOVE_MERGE", genericRepeat);
@@ -48489,9 +48514,10 @@
48489
48514
  case "DELETE_CELL": {
48490
48515
  const { cut, paste } = this.getDeleteCellsTargets(cmd.zone, cmd.shiftDimension);
48491
48516
  if (!isZoneValid(cut[0])) {
48492
- for (const { col, row } of positions(cmd.zone)) {
48493
- this.dispatch("CLEAR_CELL", { col, row, sheetId: this.getters.getActiveSheetId() });
48494
- }
48517
+ this.dispatch("CLEAR_CELLS", {
48518
+ target: [cmd.zone],
48519
+ sheetId: this.getters.getActiveSheetId(),
48520
+ });
48495
48521
  break;
48496
48522
  }
48497
48523
  const state = this.getClipboardStateForCopyCells(cut, "CUT");
@@ -57092,7 +57118,7 @@
57092
57118
  this.session.join(this.config.client);
57093
57119
  }
57094
57120
  leaveSession() {
57095
- this.session.leave(this.exportData());
57121
+ this.session.leave(lazy(() => this.exportData()));
57096
57122
  }
57097
57123
  setupUiPlugin(Plugin) {
57098
57124
  const plugin = new Plugin(this.uiPluginConfig);
@@ -57595,9 +57621,9 @@
57595
57621
  exports.tokenize = tokenize;
57596
57622
 
57597
57623
 
57598
- __info__.version = "17.0.34";
57599
- __info__.date = "2024-08-09T12:20:17.042Z";
57600
- __info__.hash = "1573912";
57624
+ __info__.version = "17.0.36";
57625
+ __info__.date = "2024-08-26T13:49:04.635Z";
57626
+ __info__.hash = "6d5069e";
57601
57627
 
57602
57628
 
57603
57629
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);