@odoo/o-spreadsheet 16.1.2 → 16.1.4

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.
@@ -2827,7 +2827,7 @@ class ChartJsComponent extends owl.Component {
2827
2827
  return `background-color: ${this.background}`;
2828
2828
  }
2829
2829
  get chartRuntime() {
2830
- const runtime = this.env.model.getters.getChartRuntime(this.env.model.getters.getActiveSheetId(), this.props.figure.id);
2830
+ const runtime = this.env.model.getters.getChartRuntime(this.props.figure.id);
2831
2831
  if (!("chartJsConfig" in runtime)) {
2832
2832
  throw new Error("Unsupported chart runtime");
2833
2833
  }
@@ -3081,7 +3081,7 @@ class ScorecardChart$1 extends owl.Component {
3081
3081
  this.ctx = document.createElement("canvas").getContext("2d");
3082
3082
  }
3083
3083
  get runtime() {
3084
- return this.env.model.getters.getChartRuntime(this.env.model.getters.getActiveSheetId(), this.props.figure.id);
3084
+ return this.env.model.getters.getChartRuntime(this.props.figure.id);
3085
3085
  }
3086
3086
  get title() {
3087
3087
  return this.runtime.title;
@@ -3472,7 +3472,7 @@ exports.CommandResult = void 0;
3472
3472
  CommandResult[CommandResult["InvalidRange"] = 25] = "InvalidRange";
3473
3473
  CommandResult[CommandResult["InvalidZones"] = 26] = "InvalidZones";
3474
3474
  CommandResult[CommandResult["InvalidSheetId"] = 27] = "InvalidSheetId";
3475
- CommandResult[CommandResult["DuplicatedImageId"] = 28] = "DuplicatedImageId";
3475
+ CommandResult[CommandResult["InvalidFigureId"] = 28] = "InvalidFigureId";
3476
3476
  CommandResult[CommandResult["InputAlreadyFocused"] = 29] = "InputAlreadyFocused";
3477
3477
  CommandResult[CommandResult["MaximumRangesReached"] = 30] = "MaximumRangesReached";
3478
3478
  CommandResult[CommandResult["InvalidChartDefinition"] = 31] = "InvalidChartDefinition";
@@ -3529,6 +3529,7 @@ exports.CommandResult = void 0;
3529
3529
  CommandResult[CommandResult["DuplicatedFigureId"] = 82] = "DuplicatedFigureId";
3530
3530
  CommandResult[CommandResult["InvalidSelectionStep"] = 83] = "InvalidSelectionStep";
3531
3531
  CommandResult[CommandResult["DuplicatedChartId"] = 84] = "DuplicatedChartId";
3532
+ CommandResult[CommandResult["ChartDoesNotExist"] = 85] = "ChartDoesNotExist";
3532
3533
  })(exports.CommandResult || (exports.CommandResult = {}));
3533
3534
 
3534
3535
  var DIRECTION;
@@ -6069,7 +6070,7 @@ class ChartFigure extends owl.Component {
6069
6070
  return registry;
6070
6071
  }
6071
6072
  get chartType() {
6072
- return this.env.model.getters.getChartType(this.env.model.getters.getActiveSheetId(), this.props.figure.id);
6073
+ return this.env.model.getters.getChartType(this.props.figure.id);
6073
6074
  }
6074
6075
  onContextMenu(ev) {
6075
6076
  const position = {
@@ -18804,7 +18805,7 @@ class ImageFigure extends owl.Component {
18804
18805
  name: _lt("Reset size"),
18805
18806
  sequence: 3,
18806
18807
  action: () => {
18807
- const size = this.env.model.getters.getImage(this.env.model.getters.getActiveSheetId(), this.figureId).size;
18808
+ const size = this.env.model.getters.getImageSize(this.figureId);
18808
18809
  const { height, width } = getMaxFigureSize(this.env.model.getters, size);
18809
18810
  this.env.model.dispatch("UPDATE_FIGURE", {
18810
18811
  sheetId: this.env.model.getters.getActiveSheetId(),
@@ -18855,8 +18856,7 @@ class ImageFigure extends owl.Component {
18855
18856
  return this.props.figure.id;
18856
18857
  }
18857
18858
  get getImagePath() {
18858
- return this.env.model.getters.getImage(this.env.model.getters.getActiveSheetId(), this.figureId)
18859
- .path;
18859
+ return this.env.model.getters.getImagePath(this.figureId);
18860
18860
  }
18861
18861
  }
18862
18862
  ImageFigure.template = "o-spreadsheet-ImageFigure";
@@ -19811,7 +19811,6 @@ class LineBarPieConfigPanel extends owl.Component {
19811
19811
  LineBarPieConfigPanel.template = "o-spreadsheet-LineBarPieConfigPanel";
19812
19812
  LineBarPieConfigPanel.components = { SelectionInput };
19813
19813
  LineBarPieConfigPanel.props = {
19814
- sheetId: String,
19815
19814
  figureId: String,
19816
19815
  definition: Object,
19817
19816
  updateChart: Function,
@@ -20015,7 +20014,7 @@ class ColorPicker extends owl.Component {
20015
20014
  }
20016
20015
  onColorClick(color) {
20017
20016
  if (color) {
20018
- this.props.onColorPicked(color);
20017
+ this.props.onColorPicked(toHex(color));
20019
20018
  }
20020
20019
  }
20021
20020
  getCheckMarkColor() {
@@ -20030,8 +20029,10 @@ class ColorPicker extends owl.Component {
20030
20029
  this.state.isCurrentColorInvalid = true;
20031
20030
  return;
20032
20031
  }
20032
+ const color = toHex(this.state.currentColor);
20033
20033
  this.state.isCurrentColorInvalid = false;
20034
- this.props.onColorPicked(this.state.currentColor);
20034
+ this.props.onColorPicked(color);
20035
+ this.state.currentColor = color;
20035
20036
  }
20036
20037
  toggleColorPicker() {
20037
20038
  this.state.showGradient = !this.state.showGradient;
@@ -20141,7 +20142,6 @@ class GaugeChartConfigPanel extends owl.Component {
20141
20142
  GaugeChartConfigPanel.template = "o-spreadsheet-GaugeChartConfigPanel";
20142
20143
  GaugeChartConfigPanel.components = { SelectionInput };
20143
20144
  GaugeChartConfigPanel.props = {
20144
- sheetId: String,
20145
20145
  figureId: String,
20146
20146
  definition: Object,
20147
20147
  updateChart: Function,
@@ -20295,7 +20295,7 @@ GaugeChartDesignPanel.props = {
20295
20295
 
20296
20296
  class LineConfigPanel extends LineBarPieConfigPanel {
20297
20297
  get canTreatLabelsAsText() {
20298
- const chart = this.env.model.getters.getChart(this.props.sheetId, this.props.figureId);
20298
+ const chart = this.env.model.getters.getChart(this.props.figureId);
20299
20299
  if (chart && chart instanceof LineChart) {
20300
20300
  return canChartParseLabels(chart.labelRange, this.env.model.getters);
20301
20301
  }
@@ -20372,7 +20372,6 @@ class ScorecardChartConfigPanel extends owl.Component {
20372
20372
  ScorecardChartConfigPanel.template = "o-spreadsheet-ScorecardChartConfigPanel";
20373
20373
  ScorecardChartConfigPanel.components = { SelectionInput };
20374
20374
  ScorecardChartConfigPanel.props = {
20375
- sheetId: String,
20376
20375
  figureId: String,
20377
20376
  definition: Object,
20378
20377
  updateChart: Function,
@@ -20504,7 +20503,7 @@ class ChartPanel extends owl.Component {
20504
20503
  else {
20505
20504
  this.shouldUpdateChart = true;
20506
20505
  }
20507
- if (!this.env.model.getters.isChartDefined(this.sheetId, this.figureId)) {
20506
+ if (!this.env.model.getters.isChartDefined(this.figureId)) {
20508
20507
  this.props.onCloseSidePanel();
20509
20508
  return;
20510
20509
  }
@@ -20525,7 +20524,7 @@ class ChartPanel extends owl.Component {
20525
20524
  });
20526
20525
  }
20527
20526
  onTypeChange(type) {
20528
- const context = this.env.model.getters.getContextCreationChart(this.sheetId, this.figureId);
20527
+ const context = this.env.model.getters.getContextCreationChart(this.figureId);
20529
20528
  if (!context) {
20530
20529
  throw new Error("Chart not defined.");
20531
20530
  }
@@ -20537,7 +20536,7 @@ class ChartPanel extends owl.Component {
20537
20536
  });
20538
20537
  }
20539
20538
  get chartPanel() {
20540
- const type = this.env.model.getters.getChartType(this.sheetId, this.figureId);
20539
+ const type = this.env.model.getters.getChartType(this.figureId);
20541
20540
  if (!type) {
20542
20541
  throw new Error("Chart not defined.");
20543
20542
  }
@@ -20547,8 +20546,8 @@ class ChartPanel extends owl.Component {
20547
20546
  }
20548
20547
  return chartPanel;
20549
20548
  }
20550
- getChartDefinition() {
20551
- return this.env.model.getters.getChartDefinition(this.sheetId, this.figureId);
20549
+ getChartDefinition(figureId = this.figureId) {
20550
+ return this.env.model.getters.getChartDefinition(figureId);
20552
20551
  }
20553
20552
  get chartTypes() {
20554
20553
  return getChartTypes();
@@ -27107,13 +27106,7 @@ function load(data, verboseImport) {
27107
27106
  data = migrate(data);
27108
27107
  }
27109
27108
  }
27110
- // sanity check: try to fix missing fields/corrupted state by providing
27111
- // sensible default values
27112
- data = Object.assign(createEmptyWorkbookData(), data, { version: CURRENT_VERSION });
27113
- data.sheets = data.sheets.map((s, i) => Object.assign(createEmptySheet(`Sheet${i + 1}`, `Sheet${i + 1}`), s));
27114
- if (data.sheets.length === 0) {
27115
- data.sheets.push(createEmptySheet(INITIAL_SHEET_ID, "Sheet1"));
27116
- }
27109
+ data = repairData(data);
27117
27110
  return data;
27118
27111
  }
27119
27112
  function migrate(data) {
@@ -27351,6 +27344,48 @@ const MIGRATIONS = [
27351
27344
  },
27352
27345
  },
27353
27346
  ];
27347
+ /**
27348
+ * This function is used to repair faulty data independently of the migration.
27349
+ */
27350
+ function repairData(data) {
27351
+ data = forceUnicityOfFigure(data);
27352
+ data = setDefaults(data);
27353
+ return data;
27354
+ }
27355
+ /**
27356
+ * Force the unicity of figure ids accross sheets
27357
+ */
27358
+ function forceUnicityOfFigure(data) {
27359
+ if (data.uniqueFigureIds) {
27360
+ return data;
27361
+ }
27362
+ const figureIds = new Set();
27363
+ const uuidGenerator = new UuidGenerator();
27364
+ for (const sheet of data.sheets || []) {
27365
+ for (const figure of sheet.figures || []) {
27366
+ if (figureIds.has(figure.id)) {
27367
+ figure.id += uuidGenerator.uuidv4();
27368
+ }
27369
+ figureIds.add(figure.id);
27370
+ }
27371
+ }
27372
+ data.uniqueFigureIds = true;
27373
+ return data;
27374
+ }
27375
+ /**
27376
+ * sanity check: try to fix missing fields/corrupted state by providing
27377
+ * sensible default values
27378
+ */
27379
+ function setDefaults(data) {
27380
+ data = Object.assign(createEmptyWorkbookData(), data, { version: CURRENT_VERSION });
27381
+ data.sheets = data.sheets
27382
+ ? data.sheets.map((s, i) => Object.assign(createEmptySheet(`Sheet${i + 1}`, `Sheet${i + 1}`), s))
27383
+ : [];
27384
+ if (data.sheets.length === 0) {
27385
+ data.sheets.push(createEmptySheet(INITIAL_SHEET_ID, "Sheet1"));
27386
+ }
27387
+ return data;
27388
+ }
27354
27389
  /**
27355
27390
  * The goal of this function is to repair corrupted/wrong initial messages caused by
27356
27391
  * a bug.
@@ -27489,6 +27524,7 @@ function createEmptyWorkbookData(sheetName = "Sheet1") {
27489
27524
  formats: {},
27490
27525
  borders: {},
27491
27526
  revisionId: DEFAULT_REVISION_ID,
27527
+ uniqueFigureIds: true,
27492
27528
  };
27493
27529
  return data;
27494
27530
  }
@@ -28486,10 +28522,8 @@ class ChartPlugin extends CorePlugin {
28486
28522
  this.validateChartDefinition = (cmd) => validateChartDefinition(this, cmd.definition);
28487
28523
  }
28488
28524
  adaptRanges(applyChange) {
28489
- for (const sheetId of Object.keys(this.charts)) {
28490
- for (const [chartId, chart] of Object.entries(this.charts[sheetId] || {})) {
28491
- this.history.update("charts", sheetId, chartId, chart === null || chart === void 0 ? void 0 : chart.updateRanges(applyChange));
28492
- }
28525
+ for (const [chartId, chart] of Object.entries(this.charts)) {
28526
+ this.history.update("charts", chartId, chart === null || chart === void 0 ? void 0 : chart.updateRanges(applyChange));
28493
28527
  }
28494
28528
  }
28495
28529
  // ---------------------------------------------------------------------------
@@ -28500,20 +28534,20 @@ class ChartPlugin extends CorePlugin {
28500
28534
  case "CREATE_CHART":
28501
28535
  return this.checkValidations(cmd, this.chainValidations(this.validateChartDefinition, this.checkChartDuplicate));
28502
28536
  case "UPDATE_CHART":
28503
- return this.validateChartDefinition(cmd);
28537
+ return this.checkValidations(cmd, this.chainValidations(this.validateChartDefinition, this.checkChartExists));
28504
28538
  default:
28505
28539
  return 0 /* CommandResult.Success */;
28506
28540
  }
28507
28541
  }
28508
28542
  handle(cmd) {
28509
- var _a, _b;
28543
+ var _a;
28510
28544
  switch (cmd.type) {
28511
28545
  case "CREATE_CHART":
28512
28546
  this.addFigure(cmd.id, cmd.sheetId, cmd.position, cmd.size);
28513
- this.addChart(cmd.id, cmd.sheetId, cmd.definition);
28547
+ this.addChart(cmd.id, cmd.definition);
28514
28548
  break;
28515
28549
  case "UPDATE_CHART": {
28516
- this.addChart(cmd.id, cmd.sheetId, cmd.definition);
28550
+ this.addChart(cmd.id, cmd.definition);
28517
28551
  break;
28518
28552
  }
28519
28553
  case "DUPLICATE_SHEET": {
@@ -28522,7 +28556,7 @@ class ChartPlugin extends CorePlugin {
28522
28556
  if (fig.tag === "chart") {
28523
28557
  const figureIdBase = fig.id.split(FIGURE_ID_SPLITTER).pop();
28524
28558
  const duplicatedFigureId = `${cmd.sheetIdTo}${FIGURE_ID_SPLITTER}${figureIdBase}`;
28525
- 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);
28559
+ const chart = (_a = this.charts[fig.id]) === null || _a === void 0 ? void 0 : _a.copyForSheetId(cmd.sheetIdTo);
28526
28560
  if (chart) {
28527
28561
  this.dispatch("CREATE_CHART", {
28528
28562
  id: duplicatedFigureId,
@@ -28537,41 +28571,44 @@ class ChartPlugin extends CorePlugin {
28537
28571
  break;
28538
28572
  }
28539
28573
  case "DELETE_FIGURE":
28540
- this.history.update("charts", cmd.sheetId, cmd.id, undefined);
28574
+ this.history.update("charts", cmd.id, undefined);
28541
28575
  break;
28542
28576
  case "DELETE_SHEET":
28543
- this.history.update("charts", cmd.sheetId, undefined);
28577
+ for (let id of this.getChartIds(cmd.sheetId)) {
28578
+ this.history.update("charts", id, undefined);
28579
+ }
28544
28580
  break;
28545
28581
  }
28546
28582
  }
28547
28583
  // ---------------------------------------------------------------------------
28548
28584
  // Getters
28549
28585
  // ---------------------------------------------------------------------------
28550
- getContextCreationChart(sheetId, figureId) {
28551
- var _a, _b;
28552
- return (_b = (_a = this.charts[sheetId]) === null || _a === void 0 ? void 0 : _a[figureId]) === null || _b === void 0 ? void 0 : _b.getContextCreation();
28553
- }
28554
- getChart(sheetId, figureId) {
28586
+ getContextCreationChart(figureId) {
28555
28587
  var _a;
28556
- return (_a = this.charts[sheetId]) === null || _a === void 0 ? void 0 : _a[figureId];
28588
+ return (_a = this.charts[figureId]) === null || _a === void 0 ? void 0 : _a.getContextCreation();
28557
28589
  }
28558
- getChartType(sheetId, figureId) {
28559
- var _a, _b;
28560
- const type = (_b = (_a = this.charts[sheetId]) === null || _a === void 0 ? void 0 : _a[figureId]) === null || _b === void 0 ? void 0 : _b.type;
28590
+ getChart(figureId) {
28591
+ return this.charts[figureId];
28592
+ }
28593
+ getChartType(figureId) {
28594
+ var _a;
28595
+ const type = (_a = this.charts[figureId]) === null || _a === void 0 ? void 0 : _a.type;
28561
28596
  if (!type) {
28562
28597
  throw new Error("Chart not defined.");
28563
28598
  }
28564
28599
  return type;
28565
28600
  }
28566
- isChartDefined(sheetId, figureId) {
28567
- return figureId in (this.charts[sheetId] || {});
28601
+ isChartDefined(figureId) {
28602
+ return figureId in this.charts && this.charts !== undefined;
28568
28603
  }
28569
28604
  getChartIds(sheetId) {
28570
- return Object.keys(this.charts[sheetId] || {});
28605
+ return Object.entries(this.charts)
28606
+ .filter(([, chart]) => (chart === null || chart === void 0 ? void 0 : chart.sheetId) === sheetId)
28607
+ .map(([id]) => id);
28571
28608
  }
28572
- getChartDefinition(sheetId, figureId) {
28573
- var _a, _b;
28574
- const definition = (_b = (_a = this.charts[sheetId]) === null || _a === void 0 ? void 0 : _a[figureId]) === null || _b === void 0 ? void 0 : _b.getDefinition();
28609
+ getChartDefinition(figureId) {
28610
+ var _a;
28611
+ const definition = (_a = this.charts[figureId]) === null || _a === void 0 ? void 0 : _a.getDefinition();
28575
28612
  if (!definition) {
28576
28613
  throw new Error(`There is no chart with the given figureId: ${figureId}`);
28577
28614
  }
@@ -28583,28 +28620,35 @@ class ChartPlugin extends CorePlugin {
28583
28620
  import(data) {
28584
28621
  for (let sheet of data.sheets) {
28585
28622
  if (sheet.figures) {
28586
- const charts = {};
28587
28623
  for (let figure of sheet.figures) {
28588
28624
  // TODO:
28589
28625
  // figure data should be external IMO => chart should be in sheet.chart
28590
28626
  // instead of in figure.data
28591
28627
  if (figure.tag === "chart") {
28592
- charts[figure.id] = this.createChart(figure.id, figure.data, sheet.id);
28628
+ this.charts[figure.id] = this.createChart(figure.id, figure.data, sheet.id);
28593
28629
  }
28594
28630
  }
28595
- this.charts[sheet.id] = charts;
28596
28631
  }
28597
28632
  }
28598
28633
  }
28599
28634
  export(data) {
28635
+ var _a;
28600
28636
  if (data.sheets) {
28601
28637
  for (let sheet of data.sheets) {
28602
28638
  // TODO This code is false, if two plugins want ot insert figures on the sheet, it will crash !
28603
28639
  const sheetFigures = this.getters.getFigures(sheet.id);
28604
- const figures = sheetFigures;
28605
- for (let figure of figures) {
28640
+ const figures = [];
28641
+ for (let sheetFigure of sheetFigures) {
28642
+ const figure = sheetFigure;
28606
28643
  if (figure && figure.tag === "chart") {
28607
- figure.data = this.getChartDefinition(sheet.id, figure.id);
28644
+ const data = (_a = this.charts[figure.id]) === null || _a === void 0 ? void 0 : _a.getDefinition();
28645
+ if (data) {
28646
+ figure.data = data;
28647
+ figures.push(figure);
28648
+ }
28649
+ }
28650
+ else {
28651
+ figures.push(figure);
28608
28652
  }
28609
28653
  }
28610
28654
  sheet.figures = figures;
@@ -28612,13 +28656,13 @@ class ChartPlugin extends CorePlugin {
28612
28656
  }
28613
28657
  }
28614
28658
  exportForExcel(data) {
28615
- var _a, _b;
28659
+ var _a;
28616
28660
  for (let sheet of data.sheets) {
28617
28661
  const sheetFigures = this.getters.getFigures(sheet.id);
28618
28662
  const figures = [];
28619
28663
  for (let figure of sheetFigures) {
28620
28664
  if (figure && figure.tag === "chart") {
28621
- 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();
28665
+ const figureData = (_a = this.charts[figure.id]) === null || _a === void 0 ? void 0 : _a.getDefinitionForExcel();
28622
28666
  if (figureData) {
28623
28667
  figures.push({
28624
28668
  ...figure,
@@ -28657,15 +28701,21 @@ class ChartPlugin extends CorePlugin {
28657
28701
  * Add a chart in the local state. If a chart already exists, this chart is
28658
28702
  * replaced
28659
28703
  */
28660
- addChart(id, sheetId, definition) {
28661
- this.history.update("charts", sheetId, id, this.createChart(id, definition, sheetId));
28704
+ addChart(id, definition) {
28705
+ const sheetId = this.getters.getFigureSheetId(id);
28706
+ if (sheetId) {
28707
+ this.history.update("charts", id, this.createChart(id, definition, sheetId));
28708
+ }
28662
28709
  }
28663
28710
  checkChartDuplicate(cmd) {
28664
- var _a;
28665
- if ((_a = this.charts[cmd.sheetId]) === null || _a === void 0 ? void 0 : _a[cmd.id]) {
28666
- return 84 /* CommandResult.DuplicatedChartId */;
28667
- }
28668
- return 0 /* CommandResult.Success */;
28711
+ return this.getters.getFigureSheetId(cmd.id)
28712
+ ? 84 /* CommandResult.DuplicatedChartId */
28713
+ : 0 /* CommandResult.Success */;
28714
+ }
28715
+ checkChartExists(cmd) {
28716
+ return this.getters.getFigureSheetId(cmd.id)
28717
+ ? 0 /* CommandResult.Success */
28718
+ : 85 /* CommandResult.ChartDoesNotExist */;
28669
28719
  }
28670
28720
  }
28671
28721
  ChartPlugin.getters = [
@@ -29046,7 +29096,7 @@ class FigurePlugin extends CorePlugin {
29046
29096
  allowDispatch(cmd) {
29047
29097
  switch (cmd.type) {
29048
29098
  case "CREATE_FIGURE":
29049
- return this.checkFigureDuplicate(cmd.sheetId, cmd.figure.id);
29099
+ return this.checkFigureDuplicate(cmd.figure.id);
29050
29100
  case "UPDATE_FIGURE":
29051
29101
  case "DELETE_FIGURE":
29052
29102
  return this.checkFigureExists(cmd.sheetId, cmd.id);
@@ -29112,9 +29162,8 @@ class FigurePlugin extends CorePlugin {
29112
29162
  }
29113
29163
  return 0 /* CommandResult.Success */;
29114
29164
  }
29115
- checkFigureDuplicate(sheetId, figureId) {
29116
- var _a;
29117
- if ((_a = this.figures[sheetId]) === null || _a === void 0 ? void 0 : _a[figureId]) {
29165
+ checkFigureDuplicate(figureId) {
29166
+ if (Object.values(this.figures).find((sheet) => sheet === null || sheet === void 0 ? void 0 : sheet[figureId])) {
29118
29167
  return 82 /* CommandResult.DuplicatedFigureId */;
29119
29168
  }
29120
29169
  return 0 /* CommandResult.Success */;
@@ -29129,6 +29178,9 @@ class FigurePlugin extends CorePlugin {
29129
29178
  var _a;
29130
29179
  return (_a = this.figures[sheetId]) === null || _a === void 0 ? void 0 : _a[figureId];
29131
29180
  }
29181
+ getFigureSheetId(figureId) {
29182
+ return Object.keys(this.figures).find((sheetId) => { var _a; return ((_a = this.figures[sheetId]) === null || _a === void 0 ? void 0 : _a[figureId]) !== undefined; });
29183
+ }
29132
29184
  // ---------------------------------------------------------------------------
29133
29185
  // Import/Export
29134
29186
  // ---------------------------------------------------------------------------
@@ -29153,7 +29205,7 @@ class FigurePlugin extends CorePlugin {
29153
29205
  this.export(data);
29154
29206
  }
29155
29207
  }
29156
- FigurePlugin.getters = ["getFigures", "getFigure"];
29208
+ FigurePlugin.getters = ["getFigures", "getFigure", "getFigureSheetId"];
29157
29209
 
29158
29210
  class FilterTable {
29159
29211
  constructor(zone) {
@@ -29880,7 +29932,7 @@ class ImagePlugin extends CorePlugin {
29880
29932
  switch (cmd.type) {
29881
29933
  case "CREATE_IMAGE":
29882
29934
  if (this.getters.getFigure(cmd.sheetId, cmd.figureId)) {
29883
- return 28 /* CommandResult.DuplicatedImageId */;
29935
+ return 28 /* CommandResult.InvalidFigureId */;
29884
29936
  }
29885
29937
  return 0 /* CommandResult.Success */;
29886
29938
  default:
@@ -29900,7 +29952,7 @@ class ImagePlugin extends CorePlugin {
29900
29952
  if (fig.tag === "image") {
29901
29953
  const figureIdBase = fig.id.split(FIGURE_ID_SPLITTER).pop();
29902
29954
  const duplicatedFigureId = `${cmd.sheetIdTo}${FIGURE_ID_SPLITTER}${figureIdBase}`;
29903
- const image = this.getImage(cmd.sheetId, fig.id);
29955
+ const image = this.getImage(fig.id);
29904
29956
  if (image) {
29905
29957
  const size = { width: fig.width, height: fig.height };
29906
29958
  this.dispatch("CREATE_IMAGE", {
@@ -29938,13 +29990,19 @@ class ImagePlugin extends CorePlugin {
29938
29990
  // ---------------------------------------------------------------------------
29939
29991
  // Getters
29940
29992
  // ---------------------------------------------------------------------------
29941
- getImage(sheetId, figureId) {
29942
- var _a;
29943
- const image = (_a = this.images[sheetId]) === null || _a === void 0 ? void 0 : _a[figureId];
29944
- if (!image) {
29945
- throw new Error(`There is no image with the given figureId: ${figureId}`);
29993
+ getImage(figureId) {
29994
+ for (const sheet of Object.values(this.images)) {
29995
+ if (sheet && sheet[figureId]) {
29996
+ return sheet[figureId];
29997
+ }
29946
29998
  }
29947
- return image;
29999
+ throw new Error(`There is no image with the given figureId: ${figureId}`);
30000
+ }
30001
+ getImagePath(figureId) {
30002
+ return this.getImage(figureId).path;
30003
+ }
30004
+ getImageSize(figureId) {
30005
+ return this.getImage(figureId).size;
29948
30006
  }
29949
30007
  // ---------------------------------------------------------------------------
29950
30008
  // Private
@@ -29986,7 +30044,7 @@ class ImagePlugin extends CorePlugin {
29986
30044
  return images;
29987
30045
  }
29988
30046
  }
29989
- ImagePlugin.getters = ["getImage"];
30047
+ ImagePlugin.getters = ["getImage", "getImagePath", "getImageSize"];
29990
30048
 
29991
30049
  class MergePlugin extends CorePlugin {
29992
30050
  constructor() {
@@ -31787,9 +31845,7 @@ class CustomColorsPlugin extends UIPlugin {
31787
31845
  return formatColors.filter(isDefined$1);
31788
31846
  }
31789
31847
  getChartColors(sheetId) {
31790
- const charts = this.getters
31791
- .getChartIds(sheetId)
31792
- .map((cid) => this.getters.getChart(sheetId, cid));
31848
+ const charts = this.getters.getChartIds(sheetId).map((cid) => this.getters.getChart(cid));
31793
31849
  let chartsColors = new Set();
31794
31850
  for (let chart of charts) {
31795
31851
  if (chart === undefined) {
@@ -32145,37 +32201,34 @@ class EvaluationChartPlugin extends UIPlugin {
32145
32201
  invalidateCFEvaluationCommands.has(cmd.type) ||
32146
32202
  cmd.type === "EVALUATE_CELLS" ||
32147
32203
  cmd.type === "UPDATE_CELL") {
32148
- for (const sheetId in this.charts) {
32149
- for (const chartId in this.charts[sheetId]) {
32150
- this.charts[sheetId][chartId] = undefined;
32151
- }
32204
+ for (const chartId in this.charts) {
32205
+ this.charts[chartId] = undefined;
32152
32206
  }
32153
32207
  }
32154
32208
  switch (cmd.type) {
32155
32209
  case "UPDATE_CHART":
32156
32210
  case "CREATE_CHART":
32157
32211
  case "DELETE_FIGURE":
32158
- if (this.charts[cmd.sheetId]) {
32159
- this.charts[cmd.sheetId][cmd.id] = undefined;
32160
- }
32212
+ this.charts[cmd.id] = undefined;
32161
32213
  break;
32162
32214
  case "DELETE_SHEET":
32163
- delete this.charts[cmd.sheetId];
32215
+ for (let chartId in this.charts) {
32216
+ if (!this.getters.isChartDefined(chartId)) {
32217
+ this.charts[chartId] = undefined;
32218
+ }
32219
+ }
32164
32220
  break;
32165
32221
  }
32166
32222
  }
32167
- getChartRuntime(sheetId, figureId) {
32168
- var _a;
32169
- if (!((_a = this.charts[sheetId]) === null || _a === void 0 ? void 0 : _a[figureId])) {
32170
- const chart = this.getters.getChart(sheetId, figureId);
32223
+ getChartRuntime(figureId) {
32224
+ if (!this.charts[figureId]) {
32225
+ const chart = this.getters.getChart(figureId);
32171
32226
  if (!chart) {
32172
32227
  throw new Error(`No chart for the given id: ${figureId}`);
32173
32228
  }
32174
- if (!this.charts[sheetId])
32175
- this.charts[sheetId] = {};
32176
- this.charts[sheetId][figureId] = this.createRuntimeChart(chart);
32229
+ this.charts[figureId] = this.createRuntimeChart(chart);
32177
32230
  }
32178
- return this.charts[sheetId][figureId];
32231
+ return this.charts[figureId];
32179
32232
  }
32180
32233
  /**
32181
32234
  * Get the background color of a chart based on the color of the first cell of the main range
@@ -32611,6 +32664,9 @@ class FilterEvaluationPlugin extends UIPlugin {
32611
32664
  case "CREATE_SHEET":
32612
32665
  this.filterValues[cmd.sheetId] = {};
32613
32666
  break;
32667
+ case "HIDE_COLUMNS_ROWS":
32668
+ this.updateHiddenRows();
32669
+ break;
32614
32670
  case "UPDATE_FILTER":
32615
32671
  this.updateFilter(cmd);
32616
32672
  this.updateHiddenRows();
@@ -32719,9 +32775,16 @@ class FilterEvaluationPlugin extends UIPlugin {
32719
32775
  updateHiddenRows() {
32720
32776
  var _a, _b;
32721
32777
  const sheetId = this.getters.getActiveSheetId();
32722
- const filters = this.getters.getFilters(sheetId);
32778
+ const filters = this.getters
32779
+ .getFilters(sheetId)
32780
+ .sort((filter1, filter2) => filter1.zoneWithHeaders.top - filter2.zoneWithHeaders.top);
32723
32781
  const hiddenRows = new Set();
32724
32782
  for (let filter of filters) {
32783
+ // Disable filters whose header are hidden
32784
+ if (this.getters.isRowHiddenByUser(sheetId, filter.zoneWithHeaders.top))
32785
+ continue;
32786
+ if (hiddenRows.has(filter.zoneWithHeaders.top))
32787
+ continue;
32725
32788
  const filteredValues = (_b = (_a = this.filterValues[sheetId]) === null || _a === void 0 ? void 0 : _a[filter.id]) === null || _b === void 0 ? void 0 : _b.map(toLowerCase);
32726
32789
  if (!filteredValues || !filter.filteredZone)
32727
32790
  continue;
@@ -37819,7 +37882,7 @@ class ClipboardFigureChart {
37819
37882
  constructor(dispatch, getters, sheetId, copiedFigureId) {
37820
37883
  this.dispatch = dispatch;
37821
37884
  this.sheetId = sheetId;
37822
- const chart = getters.getChart(sheetId, copiedFigureId);
37885
+ const chart = getters.getChart(copiedFigureId);
37823
37886
  if (!chart) {
37824
37887
  throw new Error(`No chart for the given id: ${copiedFigureId}`);
37825
37888
  }
@@ -37840,7 +37903,7 @@ class ClipboardFigureImage {
37840
37903
  constructor(dispatch, getters, sheetId, copiedFigureId) {
37841
37904
  this.dispatch = dispatch;
37842
37905
  this.sheetId = sheetId;
37843
- const image = getters.getImage(sheetId, copiedFigureId);
37906
+ const image = getters.getImage(copiedFigureId);
37844
37907
  this.copiedImage = deepCopy(image);
37845
37908
  }
37846
37909
  paste(sheetId, figureId, position, size) {
@@ -43848,6 +43911,6 @@ exports.setTranslationMethod = setTranslationMethod;
43848
43911
  exports.tokenize = tokenize;
43849
43912
 
43850
43913
 
43851
- __info__.version = '16.1.2';
43852
- __info__.date = '2023-03-01T14:43:45.667Z';
43853
- __info__.hash = '59bec2d';
43914
+ __info__.version = '16.1.4';
43915
+ __info__.date = '2023-03-14T09:27:28.837Z';
43916
+ __info__.hash = 'c8882d9';