@odoo/o-spreadsheet 16.2.8 → 16.2.10
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 +74 -45
- package/dist/o-spreadsheet.d.ts +164 -161
- package/dist/o-spreadsheet.esm.js +74 -45
- package/dist/o-spreadsheet.iife.js +74 -45
- package/dist/o-spreadsheet.iife.min.js +255 -253
- package/package.json +4 -4
|
@@ -711,12 +711,20 @@ function getDefaultCellHeight(cell) {
|
|
|
711
711
|
return computeTextLinesHeight(fontSize, numberOfLines) + 2 * PADDING_AUTORESIZE_VERTICAL;
|
|
712
712
|
}
|
|
713
713
|
function computeTextWidth(context, text, style) {
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
714
|
+
const font = computeTextFont(style);
|
|
715
|
+
if (!textWidthCache[font]) {
|
|
716
|
+
textWidthCache[font] = {};
|
|
717
|
+
}
|
|
718
|
+
if (textWidthCache[font][text] === undefined) {
|
|
719
|
+
context.save();
|
|
720
|
+
context.font = font;
|
|
721
|
+
const textWidth = context.measureText(text).width;
|
|
722
|
+
context.restore();
|
|
723
|
+
textWidthCache[font][text] = textWidth;
|
|
724
|
+
}
|
|
725
|
+
return textWidthCache[font][text];
|
|
719
726
|
}
|
|
727
|
+
const textWidthCache = {};
|
|
720
728
|
function fontSizeInPixels(fontSize) {
|
|
721
729
|
return Math.round((fontSize * 96) / 72);
|
|
722
730
|
}
|
|
@@ -1726,27 +1734,36 @@ function removeTrailingZeroes(numberString) {
|
|
|
1726
1734
|
}
|
|
1727
1735
|
return numberString.slice(0, i + 1) || undefined;
|
|
1728
1736
|
}
|
|
1737
|
+
const leadingZeroesRegexp = /^0+/;
|
|
1729
1738
|
/**
|
|
1730
1739
|
* Limit the size of the decimal part of a number to the given number of digits.
|
|
1731
1740
|
*/
|
|
1732
1741
|
function limitDecimalDigits(decimalDigits, maxDecimals) {
|
|
1742
|
+
var _a;
|
|
1733
1743
|
let integerDigits = "0";
|
|
1734
1744
|
let resultDecimalDigits = decimalDigits;
|
|
1735
1745
|
// Note : we'd want to simply use number.toFixed() to handle the max digits & rounding,
|
|
1736
1746
|
// but it has very strange behaviour. Ex: 12.345.toFixed(2) => "12.35", but 1.345.toFixed(2) => "1.34"
|
|
1737
1747
|
let slicedDecimalDigits = decimalDigits.slice(0, maxDecimals);
|
|
1738
1748
|
const i = maxDecimals;
|
|
1739
|
-
if (Number(
|
|
1749
|
+
if (Number(decimalDigits[i]) < 5) {
|
|
1740
1750
|
return { integerDigits, decimalDigits: slicedDecimalDigits };
|
|
1741
1751
|
}
|
|
1742
1752
|
// round up
|
|
1753
|
+
const leadingZeroes = ((_a = slicedDecimalDigits.match(leadingZeroesRegexp)) === null || _a === void 0 ? void 0 : _a[0]) || "";
|
|
1743
1754
|
const slicedRoundedUp = (Number(slicedDecimalDigits) + 1).toString();
|
|
1744
|
-
|
|
1745
|
-
|
|
1755
|
+
const withoutLeadingZeroes = slicedDecimalDigits.slice(leadingZeroes.length);
|
|
1756
|
+
// e.g. carry over from 99 to 100
|
|
1757
|
+
const carryOver = slicedRoundedUp.length > withoutLeadingZeroes.length;
|
|
1758
|
+
if (carryOver && !leadingZeroes) {
|
|
1759
|
+
integerDigits = "1";
|
|
1746
1760
|
resultDecimalDigits = undefined;
|
|
1747
1761
|
}
|
|
1762
|
+
else if (carryOver) {
|
|
1763
|
+
resultDecimalDigits = leadingZeroes.slice(0, -1) + slicedRoundedUp;
|
|
1764
|
+
}
|
|
1748
1765
|
else {
|
|
1749
|
-
resultDecimalDigits = slicedRoundedUp;
|
|
1766
|
+
resultDecimalDigits = leadingZeroes + slicedRoundedUp;
|
|
1750
1767
|
}
|
|
1751
1768
|
return { integerDigits, decimalDigits: resultDecimalDigits };
|
|
1752
1769
|
}
|
|
@@ -16953,6 +16970,7 @@ css /* scss */ `
|
|
|
16953
16970
|
.o-color-picker-toggler {
|
|
16954
16971
|
display: flex;
|
|
16955
16972
|
.o-color-picker-toggler-sign {
|
|
16973
|
+
display: flex;
|
|
16956
16974
|
margin: auto auto;
|
|
16957
16975
|
width: 55%;
|
|
16958
16976
|
height: 55%;
|
|
@@ -19847,6 +19865,7 @@ class Composer extends owl.Component {
|
|
|
19847
19865
|
(this.autoCompleteState.selectedIndex + 1) % this.autoCompleteState.values.length;
|
|
19848
19866
|
}
|
|
19849
19867
|
}
|
|
19868
|
+
this.updateCursorIfNeeded();
|
|
19850
19869
|
}
|
|
19851
19870
|
processTabKey(ev) {
|
|
19852
19871
|
var _a;
|
|
@@ -19917,10 +19936,12 @@ class Composer extends owl.Component {
|
|
|
19917
19936
|
}
|
|
19918
19937
|
else {
|
|
19919
19938
|
ev.stopPropagation();
|
|
19939
|
+
this.updateCursorIfNeeded();
|
|
19920
19940
|
}
|
|
19921
|
-
|
|
19922
|
-
|
|
19923
|
-
|
|
19941
|
+
}
|
|
19942
|
+
updateCursorIfNeeded() {
|
|
19943
|
+
if (!this.env.model.getters.isSelectingForComposer()) {
|
|
19944
|
+
const { start, end } = this.contentHelper.getCurrentSelection();
|
|
19924
19945
|
this.env.model.dispatch("CHANGE_COMPOSER_CURSOR_SELECTION", { start, end });
|
|
19925
19946
|
this.isKeyStillDown = true;
|
|
19926
19947
|
}
|
|
@@ -19978,7 +19999,12 @@ class Composer extends owl.Component {
|
|
|
19978
19999
|
};
|
|
19979
20000
|
});
|
|
19980
20001
|
if (searchTerm) {
|
|
19981
|
-
|
|
20002
|
+
if (searchTerm.toLowerCase() === "true" || searchTerm.toLowerCase() === "false") {
|
|
20003
|
+
values = [];
|
|
20004
|
+
}
|
|
20005
|
+
else {
|
|
20006
|
+
values = fuzzyLookup(searchTerm, values, (t) => t.text);
|
|
20007
|
+
}
|
|
19982
20008
|
}
|
|
19983
20009
|
else {
|
|
19984
20010
|
// alphabetical order
|
|
@@ -29113,7 +29139,14 @@ class FiltersPlugin extends CorePlugin {
|
|
|
29113
29139
|
this.history.update("tables", filterTables);
|
|
29114
29140
|
break;
|
|
29115
29141
|
case "DUPLICATE_SHEET":
|
|
29116
|
-
|
|
29142
|
+
const tables = {};
|
|
29143
|
+
for (const filterTable of Object.values(this.tables[cmd.sheetId] || {})) {
|
|
29144
|
+
if (filterTable) {
|
|
29145
|
+
const newFilterTable = deepCopy(filterTable);
|
|
29146
|
+
tables[newFilterTable.id] = newFilterTable;
|
|
29147
|
+
}
|
|
29148
|
+
}
|
|
29149
|
+
this.history.update("tables", cmd.sheetIdTo, tables);
|
|
29117
29150
|
break;
|
|
29118
29151
|
case "ADD_COLUMNS_ROWS":
|
|
29119
29152
|
this.onAddColumnsRows(cmd);
|
|
@@ -32690,6 +32723,7 @@ class FilterEvaluationPlugin extends UIPlugin {
|
|
|
32690
32723
|
}
|
|
32691
32724
|
exportForExcel(data) {
|
|
32692
32725
|
for (const sheetData of data.sheets) {
|
|
32726
|
+
const sheetId = sheetData.id;
|
|
32693
32727
|
for (const tableData of sheetData.filterTables) {
|
|
32694
32728
|
const tableZone = toZone(tableData.range);
|
|
32695
32729
|
const filters = [];
|
|
@@ -32705,20 +32739,20 @@ class FilterEvaluationPlugin extends UIPlugin {
|
|
|
32705
32739
|
if (!filter)
|
|
32706
32740
|
continue;
|
|
32707
32741
|
const valuesInFilterZone = filter.filteredZone
|
|
32708
|
-
? positions(filter.filteredZone)
|
|
32709
|
-
.map(({ col, row }) => this.getters.getEvaluatedCell({ sheetId: sheetData.id, col, row }))
|
|
32710
|
-
.filter((cell) => cell.type !== CellValueType.empty)
|
|
32711
|
-
.map((cell) => cell.formattedValue)
|
|
32742
|
+
? positions(filter.filteredZone).map((position) => this.getters.getEvaluatedCell({ sheetId, ...position }).formattedValue)
|
|
32712
32743
|
: [];
|
|
32713
|
-
|
|
32714
|
-
|
|
32715
|
-
|
|
32716
|
-
|
|
32717
|
-
|
|
32718
|
-
|
|
32719
|
-
|
|
32720
|
-
|
|
32721
|
-
|
|
32744
|
+
if (filteredValues.length) {
|
|
32745
|
+
const xlsxDisplayedValues = valuesInFilterZone
|
|
32746
|
+
.filter((val) => val)
|
|
32747
|
+
.filter((val) => !filteredValues.includes(val));
|
|
32748
|
+
filters.push({
|
|
32749
|
+
colId: i,
|
|
32750
|
+
displayedValues: [...new Set(xlsxDisplayedValues)],
|
|
32751
|
+
displayBlanks: !filteredValues.includes("") && valuesInFilterZone.some((val) => !val),
|
|
32752
|
+
});
|
|
32753
|
+
}
|
|
32754
|
+
// In xlsx, filter header should ALWAYS be a string and should be unique in the table
|
|
32755
|
+
const headerPosition = { col: filter.col, row: filter.zoneWithHeaders.top, sheetId };
|
|
32722
32756
|
const headerString = this.getters.getEvaluatedCell(headerPosition).formattedValue;
|
|
32723
32757
|
const headerName = this.getUniqueColNameForExcel(i, headerString, headerNames);
|
|
32724
32758
|
headerNames.push(headerName);
|
|
@@ -35747,15 +35781,15 @@ SelectionInputPlugin.getters = [];
|
|
|
35747
35781
|
* This plugin handles this internal state.
|
|
35748
35782
|
*/
|
|
35749
35783
|
class SelectionInputsManagerPlugin extends UIPlugin {
|
|
35784
|
+
get currentInput() {
|
|
35785
|
+
return this.focusedInputId ? this.inputs[this.focusedInputId] : null;
|
|
35786
|
+
}
|
|
35750
35787
|
constructor(config) {
|
|
35751
35788
|
super(config);
|
|
35752
35789
|
this.config = config;
|
|
35753
35790
|
this.inputs = {};
|
|
35754
35791
|
this.focusedInputId = null;
|
|
35755
35792
|
}
|
|
35756
|
-
get currentInput() {
|
|
35757
|
-
return this.focusedInputId ? this.inputs[this.focusedInputId] : null;
|
|
35758
|
-
}
|
|
35759
35793
|
// ---------------------------------------------------------------------------
|
|
35760
35794
|
// Command Handling
|
|
35761
35795
|
// ---------------------------------------------------------------------------
|
|
@@ -40831,11 +40865,9 @@ TopBarComposer.props = {
|
|
|
40831
40865
|
onComposerContentFocused: Function,
|
|
40832
40866
|
};
|
|
40833
40867
|
|
|
40834
|
-
// -----------------------------------------------------------------------------
|
|
40835
|
-
// TopBar
|
|
40836
|
-
// -----------------------------------------------------------------------------
|
|
40837
40868
|
css /* scss */ `
|
|
40838
40869
|
.o-font-size-editor {
|
|
40870
|
+
height: calc(100% - 4px);
|
|
40839
40871
|
input.o-font-size {
|
|
40840
40872
|
height: 20px;
|
|
40841
40873
|
width: 23px;
|
|
@@ -40913,6 +40945,7 @@ FontSizeEditor.components = {};
|
|
|
40913
40945
|
FontSizeEditor.props = {
|
|
40914
40946
|
onToggle: Function,
|
|
40915
40947
|
dropdownStyle: String,
|
|
40948
|
+
class: String,
|
|
40916
40949
|
};
|
|
40917
40950
|
|
|
40918
40951
|
const FORMATS = [
|
|
@@ -44356,15 +44389,10 @@ function addAutoFilter(table) {
|
|
|
44356
44389
|
`;
|
|
44357
44390
|
}
|
|
44358
44391
|
function addFilterColumns(table) {
|
|
44359
|
-
const tableZone = toZone(table.range);
|
|
44360
44392
|
const columns = [];
|
|
44361
|
-
for (const
|
|
44362
|
-
const filter = table.filters[i];
|
|
44363
|
-
if (!filter || !filter.filteredValues.length) {
|
|
44364
|
-
continue;
|
|
44365
|
-
}
|
|
44393
|
+
for (const filter of table.filters) {
|
|
44366
44394
|
const colXml = escapeXml /*xml*/ `
|
|
44367
|
-
<filterColumn ${formatAttributes([["colId",
|
|
44395
|
+
<filterColumn ${formatAttributes([["colId", filter.colId]])}>
|
|
44368
44396
|
${addFilter(filter)}
|
|
44369
44397
|
</filterColumn>
|
|
44370
44398
|
`;
|
|
@@ -44373,9 +44401,10 @@ function addFilterColumns(table) {
|
|
|
44373
44401
|
return columns;
|
|
44374
44402
|
}
|
|
44375
44403
|
function addFilter(filter) {
|
|
44376
|
-
const filterValues = filter.
|
|
44404
|
+
const filterValues = filter.displayedValues.map((val) => escapeXml /*xml*/ `<filter ${formatAttributes([["val", val]])}/>`);
|
|
44405
|
+
const filterAttributes = filter.displayBlanks ? [["blank", 1]] : [];
|
|
44377
44406
|
return escapeXml /*xml*/ `
|
|
44378
|
-
<filters>
|
|
44407
|
+
<filters ${formatAttributes(filterAttributes)}>
|
|
44379
44408
|
${joinXmlNodes(filterValues)}
|
|
44380
44409
|
</filters>
|
|
44381
44410
|
`;
|
|
@@ -45350,6 +45379,6 @@ exports.setTranslationMethod = setTranslationMethod;
|
|
|
45350
45379
|
exports.tokenize = tokenize;
|
|
45351
45380
|
|
|
45352
45381
|
|
|
45353
|
-
__info__.version = '16.2.
|
|
45354
|
-
__info__.date = '2023-06-
|
|
45355
|
-
__info__.hash = '
|
|
45382
|
+
__info__.version = '16.2.10';
|
|
45383
|
+
__info__.date = '2023-06-26T14:33:27.213Z';
|
|
45384
|
+
__info__.hash = '1d3f47c';
|