@odoo/o-spreadsheet 17.1.18 → 17.1.20

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.18
6
- * @date 2024-06-10T09:34:55.045Z
7
- * @hash 0e756ce
5
+ * @version 17.1.20
6
+ * @date 2024-07-02T09:03:04.534Z
7
+ * @hash d15aaf3
8
8
  */
9
9
 
10
10
  'use strict';
@@ -1770,9 +1770,10 @@ function percentile(values, percent, isInclusive) {
1770
1770
  sortedValues[indexLow] * (indexSup - percentIndex));
1771
1771
  }
1772
1772
 
1773
- // define a mock translation function, when o-spreadsheet runs in standalone it doesn't translate any string
1774
- let _translate = (s) => s;
1775
- let _loaded = () => false;
1773
+ const defaultTranslate = (s) => s;
1774
+ const defaultLoaded = () => false;
1775
+ let _translate = defaultTranslate;
1776
+ let _loaded = defaultLoaded;
1776
1777
  function sprintf(s, ...values) {
1777
1778
  if (values.length === 1 && typeof values[0] === "object" && !(values[0] instanceof String)) {
1778
1779
  const valuesDict = values[0];
@@ -1784,7 +1785,8 @@ function sprintf(s, ...values) {
1784
1785
  return s;
1785
1786
  }
1786
1787
  /***
1787
- * Allow to inject a translation function from outside o-spreadsheet.
1788
+ * Allow to inject a translation function from outside o-spreadsheet. This should be called before instantiating
1789
+ * a model.
1788
1790
  * @param tfn the function that will do the translation
1789
1791
  * @param loaded a function that returns true when the translation is loaded
1790
1792
  */
@@ -1792,6 +1794,18 @@ function setTranslationMethod(tfn, loaded = () => true) {
1792
1794
  _translate = tfn;
1793
1795
  _loaded = loaded;
1794
1796
  }
1797
+ /**
1798
+ * If no translation function has been set, this will mark the translation are loaded.
1799
+ *
1800
+ * By default, the translations should not be set as loaded, otherwise top-level translated constants will never be
1801
+ * translated. But if by the time the model is instantiated no custom translation function has been set, we can set
1802
+ * the default translation function as loaded so o-spreadsheet can be run in standalone with no translations.
1803
+ */
1804
+ function setDefaultTranslationMethod() {
1805
+ if (_translate === defaultTranslate && _loaded === defaultLoaded) {
1806
+ _loaded = () => true;
1807
+ }
1808
+ }
1795
1809
  const _t = function (s, ...values) {
1796
1810
  if (!_loaded()) {
1797
1811
  return new LazyTranslatedString(s, values);
@@ -6995,7 +7009,7 @@ class Popover extends owl.Component {
6995
7009
  if (!anchor)
6996
7010
  return;
6997
7011
  const propsMaxSize = { width: this.props.maxWidth, height: this.props.maxHeight };
6998
- const elDims = {
7012
+ let elDims = {
6999
7013
  width: el.getBoundingClientRect().width,
7000
7014
  height: el.getBoundingClientRect().height,
7001
7015
  };
@@ -7003,7 +7017,14 @@ class Popover extends owl.Component {
7003
7017
  const popoverPositionHelper = this.props.positioning === "BottomLeft"
7004
7018
  ? new BottomLeftPopoverContext(anchor, this.containerRect, propsMaxSize, spreadsheetRect)
7005
7019
  : new TopRightPopoverContext(anchor, this.containerRect, propsMaxSize, spreadsheetRect);
7006
- const style = popoverPositionHelper.getCss(elDims, this.props.verticalOffset);
7020
+ el.style["max-height"] = popoverPositionHelper.getMaxHeight(elDims.height) + "px";
7021
+ el.style["max-width"] = popoverPositionHelper.getMaxWidth(elDims.width) + "px";
7022
+ // Re-compute the dimensions after setting the max-width and max-height
7023
+ elDims = {
7024
+ width: el.getBoundingClientRect().width,
7025
+ height: el.getBoundingClientRect().height,
7026
+ };
7027
+ let style = popoverPositionHelper.getCss(elDims, this.props.verticalOffset);
7007
7028
  for (const property of Object.keys(style)) {
7008
7029
  el.style[property] = style[property];
7009
7030
  }
@@ -7066,8 +7087,6 @@ class PopoverPositionContext {
7066
7087
  const shouldRenderAtRight = this.shouldRenderAtRight(elDims.width);
7067
7088
  verticalOffset = shouldRenderAtBottom ? verticalOffset : -verticalOffset;
7068
7089
  const cssProperties = {
7069
- "max-height": maxHeight + "px",
7070
- "max-width": maxWidth + "px",
7071
7090
  top: this.getTopCoordinate(actualHeight, shouldRenderAtBottom) -
7072
7091
  this.spreadsheetOffset.y -
7073
7092
  verticalOffset +
@@ -25473,13 +25492,17 @@ class SelectMenu extends owl.Component {
25473
25492
  class: { type: String, optional: true },
25474
25493
  };
25475
25494
  static components = { Menu };
25495
+ menuId = new UuidGenerator().uuidv4();
25476
25496
  selectRef = owl.useRef("select");
25477
25497
  selectRect = useAbsoluteBoundingRect(this.selectRef);
25478
25498
  state = owl.useState({
25479
25499
  isMenuOpen: false,
25480
25500
  });
25481
- onClick() {
25482
- this.state.isMenuOpen = true;
25501
+ onClick(ev) {
25502
+ if (ev.closedMenuId === this.menuId) {
25503
+ return;
25504
+ }
25505
+ this.state.isMenuOpen = !this.state.isMenuOpen;
25483
25506
  }
25484
25507
  onMenuClosed() {
25485
25508
  this.state.isMenuOpen = false;
@@ -25487,7 +25510,7 @@ class SelectMenu extends owl.Component {
25487
25510
  get menuPosition() {
25488
25511
  return {
25489
25512
  x: this.selectRect.x,
25490
- y: this.selectRect.y,
25513
+ y: this.selectRect.y + this.selectRect.height,
25491
25514
  };
25492
25515
  }
25493
25516
  }
@@ -28525,7 +28548,7 @@ class FiguresContainer extends owl.Component {
28525
28548
  });
28526
28549
  }
28527
28550
  getContainerRect(container) {
28528
- const { width: viewWidth, height: viewHeight } = this.env.model.getters.getMainViewportRect();
28551
+ const { width: viewWidth, height: viewHeight } = this.env.model.getters.getSheetViewDimension();
28529
28552
  const { x: viewportX, y: viewportY } = this.env.model.getters.getMainViewportCoordinates();
28530
28553
  const x = ["bottomRight", "topRight"].includes(container) ? viewportX : 0;
28531
28554
  const width = viewWidth - x;
@@ -44798,7 +44821,10 @@ class Session extends EventBus {
44798
44821
  /**
44799
44822
  * Notify the server that the user client left the collaborative session
44800
44823
  */
44801
- leave() {
44824
+ leave(data) {
44825
+ if (Object.keys(this.clients).length === 1 && this.processedRevisions.size) {
44826
+ this.snapshot(data);
44827
+ }
44802
44828
  delete this.clients[this.clientId];
44803
44829
  this.transportService.leave(this.clientId);
44804
44830
  this.transportService.sendMessage({
@@ -44811,6 +44837,9 @@ class Session extends EventBus {
44811
44837
  * Send a snapshot of the spreadsheet to the collaboration server
44812
44838
  */
44813
44839
  snapshot(data) {
44840
+ if (this.pendingMessages.length !== 0) {
44841
+ return;
44842
+ }
44814
44843
  const snapshotId = this.uuidGenerator.uuidv4();
44815
44844
  this.transportService.sendMessage({
44816
44845
  type: "SNAPSHOT",
@@ -49510,10 +49539,8 @@ class EditionPlugin extends UIPlugin {
49510
49539
  const refRange = this.getters.getRangeFromSheetXC(activeSheetId, xc);
49511
49540
  return isEqual(this.getters.expandZone(activeSheetId, refRange.zone), oldZone);
49512
49541
  });
49513
- // this function assumes that the previous range is always found because
49514
- // it's called when changing a highlight, which exists by definition
49515
49542
  if (!previousRefToken) {
49516
- throw new Error("Previous range not found");
49543
+ return;
49517
49544
  }
49518
49545
  const previousRange = this.getters.getRangeFromSheetXC(activeSheetId, previousRefToken.value);
49519
49546
  this.selectionStart = previousRefToken.start;
@@ -52051,7 +52078,7 @@ class BottomBarSheet extends owl.Component {
52051
52078
  this.env.focusableElement.focus();
52052
52079
  }
52053
52080
  }
52054
- onClickSheetName(ev) {
52081
+ onMouseEventSheetName(ev) {
52055
52082
  if (this.state.isEditing)
52056
52083
  ev.stopPropagation();
52057
52084
  }
@@ -57191,6 +57218,7 @@ class Model extends EventBus {
57191
57218
  coreHandlers = [];
57192
57219
  constructor(data = {}, config = {}, stateUpdateMessages = [], uuidGenerator = new UuidGenerator(), verboseImport = true) {
57193
57220
  super();
57221
+ setDefaultTranslationMethod();
57194
57222
  stateUpdateMessages = repairInitialMessages(data, stateUpdateMessages);
57195
57223
  const workbookData = load(data, verboseImport);
57196
57224
  this.state = new StateObserver();
@@ -57266,7 +57294,7 @@ class Model extends EventBus {
57266
57294
  this.session.join(this.config.client);
57267
57295
  }
57268
57296
  leaveSession() {
57269
- this.session.leave();
57297
+ this.session.leave(this.exportData());
57270
57298
  }
57271
57299
  setupUiPlugin(Plugin) {
57272
57300
  const plugin = new Plugin(this.uiPluginConfig);
@@ -57690,6 +57718,7 @@ const helpers = {
57690
57718
  createAction,
57691
57719
  createActions,
57692
57720
  transformRangeData,
57721
+ deepEquals,
57693
57722
  };
57694
57723
  const links = {
57695
57724
  isMarkdownLink,
@@ -57777,6 +57806,6 @@ exports.setTranslationMethod = setTranslationMethod;
57777
57806
  exports.tokenize = tokenize;
57778
57807
 
57779
57808
 
57780
- __info__.version = "17.1.18";
57781
- __info__.date = "2024-06-10T09:34:55.045Z";
57782
- __info__.hash = "0e756ce";
57809
+ __info__.version = "17.1.20";
57810
+ __info__.date = "2024-07-02T09:03:04.534Z";
57811
+ __info__.hash = "d15aaf3";
@@ -841,7 +841,7 @@ declare class Session extends EventBus<CollaborativeEvent> {
841
841
  /**
842
842
  * Notify the server that the user client left the collaborative session
843
843
  */
844
- leave(): void;
844
+ leave(data: WorkbookData): void;
845
845
  /**
846
846
  * Send a snapshot of the spreadsheet to the collaboration server
847
847
  */
@@ -982,6 +982,10 @@ declare function isDefined<T>(argument: T | undefined): argument is T;
982
982
  * Lazy value computed by the provided function.
983
983
  */
984
984
  declare function lazy<T>(fn: (() => T) | T): Lazy<T>;
985
+ /**
986
+ * Compares two objects.
987
+ */
988
+ declare function deepEquals(o1: any, o2: any, ignoreFunctions?: "ignoreFunctions"): boolean;
985
989
 
986
990
  interface ConstructorArgs {
987
991
  readonly zone: Readonly<Zone | UnboundedZone>;
@@ -6621,7 +6625,7 @@ declare class BottomBarSheet extends Component<Props$v, SpreadsheetChildEnv> {
6621
6625
  private activateSheet;
6622
6626
  onDblClick(): void;
6623
6627
  onKeyDown(ev: KeyboardEvent): void;
6624
- onClickSheetName(ev: MouseEvent): void;
6628
+ onMouseEventSheetName(ev: MouseEvent): void;
6625
6629
  private startEdition;
6626
6630
  private stopEdition;
6627
6631
  private cancelEdition;
@@ -8563,7 +8567,8 @@ type SprintfValues = (string | String | number)[] | [{
8563
8567
  }];
8564
8568
  type TranslationFunction = (string: string, ...values: SprintfValues) => string;
8565
8569
  /***
8566
- * Allow to inject a translation function from outside o-spreadsheet.
8570
+ * Allow to inject a translation function from outside o-spreadsheet. This should be called before instantiating
8571
+ * a model.
8567
8572
  * @param tfn the function that will do the translation
8568
8573
  * @param loaded a function that returns true when the translation is loaded
8569
8574
  */
@@ -8691,6 +8696,7 @@ declare const helpers: {
8691
8696
  createAction: typeof createAction;
8692
8697
  createActions: typeof createActions;
8693
8698
  transformRangeData: typeof transformRangeData;
8699
+ deepEquals: typeof deepEquals;
8694
8700
  };
8695
8701
  declare const links: {
8696
8702
  isMarkdownLink: typeof isMarkdownLink;
@@ -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.18
6
- * @date 2024-06-10T09:34:55.045Z
7
- * @hash 0e756ce
5
+ * @version 17.1.20
6
+ * @date 2024-07-02T09:03:04.534Z
7
+ * @hash d15aaf3
8
8
  */
9
9
 
10
10
  import { Component, useRef, onMounted, onWillUnmount, useEffect, onWillPatch, useState, onWillUpdateProps, onPatched, useComponent, useExternalListener, onWillStart, xml, useChildSubEnv, useSubEnv, markRaw } from '@odoo/owl';
@@ -1768,9 +1768,10 @@ function percentile(values, percent, isInclusive) {
1768
1768
  sortedValues[indexLow] * (indexSup - percentIndex));
1769
1769
  }
1770
1770
 
1771
- // define a mock translation function, when o-spreadsheet runs in standalone it doesn't translate any string
1772
- let _translate = (s) => s;
1773
- let _loaded = () => false;
1771
+ const defaultTranslate = (s) => s;
1772
+ const defaultLoaded = () => false;
1773
+ let _translate = defaultTranslate;
1774
+ let _loaded = defaultLoaded;
1774
1775
  function sprintf(s, ...values) {
1775
1776
  if (values.length === 1 && typeof values[0] === "object" && !(values[0] instanceof String)) {
1776
1777
  const valuesDict = values[0];
@@ -1782,7 +1783,8 @@ function sprintf(s, ...values) {
1782
1783
  return s;
1783
1784
  }
1784
1785
  /***
1785
- * Allow to inject a translation function from outside o-spreadsheet.
1786
+ * Allow to inject a translation function from outside o-spreadsheet. This should be called before instantiating
1787
+ * a model.
1786
1788
  * @param tfn the function that will do the translation
1787
1789
  * @param loaded a function that returns true when the translation is loaded
1788
1790
  */
@@ -1790,6 +1792,18 @@ function setTranslationMethod(tfn, loaded = () => true) {
1790
1792
  _translate = tfn;
1791
1793
  _loaded = loaded;
1792
1794
  }
1795
+ /**
1796
+ * If no translation function has been set, this will mark the translation are loaded.
1797
+ *
1798
+ * By default, the translations should not be set as loaded, otherwise top-level translated constants will never be
1799
+ * translated. But if by the time the model is instantiated no custom translation function has been set, we can set
1800
+ * the default translation function as loaded so o-spreadsheet can be run in standalone with no translations.
1801
+ */
1802
+ function setDefaultTranslationMethod() {
1803
+ if (_translate === defaultTranslate && _loaded === defaultLoaded) {
1804
+ _loaded = () => true;
1805
+ }
1806
+ }
1793
1807
  const _t = function (s, ...values) {
1794
1808
  if (!_loaded()) {
1795
1809
  return new LazyTranslatedString(s, values);
@@ -6993,7 +7007,7 @@ class Popover extends Component {
6993
7007
  if (!anchor)
6994
7008
  return;
6995
7009
  const propsMaxSize = { width: this.props.maxWidth, height: this.props.maxHeight };
6996
- const elDims = {
7010
+ let elDims = {
6997
7011
  width: el.getBoundingClientRect().width,
6998
7012
  height: el.getBoundingClientRect().height,
6999
7013
  };
@@ -7001,7 +7015,14 @@ class Popover extends Component {
7001
7015
  const popoverPositionHelper = this.props.positioning === "BottomLeft"
7002
7016
  ? new BottomLeftPopoverContext(anchor, this.containerRect, propsMaxSize, spreadsheetRect)
7003
7017
  : new TopRightPopoverContext(anchor, this.containerRect, propsMaxSize, spreadsheetRect);
7004
- const style = popoverPositionHelper.getCss(elDims, this.props.verticalOffset);
7018
+ el.style["max-height"] = popoverPositionHelper.getMaxHeight(elDims.height) + "px";
7019
+ el.style["max-width"] = popoverPositionHelper.getMaxWidth(elDims.width) + "px";
7020
+ // Re-compute the dimensions after setting the max-width and max-height
7021
+ elDims = {
7022
+ width: el.getBoundingClientRect().width,
7023
+ height: el.getBoundingClientRect().height,
7024
+ };
7025
+ let style = popoverPositionHelper.getCss(elDims, this.props.verticalOffset);
7005
7026
  for (const property of Object.keys(style)) {
7006
7027
  el.style[property] = style[property];
7007
7028
  }
@@ -7064,8 +7085,6 @@ class PopoverPositionContext {
7064
7085
  const shouldRenderAtRight = this.shouldRenderAtRight(elDims.width);
7065
7086
  verticalOffset = shouldRenderAtBottom ? verticalOffset : -verticalOffset;
7066
7087
  const cssProperties = {
7067
- "max-height": maxHeight + "px",
7068
- "max-width": maxWidth + "px",
7069
7088
  top: this.getTopCoordinate(actualHeight, shouldRenderAtBottom) -
7070
7089
  this.spreadsheetOffset.y -
7071
7090
  verticalOffset +
@@ -25471,13 +25490,17 @@ class SelectMenu extends Component {
25471
25490
  class: { type: String, optional: true },
25472
25491
  };
25473
25492
  static components = { Menu };
25493
+ menuId = new UuidGenerator().uuidv4();
25474
25494
  selectRef = useRef("select");
25475
25495
  selectRect = useAbsoluteBoundingRect(this.selectRef);
25476
25496
  state = useState({
25477
25497
  isMenuOpen: false,
25478
25498
  });
25479
- onClick() {
25480
- this.state.isMenuOpen = true;
25499
+ onClick(ev) {
25500
+ if (ev.closedMenuId === this.menuId) {
25501
+ return;
25502
+ }
25503
+ this.state.isMenuOpen = !this.state.isMenuOpen;
25481
25504
  }
25482
25505
  onMenuClosed() {
25483
25506
  this.state.isMenuOpen = false;
@@ -25485,7 +25508,7 @@ class SelectMenu extends Component {
25485
25508
  get menuPosition() {
25486
25509
  return {
25487
25510
  x: this.selectRect.x,
25488
- y: this.selectRect.y,
25511
+ y: this.selectRect.y + this.selectRect.height,
25489
25512
  };
25490
25513
  }
25491
25514
  }
@@ -28523,7 +28546,7 @@ class FiguresContainer extends Component {
28523
28546
  });
28524
28547
  }
28525
28548
  getContainerRect(container) {
28526
- const { width: viewWidth, height: viewHeight } = this.env.model.getters.getMainViewportRect();
28549
+ const { width: viewWidth, height: viewHeight } = this.env.model.getters.getSheetViewDimension();
28527
28550
  const { x: viewportX, y: viewportY } = this.env.model.getters.getMainViewportCoordinates();
28528
28551
  const x = ["bottomRight", "topRight"].includes(container) ? viewportX : 0;
28529
28552
  const width = viewWidth - x;
@@ -44796,7 +44819,10 @@ class Session extends EventBus {
44796
44819
  /**
44797
44820
  * Notify the server that the user client left the collaborative session
44798
44821
  */
44799
- leave() {
44822
+ leave(data) {
44823
+ if (Object.keys(this.clients).length === 1 && this.processedRevisions.size) {
44824
+ this.snapshot(data);
44825
+ }
44800
44826
  delete this.clients[this.clientId];
44801
44827
  this.transportService.leave(this.clientId);
44802
44828
  this.transportService.sendMessage({
@@ -44809,6 +44835,9 @@ class Session extends EventBus {
44809
44835
  * Send a snapshot of the spreadsheet to the collaboration server
44810
44836
  */
44811
44837
  snapshot(data) {
44838
+ if (this.pendingMessages.length !== 0) {
44839
+ return;
44840
+ }
44812
44841
  const snapshotId = this.uuidGenerator.uuidv4();
44813
44842
  this.transportService.sendMessage({
44814
44843
  type: "SNAPSHOT",
@@ -49508,10 +49537,8 @@ class EditionPlugin extends UIPlugin {
49508
49537
  const refRange = this.getters.getRangeFromSheetXC(activeSheetId, xc);
49509
49538
  return isEqual(this.getters.expandZone(activeSheetId, refRange.zone), oldZone);
49510
49539
  });
49511
- // this function assumes that the previous range is always found because
49512
- // it's called when changing a highlight, which exists by definition
49513
49540
  if (!previousRefToken) {
49514
- throw new Error("Previous range not found");
49541
+ return;
49515
49542
  }
49516
49543
  const previousRange = this.getters.getRangeFromSheetXC(activeSheetId, previousRefToken.value);
49517
49544
  this.selectionStart = previousRefToken.start;
@@ -52049,7 +52076,7 @@ class BottomBarSheet extends Component {
52049
52076
  this.env.focusableElement.focus();
52050
52077
  }
52051
52078
  }
52052
- onClickSheetName(ev) {
52079
+ onMouseEventSheetName(ev) {
52053
52080
  if (this.state.isEditing)
52054
52081
  ev.stopPropagation();
52055
52082
  }
@@ -57189,6 +57216,7 @@ class Model extends EventBus {
57189
57216
  coreHandlers = [];
57190
57217
  constructor(data = {}, config = {}, stateUpdateMessages = [], uuidGenerator = new UuidGenerator(), verboseImport = true) {
57191
57218
  super();
57219
+ setDefaultTranslationMethod();
57192
57220
  stateUpdateMessages = repairInitialMessages(data, stateUpdateMessages);
57193
57221
  const workbookData = load(data, verboseImport);
57194
57222
  this.state = new StateObserver();
@@ -57264,7 +57292,7 @@ class Model extends EventBus {
57264
57292
  this.session.join(this.config.client);
57265
57293
  }
57266
57294
  leaveSession() {
57267
- this.session.leave();
57295
+ this.session.leave(this.exportData());
57268
57296
  }
57269
57297
  setupUiPlugin(Plugin) {
57270
57298
  const plugin = new Plugin(this.uiPluginConfig);
@@ -57688,6 +57716,7 @@ const helpers = {
57688
57716
  createAction,
57689
57717
  createActions,
57690
57718
  transformRangeData,
57719
+ deepEquals,
57691
57720
  };
57692
57721
  const links = {
57693
57722
  isMarkdownLink,
@@ -57739,6 +57768,6 @@ const constants = {
57739
57768
  export { AbstractChart, CellErrorType, CommandResult, CorePlugin, DispatchResult, EvaluationError, Model, Registry, Revision, SPREADSHEET_DIMENSIONS, Spreadsheet, UIPlugin, __info__, addFunction, astToFormula, compile, compileTokens, components, constants, convertAstNodes, coreTypes, findCellInNewZone, functionCache, helpers, hooks, invalidateCFEvaluationCommands, invalidateDependenciesCommands, invalidateEvaluationCommands, iterateAstNodes, links, load, parse, parseTokens, readonlyAllowedCommands, registries, setDefaultSheetViewSize, setTranslationMethod, tokenize };
57740
57769
 
57741
57770
 
57742
- __info__.version = "17.1.18";
57743
- __info__.date = "2024-06-10T09:34:55.045Z";
57744
- __info__.hash = "0e756ce";
57771
+ __info__.version = "17.1.20";
57772
+ __info__.date = "2024-07-02T09:03:04.534Z";
57773
+ __info__.hash = "d15aaf3";
@@ -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.18
6
- * @date 2024-06-10T09:34:55.045Z
7
- * @hash 0e756ce
5
+ * @version 17.1.20
6
+ * @date 2024-07-02T09:03:04.534Z
7
+ * @hash d15aaf3
8
8
  */
9
9
 
10
10
  (function (exports, owl) {
@@ -1769,9 +1769,10 @@
1769
1769
  sortedValues[indexLow] * (indexSup - percentIndex));
1770
1770
  }
1771
1771
 
1772
- // define a mock translation function, when o-spreadsheet runs in standalone it doesn't translate any string
1773
- let _translate = (s) => s;
1774
- let _loaded = () => false;
1772
+ const defaultTranslate = (s) => s;
1773
+ const defaultLoaded = () => false;
1774
+ let _translate = defaultTranslate;
1775
+ let _loaded = defaultLoaded;
1775
1776
  function sprintf(s, ...values) {
1776
1777
  if (values.length === 1 && typeof values[0] === "object" && !(values[0] instanceof String)) {
1777
1778
  const valuesDict = values[0];
@@ -1783,7 +1784,8 @@
1783
1784
  return s;
1784
1785
  }
1785
1786
  /***
1786
- * Allow to inject a translation function from outside o-spreadsheet.
1787
+ * Allow to inject a translation function from outside o-spreadsheet. This should be called before instantiating
1788
+ * a model.
1787
1789
  * @param tfn the function that will do the translation
1788
1790
  * @param loaded a function that returns true when the translation is loaded
1789
1791
  */
@@ -1791,6 +1793,18 @@
1791
1793
  _translate = tfn;
1792
1794
  _loaded = loaded;
1793
1795
  }
1796
+ /**
1797
+ * If no translation function has been set, this will mark the translation are loaded.
1798
+ *
1799
+ * By default, the translations should not be set as loaded, otherwise top-level translated constants will never be
1800
+ * translated. But if by the time the model is instantiated no custom translation function has been set, we can set
1801
+ * the default translation function as loaded so o-spreadsheet can be run in standalone with no translations.
1802
+ */
1803
+ function setDefaultTranslationMethod() {
1804
+ if (_translate === defaultTranslate && _loaded === defaultLoaded) {
1805
+ _loaded = () => true;
1806
+ }
1807
+ }
1794
1808
  const _t = function (s, ...values) {
1795
1809
  if (!_loaded()) {
1796
1810
  return new LazyTranslatedString(s, values);
@@ -6994,7 +7008,7 @@
6994
7008
  if (!anchor)
6995
7009
  return;
6996
7010
  const propsMaxSize = { width: this.props.maxWidth, height: this.props.maxHeight };
6997
- const elDims = {
7011
+ let elDims = {
6998
7012
  width: el.getBoundingClientRect().width,
6999
7013
  height: el.getBoundingClientRect().height,
7000
7014
  };
@@ -7002,7 +7016,14 @@
7002
7016
  const popoverPositionHelper = this.props.positioning === "BottomLeft"
7003
7017
  ? new BottomLeftPopoverContext(anchor, this.containerRect, propsMaxSize, spreadsheetRect)
7004
7018
  : new TopRightPopoverContext(anchor, this.containerRect, propsMaxSize, spreadsheetRect);
7005
- const style = popoverPositionHelper.getCss(elDims, this.props.verticalOffset);
7019
+ el.style["max-height"] = popoverPositionHelper.getMaxHeight(elDims.height) + "px";
7020
+ el.style["max-width"] = popoverPositionHelper.getMaxWidth(elDims.width) + "px";
7021
+ // Re-compute the dimensions after setting the max-width and max-height
7022
+ elDims = {
7023
+ width: el.getBoundingClientRect().width,
7024
+ height: el.getBoundingClientRect().height,
7025
+ };
7026
+ let style = popoverPositionHelper.getCss(elDims, this.props.verticalOffset);
7006
7027
  for (const property of Object.keys(style)) {
7007
7028
  el.style[property] = style[property];
7008
7029
  }
@@ -7065,8 +7086,6 @@
7065
7086
  const shouldRenderAtRight = this.shouldRenderAtRight(elDims.width);
7066
7087
  verticalOffset = shouldRenderAtBottom ? verticalOffset : -verticalOffset;
7067
7088
  const cssProperties = {
7068
- "max-height": maxHeight + "px",
7069
- "max-width": maxWidth + "px",
7070
7089
  top: this.getTopCoordinate(actualHeight, shouldRenderAtBottom) -
7071
7090
  this.spreadsheetOffset.y -
7072
7091
  verticalOffset +
@@ -25472,13 +25491,17 @@
25472
25491
  class: { type: String, optional: true },
25473
25492
  };
25474
25493
  static components = { Menu };
25494
+ menuId = new UuidGenerator().uuidv4();
25475
25495
  selectRef = owl.useRef("select");
25476
25496
  selectRect = useAbsoluteBoundingRect(this.selectRef);
25477
25497
  state = owl.useState({
25478
25498
  isMenuOpen: false,
25479
25499
  });
25480
- onClick() {
25481
- this.state.isMenuOpen = true;
25500
+ onClick(ev) {
25501
+ if (ev.closedMenuId === this.menuId) {
25502
+ return;
25503
+ }
25504
+ this.state.isMenuOpen = !this.state.isMenuOpen;
25482
25505
  }
25483
25506
  onMenuClosed() {
25484
25507
  this.state.isMenuOpen = false;
@@ -25486,7 +25509,7 @@
25486
25509
  get menuPosition() {
25487
25510
  return {
25488
25511
  x: this.selectRect.x,
25489
- y: this.selectRect.y,
25512
+ y: this.selectRect.y + this.selectRect.height,
25490
25513
  };
25491
25514
  }
25492
25515
  }
@@ -28524,7 +28547,7 @@
28524
28547
  });
28525
28548
  }
28526
28549
  getContainerRect(container) {
28527
- const { width: viewWidth, height: viewHeight } = this.env.model.getters.getMainViewportRect();
28550
+ const { width: viewWidth, height: viewHeight } = this.env.model.getters.getSheetViewDimension();
28528
28551
  const { x: viewportX, y: viewportY } = this.env.model.getters.getMainViewportCoordinates();
28529
28552
  const x = ["bottomRight", "topRight"].includes(container) ? viewportX : 0;
28530
28553
  const width = viewWidth - x;
@@ -44797,7 +44820,10 @@
44797
44820
  /**
44798
44821
  * Notify the server that the user client left the collaborative session
44799
44822
  */
44800
- leave() {
44823
+ leave(data) {
44824
+ if (Object.keys(this.clients).length === 1 && this.processedRevisions.size) {
44825
+ this.snapshot(data);
44826
+ }
44801
44827
  delete this.clients[this.clientId];
44802
44828
  this.transportService.leave(this.clientId);
44803
44829
  this.transportService.sendMessage({
@@ -44810,6 +44836,9 @@
44810
44836
  * Send a snapshot of the spreadsheet to the collaboration server
44811
44837
  */
44812
44838
  snapshot(data) {
44839
+ if (this.pendingMessages.length !== 0) {
44840
+ return;
44841
+ }
44813
44842
  const snapshotId = this.uuidGenerator.uuidv4();
44814
44843
  this.transportService.sendMessage({
44815
44844
  type: "SNAPSHOT",
@@ -49509,10 +49538,8 @@
49509
49538
  const refRange = this.getters.getRangeFromSheetXC(activeSheetId, xc);
49510
49539
  return isEqual(this.getters.expandZone(activeSheetId, refRange.zone), oldZone);
49511
49540
  });
49512
- // this function assumes that the previous range is always found because
49513
- // it's called when changing a highlight, which exists by definition
49514
49541
  if (!previousRefToken) {
49515
- throw new Error("Previous range not found");
49542
+ return;
49516
49543
  }
49517
49544
  const previousRange = this.getters.getRangeFromSheetXC(activeSheetId, previousRefToken.value);
49518
49545
  this.selectionStart = previousRefToken.start;
@@ -52050,7 +52077,7 @@
52050
52077
  this.env.focusableElement.focus();
52051
52078
  }
52052
52079
  }
52053
- onClickSheetName(ev) {
52080
+ onMouseEventSheetName(ev) {
52054
52081
  if (this.state.isEditing)
52055
52082
  ev.stopPropagation();
52056
52083
  }
@@ -57190,6 +57217,7 @@
57190
57217
  coreHandlers = [];
57191
57218
  constructor(data = {}, config = {}, stateUpdateMessages = [], uuidGenerator = new UuidGenerator(), verboseImport = true) {
57192
57219
  super();
57220
+ setDefaultTranslationMethod();
57193
57221
  stateUpdateMessages = repairInitialMessages(data, stateUpdateMessages);
57194
57222
  const workbookData = load(data, verboseImport);
57195
57223
  this.state = new StateObserver();
@@ -57265,7 +57293,7 @@
57265
57293
  this.session.join(this.config.client);
57266
57294
  }
57267
57295
  leaveSession() {
57268
- this.session.leave();
57296
+ this.session.leave(this.exportData());
57269
57297
  }
57270
57298
  setupUiPlugin(Plugin) {
57271
57299
  const plugin = new Plugin(this.uiPluginConfig);
@@ -57689,6 +57717,7 @@
57689
57717
  createAction,
57690
57718
  createActions,
57691
57719
  transformRangeData,
57720
+ deepEquals,
57692
57721
  };
57693
57722
  const links = {
57694
57723
  isMarkdownLink,
@@ -57776,9 +57805,9 @@
57776
57805
  exports.tokenize = tokenize;
57777
57806
 
57778
57807
 
57779
- __info__.version = "17.1.18";
57780
- __info__.date = "2024-06-10T09:34:55.045Z";
57781
- __info__.hash = "0e756ce";
57808
+ __info__.version = "17.1.20";
57809
+ __info__.date = "2024-07-02T09:03:04.534Z";
57810
+ __info__.hash = "d15aaf3";
57782
57811
 
57783
57812
 
57784
57813
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);