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