@veritone-ce/design-system 1.12.3 → 1.12.5
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/IconListItem/index.d.ts +3 -1
- package/dist/components/IconListItem/index.js +2 -2
- package/dist/components/ModelGridView/ModelGridView.stories.d.ts +5 -0
- package/dist/components/ModelGridView/ModelGridView.stories.js +44 -0
- package/dist/components/ModelGridView/__tests__/ModelGridView.test.d.ts +1 -0
- package/dist/components/ModelGridView/__tests__/ModelGridView.test.js +43 -0
- package/dist/components/ModelGridView/index.d.ts +13 -0
- package/dist/components/ModelGridView/index.js +159 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/package.json +1 -1
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
type ListItemIconProps = {
|
|
2
3
|
'data-testid'?: string;
|
|
4
|
+
children?: React.ReactNode;
|
|
3
5
|
};
|
|
4
|
-
declare const IconListItem: ({ ...props }: ListItemIconProps) => JSX.Element;
|
|
6
|
+
declare const IconListItem: ({ children, ...props }: ListItemIconProps) => JSX.Element;
|
|
5
7
|
export default IconListItem;
|
|
@@ -12,7 +12,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
12
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
13
|
import ListItemIcon from '@mui/material/ListItemIcon';
|
|
14
14
|
const IconListItem = (_a) => {
|
|
15
|
-
var props = __rest(_a, []);
|
|
16
|
-
return _jsx(ListItemIcon, Object.assign({}, props));
|
|
15
|
+
var { children } = _a, props = __rest(_a, ["children"]);
|
|
16
|
+
return _jsx(ListItemIcon, Object.assign({}, props, { children: children }));
|
|
17
17
|
};
|
|
18
18
|
export default IconListItem;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ComponentStory, Story, ComponentMeta } from '@storybook/react';
|
|
2
|
+
import ModelGridView from '.';
|
|
3
|
+
declare const _default: ComponentMeta<({ rows }: import(".").ModelGridViewProps) => JSX.Element>;
|
|
4
|
+
export default _default;
|
|
5
|
+
export declare const Default: ComponentStory<typeof ModelGridView> | Story;
|
|
@@ -0,0 +1,44 @@
|
|
|
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 } from "react/jsx-runtime";
|
|
13
|
+
import ModelGridView from '.';
|
|
14
|
+
const mockData = [
|
|
15
|
+
{
|
|
16
|
+
modelName: 'Lebron James',
|
|
17
|
+
lastModified: 'MM/DD/YYYY HH:MM',
|
|
18
|
+
consentForm: 'Complete',
|
|
19
|
+
versions: 2,
|
|
20
|
+
deployed: 2
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
modelName: 'John Madden',
|
|
24
|
+
lastModified: 'MM/DD/YYYY HH:MM',
|
|
25
|
+
consentForm: 'Complete',
|
|
26
|
+
versions: 2,
|
|
27
|
+
deployed: 0
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
modelName: 'Ryan Seacrest',
|
|
31
|
+
lastModified: 'MM/DD/YYYY HH:MM',
|
|
32
|
+
consentForm: 'Complete',
|
|
33
|
+
versions: 2,
|
|
34
|
+
deployed: 0
|
|
35
|
+
}
|
|
36
|
+
];
|
|
37
|
+
export default {
|
|
38
|
+
title: 'Components/ModelGridView',
|
|
39
|
+
component: ModelGridView
|
|
40
|
+
};
|
|
41
|
+
export const Default = (_a) => {
|
|
42
|
+
var args = __rest(_a, []);
|
|
43
|
+
return _jsx(ModelGridView, Object.assign({ rows: mockData }, args));
|
|
44
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { render } from '../../../utils/tests/helpers';
|
|
3
|
+
import { fireEvent, screen } from '@testing-library/react';
|
|
4
|
+
import ModelGridView from '..';
|
|
5
|
+
const mockData = [
|
|
6
|
+
{
|
|
7
|
+
modelName: 'Lebron James',
|
|
8
|
+
lastModified: 'MM/DD/YYYY HH:MM',
|
|
9
|
+
consentForm: 'Complete',
|
|
10
|
+
versions: 2,
|
|
11
|
+
deployed: 2
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
modelName: 'John Madden',
|
|
15
|
+
lastModified: 'MM/DD/YYYY HH:MM',
|
|
16
|
+
consentForm: 'Complete',
|
|
17
|
+
versions: 2,
|
|
18
|
+
deployed: 0
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
modelName: 'Ryan Seacrest',
|
|
22
|
+
lastModified: 'MM/DD/YYYY HH:MM',
|
|
23
|
+
consentForm: 'Complete',
|
|
24
|
+
versions: 2,
|
|
25
|
+
deployed: 0
|
|
26
|
+
}
|
|
27
|
+
];
|
|
28
|
+
describe('<ModelGridView />', () => {
|
|
29
|
+
it('should render the ModelGridView component', () => {
|
|
30
|
+
render(_jsx(ModelGridView, { rows: mockData }));
|
|
31
|
+
expect(screen.getByText('Model Name')).toBeInTheDocument();
|
|
32
|
+
});
|
|
33
|
+
it('should change order of lines', () => {
|
|
34
|
+
render(_jsx(ModelGridView, { rows: mockData }));
|
|
35
|
+
expect(fireEvent.click(screen.getAllByTestId('ArrowDownwardIcon')[0]));
|
|
36
|
+
expect(fireEvent.click(screen.getAllByTestId('ArrowDownwardIcon')[0]));
|
|
37
|
+
});
|
|
38
|
+
it('should select item', () => {
|
|
39
|
+
render(_jsx(ModelGridView, { rows: mockData }));
|
|
40
|
+
expect(fireEvent.click(screen.getAllByTestId('MoreVertIcon')[0]));
|
|
41
|
+
expect(fireEvent.click(screen.getAllByText('Edit Model')[0]));
|
|
42
|
+
});
|
|
43
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
interface ModelGridViewData {
|
|
2
|
+
modelName: string;
|
|
3
|
+
lastModified: string;
|
|
4
|
+
consentForm: string;
|
|
5
|
+
versions: number;
|
|
6
|
+
deployed: number;
|
|
7
|
+
}
|
|
8
|
+
export type ModelGridViewProps = {
|
|
9
|
+
'data-testid'?: string;
|
|
10
|
+
rows: ModelGridViewData[];
|
|
11
|
+
};
|
|
12
|
+
declare const ModelGridView: ({ rows }: ModelGridViewProps) => JSX.Element;
|
|
13
|
+
export default ModelGridView;
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { Box, IconButton, Link, Menu, MenuItem, Paper, Table, TableBody, TableCell, TableContainer, TableHead, TableRow, TableSortLabel } from '@mui/material';
|
|
4
|
+
import { visuallyHidden } from '@mui/utils';
|
|
5
|
+
import MoreVertIcon from '@mui/icons-material/MoreVert';
|
|
6
|
+
import EditOutlinedIcon from '@mui/icons-material/EditOutlined';
|
|
7
|
+
import ArticleRoundedIcon from '@mui/icons-material/ArticleRounded';
|
|
8
|
+
function descendingComparator(a, b, orderBy) {
|
|
9
|
+
if (b[orderBy] < a[orderBy]) {
|
|
10
|
+
return -1;
|
|
11
|
+
}
|
|
12
|
+
if (b[orderBy] > a[orderBy]) {
|
|
13
|
+
return 1;
|
|
14
|
+
}
|
|
15
|
+
return 0;
|
|
16
|
+
}
|
|
17
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
18
|
+
function getComparator(order, orderBy) {
|
|
19
|
+
return order === 'desc'
|
|
20
|
+
? (a, b) => descendingComparator(a, b, orderBy)
|
|
21
|
+
: (a, b) => -descendingComparator(a, b, orderBy);
|
|
22
|
+
}
|
|
23
|
+
const headCells = [
|
|
24
|
+
{
|
|
25
|
+
id: 'modelName',
|
|
26
|
+
numeric: false,
|
|
27
|
+
disablePadding: false,
|
|
28
|
+
label: 'Model Name',
|
|
29
|
+
sortable: true
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
id: 'lastModified',
|
|
33
|
+
numeric: false,
|
|
34
|
+
disablePadding: false,
|
|
35
|
+
label: 'Last Modified',
|
|
36
|
+
sortable: true
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
id: 'consentForm',
|
|
40
|
+
numeric: false,
|
|
41
|
+
disablePadding: true,
|
|
42
|
+
label: 'Consent Form'
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
id: 'versions',
|
|
46
|
+
numeric: false,
|
|
47
|
+
disablePadding: true,
|
|
48
|
+
label: 'Versions'
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
id: 'deployed',
|
|
52
|
+
numeric: false,
|
|
53
|
+
disablePadding: true,
|
|
54
|
+
label: 'Deployed'
|
|
55
|
+
}
|
|
56
|
+
];
|
|
57
|
+
function EnhancedTableHead(props) {
|
|
58
|
+
const { order, orderBy, onRequestSort } = props;
|
|
59
|
+
const createSortHandler = (property) => (event) => {
|
|
60
|
+
onRequestSort(event, property);
|
|
61
|
+
};
|
|
62
|
+
return (_jsx(TableHead, { children: _jsxs(TableRow, Object.assign({ sx: {
|
|
63
|
+
'& .MuiTableCell-root': {
|
|
64
|
+
borderBottomColor: (theme) => theme.palette.text.disabled,
|
|
65
|
+
padding: '14.25px 16px',
|
|
66
|
+
'&.MuiTableCell-paddingNone': {
|
|
67
|
+
padding: 0
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
} }, { children: [headCells.map((headCell) => (_jsxs(TableCell, Object.assign({ padding: headCell.disablePadding ? 'none' : 'normal', sortDirection: orderBy === headCell.id ? order : false }, { children: [headCell.label, headCell.sortable && (_jsx(TableSortLabel, Object.assign({ active: orderBy === headCell.id, direction: orderBy === headCell.id ? order : 'desc', onClick: createSortHandler(headCell.id), sx: {
|
|
71
|
+
'& .MuiSvgIcon-root': {
|
|
72
|
+
opacity: 1,
|
|
73
|
+
fill: '#1B1D1F',
|
|
74
|
+
':hover': {
|
|
75
|
+
opacity: 1,
|
|
76
|
+
fill: '#1B1D1F'
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
} }, { children: orderBy === headCell.id ? (_jsx(Box, Object.assign({ component: "span", sx: visuallyHidden }, { children: order === 'desc'
|
|
80
|
+
? 'sorted descending'
|
|
81
|
+
: 'sorted ascending' }))) : null })))] }), headCell.id))), _jsx(TableCell, {})] })) }));
|
|
82
|
+
}
|
|
83
|
+
const ModelGridView = ({ rows }) => {
|
|
84
|
+
const [order, setOrder] = React.useState('desc');
|
|
85
|
+
const [orderBy, setOrderBy] = React.useState('lastModified');
|
|
86
|
+
const [anchorEl, setAnchorEl] = React.useState(null);
|
|
87
|
+
const open = Boolean(anchorEl);
|
|
88
|
+
const menuOptions = [
|
|
89
|
+
{ icon: _jsx(EditOutlinedIcon, {}), label: 'Edit Model' },
|
|
90
|
+
{ icon: _jsx(ArticleRoundedIcon, {}), label: 'View Conset Form' }
|
|
91
|
+
];
|
|
92
|
+
const handleClick = (event) => {
|
|
93
|
+
setAnchorEl(event.currentTarget);
|
|
94
|
+
};
|
|
95
|
+
const handleClose = () => {
|
|
96
|
+
setAnchorEl(null);
|
|
97
|
+
};
|
|
98
|
+
const handleRequestSort = (event, property) => {
|
|
99
|
+
const isAsc = orderBy === property && order === 'asc';
|
|
100
|
+
setOrder(isAsc ? 'desc' : 'asc');
|
|
101
|
+
setOrderBy(property);
|
|
102
|
+
};
|
|
103
|
+
return (_jsx(Box, Object.assign({ sx: { width: '100%' } }, { children: _jsx(Paper, Object.assign({ sx: { width: '100%', mb: 2, boxShadow: 'none' } }, { children: _jsx(TableContainer, Object.assign({ sx: {
|
|
104
|
+
'& .MuiTableCell-root': {
|
|
105
|
+
lineHeight: '21px',
|
|
106
|
+
fontWeight: 400
|
|
107
|
+
}
|
|
108
|
+
} }, { children: _jsxs(Table, Object.assign({ sx: { minWidth: 750 }, "aria-labelledby": "tableTitle", size: 'medium' }, { children: [_jsx(EnhancedTableHead, { order: order, orderBy: orderBy, onRequestSort: handleRequestSort }), _jsx(TableBody, { children: rows
|
|
109
|
+
.slice()
|
|
110
|
+
.sort(getComparator(order, orderBy))
|
|
111
|
+
.map((row, index) => {
|
|
112
|
+
const labelId = `enhanced-table-checkbox-${index}`;
|
|
113
|
+
return (_jsxs(TableRow, Object.assign({ tabIndex: -1, sx: {
|
|
114
|
+
'& .MuiTableCell-root': {
|
|
115
|
+
borderBottomColor: (theme) => theme.palette.misc.altBackground,
|
|
116
|
+
padding: '17px 16px',
|
|
117
|
+
'&.MuiTableCell-paddingNone': {
|
|
118
|
+
padding: 0
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
} }, { children: [_jsx(TableCell, Object.assign({ component: "th", id: labelId, scope: "row", padding: "none" }, { children: _jsx(Link, Object.assign({ href: "#", underline: "always", sx: {
|
|
122
|
+
'&.MuiLink-underlineAlways': {
|
|
123
|
+
color: (theme) => theme.palette.button.main,
|
|
124
|
+
textDecorationColor: (theme) => theme.palette.button.main
|
|
125
|
+
}
|
|
126
|
+
} }, { children: row.modelName })) })), _jsx(TableCell, Object.assign({ align: "left" }, { children: row.lastModified })), _jsx(TableCell, Object.assign({ align: "left" }, { children: _jsx(Box, Object.assign({ sx: {
|
|
127
|
+
display: 'flex',
|
|
128
|
+
flexDirection: 'row',
|
|
129
|
+
justifyContent: 'center',
|
|
130
|
+
alignItems: 'center',
|
|
131
|
+
backgroundColor: (theme) => theme.palette.success.main,
|
|
132
|
+
color: (theme) => theme.palette.common.white,
|
|
133
|
+
width: '82px',
|
|
134
|
+
height: '18px',
|
|
135
|
+
borderRadius: '2px',
|
|
136
|
+
fontStyle: 'normal',
|
|
137
|
+
fontWeight: 800,
|
|
138
|
+
fontSize: '9px',
|
|
139
|
+
lineHeight: '12px',
|
|
140
|
+
textTransform: 'uppercase'
|
|
141
|
+
} }, { children: row.consentForm })) })), _jsx(TableCell, Object.assign({ align: "left" }, { children: row.versions })), _jsx(TableCell, Object.assign({ align: "left" }, { children: row.deployed === 0 ? '--' : row.deployed })), _jsxs(TableCell, Object.assign({ align: "right", padding: "none" }, { children: [_jsx(IconButton, Object.assign({ "aria-label": "more", id: "long-button", "aria-controls": open ? 'long-menu' : undefined, "aria-expanded": open ? 'true' : undefined, "aria-haspopup": "true", onClick: handleClick }, { children: _jsx(MoreVertIcon, {}) })), _jsx(Menu, Object.assign({ id: "long-menu", MenuListProps: {
|
|
142
|
+
'aria-labelledby': 'long-button'
|
|
143
|
+
}, anchorEl: anchorEl, open: open, onClose: handleClose, PaperProps: {
|
|
144
|
+
style: {
|
|
145
|
+
boxShadow: '0px 2px 8px rgba(0, 0, 0, 0.25)',
|
|
146
|
+
borderRadius: 0
|
|
147
|
+
}
|
|
148
|
+
} }, { children: menuOptions.map((option) => (_jsxs(MenuItem, Object.assign({ onClick: handleClose, sx: {
|
|
149
|
+
fontSize: '14px',
|
|
150
|
+
lineHeight: '20px',
|
|
151
|
+
height: '46px',
|
|
152
|
+
gap: '13px',
|
|
153
|
+
'& .MuiSvgIcon-root': {
|
|
154
|
+
color: (theme) => theme.palette.text.tertiary
|
|
155
|
+
}
|
|
156
|
+
} }, { children: [option.icon, option.label] }), option.label))) }))] }))] }), row.modelName));
|
|
157
|
+
}) })] })) })) })) })));
|
|
158
|
+
};
|
|
159
|
+
export default ModelGridView;
|
package/dist/index.d.ts
CHANGED
|
@@ -24,5 +24,6 @@ export { default as ListItemText } from './components/ListItemText';
|
|
|
24
24
|
export { default as RadioGroup } from './components/RadioGroup';
|
|
25
25
|
export { default as Step } from './components/Step';
|
|
26
26
|
export { default as StepLabel } from './components/StepLabel';
|
|
27
|
+
export { default as ModelGridView } from './components/ModelGridView';
|
|
27
28
|
export { default as theme } from './assets/theme';
|
|
28
29
|
export { useTheme } from '@mui/material';
|
package/dist/index.js
CHANGED
|
@@ -24,5 +24,6 @@ export { default as ListItemText } from './components/ListItemText';
|
|
|
24
24
|
export { default as RadioGroup } from './components/RadioGroup';
|
|
25
25
|
export { default as Step } from './components/Step';
|
|
26
26
|
export { default as StepLabel } from './components/StepLabel';
|
|
27
|
+
export { default as ModelGridView } from './components/ModelGridView';
|
|
27
28
|
export { default as theme } from './assets/theme';
|
|
28
29
|
export { useTheme } from '@mui/material';
|