@lets-events/react 12.2.7 → 12.2.9
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 +21 -19
- package/CHANGELOG.md +12 -0
- package/dist/index.d.mts +4 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.js +18 -15
- package/dist/index.mjs +18 -15
- package/package.json +2 -2
- 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 +300 -300
- package/src/components/ButtonGroup.tsx +484 -484
- package/src/components/Calendar/index.tsx +148 -146
- package/src/components/Calendar/styledComponents.ts +250 -250
- 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 +138 -138
- package/src/components/Drawer/styledComponents.ts +52 -52
- 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/CalendarFormField.tsx +95 -92
- 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 +32 -32
- package/src/components/FormFields/MultiSelectFormField.tsx +64 -64
- package/src/components/FormFields/PhoneFormField.tsx +40 -40
- package/src/components/FormFields/RadioGroupFormField.tsx +84 -84
- package/src/components/FormFields/RichEditorFormField.tsx +102 -102
- package/src/components/FormFields/SelectFormField.tsx +93 -93
- package/src/components/FormFields/SwitchFormField.tsx +46 -46
- package/src/components/FormFields/TextAreaFormField.tsx +57 -57
- package/src/components/FormFields/TextFormField.tsx +112 -112
- package/src/components/FormFields/TimePickerFormField.tsx +88 -88
- 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/index.tsx +243 -243
- package/src/components/MultiSelect/styledComponents.ts +160 -160
- package/src/components/RadioGroup.tsx +210 -210
- package/src/components/RichEditor/QuillComponent.tsx +455 -458
- package/src/components/RichEditor/RichEditor.tsx +49 -49
- package/src/components/RichEditor/index.ts +2 -2
- package/src/components/RichEditor/styledComponents.ts +1151 -1151
- 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 +372 -372
- package/src/components/TextareaField.tsx +127 -127
- package/src/components/TimePicker.tsx +328 -328
- 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/useImageUpload.ts +139 -139
- package/src/hooks/useOnClickOutside.tsx +42 -42
- package/src/index.tsx +68 -68
- 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/src/utils/uploadService.ts +180 -180
- package/tsconfig.json +3 -3
- package/tsup.config.ts +38 -38
- package/dist/index.css +0 -171
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
import { TextFormField } from "./TextFormField";
|
|
2
|
-
|
|
3
|
-
type IdentityDocumentNumberFormFieldProps = {
|
|
4
|
-
name: string;
|
|
5
|
-
label: string;
|
|
6
|
-
required?: boolean;
|
|
7
|
-
placeholder?: string;
|
|
8
|
-
validationErrorMessage: string;
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
export const IdentityDocumentNumberFormField = ({
|
|
12
|
-
name,
|
|
13
|
-
label,
|
|
14
|
-
required,
|
|
15
|
-
placeholder,
|
|
16
|
-
validationErrorMessage,
|
|
17
|
-
}: IdentityDocumentNumberFormFieldProps) => {
|
|
18
|
-
return (
|
|
19
|
-
<TextFormField
|
|
20
|
-
name={name}
|
|
21
|
-
label={label}
|
|
22
|
-
required={required}
|
|
23
|
-
placeholder={placeholder || "__.___.___-_"}
|
|
24
|
-
validate={(value: string) => {
|
|
25
|
-
const isEmpty = value.length === 0;
|
|
26
|
-
if (!required && isEmpty) return true;
|
|
27
|
-
if (value.length >= 3) return true;
|
|
28
|
-
return false || validationErrorMessage;
|
|
29
|
-
}}
|
|
30
|
-
/>
|
|
31
|
-
);
|
|
32
|
-
};
|
|
1
|
+
import { TextFormField } from "./TextFormField";
|
|
2
|
+
|
|
3
|
+
type IdentityDocumentNumberFormFieldProps = {
|
|
4
|
+
name: string;
|
|
5
|
+
label: string;
|
|
6
|
+
required?: boolean;
|
|
7
|
+
placeholder?: string;
|
|
8
|
+
validationErrorMessage: string;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export const IdentityDocumentNumberFormField = ({
|
|
12
|
+
name,
|
|
13
|
+
label,
|
|
14
|
+
required,
|
|
15
|
+
placeholder,
|
|
16
|
+
validationErrorMessage,
|
|
17
|
+
}: IdentityDocumentNumberFormFieldProps) => {
|
|
18
|
+
return (
|
|
19
|
+
<TextFormField
|
|
20
|
+
name={name}
|
|
21
|
+
label={label}
|
|
22
|
+
required={required}
|
|
23
|
+
placeholder={placeholder || "__.___.___-_"}
|
|
24
|
+
validate={(value: string) => {
|
|
25
|
+
const isEmpty = value.length === 0;
|
|
26
|
+
if (!required && isEmpty) return true;
|
|
27
|
+
if (value.length >= 3) return true;
|
|
28
|
+
return false || validationErrorMessage;
|
|
29
|
+
}}
|
|
30
|
+
/>
|
|
31
|
+
);
|
|
32
|
+
};
|
|
@@ -1,64 +1,64 @@
|
|
|
1
|
-
import { useController } from "react-hook-form";
|
|
2
|
-
import { Flex } from "../Flex";
|
|
3
|
-
import { FormLabel } from "./subComponents/FormLabel";
|
|
4
|
-
import { ErrorFormMessage } from "./subComponents/ErrorFormMessage";
|
|
5
|
-
import { MultiSelect, MultiSelectProps } from "../MultiSelect";
|
|
6
|
-
|
|
7
|
-
export type MultiSelectFormFieldProps = MultiSelectProps & {
|
|
8
|
-
name: string;
|
|
9
|
-
label?: string;
|
|
10
|
-
required?: boolean;
|
|
11
|
-
selectedOrientation?: "row" | "column";
|
|
12
|
-
zIndex?: string;
|
|
13
|
-
maxHeight?: string;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export const MultiSelectFormField = ({
|
|
17
|
-
name,
|
|
18
|
-
label,
|
|
19
|
-
required,
|
|
20
|
-
selectedOrientation = "column",
|
|
21
|
-
zIndex,
|
|
22
|
-
maxHeight,
|
|
23
|
-
...rest
|
|
24
|
-
}: MultiSelectFormFieldProps) => {
|
|
25
|
-
const { field, fieldState } = useController({
|
|
26
|
-
name,
|
|
27
|
-
rules: {
|
|
28
|
-
required,
|
|
29
|
-
},
|
|
30
|
-
defaultValue: [],
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
const { value, onChange, ref, onBlur, disabled } = field;
|
|
34
|
-
|
|
35
|
-
const haveError = !!fieldState.error;
|
|
36
|
-
|
|
37
|
-
const errorMsg = fieldState.error?.message;
|
|
38
|
-
|
|
39
|
-
const handleChange = (v: any) => {
|
|
40
|
-
onChange(v);
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
return (
|
|
44
|
-
<Flex direction={"column"}>
|
|
45
|
-
<FormLabel
|
|
46
|
-
name={name}
|
|
47
|
-
label={label}
|
|
48
|
-
required={required}
|
|
49
|
-
haveError={haveError}
|
|
50
|
-
/>
|
|
51
|
-
<MultiSelect
|
|
52
|
-
value={value}
|
|
53
|
-
onValueChange={handleChange}
|
|
54
|
-
ref={ref}
|
|
55
|
-
color={haveError ? "error" : "default"}
|
|
56
|
-
selectedOrientation={selectedOrientation}
|
|
57
|
-
zIndex={zIndex}
|
|
58
|
-
maxHeight={maxHeight}
|
|
59
|
-
{...rest}
|
|
60
|
-
/>
|
|
61
|
-
<ErrorFormMessage message={errorMsg} />
|
|
62
|
-
</Flex>
|
|
63
|
-
);
|
|
64
|
-
};
|
|
1
|
+
import { useController } from "react-hook-form";
|
|
2
|
+
import { Flex } from "../Flex";
|
|
3
|
+
import { FormLabel } from "./subComponents/FormLabel";
|
|
4
|
+
import { ErrorFormMessage } from "./subComponents/ErrorFormMessage";
|
|
5
|
+
import { MultiSelect, MultiSelectProps } from "../MultiSelect";
|
|
6
|
+
|
|
7
|
+
export type MultiSelectFormFieldProps = MultiSelectProps & {
|
|
8
|
+
name: string;
|
|
9
|
+
label?: string;
|
|
10
|
+
required?: boolean;
|
|
11
|
+
selectedOrientation?: "row" | "column";
|
|
12
|
+
zIndex?: string;
|
|
13
|
+
maxHeight?: string;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export const MultiSelectFormField = ({
|
|
17
|
+
name,
|
|
18
|
+
label,
|
|
19
|
+
required,
|
|
20
|
+
selectedOrientation = "column",
|
|
21
|
+
zIndex,
|
|
22
|
+
maxHeight,
|
|
23
|
+
...rest
|
|
24
|
+
}: MultiSelectFormFieldProps) => {
|
|
25
|
+
const { field, fieldState } = useController({
|
|
26
|
+
name,
|
|
27
|
+
rules: {
|
|
28
|
+
required,
|
|
29
|
+
},
|
|
30
|
+
defaultValue: [],
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
const { value, onChange, ref, onBlur, disabled } = field;
|
|
34
|
+
|
|
35
|
+
const haveError = !!fieldState.error;
|
|
36
|
+
|
|
37
|
+
const errorMsg = fieldState.error?.message;
|
|
38
|
+
|
|
39
|
+
const handleChange = (v: any) => {
|
|
40
|
+
onChange(v);
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
<Flex direction={"column"}>
|
|
45
|
+
<FormLabel
|
|
46
|
+
name={name}
|
|
47
|
+
label={label}
|
|
48
|
+
required={required}
|
|
49
|
+
haveError={haveError}
|
|
50
|
+
/>
|
|
51
|
+
<MultiSelect
|
|
52
|
+
value={value}
|
|
53
|
+
onValueChange={handleChange}
|
|
54
|
+
ref={ref}
|
|
55
|
+
color={haveError ? "error" : "default"}
|
|
56
|
+
selectedOrientation={selectedOrientation}
|
|
57
|
+
zIndex={zIndex}
|
|
58
|
+
maxHeight={maxHeight}
|
|
59
|
+
{...rest}
|
|
60
|
+
/>
|
|
61
|
+
<ErrorFormMessage message={errorMsg} />
|
|
62
|
+
</Flex>
|
|
63
|
+
);
|
|
64
|
+
};
|
|
@@ -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,102 +1,102 @@
|
|
|
1
|
-
import { useController } from "react-hook-form";
|
|
2
|
-
import { Flex } from "../Flex";
|
|
3
|
-
import { FormLabel } from "./subComponents/FormLabel";
|
|
4
|
-
import { ErrorFormMessage } from "./subComponents/ErrorFormMessage";
|
|
5
|
-
import { RichEditor, RichEditorProps } from "../RichEditor";
|
|
6
|
-
import { useState } from "react";
|
|
7
|
-
import { Badge } from "../Badge";
|
|
8
|
-
|
|
9
|
-
export type RichEditorFormFieldProps = Omit<
|
|
10
|
-
RichEditorProps,
|
|
11
|
-
"value" | "onChange"
|
|
12
|
-
> & {
|
|
13
|
-
name: string;
|
|
14
|
-
label?: string;
|
|
15
|
-
required?: boolean;
|
|
16
|
-
validate?: (value: string) => boolean | string;
|
|
17
|
-
maxLength?: number;
|
|
18
|
-
validationErrorMessage?: string;
|
|
19
|
-
simpleVersion?: boolean;
|
|
20
|
-
uploadConfig: RichEditorProps["uploadConfig"];
|
|
21
|
-
disableVideo?: boolean
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export const RichEditorFormField = ({
|
|
25
|
-
name,
|
|
26
|
-
label,
|
|
27
|
-
required,
|
|
28
|
-
validate,
|
|
29
|
-
validationErrorMessage = "Este campo é obrigatório.",
|
|
30
|
-
maxLength,
|
|
31
|
-
simpleVersion = false,
|
|
32
|
-
disableVideo = false,
|
|
33
|
-
...props
|
|
34
|
-
}: RichEditorFormFieldProps) => {
|
|
35
|
-
const { field, fieldState } = useController({
|
|
36
|
-
name,
|
|
37
|
-
rules: {
|
|
38
|
-
required: required ? validationErrorMessage : false,
|
|
39
|
-
validate: (value?: string) => {
|
|
40
|
-
if (
|
|
41
|
-
value === undefined ||
|
|
42
|
-
value === null ||
|
|
43
|
-
(!required && value.trim() === "")
|
|
44
|
-
)
|
|
45
|
-
return true;
|
|
46
|
-
return validate?.(value) ?? true;
|
|
47
|
-
},
|
|
48
|
-
},
|
|
49
|
-
defaultValue: "",
|
|
50
|
-
});
|
|
51
|
-
const [caracterQuantity, setCaracterQuantity] = useState(maxLength)
|
|
52
|
-
const handleCharacterCountChange = (count: number) => {
|
|
53
|
-
if (maxLength !== undefined) {
|
|
54
|
-
setCaracterQuantity(Math.max(0, maxLength - count));
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
const fieldError = fieldState.error;
|
|
58
|
-
const haveError = !!fieldError;
|
|
59
|
-
const errorMsg = fieldError?.message;
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
return (
|
|
63
|
-
<Flex direction="column">
|
|
64
|
-
{maxLength ? (
|
|
65
|
-
<Flex direction="row" justify="between">
|
|
66
|
-
{label && (
|
|
67
|
-
<FormLabel
|
|
68
|
-
name={name}
|
|
69
|
-
label={label}
|
|
70
|
-
required={required}
|
|
71
|
-
haveError={haveError}
|
|
72
|
-
/>
|
|
73
|
-
)}
|
|
74
|
-
<Badge color="grey" size="xs">
|
|
75
|
-
{caracterQuantity}
|
|
76
|
-
</Badge>
|
|
77
|
-
</Flex>
|
|
78
|
-
) : (
|
|
79
|
-
<>
|
|
80
|
-
{label && (
|
|
81
|
-
<FormLabel
|
|
82
|
-
name={name}
|
|
83
|
-
label={label}
|
|
84
|
-
required={required}
|
|
85
|
-
haveError={haveError}
|
|
86
|
-
/>
|
|
87
|
-
)}
|
|
88
|
-
</>
|
|
89
|
-
)}
|
|
90
|
-
<RichEditor
|
|
91
|
-
{...props}
|
|
92
|
-
value={field.value}
|
|
93
|
-
onChange={field.onChange}
|
|
94
|
-
aria-labelledby={`${name}-label`}
|
|
95
|
-
onCharacterCountChange={handleCharacterCountChange}
|
|
96
|
-
maxLength={maxLength}
|
|
97
|
-
disableVideo={disableVideo}
|
|
98
|
-
/>
|
|
99
|
-
<ErrorFormMessage message={errorMsg} />
|
|
100
|
-
</Flex>
|
|
101
|
-
);
|
|
102
|
-
};
|
|
1
|
+
import { useController } from "react-hook-form";
|
|
2
|
+
import { Flex } from "../Flex";
|
|
3
|
+
import { FormLabel } from "./subComponents/FormLabel";
|
|
4
|
+
import { ErrorFormMessage } from "./subComponents/ErrorFormMessage";
|
|
5
|
+
import { RichEditor, RichEditorProps } from "../RichEditor";
|
|
6
|
+
import { useState } from "react";
|
|
7
|
+
import { Badge } from "../Badge";
|
|
8
|
+
|
|
9
|
+
export type RichEditorFormFieldProps = Omit<
|
|
10
|
+
RichEditorProps,
|
|
11
|
+
"value" | "onChange"
|
|
12
|
+
> & {
|
|
13
|
+
name: string;
|
|
14
|
+
label?: string;
|
|
15
|
+
required?: boolean;
|
|
16
|
+
validate?: (value: string) => boolean | string;
|
|
17
|
+
maxLength?: number;
|
|
18
|
+
validationErrorMessage?: string;
|
|
19
|
+
simpleVersion?: boolean;
|
|
20
|
+
uploadConfig: RichEditorProps["uploadConfig"];
|
|
21
|
+
disableVideo?: boolean
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export const RichEditorFormField = ({
|
|
25
|
+
name,
|
|
26
|
+
label,
|
|
27
|
+
required,
|
|
28
|
+
validate,
|
|
29
|
+
validationErrorMessage = "Este campo é obrigatório.",
|
|
30
|
+
maxLength,
|
|
31
|
+
simpleVersion = false,
|
|
32
|
+
disableVideo = false,
|
|
33
|
+
...props
|
|
34
|
+
}: RichEditorFormFieldProps) => {
|
|
35
|
+
const { field, fieldState } = useController({
|
|
36
|
+
name,
|
|
37
|
+
rules: {
|
|
38
|
+
required: required ? validationErrorMessage : false,
|
|
39
|
+
validate: (value?: string) => {
|
|
40
|
+
if (
|
|
41
|
+
value === undefined ||
|
|
42
|
+
value === null ||
|
|
43
|
+
(!required && value.trim() === "")
|
|
44
|
+
)
|
|
45
|
+
return true;
|
|
46
|
+
return validate?.(value) ?? true;
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
defaultValue: "",
|
|
50
|
+
});
|
|
51
|
+
const [caracterQuantity, setCaracterQuantity] = useState(maxLength)
|
|
52
|
+
const handleCharacterCountChange = (count: number) => {
|
|
53
|
+
if (maxLength !== undefined) {
|
|
54
|
+
setCaracterQuantity(Math.max(0, maxLength - count));
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
const fieldError = fieldState.error;
|
|
58
|
+
const haveError = !!fieldError;
|
|
59
|
+
const errorMsg = fieldError?.message;
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
return (
|
|
63
|
+
<Flex direction="column">
|
|
64
|
+
{maxLength ? (
|
|
65
|
+
<Flex direction="row" justify="between">
|
|
66
|
+
{label && (
|
|
67
|
+
<FormLabel
|
|
68
|
+
name={name}
|
|
69
|
+
label={label}
|
|
70
|
+
required={required}
|
|
71
|
+
haveError={haveError}
|
|
72
|
+
/>
|
|
73
|
+
)}
|
|
74
|
+
<Badge color="grey" size="xs">
|
|
75
|
+
{caracterQuantity}
|
|
76
|
+
</Badge>
|
|
77
|
+
</Flex>
|
|
78
|
+
) : (
|
|
79
|
+
<>
|
|
80
|
+
{label && (
|
|
81
|
+
<FormLabel
|
|
82
|
+
name={name}
|
|
83
|
+
label={label}
|
|
84
|
+
required={required}
|
|
85
|
+
haveError={haveError}
|
|
86
|
+
/>
|
|
87
|
+
)}
|
|
88
|
+
</>
|
|
89
|
+
)}
|
|
90
|
+
<RichEditor
|
|
91
|
+
{...props}
|
|
92
|
+
value={field.value}
|
|
93
|
+
onChange={field.onChange}
|
|
94
|
+
aria-labelledby={`${name}-label`}
|
|
95
|
+
onCharacterCountChange={handleCharacterCountChange}
|
|
96
|
+
maxLength={maxLength}
|
|
97
|
+
disableVideo={disableVideo}
|
|
98
|
+
/>
|
|
99
|
+
<ErrorFormMessage message={errorMsg} />
|
|
100
|
+
</Flex>
|
|
101
|
+
);
|
|
102
|
+
};
|