@superdispatch/ui-lab 0.19.0 → 0.20.2
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 +210 -23
- package/dist-node/index.js.map +1 -1
- package/dist-src/index.js +2 -0
- package/dist-src/navbar/NavbarAccordion.js +2 -2
- package/dist-src/navbar/NavbarItem.js +1 -1
- package/dist-src/sidebar/Sidebar.js +1 -1
- package/dist-src/sidebar/SidebarBackButton.js +38 -0
- package/dist-src/sidebar/SidebarContainer.js +44 -10
- package/dist-src/sidebar/SidebarContent.js +103 -0
- package/dist-src/sidebar/SidebarMenuItem.js +36 -11
- package/dist-src/sidebar/SidebarMenuItemAvatar.js +1 -0
- package/dist-types/index.d.ts +21 -2
- package/dist-web/index.js +214 -30
- package/dist-web/index.js.map +1 -1
- package/package.json +3 -3
package/dist-node/index.js
CHANGED
|
@@ -1137,7 +1137,7 @@ var NavbarLabel = /*#__PURE__*/styled__default.span.withConfig({
|
|
|
1137
1137
|
var NavbarItemRoot = /*#__PURE__*/styled__default.div.withConfig({
|
|
1138
1138
|
displayName: "NavbarItem__NavbarItemRoot",
|
|
1139
1139
|
componentId: "SD__sc-1pvzq3w-2"
|
|
1140
|
-
})(["width:100%;display:flex;align-items:center;color:#c2c4c9;font-size:14px;font-weight:400;line-height:20px;text-decoration:none;outline:none;cursor:pointer;padding:8px 16px;border-left:4px solid transparent;&:hover,&[aria-current]{background-color:#2f394a;color:", ";border-left-color:", ";}&[data-active='true']{border-left-color:", ";}"], ui.Color.White, ui.Color.Blue300, ui.Color.Blue300);
|
|
1140
|
+
})(["width:100%;display:flex;align-items:center;color:#c2c4c9;font-size:14px;font-weight:400;line-height:20px;text-decoration:none;outline:none;cursor:pointer;padding:8px 16px;border-left:4px solid transparent;&:hover,&[aria-current]{background-color:#2f394a;color:", ";border-left-color:", ";}&[data-active='true']{background-color:#2f394a;border-left-color:", ";}"], ui.Color.White, ui.Color.Blue300, ui.Color.Blue300);
|
|
1141
1141
|
var IconWrapper$1 = /*#__PURE__*/styled__default.div.withConfig({
|
|
1142
1142
|
displayName: "NavbarItem__IconWrapper",
|
|
1143
1143
|
componentId: "SD__sc-1pvzq3w-3"
|
|
@@ -1187,12 +1187,12 @@ var NavbarAccordionRoot = /*#__PURE__*/styled__default(core.Accordion).withConfi
|
|
|
1187
1187
|
var {
|
|
1188
1188
|
gutter
|
|
1189
1189
|
} = _ref;
|
|
1190
|
-
return styled.css(["width:100%;color:#c2c4c9;font-size:14px;font-weight:400;line-height:20px;text-decoration:none;outline:none;cursor:pointer;background-color:#1b2638;margin-top:", "
|
|
1190
|
+
return styled.css(["width:100%;color:#c2c4c9;font-size:14px;font-weight:400;line-height:20px;text-decoration:none;outline:none;cursor:pointer;background-color:#1b2638;margin-top:", ";&[aria-current]{background-color:#2f394a;color:", ";}&.MuiAccordion-root:before{background-color:#1b2638;}&.MuiPaper-elevation0{border:0px;}&.MuiAccordion-root.Mui-expanded{margin-top:", ";}"], gutter ? '16px' : '0', ui.Color.White, gutter ? '16px' : '0');
|
|
1191
1191
|
});
|
|
1192
1192
|
var NavbarAccordionSummary = /*#__PURE__*/styled__default(core.AccordionSummary).withConfig({
|
|
1193
1193
|
displayName: "NavbarAccordion__NavbarAccordionSummary",
|
|
1194
1194
|
componentId: "SD__sc-1s7g3kw-2"
|
|
1195
|
-
})(["border-left:4px solid transparent;padding-left:20px;&.MuiAccordionSummary-root{max-height:40px;min-height:40px;}&:hover,&[data-active='true']{border-left-color:", ";}&[data-expanded='false']{.MuiAccordionSummary-expandIcon{display:none;}}"], ui.Color.Blue300);
|
|
1195
|
+
})(["border-left:4px solid transparent;padding-left:20px;&.MuiAccordionSummary-root{max-height:40px;min-height:40px;}&:hover,&[data-active='true']{background-color:#2f394a;border-left-color:", ";}&[data-expanded='false']{.MuiAccordionSummary-expandIcon{display:none;}}"], ui.Color.Blue300);
|
|
1196
1196
|
var IconWrapper$2 = /*#__PURE__*/styled__default.div.withConfig({
|
|
1197
1197
|
displayName: "NavbarAccordion__IconWrapper",
|
|
1198
1198
|
componentId: "SD__sc-1s7g3kw-3"
|
|
@@ -1586,7 +1586,7 @@ function NavbarMenu(_ref2) {
|
|
|
1586
1586
|
var SidebarRoot = /*#__PURE__*/styled__default.aside.withConfig({
|
|
1587
1587
|
displayName: "Sidebar__SidebarRoot",
|
|
1588
1588
|
componentId: "SD__sc-b77o22-0"
|
|
1589
|
-
})(["top:0;position:sticky;overflow-y:auto;overflow-x:hidden;
|
|
1589
|
+
})(["top:0;position:sticky;overflow-y:auto;overflow-x:hidden;height:100vh;background-color:", ";border-right:1px solid ", ";"], ui.Color.White, ui.Color.Silver400);
|
|
1590
1590
|
var SidebarHeader = /*#__PURE__*/styled__default.div.withConfig({
|
|
1591
1591
|
displayName: "Sidebar__SidebarHeader",
|
|
1592
1592
|
componentId: "SD__sc-b77o22-1"
|
|
@@ -1638,28 +1638,187 @@ var Sidebar = /*#__PURE__*/react.forwardRef((_ref, ref) => {
|
|
|
1638
1638
|
});
|
|
1639
1639
|
if (process.env.NODE_ENV !== "production") Sidebar.displayName = "Sidebar";
|
|
1640
1640
|
|
|
1641
|
-
var
|
|
1642
|
-
|
|
1641
|
+
var Context = /*#__PURE__*/react.createContext(null);
|
|
1642
|
+
function useSidebarContext() {
|
|
1643
|
+
var context = react.useContext(Context);
|
|
1644
|
+
|
|
1645
|
+
if (!context) {
|
|
1646
|
+
throw new Error('SidebarContext is used outside Provider');
|
|
1647
|
+
}
|
|
1648
|
+
|
|
1649
|
+
return context;
|
|
1650
|
+
}
|
|
1651
|
+
var SidebarContainerSidebar = /*#__PURE__*/styled__default.div.withConfig({
|
|
1652
|
+
displayName: "SidebarContainer__SidebarContainerSidebar",
|
|
1643
1653
|
componentId: "SD__sc-uibj1m-0"
|
|
1644
|
-
})(["
|
|
1654
|
+
})(["height:inherit;max-height:inherit;min-height:inherit;width:240px;"]);
|
|
1645
1655
|
var SidebarContainerContent = /*#__PURE__*/styled__default.div.withConfig({
|
|
1646
1656
|
displayName: "SidebarContainer__SidebarContainerContent",
|
|
1647
1657
|
componentId: "SD__sc-uibj1m-1"
|
|
1648
|
-
})(["height:inherit;max-height:inherit;min-height:inherit;
|
|
1658
|
+
})(["height:inherit;max-height:inherit;min-height:inherit;"]);
|
|
1659
|
+
var SidebarContainerRoot = /*#__PURE__*/styled__default.div.withConfig({
|
|
1660
|
+
displayName: "SidebarContainer__SidebarContainerRoot",
|
|
1661
|
+
componentId: "SD__sc-uibj1m-2"
|
|
1662
|
+
})(["display:flex;height:inherit;max-height:inherit;min-height:inherit;& ", "{width:calc(100% - 240px);min-width:calc(100% - 240px);max-width:calc(100% - 240px);}&[data-visibility='sidebar'] ", "{width:100%;}&[data-visibility='sidebar'] ", "{display:none;}&[data-visibility='content'] ", "{display:none;}&[data-visibility='content'] ", "{width:100%;max-width:unset;}"], SidebarContainerContent, SidebarContainerSidebar, SidebarContainerContent, SidebarContainerSidebar, SidebarContainerContent);
|
|
1649
1663
|
var SidebarContainer = /*#__PURE__*/react.forwardRef((_ref, ref) => {
|
|
1650
1664
|
var {
|
|
1651
1665
|
sidebar,
|
|
1652
1666
|
children
|
|
1653
1667
|
} = _ref;
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1668
|
+
var isCollapsed = ui.useCollapseBreakpoint('sm');
|
|
1669
|
+
var [visibilityState, setVisibilityState] = react.useState('sidebar');
|
|
1670
|
+
var visibility = isCollapsed ? visibilityState : 'both';
|
|
1671
|
+
var context = react.useMemo(() => {
|
|
1672
|
+
return {
|
|
1673
|
+
openSidebar: () => {
|
|
1674
|
+
setVisibilityState('sidebar');
|
|
1675
|
+
},
|
|
1676
|
+
openSidebarContent: () => {
|
|
1677
|
+
setVisibilityState('content');
|
|
1678
|
+
}
|
|
1679
|
+
};
|
|
1680
|
+
}, []);
|
|
1681
|
+
return /*#__PURE__*/jsxRuntime.jsx(Context.Provider, {
|
|
1682
|
+
value: context,
|
|
1683
|
+
children: /*#__PURE__*/jsxRuntime.jsxs(SidebarContainerRoot, {
|
|
1684
|
+
ref: ref,
|
|
1685
|
+
"data-visibility": visibility,
|
|
1686
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(SidebarContainerSidebar, {
|
|
1687
|
+
children: sidebar
|
|
1688
|
+
}), /*#__PURE__*/jsxRuntime.jsx(SidebarContainerContent, {
|
|
1689
|
+
children: children
|
|
1690
|
+
})]
|
|
1691
|
+
})
|
|
1659
1692
|
});
|
|
1660
1693
|
});
|
|
1661
1694
|
if (process.env.NODE_ENV !== "production") SidebarContainer.displayName = "SidebarContainer";
|
|
1662
1695
|
|
|
1696
|
+
var _excluded$8 = ["onClick", "children"];
|
|
1697
|
+
function SidebarBackButton(_ref) {
|
|
1698
|
+
var {
|
|
1699
|
+
onClick: _onClick,
|
|
1700
|
+
children = /*#__PURE__*/jsxRuntime.jsx(icons.ArrowBack, {
|
|
1701
|
+
fontSize: "small"
|
|
1702
|
+
})
|
|
1703
|
+
} = _ref,
|
|
1704
|
+
props = _objectWithoutProperties(_ref, _excluded$8);
|
|
1705
|
+
|
|
1706
|
+
var isCollapsed = ui.useCollapseBreakpoint('sm');
|
|
1707
|
+
var {
|
|
1708
|
+
openSidebar
|
|
1709
|
+
} = useSidebarContext();
|
|
1710
|
+
|
|
1711
|
+
if (!isCollapsed) {
|
|
1712
|
+
return null;
|
|
1713
|
+
}
|
|
1714
|
+
|
|
1715
|
+
return /*#__PURE__*/jsxRuntime.jsx(core.IconButton, _objectSpread(_objectSpread({}, props), {}, {
|
|
1716
|
+
size: "small",
|
|
1717
|
+
onClick: event => {
|
|
1718
|
+
_onClick === null || _onClick === void 0 ? void 0 : _onClick(event);
|
|
1719
|
+
|
|
1720
|
+
if (!event.isDefaultPrevented()) {
|
|
1721
|
+
openSidebar();
|
|
1722
|
+
}
|
|
1723
|
+
},
|
|
1724
|
+
children: children
|
|
1725
|
+
}));
|
|
1726
|
+
}
|
|
1727
|
+
|
|
1728
|
+
var SidebarAppBar = /*#__PURE__*/styled__default(core.AppBar).withConfig({
|
|
1729
|
+
displayName: "SidebarContent__SidebarAppBar",
|
|
1730
|
+
componentId: "SD__sc-zpgf61-0"
|
|
1731
|
+
})(_ref => {
|
|
1732
|
+
var {
|
|
1733
|
+
theme
|
|
1734
|
+
} = _ref;
|
|
1735
|
+
return styled.css(["", "{&&{border-left:transparent;}}"], theme.breakpoints.up('sm'));
|
|
1736
|
+
});
|
|
1737
|
+
var ToolbarContent = /*#__PURE__*/styled__default.div.withConfig({
|
|
1738
|
+
displayName: "SidebarContent__ToolbarContent",
|
|
1739
|
+
componentId: "SD__sc-zpgf61-1"
|
|
1740
|
+
})(["flex:1;padding:16px;"]);
|
|
1741
|
+
function SidebarContent(_ref2) {
|
|
1742
|
+
var {
|
|
1743
|
+
dense,
|
|
1744
|
+
action,
|
|
1745
|
+
title,
|
|
1746
|
+
children,
|
|
1747
|
+
onBack,
|
|
1748
|
+
openOnMount,
|
|
1749
|
+
closeOnUnmount
|
|
1750
|
+
} = _ref2;
|
|
1751
|
+
var isOpenedOnMount = react.useRef(false);
|
|
1752
|
+
var isClosedOnMount = react.useRef(false);
|
|
1753
|
+
var {
|
|
1754
|
+
openSidebarContent,
|
|
1755
|
+
openSidebar
|
|
1756
|
+
} = useSidebarContext();
|
|
1757
|
+
react.useLayoutEffect(() => {
|
|
1758
|
+
if (openOnMount) {
|
|
1759
|
+
if (isOpenedOnMount.current) {
|
|
1760
|
+
// eslint-disable-next-line no-console
|
|
1761
|
+
console.warn('[SidebarContent]: "openOnMount" should not change during lifecycle of the component.');
|
|
1762
|
+
} else {
|
|
1763
|
+
isOpenedOnMount.current = true;
|
|
1764
|
+
openSidebarContent();
|
|
1765
|
+
}
|
|
1766
|
+
}
|
|
1767
|
+
}, [openOnMount, openSidebarContent]);
|
|
1768
|
+
react.useLayoutEffect(() => {
|
|
1769
|
+
return () => {
|
|
1770
|
+
if (closeOnUnmount) {
|
|
1771
|
+
if (isClosedOnMount.current) {
|
|
1772
|
+
// eslint-disable-next-line no-console
|
|
1773
|
+
console.warn('[SidebarContent]: "closeOnUnmount" should not change during lifecycle of the component.');
|
|
1774
|
+
} else {
|
|
1775
|
+
isClosedOnMount.current = true;
|
|
1776
|
+
openSidebar();
|
|
1777
|
+
}
|
|
1778
|
+
}
|
|
1779
|
+
};
|
|
1780
|
+
}, [openSidebar, closeOnUnmount]);
|
|
1781
|
+
return /*#__PURE__*/jsxRuntime.jsxs(ui.Stack, {
|
|
1782
|
+
space: "none",
|
|
1783
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(SidebarAppBar, {
|
|
1784
|
+
children: /*#__PURE__*/jsxRuntime.jsx(core.Toolbar, {
|
|
1785
|
+
disableGutters: true,
|
|
1786
|
+
children: /*#__PURE__*/jsxRuntime.jsx(ToolbarContent, {
|
|
1787
|
+
children: /*#__PURE__*/jsxRuntime.jsxs(ui.Columns, {
|
|
1788
|
+
align: ['top', 'center'],
|
|
1789
|
+
space: "small",
|
|
1790
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(ui.Column, {
|
|
1791
|
+
width: "content",
|
|
1792
|
+
children: /*#__PURE__*/jsxRuntime.jsx(SidebarBackButton, {
|
|
1793
|
+
onClick: onBack
|
|
1794
|
+
})
|
|
1795
|
+
}), /*#__PURE__*/jsxRuntime.jsx(ui.Column, {
|
|
1796
|
+
children: /*#__PURE__*/jsxRuntime.jsxs(ui.Columns, {
|
|
1797
|
+
space: "small",
|
|
1798
|
+
collapseBelow: "tablet",
|
|
1799
|
+
reverse: [true, false],
|
|
1800
|
+
align: ['bottom', 'center'],
|
|
1801
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(ui.Column, {
|
|
1802
|
+
children: /*#__PURE__*/jsxRuntime.jsx(TextBox, {
|
|
1803
|
+
variant: "heading-2",
|
|
1804
|
+
children: title
|
|
1805
|
+
})
|
|
1806
|
+
}), action && /*#__PURE__*/jsxRuntime.jsx(ui.Column, {
|
|
1807
|
+
width: "content",
|
|
1808
|
+
children: action
|
|
1809
|
+
})]
|
|
1810
|
+
})
|
|
1811
|
+
})]
|
|
1812
|
+
})
|
|
1813
|
+
})
|
|
1814
|
+
})
|
|
1815
|
+
}), /*#__PURE__*/jsxRuntime.jsx(Box, {
|
|
1816
|
+
padding: dense ? 'none' : ['small', 'medium'],
|
|
1817
|
+
children: children
|
|
1818
|
+
})]
|
|
1819
|
+
});
|
|
1820
|
+
}
|
|
1821
|
+
|
|
1663
1822
|
var SidebarDividerRoot = /*#__PURE__*/styled__default.div.withConfig({
|
|
1664
1823
|
displayName: "SidebarDivider__SidebarDividerRoot",
|
|
1665
1824
|
componentId: "SD__sc-5lwi2i-0"
|
|
@@ -1714,36 +1873,60 @@ var SidebarMenuItem = /*#__PURE__*/react.forwardRef((_ref2, ref) => {
|
|
|
1714
1873
|
var {
|
|
1715
1874
|
action,
|
|
1716
1875
|
avatar,
|
|
1717
|
-
onClick,
|
|
1876
|
+
onClick: _onClick,
|
|
1718
1877
|
external,
|
|
1719
1878
|
children,
|
|
1720
1879
|
disabled,
|
|
1721
1880
|
selected,
|
|
1722
1881
|
secondaryActions,
|
|
1723
|
-
badge: badgeProp
|
|
1882
|
+
badge: badgeProp,
|
|
1883
|
+
openContentOnClick
|
|
1724
1884
|
} = _ref2;
|
|
1725
1885
|
var [hovered, setHovered] = react.useState(false);
|
|
1886
|
+
var rootRef = react.useRef(null);
|
|
1726
1887
|
var actionsRef = react.useRef(null);
|
|
1727
1888
|
var actionsPlaceholderRef = react.useRef(null);
|
|
1889
|
+
var {
|
|
1890
|
+
openSidebarContent
|
|
1891
|
+
} = useSidebarContext();
|
|
1892
|
+
var {
|
|
1893
|
+
matches: isHoverSupported
|
|
1894
|
+
} = matchMedia('(hover: hover)');
|
|
1728
1895
|
react.useLayoutEffect(() => {
|
|
1729
1896
|
if (actionsRef.current && actionsPlaceholderRef.current) {
|
|
1730
1897
|
actionsPlaceholderRef.current.style.width = "".concat(Math.max(0, actionsRef.current.offsetWidth - 8), "px");
|
|
1731
1898
|
}
|
|
1732
1899
|
});
|
|
1900
|
+
react.useLayoutEffect(() => {
|
|
1901
|
+
var rootNode = rootRef.current;
|
|
1902
|
+
|
|
1903
|
+
if (rootNode) {
|
|
1904
|
+
if (isHoverSupported) {
|
|
1905
|
+
rootNode.addEventListener('mouseenter', () => {
|
|
1906
|
+
setHovered(true);
|
|
1907
|
+
});
|
|
1908
|
+
rootNode.addEventListener('mouseleave', () => {
|
|
1909
|
+
setHovered(false);
|
|
1910
|
+
});
|
|
1911
|
+
} else {
|
|
1912
|
+
setHovered(true);
|
|
1913
|
+
}
|
|
1914
|
+
}
|
|
1915
|
+
}, [isHoverSupported]);
|
|
1733
1916
|
var badge = !badgeProp || !Number.isFinite(badgeProp) ? null : badgeProp > 999 ? '999+' : badgeProp;
|
|
1734
1917
|
return /*#__PURE__*/jsxRuntime.jsxs(SidebarMenuItemRoot, {
|
|
1735
|
-
ref: ref,
|
|
1918
|
+
ref: ui.mergeRefs(ref, rootRef),
|
|
1736
1919
|
hasAvatar: !!avatar,
|
|
1737
|
-
onMouseEnter: () => {
|
|
1738
|
-
setHovered(true);
|
|
1739
|
-
},
|
|
1740
|
-
onMouseLeave: () => {
|
|
1741
|
-
setHovered(false);
|
|
1742
|
-
},
|
|
1743
1920
|
children: [/*#__PURE__*/jsxRuntime.jsx(core.ButtonBase, {
|
|
1744
|
-
onClick: onClick,
|
|
1745
1921
|
disabled: disabled,
|
|
1746
1922
|
"aria-current": selected,
|
|
1923
|
+
onClick: event => {
|
|
1924
|
+
_onClick === null || _onClick === void 0 ? void 0 : _onClick(event);
|
|
1925
|
+
|
|
1926
|
+
if (!event.isDefaultPrevented() && openContentOnClick) {
|
|
1927
|
+
openSidebarContent();
|
|
1928
|
+
}
|
|
1929
|
+
},
|
|
1747
1930
|
children: /*#__PURE__*/jsxRuntime.jsxs(ui.Columns, {
|
|
1748
1931
|
align: "center",
|
|
1749
1932
|
space: "xsmall",
|
|
@@ -1856,6 +2039,7 @@ var SidebarMenuItemAvatar = /*#__PURE__*/react.forwardRef((_ref, ref) => {
|
|
|
1856
2039
|
color: "primary",
|
|
1857
2040
|
checked: value,
|
|
1858
2041
|
disabled: disabled,
|
|
2042
|
+
onClick: stopPropagation,
|
|
1859
2043
|
onMouseDown: stopPropagation,
|
|
1860
2044
|
onTouchStart: stopPropagation,
|
|
1861
2045
|
onChange: (_, checked) => {
|
|
@@ -1927,7 +2111,9 @@ exports.NavbarList = NavbarList;
|
|
|
1927
2111
|
exports.NavbarMenu = NavbarMenu;
|
|
1928
2112
|
exports.NavbarMenuItem = NavbarMenuItem;
|
|
1929
2113
|
exports.Sidebar = Sidebar;
|
|
2114
|
+
exports.SidebarBackButton = SidebarBackButton;
|
|
1930
2115
|
exports.SidebarContainer = SidebarContainer;
|
|
2116
|
+
exports.SidebarContent = SidebarContent;
|
|
1931
2117
|
exports.SidebarDivider = SidebarDivider;
|
|
1932
2118
|
exports.SidebarMenuItem = SidebarMenuItem;
|
|
1933
2119
|
exports.SidebarMenuItemAction = SidebarMenuItemAction;
|
|
@@ -1937,4 +2123,5 @@ exports.TextBox = TextBox;
|
|
|
1937
2123
|
exports.formatBytes = formatBytes;
|
|
1938
2124
|
exports.toBytes = toBytes;
|
|
1939
2125
|
exports.useNavbarContext = useNavbarContext;
|
|
2126
|
+
exports.useSidebarContext = useSidebarContext;
|
|
1940
2127
|
//# sourceMappingURL=index.js.map
|