@odoo/o-spreadsheet 17.2.9 → 17.2.11

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.9
7
- * @date 2024-06-03T14:56:21.684Z
8
- * @hash 086af6d
6
+ * @version 17.2.11
7
+ * @date 2024-06-14T10:03:05.033Z
8
+ * @hash 7704cc4
9
9
  */
10
10
 
11
11
  (function (exports, owl) {
@@ -294,7 +294,10 @@
294
294
  * Check if the object is a plain old javascript object.
295
295
  */
296
296
  function isPlainObject(obj) {
297
- return typeof obj === "object" && obj?.constructor === Object;
297
+ return (typeof obj === "object" &&
298
+ obj !== null &&
299
+ // obj.constructor can be undefined when there's no prototype (`Object.create(null, {})`)
300
+ (obj?.constructor === Object || obj?.constructor === undefined));
298
301
  }
299
302
  /**
300
303
  * Sanitize the name of a sheet, by eventually removing quotes
@@ -19773,7 +19776,7 @@ stores.inject(MyMetaStore, storeInstance);
19773
19776
  if ("chartJsConfig" in runtime) {
19774
19777
  runtime.chartJsConfig.plugins = [backgroundColorChartJSPlugin];
19775
19778
  // @ts-ignore
19776
- const chart = new window.Chart(canvas, runtime.chartJsConfig);
19779
+ const chart = new window.Chart(canvas, deepCopy(runtime.chartJsConfig));
19777
19780
  const imgContent = chart.toBase64Image();
19778
19781
  chart.destroy();
19779
19782
  div.remove();
@@ -21719,8 +21722,7 @@ stores.inject(MyMetaStore, storeInstance);
21719
21722
  */
21720
21723
  function useSpreadsheetRect() {
21721
21724
  const position = owl.useState({ x: 0, y: 0, width: 0, height: 0 });
21722
- let spreadsheetElement = document.querySelector(".o-spreadsheet");
21723
- updatePosition();
21725
+ let spreadsheetElement = null;
21724
21726
  function updatePosition() {
21725
21727
  if (!spreadsheetElement) {
21726
21728
  spreadsheetElement = document.querySelector(".o-spreadsheet");
@@ -21842,7 +21844,7 @@ stores.inject(MyMetaStore, storeInstance);
21842
21844
  if (!anchor)
21843
21845
  return;
21844
21846
  const propsMaxSize = { width: this.props.maxWidth, height: this.props.maxHeight };
21845
- const elDims = {
21847
+ let elDims = {
21846
21848
  width: el.getBoundingClientRect().width,
21847
21849
  height: el.getBoundingClientRect().height,
21848
21850
  };
@@ -21850,7 +21852,14 @@ stores.inject(MyMetaStore, storeInstance);
21850
21852
  const popoverPositionHelper = this.props.positioning === "BottomLeft"
21851
21853
  ? new BottomLeftPopoverContext(anchor, this.containerRect, propsMaxSize, spreadsheetRect)
21852
21854
  : new TopRightPopoverContext(anchor, this.containerRect, propsMaxSize, spreadsheetRect);
21853
- const style = popoverPositionHelper.getCss(elDims, this.props.verticalOffset);
21855
+ el.style["max-height"] = popoverPositionHelper.getMaxHeight(elDims.height) + "px";
21856
+ el.style["max-width"] = popoverPositionHelper.getMaxWidth(elDims.width) + "px";
21857
+ // Re-compute the dimensions after setting the max-width and max-height
21858
+ elDims = {
21859
+ width: el.getBoundingClientRect().width,
21860
+ height: el.getBoundingClientRect().height,
21861
+ };
21862
+ let style = popoverPositionHelper.getCss(elDims, this.props.verticalOffset);
21854
21863
  for (const property of Object.keys(style)) {
21855
21864
  el.style[property] = style[property];
21856
21865
  }
@@ -21913,8 +21922,6 @@ stores.inject(MyMetaStore, storeInstance);
21913
21922
  const shouldRenderAtRight = this.shouldRenderAtRight(elDims.width);
21914
21923
  verticalOffset = shouldRenderAtBottom ? verticalOffset : -verticalOffset;
21915
21924
  const cssProperties = {
21916
- "max-height": maxHeight + "px",
21917
- "max-width": maxWidth + "px",
21918
21925
  top: this.getTopCoordinate(actualHeight, shouldRenderAtBottom) -
21919
21926
  this.spreadsheetOffset.y -
21920
21927
  verticalOffset +
@@ -29209,13 +29216,17 @@ stores.inject(MyMetaStore, storeInstance);
29209
29216
  class: { type: String, optional: true },
29210
29217
  };
29211
29218
  static components = { Menu };
29219
+ menuId = new UuidGenerator().uuidv4();
29212
29220
  selectRef = owl.useRef("select");
29213
29221
  selectRect = useAbsoluteBoundingRect(this.selectRef);
29214
29222
  state = owl.useState({
29215
29223
  isMenuOpen: false,
29216
29224
  });
29217
- onClick() {
29218
- this.state.isMenuOpen = true;
29225
+ onClick(ev) {
29226
+ if (ev.closedMenuId === this.menuId) {
29227
+ return;
29228
+ }
29229
+ this.state.isMenuOpen = !this.state.isMenuOpen;
29219
29230
  }
29220
29231
  onMenuClosed() {
29221
29232
  this.state.isMenuOpen = false;
@@ -29223,7 +29234,7 @@ stores.inject(MyMetaStore, storeInstance);
29223
29234
  get menuPosition() {
29224
29235
  return {
29225
29236
  x: this.selectRect.x,
29226
- y: this.selectRect.y,
29237
+ y: this.selectRect.y + this.selectRect.height,
29227
29238
  };
29228
29239
  }
29229
29240
  }
@@ -30163,9 +30174,9 @@ stores.inject(MyMetaStore, storeInstance);
30163
30174
  static props = {
30164
30175
  onCloseSidePanel: Function,
30165
30176
  };
30166
- dataRange = "";
30167
30177
  searchInput = owl.useRef("searchInput");
30168
30178
  store;
30179
+ state;
30169
30180
  get hasSearchResult() {
30170
30181
  return this.store.selectedMatchIndex !== null;
30171
30182
  }
@@ -30195,6 +30206,7 @@ stores.inject(MyMetaStore, storeInstance);
30195
30206
  }
30196
30207
  setup() {
30197
30208
  this.store = useLocalStore(FindAndReplaceStore);
30209
+ this.state = owl.useState({ dataRange: "" });
30198
30210
  owl.onMounted(() => this.searchInput.el?.focus());
30199
30211
  }
30200
30212
  onFocusSearch() {
@@ -30231,13 +30243,13 @@ stores.inject(MyMetaStore, storeInstance);
30231
30243
  this.store.updateSearchOptions({ searchScope });
30232
30244
  }
30233
30245
  onSearchRangeChanged(ranges) {
30234
- this.dataRange = ranges[0];
30246
+ this.state.dataRange = ranges[0];
30235
30247
  }
30236
30248
  updateDataRange() {
30237
- if (!this.dataRange || this.searchOptions.searchScope !== "specificRange") {
30249
+ if (!this.state.dataRange || this.searchOptions.searchScope !== "specificRange") {
30238
30250
  return;
30239
30251
  }
30240
- const specificRange = this.env.model.getters.getRangeFromSheetXC(this.env.model.getters.getActiveSheetId(), this.dataRange);
30252
+ const specificRange = this.env.model.getters.getRangeFromSheetXC(this.env.model.getters.getActiveSheetId(), this.state.dataRange);
30241
30253
  this.store.updateSearchOptions({ specificRange });
30242
30254
  }
30243
30255
  }
@@ -32431,8 +32443,15 @@ stores.inject(MyMetaStore, storeInstance);
32431
32443
  }
32432
32444
  onPaste(ev) {
32433
32445
  if (this.composerStore.editionMode !== "inactive") {
32446
+ // let the browser clipboard work
32434
32447
  ev.stopPropagation();
32435
32448
  }
32449
+ else {
32450
+ // the user meant to paste in the sheet, not open the composer with the pasted content
32451
+ // While we're not editing, we still have the focus and should therefore prevent
32452
+ // the native "paste" to occur.
32453
+ ev.preventDefault();
32454
+ }
32436
32455
  }
32437
32456
  /*
32438
32457
  * Triggered automatically by the content-editable between the keydown and key up
@@ -32441,9 +32460,6 @@ stores.inject(MyMetaStore, storeInstance);
32441
32460
  if (!this.shouldProcessInputEvents) {
32442
32461
  return;
32443
32462
  }
32444
- if (ev.inputType === "insertFromPaste" && this.composerStore.editionMode === "inactive") {
32445
- return;
32446
- }
32447
32463
  ev.stopPropagation();
32448
32464
  let content;
32449
32465
  if (this.composerStore.editionMode === "inactive") {
@@ -32810,10 +32826,7 @@ stores.inject(MyMetaStore, storeInstance);
32810
32826
  }
32811
32827
  get containerStyle() {
32812
32828
  if (this.composerStore.editionMode === "inactive") {
32813
- return `
32814
- position: absolute;
32815
- z-index: -1000;
32816
- `;
32829
+ return `z-index: -1000;`;
32817
32830
  }
32818
32831
  const isFormula = this.composerStore.currentContent.startsWith("=");
32819
32832
  const cell = this.env.model.getters.getActiveCell();
@@ -33524,7 +33537,7 @@ stores.inject(MyMetaStore, storeInstance);
33524
33537
  });
33525
33538
  }
33526
33539
  getContainerRect(container) {
33527
- const { width: viewWidth, height: viewHeight } = this.env.model.getters.getMainViewportRect();
33540
+ const { width: viewWidth, height: viewHeight } = this.env.model.getters.getSheetViewDimension();
33528
33541
  const { x: viewportX, y: viewportY } = this.env.model.getters.getMainViewportCoordinates();
33529
33542
  const x = ["bottomRight", "topRight"].includes(container) ? viewportX : 0;
33530
33543
  const width = viewWidth - x;
@@ -50287,7 +50300,10 @@ stores.inject(MyMetaStore, storeInstance);
50287
50300
  /**
50288
50301
  * Notify the server that the user client left the collaborative session
50289
50302
  */
50290
- leave() {
50303
+ leave(data) {
50304
+ if (Object.keys(this.clients).length === 1 && this.processedRevisions.size) {
50305
+ this.snapshot(data);
50306
+ }
50291
50307
  delete this.clients[this.clientId];
50292
50308
  this.transportService.leave(this.clientId);
50293
50309
  this.transportService.sendMessage({
@@ -50300,6 +50316,9 @@ stores.inject(MyMetaStore, storeInstance);
50300
50316
  * Send a snapshot of the spreadsheet to the collaboration server
50301
50317
  */
50302
50318
  snapshot(data) {
50319
+ if (this.pendingMessages.length !== 0) {
50320
+ return;
50321
+ }
50303
50322
  const snapshotId = this.uuidGenerator.uuidv4();
50304
50323
  this.transportService.sendMessage({
50305
50324
  type: "SNAPSHOT",
@@ -60212,7 +60231,7 @@ stores.inject(MyMetaStore, storeInstance);
60212
60231
  this.session.join(this.config.client);
60213
60232
  }
60214
60233
  leaveSession() {
60215
- this.session.leave();
60234
+ this.session.leave(this.exportData());
60216
60235
  }
60217
60236
  setupUiPlugin(Plugin) {
60218
60237
  const plugin = new Plugin(this.uiPluginConfig);
@@ -60766,9 +60785,9 @@ stores.inject(MyMetaStore, storeInstance);
60766
60785
  exports.tokenize = tokenize;
60767
60786
 
60768
60787
 
60769
- __info__.version = "17.2.9";
60770
- __info__.date = "2024-06-03T14:56:21.684Z";
60771
- __info__.hash = "086af6d";
60788
+ __info__.version = "17.2.11";
60789
+ __info__.date = "2024-06-14T10:03:05.033Z";
60790
+ __info__.hash = "7704cc4";
60772
60791
 
60773
60792
 
60774
60793
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);