@odoo/o-spreadsheet 16.4.28 → 16.4.29
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 +79 -77
- package/dist/o-spreadsheet.d.ts +3 -5
- package/dist/o-spreadsheet.esm.js +79 -77
- package/dist/o-spreadsheet.iife.js +79 -77
- package/dist/o-spreadsheet.iife.min.js +63 -63
- package/dist/o_spreadsheet.xml +5 -4
- package/package.json +1 -1
|
@@ -613,7 +613,7 @@ function deepEquals(o1, o2) {
|
|
|
613
613
|
if (typeof o1 !== typeof o2)
|
|
614
614
|
return false;
|
|
615
615
|
if (typeof o1 !== "object")
|
|
616
|
-
return
|
|
616
|
+
return false;
|
|
617
617
|
// Objects can have different keys if the values are undefined
|
|
618
618
|
const keys = new Set();
|
|
619
619
|
Object.keys(o1).forEach((key) => keys.add(key));
|
|
@@ -15797,6 +15797,7 @@ class LinkEditor extends Component {
|
|
|
15797
15797
|
this.save();
|
|
15798
15798
|
}
|
|
15799
15799
|
ev.stopPropagation();
|
|
15800
|
+
ev.preventDefault();
|
|
15800
15801
|
break;
|
|
15801
15802
|
case "Escape":
|
|
15802
15803
|
this.cancel();
|
|
@@ -24462,6 +24463,11 @@ class Composer extends Component {
|
|
|
24462
24463
|
}
|
|
24463
24464
|
}
|
|
24464
24465
|
}
|
|
24466
|
+
onContextMenu(ev) {
|
|
24467
|
+
if (this.env.model.getters.getEditionMode() === "inactive") {
|
|
24468
|
+
this.props.onInputContextMenu?.(ev);
|
|
24469
|
+
}
|
|
24470
|
+
}
|
|
24465
24471
|
// ---------------------------------------------------------------------------
|
|
24466
24472
|
// Private
|
|
24467
24473
|
// ---------------------------------------------------------------------------
|
|
@@ -24686,6 +24692,7 @@ Composer.props = {
|
|
|
24686
24692
|
onComposerCellFocused: { type: Function, optional: true },
|
|
24687
24693
|
onComposerContentFocused: Function,
|
|
24688
24694
|
isDefaultFocus: { type: Boolean, optional: true },
|
|
24695
|
+
onInputContextMenu: { type: Function, optional: true },
|
|
24689
24696
|
};
|
|
24690
24697
|
|
|
24691
24698
|
const COMPOSER_BORDER_WIDTH = 3 * 0.4 * window.devicePixelRatio || 1;
|
|
@@ -24762,6 +24769,7 @@ class GridComposer extends Component {
|
|
|
24762
24769
|
isDefaultFocus: true,
|
|
24763
24770
|
onComposerContentFocused: this.props.onComposerContentFocused,
|
|
24764
24771
|
onComposerCellFocused: this.props.onComposerCellFocused,
|
|
24772
|
+
onInputContextMenu: this.props.onInputContextMenu,
|
|
24765
24773
|
};
|
|
24766
24774
|
}
|
|
24767
24775
|
get containerStyle() {
|
|
@@ -24850,6 +24858,7 @@ GridComposer.props = {
|
|
|
24850
24858
|
onComposerContentFocused: Function,
|
|
24851
24859
|
gridDims: Object,
|
|
24852
24860
|
onComposerCellFocused: Function,
|
|
24861
|
+
onInputContextMenu: Function,
|
|
24853
24862
|
};
|
|
24854
24863
|
|
|
24855
24864
|
const CSS$1 = css /* scss */ `
|
|
@@ -27199,8 +27208,8 @@ class Grid extends Component {
|
|
|
27199
27208
|
else if (this.env.model.getters.getActiveRows().has(row)) {
|
|
27200
27209
|
type = "ROW";
|
|
27201
27210
|
}
|
|
27202
|
-
const { x, y, width
|
|
27203
|
-
this.toggleContextMenu(type, x + width, y +
|
|
27211
|
+
const { x, y, width } = this.env.model.getters.getVisibleRect(lastZone);
|
|
27212
|
+
this.toggleContextMenu(type, this.canvasPosition.x + x + width, this.canvasPosition.y + y);
|
|
27204
27213
|
}
|
|
27205
27214
|
onCellRightClicked(col, row, { x, y }) {
|
|
27206
27215
|
const zones = this.env.model.getters.getSelectedZones();
|
|
@@ -28490,29 +28499,12 @@ function convertWidthFromExcel(width) {
|
|
|
28490
28499
|
return width;
|
|
28491
28500
|
return Math.round((width / WIDTH_FACTOR) * 100) / 100;
|
|
28492
28501
|
}
|
|
28493
|
-
function convertBorderDescr(descr) {
|
|
28494
|
-
if (!descr) {
|
|
28495
|
-
return undefined;
|
|
28496
|
-
}
|
|
28497
|
-
return {
|
|
28498
|
-
style: descr.style,
|
|
28499
|
-
color: { rgb: descr.color },
|
|
28500
|
-
};
|
|
28501
|
-
}
|
|
28502
28502
|
function extractStyle(cell, data) {
|
|
28503
28503
|
let style = {};
|
|
28504
28504
|
if (cell.style) {
|
|
28505
28505
|
style = data.styles[cell.style];
|
|
28506
28506
|
}
|
|
28507
28507
|
const format = extractFormat(cell, data);
|
|
28508
|
-
const exportedBorder = {};
|
|
28509
|
-
if (cell.border) {
|
|
28510
|
-
const border = data.borders[cell.border];
|
|
28511
|
-
exportedBorder.left = convertBorderDescr(border.left);
|
|
28512
|
-
exportedBorder.right = convertBorderDescr(border.right);
|
|
28513
|
-
exportedBorder.bottom = convertBorderDescr(border.bottom);
|
|
28514
|
-
exportedBorder.top = convertBorderDescr(border.top);
|
|
28515
|
-
}
|
|
28516
28508
|
const styles = {
|
|
28517
28509
|
font: {
|
|
28518
28510
|
size: style?.fontSize || DEFAULT_FONT_SIZE,
|
|
@@ -28526,7 +28518,7 @@ function extractStyle(cell, data) {
|
|
|
28526
28518
|
}
|
|
28527
28519
|
: { reservedAttribute: "none" },
|
|
28528
28520
|
numFmt: format ? { format: format, id: 0 /* id not used for export */ } : undefined,
|
|
28529
|
-
border:
|
|
28521
|
+
border: cell.border || 0,
|
|
28530
28522
|
alignment: {
|
|
28531
28523
|
horizontal: style.align,
|
|
28532
28524
|
vertical: style.verticalAlign
|
|
@@ -28548,15 +28540,12 @@ function extractFormat(cell, data) {
|
|
|
28548
28540
|
return undefined;
|
|
28549
28541
|
}
|
|
28550
28542
|
function normalizeStyle(construct, styles) {
|
|
28551
|
-
const { id: fontId } = pushElement(styles["font"], construct.fonts);
|
|
28552
|
-
const { id: fillId } = pushElement(styles["fill"], construct.fills);
|
|
28553
|
-
const { id: borderId } = pushElement(styles["border"], construct.borders);
|
|
28554
28543
|
// Normalize this
|
|
28555
28544
|
const numFmtId = convertFormat(styles["numFmt"], construct.numFmts);
|
|
28556
28545
|
const style = {
|
|
28557
|
-
fontId,
|
|
28558
|
-
fillId,
|
|
28559
|
-
borderId,
|
|
28546
|
+
fontId: pushElement(styles.font, construct.fonts),
|
|
28547
|
+
fillId: pushElement(styles.fill, construct.fills),
|
|
28548
|
+
borderId: styles.border,
|
|
28560
28549
|
numFmtId,
|
|
28561
28550
|
alignment: {
|
|
28562
28551
|
vertical: styles.alignment.vertical,
|
|
@@ -28564,8 +28553,7 @@ function normalizeStyle(construct, styles) {
|
|
|
28564
28553
|
wrapText: styles.alignment.wrapText,
|
|
28565
28554
|
},
|
|
28566
28555
|
};
|
|
28567
|
-
|
|
28568
|
-
return id;
|
|
28556
|
+
return pushElement(style, construct.styles);
|
|
28569
28557
|
}
|
|
28570
28558
|
function convertFormat(format, numFmtStructure) {
|
|
28571
28559
|
if (!format) {
|
|
@@ -28573,8 +28561,7 @@ function convertFormat(format, numFmtStructure) {
|
|
|
28573
28561
|
}
|
|
28574
28562
|
let formatId = XLSX_FORMAT_MAP[format.format];
|
|
28575
28563
|
if (!formatId) {
|
|
28576
|
-
|
|
28577
|
-
formatId = id + FIRST_NUMFMT_ID;
|
|
28564
|
+
formatId = pushElement(format, numFmtStructure) + FIRST_NUMFMT_ID;
|
|
28578
28565
|
}
|
|
28579
28566
|
return formatId;
|
|
28580
28567
|
}
|
|
@@ -28599,20 +28586,15 @@ function addRelsToFile(relsFiles, path, rel) {
|
|
|
28599
28586
|
return id;
|
|
28600
28587
|
}
|
|
28601
28588
|
function pushElement(property, propertyList) {
|
|
28602
|
-
|
|
28603
|
-
|
|
28604
|
-
|
|
28589
|
+
let len = propertyList.length;
|
|
28590
|
+
const operator = typeof property === "object" ? deepEquals : (a, b) => a === b;
|
|
28591
|
+
for (let i = 0; i < len; i++) {
|
|
28592
|
+
if (operator(property, propertyList[i])) {
|
|
28593
|
+
return i;
|
|
28605
28594
|
}
|
|
28606
28595
|
}
|
|
28607
|
-
|
|
28608
|
-
|
|
28609
|
-
propertyList.push(property);
|
|
28610
|
-
elemId = propertyList.length - 1;
|
|
28611
|
-
}
|
|
28612
|
-
return {
|
|
28613
|
-
id: elemId,
|
|
28614
|
-
list: propertyList,
|
|
28615
|
-
};
|
|
28596
|
+
propertyList[propertyList.length] = property;
|
|
28597
|
+
return propertyList.length - 1;
|
|
28616
28598
|
}
|
|
28617
28599
|
const chartIds = [];
|
|
28618
28600
|
/**
|
|
@@ -29333,7 +29315,25 @@ function parseXML(xmlString, mimeType = "text/xml") {
|
|
|
29333
29315
|
}
|
|
29334
29316
|
return document;
|
|
29335
29317
|
}
|
|
29336
|
-
function
|
|
29318
|
+
function convertBorderDescr(descr) {
|
|
29319
|
+
if (!descr) {
|
|
29320
|
+
return undefined;
|
|
29321
|
+
}
|
|
29322
|
+
return {
|
|
29323
|
+
style: descr.style,
|
|
29324
|
+
color: { rgb: descr.color },
|
|
29325
|
+
};
|
|
29326
|
+
}
|
|
29327
|
+
function getDefaultXLSXStructure(data) {
|
|
29328
|
+
const xlsxBorders = Object.values(data.borders).map((border) => {
|
|
29329
|
+
return {
|
|
29330
|
+
left: convertBorderDescr(border.left),
|
|
29331
|
+
right: convertBorderDescr(border.right),
|
|
29332
|
+
bottom: convertBorderDescr(border.bottom),
|
|
29333
|
+
top: convertBorderDescr(border.top),
|
|
29334
|
+
};
|
|
29335
|
+
});
|
|
29336
|
+
const borders = [{}, ...xlsxBorders];
|
|
29337
29337
|
return {
|
|
29338
29338
|
relsFiles: [],
|
|
29339
29339
|
sharedStrings: [],
|
|
@@ -29356,7 +29356,7 @@ function getDefaultXLSXStructure() {
|
|
|
29356
29356
|
},
|
|
29357
29357
|
],
|
|
29358
29358
|
fills: [{ reservedAttribute: "none" }, { reservedAttribute: "gray125" }],
|
|
29359
|
-
borders
|
|
29359
|
+
borders,
|
|
29360
29360
|
numFmts: [],
|
|
29361
29361
|
dxfs: [],
|
|
29362
29362
|
};
|
|
@@ -33421,7 +33421,17 @@ class FiltersPlugin extends CorePlugin {
|
|
|
33421
33421
|
}
|
|
33422
33422
|
}
|
|
33423
33423
|
exportForExcel(data) {
|
|
33424
|
-
|
|
33424
|
+
for (const sheet of data.sheets) {
|
|
33425
|
+
for (const filterTable of this.getFilterTables(sheet.id)) {
|
|
33426
|
+
if (zoneToDimension(filterTable.zone).numberOfRows === 1) {
|
|
33427
|
+
continue;
|
|
33428
|
+
}
|
|
33429
|
+
sheet.filterTables.push({
|
|
33430
|
+
range: zoneToXc(filterTable.zone),
|
|
33431
|
+
filters: [],
|
|
33432
|
+
});
|
|
33433
|
+
}
|
|
33434
|
+
}
|
|
33425
33435
|
}
|
|
33426
33436
|
}
|
|
33427
33437
|
|
|
@@ -36715,7 +36725,9 @@ class Evaluator {
|
|
|
36715
36725
|
this.blockedArrayFormulas = new Set();
|
|
36716
36726
|
this.spreadingRelations = new SpreadingRelation();
|
|
36717
36727
|
this.formulaDependencies = lazy(() => {
|
|
36718
|
-
const dependencies = [...this.getAllCells()].flatMap((positionId) => this.getDirectDependencies(positionId)
|
|
36728
|
+
const dependencies = [...this.getAllCells()].flatMap((positionId) => this.getDirectDependencies(positionId)
|
|
36729
|
+
.filter((range) => !range.invalidSheetName && !range.invalidXc)
|
|
36730
|
+
.map((range) => ({
|
|
36719
36731
|
data: positionId,
|
|
36720
36732
|
boundingBox: {
|
|
36721
36733
|
zone: range.zone,
|
|
@@ -45250,13 +45262,14 @@ class SheetViewPlugin extends UIPlugin {
|
|
|
45250
45262
|
}
|
|
45251
45263
|
}
|
|
45252
45264
|
handleEvent(event) {
|
|
45265
|
+
const sheetId = this.getters.getActiveSheetId();
|
|
45253
45266
|
if (event.options.scrollIntoView) {
|
|
45254
45267
|
let { col, row } = findCellInNewZone(event.previousAnchor.zone, event.anchor.zone);
|
|
45255
45268
|
if (event.mode === "updateAnchor") {
|
|
45256
45269
|
const oldZone = event.previousAnchor.zone;
|
|
45257
45270
|
const newZone = event.anchor.zone;
|
|
45258
45271
|
// altering a zone should not move the viewport in a dimension that wasn't changed
|
|
45259
|
-
const { top, bottom, left, right } = this.
|
|
45272
|
+
const { top, bottom, left, right } = this.getMainInternalViewport(sheetId);
|
|
45260
45273
|
if (oldZone.left === newZone.left && oldZone.right === newZone.right) {
|
|
45261
45274
|
col = left > col || col > right ? left : col;
|
|
45262
45275
|
}
|
|
@@ -45264,7 +45277,6 @@ class SheetViewPlugin extends UIPlugin {
|
|
|
45264
45277
|
row = top > row || row > bottom ? top : row;
|
|
45265
45278
|
}
|
|
45266
45279
|
}
|
|
45267
|
-
const sheetId = this.getters.getActiveSheetId();
|
|
45268
45280
|
col = Math.min(col, this.getters.getNumberCols(sheetId) - 1);
|
|
45269
45281
|
row = Math.min(row, this.getters.getNumberRows(sheetId) - 1);
|
|
45270
45282
|
this.refreshViewport(this.getters.getActiveSheetId(), { col, row });
|
|
@@ -45290,16 +45302,16 @@ class SheetViewPlugin extends UIPlugin {
|
|
|
45290
45302
|
this.setSheetViewOffset(cmd.offsetX, cmd.offsetY);
|
|
45291
45303
|
break;
|
|
45292
45304
|
case "SHIFT_VIEWPORT_DOWN":
|
|
45293
|
-
const { top } = this.getActiveMainViewport();
|
|
45294
45305
|
const sheetId = this.getters.getActiveSheetId();
|
|
45295
|
-
const
|
|
45296
|
-
this.
|
|
45306
|
+
const { top, viewportHeight, offsetCorrectionY } = this.getMainInternalViewport(sheetId);
|
|
45307
|
+
const topRowDims = this.getters.getRowDimensions(sheetId, top);
|
|
45308
|
+
this.shiftVertically(topRowDims.start + viewportHeight - offsetCorrectionY);
|
|
45297
45309
|
break;
|
|
45298
45310
|
case "SHIFT_VIEWPORT_UP": {
|
|
45299
|
-
const { top } = this.getActiveMainViewport();
|
|
45300
45311
|
const sheetId = this.getters.getActiveSheetId();
|
|
45301
|
-
const
|
|
45302
|
-
this.
|
|
45312
|
+
const { top, viewportHeight, offsetCorrectionY } = this.getMainInternalViewport(sheetId);
|
|
45313
|
+
const topRowDims = this.getters.getRowDimensions(sheetId, top);
|
|
45314
|
+
this.shiftVertically(topRowDims.end - offsetCorrectionY - viewportHeight);
|
|
45303
45315
|
break;
|
|
45304
45316
|
}
|
|
45305
45317
|
case "REMOVE_COLUMNS_ROWS":
|
|
@@ -45661,17 +45673,6 @@ class SheetViewPlugin extends UIPlugin {
|
|
|
45661
45673
|
const { maxOffsetX, maxOffsetY } = this.getMaximumSheetOffset();
|
|
45662
45674
|
Object.values(this.getSubViewports(sheetId)).forEach((viewport) => viewport.setViewportOffset(clip(offsetX, 0, maxOffsetX), clip(offsetY, 0, maxOffsetY)));
|
|
45663
45675
|
}
|
|
45664
|
-
/**
|
|
45665
|
-
* Clip the vertical offset within the allowed range.
|
|
45666
|
-
* Not above the sheet, nor below the sheet.
|
|
45667
|
-
*/
|
|
45668
|
-
clipOffsetY(offsetY) {
|
|
45669
|
-
const { height } = this.getMainViewportRect();
|
|
45670
|
-
const maxOffset = height - this.sheetViewHeight;
|
|
45671
|
-
offsetY = Math.min(offsetY, maxOffset);
|
|
45672
|
-
offsetY = Math.max(offsetY, 0);
|
|
45673
|
-
return offsetY;
|
|
45674
|
-
}
|
|
45675
45676
|
getViewportOffset(sheetId) {
|
|
45676
45677
|
return {
|
|
45677
45678
|
x: this.viewports[sheetId]?.bottomRight.offsetScrollbarX || 0,
|
|
@@ -45727,12 +45728,15 @@ class SheetViewPlugin extends UIPlugin {
|
|
|
45727
45728
|
* viewport top.
|
|
45728
45729
|
*/
|
|
45729
45730
|
shiftVertically(offset) {
|
|
45730
|
-
const
|
|
45731
|
+
const sheetId = this.getters.getActiveSheetId();
|
|
45732
|
+
const { top } = this.getMainInternalViewport(sheetId);
|
|
45731
45733
|
const { scrollX } = this.getActiveSheetScrollInfo();
|
|
45732
45734
|
this.setSheetViewOffset(scrollX, offset);
|
|
45733
45735
|
const { anchor } = this.getters.getSelection();
|
|
45734
|
-
|
|
45735
|
-
|
|
45736
|
+
if (anchor.cell.row >= this.getters.getPaneDivisions(sheetId).ySplit) {
|
|
45737
|
+
const deltaRow = this.getMainInternalViewport(sheetId).top - top;
|
|
45738
|
+
this.selection.selectCell(anchor.cell.col, anchor.cell.row + deltaRow);
|
|
45739
|
+
}
|
|
45736
45740
|
}
|
|
45737
45741
|
getVisibleFigures() {
|
|
45738
45742
|
const sheetId = this.getters.getActiveSheetId();
|
|
@@ -49989,8 +49993,7 @@ function addContent(content, sharedStrings, forceString = false) {
|
|
|
49989
49993
|
attrs.push(["t", "b"]);
|
|
49990
49994
|
}
|
|
49991
49995
|
else if (forceString || !isNumber(value, DEFAULT_LOCALE)) {
|
|
49992
|
-
|
|
49993
|
-
value = id.toString();
|
|
49996
|
+
value = pushElement(content, sharedStrings);
|
|
49994
49997
|
attrs.push(["t", "s"]);
|
|
49995
49998
|
}
|
|
49996
49999
|
return { attrs, node: escapeXml /*xml*/ `<v>${value}</v>` };
|
|
@@ -50115,8 +50118,7 @@ function addCellIsRule(cf, rule, dxfs) {
|
|
|
50115
50118
|
if (rule.style.fillColor) {
|
|
50116
50119
|
dxf.fill = { fgColor: { rgb: rule.style.fillColor } };
|
|
50117
50120
|
}
|
|
50118
|
-
|
|
50119
|
-
ruleAttributes.push(["dxfId", id]);
|
|
50121
|
+
ruleAttributes.push(["dxfId", pushElement(dxf, dxfs)]);
|
|
50120
50122
|
return escapeXml /*xml*/ `
|
|
50121
50123
|
<conditionalFormatting sqref="${cf.ranges.join(" ")}">
|
|
50122
50124
|
<cfRule ${formatAttributes(ruleAttributes)}>
|
|
@@ -50925,7 +50927,7 @@ function addSheetViews(sheet) {
|
|
|
50925
50927
|
*/
|
|
50926
50928
|
function getXLSX(data) {
|
|
50927
50929
|
const files = [];
|
|
50928
|
-
const construct = getDefaultXLSXStructure();
|
|
50930
|
+
const construct = getDefaultXLSXStructure(data);
|
|
50929
50931
|
files.push(createWorkbook(data, construct));
|
|
50930
50932
|
files.push(...createWorksheets(data, construct));
|
|
50931
50933
|
files.push(createStylesSheet(construct));
|
|
@@ -51748,6 +51750,6 @@ const constants = {
|
|
|
51748
51750
|
export { AbstractChart, CommandResult, CorePlugin, DispatchResult, EvaluationError, Model, Registry, Revision, SPREADSHEET_DIMENSIONS, Spreadsheet, UIPlugin, __info__, addFunction, astToFormula, compile, components, constants, convertAstNodes, coreTypes, findCellInNewZone, functionCache, helpers, invalidateCFEvaluationCommands, invalidateDependenciesCommands, invalidateEvaluationCommands, iterateAstNodes, links, load, parse, readonlyAllowedCommands, registries, setDefaultSheetViewSize, setTranslationMethod, tokenize };
|
|
51749
51751
|
|
|
51750
51752
|
|
|
51751
|
-
__info__.version = '16.4.
|
|
51752
|
-
__info__.date = '2024-04-
|
|
51753
|
-
__info__.hash = '
|
|
51753
|
+
__info__.version = '16.4.29';
|
|
51754
|
+
__info__.date = '2024-04-10T12:19:13.935Z';
|
|
51755
|
+
__info__.hash = 'c022445';
|