@odoo/o-spreadsheet 17.2.20 → 17.2.22

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.22
7
+ * @date 2024-08-26T13:48:03.927Z
8
+ * @hash 4157fb8
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);
@@ -29878,7 +29876,6 @@ class FindAndReplaceStore extends SpreadsheetStore {
29878
29876
  searchScope: "allSheets",
29879
29877
  specificRange: undefined,
29880
29878
  };
29881
- updateSearchContent = debounce(this._updateSearchContent.bind(this), 200);
29882
29879
  constructor(get) {
29883
29880
  super(get);
29884
29881
  this.initialShowFormulaState = this.model.getters.shouldShowFormulas();
@@ -29887,7 +29884,6 @@ class FindAndReplaceStore extends SpreadsheetStore {
29887
29884
  highlightStore.register(this);
29888
29885
  this.onDispose(() => {
29889
29886
  this.model.dispatch("SET_FORMULA_VISIBILITY", { show: this.initialShowFormulaState });
29890
- this.updateSearchContent.stopDebounce();
29891
29887
  highlightStore.unRegister(this);
29892
29888
  });
29893
29889
  }
@@ -29901,7 +29897,7 @@ class FindAndReplaceStore extends SpreadsheetStore {
29901
29897
  return this.specificRangeMatches;
29902
29898
  }
29903
29899
  }
29904
- _updateSearchContent(toSearch) {
29900
+ updateSearchContent(toSearch) {
29905
29901
  this._updateSearch(toSearch, this.searchOptions);
29906
29902
  }
29907
29903
  updateSearchOptions(searchOptions) {
@@ -29917,9 +29913,6 @@ class FindAndReplaceStore extends SpreadsheetStore {
29917
29913
  selectNextMatch() {
29918
29914
  this.selectNextCell(Direction.next);
29919
29915
  }
29920
- get pendingSearch() {
29921
- return this.updateSearchContent.isDebouncePending();
29922
- }
29923
29916
  handle(cmd) {
29924
29917
  switch (cmd.type) {
29925
29918
  case "SET_FORMULA_VISIBILITY":
@@ -30197,6 +30190,7 @@ class FindAndReplacePanel extends Component {
30197
30190
  searchInput = useRef("searchInput");
30198
30191
  store;
30199
30192
  state;
30193
+ updateSearchContent;
30200
30194
  get hasSearchResult() {
30201
30195
  return this.store.selectedMatchIndex !== null;
30202
30196
  }
@@ -30228,12 +30222,14 @@ class FindAndReplacePanel extends Component {
30228
30222
  this.store = useLocalStore(FindAndReplaceStore);
30229
30223
  this.state = useState({ dataRange: "" });
30230
30224
  onMounted(() => this.searchInput.el?.focus());
30225
+ onWillUnmount(() => this.updateSearchContent.stopDebounce());
30226
+ this.updateSearchContent = debounce(this.store.updateSearchContent, 200);
30231
30227
  }
30232
30228
  onFocusSearch() {
30233
30229
  this.updateDataRange();
30234
30230
  }
30235
30231
  onSearchInput(ev) {
30236
- this.store.updateSearchContent(ev.target?.value || "");
30232
+ this.updateSearchContent(ev.target.value);
30237
30233
  }
30238
30234
  onKeydownSearch(ev) {
30239
30235
  if (ev.key === "Enter") {
@@ -30272,6 +30268,9 @@ class FindAndReplacePanel extends Component {
30272
30268
  const specificRange = this.env.model.getters.getRangeFromSheetXC(this.env.model.getters.getActiveSheetId(), this.state.dataRange);
30273
30269
  this.store.updateSearchOptions({ specificRange });
30274
30270
  }
30271
+ get pendingSearch() {
30272
+ return this.updateSearchContent.isDebouncePending();
30273
+ }
30275
30274
  }
30276
30275
 
30277
30276
  css /* scss */ `
@@ -31074,10 +31073,6 @@ class TablePanel extends Component {
31074
31073
  });
31075
31074
  }
31076
31075
  onRangeChanged(ranges) {
31077
- if (!ranges[0] || !ranges[0].match(rangeReference)) {
31078
- this.state.tableZoneErrors = ["InvalidRange" /* CommandResult.InvalidRange */];
31079
- return;
31080
- }
31081
31076
  const sheetId = this.env.model.getters.getActiveSheetId();
31082
31077
  this.state.tableXc = ranges[0];
31083
31078
  this.state.tableZoneErrors = this.env.model.canDispatch("UPDATE_TABLE", {
@@ -31101,10 +31096,6 @@ class TablePanel extends Component {
31101
31096
  cell: position,
31102
31097
  });
31103
31098
  }
31104
- this.state.tableZoneErrors = [];
31105
- this.state.tableXc = result.isSuccessful
31106
- ? this.state.tableXc
31107
- : this.env.model.getters.getRangeString(this.props.table.range, sheetId);
31108
31099
  }
31109
31100
  deleteTable() {
31110
31101
  const sheetId = this.env.model.getters.getActiveSheetId();
@@ -41534,6 +41525,9 @@ class CellPlugin extends CorePlugin {
41534
41525
  format: "",
41535
41526
  });
41536
41527
  break;
41528
+ case "CLEAR_CELLS":
41529
+ this.clearCells(cmd.sheetId, cmd.target);
41530
+ break;
41537
41531
  case "DELETE_CONTENT":
41538
41532
  this.clearZones(cmd.sheetId, cmd.target);
41539
41533
  break;
@@ -41592,6 +41586,25 @@ class CellPlugin extends CorePlugin {
41592
41586
  }
41593
41587
  }
41594
41588
  }
41589
+ /**
41590
+ * Clear the styles, the format and the content of zones
41591
+ */
41592
+ clearCells(sheetId, zones) {
41593
+ for (const zone of zones) {
41594
+ for (let col = zone.left; col <= zone.right; col++) {
41595
+ for (let row = zone.top; row <= zone.bottom; row++) {
41596
+ this.dispatch("UPDATE_CELL", {
41597
+ sheetId: sheetId,
41598
+ col,
41599
+ row,
41600
+ content: "",
41601
+ style: null,
41602
+ format: "",
41603
+ });
41604
+ }
41605
+ }
41606
+ }
41607
+ }
41595
41608
  /**
41596
41609
  * Copy the style of the reference column/row to the new columns/rows.
41597
41610
  */
@@ -42976,7 +42989,10 @@ class HeaderSizePlugin extends CorePlugin {
42976
42989
  handle(cmd) {
42977
42990
  switch (cmd.type) {
42978
42991
  case "CREATE_SHEET": {
42979
- this.history.update("sizes", cmd.sheetId, { COL: [], ROW: [] });
42992
+ this.history.update("sizes", cmd.sheetId, {
42993
+ COL: Array(this.getters.getNumberCols(cmd.sheetId)).fill(undefined),
42994
+ ROW: Array(this.getters.getNumberRows(cmd.sheetId)).fill(undefined),
42995
+ });
42980
42996
  break;
42981
42997
  }
42982
42998
  case "DUPLICATE_SHEET":
@@ -45018,19 +45034,23 @@ class SheetPlugin extends CorePlugin {
45018
45034
  }
45019
45035
  }
45020
45036
  moveCellOnColumnsDeletion(sheet, deletedColumn) {
45037
+ this.dispatch("CLEAR_CELLS", {
45038
+ sheetId: sheet.id,
45039
+ target: [
45040
+ {
45041
+ left: deletedColumn,
45042
+ top: 0,
45043
+ right: deletedColumn,
45044
+ bottom: sheet.rows.length - 1,
45045
+ },
45046
+ ],
45047
+ });
45021
45048
  for (let rowIndex = 0; rowIndex < sheet.rows.length; rowIndex++) {
45022
45049
  const row = sheet.rows[rowIndex];
45023
45050
  for (let i in row.cells) {
45024
45051
  const colIndex = Number(i);
45025
45052
  const cellId = row.cells[i];
45026
45053
  if (cellId) {
45027
- if (colIndex === deletedColumn) {
45028
- this.dispatch("CLEAR_CELL", {
45029
- sheetId: sheet.id,
45030
- col: colIndex,
45031
- row: rowIndex,
45032
- });
45033
- }
45034
45054
  if (colIndex > deletedColumn) {
45035
45055
  this.setNewPosition(cellId, sheet.id, colIndex - 1, rowIndex);
45036
45056
  }
@@ -45076,22 +45096,20 @@ class SheetPlugin extends CorePlugin {
45076
45096
  *
45077
45097
  */
45078
45098
  moveCellOnRowsDeletion(sheet, deleteFromRow, deleteToRow) {
45099
+ this.dispatch("CLEAR_CELLS", {
45100
+ sheetId: sheet.id,
45101
+ target: [
45102
+ {
45103
+ left: 0,
45104
+ top: deleteFromRow,
45105
+ right: this.getters.getNumberCols(sheet.id),
45106
+ bottom: deleteToRow,
45107
+ },
45108
+ ],
45109
+ });
45079
45110
  const numberRows = deleteToRow - deleteFromRow + 1;
45080
45111
  for (let rowIndex = 0; rowIndex < sheet.rows.length; rowIndex++) {
45081
45112
  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
45113
  if (rowIndex > deleteToRow) {
45096
45114
  for (let i in row.cells) {
45097
45115
  const colIndex = Number(i);
@@ -50407,7 +50425,7 @@ class Session extends EventBus {
50407
50425
  */
50408
50426
  leave(data) {
50409
50427
  if (Object.keys(this.clients).length === 1 && this.processedRevisions.size) {
50410
- this.snapshot(data);
50428
+ this.snapshot(data());
50411
50429
  }
50412
50430
  delete this.clients[this.clientId];
50413
50431
  this.transportService.leave(this.clientId);
@@ -50829,9 +50847,7 @@ class DataCleanupPlugin extends UIPlugin {
50829
50847
  if (!data) {
50830
50848
  return;
50831
50849
  }
50832
- for (const { col, row } of positions(zone)) {
50833
- this.dispatch("CLEAR_CELL", { col, row, sheetId });
50834
- }
50850
+ this.dispatch("CLEAR_CELLS", { target: [zone], sheetId });
50835
50851
  const zonePasted = {
50836
50852
  left: zone.left,
50837
50853
  top: zone.top,
@@ -51392,6 +51408,9 @@ class SheetUIPlugin extends UIPlugin {
51392
51408
  if (showFormula && cell?.isFormula) {
51393
51409
  return localizeFormula(cell.content, this.getters.getLocale());
51394
51410
  }
51411
+ else if (showFormula && !cell?.content) {
51412
+ return "";
51413
+ }
51395
51414
  else {
51396
51415
  return this.getters.getEvaluatedCell(position).formattedValue;
51397
51416
  }
@@ -51663,6 +51682,7 @@ function repeatGroupHeadersCommand(getters, cmd) {
51663
51682
  const repeatCommandTransformRegistry = new Registry();
51664
51683
  repeatCommandTransformRegistry.add("UPDATE_CELL", genericRepeat);
51665
51684
  repeatCommandTransformRegistry.add("CLEAR_CELL", genericRepeat);
51685
+ repeatCommandTransformRegistry.add("CLEAR_CELLS", genericRepeat);
51666
51686
  repeatCommandTransformRegistry.add("DELETE_CONTENT", genericRepeat);
51667
51687
  repeatCommandTransformRegistry.add("ADD_MERGE", genericRepeat);
51668
51688
  repeatCommandTransformRegistry.add("REMOVE_MERGE", genericRepeat);
@@ -52338,6 +52358,7 @@ class ClipboardPlugin extends UIPlugin {
52338
52358
  this.status = "invisible";
52339
52359
  if (this._isCutOperation) {
52340
52360
  this.copiedData = undefined;
52361
+ this._isCutOperation = false;
52341
52362
  }
52342
52363
  break;
52343
52364
  }
@@ -52381,9 +52402,10 @@ class ClipboardPlugin extends UIPlugin {
52381
52402
  case "DELETE_CELL": {
52382
52403
  const { cut, paste } = this.getDeleteCellsTargets(cmd.zone, cmd.shiftDimension);
52383
52404
  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
- }
52405
+ this.dispatch("CLEAR_CELLS", {
52406
+ target: [cmd.zone],
52407
+ sheetId: this.getters.getActiveSheetId(),
52408
+ });
52387
52409
  break;
52388
52410
  }
52389
52411
  const copiedData = this.copy(cut);
@@ -52434,6 +52456,7 @@ class ClipboardPlugin extends UIPlugin {
52434
52456
  }
52435
52457
  case "ACTIVATE_PAINT_FORMAT": {
52436
52458
  const zones = this.getters.getSelectedZones();
52459
+ this._isCutOperation = false;
52437
52460
  this.copiedData = this.copy(zones);
52438
52461
  this.status = "visible";
52439
52462
  if (cmd.persistent) {
@@ -60343,7 +60366,7 @@ class Model extends EventBus {
60343
60366
  this.session.join(this.config.client);
60344
60367
  }
60345
60368
  leaveSession() {
60346
- this.session.leave(this.exportData());
60369
+ this.session.leave(lazy(() => this.exportData()));
60347
60370
  }
60348
60371
  setupUiPlugin(Plugin) {
60349
60372
  const plugin = new Plugin(this.uiPluginConfig);
@@ -60856,6 +60879,6 @@ const constants = {
60856
60879
  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
60880
 
60858
60881
 
60859
- __info__.version = "17.2.20";
60860
- __info__.date = "2024-08-09T12:24:12.002Z";
60861
- __info__.hash = "d667a15";
60882
+ __info__.version = "17.2.22";
60883
+ __info__.date = "2024-08-26T13:48:03.927Z";
60884
+ __info__.hash = "4157fb8";
@@ -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.22
7
+ * @date 2024-08-26T13:48:03.927Z
8
+ * @hash 4157fb8
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);
@@ -29879,7 +29877,6 @@ stores.inject(MyMetaStore, storeInstance);
29879
29877
  searchScope: "allSheets",
29880
29878
  specificRange: undefined,
29881
29879
  };
29882
- updateSearchContent = debounce(this._updateSearchContent.bind(this), 200);
29883
29880
  constructor(get) {
29884
29881
  super(get);
29885
29882
  this.initialShowFormulaState = this.model.getters.shouldShowFormulas();
@@ -29888,7 +29885,6 @@ stores.inject(MyMetaStore, storeInstance);
29888
29885
  highlightStore.register(this);
29889
29886
  this.onDispose(() => {
29890
29887
  this.model.dispatch("SET_FORMULA_VISIBILITY", { show: this.initialShowFormulaState });
29891
- this.updateSearchContent.stopDebounce();
29892
29888
  highlightStore.unRegister(this);
29893
29889
  });
29894
29890
  }
@@ -29902,7 +29898,7 @@ stores.inject(MyMetaStore, storeInstance);
29902
29898
  return this.specificRangeMatches;
29903
29899
  }
29904
29900
  }
29905
- _updateSearchContent(toSearch) {
29901
+ updateSearchContent(toSearch) {
29906
29902
  this._updateSearch(toSearch, this.searchOptions);
29907
29903
  }
29908
29904
  updateSearchOptions(searchOptions) {
@@ -29918,9 +29914,6 @@ stores.inject(MyMetaStore, storeInstance);
29918
29914
  selectNextMatch() {
29919
29915
  this.selectNextCell(Direction.next);
29920
29916
  }
29921
- get pendingSearch() {
29922
- return this.updateSearchContent.isDebouncePending();
29923
- }
29924
29917
  handle(cmd) {
29925
29918
  switch (cmd.type) {
29926
29919
  case "SET_FORMULA_VISIBILITY":
@@ -30198,6 +30191,7 @@ stores.inject(MyMetaStore, storeInstance);
30198
30191
  searchInput = owl.useRef("searchInput");
30199
30192
  store;
30200
30193
  state;
30194
+ updateSearchContent;
30201
30195
  get hasSearchResult() {
30202
30196
  return this.store.selectedMatchIndex !== null;
30203
30197
  }
@@ -30229,12 +30223,14 @@ stores.inject(MyMetaStore, storeInstance);
30229
30223
  this.store = useLocalStore(FindAndReplaceStore);
30230
30224
  this.state = owl.useState({ dataRange: "" });
30231
30225
  owl.onMounted(() => this.searchInput.el?.focus());
30226
+ owl.onWillUnmount(() => this.updateSearchContent.stopDebounce());
30227
+ this.updateSearchContent = debounce(this.store.updateSearchContent, 200);
30232
30228
  }
30233
30229
  onFocusSearch() {
30234
30230
  this.updateDataRange();
30235
30231
  }
30236
30232
  onSearchInput(ev) {
30237
- this.store.updateSearchContent(ev.target?.value || "");
30233
+ this.updateSearchContent(ev.target.value);
30238
30234
  }
30239
30235
  onKeydownSearch(ev) {
30240
30236
  if (ev.key === "Enter") {
@@ -30273,6 +30269,9 @@ stores.inject(MyMetaStore, storeInstance);
30273
30269
  const specificRange = this.env.model.getters.getRangeFromSheetXC(this.env.model.getters.getActiveSheetId(), this.state.dataRange);
30274
30270
  this.store.updateSearchOptions({ specificRange });
30275
30271
  }
30272
+ get pendingSearch() {
30273
+ return this.updateSearchContent.isDebouncePending();
30274
+ }
30276
30275
  }
30277
30276
 
30278
30277
  css /* scss */ `
@@ -31075,10 +31074,6 @@ stores.inject(MyMetaStore, storeInstance);
31075
31074
  });
31076
31075
  }
31077
31076
  onRangeChanged(ranges) {
31078
- if (!ranges[0] || !ranges[0].match(rangeReference)) {
31079
- this.state.tableZoneErrors = ["InvalidRange" /* CommandResult.InvalidRange */];
31080
- return;
31081
- }
31082
31077
  const sheetId = this.env.model.getters.getActiveSheetId();
31083
31078
  this.state.tableXc = ranges[0];
31084
31079
  this.state.tableZoneErrors = this.env.model.canDispatch("UPDATE_TABLE", {
@@ -31102,10 +31097,6 @@ stores.inject(MyMetaStore, storeInstance);
31102
31097
  cell: position,
31103
31098
  });
31104
31099
  }
31105
- this.state.tableZoneErrors = [];
31106
- this.state.tableXc = result.isSuccessful
31107
- ? this.state.tableXc
31108
- : this.env.model.getters.getRangeString(this.props.table.range, sheetId);
31109
31100
  }
31110
31101
  deleteTable() {
31111
31102
  const sheetId = this.env.model.getters.getActiveSheetId();
@@ -41535,6 +41526,9 @@ stores.inject(MyMetaStore, storeInstance);
41535
41526
  format: "",
41536
41527
  });
41537
41528
  break;
41529
+ case "CLEAR_CELLS":
41530
+ this.clearCells(cmd.sheetId, cmd.target);
41531
+ break;
41538
41532
  case "DELETE_CONTENT":
41539
41533
  this.clearZones(cmd.sheetId, cmd.target);
41540
41534
  break;
@@ -41593,6 +41587,25 @@ stores.inject(MyMetaStore, storeInstance);
41593
41587
  }
41594
41588
  }
41595
41589
  }
41590
+ /**
41591
+ * Clear the styles, the format and the content of zones
41592
+ */
41593
+ clearCells(sheetId, zones) {
41594
+ for (const zone of zones) {
41595
+ for (let col = zone.left; col <= zone.right; col++) {
41596
+ for (let row = zone.top; row <= zone.bottom; row++) {
41597
+ this.dispatch("UPDATE_CELL", {
41598
+ sheetId: sheetId,
41599
+ col,
41600
+ row,
41601
+ content: "",
41602
+ style: null,
41603
+ format: "",
41604
+ });
41605
+ }
41606
+ }
41607
+ }
41608
+ }
41596
41609
  /**
41597
41610
  * Copy the style of the reference column/row to the new columns/rows.
41598
41611
  */
@@ -42977,7 +42990,10 @@ stores.inject(MyMetaStore, storeInstance);
42977
42990
  handle(cmd) {
42978
42991
  switch (cmd.type) {
42979
42992
  case "CREATE_SHEET": {
42980
- this.history.update("sizes", cmd.sheetId, { COL: [], ROW: [] });
42993
+ this.history.update("sizes", cmd.sheetId, {
42994
+ COL: Array(this.getters.getNumberCols(cmd.sheetId)).fill(undefined),
42995
+ ROW: Array(this.getters.getNumberRows(cmd.sheetId)).fill(undefined),
42996
+ });
42981
42997
  break;
42982
42998
  }
42983
42999
  case "DUPLICATE_SHEET":
@@ -45019,19 +45035,23 @@ stores.inject(MyMetaStore, storeInstance);
45019
45035
  }
45020
45036
  }
45021
45037
  moveCellOnColumnsDeletion(sheet, deletedColumn) {
45038
+ this.dispatch("CLEAR_CELLS", {
45039
+ sheetId: sheet.id,
45040
+ target: [
45041
+ {
45042
+ left: deletedColumn,
45043
+ top: 0,
45044
+ right: deletedColumn,
45045
+ bottom: sheet.rows.length - 1,
45046
+ },
45047
+ ],
45048
+ });
45022
45049
  for (let rowIndex = 0; rowIndex < sheet.rows.length; rowIndex++) {
45023
45050
  const row = sheet.rows[rowIndex];
45024
45051
  for (let i in row.cells) {
45025
45052
  const colIndex = Number(i);
45026
45053
  const cellId = row.cells[i];
45027
45054
  if (cellId) {
45028
- if (colIndex === deletedColumn) {
45029
- this.dispatch("CLEAR_CELL", {
45030
- sheetId: sheet.id,
45031
- col: colIndex,
45032
- row: rowIndex,
45033
- });
45034
- }
45035
45055
  if (colIndex > deletedColumn) {
45036
45056
  this.setNewPosition(cellId, sheet.id, colIndex - 1, rowIndex);
45037
45057
  }
@@ -45077,22 +45097,20 @@ stores.inject(MyMetaStore, storeInstance);
45077
45097
  *
45078
45098
  */
45079
45099
  moveCellOnRowsDeletion(sheet, deleteFromRow, deleteToRow) {
45100
+ this.dispatch("CLEAR_CELLS", {
45101
+ sheetId: sheet.id,
45102
+ target: [
45103
+ {
45104
+ left: 0,
45105
+ top: deleteFromRow,
45106
+ right: this.getters.getNumberCols(sheet.id),
45107
+ bottom: deleteToRow,
45108
+ },
45109
+ ],
45110
+ });
45080
45111
  const numberRows = deleteToRow - deleteFromRow + 1;
45081
45112
  for (let rowIndex = 0; rowIndex < sheet.rows.length; rowIndex++) {
45082
45113
  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
45114
  if (rowIndex > deleteToRow) {
45097
45115
  for (let i in row.cells) {
45098
45116
  const colIndex = Number(i);
@@ -50408,7 +50426,7 @@ stores.inject(MyMetaStore, storeInstance);
50408
50426
  */
50409
50427
  leave(data) {
50410
50428
  if (Object.keys(this.clients).length === 1 && this.processedRevisions.size) {
50411
- this.snapshot(data);
50429
+ this.snapshot(data());
50412
50430
  }
50413
50431
  delete this.clients[this.clientId];
50414
50432
  this.transportService.leave(this.clientId);
@@ -50830,9 +50848,7 @@ stores.inject(MyMetaStore, storeInstance);
50830
50848
  if (!data) {
50831
50849
  return;
50832
50850
  }
50833
- for (const { col, row } of positions(zone)) {
50834
- this.dispatch("CLEAR_CELL", { col, row, sheetId });
50835
- }
50851
+ this.dispatch("CLEAR_CELLS", { target: [zone], sheetId });
50836
50852
  const zonePasted = {
50837
50853
  left: zone.left,
50838
50854
  top: zone.top,
@@ -51393,6 +51409,9 @@ stores.inject(MyMetaStore, storeInstance);
51393
51409
  if (showFormula && cell?.isFormula) {
51394
51410
  return localizeFormula(cell.content, this.getters.getLocale());
51395
51411
  }
51412
+ else if (showFormula && !cell?.content) {
51413
+ return "";
51414
+ }
51396
51415
  else {
51397
51416
  return this.getters.getEvaluatedCell(position).formattedValue;
51398
51417
  }
@@ -51664,6 +51683,7 @@ stores.inject(MyMetaStore, storeInstance);
51664
51683
  const repeatCommandTransformRegistry = new Registry();
51665
51684
  repeatCommandTransformRegistry.add("UPDATE_CELL", genericRepeat);
51666
51685
  repeatCommandTransformRegistry.add("CLEAR_CELL", genericRepeat);
51686
+ repeatCommandTransformRegistry.add("CLEAR_CELLS", genericRepeat);
51667
51687
  repeatCommandTransformRegistry.add("DELETE_CONTENT", genericRepeat);
51668
51688
  repeatCommandTransformRegistry.add("ADD_MERGE", genericRepeat);
51669
51689
  repeatCommandTransformRegistry.add("REMOVE_MERGE", genericRepeat);
@@ -52339,6 +52359,7 @@ stores.inject(MyMetaStore, storeInstance);
52339
52359
  this.status = "invisible";
52340
52360
  if (this._isCutOperation) {
52341
52361
  this.copiedData = undefined;
52362
+ this._isCutOperation = false;
52342
52363
  }
52343
52364
  break;
52344
52365
  }
@@ -52382,9 +52403,10 @@ stores.inject(MyMetaStore, storeInstance);
52382
52403
  case "DELETE_CELL": {
52383
52404
  const { cut, paste } = this.getDeleteCellsTargets(cmd.zone, cmd.shiftDimension);
52384
52405
  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
- }
52406
+ this.dispatch("CLEAR_CELLS", {
52407
+ target: [cmd.zone],
52408
+ sheetId: this.getters.getActiveSheetId(),
52409
+ });
52388
52410
  break;
52389
52411
  }
52390
52412
  const copiedData = this.copy(cut);
@@ -52435,6 +52457,7 @@ stores.inject(MyMetaStore, storeInstance);
52435
52457
  }
52436
52458
  case "ACTIVATE_PAINT_FORMAT": {
52437
52459
  const zones = this.getters.getSelectedZones();
52460
+ this._isCutOperation = false;
52438
52461
  this.copiedData = this.copy(zones);
52439
52462
  this.status = "visible";
52440
52463
  if (cmd.persistent) {
@@ -60344,7 +60367,7 @@ stores.inject(MyMetaStore, storeInstance);
60344
60367
  this.session.join(this.config.client);
60345
60368
  }
60346
60369
  leaveSession() {
60347
- this.session.leave(this.exportData());
60370
+ this.session.leave(lazy(() => this.exportData()));
60348
60371
  }
60349
60372
  setupUiPlugin(Plugin) {
60350
60373
  const plugin = new Plugin(this.uiPluginConfig);
@@ -60898,9 +60921,9 @@ stores.inject(MyMetaStore, storeInstance);
60898
60921
  exports.tokenize = tokenize;
60899
60922
 
60900
60923
 
60901
- __info__.version = "17.2.20";
60902
- __info__.date = "2024-08-09T12:24:12.002Z";
60903
- __info__.hash = "d667a15";
60924
+ __info__.version = "17.2.22";
60925
+ __info__.date = "2024-08-26T13:48:03.927Z";
60926
+ __info__.hash = "4157fb8";
60904
60927
 
60905
60928
 
60906
60929
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);