@odoo/o-spreadsheet 16.0.0 → 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.
- package/dist/o_spreadsheet.cjs.js +134 -90
- package/dist/o_spreadsheet.d.ts +20 -19
- package/dist/o_spreadsheet.esm.js +134 -90
- package/dist/o_spreadsheet.iife.js +134 -90
- package/dist/o_spreadsheet.iife.min.js +7 -7
- package/package.json +7 -4
|
@@ -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.
|
|
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.
|
|
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.
|
|
8837
|
+
if (!this.env.model.getters.isChartDefined(this.figureId)) {
|
|
8837
8838
|
this.props.onCloseSidePanel();
|
|
8838
8839
|
return;
|
|
8839
8840
|
}
|
|
@@ -8847,7 +8848,6 @@ class ChartPanel extends owl.Component {
|
|
|
8847
8848
|
...this.getChartDefinition(),
|
|
8848
8849
|
...updateDefinition,
|
|
8849
8850
|
};
|
|
8850
|
-
// TODORAR add a putain de test - c'est faux de nouveau ...
|
|
8851
8851
|
return this.env.model.dispatch("UPDATE_CHART", {
|
|
8852
8852
|
definition,
|
|
8853
8853
|
id: this.figureId,
|
|
@@ -8855,12 +8855,11 @@ class ChartPanel extends owl.Component {
|
|
|
8855
8855
|
});
|
|
8856
8856
|
}
|
|
8857
8857
|
onTypeChange(type) {
|
|
8858
|
-
const context = this.env.model.getters.getContextCreationChart(this.
|
|
8858
|
+
const context = this.env.model.getters.getContextCreationChart(this.figureId);
|
|
8859
8859
|
if (!context) {
|
|
8860
8860
|
throw new Error("Chart not defined.");
|
|
8861
8861
|
}
|
|
8862
8862
|
const definition = getChartDefinitionFromContextCreation(context, type);
|
|
8863
|
-
// TODORAR add a putain de test - c'est faux de nouveau ...
|
|
8864
8863
|
this.env.model.dispatch("UPDATE_CHART", {
|
|
8865
8864
|
definition,
|
|
8866
8865
|
id: this.figureId,
|
|
@@ -8868,7 +8867,7 @@ class ChartPanel extends owl.Component {
|
|
|
8868
8867
|
});
|
|
8869
8868
|
}
|
|
8870
8869
|
get chartPanel() {
|
|
8871
|
-
const type = this.env.model.getters.getChartType(this.
|
|
8870
|
+
const type = this.env.model.getters.getChartType(this.figureId);
|
|
8872
8871
|
if (!type) {
|
|
8873
8872
|
throw new Error("Chart not defined.");
|
|
8874
8873
|
}
|
|
@@ -8878,8 +8877,8 @@ class ChartPanel extends owl.Component {
|
|
|
8878
8877
|
}
|
|
8879
8878
|
return chartPanel;
|
|
8880
8879
|
}
|
|
8881
|
-
getChartDefinition() {
|
|
8882
|
-
return this.env.model.getters.getChartDefinition(
|
|
8880
|
+
getChartDefinition(figureId = this.figureId) {
|
|
8881
|
+
return this.env.model.getters.getChartDefinition(figureId);
|
|
8883
8882
|
}
|
|
8884
8883
|
get chartTypes() {
|
|
8885
8884
|
return getChartTypes();
|
|
@@ -10015,7 +10014,7 @@ class ScorecardChart extends owl.Component {
|
|
|
10015
10014
|
this.ctx = document.createElement("canvas").getContext("2d");
|
|
10016
10015
|
}
|
|
10017
10016
|
get runtime() {
|
|
10018
|
-
return this.env.model.getters.getChartRuntime(this.
|
|
10017
|
+
return this.env.model.getters.getChartRuntime(this.props.figure.id);
|
|
10019
10018
|
}
|
|
10020
10019
|
get title() {
|
|
10021
10020
|
return this.runtime.title;
|
|
@@ -10245,7 +10244,7 @@ class ChartFigure extends owl.Component {
|
|
|
10245
10244
|
return registry;
|
|
10246
10245
|
}
|
|
10247
10246
|
get chartType() {
|
|
10248
|
-
return this.env.model.getters.getChartType(this.
|
|
10247
|
+
return this.env.model.getters.getChartType(this.props.figure.id);
|
|
10249
10248
|
}
|
|
10250
10249
|
onContextMenu(ev) {
|
|
10251
10250
|
const position = {
|
|
@@ -26272,13 +26271,7 @@ function load(data, verboseImport) {
|
|
|
26272
26271
|
data = migrate(data);
|
|
26273
26272
|
}
|
|
26274
26273
|
}
|
|
26275
|
-
|
|
26276
|
-
// sensible default values
|
|
26277
|
-
data = Object.assign(createEmptyWorkbookData(), data, { version: CURRENT_VERSION });
|
|
26278
|
-
data.sheets = data.sheets.map((s, i) => Object.assign(createEmptySheet(`Sheet${i + 1}`, `Sheet${i + 1}`), s));
|
|
26279
|
-
if (data.sheets.length === 0) {
|
|
26280
|
-
data.sheets.push(createEmptySheet(INITIAL_SHEET_ID, "Sheet1"));
|
|
26281
|
-
}
|
|
26274
|
+
data = repairData(data);
|
|
26282
26275
|
return data;
|
|
26283
26276
|
}
|
|
26284
26277
|
function migrate(data) {
|
|
@@ -26516,6 +26509,48 @@ const MIGRATIONS = [
|
|
|
26516
26509
|
},
|
|
26517
26510
|
},
|
|
26518
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
|
+
}
|
|
26519
26554
|
/**
|
|
26520
26555
|
* The goal of this function is to repair corrupted/wrong initial messages caused by
|
|
26521
26556
|
* a bug.
|
|
@@ -26654,6 +26689,7 @@ function createEmptyWorkbookData(sheetName = "Sheet1") {
|
|
|
26654
26689
|
formats: {},
|
|
26655
26690
|
borders: {},
|
|
26656
26691
|
revisionId: DEFAULT_REVISION_ID,
|
|
26692
|
+
uniqueFigureIds: true,
|
|
26657
26693
|
};
|
|
26658
26694
|
return data;
|
|
26659
26695
|
}
|
|
@@ -27576,10 +27612,8 @@ class ChartPlugin extends CorePlugin {
|
|
|
27576
27612
|
this.validateChartDefinition = (cmd) => validateChartDefinition(this, cmd.definition);
|
|
27577
27613
|
}
|
|
27578
27614
|
adaptRanges(applyChange) {
|
|
27579
|
-
for (const
|
|
27580
|
-
|
|
27581
|
-
this.history.update("charts", sheetId, chartId, chart === null || chart === void 0 ? void 0 : chart.updateRanges(applyChange));
|
|
27582
|
-
}
|
|
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));
|
|
27583
27617
|
}
|
|
27584
27618
|
}
|
|
27585
27619
|
// ---------------------------------------------------------------------------
|
|
@@ -27590,20 +27624,20 @@ class ChartPlugin extends CorePlugin {
|
|
|
27590
27624
|
case "CREATE_CHART":
|
|
27591
27625
|
return this.checkValidations(cmd, this.chainValidations(this.validateChartDefinition, this.checkChartDuplicate));
|
|
27592
27626
|
case "UPDATE_CHART":
|
|
27593
|
-
return this.
|
|
27627
|
+
return this.checkValidations(cmd, this.chainValidations(this.validateChartDefinition, this.checkChartExists));
|
|
27594
27628
|
default:
|
|
27595
27629
|
return 0 /* CommandResult.Success */;
|
|
27596
27630
|
}
|
|
27597
27631
|
}
|
|
27598
27632
|
handle(cmd) {
|
|
27599
|
-
var _a
|
|
27633
|
+
var _a;
|
|
27600
27634
|
switch (cmd.type) {
|
|
27601
27635
|
case "CREATE_CHART":
|
|
27602
27636
|
this.addFigure(cmd.id, cmd.sheetId, cmd.position, cmd.size);
|
|
27603
|
-
this.addChart(cmd.id, cmd.
|
|
27637
|
+
this.addChart(cmd.id, cmd.definition);
|
|
27604
27638
|
break;
|
|
27605
27639
|
case "UPDATE_CHART": {
|
|
27606
|
-
this.addChart(cmd.id, cmd.
|
|
27640
|
+
this.addChart(cmd.id, cmd.definition);
|
|
27607
27641
|
break;
|
|
27608
27642
|
}
|
|
27609
27643
|
case "DUPLICATE_SHEET": {
|
|
@@ -27612,7 +27646,7 @@ class ChartPlugin extends CorePlugin {
|
|
|
27612
27646
|
if (fig.tag === "chart") {
|
|
27613
27647
|
const figureIdBase = fig.id.split(FIGURE_ID_SPLITTER).pop();
|
|
27614
27648
|
const duplicatedFigureId = `${cmd.sheetIdTo}${FIGURE_ID_SPLITTER}${figureIdBase}`;
|
|
27615
|
-
const chart = (
|
|
27649
|
+
const chart = (_a = this.charts[fig.id]) === null || _a === void 0 ? void 0 : _a.copyForSheetId(cmd.sheetIdTo);
|
|
27616
27650
|
if (chart) {
|
|
27617
27651
|
this.dispatch("CREATE_CHART", {
|
|
27618
27652
|
id: duplicatedFigureId,
|
|
@@ -27627,44 +27661,44 @@ class ChartPlugin extends CorePlugin {
|
|
|
27627
27661
|
break;
|
|
27628
27662
|
}
|
|
27629
27663
|
case "DELETE_FIGURE":
|
|
27630
|
-
this.history.update("charts", cmd.
|
|
27664
|
+
this.history.update("charts", cmd.id, undefined);
|
|
27631
27665
|
break;
|
|
27632
27666
|
case "DELETE_SHEET":
|
|
27633
|
-
this.
|
|
27667
|
+
for (let id of this.getChartIds(cmd.sheetId)) {
|
|
27668
|
+
this.history.update("charts", id, undefined);
|
|
27669
|
+
}
|
|
27634
27670
|
break;
|
|
27635
27671
|
}
|
|
27636
27672
|
}
|
|
27637
27673
|
// ---------------------------------------------------------------------------
|
|
27638
27674
|
// Getters
|
|
27639
27675
|
// ---------------------------------------------------------------------------
|
|
27640
|
-
getContextCreationChart(
|
|
27641
|
-
var _a, _b;
|
|
27642
|
-
return (_b = (_a = this.charts[sheetId]) === null || _a === void 0 ? void 0 : _a[figureId]) === null || _b === void 0 ? void 0 : _b.getContextCreation();
|
|
27643
|
-
}
|
|
27644
|
-
getChart(sheetId, figureId) {
|
|
27676
|
+
getContextCreationChart(figureId) {
|
|
27645
27677
|
var _a;
|
|
27646
|
-
return (_a = this.charts[
|
|
27678
|
+
return (_a = this.charts[figureId]) === null || _a === void 0 ? void 0 : _a.getContextCreation();
|
|
27647
27679
|
}
|
|
27648
|
-
|
|
27649
|
-
|
|
27650
|
-
|
|
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;
|
|
27651
27686
|
if (!type) {
|
|
27652
27687
|
throw new Error("Chart not defined.");
|
|
27653
27688
|
}
|
|
27654
27689
|
return type;
|
|
27655
27690
|
}
|
|
27656
|
-
isChartDefined(
|
|
27657
|
-
return figureId in
|
|
27691
|
+
isChartDefined(figureId) {
|
|
27692
|
+
return figureId in this.charts && this.charts !== undefined;
|
|
27658
27693
|
}
|
|
27659
27694
|
getChartIds(sheetId) {
|
|
27660
|
-
|
|
27661
|
-
|
|
27662
|
-
|
|
27663
|
-
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);
|
|
27664
27698
|
}
|
|
27665
|
-
getChartDefinition(
|
|
27666
|
-
var _a
|
|
27667
|
-
const definition = (
|
|
27699
|
+
getChartDefinition(figureId) {
|
|
27700
|
+
var _a;
|
|
27701
|
+
const definition = (_a = this.charts[figureId]) === null || _a === void 0 ? void 0 : _a.getDefinition();
|
|
27668
27702
|
if (!definition) {
|
|
27669
27703
|
throw new Error(`There is no chart with the given figureId: ${figureId}`);
|
|
27670
27704
|
}
|
|
@@ -27676,28 +27710,35 @@ class ChartPlugin extends CorePlugin {
|
|
|
27676
27710
|
import(data) {
|
|
27677
27711
|
for (let sheet of data.sheets) {
|
|
27678
27712
|
if (sheet.figures) {
|
|
27679
|
-
const charts = {};
|
|
27680
27713
|
for (let figure of sheet.figures) {
|
|
27681
27714
|
// TODO:
|
|
27682
27715
|
// figure data should be external IMO => chart should be in sheet.chart
|
|
27683
27716
|
// instead of in figure.data
|
|
27684
27717
|
if (figure.tag === "chart") {
|
|
27685
|
-
charts[figure.id] = this.createChart(figure.id, figure.data, sheet.id);
|
|
27718
|
+
this.charts[figure.id] = this.createChart(figure.id, figure.data, sheet.id);
|
|
27686
27719
|
}
|
|
27687
27720
|
}
|
|
27688
|
-
this.charts[sheet.id] = charts;
|
|
27689
27721
|
}
|
|
27690
27722
|
}
|
|
27691
27723
|
}
|
|
27692
27724
|
export(data) {
|
|
27725
|
+
var _a;
|
|
27693
27726
|
if (data.sheets) {
|
|
27694
27727
|
for (let sheet of data.sheets) {
|
|
27695
27728
|
// TODO This code is false, if two plugins want ot insert figures on the sheet, it will crash !
|
|
27696
27729
|
const sheetFigures = this.getters.getFigures(sheet.id);
|
|
27697
|
-
const figures =
|
|
27698
|
-
for (let
|
|
27730
|
+
const figures = [];
|
|
27731
|
+
for (let sheetFigure of sheetFigures) {
|
|
27732
|
+
const figure = sheetFigure;
|
|
27699
27733
|
if (figure && figure.tag === "chart") {
|
|
27700
|
-
|
|
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);
|
|
27701
27742
|
}
|
|
27702
27743
|
}
|
|
27703
27744
|
sheet.figures = figures;
|
|
@@ -27705,13 +27746,13 @@ class ChartPlugin extends CorePlugin {
|
|
|
27705
27746
|
}
|
|
27706
27747
|
}
|
|
27707
27748
|
exportForExcel(data) {
|
|
27708
|
-
var _a
|
|
27749
|
+
var _a;
|
|
27709
27750
|
for (let sheet of data.sheets) {
|
|
27710
27751
|
const sheetFigures = this.getters.getFigures(sheet.id);
|
|
27711
27752
|
const figures = [];
|
|
27712
27753
|
for (let figure of sheetFigures) {
|
|
27713
27754
|
if (figure && figure.tag === "chart") {
|
|
27714
|
-
const figureData = (
|
|
27755
|
+
const figureData = (_a = this.charts[figure.id]) === null || _a === void 0 ? void 0 : _a.getDefinitionForExcel();
|
|
27715
27756
|
if (figureData) {
|
|
27716
27757
|
figures.push({
|
|
27717
27758
|
...figure,
|
|
@@ -27750,15 +27791,21 @@ class ChartPlugin extends CorePlugin {
|
|
|
27750
27791
|
* Add a chart in the local state. If a chart already exists, this chart is
|
|
27751
27792
|
* replaced
|
|
27752
27793
|
*/
|
|
27753
|
-
addChart(id,
|
|
27754
|
-
|
|
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
|
+
}
|
|
27755
27799
|
}
|
|
27756
27800
|
checkChartDuplicate(cmd) {
|
|
27757
|
-
|
|
27758
|
-
|
|
27759
|
-
|
|
27760
|
-
|
|
27761
|
-
|
|
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 */;
|
|
27762
27809
|
}
|
|
27763
27810
|
}
|
|
27764
27811
|
ChartPlugin.getters = [
|
|
@@ -28139,7 +28186,7 @@ class FigurePlugin extends CorePlugin {
|
|
|
28139
28186
|
allowDispatch(cmd) {
|
|
28140
28187
|
switch (cmd.type) {
|
|
28141
28188
|
case "CREATE_FIGURE":
|
|
28142
|
-
return this.checkFigureDuplicate(cmd.
|
|
28189
|
+
return this.checkFigureDuplicate(cmd.figure.id);
|
|
28143
28190
|
case "UPDATE_FIGURE":
|
|
28144
28191
|
case "DELETE_FIGURE":
|
|
28145
28192
|
return this.checkFigureExists(cmd.sheetId, cmd.id);
|
|
@@ -28205,9 +28252,8 @@ class FigurePlugin extends CorePlugin {
|
|
|
28205
28252
|
}
|
|
28206
28253
|
return 0 /* CommandResult.Success */;
|
|
28207
28254
|
}
|
|
28208
|
-
checkFigureDuplicate(
|
|
28209
|
-
|
|
28210
|
-
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])) {
|
|
28211
28257
|
return 81 /* CommandResult.DuplicatedFigureId */;
|
|
28212
28258
|
}
|
|
28213
28259
|
return 0 /* CommandResult.Success */;
|
|
@@ -28222,6 +28268,9 @@ class FigurePlugin extends CorePlugin {
|
|
|
28222
28268
|
var _a;
|
|
28223
28269
|
return (_a = this.figures[sheetId]) === null || _a === void 0 ? void 0 : _a[figureId];
|
|
28224
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
|
+
}
|
|
28225
28274
|
// ---------------------------------------------------------------------------
|
|
28226
28275
|
// Import/Export
|
|
28227
28276
|
// ---------------------------------------------------------------------------
|
|
@@ -28246,7 +28295,7 @@ class FigurePlugin extends CorePlugin {
|
|
|
28246
28295
|
this.export(data);
|
|
28247
28296
|
}
|
|
28248
28297
|
}
|
|
28249
|
-
FigurePlugin.getters = ["getFigures", "getFigure"];
|
|
28298
|
+
FigurePlugin.getters = ["getFigures", "getFigure", "getFigureSheetId"];
|
|
28250
28299
|
|
|
28251
28300
|
class FilterTable {
|
|
28252
28301
|
constructor(zone) {
|
|
@@ -31538,7 +31587,7 @@ class ClipboardFigureState {
|
|
|
31538
31587
|
throw new Error(`No figure for the given id: ${copiedFigureId}`);
|
|
31539
31588
|
}
|
|
31540
31589
|
this.copiedFigure = { ...figure };
|
|
31541
|
-
const chart = getters.getChart(
|
|
31590
|
+
const chart = getters.getChart(copiedFigureId);
|
|
31542
31591
|
if (!chart) {
|
|
31543
31592
|
throw new Error(`No chart for the given id: ${copiedFigureId}`);
|
|
31544
31593
|
}
|
|
@@ -31990,9 +32039,7 @@ class CustomColorsPlugin extends UIPlugin {
|
|
|
31990
32039
|
return formatColors.filter(isDefined$1);
|
|
31991
32040
|
}
|
|
31992
32041
|
getChartColors(sheetId) {
|
|
31993
|
-
const charts = this.getters
|
|
31994
|
-
.getChartIds(sheetId)
|
|
31995
|
-
.map((cid) => this.getters.getChart(sheetId, cid));
|
|
32042
|
+
const charts = this.getters.getChartIds(sheetId).map((cid) => this.getters.getChart(cid));
|
|
31996
32043
|
let chartsColors = new Set();
|
|
31997
32044
|
for (let chart of charts) {
|
|
31998
32045
|
if (chart === undefined) {
|
|
@@ -32259,37 +32306,34 @@ class EvaluationChartPlugin extends UIPlugin {
|
|
|
32259
32306
|
invalidateCFEvaluationCommands.has(cmd.type) ||
|
|
32260
32307
|
cmd.type === "EVALUATE_CELLS" ||
|
|
32261
32308
|
cmd.type === "UPDATE_CELL") {
|
|
32262
|
-
for (const
|
|
32263
|
-
|
|
32264
|
-
this.charts[sheetId][chartId] = undefined;
|
|
32265
|
-
}
|
|
32309
|
+
for (const chartId in this.charts) {
|
|
32310
|
+
this.charts[chartId] = undefined;
|
|
32266
32311
|
}
|
|
32267
32312
|
}
|
|
32268
32313
|
switch (cmd.type) {
|
|
32269
32314
|
case "UPDATE_CHART":
|
|
32270
32315
|
case "CREATE_CHART":
|
|
32271
32316
|
case "DELETE_FIGURE":
|
|
32272
|
-
|
|
32273
|
-
this.charts[cmd.sheetId][cmd.id] = undefined;
|
|
32274
|
-
}
|
|
32317
|
+
this.charts[cmd.id] = undefined;
|
|
32275
32318
|
break;
|
|
32276
32319
|
case "DELETE_SHEET":
|
|
32277
|
-
|
|
32320
|
+
for (let chartId in this.charts) {
|
|
32321
|
+
if (!this.getters.isChartDefined(chartId)) {
|
|
32322
|
+
this.charts[chartId] = undefined;
|
|
32323
|
+
}
|
|
32324
|
+
}
|
|
32278
32325
|
break;
|
|
32279
32326
|
}
|
|
32280
32327
|
}
|
|
32281
|
-
getChartRuntime(
|
|
32282
|
-
|
|
32283
|
-
|
|
32284
|
-
const chart = this.getters.getChart(sheetId, figureId);
|
|
32328
|
+
getChartRuntime(figureId) {
|
|
32329
|
+
if (!this.charts[figureId]) {
|
|
32330
|
+
const chart = this.getters.getChart(figureId);
|
|
32285
32331
|
if (!chart) {
|
|
32286
32332
|
throw new Error(`No chart for the given id: ${figureId}`);
|
|
32287
32333
|
}
|
|
32288
|
-
|
|
32289
|
-
this.charts[sheetId] = {};
|
|
32290
|
-
this.charts[sheetId][figureId] = this.createRuntimeChart(chart);
|
|
32334
|
+
this.charts[figureId] = this.createRuntimeChart(chart);
|
|
32291
32335
|
}
|
|
32292
|
-
return this.charts[
|
|
32336
|
+
return this.charts[figureId];
|
|
32293
32337
|
}
|
|
32294
32338
|
/**
|
|
32295
32339
|
* Get the background color of a chart based on the color of the first cell of the main range
|
|
@@ -42411,6 +42455,6 @@ exports.setTranslationMethod = setTranslationMethod;
|
|
|
42411
42455
|
exports.tokenize = tokenize;
|
|
42412
42456
|
|
|
42413
42457
|
|
|
42414
|
-
__info__.version = '16.0.
|
|
42415
|
-
__info__.date = '2023-
|
|
42416
|
-
__info__.hash = '
|
|
42458
|
+
__info__.version = '16.0.2';
|
|
42459
|
+
__info__.date = '2023-03-06T07:17:51.313Z';
|
|
42460
|
+
__info__.hash = '6b4d816';
|
package/dist/o_spreadsheet.d.ts
CHANGED
|
@@ -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:
|
|
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(
|
|
3198
|
-
getChart(
|
|
3199
|
-
getChartType(
|
|
3200
|
-
isChartDefined(
|
|
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(
|
|
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:
|
|
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:
|
|
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(
|
|
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():
|
|
5129
|
+
get background(): string;
|
|
5129
5130
|
get canvasStyle(): string;
|
|
5130
5131
|
get chartRuntime(): ChartJSRuntime;
|
|
5131
5132
|
setup(): void;
|