@innovaccer/design-system 2.3.0 → 2.4.0-0
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/CHANGELOG.md +35 -0
- package/core/components/atoms/backdrop/Backdrop.tsx +11 -1
- package/core/components/atoms/button/Button.tsx +60 -44
- package/core/components/atoms/button/__stories__/IconButtonGroup.story.tsx +4 -4
- package/core/components/atoms/button/__stories__/IconButtonSecondary.story.tsx +1 -1
- package/core/components/atoms/button/__tests__/Button.test.tsx +36 -1
- package/core/components/atoms/dropdown/DropdownList.tsx +1 -0
- package/core/components/atoms/dropdown/Loading.tsx +9 -9
- package/core/components/atoms/dropdown/__stories__/Options.tsx +2 -0
- package/core/components/atoms/dropdown/__tests__/Dropdown.test.tsx +12 -1
- package/core/components/atoms/dropdown/__tests__/Loading.test.tsx +66 -0
- package/core/components/atoms/dropdown/__tests__/Option.test.tsx +204 -0
- package/core/components/atoms/dropdown/option/CheckboxOption.tsx +1 -0
- package/core/components/atoms/dropdown/option/IconOption.tsx +3 -1
- package/core/components/atoms/dropdown/option/IconWithMetaOption.tsx +3 -1
- package/core/components/atoms/dropdown/option/index.tsx +7 -1
- package/core/components/molecules/dialog/__tests__/__snapshots__/Dialog.test.tsx.snap +13 -0
- package/core/components/molecules/emptyState/__stories__/assets/pageNotLoaded.png +0 -0
- package/core/components/molecules/emptyState/__stories__/variants/noContentAvailable.story.tsx +26 -0
- package/core/components/molecules/emptyState/__stories__/variants/{smallSizeWithButton.story.tsx → noSearchResults.story.tsx} +2 -2
- package/core/components/molecules/emptyState/__stories__/variants/{largeSize.story.tsx → pageNotLoaded.story.tsx} +3 -3
- package/core/components/molecules/fileList/FileIcon.tsx +10 -2
- package/core/components/molecules/fileList/FileListItem.tsx +7 -3
- package/core/components/molecules/fileList/__stories__/__common__/fileListExample.tsx +1 -0
- package/core/components/molecules/fileList/__tests__/FileList.test.tsx +115 -0
- package/core/components/molecules/fileList/__tests__/__snapshots__/FileList.test.tsx.snap +232 -0
- package/core/components/molecules/inputMask/InputMask.tsx +2 -5
- package/core/components/molecules/inputMask/__tests__/InputMask.test.tsx +128 -0
- package/core/components/molecules/inputMask/__tests__/__snapshots__/InputMask.test.tsx.snap +39 -0
- package/core/components/molecules/modal/Modal.tsx +7 -5
- package/core/components/molecules/modal/__tests__/__snapshots__/Modal.test.tsx.snap +18 -0
- package/core/components/molecules/sidesheet/Sidesheet.tsx +5 -3
- package/core/components/molecules/sidesheet/__tests__/__snapshots__/Sidesheet.test.tsx.snap +2 -0
- package/core/components/organisms/calendar/Calendar.tsx +66 -22
- package/core/components/organisms/calendar/__stories__/variants/withEvents.story.tsx +45 -0
- package/core/components/organisms/calendar/__tests__/Calendar.test.tsx +10 -0
- package/core/components/organisms/calendar/__tests__/__snapshots__/Calendar.test.tsx.snap +1096 -1096
- package/core/components/organisms/calendar/config.ts +2 -2
- package/core/components/organisms/calendar/types.ts +1 -0
- package/core/components/organisms/datePicker/DatePicker.tsx +23 -9
- package/core/components/organisms/datePicker/__tests__/{DatePicker.tsx → DatePicker.test.tsx} +16 -1
- package/core/components/organisms/datePicker/__tests__/__snapshots__/DatePicker.test.tsx.snap +2257 -0
- package/core/components/organisms/dateRangePicker/__tests__/__snapshots__/DateRangePicker.test.tsx.snap +2552 -2550
- package/core/components/organisms/inlineMessage/InlineMessage.tsx +75 -0
- package/core/components/organisms/inlineMessage/__stories__/Default.story.tsx +18 -0
- package/core/components/organisms/inlineMessage/__stories__/Error.story.tsx +19 -0
- package/core/components/organisms/inlineMessage/__stories__/Info.story.tsx +19 -0
- package/core/components/organisms/inlineMessage/__stories__/Success.story.tsx +19 -0
- package/core/components/organisms/inlineMessage/__stories__/Warning.story.tsx +18 -0
- package/core/components/organisms/inlineMessage/__stories__/variants/InlineMessageWithinTable.story.tsx +139 -0
- package/core/components/organisms/inlineMessage/__tests__/InlineMessage.test.tsx +91 -0
- package/core/components/organisms/inlineMessage/__tests__/__snapshots__/InlineMessage.test.tsx.snap +139 -0
- package/core/components/organisms/inlineMessage/index.tsx +1 -0
- package/core/components/organisms/timePicker/__tests__/__snapshots__/TimePicker.test.tsx.snap +8 -0
- package/core/index.tsx +2 -0
- package/core/index.type.tsx +1 -0
- package/core/utils/__tests__/__snapshots__/TS.test.tsx.snap +485 -466
- package/css/dist/index.css +72 -8
- package/css/dist/index.css.map +1 -1
- package/css/src/components/calendar.css +37 -5
- package/css/src/components/card.css +1 -1
- package/css/src/components/chipInput.css +2 -2
- package/css/src/components/editableChipInput.css +2 -1
- package/css/src/components/inlineMessage.css +29 -0
- package/dist/core/components/atoms/backdrop/Backdrop.d.ts +1 -0
- package/dist/core/components/atoms/button/Button.d.ts +1 -0
- package/dist/core/components/atoms/popperWrapper/PopperWrapper.d.ts +28 -27
- package/dist/core/components/organisms/calendar/Calendar.d.ts +6 -1
- package/dist/core/components/organisms/calendar/types.d.ts +3 -0
- package/dist/core/components/organisms/inlineMessage/InlineMessage.d.ts +15 -0
- package/dist/core/components/organisms/inlineMessage/index.d.ts +1 -0
- package/dist/core/index.d.ts +1 -0
- package/dist/core/index.type.d.ts +1 -0
- package/dist/index.esm.js +189 -66
- package/dist/index.js +201 -80
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.br +0 -0
- package/dist/index.umd.js.gz +0 -0
- package/dts.config.js +13 -0
- package/package.json +4 -2
- package/types/innovaccer-design-system/index.d.ts +39 -0
- package/types/innovaccer-design-system/innovaccer-design-system-tests.ts +0 -0
- package/types/innovaccer-design-system/tsconfig.json +23 -0
- package/types/innovaccer-design-system/tslint.json +1 -0
- package/core/components/molecules/emptyState/__stories__/variants/smallSizeWithoutButton.story.tsx +0 -21
- package/core/components/organisms/datePicker/__tests__/__snapshots__/DatePicker.tsx.snap +0 -2164
|
@@ -132,6 +132,7 @@ const Option = (props: OptionProps) => {
|
|
|
132
132
|
if (props.optionRenderer) {
|
|
133
133
|
return (
|
|
134
134
|
<div
|
|
135
|
+
data-test="DesignSystem-DropdownOption--Custom"
|
|
135
136
|
className={customOptionClass}
|
|
136
137
|
data-disabled={disabled}
|
|
137
138
|
onMouseEnter={onUpdateActiveOption}
|
|
@@ -153,7 +154,11 @@ const Option = (props: OptionProps) => {
|
|
|
153
154
|
const iconAppearance = selected ? 'white' : 'disabled';
|
|
154
155
|
|
|
155
156
|
if (typeof subInfo === 'string') {
|
|
156
|
-
return
|
|
157
|
+
return (
|
|
158
|
+
<Text data-test="DesignSystem-DropdownOption--WITH_META--Meta" appearance={labelAppearance}>
|
|
159
|
+
{subInfo}
|
|
160
|
+
</Text>
|
|
161
|
+
);
|
|
157
162
|
}
|
|
158
163
|
|
|
159
164
|
const { list = [], seperator } = subInfo;
|
|
@@ -164,6 +169,7 @@ const Option = (props: OptionProps) => {
|
|
|
164
169
|
iconAppearance={iconAppearance}
|
|
165
170
|
labelAppearance={labelAppearance}
|
|
166
171
|
seperatorAppearance={iconAppearance}
|
|
172
|
+
data-test="DesignSystem-DropdownOption--WITH_META--MetaList"
|
|
167
173
|
/>
|
|
168
174
|
);
|
|
169
175
|
};
|
|
@@ -116,6 +116,7 @@ exports[`Dialog component
|
|
|
116
116
|
class="Backdrop Backdrop--open Backdrop-animation--open"
|
|
117
117
|
data-layer="true"
|
|
118
118
|
data-test="DesignSystem-Backdrop"
|
|
119
|
+
style="z-index: 1000;"
|
|
119
120
|
/>
|
|
120
121
|
</body>
|
|
121
122
|
`;
|
|
@@ -236,6 +237,7 @@ exports[`Dialog component
|
|
|
236
237
|
class="Backdrop Backdrop--open Backdrop-animation--open"
|
|
237
238
|
data-layer="true"
|
|
238
239
|
data-test="DesignSystem-Backdrop"
|
|
240
|
+
style="z-index: 1000;"
|
|
239
241
|
/>
|
|
240
242
|
</body>
|
|
241
243
|
`;
|
|
@@ -356,6 +358,7 @@ exports[`Dialog component
|
|
|
356
358
|
class="Backdrop Backdrop--open Backdrop-animation--open"
|
|
357
359
|
data-layer="true"
|
|
358
360
|
data-test="DesignSystem-Backdrop"
|
|
361
|
+
style="z-index: 1000;"
|
|
359
362
|
/>
|
|
360
363
|
</body>
|
|
361
364
|
`;
|
|
@@ -476,6 +479,7 @@ exports[`Dialog component
|
|
|
476
479
|
class="Backdrop Backdrop--open Backdrop-animation--open"
|
|
477
480
|
data-layer="true"
|
|
478
481
|
data-test="DesignSystem-Backdrop"
|
|
482
|
+
style="z-index: 1000;"
|
|
479
483
|
/>
|
|
480
484
|
</body>
|
|
481
485
|
`;
|
|
@@ -596,6 +600,7 @@ exports[`Dialog component
|
|
|
596
600
|
class="Backdrop Backdrop--open Backdrop-animation--open"
|
|
597
601
|
data-layer="true"
|
|
598
602
|
data-test="DesignSystem-Backdrop"
|
|
603
|
+
style="z-index: 1000;"
|
|
599
604
|
/>
|
|
600
605
|
</body>
|
|
601
606
|
`;
|
|
@@ -716,6 +721,7 @@ exports[`Dialog component
|
|
|
716
721
|
class="Backdrop Backdrop--open Backdrop-animation--open"
|
|
717
722
|
data-layer="true"
|
|
718
723
|
data-test="DesignSystem-Backdrop"
|
|
724
|
+
style="z-index: 1000;"
|
|
719
725
|
/>
|
|
720
726
|
</body>
|
|
721
727
|
`;
|
|
@@ -836,6 +842,7 @@ exports[`Dialog component
|
|
|
836
842
|
class="Backdrop Backdrop--open Backdrop-animation--open"
|
|
837
843
|
data-layer="true"
|
|
838
844
|
data-test="DesignSystem-Backdrop"
|
|
845
|
+
style="z-index: 1000;"
|
|
839
846
|
/>
|
|
840
847
|
</body>
|
|
841
848
|
`;
|
|
@@ -956,6 +963,7 @@ exports[`Dialog component
|
|
|
956
963
|
class="Backdrop Backdrop--open Backdrop-animation--open"
|
|
957
964
|
data-layer="true"
|
|
958
965
|
data-test="DesignSystem-Backdrop"
|
|
966
|
+
style="z-index: 1000;"
|
|
959
967
|
/>
|
|
960
968
|
</body>
|
|
961
969
|
`;
|
|
@@ -1076,6 +1084,7 @@ exports[`Dialog component
|
|
|
1076
1084
|
class="Backdrop Backdrop--open Backdrop-animation--open"
|
|
1077
1085
|
data-layer="true"
|
|
1078
1086
|
data-test="DesignSystem-Backdrop"
|
|
1087
|
+
style="z-index: 1000;"
|
|
1079
1088
|
/>
|
|
1080
1089
|
</body>
|
|
1081
1090
|
`;
|
|
@@ -1196,6 +1205,7 @@ exports[`Dialog component
|
|
|
1196
1205
|
class="Backdrop Backdrop--open Backdrop-animation--open"
|
|
1197
1206
|
data-layer="true"
|
|
1198
1207
|
data-test="DesignSystem-Backdrop"
|
|
1208
|
+
style="z-index: 1000;"
|
|
1199
1209
|
/>
|
|
1200
1210
|
</body>
|
|
1201
1211
|
`;
|
|
@@ -1316,6 +1326,7 @@ exports[`Dialog component
|
|
|
1316
1326
|
class="Backdrop Backdrop--open Backdrop-animation--open"
|
|
1317
1327
|
data-layer="true"
|
|
1318
1328
|
data-test="DesignSystem-Backdrop"
|
|
1329
|
+
style="z-index: 1000;"
|
|
1319
1330
|
/>
|
|
1320
1331
|
</body>
|
|
1321
1332
|
`;
|
|
@@ -1436,6 +1447,7 @@ exports[`Dialog component
|
|
|
1436
1447
|
class="Backdrop Backdrop--open Backdrop-animation--open"
|
|
1437
1448
|
data-layer="true"
|
|
1438
1449
|
data-test="DesignSystem-Backdrop"
|
|
1450
|
+
style="z-index: 1000;"
|
|
1439
1451
|
/>
|
|
1440
1452
|
</body>
|
|
1441
1453
|
`;
|
|
@@ -1556,6 +1568,7 @@ exports[`Dialog component
|
|
|
1556
1568
|
class="Backdrop Backdrop--open Backdrop-animation--open"
|
|
1557
1569
|
data-layer="true"
|
|
1558
1570
|
data-test="DesignSystem-Backdrop"
|
|
1571
|
+
style="z-index: 1000;"
|
|
1559
1572
|
/>
|
|
1560
1573
|
</body>
|
|
1561
1574
|
`;
|
package/core/components/molecules/emptyState/__stories__/variants/noContentAvailable.story.tsx
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { EmptyState, Button } from '@/index';
|
|
3
|
+
import { text } from '@storybook/addon-knobs';
|
|
4
|
+
import noContent from '../assets/noContent.png';
|
|
5
|
+
|
|
6
|
+
export const noContentAvailable = () => {
|
|
7
|
+
const title = text('title', 'Manage your outreach campaigns');
|
|
8
|
+
const description = text(
|
|
9
|
+
'description',
|
|
10
|
+
'Campaigns let you reach out to patients with text messages, emails and voice calls'
|
|
11
|
+
);
|
|
12
|
+
return (
|
|
13
|
+
<div className="h-100 pb-5" style={{ backgroundColor: 'var(--secondary-lightest)' }}>
|
|
14
|
+
<EmptyState title={title} description={description} imageSrc={noContent} size="large">
|
|
15
|
+
<Button size="large" appearance="primary">
|
|
16
|
+
Reload page
|
|
17
|
+
</Button>
|
|
18
|
+
</EmptyState>
|
|
19
|
+
</div>
|
|
20
|
+
);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export default {
|
|
24
|
+
title: 'Components/EmptyState/Variants/No Content Available',
|
|
25
|
+
component: EmptyState,
|
|
26
|
+
};
|
|
@@ -2,7 +2,7 @@ import * as React from 'react';
|
|
|
2
2
|
import { EmptyState, Button, Card } from '@/index';
|
|
3
3
|
import noSearch from '../assets/noSearch.png';
|
|
4
4
|
|
|
5
|
-
export const
|
|
5
|
+
export const noSearchResults = () => {
|
|
6
6
|
return (
|
|
7
7
|
<Card className="py-5">
|
|
8
8
|
<EmptyState
|
|
@@ -18,6 +18,6 @@ export const smallSizeWithButton = () => {
|
|
|
18
18
|
};
|
|
19
19
|
|
|
20
20
|
export default {
|
|
21
|
-
title: 'Components/EmptyState/Variants/
|
|
21
|
+
title: 'Components/EmptyState/Variants/No Search Results',
|
|
22
22
|
component: EmptyState,
|
|
23
23
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { EmptyState, Button } from '@/index';
|
|
3
|
-
import noContent from '../assets/
|
|
3
|
+
import noContent from '../assets/pageNotLoaded.png';
|
|
4
4
|
|
|
5
|
-
export const
|
|
5
|
+
export const pageNotLoaded = () => (
|
|
6
6
|
<div className="h-100 pb-5" style={{ backgroundColor: 'var(--secondary-lightest)' }}>
|
|
7
7
|
<EmptyState
|
|
8
8
|
title="There's a problem loading this page."
|
|
@@ -18,6 +18,6 @@ export const largeSize = () => (
|
|
|
18
18
|
);
|
|
19
19
|
|
|
20
20
|
export default {
|
|
21
|
-
title: 'Components/EmptyState/Variants/
|
|
21
|
+
title: 'Components/EmptyState/Variants/Page Not Loaded',
|
|
22
22
|
component: EmptyState,
|
|
23
23
|
};
|
|
@@ -45,9 +45,17 @@ export const FileIcon = (props: FileIconProps) => {
|
|
|
45
45
|
}, [status]);
|
|
46
46
|
|
|
47
47
|
if (status === 'uploading') {
|
|
48
|
-
return
|
|
48
|
+
return (
|
|
49
|
+
<ProgressRing
|
|
50
|
+
size="small"
|
|
51
|
+
value={progress || 0}
|
|
52
|
+
className={uploadingIconClass}
|
|
53
|
+
data-test="DesignSystem-FileListItem--ProgressRing"
|
|
54
|
+
/>
|
|
55
|
+
);
|
|
49
56
|
}
|
|
50
|
-
|
|
57
|
+
|
|
58
|
+
return <Icon name={IconMapping[fileType]} className={iconClass} data-test="DesignSystem-FileListItem--Icon" />;
|
|
51
59
|
};
|
|
52
60
|
|
|
53
61
|
FileIcon.displayName = 'FileIcon';
|
|
@@ -80,16 +80,20 @@ export const FileListItem = (props: FileListItemProps) => {
|
|
|
80
80
|
};
|
|
81
81
|
|
|
82
82
|
return (
|
|
83
|
-
<div {...baseProps} className={FileItemClass} onClick={onClickHandler}>
|
|
83
|
+
<div {...baseProps} className={FileItemClass} onClick={onClickHandler} data-test="DesignSystem-FileListItem">
|
|
84
84
|
<div className="FileItem-file">
|
|
85
85
|
<div className="FileItem-fileContent">
|
|
86
86
|
<FileIcon file={file} status={status} progress={progress} />
|
|
87
|
-
<Text
|
|
87
|
+
<Text
|
|
88
|
+
data-test="DesignSystem-FileListItem--Name"
|
|
89
|
+
className="FileItem-text"
|
|
90
|
+
appearance={status === 'completed' ? 'default' : 'subtle'}
|
|
91
|
+
>
|
|
88
92
|
{name}
|
|
89
93
|
</Text>
|
|
90
94
|
</div>
|
|
91
95
|
<div className="FileItem-actions">
|
|
92
|
-
<Text className="FileItem-size" appearance={'subtle'}>
|
|
96
|
+
<Text className="FileItem-size" appearance={'subtle'} data-test="DesignSystem-FileListItem--Size">
|
|
93
97
|
{fileSize || file.size}
|
|
94
98
|
</Text>
|
|
95
99
|
{!!actions && actions}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { render, fireEvent } from '@testing-library/react';
|
|
3
|
+
import { testHelper, filterUndefined, valueHelper, testMessageHelper } from '@/utils/testHelper';
|
|
4
|
+
import { fileList } from '../__stories__/__common__/fileListExample';
|
|
5
|
+
import { FileList, Button } from '@/index';
|
|
6
|
+
import { FileListProps as Props } from '@/index.type';
|
|
7
|
+
|
|
8
|
+
const FunctionValue = jest.fn();
|
|
9
|
+
|
|
10
|
+
describe('FileList component', () => {
|
|
11
|
+
const mapper: Record<string, any> = {
|
|
12
|
+
fileList: valueHelper(fileList, { required: true }),
|
|
13
|
+
onClick: valueHelper(FunctionValue, { required: true }),
|
|
14
|
+
actionRenderer: valueHelper(FunctionValue, { required: true }),
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const testFunc = (props: Record<string, any>): void => {
|
|
18
|
+
const attr = filterUndefined(props) as Props;
|
|
19
|
+
|
|
20
|
+
it(testMessageHelper(attr), () => {
|
|
21
|
+
const { asFragment } = render(<FileList {...attr} />);
|
|
22
|
+
expect(asFragment()).toMatchSnapshot();
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
testHelper(mapper, testFunc);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
describe('FileList component', () => {
|
|
30
|
+
it('does not render if file list is empty', () => {
|
|
31
|
+
const { queryByTestId } = render(<FileList fileList={[]} />);
|
|
32
|
+
expect(queryByTestId('DesignSystem-FileListItem')).not.toBeInTheDocument();
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it('renders list of files', () => {
|
|
36
|
+
const { getAllByTestId } = render(<FileList fileList={fileList} />);
|
|
37
|
+
expect(getAllByTestId('DesignSystem-FileListItem')).toHaveLength(fileList.length);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it('renders name of file', () => {
|
|
41
|
+
const { getAllByTestId } = render(<FileList fileList={fileList} />);
|
|
42
|
+
expect(getAllByTestId('DesignSystem-FileListItem--Name')[0].textContent).toMatch(fileList[0].file.name);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it('renders size of file', () => {
|
|
46
|
+
const { getAllByTestId } = render(<FileList fileList={fileList} />);
|
|
47
|
+
expect(getAllByTestId('DesignSystem-FileListItem--Size')[0].textContent).toMatch(`${fileList[0].file.size}`);
|
|
48
|
+
expect(getAllByTestId('DesignSystem-FileListItem--Size')[1].textContent).toMatch(`${fileList[1].fileSize}`);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it('renders file with status: completed', () => {
|
|
52
|
+
const { getAllByTestId } = render(<FileList fileList={fileList} />);
|
|
53
|
+
expect(getAllByTestId('DesignSystem-FileListItem--Icon')[0]).toHaveClass('FileIcon--animate');
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it('renders file with status: uploading', () => {
|
|
57
|
+
const { getByTestId } = render(<FileList fileList={[fileList[0]]} />);
|
|
58
|
+
expect(getByTestId('DesignSystem-FileListItem--ProgressRing')).toBeInTheDocument();
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it('renders file with status: error', () => {
|
|
62
|
+
const { getByTestId } = render(<FileList fileList={[fileList[2]]} />);
|
|
63
|
+
expect(getByTestId('DesignSystem-Caption').textContent).toMatch(`${fileList[2].errorMessage}`);
|
|
64
|
+
expect(getByTestId('DesignSystem-FileListItem--Name')).toHaveClass('Text--subtle');
|
|
65
|
+
expect(getByTestId('DesignSystem-FileListItem--Icon')).not.toHaveClass('FileIcon--animate');
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
describe('FileList component with prop: onClick', () => {
|
|
70
|
+
it('onClick callback is called', () => {
|
|
71
|
+
const { getAllByTestId } = render(<FileList fileList={fileList} onClick={FunctionValue} />);
|
|
72
|
+
|
|
73
|
+
const fileItem = getAllByTestId('DesignSystem-FileListItem')[0];
|
|
74
|
+
fireEvent.click(fileItem);
|
|
75
|
+
expect(FunctionValue).toHaveBeenCalled();
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
describe('FileList component with different file icons', () => {
|
|
80
|
+
it('renders video file icon', () => {
|
|
81
|
+
const { getByTestId } = render(<FileList fileList={[fileList[1]]} />);
|
|
82
|
+
expect(getByTestId('DesignSystem-FileListItem--Icon').textContent).toMatch('movie');
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
it('renders document file icon', () => {
|
|
86
|
+
const { getByTestId } = render(<FileList fileList={[fileList[3]]} />);
|
|
87
|
+
expect(getByTestId('DesignSystem-FileListItem--Icon').textContent).toMatch('insert_drive_file');
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
it('renders other file icon', () => {
|
|
91
|
+
const { getByTestId } = render(<FileList fileList={[fileList[4]]} />);
|
|
92
|
+
expect(getByTestId('DesignSystem-FileListItem--Icon').textContent).toMatch('text_snippet');
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
describe('FileList component with prop: actionRenderer', () => {
|
|
97
|
+
it('onClick callback is called', () => {
|
|
98
|
+
const { getAllByTestId } = render(
|
|
99
|
+
<FileList
|
|
100
|
+
fileList={fileList}
|
|
101
|
+
actionRenderer={() => (
|
|
102
|
+
<Button
|
|
103
|
+
appearance="transparent"
|
|
104
|
+
icon="close"
|
|
105
|
+
size="regular"
|
|
106
|
+
data-test="DesignSystem-FileList--Button"
|
|
107
|
+
className="cursor-pointer"
|
|
108
|
+
/>
|
|
109
|
+
)}
|
|
110
|
+
/>
|
|
111
|
+
);
|
|
112
|
+
|
|
113
|
+
expect(getAllByTestId('DesignSystem-FileList--Button')).toHaveLength(fileList.length);
|
|
114
|
+
});
|
|
115
|
+
});
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`FileList component
|
|
4
|
+
fileList: [{"file":{"name":"Audio File.mp3","size":"3 MB","type":"audio"},"status":"uploading","progress":45,"id":1},{"file":{"name":"Video File.mp4","size":"3 MB","type":"video"},"status":"completed","fileSize":"4 MB","id":2},{"file":{"name":"Image File.jpeg","size":"3 MB","type":"image"},"status":"error","errorMessage":"Network failure","id":3},{"file":{"name":"Document File.pdf","size":"3 MB","type":"application"},"status":"completed","id":4},{"file":{"name":"Other File","size":"3 MB","type":"others"},"status":"completed"}], onClick: "[Function]", actionRenderer: "[Function]"
|
|
5
|
+
1`] = `
|
|
6
|
+
<DocumentFragment>
|
|
7
|
+
<div
|
|
8
|
+
class="Card Card--shadow-none"
|
|
9
|
+
>
|
|
10
|
+
<div
|
|
11
|
+
class="FileItem"
|
|
12
|
+
data-test="DesignSystem-FileListItem"
|
|
13
|
+
>
|
|
14
|
+
<div
|
|
15
|
+
class="FileItem-file"
|
|
16
|
+
>
|
|
17
|
+
<div
|
|
18
|
+
class="FileItem-fileContent"
|
|
19
|
+
>
|
|
20
|
+
<svg
|
|
21
|
+
class="Ring Ring--small FileIcon FileIcon--uploading"
|
|
22
|
+
data-test="DesignSystem-FileListItem--ProgressRing"
|
|
23
|
+
viewBox="0 0 50 50"
|
|
24
|
+
>
|
|
25
|
+
<circle
|
|
26
|
+
class="Ring-background"
|
|
27
|
+
cx="25"
|
|
28
|
+
cy="25"
|
|
29
|
+
fill="none"
|
|
30
|
+
r="20"
|
|
31
|
+
stroke-dasharray="125.66370614359172 125.66370614359172"
|
|
32
|
+
stroke-width="8"
|
|
33
|
+
/>
|
|
34
|
+
<circle
|
|
35
|
+
class="Ring-indicator"
|
|
36
|
+
cx="25"
|
|
37
|
+
cy="25"
|
|
38
|
+
data-test="DesignSystem-ProgressRing--Circle"
|
|
39
|
+
fill="none"
|
|
40
|
+
r="20"
|
|
41
|
+
stroke-dasharray="125.66370614359172 125.66370614359172"
|
|
42
|
+
stroke-dashoffset="69.11503837897544"
|
|
43
|
+
stroke-width="8"
|
|
44
|
+
/>
|
|
45
|
+
</svg>
|
|
46
|
+
<span
|
|
47
|
+
class="Text Text--subtle Text--regular FileItem-text"
|
|
48
|
+
data-test="DesignSystem-FileListItem--Name"
|
|
49
|
+
>
|
|
50
|
+
Audio File.mp3
|
|
51
|
+
</span>
|
|
52
|
+
</div>
|
|
53
|
+
<div
|
|
54
|
+
class="FileItem-actions"
|
|
55
|
+
>
|
|
56
|
+
<span
|
|
57
|
+
class="Text Text--subtle Text--regular FileItem-size"
|
|
58
|
+
data-test="DesignSystem-FileListItem--Size"
|
|
59
|
+
>
|
|
60
|
+
3 MB
|
|
61
|
+
</span>
|
|
62
|
+
</div>
|
|
63
|
+
</div>
|
|
64
|
+
</div>
|
|
65
|
+
<div
|
|
66
|
+
class="FileItem"
|
|
67
|
+
data-test="DesignSystem-FileListItem"
|
|
68
|
+
>
|
|
69
|
+
<div
|
|
70
|
+
class="FileItem-file"
|
|
71
|
+
>
|
|
72
|
+
<div
|
|
73
|
+
class="FileItem-fileContent"
|
|
74
|
+
>
|
|
75
|
+
<i
|
|
76
|
+
class="material-icons material-icons-round Icon FileIcon FileIcon--animate FileIcon--video"
|
|
77
|
+
data-test="DesignSystem-FileListItem--Icon"
|
|
78
|
+
style="font-size: 16px; width: 16px;"
|
|
79
|
+
>
|
|
80
|
+
movie_round
|
|
81
|
+
</i>
|
|
82
|
+
<span
|
|
83
|
+
class="Text Text--default Text--regular FileItem-text"
|
|
84
|
+
data-test="DesignSystem-FileListItem--Name"
|
|
85
|
+
>
|
|
86
|
+
Video File.mp4
|
|
87
|
+
</span>
|
|
88
|
+
</div>
|
|
89
|
+
<div
|
|
90
|
+
class="FileItem-actions"
|
|
91
|
+
>
|
|
92
|
+
<span
|
|
93
|
+
class="Text Text--subtle Text--regular FileItem-size"
|
|
94
|
+
data-test="DesignSystem-FileListItem--Size"
|
|
95
|
+
>
|
|
96
|
+
4 MB
|
|
97
|
+
</span>
|
|
98
|
+
</div>
|
|
99
|
+
</div>
|
|
100
|
+
</div>
|
|
101
|
+
<div
|
|
102
|
+
class="FileItem"
|
|
103
|
+
data-test="DesignSystem-FileListItem"
|
|
104
|
+
>
|
|
105
|
+
<div
|
|
106
|
+
class="FileItem-file"
|
|
107
|
+
>
|
|
108
|
+
<div
|
|
109
|
+
class="FileItem-fileContent"
|
|
110
|
+
>
|
|
111
|
+
<i
|
|
112
|
+
class="material-icons material-icons-round Icon FileIcon FileIcon--image"
|
|
113
|
+
data-test="DesignSystem-FileListItem--Icon"
|
|
114
|
+
style="font-size: 16px; width: 16px;"
|
|
115
|
+
>
|
|
116
|
+
image_round
|
|
117
|
+
</i>
|
|
118
|
+
<span
|
|
119
|
+
class="Text Text--subtle Text--regular FileItem-text"
|
|
120
|
+
data-test="DesignSystem-FileListItem--Name"
|
|
121
|
+
>
|
|
122
|
+
Image File.jpeg
|
|
123
|
+
</span>
|
|
124
|
+
</div>
|
|
125
|
+
<div
|
|
126
|
+
class="FileItem-actions"
|
|
127
|
+
>
|
|
128
|
+
<span
|
|
129
|
+
class="Text Text--subtle Text--regular FileItem-size"
|
|
130
|
+
data-test="DesignSystem-FileListItem--Size"
|
|
131
|
+
>
|
|
132
|
+
3 MB
|
|
133
|
+
</span>
|
|
134
|
+
</div>
|
|
135
|
+
</div>
|
|
136
|
+
<div
|
|
137
|
+
class="Caption FileItem-error"
|
|
138
|
+
data-test="DesignSystem-Caption"
|
|
139
|
+
>
|
|
140
|
+
<div
|
|
141
|
+
class="Caption-icon"
|
|
142
|
+
>
|
|
143
|
+
<i
|
|
144
|
+
class="material-icons material-icons-round Icon Icon--alert"
|
|
145
|
+
style="font-size: 14px; width: 14px;"
|
|
146
|
+
>
|
|
147
|
+
error_round
|
|
148
|
+
</i>
|
|
149
|
+
</div>
|
|
150
|
+
<span
|
|
151
|
+
class="Text Text--destructive Text--medium Text--small"
|
|
152
|
+
data-test="DesignSystem-Text"
|
|
153
|
+
>
|
|
154
|
+
Network failure
|
|
155
|
+
</span>
|
|
156
|
+
</div>
|
|
157
|
+
</div>
|
|
158
|
+
<div
|
|
159
|
+
class="FileItem"
|
|
160
|
+
data-test="DesignSystem-FileListItem"
|
|
161
|
+
>
|
|
162
|
+
<div
|
|
163
|
+
class="FileItem-file"
|
|
164
|
+
>
|
|
165
|
+
<div
|
|
166
|
+
class="FileItem-fileContent"
|
|
167
|
+
>
|
|
168
|
+
<i
|
|
169
|
+
class="material-icons material-icons-round Icon FileIcon FileIcon--animate FileIcon--application"
|
|
170
|
+
data-test="DesignSystem-FileListItem--Icon"
|
|
171
|
+
style="font-size: 16px; width: 16px;"
|
|
172
|
+
>
|
|
173
|
+
insert_drive_file_round
|
|
174
|
+
</i>
|
|
175
|
+
<span
|
|
176
|
+
class="Text Text--default Text--regular FileItem-text"
|
|
177
|
+
data-test="DesignSystem-FileListItem--Name"
|
|
178
|
+
>
|
|
179
|
+
Document File.pdf
|
|
180
|
+
</span>
|
|
181
|
+
</div>
|
|
182
|
+
<div
|
|
183
|
+
class="FileItem-actions"
|
|
184
|
+
>
|
|
185
|
+
<span
|
|
186
|
+
class="Text Text--subtle Text--regular FileItem-size"
|
|
187
|
+
data-test="DesignSystem-FileListItem--Size"
|
|
188
|
+
>
|
|
189
|
+
3 MB
|
|
190
|
+
</span>
|
|
191
|
+
</div>
|
|
192
|
+
</div>
|
|
193
|
+
</div>
|
|
194
|
+
<div
|
|
195
|
+
class="FileItem"
|
|
196
|
+
data-test="DesignSystem-FileListItem"
|
|
197
|
+
>
|
|
198
|
+
<div
|
|
199
|
+
class="FileItem-file"
|
|
200
|
+
>
|
|
201
|
+
<div
|
|
202
|
+
class="FileItem-fileContent"
|
|
203
|
+
>
|
|
204
|
+
<i
|
|
205
|
+
class="material-icons material-icons-round Icon FileIcon FileIcon--animate FileIcon--others"
|
|
206
|
+
data-test="DesignSystem-FileListItem--Icon"
|
|
207
|
+
style="font-size: 16px; width: 16px;"
|
|
208
|
+
>
|
|
209
|
+
text_snippet_round
|
|
210
|
+
</i>
|
|
211
|
+
<span
|
|
212
|
+
class="Text Text--default Text--regular FileItem-text"
|
|
213
|
+
data-test="DesignSystem-FileListItem--Name"
|
|
214
|
+
>
|
|
215
|
+
Other File
|
|
216
|
+
</span>
|
|
217
|
+
</div>
|
|
218
|
+
<div
|
|
219
|
+
class="FileItem-actions"
|
|
220
|
+
>
|
|
221
|
+
<span
|
|
222
|
+
class="Text Text--subtle Text--regular FileItem-size"
|
|
223
|
+
data-test="DesignSystem-FileListItem--Size"
|
|
224
|
+
>
|
|
225
|
+
3 MB
|
|
226
|
+
</span>
|
|
227
|
+
</div>
|
|
228
|
+
</div>
|
|
229
|
+
</div>
|
|
230
|
+
</div>
|
|
231
|
+
</DocumentFragment>
|
|
232
|
+
`;
|
|
@@ -214,10 +214,7 @@ export const InputMask = React.forwardRef<HTMLInputElement, InputMaskProps>((pro
|
|
|
214
214
|
const newValue = maskedVal.slice(0, mask.length).join('');
|
|
215
215
|
window.requestAnimationFrame(() => setCursorPosition(cursorPosition));
|
|
216
216
|
|
|
217
|
-
if (
|
|
218
|
-
Utils.validators.isValid(validators, newValue)
|
|
219
|
-
&& newValue !== value
|
|
220
|
-
) {
|
|
217
|
+
if (Utils.validators.isValid(validators, newValue) && newValue !== value) {
|
|
221
218
|
setValue(newValue);
|
|
222
219
|
if (onChange) onChange(e, newValue);
|
|
223
220
|
}
|
|
@@ -265,7 +262,7 @@ export const InputMask = React.forwardRef<HTMLInputElement, InputMaskProps>((pro
|
|
|
265
262
|
);
|
|
266
263
|
|
|
267
264
|
return (
|
|
268
|
-
<div className={classes}>
|
|
265
|
+
<div className={classes} data-test="DesignSystem-InputMask--Wrapper">
|
|
269
266
|
<Input
|
|
270
267
|
{...rest}
|
|
271
268
|
value={value}
|