@odoo/o-spreadsheet 16.4.6 → 16.4.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 +140 -46
- package/dist/o-spreadsheet.d.ts +0 -2
- package/dist/o-spreadsheet.esm.js +140 -46
- package/dist/o-spreadsheet.iife.js +140 -46
- package/dist/o-spreadsheet.iife.min.js +244 -243
- package/package.json +1 -1
|
@@ -611,13 +611,17 @@
|
|
|
611
611
|
return position === "after" ? base + 1 : base;
|
|
612
612
|
}
|
|
613
613
|
/**
|
|
614
|
-
*
|
|
614
|
+
* Compares two objects.
|
|
615
615
|
*/
|
|
616
616
|
function deepEquals(o1, o2) {
|
|
617
617
|
if (o1 === o2)
|
|
618
618
|
return true;
|
|
619
619
|
if ((o1 && !o2) || (o2 && !o1))
|
|
620
620
|
return false;
|
|
621
|
+
if (typeof o1 !== typeof o2)
|
|
622
|
+
return false;
|
|
623
|
+
if (typeof o1 !== "object")
|
|
624
|
+
return o1 === o2;
|
|
621
625
|
// Objects can have different keys if the values are undefined
|
|
622
626
|
const keys = new Set();
|
|
623
627
|
Object.keys(o1).forEach((key) => keys.add(key));
|
|
@@ -5262,6 +5266,7 @@
|
|
|
5262
5266
|
padding: 10px;
|
|
5263
5267
|
width: ${ERROR_TOOLTIP_WIDTH}px;
|
|
5264
5268
|
box-sizing: border-box !important;
|
|
5269
|
+
overflow-wrap: break-word;
|
|
5265
5270
|
}
|
|
5266
5271
|
`;
|
|
5267
5272
|
class ErrorToolTip extends owl.Component {
|
|
@@ -15117,13 +15122,42 @@
|
|
|
15117
15122
|
}
|
|
15118
15123
|
return true;
|
|
15119
15124
|
}
|
|
15120
|
-
/**
|
|
15125
|
+
/**
|
|
15126
|
+
* Change a content string from the given locale to its canonical form (en_US locale). Don't convert date string.
|
|
15127
|
+
*
|
|
15128
|
+
* @example
|
|
15129
|
+
* canonicalizeNumberContent("=SUM(1,5; 02/12/2012)", FR_LOCALE) // "=SUM(1.5, 02/12/2012)"
|
|
15130
|
+
* canonicalizeNumberContent("125,9", FR_LOCALE) // "125.9"
|
|
15131
|
+
* canonicalizeNumberContent("02/12/2012", FR_LOCALE) // "02/12/2012"
|
|
15132
|
+
*/
|
|
15133
|
+
function canonicalizeNumberContent(content, locale) {
|
|
15134
|
+
return content.startsWith("=")
|
|
15135
|
+
? canonicalizeFormula$1(content, locale)
|
|
15136
|
+
: canonicalizeNumberLiteral(content, locale);
|
|
15137
|
+
}
|
|
15138
|
+
/**
|
|
15139
|
+
* Change a content string from the given locale to its canonical form (en_US locale). Also convert date string.
|
|
15140
|
+
* This is destructive and won't preserve the original format.
|
|
15141
|
+
*
|
|
15142
|
+
* @example
|
|
15143
|
+
* canonicalizeContent("=SUM(1,5; 5)", FR_LOCALE) // "=SUM(1.5, 5)"
|
|
15144
|
+
* canonicalizeContent("125,9", FR_LOCALE) // "125.9"
|
|
15145
|
+
* canonicalizeContent("02/12/2012", FR_LOCALE) // "12/02/2012"
|
|
15146
|
+
* canonicalizeContent("02-12-2012", FR_LOCALE) // "12/02/2012"
|
|
15147
|
+
*/
|
|
15121
15148
|
function canonicalizeContent(content, locale) {
|
|
15122
15149
|
return content.startsWith("=")
|
|
15123
15150
|
? canonicalizeFormula$1(content, locale)
|
|
15124
|
-
:
|
|
15151
|
+
: canonicalizeLiteral(content, locale);
|
|
15125
15152
|
}
|
|
15126
|
-
/**
|
|
15153
|
+
/**
|
|
15154
|
+
* Change a content string from its canonical form (en_US locale) to the given locale. Also convert date string.
|
|
15155
|
+
*
|
|
15156
|
+
* @example
|
|
15157
|
+
* localizeContent("=SUM(1.5, 5)", FR_LOCALE) // "=SUM(1,5; 5)"
|
|
15158
|
+
* localizeContent("125.9", FR_LOCALE) // "125,9"
|
|
15159
|
+
* localizeContent("12/02/2012", FR_LOCALE) // "02/12/2012"
|
|
15160
|
+
*/
|
|
15127
15161
|
function localizeContent(content, locale) {
|
|
15128
15162
|
return content.startsWith("=")
|
|
15129
15163
|
? localizeFormula(content, locale)
|
|
@@ -15158,24 +15192,75 @@
|
|
|
15158
15192
|
return localizedFormula;
|
|
15159
15193
|
}
|
|
15160
15194
|
/**
|
|
15161
|
-
*
|
|
15195
|
+
* Change a literal string from the given locale to its canonical form (en_US locale). Don't convert date string.
|
|
15196
|
+
*
|
|
15197
|
+
* @example
|
|
15198
|
+
* canonicalizeNumberLiteral("125,9", FR_LOCALE) // "125.9"
|
|
15199
|
+
* canonicalizeNumberLiteral("02/12/2012", FR_LOCALE) // "02/12/2012"
|
|
15162
15200
|
*/
|
|
15163
|
-
function
|
|
15201
|
+
function canonicalizeNumberLiteral(content, locale) {
|
|
15164
15202
|
if (locale.decimalSeparator === "." || !isNumber(content, locale)) {
|
|
15165
15203
|
return content;
|
|
15166
15204
|
}
|
|
15167
15205
|
return content.replace(locale.decimalSeparator, ".");
|
|
15168
15206
|
}
|
|
15169
|
-
|
|
15170
|
-
|
|
15171
|
-
|
|
15207
|
+
/**
|
|
15208
|
+
* Change a content string from the given locale to its canonical form (en_US locale). Also convert date string.
|
|
15209
|
+
* This is destructive and won't preserve the original format.
|
|
15210
|
+
*
|
|
15211
|
+
* @example
|
|
15212
|
+
* canonicalizeLiteral("125,9", FR_LOCALE) // "125.9"
|
|
15213
|
+
* canonicalizeLiteral("02/12/2012", FR_LOCALE) // "12/02/2012"
|
|
15214
|
+
* canonicalizeLiteral("02-12-2012", FR_LOCALE) // "12/02/2012"
|
|
15215
|
+
*/
|
|
15216
|
+
function canonicalizeLiteral(content, locale) {
|
|
15217
|
+
if (isDateTime(content, locale)) {
|
|
15218
|
+
const dateNumber = toNumber(content, locale);
|
|
15219
|
+
let format = DEFAULT_LOCALE.dateFormat;
|
|
15220
|
+
if (!Number.isInteger(dateNumber)) {
|
|
15221
|
+
format += " " + DEFAULT_LOCALE.timeFormat;
|
|
15222
|
+
}
|
|
15223
|
+
return formatValue(dateNumber, { locale: DEFAULT_LOCALE, format });
|
|
15224
|
+
}
|
|
15225
|
+
return canonicalizeNumberLiteral(content, locale);
|
|
15226
|
+
}
|
|
15227
|
+
/**
|
|
15228
|
+
* Change a literal string from its canonical form (en_US locale) to the given locale. Don't convert date string.
|
|
15229
|
+
* This is destructive and won't preserve the original format.
|
|
15230
|
+
*
|
|
15231
|
+
* @example
|
|
15232
|
+
* localizeNumberLiteral("125.9", FR_LOCALE) // "125,9"
|
|
15233
|
+
* localizeNumberLiteral("12/02/2012", FR_LOCALE) // "12/02/2012"
|
|
15234
|
+
* localizeNumberLiteral("12-02-2012", FR_LOCALE) // "12/02/2012"
|
|
15235
|
+
*/
|
|
15236
|
+
function localizeNumberLiteral(literal, locale) {
|
|
15237
|
+
if (locale.decimalSeparator === "." || !isNumber(literal, DEFAULT_LOCALE)) {
|
|
15238
|
+
return literal;
|
|
15172
15239
|
}
|
|
15173
15240
|
const decimalNumberRegex = getDecimalNumberRegex(DEFAULT_LOCALE);
|
|
15174
|
-
const localized =
|
|
15241
|
+
const localized = literal.replace(decimalNumberRegex, (match) => {
|
|
15175
15242
|
return match.replace(".", locale.decimalSeparator);
|
|
15176
15243
|
});
|
|
15177
15244
|
return localized;
|
|
15178
15245
|
}
|
|
15246
|
+
/**
|
|
15247
|
+
* Change a literal string from its canonical form (en_US locale) to the given locale. Also convert date string.
|
|
15248
|
+
*
|
|
15249
|
+
* @example
|
|
15250
|
+
* localizeLiteral("125.9", FR_LOCALE) // "125,9"
|
|
15251
|
+
* localizeLiteral("12/02/2012", FR_LOCALE) // "02/12/2012"
|
|
15252
|
+
*/
|
|
15253
|
+
function localizeLiteral(literal, locale) {
|
|
15254
|
+
if (isDateTime(literal, DEFAULT_LOCALE)) {
|
|
15255
|
+
const dateNumber = toNumber(literal, DEFAULT_LOCALE);
|
|
15256
|
+
let format = locale.dateFormat;
|
|
15257
|
+
if (!Number.isInteger(dateNumber)) {
|
|
15258
|
+
format += " " + locale.timeFormat;
|
|
15259
|
+
}
|
|
15260
|
+
return formatValue(dateNumber, { locale, format });
|
|
15261
|
+
}
|
|
15262
|
+
return localizeNumberLiteral(literal, locale);
|
|
15263
|
+
}
|
|
15179
15264
|
function canonicalizeCFRule(cf, locale) {
|
|
15180
15265
|
return changeCFRuleLocale(cf, (content) => canonicalizeContent(content, locale));
|
|
15181
15266
|
}
|
|
@@ -15532,7 +15617,9 @@
|
|
|
15532
15617
|
save() {
|
|
15533
15618
|
const { col, row } = this.props.cellPosition;
|
|
15534
15619
|
const locale = this.env.model.getters.getLocale();
|
|
15535
|
-
const label = this.link.label
|
|
15620
|
+
const label = this.link.label
|
|
15621
|
+
? canonicalizeNumberContent(this.link.label, locale)
|
|
15622
|
+
: this.link.url;
|
|
15536
15623
|
this.env.model.dispatch("UPDATE_CELL", {
|
|
15537
15624
|
col: col,
|
|
15538
15625
|
row: row,
|
|
@@ -25302,9 +25389,11 @@
|
|
|
25302
25389
|
}
|
|
25303
25390
|
}
|
|
25304
25391
|
function updateMousePosition(e) {
|
|
25305
|
-
|
|
25306
|
-
|
|
25307
|
-
|
|
25392
|
+
if (gridRef.el === e.target) {
|
|
25393
|
+
x = e.offsetX;
|
|
25394
|
+
y = e.offsetY;
|
|
25395
|
+
lastMoved = Date.now();
|
|
25396
|
+
}
|
|
25308
25397
|
}
|
|
25309
25398
|
function recompute() {
|
|
25310
25399
|
const { col, row } = getPosition();
|
|
@@ -36677,8 +36766,7 @@
|
|
|
36677
36766
|
if (cell.type === CellValueType.error) {
|
|
36678
36767
|
return false;
|
|
36679
36768
|
}
|
|
36680
|
-
const
|
|
36681
|
-
const values = rule.values.map((val) => parseLiteral(val, locale));
|
|
36769
|
+
const values = rule.values.map((val) => parseLiteral(val, DEFAULT_LOCALE));
|
|
36682
36770
|
switch (rule.operator) {
|
|
36683
36771
|
case "IsEmpty":
|
|
36684
36772
|
return cell.value.toString().trim() === "";
|
|
@@ -38762,7 +38850,7 @@
|
|
|
38762
38850
|
const replaceRegex = new RegExp(this.currentSearchRegex.source, this.currentSearchRegex.flags + "g");
|
|
38763
38851
|
const toReplace = this.getSearchableString({ sheetId, col, row });
|
|
38764
38852
|
const content = toReplace.replace(replaceRegex, replaceWith);
|
|
38765
|
-
const canonicalContent =
|
|
38853
|
+
const canonicalContent = canonicalizeNumberContent(content, this.getters.getLocale());
|
|
38766
38854
|
this.dispatch("UPDATE_CELL", { sheetId, col, row, content: canonicalContent });
|
|
38767
38855
|
}
|
|
38768
38856
|
/**
|
|
@@ -40936,7 +41024,7 @@
|
|
|
40936
41024
|
sheetId,
|
|
40937
41025
|
col: col + index,
|
|
40938
41026
|
row,
|
|
40939
|
-
content:
|
|
41027
|
+
content: canonicalizeNumberContent(content, this.getters.getLocale()),
|
|
40940
41028
|
format: "",
|
|
40941
41029
|
style: mainCell?.style || null,
|
|
40942
41030
|
});
|
|
@@ -41122,6 +41210,7 @@
|
|
|
41122
41210
|
cells;
|
|
41123
41211
|
copiedTables;
|
|
41124
41212
|
zones;
|
|
41213
|
+
uuidGenerator = new UuidGenerator();
|
|
41125
41214
|
constructor(zones, operation, getters, dispatch, selection) {
|
|
41126
41215
|
super(operation, getters, dispatch, selection);
|
|
41127
41216
|
if (!zones.length) {
|
|
@@ -41583,8 +41672,9 @@
|
|
|
41583
41672
|
this.adaptCFRules(origin.sheetId, cf, [xc], toRemoveRange);
|
|
41584
41673
|
}
|
|
41585
41674
|
else {
|
|
41586
|
-
this.adaptCFRules(target.sheetId, cf, [xc], []);
|
|
41587
41675
|
this.adaptCFRules(origin.sheetId, cf, [], toRemoveRange);
|
|
41676
|
+
const cfToCopyTo = this.getCFToCopyTo(target.sheetId, cf);
|
|
41677
|
+
this.adaptCFRules(target.sheetId, cfToCopyTo, [xc], []);
|
|
41588
41678
|
}
|
|
41589
41679
|
}
|
|
41590
41680
|
}
|
|
@@ -41608,6 +41698,12 @@
|
|
|
41608
41698
|
sheetId,
|
|
41609
41699
|
});
|
|
41610
41700
|
}
|
|
41701
|
+
getCFToCopyTo(targetSheetId, originCF) {
|
|
41702
|
+
const cfInTarget = this.getters
|
|
41703
|
+
.getConditionalFormats(targetSheetId)
|
|
41704
|
+
.find((cf) => cf.stopIfTrue === originCF.stopIfTrue && deepEquals(cf.rule, originCF.rule));
|
|
41705
|
+
return cfInTarget ? cfInTarget : { ...originCF, id: this.uuidGenerator.uuidv4(), ranges: [] };
|
|
41706
|
+
}
|
|
41611
41707
|
}
|
|
41612
41708
|
|
|
41613
41709
|
/** State of the clipboard when copying/cutting figures */
|
|
@@ -41739,7 +41835,7 @@
|
|
|
41739
41835
|
function canonicalizeNumberValue(content, locale) {
|
|
41740
41836
|
return content.startsWith("=")
|
|
41741
41837
|
? canonicalizeFormula(content, locale)
|
|
41742
|
-
:
|
|
41838
|
+
: canonicalizeNumberLiteral(content, locale);
|
|
41743
41839
|
}
|
|
41744
41840
|
/** Change a formula to its canonical form (en_US locale) */
|
|
41745
41841
|
function canonicalizeFormula(formula, locale) {
|
|
@@ -41856,7 +41952,7 @@
|
|
|
41856
41952
|
allowDispatch(cmd) {
|
|
41857
41953
|
switch (cmd.type) {
|
|
41858
41954
|
case "CUT":
|
|
41859
|
-
const zones =
|
|
41955
|
+
const zones = this.getters.getSelectedZones();
|
|
41860
41956
|
const state = this.getClipboardState(zones, cmd.type);
|
|
41861
41957
|
return state.isCutAllowed(zones);
|
|
41862
41958
|
case "PASTE":
|
|
@@ -41891,7 +41987,7 @@
|
|
|
41891
41987
|
switch (cmd.type) {
|
|
41892
41988
|
case "COPY":
|
|
41893
41989
|
case "CUT":
|
|
41894
|
-
const zones =
|
|
41990
|
+
const zones = this.getters.getSelectedZones();
|
|
41895
41991
|
this.state = this.getClipboardState(zones, cmd.type);
|
|
41896
41992
|
this.status = "visible";
|
|
41897
41993
|
this.originSheetId = this.getters.getActiveSheetId();
|
|
@@ -42541,7 +42637,7 @@
|
|
|
42541
42637
|
if (content) {
|
|
42542
42638
|
const sheetId = this.getters.getActiveSheetId();
|
|
42543
42639
|
const cell = this.getters.getEvaluatedCell({ sheetId, col: this.col, row: this.row });
|
|
42544
|
-
content =
|
|
42640
|
+
content = canonicalizeNumberContent(content, this.getters.getLocale());
|
|
42545
42641
|
if (content.startsWith("=")) {
|
|
42546
42642
|
const left = this.currentTokens.filter((t) => t.type === "LEFT_PAREN").length;
|
|
42547
42643
|
const right = this.currentTokens.filter((t) => t.type === "RIGHT_PAREN").length;
|
|
@@ -43562,26 +43658,24 @@
|
|
|
43562
43658
|
const isBasedBefore = cmd.base < start;
|
|
43563
43659
|
const deltaCol = isBasedBefore && isCol ? thickness : 0;
|
|
43564
43660
|
const deltaRow = isBasedBefore && !isCol ? thickness : 0;
|
|
43565
|
-
|
|
43566
|
-
|
|
43567
|
-
|
|
43568
|
-
|
|
43569
|
-
|
|
43570
|
-
|
|
43571
|
-
|
|
43572
|
-
|
|
43573
|
-
|
|
43574
|
-
|
|
43575
|
-
|
|
43576
|
-
|
|
43577
|
-
|
|
43578
|
-
|
|
43579
|
-
|
|
43580
|
-
|
|
43581
|
-
|
|
43582
|
-
|
|
43583
|
-
],
|
|
43584
|
-
});
|
|
43661
|
+
const target = [
|
|
43662
|
+
{
|
|
43663
|
+
left: isCol ? start + deltaCol : 0,
|
|
43664
|
+
right: isCol ? end + deltaCol : this.getters.getNumberCols(cmd.sheetId) - 1,
|
|
43665
|
+
top: !isCol ? start + deltaRow : 0,
|
|
43666
|
+
bottom: !isCol ? end + deltaRow : this.getters.getNumberRows(cmd.sheetId) - 1,
|
|
43667
|
+
},
|
|
43668
|
+
];
|
|
43669
|
+
const state = new ClipboardCellsState(target, "CUT", this.getters, this.dispatch, this.selection);
|
|
43670
|
+
const pasteTarget = [
|
|
43671
|
+
{
|
|
43672
|
+
left: isCol ? cmd.base : 0,
|
|
43673
|
+
right: isCol ? cmd.base + thickness - 1 : this.getters.getNumberCols(cmd.sheetId) - 1,
|
|
43674
|
+
top: !isCol ? cmd.base : 0,
|
|
43675
|
+
bottom: !isCol ? cmd.base + thickness - 1 : this.getters.getNumberRows(cmd.sheetId) - 1,
|
|
43676
|
+
},
|
|
43677
|
+
];
|
|
43678
|
+
state.paste(pasteTarget, { selectTarget: true });
|
|
43585
43679
|
const toRemove = isBasedBefore ? cmd.elements.map((el) => el + thickness) : cmd.elements;
|
|
43586
43680
|
let currentIndex = cmd.base;
|
|
43587
43681
|
for (const element of toRemove) {
|
|
@@ -50601,9 +50695,9 @@
|
|
|
50601
50695
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
50602
50696
|
|
|
50603
50697
|
|
|
50604
|
-
__info__.version = '16.4.
|
|
50605
|
-
__info__.date = '2023-09-
|
|
50606
|
-
__info__.hash = '
|
|
50698
|
+
__info__.version = '16.4.7';
|
|
50699
|
+
__info__.date = '2023-09-21T15:58:11.039Z';
|
|
50700
|
+
__info__.hash = 'eccdcce';
|
|
50607
50701
|
|
|
50608
50702
|
|
|
50609
50703
|
})(this.o_spreadsheet = this.o_spreadsheet || {}, owl);
|