@odoo/o-spreadsheet 18.1.14 → 18.1.15

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.1.14
6
- * @date 2025-04-04T08:42:40.149Z
7
- * @hash 63b2fb7
5
+ * @version 18.1.15
6
+ * @date 2025-04-14T17:17:30.890Z
7
+ * @hash ddaea83
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';
@@ -3562,6 +3562,7 @@ const coreTypes = new Set([
3562
3562
  "CLEAR_FORMATTING",
3563
3563
  "SET_BORDER",
3564
3564
  "SET_ZONE_BORDERS",
3565
+ "SET_BORDERS_ON_TARGET",
3565
3566
  /** CHART */
3566
3567
  "CREATE_CHART",
3567
3568
  "UPDATE_CHART",
@@ -6713,6 +6714,7 @@ class AbstractCellClipboardHandler extends ClipboardHandler {
6713
6714
  }
6714
6715
 
6715
6716
  class BorderClipboardHandler extends AbstractCellClipboardHandler {
6717
+ queuedBordersToAdd = {};
6716
6718
  copy(data) {
6717
6719
  const sheetId = data.sheetId;
6718
6720
  if (data.zones.length === 0) {
@@ -6743,6 +6745,7 @@ class BorderClipboardHandler extends AbstractCellClipboardHandler {
6743
6745
  const { left, top } = zones[0];
6744
6746
  this.pasteZone(sheetId, left, top, content.borders);
6745
6747
  }
6748
+ this.executeQueuedChanges(sheetId);
6746
6749
  }
6747
6750
  pasteZone(sheetId, col, row, borders) {
6748
6751
  for (const [r, rowBorders] of borders.entries()) {
@@ -6761,7 +6764,20 @@ class BorderClipboardHandler extends AbstractCellClipboardHandler {
6761
6764
  ...targetBorders,
6762
6765
  ...originBorders,
6763
6766
  };
6764
- this.dispatch("SET_BORDER", { ...target, border });
6767
+ const borderKey = JSON.stringify(border);
6768
+ if (!this.queuedBordersToAdd[borderKey]) {
6769
+ this.queuedBordersToAdd[borderKey] = [];
6770
+ }
6771
+ this.queuedBordersToAdd[borderKey].push(positionToZone(target));
6772
+ }
6773
+ executeQueuedChanges(pasteSheetTarget) {
6774
+ for (const borderKey in this.queuedBordersToAdd) {
6775
+ const zones = this.queuedBordersToAdd[borderKey];
6776
+ const border = JSON.parse(borderKey);
6777
+ const target = recomputeZones(zones, []);
6778
+ this.dispatch("SET_BORDERS_ON_TARGET", { sheetId: pasteSheetTarget, target, border });
6779
+ }
6780
+ this.queuedBordersToAdd = {};
6765
6781
  }
6766
6782
  }
6767
6783
 
@@ -8700,12 +8716,13 @@ class ConditionalFormatClipboardHandler extends AbstractCellClipboardHandler {
8700
8716
  }
8701
8717
  pasteCf(origin, target, isCutOperation) {
8702
8718
  if (origin?.rules && origin.rules.length > 0) {
8719
+ const originZone = positionToZone(origin.position);
8703
8720
  const zone = positionToZone(target);
8704
8721
  for (const rule of origin.rules) {
8705
8722
  const toRemoveZones = [];
8706
8723
  if (isCutOperation) {
8707
8724
  //remove from current rule
8708
- toRemoveZones.push(positionToZone(origin.position));
8725
+ toRemoveZones.push(originZone);
8709
8726
  }
8710
8727
  if (origin.position.sheetId === target.sheetId) {
8711
8728
  this.adaptCFRules(origin.position.sheetId, rule, [zone], toRemoveZones);
@@ -8819,6 +8836,7 @@ class DataValidationClipboardHandler extends AbstractCellClipboardHandler {
8819
8836
  pasteDataValidation(origin, target, isCutOperation) {
8820
8837
  if (origin) {
8821
8838
  const zone = positionToZone(target);
8839
+ const originZone = positionToZone(origin.position);
8822
8840
  const rule = origin.rule;
8823
8841
  if (!rule) {
8824
8842
  const targetRule = this.getters.getValidationRuleForCell(target);
@@ -8830,7 +8848,7 @@ class DataValidationClipboardHandler extends AbstractCellClipboardHandler {
8830
8848
  }
8831
8849
  const toRemoveZone = [];
8832
8850
  if (isCutOperation) {
8833
- toRemoveZone.push(positionToZone(origin.position));
8851
+ toRemoveZone.push(originZone);
8834
8852
  }
8835
8853
  if (origin.position.sheetId === target.sheetId) {
8836
8854
  const copyToRule = this.getDataValidationRuleToCopyTo(target.sheetId, rule, false);
@@ -8890,7 +8908,7 @@ class DataValidationClipboardHandler extends AbstractCellClipboardHandler {
8890
8908
  continue;
8891
8909
  }
8892
8910
  this.dispatch("ADD_DATA_VALIDATION_RULE", {
8893
- rule: dv,
8911
+ rule: { id: dv.id, criterion: dv.criterion, isBlocking: dv.isBlocking },
8894
8912
  ranges: newDvZones.map((zone) => this.getters.getRangeDataFromZone(sheetId, zone)),
8895
8913
  sheetId,
8896
8914
  });
@@ -52870,6 +52888,15 @@ class BordersPlugin extends CorePlugin {
52870
52888
  case "SET_BORDER":
52871
52889
  this.setBorder(cmd.sheetId, cmd.col, cmd.row, cmd.border);
52872
52890
  break;
52891
+ case "SET_BORDERS_ON_TARGET":
52892
+ for (const zone of cmd.target) {
52893
+ for (let row = zone.top; row <= zone.bottom; row++) {
52894
+ for (let col = zone.left; col <= zone.right; col++) {
52895
+ this.setBorder(cmd.sheetId, col, row, cmd.border);
52896
+ }
52897
+ }
52898
+ }
52899
+ break;
52873
52900
  case "SET_ZONE_BORDERS":
52874
52901
  if (cmd.border) {
52875
52902
  const target = cmd.target.map((zone) => this.getters.expandZone(cmd.sheetId, zone));
@@ -62596,25 +62623,6 @@ class AutofillPlugin extends UIPlugin {
62596
62623
  case "AUTOFILL_AUTO":
62597
62624
  this.autofillAuto();
62598
62625
  break;
62599
- case "AUTOFILL_CELL":
62600
- this.autoFillMerge(cmd.originCol, cmd.originRow, cmd.col, cmd.row);
62601
- const sheetId = this.getters.getActiveSheetId();
62602
- this.dispatch("UPDATE_CELL", {
62603
- sheetId,
62604
- col: cmd.col,
62605
- row: cmd.row,
62606
- style: cmd.style || null,
62607
- content: cmd.content || "",
62608
- format: cmd.format || "",
62609
- });
62610
- this.dispatch("SET_BORDER", {
62611
- sheetId,
62612
- col: cmd.col,
62613
- row: cmd.row,
62614
- border: cmd.border,
62615
- });
62616
- this.autofillCF(cmd.originCol, cmd.originRow, cmd.col, cmd.row);
62617
- this.autofillDV(cmd.originCol, cmd.originRow, cmd.col, cmd.row);
62618
62626
  }
62619
62627
  }
62620
62628
  // ---------------------------------------------------------------------------
@@ -62638,6 +62646,7 @@ class AutofillPlugin extends UIPlugin {
62638
62646
  }
62639
62647
  const source = this.getters.getSelectedZone();
62640
62648
  const target = this.autofillZone;
62649
+ const autofillCellsData = [];
62641
62650
  switch (this.direction) {
62642
62651
  case "down" /* DIRECTION.DOWN */:
62643
62652
  for (let col = source.left; col <= source.right; col++) {
@@ -62647,7 +62656,7 @@ class AutofillPlugin extends UIPlugin {
62647
62656
  }
62648
62657
  const generator = this.createGenerator(xcs);
62649
62658
  for (let row = target.top; row <= target.bottom; row++) {
62650
- this.computeNewCell(generator, col, row, apply);
62659
+ autofillCellsData.push(this.computeNewCell(generator, col, row));
62651
62660
  }
62652
62661
  }
62653
62662
  break;
@@ -62659,7 +62668,7 @@ class AutofillPlugin extends UIPlugin {
62659
62668
  }
62660
62669
  const generator = this.createGenerator(xcs);
62661
62670
  for (let row = target.bottom; row >= target.top; row--) {
62662
- this.computeNewCell(generator, col, row, apply);
62671
+ autofillCellsData.push(this.computeNewCell(generator, col, row));
62663
62672
  }
62664
62673
  }
62665
62674
  break;
@@ -62671,7 +62680,7 @@ class AutofillPlugin extends UIPlugin {
62671
62680
  }
62672
62681
  const generator = this.createGenerator(xcs);
62673
62682
  for (let col = target.right; col >= target.left; col--) {
62674
- this.computeNewCell(generator, col, row, apply);
62683
+ autofillCellsData.push(this.computeNewCell(generator, col, row));
62675
62684
  }
62676
62685
  }
62677
62686
  break;
@@ -62683,12 +62692,26 @@ class AutofillPlugin extends UIPlugin {
62683
62692
  }
62684
62693
  const generator = this.createGenerator(xcs);
62685
62694
  for (let col = target.left; col <= target.right; col++) {
62686
- this.computeNewCell(generator, col, row, apply);
62695
+ autofillCellsData.push(this.computeNewCell(generator, col, row));
62687
62696
  }
62688
62697
  }
62689
62698
  break;
62690
62699
  }
62691
62700
  if (apply) {
62701
+ const bordersZones = {};
62702
+ const cfNewRanges = {};
62703
+ const dvNewZones = {};
62704
+ const sheetId = this.getters.getActiveSheetId();
62705
+ for (const data of autofillCellsData) {
62706
+ this.collectBordersData(data, bordersZones);
62707
+ this.autofillMerge(sheetId, data);
62708
+ this.autofillCell(sheetId, data);
62709
+ this.collectConditionalFormatsData(sheetId, data, cfNewRanges);
62710
+ this.collectDataValidationsData(sheetId, data, dvNewZones);
62711
+ }
62712
+ this.autofillBorders(sheetId, bordersZones);
62713
+ this.autofillConditionalFormats(sheetId, cfNewRanges);
62714
+ this.autofillDataValidations(sheetId, dvNewZones);
62692
62715
  this.autofillZone = undefined;
62693
62716
  this.selection.resizeAnchorZone(this.direction, this.steps);
62694
62717
  this.lastCellSelected = {};
@@ -62697,6 +62720,95 @@ class AutofillPlugin extends UIPlugin {
62697
62720
  this.tooltip = undefined;
62698
62721
  }
62699
62722
  }
62723
+ collectBordersData(data, bordersPositions) {
62724
+ const key = JSON.stringify(data.border);
62725
+ if (!(key in bordersPositions)) {
62726
+ bordersPositions[key] = [];
62727
+ }
62728
+ bordersPositions[key].push(positionToZone({ col: data.col, row: data.row }));
62729
+ }
62730
+ collectConditionalFormatsData(sheetId, data, cfNewRanges) {
62731
+ const { originCol, originRow, col, row } = data;
62732
+ const cfsAtOrigin = this.getters.getRulesByCell(sheetId, originCol, originRow);
62733
+ const xc = toXC(col, row);
62734
+ for (const cf of cfsAtOrigin) {
62735
+ if (!(cf.id in cfNewRanges)) {
62736
+ cfNewRanges[cf.id] = [];
62737
+ }
62738
+ cfNewRanges[cf.id].push(xc);
62739
+ }
62740
+ }
62741
+ collectDataValidationsData(sheetId, data, dvNewZones) {
62742
+ const { originCol, originRow, col, row } = data;
62743
+ const cellPosition = { sheetId, col: originCol, row: originRow };
62744
+ const dvsAtOrigin = this.getters.getValidationRuleForCell(cellPosition);
62745
+ if (!dvsAtOrigin) {
62746
+ return;
62747
+ }
62748
+ if (!(dvsAtOrigin.id in dvNewZones)) {
62749
+ dvNewZones[dvsAtOrigin.id] = [];
62750
+ }
62751
+ dvNewZones[dvsAtOrigin.id].push(positionToZone({ col, row }));
62752
+ }
62753
+ autofillCell(sheetId, data) {
62754
+ this.dispatch("UPDATE_CELL", {
62755
+ sheetId,
62756
+ col: data.col,
62757
+ row: data.row,
62758
+ content: data.content || "",
62759
+ style: data.style || null,
62760
+ format: data.format || "",
62761
+ });
62762
+ // Still usefull in odoo ATM to autofill field sync
62763
+ this.dispatch("AUTOFILL_CELL", data);
62764
+ }
62765
+ autofillBorders(sheetId, bordersPositions) {
62766
+ for (const stringifiedBorder in bordersPositions) {
62767
+ const border = stringifiedBorder === "undefined" ? undefined : JSON.parse(stringifiedBorder);
62768
+ this.dispatch("SET_BORDERS_ON_TARGET", {
62769
+ sheetId,
62770
+ border,
62771
+ target: recomputeZones(bordersPositions[stringifiedBorder]),
62772
+ });
62773
+ }
62774
+ }
62775
+ autofillConditionalFormats(sheetId, cfNewRanges) {
62776
+ for (const cfId in cfNewRanges) {
62777
+ const changes = cfNewRanges[cfId];
62778
+ const cf = this.getters.getConditionalFormats(sheetId).find((cf) => cf.id === cfId);
62779
+ if (!cf) {
62780
+ continue;
62781
+ }
62782
+ const newCfRanges = this.getters.getAdaptedCfRanges(sheetId, cf, changes.map(toZone), []);
62783
+ if (newCfRanges) {
62784
+ this.dispatch("ADD_CONDITIONAL_FORMAT", {
62785
+ cf: {
62786
+ id: cf.id,
62787
+ rule: cf.rule,
62788
+ stopIfTrue: cf.stopIfTrue,
62789
+ },
62790
+ ranges: newCfRanges,
62791
+ sheetId,
62792
+ });
62793
+ }
62794
+ }
62795
+ }
62796
+ autofillDataValidations(sheetId, dvNewZones) {
62797
+ for (const dvId in dvNewZones) {
62798
+ const changes = dvNewZones[dvId];
62799
+ const dvOrigin = this.getters.getDataValidationRule(sheetId, dvId);
62800
+ if (!dvOrigin) {
62801
+ continue;
62802
+ }
62803
+ const dvRangesXcs = dvOrigin.ranges.map((range) => range.zone);
62804
+ const newDvRanges = recomputeZones(dvRangesXcs.concat(changes), []);
62805
+ this.dispatch("ADD_DATA_VALIDATION_RULE", {
62806
+ rule: dvOrigin,
62807
+ ranges: newDvRanges.map((zone) => this.getters.getRangeDataFromZone(sheetId, zone)),
62808
+ sheetId,
62809
+ });
62810
+ }
62811
+ }
62700
62812
  /**
62701
62813
  * Select a cell which becomes the last cell of the autofillZone
62702
62814
  */
@@ -62775,22 +62887,20 @@ class AutofillPlugin extends UIPlugin {
62775
62887
  /**
62776
62888
  * Generate the next cell
62777
62889
  */
62778
- computeNewCell(generator, col, row, apply) {
62890
+ computeNewCell(generator, col, row) {
62779
62891
  const { cellData, tooltip, origin } = generator.next();
62780
62892
  const { content, style, border, format } = cellData;
62781
62893
  this.tooltip = tooltip;
62782
- if (apply) {
62783
- this.dispatch("AUTOFILL_CELL", {
62784
- originCol: origin.col,
62785
- originRow: origin.row,
62786
- col,
62787
- row,
62788
- content,
62789
- style,
62790
- border,
62791
- format,
62792
- });
62793
- }
62894
+ return {
62895
+ originCol: origin.col,
62896
+ originRow: origin.row,
62897
+ col,
62898
+ row,
62899
+ content,
62900
+ style,
62901
+ border,
62902
+ format,
62903
+ };
62794
62904
  }
62795
62905
  /**
62796
62906
  * Get the rule associated to the current cell
@@ -62858,8 +62968,8 @@ class AutofillPlugin extends UIPlugin {
62858
62968
  ? position[first].value
62859
62969
  : position[second].value;
62860
62970
  }
62861
- autoFillMerge(originCol, originRow, col, row) {
62862
- const sheetId = this.getters.getActiveSheetId();
62971
+ autofillMerge(sheetId, data) {
62972
+ const { originCol, originRow, col, row } = data;
62863
62973
  const position = { sheetId, col, row };
62864
62974
  const originPosition = { sheetId, col: originCol, row: originRow };
62865
62975
  if (this.getters.isInMerge(position) && !this.getters.isInMerge(originPosition)) {
@@ -62886,35 +62996,6 @@ class AutofillPlugin extends UIPlugin {
62886
62996
  });
62887
62997
  }
62888
62998
  }
62889
- autofillCF(originCol, originRow, col, row) {
62890
- const sheetId = this.getters.getActiveSheetId();
62891
- const cfOrigin = this.getters.getRulesByCell(sheetId, originCol, originRow);
62892
- for (const cf of cfOrigin) {
62893
- const newCfRanges = this.getters.getAdaptedCfRanges(sheetId, cf, [positionToZone({ col, row })], []);
62894
- if (newCfRanges) {
62895
- this.dispatch("ADD_CONDITIONAL_FORMAT", {
62896
- cf: deepCopy(cf),
62897
- ranges: newCfRanges,
62898
- sheetId,
62899
- });
62900
- }
62901
- }
62902
- }
62903
- autofillDV(originCol, originRow, col, row) {
62904
- const sheetId = this.getters.getActiveSheetId();
62905
- const cellPosition = { sheetId, col: originCol, row: originRow };
62906
- const dvOrigin = this.getters.getValidationRuleForCell(cellPosition);
62907
- if (!dvOrigin) {
62908
- return;
62909
- }
62910
- const dvRangesZones = dvOrigin.ranges.map((range) => range.zone);
62911
- const newDvRanges = recomputeZones(dvRangesZones.concat(positionToZone({ col, row })), []);
62912
- this.dispatch("ADD_DATA_VALIDATION_RULE", {
62913
- rule: dvOrigin,
62914
- ranges: newDvRanges.map((zone) => this.getters.getRangeDataFromZone(sheetId, zone)),
62915
- sheetId,
62916
- });
62917
- }
62918
62999
  // ---------------------------------------------------------------------------
62919
63000
  // Grid rendering
62920
63001
  // ---------------------------------------------------------------------------
@@ -75599,6 +75680,6 @@ const chartHelpers = { ...CHART_HELPERS, ...CHART_RUNTIME_HELPERS };
75599
75680
  export { AbstractCellClipboardHandler, AbstractChart, AbstractFigureClipboardHandler, CellErrorType, CommandResult, CorePlugin, DispatchResult, EvaluationError, Model, PivotRuntimeDefinition, Registry, Revision, SPREADSHEET_DIMENSIONS, Spreadsheet, SpreadsheetPivotTable, UIPlugin, __info__, addFunction, addRenderingLayer, astToFormula, chartHelpers, 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 };
75600
75681
 
75601
75682
 
75602
- __info__.version = "18.1.14";
75603
- __info__.date = "2025-04-04T08:42:40.149Z";
75604
- __info__.hash = "63b2fb7";
75683
+ __info__.version = "18.1.15";
75684
+ __info__.date = "2025-04-14T17:17:30.890Z";
75685
+ __info__.hash = "ddaea83";