@odoo/o-spreadsheet 17.4.6 → 17.4.8

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.6
6
- * @date 2024-08-26T13:50:49.623Z
7
- * @hash f5648d9
5
+ * @version 17.4.8
6
+ * @date 2024-09-17T08:10:18.777Z
7
+ * @hash caad8bd
8
8
  */
9
9
 
10
10
  (function (exports, owl) {
@@ -4560,6 +4560,17 @@
4560
4560
  }
4561
4561
  return zone;
4562
4562
  }
4563
+ function aggregatePositionsToZones(positions) {
4564
+ const result = {};
4565
+ for (const position of positions) {
4566
+ result[position.sheetId] ??= [];
4567
+ result[position.sheetId].push(positionToZone(position));
4568
+ }
4569
+ for (const sheetId in result) {
4570
+ result[sheetId] = recomputeZones(result[sheetId]);
4571
+ }
4572
+ return result;
4573
+ }
4563
4574
  /**
4564
4575
  * This function returns a zone with coordinates modified according to the change
4565
4576
  * applied to the zone. It may be possible to change the zone by resizing or moving
@@ -6775,9 +6786,11 @@
6775
6786
  const targetCell = this.getters.getEvaluatedCell(target);
6776
6787
  const originFormat = origin.cell?.format ?? origin.evaluatedCell.format;
6777
6788
  if (clipboardOption?.pasteOption === "asValue") {
6778
- const locale = this.getters.getLocale();
6779
- const content = formatValue(origin.evaluatedCell.value, { locale });
6780
- this.dispatch("UPDATE_CELL", { ...target, content, format: originFormat });
6789
+ this.dispatch("UPDATE_CELL", {
6790
+ ...target,
6791
+ content: origin.evaluatedCell.value?.toString() || "",
6792
+ format: originFormat,
6793
+ });
6781
6794
  return;
6782
6795
  }
6783
6796
  if (clipboardOption?.pasteOption === "onlyFormat") {
@@ -28379,8 +28392,8 @@ stores.inject(MyMetaStore, storeInstance);
28379
28392
  env.openSidePanel("PivotSidePanel", { pivotId });
28380
28393
  }
28381
28394
  };
28382
- const REINSERT_PIVOT_CHILDREN = (env) => env.model.getters.getPivotIds().map((pivotId, index) => ({
28383
- id: `reinsert_pivot_${env.model.getters.getPivotFormulaId(pivotId)}`,
28395
+ const REINSERT_DYNAMIC_PIVOT_CHILDREN = (env) => env.model.getters.getPivotIds().map((pivotId, index) => ({
28396
+ id: `reinsert_dynamic_pivot_${env.model.getters.getPivotFormulaId(pivotId)}`,
28384
28397
  name: env.model.getters.getPivotDisplayName(pivotId),
28385
28398
  sequence: index,
28386
28399
  execute: (env) => {
@@ -28392,9 +28405,30 @@ stores.inject(MyMetaStore, storeInstance);
28392
28405
  col: zone.left,
28393
28406
  row: zone.top,
28394
28407
  sheetId: env.model.getters.getActiveSheetId(),
28408
+ pivotMode: "dynamic",
28395
28409
  });
28396
28410
  env.model.dispatch("REFRESH_PIVOT", { id: pivotId });
28397
28411
  },
28412
+ isVisible: (env) => env.model.getters.getPivot(pivotId).isValid(),
28413
+ }));
28414
+ const REINSERT_STATIC_PIVOT_CHILDREN = (env) => env.model.getters.getPivotIds().map((pivotId, index) => ({
28415
+ id: `reinsert_static_pivot_${env.model.getters.getPivotFormulaId(pivotId)}`,
28416
+ name: env.model.getters.getPivotDisplayName(pivotId),
28417
+ sequence: index,
28418
+ execute: (env) => {
28419
+ const zone = env.model.getters.getSelectedZone();
28420
+ const table = env.model.getters.getPivot(pivotId).getTableStructure().export();
28421
+ env.model.dispatch("INSERT_PIVOT_WITH_TABLE", {
28422
+ pivotId,
28423
+ table,
28424
+ col: zone.left,
28425
+ row: zone.top,
28426
+ sheetId: env.model.getters.getActiveSheetId(),
28427
+ pivotMode: "static",
28428
+ });
28429
+ env.model.dispatch("REFRESH_PIVOT", { id: pivotId });
28430
+ },
28431
+ isVisible: (env) => env.model.getters.getPivot(pivotId).isValid(),
28398
28432
  }));
28399
28433
  //------------------------------------------------------------------------------
28400
28434
  // Image
@@ -29260,13 +29294,21 @@ stores.inject(MyMetaStore, storeInstance);
29260
29294
  isEnabled: (env) => env.model.getters.isSingleColSelected(),
29261
29295
  icon: "o-spreadsheet-Icon.SPLIT_TEXT",
29262
29296
  };
29263
- const reinsertPivotMenu = {
29264
- id: "reinsert_pivot",
29265
- name: _t("Re-insert pivot"),
29297
+ const reinsertDynamicPivotMenu = {
29298
+ id: "reinsert_dynamic_pivot",
29299
+ name: _t("Re-insert dynamic pivot"),
29300
+ sequence: 1020,
29301
+ icon: "o-spreadsheet-Icon.INSERT_PIVOT",
29302
+ children: [REINSERT_DYNAMIC_PIVOT_CHILDREN],
29303
+ isVisible: (env) => env.model.getters.getPivotIds().some((id) => env.model.getters.getPivot(id).isValid()),
29304
+ };
29305
+ const reinsertStaticPivotMenu = {
29306
+ id: "reinsert_static_pivot",
29307
+ name: _t("Re-insert static pivot"),
29266
29308
  sequence: 1020,
29267
29309
  icon: "o-spreadsheet-Icon.INSERT_PIVOT",
29268
- children: [REINSERT_PIVOT_CHILDREN],
29269
- isVisible: (env) => env.model.getters.getPivotIds().length > 0,
29310
+ children: [REINSERT_STATIC_PIVOT_CHILDREN],
29311
+ isVisible: (env) => env.model.getters.getPivotIds().some((id) => env.model.getters.getPivot(id).isValid()),
29270
29312
  };
29271
29313
 
29272
29314
  var ACTION_DATA = /*#__PURE__*/Object.freeze({
@@ -29274,7 +29316,8 @@ stores.inject(MyMetaStore, storeInstance);
29274
29316
  createRemoveFilter: createRemoveFilter,
29275
29317
  createRemoveFilterTool: createRemoveFilterTool,
29276
29318
  dataCleanup: dataCleanup,
29277
- reinsertPivotMenu: reinsertPivotMenu,
29319
+ reinsertDynamicPivotMenu: reinsertDynamicPivotMenu,
29320
+ reinsertStaticPivotMenu: reinsertStaticPivotMenu,
29278
29321
  removeDuplicates: removeDuplicates,
29279
29322
  sortAscending: sortAscending,
29280
29323
  sortDescending: sortDescending,
@@ -30756,7 +30799,8 @@ stores.inject(MyMetaStore, storeInstance);
30756
30799
  };
30757
30800
  });
30758
30801
  })
30759
- .addChild("reinsert_pivot", ["data"], reinsertPivotMenu);
30802
+ .addChild("reinsert_dynamic_pivot", ["data"], reinsertDynamicPivotMenu)
30803
+ .addChild("reinsert_static_pivot", ["data"], reinsertStaticPivotMenu);
30760
30804
 
30761
30805
  class OTRegistry extends Registry {
30762
30806
  /**
@@ -44066,6 +44110,18 @@ stores.inject(MyMetaStore, storeInstance);
44066
44110
  // -------------------------------------
44067
44111
  // WORKSHEET HELPERS
44068
44112
  // -------------------------------------
44113
+ function getCellType(value) {
44114
+ switch (typeof value) {
44115
+ case "boolean":
44116
+ return "b";
44117
+ case "string":
44118
+ return "str";
44119
+ case "number":
44120
+ return "n";
44121
+ default:
44122
+ return undefined;
44123
+ }
44124
+ }
44069
44125
  function convertHeightToExcel(height) {
44070
44126
  return Math.round(HEIGHT_FACTOR * height * 100) / 100;
44071
44127
  }
@@ -54316,8 +54372,9 @@ stores.inject(MyMetaStore, storeInstance);
54316
54372
  }
54317
54373
  getCellsDependingOn(positions) {
54318
54374
  const ranges = [];
54319
- for (const position of positions) {
54320
- ranges.push({ sheetId: position.sheetId, zone: positionToZone(position) });
54375
+ const zonesBySheetIds = aggregatePositionsToZones(positions);
54376
+ for (const sheetId in zonesBySheetIds) {
54377
+ ranges.push(...zonesBySheetIds[sheetId].map((zone) => ({ sheetId, zone })));
54321
54378
  }
54322
54379
  return this.formulaDependencies().getCellsDependingOn(ranges);
54323
54380
  }
@@ -57227,9 +57284,9 @@ stores.inject(MyMetaStore, storeInstance);
57227
57284
  /**
57228
57285
  * Notify the server that the user client left the collaborative session
57229
57286
  */
57230
- leave(data) {
57287
+ async leave(data) {
57231
57288
  if (Object.keys(this.clients).length === 1 && this.processedRevisions.size) {
57232
- this.snapshot(data());
57289
+ await this.snapshot(data());
57233
57290
  }
57234
57291
  delete this.clients[this.clientId];
57235
57292
  this.transportService.leave(this.clientId);
@@ -57242,12 +57299,12 @@ stores.inject(MyMetaStore, storeInstance);
57242
57299
  /**
57243
57300
  * Send a snapshot of the spreadsheet to the collaboration server
57244
57301
  */
57245
- snapshot(data) {
57302
+ async snapshot(data) {
57246
57303
  if (this.pendingMessages.length !== 0) {
57247
57304
  return;
57248
57305
  }
57249
57306
  const snapshotId = this.uuidGenerator.uuidv4();
57250
- this.transportService.sendMessage({
57307
+ await this.transportService.sendMessage({
57251
57308
  type: "SNAPSHOT",
57252
57309
  nextRevisionId: snapshotId,
57253
57310
  serverRevisionId: this.serverRevisionId,
@@ -57931,7 +57988,7 @@ stores.inject(MyMetaStore, storeInstance);
57931
57988
  this.duplicatePivotInNewSheet(cmd.pivotId, cmd.newPivotId, cmd.newSheetId);
57932
57989
  break;
57933
57990
  case "INSERT_PIVOT_WITH_TABLE":
57934
- this.insertPivotWithTable(cmd.sheetId, cmd.col, cmd.row, cmd.pivotId, cmd.table);
57991
+ this.insertPivotWithTable(cmd.sheetId, cmd.col, cmd.row, cmd.pivotId, cmd.table, cmd.pivotMode);
57935
57992
  break;
57936
57993
  }
57937
57994
  }
@@ -58007,26 +58064,44 @@ stores.inject(MyMetaStore, storeInstance);
58007
58064
  }
58008
58065
  return name;
58009
58066
  }
58010
- insertPivotWithTable(sheetId, col, row, pivotId, table) {
58067
+ insertPivotWithTable(sheetId, col, row, pivotId, table, mode) {
58011
58068
  const { cols, rows, measures, fieldsType } = table;
58012
58069
  const pivotTable = new SpreadsheetPivotTable(cols, rows, measures, fieldsType || {});
58070
+ const numberOfHeaders = pivotTable.columns.length - 1;
58013
58071
  this.resizeSheet(sheetId, col, row, pivotTable);
58014
58072
  const pivotFormulaId = this.getters.getPivotFormulaId(pivotId);
58015
- this.dispatch("UPDATE_CELL", {
58016
- sheetId,
58017
- col,
58018
- row,
58019
- content: `=PIVOT(${pivotFormulaId})`,
58020
- });
58021
- const zone = {
58022
- left: col,
58023
- right: col,
58024
- top: row,
58025
- bottom: row,
58026
- };
58027
- const numberOfHeaders = pivotTable.columns.length - 1;
58073
+ let zone;
58074
+ if (mode === "dynamic") {
58075
+ this.dispatch("UPDATE_CELL", {
58076
+ sheetId,
58077
+ col,
58078
+ row,
58079
+ content: `=PIVOT(${pivotFormulaId})`,
58080
+ });
58081
+ zone = {
58082
+ left: col,
58083
+ right: col,
58084
+ top: row,
58085
+ bottom: row,
58086
+ };
58087
+ }
58088
+ else {
58089
+ this.dispatch("INSERT_PIVOT", {
58090
+ sheetId,
58091
+ col,
58092
+ row,
58093
+ pivotId,
58094
+ table: pivotTable.export(),
58095
+ });
58096
+ zone = {
58097
+ left: col,
58098
+ right: col + pivotTable.getNumberOfDataColumns(),
58099
+ top: row,
58100
+ bottom: row + numberOfHeaders + pivotTable.rows.length,
58101
+ };
58102
+ }
58028
58103
  this.dispatch("CREATE_TABLE", {
58029
- tableType: "dynamic",
58104
+ tableType: mode,
58030
58105
  sheetId,
58031
58106
  ranges: [this.getters.getRangeDataFromZone(sheetId, zone)],
58032
58107
  config: { ...PIVOT_TABLE_CONFIG, numberOfHeaders },
@@ -58588,6 +58663,7 @@ stores.inject(MyMetaStore, storeInstance);
58588
58663
  handle(cmd) {
58589
58664
  if (invalidateEvaluationCommands.has(cmd.type) ||
58590
58665
  cmd.type === "UPDATE_CELL" ||
58666
+ cmd.type === "SET_FORMATTING" ||
58591
58667
  cmd.type === "EVALUATE_CELLS") {
58592
58668
  this.styles = {};
58593
58669
  this.borders = {};
@@ -60228,6 +60304,8 @@ stores.inject(MyMetaStore, storeInstance);
60228
60304
  this.selectedFigureId = null;
60229
60305
  break;
60230
60306
  }
60307
+ }
60308
+ finalize() {
60231
60309
  /** Any change to the selection has to be reflected in the selection processor. */
60232
60310
  this.selection.resetDefaultAnchor(this, deepCopy(this.gridSelection.anchor));
60233
60311
  }
@@ -61009,7 +61087,6 @@ stores.inject(MyMetaStore, storeInstance);
61009
61087
  }
61010
61088
  }
61011
61089
  handle(cmd) {
61012
- this.cleanViewports();
61013
61090
  // changing the evaluation can hide/show rows because of data filters
61014
61091
  if (invalidateEvaluationCommands.has(cmd.type)) {
61015
61092
  for (const sheetId of this.getters.getSheetIds()) {
@@ -61025,6 +61102,7 @@ stores.inject(MyMetaStore, storeInstance);
61025
61102
  break;
61026
61103
  case "UNDO":
61027
61104
  case "REDO":
61105
+ this.cleanViewports();
61028
61106
  for (const sheetId of this.getters.getSheetIds()) {
61029
61107
  this.sheetsWithDirtyViewports.add(sheetId);
61030
61108
  }
@@ -61079,6 +61157,9 @@ stores.inject(MyMetaStore, storeInstance);
61079
61157
  }
61080
61158
  }
61081
61159
  break;
61160
+ case "DELETE_SHEET":
61161
+ this.cleanViewports();
61162
+ break;
61082
61163
  case "ACTIVATE_SHEET":
61083
61164
  this.sheetsWithDirtyViewports.add(cmd.sheetIdTo);
61084
61165
  break;
@@ -62366,6 +62447,17 @@ stores.inject(MyMetaStore, storeInstance);
62366
62447
  .o-bottom-bar-fade-in {
62367
62448
  background-image: linear-gradient(90deg, #cfcfcf, transparent 1%);
62368
62449
  }
62450
+
62451
+ .o-sheet-list {
62452
+ overflow-y: hidden;
62453
+ overflow-x: auto;
62454
+
62455
+ &::-webkit-scrollbar {
62456
+ display: none; /* Chrome */
62457
+ }
62458
+ -ms-overflow-style: none; /* IE and Edge */
62459
+ scrollbar-width: none; /* Firefox */
62460
+ }
62369
62461
  }
62370
62462
 
62371
62463
  .o-bottom-bar-arrows {
@@ -64339,7 +64431,7 @@ stores.inject(MyMetaStore, storeInstance);
64339
64431
 
64340
64432
  class LocalTransportService {
64341
64433
  listeners = [];
64342
- sendMessage(message) {
64434
+ async sendMessage(message) {
64343
64435
  for (const { callback } of this.listeners) {
64344
64436
  callback(message);
64345
64437
  }
@@ -66432,17 +66524,13 @@ stores.inject(MyMetaStore, storeInstance);
66432
66524
  if (!formula) {
66433
66525
  return { attrs: [], node: escapeXml `` };
66434
66526
  }
66435
- const attrs = [];
66436
- let node = escapeXml ``;
66437
- let cycle = escapeXml ``;
66438
- const XlsxFormula = adaptFormulaToExcel(formula);
66439
- // hack for cycles : if we don't set a value (be it 0 or #VALUE!), it will appear as invisible on excel,
66440
- // Making it very hard for the client to find where the recursion is.
66441
- if (cell.value === CellErrorType.CircularDependency) {
66442
- attrs.push(["t", "str"]);
66443
- cycle = escapeXml /*xml*/ `<v>${cell.value}</v>`;
66527
+ const type = getCellType(cell.value);
66528
+ if (type === undefined) {
66529
+ return { attrs: [], node: escapeXml `` };
66444
66530
  }
66445
- node = escapeXml /*xml*/ `<f>${XlsxFormula}</f>${cycle}`;
66531
+ const attrs = [["t", type]];
66532
+ const XlsxFormula = adaptFormulaToExcel(formula);
66533
+ const node = escapeXml /*xml*/ `<f>${XlsxFormula}</f><v>${cell.value}</v>`;
66446
66534
  return { attrs, node };
66447
66535
  }
66448
66536
  function addContent(content, sharedStrings, forceString = false) {
@@ -67856,8 +67944,8 @@ stores.inject(MyMetaStore, storeInstance);
67856
67944
  joinSession() {
67857
67945
  this.session.join(this.config.client);
67858
67946
  }
67859
- leaveSession() {
67860
- this.session.leave(lazy(() => this.exportData()));
67947
+ async leaveSession() {
67948
+ await this.session.leave(lazy(() => this.exportData()));
67861
67949
  }
67862
67950
  setupUiPlugin(Plugin) {
67863
67951
  const plugin = new Plugin(this.uiPluginConfig);
@@ -68329,6 +68417,7 @@ stores.inject(MyMetaStore, storeInstance);
68329
68417
  UNDO_REDO_PIVOT_COMMANDS,
68330
68418
  createPivotFormula,
68331
68419
  areDomainArgsFieldsValid,
68420
+ formatTickValue,
68332
68421
  };
68333
68422
  const links = {
68334
68423
  isMarkdownLink,
@@ -68459,9 +68548,9 @@ stores.inject(MyMetaStore, storeInstance);
68459
68548
  exports.tokenize = tokenize;
68460
68549
 
68461
68550
 
68462
- __info__.version = "17.4.6";
68463
- __info__.date = "2024-08-26T13:50:49.623Z";
68464
- __info__.hash = "f5648d9";
68551
+ __info__.version = "17.4.8";
68552
+ __info__.date = "2024-09-17T08:10:18.777Z";
68553
+ __info__.hash = "caad8bd";
68465
68554
 
68466
68555
 
68467
68556
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);