@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.
@@ -614,13 +614,17 @@ function getAddHeaderStartIndex(position, base) {
614
614
  return position === "after" ? base + 1 : base;
615
615
  }
616
616
  /**
617
- * Compare two objects.
617
+ * Compares two objects.
618
618
  */
619
619
  function deepEquals(o1, o2) {
620
620
  if (o1 === o2)
621
621
  return true;
622
622
  if ((o1 && !o2) || (o2 && !o1))
623
623
  return false;
624
+ if (typeof o1 !== typeof o2)
625
+ return false;
626
+ if (typeof o1 !== "object")
627
+ return o1 === o2;
624
628
  // Objects can have different keys if the values are undefined
625
629
  const keys = new Set();
626
630
  Object.keys(o1).forEach((key) => keys.add(key));
@@ -5265,6 +5269,7 @@ css /* scss */ `
5265
5269
  padding: 10px;
5266
5270
  width: ${ERROR_TOOLTIP_WIDTH}px;
5267
5271
  box-sizing: border-box !important;
5272
+ overflow-wrap: break-word;
5268
5273
  }
5269
5274
  `;
5270
5275
  class ErrorToolTip extends owl.Component {
@@ -15120,13 +15125,42 @@ function isValidLocale(locale) {
15120
15125
  }
15121
15126
  return true;
15122
15127
  }
15123
- /** Change a content string to its canonical form (en_US locale) */
15128
+ /**
15129
+ * Change a content string from the given locale to its canonical form (en_US locale). Don't convert date string.
15130
+ *
15131
+ * @example
15132
+ * canonicalizeNumberContent("=SUM(1,5; 02/12/2012)", FR_LOCALE) // "=SUM(1.5, 02/12/2012)"
15133
+ * canonicalizeNumberContent("125,9", FR_LOCALE) // "125.9"
15134
+ * canonicalizeNumberContent("02/12/2012", FR_LOCALE) // "02/12/2012"
15135
+ */
15136
+ function canonicalizeNumberContent(content, locale) {
15137
+ return content.startsWith("=")
15138
+ ? canonicalizeFormula$1(content, locale)
15139
+ : canonicalizeNumberLiteral(content, locale);
15140
+ }
15141
+ /**
15142
+ * Change a content string from the given locale to its canonical form (en_US locale). Also convert date string.
15143
+ * This is destructive and won't preserve the original format.
15144
+ *
15145
+ * @example
15146
+ * canonicalizeContent("=SUM(1,5; 5)", FR_LOCALE) // "=SUM(1.5, 5)"
15147
+ * canonicalizeContent("125,9", FR_LOCALE) // "125.9"
15148
+ * canonicalizeContent("02/12/2012", FR_LOCALE) // "12/02/2012"
15149
+ * canonicalizeContent("02-12-2012", FR_LOCALE) // "12/02/2012"
15150
+ */
15124
15151
  function canonicalizeContent(content, locale) {
15125
15152
  return content.startsWith("=")
15126
15153
  ? canonicalizeFormula$1(content, locale)
15127
- : toCanonicalNumberString(content, locale);
15154
+ : canonicalizeLiteral(content, locale);
15128
15155
  }
15129
- /** Change the content of a cell to its canonical form (en_US locale) */
15156
+ /**
15157
+ * Change a content string from its canonical form (en_US locale) to the given locale. Also convert date string.
15158
+ *
15159
+ * @example
15160
+ * localizeContent("=SUM(1.5, 5)", FR_LOCALE) // "=SUM(1,5; 5)"
15161
+ * localizeContent("125.9", FR_LOCALE) // "125,9"
15162
+ * localizeContent("12/02/2012", FR_LOCALE) // "02/12/2012"
15163
+ */
15130
15164
  function localizeContent(content, locale) {
15131
15165
  return content.startsWith("=")
15132
15166
  ? localizeFormula(content, locale)
@@ -15161,24 +15195,75 @@ function _localizeFormula$1(formula, fromLocale, toLocale) {
15161
15195
  return localizedFormula;
15162
15196
  }
15163
15197
  /**
15164
- * Replace localized number with localized decimal separator by a number with "." as decimal separator
15198
+ * Change a literal string from the given locale to its canonical form (en_US locale). Don't convert date string.
15199
+ *
15200
+ * @example
15201
+ * canonicalizeNumberLiteral("125,9", FR_LOCALE) // "125.9"
15202
+ * canonicalizeNumberLiteral("02/12/2012", FR_LOCALE) // "02/12/2012"
15165
15203
  */
15166
- function toCanonicalNumberString(content, locale) {
15204
+ function canonicalizeNumberLiteral(content, locale) {
15167
15205
  if (locale.decimalSeparator === "." || !isNumber(content, locale)) {
15168
15206
  return content;
15169
15207
  }
15170
15208
  return content.replace(locale.decimalSeparator, ".");
15171
15209
  }
15172
- function localizeLiteral(content, locale) {
15173
- if (locale.decimalSeparator === "." || !isNumber(content, DEFAULT_LOCALE)) {
15174
- return content;
15210
+ /**
15211
+ * Change a content string from the given locale to its canonical form (en_US locale). Also convert date string.
15212
+ * This is destructive and won't preserve the original format.
15213
+ *
15214
+ * @example
15215
+ * canonicalizeLiteral("125,9", FR_LOCALE) // "125.9"
15216
+ * canonicalizeLiteral("02/12/2012", FR_LOCALE) // "12/02/2012"
15217
+ * canonicalizeLiteral("02-12-2012", FR_LOCALE) // "12/02/2012"
15218
+ */
15219
+ function canonicalizeLiteral(content, locale) {
15220
+ if (isDateTime(content, locale)) {
15221
+ const dateNumber = toNumber(content, locale);
15222
+ let format = DEFAULT_LOCALE.dateFormat;
15223
+ if (!Number.isInteger(dateNumber)) {
15224
+ format += " " + DEFAULT_LOCALE.timeFormat;
15225
+ }
15226
+ return formatValue(dateNumber, { locale: DEFAULT_LOCALE, format });
15227
+ }
15228
+ return canonicalizeNumberLiteral(content, locale);
15229
+ }
15230
+ /**
15231
+ * Change a literal string from its canonical form (en_US locale) to the given locale. Don't convert date string.
15232
+ * This is destructive and won't preserve the original format.
15233
+ *
15234
+ * @example
15235
+ * localizeNumberLiteral("125.9", FR_LOCALE) // "125,9"
15236
+ * localizeNumberLiteral("12/02/2012", FR_LOCALE) // "12/02/2012"
15237
+ * localizeNumberLiteral("12-02-2012", FR_LOCALE) // "12/02/2012"
15238
+ */
15239
+ function localizeNumberLiteral(literal, locale) {
15240
+ if (locale.decimalSeparator === "." || !isNumber(literal, DEFAULT_LOCALE)) {
15241
+ return literal;
15175
15242
  }
15176
15243
  const decimalNumberRegex = getDecimalNumberRegex(DEFAULT_LOCALE);
15177
- const localized = content.replace(decimalNumberRegex, (match) => {
15244
+ const localized = literal.replace(decimalNumberRegex, (match) => {
15178
15245
  return match.replace(".", locale.decimalSeparator);
15179
15246
  });
15180
15247
  return localized;
15181
15248
  }
15249
+ /**
15250
+ * Change a literal string from its canonical form (en_US locale) to the given locale. Also convert date string.
15251
+ *
15252
+ * @example
15253
+ * localizeLiteral("125.9", FR_LOCALE) // "125,9"
15254
+ * localizeLiteral("12/02/2012", FR_LOCALE) // "02/12/2012"
15255
+ */
15256
+ function localizeLiteral(literal, locale) {
15257
+ if (isDateTime(literal, DEFAULT_LOCALE)) {
15258
+ const dateNumber = toNumber(literal, DEFAULT_LOCALE);
15259
+ let format = locale.dateFormat;
15260
+ if (!Number.isInteger(dateNumber)) {
15261
+ format += " " + locale.timeFormat;
15262
+ }
15263
+ return formatValue(dateNumber, { locale, format });
15264
+ }
15265
+ return localizeNumberLiteral(literal, locale);
15266
+ }
15182
15267
  function canonicalizeCFRule(cf, locale) {
15183
15268
  return changeCFRuleLocale(cf, (content) => canonicalizeContent(content, locale));
15184
15269
  }
@@ -15535,7 +15620,9 @@ class LinkEditor extends owl.Component {
15535
15620
  save() {
15536
15621
  const { col, row } = this.props.cellPosition;
15537
15622
  const locale = this.env.model.getters.getLocale();
15538
- const label = this.link.label ? canonicalizeContent(this.link.label, locale) : this.link.url;
15623
+ const label = this.link.label
15624
+ ? canonicalizeNumberContent(this.link.label, locale)
15625
+ : this.link.url;
15539
15626
  this.env.model.dispatch("UPDATE_CELL", {
15540
15627
  col: col,
15541
15628
  row: row,
@@ -25305,9 +25392,11 @@ function useCellHovered(env, gridRef, callback) {
25305
25392
  }
25306
25393
  }
25307
25394
  function updateMousePosition(e) {
25308
- x = e.offsetX;
25309
- y = e.offsetY;
25310
- lastMoved = Date.now();
25395
+ if (gridRef.el === e.target) {
25396
+ x = e.offsetX;
25397
+ y = e.offsetY;
25398
+ lastMoved = Date.now();
25399
+ }
25311
25400
  }
25312
25401
  function recompute() {
25313
25402
  const { col, row } = getPosition();
@@ -36680,8 +36769,7 @@ class EvaluationConditionalFormatPlugin extends UIPlugin {
36680
36769
  if (cell.type === CellValueType.error) {
36681
36770
  return false;
36682
36771
  }
36683
- const locale = this.getters.getLocale();
36684
- const values = rule.values.map((val) => parseLiteral(val, locale));
36772
+ const values = rule.values.map((val) => parseLiteral(val, DEFAULT_LOCALE));
36685
36773
  switch (rule.operator) {
36686
36774
  case "IsEmpty":
36687
36775
  return cell.value.toString().trim() === "";
@@ -38765,7 +38853,7 @@ class FindAndReplacePlugin extends UIPlugin {
38765
38853
  const replaceRegex = new RegExp(this.currentSearchRegex.source, this.currentSearchRegex.flags + "g");
38766
38854
  const toReplace = this.getSearchableString({ sheetId, col, row });
38767
38855
  const content = toReplace.replace(replaceRegex, replaceWith);
38768
- const canonicalContent = canonicalizeContent(content, this.getters.getLocale());
38856
+ const canonicalContent = canonicalizeNumberContent(content, this.getters.getLocale());
38769
38857
  this.dispatch("UPDATE_CELL", { sheetId, col, row, content: canonicalContent });
38770
38858
  }
38771
38859
  /**
@@ -40939,7 +41027,7 @@ class SplitToColumnsPlugin extends UIPlugin {
40939
41027
  sheetId,
40940
41028
  col: col + index,
40941
41029
  row,
40942
- content: canonicalizeContent(content, this.getters.getLocale()),
41030
+ content: canonicalizeNumberContent(content, this.getters.getLocale()),
40943
41031
  format: "",
40944
41032
  style: mainCell?.style || null,
40945
41033
  });
@@ -41125,6 +41213,7 @@ class ClipboardCellsState extends ClipboardCellsAbstractState {
41125
41213
  cells;
41126
41214
  copiedTables;
41127
41215
  zones;
41216
+ uuidGenerator = new UuidGenerator();
41128
41217
  constructor(zones, operation, getters, dispatch, selection) {
41129
41218
  super(operation, getters, dispatch, selection);
41130
41219
  if (!zones.length) {
@@ -41586,8 +41675,9 @@ class ClipboardCellsState extends ClipboardCellsAbstractState {
41586
41675
  this.adaptCFRules(origin.sheetId, cf, [xc], toRemoveRange);
41587
41676
  }
41588
41677
  else {
41589
- this.adaptCFRules(target.sheetId, cf, [xc], []);
41590
41678
  this.adaptCFRules(origin.sheetId, cf, [], toRemoveRange);
41679
+ const cfToCopyTo = this.getCFToCopyTo(target.sheetId, cf);
41680
+ this.adaptCFRules(target.sheetId, cfToCopyTo, [xc], []);
41591
41681
  }
41592
41682
  }
41593
41683
  }
@@ -41611,6 +41701,12 @@ class ClipboardCellsState extends ClipboardCellsAbstractState {
41611
41701
  sheetId,
41612
41702
  });
41613
41703
  }
41704
+ getCFToCopyTo(targetSheetId, originCF) {
41705
+ const cfInTarget = this.getters
41706
+ .getConditionalFormats(targetSheetId)
41707
+ .find((cf) => cf.stopIfTrue === originCF.stopIfTrue && deepEquals(cf.rule, originCF.rule));
41708
+ return cfInTarget ? cfInTarget : { ...originCF, id: this.uuidGenerator.uuidv4(), ranges: [] };
41709
+ }
41614
41710
  }
41615
41711
 
41616
41712
  /** State of the clipboard when copying/cutting figures */
@@ -41742,7 +41838,7 @@ class ClipboardFigureImage {
41742
41838
  function canonicalizeNumberValue(content, locale) {
41743
41839
  return content.startsWith("=")
41744
41840
  ? canonicalizeFormula(content, locale)
41745
- : toCanonicalNumberString(content, locale);
41841
+ : canonicalizeNumberLiteral(content, locale);
41746
41842
  }
41747
41843
  /** Change a formula to its canonical form (en_US locale) */
41748
41844
  function canonicalizeFormula(formula, locale) {
@@ -41859,7 +41955,7 @@ class ClipboardPlugin extends UIPlugin {
41859
41955
  allowDispatch(cmd) {
41860
41956
  switch (cmd.type) {
41861
41957
  case "CUT":
41862
- const zones = cmd.cutTarget || this.getters.getSelectedZones();
41958
+ const zones = this.getters.getSelectedZones();
41863
41959
  const state = this.getClipboardState(zones, cmd.type);
41864
41960
  return state.isCutAllowed(zones);
41865
41961
  case "PASTE":
@@ -41894,7 +41990,7 @@ class ClipboardPlugin extends UIPlugin {
41894
41990
  switch (cmd.type) {
41895
41991
  case "COPY":
41896
41992
  case "CUT":
41897
- const zones = ("cutTarget" in cmd && cmd.cutTarget) || this.getters.getSelectedZones();
41993
+ const zones = this.getters.getSelectedZones();
41898
41994
  this.state = this.getClipboardState(zones, cmd.type);
41899
41995
  this.status = "visible";
41900
41996
  this.originSheetId = this.getters.getActiveSheetId();
@@ -42544,7 +42640,7 @@ class EditionPlugin extends UIPlugin {
42544
42640
  if (content) {
42545
42641
  const sheetId = this.getters.getActiveSheetId();
42546
42642
  const cell = this.getters.getEvaluatedCell({ sheetId, col: this.col, row: this.row });
42547
- content = canonicalizeContent(content, this.getters.getLocale());
42643
+ content = canonicalizeNumberContent(content, this.getters.getLocale());
42548
42644
  if (content.startsWith("=")) {
42549
42645
  const left = this.currentTokens.filter((t) => t.type === "LEFT_PAREN").length;
42550
42646
  const right = this.currentTokens.filter((t) => t.type === "RIGHT_PAREN").length;
@@ -43565,26 +43661,24 @@ class GridSelectionPlugin extends UIPlugin {
43565
43661
  const isBasedBefore = cmd.base < start;
43566
43662
  const deltaCol = isBasedBefore && isCol ? thickness : 0;
43567
43663
  const deltaRow = isBasedBefore && !isCol ? thickness : 0;
43568
- this.dispatch("CUT", {
43569
- cutTarget: [
43570
- {
43571
- left: isCol ? start + deltaCol : 0,
43572
- right: isCol ? end + deltaCol : this.getters.getNumberCols(cmd.sheetId) - 1,
43573
- top: !isCol ? start + deltaRow : 0,
43574
- bottom: !isCol ? end + deltaRow : this.getters.getNumberRows(cmd.sheetId) - 1,
43575
- },
43576
- ],
43577
- });
43578
- this.dispatch("PASTE", {
43579
- target: [
43580
- {
43581
- left: isCol ? cmd.base : 0,
43582
- right: isCol ? cmd.base + thickness - 1 : this.getters.getNumberCols(cmd.sheetId) - 1,
43583
- top: !isCol ? cmd.base : 0,
43584
- bottom: !isCol ? cmd.base + thickness - 1 : this.getters.getNumberRows(cmd.sheetId) - 1,
43585
- },
43586
- ],
43587
- });
43664
+ const target = [
43665
+ {
43666
+ left: isCol ? start + deltaCol : 0,
43667
+ right: isCol ? end + deltaCol : this.getters.getNumberCols(cmd.sheetId) - 1,
43668
+ top: !isCol ? start + deltaRow : 0,
43669
+ bottom: !isCol ? end + deltaRow : this.getters.getNumberRows(cmd.sheetId) - 1,
43670
+ },
43671
+ ];
43672
+ const state = new ClipboardCellsState(target, "CUT", this.getters, this.dispatch, this.selection);
43673
+ const pasteTarget = [
43674
+ {
43675
+ left: isCol ? cmd.base : 0,
43676
+ right: isCol ? cmd.base + thickness - 1 : this.getters.getNumberCols(cmd.sheetId) - 1,
43677
+ top: !isCol ? cmd.base : 0,
43678
+ bottom: !isCol ? cmd.base + thickness - 1 : this.getters.getNumberRows(cmd.sheetId) - 1,
43679
+ },
43680
+ ];
43681
+ state.paste(pasteTarget, { selectTarget: true });
43588
43682
  const toRemove = isBasedBefore ? cmd.elements.map((el) => el + thickness) : cmd.elements;
43589
43683
  let currentIndex = cmd.base;
43590
43684
  for (const element of toRemove) {
@@ -50602,6 +50696,6 @@ exports.setTranslationMethod = setTranslationMethod;
50602
50696
  exports.tokenize = tokenize;
50603
50697
 
50604
50698
 
50605
- __info__.version = '16.4.6';
50606
- __info__.date = '2023-09-12T11:43:54.243Z';
50607
- __info__.hash = '5746355';
50699
+ __info__.version = '16.4.7';
50700
+ __info__.date = '2023-09-21T15:58:11.039Z';
50701
+ __info__.hash = 'eccdcce';
@@ -1897,8 +1897,6 @@ interface CopyCommand {
1897
1897
  }
1898
1898
  interface CutCommand {
1899
1899
  type: "CUT";
1900
- /** Zones to cut. If none were given, will copy the zones in the selection*/
1901
- cutTarget?: Zone[];
1902
1900
  }
1903
1901
  interface PasteCommand {
1904
1902
  type: "PASTE";
@@ -610,13 +610,17 @@ function getAddHeaderStartIndex(position, base) {
610
610
  return position === "after" ? base + 1 : base;
611
611
  }
612
612
  /**
613
- * Compare two objects.
613
+ * Compares two objects.
614
614
  */
615
615
  function deepEquals(o1, o2) {
616
616
  if (o1 === o2)
617
617
  return true;
618
618
  if ((o1 && !o2) || (o2 && !o1))
619
619
  return false;
620
+ if (typeof o1 !== typeof o2)
621
+ return false;
622
+ if (typeof o1 !== "object")
623
+ return o1 === o2;
620
624
  // Objects can have different keys if the values are undefined
621
625
  const keys = new Set();
622
626
  Object.keys(o1).forEach((key) => keys.add(key));
@@ -5261,6 +5265,7 @@ css /* scss */ `
5261
5265
  padding: 10px;
5262
5266
  width: ${ERROR_TOOLTIP_WIDTH}px;
5263
5267
  box-sizing: border-box !important;
5268
+ overflow-wrap: break-word;
5264
5269
  }
5265
5270
  `;
5266
5271
  class ErrorToolTip extends Component {
@@ -15116,13 +15121,42 @@ function isValidLocale(locale) {
15116
15121
  }
15117
15122
  return true;
15118
15123
  }
15119
- /** Change a content string to its canonical form (en_US locale) */
15124
+ /**
15125
+ * Change a content string from the given locale to its canonical form (en_US locale). Don't convert date string.
15126
+ *
15127
+ * @example
15128
+ * canonicalizeNumberContent("=SUM(1,5; 02/12/2012)", FR_LOCALE) // "=SUM(1.5, 02/12/2012)"
15129
+ * canonicalizeNumberContent("125,9", FR_LOCALE) // "125.9"
15130
+ * canonicalizeNumberContent("02/12/2012", FR_LOCALE) // "02/12/2012"
15131
+ */
15132
+ function canonicalizeNumberContent(content, locale) {
15133
+ return content.startsWith("=")
15134
+ ? canonicalizeFormula$1(content, locale)
15135
+ : canonicalizeNumberLiteral(content, locale);
15136
+ }
15137
+ /**
15138
+ * Change a content string from the given locale to its canonical form (en_US locale). Also convert date string.
15139
+ * This is destructive and won't preserve the original format.
15140
+ *
15141
+ * @example
15142
+ * canonicalizeContent("=SUM(1,5; 5)", FR_LOCALE) // "=SUM(1.5, 5)"
15143
+ * canonicalizeContent("125,9", FR_LOCALE) // "125.9"
15144
+ * canonicalizeContent("02/12/2012", FR_LOCALE) // "12/02/2012"
15145
+ * canonicalizeContent("02-12-2012", FR_LOCALE) // "12/02/2012"
15146
+ */
15120
15147
  function canonicalizeContent(content, locale) {
15121
15148
  return content.startsWith("=")
15122
15149
  ? canonicalizeFormula$1(content, locale)
15123
- : toCanonicalNumberString(content, locale);
15150
+ : canonicalizeLiteral(content, locale);
15124
15151
  }
15125
- /** Change the content of a cell to its canonical form (en_US locale) */
15152
+ /**
15153
+ * Change a content string from its canonical form (en_US locale) to the given locale. Also convert date string.
15154
+ *
15155
+ * @example
15156
+ * localizeContent("=SUM(1.5, 5)", FR_LOCALE) // "=SUM(1,5; 5)"
15157
+ * localizeContent("125.9", FR_LOCALE) // "125,9"
15158
+ * localizeContent("12/02/2012", FR_LOCALE) // "02/12/2012"
15159
+ */
15126
15160
  function localizeContent(content, locale) {
15127
15161
  return content.startsWith("=")
15128
15162
  ? localizeFormula(content, locale)
@@ -15157,24 +15191,75 @@ function _localizeFormula$1(formula, fromLocale, toLocale) {
15157
15191
  return localizedFormula;
15158
15192
  }
15159
15193
  /**
15160
- * Replace localized number with localized decimal separator by a number with "." as decimal separator
15194
+ * Change a literal string from the given locale to its canonical form (en_US locale). Don't convert date string.
15195
+ *
15196
+ * @example
15197
+ * canonicalizeNumberLiteral("125,9", FR_LOCALE) // "125.9"
15198
+ * canonicalizeNumberLiteral("02/12/2012", FR_LOCALE) // "02/12/2012"
15161
15199
  */
15162
- function toCanonicalNumberString(content, locale) {
15200
+ function canonicalizeNumberLiteral(content, locale) {
15163
15201
  if (locale.decimalSeparator === "." || !isNumber(content, locale)) {
15164
15202
  return content;
15165
15203
  }
15166
15204
  return content.replace(locale.decimalSeparator, ".");
15167
15205
  }
15168
- function localizeLiteral(content, locale) {
15169
- if (locale.decimalSeparator === "." || !isNumber(content, DEFAULT_LOCALE)) {
15170
- return content;
15206
+ /**
15207
+ * Change a content string from the given locale to its canonical form (en_US locale). Also convert date string.
15208
+ * This is destructive and won't preserve the original format.
15209
+ *
15210
+ * @example
15211
+ * canonicalizeLiteral("125,9", FR_LOCALE) // "125.9"
15212
+ * canonicalizeLiteral("02/12/2012", FR_LOCALE) // "12/02/2012"
15213
+ * canonicalizeLiteral("02-12-2012", FR_LOCALE) // "12/02/2012"
15214
+ */
15215
+ function canonicalizeLiteral(content, locale) {
15216
+ if (isDateTime(content, locale)) {
15217
+ const dateNumber = toNumber(content, locale);
15218
+ let format = DEFAULT_LOCALE.dateFormat;
15219
+ if (!Number.isInteger(dateNumber)) {
15220
+ format += " " + DEFAULT_LOCALE.timeFormat;
15221
+ }
15222
+ return formatValue(dateNumber, { locale: DEFAULT_LOCALE, format });
15223
+ }
15224
+ return canonicalizeNumberLiteral(content, locale);
15225
+ }
15226
+ /**
15227
+ * Change a literal string from its canonical form (en_US locale) to the given locale. Don't convert date string.
15228
+ * This is destructive and won't preserve the original format.
15229
+ *
15230
+ * @example
15231
+ * localizeNumberLiteral("125.9", FR_LOCALE) // "125,9"
15232
+ * localizeNumberLiteral("12/02/2012", FR_LOCALE) // "12/02/2012"
15233
+ * localizeNumberLiteral("12-02-2012", FR_LOCALE) // "12/02/2012"
15234
+ */
15235
+ function localizeNumberLiteral(literal, locale) {
15236
+ if (locale.decimalSeparator === "." || !isNumber(literal, DEFAULT_LOCALE)) {
15237
+ return literal;
15171
15238
  }
15172
15239
  const decimalNumberRegex = getDecimalNumberRegex(DEFAULT_LOCALE);
15173
- const localized = content.replace(decimalNumberRegex, (match) => {
15240
+ const localized = literal.replace(decimalNumberRegex, (match) => {
15174
15241
  return match.replace(".", locale.decimalSeparator);
15175
15242
  });
15176
15243
  return localized;
15177
15244
  }
15245
+ /**
15246
+ * Change a literal string from its canonical form (en_US locale) to the given locale. Also convert date string.
15247
+ *
15248
+ * @example
15249
+ * localizeLiteral("125.9", FR_LOCALE) // "125,9"
15250
+ * localizeLiteral("12/02/2012", FR_LOCALE) // "02/12/2012"
15251
+ */
15252
+ function localizeLiteral(literal, locale) {
15253
+ if (isDateTime(literal, DEFAULT_LOCALE)) {
15254
+ const dateNumber = toNumber(literal, DEFAULT_LOCALE);
15255
+ let format = locale.dateFormat;
15256
+ if (!Number.isInteger(dateNumber)) {
15257
+ format += " " + locale.timeFormat;
15258
+ }
15259
+ return formatValue(dateNumber, { locale, format });
15260
+ }
15261
+ return localizeNumberLiteral(literal, locale);
15262
+ }
15178
15263
  function canonicalizeCFRule(cf, locale) {
15179
15264
  return changeCFRuleLocale(cf, (content) => canonicalizeContent(content, locale));
15180
15265
  }
@@ -15531,7 +15616,9 @@ class LinkEditor extends Component {
15531
15616
  save() {
15532
15617
  const { col, row } = this.props.cellPosition;
15533
15618
  const locale = this.env.model.getters.getLocale();
15534
- const label = this.link.label ? canonicalizeContent(this.link.label, locale) : this.link.url;
15619
+ const label = this.link.label
15620
+ ? canonicalizeNumberContent(this.link.label, locale)
15621
+ : this.link.url;
15535
15622
  this.env.model.dispatch("UPDATE_CELL", {
15536
15623
  col: col,
15537
15624
  row: row,
@@ -25301,9 +25388,11 @@ function useCellHovered(env, gridRef, callback) {
25301
25388
  }
25302
25389
  }
25303
25390
  function updateMousePosition(e) {
25304
- x = e.offsetX;
25305
- y = e.offsetY;
25306
- lastMoved = Date.now();
25391
+ if (gridRef.el === e.target) {
25392
+ x = e.offsetX;
25393
+ y = e.offsetY;
25394
+ lastMoved = Date.now();
25395
+ }
25307
25396
  }
25308
25397
  function recompute() {
25309
25398
  const { col, row } = getPosition();
@@ -36676,8 +36765,7 @@ class EvaluationConditionalFormatPlugin extends UIPlugin {
36676
36765
  if (cell.type === CellValueType.error) {
36677
36766
  return false;
36678
36767
  }
36679
- const locale = this.getters.getLocale();
36680
- const values = rule.values.map((val) => parseLiteral(val, locale));
36768
+ const values = rule.values.map((val) => parseLiteral(val, DEFAULT_LOCALE));
36681
36769
  switch (rule.operator) {
36682
36770
  case "IsEmpty":
36683
36771
  return cell.value.toString().trim() === "";
@@ -38761,7 +38849,7 @@ class FindAndReplacePlugin extends UIPlugin {
38761
38849
  const replaceRegex = new RegExp(this.currentSearchRegex.source, this.currentSearchRegex.flags + "g");
38762
38850
  const toReplace = this.getSearchableString({ sheetId, col, row });
38763
38851
  const content = toReplace.replace(replaceRegex, replaceWith);
38764
- const canonicalContent = canonicalizeContent(content, this.getters.getLocale());
38852
+ const canonicalContent = canonicalizeNumberContent(content, this.getters.getLocale());
38765
38853
  this.dispatch("UPDATE_CELL", { sheetId, col, row, content: canonicalContent });
38766
38854
  }
38767
38855
  /**
@@ -40935,7 +41023,7 @@ class SplitToColumnsPlugin extends UIPlugin {
40935
41023
  sheetId,
40936
41024
  col: col + index,
40937
41025
  row,
40938
- content: canonicalizeContent(content, this.getters.getLocale()),
41026
+ content: canonicalizeNumberContent(content, this.getters.getLocale()),
40939
41027
  format: "",
40940
41028
  style: mainCell?.style || null,
40941
41029
  });
@@ -41121,6 +41209,7 @@ class ClipboardCellsState extends ClipboardCellsAbstractState {
41121
41209
  cells;
41122
41210
  copiedTables;
41123
41211
  zones;
41212
+ uuidGenerator = new UuidGenerator();
41124
41213
  constructor(zones, operation, getters, dispatch, selection) {
41125
41214
  super(operation, getters, dispatch, selection);
41126
41215
  if (!zones.length) {
@@ -41582,8 +41671,9 @@ class ClipboardCellsState extends ClipboardCellsAbstractState {
41582
41671
  this.adaptCFRules(origin.sheetId, cf, [xc], toRemoveRange);
41583
41672
  }
41584
41673
  else {
41585
- this.adaptCFRules(target.sheetId, cf, [xc], []);
41586
41674
  this.adaptCFRules(origin.sheetId, cf, [], toRemoveRange);
41675
+ const cfToCopyTo = this.getCFToCopyTo(target.sheetId, cf);
41676
+ this.adaptCFRules(target.sheetId, cfToCopyTo, [xc], []);
41587
41677
  }
41588
41678
  }
41589
41679
  }
@@ -41607,6 +41697,12 @@ class ClipboardCellsState extends ClipboardCellsAbstractState {
41607
41697
  sheetId,
41608
41698
  });
41609
41699
  }
41700
+ getCFToCopyTo(targetSheetId, originCF) {
41701
+ const cfInTarget = this.getters
41702
+ .getConditionalFormats(targetSheetId)
41703
+ .find((cf) => cf.stopIfTrue === originCF.stopIfTrue && deepEquals(cf.rule, originCF.rule));
41704
+ return cfInTarget ? cfInTarget : { ...originCF, id: this.uuidGenerator.uuidv4(), ranges: [] };
41705
+ }
41610
41706
  }
41611
41707
 
41612
41708
  /** State of the clipboard when copying/cutting figures */
@@ -41738,7 +41834,7 @@ class ClipboardFigureImage {
41738
41834
  function canonicalizeNumberValue(content, locale) {
41739
41835
  return content.startsWith("=")
41740
41836
  ? canonicalizeFormula(content, locale)
41741
- : toCanonicalNumberString(content, locale);
41837
+ : canonicalizeNumberLiteral(content, locale);
41742
41838
  }
41743
41839
  /** Change a formula to its canonical form (en_US locale) */
41744
41840
  function canonicalizeFormula(formula, locale) {
@@ -41855,7 +41951,7 @@ class ClipboardPlugin extends UIPlugin {
41855
41951
  allowDispatch(cmd) {
41856
41952
  switch (cmd.type) {
41857
41953
  case "CUT":
41858
- const zones = cmd.cutTarget || this.getters.getSelectedZones();
41954
+ const zones = this.getters.getSelectedZones();
41859
41955
  const state = this.getClipboardState(zones, cmd.type);
41860
41956
  return state.isCutAllowed(zones);
41861
41957
  case "PASTE":
@@ -41890,7 +41986,7 @@ class ClipboardPlugin extends UIPlugin {
41890
41986
  switch (cmd.type) {
41891
41987
  case "COPY":
41892
41988
  case "CUT":
41893
- const zones = ("cutTarget" in cmd && cmd.cutTarget) || this.getters.getSelectedZones();
41989
+ const zones = this.getters.getSelectedZones();
41894
41990
  this.state = this.getClipboardState(zones, cmd.type);
41895
41991
  this.status = "visible";
41896
41992
  this.originSheetId = this.getters.getActiveSheetId();
@@ -42540,7 +42636,7 @@ class EditionPlugin extends UIPlugin {
42540
42636
  if (content) {
42541
42637
  const sheetId = this.getters.getActiveSheetId();
42542
42638
  const cell = this.getters.getEvaluatedCell({ sheetId, col: this.col, row: this.row });
42543
- content = canonicalizeContent(content, this.getters.getLocale());
42639
+ content = canonicalizeNumberContent(content, this.getters.getLocale());
42544
42640
  if (content.startsWith("=")) {
42545
42641
  const left = this.currentTokens.filter((t) => t.type === "LEFT_PAREN").length;
42546
42642
  const right = this.currentTokens.filter((t) => t.type === "RIGHT_PAREN").length;
@@ -43561,26 +43657,24 @@ class GridSelectionPlugin extends UIPlugin {
43561
43657
  const isBasedBefore = cmd.base < start;
43562
43658
  const deltaCol = isBasedBefore && isCol ? thickness : 0;
43563
43659
  const deltaRow = isBasedBefore && !isCol ? thickness : 0;
43564
- this.dispatch("CUT", {
43565
- cutTarget: [
43566
- {
43567
- left: isCol ? start + deltaCol : 0,
43568
- right: isCol ? end + deltaCol : this.getters.getNumberCols(cmd.sheetId) - 1,
43569
- top: !isCol ? start + deltaRow : 0,
43570
- bottom: !isCol ? end + deltaRow : this.getters.getNumberRows(cmd.sheetId) - 1,
43571
- },
43572
- ],
43573
- });
43574
- this.dispatch("PASTE", {
43575
- target: [
43576
- {
43577
- left: isCol ? cmd.base : 0,
43578
- right: isCol ? cmd.base + thickness - 1 : this.getters.getNumberCols(cmd.sheetId) - 1,
43579
- top: !isCol ? cmd.base : 0,
43580
- bottom: !isCol ? cmd.base + thickness - 1 : this.getters.getNumberRows(cmd.sheetId) - 1,
43581
- },
43582
- ],
43583
- });
43660
+ const target = [
43661
+ {
43662
+ left: isCol ? start + deltaCol : 0,
43663
+ right: isCol ? end + deltaCol : this.getters.getNumberCols(cmd.sheetId) - 1,
43664
+ top: !isCol ? start + deltaRow : 0,
43665
+ bottom: !isCol ? end + deltaRow : this.getters.getNumberRows(cmd.sheetId) - 1,
43666
+ },
43667
+ ];
43668
+ const state = new ClipboardCellsState(target, "CUT", this.getters, this.dispatch, this.selection);
43669
+ const pasteTarget = [
43670
+ {
43671
+ left: isCol ? cmd.base : 0,
43672
+ right: isCol ? cmd.base + thickness - 1 : this.getters.getNumberCols(cmd.sheetId) - 1,
43673
+ top: !isCol ? cmd.base : 0,
43674
+ bottom: !isCol ? cmd.base + thickness - 1 : this.getters.getNumberRows(cmd.sheetId) - 1,
43675
+ },
43676
+ ];
43677
+ state.paste(pasteTarget, { selectTarget: true });
43584
43678
  const toRemove = isBasedBefore ? cmd.elements.map((el) => el + thickness) : cmd.elements;
43585
43679
  let currentIndex = cmd.base;
43586
43680
  for (const element of toRemove) {
@@ -50566,6 +50660,6 @@ const constants = {
50566
50660
  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 };
50567
50661
 
50568
50662
 
50569
- __info__.version = '16.4.6';
50570
- __info__.date = '2023-09-12T11:43:54.243Z';
50571
- __info__.hash = '5746355';
50663
+ __info__.version = '16.4.7';
50664
+ __info__.date = '2023-09-21T15:58:11.039Z';
50665
+ __info__.hash = 'eccdcce';