@odoo/o-spreadsheet 17.4.29 → 17.4.31

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.29
6
- * @date 2025-04-04T08:40:34.590Z
7
- * @hash 2937d99
5
+ * @version 17.4.31
6
+ * @date 2025-04-18T16:24:47.716Z
7
+ * @hash 7991032
8
8
  */
9
9
 
10
10
  'use strict';
@@ -2169,6 +2169,7 @@ const coreTypes = new Set([
2169
2169
  "CLEAR_FORMATTING",
2170
2170
  "SET_BORDER",
2171
2171
  "SET_ZONE_BORDERS",
2172
+ "SET_BORDERS_ON_TARGET",
2172
2173
  /** CHART */
2173
2174
  "CREATE_CHART",
2174
2175
  "UPDATE_CHART",
@@ -5652,6 +5653,7 @@ class AbstractCellClipboardHandler extends ClipboardHandler {
5652
5653
  }
5653
5654
 
5654
5655
  class BorderClipboardHandler extends AbstractCellClipboardHandler {
5656
+ queuedBordersToAdd = {};
5655
5657
  copy(data) {
5656
5658
  const sheetId = data.sheetId;
5657
5659
  if (data.zones.length === 0) {
@@ -5682,6 +5684,7 @@ class BorderClipboardHandler extends AbstractCellClipboardHandler {
5682
5684
  const { left, top } = zones[0];
5683
5685
  this.pasteZone(sheetId, left, top, content.borders);
5684
5686
  }
5687
+ this.executeQueuedChanges(sheetId);
5685
5688
  }
5686
5689
  pasteZone(sheetId, col, row, borders) {
5687
5690
  for (const [r, rowBorders] of borders.entries()) {
@@ -5700,7 +5703,20 @@ class BorderClipboardHandler extends AbstractCellClipboardHandler {
5700
5703
  ...targetBorders,
5701
5704
  ...originBorders,
5702
5705
  };
5703
- this.dispatch("SET_BORDER", { ...target, border });
5706
+ const borderKey = JSON.stringify(border);
5707
+ if (!this.queuedBordersToAdd[borderKey]) {
5708
+ this.queuedBordersToAdd[borderKey] = [];
5709
+ }
5710
+ this.queuedBordersToAdd[borderKey].push(positionToZone(target));
5711
+ }
5712
+ executeQueuedChanges(pasteSheetTarget) {
5713
+ for (const borderKey in this.queuedBordersToAdd) {
5714
+ const zones = this.queuedBordersToAdd[borderKey];
5715
+ const border = JSON.parse(borderKey);
5716
+ const target = recomputeZones(zones, []);
5717
+ this.dispatch("SET_BORDERS_ON_TARGET", { sheetId: pasteSheetTarget, target, border });
5718
+ }
5719
+ this.queuedBordersToAdd = {};
5704
5720
  }
5705
5721
  }
5706
5722
 
@@ -5812,6 +5828,12 @@ function tokenizeString(chars) {
5812
5828
  }
5813
5829
  return null;
5814
5830
  }
5831
+ /**
5832
+ - \p{L} is for any letter (from any language)
5833
+ - \p{N} is for any number
5834
+ - the u flag at the end is for unicode, which enables the `\p{...}` syntax
5835
+ */
5836
+ const unicodeSymbolCharRegexp = /\p{L}|\p{N}|_|\.|!|\$/u;
5815
5837
  const SYMBOL_CHARS = new Set("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_.!$");
5816
5838
  /**
5817
5839
  * A "Symbol" is just basically any word-like element that can appear in a
@@ -5852,7 +5874,8 @@ function tokenizeSymbol(chars) {
5852
5874
  };
5853
5875
  }
5854
5876
  }
5855
- while (chars.current && SYMBOL_CHARS.has(chars.current)) {
5877
+ while (chars.current &&
5878
+ (SYMBOL_CHARS.has(chars.current) || chars.current.match(unicodeSymbolCharRegexp))) {
5856
5879
  result += chars.shift();
5857
5880
  }
5858
5881
  if (result.length) {
@@ -6964,6 +6987,7 @@ class ChartClipboardHandler extends AbstractFigureClipboardHandler {
6964
6987
 
6965
6988
  class ConditionalFormatClipboardHandler extends AbstractCellClipboardHandler {
6966
6989
  uuidGenerator = new UuidGenerator();
6990
+ queuedChanges = {};
6967
6991
  copy(data) {
6968
6992
  if (!data.zones.length) {
6969
6993
  return;
@@ -6985,6 +7009,7 @@ class ConditionalFormatClipboardHandler extends AbstractCellClipboardHandler {
6985
7009
  return { cfRules };
6986
7010
  }
6987
7011
  paste(target, clippedContent, options) {
7012
+ this.queuedChanges = {};
6988
7013
  if (options.pasteOption === "asValue") {
6989
7014
  return;
6990
7015
  }
@@ -6996,6 +7021,7 @@ class ConditionalFormatClipboardHandler extends AbstractCellClipboardHandler {
6996
7021
  else {
6997
7022
  this.pasteFromCut(sheetId, zones, clippedContent);
6998
7023
  }
7024
+ this.executeQueuedChanges();
6999
7025
  }
7000
7026
  pasteFromCut(sheetId, target, content) {
7001
7027
  const selection = target[0];
@@ -7013,12 +7039,13 @@ class ConditionalFormatClipboardHandler extends AbstractCellClipboardHandler {
7013
7039
  }
7014
7040
  pasteCf(origin, target, isCutOperation) {
7015
7041
  if (origin?.rules && origin.rules.length > 0) {
7042
+ const originZone = positionToZone(origin.position);
7016
7043
  const zone = positionToZone(target);
7017
7044
  for (const rule of origin.rules) {
7018
7045
  const toRemoveZones = [];
7019
7046
  if (isCutOperation) {
7020
7047
  //remove from current rule
7021
- toRemoveZones.push(positionToZone(origin.position));
7048
+ toRemoveZones.push(originZone);
7022
7049
  }
7023
7050
  if (origin.position.sheetId === target.sheetId) {
7024
7051
  this.adaptCFRules(origin.position.sheetId, rule, [zone], toRemoveZones);
@@ -7035,36 +7062,56 @@ class ConditionalFormatClipboardHandler extends AbstractCellClipboardHandler {
7035
7062
  * Add or remove cells to a given conditional formatting rule.
7036
7063
  */
7037
7064
  adaptCFRules(sheetId, cf, toAdd, toRemove) {
7038
- const newRangesXc = this.getters.getAdaptedCfRanges(sheetId, cf, toAdd, toRemove);
7039
- if (!newRangesXc) {
7040
- return;
7065
+ if (!this.queuedChanges[sheetId]) {
7066
+ this.queuedChanges[sheetId] = [];
7041
7067
  }
7042
- if (newRangesXc.length === 0) {
7043
- this.dispatch("REMOVE_CONDITIONAL_FORMAT", { id: cf.id, sheetId });
7044
- return;
7068
+ const queuedChange = this.queuedChanges[sheetId].find((queued) => queued.cf.id === cf.id);
7069
+ if (!queuedChange) {
7070
+ this.queuedChanges[sheetId].push({ toAdd, toRemove, cf });
7071
+ }
7072
+ else {
7073
+ queuedChange.toAdd.push(...toAdd);
7074
+ queuedChange.toRemove.push(...toRemove);
7075
+ }
7076
+ }
7077
+ executeQueuedChanges() {
7078
+ for (const sheetId in this.queuedChanges) {
7079
+ for (const { toAdd, toRemove, cf } of this.queuedChanges[sheetId]) {
7080
+ const newRangesXc = this.getters.getAdaptedCfRanges(sheetId, cf, toAdd, toRemove);
7081
+ if (!newRangesXc) {
7082
+ continue;
7083
+ }
7084
+ if (newRangesXc.length === 0) {
7085
+ this.dispatch("REMOVE_CONDITIONAL_FORMAT", { id: cf.id, sheetId });
7086
+ continue;
7087
+ }
7088
+ this.dispatch("ADD_CONDITIONAL_FORMAT", {
7089
+ cf: {
7090
+ id: cf.id,
7091
+ rule: cf.rule,
7092
+ stopIfTrue: cf.stopIfTrue,
7093
+ },
7094
+ ranges: newRangesXc,
7095
+ sheetId,
7096
+ });
7097
+ }
7045
7098
  }
7046
- this.dispatch("ADD_CONDITIONAL_FORMAT", {
7047
- cf: {
7048
- id: cf.id,
7049
- rule: cf.rule,
7050
- stopIfTrue: cf.stopIfTrue,
7051
- },
7052
- ranges: newRangesXc,
7053
- sheetId,
7054
- });
7055
7099
  }
7056
7100
  getCFToCopyTo(targetSheetId, originCF) {
7057
- const cfInTarget = this.getters
7101
+ let targetCF = this.getters
7058
7102
  .getConditionalFormats(targetSheetId)
7059
7103
  .find((cf) => cf.stopIfTrue === originCF.stopIfTrue && deepEquals(cf.rule, originCF.rule));
7060
- return cfInTarget
7061
- ? cfInTarget
7062
- : { ...originCF, id: this.uuidGenerator.smallUuid(), ranges: [] };
7104
+ const queuedCfs = this.queuedChanges[targetSheetId];
7105
+ if (!targetCF && queuedCfs) {
7106
+ targetCF = queuedCfs.find((queued) => queued.cf.stopIfTrue === originCF.stopIfTrue && deepEquals(queued.cf.rule, originCF.rule))?.cf;
7107
+ }
7108
+ return targetCF || { ...originCF, id: this.uuidGenerator.uuidv4(), ranges: [] };
7063
7109
  }
7064
7110
  }
7065
7111
 
7066
7112
  class DataValidationClipboardHandler extends AbstractCellClipboardHandler {
7067
7113
  uuidGenerator = new UuidGenerator();
7114
+ queuedChanges = {};
7068
7115
  copy(data) {
7069
7116
  const { rowsIndexes, columnsIndexes } = data;
7070
7117
  const sheetId = data.sheetId;
@@ -7081,6 +7128,7 @@ class DataValidationClipboardHandler extends AbstractCellClipboardHandler {
7081
7128
  return { dvRules };
7082
7129
  }
7083
7130
  paste(target, clippedContent, options) {
7131
+ this.queuedChanges = {};
7084
7132
  if (options.pasteOption) {
7085
7133
  return;
7086
7134
  }
@@ -7092,6 +7140,7 @@ class DataValidationClipboardHandler extends AbstractCellClipboardHandler {
7092
7140
  else {
7093
7141
  this.pasteFromCut(sheetId, zones, clippedContent);
7094
7142
  }
7143
+ this.executeQueuedChanges();
7095
7144
  }
7096
7145
  pasteFromCut(sheetId, target, content) {
7097
7146
  const selection = target[0];
@@ -7110,6 +7159,7 @@ class DataValidationClipboardHandler extends AbstractCellClipboardHandler {
7110
7159
  pasteDataValidation(origin, target, isCutOperation) {
7111
7160
  if (origin) {
7112
7161
  const zone = positionToZone(target);
7162
+ const originZone = positionToZone(origin.position);
7113
7163
  const rule = origin.rule;
7114
7164
  if (!rule) {
7115
7165
  const targetRule = this.getters.getValidationRuleForCell(target);
@@ -7121,7 +7171,7 @@ class DataValidationClipboardHandler extends AbstractCellClipboardHandler {
7121
7171
  }
7122
7172
  const toRemoveZone = [];
7123
7173
  if (isCutOperation) {
7124
- toRemoveZone.push(positionToZone(origin.position));
7174
+ toRemoveZone.push(originZone);
7125
7175
  }
7126
7176
  if (origin.position.sheetId === target.sheetId) {
7127
7177
  const copyToRule = this.getDataValidationRuleToCopyTo(target.sheetId, rule, false);
@@ -7138,29 +7188,55 @@ class DataValidationClipboardHandler extends AbstractCellClipboardHandler {
7138
7188
  }
7139
7189
  }
7140
7190
  getDataValidationRuleToCopyTo(targetSheetId, originRule, newId = true) {
7141
- const ruleInTargetSheet = this.getters
7191
+ let targetRule = this.getters
7142
7192
  .getDataValidationRules(targetSheetId)
7143
7193
  .find((rule) => deepEquals(originRule.criterion, rule.criterion) &&
7144
7194
  originRule.isBlocking === rule.isBlocking);
7145
- return ruleInTargetSheet
7146
- ? ruleInTargetSheet
7147
- : { ...originRule, id: newId ? this.uuidGenerator.smallUuid() : originRule.id, ranges: [] };
7195
+ const queuedRules = this.queuedChanges[targetSheetId];
7196
+ if (!targetRule && queuedRules) {
7197
+ targetRule = queuedRules.find((queued) => deepEquals(originRule.criterion, queued.rule.criterion) &&
7198
+ originRule.isBlocking === queued.rule.isBlocking)?.rule;
7199
+ }
7200
+ return (targetRule || {
7201
+ ...originRule,
7202
+ id: newId ? this.uuidGenerator.uuidv4() : originRule.id,
7203
+ ranges: [],
7204
+ });
7148
7205
  }
7149
7206
  /**
7150
7207
  * Add or remove XCs to a given data validation rule.
7151
7208
  */
7152
7209
  adaptDataValidationRule(sheetId, rule, toAdd, toRemove) {
7153
- const dvZones = rule.ranges.map((range) => range.zone);
7154
- const newDvZones = recomputeZones([...dvZones, ...toAdd], toRemove);
7155
- if (newDvZones.length === 0) {
7156
- this.dispatch("REMOVE_DATA_VALIDATION_RULE", { sheetId, id: rule.id });
7157
- return;
7210
+ if (!this.queuedChanges[sheetId]) {
7211
+ this.queuedChanges[sheetId] = [];
7212
+ }
7213
+ const queuedChange = this.queuedChanges[sheetId].find((queued) => queued.rule.id === rule.id);
7214
+ if (!queuedChange) {
7215
+ this.queuedChanges[sheetId].push({ toAdd, toRemove, rule });
7216
+ }
7217
+ else {
7218
+ queuedChange.toAdd.push(...toAdd);
7219
+ queuedChange.toRemove.push(...toRemove);
7220
+ }
7221
+ }
7222
+ executeQueuedChanges() {
7223
+ for (const sheetId in this.queuedChanges) {
7224
+ for (const { toAdd, toRemove, rule: dv } of this.queuedChanges[sheetId]) {
7225
+ // Remove the zones first in case the same position is in toAdd and toRemove
7226
+ const dvZones = dv.ranges.map((range) => range.zone);
7227
+ const withRemovedZones = recomputeZones(dvZones, toRemove);
7228
+ const newDvZones = recomputeZones([...withRemovedZones, ...toAdd], []);
7229
+ if (newDvZones.length === 0) {
7230
+ this.dispatch("REMOVE_DATA_VALIDATION_RULE", { sheetId, id: dv.id });
7231
+ continue;
7232
+ }
7233
+ this.dispatch("ADD_DATA_VALIDATION_RULE", {
7234
+ rule: { id: dv.id, criterion: dv.criterion, isBlocking: dv.isBlocking },
7235
+ ranges: newDvZones.map((zone) => this.getters.getRangeDataFromZone(sheetId, zone)),
7236
+ sheetId,
7237
+ });
7238
+ }
7158
7239
  }
7159
- this.dispatch("ADD_DATA_VALIDATION_RULE", {
7160
- rule,
7161
- ranges: newDvZones.map((zone) => this.getters.getRangeDataFromZone(sheetId, zone)),
7162
- sheetId,
7163
- });
7164
7240
  }
7165
7241
  }
7166
7242
 
@@ -7486,7 +7562,7 @@ function transformZone(zone, executed) {
7486
7562
  if (executed.type === "ADD_COLUMNS_ROWS") {
7487
7563
  return expandZoneOnInsertion(zone, executed.dimension === "COL" ? "left" : "top", executed.base, executed.position, executed.quantity);
7488
7564
  }
7489
- return { ...zone };
7565
+ return zone;
7490
7566
  }
7491
7567
  function transformRangeData(range, executed) {
7492
7568
  const deletedSheet = executed.type === "DELETE_SHEET" && executed.sheetId;
@@ -47563,6 +47639,15 @@ class BordersPlugin extends CorePlugin {
47563
47639
  case "SET_BORDER":
47564
47640
  this.setBorder(cmd.sheetId, cmd.col, cmd.row, cmd.border);
47565
47641
  break;
47642
+ case "SET_BORDERS_ON_TARGET":
47643
+ for (const zone of cmd.target) {
47644
+ for (let row = zone.top; row <= zone.bottom; row++) {
47645
+ for (let col = zone.left; col <= zone.right; col++) {
47646
+ this.setBorder(cmd.sheetId, col, row, cmd.border);
47647
+ }
47648
+ }
47649
+ }
47650
+ break;
47566
47651
  case "SET_ZONE_BORDERS":
47567
47652
  if (cmd.border) {
47568
47653
  const target = cmd.target.map((zone) => this.getters.expandZone(cmd.sheetId, zone));
@@ -49041,8 +49126,9 @@ class ConditionalFormatPlugin extends CorePlugin {
49041
49126
  if (replaceIndex > -1) {
49042
49127
  currentRanges = rules[replaceIndex].ranges.map(toUnboundedZone);
49043
49128
  }
49044
- currentRanges = currentRanges.concat(toAdd);
49045
- return recomputeZones(currentRanges, toRemove).map((zone) => this.getters.getRangeDataFromZone(sheetId, zone));
49129
+ // Remove the zones first in case the same position is in toAdd and toRemove
49130
+ const withRemovedZones = recomputeZones(currentRanges, toRemove);
49131
+ return recomputeZones([...toAdd, ...withRemovedZones], []).map((zone) => this.getters.getRangeDataFromZone(sheetId, zone));
49046
49132
  }
49047
49133
  // ---------------------------------------------------------------------------
49048
49134
  // Private
@@ -56553,25 +56639,6 @@ class AutofillPlugin extends UIPlugin {
56553
56639
  case "AUTOFILL_AUTO":
56554
56640
  this.autofillAuto();
56555
56641
  break;
56556
- case "AUTOFILL_CELL":
56557
- this.autoFillMerge(cmd.originCol, cmd.originRow, cmd.col, cmd.row);
56558
- const sheetId = this.getters.getActiveSheetId();
56559
- this.dispatch("UPDATE_CELL", {
56560
- sheetId,
56561
- col: cmd.col,
56562
- row: cmd.row,
56563
- style: cmd.style || null,
56564
- content: cmd.content || "",
56565
- format: cmd.format || "",
56566
- });
56567
- this.dispatch("SET_BORDER", {
56568
- sheetId,
56569
- col: cmd.col,
56570
- row: cmd.row,
56571
- border: cmd.border,
56572
- });
56573
- this.autofillCF(cmd.originCol, cmd.originRow, cmd.col, cmd.row);
56574
- this.autofillDV(cmd.originCol, cmd.originRow, cmd.col, cmd.row);
56575
56642
  }
56576
56643
  }
56577
56644
  // ---------------------------------------------------------------------------
@@ -56595,6 +56662,7 @@ class AutofillPlugin extends UIPlugin {
56595
56662
  }
56596
56663
  const source = this.getters.getSelectedZone();
56597
56664
  const target = this.autofillZone;
56665
+ const autofillCellsData = [];
56598
56666
  switch (this.direction) {
56599
56667
  case "down" /* DIRECTION.DOWN */:
56600
56668
  for (let col = source.left; col <= source.right; col++) {
@@ -56604,7 +56672,7 @@ class AutofillPlugin extends UIPlugin {
56604
56672
  }
56605
56673
  const generator = this.createGenerator(xcs);
56606
56674
  for (let row = target.top; row <= target.bottom; row++) {
56607
- this.computeNewCell(generator, col, row, apply);
56675
+ autofillCellsData.push(this.computeNewCell(generator, col, row));
56608
56676
  }
56609
56677
  }
56610
56678
  break;
@@ -56616,7 +56684,7 @@ class AutofillPlugin extends UIPlugin {
56616
56684
  }
56617
56685
  const generator = this.createGenerator(xcs);
56618
56686
  for (let row = target.bottom; row >= target.top; row--) {
56619
- this.computeNewCell(generator, col, row, apply);
56687
+ autofillCellsData.push(this.computeNewCell(generator, col, row));
56620
56688
  }
56621
56689
  }
56622
56690
  break;
@@ -56628,7 +56696,7 @@ class AutofillPlugin extends UIPlugin {
56628
56696
  }
56629
56697
  const generator = this.createGenerator(xcs);
56630
56698
  for (let col = target.right; col >= target.left; col--) {
56631
- this.computeNewCell(generator, col, row, apply);
56699
+ autofillCellsData.push(this.computeNewCell(generator, col, row));
56632
56700
  }
56633
56701
  }
56634
56702
  break;
@@ -56640,12 +56708,26 @@ class AutofillPlugin extends UIPlugin {
56640
56708
  }
56641
56709
  const generator = this.createGenerator(xcs);
56642
56710
  for (let col = target.left; col <= target.right; col++) {
56643
- this.computeNewCell(generator, col, row, apply);
56711
+ autofillCellsData.push(this.computeNewCell(generator, col, row));
56644
56712
  }
56645
56713
  }
56646
56714
  break;
56647
56715
  }
56648
56716
  if (apply) {
56717
+ const bordersZones = {};
56718
+ const cfNewRanges = {};
56719
+ const dvNewZones = {};
56720
+ const sheetId = this.getters.getActiveSheetId();
56721
+ for (const data of autofillCellsData) {
56722
+ this.collectBordersData(data, bordersZones);
56723
+ this.autofillMerge(sheetId, data);
56724
+ this.autofillCell(sheetId, data);
56725
+ this.collectConditionalFormatsData(sheetId, data, cfNewRanges);
56726
+ this.collectDataValidationsData(sheetId, data, dvNewZones);
56727
+ }
56728
+ this.autofillBorders(sheetId, bordersZones);
56729
+ this.autofillConditionalFormats(sheetId, cfNewRanges);
56730
+ this.autofillDataValidations(sheetId, dvNewZones);
56649
56731
  this.autofillZone = undefined;
56650
56732
  this.selection.resizeAnchorZone(this.direction, this.steps);
56651
56733
  this.lastCellSelected = {};
@@ -56654,6 +56736,95 @@ class AutofillPlugin extends UIPlugin {
56654
56736
  this.tooltip = undefined;
56655
56737
  }
56656
56738
  }
56739
+ collectBordersData(data, bordersPositions) {
56740
+ const key = JSON.stringify(data.border);
56741
+ if (!(key in bordersPositions)) {
56742
+ bordersPositions[key] = [];
56743
+ }
56744
+ bordersPositions[key].push(positionToZone({ col: data.col, row: data.row }));
56745
+ }
56746
+ collectConditionalFormatsData(sheetId, data, cfNewRanges) {
56747
+ const { originCol, originRow, col, row } = data;
56748
+ const cfsAtOrigin = this.getters.getRulesByCell(sheetId, originCol, originRow);
56749
+ const xc = toXC(col, row);
56750
+ for (const cf of cfsAtOrigin) {
56751
+ if (!(cf.id in cfNewRanges)) {
56752
+ cfNewRanges[cf.id] = [];
56753
+ }
56754
+ cfNewRanges[cf.id].push(xc);
56755
+ }
56756
+ }
56757
+ collectDataValidationsData(sheetId, data, dvNewZones) {
56758
+ const { originCol, originRow, col, row } = data;
56759
+ const cellPosition = { sheetId, col: originCol, row: originRow };
56760
+ const dvsAtOrigin = this.getters.getValidationRuleForCell(cellPosition);
56761
+ if (!dvsAtOrigin) {
56762
+ return;
56763
+ }
56764
+ if (!(dvsAtOrigin.id in dvNewZones)) {
56765
+ dvNewZones[dvsAtOrigin.id] = [];
56766
+ }
56767
+ dvNewZones[dvsAtOrigin.id].push(positionToZone({ col, row }));
56768
+ }
56769
+ autofillCell(sheetId, data) {
56770
+ this.dispatch("UPDATE_CELL", {
56771
+ sheetId,
56772
+ col: data.col,
56773
+ row: data.row,
56774
+ content: data.content || "",
56775
+ style: data.style || null,
56776
+ format: data.format || "",
56777
+ });
56778
+ // Still usefull in odoo ATM to autofill field sync
56779
+ this.dispatch("AUTOFILL_CELL", data);
56780
+ }
56781
+ autofillBorders(sheetId, bordersPositions) {
56782
+ for (const stringifiedBorder in bordersPositions) {
56783
+ const border = stringifiedBorder === "undefined" ? undefined : JSON.parse(stringifiedBorder);
56784
+ this.dispatch("SET_BORDERS_ON_TARGET", {
56785
+ sheetId,
56786
+ border,
56787
+ target: recomputeZones(bordersPositions[stringifiedBorder]),
56788
+ });
56789
+ }
56790
+ }
56791
+ autofillConditionalFormats(sheetId, cfNewRanges) {
56792
+ for (const cfId in cfNewRanges) {
56793
+ const changes = cfNewRanges[cfId];
56794
+ const cf = this.getters.getConditionalFormats(sheetId).find((cf) => cf.id === cfId);
56795
+ if (!cf) {
56796
+ continue;
56797
+ }
56798
+ const newCfRanges = this.getters.getAdaptedCfRanges(sheetId, cf, changes.map(toZone), []);
56799
+ if (newCfRanges) {
56800
+ this.dispatch("ADD_CONDITIONAL_FORMAT", {
56801
+ cf: {
56802
+ id: cf.id,
56803
+ rule: cf.rule,
56804
+ stopIfTrue: cf.stopIfTrue,
56805
+ },
56806
+ ranges: newCfRanges,
56807
+ sheetId,
56808
+ });
56809
+ }
56810
+ }
56811
+ }
56812
+ autofillDataValidations(sheetId, dvNewZones) {
56813
+ for (const dvId in dvNewZones) {
56814
+ const changes = dvNewZones[dvId];
56815
+ const dvOrigin = this.getters.getDataValidationRule(sheetId, dvId);
56816
+ if (!dvOrigin) {
56817
+ continue;
56818
+ }
56819
+ const dvRangesXcs = dvOrigin.ranges.map((range) => range.zone);
56820
+ const newDvRanges = recomputeZones(dvRangesXcs.concat(changes), []);
56821
+ this.dispatch("ADD_DATA_VALIDATION_RULE", {
56822
+ rule: dvOrigin,
56823
+ ranges: newDvRanges.map((zone) => this.getters.getRangeDataFromZone(sheetId, zone)),
56824
+ sheetId,
56825
+ });
56826
+ }
56827
+ }
56657
56828
  /**
56658
56829
  * Select a cell which becomes the last cell of the autofillZone
56659
56830
  */
@@ -56732,22 +56903,20 @@ class AutofillPlugin extends UIPlugin {
56732
56903
  /**
56733
56904
  * Generate the next cell
56734
56905
  */
56735
- computeNewCell(generator, col, row, apply) {
56906
+ computeNewCell(generator, col, row) {
56736
56907
  const { cellData, tooltip, origin } = generator.next();
56737
56908
  const { content, style, border, format } = cellData;
56738
56909
  this.tooltip = tooltip;
56739
- if (apply) {
56740
- this.dispatch("AUTOFILL_CELL", {
56741
- originCol: origin.col,
56742
- originRow: origin.row,
56743
- col,
56744
- row,
56745
- content,
56746
- style,
56747
- border,
56748
- format,
56749
- });
56750
- }
56910
+ return {
56911
+ originCol: origin.col,
56912
+ originRow: origin.row,
56913
+ col,
56914
+ row,
56915
+ content,
56916
+ style,
56917
+ border,
56918
+ format,
56919
+ };
56751
56920
  }
56752
56921
  /**
56753
56922
  * Get the rule associated to the current cell
@@ -56815,8 +56984,8 @@ class AutofillPlugin extends UIPlugin {
56815
56984
  ? position[first].value
56816
56985
  : position[second].value;
56817
56986
  }
56818
- autoFillMerge(originCol, originRow, col, row) {
56819
- const sheetId = this.getters.getActiveSheetId();
56987
+ autofillMerge(sheetId, data) {
56988
+ const { originCol, originRow, col, row } = data;
56820
56989
  const position = { sheetId, col, row };
56821
56990
  const originPosition = { sheetId, col: originCol, row: originRow };
56822
56991
  if (this.getters.isInMerge(position) && !this.getters.isInMerge(originPosition)) {
@@ -56843,35 +57012,6 @@ class AutofillPlugin extends UIPlugin {
56843
57012
  });
56844
57013
  }
56845
57014
  }
56846
- autofillCF(originCol, originRow, col, row) {
56847
- const sheetId = this.getters.getActiveSheetId();
56848
- const cfOrigin = this.getters.getRulesByCell(sheetId, originCol, originRow);
56849
- for (const cf of cfOrigin) {
56850
- const newCfRanges = this.getters.getAdaptedCfRanges(sheetId, cf, [positionToZone({ col, row })], []);
56851
- if (newCfRanges) {
56852
- this.dispatch("ADD_CONDITIONAL_FORMAT", {
56853
- cf: deepCopy(cf),
56854
- ranges: newCfRanges,
56855
- sheetId,
56856
- });
56857
- }
56858
- }
56859
- }
56860
- autofillDV(originCol, originRow, col, row) {
56861
- const sheetId = this.getters.getActiveSheetId();
56862
- const cellPosition = { sheetId, col: originCol, row: originRow };
56863
- const dvOrigin = this.getters.getValidationRuleForCell(cellPosition);
56864
- if (!dvOrigin) {
56865
- return;
56866
- }
56867
- const dvRangesZones = dvOrigin.ranges.map((range) => range.zone);
56868
- const newDvRanges = recomputeZones(dvRangesZones.concat(positionToZone({ col, row })), []);
56869
- this.dispatch("ADD_DATA_VALIDATION_RULE", {
56870
- rule: dvOrigin,
56871
- ranges: newDvRanges.map((zone) => this.getters.getRangeDataFromZone(sheetId, zone)),
56872
- sheetId,
56873
- });
56874
- }
56875
57015
  // ---------------------------------------------------------------------------
56876
57016
  // Grid rendering
56877
57017
  // ---------------------------------------------------------------------------
@@ -57251,10 +57391,8 @@ function mergeTransformation(toTransform, executed) {
57251
57391
  }
57252
57392
  const target = [];
57253
57393
  for (const zone1 of toTransform.target) {
57254
- for (const zone2 of executed.target) {
57255
- if (!overlap(zone1, zone2)) {
57256
- target.push({ ...zone1 });
57257
- }
57394
+ if (executed.target.every((zone2) => !overlap(zone1, zone2))) {
57395
+ target.push(zone1);
57258
57396
  }
57259
57397
  }
57260
57398
  if (target.length) {
@@ -69243,6 +69381,6 @@ exports.tokenColors = tokenColors;
69243
69381
  exports.tokenize = tokenize;
69244
69382
 
69245
69383
 
69246
- __info__.version = "17.4.29";
69247
- __info__.date = "2025-04-04T08:40:34.590Z";
69248
- __info__.hash = "2937d99";
69384
+ __info__.version = "17.4.31";
69385
+ __info__.date = "2025-04-18T16:24:47.716Z";
69386
+ __info__.hash = "7991032";