@odoo/o-spreadsheet 17.4.4 → 17.4.6

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.4.4
6
- * @date 2024-08-09T12:24:07.798Z
7
- * @hash a43e855
5
+ * @version 17.4.6
6
+ * @date 2024-08-26T13:50:49.623Z
7
+ * @hash f5648d9
8
8
  */
9
9
 
10
10
  (function (exports, owl) {
@@ -241,6 +241,7 @@
241
241
  bandedRows: true,
242
242
  bandedColumns: false,
243
243
  styleId: "TableStyleMedium5",
244
+ automaticAutofill: true,
244
245
  };
245
246
 
246
247
  //------------------------------------------------------------------------------
@@ -2009,6 +2010,7 @@
2009
2010
  "UPDATE_CELL",
2010
2011
  "UPDATE_CELL_POSITION",
2011
2012
  "CLEAR_CELL",
2013
+ "CLEAR_CELLS",
2012
2014
  "DELETE_CONTENT",
2013
2015
  /** GRID SHAPE */
2014
2016
  "ADD_COLUMNS_ROWS",
@@ -6744,13 +6746,10 @@
6744
6746
  * Clear the clipped zones: remove the cells and clear the formatting
6745
6747
  */
6746
6748
  clearClippedZones(content) {
6747
- for (const row of content.cells) {
6748
- for (const cell of row) {
6749
- if (cell.cell) {
6750
- this.dispatch("CLEAR_CELL", cell.position);
6751
- }
6752
- }
6753
- }
6749
+ this.dispatch("CLEAR_CELLS", {
6750
+ sheetId: content.sheetId,
6751
+ target: content.zones,
6752
+ });
6754
6753
  this.dispatch("CLEAR_FORMATTING", {
6755
6754
  sheetId: content.sheetId,
6756
6755
  target: content.zones,
@@ -7718,7 +7717,7 @@
7718
7717
  }
7719
7718
  function parseTokens(tokens) {
7720
7719
  tokens = tokens.filter((x) => x.type !== "SPACE");
7721
- if (tokens[0].value === "=") {
7720
+ if (tokens[0]?.value === "=") {
7722
7721
  tokens.splice(0, 1);
7723
7722
  }
7724
7723
  const result = parseExpression(tokens);
@@ -9952,7 +9951,7 @@ stores.inject(MyMetaStore, storeInstance);
9952
9951
  if (pivotId && pivotCell.type !== "EMPTY" && !cell?.isFormula) {
9953
9952
  const formulaPivotId = this.getters.getPivotFormulaId(pivotId);
9954
9953
  const formula = createPivotFormula(formulaPivotId, pivotCell);
9955
- return formula.slice(1); // strip leading =
9954
+ return localizeFormula(formula, this.getters.getLocale()).slice(1); // strip leading =
9956
9955
  }
9957
9956
  }
9958
9957
  const range = this.getters.getRangeFromZone(sheetId, zone);
@@ -35174,7 +35173,6 @@ stores.inject(MyMetaStore, storeInstance);
35174
35173
  searchScope: "activeSheet",
35175
35174
  specificRange: undefined,
35176
35175
  };
35177
- updateSearchContent = debounce(this._updateSearchContent.bind(this), 200);
35178
35176
  constructor(get) {
35179
35177
  super(get);
35180
35178
  this.initialShowFormulaState = this.model.getters.shouldShowFormulas();
@@ -35183,7 +35181,6 @@ stores.inject(MyMetaStore, storeInstance);
35183
35181
  highlightStore.register(this);
35184
35182
  this.onDispose(() => {
35185
35183
  this.model.dispatch("SET_FORMULA_VISIBILITY", { show: this.initialShowFormulaState });
35186
- this.updateSearchContent.stopDebounce();
35187
35184
  highlightStore.unRegister(this);
35188
35185
  });
35189
35186
  }
@@ -35197,7 +35194,7 @@ stores.inject(MyMetaStore, storeInstance);
35197
35194
  return this.specificRangeMatches;
35198
35195
  }
35199
35196
  }
35200
- _updateSearchContent(toSearch) {
35197
+ updateSearchContent(toSearch) {
35201
35198
  this._updateSearch(toSearch, this.searchOptions);
35202
35199
  }
35203
35200
  updateSearchOptions(searchOptions) {
@@ -35213,9 +35210,6 @@ stores.inject(MyMetaStore, storeInstance);
35213
35210
  selectNextMatch() {
35214
35211
  this.selectNextCell(Direction.next);
35215
35212
  }
35216
- get pendingSearch() {
35217
- return this.updateSearchContent.isDebouncePending();
35218
- }
35219
35213
  handle(cmd) {
35220
35214
  switch (cmd.type) {
35221
35215
  case "SET_FORMULA_VISIBILITY":
@@ -35541,6 +35535,7 @@ stores.inject(MyMetaStore, storeInstance);
35541
35535
  searchInput = owl.useRef("searchInput");
35542
35536
  store;
35543
35537
  state;
35538
+ updateSearchContent;
35544
35539
  get hasSearchResult() {
35545
35540
  return this.store.selectedMatchIndex !== null;
35546
35541
  }
@@ -35572,12 +35567,14 @@ stores.inject(MyMetaStore, storeInstance);
35572
35567
  this.store = useLocalStore(FindAndReplaceStore);
35573
35568
  this.state = owl.useState({ dataRange: "" });
35574
35569
  owl.onMounted(() => this.searchInput.el?.focus());
35570
+ owl.onWillUnmount(() => this.updateSearchContent.stopDebounce());
35571
+ this.updateSearchContent = debounce(this.store.updateSearchContent, 200);
35575
35572
  }
35576
35573
  onFocusSearch() {
35577
35574
  this.updateDataRange();
35578
35575
  }
35579
35576
  onSearchInput(ev) {
35580
- this.store.updateSearchContent(ev.target?.value || "");
35577
+ this.updateSearchContent(ev.target.value);
35581
35578
  }
35582
35579
  onKeydownSearch(ev) {
35583
35580
  if (ev.key === "Enter") {
@@ -35616,6 +35613,9 @@ stores.inject(MyMetaStore, storeInstance);
35616
35613
  const specificRange = this.env.model.getters.getRangeFromSheetXC(this.env.model.getters.getActiveSheetId(), this.state.dataRange);
35617
35614
  this.store.updateSearchOptions({ specificRange });
35618
35615
  }
35616
+ get pendingSearch() {
35617
+ return this.updateSearchContent.isDebouncePending();
35618
+ }
35619
35619
  }
35620
35620
 
35621
35621
  css /* scss */ `
@@ -36669,6 +36669,12 @@ stores.inject(MyMetaStore, storeInstance);
36669
36669
  * Used to order two values
36670
36670
  */
36671
36671
  function compareDimensionValues(dimension, a, b) {
36672
+ if (a === "null") {
36673
+ return dimension.order === "asc" ? 1 : -1;
36674
+ }
36675
+ if (b === "null") {
36676
+ return dimension.order === "asc" ? -1 : 1;
36677
+ }
36672
36678
  if (dimension.type === "integer" || dimension.type === "date") {
36673
36679
  return dimension.order === "asc" ? Number(a) - Number(b) : Number(b) - Number(a);
36674
36680
  }
@@ -37031,7 +37037,7 @@ stores.inject(MyMetaStore, storeInstance);
37031
37037
  if (cell.type === CellValueType.error) {
37032
37038
  throw new EvaluationError(_t("The pivot cannot be created because cell %s contains an error", toXC(col, row)));
37033
37039
  }
37034
- if (cell.type === CellValueType.empty) {
37040
+ if (cell.type === CellValueType.empty || cell.value === "") {
37035
37041
  throw new EvaluationError(_t("The pivot cannot be created because cell %s is empty", toXC(col, row)));
37036
37042
  }
37037
37043
  if (cell.value === "__count") {
@@ -37377,15 +37383,11 @@ stores.inject(MyMetaStore, storeInstance);
37377
37383
  }
37378
37384
  onSelectionConfirmed() {
37379
37385
  if (this.state.range) {
37380
- const { sheetName, xc } = splitReference(this.state.range);
37381
- const sheetId = sheetName
37382
- ? this.env.model.getters.getSheetIdByName(sheetName)
37383
- : this.env.model.getters.getActiveSheetId();
37384
- if (!sheetId) {
37386
+ const range = this.env.model.getters.getRangeFromSheetXC(this.env.model.getters.getActiveSheetId(), this.state.range);
37387
+ if (range.invalidSheetName || range.invalidXc) {
37385
37388
  return;
37386
37389
  }
37387
- const zone = toZone(xc);
37388
- const dataSet = { sheetId, zone };
37390
+ const dataSet = { sheetId: range.sheetId, zone: range.zone };
37389
37391
  this.store.update({ dataSet });
37390
37392
  // Immediately apply the update to recompute the pivot fields
37391
37393
  this.store.applyUpdate();
@@ -38318,10 +38320,6 @@ stores.inject(MyMetaStore, storeInstance);
38318
38320
  });
38319
38321
  }
38320
38322
  onRangeChanged(ranges) {
38321
- if (!ranges[0] || !ranges[0].match(rangeReference)) {
38322
- this.state.tableZoneErrors = ["InvalidRange" /* CommandResult.InvalidRange */];
38323
- return;
38324
- }
38325
38323
  const sheetId = this.env.model.getters.getActiveSheetId();
38326
38324
  this.state.tableXc = ranges[0];
38327
38325
  const newTableRange = this.env.model.getters.getRangeFromSheetXC(sheetId, this.state.tableXc);
@@ -38361,11 +38359,6 @@ stores.inject(MyMetaStore, storeInstance);
38361
38359
  const newTableRange = updatedTable.range;
38362
38360
  this.state.tableXc = this.env.model.getters.getRangeString(newTableRange, sheetId);
38363
38361
  }
38364
- else {
38365
- const oldTableRange = this.props.table.range;
38366
- this.state.tableXc = this.env.model.getters.getRangeString(oldTableRange, sheetId);
38367
- }
38368
- this.state.tableZoneErrors = [];
38369
38362
  }
38370
38363
  deleteTable() {
38371
38364
  const sheetId = this.env.model.getters.getActiveSheetId();
@@ -44355,6 +44348,7 @@ stores.inject(MyMetaStore, storeInstance);
44355
44348
  return {
44356
44349
  dataRange: convertExcelRangeToSheetXC(data.range, dataSetsHaveTitle),
44357
44350
  label,
44351
+ backgroundColor: data.backgroundColor,
44358
44352
  };
44359
44353
  });
44360
44354
  // For doughnut charts, in chartJS first dataset = outer dataset, in excel first dataset = inner dataset
@@ -45548,11 +45542,13 @@ stores.inject(MyMetaStore, storeInstance);
45548
45542
  label = { text };
45549
45543
  }
45550
45544
  }
45545
+ const color = this.extractChildAttr(chartDataElement, "c:spPr a:solidFill a:srgbClr", "val");
45551
45546
  return {
45552
45547
  label,
45553
45548
  range: this.extractChildTextContent(chartDataElement, "c:val c:f", {
45554
45549
  required: true,
45555
45550
  }),
45551
+ backgroundColor: color ? `${toHex(color.asString())}` : undefined,
45556
45552
  };
45557
45553
  });
45558
45554
  })
@@ -47758,6 +47754,9 @@ stores.inject(MyMetaStore, storeInstance);
47758
47754
  format: "",
47759
47755
  });
47760
47756
  break;
47757
+ case "CLEAR_CELLS":
47758
+ this.clearCells(cmd.sheetId, cmd.target);
47759
+ break;
47761
47760
  case "DELETE_CONTENT":
47762
47761
  this.clearZones(cmd.sheetId, cmd.target);
47763
47762
  break;
@@ -47816,6 +47815,25 @@ stores.inject(MyMetaStore, storeInstance);
47816
47815
  }
47817
47816
  }
47818
47817
  }
47818
+ /**
47819
+ * Clear the styles, the format and the content of zones
47820
+ */
47821
+ clearCells(sheetId, zones) {
47822
+ for (const zone of zones) {
47823
+ for (let col = zone.left; col <= zone.right; col++) {
47824
+ for (let row = zone.top; row <= zone.bottom; row++) {
47825
+ this.dispatch("UPDATE_CELL", {
47826
+ sheetId: sheetId,
47827
+ col,
47828
+ row,
47829
+ content: "",
47830
+ style: null,
47831
+ format: "",
47832
+ });
47833
+ }
47834
+ }
47835
+ }
47836
+ }
47819
47837
  /**
47820
47838
  * Copy the style of the reference column/row to the new columns/rows.
47821
47839
  */
@@ -49227,7 +49245,10 @@ stores.inject(MyMetaStore, storeInstance);
49227
49245
  handle(cmd) {
49228
49246
  switch (cmd.type) {
49229
49247
  case "CREATE_SHEET": {
49230
- this.history.update("sizes", cmd.sheetId, { COL: [], ROW: [] });
49248
+ this.history.update("sizes", cmd.sheetId, {
49249
+ COL: Array(this.getters.getNumberCols(cmd.sheetId)).fill(undefined),
49250
+ ROW: Array(this.getters.getNumberRows(cmd.sheetId)).fill(undefined),
49251
+ });
49231
49252
  break;
49232
49253
  }
49233
49254
  case "DUPLICATE_SHEET":
@@ -51276,19 +51297,23 @@ stores.inject(MyMetaStore, storeInstance);
51276
51297
  }
51277
51298
  }
51278
51299
  moveCellOnColumnsDeletion(sheet, deletedColumn) {
51300
+ this.dispatch("CLEAR_CELLS", {
51301
+ sheetId: sheet.id,
51302
+ target: [
51303
+ {
51304
+ left: deletedColumn,
51305
+ top: 0,
51306
+ right: deletedColumn,
51307
+ bottom: sheet.rows.length - 1,
51308
+ },
51309
+ ],
51310
+ });
51279
51311
  for (let rowIndex = 0; rowIndex < sheet.rows.length; rowIndex++) {
51280
51312
  const row = sheet.rows[rowIndex];
51281
51313
  for (let i in row.cells) {
51282
51314
  const colIndex = Number(i);
51283
51315
  const cellId = row.cells[i];
51284
51316
  if (cellId) {
51285
- if (colIndex === deletedColumn) {
51286
- this.dispatch("CLEAR_CELL", {
51287
- sheetId: sheet.id,
51288
- col: colIndex,
51289
- row: rowIndex,
51290
- });
51291
- }
51292
51317
  if (colIndex > deletedColumn) {
51293
51318
  this.setNewPosition(cellId, sheet.id, colIndex - 1, rowIndex);
51294
51319
  }
@@ -51334,22 +51359,20 @@ stores.inject(MyMetaStore, storeInstance);
51334
51359
  *
51335
51360
  */
51336
51361
  moveCellOnRowsDeletion(sheet, deleteFromRow, deleteToRow) {
51362
+ this.dispatch("CLEAR_CELLS", {
51363
+ sheetId: sheet.id,
51364
+ target: [
51365
+ {
51366
+ left: 0,
51367
+ top: deleteFromRow,
51368
+ right: this.getters.getNumberCols(sheet.id),
51369
+ bottom: deleteToRow,
51370
+ },
51371
+ ],
51372
+ });
51337
51373
  const numberRows = deleteToRow - deleteFromRow + 1;
51338
51374
  for (let rowIndex = 0; rowIndex < sheet.rows.length; rowIndex++) {
51339
51375
  const row = sheet.rows[rowIndex];
51340
- if (rowIndex >= deleteFromRow && rowIndex <= deleteToRow) {
51341
- for (let i in row.cells) {
51342
- const colIndex = Number(i);
51343
- const cellId = row.cells[i];
51344
- if (cellId) {
51345
- this.dispatch("CLEAR_CELL", {
51346
- sheetId: sheet.id,
51347
- col: colIndex,
51348
- row: rowIndex,
51349
- });
51350
- }
51351
- }
51352
- }
51353
51376
  if (rowIndex > deleteToRow) {
51354
51377
  for (let i in row.cells) {
51355
51378
  const colIndex = Number(i);
@@ -55910,6 +55933,9 @@ stores.inject(MyMetaStore, storeInstance);
55910
55933
  }
55911
55934
  }
55912
55935
  getPivot(pivotId) {
55936
+ if (!this.getters.isExistingPivot(pivotId)) {
55937
+ throw new Error(`pivot ${pivotId} not found`);
55938
+ }
55913
55939
  return this.pivots[pivotId];
55914
55940
  }
55915
55941
  isPivotUnused(pivotId) {
@@ -57203,7 +57229,7 @@ stores.inject(MyMetaStore, storeInstance);
57203
57229
  */
57204
57230
  leave(data) {
57205
57231
  if (Object.keys(this.clients).length === 1 && this.processedRevisions.size) {
57206
- this.snapshot(data);
57232
+ this.snapshot(data());
57207
57233
  }
57208
57234
  delete this.clients[this.clientId];
57209
57235
  this.transportService.leave(this.clientId);
@@ -57625,9 +57651,7 @@ stores.inject(MyMetaStore, storeInstance);
57625
57651
  if (!data) {
57626
57652
  return;
57627
57653
  }
57628
- for (const { col, row } of positions(zone)) {
57629
- this.dispatch("CLEAR_CELL", { col, row, sheetId });
57630
- }
57654
+ this.dispatch("CLEAR_CELLS", { target: [zone], sheetId });
57631
57655
  const zonePasted = {
57632
57656
  left: zone.left,
57633
57657
  top: zone.top,
@@ -57992,7 +58016,7 @@ stores.inject(MyMetaStore, storeInstance);
57992
58016
  sheetId,
57993
58017
  col,
57994
58018
  row,
57995
- content: `=PIVOT("${pivotFormulaId}")`,
58019
+ content: `=PIVOT(${pivotFormulaId})`,
57996
58020
  });
57997
58021
  const zone = {
57998
58022
  left: col,
@@ -58300,6 +58324,9 @@ stores.inject(MyMetaStore, storeInstance);
58300
58324
  if (showFormula && cell?.isFormula) {
58301
58325
  return localizeFormula(cell.content, this.getters.getLocale());
58302
58326
  }
58327
+ else if (showFormula && !cell?.content) {
58328
+ return "";
58329
+ }
58303
58330
  else {
58304
58331
  return this.getters.getEvaluatedCell(position).formattedValue;
58305
58332
  }
@@ -58798,6 +58825,7 @@ stores.inject(MyMetaStore, storeInstance);
58798
58825
  const repeatCommandTransformRegistry = new Registry();
58799
58826
  repeatCommandTransformRegistry.add("UPDATE_CELL", genericRepeat);
58800
58827
  repeatCommandTransformRegistry.add("CLEAR_CELL", genericRepeat);
58828
+ repeatCommandTransformRegistry.add("CLEAR_CELLS", genericRepeat);
58801
58829
  repeatCommandTransformRegistry.add("DELETE_CONTENT", genericRepeat);
58802
58830
  repeatCommandTransformRegistry.add("ADD_MERGE", genericRepeat);
58803
58831
  repeatCommandTransformRegistry.add("REMOVE_MERGE", genericRepeat);
@@ -59379,6 +59407,7 @@ stores.inject(MyMetaStore, storeInstance);
59379
59407
  this.status = "invisible";
59380
59408
  if (this._isCutOperation) {
59381
59409
  this.copiedData = undefined;
59410
+ this._isCutOperation = false;
59382
59411
  }
59383
59412
  break;
59384
59413
  }
@@ -59422,9 +59451,10 @@ stores.inject(MyMetaStore, storeInstance);
59422
59451
  case "DELETE_CELL": {
59423
59452
  const { cut, paste } = this.getDeleteCellsTargets(cmd.zone, cmd.shiftDimension);
59424
59453
  if (!isZoneValid(cut[0])) {
59425
- for (const { col, row } of positions(cmd.zone)) {
59426
- this.dispatch("CLEAR_CELL", { col, row, sheetId: this.getters.getActiveSheetId() });
59427
- }
59454
+ this.dispatch("CLEAR_CELLS", {
59455
+ target: [cmd.zone],
59456
+ sheetId: this.getters.getActiveSheetId(),
59457
+ });
59428
59458
  break;
59429
59459
  }
59430
59460
  const copiedData = this.copy(cut);
@@ -59475,6 +59505,7 @@ stores.inject(MyMetaStore, storeInstance);
59475
59505
  }
59476
59506
  case "ACTIVATE_PAINT_FORMAT": {
59477
59507
  const zones = this.getters.getSelectedZones();
59508
+ this._isCutOperation = false;
59478
59509
  this.copiedData = this.copy(zones);
59479
59510
  this.status = "visible";
59480
59511
  if (cmd.persistent) {
@@ -67826,7 +67857,7 @@ stores.inject(MyMetaStore, storeInstance);
67826
67857
  this.session.join(this.config.client);
67827
67858
  }
67828
67859
  leaveSession() {
67829
- this.session.leave(this.exportData());
67860
+ this.session.leave(lazy(() => this.exportData()));
67830
67861
  }
67831
67862
  setupUiPlugin(Plugin) {
67832
67863
  const plugin = new Plugin(this.uiPluginConfig);
@@ -68428,9 +68459,9 @@ stores.inject(MyMetaStore, storeInstance);
68428
68459
  exports.tokenize = tokenize;
68429
68460
 
68430
68461
 
68431
- __info__.version = "17.4.4";
68432
- __info__.date = "2024-08-09T12:24:07.798Z";
68433
- __info__.hash = "a43e855";
68462
+ __info__.version = "17.4.6";
68463
+ __info__.date = "2024-08-26T13:50:49.623Z";
68464
+ __info__.hash = "f5648d9";
68434
68465
 
68435
68466
 
68436
68467
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);