@linzjs/lui 18.5.0 → 18.6.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,17 @@
1
+ # [18.6.0](https://github.com/linz/lui/compare/v18.5.1...v18.6.0) (2023-08-14)
2
+
3
+
4
+ ### Features
5
+
6
+ * **LuiMultiSwitch:** Adding ability to disable particular options ([#984](https://github.com/linz/lui/issues/984)) ([7eeddf3](https://github.com/linz/lui/commit/7eeddf3b86e98bf7e9f6748a3db6eb61d2f317d1))
7
+
8
+ ## [18.5.1](https://github.com/linz/lui/compare/v18.5.0...v18.5.1) (2023-08-13)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * **LuiExpandableBanner:** fix height limit ([#983](https://github.com/linz/lui/issues/983)) ([a9d8fea](https://github.com/linz/lui/commit/a9d8feade76359f001acbcf43e2835ef1d08ee43))
14
+
1
15
  # [18.5.0](https://github.com/linz/lui/compare/v18.4.5...v18.5.0) (2023-08-09)
2
16
 
3
17
 
@@ -4,6 +4,7 @@ export interface LuiMultiSwitchOption<ValueType> {
4
4
  value: ValueType;
5
5
  shortcutKey?: string;
6
6
  className?: string;
7
+ disabled?: boolean;
7
8
  }
8
9
  export declare const LuiMultiSwitchYesNo: LuiMultiSwitchOption<boolean>[];
9
10
  export interface LuiMultiSwitchProps<ValueType> {
package/dist/index.js CHANGED
@@ -25675,18 +25675,35 @@ var LuiMessagingContextProvider = function (props) {
25675
25675
  props.children));
25676
25676
  };
25677
25677
 
25678
+ var getMaxHeight = function (_a) {
25679
+ var scrollHeight = _a.scrollHeight;
25680
+ return Math.max(scrollHeight, 1200) + 'px';
25681
+ };
25678
25682
  var LuiExpandableBanner = function (props) {
25679
- var initiallyCollapsed = props.start === 'expanded' ? false : true;
25680
- var _a = React.useState(initiallyCollapsed), collapse = _a[0], setCollapse = _a[1];
25683
+ var initiallyCollapsed = React.useRef(props.start === 'expanded' ? false : true);
25684
+ var _a = React.useState(initiallyCollapsed.current), collapse = _a[0], setCollapse = _a[1];
25685
+ var content = React.useRef(null);
25686
+ var _b = React.useState('initial'), maxHeight = _b[0], setMaxHeight = _b[1];
25687
+ React.useEffect(function () {
25688
+ content.current && setMaxHeight(getMaxHeight(content.current));
25689
+ }, [content]);
25681
25690
  return (React__default["default"].createElement(React__default["default"].Fragment, null,
25682
25691
  React__default["default"].createElement("div", { className: clsx('lui-expand-container', props.className) },
25683
25692
  props.labelPrefix,
25684
- React__default["default"].createElement("div", { className: 'lui-expand-header', onClick: function () { return setCollapse(function (prev) { return !prev; }); }, style: { width: '100%' } },
25693
+ React__default["default"].createElement("div", { className: 'lui-expand-header', onClick: function () {
25694
+ setCollapse(function (prev) { return !prev; });
25695
+ if (content.current) {
25696
+ setMaxHeight(getMaxHeight(content.current));
25697
+ }
25698
+ }, style: { width: '100%' } },
25685
25699
  React__default["default"].createElement("h3", null, props.label),
25686
25700
  React__default["default"].createElement("i", { className: clsx(collapse
25687
25701
  ? 'lui-expand-icon material-icons-round'
25688
25702
  : 'lui-expand-icon material-icons-round lui-expand-icon-transform') }, 'expand_more'))),
25689
- React__default["default"].createElement("div", { style: collapse ? { maxHeight: '0px' } : undefined, className: 'lui-accordion-content' }, props.children)));
25703
+ React__default["default"].createElement("div", { className: "lui-accordion-content", style: {
25704
+ maxHeight: collapse ? '0px' : maxHeight,
25705
+ overflow: collapse ? 'hidden' : 'auto'
25706
+ }, onTransitionEnd: function (e) { return setMaxHeight(getMaxHeight(e.currentTarget)); }, ref: content }, props.children)));
25690
25707
  };
25691
25708
 
25692
25709
  /**
@@ -67808,7 +67825,10 @@ var LuiMultiSwitch = function (_a) {
67808
67825
  switch (_b.label) {
67809
67826
  case 0:
67810
67827
  (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
67811
- if (disabled || updating.current || newSelectedIndex === selectedIndex) {
67828
+ if (disabled ||
67829
+ updating.current ||
67830
+ newSelectedIndex === selectedIndex ||
67831
+ options[newSelectedIndex].disabled) {
67812
67832
  return [2 /*return*/];
67813
67833
  }
67814
67834
  if (isUncontrolled) {
@@ -67853,7 +67873,7 @@ var LuiMultiSwitch = function (_a) {
67853
67873
  return e.key && e.key === option.shortcutKey && select(i).then();
67854
67874
  });
67855
67875
  } }),
67856
- React__default["default"].createElement("div", { className: clsx('LuiMultiSwitch-labels', disabled && 'LuiMultiSwitch-disabled') }, options === null || options === void 0 ? void 0 : options.map(function (option, i) { return (React__default["default"].createElement("label", { role: 'radio', key: i, htmlFor: id.current, "aria-disabled": disabled, "aria-checked": selectedIndex === i, className: option.className, onClick: function () { return select(i); }, onTouchStart: function () { return select(i); } }, option.text)); }))));
67876
+ React__default["default"].createElement("div", { className: clsx('LuiMultiSwitch-labels', disabled && 'LuiMultiSwitch-disabled') }, options === null || options === void 0 ? void 0 : options.map(function (option, i) { return (React__default["default"].createElement("label", { role: 'radio', key: i, htmlFor: id.current, "aria-disabled": option.disabled || disabled, "aria-checked": selectedIndex === i, className: option.className, onClick: function () { return select(i); }, onTouchStart: function () { return select(i); } }, option.text)); }))));
67857
67877
  };
67858
67878
 
67859
67879
  var css_248z$5 = "/**\n @deprecated\n */\n/**\n @deprecated\n */\n/**\n @deprecated\n */\n.LuiListBox {\n padding: 0;\n list-style: none;\n}\n.LuiListBox .LuiListBoxItem {\n font-family: \"Open Sans\", system-ui, sans-serif;\n font-style: normal;\n font-weight: normal;\n user-select: none;\n color: #2a292c;\n line-height: 24px;\n outline: none;\n padding: 0.5rem 0.75rem;\n border: 2px solid transparent;\n}\n.LuiListBox .LuiListBoxItem:focus-visible {\n border-color: #007198;\n}\n.LuiListBox .LuiListBoxItem.LuiListBoxItem-selected {\n background: #e2f3f7;\n}\n.LuiListBox .LuiListBoxItem:hover, .LuiListBox .LuiListBoxItem.LuiListBoxItem-selected:hover {\n background: #d6eef4;\n}\n.LuiListBox .LuiListBoxItem.LuiListBoxItem-disabled {\n background: #eaeaea;\n}\n.LuiListBox .LuiListBox-emptyIndicator, .LuiListBox .LuiListBox-loadingIndicator {\n padding: 0.5rem 0.75rem;\n}\n.LuiListBox .LuiListBoxGroup .LuiListBoxGroup-heading {\n font-family: \"Open Sans\", system-ui, sans-serif;\n font-style: normal;\n font-weight: normal;\n font-size: 14px;\n user-select: none;\n color: #6b6966;\n line-height: 16px;\n padding: 0.5rem 0.5rem;\n}";