@ndlib/component-library 0.0.7-9.1
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/README.md +101 -0
- package/dist/FontLoader.d.ts +1 -0
- package/dist/FontLoader.js +4 -0
- package/dist/components/composites/Card/Card.stories.d.ts +13 -0
- package/dist/components/composites/Card/Card.stories.js +122 -0
- package/dist/components/composites/Card/Card.test.d.ts +1 -0
- package/dist/components/composites/Card/Card.test.js +37 -0
- package/dist/components/composites/Card/index.d.ts +36 -0
- package/dist/components/composites/Card/index.js +89 -0
- package/dist/components/composites/DragDropList/DragDropList.stories.d.ts +7 -0
- package/dist/components/composites/DragDropList/DragDropList.stories.js +32 -0
- package/dist/components/composites/DragDropList/index.d.ts +25 -0
- package/dist/components/composites/DragDropList/index.js +48 -0
- package/dist/components/composites/DropdownLinks/DropdownLinks.stories.d.ts +8 -0
- package/dist/components/composites/DropdownLinks/DropdownLinks.stories.js +25 -0
- package/dist/components/composites/DropdownLinks/DropdownLinks.test.d.ts +1 -0
- package/dist/components/composites/DropdownLinks/DropdownLinks.test.js +27 -0
- package/dist/components/composites/DropdownLinks/index.d.ts +15 -0
- package/dist/components/composites/DropdownLinks/index.js +28 -0
- package/dist/components/composites/EmptyState/EmptyState.stories.d.ts +10 -0
- package/dist/components/composites/EmptyState/EmptyState.stories.js +31 -0
- package/dist/components/composites/EmptyState/EmptyState.test.d.ts +1 -0
- package/dist/components/composites/EmptyState/EmptyState.test.js +20 -0
- package/dist/components/composites/EmptyState/index.d.ts +15 -0
- package/dist/components/composites/EmptyState/index.js +32 -0
- package/dist/components/composites/Modal/Modal.stories.d.ts +6 -0
- package/dist/components/composites/Modal/Modal.stories.js +40 -0
- package/dist/components/composites/Modal/index.d.ts +21 -0
- package/dist/components/composites/Modal/index.js +64 -0
- package/dist/components/composites/NavMenu/NavMenu.stories.d.ts +6 -0
- package/dist/components/composites/NavMenu/NavMenu.stories.js +12 -0
- package/dist/components/composites/NavMenu/NavMenu.test.d.ts +1 -0
- package/dist/components/composites/NavMenu/NavMenu.test.js +96 -0
- package/dist/components/composites/NavMenu/demo.d.ts +1 -0
- package/dist/components/composites/NavMenu/demo.js +172 -0
- package/dist/components/composites/NavMenu/index.d.ts +5 -0
- package/dist/components/composites/NavMenu/index.js +52 -0
- package/dist/components/composites/Seo/SeoDataDisplay/index.d.ts +2 -0
- package/dist/components/composites/Seo/SeoDataDisplay/index.js +9 -0
- package/dist/components/composites/Seo/index.d.ts +11 -0
- package/dist/components/composites/Seo/index.js +16 -0
- package/dist/components/composites/Seo/seo.stories.d.ts +6 -0
- package/dist/components/composites/Seo/seo.stories.js +12 -0
- package/dist/components/composites/Seo/seo.test.d.ts +1 -0
- package/dist/components/composites/Seo/seo.test.js +56 -0
- package/dist/components/composites/Seo/siteMetadata.d.ts +9 -0
- package/dist/components/composites/Seo/siteMetadata.js +16 -0
- package/dist/components/composites/SnackBar/SnackBar.stories.d.ts +8 -0
- package/dist/components/composites/SnackBar/SnackBar.stories.js +20 -0
- package/dist/components/composites/SnackBar/SnackBar.test.d.ts +1 -0
- package/dist/components/composites/SnackBar/SnackBar.test.js +75 -0
- package/dist/components/composites/SnackBar/examples.d.ts +3 -0
- package/dist/components/composites/SnackBar/examples.js +35 -0
- package/dist/components/composites/SnackBar/index.d.ts +1 -0
- package/dist/components/composites/SnackBar/index.js +45 -0
- package/dist/components/composites/StructuredData/StructuredData.stories.d.ts +6 -0
- package/dist/components/composites/StructuredData/StructuredData.stories.js +12 -0
- package/dist/components/composites/StructuredData/StructuredData.test.d.ts +1 -0
- package/dist/components/composites/StructuredData/StructuredData.test.js +48 -0
- package/dist/components/composites/StructuredData/StructuredDataDisplay/index.d.ts +2 -0
- package/dist/components/composites/StructuredData/StructuredDataDisplay/index.js +37 -0
- package/dist/components/composites/StructuredData/index.d.ts +38 -0
- package/dist/components/composites/StructuredData/index.js +58 -0
- package/dist/components/composites/StructuredData/sdEvent/index.d.ts +13 -0
- package/dist/components/composites/StructuredData/sdEvent/index.js +16 -0
- package/dist/components/composites/StructuredData/sdEvent/makeEventSchema.d.ts +15 -0
- package/dist/components/composites/StructuredData/sdEvent/makeEventSchema.js +16 -0
- package/dist/components/composites/StructuredData/sdNews/index.d.ts +11 -0
- package/dist/components/composites/StructuredData/sdNews/index.js +14 -0
- package/dist/components/composites/StructuredData/sdNews/makeNewsSchema.d.ts +12 -0
- package/dist/components/composites/StructuredData/sdNews/makeNewsSchema.js +11 -0
- package/dist/components/composites/StructuredData/sdWebsite/index.d.ts +8 -0
- package/dist/components/composites/StructuredData/sdWebsite/index.js +11 -0
- package/dist/components/composites/StructuredData/sdWebsite/makeWebPageSchema.d.ts +9 -0
- package/dist/components/composites/StructuredData/sdWebsite/makeWebPageSchema.js +9 -0
- package/dist/components/composites/StructuredData/siteMetadata.d.ts +9 -0
- package/dist/components/composites/StructuredData/siteMetadata.js +12 -0
- package/dist/components/elements/Alerts/Alert.stories.d.ts +9 -0
- package/dist/components/elements/Alerts/Alert.stories.js +41 -0
- package/dist/components/elements/Alerts/Alerts.stories.d.ts +6 -0
- package/dist/components/elements/Alerts/Alerts.stories.js +12 -0
- package/dist/components/elements/Alerts/Alerts.test.d.ts +1 -0
- package/dist/components/elements/Alerts/Alerts.test.js +61 -0
- package/dist/components/elements/Alerts/index.d.ts +14 -0
- package/dist/components/elements/Alerts/index.js +64 -0
- package/dist/components/elements/ArrowLink/ArrowLink.stories.d.ts +6 -0
- package/dist/components/elements/ArrowLink/ArrowLink.stories.js +12 -0
- package/dist/components/elements/ArrowLink/ArrowLink.test.d.ts +1 -0
- package/dist/components/elements/ArrowLink/ArrowLink.test.js +34 -0
- package/dist/components/elements/ArrowLink/index.d.ts +7 -0
- package/dist/components/elements/ArrowLink/index.js +39 -0
- package/dist/components/elements/BrandingBar/BrandingBar.stories.d.ts +6 -0
- package/dist/components/elements/BrandingBar/BrandingBar.stories.js +11 -0
- package/dist/components/elements/BrandingBar/index.d.ts +2 -0
- package/dist/components/elements/BrandingBar/index.js +52 -0
- package/dist/components/elements/Button/Button.stories.d.ts +15 -0
- package/dist/components/elements/Button/Button.stories.js +88 -0
- package/dist/components/elements/Button/Button.test.d.ts +1 -0
- package/dist/components/elements/Button/Button.test.js +39 -0
- package/dist/components/elements/Button/index.d.ts +49 -0
- package/dist/components/elements/Button/index.js +138 -0
- package/dist/components/elements/Dropdown/Dropdown.stories.d.ts +7 -0
- package/dist/components/elements/Dropdown/Dropdown.stories.js +20 -0
- package/dist/components/elements/Dropdown/index.d.ts +24 -0
- package/dist/components/elements/Dropdown/index.js +87 -0
- package/dist/components/elements/Fields/AutoComplete/AutoComplete.stories.d.ts +6 -0
- package/dist/components/elements/Fields/AutoComplete/AutoComplete.stories.js +60 -0
- package/dist/components/elements/Fields/AutoComplete/index.d.ts +11 -0
- package/dist/components/elements/Fields/AutoComplete/index.js +26 -0
- package/dist/components/elements/Fields/Checkbox/Checkbox.stories.d.ts +6 -0
- package/dist/components/elements/Fields/Checkbox/Checkbox.stories.js +17 -0
- package/dist/components/elements/Fields/Checkbox/index.d.ts +8 -0
- package/dist/components/elements/Fields/Checkbox/index.js +22 -0
- package/dist/components/elements/Fields/CheckboxGroup/CheckboxGroup.stories.d.ts +7 -0
- package/dist/components/elements/Fields/CheckboxGroup/CheckboxGroup.stories.js +26 -0
- package/dist/components/elements/Fields/CheckboxGroup/index.d.ts +16 -0
- package/dist/components/elements/Fields/CheckboxGroup/index.js +49 -0
- package/dist/components/elements/Fields/DatePicker/DatePicker.stories.d.ts +8 -0
- package/dist/components/elements/Fields/DatePicker/DatePicker.stories.js +31 -0
- package/dist/components/elements/Fields/DatePicker/index.d.ts +20 -0
- package/dist/components/elements/Fields/DatePicker/index.js +48 -0
- package/dist/components/elements/Fields/MonthPicker/MonthPicker.stories.d.ts +7 -0
- package/dist/components/elements/Fields/MonthPicker/MonthPicker.stories.js +20 -0
- package/dist/components/elements/Fields/MonthPicker/index.d.ts +13 -0
- package/dist/components/elements/Fields/MonthPicker/index.js +24 -0
- package/dist/components/elements/Fields/Radio/Radio.stories.d.ts +6 -0
- package/dist/components/elements/Fields/Radio/Radio.stories.js +17 -0
- package/dist/components/elements/Fields/Radio/index.d.ts +8 -0
- package/dist/components/elements/Fields/Radio/index.js +22 -0
- package/dist/components/elements/Fields/RadioGroup/RadioGroup.stories.d.ts +6 -0
- package/dist/components/elements/Fields/RadioGroup/RadioGroup.stories.js +23 -0
- package/dist/components/elements/Fields/RadioGroup/index.d.ts +14 -0
- package/dist/components/elements/Fields/RadioGroup/index.js +28 -0
- package/dist/components/elements/Fields/Select/Select.stories.d.ts +8 -0
- package/dist/components/elements/Fields/Select/Select.stories.js +39 -0
- package/dist/components/elements/Fields/Select/index.d.ts +18 -0
- package/dist/components/elements/Fields/Select/index.js +178 -0
- package/dist/components/elements/Fields/TextInput/TextInput.stories.d.ts +9 -0
- package/dist/components/elements/Fields/TextInput/TextInput.stories.js +35 -0
- package/dist/components/elements/Fields/TextInput/index.d.ts +45 -0
- package/dist/components/elements/Fields/TextInput/index.js +119 -0
- package/dist/components/elements/Fields/option.d.ts +16 -0
- package/dist/components/elements/Fields/option.js +3 -0
- package/dist/components/elements/Group/index.d.ts +22 -0
- package/dist/components/elements/Group/index.js +69 -0
- package/dist/components/elements/Icon/Icon.stories.d.ts +7 -0
- package/dist/components/elements/Icon/Icon.stories.js +29 -0
- package/dist/components/elements/Icon/Icon.test.d.ts +1 -0
- package/dist/components/elements/Icon/Icon.test.js +26 -0
- package/dist/components/elements/Icon/index.d.ts +10 -0
- package/dist/components/elements/Icon/index.js +34 -0
- package/dist/components/elements/Link/Link.stories.d.ts +6 -0
- package/dist/components/elements/Link/Link.stories.js +21 -0
- package/dist/components/elements/Link/Link.test.d.ts +1 -0
- package/dist/components/elements/Link/Link.test.js +58 -0
- package/dist/components/elements/Link/index.d.ts +14 -0
- package/dist/components/elements/Link/index.js +41 -0
- package/dist/components/elements/List/List.stories.d.ts +10 -0
- package/dist/components/elements/List/List.stories.js +37 -0
- package/dist/components/elements/List/List.test.d.ts +1 -0
- package/dist/components/elements/List/List.test.js +24 -0
- package/dist/components/elements/List/index.d.ts +27 -0
- package/dist/components/elements/List/index.js +103 -0
- package/dist/components/elements/ListBox/Listbox.stories.d.ts +6 -0
- package/dist/components/elements/ListBox/Listbox.stories.js +17 -0
- package/dist/components/elements/ListBox/index.d.ts +33 -0
- package/dist/components/elements/ListBox/index.js +51 -0
- package/dist/components/elements/Markdown/Markdown.stories.d.ts +10 -0
- package/dist/components/elements/Markdown/Markdown.stories.js +97 -0
- package/dist/components/elements/Markdown/Markdown.test.d.ts +1 -0
- package/dist/components/elements/Markdown/Markdown.test.js +91 -0
- package/dist/components/elements/Markdown/index.d.ts +21 -0
- package/dist/components/elements/Markdown/index.js +75 -0
- package/dist/components/elements/Pill/Pill.stories.d.ts +8 -0
- package/dist/components/elements/Pill/Pill.stories.js +40 -0
- package/dist/components/elements/Pill/Pill.test.d.ts +1 -0
- package/dist/components/elements/Pill/Pill.test.js +18 -0
- package/dist/components/elements/Pill/index.d.ts +21 -0
- package/dist/components/elements/Pill/index.js +117 -0
- package/dist/components/elements/Spinner/Spinner.stories.d.ts +7 -0
- package/dist/components/elements/Spinner/Spinner.stories.js +26 -0
- package/dist/components/elements/Spinner/Spinner.test.d.ts +1 -0
- package/dist/components/elements/Spinner/Spinner.test.js +9 -0
- package/dist/components/elements/Spinner/index.d.ts +14 -0
- package/dist/components/elements/Spinner/index.js +49 -0
- package/dist/components/elements/TabList/TabList.stories.d.ts +6 -0
- package/dist/components/elements/TabList/TabList.stories.js +12 -0
- package/dist/components/elements/TabList/TabList.test.d.ts +1 -0
- package/dist/components/elements/TabList/TabList.test.js +19 -0
- package/dist/components/elements/TabList/example.d.ts +7 -0
- package/dist/components/elements/TabList/example.js +36 -0
- package/dist/components/elements/TabList/index.d.ts +10 -0
- package/dist/components/elements/TabList/index.js +30 -0
- package/dist/components/elements/Table/Table.stories.d.ts +10 -0
- package/dist/components/elements/Table/Table.stories.js +96 -0
- package/dist/components/elements/Table/Table.test.d.ts +1 -0
- package/dist/components/elements/Table/Table.test.js +36 -0
- package/dist/components/elements/Table/index.d.ts +30 -0
- package/dist/components/elements/Table/index.js +100 -0
- package/dist/components/elements/layout/Box.d.ts +9 -0
- package/dist/components/elements/layout/Box.js +3 -0
- package/dist/components/elements/layout/Box.stories.d.ts +6 -0
- package/dist/components/elements/layout/Box.stories.js +12 -0
- package/dist/components/elements/layout/Column.d.ts +8 -0
- package/dist/components/elements/layout/Column.js +19 -0
- package/dist/components/elements/layout/Flex.stories.d.ts +10 -0
- package/dist/components/elements/layout/Flex.stories.js +26 -0
- package/dist/components/elements/layout/Flex.test.d.ts +1 -0
- package/dist/components/elements/layout/Flex.test.js +34 -0
- package/dist/components/elements/layout/Row.d.ts +20 -0
- package/dist/components/elements/layout/Row.js +52 -0
- package/dist/components/elements/text/Heading/Heading.stories.d.ts +8 -0
- package/dist/components/elements/text/Heading/Heading.stories.js +35 -0
- package/dist/components/elements/text/Heading/Heading.test.d.ts +1 -0
- package/dist/components/elements/text/Heading/Heading.test.js +51 -0
- package/dist/components/elements/text/Heading/index.d.ts +20 -0
- package/dist/components/elements/text/Heading/index.js +62 -0
- package/dist/components/elements/text/Inline/Inline.stories.d.ts +6 -0
- package/dist/components/elements/text/Inline/Inline.stories.js +12 -0
- package/dist/components/elements/text/Inline/index.d.ts +6 -0
- package/dist/components/elements/text/Inline/index.js +21 -0
- package/dist/components/elements/text/Label/Label.stories.d.ts +6 -0
- package/dist/components/elements/text/Label/Label.stories.js +20 -0
- package/dist/components/elements/text/Label/Label.test.d.ts +1 -0
- package/dist/components/elements/text/Label/Label.test.js +56 -0
- package/dist/components/elements/text/Label/index.d.ts +20 -0
- package/dist/components/elements/text/Label/index.js +38 -0
- package/dist/components/elements/text/Paragraph/Paragraph.stories.d.ts +6 -0
- package/dist/components/elements/text/Paragraph/Paragraph.stories.js +25 -0
- package/dist/components/elements/text/Paragraph/Paragraph.test.d.ts +1 -0
- package/dist/components/elements/text/Paragraph/Paragraph.test.js +9 -0
- package/dist/components/elements/text/Paragraph/index.d.ts +14 -0
- package/dist/components/elements/text/Paragraph/index.js +29 -0
- package/dist/components/elements/text/ReadMore/ReadMore.stories.d.ts +8 -0
- package/dist/components/elements/text/ReadMore/ReadMore.stories.js +26 -0
- package/dist/components/elements/text/ReadMore/index.d.ts +12 -0
- package/dist/components/elements/text/ReadMore/index.js +71 -0
- package/dist/components/providers/alerts.d.ts +41 -0
- package/dist/components/providers/alerts.js +133 -0
- package/dist/components/providers/componentConfig.d.ts +25 -0
- package/dist/components/providers/componentConfig.js +37 -0
- package/dist/components/providers/dialogs.d.ts +9 -0
- package/dist/components/providers/dialogs.js +32 -0
- package/dist/components/providers/env.d.ts +14 -0
- package/dist/components/providers/env.js +25 -0
- package/dist/components/providers/media.d.ts +8 -0
- package/dist/components/providers/media.js +43 -0
- package/dist/components/providers/menu.d.ts +46 -0
- package/dist/components/providers/menu.js +304 -0
- package/dist/components/providers/snackBar.d.ts +23 -0
- package/dist/components/providers/snackBar.js +53 -0
- package/dist/components/providers/ui.d.ts +18 -0
- package/dist/components/providers/ui.js +16 -0
- package/dist/components/providers/uniqueIds.d.ts +3 -0
- package/dist/components/providers/uniqueIds.js +23 -0
- package/dist/components/providers/uniqueIds.test.d.ts +1 -0
- package/dist/components/providers/uniqueIds.test.js +26 -0
- package/dist/index.d.ts +53 -0
- package/dist/index.js +51 -0
- package/dist/theme/Color.stories.d.ts +5 -0
- package/dist/theme/Color.stories.js +63 -0
- package/dist/theme/GlobalStyles.d.ts +1 -0
- package/dist/theme/GlobalStyles.js +167 -0
- package/dist/theme/Typography.stories.d.ts +5 -0
- package/dist/theme/Typography.stories.js +44 -0
- package/dist/theme/colors.d.ts +51 -0
- package/dist/theme/colors.js +97 -0
- package/dist/theme/custom.d.ts +11 -0
- package/dist/theme/custom.js +13 -0
- package/dist/theme/index.d.ts +185 -0
- package/dist/theme/index.js +25 -0
- package/dist/theme/spacing.d.ts +0 -0
- package/dist/theme/spacing.js +1 -0
- package/dist/theme/typography.d.ts +100 -0
- package/dist/theme/typography.js +206 -0
- package/dist/utils/hooks/useCheckMidClick.d.ts +8 -0
- package/dist/utils/hooks/useCheckMidClick.js +17 -0
- package/dist/utils/hooks/useCheckMidKeyPress.d.ts +9 -0
- package/dist/utils/hooks/useCheckMidKeyPress.js +23 -0
- package/dist/utils/hooks/useHover.d.ts +7 -0
- package/dist/utils/hooks/useHover.js +12 -0
- package/dist/utils/hooks/useStorage.d.ts +14 -0
- package/dist/utils/hooks/useStorage.js +37 -0
- package/dist/utils/misc.d.ts +14 -0
- package/dist/utils/misc.js +19 -0
- package/dist/utils/sortByKey.d.ts +12 -0
- package/dist/utils/sortByKey.js +20 -0
- package/dist/utils/test.d.ts +2 -0
- package/dist/utils/test.js +9 -0
- package/package.json +98 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { EmptyState } from '.';
|
|
3
|
+
declare const meta: Meta<typeof EmptyState>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof EmptyState>;
|
|
6
|
+
export declare const Default: Story;
|
|
7
|
+
export declare const Small: Story;
|
|
8
|
+
export declare const CustomMessage: Story;
|
|
9
|
+
export declare const JsxMessage: Story;
|
|
10
|
+
export declare const CustomIcon: Story;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { EMPTY_STATE_SIZE, EmptyState } from '.';
|
|
3
|
+
import NotInterestedIcon from '@mui/icons-material/NotInterested';
|
|
4
|
+
import { Link } from '../../elements/Link';
|
|
5
|
+
import { FONT_SIZE } from '../../../theme/typography';
|
|
6
|
+
const meta = {
|
|
7
|
+
title: 'Composites/EmptyState',
|
|
8
|
+
component: EmptyState,
|
|
9
|
+
tags: ['autodocs'],
|
|
10
|
+
};
|
|
11
|
+
export default meta;
|
|
12
|
+
export const Default = {
|
|
13
|
+
render: () => _jsx(EmptyState, {}),
|
|
14
|
+
args: {},
|
|
15
|
+
};
|
|
16
|
+
export const Small = {
|
|
17
|
+
render: () => _jsx(EmptyState, { size: EMPTY_STATE_SIZE.SM }),
|
|
18
|
+
args: {},
|
|
19
|
+
};
|
|
20
|
+
export const CustomMessage = {
|
|
21
|
+
render: () => _jsx(EmptyState, { children: "Custom message" }),
|
|
22
|
+
args: {},
|
|
23
|
+
};
|
|
24
|
+
export const JsxMessage = {
|
|
25
|
+
render: () => (_jsxs(EmptyState, { children: ["Something is wrong.", ' ', _jsx(Link, Object.assign({ to: "/", sx: { fontSize: FONT_SIZE.MD } }, { children: "Click here to fix." }))] })),
|
|
26
|
+
args: {},
|
|
27
|
+
};
|
|
28
|
+
export const CustomIcon = {
|
|
29
|
+
render: () => _jsx(EmptyState, { message: "Custom icon", icon: NotInterestedIcon }),
|
|
30
|
+
args: {},
|
|
31
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { render } from '../../../utils/test';
|
|
3
|
+
import { EmptyState, DEFAULT_MESSAGE } from '.';
|
|
4
|
+
const TEST_MESSAGE = 'test message';
|
|
5
|
+
const MOCK_ICON_TEST_ID = 'mock-icon';
|
|
6
|
+
const MockIcon = () => _jsx("div", { "data-testid": MOCK_ICON_TEST_ID });
|
|
7
|
+
describe('EmptyState', () => {
|
|
8
|
+
it('renders passed message', () => {
|
|
9
|
+
const { getByText } = render(_jsx(EmptyState, { children: TEST_MESSAGE }));
|
|
10
|
+
expect(getByText(TEST_MESSAGE)).toBeDefined();
|
|
11
|
+
});
|
|
12
|
+
it('renders default message if no message passed', () => {
|
|
13
|
+
const { getByText } = render(_jsx(EmptyState, {}));
|
|
14
|
+
expect(getByText(DEFAULT_MESSAGE)).toBeDefined();
|
|
15
|
+
});
|
|
16
|
+
it('renders passed icon', () => {
|
|
17
|
+
const { getByTestId } = render(_jsx(EmptyState, { icon: MockIcon }));
|
|
18
|
+
expect(getByTestId(MOCK_ICON_TEST_ID)).toBeDefined();
|
|
19
|
+
});
|
|
20
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { StyledElementProps } from '../../../theme';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
export declare enum EMPTY_STATE_SIZE {
|
|
4
|
+
SM = "SM",
|
|
5
|
+
LG = "LG"
|
|
6
|
+
}
|
|
7
|
+
type EmptyStateProps = StyledElementProps<HTMLDivElement, {
|
|
8
|
+
icon?: React.FC;
|
|
9
|
+
omitIcon?: boolean;
|
|
10
|
+
size?: EMPTY_STATE_SIZE;
|
|
11
|
+
message?: string;
|
|
12
|
+
}>;
|
|
13
|
+
export declare const DEFAULT_MESSAGE = "No results found.";
|
|
14
|
+
export declare const EmptyState: React.FC<EmptyStateProps>;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
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 _SearchOffIcon from '@mui/icons-material/SearchOff';
|
|
14
|
+
import { Row } from '../../elements/layout/Row';
|
|
15
|
+
import { Column } from '../../elements/layout/Column';
|
|
16
|
+
import { PARAGRAPH_SIZE, Paragraph } from '../../elements/text/Paragraph';
|
|
17
|
+
import { COLOR } from '../../../theme/colors';
|
|
18
|
+
import { Icon } from '../../elements/Icon';
|
|
19
|
+
import { FONT_SIZE } from '../../../theme/typography';
|
|
20
|
+
import { importedDefaultComponentShim } from '../../../utils/misc';
|
|
21
|
+
const SearchOffIcon = importedDefaultComponentShim(_SearchOffIcon);
|
|
22
|
+
export var EMPTY_STATE_SIZE;
|
|
23
|
+
(function (EMPTY_STATE_SIZE) {
|
|
24
|
+
EMPTY_STATE_SIZE["SM"] = "SM";
|
|
25
|
+
EMPTY_STATE_SIZE["LG"] = "LG";
|
|
26
|
+
})(EMPTY_STATE_SIZE || (EMPTY_STATE_SIZE = {}));
|
|
27
|
+
export const DEFAULT_MESSAGE = 'No results found.';
|
|
28
|
+
export const EmptyState = (_a) => {
|
|
29
|
+
var { omitIcon, icon, children, size: sizeProp, sx } = _a, rest = __rest(_a, ["omitIcon", "icon", "children", "size", "sx"]);
|
|
30
|
+
const size = sizeProp || EMPTY_STATE_SIZE.LG;
|
|
31
|
+
return (_jsxs(Column, Object.assign({ sx: Object.assign({ width: '100%', alignItems: 'center', justifyContent: 'center', mt: size === EMPTY_STATE_SIZE.SM ? 3 : 5 }, sx) }, rest, { children: [_jsx(Row, { children: omitIcon ? null : (_jsx(Icon, { icon: icon || SearchOffIcon, size: size === EMPTY_STATE_SIZE.SM ? FONT_SIZE.ML : FONT_SIZE.XL, color: COLOR.GRAY })) }), _jsx(Row, Object.assign({ sx: { mt: size === EMPTY_STATE_SIZE.SM ? 0 : 1 } }, { children: _jsx(Paragraph, Object.assign({ sx: { color: COLOR.GRAY }, size: size === EMPTY_STATE_SIZE.SM ? PARAGRAPH_SIZE.MD : PARAGRAPH_SIZE.LG }, { children: children || DEFAULT_MESSAGE })) }))] })));
|
|
32
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Modal } from '.';
|
|
3
|
+
import { Button } from '../../elements/Button';
|
|
4
|
+
import { Paragraph } from '../../elements/text/Paragraph';
|
|
5
|
+
import { useDialog } from '../../providers/dialogs';
|
|
6
|
+
import { useTheme } from '../../../theme';
|
|
7
|
+
const meta = {
|
|
8
|
+
title: 'Composites/Modal',
|
|
9
|
+
component: Modal,
|
|
10
|
+
tags: ['autodocs'],
|
|
11
|
+
};
|
|
12
|
+
export default meta;
|
|
13
|
+
const ModalExample = () => {
|
|
14
|
+
const modalId = 'modal-example';
|
|
15
|
+
const { open, close, state } = useDialog(modalId);
|
|
16
|
+
const theme = useTheme();
|
|
17
|
+
return (_jsxs(_Fragment, { children: [_jsx(Button, Object.assign({ onClick: open, sx: { position: 'relative', zIndex: theme.zIndex.DIALOG } }, { children: "Open Modal" })), _jsx(Modal, Object.assign({ isOpen: state.isOpen, heading: "Heading", close: close, actions: [
|
|
18
|
+
{
|
|
19
|
+
label: 'Secondary',
|
|
20
|
+
isPrimary: false,
|
|
21
|
+
onClick: () => { },
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
label: 'Customized',
|
|
25
|
+
onClick: () => { },
|
|
26
|
+
buttonProps: {
|
|
27
|
+
loading: true,
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
label: 'Primary',
|
|
32
|
+
isPrimary: true,
|
|
33
|
+
onClick: () => { },
|
|
34
|
+
},
|
|
35
|
+
] }, { children: _jsx(Paragraph, { children: "Modal body goes here" }) }))] }));
|
|
36
|
+
};
|
|
37
|
+
export const Default = {
|
|
38
|
+
render: () => _jsx(ModalExample, {}),
|
|
39
|
+
args: {},
|
|
40
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { StyledElementProps } from '../../../theme';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { ButtonProps } from '../../elements/Button';
|
|
4
|
+
type ModalProps = StyledElementProps<HTMLDivElement, {
|
|
5
|
+
isOpen: boolean;
|
|
6
|
+
close: (e: React.MouseEvent) => void;
|
|
7
|
+
heading: string;
|
|
8
|
+
hideHeading?: boolean;
|
|
9
|
+
zIndex?: number;
|
|
10
|
+
footer?: React.ReactNode;
|
|
11
|
+
actions?: ModalAction[];
|
|
12
|
+
wrapWithTheme?: boolean;
|
|
13
|
+
}>;
|
|
14
|
+
type ModalAction = {
|
|
15
|
+
label: string;
|
|
16
|
+
isPrimary?: boolean;
|
|
17
|
+
buttonProps?: Partial<ButtonProps>;
|
|
18
|
+
onClick: (e: React.MouseEvent) => void;
|
|
19
|
+
};
|
|
20
|
+
export declare const Modal: React.FC<ModalProps>;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,64 @@
|
|
|
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 _ReactModal from 'react-modal';
|
|
14
|
+
import { importedDefaultComponentShim } from '../../../utils/misc';
|
|
15
|
+
import { ThemeProvider, useTheme } from '../../../theme';
|
|
16
|
+
import { GROUP_TYPE, Group } from '../../elements/Group';
|
|
17
|
+
import { Row } from '../../elements/layout/Row';
|
|
18
|
+
import { HEADING_SIZE, Heading } from '../../elements/text/Heading';
|
|
19
|
+
import { BUTTON_TYPE, Button } from '../../elements/Button';
|
|
20
|
+
import { COLOR } from '../../../theme/colors';
|
|
21
|
+
import { TYPOGRAPHY_TYPE } from '../../../theme/typography';
|
|
22
|
+
import { useMediaQuery } from '../../providers/media';
|
|
23
|
+
import { useComponentConfig } from '../../providers/componentConfig';
|
|
24
|
+
const ReactModal = importedDefaultComponentShim(_ReactModal);
|
|
25
|
+
export const Modal = (_a) => {
|
|
26
|
+
var { children, heading, hideHeading, isOpen, footer, actions, wrapWithTheme, close, zIndex } = _a, props = __rest(_a, ["children", "heading", "hideHeading", "isOpen", "footer", "actions", "wrapWithTheme", "close", "zIndex"]);
|
|
27
|
+
const { breakpoint } = useMediaQuery();
|
|
28
|
+
const { modal } = useComponentConfig();
|
|
29
|
+
const theme = useTheme();
|
|
30
|
+
const shouldShowFooter = footer !== undefined || (actions !== undefined && actions.length > 0);
|
|
31
|
+
const modalBody = (_jsxs(Group, Object.assign({ type: GROUP_TYPE.REGION, sx: { my: 0 } }, { children: [!hideHeading && (_jsxs(Row, Object.assign({ justify: "space-between", align: "center", sx: {
|
|
32
|
+
p: 3,
|
|
33
|
+
borderBottom: 'solid 1px',
|
|
34
|
+
borderColor: COLOR.LIGHT_GRAY,
|
|
35
|
+
} }, { children: [_jsx(Heading, Object.assign({ size: HEADING_SIZE.SM, typography: TYPOGRAPHY_TYPE.CONTROL_MEDIUM }, { children: heading })), _jsx(Button, Object.assign({ type: BUTTON_TYPE.TEXT, onClick: (e) => {
|
|
36
|
+
e.preventDefault();
|
|
37
|
+
e.stopPropagation();
|
|
38
|
+
close(e);
|
|
39
|
+
} }, { children: "Close" }))] }))), _jsx(Row, Object.assign({ sx: { p: 3 } }, { children: children })), shouldShowFooter && (_jsxs(Row, Object.assign({ sx: { borderTop: 'solid 1px', borderColor: COLOR.LIGHT_GRAY, p: 3 } }, { children: [footer, actions !== undefined && (_jsx(Row, Object.assign({ sx: { width: '100%', justifyContent: 'flex-end' } }, { children: actions.map((action, index) => (_jsx(Button, Object.assign({ type: action.isPrimary ? BUTTON_TYPE.DEFAULT : BUTTON_TYPE.OUTLINE, onClick: (e) => {
|
|
40
|
+
action.onClick(e);
|
|
41
|
+
}, sx: {
|
|
42
|
+
mr: index < actions.length - 1 ? 1 : 0,
|
|
43
|
+
} }, action.buttonProps, { children: action.label }), index))) })))] })))] })));
|
|
44
|
+
return (_jsx(ReactModal, Object.assign({ isOpen: isOpen, shouldFocusAfterRender: true, appElement: modal.appElement, onRequestClose: (e) => {
|
|
45
|
+
e.preventDefault();
|
|
46
|
+
e.stopPropagation();
|
|
47
|
+
close(e);
|
|
48
|
+
} }, props, { style: {
|
|
49
|
+
overlay: {
|
|
50
|
+
backgroundColor: 'rgba(0, 0, 0, 0.5)',
|
|
51
|
+
zIndex: zIndex || theme.zIndex.MODAL,
|
|
52
|
+
},
|
|
53
|
+
content: {
|
|
54
|
+
padding: 0,
|
|
55
|
+
minWidth: breakpoint === 0 ? 'calc(100% - 1rem)' : '500px',
|
|
56
|
+
top: '50%',
|
|
57
|
+
left: '50%',
|
|
58
|
+
right: 'auto',
|
|
59
|
+
bottom: 'auto',
|
|
60
|
+
marginRight: '-50%',
|
|
61
|
+
transform: 'translate(-50%, -50%)',
|
|
62
|
+
},
|
|
63
|
+
} }, { children: wrapWithTheme ? _jsx(ThemeProvider, { children: modalBody }) : modalBody })));
|
|
64
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { NavMenu } from './';
|
|
3
|
+
import { DemoMenuImplementation } from './demo';
|
|
4
|
+
const meta = {
|
|
5
|
+
title: 'Composites/NavMenu',
|
|
6
|
+
component: NavMenu,
|
|
7
|
+
};
|
|
8
|
+
export default meta;
|
|
9
|
+
export const Default = {
|
|
10
|
+
render: () => _jsx(DemoMenuImplementation, {}),
|
|
11
|
+
args: {},
|
|
12
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { fireEvent } from '@testing-library/react';
|
|
3
|
+
import { render } from '../../../utils/test';
|
|
4
|
+
import { KEY_CODES } from '../../../utils/misc';
|
|
5
|
+
import { DemoMenuImplementation } from './demo';
|
|
6
|
+
describe('NavMenu', () => {
|
|
7
|
+
it('can be navigated with events', () => {
|
|
8
|
+
const { getByRole } = render(_jsx(DemoMenuImplementation, {}));
|
|
9
|
+
const menu = getByRole('menu');
|
|
10
|
+
const firstMenuItem = getByRole('menuitem', {
|
|
11
|
+
name: 'home',
|
|
12
|
+
});
|
|
13
|
+
const secondMenuItem = getByRole('menuitem', {
|
|
14
|
+
name: 'research',
|
|
15
|
+
});
|
|
16
|
+
fireEvent.focus(menu);
|
|
17
|
+
expect(firstMenuItem).toHaveFocus();
|
|
18
|
+
fireEvent.keyDown(firstMenuItem, {
|
|
19
|
+
key: KEY_CODES.ARROW_RIGHT,
|
|
20
|
+
});
|
|
21
|
+
expect(secondMenuItem).toHaveFocus();
|
|
22
|
+
const firstSubmenuItem = getByRole('menuitem', {
|
|
23
|
+
name: 'test submenu 1',
|
|
24
|
+
});
|
|
25
|
+
const secondSubmenuItem = getByRole('menuitem', {
|
|
26
|
+
name: 'test submenu 2',
|
|
27
|
+
});
|
|
28
|
+
const firstLeaf = getByRole('menuitem', {
|
|
29
|
+
name: 'test leaf 1',
|
|
30
|
+
});
|
|
31
|
+
const secondLeaf = getByRole('menuitem', {
|
|
32
|
+
name: 'test leaf 2',
|
|
33
|
+
});
|
|
34
|
+
fireEvent.keyDown(secondMenuItem, {
|
|
35
|
+
key: KEY_CODES.ARROW_DOWN,
|
|
36
|
+
});
|
|
37
|
+
expect(firstSubmenuItem).toHaveFocus();
|
|
38
|
+
fireEvent.keyDown(firstMenuItem, {
|
|
39
|
+
key: KEY_CODES.ARROW_RIGHT,
|
|
40
|
+
});
|
|
41
|
+
expect(secondSubmenuItem).toHaveFocus();
|
|
42
|
+
fireEvent.keyDown(secondMenuItem, {
|
|
43
|
+
key: KEY_CODES.ARROW_LEFT,
|
|
44
|
+
});
|
|
45
|
+
expect(firstSubmenuItem).toHaveFocus();
|
|
46
|
+
fireEvent.keyDown(secondMenuItem, {
|
|
47
|
+
key: KEY_CODES.ENTER,
|
|
48
|
+
});
|
|
49
|
+
expect(firstLeaf).toHaveFocus();
|
|
50
|
+
fireEvent.keyDown(firstLeaf, {
|
|
51
|
+
key: KEY_CODES.ARROW_DOWN,
|
|
52
|
+
});
|
|
53
|
+
expect(secondLeaf).toHaveFocus();
|
|
54
|
+
fireEvent.keyDown(secondLeaf, {
|
|
55
|
+
key: KEY_CODES.ARROW_UP,
|
|
56
|
+
});
|
|
57
|
+
expect(firstLeaf).toHaveFocus();
|
|
58
|
+
fireEvent.keyDown(firstLeaf, {
|
|
59
|
+
key: KEY_CODES.ARROW_UP,
|
|
60
|
+
});
|
|
61
|
+
expect(firstSubmenuItem).toHaveFocus();
|
|
62
|
+
fireEvent.keyDown(firstSubmenuItem, {
|
|
63
|
+
key: KEY_CODES.ARROW_UP,
|
|
64
|
+
});
|
|
65
|
+
expect(secondMenuItem).toHaveFocus();
|
|
66
|
+
});
|
|
67
|
+
it('can be navigated with keyboard events', () => {
|
|
68
|
+
const { getByRole } = render(_jsx(DemoMenuImplementation, {}));
|
|
69
|
+
const secondMenuItem = getByRole('menuitem', {
|
|
70
|
+
name: 'research',
|
|
71
|
+
});
|
|
72
|
+
fireEvent.mouseDown(secondMenuItem);
|
|
73
|
+
fireEvent.click(secondMenuItem);
|
|
74
|
+
fireEvent.mouseUp(secondMenuItem);
|
|
75
|
+
getByRole('menuitem', {
|
|
76
|
+
name: 'test submenu 1',
|
|
77
|
+
});
|
|
78
|
+
getByRole('menuitem', {
|
|
79
|
+
name: 'test submenu 2',
|
|
80
|
+
});
|
|
81
|
+
getByRole('menuitem', {
|
|
82
|
+
name: 'test leaf 1',
|
|
83
|
+
});
|
|
84
|
+
getByRole('menuitem', {
|
|
85
|
+
name: 'test leaf 2',
|
|
86
|
+
});
|
|
87
|
+
fireEvent.mouseDown(secondMenuItem);
|
|
88
|
+
fireEvent.click(secondMenuItem);
|
|
89
|
+
fireEvent.mouseUp(secondMenuItem);
|
|
90
|
+
expect(() => {
|
|
91
|
+
getByRole('menuitem', {
|
|
92
|
+
name: 'test submenu 1',
|
|
93
|
+
});
|
|
94
|
+
}).toThrow();
|
|
95
|
+
});
|
|
96
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const DemoMenuImplementation: () => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { createElement as _createElement } from "react";
|
|
3
|
+
import { NavMenu } from '.';
|
|
4
|
+
import { Button } from '../../elements/Button';
|
|
5
|
+
import { Row } from '../../elements/layout/Row';
|
|
6
|
+
import { MENU_ACTION_TYPE, MENU_ORIENTATION, MenuProvider, } from '../../providers/menu';
|
|
7
|
+
const demoMenu = {
|
|
8
|
+
orientation: MENU_ORIENTATION.HORIZONTAL,
|
|
9
|
+
items: [
|
|
10
|
+
{
|
|
11
|
+
id: 'home',
|
|
12
|
+
label: 'home',
|
|
13
|
+
action: {
|
|
14
|
+
type: MENU_ACTION_TYPE.LINK,
|
|
15
|
+
to: '/',
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
id: 'research',
|
|
20
|
+
label: 'research',
|
|
21
|
+
action: {
|
|
22
|
+
type: MENU_ACTION_TYPE.SUBMENU,
|
|
23
|
+
submenu: {
|
|
24
|
+
orientation: MENU_ORIENTATION.HORIZONTAL,
|
|
25
|
+
items: [
|
|
26
|
+
{
|
|
27
|
+
label: 'test submenu 1',
|
|
28
|
+
id: 'test-submenu-1',
|
|
29
|
+
action: {
|
|
30
|
+
type: MENU_ACTION_TYPE.SUBMENU,
|
|
31
|
+
submenu: {
|
|
32
|
+
orientation: MENU_ORIENTATION.VERTICAL,
|
|
33
|
+
items: [
|
|
34
|
+
{
|
|
35
|
+
label: 'test leaf 1',
|
|
36
|
+
id: 'test-leaf-1',
|
|
37
|
+
action: {
|
|
38
|
+
type: MENU_ACTION_TYPE.LINK,
|
|
39
|
+
to: '/',
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
label: 'test leaf 2',
|
|
44
|
+
id: 'test-leaf-2',
|
|
45
|
+
action: {
|
|
46
|
+
type: MENU_ACTION_TYPE.LINK,
|
|
47
|
+
to: '/',
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
],
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
action: {
|
|
56
|
+
type: MENU_ACTION_TYPE.SUBMENU,
|
|
57
|
+
submenu: {
|
|
58
|
+
orientation: MENU_ORIENTATION.VERTICAL,
|
|
59
|
+
items: [
|
|
60
|
+
{
|
|
61
|
+
label: 'test leaf 3',
|
|
62
|
+
id: 'test-leaf-3',
|
|
63
|
+
action: {
|
|
64
|
+
type: MENU_ACTION_TYPE.LINK,
|
|
65
|
+
to: '/',
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
label: 'test leaf 4',
|
|
70
|
+
id: 'test-leaf-4',
|
|
71
|
+
action: {
|
|
72
|
+
type: MENU_ACTION_TYPE.LINK,
|
|
73
|
+
to: '/',
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
],
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
label: 'test submenu 2',
|
|
80
|
+
id: 'test-submenu-2',
|
|
81
|
+
},
|
|
82
|
+
],
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
id: 'services',
|
|
88
|
+
label: 'services',
|
|
89
|
+
action: {
|
|
90
|
+
type: MENU_ACTION_TYPE.SUBMENU,
|
|
91
|
+
submenu: {
|
|
92
|
+
orientation: MENU_ORIENTATION.HORIZONTAL,
|
|
93
|
+
items: [
|
|
94
|
+
{
|
|
95
|
+
label: 'test submenu 5',
|
|
96
|
+
id: 'test-submenu-5',
|
|
97
|
+
action: {
|
|
98
|
+
type: MENU_ACTION_TYPE.SUBMENU,
|
|
99
|
+
submenu: {
|
|
100
|
+
orientation: MENU_ORIENTATION.VERTICAL,
|
|
101
|
+
items: [
|
|
102
|
+
{
|
|
103
|
+
label: 'test leaf 1',
|
|
104
|
+
id: 'test-leaf-1',
|
|
105
|
+
action: {
|
|
106
|
+
type: MENU_ACTION_TYPE.LINK,
|
|
107
|
+
to: '/',
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
label: 'test leaf 2',
|
|
112
|
+
id: 'test-leaf-2',
|
|
113
|
+
action: {
|
|
114
|
+
type: MENU_ACTION_TYPE.LINK,
|
|
115
|
+
to: '/',
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
],
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
action: {
|
|
124
|
+
type: MENU_ACTION_TYPE.SUBMENU,
|
|
125
|
+
submenu: {
|
|
126
|
+
orientation: MENU_ORIENTATION.VERTICAL,
|
|
127
|
+
items: [
|
|
128
|
+
{
|
|
129
|
+
label: 'test leaf 3',
|
|
130
|
+
id: 'test-leaf-3',
|
|
131
|
+
action: {
|
|
132
|
+
type: MENU_ACTION_TYPE.LINK,
|
|
133
|
+
to: '/',
|
|
134
|
+
},
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
label: 'test leaf 4',
|
|
138
|
+
id: 'test-leaf-4',
|
|
139
|
+
action: {
|
|
140
|
+
type: MENU_ACTION_TYPE.LINK,
|
|
141
|
+
to: '/',
|
|
142
|
+
},
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
label: 'test leaf 5',
|
|
146
|
+
id: 'test-leaf-5',
|
|
147
|
+
action: {
|
|
148
|
+
type: MENU_ACTION_TYPE.LINK,
|
|
149
|
+
to: '/',
|
|
150
|
+
},
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
label: 'test leaf 6',
|
|
154
|
+
id: 'test-leaf-6',
|
|
155
|
+
action: {
|
|
156
|
+
type: MENU_ACTION_TYPE.LINK,
|
|
157
|
+
to: '/',
|
|
158
|
+
},
|
|
159
|
+
},
|
|
160
|
+
],
|
|
161
|
+
},
|
|
162
|
+
},
|
|
163
|
+
label: 'test submenu 6',
|
|
164
|
+
id: 'test-submenu-6',
|
|
165
|
+
},
|
|
166
|
+
],
|
|
167
|
+
},
|
|
168
|
+
},
|
|
169
|
+
},
|
|
170
|
+
],
|
|
171
|
+
};
|
|
172
|
+
export const DemoMenuImplementation = () => (_jsx(MenuProvider, Object.assign({ menu: demoMenu }, { children: ({ menu, getMenuProps, getMenuItemProps }) => (_jsxs(_Fragment, { children: [_jsx(Row, Object.assign({}, getMenuProps(), { children: menu.items.map((menuItem) => (_createElement(Button, Object.assign({}, getMenuItemProps([menuItem.id]), { sx: { m: 1 }, key: menuItem.id }), menuItem.label))) })), _jsx(NavMenu, {})] })) })));
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import _ChevronRightIcon from '@mui/icons-material/ChevronRight';
|
|
3
|
+
import { ArrowLink } from '../../elements/ArrowLink';
|
|
4
|
+
import { List, ListItem } from '../../elements/List';
|
|
5
|
+
import { MENU_ACTION_TYPE, useMenu } from '../../providers/menu';
|
|
6
|
+
import { Row } from '../../elements/layout/Row';
|
|
7
|
+
import { Column } from '../../elements/layout/Column';
|
|
8
|
+
import { HEADING_SIZE, Heading } from '../../elements/text/Heading';
|
|
9
|
+
import { Link } from '../../elements/Link';
|
|
10
|
+
import { FONT_WEIGHT } from '../../../theme/typography';
|
|
11
|
+
import { COLOR } from '../../../theme/colors';
|
|
12
|
+
import { importedDefaultComponentShim } from '../../../utils/misc';
|
|
13
|
+
const ChevronRightIcon = importedDefaultComponentShim(_ChevronRightIcon);
|
|
14
|
+
export const NavMenu = (props) => {
|
|
15
|
+
const { isOpen, activePath, getMenuItem, getMenuItemProps, getMenuProps } = useMenu();
|
|
16
|
+
if (!isOpen) {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
const topLevelMenuId = activePath[0];
|
|
20
|
+
const activeTopLevelMenu = getMenuItem([topLevelMenuId]);
|
|
21
|
+
if (!activeTopLevelMenu ||
|
|
22
|
+
!(activeTopLevelMenu.action.type === MENU_ACTION_TYPE.SUBMENU)) {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
const submenu = activeTopLevelMenu.action.submenu;
|
|
26
|
+
return (_jsxs(Row, Object.assign({}, props, { sx: {
|
|
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) => {
|
|
34
|
+
if (!(submenuItem.action.type === MENU_ACTION_TYPE.SUBMENU)) {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
const leafMenuItems = submenuItem.action.submenu.items;
|
|
38
|
+
const submenuPath = [topLevelMenuId, submenuItem.id];
|
|
39
|
+
const link = topLevelMenuId.slice(1);
|
|
40
|
+
const category = topLevelMenuId.charAt(1).toUpperCase() + topLevelMenuId.slice(2);
|
|
41
|
+
console.log('topLevelMenuId: ', topLevelMenuId);
|
|
42
|
+
console.log('activePath: ', activePath);
|
|
43
|
+
console.log('link: ', link);
|
|
44
|
+
console.log('category: ', category);
|
|
45
|
+
return (_jsxs(Column, Object.assign({ sx: { flexBasis: '275px', p: 2, flexShrink: 0, flexGrow: 0 } }, { children: [_jsx(Heading, Object.assign({ standalone: true, size: HEADING_SIZE.SM, underline: true }, getMenuItemProps(submenuPath), { children: submenuItem.label })), _jsx(List, Object.assign({}, getMenuProps(submenuPath), { icon: ChevronRightIcon }, { children: leafMenuItems.map((leafMenuItem, i) => {
|
|
46
|
+
const leafMenuPath = submenuPath.concat(leafMenuItem.id);
|
|
47
|
+
return (_jsx(ListItem, Object.assign({ index: i, sx: { mt: 1 } }, getMenuItemProps(leafMenuPath), { children: _jsx(Link, Object.assign({ to: "/", sx: {
|
|
48
|
+
fontWeight: FONT_WEIGHT.BOLD,
|
|
49
|
+
}, tabIndex: -1 }, { children: leafMenuItem.label })) }), leafMenuItem.id));
|
|
50
|
+
}) })), i < 1 && (link.includes('esearch') || link.includes('ervices')) ? (_jsxs(ArrowLink, Object.assign({ to: link, sx: { margin: '20px 10px 10px 10px' } }, { children: ["View More ", category] }))) : null] }), submenuItem.id));
|
|
51
|
+
}), _jsx(Column, { sx: { flexGrow: 1 } })] })));
|
|
52
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import ReactDOMServer from 'react-dom/server';
|
|
3
|
+
import pretty from 'pretty';
|
|
4
|
+
import { Seo } from '../index';
|
|
5
|
+
export const SeoDataDisplay = () => {
|
|
6
|
+
const seoHtml = ReactDOMServer.renderToString(_jsx(Seo, {}));
|
|
7
|
+
return (_jsx("code", { children: _jsx("pre", { children: pretty(seoHtml) }) }));
|
|
8
|
+
};
|
|
9
|
+
export default SeoDataDisplay;
|