@groupeactual/ui-kit 1.7.0-beta.0 → 1.7.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.
Files changed (84) hide show
  1. package/dist/cjs/index.js +9 -9
  2. package/dist/cjs/index.js.map +1 -1
  3. package/dist/es/index.d.ts +176 -163
  4. package/dist/es/index.js +8 -18
  5. package/dist/es/index.js.map +1 -1
  6. package/dist/es/src/components/Accordion/Accordion.d.ts +1 -4
  7. package/dist/es/src/components/BannerNotification/BannerNotification.d.ts +1 -4
  8. package/dist/es/src/components/Breadcrumbs/Breadcrumbs.d.ts +1 -4
  9. package/dist/es/src/components/Button/Button.d.ts +1 -4
  10. package/dist/es/src/components/Chip/Chip.d.ts +2 -5
  11. package/dist/es/src/components/Datatable/Datatable.d.ts +1 -1
  12. package/dist/es/src/components/Datatable/datatable.interface.d.ts +5 -4
  13. package/dist/es/src/components/EmbbededNotification/EmbeddedNotification.d.ts +1 -4
  14. package/dist/es/src/components/Form/AutoCompleteMulti/AutoCompleteMulti.d.ts +7 -6
  15. package/dist/es/src/components/Form/AutoCompleteSingle/AutoCompleteSingle.d.ts +5 -7
  16. package/dist/es/src/components/Form/Checkbox/Checkbox.d.ts +4 -7
  17. package/dist/es/src/components/Form/CheckboxGroup/CheckboxGroup.d.ts +4 -12
  18. package/dist/es/src/components/Form/CheckboxGroup/checkboxgroup.interface.d.ts +8 -0
  19. package/dist/es/src/components/Form/DatePicker/DatePicker.d.ts +1 -1
  20. package/dist/es/src/components/Form/MultiSelect/MultiSelect.d.ts +4 -7
  21. package/dist/es/src/components/Form/RadioGroup/RadioGroup.d.ts +2 -5
  22. package/dist/es/src/components/Form/Select/Select.d.ts +5 -7
  23. package/dist/es/src/components/Form/Switch/Switch.d.ts +1 -4
  24. package/dist/es/src/components/Form/TextField/TextField.d.ts +5 -6
  25. package/dist/es/src/components/Form/TimePicker/TimePicker.d.ts +20 -0
  26. package/dist/es/src/components/Form/TimePicker/index.d.ts +1 -0
  27. package/dist/es/src/components/IconButton/IconButton.d.ts +5 -7
  28. package/dist/es/src/components/IconProvider/IconProvider.d.ts +1 -4
  29. package/dist/es/src/components/Link/Link.d.ts +1 -4
  30. package/dist/es/src/components/MenuItem/MenuItem.d.ts +7 -10
  31. package/dist/es/src/components/Navigation/Stepper/Step.d.ts +1 -1
  32. package/dist/es/src/components/Navigation/Stepper/Stepper.d.ts +1 -1
  33. package/dist/es/src/components/Pagination/Pagination.d.ts +3 -6
  34. package/dist/es/src/components/Snackbar/Snackbar.d.ts +1 -4
  35. package/dist/es/src/components/Text/Text.d.ts +1 -4
  36. package/dist/es/src/components/Tooltip/Tooltip.d.ts +5 -7
  37. package/dist/es/src/components/UploadDocument/FileUploaderSingle.d.ts +55 -8
  38. package/dist/es/src/components/UploadDocument/fileuploadersingle.interface.d.ts +5 -0
  39. package/dist/es/src/components/index.d.ts +2 -0
  40. package/dist/es/src/helpers/GooglePickerWrapper.d.ts +2 -1
  41. package/dist/es/src/hooks/useGooleDrivePicker.d.ts +1 -1
  42. package/package.json +20 -20
  43. package/src/components/Accordion/Accordion.tsx +4 -4
  44. package/src/components/BannerNotification/BannerNotification.tsx +0 -2
  45. package/src/components/Breadcrumbs/Breadcrumbs.tsx +0 -2
  46. package/src/components/Button/Button.tsx +0 -2
  47. package/src/components/Chip/Chip.tsx +1 -3
  48. package/src/components/Datatable/Datatable.tsx +27 -6
  49. package/src/components/Datatable/DatatableCellRender.tsx +2 -1
  50. package/src/components/Datatable/datatable.interface.ts +5 -4
  51. package/src/components/Datatable/use-pagination-props.hook.ts +2 -2
  52. package/src/components/EmbbededNotification/EmbeddedNotification.tsx +0 -2
  53. package/src/components/Form/AutoCompleteMulti/AutoCompleteMulti.tsx +24 -9
  54. package/src/components/Form/AutoCompleteSingle/AutoCompleteSingle.tsx +15 -10
  55. package/src/components/Form/Checkbox/Checkbox.tsx +22 -25
  56. package/src/components/Form/CheckboxGroup/CheckboxGroup.tsx +8 -25
  57. package/src/components/Form/CheckboxGroup/checkboxgroup.interface.ts +22 -0
  58. package/src/components/Form/DatePicker/DatePicker.tsx +15 -3
  59. package/src/components/Form/MultiSelect/MultiSelect.tsx +33 -7
  60. package/src/components/Form/RadioGroup/RadioGroup.tsx +18 -23
  61. package/src/components/Form/Select/Select.tsx +34 -6
  62. package/src/components/Form/Switch/Switch.tsx +0 -2
  63. package/src/components/Form/TextField/TextField.tsx +120 -107
  64. package/src/components/Form/TimePicker/TimePicker.tsx +228 -0
  65. package/src/components/Form/TimePicker/index.ts +1 -0
  66. package/src/components/IconButton/IconButton.tsx +12 -6
  67. package/src/components/IconProvider/IconProvider.tsx +3 -4
  68. package/src/components/Link/Link.tsx +0 -2
  69. package/src/components/MenuItem/MenuItem.tsx +10 -39
  70. package/src/components/Navigation/Stepper/Step.tsx +1 -1
  71. package/src/components/Navigation/Stepper/Stepper.tsx +1 -1
  72. package/src/components/Pagination/Pagination.tsx +4 -5
  73. package/src/components/Snackbar/Snackbar.tsx +0 -2
  74. package/src/components/Text/Text.tsx +0 -2
  75. package/src/components/Tooltip/Tooltip.tsx +41 -32
  76. package/src/components/UploadDocument/FileUploaderSingle.tsx +185 -88
  77. package/src/components/UploadDocument/fileuploadersingle.interface.ts +5 -0
  78. package/src/components/index.ts +2 -0
  79. package/src/helpers/GooglePickerWrapper.tsx +2 -2
  80. package/src/hooks/useGooleDrivePicker.ts +8 -6
  81. package/src/types/global.d.ts +6 -4
  82. package/src/types/googleDrive.ts +1 -0
  83. package/dist/es/src/helpers/dataGetValue.d.ts +0 -2
  84. 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-solid-svg-icons';
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: (value: T[]) => void;
45
- getRenderValue: (option: T) => string;
46
- getKeyValue: (option: T) => string;
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: (value: T) => void;
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 display="flex">
97
- {label}
97
+ <Box>
98
+ <Text component="span" variant="body1">
99
+ {label}
100
+ </Text>
98
101
  {infoBubbleContent && (
99
- <Box
100
- py={0}
101
- pl={0.5}
102
- width={16}
103
- height={21}
104
- display="flex"
105
- alignItems="center"
102
+ <Tooltip
103
+ title={infoBubbleContent}
104
+ placement={infoBubblePosition}
105
+ sx={{
106
+ ml: '6px',
107
+ }}
106
108
  >
107
- <Tooltip
108
- title={infoBubbleContent}
109
- placement={infoBubblePosition}
110
- >
111
- <IconProvider
112
- icon={faInfoCircle}
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-solid-svg-icons';
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: (option: T) => string;
35
- onChange: (value: T) => void;
36
- onBlur?: (event: BaseSyntheticEvent) => void;
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;
@@ -65,6 +65,4 @@ const Switch = ({
65
65
  );
66
66
  };
67
67
 
68
- Switch.displayName = 'Switch';
69
-
70
68
  export default Switch;
@@ -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: string;
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
- e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>,
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
- const [showPassword, setShowPassword] = useState(false);
57
- const [currentType, setCurrentType] = useState<string>(props.type ?? 'text');
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
- const passwordEndAdornment: React.ReactNode = useMemo(() => {
60
- return (
61
- <Icon
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
- useEffect(() => {
71
- if (showPassword) {
72
- setCurrentType('text');
73
- } else {
74
- setCurrentType(props.type ?? 'text');
75
- }
76
- }, [showPassword]);
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
- const getTextFieldClassName = useMemo(() => {
79
- const classNames = [
80
- (!placeholder && 'TextField-mui') || 'TextField-ds',
81
- props.color === 'success' && 'Mui-success',
82
- value && 'Mui-filled',
83
- props.className,
84
- ];
80
+ useEffect(() => {
81
+ if (showPassword) {
82
+ setCurrentType('text');
83
+ } else {
84
+ setCurrentType(props.type ?? 'text');
85
+ }
86
+ }, [showPassword]);
85
87
 
86
- return classNames.filter(Boolean).join(' ');
87
- }, [value]);
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
- const hasError = useMemo(
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
- return (
99
- <StyledTextField
100
- variant="outlined"
101
- name={name}
102
- label={label}
103
- value={value}
104
- sx={{ width }}
105
- placeholder={placeholder}
106
- FormHelperTextProps={{ component: 'div' } as never}
107
- InputLabelProps={{
108
- shrink: (placeholder && true) || undefined,
109
- }}
110
- onClick={(e) => e.stopPropagation()}
111
- onChange={(e) => {
112
- onChange?.(e);
113
- }}
114
- onBlur={(e) => {
115
- onBlur?.(e);
116
- }}
117
- error={hasError}
118
- disabled={disabled}
119
- InputProps={
120
- props.type === 'password'
121
- ? { endAdornment: passwordEndAdornment }
122
- : { endAdornment }
123
- }
124
- {...props}
125
- className={getTextFieldClassName}
126
- type={currentType}
127
- helperText={
128
- <div style={{ display: 'table', width: '100%', marginRight: '4px' }}>
129
- {(error || props.helperText) && (
130
- <div
131
- style={{
132
- display: maxLength ? 'table-cell' : '',
133
- float: 'left',
134
- }}
135
- >
136
- {error || props.helperText}
137
- </div>
138
- )}
139
- {maxLength && (
140
- <div style={{ display: 'table-cell', float: 'right' }}>
141
- {String(value).length}/{maxLength} caract.
142
- </div>
143
- )}
144
- </div>
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