@odoo/o-spreadsheet 16.2.0-alpha.2 → 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 -128
- package/dist/o_spreadsheet.d.ts +77 -69
- package/dist/o_spreadsheet.esm.js +185 -128
- package/dist/o_spreadsheet.iife.js +185 -128
- package/dist/o_spreadsheet.iife.min.js +11 -23
- package/package.json +2 -2
|
@@ -273,7 +273,6 @@ var ComponentsImportance;
|
|
|
273
273
|
ComponentsImportance[ComponentsImportance["Dropdown"] = 16] = "Dropdown";
|
|
274
274
|
ComponentsImportance[ComponentsImportance["GridComposer"] = 20] = "GridComposer";
|
|
275
275
|
ComponentsImportance[ComponentsImportance["TopBarComposer"] = 21] = "TopBarComposer";
|
|
276
|
-
ComponentsImportance[ComponentsImportance["ColorPicker"] = 25] = "ColorPicker";
|
|
277
276
|
ComponentsImportance[ComponentsImportance["IconPicker"] = 25] = "IconPicker";
|
|
278
277
|
ComponentsImportance[ComponentsImportance["Popover"] = 30] = "Popover";
|
|
279
278
|
ComponentsImportance[ComponentsImportance["ChartAnchor"] = 1000] = "ChartAnchor";
|
|
@@ -2843,7 +2842,7 @@ class ChartJsComponent extends Component {
|
|
|
2843
2842
|
return `background-color: ${this.background}`;
|
|
2844
2843
|
}
|
|
2845
2844
|
get chartRuntime() {
|
|
2846
|
-
const runtime = this.env.model.getters.getChartRuntime(this.
|
|
2845
|
+
const runtime = this.env.model.getters.getChartRuntime(this.props.figure.id);
|
|
2847
2846
|
if (!("chartJsConfig" in runtime)) {
|
|
2848
2847
|
throw new Error("Unsupported chart runtime");
|
|
2849
2848
|
}
|
|
@@ -3108,7 +3107,7 @@ class ScorecardChart$1 extends Component {
|
|
|
3108
3107
|
this.ctx = document.createElement("canvas").getContext("2d");
|
|
3109
3108
|
}
|
|
3110
3109
|
get runtime() {
|
|
3111
|
-
return this.env.model.getters.getChartRuntime(this.
|
|
3110
|
+
return this.env.model.getters.getChartRuntime(this.props.figure.id);
|
|
3112
3111
|
}
|
|
3113
3112
|
get title() {
|
|
3114
3113
|
return this.runtime.title;
|
|
@@ -3497,7 +3496,7 @@ var CommandResult;
|
|
|
3497
3496
|
CommandResult[CommandResult["InvalidRange"] = 25] = "InvalidRange";
|
|
3498
3497
|
CommandResult[CommandResult["InvalidZones"] = 26] = "InvalidZones";
|
|
3499
3498
|
CommandResult[CommandResult["InvalidSheetId"] = 27] = "InvalidSheetId";
|
|
3500
|
-
CommandResult[CommandResult["
|
|
3499
|
+
CommandResult[CommandResult["InvalidFigureId"] = 28] = "InvalidFigureId";
|
|
3501
3500
|
CommandResult[CommandResult["InputAlreadyFocused"] = 29] = "InputAlreadyFocused";
|
|
3502
3501
|
CommandResult[CommandResult["MaximumRangesReached"] = 30] = "MaximumRangesReached";
|
|
3503
3502
|
CommandResult[CommandResult["InvalidChartDefinition"] = 31] = "InvalidChartDefinition";
|
|
@@ -3554,6 +3553,7 @@ var CommandResult;
|
|
|
3554
3553
|
CommandResult[CommandResult["DuplicatedFigureId"] = 82] = "DuplicatedFigureId";
|
|
3555
3554
|
CommandResult[CommandResult["InvalidSelectionStep"] = 83] = "InvalidSelectionStep";
|
|
3556
3555
|
CommandResult[CommandResult["DuplicatedChartId"] = 84] = "DuplicatedChartId";
|
|
3556
|
+
CommandResult[CommandResult["ChartDoesNotExist"] = 85] = "ChartDoesNotExist";
|
|
3557
3557
|
})(CommandResult || (CommandResult = {}));
|
|
3558
3558
|
|
|
3559
3559
|
var DIRECTION;
|
|
@@ -6164,7 +6164,7 @@ class ChartFigure extends Component {
|
|
|
6164
6164
|
return registry;
|
|
6165
6165
|
}
|
|
6166
6166
|
get chartType() {
|
|
6167
|
-
return this.env.model.getters.getChartType(this.
|
|
6167
|
+
return this.env.model.getters.getChartType(this.props.figure.id);
|
|
6168
6168
|
}
|
|
6169
6169
|
onContextMenu(ev) {
|
|
6170
6170
|
const position = {
|
|
@@ -17183,7 +17183,7 @@ class ImageFigure extends Component {
|
|
|
17183
17183
|
id: "reset_size",
|
|
17184
17184
|
name: _lt("Reset size"),
|
|
17185
17185
|
action: () => {
|
|
17186
|
-
const size = this.env.model.getters.
|
|
17186
|
+
const size = this.env.model.getters.getImageSize(this.figureId);
|
|
17187
17187
|
const { height, width } = getMaxFigureSize(this.env.model.getters, size);
|
|
17188
17188
|
this.env.model.dispatch("UPDATE_FIGURE", {
|
|
17189
17189
|
sheetId: this.env.model.getters.getActiveSheetId(),
|
|
@@ -17232,8 +17232,7 @@ class ImageFigure extends Component {
|
|
|
17232
17232
|
return this.props.figure.id;
|
|
17233
17233
|
}
|
|
17234
17234
|
get getImagePath() {
|
|
17235
|
-
return this.env.model.getters.
|
|
17236
|
-
.path;
|
|
17235
|
+
return this.env.model.getters.getImagePath(this.figureId);
|
|
17237
17236
|
}
|
|
17238
17237
|
}
|
|
17239
17238
|
ImageFigure.template = "o-spreadsheet-ImageFigure";
|
|
@@ -18038,9 +18037,9 @@ class SelectionInput extends Component {
|
|
|
18038
18037
|
const ranges = existingSelectionRange.length
|
|
18039
18038
|
? existingSelectionRange
|
|
18040
18039
|
: this.props.ranges
|
|
18041
|
-
? this.props.ranges.map((xc,
|
|
18040
|
+
? this.props.ranges.map((xc, id) => ({
|
|
18042
18041
|
xc,
|
|
18043
|
-
id
|
|
18042
|
+
id,
|
|
18044
18043
|
isFocused: false,
|
|
18045
18044
|
}))
|
|
18046
18045
|
: [];
|
|
@@ -18106,6 +18105,7 @@ class SelectionInput extends Component {
|
|
|
18106
18105
|
else if (ev.key === "Enter") {
|
|
18107
18106
|
const target = ev.target;
|
|
18108
18107
|
target.blur();
|
|
18108
|
+
this.confirm();
|
|
18109
18109
|
}
|
|
18110
18110
|
}
|
|
18111
18111
|
focus(rangeId) {
|
|
@@ -18134,7 +18134,7 @@ class SelectionInput extends Component {
|
|
|
18134
18134
|
});
|
|
18135
18135
|
this.triggerChange();
|
|
18136
18136
|
}
|
|
18137
|
-
|
|
18137
|
+
confirm() {
|
|
18138
18138
|
var _a, _b;
|
|
18139
18139
|
this.env.model.dispatch("UNFOCUS_SELECTION_INPUT");
|
|
18140
18140
|
const ranges = this.env.model.getters.getSelectionInputValue(this.id);
|
|
@@ -18229,7 +18229,6 @@ class LineBarPieConfigPanel extends Component {
|
|
|
18229
18229
|
LineBarPieConfigPanel.template = "o-spreadsheet-LineBarPieConfigPanel";
|
|
18230
18230
|
LineBarPieConfigPanel.components = { SelectionInput };
|
|
18231
18231
|
LineBarPieConfigPanel.props = {
|
|
18232
|
-
sheetId: String,
|
|
18233
18232
|
figureId: String,
|
|
18234
18233
|
definition: Object,
|
|
18235
18234
|
updateChart: Function,
|
|
@@ -18262,9 +18261,6 @@ const GRADIENT_WIDTH = PICKER_WIDTH - 2 * LINE_HORIZONTAL_PADDING - 2 * ITEM_BOR
|
|
|
18262
18261
|
const GRADIENT_HEIGHT = PICKER_WIDTH - 50;
|
|
18263
18262
|
css /* scss */ `
|
|
18264
18263
|
.o-color-picker {
|
|
18265
|
-
position: absolute;
|
|
18266
|
-
top: calc(100% + 5px);
|
|
18267
|
-
z-index: ${ComponentsImportance.ColorPicker};
|
|
18268
18264
|
padding: ${PICKER_PADDING}px 0px;
|
|
18269
18265
|
box-shadow: 1px 2px 5px 2px rgba(51, 51, 51, 0.15);
|
|
18270
18266
|
background-color: white;
|
|
@@ -18379,15 +18375,6 @@ css /* scss */ `
|
|
|
18379
18375
|
width: 100%;
|
|
18380
18376
|
}
|
|
18381
18377
|
}
|
|
18382
|
-
&.right {
|
|
18383
|
-
left: 0;
|
|
18384
|
-
}
|
|
18385
|
-
&.left {
|
|
18386
|
-
right: 0;
|
|
18387
|
-
}
|
|
18388
|
-
&.center {
|
|
18389
|
-
left: calc(50% - ${PICKER_WIDTH / 2}px);
|
|
18390
|
-
}
|
|
18391
18378
|
}
|
|
18392
18379
|
.o-magnifier-glass {
|
|
18393
18380
|
position: absolute;
|
|
@@ -18422,14 +18409,18 @@ class ColorPicker extends Component {
|
|
|
18422
18409
|
});
|
|
18423
18410
|
}
|
|
18424
18411
|
get colorPickerStyle() {
|
|
18425
|
-
if (this.props.maxHeight
|
|
18426
|
-
return "";
|
|
18427
|
-
if (this.props.maxHeight <= 0) {
|
|
18412
|
+
if (this.props.maxHeight !== undefined && this.props.maxHeight <= 0) {
|
|
18428
18413
|
return cssPropertiesToCss({ display: "none" });
|
|
18429
18414
|
}
|
|
18430
|
-
return
|
|
18431
|
-
|
|
18432
|
-
|
|
18415
|
+
return "";
|
|
18416
|
+
}
|
|
18417
|
+
get popoverProps() {
|
|
18418
|
+
return {
|
|
18419
|
+
anchorRect: this.props.anchorRect,
|
|
18420
|
+
maxHeight: this.props.maxHeight,
|
|
18421
|
+
positioning: "BottomLeft",
|
|
18422
|
+
verticalOffset: 0,
|
|
18423
|
+
};
|
|
18433
18424
|
}
|
|
18434
18425
|
onColorClick(color) {
|
|
18435
18426
|
if (color) {
|
|
@@ -18484,11 +18475,12 @@ ColorPicker.template = "o-spreadsheet-ColorPicker";
|
|
|
18484
18475
|
ColorPicker.defaultProps = {
|
|
18485
18476
|
currentColor: "", //TODO Change it to false instead of empty string
|
|
18486
18477
|
};
|
|
18478
|
+
ColorPicker.components = { Popover };
|
|
18487
18479
|
ColorPicker.props = {
|
|
18488
|
-
dropdownDirection: { type: String, optional: true },
|
|
18489
18480
|
onColorPicked: Function,
|
|
18490
18481
|
currentColor: { type: String, optional: true },
|
|
18491
18482
|
maxHeight: { type: Number, optional: true },
|
|
18483
|
+
anchorRect: Object,
|
|
18492
18484
|
};
|
|
18493
18485
|
|
|
18494
18486
|
css /* scss */ `
|
|
@@ -18524,11 +18516,25 @@ css /* scss */ `
|
|
|
18524
18516
|
}
|
|
18525
18517
|
`;
|
|
18526
18518
|
class ColorPickerWidget extends Component {
|
|
18519
|
+
constructor() {
|
|
18520
|
+
super(...arguments);
|
|
18521
|
+
this.colorPickerButtonRef = useRef("colorPickerButton");
|
|
18522
|
+
}
|
|
18527
18523
|
get iconStyle() {
|
|
18528
18524
|
return this.props.currentColor
|
|
18529
18525
|
? `border-color: ${this.props.currentColor}`
|
|
18530
18526
|
: "border-bottom-style: hidden";
|
|
18531
18527
|
}
|
|
18528
|
+
get colorPickerAnchorRect() {
|
|
18529
|
+
const button = this.colorPickerButtonRef.el;
|
|
18530
|
+
const buttonRect = button.getBoundingClientRect();
|
|
18531
|
+
return {
|
|
18532
|
+
x: buttonRect.x,
|
|
18533
|
+
y: buttonRect.y,
|
|
18534
|
+
width: buttonRect.width,
|
|
18535
|
+
height: buttonRect.height,
|
|
18536
|
+
};
|
|
18537
|
+
}
|
|
18532
18538
|
}
|
|
18533
18539
|
ColorPickerWidget.template = "o-spreadsheet-ColorPickerWidget";
|
|
18534
18540
|
ColorPickerWidget.components = { ColorPicker };
|
|
@@ -18538,7 +18544,6 @@ ColorPickerWidget.props = {
|
|
|
18538
18544
|
showColorPicker: Boolean,
|
|
18539
18545
|
onColorPicked: Function,
|
|
18540
18546
|
icon: String,
|
|
18541
|
-
dropdownDirection: { type: String, optional: true },
|
|
18542
18547
|
title: { type: String, optional: true },
|
|
18543
18548
|
disabled: { type: Boolean, optional: true },
|
|
18544
18549
|
dropdownMaxHeight: { type: Number, optional: true },
|
|
@@ -18618,7 +18623,6 @@ class GaugeChartConfigPanel extends Component {
|
|
|
18618
18623
|
GaugeChartConfigPanel.template = "o-spreadsheet-GaugeChartConfigPanel";
|
|
18619
18624
|
GaugeChartConfigPanel.components = { SelectionInput };
|
|
18620
18625
|
GaugeChartConfigPanel.props = {
|
|
18621
|
-
sheetId: String,
|
|
18622
18626
|
figureId: String,
|
|
18623
18627
|
definition: Object,
|
|
18624
18628
|
updateChart: Function,
|
|
@@ -18765,7 +18769,7 @@ GaugeChartDesignPanel.props = {
|
|
|
18765
18769
|
|
|
18766
18770
|
class LineConfigPanel extends LineBarPieConfigPanel {
|
|
18767
18771
|
get canTreatLabelsAsText() {
|
|
18768
|
-
const chart = this.env.model.getters.getChart(this.props.
|
|
18772
|
+
const chart = this.env.model.getters.getChart(this.props.figureId);
|
|
18769
18773
|
if (chart && chart instanceof LineChart) {
|
|
18770
18774
|
return canChartParseLabels(chart.labelRange, this.env.model.getters);
|
|
18771
18775
|
}
|
|
@@ -18842,7 +18846,6 @@ class ScorecardChartConfigPanel extends Component {
|
|
|
18842
18846
|
ScorecardChartConfigPanel.template = "o-spreadsheet-ScorecardChartConfigPanel";
|
|
18843
18847
|
ScorecardChartConfigPanel.components = { SelectionInput };
|
|
18844
18848
|
ScorecardChartConfigPanel.props = {
|
|
18845
|
-
sheetId: String,
|
|
18846
18849
|
figureId: String,
|
|
18847
18850
|
definition: Object,
|
|
18848
18851
|
updateChart: Function,
|
|
@@ -18978,7 +18981,7 @@ class ChartPanel extends Component {
|
|
|
18978
18981
|
else {
|
|
18979
18982
|
this.shouldUpdateChart = true;
|
|
18980
18983
|
}
|
|
18981
|
-
if (!this.env.model.getters.isChartDefined(this.
|
|
18984
|
+
if (!this.env.model.getters.isChartDefined(this.figureId)) {
|
|
18982
18985
|
this.props.onCloseSidePanel();
|
|
18983
18986
|
return;
|
|
18984
18987
|
}
|
|
@@ -18999,7 +19002,7 @@ class ChartPanel extends Component {
|
|
|
18999
19002
|
});
|
|
19000
19003
|
}
|
|
19001
19004
|
onTypeChange(type) {
|
|
19002
|
-
const context = this.env.model.getters.getContextCreationChart(this.
|
|
19005
|
+
const context = this.env.model.getters.getContextCreationChart(this.figureId);
|
|
19003
19006
|
if (!context) {
|
|
19004
19007
|
throw new Error("Chart not defined.");
|
|
19005
19008
|
}
|
|
@@ -19011,7 +19014,7 @@ class ChartPanel extends Component {
|
|
|
19011
19014
|
});
|
|
19012
19015
|
}
|
|
19013
19016
|
get chartPanel() {
|
|
19014
|
-
const type = this.env.model.getters.getChartType(this.
|
|
19017
|
+
const type = this.env.model.getters.getChartType(this.figureId);
|
|
19015
19018
|
if (!type) {
|
|
19016
19019
|
throw new Error("Chart not defined.");
|
|
19017
19020
|
}
|
|
@@ -19021,8 +19024,8 @@ class ChartPanel extends Component {
|
|
|
19021
19024
|
}
|
|
19022
19025
|
return chartPanel;
|
|
19023
19026
|
}
|
|
19024
|
-
getChartDefinition() {
|
|
19025
|
-
return this.env.model.getters.getChartDefinition(
|
|
19027
|
+
getChartDefinition(figureId = this.figureId) {
|
|
19028
|
+
return this.env.model.getters.getChartDefinition(figureId);
|
|
19026
19029
|
}
|
|
19027
19030
|
get chartTypes() {
|
|
19028
19031
|
return getChartTypes();
|
|
@@ -25894,13 +25897,7 @@ function load(data, verboseImport) {
|
|
|
25894
25897
|
data = migrate(data);
|
|
25895
25898
|
}
|
|
25896
25899
|
}
|
|
25897
|
-
|
|
25898
|
-
// sensible default values
|
|
25899
|
-
data = Object.assign(createEmptyWorkbookData(), data, { version: CURRENT_VERSION });
|
|
25900
|
-
data.sheets = data.sheets.map((s, i) => Object.assign(createEmptySheet(`Sheet${i + 1}`, `Sheet${i + 1}`), s));
|
|
25901
|
-
if (data.sheets.length === 0) {
|
|
25902
|
-
data.sheets.push(createEmptySheet(INITIAL_SHEET_ID, "Sheet1"));
|
|
25903
|
-
}
|
|
25900
|
+
data = repairData(data);
|
|
25904
25901
|
return data;
|
|
25905
25902
|
}
|
|
25906
25903
|
function migrate(data) {
|
|
@@ -26138,6 +26135,48 @@ const MIGRATIONS = [
|
|
|
26138
26135
|
},
|
|
26139
26136
|
},
|
|
26140
26137
|
];
|
|
26138
|
+
/**
|
|
26139
|
+
* This function is used to repair faulty data independently of the migration.
|
|
26140
|
+
*/
|
|
26141
|
+
function repairData(data) {
|
|
26142
|
+
data = forceUnicityOfFigure(data);
|
|
26143
|
+
data = setDefaults(data);
|
|
26144
|
+
return data;
|
|
26145
|
+
}
|
|
26146
|
+
/**
|
|
26147
|
+
* Force the unicity of figure ids accross sheets
|
|
26148
|
+
*/
|
|
26149
|
+
function forceUnicityOfFigure(data) {
|
|
26150
|
+
if (data.uniqueFigureIds) {
|
|
26151
|
+
return data;
|
|
26152
|
+
}
|
|
26153
|
+
const figureIds = new Set();
|
|
26154
|
+
const uuidGenerator = new UuidGenerator();
|
|
26155
|
+
for (const sheet of data.sheets || []) {
|
|
26156
|
+
for (const figure of sheet.figures || []) {
|
|
26157
|
+
if (figureIds.has(figure.id)) {
|
|
26158
|
+
figure.id += uuidGenerator.uuidv4();
|
|
26159
|
+
}
|
|
26160
|
+
figureIds.add(figure.id);
|
|
26161
|
+
}
|
|
26162
|
+
}
|
|
26163
|
+
data.uniqueFigureIds = true;
|
|
26164
|
+
return data;
|
|
26165
|
+
}
|
|
26166
|
+
/**
|
|
26167
|
+
* sanity check: try to fix missing fields/corrupted state by providing
|
|
26168
|
+
* sensible default values
|
|
26169
|
+
*/
|
|
26170
|
+
function setDefaults(data) {
|
|
26171
|
+
data = Object.assign(createEmptyWorkbookData(), data, { version: CURRENT_VERSION });
|
|
26172
|
+
data.sheets = data.sheets
|
|
26173
|
+
? data.sheets.map((s, i) => Object.assign(createEmptySheet(`Sheet${i + 1}`, `Sheet${i + 1}`), s))
|
|
26174
|
+
: [];
|
|
26175
|
+
if (data.sheets.length === 0) {
|
|
26176
|
+
data.sheets.push(createEmptySheet(INITIAL_SHEET_ID, "Sheet1"));
|
|
26177
|
+
}
|
|
26178
|
+
return data;
|
|
26179
|
+
}
|
|
26141
26180
|
/**
|
|
26142
26181
|
* The goal of this function is to repair corrupted/wrong initial messages caused by
|
|
26143
26182
|
* a bug.
|
|
@@ -26276,6 +26315,7 @@ function createEmptyWorkbookData(sheetName = "Sheet1") {
|
|
|
26276
26315
|
formats: {},
|
|
26277
26316
|
borders: {},
|
|
26278
26317
|
revisionId: DEFAULT_REVISION_ID,
|
|
26318
|
+
uniqueFigureIds: true,
|
|
26279
26319
|
};
|
|
26280
26320
|
return data;
|
|
26281
26321
|
}
|
|
@@ -28055,10 +28095,8 @@ class ChartPlugin extends CorePlugin {
|
|
|
28055
28095
|
this.validateChartDefinition = (cmd) => validateChartDefinition(this, cmd.definition);
|
|
28056
28096
|
}
|
|
28057
28097
|
adaptRanges(applyChange) {
|
|
28058
|
-
for (const
|
|
28059
|
-
|
|
28060
|
-
this.history.update("charts", sheetId, chartId, chart === null || chart === void 0 ? void 0 : chart.updateRanges(applyChange));
|
|
28061
|
-
}
|
|
28098
|
+
for (const [chartId, chart] of Object.entries(this.charts)) {
|
|
28099
|
+
this.history.update("charts", chartId, chart === null || chart === void 0 ? void 0 : chart.updateRanges(applyChange));
|
|
28062
28100
|
}
|
|
28063
28101
|
}
|
|
28064
28102
|
// ---------------------------------------------------------------------------
|
|
@@ -28069,20 +28107,20 @@ class ChartPlugin extends CorePlugin {
|
|
|
28069
28107
|
case "CREATE_CHART":
|
|
28070
28108
|
return this.checkValidations(cmd, this.chainValidations(this.validateChartDefinition, this.checkChartDuplicate));
|
|
28071
28109
|
case "UPDATE_CHART":
|
|
28072
|
-
return this.
|
|
28110
|
+
return this.checkValidations(cmd, this.chainValidations(this.validateChartDefinition, this.checkChartExists));
|
|
28073
28111
|
default:
|
|
28074
28112
|
return 0 /* CommandResult.Success */;
|
|
28075
28113
|
}
|
|
28076
28114
|
}
|
|
28077
28115
|
handle(cmd) {
|
|
28078
|
-
var _a
|
|
28116
|
+
var _a;
|
|
28079
28117
|
switch (cmd.type) {
|
|
28080
28118
|
case "CREATE_CHART":
|
|
28081
28119
|
this.addFigure(cmd.id, cmd.sheetId, cmd.position, cmd.size);
|
|
28082
|
-
this.addChart(cmd.id, cmd.
|
|
28120
|
+
this.addChart(cmd.id, cmd.definition);
|
|
28083
28121
|
break;
|
|
28084
28122
|
case "UPDATE_CHART": {
|
|
28085
|
-
this.addChart(cmd.id, cmd.
|
|
28123
|
+
this.addChart(cmd.id, cmd.definition);
|
|
28086
28124
|
break;
|
|
28087
28125
|
}
|
|
28088
28126
|
case "DUPLICATE_SHEET": {
|
|
@@ -28091,7 +28129,7 @@ class ChartPlugin extends CorePlugin {
|
|
|
28091
28129
|
if (fig.tag === "chart") {
|
|
28092
28130
|
const figureIdBase = fig.id.split(FIGURE_ID_SPLITTER).pop();
|
|
28093
28131
|
const duplicatedFigureId = `${cmd.sheetIdTo}${FIGURE_ID_SPLITTER}${figureIdBase}`;
|
|
28094
|
-
const chart = (
|
|
28132
|
+
const chart = (_a = this.charts[fig.id]) === null || _a === void 0 ? void 0 : _a.copyForSheetId(cmd.sheetIdTo);
|
|
28095
28133
|
if (chart) {
|
|
28096
28134
|
this.dispatch("CREATE_CHART", {
|
|
28097
28135
|
id: duplicatedFigureId,
|
|
@@ -28106,41 +28144,44 @@ class ChartPlugin extends CorePlugin {
|
|
|
28106
28144
|
break;
|
|
28107
28145
|
}
|
|
28108
28146
|
case "DELETE_FIGURE":
|
|
28109
|
-
this.history.update("charts", cmd.
|
|
28147
|
+
this.history.update("charts", cmd.id, undefined);
|
|
28110
28148
|
break;
|
|
28111
28149
|
case "DELETE_SHEET":
|
|
28112
|
-
this.
|
|
28150
|
+
for (let id of this.getChartIds(cmd.sheetId)) {
|
|
28151
|
+
this.history.update("charts", id, undefined);
|
|
28152
|
+
}
|
|
28113
28153
|
break;
|
|
28114
28154
|
}
|
|
28115
28155
|
}
|
|
28116
28156
|
// ---------------------------------------------------------------------------
|
|
28117
28157
|
// Getters
|
|
28118
28158
|
// ---------------------------------------------------------------------------
|
|
28119
|
-
getContextCreationChart(
|
|
28120
|
-
var _a, _b;
|
|
28121
|
-
return (_b = (_a = this.charts[sheetId]) === null || _a === void 0 ? void 0 : _a[figureId]) === null || _b === void 0 ? void 0 : _b.getContextCreation();
|
|
28122
|
-
}
|
|
28123
|
-
getChart(sheetId, figureId) {
|
|
28159
|
+
getContextCreationChart(figureId) {
|
|
28124
28160
|
var _a;
|
|
28125
|
-
return (_a = this.charts[
|
|
28161
|
+
return (_a = this.charts[figureId]) === null || _a === void 0 ? void 0 : _a.getContextCreation();
|
|
28126
28162
|
}
|
|
28127
|
-
|
|
28128
|
-
|
|
28129
|
-
|
|
28163
|
+
getChart(figureId) {
|
|
28164
|
+
return this.charts[figureId];
|
|
28165
|
+
}
|
|
28166
|
+
getChartType(figureId) {
|
|
28167
|
+
var _a;
|
|
28168
|
+
const type = (_a = this.charts[figureId]) === null || _a === void 0 ? void 0 : _a.type;
|
|
28130
28169
|
if (!type) {
|
|
28131
28170
|
throw new Error("Chart not defined.");
|
|
28132
28171
|
}
|
|
28133
28172
|
return type;
|
|
28134
28173
|
}
|
|
28135
|
-
isChartDefined(
|
|
28136
|
-
return figureId in
|
|
28174
|
+
isChartDefined(figureId) {
|
|
28175
|
+
return figureId in this.charts && this.charts !== undefined;
|
|
28137
28176
|
}
|
|
28138
28177
|
getChartIds(sheetId) {
|
|
28139
|
-
return Object.
|
|
28178
|
+
return Object.entries(this.charts)
|
|
28179
|
+
.filter(([, chart]) => (chart === null || chart === void 0 ? void 0 : chart.sheetId) === sheetId)
|
|
28180
|
+
.map(([id]) => id);
|
|
28140
28181
|
}
|
|
28141
|
-
getChartDefinition(
|
|
28142
|
-
var _a
|
|
28143
|
-
const definition = (
|
|
28182
|
+
getChartDefinition(figureId) {
|
|
28183
|
+
var _a;
|
|
28184
|
+
const definition = (_a = this.charts[figureId]) === null || _a === void 0 ? void 0 : _a.getDefinition();
|
|
28144
28185
|
if (!definition) {
|
|
28145
28186
|
throw new Error(`There is no chart with the given figureId: ${figureId}`);
|
|
28146
28187
|
}
|
|
@@ -28152,28 +28193,35 @@ class ChartPlugin extends CorePlugin {
|
|
|
28152
28193
|
import(data) {
|
|
28153
28194
|
for (let sheet of data.sheets) {
|
|
28154
28195
|
if (sheet.figures) {
|
|
28155
|
-
const charts = {};
|
|
28156
28196
|
for (let figure of sheet.figures) {
|
|
28157
28197
|
// TODO:
|
|
28158
28198
|
// figure data should be external IMO => chart should be in sheet.chart
|
|
28159
28199
|
// instead of in figure.data
|
|
28160
28200
|
if (figure.tag === "chart") {
|
|
28161
|
-
charts[figure.id] = this.createChart(figure.id, figure.data, sheet.id);
|
|
28201
|
+
this.charts[figure.id] = this.createChart(figure.id, figure.data, sheet.id);
|
|
28162
28202
|
}
|
|
28163
28203
|
}
|
|
28164
|
-
this.charts[sheet.id] = charts;
|
|
28165
28204
|
}
|
|
28166
28205
|
}
|
|
28167
28206
|
}
|
|
28168
28207
|
export(data) {
|
|
28208
|
+
var _a;
|
|
28169
28209
|
if (data.sheets) {
|
|
28170
28210
|
for (let sheet of data.sheets) {
|
|
28171
28211
|
// TODO This code is false, if two plugins want ot insert figures on the sheet, it will crash !
|
|
28172
28212
|
const sheetFigures = this.getters.getFigures(sheet.id);
|
|
28173
|
-
const figures =
|
|
28174
|
-
for (let
|
|
28213
|
+
const figures = [];
|
|
28214
|
+
for (let sheetFigure of sheetFigures) {
|
|
28215
|
+
const figure = sheetFigure;
|
|
28175
28216
|
if (figure && figure.tag === "chart") {
|
|
28176
|
-
|
|
28217
|
+
const data = (_a = this.charts[figure.id]) === null || _a === void 0 ? void 0 : _a.getDefinition();
|
|
28218
|
+
if (data) {
|
|
28219
|
+
figure.data = data;
|
|
28220
|
+
figures.push(figure);
|
|
28221
|
+
}
|
|
28222
|
+
}
|
|
28223
|
+
else {
|
|
28224
|
+
figures.push(figure);
|
|
28177
28225
|
}
|
|
28178
28226
|
}
|
|
28179
28227
|
sheet.figures = figures;
|
|
@@ -28181,13 +28229,13 @@ class ChartPlugin extends CorePlugin {
|
|
|
28181
28229
|
}
|
|
28182
28230
|
}
|
|
28183
28231
|
exportForExcel(data) {
|
|
28184
|
-
var _a
|
|
28232
|
+
var _a;
|
|
28185
28233
|
for (let sheet of data.sheets) {
|
|
28186
28234
|
const sheetFigures = this.getters.getFigures(sheet.id);
|
|
28187
28235
|
const figures = [];
|
|
28188
28236
|
for (let figure of sheetFigures) {
|
|
28189
28237
|
if (figure && figure.tag === "chart") {
|
|
28190
|
-
const figureData = (
|
|
28238
|
+
const figureData = (_a = this.charts[figure.id]) === null || _a === void 0 ? void 0 : _a.getDefinitionForExcel();
|
|
28191
28239
|
if (figureData) {
|
|
28192
28240
|
figures.push({
|
|
28193
28241
|
...figure,
|
|
@@ -28226,15 +28274,21 @@ class ChartPlugin extends CorePlugin {
|
|
|
28226
28274
|
* Add a chart in the local state. If a chart already exists, this chart is
|
|
28227
28275
|
* replaced
|
|
28228
28276
|
*/
|
|
28229
|
-
addChart(id,
|
|
28230
|
-
|
|
28277
|
+
addChart(id, definition) {
|
|
28278
|
+
const sheetId = this.getters.getFigureSheetId(id);
|
|
28279
|
+
if (sheetId) {
|
|
28280
|
+
this.history.update("charts", id, this.createChart(id, definition, sheetId));
|
|
28281
|
+
}
|
|
28231
28282
|
}
|
|
28232
28283
|
checkChartDuplicate(cmd) {
|
|
28233
|
-
|
|
28234
|
-
|
|
28235
|
-
|
|
28236
|
-
|
|
28237
|
-
|
|
28284
|
+
return this.getters.getFigureSheetId(cmd.id)
|
|
28285
|
+
? 84 /* CommandResult.DuplicatedChartId */
|
|
28286
|
+
: 0 /* CommandResult.Success */;
|
|
28287
|
+
}
|
|
28288
|
+
checkChartExists(cmd) {
|
|
28289
|
+
return this.getters.getFigureSheetId(cmd.id)
|
|
28290
|
+
? 0 /* CommandResult.Success */
|
|
28291
|
+
: 85 /* CommandResult.ChartDoesNotExist */;
|
|
28238
28292
|
}
|
|
28239
28293
|
}
|
|
28240
28294
|
ChartPlugin.getters = [
|
|
@@ -28615,7 +28669,7 @@ class FigurePlugin extends CorePlugin {
|
|
|
28615
28669
|
allowDispatch(cmd) {
|
|
28616
28670
|
switch (cmd.type) {
|
|
28617
28671
|
case "CREATE_FIGURE":
|
|
28618
|
-
return this.checkFigureDuplicate(cmd.
|
|
28672
|
+
return this.checkFigureDuplicate(cmd.figure.id);
|
|
28619
28673
|
case "UPDATE_FIGURE":
|
|
28620
28674
|
case "DELETE_FIGURE":
|
|
28621
28675
|
return this.checkFigureExists(cmd.sheetId, cmd.id);
|
|
@@ -28681,9 +28735,8 @@ class FigurePlugin extends CorePlugin {
|
|
|
28681
28735
|
}
|
|
28682
28736
|
return 0 /* CommandResult.Success */;
|
|
28683
28737
|
}
|
|
28684
|
-
checkFigureDuplicate(
|
|
28685
|
-
|
|
28686
|
-
if ((_a = this.figures[sheetId]) === null || _a === void 0 ? void 0 : _a[figureId]) {
|
|
28738
|
+
checkFigureDuplicate(figureId) {
|
|
28739
|
+
if (Object.values(this.figures).find((sheet) => sheet === null || sheet === void 0 ? void 0 : sheet[figureId])) {
|
|
28687
28740
|
return 82 /* CommandResult.DuplicatedFigureId */;
|
|
28688
28741
|
}
|
|
28689
28742
|
return 0 /* CommandResult.Success */;
|
|
@@ -28698,6 +28751,9 @@ class FigurePlugin extends CorePlugin {
|
|
|
28698
28751
|
var _a;
|
|
28699
28752
|
return (_a = this.figures[sheetId]) === null || _a === void 0 ? void 0 : _a[figureId];
|
|
28700
28753
|
}
|
|
28754
|
+
getFigureSheetId(figureId) {
|
|
28755
|
+
return Object.keys(this.figures).find((sheetId) => { var _a; return ((_a = this.figures[sheetId]) === null || _a === void 0 ? void 0 : _a[figureId]) !== undefined; });
|
|
28756
|
+
}
|
|
28701
28757
|
// ---------------------------------------------------------------------------
|
|
28702
28758
|
// Import/Export
|
|
28703
28759
|
// ---------------------------------------------------------------------------
|
|
@@ -28722,7 +28778,7 @@ class FigurePlugin extends CorePlugin {
|
|
|
28722
28778
|
this.export(data);
|
|
28723
28779
|
}
|
|
28724
28780
|
}
|
|
28725
|
-
FigurePlugin.getters = ["getFigures", "getFigure"];
|
|
28781
|
+
FigurePlugin.getters = ["getFigures", "getFigure", "getFigureSheetId"];
|
|
28726
28782
|
|
|
28727
28783
|
class FilterTable {
|
|
28728
28784
|
constructor(zone) {
|
|
@@ -29449,7 +29505,7 @@ class ImagePlugin extends CorePlugin {
|
|
|
29449
29505
|
switch (cmd.type) {
|
|
29450
29506
|
case "CREATE_IMAGE":
|
|
29451
29507
|
if (this.getters.getFigure(cmd.sheetId, cmd.figureId)) {
|
|
29452
|
-
return 28 /* CommandResult.
|
|
29508
|
+
return 28 /* CommandResult.InvalidFigureId */;
|
|
29453
29509
|
}
|
|
29454
29510
|
return 0 /* CommandResult.Success */;
|
|
29455
29511
|
default:
|
|
@@ -29469,7 +29525,7 @@ class ImagePlugin extends CorePlugin {
|
|
|
29469
29525
|
if (fig.tag === "image") {
|
|
29470
29526
|
const figureIdBase = fig.id.split(FIGURE_ID_SPLITTER).pop();
|
|
29471
29527
|
const duplicatedFigureId = `${cmd.sheetIdTo}${FIGURE_ID_SPLITTER}${figureIdBase}`;
|
|
29472
|
-
const image = this.getImage(
|
|
29528
|
+
const image = this.getImage(fig.id);
|
|
29473
29529
|
if (image) {
|
|
29474
29530
|
const size = { width: fig.width, height: fig.height };
|
|
29475
29531
|
this.dispatch("CREATE_IMAGE", {
|
|
@@ -29507,13 +29563,19 @@ class ImagePlugin extends CorePlugin {
|
|
|
29507
29563
|
// ---------------------------------------------------------------------------
|
|
29508
29564
|
// Getters
|
|
29509
29565
|
// ---------------------------------------------------------------------------
|
|
29510
|
-
getImage(
|
|
29511
|
-
|
|
29512
|
-
|
|
29513
|
-
|
|
29514
|
-
|
|
29566
|
+
getImage(figureId) {
|
|
29567
|
+
for (const sheet of Object.values(this.images)) {
|
|
29568
|
+
if (sheet && sheet[figureId]) {
|
|
29569
|
+
return sheet[figureId];
|
|
29570
|
+
}
|
|
29515
29571
|
}
|
|
29516
|
-
|
|
29572
|
+
throw new Error(`There is no image with the given figureId: ${figureId}`);
|
|
29573
|
+
}
|
|
29574
|
+
getImagePath(figureId) {
|
|
29575
|
+
return this.getImage(figureId).path;
|
|
29576
|
+
}
|
|
29577
|
+
getImageSize(figureId) {
|
|
29578
|
+
return this.getImage(figureId).size;
|
|
29517
29579
|
}
|
|
29518
29580
|
// ---------------------------------------------------------------------------
|
|
29519
29581
|
// Private
|
|
@@ -29555,7 +29617,7 @@ class ImagePlugin extends CorePlugin {
|
|
|
29555
29617
|
return images;
|
|
29556
29618
|
}
|
|
29557
29619
|
}
|
|
29558
|
-
ImagePlugin.getters = ["getImage"];
|
|
29620
|
+
ImagePlugin.getters = ["getImage", "getImagePath", "getImageSize"];
|
|
29559
29621
|
|
|
29560
29622
|
class MergePlugin extends CorePlugin {
|
|
29561
29623
|
constructor() {
|
|
@@ -31361,9 +31423,7 @@ class CustomColorsPlugin extends UIPlugin {
|
|
|
31361
31423
|
return formatColors.filter(isDefined$1);
|
|
31362
31424
|
}
|
|
31363
31425
|
getChartColors(sheetId) {
|
|
31364
|
-
const charts = this.getters
|
|
31365
|
-
.getChartIds(sheetId)
|
|
31366
|
-
.map((cid) => this.getters.getChart(sheetId, cid));
|
|
31426
|
+
const charts = this.getters.getChartIds(sheetId).map((cid) => this.getters.getChart(cid));
|
|
31367
31427
|
let chartsColors = new Set();
|
|
31368
31428
|
for (let chart of charts) {
|
|
31369
31429
|
if (chart === undefined) {
|
|
@@ -31729,37 +31789,34 @@ class EvaluationChartPlugin extends UIPlugin {
|
|
|
31729
31789
|
invalidateCFEvaluationCommands.has(cmd.type) ||
|
|
31730
31790
|
cmd.type === "EVALUATE_CELLS" ||
|
|
31731
31791
|
cmd.type === "UPDATE_CELL") {
|
|
31732
|
-
for (const
|
|
31733
|
-
|
|
31734
|
-
this.charts[sheetId][chartId] = undefined;
|
|
31735
|
-
}
|
|
31792
|
+
for (const chartId in this.charts) {
|
|
31793
|
+
this.charts[chartId] = undefined;
|
|
31736
31794
|
}
|
|
31737
31795
|
}
|
|
31738
31796
|
switch (cmd.type) {
|
|
31739
31797
|
case "UPDATE_CHART":
|
|
31740
31798
|
case "CREATE_CHART":
|
|
31741
31799
|
case "DELETE_FIGURE":
|
|
31742
|
-
|
|
31743
|
-
this.charts[cmd.sheetId][cmd.id] = undefined;
|
|
31744
|
-
}
|
|
31800
|
+
this.charts[cmd.id] = undefined;
|
|
31745
31801
|
break;
|
|
31746
31802
|
case "DELETE_SHEET":
|
|
31747
|
-
|
|
31803
|
+
for (let chartId in this.charts) {
|
|
31804
|
+
if (!this.getters.isChartDefined(chartId)) {
|
|
31805
|
+
this.charts[chartId] = undefined;
|
|
31806
|
+
}
|
|
31807
|
+
}
|
|
31748
31808
|
break;
|
|
31749
31809
|
}
|
|
31750
31810
|
}
|
|
31751
|
-
getChartRuntime(
|
|
31752
|
-
|
|
31753
|
-
|
|
31754
|
-
const chart = this.getters.getChart(sheetId, figureId);
|
|
31811
|
+
getChartRuntime(figureId) {
|
|
31812
|
+
if (!this.charts[figureId]) {
|
|
31813
|
+
const chart = this.getters.getChart(figureId);
|
|
31755
31814
|
if (!chart) {
|
|
31756
31815
|
throw new Error(`No chart for the given id: ${figureId}`);
|
|
31757
31816
|
}
|
|
31758
|
-
|
|
31759
|
-
this.charts[sheetId] = {};
|
|
31760
|
-
this.charts[sheetId][figureId] = this.createRuntimeChart(chart);
|
|
31817
|
+
this.charts[figureId] = this.createRuntimeChart(chart);
|
|
31761
31818
|
}
|
|
31762
|
-
return this.charts[
|
|
31819
|
+
return this.charts[figureId];
|
|
31763
31820
|
}
|
|
31764
31821
|
/**
|
|
31765
31822
|
* Get the background color of a chart based on the color of the first cell of the main range
|
|
@@ -35244,8 +35301,8 @@ class SelectionInputPlugin extends UIPlugin {
|
|
|
35244
35301
|
const currentMaxId = Math.max(0, ...this.ranges.map((range) => Number(range.id)));
|
|
35245
35302
|
this.ranges.splice(index, 0, ...values.map((xc, i) => ({
|
|
35246
35303
|
xc,
|
|
35247
|
-
id:
|
|
35248
|
-
color: colors$1[(currentMaxId +
|
|
35304
|
+
id: currentMaxId + i + 1,
|
|
35305
|
+
color: colors$1[(currentMaxId + i) % colors$1.length],
|
|
35249
35306
|
})));
|
|
35250
35307
|
}
|
|
35251
35308
|
/**
|
|
@@ -37411,7 +37468,7 @@ class ClipboardFigureChart {
|
|
|
37411
37468
|
constructor(dispatch, getters, sheetId, copiedFigureId) {
|
|
37412
37469
|
this.dispatch = dispatch;
|
|
37413
37470
|
this.sheetId = sheetId;
|
|
37414
|
-
const chart = getters.getChart(
|
|
37471
|
+
const chart = getters.getChart(copiedFigureId);
|
|
37415
37472
|
if (!chart) {
|
|
37416
37473
|
throw new Error(`No chart for the given id: ${copiedFigureId}`);
|
|
37417
37474
|
}
|
|
@@ -37432,7 +37489,7 @@ class ClipboardFigureImage {
|
|
|
37432
37489
|
constructor(dispatch, getters, sheetId, copiedFigureId) {
|
|
37433
37490
|
this.dispatch = dispatch;
|
|
37434
37491
|
this.sheetId = sheetId;
|
|
37435
|
-
const image = getters.getImage(
|
|
37492
|
+
const image = getters.getImage(copiedFigureId);
|
|
37436
37493
|
this.copiedImage = deepCopy(image);
|
|
37437
37494
|
}
|
|
37438
37495
|
paste(sheetId, figureId, position, size) {
|
|
@@ -44814,6 +44871,6 @@ function addFunction(functionName, functionDescription) {
|
|
|
44814
44871
|
export { AbstractChart, CommandResult, CorePlugin, DATETIME_FORMAT, DispatchResult, EvaluationError, Model, Registry, Revision, SPREADSHEET_DIMENSIONS, Spreadsheet, UIPlugin, __info__, addFunction, astToFormula, compile, components, convertAstNodes, coreTypes, findCellInNewZone, functionCache, helpers, invalidateEvaluationCommands, links, load, parse, readonlyAllowedCommands, registries, setTranslationMethod, tokenize };
|
|
44815
44872
|
|
|
44816
44873
|
|
|
44817
|
-
__info__.version = '16.2.0-alpha.
|
|
44818
|
-
__info__.date = '2023-03-
|
|
44819
|
-
__info__.hash = '
|
|
44874
|
+
__info__.version = '16.2.0-alpha.3';
|
|
44875
|
+
__info__.date = '2023-03-06T07:18:09.258Z';
|
|
44876
|
+
__info__.hash = 'ec749cf';
|