@odoo/o-spreadsheet 16.0.1 → 16.0.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.
@@ -2803,7 +2803,7 @@ class ChartJsComponent extends owl.Component {
2803
2803
  return `background-color: ${this.background}`;
2804
2804
  }
2805
2805
  get chartRuntime() {
2806
- const runtime = this.env.model.getters.getChartRuntime(this.env.model.getters.getActiveSheetId(), this.props.figure.id);
2806
+ const runtime = this.env.model.getters.getChartRuntime(this.props.figure.id);
2807
2807
  if (!("chartJsConfig" in runtime)) {
2808
2808
  throw new Error("Unsupported chart runtime");
2809
2809
  }
@@ -3172,6 +3172,7 @@ exports.CommandResult = void 0;
3172
3172
  CommandResult[CommandResult["DuplicatedFigureId"] = 81] = "DuplicatedFigureId";
3173
3173
  CommandResult[CommandResult["InvalidSelectionStep"] = 82] = "InvalidSelectionStep";
3174
3174
  CommandResult[CommandResult["DuplicatedChartId"] = 83] = "DuplicatedChartId";
3175
+ CommandResult[CommandResult["ChartDoesNotExist"] = 84] = "ChartDoesNotExist";
3175
3176
  })(exports.CommandResult || (exports.CommandResult = {}));
3176
3177
 
3177
3178
  var DIRECTION;
@@ -8640,7 +8641,7 @@ GaugeChartDesignPanel.components = { ColorPicker };
8640
8641
 
8641
8642
  class LineConfigPanel extends LineBarPieConfigPanel {
8642
8643
  get canTreatLabelsAsText() {
8643
- const chart = this.env.model.getters.getChart(this.props.sheetId, this.props.figureId);
8644
+ const chart = this.env.model.getters.getChart(this.props.figureId);
8644
8645
  if (chart && chart instanceof LineChart) {
8645
8646
  return canChartParseLabels(chart, this.env.model.getters);
8646
8647
  }
@@ -8833,7 +8834,7 @@ class ChartPanel extends owl.Component {
8833
8834
  else {
8834
8835
  this.shouldUpdateChart = true;
8835
8836
  }
8836
- if (!this.env.model.getters.isChartDefined(this.sheetId, this.figureId)) {
8837
+ if (!this.env.model.getters.isChartDefined(this.figureId)) {
8837
8838
  this.props.onCloseSidePanel();
8838
8839
  return;
8839
8840
  }
@@ -8854,7 +8855,7 @@ class ChartPanel extends owl.Component {
8854
8855
  });
8855
8856
  }
8856
8857
  onTypeChange(type) {
8857
- const context = this.env.model.getters.getContextCreationChart(this.sheetId, this.figureId);
8858
+ const context = this.env.model.getters.getContextCreationChart(this.figureId);
8858
8859
  if (!context) {
8859
8860
  throw new Error("Chart not defined.");
8860
8861
  }
@@ -8866,7 +8867,7 @@ class ChartPanel extends owl.Component {
8866
8867
  });
8867
8868
  }
8868
8869
  get chartPanel() {
8869
- const type = this.env.model.getters.getChartType(this.sheetId, this.figureId);
8870
+ const type = this.env.model.getters.getChartType(this.figureId);
8870
8871
  if (!type) {
8871
8872
  throw new Error("Chart not defined.");
8872
8873
  }
@@ -8876,8 +8877,8 @@ class ChartPanel extends owl.Component {
8876
8877
  }
8877
8878
  return chartPanel;
8878
8879
  }
8879
- getChartDefinition() {
8880
- return this.env.model.getters.getChartDefinition(this.sheetId, this.figureId);
8880
+ getChartDefinition(figureId = this.figureId) {
8881
+ return this.env.model.getters.getChartDefinition(figureId);
8881
8882
  }
8882
8883
  get chartTypes() {
8883
8884
  return getChartTypes();
@@ -10013,7 +10014,7 @@ class ScorecardChart extends owl.Component {
10013
10014
  this.ctx = document.createElement("canvas").getContext("2d");
10014
10015
  }
10015
10016
  get runtime() {
10016
- return this.env.model.getters.getChartRuntime(this.env.model.getters.getActiveSheetId(), this.props.figure.id);
10017
+ return this.env.model.getters.getChartRuntime(this.props.figure.id);
10017
10018
  }
10018
10019
  get title() {
10019
10020
  return this.runtime.title;
@@ -10243,7 +10244,7 @@ class ChartFigure extends owl.Component {
10243
10244
  return registry;
10244
10245
  }
10245
10246
  get chartType() {
10246
- return this.env.model.getters.getChartType(this.env.model.getters.getActiveSheetId(), this.props.figure.id);
10247
+ return this.env.model.getters.getChartType(this.props.figure.id);
10247
10248
  }
10248
10249
  onContextMenu(ev) {
10249
10250
  const position = {
@@ -26270,13 +26271,7 @@ function load(data, verboseImport) {
26270
26271
  data = migrate(data);
26271
26272
  }
26272
26273
  }
26273
- // sanity check: try to fix missing fields/corrupted state by providing
26274
- // sensible default values
26275
- data = Object.assign(createEmptyWorkbookData(), data, { version: CURRENT_VERSION });
26276
- data.sheets = data.sheets.map((s, i) => Object.assign(createEmptySheet(`Sheet${i + 1}`, `Sheet${i + 1}`), s));
26277
- if (data.sheets.length === 0) {
26278
- data.sheets.push(createEmptySheet(INITIAL_SHEET_ID, "Sheet1"));
26279
- }
26274
+ data = repairData(data);
26280
26275
  return data;
26281
26276
  }
26282
26277
  function migrate(data) {
@@ -26514,6 +26509,48 @@ const MIGRATIONS = [
26514
26509
  },
26515
26510
  },
26516
26511
  ];
26512
+ /**
26513
+ * This function is used to repair faulty data independently of the migration.
26514
+ */
26515
+ function repairData(data) {
26516
+ data = forceUnicityOfFigure(data);
26517
+ data = setDefaults(data);
26518
+ return data;
26519
+ }
26520
+ /**
26521
+ * Force the unicity of figure ids accross sheets
26522
+ */
26523
+ function forceUnicityOfFigure(data) {
26524
+ if (data.uniqueFigureIds) {
26525
+ return data;
26526
+ }
26527
+ const figureIds = new Set();
26528
+ const uuidGenerator = new UuidGenerator();
26529
+ for (const sheet of data.sheets || []) {
26530
+ for (const figure of sheet.figures || []) {
26531
+ if (figureIds.has(figure.id)) {
26532
+ figure.id += uuidGenerator.uuidv4();
26533
+ }
26534
+ figureIds.add(figure.id);
26535
+ }
26536
+ }
26537
+ data.uniqueFigureIds = true;
26538
+ return data;
26539
+ }
26540
+ /**
26541
+ * sanity check: try to fix missing fields/corrupted state by providing
26542
+ * sensible default values
26543
+ */
26544
+ function setDefaults(data) {
26545
+ data = Object.assign(createEmptyWorkbookData(), data, { version: CURRENT_VERSION });
26546
+ data.sheets = data.sheets
26547
+ ? data.sheets.map((s, i) => Object.assign(createEmptySheet(`Sheet${i + 1}`, `Sheet${i + 1}`), s))
26548
+ : [];
26549
+ if (data.sheets.length === 0) {
26550
+ data.sheets.push(createEmptySheet(INITIAL_SHEET_ID, "Sheet1"));
26551
+ }
26552
+ return data;
26553
+ }
26517
26554
  /**
26518
26555
  * The goal of this function is to repair corrupted/wrong initial messages caused by
26519
26556
  * a bug.
@@ -26652,6 +26689,7 @@ function createEmptyWorkbookData(sheetName = "Sheet1") {
26652
26689
  formats: {},
26653
26690
  borders: {},
26654
26691
  revisionId: DEFAULT_REVISION_ID,
26692
+ uniqueFigureIds: true,
26655
26693
  };
26656
26694
  return data;
26657
26695
  }
@@ -27574,10 +27612,8 @@ class ChartPlugin extends CorePlugin {
27574
27612
  this.validateChartDefinition = (cmd) => validateChartDefinition(this, cmd.definition);
27575
27613
  }
27576
27614
  adaptRanges(applyChange) {
27577
- for (const sheetId of Object.keys(this.charts)) {
27578
- for (const [chartId, chart] of Object.entries(this.charts[sheetId] || {})) {
27579
- this.history.update("charts", sheetId, chartId, chart === null || chart === void 0 ? void 0 : chart.updateRanges(applyChange));
27580
- }
27615
+ for (const [chartId, chart] of Object.entries(this.charts)) {
27616
+ this.history.update("charts", chartId, chart === null || chart === void 0 ? void 0 : chart.updateRanges(applyChange));
27581
27617
  }
27582
27618
  }
27583
27619
  // ---------------------------------------------------------------------------
@@ -27588,20 +27624,20 @@ class ChartPlugin extends CorePlugin {
27588
27624
  case "CREATE_CHART":
27589
27625
  return this.checkValidations(cmd, this.chainValidations(this.validateChartDefinition, this.checkChartDuplicate));
27590
27626
  case "UPDATE_CHART":
27591
- return this.validateChartDefinition(cmd);
27627
+ return this.checkValidations(cmd, this.chainValidations(this.validateChartDefinition, this.checkChartExists));
27592
27628
  default:
27593
27629
  return 0 /* CommandResult.Success */;
27594
27630
  }
27595
27631
  }
27596
27632
  handle(cmd) {
27597
- var _a, _b;
27633
+ var _a;
27598
27634
  switch (cmd.type) {
27599
27635
  case "CREATE_CHART":
27600
27636
  this.addFigure(cmd.id, cmd.sheetId, cmd.position, cmd.size);
27601
- this.addChart(cmd.id, cmd.sheetId, cmd.definition);
27637
+ this.addChart(cmd.id, cmd.definition);
27602
27638
  break;
27603
27639
  case "UPDATE_CHART": {
27604
- this.addChart(cmd.id, cmd.sheetId, cmd.definition);
27640
+ this.addChart(cmd.id, cmd.definition);
27605
27641
  break;
27606
27642
  }
27607
27643
  case "DUPLICATE_SHEET": {
@@ -27610,7 +27646,7 @@ class ChartPlugin extends CorePlugin {
27610
27646
  if (fig.tag === "chart") {
27611
27647
  const figureIdBase = fig.id.split(FIGURE_ID_SPLITTER).pop();
27612
27648
  const duplicatedFigureId = `${cmd.sheetIdTo}${FIGURE_ID_SPLITTER}${figureIdBase}`;
27613
- const chart = (_b = (_a = this.charts[cmd.sheetId]) === null || _a === void 0 ? void 0 : _a[fig.id]) === null || _b === void 0 ? void 0 : _b.copyForSheetId(cmd.sheetIdTo);
27649
+ const chart = (_a = this.charts[fig.id]) === null || _a === void 0 ? void 0 : _a.copyForSheetId(cmd.sheetIdTo);
27614
27650
  if (chart) {
27615
27651
  this.dispatch("CREATE_CHART", {
27616
27652
  id: duplicatedFigureId,
@@ -27625,41 +27661,44 @@ class ChartPlugin extends CorePlugin {
27625
27661
  break;
27626
27662
  }
27627
27663
  case "DELETE_FIGURE":
27628
- this.history.update("charts", cmd.sheetId, cmd.id, undefined);
27664
+ this.history.update("charts", cmd.id, undefined);
27629
27665
  break;
27630
27666
  case "DELETE_SHEET":
27631
- this.history.update("charts", cmd.sheetId, undefined);
27667
+ for (let id of this.getChartIds(cmd.sheetId)) {
27668
+ this.history.update("charts", id, undefined);
27669
+ }
27632
27670
  break;
27633
27671
  }
27634
27672
  }
27635
27673
  // ---------------------------------------------------------------------------
27636
27674
  // Getters
27637
27675
  // ---------------------------------------------------------------------------
27638
- getContextCreationChart(sheetId, figureId) {
27639
- var _a, _b;
27640
- return (_b = (_a = this.charts[sheetId]) === null || _a === void 0 ? void 0 : _a[figureId]) === null || _b === void 0 ? void 0 : _b.getContextCreation();
27641
- }
27642
- getChart(sheetId, figureId) {
27676
+ getContextCreationChart(figureId) {
27643
27677
  var _a;
27644
- return (_a = this.charts[sheetId]) === null || _a === void 0 ? void 0 : _a[figureId];
27678
+ return (_a = this.charts[figureId]) === null || _a === void 0 ? void 0 : _a.getContextCreation();
27645
27679
  }
27646
- getChartType(sheetId, figureId) {
27647
- var _a, _b;
27648
- const type = (_b = (_a = this.charts[sheetId]) === null || _a === void 0 ? void 0 : _a[figureId]) === null || _b === void 0 ? void 0 : _b.type;
27680
+ getChart(figureId) {
27681
+ return this.charts[figureId];
27682
+ }
27683
+ getChartType(figureId) {
27684
+ var _a;
27685
+ const type = (_a = this.charts[figureId]) === null || _a === void 0 ? void 0 : _a.type;
27649
27686
  if (!type) {
27650
27687
  throw new Error("Chart not defined.");
27651
27688
  }
27652
27689
  return type;
27653
27690
  }
27654
- isChartDefined(sheetId, figureId) {
27655
- return figureId in (this.charts[sheetId] || {});
27691
+ isChartDefined(figureId) {
27692
+ return figureId in this.charts && this.charts !== undefined;
27656
27693
  }
27657
27694
  getChartIds(sheetId) {
27658
- return Object.keys(this.charts[sheetId] || {});
27695
+ return Object.entries(this.charts)
27696
+ .filter(([, chart]) => (chart === null || chart === void 0 ? void 0 : chart.sheetId) === sheetId)
27697
+ .map(([id]) => id);
27659
27698
  }
27660
- getChartDefinition(sheetId, figureId) {
27661
- var _a, _b;
27662
- const definition = (_b = (_a = this.charts[sheetId]) === null || _a === void 0 ? void 0 : _a[figureId]) === null || _b === void 0 ? void 0 : _b.getDefinition();
27699
+ getChartDefinition(figureId) {
27700
+ var _a;
27701
+ const definition = (_a = this.charts[figureId]) === null || _a === void 0 ? void 0 : _a.getDefinition();
27663
27702
  if (!definition) {
27664
27703
  throw new Error(`There is no chart with the given figureId: ${figureId}`);
27665
27704
  }
@@ -27671,28 +27710,35 @@ class ChartPlugin extends CorePlugin {
27671
27710
  import(data) {
27672
27711
  for (let sheet of data.sheets) {
27673
27712
  if (sheet.figures) {
27674
- const charts = {};
27675
27713
  for (let figure of sheet.figures) {
27676
27714
  // TODO:
27677
27715
  // figure data should be external IMO => chart should be in sheet.chart
27678
27716
  // instead of in figure.data
27679
27717
  if (figure.tag === "chart") {
27680
- charts[figure.id] = this.createChart(figure.id, figure.data, sheet.id);
27718
+ this.charts[figure.id] = this.createChart(figure.id, figure.data, sheet.id);
27681
27719
  }
27682
27720
  }
27683
- this.charts[sheet.id] = charts;
27684
27721
  }
27685
27722
  }
27686
27723
  }
27687
27724
  export(data) {
27725
+ var _a;
27688
27726
  if (data.sheets) {
27689
27727
  for (let sheet of data.sheets) {
27690
27728
  // TODO This code is false, if two plugins want ot insert figures on the sheet, it will crash !
27691
27729
  const sheetFigures = this.getters.getFigures(sheet.id);
27692
- const figures = sheetFigures;
27693
- for (let figure of figures) {
27730
+ const figures = [];
27731
+ for (let sheetFigure of sheetFigures) {
27732
+ const figure = sheetFigure;
27694
27733
  if (figure && figure.tag === "chart") {
27695
- figure.data = this.getChartDefinition(sheet.id, figure.id);
27734
+ const data = (_a = this.charts[figure.id]) === null || _a === void 0 ? void 0 : _a.getDefinition();
27735
+ if (data) {
27736
+ figure.data = data;
27737
+ figures.push(figure);
27738
+ }
27739
+ }
27740
+ else {
27741
+ figures.push(figure);
27696
27742
  }
27697
27743
  }
27698
27744
  sheet.figures = figures;
@@ -27700,13 +27746,13 @@ class ChartPlugin extends CorePlugin {
27700
27746
  }
27701
27747
  }
27702
27748
  exportForExcel(data) {
27703
- var _a, _b;
27749
+ var _a;
27704
27750
  for (let sheet of data.sheets) {
27705
27751
  const sheetFigures = this.getters.getFigures(sheet.id);
27706
27752
  const figures = [];
27707
27753
  for (let figure of sheetFigures) {
27708
27754
  if (figure && figure.tag === "chart") {
27709
- const figureData = (_b = (_a = this.charts[sheet.id]) === null || _a === void 0 ? void 0 : _a[figure.id]) === null || _b === void 0 ? void 0 : _b.getDefinitionForExcel();
27755
+ const figureData = (_a = this.charts[figure.id]) === null || _a === void 0 ? void 0 : _a.getDefinitionForExcel();
27710
27756
  if (figureData) {
27711
27757
  figures.push({
27712
27758
  ...figure,
@@ -27745,15 +27791,21 @@ class ChartPlugin extends CorePlugin {
27745
27791
  * Add a chart in the local state. If a chart already exists, this chart is
27746
27792
  * replaced
27747
27793
  */
27748
- addChart(id, sheetId, definition) {
27749
- this.history.update("charts", sheetId, id, this.createChart(id, definition, sheetId));
27794
+ addChart(id, definition) {
27795
+ const sheetId = this.getters.getFigureSheetId(id);
27796
+ if (sheetId) {
27797
+ this.history.update("charts", id, this.createChart(id, definition, sheetId));
27798
+ }
27750
27799
  }
27751
27800
  checkChartDuplicate(cmd) {
27752
- var _a;
27753
- if ((_a = this.charts[cmd.sheetId]) === null || _a === void 0 ? void 0 : _a[cmd.id]) {
27754
- return 83 /* CommandResult.DuplicatedChartId */;
27755
- }
27756
- return 0 /* CommandResult.Success */;
27801
+ return this.getters.getFigureSheetId(cmd.id)
27802
+ ? 83 /* CommandResult.DuplicatedChartId */
27803
+ : 0 /* CommandResult.Success */;
27804
+ }
27805
+ checkChartExists(cmd) {
27806
+ return this.getters.getFigureSheetId(cmd.id)
27807
+ ? 0 /* CommandResult.Success */
27808
+ : 84 /* CommandResult.ChartDoesNotExist */;
27757
27809
  }
27758
27810
  }
27759
27811
  ChartPlugin.getters = [
@@ -28134,7 +28186,7 @@ class FigurePlugin extends CorePlugin {
28134
28186
  allowDispatch(cmd) {
28135
28187
  switch (cmd.type) {
28136
28188
  case "CREATE_FIGURE":
28137
- return this.checkFigureDuplicate(cmd.sheetId, cmd.figure.id);
28189
+ return this.checkFigureDuplicate(cmd.figure.id);
28138
28190
  case "UPDATE_FIGURE":
28139
28191
  case "DELETE_FIGURE":
28140
28192
  return this.checkFigureExists(cmd.sheetId, cmd.id);
@@ -28200,9 +28252,8 @@ class FigurePlugin extends CorePlugin {
28200
28252
  }
28201
28253
  return 0 /* CommandResult.Success */;
28202
28254
  }
28203
- checkFigureDuplicate(sheetId, figureId) {
28204
- var _a;
28205
- if ((_a = this.figures[sheetId]) === null || _a === void 0 ? void 0 : _a[figureId]) {
28255
+ checkFigureDuplicate(figureId) {
28256
+ if (Object.values(this.figures).find((sheet) => sheet === null || sheet === void 0 ? void 0 : sheet[figureId])) {
28206
28257
  return 81 /* CommandResult.DuplicatedFigureId */;
28207
28258
  }
28208
28259
  return 0 /* CommandResult.Success */;
@@ -28217,6 +28268,9 @@ class FigurePlugin extends CorePlugin {
28217
28268
  var _a;
28218
28269
  return (_a = this.figures[sheetId]) === null || _a === void 0 ? void 0 : _a[figureId];
28219
28270
  }
28271
+ getFigureSheetId(figureId) {
28272
+ return Object.keys(this.figures).find((sheetId) => { var _a; return ((_a = this.figures[sheetId]) === null || _a === void 0 ? void 0 : _a[figureId]) !== undefined; });
28273
+ }
28220
28274
  // ---------------------------------------------------------------------------
28221
28275
  // Import/Export
28222
28276
  // ---------------------------------------------------------------------------
@@ -28241,7 +28295,7 @@ class FigurePlugin extends CorePlugin {
28241
28295
  this.export(data);
28242
28296
  }
28243
28297
  }
28244
- FigurePlugin.getters = ["getFigures", "getFigure"];
28298
+ FigurePlugin.getters = ["getFigures", "getFigure", "getFigureSheetId"];
28245
28299
 
28246
28300
  class FilterTable {
28247
28301
  constructor(zone) {
@@ -31533,7 +31587,7 @@ class ClipboardFigureState {
31533
31587
  throw new Error(`No figure for the given id: ${copiedFigureId}`);
31534
31588
  }
31535
31589
  this.copiedFigure = { ...figure };
31536
- const chart = getters.getChart(this.sheetId, copiedFigureId);
31590
+ const chart = getters.getChart(copiedFigureId);
31537
31591
  if (!chart) {
31538
31592
  throw new Error(`No chart for the given id: ${copiedFigureId}`);
31539
31593
  }
@@ -31985,9 +32039,7 @@ class CustomColorsPlugin extends UIPlugin {
31985
32039
  return formatColors.filter(isDefined$1);
31986
32040
  }
31987
32041
  getChartColors(sheetId) {
31988
- const charts = this.getters
31989
- .getChartIds(sheetId)
31990
- .map((cid) => this.getters.getChart(sheetId, cid));
32042
+ const charts = this.getters.getChartIds(sheetId).map((cid) => this.getters.getChart(cid));
31991
32043
  let chartsColors = new Set();
31992
32044
  for (let chart of charts) {
31993
32045
  if (chart === undefined) {
@@ -32254,37 +32306,34 @@ class EvaluationChartPlugin extends UIPlugin {
32254
32306
  invalidateCFEvaluationCommands.has(cmd.type) ||
32255
32307
  cmd.type === "EVALUATE_CELLS" ||
32256
32308
  cmd.type === "UPDATE_CELL") {
32257
- for (const sheetId in this.charts) {
32258
- for (const chartId in this.charts[sheetId]) {
32259
- this.charts[sheetId][chartId] = undefined;
32260
- }
32309
+ for (const chartId in this.charts) {
32310
+ this.charts[chartId] = undefined;
32261
32311
  }
32262
32312
  }
32263
32313
  switch (cmd.type) {
32264
32314
  case "UPDATE_CHART":
32265
32315
  case "CREATE_CHART":
32266
32316
  case "DELETE_FIGURE":
32267
- if (this.charts[cmd.sheetId]) {
32268
- this.charts[cmd.sheetId][cmd.id] = undefined;
32269
- }
32317
+ this.charts[cmd.id] = undefined;
32270
32318
  break;
32271
32319
  case "DELETE_SHEET":
32272
- delete this.charts[cmd.sheetId];
32320
+ for (let chartId in this.charts) {
32321
+ if (!this.getters.isChartDefined(chartId)) {
32322
+ this.charts[chartId] = undefined;
32323
+ }
32324
+ }
32273
32325
  break;
32274
32326
  }
32275
32327
  }
32276
- getChartRuntime(sheetId, figureId) {
32277
- var _a;
32278
- if (!((_a = this.charts[sheetId]) === null || _a === void 0 ? void 0 : _a[figureId])) {
32279
- const chart = this.getters.getChart(sheetId, figureId);
32328
+ getChartRuntime(figureId) {
32329
+ if (!this.charts[figureId]) {
32330
+ const chart = this.getters.getChart(figureId);
32280
32331
  if (!chart) {
32281
32332
  throw new Error(`No chart for the given id: ${figureId}`);
32282
32333
  }
32283
- if (!this.charts[sheetId])
32284
- this.charts[sheetId] = {};
32285
- this.charts[sheetId][figureId] = this.createRuntimeChart(chart);
32334
+ this.charts[figureId] = this.createRuntimeChart(chart);
32286
32335
  }
32287
- return this.charts[sheetId][figureId];
32336
+ return this.charts[figureId];
32288
32337
  }
32289
32338
  /**
32290
32339
  * Get the background color of a chart based on the color of the first cell of the main range
@@ -42406,6 +42455,6 @@ exports.setTranslationMethod = setTranslationMethod;
42406
42455
  exports.tokenize = tokenize;
42407
42456
 
42408
42457
 
42409
- __info__.version = '16.0.1';
42410
- __info__.date = '2023-03-01T14:43:41.736Z';
42411
- __info__.hash = '2ac9223';
42458
+ __info__.version = '16.0.2';
42459
+ __info__.date = '2023-03-06T07:17:51.313Z';
42460
+ __info__.hash = '6b4d816';
@@ -810,6 +810,7 @@ interface WorkbookData {
810
810
  };
811
811
  };
812
812
  revisionId: UID;
813
+ uniqueFigureIds: boolean;
813
814
  }
814
815
  interface ExcelWorkbookData extends WorkbookData {
815
816
  sheets: ExcelSheetData[];
@@ -2175,7 +2176,8 @@ declare const enum CommandResult {
2175
2176
  NonContinuousTargets = 80,
2176
2177
  DuplicatedFigureId = 81,
2177
2178
  InvalidSelectionStep = 82,
2178
- DuplicatedChartId = 83
2179
+ DuplicatedChartId = 83,
2180
+ ChartDoesNotExist = 84
2179
2181
  }
2180
2182
  interface CommandHandler<T> {
2181
2183
  allowDispatch(command: T): CommandResult | CommandResult[];
@@ -3182,24 +3184,22 @@ declare abstract class AbstractChart {
3182
3184
  * This plugin manages charts
3183
3185
  * */
3184
3186
  interface ChartState {
3185
- readonly charts: {
3186
- [sheetId: UID]: Record<UID, AbstractChart | undefined> | undefined;
3187
- };
3187
+ readonly charts: Record<UID, AbstractChart | undefined>;
3188
3188
  }
3189
3189
  declare class ChartPlugin extends CorePlugin<ChartState> implements ChartState {
3190
3190
  static getters: readonly ["isChartDefined", "getChartDefinition", "getChartType", "getChartIds", "getChart", "getContextCreationChart"];
3191
- readonly charts: ChartState["charts"];
3191
+ readonly charts: Record<UID, AbstractChart | undefined>;
3192
3192
  private createChart;
3193
3193
  private validateChartDefinition;
3194
3194
  adaptRanges(applyChange: ApplyRangeChange): void;
3195
3195
  allowDispatch(cmd: Command): CommandResult | CommandResult[];
3196
3196
  handle(cmd: CoreCommand): void;
3197
- getContextCreationChart(sheetId: UID, figureId: UID): ChartCreationContext | undefined;
3198
- getChart(sheetId: UID, figureId: UID): AbstractChart | undefined;
3199
- getChartType(sheetId: UID, figureId: UID): ChartType;
3200
- isChartDefined(sheetId: UID, figureId: UID): boolean;
3197
+ getContextCreationChart(figureId: UID): ChartCreationContext | undefined;
3198
+ getChart(figureId: UID): AbstractChart | undefined;
3199
+ getChartType(figureId: UID): ChartType;
3200
+ isChartDefined(figureId: UID): boolean;
3201
3201
  getChartIds(sheetId: UID): string[];
3202
- getChartDefinition(sheetId: UID, figureId: UID): ChartDefinition;
3202
+ getChartDefinition(figureId: UID): ChartDefinition;
3203
3203
  import(data: WorkbookData): void;
3204
3204
  export(data: WorkbookData): void;
3205
3205
  exportForExcel(data: ExcelWorkbookData): void;
@@ -3213,6 +3213,7 @@ declare class ChartPlugin extends CorePlugin<ChartState> implements ChartState {
3213
3213
  */
3214
3214
  private addChart;
3215
3215
  private checkChartDuplicate;
3216
+ private checkChartExists;
3216
3217
  }
3217
3218
 
3218
3219
  interface ConditionalFormatState {
@@ -3263,12 +3264,14 @@ declare class ConditionalFormatPlugin extends CorePlugin<ConditionalFormatState>
3263
3264
 
3264
3265
  interface FigureState {
3265
3266
  readonly figures: {
3266
- [sheet: UID]: Record<UID, Figure | undefined> | undefined;
3267
+ [sheet: string]: Record<UID, Figure | undefined> | undefined;
3267
3268
  };
3268
3269
  }
3269
3270
  declare class FigurePlugin extends CorePlugin<FigureState> implements FigureState {
3270
- static getters: readonly ["getFigures", "getFigure"];
3271
- readonly figures: FigureState["figures"];
3271
+ static getters: readonly ["getFigures", "getFigure", "getFigureSheetId"];
3272
+ readonly figures: {
3273
+ [sheet: string]: Record<UID, Figure | undefined> | undefined;
3274
+ };
3272
3275
  allowDispatch(cmd: CoreCommand): CommandResult;
3273
3276
  handle(cmd: CoreCommand): void;
3274
3277
  private updateFigure;
@@ -3279,6 +3282,7 @@ declare class FigurePlugin extends CorePlugin<FigureState> implements FigureStat
3279
3282
  private checkFigureDuplicate;
3280
3283
  getFigures(sheetId: UID): Figure[];
3281
3284
  getFigure(sheetId: string, figureId: string): Figure | undefined;
3285
+ getFigureSheetId(figureId: string): UID | undefined;
3282
3286
  import(data: WorkbookData): void;
3283
3287
  export(data: WorkbookData): void;
3284
3288
  exportForExcel(data: ExcelWorkbookData): void;
@@ -3877,12 +3881,10 @@ declare class EvaluationPlugin extends UIPlugin {
3877
3881
 
3878
3882
  declare class EvaluationChartPlugin extends UIPlugin {
3879
3883
  static getters: readonly ["getChartRuntime", "getBackgroundOfSingleCellChart"];
3880
- readonly charts: {
3881
- [sheetId: UID]: Record<UID, ChartRuntime | undefined> | undefined;
3882
- };
3884
+ readonly charts: Record<UID, ChartRuntime | undefined>;
3883
3885
  private createRuntimeChart;
3884
3886
  handle(cmd: Command): void;
3885
- getChartRuntime(sheetId: UID, figureId: UID): ChartRuntime;
3887
+ getChartRuntime(figureId: UID): ChartRuntime;
3886
3888
  /**
3887
3889
  * Get the background color of a chart based on the color of the first cell of the main range
3888
3890
  * of the chart. In order of priority, it will return :
@@ -4850,7 +4852,6 @@ declare class SelectionInput extends Component<Props$y, SpreadsheetChildEnv> {
4850
4852
  }
4851
4853
 
4852
4854
  interface Props$x {
4853
- sheetId: UID;
4854
4855
  figureId: UID;
4855
4856
  definition: LineChartDefinition | BarChartDefinition | PieChartDefinition;
4856
4857
  updateChart: (definition: Partial<LineChartDefinition | BarChartDefinition | PieChartDefinition>) => DispatchResult;
@@ -5125,7 +5126,7 @@ declare class ChartJsComponent extends Component<Props$r, SpreadsheetChildEnv> {
5125
5126
  static template: string;
5126
5127
  private canvas;
5127
5128
  private chart?;
5128
- get background(): Color;
5129
+ get background(): string;
5129
5130
  get canvasStyle(): string;
5130
5131
  get chartRuntime(): ChartJSRuntime;
5131
5132
  setup(): void;