@sonardigital/carbon-ui 1.2.27 → 1.2.29
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/package.json +2 -1
- package/src/components/form/fields/FormDatePicker.tsx +4 -1
- package/src/components/form/fields/FormInput.tsx +10 -1
- package/src/components/form/fields/FormMultiselect.tsx +5 -1
- package/src/components/form/fields/FormNumber.tsx +4 -1
- package/src/components/form/fields/FormPassword.tsx +4 -1
- package/src/components/form/fields/FormSelect.tsx +14 -1
- package/src/components/form/fields/FormSwitch.tsx +4 -1
- package/src/components/form/fields/FormTextArea.tsx +4 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sonardigital/carbon-ui",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.29",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"files": [
|
|
@@ -59,6 +59,7 @@
|
|
|
59
59
|
"@mui/material": "^7.3.2",
|
|
60
60
|
"@mui/x-date-pickers": "^8.12.0",
|
|
61
61
|
"@sonardigital/cli": "^1.6.4",
|
|
62
|
+
"@sonardigital/hooks": "^1.1.6",
|
|
62
63
|
"dayjs": "^1.11.18",
|
|
63
64
|
"eslint-plugin-react": "^7.34.3",
|
|
64
65
|
"eslint-plugin-storybook": "^0.8.0",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Stack } from '@mui/material';
|
|
1
|
+
import { FormHelperText, Stack } from '@mui/material';
|
|
2
2
|
import { Controller } from 'react-hook-form';
|
|
3
3
|
import { FormLabel } from '../layout';
|
|
4
4
|
import { FormError } from '../layout/FormError';
|
|
@@ -9,12 +9,14 @@ interface FormDatePickerProps extends Omit<
|
|
|
9
9
|
'value' | 'onChange'
|
|
10
10
|
> {
|
|
11
11
|
name: string;
|
|
12
|
+
helperText?: string;
|
|
12
13
|
label: string;
|
|
13
14
|
}
|
|
14
15
|
|
|
15
16
|
export function FormDatePicker({
|
|
16
17
|
name,
|
|
17
18
|
label,
|
|
19
|
+
helperText,
|
|
18
20
|
...props
|
|
19
21
|
}: FormDatePickerProps): React.ReactElement {
|
|
20
22
|
return (
|
|
@@ -27,6 +29,7 @@ export function FormDatePicker({
|
|
|
27
29
|
{fieldState.error && (
|
|
28
30
|
<FormError label={fieldState.error?.message ?? ''} />
|
|
29
31
|
)}
|
|
32
|
+
{helperText && <FormHelperText>{helperText}</FormHelperText>}
|
|
30
33
|
</Stack>
|
|
31
34
|
</FormLabel>
|
|
32
35
|
)}
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
FormHelperText,
|
|
3
|
+
Stack,
|
|
4
|
+
TextField,
|
|
5
|
+
TextFieldProps,
|
|
6
|
+
} from '@mui/material';
|
|
2
7
|
import { Controller } from 'react-hook-form';
|
|
3
8
|
import { FormLabel } from '../layout';
|
|
4
9
|
import { FormError } from '../layout/FormError';
|
|
@@ -11,6 +16,7 @@ interface FormInputProps extends TextFieldProps<'standard'> {
|
|
|
11
16
|
export function FormInput({
|
|
12
17
|
name,
|
|
13
18
|
label,
|
|
19
|
+
helperText,
|
|
14
20
|
...props
|
|
15
21
|
}: FormInputProps): React.ReactElement {
|
|
16
22
|
return (
|
|
@@ -23,6 +29,9 @@ export function FormInput({
|
|
|
23
29
|
{fieldState.error && (
|
|
24
30
|
<FormError label={fieldState.error?.message ?? ''} />
|
|
25
31
|
)}
|
|
32
|
+
{helperText && (
|
|
33
|
+
<FormHelperText>{helperText}</FormHelperText>
|
|
34
|
+
)}
|
|
26
35
|
</Stack>
|
|
27
36
|
</FormLabel>
|
|
28
37
|
)}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AutocompleteProps, Stack } from '@mui/material';
|
|
1
|
+
import { AutocompleteProps, FormHelperText, Stack } from '@mui/material';
|
|
2
2
|
import { Controller } from 'react-hook-form';
|
|
3
3
|
import { FormLabel } from '../layout';
|
|
4
4
|
import { FormError } from '../layout/FormError';
|
|
@@ -22,6 +22,7 @@ export function FormMultiselect({
|
|
|
22
22
|
name,
|
|
23
23
|
label,
|
|
24
24
|
options,
|
|
25
|
+
helperText,
|
|
25
26
|
...rest
|
|
26
27
|
}: MultiselectAutocompleteProps): React.ReactElement {
|
|
27
28
|
return (
|
|
@@ -42,6 +43,9 @@ export function FormMultiselect({
|
|
|
42
43
|
{fieldState.error && (
|
|
43
44
|
<FormError label={fieldState.error?.message ?? ''} />
|
|
44
45
|
)}
|
|
46
|
+
{helperText && (
|
|
47
|
+
<FormHelperText>{helperText}</FormHelperText>
|
|
48
|
+
)}
|
|
45
49
|
</Stack>
|
|
46
50
|
</FormLabel>
|
|
47
51
|
);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Stack } from '@mui/material';
|
|
1
|
+
import { FormHelperText, Stack } from '@mui/material';
|
|
2
2
|
import { Controller } from 'react-hook-form';
|
|
3
3
|
import { FormLabel } from '../layout';
|
|
4
4
|
import { FormError } from '../layout/FormError';
|
|
@@ -7,12 +7,14 @@ import { NumberInput } from '../../inputs/Number';
|
|
|
7
7
|
|
|
8
8
|
interface FormNumberProps extends Omit<NumberProps, 'onChange'> {
|
|
9
9
|
name: string;
|
|
10
|
+
helperText?: string;
|
|
10
11
|
label: string;
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
export function FormNumber({
|
|
14
15
|
name,
|
|
15
16
|
label,
|
|
17
|
+
helperText,
|
|
16
18
|
...props
|
|
17
19
|
}: FormNumberProps): React.ReactElement {
|
|
18
20
|
return (
|
|
@@ -25,6 +27,7 @@ export function FormNumber({
|
|
|
25
27
|
{fieldState.error && (
|
|
26
28
|
<FormError label={fieldState.error?.message ?? ''} />
|
|
27
29
|
)}
|
|
30
|
+
{helperText && <FormHelperText>{helperText}</FormHelperText>}
|
|
28
31
|
</Stack>
|
|
29
32
|
</FormLabel>
|
|
30
33
|
)}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { OutlinedInput, Stack } from '@mui/material';
|
|
1
|
+
import { FormHelperText, OutlinedInput, Stack } from '@mui/material';
|
|
2
2
|
import { Controller } from 'react-hook-form';
|
|
3
3
|
import { FormLabel } from '../layout';
|
|
4
4
|
import { FormError } from '../layout/FormError';
|
|
@@ -9,9 +9,11 @@ import { Cursor } from '../../atoms';
|
|
|
9
9
|
export function FormPassword({
|
|
10
10
|
name,
|
|
11
11
|
label,
|
|
12
|
+
helperText,
|
|
12
13
|
}: {
|
|
13
14
|
name: string;
|
|
14
15
|
label: string;
|
|
16
|
+
helperText?: string;
|
|
15
17
|
}): React.ReactElement {
|
|
16
18
|
const [isVisible, setIsVisible] = useState(false);
|
|
17
19
|
return (
|
|
@@ -48,6 +50,7 @@ export function FormPassword({
|
|
|
48
50
|
{fieldState.error && (
|
|
49
51
|
<FormError label={fieldState.error?.message ?? ''} />
|
|
50
52
|
)}
|
|
53
|
+
{helperText && <FormHelperText>{helperText}</FormHelperText>}
|
|
51
54
|
</Stack>
|
|
52
55
|
</FormLabel>
|
|
53
56
|
)}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import { AutocompleteProps, Stack } from '@mui/material';
|
|
1
|
+
import { AutocompleteProps, FormHelperText, Stack } from '@mui/material';
|
|
2
2
|
import { Controller } from 'react-hook-form';
|
|
3
3
|
import { FormLabel } from '../layout';
|
|
4
4
|
import { FormError } from '../layout/FormError';
|
|
5
5
|
import { SelectAutocomplete } from '../../inputs';
|
|
6
|
+
import { useDebounce } from '@sonardigital/hooks';
|
|
7
|
+
import { useState } from 'react';
|
|
6
8
|
|
|
7
9
|
// eslint-disable-next-line
|
|
8
10
|
interface SelectAutocompleteProps extends Omit<
|
|
@@ -16,6 +18,7 @@ interface SelectAutocompleteProps extends Omit<
|
|
|
16
18
|
> {
|
|
17
19
|
name: string;
|
|
18
20
|
label: string;
|
|
21
|
+
onDebounce?: (value: string) => void;
|
|
19
22
|
placeholder?: string;
|
|
20
23
|
options?: { label: string; value: string | number }[];
|
|
21
24
|
helperText?: string;
|
|
@@ -26,8 +29,14 @@ export function FormSelect({
|
|
|
26
29
|
name,
|
|
27
30
|
label,
|
|
28
31
|
options,
|
|
32
|
+
helperText,
|
|
33
|
+
onDebounce,
|
|
29
34
|
...rest
|
|
30
35
|
}: SelectAutocompleteProps): React.ReactElement {
|
|
36
|
+
const [search, setSearch] = useState('');
|
|
37
|
+
|
|
38
|
+
useDebounce(search, 500, onDebounce);
|
|
39
|
+
|
|
31
40
|
return (
|
|
32
41
|
<Controller
|
|
33
42
|
name={name}
|
|
@@ -41,11 +50,15 @@ export function FormSelect({
|
|
|
41
50
|
{...rest}
|
|
42
51
|
options={options}
|
|
43
52
|
value={value}
|
|
53
|
+
onInputChange={(value) => setSearch((value?.target as HTMLInputElement)?.value ?? '')}
|
|
44
54
|
onChange={onChange}
|
|
45
55
|
/>
|
|
46
56
|
{fieldState.error && (
|
|
47
57
|
<FormError label={fieldState.error?.message ?? ''} />
|
|
48
58
|
)}
|
|
59
|
+
{helperText && (
|
|
60
|
+
<FormHelperText>{helperText}</FormHelperText>
|
|
61
|
+
)}
|
|
49
62
|
</Stack>
|
|
50
63
|
</FormLabel>
|
|
51
64
|
);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Stack, SwitchProps, Typography } from '@mui/material';
|
|
1
|
+
import { FormHelperText, Stack, SwitchProps, Typography } from '@mui/material';
|
|
2
2
|
import { Controller } from 'react-hook-form';
|
|
3
3
|
import { FormError } from '../layout/FormError';
|
|
4
4
|
import { Switch } from '../../inputs/Switch';
|
|
@@ -6,11 +6,13 @@ import { Switch } from '../../inputs/Switch';
|
|
|
6
6
|
interface FormSwitchProps extends SwitchProps {
|
|
7
7
|
name: string;
|
|
8
8
|
label: string;
|
|
9
|
+
helperText?: string;
|
|
9
10
|
}
|
|
10
11
|
|
|
11
12
|
export function FormSwitch({
|
|
12
13
|
name,
|
|
13
14
|
label,
|
|
15
|
+
helperText,
|
|
14
16
|
...props
|
|
15
17
|
}: FormSwitchProps): React.ReactElement {
|
|
16
18
|
return (
|
|
@@ -38,6 +40,7 @@ export function FormSwitch({
|
|
|
38
40
|
{fieldState.error && (
|
|
39
41
|
<FormError label={fieldState.error?.message ?? ''} />
|
|
40
42
|
)}
|
|
43
|
+
{helperText && <FormHelperText>{helperText}</FormHelperText>}
|
|
41
44
|
</Stack>
|
|
42
45
|
)}
|
|
43
46
|
/>
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
+
FormHelperText,
|
|
2
3
|
Stack,
|
|
3
4
|
TextareaAutosize,
|
|
4
5
|
TextareaAutosizeProps,
|
|
@@ -11,11 +12,13 @@ import { FormError } from '../layout/FormError';
|
|
|
11
12
|
interface FormTextareaProps extends TextareaAutosizeProps {
|
|
12
13
|
name: string;
|
|
13
14
|
label: string;
|
|
15
|
+
helperText?: string;
|
|
14
16
|
}
|
|
15
17
|
|
|
16
18
|
export function FormTextarea({
|
|
17
19
|
name,
|
|
18
20
|
label,
|
|
21
|
+
helperText,
|
|
19
22
|
...props
|
|
20
23
|
}: FormTextareaProps): React.ReactElement {
|
|
21
24
|
const theme = useTheme();
|
|
@@ -37,6 +40,7 @@ export function FormTextarea({
|
|
|
37
40
|
{fieldState.error && (
|
|
38
41
|
<FormError label={fieldState.error?.message ?? ''} />
|
|
39
42
|
)}
|
|
43
|
+
{helperText && <FormHelperText>{helperText}</FormHelperText>}
|
|
40
44
|
</Stack>
|
|
41
45
|
</FormLabel>
|
|
42
46
|
)}
|