@odoo/o-spreadsheet 17.4.6 → 17.4.7

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.7
6
+ * @date 2024-09-05T09:32:00.461Z
7
+ * @hash c14a4c9
8
8
  */
9
9
 
10
10
  import { useEnv, useSubEnv, onWillUnmount, useComponent, status, Component, useRef, onMounted, useEffect, useState, onPatched, onWillPatch, onWillUpdateProps, useExternalListener, onWillStart, xml, useChildSubEnv, markRaw, toRaw } from '@odoo/owl';
@@ -4559,6 +4559,17 @@ function reorderZone(zone) {
4559
4559
  }
4560
4560
  return zone;
4561
4561
  }
4562
+ function aggregatePositionsToZones(positions) {
4563
+ const result = {};
4564
+ for (const position of positions) {
4565
+ result[position.sheetId] ??= [];
4566
+ result[position.sheetId].push(positionToZone(position));
4567
+ }
4568
+ for (const sheetId in result) {
4569
+ result[sheetId] = recomputeZones(result[sheetId]);
4570
+ }
4571
+ return result;
4572
+ }
4562
4573
  /**
4563
4574
  * This function returns a zone with coordinates modified according to the change
4564
4575
  * applied to the zone. It may be possible to change the zone by resizing or moving
@@ -6774,9 +6785,11 @@ class CellClipboardHandler extends AbstractCellClipboardHandler {
6774
6785
  const targetCell = this.getters.getEvaluatedCell(target);
6775
6786
  const originFormat = origin.cell?.format ?? origin.evaluatedCell.format;
6776
6787
  if (clipboardOption?.pasteOption === "asValue") {
6777
- const locale = this.getters.getLocale();
6778
- const content = formatValue(origin.evaluatedCell.value, { locale });
6779
- this.dispatch("UPDATE_CELL", { ...target, content, format: originFormat });
6788
+ this.dispatch("UPDATE_CELL", {
6789
+ ...target,
6790
+ content: origin.evaluatedCell.value?.toString() || "",
6791
+ format: originFormat,
6792
+ });
6780
6793
  return;
6781
6794
  }
6782
6795
  if (clipboardOption?.pasteOption === "onlyFormat") {
@@ -28378,8 +28391,26 @@ const CREATE_PIVOT = (env) => {
28378
28391
  env.openSidePanel("PivotSidePanel", { pivotId });
28379
28392
  }
28380
28393
  };
28381
- const REINSERT_PIVOT_CHILDREN = (env) => env.model.getters.getPivotIds().map((pivotId, index) => ({
28382
- id: `reinsert_pivot_${env.model.getters.getPivotFormulaId(pivotId)}`,
28394
+ const REINSERT_DYNAMIC_PIVOT_CHILDREN = (env) => env.model.getters.getPivotIds().map((pivotId, index) => ({
28395
+ id: `reinsert_dynamic_pivot_${env.model.getters.getPivotFormulaId(pivotId)}`,
28396
+ name: env.model.getters.getPivotDisplayName(pivotId),
28397
+ sequence: index,
28398
+ execute: (env) => {
28399
+ const zone = env.model.getters.getSelectedZone();
28400
+ const table = env.model.getters.getPivot(pivotId).getTableStructure().export();
28401
+ env.model.dispatch("INSERT_PIVOT_WITH_TABLE", {
28402
+ pivotId,
28403
+ table,
28404
+ col: zone.left,
28405
+ row: zone.top,
28406
+ sheetId: env.model.getters.getActiveSheetId(),
28407
+ pivotMode: "dynamic",
28408
+ });
28409
+ env.model.dispatch("REFRESH_PIVOT", { id: pivotId });
28410
+ },
28411
+ }));
28412
+ const REINSERT_STATIC_PIVOT_CHILDREN = (env) => env.model.getters.getPivotIds().map((pivotId, index) => ({
28413
+ id: `reinsert_static_pivot_${env.model.getters.getPivotFormulaId(pivotId)}`,
28383
28414
  name: env.model.getters.getPivotDisplayName(pivotId),
28384
28415
  sequence: index,
28385
28416
  execute: (env) => {
@@ -28391,6 +28422,7 @@ const REINSERT_PIVOT_CHILDREN = (env) => env.model.getters.getPivotIds().map((pi
28391
28422
  col: zone.left,
28392
28423
  row: zone.top,
28393
28424
  sheetId: env.model.getters.getActiveSheetId(),
28425
+ pivotMode: "static",
28394
28426
  });
28395
28427
  env.model.dispatch("REFRESH_PIVOT", { id: pivotId });
28396
28428
  },
@@ -29259,12 +29291,20 @@ const splitToColumns = {
29259
29291
  isEnabled: (env) => env.model.getters.isSingleColSelected(),
29260
29292
  icon: "o-spreadsheet-Icon.SPLIT_TEXT",
29261
29293
  };
29262
- const reinsertPivotMenu = {
29263
- id: "reinsert_pivot",
29264
- name: _t("Re-insert pivot"),
29294
+ const reinsertDynamicPivotMenu = {
29295
+ id: "reinsert_dynamic_pivot",
29296
+ name: _t("Re-insert dynamic pivot"),
29297
+ sequence: 1020,
29298
+ icon: "o-spreadsheet-Icon.INSERT_PIVOT",
29299
+ children: [REINSERT_DYNAMIC_PIVOT_CHILDREN],
29300
+ isVisible: (env) => env.model.getters.getPivotIds().length > 0,
29301
+ };
29302
+ const reinsertStaticPivotMenu = {
29303
+ id: "reinsert_static_pivot",
29304
+ name: _t("Re-insert static pivot"),
29265
29305
  sequence: 1020,
29266
29306
  icon: "o-spreadsheet-Icon.INSERT_PIVOT",
29267
- children: [REINSERT_PIVOT_CHILDREN],
29307
+ children: [REINSERT_STATIC_PIVOT_CHILDREN],
29268
29308
  isVisible: (env) => env.model.getters.getPivotIds().length > 0,
29269
29309
  };
29270
29310
 
@@ -29273,7 +29313,8 @@ var ACTION_DATA = /*#__PURE__*/Object.freeze({
29273
29313
  createRemoveFilter: createRemoveFilter,
29274
29314
  createRemoveFilterTool: createRemoveFilterTool,
29275
29315
  dataCleanup: dataCleanup,
29276
- reinsertPivotMenu: reinsertPivotMenu,
29316
+ reinsertDynamicPivotMenu: reinsertDynamicPivotMenu,
29317
+ reinsertStaticPivotMenu: reinsertStaticPivotMenu,
29277
29318
  removeDuplicates: removeDuplicates,
29278
29319
  sortAscending: sortAscending,
29279
29320
  sortDescending: sortDescending,
@@ -30755,7 +30796,8 @@ topbarMenuRegistry
30755
30796
  };
30756
30797
  });
30757
30798
  })
30758
- .addChild("reinsert_pivot", ["data"], reinsertPivotMenu);
30799
+ .addChild("reinsert_dynamic_pivot", ["data"], reinsertDynamicPivotMenu)
30800
+ .addChild("reinsert_static_pivot", ["data"], reinsertStaticPivotMenu);
30759
30801
 
30760
30802
  class OTRegistry extends Registry {
30761
30803
  /**
@@ -44065,6 +44107,18 @@ function convertOperator(operator) {
44065
44107
  // -------------------------------------
44066
44108
  // WORKSHEET HELPERS
44067
44109
  // -------------------------------------
44110
+ function getCellType(value) {
44111
+ switch (typeof value) {
44112
+ case "boolean":
44113
+ return "b";
44114
+ case "string":
44115
+ return "str";
44116
+ case "number":
44117
+ return "n";
44118
+ default:
44119
+ return undefined;
44120
+ }
44121
+ }
44068
44122
  function convertHeightToExcel(height) {
44069
44123
  return Math.round(HEIGHT_FACTOR * height * 100) / 100;
44070
44124
  }
@@ -54315,8 +54369,9 @@ class Evaluator {
54315
54369
  }
54316
54370
  getCellsDependingOn(positions) {
54317
54371
  const ranges = [];
54318
- for (const position of positions) {
54319
- ranges.push({ sheetId: position.sheetId, zone: positionToZone(position) });
54372
+ const zonesBySheetIds = aggregatePositionsToZones(positions);
54373
+ for (const sheetId in zonesBySheetIds) {
54374
+ ranges.push(...zonesBySheetIds[sheetId].map((zone) => ({ sheetId, zone })));
54320
54375
  }
54321
54376
  return this.formulaDependencies().getCellsDependingOn(ranges);
54322
54377
  }
@@ -57226,9 +57281,9 @@ class Session extends EventBus {
57226
57281
  /**
57227
57282
  * Notify the server that the user client left the collaborative session
57228
57283
  */
57229
- leave(data) {
57284
+ async leave(data) {
57230
57285
  if (Object.keys(this.clients).length === 1 && this.processedRevisions.size) {
57231
- this.snapshot(data());
57286
+ await this.snapshot(data());
57232
57287
  }
57233
57288
  delete this.clients[this.clientId];
57234
57289
  this.transportService.leave(this.clientId);
@@ -57241,12 +57296,12 @@ class Session extends EventBus {
57241
57296
  /**
57242
57297
  * Send a snapshot of the spreadsheet to the collaboration server
57243
57298
  */
57244
- snapshot(data) {
57299
+ async snapshot(data) {
57245
57300
  if (this.pendingMessages.length !== 0) {
57246
57301
  return;
57247
57302
  }
57248
57303
  const snapshotId = this.uuidGenerator.uuidv4();
57249
- this.transportService.sendMessage({
57304
+ await this.transportService.sendMessage({
57250
57305
  type: "SNAPSHOT",
57251
57306
  nextRevisionId: snapshotId,
57252
57307
  serverRevisionId: this.serverRevisionId,
@@ -57930,7 +57985,7 @@ class InsertPivotPlugin extends UIPlugin {
57930
57985
  this.duplicatePivotInNewSheet(cmd.pivotId, cmd.newPivotId, cmd.newSheetId);
57931
57986
  break;
57932
57987
  case "INSERT_PIVOT_WITH_TABLE":
57933
- this.insertPivotWithTable(cmd.sheetId, cmd.col, cmd.row, cmd.pivotId, cmd.table);
57988
+ this.insertPivotWithTable(cmd.sheetId, cmd.col, cmd.row, cmd.pivotId, cmd.table, cmd.pivotMode);
57934
57989
  break;
57935
57990
  }
57936
57991
  }
@@ -58006,26 +58061,44 @@ class InsertPivotPlugin extends UIPlugin {
58006
58061
  }
58007
58062
  return name;
58008
58063
  }
58009
- insertPivotWithTable(sheetId, col, row, pivotId, table) {
58064
+ insertPivotWithTable(sheetId, col, row, pivotId, table, mode) {
58010
58065
  const { cols, rows, measures, fieldsType } = table;
58011
58066
  const pivotTable = new SpreadsheetPivotTable(cols, rows, measures, fieldsType || {});
58067
+ const numberOfHeaders = pivotTable.columns.length - 1;
58012
58068
  this.resizeSheet(sheetId, col, row, pivotTable);
58013
58069
  const pivotFormulaId = this.getters.getPivotFormulaId(pivotId);
58014
- this.dispatch("UPDATE_CELL", {
58015
- sheetId,
58016
- col,
58017
- row,
58018
- content: `=PIVOT(${pivotFormulaId})`,
58019
- });
58020
- const zone = {
58021
- left: col,
58022
- right: col,
58023
- top: row,
58024
- bottom: row,
58025
- };
58026
- const numberOfHeaders = pivotTable.columns.length - 1;
58070
+ let zone;
58071
+ if (mode === "dynamic") {
58072
+ this.dispatch("UPDATE_CELL", {
58073
+ sheetId,
58074
+ col,
58075
+ row,
58076
+ content: `=PIVOT(${pivotFormulaId})`,
58077
+ });
58078
+ zone = {
58079
+ left: col,
58080
+ right: col,
58081
+ top: row,
58082
+ bottom: row,
58083
+ };
58084
+ }
58085
+ else {
58086
+ this.dispatch("INSERT_PIVOT", {
58087
+ sheetId,
58088
+ col,
58089
+ row,
58090
+ pivotId,
58091
+ table: pivotTable.export(),
58092
+ });
58093
+ zone = {
58094
+ left: col,
58095
+ right: col + pivotTable.getNumberOfDataColumns(),
58096
+ top: row,
58097
+ bottom: row + numberOfHeaders + pivotTable.rows.length,
58098
+ };
58099
+ }
58027
58100
  this.dispatch("CREATE_TABLE", {
58028
- tableType: "dynamic",
58101
+ tableType: mode,
58029
58102
  sheetId,
58030
58103
  ranges: [this.getters.getRangeDataFromZone(sheetId, zone)],
58031
58104
  config: { ...PIVOT_TABLE_CONFIG, numberOfHeaders },
@@ -60227,6 +60300,8 @@ class GridSelectionPlugin extends UIPlugin {
60227
60300
  this.selectedFigureId = null;
60228
60301
  break;
60229
60302
  }
60303
+ }
60304
+ finalize() {
60230
60305
  /** Any change to the selection has to be reflected in the selection processor. */
60231
60306
  this.selection.resetDefaultAnchor(this, deepCopy(this.gridSelection.anchor));
60232
60307
  }
@@ -61008,7 +61083,6 @@ class SheetViewPlugin extends UIPlugin {
61008
61083
  }
61009
61084
  }
61010
61085
  handle(cmd) {
61011
- this.cleanViewports();
61012
61086
  // changing the evaluation can hide/show rows because of data filters
61013
61087
  if (invalidateEvaluationCommands.has(cmd.type)) {
61014
61088
  for (const sheetId of this.getters.getSheetIds()) {
@@ -61024,6 +61098,7 @@ class SheetViewPlugin extends UIPlugin {
61024
61098
  break;
61025
61099
  case "UNDO":
61026
61100
  case "REDO":
61101
+ this.cleanViewports();
61027
61102
  for (const sheetId of this.getters.getSheetIds()) {
61028
61103
  this.sheetsWithDirtyViewports.add(sheetId);
61029
61104
  }
@@ -61078,6 +61153,9 @@ class SheetViewPlugin extends UIPlugin {
61078
61153
  }
61079
61154
  }
61080
61155
  break;
61156
+ case "DELETE_SHEET":
61157
+ this.cleanViewports();
61158
+ break;
61081
61159
  case "ACTIVATE_SHEET":
61082
61160
  this.sheetsWithDirtyViewports.add(cmd.sheetIdTo);
61083
61161
  break;
@@ -62365,6 +62443,17 @@ css /* scss */ `
62365
62443
  .o-bottom-bar-fade-in {
62366
62444
  background-image: linear-gradient(90deg, #cfcfcf, transparent 1%);
62367
62445
  }
62446
+
62447
+ .o-sheet-list {
62448
+ overflow-y: hidden;
62449
+ overflow-x: auto;
62450
+
62451
+ &::-webkit-scrollbar {
62452
+ display: none; /* Chrome */
62453
+ }
62454
+ -ms-overflow-style: none; /* IE and Edge */
62455
+ scrollbar-width: none; /* Firefox */
62456
+ }
62368
62457
  }
62369
62458
 
62370
62459
  .o-bottom-bar-arrows {
@@ -64338,7 +64427,7 @@ class Spreadsheet extends Component {
64338
64427
 
64339
64428
  class LocalTransportService {
64340
64429
  listeners = [];
64341
- sendMessage(message) {
64430
+ async sendMessage(message) {
64342
64431
  for (const { callback } of this.listeners) {
64343
64432
  callback(message);
64344
64433
  }
@@ -66431,17 +66520,13 @@ function addFormula(cell) {
66431
66520
  if (!formula) {
66432
66521
  return { attrs: [], node: escapeXml `` };
66433
66522
  }
66434
- const attrs = [];
66435
- let node = escapeXml ``;
66436
- let cycle = escapeXml ``;
66437
- const XlsxFormula = adaptFormulaToExcel(formula);
66438
- // hack for cycles : if we don't set a value (be it 0 or #VALUE!), it will appear as invisible on excel,
66439
- // Making it very hard for the client to find where the recursion is.
66440
- if (cell.value === CellErrorType.CircularDependency) {
66441
- attrs.push(["t", "str"]);
66442
- cycle = escapeXml /*xml*/ `<v>${cell.value}</v>`;
66523
+ const type = getCellType(cell.value);
66524
+ if (type === undefined) {
66525
+ return { attrs: [], node: escapeXml `` };
66443
66526
  }
66444
- node = escapeXml /*xml*/ `<f>${XlsxFormula}</f>${cycle}`;
66527
+ const attrs = [["t", type]];
66528
+ const XlsxFormula = adaptFormulaToExcel(formula);
66529
+ const node = escapeXml /*xml*/ `<f>${XlsxFormula}</f><v>${cell.value}</v>`;
66445
66530
  return { attrs, node };
66446
66531
  }
66447
66532
  function addContent(content, sharedStrings, forceString = false) {
@@ -67855,8 +67940,8 @@ class Model extends EventBus {
67855
67940
  joinSession() {
67856
67941
  this.session.join(this.config.client);
67857
67942
  }
67858
- leaveSession() {
67859
- this.session.leave(lazy(() => this.exportData()));
67943
+ async leaveSession() {
67944
+ await this.session.leave(lazy(() => this.exportData()));
67860
67945
  }
67861
67946
  setupUiPlugin(Plugin) {
67862
67947
  const plugin = new Plugin(this.uiPluginConfig);
@@ -68415,6 +68500,6 @@ const constants = {
68415
68500
  export { AbstractCellClipboardHandler, AbstractChart, AbstractFigureClipboardHandler, CellErrorType, CommandResult, CorePlugin, DispatchResult, EvaluationError, Model, PivotRuntimeDefinition, Registry, Revision, SPREADSHEET_DIMENSIONS, Spreadsheet, SpreadsheetPivotTable, 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 };
68416
68501
 
68417
68502
 
68418
- __info__.version = "17.4.6";
68419
- __info__.date = "2024-08-26T13:50:49.623Z";
68420
- __info__.hash = "f5648d9";
68503
+ __info__.version = "17.4.7";
68504
+ __info__.date = "2024-09-05T09:32:00.461Z";
68505
+ __info__.hash = "c14a4c9";