@linzjs/lui 20.0.1 → 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,17 @@
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
+
8
+ ## [20.0.2](https://github.com/linz/lui/compare/v20.0.1...v20.0.2) (2023-09-21)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * **LuiExpandableBanner:** configure overflow ([#1013](https://github.com/linz/lui/issues/1013)) ([da054c2](https://github.com/linz/lui/commit/da054c25aa9b0ae194a03c019f4249164823abd5))
14
+
1
15
  ## [20.0.1](https://github.com/linz/lui/compare/v20.0.0...v20.0.1) (2023-09-20)
2
16
 
3
17
 
@@ -1,8 +1,19 @@
1
1
  import React, { ReactNode } from 'react';
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
+ };
2
10
  export interface Expandable {
3
11
  className?: string;
4
12
  label: ReactNode;
5
13
  labelPrefix?: ReactNode;
6
14
  start?: 'collapsed' | 'expanded';
15
+ expandedOverflow?: OverflowType;
16
+ contentMaxHeight?: ContentMaxHeight;
7
17
  }
8
18
  export declare const LuiExpandableBanner: React.FC<React.PropsWithChildren<Expandable>>;
19
+ export {};
package/dist/index.js CHANGED
@@ -25689,18 +25689,28 @@ 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]);
25713
+ var accordionExpandedOverflow = props.expandedOverflow || 'auto';
25704
25714
  return (React__default["default"].createElement(React__default["default"].Fragment, null,
25705
25715
  React__default["default"].createElement("div", { className: clsx('lui-expand-container', props.className) },
25706
25716
  props.labelPrefix,
@@ -25716,7 +25726,7 @@ var LuiExpandableBanner = function (props) {
25716
25726
  : 'lui-expand-icon material-icons-round lui-expand-icon-transform') }, 'expand_more'))),
25717
25727
  React__default["default"].createElement("div", { className: "lui-accordion-content", style: {
25718
25728
  maxHeight: collapse ? '0px' : maxHeight,
25719
- overflow: collapse ? 'hidden' : 'auto'
25729
+ overflow: collapse ? 'hidden' : accordionExpandedOverflow
25720
25730
  }, onTransitionEnd: function (e) { return setMaxHeight(getMaxHeight(e.currentTarget)); }, ref: content }, props.children)));
25721
25731
  };
25722
25732