@groupeactual/ui-kit 1.6.7-beta.0 → 1.7.0-beta.3
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 +9 -9
- package/dist/cjs/index.js.map +1 -1
- package/dist/es/index.d.ts +132 -166
- package/dist/es/index.js +97 -0
- package/dist/es/index.js.map +1 -0
- package/dist/{cjs/types → es/src}/components/Accordion/Accordion.d.ts +1 -4
- package/dist/es/{types → src}/components/BannerNotification/BannerNotification.d.ts +1 -4
- package/dist/es/{types → src}/components/Breadcrumbs/Breadcrumbs.d.ts +1 -4
- package/dist/{cjs/types → es/src}/components/Button/Button.d.ts +1 -4
- package/dist/es/{types → src}/components/Chip/Chip.d.ts +2 -5
- package/dist/es/{types → src}/components/Datatable/Datatable.d.ts +1 -1
- package/dist/es/{types → src}/components/Datatable/datatable.interface.d.ts +5 -4
- package/dist/{cjs/types → es/src}/components/EmbbededNotification/EmbeddedNotification.d.ts +1 -4
- package/dist/es/{types → src}/components/Form/AutoCompleteMulti/AutoCompleteMulti.d.ts +7 -6
- package/dist/{cjs/types → es/src}/components/Form/AutoCompleteSingle/AutoCompleteSingle.d.ts +4 -6
- package/dist/{cjs/types → es/src}/components/Form/Checkbox/Checkbox.d.ts +4 -7
- package/dist/es/src/components/Form/CheckboxGroup/CheckboxGroup.d.ts +12 -0
- package/dist/es/src/components/Form/CheckboxGroup/checkboxgroup.interface.d.ts +8 -0
- package/dist/{cjs/types → es/src}/components/Form/DatePicker/DatePicker.d.ts +1 -1
- package/dist/es/{types → src}/components/Form/MultiSelect/MultiSelect.d.ts +4 -7
- package/dist/{cjs/types → es/src}/components/Form/RadioGroup/RadioGroup.d.ts +2 -5
- package/dist/es/src/components/Form/Select/Select.d.ts +22 -0
- package/dist/{cjs/types → es/src}/components/Form/Switch/Switch.d.ts +1 -4
- package/dist/es/{types → src}/components/Form/TextField/TextField.d.ts +5 -6
- package/dist/es/src/components/Form/TimePicker/TimePicker.d.ts +20 -0
- package/dist/es/src/components/Form/TimePicker/index.d.ts +1 -0
- package/dist/es/src/components/IconButton/IconButton.d.ts +17 -0
- package/dist/{cjs/types → es/src}/components/IconProvider/IconProvider.d.ts +1 -4
- package/dist/es/{types → src}/components/Link/Link.d.ts +1 -4
- package/dist/es/src/components/MenuItem/MenuItem.d.ts +10 -0
- package/dist/es/{types → src}/components/Modal/Dialog/Dialog.d.ts +1 -1
- package/dist/es/{types → src}/components/Modal/Drawer/Drawer.d.ts +1 -1
- package/dist/{cjs/types → es/src}/components/Navigation/Stepper/Step.d.ts +1 -1
- package/dist/{cjs/types → es/src}/components/Navigation/Stepper/Stepper.d.ts +1 -1
- package/dist/es/src/components/Pagination/Pagination.d.ts +13 -0
- package/dist/{cjs/types → es/src}/components/Snackbar/Snackbar.d.ts +1 -4
- package/dist/{cjs/types → es/src}/components/Text/Text.d.ts +1 -4
- package/dist/es/src/components/Tooltip/Tooltip.d.ts +11 -0
- package/dist/{cjs/types → es/src}/components/UploadDocument/FileUploaderSingle.d.ts +10 -11
- package/dist/es/src/components/UploadDocument/fileuploadersingle.interface.d.ts +5 -0
- package/dist/{cjs/types → es/src}/components/index.d.ts +2 -0
- package/dist/{cjs/types → es/src}/helpers/GooglePickerWrapper.d.ts +2 -1
- package/dist/es/src/hooks/useGooleDrivePicker.d.ts +4 -0
- package/dist/es/src/index.d.ts +4 -0
- package/package.json +30 -35
- package/src/DesignSystemProvider.tsx +2 -1
- package/src/components/Accordion/Accordion.tsx +4 -4
- package/src/components/BannerNotification/BannerNotification.tsx +1 -3
- package/src/components/Breadcrumbs/Breadcrumbs.tsx +2 -4
- package/src/components/Button/Button.tsx +0 -2
- package/src/components/Chip/Chip.tsx +2 -4
- package/src/components/Datatable/Datatable.tsx +31 -9
- package/src/components/Datatable/DatatableCellRender.tsx +4 -3
- package/src/components/Datatable/datatable.interface.ts +5 -4
- package/src/components/Datatable/use-pagination-props.hook.ts +2 -2
- package/src/components/EmbbededNotification/EmbeddedNotification.tsx +2 -4
- package/src/components/Form/AutoCompleteMulti/AutoCompleteMulti.tsx +37 -12
- package/src/components/Form/AutoCompleteSingle/AutoCompleteSingle.tsx +28 -11
- package/src/components/Form/Checkbox/Checkbox.tsx +24 -27
- package/src/components/Form/CheckboxGroup/CheckboxGroup.tsx +9 -26
- package/src/components/Form/CheckboxGroup/checkboxgroup.interface.ts +22 -0
- package/src/components/Form/DatePicker/DatePicker.tsx +16 -4
- package/src/components/Form/MultiSelect/MultiSelect.tsx +43 -14
- package/src/components/Form/RadioGroup/RadioGroup.tsx +20 -25
- package/src/components/Form/Select/Select.tsx +49 -12
- package/src/components/Form/Switch/Switch.tsx +0 -2
- package/src/components/Form/TextField/TextField.tsx +121 -108
- package/src/components/Form/TimePicker/TimePicker.tsx +228 -0
- package/src/components/Form/TimePicker/index.ts +1 -0
- package/src/components/IconButton/IconButton.tsx +15 -9
- package/src/components/IconProvider/IconProvider.tsx +3 -4
- package/src/components/Link/Link.tsx +0 -2
- package/src/components/MenuItem/MenuItem.tsx +10 -39
- package/src/components/Modal/Dialog/Dialog.tsx +7 -4
- package/src/components/Modal/Drawer/Drawer.tsx +2 -2
- package/src/components/Navigation/Stepper/Step.tsx +4 -3
- package/src/components/Navigation/Stepper/Stepper.tsx +1 -1
- package/src/components/NotistackAdapter/NotistackAdapter.tsx +1 -1
- package/src/components/Pagination/Pagination.tsx +9 -14
- package/src/components/Snackbar/Snackbar.tsx +1 -3
- package/src/components/Text/Text.tsx +0 -2
- package/src/components/Tooltip/Tooltip.tsx +41 -32
- package/src/components/UploadDocument/FileUploaderSingle.tsx +97 -55
- package/src/components/UploadDocument/fileuploadersingle.interface.ts +5 -0
- package/src/components/index.ts +2 -0
- package/src/helpers/GooglePickerWrapper.tsx +3 -3
- package/src/hooks/useGooleDrivePicker.ts +10 -8
- package/src/index.ts +3 -5
- package/src/types/global.d.ts +6 -4
- package/src/types/googleDrive.ts +1 -0
- package/dist/cjs/types/components/BannerNotification/BannerNotification.d.ts +0 -11
- package/dist/cjs/types/components/Breadcrumbs/Breadcrumbs.d.ts +0 -15
- package/dist/cjs/types/components/Chip/Chip.d.ts +0 -19
- package/dist/cjs/types/components/Datatable/Datatable.d.ts +0 -4
- package/dist/cjs/types/components/Datatable/datatable.interface.d.ts +0 -53
- package/dist/cjs/types/components/Form/AutoCompleteMulti/AutoCompleteMulti.d.ts +0 -18
- package/dist/cjs/types/components/Form/CheckboxGroup/CheckboxGroup.d.ts +0 -20
- package/dist/cjs/types/components/Form/MultiSelect/MultiSelect.d.ts +0 -23
- package/dist/cjs/types/components/Form/Select/Select.d.ts +0 -22
- package/dist/cjs/types/components/Form/TextField/TextField.d.ts +0 -21
- package/dist/cjs/types/components/IconButton/IconButton.d.ts +0 -19
- package/dist/cjs/types/components/Link/Link.d.ts +0 -11
- package/dist/cjs/types/components/MenuItem/MenuItem.d.ts +0 -13
- package/dist/cjs/types/components/Modal/Dialog/Dialog.d.ts +0 -4
- package/dist/cjs/types/components/Modal/Drawer/Drawer.d.ts +0 -4
- package/dist/cjs/types/components/Pagination/Pagination.d.ts +0 -16
- package/dist/cjs/types/components/Tooltip/Tooltip.d.ts +0 -13
- package/dist/cjs/types/helpers/dataGetValue.d.ts +0 -2
- package/dist/cjs/types/hooks/useGooleDrivePicker.d.ts +0 -4
- package/dist/cjs/types/index.d.ts +0 -2
- package/dist/es/index.mjs +0 -106
- package/dist/es/index.mjs.map +0 -1
- package/dist/es/types/DesignSystemProvider.d.ts +0 -13
- package/dist/es/types/components/Accordion/Accordion.d.ts +0 -15
- package/dist/es/types/components/Accordion/index.d.ts +0 -1
- package/dist/es/types/components/BannerNotification/index.d.ts +0 -1
- package/dist/es/types/components/Breadcrumbs/index.d.ts +0 -1
- package/dist/es/types/components/Button/Button.d.ts +0 -11
- package/dist/es/types/components/Button/index.d.ts +0 -1
- package/dist/es/types/components/Chip/index.d.ts +0 -1
- package/dist/es/types/components/Datatable/DatatableCellRender.d.ts +0 -4
- package/dist/es/types/components/Datatable/index.d.ts +0 -1
- package/dist/es/types/components/Datatable/use-pagination-props.hook.d.ts +0 -3
- package/dist/es/types/components/EmbbededNotification/EmbeddedNotification.d.ts +0 -13
- package/dist/es/types/components/EmbbededNotification/index.d.ts +0 -1
- package/dist/es/types/components/Form/AutoCompleteMulti/index.d.ts +0 -1
- package/dist/es/types/components/Form/AutoCompleteSingle/AutoCompleteSingle.d.ts +0 -19
- package/dist/es/types/components/Form/AutoCompleteSingle/index.d.ts +0 -1
- package/dist/es/types/components/Form/Checkbox/Checkbox.d.ts +0 -17
- package/dist/es/types/components/Form/Checkbox/index.d.ts +0 -1
- package/dist/es/types/components/Form/CheckboxGroup/CheckboxGroup.d.ts +0 -20
- package/dist/es/types/components/Form/CheckboxGroup/index.d.ts +0 -1
- package/dist/es/types/components/Form/DatePicker/DatePicker.d.ts +0 -15
- package/dist/es/types/components/Form/DatePicker/index.d.ts +0 -1
- package/dist/es/types/components/Form/MultiSelect/index.d.ts +0 -1
- package/dist/es/types/components/Form/RadioGroup/RadioGroup.d.ts +0 -21
- package/dist/es/types/components/Form/RadioGroup/index.d.ts +0 -1
- package/dist/es/types/components/Form/Select/Select.d.ts +0 -22
- package/dist/es/types/components/Form/Select/index.d.ts +0 -1
- package/dist/es/types/components/Form/Switch/Switch.d.ts +0 -13
- package/dist/es/types/components/Form/Switch/index.d.ts +0 -1
- package/dist/es/types/components/Form/TextField/index.d.ts +0 -1
- package/dist/es/types/components/IconButton/IconButton.d.ts +0 -19
- package/dist/es/types/components/IconButton/index.d.ts +0 -1
- package/dist/es/types/components/IconProvider/IconProvider.d.ts +0 -22
- package/dist/es/types/components/IconProvider/index.d.ts +0 -1
- package/dist/es/types/components/Link/index.d.ts +0 -1
- package/dist/es/types/components/MenuItem/MenuItem.d.ts +0 -13
- package/dist/es/types/components/MenuItem/index.d.ts +0 -1
- package/dist/es/types/components/Modal/Dialog/index.d.ts +0 -1
- package/dist/es/types/components/Modal/Drawer/index.d.ts +0 -1
- package/dist/es/types/components/Modal/modal.interface.d.ts +0 -24
- package/dist/es/types/components/Navigation/Stepper/Step.d.ts +0 -7
- package/dist/es/types/components/Navigation/Stepper/Stepper.d.ts +0 -11
- package/dist/es/types/components/Navigation/Stepper/index.d.ts +0 -1
- package/dist/es/types/components/Navigation/Stepper/stepper.helper.d.ts +0 -2
- package/dist/es/types/components/Navigation/Stepper/stepper.interface.d.ts +0 -12
- package/dist/es/types/components/NotistackAdapter/NotistackAdapter.d.ts +0 -4
- package/dist/es/types/components/NotistackAdapter/index.d.ts +0 -1
- package/dist/es/types/components/Pagination/Pagination.d.ts +0 -16
- package/dist/es/types/components/Pagination/index.d.ts +0 -1
- package/dist/es/types/components/Pagination/pagination.helper.d.ts +0 -1
- package/dist/es/types/components/Snackbar/Snackbar.d.ts +0 -11
- package/dist/es/types/components/Snackbar/index.d.ts +0 -1
- package/dist/es/types/components/Text/Text.d.ts +0 -11
- package/dist/es/types/components/Text/index.d.ts +0 -1
- package/dist/es/types/components/Tooltip/Tooltip.d.ts +0 -13
- package/dist/es/types/components/Tooltip/index.d.ts +0 -1
- package/dist/es/types/components/Tooltip/tooltip.interface.d.ts +0 -1
- package/dist/es/types/components/UploadDocument/FileUploaderSingle.d.ts +0 -78
- package/dist/es/types/components/UploadDocument/index.d.ts +0 -1
- package/dist/es/types/components/index.d.ts +0 -31
- package/dist/es/types/helpers/GooglePickerWrapper.d.ts +0 -13
- package/dist/es/types/helpers/dataGetValue.d.ts +0 -2
- package/dist/es/types/hooks/useGooleDrivePicker.d.ts +0 -4
- package/dist/es/types/index.d.ts +0 -2
- package/dist/es/types/types/googleDrive.d.ts +0 -133
- package/src/helpers/dataGetValue.ts +0 -22
- /package/dist/{cjs/types → es/src}/DesignSystemProvider.d.ts +0 -0
- /package/dist/{cjs/types → es/src}/components/Accordion/index.d.ts +0 -0
- /package/dist/{cjs/types → es/src}/components/BannerNotification/index.d.ts +0 -0
- /package/dist/{cjs/types → es/src}/components/Breadcrumbs/index.d.ts +0 -0
- /package/dist/{cjs/types → es/src}/components/Button/index.d.ts +0 -0
- /package/dist/{cjs/types → es/src}/components/Chip/index.d.ts +0 -0
- /package/dist/{cjs/types → es/src}/components/Datatable/DatatableCellRender.d.ts +0 -0
- /package/dist/{cjs/types → es/src}/components/Datatable/index.d.ts +0 -0
- /package/dist/{cjs/types → es/src}/components/Datatable/use-pagination-props.hook.d.ts +0 -0
- /package/dist/{cjs/types → es/src}/components/EmbbededNotification/index.d.ts +0 -0
- /package/dist/{cjs/types → es/src}/components/Form/AutoCompleteMulti/index.d.ts +0 -0
- /package/dist/{cjs/types → es/src}/components/Form/AutoCompleteSingle/index.d.ts +0 -0
- /package/dist/{cjs/types → es/src}/components/Form/Checkbox/index.d.ts +0 -0
- /package/dist/{cjs/types → es/src}/components/Form/CheckboxGroup/index.d.ts +0 -0
- /package/dist/{cjs/types → es/src}/components/Form/DatePicker/index.d.ts +0 -0
- /package/dist/{cjs/types → es/src}/components/Form/MultiSelect/index.d.ts +0 -0
- /package/dist/{cjs/types → es/src}/components/Form/RadioGroup/index.d.ts +0 -0
- /package/dist/{cjs/types → es/src}/components/Form/Select/index.d.ts +0 -0
- /package/dist/{cjs/types → es/src}/components/Form/Switch/index.d.ts +0 -0
- /package/dist/{cjs/types → es/src}/components/Form/TextField/index.d.ts +0 -0
- /package/dist/{cjs/types → es/src}/components/IconButton/index.d.ts +0 -0
- /package/dist/{cjs/types → es/src}/components/IconProvider/index.d.ts +0 -0
- /package/dist/{cjs/types → es/src}/components/Link/index.d.ts +0 -0
- /package/dist/{cjs/types → es/src}/components/MenuItem/index.d.ts +0 -0
- /package/dist/{cjs/types → es/src}/components/Modal/Dialog/index.d.ts +0 -0
- /package/dist/{cjs/types → es/src}/components/Modal/Drawer/index.d.ts +0 -0
- /package/dist/{cjs/types → es/src}/components/Modal/modal.interface.d.ts +0 -0
- /package/dist/{cjs/types → es/src}/components/Navigation/Stepper/index.d.ts +0 -0
- /package/dist/{cjs/types → es/src}/components/Navigation/Stepper/stepper.helper.d.ts +0 -0
- /package/dist/{cjs/types → es/src}/components/Navigation/Stepper/stepper.interface.d.ts +0 -0
- /package/dist/{cjs/types → es/src}/components/NotistackAdapter/NotistackAdapter.d.ts +0 -0
- /package/dist/{cjs/types → es/src}/components/NotistackAdapter/index.d.ts +0 -0
- /package/dist/{cjs/types → es/src}/components/Pagination/index.d.ts +0 -0
- /package/dist/{cjs/types → es/src}/components/Pagination/pagination.helper.d.ts +0 -0
- /package/dist/{cjs/types → es/src}/components/Snackbar/index.d.ts +0 -0
- /package/dist/{cjs/types → es/src}/components/Text/index.d.ts +0 -0
- /package/dist/{cjs/types → es/src}/components/Tooltip/index.d.ts +0 -0
- /package/dist/{cjs/types → es/src}/components/Tooltip/tooltip.interface.d.ts +0 -0
- /package/dist/{cjs/types → es/src}/components/UploadDocument/index.d.ts +0 -0
- /package/dist/{cjs/types → es/src}/types/googleDrive.d.ts +0 -0
|
@@ -15,11 +15,11 @@ import {
|
|
|
15
15
|
useTheme,
|
|
16
16
|
} from '@mui/material';
|
|
17
17
|
|
|
18
|
-
import Icon from '
|
|
18
|
+
import Icon from '@/components/IconProvider';
|
|
19
19
|
|
|
20
20
|
interface Props extends Omit<TextFieldProps, 'error'> {
|
|
21
21
|
error?: string;
|
|
22
|
-
label
|
|
22
|
+
label?: string;
|
|
23
23
|
value?: string | unknown;
|
|
24
24
|
name?: string;
|
|
25
25
|
placeholder?: string;
|
|
@@ -28,124 +28,137 @@ interface Props extends Omit<TextFieldProps, 'error'> {
|
|
|
28
28
|
maxLength?: number;
|
|
29
29
|
width?: number | string;
|
|
30
30
|
className?: string;
|
|
31
|
+
focused?: boolean;
|
|
32
|
+
onClick?: (_e: React.MouseEvent<HTMLInputElement>) => void;
|
|
31
33
|
onBlur?: FocusEventHandler<unknown>;
|
|
32
34
|
onChange?: (
|
|
33
|
-
|
|
35
|
+
_e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>,
|
|
34
36
|
) => void;
|
|
35
37
|
}
|
|
36
|
-
const TextField = ({
|
|
37
|
-
name,
|
|
38
|
-
value,
|
|
39
|
-
error,
|
|
40
|
-
onBlur,
|
|
41
|
-
onChange,
|
|
42
|
-
label,
|
|
43
|
-
disabled,
|
|
44
|
-
width = '100%',
|
|
45
|
-
endAdornment,
|
|
46
|
-
placeholder = '',
|
|
47
|
-
maxLength,
|
|
48
|
-
...props
|
|
49
|
-
}: Props) => {
|
|
50
|
-
const theme = useTheme();
|
|
51
|
-
const StyledTextField = useMemo(
|
|
52
|
-
() => styled(MuiTextField)(TextFieldStyle(theme)),
|
|
53
|
-
[theme],
|
|
54
|
-
);
|
|
55
38
|
|
|
56
|
-
|
|
57
|
-
|
|
39
|
+
const TextField = React.forwardRef<HTMLDivElement, Props>(
|
|
40
|
+
(
|
|
41
|
+
{
|
|
42
|
+
name,
|
|
43
|
+
value,
|
|
44
|
+
error,
|
|
45
|
+
onBlur,
|
|
46
|
+
onChange,
|
|
47
|
+
label = '',
|
|
48
|
+
disabled,
|
|
49
|
+
width = '100%',
|
|
50
|
+
endAdornment,
|
|
51
|
+
placeholder = '',
|
|
52
|
+
maxLength,
|
|
53
|
+
focused,
|
|
54
|
+
...props
|
|
55
|
+
},
|
|
56
|
+
ref,
|
|
57
|
+
) => {
|
|
58
|
+
const theme = useTheme();
|
|
59
|
+
const StyledTextField = useMemo(
|
|
60
|
+
() => styled(MuiTextField)(TextFieldStyle(theme)),
|
|
61
|
+
[theme],
|
|
62
|
+
);
|
|
58
63
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
className="DsTextField-passwordIcon"
|
|
63
|
-
icon={showPassword ? faEyeSlash : faEye}
|
|
64
|
-
color="blueClickable"
|
|
65
|
-
onClick={() => setShowPassword(!showPassword)}
|
|
66
|
-
/>
|
|
64
|
+
const [showPassword, setShowPassword] = useState(false);
|
|
65
|
+
const [currentType, setCurrentType] = useState<string>(
|
|
66
|
+
props.type ?? 'text',
|
|
67
67
|
);
|
|
68
|
-
}, [showPassword]);
|
|
69
68
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
69
|
+
const passwordEndAdornment: React.ReactNode = useMemo(() => {
|
|
70
|
+
return (
|
|
71
|
+
<Icon
|
|
72
|
+
className="DsTextField-passwordIcon"
|
|
73
|
+
icon={showPassword ? faEyeSlash : faEye}
|
|
74
|
+
color="blueClickable"
|
|
75
|
+
onClick={() => setShowPassword(!showPassword)}
|
|
76
|
+
/>
|
|
77
|
+
);
|
|
78
|
+
}, [showPassword]);
|
|
77
79
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
];
|
|
80
|
+
useEffect(() => {
|
|
81
|
+
if (showPassword) {
|
|
82
|
+
setCurrentType('text');
|
|
83
|
+
} else {
|
|
84
|
+
setCurrentType(props.type ?? 'text');
|
|
85
|
+
}
|
|
86
|
+
}, [showPassword]);
|
|
85
87
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
+
const getTextFieldClassName = useMemo(() => {
|
|
89
|
+
const classNames = [
|
|
90
|
+
(!placeholder && 'TextField-mui') || 'TextField-ds',
|
|
91
|
+
props.color === 'success' && 'Mui-success',
|
|
92
|
+
value && 'Mui-filled',
|
|
93
|
+
props.className,
|
|
94
|
+
];
|
|
88
95
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
Boolean(
|
|
92
|
-
(error && error?.length > 0) ||
|
|
93
|
-
(maxLength && String(value).length > maxLength),
|
|
94
|
-
),
|
|
95
|
-
[error, maxLength, value],
|
|
96
|
-
);
|
|
96
|
+
return classNames.filter(Boolean).join(' ');
|
|
97
|
+
}, [value]);
|
|
97
98
|
|
|
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
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
99
|
+
const hasError = useMemo(
|
|
100
|
+
() =>
|
|
101
|
+
Boolean(
|
|
102
|
+
(error && error?.length > 0) ||
|
|
103
|
+
(maxLength && String(value).length > maxLength),
|
|
104
|
+
),
|
|
105
|
+
[error, maxLength, value],
|
|
106
|
+
);
|
|
107
|
+
|
|
108
|
+
return (
|
|
109
|
+
<StyledTextField
|
|
110
|
+
variant="outlined"
|
|
111
|
+
name={name}
|
|
112
|
+
ref={ref}
|
|
113
|
+
label={label}
|
|
114
|
+
value={value}
|
|
115
|
+
sx={{ width }}
|
|
116
|
+
placeholder={placeholder}
|
|
117
|
+
focused={focused}
|
|
118
|
+
FormHelperTextProps={{ component: 'div' } as never}
|
|
119
|
+
InputLabelProps={{
|
|
120
|
+
shrink: (placeholder && true) || undefined,
|
|
121
|
+
}}
|
|
122
|
+
onClick={(e) => e.stopPropagation()}
|
|
123
|
+
onChange={(e) => {
|
|
124
|
+
onChange?.(e);
|
|
125
|
+
}}
|
|
126
|
+
onBlur={(e) => {
|
|
127
|
+
onBlur?.(e);
|
|
128
|
+
}}
|
|
129
|
+
error={hasError}
|
|
130
|
+
disabled={disabled}
|
|
131
|
+
InputProps={
|
|
132
|
+
props.type === 'password'
|
|
133
|
+
? { endAdornment: passwordEndAdornment }
|
|
134
|
+
: { endAdornment }
|
|
135
|
+
}
|
|
136
|
+
{...props}
|
|
137
|
+
className={getTextFieldClassName}
|
|
138
|
+
type={currentType}
|
|
139
|
+
helperText={
|
|
140
|
+
<div style={{ display: 'table', width: '100%', marginRight: '4px' }}>
|
|
141
|
+
{(error || props.helperText) && (
|
|
142
|
+
<div
|
|
143
|
+
style={{
|
|
144
|
+
display: maxLength ? 'table-cell' : '',
|
|
145
|
+
float: 'left',
|
|
146
|
+
}}
|
|
147
|
+
>
|
|
148
|
+
{error || props.helperText}
|
|
149
|
+
</div>
|
|
150
|
+
)}
|
|
151
|
+
{maxLength && (
|
|
152
|
+
<div style={{ display: 'table-cell', float: 'right' }}>
|
|
153
|
+
{String(value).length}/{maxLength} caract.
|
|
154
|
+
</div>
|
|
155
|
+
)}
|
|
156
|
+
</div>
|
|
157
|
+
}
|
|
158
|
+
/>
|
|
159
|
+
);
|
|
160
|
+
},
|
|
161
|
+
);
|
|
149
162
|
|
|
150
163
|
TextField.displayName = 'TextField';
|
|
151
164
|
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
import React, { MouseEventHandler, useEffect, useRef, useState } from 'react';
|
|
2
|
+
|
|
3
|
+
import { faCheck, faClock } from '@fortawesome/pro-regular-svg-icons';
|
|
4
|
+
import { Popover, PopoverProps, TextFieldProps } from '@mui/material';
|
|
5
|
+
import { DigitalClock, LocalizationProvider } from '@mui/x-date-pickers-pro';
|
|
6
|
+
import { AdapterDayjs } from '@mui/x-date-pickers-pro/AdapterDayjs';
|
|
7
|
+
import { enUS, frFR } from '@mui/x-date-pickers/locales';
|
|
8
|
+
import dayjs, { Dayjs } from 'dayjs';
|
|
9
|
+
|
|
10
|
+
import TextField from '@/components/Form/TextField';
|
|
11
|
+
import IconProvider from '@/components/IconProvider';
|
|
12
|
+
|
|
13
|
+
interface Props extends Omit<TextFieldProps, 'error' | 'onChange'> {
|
|
14
|
+
value: Dayjs | undefined;
|
|
15
|
+
onChange?: (_time: string | Dayjs | undefined) => void;
|
|
16
|
+
onTouched?: () => void;
|
|
17
|
+
label?: string;
|
|
18
|
+
helperText?: string;
|
|
19
|
+
minTime?: Dayjs;
|
|
20
|
+
maxTime?: Dayjs;
|
|
21
|
+
timeStep?: number;
|
|
22
|
+
error?: string;
|
|
23
|
+
disabled?: boolean;
|
|
24
|
+
width?: string | number;
|
|
25
|
+
locale?: 'fr' | 'en';
|
|
26
|
+
color?: 'success';
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const TimePicker = ({
|
|
30
|
+
value,
|
|
31
|
+
label = '',
|
|
32
|
+
helperText = '',
|
|
33
|
+
error,
|
|
34
|
+
disabled = false,
|
|
35
|
+
minTime = dayjs().hour(8).minute(0),
|
|
36
|
+
maxTime = dayjs().hour(19).minute(0),
|
|
37
|
+
timeStep = 15,
|
|
38
|
+
locale = 'fr',
|
|
39
|
+
width,
|
|
40
|
+
color,
|
|
41
|
+
onTouched,
|
|
42
|
+
onChange,
|
|
43
|
+
...props
|
|
44
|
+
}: Props) => {
|
|
45
|
+
const [customError, setCustomError] = useState<string | null>(null);
|
|
46
|
+
const [textHour, setTextHour] = useState<string>(
|
|
47
|
+
value && typeof value !== 'string' ? value.format('HH:mm') : '',
|
|
48
|
+
);
|
|
49
|
+
const [displayedMinTime, setDisplayedMinTime] = useState<Dayjs | undefined>(
|
|
50
|
+
undefined,
|
|
51
|
+
);
|
|
52
|
+
const [anchorEl, setAnchorEl] = useState<PopoverProps['anchorEl'] | null>(
|
|
53
|
+
null,
|
|
54
|
+
);
|
|
55
|
+
const [textHourFixed, setTextHourFixed] = useState<boolean>(false);
|
|
56
|
+
const [textfieldWidth, setTextfieldWidth] = useState<number | undefined>(
|
|
57
|
+
undefined,
|
|
58
|
+
);
|
|
59
|
+
const textFieldRef = useRef<HTMLDivElement>(null); // Reference for the TextField
|
|
60
|
+
|
|
61
|
+
const isOpen = Boolean(anchorEl);
|
|
62
|
+
|
|
63
|
+
const handleClick: MouseEventHandler = (_event: React.MouseEvent) => {
|
|
64
|
+
if (disabled) return;
|
|
65
|
+
if (textHour === '') setTextHour('HH:mm');
|
|
66
|
+
setAnchorEl(textFieldRef.current);
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
const handleClose = () => {
|
|
70
|
+
onTouched?.();
|
|
71
|
+
setAnchorEl(null);
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
const handleChange = (
|
|
75
|
+
e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>,
|
|
76
|
+
) => {
|
|
77
|
+
if (/H/.test(e.target.value) || e.target.value === '' || !e.target.value) {
|
|
78
|
+
setTextHour('');
|
|
79
|
+
setCustomError(null);
|
|
80
|
+
onChange?.(undefined);
|
|
81
|
+
} else {
|
|
82
|
+
const inputValue = e.target.value;
|
|
83
|
+
const numericValue = inputValue.replace(/[^\d]/g, '');
|
|
84
|
+
const formattedValue =
|
|
85
|
+
numericValue.slice(0, 2) +
|
|
86
|
+
(numericValue.length > 2 ? ':' + numericValue.slice(2) : '');
|
|
87
|
+
|
|
88
|
+
if (formattedValue !== '') {
|
|
89
|
+
setTextHour(formattedValue);
|
|
90
|
+
} else {
|
|
91
|
+
setTextHour('');
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const dayjsTime = dayjs(inputValue, 'HH:mm', true);
|
|
95
|
+
const isValidTime = dayjsTime.isValid();
|
|
96
|
+
if (!isValidTime) {
|
|
97
|
+
if (!e.target?.value || e.target.value === 'HH:mm') {
|
|
98
|
+
setCustomError(null);
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
setCustomError(error || '');
|
|
102
|
+
onChange?.(e.target.value);
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
setCustomError(null);
|
|
106
|
+
onChange?.(dayjsTime);
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
useEffect(() => {
|
|
111
|
+
if (minTime && !displayedMinTime) {
|
|
112
|
+
setDisplayedMinTime(minTime.subtract(timeStep, 'minute'));
|
|
113
|
+
}
|
|
114
|
+
}, [minTime]);
|
|
115
|
+
|
|
116
|
+
useEffect(() => {
|
|
117
|
+
if (!value || textHour || textHourFixed) return;
|
|
118
|
+
setTextHourFixed(true);
|
|
119
|
+
setTextHour(
|
|
120
|
+
value && typeof value !== 'string' ? value?.format('HH:mm') : '',
|
|
121
|
+
);
|
|
122
|
+
}, [value]);
|
|
123
|
+
|
|
124
|
+
useEffect(() => {
|
|
125
|
+
if (textFieldRef.current) {
|
|
126
|
+
setTextfieldWidth(textFieldRef.current.offsetWidth);
|
|
127
|
+
}
|
|
128
|
+
}, [textFieldRef.current, textHour]);
|
|
129
|
+
|
|
130
|
+
return (
|
|
131
|
+
<>
|
|
132
|
+
<TextField
|
|
133
|
+
{...props}
|
|
134
|
+
ref={textFieldRef}
|
|
135
|
+
data-testid="select-hour"
|
|
136
|
+
fullWidth
|
|
137
|
+
error={customError || error}
|
|
138
|
+
label={label}
|
|
139
|
+
helperText={customError ?? helperText}
|
|
140
|
+
onChange={handleChange}
|
|
141
|
+
focused={isOpen}
|
|
142
|
+
value={textHour}
|
|
143
|
+
disabled={disabled}
|
|
144
|
+
width={width}
|
|
145
|
+
color={color}
|
|
146
|
+
endAdornment={
|
|
147
|
+
color === 'success' ? (
|
|
148
|
+
<IconProvider
|
|
149
|
+
onClick={handleClick}
|
|
150
|
+
sx={{
|
|
151
|
+
':hover': {
|
|
152
|
+
cursor: disabled ? 'auto' : 'pointer',
|
|
153
|
+
},
|
|
154
|
+
}}
|
|
155
|
+
icon={faCheck}
|
|
156
|
+
color="greenSuccess"
|
|
157
|
+
/>
|
|
158
|
+
) : (
|
|
159
|
+
<IconProvider
|
|
160
|
+
onClick={handleClick}
|
|
161
|
+
sx={{
|
|
162
|
+
':hover': {
|
|
163
|
+
cursor: disabled ? 'auto' : 'pointer',
|
|
164
|
+
},
|
|
165
|
+
}}
|
|
166
|
+
icon={faClock}
|
|
167
|
+
/>
|
|
168
|
+
)
|
|
169
|
+
}
|
|
170
|
+
/>
|
|
171
|
+
<Popover
|
|
172
|
+
data-testid="select-hour_popover"
|
|
173
|
+
open={isOpen}
|
|
174
|
+
anchorEl={anchorEl}
|
|
175
|
+
onClose={handleClose}
|
|
176
|
+
slotProps={{
|
|
177
|
+
paper: {
|
|
178
|
+
sx: {
|
|
179
|
+
boxShadow: '0px 2px 10px 0px #2727271F',
|
|
180
|
+
},
|
|
181
|
+
},
|
|
182
|
+
}}
|
|
183
|
+
anchorOrigin={{
|
|
184
|
+
vertical: 'bottom',
|
|
185
|
+
horizontal: 'left',
|
|
186
|
+
}}
|
|
187
|
+
transformOrigin={{
|
|
188
|
+
vertical: 'top',
|
|
189
|
+
horizontal: 'left',
|
|
190
|
+
}}
|
|
191
|
+
sx={{
|
|
192
|
+
marginTop: helperText !== '' ? '-20px' : '0px',
|
|
193
|
+
}}
|
|
194
|
+
>
|
|
195
|
+
<LocalizationProvider
|
|
196
|
+
dateAdapter={AdapterDayjs}
|
|
197
|
+
adapterLocale={locale}
|
|
198
|
+
localeText={
|
|
199
|
+
locale == 'fr'
|
|
200
|
+
? frFR.components.MuiLocalizationProvider.defaultProps.localeText
|
|
201
|
+
: enUS.components.MuiLocalizationProvider.defaultProps.localeText
|
|
202
|
+
}
|
|
203
|
+
>
|
|
204
|
+
<DigitalClock
|
|
205
|
+
data-testid="select-hour_digital_clock"
|
|
206
|
+
timeStep={timeStep}
|
|
207
|
+
value={value && typeof value === 'object' ? value : null}
|
|
208
|
+
onChange={(time) => {
|
|
209
|
+
setTextHour(time ? time.format('HH:mm') : '');
|
|
210
|
+
setCustomError(null);
|
|
211
|
+
if (time) onChange?.(time);
|
|
212
|
+
handleClose();
|
|
213
|
+
}}
|
|
214
|
+
ampm={false}
|
|
215
|
+
sx={{
|
|
216
|
+
width: textfieldWidth,
|
|
217
|
+
'& .MuiMenuItem-root.Mui-disabled': { display: 'none' },
|
|
218
|
+
}}
|
|
219
|
+
minTime={displayedMinTime}
|
|
220
|
+
maxTime={maxTime}
|
|
221
|
+
/>
|
|
222
|
+
</LocalizationProvider>
|
|
223
|
+
</Popover>
|
|
224
|
+
</>
|
|
225
|
+
);
|
|
226
|
+
};
|
|
227
|
+
|
|
228
|
+
export default TimePicker;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './TimePicker';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useMemo } from 'react';
|
|
1
|
+
import React, { MouseEventHandler, useMemo } from 'react';
|
|
2
2
|
|
|
3
3
|
import { IconDefinition } from '@fortawesome/fontawesome-svg-core';
|
|
4
4
|
import { IconButtonStyle } from '@groupeactual/design-tokens';
|
|
@@ -11,11 +11,11 @@ import {
|
|
|
11
11
|
useTheme,
|
|
12
12
|
} from '@mui/material';
|
|
13
13
|
|
|
14
|
-
import IconProvider from '
|
|
15
|
-
import Tooltip from '
|
|
16
|
-
import { Placement } from '
|
|
14
|
+
import IconProvider from '@/components/IconProvider';
|
|
15
|
+
import Tooltip from '@/components/Tooltip';
|
|
16
|
+
import { Placement } from '@/components/Tooltip/tooltip.interface';
|
|
17
17
|
|
|
18
|
-
interface Props extends IconButtonProps {
|
|
18
|
+
interface Props extends Omit<IconButtonProps, 'color'> {
|
|
19
19
|
icon: IconDefinition;
|
|
20
20
|
variant?: 'default' | 'table';
|
|
21
21
|
positionGroup?: 'left' | 'middle' | 'right';
|
|
@@ -23,7 +23,8 @@ interface Props extends IconButtonProps {
|
|
|
23
23
|
tooltipPosition?: Placement;
|
|
24
24
|
size?: 'small' | 'medium';
|
|
25
25
|
sx?: SxProps<Theme>;
|
|
26
|
-
|
|
26
|
+
color?: string;
|
|
27
|
+
onClick?: MouseEventHandler | undefined;
|
|
27
28
|
}
|
|
28
29
|
|
|
29
30
|
const IconButton = ({
|
|
@@ -33,6 +34,8 @@ const IconButton = ({
|
|
|
33
34
|
tooltipText = '',
|
|
34
35
|
tooltipPosition = 'top',
|
|
35
36
|
size = 'medium',
|
|
37
|
+
color,
|
|
38
|
+
onClick,
|
|
36
39
|
...iconButtonProps
|
|
37
40
|
}: Props) => {
|
|
38
41
|
const theme = useTheme();
|
|
@@ -46,14 +49,17 @@ const IconButton = ({
|
|
|
46
49
|
className={`IconButtonVariant-${variant} IconButtonSize-${size} ${
|
|
47
50
|
positionGroup ? `IconButtonPositionGroup-${positionGroup}` : ''
|
|
48
51
|
} `}
|
|
52
|
+
onClick={onClick}
|
|
49
53
|
{...iconButtonProps}
|
|
50
54
|
>
|
|
51
|
-
<IconProvider
|
|
55
|
+
<IconProvider
|
|
56
|
+
color={color}
|
|
57
|
+
icon={icon}
|
|
58
|
+
size={size === 'small' ? 'sm' : 'md'}
|
|
59
|
+
/>
|
|
52
60
|
</StyledIconButton>
|
|
53
61
|
</Tooltip>
|
|
54
62
|
);
|
|
55
63
|
};
|
|
56
64
|
|
|
57
|
-
IconButton.displayName = 'IconButton';
|
|
58
|
-
|
|
59
65
|
export default IconButton;
|
|
@@ -111,7 +111,8 @@ const IconProvider = ({
|
|
|
111
111
|
...sx,
|
|
112
112
|
color: usedColor,
|
|
113
113
|
width: usedFontSize,
|
|
114
|
-
height:
|
|
114
|
+
height: usedFontSize,
|
|
115
|
+
lineHeight: usedFontSize + 'px',
|
|
115
116
|
display: 'inline-flex',
|
|
116
117
|
alignItems: 'center',
|
|
117
118
|
justifyContent: 'center',
|
|
@@ -136,12 +137,10 @@ const IconProvider = ({
|
|
|
136
137
|
}, [variant, size]);
|
|
137
138
|
|
|
138
139
|
return (
|
|
139
|
-
<Box component="span" sx={getStyles()} {...props}>
|
|
140
|
+
<Box className="itemIcon" component="span" sx={getStyles()} {...props}>
|
|
140
141
|
<FontAwesomeSvgIcon icon={icon} fontSize={usedFontSize} />
|
|
141
142
|
</Box>
|
|
142
143
|
);
|
|
143
144
|
};
|
|
144
145
|
|
|
145
|
-
IconProvider.displayName = 'IconProvider';
|
|
146
|
-
|
|
147
146
|
export default IconProvider;
|
|
@@ -1,35 +1,21 @@
|
|
|
1
|
-
import React, { useMemo } from 'react';
|
|
1
|
+
import React, { ReactNode, useMemo } from 'react';
|
|
2
2
|
|
|
3
|
-
import { IconDefinition } from '@fortawesome/pro-regular-svg-icons';
|
|
4
3
|
import { MenuItemStyle } from '@groupeactual/design-tokens';
|
|
5
4
|
import {
|
|
6
|
-
Box,
|
|
7
5
|
MenuItem as MenuItemMUI,
|
|
8
6
|
MenuItemProps,
|
|
9
7
|
styled,
|
|
10
8
|
useTheme,
|
|
11
9
|
} from '@mui/material';
|
|
12
10
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
testId: string;
|
|
18
|
-
onAction: (value?: string) => void;
|
|
19
|
-
icon?: IconDefinition;
|
|
20
|
-
text: string;
|
|
21
|
-
value?: string;
|
|
11
|
+
interface Props extends Omit<MenuItemProps, 'onClick'> {
|
|
12
|
+
onClick: (_event?: React.MouseEvent<HTMLElement>) => void;
|
|
13
|
+
children: NonNullable<ReactNode>;
|
|
14
|
+
testId?: string;
|
|
22
15
|
disabled?: boolean;
|
|
23
16
|
}
|
|
24
17
|
|
|
25
|
-
const
|
|
26
|
-
onAction,
|
|
27
|
-
icon,
|
|
28
|
-
text,
|
|
29
|
-
testId,
|
|
30
|
-
value,
|
|
31
|
-
disabled,
|
|
32
|
-
}: Props) => {
|
|
18
|
+
const MenuItem = ({ onClick, children, testId, disabled, ...props }: Props) => {
|
|
33
19
|
const theme = useTheme();
|
|
34
20
|
const StyledMenuItem = useMemo(
|
|
35
21
|
() => styled(MenuItemMUI)(MenuItemStyle(theme)),
|
|
@@ -37,29 +23,14 @@ const MenuItemCustom = ({
|
|
|
37
23
|
);
|
|
38
24
|
return (
|
|
39
25
|
<StyledMenuItem
|
|
26
|
+
{...props}
|
|
40
27
|
disabled={disabled}
|
|
41
|
-
|
|
42
|
-
onClick={() => onAction(value)}
|
|
28
|
+
onClick={(e) => onClick(e)}
|
|
43
29
|
data-testid={testId}
|
|
44
30
|
>
|
|
45
|
-
|
|
46
|
-
{icon && (
|
|
47
|
-
<IconProvider
|
|
48
|
-
icon={icon}
|
|
49
|
-
size="sm"
|
|
50
|
-
color="bleuClickable"
|
|
51
|
-
sx={{
|
|
52
|
-
'&:hover': {
|
|
53
|
-
color: 'blueHoverClickable',
|
|
54
|
-
},
|
|
55
|
-
}}
|
|
56
|
-
data-testid={`${testId}-icon`}
|
|
57
|
-
/>
|
|
58
|
-
)}
|
|
59
|
-
<Text variant="body2">{text}</Text>
|
|
60
|
-
</Box>
|
|
31
|
+
{children}
|
|
61
32
|
</StyledMenuItem>
|
|
62
33
|
);
|
|
63
34
|
};
|
|
64
35
|
|
|
65
|
-
export default
|
|
36
|
+
export default MenuItem;
|
|
@@ -10,10 +10,13 @@ import {
|
|
|
10
10
|
} from '@mui/material';
|
|
11
11
|
import { OverridableTypeMap } from '@mui/material/OverridableComponent';
|
|
12
12
|
|
|
13
|
-
import IconButton from '
|
|
14
|
-
import IconProvider from '
|
|
15
|
-
import
|
|
16
|
-
|
|
13
|
+
import IconButton from '@/components/IconButton';
|
|
14
|
+
import IconProvider from '@/components/IconProvider';
|
|
15
|
+
import {
|
|
16
|
+
DialogTitleProps,
|
|
17
|
+
ModalProps,
|
|
18
|
+
} from '@/components/Modal/modal.interface';
|
|
19
|
+
import Text from '@/components/Text';
|
|
17
20
|
|
|
18
21
|
const BootstrapDialog = styled(DialogMUI)(() => ({
|
|
19
22
|
'& .MuiDialogContent-root': {
|
|
@@ -9,8 +9,8 @@ import {
|
|
|
9
9
|
Drawer as DrawerMUI,
|
|
10
10
|
} from '@mui/material';
|
|
11
11
|
|
|
12
|
-
import IconButton from '
|
|
13
|
-
import { ModalProps } from '
|
|
12
|
+
import IconButton from '@/components/IconButton';
|
|
13
|
+
import { ModalProps } from '@/components/Modal/modal.interface';
|
|
14
14
|
|
|
15
15
|
const Drawer = ({
|
|
16
16
|
title,
|