@linzjs/lui 20.0.2 → 20.0.3

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,3 +1,10 @@
1
+ ## [20.0.3](https://github.com/linz/lui/compare/v20.0.2...v20.0.3) (2023-09-21)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **LuiExpandableBanner:** configure max-height ([#1014](https://github.com/linz/lui/issues/1014)) ([5a291c4](https://github.com/linz/lui/commit/5a291c483488b8abe5a5f0313727a34456719ff7))
7
+
1
8
  ## [20.0.2](https://github.com/linz/lui/compare/v20.0.1...v20.0.2) (2023-09-21)
2
9
 
3
10
 
@@ -1,11 +1,19 @@
1
1
  import React, { ReactNode } from 'react';
2
2
  declare type OverflowType = 'hidden' | 'auto' | 'inherit' | 'overlay' | 'revert' | 'scroll' | 'unset' | 'visible';
3
+ declare type MaxHeight = 'none' | ' max-content' | 'min-content' | string | number;
4
+ declare type ContentMaxHeight = {
5
+ type: 'calculated';
6
+ } | {
7
+ type: 'fixed';
8
+ maxHeight: MaxHeight;
9
+ };
3
10
  export interface Expandable {
4
11
  className?: string;
5
12
  label: ReactNode;
6
13
  labelPrefix?: ReactNode;
7
14
  start?: 'collapsed' | 'expanded';
8
15
  expandedOverflow?: OverflowType;
16
+ contentMaxHeight?: ContentMaxHeight;
9
17
  }
10
18
  export declare const LuiExpandableBanner: React.FC<React.PropsWithChildren<Expandable>>;
11
19
  export {};
package/dist/index.js CHANGED
@@ -25689,18 +25689,27 @@ var LuiMessagingContextProvider = function (props) {
25689
25689
  props.children));
25690
25690
  };
25691
25691
 
25692
- var getMaxHeight = function (_a) {
25693
- var scrollHeight = _a.scrollHeight;
25694
- return Math.max(scrollHeight, 1200) + 'px';
25695
- };
25696
25692
  var LuiExpandableBanner = function (props) {
25693
+ var contentMaxHeight = props.contentMaxHeight;
25697
25694
  var initiallyCollapsed = React.useRef(props.start === 'expanded' ? false : true);
25698
25695
  var _a = React.useState(initiallyCollapsed.current), collapse = _a[0], setCollapse = _a[1];
25699
25696
  var content = React.useRef(null);
25697
+ var getMaxHeight = React.useCallback(function (_a) {
25698
+ var scrollHeight = _a.scrollHeight;
25699
+ if (contentMaxHeight && contentMaxHeight.type === 'calculated') {
25700
+ return scrollHeight + 'px';
25701
+ }
25702
+ else if (contentMaxHeight && contentMaxHeight.type === 'fixed') {
25703
+ return contentMaxHeight.maxHeight;
25704
+ }
25705
+ else {
25706
+ return Math.max(scrollHeight, 1200) + 'px';
25707
+ }
25708
+ }, [content, props.contentMaxHeight]);
25700
25709
  var _b = React.useState('initial'), maxHeight = _b[0], setMaxHeight = _b[1];
25701
25710
  React.useEffect(function () {
25702
25711
  content.current && setMaxHeight(getMaxHeight(content.current));
25703
- }, [content]);
25712
+ }, [content, getMaxHeight]);
25704
25713
  var accordionExpandedOverflow = props.expandedOverflow || 'auto';
25705
25714
  return (React__default["default"].createElement(React__default["default"].Fragment, null,
25706
25715
  React__default["default"].createElement("div", { className: clsx('lui-expand-container', props.className) },