@odoo/o-spreadsheet 17.1.2 → 17.1.3

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.
@@ -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 17.1.2
6
- * @date 2024-01-29T13:54:42.679Z
7
- * @hash 043a0d5
5
+ * @version 17.1.3
6
+ * @date 2024-02-02T13:46:54.332Z
7
+ * @hash 798f979
8
8
  */
9
9
 
10
10
  (function (exports, owl) {
@@ -5048,8 +5048,10 @@
5048
5048
  }
5049
5049
  const dataRange = ds.dataRange.clone({ zone: dataZone });
5050
5050
  return {
5051
- label: ds.labelCell ? getters.getRangeString(ds.labelCell, "forceSheetReference") : undefined,
5052
- range: getters.getRangeString(dataRange, "forceSheetReference"),
5051
+ label: ds.labelCell
5052
+ ? getters.getRangeString(ds.labelCell, "forceSheetReference", { useFixedReference: true })
5053
+ : undefined,
5054
+ range: getters.getRangeString(dataRange, "forceSheetReference", { useFixedReference: true }),
5053
5055
  };
5054
5056
  }
5055
5057
  function toExcelLabelRange(getters, labelRange, shouldRemoveFirstLabel) {
@@ -5062,7 +5064,7 @@
5062
5064
  zone.top = zone.top + 1;
5063
5065
  }
5064
5066
  const range = labelRange.clone({ zone });
5065
- return getters.getRangeString(range, "forceSheetReference");
5067
+ return getters.getRangeString(range, "forceSheetReference", { useFixedReference: true });
5066
5068
  }
5067
5069
  /**
5068
5070
  * Transform a chart definition which supports dataSets (dataSets and LabelRange)
@@ -6697,6 +6699,7 @@
6697
6699
  };
6698
6700
 
6699
6701
  const macRegex = /Mac/i;
6702
+ const MODIFIER_KEYS = ["Shift", "Control", "Alt", "Meta"];
6700
6703
  /**
6701
6704
  * Return true if the event was triggered from
6702
6705
  * a child element.
@@ -6748,14 +6751,14 @@
6748
6751
  */
6749
6752
  function keyboardEventToShortcutString(ev, mode = "key") {
6750
6753
  let keyDownString = "";
6751
- if (isCtrlKey(ev) && ev.key !== "Ctrl")
6752
- keyDownString += "Ctrl+";
6753
- if (ev.metaKey)
6754
- keyDownString += "Ctrl+";
6755
- if (ev.altKey && ev.key !== "Alt")
6756
- keyDownString += "Alt+";
6757
- if (ev.shiftKey && ev.key !== "Shift")
6758
- keyDownString += "Shift+";
6754
+ if (!MODIFIER_KEYS.includes(ev.key)) {
6755
+ if (isCtrlKey(ev))
6756
+ keyDownString += "Ctrl+";
6757
+ if (ev.altKey)
6758
+ keyDownString += "Alt+";
6759
+ if (ev.shiftKey)
6760
+ keyDownString += "Shift+";
6761
+ }
6759
6762
  const key = mode === "key" ? ev.key : ev.code;
6760
6763
  keyDownString += letterRegex.test(key) ? key.toUpperCase() : key;
6761
6764
  return keyDownString;
@@ -20207,19 +20210,20 @@
20207
20210
  const formatNumberCurrency = createFormatActionSpec({
20208
20211
  name: _t("Currency"),
20209
20212
  descriptionValue: 1000.12,
20210
- format: (env) => env.model.config.defaultCurrencyFormat,
20213
+ format: (env) => env.model.config.defaultCurrencyFormat ?? DEFAULT_CURRENCY_FORMAT,
20211
20214
  });
20212
20215
  const formatNumberCurrencyRounded = {
20213
20216
  ...createFormatActionSpec({
20214
20217
  name: _t("Currency rounded"),
20215
20218
  descriptionValue: 1000,
20216
- format: (env) => roundFormat(env.model.config.defaultCurrencyFormat),
20219
+ format: (env) => roundFormat(env.model.config.defaultCurrencyFormat ?? DEFAULT_CURRENCY_FORMAT),
20217
20220
  }),
20218
20221
  isVisible: (env) => {
20219
20222
  const currencyFormat = env.model.config.defaultCurrencyFormat;
20220
- return currencyFormat !== roundFormat(currencyFormat);
20223
+ return currencyFormat !== roundFormat(currencyFormat ?? DEFAULT_CURRENCY_FORMAT);
20221
20224
  },
20222
20225
  };
20226
+ const DEFAULT_CURRENCY_FORMAT = "[$$]#,##0.00";
20223
20227
  const EXAMPLE_DATE = parseLiteral("2023/09/26 10:43:00 PM", DEFAULT_LOCALE);
20224
20228
  const formatCustomCurrency = {
20225
20229
  name: _t("Custom currency"),
@@ -36029,6 +36033,9 @@
36029
36033
  format: cell.format ? getItemId(cell.format, formats) : undefined,
36030
36034
  content: cell.content || undefined,
36031
36035
  };
36036
+ if (cell instanceof FormulaCellWithDependencies) {
36037
+ cells[xc].content = cell.contentWithFixedReferences || undefined;
36038
+ }
36032
36039
  }
36033
36040
  _sheet.cells = cells;
36034
36041
  }
@@ -36072,12 +36079,12 @@
36072
36079
  /*
36073
36080
  * Reconstructs the original formula string based on a normalized form and its dependencies
36074
36081
  */
36075
- getFormulaCellContent(sheetId, compiledFormula, dependencies) {
36082
+ getFormulaCellContent(sheetId, compiledFormula, dependencies, useFixedReference = false) {
36076
36083
  let rangeIndex = 0;
36077
36084
  return concat(compiledFormula.tokens.map((token) => {
36078
36085
  if (token.type === "REFERENCE") {
36079
36086
  const range = dependencies[rangeIndex++];
36080
- return this.getters.getRangeString(range, sheetId);
36087
+ return this.getters.getRangeString(range, sheetId, { useFixedReference });
36081
36088
  }
36082
36089
  return token.value;
36083
36090
  }));
@@ -36348,6 +36355,18 @@
36348
36355
  get content() {
36349
36356
  return concat(this.compiledFormula.tokens.map((token) => token.value));
36350
36357
  }
36358
+ get contentWithFixedReferences() {
36359
+ let rangeIndex = 0;
36360
+ return concat(this.compiledFormula.tokens.map((token) => {
36361
+ if (token.type === "REFERENCE") {
36362
+ const index = rangeIndex++;
36363
+ return this.getRangeString(this.compiledFormula.dependencies[index], this.sheetId, {
36364
+ useFixedReference: true,
36365
+ });
36366
+ }
36367
+ return token.value;
36368
+ }));
36369
+ }
36351
36370
  }
36352
36371
  class RangeReferenceToken {
36353
36372
  getValue;
@@ -36652,7 +36671,13 @@
36652
36671
  }
36653
36672
  }
36654
36673
  exportForExcel(data) {
36655
- this.export(data);
36674
+ if (data.sheets) {
36675
+ for (let sheet of data.sheets) {
36676
+ if (this.cfRules[sheet.id]) {
36677
+ sheet.conditionalFormats = this.cfRules[sheet.id].map((rule) => this.mapToConditionalFormat(sheet.id, rule, { useFixedReference: true }));
36678
+ }
36679
+ }
36680
+ }
36656
36681
  }
36657
36682
  // ---------------------------------------------------------------------------
36658
36683
  // Getters
@@ -36717,11 +36742,11 @@
36717
36742
  // ---------------------------------------------------------------------------
36718
36743
  // Private
36719
36744
  // ---------------------------------------------------------------------------
36720
- mapToConditionalFormat(sheetId, cf) {
36745
+ mapToConditionalFormat(sheetId, cf, { useFixedReference } = { useFixedReference: false }) {
36721
36746
  return {
36722
36747
  ...cf,
36723
36748
  ranges: cf.ranges.map((range) => {
36724
- return this.getters.getRangeString(range, sheetId);
36749
+ return this.getters.getRangeString(range, sheetId, { useFixedReference });
36725
36750
  }),
36726
36751
  };
36727
36752
  }
@@ -38789,8 +38814,10 @@
38789
38814
  *
38790
38815
  * @param range the range (received from getRangeFromXC or getRangeFromZone)
38791
38816
  * @param forSheetId the id of the sheet where the range string is supposed to be used.
38817
+ * @param options
38818
+ * @param options.useFixedReference if true, the range will be returned with fixed row and column
38792
38819
  */
38793
- getRangeString(range, forSheetId) {
38820
+ getRangeString(range, forSheetId, options = { useFixedReference: false }) {
38794
38821
  if (!range) {
38795
38822
  return CellErrorType.InvalidReference;
38796
38823
  }
@@ -38817,7 +38844,7 @@
38817
38844
  if (prefixSheet && !sheetName) {
38818
38845
  return CellErrorType.InvalidReference;
38819
38846
  }
38820
- let rangeString = this.getRangePartString(rangeImpl, 0);
38847
+ let rangeString = this.getRangePartString(rangeImpl, 0, options);
38821
38848
  if (rangeImpl.parts && rangeImpl.parts.length === 2) {
38822
38849
  // this if converts A2:A2 into A2 except if any part of the original range had fixed row or column (with $)
38823
38850
  if (rangeImpl.zone.top !== rangeImpl.zone.bottom ||
@@ -38827,7 +38854,7 @@
38827
38854
  rangeImpl.parts[1].rowFixed ||
38828
38855
  rangeImpl.parts[1].colFixed) {
38829
38856
  rangeString += ":";
38830
- rangeString += this.getRangePartString(rangeImpl, 1);
38857
+ rangeString += this.getRangePartString(rangeImpl, 1, options);
38831
38858
  }
38832
38859
  }
38833
38860
  return `${prefixSheet ? sheetName + "!" : ""}${rangeString}`;
@@ -38868,13 +38895,13 @@
38868
38895
  /**
38869
38896
  * Get a Xc string that represent a part of a range
38870
38897
  */
38871
- getRangePartString(range, part) {
38898
+ getRangePartString(range, part, options = { useFixedReference: false }) {
38872
38899
  const colFixed = range.parts && range.parts[part]?.colFixed ? "$" : "";
38873
38900
  const col = part === 0 ? numberToLetters(range.zone.left) : numberToLetters(range.zone.right);
38874
38901
  const rowFixed = range.parts && range.parts[part]?.rowFixed ? "$" : "";
38875
38902
  const row = part === 0 ? String(range.zone.top + 1) : String(range.zone.bottom + 1);
38876
38903
  let str = "";
38877
- if (range.isFullCol) {
38904
+ if (range.isFullCol && !options.useFixedReference) {
38878
38905
  if (part === 0 && range.unboundedZone.hasHeader) {
38879
38906
  str = colFixed + col + rowFixed + row;
38880
38907
  }
@@ -38882,7 +38909,7 @@
38882
38909
  str = colFixed + col;
38883
38910
  }
38884
38911
  }
38885
- else if (range.isFullRow) {
38912
+ else if (range.isFullRow && !options.useFixedReference) {
38886
38913
  if (part === 0 && range.unboundedZone.hasHeader) {
38887
38914
  str = colFixed + col + rowFixed + row;
38888
38915
  }
@@ -55234,12 +55261,7 @@
55234
55261
  attrs.push(["t", "str"]);
55235
55262
  cycle = escapeXml /*xml*/ `<v>${cell.value}</v>`;
55236
55263
  }
55237
- node = escapeXml /*xml*/ `
55238
- <f>
55239
- ${XlsxFormula}
55240
- </f>
55241
- ${cycle}
55242
- `;
55264
+ node = escapeXml /*xml*/ `<f>${XlsxFormula}</f>${cycle}`;
55243
55265
  return { attrs, node };
55244
55266
  }
55245
55267
  function addContent(content, sharedStrings, forceString = false) {
@@ -56059,11 +56081,10 @@
56059
56081
  ({ attrs: additionalAttrs, node: cellNode } = addContent(cell.content, construct.sharedStrings, isTableHeader || isPlainText));
56060
56082
  }
56061
56083
  attributes.push(...additionalAttrs);
56062
- cellNodes.push(escapeXml /*xml*/ `
56063
- <c ${formatAttributes(attributes)}>
56064
- ${cellNode}
56065
- </c>
56066
- `);
56084
+ // prettier-ignore
56085
+ cellNodes.push(escapeXml /*xml*/ `<c ${formatAttributes(attributes)}>
56086
+ ${cellNode}
56087
+ </c>`);
56067
56088
  }
56068
56089
  }
56069
56090
  if (cellNodes.length || row.size !== DEFAULT_CELL_HEIGHT || row.isHidden) {
@@ -56659,7 +56680,6 @@
56659
56680
  ...config,
56660
56681
  mode: config.mode || "normal",
56661
56682
  custom: config.custom || {},
56662
- defaultCurrencyFormat: config.defaultCurrencyFormat || "[$$]#,##0.00",
56663
56683
  external: this.setupExternalConfig(config.external || {}),
56664
56684
  transportService,
56665
56685
  client,
@@ -56697,6 +56717,7 @@
56697
56717
  custom: this.config.custom,
56698
56718
  uiActions: this.config,
56699
56719
  session: this.session,
56720
+ defaultCurrencyFormat: this.config.defaultCurrencyFormat,
56700
56721
  };
56701
56722
  }
56702
56723
  // ---------------------------------------------------------------------------
@@ -57078,9 +57099,9 @@
57078
57099
  exports.tokenize = tokenize;
57079
57100
 
57080
57101
 
57081
- __info__.version = "17.1.2";
57082
- __info__.date = "2024-01-29T13:54:42.679Z";
57083
- __info__.hash = "043a0d5";
57102
+ __info__.version = "17.1.3";
57103
+ __info__.date = "2024-02-02T13:46:54.332Z";
57104
+ __info__.hash = "798f979";
57084
57105
 
57085
57106
 
57086
57107
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);