@groupeactual/ui-kit 1.0.10 → 1.0.12

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.
@@ -8,7 +8,7 @@ interface Props<T> extends Omit<SelectProps<T>, 'value' | 'onChange' | 'defaultV
8
8
  helperText?: string;
9
9
  color?: 'success';
10
10
  defaultValue?: T | undefined;
11
- width?: number;
11
+ width?: number | string;
12
12
  error?: string;
13
13
  }
14
14
  declare const Select: {
@@ -5,15 +5,16 @@ interface Props extends Omit<TextFieldProps, 'error'> {
5
5
  onBlur?: FocusEventHandler<unknown>;
6
6
  onChange?: StandardInputProps['onChange'];
7
7
  label: string;
8
- value: string;
9
- name: string;
8
+ value?: string | unknown;
9
+ name?: string;
10
10
  placeholder?: string;
11
11
  disabled?: boolean;
12
12
  endAdornment?: ReactNode;
13
13
  maxLength?: number;
14
+ width?: number | string;
14
15
  }
15
16
  declare const TextField: {
16
- ({ name, value, error, onBlur, onChange, label, disabled, endAdornment, placeholder, maxLength, ...props }: Props): React.JSX.Element;
17
+ ({ name, value, error, onBlur, onChange, label, disabled, width, endAdornment, placeholder, maxLength, ...props }: Props): React.JSX.Element;
17
18
  displayName: string;
18
19
  };
19
20
  export default TextField;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@groupeactual/ui-kit",
3
- "version": "1.0.10",
3
+ "version": "1.0.12",
4
4
  "type": "module",
5
5
  "description": "A simple template for a custom React component library",
6
6
  "devDependencies": {
@@ -36,7 +36,7 @@
36
36
  "dist",
37
37
  "src"
38
38
  ],
39
- "types": "dist/index.d.ts",
39
+ "types": "dist/es/types/index.d.ts",
40
40
  "dependencies": {
41
41
  "@emotion/is-prop-valid": "^1.2.1",
42
42
  "@emotion/react": "^11.11.1",
@@ -51,7 +51,7 @@
51
51
  "@mui/system": "^5.13.6",
52
52
  "react": "^18.2.0",
53
53
  "react-dom": "^18.2.0",
54
- "@groupeactual/design-tokens": "1.0.10"
54
+ "@groupeactual/design-tokens": "1.0.12"
55
55
  },
56
56
  "peerDependencies": {
57
57
  "@fortawesome/fontawesome-common-types": "^6.3.0",
@@ -36,7 +36,7 @@ interface AutocompleteMultipleSelectProps<T>
36
36
  onChange: (value: T[]) => void;
37
37
  defaultValue?: T[];
38
38
  color?: 'success';
39
- width?: number;
39
+ width?: number | string;
40
40
  error?: string;
41
41
  }
42
42
 
@@ -49,7 +49,7 @@ const AutocompleteMultipleSelect = <T,>({
49
49
  getKeyValue,
50
50
  onChange,
51
51
  defaultValue = [],
52
- width = 256,
52
+ width = '100%',
53
53
  color,
54
54
  helperText,
55
55
  error,
@@ -61,6 +61,10 @@ const AutocompleteMultipleSelect = <T,>({
61
61
  [theme]
62
62
  );
63
63
 
64
+ if (label && placeholder === '' && label !== placeholder) {
65
+ placeholder = label;
66
+ }
67
+
64
68
  const [value, setValue] = useState<T[]>(defaultValue ?? []);
65
69
  const [inputValue, setInputValue] = useState('');
66
70
 
@@ -32,7 +32,7 @@ interface Props<T>
32
32
  getOptionLabel: (option: T) => string;
33
33
  onChange: (value: T | null) => void;
34
34
  defaultValue?: T | null;
35
- width?: number;
35
+ width?: number | string;
36
36
  error?: string;
37
37
  }
38
38
 
@@ -44,7 +44,7 @@ const AutoCompleteSingle = <T extends {}>({
44
44
  getOptionLabel,
45
45
  onChange,
46
46
  defaultValue = null,
47
- width = 200,
47
+ width = '100%',
48
48
  color,
49
49
  helperText,
50
50
  error,
@@ -56,6 +56,10 @@ const AutoCompleteSingle = <T extends {}>({
56
56
  [theme]
57
57
  );
58
58
 
59
+ if (label && placeholder === '' && label !== placeholder) {
60
+ placeholder = label;
61
+ }
62
+
59
63
  const [value, setValue] = useState<T | null>(defaultValue);
60
64
 
61
65
  const handleValueChange = (
@@ -36,7 +36,7 @@ interface Props<T>
36
36
  getRenderValue: (option: T) => string;
37
37
  getKeyValue: (option: T) => string;
38
38
  defaultValue?: T[];
39
- width?: number;
39
+ width?: number | string;
40
40
  error?: string;
41
41
  }
42
42
 
@@ -47,7 +47,7 @@ const MultiSelect = <T extends {}>({
47
47
  error,
48
48
  placeholder,
49
49
  helperText,
50
- width = 200,
50
+ width = '100%',
51
51
  defaultValue = [],
52
52
  getRenderValue,
53
53
  getKeyValue,
@@ -61,6 +61,10 @@ const MultiSelect = <T extends {}>({
61
61
  [theme]
62
62
  );
63
63
 
64
+ if (label && placeholder === '' && label !== placeholder) {
65
+ placeholder = label;
66
+ }
67
+
64
68
  const [values, setValues] = useState(defaultValue);
65
69
 
66
70
  const handleChange = (event: SelectChangeEvent<typeof options>) => {
@@ -188,12 +192,7 @@ const MultiSelect = <T extends {}>({
188
192
  />
189
193
  )}
190
194
  MenuProps={{
191
- disableAutoFocusItem: true,
192
- PaperProps: {
193
- style: {
194
- width
195
- }
196
- }
195
+ disableAutoFocusItem: true
197
196
  }}
198
197
  {...props}
199
198
  >
@@ -30,7 +30,7 @@ interface Props<T>
30
30
  helperText?: string;
31
31
  color?: 'success';
32
32
  defaultValue?: T | undefined;
33
- width?: number;
33
+ width?: number | string;
34
34
  error?: string;
35
35
  }
36
36
 
@@ -45,7 +45,7 @@ const Select = <T extends {}>({
45
45
  getRenderValue,
46
46
  helperText,
47
47
  onBlur,
48
- width = 200,
48
+ width = '100%',
49
49
  ...props
50
50
  }: Props<T>) => {
51
51
  const theme = useTheme();
@@ -54,6 +54,10 @@ const Select = <T extends {}>({
54
54
  [theme]
55
55
  );
56
56
 
57
+ if (label && placeholder === '' && label !== placeholder) {
58
+ placeholder = label;
59
+ }
60
+
57
61
  const [value, setValue] = useState(defaultValue);
58
62
 
59
63
  const handleChange = (event: SelectChangeEvent<T>) => {
@@ -136,12 +140,7 @@ const Select = <T extends {}>({
136
140
  />
137
141
  )}
138
142
  MenuProps={{
139
- disableAutoFocusItem: true,
140
- PaperProps: {
141
- style: {
142
- width
143
- }
144
- }
143
+ disableAutoFocusItem: true
145
144
  }}
146
145
  renderValue={(value) => getRenderValue(value)}
147
146
  {...props}
@@ -23,12 +23,13 @@ interface Props extends Omit<TextFieldProps, 'error'> {
23
23
  onBlur?: FocusEventHandler<unknown>;
24
24
  onChange?: StandardInputProps['onChange'];
25
25
  label: string;
26
- value: string;
27
- name: string;
26
+ value?: string | unknown;
27
+ name?: string;
28
28
  placeholder?: string;
29
29
  disabled?: boolean;
30
30
  endAdornment?: ReactNode;
31
31
  maxLength?: number;
32
+ width?: number | string;
32
33
  }
33
34
  const TextField = ({
34
35
  name,
@@ -38,6 +39,7 @@ const TextField = ({
38
39
  onChange,
39
40
  label,
40
41
  disabled,
42
+ width = '100%',
41
43
  endAdornment,
42
44
  placeholder = '',
43
45
  maxLength,
@@ -64,6 +66,10 @@ const TextField = ({
64
66
  );
65
67
  }, [showPassword]);
66
68
 
69
+ if (label && placeholder === '' && label !== placeholder) {
70
+ placeholder = label;
71
+ }
72
+
67
73
  useEffect(() => {
68
74
  if (value !== internalValue) {
69
75
  setInternalValue(value);
@@ -100,6 +106,7 @@ const TextField = ({
100
106
  name={name}
101
107
  label={label}
102
108
  value={internalValue}
109
+ sx={{ width }}
103
110
  placeholder={label === placeholder ? '' : placeholder}
104
111
  FormHelperTextProps={{ component: 'div' } as any}
105
112
  InputLabelProps={{
@@ -144,7 +151,7 @@ const TextField = ({
144
151
  )}
145
152
  {maxLength && (
146
153
  <div style={{ display: 'table-cell', float: 'right' }}>
147
- {internalValue.length}/{maxLength} caract.
154
+ {String(internalValue).length}/{maxLength} caract.
148
155
  </div>
149
156
  )}
150
157
  </div>
@@ -19,7 +19,7 @@ interface Props extends Omit<TooltipProps, 'icon' | 'children'> {
19
19
  const Tooltip = ({ title, children, ...props }: Props) => {
20
20
  const theme = useTheme();
21
21
  const StyledTooltip = useMemo(
22
- () => styled(TooltipMui)(TooltipStyle(theme)),
22
+ () => styled(TooltipMui)(TooltipStyle()),
23
23
  [theme]
24
24
  );
25
25