@xh/hoist 59.0.0 → 59.0.2

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,32 @@
1
1
  # Changelog
2
2
 
3
+ ## 59.0.2 - 2023-08-24
4
+
5
+ ### 🐞 Bug Fixes
6
+
7
+ * Restored support for `Select.selectOnFocus` (had broken with upgrade to `react-select` in v59.0).
8
+ * Fixed `DateInput` bug caused by changes in Chrome v116 - clicking on inputs
9
+ with `enableTextInput: false` now open the date picker popup as expected.
10
+ * Flex inner title element added to `Panel` headers in v59.0, and set `display:flex` on the new
11
+ element itself. Restores previous flexbox container behavior (when not L/R collapsed) for apps
12
+ that are providing custom components as titles.
13
+ * `DashCanvas` now properly updates its layout when shown if the browser window had been resized
14
+ while the component was hidden (e.g. in an inactive tab).
15
+ * Reverted upgrade to `react-select` in v59.0.0 due to issues found with `selectEditor` / inline
16
+ grid editing. We will revisit this upgrade in a future release.
17
+
18
+ ### 📚 Libraries
19
+
20
+ * react-select `5.7 -> 4.3`
21
+ * react-windowed-select `5.1 -> 3.1`
22
+
23
+ ## 59.0.1 - 2023-08-17
24
+
25
+ ### 🎁 New Features
26
+
27
+ * Added new `Panel.collapsedTitle` prop to make it easier to display a different title when the
28
+ panel is collapsed.
29
+
3
30
  ## 59.0.0 - 2023-08-17
4
31
 
5
32
  ### 💥 Breaking Changes
@@ -42,10 +69,6 @@
42
69
  the latest Chrome v115.
43
70
  * Note this required some adjustments to the internal DOM structure of `PanelHeader` - highly
44
71
  specific CSS selectors or visual tests may be affected.
45
- * Note Panels accept a *custom component* as titles, not just a strings. No transforms
46
- are applied in this case when the panel is collapsed to the left or right - the custom title
47
- component is responsible for its own styling. Please avoid custom component titles for
48
- left/right collapsible panels, at least when in a collapsed state.
49
72
  * Fixed bug where `manuallySized` was not being set properly on column state.
50
73
  * Fixed bug where mobile `Dialog` max height was not properly constrained to the viewport.
51
74
  * Fixed bug where mobile `NumberInput` would clear when trying to enter decimals on certain devices.
@@ -61,8 +84,8 @@
61
84
  * semver `7.3 -> 7.5`
62
85
  * typescript `4.9 -> 5.1`
63
86
  * highcharts `10.3 -> 11.1`
64
- * react-select `4.3.1 -> 5.7.4`
65
- * react-windowed-select `3.1.2 -> 5.1.0`
87
+ * react-select `4.3 -> 5.7`
88
+ * react-windowed-select `3.1 -> 5.1`
66
89
 
67
90
  ## 58.0.1 - 2023-07-13
68
91
 
@@ -5,11 +5,13 @@
5
5
  * Copyright © 2023 Extremely Heavy Industries Inc.
6
6
  */
7
7
  import {ContextMenu} from '@blueprintjs/core';
8
+ import composeRefs from '@seznam/compose-react-refs';
8
9
  import {div, vbox, vspacer} from '@xh/hoist/cmp/layout';
9
10
  import {elementFactory, hoistCmp, HoistProps, refreshContextView, uses, XH} from '@xh/hoist/core';
10
11
  import {dashCanvasAddViewButton} from '@xh/hoist/desktop/cmp/button/DashCanvasAddViewButton';
11
12
  import '@xh/hoist/desktop/register';
12
13
  import {Classes, overlay} from '@xh/hoist/kit/blueprint';
14
+ import {useOnVisibleChange} from '@xh/hoist/utils/react';
13
15
  import classNames from 'classnames';
14
16
  import ReactGridLayout, {WidthProvider} from 'react-grid-layout';
15
17
  import 'react-grid-layout/css/styles.css';
@@ -36,10 +38,16 @@ export const [DashCanvas, dashCanvas] = hoistCmp.withFactory<DashCanvasProps>({
36
38
  className: 'xh-dash-canvas',
37
39
  model: uses(DashCanvasModel),
38
40
 
39
- render({className, model}) {
41
+ render({className, model}, ref) {
40
42
  const isDraggable = !model.layoutLocked,
41
43
  isResizable = !model.layoutLocked;
42
44
 
45
+ ref = composeRefs(
46
+ ref,
47
+ model.ref,
48
+ useOnVisibleChange(viz => model.onVisibleChange(viz))
49
+ );
50
+
43
51
  return refreshContextView({
44
52
  model: model.refreshContextModel,
45
53
  item: div({
@@ -48,7 +56,7 @@ export const [DashCanvas, dashCanvas] = hoistCmp.withFactory<DashCanvasProps>({
48
56
  isDraggable ? `${className}--draggable` : null,
49
57
  isResizable ? `${className}--resizable` : null
50
58
  ),
51
- ref: model.ref,
59
+ ref,
52
60
  onContextMenu: e => onContextMenu(e, model),
53
61
  items: [
54
62
  reactGridLayout({
@@ -198,18 +198,19 @@ export class DashCanvasModel extends DashModel<
198
198
  this.loadState(persistState?.state ?? initialState);
199
199
  this.state = this.buildState();
200
200
 
201
- this.addReaction({
202
- track: () => this.viewState,
203
- run: () => this.publishState()
204
- });
205
-
206
- this.addReaction({
207
- when: () => !!this.ref.current,
208
- run: () => {
209
- const {current: node} = this.ref;
210
- this.scrollbarVisible = node.offsetWidth > node.clientWidth;
201
+ this.addReaction(
202
+ {
203
+ track: () => this.viewState,
204
+ run: () => this.publishState()
205
+ },
206
+ {
207
+ when: () => !!this.ref.current,
208
+ run: () => {
209
+ const {current: node} = this.ref;
210
+ this.scrollbarVisible = node.offsetWidth > node.clientWidth;
211
+ }
211
212
  }
212
- });
213
+ );
213
214
  }
214
215
 
215
216
  /** Removes all views from the canvas */
@@ -377,6 +378,12 @@ export class DashCanvasModel extends DashModel<
377
378
  return model;
378
379
  }
379
380
 
381
+ // Trigger window resize event when component becomes visible to ensure layout adjusted to
382
+ // current window size - fixes https://github.com/xh/hoist-react/issues/3215
383
+ onVisibleChange(visible: boolean) {
384
+ if (visible) this.fireWindowResizeEvent();
385
+ }
386
+
380
387
  onRglLayoutChange(rglLayout) {
381
388
  rglLayout = rglLayout.map(it => pick(it, ['i', 'x', 'y', 'w', 'h']));
382
389
  this.setLayout(rglLayout);
@@ -396,7 +403,7 @@ export class DashCanvasModel extends DashModel<
396
403
  if (!node) return;
397
404
  const scrollbarVisible = node.offsetWidth > node.clientWidth;
398
405
  if (scrollbarVisible !== this.scrollbarVisible) {
399
- window.dispatchEvent(new Event('resize'));
406
+ this.fireWindowResizeEvent();
400
407
  this.scrollbarVisible = scrollbarVisible;
401
408
  }
402
409
  }
@@ -522,4 +529,8 @@ export class DashCanvasModel extends DashModel<
522
529
 
523
530
  return {x: defaultX, y: endY ?? rows};
524
531
  }
532
+
533
+ private fireWindowResizeEvent() {
534
+ window.dispatchEvent(new Event('resize'));
535
+ }
525
536
  }
@@ -30,4 +30,10 @@
30
30
  background-color: transparent !important;
31
31
  cursor: not-allowed;
32
32
  }
33
+
34
+ // Prevent browser from capturing click events when input is disabled due to use of
35
+ // enableTextInput: false prop. See https://github.com/xh/hoist-react/issues/3460
36
+ input[disabled] {
37
+ pointer-events: none;
38
+ }
33
39
  }
@@ -485,6 +485,7 @@ const cmp = hoistCmp.factory<DateInputModel>(({model, className, ...props}, ref)
485
485
  ref: model.textInputRef,
486
486
  ...getLayoutProps(props)
487
487
  }),
488
+ className: 'xh-date-input__click-target',
488
489
  onClick: !enableTextInput && !disabled ? model.onOpenPopoverClick : null
489
490
  })
490
491
  }),
@@ -373,9 +373,12 @@ class SelectInputModel extends HoistInputModel {
373
373
  const {reactSelect} = this;
374
374
  if (!reactSelect) return;
375
375
 
376
- // Use of windowedMode, creatable and async variants will create levels of nesting we must
377
- // traverse to get to the underlying Select comp and its inputRef.
378
- let selectComp = reactSelect.select;
376
+ // TODO - after update to react-select v5 in HR v59, could not identify any cases that
377
+ // still required the while loop below. Had been required due to nested layers of
378
+ // components when using enableWindowed, enableCreate, and/or queryFn. Leaving in place to
379
+ // avoid breaking some edge-case we're not finding, but could review/simplify once update
380
+ // is baked in a bit more.
381
+ let selectComp = reactSelect;
379
382
  while (selectComp && !selectComp.inputRef) {
380
383
  selectComp = selectComp.select;
381
384
  }
@@ -82,6 +82,9 @@ export interface PanelProps extends HoistProps<PanelModel>, Omit<BoxProps, 'titl
82
82
 
83
83
  /** Title text added to the panel's header. */
84
84
  title?: ReactNode;
85
+
86
+ /** Title to be used when the panel is collapsed. Defaults to `title`. */
87
+ collapsedTitle?: ReactNode;
85
88
  }
86
89
 
87
90
  /**
@@ -114,6 +117,7 @@ export const [Panel, panel] = hoistCmp.withFactory<PanelProps>({
114
117
  title,
115
118
  icon,
116
119
  compactHeader,
120
+ collapsedTitle,
117
121
  headerItems,
118
122
  mask: maskProp,
119
123
  loadingIndicator: loadingIndicatorProp,
@@ -183,7 +187,7 @@ export const [Panel, panel] = hoistCmp.withFactory<PanelProps>({
183
187
  let item = vbox({
184
188
  className: 'xh-panel__content',
185
189
  items: [
186
- panelHeader({title, icon, compact: compactHeader, headerItems}),
190
+ panelHeader({title, icon, compact: compactHeader, collapsedTitle, headerItems}),
187
191
  coreContents,
188
192
  parseLoadDecorator(maskProp, 'mask', contextModel),
189
193
  parseLoadDecorator(loadingIndicatorProp, 'loadingIndicator', contextModel)
@@ -12,6 +12,11 @@
12
12
  white-space: nowrap;
13
13
  font-family: var(--xh-panel-title-font-family);
14
14
  font-size: var(--xh-panel-title-font-size-px);
15
+
16
+ &__inner {
17
+ display: flex;
18
+ flex: 1;
19
+ }
15
20
  }
16
21
 
17
22
  &__items {
@@ -45,6 +50,8 @@
45
50
  height: 100%;
46
51
 
47
52
  &__inner {
53
+ display: block;
54
+ flex: none;
48
55
  margin-top: 50%;
49
56
  transform: rotate(90deg);
50
57
  height: calc(1em + 5px);
@@ -8,8 +8,9 @@ import {box, filler, hbox, span, vbox} from '@xh/hoist/cmp/layout';
8
8
  import {hoistCmp, useContextModel} from '@xh/hoist/core';
9
9
  import {button, modalToggleButton} from '@xh/hoist/desktop/cmp/button';
10
10
  import {Icon} from '@xh/hoist/icon';
11
+ import {withDefault} from '@xh/hoist/utils/js';
11
12
  import classNames from 'classnames';
12
- import {isEmpty, isNil, isString} from 'lodash';
13
+ import {isEmpty, isNil} from 'lodash';
13
14
  import {PanelModel} from '../PanelModel';
14
15
  import './PanelHeader.scss';
15
16
 
@@ -22,6 +23,8 @@ export const panelHeader = hoistCmp.factory({
22
23
  const panelModel = useContextModel(PanelModel),
23
24
  {collapsed, collapsible, isModal, vertical, side} = panelModel,
24
25
  {title, icon, compact} = props,
26
+ collapsedTitle = withDefault(props.collapsedTitle, title),
27
+ displayedTitle = collapsed ? collapsedTitle : title,
25
28
  headerItems = props.headerItems ?? [];
26
29
 
27
30
  if (isNil(title) && isNil(icon) && isEmpty(headerItems)) return null;
@@ -44,13 +47,11 @@ export const panelHeader = hoistCmp.factory({
44
47
  className: classNames(className, compactCls),
45
48
  items: [
46
49
  icon || null,
47
- title
50
+ displayedTitle
48
51
  ? box({
49
52
  className: titleCls,
50
53
  flex: 1,
51
- item: isString(title)
52
- ? span({className: `${titleCls}__inner`, item: title})
53
- : title
54
+ item: span({className: `${titleCls}__inner`, item: displayedTitle})
54
55
  })
55
56
  : filler(),
56
57
  hbox({
@@ -74,12 +75,10 @@ export const panelHeader = hoistCmp.factory({
74
75
  items: [
75
76
  collapseButton({panelModel}),
76
77
  icon || null,
77
- title
78
+ displayedTitle
78
79
  ? box({
79
80
  className: titleCls,
80
- item: isString(title)
81
- ? span({className: `${titleCls}__inner`, item: title})
82
- : title
81
+ item: span({className: `${titleCls}__inner`, item: displayedTitle})
83
82
  })
84
83
  : null
85
84
  ],
@@ -1,5 +1,10 @@
1
1
  .xh-inspector {
2
- .xh-modal-support__host > .xh-panel__content > .xh-panel-header {
2
+ & > .xh-panel__content > .xh-panel-header {
3
+ background-color: hsl(33, 93%, 40%);
4
+ color: white;
5
+ }
6
+
7
+ .xh-modal-support__host > div > .xh-panel__content > .xh-panel-header {
3
8
  background-color: hsl(33, 93%, 40%);
4
9
  color: white;
5
10
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xh/hoist",
3
- "version": "59.0.0",
3
+ "version": "59.0.2",
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",
@@ -68,9 +68,9 @@
68
68
  "react-grid-layout": "^1.3.4",
69
69
  "react-onsenui": "~1.13.2",
70
70
  "react-popper": "~2.3.0",
71
- "react-select": "~5.7.4",
71
+ "react-select": "~4.3.1",
72
72
  "react-transition-group": "~4.4.2",
73
- "react-windowed-select": "~5.1.0",
73
+ "react-windowed-select": "~3.1.2",
74
74
  "regenerator-runtime": "~0.13.11",
75
75
  "resize-observer-polyfill": "~1.5.1",
76
76
  "router5": "~7.0.2",