@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,13 +1,11 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { ReactNode, useMemo } from 'react';
|
|
2
2
|
|
|
3
|
-
import { CheckboxGroupStyle } from '@groupeactual/design-tokens';
|
|
4
3
|
import {
|
|
4
|
+
Box,
|
|
5
5
|
FormControl,
|
|
6
6
|
FormGroup,
|
|
7
7
|
FormHelperText,
|
|
8
8
|
FormLabel,
|
|
9
|
-
styled,
|
|
10
|
-
useTheme,
|
|
11
9
|
} from '@mui/material';
|
|
12
10
|
|
|
13
11
|
import Checkbox from '@/components/Form/Checkbox';
|
|
@@ -15,71 +13,99 @@ import Checkbox from '@/components/Form/Checkbox';
|
|
|
15
13
|
import { CheckboxItemType } from './checkboxgroup.interface';
|
|
16
14
|
|
|
17
15
|
interface CheckboxGroupProps {
|
|
18
|
-
label
|
|
16
|
+
label?: ReactNode;
|
|
19
17
|
options: CheckboxItemType[];
|
|
20
18
|
disabled?: boolean;
|
|
21
19
|
error?: string;
|
|
22
20
|
helperText?: string;
|
|
23
|
-
onChange?: (
|
|
21
|
+
onChange?: (
|
|
22
|
+
_selectedOptionsNameValue: Record<string, boolean>,
|
|
23
|
+
_updatedOptions: CheckboxItemType[],
|
|
24
|
+
_updatedIndexOptions: number,
|
|
25
|
+
) => void;
|
|
24
26
|
}
|
|
25
27
|
|
|
26
|
-
const CheckboxGroup = (
|
|
27
|
-
options,
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
helperText,
|
|
32
|
-
onChange,
|
|
33
|
-
}: CheckboxGroupProps) => {
|
|
34
|
-
const theme = useTheme();
|
|
35
|
-
const StyledCheckboxGroupForm = useMemo(
|
|
36
|
-
() => styled(FormControl)(CheckboxGroupStyle(theme)),
|
|
37
|
-
[theme],
|
|
38
|
-
);
|
|
39
|
-
const [selectedOptions, setSelectedOptions] = useState({});
|
|
28
|
+
const CheckboxGroup = React.forwardRef<HTMLDivElement, CheckboxGroupProps>(
|
|
29
|
+
({ options, label, disabled, error, helperText, onChange }, ref) => {
|
|
30
|
+
const handleChange = (name: string, isChecked: boolean) => {
|
|
31
|
+
const index = options.findIndex((option) => option.name === name);
|
|
32
|
+
if (index === -1) return;
|
|
40
33
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
34
|
+
const optionsChanged = options.map((option, i) =>
|
|
35
|
+
i === index ? { ...option, value: isChecked } : option,
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
const selectedOptions: Record<string, boolean> = optionsChanged.reduce(
|
|
39
|
+
(acc, option) => ({
|
|
40
|
+
...acc,
|
|
41
|
+
[option.name]: option.value ?? false,
|
|
42
|
+
}),
|
|
43
|
+
{},
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
onChange?.(selectedOptions, optionsChanged, index);
|
|
45
47
|
};
|
|
46
|
-
setSelectedOptions(updatedOptions);
|
|
47
|
-
onChange?.(updatedOptions);
|
|
48
|
-
};
|
|
49
48
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
49
|
+
const getClassName = useMemo(() => {
|
|
50
|
+
const classNames = [disabled && 'Mui-disabled', error && 'Mui-error'];
|
|
51
|
+
|
|
52
|
+
return classNames.filter(Boolean).join(' ');
|
|
53
|
+
}, [disabled, error]);
|
|
54
|
+
|
|
55
|
+
return (
|
|
56
|
+
<Box data-testid="ds-checkbox-group-container">
|
|
57
|
+
<FormControl
|
|
58
|
+
disabled={disabled}
|
|
59
|
+
error={!!error}
|
|
60
|
+
ref={ref}
|
|
61
|
+
data-testid="ds-checkbox-group-form-control"
|
|
62
|
+
>
|
|
63
|
+
{label && label !== '' && (
|
|
64
|
+
<FormLabel
|
|
65
|
+
component="legend"
|
|
66
|
+
className={getClassName}
|
|
67
|
+
sx={{
|
|
68
|
+
marginLeft: '-6px',
|
|
69
|
+
marginBottom: '4px',
|
|
70
|
+
}}
|
|
71
|
+
data-testid="ds-checkbox-group-label"
|
|
72
|
+
>
|
|
73
|
+
{label}
|
|
74
|
+
</FormLabel>
|
|
75
|
+
)}
|
|
76
|
+
<FormGroup data-testid="ds-checkbox-group">
|
|
77
|
+
{options
|
|
78
|
+
?.slice(0, 7)
|
|
79
|
+
.map((option) => (
|
|
80
|
+
<Checkbox
|
|
81
|
+
key={option.name}
|
|
82
|
+
name={option.name}
|
|
83
|
+
value={option.value || false}
|
|
84
|
+
onChange={(name, isChecked: boolean) =>
|
|
85
|
+
handleChange(name, isChecked)
|
|
86
|
+
}
|
|
87
|
+
disabled={disabled}
|
|
88
|
+
label={option.label}
|
|
89
|
+
data-testid={`ds-checkbox-${option.name}`}
|
|
90
|
+
/>
|
|
91
|
+
))}
|
|
92
|
+
</FormGroup>
|
|
93
|
+
{(error || helperText) && (
|
|
94
|
+
<FormHelperText
|
|
95
|
+
component="span"
|
|
96
|
+
className={getClassName}
|
|
97
|
+
sx={{ marginTop: '3px', marginLeft: '-6px' }}
|
|
98
|
+
data-testid="ds-checkbox-group-helper-text"
|
|
99
|
+
>
|
|
100
|
+
{error || helperText}
|
|
101
|
+
</FormHelperText>
|
|
102
|
+
)}
|
|
103
|
+
</FormControl>
|
|
104
|
+
</Box>
|
|
105
|
+
);
|
|
106
|
+
},
|
|
107
|
+
);
|
|
56
108
|
|
|
57
|
-
|
|
58
|
-
<StyledCheckboxGroupForm error={!!error} className={getLegendClassName}>
|
|
59
|
-
<FormLabel component="legend">{label}</FormLabel>
|
|
60
|
-
<FormGroup>
|
|
61
|
-
{options
|
|
62
|
-
?.slice(0, 7)
|
|
63
|
-
.map((option) => (
|
|
64
|
-
<Checkbox
|
|
65
|
-
key={option.name}
|
|
66
|
-
name={option.name}
|
|
67
|
-
value={selectedOptions[option.name] || false}
|
|
68
|
-
onChange={(label, isChecked) => handleChange(label, isChecked)}
|
|
69
|
-
disabled={disabled}
|
|
70
|
-
label={option.label}
|
|
71
|
-
infoBubbleContent={option.infoBubbleContent}
|
|
72
|
-
infoBubblePosition={option.infoBubblePosition}
|
|
73
|
-
/>
|
|
74
|
-
))}
|
|
75
|
-
</FormGroup>
|
|
76
|
-
{(error || helperText) && (
|
|
77
|
-
<FormHelperText component="span" className={error ? 'Mui-error' : ''}>
|
|
78
|
-
{error || helperText}
|
|
79
|
-
</FormHelperText>
|
|
80
|
-
)}
|
|
81
|
-
</StyledCheckboxGroupForm>
|
|
82
|
-
);
|
|
83
|
-
};
|
|
109
|
+
CheckboxGroup.displayName = 'CheckboxGroup';
|
|
84
110
|
|
|
85
111
|
export default CheckboxGroup;
|
|
@@ -4,19 +4,4 @@ export interface CheckboxItemType {
|
|
|
4
4
|
label: ReactNode;
|
|
5
5
|
value: boolean;
|
|
6
6
|
name: string;
|
|
7
|
-
infoBubbleContent?: string;
|
|
8
|
-
infoBubblePosition?:
|
|
9
|
-
| 'right'
|
|
10
|
-
| 'bottom'
|
|
11
|
-
| 'left'
|
|
12
|
-
| 'top'
|
|
13
|
-
| 'bottom-end'
|
|
14
|
-
| 'bottom-start'
|
|
15
|
-
| 'left-end'
|
|
16
|
-
| 'left-start'
|
|
17
|
-
| 'right-end'
|
|
18
|
-
| 'right-start'
|
|
19
|
-
| 'top-end'
|
|
20
|
-
| 'top-start'
|
|
21
|
-
| undefined;
|
|
22
7
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useMemo } from 'react';
|
|
1
|
+
import React, { ReactNode, useId, useMemo } from 'react';
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
4
|
faAngleLeft,
|
|
@@ -7,14 +7,7 @@ import {
|
|
|
7
7
|
faCheck,
|
|
8
8
|
} from '@fortawesome/pro-regular-svg-icons';
|
|
9
9
|
import { faCaretDown } from '@fortawesome/pro-solid-svg-icons';
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
Box,
|
|
13
|
-
FormHelperText,
|
|
14
|
-
IconButton,
|
|
15
|
-
styled,
|
|
16
|
-
useTheme,
|
|
17
|
-
} from '@mui/material';
|
|
10
|
+
import { Box, FormHelperText, IconButton, InputLabel } from '@mui/material';
|
|
18
11
|
import {
|
|
19
12
|
DatePicker as DatePickerMUI,
|
|
20
13
|
DatePickerProps,
|
|
@@ -29,39 +22,53 @@ import IconProvider from '@/components/IconProvider';
|
|
|
29
22
|
|
|
30
23
|
interface Props<T extends Dayjs>
|
|
31
24
|
extends Omit<DatePickerProps<T>, 'onChange' | 'width'> {
|
|
25
|
+
label?: ReactNode;
|
|
32
26
|
value: T | null | undefined;
|
|
33
|
-
|
|
27
|
+
disabled?: boolean;
|
|
34
28
|
error?: string;
|
|
35
|
-
|
|
29
|
+
color?: 'primary' | 'secondary' | 'error' | 'info' | 'success' | 'warning';
|
|
36
30
|
helperText?: string;
|
|
37
31
|
width?: string;
|
|
38
32
|
locale?: 'fr' | 'en';
|
|
33
|
+
onChange: (_value: T | null | undefined) => void;
|
|
39
34
|
}
|
|
40
35
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
width,
|
|
48
|
-
locale = 'fr',
|
|
49
|
-
...props
|
|
50
|
-
}: Props<T>) => {
|
|
51
|
-
const theme = useTheme();
|
|
36
|
+
function fixedForwardRef<T, P = {}>(
|
|
37
|
+
render: (_props: P, _ref: React.Ref<T>) => React.ReactNode,
|
|
38
|
+
): (_props: P & React.RefAttributes<T>) => React.ReactNode {
|
|
39
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
40
|
+
return React.forwardRef(render as any) as any;
|
|
41
|
+
}
|
|
52
42
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
43
|
+
const DatePickerComponent = <T extends Dayjs>(
|
|
44
|
+
{
|
|
45
|
+
label,
|
|
46
|
+
value,
|
|
47
|
+
error,
|
|
48
|
+
color,
|
|
49
|
+
helperText,
|
|
50
|
+
width = '100%',
|
|
51
|
+
locale = 'fr',
|
|
52
|
+
disabled,
|
|
53
|
+
onChange,
|
|
54
|
+
...props
|
|
55
|
+
}: Props<T>,
|
|
56
|
+
ref: React.ForwardedRef<HTMLDivElement>,
|
|
57
|
+
) => {
|
|
58
|
+
const generatedId = useId();
|
|
59
|
+
|
|
60
|
+
const inputId = props.name || `datepicker-${generatedId}`;
|
|
57
61
|
|
|
58
|
-
const
|
|
59
|
-
const classNames
|
|
60
|
-
|
|
61
|
-
|
|
62
|
+
const getClassName = useMemo(() => {
|
|
63
|
+
const classNames = [
|
|
64
|
+
value && 'Mui-filled',
|
|
65
|
+
error && 'Mui-error',
|
|
66
|
+
disabled && 'Mui-disabled',
|
|
67
|
+
color === 'success' && 'Mui-success',
|
|
68
|
+
];
|
|
62
69
|
|
|
63
|
-
return classNames.join(' ');
|
|
64
|
-
}, [error,
|
|
70
|
+
return classNames.filter(Boolean).join(' ');
|
|
71
|
+
}, [value, error, color, disabled]);
|
|
65
72
|
|
|
66
73
|
const CustomIconButton = ({ icon, buttonProps }) => {
|
|
67
74
|
return (
|
|
@@ -82,7 +89,7 @@ const DatePicker = <T extends Dayjs>({
|
|
|
82
89
|
};
|
|
83
90
|
|
|
84
91
|
return (
|
|
85
|
-
<
|
|
92
|
+
<Box data-testid="ds-date-picker-container">
|
|
86
93
|
<LocalizationProvider
|
|
87
94
|
dateAdapter={AdapterDayjs}
|
|
88
95
|
adapterLocale={locale}
|
|
@@ -92,26 +99,58 @@ const DatePicker = <T extends Dayjs>({
|
|
|
92
99
|
: enUS.components.MuiLocalizationProvider.defaultProps.localeText
|
|
93
100
|
}
|
|
94
101
|
>
|
|
102
|
+
{label && (
|
|
103
|
+
<InputLabel
|
|
104
|
+
htmlFor={inputId}
|
|
105
|
+
disabled={disabled}
|
|
106
|
+
className={getClassName}
|
|
107
|
+
data-testid="ds-date-picker-label"
|
|
108
|
+
>
|
|
109
|
+
{label}
|
|
110
|
+
</InputLabel>
|
|
111
|
+
)}
|
|
95
112
|
<DatePickerMUI
|
|
96
|
-
|
|
113
|
+
ref={ref}
|
|
114
|
+
className={getClassName}
|
|
115
|
+
disabled={disabled}
|
|
97
116
|
value={value}
|
|
117
|
+
sx={{
|
|
118
|
+
width,
|
|
119
|
+
...props.sx,
|
|
120
|
+
}}
|
|
98
121
|
onChange={onChange}
|
|
99
122
|
slots={{
|
|
100
123
|
openPickerIcon: () => (
|
|
101
124
|
<IconProvider
|
|
102
125
|
sx={{ marginTop: '-2px' }}
|
|
103
|
-
|
|
126
|
+
className={
|
|
127
|
+
getClassName + (color === 'success' ? '' : ' SelectIcon')
|
|
128
|
+
}
|
|
129
|
+
icon={color === 'success' ? faCheck : faCalendarDay}
|
|
104
130
|
size="md"
|
|
131
|
+
data-testid="ds-open-picker-icon"
|
|
105
132
|
/>
|
|
106
133
|
),
|
|
107
134
|
previousIconButton: (props) => (
|
|
108
|
-
<CustomIconButton
|
|
135
|
+
<CustomIconButton
|
|
136
|
+
icon={faAngleLeft}
|
|
137
|
+
buttonProps={props}
|
|
138
|
+
data-testid="ds-previous-icon-button"
|
|
139
|
+
/>
|
|
109
140
|
),
|
|
110
141
|
nextIconButton: (props) => (
|
|
111
|
-
<CustomIconButton
|
|
142
|
+
<CustomIconButton
|
|
143
|
+
icon={faAngleRight}
|
|
144
|
+
buttonProps={props}
|
|
145
|
+
data-testid="ds-next-icon-button"
|
|
146
|
+
/>
|
|
112
147
|
),
|
|
113
148
|
switchViewButton: (props) => (
|
|
114
|
-
<CustomIconButton
|
|
149
|
+
<CustomIconButton
|
|
150
|
+
icon={faCaretDown}
|
|
151
|
+
buttonProps={props}
|
|
152
|
+
data-testid="ds-switch-view-button"
|
|
153
|
+
/>
|
|
115
154
|
),
|
|
116
155
|
}}
|
|
117
156
|
slotProps={{
|
|
@@ -123,6 +162,7 @@ const DatePicker = <T extends Dayjs>({
|
|
|
123
162
|
textField: {
|
|
124
163
|
variant: 'outlined',
|
|
125
164
|
error: !!error,
|
|
165
|
+
className: getClassName,
|
|
126
166
|
},
|
|
127
167
|
calendarHeader: {
|
|
128
168
|
sx: {
|
|
@@ -152,12 +192,20 @@ const DatePicker = <T extends Dayjs>({
|
|
|
152
192
|
/>
|
|
153
193
|
</LocalizationProvider>
|
|
154
194
|
{(error || helperText) && (
|
|
155
|
-
<FormHelperText
|
|
195
|
+
<FormHelperText
|
|
196
|
+
component="span"
|
|
197
|
+
className={getClassName}
|
|
198
|
+
data-testid="ds-form-helper-text"
|
|
199
|
+
>
|
|
156
200
|
{error || helperText}
|
|
157
201
|
</FormHelperText>
|
|
158
202
|
)}
|
|
159
|
-
</
|
|
203
|
+
</Box>
|
|
160
204
|
);
|
|
161
205
|
};
|
|
162
206
|
|
|
207
|
+
DatePickerComponent.displayName = 'DatePicker';
|
|
208
|
+
|
|
209
|
+
const DatePicker = fixedForwardRef(DatePickerComponent);
|
|
210
|
+
|
|
163
211
|
export default DatePicker;
|