@odoo/o-spreadsheet 15.0.19 → 15.0.21
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 +77 -62
- package/dist/o-spreadsheet.d.ts +2 -0
- package/dist/o-spreadsheet.esm.js +77 -62
- package/dist/o-spreadsheet.iife.js +77 -62
- package/dist/o-spreadsheet.iife.min.js +368 -368
- package/package.json +1 -1
|
@@ -2975,7 +2975,7 @@ function deepEquals(o1, o2) {
|
|
|
2975
2975
|
if (typeof o1 !== typeof o2)
|
|
2976
2976
|
return false;
|
|
2977
2977
|
if (typeof o1 !== "object")
|
|
2978
|
-
return
|
|
2978
|
+
return false;
|
|
2979
2979
|
// Objects can have different keys if the values are undefined
|
|
2980
2980
|
const keys = new Set();
|
|
2981
2981
|
Object.keys(o1).forEach((key) => keys.add(key));
|
|
@@ -2993,6 +2993,34 @@ function deepEquals(o1, o2) {
|
|
|
2993
2993
|
}
|
|
2994
2994
|
}
|
|
2995
2995
|
return true;
|
|
2996
|
+
}
|
|
2997
|
+
/**
|
|
2998
|
+
* Alternative to Math.max that works with large arrays.
|
|
2999
|
+
* Typically useful for arrays bigger than 100k elements.
|
|
3000
|
+
*/
|
|
3001
|
+
function largeMax(array) {
|
|
3002
|
+
let len = array.length;
|
|
3003
|
+
if (len < 100000)
|
|
3004
|
+
return Math.max(...array);
|
|
3005
|
+
let max = -Infinity;
|
|
3006
|
+
while (len--) {
|
|
3007
|
+
max = array[len] > max ? array[len] : max;
|
|
3008
|
+
}
|
|
3009
|
+
return max;
|
|
3010
|
+
}
|
|
3011
|
+
/**
|
|
3012
|
+
* Alternative to Math.min that works with large arrays.
|
|
3013
|
+
* Typically useful for arrays bigger than 100k elements.
|
|
3014
|
+
*/
|
|
3015
|
+
function largeMin(array) {
|
|
3016
|
+
let len = array.length;
|
|
3017
|
+
if (len < 100000)
|
|
3018
|
+
return Math.min(...array);
|
|
3019
|
+
let min = +Infinity;
|
|
3020
|
+
while (len--) {
|
|
3021
|
+
min = array[len] < min ? array[len] : min;
|
|
3022
|
+
}
|
|
3023
|
+
return min;
|
|
2996
3024
|
}
|
|
2997
3025
|
|
|
2998
3026
|
/**
|
|
@@ -3610,9 +3638,10 @@ function exportRows(rows, exportDefaults = false) {
|
|
|
3610
3638
|
* https://stackoverflow.com/questions/105034/create-guid-uuid-in-javascript
|
|
3611
3639
|
* */
|
|
3612
3640
|
class UuidGenerator {
|
|
3613
|
-
constructor() {
|
|
3641
|
+
constructor(isFast = false) {
|
|
3614
3642
|
this.isFastIdStrategy = false;
|
|
3615
3643
|
this.fastIdStart = 0;
|
|
3644
|
+
this.setIsFastStrategy(isFast);
|
|
3616
3645
|
}
|
|
3617
3646
|
setIsFastStrategy(isFast) {
|
|
3618
3647
|
this.isFastIdStrategy = isFast;
|
|
@@ -9523,6 +9552,7 @@ class CellPlugin extends CorePlugin {
|
|
|
9523
9552
|
constructor() {
|
|
9524
9553
|
super(...arguments);
|
|
9525
9554
|
this.cells = {};
|
|
9555
|
+
this.cellUuidGenerator = new UuidGenerator(true);
|
|
9526
9556
|
this.createCell = cellFactory(this.getters);
|
|
9527
9557
|
}
|
|
9528
9558
|
adaptRanges(applyChange, sheetId) {
|
|
@@ -9702,7 +9732,7 @@ class CellPlugin extends CorePlugin {
|
|
|
9702
9732
|
}
|
|
9703
9733
|
importCell(sheet, cellData, normalizedStyles) {
|
|
9704
9734
|
const style = (cellData.style && normalizedStyles[cellData.style]) || undefined;
|
|
9705
|
-
const cellId = this.
|
|
9735
|
+
const cellId = this.cellUuidGenerator.uuidv4();
|
|
9706
9736
|
const properties = { format: cellData === null || cellData === void 0 ? void 0 : cellData.format, style };
|
|
9707
9737
|
return this.createCell(cellId, (cellData === null || cellData === void 0 ? void 0 : cellData.content) || "", properties, sheet.id);
|
|
9708
9738
|
}
|
|
@@ -9885,7 +9915,7 @@ class CellPlugin extends CorePlugin {
|
|
|
9885
9915
|
}
|
|
9886
9916
|
return;
|
|
9887
9917
|
}
|
|
9888
|
-
const cellId = (before === null || before === void 0 ? void 0 : before.id) || this.
|
|
9918
|
+
const cellId = (before === null || before === void 0 ? void 0 : before.id) || this.cellUuidGenerator.uuidv4();
|
|
9889
9919
|
const didContentChange = hasContent;
|
|
9890
9920
|
const properties = { format, style };
|
|
9891
9921
|
const cell = this.createCell(cellId, afterContent, properties, sheet.id);
|
|
@@ -12032,8 +12062,8 @@ class SheetPlugin extends CorePlugin {
|
|
|
12032
12062
|
getImportedSheetSize(data) {
|
|
12033
12063
|
const positions = Object.keys(data.cells).map(toCartesian);
|
|
12034
12064
|
return {
|
|
12035
|
-
rowNumber: Math.max(data.rowNumber,
|
|
12036
|
-
colNumber: Math.max(data.colNumber,
|
|
12065
|
+
rowNumber: Math.max(data.rowNumber, largeMax(positions.map(([col, row]) => row + 1))),
|
|
12066
|
+
colNumber: Math.max(data.colNumber, largeMax(positions.map(([col, row]) => col + 1))),
|
|
12037
12067
|
};
|
|
12038
12068
|
}
|
|
12039
12069
|
// ----------------------------------------------------
|
|
@@ -12570,8 +12600,8 @@ const DELETE_CONTENT_ROWS_NAME = (env) => {
|
|
|
12570
12600
|
let last;
|
|
12571
12601
|
const activesRows = env.getters.getActiveRows();
|
|
12572
12602
|
if (activesRows.size !== 0) {
|
|
12573
|
-
first =
|
|
12574
|
-
last =
|
|
12603
|
+
first = largeMin([...activesRows]);
|
|
12604
|
+
last = largeMax([...activesRows]);
|
|
12575
12605
|
}
|
|
12576
12606
|
else {
|
|
12577
12607
|
const zone = env.getters.getSelectedZones()[0];
|
|
@@ -12596,8 +12626,8 @@ const DELETE_CONTENT_COLUMNS_NAME = (env) => {
|
|
|
12596
12626
|
let last;
|
|
12597
12627
|
const activeCols = env.getters.getActiveCols();
|
|
12598
12628
|
if (activeCols.size !== 0) {
|
|
12599
|
-
first =
|
|
12600
|
-
last =
|
|
12629
|
+
first = largeMin([...activeCols]);
|
|
12630
|
+
last = largeMax([...activeCols]);
|
|
12601
12631
|
}
|
|
12602
12632
|
else {
|
|
12603
12633
|
const zone = env.getters.getSelectedZones()[0];
|
|
@@ -12622,8 +12652,8 @@ const REMOVE_ROWS_NAME = (env) => {
|
|
|
12622
12652
|
let last;
|
|
12623
12653
|
const activesRows = env.getters.getActiveRows();
|
|
12624
12654
|
if (activesRows.size !== 0) {
|
|
12625
|
-
first =
|
|
12626
|
-
last =
|
|
12655
|
+
first = largeMin([...activesRows]);
|
|
12656
|
+
last = largeMax([...activesRows]);
|
|
12627
12657
|
}
|
|
12628
12658
|
else {
|
|
12629
12659
|
const zone = env.getters.getSelectedZones()[0];
|
|
@@ -12654,8 +12684,8 @@ const REMOVE_COLUMNS_NAME = (env) => {
|
|
|
12654
12684
|
let last;
|
|
12655
12685
|
const activeCols = env.getters.getActiveCols();
|
|
12656
12686
|
if (activeCols.size !== 0) {
|
|
12657
|
-
first =
|
|
12658
|
-
last =
|
|
12687
|
+
first = largeMin([...activeCols]);
|
|
12688
|
+
last = largeMax([...activeCols]);
|
|
12659
12689
|
}
|
|
12660
12690
|
else {
|
|
12661
12691
|
const zone = env.getters.getSelectedZones()[0];
|
|
@@ -12720,7 +12750,7 @@ const INSERT_ROWS_BEFORE_ACTION = (env) => {
|
|
|
12720
12750
|
let row;
|
|
12721
12751
|
let quantity;
|
|
12722
12752
|
if (activeRows.size) {
|
|
12723
|
-
row =
|
|
12753
|
+
row = largeMin([...activeRows]);
|
|
12724
12754
|
quantity = activeRows.size;
|
|
12725
12755
|
}
|
|
12726
12756
|
else {
|
|
@@ -12752,7 +12782,7 @@ const INSERT_ROWS_AFTER_ACTION = (env) => {
|
|
|
12752
12782
|
let row;
|
|
12753
12783
|
let quantity;
|
|
12754
12784
|
if (activeRows.size) {
|
|
12755
|
-
row =
|
|
12785
|
+
row = largeMax([...activeRows]);
|
|
12756
12786
|
quantity = activeRows.size;
|
|
12757
12787
|
}
|
|
12758
12788
|
else {
|
|
@@ -12793,7 +12823,7 @@ const INSERT_COLUMNS_BEFORE_ACTION = (env) => {
|
|
|
12793
12823
|
let column;
|
|
12794
12824
|
let quantity;
|
|
12795
12825
|
if (activeCols.size) {
|
|
12796
|
-
column =
|
|
12826
|
+
column = largeMin([...activeCols]);
|
|
12797
12827
|
quantity = activeCols.size;
|
|
12798
12828
|
}
|
|
12799
12829
|
else {
|
|
@@ -12827,7 +12857,7 @@ const INSERT_COLUMNS_AFTER_ACTION = (env) => {
|
|
|
12827
12857
|
let column;
|
|
12828
12858
|
let quantity;
|
|
12829
12859
|
if (activeCols.size) {
|
|
12830
|
-
column =
|
|
12860
|
+
column = largeMax([...activeCols]);
|
|
12831
12861
|
quantity = activeCols.size;
|
|
12832
12862
|
}
|
|
12833
12863
|
else {
|
|
@@ -16569,13 +16599,13 @@ class AutomaticSumPlugin extends UIPlugin {
|
|
|
16569
16599
|
const cells = mapCellsInZone(zone, sheet, (cell) => cell, undefined).flat();
|
|
16570
16600
|
const cellPositions = range(end, -1, -1);
|
|
16571
16601
|
const invalidCells = cellPositions.filter((position) => { var _a; return cells[position] && !((_a = cells[position]) === null || _a === void 0 ? void 0 : _a.isAutoSummable); });
|
|
16572
|
-
const maxValidPosition =
|
|
16602
|
+
const maxValidPosition = largeMax(invalidCells);
|
|
16573
16603
|
const numberSequences = groupConsecutive(cellPositions.filter((position) => this.isNumber(cells[position])));
|
|
16574
16604
|
const firstSequence = numberSequences[0] || [];
|
|
16575
|
-
if (
|
|
16605
|
+
if (largeMax(firstSequence) < maxValidPosition) {
|
|
16576
16606
|
return Infinity;
|
|
16577
16607
|
}
|
|
16578
|
-
return
|
|
16608
|
+
return largeMin(firstSequence);
|
|
16579
16609
|
}
|
|
16580
16610
|
shouldFindData(sheetId, zone) {
|
|
16581
16611
|
return this.getters.isEmpty(sheetId, zone) || this.getters.isSingleCellOrMerge(sheetId, zone);
|
|
@@ -22266,13 +22296,13 @@ class SheetUIPlugin extends UIPlugin {
|
|
|
22266
22296
|
getColMaxWidth(sheetId, index) {
|
|
22267
22297
|
const cells = this.getters.getColCells(sheetId, index);
|
|
22268
22298
|
const sizes = cells.map((cell) => this.getCellWidth(cell));
|
|
22269
|
-
return Math.max(0,
|
|
22299
|
+
return Math.max(0, largeMax(sizes));
|
|
22270
22300
|
}
|
|
22271
22301
|
getRowMaxHeight(sheetId, index) {
|
|
22272
22302
|
const sheet = this.getters.getSheet(sheetId);
|
|
22273
22303
|
const cells = Object.values(sheet.rows[index].cells);
|
|
22274
22304
|
const sizes = cells.map((cell) => this.getCellHeight(cell));
|
|
22275
|
-
return Math.max(0,
|
|
22305
|
+
return Math.max(0, largeMax(sizes));
|
|
22276
22306
|
}
|
|
22277
22307
|
interactiveRenameSheet(sheetId, title) {
|
|
22278
22308
|
const placeholder = this.getters.getSheetName(sheetId);
|
|
@@ -23691,8 +23721,8 @@ class RangeAdapter {
|
|
|
23691
23721
|
let newRange = range;
|
|
23692
23722
|
let changeType = "NONE";
|
|
23693
23723
|
for (let group of groups) {
|
|
23694
|
-
const min =
|
|
23695
|
-
const max =
|
|
23724
|
+
const min = largeMin(group);
|
|
23725
|
+
const max = largeMax(group);
|
|
23696
23726
|
if (range.zone[start] <= min && min <= range.zone[end]) {
|
|
23697
23727
|
const toRemove = Math.min(range.zone[end], max) - min + 1;
|
|
23698
23728
|
changeType = "RESIZE";
|
|
@@ -24277,10 +24307,6 @@ function extractStyle(cell, data) {
|
|
|
24277
24307
|
if (cell.style) {
|
|
24278
24308
|
style = data.styles[cell.style];
|
|
24279
24309
|
}
|
|
24280
|
-
let border = {};
|
|
24281
|
-
if (cell.border) {
|
|
24282
|
-
border = data.borders[cell.border];
|
|
24283
|
-
}
|
|
24284
24310
|
const styles = {
|
|
24285
24311
|
font: {
|
|
24286
24312
|
size: (style === null || style === void 0 ? void 0 : style.fontSize) || DEFAULT_FONT_SIZE,
|
|
@@ -24294,7 +24320,7 @@ function extractStyle(cell, data) {
|
|
|
24294
24320
|
}
|
|
24295
24321
|
: { reservedAttribute: "none" },
|
|
24296
24322
|
numFmt: cell.format,
|
|
24297
|
-
border: border ||
|
|
24323
|
+
border: cell.border || 0,
|
|
24298
24324
|
verticalAlignment: "center",
|
|
24299
24325
|
horizontalAlignment: style === null || style === void 0 ? void 0 : style.align,
|
|
24300
24326
|
};
|
|
@@ -24305,21 +24331,17 @@ function extractStyle(cell, data) {
|
|
|
24305
24331
|
return styles;
|
|
24306
24332
|
}
|
|
24307
24333
|
function normalizeStyle(construct, styles) {
|
|
24308
|
-
const { id: fontId } = pushElement(styles["font"], construct.fonts);
|
|
24309
|
-
const { id: fillId } = pushElement(styles["fill"], construct.fills);
|
|
24310
|
-
const { id: borderId } = pushElement(styles["border"], construct.borders);
|
|
24311
24334
|
// Normalize this
|
|
24312
24335
|
const numFmtId = convertFormat(styles["numFmt"], construct.numFmts);
|
|
24313
24336
|
const style = {
|
|
24314
|
-
fontId,
|
|
24315
|
-
fillId,
|
|
24316
|
-
borderId,
|
|
24337
|
+
fontId: pushElement(styles.font, construct.fonts),
|
|
24338
|
+
fillId: pushElement(styles.fill, construct.fills),
|
|
24339
|
+
borderId: styles.border,
|
|
24317
24340
|
numFmtId,
|
|
24318
24341
|
verticalAlignment: styles["verticalAlignment"],
|
|
24319
24342
|
horizontalAlignment: styles["horizontalAlignment"],
|
|
24320
24343
|
};
|
|
24321
|
-
|
|
24322
|
-
return id;
|
|
24344
|
+
return pushElement(style, construct.styles);
|
|
24323
24345
|
}
|
|
24324
24346
|
function convertFormat(format, numFmtStructure) {
|
|
24325
24347
|
if (!format) {
|
|
@@ -24327,8 +24349,7 @@ function convertFormat(format, numFmtStructure) {
|
|
|
24327
24349
|
}
|
|
24328
24350
|
let formatId = XLSX_FORMAT_MAP[format];
|
|
24329
24351
|
if (!formatId) {
|
|
24330
|
-
|
|
24331
|
-
formatId = id + FIRST_NUMFMT_ID;
|
|
24352
|
+
formatId = pushElement(format, numFmtStructure) + FIRST_NUMFMT_ID;
|
|
24332
24353
|
}
|
|
24333
24354
|
return formatId;
|
|
24334
24355
|
}
|
|
@@ -24353,20 +24374,15 @@ function addRelsToFile(relsFiles, path, rel) {
|
|
|
24353
24374
|
return id;
|
|
24354
24375
|
}
|
|
24355
24376
|
function pushElement(property, propertyList) {
|
|
24356
|
-
|
|
24357
|
-
|
|
24358
|
-
|
|
24377
|
+
let len = propertyList.length;
|
|
24378
|
+
const operator = typeof property === "object" ? deepEquals : (a, b) => a === b;
|
|
24379
|
+
for (let i = 0; i < len; i++) {
|
|
24380
|
+
if (operator(property, propertyList[i])) {
|
|
24381
|
+
return i;
|
|
24359
24382
|
}
|
|
24360
24383
|
}
|
|
24361
|
-
|
|
24362
|
-
|
|
24363
|
-
propertyList.push(property);
|
|
24364
|
-
elemId = propertyList.length - 1;
|
|
24365
|
-
}
|
|
24366
|
-
return {
|
|
24367
|
-
id: elemId,
|
|
24368
|
-
list: propertyList,
|
|
24369
|
-
};
|
|
24384
|
+
propertyList[propertyList.length] = property;
|
|
24385
|
+
return propertyList.length - 1;
|
|
24370
24386
|
}
|
|
24371
24387
|
const chartIds = [];
|
|
24372
24388
|
/**
|
|
@@ -24447,7 +24463,8 @@ function parseXML(xmlString) {
|
|
|
24447
24463
|
}
|
|
24448
24464
|
return document;
|
|
24449
24465
|
}
|
|
24450
|
-
function getDefaultXLSXStructure() {
|
|
24466
|
+
function getDefaultXLSXStructure(data) {
|
|
24467
|
+
const borders = [{}, ...Object.values(data.borders)];
|
|
24451
24468
|
return {
|
|
24452
24469
|
relsFiles: [],
|
|
24453
24470
|
sharedStrings: [],
|
|
@@ -24470,7 +24487,7 @@ function getDefaultXLSXStructure() {
|
|
|
24470
24487
|
},
|
|
24471
24488
|
],
|
|
24472
24489
|
fills: [{ reservedAttribute: "none" }, { reservedAttribute: "gray125" }],
|
|
24473
|
-
borders
|
|
24490
|
+
borders,
|
|
24474
24491
|
numFmts: [],
|
|
24475
24492
|
dxfs: [],
|
|
24476
24493
|
};
|
|
@@ -24897,8 +24914,7 @@ function addContent(content, sharedStrings) {
|
|
|
24897
24914
|
attrs.push(["t", "b"]);
|
|
24898
24915
|
}
|
|
24899
24916
|
else if (!isNumber(value)) {
|
|
24900
|
-
|
|
24901
|
-
value = id.toString();
|
|
24917
|
+
value = pushElement(content, sharedStrings);
|
|
24902
24918
|
attrs.push(["t", "s"]);
|
|
24903
24919
|
}
|
|
24904
24920
|
return { attrs, node: escapeXml /*xml*/ `<v>${value}</v>` };
|
|
@@ -25023,8 +25039,7 @@ function addCellIsRule(cf, rule, dxfs) {
|
|
|
25023
25039
|
if (rule.style.fillColor) {
|
|
25024
25040
|
dxf.fill = { fgColor: rule.style.fillColor };
|
|
25025
25041
|
}
|
|
25026
|
-
|
|
25027
|
-
ruleAttributes.push(["dxfId", id]);
|
|
25042
|
+
ruleAttributes.push(["dxfId", pushElement(dxf, dxfs)]);
|
|
25028
25043
|
return escapeXml /*xml*/ `
|
|
25029
25044
|
<conditionalFormatting sqref="${cf.ranges.join(" ")}">
|
|
25030
25045
|
<cfRule ${formatAttributes(ruleAttributes)}>
|
|
@@ -25633,7 +25648,7 @@ function addMerges(merges) {
|
|
|
25633
25648
|
*/
|
|
25634
25649
|
function getXLSX(data) {
|
|
25635
25650
|
const files = [];
|
|
25636
|
-
const construct = getDefaultXLSXStructure();
|
|
25651
|
+
const construct = getDefaultXLSXStructure(data);
|
|
25637
25652
|
files.push(createWorkbook(data, construct));
|
|
25638
25653
|
files.push(...createWorksheets(data, construct));
|
|
25639
25654
|
files.push(createStylesSheet(construct));
|
|
@@ -31508,6 +31523,6 @@ exports.registries = registries;
|
|
|
31508
31523
|
exports.setTranslationMethod = setTranslationMethod;
|
|
31509
31524
|
|
|
31510
31525
|
|
|
31511
|
-
__info__.version = '15.0.
|
|
31512
|
-
__info__.date = '2024-
|
|
31513
|
-
__info__.hash = '
|
|
31526
|
+
__info__.version = '15.0.21';
|
|
31527
|
+
__info__.date = '2024-04-10T12:08:56.252Z';
|
|
31528
|
+
__info__.hash = '4d672af';
|
package/dist/o-spreadsheet.d.ts
CHANGED
|
@@ -92,6 +92,7 @@ declare function formatDecimal(n: number, decimals: number, sep?: string): strin
|
|
|
92
92
|
declare class UuidGenerator {
|
|
93
93
|
private isFastIdStrategy;
|
|
94
94
|
private fastIdStart;
|
|
95
|
+
constructor(isFast?: boolean);
|
|
95
96
|
setIsFastStrategy(isFast: boolean): void;
|
|
96
97
|
uuidv4(): string;
|
|
97
98
|
}
|
|
@@ -2344,6 +2345,7 @@ declare class CellPlugin extends CorePlugin<CoreState> implements CoreState {
|
|
|
2344
2345
|
[id: string]: Cell;
|
|
2345
2346
|
};
|
|
2346
2347
|
};
|
|
2348
|
+
private cellUuidGenerator;
|
|
2347
2349
|
private createCell;
|
|
2348
2350
|
adaptRanges(applyChange: ApplyRangeChange, sheetId?: UID): void;
|
|
2349
2351
|
allowDispatch(cmd: CoreCommand): CommandResult;
|