@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.
- package/dist/{o_spreadsheet.cjs.js → o-spreadsheet.cjs.js} +150 -89
- package/dist/{o_spreadsheet.d.ts → o-spreadsheet.d.ts} +21 -20
- package/dist/{o_spreadsheet.esm.js → o-spreadsheet.esm.js} +150 -89
- package/dist/{o_spreadsheet.iife.js → o-spreadsheet.iife.js} +150 -89
- package/dist/{o_spreadsheet.iife.min.js → o-spreadsheet.iife.min.js} +8 -8
- package/package.json +10 -9
- package/readme.md +3 -1
|
@@ -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;
|
|
@@ -8385,7 +8386,7 @@ class ColorPicker extends owl.Component {
|
|
|
8385
8386
|
}
|
|
8386
8387
|
onColorClick(color) {
|
|
8387
8388
|
if (color) {
|
|
8388
|
-
this.props.onColorPicked(color);
|
|
8389
|
+
this.props.onColorPicked(toHex(color));
|
|
8389
8390
|
}
|
|
8390
8391
|
}
|
|
8391
8392
|
getCheckMarkColor() {
|
|
@@ -8400,8 +8401,10 @@ class ColorPicker extends owl.Component {
|
|
|
8400
8401
|
this.state.isCurrentColorInvalid = true;
|
|
8401
8402
|
return;
|
|
8402
8403
|
}
|
|
8404
|
+
const color = toHex(this.state.currentColor);
|
|
8403
8405
|
this.state.isCurrentColorInvalid = false;
|
|
8404
|
-
this.props.onColorPicked(
|
|
8406
|
+
this.props.onColorPicked(color);
|
|
8407
|
+
this.state.currentColor = color;
|
|
8405
8408
|
}
|
|
8406
8409
|
toggleColorPicker() {
|
|
8407
8410
|
this.state.showGradient = !this.state.showGradient;
|
|
@@ -8640,7 +8643,7 @@ GaugeChartDesignPanel.components = { ColorPicker };
|
|
|
8640
8643
|
|
|
8641
8644
|
class LineConfigPanel extends LineBarPieConfigPanel {
|
|
8642
8645
|
get canTreatLabelsAsText() {
|
|
8643
|
-
const chart = this.env.model.getters.getChart(this.props.
|
|
8646
|
+
const chart = this.env.model.getters.getChart(this.props.figureId);
|
|
8644
8647
|
if (chart && chart instanceof LineChart) {
|
|
8645
8648
|
return canChartParseLabels(chart, this.env.model.getters);
|
|
8646
8649
|
}
|
|
@@ -8833,7 +8836,7 @@ class ChartPanel extends owl.Component {
|
|
|
8833
8836
|
else {
|
|
8834
8837
|
this.shouldUpdateChart = true;
|
|
8835
8838
|
}
|
|
8836
|
-
if (!this.env.model.getters.isChartDefined(this.
|
|
8839
|
+
if (!this.env.model.getters.isChartDefined(this.figureId)) {
|
|
8837
8840
|
this.props.onCloseSidePanel();
|
|
8838
8841
|
return;
|
|
8839
8842
|
}
|
|
@@ -8854,7 +8857,7 @@ class ChartPanel extends owl.Component {
|
|
|
8854
8857
|
});
|
|
8855
8858
|
}
|
|
8856
8859
|
onTypeChange(type) {
|
|
8857
|
-
const context = this.env.model.getters.getContextCreationChart(this.
|
|
8860
|
+
const context = this.env.model.getters.getContextCreationChart(this.figureId);
|
|
8858
8861
|
if (!context) {
|
|
8859
8862
|
throw new Error("Chart not defined.");
|
|
8860
8863
|
}
|
|
@@ -8866,7 +8869,7 @@ class ChartPanel extends owl.Component {
|
|
|
8866
8869
|
});
|
|
8867
8870
|
}
|
|
8868
8871
|
get chartPanel() {
|
|
8869
|
-
const type = this.env.model.getters.getChartType(this.
|
|
8872
|
+
const type = this.env.model.getters.getChartType(this.figureId);
|
|
8870
8873
|
if (!type) {
|
|
8871
8874
|
throw new Error("Chart not defined.");
|
|
8872
8875
|
}
|
|
@@ -8876,8 +8879,8 @@ class ChartPanel extends owl.Component {
|
|
|
8876
8879
|
}
|
|
8877
8880
|
return chartPanel;
|
|
8878
8881
|
}
|
|
8879
|
-
getChartDefinition() {
|
|
8880
|
-
return this.env.model.getters.getChartDefinition(
|
|
8882
|
+
getChartDefinition(figureId = this.figureId) {
|
|
8883
|
+
return this.env.model.getters.getChartDefinition(figureId);
|
|
8881
8884
|
}
|
|
8882
8885
|
get chartTypes() {
|
|
8883
8886
|
return getChartTypes();
|
|
@@ -10013,7 +10016,7 @@ class ScorecardChart extends owl.Component {
|
|
|
10013
10016
|
this.ctx = document.createElement("canvas").getContext("2d");
|
|
10014
10017
|
}
|
|
10015
10018
|
get runtime() {
|
|
10016
|
-
return this.env.model.getters.getChartRuntime(this.
|
|
10019
|
+
return this.env.model.getters.getChartRuntime(this.props.figure.id);
|
|
10017
10020
|
}
|
|
10018
10021
|
get title() {
|
|
10019
10022
|
return this.runtime.title;
|
|
@@ -10038,7 +10041,7 @@ class ScorecardChart extends owl.Component {
|
|
|
10038
10041
|
return this.runtime.fontColor;
|
|
10039
10042
|
}
|
|
10040
10043
|
get secondaryFontColor() {
|
|
10041
|
-
return relativeLuminance(this.
|
|
10044
|
+
return relativeLuminance(this.backgroundColor) > 0.3 ? "#525252" : "#C8C8C8";
|
|
10042
10045
|
}
|
|
10043
10046
|
get figure() {
|
|
10044
10047
|
return this.props.figure;
|
|
@@ -10243,7 +10246,7 @@ class ChartFigure extends owl.Component {
|
|
|
10243
10246
|
return registry;
|
|
10244
10247
|
}
|
|
10245
10248
|
get chartType() {
|
|
10246
|
-
return this.env.model.getters.getChartType(this.
|
|
10249
|
+
return this.env.model.getters.getChartType(this.props.figure.id);
|
|
10247
10250
|
}
|
|
10248
10251
|
onContextMenu(ev) {
|
|
10249
10252
|
const position = {
|
|
@@ -26270,13 +26273,7 @@ function load(data, verboseImport) {
|
|
|
26270
26273
|
data = migrate(data);
|
|
26271
26274
|
}
|
|
26272
26275
|
}
|
|
26273
|
-
|
|
26274
|
-
// sensible default values
|
|
26275
|
-
data = Object.assign(createEmptyWorkbookData(), data, { version: CURRENT_VERSION });
|
|
26276
|
-
data.sheets = data.sheets.map((s, i) => Object.assign(createEmptySheet(`Sheet${i + 1}`, `Sheet${i + 1}`), s));
|
|
26277
|
-
if (data.sheets.length === 0) {
|
|
26278
|
-
data.sheets.push(createEmptySheet(INITIAL_SHEET_ID, "Sheet1"));
|
|
26279
|
-
}
|
|
26276
|
+
data = repairData(data);
|
|
26280
26277
|
return data;
|
|
26281
26278
|
}
|
|
26282
26279
|
function migrate(data) {
|
|
@@ -26514,6 +26511,48 @@ const MIGRATIONS = [
|
|
|
26514
26511
|
},
|
|
26515
26512
|
},
|
|
26516
26513
|
];
|
|
26514
|
+
/**
|
|
26515
|
+
* This function is used to repair faulty data independently of the migration.
|
|
26516
|
+
*/
|
|
26517
|
+
function repairData(data) {
|
|
26518
|
+
data = forceUnicityOfFigure(data);
|
|
26519
|
+
data = setDefaults(data);
|
|
26520
|
+
return data;
|
|
26521
|
+
}
|
|
26522
|
+
/**
|
|
26523
|
+
* Force the unicity of figure ids accross sheets
|
|
26524
|
+
*/
|
|
26525
|
+
function forceUnicityOfFigure(data) {
|
|
26526
|
+
if (data.uniqueFigureIds) {
|
|
26527
|
+
return data;
|
|
26528
|
+
}
|
|
26529
|
+
const figureIds = new Set();
|
|
26530
|
+
const uuidGenerator = new UuidGenerator();
|
|
26531
|
+
for (const sheet of data.sheets || []) {
|
|
26532
|
+
for (const figure of sheet.figures || []) {
|
|
26533
|
+
if (figureIds.has(figure.id)) {
|
|
26534
|
+
figure.id += uuidGenerator.uuidv4();
|
|
26535
|
+
}
|
|
26536
|
+
figureIds.add(figure.id);
|
|
26537
|
+
}
|
|
26538
|
+
}
|
|
26539
|
+
data.uniqueFigureIds = true;
|
|
26540
|
+
return data;
|
|
26541
|
+
}
|
|
26542
|
+
/**
|
|
26543
|
+
* sanity check: try to fix missing fields/corrupted state by providing
|
|
26544
|
+
* sensible default values
|
|
26545
|
+
*/
|
|
26546
|
+
function setDefaults(data) {
|
|
26547
|
+
data = Object.assign(createEmptyWorkbookData(), data, { version: CURRENT_VERSION });
|
|
26548
|
+
data.sheets = data.sheets
|
|
26549
|
+
? data.sheets.map((s, i) => Object.assign(createEmptySheet(`Sheet${i + 1}`, `Sheet${i + 1}`), s))
|
|
26550
|
+
: [];
|
|
26551
|
+
if (data.sheets.length === 0) {
|
|
26552
|
+
data.sheets.push(createEmptySheet(INITIAL_SHEET_ID, "Sheet1"));
|
|
26553
|
+
}
|
|
26554
|
+
return data;
|
|
26555
|
+
}
|
|
26517
26556
|
/**
|
|
26518
26557
|
* The goal of this function is to repair corrupted/wrong initial messages caused by
|
|
26519
26558
|
* a bug.
|
|
@@ -26652,6 +26691,7 @@ function createEmptyWorkbookData(sheetName = "Sheet1") {
|
|
|
26652
26691
|
formats: {},
|
|
26653
26692
|
borders: {},
|
|
26654
26693
|
revisionId: DEFAULT_REVISION_ID,
|
|
26694
|
+
uniqueFigureIds: true,
|
|
26655
26695
|
};
|
|
26656
26696
|
return data;
|
|
26657
26697
|
}
|
|
@@ -27574,10 +27614,8 @@ class ChartPlugin extends CorePlugin {
|
|
|
27574
27614
|
this.validateChartDefinition = (cmd) => validateChartDefinition(this, cmd.definition);
|
|
27575
27615
|
}
|
|
27576
27616
|
adaptRanges(applyChange) {
|
|
27577
|
-
for (const
|
|
27578
|
-
|
|
27579
|
-
this.history.update("charts", sheetId, chartId, chart === null || chart === void 0 ? void 0 : chart.updateRanges(applyChange));
|
|
27580
|
-
}
|
|
27617
|
+
for (const [chartId, chart] of Object.entries(this.charts)) {
|
|
27618
|
+
this.history.update("charts", chartId, chart === null || chart === void 0 ? void 0 : chart.updateRanges(applyChange));
|
|
27581
27619
|
}
|
|
27582
27620
|
}
|
|
27583
27621
|
// ---------------------------------------------------------------------------
|
|
@@ -27588,20 +27626,20 @@ class ChartPlugin extends CorePlugin {
|
|
|
27588
27626
|
case "CREATE_CHART":
|
|
27589
27627
|
return this.checkValidations(cmd, this.chainValidations(this.validateChartDefinition, this.checkChartDuplicate));
|
|
27590
27628
|
case "UPDATE_CHART":
|
|
27591
|
-
return this.
|
|
27629
|
+
return this.checkValidations(cmd, this.chainValidations(this.validateChartDefinition, this.checkChartExists));
|
|
27592
27630
|
default:
|
|
27593
27631
|
return 0 /* CommandResult.Success */;
|
|
27594
27632
|
}
|
|
27595
27633
|
}
|
|
27596
27634
|
handle(cmd) {
|
|
27597
|
-
var _a
|
|
27635
|
+
var _a;
|
|
27598
27636
|
switch (cmd.type) {
|
|
27599
27637
|
case "CREATE_CHART":
|
|
27600
27638
|
this.addFigure(cmd.id, cmd.sheetId, cmd.position, cmd.size);
|
|
27601
|
-
this.addChart(cmd.id, cmd.
|
|
27639
|
+
this.addChart(cmd.id, cmd.definition);
|
|
27602
27640
|
break;
|
|
27603
27641
|
case "UPDATE_CHART": {
|
|
27604
|
-
this.addChart(cmd.id, cmd.
|
|
27642
|
+
this.addChart(cmd.id, cmd.definition);
|
|
27605
27643
|
break;
|
|
27606
27644
|
}
|
|
27607
27645
|
case "DUPLICATE_SHEET": {
|
|
@@ -27610,7 +27648,7 @@ class ChartPlugin extends CorePlugin {
|
|
|
27610
27648
|
if (fig.tag === "chart") {
|
|
27611
27649
|
const figureIdBase = fig.id.split(FIGURE_ID_SPLITTER).pop();
|
|
27612
27650
|
const duplicatedFigureId = `${cmd.sheetIdTo}${FIGURE_ID_SPLITTER}${figureIdBase}`;
|
|
27613
|
-
const chart = (
|
|
27651
|
+
const chart = (_a = this.charts[fig.id]) === null || _a === void 0 ? void 0 : _a.copyForSheetId(cmd.sheetIdTo);
|
|
27614
27652
|
if (chart) {
|
|
27615
27653
|
this.dispatch("CREATE_CHART", {
|
|
27616
27654
|
id: duplicatedFigureId,
|
|
@@ -27625,41 +27663,44 @@ class ChartPlugin extends CorePlugin {
|
|
|
27625
27663
|
break;
|
|
27626
27664
|
}
|
|
27627
27665
|
case "DELETE_FIGURE":
|
|
27628
|
-
this.history.update("charts", cmd.
|
|
27666
|
+
this.history.update("charts", cmd.id, undefined);
|
|
27629
27667
|
break;
|
|
27630
27668
|
case "DELETE_SHEET":
|
|
27631
|
-
this.
|
|
27669
|
+
for (let id of this.getChartIds(cmd.sheetId)) {
|
|
27670
|
+
this.history.update("charts", id, undefined);
|
|
27671
|
+
}
|
|
27632
27672
|
break;
|
|
27633
27673
|
}
|
|
27634
27674
|
}
|
|
27635
27675
|
// ---------------------------------------------------------------------------
|
|
27636
27676
|
// Getters
|
|
27637
27677
|
// ---------------------------------------------------------------------------
|
|
27638
|
-
getContextCreationChart(
|
|
27639
|
-
var _a, _b;
|
|
27640
|
-
return (_b = (_a = this.charts[sheetId]) === null || _a === void 0 ? void 0 : _a[figureId]) === null || _b === void 0 ? void 0 : _b.getContextCreation();
|
|
27641
|
-
}
|
|
27642
|
-
getChart(sheetId, figureId) {
|
|
27678
|
+
getContextCreationChart(figureId) {
|
|
27643
27679
|
var _a;
|
|
27644
|
-
return (_a = this.charts[
|
|
27680
|
+
return (_a = this.charts[figureId]) === null || _a === void 0 ? void 0 : _a.getContextCreation();
|
|
27645
27681
|
}
|
|
27646
|
-
|
|
27647
|
-
|
|
27648
|
-
|
|
27682
|
+
getChart(figureId) {
|
|
27683
|
+
return this.charts[figureId];
|
|
27684
|
+
}
|
|
27685
|
+
getChartType(figureId) {
|
|
27686
|
+
var _a;
|
|
27687
|
+
const type = (_a = this.charts[figureId]) === null || _a === void 0 ? void 0 : _a.type;
|
|
27649
27688
|
if (!type) {
|
|
27650
27689
|
throw new Error("Chart not defined.");
|
|
27651
27690
|
}
|
|
27652
27691
|
return type;
|
|
27653
27692
|
}
|
|
27654
|
-
isChartDefined(
|
|
27655
|
-
return figureId in
|
|
27693
|
+
isChartDefined(figureId) {
|
|
27694
|
+
return figureId in this.charts && this.charts !== undefined;
|
|
27656
27695
|
}
|
|
27657
27696
|
getChartIds(sheetId) {
|
|
27658
|
-
return Object.
|
|
27697
|
+
return Object.entries(this.charts)
|
|
27698
|
+
.filter(([, chart]) => (chart === null || chart === void 0 ? void 0 : chart.sheetId) === sheetId)
|
|
27699
|
+
.map(([id]) => id);
|
|
27659
27700
|
}
|
|
27660
|
-
getChartDefinition(
|
|
27661
|
-
var _a
|
|
27662
|
-
const definition = (
|
|
27701
|
+
getChartDefinition(figureId) {
|
|
27702
|
+
var _a;
|
|
27703
|
+
const definition = (_a = this.charts[figureId]) === null || _a === void 0 ? void 0 : _a.getDefinition();
|
|
27663
27704
|
if (!definition) {
|
|
27664
27705
|
throw new Error(`There is no chart with the given figureId: ${figureId}`);
|
|
27665
27706
|
}
|
|
@@ -27671,28 +27712,35 @@ class ChartPlugin extends CorePlugin {
|
|
|
27671
27712
|
import(data) {
|
|
27672
27713
|
for (let sheet of data.sheets) {
|
|
27673
27714
|
if (sheet.figures) {
|
|
27674
|
-
const charts = {};
|
|
27675
27715
|
for (let figure of sheet.figures) {
|
|
27676
27716
|
// TODO:
|
|
27677
27717
|
// figure data should be external IMO => chart should be in sheet.chart
|
|
27678
27718
|
// instead of in figure.data
|
|
27679
27719
|
if (figure.tag === "chart") {
|
|
27680
|
-
charts[figure.id] = this.createChart(figure.id, figure.data, sheet.id);
|
|
27720
|
+
this.charts[figure.id] = this.createChart(figure.id, figure.data, sheet.id);
|
|
27681
27721
|
}
|
|
27682
27722
|
}
|
|
27683
|
-
this.charts[sheet.id] = charts;
|
|
27684
27723
|
}
|
|
27685
27724
|
}
|
|
27686
27725
|
}
|
|
27687
27726
|
export(data) {
|
|
27727
|
+
var _a;
|
|
27688
27728
|
if (data.sheets) {
|
|
27689
27729
|
for (let sheet of data.sheets) {
|
|
27690
27730
|
// TODO This code is false, if two plugins want ot insert figures on the sheet, it will crash !
|
|
27691
27731
|
const sheetFigures = this.getters.getFigures(sheet.id);
|
|
27692
|
-
const figures =
|
|
27693
|
-
for (let
|
|
27732
|
+
const figures = [];
|
|
27733
|
+
for (let sheetFigure of sheetFigures) {
|
|
27734
|
+
const figure = sheetFigure;
|
|
27694
27735
|
if (figure && figure.tag === "chart") {
|
|
27695
|
-
|
|
27736
|
+
const data = (_a = this.charts[figure.id]) === null || _a === void 0 ? void 0 : _a.getDefinition();
|
|
27737
|
+
if (data) {
|
|
27738
|
+
figure.data = data;
|
|
27739
|
+
figures.push(figure);
|
|
27740
|
+
}
|
|
27741
|
+
}
|
|
27742
|
+
else {
|
|
27743
|
+
figures.push(figure);
|
|
27696
27744
|
}
|
|
27697
27745
|
}
|
|
27698
27746
|
sheet.figures = figures;
|
|
@@ -27700,13 +27748,13 @@ class ChartPlugin extends CorePlugin {
|
|
|
27700
27748
|
}
|
|
27701
27749
|
}
|
|
27702
27750
|
exportForExcel(data) {
|
|
27703
|
-
var _a
|
|
27751
|
+
var _a;
|
|
27704
27752
|
for (let sheet of data.sheets) {
|
|
27705
27753
|
const sheetFigures = this.getters.getFigures(sheet.id);
|
|
27706
27754
|
const figures = [];
|
|
27707
27755
|
for (let figure of sheetFigures) {
|
|
27708
27756
|
if (figure && figure.tag === "chart") {
|
|
27709
|
-
const figureData = (
|
|
27757
|
+
const figureData = (_a = this.charts[figure.id]) === null || _a === void 0 ? void 0 : _a.getDefinitionForExcel();
|
|
27710
27758
|
if (figureData) {
|
|
27711
27759
|
figures.push({
|
|
27712
27760
|
...figure,
|
|
@@ -27745,15 +27793,21 @@ class ChartPlugin extends CorePlugin {
|
|
|
27745
27793
|
* Add a chart in the local state. If a chart already exists, this chart is
|
|
27746
27794
|
* replaced
|
|
27747
27795
|
*/
|
|
27748
|
-
addChart(id,
|
|
27749
|
-
|
|
27796
|
+
addChart(id, definition) {
|
|
27797
|
+
const sheetId = this.getters.getFigureSheetId(id);
|
|
27798
|
+
if (sheetId) {
|
|
27799
|
+
this.history.update("charts", id, this.createChart(id, definition, sheetId));
|
|
27800
|
+
}
|
|
27750
27801
|
}
|
|
27751
27802
|
checkChartDuplicate(cmd) {
|
|
27752
|
-
|
|
27753
|
-
|
|
27754
|
-
|
|
27755
|
-
|
|
27756
|
-
|
|
27803
|
+
return this.getters.getFigureSheetId(cmd.id)
|
|
27804
|
+
? 83 /* CommandResult.DuplicatedChartId */
|
|
27805
|
+
: 0 /* CommandResult.Success */;
|
|
27806
|
+
}
|
|
27807
|
+
checkChartExists(cmd) {
|
|
27808
|
+
return this.getters.getFigureSheetId(cmd.id)
|
|
27809
|
+
? 0 /* CommandResult.Success */
|
|
27810
|
+
: 84 /* CommandResult.ChartDoesNotExist */;
|
|
27757
27811
|
}
|
|
27758
27812
|
}
|
|
27759
27813
|
ChartPlugin.getters = [
|
|
@@ -28134,7 +28188,7 @@ class FigurePlugin extends CorePlugin {
|
|
|
28134
28188
|
allowDispatch(cmd) {
|
|
28135
28189
|
switch (cmd.type) {
|
|
28136
28190
|
case "CREATE_FIGURE":
|
|
28137
|
-
return this.checkFigureDuplicate(cmd.
|
|
28191
|
+
return this.checkFigureDuplicate(cmd.figure.id);
|
|
28138
28192
|
case "UPDATE_FIGURE":
|
|
28139
28193
|
case "DELETE_FIGURE":
|
|
28140
28194
|
return this.checkFigureExists(cmd.sheetId, cmd.id);
|
|
@@ -28200,9 +28254,8 @@ class FigurePlugin extends CorePlugin {
|
|
|
28200
28254
|
}
|
|
28201
28255
|
return 0 /* CommandResult.Success */;
|
|
28202
28256
|
}
|
|
28203
|
-
checkFigureDuplicate(
|
|
28204
|
-
|
|
28205
|
-
if ((_a = this.figures[sheetId]) === null || _a === void 0 ? void 0 : _a[figureId]) {
|
|
28257
|
+
checkFigureDuplicate(figureId) {
|
|
28258
|
+
if (Object.values(this.figures).find((sheet) => sheet === null || sheet === void 0 ? void 0 : sheet[figureId])) {
|
|
28206
28259
|
return 81 /* CommandResult.DuplicatedFigureId */;
|
|
28207
28260
|
}
|
|
28208
28261
|
return 0 /* CommandResult.Success */;
|
|
@@ -28217,6 +28270,9 @@ class FigurePlugin extends CorePlugin {
|
|
|
28217
28270
|
var _a;
|
|
28218
28271
|
return (_a = this.figures[sheetId]) === null || _a === void 0 ? void 0 : _a[figureId];
|
|
28219
28272
|
}
|
|
28273
|
+
getFigureSheetId(figureId) {
|
|
28274
|
+
return Object.keys(this.figures).find((sheetId) => { var _a; return ((_a = this.figures[sheetId]) === null || _a === void 0 ? void 0 : _a[figureId]) !== undefined; });
|
|
28275
|
+
}
|
|
28220
28276
|
// ---------------------------------------------------------------------------
|
|
28221
28277
|
// Import/Export
|
|
28222
28278
|
// ---------------------------------------------------------------------------
|
|
@@ -28241,7 +28297,7 @@ class FigurePlugin extends CorePlugin {
|
|
|
28241
28297
|
this.export(data);
|
|
28242
28298
|
}
|
|
28243
28299
|
}
|
|
28244
|
-
FigurePlugin.getters = ["getFigures", "getFigure"];
|
|
28300
|
+
FigurePlugin.getters = ["getFigures", "getFigure", "getFigureSheetId"];
|
|
28245
28301
|
|
|
28246
28302
|
class FilterTable {
|
|
28247
28303
|
constructor(zone) {
|
|
@@ -31533,7 +31589,7 @@ class ClipboardFigureState {
|
|
|
31533
31589
|
throw new Error(`No figure for the given id: ${copiedFigureId}`);
|
|
31534
31590
|
}
|
|
31535
31591
|
this.copiedFigure = { ...figure };
|
|
31536
|
-
const chart = getters.getChart(
|
|
31592
|
+
const chart = getters.getChart(copiedFigureId);
|
|
31537
31593
|
if (!chart) {
|
|
31538
31594
|
throw new Error(`No chart for the given id: ${copiedFigureId}`);
|
|
31539
31595
|
}
|
|
@@ -31985,9 +32041,7 @@ class CustomColorsPlugin extends UIPlugin {
|
|
|
31985
32041
|
return formatColors.filter(isDefined$1);
|
|
31986
32042
|
}
|
|
31987
32043
|
getChartColors(sheetId) {
|
|
31988
|
-
const charts = this.getters
|
|
31989
|
-
.getChartIds(sheetId)
|
|
31990
|
-
.map((cid) => this.getters.getChart(sheetId, cid));
|
|
32044
|
+
const charts = this.getters.getChartIds(sheetId).map((cid) => this.getters.getChart(cid));
|
|
31991
32045
|
let chartsColors = new Set();
|
|
31992
32046
|
for (let chart of charts) {
|
|
31993
32047
|
if (chart === undefined) {
|
|
@@ -32254,37 +32308,34 @@ class EvaluationChartPlugin extends UIPlugin {
|
|
|
32254
32308
|
invalidateCFEvaluationCommands.has(cmd.type) ||
|
|
32255
32309
|
cmd.type === "EVALUATE_CELLS" ||
|
|
32256
32310
|
cmd.type === "UPDATE_CELL") {
|
|
32257
|
-
for (const
|
|
32258
|
-
|
|
32259
|
-
this.charts[sheetId][chartId] = undefined;
|
|
32260
|
-
}
|
|
32311
|
+
for (const chartId in this.charts) {
|
|
32312
|
+
this.charts[chartId] = undefined;
|
|
32261
32313
|
}
|
|
32262
32314
|
}
|
|
32263
32315
|
switch (cmd.type) {
|
|
32264
32316
|
case "UPDATE_CHART":
|
|
32265
32317
|
case "CREATE_CHART":
|
|
32266
32318
|
case "DELETE_FIGURE":
|
|
32267
|
-
|
|
32268
|
-
this.charts[cmd.sheetId][cmd.id] = undefined;
|
|
32269
|
-
}
|
|
32319
|
+
this.charts[cmd.id] = undefined;
|
|
32270
32320
|
break;
|
|
32271
32321
|
case "DELETE_SHEET":
|
|
32272
|
-
|
|
32322
|
+
for (let chartId in this.charts) {
|
|
32323
|
+
if (!this.getters.isChartDefined(chartId)) {
|
|
32324
|
+
this.charts[chartId] = undefined;
|
|
32325
|
+
}
|
|
32326
|
+
}
|
|
32273
32327
|
break;
|
|
32274
32328
|
}
|
|
32275
32329
|
}
|
|
32276
|
-
getChartRuntime(
|
|
32277
|
-
|
|
32278
|
-
|
|
32279
|
-
const chart = this.getters.getChart(sheetId, figureId);
|
|
32330
|
+
getChartRuntime(figureId) {
|
|
32331
|
+
if (!this.charts[figureId]) {
|
|
32332
|
+
const chart = this.getters.getChart(figureId);
|
|
32280
32333
|
if (!chart) {
|
|
32281
32334
|
throw new Error(`No chart for the given id: ${figureId}`);
|
|
32282
32335
|
}
|
|
32283
|
-
|
|
32284
|
-
this.charts[sheetId] = {};
|
|
32285
|
-
this.charts[sheetId][figureId] = this.createRuntimeChart(chart);
|
|
32336
|
+
this.charts[figureId] = this.createRuntimeChart(chart);
|
|
32286
32337
|
}
|
|
32287
|
-
return this.charts[
|
|
32338
|
+
return this.charts[figureId];
|
|
32288
32339
|
}
|
|
32289
32340
|
/**
|
|
32290
32341
|
* Get the background color of a chart based on the color of the first cell of the main range
|
|
@@ -32721,6 +32772,9 @@ class FilterEvaluationPlugin extends UIPlugin {
|
|
|
32721
32772
|
case "CREATE_SHEET":
|
|
32722
32773
|
this.filterValues[cmd.sheetId] = {};
|
|
32723
32774
|
break;
|
|
32775
|
+
case "HIDE_COLUMNS_ROWS":
|
|
32776
|
+
this.updateHiddenRows();
|
|
32777
|
+
break;
|
|
32724
32778
|
case "UPDATE_FILTER":
|
|
32725
32779
|
this.updateFilter(cmd);
|
|
32726
32780
|
this.updateHiddenRows();
|
|
@@ -32822,9 +32876,16 @@ class FilterEvaluationPlugin extends UIPlugin {
|
|
|
32822
32876
|
updateHiddenRows() {
|
|
32823
32877
|
var _a, _b;
|
|
32824
32878
|
const sheetId = this.getters.getActiveSheetId();
|
|
32825
|
-
const filters = this.getters
|
|
32879
|
+
const filters = this.getters
|
|
32880
|
+
.getFilters(sheetId)
|
|
32881
|
+
.sort((filter1, filter2) => filter1.zoneWithHeaders.top - filter2.zoneWithHeaders.top);
|
|
32826
32882
|
const hiddenRows = new Set();
|
|
32827
32883
|
for (let filter of filters) {
|
|
32884
|
+
// Disable filters whose header are hidden
|
|
32885
|
+
if (this.getters.isRowHiddenByUser(sheetId, filter.zoneWithHeaders.top))
|
|
32886
|
+
continue;
|
|
32887
|
+
if (hiddenRows.has(filter.zoneWithHeaders.top))
|
|
32888
|
+
continue;
|
|
32828
32889
|
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);
|
|
32829
32890
|
if (!filteredValues || !filter.filteredZone)
|
|
32830
32891
|
continue;
|
|
@@ -42406,6 +42467,6 @@ exports.setTranslationMethod = setTranslationMethod;
|
|
|
42406
42467
|
exports.tokenize = tokenize;
|
|
42407
42468
|
|
|
42408
42469
|
|
|
42409
|
-
__info__.version = '16.0.
|
|
42410
|
-
__info__.date = '2023-03-
|
|
42411
|
-
__info__.hash = '
|
|
42470
|
+
__info__.version = '16.0.3';
|
|
42471
|
+
__info__.date = '2023-03-14T09:22:56.932Z';
|
|
42472
|
+
__info__.hash = '4deeca9';
|
|
@@ -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;
|
|
@@ -5147,7 +5148,7 @@ declare class ScorecardChart extends Component<Props$q, SpreadsheetChildEnv> {
|
|
|
5147
5148
|
get baselineArrowDirection(): BaselineArrowDirection;
|
|
5148
5149
|
get backgroundColor(): string;
|
|
5149
5150
|
get primaryFontColor(): string;
|
|
5150
|
-
get secondaryFontColor(): "#
|
|
5151
|
+
get secondaryFontColor(): "#525252" | "#C8C8C8";
|
|
5151
5152
|
get figure(): Figure;
|
|
5152
5153
|
get chartStyle(): string;
|
|
5153
5154
|
get chartContentStyle(): string;
|