@odoo/o-spreadsheet 16.0.55 → 16.0.57

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.
@@ -10685,15 +10685,23 @@
10685
10685
  ChartFigure.template = "o-spreadsheet-ChartFigure";
10686
10686
  ChartFigure.components = { Menu };
10687
10687
 
10688
+ /**
10689
+ * Start listening to pointer events and apply the given callbacks.
10690
+ *
10691
+ * @returns A function to remove the listeners.
10692
+ */
10688
10693
  function startDnd(onMouseMove, onMouseUp, onMouseDown = () => { }) {
10689
- const _onMouseUp = (ev) => {
10690
- onMouseUp(ev);
10694
+ const removeListeners = () => {
10691
10695
  window.removeEventListener("mousedown", onMouseDown);
10692
10696
  window.removeEventListener("mouseup", _onMouseUp);
10693
10697
  window.removeEventListener("dragstart", _onDragStart);
10694
10698
  window.removeEventListener("mousemove", onMouseMove);
10695
10699
  window.removeEventListener("wheel", onMouseMove);
10696
10700
  };
10701
+ const _onMouseUp = (ev) => {
10702
+ onMouseUp(ev);
10703
+ removeListeners();
10704
+ };
10697
10705
  function _onDragStart(ev) {
10698
10706
  ev.preventDefault();
10699
10707
  }
@@ -10702,6 +10710,7 @@
10702
10710
  window.addEventListener("dragstart", _onDragStart);
10703
10711
  window.addEventListener("mousemove", onMouseMove);
10704
10712
  window.addEventListener("wheel", onMouseMove);
10713
+ return removeListeners;
10705
10714
  }
10706
10715
  /**
10707
10716
  * Function to be used during a mousedown event, this function allows to
@@ -18396,13 +18405,12 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
18396
18405
  }
18397
18406
  const whiteSpaceRegexp = /\s/;
18398
18407
  function tokenizeSpace(chars) {
18399
- let length = 0;
18408
+ let spaces = "";
18400
18409
  while (chars[0] && chars[0].match(whiteSpaceRegexp)) {
18401
- length++;
18402
- chars.shift();
18410
+ spaces += chars.shift();
18403
18411
  }
18404
- if (length) {
18405
- return { type: "SPACE", value: " ".repeat(length) };
18412
+ if (spaces) {
18413
+ return { type: "SPACE", value: spaces };
18406
18414
  }
18407
18415
  return null;
18408
18416
  }
@@ -20429,11 +20437,11 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
20429
20437
  }
20430
20438
 
20431
20439
  /* Custom css to highlight topbar composer on focus */
20432
- .o-topbar-toolbar .o-composer-container:focus-within {
20433
- border: 1px solid ${SELECTION_BORDER_COLOR};
20440
+ .o-topbar-toolbar .o-composer-container[active] {
20441
+ border: 1px solid ${SELECTION_BORDER_COLOR} !important;
20434
20442
  }
20435
20443
 
20436
- .o-topbar-toolbar .o-composer-container {
20444
+ .o-topbar-toolbar .o-composer-container[active] {
20437
20445
  z-index: ${ComponentsImportance.TopBarComposer};
20438
20446
  }
20439
20447
  `;
@@ -21382,6 +21390,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
21382
21390
  y: 0,
21383
21391
  width: 0,
21384
21392
  height: 0,
21393
+ cancelDnd: undefined,
21385
21394
  });
21386
21395
  }
21387
21396
  setup() {
@@ -21395,11 +21404,24 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
21395
21404
  // new rendering
21396
21405
  this.render();
21397
21406
  });
21407
+ owl.onWillUpdateProps(() => {
21408
+ const sheetId = this.env.model.getters.getActiveSheetId();
21409
+ if (this.dnd.figId && !this.env.model.getters.getFigure(sheetId, this.dnd.figId)) {
21410
+ if (this.dnd.cancelDnd) {
21411
+ this.dnd.cancelDnd();
21412
+ }
21413
+ this.dnd.figId = undefined;
21414
+ this.dnd.cancelDnd = undefined;
21415
+ }
21416
+ });
21398
21417
  }
21399
21418
  getVisibleFigures() {
21400
21419
  const visibleFigures = this.env.model.getters.getVisibleFigures();
21401
21420
  if (this.dnd.figId && !visibleFigures.some((figure) => figure.id === this.dnd.figId)) {
21402
- visibleFigures.push(this.env.model.getters.getFigure(this.env.model.getters.getActiveSheetId(), this.dnd.figId));
21421
+ const draggedFigure = this.env.model.getters.getFigure(this.env.model.getters.getActiveSheetId(), this.dnd.figId);
21422
+ if (draggedFigure) {
21423
+ visibleFigures.push(draggedFigure);
21424
+ }
21403
21425
  }
21404
21426
  return visibleFigures;
21405
21427
  }
@@ -21512,7 +21534,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
21512
21534
  this.dnd.figId = undefined;
21513
21535
  this.env.model.dispatch("UPDATE_FIGURE", { sheetId, id: figure.id, x, y });
21514
21536
  };
21515
- startDnd(onMouseMove, onMouseUp);
21537
+ this.dnd.cancelDnd = startDnd(onMouseMove, onMouseUp);
21516
21538
  }
21517
21539
  startResize(figure, dirX, dirY, ev) {
21518
21540
  ev.stopPropagation();
@@ -21566,7 +21588,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
21566
21588
  ...update,
21567
21589
  });
21568
21590
  };
21569
- startDnd(onMouseMove, onMouseUp);
21591
+ this.dnd.cancelDnd = startDnd(onMouseMove, onMouseUp);
21570
21592
  }
21571
21593
  getDndFigure() {
21572
21594
  const figure = this.getVisibleFigures().find((fig) => fig.id === this.dnd.figId);
@@ -25014,6 +25036,9 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
25014
25036
  }
25015
25037
  function convertChartData(chartData) {
25016
25038
  var _a;
25039
+ if (chartData.dataSets.length === 0) {
25040
+ return undefined;
25041
+ }
25017
25042
  const labelRange = (_a = chartData.dataSets[0].label) === null || _a === void 0 ? void 0 : _a.replace(/\$/g, "");
25018
25043
  let dataSets = chartData.dataSets.map((data) => data.range.replace(/\$/g, ""));
25019
25044
  // For doughnut charts, in chartJS first dataset = outer dataset, in excel first dataset = inner dataset
@@ -27485,10 +27510,34 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
27485
27510
  const elements = [...cmd.elements].sort((a, b) => b - a);
27486
27511
  for (const group of groupConsecutive(elements)) {
27487
27512
  if (cmd.dimension === "COL") {
27488
- this.shiftBordersHorizontally(cmd.sheetId, group[group.length - 1] + 1, -group.length);
27513
+ if (group[0] >= this.getters.getNumberCols(cmd.sheetId)) {
27514
+ for (let row = 0; row < this.getters.getNumberRows(cmd.sheetId); row++) {
27515
+ this.history.update("borders", cmd.sheetId, group[0] + 1, row, "vertical", undefined);
27516
+ }
27517
+ }
27518
+ if (group[group.length - 1] === 0) {
27519
+ for (let row = 0; row < this.getters.getNumberRows(cmd.sheetId); row++) {
27520
+ this.history.update("borders", cmd.sheetId, 0, row, "vertical", undefined);
27521
+ }
27522
+ }
27523
+ const zone = this.getters.getColsZone(cmd.sheetId, group[group.length - 1] + 1, group[0]);
27524
+ this.clearInsideBorders(cmd.sheetId, [zone]);
27525
+ this.shiftBordersHorizontally(cmd.sheetId, group[0] + 1, -group.length);
27489
27526
  }
27490
27527
  else {
27491
- this.shiftBordersVertically(cmd.sheetId, group[group.length - 1] + 1, -group.length);
27528
+ if (group[0] >= this.getters.getNumberRows(cmd.sheetId)) {
27529
+ for (let col = 0; col < this.getters.getNumberCols(cmd.sheetId); col++) {
27530
+ this.history.update("borders", cmd.sheetId, col, group[0] + 1, "horizontal", undefined);
27531
+ }
27532
+ }
27533
+ if (group[group.length - 1] === 0) {
27534
+ for (let col = 0; col < this.getters.getNumberCols(cmd.sheetId); col++) {
27535
+ this.history.update("borders", cmd.sheetId, col, 0, "horizontal", undefined);
27536
+ }
27537
+ }
27538
+ const zone = this.getters.getRowsZone(cmd.sheetId, group[group.length - 1] + 1, group[0]);
27539
+ this.clearInsideBorders(cmd.sheetId, [zone]);
27540
+ this.shiftBordersVertically(cmd.sheetId, group[0] + 1, -group.length);
27492
27541
  }
27493
27542
  }
27494
27543
  break;
@@ -27783,6 +27832,18 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
27783
27832
  }
27784
27833
  }
27785
27834
  }
27835
+ /**
27836
+ * Remove the borders inside of a zone
27837
+ */
27838
+ clearInsideBorders(sheetId, zones) {
27839
+ for (let zone of zones) {
27840
+ for (let row = zone.top; row <= zone.bottom; row++) {
27841
+ for (let col = zone.left; col <= zone.right; col++) {
27842
+ this.history.update("borders", sheetId, col, row, undefined);
27843
+ }
27844
+ }
27845
+ }
27846
+ }
27786
27847
  /**
27787
27848
  * Add a border to the existing one to a cell
27788
27849
  */
@@ -27935,7 +27996,6 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
27935
27996
  }
27936
27997
  BordersPlugin.getters = ["getCellBorder"];
27937
27998
 
27938
- const nbspRegexp = new RegExp(String.fromCharCode(160), "g");
27939
27999
  const LINK_STYLE = { textColor: LINK_COLOR };
27940
28000
  /**
27941
28001
  * Core Plugin
@@ -28269,13 +28329,10 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
28269
28329
  return id;
28270
28330
  }
28271
28331
  updateCell(sheetId, col, row, after) {
28272
- var _a;
28273
28332
  const before = this.getters.getCell(sheetId, col, row);
28274
28333
  const hasContent = "content" in after || "formula" in after;
28275
28334
  // Compute the new cell properties
28276
- const afterContent = hasContent
28277
- ? ((_a = after.content) === null || _a === void 0 ? void 0 : _a.replace(nbspRegexp, "")) || ""
28278
- : (before === null || before === void 0 ? void 0 : before.content) || "";
28335
+ const afterContent = (hasContent ? after.content : before === null || before === void 0 ? void 0 : before.content) || "";
28279
28336
  let style;
28280
28337
  if (after.style !== undefined) {
28281
28338
  style = after.style || undefined;
@@ -37159,6 +37216,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
37159
37216
  break;
37160
37217
  case "DELETE_SHEET":
37161
37218
  this.cleanViewports();
37219
+ this.sheetsWithDirtyViewports.delete(cmd.sheetId);
37162
37220
  break;
37163
37221
  case "ACTIVATE_SHEET":
37164
37222
  this.setViewports();
@@ -37511,6 +37569,9 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
37511
37569
  };
37512
37570
  }
37513
37571
  resetViewports(sheetId) {
37572
+ if (!this.getters.tryGetSheet(sheetId)) {
37573
+ return;
37574
+ }
37514
37575
  const { xSplit, ySplit } = this.getters.getPaneDivisions(sheetId);
37515
37576
  const nCols = this.getters.getNumberCols(sheetId);
37516
37577
  const nRows = this.getters.getNumberRows(sheetId);
@@ -43461,9 +43522,9 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
43461
43522
  Object.defineProperty(exports, '__esModule', { value: true });
43462
43523
 
43463
43524
 
43464
- __info__.version = '16.0.55';
43465
- __info__.date = '2024-11-13T15:02:56.109Z';
43466
- __info__.hash = '6984990';
43525
+ __info__.version = '16.0.57';
43526
+ __info__.date = '2025-01-14T11:28:51.212Z';
43527
+ __info__.hash = '5c7bf6e';
43467
43528
 
43468
43529
 
43469
43530
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);