@groupeactual/ui-kit 1.7.0-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 +176 -163
- package/dist/es/index.js +8 -18
- package/dist/es/index.js.map +1 -1
- package/dist/es/src/components/Accordion/Accordion.d.ts +1 -4
- package/dist/es/src/components/BannerNotification/BannerNotification.d.ts +1 -4
- package/dist/es/src/components/Breadcrumbs/Breadcrumbs.d.ts +1 -4
- package/dist/es/src/components/Button/Button.d.ts +1 -4
- package/dist/es/src/components/Chip/Chip.d.ts +2 -5
- package/dist/es/src/components/Datatable/Datatable.d.ts +1 -1
- package/dist/es/src/components/Datatable/datatable.interface.d.ts +5 -4
- package/dist/es/src/components/EmbbededNotification/EmbeddedNotification.d.ts +1 -4
- package/dist/es/src/components/Form/AutoCompleteMulti/AutoCompleteMulti.d.ts +7 -6
- package/dist/es/src/components/Form/AutoCompleteSingle/AutoCompleteSingle.d.ts +5 -7
- package/dist/es/src/components/Form/Checkbox/Checkbox.d.ts +4 -7
- package/dist/es/src/components/Form/CheckboxGroup/CheckboxGroup.d.ts +4 -12
- package/dist/es/src/components/Form/CheckboxGroup/checkboxgroup.interface.d.ts +8 -0
- package/dist/es/src/components/Form/DatePicker/DatePicker.d.ts +1 -1
- package/dist/es/src/components/Form/MultiSelect/MultiSelect.d.ts +4 -7
- package/dist/es/src/components/Form/RadioGroup/RadioGroup.d.ts +2 -5
- package/dist/es/src/components/Form/Select/Select.d.ts +5 -7
- package/dist/es/src/components/Form/Switch/Switch.d.ts +1 -4
- package/dist/es/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 +5 -7
- package/dist/es/src/components/IconProvider/IconProvider.d.ts +1 -4
- package/dist/es/src/components/Link/Link.d.ts +1 -4
- package/dist/es/src/components/MenuItem/MenuItem.d.ts +7 -10
- package/dist/es/src/components/Navigation/Stepper/Step.d.ts +1 -1
- package/dist/es/src/components/Navigation/Stepper/Stepper.d.ts +1 -1
- package/dist/es/src/components/Pagination/Pagination.d.ts +3 -6
- package/dist/es/src/components/Snackbar/Snackbar.d.ts +1 -4
- package/dist/es/src/components/Text/Text.d.ts +1 -4
- package/dist/es/src/components/Tooltip/Tooltip.d.ts +5 -7
- package/dist/es/src/components/UploadDocument/FileUploaderSingle.d.ts +55 -8
- package/dist/es/src/components/UploadDocument/fileuploadersingle.interface.d.ts +5 -0
- package/dist/es/src/components/index.d.ts +2 -0
- package/dist/es/src/helpers/GooglePickerWrapper.d.ts +2 -1
- package/dist/es/src/hooks/useGooleDrivePicker.d.ts +1 -1
- package/package.json +20 -20
- package/src/components/Accordion/Accordion.tsx +4 -4
- package/src/components/BannerNotification/BannerNotification.tsx +0 -2
- package/src/components/Breadcrumbs/Breadcrumbs.tsx +0 -2
- package/src/components/Button/Button.tsx +0 -2
- package/src/components/Chip/Chip.tsx +1 -3
- package/src/components/Datatable/Datatable.tsx +27 -6
- package/src/components/Datatable/DatatableCellRender.tsx +2 -1
- 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 +0 -2
- package/src/components/Form/AutoCompleteMulti/AutoCompleteMulti.tsx +24 -9
- package/src/components/Form/AutoCompleteSingle/AutoCompleteSingle.tsx +15 -10
- package/src/components/Form/Checkbox/Checkbox.tsx +22 -25
- package/src/components/Form/CheckboxGroup/CheckboxGroup.tsx +8 -25
- package/src/components/Form/CheckboxGroup/checkboxgroup.interface.ts +22 -0
- package/src/components/Form/DatePicker/DatePicker.tsx +15 -3
- package/src/components/Form/MultiSelect/MultiSelect.tsx +33 -7
- package/src/components/Form/RadioGroup/RadioGroup.tsx +18 -23
- package/src/components/Form/Select/Select.tsx +34 -6
- package/src/components/Form/Switch/Switch.tsx +0 -2
- package/src/components/Form/TextField/TextField.tsx +120 -107
- package/src/components/Form/TimePicker/TimePicker.tsx +228 -0
- package/src/components/Form/TimePicker/index.ts +1 -0
- package/src/components/IconButton/IconButton.tsx +12 -6
- 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/Navigation/Stepper/Step.tsx +1 -1
- package/src/components/Navigation/Stepper/Stepper.tsx +1 -1
- package/src/components/Pagination/Pagination.tsx +4 -5
- package/src/components/Snackbar/Snackbar.tsx +0 -2
- package/src/components/Text/Text.tsx +0 -2
- package/src/components/Tooltip/Tooltip.tsx +41 -32
- package/src/components/UploadDocument/FileUploaderSingle.tsx +156 -86
- package/src/components/UploadDocument/fileuploadersingle.interface.ts +5 -0
- package/src/components/index.ts +2 -0
- package/src/helpers/GooglePickerWrapper.tsx +2 -2
- package/src/hooks/useGooleDrivePicker.ts +8 -6
- package/src/types/global.d.ts +6 -4
- package/src/types/googleDrive.ts +1 -0
- package/dist/es/src/helpers/dataGetValue.d.ts +0 -2
- package/src/helpers/dataGetValue.ts +0 -22
|
@@ -3,9 +3,9 @@ import React, { FocusEventHandler, useMemo, useRef } from 'react';
|
|
|
3
3
|
import {
|
|
4
4
|
faCheck,
|
|
5
5
|
faChevronDown,
|
|
6
|
-
faCircleX,
|
|
7
6
|
faTimes,
|
|
8
|
-
} from '@fortawesome/pro-
|
|
7
|
+
} from '@fortawesome/pro-regular-svg-icons';
|
|
8
|
+
import { faCircleX } from '@fortawesome/pro-solid-svg-icons';
|
|
9
9
|
import { SelectStyle } from '@groupeactual/design-tokens';
|
|
10
10
|
import {
|
|
11
11
|
Box,
|
|
@@ -41,9 +41,9 @@ interface Props<T>
|
|
|
41
41
|
onBlur?:
|
|
42
42
|
| FocusEventHandler<HTMLInputElement | HTMLTextAreaElement>
|
|
43
43
|
| undefined;
|
|
44
|
-
onChange: (
|
|
45
|
-
getRenderValue: (
|
|
46
|
-
getKeyValue: (
|
|
44
|
+
onChange: (_value: T[]) => void;
|
|
45
|
+
getRenderValue: (_option: T) => string;
|
|
46
|
+
getKeyValue: (_option: T) => string;
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
const MenuProps = {
|
|
@@ -76,6 +76,7 @@ const MultiSelect = <T,>({
|
|
|
76
76
|
() => styled(FormControl)(SelectStyle(theme)),
|
|
77
77
|
[theme],
|
|
78
78
|
);
|
|
79
|
+
const [isOpened, setIsOpened] = React.useState(props.open ?? false);
|
|
79
80
|
|
|
80
81
|
const handleChange = (event: SelectChangeEvent<typeof options>) =>
|
|
81
82
|
onChange?.(event.target.value as T[]);
|
|
@@ -180,7 +181,15 @@ const MultiSelect = <T,>({
|
|
|
180
181
|
className={disabled ? 'Mui-disabled SelectIcon' : 'SelectIcon'}
|
|
181
182
|
icon={color === 'success' ? faCheck : faChevronDown}
|
|
182
183
|
size="md"
|
|
184
|
+
onClick={() => {
|
|
185
|
+
if (!disabled) {
|
|
186
|
+
setIsOpened(!isOpened);
|
|
187
|
+
}
|
|
188
|
+
}}
|
|
183
189
|
sx={{
|
|
190
|
+
':hover': {
|
|
191
|
+
cursor: disabled ? 'auto' : 'pointer',
|
|
192
|
+
},
|
|
184
193
|
transform:
|
|
185
194
|
className.toString().includes('iconOpen') &&
|
|
186
195
|
color !== 'success'
|
|
@@ -191,6 +200,25 @@ const MultiSelect = <T,>({
|
|
|
191
200
|
)}
|
|
192
201
|
MenuProps={MenuProps}
|
|
193
202
|
{...props}
|
|
203
|
+
open={isOpened}
|
|
204
|
+
onClose={(e) => {
|
|
205
|
+
if (!disabled) {
|
|
206
|
+
if (props.onClose) {
|
|
207
|
+
props.onClose(e);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
setIsOpened(false);
|
|
211
|
+
}
|
|
212
|
+
}}
|
|
213
|
+
onOpen={(e) => {
|
|
214
|
+
if (!disabled) {
|
|
215
|
+
if (props.onOpen) {
|
|
216
|
+
props.onOpen(e);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
setIsOpened(true);
|
|
220
|
+
}
|
|
221
|
+
}}
|
|
194
222
|
>
|
|
195
223
|
{options?.map((option) => (
|
|
196
224
|
<MenuItem
|
|
@@ -227,6 +255,4 @@ const MultiSelect = <T,>({
|
|
|
227
255
|
);
|
|
228
256
|
};
|
|
229
257
|
|
|
230
|
-
MultiSelect.displayName = 'MultiSelect';
|
|
231
|
-
|
|
232
258
|
export default MultiSelect;
|
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
} from '@mui/material';
|
|
17
17
|
|
|
18
18
|
import IconProvider from '@/components/IconProvider';
|
|
19
|
+
import Text from '@/components/Text';
|
|
19
20
|
import Tooltip from '@/components/Tooltip';
|
|
20
21
|
|
|
21
22
|
interface ItemType<T> {
|
|
@@ -41,7 +42,7 @@ interface ItemType<T> {
|
|
|
41
42
|
interface Props<T> extends Omit<RadioGroupProps, 'onChange'> {
|
|
42
43
|
label: string;
|
|
43
44
|
options: ItemType<T>[];
|
|
44
|
-
onChange: (
|
|
45
|
+
onChange: (_value: T) => void;
|
|
45
46
|
error?: string;
|
|
46
47
|
helperText?: string;
|
|
47
48
|
disabled?: boolean;
|
|
@@ -93,28 +94,24 @@ const RadioGroup = <T,>({
|
|
|
93
94
|
control={<MUIRadio size="small" />}
|
|
94
95
|
value={value}
|
|
95
96
|
label={
|
|
96
|
-
<Box
|
|
97
|
-
|
|
97
|
+
<Box>
|
|
98
|
+
<Text component="span" variant="body1">
|
|
99
|
+
{label}
|
|
100
|
+
</Text>
|
|
98
101
|
{infoBubbleContent && (
|
|
99
|
-
<
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
alignItems="center"
|
|
102
|
+
<Tooltip
|
|
103
|
+
title={infoBubbleContent}
|
|
104
|
+
placement={infoBubblePosition}
|
|
105
|
+
sx={{
|
|
106
|
+
ml: '6px',
|
|
107
|
+
}}
|
|
106
108
|
>
|
|
107
|
-
<
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
size="sm"
|
|
114
|
-
color="#1d91c3"
|
|
115
|
-
/>
|
|
116
|
-
</Tooltip>
|
|
117
|
-
</Box>
|
|
109
|
+
<IconProvider
|
|
110
|
+
icon={faInfoCircle}
|
|
111
|
+
size="sm"
|
|
112
|
+
color="blueInfo"
|
|
113
|
+
/>
|
|
114
|
+
</Tooltip>
|
|
118
115
|
)}
|
|
119
116
|
</Box>
|
|
120
117
|
}
|
|
@@ -131,6 +128,4 @@ const RadioGroup = <T,>({
|
|
|
131
128
|
);
|
|
132
129
|
};
|
|
133
130
|
|
|
134
|
-
RadioGroup.displayName = 'RadioGroup';
|
|
135
|
-
|
|
136
131
|
export default RadioGroup;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { BaseSyntheticEvent, useMemo } from 'react';
|
|
2
2
|
|
|
3
3
|
import { IconDefinition } from '@fortawesome/fontawesome-svg-core';
|
|
4
|
-
import { faCheck, faChevronDown } from '@fortawesome/pro-
|
|
4
|
+
import { faCheck, faChevronDown } from '@fortawesome/pro-regular-svg-icons';
|
|
5
5
|
import { SelectStyle } from '@groupeactual/design-tokens';
|
|
6
6
|
import {
|
|
7
7
|
Box,
|
|
@@ -31,9 +31,10 @@ interface Props<T>
|
|
|
31
31
|
error?: string;
|
|
32
32
|
className?: string;
|
|
33
33
|
popupIcon?: IconDefinition;
|
|
34
|
-
getRenderValue: (
|
|
35
|
-
onChange: (
|
|
36
|
-
onBlur?: (
|
|
34
|
+
getRenderValue: (_option: T) => string;
|
|
35
|
+
onChange: (_value: T) => void;
|
|
36
|
+
onBlur?: (_event: BaseSyntheticEvent) => void;
|
|
37
|
+
onClick?: (_event: BaseSyntheticEvent) => void;
|
|
37
38
|
}
|
|
38
39
|
|
|
39
40
|
const MenuProps = {
|
|
@@ -67,6 +68,8 @@ const Select = <T,>({
|
|
|
67
68
|
[theme],
|
|
68
69
|
);
|
|
69
70
|
|
|
71
|
+
const [isOpened, setIsOpened] = React.useState(props.open ?? false);
|
|
72
|
+
|
|
70
73
|
const handleChange = (event: SelectChangeEvent<T>) =>
|
|
71
74
|
onChange?.(event.target.value as T);
|
|
72
75
|
|
|
@@ -115,8 +118,16 @@ const Select = <T,>({
|
|
|
115
118
|
<IconProvider
|
|
116
119
|
className={disabled ? 'Mui-disabled SelectIcon' : 'SelectIcon'}
|
|
117
120
|
icon={color === 'success' ? faCheck : popupIcon}
|
|
121
|
+
onClick={() => {
|
|
122
|
+
if (!disabled) {
|
|
123
|
+
setIsOpened(!isOpened);
|
|
124
|
+
}
|
|
125
|
+
}}
|
|
118
126
|
size="md"
|
|
119
127
|
sx={{
|
|
128
|
+
':hover': {
|
|
129
|
+
cursor: disabled ? 'auto' : 'pointer',
|
|
130
|
+
},
|
|
120
131
|
marginTop: color === 'success' ? '2px' : '0px',
|
|
121
132
|
transform:
|
|
122
133
|
className.toString().includes('iconOpen') &&
|
|
@@ -129,6 +140,25 @@ const Select = <T,>({
|
|
|
129
140
|
MenuProps={MenuProps}
|
|
130
141
|
renderValue={(value) => getRenderValue(value)}
|
|
131
142
|
{...props}
|
|
143
|
+
open={isOpened}
|
|
144
|
+
onClose={(e) => {
|
|
145
|
+
if (!disabled) {
|
|
146
|
+
if (props.onClose) {
|
|
147
|
+
props.onClose(e);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
setIsOpened(false);
|
|
151
|
+
}
|
|
152
|
+
}}
|
|
153
|
+
onOpen={(e) => {
|
|
154
|
+
if (!disabled) {
|
|
155
|
+
if (props.onOpen) {
|
|
156
|
+
props.onOpen(e);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
setIsOpened(true);
|
|
160
|
+
}
|
|
161
|
+
}}
|
|
132
162
|
>
|
|
133
163
|
{options?.map((option, i) => (
|
|
134
164
|
<MenuItem
|
|
@@ -174,6 +204,4 @@ const Select = <T,>({
|
|
|
174
204
|
);
|
|
175
205
|
};
|
|
176
206
|
|
|
177
|
-
Select.displayName = 'Select';
|
|
178
|
-
|
|
179
207
|
export default Select;
|
|
@@ -19,7 +19,7 @@ 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
|
|