@odoo/o-spreadsheet 16.0.1 → 16.0.3

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.
@@ -2799,7 +2799,7 @@ class ChartJsComponent extends Component {
2799
2799
  return `background-color: ${this.background}`;
2800
2800
  }
2801
2801
  get chartRuntime() {
2802
- const runtime = this.env.model.getters.getChartRuntime(this.env.model.getters.getActiveSheetId(), this.props.figure.id);
2802
+ const runtime = this.env.model.getters.getChartRuntime(this.props.figure.id);
2803
2803
  if (!("chartJsConfig" in runtime)) {
2804
2804
  throw new Error("Unsupported chart runtime");
2805
2805
  }
@@ -3168,6 +3168,7 @@ var CommandResult;
3168
3168
  CommandResult[CommandResult["DuplicatedFigureId"] = 81] = "DuplicatedFigureId";
3169
3169
  CommandResult[CommandResult["InvalidSelectionStep"] = 82] = "InvalidSelectionStep";
3170
3170
  CommandResult[CommandResult["DuplicatedChartId"] = 83] = "DuplicatedChartId";
3171
+ CommandResult[CommandResult["ChartDoesNotExist"] = 84] = "ChartDoesNotExist";
3171
3172
  })(CommandResult || (CommandResult = {}));
3172
3173
 
3173
3174
  var DIRECTION;
@@ -8381,7 +8382,7 @@ class ColorPicker extends Component {
8381
8382
  }
8382
8383
  onColorClick(color) {
8383
8384
  if (color) {
8384
- this.props.onColorPicked(color);
8385
+ this.props.onColorPicked(toHex(color));
8385
8386
  }
8386
8387
  }
8387
8388
  getCheckMarkColor() {
@@ -8396,8 +8397,10 @@ class ColorPicker extends Component {
8396
8397
  this.state.isCurrentColorInvalid = true;
8397
8398
  return;
8398
8399
  }
8400
+ const color = toHex(this.state.currentColor);
8399
8401
  this.state.isCurrentColorInvalid = false;
8400
- this.props.onColorPicked(this.state.currentColor);
8402
+ this.props.onColorPicked(color);
8403
+ this.state.currentColor = color;
8401
8404
  }
8402
8405
  toggleColorPicker() {
8403
8406
  this.state.showGradient = !this.state.showGradient;
@@ -8636,7 +8639,7 @@ GaugeChartDesignPanel.components = { ColorPicker };
8636
8639
 
8637
8640
  class LineConfigPanel extends LineBarPieConfigPanel {
8638
8641
  get canTreatLabelsAsText() {
8639
- const chart = this.env.model.getters.getChart(this.props.sheetId, this.props.figureId);
8642
+ const chart = this.env.model.getters.getChart(this.props.figureId);
8640
8643
  if (chart && chart instanceof LineChart) {
8641
8644
  return canChartParseLabels(chart, this.env.model.getters);
8642
8645
  }
@@ -8829,7 +8832,7 @@ class ChartPanel extends Component {
8829
8832
  else {
8830
8833
  this.shouldUpdateChart = true;
8831
8834
  }
8832
- if (!this.env.model.getters.isChartDefined(this.sheetId, this.figureId)) {
8835
+ if (!this.env.model.getters.isChartDefined(this.figureId)) {
8833
8836
  this.props.onCloseSidePanel();
8834
8837
  return;
8835
8838
  }
@@ -8850,7 +8853,7 @@ class ChartPanel extends Component {
8850
8853
  });
8851
8854
  }
8852
8855
  onTypeChange(type) {
8853
- const context = this.env.model.getters.getContextCreationChart(this.sheetId, this.figureId);
8856
+ const context = this.env.model.getters.getContextCreationChart(this.figureId);
8854
8857
  if (!context) {
8855
8858
  throw new Error("Chart not defined.");
8856
8859
  }
@@ -8862,7 +8865,7 @@ class ChartPanel extends Component {
8862
8865
  });
8863
8866
  }
8864
8867
  get chartPanel() {
8865
- const type = this.env.model.getters.getChartType(this.sheetId, this.figureId);
8868
+ const type = this.env.model.getters.getChartType(this.figureId);
8866
8869
  if (!type) {
8867
8870
  throw new Error("Chart not defined.");
8868
8871
  }
@@ -8872,8 +8875,8 @@ class ChartPanel extends Component {
8872
8875
  }
8873
8876
  return chartPanel;
8874
8877
  }
8875
- getChartDefinition() {
8876
- return this.env.model.getters.getChartDefinition(this.sheetId, this.figureId);
8878
+ getChartDefinition(figureId = this.figureId) {
8879
+ return this.env.model.getters.getChartDefinition(figureId);
8877
8880
  }
8878
8881
  get chartTypes() {
8879
8882
  return getChartTypes();
@@ -10009,7 +10012,7 @@ class ScorecardChart extends Component {
10009
10012
  this.ctx = document.createElement("canvas").getContext("2d");
10010
10013
  }
10011
10014
  get runtime() {
10012
- return this.env.model.getters.getChartRuntime(this.env.model.getters.getActiveSheetId(), this.props.figure.id);
10015
+ return this.env.model.getters.getChartRuntime(this.props.figure.id);
10013
10016
  }
10014
10017
  get title() {
10015
10018
  return this.runtime.title;
@@ -10034,7 +10037,7 @@ class ScorecardChart extends Component {
10034
10037
  return this.runtime.fontColor;
10035
10038
  }
10036
10039
  get secondaryFontColor() {
10037
- return relativeLuminance(this.primaryFontColor) <= 0.3 ? "#757575" : "#bbbbbb";
10040
+ return relativeLuminance(this.backgroundColor) > 0.3 ? "#525252" : "#C8C8C8";
10038
10041
  }
10039
10042
  get figure() {
10040
10043
  return this.props.figure;
@@ -10239,7 +10242,7 @@ class ChartFigure extends Component {
10239
10242
  return registry;
10240
10243
  }
10241
10244
  get chartType() {
10242
- return this.env.model.getters.getChartType(this.env.model.getters.getActiveSheetId(), this.props.figure.id);
10245
+ return this.env.model.getters.getChartType(this.props.figure.id);
10243
10246
  }
10244
10247
  onContextMenu(ev) {
10245
10248
  const position = {
@@ -26266,13 +26269,7 @@ function load(data, verboseImport) {
26266
26269
  data = migrate(data);
26267
26270
  }
26268
26271
  }
26269
- // sanity check: try to fix missing fields/corrupted state by providing
26270
- // sensible default values
26271
- data = Object.assign(createEmptyWorkbookData(), data, { version: CURRENT_VERSION });
26272
- data.sheets = data.sheets.map((s, i) => Object.assign(createEmptySheet(`Sheet${i + 1}`, `Sheet${i + 1}`), s));
26273
- if (data.sheets.length === 0) {
26274
- data.sheets.push(createEmptySheet(INITIAL_SHEET_ID, "Sheet1"));
26275
- }
26272
+ data = repairData(data);
26276
26273
  return data;
26277
26274
  }
26278
26275
  function migrate(data) {
@@ -26510,6 +26507,48 @@ const MIGRATIONS = [
26510
26507
  },
26511
26508
  },
26512
26509
  ];
26510
+ /**
26511
+ * This function is used to repair faulty data independently of the migration.
26512
+ */
26513
+ function repairData(data) {
26514
+ data = forceUnicityOfFigure(data);
26515
+ data = setDefaults(data);
26516
+ return data;
26517
+ }
26518
+ /**
26519
+ * Force the unicity of figure ids accross sheets
26520
+ */
26521
+ function forceUnicityOfFigure(data) {
26522
+ if (data.uniqueFigureIds) {
26523
+ return data;
26524
+ }
26525
+ const figureIds = new Set();
26526
+ const uuidGenerator = new UuidGenerator();
26527
+ for (const sheet of data.sheets || []) {
26528
+ for (const figure of sheet.figures || []) {
26529
+ if (figureIds.has(figure.id)) {
26530
+ figure.id += uuidGenerator.uuidv4();
26531
+ }
26532
+ figureIds.add(figure.id);
26533
+ }
26534
+ }
26535
+ data.uniqueFigureIds = true;
26536
+ return data;
26537
+ }
26538
+ /**
26539
+ * sanity check: try to fix missing fields/corrupted state by providing
26540
+ * sensible default values
26541
+ */
26542
+ function setDefaults(data) {
26543
+ data = Object.assign(createEmptyWorkbookData(), data, { version: CURRENT_VERSION });
26544
+ data.sheets = data.sheets
26545
+ ? data.sheets.map((s, i) => Object.assign(createEmptySheet(`Sheet${i + 1}`, `Sheet${i + 1}`), s))
26546
+ : [];
26547
+ if (data.sheets.length === 0) {
26548
+ data.sheets.push(createEmptySheet(INITIAL_SHEET_ID, "Sheet1"));
26549
+ }
26550
+ return data;
26551
+ }
26513
26552
  /**
26514
26553
  * The goal of this function is to repair corrupted/wrong initial messages caused by
26515
26554
  * a bug.
@@ -26648,6 +26687,7 @@ function createEmptyWorkbookData(sheetName = "Sheet1") {
26648
26687
  formats: {},
26649
26688
  borders: {},
26650
26689
  revisionId: DEFAULT_REVISION_ID,
26690
+ uniqueFigureIds: true,
26651
26691
  };
26652
26692
  return data;
26653
26693
  }
@@ -27570,10 +27610,8 @@ class ChartPlugin extends CorePlugin {
27570
27610
  this.validateChartDefinition = (cmd) => validateChartDefinition(this, cmd.definition);
27571
27611
  }
27572
27612
  adaptRanges(applyChange) {
27573
- for (const sheetId of Object.keys(this.charts)) {
27574
- for (const [chartId, chart] of Object.entries(this.charts[sheetId] || {})) {
27575
- this.history.update("charts", sheetId, chartId, chart === null || chart === void 0 ? void 0 : chart.updateRanges(applyChange));
27576
- }
27613
+ for (const [chartId, chart] of Object.entries(this.charts)) {
27614
+ this.history.update("charts", chartId, chart === null || chart === void 0 ? void 0 : chart.updateRanges(applyChange));
27577
27615
  }
27578
27616
  }
27579
27617
  // ---------------------------------------------------------------------------
@@ -27584,20 +27622,20 @@ class ChartPlugin extends CorePlugin {
27584
27622
  case "CREATE_CHART":
27585
27623
  return this.checkValidations(cmd, this.chainValidations(this.validateChartDefinition, this.checkChartDuplicate));
27586
27624
  case "UPDATE_CHART":
27587
- return this.validateChartDefinition(cmd);
27625
+ return this.checkValidations(cmd, this.chainValidations(this.validateChartDefinition, this.checkChartExists));
27588
27626
  default:
27589
27627
  return 0 /* CommandResult.Success */;
27590
27628
  }
27591
27629
  }
27592
27630
  handle(cmd) {
27593
- var _a, _b;
27631
+ var _a;
27594
27632
  switch (cmd.type) {
27595
27633
  case "CREATE_CHART":
27596
27634
  this.addFigure(cmd.id, cmd.sheetId, cmd.position, cmd.size);
27597
- this.addChart(cmd.id, cmd.sheetId, cmd.definition);
27635
+ this.addChart(cmd.id, cmd.definition);
27598
27636
  break;
27599
27637
  case "UPDATE_CHART": {
27600
- this.addChart(cmd.id, cmd.sheetId, cmd.definition);
27638
+ this.addChart(cmd.id, cmd.definition);
27601
27639
  break;
27602
27640
  }
27603
27641
  case "DUPLICATE_SHEET": {
@@ -27606,7 +27644,7 @@ class ChartPlugin extends CorePlugin {
27606
27644
  if (fig.tag === "chart") {
27607
27645
  const figureIdBase = fig.id.split(FIGURE_ID_SPLITTER).pop();
27608
27646
  const duplicatedFigureId = `${cmd.sheetIdTo}${FIGURE_ID_SPLITTER}${figureIdBase}`;
27609
- 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);
27647
+ const chart = (_a = this.charts[fig.id]) === null || _a === void 0 ? void 0 : _a.copyForSheetId(cmd.sheetIdTo);
27610
27648
  if (chart) {
27611
27649
  this.dispatch("CREATE_CHART", {
27612
27650
  id: duplicatedFigureId,
@@ -27621,41 +27659,44 @@ class ChartPlugin extends CorePlugin {
27621
27659
  break;
27622
27660
  }
27623
27661
  case "DELETE_FIGURE":
27624
- this.history.update("charts", cmd.sheetId, cmd.id, undefined);
27662
+ this.history.update("charts", cmd.id, undefined);
27625
27663
  break;
27626
27664
  case "DELETE_SHEET":
27627
- this.history.update("charts", cmd.sheetId, undefined);
27665
+ for (let id of this.getChartIds(cmd.sheetId)) {
27666
+ this.history.update("charts", id, undefined);
27667
+ }
27628
27668
  break;
27629
27669
  }
27630
27670
  }
27631
27671
  // ---------------------------------------------------------------------------
27632
27672
  // Getters
27633
27673
  // ---------------------------------------------------------------------------
27634
- getContextCreationChart(sheetId, figureId) {
27635
- var _a, _b;
27636
- return (_b = (_a = this.charts[sheetId]) === null || _a === void 0 ? void 0 : _a[figureId]) === null || _b === void 0 ? void 0 : _b.getContextCreation();
27637
- }
27638
- getChart(sheetId, figureId) {
27674
+ getContextCreationChart(figureId) {
27639
27675
  var _a;
27640
- return (_a = this.charts[sheetId]) === null || _a === void 0 ? void 0 : _a[figureId];
27676
+ return (_a = this.charts[figureId]) === null || _a === void 0 ? void 0 : _a.getContextCreation();
27641
27677
  }
27642
- getChartType(sheetId, figureId) {
27643
- var _a, _b;
27644
- const type = (_b = (_a = this.charts[sheetId]) === null || _a === void 0 ? void 0 : _a[figureId]) === null || _b === void 0 ? void 0 : _b.type;
27678
+ getChart(figureId) {
27679
+ return this.charts[figureId];
27680
+ }
27681
+ getChartType(figureId) {
27682
+ var _a;
27683
+ const type = (_a = this.charts[figureId]) === null || _a === void 0 ? void 0 : _a.type;
27645
27684
  if (!type) {
27646
27685
  throw new Error("Chart not defined.");
27647
27686
  }
27648
27687
  return type;
27649
27688
  }
27650
- isChartDefined(sheetId, figureId) {
27651
- return figureId in (this.charts[sheetId] || {});
27689
+ isChartDefined(figureId) {
27690
+ return figureId in this.charts && this.charts !== undefined;
27652
27691
  }
27653
27692
  getChartIds(sheetId) {
27654
- return Object.keys(this.charts[sheetId] || {});
27693
+ return Object.entries(this.charts)
27694
+ .filter(([, chart]) => (chart === null || chart === void 0 ? void 0 : chart.sheetId) === sheetId)
27695
+ .map(([id]) => id);
27655
27696
  }
27656
- getChartDefinition(sheetId, figureId) {
27657
- var _a, _b;
27658
- const definition = (_b = (_a = this.charts[sheetId]) === null || _a === void 0 ? void 0 : _a[figureId]) === null || _b === void 0 ? void 0 : _b.getDefinition();
27697
+ getChartDefinition(figureId) {
27698
+ var _a;
27699
+ const definition = (_a = this.charts[figureId]) === null || _a === void 0 ? void 0 : _a.getDefinition();
27659
27700
  if (!definition) {
27660
27701
  throw new Error(`There is no chart with the given figureId: ${figureId}`);
27661
27702
  }
@@ -27667,28 +27708,35 @@ class ChartPlugin extends CorePlugin {
27667
27708
  import(data) {
27668
27709
  for (let sheet of data.sheets) {
27669
27710
  if (sheet.figures) {
27670
- const charts = {};
27671
27711
  for (let figure of sheet.figures) {
27672
27712
  // TODO:
27673
27713
  // figure data should be external IMO => chart should be in sheet.chart
27674
27714
  // instead of in figure.data
27675
27715
  if (figure.tag === "chart") {
27676
- charts[figure.id] = this.createChart(figure.id, figure.data, sheet.id);
27716
+ this.charts[figure.id] = this.createChart(figure.id, figure.data, sheet.id);
27677
27717
  }
27678
27718
  }
27679
- this.charts[sheet.id] = charts;
27680
27719
  }
27681
27720
  }
27682
27721
  }
27683
27722
  export(data) {
27723
+ var _a;
27684
27724
  if (data.sheets) {
27685
27725
  for (let sheet of data.sheets) {
27686
27726
  // TODO This code is false, if two plugins want ot insert figures on the sheet, it will crash !
27687
27727
  const sheetFigures = this.getters.getFigures(sheet.id);
27688
- const figures = sheetFigures;
27689
- for (let figure of figures) {
27728
+ const figures = [];
27729
+ for (let sheetFigure of sheetFigures) {
27730
+ const figure = sheetFigure;
27690
27731
  if (figure && figure.tag === "chart") {
27691
- figure.data = this.getChartDefinition(sheet.id, figure.id);
27732
+ const data = (_a = this.charts[figure.id]) === null || _a === void 0 ? void 0 : _a.getDefinition();
27733
+ if (data) {
27734
+ figure.data = data;
27735
+ figures.push(figure);
27736
+ }
27737
+ }
27738
+ else {
27739
+ figures.push(figure);
27692
27740
  }
27693
27741
  }
27694
27742
  sheet.figures = figures;
@@ -27696,13 +27744,13 @@ class ChartPlugin extends CorePlugin {
27696
27744
  }
27697
27745
  }
27698
27746
  exportForExcel(data) {
27699
- var _a, _b;
27747
+ var _a;
27700
27748
  for (let sheet of data.sheets) {
27701
27749
  const sheetFigures = this.getters.getFigures(sheet.id);
27702
27750
  const figures = [];
27703
27751
  for (let figure of sheetFigures) {
27704
27752
  if (figure && figure.tag === "chart") {
27705
- 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();
27753
+ const figureData = (_a = this.charts[figure.id]) === null || _a === void 0 ? void 0 : _a.getDefinitionForExcel();
27706
27754
  if (figureData) {
27707
27755
  figures.push({
27708
27756
  ...figure,
@@ -27741,15 +27789,21 @@ class ChartPlugin extends CorePlugin {
27741
27789
  * Add a chart in the local state. If a chart already exists, this chart is
27742
27790
  * replaced
27743
27791
  */
27744
- addChart(id, sheetId, definition) {
27745
- this.history.update("charts", sheetId, id, this.createChart(id, definition, sheetId));
27792
+ addChart(id, definition) {
27793
+ const sheetId = this.getters.getFigureSheetId(id);
27794
+ if (sheetId) {
27795
+ this.history.update("charts", id, this.createChart(id, definition, sheetId));
27796
+ }
27746
27797
  }
27747
27798
  checkChartDuplicate(cmd) {
27748
- var _a;
27749
- if ((_a = this.charts[cmd.sheetId]) === null || _a === void 0 ? void 0 : _a[cmd.id]) {
27750
- return 83 /* CommandResult.DuplicatedChartId */;
27751
- }
27752
- return 0 /* CommandResult.Success */;
27799
+ return this.getters.getFigureSheetId(cmd.id)
27800
+ ? 83 /* CommandResult.DuplicatedChartId */
27801
+ : 0 /* CommandResult.Success */;
27802
+ }
27803
+ checkChartExists(cmd) {
27804
+ return this.getters.getFigureSheetId(cmd.id)
27805
+ ? 0 /* CommandResult.Success */
27806
+ : 84 /* CommandResult.ChartDoesNotExist */;
27753
27807
  }
27754
27808
  }
27755
27809
  ChartPlugin.getters = [
@@ -28130,7 +28184,7 @@ class FigurePlugin extends CorePlugin {
28130
28184
  allowDispatch(cmd) {
28131
28185
  switch (cmd.type) {
28132
28186
  case "CREATE_FIGURE":
28133
- return this.checkFigureDuplicate(cmd.sheetId, cmd.figure.id);
28187
+ return this.checkFigureDuplicate(cmd.figure.id);
28134
28188
  case "UPDATE_FIGURE":
28135
28189
  case "DELETE_FIGURE":
28136
28190
  return this.checkFigureExists(cmd.sheetId, cmd.id);
@@ -28196,9 +28250,8 @@ class FigurePlugin extends CorePlugin {
28196
28250
  }
28197
28251
  return 0 /* CommandResult.Success */;
28198
28252
  }
28199
- checkFigureDuplicate(sheetId, figureId) {
28200
- var _a;
28201
- if ((_a = this.figures[sheetId]) === null || _a === void 0 ? void 0 : _a[figureId]) {
28253
+ checkFigureDuplicate(figureId) {
28254
+ if (Object.values(this.figures).find((sheet) => sheet === null || sheet === void 0 ? void 0 : sheet[figureId])) {
28202
28255
  return 81 /* CommandResult.DuplicatedFigureId */;
28203
28256
  }
28204
28257
  return 0 /* CommandResult.Success */;
@@ -28213,6 +28266,9 @@ class FigurePlugin extends CorePlugin {
28213
28266
  var _a;
28214
28267
  return (_a = this.figures[sheetId]) === null || _a === void 0 ? void 0 : _a[figureId];
28215
28268
  }
28269
+ getFigureSheetId(figureId) {
28270
+ return Object.keys(this.figures).find((sheetId) => { var _a; return ((_a = this.figures[sheetId]) === null || _a === void 0 ? void 0 : _a[figureId]) !== undefined; });
28271
+ }
28216
28272
  // ---------------------------------------------------------------------------
28217
28273
  // Import/Export
28218
28274
  // ---------------------------------------------------------------------------
@@ -28237,7 +28293,7 @@ class FigurePlugin extends CorePlugin {
28237
28293
  this.export(data);
28238
28294
  }
28239
28295
  }
28240
- FigurePlugin.getters = ["getFigures", "getFigure"];
28296
+ FigurePlugin.getters = ["getFigures", "getFigure", "getFigureSheetId"];
28241
28297
 
28242
28298
  class FilterTable {
28243
28299
  constructor(zone) {
@@ -31529,7 +31585,7 @@ class ClipboardFigureState {
31529
31585
  throw new Error(`No figure for the given id: ${copiedFigureId}`);
31530
31586
  }
31531
31587
  this.copiedFigure = { ...figure };
31532
- const chart = getters.getChart(this.sheetId, copiedFigureId);
31588
+ const chart = getters.getChart(copiedFigureId);
31533
31589
  if (!chart) {
31534
31590
  throw new Error(`No chart for the given id: ${copiedFigureId}`);
31535
31591
  }
@@ -31981,9 +32037,7 @@ class CustomColorsPlugin extends UIPlugin {
31981
32037
  return formatColors.filter(isDefined$1);
31982
32038
  }
31983
32039
  getChartColors(sheetId) {
31984
- const charts = this.getters
31985
- .getChartIds(sheetId)
31986
- .map((cid) => this.getters.getChart(sheetId, cid));
32040
+ const charts = this.getters.getChartIds(sheetId).map((cid) => this.getters.getChart(cid));
31987
32041
  let chartsColors = new Set();
31988
32042
  for (let chart of charts) {
31989
32043
  if (chart === undefined) {
@@ -32250,37 +32304,34 @@ class EvaluationChartPlugin extends UIPlugin {
32250
32304
  invalidateCFEvaluationCommands.has(cmd.type) ||
32251
32305
  cmd.type === "EVALUATE_CELLS" ||
32252
32306
  cmd.type === "UPDATE_CELL") {
32253
- for (const sheetId in this.charts) {
32254
- for (const chartId in this.charts[sheetId]) {
32255
- this.charts[sheetId][chartId] = undefined;
32256
- }
32307
+ for (const chartId in this.charts) {
32308
+ this.charts[chartId] = undefined;
32257
32309
  }
32258
32310
  }
32259
32311
  switch (cmd.type) {
32260
32312
  case "UPDATE_CHART":
32261
32313
  case "CREATE_CHART":
32262
32314
  case "DELETE_FIGURE":
32263
- if (this.charts[cmd.sheetId]) {
32264
- this.charts[cmd.sheetId][cmd.id] = undefined;
32265
- }
32315
+ this.charts[cmd.id] = undefined;
32266
32316
  break;
32267
32317
  case "DELETE_SHEET":
32268
- delete this.charts[cmd.sheetId];
32318
+ for (let chartId in this.charts) {
32319
+ if (!this.getters.isChartDefined(chartId)) {
32320
+ this.charts[chartId] = undefined;
32321
+ }
32322
+ }
32269
32323
  break;
32270
32324
  }
32271
32325
  }
32272
- getChartRuntime(sheetId, figureId) {
32273
- var _a;
32274
- if (!((_a = this.charts[sheetId]) === null || _a === void 0 ? void 0 : _a[figureId])) {
32275
- const chart = this.getters.getChart(sheetId, figureId);
32326
+ getChartRuntime(figureId) {
32327
+ if (!this.charts[figureId]) {
32328
+ const chart = this.getters.getChart(figureId);
32276
32329
  if (!chart) {
32277
32330
  throw new Error(`No chart for the given id: ${figureId}`);
32278
32331
  }
32279
- if (!this.charts[sheetId])
32280
- this.charts[sheetId] = {};
32281
- this.charts[sheetId][figureId] = this.createRuntimeChart(chart);
32332
+ this.charts[figureId] = this.createRuntimeChart(chart);
32282
32333
  }
32283
- return this.charts[sheetId][figureId];
32334
+ return this.charts[figureId];
32284
32335
  }
32285
32336
  /**
32286
32337
  * Get the background color of a chart based on the color of the first cell of the main range
@@ -32717,6 +32768,9 @@ class FilterEvaluationPlugin extends UIPlugin {
32717
32768
  case "CREATE_SHEET":
32718
32769
  this.filterValues[cmd.sheetId] = {};
32719
32770
  break;
32771
+ case "HIDE_COLUMNS_ROWS":
32772
+ this.updateHiddenRows();
32773
+ break;
32720
32774
  case "UPDATE_FILTER":
32721
32775
  this.updateFilter(cmd);
32722
32776
  this.updateHiddenRows();
@@ -32818,9 +32872,16 @@ class FilterEvaluationPlugin extends UIPlugin {
32818
32872
  updateHiddenRows() {
32819
32873
  var _a, _b;
32820
32874
  const sheetId = this.getters.getActiveSheetId();
32821
- const filters = this.getters.getFilters(sheetId);
32875
+ const filters = this.getters
32876
+ .getFilters(sheetId)
32877
+ .sort((filter1, filter2) => filter1.zoneWithHeaders.top - filter2.zoneWithHeaders.top);
32822
32878
  const hiddenRows = new Set();
32823
32879
  for (let filter of filters) {
32880
+ // Disable filters whose header are hidden
32881
+ if (this.getters.isRowHiddenByUser(sheetId, filter.zoneWithHeaders.top))
32882
+ continue;
32883
+ if (hiddenRows.has(filter.zoneWithHeaders.top))
32884
+ continue;
32824
32885
  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);
32825
32886
  if (!filteredValues || !filter.filteredZone)
32826
32887
  continue;
@@ -42374,6 +42435,6 @@ function addFunction(functionName, functionDescription) {
42374
42435
  export { AbstractChart, CommandResult, CorePlugin, DATETIME_FORMAT, DispatchResult, EvaluationError, Model, Registry, Revision, SPREADSHEET_DIMENSIONS, Spreadsheet, UIPlugin, __info__, addFunction, astToFormula, cellTypes, compile, components, convertAstNodes, coreTypes, findCellInNewZone, functionCache, helpers, invalidateEvaluationCommands, load, parse, readonlyAllowedCommands, registries, setTranslationMethod, tokenize };
42375
42436
 
42376
42437
 
42377
- __info__.version = '16.0.1';
42378
- __info__.date = '2023-03-01T14:43:41.736Z';
42379
- __info__.hash = '2ac9223';
42438
+ __info__.version = '16.0.3';
42439
+ __info__.date = '2023-03-14T09:22:56.932Z';
42440
+ __info__.hash = '4deeca9';