@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
|
@@ -274,7 +274,6 @@
|
|
|
274
274
|
ComponentsImportance[ComponentsImportance["Dropdown"] = 16] = "Dropdown";
|
|
275
275
|
ComponentsImportance[ComponentsImportance["GridComposer"] = 20] = "GridComposer";
|
|
276
276
|
ComponentsImportance[ComponentsImportance["TopBarComposer"] = 21] = "TopBarComposer";
|
|
277
|
-
ComponentsImportance[ComponentsImportance["ColorPicker"] = 25] = "ColorPicker";
|
|
278
277
|
ComponentsImportance[ComponentsImportance["IconPicker"] = 25] = "IconPicker";
|
|
279
278
|
ComponentsImportance[ComponentsImportance["Popover"] = 30] = "Popover";
|
|
280
279
|
ComponentsImportance[ComponentsImportance["ChartAnchor"] = 1000] = "ChartAnchor";
|
|
@@ -2844,7 +2843,7 @@
|
|
|
2844
2843
|
return `background-color: ${this.background}`;
|
|
2845
2844
|
}
|
|
2846
2845
|
get chartRuntime() {
|
|
2847
|
-
const runtime = this.env.model.getters.getChartRuntime(this.
|
|
2846
|
+
const runtime = this.env.model.getters.getChartRuntime(this.props.figure.id);
|
|
2848
2847
|
if (!("chartJsConfig" in runtime)) {
|
|
2849
2848
|
throw new Error("Unsupported chart runtime");
|
|
2850
2849
|
}
|
|
@@ -3109,7 +3108,7 @@
|
|
|
3109
3108
|
this.ctx = document.createElement("canvas").getContext("2d");
|
|
3110
3109
|
}
|
|
3111
3110
|
get runtime() {
|
|
3112
|
-
return this.env.model.getters.getChartRuntime(this.
|
|
3111
|
+
return this.env.model.getters.getChartRuntime(this.props.figure.id);
|
|
3113
3112
|
}
|
|
3114
3113
|
get title() {
|
|
3115
3114
|
return this.runtime.title;
|
|
@@ -3498,7 +3497,7 @@
|
|
|
3498
3497
|
CommandResult[CommandResult["InvalidRange"] = 25] = "InvalidRange";
|
|
3499
3498
|
CommandResult[CommandResult["InvalidZones"] = 26] = "InvalidZones";
|
|
3500
3499
|
CommandResult[CommandResult["InvalidSheetId"] = 27] = "InvalidSheetId";
|
|
3501
|
-
CommandResult[CommandResult["
|
|
3500
|
+
CommandResult[CommandResult["InvalidFigureId"] = 28] = "InvalidFigureId";
|
|
3502
3501
|
CommandResult[CommandResult["InputAlreadyFocused"] = 29] = "InputAlreadyFocused";
|
|
3503
3502
|
CommandResult[CommandResult["MaximumRangesReached"] = 30] = "MaximumRangesReached";
|
|
3504
3503
|
CommandResult[CommandResult["InvalidChartDefinition"] = 31] = "InvalidChartDefinition";
|
|
@@ -3555,6 +3554,7 @@
|
|
|
3555
3554
|
CommandResult[CommandResult["DuplicatedFigureId"] = 82] = "DuplicatedFigureId";
|
|
3556
3555
|
CommandResult[CommandResult["InvalidSelectionStep"] = 83] = "InvalidSelectionStep";
|
|
3557
3556
|
CommandResult[CommandResult["DuplicatedChartId"] = 84] = "DuplicatedChartId";
|
|
3557
|
+
CommandResult[CommandResult["ChartDoesNotExist"] = 85] = "ChartDoesNotExist";
|
|
3558
3558
|
})(exports.CommandResult || (exports.CommandResult = {}));
|
|
3559
3559
|
|
|
3560
3560
|
var DIRECTION;
|
|
@@ -6165,7 +6165,7 @@
|
|
|
6165
6165
|
return registry;
|
|
6166
6166
|
}
|
|
6167
6167
|
get chartType() {
|
|
6168
|
-
return this.env.model.getters.getChartType(this.
|
|
6168
|
+
return this.env.model.getters.getChartType(this.props.figure.id);
|
|
6169
6169
|
}
|
|
6170
6170
|
onContextMenu(ev) {
|
|
6171
6171
|
const position = {
|
|
@@ -17184,7 +17184,7 @@
|
|
|
17184
17184
|
id: "reset_size",
|
|
17185
17185
|
name: _lt("Reset size"),
|
|
17186
17186
|
action: () => {
|
|
17187
|
-
const size = this.env.model.getters.
|
|
17187
|
+
const size = this.env.model.getters.getImageSize(this.figureId);
|
|
17188
17188
|
const { height, width } = getMaxFigureSize(this.env.model.getters, size);
|
|
17189
17189
|
this.env.model.dispatch("UPDATE_FIGURE", {
|
|
17190
17190
|
sheetId: this.env.model.getters.getActiveSheetId(),
|
|
@@ -17233,8 +17233,7 @@
|
|
|
17233
17233
|
return this.props.figure.id;
|
|
17234
17234
|
}
|
|
17235
17235
|
get getImagePath() {
|
|
17236
|
-
return this.env.model.getters.
|
|
17237
|
-
.path;
|
|
17236
|
+
return this.env.model.getters.getImagePath(this.figureId);
|
|
17238
17237
|
}
|
|
17239
17238
|
}
|
|
17240
17239
|
ImageFigure.template = "o-spreadsheet-ImageFigure";
|
|
@@ -18039,9 +18038,9 @@
|
|
|
18039
18038
|
const ranges = existingSelectionRange.length
|
|
18040
18039
|
? existingSelectionRange
|
|
18041
18040
|
: this.props.ranges
|
|
18042
|
-
? this.props.ranges.map((xc,
|
|
18041
|
+
? this.props.ranges.map((xc, id) => ({
|
|
18043
18042
|
xc,
|
|
18044
|
-
id
|
|
18043
|
+
id,
|
|
18045
18044
|
isFocused: false,
|
|
18046
18045
|
}))
|
|
18047
18046
|
: [];
|
|
@@ -18107,6 +18106,7 @@
|
|
|
18107
18106
|
else if (ev.key === "Enter") {
|
|
18108
18107
|
const target = ev.target;
|
|
18109
18108
|
target.blur();
|
|
18109
|
+
this.confirm();
|
|
18110
18110
|
}
|
|
18111
18111
|
}
|
|
18112
18112
|
focus(rangeId) {
|
|
@@ -18135,7 +18135,7 @@
|
|
|
18135
18135
|
});
|
|
18136
18136
|
this.triggerChange();
|
|
18137
18137
|
}
|
|
18138
|
-
|
|
18138
|
+
confirm() {
|
|
18139
18139
|
var _a, _b;
|
|
18140
18140
|
this.env.model.dispatch("UNFOCUS_SELECTION_INPUT");
|
|
18141
18141
|
const ranges = this.env.model.getters.getSelectionInputValue(this.id);
|
|
@@ -18230,7 +18230,6 @@
|
|
|
18230
18230
|
LineBarPieConfigPanel.template = "o-spreadsheet-LineBarPieConfigPanel";
|
|
18231
18231
|
LineBarPieConfigPanel.components = { SelectionInput };
|
|
18232
18232
|
LineBarPieConfigPanel.props = {
|
|
18233
|
-
sheetId: String,
|
|
18234
18233
|
figureId: String,
|
|
18235
18234
|
definition: Object,
|
|
18236
18235
|
updateChart: Function,
|
|
@@ -18263,9 +18262,6 @@
|
|
|
18263
18262
|
const GRADIENT_HEIGHT = PICKER_WIDTH - 50;
|
|
18264
18263
|
css /* scss */ `
|
|
18265
18264
|
.o-color-picker {
|
|
18266
|
-
position: absolute;
|
|
18267
|
-
top: calc(100% + 5px);
|
|
18268
|
-
z-index: ${ComponentsImportance.ColorPicker};
|
|
18269
18265
|
padding: ${PICKER_PADDING}px 0px;
|
|
18270
18266
|
box-shadow: 1px 2px 5px 2px rgba(51, 51, 51, 0.15);
|
|
18271
18267
|
background-color: white;
|
|
@@ -18380,15 +18376,6 @@
|
|
|
18380
18376
|
width: 100%;
|
|
18381
18377
|
}
|
|
18382
18378
|
}
|
|
18383
|
-
&.right {
|
|
18384
|
-
left: 0;
|
|
18385
|
-
}
|
|
18386
|
-
&.left {
|
|
18387
|
-
right: 0;
|
|
18388
|
-
}
|
|
18389
|
-
&.center {
|
|
18390
|
-
left: calc(50% - ${PICKER_WIDTH / 2}px);
|
|
18391
|
-
}
|
|
18392
18379
|
}
|
|
18393
18380
|
.o-magnifier-glass {
|
|
18394
18381
|
position: absolute;
|
|
@@ -18423,14 +18410,18 @@
|
|
|
18423
18410
|
});
|
|
18424
18411
|
}
|
|
18425
18412
|
get colorPickerStyle() {
|
|
18426
|
-
if (this.props.maxHeight
|
|
18427
|
-
return "";
|
|
18428
|
-
if (this.props.maxHeight <= 0) {
|
|
18413
|
+
if (this.props.maxHeight !== undefined && this.props.maxHeight <= 0) {
|
|
18429
18414
|
return cssPropertiesToCss({ display: "none" });
|
|
18430
18415
|
}
|
|
18431
|
-
return
|
|
18432
|
-
|
|
18433
|
-
|
|
18416
|
+
return "";
|
|
18417
|
+
}
|
|
18418
|
+
get popoverProps() {
|
|
18419
|
+
return {
|
|
18420
|
+
anchorRect: this.props.anchorRect,
|
|
18421
|
+
maxHeight: this.props.maxHeight,
|
|
18422
|
+
positioning: "BottomLeft",
|
|
18423
|
+
verticalOffset: 0,
|
|
18424
|
+
};
|
|
18434
18425
|
}
|
|
18435
18426
|
onColorClick(color) {
|
|
18436
18427
|
if (color) {
|
|
@@ -18485,11 +18476,12 @@
|
|
|
18485
18476
|
ColorPicker.defaultProps = {
|
|
18486
18477
|
currentColor: "", //TODO Change it to false instead of empty string
|
|
18487
18478
|
};
|
|
18479
|
+
ColorPicker.components = { Popover };
|
|
18488
18480
|
ColorPicker.props = {
|
|
18489
|
-
dropdownDirection: { type: String, optional: true },
|
|
18490
18481
|
onColorPicked: Function,
|
|
18491
18482
|
currentColor: { type: String, optional: true },
|
|
18492
18483
|
maxHeight: { type: Number, optional: true },
|
|
18484
|
+
anchorRect: Object,
|
|
18493
18485
|
};
|
|
18494
18486
|
|
|
18495
18487
|
css /* scss */ `
|
|
@@ -18525,11 +18517,25 @@
|
|
|
18525
18517
|
}
|
|
18526
18518
|
`;
|
|
18527
18519
|
class ColorPickerWidget extends owl.Component {
|
|
18520
|
+
constructor() {
|
|
18521
|
+
super(...arguments);
|
|
18522
|
+
this.colorPickerButtonRef = owl.useRef("colorPickerButton");
|
|
18523
|
+
}
|
|
18528
18524
|
get iconStyle() {
|
|
18529
18525
|
return this.props.currentColor
|
|
18530
18526
|
? `border-color: ${this.props.currentColor}`
|
|
18531
18527
|
: "border-bottom-style: hidden";
|
|
18532
18528
|
}
|
|
18529
|
+
get colorPickerAnchorRect() {
|
|
18530
|
+
const button = this.colorPickerButtonRef.el;
|
|
18531
|
+
const buttonRect = button.getBoundingClientRect();
|
|
18532
|
+
return {
|
|
18533
|
+
x: buttonRect.x,
|
|
18534
|
+
y: buttonRect.y,
|
|
18535
|
+
width: buttonRect.width,
|
|
18536
|
+
height: buttonRect.height,
|
|
18537
|
+
};
|
|
18538
|
+
}
|
|
18533
18539
|
}
|
|
18534
18540
|
ColorPickerWidget.template = "o-spreadsheet-ColorPickerWidget";
|
|
18535
18541
|
ColorPickerWidget.components = { ColorPicker };
|
|
@@ -18539,7 +18545,6 @@
|
|
|
18539
18545
|
showColorPicker: Boolean,
|
|
18540
18546
|
onColorPicked: Function,
|
|
18541
18547
|
icon: String,
|
|
18542
|
-
dropdownDirection: { type: String, optional: true },
|
|
18543
18548
|
title: { type: String, optional: true },
|
|
18544
18549
|
disabled: { type: Boolean, optional: true },
|
|
18545
18550
|
dropdownMaxHeight: { type: Number, optional: true },
|
|
@@ -18619,7 +18624,6 @@
|
|
|
18619
18624
|
GaugeChartConfigPanel.template = "o-spreadsheet-GaugeChartConfigPanel";
|
|
18620
18625
|
GaugeChartConfigPanel.components = { SelectionInput };
|
|
18621
18626
|
GaugeChartConfigPanel.props = {
|
|
18622
|
-
sheetId: String,
|
|
18623
18627
|
figureId: String,
|
|
18624
18628
|
definition: Object,
|
|
18625
18629
|
updateChart: Function,
|
|
@@ -18766,7 +18770,7 @@
|
|
|
18766
18770
|
|
|
18767
18771
|
class LineConfigPanel extends LineBarPieConfigPanel {
|
|
18768
18772
|
get canTreatLabelsAsText() {
|
|
18769
|
-
const chart = this.env.model.getters.getChart(this.props.
|
|
18773
|
+
const chart = this.env.model.getters.getChart(this.props.figureId);
|
|
18770
18774
|
if (chart && chart instanceof LineChart) {
|
|
18771
18775
|
return canChartParseLabels(chart.labelRange, this.env.model.getters);
|
|
18772
18776
|
}
|
|
@@ -18843,7 +18847,6 @@
|
|
|
18843
18847
|
ScorecardChartConfigPanel.template = "o-spreadsheet-ScorecardChartConfigPanel";
|
|
18844
18848
|
ScorecardChartConfigPanel.components = { SelectionInput };
|
|
18845
18849
|
ScorecardChartConfigPanel.props = {
|
|
18846
|
-
sheetId: String,
|
|
18847
18850
|
figureId: String,
|
|
18848
18851
|
definition: Object,
|
|
18849
18852
|
updateChart: Function,
|
|
@@ -18979,7 +18982,7 @@
|
|
|
18979
18982
|
else {
|
|
18980
18983
|
this.shouldUpdateChart = true;
|
|
18981
18984
|
}
|
|
18982
|
-
if (!this.env.model.getters.isChartDefined(this.
|
|
18985
|
+
if (!this.env.model.getters.isChartDefined(this.figureId)) {
|
|
18983
18986
|
this.props.onCloseSidePanel();
|
|
18984
18987
|
return;
|
|
18985
18988
|
}
|
|
@@ -18993,7 +18996,6 @@
|
|
|
18993
18996
|
...this.getChartDefinition(),
|
|
18994
18997
|
...updateDefinition,
|
|
18995
18998
|
};
|
|
18996
|
-
// TODORAR add a putain de test - c'est faux de nouveau ...
|
|
18997
18999
|
return this.env.model.dispatch("UPDATE_CHART", {
|
|
18998
19000
|
definition,
|
|
18999
19001
|
id: this.figureId,
|
|
@@ -19001,12 +19003,11 @@
|
|
|
19001
19003
|
});
|
|
19002
19004
|
}
|
|
19003
19005
|
onTypeChange(type) {
|
|
19004
|
-
const context = this.env.model.getters.getContextCreationChart(this.
|
|
19006
|
+
const context = this.env.model.getters.getContextCreationChart(this.figureId);
|
|
19005
19007
|
if (!context) {
|
|
19006
19008
|
throw new Error("Chart not defined.");
|
|
19007
19009
|
}
|
|
19008
19010
|
const definition = getChartDefinitionFromContextCreation(context, type);
|
|
19009
|
-
// TODORAR add a putain de test - c'est faux de nouveau ...
|
|
19010
19011
|
this.env.model.dispatch("UPDATE_CHART", {
|
|
19011
19012
|
definition,
|
|
19012
19013
|
id: this.figureId,
|
|
@@ -19014,7 +19015,7 @@
|
|
|
19014
19015
|
});
|
|
19015
19016
|
}
|
|
19016
19017
|
get chartPanel() {
|
|
19017
|
-
const type = this.env.model.getters.getChartType(this.
|
|
19018
|
+
const type = this.env.model.getters.getChartType(this.figureId);
|
|
19018
19019
|
if (!type) {
|
|
19019
19020
|
throw new Error("Chart not defined.");
|
|
19020
19021
|
}
|
|
@@ -19024,8 +19025,8 @@
|
|
|
19024
19025
|
}
|
|
19025
19026
|
return chartPanel;
|
|
19026
19027
|
}
|
|
19027
|
-
getChartDefinition() {
|
|
19028
|
-
return this.env.model.getters.getChartDefinition(
|
|
19028
|
+
getChartDefinition(figureId = this.figureId) {
|
|
19029
|
+
return this.env.model.getters.getChartDefinition(figureId);
|
|
19029
19030
|
}
|
|
19030
19031
|
get chartTypes() {
|
|
19031
19032
|
return getChartTypes();
|
|
@@ -25897,13 +25898,7 @@
|
|
|
25897
25898
|
data = migrate(data);
|
|
25898
25899
|
}
|
|
25899
25900
|
}
|
|
25900
|
-
|
|
25901
|
-
// sensible default values
|
|
25902
|
-
data = Object.assign(createEmptyWorkbookData(), data, { version: CURRENT_VERSION });
|
|
25903
|
-
data.sheets = data.sheets.map((s, i) => Object.assign(createEmptySheet(`Sheet${i + 1}`, `Sheet${i + 1}`), s));
|
|
25904
|
-
if (data.sheets.length === 0) {
|
|
25905
|
-
data.sheets.push(createEmptySheet(INITIAL_SHEET_ID, "Sheet1"));
|
|
25906
|
-
}
|
|
25901
|
+
data = repairData(data);
|
|
25907
25902
|
return data;
|
|
25908
25903
|
}
|
|
25909
25904
|
function migrate(data) {
|
|
@@ -26141,6 +26136,48 @@
|
|
|
26141
26136
|
},
|
|
26142
26137
|
},
|
|
26143
26138
|
];
|
|
26139
|
+
/**
|
|
26140
|
+
* This function is used to repair faulty data independently of the migration.
|
|
26141
|
+
*/
|
|
26142
|
+
function repairData(data) {
|
|
26143
|
+
data = forceUnicityOfFigure(data);
|
|
26144
|
+
data = setDefaults(data);
|
|
26145
|
+
return data;
|
|
26146
|
+
}
|
|
26147
|
+
/**
|
|
26148
|
+
* Force the unicity of figure ids accross sheets
|
|
26149
|
+
*/
|
|
26150
|
+
function forceUnicityOfFigure(data) {
|
|
26151
|
+
if (data.uniqueFigureIds) {
|
|
26152
|
+
return data;
|
|
26153
|
+
}
|
|
26154
|
+
const figureIds = new Set();
|
|
26155
|
+
const uuidGenerator = new UuidGenerator();
|
|
26156
|
+
for (const sheet of data.sheets || []) {
|
|
26157
|
+
for (const figure of sheet.figures || []) {
|
|
26158
|
+
if (figureIds.has(figure.id)) {
|
|
26159
|
+
figure.id += uuidGenerator.uuidv4();
|
|
26160
|
+
}
|
|
26161
|
+
figureIds.add(figure.id);
|
|
26162
|
+
}
|
|
26163
|
+
}
|
|
26164
|
+
data.uniqueFigureIds = true;
|
|
26165
|
+
return data;
|
|
26166
|
+
}
|
|
26167
|
+
/**
|
|
26168
|
+
* sanity check: try to fix missing fields/corrupted state by providing
|
|
26169
|
+
* sensible default values
|
|
26170
|
+
*/
|
|
26171
|
+
function setDefaults(data) {
|
|
26172
|
+
data = Object.assign(createEmptyWorkbookData(), data, { version: CURRENT_VERSION });
|
|
26173
|
+
data.sheets = data.sheets
|
|
26174
|
+
? data.sheets.map((s, i) => Object.assign(createEmptySheet(`Sheet${i + 1}`, `Sheet${i + 1}`), s))
|
|
26175
|
+
: [];
|
|
26176
|
+
if (data.sheets.length === 0) {
|
|
26177
|
+
data.sheets.push(createEmptySheet(INITIAL_SHEET_ID, "Sheet1"));
|
|
26178
|
+
}
|
|
26179
|
+
return data;
|
|
26180
|
+
}
|
|
26144
26181
|
/**
|
|
26145
26182
|
* The goal of this function is to repair corrupted/wrong initial messages caused by
|
|
26146
26183
|
* a bug.
|
|
@@ -26279,6 +26316,7 @@
|
|
|
26279
26316
|
formats: {},
|
|
26280
26317
|
borders: {},
|
|
26281
26318
|
revisionId: DEFAULT_REVISION_ID,
|
|
26319
|
+
uniqueFigureIds: true,
|
|
26282
26320
|
};
|
|
26283
26321
|
return data;
|
|
26284
26322
|
}
|
|
@@ -28058,10 +28096,8 @@
|
|
|
28058
28096
|
this.validateChartDefinition = (cmd) => validateChartDefinition(this, cmd.definition);
|
|
28059
28097
|
}
|
|
28060
28098
|
adaptRanges(applyChange) {
|
|
28061
|
-
for (const
|
|
28062
|
-
|
|
28063
|
-
this.history.update("charts", sheetId, chartId, chart === null || chart === void 0 ? void 0 : chart.updateRanges(applyChange));
|
|
28064
|
-
}
|
|
28099
|
+
for (const [chartId, chart] of Object.entries(this.charts)) {
|
|
28100
|
+
this.history.update("charts", chartId, chart === null || chart === void 0 ? void 0 : chart.updateRanges(applyChange));
|
|
28065
28101
|
}
|
|
28066
28102
|
}
|
|
28067
28103
|
// ---------------------------------------------------------------------------
|
|
@@ -28072,20 +28108,20 @@
|
|
|
28072
28108
|
case "CREATE_CHART":
|
|
28073
28109
|
return this.checkValidations(cmd, this.chainValidations(this.validateChartDefinition, this.checkChartDuplicate));
|
|
28074
28110
|
case "UPDATE_CHART":
|
|
28075
|
-
return this.
|
|
28111
|
+
return this.checkValidations(cmd, this.chainValidations(this.validateChartDefinition, this.checkChartExists));
|
|
28076
28112
|
default:
|
|
28077
28113
|
return 0 /* CommandResult.Success */;
|
|
28078
28114
|
}
|
|
28079
28115
|
}
|
|
28080
28116
|
handle(cmd) {
|
|
28081
|
-
var _a
|
|
28117
|
+
var _a;
|
|
28082
28118
|
switch (cmd.type) {
|
|
28083
28119
|
case "CREATE_CHART":
|
|
28084
28120
|
this.addFigure(cmd.id, cmd.sheetId, cmd.position, cmd.size);
|
|
28085
|
-
this.addChart(cmd.id, cmd.
|
|
28121
|
+
this.addChart(cmd.id, cmd.definition);
|
|
28086
28122
|
break;
|
|
28087
28123
|
case "UPDATE_CHART": {
|
|
28088
|
-
this.addChart(cmd.id, cmd.
|
|
28124
|
+
this.addChart(cmd.id, cmd.definition);
|
|
28089
28125
|
break;
|
|
28090
28126
|
}
|
|
28091
28127
|
case "DUPLICATE_SHEET": {
|
|
@@ -28094,7 +28130,7 @@
|
|
|
28094
28130
|
if (fig.tag === "chart") {
|
|
28095
28131
|
const figureIdBase = fig.id.split(FIGURE_ID_SPLITTER).pop();
|
|
28096
28132
|
const duplicatedFigureId = `${cmd.sheetIdTo}${FIGURE_ID_SPLITTER}${figureIdBase}`;
|
|
28097
|
-
const chart = (
|
|
28133
|
+
const chart = (_a = this.charts[fig.id]) === null || _a === void 0 ? void 0 : _a.copyForSheetId(cmd.sheetIdTo);
|
|
28098
28134
|
if (chart) {
|
|
28099
28135
|
this.dispatch("CREATE_CHART", {
|
|
28100
28136
|
id: duplicatedFigureId,
|
|
@@ -28109,44 +28145,44 @@
|
|
|
28109
28145
|
break;
|
|
28110
28146
|
}
|
|
28111
28147
|
case "DELETE_FIGURE":
|
|
28112
|
-
this.history.update("charts", cmd.
|
|
28148
|
+
this.history.update("charts", cmd.id, undefined);
|
|
28113
28149
|
break;
|
|
28114
28150
|
case "DELETE_SHEET":
|
|
28115
|
-
this.
|
|
28151
|
+
for (let id of this.getChartIds(cmd.sheetId)) {
|
|
28152
|
+
this.history.update("charts", id, undefined);
|
|
28153
|
+
}
|
|
28116
28154
|
break;
|
|
28117
28155
|
}
|
|
28118
28156
|
}
|
|
28119
28157
|
// ---------------------------------------------------------------------------
|
|
28120
28158
|
// Getters
|
|
28121
28159
|
// ---------------------------------------------------------------------------
|
|
28122
|
-
getContextCreationChart(
|
|
28123
|
-
var _a, _b;
|
|
28124
|
-
return (_b = (_a = this.charts[sheetId]) === null || _a === void 0 ? void 0 : _a[figureId]) === null || _b === void 0 ? void 0 : _b.getContextCreation();
|
|
28125
|
-
}
|
|
28126
|
-
getChart(sheetId, figureId) {
|
|
28160
|
+
getContextCreationChart(figureId) {
|
|
28127
28161
|
var _a;
|
|
28128
|
-
return (_a = this.charts[
|
|
28162
|
+
return (_a = this.charts[figureId]) === null || _a === void 0 ? void 0 : _a.getContextCreation();
|
|
28129
28163
|
}
|
|
28130
|
-
|
|
28131
|
-
|
|
28132
|
-
|
|
28164
|
+
getChart(figureId) {
|
|
28165
|
+
return this.charts[figureId];
|
|
28166
|
+
}
|
|
28167
|
+
getChartType(figureId) {
|
|
28168
|
+
var _a;
|
|
28169
|
+
const type = (_a = this.charts[figureId]) === null || _a === void 0 ? void 0 : _a.type;
|
|
28133
28170
|
if (!type) {
|
|
28134
28171
|
throw new Error("Chart not defined.");
|
|
28135
28172
|
}
|
|
28136
28173
|
return type;
|
|
28137
28174
|
}
|
|
28138
|
-
isChartDefined(
|
|
28139
|
-
return figureId in
|
|
28175
|
+
isChartDefined(figureId) {
|
|
28176
|
+
return figureId in this.charts && this.charts !== undefined;
|
|
28140
28177
|
}
|
|
28141
28178
|
getChartIds(sheetId) {
|
|
28142
|
-
|
|
28143
|
-
|
|
28144
|
-
|
|
28145
|
-
return Object.keys(this.charts[sheetId] || {});
|
|
28179
|
+
return Object.entries(this.charts)
|
|
28180
|
+
.filter(([, chart]) => (chart === null || chart === void 0 ? void 0 : chart.sheetId) === sheetId)
|
|
28181
|
+
.map(([id]) => id);
|
|
28146
28182
|
}
|
|
28147
|
-
getChartDefinition(
|
|
28148
|
-
var _a
|
|
28149
|
-
const definition = (
|
|
28183
|
+
getChartDefinition(figureId) {
|
|
28184
|
+
var _a;
|
|
28185
|
+
const definition = (_a = this.charts[figureId]) === null || _a === void 0 ? void 0 : _a.getDefinition();
|
|
28150
28186
|
if (!definition) {
|
|
28151
28187
|
throw new Error(`There is no chart with the given figureId: ${figureId}`);
|
|
28152
28188
|
}
|
|
@@ -28158,28 +28194,35 @@
|
|
|
28158
28194
|
import(data) {
|
|
28159
28195
|
for (let sheet of data.sheets) {
|
|
28160
28196
|
if (sheet.figures) {
|
|
28161
|
-
const charts = {};
|
|
28162
28197
|
for (let figure of sheet.figures) {
|
|
28163
28198
|
// TODO:
|
|
28164
28199
|
// figure data should be external IMO => chart should be in sheet.chart
|
|
28165
28200
|
// instead of in figure.data
|
|
28166
28201
|
if (figure.tag === "chart") {
|
|
28167
|
-
charts[figure.id] = this.createChart(figure.id, figure.data, sheet.id);
|
|
28202
|
+
this.charts[figure.id] = this.createChart(figure.id, figure.data, sheet.id);
|
|
28168
28203
|
}
|
|
28169
28204
|
}
|
|
28170
|
-
this.charts[sheet.id] = charts;
|
|
28171
28205
|
}
|
|
28172
28206
|
}
|
|
28173
28207
|
}
|
|
28174
28208
|
export(data) {
|
|
28209
|
+
var _a;
|
|
28175
28210
|
if (data.sheets) {
|
|
28176
28211
|
for (let sheet of data.sheets) {
|
|
28177
28212
|
// TODO This code is false, if two plugins want ot insert figures on the sheet, it will crash !
|
|
28178
28213
|
const sheetFigures = this.getters.getFigures(sheet.id);
|
|
28179
|
-
const figures =
|
|
28180
|
-
for (let
|
|
28214
|
+
const figures = [];
|
|
28215
|
+
for (let sheetFigure of sheetFigures) {
|
|
28216
|
+
const figure = sheetFigure;
|
|
28181
28217
|
if (figure && figure.tag === "chart") {
|
|
28182
|
-
|
|
28218
|
+
const data = (_a = this.charts[figure.id]) === null || _a === void 0 ? void 0 : _a.getDefinition();
|
|
28219
|
+
if (data) {
|
|
28220
|
+
figure.data = data;
|
|
28221
|
+
figures.push(figure);
|
|
28222
|
+
}
|
|
28223
|
+
}
|
|
28224
|
+
else {
|
|
28225
|
+
figures.push(figure);
|
|
28183
28226
|
}
|
|
28184
28227
|
}
|
|
28185
28228
|
sheet.figures = figures;
|
|
@@ -28187,13 +28230,13 @@
|
|
|
28187
28230
|
}
|
|
28188
28231
|
}
|
|
28189
28232
|
exportForExcel(data) {
|
|
28190
|
-
var _a
|
|
28233
|
+
var _a;
|
|
28191
28234
|
for (let sheet of data.sheets) {
|
|
28192
28235
|
const sheetFigures = this.getters.getFigures(sheet.id);
|
|
28193
28236
|
const figures = [];
|
|
28194
28237
|
for (let figure of sheetFigures) {
|
|
28195
28238
|
if (figure && figure.tag === "chart") {
|
|
28196
|
-
const figureData = (
|
|
28239
|
+
const figureData = (_a = this.charts[figure.id]) === null || _a === void 0 ? void 0 : _a.getDefinitionForExcel();
|
|
28197
28240
|
if (figureData) {
|
|
28198
28241
|
figures.push({
|
|
28199
28242
|
...figure,
|
|
@@ -28232,15 +28275,21 @@
|
|
|
28232
28275
|
* Add a chart in the local state. If a chart already exists, this chart is
|
|
28233
28276
|
* replaced
|
|
28234
28277
|
*/
|
|
28235
|
-
addChart(id,
|
|
28236
|
-
|
|
28278
|
+
addChart(id, definition) {
|
|
28279
|
+
const sheetId = this.getters.getFigureSheetId(id);
|
|
28280
|
+
if (sheetId) {
|
|
28281
|
+
this.history.update("charts", id, this.createChart(id, definition, sheetId));
|
|
28282
|
+
}
|
|
28237
28283
|
}
|
|
28238
28284
|
checkChartDuplicate(cmd) {
|
|
28239
|
-
|
|
28240
|
-
|
|
28241
|
-
|
|
28242
|
-
|
|
28243
|
-
|
|
28285
|
+
return this.getters.getFigureSheetId(cmd.id)
|
|
28286
|
+
? 84 /* CommandResult.DuplicatedChartId */
|
|
28287
|
+
: 0 /* CommandResult.Success */;
|
|
28288
|
+
}
|
|
28289
|
+
checkChartExists(cmd) {
|
|
28290
|
+
return this.getters.getFigureSheetId(cmd.id)
|
|
28291
|
+
? 0 /* CommandResult.Success */
|
|
28292
|
+
: 85 /* CommandResult.ChartDoesNotExist */;
|
|
28244
28293
|
}
|
|
28245
28294
|
}
|
|
28246
28295
|
ChartPlugin.getters = [
|
|
@@ -28621,7 +28670,7 @@
|
|
|
28621
28670
|
allowDispatch(cmd) {
|
|
28622
28671
|
switch (cmd.type) {
|
|
28623
28672
|
case "CREATE_FIGURE":
|
|
28624
|
-
return this.checkFigureDuplicate(cmd.
|
|
28673
|
+
return this.checkFigureDuplicate(cmd.figure.id);
|
|
28625
28674
|
case "UPDATE_FIGURE":
|
|
28626
28675
|
case "DELETE_FIGURE":
|
|
28627
28676
|
return this.checkFigureExists(cmd.sheetId, cmd.id);
|
|
@@ -28687,9 +28736,8 @@
|
|
|
28687
28736
|
}
|
|
28688
28737
|
return 0 /* CommandResult.Success */;
|
|
28689
28738
|
}
|
|
28690
|
-
checkFigureDuplicate(
|
|
28691
|
-
|
|
28692
|
-
if ((_a = this.figures[sheetId]) === null || _a === void 0 ? void 0 : _a[figureId]) {
|
|
28739
|
+
checkFigureDuplicate(figureId) {
|
|
28740
|
+
if (Object.values(this.figures).find((sheet) => sheet === null || sheet === void 0 ? void 0 : sheet[figureId])) {
|
|
28693
28741
|
return 82 /* CommandResult.DuplicatedFigureId */;
|
|
28694
28742
|
}
|
|
28695
28743
|
return 0 /* CommandResult.Success */;
|
|
@@ -28704,6 +28752,9 @@
|
|
|
28704
28752
|
var _a;
|
|
28705
28753
|
return (_a = this.figures[sheetId]) === null || _a === void 0 ? void 0 : _a[figureId];
|
|
28706
28754
|
}
|
|
28755
|
+
getFigureSheetId(figureId) {
|
|
28756
|
+
return Object.keys(this.figures).find((sheetId) => { var _a; return ((_a = this.figures[sheetId]) === null || _a === void 0 ? void 0 : _a[figureId]) !== undefined; });
|
|
28757
|
+
}
|
|
28707
28758
|
// ---------------------------------------------------------------------------
|
|
28708
28759
|
// Import/Export
|
|
28709
28760
|
// ---------------------------------------------------------------------------
|
|
@@ -28728,7 +28779,7 @@
|
|
|
28728
28779
|
this.export(data);
|
|
28729
28780
|
}
|
|
28730
28781
|
}
|
|
28731
|
-
FigurePlugin.getters = ["getFigures", "getFigure"];
|
|
28782
|
+
FigurePlugin.getters = ["getFigures", "getFigure", "getFigureSheetId"];
|
|
28732
28783
|
|
|
28733
28784
|
class FilterTable {
|
|
28734
28785
|
constructor(zone) {
|
|
@@ -29455,7 +29506,7 @@
|
|
|
29455
29506
|
switch (cmd.type) {
|
|
29456
29507
|
case "CREATE_IMAGE":
|
|
29457
29508
|
if (this.getters.getFigure(cmd.sheetId, cmd.figureId)) {
|
|
29458
|
-
return 28 /* CommandResult.
|
|
29509
|
+
return 28 /* CommandResult.InvalidFigureId */;
|
|
29459
29510
|
}
|
|
29460
29511
|
return 0 /* CommandResult.Success */;
|
|
29461
29512
|
default:
|
|
@@ -29475,7 +29526,7 @@
|
|
|
29475
29526
|
if (fig.tag === "image") {
|
|
29476
29527
|
const figureIdBase = fig.id.split(FIGURE_ID_SPLITTER).pop();
|
|
29477
29528
|
const duplicatedFigureId = `${cmd.sheetIdTo}${FIGURE_ID_SPLITTER}${figureIdBase}`;
|
|
29478
|
-
const image = this.getImage(
|
|
29529
|
+
const image = this.getImage(fig.id);
|
|
29479
29530
|
if (image) {
|
|
29480
29531
|
const size = { width: fig.width, height: fig.height };
|
|
29481
29532
|
this.dispatch("CREATE_IMAGE", {
|
|
@@ -29513,13 +29564,19 @@
|
|
|
29513
29564
|
// ---------------------------------------------------------------------------
|
|
29514
29565
|
// Getters
|
|
29515
29566
|
// ---------------------------------------------------------------------------
|
|
29516
|
-
getImage(
|
|
29517
|
-
|
|
29518
|
-
|
|
29519
|
-
|
|
29520
|
-
|
|
29567
|
+
getImage(figureId) {
|
|
29568
|
+
for (const sheet of Object.values(this.images)) {
|
|
29569
|
+
if (sheet && sheet[figureId]) {
|
|
29570
|
+
return sheet[figureId];
|
|
29571
|
+
}
|
|
29521
29572
|
}
|
|
29522
|
-
|
|
29573
|
+
throw new Error(`There is no image with the given figureId: ${figureId}`);
|
|
29574
|
+
}
|
|
29575
|
+
getImagePath(figureId) {
|
|
29576
|
+
return this.getImage(figureId).path;
|
|
29577
|
+
}
|
|
29578
|
+
getImageSize(figureId) {
|
|
29579
|
+
return this.getImage(figureId).size;
|
|
29523
29580
|
}
|
|
29524
29581
|
// ---------------------------------------------------------------------------
|
|
29525
29582
|
// Private
|
|
@@ -29561,7 +29618,7 @@
|
|
|
29561
29618
|
return images;
|
|
29562
29619
|
}
|
|
29563
29620
|
}
|
|
29564
|
-
ImagePlugin.getters = ["getImage"];
|
|
29621
|
+
ImagePlugin.getters = ["getImage", "getImagePath", "getImageSize"];
|
|
29565
29622
|
|
|
29566
29623
|
class MergePlugin extends CorePlugin {
|
|
29567
29624
|
constructor() {
|
|
@@ -31367,9 +31424,7 @@
|
|
|
31367
31424
|
return formatColors.filter(isDefined$1);
|
|
31368
31425
|
}
|
|
31369
31426
|
getChartColors(sheetId) {
|
|
31370
|
-
const charts = this.getters
|
|
31371
|
-
.getChartIds(sheetId)
|
|
31372
|
-
.map((cid) => this.getters.getChart(sheetId, cid));
|
|
31427
|
+
const charts = this.getters.getChartIds(sheetId).map((cid) => this.getters.getChart(cid));
|
|
31373
31428
|
let chartsColors = new Set();
|
|
31374
31429
|
for (let chart of charts) {
|
|
31375
31430
|
if (chart === undefined) {
|
|
@@ -31735,37 +31790,34 @@
|
|
|
31735
31790
|
invalidateCFEvaluationCommands.has(cmd.type) ||
|
|
31736
31791
|
cmd.type === "EVALUATE_CELLS" ||
|
|
31737
31792
|
cmd.type === "UPDATE_CELL") {
|
|
31738
|
-
for (const
|
|
31739
|
-
|
|
31740
|
-
this.charts[sheetId][chartId] = undefined;
|
|
31741
|
-
}
|
|
31793
|
+
for (const chartId in this.charts) {
|
|
31794
|
+
this.charts[chartId] = undefined;
|
|
31742
31795
|
}
|
|
31743
31796
|
}
|
|
31744
31797
|
switch (cmd.type) {
|
|
31745
31798
|
case "UPDATE_CHART":
|
|
31746
31799
|
case "CREATE_CHART":
|
|
31747
31800
|
case "DELETE_FIGURE":
|
|
31748
|
-
|
|
31749
|
-
this.charts[cmd.sheetId][cmd.id] = undefined;
|
|
31750
|
-
}
|
|
31801
|
+
this.charts[cmd.id] = undefined;
|
|
31751
31802
|
break;
|
|
31752
31803
|
case "DELETE_SHEET":
|
|
31753
|
-
|
|
31804
|
+
for (let chartId in this.charts) {
|
|
31805
|
+
if (!this.getters.isChartDefined(chartId)) {
|
|
31806
|
+
this.charts[chartId] = undefined;
|
|
31807
|
+
}
|
|
31808
|
+
}
|
|
31754
31809
|
break;
|
|
31755
31810
|
}
|
|
31756
31811
|
}
|
|
31757
|
-
getChartRuntime(
|
|
31758
|
-
|
|
31759
|
-
|
|
31760
|
-
const chart = this.getters.getChart(sheetId, figureId);
|
|
31812
|
+
getChartRuntime(figureId) {
|
|
31813
|
+
if (!this.charts[figureId]) {
|
|
31814
|
+
const chart = this.getters.getChart(figureId);
|
|
31761
31815
|
if (!chart) {
|
|
31762
31816
|
throw new Error(`No chart for the given id: ${figureId}`);
|
|
31763
31817
|
}
|
|
31764
|
-
|
|
31765
|
-
this.charts[sheetId] = {};
|
|
31766
|
-
this.charts[sheetId][figureId] = this.createRuntimeChart(chart);
|
|
31818
|
+
this.charts[figureId] = this.createRuntimeChart(chart);
|
|
31767
31819
|
}
|
|
31768
|
-
return this.charts[
|
|
31820
|
+
return this.charts[figureId];
|
|
31769
31821
|
}
|
|
31770
31822
|
/**
|
|
31771
31823
|
* Get the background color of a chart based on the color of the first cell of the main range
|
|
@@ -35250,8 +35302,8 @@
|
|
|
35250
35302
|
const currentMaxId = Math.max(0, ...this.ranges.map((range) => Number(range.id)));
|
|
35251
35303
|
this.ranges.splice(index, 0, ...values.map((xc, i) => ({
|
|
35252
35304
|
xc,
|
|
35253
|
-
id:
|
|
35254
|
-
color: colors$1[(currentMaxId +
|
|
35305
|
+
id: currentMaxId + i + 1,
|
|
35306
|
+
color: colors$1[(currentMaxId + i) % colors$1.length],
|
|
35255
35307
|
})));
|
|
35256
35308
|
}
|
|
35257
35309
|
/**
|
|
@@ -37417,7 +37469,7 @@
|
|
|
37417
37469
|
constructor(dispatch, getters, sheetId, copiedFigureId) {
|
|
37418
37470
|
this.dispatch = dispatch;
|
|
37419
37471
|
this.sheetId = sheetId;
|
|
37420
|
-
const chart = getters.getChart(
|
|
37472
|
+
const chart = getters.getChart(copiedFigureId);
|
|
37421
37473
|
if (!chart) {
|
|
37422
37474
|
throw new Error(`No chart for the given id: ${copiedFigureId}`);
|
|
37423
37475
|
}
|
|
@@ -37438,7 +37490,7 @@
|
|
|
37438
37490
|
constructor(dispatch, getters, sheetId, copiedFigureId) {
|
|
37439
37491
|
this.dispatch = dispatch;
|
|
37440
37492
|
this.sheetId = sheetId;
|
|
37441
|
-
const image = getters.getImage(
|
|
37493
|
+
const image = getters.getImage(copiedFigureId);
|
|
37442
37494
|
this.copiedImage = deepCopy(image);
|
|
37443
37495
|
}
|
|
37444
37496
|
paste(sheetId, figureId, position, size) {
|
|
@@ -44850,9 +44902,9 @@
|
|
|
44850
44902
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
44851
44903
|
|
|
44852
44904
|
|
|
44853
|
-
__info__.version = '16.2.0-alpha.
|
|
44854
|
-
__info__.date = '2023-03-
|
|
44855
|
-
__info__.hash = '
|
|
44905
|
+
__info__.version = '16.2.0-alpha.3';
|
|
44906
|
+
__info__.date = '2023-03-06T07:18:09.258Z';
|
|
44907
|
+
__info__.hash = 'ec749cf';
|
|
44856
44908
|
|
|
44857
44909
|
|
|
44858
44910
|
})(this.o_spreadsheet = this.o_spreadsheet || {}, owl);
|