@odoo/o-spreadsheet 16.3.1 → 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.
@@ -17844,7 +17844,7 @@ class LineBarPieConfigPanel extends owl.Component {
17844
17844
  return !!this.state.labelsDispatchResult?.isCancelledBecause(33 /* CommandResult.InvalidLabelRange */);
17845
17845
  }
17846
17846
  onUpdateDataSetsHaveTitle(ev) {
17847
- this.props.updateChart({
17847
+ this.props.updateChart(this.props.figureId, {
17848
17848
  dataSetsHaveTitle: ev.target.checked,
17849
17849
  });
17850
17850
  }
@@ -17856,7 +17856,7 @@ class LineBarPieConfigPanel extends owl.Component {
17856
17856
  this.dataSeriesRanges = ranges;
17857
17857
  }
17858
17858
  onDataSeriesConfirmed() {
17859
- this.state.datasetDispatchResult = this.props.updateChart({
17859
+ this.state.datasetDispatchResult = this.props.updateChart(this.props.figureId, {
17860
17860
  dataSets: this.dataSeriesRanges,
17861
17861
  });
17862
17862
  }
@@ -17868,12 +17868,12 @@ class LineBarPieConfigPanel extends owl.Component {
17868
17868
  this.labelRange = ranges[0];
17869
17869
  }
17870
17870
  onLabelRangeConfirmed() {
17871
- this.state.labelsDispatchResult = this.props.updateChart({
17871
+ this.state.labelsDispatchResult = this.props.updateChart(this.props.figureId, {
17872
17872
  labelRange: this.labelRange,
17873
17873
  });
17874
17874
  }
17875
17875
  onUpdateAggregated(ev) {
17876
- this.props.updateChart({
17876
+ this.props.updateChart(this.props.figureId, {
17877
17877
  aggregated: ev.target.checked,
17878
17878
  });
17879
17879
  }
@@ -17903,12 +17903,12 @@ LineBarPieConfigPanel.props = {
17903
17903
  class BarConfigPanel extends LineBarPieConfigPanel {
17904
17904
  static template = "o-spreadsheet-BarConfigPanel";
17905
17905
  onUpdateStacked(ev) {
17906
- this.props.updateChart({
17906
+ this.props.updateChart(this.props.figureId, {
17907
17907
  stacked: ev.target.checked,
17908
17908
  });
17909
17909
  }
17910
17910
  onUpdateAggregated(ev) {
17911
- this.props.updateChart({
17911
+ this.props.updateChart(this.props.figureId, {
17912
17912
  aggregated: ev.target.checked,
17913
17913
  });
17914
17914
  }
@@ -18245,17 +18245,17 @@ class LineBarPieDesignPanel extends owl.Component {
18245
18245
  this.state.fillColorTool = !this.state.fillColorTool;
18246
18246
  }
18247
18247
  updateBackgroundColor(color) {
18248
- this.props.updateChart({
18248
+ this.props.updateChart(this.props.figureId, {
18249
18249
  background: color,
18250
18250
  });
18251
18251
  }
18252
18252
  updateTitle(ev) {
18253
- this.props.updateChart({
18253
+ this.props.updateChart(this.props.figureId, {
18254
18254
  title: ev.target.value,
18255
18255
  });
18256
18256
  }
18257
18257
  updateSelect(attr, ev) {
18258
- this.props.updateChart({
18258
+ this.props.updateChart(this.props.figureId, {
18259
18259
  [attr]: ev.target.value,
18260
18260
  });
18261
18261
  }
@@ -18288,7 +18288,7 @@ class GaugeChartConfigPanel extends owl.Component {
18288
18288
  this.dataRange = ranges[0];
18289
18289
  }
18290
18290
  updateDataRange() {
18291
- this.state.dataRangeDispatchResult = this.props.updateChart({
18291
+ this.state.dataRangeDispatchResult = this.props.updateChart(this.props.figureId, {
18292
18292
  dataRange: this.dataRange,
18293
18293
  });
18294
18294
  }
@@ -18346,12 +18346,12 @@ class GaugeChartDesignPanel extends owl.Component {
18346
18346
  }
18347
18347
  updateBackgroundColor(color) {
18348
18348
  this.state.openedMenu = undefined;
18349
- this.props.updateChart({
18349
+ this.props.updateChart(this.props.figureId, {
18350
18350
  background: color,
18351
18351
  });
18352
18352
  }
18353
18353
  updateTitle(ev) {
18354
- this.props.updateChart({
18354
+ this.props.updateChart(this.props.figureId, {
18355
18355
  title: ev.target.value,
18356
18356
  });
18357
18357
  }
@@ -18416,7 +18416,7 @@ class GaugeChartDesignPanel extends owl.Component {
18416
18416
  }
18417
18417
  }
18418
18418
  updateSectionRule(sectionRule) {
18419
- this.state.sectionRuleDispatchResult = this.props.updateChart({
18419
+ this.state.sectionRuleDispatchResult = this.props.updateChart(this.props.figureId, {
18420
18420
  sectionRule,
18421
18421
  });
18422
18422
  }
@@ -18440,17 +18440,17 @@ class LineConfigPanel extends LineBarPieConfigPanel {
18440
18440
  return false;
18441
18441
  }
18442
18442
  onUpdateLabelsAsText(ev) {
18443
- this.props.updateChart({
18443
+ this.props.updateChart(this.props.figureId, {
18444
18444
  labelsAsText: ev.target.checked,
18445
18445
  });
18446
18446
  }
18447
18447
  onUpdateStacked(ev) {
18448
- this.props.updateChart({
18448
+ this.props.updateChart(this.props.figureId, {
18449
18449
  stacked: ev.target.checked,
18450
18450
  });
18451
18451
  }
18452
18452
  onUpdateAggregated(ev) {
18453
- this.props.updateChart({
18453
+ this.props.updateChart(this.props.figureId, {
18454
18454
  aggregated: ev.target.checked,
18455
18455
  });
18456
18456
  }
@@ -18486,7 +18486,7 @@ class ScorecardChartConfigPanel extends owl.Component {
18486
18486
  this.keyValue = ranges[0];
18487
18487
  }
18488
18488
  updateKeyValueRange() {
18489
- this.state.keyValueDispatchResult = this.props.updateChart({
18489
+ this.state.keyValueDispatchResult = this.props.updateChart(this.props.figureId, {
18490
18490
  keyValue: this.keyValue,
18491
18491
  });
18492
18492
  }
@@ -18494,12 +18494,12 @@ class ScorecardChartConfigPanel extends owl.Component {
18494
18494
  this.baseline = ranges[0];
18495
18495
  }
18496
18496
  updateBaselineRange() {
18497
- this.state.baselineDispatchResult = this.props.updateChart({
18497
+ this.state.baselineDispatchResult = this.props.updateChart(this.props.figureId, {
18498
18498
  baseline: this.baseline,
18499
18499
  });
18500
18500
  }
18501
18501
  updateBaselineMode(ev) {
18502
- this.props.updateChart({ baselineMode: ev.target.value });
18502
+ this.props.updateChart(this.props.figureId, { baselineMode: ev.target.value });
18503
18503
  }
18504
18504
  }
18505
18505
  ScorecardChartConfigPanel.props = {
@@ -18518,12 +18518,12 @@ class ScorecardChartDesignPanel extends owl.Component {
18518
18518
  owl.useExternalListener(window, "click", this.closeMenus);
18519
18519
  }
18520
18520
  updateTitle(ev) {
18521
- this.props.updateChart({
18521
+ this.props.updateChart(this.props.figureId, {
18522
18522
  title: ev.target.value,
18523
18523
  });
18524
18524
  }
18525
18525
  updateBaselineDescr(ev) {
18526
- this.props.updateChart({ baselineDescr: ev.target.value });
18526
+ this.props.updateChart(this.props.figureId, { baselineDescr: ev.target.value });
18527
18527
  }
18528
18528
  toggleColorPicker(colorPickerId) {
18529
18529
  if (this.state.openedColorPicker === colorPickerId) {
@@ -18536,13 +18536,13 @@ class ScorecardChartDesignPanel extends owl.Component {
18536
18536
  setColor(color, colorPickerId) {
18537
18537
  switch (colorPickerId) {
18538
18538
  case "backgroundColor":
18539
- this.props.updateChart({ background: color });
18539
+ this.props.updateChart(this.props.figureId, { background: color });
18540
18540
  break;
18541
18541
  case "baselineColorDown":
18542
- this.props.updateChart({ baselineColorDown: color });
18542
+ this.props.updateChart(this.props.figureId, { baselineColorDown: color });
18543
18543
  break;
18544
18544
  case "baselineColorUp":
18545
- this.props.updateChart({ baselineColorUp: color });
18545
+ this.props.updateChart(this.props.figureId, { baselineColorUp: color });
18546
18546
  break;
18547
18547
  }
18548
18548
  this.closeMenus();
@@ -18607,13 +18607,9 @@ css /* scss */ `
18607
18607
  class ChartPanel extends owl.Component {
18608
18608
  static template = "o-spreadsheet-ChartPanel";
18609
18609
  state;
18610
- shouldUpdateChart = true;
18611
18610
  get figureId() {
18612
18611
  return this.state.figureId;
18613
18612
  }
18614
- get sheetId() {
18615
- return this.state.sheetId;
18616
- }
18617
18613
  setup() {
18618
18614
  const selectedFigureId = this.env.model.getters.getSelectedFigureId();
18619
18615
  if (!selectedFigureId) {
@@ -18623,17 +18619,11 @@ class ChartPanel extends owl.Component {
18623
18619
  this.state = owl.useState({
18624
18620
  panel: "configuration",
18625
18621
  figureId: selectedFigureId,
18626
- sheetId: this.env.model.getters.getActiveSheetId(),
18627
18622
  });
18628
18623
  owl.onWillUpdateProps(() => {
18629
18624
  const selectedFigureId = this.env.model.getters.getSelectedFigureId();
18630
18625
  if (selectedFigureId && selectedFigureId !== this.state.figureId) {
18631
18626
  this.state.figureId = selectedFigureId;
18632
- this.state.sheetId = this.env.model.getters.getActiveSheetId();
18633
- this.shouldUpdateChart = false;
18634
- }
18635
- else {
18636
- this.shouldUpdateChart = true;
18637
18627
  }
18638
18628
  if (!this.env.model.getters.isChartDefined(this.figureId)) {
18639
18629
  this.props.onCloseSidePanel();
@@ -18641,8 +18631,8 @@ class ChartPanel extends owl.Component {
18641
18631
  }
18642
18632
  });
18643
18633
  }
18644
- updateChart(updateDefinition) {
18645
- if (!this.shouldUpdateChart) {
18634
+ updateChart(figureId, updateDefinition) {
18635
+ if (figureId !== this.figureId) {
18646
18636
  return;
18647
18637
  }
18648
18638
  const definition = {
@@ -18651,8 +18641,8 @@ class ChartPanel extends owl.Component {
18651
18641
  };
18652
18642
  return this.env.model.dispatch("UPDATE_CHART", {
18653
18643
  definition,
18654
- id: this.figureId,
18655
- sheetId: this.sheetId,
18644
+ id: figureId,
18645
+ sheetId: this.env.model.getters.getFigureSheetId(figureId),
18656
18646
  });
18657
18647
  }
18658
18648
  onTypeChange(type) {
@@ -18664,7 +18654,7 @@ class ChartPanel extends owl.Component {
18664
18654
  this.env.model.dispatch("UPDATE_CHART", {
18665
18655
  definition,
18666
18656
  id: this.figureId,
18667
- sheetId: this.sheetId,
18657
+ sheetId: this.env.model.getters.getFigureSheetId(this.figureId),
18668
18658
  });
18669
18659
  }
18670
18660
  get chartPanel() {
@@ -24485,6 +24475,16 @@ const XLSX_INDEXED_COLORS = {
24485
24475
  63: "333333",
24486
24476
  64: "000000",
24487
24477
  65: "FFFFFF", // system background
24478
+ };
24479
+ const IMAGE_MIMETYPE_EXTENSION_MAPPING = {
24480
+ "image/avif": "avif",
24481
+ "image/bmp": "bmp",
24482
+ "image/gif": "gif",
24483
+ "image/vnd.microsoft.icon": "ico",
24484
+ "image/jpeg": "jpeg",
24485
+ "image/png": "png",
24486
+ "image/tiff": "tiff",
24487
+ "image/webp": "webp",
24488
24488
  };
24489
24489
 
24490
24490
  /**
@@ -26966,6 +26966,11 @@ function createOverride(partName, contentType) {
26966
26966
  <Override ContentType="${contentType}" PartName="${partName}" />
26967
26967
  `;
26968
26968
  }
26969
+ function createDefaultXMLElement(extension, contentType) {
26970
+ return escapeXml /*xml*/ `
26971
+ <Default Extension="${extension}" ContentType="${contentType}" />
26972
+ `;
26973
+ }
26969
26974
  function joinXmlNodes(xmlNodes) {
26970
26975
  return new XMLString(xmlNodes.join("\n"));
26971
26976
  }
@@ -41733,7 +41738,7 @@ class ImageProvider {
41733
41738
  const file = await this.getImageFromUser();
41734
41739
  const path = await this.fileStore.upload(file);
41735
41740
  const size = await this.getImageSize(path);
41736
- return { path, size };
41741
+ return { path, size, mimetype: file.type };
41737
41742
  }
41738
41743
  getImageFromUser() {
41739
41744
  return new Promise((resolve, reject) => {
@@ -46814,8 +46819,7 @@ function createWorksheets(data, construct) {
46814
46819
  // Figures and Charts
46815
46820
  let drawingNode = escapeXml ``;
46816
46821
  const drawingRelIds = [];
46817
- const charts = sheet.charts;
46818
- for (const chart of charts) {
46822
+ for (const chart of sheet.charts) {
46819
46823
  const xlsxChartId = convertChartId(chart.id);
46820
46824
  const chartRelId = addRelsToFile(construct.relsFiles, `xl/drawings/_rels/drawing${sheetIndex}.xml.rels`, {
46821
46825
  target: `../charts/chart${xlsxChartId}.xml`,
@@ -46824,20 +46828,27 @@ function createWorksheets(data, construct) {
46824
46828
  drawingRelIds.push(chartRelId);
46825
46829
  files.push(createXMLFile(createChart(chart, sheetIndex, data), `xl/charts/chart${xlsxChartId}.xml`, "chart"));
46826
46830
  }
46827
- const images = sheet.images;
46828
- for (const image of images) {
46831
+ for (const image of sheet.images) {
46832
+ const mimeType = image.data.mimetype;
46833
+ if (mimeType === undefined)
46834
+ continue;
46835
+ const extension = IMAGE_MIMETYPE_EXTENSION_MAPPING[mimeType];
46836
+ // only support exporting images with mimetypes specified in the mapping
46837
+ if (extension === undefined)
46838
+ continue;
46829
46839
  const xlsxImageId = convertImageId(image.id);
46840
+ let imageFileName = `image${xlsxImageId}.${extension}`;
46830
46841
  const imageRelId = addRelsToFile(construct.relsFiles, `xl/drawings/_rels/drawing${sheetIndex}.xml.rels`, {
46831
- target: `../media/image${xlsxImageId}`,
46842
+ target: `../media/${imageFileName}`,
46832
46843
  type: XLSX_RELATION_TYPE.image,
46833
46844
  });
46834
46845
  drawingRelIds.push(imageRelId);
46835
46846
  files.push({
46836
- path: `xl/media/image${xlsxImageId}`,
46837
- imagePath: image.data.path,
46847
+ path: `xl/media/${imageFileName}`,
46848
+ imageSrc: image.data.path,
46838
46849
  });
46839
46850
  }
46840
- const drawings = [...charts, ...images];
46851
+ const drawings = [...sheet.charts, ...sheet.images];
46841
46852
  if (drawings.length) {
46842
46853
  const drawingRelId = addRelsToFile(construct.relsFiles, `xl/worksheets/_rels/sheet${sheetIndex}.xml.rels`, {
46843
46854
  target: `../drawings/drawing${sheetIndex}.xml`,
@@ -46956,6 +46967,8 @@ function createRelsFiles(relsFiles) {
46956
46967
  }
46957
46968
  function createContentTypes(files) {
46958
46969
  const overrideNodes = [];
46970
+ // hard-code supported image mimetypes
46971
+ const imageDefaultNodes = Object.entries(IMAGE_MIMETYPE_EXTENSION_MAPPING).map(([mimetype, extension]) => createDefaultXMLElement(extension, mimetype));
46959
46972
  for (const file of files) {
46960
46973
  if ("contentType" in file && file.contentType) {
46961
46974
  overrideNodes.push(createOverride("/" + file.path, CONTENT_TYPES[file.contentType]));
@@ -46971,6 +46984,7 @@ function createContentTypes(files) {
46971
46984
  ];
46972
46985
  const xml = escapeXml /*xml*/ `
46973
46986
  <Types xmlns="${NAMESPACE["Types"]}">
46987
+ ${joinXmlNodes(Object.values(imageDefaultNodes))}
46974
46988
  <Default ${formatAttributes(relsAttributes)} />
46975
46989
  <Default ${formatAttributes(xmlAttributes)} />
46976
46990
  ${joinXmlNodes(overrideNodes)}
@@ -47583,6 +47597,6 @@ exports.setTranslationMethod = setTranslationMethod;
47583
47597
  exports.tokenize = tokenize;
47584
47598
 
47585
47599
 
47586
- __info__.version = '16.3.1';
47587
- __info__.date = '2023-05-25T13:00:27.320Z';
47588
- __info__.hash = 'b3cfd2c';
47600
+ __info__.version = '16.3.2';
47601
+ __info__.date = '2023-06-02T10:13:46.734Z';
47602
+ __info__.hash = '69a4378';
@@ -297,7 +297,7 @@ interface XLSXExportXMLFile {
297
297
  }
298
298
  interface XLSXExportImageFile {
299
299
  path: string;
300
- imagePath: string;
300
+ imageSrc: string;
301
301
  }
302
302
  interface XLSXExport {
303
303
  name: string;
@@ -574,6 +574,7 @@ declare type ResizeDirection = -1 | 0 | 1;
574
574
  interface Image {
575
575
  path: string;
576
576
  size: FigureSize;
577
+ mimetype?: string;
577
578
  }
578
579
 
579
580
  interface CellData {
@@ -5026,7 +5027,7 @@ declare class SelectionInput extends Component<Props$D, SpreadsheetChildEnv> {
5026
5027
  interface Props$C {
5027
5028
  figureId: UID;
5028
5029
  definition: LineChartDefinition | BarChartDefinition | PieChartDefinition;
5029
- updateChart: (definition: Partial<LineChartDefinition | BarChartDefinition | PieChartDefinition>) => DispatchResult;
5030
+ updateChart: (figureId: UID, definition: Partial<LineChartDefinition | BarChartDefinition | PieChartDefinition>) => DispatchResult;
5030
5031
  }
5031
5032
  declare class LineBarPieConfigPanel extends Component<Props$C, SpreadsheetChildEnv> {
5032
5033
  static template: string;
@@ -5173,7 +5174,7 @@ declare class ColorPickerWidget extends Component<Props$B, SpreadsheetChildEnv>
5173
5174
  interface Props$A {
5174
5175
  figureId: UID;
5175
5176
  definition: LineChartDefinition | BarChartDefinition | PieChartDefinition;
5176
- updateChart: (definition: Partial<LineChartDefinition | BarChartDefinition | PieChartDefinition>) => CommandResult | CommandResult[];
5177
+ updateChart: (figureId: UID, definition: Partial<LineChartDefinition | BarChartDefinition | PieChartDefinition>) => CommandResult | CommandResult[];
5177
5178
  }
5178
5179
  declare class LineBarPieDesignPanel extends Component<Props$A, SpreadsheetChildEnv> {
5179
5180
  static template: string;
@@ -5192,7 +5193,7 @@ declare class LineBarPieDesignPanel extends Component<Props$A, SpreadsheetChildE
5192
5193
  interface Props$z {
5193
5194
  figureId: UID;
5194
5195
  definition: GaugeChartDefinition;
5195
- updateChart: (definition: Partial<GaugeChartDefinition>) => DispatchResult;
5196
+ updateChart: (figureId: UID, definition: Partial<GaugeChartDefinition>) => DispatchResult;
5196
5197
  }
5197
5198
  declare class GaugeChartConfigPanel extends Component<Props$z, SpreadsheetChildEnv> {
5198
5199
  static template: string;
@@ -5211,7 +5212,7 @@ declare type GaugeMenu = "backgroundColor" | "sectionColor-lowerColor" | "sectio
5211
5212
  interface Props$y {
5212
5213
  figureId: UID;
5213
5214
  definition: GaugeChartDefinition;
5214
- updateChart: (definition: Partial<GaugeChartDefinition>) => DispatchResult;
5215
+ updateChart: (figureId: UID, definition: Partial<GaugeChartDefinition>) => DispatchResult;
5215
5216
  }
5216
5217
  declare class GaugeChartDesignPanel extends Component<Props$y, SpreadsheetChildEnv> {
5217
5218
  static template: string;
@@ -5248,7 +5249,7 @@ declare class LineConfigPanel extends LineBarPieConfigPanel {
5248
5249
  interface Props$x {
5249
5250
  figureId: UID;
5250
5251
  definition: ScorecardChartDefinition;
5251
- updateChart: (definition: Partial<ScorecardChartDefinition>) => DispatchResult;
5252
+ updateChart: (figureId: UID, definition: Partial<ScorecardChartDefinition>) => DispatchResult;
5252
5253
  }
5253
5254
  declare class ScorecardChartConfigPanel extends Component<Props$x, SpreadsheetChildEnv> {
5254
5255
  static template: string;
@@ -5272,7 +5273,7 @@ declare type ColorPickerId = undefined | "backgroundColor" | "baselineColorUp" |
5272
5273
  interface Props$w {
5273
5274
  figureId: UID;
5274
5275
  definition: ScorecardChartDefinition;
5275
- updateChart: (definition: Partial<ScorecardChartDefinition>) => DispatchResult;
5276
+ updateChart: (figureId: UID, definition: Partial<ScorecardChartDefinition>) => DispatchResult;
5276
5277
  }
5277
5278
  declare class ScorecardChartDesignPanel extends Component<Props$w, SpreadsheetChildEnv> {
5278
5279
  static template: string;
@@ -7018,11 +7019,9 @@ interface Props {
7018
7019
  declare class ChartPanel extends Component<Props, SpreadsheetChildEnv> {
7019
7020
  static template: string;
7020
7021
  private state;
7021
- private shouldUpdateChart;
7022
7022
  get figureId(): UID;
7023
- get sheetId(): UID;
7024
7023
  setup(): void;
7025
- updateChart<T extends ChartDefinition>(updateDefinition: Partial<T>): DispatchResult | undefined;
7024
+ updateChart<T extends ChartDefinition>(figureId: UID, updateDefinition: Partial<T>): DispatchResult | undefined;
7026
7025
  onTypeChange(type: ChartType): void;
7027
7026
  get chartPanel(): ChartSidePanel;
7028
7027
  private getChartDefinition;