@veritone-ce/design-system 1.7.1 → 1.8.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/dist/assets/theme.d.ts +1 -1
- package/dist/components/Button/Button.stories.d.ts +1 -0
- package/dist/components/Button/Indicator.d.ts +1 -0
- package/dist/components/Button/index.d.ts +2 -1
- package/dist/components/Checkbox/Checkbox.stories.d.ts +1 -0
- package/dist/components/Checkbox/index.d.ts +2 -1
- package/dist/components/FileUploader/FileUploader.stories.d.ts +1 -0
- package/dist/components/FileUploader/index.d.ts +2 -1
- package/dist/components/FileUploader/useUploadFile.js +21 -14
- package/dist/components/Input/Input.stories.d.ts +1 -0
- package/dist/components/Input/index.d.ts +2 -1
- package/dist/components/Panel/Panel.stories.d.ts +14 -0
- package/dist/components/Panel/Panel.stories.js +46 -0
- package/dist/components/Panel/__tests__/Panel.test.d.ts +1 -0
- package/dist/components/Panel/__tests__/Panel.test.js +44 -0
- package/dist/components/Panel/index.d.ts +11 -0
- package/dist/components/Panel/index.js +79 -0
- package/dist/components/ProgressIndicator/DefaultProgress.d.ts +1 -0
- package/dist/components/ProgressIndicator/MLProgress.d.ts +1 -0
- package/dist/components/ProgressIndicator/ProgressIndicator.stories.d.ts +1 -0
- package/dist/components/ProgressIndicator/index.d.ts +2 -1
- package/dist/components/RadioButton/RadioButton.stories.d.ts +1 -0
- package/dist/components/RadioButton/index.d.ts +2 -1
- package/dist/components/Select/Select.stories.d.ts +1 -0
- package/dist/components/Select/index.d.ts +3 -2
- package/dist/components/ThemeProvider/index.d.ts +1 -0
- package/dist/utils/tests/helpers.d.ts +1 -1
- package/package.json +4 -1
package/dist/assets/theme.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
import { Accept } from 'react-dropzone';
|
|
2
3
|
export interface FileData {
|
|
3
4
|
file: File;
|
|
@@ -5,7 +6,7 @@ export interface FileData {
|
|
|
5
6
|
isUploaded: boolean;
|
|
6
7
|
withError: boolean;
|
|
7
8
|
}
|
|
8
|
-
|
|
9
|
+
type FileUploaderProps = {
|
|
9
10
|
'data-testid'?: string;
|
|
10
11
|
accept?: Accept;
|
|
11
12
|
multiple?: boolean;
|
|
@@ -18,7 +18,7 @@ import axios from 'axios';
|
|
|
18
18
|
import { useCallback } from 'react';
|
|
19
19
|
export const useUploadFile = (setfileList, uploadUrl, onSuccess, onError) => {
|
|
20
20
|
const onDrop = useCallback((acceptedFiles) => __awaiter(void 0, void 0, void 0, function* () {
|
|
21
|
-
var e_1,
|
|
21
|
+
var _a, e_1, _b, _c;
|
|
22
22
|
if (!uploadUrl) {
|
|
23
23
|
onError && onError(new Error('upload url is required'));
|
|
24
24
|
return;
|
|
@@ -31,30 +31,37 @@ export const useUploadFile = (setfileList, uploadUrl, onSuccess, onError) => {
|
|
|
31
31
|
}));
|
|
32
32
|
setfileList(newList);
|
|
33
33
|
try {
|
|
34
|
-
for (var
|
|
35
|
-
|
|
34
|
+
for (var _d = true, _e = __asyncValues(newList.entries()), _f; _f = yield _e.next(), _a = _f.done, !_a;) {
|
|
35
|
+
_c = _f.value;
|
|
36
|
+
_d = false;
|
|
36
37
|
try {
|
|
37
|
-
|
|
38
|
+
const [index, file] = _c;
|
|
39
|
+
try {
|
|
40
|
+
yield uploadFile(uploadUrl, file.file, (progress) => {
|
|
41
|
+
const nList = [...newList];
|
|
42
|
+
nList.splice(index, 1, Object.assign(Object.assign({}, file), { isUploaded: progress === 100, uploadProgress: progress }));
|
|
43
|
+
newList = nList;
|
|
44
|
+
setfileList(nList);
|
|
45
|
+
});
|
|
46
|
+
onSuccess && onSuccess(true);
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
38
49
|
const nList = [...newList];
|
|
39
|
-
nList.splice(index, 1, Object.assign(Object.assign({}, file), { isUploaded:
|
|
50
|
+
nList.splice(index, 1, Object.assign(Object.assign({}, file), { isUploaded: false, uploadProgress: 0, withError: true }));
|
|
40
51
|
newList = nList;
|
|
41
52
|
setfileList(nList);
|
|
42
|
-
|
|
43
|
-
|
|
53
|
+
onError && onError(error);
|
|
54
|
+
}
|
|
44
55
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
nList.splice(index, 1, Object.assign(Object.assign({}, file), { isUploaded: false, uploadProgress: 0, withError: true }));
|
|
48
|
-
newList = nList;
|
|
49
|
-
setfileList(nList);
|
|
50
|
-
onError && onError(error);
|
|
56
|
+
finally {
|
|
57
|
+
_d = true;
|
|
51
58
|
}
|
|
52
59
|
}
|
|
53
60
|
}
|
|
54
61
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
55
62
|
finally {
|
|
56
63
|
try {
|
|
57
|
-
if (
|
|
64
|
+
if (!_d && !_a && (_b = _e.return)) yield _b.call(_e);
|
|
58
65
|
}
|
|
59
66
|
finally { if (e_1) throw e_1.error; }
|
|
60
67
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
import { TextFieldProps } from '@mui/material';
|
|
2
|
-
|
|
3
|
+
type InputComponentProps = {
|
|
3
4
|
'data-testid'?: string;
|
|
4
5
|
} & TextFieldProps;
|
|
5
6
|
declare const Input: ({ ...TextFieldProps }: InputComponentProps) => JSX.Element;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { Story, ComponentMeta } from '@storybook/react';
|
|
3
|
+
declare const _default: ComponentMeta<({ title, isOpen, children, size, handleClose, ...props }: {
|
|
4
|
+
title: string;
|
|
5
|
+
isOpen: boolean;
|
|
6
|
+
size?: "big" | "small" | "medium" | undefined;
|
|
7
|
+
children?: import("react").ReactNode;
|
|
8
|
+
handleClose?: (() => void) | undefined;
|
|
9
|
+
'data-testid'?: string | undefined;
|
|
10
|
+
}) => JSX.Element>;
|
|
11
|
+
export default _default;
|
|
12
|
+
export declare const Big: Story;
|
|
13
|
+
export declare const Medium: Story;
|
|
14
|
+
export declare const Small: Story;
|
|
@@ -0,0 +1,46 @@
|
|
|
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 Panel from '.';
|
|
14
|
+
export default {
|
|
15
|
+
title: 'Components/Panel',
|
|
16
|
+
component: Panel,
|
|
17
|
+
argTypes: {
|
|
18
|
+
title: {
|
|
19
|
+
defaultValue: 'Panel',
|
|
20
|
+
control: {
|
|
21
|
+
type: 'text'
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
isOpen: {
|
|
25
|
+
control: {
|
|
26
|
+
type: 'boolean'
|
|
27
|
+
},
|
|
28
|
+
defaultValue: true
|
|
29
|
+
},
|
|
30
|
+
handleClose: { control: false },
|
|
31
|
+
'data-testid': { control: false },
|
|
32
|
+
size: { control: false }
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
export const Big = (_a) => {
|
|
36
|
+
var args = __rest(_a, []);
|
|
37
|
+
return (_jsx(Panel, Object.assign({ title: "Big Panel", isOpen: true }, args)));
|
|
38
|
+
};
|
|
39
|
+
export const Medium = (_a) => {
|
|
40
|
+
var args = __rest(_a, []);
|
|
41
|
+
return (_jsx(Panel, Object.assign({ title: "Medium Panel", isOpen: true, size: "medium" }, args)));
|
|
42
|
+
};
|
|
43
|
+
export const Small = (_a) => {
|
|
44
|
+
var args = __rest(_a, []);
|
|
45
|
+
return (_jsx(Panel, Object.assign({ title: "Small Panel", size: "small", isOpen: true }, args)));
|
|
46
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { screen, render, fireEvent } from '@testing-library/react';
|
|
3
|
+
import Panel from '..';
|
|
4
|
+
describe('<Panel />', () => {
|
|
5
|
+
it('should render the Panel component with primary variant', () => {
|
|
6
|
+
render(_jsx(Panel, Object.assign({ title: "Panel title", isOpen: false }, { children: "With some children" })));
|
|
7
|
+
expect(screen.getByText('Panel title')).toBeInTheDocument();
|
|
8
|
+
expect(screen.getByTestId('wrapper-panel')).toBeInTheDocument();
|
|
9
|
+
expect(screen.getByTestId('panel-close-icon')).toBeInTheDocument();
|
|
10
|
+
const header = screen.getByTestId('header-panel');
|
|
11
|
+
const style = getComputedStyle(header);
|
|
12
|
+
expect(style.background).toBe('rgb(156, 39, 176)');
|
|
13
|
+
});
|
|
14
|
+
it('should render the Panel component with big size', () => {
|
|
15
|
+
render(_jsx(Panel, Object.assign({ title: "Panel title", isOpen: true }, { children: "With some children" })));
|
|
16
|
+
const wrapper = screen.getByTestId('wrapper-panel');
|
|
17
|
+
const style = getComputedStyle(wrapper);
|
|
18
|
+
expect(style.maxWidth).toBe('720px');
|
|
19
|
+
});
|
|
20
|
+
it('should render the Panel component with medium size', () => {
|
|
21
|
+
render(_jsx(Panel, Object.assign({ size: "medium", title: "Panel title", isOpen: true }, { children: "With some children" })));
|
|
22
|
+
const wrapper = screen.getByTestId('wrapper-panel');
|
|
23
|
+
const style = getComputedStyle(wrapper);
|
|
24
|
+
expect(style.maxWidth).toBe('560px');
|
|
25
|
+
});
|
|
26
|
+
it('should render the Panel component with small size', () => {
|
|
27
|
+
render(_jsx(Panel, Object.assign({ size: "small", title: "Panel title", isOpen: true }, { children: "With some children" })));
|
|
28
|
+
const wrapper = screen.getByTestId('wrapper-panel');
|
|
29
|
+
const style = getComputedStyle(wrapper);
|
|
30
|
+
expect(style.maxWidth).toBe('380px');
|
|
31
|
+
});
|
|
32
|
+
it('should close the Panel component', () => {
|
|
33
|
+
const handleClose = jest.fn();
|
|
34
|
+
render(_jsx(Panel, { title: "Panel title", isOpen: true, handleClose: handleClose }));
|
|
35
|
+
const buttonClose = screen.getByTestId('close-button-wrapper-panel');
|
|
36
|
+
fireEvent.click(buttonClose);
|
|
37
|
+
expect(handleClose).toBeCalled();
|
|
38
|
+
});
|
|
39
|
+
it('should creates data test id in props', () => {
|
|
40
|
+
render(_jsx(Panel, { title: "Panel title", isOpen: true, "data-testid": "panel-test" }));
|
|
41
|
+
expect(screen.getByTestId('overlay-panel-test')).toBeInTheDocument();
|
|
42
|
+
expect(screen.getByTestId('close-button-panel-test')).toBeInTheDocument();
|
|
43
|
+
});
|
|
44
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
type PanelProps = {
|
|
3
|
+
title: string;
|
|
4
|
+
isOpen: boolean;
|
|
5
|
+
size?: 'big' | 'medium' | 'small';
|
|
6
|
+
children?: ReactNode;
|
|
7
|
+
handleClose?: () => void;
|
|
8
|
+
'data-testid'?: string;
|
|
9
|
+
};
|
|
10
|
+
declare const Panel: ({ title, isOpen, children, size, handleClose, ...props }: PanelProps) => JSX.Element;
|
|
11
|
+
export default Panel;
|
|
@@ -0,0 +1,79 @@
|
|
|
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 { Box, Typography, useTheme } from '@mui/material';
|
|
14
|
+
import CloseIcon from '@mui/icons-material/Close';
|
|
15
|
+
const Panel = (_a) => {
|
|
16
|
+
var { title, isOpen, children, size = 'big', handleClose } = _a, props = __rest(_a, ["title", "isOpen", "children", "size", "handleClose"]);
|
|
17
|
+
const { palette } = useTheme();
|
|
18
|
+
return (_jsx(Box, Object.assign({ component: "div", "data-testid": props['data-testid']
|
|
19
|
+
? `overlay-${props['data-testid']}`
|
|
20
|
+
: 'overlay-panel', sx: {
|
|
21
|
+
position: 'absolute',
|
|
22
|
+
top: 0,
|
|
23
|
+
left: 0,
|
|
24
|
+
right: 0,
|
|
25
|
+
bottom: 0,
|
|
26
|
+
zIndex: 1,
|
|
27
|
+
display: !isOpen ? 'none' : 'block'
|
|
28
|
+
} }, { children: _jsxs(Box, Object.assign({ component: "div", "data-testid": props['data-testid'] || 'wrapper-panel', sx: {
|
|
29
|
+
position: 'absolute',
|
|
30
|
+
background: palette.common.white,
|
|
31
|
+
maxWidth: size === 'medium' ? '560px' : size === 'small' ? '380px' : '720px',
|
|
32
|
+
width: '100%',
|
|
33
|
+
height: '99vh',
|
|
34
|
+
display: 'flex',
|
|
35
|
+
flexDirection: 'column',
|
|
36
|
+
boxShadow: `0 4px 10px ${palette.text.primary}80`,
|
|
37
|
+
overflow: 'auto',
|
|
38
|
+
borderBottom: `5px solid ${palette.secondary.main}`,
|
|
39
|
+
zIndex: 2
|
|
40
|
+
} }, { children: [_jsxs(Box, Object.assign({ component: "header", "data-testid": "header-panel", sx: {
|
|
41
|
+
background: palette.secondary.main,
|
|
42
|
+
height: '64px',
|
|
43
|
+
padding: '0px 25px 0px 30px',
|
|
44
|
+
display: 'flex',
|
|
45
|
+
alignItems: 'center',
|
|
46
|
+
justifyContent: 'space-between',
|
|
47
|
+
position: 'sticky',
|
|
48
|
+
top: 0
|
|
49
|
+
} }, { children: [_jsx(Typography, Object.assign({ sx: {
|
|
50
|
+
fontFamily: 'Dosis',
|
|
51
|
+
textTransform: 'uppercase',
|
|
52
|
+
fontWeight: 600,
|
|
53
|
+
fontSize: '18px',
|
|
54
|
+
color: palette.common.white,
|
|
55
|
+
lineHeight: '23px',
|
|
56
|
+
letterSpacing: '0.25px'
|
|
57
|
+
} }, { children: title })), _jsx(Box, Object.assign({ component: "button", "aria-label": "close-button-panel", "data-testid": props['data-testid']
|
|
58
|
+
? `close-button-${props['data-testid']}`
|
|
59
|
+
: 'close-button-wrapper-panel', onClick: handleClose, sx: {
|
|
60
|
+
cursor: 'pointer',
|
|
61
|
+
background: 'transparent',
|
|
62
|
+
border: 'none',
|
|
63
|
+
width: '26px',
|
|
64
|
+
height: '26px',
|
|
65
|
+
display: 'flex',
|
|
66
|
+
alignItems: 'center',
|
|
67
|
+
justifyContent: 'center'
|
|
68
|
+
} }, { children: _jsx(CloseIcon, { "data-testid": "panel-close-icon", sx: {
|
|
69
|
+
fill: palette.common.white,
|
|
70
|
+
margin: 'auto'
|
|
71
|
+
} }) }))] })), _jsx(Box, Object.assign({ component: "div", sx: {
|
|
72
|
+
overflow: 'auto',
|
|
73
|
+
flex: 1
|
|
74
|
+
} }, { children: _jsx(Box, Object.assign({ component: "div", "data-testid": "panel-content", sx: {
|
|
75
|
+
flex: 1,
|
|
76
|
+
padding: '30px'
|
|
77
|
+
} }, { children: children })) }))] })) })));
|
|
78
|
+
};
|
|
79
|
+
export default Panel;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
import { SelectProps as MuiSelectProps } from '@mui/material';
|
|
2
|
-
|
|
3
|
+
type ItemData = {
|
|
3
4
|
title?: string;
|
|
4
5
|
name: string;
|
|
5
6
|
value: string | number;
|
|
6
7
|
};
|
|
7
|
-
export
|
|
8
|
+
export type SelectProps = {
|
|
8
9
|
'data-testid'?: string;
|
|
9
10
|
label: string;
|
|
10
11
|
items: ItemData[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { RenderOptions } from '@testing-library/react';
|
|
2
2
|
import { ReactElement } from 'react';
|
|
3
|
-
export
|
|
3
|
+
export type CustomRenderProps = Omit<RenderOptions, 'queries'>;
|
|
4
4
|
declare const customRender: (ui: ReactElement, { ...renderOptions }?: CustomRenderProps) => import("@testing-library/react").RenderResult<typeof import("@testing-library/dom/types/queries"), HTMLElement, HTMLElement>;
|
|
5
5
|
export * from '@testing-library/react';
|
|
6
6
|
export { customRender as render };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@veritone-ce/design-system",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"scripts": {
|
|
6
6
|
"start": "yarn storybook",
|
|
@@ -60,6 +60,8 @@
|
|
|
60
60
|
"@babel/preset-react": "^7.18.6",
|
|
61
61
|
"@commitlint/cli": "^17.0.3",
|
|
62
62
|
"@commitlint/config-conventional": "^17.0.3",
|
|
63
|
+
"@emotion/babel-plugin": "^11.10.5",
|
|
64
|
+
"@emotion/jest": "^11.10.5",
|
|
63
65
|
"@storybook/addon-a11y": "^6.5.13",
|
|
64
66
|
"@storybook/addon-actions": "^6.5.13",
|
|
65
67
|
"@storybook/addon-essentials": "^6.5.13",
|
|
@@ -77,6 +79,7 @@
|
|
|
77
79
|
"@typescript-eslint/parser": "^5.45.0",
|
|
78
80
|
"auto": "^10.37.6",
|
|
79
81
|
"babel-jest": "^29.3.1",
|
|
82
|
+
"babel-plugin-macros": "^3.1.0",
|
|
80
83
|
"babel-plugin-named-exports-order": "^0.0.2",
|
|
81
84
|
"chromatic": "^6.10.1",
|
|
82
85
|
"cross-env": "^7.0.3",
|