@odoo/o-spreadsheet 16.3.0 → 16.3.2

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.
@@ -16870,6 +16870,7 @@
16870
16870
  execute: (env) => env.model.dispatch("UNFREEZE_COLUMNS_ROWS", {
16871
16871
  sheetId: env.model.getters.getActiveSheetId(),
16872
16872
  }),
16873
+ icon: "o-spreadsheet-Icon.UNFREEZE",
16873
16874
  };
16874
16875
  const freezePane = {
16875
16876
  name: _lt("Freeze"),
@@ -17840,7 +17841,7 @@
17840
17841
  return !!this.state.labelsDispatchResult?.isCancelledBecause(33 /* CommandResult.InvalidLabelRange */);
17841
17842
  }
17842
17843
  onUpdateDataSetsHaveTitle(ev) {
17843
- this.props.updateChart({
17844
+ this.props.updateChart(this.props.figureId, {
17844
17845
  dataSetsHaveTitle: ev.target.checked,
17845
17846
  });
17846
17847
  }
@@ -17852,7 +17853,7 @@
17852
17853
  this.dataSeriesRanges = ranges;
17853
17854
  }
17854
17855
  onDataSeriesConfirmed() {
17855
- this.state.datasetDispatchResult = this.props.updateChart({
17856
+ this.state.datasetDispatchResult = this.props.updateChart(this.props.figureId, {
17856
17857
  dataSets: this.dataSeriesRanges,
17857
17858
  });
17858
17859
  }
@@ -17864,12 +17865,12 @@
17864
17865
  this.labelRange = ranges[0];
17865
17866
  }
17866
17867
  onLabelRangeConfirmed() {
17867
- this.state.labelsDispatchResult = this.props.updateChart({
17868
+ this.state.labelsDispatchResult = this.props.updateChart(this.props.figureId, {
17868
17869
  labelRange: this.labelRange,
17869
17870
  });
17870
17871
  }
17871
17872
  onUpdateAggregated(ev) {
17872
- this.props.updateChart({
17873
+ this.props.updateChart(this.props.figureId, {
17873
17874
  aggregated: ev.target.checked,
17874
17875
  });
17875
17876
  }
@@ -17899,12 +17900,12 @@
17899
17900
  class BarConfigPanel extends LineBarPieConfigPanel {
17900
17901
  static template = "o-spreadsheet-BarConfigPanel";
17901
17902
  onUpdateStacked(ev) {
17902
- this.props.updateChart({
17903
+ this.props.updateChart(this.props.figureId, {
17903
17904
  stacked: ev.target.checked,
17904
17905
  });
17905
17906
  }
17906
17907
  onUpdateAggregated(ev) {
17907
- this.props.updateChart({
17908
+ this.props.updateChart(this.props.figureId, {
17908
17909
  aggregated: ev.target.checked,
17909
17910
  });
17910
17911
  }
@@ -17941,6 +17942,18 @@
17941
17942
  grid-template-columns: repeat(${ITEMS_PER_LINE}, 1fr);
17942
17943
  grid-gap: ${ITEM_HORIZONTAL_MARGIN * 2}px;
17943
17944
  }
17945
+ .o-color-picker-toggler-button {
17946
+ display: flex;
17947
+ .o-color-picker-toggler-sign {
17948
+ margin: auto auto;
17949
+ width: 55%;
17950
+ height: 55%;
17951
+ .o-icon {
17952
+ width: 100%;
17953
+ height: 100%;
17954
+ }
17955
+ }
17956
+ }
17944
17957
  .o-color-picker-line-item {
17945
17958
  width: ${ITEM_EDGE_LENGTH}px;
17946
17959
  height: ${ITEM_EDGE_LENGTH}px;
@@ -18229,17 +18242,17 @@
18229
18242
  this.state.fillColorTool = !this.state.fillColorTool;
18230
18243
  }
18231
18244
  updateBackgroundColor(color) {
18232
- this.props.updateChart({
18245
+ this.props.updateChart(this.props.figureId, {
18233
18246
  background: color,
18234
18247
  });
18235
18248
  }
18236
18249
  updateTitle(ev) {
18237
- this.props.updateChart({
18250
+ this.props.updateChart(this.props.figureId, {
18238
18251
  title: ev.target.value,
18239
18252
  });
18240
18253
  }
18241
18254
  updateSelect(attr, ev) {
18242
- this.props.updateChart({
18255
+ this.props.updateChart(this.props.figureId, {
18243
18256
  [attr]: ev.target.value,
18244
18257
  });
18245
18258
  }
@@ -18272,7 +18285,7 @@
18272
18285
  this.dataRange = ranges[0];
18273
18286
  }
18274
18287
  updateDataRange() {
18275
- this.state.dataRangeDispatchResult = this.props.updateChart({
18288
+ this.state.dataRangeDispatchResult = this.props.updateChart(this.props.figureId, {
18276
18289
  dataRange: this.dataRange,
18277
18290
  });
18278
18291
  }
@@ -18330,12 +18343,12 @@
18330
18343
  }
18331
18344
  updateBackgroundColor(color) {
18332
18345
  this.state.openedMenu = undefined;
18333
- this.props.updateChart({
18346
+ this.props.updateChart(this.props.figureId, {
18334
18347
  background: color,
18335
18348
  });
18336
18349
  }
18337
18350
  updateTitle(ev) {
18338
- this.props.updateChart({
18351
+ this.props.updateChart(this.props.figureId, {
18339
18352
  title: ev.target.value,
18340
18353
  });
18341
18354
  }
@@ -18400,7 +18413,7 @@
18400
18413
  }
18401
18414
  }
18402
18415
  updateSectionRule(sectionRule) {
18403
- this.state.sectionRuleDispatchResult = this.props.updateChart({
18416
+ this.state.sectionRuleDispatchResult = this.props.updateChart(this.props.figureId, {
18404
18417
  sectionRule,
18405
18418
  });
18406
18419
  }
@@ -18424,17 +18437,17 @@
18424
18437
  return false;
18425
18438
  }
18426
18439
  onUpdateLabelsAsText(ev) {
18427
- this.props.updateChart({
18440
+ this.props.updateChart(this.props.figureId, {
18428
18441
  labelsAsText: ev.target.checked,
18429
18442
  });
18430
18443
  }
18431
18444
  onUpdateStacked(ev) {
18432
- this.props.updateChart({
18445
+ this.props.updateChart(this.props.figureId, {
18433
18446
  stacked: ev.target.checked,
18434
18447
  });
18435
18448
  }
18436
18449
  onUpdateAggregated(ev) {
18437
- this.props.updateChart({
18450
+ this.props.updateChart(this.props.figureId, {
18438
18451
  aggregated: ev.target.checked,
18439
18452
  });
18440
18453
  }
@@ -18470,7 +18483,7 @@
18470
18483
  this.keyValue = ranges[0];
18471
18484
  }
18472
18485
  updateKeyValueRange() {
18473
- this.state.keyValueDispatchResult = this.props.updateChart({
18486
+ this.state.keyValueDispatchResult = this.props.updateChart(this.props.figureId, {
18474
18487
  keyValue: this.keyValue,
18475
18488
  });
18476
18489
  }
@@ -18478,12 +18491,12 @@
18478
18491
  this.baseline = ranges[0];
18479
18492
  }
18480
18493
  updateBaselineRange() {
18481
- this.state.baselineDispatchResult = this.props.updateChart({
18494
+ this.state.baselineDispatchResult = this.props.updateChart(this.props.figureId, {
18482
18495
  baseline: this.baseline,
18483
18496
  });
18484
18497
  }
18485
18498
  updateBaselineMode(ev) {
18486
- this.props.updateChart({ baselineMode: ev.target.value });
18499
+ this.props.updateChart(this.props.figureId, { baselineMode: ev.target.value });
18487
18500
  }
18488
18501
  }
18489
18502
  ScorecardChartConfigPanel.props = {
@@ -18502,12 +18515,12 @@
18502
18515
  owl.useExternalListener(window, "click", this.closeMenus);
18503
18516
  }
18504
18517
  updateTitle(ev) {
18505
- this.props.updateChart({
18518
+ this.props.updateChart(this.props.figureId, {
18506
18519
  title: ev.target.value,
18507
18520
  });
18508
18521
  }
18509
18522
  updateBaselineDescr(ev) {
18510
- this.props.updateChart({ baselineDescr: ev.target.value });
18523
+ this.props.updateChart(this.props.figureId, { baselineDescr: ev.target.value });
18511
18524
  }
18512
18525
  toggleColorPicker(colorPickerId) {
18513
18526
  if (this.state.openedColorPicker === colorPickerId) {
@@ -18520,13 +18533,13 @@
18520
18533
  setColor(color, colorPickerId) {
18521
18534
  switch (colorPickerId) {
18522
18535
  case "backgroundColor":
18523
- this.props.updateChart({ background: color });
18536
+ this.props.updateChart(this.props.figureId, { background: color });
18524
18537
  break;
18525
18538
  case "baselineColorDown":
18526
- this.props.updateChart({ baselineColorDown: color });
18539
+ this.props.updateChart(this.props.figureId, { baselineColorDown: color });
18527
18540
  break;
18528
18541
  case "baselineColorUp":
18529
- this.props.updateChart({ baselineColorUp: color });
18542
+ this.props.updateChart(this.props.figureId, { baselineColorUp: color });
18530
18543
  break;
18531
18544
  }
18532
18545
  this.closeMenus();
@@ -18591,13 +18604,9 @@
18591
18604
  class ChartPanel extends owl.Component {
18592
18605
  static template = "o-spreadsheet-ChartPanel";
18593
18606
  state;
18594
- shouldUpdateChart = true;
18595
18607
  get figureId() {
18596
18608
  return this.state.figureId;
18597
18609
  }
18598
- get sheetId() {
18599
- return this.state.sheetId;
18600
- }
18601
18610
  setup() {
18602
18611
  const selectedFigureId = this.env.model.getters.getSelectedFigureId();
18603
18612
  if (!selectedFigureId) {
@@ -18607,17 +18616,11 @@
18607
18616
  this.state = owl.useState({
18608
18617
  panel: "configuration",
18609
18618
  figureId: selectedFigureId,
18610
- sheetId: this.env.model.getters.getActiveSheetId(),
18611
18619
  });
18612
18620
  owl.onWillUpdateProps(() => {
18613
18621
  const selectedFigureId = this.env.model.getters.getSelectedFigureId();
18614
18622
  if (selectedFigureId && selectedFigureId !== this.state.figureId) {
18615
18623
  this.state.figureId = selectedFigureId;
18616
- this.state.sheetId = this.env.model.getters.getActiveSheetId();
18617
- this.shouldUpdateChart = false;
18618
- }
18619
- else {
18620
- this.shouldUpdateChart = true;
18621
18624
  }
18622
18625
  if (!this.env.model.getters.isChartDefined(this.figureId)) {
18623
18626
  this.props.onCloseSidePanel();
@@ -18625,8 +18628,8 @@
18625
18628
  }
18626
18629
  });
18627
18630
  }
18628
- updateChart(updateDefinition) {
18629
- if (!this.shouldUpdateChart) {
18631
+ updateChart(figureId, updateDefinition) {
18632
+ if (figureId !== this.figureId) {
18630
18633
  return;
18631
18634
  }
18632
18635
  const definition = {
@@ -18635,8 +18638,8 @@
18635
18638
  };
18636
18639
  return this.env.model.dispatch("UPDATE_CHART", {
18637
18640
  definition,
18638
- id: this.figureId,
18639
- sheetId: this.sheetId,
18641
+ id: figureId,
18642
+ sheetId: this.env.model.getters.getFigureSheetId(figureId),
18640
18643
  });
18641
18644
  }
18642
18645
  onTypeChange(type) {
@@ -18648,7 +18651,7 @@
18648
18651
  this.env.model.dispatch("UPDATE_CHART", {
18649
18652
  definition,
18650
18653
  id: this.figureId,
18651
- sheetId: this.sheetId,
18654
+ sheetId: this.env.model.getters.getFigureSheetId(this.figureId),
18652
18655
  });
18653
18656
  }
18654
18657
  get chartPanel() {
@@ -20613,7 +20616,14 @@
20613
20616
  current = it.next();
20614
20617
  }
20615
20618
  if (current.value !== nodeToFind) {
20616
- throw new Error("Cannot find the node in the children of the element");
20619
+ /** This situation can happen if the code is called while the selection is not currently on the ContentEditableHelper.
20620
+ * In this case, we return 0 because we don't know the size of the text before the selection.
20621
+ *
20622
+ * A known occurence is triggered since the introduction of commit d4663158 (PR #2038).
20623
+ *
20624
+ * FIXME: find a way to test eventhough the selection API is not available in jsDOM.
20625
+ */
20626
+ return 0;
20617
20627
  }
20618
20628
  else {
20619
20629
  if (!current.value.hasChildNodes()) {
@@ -24462,6 +24472,16 @@
24462
24472
  63: "333333",
24463
24473
  64: "000000",
24464
24474
  65: "FFFFFF", // system background
24475
+ };
24476
+ const IMAGE_MIMETYPE_EXTENSION_MAPPING = {
24477
+ "image/avif": "avif",
24478
+ "image/bmp": "bmp",
24479
+ "image/gif": "gif",
24480
+ "image/vnd.microsoft.icon": "ico",
24481
+ "image/jpeg": "jpeg",
24482
+ "image/png": "png",
24483
+ "image/tiff": "tiff",
24484
+ "image/webp": "webp",
24465
24485
  };
24466
24486
 
24467
24487
  /**
@@ -26943,6 +26963,11 @@
26943
26963
  <Override ContentType="${contentType}" PartName="${partName}" />
26944
26964
  `;
26945
26965
  }
26966
+ function createDefaultXMLElement(extension, contentType) {
26967
+ return escapeXml /*xml*/ `
26968
+ <Default Extension="${extension}" ContentType="${contentType}" />
26969
+ `;
26970
+ }
26946
26971
  function joinXmlNodes(xmlNodes) {
26947
26972
  return new XMLString(xmlNodes.join("\n"));
26948
26973
  }
@@ -38665,7 +38690,8 @@
38665
38690
  getCellWidth(position) {
38666
38691
  const text = this.getCellText(position);
38667
38692
  const style = this.getters.getCellComputedStyle(position);
38668
- let contentWidth = this.getTextWidth(text, style);
38693
+ const multiLineText = text.split(NEWLINE);
38694
+ let contentWidth = Math.max(...multiLineText.map((line) => this.getTextWidth(line, style)));
38669
38695
  const icon = this.getters.getConditionalIcon(position);
38670
38696
  if (icon) {
38671
38697
  contentWidth += computeIconWidth(this.getters.getCellStyle(position));
@@ -41709,7 +41735,7 @@
41709
41735
  const file = await this.getImageFromUser();
41710
41736
  const path = await this.fileStore.upload(file);
41711
41737
  const size = await this.getImageSize(path);
41712
- return { path, size };
41738
+ return { path, size, mimetype: file.type };
41713
41739
  }
41714
41740
  getImageFromUser() {
41715
41741
  return new Promise((resolve, reject) => {
@@ -43794,6 +43820,10 @@
43794
43820
  }
43795
43821
  checkViewportSize() {
43796
43822
  const { xRatio, yRatio } = this.env.model.getters.getFrozenSheetViewRatio(this.env.model.getters.getActiveSheetId());
43823
+ if (!isFinite(xRatio) || !isFinite(yRatio)) {
43824
+ // before mounting, the ratios can be NaN or Infinity if the viewport size is 0
43825
+ return;
43826
+ }
43797
43827
  if (yRatio > MAXIMAL_FREEZABLE_RATIO || xRatio > MAXIMAL_FREEZABLE_RATIO) {
43798
43828
  if (this.isViewportTooSmall) {
43799
43829
  return;
@@ -46786,8 +46816,7 @@
46786
46816
  // Figures and Charts
46787
46817
  let drawingNode = escapeXml ``;
46788
46818
  const drawingRelIds = [];
46789
- const charts = sheet.charts;
46790
- for (const chart of charts) {
46819
+ for (const chart of sheet.charts) {
46791
46820
  const xlsxChartId = convertChartId(chart.id);
46792
46821
  const chartRelId = addRelsToFile(construct.relsFiles, `xl/drawings/_rels/drawing${sheetIndex}.xml.rels`, {
46793
46822
  target: `../charts/chart${xlsxChartId}.xml`,
@@ -46796,20 +46825,27 @@
46796
46825
  drawingRelIds.push(chartRelId);
46797
46826
  files.push(createXMLFile(createChart(chart, sheetIndex, data), `xl/charts/chart${xlsxChartId}.xml`, "chart"));
46798
46827
  }
46799
- const images = sheet.images;
46800
- for (const image of images) {
46828
+ for (const image of sheet.images) {
46829
+ const mimeType = image.data.mimetype;
46830
+ if (mimeType === undefined)
46831
+ continue;
46832
+ const extension = IMAGE_MIMETYPE_EXTENSION_MAPPING[mimeType];
46833
+ // only support exporting images with mimetypes specified in the mapping
46834
+ if (extension === undefined)
46835
+ continue;
46801
46836
  const xlsxImageId = convertImageId(image.id);
46837
+ let imageFileName = `image${xlsxImageId}.${extension}`;
46802
46838
  const imageRelId = addRelsToFile(construct.relsFiles, `xl/drawings/_rels/drawing${sheetIndex}.xml.rels`, {
46803
- target: `../media/image${xlsxImageId}`,
46839
+ target: `../media/${imageFileName}`,
46804
46840
  type: XLSX_RELATION_TYPE.image,
46805
46841
  });
46806
46842
  drawingRelIds.push(imageRelId);
46807
46843
  files.push({
46808
- path: `xl/media/image${xlsxImageId}`,
46809
- imagePath: image.data.path,
46844
+ path: `xl/media/${imageFileName}`,
46845
+ imageSrc: image.data.path,
46810
46846
  });
46811
46847
  }
46812
- const drawings = [...charts, ...images];
46848
+ const drawings = [...sheet.charts, ...sheet.images];
46813
46849
  if (drawings.length) {
46814
46850
  const drawingRelId = addRelsToFile(construct.relsFiles, `xl/worksheets/_rels/sheet${sheetIndex}.xml.rels`, {
46815
46851
  target: `../drawings/drawing${sheetIndex}.xml`,
@@ -46928,6 +46964,8 @@
46928
46964
  }
46929
46965
  function createContentTypes(files) {
46930
46966
  const overrideNodes = [];
46967
+ // hard-code supported image mimetypes
46968
+ const imageDefaultNodes = Object.entries(IMAGE_MIMETYPE_EXTENSION_MAPPING).map(([mimetype, extension]) => createDefaultXMLElement(extension, mimetype));
46931
46969
  for (const file of files) {
46932
46970
  if ("contentType" in file && file.contentType) {
46933
46971
  overrideNodes.push(createOverride("/" + file.path, CONTENT_TYPES[file.contentType]));
@@ -46943,6 +46981,7 @@
46943
46981
  ];
46944
46982
  const xml = escapeXml /*xml*/ `
46945
46983
  <Types xmlns="${NAMESPACE["Types"]}">
46984
+ ${joinXmlNodes(Object.values(imageDefaultNodes))}
46946
46985
  <Default ${formatAttributes(relsAttributes)} />
46947
46986
  <Default ${formatAttributes(xmlAttributes)} />
46948
46987
  ${joinXmlNodes(overrideNodes)}
@@ -47557,9 +47596,9 @@
47557
47596
  Object.defineProperty(exports, '__esModule', { value: true });
47558
47597
 
47559
47598
 
47560
- __info__.version = '16.3.0';
47561
- __info__.date = '2023-05-17T14:44:57.860Z';
47562
- __info__.hash = '33b37e4';
47599
+ __info__.version = '16.3.2';
47600
+ __info__.date = '2023-06-02T10:13:46.734Z';
47601
+ __info__.hash = '69a4378';
47563
47602
 
47564
47603
 
47565
47604
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);