@odoo/o-spreadsheet 18.1.14 → 18.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 +158 -77
- package/dist/o-spreadsheet.d.ts +33 -16
- package/dist/o-spreadsheet.esm.js +158 -77
- package/dist/o-spreadsheet.iife.js +158 -77
- package/dist/o-spreadsheet.iife.min.js +34 -34
- package/dist/o_spreadsheet.xml +3 -3
- package/package.json +1 -1
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* This file is generated by o-spreadsheet build tools. Do not edit it.
|
|
4
4
|
* @see https://github.com/odoo/o-spreadsheet
|
|
5
|
-
* @version 18.1.
|
|
6
|
-
* @date 2025-04-
|
|
7
|
-
* @hash
|
|
5
|
+
* @version 18.1.15
|
|
6
|
+
* @date 2025-04-14T17:17:30.890Z
|
|
7
|
+
* @hash ddaea83
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
'use strict';
|
|
@@ -3564,6 +3564,7 @@ const coreTypes = new Set([
|
|
|
3564
3564
|
"CLEAR_FORMATTING",
|
|
3565
3565
|
"SET_BORDER",
|
|
3566
3566
|
"SET_ZONE_BORDERS",
|
|
3567
|
+
"SET_BORDERS_ON_TARGET",
|
|
3567
3568
|
/** CHART */
|
|
3568
3569
|
"CREATE_CHART",
|
|
3569
3570
|
"UPDATE_CHART",
|
|
@@ -6715,6 +6716,7 @@ class AbstractCellClipboardHandler extends ClipboardHandler {
|
|
|
6715
6716
|
}
|
|
6716
6717
|
|
|
6717
6718
|
class BorderClipboardHandler extends AbstractCellClipboardHandler {
|
|
6719
|
+
queuedBordersToAdd = {};
|
|
6718
6720
|
copy(data) {
|
|
6719
6721
|
const sheetId = data.sheetId;
|
|
6720
6722
|
if (data.zones.length === 0) {
|
|
@@ -6745,6 +6747,7 @@ class BorderClipboardHandler extends AbstractCellClipboardHandler {
|
|
|
6745
6747
|
const { left, top } = zones[0];
|
|
6746
6748
|
this.pasteZone(sheetId, left, top, content.borders);
|
|
6747
6749
|
}
|
|
6750
|
+
this.executeQueuedChanges(sheetId);
|
|
6748
6751
|
}
|
|
6749
6752
|
pasteZone(sheetId, col, row, borders) {
|
|
6750
6753
|
for (const [r, rowBorders] of borders.entries()) {
|
|
@@ -6763,7 +6766,20 @@ class BorderClipboardHandler extends AbstractCellClipboardHandler {
|
|
|
6763
6766
|
...targetBorders,
|
|
6764
6767
|
...originBorders,
|
|
6765
6768
|
};
|
|
6766
|
-
|
|
6769
|
+
const borderKey = JSON.stringify(border);
|
|
6770
|
+
if (!this.queuedBordersToAdd[borderKey]) {
|
|
6771
|
+
this.queuedBordersToAdd[borderKey] = [];
|
|
6772
|
+
}
|
|
6773
|
+
this.queuedBordersToAdd[borderKey].push(positionToZone(target));
|
|
6774
|
+
}
|
|
6775
|
+
executeQueuedChanges(pasteSheetTarget) {
|
|
6776
|
+
for (const borderKey in this.queuedBordersToAdd) {
|
|
6777
|
+
const zones = this.queuedBordersToAdd[borderKey];
|
|
6778
|
+
const border = JSON.parse(borderKey);
|
|
6779
|
+
const target = recomputeZones(zones, []);
|
|
6780
|
+
this.dispatch("SET_BORDERS_ON_TARGET", { sheetId: pasteSheetTarget, target, border });
|
|
6781
|
+
}
|
|
6782
|
+
this.queuedBordersToAdd = {};
|
|
6767
6783
|
}
|
|
6768
6784
|
}
|
|
6769
6785
|
|
|
@@ -8702,12 +8718,13 @@ class ConditionalFormatClipboardHandler extends AbstractCellClipboardHandler {
|
|
|
8702
8718
|
}
|
|
8703
8719
|
pasteCf(origin, target, isCutOperation) {
|
|
8704
8720
|
if (origin?.rules && origin.rules.length > 0) {
|
|
8721
|
+
const originZone = positionToZone(origin.position);
|
|
8705
8722
|
const zone = positionToZone(target);
|
|
8706
8723
|
for (const rule of origin.rules) {
|
|
8707
8724
|
const toRemoveZones = [];
|
|
8708
8725
|
if (isCutOperation) {
|
|
8709
8726
|
//remove from current rule
|
|
8710
|
-
toRemoveZones.push(
|
|
8727
|
+
toRemoveZones.push(originZone);
|
|
8711
8728
|
}
|
|
8712
8729
|
if (origin.position.sheetId === target.sheetId) {
|
|
8713
8730
|
this.adaptCFRules(origin.position.sheetId, rule, [zone], toRemoveZones);
|
|
@@ -8821,6 +8838,7 @@ class DataValidationClipboardHandler extends AbstractCellClipboardHandler {
|
|
|
8821
8838
|
pasteDataValidation(origin, target, isCutOperation) {
|
|
8822
8839
|
if (origin) {
|
|
8823
8840
|
const zone = positionToZone(target);
|
|
8841
|
+
const originZone = positionToZone(origin.position);
|
|
8824
8842
|
const rule = origin.rule;
|
|
8825
8843
|
if (!rule) {
|
|
8826
8844
|
const targetRule = this.getters.getValidationRuleForCell(target);
|
|
@@ -8832,7 +8850,7 @@ class DataValidationClipboardHandler extends AbstractCellClipboardHandler {
|
|
|
8832
8850
|
}
|
|
8833
8851
|
const toRemoveZone = [];
|
|
8834
8852
|
if (isCutOperation) {
|
|
8835
|
-
toRemoveZone.push(
|
|
8853
|
+
toRemoveZone.push(originZone);
|
|
8836
8854
|
}
|
|
8837
8855
|
if (origin.position.sheetId === target.sheetId) {
|
|
8838
8856
|
const copyToRule = this.getDataValidationRuleToCopyTo(target.sheetId, rule, false);
|
|
@@ -8892,7 +8910,7 @@ class DataValidationClipboardHandler extends AbstractCellClipboardHandler {
|
|
|
8892
8910
|
continue;
|
|
8893
8911
|
}
|
|
8894
8912
|
this.dispatch("ADD_DATA_VALIDATION_RULE", {
|
|
8895
|
-
rule: dv,
|
|
8913
|
+
rule: { id: dv.id, criterion: dv.criterion, isBlocking: dv.isBlocking },
|
|
8896
8914
|
ranges: newDvZones.map((zone) => this.getters.getRangeDataFromZone(sheetId, zone)),
|
|
8897
8915
|
sheetId,
|
|
8898
8916
|
});
|
|
@@ -52872,6 +52890,15 @@ class BordersPlugin extends CorePlugin {
|
|
|
52872
52890
|
case "SET_BORDER":
|
|
52873
52891
|
this.setBorder(cmd.sheetId, cmd.col, cmd.row, cmd.border);
|
|
52874
52892
|
break;
|
|
52893
|
+
case "SET_BORDERS_ON_TARGET":
|
|
52894
|
+
for (const zone of cmd.target) {
|
|
52895
|
+
for (let row = zone.top; row <= zone.bottom; row++) {
|
|
52896
|
+
for (let col = zone.left; col <= zone.right; col++) {
|
|
52897
|
+
this.setBorder(cmd.sheetId, col, row, cmd.border);
|
|
52898
|
+
}
|
|
52899
|
+
}
|
|
52900
|
+
}
|
|
52901
|
+
break;
|
|
52875
52902
|
case "SET_ZONE_BORDERS":
|
|
52876
52903
|
if (cmd.border) {
|
|
52877
52904
|
const target = cmd.target.map((zone) => this.getters.expandZone(cmd.sheetId, zone));
|
|
@@ -62598,25 +62625,6 @@ class AutofillPlugin extends UIPlugin {
|
|
|
62598
62625
|
case "AUTOFILL_AUTO":
|
|
62599
62626
|
this.autofillAuto();
|
|
62600
62627
|
break;
|
|
62601
|
-
case "AUTOFILL_CELL":
|
|
62602
|
-
this.autoFillMerge(cmd.originCol, cmd.originRow, cmd.col, cmd.row);
|
|
62603
|
-
const sheetId = this.getters.getActiveSheetId();
|
|
62604
|
-
this.dispatch("UPDATE_CELL", {
|
|
62605
|
-
sheetId,
|
|
62606
|
-
col: cmd.col,
|
|
62607
|
-
row: cmd.row,
|
|
62608
|
-
style: cmd.style || null,
|
|
62609
|
-
content: cmd.content || "",
|
|
62610
|
-
format: cmd.format || "",
|
|
62611
|
-
});
|
|
62612
|
-
this.dispatch("SET_BORDER", {
|
|
62613
|
-
sheetId,
|
|
62614
|
-
col: cmd.col,
|
|
62615
|
-
row: cmd.row,
|
|
62616
|
-
border: cmd.border,
|
|
62617
|
-
});
|
|
62618
|
-
this.autofillCF(cmd.originCol, cmd.originRow, cmd.col, cmd.row);
|
|
62619
|
-
this.autofillDV(cmd.originCol, cmd.originRow, cmd.col, cmd.row);
|
|
62620
62628
|
}
|
|
62621
62629
|
}
|
|
62622
62630
|
// ---------------------------------------------------------------------------
|
|
@@ -62640,6 +62648,7 @@ class AutofillPlugin extends UIPlugin {
|
|
|
62640
62648
|
}
|
|
62641
62649
|
const source = this.getters.getSelectedZone();
|
|
62642
62650
|
const target = this.autofillZone;
|
|
62651
|
+
const autofillCellsData = [];
|
|
62643
62652
|
switch (this.direction) {
|
|
62644
62653
|
case "down" /* DIRECTION.DOWN */:
|
|
62645
62654
|
for (let col = source.left; col <= source.right; col++) {
|
|
@@ -62649,7 +62658,7 @@ class AutofillPlugin extends UIPlugin {
|
|
|
62649
62658
|
}
|
|
62650
62659
|
const generator = this.createGenerator(xcs);
|
|
62651
62660
|
for (let row = target.top; row <= target.bottom; row++) {
|
|
62652
|
-
this.computeNewCell(generator, col, row
|
|
62661
|
+
autofillCellsData.push(this.computeNewCell(generator, col, row));
|
|
62653
62662
|
}
|
|
62654
62663
|
}
|
|
62655
62664
|
break;
|
|
@@ -62661,7 +62670,7 @@ class AutofillPlugin extends UIPlugin {
|
|
|
62661
62670
|
}
|
|
62662
62671
|
const generator = this.createGenerator(xcs);
|
|
62663
62672
|
for (let row = target.bottom; row >= target.top; row--) {
|
|
62664
|
-
this.computeNewCell(generator, col, row
|
|
62673
|
+
autofillCellsData.push(this.computeNewCell(generator, col, row));
|
|
62665
62674
|
}
|
|
62666
62675
|
}
|
|
62667
62676
|
break;
|
|
@@ -62673,7 +62682,7 @@ class AutofillPlugin extends UIPlugin {
|
|
|
62673
62682
|
}
|
|
62674
62683
|
const generator = this.createGenerator(xcs);
|
|
62675
62684
|
for (let col = target.right; col >= target.left; col--) {
|
|
62676
|
-
this.computeNewCell(generator, col, row
|
|
62685
|
+
autofillCellsData.push(this.computeNewCell(generator, col, row));
|
|
62677
62686
|
}
|
|
62678
62687
|
}
|
|
62679
62688
|
break;
|
|
@@ -62685,12 +62694,26 @@ class AutofillPlugin extends UIPlugin {
|
|
|
62685
62694
|
}
|
|
62686
62695
|
const generator = this.createGenerator(xcs);
|
|
62687
62696
|
for (let col = target.left; col <= target.right; col++) {
|
|
62688
|
-
this.computeNewCell(generator, col, row
|
|
62697
|
+
autofillCellsData.push(this.computeNewCell(generator, col, row));
|
|
62689
62698
|
}
|
|
62690
62699
|
}
|
|
62691
62700
|
break;
|
|
62692
62701
|
}
|
|
62693
62702
|
if (apply) {
|
|
62703
|
+
const bordersZones = {};
|
|
62704
|
+
const cfNewRanges = {};
|
|
62705
|
+
const dvNewZones = {};
|
|
62706
|
+
const sheetId = this.getters.getActiveSheetId();
|
|
62707
|
+
for (const data of autofillCellsData) {
|
|
62708
|
+
this.collectBordersData(data, bordersZones);
|
|
62709
|
+
this.autofillMerge(sheetId, data);
|
|
62710
|
+
this.autofillCell(sheetId, data);
|
|
62711
|
+
this.collectConditionalFormatsData(sheetId, data, cfNewRanges);
|
|
62712
|
+
this.collectDataValidationsData(sheetId, data, dvNewZones);
|
|
62713
|
+
}
|
|
62714
|
+
this.autofillBorders(sheetId, bordersZones);
|
|
62715
|
+
this.autofillConditionalFormats(sheetId, cfNewRanges);
|
|
62716
|
+
this.autofillDataValidations(sheetId, dvNewZones);
|
|
62694
62717
|
this.autofillZone = undefined;
|
|
62695
62718
|
this.selection.resizeAnchorZone(this.direction, this.steps);
|
|
62696
62719
|
this.lastCellSelected = {};
|
|
@@ -62699,6 +62722,95 @@ class AutofillPlugin extends UIPlugin {
|
|
|
62699
62722
|
this.tooltip = undefined;
|
|
62700
62723
|
}
|
|
62701
62724
|
}
|
|
62725
|
+
collectBordersData(data, bordersPositions) {
|
|
62726
|
+
const key = JSON.stringify(data.border);
|
|
62727
|
+
if (!(key in bordersPositions)) {
|
|
62728
|
+
bordersPositions[key] = [];
|
|
62729
|
+
}
|
|
62730
|
+
bordersPositions[key].push(positionToZone({ col: data.col, row: data.row }));
|
|
62731
|
+
}
|
|
62732
|
+
collectConditionalFormatsData(sheetId, data, cfNewRanges) {
|
|
62733
|
+
const { originCol, originRow, col, row } = data;
|
|
62734
|
+
const cfsAtOrigin = this.getters.getRulesByCell(sheetId, originCol, originRow);
|
|
62735
|
+
const xc = toXC(col, row);
|
|
62736
|
+
for (const cf of cfsAtOrigin) {
|
|
62737
|
+
if (!(cf.id in cfNewRanges)) {
|
|
62738
|
+
cfNewRanges[cf.id] = [];
|
|
62739
|
+
}
|
|
62740
|
+
cfNewRanges[cf.id].push(xc);
|
|
62741
|
+
}
|
|
62742
|
+
}
|
|
62743
|
+
collectDataValidationsData(sheetId, data, dvNewZones) {
|
|
62744
|
+
const { originCol, originRow, col, row } = data;
|
|
62745
|
+
const cellPosition = { sheetId, col: originCol, row: originRow };
|
|
62746
|
+
const dvsAtOrigin = this.getters.getValidationRuleForCell(cellPosition);
|
|
62747
|
+
if (!dvsAtOrigin) {
|
|
62748
|
+
return;
|
|
62749
|
+
}
|
|
62750
|
+
if (!(dvsAtOrigin.id in dvNewZones)) {
|
|
62751
|
+
dvNewZones[dvsAtOrigin.id] = [];
|
|
62752
|
+
}
|
|
62753
|
+
dvNewZones[dvsAtOrigin.id].push(positionToZone({ col, row }));
|
|
62754
|
+
}
|
|
62755
|
+
autofillCell(sheetId, data) {
|
|
62756
|
+
this.dispatch("UPDATE_CELL", {
|
|
62757
|
+
sheetId,
|
|
62758
|
+
col: data.col,
|
|
62759
|
+
row: data.row,
|
|
62760
|
+
content: data.content || "",
|
|
62761
|
+
style: data.style || null,
|
|
62762
|
+
format: data.format || "",
|
|
62763
|
+
});
|
|
62764
|
+
// Still usefull in odoo ATM to autofill field sync
|
|
62765
|
+
this.dispatch("AUTOFILL_CELL", data);
|
|
62766
|
+
}
|
|
62767
|
+
autofillBorders(sheetId, bordersPositions) {
|
|
62768
|
+
for (const stringifiedBorder in bordersPositions) {
|
|
62769
|
+
const border = stringifiedBorder === "undefined" ? undefined : JSON.parse(stringifiedBorder);
|
|
62770
|
+
this.dispatch("SET_BORDERS_ON_TARGET", {
|
|
62771
|
+
sheetId,
|
|
62772
|
+
border,
|
|
62773
|
+
target: recomputeZones(bordersPositions[stringifiedBorder]),
|
|
62774
|
+
});
|
|
62775
|
+
}
|
|
62776
|
+
}
|
|
62777
|
+
autofillConditionalFormats(sheetId, cfNewRanges) {
|
|
62778
|
+
for (const cfId in cfNewRanges) {
|
|
62779
|
+
const changes = cfNewRanges[cfId];
|
|
62780
|
+
const cf = this.getters.getConditionalFormats(sheetId).find((cf) => cf.id === cfId);
|
|
62781
|
+
if (!cf) {
|
|
62782
|
+
continue;
|
|
62783
|
+
}
|
|
62784
|
+
const newCfRanges = this.getters.getAdaptedCfRanges(sheetId, cf, changes.map(toZone), []);
|
|
62785
|
+
if (newCfRanges) {
|
|
62786
|
+
this.dispatch("ADD_CONDITIONAL_FORMAT", {
|
|
62787
|
+
cf: {
|
|
62788
|
+
id: cf.id,
|
|
62789
|
+
rule: cf.rule,
|
|
62790
|
+
stopIfTrue: cf.stopIfTrue,
|
|
62791
|
+
},
|
|
62792
|
+
ranges: newCfRanges,
|
|
62793
|
+
sheetId,
|
|
62794
|
+
});
|
|
62795
|
+
}
|
|
62796
|
+
}
|
|
62797
|
+
}
|
|
62798
|
+
autofillDataValidations(sheetId, dvNewZones) {
|
|
62799
|
+
for (const dvId in dvNewZones) {
|
|
62800
|
+
const changes = dvNewZones[dvId];
|
|
62801
|
+
const dvOrigin = this.getters.getDataValidationRule(sheetId, dvId);
|
|
62802
|
+
if (!dvOrigin) {
|
|
62803
|
+
continue;
|
|
62804
|
+
}
|
|
62805
|
+
const dvRangesXcs = dvOrigin.ranges.map((range) => range.zone);
|
|
62806
|
+
const newDvRanges = recomputeZones(dvRangesXcs.concat(changes), []);
|
|
62807
|
+
this.dispatch("ADD_DATA_VALIDATION_RULE", {
|
|
62808
|
+
rule: dvOrigin,
|
|
62809
|
+
ranges: newDvRanges.map((zone) => this.getters.getRangeDataFromZone(sheetId, zone)),
|
|
62810
|
+
sheetId,
|
|
62811
|
+
});
|
|
62812
|
+
}
|
|
62813
|
+
}
|
|
62702
62814
|
/**
|
|
62703
62815
|
* Select a cell which becomes the last cell of the autofillZone
|
|
62704
62816
|
*/
|
|
@@ -62777,22 +62889,20 @@ class AutofillPlugin extends UIPlugin {
|
|
|
62777
62889
|
/**
|
|
62778
62890
|
* Generate the next cell
|
|
62779
62891
|
*/
|
|
62780
|
-
computeNewCell(generator, col, row
|
|
62892
|
+
computeNewCell(generator, col, row) {
|
|
62781
62893
|
const { cellData, tooltip, origin } = generator.next();
|
|
62782
62894
|
const { content, style, border, format } = cellData;
|
|
62783
62895
|
this.tooltip = tooltip;
|
|
62784
|
-
|
|
62785
|
-
|
|
62786
|
-
|
|
62787
|
-
|
|
62788
|
-
|
|
62789
|
-
|
|
62790
|
-
|
|
62791
|
-
|
|
62792
|
-
|
|
62793
|
-
|
|
62794
|
-
});
|
|
62795
|
-
}
|
|
62896
|
+
return {
|
|
62897
|
+
originCol: origin.col,
|
|
62898
|
+
originRow: origin.row,
|
|
62899
|
+
col,
|
|
62900
|
+
row,
|
|
62901
|
+
content,
|
|
62902
|
+
style,
|
|
62903
|
+
border,
|
|
62904
|
+
format,
|
|
62905
|
+
};
|
|
62796
62906
|
}
|
|
62797
62907
|
/**
|
|
62798
62908
|
* Get the rule associated to the current cell
|
|
@@ -62860,8 +62970,8 @@ class AutofillPlugin extends UIPlugin {
|
|
|
62860
62970
|
? position[first].value
|
|
62861
62971
|
: position[second].value;
|
|
62862
62972
|
}
|
|
62863
|
-
|
|
62864
|
-
const
|
|
62973
|
+
autofillMerge(sheetId, data) {
|
|
62974
|
+
const { originCol, originRow, col, row } = data;
|
|
62865
62975
|
const position = { sheetId, col, row };
|
|
62866
62976
|
const originPosition = { sheetId, col: originCol, row: originRow };
|
|
62867
62977
|
if (this.getters.isInMerge(position) && !this.getters.isInMerge(originPosition)) {
|
|
@@ -62888,35 +62998,6 @@ class AutofillPlugin extends UIPlugin {
|
|
|
62888
62998
|
});
|
|
62889
62999
|
}
|
|
62890
63000
|
}
|
|
62891
|
-
autofillCF(originCol, originRow, col, row) {
|
|
62892
|
-
const sheetId = this.getters.getActiveSheetId();
|
|
62893
|
-
const cfOrigin = this.getters.getRulesByCell(sheetId, originCol, originRow);
|
|
62894
|
-
for (const cf of cfOrigin) {
|
|
62895
|
-
const newCfRanges = this.getters.getAdaptedCfRanges(sheetId, cf, [positionToZone({ col, row })], []);
|
|
62896
|
-
if (newCfRanges) {
|
|
62897
|
-
this.dispatch("ADD_CONDITIONAL_FORMAT", {
|
|
62898
|
-
cf: deepCopy(cf),
|
|
62899
|
-
ranges: newCfRanges,
|
|
62900
|
-
sheetId,
|
|
62901
|
-
});
|
|
62902
|
-
}
|
|
62903
|
-
}
|
|
62904
|
-
}
|
|
62905
|
-
autofillDV(originCol, originRow, col, row) {
|
|
62906
|
-
const sheetId = this.getters.getActiveSheetId();
|
|
62907
|
-
const cellPosition = { sheetId, col: originCol, row: originRow };
|
|
62908
|
-
const dvOrigin = this.getters.getValidationRuleForCell(cellPosition);
|
|
62909
|
-
if (!dvOrigin) {
|
|
62910
|
-
return;
|
|
62911
|
-
}
|
|
62912
|
-
const dvRangesZones = dvOrigin.ranges.map((range) => range.zone);
|
|
62913
|
-
const newDvRanges = recomputeZones(dvRangesZones.concat(positionToZone({ col, row })), []);
|
|
62914
|
-
this.dispatch("ADD_DATA_VALIDATION_RULE", {
|
|
62915
|
-
rule: dvOrigin,
|
|
62916
|
-
ranges: newDvRanges.map((zone) => this.getters.getRangeDataFromZone(sheetId, zone)),
|
|
62917
|
-
sheetId,
|
|
62918
|
-
});
|
|
62919
|
-
}
|
|
62920
63001
|
// ---------------------------------------------------------------------------
|
|
62921
63002
|
// Grid rendering
|
|
62922
63003
|
// ---------------------------------------------------------------------------
|
|
@@ -75645,6 +75726,6 @@ exports.tokenColors = tokenColors;
|
|
|
75645
75726
|
exports.tokenize = tokenize;
|
|
75646
75727
|
|
|
75647
75728
|
|
|
75648
|
-
__info__.version = "18.1.
|
|
75649
|
-
__info__.date = "2025-04-
|
|
75650
|
-
__info__.hash = "
|
|
75729
|
+
__info__.version = "18.1.15";
|
|
75730
|
+
__info__.date = "2025-04-14T17:17:30.890Z";
|
|
75731
|
+
__info__.hash = "ddaea83";
|