@ndlib/component-library 0.0.91 → 0.0.93
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/components/composites/NavMenu/index.js +13 -8
- package/dist/components/elements/Dropdown/Dropdown.stories.d.ts +1 -0
- package/dist/components/elements/Dropdown/Dropdown.stories.js +4 -0
- package/dist/components/elements/Dropdown/index.d.ts +2 -0
- package/dist/components/elements/Dropdown/index.js +2 -7
- package/package.json +1 -1
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
1
12
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
13
|
import _ChevronRightIcon from '@mui/icons-material/ChevronRight';
|
|
3
14
|
import { ArrowLink } from '../../elements/ArrowLink';
|
|
@@ -12,6 +23,7 @@ import { COLOR } from '../../../theme/colors';
|
|
|
12
23
|
import { importedDefaultComponentShim } from '../../../utils/misc';
|
|
13
24
|
const ChevronRightIcon = importedDefaultComponentShim(_ChevronRightIcon);
|
|
14
25
|
export const NavMenu = (props) => {
|
|
26
|
+
const { sx } = props, rest = __rest(props, ["sx"]);
|
|
15
27
|
const { isOpen, activePath, getMenuItem, getMenuItemProps, getMenuProps } = useMenu();
|
|
16
28
|
if (!isOpen) {
|
|
17
29
|
return null;
|
|
@@ -23,14 +35,7 @@ export const NavMenu = (props) => {
|
|
|
23
35
|
return null;
|
|
24
36
|
}
|
|
25
37
|
const submenu = activeTopLevelMenu.action.submenu;
|
|
26
|
-
return (_jsxs(Row, Object.assign({},
|
|
27
|
-
justifyContent: 'center',
|
|
28
|
-
p: 3,
|
|
29
|
-
border: 'solid 1px',
|
|
30
|
-
borderColor: COLOR.EXTRA_LIGHT_GRAY,
|
|
31
|
-
borderRadius: '4px',
|
|
32
|
-
margin: '0px 10px 0px 10px',
|
|
33
|
-
} }, { children: [_jsx(Column, { sx: { flexGrow: 1 } }), submenu.items.map((submenuItem, i) => {
|
|
38
|
+
return (_jsxs(Row, Object.assign({}, rest, { sx: Object.assign({ justifyContent: 'center', p: 3, border: 'solid 1px', borderColor: COLOR.EXTRA_LIGHT_GRAY, bg: COLOR.WHITE, borderRadius: '4px', margin: '0px 10px 0px 10px' }, sx) }, { children: [_jsx(Column, { sx: { flexGrow: 1 } }), submenu.items.map((submenuItem, i) => {
|
|
34
39
|
if (!(submenuItem.action.type === MENU_ACTION_TYPE.SUBMENU)) {
|
|
35
40
|
return null;
|
|
36
41
|
}
|
|
@@ -4,6 +4,7 @@ import { Button } from '../../elements/Button';
|
|
|
4
4
|
import { Box } from '../../elements/layout/Box';
|
|
5
5
|
import { Dropdown } from '.';
|
|
6
6
|
import { Paragraph } from '../text/Paragraph';
|
|
7
|
+
import { Column } from '../layout/Column';
|
|
7
8
|
const meta = {
|
|
8
9
|
title: 'Elements/Dropdown',
|
|
9
10
|
component: Dropdown,
|
|
@@ -18,3 +19,6 @@ export const Default = {
|
|
|
18
19
|
export const MatchWidth = {
|
|
19
20
|
render: () => (_jsx(Box, Object.assign({ sx: { width: '200px', height: '200px' } }, { children: _jsx(Dropdown, { matchWidth: true, renderAnchor: ({ anchorProps }) => (_jsx(Button, Object.assign({}, anchorProps, { rightIcon: ArrowDropDownIcon }, { children: "Open Dropdown" }))), renderDropdown: () => _jsx(Paragraph, { children: lorem }) }) }))),
|
|
20
21
|
};
|
|
22
|
+
export const ForcePlacement = {
|
|
23
|
+
render: () => (_jsx(Column, Object.assign({ sx: { width: '200x', height: '100vh' }, justify: "flex-end" }, { children: _jsx(Dropdown, { allowedPlacements: ['bottom-start'], renderAnchor: ({ anchorProps }) => (_jsx(Button, Object.assign({}, anchorProps, { rightIcon: ArrowDropDownIcon }, { children: "Open Dropdown" }))), renderDropdown: () => _jsx(Paragraph, { children: lorem }) }) }))),
|
|
24
|
+
};
|
|
@@ -13,11 +13,13 @@ type DropdownRenderFn = (params: {
|
|
|
13
13
|
setIsOpen: (isOpen: boolean) => void;
|
|
14
14
|
id: string;
|
|
15
15
|
}) => React.ReactNode;
|
|
16
|
+
type Placement = 'top-start' | 'bottom-start' | 'top-end' | 'bottom-end';
|
|
16
17
|
type DropdownProps = StyledElementProps<HTMLDivElement, {
|
|
17
18
|
renderAnchor: AnchorRenderFn;
|
|
18
19
|
renderDropdown: DropdownRenderFn;
|
|
19
20
|
shouldRenderDropdownContainer?: boolean;
|
|
20
21
|
matchWidth?: boolean;
|
|
22
|
+
allowedPlacements?: Placement[];
|
|
21
23
|
}>;
|
|
22
24
|
export declare const Overlay: React.FC<StyledElementProps<HTMLDivElement>>;
|
|
23
25
|
export declare const Dropdown: React.FC<DropdownProps>;
|
|
@@ -26,7 +26,7 @@ export const Overlay = (props) => (_jsx(Box, Object.assign({}, props, { sx: {
|
|
|
26
26
|
zIndex: Z_INDEX.ELEVATED,
|
|
27
27
|
} })));
|
|
28
28
|
export const Dropdown = (_a) => {
|
|
29
|
-
var { renderAnchor, renderDropdown, matchWidth, shouldRenderDropdownContainer = true } = _a, rest = __rest(_a, ["renderAnchor", "renderDropdown", "matchWidth", "shouldRenderDropdownContainer"]);
|
|
29
|
+
var { renderAnchor, renderDropdown, matchWidth, shouldRenderDropdownContainer = true, allowedPlacements = ['top-start', 'bottom-start', 'top-end', 'bottom-end'] } = _a, rest = __rest(_a, ["renderAnchor", "renderDropdown", "matchWidth", "shouldRenderDropdownContainer", "allowedPlacements"]);
|
|
30
30
|
const [isOpen, setIsOpen] = useState(false);
|
|
31
31
|
const [dropdownMinWidth, setDropdownMinWidth] = useState('0px');
|
|
32
32
|
const [dropdownMaxWidth, setDropdownMaxWidth] = useState();
|
|
@@ -46,12 +46,7 @@ export const Dropdown = (_a) => {
|
|
|
46
46
|
},
|
|
47
47
|
}),
|
|
48
48
|
autoPlacement({
|
|
49
|
-
allowedPlacements
|
|
50
|
-
'top-start',
|
|
51
|
-
'bottom-start',
|
|
52
|
-
'top-end',
|
|
53
|
-
'bottom-end',
|
|
54
|
-
],
|
|
49
|
+
allowedPlacements,
|
|
55
50
|
}),
|
|
56
51
|
],
|
|
57
52
|
});
|