@odoo/o-spreadsheet 18.2.6 → 18.2.7

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.2.6
6
- * @date 2025-04-04T08:41:26.115Z
7
- * @hash faa00e2
5
+ * @version 18.2.7
6
+ * @date 2025-04-14T17:19:31.011Z
7
+ * @hash e187958
8
8
  */
9
9
 
10
10
  import { useEnv, useSubEnv, onWillUnmount, useComponent, status, Component, useRef, onMounted, useEffect, App, blockDom, useState, onPatched, onWillPatch, onWillUpdateProps, useExternalListener, onWillStart, xml, useChildSubEnv, markRaw, toRaw } from '@odoo/owl';
@@ -3573,6 +3573,7 @@ const coreTypes = new Set([
3573
3573
  "CLEAR_FORMATTING",
3574
3574
  "SET_BORDER",
3575
3575
  "SET_ZONE_BORDERS",
3576
+ "SET_BORDERS_ON_TARGET",
3576
3577
  /** CHART */
3577
3578
  "CREATE_CHART",
3578
3579
  "UPDATE_CHART",
@@ -6722,6 +6723,7 @@ class AbstractCellClipboardHandler extends ClipboardHandler {
6722
6723
  }
6723
6724
 
6724
6725
  class BorderClipboardHandler extends AbstractCellClipboardHandler {
6726
+ queuedBordersToAdd = {};
6725
6727
  copy(data) {
6726
6728
  const sheetId = data.sheetId;
6727
6729
  if (data.zones.length === 0) {
@@ -6752,6 +6754,7 @@ class BorderClipboardHandler extends AbstractCellClipboardHandler {
6752
6754
  const { left, top } = zones[0];
6753
6755
  this.pasteZone(sheetId, left, top, content.borders);
6754
6756
  }
6757
+ this.executeQueuedChanges(sheetId);
6755
6758
  }
6756
6759
  pasteZone(sheetId, col, row, borders) {
6757
6760
  for (const [r, rowBorders] of borders.entries()) {
@@ -6770,7 +6773,20 @@ class BorderClipboardHandler extends AbstractCellClipboardHandler {
6770
6773
  ...targetBorders,
6771
6774
  ...originBorders,
6772
6775
  };
6773
- this.dispatch("SET_BORDER", { ...target, border });
6776
+ const borderKey = JSON.stringify(border);
6777
+ if (!this.queuedBordersToAdd[borderKey]) {
6778
+ this.queuedBordersToAdd[borderKey] = [];
6779
+ }
6780
+ this.queuedBordersToAdd[borderKey].push(positionToZone(target));
6781
+ }
6782
+ executeQueuedChanges(pasteSheetTarget) {
6783
+ for (const borderKey in this.queuedBordersToAdd) {
6784
+ const zones = this.queuedBordersToAdd[borderKey];
6785
+ const border = JSON.parse(borderKey);
6786
+ const target = recomputeZones(zones, []);
6787
+ this.dispatch("SET_BORDERS_ON_TARGET", { sheetId: pasteSheetTarget, target, border });
6788
+ }
6789
+ this.queuedBordersToAdd = {};
6774
6790
  }
6775
6791
  }
6776
6792
 
@@ -8710,12 +8726,13 @@ class ConditionalFormatClipboardHandler extends AbstractCellClipboardHandler {
8710
8726
  }
8711
8727
  pasteCf(origin, target, isCutOperation) {
8712
8728
  if (origin?.rules && origin.rules.length > 0) {
8729
+ const originZone = positionToZone(origin.position);
8713
8730
  const zone = positionToZone(target);
8714
8731
  for (const rule of origin.rules) {
8715
8732
  const toRemoveZones = [];
8716
8733
  if (isCutOperation) {
8717
8734
  //remove from current rule
8718
- toRemoveZones.push(positionToZone(origin.position));
8735
+ toRemoveZones.push(originZone);
8719
8736
  }
8720
8737
  if (origin.position.sheetId === target.sheetId) {
8721
8738
  this.adaptCFRules(origin.position.sheetId, rule, [zone], toRemoveZones);
@@ -8829,6 +8846,7 @@ class DataValidationClipboardHandler extends AbstractCellClipboardHandler {
8829
8846
  pasteDataValidation(origin, target, isCutOperation) {
8830
8847
  if (origin) {
8831
8848
  const zone = positionToZone(target);
8849
+ const originZone = positionToZone(origin.position);
8832
8850
  const rule = origin.rule;
8833
8851
  if (!rule) {
8834
8852
  const targetRule = this.getters.getValidationRuleForCell(target);
@@ -8840,7 +8858,7 @@ class DataValidationClipboardHandler extends AbstractCellClipboardHandler {
8840
8858
  }
8841
8859
  const toRemoveZone = [];
8842
8860
  if (isCutOperation) {
8843
- toRemoveZone.push(positionToZone(origin.position));
8861
+ toRemoveZone.push(originZone);
8844
8862
  }
8845
8863
  if (origin.position.sheetId === target.sheetId) {
8846
8864
  const copyToRule = this.getDataValidationRuleToCopyTo(target.sheetId, rule, false);
@@ -8900,7 +8918,7 @@ class DataValidationClipboardHandler extends AbstractCellClipboardHandler {
8900
8918
  continue;
8901
8919
  }
8902
8920
  this.dispatch("ADD_DATA_VALIDATION_RULE", {
8903
- rule: dv,
8921
+ rule: { id: dv.id, criterion: dv.criterion, isBlocking: dv.isBlocking },
8904
8922
  ranges: newDvZones.map((zone) => this.getters.getRangeDataFromZone(sheetId, zone)),
8905
8923
  sheetId,
8906
8924
  });
@@ -53311,6 +53329,15 @@ class BordersPlugin extends CorePlugin {
53311
53329
  case "SET_BORDER":
53312
53330
  this.setBorder(cmd.sheetId, cmd.col, cmd.row, cmd.border);
53313
53331
  break;
53332
+ case "SET_BORDERS_ON_TARGET":
53333
+ for (const zone of cmd.target) {
53334
+ for (let row = zone.top; row <= zone.bottom; row++) {
53335
+ for (let col = zone.left; col <= zone.right; col++) {
53336
+ this.setBorder(cmd.sheetId, col, row, cmd.border);
53337
+ }
53338
+ }
53339
+ }
53340
+ break;
53314
53341
  case "SET_ZONE_BORDERS":
53315
53342
  if (cmd.border) {
53316
53343
  const target = cmd.target.map((zone) => this.getters.expandZone(cmd.sheetId, zone));
@@ -63073,25 +63100,6 @@ class AutofillPlugin extends UIPlugin {
63073
63100
  case "AUTOFILL_AUTO":
63074
63101
  this.autofillAuto();
63075
63102
  break;
63076
- case "AUTOFILL_CELL":
63077
- this.autoFillMerge(cmd.originCol, cmd.originRow, cmd.col, cmd.row);
63078
- const sheetId = this.getters.getActiveSheetId();
63079
- this.dispatch("UPDATE_CELL", {
63080
- sheetId,
63081
- col: cmd.col,
63082
- row: cmd.row,
63083
- style: cmd.style || null,
63084
- content: cmd.content || "",
63085
- format: cmd.format || "",
63086
- });
63087
- this.dispatch("SET_BORDER", {
63088
- sheetId,
63089
- col: cmd.col,
63090
- row: cmd.row,
63091
- border: cmd.border,
63092
- });
63093
- this.autofillCF(cmd.originCol, cmd.originRow, cmd.col, cmd.row);
63094
- this.autofillDV(cmd.originCol, cmd.originRow, cmd.col, cmd.row);
63095
63103
  }
63096
63104
  }
63097
63105
  // ---------------------------------------------------------------------------
@@ -63115,6 +63123,7 @@ class AutofillPlugin extends UIPlugin {
63115
63123
  }
63116
63124
  const source = this.getters.getSelectedZone();
63117
63125
  const target = this.autofillZone;
63126
+ const autofillCellsData = [];
63118
63127
  switch (this.direction) {
63119
63128
  case "down" /* DIRECTION.DOWN */:
63120
63129
  for (let col = source.left; col <= source.right; col++) {
@@ -63124,7 +63133,7 @@ class AutofillPlugin extends UIPlugin {
63124
63133
  }
63125
63134
  const generator = this.createGenerator(xcs);
63126
63135
  for (let row = target.top; row <= target.bottom; row++) {
63127
- this.computeNewCell(generator, col, row, apply);
63136
+ autofillCellsData.push(this.computeNewCell(generator, col, row));
63128
63137
  }
63129
63138
  }
63130
63139
  break;
@@ -63136,7 +63145,7 @@ class AutofillPlugin extends UIPlugin {
63136
63145
  }
63137
63146
  const generator = this.createGenerator(xcs);
63138
63147
  for (let row = target.bottom; row >= target.top; row--) {
63139
- this.computeNewCell(generator, col, row, apply);
63148
+ autofillCellsData.push(this.computeNewCell(generator, col, row));
63140
63149
  }
63141
63150
  }
63142
63151
  break;
@@ -63148,7 +63157,7 @@ class AutofillPlugin extends UIPlugin {
63148
63157
  }
63149
63158
  const generator = this.createGenerator(xcs);
63150
63159
  for (let col = target.right; col >= target.left; col--) {
63151
- this.computeNewCell(generator, col, row, apply);
63160
+ autofillCellsData.push(this.computeNewCell(generator, col, row));
63152
63161
  }
63153
63162
  }
63154
63163
  break;
@@ -63160,12 +63169,26 @@ class AutofillPlugin extends UIPlugin {
63160
63169
  }
63161
63170
  const generator = this.createGenerator(xcs);
63162
63171
  for (let col = target.left; col <= target.right; col++) {
63163
- this.computeNewCell(generator, col, row, apply);
63172
+ autofillCellsData.push(this.computeNewCell(generator, col, row));
63164
63173
  }
63165
63174
  }
63166
63175
  break;
63167
63176
  }
63168
63177
  if (apply) {
63178
+ const bordersZones = {};
63179
+ const cfNewRanges = {};
63180
+ const dvNewZones = {};
63181
+ const sheetId = this.getters.getActiveSheetId();
63182
+ for (const data of autofillCellsData) {
63183
+ this.collectBordersData(data, bordersZones);
63184
+ this.autofillMerge(sheetId, data);
63185
+ this.autofillCell(sheetId, data);
63186
+ this.collectConditionalFormatsData(sheetId, data, cfNewRanges);
63187
+ this.collectDataValidationsData(sheetId, data, dvNewZones);
63188
+ }
63189
+ this.autofillBorders(sheetId, bordersZones);
63190
+ this.autofillConditionalFormats(sheetId, cfNewRanges);
63191
+ this.autofillDataValidations(sheetId, dvNewZones);
63169
63192
  this.autofillZone = undefined;
63170
63193
  this.selection.resizeAnchorZone(this.direction, this.steps);
63171
63194
  this.lastCellSelected = {};
@@ -63174,6 +63197,95 @@ class AutofillPlugin extends UIPlugin {
63174
63197
  this.tooltip = undefined;
63175
63198
  }
63176
63199
  }
63200
+ collectBordersData(data, bordersPositions) {
63201
+ const key = JSON.stringify(data.border);
63202
+ if (!(key in bordersPositions)) {
63203
+ bordersPositions[key] = [];
63204
+ }
63205
+ bordersPositions[key].push(positionToZone({ col: data.col, row: data.row }));
63206
+ }
63207
+ collectConditionalFormatsData(sheetId, data, cfNewRanges) {
63208
+ const { originCol, originRow, col, row } = data;
63209
+ const cfsAtOrigin = this.getters.getRulesByCell(sheetId, originCol, originRow);
63210
+ const xc = toXC(col, row);
63211
+ for (const cf of cfsAtOrigin) {
63212
+ if (!(cf.id in cfNewRanges)) {
63213
+ cfNewRanges[cf.id] = [];
63214
+ }
63215
+ cfNewRanges[cf.id].push(xc);
63216
+ }
63217
+ }
63218
+ collectDataValidationsData(sheetId, data, dvNewZones) {
63219
+ const { originCol, originRow, col, row } = data;
63220
+ const cellPosition = { sheetId, col: originCol, row: originRow };
63221
+ const dvsAtOrigin = this.getters.getValidationRuleForCell(cellPosition);
63222
+ if (!dvsAtOrigin) {
63223
+ return;
63224
+ }
63225
+ if (!(dvsAtOrigin.id in dvNewZones)) {
63226
+ dvNewZones[dvsAtOrigin.id] = [];
63227
+ }
63228
+ dvNewZones[dvsAtOrigin.id].push(positionToZone({ col, row }));
63229
+ }
63230
+ autofillCell(sheetId, data) {
63231
+ this.dispatch("UPDATE_CELL", {
63232
+ sheetId,
63233
+ col: data.col,
63234
+ row: data.row,
63235
+ content: data.content || "",
63236
+ style: data.style || null,
63237
+ format: data.format || "",
63238
+ });
63239
+ // Still usefull in odoo ATM to autofill field sync
63240
+ this.dispatch("AUTOFILL_CELL", data);
63241
+ }
63242
+ autofillBorders(sheetId, bordersPositions) {
63243
+ for (const stringifiedBorder in bordersPositions) {
63244
+ const border = stringifiedBorder === "undefined" ? undefined : JSON.parse(stringifiedBorder);
63245
+ this.dispatch("SET_BORDERS_ON_TARGET", {
63246
+ sheetId,
63247
+ border,
63248
+ target: recomputeZones(bordersPositions[stringifiedBorder]),
63249
+ });
63250
+ }
63251
+ }
63252
+ autofillConditionalFormats(sheetId, cfNewRanges) {
63253
+ for (const cfId in cfNewRanges) {
63254
+ const changes = cfNewRanges[cfId];
63255
+ const cf = this.getters.getConditionalFormats(sheetId).find((cf) => cf.id === cfId);
63256
+ if (!cf) {
63257
+ continue;
63258
+ }
63259
+ const newCfRanges = this.getters.getAdaptedCfRanges(sheetId, cf, changes.map(toZone), []);
63260
+ if (newCfRanges) {
63261
+ this.dispatch("ADD_CONDITIONAL_FORMAT", {
63262
+ cf: {
63263
+ id: cf.id,
63264
+ rule: cf.rule,
63265
+ stopIfTrue: cf.stopIfTrue,
63266
+ },
63267
+ ranges: newCfRanges,
63268
+ sheetId,
63269
+ });
63270
+ }
63271
+ }
63272
+ }
63273
+ autofillDataValidations(sheetId, dvNewZones) {
63274
+ for (const dvId in dvNewZones) {
63275
+ const changes = dvNewZones[dvId];
63276
+ const dvOrigin = this.getters.getDataValidationRule(sheetId, dvId);
63277
+ if (!dvOrigin) {
63278
+ continue;
63279
+ }
63280
+ const dvRangesXcs = dvOrigin.ranges.map((range) => range.zone);
63281
+ const newDvRanges = recomputeZones(dvRangesXcs.concat(changes), []);
63282
+ this.dispatch("ADD_DATA_VALIDATION_RULE", {
63283
+ rule: dvOrigin,
63284
+ ranges: newDvRanges.map((zone) => this.getters.getRangeDataFromZone(sheetId, zone)),
63285
+ sheetId,
63286
+ });
63287
+ }
63288
+ }
63177
63289
  /**
63178
63290
  * Select a cell which becomes the last cell of the autofillZone
63179
63291
  */
@@ -63252,22 +63364,20 @@ class AutofillPlugin extends UIPlugin {
63252
63364
  /**
63253
63365
  * Generate the next cell
63254
63366
  */
63255
- computeNewCell(generator, col, row, apply) {
63367
+ computeNewCell(generator, col, row) {
63256
63368
  const { cellData, tooltip, origin } = generator.next();
63257
63369
  const { content, style, border, format } = cellData;
63258
63370
  this.tooltip = tooltip;
63259
- if (apply) {
63260
- this.dispatch("AUTOFILL_CELL", {
63261
- originCol: origin.col,
63262
- originRow: origin.row,
63263
- col,
63264
- row,
63265
- content,
63266
- style,
63267
- border,
63268
- format,
63269
- });
63270
- }
63371
+ return {
63372
+ originCol: origin.col,
63373
+ originRow: origin.row,
63374
+ col,
63375
+ row,
63376
+ content,
63377
+ style,
63378
+ border,
63379
+ format,
63380
+ };
63271
63381
  }
63272
63382
  /**
63273
63383
  * Get the rule associated to the current cell
@@ -63335,8 +63445,8 @@ class AutofillPlugin extends UIPlugin {
63335
63445
  ? position[first].value
63336
63446
  : position[second].value;
63337
63447
  }
63338
- autoFillMerge(originCol, originRow, col, row) {
63339
- const sheetId = this.getters.getActiveSheetId();
63448
+ autofillMerge(sheetId, data) {
63449
+ const { originCol, originRow, col, row } = data;
63340
63450
  const position = { sheetId, col, row };
63341
63451
  const originPosition = { sheetId, col: originCol, row: originRow };
63342
63452
  if (this.getters.isInMerge(position) && !this.getters.isInMerge(originPosition)) {
@@ -63363,35 +63473,6 @@ class AutofillPlugin extends UIPlugin {
63363
63473
  });
63364
63474
  }
63365
63475
  }
63366
- autofillCF(originCol, originRow, col, row) {
63367
- const sheetId = this.getters.getActiveSheetId();
63368
- const cfOrigin = this.getters.getRulesByCell(sheetId, originCol, originRow);
63369
- for (const cf of cfOrigin) {
63370
- const newCfRanges = this.getters.getAdaptedCfRanges(sheetId, cf, [positionToZone({ col, row })], []);
63371
- if (newCfRanges) {
63372
- this.dispatch("ADD_CONDITIONAL_FORMAT", {
63373
- cf: deepCopy(cf),
63374
- ranges: newCfRanges,
63375
- sheetId,
63376
- });
63377
- }
63378
- }
63379
- }
63380
- autofillDV(originCol, originRow, col, row) {
63381
- const sheetId = this.getters.getActiveSheetId();
63382
- const cellPosition = { sheetId, col: originCol, row: originRow };
63383
- const dvOrigin = this.getters.getValidationRuleForCell(cellPosition);
63384
- if (!dvOrigin) {
63385
- return;
63386
- }
63387
- const dvRangesZones = dvOrigin.ranges.map((range) => range.zone);
63388
- const newDvRanges = recomputeZones(dvRangesZones.concat(positionToZone({ col, row })), []);
63389
- this.dispatch("ADD_DATA_VALIDATION_RULE", {
63390
- rule: dvOrigin,
63391
- ranges: newDvRanges.map((zone) => this.getters.getRangeDataFromZone(sheetId, zone)),
63392
- sheetId,
63393
- });
63394
- }
63395
63476
  // ---------------------------------------------------------------------------
63396
63477
  // Grid rendering
63397
63478
  // ---------------------------------------------------------------------------
@@ -76062,6 +76143,6 @@ const chartHelpers = { ...CHART_HELPERS, ...CHART_RUNTIME_HELPERS };
76062
76143
  export { AbstractCellClipboardHandler, AbstractChart, AbstractFigureClipboardHandler, CellErrorType, CommandResult, CorePlugin, CoreViewPlugin, 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 };
76063
76144
 
76064
76145
 
76065
- __info__.version = "18.2.6";
76066
- __info__.date = "2025-04-04T08:41:26.115Z";
76067
- __info__.hash = "faa00e2";
76146
+ __info__.version = "18.2.7";
76147
+ __info__.date = "2025-04-14T17:19:31.011Z";
76148
+ __info__.hash = "e187958";