@odoo/o-spreadsheet 16.3.10 → 16.3.11

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.
@@ -1034,13 +1034,17 @@ function getAddHeaderStartIndex(position, base) {
1034
1034
  return position === "after" ? base + 1 : base;
1035
1035
  }
1036
1036
  /**
1037
- * Compare two objects.
1037
+ * Compares two objects.
1038
1038
  */
1039
1039
  function deepEquals(o1, o2) {
1040
1040
  if (o1 === o2)
1041
1041
  return true;
1042
1042
  if ((o1 && !o2) || (o2 && !o1))
1043
1043
  return false;
1044
+ if (typeof o1 !== typeof o2)
1045
+ return false;
1046
+ if (typeof o1 !== "object")
1047
+ return o1 === o2;
1044
1048
  // Objects can have different keys if the values are undefined
1045
1049
  const keys = new Set();
1046
1050
  Object.keys(o1).forEach((key) => keys.add(key));
@@ -4806,6 +4810,7 @@ css /* scss */ `
4806
4810
  padding: 10px;
4807
4811
  width: ${ERROR_TOOLTIP_WIDTH}px;
4808
4812
  box-sizing: border-box !important;
4813
+ overflow-wrap: break-word;
4809
4814
  }
4810
4815
  `;
4811
4816
  class ErrorToolTip extends owl.Component {
@@ -22221,9 +22226,11 @@ function useCellHovered(env, gridRef, callback) {
22221
22226
  }
22222
22227
  }
22223
22228
  function updateMousePosition(e) {
22224
- x = e.offsetX;
22225
- y = e.offsetY;
22226
- lastMoved = Date.now();
22229
+ if (gridRef.el === e.target) {
22230
+ x = e.offsetX;
22231
+ y = e.offsetY;
22232
+ lastMoved = Date.now();
22233
+ }
22227
22234
  }
22228
22235
  function recompute() {
22229
22236
  const { col, row } = getPosition();
@@ -33723,6 +33730,7 @@ class EvaluationConditionalFormatPlugin extends UIPlugin {
33723
33730
  // stores the computed styles in the format of computedStyles.sheetName[col][row] = Style
33724
33731
  computedStyles = {};
33725
33732
  computedIcons = {};
33733
+ uuidGenerator = new UuidGenerator();
33726
33734
  // ---------------------------------------------------------------------------
33727
33735
  // Command Handling
33728
33736
  // ---------------------------------------------------------------------------
@@ -34070,13 +34078,20 @@ class EvaluationConditionalFormatPlugin extends UIPlugin {
34070
34078
  this.adaptRules(origin.sheetId, cf, [xc], toRemoveRange);
34071
34079
  }
34072
34080
  else {
34073
- this.adaptRules(target.sheetId, cf, [xc], []);
34074
34081
  this.adaptRules(origin.sheetId, cf, [], toRemoveRange);
34082
+ const cfToCopyTo = this.getCFToCopyTo(target.sheetId, cf);
34083
+ this.adaptRules(target.sheetId, cfToCopyTo, [xc], []);
34075
34084
  }
34076
34085
  }
34077
34086
  }
34078
34087
  }
34079
34088
  }
34089
+ getCFToCopyTo(targetSheetId, originCF) {
34090
+ const cfInTarget = this.getters
34091
+ .getConditionalFormats(targetSheetId)
34092
+ .find((cf) => cf.stopIfTrue === originCF.stopIfTrue && deepEquals(cf.rule, originCF.rule));
34093
+ return cfInTarget ? cfInTarget : { ...originCF, id: this.uuidGenerator.uuidv4(), ranges: [] };
34094
+ }
34080
34095
  }
34081
34096
 
34082
34097
  class FilterEvaluationPlugin extends UIPlugin {
@@ -40194,7 +40209,7 @@ class ClipboardPlugin extends UIPlugin {
40194
40209
  allowDispatch(cmd) {
40195
40210
  switch (cmd.type) {
40196
40211
  case "CUT":
40197
- const zones = cmd.cutTarget || this.getters.getSelectedZones();
40212
+ const zones = this.getters.getSelectedZones();
40198
40213
  const state = this.getClipboardState(zones, cmd.type);
40199
40214
  return state.isCutAllowed(zones);
40200
40215
  case "PASTE":
@@ -40224,7 +40239,7 @@ class ClipboardPlugin extends UIPlugin {
40224
40239
  switch (cmd.type) {
40225
40240
  case "COPY":
40226
40241
  case "CUT":
40227
- const zones = ("cutTarget" in cmd && cmd.cutTarget) || this.getters.getSelectedZones();
40242
+ const zones = this.getters.getSelectedZones();
40228
40243
  this.state = this.getClipboardState(zones, cmd.type);
40229
40244
  this.status = "visible";
40230
40245
  break;
@@ -41644,26 +41659,24 @@ class GridSelectionPlugin extends UIPlugin {
41644
41659
  const isBasedBefore = cmd.base < start;
41645
41660
  const deltaCol = isBasedBefore && isCol ? thickness : 0;
41646
41661
  const deltaRow = isBasedBefore && !isCol ? thickness : 0;
41647
- this.dispatch("CUT", {
41648
- cutTarget: [
41649
- {
41650
- left: isCol ? start + deltaCol : 0,
41651
- right: isCol ? end + deltaCol : this.getters.getNumberCols(cmd.sheetId) - 1,
41652
- top: !isCol ? start + deltaRow : 0,
41653
- bottom: !isCol ? end + deltaRow : this.getters.getNumberRows(cmd.sheetId) - 1,
41654
- },
41655
- ],
41656
- });
41657
- this.dispatch("PASTE", {
41658
- target: [
41659
- {
41660
- left: isCol ? cmd.base : 0,
41661
- right: isCol ? cmd.base + thickness - 1 : this.getters.getNumberCols(cmd.sheetId) - 1,
41662
- top: !isCol ? cmd.base : 0,
41663
- bottom: !isCol ? cmd.base + thickness - 1 : this.getters.getNumberRows(cmd.sheetId) - 1,
41664
- },
41665
- ],
41666
- });
41662
+ const target = [
41663
+ {
41664
+ left: isCol ? start + deltaCol : 0,
41665
+ right: isCol ? end + deltaCol : this.getters.getNumberCols(cmd.sheetId) - 1,
41666
+ top: !isCol ? start + deltaRow : 0,
41667
+ bottom: !isCol ? end + deltaRow : this.getters.getNumberRows(cmd.sheetId) - 1,
41668
+ },
41669
+ ];
41670
+ const state = new ClipboardCellsState(target, "CUT", this.getters, this.dispatch, this.selection);
41671
+ const pasteTarget = [
41672
+ {
41673
+ left: isCol ? cmd.base : 0,
41674
+ right: isCol ? cmd.base + thickness - 1 : this.getters.getNumberCols(cmd.sheetId) - 1,
41675
+ top: !isCol ? cmd.base : 0,
41676
+ bottom: !isCol ? cmd.base + thickness - 1 : this.getters.getNumberRows(cmd.sheetId) - 1,
41677
+ },
41678
+ ];
41679
+ state.paste(pasteTarget, { selectTarget: true });
41667
41680
  const toRemove = isBasedBefore ? cmd.elements.map((el) => el + thickness) : cmd.elements;
41668
41681
  let currentIndex = cmd.base;
41669
41682
  for (const element of toRemove) {
@@ -47707,6 +47720,6 @@ exports.setTranslationMethod = setTranslationMethod;
47707
47720
  exports.tokenize = tokenize;
47708
47721
 
47709
47722
 
47710
- __info__.version = '16.3.10';
47711
- __info__.date = '2023-09-12T11:41:57.775Z';
47712
- __info__.hash = '3a95562';
47723
+ __info__.version = '16.3.11';
47724
+ __info__.date = '2023-09-21T15:56:40.754Z';
47725
+ __info__.hash = '245df8c';
@@ -1887,8 +1887,6 @@ interface CopyCommand {
1887
1887
  }
1888
1888
  interface CutCommand {
1889
1889
  type: "CUT";
1890
- /** Zones to cut. If none were given, will copy the zones in the selection*/
1891
- cutTarget?: Zone[];
1892
1890
  }
1893
1891
  interface PasteCommand {
1894
1892
  type: "PASTE";
@@ -3786,6 +3784,7 @@ declare class EvaluationConditionalFormatPlugin extends UIPlugin {
3786
3784
  private isStale;
3787
3785
  private computedStyles;
3788
3786
  private computedIcons;
3787
+ private uuidGenerator;
3789
3788
  handle(cmd: Command): void;
3790
3789
  finalize(): void;
3791
3790
  getCellComputedStyle(position: CellPosition): Style;
@@ -3816,6 +3815,7 @@ declare class EvaluationConditionalFormatPlugin extends UIPlugin {
3816
3815
  */
3817
3816
  private adaptRules;
3818
3817
  private pasteCf;
3818
+ private getCFToCopyTo;
3819
3819
  }
3820
3820
 
3821
3821
  declare class FilterEvaluationPlugin extends UIPlugin {
@@ -1030,13 +1030,17 @@ function getAddHeaderStartIndex(position, base) {
1030
1030
  return position === "after" ? base + 1 : base;
1031
1031
  }
1032
1032
  /**
1033
- * Compare two objects.
1033
+ * Compares two objects.
1034
1034
  */
1035
1035
  function deepEquals(o1, o2) {
1036
1036
  if (o1 === o2)
1037
1037
  return true;
1038
1038
  if ((o1 && !o2) || (o2 && !o1))
1039
1039
  return false;
1040
+ if (typeof o1 !== typeof o2)
1041
+ return false;
1042
+ if (typeof o1 !== "object")
1043
+ return o1 === o2;
1040
1044
  // Objects can have different keys if the values are undefined
1041
1045
  const keys = new Set();
1042
1046
  Object.keys(o1).forEach((key) => keys.add(key));
@@ -4802,6 +4806,7 @@ css /* scss */ `
4802
4806
  padding: 10px;
4803
4807
  width: ${ERROR_TOOLTIP_WIDTH}px;
4804
4808
  box-sizing: border-box !important;
4809
+ overflow-wrap: break-word;
4805
4810
  }
4806
4811
  `;
4807
4812
  class ErrorToolTip extends Component {
@@ -22217,9 +22222,11 @@ function useCellHovered(env, gridRef, callback) {
22217
22222
  }
22218
22223
  }
22219
22224
  function updateMousePosition(e) {
22220
- x = e.offsetX;
22221
- y = e.offsetY;
22222
- lastMoved = Date.now();
22225
+ if (gridRef.el === e.target) {
22226
+ x = e.offsetX;
22227
+ y = e.offsetY;
22228
+ lastMoved = Date.now();
22229
+ }
22223
22230
  }
22224
22231
  function recompute() {
22225
22232
  const { col, row } = getPosition();
@@ -33719,6 +33726,7 @@ class EvaluationConditionalFormatPlugin extends UIPlugin {
33719
33726
  // stores the computed styles in the format of computedStyles.sheetName[col][row] = Style
33720
33727
  computedStyles = {};
33721
33728
  computedIcons = {};
33729
+ uuidGenerator = new UuidGenerator();
33722
33730
  // ---------------------------------------------------------------------------
33723
33731
  // Command Handling
33724
33732
  // ---------------------------------------------------------------------------
@@ -34066,13 +34074,20 @@ class EvaluationConditionalFormatPlugin extends UIPlugin {
34066
34074
  this.adaptRules(origin.sheetId, cf, [xc], toRemoveRange);
34067
34075
  }
34068
34076
  else {
34069
- this.adaptRules(target.sheetId, cf, [xc], []);
34070
34077
  this.adaptRules(origin.sheetId, cf, [], toRemoveRange);
34078
+ const cfToCopyTo = this.getCFToCopyTo(target.sheetId, cf);
34079
+ this.adaptRules(target.sheetId, cfToCopyTo, [xc], []);
34071
34080
  }
34072
34081
  }
34073
34082
  }
34074
34083
  }
34075
34084
  }
34085
+ getCFToCopyTo(targetSheetId, originCF) {
34086
+ const cfInTarget = this.getters
34087
+ .getConditionalFormats(targetSheetId)
34088
+ .find((cf) => cf.stopIfTrue === originCF.stopIfTrue && deepEquals(cf.rule, originCF.rule));
34089
+ return cfInTarget ? cfInTarget : { ...originCF, id: this.uuidGenerator.uuidv4(), ranges: [] };
34090
+ }
34076
34091
  }
34077
34092
 
34078
34093
  class FilterEvaluationPlugin extends UIPlugin {
@@ -40190,7 +40205,7 @@ class ClipboardPlugin extends UIPlugin {
40190
40205
  allowDispatch(cmd) {
40191
40206
  switch (cmd.type) {
40192
40207
  case "CUT":
40193
- const zones = cmd.cutTarget || this.getters.getSelectedZones();
40208
+ const zones = this.getters.getSelectedZones();
40194
40209
  const state = this.getClipboardState(zones, cmd.type);
40195
40210
  return state.isCutAllowed(zones);
40196
40211
  case "PASTE":
@@ -40220,7 +40235,7 @@ class ClipboardPlugin extends UIPlugin {
40220
40235
  switch (cmd.type) {
40221
40236
  case "COPY":
40222
40237
  case "CUT":
40223
- const zones = ("cutTarget" in cmd && cmd.cutTarget) || this.getters.getSelectedZones();
40238
+ const zones = this.getters.getSelectedZones();
40224
40239
  this.state = this.getClipboardState(zones, cmd.type);
40225
40240
  this.status = "visible";
40226
40241
  break;
@@ -41640,26 +41655,24 @@ class GridSelectionPlugin extends UIPlugin {
41640
41655
  const isBasedBefore = cmd.base < start;
41641
41656
  const deltaCol = isBasedBefore && isCol ? thickness : 0;
41642
41657
  const deltaRow = isBasedBefore && !isCol ? thickness : 0;
41643
- this.dispatch("CUT", {
41644
- cutTarget: [
41645
- {
41646
- left: isCol ? start + deltaCol : 0,
41647
- right: isCol ? end + deltaCol : this.getters.getNumberCols(cmd.sheetId) - 1,
41648
- top: !isCol ? start + deltaRow : 0,
41649
- bottom: !isCol ? end + deltaRow : this.getters.getNumberRows(cmd.sheetId) - 1,
41650
- },
41651
- ],
41652
- });
41653
- this.dispatch("PASTE", {
41654
- target: [
41655
- {
41656
- left: isCol ? cmd.base : 0,
41657
- right: isCol ? cmd.base + thickness - 1 : this.getters.getNumberCols(cmd.sheetId) - 1,
41658
- top: !isCol ? cmd.base : 0,
41659
- bottom: !isCol ? cmd.base + thickness - 1 : this.getters.getNumberRows(cmd.sheetId) - 1,
41660
- },
41661
- ],
41662
- });
41658
+ const target = [
41659
+ {
41660
+ left: isCol ? start + deltaCol : 0,
41661
+ right: isCol ? end + deltaCol : this.getters.getNumberCols(cmd.sheetId) - 1,
41662
+ top: !isCol ? start + deltaRow : 0,
41663
+ bottom: !isCol ? end + deltaRow : this.getters.getNumberRows(cmd.sheetId) - 1,
41664
+ },
41665
+ ];
41666
+ const state = new ClipboardCellsState(target, "CUT", this.getters, this.dispatch, this.selection);
41667
+ const pasteTarget = [
41668
+ {
41669
+ left: isCol ? cmd.base : 0,
41670
+ right: isCol ? cmd.base + thickness - 1 : this.getters.getNumberCols(cmd.sheetId) - 1,
41671
+ top: !isCol ? cmd.base : 0,
41672
+ bottom: !isCol ? cmd.base + thickness - 1 : this.getters.getNumberRows(cmd.sheetId) - 1,
41673
+ },
41674
+ ];
41675
+ state.paste(pasteTarget, { selectTarget: true });
41663
41676
  const toRemove = isBasedBefore ? cmd.elements.map((el) => el + thickness) : cmd.elements;
41664
41677
  let currentIndex = cmd.base;
41665
41678
  for (const element of toRemove) {
@@ -47675,6 +47688,6 @@ function addFunction(functionName, functionDescription) {
47675
47688
  export { AbstractChart, CommandResult, CorePlugin, DispatchResult, EvaluationError, Model, Registry, Revision, SPREADSHEET_DIMENSIONS, Spreadsheet, UIPlugin, __info__, addFunction, astToFormula, compile, components, convertAstNodes, coreTypes, findCellInNewZone, functionCache, helpers, invalidateEvaluationCommands, links, load, parse, readonlyAllowedCommands, registries, setDefaultSheetViewSize, setTranslationMethod, tokenize };
47676
47689
 
47677
47690
 
47678
- __info__.version = '16.3.10';
47679
- __info__.date = '2023-09-12T11:41:57.775Z';
47680
- __info__.hash = '3a95562';
47691
+ __info__.version = '16.3.11';
47692
+ __info__.date = '2023-09-21T15:56:40.754Z';
47693
+ __info__.hash = '245df8c';
@@ -1031,13 +1031,17 @@
1031
1031
  return position === "after" ? base + 1 : base;
1032
1032
  }
1033
1033
  /**
1034
- * Compare two objects.
1034
+ * Compares two objects.
1035
1035
  */
1036
1036
  function deepEquals(o1, o2) {
1037
1037
  if (o1 === o2)
1038
1038
  return true;
1039
1039
  if ((o1 && !o2) || (o2 && !o1))
1040
1040
  return false;
1041
+ if (typeof o1 !== typeof o2)
1042
+ return false;
1043
+ if (typeof o1 !== "object")
1044
+ return o1 === o2;
1041
1045
  // Objects can have different keys if the values are undefined
1042
1046
  const keys = new Set();
1043
1047
  Object.keys(o1).forEach((key) => keys.add(key));
@@ -4803,6 +4807,7 @@
4803
4807
  padding: 10px;
4804
4808
  width: ${ERROR_TOOLTIP_WIDTH}px;
4805
4809
  box-sizing: border-box !important;
4810
+ overflow-wrap: break-word;
4806
4811
  }
4807
4812
  `;
4808
4813
  class ErrorToolTip extends owl.Component {
@@ -22218,9 +22223,11 @@
22218
22223
  }
22219
22224
  }
22220
22225
  function updateMousePosition(e) {
22221
- x = e.offsetX;
22222
- y = e.offsetY;
22223
- lastMoved = Date.now();
22226
+ if (gridRef.el === e.target) {
22227
+ x = e.offsetX;
22228
+ y = e.offsetY;
22229
+ lastMoved = Date.now();
22230
+ }
22224
22231
  }
22225
22232
  function recompute() {
22226
22233
  const { col, row } = getPosition();
@@ -33720,6 +33727,7 @@
33720
33727
  // stores the computed styles in the format of computedStyles.sheetName[col][row] = Style
33721
33728
  computedStyles = {};
33722
33729
  computedIcons = {};
33730
+ uuidGenerator = new UuidGenerator();
33723
33731
  // ---------------------------------------------------------------------------
33724
33732
  // Command Handling
33725
33733
  // ---------------------------------------------------------------------------
@@ -34067,13 +34075,20 @@
34067
34075
  this.adaptRules(origin.sheetId, cf, [xc], toRemoveRange);
34068
34076
  }
34069
34077
  else {
34070
- this.adaptRules(target.sheetId, cf, [xc], []);
34071
34078
  this.adaptRules(origin.sheetId, cf, [], toRemoveRange);
34079
+ const cfToCopyTo = this.getCFToCopyTo(target.sheetId, cf);
34080
+ this.adaptRules(target.sheetId, cfToCopyTo, [xc], []);
34072
34081
  }
34073
34082
  }
34074
34083
  }
34075
34084
  }
34076
34085
  }
34086
+ getCFToCopyTo(targetSheetId, originCF) {
34087
+ const cfInTarget = this.getters
34088
+ .getConditionalFormats(targetSheetId)
34089
+ .find((cf) => cf.stopIfTrue === originCF.stopIfTrue && deepEquals(cf.rule, originCF.rule));
34090
+ return cfInTarget ? cfInTarget : { ...originCF, id: this.uuidGenerator.uuidv4(), ranges: [] };
34091
+ }
34077
34092
  }
34078
34093
 
34079
34094
  class FilterEvaluationPlugin extends UIPlugin {
@@ -40191,7 +40206,7 @@
40191
40206
  allowDispatch(cmd) {
40192
40207
  switch (cmd.type) {
40193
40208
  case "CUT":
40194
- const zones = cmd.cutTarget || this.getters.getSelectedZones();
40209
+ const zones = this.getters.getSelectedZones();
40195
40210
  const state = this.getClipboardState(zones, cmd.type);
40196
40211
  return state.isCutAllowed(zones);
40197
40212
  case "PASTE":
@@ -40221,7 +40236,7 @@
40221
40236
  switch (cmd.type) {
40222
40237
  case "COPY":
40223
40238
  case "CUT":
40224
- const zones = ("cutTarget" in cmd && cmd.cutTarget) || this.getters.getSelectedZones();
40239
+ const zones = this.getters.getSelectedZones();
40225
40240
  this.state = this.getClipboardState(zones, cmd.type);
40226
40241
  this.status = "visible";
40227
40242
  break;
@@ -41641,26 +41656,24 @@
41641
41656
  const isBasedBefore = cmd.base < start;
41642
41657
  const deltaCol = isBasedBefore && isCol ? thickness : 0;
41643
41658
  const deltaRow = isBasedBefore && !isCol ? thickness : 0;
41644
- this.dispatch("CUT", {
41645
- cutTarget: [
41646
- {
41647
- left: isCol ? start + deltaCol : 0,
41648
- right: isCol ? end + deltaCol : this.getters.getNumberCols(cmd.sheetId) - 1,
41649
- top: !isCol ? start + deltaRow : 0,
41650
- bottom: !isCol ? end + deltaRow : this.getters.getNumberRows(cmd.sheetId) - 1,
41651
- },
41652
- ],
41653
- });
41654
- this.dispatch("PASTE", {
41655
- target: [
41656
- {
41657
- left: isCol ? cmd.base : 0,
41658
- right: isCol ? cmd.base + thickness - 1 : this.getters.getNumberCols(cmd.sheetId) - 1,
41659
- top: !isCol ? cmd.base : 0,
41660
- bottom: !isCol ? cmd.base + thickness - 1 : this.getters.getNumberRows(cmd.sheetId) - 1,
41661
- },
41662
- ],
41663
- });
41659
+ const target = [
41660
+ {
41661
+ left: isCol ? start + deltaCol : 0,
41662
+ right: isCol ? end + deltaCol : this.getters.getNumberCols(cmd.sheetId) - 1,
41663
+ top: !isCol ? start + deltaRow : 0,
41664
+ bottom: !isCol ? end + deltaRow : this.getters.getNumberRows(cmd.sheetId) - 1,
41665
+ },
41666
+ ];
41667
+ const state = new ClipboardCellsState(target, "CUT", this.getters, this.dispatch, this.selection);
41668
+ const pasteTarget = [
41669
+ {
41670
+ left: isCol ? cmd.base : 0,
41671
+ right: isCol ? cmd.base + thickness - 1 : this.getters.getNumberCols(cmd.sheetId) - 1,
41672
+ top: !isCol ? cmd.base : 0,
41673
+ bottom: !isCol ? cmd.base + thickness - 1 : this.getters.getNumberRows(cmd.sheetId) - 1,
41674
+ },
41675
+ ];
41676
+ state.paste(pasteTarget, { selectTarget: true });
41664
41677
  const toRemove = isBasedBefore ? cmd.elements.map((el) => el + thickness) : cmd.elements;
41665
41678
  let currentIndex = cmd.base;
41666
41679
  for (const element of toRemove) {
@@ -47706,9 +47719,9 @@
47706
47719
  Object.defineProperty(exports, '__esModule', { value: true });
47707
47720
 
47708
47721
 
47709
- __info__.version = '16.3.10';
47710
- __info__.date = '2023-09-12T11:41:57.775Z';
47711
- __info__.hash = '3a95562';
47722
+ __info__.version = '16.3.11';
47723
+ __info__.date = '2023-09-21T15:56:40.754Z';
47724
+ __info__.hash = '245df8c';
47712
47725
 
47713
47726
 
47714
47727
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);