@odoo/o-spreadsheet 16.2.7 → 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.
@@ -16863,7 +16863,7 @@ class LineBarPieConfigPanel extends owl.Component {
16863
16863
  return !!((_a = this.state.labelsDispatchResult) === null || _a === void 0 ? void 0 : _a.isCancelledBecause(33 /* CommandResult.InvalidLabelRange */));
16864
16864
  }
16865
16865
  onUpdateDataSetsHaveTitle(ev) {
16866
- this.props.updateChart({
16866
+ this.props.updateChart(this.props.figureId, {
16867
16867
  dataSetsHaveTitle: ev.target.checked,
16868
16868
  });
16869
16869
  }
@@ -16875,7 +16875,7 @@ class LineBarPieConfigPanel extends owl.Component {
16875
16875
  this.dataSeriesRanges = ranges;
16876
16876
  }
16877
16877
  onDataSeriesConfirmed() {
16878
- this.state.datasetDispatchResult = this.props.updateChart({
16878
+ this.state.datasetDispatchResult = this.props.updateChart(this.props.figureId, {
16879
16879
  dataSets: this.dataSeriesRanges,
16880
16880
  });
16881
16881
  }
@@ -16887,12 +16887,12 @@ class LineBarPieConfigPanel extends owl.Component {
16887
16887
  this.labelRange = ranges[0];
16888
16888
  }
16889
16889
  onLabelRangeConfirmed() {
16890
- this.state.labelsDispatchResult = this.props.updateChart({
16890
+ this.state.labelsDispatchResult = this.props.updateChart(this.props.figureId, {
16891
16891
  labelRange: this.labelRange,
16892
16892
  });
16893
16893
  }
16894
16894
  onUpdateAggregated(ev) {
16895
- this.props.updateChart({
16895
+ this.props.updateChart(this.props.figureId, {
16896
16896
  aggregated: ev.target.checked,
16897
16897
  });
16898
16898
  }
@@ -16907,12 +16907,12 @@ LineBarPieConfigPanel.props = {
16907
16907
 
16908
16908
  class BarConfigPanel extends LineBarPieConfigPanel {
16909
16909
  onUpdateStacked(ev) {
16910
- this.props.updateChart({
16910
+ this.props.updateChart(this.props.figureId, {
16911
16911
  stacked: ev.target.checked,
16912
16912
  });
16913
16913
  }
16914
16914
  onUpdateAggregated(ev) {
16915
- this.props.updateChart({
16915
+ this.props.updateChart(this.props.figureId, {
16916
16916
  aggregated: ev.target.checked,
16917
16917
  });
16918
16918
  }
@@ -17255,17 +17255,17 @@ class LineBarPieDesignPanel extends owl.Component {
17255
17255
  this.state.fillColorTool = !this.state.fillColorTool;
17256
17256
  }
17257
17257
  updateBackgroundColor(color) {
17258
- this.props.updateChart({
17258
+ this.props.updateChart(this.props.figureId, {
17259
17259
  background: color,
17260
17260
  });
17261
17261
  }
17262
17262
  updateTitle(ev) {
17263
- this.props.updateChart({
17263
+ this.props.updateChart(this.props.figureId, {
17264
17264
  title: ev.target.value,
17265
17265
  });
17266
17266
  }
17267
17267
  updateSelect(attr, ev) {
17268
- this.props.updateChart({
17268
+ this.props.updateChart(this.props.figureId, {
17269
17269
  [attr]: ev.target.value,
17270
17270
  });
17271
17271
  }
@@ -17303,7 +17303,7 @@ class GaugeChartConfigPanel extends owl.Component {
17303
17303
  this.dataRange = ranges[0];
17304
17304
  }
17305
17305
  updateDataRange() {
17306
- this.state.dataRangeDispatchResult = this.props.updateChart({
17306
+ this.state.dataRangeDispatchResult = this.props.updateChart(this.props.figureId, {
17307
17307
  dataRange: this.dataRange,
17308
17308
  });
17309
17309
  }
@@ -17365,12 +17365,12 @@ class GaugeChartDesignPanel extends owl.Component {
17365
17365
  }
17366
17366
  updateBackgroundColor(color) {
17367
17367
  this.state.openedMenu = undefined;
17368
- this.props.updateChart({
17368
+ this.props.updateChart(this.props.figureId, {
17369
17369
  background: color,
17370
17370
  });
17371
17371
  }
17372
17372
  updateTitle(ev) {
17373
- this.props.updateChart({
17373
+ this.props.updateChart(this.props.figureId, {
17374
17374
  title: ev.target.value,
17375
17375
  });
17376
17376
  }
@@ -17439,7 +17439,7 @@ class GaugeChartDesignPanel extends owl.Component {
17439
17439
  }
17440
17440
  }
17441
17441
  updateSectionRule(sectionRule) {
17442
- this.state.sectionRuleDispatchResult = this.props.updateChart({
17442
+ this.state.sectionRuleDispatchResult = this.props.updateChart(this.props.figureId, {
17443
17443
  sectionRule,
17444
17444
  });
17445
17445
  }
@@ -17464,17 +17464,17 @@ class LineConfigPanel extends LineBarPieConfigPanel {
17464
17464
  return false;
17465
17465
  }
17466
17466
  onUpdateLabelsAsText(ev) {
17467
- this.props.updateChart({
17467
+ this.props.updateChart(this.props.figureId, {
17468
17468
  labelsAsText: ev.target.checked,
17469
17469
  });
17470
17470
  }
17471
17471
  onUpdateStacked(ev) {
17472
- this.props.updateChart({
17472
+ this.props.updateChart(this.props.figureId, {
17473
17473
  stacked: ev.target.checked,
17474
17474
  });
17475
17475
  }
17476
17476
  onUpdateAggregated(ev) {
17477
- this.props.updateChart({
17477
+ this.props.updateChart(this.props.figureId, {
17478
17478
  aggregated: ev.target.checked,
17479
17479
  });
17480
17480
  }
@@ -17515,7 +17515,7 @@ class ScorecardChartConfigPanel extends owl.Component {
17515
17515
  this.keyValue = ranges[0];
17516
17516
  }
17517
17517
  updateKeyValueRange() {
17518
- this.state.keyValueDispatchResult = this.props.updateChart({
17518
+ this.state.keyValueDispatchResult = this.props.updateChart(this.props.figureId, {
17519
17519
  keyValue: this.keyValue,
17520
17520
  });
17521
17521
  }
@@ -17523,12 +17523,12 @@ class ScorecardChartConfigPanel extends owl.Component {
17523
17523
  this.baseline = ranges[0];
17524
17524
  }
17525
17525
  updateBaselineRange() {
17526
- this.state.baselineDispatchResult = this.props.updateChart({
17526
+ this.state.baselineDispatchResult = this.props.updateChart(this.props.figureId, {
17527
17527
  baseline: this.baseline,
17528
17528
  });
17529
17529
  }
17530
17530
  updateBaselineMode(ev) {
17531
- this.props.updateChart({ baselineMode: ev.target.value });
17531
+ this.props.updateChart(this.props.figureId, { baselineMode: ev.target.value });
17532
17532
  }
17533
17533
  }
17534
17534
  ScorecardChartConfigPanel.template = "o-spreadsheet-ScorecardChartConfigPanel";
@@ -17550,12 +17550,12 @@ class ScorecardChartDesignPanel extends owl.Component {
17550
17550
  owl.useExternalListener(window, "click", this.closeMenus);
17551
17551
  }
17552
17552
  updateTitle(ev) {
17553
- this.props.updateChart({
17553
+ this.props.updateChart(this.props.figureId, {
17554
17554
  title: ev.target.value,
17555
17555
  });
17556
17556
  }
17557
17557
  updateBaselineDescr(ev) {
17558
- this.props.updateChart({ baselineDescr: ev.target.value });
17558
+ this.props.updateChart(this.props.figureId, { baselineDescr: ev.target.value });
17559
17559
  }
17560
17560
  toggleColorPicker(colorPickerId) {
17561
17561
  if (this.state.openedColorPicker === colorPickerId) {
@@ -17568,13 +17568,13 @@ class ScorecardChartDesignPanel extends owl.Component {
17568
17568
  setColor(color, colorPickerId) {
17569
17569
  switch (colorPickerId) {
17570
17570
  case "backgroundColor":
17571
- this.props.updateChart({ background: color });
17571
+ this.props.updateChart(this.props.figureId, { background: color });
17572
17572
  break;
17573
17573
  case "baselineColorDown":
17574
- this.props.updateChart({ baselineColorDown: color });
17574
+ this.props.updateChart(this.props.figureId, { baselineColorDown: color });
17575
17575
  break;
17576
17576
  case "baselineColorUp":
17577
- this.props.updateChart({ baselineColorUp: color });
17577
+ this.props.updateChart(this.props.figureId, { baselineColorUp: color });
17578
17578
  break;
17579
17579
  }
17580
17580
  this.closeMenus();
@@ -17639,16 +17639,9 @@ css /* scss */ `
17639
17639
  }
17640
17640
  `;
17641
17641
  class ChartPanel extends owl.Component {
17642
- constructor() {
17643
- super(...arguments);
17644
- this.shouldUpdateChart = true;
17645
- }
17646
17642
  get figureId() {
17647
17643
  return this.state.figureId;
17648
17644
  }
17649
- get sheetId() {
17650
- return this.state.sheetId;
17651
- }
17652
17645
  setup() {
17653
17646
  const selectedFigureId = this.env.model.getters.getSelectedFigureId();
17654
17647
  if (!selectedFigureId) {
@@ -17657,17 +17650,11 @@ class ChartPanel extends owl.Component {
17657
17650
  this.state = owl.useState({
17658
17651
  panel: "configuration",
17659
17652
  figureId: selectedFigureId,
17660
- sheetId: this.env.model.getters.getActiveSheetId(),
17661
17653
  });
17662
17654
  owl.onWillUpdateProps(() => {
17663
17655
  const selectedFigureId = this.env.model.getters.getSelectedFigureId();
17664
17656
  if (selectedFigureId && selectedFigureId !== this.state.figureId) {
17665
17657
  this.state.figureId = selectedFigureId;
17666
- this.state.sheetId = this.env.model.getters.getActiveSheetId();
17667
- this.shouldUpdateChart = false;
17668
- }
17669
- else {
17670
- this.shouldUpdateChart = true;
17671
17658
  }
17672
17659
  if (!this.env.model.getters.isChartDefined(this.figureId)) {
17673
17660
  this.props.onCloseSidePanel();
@@ -17675,8 +17662,8 @@ class ChartPanel extends owl.Component {
17675
17662
  }
17676
17663
  });
17677
17664
  }
17678
- updateChart(updateDefinition) {
17679
- if (!this.shouldUpdateChart) {
17665
+ updateChart(figureId, updateDefinition) {
17666
+ if (figureId !== this.figureId) {
17680
17667
  return;
17681
17668
  }
17682
17669
  const definition = {
@@ -17685,8 +17672,8 @@ class ChartPanel extends owl.Component {
17685
17672
  };
17686
17673
  return this.env.model.dispatch("UPDATE_CHART", {
17687
17674
  definition,
17688
- id: this.figureId,
17689
- sheetId: this.sheetId,
17675
+ id: figureId,
17676
+ sheetId: this.env.model.getters.getFigureSheetId(figureId),
17690
17677
  });
17691
17678
  }
17692
17679
  onTypeChange(type) {
@@ -17698,7 +17685,7 @@ class ChartPanel extends owl.Component {
17698
17685
  this.env.model.dispatch("UPDATE_CHART", {
17699
17686
  definition,
17700
17687
  id: this.figureId,
17701
- sheetId: this.sheetId,
17688
+ sheetId: this.env.model.getters.getFigureSheetId(this.figureId),
17702
17689
  });
17703
17690
  }
17704
17691
  get chartPanel() {
@@ -23068,6 +23055,16 @@ const XLSX_INDEXED_COLORS = {
23068
23055
  63: "333333",
23069
23056
  64: "000000",
23070
23057
  65: "FFFFFF", // system background
23058
+ };
23059
+ const IMAGE_MIMETYPE_EXTENSION_MAPPING = {
23060
+ "image/avif": "avif",
23061
+ "image/bmp": "bmp",
23062
+ "image/gif": "gif",
23063
+ "image/vnd.microsoft.icon": "ico",
23064
+ "image/jpeg": "jpeg",
23065
+ "image/png": "png",
23066
+ "image/tiff": "tiff",
23067
+ "image/webp": "webp",
23071
23068
  };
23072
23069
 
23073
23070
  /**
@@ -25504,6 +25501,11 @@ function createOverride(partName, contentType) {
25504
25501
  <Override ContentType="${contentType}" PartName="${partName}" />
25505
25502
  `;
25506
25503
  }
25504
+ function createDefaultXMLElement(extension, contentType) {
25505
+ return escapeXml /*xml*/ `
25506
+ <Default Extension="${extension}" ContentType="${contentType}" />
25507
+ `;
25508
+ }
25507
25509
  function joinXmlNodes(xmlNodes) {
25508
25510
  return new XMLString(xmlNodes.join("\n"));
25509
25511
  }
@@ -39565,7 +39567,7 @@ class ImageProvider {
39565
39567
  const file = await this.getImageFromUser();
39566
39568
  const path = await this.fileStore.upload(file);
39567
39569
  const size = await this.getImageSize(path);
39568
- return { path, size };
39570
+ return { path, size, mimetype: file.type };
39569
39571
  }
39570
39572
  getImageFromUser() {
39571
39573
  return new Promise((resolve, reject) => {
@@ -44631,8 +44633,7 @@ function createWorksheets(data, construct) {
44631
44633
  // Figures and Charts
44632
44634
  let drawingNode = escapeXml ``;
44633
44635
  const drawingRelIds = [];
44634
- const charts = sheet.charts;
44635
- for (const chart of charts) {
44636
+ for (const chart of sheet.charts) {
44636
44637
  const xlsxChartId = convertChartId(chart.id);
44637
44638
  const chartRelId = addRelsToFile(construct.relsFiles, `xl/drawings/_rels/drawing${sheetIndex}.xml.rels`, {
44638
44639
  target: `../charts/chart${xlsxChartId}.xml`,
@@ -44641,20 +44642,27 @@ function createWorksheets(data, construct) {
44641
44642
  drawingRelIds.push(chartRelId);
44642
44643
  files.push(createXMLFile(createChart(chart, sheetIndex, data), `xl/charts/chart${xlsxChartId}.xml`, "chart"));
44643
44644
  }
44644
- const images = sheet.images;
44645
- for (const image of images) {
44645
+ for (const image of sheet.images) {
44646
+ const mimeType = image.data.mimetype;
44647
+ if (mimeType === undefined)
44648
+ continue;
44649
+ const extension = IMAGE_MIMETYPE_EXTENSION_MAPPING[mimeType];
44650
+ // only support exporting images with mimetypes specified in the mapping
44651
+ if (extension === undefined)
44652
+ continue;
44646
44653
  const xlsxImageId = convertImageId(image.id);
44654
+ let imageFileName = `image${xlsxImageId}.${extension}`;
44647
44655
  const imageRelId = addRelsToFile(construct.relsFiles, `xl/drawings/_rels/drawing${sheetIndex}.xml.rels`, {
44648
- target: `../media/image${xlsxImageId}`,
44656
+ target: `../media/${imageFileName}`,
44649
44657
  type: XLSX_RELATION_TYPE.image,
44650
44658
  });
44651
44659
  drawingRelIds.push(imageRelId);
44652
44660
  files.push({
44653
- path: `xl/media/image${xlsxImageId}`,
44654
- imagePath: image.data.path,
44661
+ path: `xl/media/${imageFileName}`,
44662
+ imageSrc: image.data.path,
44655
44663
  });
44656
44664
  }
44657
- const drawings = [...charts, ...images];
44665
+ const drawings = [...sheet.charts, ...sheet.images];
44658
44666
  if (drawings.length) {
44659
44667
  const drawingRelId = addRelsToFile(construct.relsFiles, `xl/worksheets/_rels/sheet${sheetIndex}.xml.rels`, {
44660
44668
  target: `../drawings/drawing${sheetIndex}.xml`,
@@ -44773,6 +44781,8 @@ function createRelsFiles(relsFiles) {
44773
44781
  }
44774
44782
  function createContentTypes(files) {
44775
44783
  const overrideNodes = [];
44784
+ // hard-code supported image mimetypes
44785
+ const imageDefaultNodes = Object.entries(IMAGE_MIMETYPE_EXTENSION_MAPPING).map(([mimetype, extension]) => createDefaultXMLElement(extension, mimetype));
44776
44786
  for (const file of files) {
44777
44787
  if ("contentType" in file && file.contentType) {
44778
44788
  overrideNodes.push(createOverride("/" + file.path, CONTENT_TYPES[file.contentType]));
@@ -44780,6 +44790,7 @@ function createContentTypes(files) {
44780
44790
  }
44781
44791
  const xml = escapeXml /*xml*/ `
44782
44792
  <Types xmlns="${NAMESPACE["Types"]}">
44793
+ ${joinXmlNodes(Object.values(imageDefaultNodes))}
44783
44794
  <Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml" />
44784
44795
  <Default Extension="xml" ContentType="application/xml" />
44785
44796
  ${joinXmlNodes(overrideNodes)}
@@ -45339,6 +45350,6 @@ exports.setTranslationMethod = setTranslationMethod;
45339
45350
  exports.tokenize = tokenize;
45340
45351
 
45341
45352
 
45342
- __info__.version = '16.2.7';
45343
- __info__.date = '2023-05-25T12:56:32.163Z';
45344
- __info__.hash = '047a6d5';
45353
+ __info__.version = '16.2.8';
45354
+ __info__.date = '2023-06-02T10:12:43.068Z';
45355
+ __info__.hash = 'b474e62';
@@ -358,7 +358,7 @@ interface XLSXExportXMLFile {
358
358
  }
359
359
  interface XLSXExportImageFile {
360
360
  path: string;
361
- imagePath: string;
361
+ imageSrc: string;
362
362
  }
363
363
  interface XLSXExport {
364
364
  name: string;
@@ -635,6 +635,7 @@ declare type ResizeDirection = -1 | 0 | 1;
635
635
  interface Image {
636
636
  path: string;
637
637
  size: FigureSize;
638
+ mimetype?: string;
638
639
  }
639
640
 
640
641
  interface CellData {
@@ -4920,7 +4921,7 @@ declare class SelectionInput extends Component<Props$B, SpreadsheetChildEnv> {
4920
4921
  interface Props$A {
4921
4922
  figureId: UID;
4922
4923
  definition: LineChartDefinition | BarChartDefinition | PieChartDefinition;
4923
- updateChart: (definition: Partial<LineChartDefinition | BarChartDefinition | PieChartDefinition>) => DispatchResult;
4924
+ updateChart: (figureId: UID, definition: Partial<LineChartDefinition | BarChartDefinition | PieChartDefinition>) => DispatchResult;
4924
4925
  }
4925
4926
  declare class LineBarPieConfigPanel extends Component<Props$A, SpreadsheetChildEnv> {
4926
4927
  static template: string;
@@ -5065,7 +5066,7 @@ declare class ColorPickerWidget extends Component<Props$z, SpreadsheetChildEnv>
5065
5066
  interface Props$y {
5066
5067
  figureId: UID;
5067
5068
  definition: LineChartDefinition | BarChartDefinition | PieChartDefinition;
5068
- updateChart: (definition: Partial<LineChartDefinition | BarChartDefinition | PieChartDefinition>) => CommandResult | CommandResult[];
5069
+ updateChart: (figureId: UID, definition: Partial<LineChartDefinition | BarChartDefinition | PieChartDefinition>) => CommandResult | CommandResult[];
5069
5070
  }
5070
5071
  declare class LineBarPieDesignPanel extends Component<Props$y, SpreadsheetChildEnv> {
5071
5072
  static template: string;
@@ -5084,7 +5085,7 @@ declare class LineBarPieDesignPanel extends Component<Props$y, SpreadsheetChildE
5084
5085
  interface Props$x {
5085
5086
  figureId: UID;
5086
5087
  definition: GaugeChartDefinition;
5087
- updateChart: (definition: Partial<GaugeChartDefinition>) => DispatchResult;
5088
+ updateChart: (figureId: UID, definition: Partial<GaugeChartDefinition>) => DispatchResult;
5088
5089
  }
5089
5090
  declare class GaugeChartConfigPanel extends Component<Props$x, SpreadsheetChildEnv> {
5090
5091
  static template: string;
@@ -5103,7 +5104,7 @@ declare type GaugeMenu = "backgroundColor" | "sectionColor-lowerColor" | "sectio
5103
5104
  interface Props$w {
5104
5105
  figureId: UID;
5105
5106
  definition: GaugeChartDefinition;
5106
- updateChart: (definition: Partial<GaugeChartDefinition>) => DispatchResult;
5107
+ updateChart: (figureId: UID, definition: Partial<GaugeChartDefinition>) => DispatchResult;
5107
5108
  }
5108
5109
  declare class GaugeChartDesignPanel extends Component<Props$w, SpreadsheetChildEnv> {
5109
5110
  static template: string;
@@ -5140,7 +5141,7 @@ declare class LineConfigPanel extends LineBarPieConfigPanel {
5140
5141
  interface Props$v {
5141
5142
  figureId: UID;
5142
5143
  definition: ScorecardChartDefinition;
5143
- updateChart: (definition: Partial<ScorecardChartDefinition>) => DispatchResult;
5144
+ updateChart: (figureId: UID, definition: Partial<ScorecardChartDefinition>) => DispatchResult;
5144
5145
  }
5145
5146
  declare class ScorecardChartConfigPanel extends Component<Props$v, SpreadsheetChildEnv> {
5146
5147
  static template: string;
@@ -5164,7 +5165,7 @@ declare type ColorPickerId = undefined | "backgroundColor" | "baselineColorUp" |
5164
5165
  interface Props$u {
5165
5166
  figureId: UID;
5166
5167
  definition: ScorecardChartDefinition;
5167
- updateChart: (definition: Partial<ScorecardChartDefinition>) => DispatchResult;
5168
+ updateChart: (figureId: UID, definition: Partial<ScorecardChartDefinition>) => DispatchResult;
5168
5169
  }
5169
5170
  declare class ScorecardChartDesignPanel extends Component<Props$u, SpreadsheetChildEnv> {
5170
5171
  static template: string;
@@ -6571,11 +6572,9 @@ interface Props {
6571
6572
  declare class ChartPanel extends Component<Props, SpreadsheetChildEnv> {
6572
6573
  static template: string;
6573
6574
  private state;
6574
- private shouldUpdateChart;
6575
6575
  get figureId(): UID;
6576
- get sheetId(): UID;
6577
6576
  setup(): void;
6578
- updateChart<T extends ChartDefinition>(updateDefinition: Partial<T>): DispatchResult | undefined;
6577
+ updateChart<T extends ChartDefinition>(figureId: UID, updateDefinition: Partial<T>): DispatchResult | undefined;
6579
6578
  onTypeChange(type: ChartType): void;
6580
6579
  get chartPanel(): ChartSidePanel;
6581
6580
  private getChartDefinition;