@odoo/o-spreadsheet 18.0.34 → 18.0.35

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.34
6
- * @date 2025-06-19T18:26:11.726Z
7
- * @hash 5526881
5
+ * @version 18.0.35
6
+ * @date 2025-06-23T15:06:32.032Z
7
+ * @hash a38db25
8
8
  */
9
9
 
10
10
  (function (exports, owl) {
@@ -6662,6 +6662,63 @@
6662
6662
  data: spreadsheetContent,
6663
6663
  };
6664
6664
  }
6665
+ /**
6666
+ * Applies each clipboard handler to paste its corresponding data into the target.
6667
+ */
6668
+ const applyClipboardHandlersPaste = (handlers, copiedData, target, options) => {
6669
+ handlers.forEach(({ handlerName, handler }) => {
6670
+ const data = copiedData[handlerName];
6671
+ if (data) {
6672
+ handler.paste(target, data, options);
6673
+ }
6674
+ });
6675
+ };
6676
+ /**
6677
+ * Returns the paste target based on clipboard handlers.
6678
+ * Also includes the full affected zone and the list of pasted zones for selection.
6679
+ */
6680
+ function getPasteTargetFromHandlers(sheetId, zones, copiedData, handlers, options) {
6681
+ let zone = undefined;
6682
+ let selectedZones = [];
6683
+ let target = {
6684
+ sheetId,
6685
+ zones,
6686
+ };
6687
+ for (const { handlerName, handler } of handlers) {
6688
+ const handlerData = copiedData[handlerName];
6689
+ if (!handlerData) {
6690
+ continue;
6691
+ }
6692
+ const currentTarget = handler.getPasteTarget(sheetId, zones, handlerData, options);
6693
+ if (currentTarget.figureId) {
6694
+ target.figureId = currentTarget.figureId;
6695
+ }
6696
+ for (const targetZone of currentTarget.zones) {
6697
+ selectedZones.push(targetZone);
6698
+ if (zone === undefined) {
6699
+ zone = targetZone;
6700
+ continue;
6701
+ }
6702
+ zone = union(zone, targetZone);
6703
+ }
6704
+ }
6705
+ return {
6706
+ target,
6707
+ zone,
6708
+ selectedZones,
6709
+ };
6710
+ }
6711
+ /**
6712
+ * Updates the selection after a paste operation.
6713
+ */
6714
+ const selectPastedZone = (selection, sourceZones, pastedZones) => {
6715
+ const anchorCell = {
6716
+ col: sourceZones[0].left,
6717
+ row: sourceZones[0].top,
6718
+ };
6719
+ selection.getBackToDefault();
6720
+ selection.selectZone({ cell: anchorCell, zone: union(...pastedZones) }, { scrollIntoView: false });
6721
+ };
6665
6722
 
6666
6723
  class ClipboardHandler {
6667
6724
  getters;
@@ -44615,7 +44672,7 @@ stores.inject(MyMetaStore, storeInstance);
44615
44672
  }
44616
44673
  getTypeFromZone(sheetId, zone) {
44617
44674
  const cells = this.getters.getEvaluatedCellsInZone(sheetId, zone);
44618
- const nonEmptyCells = cells.filter((cell) => cell.type !== CellValueType.empty);
44675
+ const nonEmptyCells = cells.filter((cell) => !(cell.type === CellValueType.empty || cell.value === ""));
44619
44676
  if (nonEmptyCells.length === 0) {
44620
44677
  return "integer";
44621
44678
  }
@@ -48148,15 +48205,16 @@ stores.inject(MyMetaStore, storeInstance);
48148
48205
  }
48149
48206
  }
48150
48207
 
48208
+ const PAINT_FORMAT_HANDLER_KEYS = [
48209
+ "cell",
48210
+ "border",
48211
+ "table",
48212
+ "conditionalFormat",
48213
+ "merge",
48214
+ ];
48151
48215
  class PaintFormatStore extends SpreadsheetStore {
48152
48216
  mutators = ["activate", "cancel", "pasteFormat"];
48153
48217
  highlightStore = this.get(HighlightStore);
48154
- clipboardHandlers = [
48155
- new CellClipboardHandler(this.getters, this.model.dispatch),
48156
- new BorderClipboardHandler(this.getters, this.model.dispatch),
48157
- new TableClipboardHandler(this.getters, this.model.dispatch),
48158
- new ConditionalFormatClipboardHandler(this.getters, this.model.dispatch),
48159
- ];
48160
48218
  status = "inactive";
48161
48219
  copiedData;
48162
48220
  constructor(get) {
@@ -48187,24 +48245,38 @@ stores.inject(MyMetaStore, storeInstance);
48187
48245
  get isActive() {
48188
48246
  return this.status !== "inactive";
48189
48247
  }
48248
+ get clipboardHandlers() {
48249
+ return PAINT_FORMAT_HANDLER_KEYS.map((handlerName) => {
48250
+ const HandlerClass = clipboardHandlersRegistries.cellHandlers.get(handlerName);
48251
+ return {
48252
+ handlerName,
48253
+ handler: new HandlerClass(this.getters, this.model.dispatch),
48254
+ };
48255
+ });
48256
+ }
48190
48257
  copyFormats() {
48191
48258
  const sheetId = this.getters.getActiveSheetId();
48192
48259
  const zones = this.getters.getSelectedZones();
48193
- const copiedData = {};
48194
- for (const handler of this.clipboardHandlers) {
48195
- Object.assign(copiedData, handler.copy(getClipboardDataPositions(sheetId, zones)));
48260
+ const copiedData = { zones, sheetId };
48261
+ for (const { handlerName, handler } of this.clipboardHandlers) {
48262
+ const handlerResult = handler.copy(getClipboardDataPositions(sheetId, zones));
48263
+ if (handlerResult !== undefined) {
48264
+ copiedData[handlerName] = handlerResult;
48265
+ }
48196
48266
  }
48197
48267
  return copiedData;
48198
48268
  }
48199
48269
  paintFormat(sheetId, target) {
48200
- if (this.copiedData) {
48201
- for (const handler of this.clipboardHandlers) {
48202
- handler.paste({ zones: target, sheetId }, this.copiedData, {
48203
- isCutOperation: false,
48204
- pasteOption: "onlyFormat",
48205
- });
48206
- }
48270
+ if (!this.copiedData) {
48271
+ return;
48207
48272
  }
48273
+ const options = {
48274
+ isCutOperation: false,
48275
+ pasteOption: "onlyFormat",
48276
+ };
48277
+ const { target: pasteTarget, selectedZones } = getPasteTargetFromHandlers(sheetId, target, this.copiedData, this.clipboardHandlers, options);
48278
+ applyClipboardHandlersPaste(this.clipboardHandlers, this.copiedData, pasteTarget, options);
48279
+ selectPastedZone(this.model.selection, target, selectedZones);
48208
48280
  if (this.status === "oneOff") {
48209
48281
  this.cancel();
48210
48282
  }
@@ -53462,7 +53534,7 @@ stores.inject(MyMetaStore, storeInstance);
53462
53534
  else if (newRule.criterion.type === "isValueInList") {
53463
53535
  newRule.criterion.values = Array.from(new Set(newRule.criterion.values));
53464
53536
  }
53465
- const adaptedRules = this.removeRangesFromRules(sheetId, newRule.ranges, rules);
53537
+ const adaptedRules = this.removeRangesFromRules(sheetId, newRule.ranges, rules, newRule.id);
53466
53538
  const ruleIndex = adaptedRules.findIndex((rule) => rule.id === newRule.id);
53467
53539
  if (ruleIndex !== -1) {
53468
53540
  adaptedRules[ruleIndex] = newRule;
@@ -53472,9 +53544,12 @@ stores.inject(MyMetaStore, storeInstance);
53472
53544
  this.history.update("rules", sheetId, [...adaptedRules, newRule]);
53473
53545
  }
53474
53546
  }
53475
- removeRangesFromRules(sheetId, ranges, rules) {
53547
+ removeRangesFromRules(sheetId, ranges, rules, editingRuleId) {
53476
53548
  rules = deepCopy(rules);
53477
53549
  for (const rule of rules) {
53550
+ if (rule.id === editingRuleId) {
53551
+ continue; // Skip the rule being edited to preserve its place in the list
53552
+ }
53478
53553
  rule.ranges = this.getters.recomputeRanges(rule.ranges, ranges);
53479
53554
  }
53480
53555
  return rules.filter((rule) => rule.ranges.length > 0);
@@ -65159,49 +65234,17 @@ stores.inject(MyMetaStore, storeInstance);
65159
65234
  if (!copiedData) {
65160
65235
  return;
65161
65236
  }
65162
- let zone = undefined;
65163
- let selectedZones = [];
65164
65237
  const sheetId = this.getters.getActiveSheetId();
65165
- let target = {
65166
- sheetId,
65167
- zones,
65168
- };
65169
65238
  const handlers = this.selectClipboardHandlers(copiedData);
65170
- for (const { handlerName, handler } of handlers) {
65171
- const handlerData = copiedData[handlerName];
65172
- if (!handlerData) {
65173
- continue;
65174
- }
65175
- const currentTarget = handler.getPasteTarget(sheetId, zones, handlerData, options);
65176
- if (currentTarget.figureId) {
65177
- target.figureId = currentTarget.figureId;
65178
- }
65179
- for (const targetZone of currentTarget.zones) {
65180
- selectedZones.push(targetZone);
65181
- if (zone === undefined) {
65182
- zone = targetZone;
65183
- continue;
65184
- }
65185
- zone = union(zone, targetZone);
65186
- }
65187
- }
65239
+ const { target, zone, selectedZones } = getPasteTargetFromHandlers(sheetId, zones, copiedData, handlers, options);
65188
65240
  if (zone !== undefined) {
65189
- this.addMissingDimensions(this.getters.getActiveSheetId(), zone.right - zone.left + 1, zone.bottom - zone.top + 1, zone.left, zone.top);
65241
+ this.addMissingDimensions(sheetId, zone.right - zone.left + 1, zone.bottom - zone.top + 1, zone.left, zone.top);
65190
65242
  }
65191
- handlers.forEach(({ handlerName, handler }) => {
65192
- const handlerData = copiedData[handlerName];
65193
- if (handlerData) {
65194
- handler.paste(target, handlerData, options);
65195
- }
65196
- });
65243
+ applyClipboardHandlersPaste(handlers, copiedData, target, options);
65197
65244
  if (!options?.selectTarget) {
65198
65245
  return;
65199
65246
  }
65200
- const selection = zones[0];
65201
- const col = selection.left;
65202
- const row = selection.top;
65203
- this.selection.getBackToDefault();
65204
- this.selection.selectZone({ cell: { col, row }, zone: union(...selectedZones) }, { scrollIntoView: false });
65247
+ selectPastedZone(this.selection, zones, selectedZones);
65205
65248
  }
65206
65249
  /**
65207
65250
  * Add columns and/or rows to ensure that col + width and row + height are still
@@ -74460,9 +74503,9 @@ stores.inject(MyMetaStore, storeInstance);
74460
74503
  exports.tokenize = tokenize;
74461
74504
 
74462
74505
 
74463
- __info__.version = "18.0.34";
74464
- __info__.date = "2025-06-19T18:26:11.726Z";
74465
- __info__.hash = "5526881";
74506
+ __info__.version = "18.0.35";
74507
+ __info__.date = "2025-06-23T15:06:32.032Z";
74508
+ __info__.hash = "a38db25";
74466
74509
 
74467
74510
 
74468
74511
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);