@odoo/o-spreadsheet 16.2.0-alpha.1 → 16.2.0-alpha.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 +185 -133
- package/dist/o_spreadsheet.d.ts +77 -69
- package/dist/o_spreadsheet.esm.js +185 -133
- package/dist/o_spreadsheet.iife.js +185 -133
- package/dist/o_spreadsheet.iife.min.js +11 -23
- package/package.json +7 -4
|
@@ -277,7 +277,6 @@ var ComponentsImportance;
|
|
|
277
277
|
ComponentsImportance[ComponentsImportance["Dropdown"] = 16] = "Dropdown";
|
|
278
278
|
ComponentsImportance[ComponentsImportance["GridComposer"] = 20] = "GridComposer";
|
|
279
279
|
ComponentsImportance[ComponentsImportance["TopBarComposer"] = 21] = "TopBarComposer";
|
|
280
|
-
ComponentsImportance[ComponentsImportance["ColorPicker"] = 25] = "ColorPicker";
|
|
281
280
|
ComponentsImportance[ComponentsImportance["IconPicker"] = 25] = "IconPicker";
|
|
282
281
|
ComponentsImportance[ComponentsImportance["Popover"] = 30] = "Popover";
|
|
283
282
|
ComponentsImportance[ComponentsImportance["ChartAnchor"] = 1000] = "ChartAnchor";
|
|
@@ -2847,7 +2846,7 @@ class ChartJsComponent extends owl.Component {
|
|
|
2847
2846
|
return `background-color: ${this.background}`;
|
|
2848
2847
|
}
|
|
2849
2848
|
get chartRuntime() {
|
|
2850
|
-
const runtime = this.env.model.getters.getChartRuntime(this.
|
|
2849
|
+
const runtime = this.env.model.getters.getChartRuntime(this.props.figure.id);
|
|
2851
2850
|
if (!("chartJsConfig" in runtime)) {
|
|
2852
2851
|
throw new Error("Unsupported chart runtime");
|
|
2853
2852
|
}
|
|
@@ -3112,7 +3111,7 @@ class ScorecardChart$1 extends owl.Component {
|
|
|
3112
3111
|
this.ctx = document.createElement("canvas").getContext("2d");
|
|
3113
3112
|
}
|
|
3114
3113
|
get runtime() {
|
|
3115
|
-
return this.env.model.getters.getChartRuntime(this.
|
|
3114
|
+
return this.env.model.getters.getChartRuntime(this.props.figure.id);
|
|
3116
3115
|
}
|
|
3117
3116
|
get title() {
|
|
3118
3117
|
return this.runtime.title;
|
|
@@ -3501,7 +3500,7 @@ exports.CommandResult = void 0;
|
|
|
3501
3500
|
CommandResult[CommandResult["InvalidRange"] = 25] = "InvalidRange";
|
|
3502
3501
|
CommandResult[CommandResult["InvalidZones"] = 26] = "InvalidZones";
|
|
3503
3502
|
CommandResult[CommandResult["InvalidSheetId"] = 27] = "InvalidSheetId";
|
|
3504
|
-
CommandResult[CommandResult["
|
|
3503
|
+
CommandResult[CommandResult["InvalidFigureId"] = 28] = "InvalidFigureId";
|
|
3505
3504
|
CommandResult[CommandResult["InputAlreadyFocused"] = 29] = "InputAlreadyFocused";
|
|
3506
3505
|
CommandResult[CommandResult["MaximumRangesReached"] = 30] = "MaximumRangesReached";
|
|
3507
3506
|
CommandResult[CommandResult["InvalidChartDefinition"] = 31] = "InvalidChartDefinition";
|
|
@@ -3558,6 +3557,7 @@ exports.CommandResult = void 0;
|
|
|
3558
3557
|
CommandResult[CommandResult["DuplicatedFigureId"] = 82] = "DuplicatedFigureId";
|
|
3559
3558
|
CommandResult[CommandResult["InvalidSelectionStep"] = 83] = "InvalidSelectionStep";
|
|
3560
3559
|
CommandResult[CommandResult["DuplicatedChartId"] = 84] = "DuplicatedChartId";
|
|
3560
|
+
CommandResult[CommandResult["ChartDoesNotExist"] = 85] = "ChartDoesNotExist";
|
|
3561
3561
|
})(exports.CommandResult || (exports.CommandResult = {}));
|
|
3562
3562
|
|
|
3563
3563
|
var DIRECTION;
|
|
@@ -6168,7 +6168,7 @@ class ChartFigure extends owl.Component {
|
|
|
6168
6168
|
return registry;
|
|
6169
6169
|
}
|
|
6170
6170
|
get chartType() {
|
|
6171
|
-
return this.env.model.getters.getChartType(this.
|
|
6171
|
+
return this.env.model.getters.getChartType(this.props.figure.id);
|
|
6172
6172
|
}
|
|
6173
6173
|
onContextMenu(ev) {
|
|
6174
6174
|
const position = {
|
|
@@ -17187,7 +17187,7 @@ class ImageFigure extends owl.Component {
|
|
|
17187
17187
|
id: "reset_size",
|
|
17188
17188
|
name: _lt("Reset size"),
|
|
17189
17189
|
action: () => {
|
|
17190
|
-
const size = this.env.model.getters.
|
|
17190
|
+
const size = this.env.model.getters.getImageSize(this.figureId);
|
|
17191
17191
|
const { height, width } = getMaxFigureSize(this.env.model.getters, size);
|
|
17192
17192
|
this.env.model.dispatch("UPDATE_FIGURE", {
|
|
17193
17193
|
sheetId: this.env.model.getters.getActiveSheetId(),
|
|
@@ -17236,8 +17236,7 @@ class ImageFigure extends owl.Component {
|
|
|
17236
17236
|
return this.props.figure.id;
|
|
17237
17237
|
}
|
|
17238
17238
|
get getImagePath() {
|
|
17239
|
-
return this.env.model.getters.
|
|
17240
|
-
.path;
|
|
17239
|
+
return this.env.model.getters.getImagePath(this.figureId);
|
|
17241
17240
|
}
|
|
17242
17241
|
}
|
|
17243
17242
|
ImageFigure.template = "o-spreadsheet-ImageFigure";
|
|
@@ -18042,9 +18041,9 @@ class SelectionInput extends owl.Component {
|
|
|
18042
18041
|
const ranges = existingSelectionRange.length
|
|
18043
18042
|
? existingSelectionRange
|
|
18044
18043
|
: this.props.ranges
|
|
18045
|
-
? this.props.ranges.map((xc,
|
|
18044
|
+
? this.props.ranges.map((xc, id) => ({
|
|
18046
18045
|
xc,
|
|
18047
|
-
id
|
|
18046
|
+
id,
|
|
18048
18047
|
isFocused: false,
|
|
18049
18048
|
}))
|
|
18050
18049
|
: [];
|
|
@@ -18110,6 +18109,7 @@ class SelectionInput extends owl.Component {
|
|
|
18110
18109
|
else if (ev.key === "Enter") {
|
|
18111
18110
|
const target = ev.target;
|
|
18112
18111
|
target.blur();
|
|
18112
|
+
this.confirm();
|
|
18113
18113
|
}
|
|
18114
18114
|
}
|
|
18115
18115
|
focus(rangeId) {
|
|
@@ -18138,7 +18138,7 @@ class SelectionInput extends owl.Component {
|
|
|
18138
18138
|
});
|
|
18139
18139
|
this.triggerChange();
|
|
18140
18140
|
}
|
|
18141
|
-
|
|
18141
|
+
confirm() {
|
|
18142
18142
|
var _a, _b;
|
|
18143
18143
|
this.env.model.dispatch("UNFOCUS_SELECTION_INPUT");
|
|
18144
18144
|
const ranges = this.env.model.getters.getSelectionInputValue(this.id);
|
|
@@ -18233,7 +18233,6 @@ class LineBarPieConfigPanel extends owl.Component {
|
|
|
18233
18233
|
LineBarPieConfigPanel.template = "o-spreadsheet-LineBarPieConfigPanel";
|
|
18234
18234
|
LineBarPieConfigPanel.components = { SelectionInput };
|
|
18235
18235
|
LineBarPieConfigPanel.props = {
|
|
18236
|
-
sheetId: String,
|
|
18237
18236
|
figureId: String,
|
|
18238
18237
|
definition: Object,
|
|
18239
18238
|
updateChart: Function,
|
|
@@ -18266,9 +18265,6 @@ const GRADIENT_WIDTH = PICKER_WIDTH - 2 * LINE_HORIZONTAL_PADDING - 2 * ITEM_BOR
|
|
|
18266
18265
|
const GRADIENT_HEIGHT = PICKER_WIDTH - 50;
|
|
18267
18266
|
css /* scss */ `
|
|
18268
18267
|
.o-color-picker {
|
|
18269
|
-
position: absolute;
|
|
18270
|
-
top: calc(100% + 5px);
|
|
18271
|
-
z-index: ${ComponentsImportance.ColorPicker};
|
|
18272
18268
|
padding: ${PICKER_PADDING}px 0px;
|
|
18273
18269
|
box-shadow: 1px 2px 5px 2px rgba(51, 51, 51, 0.15);
|
|
18274
18270
|
background-color: white;
|
|
@@ -18383,15 +18379,6 @@ css /* scss */ `
|
|
|
18383
18379
|
width: 100%;
|
|
18384
18380
|
}
|
|
18385
18381
|
}
|
|
18386
|
-
&.right {
|
|
18387
|
-
left: 0;
|
|
18388
|
-
}
|
|
18389
|
-
&.left {
|
|
18390
|
-
right: 0;
|
|
18391
|
-
}
|
|
18392
|
-
&.center {
|
|
18393
|
-
left: calc(50% - ${PICKER_WIDTH / 2}px);
|
|
18394
|
-
}
|
|
18395
18382
|
}
|
|
18396
18383
|
.o-magnifier-glass {
|
|
18397
18384
|
position: absolute;
|
|
@@ -18426,14 +18413,18 @@ class ColorPicker extends owl.Component {
|
|
|
18426
18413
|
});
|
|
18427
18414
|
}
|
|
18428
18415
|
get colorPickerStyle() {
|
|
18429
|
-
if (this.props.maxHeight
|
|
18430
|
-
return "";
|
|
18431
|
-
if (this.props.maxHeight <= 0) {
|
|
18416
|
+
if (this.props.maxHeight !== undefined && this.props.maxHeight <= 0) {
|
|
18432
18417
|
return cssPropertiesToCss({ display: "none" });
|
|
18433
18418
|
}
|
|
18434
|
-
return
|
|
18435
|
-
|
|
18436
|
-
|
|
18419
|
+
return "";
|
|
18420
|
+
}
|
|
18421
|
+
get popoverProps() {
|
|
18422
|
+
return {
|
|
18423
|
+
anchorRect: this.props.anchorRect,
|
|
18424
|
+
maxHeight: this.props.maxHeight,
|
|
18425
|
+
positioning: "BottomLeft",
|
|
18426
|
+
verticalOffset: 0,
|
|
18427
|
+
};
|
|
18437
18428
|
}
|
|
18438
18429
|
onColorClick(color) {
|
|
18439
18430
|
if (color) {
|
|
@@ -18488,11 +18479,12 @@ ColorPicker.template = "o-spreadsheet-ColorPicker";
|
|
|
18488
18479
|
ColorPicker.defaultProps = {
|
|
18489
18480
|
currentColor: "", //TODO Change it to false instead of empty string
|
|
18490
18481
|
};
|
|
18482
|
+
ColorPicker.components = { Popover };
|
|
18491
18483
|
ColorPicker.props = {
|
|
18492
|
-
dropdownDirection: { type: String, optional: true },
|
|
18493
18484
|
onColorPicked: Function,
|
|
18494
18485
|
currentColor: { type: String, optional: true },
|
|
18495
18486
|
maxHeight: { type: Number, optional: true },
|
|
18487
|
+
anchorRect: Object,
|
|
18496
18488
|
};
|
|
18497
18489
|
|
|
18498
18490
|
css /* scss */ `
|
|
@@ -18528,11 +18520,25 @@ css /* scss */ `
|
|
|
18528
18520
|
}
|
|
18529
18521
|
`;
|
|
18530
18522
|
class ColorPickerWidget extends owl.Component {
|
|
18523
|
+
constructor() {
|
|
18524
|
+
super(...arguments);
|
|
18525
|
+
this.colorPickerButtonRef = owl.useRef("colorPickerButton");
|
|
18526
|
+
}
|
|
18531
18527
|
get iconStyle() {
|
|
18532
18528
|
return this.props.currentColor
|
|
18533
18529
|
? `border-color: ${this.props.currentColor}`
|
|
18534
18530
|
: "border-bottom-style: hidden";
|
|
18535
18531
|
}
|
|
18532
|
+
get colorPickerAnchorRect() {
|
|
18533
|
+
const button = this.colorPickerButtonRef.el;
|
|
18534
|
+
const buttonRect = button.getBoundingClientRect();
|
|
18535
|
+
return {
|
|
18536
|
+
x: buttonRect.x,
|
|
18537
|
+
y: buttonRect.y,
|
|
18538
|
+
width: buttonRect.width,
|
|
18539
|
+
height: buttonRect.height,
|
|
18540
|
+
};
|
|
18541
|
+
}
|
|
18536
18542
|
}
|
|
18537
18543
|
ColorPickerWidget.template = "o-spreadsheet-ColorPickerWidget";
|
|
18538
18544
|
ColorPickerWidget.components = { ColorPicker };
|
|
@@ -18542,7 +18548,6 @@ ColorPickerWidget.props = {
|
|
|
18542
18548
|
showColorPicker: Boolean,
|
|
18543
18549
|
onColorPicked: Function,
|
|
18544
18550
|
icon: String,
|
|
18545
|
-
dropdownDirection: { type: String, optional: true },
|
|
18546
18551
|
title: { type: String, optional: true },
|
|
18547
18552
|
disabled: { type: Boolean, optional: true },
|
|
18548
18553
|
dropdownMaxHeight: { type: Number, optional: true },
|
|
@@ -18622,7 +18627,6 @@ class GaugeChartConfigPanel extends owl.Component {
|
|
|
18622
18627
|
GaugeChartConfigPanel.template = "o-spreadsheet-GaugeChartConfigPanel";
|
|
18623
18628
|
GaugeChartConfigPanel.components = { SelectionInput };
|
|
18624
18629
|
GaugeChartConfigPanel.props = {
|
|
18625
|
-
sheetId: String,
|
|
18626
18630
|
figureId: String,
|
|
18627
18631
|
definition: Object,
|
|
18628
18632
|
updateChart: Function,
|
|
@@ -18769,7 +18773,7 @@ GaugeChartDesignPanel.props = {
|
|
|
18769
18773
|
|
|
18770
18774
|
class LineConfigPanel extends LineBarPieConfigPanel {
|
|
18771
18775
|
get canTreatLabelsAsText() {
|
|
18772
|
-
const chart = this.env.model.getters.getChart(this.props.
|
|
18776
|
+
const chart = this.env.model.getters.getChart(this.props.figureId);
|
|
18773
18777
|
if (chart && chart instanceof LineChart) {
|
|
18774
18778
|
return canChartParseLabels(chart.labelRange, this.env.model.getters);
|
|
18775
18779
|
}
|
|
@@ -18846,7 +18850,6 @@ class ScorecardChartConfigPanel extends owl.Component {
|
|
|
18846
18850
|
ScorecardChartConfigPanel.template = "o-spreadsheet-ScorecardChartConfigPanel";
|
|
18847
18851
|
ScorecardChartConfigPanel.components = { SelectionInput };
|
|
18848
18852
|
ScorecardChartConfigPanel.props = {
|
|
18849
|
-
sheetId: String,
|
|
18850
18853
|
figureId: String,
|
|
18851
18854
|
definition: Object,
|
|
18852
18855
|
updateChart: Function,
|
|
@@ -18982,7 +18985,7 @@ class ChartPanel extends owl.Component {
|
|
|
18982
18985
|
else {
|
|
18983
18986
|
this.shouldUpdateChart = true;
|
|
18984
18987
|
}
|
|
18985
|
-
if (!this.env.model.getters.isChartDefined(this.
|
|
18988
|
+
if (!this.env.model.getters.isChartDefined(this.figureId)) {
|
|
18986
18989
|
this.props.onCloseSidePanel();
|
|
18987
18990
|
return;
|
|
18988
18991
|
}
|
|
@@ -18996,7 +18999,6 @@ class ChartPanel extends owl.Component {
|
|
|
18996
18999
|
...this.getChartDefinition(),
|
|
18997
19000
|
...updateDefinition,
|
|
18998
19001
|
};
|
|
18999
|
-
// TODORAR add a putain de test - c'est faux de nouveau ...
|
|
19000
19002
|
return this.env.model.dispatch("UPDATE_CHART", {
|
|
19001
19003
|
definition,
|
|
19002
19004
|
id: this.figureId,
|
|
@@ -19004,12 +19006,11 @@ class ChartPanel extends owl.Component {
|
|
|
19004
19006
|
});
|
|
19005
19007
|
}
|
|
19006
19008
|
onTypeChange(type) {
|
|
19007
|
-
const context = this.env.model.getters.getContextCreationChart(this.
|
|
19009
|
+
const context = this.env.model.getters.getContextCreationChart(this.figureId);
|
|
19008
19010
|
if (!context) {
|
|
19009
19011
|
throw new Error("Chart not defined.");
|
|
19010
19012
|
}
|
|
19011
19013
|
const definition = getChartDefinitionFromContextCreation(context, type);
|
|
19012
|
-
// TODORAR add a putain de test - c'est faux de nouveau ...
|
|
19013
19014
|
this.env.model.dispatch("UPDATE_CHART", {
|
|
19014
19015
|
definition,
|
|
19015
19016
|
id: this.figureId,
|
|
@@ -19017,7 +19018,7 @@ class ChartPanel extends owl.Component {
|
|
|
19017
19018
|
});
|
|
19018
19019
|
}
|
|
19019
19020
|
get chartPanel() {
|
|
19020
|
-
const type = this.env.model.getters.getChartType(this.
|
|
19021
|
+
const type = this.env.model.getters.getChartType(this.figureId);
|
|
19021
19022
|
if (!type) {
|
|
19022
19023
|
throw new Error("Chart not defined.");
|
|
19023
19024
|
}
|
|
@@ -19027,8 +19028,8 @@ class ChartPanel extends owl.Component {
|
|
|
19027
19028
|
}
|
|
19028
19029
|
return chartPanel;
|
|
19029
19030
|
}
|
|
19030
|
-
getChartDefinition() {
|
|
19031
|
-
return this.env.model.getters.getChartDefinition(
|
|
19031
|
+
getChartDefinition(figureId = this.figureId) {
|
|
19032
|
+
return this.env.model.getters.getChartDefinition(figureId);
|
|
19032
19033
|
}
|
|
19033
19034
|
get chartTypes() {
|
|
19034
19035
|
return getChartTypes();
|
|
@@ -25900,13 +25901,7 @@ function load(data, verboseImport) {
|
|
|
25900
25901
|
data = migrate(data);
|
|
25901
25902
|
}
|
|
25902
25903
|
}
|
|
25903
|
-
|
|
25904
|
-
// sensible default values
|
|
25905
|
-
data = Object.assign(createEmptyWorkbookData(), data, { version: CURRENT_VERSION });
|
|
25906
|
-
data.sheets = data.sheets.map((s, i) => Object.assign(createEmptySheet(`Sheet${i + 1}`, `Sheet${i + 1}`), s));
|
|
25907
|
-
if (data.sheets.length === 0) {
|
|
25908
|
-
data.sheets.push(createEmptySheet(INITIAL_SHEET_ID, "Sheet1"));
|
|
25909
|
-
}
|
|
25904
|
+
data = repairData(data);
|
|
25910
25905
|
return data;
|
|
25911
25906
|
}
|
|
25912
25907
|
function migrate(data) {
|
|
@@ -26144,6 +26139,48 @@ const MIGRATIONS = [
|
|
|
26144
26139
|
},
|
|
26145
26140
|
},
|
|
26146
26141
|
];
|
|
26142
|
+
/**
|
|
26143
|
+
* This function is used to repair faulty data independently of the migration.
|
|
26144
|
+
*/
|
|
26145
|
+
function repairData(data) {
|
|
26146
|
+
data = forceUnicityOfFigure(data);
|
|
26147
|
+
data = setDefaults(data);
|
|
26148
|
+
return data;
|
|
26149
|
+
}
|
|
26150
|
+
/**
|
|
26151
|
+
* Force the unicity of figure ids accross sheets
|
|
26152
|
+
*/
|
|
26153
|
+
function forceUnicityOfFigure(data) {
|
|
26154
|
+
if (data.uniqueFigureIds) {
|
|
26155
|
+
return data;
|
|
26156
|
+
}
|
|
26157
|
+
const figureIds = new Set();
|
|
26158
|
+
const uuidGenerator = new UuidGenerator();
|
|
26159
|
+
for (const sheet of data.sheets || []) {
|
|
26160
|
+
for (const figure of sheet.figures || []) {
|
|
26161
|
+
if (figureIds.has(figure.id)) {
|
|
26162
|
+
figure.id += uuidGenerator.uuidv4();
|
|
26163
|
+
}
|
|
26164
|
+
figureIds.add(figure.id);
|
|
26165
|
+
}
|
|
26166
|
+
}
|
|
26167
|
+
data.uniqueFigureIds = true;
|
|
26168
|
+
return data;
|
|
26169
|
+
}
|
|
26170
|
+
/**
|
|
26171
|
+
* sanity check: try to fix missing fields/corrupted state by providing
|
|
26172
|
+
* sensible default values
|
|
26173
|
+
*/
|
|
26174
|
+
function setDefaults(data) {
|
|
26175
|
+
data = Object.assign(createEmptyWorkbookData(), data, { version: CURRENT_VERSION });
|
|
26176
|
+
data.sheets = data.sheets
|
|
26177
|
+
? data.sheets.map((s, i) => Object.assign(createEmptySheet(`Sheet${i + 1}`, `Sheet${i + 1}`), s))
|
|
26178
|
+
: [];
|
|
26179
|
+
if (data.sheets.length === 0) {
|
|
26180
|
+
data.sheets.push(createEmptySheet(INITIAL_SHEET_ID, "Sheet1"));
|
|
26181
|
+
}
|
|
26182
|
+
return data;
|
|
26183
|
+
}
|
|
26147
26184
|
/**
|
|
26148
26185
|
* The goal of this function is to repair corrupted/wrong initial messages caused by
|
|
26149
26186
|
* a bug.
|
|
@@ -26282,6 +26319,7 @@ function createEmptyWorkbookData(sheetName = "Sheet1") {
|
|
|
26282
26319
|
formats: {},
|
|
26283
26320
|
borders: {},
|
|
26284
26321
|
revisionId: DEFAULT_REVISION_ID,
|
|
26322
|
+
uniqueFigureIds: true,
|
|
26285
26323
|
};
|
|
26286
26324
|
return data;
|
|
26287
26325
|
}
|
|
@@ -28061,10 +28099,8 @@ class ChartPlugin extends CorePlugin {
|
|
|
28061
28099
|
this.validateChartDefinition = (cmd) => validateChartDefinition(this, cmd.definition);
|
|
28062
28100
|
}
|
|
28063
28101
|
adaptRanges(applyChange) {
|
|
28064
|
-
for (const
|
|
28065
|
-
|
|
28066
|
-
this.history.update("charts", sheetId, chartId, chart === null || chart === void 0 ? void 0 : chart.updateRanges(applyChange));
|
|
28067
|
-
}
|
|
28102
|
+
for (const [chartId, chart] of Object.entries(this.charts)) {
|
|
28103
|
+
this.history.update("charts", chartId, chart === null || chart === void 0 ? void 0 : chart.updateRanges(applyChange));
|
|
28068
28104
|
}
|
|
28069
28105
|
}
|
|
28070
28106
|
// ---------------------------------------------------------------------------
|
|
@@ -28075,20 +28111,20 @@ class ChartPlugin extends CorePlugin {
|
|
|
28075
28111
|
case "CREATE_CHART":
|
|
28076
28112
|
return this.checkValidations(cmd, this.chainValidations(this.validateChartDefinition, this.checkChartDuplicate));
|
|
28077
28113
|
case "UPDATE_CHART":
|
|
28078
|
-
return this.
|
|
28114
|
+
return this.checkValidations(cmd, this.chainValidations(this.validateChartDefinition, this.checkChartExists));
|
|
28079
28115
|
default:
|
|
28080
28116
|
return 0 /* CommandResult.Success */;
|
|
28081
28117
|
}
|
|
28082
28118
|
}
|
|
28083
28119
|
handle(cmd) {
|
|
28084
|
-
var _a
|
|
28120
|
+
var _a;
|
|
28085
28121
|
switch (cmd.type) {
|
|
28086
28122
|
case "CREATE_CHART":
|
|
28087
28123
|
this.addFigure(cmd.id, cmd.sheetId, cmd.position, cmd.size);
|
|
28088
|
-
this.addChart(cmd.id, cmd.
|
|
28124
|
+
this.addChart(cmd.id, cmd.definition);
|
|
28089
28125
|
break;
|
|
28090
28126
|
case "UPDATE_CHART": {
|
|
28091
|
-
this.addChart(cmd.id, cmd.
|
|
28127
|
+
this.addChart(cmd.id, cmd.definition);
|
|
28092
28128
|
break;
|
|
28093
28129
|
}
|
|
28094
28130
|
case "DUPLICATE_SHEET": {
|
|
@@ -28097,7 +28133,7 @@ class ChartPlugin extends CorePlugin {
|
|
|
28097
28133
|
if (fig.tag === "chart") {
|
|
28098
28134
|
const figureIdBase = fig.id.split(FIGURE_ID_SPLITTER).pop();
|
|
28099
28135
|
const duplicatedFigureId = `${cmd.sheetIdTo}${FIGURE_ID_SPLITTER}${figureIdBase}`;
|
|
28100
|
-
const chart = (
|
|
28136
|
+
const chart = (_a = this.charts[fig.id]) === null || _a === void 0 ? void 0 : _a.copyForSheetId(cmd.sheetIdTo);
|
|
28101
28137
|
if (chart) {
|
|
28102
28138
|
this.dispatch("CREATE_CHART", {
|
|
28103
28139
|
id: duplicatedFigureId,
|
|
@@ -28112,44 +28148,44 @@ class ChartPlugin extends CorePlugin {
|
|
|
28112
28148
|
break;
|
|
28113
28149
|
}
|
|
28114
28150
|
case "DELETE_FIGURE":
|
|
28115
|
-
this.history.update("charts", cmd.
|
|
28151
|
+
this.history.update("charts", cmd.id, undefined);
|
|
28116
28152
|
break;
|
|
28117
28153
|
case "DELETE_SHEET":
|
|
28118
|
-
this.
|
|
28154
|
+
for (let id of this.getChartIds(cmd.sheetId)) {
|
|
28155
|
+
this.history.update("charts", id, undefined);
|
|
28156
|
+
}
|
|
28119
28157
|
break;
|
|
28120
28158
|
}
|
|
28121
28159
|
}
|
|
28122
28160
|
// ---------------------------------------------------------------------------
|
|
28123
28161
|
// Getters
|
|
28124
28162
|
// ---------------------------------------------------------------------------
|
|
28125
|
-
getContextCreationChart(
|
|
28126
|
-
var _a, _b;
|
|
28127
|
-
return (_b = (_a = this.charts[sheetId]) === null || _a === void 0 ? void 0 : _a[figureId]) === null || _b === void 0 ? void 0 : _b.getContextCreation();
|
|
28128
|
-
}
|
|
28129
|
-
getChart(sheetId, figureId) {
|
|
28163
|
+
getContextCreationChart(figureId) {
|
|
28130
28164
|
var _a;
|
|
28131
|
-
return (_a = this.charts[
|
|
28165
|
+
return (_a = this.charts[figureId]) === null || _a === void 0 ? void 0 : _a.getContextCreation();
|
|
28132
28166
|
}
|
|
28133
|
-
|
|
28134
|
-
|
|
28135
|
-
|
|
28167
|
+
getChart(figureId) {
|
|
28168
|
+
return this.charts[figureId];
|
|
28169
|
+
}
|
|
28170
|
+
getChartType(figureId) {
|
|
28171
|
+
var _a;
|
|
28172
|
+
const type = (_a = this.charts[figureId]) === null || _a === void 0 ? void 0 : _a.type;
|
|
28136
28173
|
if (!type) {
|
|
28137
28174
|
throw new Error("Chart not defined.");
|
|
28138
28175
|
}
|
|
28139
28176
|
return type;
|
|
28140
28177
|
}
|
|
28141
|
-
isChartDefined(
|
|
28142
|
-
return figureId in
|
|
28178
|
+
isChartDefined(figureId) {
|
|
28179
|
+
return figureId in this.charts && this.charts !== undefined;
|
|
28143
28180
|
}
|
|
28144
28181
|
getChartIds(sheetId) {
|
|
28145
|
-
|
|
28146
|
-
|
|
28147
|
-
|
|
28148
|
-
return Object.keys(this.charts[sheetId] || {});
|
|
28182
|
+
return Object.entries(this.charts)
|
|
28183
|
+
.filter(([, chart]) => (chart === null || chart === void 0 ? void 0 : chart.sheetId) === sheetId)
|
|
28184
|
+
.map(([id]) => id);
|
|
28149
28185
|
}
|
|
28150
|
-
getChartDefinition(
|
|
28151
|
-
var _a
|
|
28152
|
-
const definition = (
|
|
28186
|
+
getChartDefinition(figureId) {
|
|
28187
|
+
var _a;
|
|
28188
|
+
const definition = (_a = this.charts[figureId]) === null || _a === void 0 ? void 0 : _a.getDefinition();
|
|
28153
28189
|
if (!definition) {
|
|
28154
28190
|
throw new Error(`There is no chart with the given figureId: ${figureId}`);
|
|
28155
28191
|
}
|
|
@@ -28161,28 +28197,35 @@ class ChartPlugin extends CorePlugin {
|
|
|
28161
28197
|
import(data) {
|
|
28162
28198
|
for (let sheet of data.sheets) {
|
|
28163
28199
|
if (sheet.figures) {
|
|
28164
|
-
const charts = {};
|
|
28165
28200
|
for (let figure of sheet.figures) {
|
|
28166
28201
|
// TODO:
|
|
28167
28202
|
// figure data should be external IMO => chart should be in sheet.chart
|
|
28168
28203
|
// instead of in figure.data
|
|
28169
28204
|
if (figure.tag === "chart") {
|
|
28170
|
-
charts[figure.id] = this.createChart(figure.id, figure.data, sheet.id);
|
|
28205
|
+
this.charts[figure.id] = this.createChart(figure.id, figure.data, sheet.id);
|
|
28171
28206
|
}
|
|
28172
28207
|
}
|
|
28173
|
-
this.charts[sheet.id] = charts;
|
|
28174
28208
|
}
|
|
28175
28209
|
}
|
|
28176
28210
|
}
|
|
28177
28211
|
export(data) {
|
|
28212
|
+
var _a;
|
|
28178
28213
|
if (data.sheets) {
|
|
28179
28214
|
for (let sheet of data.sheets) {
|
|
28180
28215
|
// TODO This code is false, if two plugins want ot insert figures on the sheet, it will crash !
|
|
28181
28216
|
const sheetFigures = this.getters.getFigures(sheet.id);
|
|
28182
|
-
const figures =
|
|
28183
|
-
for (let
|
|
28217
|
+
const figures = [];
|
|
28218
|
+
for (let sheetFigure of sheetFigures) {
|
|
28219
|
+
const figure = sheetFigure;
|
|
28184
28220
|
if (figure && figure.tag === "chart") {
|
|
28185
|
-
|
|
28221
|
+
const data = (_a = this.charts[figure.id]) === null || _a === void 0 ? void 0 : _a.getDefinition();
|
|
28222
|
+
if (data) {
|
|
28223
|
+
figure.data = data;
|
|
28224
|
+
figures.push(figure);
|
|
28225
|
+
}
|
|
28226
|
+
}
|
|
28227
|
+
else {
|
|
28228
|
+
figures.push(figure);
|
|
28186
28229
|
}
|
|
28187
28230
|
}
|
|
28188
28231
|
sheet.figures = figures;
|
|
@@ -28190,13 +28233,13 @@ class ChartPlugin extends CorePlugin {
|
|
|
28190
28233
|
}
|
|
28191
28234
|
}
|
|
28192
28235
|
exportForExcel(data) {
|
|
28193
|
-
var _a
|
|
28236
|
+
var _a;
|
|
28194
28237
|
for (let sheet of data.sheets) {
|
|
28195
28238
|
const sheetFigures = this.getters.getFigures(sheet.id);
|
|
28196
28239
|
const figures = [];
|
|
28197
28240
|
for (let figure of sheetFigures) {
|
|
28198
28241
|
if (figure && figure.tag === "chart") {
|
|
28199
|
-
const figureData = (
|
|
28242
|
+
const figureData = (_a = this.charts[figure.id]) === null || _a === void 0 ? void 0 : _a.getDefinitionForExcel();
|
|
28200
28243
|
if (figureData) {
|
|
28201
28244
|
figures.push({
|
|
28202
28245
|
...figure,
|
|
@@ -28235,15 +28278,21 @@ class ChartPlugin extends CorePlugin {
|
|
|
28235
28278
|
* Add a chart in the local state. If a chart already exists, this chart is
|
|
28236
28279
|
* replaced
|
|
28237
28280
|
*/
|
|
28238
|
-
addChart(id,
|
|
28239
|
-
|
|
28281
|
+
addChart(id, definition) {
|
|
28282
|
+
const sheetId = this.getters.getFigureSheetId(id);
|
|
28283
|
+
if (sheetId) {
|
|
28284
|
+
this.history.update("charts", id, this.createChart(id, definition, sheetId));
|
|
28285
|
+
}
|
|
28240
28286
|
}
|
|
28241
28287
|
checkChartDuplicate(cmd) {
|
|
28242
|
-
|
|
28243
|
-
|
|
28244
|
-
|
|
28245
|
-
|
|
28246
|
-
|
|
28288
|
+
return this.getters.getFigureSheetId(cmd.id)
|
|
28289
|
+
? 84 /* CommandResult.DuplicatedChartId */
|
|
28290
|
+
: 0 /* CommandResult.Success */;
|
|
28291
|
+
}
|
|
28292
|
+
checkChartExists(cmd) {
|
|
28293
|
+
return this.getters.getFigureSheetId(cmd.id)
|
|
28294
|
+
? 0 /* CommandResult.Success */
|
|
28295
|
+
: 85 /* CommandResult.ChartDoesNotExist */;
|
|
28247
28296
|
}
|
|
28248
28297
|
}
|
|
28249
28298
|
ChartPlugin.getters = [
|
|
@@ -28624,7 +28673,7 @@ class FigurePlugin extends CorePlugin {
|
|
|
28624
28673
|
allowDispatch(cmd) {
|
|
28625
28674
|
switch (cmd.type) {
|
|
28626
28675
|
case "CREATE_FIGURE":
|
|
28627
|
-
return this.checkFigureDuplicate(cmd.
|
|
28676
|
+
return this.checkFigureDuplicate(cmd.figure.id);
|
|
28628
28677
|
case "UPDATE_FIGURE":
|
|
28629
28678
|
case "DELETE_FIGURE":
|
|
28630
28679
|
return this.checkFigureExists(cmd.sheetId, cmd.id);
|
|
@@ -28690,9 +28739,8 @@ class FigurePlugin extends CorePlugin {
|
|
|
28690
28739
|
}
|
|
28691
28740
|
return 0 /* CommandResult.Success */;
|
|
28692
28741
|
}
|
|
28693
|
-
checkFigureDuplicate(
|
|
28694
|
-
|
|
28695
|
-
if ((_a = this.figures[sheetId]) === null || _a === void 0 ? void 0 : _a[figureId]) {
|
|
28742
|
+
checkFigureDuplicate(figureId) {
|
|
28743
|
+
if (Object.values(this.figures).find((sheet) => sheet === null || sheet === void 0 ? void 0 : sheet[figureId])) {
|
|
28696
28744
|
return 82 /* CommandResult.DuplicatedFigureId */;
|
|
28697
28745
|
}
|
|
28698
28746
|
return 0 /* CommandResult.Success */;
|
|
@@ -28707,6 +28755,9 @@ class FigurePlugin extends CorePlugin {
|
|
|
28707
28755
|
var _a;
|
|
28708
28756
|
return (_a = this.figures[sheetId]) === null || _a === void 0 ? void 0 : _a[figureId];
|
|
28709
28757
|
}
|
|
28758
|
+
getFigureSheetId(figureId) {
|
|
28759
|
+
return Object.keys(this.figures).find((sheetId) => { var _a; return ((_a = this.figures[sheetId]) === null || _a === void 0 ? void 0 : _a[figureId]) !== undefined; });
|
|
28760
|
+
}
|
|
28710
28761
|
// ---------------------------------------------------------------------------
|
|
28711
28762
|
// Import/Export
|
|
28712
28763
|
// ---------------------------------------------------------------------------
|
|
@@ -28731,7 +28782,7 @@ class FigurePlugin extends CorePlugin {
|
|
|
28731
28782
|
this.export(data);
|
|
28732
28783
|
}
|
|
28733
28784
|
}
|
|
28734
|
-
FigurePlugin.getters = ["getFigures", "getFigure"];
|
|
28785
|
+
FigurePlugin.getters = ["getFigures", "getFigure", "getFigureSheetId"];
|
|
28735
28786
|
|
|
28736
28787
|
class FilterTable {
|
|
28737
28788
|
constructor(zone) {
|
|
@@ -29458,7 +29509,7 @@ class ImagePlugin extends CorePlugin {
|
|
|
29458
29509
|
switch (cmd.type) {
|
|
29459
29510
|
case "CREATE_IMAGE":
|
|
29460
29511
|
if (this.getters.getFigure(cmd.sheetId, cmd.figureId)) {
|
|
29461
|
-
return 28 /* CommandResult.
|
|
29512
|
+
return 28 /* CommandResult.InvalidFigureId */;
|
|
29462
29513
|
}
|
|
29463
29514
|
return 0 /* CommandResult.Success */;
|
|
29464
29515
|
default:
|
|
@@ -29478,7 +29529,7 @@ class ImagePlugin extends CorePlugin {
|
|
|
29478
29529
|
if (fig.tag === "image") {
|
|
29479
29530
|
const figureIdBase = fig.id.split(FIGURE_ID_SPLITTER).pop();
|
|
29480
29531
|
const duplicatedFigureId = `${cmd.sheetIdTo}${FIGURE_ID_SPLITTER}${figureIdBase}`;
|
|
29481
|
-
const image = this.getImage(
|
|
29532
|
+
const image = this.getImage(fig.id);
|
|
29482
29533
|
if (image) {
|
|
29483
29534
|
const size = { width: fig.width, height: fig.height };
|
|
29484
29535
|
this.dispatch("CREATE_IMAGE", {
|
|
@@ -29516,13 +29567,19 @@ class ImagePlugin extends CorePlugin {
|
|
|
29516
29567
|
// ---------------------------------------------------------------------------
|
|
29517
29568
|
// Getters
|
|
29518
29569
|
// ---------------------------------------------------------------------------
|
|
29519
|
-
getImage(
|
|
29520
|
-
|
|
29521
|
-
|
|
29522
|
-
|
|
29523
|
-
|
|
29570
|
+
getImage(figureId) {
|
|
29571
|
+
for (const sheet of Object.values(this.images)) {
|
|
29572
|
+
if (sheet && sheet[figureId]) {
|
|
29573
|
+
return sheet[figureId];
|
|
29574
|
+
}
|
|
29524
29575
|
}
|
|
29525
|
-
|
|
29576
|
+
throw new Error(`There is no image with the given figureId: ${figureId}`);
|
|
29577
|
+
}
|
|
29578
|
+
getImagePath(figureId) {
|
|
29579
|
+
return this.getImage(figureId).path;
|
|
29580
|
+
}
|
|
29581
|
+
getImageSize(figureId) {
|
|
29582
|
+
return this.getImage(figureId).size;
|
|
29526
29583
|
}
|
|
29527
29584
|
// ---------------------------------------------------------------------------
|
|
29528
29585
|
// Private
|
|
@@ -29564,7 +29621,7 @@ class ImagePlugin extends CorePlugin {
|
|
|
29564
29621
|
return images;
|
|
29565
29622
|
}
|
|
29566
29623
|
}
|
|
29567
|
-
ImagePlugin.getters = ["getImage"];
|
|
29624
|
+
ImagePlugin.getters = ["getImage", "getImagePath", "getImageSize"];
|
|
29568
29625
|
|
|
29569
29626
|
class MergePlugin extends CorePlugin {
|
|
29570
29627
|
constructor() {
|
|
@@ -31370,9 +31427,7 @@ class CustomColorsPlugin extends UIPlugin {
|
|
|
31370
31427
|
return formatColors.filter(isDefined$1);
|
|
31371
31428
|
}
|
|
31372
31429
|
getChartColors(sheetId) {
|
|
31373
|
-
const charts = this.getters
|
|
31374
|
-
.getChartIds(sheetId)
|
|
31375
|
-
.map((cid) => this.getters.getChart(sheetId, cid));
|
|
31430
|
+
const charts = this.getters.getChartIds(sheetId).map((cid) => this.getters.getChart(cid));
|
|
31376
31431
|
let chartsColors = new Set();
|
|
31377
31432
|
for (let chart of charts) {
|
|
31378
31433
|
if (chart === undefined) {
|
|
@@ -31738,37 +31793,34 @@ class EvaluationChartPlugin extends UIPlugin {
|
|
|
31738
31793
|
invalidateCFEvaluationCommands.has(cmd.type) ||
|
|
31739
31794
|
cmd.type === "EVALUATE_CELLS" ||
|
|
31740
31795
|
cmd.type === "UPDATE_CELL") {
|
|
31741
|
-
for (const
|
|
31742
|
-
|
|
31743
|
-
this.charts[sheetId][chartId] = undefined;
|
|
31744
|
-
}
|
|
31796
|
+
for (const chartId in this.charts) {
|
|
31797
|
+
this.charts[chartId] = undefined;
|
|
31745
31798
|
}
|
|
31746
31799
|
}
|
|
31747
31800
|
switch (cmd.type) {
|
|
31748
31801
|
case "UPDATE_CHART":
|
|
31749
31802
|
case "CREATE_CHART":
|
|
31750
31803
|
case "DELETE_FIGURE":
|
|
31751
|
-
|
|
31752
|
-
this.charts[cmd.sheetId][cmd.id] = undefined;
|
|
31753
|
-
}
|
|
31804
|
+
this.charts[cmd.id] = undefined;
|
|
31754
31805
|
break;
|
|
31755
31806
|
case "DELETE_SHEET":
|
|
31756
|
-
|
|
31807
|
+
for (let chartId in this.charts) {
|
|
31808
|
+
if (!this.getters.isChartDefined(chartId)) {
|
|
31809
|
+
this.charts[chartId] = undefined;
|
|
31810
|
+
}
|
|
31811
|
+
}
|
|
31757
31812
|
break;
|
|
31758
31813
|
}
|
|
31759
31814
|
}
|
|
31760
|
-
getChartRuntime(
|
|
31761
|
-
|
|
31762
|
-
|
|
31763
|
-
const chart = this.getters.getChart(sheetId, figureId);
|
|
31815
|
+
getChartRuntime(figureId) {
|
|
31816
|
+
if (!this.charts[figureId]) {
|
|
31817
|
+
const chart = this.getters.getChart(figureId);
|
|
31764
31818
|
if (!chart) {
|
|
31765
31819
|
throw new Error(`No chart for the given id: ${figureId}`);
|
|
31766
31820
|
}
|
|
31767
|
-
|
|
31768
|
-
this.charts[sheetId] = {};
|
|
31769
|
-
this.charts[sheetId][figureId] = this.createRuntimeChart(chart);
|
|
31821
|
+
this.charts[figureId] = this.createRuntimeChart(chart);
|
|
31770
31822
|
}
|
|
31771
|
-
return this.charts[
|
|
31823
|
+
return this.charts[figureId];
|
|
31772
31824
|
}
|
|
31773
31825
|
/**
|
|
31774
31826
|
* Get the background color of a chart based on the color of the first cell of the main range
|
|
@@ -35253,8 +35305,8 @@ class SelectionInputPlugin extends UIPlugin {
|
|
|
35253
35305
|
const currentMaxId = Math.max(0, ...this.ranges.map((range) => Number(range.id)));
|
|
35254
35306
|
this.ranges.splice(index, 0, ...values.map((xc, i) => ({
|
|
35255
35307
|
xc,
|
|
35256
|
-
id:
|
|
35257
|
-
color: colors$1[(currentMaxId +
|
|
35308
|
+
id: currentMaxId + i + 1,
|
|
35309
|
+
color: colors$1[(currentMaxId + i) % colors$1.length],
|
|
35258
35310
|
})));
|
|
35259
35311
|
}
|
|
35260
35312
|
/**
|
|
@@ -37420,7 +37472,7 @@ class ClipboardFigureChart {
|
|
|
37420
37472
|
constructor(dispatch, getters, sheetId, copiedFigureId) {
|
|
37421
37473
|
this.dispatch = dispatch;
|
|
37422
37474
|
this.sheetId = sheetId;
|
|
37423
|
-
const chart = getters.getChart(
|
|
37475
|
+
const chart = getters.getChart(copiedFigureId);
|
|
37424
37476
|
if (!chart) {
|
|
37425
37477
|
throw new Error(`No chart for the given id: ${copiedFigureId}`);
|
|
37426
37478
|
}
|
|
@@ -37441,7 +37493,7 @@ class ClipboardFigureImage {
|
|
|
37441
37493
|
constructor(dispatch, getters, sheetId, copiedFigureId) {
|
|
37442
37494
|
this.dispatch = dispatch;
|
|
37443
37495
|
this.sheetId = sheetId;
|
|
37444
|
-
const image = getters.getImage(
|
|
37496
|
+
const image = getters.getImage(copiedFigureId);
|
|
37445
37497
|
this.copiedImage = deepCopy(image);
|
|
37446
37498
|
}
|
|
37447
37499
|
paste(sheetId, figureId, position, size) {
|
|
@@ -44851,6 +44903,6 @@ exports.setTranslationMethod = setTranslationMethod;
|
|
|
44851
44903
|
exports.tokenize = tokenize;
|
|
44852
44904
|
|
|
44853
44905
|
|
|
44854
|
-
__info__.version = '16.2.0-alpha.
|
|
44855
|
-
__info__.date = '2023-03-
|
|
44856
|
-
__info__.hash = '
|
|
44906
|
+
__info__.version = '16.2.0-alpha.3';
|
|
44907
|
+
__info__.date = '2023-03-06T07:18:09.258Z';
|
|
44908
|
+
__info__.hash = 'ec749cf';
|