@odoo/o-spreadsheet 16.0.37 → 16.0.39

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.
@@ -1080,7 +1080,7 @@
1080
1080
  if (typeof o1 !== typeof o2)
1081
1081
  return false;
1082
1082
  if (typeof o1 !== "object")
1083
- return o1 === o2;
1083
+ return false;
1084
1084
  // Objects can have different keys if the values are undefined
1085
1085
  const keys = new Set();
1086
1086
  Object.keys(o1).forEach((key) => keys.add(key));
@@ -4710,6 +4710,7 @@
4710
4710
  if (this.state.link.url) {
4711
4711
  this.save();
4712
4712
  }
4713
+ ev.preventDefault();
4713
4714
  break;
4714
4715
  case "Escape":
4715
4716
  this.cancel();
@@ -24689,29 +24690,12 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
24689
24690
  return width;
24690
24691
  return Math.round((width / WIDTH_FACTOR) * 100) / 100;
24691
24692
  }
24692
- function convertBorderDescr(descr) {
24693
- if (!descr) {
24694
- return undefined;
24695
- }
24696
- return {
24697
- style: descr[0],
24698
- color: { rgb: descr[1] },
24699
- };
24700
- }
24701
24693
  function extractStyle(cell, data) {
24702
24694
  let style = {};
24703
24695
  if (cell.style) {
24704
24696
  style = data.styles[cell.style];
24705
24697
  }
24706
24698
  const format = extractFormat(cell, data);
24707
- const exportedBorder = {};
24708
- if (cell.border) {
24709
- const border = data.borders[cell.border];
24710
- exportedBorder.left = convertBorderDescr(border.left);
24711
- exportedBorder.right = convertBorderDescr(border.right);
24712
- exportedBorder.bottom = convertBorderDescr(border.bottom);
24713
- exportedBorder.top = convertBorderDescr(border.top);
24714
- }
24715
24699
  const styles = {
24716
24700
  font: {
24717
24701
  size: (style === null || style === void 0 ? void 0 : style.fontSize) || DEFAULT_FONT_SIZE,
@@ -24725,7 +24709,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
24725
24709
  }
24726
24710
  : { reservedAttribute: "none" },
24727
24711
  numFmt: format ? { format: format, id: 0 /* id not used for export */ } : undefined,
24728
- border: exportedBorder || {},
24712
+ border: cell.border || 0,
24729
24713
  alignment: {
24730
24714
  vertical: "center",
24731
24715
  horizontal: style.align,
@@ -24754,23 +24738,19 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
24754
24738
  return undefined;
24755
24739
  }
24756
24740
  function normalizeStyle(construct, styles) {
24757
- const { id: fontId } = pushElement(styles["font"], construct.fonts);
24758
- const { id: fillId } = pushElement(styles["fill"], construct.fills);
24759
- const { id: borderId } = pushElement(styles["border"], construct.borders);
24760
24741
  // Normalize this
24761
24742
  const numFmtId = convertFormat(styles["numFmt"], construct.numFmts);
24762
24743
  const style = {
24763
- fontId,
24764
- fillId,
24765
- borderId,
24744
+ fontId: pushElement(styles.font, construct.fonts),
24745
+ fillId: pushElement(styles.fill, construct.fills),
24746
+ borderId: styles.border,
24766
24747
  numFmtId,
24767
24748
  alignment: {
24768
24749
  vertical: styles.alignment.vertical,
24769
24750
  horizontal: styles.alignment.horizontal,
24770
24751
  },
24771
24752
  };
24772
- const { id } = pushElement(style, construct.styles);
24773
- return id;
24753
+ return pushElement(style, construct.styles);
24774
24754
  }
24775
24755
  function convertFormat(format, numFmtStructure) {
24776
24756
  if (!format) {
@@ -24778,8 +24758,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
24778
24758
  }
24779
24759
  let formatId = XLSX_FORMAT_MAP[format.format];
24780
24760
  if (!formatId) {
24781
- const { id } = pushElement(format, numFmtStructure);
24782
- formatId = id + FIRST_NUMFMT_ID;
24761
+ formatId = pushElement(format, numFmtStructure) + FIRST_NUMFMT_ID;
24783
24762
  }
24784
24763
  return formatId;
24785
24764
  }
@@ -24804,20 +24783,15 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
24804
24783
  return id;
24805
24784
  }
24806
24785
  function pushElement(property, propertyList) {
24807
- for (let [key, value] of Object.entries(propertyList)) {
24808
- if (JSON.stringify(value) === JSON.stringify(property)) {
24809
- return { id: parseInt(key, 10), list: propertyList };
24786
+ let len = propertyList.length;
24787
+ const operator = typeof property === "object" ? deepEquals : (a, b) => a === b;
24788
+ for (let i = 0; i < len; i++) {
24789
+ if (operator(property, propertyList[i])) {
24790
+ return i;
24810
24791
  }
24811
24792
  }
24812
- let elemId = propertyList.findIndex((elem) => JSON.stringify(elem) === JSON.stringify(property));
24813
- if (elemId === -1) {
24814
- propertyList.push(property);
24815
- elemId = propertyList.length - 1;
24816
- }
24817
- return {
24818
- id: elemId,
24819
- list: propertyList,
24820
- };
24793
+ propertyList[propertyList.length] = property;
24794
+ return propertyList.length - 1;
24821
24795
  }
24822
24796
  const chartIds = [];
24823
24797
  /**
@@ -25491,7 +25465,25 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
25491
25465
  }
25492
25466
  return document;
25493
25467
  }
25494
- function getDefaultXLSXStructure() {
25468
+ function convertBorderDescr(descr) {
25469
+ if (!descr) {
25470
+ return undefined;
25471
+ }
25472
+ return {
25473
+ style: descr[0],
25474
+ color: { rgb: descr[1] },
25475
+ };
25476
+ }
25477
+ function getDefaultXLSXStructure(data) {
25478
+ const xlsxBorders = Object.values(data.borders).map((border) => {
25479
+ return {
25480
+ left: convertBorderDescr(border.left),
25481
+ right: convertBorderDescr(border.right),
25482
+ bottom: convertBorderDescr(border.bottom),
25483
+ top: convertBorderDescr(border.top),
25484
+ };
25485
+ });
25486
+ const borders = [{}, ...xlsxBorders];
25495
25487
  return {
25496
25488
  relsFiles: [],
25497
25489
  sharedStrings: [],
@@ -25514,7 +25506,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
25514
25506
  },
25515
25507
  ],
25516
25508
  fills: [{ reservedAttribute: "none" }, { reservedAttribute: "gray125" }],
25517
- borders: [{}],
25509
+ borders,
25518
25510
  numFmts: [],
25519
25511
  dxfs: [],
25520
25512
  };
@@ -36993,12 +36985,13 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
36993
36985
  case "AlterZoneCorner":
36994
36986
  break;
36995
36987
  case "ZonesSelected":
36988
+ const sheetId = this.getters.getActiveSheetId();
36996
36989
  let { col, row } = findCellInNewZone(event.previousAnchor.zone, event.anchor.zone);
36997
36990
  if (event.mode === "updateAnchor") {
36998
36991
  const oldZone = event.previousAnchor.zone;
36999
36992
  const newZone = event.anchor.zone;
37000
36993
  // altering a zone should not move the viewport in a dimension that wasn't changed
37001
- const { top, bottom, left, right } = this.getters.getActiveMainViewport();
36994
+ const { top, bottom, left, right } = this.getMainInternalViewport(sheetId);
37002
36995
  if (oldZone.left === newZone.left && oldZone.right === newZone.right) {
37003
36996
  col = left > col || col > right ? left : col;
37004
36997
  }
@@ -37006,10 +36999,9 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
37006
36999
  row = top > row || row > bottom ? top : row;
37007
37000
  }
37008
37001
  }
37009
- const sheetId = this.getters.getActiveSheetId();
37010
37002
  col = Math.min(col, this.getters.getNumberCols(sheetId) - 1);
37011
37003
  row = Math.min(row, this.getters.getNumberRows(sheetId) - 1);
37012
- this.refreshViewport(this.getters.getActiveSheetId(), { col, row });
37004
+ this.refreshViewport(sheetId, { col, row });
37013
37005
  break;
37014
37006
  }
37015
37007
  }
@@ -37034,16 +37026,16 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
37034
37026
  this.setSheetViewOffset(cmd.offsetX, cmd.offsetY);
37035
37027
  break;
37036
37028
  case "SHIFT_VIEWPORT_DOWN":
37037
- const { top } = this.getActiveMainViewport();
37038
37029
  const sheetId = this.getters.getActiveSheetId();
37039
- const shiftedOffsetY = this.clipOffsetY(this.getters.getRowDimensions(sheetId, top).start + this.sheetViewHeight);
37040
- this.shiftVertically(shiftedOffsetY);
37030
+ const { top, viewportHeight, offsetCorrectionY } = this.getMainInternalViewport(sheetId);
37031
+ const topRowDims = this.getters.getRowDimensions(sheetId, top);
37032
+ this.shiftVertically(topRowDims.start + viewportHeight - offsetCorrectionY);
37041
37033
  break;
37042
37034
  case "SHIFT_VIEWPORT_UP": {
37043
- const { top } = this.getActiveMainViewport();
37044
37035
  const sheetId = this.getters.getActiveSheetId();
37045
- const shiftedOffsetY = this.clipOffsetY(this.getters.getRowDimensions(sheetId, top).end - this.sheetViewHeight);
37046
- this.shiftVertically(shiftedOffsetY);
37036
+ const { top, viewportHeight, offsetCorrectionY } = this.getMainInternalViewport(sheetId);
37037
+ const topRowDims = this.getters.getRowDimensions(sheetId, top);
37038
+ this.shiftVertically(topRowDims.end - offsetCorrectionY - viewportHeight);
37047
37039
  break;
37048
37040
  }
37049
37041
  case "REMOVE_COLUMNS_ROWS":
@@ -37402,17 +37394,6 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
37402
37394
  const { maxOffsetX, maxOffsetY } = this.getMaximumSheetOffset();
37403
37395
  Object.values(this.getSubViewports(sheetId)).forEach((viewport) => viewport.setViewportOffset(clip(offsetX, 0, maxOffsetX), clip(offsetY, 0, maxOffsetY)));
37404
37396
  }
37405
- /**
37406
- * Clip the vertical offset within the allowed range.
37407
- * Not above the sheet, nor below the sheet.
37408
- */
37409
- clipOffsetY(offsetY) {
37410
- const { height } = this.getMainViewportRect();
37411
- const maxOffset = height - this.sheetViewHeight;
37412
- offsetY = Math.min(offsetY, maxOffset);
37413
- offsetY = Math.max(offsetY, 0);
37414
- return offsetY;
37415
- }
37416
37397
  getViewportOffset(sheetId) {
37417
37398
  var _a, _b;
37418
37399
  return {
@@ -37466,12 +37447,15 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
37466
37447
  * viewport top.
37467
37448
  */
37468
37449
  shiftVertically(offset) {
37469
- const { top } = this.getActiveMainViewport();
37450
+ const sheetId = this.getters.getActiveSheetId();
37451
+ const { top } = this.getMainInternalViewport(sheetId);
37470
37452
  const { scrollX } = this.getActiveSheetScrollInfo();
37471
37453
  this.setSheetViewOffset(scrollX, offset);
37472
37454
  const { anchor } = this.getters.getSelection();
37473
- const deltaRow = this.getActiveMainViewport().top - top;
37474
- this.selection.selectCell(anchor.cell.col, anchor.cell.row + deltaRow);
37455
+ if (anchor.cell.row >= this.getters.getPaneDivisions(sheetId).ySplit) {
37456
+ const deltaRow = this.getMainInternalViewport(sheetId).top - top;
37457
+ this.selection.selectCell(anchor.cell.col, anchor.cell.row + deltaRow);
37458
+ }
37475
37459
  }
37476
37460
  getVisibleFigures() {
37477
37461
  const sheetId = this.getters.getActiveSheetId();
@@ -41791,8 +41775,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
41791
41775
  attrs.push(["t", "b"]);
41792
41776
  }
41793
41777
  else if (forceString || !isNumber(value)) {
41794
- const { id } = pushElement(content, sharedStrings);
41795
- value = id.toString();
41778
+ value = pushElement(content, sharedStrings);
41796
41779
  attrs.push(["t", "s"]);
41797
41780
  }
41798
41781
  return { attrs, node: escapeXml /*xml*/ `<v>${value}</v>` };
@@ -41917,8 +41900,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
41917
41900
  if (rule.style.fillColor) {
41918
41901
  dxf.fill = { fgColor: { rgb: rule.style.fillColor } };
41919
41902
  }
41920
- const { id } = pushElement(dxf, dxfs);
41921
- ruleAttributes.push(["dxfId", id]);
41903
+ ruleAttributes.push(["dxfId", pushElement(dxf, dxfs)]);
41922
41904
  return escapeXml /*xml*/ `
41923
41905
  <conditionalFormatting sqref="${cf.ranges.join(" ")}">
41924
41906
  <cfRule ${formatAttributes(ruleAttributes)}>
@@ -42629,7 +42611,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
42629
42611
  */
42630
42612
  function getXLSX(data) {
42631
42613
  const files = [];
42632
- const construct = getDefaultXLSXStructure();
42614
+ const construct = getDefaultXLSXStructure(data);
42633
42615
  files.push(createWorkbook(data, construct));
42634
42616
  files.push(...createWorksheets(data, construct));
42635
42617
  files.push(createStylesSheet(construct));
@@ -43339,9 +43321,9 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
43339
43321
  Object.defineProperty(exports, '__esModule', { value: true });
43340
43322
 
43341
43323
 
43342
- __info__.version = '16.0.37';
43343
- __info__.date = '2024-04-05T13:58:08.848Z';
43344
- __info__.hash = 'e95827b';
43324
+ __info__.version = '16.0.39';
43325
+ __info__.date = '2024-04-18T16:36:36.901Z';
43326
+ __info__.hash = 'ea5a526';
43345
43327
 
43346
43328
 
43347
43329
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);