@odoo/o-spreadsheet 15.0.9 → 15.0.10

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.
@@ -2912,7 +2912,37 @@ function parseSheetLink(sheetLink) {
2912
2912
  function isDefined(argument) {
2913
2913
  return argument !== undefined;
2914
2914
  }
2915
- const DEBUG = {};
2915
+ const DEBUG = {};
2916
+ /**
2917
+ * Compares two objects.
2918
+ */
2919
+ function deepEquals(o1, o2) {
2920
+ if (o1 === o2)
2921
+ return true;
2922
+ if ((o1 && !o2) || (o2 && !o1))
2923
+ return false;
2924
+ if (typeof o1 !== typeof o2)
2925
+ return false;
2926
+ if (typeof o1 !== "object")
2927
+ return o1 === o2;
2928
+ // Objects can have different keys if the values are undefined
2929
+ const keys = new Set();
2930
+ Object.keys(o1).forEach((key) => keys.add(key));
2931
+ Object.keys(o2).forEach((key) => keys.add(key));
2932
+ for (let key of keys) {
2933
+ if (typeof o1[key] !== typeof o1[key])
2934
+ return false;
2935
+ if (typeof o1[key] === "object") {
2936
+ if (!deepEquals(o1[key], o2[key]))
2937
+ return false;
2938
+ }
2939
+ else {
2940
+ if (o1[key] !== o2[key])
2941
+ return false;
2942
+ }
2943
+ }
2944
+ return true;
2945
+ }
2916
2946
 
2917
2947
  /**
2918
2948
  * Convert from a cartesian reference to a Zone
@@ -19149,6 +19179,7 @@ class EvaluationConditionalFormatPlugin extends UIPlugin {
19149
19179
  // stores the computed styles in the format of computedStyles.sheetName[col][row] = Style
19150
19180
  this.computedStyles = {};
19151
19181
  this.computedIcons = {};
19182
+ this.uuidGenerator = new UuidGenerator();
19152
19183
  /**
19153
19184
  * Execute the predicate to know if a conditional formatting rule should be applied to a cell
19154
19185
  */
@@ -19502,13 +19533,20 @@ class EvaluationConditionalFormatPlugin extends UIPlugin {
19502
19533
  this.adaptRules(origin.sheetId, cf, [xc], toRemoveRange);
19503
19534
  }
19504
19535
  else {
19505
- this.adaptRules(target.sheetId, cf, [xc], []);
19506
19536
  this.adaptRules(origin.sheetId, cf, [], toRemoveRange);
19537
+ const cfToCopyTo = this.getCFToCopyTo(target.sheetId, cf);
19538
+ this.adaptRules(target.sheetId, cfToCopyTo, [xc], []);
19507
19539
  }
19508
19540
  }
19509
19541
  }
19510
19542
  }
19511
19543
  }
19544
+ getCFToCopyTo(targetSheetId, originCF) {
19545
+ const cfInTarget = this.getters
19546
+ .getConditionalFormats(targetSheetId)
19547
+ .find((cf) => cf.stopIfTrue === originCF.stopIfTrue && deepEquals(cf.rule, originCF.rule));
19548
+ return cfInTarget ? cfInTarget : { ...originCF, id: this.uuidGenerator.uuidv4(), ranges: [] };
19549
+ }
19512
19550
  }
19513
19551
  EvaluationConditionalFormatPlugin.getters = ["getConditionalStyle", "getConditionalIcon"];
19514
19552
  EvaluationConditionalFormatPlugin.modes = ["normal"];
@@ -31407,6 +31445,6 @@ exports.registries = registries;
31407
31445
  exports.setTranslationMethod = setTranslationMethod;
31408
31446
 
31409
31447
 
31410
- __info__.version = '15.0.9';
31411
- __info__.date = '2023-06-12T13:46:56.382Z';
31412
- __info__.hash = '40ae7eb';
31448
+ __info__.version = '15.0.10';
31449
+ __info__.date = '2023-09-21T15:55:03.676Z';
31450
+ __info__.hash = '23bff2d';
@@ -3052,6 +3052,7 @@ declare class EvaluationConditionalFormatPlugin extends UIPlugin {
3052
3052
  private isStale;
3053
3053
  private computedStyles;
3054
3054
  private computedIcons;
3055
+ private uuidGenerator;
3055
3056
  handle(cmd: Command): void;
3056
3057
  finalize(): void;
3057
3058
  /**
@@ -3086,6 +3087,7 @@ declare class EvaluationConditionalFormatPlugin extends UIPlugin {
3086
3087
  */
3087
3088
  private adaptRules;
3088
3089
  private pasteCf;
3090
+ private getCFToCopyTo;
3089
3091
  }
3090
3092
 
3091
3093
  /**
@@ -2889,7 +2889,37 @@ function parseSheetLink(sheetLink) {
2889
2889
  function isDefined(argument) {
2890
2890
  return argument !== undefined;
2891
2891
  }
2892
- const DEBUG = {};
2892
+ const DEBUG = {};
2893
+ /**
2894
+ * Compares two objects.
2895
+ */
2896
+ function deepEquals(o1, o2) {
2897
+ if (o1 === o2)
2898
+ return true;
2899
+ if ((o1 && !o2) || (o2 && !o1))
2900
+ return false;
2901
+ if (typeof o1 !== typeof o2)
2902
+ return false;
2903
+ if (typeof o1 !== "object")
2904
+ return o1 === o2;
2905
+ // Objects can have different keys if the values are undefined
2906
+ const keys = new Set();
2907
+ Object.keys(o1).forEach((key) => keys.add(key));
2908
+ Object.keys(o2).forEach((key) => keys.add(key));
2909
+ for (let key of keys) {
2910
+ if (typeof o1[key] !== typeof o1[key])
2911
+ return false;
2912
+ if (typeof o1[key] === "object") {
2913
+ if (!deepEquals(o1[key], o2[key]))
2914
+ return false;
2915
+ }
2916
+ else {
2917
+ if (o1[key] !== o2[key])
2918
+ return false;
2919
+ }
2920
+ }
2921
+ return true;
2922
+ }
2893
2923
 
2894
2924
  /**
2895
2925
  * Convert from a cartesian reference to a Zone
@@ -19126,6 +19156,7 @@ class EvaluationConditionalFormatPlugin extends UIPlugin {
19126
19156
  // stores the computed styles in the format of computedStyles.sheetName[col][row] = Style
19127
19157
  this.computedStyles = {};
19128
19158
  this.computedIcons = {};
19159
+ this.uuidGenerator = new UuidGenerator();
19129
19160
  /**
19130
19161
  * Execute the predicate to know if a conditional formatting rule should be applied to a cell
19131
19162
  */
@@ -19479,13 +19510,20 @@ class EvaluationConditionalFormatPlugin extends UIPlugin {
19479
19510
  this.adaptRules(origin.sheetId, cf, [xc], toRemoveRange);
19480
19511
  }
19481
19512
  else {
19482
- this.adaptRules(target.sheetId, cf, [xc], []);
19483
19513
  this.adaptRules(origin.sheetId, cf, [], toRemoveRange);
19514
+ const cfToCopyTo = this.getCFToCopyTo(target.sheetId, cf);
19515
+ this.adaptRules(target.sheetId, cfToCopyTo, [xc], []);
19484
19516
  }
19485
19517
  }
19486
19518
  }
19487
19519
  }
19488
19520
  }
19521
+ getCFToCopyTo(targetSheetId, originCF) {
19522
+ const cfInTarget = this.getters
19523
+ .getConditionalFormats(targetSheetId)
19524
+ .find((cf) => cf.stopIfTrue === originCF.stopIfTrue && deepEquals(cf.rule, originCF.rule));
19525
+ return cfInTarget ? cfInTarget : { ...originCF, id: this.uuidGenerator.uuidv4(), ranges: [] };
19526
+ }
19489
19527
  }
19490
19528
  EvaluationConditionalFormatPlugin.getters = ["getConditionalStyle", "getConditionalIcon"];
19491
19529
  EvaluationConditionalFormatPlugin.modes = ["normal"];
@@ -31362,6 +31400,6 @@ const helpers = {
31362
31400
  export { CommandResult, CorePlugin, DATETIME_FORMAT, DataSource, DispatchResult, Model, Revision, SPREADSHEET_DIMENSIONS, Spreadsheet, UIPlugin, DEBUG as __DEBUG__, __info__, astToFormula, cellTypes, convertAstNodes, coreTypes, functionCache, helpers, invalidateEvaluationCommands, normalize, parse, readonlyAllowedCommands, registries, setTranslationMethod };
31363
31401
 
31364
31402
 
31365
- __info__.version = '15.0.9';
31366
- __info__.date = '2023-06-12T13:46:56.382Z';
31367
- __info__.hash = '40ae7eb';
31403
+ __info__.version = '15.0.10';
31404
+ __info__.date = '2023-09-21T15:55:03.676Z';
31405
+ __info__.hash = '23bff2d';
@@ -2909,7 +2909,37 @@
2909
2909
  function isDefined(argument) {
2910
2910
  return argument !== undefined;
2911
2911
  }
2912
- const DEBUG = {};
2912
+ const DEBUG = {};
2913
+ /**
2914
+ * Compares two objects.
2915
+ */
2916
+ function deepEquals(o1, o2) {
2917
+ if (o1 === o2)
2918
+ return true;
2919
+ if ((o1 && !o2) || (o2 && !o1))
2920
+ return false;
2921
+ if (typeof o1 !== typeof o2)
2922
+ return false;
2923
+ if (typeof o1 !== "object")
2924
+ return o1 === o2;
2925
+ // Objects can have different keys if the values are undefined
2926
+ const keys = new Set();
2927
+ Object.keys(o1).forEach((key) => keys.add(key));
2928
+ Object.keys(o2).forEach((key) => keys.add(key));
2929
+ for (let key of keys) {
2930
+ if (typeof o1[key] !== typeof o1[key])
2931
+ return false;
2932
+ if (typeof o1[key] === "object") {
2933
+ if (!deepEquals(o1[key], o2[key]))
2934
+ return false;
2935
+ }
2936
+ else {
2937
+ if (o1[key] !== o2[key])
2938
+ return false;
2939
+ }
2940
+ }
2941
+ return true;
2942
+ }
2913
2943
 
2914
2944
  /**
2915
2945
  * Convert from a cartesian reference to a Zone
@@ -19146,6 +19176,7 @@
19146
19176
  // stores the computed styles in the format of computedStyles.sheetName[col][row] = Style
19147
19177
  this.computedStyles = {};
19148
19178
  this.computedIcons = {};
19179
+ this.uuidGenerator = new UuidGenerator();
19149
19180
  /**
19150
19181
  * Execute the predicate to know if a conditional formatting rule should be applied to a cell
19151
19182
  */
@@ -19499,13 +19530,20 @@
19499
19530
  this.adaptRules(origin.sheetId, cf, [xc], toRemoveRange);
19500
19531
  }
19501
19532
  else {
19502
- this.adaptRules(target.sheetId, cf, [xc], []);
19503
19533
  this.adaptRules(origin.sheetId, cf, [], toRemoveRange);
19534
+ const cfToCopyTo = this.getCFToCopyTo(target.sheetId, cf);
19535
+ this.adaptRules(target.sheetId, cfToCopyTo, [xc], []);
19504
19536
  }
19505
19537
  }
19506
19538
  }
19507
19539
  }
19508
19540
  }
19541
+ getCFToCopyTo(targetSheetId, originCF) {
19542
+ const cfInTarget = this.getters
19543
+ .getConditionalFormats(targetSheetId)
19544
+ .find((cf) => cf.stopIfTrue === originCF.stopIfTrue && deepEquals(cf.rule, originCF.rule));
19545
+ return cfInTarget ? cfInTarget : { ...originCF, id: this.uuidGenerator.uuidv4(), ranges: [] };
19546
+ }
19509
19547
  }
19510
19548
  EvaluationConditionalFormatPlugin.getters = ["getConditionalStyle", "getConditionalIcon"];
19511
19549
  EvaluationConditionalFormatPlugin.modes = ["normal"];
@@ -31406,9 +31444,9 @@
31406
31444
  Object.defineProperty(exports, '__esModule', { value: true });
31407
31445
 
31408
31446
 
31409
- __info__.version = '15.0.9';
31410
- __info__.date = '2023-06-12T13:46:56.382Z';
31411
- __info__.hash = '40ae7eb';
31447
+ __info__.version = '15.0.10';
31448
+ __info__.date = '2023-09-21T15:55:03.676Z';
31449
+ __info__.hash = '23bff2d';
31412
31450
 
31413
31451
 
31414
31452
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);