@odoo/o-spreadsheet 17.3.4 → 17.3.6

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.3.4
7
- * @date 2024-06-21T20:00:08.515Z
8
- * @hash 6efbf3b
6
+ * @version 17.3.6
7
+ * @date 2024-07-02T09:04:06.235Z
8
+ * @hash 979c0b1
9
9
  */
10
10
 
11
11
  'use strict';
@@ -1898,9 +1898,10 @@ function percentile(values, percent, isInclusive) {
1898
1898
  sortedValues[indexLow] * (indexSup - percentIndex));
1899
1899
  }
1900
1900
 
1901
- // define a mock translation function, when o-spreadsheet runs in standalone it doesn't translate any string
1902
- let _translate = (s) => s;
1903
- let _loaded = () => false;
1901
+ const defaultTranslate = (s) => s;
1902
+ const defaultLoaded = () => false;
1903
+ let _translate = defaultTranslate;
1904
+ let _loaded = defaultLoaded;
1904
1905
  function sprintf(s, ...values) {
1905
1906
  if (values.length === 1 && typeof values[0] === "object" && !(values[0] instanceof String)) {
1906
1907
  const valuesDict = values[0];
@@ -1912,7 +1913,8 @@ function sprintf(s, ...values) {
1912
1913
  return s;
1913
1914
  }
1914
1915
  /***
1915
- * Allow to inject a translation function from outside o-spreadsheet.
1916
+ * Allow to inject a translation function from outside o-spreadsheet. This should be called before instantiating
1917
+ * a model.
1916
1918
  * @param tfn the function that will do the translation
1917
1919
  * @param loaded a function that returns true when the translation is loaded
1918
1920
  */
@@ -1920,6 +1922,18 @@ function setTranslationMethod(tfn, loaded = () => true) {
1920
1922
  _translate = tfn;
1921
1923
  _loaded = loaded;
1922
1924
  }
1925
+ /**
1926
+ * If no translation function has been set, this will mark the translation are loaded.
1927
+ *
1928
+ * By default, the translations should not be set as loaded, otherwise top-level translated constants will never be
1929
+ * translated. But if by the time the model is instantiated no custom translation function has been set, we can set
1930
+ * the default translation function as loaded so o-spreadsheet can be run in standalone with no translations.
1931
+ */
1932
+ function setDefaultTranslationMethod() {
1933
+ if (_translate === defaultTranslate && _loaded === defaultLoaded) {
1934
+ _loaded = () => true;
1935
+ }
1936
+ }
1923
1937
  const _t = function (s, ...values) {
1924
1938
  if (!_loaded()) {
1925
1939
  return new LazyTranslatedString(s, values);
@@ -21675,7 +21689,6 @@ const ALL_PERIODS = {
21675
21689
  month: _t("Month"),
21676
21690
  week: _t("Week"),
21677
21691
  day: _t("Day"),
21678
- year_number: _t("Year"),
21679
21692
  quarter_number: _t("Quarter"),
21680
21693
  month_number: _t("Month"),
21681
21694
  iso_week_number: _t("Week"),
@@ -34063,6 +34076,7 @@ class FindAndReplaceStore extends SpreadsheetStore {
34063
34076
  currentSearchRegex = null;
34064
34077
  isSearchDirty = false;
34065
34078
  initialShowFormulaState;
34079
+ preserveSelectedMatchIndex = false;
34066
34080
  // fixme: why do we make selectedMatchIndex on top of a selected
34067
34081
  // property in the matches?
34068
34082
  selectedMatchIndex = null;
@@ -34172,7 +34186,9 @@ class FindAndReplaceStore extends SpreadsheetStore {
34172
34186
  * refresh the matches according to the current search options
34173
34187
  */
34174
34188
  refreshSearch(jumpToMatchSheet = true) {
34175
- this.selectedMatchIndex = null;
34189
+ if (!this.preserveSelectedMatchIndex) {
34190
+ this.selectedMatchIndex = null;
34191
+ }
34176
34192
  this.findMatches();
34177
34193
  this.selectNextCell(Direction.current, jumpToMatchSheet);
34178
34194
  }
@@ -34271,10 +34287,16 @@ class FindAndReplaceStore extends SpreadsheetStore {
34271
34287
  const selectedMatch = matches[nextIndex];
34272
34288
  // Switch to the sheet where the match is located
34273
34289
  if (jumpToMatchSheet && this.getters.getActiveSheetId() !== selectedMatch.sheetId) {
34290
+ // We set `preserveSelectedMatchIndex` to true to avoid resetting the selected search
34291
+ // index in the `refreshSearch` function when a new sheet is activated. The reason being
34292
+ // that, when we automatically go back to previous sheet while performing a search, the
34293
+ // search index is reset to the first occurrence each time.
34294
+ this.preserveSelectedMatchIndex = true;
34274
34295
  this.model.dispatch("ACTIVATE_SHEET", {
34275
34296
  sheetIdFrom: this.getters.getActiveSheetId(),
34276
34297
  sheetIdTo: selectedMatch.sheetId,
34277
34298
  });
34299
+ this.preserveSelectedMatchIndex = false;
34278
34300
  // We do not want to reset the selection at finalize in this case
34279
34301
  this.isSearchDirty = false;
34280
34302
  }
@@ -35339,7 +35361,7 @@ function createDate(dimension, value, locale) {
35339
35361
  const date = toJsDate(value, locale);
35340
35362
  let number = 0;
35341
35363
  switch (granularity) {
35342
- case "year_number":
35364
+ case "year":
35343
35365
  number = date.getFullYear();
35344
35366
  break;
35345
35367
  case "quarter_number":
@@ -35366,7 +35388,7 @@ function createDate(dimension, value, locale) {
35366
35388
  * This map is used to cache the different values of a pivot date value
35367
35389
  * 43_831 -> 01/01/2012
35368
35390
  * Example: {
35369
- * year_number: {
35391
+ * year: {
35370
35392
  * set: { 43_831 },
35371
35393
  * values: { '43_831': 2012 }
35372
35394
  * },
@@ -35393,7 +35415,7 @@ function createDate(dimension, value, locale) {
35393
35415
  * }
35394
35416
  */
35395
35417
  const MAP_VALUE_DIMENSION_DATE = {
35396
- year_number: {
35418
+ year: {
35397
35419
  set: new Set(),
35398
35420
  values: {},
35399
35421
  },
@@ -35752,7 +35774,7 @@ pivotRegistry.add("SPREADSHEET", {
35752
35774
  externalData: false,
35753
35775
  onIterationEndEvaluation: (pivot) => pivot.markAsDirtyForEvaluation(),
35754
35776
  granularities: [
35755
- "year_number",
35777
+ "year",
35756
35778
  "quarter_number",
35757
35779
  "month_number",
35758
35780
  "iso_week_number",
@@ -54489,7 +54511,7 @@ class PivotUIPlugin extends UIPlugin {
54489
54511
  getPivotIdFromPosition(position) {
54490
54512
  const cell = this.getters.getCorrespondingFormulaCell(position);
54491
54513
  if (cell && cell.isFormula) {
54492
- const pivotFunction = this.getFirstPivotFunction(cell.compiledFormula.tokens);
54514
+ const pivotFunction = this.getFirstPivotFunction(position.sheetId, cell.compiledFormula.tokens);
54493
54515
  if (pivotFunction) {
54494
54516
  const pivotId = pivotFunction.args[0]?.toString();
54495
54517
  return pivotId && this.getters.getPivotId(pivotId);
@@ -54497,7 +54519,7 @@ class PivotUIPlugin extends UIPlugin {
54497
54519
  }
54498
54520
  return undefined;
54499
54521
  }
54500
- getFirstPivotFunction(tokens) {
54522
+ getFirstPivotFunction(sheetId, tokens) {
54501
54523
  const pivotFunction = getFirstPivotFunction(tokens);
54502
54524
  if (!pivotFunction) {
54503
54525
  return undefined;
@@ -54513,7 +54535,7 @@ class PivotUIPlugin extends UIPlugin {
54513
54535
  return argAst.value;
54514
54536
  }
54515
54537
  const argsString = astToFormula(argAst);
54516
- return this.getters.evaluateFormula(this.getters.getActiveSheetId(), argsString);
54538
+ return this.getters.evaluateFormula(sheetId, argsString);
54517
54539
  });
54518
54540
  return { functionName, args: evaluatedArgs };
54519
54541
  }
@@ -54536,7 +54558,7 @@ class PivotUIPlugin extends UIPlugin {
54536
54558
  return undefined;
54537
54559
  }
54538
54560
  const mainPosition = this.getters.getCellPosition(cell.id);
54539
- const result = this.getters.getFirstPivotFunction(cell.compiledFormula.tokens);
54561
+ const result = this.getters.getFirstPivotFunction(position.sheetId, cell.compiledFormula.tokens);
54540
54562
  if (!result) {
54541
54563
  return undefined;
54542
54564
  }
@@ -60669,7 +60691,7 @@ class BottomBarSheet extends owl.Component {
60669
60691
  this.DOMFocusableElementStore.focus();
60670
60692
  }
60671
60693
  }
60672
- onClickSheetName(ev) {
60694
+ onMouseEventSheetName(ev) {
60673
60695
  if (this.state.isEditing)
60674
60696
  ev.stopPropagation();
60675
60697
  }
@@ -66314,6 +66336,7 @@ class Model extends EventBus {
66314
66336
  const start = performance.now();
66315
66337
  console.group("Model creation");
66316
66338
  super();
66339
+ setDefaultTranslationMethod();
66317
66340
  stateUpdateMessages = repairInitialMessages(data, stateUpdateMessages);
66318
66341
  const workbookData = load(data, verboseImport);
66319
66342
  this.state = new StateObserver();
@@ -66990,6 +67013,6 @@ exports.tokenColors = tokenColors;
66990
67013
  exports.tokenize = tokenize;
66991
67014
 
66992
67015
 
66993
- __info__.version = "17.3.4";
66994
- __info__.date = "2024-06-21T20:00:08.515Z";
66995
- __info__.hash = "6efbf3b";
67016
+ __info__.version = "17.3.6";
67017
+ __info__.date = "2024-07-02T09:04:06.235Z";
67018
+ __info__.hash = "979c0b1";
@@ -499,7 +499,7 @@ interface SearchOptions {
499
499
  }
500
500
 
501
501
  type Aggregator = "array_agg" | "count" | "count_distinct" | "bool_and" | "bool_or" | "max" | "min" | "avg" | "sum";
502
- type Granularity = "day" | "week" | "month" | "quarter" | "year" | "day_of_month" | "iso_week_number" | "month_number" | "quarter_number" | "year_number";
502
+ type Granularity = "day" | "week" | "month" | "quarter" | "year" | "day_of_month" | "iso_week_number" | "month_number" | "quarter_number";
503
503
  interface PivotCoreDimension {
504
504
  name: string;
505
505
  order?: "asc" | "desc";
@@ -4255,7 +4255,7 @@ declare class PivotUIPlugin extends UIPlugin {
4255
4255
  * is no pivot at this position
4256
4256
  */
4257
4257
  getPivotIdFromPosition(position: CellPosition): "" | UID | undefined;
4258
- getFirstPivotFunction(tokens: Token[]): {
4258
+ getFirstPivotFunction(sheetId: UID, tokens: Token[]): {
4259
4259
  functionName: string;
4260
4260
  args: (CellValue | Matrix<CellValue> | undefined)[];
4261
4261
  } | undefined;
@@ -8899,6 +8899,7 @@ declare class FindAndReplaceStore extends SpreadsheetStore implements HighlightP
8899
8899
  private currentSearchRegex;
8900
8900
  private isSearchDirty;
8901
8901
  private initialShowFormulaState;
8902
+ private preserveSelectedMatchIndex;
8902
8903
  selectedMatchIndex: number | null;
8903
8904
  toSearch: string;
8904
8905
  toReplace: string;
@@ -9048,7 +9049,6 @@ declare class PivotDimensionGranularity extends Component<Props$e, SpreadsheetCh
9048
9049
  month: string;
9049
9050
  week: string;
9050
9051
  day: string;
9051
- year_number: string;
9052
9052
  quarter_number: string;
9053
9053
  month_number: string;
9054
9054
  iso_week_number: string;
@@ -9432,7 +9432,7 @@ declare class BottomBarSheet extends Component<Props$b, SpreadsheetChildEnv> {
9432
9432
  private activateSheet;
9433
9433
  onDblClick(): void;
9434
9434
  onKeyDown(ev: KeyboardEvent): void;
9435
- onClickSheetName(ev: MouseEvent): void;
9435
+ onMouseEventSheetName(ev: MouseEvent): void;
9436
9436
  private startEdition;
9437
9437
  private stopEdition;
9438
9438
  private cancelEdition;
@@ -10180,7 +10180,8 @@ type SprintfValues = (string | String | number)[] | [{
10180
10180
  }];
10181
10181
  type TranslationFunction = (string: string, ...values: SprintfValues) => string;
10182
10182
  /***
10183
- * Allow to inject a translation function from outside o-spreadsheet.
10183
+ * Allow to inject a translation function from outside o-spreadsheet. This should be called before instantiating
10184
+ * a model.
10184
10185
  * @param tfn the function that will do the translation
10185
10186
  * @param loaded a function that returns true when the translation is loaded
10186
10187
  */
@@ -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.3.4
7
- * @date 2024-06-21T20:00:08.515Z
8
- * @hash 6efbf3b
6
+ * @version 17.3.6
7
+ * @date 2024-07-02T09:04:06.235Z
8
+ * @hash 979c0b1
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, toRaw } from '@odoo/owl';
@@ -1896,9 +1896,10 @@ function percentile(values, percent, isInclusive) {
1896
1896
  sortedValues[indexLow] * (indexSup - percentIndex));
1897
1897
  }
1898
1898
 
1899
- // define a mock translation function, when o-spreadsheet runs in standalone it doesn't translate any string
1900
- let _translate = (s) => s;
1901
- let _loaded = () => false;
1899
+ const defaultTranslate = (s) => s;
1900
+ const defaultLoaded = () => false;
1901
+ let _translate = defaultTranslate;
1902
+ let _loaded = defaultLoaded;
1902
1903
  function sprintf(s, ...values) {
1903
1904
  if (values.length === 1 && typeof values[0] === "object" && !(values[0] instanceof String)) {
1904
1905
  const valuesDict = values[0];
@@ -1910,7 +1911,8 @@ function sprintf(s, ...values) {
1910
1911
  return s;
1911
1912
  }
1912
1913
  /***
1913
- * Allow to inject a translation function from outside o-spreadsheet.
1914
+ * Allow to inject a translation function from outside o-spreadsheet. This should be called before instantiating
1915
+ * a model.
1914
1916
  * @param tfn the function that will do the translation
1915
1917
  * @param loaded a function that returns true when the translation is loaded
1916
1918
  */
@@ -1918,6 +1920,18 @@ function setTranslationMethod(tfn, loaded = () => true) {
1918
1920
  _translate = tfn;
1919
1921
  _loaded = loaded;
1920
1922
  }
1923
+ /**
1924
+ * If no translation function has been set, this will mark the translation are loaded.
1925
+ *
1926
+ * By default, the translations should not be set as loaded, otherwise top-level translated constants will never be
1927
+ * translated. But if by the time the model is instantiated no custom translation function has been set, we can set
1928
+ * the default translation function as loaded so o-spreadsheet can be run in standalone with no translations.
1929
+ */
1930
+ function setDefaultTranslationMethod() {
1931
+ if (_translate === defaultTranslate && _loaded === defaultLoaded) {
1932
+ _loaded = () => true;
1933
+ }
1934
+ }
1921
1935
  const _t = function (s, ...values) {
1922
1936
  if (!_loaded()) {
1923
1937
  return new LazyTranslatedString(s, values);
@@ -21673,7 +21687,6 @@ const ALL_PERIODS = {
21673
21687
  month: _t("Month"),
21674
21688
  week: _t("Week"),
21675
21689
  day: _t("Day"),
21676
- year_number: _t("Year"),
21677
21690
  quarter_number: _t("Quarter"),
21678
21691
  month_number: _t("Month"),
21679
21692
  iso_week_number: _t("Week"),
@@ -34061,6 +34074,7 @@ class FindAndReplaceStore extends SpreadsheetStore {
34061
34074
  currentSearchRegex = null;
34062
34075
  isSearchDirty = false;
34063
34076
  initialShowFormulaState;
34077
+ preserveSelectedMatchIndex = false;
34064
34078
  // fixme: why do we make selectedMatchIndex on top of a selected
34065
34079
  // property in the matches?
34066
34080
  selectedMatchIndex = null;
@@ -34170,7 +34184,9 @@ class FindAndReplaceStore extends SpreadsheetStore {
34170
34184
  * refresh the matches according to the current search options
34171
34185
  */
34172
34186
  refreshSearch(jumpToMatchSheet = true) {
34173
- this.selectedMatchIndex = null;
34187
+ if (!this.preserveSelectedMatchIndex) {
34188
+ this.selectedMatchIndex = null;
34189
+ }
34174
34190
  this.findMatches();
34175
34191
  this.selectNextCell(Direction.current, jumpToMatchSheet);
34176
34192
  }
@@ -34269,10 +34285,16 @@ class FindAndReplaceStore extends SpreadsheetStore {
34269
34285
  const selectedMatch = matches[nextIndex];
34270
34286
  // Switch to the sheet where the match is located
34271
34287
  if (jumpToMatchSheet && this.getters.getActiveSheetId() !== selectedMatch.sheetId) {
34288
+ // We set `preserveSelectedMatchIndex` to true to avoid resetting the selected search
34289
+ // index in the `refreshSearch` function when a new sheet is activated. The reason being
34290
+ // that, when we automatically go back to previous sheet while performing a search, the
34291
+ // search index is reset to the first occurrence each time.
34292
+ this.preserveSelectedMatchIndex = true;
34272
34293
  this.model.dispatch("ACTIVATE_SHEET", {
34273
34294
  sheetIdFrom: this.getters.getActiveSheetId(),
34274
34295
  sheetIdTo: selectedMatch.sheetId,
34275
34296
  });
34297
+ this.preserveSelectedMatchIndex = false;
34276
34298
  // We do not want to reset the selection at finalize in this case
34277
34299
  this.isSearchDirty = false;
34278
34300
  }
@@ -35337,7 +35359,7 @@ function createDate(dimension, value, locale) {
35337
35359
  const date = toJsDate(value, locale);
35338
35360
  let number = 0;
35339
35361
  switch (granularity) {
35340
- case "year_number":
35362
+ case "year":
35341
35363
  number = date.getFullYear();
35342
35364
  break;
35343
35365
  case "quarter_number":
@@ -35364,7 +35386,7 @@ function createDate(dimension, value, locale) {
35364
35386
  * This map is used to cache the different values of a pivot date value
35365
35387
  * 43_831 -> 01/01/2012
35366
35388
  * Example: {
35367
- * year_number: {
35389
+ * year: {
35368
35390
  * set: { 43_831 },
35369
35391
  * values: { '43_831': 2012 }
35370
35392
  * },
@@ -35391,7 +35413,7 @@ function createDate(dimension, value, locale) {
35391
35413
  * }
35392
35414
  */
35393
35415
  const MAP_VALUE_DIMENSION_DATE = {
35394
- year_number: {
35416
+ year: {
35395
35417
  set: new Set(),
35396
35418
  values: {},
35397
35419
  },
@@ -35750,7 +35772,7 @@ pivotRegistry.add("SPREADSHEET", {
35750
35772
  externalData: false,
35751
35773
  onIterationEndEvaluation: (pivot) => pivot.markAsDirtyForEvaluation(),
35752
35774
  granularities: [
35753
- "year_number",
35775
+ "year",
35754
35776
  "quarter_number",
35755
35777
  "month_number",
35756
35778
  "iso_week_number",
@@ -54487,7 +54509,7 @@ class PivotUIPlugin extends UIPlugin {
54487
54509
  getPivotIdFromPosition(position) {
54488
54510
  const cell = this.getters.getCorrespondingFormulaCell(position);
54489
54511
  if (cell && cell.isFormula) {
54490
- const pivotFunction = this.getFirstPivotFunction(cell.compiledFormula.tokens);
54512
+ const pivotFunction = this.getFirstPivotFunction(position.sheetId, cell.compiledFormula.tokens);
54491
54513
  if (pivotFunction) {
54492
54514
  const pivotId = pivotFunction.args[0]?.toString();
54493
54515
  return pivotId && this.getters.getPivotId(pivotId);
@@ -54495,7 +54517,7 @@ class PivotUIPlugin extends UIPlugin {
54495
54517
  }
54496
54518
  return undefined;
54497
54519
  }
54498
- getFirstPivotFunction(tokens) {
54520
+ getFirstPivotFunction(sheetId, tokens) {
54499
54521
  const pivotFunction = getFirstPivotFunction(tokens);
54500
54522
  if (!pivotFunction) {
54501
54523
  return undefined;
@@ -54511,7 +54533,7 @@ class PivotUIPlugin extends UIPlugin {
54511
54533
  return argAst.value;
54512
54534
  }
54513
54535
  const argsString = astToFormula(argAst);
54514
- return this.getters.evaluateFormula(this.getters.getActiveSheetId(), argsString);
54536
+ return this.getters.evaluateFormula(sheetId, argsString);
54515
54537
  });
54516
54538
  return { functionName, args: evaluatedArgs };
54517
54539
  }
@@ -54534,7 +54556,7 @@ class PivotUIPlugin extends UIPlugin {
54534
54556
  return undefined;
54535
54557
  }
54536
54558
  const mainPosition = this.getters.getCellPosition(cell.id);
54537
- const result = this.getters.getFirstPivotFunction(cell.compiledFormula.tokens);
54559
+ const result = this.getters.getFirstPivotFunction(position.sheetId, cell.compiledFormula.tokens);
54538
54560
  if (!result) {
54539
54561
  return undefined;
54540
54562
  }
@@ -60667,7 +60689,7 @@ class BottomBarSheet extends Component {
60667
60689
  this.DOMFocusableElementStore.focus();
60668
60690
  }
60669
60691
  }
60670
- onClickSheetName(ev) {
60692
+ onMouseEventSheetName(ev) {
60671
60693
  if (this.state.isEditing)
60672
60694
  ev.stopPropagation();
60673
60695
  }
@@ -66312,6 +66334,7 @@ class Model extends EventBus {
66312
66334
  const start = performance.now();
66313
66335
  console.group("Model creation");
66314
66336
  super();
66337
+ setDefaultTranslationMethod();
66315
66338
  stateUpdateMessages = repairInitialMessages(data, stateUpdateMessages);
66316
66339
  const workbookData = load(data, verboseImport);
66317
66340
  this.state = new StateObserver();
@@ -66945,6 +66968,6 @@ const constants = {
66945
66968
  export { AbstractCellClipboardHandler, AbstractChart, AbstractFigureClipboardHandler, CellErrorType, CommandResult, CorePlugin, DispatchResult, EvaluationError, Model, PivotRuntimeDefinition, Registry, Revision, SPREADSHEET_DIMENSIONS, Spreadsheet, SpreadsheetPivotTable, 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 };
66946
66969
 
66947
66970
 
66948
- __info__.version = "17.3.4";
66949
- __info__.date = "2024-06-21T20:00:08.515Z";
66950
- __info__.hash = "6efbf3b";
66971
+ __info__.version = "17.3.6";
66972
+ __info__.date = "2024-07-02T09:04:06.235Z";
66973
+ __info__.hash = "979c0b1";
@@ -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.3.4
7
- * @date 2024-06-21T20:00:08.515Z
8
- * @hash 6efbf3b
6
+ * @version 17.3.6
7
+ * @date 2024-07-02T09:04:06.235Z
8
+ * @hash 979c0b1
9
9
  */
10
10
 
11
11
  (function (exports, owl) {
@@ -1897,9 +1897,10 @@
1897
1897
  sortedValues[indexLow] * (indexSup - percentIndex));
1898
1898
  }
1899
1899
 
1900
- // define a mock translation function, when o-spreadsheet runs in standalone it doesn't translate any string
1901
- let _translate = (s) => s;
1902
- let _loaded = () => false;
1900
+ const defaultTranslate = (s) => s;
1901
+ const defaultLoaded = () => false;
1902
+ let _translate = defaultTranslate;
1903
+ let _loaded = defaultLoaded;
1903
1904
  function sprintf(s, ...values) {
1904
1905
  if (values.length === 1 && typeof values[0] === "object" && !(values[0] instanceof String)) {
1905
1906
  const valuesDict = values[0];
@@ -1911,7 +1912,8 @@
1911
1912
  return s;
1912
1913
  }
1913
1914
  /***
1914
- * Allow to inject a translation function from outside o-spreadsheet.
1915
+ * Allow to inject a translation function from outside o-spreadsheet. This should be called before instantiating
1916
+ * a model.
1915
1917
  * @param tfn the function that will do the translation
1916
1918
  * @param loaded a function that returns true when the translation is loaded
1917
1919
  */
@@ -1919,6 +1921,18 @@
1919
1921
  _translate = tfn;
1920
1922
  _loaded = loaded;
1921
1923
  }
1924
+ /**
1925
+ * If no translation function has been set, this will mark the translation are loaded.
1926
+ *
1927
+ * By default, the translations should not be set as loaded, otherwise top-level translated constants will never be
1928
+ * translated. But if by the time the model is instantiated no custom translation function has been set, we can set
1929
+ * the default translation function as loaded so o-spreadsheet can be run in standalone with no translations.
1930
+ */
1931
+ function setDefaultTranslationMethod() {
1932
+ if (_translate === defaultTranslate && _loaded === defaultLoaded) {
1933
+ _loaded = () => true;
1934
+ }
1935
+ }
1922
1936
  const _t = function (s, ...values) {
1923
1937
  if (!_loaded()) {
1924
1938
  return new LazyTranslatedString(s, values);
@@ -21674,7 +21688,6 @@ stores.inject(MyMetaStore, storeInstance);
21674
21688
  month: _t("Month"),
21675
21689
  week: _t("Week"),
21676
21690
  day: _t("Day"),
21677
- year_number: _t("Year"),
21678
21691
  quarter_number: _t("Quarter"),
21679
21692
  month_number: _t("Month"),
21680
21693
  iso_week_number: _t("Week"),
@@ -34062,6 +34075,7 @@ stores.inject(MyMetaStore, storeInstance);
34062
34075
  currentSearchRegex = null;
34063
34076
  isSearchDirty = false;
34064
34077
  initialShowFormulaState;
34078
+ preserveSelectedMatchIndex = false;
34065
34079
  // fixme: why do we make selectedMatchIndex on top of a selected
34066
34080
  // property in the matches?
34067
34081
  selectedMatchIndex = null;
@@ -34171,7 +34185,9 @@ stores.inject(MyMetaStore, storeInstance);
34171
34185
  * refresh the matches according to the current search options
34172
34186
  */
34173
34187
  refreshSearch(jumpToMatchSheet = true) {
34174
- this.selectedMatchIndex = null;
34188
+ if (!this.preserveSelectedMatchIndex) {
34189
+ this.selectedMatchIndex = null;
34190
+ }
34175
34191
  this.findMatches();
34176
34192
  this.selectNextCell(Direction.current, jumpToMatchSheet);
34177
34193
  }
@@ -34270,10 +34286,16 @@ stores.inject(MyMetaStore, storeInstance);
34270
34286
  const selectedMatch = matches[nextIndex];
34271
34287
  // Switch to the sheet where the match is located
34272
34288
  if (jumpToMatchSheet && this.getters.getActiveSheetId() !== selectedMatch.sheetId) {
34289
+ // We set `preserveSelectedMatchIndex` to true to avoid resetting the selected search
34290
+ // index in the `refreshSearch` function when a new sheet is activated. The reason being
34291
+ // that, when we automatically go back to previous sheet while performing a search, the
34292
+ // search index is reset to the first occurrence each time.
34293
+ this.preserveSelectedMatchIndex = true;
34273
34294
  this.model.dispatch("ACTIVATE_SHEET", {
34274
34295
  sheetIdFrom: this.getters.getActiveSheetId(),
34275
34296
  sheetIdTo: selectedMatch.sheetId,
34276
34297
  });
34298
+ this.preserveSelectedMatchIndex = false;
34277
34299
  // We do not want to reset the selection at finalize in this case
34278
34300
  this.isSearchDirty = false;
34279
34301
  }
@@ -35338,7 +35360,7 @@ stores.inject(MyMetaStore, storeInstance);
35338
35360
  const date = toJsDate(value, locale);
35339
35361
  let number = 0;
35340
35362
  switch (granularity) {
35341
- case "year_number":
35363
+ case "year":
35342
35364
  number = date.getFullYear();
35343
35365
  break;
35344
35366
  case "quarter_number":
@@ -35365,7 +35387,7 @@ stores.inject(MyMetaStore, storeInstance);
35365
35387
  * This map is used to cache the different values of a pivot date value
35366
35388
  * 43_831 -> 01/01/2012
35367
35389
  * Example: {
35368
- * year_number: {
35390
+ * year: {
35369
35391
  * set: { 43_831 },
35370
35392
  * values: { '43_831': 2012 }
35371
35393
  * },
@@ -35392,7 +35414,7 @@ stores.inject(MyMetaStore, storeInstance);
35392
35414
  * }
35393
35415
  */
35394
35416
  const MAP_VALUE_DIMENSION_DATE = {
35395
- year_number: {
35417
+ year: {
35396
35418
  set: new Set(),
35397
35419
  values: {},
35398
35420
  },
@@ -35751,7 +35773,7 @@ stores.inject(MyMetaStore, storeInstance);
35751
35773
  externalData: false,
35752
35774
  onIterationEndEvaluation: (pivot) => pivot.markAsDirtyForEvaluation(),
35753
35775
  granularities: [
35754
- "year_number",
35776
+ "year",
35755
35777
  "quarter_number",
35756
35778
  "month_number",
35757
35779
  "iso_week_number",
@@ -54488,7 +54510,7 @@ stores.inject(MyMetaStore, storeInstance);
54488
54510
  getPivotIdFromPosition(position) {
54489
54511
  const cell = this.getters.getCorrespondingFormulaCell(position);
54490
54512
  if (cell && cell.isFormula) {
54491
- const pivotFunction = this.getFirstPivotFunction(cell.compiledFormula.tokens);
54513
+ const pivotFunction = this.getFirstPivotFunction(position.sheetId, cell.compiledFormula.tokens);
54492
54514
  if (pivotFunction) {
54493
54515
  const pivotId = pivotFunction.args[0]?.toString();
54494
54516
  return pivotId && this.getters.getPivotId(pivotId);
@@ -54496,7 +54518,7 @@ stores.inject(MyMetaStore, storeInstance);
54496
54518
  }
54497
54519
  return undefined;
54498
54520
  }
54499
- getFirstPivotFunction(tokens) {
54521
+ getFirstPivotFunction(sheetId, tokens) {
54500
54522
  const pivotFunction = getFirstPivotFunction(tokens);
54501
54523
  if (!pivotFunction) {
54502
54524
  return undefined;
@@ -54512,7 +54534,7 @@ stores.inject(MyMetaStore, storeInstance);
54512
54534
  return argAst.value;
54513
54535
  }
54514
54536
  const argsString = astToFormula(argAst);
54515
- return this.getters.evaluateFormula(this.getters.getActiveSheetId(), argsString);
54537
+ return this.getters.evaluateFormula(sheetId, argsString);
54516
54538
  });
54517
54539
  return { functionName, args: evaluatedArgs };
54518
54540
  }
@@ -54535,7 +54557,7 @@ stores.inject(MyMetaStore, storeInstance);
54535
54557
  return undefined;
54536
54558
  }
54537
54559
  const mainPosition = this.getters.getCellPosition(cell.id);
54538
- const result = this.getters.getFirstPivotFunction(cell.compiledFormula.tokens);
54560
+ const result = this.getters.getFirstPivotFunction(position.sheetId, cell.compiledFormula.tokens);
54539
54561
  if (!result) {
54540
54562
  return undefined;
54541
54563
  }
@@ -60668,7 +60690,7 @@ stores.inject(MyMetaStore, storeInstance);
60668
60690
  this.DOMFocusableElementStore.focus();
60669
60691
  }
60670
60692
  }
60671
- onClickSheetName(ev) {
60693
+ onMouseEventSheetName(ev) {
60672
60694
  if (this.state.isEditing)
60673
60695
  ev.stopPropagation();
60674
60696
  }
@@ -66313,6 +66335,7 @@ stores.inject(MyMetaStore, storeInstance);
66313
66335
  const start = performance.now();
66314
66336
  console.group("Model creation");
66315
66337
  super();
66338
+ setDefaultTranslationMethod();
66316
66339
  stateUpdateMessages = repairInitialMessages(data, stateUpdateMessages);
66317
66340
  const workbookData = load(data, verboseImport);
66318
66341
  this.state = new StateObserver();
@@ -66989,9 +67012,9 @@ stores.inject(MyMetaStore, storeInstance);
66989
67012
  exports.tokenize = tokenize;
66990
67013
 
66991
67014
 
66992
- __info__.version = "17.3.4";
66993
- __info__.date = "2024-06-21T20:00:08.515Z";
66994
- __info__.hash = "6efbf3b";
67015
+ __info__.version = "17.3.6";
67016
+ __info__.date = "2024-07-02T09:04:06.235Z";
67017
+ __info__.hash = "979c0b1";
66995
67018
 
66996
67019
 
66997
67020
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);