@odoo/o-spreadsheet 16.1.14 → 16.1.15
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 +46 -34
- package/dist/o-spreadsheet.d.ts +161 -160
- package/dist/o-spreadsheet.esm.js +46 -34
- package/dist/o-spreadsheet.iife.js +46 -34
- package/dist/o-spreadsheet.iife.min.js +229 -229
- package/package.json +4 -4
|
@@ -726,12 +726,20 @@ function getDefaultCellHeight(style) {
|
|
|
726
726
|
return computeTextLinesHeight(fontSize) + 2 * PADDING_AUTORESIZE_VERTICAL;
|
|
727
727
|
}
|
|
728
728
|
function computeTextWidth(context, text, style) {
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
729
|
+
const font = computeTextFont(style);
|
|
730
|
+
if (!textWidthCache[font]) {
|
|
731
|
+
textWidthCache[font] = {};
|
|
732
|
+
}
|
|
733
|
+
if (textWidthCache[font][text] === undefined) {
|
|
734
|
+
context.save();
|
|
735
|
+
context.font = font;
|
|
736
|
+
const textWidth = context.measureText(text).width;
|
|
737
|
+
context.restore();
|
|
738
|
+
textWidthCache[font][text] = textWidth;
|
|
739
|
+
}
|
|
740
|
+
return textWidthCache[font][text];
|
|
734
741
|
}
|
|
742
|
+
const textWidthCache = {};
|
|
735
743
|
function computeTextFont(style) {
|
|
736
744
|
const italic = style.italic ? "italic " : "";
|
|
737
745
|
const weight = style.bold ? "bold" : DEFAULT_FONT_WEIGHT;
|
|
@@ -29560,7 +29568,14 @@ class FiltersPlugin extends CorePlugin {
|
|
|
29560
29568
|
this.history.update("tables", filterTables);
|
|
29561
29569
|
break;
|
|
29562
29570
|
case "DUPLICATE_SHEET":
|
|
29563
|
-
|
|
29571
|
+
const tables = {};
|
|
29572
|
+
for (const filterTable of Object.values(this.tables[cmd.sheetId] || {})) {
|
|
29573
|
+
if (filterTable) {
|
|
29574
|
+
const newFilterTable = deepCopy(filterTable);
|
|
29575
|
+
tables[newFilterTable.id] = newFilterTable;
|
|
29576
|
+
}
|
|
29577
|
+
}
|
|
29578
|
+
this.history.update("tables", cmd.sheetIdTo, tables);
|
|
29564
29579
|
break;
|
|
29565
29580
|
case "ADD_COLUMNS_ROWS":
|
|
29566
29581
|
this.onAddColumnsRows(cmd);
|
|
@@ -33104,6 +33119,7 @@ class FilterEvaluationPlugin extends UIPlugin {
|
|
|
33104
33119
|
}
|
|
33105
33120
|
exportForExcel(data) {
|
|
33106
33121
|
for (const sheetData of data.sheets) {
|
|
33122
|
+
const sheetId = sheetData.id;
|
|
33107
33123
|
for (const tableData of sheetData.filterTables) {
|
|
33108
33124
|
const tableZone = toZone(tableData.range);
|
|
33109
33125
|
const filters = [];
|
|
@@ -33119,20 +33135,20 @@ class FilterEvaluationPlugin extends UIPlugin {
|
|
|
33119
33135
|
if (!filter)
|
|
33120
33136
|
continue;
|
|
33121
33137
|
const valuesInFilterZone = filter.filteredZone
|
|
33122
|
-
? positions(filter.filteredZone)
|
|
33123
|
-
.map(({ col, row }) => this.getters.getEvaluatedCell({ sheetId: sheetData.id, col, row }))
|
|
33124
|
-
.filter((cell) => cell.type !== CellValueType.empty)
|
|
33125
|
-
.map((cell) => cell.formattedValue)
|
|
33138
|
+
? positions(filter.filteredZone).map((position) => this.getters.getEvaluatedCell({ sheetId, ...position }).formattedValue)
|
|
33126
33139
|
: [];
|
|
33127
|
-
|
|
33128
|
-
|
|
33129
|
-
|
|
33130
|
-
|
|
33131
|
-
|
|
33132
|
-
|
|
33133
|
-
|
|
33134
|
-
|
|
33135
|
-
|
|
33140
|
+
if (filteredValues.length) {
|
|
33141
|
+
const xlsxDisplayedValues = valuesInFilterZone
|
|
33142
|
+
.filter((val) => val)
|
|
33143
|
+
.filter((val) => !filteredValues.includes(val));
|
|
33144
|
+
filters.push({
|
|
33145
|
+
colId: i,
|
|
33146
|
+
displayedValues: [...new Set(xlsxDisplayedValues)],
|
|
33147
|
+
displayBlanks: !filteredValues.includes("") && valuesInFilterZone.some((val) => !val),
|
|
33148
|
+
});
|
|
33149
|
+
}
|
|
33150
|
+
// In xlsx, filter header should ALWAYS be a string and should be unique in the table
|
|
33151
|
+
const headerPosition = { col: filter.col, row: filter.zoneWithHeaders.top, sheetId };
|
|
33136
33152
|
const headerString = this.getters.getEvaluatedCell(headerPosition).formattedValue;
|
|
33137
33153
|
const headerName = this.getUniqueColNameForExcel(i, headerString, headerNames);
|
|
33138
33154
|
headerNames.push(headerName);
|
|
@@ -36161,15 +36177,15 @@ SelectionInputPlugin.getters = [];
|
|
|
36161
36177
|
* This plugin handles this internal state.
|
|
36162
36178
|
*/
|
|
36163
36179
|
class SelectionInputsManagerPlugin extends UIPlugin {
|
|
36180
|
+
get currentInput() {
|
|
36181
|
+
return this.focusedInputId ? this.inputs[this.focusedInputId] : null;
|
|
36182
|
+
}
|
|
36164
36183
|
constructor(config) {
|
|
36165
36184
|
super(config);
|
|
36166
36185
|
this.config = config;
|
|
36167
36186
|
this.inputs = {};
|
|
36168
36187
|
this.focusedInputId = null;
|
|
36169
36188
|
}
|
|
36170
|
-
get currentInput() {
|
|
36171
|
-
return this.focusedInputId ? this.inputs[this.focusedInputId] : null;
|
|
36172
|
-
}
|
|
36173
36189
|
// ---------------------------------------------------------------------------
|
|
36174
36190
|
// Command Handling
|
|
36175
36191
|
// ---------------------------------------------------------------------------
|
|
@@ -43300,15 +43316,10 @@ function addAutoFilter(table) {
|
|
|
43300
43316
|
`;
|
|
43301
43317
|
}
|
|
43302
43318
|
function addFilterColumns(table) {
|
|
43303
|
-
const tableZone = toZone(table.range);
|
|
43304
43319
|
const columns = [];
|
|
43305
|
-
for (const
|
|
43306
|
-
const filter = table.filters[i];
|
|
43307
|
-
if (!filter || !filter.filteredValues.length) {
|
|
43308
|
-
continue;
|
|
43309
|
-
}
|
|
43320
|
+
for (const filter of table.filters) {
|
|
43310
43321
|
const colXml = escapeXml /*xml*/ `
|
|
43311
|
-
<filterColumn ${formatAttributes([["colId",
|
|
43322
|
+
<filterColumn ${formatAttributes([["colId", filter.colId]])}>
|
|
43312
43323
|
${addFilter(filter)}
|
|
43313
43324
|
</filterColumn>
|
|
43314
43325
|
`;
|
|
@@ -43317,9 +43328,10 @@ function addFilterColumns(table) {
|
|
|
43317
43328
|
return columns;
|
|
43318
43329
|
}
|
|
43319
43330
|
function addFilter(filter) {
|
|
43320
|
-
const filterValues = filter.
|
|
43331
|
+
const filterValues = filter.displayedValues.map((val) => escapeXml /*xml*/ `<filter ${formatAttributes([["val", val]])}/>`);
|
|
43332
|
+
const filterAttributes = filter.displayBlanks ? [["blank", 1]] : [];
|
|
43321
43333
|
return escapeXml /*xml*/ `
|
|
43322
|
-
<filters>
|
|
43334
|
+
<filters ${formatAttributes(filterAttributes)}>
|
|
43323
43335
|
${joinXmlNodes(filterValues)}
|
|
43324
43336
|
</filters>
|
|
43325
43337
|
`;
|
|
@@ -44272,6 +44284,6 @@ exports.setTranslationMethod = setTranslationMethod;
|
|
|
44272
44284
|
exports.tokenize = tokenize;
|
|
44273
44285
|
|
|
44274
44286
|
|
|
44275
|
-
__info__.version = '16.1.
|
|
44276
|
-
__info__.date = '2023-06-
|
|
44277
|
-
__info__.hash = '
|
|
44287
|
+
__info__.version = '16.1.15';
|
|
44288
|
+
__info__.date = '2023-06-26T14:33:07.859Z';
|
|
44289
|
+
__info__.hash = '2b264ad';
|