@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.
- package/dist/{o_spreadsheet.cjs.js → o-spreadsheet.cjs.js} +168 -105
- package/dist/{o_spreadsheet.d.ts → o-spreadsheet.d.ts} +26 -25
- package/dist/{o_spreadsheet.esm.js → o-spreadsheet.esm.js} +168 -105
- package/dist/{o_spreadsheet.iife.js → o-spreadsheet.iife.js} +168 -105
- package/dist/{o_spreadsheet.iife.min.js → o-spreadsheet.iife.min.js} +156 -156
- package/package.json +10 -9
- package/readme.md +3 -1
|
@@ -2823,7 +2823,7 @@ class ChartJsComponent extends Component {
|
|
|
2823
2823
|
return `background-color: ${this.background}`;
|
|
2824
2824
|
}
|
|
2825
2825
|
get chartRuntime() {
|
|
2826
|
-
const runtime = this.env.model.getters.getChartRuntime(this.
|
|
2826
|
+
const runtime = this.env.model.getters.getChartRuntime(this.props.figure.id);
|
|
2827
2827
|
if (!("chartJsConfig" in runtime)) {
|
|
2828
2828
|
throw new Error("Unsupported chart runtime");
|
|
2829
2829
|
}
|
|
@@ -3077,7 +3077,7 @@ class ScorecardChart$1 extends Component {
|
|
|
3077
3077
|
this.ctx = document.createElement("canvas").getContext("2d");
|
|
3078
3078
|
}
|
|
3079
3079
|
get runtime() {
|
|
3080
|
-
return this.env.model.getters.getChartRuntime(this.
|
|
3080
|
+
return this.env.model.getters.getChartRuntime(this.props.figure.id);
|
|
3081
3081
|
}
|
|
3082
3082
|
get title() {
|
|
3083
3083
|
return this.runtime.title;
|
|
@@ -3468,7 +3468,7 @@ var CommandResult;
|
|
|
3468
3468
|
CommandResult[CommandResult["InvalidRange"] = 25] = "InvalidRange";
|
|
3469
3469
|
CommandResult[CommandResult["InvalidZones"] = 26] = "InvalidZones";
|
|
3470
3470
|
CommandResult[CommandResult["InvalidSheetId"] = 27] = "InvalidSheetId";
|
|
3471
|
-
CommandResult[CommandResult["
|
|
3471
|
+
CommandResult[CommandResult["InvalidFigureId"] = 28] = "InvalidFigureId";
|
|
3472
3472
|
CommandResult[CommandResult["InputAlreadyFocused"] = 29] = "InputAlreadyFocused";
|
|
3473
3473
|
CommandResult[CommandResult["MaximumRangesReached"] = 30] = "MaximumRangesReached";
|
|
3474
3474
|
CommandResult[CommandResult["InvalidChartDefinition"] = 31] = "InvalidChartDefinition";
|
|
@@ -3525,6 +3525,7 @@ var CommandResult;
|
|
|
3525
3525
|
CommandResult[CommandResult["DuplicatedFigureId"] = 82] = "DuplicatedFigureId";
|
|
3526
3526
|
CommandResult[CommandResult["InvalidSelectionStep"] = 83] = "InvalidSelectionStep";
|
|
3527
3527
|
CommandResult[CommandResult["DuplicatedChartId"] = 84] = "DuplicatedChartId";
|
|
3528
|
+
CommandResult[CommandResult["ChartDoesNotExist"] = 85] = "ChartDoesNotExist";
|
|
3528
3529
|
})(CommandResult || (CommandResult = {}));
|
|
3529
3530
|
|
|
3530
3531
|
var DIRECTION;
|
|
@@ -6065,7 +6066,7 @@ class ChartFigure extends Component {
|
|
|
6065
6066
|
return registry;
|
|
6066
6067
|
}
|
|
6067
6068
|
get chartType() {
|
|
6068
|
-
return this.env.model.getters.getChartType(this.
|
|
6069
|
+
return this.env.model.getters.getChartType(this.props.figure.id);
|
|
6069
6070
|
}
|
|
6070
6071
|
onContextMenu(ev) {
|
|
6071
6072
|
const position = {
|
|
@@ -18800,7 +18801,7 @@ class ImageFigure extends Component {
|
|
|
18800
18801
|
name: _lt("Reset size"),
|
|
18801
18802
|
sequence: 3,
|
|
18802
18803
|
action: () => {
|
|
18803
|
-
const size = this.env.model.getters.
|
|
18804
|
+
const size = this.env.model.getters.getImageSize(this.figureId);
|
|
18804
18805
|
const { height, width } = getMaxFigureSize(this.env.model.getters, size);
|
|
18805
18806
|
this.env.model.dispatch("UPDATE_FIGURE", {
|
|
18806
18807
|
sheetId: this.env.model.getters.getActiveSheetId(),
|
|
@@ -18851,8 +18852,7 @@ class ImageFigure extends Component {
|
|
|
18851
18852
|
return this.props.figure.id;
|
|
18852
18853
|
}
|
|
18853
18854
|
get getImagePath() {
|
|
18854
|
-
return this.env.model.getters.
|
|
18855
|
-
.path;
|
|
18855
|
+
return this.env.model.getters.getImagePath(this.figureId);
|
|
18856
18856
|
}
|
|
18857
18857
|
}
|
|
18858
18858
|
ImageFigure.template = "o-spreadsheet-ImageFigure";
|
|
@@ -19807,7 +19807,6 @@ class LineBarPieConfigPanel extends Component {
|
|
|
19807
19807
|
LineBarPieConfigPanel.template = "o-spreadsheet-LineBarPieConfigPanel";
|
|
19808
19808
|
LineBarPieConfigPanel.components = { SelectionInput };
|
|
19809
19809
|
LineBarPieConfigPanel.props = {
|
|
19810
|
-
sheetId: String,
|
|
19811
19810
|
figureId: String,
|
|
19812
19811
|
definition: Object,
|
|
19813
19812
|
updateChart: Function,
|
|
@@ -20011,7 +20010,7 @@ class ColorPicker extends Component {
|
|
|
20011
20010
|
}
|
|
20012
20011
|
onColorClick(color) {
|
|
20013
20012
|
if (color) {
|
|
20014
|
-
this.props.onColorPicked(color);
|
|
20013
|
+
this.props.onColorPicked(toHex(color));
|
|
20015
20014
|
}
|
|
20016
20015
|
}
|
|
20017
20016
|
getCheckMarkColor() {
|
|
@@ -20026,8 +20025,10 @@ class ColorPicker extends Component {
|
|
|
20026
20025
|
this.state.isCurrentColorInvalid = true;
|
|
20027
20026
|
return;
|
|
20028
20027
|
}
|
|
20028
|
+
const color = toHex(this.state.currentColor);
|
|
20029
20029
|
this.state.isCurrentColorInvalid = false;
|
|
20030
|
-
this.props.onColorPicked(
|
|
20030
|
+
this.props.onColorPicked(color);
|
|
20031
|
+
this.state.currentColor = color;
|
|
20031
20032
|
}
|
|
20032
20033
|
toggleColorPicker() {
|
|
20033
20034
|
this.state.showGradient = !this.state.showGradient;
|
|
@@ -20137,7 +20138,6 @@ class GaugeChartConfigPanel extends Component {
|
|
|
20137
20138
|
GaugeChartConfigPanel.template = "o-spreadsheet-GaugeChartConfigPanel";
|
|
20138
20139
|
GaugeChartConfigPanel.components = { SelectionInput };
|
|
20139
20140
|
GaugeChartConfigPanel.props = {
|
|
20140
|
-
sheetId: String,
|
|
20141
20141
|
figureId: String,
|
|
20142
20142
|
definition: Object,
|
|
20143
20143
|
updateChart: Function,
|
|
@@ -20291,7 +20291,7 @@ GaugeChartDesignPanel.props = {
|
|
|
20291
20291
|
|
|
20292
20292
|
class LineConfigPanel extends LineBarPieConfigPanel {
|
|
20293
20293
|
get canTreatLabelsAsText() {
|
|
20294
|
-
const chart = this.env.model.getters.getChart(this.props.
|
|
20294
|
+
const chart = this.env.model.getters.getChart(this.props.figureId);
|
|
20295
20295
|
if (chart && chart instanceof LineChart) {
|
|
20296
20296
|
return canChartParseLabels(chart.labelRange, this.env.model.getters);
|
|
20297
20297
|
}
|
|
@@ -20368,7 +20368,6 @@ class ScorecardChartConfigPanel extends Component {
|
|
|
20368
20368
|
ScorecardChartConfigPanel.template = "o-spreadsheet-ScorecardChartConfigPanel";
|
|
20369
20369
|
ScorecardChartConfigPanel.components = { SelectionInput };
|
|
20370
20370
|
ScorecardChartConfigPanel.props = {
|
|
20371
|
-
sheetId: String,
|
|
20372
20371
|
figureId: String,
|
|
20373
20372
|
definition: Object,
|
|
20374
20373
|
updateChart: Function,
|
|
@@ -20500,7 +20499,7 @@ class ChartPanel extends Component {
|
|
|
20500
20499
|
else {
|
|
20501
20500
|
this.shouldUpdateChart = true;
|
|
20502
20501
|
}
|
|
20503
|
-
if (!this.env.model.getters.isChartDefined(this.
|
|
20502
|
+
if (!this.env.model.getters.isChartDefined(this.figureId)) {
|
|
20504
20503
|
this.props.onCloseSidePanel();
|
|
20505
20504
|
return;
|
|
20506
20505
|
}
|
|
@@ -20521,7 +20520,7 @@ class ChartPanel extends Component {
|
|
|
20521
20520
|
});
|
|
20522
20521
|
}
|
|
20523
20522
|
onTypeChange(type) {
|
|
20524
|
-
const context = this.env.model.getters.getContextCreationChart(this.
|
|
20523
|
+
const context = this.env.model.getters.getContextCreationChart(this.figureId);
|
|
20525
20524
|
if (!context) {
|
|
20526
20525
|
throw new Error("Chart not defined.");
|
|
20527
20526
|
}
|
|
@@ -20533,7 +20532,7 @@ class ChartPanel extends Component {
|
|
|
20533
20532
|
});
|
|
20534
20533
|
}
|
|
20535
20534
|
get chartPanel() {
|
|
20536
|
-
const type = this.env.model.getters.getChartType(this.
|
|
20535
|
+
const type = this.env.model.getters.getChartType(this.figureId);
|
|
20537
20536
|
if (!type) {
|
|
20538
20537
|
throw new Error("Chart not defined.");
|
|
20539
20538
|
}
|
|
@@ -20543,8 +20542,8 @@ class ChartPanel extends Component {
|
|
|
20543
20542
|
}
|
|
20544
20543
|
return chartPanel;
|
|
20545
20544
|
}
|
|
20546
|
-
getChartDefinition() {
|
|
20547
|
-
return this.env.model.getters.getChartDefinition(
|
|
20545
|
+
getChartDefinition(figureId = this.figureId) {
|
|
20546
|
+
return this.env.model.getters.getChartDefinition(figureId);
|
|
20548
20547
|
}
|
|
20549
20548
|
get chartTypes() {
|
|
20550
20549
|
return getChartTypes();
|
|
@@ -27103,13 +27102,7 @@ function load(data, verboseImport) {
|
|
|
27103
27102
|
data = migrate(data);
|
|
27104
27103
|
}
|
|
27105
27104
|
}
|
|
27106
|
-
|
|
27107
|
-
// sensible default values
|
|
27108
|
-
data = Object.assign(createEmptyWorkbookData(), data, { version: CURRENT_VERSION });
|
|
27109
|
-
data.sheets = data.sheets.map((s, i) => Object.assign(createEmptySheet(`Sheet${i + 1}`, `Sheet${i + 1}`), s));
|
|
27110
|
-
if (data.sheets.length === 0) {
|
|
27111
|
-
data.sheets.push(createEmptySheet(INITIAL_SHEET_ID, "Sheet1"));
|
|
27112
|
-
}
|
|
27105
|
+
data = repairData(data);
|
|
27113
27106
|
return data;
|
|
27114
27107
|
}
|
|
27115
27108
|
function migrate(data) {
|
|
@@ -27347,6 +27340,48 @@ const MIGRATIONS = [
|
|
|
27347
27340
|
},
|
|
27348
27341
|
},
|
|
27349
27342
|
];
|
|
27343
|
+
/**
|
|
27344
|
+
* This function is used to repair faulty data independently of the migration.
|
|
27345
|
+
*/
|
|
27346
|
+
function repairData(data) {
|
|
27347
|
+
data = forceUnicityOfFigure(data);
|
|
27348
|
+
data = setDefaults(data);
|
|
27349
|
+
return data;
|
|
27350
|
+
}
|
|
27351
|
+
/**
|
|
27352
|
+
* Force the unicity of figure ids accross sheets
|
|
27353
|
+
*/
|
|
27354
|
+
function forceUnicityOfFigure(data) {
|
|
27355
|
+
if (data.uniqueFigureIds) {
|
|
27356
|
+
return data;
|
|
27357
|
+
}
|
|
27358
|
+
const figureIds = new Set();
|
|
27359
|
+
const uuidGenerator = new UuidGenerator();
|
|
27360
|
+
for (const sheet of data.sheets || []) {
|
|
27361
|
+
for (const figure of sheet.figures || []) {
|
|
27362
|
+
if (figureIds.has(figure.id)) {
|
|
27363
|
+
figure.id += uuidGenerator.uuidv4();
|
|
27364
|
+
}
|
|
27365
|
+
figureIds.add(figure.id);
|
|
27366
|
+
}
|
|
27367
|
+
}
|
|
27368
|
+
data.uniqueFigureIds = true;
|
|
27369
|
+
return data;
|
|
27370
|
+
}
|
|
27371
|
+
/**
|
|
27372
|
+
* sanity check: try to fix missing fields/corrupted state by providing
|
|
27373
|
+
* sensible default values
|
|
27374
|
+
*/
|
|
27375
|
+
function setDefaults(data) {
|
|
27376
|
+
data = Object.assign(createEmptyWorkbookData(), data, { version: CURRENT_VERSION });
|
|
27377
|
+
data.sheets = data.sheets
|
|
27378
|
+
? data.sheets.map((s, i) => Object.assign(createEmptySheet(`Sheet${i + 1}`, `Sheet${i + 1}`), s))
|
|
27379
|
+
: [];
|
|
27380
|
+
if (data.sheets.length === 0) {
|
|
27381
|
+
data.sheets.push(createEmptySheet(INITIAL_SHEET_ID, "Sheet1"));
|
|
27382
|
+
}
|
|
27383
|
+
return data;
|
|
27384
|
+
}
|
|
27350
27385
|
/**
|
|
27351
27386
|
* The goal of this function is to repair corrupted/wrong initial messages caused by
|
|
27352
27387
|
* a bug.
|
|
@@ -27485,6 +27520,7 @@ function createEmptyWorkbookData(sheetName = "Sheet1") {
|
|
|
27485
27520
|
formats: {},
|
|
27486
27521
|
borders: {},
|
|
27487
27522
|
revisionId: DEFAULT_REVISION_ID,
|
|
27523
|
+
uniqueFigureIds: true,
|
|
27488
27524
|
};
|
|
27489
27525
|
return data;
|
|
27490
27526
|
}
|
|
@@ -28482,10 +28518,8 @@ class ChartPlugin extends CorePlugin {
|
|
|
28482
28518
|
this.validateChartDefinition = (cmd) => validateChartDefinition(this, cmd.definition);
|
|
28483
28519
|
}
|
|
28484
28520
|
adaptRanges(applyChange) {
|
|
28485
|
-
for (const
|
|
28486
|
-
|
|
28487
|
-
this.history.update("charts", sheetId, chartId, chart === null || chart === void 0 ? void 0 : chart.updateRanges(applyChange));
|
|
28488
|
-
}
|
|
28521
|
+
for (const [chartId, chart] of Object.entries(this.charts)) {
|
|
28522
|
+
this.history.update("charts", chartId, chart === null || chart === void 0 ? void 0 : chart.updateRanges(applyChange));
|
|
28489
28523
|
}
|
|
28490
28524
|
}
|
|
28491
28525
|
// ---------------------------------------------------------------------------
|
|
@@ -28496,20 +28530,20 @@ class ChartPlugin extends CorePlugin {
|
|
|
28496
28530
|
case "CREATE_CHART":
|
|
28497
28531
|
return this.checkValidations(cmd, this.chainValidations(this.validateChartDefinition, this.checkChartDuplicate));
|
|
28498
28532
|
case "UPDATE_CHART":
|
|
28499
|
-
return this.
|
|
28533
|
+
return this.checkValidations(cmd, this.chainValidations(this.validateChartDefinition, this.checkChartExists));
|
|
28500
28534
|
default:
|
|
28501
28535
|
return 0 /* CommandResult.Success */;
|
|
28502
28536
|
}
|
|
28503
28537
|
}
|
|
28504
28538
|
handle(cmd) {
|
|
28505
|
-
var _a
|
|
28539
|
+
var _a;
|
|
28506
28540
|
switch (cmd.type) {
|
|
28507
28541
|
case "CREATE_CHART":
|
|
28508
28542
|
this.addFigure(cmd.id, cmd.sheetId, cmd.position, cmd.size);
|
|
28509
|
-
this.addChart(cmd.id, cmd.
|
|
28543
|
+
this.addChart(cmd.id, cmd.definition);
|
|
28510
28544
|
break;
|
|
28511
28545
|
case "UPDATE_CHART": {
|
|
28512
|
-
this.addChart(cmd.id, cmd.
|
|
28546
|
+
this.addChart(cmd.id, cmd.definition);
|
|
28513
28547
|
break;
|
|
28514
28548
|
}
|
|
28515
28549
|
case "DUPLICATE_SHEET": {
|
|
@@ -28518,7 +28552,7 @@ class ChartPlugin extends CorePlugin {
|
|
|
28518
28552
|
if (fig.tag === "chart") {
|
|
28519
28553
|
const figureIdBase = fig.id.split(FIGURE_ID_SPLITTER).pop();
|
|
28520
28554
|
const duplicatedFigureId = `${cmd.sheetIdTo}${FIGURE_ID_SPLITTER}${figureIdBase}`;
|
|
28521
|
-
const chart = (
|
|
28555
|
+
const chart = (_a = this.charts[fig.id]) === null || _a === void 0 ? void 0 : _a.copyForSheetId(cmd.sheetIdTo);
|
|
28522
28556
|
if (chart) {
|
|
28523
28557
|
this.dispatch("CREATE_CHART", {
|
|
28524
28558
|
id: duplicatedFigureId,
|
|
@@ -28533,41 +28567,44 @@ class ChartPlugin extends CorePlugin {
|
|
|
28533
28567
|
break;
|
|
28534
28568
|
}
|
|
28535
28569
|
case "DELETE_FIGURE":
|
|
28536
|
-
this.history.update("charts", cmd.
|
|
28570
|
+
this.history.update("charts", cmd.id, undefined);
|
|
28537
28571
|
break;
|
|
28538
28572
|
case "DELETE_SHEET":
|
|
28539
|
-
this.
|
|
28573
|
+
for (let id of this.getChartIds(cmd.sheetId)) {
|
|
28574
|
+
this.history.update("charts", id, undefined);
|
|
28575
|
+
}
|
|
28540
28576
|
break;
|
|
28541
28577
|
}
|
|
28542
28578
|
}
|
|
28543
28579
|
// ---------------------------------------------------------------------------
|
|
28544
28580
|
// Getters
|
|
28545
28581
|
// ---------------------------------------------------------------------------
|
|
28546
|
-
getContextCreationChart(
|
|
28547
|
-
var _a, _b;
|
|
28548
|
-
return (_b = (_a = this.charts[sheetId]) === null || _a === void 0 ? void 0 : _a[figureId]) === null || _b === void 0 ? void 0 : _b.getContextCreation();
|
|
28549
|
-
}
|
|
28550
|
-
getChart(sheetId, figureId) {
|
|
28582
|
+
getContextCreationChart(figureId) {
|
|
28551
28583
|
var _a;
|
|
28552
|
-
return (_a = this.charts[
|
|
28584
|
+
return (_a = this.charts[figureId]) === null || _a === void 0 ? void 0 : _a.getContextCreation();
|
|
28553
28585
|
}
|
|
28554
|
-
|
|
28555
|
-
|
|
28556
|
-
|
|
28586
|
+
getChart(figureId) {
|
|
28587
|
+
return this.charts[figureId];
|
|
28588
|
+
}
|
|
28589
|
+
getChartType(figureId) {
|
|
28590
|
+
var _a;
|
|
28591
|
+
const type = (_a = this.charts[figureId]) === null || _a === void 0 ? void 0 : _a.type;
|
|
28557
28592
|
if (!type) {
|
|
28558
28593
|
throw new Error("Chart not defined.");
|
|
28559
28594
|
}
|
|
28560
28595
|
return type;
|
|
28561
28596
|
}
|
|
28562
|
-
isChartDefined(
|
|
28563
|
-
return figureId in
|
|
28597
|
+
isChartDefined(figureId) {
|
|
28598
|
+
return figureId in this.charts && this.charts !== undefined;
|
|
28564
28599
|
}
|
|
28565
28600
|
getChartIds(sheetId) {
|
|
28566
|
-
return Object.
|
|
28601
|
+
return Object.entries(this.charts)
|
|
28602
|
+
.filter(([, chart]) => (chart === null || chart === void 0 ? void 0 : chart.sheetId) === sheetId)
|
|
28603
|
+
.map(([id]) => id);
|
|
28567
28604
|
}
|
|
28568
|
-
getChartDefinition(
|
|
28569
|
-
var _a
|
|
28570
|
-
const definition = (
|
|
28605
|
+
getChartDefinition(figureId) {
|
|
28606
|
+
var _a;
|
|
28607
|
+
const definition = (_a = this.charts[figureId]) === null || _a === void 0 ? void 0 : _a.getDefinition();
|
|
28571
28608
|
if (!definition) {
|
|
28572
28609
|
throw new Error(`There is no chart with the given figureId: ${figureId}`);
|
|
28573
28610
|
}
|
|
@@ -28579,28 +28616,35 @@ class ChartPlugin extends CorePlugin {
|
|
|
28579
28616
|
import(data) {
|
|
28580
28617
|
for (let sheet of data.sheets) {
|
|
28581
28618
|
if (sheet.figures) {
|
|
28582
|
-
const charts = {};
|
|
28583
28619
|
for (let figure of sheet.figures) {
|
|
28584
28620
|
// TODO:
|
|
28585
28621
|
// figure data should be external IMO => chart should be in sheet.chart
|
|
28586
28622
|
// instead of in figure.data
|
|
28587
28623
|
if (figure.tag === "chart") {
|
|
28588
|
-
charts[figure.id] = this.createChart(figure.id, figure.data, sheet.id);
|
|
28624
|
+
this.charts[figure.id] = this.createChart(figure.id, figure.data, sheet.id);
|
|
28589
28625
|
}
|
|
28590
28626
|
}
|
|
28591
|
-
this.charts[sheet.id] = charts;
|
|
28592
28627
|
}
|
|
28593
28628
|
}
|
|
28594
28629
|
}
|
|
28595
28630
|
export(data) {
|
|
28631
|
+
var _a;
|
|
28596
28632
|
if (data.sheets) {
|
|
28597
28633
|
for (let sheet of data.sheets) {
|
|
28598
28634
|
// TODO This code is false, if two plugins want ot insert figures on the sheet, it will crash !
|
|
28599
28635
|
const sheetFigures = this.getters.getFigures(sheet.id);
|
|
28600
|
-
const figures =
|
|
28601
|
-
for (let
|
|
28636
|
+
const figures = [];
|
|
28637
|
+
for (let sheetFigure of sheetFigures) {
|
|
28638
|
+
const figure = sheetFigure;
|
|
28602
28639
|
if (figure && figure.tag === "chart") {
|
|
28603
|
-
|
|
28640
|
+
const data = (_a = this.charts[figure.id]) === null || _a === void 0 ? void 0 : _a.getDefinition();
|
|
28641
|
+
if (data) {
|
|
28642
|
+
figure.data = data;
|
|
28643
|
+
figures.push(figure);
|
|
28644
|
+
}
|
|
28645
|
+
}
|
|
28646
|
+
else {
|
|
28647
|
+
figures.push(figure);
|
|
28604
28648
|
}
|
|
28605
28649
|
}
|
|
28606
28650
|
sheet.figures = figures;
|
|
@@ -28608,13 +28652,13 @@ class ChartPlugin extends CorePlugin {
|
|
|
28608
28652
|
}
|
|
28609
28653
|
}
|
|
28610
28654
|
exportForExcel(data) {
|
|
28611
|
-
var _a
|
|
28655
|
+
var _a;
|
|
28612
28656
|
for (let sheet of data.sheets) {
|
|
28613
28657
|
const sheetFigures = this.getters.getFigures(sheet.id);
|
|
28614
28658
|
const figures = [];
|
|
28615
28659
|
for (let figure of sheetFigures) {
|
|
28616
28660
|
if (figure && figure.tag === "chart") {
|
|
28617
|
-
const figureData = (
|
|
28661
|
+
const figureData = (_a = this.charts[figure.id]) === null || _a === void 0 ? void 0 : _a.getDefinitionForExcel();
|
|
28618
28662
|
if (figureData) {
|
|
28619
28663
|
figures.push({
|
|
28620
28664
|
...figure,
|
|
@@ -28653,15 +28697,21 @@ class ChartPlugin extends CorePlugin {
|
|
|
28653
28697
|
* Add a chart in the local state. If a chart already exists, this chart is
|
|
28654
28698
|
* replaced
|
|
28655
28699
|
*/
|
|
28656
|
-
addChart(id,
|
|
28657
|
-
|
|
28700
|
+
addChart(id, definition) {
|
|
28701
|
+
const sheetId = this.getters.getFigureSheetId(id);
|
|
28702
|
+
if (sheetId) {
|
|
28703
|
+
this.history.update("charts", id, this.createChart(id, definition, sheetId));
|
|
28704
|
+
}
|
|
28658
28705
|
}
|
|
28659
28706
|
checkChartDuplicate(cmd) {
|
|
28660
|
-
|
|
28661
|
-
|
|
28662
|
-
|
|
28663
|
-
|
|
28664
|
-
|
|
28707
|
+
return this.getters.getFigureSheetId(cmd.id)
|
|
28708
|
+
? 84 /* CommandResult.DuplicatedChartId */
|
|
28709
|
+
: 0 /* CommandResult.Success */;
|
|
28710
|
+
}
|
|
28711
|
+
checkChartExists(cmd) {
|
|
28712
|
+
return this.getters.getFigureSheetId(cmd.id)
|
|
28713
|
+
? 0 /* CommandResult.Success */
|
|
28714
|
+
: 85 /* CommandResult.ChartDoesNotExist */;
|
|
28665
28715
|
}
|
|
28666
28716
|
}
|
|
28667
28717
|
ChartPlugin.getters = [
|
|
@@ -29042,7 +29092,7 @@ class FigurePlugin extends CorePlugin {
|
|
|
29042
29092
|
allowDispatch(cmd) {
|
|
29043
29093
|
switch (cmd.type) {
|
|
29044
29094
|
case "CREATE_FIGURE":
|
|
29045
|
-
return this.checkFigureDuplicate(cmd.
|
|
29095
|
+
return this.checkFigureDuplicate(cmd.figure.id);
|
|
29046
29096
|
case "UPDATE_FIGURE":
|
|
29047
29097
|
case "DELETE_FIGURE":
|
|
29048
29098
|
return this.checkFigureExists(cmd.sheetId, cmd.id);
|
|
@@ -29108,9 +29158,8 @@ class FigurePlugin extends CorePlugin {
|
|
|
29108
29158
|
}
|
|
29109
29159
|
return 0 /* CommandResult.Success */;
|
|
29110
29160
|
}
|
|
29111
|
-
checkFigureDuplicate(
|
|
29112
|
-
|
|
29113
|
-
if ((_a = this.figures[sheetId]) === null || _a === void 0 ? void 0 : _a[figureId]) {
|
|
29161
|
+
checkFigureDuplicate(figureId) {
|
|
29162
|
+
if (Object.values(this.figures).find((sheet) => sheet === null || sheet === void 0 ? void 0 : sheet[figureId])) {
|
|
29114
29163
|
return 82 /* CommandResult.DuplicatedFigureId */;
|
|
29115
29164
|
}
|
|
29116
29165
|
return 0 /* CommandResult.Success */;
|
|
@@ -29125,6 +29174,9 @@ class FigurePlugin extends CorePlugin {
|
|
|
29125
29174
|
var _a;
|
|
29126
29175
|
return (_a = this.figures[sheetId]) === null || _a === void 0 ? void 0 : _a[figureId];
|
|
29127
29176
|
}
|
|
29177
|
+
getFigureSheetId(figureId) {
|
|
29178
|
+
return Object.keys(this.figures).find((sheetId) => { var _a; return ((_a = this.figures[sheetId]) === null || _a === void 0 ? void 0 : _a[figureId]) !== undefined; });
|
|
29179
|
+
}
|
|
29128
29180
|
// ---------------------------------------------------------------------------
|
|
29129
29181
|
// Import/Export
|
|
29130
29182
|
// ---------------------------------------------------------------------------
|
|
@@ -29149,7 +29201,7 @@ class FigurePlugin extends CorePlugin {
|
|
|
29149
29201
|
this.export(data);
|
|
29150
29202
|
}
|
|
29151
29203
|
}
|
|
29152
|
-
FigurePlugin.getters = ["getFigures", "getFigure"];
|
|
29204
|
+
FigurePlugin.getters = ["getFigures", "getFigure", "getFigureSheetId"];
|
|
29153
29205
|
|
|
29154
29206
|
class FilterTable {
|
|
29155
29207
|
constructor(zone) {
|
|
@@ -29876,7 +29928,7 @@ class ImagePlugin extends CorePlugin {
|
|
|
29876
29928
|
switch (cmd.type) {
|
|
29877
29929
|
case "CREATE_IMAGE":
|
|
29878
29930
|
if (this.getters.getFigure(cmd.sheetId, cmd.figureId)) {
|
|
29879
|
-
return 28 /* CommandResult.
|
|
29931
|
+
return 28 /* CommandResult.InvalidFigureId */;
|
|
29880
29932
|
}
|
|
29881
29933
|
return 0 /* CommandResult.Success */;
|
|
29882
29934
|
default:
|
|
@@ -29896,7 +29948,7 @@ class ImagePlugin extends CorePlugin {
|
|
|
29896
29948
|
if (fig.tag === "image") {
|
|
29897
29949
|
const figureIdBase = fig.id.split(FIGURE_ID_SPLITTER).pop();
|
|
29898
29950
|
const duplicatedFigureId = `${cmd.sheetIdTo}${FIGURE_ID_SPLITTER}${figureIdBase}`;
|
|
29899
|
-
const image = this.getImage(
|
|
29951
|
+
const image = this.getImage(fig.id);
|
|
29900
29952
|
if (image) {
|
|
29901
29953
|
const size = { width: fig.width, height: fig.height };
|
|
29902
29954
|
this.dispatch("CREATE_IMAGE", {
|
|
@@ -29934,13 +29986,19 @@ class ImagePlugin extends CorePlugin {
|
|
|
29934
29986
|
// ---------------------------------------------------------------------------
|
|
29935
29987
|
// Getters
|
|
29936
29988
|
// ---------------------------------------------------------------------------
|
|
29937
|
-
getImage(
|
|
29938
|
-
|
|
29939
|
-
|
|
29940
|
-
|
|
29941
|
-
|
|
29989
|
+
getImage(figureId) {
|
|
29990
|
+
for (const sheet of Object.values(this.images)) {
|
|
29991
|
+
if (sheet && sheet[figureId]) {
|
|
29992
|
+
return sheet[figureId];
|
|
29993
|
+
}
|
|
29942
29994
|
}
|
|
29943
|
-
|
|
29995
|
+
throw new Error(`There is no image with the given figureId: ${figureId}`);
|
|
29996
|
+
}
|
|
29997
|
+
getImagePath(figureId) {
|
|
29998
|
+
return this.getImage(figureId).path;
|
|
29999
|
+
}
|
|
30000
|
+
getImageSize(figureId) {
|
|
30001
|
+
return this.getImage(figureId).size;
|
|
29944
30002
|
}
|
|
29945
30003
|
// ---------------------------------------------------------------------------
|
|
29946
30004
|
// Private
|
|
@@ -29982,7 +30040,7 @@ class ImagePlugin extends CorePlugin {
|
|
|
29982
30040
|
return images;
|
|
29983
30041
|
}
|
|
29984
30042
|
}
|
|
29985
|
-
ImagePlugin.getters = ["getImage"];
|
|
30043
|
+
ImagePlugin.getters = ["getImage", "getImagePath", "getImageSize"];
|
|
29986
30044
|
|
|
29987
30045
|
class MergePlugin extends CorePlugin {
|
|
29988
30046
|
constructor() {
|
|
@@ -31783,9 +31841,7 @@ class CustomColorsPlugin extends UIPlugin {
|
|
|
31783
31841
|
return formatColors.filter(isDefined$1);
|
|
31784
31842
|
}
|
|
31785
31843
|
getChartColors(sheetId) {
|
|
31786
|
-
const charts = this.getters
|
|
31787
|
-
.getChartIds(sheetId)
|
|
31788
|
-
.map((cid) => this.getters.getChart(sheetId, cid));
|
|
31844
|
+
const charts = this.getters.getChartIds(sheetId).map((cid) => this.getters.getChart(cid));
|
|
31789
31845
|
let chartsColors = new Set();
|
|
31790
31846
|
for (let chart of charts) {
|
|
31791
31847
|
if (chart === undefined) {
|
|
@@ -32141,37 +32197,34 @@ class EvaluationChartPlugin extends UIPlugin {
|
|
|
32141
32197
|
invalidateCFEvaluationCommands.has(cmd.type) ||
|
|
32142
32198
|
cmd.type === "EVALUATE_CELLS" ||
|
|
32143
32199
|
cmd.type === "UPDATE_CELL") {
|
|
32144
|
-
for (const
|
|
32145
|
-
|
|
32146
|
-
this.charts[sheetId][chartId] = undefined;
|
|
32147
|
-
}
|
|
32200
|
+
for (const chartId in this.charts) {
|
|
32201
|
+
this.charts[chartId] = undefined;
|
|
32148
32202
|
}
|
|
32149
32203
|
}
|
|
32150
32204
|
switch (cmd.type) {
|
|
32151
32205
|
case "UPDATE_CHART":
|
|
32152
32206
|
case "CREATE_CHART":
|
|
32153
32207
|
case "DELETE_FIGURE":
|
|
32154
|
-
|
|
32155
|
-
this.charts[cmd.sheetId][cmd.id] = undefined;
|
|
32156
|
-
}
|
|
32208
|
+
this.charts[cmd.id] = undefined;
|
|
32157
32209
|
break;
|
|
32158
32210
|
case "DELETE_SHEET":
|
|
32159
|
-
|
|
32211
|
+
for (let chartId in this.charts) {
|
|
32212
|
+
if (!this.getters.isChartDefined(chartId)) {
|
|
32213
|
+
this.charts[chartId] = undefined;
|
|
32214
|
+
}
|
|
32215
|
+
}
|
|
32160
32216
|
break;
|
|
32161
32217
|
}
|
|
32162
32218
|
}
|
|
32163
|
-
getChartRuntime(
|
|
32164
|
-
|
|
32165
|
-
|
|
32166
|
-
const chart = this.getters.getChart(sheetId, figureId);
|
|
32219
|
+
getChartRuntime(figureId) {
|
|
32220
|
+
if (!this.charts[figureId]) {
|
|
32221
|
+
const chart = this.getters.getChart(figureId);
|
|
32167
32222
|
if (!chart) {
|
|
32168
32223
|
throw new Error(`No chart for the given id: ${figureId}`);
|
|
32169
32224
|
}
|
|
32170
|
-
|
|
32171
|
-
this.charts[sheetId] = {};
|
|
32172
|
-
this.charts[sheetId][figureId] = this.createRuntimeChart(chart);
|
|
32225
|
+
this.charts[figureId] = this.createRuntimeChart(chart);
|
|
32173
32226
|
}
|
|
32174
|
-
return this.charts[
|
|
32227
|
+
return this.charts[figureId];
|
|
32175
32228
|
}
|
|
32176
32229
|
/**
|
|
32177
32230
|
* Get the background color of a chart based on the color of the first cell of the main range
|
|
@@ -32607,6 +32660,9 @@ class FilterEvaluationPlugin extends UIPlugin {
|
|
|
32607
32660
|
case "CREATE_SHEET":
|
|
32608
32661
|
this.filterValues[cmd.sheetId] = {};
|
|
32609
32662
|
break;
|
|
32663
|
+
case "HIDE_COLUMNS_ROWS":
|
|
32664
|
+
this.updateHiddenRows();
|
|
32665
|
+
break;
|
|
32610
32666
|
case "UPDATE_FILTER":
|
|
32611
32667
|
this.updateFilter(cmd);
|
|
32612
32668
|
this.updateHiddenRows();
|
|
@@ -32715,9 +32771,16 @@ class FilterEvaluationPlugin extends UIPlugin {
|
|
|
32715
32771
|
updateHiddenRows() {
|
|
32716
32772
|
var _a, _b;
|
|
32717
32773
|
const sheetId = this.getters.getActiveSheetId();
|
|
32718
|
-
const filters = this.getters
|
|
32774
|
+
const filters = this.getters
|
|
32775
|
+
.getFilters(sheetId)
|
|
32776
|
+
.sort((filter1, filter2) => filter1.zoneWithHeaders.top - filter2.zoneWithHeaders.top);
|
|
32719
32777
|
const hiddenRows = new Set();
|
|
32720
32778
|
for (let filter of filters) {
|
|
32779
|
+
// Disable filters whose header are hidden
|
|
32780
|
+
if (this.getters.isRowHiddenByUser(sheetId, filter.zoneWithHeaders.top))
|
|
32781
|
+
continue;
|
|
32782
|
+
if (hiddenRows.has(filter.zoneWithHeaders.top))
|
|
32783
|
+
continue;
|
|
32721
32784
|
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);
|
|
32722
32785
|
if (!filteredValues || !filter.filteredZone)
|
|
32723
32786
|
continue;
|
|
@@ -37815,7 +37878,7 @@ class ClipboardFigureChart {
|
|
|
37815
37878
|
constructor(dispatch, getters, sheetId, copiedFigureId) {
|
|
37816
37879
|
this.dispatch = dispatch;
|
|
37817
37880
|
this.sheetId = sheetId;
|
|
37818
|
-
const chart = getters.getChart(
|
|
37881
|
+
const chart = getters.getChart(copiedFigureId);
|
|
37819
37882
|
if (!chart) {
|
|
37820
37883
|
throw new Error(`No chart for the given id: ${copiedFigureId}`);
|
|
37821
37884
|
}
|
|
@@ -37836,7 +37899,7 @@ class ClipboardFigureImage {
|
|
|
37836
37899
|
constructor(dispatch, getters, sheetId, copiedFigureId) {
|
|
37837
37900
|
this.dispatch = dispatch;
|
|
37838
37901
|
this.sheetId = sheetId;
|
|
37839
|
-
const image = getters.getImage(
|
|
37902
|
+
const image = getters.getImage(copiedFigureId);
|
|
37840
37903
|
this.copiedImage = deepCopy(image);
|
|
37841
37904
|
}
|
|
37842
37905
|
paste(sheetId, figureId, position, size) {
|
|
@@ -43816,6 +43879,6 @@ function addFunction(functionName, functionDescription) {
|
|
|
43816
43879
|
export { AbstractChart, CommandResult, CorePlugin, DATETIME_FORMAT, DispatchResult, EvaluationError, Model, Registry, Revision, SPREADSHEET_DIMENSIONS, Spreadsheet, UIPlugin, __info__, addFunction, astToFormula, compile, components, convertAstNodes, coreTypes, findCellInNewZone, functionCache, helpers, invalidateEvaluationCommands, links, load, parse, readonlyAllowedCommands, registries, setTranslationMethod, tokenize };
|
|
43817
43880
|
|
|
43818
43881
|
|
|
43819
|
-
__info__.version = '16.1.
|
|
43820
|
-
__info__.date = '2023-03-
|
|
43821
|
-
__info__.hash = '
|
|
43882
|
+
__info__.version = '16.1.4';
|
|
43883
|
+
__info__.date = '2023-03-14T09:27:28.837Z';
|
|
43884
|
+
__info__.hash = 'c8882d9';
|