@odoo/o-spreadsheet 17.1.10 → 17.1.11

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.
@@ -2,9 +2,9 @@
2
2
  /**
3
3
  * This file is generated by o-spreadsheet build tools. Do not edit it.
4
4
  * @see https://github.com/odoo/o-spreadsheet
5
- * @version 17.1.10
6
- * @date 2024-04-05T14:00:03.890Z
7
- * @hash edc821c
5
+ * @version 17.1.11
6
+ * @date 2024-04-10T12:27:11.107Z
7
+ * @hash 246caf7
8
8
  */
9
9
 
10
10
  (function (exports, owl) {
@@ -550,7 +550,7 @@
550
550
  if (typeof o1 !== typeof o2)
551
551
  return false;
552
552
  if (typeof o1 !== "object")
553
- return o1 === o2;
553
+ return false;
554
554
  // Objects can have different keys if the values are undefined
555
555
  for (const key in o2) {
556
556
  if (!(key in o1) && o2[key] !== undefined) {
@@ -8464,7 +8464,7 @@
8464
8464
  const xLabel = tooltipItem.dataset?.label || tooltipItem.label;
8465
8465
  // tooltipItem.parsed.y can be an object or a number for pie charts
8466
8466
  const yLabel = tooltipItem.parsed.y ?? tooltipItem.parsed;
8467
- const toolTipFormat = !format && yLabel > 1000 ? "#,##" : format;
8467
+ const toolTipFormat = !format && Math.abs(yLabel) >= 1000 ? "#,##" : format;
8468
8468
  const yLabelStr = formatValue(yLabel, { format: toolTipFormat, locale });
8469
8469
  return xLabel ? `${xLabel}: ${yLabelStr}` : yLabelStr;
8470
8470
  },
@@ -8751,7 +8751,10 @@
8751
8751
  if (isNaN(value))
8752
8752
  return value;
8753
8753
  const { locale, format } = localeFormat;
8754
- return formatValue(value, { locale, format: !format && value > 1000 ? "#,##" : format });
8754
+ return formatValue(value, {
8755
+ locale,
8756
+ format: !format && Math.abs(value) >= 1000 ? "#,##" : format,
8757
+ });
8755
8758
  },
8756
8759
  },
8757
8760
  },
@@ -9402,7 +9405,10 @@
9402
9405
  if (isNaN(value))
9403
9406
  return value;
9404
9407
  const { locale, format } = localeFormat;
9405
- return formatValue(value, { locale, format: !format && value > 1000 ? "#,##" : format });
9408
+ return formatValue(value, {
9409
+ locale,
9410
+ format: !format && Math.abs(value) >= 1000 ? "#,##" : format,
9411
+ });
9406
9412
  },
9407
9413
  },
9408
9414
  },
@@ -9629,7 +9635,7 @@
9629
9635
  const percentage = calculatePercentage(data, dataIndex);
9630
9636
  const xLabel = tooltipItem.label || tooltipItem.dataset.label;
9631
9637
  const yLabel = tooltipItem.parsed.y ?? tooltipItem.parsed;
9632
- const toolTipFormat = !format && yLabel > 1000 ? "#,##" : format;
9638
+ const toolTipFormat = !format && yLabel >= 1000 ? "#,##" : format;
9633
9639
  const yLabelStr = formatValue(yLabel, { format: toolTipFormat, locale });
9634
9640
  return xLabel ? `${xLabel}: ${yLabelStr} (${percentage}%)` : `${yLabelStr} (${percentage}%)`;
9635
9641
  };
@@ -27102,6 +27108,7 @@
27102
27108
  onComposerCellFocused: { type: Function, optional: true },
27103
27109
  onComposerContentFocused: Function,
27104
27110
  isDefaultFocus: { type: Boolean, optional: true },
27111
+ onInputContextMenu: { type: Function, optional: true },
27105
27112
  };
27106
27113
  static components = { TextValueProvider, FunctionDescriptionProvider };
27107
27114
  static defaultProps = {
@@ -27460,6 +27467,11 @@
27460
27467
  }
27461
27468
  }
27462
27469
  }
27470
+ onContextMenu(ev) {
27471
+ if (this.env.model.getters.getEditionMode() === "inactive") {
27472
+ this.props.onInputContextMenu?.(ev);
27473
+ }
27474
+ }
27463
27475
  // ---------------------------------------------------------------------------
27464
27476
  // Private
27465
27477
  // ---------------------------------------------------------------------------
@@ -27727,6 +27739,7 @@
27727
27739
  onComposerCellFocused: Function,
27728
27740
  onComposerContentFocused: Function,
27729
27741
  gridDims: Object,
27742
+ onInputContextMenu: Function,
27730
27743
  };
27731
27744
  static components = { Composer };
27732
27745
  rect = this.defaultRect;
@@ -27771,6 +27784,7 @@
27771
27784
  isDefaultFocus: true,
27772
27785
  onComposerContentFocused: this.props.onComposerContentFocused,
27773
27786
  onComposerCellFocused: this.props.onComposerCellFocused,
27787
+ onInputContextMenu: this.props.onInputContextMenu,
27774
27788
  };
27775
27789
  }
27776
27790
  get containerStyle() {
@@ -31768,29 +31782,12 @@
31768
31782
  return width;
31769
31783
  return Math.round((width / WIDTH_FACTOR) * 100) / 100;
31770
31784
  }
31771
- function convertBorderDescr(descr) {
31772
- if (!descr) {
31773
- return undefined;
31774
- }
31775
- return {
31776
- style: descr.style,
31777
- color: { rgb: descr.color },
31778
- };
31779
- }
31780
31785
  function extractStyle(cell, data) {
31781
31786
  let style = {};
31782
31787
  if (cell.style) {
31783
31788
  style = data.styles[cell.style];
31784
31789
  }
31785
31790
  const format = extractFormat(cell, data);
31786
- const exportedBorder = {};
31787
- if (cell.border) {
31788
- const border = data.borders[cell.border];
31789
- exportedBorder.left = convertBorderDescr(border.left);
31790
- exportedBorder.right = convertBorderDescr(border.right);
31791
- exportedBorder.bottom = convertBorderDescr(border.bottom);
31792
- exportedBorder.top = convertBorderDescr(border.top);
31793
- }
31794
31791
  const styles = {
31795
31792
  font: {
31796
31793
  size: style?.fontSize || DEFAULT_FONT_SIZE,
@@ -31804,7 +31801,7 @@
31804
31801
  }
31805
31802
  : { reservedAttribute: "none" },
31806
31803
  numFmt: format ? { format: format, id: 0 /* id not used for export */ } : undefined,
31807
- border: exportedBorder || {},
31804
+ border: cell.border || 0,
31808
31805
  alignment: {
31809
31806
  horizontal: style.align,
31810
31807
  vertical: style.verticalAlign
@@ -31826,15 +31823,12 @@
31826
31823
  return undefined;
31827
31824
  }
31828
31825
  function normalizeStyle(construct, styles) {
31829
- const { id: fontId } = pushElement(styles["font"], construct.fonts);
31830
- const { id: fillId } = pushElement(styles["fill"], construct.fills);
31831
- const { id: borderId } = pushElement(styles["border"], construct.borders);
31832
31826
  // Normalize this
31833
31827
  const numFmtId = convertFormat(styles["numFmt"], construct.numFmts);
31834
31828
  const style = {
31835
- fontId,
31836
- fillId,
31837
- borderId,
31829
+ fontId: pushElement(styles.font, construct.fonts),
31830
+ fillId: pushElement(styles.fill, construct.fills),
31831
+ borderId: styles.border,
31838
31832
  numFmtId,
31839
31833
  alignment: {
31840
31834
  vertical: styles.alignment.vertical,
@@ -31842,8 +31836,7 @@
31842
31836
  wrapText: styles.alignment.wrapText,
31843
31837
  },
31844
31838
  };
31845
- const { id } = pushElement(style, construct.styles);
31846
- return id;
31839
+ return pushElement(style, construct.styles);
31847
31840
  }
31848
31841
  function convertFormat(format, numFmtStructure) {
31849
31842
  if (!format) {
@@ -31851,8 +31844,7 @@
31851
31844
  }
31852
31845
  let formatId = XLSX_FORMAT_MAP[format.format];
31853
31846
  if (!formatId) {
31854
- const { id } = pushElement(format, numFmtStructure);
31855
- formatId = id + FIRST_NUMFMT_ID;
31847
+ formatId = pushElement(format, numFmtStructure) + FIRST_NUMFMT_ID;
31856
31848
  }
31857
31849
  return formatId;
31858
31850
  }
@@ -31877,20 +31869,15 @@
31877
31869
  return id;
31878
31870
  }
31879
31871
  function pushElement(property, propertyList) {
31880
- for (let [key, value] of Object.entries(propertyList)) {
31881
- if (JSON.stringify(value) === JSON.stringify(property)) {
31882
- return { id: parseInt(key, 10), list: propertyList };
31872
+ let len = propertyList.length;
31873
+ const operator = typeof property === "object" ? deepEquals : (a, b) => a === b;
31874
+ for (let i = 0; i < len; i++) {
31875
+ if (operator(property, propertyList[i])) {
31876
+ return i;
31883
31877
  }
31884
31878
  }
31885
- let elemId = propertyList.findIndex((elem) => JSON.stringify(elem) === JSON.stringify(property));
31886
- if (elemId === -1) {
31887
- propertyList.push(property);
31888
- elemId = propertyList.length - 1;
31889
- }
31890
- return {
31891
- id: elemId,
31892
- list: propertyList,
31893
- };
31879
+ propertyList[propertyList.length] = property;
31880
+ return propertyList.length - 1;
31894
31881
  }
31895
31882
  const chartIds = [];
31896
31883
  /**
@@ -32617,7 +32604,25 @@
32617
32604
  }
32618
32605
  return document;
32619
32606
  }
32620
- function getDefaultXLSXStructure() {
32607
+ function convertBorderDescr(descr) {
32608
+ if (!descr) {
32609
+ return undefined;
32610
+ }
32611
+ return {
32612
+ style: descr.style,
32613
+ color: { rgb: descr.color },
32614
+ };
32615
+ }
32616
+ function getDefaultXLSXStructure(data) {
32617
+ const xlsxBorders = Object.values(data.borders).map((border) => {
32618
+ return {
32619
+ left: convertBorderDescr(border.left),
32620
+ right: convertBorderDescr(border.right),
32621
+ bottom: convertBorderDescr(border.bottom),
32622
+ top: convertBorderDescr(border.top),
32623
+ };
32624
+ });
32625
+ const borders = [{}, ...xlsxBorders];
32621
32626
  return {
32622
32627
  relsFiles: [],
32623
32628
  sharedStrings: [],
@@ -32640,7 +32645,7 @@
32640
32645
  },
32641
32646
  ],
32642
32647
  fills: [{ reservedAttribute: "none" }, { reservedAttribute: "gray125" }],
32643
- borders: [{}],
32648
+ borders,
32644
32649
  numFmts: [],
32645
32650
  dxfs: [],
32646
32651
  };
@@ -37836,7 +37841,17 @@
37836
37841
  }
37837
37842
  }
37838
37843
  exportForExcel(data) {
37839
- this.export(data);
37844
+ for (const sheet of data.sheets) {
37845
+ for (const filterTable of this.getFilterTables(sheet.id)) {
37846
+ if (zoneToDimension(filterTable.zone).numberOfRows === 1) {
37847
+ continue;
37848
+ }
37849
+ sheet.filterTables.push({
37850
+ range: zoneToXc(filterTable.zone),
37851
+ filters: [],
37852
+ });
37853
+ }
37854
+ }
37840
37855
  }
37841
37856
  }
37842
37857
 
@@ -41556,7 +41571,9 @@
41556
41571
  this.blockedArrayFormulas = new Set();
41557
41572
  this.spreadingRelations = new SpreadingRelation();
41558
41573
  this.formulaDependencies = lazy(() => {
41559
- const dependencies = [...this.getAllCells()].flatMap((positionId) => this.getDirectDependencies(positionId).map((range) => ({
41574
+ const dependencies = [...this.getAllCells()].flatMap((positionId) => this.getDirectDependencies(positionId)
41575
+ .filter((range) => !range.invalidSheetName && !range.invalidXc)
41576
+ .map((range) => ({
41560
41577
  data: positionId,
41561
41578
  boundingBox: {
41562
41579
  zone: range.zone,
@@ -55530,8 +55547,7 @@
55530
55547
  attrs.push(["t", "b"]);
55531
55548
  }
55532
55549
  else if (forceString || !isNumber(value, DEFAULT_LOCALE)) {
55533
- const { id } = pushElement(content, sharedStrings);
55534
- value = id.toString();
55550
+ value = pushElement(content, sharedStrings);
55535
55551
  attrs.push(["t", "s"]);
55536
55552
  }
55537
55553
  return { attrs, node: escapeXml /*xml*/ `<v>${value}</v>` };
@@ -55656,8 +55672,7 @@
55656
55672
  if (rule.style.fillColor) {
55657
55673
  dxf.fill = { fgColor: { rgb: rule.style.fillColor } };
55658
55674
  }
55659
- const { id } = pushElement(dxf, dxfs);
55660
- ruleAttributes.push(["dxfId", id]);
55675
+ ruleAttributes.push(["dxfId", pushElement(dxf, dxfs)]);
55661
55676
  return escapeXml /*xml*/ `
55662
55677
  <conditionalFormatting sqref="${cf.ranges.join(" ")}">
55663
55678
  <cfRule ${formatAttributes(ruleAttributes)}>
@@ -56467,7 +56482,7 @@
56467
56482
  */
56468
56483
  function getXLSX(data) {
56469
56484
  const files = [];
56470
- const construct = getDefaultXLSXStructure();
56485
+ const construct = getDefaultXLSXStructure(data);
56471
56486
  files.push(createWorkbook(data, construct));
56472
56487
  files.push(...createWorksheets(data, construct));
56473
56488
  files.push(createStylesSheet(construct));
@@ -57356,9 +57371,9 @@
57356
57371
  exports.tokenize = tokenize;
57357
57372
 
57358
57373
 
57359
- __info__.version = "17.1.10";
57360
- __info__.date = "2024-04-05T14:00:03.890Z";
57361
- __info__.hash = "edc821c";
57374
+ __info__.version = "17.1.11";
57375
+ __info__.date = "2024-04-10T12:27:11.107Z";
57376
+ __info__.hash = "246caf7";
57362
57377
 
57363
57378
 
57364
57379
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);