@odoo/o-spreadsheet 17.0.84 → 17.0.85

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.0.84
6
- * @date 2026-01-14T09:59:26.542Z
7
- * @hash ae64224
5
+ * @version 17.0.85
6
+ * @date 2026-01-21T11:02:43.920Z
7
+ * @hash 0343060
8
8
  */
9
9
 
10
10
  'use strict';
@@ -4557,17 +4557,318 @@ function isSheetNameEqual(name1, name2) {
4557
4557
  getUnquotedSheetName(name2.trim().toUpperCase()));
4558
4558
  }
4559
4559
 
4560
+ /**
4561
+ * Registry
4562
+ *
4563
+ * The Registry class is basically just a mapping from a string key to an object.
4564
+ * It is really not much more than an object. It is however useful for the
4565
+ * following reasons:
4566
+ *
4567
+ * 1. it let us react and execute code when someone add something to the registry
4568
+ * (for example, the FunctionRegistry subclass this for this purpose)
4569
+ * 2. it throws an error when the get operation fails
4570
+ * 3. it provides a chained API to add items to the registry.
4571
+ */
4572
+ class Registry {
4573
+ content = {};
4574
+ /**
4575
+ * Add an item to the registry
4576
+ *
4577
+ * Note that this also returns the registry, so another add method call can
4578
+ * be chained
4579
+ */
4580
+ add(key, value) {
4581
+ this.content[key] = value;
4582
+ return this;
4583
+ }
4584
+ /**
4585
+ * Get an item from the registry
4586
+ */
4587
+ get(key) {
4588
+ /**
4589
+ * Note: key in {} is ~12 times slower than {}[key].
4590
+ * So, we check the absence of key only when the direct access returns
4591
+ * a falsy value. It's done to ensure that the registry can contains falsy values
4592
+ */
4593
+ const content = this.content[key];
4594
+ if (!content) {
4595
+ if (!(key in this.content)) {
4596
+ throw new Error(`Cannot find ${key} in this registry!`);
4597
+ }
4598
+ }
4599
+ return content;
4600
+ }
4601
+ /**
4602
+ * Check if the key is already in the registry
4603
+ */
4604
+ contains(key) {
4605
+ return key in this.content;
4606
+ }
4607
+ /**
4608
+ * Get a list of all elements in the registry
4609
+ */
4610
+ getAll() {
4611
+ return Object.values(this.content);
4612
+ }
4613
+ /**
4614
+ * Get a list of all keys in the registry
4615
+ */
4616
+ getKeys() {
4617
+ return Object.keys(this.content);
4618
+ }
4619
+ /**
4620
+ * Remove an item from the registry
4621
+ */
4622
+ remove(key) {
4623
+ delete this.content[key];
4624
+ }
4625
+ }
4626
+
4627
+ /**
4628
+ * Add the `https` prefix to the url if it's missing
4629
+ */
4630
+ function withHttps(url) {
4631
+ return !/^https?:\/\//i.test(url) ? `https://${url}` : url;
4632
+ }
4633
+ const urlRegistry = new Registry();
4634
+ function createWebLink(url, label) {
4635
+ url = withHttps(url);
4636
+ return {
4637
+ url,
4638
+ label: label || url,
4639
+ isExternal: true,
4640
+ isUrlEditable: true,
4641
+ };
4642
+ }
4643
+ urlRegistry.add("sheet_URL", {
4644
+ match: (url) => isSheetUrl(url),
4645
+ createLink: (url, label) => {
4646
+ return {
4647
+ label,
4648
+ url,
4649
+ isExternal: false,
4650
+ isUrlEditable: false,
4651
+ };
4652
+ },
4653
+ urlRepresentation(url, getters) {
4654
+ const sheetId = parseSheetUrl(url);
4655
+ return getters.tryGetSheetName(sheetId) || _t("Invalid sheet");
4656
+ },
4657
+ open(url, env) {
4658
+ const sheetId = parseSheetUrl(url);
4659
+ env.model.dispatch("ACTIVATE_SHEET", {
4660
+ sheetIdFrom: env.model.getters.getActiveSheetId(),
4661
+ sheetIdTo: sheetId,
4662
+ });
4663
+ },
4664
+ sequence: 0,
4665
+ });
4666
+ const WebUrlSpec = {
4667
+ createLink: createWebLink,
4668
+ match: (url) => isWebLink(url),
4669
+ open: (url) => window.open(url, "_blank"),
4670
+ urlRepresentation: (url) => url,
4671
+ sequence: 0,
4672
+ };
4673
+ function findMatchingSpec(url) {
4674
+ return (urlRegistry
4675
+ .getAll()
4676
+ .sort((a, b) => a.sequence - b.sequence)
4677
+ .find((urlType) => urlType.match(url)) || WebUrlSpec);
4678
+ }
4679
+ function urlRepresentation(link, getters) {
4680
+ return findMatchingSpec(link.url).urlRepresentation(link.url, getters);
4681
+ }
4682
+ function openLink(link, env) {
4683
+ findMatchingSpec(link.url).open(link.url, env);
4684
+ }
4685
+ function detectLink(value) {
4686
+ if (typeof value !== "string") {
4687
+ return undefined;
4688
+ }
4689
+ if (isMarkdownLink(value)) {
4690
+ const { label, url } = parseMarkdownLink(value);
4691
+ return findMatchingSpec(url).createLink(url, label);
4692
+ }
4693
+ else if (isWebLink(value)) {
4694
+ return createWebLink(value);
4695
+ }
4696
+ return undefined;
4697
+ }
4698
+
4699
+ function evaluateLiteral(content, localeFormat) {
4700
+ return createEvaluatedCell(parseLiteral(content || "", localeFormat.locale), localeFormat);
4701
+ }
4702
+ function parseLiteral(content, locale) {
4703
+ if (content.startsWith("=")) {
4704
+ throw new Error(`Cannot parse "${content}" because it's not a literal value. It's a formula`);
4705
+ }
4706
+ if (isNumber(content, DEFAULT_LOCALE)) {
4707
+ return toNumber(content, DEFAULT_LOCALE);
4708
+ }
4709
+ else if (isDateTime(content, locale)) {
4710
+ return toNumber(content, locale);
4711
+ }
4712
+ else if (isBoolean(content)) {
4713
+ return content.toUpperCase() === "TRUE" ? true : false;
4714
+ }
4715
+ return content;
4716
+ }
4717
+ function createEvaluatedCell(value, localeFormat) {
4718
+ const link = detectLink(value);
4719
+ if (link) {
4720
+ return {
4721
+ ..._createEvaluatedCell(parseLiteral(link.label, localeFormat.locale), {
4722
+ format: localeFormat.format ||
4723
+ detectDateFormat(link.label, localeFormat.locale) ||
4724
+ detectNumberFormat(link.label),
4725
+ locale: localeFormat.locale,
4726
+ }),
4727
+ link,
4728
+ };
4729
+ }
4730
+ return _createEvaluatedCell(value, localeFormat);
4731
+ }
4732
+ function _createEvaluatedCell(value, localeFormat) {
4733
+ try {
4734
+ for (const builder of builders) {
4735
+ const evaluateCell = builder(value, localeFormat);
4736
+ if (evaluateCell) {
4737
+ return evaluateCell;
4738
+ }
4739
+ }
4740
+ return textCell((value || "").toString(), localeFormat);
4741
+ }
4742
+ catch (error) {
4743
+ return errorCell(new EvaluationError(CellErrorType.GenericError, error.message || DEFAULT_ERROR_MESSAGE));
4744
+ }
4745
+ }
4746
+ function textCell(value, localeFormat) {
4747
+ return {
4748
+ type: CellValueType.text,
4749
+ value,
4750
+ format: localeFormat.format,
4751
+ isAutoSummable: true,
4752
+ defaultAlign: "left",
4753
+ formattedValue: formatValue(value, localeFormat),
4754
+ };
4755
+ }
4756
+ function numberCell(value, localeFormat) {
4757
+ return {
4758
+ type: CellValueType.number,
4759
+ value: value || 0, // necessary to avoid "-0" and NaN values,
4760
+ format: localeFormat.format,
4761
+ isAutoSummable: true,
4762
+ defaultAlign: "right",
4763
+ formattedValue: formatValue(value, localeFormat),
4764
+ };
4765
+ }
4766
+ const EMPTY_EVALUATED_CELL = {
4767
+ type: CellValueType.empty,
4768
+ value: "",
4769
+ format: undefined,
4770
+ isAutoSummable: true,
4771
+ defaultAlign: "left",
4772
+ formattedValue: "",
4773
+ };
4774
+ function emptyCell(localeFormat) {
4775
+ if (localeFormat.format === undefined) {
4776
+ // share the same object to save memory
4777
+ return EMPTY_EVALUATED_CELL;
4778
+ }
4779
+ return {
4780
+ type: CellValueType.empty,
4781
+ value: "",
4782
+ format: localeFormat.format,
4783
+ isAutoSummable: true,
4784
+ defaultAlign: "left",
4785
+ formattedValue: "",
4786
+ };
4787
+ }
4788
+ function dateTimeCell(value, localeFormat) {
4789
+ const formattedValue = formatValue(value, localeFormat);
4790
+ return {
4791
+ type: CellValueType.number,
4792
+ value,
4793
+ format: localeFormat.format,
4794
+ isAutoSummable: false,
4795
+ defaultAlign: "right",
4796
+ formattedValue,
4797
+ };
4798
+ }
4799
+ function booleanCell(value, localeFormat) {
4800
+ const formattedValue = value ? "TRUE" : "FALSE";
4801
+ return {
4802
+ type: CellValueType.boolean,
4803
+ value,
4804
+ format: localeFormat.format,
4805
+ isAutoSummable: false,
4806
+ defaultAlign: "center",
4807
+ formattedValue,
4808
+ };
4809
+ }
4810
+ function errorCell(error) {
4811
+ return {
4812
+ type: CellValueType.error,
4813
+ value: error.errorType,
4814
+ error,
4815
+ isAutoSummable: false,
4816
+ defaultAlign: "center",
4817
+ formattedValue: error.errorType,
4818
+ };
4819
+ }
4820
+ const builders = [
4821
+ function createEmpty(value, localeFormat) {
4822
+ if (value === "") {
4823
+ return emptyCell(localeFormat);
4824
+ }
4825
+ return undefined;
4826
+ },
4827
+ function createDateTime(value, localeFormat) {
4828
+ if (!!localeFormat.format &&
4829
+ typeof value === "number" &&
4830
+ isDateTimeFormat(localeFormat.format)) {
4831
+ return dateTimeCell(value, localeFormat);
4832
+ }
4833
+ return undefined;
4834
+ },
4835
+ function createNumber(value, localeFormat) {
4836
+ if (typeof value === "number") {
4837
+ return numberCell(value, localeFormat);
4838
+ }
4839
+ else if (value === null) {
4840
+ return numberCell(0, localeFormat);
4841
+ }
4842
+ return undefined;
4843
+ },
4844
+ function createBoolean(value, localeFormat) {
4845
+ if (typeof value === "boolean") {
4846
+ return booleanCell(value, localeFormat);
4847
+ }
4848
+ return undefined;
4849
+ },
4850
+ ];
4851
+
4560
4852
  function computeTextLinesHeight(textLineHeight, numberOfLines = 1) {
4561
4853
  return numberOfLines * (textLineHeight + MIN_CELL_TEXT_MARGIN) - MIN_CELL_TEXT_MARGIN;
4562
4854
  }
4563
4855
  /**
4564
4856
  * Get the default height of the cell given its style.
4565
4857
  */
4566
- function getDefaultCellHeight(ctx, cell, colSize) {
4858
+ function getDefaultCellHeight(ctx, cell, locale, colSize) {
4567
4859
  if (!cell || (!cell.isFormula && !cell.content)) {
4568
4860
  return DEFAULT_CELL_HEIGHT;
4569
4861
  }
4570
- const content = cell.isFormula ? "" : cell.content;
4862
+ let content = "";
4863
+ try {
4864
+ if (!cell.isFormula) {
4865
+ const localeFormat = { format: cell.format, locale };
4866
+ content = formatValue(parseLiteral(cell.content, locale), localeFormat);
4867
+ }
4868
+ }
4869
+ catch {
4870
+ content = CellErrorType.GenericError;
4871
+ }
4571
4872
  return getCellContentHeight(ctx, content, cell.style, colSize);
4572
4873
  }
4573
4874
  function getCellContentHeight(ctx, content, style, colSize) {
@@ -4871,7 +5172,8 @@ function createAction(item) {
4871
5172
  return children
4872
5173
  .map((child) => (typeof child === "function" ? child(env) : child))
4873
5174
  .flat()
4874
- .map(createAction);
5175
+ .map(createAction)
5176
+ .sort((a, b) => a.sequence - b.sequence);
4875
5177
  }
4876
5178
  : () => [],
4877
5179
  isReadonlyAllowed: item.isReadonlyAllowed || false,
@@ -5832,298 +6134,6 @@ ScorecardChart.props = {
5832
6134
  figure: Object,
5833
6135
  };
5834
6136
 
5835
- /**
5836
- * Registry
5837
- *
5838
- * The Registry class is basically just a mapping from a string key to an object.
5839
- * It is really not much more than an object. It is however useful for the
5840
- * following reasons:
5841
- *
5842
- * 1. it let us react and execute code when someone add something to the registry
5843
- * (for example, the FunctionRegistry subclass this for this purpose)
5844
- * 2. it throws an error when the get operation fails
5845
- * 3. it provides a chained API to add items to the registry.
5846
- */
5847
- class Registry {
5848
- content = {};
5849
- /**
5850
- * Add an item to the registry
5851
- *
5852
- * Note that this also returns the registry, so another add method call can
5853
- * be chained
5854
- */
5855
- add(key, value) {
5856
- this.content[key] = value;
5857
- return this;
5858
- }
5859
- /**
5860
- * Get an item from the registry
5861
- */
5862
- get(key) {
5863
- /**
5864
- * Note: key in {} is ~12 times slower than {}[key].
5865
- * So, we check the absence of key only when the direct access returns
5866
- * a falsy value. It's done to ensure that the registry can contains falsy values
5867
- */
5868
- const content = this.content[key];
5869
- if (!content) {
5870
- if (!(key in this.content)) {
5871
- throw new Error(`Cannot find ${key} in this registry!`);
5872
- }
5873
- }
5874
- return content;
5875
- }
5876
- /**
5877
- * Check if the key is already in the registry
5878
- */
5879
- contains(key) {
5880
- return key in this.content;
5881
- }
5882
- /**
5883
- * Get a list of all elements in the registry
5884
- */
5885
- getAll() {
5886
- return Object.values(this.content);
5887
- }
5888
- /**
5889
- * Get a list of all keys in the registry
5890
- */
5891
- getKeys() {
5892
- return Object.keys(this.content);
5893
- }
5894
- /**
5895
- * Remove an item from the registry
5896
- */
5897
- remove(key) {
5898
- delete this.content[key];
5899
- }
5900
- }
5901
-
5902
- /**
5903
- * Add the `https` prefix to the url if it's missing
5904
- */
5905
- function withHttps(url) {
5906
- return !/^https?:\/\//i.test(url) ? `https://${url}` : url;
5907
- }
5908
- const urlRegistry = new Registry();
5909
- function createWebLink(url, label) {
5910
- url = withHttps(url);
5911
- return {
5912
- url,
5913
- label: label || url,
5914
- isExternal: true,
5915
- isUrlEditable: true,
5916
- };
5917
- }
5918
- urlRegistry.add("sheet_URL", {
5919
- match: (url) => isSheetUrl(url),
5920
- createLink: (url, label) => {
5921
- return {
5922
- label,
5923
- url,
5924
- isExternal: false,
5925
- isUrlEditable: false,
5926
- };
5927
- },
5928
- urlRepresentation(url, getters) {
5929
- const sheetId = parseSheetUrl(url);
5930
- return getters.tryGetSheetName(sheetId) || _t("Invalid sheet");
5931
- },
5932
- open(url, env) {
5933
- const sheetId = parseSheetUrl(url);
5934
- env.model.dispatch("ACTIVATE_SHEET", {
5935
- sheetIdFrom: env.model.getters.getActiveSheetId(),
5936
- sheetIdTo: sheetId,
5937
- });
5938
- },
5939
- sequence: 0,
5940
- });
5941
- const WebUrlSpec = {
5942
- createLink: createWebLink,
5943
- match: (url) => isWebLink(url),
5944
- open: (url) => window.open(url, "_blank"),
5945
- urlRepresentation: (url) => url,
5946
- sequence: 0,
5947
- };
5948
- function findMatchingSpec(url) {
5949
- return (urlRegistry
5950
- .getAll()
5951
- .sort((a, b) => a.sequence - b.sequence)
5952
- .find((urlType) => urlType.match(url)) || WebUrlSpec);
5953
- }
5954
- function urlRepresentation(link, getters) {
5955
- return findMatchingSpec(link.url).urlRepresentation(link.url, getters);
5956
- }
5957
- function openLink(link, env) {
5958
- findMatchingSpec(link.url).open(link.url, env);
5959
- }
5960
- function detectLink(value) {
5961
- if (typeof value !== "string") {
5962
- return undefined;
5963
- }
5964
- if (isMarkdownLink(value)) {
5965
- const { label, url } = parseMarkdownLink(value);
5966
- return findMatchingSpec(url).createLink(url, label);
5967
- }
5968
- else if (isWebLink(value)) {
5969
- return createWebLink(value);
5970
- }
5971
- return undefined;
5972
- }
5973
-
5974
- function evaluateLiteral(content, localeFormat) {
5975
- return createEvaluatedCell(parseLiteral(content || "", localeFormat.locale), localeFormat);
5976
- }
5977
- function parseLiteral(content, locale) {
5978
- if (content.startsWith("=")) {
5979
- throw new Error(`Cannot parse "${content}" because it's not a literal value. It's a formula`);
5980
- }
5981
- if (isNumber(content, DEFAULT_LOCALE)) {
5982
- return toNumber(content, DEFAULT_LOCALE);
5983
- }
5984
- else if (isDateTime(content, locale)) {
5985
- return toNumber(content, locale);
5986
- }
5987
- else if (isBoolean(content)) {
5988
- return content.toUpperCase() === "TRUE" ? true : false;
5989
- }
5990
- return content;
5991
- }
5992
- function createEvaluatedCell(value, localeFormat) {
5993
- const link = detectLink(value);
5994
- if (link) {
5995
- return {
5996
- ..._createEvaluatedCell(parseLiteral(link.label, localeFormat.locale), {
5997
- format: localeFormat.format ||
5998
- detectDateFormat(link.label, localeFormat.locale) ||
5999
- detectNumberFormat(link.label),
6000
- locale: localeFormat.locale,
6001
- }),
6002
- link,
6003
- };
6004
- }
6005
- return _createEvaluatedCell(value, localeFormat);
6006
- }
6007
- function _createEvaluatedCell(value, localeFormat) {
6008
- try {
6009
- for (const builder of builders) {
6010
- const evaluateCell = builder(value, localeFormat);
6011
- if (evaluateCell) {
6012
- return evaluateCell;
6013
- }
6014
- }
6015
- return textCell((value || "").toString(), localeFormat);
6016
- }
6017
- catch (error) {
6018
- return errorCell(new EvaluationError(CellErrorType.GenericError, error.message || DEFAULT_ERROR_MESSAGE));
6019
- }
6020
- }
6021
- function textCell(value, localeFormat) {
6022
- return {
6023
- type: CellValueType.text,
6024
- value,
6025
- format: localeFormat.format,
6026
- isAutoSummable: true,
6027
- defaultAlign: "left",
6028
- formattedValue: formatValue(value, localeFormat),
6029
- };
6030
- }
6031
- function numberCell(value, localeFormat) {
6032
- return {
6033
- type: CellValueType.number,
6034
- value: value || 0, // necessary to avoid "-0" and NaN values,
6035
- format: localeFormat.format,
6036
- isAutoSummable: true,
6037
- defaultAlign: "right",
6038
- formattedValue: formatValue(value, localeFormat),
6039
- };
6040
- }
6041
- const EMPTY_EVALUATED_CELL = {
6042
- type: CellValueType.empty,
6043
- value: "",
6044
- format: undefined,
6045
- isAutoSummable: true,
6046
- defaultAlign: "left",
6047
- formattedValue: "",
6048
- };
6049
- function emptyCell(localeFormat) {
6050
- if (localeFormat.format === undefined) {
6051
- // share the same object to save memory
6052
- return EMPTY_EVALUATED_CELL;
6053
- }
6054
- return {
6055
- type: CellValueType.empty,
6056
- value: "",
6057
- format: localeFormat.format,
6058
- isAutoSummable: true,
6059
- defaultAlign: "left",
6060
- formattedValue: "",
6061
- };
6062
- }
6063
- function dateTimeCell(value, localeFormat) {
6064
- const formattedValue = formatValue(value, localeFormat);
6065
- return {
6066
- type: CellValueType.number,
6067
- value,
6068
- format: localeFormat.format,
6069
- isAutoSummable: false,
6070
- defaultAlign: "right",
6071
- formattedValue,
6072
- };
6073
- }
6074
- function booleanCell(value, localeFormat) {
6075
- const formattedValue = value ? "TRUE" : "FALSE";
6076
- return {
6077
- type: CellValueType.boolean,
6078
- value,
6079
- format: localeFormat.format,
6080
- isAutoSummable: false,
6081
- defaultAlign: "center",
6082
- formattedValue,
6083
- };
6084
- }
6085
- function errorCell(error) {
6086
- return {
6087
- type: CellValueType.error,
6088
- value: error.errorType,
6089
- error,
6090
- isAutoSummable: false,
6091
- defaultAlign: "center",
6092
- formattedValue: error.errorType,
6093
- };
6094
- }
6095
- const builders = [
6096
- function createEmpty(value, localeFormat) {
6097
- if (value === "") {
6098
- return emptyCell(localeFormat);
6099
- }
6100
- return undefined;
6101
- },
6102
- function createDateTime(value, localeFormat) {
6103
- if (!!localeFormat.format &&
6104
- typeof value === "number" &&
6105
- isDateTimeFormat(localeFormat.format)) {
6106
- return dateTimeCell(value, localeFormat);
6107
- }
6108
- return undefined;
6109
- },
6110
- function createNumber(value, localeFormat) {
6111
- if (typeof value === "number") {
6112
- return numberCell(value, localeFormat);
6113
- }
6114
- else if (value === null) {
6115
- return numberCell(0, localeFormat);
6116
- }
6117
- return undefined;
6118
- },
6119
- function createBoolean(value, localeFormat) {
6120
- if (typeof value === "boolean") {
6121
- return booleanCell(value, localeFormat);
6122
- }
6123
- return undefined;
6124
- },
6125
- ];
6126
-
6127
6137
  /**
6128
6138
  * An AutofillModifierImplementation is used to describe how to handle a
6129
6139
  * AutofillModifier.
@@ -43585,6 +43595,7 @@ class HeaderSizeUIPlugin extends UIPlugin {
43585
43595
  handle(cmd) {
43586
43596
  switch (cmd.type) {
43587
43597
  case "START":
43598
+ case "UPDATE_LOCALE":
43588
43599
  for (const sheetId of this.getters.getSheetIds()) {
43589
43600
  this.initializeSheet(sheetId);
43590
43601
  }
@@ -43690,7 +43701,7 @@ class HeaderSizeUIPlugin extends UIPlugin {
43690
43701
  }
43691
43702
  const cell = this.getters.getCell(position);
43692
43703
  const colSize = this.getters.getColSize(position.sheetId, position.col);
43693
- return getDefaultCellHeight(this.ctx, cell, colSize);
43704
+ return getDefaultCellHeight(this.ctx, cell, this.getters.getLocale(), colSize);
43694
43705
  }
43695
43706
  isInMultiRowMerge(position) {
43696
43707
  const merge = this.getters.getMerge(position);
@@ -58549,6 +58560,6 @@ exports.setTranslationMethod = setTranslationMethod;
58549
58560
  exports.tokenize = tokenize;
58550
58561
 
58551
58562
 
58552
- __info__.version = "17.0.84";
58553
- __info__.date = "2026-01-14T09:59:26.542Z";
58554
- __info__.hash = "ae64224";
58563
+ __info__.version = "17.0.85";
58564
+ __info__.date = "2026-01-21T11:02:43.920Z";
58565
+ __info__.hash = "0343060";