@veritone-ce/design-system 1.12.8 → 1.12.9

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.
@@ -8,6 +8,7 @@ import statusChipTheme from '../components/StatusChip/statusChip.theme';
8
8
  import selectTheme from '../components/Select/select.theme';
9
9
  import tabsTheme from '../components/Tabs/tabs.theme';
10
10
  import inputTheme from '../components/Input/input.theme';
11
+ import { menuFlyoutTheme, menuItemTheme } from '../components/MenuFlyout/menuFlyout.theme';
11
12
  import modalTheme from '../components/Modal/modal.theme';
12
13
  import linearProgress from '../components/LinearProgress/linearProgress.theme';
13
14
  import CheckCircleIcon from '@mui/icons-material/CheckCircle';
@@ -93,7 +94,7 @@ let theme = createTheme({
93
94
  spacing: 10
94
95
  });
95
96
  theme = createTheme(theme, {
96
- components: Object.assign(Object.assign({ MuiButton: buttonTheme(theme) }, stepperTheme(theme)), { MuiSelect: selectTheme(theme), MuiTextField: inputTheme(theme), MuiDialog: modalTheme(theme), MuiCheckbox: checkboxTheme(theme), MuiRadio: radioButtonTheme(theme), MuiTabs: tabsTheme(theme), MuiChip: statusChipTheme(theme), MuiLinearProgress: linearProgress(theme), MuiInputLabel: {
97
+ components: Object.assign(Object.assign({ MuiButton: buttonTheme(theme) }, stepperTheme(theme)), { MuiSelect: selectTheme(theme), MuiTextField: inputTheme(theme), MuiDialog: modalTheme(theme), MuiCheckbox: checkboxTheme(theme), MuiRadio: radioButtonTheme(theme), MuiTabs: tabsTheme(theme), MuiChip: statusChipTheme(theme), MuiMenu: menuFlyoutTheme(theme), MuiMenuItem: menuItemTheme(theme), MuiLinearProgress: linearProgress(theme), MuiInputLabel: {
97
98
  styleOverrides: {
98
99
  root: {
99
100
  color: theme.palette.text.secondary,
@@ -259,18 +260,8 @@ theme = createTheme(theme, {
259
260
  styleOverrides: {
260
261
  root: {
261
262
  '&.MuiMenu-paper': {
262
- border: '1px solid ' + theme.palette.text.disabled,
263
- boxShadow: 'none'
264
- }
265
- }
266
- }
267
- }, MuiMenuItem: {
268
- styleOverrides: {
269
- root: {
270
- color: theme.palette.text.primary,
271
- padding: '10px 20px',
272
- ':hover, :focus': {
273
- backgroundColor: theme.palette.misc.altBackground
263
+ // border: '1px solid ' + theme.palette.text.disabled,
264
+ // boxShadow: 'none'
274
265
  }
275
266
  }
276
267
  }
@@ -0,0 +1,31 @@
1
+ /// <reference types="react" />
2
+ import { ComponentStory, ComponentMeta } from '@storybook/react';
3
+ declare const _default: ComponentMeta<({ menuOptions, open, ...props }: {
4
+ 'data-testid'?: string | undefined;
5
+ menuOptions: {
6
+ label: string;
7
+ icon?: import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | undefined;
8
+ }[];
9
+ } & import("@mui/material").MenuProps) => JSX.Element>;
10
+ export default _default;
11
+ export declare const Default: ComponentStory<({ menuOptions, open, ...props }: {
12
+ 'data-testid'?: string | undefined;
13
+ menuOptions: {
14
+ label: string;
15
+ icon?: import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | undefined;
16
+ }[];
17
+ } & import("@mui/material").MenuProps) => JSX.Element>;
18
+ export declare const WithIcons: ComponentStory<({ menuOptions, open, ...props }: {
19
+ 'data-testid'?: string | undefined;
20
+ menuOptions: {
21
+ label: string;
22
+ icon?: import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | undefined;
23
+ }[];
24
+ } & import("@mui/material").MenuProps) => JSX.Element>;
25
+ export declare const WithoutIcons: ComponentStory<({ menuOptions, open, ...props }: {
26
+ 'data-testid'?: string | undefined;
27
+ menuOptions: {
28
+ label: string;
29
+ icon?: import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | undefined;
30
+ }[];
31
+ } & import("@mui/material").MenuProps) => JSX.Element>;
@@ -0,0 +1,38 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import EditOutlinedIcon from '@mui/icons-material/EditOutlined';
3
+ import PersonAddAltOutlinedIcon from '@mui/icons-material/PersonAddAltOutlined';
4
+ import DeleteOutlinedIcon from '@mui/icons-material/DeleteOutlined';
5
+ import { editLabel, shareWithLabel, deleteLabel } from './constants';
6
+ import MenuFlyout from '.';
7
+ export default {
8
+ title: 'Components/MenuFlyout',
9
+ component: MenuFlyout
10
+ };
11
+ const Template = (args) => (_jsx(MenuFlyout, Object.assign({}, args)));
12
+ export const Default = Template.bind({});
13
+ Default.args = {
14
+ menuOptions: [
15
+ {
16
+ label: 'This is an example of a 2 line item',
17
+ icon: _jsx(EditOutlinedIcon, {})
18
+ },
19
+ { label: '1 Line Item', icon: _jsx(EditOutlinedIcon, {}) },
20
+ { label: '2 Line Item', icon: _jsx(EditOutlinedIcon, {}) }
21
+ ]
22
+ };
23
+ export const WithIcons = Template.bind({});
24
+ WithIcons.args = {
25
+ menuOptions: [
26
+ { label: editLabel, icon: _jsx(EditOutlinedIcon, {}) },
27
+ { label: shareWithLabel, icon: _jsx(PersonAddAltOutlinedIcon, {}) },
28
+ { label: deleteLabel, icon: _jsx(DeleteOutlinedIcon, {}) }
29
+ ]
30
+ };
31
+ export const WithoutIcons = Template.bind({});
32
+ WithoutIcons.args = {
33
+ menuOptions: [
34
+ { label: editLabel },
35
+ { label: shareWithLabel },
36
+ { label: deleteLabel }
37
+ ]
38
+ };
@@ -0,0 +1,24 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { render } from '../../../utils/tests/helpers';
3
+ import { screen } from '@testing-library/react';
4
+ import { editLabel, shareWithLabel } from '../constants';
5
+ import EditOutlinedIcon from '@mui/icons-material/EditOutlined';
6
+ import MenuFlyout from '..';
7
+ describe('<MenuFlyout />', () => {
8
+ const mockMenuOptions = [{ label: editLabel }, { label: shareWithLabel }];
9
+ const mockMenuIconOptions = [{ label: editLabel, icon: _jsx(EditOutlinedIcon, {}) }];
10
+ it('should render the MenuFlyout component, multi item list without icons', () => {
11
+ render(_jsx(MenuFlyout, { "data-testid": "menu-flyout", open: true, menuOptions: mockMenuOptions }));
12
+ expect(screen.getByTestId('menu-flyout')).toBeInTheDocument();
13
+ expect(screen.getByText(editLabel)).toBeInTheDocument();
14
+ expect(screen.getByText(shareWithLabel)).toBeInTheDocument();
15
+ expect(screen.getByRole('menu').children).toHaveLength(2);
16
+ });
17
+ it('should render MenuFlyout component, single item list with icon', () => {
18
+ render(_jsx(MenuFlyout, { "data-testid": "menu-flyout", open: true, menuOptions: mockMenuIconOptions }));
19
+ expect(screen.getByTestId('menu-flyout')).toBeInTheDocument();
20
+ expect(screen.getByText(editLabel)).toBeInTheDocument();
21
+ expect(screen.getByTestId('EditOutlinedIcon')).toBeVisible();
22
+ expect(screen.getByRole('menu').children).toHaveLength(1);
23
+ });
24
+ });
@@ -0,0 +1,3 @@
1
+ export declare const editLabel = "Edit Project";
2
+ export declare const shareWithLabel = "Share with...";
3
+ export declare const deleteLabel = "Delete Project";
@@ -0,0 +1,3 @@
1
+ export const editLabel = 'Edit Project';
2
+ export const shareWithLabel = 'Share with...';
3
+ export const deleteLabel = 'Delete Project';
@@ -0,0 +1,15 @@
1
+ import { MenuProps } from '@mui/material';
2
+ import React from 'react';
3
+ type MenuOption = {
4
+ label: string;
5
+ icon?: React.ReactElement;
6
+ };
7
+ type MenuFlyoutProps = {
8
+ 'data-testid'?: string;
9
+ /**
10
+ An array of objects of type `MenuOption[]`. Each object in this array **requires** a label property of type `string` and an **optional** icon property of type `React.ReactElement`. Each object represents a list item on the menu flyout component.
11
+ **/
12
+ menuOptions: MenuOption[];
13
+ } & MenuProps;
14
+ declare const MenuFlyout: ({ menuOptions, open, ...props }: MenuFlyoutProps) => JSX.Element;
15
+ export default MenuFlyout;
@@ -0,0 +1,27 @@
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 { Menu, MenuItem, ListItemIcon, Box, Typography } from '@mui/material';
14
+ const MenuFlyout = (_a) => {
15
+ var { menuOptions, open } = _a, props = __rest(_a, ["menuOptions", "open"]);
16
+ return (_jsx(Menu, Object.assign({ "data-testid": true, open: true }, props, { children: menuOptions.map((menuItem, index) => {
17
+ return (_jsx(MenuItem, { children: _jsxs(Box, Object.assign({ sx: {
18
+ display: 'flex',
19
+ alignItems: 'center'
20
+ } }, { children: [_jsx(Box, Object.assign({ sx: {
21
+ mr: '10px'
22
+ } }, { children: menuItem.icon && _jsx(ListItemIcon, { children: menuItem.icon }) })), _jsx(Box, { children: _jsx(Typography, Object.assign({ sx: {
23
+ fontSize: '14px'
24
+ } }, { children: menuItem.label })) })] })) }, index));
25
+ }) })));
26
+ };
27
+ export default MenuFlyout;
@@ -0,0 +1,41 @@
1
+ import { Theme } from '../../assets/theme';
2
+ export declare const menuFlyoutTheme: (theme: Theme) => {
3
+ styleOverrides: {
4
+ root: () => {
5
+ height: string;
6
+ fontSize: string;
7
+ borderRadius: string;
8
+ fontFamily: string;
9
+ fontStyle: string;
10
+ fontWeight: number;
11
+ textTransform: string;
12
+ backgroundColor: string;
13
+ ':hover, :focus': {
14
+ backgroundColor: string;
15
+ };
16
+ '& .MuiList-root, &.MuiMenu-list': {
17
+ minWidth: number;
18
+ maxWidth: number;
19
+ padding: number;
20
+ };
21
+ '& .MuiPaper-root': {
22
+ background: string;
23
+ border: string;
24
+ borderRadius: string;
25
+ padding: string;
26
+ gap: string;
27
+ boxShadow: string;
28
+ };
29
+ };
30
+ };
31
+ };
32
+ export declare const menuItemTheme: (theme: Theme) => {
33
+ styleOverrides: {
34
+ root: () => {
35
+ whiteSpace: string;
36
+ minWidth: number;
37
+ maxWidth: number;
38
+ padding: string;
39
+ };
40
+ };
41
+ };
@@ -0,0 +1,40 @@
1
+ export const menuFlyoutTheme = (theme) => ({
2
+ styleOverrides: {
3
+ root: () => ({
4
+ height: 'auto',
5
+ fontSize: '14px',
6
+ borderRadius: '2px',
7
+ fontFamily: 'Nunito',
8
+ fontStyle: 'normal',
9
+ fontWeight: 400,
10
+ textTransform: 'capitalize',
11
+ backgroundColor: theme.palette.common.white,
12
+ ':hover, :focus': {
13
+ backgroundColor: theme.palette.misc.altBackground
14
+ },
15
+ '& .MuiList-root, &.MuiMenu-list': {
16
+ minWidth: 168,
17
+ maxWidth: 200,
18
+ padding: 0
19
+ },
20
+ '& .MuiPaper-root': {
21
+ background: '#FFFFFF',
22
+ border: '1px solid #7C848D',
23
+ borderRadius: '0px 0px 4px 4px',
24
+ padding: '10px',
25
+ gap: '20px',
26
+ boxShadow: '3px 3px 5px rgba(0, 0, 0, 0.2)'
27
+ }
28
+ })
29
+ }
30
+ });
31
+ export const menuItemTheme = (theme) => ({
32
+ styleOverrides: {
33
+ root: () => ({
34
+ whiteSpace: 'normal',
35
+ minWidth: 168,
36
+ maxWidth: 200,
37
+ padding: '5px'
38
+ })
39
+ }
40
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@veritone-ce/design-system",
3
- "version": "1.12.8",
3
+ "version": "1.12.9",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "start": "yarn storybook",