@odoo/o-spreadsheet 16.2.9 → 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 +48 -37
- package/dist/o-spreadsheet.d.ts +163 -161
- package/dist/o-spreadsheet.esm.js +48 -37
- package/dist/o-spreadsheet.iife.js +48 -37
- package/dist/o-spreadsheet.iife.min.js +243 -242
- package/package.json +4 -4
|
@@ -707,12 +707,20 @@ function getDefaultCellHeight(cell) {
|
|
|
707
707
|
return computeTextLinesHeight(fontSize, numberOfLines) + 2 * PADDING_AUTORESIZE_VERTICAL;
|
|
708
708
|
}
|
|
709
709
|
function computeTextWidth(context, text, style) {
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
710
|
+
const font = computeTextFont(style);
|
|
711
|
+
if (!textWidthCache[font]) {
|
|
712
|
+
textWidthCache[font] = {};
|
|
713
|
+
}
|
|
714
|
+
if (textWidthCache[font][text] === undefined) {
|
|
715
|
+
context.save();
|
|
716
|
+
context.font = font;
|
|
717
|
+
const textWidth = context.measureText(text).width;
|
|
718
|
+
context.restore();
|
|
719
|
+
textWidthCache[font][text] = textWidth;
|
|
720
|
+
}
|
|
721
|
+
return textWidthCache[font][text];
|
|
715
722
|
}
|
|
723
|
+
const textWidthCache = {};
|
|
716
724
|
function fontSizeInPixels(fontSize) {
|
|
717
725
|
return Math.round((fontSize * 96) / 72);
|
|
718
726
|
}
|
|
@@ -29127,7 +29135,14 @@ class FiltersPlugin extends CorePlugin {
|
|
|
29127
29135
|
this.history.update("tables", filterTables);
|
|
29128
29136
|
break;
|
|
29129
29137
|
case "DUPLICATE_SHEET":
|
|
29130
|
-
|
|
29138
|
+
const tables = {};
|
|
29139
|
+
for (const filterTable of Object.values(this.tables[cmd.sheetId] || {})) {
|
|
29140
|
+
if (filterTable) {
|
|
29141
|
+
const newFilterTable = deepCopy(filterTable);
|
|
29142
|
+
tables[newFilterTable.id] = newFilterTable;
|
|
29143
|
+
}
|
|
29144
|
+
}
|
|
29145
|
+
this.history.update("tables", cmd.sheetIdTo, tables);
|
|
29131
29146
|
break;
|
|
29132
29147
|
case "ADD_COLUMNS_ROWS":
|
|
29133
29148
|
this.onAddColumnsRows(cmd);
|
|
@@ -32704,6 +32719,7 @@ class FilterEvaluationPlugin extends UIPlugin {
|
|
|
32704
32719
|
}
|
|
32705
32720
|
exportForExcel(data) {
|
|
32706
32721
|
for (const sheetData of data.sheets) {
|
|
32722
|
+
const sheetId = sheetData.id;
|
|
32707
32723
|
for (const tableData of sheetData.filterTables) {
|
|
32708
32724
|
const tableZone = toZone(tableData.range);
|
|
32709
32725
|
const filters = [];
|
|
@@ -32719,20 +32735,20 @@ class FilterEvaluationPlugin extends UIPlugin {
|
|
|
32719
32735
|
if (!filter)
|
|
32720
32736
|
continue;
|
|
32721
32737
|
const valuesInFilterZone = filter.filteredZone
|
|
32722
|
-
? positions(filter.filteredZone)
|
|
32723
|
-
.map(({ col, row }) => this.getters.getEvaluatedCell({ sheetId: sheetData.id, col, row }))
|
|
32724
|
-
.filter((cell) => cell.type !== CellValueType.empty)
|
|
32725
|
-
.map((cell) => cell.formattedValue)
|
|
32738
|
+
? positions(filter.filteredZone).map((position) => this.getters.getEvaluatedCell({ sheetId, ...position }).formattedValue)
|
|
32726
32739
|
: [];
|
|
32727
|
-
|
|
32728
|
-
|
|
32729
|
-
|
|
32730
|
-
|
|
32731
|
-
|
|
32732
|
-
|
|
32733
|
-
|
|
32734
|
-
|
|
32735
|
-
|
|
32740
|
+
if (filteredValues.length) {
|
|
32741
|
+
const xlsxDisplayedValues = valuesInFilterZone
|
|
32742
|
+
.filter((val) => val)
|
|
32743
|
+
.filter((val) => !filteredValues.includes(val));
|
|
32744
|
+
filters.push({
|
|
32745
|
+
colId: i,
|
|
32746
|
+
displayedValues: [...new Set(xlsxDisplayedValues)],
|
|
32747
|
+
displayBlanks: !filteredValues.includes("") && valuesInFilterZone.some((val) => !val),
|
|
32748
|
+
});
|
|
32749
|
+
}
|
|
32750
|
+
// In xlsx, filter header should ALWAYS be a string and should be unique in the table
|
|
32751
|
+
const headerPosition = { col: filter.col, row: filter.zoneWithHeaders.top, sheetId };
|
|
32736
32752
|
const headerString = this.getters.getEvaluatedCell(headerPosition).formattedValue;
|
|
32737
32753
|
const headerName = this.getUniqueColNameForExcel(i, headerString, headerNames);
|
|
32738
32754
|
headerNames.push(headerName);
|
|
@@ -35761,15 +35777,15 @@ SelectionInputPlugin.getters = [];
|
|
|
35761
35777
|
* This plugin handles this internal state.
|
|
35762
35778
|
*/
|
|
35763
35779
|
class SelectionInputsManagerPlugin extends UIPlugin {
|
|
35780
|
+
get currentInput() {
|
|
35781
|
+
return this.focusedInputId ? this.inputs[this.focusedInputId] : null;
|
|
35782
|
+
}
|
|
35764
35783
|
constructor(config) {
|
|
35765
35784
|
super(config);
|
|
35766
35785
|
this.config = config;
|
|
35767
35786
|
this.inputs = {};
|
|
35768
35787
|
this.focusedInputId = null;
|
|
35769
35788
|
}
|
|
35770
|
-
get currentInput() {
|
|
35771
|
-
return this.focusedInputId ? this.inputs[this.focusedInputId] : null;
|
|
35772
|
-
}
|
|
35773
35789
|
// ---------------------------------------------------------------------------
|
|
35774
35790
|
// Command Handling
|
|
35775
35791
|
// ---------------------------------------------------------------------------
|
|
@@ -40845,11 +40861,9 @@ TopBarComposer.props = {
|
|
|
40845
40861
|
onComposerContentFocused: Function,
|
|
40846
40862
|
};
|
|
40847
40863
|
|
|
40848
|
-
// -----------------------------------------------------------------------------
|
|
40849
|
-
// TopBar
|
|
40850
|
-
// -----------------------------------------------------------------------------
|
|
40851
40864
|
css /* scss */ `
|
|
40852
40865
|
.o-font-size-editor {
|
|
40866
|
+
height: calc(100% - 4px);
|
|
40853
40867
|
input.o-font-size {
|
|
40854
40868
|
height: 20px;
|
|
40855
40869
|
width: 23px;
|
|
@@ -40927,6 +40941,7 @@ FontSizeEditor.components = {};
|
|
|
40927
40941
|
FontSizeEditor.props = {
|
|
40928
40942
|
onToggle: Function,
|
|
40929
40943
|
dropdownStyle: String,
|
|
40944
|
+
class: String,
|
|
40930
40945
|
};
|
|
40931
40946
|
|
|
40932
40947
|
const FORMATS = [
|
|
@@ -44370,15 +44385,10 @@ function addAutoFilter(table) {
|
|
|
44370
44385
|
`;
|
|
44371
44386
|
}
|
|
44372
44387
|
function addFilterColumns(table) {
|
|
44373
|
-
const tableZone = toZone(table.range);
|
|
44374
44388
|
const columns = [];
|
|
44375
|
-
for (const
|
|
44376
|
-
const filter = table.filters[i];
|
|
44377
|
-
if (!filter || !filter.filteredValues.length) {
|
|
44378
|
-
continue;
|
|
44379
|
-
}
|
|
44389
|
+
for (const filter of table.filters) {
|
|
44380
44390
|
const colXml = escapeXml /*xml*/ `
|
|
44381
|
-
<filterColumn ${formatAttributes([["colId",
|
|
44391
|
+
<filterColumn ${formatAttributes([["colId", filter.colId]])}>
|
|
44382
44392
|
${addFilter(filter)}
|
|
44383
44393
|
</filterColumn>
|
|
44384
44394
|
`;
|
|
@@ -44387,9 +44397,10 @@ function addFilterColumns(table) {
|
|
|
44387
44397
|
return columns;
|
|
44388
44398
|
}
|
|
44389
44399
|
function addFilter(filter) {
|
|
44390
|
-
const filterValues = filter.
|
|
44400
|
+
const filterValues = filter.displayedValues.map((val) => escapeXml /*xml*/ `<filter ${formatAttributes([["val", val]])}/>`);
|
|
44401
|
+
const filterAttributes = filter.displayBlanks ? [["blank", 1]] : [];
|
|
44391
44402
|
return escapeXml /*xml*/ `
|
|
44392
|
-
<filters>
|
|
44403
|
+
<filters ${formatAttributes(filterAttributes)}>
|
|
44393
44404
|
${joinXmlNodes(filterValues)}
|
|
44394
44405
|
</filters>
|
|
44395
44406
|
`;
|
|
@@ -45336,6 +45347,6 @@ function addFunction(functionName, functionDescription) {
|
|
|
45336
45347
|
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 };
|
|
45337
45348
|
|
|
45338
45349
|
|
|
45339
|
-
__info__.version = '16.2.
|
|
45340
|
-
__info__.date = '2023-06-
|
|
45341
|
-
__info__.hash = '
|
|
45350
|
+
__info__.version = '16.2.10';
|
|
45351
|
+
__info__.date = '2023-06-26T14:33:27.213Z';
|
|
45352
|
+
__info__.hash = '1d3f47c';
|
|
@@ -708,12 +708,20 @@
|
|
|
708
708
|
return computeTextLinesHeight(fontSize, numberOfLines) + 2 * PADDING_AUTORESIZE_VERTICAL;
|
|
709
709
|
}
|
|
710
710
|
function computeTextWidth(context, text, style) {
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
711
|
+
const font = computeTextFont(style);
|
|
712
|
+
if (!textWidthCache[font]) {
|
|
713
|
+
textWidthCache[font] = {};
|
|
714
|
+
}
|
|
715
|
+
if (textWidthCache[font][text] === undefined) {
|
|
716
|
+
context.save();
|
|
717
|
+
context.font = font;
|
|
718
|
+
const textWidth = context.measureText(text).width;
|
|
719
|
+
context.restore();
|
|
720
|
+
textWidthCache[font][text] = textWidth;
|
|
721
|
+
}
|
|
722
|
+
return textWidthCache[font][text];
|
|
716
723
|
}
|
|
724
|
+
const textWidthCache = {};
|
|
717
725
|
function fontSizeInPixels(fontSize) {
|
|
718
726
|
return Math.round((fontSize * 96) / 72);
|
|
719
727
|
}
|
|
@@ -29128,7 +29136,14 @@
|
|
|
29128
29136
|
this.history.update("tables", filterTables);
|
|
29129
29137
|
break;
|
|
29130
29138
|
case "DUPLICATE_SHEET":
|
|
29131
|
-
|
|
29139
|
+
const tables = {};
|
|
29140
|
+
for (const filterTable of Object.values(this.tables[cmd.sheetId] || {})) {
|
|
29141
|
+
if (filterTable) {
|
|
29142
|
+
const newFilterTable = deepCopy(filterTable);
|
|
29143
|
+
tables[newFilterTable.id] = newFilterTable;
|
|
29144
|
+
}
|
|
29145
|
+
}
|
|
29146
|
+
this.history.update("tables", cmd.sheetIdTo, tables);
|
|
29132
29147
|
break;
|
|
29133
29148
|
case "ADD_COLUMNS_ROWS":
|
|
29134
29149
|
this.onAddColumnsRows(cmd);
|
|
@@ -32705,6 +32720,7 @@
|
|
|
32705
32720
|
}
|
|
32706
32721
|
exportForExcel(data) {
|
|
32707
32722
|
for (const sheetData of data.sheets) {
|
|
32723
|
+
const sheetId = sheetData.id;
|
|
32708
32724
|
for (const tableData of sheetData.filterTables) {
|
|
32709
32725
|
const tableZone = toZone(tableData.range);
|
|
32710
32726
|
const filters = [];
|
|
@@ -32720,20 +32736,20 @@
|
|
|
32720
32736
|
if (!filter)
|
|
32721
32737
|
continue;
|
|
32722
32738
|
const valuesInFilterZone = filter.filteredZone
|
|
32723
|
-
? positions(filter.filteredZone)
|
|
32724
|
-
.map(({ col, row }) => this.getters.getEvaluatedCell({ sheetId: sheetData.id, col, row }))
|
|
32725
|
-
.filter((cell) => cell.type !== CellValueType.empty)
|
|
32726
|
-
.map((cell) => cell.formattedValue)
|
|
32739
|
+
? positions(filter.filteredZone).map((position) => this.getters.getEvaluatedCell({ sheetId, ...position }).formattedValue)
|
|
32727
32740
|
: [];
|
|
32728
|
-
|
|
32729
|
-
|
|
32730
|
-
|
|
32731
|
-
|
|
32732
|
-
|
|
32733
|
-
|
|
32734
|
-
|
|
32735
|
-
|
|
32736
|
-
|
|
32741
|
+
if (filteredValues.length) {
|
|
32742
|
+
const xlsxDisplayedValues = valuesInFilterZone
|
|
32743
|
+
.filter((val) => val)
|
|
32744
|
+
.filter((val) => !filteredValues.includes(val));
|
|
32745
|
+
filters.push({
|
|
32746
|
+
colId: i,
|
|
32747
|
+
displayedValues: [...new Set(xlsxDisplayedValues)],
|
|
32748
|
+
displayBlanks: !filteredValues.includes("") && valuesInFilterZone.some((val) => !val),
|
|
32749
|
+
});
|
|
32750
|
+
}
|
|
32751
|
+
// In xlsx, filter header should ALWAYS be a string and should be unique in the table
|
|
32752
|
+
const headerPosition = { col: filter.col, row: filter.zoneWithHeaders.top, sheetId };
|
|
32737
32753
|
const headerString = this.getters.getEvaluatedCell(headerPosition).formattedValue;
|
|
32738
32754
|
const headerName = this.getUniqueColNameForExcel(i, headerString, headerNames);
|
|
32739
32755
|
headerNames.push(headerName);
|
|
@@ -35762,15 +35778,15 @@
|
|
|
35762
35778
|
* This plugin handles this internal state.
|
|
35763
35779
|
*/
|
|
35764
35780
|
class SelectionInputsManagerPlugin extends UIPlugin {
|
|
35781
|
+
get currentInput() {
|
|
35782
|
+
return this.focusedInputId ? this.inputs[this.focusedInputId] : null;
|
|
35783
|
+
}
|
|
35765
35784
|
constructor(config) {
|
|
35766
35785
|
super(config);
|
|
35767
35786
|
this.config = config;
|
|
35768
35787
|
this.inputs = {};
|
|
35769
35788
|
this.focusedInputId = null;
|
|
35770
35789
|
}
|
|
35771
|
-
get currentInput() {
|
|
35772
|
-
return this.focusedInputId ? this.inputs[this.focusedInputId] : null;
|
|
35773
|
-
}
|
|
35774
35790
|
// ---------------------------------------------------------------------------
|
|
35775
35791
|
// Command Handling
|
|
35776
35792
|
// ---------------------------------------------------------------------------
|
|
@@ -40846,11 +40862,9 @@
|
|
|
40846
40862
|
onComposerContentFocused: Function,
|
|
40847
40863
|
};
|
|
40848
40864
|
|
|
40849
|
-
// -----------------------------------------------------------------------------
|
|
40850
|
-
// TopBar
|
|
40851
|
-
// -----------------------------------------------------------------------------
|
|
40852
40865
|
css /* scss */ `
|
|
40853
40866
|
.o-font-size-editor {
|
|
40867
|
+
height: calc(100% - 4px);
|
|
40854
40868
|
input.o-font-size {
|
|
40855
40869
|
height: 20px;
|
|
40856
40870
|
width: 23px;
|
|
@@ -40928,6 +40942,7 @@
|
|
|
40928
40942
|
FontSizeEditor.props = {
|
|
40929
40943
|
onToggle: Function,
|
|
40930
40944
|
dropdownStyle: String,
|
|
40945
|
+
class: String,
|
|
40931
40946
|
};
|
|
40932
40947
|
|
|
40933
40948
|
const FORMATS = [
|
|
@@ -44371,15 +44386,10 @@
|
|
|
44371
44386
|
`;
|
|
44372
44387
|
}
|
|
44373
44388
|
function addFilterColumns(table) {
|
|
44374
|
-
const tableZone = toZone(table.range);
|
|
44375
44389
|
const columns = [];
|
|
44376
|
-
for (const
|
|
44377
|
-
const filter = table.filters[i];
|
|
44378
|
-
if (!filter || !filter.filteredValues.length) {
|
|
44379
|
-
continue;
|
|
44380
|
-
}
|
|
44390
|
+
for (const filter of table.filters) {
|
|
44381
44391
|
const colXml = escapeXml /*xml*/ `
|
|
44382
|
-
<filterColumn ${formatAttributes([["colId",
|
|
44392
|
+
<filterColumn ${formatAttributes([["colId", filter.colId]])}>
|
|
44383
44393
|
${addFilter(filter)}
|
|
44384
44394
|
</filterColumn>
|
|
44385
44395
|
`;
|
|
@@ -44388,9 +44398,10 @@
|
|
|
44388
44398
|
return columns;
|
|
44389
44399
|
}
|
|
44390
44400
|
function addFilter(filter) {
|
|
44391
|
-
const filterValues = filter.
|
|
44401
|
+
const filterValues = filter.displayedValues.map((val) => escapeXml /*xml*/ `<filter ${formatAttributes([["val", val]])}/>`);
|
|
44402
|
+
const filterAttributes = filter.displayBlanks ? [["blank", 1]] : [];
|
|
44392
44403
|
return escapeXml /*xml*/ `
|
|
44393
|
-
<filters>
|
|
44404
|
+
<filters ${formatAttributes(filterAttributes)}>
|
|
44394
44405
|
${joinXmlNodes(filterValues)}
|
|
44395
44406
|
</filters>
|
|
44396
44407
|
`;
|
|
@@ -45367,9 +45378,9 @@
|
|
|
45367
45378
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
45368
45379
|
|
|
45369
45380
|
|
|
45370
|
-
__info__.version = '16.2.
|
|
45371
|
-
__info__.date = '2023-06-
|
|
45372
|
-
__info__.hash = '
|
|
45381
|
+
__info__.version = '16.2.10';
|
|
45382
|
+
__info__.date = '2023-06-26T14:33:27.213Z';
|
|
45383
|
+
__info__.hash = '1d3f47c';
|
|
45373
45384
|
|
|
45374
45385
|
|
|
45375
45386
|
})(this.o_spreadsheet = this.o_spreadsheet || {}, owl);
|