@groupeactual/ui-kit 1.7.9 → 2.0.0-beta.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/dist/cjs/index.js +15097 -66
- package/dist/es/{src/DesignSystemProvider.d.ts → DesignSystemProvider.d.ts} +6 -5
- package/dist/es/{src/components → components}/Accordion/Accordion.d.ts +1 -1
- package/dist/es/{src/components → components}/BannerNotification/BannerNotification.d.ts +1 -1
- package/dist/es/{src/components → components}/Breadcrumbs/Breadcrumbs.d.ts +2 -2
- package/dist/es/{src/components → components}/Button/Button.d.ts +2 -2
- package/dist/es/{src/components → components}/Chip/Chip.d.ts +1 -1
- package/dist/es/components/Datatable/Datatable.d.ts +4 -0
- package/dist/es/{src/components → components}/EmbbededNotification/EmbeddedNotification.d.ts +1 -1
- package/dist/es/{src/components/UploadDocument → components/FileUploader}/FileUploader.d.ts +1 -1
- package/dist/es/components/Form/AutoCompleteMulti/AutoCompleteMulti.d.ts +23 -0
- package/dist/es/{src/components → components}/Form/AutoCompleteSingle/AutoCompleteSingle.d.ts +8 -5
- package/dist/es/components/Form/Checkbox/Checkbox.d.ts +12 -0
- package/dist/es/components/Form/CheckboxGroup/CheckboxGroup.d.ts +12 -0
- package/dist/es/components/Form/CheckboxGroup/checkboxgroup.interface.d.ts +6 -0
- package/dist/es/{src/components → components}/Form/DatePicker/DatePicker.d.ts +6 -4
- package/dist/es/{src/components → components}/Form/MultiSelect/MultiSelect.d.ts +3 -3
- package/dist/es/components/Form/RadioGroup/RadioGroup.d.ts +16 -0
- package/dist/es/{src/components → components}/Form/Select/Select.d.ts +3 -3
- package/dist/es/components/Form/Switch/Switch.d.ts +11 -0
- package/dist/es/{src/components → components}/Form/TextField/TextField.d.ts +6 -5
- package/dist/es/{src/components → components}/Form/TimePicker/TimePicker.d.ts +3 -3
- package/dist/es/{src/components → components}/IconButton/IconButton.d.ts +3 -3
- package/dist/es/components/IconProvider/IconProvider.d.ts +24 -0
- package/dist/es/{src/components → components}/Link/Link.d.ts +1 -2
- package/dist/es/components/MenuItem/MenuItem.d.ts +9 -0
- package/dist/es/components/Modal/Dialog/Dialog.d.ts +4 -0
- package/dist/es/components/Modal/Drawer/Drawer.d.ts +4 -0
- package/dist/es/{src/components → components}/Modal/modal.interface.d.ts +4 -1
- package/dist/es/{src/components → components}/Navigation/Stepper/Stepper.d.ts +1 -1
- package/dist/es/{src/components → components}/Pagination/Pagination.d.ts +2 -1
- package/dist/es/{src/components → components}/Snackbar/Snackbar.d.ts +1 -1
- package/dist/es/components/TabsPanel/TabsPanel.d.ts +4 -0
- package/dist/es/components/TabsPanel/index.d.ts +1 -0
- package/dist/es/components/TabsPanel/tab.interface.d.ts +17 -0
- package/dist/es/components/Text/Text.d.ts +8 -0
- package/dist/es/{src/components → components}/Tooltip/Tooltip.d.ts +1 -1
- package/dist/es/{src/components → components}/index.d.ts +3 -2
- package/dist/es/index.d.ts +108 -153
- package/dist/es/index.js +37 -79
- package/package.json +20 -17
- package/src/DesignSystemProvider.tsx +21 -36
- package/src/components/Accordion/Accordion.tsx +41 -59
- package/src/components/BannerNotification/BannerNotification.tsx +19 -20
- package/src/components/Breadcrumbs/Breadcrumbs.tsx +32 -28
- package/src/components/Button/Button.tsx +70 -17
- package/src/components/Chip/Chip.tsx +88 -117
- package/src/components/Datatable/Datatable.tsx +49 -37
- package/src/components/Datatable/DatatableCellRender.tsx +1 -1
- package/src/components/EmbbededNotification/EmbeddedNotification.tsx +78 -69
- package/src/components/FileUploader/FileUploader.tsx +767 -0
- package/src/components/Form/AutoCompleteMulti/AutoCompleteMulti.tsx +289 -172
- package/src/components/Form/AutoCompleteSingle/AutoCompleteSingle.tsx +228 -126
- package/src/components/Form/Checkbox/Checkbox.tsx +38 -96
- package/src/components/Form/CheckboxGroup/CheckboxGroup.tsx +86 -60
- package/src/components/Form/CheckboxGroup/checkboxgroup.interface.ts +0 -15
- package/src/components/Form/DatePicker/DatePicker.tsx +88 -40
- package/src/components/Form/MultiSelect/MultiSelect.tsx +196 -171
- package/src/components/Form/RadioGroup/RadioGroup.tsx +76 -82
- package/src/components/Form/Select/Select.tsx +156 -136
- package/src/components/Form/Switch/Switch.tsx +87 -47
- package/src/components/Form/TextField/TextField.tsx +125 -76
- package/src/components/Form/TimePicker/TimePicker.tsx +26 -7
- package/src/components/IconButton/IconButton.tsx +64 -39
- package/src/components/IconProvider/IconProvider.tsx +90 -69
- package/src/components/Link/Link.tsx +6 -10
- package/src/components/MenuItem/MenuItem.tsx +35 -23
- package/src/components/Modal/Dialog/Dialog.tsx +17 -14
- package/src/components/Modal/Drawer/Drawer.tsx +97 -69
- package/src/components/Modal/modal.interface.ts +4 -1
- package/src/components/Navigation/Stepper/Step.tsx +7 -6
- package/src/components/Navigation/Stepper/Stepper.tsx +24 -23
- package/src/components/NotistackAdapter/NotistackAdapter.tsx +1 -1
- package/src/components/Pagination/Pagination.tsx +131 -118
- package/src/components/Snackbar/Snackbar.tsx +29 -29
- package/src/components/TabsPanel/TabsPanel.tsx +151 -0
- package/src/components/TabsPanel/index.ts +1 -0
- package/src/components/TabsPanel/tab.interface.ts +20 -0
- package/src/components/Text/Text.tsx +25 -12
- package/src/components/Tooltip/Tooltip.tsx +54 -51
- package/src/components/index.ts +3 -2
- package/src/index.ts +0 -1
- package/dist/es/src/components/Datatable/Datatable.d.ts +0 -4
- package/dist/es/src/components/Form/AutoCompleteMulti/AutoCompleteMulti.d.ts +0 -19
- package/dist/es/src/components/Form/Checkbox/Checkbox.d.ts +0 -14
- package/dist/es/src/components/Form/CheckboxGroup/CheckboxGroup.d.ts +0 -12
- package/dist/es/src/components/Form/CheckboxGroup/checkboxgroup.interface.d.ts +0 -8
- package/dist/es/src/components/Form/RadioGroup/RadioGroup.d.ts +0 -18
- package/dist/es/src/components/Form/Switch/Switch.d.ts +0 -10
- package/dist/es/src/components/IconProvider/IconProvider.d.ts +0 -19
- package/dist/es/src/components/MenuItem/MenuItem.d.ts +0 -10
- package/dist/es/src/components/Modal/Dialog/Dialog.d.ts +0 -4
- package/dist/es/src/components/Modal/Drawer/Drawer.d.ts +0 -4
- package/dist/es/src/components/Text/Text.d.ts +0 -8
- package/dist/es/src/index.d.ts +0 -5
- package/dist/es/src/interfaces/theme.d.ts +0 -51
- package/src/components/UploadDocument/FileUploader.tsx +0 -728
- package/src/interfaces/theme.ts +0 -51
- /package/dist/es/{src/components → components}/Accordion/index.d.ts +0 -0
- /package/dist/es/{src/components → components}/BannerNotification/index.d.ts +0 -0
- /package/dist/es/{src/components → components}/Breadcrumbs/index.d.ts +0 -0
- /package/dist/es/{src/components → components}/Button/index.d.ts +0 -0
- /package/dist/es/{src/components → components}/Chip/index.d.ts +0 -0
- /package/dist/es/{src/components → components}/Datatable/DatatableCellRender.d.ts +0 -0
- /package/dist/es/{src/components → components}/Datatable/datatable.interface.d.ts +0 -0
- /package/dist/es/{src/components → components}/Datatable/index.d.ts +0 -0
- /package/dist/es/{src/components → components}/Datatable/use-pagination-props.hook.d.ts +0 -0
- /package/dist/es/{src/components → components}/EmbbededNotification/index.d.ts +0 -0
- /package/dist/es/{src/components/UploadDocument → components/FileUploader}/fileuploader.interface.d.ts +0 -0
- /package/dist/es/{src/components/UploadDocument → components/FileUploader}/index.d.ts +0 -0
- /package/dist/es/{src/components → components}/Form/AutoCompleteMulti/index.d.ts +0 -0
- /package/dist/es/{src/components → components}/Form/AutoCompleteSingle/index.d.ts +0 -0
- /package/dist/es/{src/components → components}/Form/Checkbox/index.d.ts +0 -0
- /package/dist/es/{src/components → components}/Form/CheckboxGroup/index.d.ts +0 -0
- /package/dist/es/{src/components → components}/Form/DatePicker/index.d.ts +0 -0
- /package/dist/es/{src/components → components}/Form/MultiSelect/index.d.ts +0 -0
- /package/dist/es/{src/components → components}/Form/RadioGroup/index.d.ts +0 -0
- /package/dist/es/{src/components → components}/Form/Select/index.d.ts +0 -0
- /package/dist/es/{src/components → components}/Form/Switch/index.d.ts +0 -0
- /package/dist/es/{src/components → components}/Form/TextField/index.d.ts +0 -0
- /package/dist/es/{src/components → components}/Form/TimePicker/index.d.ts +0 -0
- /package/dist/es/{src/components → components}/IconButton/index.d.ts +0 -0
- /package/dist/es/{src/components → components}/IconProvider/index.d.ts +0 -0
- /package/dist/es/{src/components → components}/Link/index.d.ts +0 -0
- /package/dist/es/{src/components → components}/MenuItem/index.d.ts +0 -0
- /package/dist/es/{src/components → components}/Modal/Dialog/index.d.ts +0 -0
- /package/dist/es/{src/components → components}/Modal/Drawer/index.d.ts +0 -0
- /package/dist/es/{src/components → components}/Navigation/Stepper/Step.d.ts +0 -0
- /package/dist/es/{src/components → components}/Navigation/Stepper/index.d.ts +0 -0
- /package/dist/es/{src/components → components}/Navigation/Stepper/stepper.helper.d.ts +0 -0
- /package/dist/es/{src/components → components}/Navigation/Stepper/stepper.interface.d.ts +0 -0
- /package/dist/es/{src/components → components}/NotistackAdapter/NotistackAdapter.d.ts +0 -0
- /package/dist/es/{src/components → components}/NotistackAdapter/index.d.ts +0 -0
- /package/dist/es/{src/components → components}/Pagination/index.d.ts +0 -0
- /package/dist/es/{src/components → components}/Pagination/pagination.helper.d.ts +0 -0
- /package/dist/es/{src/components → components}/Snackbar/index.d.ts +0 -0
- /package/dist/es/{src/components → components}/Text/index.d.ts +0 -0
- /package/dist/es/{src/components → components}/Tooltip/index.d.ts +0 -0
- /package/dist/es/{src/components → components}/Tooltip/tooltip.interface.d.ts +0 -0
- /package/dist/es/{src/helpers → helpers}/GooglePickerWrapper.d.ts +0 -0
- /package/dist/es/{src/hooks → hooks}/useGooleDrivePicker.d.ts +0 -0
- /package/dist/es/{src/types → types}/googleDrive.d.ts +0 -0
- /package/src/components/{UploadDocument → FileUploader}/fileuploader.interface.ts +0 -0
- /package/src/components/{UploadDocument → FileUploader}/index.ts +0 -0
|
@@ -1,14 +1,7 @@
|
|
|
1
|
-
import React, { ChangeEvent, useEffect,
|
|
1
|
+
import React, { ChangeEvent, useEffect, useState } from 'react';
|
|
2
2
|
|
|
3
3
|
import { faCaretDown } from '@fortawesome/pro-solid-svg-icons';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
Box,
|
|
7
|
-
Divider,
|
|
8
|
-
Pagination as MUIPagination,
|
|
9
|
-
styled,
|
|
10
|
-
useTheme,
|
|
11
|
-
} from '@mui/material';
|
|
4
|
+
import { Box, Divider, Pagination as MUIPagination } from '@mui/material';
|
|
12
5
|
|
|
13
6
|
import Select from '@/components/Form/Select';
|
|
14
7
|
import Text from '@/components/Text';
|
|
@@ -23,126 +16,146 @@ interface Props {
|
|
|
23
16
|
limitsPerPage?: number[];
|
|
24
17
|
page?: number;
|
|
25
18
|
limit?: number;
|
|
19
|
+
disabled?: boolean;
|
|
26
20
|
setPage?: (_page: number) => void;
|
|
27
21
|
setLimit?: (_limit: number) => void;
|
|
28
22
|
}
|
|
29
23
|
|
|
30
|
-
const Pagination = (
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
)
|
|
24
|
+
const Pagination = React.forwardRef<HTMLDivElement, Props>(
|
|
25
|
+
(
|
|
26
|
+
{
|
|
27
|
+
totalString,
|
|
28
|
+
totalPerPageString,
|
|
29
|
+
hideTotal = false,
|
|
30
|
+
limitsPerPage = [5, 10, 20],
|
|
31
|
+
page = 1,
|
|
32
|
+
totalRows,
|
|
33
|
+
limit,
|
|
34
|
+
disabled,
|
|
35
|
+
setLimit,
|
|
36
|
+
setPage,
|
|
37
|
+
},
|
|
38
|
+
ref,
|
|
39
|
+
) => {
|
|
40
|
+
const [internalPage, setInternalPage] = useState<number>(page);
|
|
41
|
+
const [internalLimit, setInternalLimit] = useState<number>(
|
|
42
|
+
limit ?? limitsPerPage[0],
|
|
43
|
+
);
|
|
46
44
|
|
|
47
|
-
|
|
48
|
-
const [internalLimit, setInternalLimit] = useState<number>(
|
|
49
|
-
limit ?? limitsPerPage[0],
|
|
50
|
-
);
|
|
45
|
+
const displayablePages = getTotalPages(totalRows, internalLimit);
|
|
51
46
|
|
|
52
|
-
|
|
47
|
+
const changePage = (newPage: number) => {
|
|
48
|
+
setInternalPage(newPage);
|
|
49
|
+
setPage?.(newPage);
|
|
50
|
+
};
|
|
53
51
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
52
|
+
const changeLimit = (newLimit: number) => {
|
|
53
|
+
setInternalLimit(newLimit);
|
|
54
|
+
setLimit?.(newLimit);
|
|
55
|
+
};
|
|
58
56
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
57
|
+
const handleChangeLimit = (newLimit: number) => {
|
|
58
|
+
changePage(1);
|
|
59
|
+
changeLimit(newLimit);
|
|
60
|
+
};
|
|
63
61
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
62
|
+
useEffect(() => {
|
|
63
|
+
if (page !== internalPage) {
|
|
64
|
+
setInternalPage(page);
|
|
65
|
+
}
|
|
66
|
+
}, [page]);
|
|
68
67
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
68
|
+
useEffect(() => {
|
|
69
|
+
if (limit && limit !== internalLimit) {
|
|
70
|
+
setInternalLimit(limit);
|
|
71
|
+
}
|
|
72
|
+
}, [limit]);
|
|
74
73
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
74
|
+
return (
|
|
75
|
+
<Box
|
|
76
|
+
ref={ref}
|
|
77
|
+
display="flex"
|
|
78
|
+
flexDirection="row"
|
|
79
|
+
justifyContent="flex-end"
|
|
80
|
+
alignItems="center"
|
|
81
|
+
sx={{
|
|
82
|
+
paddingTop: '16px',
|
|
83
|
+
paddingBottom: '24px',
|
|
84
|
+
}}
|
|
85
|
+
data-testid="ds-pagination-container"
|
|
86
|
+
>
|
|
87
|
+
<Box
|
|
88
|
+
display="flex"
|
|
89
|
+
alignItems="center"
|
|
90
|
+
data-testid="ds-pagination-info"
|
|
91
|
+
>
|
|
92
|
+
{!hideTotal && (
|
|
93
|
+
<>
|
|
94
|
+
<Text variant="body1Medium" data-testid="ds-pagination-total">
|
|
95
|
+
{totalRows} {totalString}
|
|
96
|
+
</Text>
|
|
97
|
+
<Divider
|
|
98
|
+
orientation="vertical"
|
|
99
|
+
sx={{
|
|
100
|
+
color: 'greyXLight',
|
|
101
|
+
width: '1px',
|
|
102
|
+
height: '33px',
|
|
103
|
+
marginX: '16px',
|
|
104
|
+
}}
|
|
105
|
+
data-testid="ds-pagination-divider"
|
|
106
|
+
/>
|
|
107
|
+
</>
|
|
108
|
+
)}
|
|
109
|
+
<Select
|
|
110
|
+
className="PaginationSelect"
|
|
111
|
+
labelId="select-label"
|
|
112
|
+
value={internalLimit}
|
|
113
|
+
disabled={disabled}
|
|
114
|
+
inputProps={{ MenuProps: { disableScrollLock: true } }}
|
|
115
|
+
onChange={handleChangeLimit}
|
|
116
|
+
options={limitsPerPage}
|
|
117
|
+
getRenderValue={(value) => value.toString()}
|
|
118
|
+
popupIcon={faCaretDown}
|
|
119
|
+
width={73}
|
|
120
|
+
data-testid="ds-pagination-select"
|
|
121
|
+
sx={{
|
|
122
|
+
'.MuiSelect-select': {
|
|
123
|
+
paddingRight: '24px !important',
|
|
124
|
+
},
|
|
125
|
+
}}
|
|
126
|
+
/>
|
|
127
|
+
<Text variant="body1" pl={2} data-testid="ds-pagination-per-page">
|
|
128
|
+
{totalPerPageString}
|
|
129
|
+
</Text>
|
|
130
|
+
<Divider
|
|
131
|
+
orientation="vertical"
|
|
132
|
+
sx={{
|
|
133
|
+
color: 'greyXLight',
|
|
134
|
+
width: '1px',
|
|
135
|
+
height: '33px',
|
|
136
|
+
marginX: 4,
|
|
137
|
+
}}
|
|
138
|
+
data-testid="ds-pagination-divider"
|
|
139
|
+
/>
|
|
140
|
+
</Box>
|
|
141
|
+
<Box display="flex" pr={1} data-testid="ds-pagination-controls">
|
|
142
|
+
<MUIPagination
|
|
143
|
+
variant="outlined"
|
|
144
|
+
shape="rounded"
|
|
145
|
+
disabled={disabled}
|
|
146
|
+
count={displayablePages}
|
|
147
|
+
page={internalPage}
|
|
148
|
+
onChange={(_: ChangeEvent<unknown>, value: number) =>
|
|
149
|
+
changePage(value)
|
|
150
|
+
}
|
|
151
|
+
data-testid="ds-pagination"
|
|
152
|
+
/>
|
|
153
|
+
</Box>
|
|
143
154
|
</Box>
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
155
|
+
);
|
|
156
|
+
},
|
|
157
|
+
);
|
|
158
|
+
|
|
159
|
+
Pagination.displayName = 'Pagination';
|
|
147
160
|
|
|
148
161
|
export default Pagination;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from 'react';
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
4
|
IconDefinition,
|
|
@@ -6,8 +6,7 @@ import {
|
|
|
6
6
|
faExclamationCircle,
|
|
7
7
|
faTimesCircle,
|
|
8
8
|
} from '@fortawesome/pro-solid-svg-icons';
|
|
9
|
-
import {
|
|
10
|
-
import { Alert, AlertProps, styled, useTheme } from '@mui/material';
|
|
9
|
+
import { Alert, AlertProps } from '@mui/material';
|
|
11
10
|
|
|
12
11
|
import IconProvider from '@/components/IconProvider';
|
|
13
12
|
|
|
@@ -16,33 +15,34 @@ interface Props extends Omit<AlertProps, 'severity' | 'text'> {
|
|
|
16
15
|
severity: 'success' | 'warning' | 'error' | 'info';
|
|
17
16
|
}
|
|
18
17
|
|
|
19
|
-
const Snackbar =
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
()
|
|
23
|
-
|
|
24
|
-
|
|
18
|
+
const Snackbar = React.forwardRef<HTMLDivElement, Props>(
|
|
19
|
+
({ text, severity }, ref) => {
|
|
20
|
+
let alertIcon: IconDefinition;
|
|
21
|
+
switch (severity) {
|
|
22
|
+
case 'error':
|
|
23
|
+
alertIcon = faTimesCircle;
|
|
24
|
+
break;
|
|
25
|
+
case 'warning':
|
|
26
|
+
alertIcon = faExclamationCircle;
|
|
27
|
+
break;
|
|
28
|
+
default:
|
|
29
|
+
alertIcon = faCheckCircle;
|
|
30
|
+
}
|
|
25
31
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
32
|
+
return (
|
|
33
|
+
<Alert
|
|
34
|
+
ref={ref}
|
|
35
|
+
className="MuiAlertSnackbar"
|
|
36
|
+
data-testid="ds-snackbar"
|
|
37
|
+
icon={<IconProvider icon={alertIcon} />}
|
|
38
|
+
severity={severity}
|
|
39
|
+
>
|
|
40
|
+
{text}
|
|
41
|
+
</Alert>
|
|
42
|
+
);
|
|
43
|
+
},
|
|
44
|
+
);
|
|
37
45
|
|
|
38
|
-
|
|
39
|
-
<StyledSnackbar
|
|
40
|
-
icon={<IconProvider icon={alertIcon} />}
|
|
41
|
-
severity={severity}
|
|
42
|
-
>
|
|
43
|
-
{text}
|
|
44
|
-
</StyledSnackbar>
|
|
45
|
-
);
|
|
46
|
-
};
|
|
46
|
+
Snackbar.displayName = 'Snackbar';
|
|
47
47
|
|
|
48
48
|
export default Snackbar;
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
|
|
3
|
+
import { Box, FormControlLabel, Radio, Tab, Tabs } from '@mui/material';
|
|
4
|
+
|
|
5
|
+
import Text from '@/components/Text';
|
|
6
|
+
|
|
7
|
+
import { TabPanelProps, TabsPanelProps } from './tab.interface';
|
|
8
|
+
|
|
9
|
+
const TabPanel = ({ children, value, index }: TabPanelProps) => {
|
|
10
|
+
return (
|
|
11
|
+
<Box
|
|
12
|
+
role="tabpanel"
|
|
13
|
+
hidden={value !== index}
|
|
14
|
+
id={`tabpanel-${index}`}
|
|
15
|
+
aria-labelledby={`tab-${index}`}
|
|
16
|
+
sx={{
|
|
17
|
+
borderLeft: '1px solid',
|
|
18
|
+
borderLeftColor: 'primary.main',
|
|
19
|
+
borderRight: '1px solid',
|
|
20
|
+
borderRightColor: 'primary.main',
|
|
21
|
+
borderBottom: '1px solid',
|
|
22
|
+
borderBottomColor: 'primary.main',
|
|
23
|
+
borderBottomLeftRadius: '4px',
|
|
24
|
+
borderBottomRightRadius: '4px',
|
|
25
|
+
}}
|
|
26
|
+
>
|
|
27
|
+
{value === index && <Box sx={{ p: 2 }}>{children}</Box>}
|
|
28
|
+
</Box>
|
|
29
|
+
);
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const TabsPanel = React.forwardRef<HTMLDivElement, TabsPanelProps>(
|
|
33
|
+
({ tabs, value, width, disabled, onChange }, ref) => {
|
|
34
|
+
const [localValue, setValue] = useState<number>(value || 0);
|
|
35
|
+
|
|
36
|
+
const handleChange = (_event: React.SyntheticEvent, newValue: number) => {
|
|
37
|
+
setValue(newValue);
|
|
38
|
+
|
|
39
|
+
if (onChange) {
|
|
40
|
+
onChange(_event, newValue);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
return (
|
|
45
|
+
<Box sx={{ width: width || 'fit-content' }} data-testid="ds-tabs-panel">
|
|
46
|
+
<Box
|
|
47
|
+
sx={{
|
|
48
|
+
display: 'flex',
|
|
49
|
+
flexGrow: 1,
|
|
50
|
+
}}
|
|
51
|
+
>
|
|
52
|
+
<Tabs
|
|
53
|
+
ref={ref}
|
|
54
|
+
value={value || localValue}
|
|
55
|
+
onChange={disabled ? undefined : handleChange}
|
|
56
|
+
sx={{
|
|
57
|
+
flexGrow: 1,
|
|
58
|
+
flexShrink: 1,
|
|
59
|
+
'& .MuiTabs-indicator': {
|
|
60
|
+
display: 'none',
|
|
61
|
+
},
|
|
62
|
+
}}
|
|
63
|
+
data-testid="ds-tabs"
|
|
64
|
+
>
|
|
65
|
+
{tabs.map((tab, index) => (
|
|
66
|
+
<Tab
|
|
67
|
+
key={index}
|
|
68
|
+
sx={{
|
|
69
|
+
alignItems: 'flex-start',
|
|
70
|
+
flexGrow: 1,
|
|
71
|
+
borderTop: '1px solid',
|
|
72
|
+
borderLeft: '1px solid',
|
|
73
|
+
borderRight: '1px solid',
|
|
74
|
+
borderTopRightRadius: '4px',
|
|
75
|
+
borderTopLeftRadius: '4px',
|
|
76
|
+
borderColor:
|
|
77
|
+
index === localValue
|
|
78
|
+
? 'primary.main'
|
|
79
|
+
: 'greyLightDefaultBorder',
|
|
80
|
+
borderBottom: index === localValue ? '' : '1px solid',
|
|
81
|
+
borderBottomColor: 'primary.main',
|
|
82
|
+
borderBottomLeftRadius: 'unset !important',
|
|
83
|
+
borderBottomRightRadius: 'unset !important',
|
|
84
|
+
mr: '8px',
|
|
85
|
+
position: 'relative',
|
|
86
|
+
overflow: 'visible',
|
|
87
|
+
textTransform: 'none',
|
|
88
|
+
maxHeight: '54px',
|
|
89
|
+
'&:hover': {
|
|
90
|
+
pointer: disabled ? 'not-allowed' : 'pointer',
|
|
91
|
+
},
|
|
92
|
+
'&::after': {
|
|
93
|
+
content: '""',
|
|
94
|
+
position: 'absolute',
|
|
95
|
+
bottom: index === localValue ? '0' : '-1px',
|
|
96
|
+
right: `-9px`,
|
|
97
|
+
width: '8px',
|
|
98
|
+
height: '1px',
|
|
99
|
+
backgroundColor: 'primary.main',
|
|
100
|
+
},
|
|
101
|
+
}}
|
|
102
|
+
label={
|
|
103
|
+
<Box>
|
|
104
|
+
<FormControlLabel
|
|
105
|
+
key={index}
|
|
106
|
+
control={
|
|
107
|
+
<Radio
|
|
108
|
+
size="small"
|
|
109
|
+
disabled={disabled}
|
|
110
|
+
checked={value === index}
|
|
111
|
+
data-testid={`ds-radio-${index}`}
|
|
112
|
+
/>
|
|
113
|
+
}
|
|
114
|
+
value={value}
|
|
115
|
+
label={
|
|
116
|
+
<Box
|
|
117
|
+
display="flex"
|
|
118
|
+
alignItems="center"
|
|
119
|
+
data-testid={`ds-radio-label-${index}`}
|
|
120
|
+
>
|
|
121
|
+
<Text component="span" variant="body1">
|
|
122
|
+
{tab.label}
|
|
123
|
+
</Text>
|
|
124
|
+
</Box>
|
|
125
|
+
}
|
|
126
|
+
/>
|
|
127
|
+
</Box>
|
|
128
|
+
}
|
|
129
|
+
data-testid={`tab-${index}`}
|
|
130
|
+
/>
|
|
131
|
+
))}
|
|
132
|
+
</Tabs>
|
|
133
|
+
</Box>
|
|
134
|
+
{tabs.map((tab, index) => (
|
|
135
|
+
<TabPanel
|
|
136
|
+
key={index}
|
|
137
|
+
value={localValue}
|
|
138
|
+
index={index}
|
|
139
|
+
data-testid={`ds-tabpanel-${index}`}
|
|
140
|
+
>
|
|
141
|
+
{tab.content}
|
|
142
|
+
</TabPanel>
|
|
143
|
+
))}
|
|
144
|
+
</Box>
|
|
145
|
+
);
|
|
146
|
+
},
|
|
147
|
+
);
|
|
148
|
+
|
|
149
|
+
TabsPanel.displayName = 'TabsPanel';
|
|
150
|
+
|
|
151
|
+
export default TabsPanel;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './TabsPanel';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ReactNode, SyntheticEvent } from 'react';
|
|
2
|
+
|
|
3
|
+
export interface TabPanelProps {
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
value: number;
|
|
6
|
+
index: number;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface TabData {
|
|
10
|
+
label: string;
|
|
11
|
+
content: ReactNode;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface TabsPanelProps {
|
|
15
|
+
tabs: TabData[];
|
|
16
|
+
value?: number;
|
|
17
|
+
width?: string | number;
|
|
18
|
+
disabled?: boolean;
|
|
19
|
+
onChange?: (_event: SyntheticEvent, _newValue: number) => void;
|
|
20
|
+
}
|
|
@@ -1,36 +1,49 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
|
|
3
|
-
import { Typography, TypographyProps } from '@mui/material';
|
|
3
|
+
import { Typography, TypographyProps, useTheme } from '@mui/material';
|
|
4
4
|
|
|
5
5
|
interface Props extends Omit<TypographyProps, 'variant'> {
|
|
6
6
|
variant?:
|
|
7
7
|
| 'bigNumber'
|
|
8
8
|
| 'body1'
|
|
9
|
-
| 'body1Regular'
|
|
10
9
|
| 'body1Medium'
|
|
11
10
|
| 'body1Bold'
|
|
12
11
|
| 'body2'
|
|
13
|
-
| 'body2Regular'
|
|
14
12
|
| 'body2Medium'
|
|
15
13
|
| 'body2Bold'
|
|
16
|
-
| 'caption'
|
|
17
|
-
| 'buttonNotif'
|
|
18
|
-
| 'header1'
|
|
19
|
-
| 'header2'
|
|
20
|
-
| 'header3'
|
|
21
|
-
| 'header4'
|
|
22
14
|
| 'h1'
|
|
23
15
|
| 'h2'
|
|
24
16
|
| 'h3'
|
|
25
17
|
| 'h4'
|
|
18
|
+
| 'caption'
|
|
19
|
+
| 'buttonNotif'
|
|
26
20
|
| 'link1'
|
|
27
21
|
| 'link2';
|
|
28
22
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
29
23
|
component?: any;
|
|
30
24
|
}
|
|
31
25
|
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
26
|
+
const getColor = (color: Props['color']): string | undefined => {
|
|
27
|
+
const { palette } = useTheme();
|
|
28
|
+
|
|
29
|
+
switch (color) {
|
|
30
|
+
case 'primary':
|
|
31
|
+
return palette.text.primary;
|
|
32
|
+
case 'secondary':
|
|
33
|
+
return palette.text.secondary;
|
|
34
|
+
default:
|
|
35
|
+
return color;
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const Text = React.forwardRef<HTMLDivElement, Props>((props, ref) => (
|
|
40
|
+
<Typography
|
|
41
|
+
{...(props as TypographyProps)}
|
|
42
|
+
color={getColor(props?.color) + ' !important'}
|
|
43
|
+
ref={ref}
|
|
44
|
+
/>
|
|
45
|
+
));
|
|
46
|
+
|
|
47
|
+
Text.displayName = 'Text';
|
|
35
48
|
|
|
36
49
|
export default Text;
|