@odoo/o-spreadsheet 17.4.28 → 17.4.30

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.28
6
- * @date 2025-03-26T12:48:33.387Z
7
- * @hash a81a8f4
5
+ * @version 17.4.30
6
+ * @date 2025-04-14T17:17:01.767Z
7
+ * @hash e4cf37d
8
8
  */
9
9
 
10
10
  'use strict';
@@ -774,8 +774,7 @@ function removeFalsyAttributes(obj) {
774
774
  *
775
775
  * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions/Character_Classes
776
776
  */
777
- const whiteSpaceSpecialCharacters = [
778
- " ",
777
+ const specialWhiteSpaceSpecialCharacters = [
779
778
  "\t",
780
779
  "\f",
781
780
  "\v",
@@ -790,7 +789,7 @@ const whiteSpaceSpecialCharacters = [
790
789
  String.fromCharCode(parseInt("3000", 16)),
791
790
  String.fromCharCode(parseInt("feff", 16)),
792
791
  ];
793
- const whiteSpaceRegexp = new RegExp(whiteSpaceSpecialCharacters.join("|"), "g");
792
+ const specialWhiteSpaceRegexp = new RegExp(specialWhiteSpaceSpecialCharacters.join("|"), "g");
794
793
  const newLineRegexp = /(\r\n|\r)/g;
795
794
  /**
796
795
  * Replace all different newlines characters by \n
@@ -2170,6 +2169,7 @@ const coreTypes = new Set([
2170
2169
  "CLEAR_FORMATTING",
2171
2170
  "SET_BORDER",
2172
2171
  "SET_ZONE_BORDERS",
2172
+ "SET_BORDERS_ON_TARGET",
2173
2173
  /** CHART */
2174
2174
  "CREATE_CHART",
2175
2175
  "UPDATE_CHART",
@@ -5653,6 +5653,7 @@ class AbstractCellClipboardHandler extends ClipboardHandler {
5653
5653
  }
5654
5654
 
5655
5655
  class BorderClipboardHandler extends AbstractCellClipboardHandler {
5656
+ queuedBordersToAdd = {};
5656
5657
  copy(data) {
5657
5658
  const sheetId = data.sheetId;
5658
5659
  if (data.zones.length === 0) {
@@ -5683,6 +5684,7 @@ class BorderClipboardHandler extends AbstractCellClipboardHandler {
5683
5684
  const { left, top } = zones[0];
5684
5685
  this.pasteZone(sheetId, left, top, content.borders);
5685
5686
  }
5687
+ this.executeQueuedChanges(sheetId);
5686
5688
  }
5687
5689
  pasteZone(sheetId, col, row, borders) {
5688
5690
  for (const [r, rowBorders] of borders.entries()) {
@@ -5701,7 +5703,20 @@ class BorderClipboardHandler extends AbstractCellClipboardHandler {
5701
5703
  ...targetBorders,
5702
5704
  ...originBorders,
5703
5705
  };
5704
- 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 = {};
5705
5720
  }
5706
5721
  }
5707
5722
 
@@ -5727,8 +5742,12 @@ function tokenize(str, locale = DEFAULT_LOCALE) {
5727
5742
  str = replaceNewLines(str);
5728
5743
  const chars = new TokenizingChars(str);
5729
5744
  const result = [];
5745
+ const tokenizeSpace = specialWhiteSpaceRegexp.test(str)
5746
+ ? tokenizeSpecialCharacterSpace
5747
+ : tokenizeSimpleSpace;
5730
5748
  while (!chars.isOver()) {
5731
- let token = tokenizeSpace(chars) ||
5749
+ let token = tokenizeNewLine(chars) ||
5750
+ tokenizeSpace(chars) ||
5732
5751
  tokenizeArgsSeparator(chars, locale) ||
5733
5752
  tokenizeParenthesis(chars) ||
5734
5753
  tokenizeOperator(chars) ||
@@ -5862,17 +5881,19 @@ function tokenizeSymbol(chars) {
5862
5881
  }
5863
5882
  return null;
5864
5883
  }
5865
- function tokenizeSpace(chars) {
5866
- let length = 0;
5867
- while (chars.current === NEWLINE) {
5868
- length++;
5869
- chars.shift();
5884
+ function tokenizeSpecialCharacterSpace(chars) {
5885
+ let spaces = "";
5886
+ while (chars.current === " " || (chars.current && chars.current.match(specialWhiteSpaceRegexp))) {
5887
+ spaces += chars.shift();
5870
5888
  }
5871
- if (length) {
5872
- return { type: "SPACE", value: NEWLINE.repeat(length) };
5889
+ if (spaces) {
5890
+ return { type: "SPACE", value: spaces };
5873
5891
  }
5892
+ return null;
5893
+ }
5894
+ function tokenizeSimpleSpace(chars) {
5874
5895
  let spaces = "";
5875
- while (chars.current && chars.current.match(whiteSpaceRegexp)) {
5896
+ while (chars.current === " ") {
5876
5897
  spaces += chars.shift();
5877
5898
  }
5878
5899
  if (spaces) {
@@ -5880,6 +5901,17 @@ function tokenizeSpace(chars) {
5880
5901
  }
5881
5902
  return null;
5882
5903
  }
5904
+ function tokenizeNewLine(chars) {
5905
+ let length = 0;
5906
+ while (chars.current === NEWLINE) {
5907
+ length++;
5908
+ chars.shift();
5909
+ }
5910
+ if (length) {
5911
+ return { type: "SPACE", value: NEWLINE.repeat(length) };
5912
+ }
5913
+ return null;
5914
+ }
5883
5915
  function tokenizeInvalidRange(chars) {
5884
5916
  if (chars.currentStartsWith(CellErrorType.InvalidReference)) {
5885
5917
  chars.advanceBy(CellErrorType.InvalidReference.length);
@@ -6948,6 +6980,7 @@ class ChartClipboardHandler extends AbstractFigureClipboardHandler {
6948
6980
 
6949
6981
  class ConditionalFormatClipboardHandler extends AbstractCellClipboardHandler {
6950
6982
  uuidGenerator = new UuidGenerator();
6983
+ queuedChanges = {};
6951
6984
  copy(data) {
6952
6985
  if (!data.zones.length) {
6953
6986
  return;
@@ -6969,6 +7002,7 @@ class ConditionalFormatClipboardHandler extends AbstractCellClipboardHandler {
6969
7002
  return { cfRules };
6970
7003
  }
6971
7004
  paste(target, clippedContent, options) {
7005
+ this.queuedChanges = {};
6972
7006
  if (options.pasteOption === "asValue") {
6973
7007
  return;
6974
7008
  }
@@ -6980,6 +7014,7 @@ class ConditionalFormatClipboardHandler extends AbstractCellClipboardHandler {
6980
7014
  else {
6981
7015
  this.pasteFromCut(sheetId, zones, clippedContent);
6982
7016
  }
7017
+ this.executeQueuedChanges();
6983
7018
  }
6984
7019
  pasteFromCut(sheetId, target, content) {
6985
7020
  const selection = target[0];
@@ -6997,12 +7032,13 @@ class ConditionalFormatClipboardHandler extends AbstractCellClipboardHandler {
6997
7032
  }
6998
7033
  pasteCf(origin, target, isCutOperation) {
6999
7034
  if (origin?.rules && origin.rules.length > 0) {
7035
+ const originZone = positionToZone(origin.position);
7000
7036
  const zone = positionToZone(target);
7001
7037
  for (const rule of origin.rules) {
7002
7038
  const toRemoveZones = [];
7003
7039
  if (isCutOperation) {
7004
7040
  //remove from current rule
7005
- toRemoveZones.push(positionToZone(origin.position));
7041
+ toRemoveZones.push(originZone);
7006
7042
  }
7007
7043
  if (origin.position.sheetId === target.sheetId) {
7008
7044
  this.adaptCFRules(origin.position.sheetId, rule, [zone], toRemoveZones);
@@ -7019,36 +7055,56 @@ class ConditionalFormatClipboardHandler extends AbstractCellClipboardHandler {
7019
7055
  * Add or remove cells to a given conditional formatting rule.
7020
7056
  */
7021
7057
  adaptCFRules(sheetId, cf, toAdd, toRemove) {
7022
- const newRangesXc = this.getters.getAdaptedCfRanges(sheetId, cf, toAdd, toRemove);
7023
- if (!newRangesXc) {
7024
- return;
7058
+ if (!this.queuedChanges[sheetId]) {
7059
+ this.queuedChanges[sheetId] = [];
7025
7060
  }
7026
- if (newRangesXc.length === 0) {
7027
- this.dispatch("REMOVE_CONDITIONAL_FORMAT", { id: cf.id, sheetId });
7028
- return;
7061
+ const queuedChange = this.queuedChanges[sheetId].find((queued) => queued.cf.id === cf.id);
7062
+ if (!queuedChange) {
7063
+ this.queuedChanges[sheetId].push({ toAdd, toRemove, cf });
7064
+ }
7065
+ else {
7066
+ queuedChange.toAdd.push(...toAdd);
7067
+ queuedChange.toRemove.push(...toRemove);
7068
+ }
7069
+ }
7070
+ executeQueuedChanges() {
7071
+ for (const sheetId in this.queuedChanges) {
7072
+ for (const { toAdd, toRemove, cf } of this.queuedChanges[sheetId]) {
7073
+ const newRangesXc = this.getters.getAdaptedCfRanges(sheetId, cf, toAdd, toRemove);
7074
+ if (!newRangesXc) {
7075
+ continue;
7076
+ }
7077
+ if (newRangesXc.length === 0) {
7078
+ this.dispatch("REMOVE_CONDITIONAL_FORMAT", { id: cf.id, sheetId });
7079
+ continue;
7080
+ }
7081
+ this.dispatch("ADD_CONDITIONAL_FORMAT", {
7082
+ cf: {
7083
+ id: cf.id,
7084
+ rule: cf.rule,
7085
+ stopIfTrue: cf.stopIfTrue,
7086
+ },
7087
+ ranges: newRangesXc,
7088
+ sheetId,
7089
+ });
7090
+ }
7029
7091
  }
7030
- this.dispatch("ADD_CONDITIONAL_FORMAT", {
7031
- cf: {
7032
- id: cf.id,
7033
- rule: cf.rule,
7034
- stopIfTrue: cf.stopIfTrue,
7035
- },
7036
- ranges: newRangesXc,
7037
- sheetId,
7038
- });
7039
7092
  }
7040
7093
  getCFToCopyTo(targetSheetId, originCF) {
7041
- const cfInTarget = this.getters
7094
+ let targetCF = this.getters
7042
7095
  .getConditionalFormats(targetSheetId)
7043
7096
  .find((cf) => cf.stopIfTrue === originCF.stopIfTrue && deepEquals(cf.rule, originCF.rule));
7044
- return cfInTarget
7045
- ? cfInTarget
7046
- : { ...originCF, id: this.uuidGenerator.smallUuid(), ranges: [] };
7097
+ const queuedCfs = this.queuedChanges[targetSheetId];
7098
+ if (!targetCF && queuedCfs) {
7099
+ targetCF = queuedCfs.find((queued) => queued.cf.stopIfTrue === originCF.stopIfTrue && deepEquals(queued.cf.rule, originCF.rule))?.cf;
7100
+ }
7101
+ return targetCF || { ...originCF, id: this.uuidGenerator.uuidv4(), ranges: [] };
7047
7102
  }
7048
7103
  }
7049
7104
 
7050
7105
  class DataValidationClipboardHandler extends AbstractCellClipboardHandler {
7051
7106
  uuidGenerator = new UuidGenerator();
7107
+ queuedChanges = {};
7052
7108
  copy(data) {
7053
7109
  const { rowsIndexes, columnsIndexes } = data;
7054
7110
  const sheetId = data.sheetId;
@@ -7065,6 +7121,7 @@ class DataValidationClipboardHandler extends AbstractCellClipboardHandler {
7065
7121
  return { dvRules };
7066
7122
  }
7067
7123
  paste(target, clippedContent, options) {
7124
+ this.queuedChanges = {};
7068
7125
  if (options.pasteOption) {
7069
7126
  return;
7070
7127
  }
@@ -7076,6 +7133,7 @@ class DataValidationClipboardHandler extends AbstractCellClipboardHandler {
7076
7133
  else {
7077
7134
  this.pasteFromCut(sheetId, zones, clippedContent);
7078
7135
  }
7136
+ this.executeQueuedChanges();
7079
7137
  }
7080
7138
  pasteFromCut(sheetId, target, content) {
7081
7139
  const selection = target[0];
@@ -7094,6 +7152,7 @@ class DataValidationClipboardHandler extends AbstractCellClipboardHandler {
7094
7152
  pasteDataValidation(origin, target, isCutOperation) {
7095
7153
  if (origin) {
7096
7154
  const zone = positionToZone(target);
7155
+ const originZone = positionToZone(origin.position);
7097
7156
  const rule = origin.rule;
7098
7157
  if (!rule) {
7099
7158
  const targetRule = this.getters.getValidationRuleForCell(target);
@@ -7105,7 +7164,7 @@ class DataValidationClipboardHandler extends AbstractCellClipboardHandler {
7105
7164
  }
7106
7165
  const toRemoveZone = [];
7107
7166
  if (isCutOperation) {
7108
- toRemoveZone.push(positionToZone(origin.position));
7167
+ toRemoveZone.push(originZone);
7109
7168
  }
7110
7169
  if (origin.position.sheetId === target.sheetId) {
7111
7170
  const copyToRule = this.getDataValidationRuleToCopyTo(target.sheetId, rule, false);
@@ -7122,29 +7181,55 @@ class DataValidationClipboardHandler extends AbstractCellClipboardHandler {
7122
7181
  }
7123
7182
  }
7124
7183
  getDataValidationRuleToCopyTo(targetSheetId, originRule, newId = true) {
7125
- const ruleInTargetSheet = this.getters
7184
+ let targetRule = this.getters
7126
7185
  .getDataValidationRules(targetSheetId)
7127
7186
  .find((rule) => deepEquals(originRule.criterion, rule.criterion) &&
7128
7187
  originRule.isBlocking === rule.isBlocking);
7129
- return ruleInTargetSheet
7130
- ? ruleInTargetSheet
7131
- : { ...originRule, id: newId ? this.uuidGenerator.smallUuid() : originRule.id, ranges: [] };
7188
+ const queuedRules = this.queuedChanges[targetSheetId];
7189
+ if (!targetRule && queuedRules) {
7190
+ targetRule = queuedRules.find((queued) => deepEquals(originRule.criterion, queued.rule.criterion) &&
7191
+ originRule.isBlocking === queued.rule.isBlocking)?.rule;
7192
+ }
7193
+ return (targetRule || {
7194
+ ...originRule,
7195
+ id: newId ? this.uuidGenerator.uuidv4() : originRule.id,
7196
+ ranges: [],
7197
+ });
7132
7198
  }
7133
7199
  /**
7134
7200
  * Add or remove XCs to a given data validation rule.
7135
7201
  */
7136
7202
  adaptDataValidationRule(sheetId, rule, toAdd, toRemove) {
7137
- const dvZones = rule.ranges.map((range) => range.zone);
7138
- const newDvZones = recomputeZones([...dvZones, ...toAdd], toRemove);
7139
- if (newDvZones.length === 0) {
7140
- this.dispatch("REMOVE_DATA_VALIDATION_RULE", { sheetId, id: rule.id });
7141
- return;
7203
+ if (!this.queuedChanges[sheetId]) {
7204
+ this.queuedChanges[sheetId] = [];
7205
+ }
7206
+ const queuedChange = this.queuedChanges[sheetId].find((queued) => queued.rule.id === rule.id);
7207
+ if (!queuedChange) {
7208
+ this.queuedChanges[sheetId].push({ toAdd, toRemove, rule });
7209
+ }
7210
+ else {
7211
+ queuedChange.toAdd.push(...toAdd);
7212
+ queuedChange.toRemove.push(...toRemove);
7213
+ }
7214
+ }
7215
+ executeQueuedChanges() {
7216
+ for (const sheetId in this.queuedChanges) {
7217
+ for (const { toAdd, toRemove, rule: dv } of this.queuedChanges[sheetId]) {
7218
+ // Remove the zones first in case the same position is in toAdd and toRemove
7219
+ const dvZones = dv.ranges.map((range) => range.zone);
7220
+ const withRemovedZones = recomputeZones(dvZones, toRemove);
7221
+ const newDvZones = recomputeZones([...withRemovedZones, ...toAdd], []);
7222
+ if (newDvZones.length === 0) {
7223
+ this.dispatch("REMOVE_DATA_VALIDATION_RULE", { sheetId, id: dv.id });
7224
+ continue;
7225
+ }
7226
+ this.dispatch("ADD_DATA_VALIDATION_RULE", {
7227
+ rule: { id: dv.id, criterion: dv.criterion, isBlocking: dv.isBlocking },
7228
+ ranges: newDvZones.map((zone) => this.getters.getRangeDataFromZone(sheetId, zone)),
7229
+ sheetId,
7230
+ });
7231
+ }
7142
7232
  }
7143
- this.dispatch("ADD_DATA_VALIDATION_RULE", {
7144
- rule,
7145
- ranges: newDvZones.map((zone) => this.getters.getRangeDataFromZone(sheetId, zone)),
7146
- sheetId,
7147
- });
7148
7233
  }
7149
7234
  }
7150
7235
 
@@ -47547,6 +47632,15 @@ class BordersPlugin extends CorePlugin {
47547
47632
  case "SET_BORDER":
47548
47633
  this.setBorder(cmd.sheetId, cmd.col, cmd.row, cmd.border);
47549
47634
  break;
47635
+ case "SET_BORDERS_ON_TARGET":
47636
+ for (const zone of cmd.target) {
47637
+ for (let row = zone.top; row <= zone.bottom; row++) {
47638
+ for (let col = zone.left; col <= zone.right; col++) {
47639
+ this.setBorder(cmd.sheetId, col, row, cmd.border);
47640
+ }
47641
+ }
47642
+ }
47643
+ break;
47550
47644
  case "SET_ZONE_BORDERS":
47551
47645
  if (cmd.border) {
47552
47646
  const target = cmd.target.map((zone) => this.getters.expandZone(cmd.sheetId, zone));
@@ -49025,8 +49119,9 @@ class ConditionalFormatPlugin extends CorePlugin {
49025
49119
  if (replaceIndex > -1) {
49026
49120
  currentRanges = rules[replaceIndex].ranges.map(toUnboundedZone);
49027
49121
  }
49028
- currentRanges = currentRanges.concat(toAdd);
49029
- return recomputeZones(currentRanges, toRemove).map((zone) => this.getters.getRangeDataFromZone(sheetId, zone));
49122
+ // Remove the zones first in case the same position is in toAdd and toRemove
49123
+ const withRemovedZones = recomputeZones(currentRanges, toRemove);
49124
+ return recomputeZones([...toAdd, ...withRemovedZones], []).map((zone) => this.getters.getRangeDataFromZone(sheetId, zone));
49030
49125
  }
49031
49126
  // ---------------------------------------------------------------------------
49032
49127
  // Private
@@ -56537,25 +56632,6 @@ class AutofillPlugin extends UIPlugin {
56537
56632
  case "AUTOFILL_AUTO":
56538
56633
  this.autofillAuto();
56539
56634
  break;
56540
- case "AUTOFILL_CELL":
56541
- this.autoFillMerge(cmd.originCol, cmd.originRow, cmd.col, cmd.row);
56542
- const sheetId = this.getters.getActiveSheetId();
56543
- this.dispatch("UPDATE_CELL", {
56544
- sheetId,
56545
- col: cmd.col,
56546
- row: cmd.row,
56547
- style: cmd.style || null,
56548
- content: cmd.content || "",
56549
- format: cmd.format || "",
56550
- });
56551
- this.dispatch("SET_BORDER", {
56552
- sheetId,
56553
- col: cmd.col,
56554
- row: cmd.row,
56555
- border: cmd.border,
56556
- });
56557
- this.autofillCF(cmd.originCol, cmd.originRow, cmd.col, cmd.row);
56558
- this.autofillDV(cmd.originCol, cmd.originRow, cmd.col, cmd.row);
56559
56635
  }
56560
56636
  }
56561
56637
  // ---------------------------------------------------------------------------
@@ -56579,6 +56655,7 @@ class AutofillPlugin extends UIPlugin {
56579
56655
  }
56580
56656
  const source = this.getters.getSelectedZone();
56581
56657
  const target = this.autofillZone;
56658
+ const autofillCellsData = [];
56582
56659
  switch (this.direction) {
56583
56660
  case "down" /* DIRECTION.DOWN */:
56584
56661
  for (let col = source.left; col <= source.right; col++) {
@@ -56588,7 +56665,7 @@ class AutofillPlugin extends UIPlugin {
56588
56665
  }
56589
56666
  const generator = this.createGenerator(xcs);
56590
56667
  for (let row = target.top; row <= target.bottom; row++) {
56591
- this.computeNewCell(generator, col, row, apply);
56668
+ autofillCellsData.push(this.computeNewCell(generator, col, row));
56592
56669
  }
56593
56670
  }
56594
56671
  break;
@@ -56600,7 +56677,7 @@ class AutofillPlugin extends UIPlugin {
56600
56677
  }
56601
56678
  const generator = this.createGenerator(xcs);
56602
56679
  for (let row = target.bottom; row >= target.top; row--) {
56603
- this.computeNewCell(generator, col, row, apply);
56680
+ autofillCellsData.push(this.computeNewCell(generator, col, row));
56604
56681
  }
56605
56682
  }
56606
56683
  break;
@@ -56612,7 +56689,7 @@ class AutofillPlugin extends UIPlugin {
56612
56689
  }
56613
56690
  const generator = this.createGenerator(xcs);
56614
56691
  for (let col = target.right; col >= target.left; col--) {
56615
- this.computeNewCell(generator, col, row, apply);
56692
+ autofillCellsData.push(this.computeNewCell(generator, col, row));
56616
56693
  }
56617
56694
  }
56618
56695
  break;
@@ -56624,12 +56701,26 @@ class AutofillPlugin extends UIPlugin {
56624
56701
  }
56625
56702
  const generator = this.createGenerator(xcs);
56626
56703
  for (let col = target.left; col <= target.right; col++) {
56627
- this.computeNewCell(generator, col, row, apply);
56704
+ autofillCellsData.push(this.computeNewCell(generator, col, row));
56628
56705
  }
56629
56706
  }
56630
56707
  break;
56631
56708
  }
56632
56709
  if (apply) {
56710
+ const bordersZones = {};
56711
+ const cfNewRanges = {};
56712
+ const dvNewZones = {};
56713
+ const sheetId = this.getters.getActiveSheetId();
56714
+ for (const data of autofillCellsData) {
56715
+ this.collectBordersData(data, bordersZones);
56716
+ this.autofillMerge(sheetId, data);
56717
+ this.autofillCell(sheetId, data);
56718
+ this.collectConditionalFormatsData(sheetId, data, cfNewRanges);
56719
+ this.collectDataValidationsData(sheetId, data, dvNewZones);
56720
+ }
56721
+ this.autofillBorders(sheetId, bordersZones);
56722
+ this.autofillConditionalFormats(sheetId, cfNewRanges);
56723
+ this.autofillDataValidations(sheetId, dvNewZones);
56633
56724
  this.autofillZone = undefined;
56634
56725
  this.selection.resizeAnchorZone(this.direction, this.steps);
56635
56726
  this.lastCellSelected = {};
@@ -56638,6 +56729,95 @@ class AutofillPlugin extends UIPlugin {
56638
56729
  this.tooltip = undefined;
56639
56730
  }
56640
56731
  }
56732
+ collectBordersData(data, bordersPositions) {
56733
+ const key = JSON.stringify(data.border);
56734
+ if (!(key in bordersPositions)) {
56735
+ bordersPositions[key] = [];
56736
+ }
56737
+ bordersPositions[key].push(positionToZone({ col: data.col, row: data.row }));
56738
+ }
56739
+ collectConditionalFormatsData(sheetId, data, cfNewRanges) {
56740
+ const { originCol, originRow, col, row } = data;
56741
+ const cfsAtOrigin = this.getters.getRulesByCell(sheetId, originCol, originRow);
56742
+ const xc = toXC(col, row);
56743
+ for (const cf of cfsAtOrigin) {
56744
+ if (!(cf.id in cfNewRanges)) {
56745
+ cfNewRanges[cf.id] = [];
56746
+ }
56747
+ cfNewRanges[cf.id].push(xc);
56748
+ }
56749
+ }
56750
+ collectDataValidationsData(sheetId, data, dvNewZones) {
56751
+ const { originCol, originRow, col, row } = data;
56752
+ const cellPosition = { sheetId, col: originCol, row: originRow };
56753
+ const dvsAtOrigin = this.getters.getValidationRuleForCell(cellPosition);
56754
+ if (!dvsAtOrigin) {
56755
+ return;
56756
+ }
56757
+ if (!(dvsAtOrigin.id in dvNewZones)) {
56758
+ dvNewZones[dvsAtOrigin.id] = [];
56759
+ }
56760
+ dvNewZones[dvsAtOrigin.id].push(positionToZone({ col, row }));
56761
+ }
56762
+ autofillCell(sheetId, data) {
56763
+ this.dispatch("UPDATE_CELL", {
56764
+ sheetId,
56765
+ col: data.col,
56766
+ row: data.row,
56767
+ content: data.content || "",
56768
+ style: data.style || null,
56769
+ format: data.format || "",
56770
+ });
56771
+ // Still usefull in odoo ATM to autofill field sync
56772
+ this.dispatch("AUTOFILL_CELL", data);
56773
+ }
56774
+ autofillBorders(sheetId, bordersPositions) {
56775
+ for (const stringifiedBorder in bordersPositions) {
56776
+ const border = stringifiedBorder === "undefined" ? undefined : JSON.parse(stringifiedBorder);
56777
+ this.dispatch("SET_BORDERS_ON_TARGET", {
56778
+ sheetId,
56779
+ border,
56780
+ target: recomputeZones(bordersPositions[stringifiedBorder]),
56781
+ });
56782
+ }
56783
+ }
56784
+ autofillConditionalFormats(sheetId, cfNewRanges) {
56785
+ for (const cfId in cfNewRanges) {
56786
+ const changes = cfNewRanges[cfId];
56787
+ const cf = this.getters.getConditionalFormats(sheetId).find((cf) => cf.id === cfId);
56788
+ if (!cf) {
56789
+ continue;
56790
+ }
56791
+ const newCfRanges = this.getters.getAdaptedCfRanges(sheetId, cf, changes.map(toZone), []);
56792
+ if (newCfRanges) {
56793
+ this.dispatch("ADD_CONDITIONAL_FORMAT", {
56794
+ cf: {
56795
+ id: cf.id,
56796
+ rule: cf.rule,
56797
+ stopIfTrue: cf.stopIfTrue,
56798
+ },
56799
+ ranges: newCfRanges,
56800
+ sheetId,
56801
+ });
56802
+ }
56803
+ }
56804
+ }
56805
+ autofillDataValidations(sheetId, dvNewZones) {
56806
+ for (const dvId in dvNewZones) {
56807
+ const changes = dvNewZones[dvId];
56808
+ const dvOrigin = this.getters.getDataValidationRule(sheetId, dvId);
56809
+ if (!dvOrigin) {
56810
+ continue;
56811
+ }
56812
+ const dvRangesXcs = dvOrigin.ranges.map((range) => range.zone);
56813
+ const newDvRanges = recomputeZones(dvRangesXcs.concat(changes), []);
56814
+ this.dispatch("ADD_DATA_VALIDATION_RULE", {
56815
+ rule: dvOrigin,
56816
+ ranges: newDvRanges.map((zone) => this.getters.getRangeDataFromZone(sheetId, zone)),
56817
+ sheetId,
56818
+ });
56819
+ }
56820
+ }
56641
56821
  /**
56642
56822
  * Select a cell which becomes the last cell of the autofillZone
56643
56823
  */
@@ -56716,22 +56896,20 @@ class AutofillPlugin extends UIPlugin {
56716
56896
  /**
56717
56897
  * Generate the next cell
56718
56898
  */
56719
- computeNewCell(generator, col, row, apply) {
56899
+ computeNewCell(generator, col, row) {
56720
56900
  const { cellData, tooltip, origin } = generator.next();
56721
56901
  const { content, style, border, format } = cellData;
56722
56902
  this.tooltip = tooltip;
56723
- if (apply) {
56724
- this.dispatch("AUTOFILL_CELL", {
56725
- originCol: origin.col,
56726
- originRow: origin.row,
56727
- col,
56728
- row,
56729
- content,
56730
- style,
56731
- border,
56732
- format,
56733
- });
56734
- }
56903
+ return {
56904
+ originCol: origin.col,
56905
+ originRow: origin.row,
56906
+ col,
56907
+ row,
56908
+ content,
56909
+ style,
56910
+ border,
56911
+ format,
56912
+ };
56735
56913
  }
56736
56914
  /**
56737
56915
  * Get the rule associated to the current cell
@@ -56799,8 +56977,8 @@ class AutofillPlugin extends UIPlugin {
56799
56977
  ? position[first].value
56800
56978
  : position[second].value;
56801
56979
  }
56802
- autoFillMerge(originCol, originRow, col, row) {
56803
- const sheetId = this.getters.getActiveSheetId();
56980
+ autofillMerge(sheetId, data) {
56981
+ const { originCol, originRow, col, row } = data;
56804
56982
  const position = { sheetId, col, row };
56805
56983
  const originPosition = { sheetId, col: originCol, row: originRow };
56806
56984
  if (this.getters.isInMerge(position) && !this.getters.isInMerge(originPosition)) {
@@ -56827,35 +57005,6 @@ class AutofillPlugin extends UIPlugin {
56827
57005
  });
56828
57006
  }
56829
57007
  }
56830
- autofillCF(originCol, originRow, col, row) {
56831
- const sheetId = this.getters.getActiveSheetId();
56832
- const cfOrigin = this.getters.getRulesByCell(sheetId, originCol, originRow);
56833
- for (const cf of cfOrigin) {
56834
- const newCfRanges = this.getters.getAdaptedCfRanges(sheetId, cf, [positionToZone({ col, row })], []);
56835
- if (newCfRanges) {
56836
- this.dispatch("ADD_CONDITIONAL_FORMAT", {
56837
- cf: deepCopy(cf),
56838
- ranges: newCfRanges,
56839
- sheetId,
56840
- });
56841
- }
56842
- }
56843
- }
56844
- autofillDV(originCol, originRow, col, row) {
56845
- const sheetId = this.getters.getActiveSheetId();
56846
- const cellPosition = { sheetId, col: originCol, row: originRow };
56847
- const dvOrigin = this.getters.getValidationRuleForCell(cellPosition);
56848
- if (!dvOrigin) {
56849
- return;
56850
- }
56851
- const dvRangesZones = dvOrigin.ranges.map((range) => range.zone);
56852
- const newDvRanges = recomputeZones(dvRangesZones.concat(positionToZone({ col, row })), []);
56853
- this.dispatch("ADD_DATA_VALIDATION_RULE", {
56854
- rule: dvOrigin,
56855
- ranges: newDvRanges.map((zone) => this.getters.getRangeDataFromZone(sheetId, zone)),
56856
- sheetId,
56857
- });
56858
- }
56859
57008
  // ---------------------------------------------------------------------------
56860
57009
  // Grid rendering
56861
57010
  // ---------------------------------------------------------------------------
@@ -69227,6 +69376,6 @@ exports.tokenColors = tokenColors;
69227
69376
  exports.tokenize = tokenize;
69228
69377
 
69229
69378
 
69230
- __info__.version = "17.4.28";
69231
- __info__.date = "2025-03-26T12:48:33.387Z";
69232
- __info__.hash = "a81a8f4";
69379
+ __info__.version = "17.4.30";
69380
+ __info__.date = "2025-04-14T17:17:01.767Z";
69381
+ __info__.hash = "e4cf37d";