@odoo/o-spreadsheet 18.0.22 → 18.0.23

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.0.22
6
- * @date 2025-04-04T08:42:35.352Z
7
- * @hash 89a3279
5
+ * @version 18.0.23
6
+ * @date 2025-04-14T17:16:35.374Z
7
+ * @hash f560133
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';
@@ -3395,6 +3395,7 @@ const coreTypes = new Set([
3395
3395
  "CLEAR_FORMATTING",
3396
3396
  "SET_BORDER",
3397
3397
  "SET_ZONE_BORDERS",
3398
+ "SET_BORDERS_ON_TARGET",
3398
3399
  /** CHART */
3399
3400
  "CREATE_CHART",
3400
3401
  "UPDATE_CHART",
@@ -6558,6 +6559,7 @@ class AbstractCellClipboardHandler extends ClipboardHandler {
6558
6559
  }
6559
6560
 
6560
6561
  class BorderClipboardHandler extends AbstractCellClipboardHandler {
6562
+ queuedBordersToAdd = {};
6561
6563
  copy(data) {
6562
6564
  const sheetId = data.sheetId;
6563
6565
  if (data.zones.length === 0) {
@@ -6588,6 +6590,7 @@ class BorderClipboardHandler extends AbstractCellClipboardHandler {
6588
6590
  const { left, top } = zones[0];
6589
6591
  this.pasteZone(sheetId, left, top, content.borders);
6590
6592
  }
6593
+ this.executeQueuedChanges(sheetId);
6591
6594
  }
6592
6595
  pasteZone(sheetId, col, row, borders) {
6593
6596
  for (const [r, rowBorders] of borders.entries()) {
@@ -6606,7 +6609,20 @@ class BorderClipboardHandler extends AbstractCellClipboardHandler {
6606
6609
  ...targetBorders,
6607
6610
  ...originBorders,
6608
6611
  };
6609
- this.dispatch("SET_BORDER", { ...target, border });
6612
+ const borderKey = JSON.stringify(border);
6613
+ if (!this.queuedBordersToAdd[borderKey]) {
6614
+ this.queuedBordersToAdd[borderKey] = [];
6615
+ }
6616
+ this.queuedBordersToAdd[borderKey].push(positionToZone(target));
6617
+ }
6618
+ executeQueuedChanges(pasteSheetTarget) {
6619
+ for (const borderKey in this.queuedBordersToAdd) {
6620
+ const zones = this.queuedBordersToAdd[borderKey];
6621
+ const border = JSON.parse(borderKey);
6622
+ const target = recomputeZones(zones, []);
6623
+ this.dispatch("SET_BORDERS_ON_TARGET", { sheetId: pasteSheetTarget, target, border });
6624
+ }
6625
+ this.queuedBordersToAdd = {};
6610
6626
  }
6611
6627
  }
6612
6628
 
@@ -8498,12 +8514,13 @@ class ConditionalFormatClipboardHandler extends AbstractCellClipboardHandler {
8498
8514
  }
8499
8515
  pasteCf(origin, target, isCutOperation) {
8500
8516
  if (origin?.rules && origin.rules.length > 0) {
8517
+ const originZone = positionToZone(origin.position);
8501
8518
  const zone = positionToZone(target);
8502
8519
  for (const rule of origin.rules) {
8503
8520
  const toRemoveZones = [];
8504
8521
  if (isCutOperation) {
8505
8522
  //remove from current rule
8506
- toRemoveZones.push(positionToZone(origin.position));
8523
+ toRemoveZones.push(originZone);
8507
8524
  }
8508
8525
  if (origin.position.sheetId === target.sheetId) {
8509
8526
  this.adaptCFRules(origin.position.sheetId, rule, [zone], toRemoveZones);
@@ -8617,6 +8634,7 @@ class DataValidationClipboardHandler extends AbstractCellClipboardHandler {
8617
8634
  pasteDataValidation(origin, target, isCutOperation) {
8618
8635
  if (origin) {
8619
8636
  const zone = positionToZone(target);
8637
+ const originZone = positionToZone(origin.position);
8620
8638
  const rule = origin.rule;
8621
8639
  if (!rule) {
8622
8640
  const targetRule = this.getters.getValidationRuleForCell(target);
@@ -8628,7 +8646,7 @@ class DataValidationClipboardHandler extends AbstractCellClipboardHandler {
8628
8646
  }
8629
8647
  const toRemoveZone = [];
8630
8648
  if (isCutOperation) {
8631
- toRemoveZone.push(positionToZone(origin.position));
8649
+ toRemoveZone.push(originZone);
8632
8650
  }
8633
8651
  if (origin.position.sheetId === target.sheetId) {
8634
8652
  const copyToRule = this.getDataValidationRuleToCopyTo(target.sheetId, rule, false);
@@ -8688,7 +8706,7 @@ class DataValidationClipboardHandler extends AbstractCellClipboardHandler {
8688
8706
  continue;
8689
8707
  }
8690
8708
  this.dispatch("ADD_DATA_VALIDATION_RULE", {
8691
- rule: dv,
8709
+ rule: { id: dv.id, criterion: dv.criterion, isBlocking: dv.isBlocking },
8692
8710
  ranges: newDvZones.map((zone) => this.getters.getRangeDataFromZone(sheetId, zone)),
8693
8711
  sheetId,
8694
8712
  });
@@ -50789,6 +50807,15 @@ class BordersPlugin extends CorePlugin {
50789
50807
  case "SET_BORDER":
50790
50808
  this.setBorder(cmd.sheetId, cmd.col, cmd.row, cmd.border);
50791
50809
  break;
50810
+ case "SET_BORDERS_ON_TARGET":
50811
+ for (const zone of cmd.target) {
50812
+ for (let row = zone.top; row <= zone.bottom; row++) {
50813
+ for (let col = zone.left; col <= zone.right; col++) {
50814
+ this.setBorder(cmd.sheetId, col, row, cmd.border);
50815
+ }
50816
+ }
50817
+ }
50818
+ break;
50792
50819
  case "SET_ZONE_BORDERS":
50793
50820
  if (cmd.border) {
50794
50821
  const target = cmd.target.map((zone) => this.getters.expandZone(cmd.sheetId, zone));
@@ -60607,25 +60634,6 @@ class AutofillPlugin extends UIPlugin {
60607
60634
  case "AUTOFILL_AUTO":
60608
60635
  this.autofillAuto();
60609
60636
  break;
60610
- case "AUTOFILL_CELL":
60611
- this.autoFillMerge(cmd.originCol, cmd.originRow, cmd.col, cmd.row);
60612
- const sheetId = this.getters.getActiveSheetId();
60613
- this.dispatch("UPDATE_CELL", {
60614
- sheetId,
60615
- col: cmd.col,
60616
- row: cmd.row,
60617
- style: cmd.style || null,
60618
- content: cmd.content || "",
60619
- format: cmd.format || "",
60620
- });
60621
- this.dispatch("SET_BORDER", {
60622
- sheetId,
60623
- col: cmd.col,
60624
- row: cmd.row,
60625
- border: cmd.border,
60626
- });
60627
- this.autofillCF(cmd.originCol, cmd.originRow, cmd.col, cmd.row);
60628
- this.autofillDV(cmd.originCol, cmd.originRow, cmd.col, cmd.row);
60629
60637
  }
60630
60638
  }
60631
60639
  // ---------------------------------------------------------------------------
@@ -60649,6 +60657,7 @@ class AutofillPlugin extends UIPlugin {
60649
60657
  }
60650
60658
  const source = this.getters.getSelectedZone();
60651
60659
  const target = this.autofillZone;
60660
+ const autofillCellsData = [];
60652
60661
  switch (this.direction) {
60653
60662
  case "down" /* DIRECTION.DOWN */:
60654
60663
  for (let col = source.left; col <= source.right; col++) {
@@ -60658,7 +60667,7 @@ class AutofillPlugin extends UIPlugin {
60658
60667
  }
60659
60668
  const generator = this.createGenerator(xcs);
60660
60669
  for (let row = target.top; row <= target.bottom; row++) {
60661
- this.computeNewCell(generator, col, row, apply);
60670
+ autofillCellsData.push(this.computeNewCell(generator, col, row));
60662
60671
  }
60663
60672
  }
60664
60673
  break;
@@ -60670,7 +60679,7 @@ class AutofillPlugin extends UIPlugin {
60670
60679
  }
60671
60680
  const generator = this.createGenerator(xcs);
60672
60681
  for (let row = target.bottom; row >= target.top; row--) {
60673
- this.computeNewCell(generator, col, row, apply);
60682
+ autofillCellsData.push(this.computeNewCell(generator, col, row));
60674
60683
  }
60675
60684
  }
60676
60685
  break;
@@ -60682,7 +60691,7 @@ class AutofillPlugin extends UIPlugin {
60682
60691
  }
60683
60692
  const generator = this.createGenerator(xcs);
60684
60693
  for (let col = target.right; col >= target.left; col--) {
60685
- this.computeNewCell(generator, col, row, apply);
60694
+ autofillCellsData.push(this.computeNewCell(generator, col, row));
60686
60695
  }
60687
60696
  }
60688
60697
  break;
@@ -60694,12 +60703,26 @@ class AutofillPlugin extends UIPlugin {
60694
60703
  }
60695
60704
  const generator = this.createGenerator(xcs);
60696
60705
  for (let col = target.left; col <= target.right; col++) {
60697
- this.computeNewCell(generator, col, row, apply);
60706
+ autofillCellsData.push(this.computeNewCell(generator, col, row));
60698
60707
  }
60699
60708
  }
60700
60709
  break;
60701
60710
  }
60702
60711
  if (apply) {
60712
+ const bordersZones = {};
60713
+ const cfNewRanges = {};
60714
+ const dvNewZones = {};
60715
+ const sheetId = this.getters.getActiveSheetId();
60716
+ for (const data of autofillCellsData) {
60717
+ this.collectBordersData(data, bordersZones);
60718
+ this.autofillMerge(sheetId, data);
60719
+ this.autofillCell(sheetId, data);
60720
+ this.collectConditionalFormatsData(sheetId, data, cfNewRanges);
60721
+ this.collectDataValidationsData(sheetId, data, dvNewZones);
60722
+ }
60723
+ this.autofillBorders(sheetId, bordersZones);
60724
+ this.autofillConditionalFormats(sheetId, cfNewRanges);
60725
+ this.autofillDataValidations(sheetId, dvNewZones);
60703
60726
  this.autofillZone = undefined;
60704
60727
  this.selection.resizeAnchorZone(this.direction, this.steps);
60705
60728
  this.lastCellSelected = {};
@@ -60708,6 +60731,95 @@ class AutofillPlugin extends UIPlugin {
60708
60731
  this.tooltip = undefined;
60709
60732
  }
60710
60733
  }
60734
+ collectBordersData(data, bordersPositions) {
60735
+ const key = JSON.stringify(data.border);
60736
+ if (!(key in bordersPositions)) {
60737
+ bordersPositions[key] = [];
60738
+ }
60739
+ bordersPositions[key].push(positionToZone({ col: data.col, row: data.row }));
60740
+ }
60741
+ collectConditionalFormatsData(sheetId, data, cfNewRanges) {
60742
+ const { originCol, originRow, col, row } = data;
60743
+ const cfsAtOrigin = this.getters.getRulesByCell(sheetId, originCol, originRow);
60744
+ const xc = toXC(col, row);
60745
+ for (const cf of cfsAtOrigin) {
60746
+ if (!(cf.id in cfNewRanges)) {
60747
+ cfNewRanges[cf.id] = [];
60748
+ }
60749
+ cfNewRanges[cf.id].push(xc);
60750
+ }
60751
+ }
60752
+ collectDataValidationsData(sheetId, data, dvNewZones) {
60753
+ const { originCol, originRow, col, row } = data;
60754
+ const cellPosition = { sheetId, col: originCol, row: originRow };
60755
+ const dvsAtOrigin = this.getters.getValidationRuleForCell(cellPosition);
60756
+ if (!dvsAtOrigin) {
60757
+ return;
60758
+ }
60759
+ if (!(dvsAtOrigin.id in dvNewZones)) {
60760
+ dvNewZones[dvsAtOrigin.id] = [];
60761
+ }
60762
+ dvNewZones[dvsAtOrigin.id].push(positionToZone({ col, row }));
60763
+ }
60764
+ autofillCell(sheetId, data) {
60765
+ this.dispatch("UPDATE_CELL", {
60766
+ sheetId,
60767
+ col: data.col,
60768
+ row: data.row,
60769
+ content: data.content || "",
60770
+ style: data.style || null,
60771
+ format: data.format || "",
60772
+ });
60773
+ // Still usefull in odoo ATM to autofill field sync
60774
+ this.dispatch("AUTOFILL_CELL", data);
60775
+ }
60776
+ autofillBorders(sheetId, bordersPositions) {
60777
+ for (const stringifiedBorder in bordersPositions) {
60778
+ const border = stringifiedBorder === "undefined" ? undefined : JSON.parse(stringifiedBorder);
60779
+ this.dispatch("SET_BORDERS_ON_TARGET", {
60780
+ sheetId,
60781
+ border,
60782
+ target: recomputeZones(bordersPositions[stringifiedBorder]),
60783
+ });
60784
+ }
60785
+ }
60786
+ autofillConditionalFormats(sheetId, cfNewRanges) {
60787
+ for (const cfId in cfNewRanges) {
60788
+ const changes = cfNewRanges[cfId];
60789
+ const cf = this.getters.getConditionalFormats(sheetId).find((cf) => cf.id === cfId);
60790
+ if (!cf) {
60791
+ continue;
60792
+ }
60793
+ const newCfRanges = this.getters.getAdaptedCfRanges(sheetId, cf, changes.map(toZone), []);
60794
+ if (newCfRanges) {
60795
+ this.dispatch("ADD_CONDITIONAL_FORMAT", {
60796
+ cf: {
60797
+ id: cf.id,
60798
+ rule: cf.rule,
60799
+ stopIfTrue: cf.stopIfTrue,
60800
+ },
60801
+ ranges: newCfRanges,
60802
+ sheetId,
60803
+ });
60804
+ }
60805
+ }
60806
+ }
60807
+ autofillDataValidations(sheetId, dvNewZones) {
60808
+ for (const dvId in dvNewZones) {
60809
+ const changes = dvNewZones[dvId];
60810
+ const dvOrigin = this.getters.getDataValidationRule(sheetId, dvId);
60811
+ if (!dvOrigin) {
60812
+ continue;
60813
+ }
60814
+ const dvRangesXcs = dvOrigin.ranges.map((range) => range.zone);
60815
+ const newDvRanges = recomputeZones(dvRangesXcs.concat(changes), []);
60816
+ this.dispatch("ADD_DATA_VALIDATION_RULE", {
60817
+ rule: dvOrigin,
60818
+ ranges: newDvRanges.map((zone) => this.getters.getRangeDataFromZone(sheetId, zone)),
60819
+ sheetId,
60820
+ });
60821
+ }
60822
+ }
60711
60823
  /**
60712
60824
  * Select a cell which becomes the last cell of the autofillZone
60713
60825
  */
@@ -60786,22 +60898,20 @@ class AutofillPlugin extends UIPlugin {
60786
60898
  /**
60787
60899
  * Generate the next cell
60788
60900
  */
60789
- computeNewCell(generator, col, row, apply) {
60901
+ computeNewCell(generator, col, row) {
60790
60902
  const { cellData, tooltip, origin } = generator.next();
60791
60903
  const { content, style, border, format } = cellData;
60792
60904
  this.tooltip = tooltip;
60793
- if (apply) {
60794
- this.dispatch("AUTOFILL_CELL", {
60795
- originCol: origin.col,
60796
- originRow: origin.row,
60797
- col,
60798
- row,
60799
- content,
60800
- style,
60801
- border,
60802
- format,
60803
- });
60804
- }
60905
+ return {
60906
+ originCol: origin.col,
60907
+ originRow: origin.row,
60908
+ col,
60909
+ row,
60910
+ content,
60911
+ style,
60912
+ border,
60913
+ format,
60914
+ };
60805
60915
  }
60806
60916
  /**
60807
60917
  * Get the rule associated to the current cell
@@ -60869,8 +60979,8 @@ class AutofillPlugin extends UIPlugin {
60869
60979
  ? position[first].value
60870
60980
  : position[second].value;
60871
60981
  }
60872
- autoFillMerge(originCol, originRow, col, row) {
60873
- const sheetId = this.getters.getActiveSheetId();
60982
+ autofillMerge(sheetId, data) {
60983
+ const { originCol, originRow, col, row } = data;
60874
60984
  const position = { sheetId, col, row };
60875
60985
  const originPosition = { sheetId, col: originCol, row: originRow };
60876
60986
  if (this.getters.isInMerge(position) && !this.getters.isInMerge(originPosition)) {
@@ -60897,35 +61007,6 @@ class AutofillPlugin extends UIPlugin {
60897
61007
  });
60898
61008
  }
60899
61009
  }
60900
- autofillCF(originCol, originRow, col, row) {
60901
- const sheetId = this.getters.getActiveSheetId();
60902
- const cfOrigin = this.getters.getRulesByCell(sheetId, originCol, originRow);
60903
- for (const cf of cfOrigin) {
60904
- const newCfRanges = this.getters.getAdaptedCfRanges(sheetId, cf, [positionToZone({ col, row })], []);
60905
- if (newCfRanges) {
60906
- this.dispatch("ADD_CONDITIONAL_FORMAT", {
60907
- cf: deepCopy(cf),
60908
- ranges: newCfRanges,
60909
- sheetId,
60910
- });
60911
- }
60912
- }
60913
- }
60914
- autofillDV(originCol, originRow, col, row) {
60915
- const sheetId = this.getters.getActiveSheetId();
60916
- const cellPosition = { sheetId, col: originCol, row: originRow };
60917
- const dvOrigin = this.getters.getValidationRuleForCell(cellPosition);
60918
- if (!dvOrigin) {
60919
- return;
60920
- }
60921
- const dvRangesZones = dvOrigin.ranges.map((range) => range.zone);
60922
- const newDvRanges = recomputeZones(dvRangesZones.concat(positionToZone({ col, row })), []);
60923
- this.dispatch("ADD_DATA_VALIDATION_RULE", {
60924
- rule: dvOrigin,
60925
- ranges: newDvRanges.map((zone) => this.getters.getRangeDataFromZone(sheetId, zone)),
60926
- sheetId,
60927
- });
60928
- }
60929
61010
  // ---------------------------------------------------------------------------
60930
61011
  // Grid rendering
60931
61012
  // ---------------------------------------------------------------------------
@@ -73588,6 +73669,6 @@ const constants = {
73588
73669
  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 };
73589
73670
 
73590
73671
 
73591
- __info__.version = "18.0.22";
73592
- __info__.date = "2025-04-04T08:42:35.352Z";
73593
- __info__.hash = "89a3279";
73672
+ __info__.version = "18.0.23";
73673
+ __info__.date = "2025-04-14T17:16:35.374Z";
73674
+ __info__.hash = "f560133";