@odoo/o-spreadsheet 18.2.6 → 18.2.7
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 +3 -3
- 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.2.
|
|
6
|
-
* @date 2025-04-
|
|
7
|
-
* @hash
|
|
5
|
+
* @version 18.2.7
|
|
6
|
+
* @date 2025-04-14T17:19:31.011Z
|
|
7
|
+
* @hash e187958
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
'use strict';
|
|
@@ -3575,6 +3575,7 @@ const coreTypes = new Set([
|
|
|
3575
3575
|
"CLEAR_FORMATTING",
|
|
3576
3576
|
"SET_BORDER",
|
|
3577
3577
|
"SET_ZONE_BORDERS",
|
|
3578
|
+
"SET_BORDERS_ON_TARGET",
|
|
3578
3579
|
/** CHART */
|
|
3579
3580
|
"CREATE_CHART",
|
|
3580
3581
|
"UPDATE_CHART",
|
|
@@ -6724,6 +6725,7 @@ class AbstractCellClipboardHandler extends ClipboardHandler {
|
|
|
6724
6725
|
}
|
|
6725
6726
|
|
|
6726
6727
|
class BorderClipboardHandler extends AbstractCellClipboardHandler {
|
|
6728
|
+
queuedBordersToAdd = {};
|
|
6727
6729
|
copy(data) {
|
|
6728
6730
|
const sheetId = data.sheetId;
|
|
6729
6731
|
if (data.zones.length === 0) {
|
|
@@ -6754,6 +6756,7 @@ class BorderClipboardHandler extends AbstractCellClipboardHandler {
|
|
|
6754
6756
|
const { left, top } = zones[0];
|
|
6755
6757
|
this.pasteZone(sheetId, left, top, content.borders);
|
|
6756
6758
|
}
|
|
6759
|
+
this.executeQueuedChanges(sheetId);
|
|
6757
6760
|
}
|
|
6758
6761
|
pasteZone(sheetId, col, row, borders) {
|
|
6759
6762
|
for (const [r, rowBorders] of borders.entries()) {
|
|
@@ -6772,7 +6775,20 @@ class BorderClipboardHandler extends AbstractCellClipboardHandler {
|
|
|
6772
6775
|
...targetBorders,
|
|
6773
6776
|
...originBorders,
|
|
6774
6777
|
};
|
|
6775
|
-
|
|
6778
|
+
const borderKey = JSON.stringify(border);
|
|
6779
|
+
if (!this.queuedBordersToAdd[borderKey]) {
|
|
6780
|
+
this.queuedBordersToAdd[borderKey] = [];
|
|
6781
|
+
}
|
|
6782
|
+
this.queuedBordersToAdd[borderKey].push(positionToZone(target));
|
|
6783
|
+
}
|
|
6784
|
+
executeQueuedChanges(pasteSheetTarget) {
|
|
6785
|
+
for (const borderKey in this.queuedBordersToAdd) {
|
|
6786
|
+
const zones = this.queuedBordersToAdd[borderKey];
|
|
6787
|
+
const border = JSON.parse(borderKey);
|
|
6788
|
+
const target = recomputeZones(zones, []);
|
|
6789
|
+
this.dispatch("SET_BORDERS_ON_TARGET", { sheetId: pasteSheetTarget, target, border });
|
|
6790
|
+
}
|
|
6791
|
+
this.queuedBordersToAdd = {};
|
|
6776
6792
|
}
|
|
6777
6793
|
}
|
|
6778
6794
|
|
|
@@ -8712,12 +8728,13 @@ class ConditionalFormatClipboardHandler extends AbstractCellClipboardHandler {
|
|
|
8712
8728
|
}
|
|
8713
8729
|
pasteCf(origin, target, isCutOperation) {
|
|
8714
8730
|
if (origin?.rules && origin.rules.length > 0) {
|
|
8731
|
+
const originZone = positionToZone(origin.position);
|
|
8715
8732
|
const zone = positionToZone(target);
|
|
8716
8733
|
for (const rule of origin.rules) {
|
|
8717
8734
|
const toRemoveZones = [];
|
|
8718
8735
|
if (isCutOperation) {
|
|
8719
8736
|
//remove from current rule
|
|
8720
|
-
toRemoveZones.push(
|
|
8737
|
+
toRemoveZones.push(originZone);
|
|
8721
8738
|
}
|
|
8722
8739
|
if (origin.position.sheetId === target.sheetId) {
|
|
8723
8740
|
this.adaptCFRules(origin.position.sheetId, rule, [zone], toRemoveZones);
|
|
@@ -8831,6 +8848,7 @@ class DataValidationClipboardHandler extends AbstractCellClipboardHandler {
|
|
|
8831
8848
|
pasteDataValidation(origin, target, isCutOperation) {
|
|
8832
8849
|
if (origin) {
|
|
8833
8850
|
const zone = positionToZone(target);
|
|
8851
|
+
const originZone = positionToZone(origin.position);
|
|
8834
8852
|
const rule = origin.rule;
|
|
8835
8853
|
if (!rule) {
|
|
8836
8854
|
const targetRule = this.getters.getValidationRuleForCell(target);
|
|
@@ -8842,7 +8860,7 @@ class DataValidationClipboardHandler extends AbstractCellClipboardHandler {
|
|
|
8842
8860
|
}
|
|
8843
8861
|
const toRemoveZone = [];
|
|
8844
8862
|
if (isCutOperation) {
|
|
8845
|
-
toRemoveZone.push(
|
|
8863
|
+
toRemoveZone.push(originZone);
|
|
8846
8864
|
}
|
|
8847
8865
|
if (origin.position.sheetId === target.sheetId) {
|
|
8848
8866
|
const copyToRule = this.getDataValidationRuleToCopyTo(target.sheetId, rule, false);
|
|
@@ -8902,7 +8920,7 @@ class DataValidationClipboardHandler extends AbstractCellClipboardHandler {
|
|
|
8902
8920
|
continue;
|
|
8903
8921
|
}
|
|
8904
8922
|
this.dispatch("ADD_DATA_VALIDATION_RULE", {
|
|
8905
|
-
rule: dv,
|
|
8923
|
+
rule: { id: dv.id, criterion: dv.criterion, isBlocking: dv.isBlocking },
|
|
8906
8924
|
ranges: newDvZones.map((zone) => this.getters.getRangeDataFromZone(sheetId, zone)),
|
|
8907
8925
|
sheetId,
|
|
8908
8926
|
});
|
|
@@ -53313,6 +53331,15 @@ class BordersPlugin extends CorePlugin {
|
|
|
53313
53331
|
case "SET_BORDER":
|
|
53314
53332
|
this.setBorder(cmd.sheetId, cmd.col, cmd.row, cmd.border);
|
|
53315
53333
|
break;
|
|
53334
|
+
case "SET_BORDERS_ON_TARGET":
|
|
53335
|
+
for (const zone of cmd.target) {
|
|
53336
|
+
for (let row = zone.top; row <= zone.bottom; row++) {
|
|
53337
|
+
for (let col = zone.left; col <= zone.right; col++) {
|
|
53338
|
+
this.setBorder(cmd.sheetId, col, row, cmd.border);
|
|
53339
|
+
}
|
|
53340
|
+
}
|
|
53341
|
+
}
|
|
53342
|
+
break;
|
|
53316
53343
|
case "SET_ZONE_BORDERS":
|
|
53317
53344
|
if (cmd.border) {
|
|
53318
53345
|
const target = cmd.target.map((zone) => this.getters.expandZone(cmd.sheetId, zone));
|
|
@@ -63075,25 +63102,6 @@ class AutofillPlugin extends UIPlugin {
|
|
|
63075
63102
|
case "AUTOFILL_AUTO":
|
|
63076
63103
|
this.autofillAuto();
|
|
63077
63104
|
break;
|
|
63078
|
-
case "AUTOFILL_CELL":
|
|
63079
|
-
this.autoFillMerge(cmd.originCol, cmd.originRow, cmd.col, cmd.row);
|
|
63080
|
-
const sheetId = this.getters.getActiveSheetId();
|
|
63081
|
-
this.dispatch("UPDATE_CELL", {
|
|
63082
|
-
sheetId,
|
|
63083
|
-
col: cmd.col,
|
|
63084
|
-
row: cmd.row,
|
|
63085
|
-
style: cmd.style || null,
|
|
63086
|
-
content: cmd.content || "",
|
|
63087
|
-
format: cmd.format || "",
|
|
63088
|
-
});
|
|
63089
|
-
this.dispatch("SET_BORDER", {
|
|
63090
|
-
sheetId,
|
|
63091
|
-
col: cmd.col,
|
|
63092
|
-
row: cmd.row,
|
|
63093
|
-
border: cmd.border,
|
|
63094
|
-
});
|
|
63095
|
-
this.autofillCF(cmd.originCol, cmd.originRow, cmd.col, cmd.row);
|
|
63096
|
-
this.autofillDV(cmd.originCol, cmd.originRow, cmd.col, cmd.row);
|
|
63097
63105
|
}
|
|
63098
63106
|
}
|
|
63099
63107
|
// ---------------------------------------------------------------------------
|
|
@@ -63117,6 +63125,7 @@ class AutofillPlugin extends UIPlugin {
|
|
|
63117
63125
|
}
|
|
63118
63126
|
const source = this.getters.getSelectedZone();
|
|
63119
63127
|
const target = this.autofillZone;
|
|
63128
|
+
const autofillCellsData = [];
|
|
63120
63129
|
switch (this.direction) {
|
|
63121
63130
|
case "down" /* DIRECTION.DOWN */:
|
|
63122
63131
|
for (let col = source.left; col <= source.right; col++) {
|
|
@@ -63126,7 +63135,7 @@ class AutofillPlugin extends UIPlugin {
|
|
|
63126
63135
|
}
|
|
63127
63136
|
const generator = this.createGenerator(xcs);
|
|
63128
63137
|
for (let row = target.top; row <= target.bottom; row++) {
|
|
63129
|
-
this.computeNewCell(generator, col, row
|
|
63138
|
+
autofillCellsData.push(this.computeNewCell(generator, col, row));
|
|
63130
63139
|
}
|
|
63131
63140
|
}
|
|
63132
63141
|
break;
|
|
@@ -63138,7 +63147,7 @@ class AutofillPlugin extends UIPlugin {
|
|
|
63138
63147
|
}
|
|
63139
63148
|
const generator = this.createGenerator(xcs);
|
|
63140
63149
|
for (let row = target.bottom; row >= target.top; row--) {
|
|
63141
|
-
this.computeNewCell(generator, col, row
|
|
63150
|
+
autofillCellsData.push(this.computeNewCell(generator, col, row));
|
|
63142
63151
|
}
|
|
63143
63152
|
}
|
|
63144
63153
|
break;
|
|
@@ -63150,7 +63159,7 @@ class AutofillPlugin extends UIPlugin {
|
|
|
63150
63159
|
}
|
|
63151
63160
|
const generator = this.createGenerator(xcs);
|
|
63152
63161
|
for (let col = target.right; col >= target.left; col--) {
|
|
63153
|
-
this.computeNewCell(generator, col, row
|
|
63162
|
+
autofillCellsData.push(this.computeNewCell(generator, col, row));
|
|
63154
63163
|
}
|
|
63155
63164
|
}
|
|
63156
63165
|
break;
|
|
@@ -63162,12 +63171,26 @@ class AutofillPlugin extends UIPlugin {
|
|
|
63162
63171
|
}
|
|
63163
63172
|
const generator = this.createGenerator(xcs);
|
|
63164
63173
|
for (let col = target.left; col <= target.right; col++) {
|
|
63165
|
-
this.computeNewCell(generator, col, row
|
|
63174
|
+
autofillCellsData.push(this.computeNewCell(generator, col, row));
|
|
63166
63175
|
}
|
|
63167
63176
|
}
|
|
63168
63177
|
break;
|
|
63169
63178
|
}
|
|
63170
63179
|
if (apply) {
|
|
63180
|
+
const bordersZones = {};
|
|
63181
|
+
const cfNewRanges = {};
|
|
63182
|
+
const dvNewZones = {};
|
|
63183
|
+
const sheetId = this.getters.getActiveSheetId();
|
|
63184
|
+
for (const data of autofillCellsData) {
|
|
63185
|
+
this.collectBordersData(data, bordersZones);
|
|
63186
|
+
this.autofillMerge(sheetId, data);
|
|
63187
|
+
this.autofillCell(sheetId, data);
|
|
63188
|
+
this.collectConditionalFormatsData(sheetId, data, cfNewRanges);
|
|
63189
|
+
this.collectDataValidationsData(sheetId, data, dvNewZones);
|
|
63190
|
+
}
|
|
63191
|
+
this.autofillBorders(sheetId, bordersZones);
|
|
63192
|
+
this.autofillConditionalFormats(sheetId, cfNewRanges);
|
|
63193
|
+
this.autofillDataValidations(sheetId, dvNewZones);
|
|
63171
63194
|
this.autofillZone = undefined;
|
|
63172
63195
|
this.selection.resizeAnchorZone(this.direction, this.steps);
|
|
63173
63196
|
this.lastCellSelected = {};
|
|
@@ -63176,6 +63199,95 @@ class AutofillPlugin extends UIPlugin {
|
|
|
63176
63199
|
this.tooltip = undefined;
|
|
63177
63200
|
}
|
|
63178
63201
|
}
|
|
63202
|
+
collectBordersData(data, bordersPositions) {
|
|
63203
|
+
const key = JSON.stringify(data.border);
|
|
63204
|
+
if (!(key in bordersPositions)) {
|
|
63205
|
+
bordersPositions[key] = [];
|
|
63206
|
+
}
|
|
63207
|
+
bordersPositions[key].push(positionToZone({ col: data.col, row: data.row }));
|
|
63208
|
+
}
|
|
63209
|
+
collectConditionalFormatsData(sheetId, data, cfNewRanges) {
|
|
63210
|
+
const { originCol, originRow, col, row } = data;
|
|
63211
|
+
const cfsAtOrigin = this.getters.getRulesByCell(sheetId, originCol, originRow);
|
|
63212
|
+
const xc = toXC(col, row);
|
|
63213
|
+
for (const cf of cfsAtOrigin) {
|
|
63214
|
+
if (!(cf.id in cfNewRanges)) {
|
|
63215
|
+
cfNewRanges[cf.id] = [];
|
|
63216
|
+
}
|
|
63217
|
+
cfNewRanges[cf.id].push(xc);
|
|
63218
|
+
}
|
|
63219
|
+
}
|
|
63220
|
+
collectDataValidationsData(sheetId, data, dvNewZones) {
|
|
63221
|
+
const { originCol, originRow, col, row } = data;
|
|
63222
|
+
const cellPosition = { sheetId, col: originCol, row: originRow };
|
|
63223
|
+
const dvsAtOrigin = this.getters.getValidationRuleForCell(cellPosition);
|
|
63224
|
+
if (!dvsAtOrigin) {
|
|
63225
|
+
return;
|
|
63226
|
+
}
|
|
63227
|
+
if (!(dvsAtOrigin.id in dvNewZones)) {
|
|
63228
|
+
dvNewZones[dvsAtOrigin.id] = [];
|
|
63229
|
+
}
|
|
63230
|
+
dvNewZones[dvsAtOrigin.id].push(positionToZone({ col, row }));
|
|
63231
|
+
}
|
|
63232
|
+
autofillCell(sheetId, data) {
|
|
63233
|
+
this.dispatch("UPDATE_CELL", {
|
|
63234
|
+
sheetId,
|
|
63235
|
+
col: data.col,
|
|
63236
|
+
row: data.row,
|
|
63237
|
+
content: data.content || "",
|
|
63238
|
+
style: data.style || null,
|
|
63239
|
+
format: data.format || "",
|
|
63240
|
+
});
|
|
63241
|
+
// Still usefull in odoo ATM to autofill field sync
|
|
63242
|
+
this.dispatch("AUTOFILL_CELL", data);
|
|
63243
|
+
}
|
|
63244
|
+
autofillBorders(sheetId, bordersPositions) {
|
|
63245
|
+
for (const stringifiedBorder in bordersPositions) {
|
|
63246
|
+
const border = stringifiedBorder === "undefined" ? undefined : JSON.parse(stringifiedBorder);
|
|
63247
|
+
this.dispatch("SET_BORDERS_ON_TARGET", {
|
|
63248
|
+
sheetId,
|
|
63249
|
+
border,
|
|
63250
|
+
target: recomputeZones(bordersPositions[stringifiedBorder]),
|
|
63251
|
+
});
|
|
63252
|
+
}
|
|
63253
|
+
}
|
|
63254
|
+
autofillConditionalFormats(sheetId, cfNewRanges) {
|
|
63255
|
+
for (const cfId in cfNewRanges) {
|
|
63256
|
+
const changes = cfNewRanges[cfId];
|
|
63257
|
+
const cf = this.getters.getConditionalFormats(sheetId).find((cf) => cf.id === cfId);
|
|
63258
|
+
if (!cf) {
|
|
63259
|
+
continue;
|
|
63260
|
+
}
|
|
63261
|
+
const newCfRanges = this.getters.getAdaptedCfRanges(sheetId, cf, changes.map(toZone), []);
|
|
63262
|
+
if (newCfRanges) {
|
|
63263
|
+
this.dispatch("ADD_CONDITIONAL_FORMAT", {
|
|
63264
|
+
cf: {
|
|
63265
|
+
id: cf.id,
|
|
63266
|
+
rule: cf.rule,
|
|
63267
|
+
stopIfTrue: cf.stopIfTrue,
|
|
63268
|
+
},
|
|
63269
|
+
ranges: newCfRanges,
|
|
63270
|
+
sheetId,
|
|
63271
|
+
});
|
|
63272
|
+
}
|
|
63273
|
+
}
|
|
63274
|
+
}
|
|
63275
|
+
autofillDataValidations(sheetId, dvNewZones) {
|
|
63276
|
+
for (const dvId in dvNewZones) {
|
|
63277
|
+
const changes = dvNewZones[dvId];
|
|
63278
|
+
const dvOrigin = this.getters.getDataValidationRule(sheetId, dvId);
|
|
63279
|
+
if (!dvOrigin) {
|
|
63280
|
+
continue;
|
|
63281
|
+
}
|
|
63282
|
+
const dvRangesXcs = dvOrigin.ranges.map((range) => range.zone);
|
|
63283
|
+
const newDvRanges = recomputeZones(dvRangesXcs.concat(changes), []);
|
|
63284
|
+
this.dispatch("ADD_DATA_VALIDATION_RULE", {
|
|
63285
|
+
rule: dvOrigin,
|
|
63286
|
+
ranges: newDvRanges.map((zone) => this.getters.getRangeDataFromZone(sheetId, zone)),
|
|
63287
|
+
sheetId,
|
|
63288
|
+
});
|
|
63289
|
+
}
|
|
63290
|
+
}
|
|
63179
63291
|
/**
|
|
63180
63292
|
* Select a cell which becomes the last cell of the autofillZone
|
|
63181
63293
|
*/
|
|
@@ -63254,22 +63366,20 @@ class AutofillPlugin extends UIPlugin {
|
|
|
63254
63366
|
/**
|
|
63255
63367
|
* Generate the next cell
|
|
63256
63368
|
*/
|
|
63257
|
-
computeNewCell(generator, col, row
|
|
63369
|
+
computeNewCell(generator, col, row) {
|
|
63258
63370
|
const { cellData, tooltip, origin } = generator.next();
|
|
63259
63371
|
const { content, style, border, format } = cellData;
|
|
63260
63372
|
this.tooltip = tooltip;
|
|
63261
|
-
|
|
63262
|
-
|
|
63263
|
-
|
|
63264
|
-
|
|
63265
|
-
|
|
63266
|
-
|
|
63267
|
-
|
|
63268
|
-
|
|
63269
|
-
|
|
63270
|
-
|
|
63271
|
-
});
|
|
63272
|
-
}
|
|
63373
|
+
return {
|
|
63374
|
+
originCol: origin.col,
|
|
63375
|
+
originRow: origin.row,
|
|
63376
|
+
col,
|
|
63377
|
+
row,
|
|
63378
|
+
content,
|
|
63379
|
+
style,
|
|
63380
|
+
border,
|
|
63381
|
+
format,
|
|
63382
|
+
};
|
|
63273
63383
|
}
|
|
63274
63384
|
/**
|
|
63275
63385
|
* Get the rule associated to the current cell
|
|
@@ -63337,8 +63447,8 @@ class AutofillPlugin extends UIPlugin {
|
|
|
63337
63447
|
? position[first].value
|
|
63338
63448
|
: position[second].value;
|
|
63339
63449
|
}
|
|
63340
|
-
|
|
63341
|
-
const
|
|
63450
|
+
autofillMerge(sheetId, data) {
|
|
63451
|
+
const { originCol, originRow, col, row } = data;
|
|
63342
63452
|
const position = { sheetId, col, row };
|
|
63343
63453
|
const originPosition = { sheetId, col: originCol, row: originRow };
|
|
63344
63454
|
if (this.getters.isInMerge(position) && !this.getters.isInMerge(originPosition)) {
|
|
@@ -63365,35 +63475,6 @@ class AutofillPlugin extends UIPlugin {
|
|
|
63365
63475
|
});
|
|
63366
63476
|
}
|
|
63367
63477
|
}
|
|
63368
|
-
autofillCF(originCol, originRow, col, row) {
|
|
63369
|
-
const sheetId = this.getters.getActiveSheetId();
|
|
63370
|
-
const cfOrigin = this.getters.getRulesByCell(sheetId, originCol, originRow);
|
|
63371
|
-
for (const cf of cfOrigin) {
|
|
63372
|
-
const newCfRanges = this.getters.getAdaptedCfRanges(sheetId, cf, [positionToZone({ col, row })], []);
|
|
63373
|
-
if (newCfRanges) {
|
|
63374
|
-
this.dispatch("ADD_CONDITIONAL_FORMAT", {
|
|
63375
|
-
cf: deepCopy(cf),
|
|
63376
|
-
ranges: newCfRanges,
|
|
63377
|
-
sheetId,
|
|
63378
|
-
});
|
|
63379
|
-
}
|
|
63380
|
-
}
|
|
63381
|
-
}
|
|
63382
|
-
autofillDV(originCol, originRow, col, row) {
|
|
63383
|
-
const sheetId = this.getters.getActiveSheetId();
|
|
63384
|
-
const cellPosition = { sheetId, col: originCol, row: originRow };
|
|
63385
|
-
const dvOrigin = this.getters.getValidationRuleForCell(cellPosition);
|
|
63386
|
-
if (!dvOrigin) {
|
|
63387
|
-
return;
|
|
63388
|
-
}
|
|
63389
|
-
const dvRangesZones = dvOrigin.ranges.map((range) => range.zone);
|
|
63390
|
-
const newDvRanges = recomputeZones(dvRangesZones.concat(positionToZone({ col, row })), []);
|
|
63391
|
-
this.dispatch("ADD_DATA_VALIDATION_RULE", {
|
|
63392
|
-
rule: dvOrigin,
|
|
63393
|
-
ranges: newDvRanges.map((zone) => this.getters.getRangeDataFromZone(sheetId, zone)),
|
|
63394
|
-
sheetId,
|
|
63395
|
-
});
|
|
63396
|
-
}
|
|
63397
63478
|
// ---------------------------------------------------------------------------
|
|
63398
63479
|
// Grid rendering
|
|
63399
63480
|
// ---------------------------------------------------------------------------
|
|
@@ -76109,6 +76190,6 @@ exports.tokenColors = tokenColors;
|
|
|
76109
76190
|
exports.tokenize = tokenize;
|
|
76110
76191
|
|
|
76111
76192
|
|
|
76112
|
-
__info__.version = "18.2.
|
|
76113
|
-
__info__.date = "2025-04-
|
|
76114
|
-
__info__.hash = "
|
|
76193
|
+
__info__.version = "18.2.7";
|
|
76194
|
+
__info__.date = "2025-04-14T17:19:31.011Z";
|
|
76195
|
+
__info__.hash = "e187958";
|