@odoo/o-spreadsheet 16.2.6 → 16.2.8

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.
@@ -16860,7 +16860,7 @@
16860
16860
  return !!((_a = this.state.labelsDispatchResult) === null || _a === void 0 ? void 0 : _a.isCancelledBecause(33 /* CommandResult.InvalidLabelRange */));
16861
16861
  }
16862
16862
  onUpdateDataSetsHaveTitle(ev) {
16863
- this.props.updateChart({
16863
+ this.props.updateChart(this.props.figureId, {
16864
16864
  dataSetsHaveTitle: ev.target.checked,
16865
16865
  });
16866
16866
  }
@@ -16872,7 +16872,7 @@
16872
16872
  this.dataSeriesRanges = ranges;
16873
16873
  }
16874
16874
  onDataSeriesConfirmed() {
16875
- this.state.datasetDispatchResult = this.props.updateChart({
16875
+ this.state.datasetDispatchResult = this.props.updateChart(this.props.figureId, {
16876
16876
  dataSets: this.dataSeriesRanges,
16877
16877
  });
16878
16878
  }
@@ -16884,12 +16884,12 @@
16884
16884
  this.labelRange = ranges[0];
16885
16885
  }
16886
16886
  onLabelRangeConfirmed() {
16887
- this.state.labelsDispatchResult = this.props.updateChart({
16887
+ this.state.labelsDispatchResult = this.props.updateChart(this.props.figureId, {
16888
16888
  labelRange: this.labelRange,
16889
16889
  });
16890
16890
  }
16891
16891
  onUpdateAggregated(ev) {
16892
- this.props.updateChart({
16892
+ this.props.updateChart(this.props.figureId, {
16893
16893
  aggregated: ev.target.checked,
16894
16894
  });
16895
16895
  }
@@ -16904,12 +16904,12 @@
16904
16904
 
16905
16905
  class BarConfigPanel extends LineBarPieConfigPanel {
16906
16906
  onUpdateStacked(ev) {
16907
- this.props.updateChart({
16907
+ this.props.updateChart(this.props.figureId, {
16908
16908
  stacked: ev.target.checked,
16909
16909
  });
16910
16910
  }
16911
16911
  onUpdateAggregated(ev) {
16912
- this.props.updateChart({
16912
+ this.props.updateChart(this.props.figureId, {
16913
16913
  aggregated: ev.target.checked,
16914
16914
  });
16915
16915
  }
@@ -16947,6 +16947,18 @@
16947
16947
  grid-template-columns: repeat(${ITEMS_PER_LINE}, 1fr);
16948
16948
  grid-gap: ${ITEM_HORIZONTAL_MARGIN * 2}px;
16949
16949
  }
16950
+ .o-color-picker-toggler {
16951
+ display: flex;
16952
+ .o-color-picker-toggler-sign {
16953
+ margin: auto auto;
16954
+ width: 55%;
16955
+ height: 55%;
16956
+ .o-icon {
16957
+ width: 100%;
16958
+ height: 100%;
16959
+ }
16960
+ }
16961
+ }
16950
16962
  .o-color-picker-line-item {
16951
16963
  width: ${ITEM_EDGE_LENGTH}px;
16952
16964
  height: ${ITEM_EDGE_LENGTH}px;
@@ -17240,17 +17252,17 @@
17240
17252
  this.state.fillColorTool = !this.state.fillColorTool;
17241
17253
  }
17242
17254
  updateBackgroundColor(color) {
17243
- this.props.updateChart({
17255
+ this.props.updateChart(this.props.figureId, {
17244
17256
  background: color,
17245
17257
  });
17246
17258
  }
17247
17259
  updateTitle(ev) {
17248
- this.props.updateChart({
17260
+ this.props.updateChart(this.props.figureId, {
17249
17261
  title: ev.target.value,
17250
17262
  });
17251
17263
  }
17252
17264
  updateSelect(attr, ev) {
17253
- this.props.updateChart({
17265
+ this.props.updateChart(this.props.figureId, {
17254
17266
  [attr]: ev.target.value,
17255
17267
  });
17256
17268
  }
@@ -17288,7 +17300,7 @@
17288
17300
  this.dataRange = ranges[0];
17289
17301
  }
17290
17302
  updateDataRange() {
17291
- this.state.dataRangeDispatchResult = this.props.updateChart({
17303
+ this.state.dataRangeDispatchResult = this.props.updateChart(this.props.figureId, {
17292
17304
  dataRange: this.dataRange,
17293
17305
  });
17294
17306
  }
@@ -17350,12 +17362,12 @@
17350
17362
  }
17351
17363
  updateBackgroundColor(color) {
17352
17364
  this.state.openedMenu = undefined;
17353
- this.props.updateChart({
17365
+ this.props.updateChart(this.props.figureId, {
17354
17366
  background: color,
17355
17367
  });
17356
17368
  }
17357
17369
  updateTitle(ev) {
17358
- this.props.updateChart({
17370
+ this.props.updateChart(this.props.figureId, {
17359
17371
  title: ev.target.value,
17360
17372
  });
17361
17373
  }
@@ -17424,7 +17436,7 @@
17424
17436
  }
17425
17437
  }
17426
17438
  updateSectionRule(sectionRule) {
17427
- this.state.sectionRuleDispatchResult = this.props.updateChart({
17439
+ this.state.sectionRuleDispatchResult = this.props.updateChart(this.props.figureId, {
17428
17440
  sectionRule,
17429
17441
  });
17430
17442
  }
@@ -17449,17 +17461,17 @@
17449
17461
  return false;
17450
17462
  }
17451
17463
  onUpdateLabelsAsText(ev) {
17452
- this.props.updateChart({
17464
+ this.props.updateChart(this.props.figureId, {
17453
17465
  labelsAsText: ev.target.checked,
17454
17466
  });
17455
17467
  }
17456
17468
  onUpdateStacked(ev) {
17457
- this.props.updateChart({
17469
+ this.props.updateChart(this.props.figureId, {
17458
17470
  stacked: ev.target.checked,
17459
17471
  });
17460
17472
  }
17461
17473
  onUpdateAggregated(ev) {
17462
- this.props.updateChart({
17474
+ this.props.updateChart(this.props.figureId, {
17463
17475
  aggregated: ev.target.checked,
17464
17476
  });
17465
17477
  }
@@ -17500,7 +17512,7 @@
17500
17512
  this.keyValue = ranges[0];
17501
17513
  }
17502
17514
  updateKeyValueRange() {
17503
- this.state.keyValueDispatchResult = this.props.updateChart({
17515
+ this.state.keyValueDispatchResult = this.props.updateChart(this.props.figureId, {
17504
17516
  keyValue: this.keyValue,
17505
17517
  });
17506
17518
  }
@@ -17508,12 +17520,12 @@
17508
17520
  this.baseline = ranges[0];
17509
17521
  }
17510
17522
  updateBaselineRange() {
17511
- this.state.baselineDispatchResult = this.props.updateChart({
17523
+ this.state.baselineDispatchResult = this.props.updateChart(this.props.figureId, {
17512
17524
  baseline: this.baseline,
17513
17525
  });
17514
17526
  }
17515
17527
  updateBaselineMode(ev) {
17516
- this.props.updateChart({ baselineMode: ev.target.value });
17528
+ this.props.updateChart(this.props.figureId, { baselineMode: ev.target.value });
17517
17529
  }
17518
17530
  }
17519
17531
  ScorecardChartConfigPanel.template = "o-spreadsheet-ScorecardChartConfigPanel";
@@ -17535,12 +17547,12 @@
17535
17547
  owl.useExternalListener(window, "click", this.closeMenus);
17536
17548
  }
17537
17549
  updateTitle(ev) {
17538
- this.props.updateChart({
17550
+ this.props.updateChart(this.props.figureId, {
17539
17551
  title: ev.target.value,
17540
17552
  });
17541
17553
  }
17542
17554
  updateBaselineDescr(ev) {
17543
- this.props.updateChart({ baselineDescr: ev.target.value });
17555
+ this.props.updateChart(this.props.figureId, { baselineDescr: ev.target.value });
17544
17556
  }
17545
17557
  toggleColorPicker(colorPickerId) {
17546
17558
  if (this.state.openedColorPicker === colorPickerId) {
@@ -17553,13 +17565,13 @@
17553
17565
  setColor(color, colorPickerId) {
17554
17566
  switch (colorPickerId) {
17555
17567
  case "backgroundColor":
17556
- this.props.updateChart({ background: color });
17568
+ this.props.updateChart(this.props.figureId, { background: color });
17557
17569
  break;
17558
17570
  case "baselineColorDown":
17559
- this.props.updateChart({ baselineColorDown: color });
17571
+ this.props.updateChart(this.props.figureId, { baselineColorDown: color });
17560
17572
  break;
17561
17573
  case "baselineColorUp":
17562
- this.props.updateChart({ baselineColorUp: color });
17574
+ this.props.updateChart(this.props.figureId, { baselineColorUp: color });
17563
17575
  break;
17564
17576
  }
17565
17577
  this.closeMenus();
@@ -17624,16 +17636,9 @@
17624
17636
  }
17625
17637
  `;
17626
17638
  class ChartPanel extends owl.Component {
17627
- constructor() {
17628
- super(...arguments);
17629
- this.shouldUpdateChart = true;
17630
- }
17631
17639
  get figureId() {
17632
17640
  return this.state.figureId;
17633
17641
  }
17634
- get sheetId() {
17635
- return this.state.sheetId;
17636
- }
17637
17642
  setup() {
17638
17643
  const selectedFigureId = this.env.model.getters.getSelectedFigureId();
17639
17644
  if (!selectedFigureId) {
@@ -17642,17 +17647,11 @@
17642
17647
  this.state = owl.useState({
17643
17648
  panel: "configuration",
17644
17649
  figureId: selectedFigureId,
17645
- sheetId: this.env.model.getters.getActiveSheetId(),
17646
17650
  });
17647
17651
  owl.onWillUpdateProps(() => {
17648
17652
  const selectedFigureId = this.env.model.getters.getSelectedFigureId();
17649
17653
  if (selectedFigureId && selectedFigureId !== this.state.figureId) {
17650
17654
  this.state.figureId = selectedFigureId;
17651
- this.state.sheetId = this.env.model.getters.getActiveSheetId();
17652
- this.shouldUpdateChart = false;
17653
- }
17654
- else {
17655
- this.shouldUpdateChart = true;
17656
17655
  }
17657
17656
  if (!this.env.model.getters.isChartDefined(this.figureId)) {
17658
17657
  this.props.onCloseSidePanel();
@@ -17660,8 +17659,8 @@
17660
17659
  }
17661
17660
  });
17662
17661
  }
17663
- updateChart(updateDefinition) {
17664
- if (!this.shouldUpdateChart) {
17662
+ updateChart(figureId, updateDefinition) {
17663
+ if (figureId !== this.figureId) {
17665
17664
  return;
17666
17665
  }
17667
17666
  const definition = {
@@ -17670,8 +17669,8 @@
17670
17669
  };
17671
17670
  return this.env.model.dispatch("UPDATE_CHART", {
17672
17671
  definition,
17673
- id: this.figureId,
17674
- sheetId: this.sheetId,
17672
+ id: figureId,
17673
+ sheetId: this.env.model.getters.getFigureSheetId(figureId),
17675
17674
  });
17676
17675
  }
17677
17676
  onTypeChange(type) {
@@ -17683,7 +17682,7 @@
17683
17682
  this.env.model.dispatch("UPDATE_CHART", {
17684
17683
  definition,
17685
17684
  id: this.figureId,
17686
- sheetId: this.sheetId,
17685
+ sheetId: this.env.model.getters.getFigureSheetId(this.figureId),
17687
17686
  });
17688
17687
  }
17689
17688
  get chartPanel() {
@@ -19539,7 +19538,14 @@
19539
19538
  current = it.next();
19540
19539
  }
19541
19540
  if (current.value !== nodeToFind) {
19542
- throw new Error("Cannot find the node in the children of the element");
19541
+ /** This situation can happen if the code is called while the selection is not currently on the ContentEditableHelper.
19542
+ * In this case, we return 0 because we don't know the size of the text before the selection.
19543
+ *
19544
+ * A known occurence is triggered since the introduction of commit d4663158 (PR #2038).
19545
+ *
19546
+ * FIXME: find a way to test eventhough the selection API is not available in jsDOM.
19547
+ */
19548
+ return 0;
19543
19549
  }
19544
19550
  else {
19545
19551
  if (!current.value.hasChildNodes()) {
@@ -23046,6 +23052,16 @@
23046
23052
  63: "333333",
23047
23053
  64: "000000",
23048
23054
  65: "FFFFFF", // system background
23055
+ };
23056
+ const IMAGE_MIMETYPE_EXTENSION_MAPPING = {
23057
+ "image/avif": "avif",
23058
+ "image/bmp": "bmp",
23059
+ "image/gif": "gif",
23060
+ "image/vnd.microsoft.icon": "ico",
23061
+ "image/jpeg": "jpeg",
23062
+ "image/png": "png",
23063
+ "image/tiff": "tiff",
23064
+ "image/webp": "webp",
23049
23065
  };
23050
23066
 
23051
23067
  /**
@@ -25482,6 +25498,11 @@
25482
25498
  <Override ContentType="${contentType}" PartName="${partName}" />
25483
25499
  `;
25484
25500
  }
25501
+ function createDefaultXMLElement(extension, contentType) {
25502
+ return escapeXml /*xml*/ `
25503
+ <Default Extension="${extension}" ContentType="${contentType}" />
25504
+ `;
25505
+ }
25485
25506
  function joinXmlNodes(xmlNodes) {
25486
25507
  return new XMLString(xmlNodes.join("\n"));
25487
25508
  }
@@ -37075,7 +37096,8 @@
37075
37096
  getCellWidth(position) {
37076
37097
  const text = this.getCellText(position);
37077
37098
  const style = this.getters.getCellComputedStyle(position);
37078
- let contentWidth = this.getTextWidth(text, style);
37099
+ const multiLineText = text.split(NEWLINE);
37100
+ let contentWidth = Math.max(...multiLineText.map((line) => this.getTextWidth(line, style)));
37079
37101
  const icon = this.getters.getConditionalIcon(position);
37080
37102
  if (icon) {
37081
37103
  contentWidth += computeIconWidth(this.getters.getCellStyle(position));
@@ -39542,7 +39564,7 @@
39542
39564
  const file = await this.getImageFromUser();
39543
39565
  const path = await this.fileStore.upload(file);
39544
39566
  const size = await this.getImageSize(path);
39545
- return { path, size };
39567
+ return { path, size, mimetype: file.type };
39546
39568
  }
39547
39569
  getImageFromUser() {
39548
39570
  return new Promise((resolve, reject) => {
@@ -44608,8 +44630,7 @@
44608
44630
  // Figures and Charts
44609
44631
  let drawingNode = escapeXml ``;
44610
44632
  const drawingRelIds = [];
44611
- const charts = sheet.charts;
44612
- for (const chart of charts) {
44633
+ for (const chart of sheet.charts) {
44613
44634
  const xlsxChartId = convertChartId(chart.id);
44614
44635
  const chartRelId = addRelsToFile(construct.relsFiles, `xl/drawings/_rels/drawing${sheetIndex}.xml.rels`, {
44615
44636
  target: `../charts/chart${xlsxChartId}.xml`,
@@ -44618,20 +44639,27 @@
44618
44639
  drawingRelIds.push(chartRelId);
44619
44640
  files.push(createXMLFile(createChart(chart, sheetIndex, data), `xl/charts/chart${xlsxChartId}.xml`, "chart"));
44620
44641
  }
44621
- const images = sheet.images;
44622
- for (const image of images) {
44642
+ for (const image of sheet.images) {
44643
+ const mimeType = image.data.mimetype;
44644
+ if (mimeType === undefined)
44645
+ continue;
44646
+ const extension = IMAGE_MIMETYPE_EXTENSION_MAPPING[mimeType];
44647
+ // only support exporting images with mimetypes specified in the mapping
44648
+ if (extension === undefined)
44649
+ continue;
44623
44650
  const xlsxImageId = convertImageId(image.id);
44651
+ let imageFileName = `image${xlsxImageId}.${extension}`;
44624
44652
  const imageRelId = addRelsToFile(construct.relsFiles, `xl/drawings/_rels/drawing${sheetIndex}.xml.rels`, {
44625
- target: `../media/image${xlsxImageId}`,
44653
+ target: `../media/${imageFileName}`,
44626
44654
  type: XLSX_RELATION_TYPE.image,
44627
44655
  });
44628
44656
  drawingRelIds.push(imageRelId);
44629
44657
  files.push({
44630
- path: `xl/media/image${xlsxImageId}`,
44631
- imagePath: image.data.path,
44658
+ path: `xl/media/${imageFileName}`,
44659
+ imageSrc: image.data.path,
44632
44660
  });
44633
44661
  }
44634
- const drawings = [...charts, ...images];
44662
+ const drawings = [...sheet.charts, ...sheet.images];
44635
44663
  if (drawings.length) {
44636
44664
  const drawingRelId = addRelsToFile(construct.relsFiles, `xl/worksheets/_rels/sheet${sheetIndex}.xml.rels`, {
44637
44665
  target: `../drawings/drawing${sheetIndex}.xml`,
@@ -44750,6 +44778,8 @@
44750
44778
  }
44751
44779
  function createContentTypes(files) {
44752
44780
  const overrideNodes = [];
44781
+ // hard-code supported image mimetypes
44782
+ const imageDefaultNodes = Object.entries(IMAGE_MIMETYPE_EXTENSION_MAPPING).map(([mimetype, extension]) => createDefaultXMLElement(extension, mimetype));
44753
44783
  for (const file of files) {
44754
44784
  if ("contentType" in file && file.contentType) {
44755
44785
  overrideNodes.push(createOverride("/" + file.path, CONTENT_TYPES[file.contentType]));
@@ -44757,6 +44787,7 @@
44757
44787
  }
44758
44788
  const xml = escapeXml /*xml*/ `
44759
44789
  <Types xmlns="${NAMESPACE["Types"]}">
44790
+ ${joinXmlNodes(Object.values(imageDefaultNodes))}
44760
44791
  <Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml" />
44761
44792
  <Default Extension="xml" ContentType="application/xml" />
44762
44793
  ${joinXmlNodes(overrideNodes)}
@@ -45318,9 +45349,9 @@
45318
45349
  Object.defineProperty(exports, '__esModule', { value: true });
45319
45350
 
45320
45351
 
45321
- __info__.version = '16.2.6';
45322
- __info__.date = '2023-05-12T10:58:25.815Z';
45323
- __info__.hash = '6848d25';
45352
+ __info__.version = '16.2.8';
45353
+ __info__.date = '2023-06-02T10:12:43.068Z';
45354
+ __info__.hash = 'b474e62';
45324
45355
 
45325
45356
 
45326
45357
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);