@odoo/o-spreadsheet 16.0.33 → 16.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.
@@ -5928,17 +5928,20 @@ rowMenuRegistry
5928
5928
  });
5929
5929
 
5930
5930
  function interactiveRenameSheet(env, sheetId, errorText) {
5931
+ if (env.model.getters.isReadonly()) {
5932
+ return;
5933
+ }
5931
5934
  const placeholder = env.model.getters.getSheetName(sheetId);
5932
5935
  const title = _lt("Rename Sheet");
5933
5936
  const callback = (name) => {
5934
5937
  if (name === null || name === placeholder) {
5935
5938
  return;
5936
5939
  }
5937
- if (name === "") {
5938
- interactiveRenameSheet(env, sheetId, _lt("The sheet name cannot be empty."));
5939
- }
5940
5940
  const result = env.model.dispatch("RENAME_SHEET", { sheetId, name });
5941
5941
  if (!result.isSuccessful) {
5942
+ if (result.reasons.includes(10 /* CommandResult.MissingSheetName */)) {
5943
+ interactiveRenameSheet(env, sheetId, _lt("The sheet name cannot be empty."));
5944
+ }
5942
5945
  if (result.reasons.includes(11 /* CommandResult.DuplicatedSheetName */)) {
5943
5946
  interactiveRenameSheet(env, sheetId, _lt("A sheet with the name %s already exists. Please select another name.", name));
5944
5947
  }
@@ -21146,6 +21149,9 @@ class FigureComponent extends owl.Component {
21146
21149
  el === null || el === void 0 ? void 0 : el.focus({ preventScroll: true });
21147
21150
  }
21148
21151
  }, () => [this.env.model.getters.getSelectedFigureId(), this.props.figure.id, this.figureRef.el]);
21152
+ owl.onWillUnmount(() => {
21153
+ this.props.onFigureDeleted();
21154
+ });
21149
21155
  }
21150
21156
  clickAnchor(dirX, dirY, ev) {
21151
21157
  this.props.onClickAnchor(dirX, dirY, ev);
@@ -21163,6 +21169,7 @@ class FigureComponent extends owl.Component {
21163
21169
  });
21164
21170
  this.props.onFigureDeleted();
21165
21171
  ev.preventDefault();
21172
+ ev.stopPropagation();
21166
21173
  break;
21167
21174
  case "ArrowDown":
21168
21175
  case "ArrowLeft":
@@ -21182,6 +21189,7 @@ class FigureComponent extends owl.Component {
21182
21189
  y: figure.y + delta[1],
21183
21190
  });
21184
21191
  ev.preventDefault();
21192
+ ev.stopPropagation();
21185
21193
  break;
21186
21194
  }
21187
21195
  }
@@ -21406,6 +21414,7 @@ class FiguresContainer extends owl.Component {
21406
21414
  ev.stopPropagation();
21407
21415
  const initialX = ev.clientX;
21408
21416
  const initialY = ev.clientY;
21417
+ const { scrollX, scrollY } = this.env.model.getters.getActiveSheetScrollInfo();
21409
21418
  const { x: dndInitialX, y: dndInitialY } = this.internalToScreenCoordinates(figure);
21410
21419
  this.dnd.x = dndInitialX;
21411
21420
  this.dnd.y = dndInitialY;
@@ -21424,13 +21433,14 @@ class FiguresContainer extends owl.Component {
21424
21433
  if (dirY < 0) {
21425
21434
  this.dnd.y = dndInitialY - deltaY;
21426
21435
  }
21427
- if (this.dnd.x < 0) {
21428
- this.dnd.width += this.dnd.x;
21429
- this.dnd.x = 0;
21436
+ // Adjusts figure dimensions to ensure it remains within header boundaries and viewport during resizing.
21437
+ if (this.dnd.x + scrollX <= 0) {
21438
+ this.dnd.width = this.dnd.width + this.dnd.x + scrollX;
21439
+ this.dnd.x = -scrollX;
21430
21440
  }
21431
- if (this.dnd.y < 0) {
21432
- this.dnd.height += this.dnd.y;
21433
- this.dnd.y = 0;
21441
+ if (this.dnd.y + scrollY <= 0) {
21442
+ this.dnd.height = this.dnd.height + this.dnd.y + scrollY;
21443
+ this.dnd.y = -scrollY;
21434
21444
  }
21435
21445
  };
21436
21446
  const onMouseUp = (ev) => {
@@ -28800,6 +28810,15 @@ class FigurePlugin extends CorePlugin {
28800
28810
  return 0 /* CommandResult.Success */;
28801
28811
  }
28802
28812
  }
28813
+ beforeHandle(cmd) {
28814
+ switch (cmd.type) {
28815
+ case "DELETE_SHEET":
28816
+ this.getters.getFigures(cmd.sheetId).forEach((figure) => {
28817
+ this.dispatch("DELETE_FIGURE", { id: figure.id, sheetId: cmd.sheetId });
28818
+ });
28819
+ break;
28820
+ }
28821
+ }
28803
28822
  handle(cmd) {
28804
28823
  switch (cmd.type) {
28805
28824
  case "CREATE_SHEET":
@@ -34948,6 +34967,7 @@ class GridSelectionPlugin extends UIPlugin {
34948
34967
  this.gridSelection.zones = this.gridSelection.zones.map((z) => this.getters.expandZone(sheetId, z));
34949
34968
  this.gridSelection.anchor.zone = this.getters.expandZone(sheetId, this.gridSelection.anchor.zone);
34950
34969
  this.setSelectionMixin(this.gridSelection.anchor, this.gridSelection.zones);
34970
+ this.selectedFigureId = null;
34951
34971
  break;
34952
34972
  }
34953
34973
  /** Any change to the selection has to be reflected in the selection processor. */
@@ -43271,6 +43291,6 @@ exports.setTranslationMethod = setTranslationMethod;
43271
43291
  exports.tokenize = tokenize;
43272
43292
 
43273
43293
 
43274
- __info__.version = '16.0.33';
43275
- __info__.date = '2024-02-16T14:49:10.674Z';
43276
- __info__.hash = 'c0cefe8';
43294
+ __info__.version = '16.0.35';
43295
+ __info__.date = '2024-03-15T10:57:14.362Z';
43296
+ __info__.hash = '5cba28b';
@@ -3328,6 +3328,7 @@ declare class FigurePlugin extends CorePlugin<FigureState> implements FigureStat
3328
3328
  [sheet: string]: Record<UID, Figure | undefined> | undefined;
3329
3329
  };
3330
3330
  allowDispatch(cmd: CoreCommand): CommandResult;
3331
+ beforeHandle(cmd: CoreCommand): void;
3331
3332
  handle(cmd: CoreCommand): void;
3332
3333
  private updateFigure;
3333
3334
  private addFigure;
@@ -5924,17 +5924,20 @@ rowMenuRegistry
5924
5924
  });
5925
5925
 
5926
5926
  function interactiveRenameSheet(env, sheetId, errorText) {
5927
+ if (env.model.getters.isReadonly()) {
5928
+ return;
5929
+ }
5927
5930
  const placeholder = env.model.getters.getSheetName(sheetId);
5928
5931
  const title = _lt("Rename Sheet");
5929
5932
  const callback = (name) => {
5930
5933
  if (name === null || name === placeholder) {
5931
5934
  return;
5932
5935
  }
5933
- if (name === "") {
5934
- interactiveRenameSheet(env, sheetId, _lt("The sheet name cannot be empty."));
5935
- }
5936
5936
  const result = env.model.dispatch("RENAME_SHEET", { sheetId, name });
5937
5937
  if (!result.isSuccessful) {
5938
+ if (result.reasons.includes(10 /* CommandResult.MissingSheetName */)) {
5939
+ interactiveRenameSheet(env, sheetId, _lt("The sheet name cannot be empty."));
5940
+ }
5938
5941
  if (result.reasons.includes(11 /* CommandResult.DuplicatedSheetName */)) {
5939
5942
  interactiveRenameSheet(env, sheetId, _lt("A sheet with the name %s already exists. Please select another name.", name));
5940
5943
  }
@@ -21142,6 +21145,9 @@ class FigureComponent extends Component {
21142
21145
  el === null || el === void 0 ? void 0 : el.focus({ preventScroll: true });
21143
21146
  }
21144
21147
  }, () => [this.env.model.getters.getSelectedFigureId(), this.props.figure.id, this.figureRef.el]);
21148
+ onWillUnmount(() => {
21149
+ this.props.onFigureDeleted();
21150
+ });
21145
21151
  }
21146
21152
  clickAnchor(dirX, dirY, ev) {
21147
21153
  this.props.onClickAnchor(dirX, dirY, ev);
@@ -21159,6 +21165,7 @@ class FigureComponent extends Component {
21159
21165
  });
21160
21166
  this.props.onFigureDeleted();
21161
21167
  ev.preventDefault();
21168
+ ev.stopPropagation();
21162
21169
  break;
21163
21170
  case "ArrowDown":
21164
21171
  case "ArrowLeft":
@@ -21178,6 +21185,7 @@ class FigureComponent extends Component {
21178
21185
  y: figure.y + delta[1],
21179
21186
  });
21180
21187
  ev.preventDefault();
21188
+ ev.stopPropagation();
21181
21189
  break;
21182
21190
  }
21183
21191
  }
@@ -21402,6 +21410,7 @@ class FiguresContainer extends Component {
21402
21410
  ev.stopPropagation();
21403
21411
  const initialX = ev.clientX;
21404
21412
  const initialY = ev.clientY;
21413
+ const { scrollX, scrollY } = this.env.model.getters.getActiveSheetScrollInfo();
21405
21414
  const { x: dndInitialX, y: dndInitialY } = this.internalToScreenCoordinates(figure);
21406
21415
  this.dnd.x = dndInitialX;
21407
21416
  this.dnd.y = dndInitialY;
@@ -21420,13 +21429,14 @@ class FiguresContainer extends Component {
21420
21429
  if (dirY < 0) {
21421
21430
  this.dnd.y = dndInitialY - deltaY;
21422
21431
  }
21423
- if (this.dnd.x < 0) {
21424
- this.dnd.width += this.dnd.x;
21425
- this.dnd.x = 0;
21432
+ // Adjusts figure dimensions to ensure it remains within header boundaries and viewport during resizing.
21433
+ if (this.dnd.x + scrollX <= 0) {
21434
+ this.dnd.width = this.dnd.width + this.dnd.x + scrollX;
21435
+ this.dnd.x = -scrollX;
21426
21436
  }
21427
- if (this.dnd.y < 0) {
21428
- this.dnd.height += this.dnd.y;
21429
- this.dnd.y = 0;
21437
+ if (this.dnd.y + scrollY <= 0) {
21438
+ this.dnd.height = this.dnd.height + this.dnd.y + scrollY;
21439
+ this.dnd.y = -scrollY;
21430
21440
  }
21431
21441
  };
21432
21442
  const onMouseUp = (ev) => {
@@ -28796,6 +28806,15 @@ class FigurePlugin extends CorePlugin {
28796
28806
  return 0 /* CommandResult.Success */;
28797
28807
  }
28798
28808
  }
28809
+ beforeHandle(cmd) {
28810
+ switch (cmd.type) {
28811
+ case "DELETE_SHEET":
28812
+ this.getters.getFigures(cmd.sheetId).forEach((figure) => {
28813
+ this.dispatch("DELETE_FIGURE", { id: figure.id, sheetId: cmd.sheetId });
28814
+ });
28815
+ break;
28816
+ }
28817
+ }
28799
28818
  handle(cmd) {
28800
28819
  switch (cmd.type) {
28801
28820
  case "CREATE_SHEET":
@@ -34944,6 +34963,7 @@ class GridSelectionPlugin extends UIPlugin {
34944
34963
  this.gridSelection.zones = this.gridSelection.zones.map((z) => this.getters.expandZone(sheetId, z));
34945
34964
  this.gridSelection.anchor.zone = this.getters.expandZone(sheetId, this.gridSelection.anchor.zone);
34946
34965
  this.setSelectionMixin(this.gridSelection.anchor, this.gridSelection.zones);
34966
+ this.selectedFigureId = null;
34947
34967
  break;
34948
34968
  }
34949
34969
  /** Any change to the selection has to be reflected in the selection processor. */
@@ -43239,6 +43259,6 @@ function addFunction(functionName, functionDescription) {
43239
43259
  export { AbstractChart, CommandResult, CorePlugin, DATETIME_FORMAT, DispatchResult, EvaluationError, Model, Registry, Revision, SPREADSHEET_DIMENSIONS, Spreadsheet, UIPlugin, __info__, addFunction, astToFormula, cellTypes, compile, components, convertAstNodes, coreTypes, findCellInNewZone, functionCache, helpers, invalidateEvaluationCommands, load, parse, readonlyAllowedCommands, registries, setTranslationMethod, tokenize };
43240
43260
 
43241
43261
 
43242
- __info__.version = '16.0.33';
43243
- __info__.date = '2024-02-16T14:49:10.674Z';
43244
- __info__.hash = 'c0cefe8';
43262
+ __info__.version = '16.0.35';
43263
+ __info__.date = '2024-03-15T10:57:14.362Z';
43264
+ __info__.hash = '5cba28b';
@@ -5925,17 +5925,20 @@
5925
5925
  });
5926
5926
 
5927
5927
  function interactiveRenameSheet(env, sheetId, errorText) {
5928
+ if (env.model.getters.isReadonly()) {
5929
+ return;
5930
+ }
5928
5931
  const placeholder = env.model.getters.getSheetName(sheetId);
5929
5932
  const title = _lt("Rename Sheet");
5930
5933
  const callback = (name) => {
5931
5934
  if (name === null || name === placeholder) {
5932
5935
  return;
5933
5936
  }
5934
- if (name === "") {
5935
- interactiveRenameSheet(env, sheetId, _lt("The sheet name cannot be empty."));
5936
- }
5937
5937
  const result = env.model.dispatch("RENAME_SHEET", { sheetId, name });
5938
5938
  if (!result.isSuccessful) {
5939
+ if (result.reasons.includes(10 /* CommandResult.MissingSheetName */)) {
5940
+ interactiveRenameSheet(env, sheetId, _lt("The sheet name cannot be empty."));
5941
+ }
5939
5942
  if (result.reasons.includes(11 /* CommandResult.DuplicatedSheetName */)) {
5940
5943
  interactiveRenameSheet(env, sheetId, _lt("A sheet with the name %s already exists. Please select another name.", name));
5941
5944
  }
@@ -21143,6 +21146,9 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
21143
21146
  el === null || el === void 0 ? void 0 : el.focus({ preventScroll: true });
21144
21147
  }
21145
21148
  }, () => [this.env.model.getters.getSelectedFigureId(), this.props.figure.id, this.figureRef.el]);
21149
+ owl.onWillUnmount(() => {
21150
+ this.props.onFigureDeleted();
21151
+ });
21146
21152
  }
21147
21153
  clickAnchor(dirX, dirY, ev) {
21148
21154
  this.props.onClickAnchor(dirX, dirY, ev);
@@ -21160,6 +21166,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
21160
21166
  });
21161
21167
  this.props.onFigureDeleted();
21162
21168
  ev.preventDefault();
21169
+ ev.stopPropagation();
21163
21170
  break;
21164
21171
  case "ArrowDown":
21165
21172
  case "ArrowLeft":
@@ -21179,6 +21186,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
21179
21186
  y: figure.y + delta[1],
21180
21187
  });
21181
21188
  ev.preventDefault();
21189
+ ev.stopPropagation();
21182
21190
  break;
21183
21191
  }
21184
21192
  }
@@ -21403,6 +21411,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
21403
21411
  ev.stopPropagation();
21404
21412
  const initialX = ev.clientX;
21405
21413
  const initialY = ev.clientY;
21414
+ const { scrollX, scrollY } = this.env.model.getters.getActiveSheetScrollInfo();
21406
21415
  const { x: dndInitialX, y: dndInitialY } = this.internalToScreenCoordinates(figure);
21407
21416
  this.dnd.x = dndInitialX;
21408
21417
  this.dnd.y = dndInitialY;
@@ -21421,13 +21430,14 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
21421
21430
  if (dirY < 0) {
21422
21431
  this.dnd.y = dndInitialY - deltaY;
21423
21432
  }
21424
- if (this.dnd.x < 0) {
21425
- this.dnd.width += this.dnd.x;
21426
- this.dnd.x = 0;
21433
+ // Adjusts figure dimensions to ensure it remains within header boundaries and viewport during resizing.
21434
+ if (this.dnd.x + scrollX <= 0) {
21435
+ this.dnd.width = this.dnd.width + this.dnd.x + scrollX;
21436
+ this.dnd.x = -scrollX;
21427
21437
  }
21428
- if (this.dnd.y < 0) {
21429
- this.dnd.height += this.dnd.y;
21430
- this.dnd.y = 0;
21438
+ if (this.dnd.y + scrollY <= 0) {
21439
+ this.dnd.height = this.dnd.height + this.dnd.y + scrollY;
21440
+ this.dnd.y = -scrollY;
21431
21441
  }
21432
21442
  };
21433
21443
  const onMouseUp = (ev) => {
@@ -28797,6 +28807,15 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
28797
28807
  return 0 /* CommandResult.Success */;
28798
28808
  }
28799
28809
  }
28810
+ beforeHandle(cmd) {
28811
+ switch (cmd.type) {
28812
+ case "DELETE_SHEET":
28813
+ this.getters.getFigures(cmd.sheetId).forEach((figure) => {
28814
+ this.dispatch("DELETE_FIGURE", { id: figure.id, sheetId: cmd.sheetId });
28815
+ });
28816
+ break;
28817
+ }
28818
+ }
28800
28819
  handle(cmd) {
28801
28820
  switch (cmd.type) {
28802
28821
  case "CREATE_SHEET":
@@ -34945,6 +34964,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
34945
34964
  this.gridSelection.zones = this.gridSelection.zones.map((z) => this.getters.expandZone(sheetId, z));
34946
34965
  this.gridSelection.anchor.zone = this.getters.expandZone(sheetId, this.gridSelection.anchor.zone);
34947
34966
  this.setSelectionMixin(this.gridSelection.anchor, this.gridSelection.zones);
34967
+ this.selectedFigureId = null;
34948
34968
  break;
34949
34969
  }
34950
34970
  /** Any change to the selection has to be reflected in the selection processor. */
@@ -43270,9 +43290,9 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
43270
43290
  Object.defineProperty(exports, '__esModule', { value: true });
43271
43291
 
43272
43292
 
43273
- __info__.version = '16.0.33';
43274
- __info__.date = '2024-02-16T14:49:10.674Z';
43275
- __info__.hash = 'c0cefe8';
43293
+ __info__.version = '16.0.35';
43294
+ __info__.date = '2024-03-15T10:57:14.362Z';
43295
+ __info__.hash = '5cba28b';
43276
43296
 
43277
43297
 
43278
43298
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);