@odoo/o-spreadsheet 15.2.11 → 15.2.13

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.
@@ -2709,13 +2709,6 @@ for (let font of fontSizes) {
2709
2709
  }
2710
2710
 
2711
2711
  //------------------------------------------------------------------------------
2712
- /**
2713
- * Stringify an object, like JSON.stringify, except that the first level of keys
2714
- * is ordered.
2715
- */
2716
- function stringify(obj) {
2717
- return JSON.stringify(obj, Object.keys(obj).sort());
2718
- }
2719
2712
  /**
2720
2713
  * Remove quotes from a quoted string
2721
2714
  * ```js
@@ -2940,7 +2933,7 @@ const DEBUG = {};
2940
2933
  */
2941
2934
  function getItemId(item, itemsDic) {
2942
2935
  for (let [key, value] of Object.entries(itemsDic)) {
2943
- if (stringify(value) === stringify(item)) {
2936
+ if (deepEquals(value, item)) {
2944
2937
  return parseInt(key, 10);
2945
2938
  }
2946
2939
  }
@@ -9405,7 +9398,7 @@ class BordersPlugin extends CorePlugin {
9405
9398
  */
9406
9399
  function getBorderId(border) {
9407
9400
  for (let [key, value] of Object.entries(borders)) {
9408
- if (stringify(value) === stringify(border)) {
9401
+ if (deepEquals(value, border)) {
9409
9402
  return parseInt(key, 10);
9410
9403
  }
9411
9404
  }
@@ -9643,12 +9636,10 @@ class CellPlugin extends CorePlugin {
9643
9636
  * starting an async evaluation even if it has been moved or re-allocated
9644
9637
  */
9645
9638
  getCellById(cellId) {
9646
- for (const sheet of Object.values(this.cells)) {
9647
- if (sheet[cellId]) {
9648
- return sheet[cellId];
9649
- }
9650
- }
9651
- return undefined;
9639
+ // this must be as fast as possible
9640
+ const position = this.getters.getCellPosition(cellId);
9641
+ const sheet = this.cells[position.sheetId];
9642
+ return sheet[cellId];
9652
9643
  }
9653
9644
  /**
9654
9645
  * Try to infer the cell format based on the formula dependencies.
@@ -15876,7 +15867,7 @@ const CSS$i = css$k /* scss */ `
15876
15867
  }
15877
15868
  .o-input-count {
15878
15869
  width: fit-content;
15879
- padding: 4 0 4 4;
15870
+ padding: 4px 0 4px 4px;
15880
15871
  }
15881
15872
  }
15882
15873
  }
@@ -23413,9 +23404,9 @@ function revertChanges(revisions) {
23413
23404
  * Apply the changes of the given HistoryChange to the state
23414
23405
  */
23415
23406
  function applyChange(change, target) {
23416
- let val = change.root;
23417
- let key = change.path[change.path.length - 1];
23418
- for (let pathIndex = 0; pathIndex < change.path.slice(0, -1).length; pathIndex++) {
23407
+ let val = change.path[0];
23408
+ const key = change.path[change.path.length - 1];
23409
+ for (let pathIndex = 1; pathIndex < change.path.slice(0, -1).length; pathIndex++) {
23419
23410
  const p = change.path[pathIndex];
23420
23411
  if (val[p] === undefined) {
23421
23412
  const nextPath = change.path[pathIndex + 1];
@@ -23871,13 +23862,14 @@ class StateObserver {
23871
23862
  }
23872
23863
  addChange(...args) {
23873
23864
  const val = args.pop();
23874
- const [root, ...path] = args;
23865
+ const root = args[0];
23875
23866
  let value = root;
23876
- let key = path[path.length - 1];
23877
- for (let pathIndex = 0; pathIndex <= path.length - 2; pathIndex++) {
23878
- const p = path[pathIndex];
23867
+ let key = args[args.length - 1];
23868
+ const pathLength = args.length - 2;
23869
+ for (let pathIndex = 1; pathIndex <= pathLength; pathIndex++) {
23870
+ const p = args[pathIndex];
23879
23871
  if (value[p] === undefined) {
23880
- const nextPath = path[pathIndex + 1];
23872
+ const nextPath = args[pathIndex + 1];
23881
23873
  value[p] = createEmptyStructure(nextPath);
23882
23874
  }
23883
23875
  value = value[p];
@@ -23886,8 +23878,7 @@ class StateObserver {
23886
23878
  return;
23887
23879
  }
23888
23880
  this.changes.push({
23889
- root,
23890
- path,
23881
+ path: args,
23891
23882
  before: value[key],
23892
23883
  after: val,
23893
23884
  });
@@ -25927,7 +25918,10 @@ class Model extends owl__namespace.core.EventBus {
25927
25918
  */
25928
25919
  checkDispatchAllowed(command) {
25929
25920
  const results = this.handlers.map((handler) => handler.allowDispatch(command));
25930
- return new DispatchResult(results.flat());
25921
+ if (results.some((r) => r !== 0 /* Success */)) {
25922
+ return new DispatchResult(results.flat());
25923
+ }
25924
+ return DispatchResult.Success;
25931
25925
  }
25932
25926
  finalize() {
25933
25927
  this.status = 3 /* Finalizing */;
@@ -26090,10 +26084,13 @@ class Popover extends owl.Component {
26090
26084
  super(...arguments);
26091
26085
  this.getters = this.env.getters;
26092
26086
  }
26087
+ get maxHeight() {
26088
+ return Math.max(0, this.viewportDimension.height - BOTTOMBAR_HEIGHT - SCROLLBAR_WIDTH$1);
26089
+ }
26093
26090
  get style() {
26094
26091
  const horizontalPosition = `left:${this.horizontalPosition()}`;
26095
26092
  const verticalPosition = `top:${this.verticalPosition()}`;
26096
- const height = `max-height:${this.viewportDimension.height - BOTTOMBAR_HEIGHT - SCROLLBAR_WIDTH$1}`;
26093
+ const height = `max-height:${this.maxHeight}`;
26097
26094
  return `
26098
26095
  position: absolute;
26099
26096
  z-index: 5;
@@ -26115,7 +26112,8 @@ class Popover extends owl.Component {
26115
26112
  }
26116
26113
  get shouldRenderBottom() {
26117
26114
  const { y } = this.props.position;
26118
- return y + this.props.childHeight < this.viewportDimension.height + TOPBAR_HEIGHT;
26115
+ return (y + Math.min(this.props.childHeight, this.maxHeight) <
26116
+ this.viewportDimension.height + TOPBAR_HEIGHT);
26119
26117
  }
26120
26118
  horizontalPosition() {
26121
26119
  const { x } = this.props.position;
@@ -31385,6 +31383,6 @@ exports.registries = registries;
31385
31383
  exports.setTranslationMethod = setTranslationMethod;
31386
31384
 
31387
31385
 
31388
- __info__.version = '15.2.11';
31389
- __info__.date = '2023-10-19T14:17:12.583Z';
31390
- __info__.hash = 'e13740a';
31386
+ __info__.version = '15.2.13';
31387
+ __info__.date = '2023-11-24T13:06:49.659Z';
31388
+ __info__.hash = 'ea82269';
@@ -888,7 +888,7 @@ declare class StateObserver {
888
888
  commands: CoreCommand[];
889
889
  };
890
890
  addCommand(command: CoreCommand): void;
891
- addChange(...args: any[]): void;
891
+ addChange(...args: [...HistoryChange["path"], any]): void;
892
892
  }
893
893
 
894
894
  /**
@@ -3803,8 +3803,7 @@ declare type EvalContext = {
3803
3803
  };
3804
3804
 
3805
3805
  interface HistoryChange {
3806
- root: any;
3807
- path: (string | number)[];
3806
+ path: [any, ...(number | string)[]];
3808
3807
  before: any;
3809
3808
  after: any;
3810
3809
  }
@@ -4088,6 +4087,7 @@ declare class Popover extends Component<Props$g, SpreadsheetEnv> {
4088
4087
  marginTop: number;
4089
4088
  };
4090
4089
  private getters;
4090
+ get maxHeight(): number;
4091
4091
  get style(): string;
4092
4092
  private get viewportDimension();
4093
4093
  private get shouldRenderRight();
@@ -2686,13 +2686,6 @@ for (let font of fontSizes) {
2686
2686
  }
2687
2687
 
2688
2688
  //------------------------------------------------------------------------------
2689
- /**
2690
- * Stringify an object, like JSON.stringify, except that the first level of keys
2691
- * is ordered.
2692
- */
2693
- function stringify(obj) {
2694
- return JSON.stringify(obj, Object.keys(obj).sort());
2695
- }
2696
2689
  /**
2697
2690
  * Remove quotes from a quoted string
2698
2691
  * ```js
@@ -2917,7 +2910,7 @@ const DEBUG = {};
2917
2910
  */
2918
2911
  function getItemId(item, itemsDic) {
2919
2912
  for (let [key, value] of Object.entries(itemsDic)) {
2920
- if (stringify(value) === stringify(item)) {
2913
+ if (deepEquals(value, item)) {
2921
2914
  return parseInt(key, 10);
2922
2915
  }
2923
2916
  }
@@ -9382,7 +9375,7 @@ class BordersPlugin extends CorePlugin {
9382
9375
  */
9383
9376
  function getBorderId(border) {
9384
9377
  for (let [key, value] of Object.entries(borders)) {
9385
- if (stringify(value) === stringify(border)) {
9378
+ if (deepEquals(value, border)) {
9386
9379
  return parseInt(key, 10);
9387
9380
  }
9388
9381
  }
@@ -9620,12 +9613,10 @@ class CellPlugin extends CorePlugin {
9620
9613
  * starting an async evaluation even if it has been moved or re-allocated
9621
9614
  */
9622
9615
  getCellById(cellId) {
9623
- for (const sheet of Object.values(this.cells)) {
9624
- if (sheet[cellId]) {
9625
- return sheet[cellId];
9626
- }
9627
- }
9628
- return undefined;
9616
+ // this must be as fast as possible
9617
+ const position = this.getters.getCellPosition(cellId);
9618
+ const sheet = this.cells[position.sheetId];
9619
+ return sheet[cellId];
9629
9620
  }
9630
9621
  /**
9631
9622
  * Try to infer the cell format based on the formula dependencies.
@@ -15853,7 +15844,7 @@ const CSS$i = css$k /* scss */ `
15853
15844
  }
15854
15845
  .o-input-count {
15855
15846
  width: fit-content;
15856
- padding: 4 0 4 4;
15847
+ padding: 4px 0 4px 4px;
15857
15848
  }
15858
15849
  }
15859
15850
  }
@@ -23390,9 +23381,9 @@ function revertChanges(revisions) {
23390
23381
  * Apply the changes of the given HistoryChange to the state
23391
23382
  */
23392
23383
  function applyChange(change, target) {
23393
- let val = change.root;
23394
- let key = change.path[change.path.length - 1];
23395
- for (let pathIndex = 0; pathIndex < change.path.slice(0, -1).length; pathIndex++) {
23384
+ let val = change.path[0];
23385
+ const key = change.path[change.path.length - 1];
23386
+ for (let pathIndex = 1; pathIndex < change.path.slice(0, -1).length; pathIndex++) {
23396
23387
  const p = change.path[pathIndex];
23397
23388
  if (val[p] === undefined) {
23398
23389
  const nextPath = change.path[pathIndex + 1];
@@ -23848,13 +23839,14 @@ class StateObserver {
23848
23839
  }
23849
23840
  addChange(...args) {
23850
23841
  const val = args.pop();
23851
- const [root, ...path] = args;
23842
+ const root = args[0];
23852
23843
  let value = root;
23853
- let key = path[path.length - 1];
23854
- for (let pathIndex = 0; pathIndex <= path.length - 2; pathIndex++) {
23855
- const p = path[pathIndex];
23844
+ let key = args[args.length - 1];
23845
+ const pathLength = args.length - 2;
23846
+ for (let pathIndex = 1; pathIndex <= pathLength; pathIndex++) {
23847
+ const p = args[pathIndex];
23856
23848
  if (value[p] === undefined) {
23857
- const nextPath = path[pathIndex + 1];
23849
+ const nextPath = args[pathIndex + 1];
23858
23850
  value[p] = createEmptyStructure(nextPath);
23859
23851
  }
23860
23852
  value = value[p];
@@ -23863,8 +23855,7 @@ class StateObserver {
23863
23855
  return;
23864
23856
  }
23865
23857
  this.changes.push({
23866
- root,
23867
- path,
23858
+ path: args,
23868
23859
  before: value[key],
23869
23860
  after: val,
23870
23861
  });
@@ -25904,7 +25895,10 @@ class Model extends owl.core.EventBus {
25904
25895
  */
25905
25896
  checkDispatchAllowed(command) {
25906
25897
  const results = this.handlers.map((handler) => handler.allowDispatch(command));
25907
- return new DispatchResult(results.flat());
25898
+ if (results.some((r) => r !== 0 /* Success */)) {
25899
+ return new DispatchResult(results.flat());
25900
+ }
25901
+ return DispatchResult.Success;
25908
25902
  }
25909
25903
  finalize() {
25910
25904
  this.status = 3 /* Finalizing */;
@@ -26067,10 +26061,13 @@ class Popover extends Component {
26067
26061
  super(...arguments);
26068
26062
  this.getters = this.env.getters;
26069
26063
  }
26064
+ get maxHeight() {
26065
+ return Math.max(0, this.viewportDimension.height - BOTTOMBAR_HEIGHT - SCROLLBAR_WIDTH$1);
26066
+ }
26070
26067
  get style() {
26071
26068
  const horizontalPosition = `left:${this.horizontalPosition()}`;
26072
26069
  const verticalPosition = `top:${this.verticalPosition()}`;
26073
- const height = `max-height:${this.viewportDimension.height - BOTTOMBAR_HEIGHT - SCROLLBAR_WIDTH$1}`;
26070
+ const height = `max-height:${this.maxHeight}`;
26074
26071
  return `
26075
26072
  position: absolute;
26076
26073
  z-index: 5;
@@ -26092,7 +26089,8 @@ class Popover extends Component {
26092
26089
  }
26093
26090
  get shouldRenderBottom() {
26094
26091
  const { y } = this.props.position;
26095
- return y + this.props.childHeight < this.viewportDimension.height + TOPBAR_HEIGHT;
26092
+ return (y + Math.min(this.props.childHeight, this.maxHeight) <
26093
+ this.viewportDimension.height + TOPBAR_HEIGHT);
26096
26094
  }
26097
26095
  horizontalPosition() {
26098
26096
  const { x } = this.props.position;
@@ -31339,6 +31337,6 @@ const helpers = {
31339
31337
  export { CommandResult, CorePlugin, DATETIME_FORMAT, DataSource, DispatchResult, Model, Registry, Revision, SPREADSHEET_DIMENSIONS, Spreadsheet, UIPlugin, DEBUG as __DEBUG__, __info__, astToFormula, cellTypes, compile, convertAstNodes, coreTypes, functionCache, helpers, invalidateEvaluationCommands, parse, readonlyAllowedCommands, registries, setTranslationMethod };
31340
31338
 
31341
31339
 
31342
- __info__.version = '15.2.11';
31343
- __info__.date = '2023-10-19T14:17:12.583Z';
31344
- __info__.hash = 'e13740a';
31340
+ __info__.version = '15.2.13';
31341
+ __info__.date = '2023-11-24T13:06:49.659Z';
31342
+ __info__.hash = 'ea82269';
@@ -2706,13 +2706,6 @@
2706
2706
  }
2707
2707
 
2708
2708
  //------------------------------------------------------------------------------
2709
- /**
2710
- * Stringify an object, like JSON.stringify, except that the first level of keys
2711
- * is ordered.
2712
- */
2713
- function stringify(obj) {
2714
- return JSON.stringify(obj, Object.keys(obj).sort());
2715
- }
2716
2709
  /**
2717
2710
  * Remove quotes from a quoted string
2718
2711
  * ```js
@@ -2937,7 +2930,7 @@
2937
2930
  */
2938
2931
  function getItemId(item, itemsDic) {
2939
2932
  for (let [key, value] of Object.entries(itemsDic)) {
2940
- if (stringify(value) === stringify(item)) {
2933
+ if (deepEquals(value, item)) {
2941
2934
  return parseInt(key, 10);
2942
2935
  }
2943
2936
  }
@@ -9402,7 +9395,7 @@
9402
9395
  */
9403
9396
  function getBorderId(border) {
9404
9397
  for (let [key, value] of Object.entries(borders)) {
9405
- if (stringify(value) === stringify(border)) {
9398
+ if (deepEquals(value, border)) {
9406
9399
  return parseInt(key, 10);
9407
9400
  }
9408
9401
  }
@@ -9640,12 +9633,10 @@
9640
9633
  * starting an async evaluation even if it has been moved or re-allocated
9641
9634
  */
9642
9635
  getCellById(cellId) {
9643
- for (const sheet of Object.values(this.cells)) {
9644
- if (sheet[cellId]) {
9645
- return sheet[cellId];
9646
- }
9647
- }
9648
- return undefined;
9636
+ // this must be as fast as possible
9637
+ const position = this.getters.getCellPosition(cellId);
9638
+ const sheet = this.cells[position.sheetId];
9639
+ return sheet[cellId];
9649
9640
  }
9650
9641
  /**
9651
9642
  * Try to infer the cell format based on the formula dependencies.
@@ -15873,7 +15864,7 @@
15873
15864
  }
15874
15865
  .o-input-count {
15875
15866
  width: fit-content;
15876
- padding: 4 0 4 4;
15867
+ padding: 4px 0 4px 4px;
15877
15868
  }
15878
15869
  }
15879
15870
  }
@@ -23410,9 +23401,9 @@
23410
23401
  * Apply the changes of the given HistoryChange to the state
23411
23402
  */
23412
23403
  function applyChange(change, target) {
23413
- let val = change.root;
23414
- let key = change.path[change.path.length - 1];
23415
- for (let pathIndex = 0; pathIndex < change.path.slice(0, -1).length; pathIndex++) {
23404
+ let val = change.path[0];
23405
+ const key = change.path[change.path.length - 1];
23406
+ for (let pathIndex = 1; pathIndex < change.path.slice(0, -1).length; pathIndex++) {
23416
23407
  const p = change.path[pathIndex];
23417
23408
  if (val[p] === undefined) {
23418
23409
  const nextPath = change.path[pathIndex + 1];
@@ -23868,13 +23859,14 @@
23868
23859
  }
23869
23860
  addChange(...args) {
23870
23861
  const val = args.pop();
23871
- const [root, ...path] = args;
23862
+ const root = args[0];
23872
23863
  let value = root;
23873
- let key = path[path.length - 1];
23874
- for (let pathIndex = 0; pathIndex <= path.length - 2; pathIndex++) {
23875
- const p = path[pathIndex];
23864
+ let key = args[args.length - 1];
23865
+ const pathLength = args.length - 2;
23866
+ for (let pathIndex = 1; pathIndex <= pathLength; pathIndex++) {
23867
+ const p = args[pathIndex];
23876
23868
  if (value[p] === undefined) {
23877
- const nextPath = path[pathIndex + 1];
23869
+ const nextPath = args[pathIndex + 1];
23878
23870
  value[p] = createEmptyStructure(nextPath);
23879
23871
  }
23880
23872
  value = value[p];
@@ -23883,8 +23875,7 @@
23883
23875
  return;
23884
23876
  }
23885
23877
  this.changes.push({
23886
- root,
23887
- path,
23878
+ path: args,
23888
23879
  before: value[key],
23889
23880
  after: val,
23890
23881
  });
@@ -25924,7 +25915,10 @@
25924
25915
  */
25925
25916
  checkDispatchAllowed(command) {
25926
25917
  const results = this.handlers.map((handler) => handler.allowDispatch(command));
25927
- return new DispatchResult(results.flat());
25918
+ if (results.some((r) => r !== 0 /* Success */)) {
25919
+ return new DispatchResult(results.flat());
25920
+ }
25921
+ return DispatchResult.Success;
25928
25922
  }
25929
25923
  finalize() {
25930
25924
  this.status = 3 /* Finalizing */;
@@ -26087,10 +26081,13 @@
26087
26081
  super(...arguments);
26088
26082
  this.getters = this.env.getters;
26089
26083
  }
26084
+ get maxHeight() {
26085
+ return Math.max(0, this.viewportDimension.height - BOTTOMBAR_HEIGHT - SCROLLBAR_WIDTH$1);
26086
+ }
26090
26087
  get style() {
26091
26088
  const horizontalPosition = `left:${this.horizontalPosition()}`;
26092
26089
  const verticalPosition = `top:${this.verticalPosition()}`;
26093
- const height = `max-height:${this.viewportDimension.height - BOTTOMBAR_HEIGHT - SCROLLBAR_WIDTH$1}`;
26090
+ const height = `max-height:${this.maxHeight}`;
26094
26091
  return `
26095
26092
  position: absolute;
26096
26093
  z-index: 5;
@@ -26112,7 +26109,8 @@
26112
26109
  }
26113
26110
  get shouldRenderBottom() {
26114
26111
  const { y } = this.props.position;
26115
- return y + this.props.childHeight < this.viewportDimension.height + TOPBAR_HEIGHT;
26112
+ return (y + Math.min(this.props.childHeight, this.maxHeight) <
26113
+ this.viewportDimension.height + TOPBAR_HEIGHT);
26116
26114
  }
26117
26115
  horizontalPosition() {
26118
26116
  const { x } = this.props.position;
@@ -31384,9 +31382,9 @@
31384
31382
  Object.defineProperty(exports, '__esModule', { value: true });
31385
31383
 
31386
31384
 
31387
- __info__.version = '15.2.11';
31388
- __info__.date = '2023-10-19T14:17:12.583Z';
31389
- __info__.hash = 'e13740a';
31385
+ __info__.version = '15.2.13';
31386
+ __info__.date = '2023-11-24T13:06:49.659Z';
31387
+ __info__.hash = 'ea82269';
31390
31388
 
31391
31389
 
31392
31390
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);