@groupeactual/ui-kit 1.5.2 → 1.6.0-beta.4
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 +16 -16
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/DesignSystemProvider.d.ts +3 -3
- package/dist/cjs/types/components/Accordion/Accordion.d.ts +3 -1
- package/dist/cjs/types/components/Chip/Chip.d.ts +3 -3
- package/dist/cjs/types/components/Datatable/Datatable.d.ts +1 -1
- package/dist/cjs/types/components/Datatable/DatatableCellRender.d.ts +0 -1
- package/dist/cjs/types/components/Datatable/datatable.interface.d.ts +1 -1
- package/dist/cjs/types/components/Datatable/use-pagination-props.hook.d.ts +1 -1
- package/dist/cjs/types/components/EmbbededNotification/EmbeddedNotification.d.ts +1 -1
- package/dist/cjs/types/components/Form/DatePicker/DatePicker.d.ts +5 -4
- package/dist/cjs/types/components/Form/MultiSelect/MultiSelect.d.ts +9 -4
- package/dist/cjs/types/components/Form/Select/Select.d.ts +8 -3
- package/dist/cjs/types/components/Form/TextField/TextField.d.ts +5 -4
- package/dist/cjs/types/components/IconButton/IconButton.d.ts +4 -1
- package/dist/cjs/types/components/IconProvider/IconProvider.d.ts +0 -1
- package/dist/cjs/types/components/Modal/Dialog/Dialog.d.ts +1 -1
- package/dist/cjs/types/components/Modal/Drawer/Drawer.d.ts +1 -1
- package/dist/cjs/types/components/Modal/modal.interface.d.ts +4 -4
- package/dist/cjs/types/components/NotistackAdapter/NotistackAdapter.d.ts +1 -2
- package/dist/cjs/types/components/UploadDocument/FileUploaderSingle.d.ts +0 -1
- package/dist/es/index.d.ts +44 -27
- package/dist/es/index.mjs +15 -15
- package/dist/es/index.mjs.map +1 -1
- package/dist/es/types/DesignSystemProvider.d.ts +3 -3
- package/dist/es/types/components/Accordion/Accordion.d.ts +3 -1
- package/dist/es/types/components/Chip/Chip.d.ts +3 -3
- package/dist/es/types/components/Datatable/Datatable.d.ts +1 -1
- package/dist/es/types/components/Datatable/DatatableCellRender.d.ts +0 -1
- package/dist/es/types/components/Datatable/datatable.interface.d.ts +1 -1
- package/dist/es/types/components/Datatable/use-pagination-props.hook.d.ts +1 -1
- package/dist/es/types/components/EmbbededNotification/EmbeddedNotification.d.ts +1 -1
- package/dist/es/types/components/Form/DatePicker/DatePicker.d.ts +5 -4
- package/dist/es/types/components/Form/MultiSelect/MultiSelect.d.ts +9 -4
- package/dist/es/types/components/Form/Select/Select.d.ts +8 -3
- package/dist/es/types/components/Form/TextField/TextField.d.ts +5 -4
- package/dist/es/types/components/IconButton/IconButton.d.ts +4 -1
- package/dist/es/types/components/IconProvider/IconProvider.d.ts +0 -1
- package/dist/es/types/components/Modal/Dialog/Dialog.d.ts +1 -1
- package/dist/es/types/components/Modal/Drawer/Drawer.d.ts +1 -1
- package/dist/es/types/components/Modal/modal.interface.d.ts +4 -4
- package/dist/es/types/components/NotistackAdapter/NotistackAdapter.d.ts +1 -2
- package/dist/es/types/components/UploadDocument/FileUploaderSingle.d.ts +0 -1
- package/package.json +31 -33
- package/src/DesignSystemProvider.tsx +3 -8
- package/src/components/Accordion/Accordion.tsx +5 -3
- package/src/components/BannerNotification/BannerNotification.tsx +2 -3
- package/src/components/Breadcrumbs/Breadcrumbs.tsx +3 -3
- package/src/components/Button/Button.tsx +6 -6
- package/src/components/Chip/Chip.tsx +32 -29
- package/src/components/Datatable/Datatable.tsx +4 -4
- package/src/components/Datatable/datatable.interface.ts +1 -1
- package/src/components/Datatable/use-pagination-props.hook.ts +3 -3
- package/src/components/EmbbededNotification/EmbeddedNotification.tsx +8 -7
- package/src/components/Form/AutoCompleteMulti/AutoCompleteMulti.tsx +11 -7
- package/src/components/Form/AutoCompleteSingle/AutoCompleteSingle.tsx +8 -3
- package/src/components/Form/Checkbox/Checkbox.tsx +5 -5
- package/src/components/Form/CheckboxGroup/CheckboxGroup.tsx +1 -1
- package/src/components/Form/DatePicker/DatePicker.tsx +7 -6
- package/src/components/Form/MultiSelect/MultiSelect.tsx +22 -17
- package/src/components/Form/RadioGroup/RadioGroup.tsx +6 -6
- package/src/components/Form/Select/Select.tsx +21 -18
- package/src/components/Form/Switch/Switch.tsx +1 -1
- package/src/components/Form/TextField/TextField.tsx +5 -3
- package/src/components/IconButton/IconButton.tsx +12 -3
- package/src/components/IconProvider/IconProvider.tsx +36 -24
- package/src/components/Link/Link.tsx +5 -8
- package/src/components/Modal/Drawer/Drawer.tsx +1 -2
- package/src/components/Modal/modal.interface.ts +4 -4
- package/src/components/NotistackAdapter/NotistackAdapter.tsx +4 -3
- package/src/components/Pagination/Pagination.tsx +2 -2
- package/src/components/Snackbar/Snackbar.tsx +4 -4
- package/src/components/Text/Text.tsx +1 -1
- package/src/components/Tooltip/Tooltip.tsx +10 -12
- package/src/components/UploadDocument/FileUploaderSingle.tsx +1 -2
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-empty-function */
|
|
2
2
|
import { PaginationProps, PaginationTrans, Props } from './datatable.interface';
|
|
3
3
|
|
|
4
|
-
const usePaginationProps = <T extends
|
|
5
|
-
props: Props<T> |
|
|
4
|
+
const usePaginationProps = <T extends object>(
|
|
5
|
+
props: Props<T> | object,
|
|
6
6
|
): Omit<PaginationProps, 'withPagination'> => {
|
|
7
7
|
let trans = {} as PaginationTrans;
|
|
8
8
|
let limits: number[] = [3, 5, 10, 20];
|
|
@@ -35,7 +35,7 @@ const usePaginationProps = <T extends {}>(
|
|
|
35
35
|
limits,
|
|
36
36
|
withTopPagination,
|
|
37
37
|
setPage,
|
|
38
|
-
setLimit
|
|
38
|
+
setLimit,
|
|
39
39
|
};
|
|
40
40
|
};
|
|
41
41
|
|
|
@@ -5,9 +5,10 @@ import {
|
|
|
5
5
|
faCircleCheck,
|
|
6
6
|
faCircleExclamation,
|
|
7
7
|
faCircleInfo,
|
|
8
|
-
faCircleXmark
|
|
8
|
+
faCircleXmark,
|
|
9
9
|
} from '@fortawesome/pro-solid-svg-icons';
|
|
10
|
-
import { Box
|
|
10
|
+
import { Box } from '@mui/material';
|
|
11
|
+
import { BoxProps } from '@mui/system';
|
|
11
12
|
|
|
12
13
|
import Icon from '../IconProvider/IconProvider';
|
|
13
14
|
import Text from '../Text';
|
|
@@ -34,20 +35,20 @@ const EmbeddedNotification = ({
|
|
|
34
35
|
const variantNotification: Record<string, EmbeddedNotifVariant> = {
|
|
35
36
|
warning: {
|
|
36
37
|
color: 'orangeWarning',
|
|
37
|
-
icon: faCircleExclamation
|
|
38
|
+
icon: faCircleExclamation,
|
|
38
39
|
},
|
|
39
40
|
error: {
|
|
40
41
|
color: 'redError',
|
|
41
|
-
icon: faCircleXmark
|
|
42
|
+
icon: faCircleXmark,
|
|
42
43
|
},
|
|
43
44
|
success: {
|
|
44
45
|
color: 'greenSuccess',
|
|
45
|
-
icon: faCircleCheck
|
|
46
|
+
icon: faCircleCheck,
|
|
46
47
|
},
|
|
47
48
|
infos: {
|
|
48
49
|
color: 'blueInfo',
|
|
49
|
-
icon: faCircleInfo
|
|
50
|
-
}
|
|
50
|
+
icon: faCircleInfo,
|
|
51
|
+
},
|
|
51
52
|
};
|
|
52
53
|
|
|
53
54
|
return (
|
|
@@ -8,16 +8,16 @@ import {
|
|
|
8
8
|
} from '@fortawesome/pro-solid-svg-icons';
|
|
9
9
|
import { AutoCompleteStyle } from '@groupeactual/design-tokens';
|
|
10
10
|
import {
|
|
11
|
-
Autocomplete,
|
|
12
11
|
type AutocompleteProps,
|
|
13
|
-
Box,
|
|
14
12
|
FormControl,
|
|
15
13
|
FormHelperText,
|
|
16
14
|
MenuItem,
|
|
17
|
-
TextField,
|
|
18
15
|
styled,
|
|
19
16
|
useTheme,
|
|
20
17
|
} from '@mui/material';
|
|
18
|
+
import Autocomplete from '@mui/material/Autocomplete';
|
|
19
|
+
import Box from '@mui/material/Box';
|
|
20
|
+
import TextField, { TextFieldProps } from '@mui/material/TextField';
|
|
21
21
|
|
|
22
22
|
import Chip from '../../Chip/Chip';
|
|
23
23
|
import IconProvider from '../../IconProvider';
|
|
@@ -86,7 +86,8 @@ const AutocompleteMultipleSelect = <T,>({
|
|
|
86
86
|
const addFormControlClassName = useMemo(() => {
|
|
87
87
|
const classNames = [
|
|
88
88
|
'DsAutoComplete',
|
|
89
|
-
value &&
|
|
89
|
+
value && 'Mui-filled',
|
|
90
|
+
color === 'success' && 'Mui-success',
|
|
90
91
|
disabled && 'Mui-disabled',
|
|
91
92
|
];
|
|
92
93
|
|
|
@@ -95,7 +96,7 @@ const AutocompleteMultipleSelect = <T,>({
|
|
|
95
96
|
|
|
96
97
|
const addInputLabelClassName = useMemo(() => {
|
|
97
98
|
const classNames = [
|
|
98
|
-
(!placeholder && 'labelCustom') || 'labelClassic',
|
|
99
|
+
(!placeholder && 'labelCustom') || 'labelClassic Mui-Input-filled',
|
|
99
100
|
error && 'Mui-error',
|
|
100
101
|
color === 'success' && 'Mui-success',
|
|
101
102
|
value && value.length > 0 && 'Mui-Input-filled',
|
|
@@ -165,6 +166,7 @@ const AutocompleteMultipleSelect = <T,>({
|
|
|
165
166
|
suffixAction={() =>
|
|
166
167
|
!disabled && handleDeleteChip(selectedOption)
|
|
167
168
|
}
|
|
169
|
+
data-testid="ChipOption"
|
|
168
170
|
sx={{
|
|
169
171
|
margin: '3px',
|
|
170
172
|
maxWidth: boxRef?.current
|
|
@@ -206,11 +208,13 @@ const AutocompleteMultipleSelect = <T,>({
|
|
|
206
208
|
)}
|
|
207
209
|
renderInput={(params) => (
|
|
208
210
|
<TextField
|
|
209
|
-
{...params}
|
|
211
|
+
{...(params as TextFieldProps)}
|
|
210
212
|
label={label}
|
|
211
213
|
error={!!error}
|
|
212
214
|
fullWidth
|
|
213
|
-
|
|
215
|
+
inputProps={{
|
|
216
|
+
...params.inputProps,
|
|
217
|
+
}}
|
|
214
218
|
InputLabelProps={{
|
|
215
219
|
shrink: (!!placeholder && true) || undefined,
|
|
216
220
|
className: addInputLabelClassName,
|
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
FormHelperText,
|
|
15
15
|
MenuItem,
|
|
16
16
|
TextField,
|
|
17
|
+
TextFieldProps,
|
|
17
18
|
styled,
|
|
18
19
|
useTheme,
|
|
19
20
|
} from '@mui/material';
|
|
@@ -73,6 +74,7 @@ const AutoCompleteSingle = <T,>({
|
|
|
73
74
|
const classNames = [
|
|
74
75
|
'DsAutoComplete',
|
|
75
76
|
value && 'Mui-filled',
|
|
77
|
+
color === 'success' && 'Mui-success',
|
|
76
78
|
disabled && 'Mui-disabled',
|
|
77
79
|
];
|
|
78
80
|
|
|
@@ -81,8 +83,9 @@ const AutoCompleteSingle = <T,>({
|
|
|
81
83
|
|
|
82
84
|
const getInputLabelClassName = useMemo(() => {
|
|
83
85
|
const classNames = [
|
|
84
|
-
(!placeholder && 'labelCustom') || 'labelClassic',
|
|
86
|
+
(!placeholder && 'labelCustom') || 'labelClassic Mui-Input-filled',
|
|
85
87
|
color === 'success' && 'Mui-success',
|
|
88
|
+
value && 'Mui-Input-filled',
|
|
86
89
|
];
|
|
87
90
|
|
|
88
91
|
return classNames.filter(Boolean).join(' ');
|
|
@@ -158,12 +161,14 @@ const AutoCompleteSingle = <T,>({
|
|
|
158
161
|
}
|
|
159
162
|
renderInput={(params) => (
|
|
160
163
|
<TextField
|
|
161
|
-
{...params}
|
|
164
|
+
{...(params as TextFieldProps)}
|
|
162
165
|
label={label}
|
|
163
166
|
error={!!error}
|
|
164
167
|
fullWidth
|
|
165
|
-
className={getInputLabelClassName}
|
|
166
168
|
variant="outlined"
|
|
169
|
+
inputProps={{
|
|
170
|
+
...params.inputProps,
|
|
171
|
+
}}
|
|
167
172
|
InputLabelProps={{
|
|
168
173
|
shrink: (placeholder && true) || undefined,
|
|
169
174
|
className: getInputLabelClassName,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
2
|
|
|
3
3
|
import { faInfoCircle } from '@fortawesome/pro-solid-svg-icons';
|
|
4
4
|
import { CheckboxStyle } from '@groupeactual/design-tokens';
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
FormHelperText,
|
|
12
12
|
Typography,
|
|
13
13
|
styled,
|
|
14
|
-
useTheme
|
|
14
|
+
useTheme,
|
|
15
15
|
} from '@mui/material';
|
|
16
16
|
|
|
17
17
|
import IconProvider from '../../IconProvider';
|
|
@@ -24,7 +24,7 @@ interface Props {
|
|
|
24
24
|
onChange?: (
|
|
25
25
|
field: string,
|
|
26
26
|
value: boolean,
|
|
27
|
-
shouldValidate?: boolean | undefined
|
|
27
|
+
shouldValidate?: boolean | undefined,
|
|
28
28
|
) => void;
|
|
29
29
|
helperText?: string;
|
|
30
30
|
error?: string;
|
|
@@ -60,7 +60,7 @@ const Checkbox = ({
|
|
|
60
60
|
const theme = useTheme();
|
|
61
61
|
const StyledCheckboxForm = useMemo(
|
|
62
62
|
() => styled(FormControl)(CheckboxStyle(theme)),
|
|
63
|
-
[theme]
|
|
63
|
+
[theme],
|
|
64
64
|
);
|
|
65
65
|
|
|
66
66
|
const getComponentClassName = useMemo(() => {
|
|
@@ -84,7 +84,7 @@ const Checkbox = ({
|
|
|
84
84
|
control={
|
|
85
85
|
<Box>
|
|
86
86
|
<CheckboxMUI
|
|
87
|
-
|
|
87
|
+
inputProps={{ name }}
|
|
88
88
|
disabled={disabled}
|
|
89
89
|
sx={{ marginTop: '-2px' }}
|
|
90
90
|
checked={value}
|
|
@@ -18,17 +18,18 @@ import {
|
|
|
18
18
|
DatePicker as DatePickerMUI,
|
|
19
19
|
DatePickerProps,
|
|
20
20
|
LocalizationProvider,
|
|
21
|
-
enUS,
|
|
22
|
-
frFR,
|
|
23
21
|
} from '@mui/x-date-pickers-pro';
|
|
24
22
|
import { AdapterDayjs } from '@mui/x-date-pickers-pro/AdapterDayjs';
|
|
23
|
+
import { enUS, frFR } from '@mui/x-date-pickers/locales';
|
|
24
|
+
import { Dayjs } from 'dayjs';
|
|
25
25
|
import 'dayjs/locale/fr';
|
|
26
26
|
|
|
27
27
|
import IconProvider from '../../IconProvider/IconProvider';
|
|
28
28
|
|
|
29
|
-
interface Props<T
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
interface Props<T extends Dayjs>
|
|
30
|
+
extends Omit<DatePickerProps<Dayjs>, 'onChange' | 'width'> {
|
|
31
|
+
value: T | null;
|
|
32
|
+
onChange: (value: Dayjs | null) => void;
|
|
32
33
|
error?: string;
|
|
33
34
|
success?: boolean;
|
|
34
35
|
helperText?: string;
|
|
@@ -36,7 +37,7 @@ interface Props<T> extends Omit<DatePickerProps<T>, 'onChange' | 'width'> {
|
|
|
36
37
|
locale?: 'fr' | 'en';
|
|
37
38
|
}
|
|
38
39
|
|
|
39
|
-
const DatePicker = <T extends
|
|
40
|
+
const DatePicker = <T extends Dayjs>({
|
|
40
41
|
value,
|
|
41
42
|
onChange,
|
|
42
43
|
error,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useMemo, useRef } from 'react';
|
|
1
|
+
import React, { FocusEventHandler, useMemo, useRef } from 'react';
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
4
|
faCheck,
|
|
@@ -32,14 +32,30 @@ interface Props<T>
|
|
|
32
32
|
options: T[] | [];
|
|
33
33
|
helperText?: string;
|
|
34
34
|
color?: 'success';
|
|
35
|
-
onChange: (value: T[]) => void;
|
|
36
|
-
getRenderValue: (option: T) => string;
|
|
37
|
-
getKeyValue: (option: T) => string;
|
|
38
35
|
value: T[];
|
|
39
36
|
width?: number | string;
|
|
40
37
|
error?: string;
|
|
38
|
+
placeholder?: string;
|
|
39
|
+
disabled?: boolean;
|
|
40
|
+
className?: string;
|
|
41
|
+
onBlur?:
|
|
42
|
+
| FocusEventHandler<HTMLInputElement | HTMLTextAreaElement>
|
|
43
|
+
| undefined;
|
|
44
|
+
onChange: (value: T[]) => void;
|
|
45
|
+
getRenderValue: (option: T) => string;
|
|
46
|
+
getKeyValue: (option: T) => string;
|
|
41
47
|
}
|
|
42
48
|
|
|
49
|
+
const MenuProps = {
|
|
50
|
+
disableAutoFocusItem: true,
|
|
51
|
+
PaperProps: {
|
|
52
|
+
sx: {
|
|
53
|
+
boxShadow: '0px 2px 10px 0px',
|
|
54
|
+
width: 0,
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
|
|
43
59
|
const MultiSelect = <T,>({
|
|
44
60
|
value,
|
|
45
61
|
label,
|
|
@@ -52,7 +68,6 @@ const MultiSelect = <T,>({
|
|
|
52
68
|
getRenderValue,
|
|
53
69
|
getKeyValue,
|
|
54
70
|
onChange,
|
|
55
|
-
onBlur,
|
|
56
71
|
disabled,
|
|
57
72
|
...props
|
|
58
73
|
}: Props<T>) => {
|
|
@@ -79,6 +94,7 @@ const MultiSelect = <T,>({
|
|
|
79
94
|
'DsMultiSelect',
|
|
80
95
|
(!placeholder && 'Select-mui') || 'Select-ds',
|
|
81
96
|
value.length > 0 && 'Mui-filled',
|
|
97
|
+
error && 'Mui-error',
|
|
82
98
|
];
|
|
83
99
|
|
|
84
100
|
return classNames.filter(Boolean).join(' ');
|
|
@@ -115,12 +131,9 @@ const MultiSelect = <T,>({
|
|
|
115
131
|
}}
|
|
116
132
|
multiple
|
|
117
133
|
label={label}
|
|
118
|
-
placeholder={placeholder}
|
|
119
134
|
notched={(placeholder && true) || undefined}
|
|
120
135
|
value={value}
|
|
121
|
-
error={!!error}
|
|
122
136
|
onChange={handleChange}
|
|
123
|
-
onBlur={onBlur}
|
|
124
137
|
renderValue={(selected) => (
|
|
125
138
|
<Box sx={{ display: 'flex' }}>
|
|
126
139
|
<Box sx={{ display: 'flex', flexWrap: 'wrap', gap: 0.5 }}>
|
|
@@ -176,15 +189,7 @@ const MultiSelect = <T,>({
|
|
|
176
189
|
}}
|
|
177
190
|
/>
|
|
178
191
|
)}
|
|
179
|
-
MenuProps={
|
|
180
|
-
disableAutoFocusItem: true,
|
|
181
|
-
PaperProps: {
|
|
182
|
-
sx: {
|
|
183
|
-
boxShadow: '0px 2px 10px 0px',
|
|
184
|
-
width: 0,
|
|
185
|
-
},
|
|
186
|
-
},
|
|
187
|
-
}}
|
|
192
|
+
MenuProps={MenuProps}
|
|
188
193
|
{...props}
|
|
189
194
|
>
|
|
190
195
|
{options?.map((option) => (
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ChangeEvent, useMemo } from 'react';
|
|
2
2
|
|
|
3
3
|
import { faInfoCircle } from '@fortawesome/pro-solid-svg-icons';
|
|
4
4
|
import { RadioStyle } from '@groupeactual/design-tokens';
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
RadioGroup as RadioGroupMUI,
|
|
13
13
|
RadioGroupProps,
|
|
14
14
|
styled,
|
|
15
|
-
useTheme
|
|
15
|
+
useTheme,
|
|
16
16
|
} from '@mui/material';
|
|
17
17
|
|
|
18
18
|
import IconProvider from '../../IconProvider';
|
|
@@ -60,10 +60,10 @@ const RadioGroup = <T,>({
|
|
|
60
60
|
const theme = useTheme();
|
|
61
61
|
const StyledRadioForm = useMemo(
|
|
62
62
|
() => styled(FormControl)(RadioStyle(theme)),
|
|
63
|
-
[theme]
|
|
63
|
+
[theme],
|
|
64
64
|
);
|
|
65
65
|
|
|
66
|
-
const handleChange = (event:
|
|
66
|
+
const handleChange = (event: ChangeEvent<HTMLInputElement>) => {
|
|
67
67
|
onChange((event.target as HTMLInputElement).value as T);
|
|
68
68
|
};
|
|
69
69
|
|
|
@@ -86,7 +86,7 @@ const RadioGroup = <T,>({
|
|
|
86
86
|
.map(
|
|
87
87
|
(
|
|
88
88
|
{ value, label, infoBubbleContent, infoBubblePosition },
|
|
89
|
-
index
|
|
89
|
+
index,
|
|
90
90
|
) => (
|
|
91
91
|
<FormControlLabel
|
|
92
92
|
key={index}
|
|
@@ -119,7 +119,7 @@ const RadioGroup = <T,>({
|
|
|
119
119
|
</Box>
|
|
120
120
|
}
|
|
121
121
|
/>
|
|
122
|
-
)
|
|
122
|
+
),
|
|
123
123
|
)}
|
|
124
124
|
</RadioGroupMUI>
|
|
125
125
|
{((error || helperText) && (
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { BaseSyntheticEvent, useMemo } from 'react';
|
|
2
2
|
|
|
3
3
|
import { faCheck, faChevronDown } from '@fortawesome/pro-solid-svg-icons';
|
|
4
4
|
import { SelectStyle } from '@groupeactual/design-tokens';
|
|
@@ -20,16 +20,30 @@ import Icon from '../../IconProvider';
|
|
|
20
20
|
interface Props<T>
|
|
21
21
|
extends Omit<SelectProps<T>, 'value' | 'onChange' | 'color' | 'error'> {
|
|
22
22
|
options: T[];
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
placeholder?: string;
|
|
24
|
+
disabled?: boolean;
|
|
25
25
|
label: string;
|
|
26
26
|
helperText?: string;
|
|
27
27
|
color?: 'success';
|
|
28
28
|
value: T | undefined;
|
|
29
29
|
width?: number | string;
|
|
30
30
|
error?: string;
|
|
31
|
+
className?: string;
|
|
32
|
+
getRenderValue: (option: T) => string;
|
|
33
|
+
onChange: (value: T) => void;
|
|
34
|
+
onBlur?: (event: BaseSyntheticEvent) => void;
|
|
31
35
|
}
|
|
32
36
|
|
|
37
|
+
const MenuProps = {
|
|
38
|
+
disableAutoFocusItem: true,
|
|
39
|
+
PaperProps: {
|
|
40
|
+
sx: {
|
|
41
|
+
boxShadow: '0px 2px 10px 0px',
|
|
42
|
+
width: 0,
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
|
|
33
47
|
const Select = <T,>({
|
|
34
48
|
value,
|
|
35
49
|
label = '',
|
|
@@ -37,12 +51,11 @@ const Select = <T,>({
|
|
|
37
51
|
color,
|
|
38
52
|
error,
|
|
39
53
|
placeholder = '',
|
|
40
|
-
onChange,
|
|
41
|
-
getRenderValue,
|
|
42
54
|
helperText,
|
|
43
|
-
onBlur,
|
|
44
55
|
width = '100%',
|
|
45
56
|
disabled,
|
|
57
|
+
onChange,
|
|
58
|
+
getRenderValue,
|
|
46
59
|
...props
|
|
47
60
|
}: Props<T>) => {
|
|
48
61
|
const theme = useTheme();
|
|
@@ -59,6 +72,7 @@ const Select = <T,>({
|
|
|
59
72
|
'DSSingleSelect',
|
|
60
73
|
(!placeholder && 'Select-mui') || 'Select-ds',
|
|
61
74
|
value && 'Mui-filled',
|
|
75
|
+
error && 'Mui-error',
|
|
62
76
|
];
|
|
63
77
|
|
|
64
78
|
return classNames.filter(Boolean).join(' ');
|
|
@@ -91,12 +105,9 @@ const Select = <T,>({
|
|
|
91
105
|
: {},
|
|
92
106
|
}}
|
|
93
107
|
label={label}
|
|
94
|
-
placeholder={placeholder}
|
|
95
108
|
value={value}
|
|
96
|
-
error={!!error}
|
|
97
109
|
notched={(placeholder && true) || undefined}
|
|
98
110
|
onChange={handleChange}
|
|
99
|
-
onBlur={onBlur}
|
|
100
111
|
IconComponent={({ className }) => (
|
|
101
112
|
<Icon
|
|
102
113
|
className={disabled ? 'Mui-disabled SelectIcon' : 'SelectIcon'}
|
|
@@ -112,15 +123,7 @@ const Select = <T,>({
|
|
|
112
123
|
}}
|
|
113
124
|
/>
|
|
114
125
|
)}
|
|
115
|
-
MenuProps={
|
|
116
|
-
disableAutoFocusItem: true,
|
|
117
|
-
PaperProps: {
|
|
118
|
-
sx: {
|
|
119
|
-
boxShadow: '0px 2px 10px 0px',
|
|
120
|
-
width: 0,
|
|
121
|
-
},
|
|
122
|
-
},
|
|
123
|
-
}}
|
|
126
|
+
MenuProps={MenuProps}
|
|
124
127
|
renderValue={(value) => getRenderValue(value)}
|
|
125
128
|
{...props}
|
|
126
129
|
>
|
|
@@ -10,7 +10,6 @@ import { faEye, faEyeSlash } from '@fortawesome/pro-solid-svg-icons';
|
|
|
10
10
|
import { TextFieldStyle } from '@groupeactual/design-tokens';
|
|
11
11
|
import {
|
|
12
12
|
TextField as MuiTextField,
|
|
13
|
-
InputProps as StandardInputProps,
|
|
14
13
|
TextFieldProps,
|
|
15
14
|
styled,
|
|
16
15
|
useTheme,
|
|
@@ -20,8 +19,6 @@ import Icon from '../../IconProvider';
|
|
|
20
19
|
|
|
21
20
|
interface Props extends Omit<TextFieldProps, 'error'> {
|
|
22
21
|
error?: string;
|
|
23
|
-
onBlur?: FocusEventHandler<unknown>;
|
|
24
|
-
onChange?: StandardInputProps['onChange'];
|
|
25
22
|
label: string;
|
|
26
23
|
value?: string | unknown;
|
|
27
24
|
name?: string;
|
|
@@ -30,6 +27,11 @@ interface Props extends Omit<TextFieldProps, 'error'> {
|
|
|
30
27
|
endAdornment?: ReactNode;
|
|
31
28
|
maxLength?: number;
|
|
32
29
|
width?: number | string;
|
|
30
|
+
className?: string;
|
|
31
|
+
onBlur?: FocusEventHandler<unknown>;
|
|
32
|
+
onChange?: (
|
|
33
|
+
e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>,
|
|
34
|
+
) => void;
|
|
33
35
|
}
|
|
34
36
|
const TextField = ({
|
|
35
37
|
name,
|
|
@@ -2,8 +2,14 @@ import { useMemo } from 'react';
|
|
|
2
2
|
|
|
3
3
|
import { IconDefinition } from '@fortawesome/fontawesome-svg-core';
|
|
4
4
|
import { IconButtonStyle } from '@groupeactual/design-tokens';
|
|
5
|
-
import {
|
|
6
|
-
|
|
5
|
+
import {
|
|
6
|
+
IconButton as IconButtonMUI,
|
|
7
|
+
IconButtonProps,
|
|
8
|
+
SxProps,
|
|
9
|
+
Theme,
|
|
10
|
+
styled,
|
|
11
|
+
useTheme,
|
|
12
|
+
} from '@mui/material';
|
|
7
13
|
|
|
8
14
|
import IconProvider from '../IconProvider';
|
|
9
15
|
import Tooltip from '../Tooltip';
|
|
@@ -15,6 +21,9 @@ interface Props extends IconButtonProps {
|
|
|
15
21
|
positionGroup?: 'left' | 'middle' | 'right';
|
|
16
22
|
tooltipText?: string;
|
|
17
23
|
tooltipPosition?: Placement;
|
|
24
|
+
size?: 'small' | 'medium';
|
|
25
|
+
sx?: SxProps<Theme>;
|
|
26
|
+
onClick?: () => void;
|
|
18
27
|
}
|
|
19
28
|
|
|
20
29
|
const IconButton = ({
|
|
@@ -29,7 +38,7 @@ const IconButton = ({
|
|
|
29
38
|
const theme = useTheme();
|
|
30
39
|
const StyledIconButton = useMemo(
|
|
31
40
|
() => styled(IconButtonMUI)(IconButtonStyle(theme)),
|
|
32
|
-
[theme]
|
|
41
|
+
[theme],
|
|
33
42
|
);
|
|
34
43
|
return (
|
|
35
44
|
<Tooltip title={tooltipText} placement={tooltipPosition}>
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { forwardRef, useMemo } from 'react';
|
|
2
|
+
|
|
2
3
|
import { IconDefinition } from '@fortawesome/fontawesome-svg-core';
|
|
3
4
|
import {
|
|
4
5
|
Box,
|
|
5
6
|
BoxProps,
|
|
7
|
+
SvgIcon,
|
|
6
8
|
SxProps,
|
|
7
9
|
Theme,
|
|
8
|
-
|
|
9
|
-
useTheme
|
|
10
|
+
useTheme,
|
|
10
11
|
} from '@mui/material';
|
|
11
12
|
|
|
12
13
|
const FontSizes = {
|
|
@@ -16,7 +17,7 @@ const FontSizes = {
|
|
|
16
17
|
lg: 24,
|
|
17
18
|
xl: 32,
|
|
18
19
|
xxl: 40,
|
|
19
|
-
xxxl: 72
|
|
20
|
+
xxxl: 72,
|
|
20
21
|
};
|
|
21
22
|
|
|
22
23
|
interface Props {
|
|
@@ -27,6 +28,7 @@ interface Props {
|
|
|
27
28
|
}
|
|
28
29
|
|
|
29
30
|
interface FontAwesomeSvgIconProps {
|
|
31
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
30
32
|
icon: any;
|
|
31
33
|
fontSize: number | undefined;
|
|
32
34
|
}
|
|
@@ -35,7 +37,7 @@ interface FontAwesomeSvgIconProps {
|
|
|
35
37
|
const FontAwesomeSvgIcon = forwardRef<SVGSVGElement, FontAwesomeSvgIconProps>(
|
|
36
38
|
({ icon, fontSize }, ref) => {
|
|
37
39
|
const {
|
|
38
|
-
icon: [width, height, , , svgPathData]
|
|
40
|
+
icon: [width, height, , , svgPathData],
|
|
39
41
|
} = icon;
|
|
40
42
|
|
|
41
43
|
return (
|
|
@@ -43,7 +45,7 @@ const FontAwesomeSvgIcon = forwardRef<SVGSVGElement, FontAwesomeSvgIconProps>(
|
|
|
43
45
|
ref={ref}
|
|
44
46
|
viewBox={`0 0 ${width as string} ${height as string}`}
|
|
45
47
|
sx={{
|
|
46
|
-
fontSize: fontSize ?? '14px'
|
|
48
|
+
fontSize: fontSize ?? '14px',
|
|
47
49
|
}}
|
|
48
50
|
>
|
|
49
51
|
{typeof svgPathData === 'string' ? (
|
|
@@ -62,7 +64,7 @@ const FontAwesomeSvgIcon = forwardRef<SVGSVGElement, FontAwesomeSvgIconProps>(
|
|
|
62
64
|
)}
|
|
63
65
|
</SvgIcon>
|
|
64
66
|
);
|
|
65
|
-
}
|
|
67
|
+
},
|
|
66
68
|
);
|
|
67
69
|
|
|
68
70
|
const IconProvider = ({
|
|
@@ -73,14 +75,21 @@ const IconProvider = ({
|
|
|
73
75
|
sx,
|
|
74
76
|
...props
|
|
75
77
|
}: Props & BoxProps): JSX.Element => {
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
78
|
+
const theme = useTheme();
|
|
79
|
+
|
|
80
|
+
const usedColor = useMemo(() => {
|
|
81
|
+
if (theme.palette[color]) {
|
|
82
|
+
return theme.palette[color];
|
|
83
|
+
} else {
|
|
84
|
+
if (!color || color.length === 0) {
|
|
85
|
+
return '#136cac';
|
|
86
|
+
} else {
|
|
87
|
+
return color;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}, [theme.palette, color]);
|
|
83
91
|
|
|
92
|
+
const getStyles = (): SxProps<Theme> => {
|
|
84
93
|
switch (variant) {
|
|
85
94
|
case 'square':
|
|
86
95
|
return {
|
|
@@ -95,7 +104,7 @@ const IconProvider = ({
|
|
|
95
104
|
height: '36px',
|
|
96
105
|
display: 'flex',
|
|
97
106
|
justifyContent: 'center',
|
|
98
|
-
alignItems: 'center'
|
|
107
|
+
alignItems: 'center',
|
|
99
108
|
};
|
|
100
109
|
default:
|
|
101
110
|
return {
|
|
@@ -105,7 +114,7 @@ const IconProvider = ({
|
|
|
105
114
|
height: size,
|
|
106
115
|
display: 'inline-flex',
|
|
107
116
|
alignItems: 'center',
|
|
108
|
-
justifyContent: 'center'
|
|
117
|
+
justifyContent: 'center',
|
|
109
118
|
};
|
|
110
119
|
}
|
|
111
120
|
};
|
|
@@ -114,14 +123,17 @@ const IconProvider = ({
|
|
|
114
123
|
return key in FontSizes;
|
|
115
124
|
};
|
|
116
125
|
|
|
117
|
-
const usedFontSize
|
|
118
|
-
variant === 'square'
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
126
|
+
const usedFontSize = useMemo(() => {
|
|
127
|
+
if (variant === 'square') {
|
|
128
|
+
return 16;
|
|
129
|
+
} else if (isKey(size)) {
|
|
130
|
+
return FontSizes[size];
|
|
131
|
+
} else if (size >= 0) {
|
|
132
|
+
return size;
|
|
133
|
+
} else {
|
|
134
|
+
return 16;
|
|
135
|
+
}
|
|
136
|
+
}, [variant, size]);
|
|
125
137
|
|
|
126
138
|
return (
|
|
127
139
|
<Box component="span" sx={getStyles()} {...props}>
|