@xh/hoist 59.0.0 → 59.0.1

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,12 @@
1
1
  # Changelog
2
2
 
3
+ ## 59.0.1 - 2023-08-17
4
+
5
+ ### 🎁 New Features
6
+
7
+ * Added new `collapsedTitle` prop to `Panel` to make it easier to display different a title
8
+ when the panel is collapsed.
9
+
3
10
  ## 59.0.0 - 2023-08-17
4
11
 
5
12
  ### 💥 Breaking Changes
@@ -42,10 +49,6 @@
42
49
  the latest Chrome v115.
43
50
  * Note this required some adjustments to the internal DOM structure of `PanelHeader` - highly
44
51
  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
52
  * Fixed bug where `manuallySized` was not being set properly on column state.
50
53
  * Fixed bug where mobile `Dialog` max height was not properly constrained to the viewport.
51
54
  * Fixed bug where mobile `NumberInput` would clear when trying to enter decimals on certain devices.
@@ -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)
@@ -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
  ],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xh/hoist",
3
- "version": "59.0.0",
3
+ "version": "59.0.1",
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",