@xh/hoist 44.2.0 → 44.3.0

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # Changelog
2
2
 
3
+ ## v44.3.0 - 2021-12-15
4
+
5
+ ### 🐞 Bug Fixes
6
+ * Fixes issue with columns failing to resize on first try.
7
+ * Fixes issue preventing use of context menus on iPad.
8
+
9
+ ### 📚 Libraries
10
+
11
+ * @blueprintjs/core `3.51 -> 3.52`
12
+
13
+ * [Commit Log](https://github.com/xh/hoist-react/compare/v44.2.0...v44.3.0)
14
+
3
15
  ## v44.2.0 - 2021-12-07
4
16
 
5
17
  ### 🎁 New Features
package/cmp/grid/Grid.js CHANGED
@@ -719,7 +719,8 @@ class GridLocalModel extends HoistModel {
719
719
  onColumnResized = (ev) => {
720
720
  if (!isDisplayed(this.viewRef.current) || !ev.finished) return;
721
721
  if (ev.source === 'uiColumnDragged') {
722
- this.model.noteColumnsManuallySized(ev.column.colId);
722
+ const width = ev.columnApi.getColumnState().find(it => it.colId === ev.column.colId)?.width;
723
+ this.model.noteColumnManuallySized(ev.column.colId, width);
723
724
  } else if (ev.source === 'autosizeColumns') {
724
725
  this.model.noteAgColumnStateChanged(ev.columnApi.getColumnState());
725
726
  }
@@ -838,8 +838,10 @@ export class GridModel extends HoistModel {
838
838
  }
839
839
  }
840
840
 
841
- noteColumnsManuallySized(colIds) {
842
- const colStateChanges = castArray(colIds).map(colId => ({colId, manuallySized: true}));
841
+ noteColumnManuallySized(colId, width) {
842
+ const col = this.findColumn(this.columns, colId);
843
+ if (!width || !col || col.flex) return;
844
+ const colStateChanges = [{colId, width, manuallySized: true}];
843
845
  this.applyColumnStateChanges(colStateChanges);
844
846
  }
845
847
 
@@ -13,7 +13,7 @@ import {action, observable, bindable, makeObservable} from '@xh/hoist/mobx';
13
13
  import {wait} from '@xh/hoist/promise';
14
14
  import {debounced, ensureUniqueBy, throwIf} from '@xh/hoist/utils/js';
15
15
  import {createObservableRef} from '@xh/hoist/utils/react';
16
- import {cloneDeep, defaultsDeep, find, isFinite, reject} from 'lodash';
16
+ import {cloneDeep, defaultsDeep, find, isFinite, isNil, reject} from 'lodash';
17
17
  import {DashViewModel} from './DashViewModel';
18
18
  import {DashViewSpec} from './DashViewSpec';
19
19
  import {dashContainerMenuButton} from './impl/DashContainerMenuButton';
@@ -395,21 +395,27 @@ export class DashContainerModel extends HoistModel {
395
395
  // Add context menu listener for adding components
396
396
  const $el = stack.header.element;
397
397
  $el.off('contextmenu').contextmenu(e => {
398
- this.showContextMenu(e, {stack});
398
+ this.showContextMenu(e, $el, {stack});
399
399
  return false;
400
400
  });
401
401
  }
402
402
 
403
- showContextMenu(e, {stack, viewModel, index}) {
403
+ showContextMenu(e, $target, {stack, viewModel, index}) {
404
404
  if (this.contentLocked) return;
405
405
 
406
- const offset = {left: e.clientX, top: e.clientY},
407
- menu = dashContainerContextMenu({
408
- stack,
409
- viewModel,
410
- index,
411
- dashContainerModel: this
412
- });
406
+ // If event does not contain co-ordinates, fallback to showing context menu below target
407
+ let offset = {left: e.clientX, top: e.clientY};
408
+ if (isNil(offset.left) || isNil(offset.top)) {
409
+ offset = $target.offset();
410
+ offset.top += 30;
411
+ }
412
+
413
+ const menu = dashContainerContextMenu({
414
+ stack,
415
+ viewModel,
416
+ index,
417
+ dashContainerModel: this
418
+ });
413
419
 
414
420
  ContextMenu.show(menu, offset, null, XH.darkTheme);
415
421
  }
@@ -456,7 +462,7 @@ export class DashContainerModel extends HoistModel {
456
462
 
457
463
  $el.off('contextmenu').contextmenu(e => {
458
464
  const index = stack.contentItems.indexOf(item);
459
- this.showContextMenu(e, {stack, viewModel, index});
465
+ this.showContextMenu(e, $el, {stack, viewModel, index});
460
466
  return false;
461
467
  });
462
468
 
@@ -59,9 +59,9 @@ GoldenLayout['__lm'].utils.ReactComponentHandler = ReactComponentHandlerPatched;
59
59
  const DragListener = GoldenLayout['__lm'].utils.DragListener;
60
60
  class DragListenerPatched extends DragListener {
61
61
  onMouseDown(oEvent) {
62
- oEvent.preventDefault();
63
-
64
62
  // PATCH BEGINS
63
+ if (oEvent.cancelable) oEvent.preventDefault();
64
+
65
65
  if (oEvent.type === 'touchstart') {
66
66
  this._touchTarget = oEvent.target;
67
67
 
@@ -87,7 +87,14 @@ class DragListenerPatched extends DragListener {
87
87
  this._oDocument.on('mousemove touchmove', this._fMove);
88
88
  this._oDocument.one('mouseup touchend', this._fUp);
89
89
 
90
- this._timeout = setTimeout(GoldenLayout['__lm'].utils.fnBind(this._startDrag, this), this._nDelay);
90
+ // PATCH BEGINS
91
+ // Extend time held to begin drag for stationary touch events. Note that this should be
92
+ // quite long to allow for showing the context menu on a shorter hold. The user can
93
+ // initiate a drag at any time in the interim by moving their touch.
94
+ const ms = oEvent.type === 'touchstart' ? 3000 : this._nDelay;
95
+ this._touchStart = Date.now();
96
+ this._timeout = setTimeout(GoldenLayout['__lm'].utils.fnBind(this._startDrag, this), ms);
97
+ // PATCH ENDS
91
98
  }
92
99
  }
93
100
 
@@ -110,7 +117,14 @@ class DragListenerPatched extends DragListener {
110
117
  if (this._bDragging === true) {
111
118
  this._bDragging = false;
112
119
  this.emit('dragStop', oEvent, this._nOriginalX + this._nX);
120
+ // PATCH BEGINS
121
+ // If the touch is released *before* dragging has started, trigger the context menu
122
+ // event. We still require a minimum about of time to pass, to differentiate from
123
+ // taps to change the selected tab.
124
+ } else if (oEvent.type === 'touchend' && Date.now() - this._touchStart > 800) {
125
+ this._eElement.trigger('contextmenu');
113
126
  }
127
+ // PATCH ENDS
114
128
  }
115
129
  }
116
130
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xh/hoist",
3
- "version": "44.2.0",
3
+ "version": "44.3.0",
4
4
  "description": "Hoist add-on for building and deploying React Applications.",
5
5
  "repository": "github:xh/hoist-react",
6
6
  "homepage": "https://xh.io",
@@ -26,8 +26,8 @@
26
26
  }
27
27
  },
28
28
  "dependencies": {
29
- "@blueprintjs/core": "~3.51.0",
30
- "@blueprintjs/datetime": "~3.23.15",
29
+ "@blueprintjs/core": "~3.52.0",
30
+ "@blueprintjs/datetime": "~3.23.18",
31
31
  "@fortawesome/fontawesome-pro": "~5.15.4",
32
32
  "@fortawesome/fontawesome-svg-core": "~1.2.36",
33
33
  "@fortawesome/pro-light-svg-icons": "~5.15.4",