@lets-events/react 11.7.10 → 11.8.0
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/.eslintrc.json +2 -2
- package/.turbo/turbo-build.log +18 -20
- package/CHANGELOG.md +3 -3
- package/dist/index.css +171 -0
- package/dist/index.d.mts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +104 -76
- package/dist/index.mjs +110 -82
- package/package.json +1 -1
- package/src/components/Alert.tsx +303 -303
- package/src/components/Avatar.tsx +55 -55
- package/src/components/Badge.tsx +125 -125
- package/src/components/Box.tsx +3 -3
- package/src/components/Button/index.tsx +16 -16
- package/src/components/Button/styledComponents.ts +287 -287
- package/src/components/ButtonGroup.tsx +484 -484
- package/src/components/Calendar/index.tsx +136 -136
- package/src/components/Calendar/styledComponents.ts +209 -209
- package/src/components/Card.tsx +48 -48
- package/src/components/CheckboxGroup.tsx +176 -176
- package/src/components/Container.tsx +39 -39
- package/src/components/Drawer/index.tsx +55 -55
- package/src/components/Drawer/styledComponents.ts +46 -46
- package/src/components/Dropdown.tsx +302 -302
- package/src/components/Filter.tsx +164 -164
- package/src/components/Flex.tsx +118 -118
- package/src/components/FormFields/AddressFormFields/CityFormField.tsx +111 -111
- package/src/components/FormFields/AddressFormFields/CountryFormField.tsx +33 -33
- package/src/components/FormFields/AddressFormFields/PostalCodeFormField.tsx +39 -39
- package/src/components/FormFields/AddressFormFields/StateFormField.tsx +32 -32
- package/src/components/FormFields/AddressFormFields/index.tsx +141 -141
- package/src/components/FormFields/BirthDateFormField.tsx +84 -84
- package/src/components/FormFields/CNPJFormField.tsx +87 -87
- package/src/components/FormFields/CPFFormField.tsx +78 -78
- package/src/components/FormFields/CheckboxGroupFormField.tsx +91 -91
- package/src/components/FormFields/EmailFormField.tsx +27 -27
- package/src/components/FormFields/Form.tsx +39 -39
- package/src/components/FormFields/IdentityDocumentNumberFormField.tsx +40 -40
- package/src/components/FormFields/MultiSelectFormField.tsx +55 -55
- package/src/components/FormFields/PhoneFormField.tsx +40 -40
- package/src/components/FormFields/RadioGroupFormField.tsx +84 -84
- package/src/components/FormFields/SelectFormField.tsx +93 -93
- package/src/components/FormFields/TextAreaFormField.tsx +48 -48
- package/src/components/FormFields/TextFormField.tsx +112 -112
- package/src/components/FormFields/subComponents/ErrorFormMessage.tsx +36 -36
- package/src/components/FormFields/subComponents/FormLabel.tsx +29 -29
- package/src/components/FormFields/utils/validation.ts +23 -23
- package/src/components/Grid.tsx +137 -137
- package/src/components/Icon.tsx +47 -47
- package/src/components/MenuDropdown/index.tsx +38 -38
- package/src/components/MenuDropdown/styledComponents.ts +31 -31
- package/src/components/Modal.tsx +90 -90
- package/src/components/MultiSelect.tsx +252 -218
- package/src/components/RadioGroup.tsx +210 -210
- package/src/components/Section.tsx +33 -33
- package/src/components/Step.tsx +164 -164
- package/src/components/Switch.tsx +108 -108
- package/src/components/Text.tsx +38 -38
- package/src/components/TextField.tsx +365 -365
- package/src/components/TextareaField.tsx +128 -128
- package/src/components/TimePicker.tsx +298 -298
- package/src/components/Toast/components/ToastItem.tsx +41 -41
- package/src/components/Toast/components/ToastProvider.tsx +63 -63
- package/src/components/Toast/hooks/useToast.ts +12 -12
- package/src/components/Toast/index.tsx +5 -5
- package/src/components/Toast/styles/index.ts +135 -135
- package/src/components/Toast/types/index.ts +46 -46
- package/src/components/Tooltip/index.tsx +66 -66
- package/src/components/Tooltip/styles.ts +77 -77
- package/src/hooks/useCountries.ts +41 -41
- package/src/hooks/useOnClickOutside.tsx +20 -20
- package/src/index.tsx +54 -54
- package/src/styles/index.ts +38 -38
- package/src/types/typographyValues.ts +178 -178
- package/src/utils/getNestedValue.ts +3 -3
- package/src/utils/states.ts +29 -29
- package/tsconfig.json +3 -3
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
import { TextFormField } from "./TextFormField";
|
|
2
|
-
import { minMaxLength } from "./utils/validation";
|
|
3
|
-
|
|
4
|
-
export type PhoneFormFieldProps = {
|
|
5
|
-
name: string;
|
|
6
|
-
label?: string;
|
|
7
|
-
required?: boolean;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
export const PhoneFormField = ({
|
|
11
|
-
name,
|
|
12
|
-
label,
|
|
13
|
-
required,
|
|
14
|
-
}: PhoneFormFieldProps) => {
|
|
15
|
-
return (
|
|
16
|
-
<TextFormField
|
|
17
|
-
name={name}
|
|
18
|
-
label={label}
|
|
19
|
-
required={required}
|
|
20
|
-
addon={"+ 55"}
|
|
21
|
-
mask={{
|
|
22
|
-
mask: "(__) _____-____}",
|
|
23
|
-
replacement: { _: /\d/ },
|
|
24
|
-
}}
|
|
25
|
-
placeholder="(00) 00000-0000"
|
|
26
|
-
type="tel"
|
|
27
|
-
validate={minMaxLength(13, 14, "Telefone inválido")}
|
|
28
|
-
valueFormatter={{
|
|
29
|
-
format(v) {
|
|
30
|
-
if (!v || v === "") return v;
|
|
31
|
-
return v.replace(/^\+55/, "");
|
|
32
|
-
},
|
|
33
|
-
unformat(v) {
|
|
34
|
-
if (!v || v === "") return v;
|
|
35
|
-
return "+55" + v;
|
|
36
|
-
},
|
|
37
|
-
}}
|
|
38
|
-
/>
|
|
39
|
-
);
|
|
40
|
-
};
|
|
1
|
+
import { TextFormField } from "./TextFormField";
|
|
2
|
+
import { minMaxLength } from "./utils/validation";
|
|
3
|
+
|
|
4
|
+
export type PhoneFormFieldProps = {
|
|
5
|
+
name: string;
|
|
6
|
+
label?: string;
|
|
7
|
+
required?: boolean;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export const PhoneFormField = ({
|
|
11
|
+
name,
|
|
12
|
+
label,
|
|
13
|
+
required,
|
|
14
|
+
}: PhoneFormFieldProps) => {
|
|
15
|
+
return (
|
|
16
|
+
<TextFormField
|
|
17
|
+
name={name}
|
|
18
|
+
label={label}
|
|
19
|
+
required={required}
|
|
20
|
+
addon={"+ 55"}
|
|
21
|
+
mask={{
|
|
22
|
+
mask: "(__) _____-____}",
|
|
23
|
+
replacement: { _: /\d/ },
|
|
24
|
+
}}
|
|
25
|
+
placeholder="(00) 00000-0000"
|
|
26
|
+
type="tel"
|
|
27
|
+
validate={minMaxLength(13, 14, "Telefone inválido")}
|
|
28
|
+
valueFormatter={{
|
|
29
|
+
format(v) {
|
|
30
|
+
if (!v || v === "") return v;
|
|
31
|
+
return v.replace(/^\+55/, "");
|
|
32
|
+
},
|
|
33
|
+
unformat(v) {
|
|
34
|
+
if (!v || v === "") return v;
|
|
35
|
+
return "+55" + v;
|
|
36
|
+
},
|
|
37
|
+
}}
|
|
38
|
+
/>
|
|
39
|
+
);
|
|
40
|
+
};
|
|
@@ -1,84 +1,84 @@
|
|
|
1
|
-
import { Controller, useFormContext } from "react-hook-form";
|
|
2
|
-
import { Flex } from "../Flex";
|
|
3
|
-
import { FormLabel } from "./subComponents/FormLabel";
|
|
4
|
-
import { ErrorFormMessage } from "./subComponents/ErrorFormMessage";
|
|
5
|
-
import { RadioGroup, RadioItem } from "../RadioGroup";
|
|
6
|
-
import { getNestedValue } from "../../utils/getNestedValue";
|
|
7
|
-
|
|
8
|
-
type Option = {
|
|
9
|
-
label: string;
|
|
10
|
-
value: string;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export type RadioGroupFormFieldProps = {
|
|
14
|
-
name: string;
|
|
15
|
-
label: string;
|
|
16
|
-
options: Option[];
|
|
17
|
-
required?: boolean;
|
|
18
|
-
defaultValue?: string;
|
|
19
|
-
validationErrorMessage?: string;
|
|
20
|
-
color?: "blue" | "success" | "error";
|
|
21
|
-
fontWeight?: "regular" | "medium" | "semibold" | "bold";
|
|
22
|
-
disabled?: boolean;
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
export const RadioGroupFormField = ({
|
|
26
|
-
name,
|
|
27
|
-
label,
|
|
28
|
-
options,
|
|
29
|
-
required,
|
|
30
|
-
defaultValue,
|
|
31
|
-
validationErrorMessage = "Este campo é obrigatório.",
|
|
32
|
-
color = "blue",
|
|
33
|
-
fontWeight = "regular",
|
|
34
|
-
disabled = false,
|
|
35
|
-
}: RadioGroupFormFieldProps) => {
|
|
36
|
-
const {
|
|
37
|
-
control,
|
|
38
|
-
formState: { errors },
|
|
39
|
-
} = useFormContext();
|
|
40
|
-
|
|
41
|
-
const fieldError = getNestedValue(errors, name);
|
|
42
|
-
const haveError = !!fieldError;
|
|
43
|
-
const errorMsg = fieldError?.message;
|
|
44
|
-
|
|
45
|
-
const validationRules = {
|
|
46
|
-
required: required ? validationErrorMessage : false,
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
return (
|
|
50
|
-
<Flex direction="column">
|
|
51
|
-
<FormLabel
|
|
52
|
-
name={name}
|
|
53
|
-
label={label}
|
|
54
|
-
required={required}
|
|
55
|
-
haveError={haveError}
|
|
56
|
-
/>
|
|
57
|
-
|
|
58
|
-
<Controller
|
|
59
|
-
name={name}
|
|
60
|
-
control={control}
|
|
61
|
-
defaultValue={defaultValue || ""}
|
|
62
|
-
rules={validationRules}
|
|
63
|
-
render={({ field: { value, onChange } }) => (
|
|
64
|
-
<RadioGroup
|
|
65
|
-
value={value}
|
|
66
|
-
onValueChange={onChange}
|
|
67
|
-
color={haveError ? "error" : color}
|
|
68
|
-
fontWeight={fontWeight}
|
|
69
|
-
disabled={disabled}
|
|
70
|
-
>
|
|
71
|
-
{options.map((option) => (
|
|
72
|
-
<label key={option.value}>
|
|
73
|
-
<RadioItem value={option.value} />
|
|
74
|
-
{option.label}
|
|
75
|
-
</label>
|
|
76
|
-
))}
|
|
77
|
-
</RadioGroup>
|
|
78
|
-
)}
|
|
79
|
-
/>
|
|
80
|
-
|
|
81
|
-
<ErrorFormMessage message={errorMsg} />
|
|
82
|
-
</Flex>
|
|
83
|
-
);
|
|
84
|
-
};
|
|
1
|
+
import { Controller, useFormContext } from "react-hook-form";
|
|
2
|
+
import { Flex } from "../Flex";
|
|
3
|
+
import { FormLabel } from "./subComponents/FormLabel";
|
|
4
|
+
import { ErrorFormMessage } from "./subComponents/ErrorFormMessage";
|
|
5
|
+
import { RadioGroup, RadioItem } from "../RadioGroup";
|
|
6
|
+
import { getNestedValue } from "../../utils/getNestedValue";
|
|
7
|
+
|
|
8
|
+
type Option = {
|
|
9
|
+
label: string;
|
|
10
|
+
value: string;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export type RadioGroupFormFieldProps = {
|
|
14
|
+
name: string;
|
|
15
|
+
label: string;
|
|
16
|
+
options: Option[];
|
|
17
|
+
required?: boolean;
|
|
18
|
+
defaultValue?: string;
|
|
19
|
+
validationErrorMessage?: string;
|
|
20
|
+
color?: "blue" | "success" | "error";
|
|
21
|
+
fontWeight?: "regular" | "medium" | "semibold" | "bold";
|
|
22
|
+
disabled?: boolean;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export const RadioGroupFormField = ({
|
|
26
|
+
name,
|
|
27
|
+
label,
|
|
28
|
+
options,
|
|
29
|
+
required,
|
|
30
|
+
defaultValue,
|
|
31
|
+
validationErrorMessage = "Este campo é obrigatório.",
|
|
32
|
+
color = "blue",
|
|
33
|
+
fontWeight = "regular",
|
|
34
|
+
disabled = false,
|
|
35
|
+
}: RadioGroupFormFieldProps) => {
|
|
36
|
+
const {
|
|
37
|
+
control,
|
|
38
|
+
formState: { errors },
|
|
39
|
+
} = useFormContext();
|
|
40
|
+
|
|
41
|
+
const fieldError = getNestedValue(errors, name);
|
|
42
|
+
const haveError = !!fieldError;
|
|
43
|
+
const errorMsg = fieldError?.message;
|
|
44
|
+
|
|
45
|
+
const validationRules = {
|
|
46
|
+
required: required ? validationErrorMessage : false,
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
return (
|
|
50
|
+
<Flex direction="column">
|
|
51
|
+
<FormLabel
|
|
52
|
+
name={name}
|
|
53
|
+
label={label}
|
|
54
|
+
required={required}
|
|
55
|
+
haveError={haveError}
|
|
56
|
+
/>
|
|
57
|
+
|
|
58
|
+
<Controller
|
|
59
|
+
name={name}
|
|
60
|
+
control={control}
|
|
61
|
+
defaultValue={defaultValue || ""}
|
|
62
|
+
rules={validationRules}
|
|
63
|
+
render={({ field: { value, onChange } }) => (
|
|
64
|
+
<RadioGroup
|
|
65
|
+
value={value}
|
|
66
|
+
onValueChange={onChange}
|
|
67
|
+
color={haveError ? "error" : color}
|
|
68
|
+
fontWeight={fontWeight}
|
|
69
|
+
disabled={disabled}
|
|
70
|
+
>
|
|
71
|
+
{options.map((option) => (
|
|
72
|
+
<label key={option.value}>
|
|
73
|
+
<RadioItem value={option.value} />
|
|
74
|
+
{option.label}
|
|
75
|
+
</label>
|
|
76
|
+
))}
|
|
77
|
+
</RadioGroup>
|
|
78
|
+
)}
|
|
79
|
+
/>
|
|
80
|
+
|
|
81
|
+
<ErrorFormMessage message={errorMsg} />
|
|
82
|
+
</Flex>
|
|
83
|
+
);
|
|
84
|
+
};
|
|
@@ -1,93 +1,93 @@
|
|
|
1
|
-
import { useFormContext, Controller } from "react-hook-form";
|
|
2
|
-
import { DropdownMenu, DropdownMenuItem } from "../Dropdown";
|
|
3
|
-
import { Flex } from "../Flex";
|
|
4
|
-
import { FormLabel } from "./subComponents/FormLabel";
|
|
5
|
-
import { ErrorFormMessage } from "./subComponents/ErrorFormMessage";
|
|
6
|
-
import { getNestedValue } from "../../utils/getNestedValue";
|
|
7
|
-
|
|
8
|
-
type Option = {
|
|
9
|
-
label: string;
|
|
10
|
-
value: string;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export type SelectFormFieldProps = {
|
|
14
|
-
name: string;
|
|
15
|
-
label: string;
|
|
16
|
-
required?: boolean;
|
|
17
|
-
placeholder?: string;
|
|
18
|
-
options: Option[];
|
|
19
|
-
validation?: {
|
|
20
|
-
validate?: (value: string) => boolean | string;
|
|
21
|
-
};
|
|
22
|
-
validationErrorMessage?: string;
|
|
23
|
-
defaultValue?: string;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
export const SelectFormField = ({
|
|
27
|
-
name,
|
|
28
|
-
label,
|
|
29
|
-
required,
|
|
30
|
-
placeholder = "Selecione",
|
|
31
|
-
options,
|
|
32
|
-
validation,
|
|
33
|
-
validationErrorMessage = "Este campo é obrigatório.",
|
|
34
|
-
defaultValue,
|
|
35
|
-
}: SelectFormFieldProps) => {
|
|
36
|
-
const {
|
|
37
|
-
control,
|
|
38
|
-
formState: { errors },
|
|
39
|
-
} = useFormContext();
|
|
40
|
-
|
|
41
|
-
const fieldError = getNestedValue(errors, name);
|
|
42
|
-
const haveError = !!fieldError;
|
|
43
|
-
const errorMsg = fieldError?.message;
|
|
44
|
-
|
|
45
|
-
const validationRules = {
|
|
46
|
-
required: required ? validationErrorMessage : false,
|
|
47
|
-
...validation,
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
return (
|
|
51
|
-
<Flex direction="column">
|
|
52
|
-
<FormLabel
|
|
53
|
-
name={name}
|
|
54
|
-
label={label}
|
|
55
|
-
required={required}
|
|
56
|
-
haveError={haveError}
|
|
57
|
-
/>
|
|
58
|
-
|
|
59
|
-
<Controller
|
|
60
|
-
control={control}
|
|
61
|
-
name={name}
|
|
62
|
-
rules={validationRules}
|
|
63
|
-
defaultValue={defaultValue || ""}
|
|
64
|
-
render={({ field: { value, onChange } }) => {
|
|
65
|
-
const selectedOption = options.find((opt) => opt.value === value);
|
|
66
|
-
|
|
67
|
-
return (
|
|
68
|
-
<DropdownMenu
|
|
69
|
-
placeholder={selectedOption?.label || placeholder}
|
|
70
|
-
fontWeight="regular"
|
|
71
|
-
typography="labelLarge"
|
|
72
|
-
color={haveError ? "error" : "default"}
|
|
73
|
-
>
|
|
74
|
-
{options.map((option, index) => (
|
|
75
|
-
<DropdownMenuItem
|
|
76
|
-
key={`${option.value}${index}`}
|
|
77
|
-
value={option.value}
|
|
78
|
-
onSelect={() => onChange(option.value)}
|
|
79
|
-
fontWeight="regular"
|
|
80
|
-
typography="labelLarge"
|
|
81
|
-
>
|
|
82
|
-
{option.label}
|
|
83
|
-
</DropdownMenuItem>
|
|
84
|
-
))}
|
|
85
|
-
</DropdownMenu>
|
|
86
|
-
);
|
|
87
|
-
}}
|
|
88
|
-
/>
|
|
89
|
-
|
|
90
|
-
<ErrorFormMessage message={errorMsg} />
|
|
91
|
-
</Flex>
|
|
92
|
-
);
|
|
93
|
-
};
|
|
1
|
+
import { useFormContext, Controller } from "react-hook-form";
|
|
2
|
+
import { DropdownMenu, DropdownMenuItem } from "../Dropdown";
|
|
3
|
+
import { Flex } from "../Flex";
|
|
4
|
+
import { FormLabel } from "./subComponents/FormLabel";
|
|
5
|
+
import { ErrorFormMessage } from "./subComponents/ErrorFormMessage";
|
|
6
|
+
import { getNestedValue } from "../../utils/getNestedValue";
|
|
7
|
+
|
|
8
|
+
type Option = {
|
|
9
|
+
label: string;
|
|
10
|
+
value: string;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export type SelectFormFieldProps = {
|
|
14
|
+
name: string;
|
|
15
|
+
label: string;
|
|
16
|
+
required?: boolean;
|
|
17
|
+
placeholder?: string;
|
|
18
|
+
options: Option[];
|
|
19
|
+
validation?: {
|
|
20
|
+
validate?: (value: string) => boolean | string;
|
|
21
|
+
};
|
|
22
|
+
validationErrorMessage?: string;
|
|
23
|
+
defaultValue?: string;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export const SelectFormField = ({
|
|
27
|
+
name,
|
|
28
|
+
label,
|
|
29
|
+
required,
|
|
30
|
+
placeholder = "Selecione",
|
|
31
|
+
options,
|
|
32
|
+
validation,
|
|
33
|
+
validationErrorMessage = "Este campo é obrigatório.",
|
|
34
|
+
defaultValue,
|
|
35
|
+
}: SelectFormFieldProps) => {
|
|
36
|
+
const {
|
|
37
|
+
control,
|
|
38
|
+
formState: { errors },
|
|
39
|
+
} = useFormContext();
|
|
40
|
+
|
|
41
|
+
const fieldError = getNestedValue(errors, name);
|
|
42
|
+
const haveError = !!fieldError;
|
|
43
|
+
const errorMsg = fieldError?.message;
|
|
44
|
+
|
|
45
|
+
const validationRules = {
|
|
46
|
+
required: required ? validationErrorMessage : false,
|
|
47
|
+
...validation,
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
return (
|
|
51
|
+
<Flex direction="column">
|
|
52
|
+
<FormLabel
|
|
53
|
+
name={name}
|
|
54
|
+
label={label}
|
|
55
|
+
required={required}
|
|
56
|
+
haveError={haveError}
|
|
57
|
+
/>
|
|
58
|
+
|
|
59
|
+
<Controller
|
|
60
|
+
control={control}
|
|
61
|
+
name={name}
|
|
62
|
+
rules={validationRules}
|
|
63
|
+
defaultValue={defaultValue || ""}
|
|
64
|
+
render={({ field: { value, onChange } }) => {
|
|
65
|
+
const selectedOption = options.find((opt) => opt.value === value);
|
|
66
|
+
|
|
67
|
+
return (
|
|
68
|
+
<DropdownMenu
|
|
69
|
+
placeholder={selectedOption?.label || placeholder}
|
|
70
|
+
fontWeight="regular"
|
|
71
|
+
typography="labelLarge"
|
|
72
|
+
color={haveError ? "error" : "default"}
|
|
73
|
+
>
|
|
74
|
+
{options.map((option, index) => (
|
|
75
|
+
<DropdownMenuItem
|
|
76
|
+
key={`${option.value}${index}`}
|
|
77
|
+
value={option.value}
|
|
78
|
+
onSelect={() => onChange(option.value)}
|
|
79
|
+
fontWeight="regular"
|
|
80
|
+
typography="labelLarge"
|
|
81
|
+
>
|
|
82
|
+
{option.label}
|
|
83
|
+
</DropdownMenuItem>
|
|
84
|
+
))}
|
|
85
|
+
</DropdownMenu>
|
|
86
|
+
);
|
|
87
|
+
}}
|
|
88
|
+
/>
|
|
89
|
+
|
|
90
|
+
<ErrorFormMessage message={errorMsg} />
|
|
91
|
+
</Flex>
|
|
92
|
+
);
|
|
93
|
+
};
|
|
@@ -1,48 +1,48 @@
|
|
|
1
|
-
import { useFormContext } from "react-hook-form";
|
|
2
|
-
import { Flex } from "../Flex";
|
|
3
|
-
import { FormLabel } from "./subComponents/FormLabel";
|
|
4
|
-
import { ErrorFormMessage } from "./subComponents/ErrorFormMessage";
|
|
5
|
-
import { TextareaField, TextareaFieldProps } from "../TextareaField";
|
|
6
|
-
|
|
7
|
-
export type TextAreaFormFieldProps = TextareaFieldProps & {
|
|
8
|
-
name: string;
|
|
9
|
-
label?: string;
|
|
10
|
-
required?: boolean;
|
|
11
|
-
placeholder?: string;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export const TextAreaFormField = ({
|
|
15
|
-
name,
|
|
16
|
-
label,
|
|
17
|
-
required,
|
|
18
|
-
placeholder,
|
|
19
|
-
...props
|
|
20
|
-
}: TextAreaFormFieldProps) => {
|
|
21
|
-
const {
|
|
22
|
-
register,
|
|
23
|
-
formState: { errors },
|
|
24
|
-
} = useFormContext();
|
|
25
|
-
|
|
26
|
-
const haveError = !!errors[name];
|
|
27
|
-
|
|
28
|
-
const errorMsg = errors[name]?.message;
|
|
29
|
-
|
|
30
|
-
return (
|
|
31
|
-
<Flex direction={"column"}>
|
|
32
|
-
<FormLabel
|
|
33
|
-
name={name}
|
|
34
|
-
label={label}
|
|
35
|
-
required={required}
|
|
36
|
-
haveError={haveError}
|
|
37
|
-
/>
|
|
38
|
-
<TextareaField
|
|
39
|
-
{...props}
|
|
40
|
-
{...register(name, { required })}
|
|
41
|
-
placeholder={placeholder}
|
|
42
|
-
color={haveError ? "error" : "default"}
|
|
43
|
-
aria-labelledby={`${name}-label`}
|
|
44
|
-
/>
|
|
45
|
-
<ErrorFormMessage message={errorMsg} />
|
|
46
|
-
</Flex>
|
|
47
|
-
);
|
|
48
|
-
};
|
|
1
|
+
import { useFormContext } from "react-hook-form";
|
|
2
|
+
import { Flex } from "../Flex";
|
|
3
|
+
import { FormLabel } from "./subComponents/FormLabel";
|
|
4
|
+
import { ErrorFormMessage } from "./subComponents/ErrorFormMessage";
|
|
5
|
+
import { TextareaField, TextareaFieldProps } from "../TextareaField";
|
|
6
|
+
|
|
7
|
+
export type TextAreaFormFieldProps = TextareaFieldProps & {
|
|
8
|
+
name: string;
|
|
9
|
+
label?: string;
|
|
10
|
+
required?: boolean;
|
|
11
|
+
placeholder?: string;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export const TextAreaFormField = ({
|
|
15
|
+
name,
|
|
16
|
+
label,
|
|
17
|
+
required,
|
|
18
|
+
placeholder,
|
|
19
|
+
...props
|
|
20
|
+
}: TextAreaFormFieldProps) => {
|
|
21
|
+
const {
|
|
22
|
+
register,
|
|
23
|
+
formState: { errors },
|
|
24
|
+
} = useFormContext();
|
|
25
|
+
|
|
26
|
+
const haveError = !!errors[name];
|
|
27
|
+
|
|
28
|
+
const errorMsg = errors[name]?.message;
|
|
29
|
+
|
|
30
|
+
return (
|
|
31
|
+
<Flex direction={"column"}>
|
|
32
|
+
<FormLabel
|
|
33
|
+
name={name}
|
|
34
|
+
label={label}
|
|
35
|
+
required={required}
|
|
36
|
+
haveError={haveError}
|
|
37
|
+
/>
|
|
38
|
+
<TextareaField
|
|
39
|
+
{...props}
|
|
40
|
+
{...register(name, { required })}
|
|
41
|
+
placeholder={placeholder}
|
|
42
|
+
color={haveError ? "error" : "default"}
|
|
43
|
+
aria-labelledby={`${name}-label`}
|
|
44
|
+
/>
|
|
45
|
+
<ErrorFormMessage message={errorMsg} />
|
|
46
|
+
</Flex>
|
|
47
|
+
);
|
|
48
|
+
};
|