@superdispatch/ui-lab 0.50.4 → 0.50.6

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.
@@ -909,7 +909,7 @@ var EmailAutocomplete = /*#__PURE__*/react.forwardRef((_ref, ref) => {
909
909
  },
910
910
  onChange: (_event, selectedValue, reason) => {
911
911
  var emails = selectedValue.flatMap(item => item.split(',')).map(item => item.trim());
912
- _onChange === null || _onChange === void 0 ? void 0 : _onChange(emails, reason);
912
+ _onChange === null || _onChange === void 0 || _onChange(emails, reason);
913
913
  },
914
914
  renderTags: items => {
915
915
  return /*#__PURE__*/jsxRuntime.jsx(ui.Inline, {
@@ -944,13 +944,13 @@ var EmailAutocomplete = /*#__PURE__*/react.forwardRef((_ref, ref) => {
944
944
  var text = event.target.value.replace(/,/g, '');
945
945
  var hasCommaOrSpace = /,|\s/.test(event.target.value);
946
946
  if (hasCommaOrSpace && text.trim() !== '') {
947
- _onChange === null || _onChange === void 0 ? void 0 : _onChange([...(value || []), text.trim()], 'select-option');
947
+ _onChange === null || _onChange === void 0 || _onChange([...(value || []), text.trim()], 'select-option');
948
948
  }
949
949
  },
950
950
  onBlur: event => {
951
951
  var text = event.target.value;
952
952
  if (text.trim() !== '') {
953
- _onChange === null || _onChange === void 0 ? void 0 : _onChange([...(value || []), text.trim()], 'select-option');
953
+ _onChange === null || _onChange === void 0 || _onChange([...(value || []), text.trim()], 'select-option');
954
954
  }
955
955
  }
956
956
  }))
@@ -1037,10 +1037,10 @@ var FileDropZone = /*#__PURE__*/react.forwardRef((props, ref) => {
1037
1037
  maxFiles: maxFiles,
1038
1038
  disabled: disabled,
1039
1039
  onDropAccepted: files => {
1040
- _onDropAccepted === null || _onDropAccepted === void 0 ? void 0 : _onDropAccepted(files);
1040
+ _onDropAccepted === null || _onDropAccepted === void 0 || _onDropAccepted(files);
1041
1041
  },
1042
1042
  onDropRejected: fileRejections => {
1043
- _onDropRejected === null || _onDropRejected === void 0 ? void 0 : _onDropRejected(fileRejections);
1043
+ _onDropRejected === null || _onDropRejected === void 0 || _onDropRejected(fileRejections);
1044
1044
  },
1045
1045
  children: _ref3 => {
1046
1046
  var {
@@ -1490,19 +1490,28 @@ function NavbarAccordion(_ref2) {
1490
1490
  icon,
1491
1491
  gutter,
1492
1492
  items,
1493
- onClick: _onClick
1493
+ onClick: _onClick,
1494
+ isExpanded: controlledIsExpanded,
1495
+ onExpandedChange
1494
1496
  } = _ref2;
1495
1497
  var uid = ui.useUID();
1496
1498
  var {
1497
1499
  setDrawerOpen,
1498
1500
  isNavbarExpanded
1499
1501
  } = useNavbarContext();
1500
- var [isExpanded, setExpanded] = react.useState(true);
1501
-
1502
- // sync accordion state with Desktop menu state
1502
+ var [internalIsExpanded, setInternalExpanded] = react.useState(true);
1503
1503
  react.useEffect(() => {
1504
- setExpanded(isNavbarExpanded);
1505
- }, [isNavbarExpanded]);
1504
+ if (controlledIsExpanded === undefined) {
1505
+ setInternalExpanded(isNavbarExpanded);
1506
+ }
1507
+ }, [isNavbarExpanded, controlledIsExpanded]);
1508
+ var isExpanded = controlledIsExpanded !== undefined ? controlledIsExpanded : internalIsExpanded;
1509
+ function setExpanded(value) {
1510
+ if (controlledIsExpanded === undefined) {
1511
+ setInternalExpanded(value);
1512
+ }
1513
+ onExpandedChange === null || onExpandedChange === void 0 || onExpandedChange(value);
1514
+ }
1506
1515
  var filteredItems = react.useMemo(() => items.filter(item => !item.hide), [items]);
1507
1516
  return /*#__PURE__*/jsxRuntime.jsxs(NavbarAccordionRoot, {
1508
1517
  square: true,
@@ -1510,8 +1519,8 @@ function NavbarAccordion(_ref2) {
1510
1519
  "aria-labelledby": uid,
1511
1520
  expanded: isExpanded,
1512
1521
  onClick: event => {
1513
- _onClick === null || _onClick === void 0 ? void 0 : _onClick(event);
1514
- if (isNavbarExpanded) {
1522
+ _onClick === null || _onClick === void 0 || _onClick(event);
1523
+ if (controlledIsExpanded !== undefined || isNavbarExpanded) {
1515
1524
  setExpanded(!isExpanded);
1516
1525
  }
1517
1526
  },
@@ -1540,7 +1549,7 @@ function NavbarAccordion(_ref2) {
1540
1549
  onClick: event => {
1541
1550
  var _item$onClick;
1542
1551
  event.stopPropagation();
1543
- (_item$onClick = item.onClick) === null || _item$onClick === void 0 ? void 0 : _item$onClick.call(item, event);
1552
+ (_item$onClick = item.onClick) === null || _item$onClick === void 0 || _item$onClick.call(item, event);
1544
1553
  if (!event.isDefaultPrevented()) {
1545
1554
  setDrawerOpen(false);
1546
1555
  }
@@ -1664,7 +1673,7 @@ function NavbarList(_ref6) {
1664
1673
  gutter: prev && prev.groupKey !== item.groupKey,
1665
1674
  onClick: event => {
1666
1675
  var _item$onClick;
1667
- (_item$onClick = item.onClick) === null || _item$onClick === void 0 ? void 0 : _item$onClick.call(item, event);
1676
+ (_item$onClick = item.onClick) === null || _item$onClick === void 0 || _item$onClick.call(item, event);
1668
1677
  if (!event.isDefaultPrevented()) {
1669
1678
  setDrawerOpen(false);
1670
1679
  }
@@ -1693,7 +1702,9 @@ function Navbar(_ref) {
1693
1702
  bottomItems,
1694
1703
  children,
1695
1704
  containerStyle,
1696
- hasExtraBadge
1705
+ hasExtraBadge,
1706
+ isMenuExpanded: controlledIsMenuExpanded,
1707
+ onMenuExpandedChange
1697
1708
  } = _ref;
1698
1709
  var theme = core.useTheme();
1699
1710
  var [isDrawerOpen, setDrawerOpen] = react.useState(false);
@@ -1702,7 +1713,14 @@ function Navbar(_ref) {
1702
1713
  var matches = core.useMediaQuery(theme.breakpoints.up('md'), {
1703
1714
  noSsr: true
1704
1715
  });
1705
- var [isMenuExpanded, setMenuExpanded] = react.useState(matches);
1716
+ var [internalIsMenuExpanded, setInternalMenuExpanded] = react.useState(matches);
1717
+ var isMenuExpanded = controlledIsMenuExpanded !== undefined ? controlledIsMenuExpanded : internalIsMenuExpanded;
1718
+ var setMenuExpanded = react.useCallback(value => {
1719
+ if (controlledIsMenuExpanded === undefined) {
1720
+ setInternalMenuExpanded(value);
1721
+ }
1722
+ onMenuExpandedChange === null || onMenuExpandedChange === void 0 || onMenuExpandedChange(value);
1723
+ }, [controlledIsMenuExpanded, onMenuExpandedChange]);
1706
1724
  var hasBadge = hasExtraBadge || items.some(item => item.badge);
1707
1725
  var ctx = react.useMemo(() => ({
1708
1726
  isDrawerOpen,
@@ -1710,7 +1728,7 @@ function Navbar(_ref) {
1710
1728
  setDrawerOpen,
1711
1729
  setMenuExpanded,
1712
1730
  isNavbarExpanded: isMenuExpanded || isDrawerOpen
1713
- }), [isDrawerOpen, isMenuExpanded, setMenuExpanded, setDrawerOpen]);
1731
+ }), [isDrawerOpen, isMenuExpanded, setDrawerOpen, setMenuExpanded]);
1714
1732
  return /*#__PURE__*/jsxRuntime.jsx(NavbarContext.Provider, {
1715
1733
  value: ctx,
1716
1734
  children: /*#__PURE__*/jsxRuntime.jsxs("div", {
@@ -2161,7 +2179,7 @@ function SidebarBackButton(_ref) {
2161
2179
  return /*#__PURE__*/jsxRuntime.jsx(core.IconButton, _objectSpread(_objectSpread({}, props), {}, {
2162
2180
  size: "small",
2163
2181
  onClick: event => {
2164
- _onClick === null || _onClick === void 0 ? void 0 : _onClick(event);
2182
+ _onClick === null || _onClick === void 0 || _onClick(event);
2165
2183
  if (!event.isDefaultPrevented()) {
2166
2184
  openSidebar();
2167
2185
  }
@@ -2357,7 +2375,7 @@ var SidebarMenuItem = /*#__PURE__*/react.forwardRef((_ref2, ref) => {
2357
2375
  disabled: disabled,
2358
2376
  "aria-current": selected,
2359
2377
  onClick: event => {
2360
- _onClick === null || _onClick === void 0 ? void 0 : _onClick(event);
2378
+ _onClick === null || _onClick === void 0 || _onClick(event);
2361
2379
  if (!event.isDefaultPrevented() && openContentOnClick) {
2362
2380
  openSidebarContent();
2363
2381
  }
@@ -2471,7 +2489,7 @@ var SidebarMenuItemAvatar = /*#__PURE__*/react.forwardRef((_ref, ref) => {
2471
2489
  onMouseDown: stopPropagation,
2472
2490
  onTouchStart: stopPropagation,
2473
2491
  onChange: (_, checked) => {
2474
- _onChange === null || _onChange === void 0 ? void 0 : _onChange(checked);
2492
+ _onChange === null || _onChange === void 0 || _onChange(checked);
2475
2493
  }
2476
2494
  })
2477
2495
  });
@@ -2536,6 +2554,8 @@ exports.FlagListItem = FlagListItem;
2536
2554
  exports.LinkedText = LinkedText;
2537
2555
  exports.MultilineText = MultilineText;
2538
2556
  exports.Navbar = Navbar;
2557
+ exports.NavbarAccordion = NavbarAccordion;
2558
+ exports.NavbarAccordionLabel = NavbarAccordionLabel;
2539
2559
  exports.NavbarAvatar = NavbarAvatar;
2540
2560
  exports.NavbarBadge = NavbarBadge;
2541
2561
  exports.NavbarBottomBar = NavbarBottomBar;