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