@odoo/o-spreadsheet 17.2.12 → 17.2.13

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.
@@ -3,9 +3,9 @@
3
3
  /**
4
4
  * This file is generated by o-spreadsheet build tools. Do not edit it.
5
5
  * @see https://github.com/odoo/o-spreadsheet
6
- * @version 17.2.12
7
- * @date 2024-06-21T19:58:15.248Z
8
- * @hash 1aaacc4
6
+ * @version 17.2.13
7
+ * @date 2024-07-02T09:03:00.731Z
8
+ * @hash fac2351
9
9
  */
10
10
 
11
11
  'use strict';
@@ -1818,9 +1818,10 @@ function percentile(values, percent, isInclusive) {
1818
1818
  sortedValues[indexLow] * (indexSup - percentIndex));
1819
1819
  }
1820
1820
 
1821
- // define a mock translation function, when o-spreadsheet runs in standalone it doesn't translate any string
1822
- let _translate = (s) => s;
1823
- let _loaded = () => false;
1821
+ const defaultTranslate = (s) => s;
1822
+ const defaultLoaded = () => false;
1823
+ let _translate = defaultTranslate;
1824
+ let _loaded = defaultLoaded;
1824
1825
  function sprintf(s, ...values) {
1825
1826
  if (values.length === 1 && typeof values[0] === "object" && !(values[0] instanceof String)) {
1826
1827
  const valuesDict = values[0];
@@ -1832,7 +1833,8 @@ function sprintf(s, ...values) {
1832
1833
  return s;
1833
1834
  }
1834
1835
  /***
1835
- * Allow to inject a translation function from outside o-spreadsheet.
1836
+ * Allow to inject a translation function from outside o-spreadsheet. This should be called before instantiating
1837
+ * a model.
1836
1838
  * @param tfn the function that will do the translation
1837
1839
  * @param loaded a function that returns true when the translation is loaded
1838
1840
  */
@@ -1840,6 +1842,18 @@ function setTranslationMethod(tfn, loaded = () => true) {
1840
1842
  _translate = tfn;
1841
1843
  _loaded = loaded;
1842
1844
  }
1845
+ /**
1846
+ * If no translation function has been set, this will mark the translation are loaded.
1847
+ *
1848
+ * By default, the translations should not be set as loaded, otherwise top-level translated constants will never be
1849
+ * translated. But if by the time the model is instantiated no custom translation function has been set, we can set
1850
+ * the default translation function as loaded so o-spreadsheet can be run in standalone with no translations.
1851
+ */
1852
+ function setDefaultTranslationMethod() {
1853
+ if (_translate === defaultTranslate && _loaded === defaultLoaded) {
1854
+ _loaded = () => true;
1855
+ }
1856
+ }
1843
1857
  const _t = function (s, ...values) {
1844
1858
  if (!_loaded()) {
1845
1859
  return new LazyTranslatedString(s, values);
@@ -29853,6 +29867,7 @@ class FindAndReplaceStore extends SpreadsheetStore {
29853
29867
  currentSearchRegex = null;
29854
29868
  isSearchDirty = false;
29855
29869
  initialShowFormulaState;
29870
+ preserveSelectedMatchIndex = false;
29856
29871
  // fixme: why do we make selectedMatchIndex on top of a selected
29857
29872
  // property in the matches?
29858
29873
  selectedMatchIndex = null;
@@ -29962,7 +29977,9 @@ class FindAndReplaceStore extends SpreadsheetStore {
29962
29977
  * refresh the matches according to the current search options
29963
29978
  */
29964
29979
  refreshSearch(jumpToMatchSheet = true) {
29965
- this.selectedMatchIndex = null;
29980
+ if (!this.preserveSelectedMatchIndex) {
29981
+ this.selectedMatchIndex = null;
29982
+ }
29966
29983
  this.findMatches();
29967
29984
  this.selectNextCell(Direction.current, jumpToMatchSheet);
29968
29985
  }
@@ -30061,10 +30078,16 @@ class FindAndReplaceStore extends SpreadsheetStore {
30061
30078
  const selectedMatch = matches[nextIndex];
30062
30079
  // Switch to the sheet where the match is located
30063
30080
  if (jumpToMatchSheet && this.getters.getActiveSheetId() !== selectedMatch.sheetId) {
30081
+ // We set `preserveSelectedMatchIndex` to true to avoid resetting the selected search
30082
+ // index in the `refreshSearch` function when a new sheet is activated. The reason being
30083
+ // that, when we automatically go back to previous sheet while performing a search, the
30084
+ // search index is reset to the first occurrence each time.
30085
+ this.preserveSelectedMatchIndex = true;
30064
30086
  this.model.dispatch("ACTIVATE_SHEET", {
30065
30087
  sheetIdFrom: this.getters.getActiveSheetId(),
30066
30088
  sheetIdTo: selectedMatch.sheetId,
30067
30089
  });
30090
+ this.preserveSelectedMatchIndex = false;
30068
30091
  // We do not want to reset the selection at finalize in this case
30069
30092
  this.isSearchDirty = false;
30070
30093
  }
@@ -54980,7 +55003,7 @@ class BottomBarSheet extends owl.Component {
54980
55003
  this.DOMFocusableElementStore.focus();
54981
55004
  }
54982
55005
  }
54983
- onClickSheetName(ev) {
55006
+ onMouseEventSheetName(ev) {
54984
55007
  if (this.state.isEditing)
54985
55008
  ev.stopPropagation();
54986
55009
  }
@@ -60152,6 +60175,7 @@ class Model extends EventBus {
60152
60175
  coreHandlers = [];
60153
60176
  constructor(data = {}, config = {}, stateUpdateMessages = [], uuidGenerator = new UuidGenerator(), verboseImport = true) {
60154
60177
  super();
60178
+ setDefaultTranslationMethod();
60155
60179
  stateUpdateMessages = repairInitialMessages(data, stateUpdateMessages);
60156
60180
  const workbookData = load(data, verboseImport);
60157
60181
  this.state = new StateObserver();
@@ -60784,6 +60808,6 @@ exports.tokenColors = tokenColors;
60784
60808
  exports.tokenize = tokenize;
60785
60809
 
60786
60810
 
60787
- __info__.version = "17.2.12";
60788
- __info__.date = "2024-06-21T19:58:15.248Z";
60789
- __info__.hash = "1aaacc4";
60811
+ __info__.version = "17.2.13";
60812
+ __info__.date = "2024-07-02T09:03:00.731Z";
60813
+ __info__.hash = "fac2351";
@@ -7951,6 +7951,7 @@ declare class FindAndReplaceStore extends SpreadsheetStore implements HighlightP
7951
7951
  private currentSearchRegex;
7952
7952
  private isSearchDirty;
7953
7953
  private initialShowFormulaState;
7954
+ private preserveSelectedMatchIndex;
7954
7955
  selectedMatchIndex: number | null;
7955
7956
  toSearch: string;
7956
7957
  toReplace: string;
@@ -8235,7 +8236,7 @@ declare class BottomBarSheet extends Component<Props$b, SpreadsheetChildEnv> {
8235
8236
  private activateSheet;
8236
8237
  onDblClick(): void;
8237
8238
  onKeyDown(ev: KeyboardEvent): void;
8238
- onClickSheetName(ev: MouseEvent): void;
8239
+ onMouseEventSheetName(ev: MouseEvent): void;
8239
8240
  private startEdition;
8240
8241
  private stopEdition;
8241
8242
  private cancelEdition;
@@ -9072,7 +9073,8 @@ type SprintfValues = (string | String | number)[] | [{
9072
9073
  }];
9073
9074
  type TranslationFunction = (string: string, ...values: SprintfValues) => string;
9074
9075
  /***
9075
- * Allow to inject a translation function from outside o-spreadsheet.
9076
+ * Allow to inject a translation function from outside o-spreadsheet. This should be called before instantiating
9077
+ * a model.
9076
9078
  * @param tfn the function that will do the translation
9077
9079
  * @param loaded a function that returns true when the translation is loaded
9078
9080
  */
@@ -3,9 +3,9 @@
3
3
  /**
4
4
  * This file is generated by o-spreadsheet build tools. Do not edit it.
5
5
  * @see https://github.com/odoo/o-spreadsheet
6
- * @version 17.2.12
7
- * @date 2024-06-21T19:58:15.248Z
8
- * @hash 1aaacc4
6
+ * @version 17.2.13
7
+ * @date 2024-07-02T09:03:00.731Z
8
+ * @hash fac2351
9
9
  */
10
10
 
11
11
  import { useEnv, useSubEnv, onWillUnmount, useComponent, status, Component, useRef, onMounted, useEffect, useState, onPatched, onWillPatch, onWillUpdateProps, useExternalListener, onWillStart, xml, useChildSubEnv, markRaw } from '@odoo/owl';
@@ -1816,9 +1816,10 @@ function percentile(values, percent, isInclusive) {
1816
1816
  sortedValues[indexLow] * (indexSup - percentIndex));
1817
1817
  }
1818
1818
 
1819
- // define a mock translation function, when o-spreadsheet runs in standalone it doesn't translate any string
1820
- let _translate = (s) => s;
1821
- let _loaded = () => false;
1819
+ const defaultTranslate = (s) => s;
1820
+ const defaultLoaded = () => false;
1821
+ let _translate = defaultTranslate;
1822
+ let _loaded = defaultLoaded;
1822
1823
  function sprintf(s, ...values) {
1823
1824
  if (values.length === 1 && typeof values[0] === "object" && !(values[0] instanceof String)) {
1824
1825
  const valuesDict = values[0];
@@ -1830,7 +1831,8 @@ function sprintf(s, ...values) {
1830
1831
  return s;
1831
1832
  }
1832
1833
  /***
1833
- * Allow to inject a translation function from outside o-spreadsheet.
1834
+ * Allow to inject a translation function from outside o-spreadsheet. This should be called before instantiating
1835
+ * a model.
1834
1836
  * @param tfn the function that will do the translation
1835
1837
  * @param loaded a function that returns true when the translation is loaded
1836
1838
  */
@@ -1838,6 +1840,18 @@ function setTranslationMethod(tfn, loaded = () => true) {
1838
1840
  _translate = tfn;
1839
1841
  _loaded = loaded;
1840
1842
  }
1843
+ /**
1844
+ * If no translation function has been set, this will mark the translation are loaded.
1845
+ *
1846
+ * By default, the translations should not be set as loaded, otherwise top-level translated constants will never be
1847
+ * translated. But if by the time the model is instantiated no custom translation function has been set, we can set
1848
+ * the default translation function as loaded so o-spreadsheet can be run in standalone with no translations.
1849
+ */
1850
+ function setDefaultTranslationMethod() {
1851
+ if (_translate === defaultTranslate && _loaded === defaultLoaded) {
1852
+ _loaded = () => true;
1853
+ }
1854
+ }
1841
1855
  const _t = function (s, ...values) {
1842
1856
  if (!_loaded()) {
1843
1857
  return new LazyTranslatedString(s, values);
@@ -29851,6 +29865,7 @@ class FindAndReplaceStore extends SpreadsheetStore {
29851
29865
  currentSearchRegex = null;
29852
29866
  isSearchDirty = false;
29853
29867
  initialShowFormulaState;
29868
+ preserveSelectedMatchIndex = false;
29854
29869
  // fixme: why do we make selectedMatchIndex on top of a selected
29855
29870
  // property in the matches?
29856
29871
  selectedMatchIndex = null;
@@ -29960,7 +29975,9 @@ class FindAndReplaceStore extends SpreadsheetStore {
29960
29975
  * refresh the matches according to the current search options
29961
29976
  */
29962
29977
  refreshSearch(jumpToMatchSheet = true) {
29963
- this.selectedMatchIndex = null;
29978
+ if (!this.preserveSelectedMatchIndex) {
29979
+ this.selectedMatchIndex = null;
29980
+ }
29964
29981
  this.findMatches();
29965
29982
  this.selectNextCell(Direction.current, jumpToMatchSheet);
29966
29983
  }
@@ -30059,10 +30076,16 @@ class FindAndReplaceStore extends SpreadsheetStore {
30059
30076
  const selectedMatch = matches[nextIndex];
30060
30077
  // Switch to the sheet where the match is located
30061
30078
  if (jumpToMatchSheet && this.getters.getActiveSheetId() !== selectedMatch.sheetId) {
30079
+ // We set `preserveSelectedMatchIndex` to true to avoid resetting the selected search
30080
+ // index in the `refreshSearch` function when a new sheet is activated. The reason being
30081
+ // that, when we automatically go back to previous sheet while performing a search, the
30082
+ // search index is reset to the first occurrence each time.
30083
+ this.preserveSelectedMatchIndex = true;
30062
30084
  this.model.dispatch("ACTIVATE_SHEET", {
30063
30085
  sheetIdFrom: this.getters.getActiveSheetId(),
30064
30086
  sheetIdTo: selectedMatch.sheetId,
30065
30087
  });
30088
+ this.preserveSelectedMatchIndex = false;
30066
30089
  // We do not want to reset the selection at finalize in this case
30067
30090
  this.isSearchDirty = false;
30068
30091
  }
@@ -54978,7 +55001,7 @@ class BottomBarSheet extends Component {
54978
55001
  this.DOMFocusableElementStore.focus();
54979
55002
  }
54980
55003
  }
54981
- onClickSheetName(ev) {
55004
+ onMouseEventSheetName(ev) {
54982
55005
  if (this.state.isEditing)
54983
55006
  ev.stopPropagation();
54984
55007
  }
@@ -60150,6 +60173,7 @@ class Model extends EventBus {
60150
60173
  coreHandlers = [];
60151
60174
  constructor(data = {}, config = {}, stateUpdateMessages = [], uuidGenerator = new UuidGenerator(), verboseImport = true) {
60152
60175
  super();
60176
+ setDefaultTranslationMethod();
60153
60177
  stateUpdateMessages = repairInitialMessages(data, stateUpdateMessages);
60154
60178
  const workbookData = load(data, verboseImport);
60155
60179
  this.state = new StateObserver();
@@ -60741,6 +60765,6 @@ const constants = {
60741
60765
  export { AbstractCellClipboardHandler, AbstractChart, AbstractFigureClipboardHandler, CellErrorType, CommandResult, CorePlugin, DispatchResult, EvaluationError, Model, Registry, Revision, SPREADSHEET_DIMENSIONS, Spreadsheet, UIPlugin, __info__, addFunction, addRenderingLayer, astToFormula, compile, compileTokens, components, constants, convertAstNodes, coreTypes, findCellInNewZone, functionCache, helpers, hooks, invalidateCFEvaluationCommands, invalidateDependenciesCommands, invalidateEvaluationCommands, iterateAstNodes, links, load, parse, parseTokens, readonlyAllowedCommands, registries, setDefaultSheetViewSize, setTranslationMethod, stores, tokenColors, tokenize };
60742
60766
 
60743
60767
 
60744
- __info__.version = "17.2.12";
60745
- __info__.date = "2024-06-21T19:58:15.248Z";
60746
- __info__.hash = "1aaacc4";
60768
+ __info__.version = "17.2.13";
60769
+ __info__.date = "2024-07-02T09:03:00.731Z";
60770
+ __info__.hash = "fac2351";
@@ -3,9 +3,9 @@
3
3
  /**
4
4
  * This file is generated by o-spreadsheet build tools. Do not edit it.
5
5
  * @see https://github.com/odoo/o-spreadsheet
6
- * @version 17.2.12
7
- * @date 2024-06-21T19:58:15.248Z
8
- * @hash 1aaacc4
6
+ * @version 17.2.13
7
+ * @date 2024-07-02T09:03:00.731Z
8
+ * @hash fac2351
9
9
  */
10
10
 
11
11
  (function (exports, owl) {
@@ -1817,9 +1817,10 @@
1817
1817
  sortedValues[indexLow] * (indexSup - percentIndex));
1818
1818
  }
1819
1819
 
1820
- // define a mock translation function, when o-spreadsheet runs in standalone it doesn't translate any string
1821
- let _translate = (s) => s;
1822
- let _loaded = () => false;
1820
+ const defaultTranslate = (s) => s;
1821
+ const defaultLoaded = () => false;
1822
+ let _translate = defaultTranslate;
1823
+ let _loaded = defaultLoaded;
1823
1824
  function sprintf(s, ...values) {
1824
1825
  if (values.length === 1 && typeof values[0] === "object" && !(values[0] instanceof String)) {
1825
1826
  const valuesDict = values[0];
@@ -1831,7 +1832,8 @@
1831
1832
  return s;
1832
1833
  }
1833
1834
  /***
1834
- * Allow to inject a translation function from outside o-spreadsheet.
1835
+ * Allow to inject a translation function from outside o-spreadsheet. This should be called before instantiating
1836
+ * a model.
1835
1837
  * @param tfn the function that will do the translation
1836
1838
  * @param loaded a function that returns true when the translation is loaded
1837
1839
  */
@@ -1839,6 +1841,18 @@
1839
1841
  _translate = tfn;
1840
1842
  _loaded = loaded;
1841
1843
  }
1844
+ /**
1845
+ * If no translation function has been set, this will mark the translation are loaded.
1846
+ *
1847
+ * By default, the translations should not be set as loaded, otherwise top-level translated constants will never be
1848
+ * translated. But if by the time the model is instantiated no custom translation function has been set, we can set
1849
+ * the default translation function as loaded so o-spreadsheet can be run in standalone with no translations.
1850
+ */
1851
+ function setDefaultTranslationMethod() {
1852
+ if (_translate === defaultTranslate && _loaded === defaultLoaded) {
1853
+ _loaded = () => true;
1854
+ }
1855
+ }
1842
1856
  const _t = function (s, ...values) {
1843
1857
  if (!_loaded()) {
1844
1858
  return new LazyTranslatedString(s, values);
@@ -29852,6 +29866,7 @@ stores.inject(MyMetaStore, storeInstance);
29852
29866
  currentSearchRegex = null;
29853
29867
  isSearchDirty = false;
29854
29868
  initialShowFormulaState;
29869
+ preserveSelectedMatchIndex = false;
29855
29870
  // fixme: why do we make selectedMatchIndex on top of a selected
29856
29871
  // property in the matches?
29857
29872
  selectedMatchIndex = null;
@@ -29961,7 +29976,9 @@ stores.inject(MyMetaStore, storeInstance);
29961
29976
  * refresh the matches according to the current search options
29962
29977
  */
29963
29978
  refreshSearch(jumpToMatchSheet = true) {
29964
- this.selectedMatchIndex = null;
29979
+ if (!this.preserveSelectedMatchIndex) {
29980
+ this.selectedMatchIndex = null;
29981
+ }
29965
29982
  this.findMatches();
29966
29983
  this.selectNextCell(Direction.current, jumpToMatchSheet);
29967
29984
  }
@@ -30060,10 +30077,16 @@ stores.inject(MyMetaStore, storeInstance);
30060
30077
  const selectedMatch = matches[nextIndex];
30061
30078
  // Switch to the sheet where the match is located
30062
30079
  if (jumpToMatchSheet && this.getters.getActiveSheetId() !== selectedMatch.sheetId) {
30080
+ // We set `preserveSelectedMatchIndex` to true to avoid resetting the selected search
30081
+ // index in the `refreshSearch` function when a new sheet is activated. The reason being
30082
+ // that, when we automatically go back to previous sheet while performing a search, the
30083
+ // search index is reset to the first occurrence each time.
30084
+ this.preserveSelectedMatchIndex = true;
30063
30085
  this.model.dispatch("ACTIVATE_SHEET", {
30064
30086
  sheetIdFrom: this.getters.getActiveSheetId(),
30065
30087
  sheetIdTo: selectedMatch.sheetId,
30066
30088
  });
30089
+ this.preserveSelectedMatchIndex = false;
30067
30090
  // We do not want to reset the selection at finalize in this case
30068
30091
  this.isSearchDirty = false;
30069
30092
  }
@@ -54979,7 +55002,7 @@ stores.inject(MyMetaStore, storeInstance);
54979
55002
  this.DOMFocusableElementStore.focus();
54980
55003
  }
54981
55004
  }
54982
- onClickSheetName(ev) {
55005
+ onMouseEventSheetName(ev) {
54983
55006
  if (this.state.isEditing)
54984
55007
  ev.stopPropagation();
54985
55008
  }
@@ -60151,6 +60174,7 @@ stores.inject(MyMetaStore, storeInstance);
60151
60174
  coreHandlers = [];
60152
60175
  constructor(data = {}, config = {}, stateUpdateMessages = [], uuidGenerator = new UuidGenerator(), verboseImport = true) {
60153
60176
  super();
60177
+ setDefaultTranslationMethod();
60154
60178
  stateUpdateMessages = repairInitialMessages(data, stateUpdateMessages);
60155
60179
  const workbookData = load(data, verboseImport);
60156
60180
  this.state = new StateObserver();
@@ -60783,9 +60807,9 @@ stores.inject(MyMetaStore, storeInstance);
60783
60807
  exports.tokenize = tokenize;
60784
60808
 
60785
60809
 
60786
- __info__.version = "17.2.12";
60787
- __info__.date = "2024-06-21T19:58:15.248Z";
60788
- __info__.hash = "1aaacc4";
60810
+ __info__.version = "17.2.13";
60811
+ __info__.date = "2024-07-02T09:03:00.731Z";
60812
+ __info__.hash = "fac2351";
60789
60813
 
60790
60814
 
60791
60815
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);