@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,17 +1,10 @@
|
|
|
1
|
-
import React, { MouseEvent,
|
|
1
|
+
import React, { MouseEvent, useState } from 'react';
|
|
2
2
|
|
|
3
3
|
import { IconDefinition } from '@fortawesome/fontawesome-svg-core';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
Box,
|
|
7
|
-
Chip as ChipMUI,
|
|
8
|
-
ChipProps as ChipPropsMUI,
|
|
9
|
-
Tooltip,
|
|
10
|
-
styled,
|
|
11
|
-
useTheme,
|
|
12
|
-
} from '@mui/material';
|
|
4
|
+
import { Box, Chip as ChipMUI, ChipProps as ChipPropsMUI } from '@mui/material';
|
|
13
5
|
|
|
14
6
|
import IconProvider from '@/components/IconProvider';
|
|
7
|
+
import Tooltip from '@/components/Tooltip';
|
|
15
8
|
|
|
16
9
|
interface Props
|
|
17
10
|
extends Omit<
|
|
@@ -29,120 +22,98 @@ interface Props
|
|
|
29
22
|
maxLength?: number;
|
|
30
23
|
}
|
|
31
24
|
|
|
32
|
-
const Chip = (
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
25
|
+
const Chip = React.forwardRef<HTMLDivElement, Props>(
|
|
26
|
+
(
|
|
27
|
+
{
|
|
28
|
+
variant,
|
|
29
|
+
label,
|
|
30
|
+
prefixIcon,
|
|
31
|
+
suffixIcon,
|
|
32
|
+
suffixTooltip,
|
|
33
|
+
suffixAction,
|
|
34
|
+
tooltip,
|
|
35
|
+
maxWidth = '100%',
|
|
36
|
+
...props
|
|
37
|
+
},
|
|
38
|
+
ref,
|
|
39
|
+
) => {
|
|
40
|
+
const [isTooltipOpen, setIsTooltipOpen] = useState(false);
|
|
41
|
+
const [isSuffixTooltipOpen, setIsSuffixTooltipOpen] = useState(false);
|
|
45
42
|
|
|
46
|
-
|
|
47
|
-
const [isSuffixTooltipOpen, setIsSuffixTooltipOpen] = useState(false);
|
|
48
|
-
|
|
49
|
-
const ref = useRef<HTMLDivElement>(null);
|
|
50
|
-
|
|
51
|
-
let backgroundColor: string =
|
|
52
|
-
// eslint-disable-next-line no-nested-ternary
|
|
53
|
-
props.color && theme.palette[props.color]
|
|
54
|
-
? typeof theme.palette[props.color] === 'object'
|
|
55
|
-
? theme.palette[props.color]['main']
|
|
56
|
-
: theme.palette[props.color]
|
|
57
|
-
: (props.color ?? 'white');
|
|
58
|
-
|
|
59
|
-
if (variant === 'filled' || variant === 'statusFilled') {
|
|
60
|
-
// opacity 0.08
|
|
61
|
-
backgroundColor = `${backgroundColor}14`;
|
|
62
|
-
} else if (variant === 'status') {
|
|
63
|
-
backgroundColor = 'white';
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
return (
|
|
67
|
-
<Tooltip title={tooltip} placement="right-start" open={isTooltipOpen}>
|
|
43
|
+
return (
|
|
68
44
|
<Box
|
|
69
|
-
maxWidth="fit-content"
|
|
70
45
|
onMouseEnter={() => setIsTooltipOpen(true)}
|
|
71
46
|
onMouseLeave={() => setIsTooltipOpen(false)}
|
|
47
|
+
sx={{ width: 'fit-content' }}
|
|
48
|
+
data-testid="ds-chip-container"
|
|
72
49
|
>
|
|
73
|
-
<Tooltip
|
|
74
|
-
|
|
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
|
-
color: '#004f88 !important',
|
|
107
|
-
},
|
|
108
|
-
},
|
|
109
|
-
},
|
|
110
|
-
}}
|
|
111
|
-
avatar={
|
|
112
|
-
prefixIcon ? <IconProvider icon={prefixIcon} size="sm" /> : <></>
|
|
113
|
-
}
|
|
114
|
-
deleteIcon={
|
|
115
|
-
suffixIcon ? (
|
|
116
|
-
<IconProvider
|
|
117
|
-
icon={suffixIcon}
|
|
118
|
-
onMouseEnter={() => {
|
|
119
|
-
if (suffixTooltip) {
|
|
120
|
-
setIsSuffixTooltipOpen(true);
|
|
121
|
-
setIsTooltipOpen(false);
|
|
122
|
-
}
|
|
123
|
-
}}
|
|
124
|
-
onMouseLeave={() => {
|
|
125
|
-
if (suffixTooltip) {
|
|
126
|
-
setIsSuffixTooltipOpen(false);
|
|
127
|
-
setIsTooltipOpen(true);
|
|
50
|
+
<Tooltip title={tooltip} placement="right-start" open={isTooltipOpen}>
|
|
51
|
+
<Tooltip
|
|
52
|
+
title={suffixTooltip}
|
|
53
|
+
open={isSuffixTooltipOpen}
|
|
54
|
+
placement="bottom-end"
|
|
55
|
+
sx={{ cursor: suffixAction ? 'pointer !important' : 'default' }}
|
|
56
|
+
>
|
|
57
|
+
<ChipMUI
|
|
58
|
+
label={label}
|
|
59
|
+
ref={ref}
|
|
60
|
+
size="small"
|
|
61
|
+
variant={variant}
|
|
62
|
+
sx={{
|
|
63
|
+
maxWidth,
|
|
64
|
+
}}
|
|
65
|
+
avatar={
|
|
66
|
+
prefixIcon ? (
|
|
67
|
+
<IconProvider
|
|
68
|
+
color=""
|
|
69
|
+
icon={prefixIcon}
|
|
70
|
+
size="sm"
|
|
71
|
+
data-testid="ds-prefix-icon"
|
|
72
|
+
/>
|
|
73
|
+
) : (
|
|
74
|
+
<></>
|
|
75
|
+
)
|
|
76
|
+
}
|
|
77
|
+
deleteIcon={
|
|
78
|
+
suffixIcon ? (
|
|
79
|
+
<IconProvider
|
|
80
|
+
icon={suffixIcon}
|
|
81
|
+
className={
|
|
82
|
+
suffixAction ? 'MuiChip-iconAction' : 'MuiChip-icon'
|
|
128
83
|
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
84
|
+
onMouseEnter={() => {
|
|
85
|
+
if (suffixTooltip) {
|
|
86
|
+
setIsSuffixTooltipOpen(true);
|
|
87
|
+
setIsTooltipOpen(false);
|
|
88
|
+
}
|
|
89
|
+
}}
|
|
90
|
+
onMouseLeave={() => {
|
|
91
|
+
if (suffixTooltip) {
|
|
92
|
+
setIsSuffixTooltipOpen(false);
|
|
93
|
+
setIsTooltipOpen(true);
|
|
94
|
+
}
|
|
95
|
+
}}
|
|
96
|
+
sx={{
|
|
97
|
+
cursor: suffixAction ? 'pointer !important' : 'default',
|
|
98
|
+
}}
|
|
99
|
+
size="sm"
|
|
100
|
+
data-testid="ds-suffix-icon"
|
|
101
|
+
/>
|
|
102
|
+
) : (
|
|
103
|
+
<></>
|
|
104
|
+
)
|
|
105
|
+
}
|
|
106
|
+
onDelete={suffixAction ?? (() => null)}
|
|
107
|
+
{...props}
|
|
108
|
+
data-testid="ds-chip"
|
|
109
|
+
/>
|
|
110
|
+
</Tooltip>
|
|
142
111
|
</Tooltip>
|
|
143
112
|
</Box>
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
113
|
+
);
|
|
114
|
+
},
|
|
115
|
+
);
|
|
116
|
+
|
|
117
|
+
Chip.displayName = 'Chip';
|
|
147
118
|
|
|
148
119
|
export default Chip;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import React, { Fragment, useEffect,
|
|
1
|
+
import React, { Fragment, useEffect, useState } from 'react';
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
4
|
faArrowDownLong,
|
|
5
5
|
faArrowUpLong,
|
|
6
6
|
} from '@fortawesome/pro-regular-svg-icons';
|
|
7
|
-
import { DatatableStyle } from '@groupeactual/design-tokens';
|
|
8
7
|
import {
|
|
9
8
|
Box,
|
|
10
9
|
Table,
|
|
@@ -14,8 +13,6 @@ import {
|
|
|
14
13
|
TableHead,
|
|
15
14
|
TableRow,
|
|
16
15
|
TableSortLabel,
|
|
17
|
-
styled,
|
|
18
|
-
useTheme,
|
|
19
16
|
} from '@mui/material';
|
|
20
17
|
|
|
21
18
|
import IconButton from '@/components/IconButton';
|
|
@@ -25,19 +22,28 @@ import Text from '@/components/Text';
|
|
|
25
22
|
import { RowDetail as D, Props } from './datatable.interface';
|
|
26
23
|
import usePaginationProps from './use-pagination-props.hook';
|
|
27
24
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
25
|
+
function fixedForwardRef<T, P = {}>(
|
|
26
|
+
render: (_props: P, _ref: React.Ref<T>) => React.ReactNode,
|
|
27
|
+
): (_props: P & React.RefAttributes<T>) => React.ReactNode {
|
|
28
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
29
|
+
return React.forwardRef(render as any) as any;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const DatatableComponent = <T extends object>(
|
|
33
|
+
{
|
|
34
|
+
onLoad,
|
|
35
|
+
onSort = () => undefined,
|
|
36
|
+
sortInfo = null,
|
|
37
|
+
withHeader = false,
|
|
38
|
+
withPagination,
|
|
39
|
+
columns,
|
|
40
|
+
isTableLayoutFixed = false,
|
|
41
|
+
...props
|
|
42
|
+
}: Props<T>,
|
|
43
|
+
ref: React.ForwardedRef<HTMLTableElement>,
|
|
44
|
+
) => {
|
|
38
45
|
const { trans, limits, withTopPagination, hideTotal, setPage, setLimit } =
|
|
39
46
|
usePaginationProps<T>(props);
|
|
40
|
-
const theme = useTheme();
|
|
41
47
|
|
|
42
48
|
const [currentRows, setCurrentRows] = useState<T[] | (T & D)[]>();
|
|
43
49
|
const [currentPage, setCurrentPage] = useState<number>();
|
|
@@ -48,11 +54,6 @@ const Datatable = <T extends object>({
|
|
|
48
54
|
const isAsc = sortInfo?.direction === 'asc';
|
|
49
55
|
const hasTopTitle = columns.some(({ topTitle }) => topTitle);
|
|
50
56
|
|
|
51
|
-
const StyledDatatable = useMemo(
|
|
52
|
-
() => styled(Box)(DatatableStyle(theme)),
|
|
53
|
-
[theme],
|
|
54
|
-
);
|
|
55
|
-
|
|
56
57
|
useEffect(() => {
|
|
57
58
|
onLoad()
|
|
58
59
|
.then((data) => {
|
|
@@ -84,19 +85,21 @@ const Datatable = <T extends object>({
|
|
|
84
85
|
);
|
|
85
86
|
|
|
86
87
|
return (
|
|
87
|
-
<
|
|
88
|
+
<Box ref={ref} data-testid="ds-datatable">
|
|
88
89
|
{withTopPagination && <SyncedPagination />}
|
|
89
90
|
<TableContainer
|
|
90
91
|
sx={{ display: 'flex', maxWidth: '100%', overflow: 'auto' }}
|
|
92
|
+
data-testid="ds-table-container"
|
|
91
93
|
>
|
|
92
94
|
<Table
|
|
93
95
|
sx={{
|
|
94
96
|
tableLayout: isTableLayoutFixed ? 'fixed' : 'auto',
|
|
95
97
|
}}
|
|
98
|
+
data-testid="ds-table"
|
|
96
99
|
>
|
|
97
100
|
{withHeader && (
|
|
98
|
-
<TableHead>
|
|
99
|
-
<TableRow data-testid="datatable-head-row">
|
|
101
|
+
<TableHead data-testid="ds-table-head">
|
|
102
|
+
<TableRow data-testid="ds-datatable-head-row">
|
|
100
103
|
{columns.map(
|
|
101
104
|
({
|
|
102
105
|
name,
|
|
@@ -117,10 +120,14 @@ const Datatable = <T extends object>({
|
|
|
117
120
|
width: width,
|
|
118
121
|
height: hasTopTitle ? '55px' : 'inherit',
|
|
119
122
|
}}
|
|
123
|
+
data-testid={`ds-table-cell-head-${name}`}
|
|
120
124
|
>
|
|
121
125
|
{hasTopTitle && (
|
|
122
|
-
<Box
|
|
123
|
-
|
|
126
|
+
<Box
|
|
127
|
+
sx={{ mb: 1, height: '16px' }}
|
|
128
|
+
data-testid={`ds-top-title-${name}`}
|
|
129
|
+
>
|
|
130
|
+
<Text variant="body1Medium">{topTitle}</Text>
|
|
124
131
|
</Box>
|
|
125
132
|
)}
|
|
126
133
|
{(sortable && (
|
|
@@ -148,7 +155,7 @@ const Datatable = <T extends object>({
|
|
|
148
155
|
IconComponent={() => (
|
|
149
156
|
<IconButton
|
|
150
157
|
icon={isAsc ? faArrowUpLong : faArrowDownLong}
|
|
151
|
-
variant="
|
|
158
|
+
variant="plain"
|
|
152
159
|
size="small"
|
|
153
160
|
sx={{
|
|
154
161
|
visibility:
|
|
@@ -156,30 +163,28 @@ const Datatable = <T extends object>({
|
|
|
156
163
|
? 'visible'
|
|
157
164
|
: 'hidden',
|
|
158
165
|
}}
|
|
166
|
+
data-testid={`ds-sort-icon-${name}`}
|
|
159
167
|
/>
|
|
160
168
|
)}
|
|
169
|
+
data-testid={`ds-sort-label-${name}`}
|
|
161
170
|
>
|
|
162
171
|
<Box
|
|
163
172
|
sx={{
|
|
164
173
|
pr: 1,
|
|
165
|
-
fontWeight: 500,
|
|
166
|
-
lineHeight: '16px',
|
|
167
|
-
fontSize: '13px',
|
|
168
174
|
}}
|
|
175
|
+
data-testid={`ds-title-${name}`}
|
|
169
176
|
>
|
|
170
|
-
{title}
|
|
177
|
+
<Text variant="body1">{title}</Text>
|
|
171
178
|
</Box>
|
|
172
179
|
</TableSortLabel>
|
|
173
180
|
)) || (
|
|
174
181
|
<Box
|
|
175
182
|
sx={{
|
|
176
183
|
pr: 1,
|
|
177
|
-
fontWeight: 500,
|
|
178
|
-
lineHeight: '16px',
|
|
179
|
-
fontSize: '13px',
|
|
180
184
|
}}
|
|
185
|
+
data-testid={`ds-title-${name}`}
|
|
181
186
|
>
|
|
182
|
-
{title}
|
|
187
|
+
<Text variant="body1">{title}</Text>
|
|
183
188
|
</Box>
|
|
184
189
|
)}
|
|
185
190
|
</TableCell>
|
|
@@ -189,10 +194,10 @@ const Datatable = <T extends object>({
|
|
|
189
194
|
</TableRow>
|
|
190
195
|
</TableHead>
|
|
191
196
|
)}
|
|
192
|
-
<TableBody>
|
|
197
|
+
<TableBody data-testid="ds-table-body">
|
|
193
198
|
{currentRows?.map((record, index) => (
|
|
194
199
|
<Fragment key={index}>
|
|
195
|
-
<TableRow data-testid="datatable-body-row">
|
|
200
|
+
<TableRow data-testid="ds-datatable-body-row">
|
|
196
201
|
{columns.map(({ name, width, render }) => (
|
|
197
202
|
<TableCell
|
|
198
203
|
key={name}
|
|
@@ -207,6 +212,7 @@ const Datatable = <T extends object>({
|
|
|
207
212
|
? '0px'
|
|
208
213
|
: 'default',
|
|
209
214
|
}}
|
|
215
|
+
data-testid={`ds-table-cell-body-${name}`}
|
|
210
216
|
>
|
|
211
217
|
{render(record)}
|
|
212
218
|
</TableCell>
|
|
@@ -219,12 +225,14 @@ const Datatable = <T extends object>({
|
|
|
219
225
|
width: record.width,
|
|
220
226
|
borderColor: 'greyLightDefaultBorder',
|
|
221
227
|
}}
|
|
228
|
+
data-testid={`ds-details-row-${index}`}
|
|
222
229
|
>
|
|
223
230
|
<TableCell
|
|
224
231
|
sx={{
|
|
225
232
|
columnSpan: columns.length,
|
|
226
233
|
borderBottom: 'none',
|
|
227
234
|
}}
|
|
235
|
+
data-testid={`ds-details-cell-${index}`}
|
|
228
236
|
>
|
|
229
237
|
{record.details}
|
|
230
238
|
</TableCell>
|
|
@@ -236,8 +244,12 @@ const Datatable = <T extends object>({
|
|
|
236
244
|
</Table>
|
|
237
245
|
</TableContainer>
|
|
238
246
|
{withPagination && <SyncedPagination />}
|
|
239
|
-
</
|
|
247
|
+
</Box>
|
|
240
248
|
);
|
|
241
249
|
};
|
|
242
250
|
|
|
251
|
+
DatatableComponent.displayName = 'Datatable';
|
|
252
|
+
|
|
253
|
+
const Datatable = fixedForwardRef(DatatableComponent);
|
|
254
|
+
|
|
243
255
|
export default Datatable;
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
faCircleInfo,
|
|
8
8
|
faCircleXmark,
|
|
9
9
|
} from '@fortawesome/pro-solid-svg-icons';
|
|
10
|
-
import { Box, BoxProps } from '@mui/material';
|
|
10
|
+
import { Box, BoxProps, useTheme } from '@mui/material';
|
|
11
11
|
|
|
12
12
|
import Text from '@/components//Text';
|
|
13
13
|
import Icon from '@/components/IconProvider';
|
|
@@ -19,83 +19,92 @@ interface Props extends BoxProps {
|
|
|
19
19
|
actionButton?: ReactNode;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
color: string;
|
|
31
|
-
icon: IconDefinition;
|
|
32
|
-
}
|
|
22
|
+
interface EmbeddedNotifVariant {
|
|
23
|
+
color: string;
|
|
24
|
+
icon: IconDefinition;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const EmbeddedNotification = React.forwardRef<HTMLDivElement, Props>(
|
|
28
|
+
({ title, text, variant = 'infos', actionButton, ...props }, ref) => {
|
|
29
|
+
const { spacing } = useTheme();
|
|
33
30
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
31
|
+
const variantNotification: Record<string, EmbeddedNotifVariant> = {
|
|
32
|
+
warning: {
|
|
33
|
+
color: 'orangeWarning',
|
|
34
|
+
icon: faCircleExclamation,
|
|
35
|
+
},
|
|
36
|
+
error: {
|
|
37
|
+
color: 'redError',
|
|
38
|
+
icon: faCircleXmark,
|
|
39
|
+
},
|
|
40
|
+
success: {
|
|
41
|
+
color: 'greenSuccess',
|
|
42
|
+
icon: faCircleCheck,
|
|
43
|
+
},
|
|
44
|
+
infos: {
|
|
45
|
+
color: 'blueInfo',
|
|
46
|
+
icon: faCircleInfo,
|
|
47
|
+
},
|
|
48
|
+
};
|
|
52
49
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
mt={text ? '1px' : 0}
|
|
69
|
-
/>
|
|
70
|
-
<Box display="flex" flexDirection="column" paddingRight={4}>
|
|
71
|
-
<Text
|
|
72
|
-
align="left"
|
|
73
|
-
variant="body1Bold"
|
|
50
|
+
return (
|
|
51
|
+
<Box
|
|
52
|
+
ref={ref}
|
|
53
|
+
border="1px solid"
|
|
54
|
+
borderColor={variantNotification[variant].color}
|
|
55
|
+
p={spacing(2, 4)}
|
|
56
|
+
borderRadius="4px"
|
|
57
|
+
display="flex"
|
|
58
|
+
alignItems={text ? 'flex-start' : 'center'}
|
|
59
|
+
justifyContent={text ? 'flex-start' : 'center'}
|
|
60
|
+
{...props}
|
|
61
|
+
data-testid="ds-embedded-notification"
|
|
62
|
+
>
|
|
63
|
+
<Icon
|
|
64
|
+
icon={variantNotification[variant].icon}
|
|
74
65
|
color={variantNotification[variant].color}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
66
|
+
mr={4}
|
|
67
|
+
mt={text ? '1px' : 0}
|
|
68
|
+
data-testid="ds-icon"
|
|
69
|
+
/>
|
|
70
|
+
<Box display="flex" flexDirection="column" paddingRight={4}>
|
|
80
71
|
<Text
|
|
81
72
|
align="left"
|
|
82
|
-
variant="
|
|
83
|
-
color=
|
|
73
|
+
variant="body1Bold"
|
|
74
|
+
color={variantNotification[variant].color}
|
|
84
75
|
display="inline-block"
|
|
85
|
-
|
|
76
|
+
data-testid="ds-title"
|
|
86
77
|
>
|
|
87
|
-
{
|
|
78
|
+
{title}
|
|
88
79
|
</Text>
|
|
80
|
+
{text && (
|
|
81
|
+
<Text
|
|
82
|
+
align="left"
|
|
83
|
+
variant="body1"
|
|
84
|
+
color="greyDark"
|
|
85
|
+
display="inline-block"
|
|
86
|
+
pt={1}
|
|
87
|
+
data-testid="ds-text"
|
|
88
|
+
>
|
|
89
|
+
{text}
|
|
90
|
+
</Text>
|
|
91
|
+
)}
|
|
92
|
+
</Box>
|
|
93
|
+
<Box flexGrow={2} />
|
|
94
|
+
{actionButton && (
|
|
95
|
+
<Box
|
|
96
|
+
alignSelf="center"
|
|
97
|
+
whiteSpace="nowrap"
|
|
98
|
+
data-testid="ds-action-button"
|
|
99
|
+
>
|
|
100
|
+
{actionButton}
|
|
101
|
+
</Box>
|
|
89
102
|
)}
|
|
90
103
|
</Box>
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
)}
|
|
97
|
-
</Box>
|
|
98
|
-
);
|
|
99
|
-
};
|
|
104
|
+
);
|
|
105
|
+
},
|
|
106
|
+
);
|
|
107
|
+
|
|
108
|
+
EmbeddedNotification.displayName = 'EmbeddedNotification';
|
|
100
109
|
|
|
101
110
|
export default EmbeddedNotification;
|