@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
|
@@ -2952,7 +2952,7 @@ function deepEquals(o1, o2) {
|
|
|
2952
2952
|
if (typeof o1 !== typeof o2)
|
|
2953
2953
|
return false;
|
|
2954
2954
|
if (typeof o1 !== "object")
|
|
2955
|
-
return
|
|
2955
|
+
return false;
|
|
2956
2956
|
// Objects can have different keys if the values are undefined
|
|
2957
2957
|
const keys = new Set();
|
|
2958
2958
|
Object.keys(o1).forEach((key) => keys.add(key));
|
|
@@ -2970,6 +2970,34 @@ function deepEquals(o1, o2) {
|
|
|
2970
2970
|
}
|
|
2971
2971
|
}
|
|
2972
2972
|
return true;
|
|
2973
|
+
}
|
|
2974
|
+
/**
|
|
2975
|
+
* Alternative to Math.max that works with large arrays.
|
|
2976
|
+
* Typically useful for arrays bigger than 100k elements.
|
|
2977
|
+
*/
|
|
2978
|
+
function largeMax(array) {
|
|
2979
|
+
let len = array.length;
|
|
2980
|
+
if (len < 100000)
|
|
2981
|
+
return Math.max(...array);
|
|
2982
|
+
let max = -Infinity;
|
|
2983
|
+
while (len--) {
|
|
2984
|
+
max = array[len] > max ? array[len] : max;
|
|
2985
|
+
}
|
|
2986
|
+
return max;
|
|
2987
|
+
}
|
|
2988
|
+
/**
|
|
2989
|
+
* Alternative to Math.min that works with large arrays.
|
|
2990
|
+
* Typically useful for arrays bigger than 100k elements.
|
|
2991
|
+
*/
|
|
2992
|
+
function largeMin(array) {
|
|
2993
|
+
let len = array.length;
|
|
2994
|
+
if (len < 100000)
|
|
2995
|
+
return Math.min(...array);
|
|
2996
|
+
let min = +Infinity;
|
|
2997
|
+
while (len--) {
|
|
2998
|
+
min = array[len] < min ? array[len] : min;
|
|
2999
|
+
}
|
|
3000
|
+
return min;
|
|
2973
3001
|
}
|
|
2974
3002
|
|
|
2975
3003
|
/**
|
|
@@ -3587,9 +3615,10 @@ function exportRows(rows, exportDefaults = false) {
|
|
|
3587
3615
|
* https://stackoverflow.com/questions/105034/create-guid-uuid-in-javascript
|
|
3588
3616
|
* */
|
|
3589
3617
|
class UuidGenerator {
|
|
3590
|
-
constructor() {
|
|
3618
|
+
constructor(isFast = false) {
|
|
3591
3619
|
this.isFastIdStrategy = false;
|
|
3592
3620
|
this.fastIdStart = 0;
|
|
3621
|
+
this.setIsFastStrategy(isFast);
|
|
3593
3622
|
}
|
|
3594
3623
|
setIsFastStrategy(isFast) {
|
|
3595
3624
|
this.isFastIdStrategy = isFast;
|
|
@@ -9500,6 +9529,7 @@ class CellPlugin extends CorePlugin {
|
|
|
9500
9529
|
constructor() {
|
|
9501
9530
|
super(...arguments);
|
|
9502
9531
|
this.cells = {};
|
|
9532
|
+
this.cellUuidGenerator = new UuidGenerator(true);
|
|
9503
9533
|
this.createCell = cellFactory(this.getters);
|
|
9504
9534
|
}
|
|
9505
9535
|
adaptRanges(applyChange, sheetId) {
|
|
@@ -9679,7 +9709,7 @@ class CellPlugin extends CorePlugin {
|
|
|
9679
9709
|
}
|
|
9680
9710
|
importCell(sheet, cellData, normalizedStyles) {
|
|
9681
9711
|
const style = (cellData.style && normalizedStyles[cellData.style]) || undefined;
|
|
9682
|
-
const cellId = this.
|
|
9712
|
+
const cellId = this.cellUuidGenerator.uuidv4();
|
|
9683
9713
|
const properties = { format: cellData === null || cellData === void 0 ? void 0 : cellData.format, style };
|
|
9684
9714
|
return this.createCell(cellId, (cellData === null || cellData === void 0 ? void 0 : cellData.content) || "", properties, sheet.id);
|
|
9685
9715
|
}
|
|
@@ -9862,7 +9892,7 @@ class CellPlugin extends CorePlugin {
|
|
|
9862
9892
|
}
|
|
9863
9893
|
return;
|
|
9864
9894
|
}
|
|
9865
|
-
const cellId = (before === null || before === void 0 ? void 0 : before.id) || this.
|
|
9895
|
+
const cellId = (before === null || before === void 0 ? void 0 : before.id) || this.cellUuidGenerator.uuidv4();
|
|
9866
9896
|
const didContentChange = hasContent;
|
|
9867
9897
|
const properties = { format, style };
|
|
9868
9898
|
const cell = this.createCell(cellId, afterContent, properties, sheet.id);
|
|
@@ -12009,8 +12039,8 @@ class SheetPlugin extends CorePlugin {
|
|
|
12009
12039
|
getImportedSheetSize(data) {
|
|
12010
12040
|
const positions = Object.keys(data.cells).map(toCartesian);
|
|
12011
12041
|
return {
|
|
12012
|
-
rowNumber: Math.max(data.rowNumber,
|
|
12013
|
-
colNumber: Math.max(data.colNumber,
|
|
12042
|
+
rowNumber: Math.max(data.rowNumber, largeMax(positions.map(([col, row]) => row + 1))),
|
|
12043
|
+
colNumber: Math.max(data.colNumber, largeMax(positions.map(([col, row]) => col + 1))),
|
|
12014
12044
|
};
|
|
12015
12045
|
}
|
|
12016
12046
|
// ----------------------------------------------------
|
|
@@ -12547,8 +12577,8 @@ const DELETE_CONTENT_ROWS_NAME = (env) => {
|
|
|
12547
12577
|
let last;
|
|
12548
12578
|
const activesRows = env.getters.getActiveRows();
|
|
12549
12579
|
if (activesRows.size !== 0) {
|
|
12550
|
-
first =
|
|
12551
|
-
last =
|
|
12580
|
+
first = largeMin([...activesRows]);
|
|
12581
|
+
last = largeMax([...activesRows]);
|
|
12552
12582
|
}
|
|
12553
12583
|
else {
|
|
12554
12584
|
const zone = env.getters.getSelectedZones()[0];
|
|
@@ -12573,8 +12603,8 @@ const DELETE_CONTENT_COLUMNS_NAME = (env) => {
|
|
|
12573
12603
|
let last;
|
|
12574
12604
|
const activeCols = env.getters.getActiveCols();
|
|
12575
12605
|
if (activeCols.size !== 0) {
|
|
12576
|
-
first =
|
|
12577
|
-
last =
|
|
12606
|
+
first = largeMin([...activeCols]);
|
|
12607
|
+
last = largeMax([...activeCols]);
|
|
12578
12608
|
}
|
|
12579
12609
|
else {
|
|
12580
12610
|
const zone = env.getters.getSelectedZones()[0];
|
|
@@ -12599,8 +12629,8 @@ const REMOVE_ROWS_NAME = (env) => {
|
|
|
12599
12629
|
let last;
|
|
12600
12630
|
const activesRows = env.getters.getActiveRows();
|
|
12601
12631
|
if (activesRows.size !== 0) {
|
|
12602
|
-
first =
|
|
12603
|
-
last =
|
|
12632
|
+
first = largeMin([...activesRows]);
|
|
12633
|
+
last = largeMax([...activesRows]);
|
|
12604
12634
|
}
|
|
12605
12635
|
else {
|
|
12606
12636
|
const zone = env.getters.getSelectedZones()[0];
|
|
@@ -12631,8 +12661,8 @@ const REMOVE_COLUMNS_NAME = (env) => {
|
|
|
12631
12661
|
let last;
|
|
12632
12662
|
const activeCols = env.getters.getActiveCols();
|
|
12633
12663
|
if (activeCols.size !== 0) {
|
|
12634
|
-
first =
|
|
12635
|
-
last =
|
|
12664
|
+
first = largeMin([...activeCols]);
|
|
12665
|
+
last = largeMax([...activeCols]);
|
|
12636
12666
|
}
|
|
12637
12667
|
else {
|
|
12638
12668
|
const zone = env.getters.getSelectedZones()[0];
|
|
@@ -12697,7 +12727,7 @@ const INSERT_ROWS_BEFORE_ACTION = (env) => {
|
|
|
12697
12727
|
let row;
|
|
12698
12728
|
let quantity;
|
|
12699
12729
|
if (activeRows.size) {
|
|
12700
|
-
row =
|
|
12730
|
+
row = largeMin([...activeRows]);
|
|
12701
12731
|
quantity = activeRows.size;
|
|
12702
12732
|
}
|
|
12703
12733
|
else {
|
|
@@ -12729,7 +12759,7 @@ const INSERT_ROWS_AFTER_ACTION = (env) => {
|
|
|
12729
12759
|
let row;
|
|
12730
12760
|
let quantity;
|
|
12731
12761
|
if (activeRows.size) {
|
|
12732
|
-
row =
|
|
12762
|
+
row = largeMax([...activeRows]);
|
|
12733
12763
|
quantity = activeRows.size;
|
|
12734
12764
|
}
|
|
12735
12765
|
else {
|
|
@@ -12770,7 +12800,7 @@ const INSERT_COLUMNS_BEFORE_ACTION = (env) => {
|
|
|
12770
12800
|
let column;
|
|
12771
12801
|
let quantity;
|
|
12772
12802
|
if (activeCols.size) {
|
|
12773
|
-
column =
|
|
12803
|
+
column = largeMin([...activeCols]);
|
|
12774
12804
|
quantity = activeCols.size;
|
|
12775
12805
|
}
|
|
12776
12806
|
else {
|
|
@@ -12804,7 +12834,7 @@ const INSERT_COLUMNS_AFTER_ACTION = (env) => {
|
|
|
12804
12834
|
let column;
|
|
12805
12835
|
let quantity;
|
|
12806
12836
|
if (activeCols.size) {
|
|
12807
|
-
column =
|
|
12837
|
+
column = largeMax([...activeCols]);
|
|
12808
12838
|
quantity = activeCols.size;
|
|
12809
12839
|
}
|
|
12810
12840
|
else {
|
|
@@ -16546,13 +16576,13 @@ class AutomaticSumPlugin extends UIPlugin {
|
|
|
16546
16576
|
const cells = mapCellsInZone(zone, sheet, (cell) => cell, undefined).flat();
|
|
16547
16577
|
const cellPositions = range(end, -1, -1);
|
|
16548
16578
|
const invalidCells = cellPositions.filter((position) => { var _a; return cells[position] && !((_a = cells[position]) === null || _a === void 0 ? void 0 : _a.isAutoSummable); });
|
|
16549
|
-
const maxValidPosition =
|
|
16579
|
+
const maxValidPosition = largeMax(invalidCells);
|
|
16550
16580
|
const numberSequences = groupConsecutive(cellPositions.filter((position) => this.isNumber(cells[position])));
|
|
16551
16581
|
const firstSequence = numberSequences[0] || [];
|
|
16552
|
-
if (
|
|
16582
|
+
if (largeMax(firstSequence) < maxValidPosition) {
|
|
16553
16583
|
return Infinity;
|
|
16554
16584
|
}
|
|
16555
|
-
return
|
|
16585
|
+
return largeMin(firstSequence);
|
|
16556
16586
|
}
|
|
16557
16587
|
shouldFindData(sheetId, zone) {
|
|
16558
16588
|
return this.getters.isEmpty(sheetId, zone) || this.getters.isSingleCellOrMerge(sheetId, zone);
|
|
@@ -22243,13 +22273,13 @@ class SheetUIPlugin extends UIPlugin {
|
|
|
22243
22273
|
getColMaxWidth(sheetId, index) {
|
|
22244
22274
|
const cells = this.getters.getColCells(sheetId, index);
|
|
22245
22275
|
const sizes = cells.map((cell) => this.getCellWidth(cell));
|
|
22246
|
-
return Math.max(0,
|
|
22276
|
+
return Math.max(0, largeMax(sizes));
|
|
22247
22277
|
}
|
|
22248
22278
|
getRowMaxHeight(sheetId, index) {
|
|
22249
22279
|
const sheet = this.getters.getSheet(sheetId);
|
|
22250
22280
|
const cells = Object.values(sheet.rows[index].cells);
|
|
22251
22281
|
const sizes = cells.map((cell) => this.getCellHeight(cell));
|
|
22252
|
-
return Math.max(0,
|
|
22282
|
+
return Math.max(0, largeMax(sizes));
|
|
22253
22283
|
}
|
|
22254
22284
|
interactiveRenameSheet(sheetId, title) {
|
|
22255
22285
|
const placeholder = this.getters.getSheetName(sheetId);
|
|
@@ -23668,8 +23698,8 @@ class RangeAdapter {
|
|
|
23668
23698
|
let newRange = range;
|
|
23669
23699
|
let changeType = "NONE";
|
|
23670
23700
|
for (let group of groups) {
|
|
23671
|
-
const min =
|
|
23672
|
-
const max =
|
|
23701
|
+
const min = largeMin(group);
|
|
23702
|
+
const max = largeMax(group);
|
|
23673
23703
|
if (range.zone[start] <= min && min <= range.zone[end]) {
|
|
23674
23704
|
const toRemove = Math.min(range.zone[end], max) - min + 1;
|
|
23675
23705
|
changeType = "RESIZE";
|
|
@@ -24254,10 +24284,6 @@ function extractStyle(cell, data) {
|
|
|
24254
24284
|
if (cell.style) {
|
|
24255
24285
|
style = data.styles[cell.style];
|
|
24256
24286
|
}
|
|
24257
|
-
let border = {};
|
|
24258
|
-
if (cell.border) {
|
|
24259
|
-
border = data.borders[cell.border];
|
|
24260
|
-
}
|
|
24261
24287
|
const styles = {
|
|
24262
24288
|
font: {
|
|
24263
24289
|
size: (style === null || style === void 0 ? void 0 : style.fontSize) || DEFAULT_FONT_SIZE,
|
|
@@ -24271,7 +24297,7 @@ function extractStyle(cell, data) {
|
|
|
24271
24297
|
}
|
|
24272
24298
|
: { reservedAttribute: "none" },
|
|
24273
24299
|
numFmt: cell.format,
|
|
24274
|
-
border: border ||
|
|
24300
|
+
border: cell.border || 0,
|
|
24275
24301
|
verticalAlignment: "center",
|
|
24276
24302
|
horizontalAlignment: style === null || style === void 0 ? void 0 : style.align,
|
|
24277
24303
|
};
|
|
@@ -24282,21 +24308,17 @@ function extractStyle(cell, data) {
|
|
|
24282
24308
|
return styles;
|
|
24283
24309
|
}
|
|
24284
24310
|
function normalizeStyle(construct, styles) {
|
|
24285
|
-
const { id: fontId } = pushElement(styles["font"], construct.fonts);
|
|
24286
|
-
const { id: fillId } = pushElement(styles["fill"], construct.fills);
|
|
24287
|
-
const { id: borderId } = pushElement(styles["border"], construct.borders);
|
|
24288
24311
|
// Normalize this
|
|
24289
24312
|
const numFmtId = convertFormat(styles["numFmt"], construct.numFmts);
|
|
24290
24313
|
const style = {
|
|
24291
|
-
fontId,
|
|
24292
|
-
fillId,
|
|
24293
|
-
borderId,
|
|
24314
|
+
fontId: pushElement(styles.font, construct.fonts),
|
|
24315
|
+
fillId: pushElement(styles.fill, construct.fills),
|
|
24316
|
+
borderId: styles.border,
|
|
24294
24317
|
numFmtId,
|
|
24295
24318
|
verticalAlignment: styles["verticalAlignment"],
|
|
24296
24319
|
horizontalAlignment: styles["horizontalAlignment"],
|
|
24297
24320
|
};
|
|
24298
|
-
|
|
24299
|
-
return id;
|
|
24321
|
+
return pushElement(style, construct.styles);
|
|
24300
24322
|
}
|
|
24301
24323
|
function convertFormat(format, numFmtStructure) {
|
|
24302
24324
|
if (!format) {
|
|
@@ -24304,8 +24326,7 @@ function convertFormat(format, numFmtStructure) {
|
|
|
24304
24326
|
}
|
|
24305
24327
|
let formatId = XLSX_FORMAT_MAP[format];
|
|
24306
24328
|
if (!formatId) {
|
|
24307
|
-
|
|
24308
|
-
formatId = id + FIRST_NUMFMT_ID;
|
|
24329
|
+
formatId = pushElement(format, numFmtStructure) + FIRST_NUMFMT_ID;
|
|
24309
24330
|
}
|
|
24310
24331
|
return formatId;
|
|
24311
24332
|
}
|
|
@@ -24330,20 +24351,15 @@ function addRelsToFile(relsFiles, path, rel) {
|
|
|
24330
24351
|
return id;
|
|
24331
24352
|
}
|
|
24332
24353
|
function pushElement(property, propertyList) {
|
|
24333
|
-
|
|
24334
|
-
|
|
24335
|
-
|
|
24354
|
+
let len = propertyList.length;
|
|
24355
|
+
const operator = typeof property === "object" ? deepEquals : (a, b) => a === b;
|
|
24356
|
+
for (let i = 0; i < len; i++) {
|
|
24357
|
+
if (operator(property, propertyList[i])) {
|
|
24358
|
+
return i;
|
|
24336
24359
|
}
|
|
24337
24360
|
}
|
|
24338
|
-
|
|
24339
|
-
|
|
24340
|
-
propertyList.push(property);
|
|
24341
|
-
elemId = propertyList.length - 1;
|
|
24342
|
-
}
|
|
24343
|
-
return {
|
|
24344
|
-
id: elemId,
|
|
24345
|
-
list: propertyList,
|
|
24346
|
-
};
|
|
24361
|
+
propertyList[propertyList.length] = property;
|
|
24362
|
+
return propertyList.length - 1;
|
|
24347
24363
|
}
|
|
24348
24364
|
const chartIds = [];
|
|
24349
24365
|
/**
|
|
@@ -24424,7 +24440,8 @@ function parseXML(xmlString) {
|
|
|
24424
24440
|
}
|
|
24425
24441
|
return document;
|
|
24426
24442
|
}
|
|
24427
|
-
function getDefaultXLSXStructure() {
|
|
24443
|
+
function getDefaultXLSXStructure(data) {
|
|
24444
|
+
const borders = [{}, ...Object.values(data.borders)];
|
|
24428
24445
|
return {
|
|
24429
24446
|
relsFiles: [],
|
|
24430
24447
|
sharedStrings: [],
|
|
@@ -24447,7 +24464,7 @@ function getDefaultXLSXStructure() {
|
|
|
24447
24464
|
},
|
|
24448
24465
|
],
|
|
24449
24466
|
fills: [{ reservedAttribute: "none" }, { reservedAttribute: "gray125" }],
|
|
24450
|
-
borders
|
|
24467
|
+
borders,
|
|
24451
24468
|
numFmts: [],
|
|
24452
24469
|
dxfs: [],
|
|
24453
24470
|
};
|
|
@@ -24874,8 +24891,7 @@ function addContent(content, sharedStrings) {
|
|
|
24874
24891
|
attrs.push(["t", "b"]);
|
|
24875
24892
|
}
|
|
24876
24893
|
else if (!isNumber(value)) {
|
|
24877
|
-
|
|
24878
|
-
value = id.toString();
|
|
24894
|
+
value = pushElement(content, sharedStrings);
|
|
24879
24895
|
attrs.push(["t", "s"]);
|
|
24880
24896
|
}
|
|
24881
24897
|
return { attrs, node: escapeXml /*xml*/ `<v>${value}</v>` };
|
|
@@ -25000,8 +25016,7 @@ function addCellIsRule(cf, rule, dxfs) {
|
|
|
25000
25016
|
if (rule.style.fillColor) {
|
|
25001
25017
|
dxf.fill = { fgColor: rule.style.fillColor };
|
|
25002
25018
|
}
|
|
25003
|
-
|
|
25004
|
-
ruleAttributes.push(["dxfId", id]);
|
|
25019
|
+
ruleAttributes.push(["dxfId", pushElement(dxf, dxfs)]);
|
|
25005
25020
|
return escapeXml /*xml*/ `
|
|
25006
25021
|
<conditionalFormatting sqref="${cf.ranges.join(" ")}">
|
|
25007
25022
|
<cfRule ${formatAttributes(ruleAttributes)}>
|
|
@@ -25610,7 +25625,7 @@ function addMerges(merges) {
|
|
|
25610
25625
|
*/
|
|
25611
25626
|
function getXLSX(data) {
|
|
25612
25627
|
const files = [];
|
|
25613
|
-
const construct = getDefaultXLSXStructure();
|
|
25628
|
+
const construct = getDefaultXLSXStructure(data);
|
|
25614
25629
|
files.push(createWorkbook(data, construct));
|
|
25615
25630
|
files.push(...createWorksheets(data, construct));
|
|
25616
25631
|
files.push(createStylesSheet(construct));
|
|
@@ -31463,6 +31478,6 @@ const helpers = {
|
|
|
31463
31478
|
export { CommandResult, CorePlugin, DATETIME_FORMAT, DataSource, DispatchResult, Model, Revision, SPREADSHEET_DIMENSIONS, Spreadsheet, UIPlugin, DEBUG as __DEBUG__, __info__, astToFormula, cellTypes, convertAstNodes, coreTypes, functionCache, helpers, invalidateEvaluationCommands, normalize, parse, readonlyAllowedCommands, registries, setTranslationMethod };
|
|
31464
31479
|
|
|
31465
31480
|
|
|
31466
|
-
__info__.version = '15.0.
|
|
31467
|
-
__info__.date = '2024-
|
|
31468
|
-
__info__.hash = '
|
|
31481
|
+
__info__.version = '15.0.21';
|
|
31482
|
+
__info__.date = '2024-04-10T12:08:56.252Z';
|
|
31483
|
+
__info__.hash = '4d672af';
|