@odoo/o-spreadsheet 16.3.1 → 16.3.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 +78 -55
- package/dist/o-spreadsheet.d.ts +9 -10
- package/dist/o-spreadsheet.esm.js +78 -55
- package/dist/o-spreadsheet.iife.js +78 -55
- package/dist/o-spreadsheet.iife.min.js +255 -251
- package/package.json +1 -1
- package/readme.md +8 -7
|
@@ -1774,6 +1774,7 @@
|
|
|
1774
1774
|
}
|
|
1775
1775
|
return numberString.slice(0, i + 1) || undefined;
|
|
1776
1776
|
}
|
|
1777
|
+
const leadingZeroesRegexp = /^0+/;
|
|
1777
1778
|
/**
|
|
1778
1779
|
* Limit the size of the decimal part of a number to the given number of digits.
|
|
1779
1780
|
*/
|
|
@@ -1784,17 +1785,24 @@
|
|
|
1784
1785
|
// but it has very strange behaviour. Ex: 12.345.toFixed(2) => "12.35", but 1.345.toFixed(2) => "1.34"
|
|
1785
1786
|
let slicedDecimalDigits = decimalDigits.slice(0, maxDecimals);
|
|
1786
1787
|
const i = maxDecimals;
|
|
1787
|
-
if (Number(
|
|
1788
|
+
if (Number(decimalDigits[i]) < 5) {
|
|
1788
1789
|
return { integerDigits, decimalDigits: slicedDecimalDigits };
|
|
1789
1790
|
}
|
|
1790
1791
|
// round up
|
|
1792
|
+
const leadingZeroes = slicedDecimalDigits.match(leadingZeroesRegexp)?.[0] || "";
|
|
1791
1793
|
const slicedRoundedUp = (Number(slicedDecimalDigits) + 1).toString();
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
+
const withoutLeadingZeroes = slicedDecimalDigits.slice(leadingZeroes.length);
|
|
1795
|
+
// e.g. carry over from 99 to 100
|
|
1796
|
+
const carryOver = slicedRoundedUp.length > withoutLeadingZeroes.length;
|
|
1797
|
+
if (carryOver && !leadingZeroes) {
|
|
1798
|
+
integerDigits = "1";
|
|
1794
1799
|
resultDecimalDigits = undefined;
|
|
1795
1800
|
}
|
|
1801
|
+
else if (carryOver) {
|
|
1802
|
+
resultDecimalDigits = leadingZeroes.slice(0, -1) + slicedRoundedUp;
|
|
1803
|
+
}
|
|
1796
1804
|
else {
|
|
1797
|
-
resultDecimalDigits = slicedRoundedUp;
|
|
1805
|
+
resultDecimalDigits = leadingZeroes + slicedRoundedUp;
|
|
1798
1806
|
}
|
|
1799
1807
|
return { integerDigits, decimalDigits: resultDecimalDigits };
|
|
1800
1808
|
}
|
|
@@ -17841,7 +17849,7 @@
|
|
|
17841
17849
|
return !!this.state.labelsDispatchResult?.isCancelledBecause(33 /* CommandResult.InvalidLabelRange */);
|
|
17842
17850
|
}
|
|
17843
17851
|
onUpdateDataSetsHaveTitle(ev) {
|
|
17844
|
-
this.props.updateChart({
|
|
17852
|
+
this.props.updateChart(this.props.figureId, {
|
|
17845
17853
|
dataSetsHaveTitle: ev.target.checked,
|
|
17846
17854
|
});
|
|
17847
17855
|
}
|
|
@@ -17853,7 +17861,7 @@
|
|
|
17853
17861
|
this.dataSeriesRanges = ranges;
|
|
17854
17862
|
}
|
|
17855
17863
|
onDataSeriesConfirmed() {
|
|
17856
|
-
this.state.datasetDispatchResult = this.props.updateChart({
|
|
17864
|
+
this.state.datasetDispatchResult = this.props.updateChart(this.props.figureId, {
|
|
17857
17865
|
dataSets: this.dataSeriesRanges,
|
|
17858
17866
|
});
|
|
17859
17867
|
}
|
|
@@ -17865,12 +17873,12 @@
|
|
|
17865
17873
|
this.labelRange = ranges[0];
|
|
17866
17874
|
}
|
|
17867
17875
|
onLabelRangeConfirmed() {
|
|
17868
|
-
this.state.labelsDispatchResult = this.props.updateChart({
|
|
17876
|
+
this.state.labelsDispatchResult = this.props.updateChart(this.props.figureId, {
|
|
17869
17877
|
labelRange: this.labelRange,
|
|
17870
17878
|
});
|
|
17871
17879
|
}
|
|
17872
17880
|
onUpdateAggregated(ev) {
|
|
17873
|
-
this.props.updateChart({
|
|
17881
|
+
this.props.updateChart(this.props.figureId, {
|
|
17874
17882
|
aggregated: ev.target.checked,
|
|
17875
17883
|
});
|
|
17876
17884
|
}
|
|
@@ -17900,12 +17908,12 @@
|
|
|
17900
17908
|
class BarConfigPanel extends LineBarPieConfigPanel {
|
|
17901
17909
|
static template = "o-spreadsheet-BarConfigPanel";
|
|
17902
17910
|
onUpdateStacked(ev) {
|
|
17903
|
-
this.props.updateChart({
|
|
17911
|
+
this.props.updateChart(this.props.figureId, {
|
|
17904
17912
|
stacked: ev.target.checked,
|
|
17905
17913
|
});
|
|
17906
17914
|
}
|
|
17907
17915
|
onUpdateAggregated(ev) {
|
|
17908
|
-
this.props.updateChart({
|
|
17916
|
+
this.props.updateChart(this.props.figureId, {
|
|
17909
17917
|
aggregated: ev.target.checked,
|
|
17910
17918
|
});
|
|
17911
17919
|
}
|
|
@@ -17945,6 +17953,7 @@
|
|
|
17945
17953
|
.o-color-picker-toggler-button {
|
|
17946
17954
|
display: flex;
|
|
17947
17955
|
.o-color-picker-toggler-sign {
|
|
17956
|
+
display: flex;
|
|
17948
17957
|
margin: auto auto;
|
|
17949
17958
|
width: 55%;
|
|
17950
17959
|
height: 55%;
|
|
@@ -18242,17 +18251,17 @@
|
|
|
18242
18251
|
this.state.fillColorTool = !this.state.fillColorTool;
|
|
18243
18252
|
}
|
|
18244
18253
|
updateBackgroundColor(color) {
|
|
18245
|
-
this.props.updateChart({
|
|
18254
|
+
this.props.updateChart(this.props.figureId, {
|
|
18246
18255
|
background: color,
|
|
18247
18256
|
});
|
|
18248
18257
|
}
|
|
18249
18258
|
updateTitle(ev) {
|
|
18250
|
-
this.props.updateChart({
|
|
18259
|
+
this.props.updateChart(this.props.figureId, {
|
|
18251
18260
|
title: ev.target.value,
|
|
18252
18261
|
});
|
|
18253
18262
|
}
|
|
18254
18263
|
updateSelect(attr, ev) {
|
|
18255
|
-
this.props.updateChart({
|
|
18264
|
+
this.props.updateChart(this.props.figureId, {
|
|
18256
18265
|
[attr]: ev.target.value,
|
|
18257
18266
|
});
|
|
18258
18267
|
}
|
|
@@ -18285,7 +18294,7 @@
|
|
|
18285
18294
|
this.dataRange = ranges[0];
|
|
18286
18295
|
}
|
|
18287
18296
|
updateDataRange() {
|
|
18288
|
-
this.state.dataRangeDispatchResult = this.props.updateChart({
|
|
18297
|
+
this.state.dataRangeDispatchResult = this.props.updateChart(this.props.figureId, {
|
|
18289
18298
|
dataRange: this.dataRange,
|
|
18290
18299
|
});
|
|
18291
18300
|
}
|
|
@@ -18343,12 +18352,12 @@
|
|
|
18343
18352
|
}
|
|
18344
18353
|
updateBackgroundColor(color) {
|
|
18345
18354
|
this.state.openedMenu = undefined;
|
|
18346
|
-
this.props.updateChart({
|
|
18355
|
+
this.props.updateChart(this.props.figureId, {
|
|
18347
18356
|
background: color,
|
|
18348
18357
|
});
|
|
18349
18358
|
}
|
|
18350
18359
|
updateTitle(ev) {
|
|
18351
|
-
this.props.updateChart({
|
|
18360
|
+
this.props.updateChart(this.props.figureId, {
|
|
18352
18361
|
title: ev.target.value,
|
|
18353
18362
|
});
|
|
18354
18363
|
}
|
|
@@ -18413,7 +18422,7 @@
|
|
|
18413
18422
|
}
|
|
18414
18423
|
}
|
|
18415
18424
|
updateSectionRule(sectionRule) {
|
|
18416
|
-
this.state.sectionRuleDispatchResult = this.props.updateChart({
|
|
18425
|
+
this.state.sectionRuleDispatchResult = this.props.updateChart(this.props.figureId, {
|
|
18417
18426
|
sectionRule,
|
|
18418
18427
|
});
|
|
18419
18428
|
}
|
|
@@ -18437,17 +18446,17 @@
|
|
|
18437
18446
|
return false;
|
|
18438
18447
|
}
|
|
18439
18448
|
onUpdateLabelsAsText(ev) {
|
|
18440
|
-
this.props.updateChart({
|
|
18449
|
+
this.props.updateChart(this.props.figureId, {
|
|
18441
18450
|
labelsAsText: ev.target.checked,
|
|
18442
18451
|
});
|
|
18443
18452
|
}
|
|
18444
18453
|
onUpdateStacked(ev) {
|
|
18445
|
-
this.props.updateChart({
|
|
18454
|
+
this.props.updateChart(this.props.figureId, {
|
|
18446
18455
|
stacked: ev.target.checked,
|
|
18447
18456
|
});
|
|
18448
18457
|
}
|
|
18449
18458
|
onUpdateAggregated(ev) {
|
|
18450
|
-
this.props.updateChart({
|
|
18459
|
+
this.props.updateChart(this.props.figureId, {
|
|
18451
18460
|
aggregated: ev.target.checked,
|
|
18452
18461
|
});
|
|
18453
18462
|
}
|
|
@@ -18483,7 +18492,7 @@
|
|
|
18483
18492
|
this.keyValue = ranges[0];
|
|
18484
18493
|
}
|
|
18485
18494
|
updateKeyValueRange() {
|
|
18486
|
-
this.state.keyValueDispatchResult = this.props.updateChart({
|
|
18495
|
+
this.state.keyValueDispatchResult = this.props.updateChart(this.props.figureId, {
|
|
18487
18496
|
keyValue: this.keyValue,
|
|
18488
18497
|
});
|
|
18489
18498
|
}
|
|
@@ -18491,12 +18500,12 @@
|
|
|
18491
18500
|
this.baseline = ranges[0];
|
|
18492
18501
|
}
|
|
18493
18502
|
updateBaselineRange() {
|
|
18494
|
-
this.state.baselineDispatchResult = this.props.updateChart({
|
|
18503
|
+
this.state.baselineDispatchResult = this.props.updateChart(this.props.figureId, {
|
|
18495
18504
|
baseline: this.baseline,
|
|
18496
18505
|
});
|
|
18497
18506
|
}
|
|
18498
18507
|
updateBaselineMode(ev) {
|
|
18499
|
-
this.props.updateChart({ baselineMode: ev.target.value });
|
|
18508
|
+
this.props.updateChart(this.props.figureId, { baselineMode: ev.target.value });
|
|
18500
18509
|
}
|
|
18501
18510
|
}
|
|
18502
18511
|
ScorecardChartConfigPanel.props = {
|
|
@@ -18515,12 +18524,12 @@
|
|
|
18515
18524
|
owl.useExternalListener(window, "click", this.closeMenus);
|
|
18516
18525
|
}
|
|
18517
18526
|
updateTitle(ev) {
|
|
18518
|
-
this.props.updateChart({
|
|
18527
|
+
this.props.updateChart(this.props.figureId, {
|
|
18519
18528
|
title: ev.target.value,
|
|
18520
18529
|
});
|
|
18521
18530
|
}
|
|
18522
18531
|
updateBaselineDescr(ev) {
|
|
18523
|
-
this.props.updateChart({ baselineDescr: ev.target.value });
|
|
18532
|
+
this.props.updateChart(this.props.figureId, { baselineDescr: ev.target.value });
|
|
18524
18533
|
}
|
|
18525
18534
|
toggleColorPicker(colorPickerId) {
|
|
18526
18535
|
if (this.state.openedColorPicker === colorPickerId) {
|
|
@@ -18533,13 +18542,13 @@
|
|
|
18533
18542
|
setColor(color, colorPickerId) {
|
|
18534
18543
|
switch (colorPickerId) {
|
|
18535
18544
|
case "backgroundColor":
|
|
18536
|
-
this.props.updateChart({ background: color });
|
|
18545
|
+
this.props.updateChart(this.props.figureId, { background: color });
|
|
18537
18546
|
break;
|
|
18538
18547
|
case "baselineColorDown":
|
|
18539
|
-
this.props.updateChart({ baselineColorDown: color });
|
|
18548
|
+
this.props.updateChart(this.props.figureId, { baselineColorDown: color });
|
|
18540
18549
|
break;
|
|
18541
18550
|
case "baselineColorUp":
|
|
18542
|
-
this.props.updateChart({ baselineColorUp: color });
|
|
18551
|
+
this.props.updateChart(this.props.figureId, { baselineColorUp: color });
|
|
18543
18552
|
break;
|
|
18544
18553
|
}
|
|
18545
18554
|
this.closeMenus();
|
|
@@ -18604,13 +18613,9 @@
|
|
|
18604
18613
|
class ChartPanel extends owl.Component {
|
|
18605
18614
|
static template = "o-spreadsheet-ChartPanel";
|
|
18606
18615
|
state;
|
|
18607
|
-
shouldUpdateChart = true;
|
|
18608
18616
|
get figureId() {
|
|
18609
18617
|
return this.state.figureId;
|
|
18610
18618
|
}
|
|
18611
|
-
get sheetId() {
|
|
18612
|
-
return this.state.sheetId;
|
|
18613
|
-
}
|
|
18614
18619
|
setup() {
|
|
18615
18620
|
const selectedFigureId = this.env.model.getters.getSelectedFigureId();
|
|
18616
18621
|
if (!selectedFigureId) {
|
|
@@ -18620,17 +18625,11 @@
|
|
|
18620
18625
|
this.state = owl.useState({
|
|
18621
18626
|
panel: "configuration",
|
|
18622
18627
|
figureId: selectedFigureId,
|
|
18623
|
-
sheetId: this.env.model.getters.getActiveSheetId(),
|
|
18624
18628
|
});
|
|
18625
18629
|
owl.onWillUpdateProps(() => {
|
|
18626
18630
|
const selectedFigureId = this.env.model.getters.getSelectedFigureId();
|
|
18627
18631
|
if (selectedFigureId && selectedFigureId !== this.state.figureId) {
|
|
18628
18632
|
this.state.figureId = selectedFigureId;
|
|
18629
|
-
this.state.sheetId = this.env.model.getters.getActiveSheetId();
|
|
18630
|
-
this.shouldUpdateChart = false;
|
|
18631
|
-
}
|
|
18632
|
-
else {
|
|
18633
|
-
this.shouldUpdateChart = true;
|
|
18634
18633
|
}
|
|
18635
18634
|
if (!this.env.model.getters.isChartDefined(this.figureId)) {
|
|
18636
18635
|
this.props.onCloseSidePanel();
|
|
@@ -18638,8 +18637,8 @@
|
|
|
18638
18637
|
}
|
|
18639
18638
|
});
|
|
18640
18639
|
}
|
|
18641
|
-
updateChart(updateDefinition) {
|
|
18642
|
-
if (
|
|
18640
|
+
updateChart(figureId, updateDefinition) {
|
|
18641
|
+
if (figureId !== this.figureId) {
|
|
18643
18642
|
return;
|
|
18644
18643
|
}
|
|
18645
18644
|
const definition = {
|
|
@@ -18648,8 +18647,8 @@
|
|
|
18648
18647
|
};
|
|
18649
18648
|
return this.env.model.dispatch("UPDATE_CHART", {
|
|
18650
18649
|
definition,
|
|
18651
|
-
id:
|
|
18652
|
-
sheetId: this.
|
|
18650
|
+
id: figureId,
|
|
18651
|
+
sheetId: this.env.model.getters.getFigureSheetId(figureId),
|
|
18653
18652
|
});
|
|
18654
18653
|
}
|
|
18655
18654
|
onTypeChange(type) {
|
|
@@ -18661,7 +18660,7 @@
|
|
|
18661
18660
|
this.env.model.dispatch("UPDATE_CHART", {
|
|
18662
18661
|
definition,
|
|
18663
18662
|
id: this.figureId,
|
|
18664
|
-
sheetId: this.
|
|
18663
|
+
sheetId: this.env.model.getters.getFigureSheetId(this.figureId),
|
|
18665
18664
|
});
|
|
18666
18665
|
}
|
|
18667
18666
|
get chartPanel() {
|
|
@@ -24482,6 +24481,16 @@
|
|
|
24482
24481
|
63: "333333",
|
|
24483
24482
|
64: "000000",
|
|
24484
24483
|
65: "FFFFFF", // system background
|
|
24484
|
+
};
|
|
24485
|
+
const IMAGE_MIMETYPE_EXTENSION_MAPPING = {
|
|
24486
|
+
"image/avif": "avif",
|
|
24487
|
+
"image/bmp": "bmp",
|
|
24488
|
+
"image/gif": "gif",
|
|
24489
|
+
"image/vnd.microsoft.icon": "ico",
|
|
24490
|
+
"image/jpeg": "jpeg",
|
|
24491
|
+
"image/png": "png",
|
|
24492
|
+
"image/tiff": "tiff",
|
|
24493
|
+
"image/webp": "webp",
|
|
24485
24494
|
};
|
|
24486
24495
|
|
|
24487
24496
|
/**
|
|
@@ -26963,6 +26972,11 @@
|
|
|
26963
26972
|
<Override ContentType="${contentType}" PartName="${partName}" />
|
|
26964
26973
|
`;
|
|
26965
26974
|
}
|
|
26975
|
+
function createDefaultXMLElement(extension, contentType) {
|
|
26976
|
+
return escapeXml /*xml*/ `
|
|
26977
|
+
<Default Extension="${extension}" ContentType="${contentType}" />
|
|
26978
|
+
`;
|
|
26979
|
+
}
|
|
26966
26980
|
function joinXmlNodes(xmlNodes) {
|
|
26967
26981
|
return new XMLString(xmlNodes.join("\n"));
|
|
26968
26982
|
}
|
|
@@ -41730,7 +41744,7 @@
|
|
|
41730
41744
|
const file = await this.getImageFromUser();
|
|
41731
41745
|
const path = await this.fileStore.upload(file);
|
|
41732
41746
|
const size = await this.getImageSize(path);
|
|
41733
|
-
return { path, size };
|
|
41747
|
+
return { path, size, mimetype: file.type };
|
|
41734
41748
|
}
|
|
41735
41749
|
getImageFromUser() {
|
|
41736
41750
|
return new Promise((resolve, reject) => {
|
|
@@ -46811,8 +46825,7 @@
|
|
|
46811
46825
|
// Figures and Charts
|
|
46812
46826
|
let drawingNode = escapeXml ``;
|
|
46813
46827
|
const drawingRelIds = [];
|
|
46814
|
-
const
|
|
46815
|
-
for (const chart of charts) {
|
|
46828
|
+
for (const chart of sheet.charts) {
|
|
46816
46829
|
const xlsxChartId = convertChartId(chart.id);
|
|
46817
46830
|
const chartRelId = addRelsToFile(construct.relsFiles, `xl/drawings/_rels/drawing${sheetIndex}.xml.rels`, {
|
|
46818
46831
|
target: `../charts/chart${xlsxChartId}.xml`,
|
|
@@ -46821,20 +46834,27 @@
|
|
|
46821
46834
|
drawingRelIds.push(chartRelId);
|
|
46822
46835
|
files.push(createXMLFile(createChart(chart, sheetIndex, data), `xl/charts/chart${xlsxChartId}.xml`, "chart"));
|
|
46823
46836
|
}
|
|
46824
|
-
const
|
|
46825
|
-
|
|
46837
|
+
for (const image of sheet.images) {
|
|
46838
|
+
const mimeType = image.data.mimetype;
|
|
46839
|
+
if (mimeType === undefined)
|
|
46840
|
+
continue;
|
|
46841
|
+
const extension = IMAGE_MIMETYPE_EXTENSION_MAPPING[mimeType];
|
|
46842
|
+
// only support exporting images with mimetypes specified in the mapping
|
|
46843
|
+
if (extension === undefined)
|
|
46844
|
+
continue;
|
|
46826
46845
|
const xlsxImageId = convertImageId(image.id);
|
|
46846
|
+
let imageFileName = `image${xlsxImageId}.${extension}`;
|
|
46827
46847
|
const imageRelId = addRelsToFile(construct.relsFiles, `xl/drawings/_rels/drawing${sheetIndex}.xml.rels`, {
|
|
46828
|
-
target: `../media
|
|
46848
|
+
target: `../media/${imageFileName}`,
|
|
46829
46849
|
type: XLSX_RELATION_TYPE.image,
|
|
46830
46850
|
});
|
|
46831
46851
|
drawingRelIds.push(imageRelId);
|
|
46832
46852
|
files.push({
|
|
46833
|
-
path: `xl/media
|
|
46834
|
-
|
|
46853
|
+
path: `xl/media/${imageFileName}`,
|
|
46854
|
+
imageSrc: image.data.path,
|
|
46835
46855
|
});
|
|
46836
46856
|
}
|
|
46837
|
-
const drawings = [...charts, ...images];
|
|
46857
|
+
const drawings = [...sheet.charts, ...sheet.images];
|
|
46838
46858
|
if (drawings.length) {
|
|
46839
46859
|
const drawingRelId = addRelsToFile(construct.relsFiles, `xl/worksheets/_rels/sheet${sheetIndex}.xml.rels`, {
|
|
46840
46860
|
target: `../drawings/drawing${sheetIndex}.xml`,
|
|
@@ -46953,6 +46973,8 @@
|
|
|
46953
46973
|
}
|
|
46954
46974
|
function createContentTypes(files) {
|
|
46955
46975
|
const overrideNodes = [];
|
|
46976
|
+
// hard-code supported image mimetypes
|
|
46977
|
+
const imageDefaultNodes = Object.entries(IMAGE_MIMETYPE_EXTENSION_MAPPING).map(([mimetype, extension]) => createDefaultXMLElement(extension, mimetype));
|
|
46956
46978
|
for (const file of files) {
|
|
46957
46979
|
if ("contentType" in file && file.contentType) {
|
|
46958
46980
|
overrideNodes.push(createOverride("/" + file.path, CONTENT_TYPES[file.contentType]));
|
|
@@ -46968,6 +46990,7 @@
|
|
|
46968
46990
|
];
|
|
46969
46991
|
const xml = escapeXml /*xml*/ `
|
|
46970
46992
|
<Types xmlns="${NAMESPACE["Types"]}">
|
|
46993
|
+
${joinXmlNodes(Object.values(imageDefaultNodes))}
|
|
46971
46994
|
<Default ${formatAttributes(relsAttributes)} />
|
|
46972
46995
|
<Default ${formatAttributes(xmlAttributes)} />
|
|
46973
46996
|
${joinXmlNodes(overrideNodes)}
|
|
@@ -47582,9 +47605,9 @@
|
|
|
47582
47605
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
47583
47606
|
|
|
47584
47607
|
|
|
47585
|
-
__info__.version = '16.3.
|
|
47586
|
-
__info__.date = '2023-
|
|
47587
|
-
__info__.hash = '
|
|
47608
|
+
__info__.version = '16.3.3';
|
|
47609
|
+
__info__.date = '2023-06-12T13:50:01.114Z';
|
|
47610
|
+
__info__.hash = 'd3ab96f';
|
|
47588
47611
|
|
|
47589
47612
|
|
|
47590
47613
|
})(this.o_spreadsheet = this.o_spreadsheet || {}, owl);
|