@superdispatch/ui-lab 0.50.6 → 0.50.7
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/dist-node/index.js +31 -23
- package/dist-node/index.js.map +1 -1
- package/dist-src/navbar/Navbar.js +18 -3
- package/dist-src/navbar/NavbarAccordion.js +9 -19
- package/dist-src/navbar/NavbarContext.js +3 -1
- package/dist-src/navbar/NavbarList.js +2 -1
- package/dist-types/index.d.ts +8 -6
- package/dist-web/index.js +31 -23
- package/dist-web/index.js.map +1 -1
- package/package.json +1 -1
package/dist-node/index.js
CHANGED
|
@@ -1341,8 +1341,10 @@ var NavbarContext = /*#__PURE__*/react.createContext({
|
|
|
1341
1341
|
isDrawerOpen: false,
|
|
1342
1342
|
isMenuExpanded: false,
|
|
1343
1343
|
isNavbarExpanded: false,
|
|
1344
|
+
groupExpanded: {},
|
|
1344
1345
|
setMenuExpanded: () => void 0,
|
|
1345
|
-
setDrawerOpen: () => void 0
|
|
1346
|
+
setDrawerOpen: () => void 0,
|
|
1347
|
+
setGroupExpanded: () => void 0
|
|
1346
1348
|
});
|
|
1347
1349
|
function useNavbarContext() {
|
|
1348
1350
|
return react.useContext(NavbarContext);
|
|
@@ -1485,33 +1487,23 @@ var IconWrapper$2 = /*#__PURE__*/styled__default.div.withConfig({
|
|
|
1485
1487
|
componentId: "SD__sc-1s7g3kw-3"
|
|
1486
1488
|
})(["width:24px;margin-right:8px;& svg{font-size:24px;}"]);
|
|
1487
1489
|
function NavbarAccordion(_ref2) {
|
|
1490
|
+
var _groupExpanded$groupK;
|
|
1488
1491
|
var {
|
|
1489
1492
|
label,
|
|
1490
1493
|
icon,
|
|
1491
1494
|
gutter,
|
|
1492
1495
|
items,
|
|
1493
1496
|
onClick: _onClick,
|
|
1494
|
-
|
|
1495
|
-
onExpandedChange
|
|
1497
|
+
groupKey
|
|
1496
1498
|
} = _ref2;
|
|
1497
1499
|
var uid = ui.useUID();
|
|
1498
1500
|
var {
|
|
1499
1501
|
setDrawerOpen,
|
|
1500
|
-
isNavbarExpanded
|
|
1502
|
+
isNavbarExpanded,
|
|
1503
|
+
groupExpanded,
|
|
1504
|
+
setGroupExpanded
|
|
1501
1505
|
} = useNavbarContext();
|
|
1502
|
-
var
|
|
1503
|
-
react.useEffect(() => {
|
|
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
|
+
var isExpanded = (_groupExpanded$groupK = groupExpanded[groupKey]) !== null && _groupExpanded$groupK !== void 0 ? _groupExpanded$groupK : true;
|
|
1515
1507
|
var filteredItems = react.useMemo(() => items.filter(item => !item.hide), [items]);
|
|
1516
1508
|
return /*#__PURE__*/jsxRuntime.jsxs(NavbarAccordionRoot, {
|
|
1517
1509
|
square: true,
|
|
@@ -1520,8 +1512,8 @@ function NavbarAccordion(_ref2) {
|
|
|
1520
1512
|
expanded: isExpanded,
|
|
1521
1513
|
onClick: event => {
|
|
1522
1514
|
_onClick === null || _onClick === void 0 || _onClick(event);
|
|
1523
|
-
if (
|
|
1524
|
-
|
|
1515
|
+
if (isNavbarExpanded) {
|
|
1516
|
+
setGroupExpanded(groupKey, !isExpanded);
|
|
1525
1517
|
}
|
|
1526
1518
|
},
|
|
1527
1519
|
children: [/*#__PURE__*/jsxRuntime.jsxs(NavbarAccordionSummary, {
|
|
@@ -1665,7 +1657,8 @@ function NavbarList(_ref6) {
|
|
|
1665
1657
|
return /*#__PURE__*/react.createElement(NavbarAccordion, _objectSpread(_objectSpread({}, item), {}, {
|
|
1666
1658
|
key: item.key,
|
|
1667
1659
|
gutter: prev && prev.groupKey !== item.groupKey,
|
|
1668
|
-
onClick: item.onClick
|
|
1660
|
+
onClick: item.onClick,
|
|
1661
|
+
groupKey: item.groupKey || item.key
|
|
1669
1662
|
}));
|
|
1670
1663
|
}
|
|
1671
1664
|
return /*#__PURE__*/react.createElement(NavbarItem, _objectSpread(_objectSpread({}, item), {}, {
|
|
@@ -1703,8 +1696,10 @@ function Navbar(_ref) {
|
|
|
1703
1696
|
children,
|
|
1704
1697
|
containerStyle,
|
|
1705
1698
|
hasExtraBadge,
|
|
1699
|
+
groupExpanded: controlledGroupExpanded,
|
|
1706
1700
|
isMenuExpanded: controlledIsMenuExpanded,
|
|
1707
|
-
onMenuExpandedChange
|
|
1701
|
+
onMenuExpandedChange,
|
|
1702
|
+
onGroupExpandedChange
|
|
1708
1703
|
} = _ref;
|
|
1709
1704
|
var theme = core.useTheme();
|
|
1710
1705
|
var [isDrawerOpen, setDrawerOpen] = react.useState(false);
|
|
@@ -1714,6 +1709,8 @@ function Navbar(_ref) {
|
|
|
1714
1709
|
noSsr: true
|
|
1715
1710
|
});
|
|
1716
1711
|
var [internalIsMenuExpanded, setInternalMenuExpanded] = react.useState(matches);
|
|
1712
|
+
var [groupExpandedState, setGroupExpandedState] = react.useState(controlledGroupExpanded || {});
|
|
1713
|
+
var groupExpanded = controlledGroupExpanded ? controlledGroupExpanded : groupExpandedState;
|
|
1717
1714
|
var isMenuExpanded = controlledIsMenuExpanded !== undefined ? controlledIsMenuExpanded : internalIsMenuExpanded;
|
|
1718
1715
|
var setMenuExpanded = react.useCallback(value => {
|
|
1719
1716
|
if (controlledIsMenuExpanded === undefined) {
|
|
@@ -1721,14 +1718,25 @@ function Navbar(_ref) {
|
|
|
1721
1718
|
}
|
|
1722
1719
|
onMenuExpandedChange === null || onMenuExpandedChange === void 0 || onMenuExpandedChange(value);
|
|
1723
1720
|
}, [controlledIsMenuExpanded, onMenuExpandedChange]);
|
|
1721
|
+
var setGroupExpanded = react.useCallback((groupKey, isExpanded) => {
|
|
1722
|
+
var updatedGroupExpanded = _objectSpread(_objectSpread({}, groupExpanded), {}, {
|
|
1723
|
+
[groupKey]: isExpanded
|
|
1724
|
+
});
|
|
1725
|
+
if (!controlledGroupExpanded) {
|
|
1726
|
+
setGroupExpandedState(updatedGroupExpanded);
|
|
1727
|
+
}
|
|
1728
|
+
onGroupExpandedChange === null || onGroupExpandedChange === void 0 || onGroupExpandedChange(updatedGroupExpanded);
|
|
1729
|
+
}, [controlledGroupExpanded, groupExpanded, onGroupExpandedChange]);
|
|
1724
1730
|
var hasBadge = hasExtraBadge || items.some(item => item.badge);
|
|
1725
1731
|
var ctx = react.useMemo(() => ({
|
|
1726
1732
|
isDrawerOpen,
|
|
1727
1733
|
isMenuExpanded,
|
|
1728
1734
|
setDrawerOpen,
|
|
1729
1735
|
setMenuExpanded,
|
|
1730
|
-
isNavbarExpanded: isMenuExpanded || isDrawerOpen
|
|
1731
|
-
|
|
1736
|
+
isNavbarExpanded: isMenuExpanded || isDrawerOpen,
|
|
1737
|
+
setGroupExpanded,
|
|
1738
|
+
groupExpanded
|
|
1739
|
+
}), [isDrawerOpen, isMenuExpanded, setMenuExpanded, setGroupExpanded, groupExpanded]);
|
|
1732
1740
|
return /*#__PURE__*/jsxRuntime.jsx(NavbarContext.Provider, {
|
|
1733
1741
|
value: ctx,
|
|
1734
1742
|
children: /*#__PURE__*/jsxRuntime.jsxs("div", {
|