@odoo/o-spreadsheet 17.2.20 → 17.2.21

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.20
7
- * @date 2024-08-09T12:24:12.002Z
8
- * @hash d667a15
6
+ * @version 17.2.21
7
+ * @date 2024-08-19T08:10:10.580Z
8
+ * @hash fb17f9c
9
9
  */
10
10
 
11
11
  import { useEnv, useSubEnv, onWillUnmount, useComponent, status, Component, useRef, onMounted, useEffect, useState, onPatched, onWillPatch, onWillUpdateProps, useExternalListener, onWillStart, xml, useChildSubEnv, markRaw } from '@odoo/owl';
@@ -1936,6 +1936,7 @@ const coreTypes = new Set([
1936
1936
  "UPDATE_CELL",
1937
1937
  "UPDATE_CELL_POSITION",
1938
1938
  "CLEAR_CELL",
1939
+ "CLEAR_CELLS",
1939
1940
  "DELETE_CONTENT",
1940
1941
  /** GRID SHAPE */
1941
1942
  "ADD_COLUMNS_ROWS",
@@ -5755,13 +5756,10 @@ class CellClipboardHandler extends AbstractCellClipboardHandler {
5755
5756
  * Clear the clipped zones: remove the cells and clear the formatting
5756
5757
  */
5757
5758
  clearClippedZones(content) {
5758
- for (const row of content.cells) {
5759
- for (const cell of row) {
5760
- if (cell.cell) {
5761
- this.dispatch("CLEAR_CELL", cell.position);
5762
- }
5763
- }
5764
- }
5759
+ this.dispatch("CLEAR_CELLS", {
5760
+ sheetId: content.sheetId,
5761
+ target: content.zones,
5762
+ });
5765
5763
  this.dispatch("CLEAR_FORMATTING", {
5766
5764
  sheetId: content.sheetId,
5767
5765
  target: content.zones,
@@ -6751,7 +6749,7 @@ function parse(str) {
6751
6749
  }
6752
6750
  function parseTokens(tokens) {
6753
6751
  tokens = tokens.filter((x) => x.type !== "SPACE");
6754
- if (tokens[0].value === "=") {
6752
+ if (tokens[0]?.value === "=") {
6755
6753
  tokens.splice(0, 1);
6756
6754
  }
6757
6755
  const result = parseExpression(tokens);
@@ -41534,6 +41532,9 @@ class CellPlugin extends CorePlugin {
41534
41532
  format: "",
41535
41533
  });
41536
41534
  break;
41535
+ case "CLEAR_CELLS":
41536
+ this.clearCells(cmd.sheetId, cmd.target);
41537
+ break;
41537
41538
  case "DELETE_CONTENT":
41538
41539
  this.clearZones(cmd.sheetId, cmd.target);
41539
41540
  break;
@@ -41592,6 +41593,25 @@ class CellPlugin extends CorePlugin {
41592
41593
  }
41593
41594
  }
41594
41595
  }
41596
+ /**
41597
+ * Clear the styles, the format and the content of zones
41598
+ */
41599
+ clearCells(sheetId, zones) {
41600
+ for (const zone of zones) {
41601
+ for (let col = zone.left; col <= zone.right; col++) {
41602
+ for (let row = zone.top; row <= zone.bottom; row++) {
41603
+ this.dispatch("UPDATE_CELL", {
41604
+ sheetId: sheetId,
41605
+ col,
41606
+ row,
41607
+ content: "",
41608
+ style: null,
41609
+ format: "",
41610
+ });
41611
+ }
41612
+ }
41613
+ }
41614
+ }
41595
41615
  /**
41596
41616
  * Copy the style of the reference column/row to the new columns/rows.
41597
41617
  */
@@ -45018,19 +45038,23 @@ class SheetPlugin extends CorePlugin {
45018
45038
  }
45019
45039
  }
45020
45040
  moveCellOnColumnsDeletion(sheet, deletedColumn) {
45041
+ this.dispatch("CLEAR_CELLS", {
45042
+ sheetId: sheet.id,
45043
+ target: [
45044
+ {
45045
+ left: deletedColumn,
45046
+ top: 0,
45047
+ right: deletedColumn,
45048
+ bottom: sheet.rows.length - 1,
45049
+ },
45050
+ ],
45051
+ });
45021
45052
  for (let rowIndex = 0; rowIndex < sheet.rows.length; rowIndex++) {
45022
45053
  const row = sheet.rows[rowIndex];
45023
45054
  for (let i in row.cells) {
45024
45055
  const colIndex = Number(i);
45025
45056
  const cellId = row.cells[i];
45026
45057
  if (cellId) {
45027
- if (colIndex === deletedColumn) {
45028
- this.dispatch("CLEAR_CELL", {
45029
- sheetId: sheet.id,
45030
- col: colIndex,
45031
- row: rowIndex,
45032
- });
45033
- }
45034
45058
  if (colIndex > deletedColumn) {
45035
45059
  this.setNewPosition(cellId, sheet.id, colIndex - 1, rowIndex);
45036
45060
  }
@@ -45076,22 +45100,20 @@ class SheetPlugin extends CorePlugin {
45076
45100
  *
45077
45101
  */
45078
45102
  moveCellOnRowsDeletion(sheet, deleteFromRow, deleteToRow) {
45103
+ this.dispatch("CLEAR_CELLS", {
45104
+ sheetId: sheet.id,
45105
+ target: [
45106
+ {
45107
+ left: 0,
45108
+ top: deleteFromRow,
45109
+ right: this.getters.getNumberCols(sheet.id),
45110
+ bottom: deleteToRow,
45111
+ },
45112
+ ],
45113
+ });
45079
45114
  const numberRows = deleteToRow - deleteFromRow + 1;
45080
45115
  for (let rowIndex = 0; rowIndex < sheet.rows.length; rowIndex++) {
45081
45116
  const row = sheet.rows[rowIndex];
45082
- if (rowIndex >= deleteFromRow && rowIndex <= deleteToRow) {
45083
- for (let i in row.cells) {
45084
- const colIndex = Number(i);
45085
- const cellId = row.cells[i];
45086
- if (cellId) {
45087
- this.dispatch("CLEAR_CELL", {
45088
- sheetId: sheet.id,
45089
- col: colIndex,
45090
- row: rowIndex,
45091
- });
45092
- }
45093
- }
45094
- }
45095
45117
  if (rowIndex > deleteToRow) {
45096
45118
  for (let i in row.cells) {
45097
45119
  const colIndex = Number(i);
@@ -50407,7 +50429,7 @@ class Session extends EventBus {
50407
50429
  */
50408
50430
  leave(data) {
50409
50431
  if (Object.keys(this.clients).length === 1 && this.processedRevisions.size) {
50410
- this.snapshot(data);
50432
+ this.snapshot(data());
50411
50433
  }
50412
50434
  delete this.clients[this.clientId];
50413
50435
  this.transportService.leave(this.clientId);
@@ -50829,9 +50851,7 @@ class DataCleanupPlugin extends UIPlugin {
50829
50851
  if (!data) {
50830
50852
  return;
50831
50853
  }
50832
- for (const { col, row } of positions(zone)) {
50833
- this.dispatch("CLEAR_CELL", { col, row, sheetId });
50834
- }
50854
+ this.dispatch("CLEAR_CELLS", { target: [zone], sheetId });
50835
50855
  const zonePasted = {
50836
50856
  left: zone.left,
50837
50857
  top: zone.top,
@@ -51392,6 +51412,9 @@ class SheetUIPlugin extends UIPlugin {
51392
51412
  if (showFormula && cell?.isFormula) {
51393
51413
  return localizeFormula(cell.content, this.getters.getLocale());
51394
51414
  }
51415
+ else if (showFormula && !cell?.content) {
51416
+ return "";
51417
+ }
51395
51418
  else {
51396
51419
  return this.getters.getEvaluatedCell(position).formattedValue;
51397
51420
  }
@@ -51663,6 +51686,7 @@ function repeatGroupHeadersCommand(getters, cmd) {
51663
51686
  const repeatCommandTransformRegistry = new Registry();
51664
51687
  repeatCommandTransformRegistry.add("UPDATE_CELL", genericRepeat);
51665
51688
  repeatCommandTransformRegistry.add("CLEAR_CELL", genericRepeat);
51689
+ repeatCommandTransformRegistry.add("CLEAR_CELLS", genericRepeat);
51666
51690
  repeatCommandTransformRegistry.add("DELETE_CONTENT", genericRepeat);
51667
51691
  repeatCommandTransformRegistry.add("ADD_MERGE", genericRepeat);
51668
51692
  repeatCommandTransformRegistry.add("REMOVE_MERGE", genericRepeat);
@@ -52381,9 +52405,10 @@ class ClipboardPlugin extends UIPlugin {
52381
52405
  case "DELETE_CELL": {
52382
52406
  const { cut, paste } = this.getDeleteCellsTargets(cmd.zone, cmd.shiftDimension);
52383
52407
  if (!isZoneValid(cut[0])) {
52384
- for (const { col, row } of positions(cmd.zone)) {
52385
- this.dispatch("CLEAR_CELL", { col, row, sheetId: this.getters.getActiveSheetId() });
52386
- }
52408
+ this.dispatch("CLEAR_CELLS", {
52409
+ target: [cmd.zone],
52410
+ sheetId: this.getters.getActiveSheetId(),
52411
+ });
52387
52412
  break;
52388
52413
  }
52389
52414
  const copiedData = this.copy(cut);
@@ -60343,7 +60368,7 @@ class Model extends EventBus {
60343
60368
  this.session.join(this.config.client);
60344
60369
  }
60345
60370
  leaveSession() {
60346
- this.session.leave(this.exportData());
60371
+ this.session.leave(lazy(() => this.exportData()));
60347
60372
  }
60348
60373
  setupUiPlugin(Plugin) {
60349
60374
  const plugin = new Plugin(this.uiPluginConfig);
@@ -60856,6 +60881,6 @@ const constants = {
60856
60881
  export { AbstractCellClipboardHandler, AbstractChart, AbstractFigureClipboardHandler, CellErrorType, CommandResult, CorePlugin, DispatchResult, EvaluationError, Model, Registry, Revision, SPREADSHEET_DIMENSIONS, Spreadsheet, UIPlugin, __info__, addFunction, addRenderingLayer, astToFormula, compile, compileTokens, components, constants, convertAstNodes, coreTypes, findCellInNewZone, functionCache, helpers, hooks, invalidateCFEvaluationCommands, invalidateDependenciesCommands, invalidateEvaluationCommands, iterateAstNodes, links, load, parse, parseTokens, readonlyAllowedCommands, registries, setDefaultSheetViewSize, setTranslationMethod, stores, tokenColors, tokenize };
60857
60882
 
60858
60883
 
60859
- __info__.version = "17.2.20";
60860
- __info__.date = "2024-08-09T12:24:12.002Z";
60861
- __info__.hash = "d667a15";
60884
+ __info__.version = "17.2.21";
60885
+ __info__.date = "2024-08-19T08:10:10.580Z";
60886
+ __info__.hash = "fb17f9c";
@@ -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.20
7
- * @date 2024-08-09T12:24:12.002Z
8
- * @hash d667a15
6
+ * @version 17.2.21
7
+ * @date 2024-08-19T08:10:10.580Z
8
+ * @hash fb17f9c
9
9
  */
10
10
 
11
11
  (function (exports, owl) {
@@ -1937,6 +1937,7 @@
1937
1937
  "UPDATE_CELL",
1938
1938
  "UPDATE_CELL_POSITION",
1939
1939
  "CLEAR_CELL",
1940
+ "CLEAR_CELLS",
1940
1941
  "DELETE_CONTENT",
1941
1942
  /** GRID SHAPE */
1942
1943
  "ADD_COLUMNS_ROWS",
@@ -5756,13 +5757,10 @@
5756
5757
  * Clear the clipped zones: remove the cells and clear the formatting
5757
5758
  */
5758
5759
  clearClippedZones(content) {
5759
- for (const row of content.cells) {
5760
- for (const cell of row) {
5761
- if (cell.cell) {
5762
- this.dispatch("CLEAR_CELL", cell.position);
5763
- }
5764
- }
5765
- }
5760
+ this.dispatch("CLEAR_CELLS", {
5761
+ sheetId: content.sheetId,
5762
+ target: content.zones,
5763
+ });
5766
5764
  this.dispatch("CLEAR_FORMATTING", {
5767
5765
  sheetId: content.sheetId,
5768
5766
  target: content.zones,
@@ -6752,7 +6750,7 @@
6752
6750
  }
6753
6751
  function parseTokens(tokens) {
6754
6752
  tokens = tokens.filter((x) => x.type !== "SPACE");
6755
- if (tokens[0].value === "=") {
6753
+ if (tokens[0]?.value === "=") {
6756
6754
  tokens.splice(0, 1);
6757
6755
  }
6758
6756
  const result = parseExpression(tokens);
@@ -41535,6 +41533,9 @@ stores.inject(MyMetaStore, storeInstance);
41535
41533
  format: "",
41536
41534
  });
41537
41535
  break;
41536
+ case "CLEAR_CELLS":
41537
+ this.clearCells(cmd.sheetId, cmd.target);
41538
+ break;
41538
41539
  case "DELETE_CONTENT":
41539
41540
  this.clearZones(cmd.sheetId, cmd.target);
41540
41541
  break;
@@ -41593,6 +41594,25 @@ stores.inject(MyMetaStore, storeInstance);
41593
41594
  }
41594
41595
  }
41595
41596
  }
41597
+ /**
41598
+ * Clear the styles, the format and the content of zones
41599
+ */
41600
+ clearCells(sheetId, zones) {
41601
+ for (const zone of zones) {
41602
+ for (let col = zone.left; col <= zone.right; col++) {
41603
+ for (let row = zone.top; row <= zone.bottom; row++) {
41604
+ this.dispatch("UPDATE_CELL", {
41605
+ sheetId: sheetId,
41606
+ col,
41607
+ row,
41608
+ content: "",
41609
+ style: null,
41610
+ format: "",
41611
+ });
41612
+ }
41613
+ }
41614
+ }
41615
+ }
41596
41616
  /**
41597
41617
  * Copy the style of the reference column/row to the new columns/rows.
41598
41618
  */
@@ -45019,19 +45039,23 @@ stores.inject(MyMetaStore, storeInstance);
45019
45039
  }
45020
45040
  }
45021
45041
  moveCellOnColumnsDeletion(sheet, deletedColumn) {
45042
+ this.dispatch("CLEAR_CELLS", {
45043
+ sheetId: sheet.id,
45044
+ target: [
45045
+ {
45046
+ left: deletedColumn,
45047
+ top: 0,
45048
+ right: deletedColumn,
45049
+ bottom: sheet.rows.length - 1,
45050
+ },
45051
+ ],
45052
+ });
45022
45053
  for (let rowIndex = 0; rowIndex < sheet.rows.length; rowIndex++) {
45023
45054
  const row = sheet.rows[rowIndex];
45024
45055
  for (let i in row.cells) {
45025
45056
  const colIndex = Number(i);
45026
45057
  const cellId = row.cells[i];
45027
45058
  if (cellId) {
45028
- if (colIndex === deletedColumn) {
45029
- this.dispatch("CLEAR_CELL", {
45030
- sheetId: sheet.id,
45031
- col: colIndex,
45032
- row: rowIndex,
45033
- });
45034
- }
45035
45059
  if (colIndex > deletedColumn) {
45036
45060
  this.setNewPosition(cellId, sheet.id, colIndex - 1, rowIndex);
45037
45061
  }
@@ -45077,22 +45101,20 @@ stores.inject(MyMetaStore, storeInstance);
45077
45101
  *
45078
45102
  */
45079
45103
  moveCellOnRowsDeletion(sheet, deleteFromRow, deleteToRow) {
45104
+ this.dispatch("CLEAR_CELLS", {
45105
+ sheetId: sheet.id,
45106
+ target: [
45107
+ {
45108
+ left: 0,
45109
+ top: deleteFromRow,
45110
+ right: this.getters.getNumberCols(sheet.id),
45111
+ bottom: deleteToRow,
45112
+ },
45113
+ ],
45114
+ });
45080
45115
  const numberRows = deleteToRow - deleteFromRow + 1;
45081
45116
  for (let rowIndex = 0; rowIndex < sheet.rows.length; rowIndex++) {
45082
45117
  const row = sheet.rows[rowIndex];
45083
- if (rowIndex >= deleteFromRow && rowIndex <= deleteToRow) {
45084
- for (let i in row.cells) {
45085
- const colIndex = Number(i);
45086
- const cellId = row.cells[i];
45087
- if (cellId) {
45088
- this.dispatch("CLEAR_CELL", {
45089
- sheetId: sheet.id,
45090
- col: colIndex,
45091
- row: rowIndex,
45092
- });
45093
- }
45094
- }
45095
- }
45096
45118
  if (rowIndex > deleteToRow) {
45097
45119
  for (let i in row.cells) {
45098
45120
  const colIndex = Number(i);
@@ -50408,7 +50430,7 @@ stores.inject(MyMetaStore, storeInstance);
50408
50430
  */
50409
50431
  leave(data) {
50410
50432
  if (Object.keys(this.clients).length === 1 && this.processedRevisions.size) {
50411
- this.snapshot(data);
50433
+ this.snapshot(data());
50412
50434
  }
50413
50435
  delete this.clients[this.clientId];
50414
50436
  this.transportService.leave(this.clientId);
@@ -50830,9 +50852,7 @@ stores.inject(MyMetaStore, storeInstance);
50830
50852
  if (!data) {
50831
50853
  return;
50832
50854
  }
50833
- for (const { col, row } of positions(zone)) {
50834
- this.dispatch("CLEAR_CELL", { col, row, sheetId });
50835
- }
50855
+ this.dispatch("CLEAR_CELLS", { target: [zone], sheetId });
50836
50856
  const zonePasted = {
50837
50857
  left: zone.left,
50838
50858
  top: zone.top,
@@ -51393,6 +51413,9 @@ stores.inject(MyMetaStore, storeInstance);
51393
51413
  if (showFormula && cell?.isFormula) {
51394
51414
  return localizeFormula(cell.content, this.getters.getLocale());
51395
51415
  }
51416
+ else if (showFormula && !cell?.content) {
51417
+ return "";
51418
+ }
51396
51419
  else {
51397
51420
  return this.getters.getEvaluatedCell(position).formattedValue;
51398
51421
  }
@@ -51664,6 +51687,7 @@ stores.inject(MyMetaStore, storeInstance);
51664
51687
  const repeatCommandTransformRegistry = new Registry();
51665
51688
  repeatCommandTransformRegistry.add("UPDATE_CELL", genericRepeat);
51666
51689
  repeatCommandTransformRegistry.add("CLEAR_CELL", genericRepeat);
51690
+ repeatCommandTransformRegistry.add("CLEAR_CELLS", genericRepeat);
51667
51691
  repeatCommandTransformRegistry.add("DELETE_CONTENT", genericRepeat);
51668
51692
  repeatCommandTransformRegistry.add("ADD_MERGE", genericRepeat);
51669
51693
  repeatCommandTransformRegistry.add("REMOVE_MERGE", genericRepeat);
@@ -52382,9 +52406,10 @@ stores.inject(MyMetaStore, storeInstance);
52382
52406
  case "DELETE_CELL": {
52383
52407
  const { cut, paste } = this.getDeleteCellsTargets(cmd.zone, cmd.shiftDimension);
52384
52408
  if (!isZoneValid(cut[0])) {
52385
- for (const { col, row } of positions(cmd.zone)) {
52386
- this.dispatch("CLEAR_CELL", { col, row, sheetId: this.getters.getActiveSheetId() });
52387
- }
52409
+ this.dispatch("CLEAR_CELLS", {
52410
+ target: [cmd.zone],
52411
+ sheetId: this.getters.getActiveSheetId(),
52412
+ });
52388
52413
  break;
52389
52414
  }
52390
52415
  const copiedData = this.copy(cut);
@@ -60344,7 +60369,7 @@ stores.inject(MyMetaStore, storeInstance);
60344
60369
  this.session.join(this.config.client);
60345
60370
  }
60346
60371
  leaveSession() {
60347
- this.session.leave(this.exportData());
60372
+ this.session.leave(lazy(() => this.exportData()));
60348
60373
  }
60349
60374
  setupUiPlugin(Plugin) {
60350
60375
  const plugin = new Plugin(this.uiPluginConfig);
@@ -60898,9 +60923,9 @@ stores.inject(MyMetaStore, storeInstance);
60898
60923
  exports.tokenize = tokenize;
60899
60924
 
60900
60925
 
60901
- __info__.version = "17.2.20";
60902
- __info__.date = "2024-08-09T12:24:12.002Z";
60903
- __info__.hash = "d667a15";
60926
+ __info__.version = "17.2.21";
60927
+ __info__.date = "2024-08-19T08:10:10.580Z";
60928
+ __info__.hash = "fb17f9c";
60904
60929
 
60905
60930
 
60906
60931
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);