@odoo/o-spreadsheet 18.2.0-alpha.8 → 18.3.0-alpha.0

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 18.2.0-alpha.8
6
- * @date 2025-02-14T08:40:13.286Z
7
- * @hash 19d45d9
5
+ * @version 18.3.0-alpha.0
6
+ * @date 2025-02-18T09:02:28.625Z
7
+ * @hash 9b88da0
8
8
  */
9
9
 
10
10
  (function (exports, owl) {
@@ -2230,17 +2230,7 @@
2230
2230
  */
2231
2231
  function toUnboundedZone(xc) {
2232
2232
  const zone = toZoneWithoutBoundaryChanges(xc);
2233
- if (zone.right !== undefined && zone.right < zone.left) {
2234
- const tmp = zone.left;
2235
- zone.left = zone.right;
2236
- zone.right = tmp;
2237
- }
2238
- if (zone.bottom !== undefined && zone.bottom < zone.top) {
2239
- const tmp = zone.top;
2240
- zone.top = zone.bottom;
2241
- zone.bottom = tmp;
2242
- }
2243
- return zone;
2233
+ return reorderZone(zone);
2244
2234
  }
2245
2235
  /**
2246
2236
  * Convert from a cartesian reference to a Zone.
@@ -2514,11 +2504,11 @@
2514
2504
  return positions;
2515
2505
  }
2516
2506
  function reorderZone(zone) {
2517
- if (zone.left > zone.right) {
2518
- zone = { left: zone.right, right: zone.left, top: zone.top, bottom: zone.bottom };
2507
+ if (zone.right !== undefined && zone.left > zone.right) {
2508
+ zone = { ...zone, left: zone.right, right: zone.left };
2519
2509
  }
2520
- if (zone.top > zone.bottom) {
2521
- zone = { left: zone.left, right: zone.right, top: zone.bottom, bottom: zone.top };
2510
+ if (zone.bottom !== undefined && zone.top > zone.bottom) {
2511
+ zone = { ...zone, top: zone.bottom, bottom: zone.top };
2522
2512
  }
2523
2513
  return zone;
2524
2514
  }
@@ -3423,12 +3413,12 @@
3423
3413
  function isRangeDependant(cmd) {
3424
3414
  return "ranges" in cmd;
3425
3415
  }
3426
- function isZoneDependent(cmd) {
3427
- return "zone" in cmd;
3428
- }
3429
3416
  function isPositionDependent(cmd) {
3430
3417
  return "col" in cmd && "row" in cmd && "sheetId" in cmd;
3431
3418
  }
3419
+ function isZoneDependent(cmd) {
3420
+ return "sheetId" in cmd && "zone" in cmd;
3421
+ }
3432
3422
  const invalidateEvaluationCommands = new Set([
3433
3423
  "RENAME_SHEET",
3434
3424
  "DELETE_SHEET",
@@ -3440,6 +3430,7 @@
3440
3430
  "REDO",
3441
3431
  "ADD_MERGE",
3442
3432
  "REMOVE_MERGE",
3433
+ "DUPLICATE_SHEET",
3443
3434
  "UPDATE_LOCALE",
3444
3435
  "ADD_PIVOT",
3445
3436
  "UPDATE_PIVOT",
@@ -3469,7 +3460,6 @@
3469
3460
  ]);
3470
3461
  const invalidateDependenciesCommands = new Set(["MOVE_RANGES"]);
3471
3462
  const invalidateCFEvaluationCommands = new Set([
3472
- "DUPLICATE_SHEET",
3473
3463
  "EVALUATE_CELLS",
3474
3464
  "ADD_CONDITIONAL_FORMAT",
3475
3465
  "REMOVE_CONDITIONAL_FORMAT",
@@ -3639,6 +3629,7 @@
3639
3629
  CommandResult["InvalidRange"] = "InvalidRange";
3640
3630
  CommandResult["InvalidZones"] = "InvalidZones";
3641
3631
  CommandResult["InvalidSheetId"] = "InvalidSheetId";
3632
+ CommandResult["InvalidCellId"] = "InvalidCellId";
3642
3633
  CommandResult["InvalidFigureId"] = "InvalidFigureId";
3643
3634
  CommandResult["InputAlreadyFocused"] = "InputAlreadyFocused";
3644
3635
  CommandResult["MaximumRangesReached"] = "MaximumRangesReached";
@@ -12237,6 +12228,25 @@ stores.inject(MyMetaStore, storeInstance);
12237
12228
  isExported: true,
12238
12229
  };
12239
12230
  // -----------------------------------------------------------------------------
12231
+ // LOG
12232
+ // -----------------------------------------------------------------------------
12233
+ const LOG = {
12234
+ description: _t("The logarithm of a number, for a given base."),
12235
+ args: [
12236
+ arg("value (number)", _t("The value for which to calculate the logarithm.")),
12237
+ arg("base (number, default=10)", _t("The base of the logarithm.")),
12238
+ ],
12239
+ compute: function (value, base = { value: 10 }) {
12240
+ const _value = toNumber(value, this.locale);
12241
+ const _base = toNumber(base, this.locale);
12242
+ assert(() => _value > 0, _t("The value (%s) must be strictly positive.", _value.toString()));
12243
+ assert(() => _base > 0, _t("The base (%s) must be strictly positive.", _base.toString()));
12244
+ assert(() => _base !== 1, _t("The base must be different from 1."));
12245
+ return Math.log10(_value) / Math.log10(_base);
12246
+ },
12247
+ isExported: true,
12248
+ };
12249
+ // -----------------------------------------------------------------------------
12240
12250
  // MOD
12241
12251
  // -----------------------------------------------------------------------------
12242
12252
  function mod(dividend, divisor) {
@@ -12776,6 +12786,7 @@ stores.inject(MyMetaStore, storeInstance);
12776
12786
  ISODD: ISODD,
12777
12787
  ISO_CEILING: ISO_CEILING,
12778
12788
  LN: LN,
12789
+ LOG: LOG,
12779
12790
  MOD: MOD,
12780
12791
  MUNIT: MUNIT,
12781
12792
  ODD: ODD,
@@ -28931,7 +28942,7 @@ stores.inject(MyMetaStore, storeInstance);
28931
28942
  const dataset = {
28932
28943
  label,
28933
28944
  data,
28934
- borderColor: BACKGROUND_CHART_COLOR,
28945
+ borderColor: definition.background || "#FFFFFF",
28935
28946
  backgroundColor,
28936
28947
  hoverOffset: 30,
28937
28948
  };
@@ -38919,7 +38930,7 @@ stores.inject(MyMetaStore, storeInstance);
38919
38930
  .o-font-size-editor {
38920
38931
  height: calc(100% - 4px);
38921
38932
  input.o-font-size {
38922
- outline-color: ${SELECTION_BORDER_COLOR};
38933
+ outline: none;
38923
38934
  height: 20px;
38924
38935
  width: 23px;
38925
38936
  }
@@ -53465,6 +53476,10 @@ stores.inject(MyMetaStore, storeInstance);
53465
53476
  return this.checkValidations(cmd, this.checkCellOutOfSheet, this.checkUselessUpdateCell);
53466
53477
  case "CLEAR_CELL":
53467
53478
  return this.checkValidations(cmd, this.checkCellOutOfSheet, this.checkUselessClearCell);
53479
+ case "UPDATE_CELL_POSITION":
53480
+ return !cmd.cellId || this.cells[cmd.sheetId]?.[cmd.cellId]
53481
+ ? "Success" /* CommandResult.Success */
53482
+ : "InvalidCellId" /* CommandResult.InvalidCellId */;
53468
53483
  default:
53469
53484
  return "Success" /* CommandResult.Success */;
53470
53485
  }
@@ -53509,6 +53524,9 @@ stores.inject(MyMetaStore, storeInstance);
53509
53524
  case "DELETE_CONTENT":
53510
53525
  this.clearZones(cmd.sheetId, cmd.target);
53511
53526
  break;
53527
+ case "DELETE_SHEET": {
53528
+ this.history.update("cells", cmd.sheetId, undefined);
53529
+ }
53512
53530
  }
53513
53531
  }
53514
53532
  clearZones(sheetId, zones) {
@@ -54299,6 +54317,9 @@ stores.inject(MyMetaStore, storeInstance);
54299
54317
  allowDispatch(cmd) {
54300
54318
  switch (cmd.type) {
54301
54319
  case "ADD_CONDITIONAL_FORMAT":
54320
+ if (cmd.ranges.some((rangeData) => !this.getters.tryGetSheet(rangeData._sheetId))) {
54321
+ return "InvalidSheetId" /* CommandResult.InvalidSheetId */;
54322
+ }
54302
54323
  return this.checkValidations(cmd, this.checkCFRule, this.checkEmptyRange, this.checkCFHasChanged);
54303
54324
  case "CHANGE_CONDITIONAL_FORMAT_PRIORITY":
54304
54325
  return this.checkValidPriorityChange(cmd.cfId, cmd.delta, cmd.sheetId);
@@ -54715,8 +54736,17 @@ stores.inject(MyMetaStore, storeInstance);
54715
54736
  allowDispatch(cmd) {
54716
54737
  switch (cmd.type) {
54717
54738
  case "ADD_DATA_VALIDATION_RULE":
54739
+ if (!this.getters.tryGetSheet(cmd.sheetId)) {
54740
+ return "InvalidSheetId" /* CommandResult.InvalidSheetId */;
54741
+ }
54742
+ if (cmd.ranges.some((rangeData) => !this.getters.tryGetSheet(rangeData._sheetId))) {
54743
+ return "InvalidSheetId" /* CommandResult.InvalidSheetId */;
54744
+ }
54718
54745
  return this.checkValidations(cmd, this.chainValidations(this.checkEmptyRange, this.checkValidRange, this.checkCriterionTypeIsValid, this.checkCriterionHasValidNumberOfValues, this.checkCriterionValuesAreValid));
54719
54746
  case "REMOVE_DATA_VALIDATION_RULE":
54747
+ if (!this.getters.tryGetSheet(cmd.sheetId)) {
54748
+ return "InvalidSheetId" /* CommandResult.InvalidSheetId */;
54749
+ }
54720
54750
  if (!this.rules[cmd.sheetId].find((rule) => rule.id === cmd.id)) {
54721
54751
  return "UnknownDataValidationRule" /* CommandResult.UnknownDataValidationRule */;
54722
54752
  }
@@ -54943,6 +54973,7 @@ stores.inject(MyMetaStore, storeInstance);
54943
54973
  class FigurePlugin extends CorePlugin {
54944
54974
  static getters = ["getFigures", "getFigure", "getFigureSheetId"];
54945
54975
  figures = {};
54976
+ insertionOrders = []; // TODO use a list in master
54946
54977
  // ---------------------------------------------------------------------------
54947
54978
  // Command Handling
54948
54979
  // ---------------------------------------------------------------------------
@@ -55045,11 +55076,14 @@ stores.inject(MyMetaStore, storeInstance);
55045
55076
  }
55046
55077
  addFigure(figure, sheetId) {
55047
55078
  this.history.update("figures", sheetId, figure.id, figure);
55079
+ this.history.update("insertionOrders", this.insertionOrders.length, figure.id);
55048
55080
  }
55049
55081
  deleteSheet(sheetId) {
55082
+ this.history.update("insertionOrders", this.insertionOrders.filter((id) => !this.figures[sheetId]?.[id]));
55050
55083
  this.history.update("figures", sheetId, undefined);
55051
55084
  }
55052
55085
  removeFigure(id, sheetId) {
55086
+ this.history.update("insertionOrders", this.insertionOrders.filter((figureId) => figureId !== id));
55053
55087
  this.history.update("figures", sheetId, id, undefined);
55054
55088
  }
55055
55089
  checkFigureExists(sheetId, figureId) {
@@ -55068,7 +55102,14 @@ stores.inject(MyMetaStore, storeInstance);
55068
55102
  // Getters
55069
55103
  // ---------------------------------------------------------------------------
55070
55104
  getFigures(sheetId) {
55071
- return Object.values(this.figures[sheetId] || {}).filter(isDefined);
55105
+ const figures = [];
55106
+ for (const figureId of this.insertionOrders) {
55107
+ const figure = this.figures[sheetId]?.[figureId];
55108
+ if (figure) {
55109
+ figures.push(figure);
55110
+ }
55111
+ }
55112
+ return figures;
55072
55113
  }
55073
55114
  getFigure(sheetId, figureId) {
55074
55115
  return this.figures[sheetId]?.[figureId];
@@ -55081,11 +55122,9 @@ stores.inject(MyMetaStore, storeInstance);
55081
55122
  // ---------------------------------------------------------------------------
55082
55123
  import(data) {
55083
55124
  for (let sheet of data.sheets) {
55084
- const figures = {};
55085
- sheet.figures.forEach((figure) => {
55086
- figures[figure.id] = figure;
55087
- });
55088
- this.figures[sheet.id] = figures;
55125
+ for (const figure of sheet.figures) {
55126
+ this.addFigure(figure, sheet.id);
55127
+ }
55089
55128
  }
55090
55129
  }
55091
55130
  export(data) {
@@ -56545,6 +56584,9 @@ stores.inject(MyMetaStore, storeInstance);
56545
56584
  case "CREATE_SHEET": {
56546
56585
  return this.checkValidations(cmd, this.checkSheetName, this.checkSheetPosition);
56547
56586
  }
56587
+ case "DUPLICATE_SHEET": {
56588
+ return this.sheets[cmd.sheetIdTo] ? "DuplicatedSheetId" /* CommandResult.DuplicatedSheetId */ : "Success" /* CommandResult.Success */;
56589
+ }
56548
56590
  case "MOVE_SHEET":
56549
56591
  try {
56550
56592
  const currentIndex = this.orderedSheetIds.findIndex((id) => id === cmd.sheetId);
@@ -57347,14 +57389,18 @@ stores.inject(MyMetaStore, storeInstance);
57347
57389
  checkZonesAreInSheet(cmd) {
57348
57390
  if (!("sheetId" in cmd))
57349
57391
  return "Success" /* CommandResult.Success */;
57392
+ if ("ranges" in cmd &&
57393
+ cmd.ranges.some((rangeData) => rangeData._sheetId !== "" && !this.getters.tryGetSheet(rangeData._sheetId))) {
57394
+ return "InvalidSheetId" /* CommandResult.InvalidSheetId */;
57395
+ }
57350
57396
  return this.checkZonesExistInSheet(cmd.sheetId, this.getCommandZones(cmd));
57351
57397
  }
57352
57398
  }
57353
57399
 
57354
- let nextTableId = 1;
57355
57400
  class TablePlugin extends CorePlugin {
57356
57401
  static getters = ["getCoreTable", "getCoreTables", "getCoreTableMatchingTopLeft"];
57357
57402
  tables = {};
57403
+ nextTableId = 1;
57358
57404
  adaptRanges(applyChange, sheetId) {
57359
57405
  const sheetIds = sheetId ? [sheetId] : this.getters.getSheetIds();
57360
57406
  for (const sheetId of sheetIds) {
@@ -57366,6 +57412,9 @@ stores.inject(MyMetaStore, storeInstance);
57366
57412
  allowDispatch(cmd) {
57367
57413
  switch (cmd.type) {
57368
57414
  case "CREATE_TABLE":
57415
+ if (cmd.ranges.some((rangeData) => !this.getters.tryGetSheet(rangeData._sheetId) || rangeData._sheetId !== cmd.sheetId)) {
57416
+ return "InvalidSheetId" /* CommandResult.InvalidSheetId */;
57417
+ }
57369
57418
  const zones = cmd.ranges.map((rangeData) => this.getters.getRangeFromRangeData(rangeData).zone);
57370
57419
  if (!areZonesContinuous(zones)) {
57371
57420
  return "NonContinuousTargets" /* CommandResult.NonContinuousTargets */;
@@ -57419,7 +57468,7 @@ stores.inject(MyMetaStore, storeInstance);
57419
57468
  const union = this.getters.getRangesUnion(ranges);
57420
57469
  const mergesInTarget = this.getters.getMergesInZone(cmd.sheetId, union.zone);
57421
57470
  this.dispatch("REMOVE_MERGE", { sheetId: cmd.sheetId, target: mergesInTarget });
57422
- const id = `${nextTableId++}`;
57471
+ const id = this.consumeNextId();
57423
57472
  const config = cmd.config || DEFAULT_TABLE_CONFIG;
57424
57473
  const newTable = cmd.tableType === "dynamic"
57425
57474
  ? this.createDynamicTable(id, union, config)
@@ -57572,7 +57621,7 @@ stores.inject(MyMetaStore, storeInstance);
57572
57621
  filters = [];
57573
57622
  for (const i of range(zone.left, zone.right + 1)) {
57574
57623
  const filterZone = { ...zone, left: i, right: i };
57575
- const uid = `${nextTableId++}`;
57624
+ const uid = this.consumeNextId();
57576
57625
  filters.push(this.createFilterFromZone(uid, tableRange.sheetId, filterZone, config));
57577
57626
  }
57578
57627
  }
@@ -57637,7 +57686,7 @@ stores.inject(MyMetaStore, storeInstance);
57637
57686
  ? table.filters.find((f) => f.col === i)
57638
57687
  : undefined;
57639
57688
  const filterZone = { ...tableZone, left: i, right: i };
57640
- const filterId = oldFilter?.id || `${nextTableId++}`;
57689
+ const filterId = oldFilter?.id || this.consumeNextId();
57641
57690
  filters.push(this.createFilterFromZone(filterId, tableRange.sheetId, filterZone, config));
57642
57691
  }
57643
57692
  }
@@ -57738,7 +57787,7 @@ stores.inject(MyMetaStore, storeInstance);
57738
57787
  if (filters.length < zoneToDimension(tableZone).numberOfCols) {
57739
57788
  for (let col = tableZone.left; col <= tableZone.right; col++) {
57740
57789
  if (!filters.find((filter) => filter.col === col)) {
57741
- const uid = `${nextTableId++}`;
57790
+ const uid = this.consumeNextId();
57742
57791
  const filterZone = { ...tableZone, left: col, right: col };
57743
57792
  filters.push(this.createFilterFromZone(uid, sheetId, filterZone, table.config));
57744
57793
  }
@@ -57748,13 +57797,18 @@ stores.inject(MyMetaStore, storeInstance);
57748
57797
  const newTable = this.createStaticTable(table.id, table.type, newTableRange, table.config, filters);
57749
57798
  this.history.update("tables", sheetId, table.id, newTable);
57750
57799
  }
57800
+ consumeNextId() {
57801
+ const id = `${this.nextTableId}`;
57802
+ this.history.update("nextTableId", this.nextTableId + 1);
57803
+ return id;
57804
+ }
57751
57805
  // ---------------------------------------------------------------------------
57752
57806
  // Import/Export
57753
57807
  // ---------------------------------------------------------------------------
57754
57808
  import(data) {
57755
57809
  for (const sheet of data.sheets) {
57756
57810
  for (const tableData of sheet.tables || []) {
57757
- const uuid = `${nextTableId++}`;
57811
+ const uuid = this.consumeNextId();
57758
57812
  const tableConfig = tableData.config || DEFAULT_TABLE_CONFIG;
57759
57813
  const range = this.getters.getRangeFromSheetXC(sheet.id, tableData.range);
57760
57814
  const tableType = tableData.type || "static";
@@ -57802,7 +57856,10 @@ stores.inject(MyMetaStore, storeInstance);
57802
57856
  allowDispatch(cmd) {
57803
57857
  switch (cmd.type) {
57804
57858
  case "GROUP_HEADERS": {
57805
- const { start, end } = cmd;
57859
+ const { start, end, sheetId } = cmd;
57860
+ if (!this.getters.tryGetSheet(sheetId)) {
57861
+ return "InvalidSheetId" /* CommandResult.InvalidSheetId */;
57862
+ }
57806
57863
  if (!this.getters.doesHeadersExist(cmd.sheetId, cmd.dimension, [start, end])) {
57807
57864
  return "InvalidHeaderGroupStartEnd" /* CommandResult.InvalidHeaderGroupStartEnd */;
57808
57865
  }
@@ -57815,7 +57872,10 @@ stores.inject(MyMetaStore, storeInstance);
57815
57872
  break;
57816
57873
  }
57817
57874
  case "UNGROUP_HEADERS": {
57818
- const { start, end } = cmd;
57875
+ const { start, end, sheetId } = cmd;
57876
+ if (!this.getters.tryGetSheet(sheetId)) {
57877
+ return "InvalidSheetId" /* CommandResult.InvalidSheetId */;
57878
+ }
57819
57879
  if (!this.getters.doesHeadersExist(cmd.sheetId, cmd.dimension, [start, end])) {
57820
57880
  return "InvalidHeaderGroupStartEnd" /* CommandResult.InvalidHeaderGroupStartEnd */;
57821
57881
  }
@@ -57826,6 +57886,9 @@ stores.inject(MyMetaStore, storeInstance);
57826
57886
  }
57827
57887
  case "UNFOLD_HEADER_GROUP":
57828
57888
  case "FOLD_HEADER_GROUP":
57889
+ if (!this.getters.tryGetSheet(cmd.sheetId)) {
57890
+ return "InvalidSheetId" /* CommandResult.InvalidSheetId */;
57891
+ }
57829
57892
  const group = this.findGroupWithStartEnd(cmd.sheetId, cmd.dimension, cmd.start, cmd.end);
57830
57893
  if (!group) {
57831
57894
  return "UnknownHeaderGroup" /* CommandResult.UnknownHeaderGroup */;
@@ -58226,6 +58289,9 @@ stores.inject(MyMetaStore, storeInstance);
58226
58289
  return this.checkDuplicatedMeasureIds(cmd.pivot);
58227
58290
  }
58228
58291
  case "UPDATE_PIVOT": {
58292
+ if (!(cmd.pivotId in this.pivots)) {
58293
+ return "PivotIdNotFound" /* CommandResult.PivotIdNotFound */;
58294
+ }
58229
58295
  if (deepEquals(cmd.pivot, this.pivots[cmd.pivotId]?.definition)) {
58230
58296
  return "NoChanges" /* CommandResult.NoChanges */;
58231
58297
  }
@@ -58242,6 +58308,8 @@ stores.inject(MyMetaStore, storeInstance);
58242
58308
  return "EmptyName" /* CommandResult.EmptyName */;
58243
58309
  }
58244
58310
  break;
58311
+ case "REMOVE_PIVOT":
58312
+ case "DUPLICATE_PIVOT":
58245
58313
  case "INSERT_PIVOT": {
58246
58314
  if (!(cmd.pivotId in this.pivots)) {
58247
58315
  return "PivotIdNotFound" /* CommandResult.PivotIdNotFound */;
@@ -58291,7 +58359,7 @@ stores.inject(MyMetaStore, storeInstance);
58291
58359
  break;
58292
58360
  }
58293
58361
  case "UPDATE_PIVOT": {
58294
- this.history.update("pivots", cmd.pivotId, "definition", cmd.pivot);
58362
+ this.history.update("pivots", cmd.pivotId, "definition", deepCopy(cmd.pivot));
58295
58363
  this.compileCalculatedMeasures(cmd.pivot.measures);
58296
58364
  break;
58297
58365
  }
@@ -58362,7 +58430,7 @@ stores.inject(MyMetaStore, storeInstance);
58362
58430
  // Private
58363
58431
  // -------------------------------------------------------------------------
58364
58432
  addPivot(pivotId, pivot, formulaId = this.nextFormulaId.toString()) {
58365
- this.history.update("pivots", pivotId, { definition: pivot, formulaId });
58433
+ this.history.update("pivots", pivotId, { definition: deepCopy(pivot), formulaId });
58366
58434
  this.compileCalculatedMeasures(pivot.measures);
58367
58435
  this.history.update("formulaIds", formulaId, pivotId);
58368
58436
  this.history.update("nextFormulaId", this.nextFormulaId + 1);
@@ -63280,6 +63348,9 @@ stores.inject(MyMetaStore, storeInstance);
63280
63348
  };
63281
63349
  }
63282
63350
  function createSheetTransformation(toTransform, executed) {
63351
+ if (toTransform.sheetId === executed.sheetId) {
63352
+ toTransform = { ...toTransform, sheetId: `${toTransform.sheetId}~` };
63353
+ }
63283
63354
  if (toTransform.name === executed.name) {
63284
63355
  return {
63285
63356
  ...toTransform,
@@ -63923,15 +63994,6 @@ stores.inject(MyMetaStore, storeInstance);
63923
63994
  }
63924
63995
  this.sendPendingMessage();
63925
63996
  }
63926
- dropPendingRevision(revisionId) {
63927
- this.revisions.drop(revisionId);
63928
- const revisionIds = this.pendingMessages
63929
- .filter((message) => message.type === "REMOTE_REVISION")
63930
- .map((message) => message.nextRevisionId);
63931
- this.trigger("pending-revisions-dropped", { revisionIds });
63932
- this.waitingAck = false;
63933
- this.waitingUndoRedoAck = false;
63934
- }
63935
63997
  /**
63936
63998
  * Send the next pending message
63937
63999
  */
@@ -63940,15 +64002,14 @@ stores.inject(MyMetaStore, storeInstance);
63940
64002
  if (!message)
63941
64003
  return;
63942
64004
  if (message.type === "REMOTE_REVISION") {
63943
- const revision = this.revisions.get(message.nextRevisionId);
64005
+ let revision = this.revisions.get(message.nextRevisionId);
63944
64006
  if (revision.commands.length === 0) {
63945
64007
  /**
63946
- * The command is empty, we have to drop all the next local revisions
64008
+ * The command is empty, we have to rebase all the next local revisions
63947
64009
  * to avoid issues with undo/redo
63948
64010
  */
63949
- this.dropPendingRevision(revision.id);
63950
- this.pendingMessages = [];
63951
- return;
64011
+ this.revisions.rebase(revision.id);
64012
+ revision = this.revisions.get(message.nextRevisionId);
63952
64013
  }
63953
64014
  message = {
63954
64015
  ...message,
@@ -63984,18 +64045,16 @@ stores.inject(MyMetaStore, storeInstance);
63984
64045
  case "REVISION_UNDONE": {
63985
64046
  this.waitingAck = false;
63986
64047
  this.pendingMessages = this.pendingMessages.filter((msg) => msg.nextRevisionId !== message.nextRevisionId);
63987
- const pendingRemoteRevisions = this.pendingMessages.filter((message) => message.type === "REMOTE_REVISION");
63988
- const firstTransformedRevisionIndex = pendingRemoteRevisions.findIndex((message) => !deepEquals(message.commands, this.revisions.get(message.nextRevisionId).commands));
63989
- if (firstTransformedRevisionIndex !== -1) {
64048
+ const firstPendingRevisionId = this.pendingMessages.findIndex((message) => message.type === "REMOTE_REVISION");
64049
+ if (firstPendingRevisionId !== -1) {
63990
64050
  /**
63991
64051
  * Some revisions undergo transformations that may cause issues with
63992
64052
  * undo/redo if the transformation is destructive (we don't get back
63993
64053
  * the original command by transforming it with the inverse).
63994
- * To prevent these problems, we must discard all subsequent local
64054
+ * To prevent these problems, we must rebase all subsequent local
63995
64055
  * revisions.
63996
64056
  */
63997
- this.dropPendingRevision(this.pendingMessages[firstTransformedRevisionIndex].nextRevisionId);
63998
- this.pendingMessages = this.pendingMessages.slice(0, firstTransformedRevisionIndex);
64057
+ this.revisions.rebase(this.pendingMessages[firstPendingRevisionId].nextRevisionId);
63999
64058
  }
64000
64059
  this.serverRevisionId = message.nextRevisionId;
64001
64060
  this.processedRevisions.add(message.nextRevisionId);
@@ -65117,6 +65176,10 @@ stores.inject(MyMetaStore, storeInstance);
65117
65176
  */
65118
65177
  checkZonesAreInSheet(cmd) {
65119
65178
  const sheetId = "sheetId" in cmd ? cmd.sheetId : this.getters.tryGetActiveSheetId();
65179
+ if ("ranges" in cmd &&
65180
+ cmd.ranges.some((rangeData) => !this.getters.tryGetSheet(rangeData._sheetId))) {
65181
+ return "InvalidSheetId" /* CommandResult.InvalidSheetId */;
65182
+ }
65120
65183
  const zones = this.getters.getCommandZones(cmd);
65121
65184
  if (!sheetId && zones.length > 0) {
65122
65185
  return "NoActiveSheet" /* CommandResult.NoActiveSheet */;
@@ -65671,7 +65734,6 @@ stores.inject(MyMetaStore, storeInstance);
65671
65734
  super(config);
65672
65735
  this.session = config.session;
65673
65736
  this.session.on("new-local-state-update", this, this.onNewLocalStateUpdate);
65674
- this.session.on("pending-revisions-dropped", this, ({ revisionIds }) => this.drop(revisionIds));
65675
65737
  this.session.on("snapshot", this, () => {
65676
65738
  this.undoStack = [];
65677
65739
  this.redoStack = [];
@@ -65741,10 +65803,6 @@ stores.inject(MyMetaStore, storeInstance);
65741
65803
  const lastNonRedoRevision = this.getPossibleRevisionToRepeat();
65742
65804
  return canRepeatRevision(lastNonRedoRevision);
65743
65805
  }
65744
- drop(revisionIds) {
65745
- this.undoStack = this.undoStack.filter((id) => !revisionIds.includes(id));
65746
- this.redoStack = [];
65747
- }
65748
65806
  onNewLocalStateUpdate({ id }) {
65749
65807
  this.undoStack.push(id);
65750
65808
  this.redoStack = [];
@@ -68419,7 +68477,9 @@ stores.inject(MyMetaStore, storeInstance);
68419
68477
  case "UNGROUP_HEADERS":
68420
68478
  case "GROUP_HEADERS":
68421
68479
  case "CREATE_SHEET":
68422
- this.headerPositions[cmd.sheetId] = this.computeHeaderPositionsOfSheet(cmd.sheetId);
68480
+ if (this.getters.tryGetSheet(cmd.sheetId)) {
68481
+ this.headerPositions[cmd.sheetId] = this.computeHeaderPositionsOfSheet(cmd.sheetId);
68482
+ }
68423
68483
  break;
68424
68484
  case "DUPLICATE_SHEET":
68425
68485
  this.headerPositions[cmd.sheetIdTo] = deepCopy(this.headerPositions[cmd.sheetId]);
@@ -68427,12 +68487,14 @@ stores.inject(MyMetaStore, storeInstance);
68427
68487
  }
68428
68488
  }
68429
68489
  finalize() {
68430
- if (this.isDirty) {
68431
- for (const sheetId of this.getters.getSheetIds()) {
68490
+ for (const sheetId of this.getters.getSheetIds()) {
68491
+ // sheets can be created without this plugin being aware of it
68492
+ // in concurrent situations.
68493
+ if (this.isDirty || !this.headerPositions[sheetId]) {
68432
68494
  this.headerPositions[sheetId] = this.computeHeaderPositionsOfSheet(sheetId);
68433
68495
  }
68434
- this.isDirty = false;
68435
68496
  }
68497
+ this.isDirty = false;
68436
68498
  }
68437
68499
  /**
68438
68500
  * Returns the size, start and end coordinates of a column on an unfolded sheet
@@ -70273,6 +70335,10 @@ stores.inject(MyMetaStore, storeInstance);
70273
70335
  </svg>
70274
70336
  `;
70275
70337
  css /* scss */ `
70338
+ .o-topbar-composer-container {
70339
+ height: ${TOPBAR_TOOLBAR_HEIGHT}px;
70340
+ }
70341
+
70276
70342
  .o-topbar-composer {
70277
70343
  height: fit-content;
70278
70344
  margin-top: -1px;
@@ -71836,9 +71902,16 @@ stores.inject(MyMetaStore, storeInstance);
71836
71902
  this.fastForward();
71837
71903
  this.insert(redoId, this.buildEmpty(redoId), insertAfter);
71838
71904
  }
71839
- drop(operationId) {
71905
+ rebase(operationId) {
71906
+ const operation = this.get(operationId);
71907
+ const execution = [...this.tree.execution(this.HEAD_BRANCH).startAfter(operationId)];
71840
71908
  this.revertBefore(operationId);
71909
+ const baseId = this.HEAD_OPERATION.id;
71841
71910
  this.tree.drop(operationId);
71911
+ this.insert(operationId, operation, baseId);
71912
+ for (const { operation } of execution) {
71913
+ this.insert(operation.id, operation.data, this.HEAD_OPERATION.id);
71914
+ }
71842
71915
  }
71843
71916
  /**
71844
71917
  * Revert the state as it was *before* the given operation was executed.
@@ -74966,6 +75039,11 @@ stores.inject(MyMetaStore, storeInstance);
74966
75039
  dispatch: (command) => {
74967
75040
  const result = this.checkDispatchAllowed(command);
74968
75041
  if (!result.isSuccessful) {
75042
+ // core views plugins need to be invalidated
75043
+ this.dispatchToHandlers(this.coreHandlers, {
75044
+ type: "UNDO",
75045
+ commands: [command],
75046
+ });
74969
75047
  return;
74970
75048
  }
74971
75049
  this.isReplayingCommand = true;
@@ -75532,9 +75610,9 @@ stores.inject(MyMetaStore, storeInstance);
75532
75610
  exports.tokenize = tokenize;
75533
75611
 
75534
75612
 
75535
- __info__.version = "18.2.0-alpha.8";
75536
- __info__.date = "2025-02-14T08:40:13.286Z";
75537
- __info__.hash = "19d45d9";
75613
+ __info__.version = "18.3.0-alpha.0";
75614
+ __info__.date = "2025-02-18T09:02:28.625Z";
75615
+ __info__.hash = "9b88da0";
75538
75616
 
75539
75617
 
75540
75618
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);