@odoo/o-spreadsheet 16.2.7 → 16.2.9

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.
@@ -1723,27 +1723,36 @@
1723
1723
  }
1724
1724
  return numberString.slice(0, i + 1) || undefined;
1725
1725
  }
1726
+ const leadingZeroesRegexp = /^0+/;
1726
1727
  /**
1727
1728
  * Limit the size of the decimal part of a number to the given number of digits.
1728
1729
  */
1729
1730
  function limitDecimalDigits(decimalDigits, maxDecimals) {
1731
+ var _a;
1730
1732
  let integerDigits = "0";
1731
1733
  let resultDecimalDigits = decimalDigits;
1732
1734
  // Note : we'd want to simply use number.toFixed() to handle the max digits & rounding,
1733
1735
  // but it has very strange behaviour. Ex: 12.345.toFixed(2) => "12.35", but 1.345.toFixed(2) => "1.34"
1734
1736
  let slicedDecimalDigits = decimalDigits.slice(0, maxDecimals);
1735
1737
  const i = maxDecimals;
1736
- if (Number(Number(decimalDigits[i]) < 5)) {
1738
+ if (Number(decimalDigits[i]) < 5) {
1737
1739
  return { integerDigits, decimalDigits: slicedDecimalDigits };
1738
1740
  }
1739
1741
  // round up
1742
+ const leadingZeroes = ((_a = slicedDecimalDigits.match(leadingZeroesRegexp)) === null || _a === void 0 ? void 0 : _a[0]) || "";
1740
1743
  const slicedRoundedUp = (Number(slicedDecimalDigits) + 1).toString();
1741
- if (slicedRoundedUp.length > slicedDecimalDigits.length) {
1742
- integerDigits = (Number(integerDigits) + 1).toString();
1744
+ const withoutLeadingZeroes = slicedDecimalDigits.slice(leadingZeroes.length);
1745
+ // e.g. carry over from 99 to 100
1746
+ const carryOver = slicedRoundedUp.length > withoutLeadingZeroes.length;
1747
+ if (carryOver && !leadingZeroes) {
1748
+ integerDigits = "1";
1743
1749
  resultDecimalDigits = undefined;
1744
1750
  }
1751
+ else if (carryOver) {
1752
+ resultDecimalDigits = leadingZeroes.slice(0, -1) + slicedRoundedUp;
1753
+ }
1745
1754
  else {
1746
- resultDecimalDigits = slicedRoundedUp;
1755
+ resultDecimalDigits = leadingZeroes + slicedRoundedUp;
1747
1756
  }
1748
1757
  return { integerDigits, decimalDigits: resultDecimalDigits };
1749
1758
  }
@@ -16860,7 +16869,7 @@
16860
16869
  return !!((_a = this.state.labelsDispatchResult) === null || _a === void 0 ? void 0 : _a.isCancelledBecause(33 /* CommandResult.InvalidLabelRange */));
16861
16870
  }
16862
16871
  onUpdateDataSetsHaveTitle(ev) {
16863
- this.props.updateChart({
16872
+ this.props.updateChart(this.props.figureId, {
16864
16873
  dataSetsHaveTitle: ev.target.checked,
16865
16874
  });
16866
16875
  }
@@ -16872,7 +16881,7 @@
16872
16881
  this.dataSeriesRanges = ranges;
16873
16882
  }
16874
16883
  onDataSeriesConfirmed() {
16875
- this.state.datasetDispatchResult = this.props.updateChart({
16884
+ this.state.datasetDispatchResult = this.props.updateChart(this.props.figureId, {
16876
16885
  dataSets: this.dataSeriesRanges,
16877
16886
  });
16878
16887
  }
@@ -16884,12 +16893,12 @@
16884
16893
  this.labelRange = ranges[0];
16885
16894
  }
16886
16895
  onLabelRangeConfirmed() {
16887
- this.state.labelsDispatchResult = this.props.updateChart({
16896
+ this.state.labelsDispatchResult = this.props.updateChart(this.props.figureId, {
16888
16897
  labelRange: this.labelRange,
16889
16898
  });
16890
16899
  }
16891
16900
  onUpdateAggregated(ev) {
16892
- this.props.updateChart({
16901
+ this.props.updateChart(this.props.figureId, {
16893
16902
  aggregated: ev.target.checked,
16894
16903
  });
16895
16904
  }
@@ -16904,12 +16913,12 @@
16904
16913
 
16905
16914
  class BarConfigPanel extends LineBarPieConfigPanel {
16906
16915
  onUpdateStacked(ev) {
16907
- this.props.updateChart({
16916
+ this.props.updateChart(this.props.figureId, {
16908
16917
  stacked: ev.target.checked,
16909
16918
  });
16910
16919
  }
16911
16920
  onUpdateAggregated(ev) {
16912
- this.props.updateChart({
16921
+ this.props.updateChart(this.props.figureId, {
16913
16922
  aggregated: ev.target.checked,
16914
16923
  });
16915
16924
  }
@@ -16950,6 +16959,7 @@
16950
16959
  .o-color-picker-toggler {
16951
16960
  display: flex;
16952
16961
  .o-color-picker-toggler-sign {
16962
+ display: flex;
16953
16963
  margin: auto auto;
16954
16964
  width: 55%;
16955
16965
  height: 55%;
@@ -17252,17 +17262,17 @@
17252
17262
  this.state.fillColorTool = !this.state.fillColorTool;
17253
17263
  }
17254
17264
  updateBackgroundColor(color) {
17255
- this.props.updateChart({
17265
+ this.props.updateChart(this.props.figureId, {
17256
17266
  background: color,
17257
17267
  });
17258
17268
  }
17259
17269
  updateTitle(ev) {
17260
- this.props.updateChart({
17270
+ this.props.updateChart(this.props.figureId, {
17261
17271
  title: ev.target.value,
17262
17272
  });
17263
17273
  }
17264
17274
  updateSelect(attr, ev) {
17265
- this.props.updateChart({
17275
+ this.props.updateChart(this.props.figureId, {
17266
17276
  [attr]: ev.target.value,
17267
17277
  });
17268
17278
  }
@@ -17300,7 +17310,7 @@
17300
17310
  this.dataRange = ranges[0];
17301
17311
  }
17302
17312
  updateDataRange() {
17303
- this.state.dataRangeDispatchResult = this.props.updateChart({
17313
+ this.state.dataRangeDispatchResult = this.props.updateChart(this.props.figureId, {
17304
17314
  dataRange: this.dataRange,
17305
17315
  });
17306
17316
  }
@@ -17362,12 +17372,12 @@
17362
17372
  }
17363
17373
  updateBackgroundColor(color) {
17364
17374
  this.state.openedMenu = undefined;
17365
- this.props.updateChart({
17375
+ this.props.updateChart(this.props.figureId, {
17366
17376
  background: color,
17367
17377
  });
17368
17378
  }
17369
17379
  updateTitle(ev) {
17370
- this.props.updateChart({
17380
+ this.props.updateChart(this.props.figureId, {
17371
17381
  title: ev.target.value,
17372
17382
  });
17373
17383
  }
@@ -17436,7 +17446,7 @@
17436
17446
  }
17437
17447
  }
17438
17448
  updateSectionRule(sectionRule) {
17439
- this.state.sectionRuleDispatchResult = this.props.updateChart({
17449
+ this.state.sectionRuleDispatchResult = this.props.updateChart(this.props.figureId, {
17440
17450
  sectionRule,
17441
17451
  });
17442
17452
  }
@@ -17461,17 +17471,17 @@
17461
17471
  return false;
17462
17472
  }
17463
17473
  onUpdateLabelsAsText(ev) {
17464
- this.props.updateChart({
17474
+ this.props.updateChart(this.props.figureId, {
17465
17475
  labelsAsText: ev.target.checked,
17466
17476
  });
17467
17477
  }
17468
17478
  onUpdateStacked(ev) {
17469
- this.props.updateChart({
17479
+ this.props.updateChart(this.props.figureId, {
17470
17480
  stacked: ev.target.checked,
17471
17481
  });
17472
17482
  }
17473
17483
  onUpdateAggregated(ev) {
17474
- this.props.updateChart({
17484
+ this.props.updateChart(this.props.figureId, {
17475
17485
  aggregated: ev.target.checked,
17476
17486
  });
17477
17487
  }
@@ -17512,7 +17522,7 @@
17512
17522
  this.keyValue = ranges[0];
17513
17523
  }
17514
17524
  updateKeyValueRange() {
17515
- this.state.keyValueDispatchResult = this.props.updateChart({
17525
+ this.state.keyValueDispatchResult = this.props.updateChart(this.props.figureId, {
17516
17526
  keyValue: this.keyValue,
17517
17527
  });
17518
17528
  }
@@ -17520,12 +17530,12 @@
17520
17530
  this.baseline = ranges[0];
17521
17531
  }
17522
17532
  updateBaselineRange() {
17523
- this.state.baselineDispatchResult = this.props.updateChart({
17533
+ this.state.baselineDispatchResult = this.props.updateChart(this.props.figureId, {
17524
17534
  baseline: this.baseline,
17525
17535
  });
17526
17536
  }
17527
17537
  updateBaselineMode(ev) {
17528
- this.props.updateChart({ baselineMode: ev.target.value });
17538
+ this.props.updateChart(this.props.figureId, { baselineMode: ev.target.value });
17529
17539
  }
17530
17540
  }
17531
17541
  ScorecardChartConfigPanel.template = "o-spreadsheet-ScorecardChartConfigPanel";
@@ -17547,12 +17557,12 @@
17547
17557
  owl.useExternalListener(window, "click", this.closeMenus);
17548
17558
  }
17549
17559
  updateTitle(ev) {
17550
- this.props.updateChart({
17560
+ this.props.updateChart(this.props.figureId, {
17551
17561
  title: ev.target.value,
17552
17562
  });
17553
17563
  }
17554
17564
  updateBaselineDescr(ev) {
17555
- this.props.updateChart({ baselineDescr: ev.target.value });
17565
+ this.props.updateChart(this.props.figureId, { baselineDescr: ev.target.value });
17556
17566
  }
17557
17567
  toggleColorPicker(colorPickerId) {
17558
17568
  if (this.state.openedColorPicker === colorPickerId) {
@@ -17565,13 +17575,13 @@
17565
17575
  setColor(color, colorPickerId) {
17566
17576
  switch (colorPickerId) {
17567
17577
  case "backgroundColor":
17568
- this.props.updateChart({ background: color });
17578
+ this.props.updateChart(this.props.figureId, { background: color });
17569
17579
  break;
17570
17580
  case "baselineColorDown":
17571
- this.props.updateChart({ baselineColorDown: color });
17581
+ this.props.updateChart(this.props.figureId, { baselineColorDown: color });
17572
17582
  break;
17573
17583
  case "baselineColorUp":
17574
- this.props.updateChart({ baselineColorUp: color });
17584
+ this.props.updateChart(this.props.figureId, { baselineColorUp: color });
17575
17585
  break;
17576
17586
  }
17577
17587
  this.closeMenus();
@@ -17636,16 +17646,9 @@
17636
17646
  }
17637
17647
  `;
17638
17648
  class ChartPanel extends owl.Component {
17639
- constructor() {
17640
- super(...arguments);
17641
- this.shouldUpdateChart = true;
17642
- }
17643
17649
  get figureId() {
17644
17650
  return this.state.figureId;
17645
17651
  }
17646
- get sheetId() {
17647
- return this.state.sheetId;
17648
- }
17649
17652
  setup() {
17650
17653
  const selectedFigureId = this.env.model.getters.getSelectedFigureId();
17651
17654
  if (!selectedFigureId) {
@@ -17654,17 +17657,11 @@
17654
17657
  this.state = owl.useState({
17655
17658
  panel: "configuration",
17656
17659
  figureId: selectedFigureId,
17657
- sheetId: this.env.model.getters.getActiveSheetId(),
17658
17660
  });
17659
17661
  owl.onWillUpdateProps(() => {
17660
17662
  const selectedFigureId = this.env.model.getters.getSelectedFigureId();
17661
17663
  if (selectedFigureId && selectedFigureId !== this.state.figureId) {
17662
17664
  this.state.figureId = selectedFigureId;
17663
- this.state.sheetId = this.env.model.getters.getActiveSheetId();
17664
- this.shouldUpdateChart = false;
17665
- }
17666
- else {
17667
- this.shouldUpdateChart = true;
17668
17665
  }
17669
17666
  if (!this.env.model.getters.isChartDefined(this.figureId)) {
17670
17667
  this.props.onCloseSidePanel();
@@ -17672,8 +17669,8 @@
17672
17669
  }
17673
17670
  });
17674
17671
  }
17675
- updateChart(updateDefinition) {
17676
- if (!this.shouldUpdateChart) {
17672
+ updateChart(figureId, updateDefinition) {
17673
+ if (figureId !== this.figureId) {
17677
17674
  return;
17678
17675
  }
17679
17676
  const definition = {
@@ -17682,8 +17679,8 @@
17682
17679
  };
17683
17680
  return this.env.model.dispatch("UPDATE_CHART", {
17684
17681
  definition,
17685
- id: this.figureId,
17686
- sheetId: this.sheetId,
17682
+ id: figureId,
17683
+ sheetId: this.env.model.getters.getFigureSheetId(figureId),
17687
17684
  });
17688
17685
  }
17689
17686
  onTypeChange(type) {
@@ -17695,7 +17692,7 @@
17695
17692
  this.env.model.dispatch("UPDATE_CHART", {
17696
17693
  definition,
17697
17694
  id: this.figureId,
17698
- sheetId: this.sheetId,
17695
+ sheetId: this.env.model.getters.getFigureSheetId(this.figureId),
17699
17696
  });
17700
17697
  }
17701
17698
  get chartPanel() {
@@ -19857,6 +19854,7 @@
19857
19854
  (this.autoCompleteState.selectedIndex + 1) % this.autoCompleteState.values.length;
19858
19855
  }
19859
19856
  }
19857
+ this.updateCursorIfNeeded();
19860
19858
  }
19861
19859
  processTabKey(ev) {
19862
19860
  var _a;
@@ -19927,10 +19925,12 @@
19927
19925
  }
19928
19926
  else {
19929
19927
  ev.stopPropagation();
19928
+ this.updateCursorIfNeeded();
19930
19929
  }
19931
- const { start, end } = this.contentHelper.getCurrentSelection();
19932
- if (!this.env.model.getters.isSelectingForComposer() &&
19933
- !(ev.key === "Enter" && (ev.altKey || ev.ctrlKey))) {
19930
+ }
19931
+ updateCursorIfNeeded() {
19932
+ if (!this.env.model.getters.isSelectingForComposer()) {
19933
+ const { start, end } = this.contentHelper.getCurrentSelection();
19934
19934
  this.env.model.dispatch("CHANGE_COMPOSER_CURSOR_SELECTION", { start, end });
19935
19935
  this.isKeyStillDown = true;
19936
19936
  }
@@ -19988,7 +19988,12 @@
19988
19988
  };
19989
19989
  });
19990
19990
  if (searchTerm) {
19991
- values = fuzzyLookup(searchTerm, values, (t) => t.text);
19991
+ if (searchTerm.toLowerCase() === "true" || searchTerm.toLowerCase() === "false") {
19992
+ values = [];
19993
+ }
19994
+ else {
19995
+ values = fuzzyLookup(searchTerm, values, (t) => t.text);
19996
+ }
19992
19997
  }
19993
19998
  else {
19994
19999
  // alphabetical order
@@ -23065,6 +23070,16 @@
23065
23070
  63: "333333",
23066
23071
  64: "000000",
23067
23072
  65: "FFFFFF", // system background
23073
+ };
23074
+ const IMAGE_MIMETYPE_EXTENSION_MAPPING = {
23075
+ "image/avif": "avif",
23076
+ "image/bmp": "bmp",
23077
+ "image/gif": "gif",
23078
+ "image/vnd.microsoft.icon": "ico",
23079
+ "image/jpeg": "jpeg",
23080
+ "image/png": "png",
23081
+ "image/tiff": "tiff",
23082
+ "image/webp": "webp",
23068
23083
  };
23069
23084
 
23070
23085
  /**
@@ -25501,6 +25516,11 @@
25501
25516
  <Override ContentType="${contentType}" PartName="${partName}" />
25502
25517
  `;
25503
25518
  }
25519
+ function createDefaultXMLElement(extension, contentType) {
25520
+ return escapeXml /*xml*/ `
25521
+ <Default Extension="${extension}" ContentType="${contentType}" />
25522
+ `;
25523
+ }
25504
25524
  function joinXmlNodes(xmlNodes) {
25505
25525
  return new XMLString(xmlNodes.join("\n"));
25506
25526
  }
@@ -39562,7 +39582,7 @@
39562
39582
  const file = await this.getImageFromUser();
39563
39583
  const path = await this.fileStore.upload(file);
39564
39584
  const size = await this.getImageSize(path);
39565
- return { path, size };
39585
+ return { path, size, mimetype: file.type };
39566
39586
  }
39567
39587
  getImageFromUser() {
39568
39588
  return new Promise((resolve, reject) => {
@@ -44628,8 +44648,7 @@
44628
44648
  // Figures and Charts
44629
44649
  let drawingNode = escapeXml ``;
44630
44650
  const drawingRelIds = [];
44631
- const charts = sheet.charts;
44632
- for (const chart of charts) {
44651
+ for (const chart of sheet.charts) {
44633
44652
  const xlsxChartId = convertChartId(chart.id);
44634
44653
  const chartRelId = addRelsToFile(construct.relsFiles, `xl/drawings/_rels/drawing${sheetIndex}.xml.rels`, {
44635
44654
  target: `../charts/chart${xlsxChartId}.xml`,
@@ -44638,20 +44657,27 @@
44638
44657
  drawingRelIds.push(chartRelId);
44639
44658
  files.push(createXMLFile(createChart(chart, sheetIndex, data), `xl/charts/chart${xlsxChartId}.xml`, "chart"));
44640
44659
  }
44641
- const images = sheet.images;
44642
- for (const image of images) {
44660
+ for (const image of sheet.images) {
44661
+ const mimeType = image.data.mimetype;
44662
+ if (mimeType === undefined)
44663
+ continue;
44664
+ const extension = IMAGE_MIMETYPE_EXTENSION_MAPPING[mimeType];
44665
+ // only support exporting images with mimetypes specified in the mapping
44666
+ if (extension === undefined)
44667
+ continue;
44643
44668
  const xlsxImageId = convertImageId(image.id);
44669
+ let imageFileName = `image${xlsxImageId}.${extension}`;
44644
44670
  const imageRelId = addRelsToFile(construct.relsFiles, `xl/drawings/_rels/drawing${sheetIndex}.xml.rels`, {
44645
- target: `../media/image${xlsxImageId}`,
44671
+ target: `../media/${imageFileName}`,
44646
44672
  type: XLSX_RELATION_TYPE.image,
44647
44673
  });
44648
44674
  drawingRelIds.push(imageRelId);
44649
44675
  files.push({
44650
- path: `xl/media/image${xlsxImageId}`,
44651
- imagePath: image.data.path,
44676
+ path: `xl/media/${imageFileName}`,
44677
+ imageSrc: image.data.path,
44652
44678
  });
44653
44679
  }
44654
- const drawings = [...charts, ...images];
44680
+ const drawings = [...sheet.charts, ...sheet.images];
44655
44681
  if (drawings.length) {
44656
44682
  const drawingRelId = addRelsToFile(construct.relsFiles, `xl/worksheets/_rels/sheet${sheetIndex}.xml.rels`, {
44657
44683
  target: `../drawings/drawing${sheetIndex}.xml`,
@@ -44770,6 +44796,8 @@
44770
44796
  }
44771
44797
  function createContentTypes(files) {
44772
44798
  const overrideNodes = [];
44799
+ // hard-code supported image mimetypes
44800
+ const imageDefaultNodes = Object.entries(IMAGE_MIMETYPE_EXTENSION_MAPPING).map(([mimetype, extension]) => createDefaultXMLElement(extension, mimetype));
44773
44801
  for (const file of files) {
44774
44802
  if ("contentType" in file && file.contentType) {
44775
44803
  overrideNodes.push(createOverride("/" + file.path, CONTENT_TYPES[file.contentType]));
@@ -44777,6 +44805,7 @@
44777
44805
  }
44778
44806
  const xml = escapeXml /*xml*/ `
44779
44807
  <Types xmlns="${NAMESPACE["Types"]}">
44808
+ ${joinXmlNodes(Object.values(imageDefaultNodes))}
44780
44809
  <Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml" />
44781
44810
  <Default Extension="xml" ContentType="application/xml" />
44782
44811
  ${joinXmlNodes(overrideNodes)}
@@ -45338,9 +45367,9 @@
45338
45367
  Object.defineProperty(exports, '__esModule', { value: true });
45339
45368
 
45340
45369
 
45341
- __info__.version = '16.2.7';
45342
- __info__.date = '2023-05-25T12:56:32.163Z';
45343
- __info__.hash = '047a6d5';
45370
+ __info__.version = '16.2.9';
45371
+ __info__.date = '2023-06-12T13:49:57.216Z';
45372
+ __info__.hash = '37e2719';
45344
45373
 
45345
45374
 
45346
45375
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);