@linzjs/lui 17.8.1 → 17.9.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,3 +1,10 @@
1
+ # [17.9.0](https://github.com/linz/lui/compare/v17.8.1...v17.9.0) (2022-08-08)
2
+
3
+
4
+ ### Features
5
+
6
+ * **LuiTabsPanel:** adding support for lazy loading content via the mode prop ([#715](https://github.com/linz/lui/issues/715)) ([55ee571](https://github.com/linz/lui/commit/55ee57105a917312fa7ab84c51d89277b9f213c7))
7
+
1
8
  ## [17.8.1](https://github.com/linz/lui/compare/v17.8.0...v17.8.1) (2022-08-08)
2
9
 
3
10
 
@@ -1,6 +1,8 @@
1
1
  import React from 'react';
2
+ export declare type LuiTabsPanelMode = 'lazy' | 'eager';
2
3
  interface LuiTabsPanelProps {
3
4
  panel: string;
5
+ mode?: LuiTabsPanelMode;
4
6
  }
5
7
  export declare const LuiTabsPanel: React.FC<LuiTabsPanelProps>;
6
8
  export {};
package/dist/index.js CHANGED
@@ -863,10 +863,17 @@ var LuiTabsGroup = function (props) {
863
863
  return (React__default["default"].createElement("div", { className: "LuiTabsGroup " + (props.justify ? 'LuiTabsGroup--justified' : ''), role: "tablist", "aria-label": props.ariaLabel }, props.children));
864
864
  };
865
865
 
866
- var LuiTabsPanel = function (props) {
866
+ var LuiTabsPanel = function (_a) {
867
+ var children = _a.children, panel = _a.panel, _b = _a.mode, mode = _b === void 0 ? 'eager' : _b;
867
868
  var context = React.useContext(LuiTabsContext);
868
- var active = context.activePanel === props.panel;
869
- return (React__default["default"].createElement("div", { className: clsx('LuiTabsPanel', active && 'LuiTabsPanel--active'), id: props.panel + "-tab-panel", role: "tabpanel", "aria-labelledby": props.panel + "-tab" }, props.children));
869
+ var _c = React.useState(mode === 'eager'), shouldShow = _c[0], setShouldShow = _c[1];
870
+ var active = context.activePanel === panel;
871
+ React.useEffect(function () {
872
+ if (active && !shouldShow) {
873
+ setShouldShow(true);
874
+ }
875
+ }, [active, shouldShow]);
876
+ return (React__default["default"].createElement("div", { className: clsx('LuiTabsPanel', active && 'LuiTabsPanel--active'), id: panel + "-tab-panel", role: "tabpanel", "aria-labelledby": panel + "-tab" }, shouldShow ? children : null));
870
877
  };
871
878
 
872
879
  var LuiTabsPanelSwitch = function (props) {