@ndlib/component-library 1.0.42 → 1.0.44

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.
@@ -0,0 +1,24 @@
1
+ .navWrapper {
2
+ justify-content: center;
3
+ padding: 0.75rem;
4
+ border: 1px solid var(--extraLightGray);
5
+ background: var(--white);
6
+ border-radius: 4px;
7
+ margin: 0px 10px 0px 10px;
8
+ }
9
+
10
+ .submenuCol {
11
+ flex-basis: 300px;
12
+ padding: 0.5rem 1rem;
13
+ flex-shrink: 0;
14
+ flex-grow: 0;
15
+ }
16
+
17
+ .leafMenuLink {
18
+ font-weight: 700;
19
+ font-size: 1rem;
20
+ line-height: 1.4;
21
+ font-family: 'Libre Franklin', 'Helvetica Neue', Helvetica, Arial, Verdana,
22
+ sans-serif;
23
+ text-decoration: none;
24
+ }
@@ -0,0 +1,6 @@
1
+ import { NavMenuV2 } from '.';
2
+ import type { Meta, StoryObj } from '@storybook/react';
3
+ declare const meta: Meta<typeof NavMenuV2>;
4
+ export default meta;
5
+ type Story = StoryObj<typeof NavMenuV2>;
6
+ export declare const Default: Story;
@@ -0,0 +1,14 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { UIVersion2 } from '../../../utils/decorators/UIVersion2';
3
+ import { NavMenuV2 } from '.';
4
+ import { DemoMenuImplementationV2 } from './demoV2';
5
+ const meta = {
6
+ title: 'Composites/NavMenuV2',
7
+ component: NavMenuV2,
8
+ decorators: [UIVersion2],
9
+ };
10
+ export default meta;
11
+ export const Default = {
12
+ render: () => _jsx(DemoMenuImplementationV2, {}),
13
+ args: {},
14
+ };
@@ -0,0 +1 @@
1
+ export declare const DemoMenuImplementationV2: () => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,189 @@
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
+ };
12
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
13
+ import { createElement as _createElement } from "react";
14
+ import { NavMenuV2 } from '.';
15
+ import { ButtonV2 } from '../../elements/ButtonV2';
16
+ import { RowV2 } from '../../elements/RowV2';
17
+ import { MENU_ACTION_TYPE, MENU_ORIENTATION, MenuProvider, } from '../../providers/menu';
18
+ const demoMenuV2 = {
19
+ orientation: MENU_ORIENTATION.HORIZONTAL,
20
+ items: [
21
+ {
22
+ id: 'home',
23
+ label: 'home',
24
+ action: {
25
+ type: MENU_ACTION_TYPE.LINK,
26
+ to: '/',
27
+ },
28
+ },
29
+ {
30
+ id: 'research',
31
+ label: 'research',
32
+ action: {
33
+ type: MENU_ACTION_TYPE.SUBMENU,
34
+ submenu: {
35
+ orientation: MENU_ORIENTATION.HORIZONTAL,
36
+ items: [
37
+ {
38
+ label: 'test submenu 1',
39
+ id: 'test-submenu-1',
40
+ action: {
41
+ type: MENU_ACTION_TYPE.SUBMENU,
42
+ submenu: {
43
+ orientation: MENU_ORIENTATION.VERTICAL,
44
+ items: [
45
+ {
46
+ label: 'test leaf 1',
47
+ id: 'test-leaf-1',
48
+ action: {
49
+ type: MENU_ACTION_TYPE.LINK,
50
+ to: '/',
51
+ },
52
+ },
53
+ {
54
+ label: 'test leaf 2',
55
+ id: 'test-leaf-2',
56
+ action: {
57
+ type: MENU_ACTION_TYPE.LINK,
58
+ to: '/',
59
+ },
60
+ },
61
+ ],
62
+ },
63
+ },
64
+ },
65
+ {
66
+ action: {
67
+ type: MENU_ACTION_TYPE.SUBMENU,
68
+ submenu: {
69
+ orientation: MENU_ORIENTATION.VERTICAL,
70
+ items: [
71
+ {
72
+ label: 'test leaf 3',
73
+ id: 'test-leaf-3',
74
+ action: {
75
+ type: MENU_ACTION_TYPE.LINK,
76
+ to: '/',
77
+ },
78
+ },
79
+ {
80
+ label: 'test leaf 4',
81
+ id: 'test-leaf-4',
82
+ action: {
83
+ type: MENU_ACTION_TYPE.LINK,
84
+ to: '/',
85
+ },
86
+ },
87
+ ],
88
+ },
89
+ },
90
+ label: 'test submenu 2',
91
+ id: 'test-submenu-2',
92
+ },
93
+ ],
94
+ },
95
+ },
96
+ },
97
+ {
98
+ id: 'services',
99
+ label: 'services',
100
+ action: {
101
+ type: MENU_ACTION_TYPE.SUBMENU,
102
+ submenu: {
103
+ orientation: MENU_ORIENTATION.HORIZONTAL,
104
+ items: [
105
+ {
106
+ label: 'test submenu 5',
107
+ id: 'test-submenu-5',
108
+ action: {
109
+ type: MENU_ACTION_TYPE.SUBMENU,
110
+ submenu: {
111
+ orientation: MENU_ORIENTATION.VERTICAL,
112
+ items: [
113
+ {
114
+ label: 'test leaf 1',
115
+ id: 'test-leaf-1',
116
+ action: {
117
+ type: MENU_ACTION_TYPE.LINK,
118
+ to: '/',
119
+ },
120
+ },
121
+ {
122
+ label: 'test leaf 2',
123
+ id: 'test-leaf-2',
124
+ action: {
125
+ type: MENU_ACTION_TYPE.LINK,
126
+ to: '/',
127
+ },
128
+ },
129
+ ],
130
+ },
131
+ },
132
+ },
133
+ {
134
+ action: {
135
+ type: MENU_ACTION_TYPE.SUBMENU,
136
+ submenu: {
137
+ orientation: MENU_ORIENTATION.VERTICAL,
138
+ items: [
139
+ {
140
+ label: 'test leaf 3',
141
+ id: 'test-leaf-3',
142
+ action: {
143
+ type: MENU_ACTION_TYPE.LINK,
144
+ to: '/',
145
+ },
146
+ },
147
+ {
148
+ label: 'test leaf 4',
149
+ id: 'test-leaf-4',
150
+ action: {
151
+ type: MENU_ACTION_TYPE.LINK,
152
+ to: '/',
153
+ },
154
+ },
155
+ {
156
+ label: 'test leaf 5',
157
+ id: 'test-leaf-5',
158
+ action: {
159
+ type: MENU_ACTION_TYPE.LINK,
160
+ to: '/',
161
+ },
162
+ },
163
+ {
164
+ label: 'test leaf 6',
165
+ id: 'test-leaf-6',
166
+ action: {
167
+ type: MENU_ACTION_TYPE.LINK,
168
+ to: '/',
169
+ },
170
+ },
171
+ ],
172
+ },
173
+ },
174
+ label: 'test submenu 6',
175
+ id: 'test-submenu-6',
176
+ },
177
+ ],
178
+ },
179
+ },
180
+ },
181
+ ],
182
+ };
183
+ export const DemoMenuImplementationV2 = () => (_jsx(MenuProvider, Object.assign({ menu: demoMenuV2 }, { children: ({ menu, getMenuProps, getMenuItemProps }) => {
184
+ const getPropsWithoutStyle = (props) => {
185
+ const { style: _style } = props, propsWithoutStyle = __rest(props, ["style"]);
186
+ return propsWithoutStyle;
187
+ };
188
+ return (_jsxs(_Fragment, { children: [_jsx(RowV2, Object.assign({}, getMenuProps(), { children: menu.items.map((menuItem) => (_createElement(ButtonV2, Object.assign({}, getPropsWithoutStyle(getMenuItemProps([menuItem.id])), { sx: { margin: '4px' }, key: menuItem.id }), menuItem.label))) })), _jsx(NavMenuV2, {})] }));
189
+ } })));
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ import { StyledElementPropsV2 } from '../../../theme';
3
+ type NavMenuV2Props = StyledElementPropsV2<HTMLDivElement>;
4
+ export declare const NavMenuV2: React.FC<NavMenuV2Props>;
5
+ export {};
@@ -0,0 +1,56 @@
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
+ };
12
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
+ import _ChevronRightIcon from '@mui/icons-material/ChevronRight';
14
+ import { ArrowLinkV2 } from '../../elements/ArrowLinkV2';
15
+ import { ListV2, ListItemV2 } from '../../elements/ListV2';
16
+ import { MENU_ACTION_TYPE, useMenu } from '../../providers/menu';
17
+ import { RowV2 } from '../../elements/RowV2';
18
+ import { ColumnV2 } from '../../elements/ColumnV2';
19
+ import { HEADINGV2_SIZE, HeadingV2 } from '../../elements/HeadingV2';
20
+ import { FONT_SIZE } from '../../../theme/typography';
21
+ import { importedDefaultComponentShim } from '../../../utils/misc';
22
+ import * as styles from './NavMenuV2.module.css';
23
+ const typeSafeStyles = styles;
24
+ const ChevronRightIcon = importedDefaultComponentShim(_ChevronRightIcon);
25
+ export const NavMenuV2 = (props) => {
26
+ const { sx } = props, rest = __rest(props, ["sx"]);
27
+ const { isOpen, activePath, getMenuItem, getMenuItemProps, getMenuProps } = useMenu();
28
+ if (!isOpen) {
29
+ return null;
30
+ }
31
+ const topLevelMenuId = activePath[0];
32
+ const activeTopLevelMenu = getMenuItem([topLevelMenuId]);
33
+ if (!activeTopLevelMenu ||
34
+ !(activeTopLevelMenu.action.type === MENU_ACTION_TYPE.SUBMENU)) {
35
+ return null;
36
+ }
37
+ const submenu = activeTopLevelMenu.action.submenu;
38
+ const getPropsWithoutStyle = (propsFn) => {
39
+ const _a = propsFn(), { style: _style } = _a, propsWithoutStyle = __rest(_a, ["style"]);
40
+ return propsWithoutStyle;
41
+ };
42
+ return (_jsxs(RowV2, Object.assign({ className: typeSafeStyles.navWrapper, sx: sx }, rest, { children: [_jsx(ColumnV2, { sx: { flexGrow: 1 } }), submenu.items.map((submenuItem, i) => {
43
+ if (!(submenuItem.action.type === MENU_ACTION_TYPE.SUBMENU)) {
44
+ return null;
45
+ }
46
+ const leafMenuItems = submenuItem.action.submenu.items;
47
+ const submenuPath = [topLevelMenuId, submenuItem.id];
48
+ const link = '//' + document.location.host + topLevelMenuId;
49
+ const category = topLevelMenuId.charAt(1).toUpperCase() + topLevelMenuId.slice(2);
50
+ return (_jsxs(ColumnV2, Object.assign({ className: typeSafeStyles.submenuCol }, { children: [_jsx("div", Object.assign({}, getPropsWithoutStyle(() => getMenuItemProps(submenuPath)), { children: _jsx(HeadingV2, Object.assign({ standalone: true, size: HEADINGV2_SIZE.SM, underline: true }, { children: submenuItem.label })) })), _jsx(ListV2, Object.assign({}, getPropsWithoutStyle(() => getMenuProps(submenuPath)), { icon: ChevronRightIcon, iconSize: FONT_SIZE.MS }, { children: leafMenuItems.map((leafMenuItem, i) => {
51
+ var _a;
52
+ const leafMenuPath = submenuPath.concat(leafMenuItem.id);
53
+ return (_jsx(ListItemV2, Object.assign({ index: i, sx: { mt: 2 } }, getPropsWithoutStyle(() => getMenuItemProps(leafMenuPath)), { children: _jsx("a", Object.assign({ href: (_a = leafMenuItem === null || leafMenuItem === void 0 ? void 0 : leafMenuItem.action) === null || _a === void 0 ? void 0 : _a.to, className: typeSafeStyles.leafMenuLink, tabIndex: -1 }, { children: leafMenuItem.label })) }), leafMenuItem.id));
54
+ }) })), i < 1 && (link.includes('esearch') || link.includes('ervices')) ? (_jsxs(ArrowLinkV2, Object.assign({ to: link, sx: { m: '20px 10px 10px 10px' } }, { children: ["View More ", category] }))) : null] }), submenuItem.id));
55
+ }), _jsx(ColumnV2, { sx: { flexGrow: 1 } })] })));
56
+ };
@@ -0,0 +1,47 @@
1
+ .arrowLinkWrapper {
2
+ text-decoration: none;
3
+ display: inline-flex;
4
+ white-space: nowrap;
5
+ padding: 0;
6
+ flex-grow: 0;
7
+ position: relative;
8
+ box-sizing: border-box;
9
+ background: var(--white);
10
+ color: var(--primary);
11
+ font-weight: 700;
12
+ font-size: 1rem;
13
+ line-height: 1.4;
14
+ font-family: 'Libre Franklin', 'Helvetica Neue', Helvetica, Arial, Verdana,
15
+ sans-serif;
16
+
17
+ &:hover {
18
+ transform: scale(1.02);
19
+ background: var(--extraExtraLightGray);
20
+ }
21
+
22
+ &:hover > svg {
23
+ fill: var(--extraExtraLightGray);
24
+ }
25
+
26
+ & > svg {
27
+ fill: var(--white);
28
+ }
29
+ }
30
+
31
+ .arrowLinkInnerWrapper {
32
+ position: relative;
33
+ border: 1px solid #a7a7a7;
34
+ border-width: 1px 0 2px 1px;
35
+ box-sizing: border-box;
36
+ padding: 0.125rem 1.5rem 0.125rem 0.5rem;
37
+ height: 100%;
38
+ flex: 1 1 auto;
39
+ }
40
+
41
+ .arrow {
42
+ width: 16px;
43
+ right: -16px;
44
+ position: absolute;
45
+ top: 0;
46
+ height: 100%;
47
+ }
@@ -0,0 +1,6 @@
1
+ import type { Meta, StoryObj } from '@storybook/react';
2
+ import { ArrowLinkV2 } from '.';
3
+ declare const meta: Meta<typeof ArrowLinkV2>;
4
+ export default meta;
5
+ type Story = StoryObj<typeof ArrowLinkV2>;
6
+ export declare const Default: Story;
@@ -0,0 +1,14 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { ArrowLinkV2 } from '.';
3
+ import { ColumnV2 } from '../ColumnV2';
4
+ import { BoxV2 } from '../BoxV2';
5
+ import { UIVersion2 } from '../../../utils/decorators/UIVersion2';
6
+ const meta = {
7
+ title: 'Elements/ArrowLinkV2',
8
+ component: ArrowLinkV2,
9
+ decorators: [UIVersion2],
10
+ };
11
+ export default meta;
12
+ export const Default = {
13
+ render: () => (_jsx(ColumnV2, { children: _jsx(BoxV2, { children: _jsx(ArrowLinkV2, Object.assign({ to: "/" }, { children: "Click Me" })) }) })),
14
+ };
@@ -0,0 +1,7 @@
1
+ /// <reference types="react" />
2
+ import { StyledElementPropsV2 } from '../../../theme';
3
+ type ArrowLinkV2Props = StyledElementPropsV2<HTMLAnchorElement, {
4
+ to: string;
5
+ }>;
6
+ export declare const ArrowLinkV2: React.FC<ArrowLinkV2Props>;
7
+ export {};
@@ -0,0 +1,21 @@
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
+ };
12
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
+ import { processSx } from '../../../utils/processSx';
14
+ import { BoxV2 } from '../BoxV2';
15
+ import * as styles from './ArrowLinkV2.module.css';
16
+ const typeSafeStyles = styles;
17
+ export const ArrowLinkV2 = (_a) => {
18
+ var { to, children, sx } = _a, rest = __rest(_a, ["to", "children", "sx"]);
19
+ const processedSx = processSx(sx);
20
+ return (_jsxs("a", Object.assign({ href: to, className: typeSafeStyles.arrowLinkWrapper, style: processedSx }, rest, { children: [_jsx(BoxV2, Object.assign({ className: typeSafeStyles.arrowLinkInnerWrapper }, { children: children })), _jsxs("svg", Object.assign({ viewBox: "0 0 16 1", preserveAspectRatio: "none", className: typeSafeStyles.arrow }, { children: [_jsx("path", { d: "M0,0 0,0 16,0.5 0,1 0,1z" }), _jsx("line", { x1: "0", x2: "16", y1: "0", y2: "0.5", stroke: "#a7a7a7", strokeWidth: "0.05", strokeLinecap: "butt" }), _jsx("line", { x1: "0", x2: "16", y1: "1", y2: "0.5", stroke: "#a7a7a7", strokeWidth: "0.1", strokeLinecap: "butt" })] }))] })));
21
+ };
package/dist/index.d.ts CHANGED
@@ -7,6 +7,7 @@ export { GlobalStyles } from './theme/GlobalStyles';
7
7
  export { Alert, Alerts } from './components/elements/Alerts';
8
8
  export { AlertV2, AlertsV2 } from './components/elements/AlertsV2';
9
9
  export { ArrowLink } from './components/elements/ArrowLink';
10
+ export { ArrowLinkV2 } from './components/elements/ArrowLinkV2';
10
11
  export { BrandingBar } from './components/elements/BrandingBar';
11
12
  export { BrandingBarV2 } from './components/elements/BrandingBarV2';
12
13
  export { Button, BUTTON_SIZE, BUTTON_TYPE, LinkButton, } from './components/elements/Button';
@@ -66,6 +67,7 @@ export { Card, CARD_SIZE, CARD_LAYOUT } from './components/composites/Card';
66
67
  export { CardV2, CARDV2_SIZE, CARDV2_LAYOUT, } from './components/composites/CardV2';
67
68
  export { SnackBar } from './components/composites/SnackBar';
68
69
  export { NavMenu } from './components/composites/NavMenu';
70
+ export { NavMenuV2 } from './components/composites/NavMenuV2';
69
71
  export { EmptyState, EMPTY_STATE_SIZE, } from './components/composites/EmptyState';
70
72
  export { DropdownLinks } from './components/composites/DropdownLinks';
71
73
  export { Modal } from './components/composites/Modal';
package/dist/index.js CHANGED
@@ -6,6 +6,7 @@ export { GlobalStyles } from './theme/GlobalStyles';
6
6
  export { Alert, Alerts } from './components/elements/Alerts';
7
7
  export { AlertV2, AlertsV2 } from './components/elements/AlertsV2';
8
8
  export { ArrowLink } from './components/elements/ArrowLink';
9
+ export { ArrowLinkV2 } from './components/elements/ArrowLinkV2';
9
10
  export { BrandingBar } from './components/elements/BrandingBar';
10
11
  export { BrandingBarV2 } from './components/elements/BrandingBarV2';
11
12
  export { Button, BUTTON_SIZE, BUTTON_TYPE, LinkButton, } from './components/elements/Button';
@@ -65,6 +66,7 @@ export { Card, CARD_SIZE, CARD_LAYOUT } from './components/composites/Card';
65
66
  export { CardV2, CARDV2_SIZE, CARDV2_LAYOUT, } from './components/composites/CardV2';
66
67
  export { SnackBar } from './components/composites/SnackBar';
67
68
  export { NavMenu } from './components/composites/NavMenu';
69
+ export { NavMenuV2 } from './components/composites/NavMenuV2';
68
70
  export { EmptyState, EMPTY_STATE_SIZE, } from './components/composites/EmptyState';
69
71
  export { DropdownLinks } from './components/composites/DropdownLinks';
70
72
  export { Modal } from './components/composites/Modal';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ndlib/component-library",
3
- "version": "1.0.42",
3
+ "version": "1.0.44",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "files": [