@lets-events/react 11.6.5 → 11.7.1
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 +12 -0
- package/dist/index.css +171 -0
- package/dist/index.d.mts +17 -13
- package/dist/index.d.ts +17 -13
- package/dist/index.js +230 -188
- package/dist/index.mjs +234 -191
- package/package.json +1 -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 +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 +48 -48
- 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 -45
- package/src/components/FormFields/AddressFormFields/StateFormField.tsx +32 -32
- package/src/components/FormFields/AddressFormFields/index.tsx +141 -139
- package/src/components/FormFields/BirthDateFormField.tsx +85 -87
- package/src/components/FormFields/CNPJFormField.tsx +87 -89
- package/src/components/FormFields/CPFFormField.tsx +77 -79
- package/src/components/FormFields/CheckboxGroupFormField.tsx +90 -90
- package/src/components/FormFields/EmailFormField.tsx +25 -0
- package/src/components/FormFields/Form.tsx +31 -29
- package/src/components/FormFields/IdentityDocumentNumberFormField.tsx +40 -42
- package/src/components/FormFields/MultiSelectFormField.tsx +55 -59
- package/src/components/FormFields/PhoneFormField.tsx +40 -130
- 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 +107 -76
- package/src/components/FormFields/{ErrorFormMessage.tsx → subComponents/ErrorFormMessage.tsx} +36 -36
- package/src/components/FormFields/{FormLabel.tsx → subComponents/FormLabel.tsx} +29 -29
- package/src/components/FormFields/utils/validation.ts +23 -0
- package/src/components/Grid.tsx +137 -137
- package/src/components/Icon.tsx +47 -47
- package/src/components/MenuDropdown/index.tsx +30 -30
- package/src/components/MenuDropdown/styledComponents.ts +31 -31
- package/src/components/Modal.tsx +90 -90
- package/src/components/MultiSelect.tsx +218 -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 +316 -312
- 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 +55 -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
package/dist/index.js
CHANGED
|
@@ -1066,6 +1066,7 @@ __export(index_exports, {
|
|
|
1066
1066
|
Drawer: () => Drawer,
|
|
1067
1067
|
DropdownMenu: () => DropdownMenu2,
|
|
1068
1068
|
DropdownMenuItem: () => DropdownMenuItem,
|
|
1069
|
+
EmailFormField: () => EmailFormField,
|
|
1069
1070
|
ErrorFormMessage: () => ErrorFormMessage,
|
|
1070
1071
|
Filter: () => Filter,
|
|
1071
1072
|
FilterItem: () => FilterItem,
|
|
@@ -2761,7 +2762,10 @@ var TextFieldStyled = styled(import_themes7.TextField.Root, {
|
|
|
2761
2762
|
}
|
|
2762
2763
|
}
|
|
2763
2764
|
}
|
|
2764
|
-
]
|
|
2765
|
+
],
|
|
2766
|
+
defaultVariants: {
|
|
2767
|
+
typography: "labelSmall"
|
|
2768
|
+
}
|
|
2765
2769
|
});
|
|
2766
2770
|
var TextFieldSlotStyled = styled(import_themes7.TextField.Slot, {
|
|
2767
2771
|
display: "flex",
|
|
@@ -2796,7 +2800,17 @@ var InputAddon = styled(TextStyle, {
|
|
|
2796
2800
|
display: "flex",
|
|
2797
2801
|
flexWrap: "nowrap",
|
|
2798
2802
|
alignItems: "center",
|
|
2799
|
-
lineHeight: 1
|
|
2803
|
+
lineHeight: 1,
|
|
2804
|
+
variants: {
|
|
2805
|
+
color: {
|
|
2806
|
+
default: {
|
|
2807
|
+
borderColor: "$dark300"
|
|
2808
|
+
},
|
|
2809
|
+
error: {
|
|
2810
|
+
borderColor: "$error400"
|
|
2811
|
+
}
|
|
2812
|
+
}
|
|
2813
|
+
}
|
|
2800
2814
|
});
|
|
2801
2815
|
var maskFormat = import_mask.format;
|
|
2802
2816
|
var maskUnformat = import_mask.unformat;
|
|
@@ -2825,7 +2839,7 @@ var TextField = import_react2.default.forwardRef(
|
|
|
2825
2839
|
]);
|
|
2826
2840
|
const maskRef = mask ? (0, import_mask.useMask)(mask) : void 0;
|
|
2827
2841
|
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Flex2, { gap: "0", css: { width: "100%" }, children: [
|
|
2828
|
-
!!addon && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(InputAddon, { typography: "labelSmall", children: addon }),
|
|
2842
|
+
!!addon && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(InputAddon, { color, typography: "labelSmall", children: addon }),
|
|
2829
2843
|
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
2830
2844
|
TextFieldStyled,
|
|
2831
2845
|
__spreadProps(__spreadValues({
|
|
@@ -2888,27 +2902,17 @@ function TextFieldSlot(_a) {
|
|
|
2888
2902
|
}, props), {
|
|
2889
2903
|
color: void 0
|
|
2890
2904
|
});
|
|
2891
|
-
return
|
|
2905
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
2892
2906
|
TextFieldSlotStyled,
|
|
2893
2907
|
__spreadProps(__spreadValues({}, sharedStyles), {
|
|
2894
2908
|
style: {
|
|
2895
2909
|
float: position === "flex-start" ? "left" : "right",
|
|
2896
2910
|
order: position === "flex-start" ? 0 : 2,
|
|
2897
2911
|
textAlign,
|
|
2898
|
-
zIndex: 2,
|
|
2899
|
-
cursor: "pointer"
|
|
2900
|
-
},
|
|
2901
|
-
onClick: () => onClick(),
|
|
2902
|
-
children
|
|
2903
|
-
})
|
|
2904
|
-
) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
2905
|
-
TextFieldSlotStyled,
|
|
2906
|
-
__spreadProps(__spreadValues({}, sharedStyles), {
|
|
2907
|
-
style: {
|
|
2908
|
-
float: position === "flex-start" ? "left" : "right",
|
|
2909
|
-
order: position === "flex-start" ? 0 : 2,
|
|
2910
|
-
textAlign
|
|
2912
|
+
zIndex: onClick ? 2 : void 0,
|
|
2913
|
+
cursor: onClick ? "pointer" : void 0
|
|
2911
2914
|
},
|
|
2915
|
+
onClick,
|
|
2912
2916
|
children
|
|
2913
2917
|
})
|
|
2914
2918
|
);
|
|
@@ -3916,8 +3920,8 @@ var import_react_day_picker = require("react-day-picker");
|
|
|
3916
3920
|
function buildFormatLongFn(args) {
|
|
3917
3921
|
return (options = {}) => {
|
|
3918
3922
|
const width = options.width ? String(options.width) : args.defaultWidth;
|
|
3919
|
-
const
|
|
3920
|
-
return
|
|
3923
|
+
const format4 = args.formats[width] || args.formats[args.defaultWidth];
|
|
3924
|
+
return format4;
|
|
3921
3925
|
};
|
|
3922
3926
|
}
|
|
3923
3927
|
|
|
@@ -4612,11 +4616,11 @@ var formatRelativeLocale2 = {
|
|
|
4612
4616
|
other: "P"
|
|
4613
4617
|
};
|
|
4614
4618
|
var formatRelative2 = (token, date, _baseDate, _options) => {
|
|
4615
|
-
const
|
|
4616
|
-
if (typeof
|
|
4617
|
-
return
|
|
4619
|
+
const format4 = formatRelativeLocale2[token];
|
|
4620
|
+
if (typeof format4 === "function") {
|
|
4621
|
+
return format4(date);
|
|
4618
4622
|
}
|
|
4619
|
-
return
|
|
4623
|
+
return format4;
|
|
4620
4624
|
};
|
|
4621
4625
|
|
|
4622
4626
|
// ../../node_modules/date-fns/locale/pt-BR/_lib/localize.js
|
|
@@ -5884,14 +5888,14 @@ function isProtectedDayOfYearToken(token) {
|
|
|
5884
5888
|
function isProtectedWeekYearToken(token) {
|
|
5885
5889
|
return weekYearTokenRE.test(token);
|
|
5886
5890
|
}
|
|
5887
|
-
function warnOrThrowProtectedError(token,
|
|
5888
|
-
const _message = message(token,
|
|
5891
|
+
function warnOrThrowProtectedError(token, format4, input) {
|
|
5892
|
+
const _message = message(token, format4, input);
|
|
5889
5893
|
console.warn(_message);
|
|
5890
5894
|
if (throwTokens.includes(token)) throw new RangeError(_message);
|
|
5891
5895
|
}
|
|
5892
|
-
function message(token,
|
|
5896
|
+
function message(token, format4, input) {
|
|
5893
5897
|
const subject = token[0] === "Y" ? "years" : "days of the month";
|
|
5894
|
-
return `Use \`${token.toLowerCase()}\` instead of \`${token}\` (in \`${
|
|
5898
|
+
return `Use \`${token.toLowerCase()}\` instead of \`${token}\` (in \`${format4}\`) for formatting ${subject} to the input \`${input}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`;
|
|
5895
5899
|
}
|
|
5896
5900
|
|
|
5897
5901
|
// ../../node_modules/date-fns/format.js
|
|
@@ -9731,7 +9735,7 @@ function Section(_a) {
|
|
|
9731
9735
|
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(SectionStyled, __spreadProps(__spreadValues({}, props), { children }));
|
|
9732
9736
|
}
|
|
9733
9737
|
|
|
9734
|
-
// src/components/FormFields/ErrorFormMessage.tsx
|
|
9738
|
+
// src/components/FormFields/subComponents/ErrorFormMessage.tsx
|
|
9735
9739
|
var import_free_solid_svg_icons4 = require("@fortawesome/free-solid-svg-icons");
|
|
9736
9740
|
var import_react_fontawesome4 = require("@fortawesome/react-fontawesome");
|
|
9737
9741
|
var import_jsx_runtime30 = require("react/jsx-runtime");
|
|
@@ -9746,7 +9750,7 @@ var ErrorFormMessage = ({ message: message2 }) => {
|
|
|
9746
9750
|
] });
|
|
9747
9751
|
};
|
|
9748
9752
|
|
|
9749
|
-
// src/components/FormFields/FormLabel.tsx
|
|
9753
|
+
// src/components/FormFields/subComponents/FormLabel.tsx
|
|
9750
9754
|
var import_jsx_runtime31 = require("react/jsx-runtime");
|
|
9751
9755
|
var FormLabel = ({
|
|
9752
9756
|
name,
|
|
@@ -9816,37 +9820,62 @@ var TextAreaFormField = (_a) => {
|
|
|
9816
9820
|
|
|
9817
9821
|
// src/components/FormFields/TextFormField.tsx
|
|
9818
9822
|
var import_react_hook_form2 = require("react-hook-form");
|
|
9819
|
-
|
|
9820
|
-
|
|
9821
|
-
function getNestedValue(obj, path) {
|
|
9822
|
-
return path.split(".").reduce((acc, key) => acc == null ? void 0 : acc[key], obj);
|
|
9823
|
-
}
|
|
9824
|
-
|
|
9825
|
-
// src/components/FormFields/TextFormField.tsx
|
|
9823
|
+
var import_react17 = require("react");
|
|
9824
|
+
var import_mask2 = require("@react-input/mask");
|
|
9826
9825
|
var import_jsx_runtime33 = require("react/jsx-runtime");
|
|
9827
|
-
var TextFormField = ({
|
|
9828
|
-
|
|
9829
|
-
|
|
9830
|
-
|
|
9831
|
-
|
|
9832
|
-
|
|
9833
|
-
|
|
9834
|
-
|
|
9835
|
-
|
|
9836
|
-
|
|
9837
|
-
|
|
9838
|
-
|
|
9839
|
-
|
|
9840
|
-
|
|
9841
|
-
|
|
9842
|
-
|
|
9843
|
-
|
|
9844
|
-
|
|
9845
|
-
|
|
9846
|
-
|
|
9847
|
-
const
|
|
9826
|
+
var TextFormField = (_a) => {
|
|
9827
|
+
var _b = _a, {
|
|
9828
|
+
name,
|
|
9829
|
+
label,
|
|
9830
|
+
required,
|
|
9831
|
+
mask,
|
|
9832
|
+
validate,
|
|
9833
|
+
validationErrorMessage = "Este campo \xE9 obrigat\xF3rio.",
|
|
9834
|
+
onChange,
|
|
9835
|
+
valueFormatter
|
|
9836
|
+
} = _b, inputProps = __objRest(_b, [
|
|
9837
|
+
"name",
|
|
9838
|
+
"label",
|
|
9839
|
+
"required",
|
|
9840
|
+
"mask",
|
|
9841
|
+
"validate",
|
|
9842
|
+
"validationErrorMessage",
|
|
9843
|
+
"onChange",
|
|
9844
|
+
"valueFormatter"
|
|
9845
|
+
]);
|
|
9846
|
+
const handleValidate = (0, import_react17.useCallback)(
|
|
9847
|
+
(value) => {
|
|
9848
|
+
var _a2;
|
|
9849
|
+
if (!required && value.trim() === "") return true;
|
|
9850
|
+
return (_a2 = validate == null ? void 0 : validate(value)) != null ? _a2 : true;
|
|
9851
|
+
},
|
|
9852
|
+
[validate, required]
|
|
9853
|
+
);
|
|
9854
|
+
const { field, fieldState } = (0, import_react_hook_form2.useController)({
|
|
9855
|
+
name,
|
|
9856
|
+
rules: {
|
|
9857
|
+
required: required ? validationErrorMessage : false,
|
|
9858
|
+
validate: handleValidate,
|
|
9859
|
+
onChange
|
|
9860
|
+
},
|
|
9861
|
+
defaultValue: ""
|
|
9862
|
+
});
|
|
9863
|
+
const fieldError = fieldState.error;
|
|
9848
9864
|
const haveError = !!fieldError;
|
|
9849
9865
|
const errorMsg = fieldError == null ? void 0 : fieldError.message;
|
|
9866
|
+
const { value: formValue, onChange: formChange } = field;
|
|
9867
|
+
const formattedValue = (0, import_react17.useMemo)(() => {
|
|
9868
|
+
let value = formValue;
|
|
9869
|
+
if (valueFormatter) value = valueFormatter.format(value);
|
|
9870
|
+
if (mask) value = (0, import_mask2.format)(value != null ? value : "", mask);
|
|
9871
|
+
return value;
|
|
9872
|
+
}, [formValue, valueFormatter, mask]);
|
|
9873
|
+
const handleChange = (e) => {
|
|
9874
|
+
let value = e.target.value;
|
|
9875
|
+
if (mask) value = (0, import_mask2.unformat)(value, mask);
|
|
9876
|
+
if (valueFormatter) value = valueFormatter.unformat(value);
|
|
9877
|
+
formChange(value);
|
|
9878
|
+
};
|
|
9850
9879
|
return /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(Flex2, { direction: "column", children: [
|
|
9851
9880
|
label && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
9852
9881
|
FormLabel,
|
|
@@ -9859,16 +9888,13 @@ var TextFormField = ({
|
|
|
9859
9888
|
),
|
|
9860
9889
|
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
9861
9890
|
TextField,
|
|
9862
|
-
__spreadProps(__spreadValues({
|
|
9891
|
+
__spreadProps(__spreadValues(__spreadValues({
|
|
9863
9892
|
mask,
|
|
9864
|
-
placeholder,
|
|
9865
|
-
disabled,
|
|
9866
9893
|
color: haveError ? "error" : "default",
|
|
9867
9894
|
"aria-labelledby": `${name}-label`
|
|
9868
|
-
},
|
|
9869
|
-
|
|
9870
|
-
|
|
9871
|
-
value
|
|
9895
|
+
}, inputProps), field), {
|
|
9896
|
+
onChange: handleChange,
|
|
9897
|
+
value: formattedValue
|
|
9872
9898
|
})
|
|
9873
9899
|
),
|
|
9874
9900
|
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(ErrorFormMessage, { message: errorMsg })
|
|
@@ -9881,14 +9907,14 @@ var import_jsx_runtime34 = require("react/jsx-runtime");
|
|
|
9881
9907
|
var Form = (_a) => {
|
|
9882
9908
|
var _b = _a, {
|
|
9883
9909
|
onSubmit,
|
|
9884
|
-
children
|
|
9885
|
-
methods
|
|
9910
|
+
children
|
|
9886
9911
|
} = _b, props = __objRest(_b, [
|
|
9887
9912
|
"onSubmit",
|
|
9888
|
-
"children"
|
|
9889
|
-
"methods"
|
|
9913
|
+
"children"
|
|
9890
9914
|
]);
|
|
9891
|
-
const formMethods =
|
|
9915
|
+
const formMethods = (0, import_react_hook_form3.useForm)(__spreadValues({
|
|
9916
|
+
mode: "onTouched"
|
|
9917
|
+
}, props));
|
|
9892
9918
|
return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_react_hook_form3.FormProvider, __spreadProps(__spreadValues({}, formMethods), { children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("form", { onSubmit: formMethods.handleSubmit(onSubmit), children }) }));
|
|
9893
9919
|
};
|
|
9894
9920
|
|
|
@@ -9906,10 +9932,7 @@ var MultiSelectFormField = (_a) => {
|
|
|
9906
9932
|
"required"
|
|
9907
9933
|
]);
|
|
9908
9934
|
var _a2;
|
|
9909
|
-
const {
|
|
9910
|
-
formState: { errors }
|
|
9911
|
-
} = (0, import_react_hook_form4.useFormContext)();
|
|
9912
|
-
const { field } = (0, import_react_hook_form4.useController)({
|
|
9935
|
+
const { field, fieldState } = (0, import_react_hook_form4.useController)({
|
|
9913
9936
|
name,
|
|
9914
9937
|
rules: {
|
|
9915
9938
|
required
|
|
@@ -9917,8 +9940,8 @@ var MultiSelectFormField = (_a) => {
|
|
|
9917
9940
|
defaultValue: []
|
|
9918
9941
|
});
|
|
9919
9942
|
const { value, onChange, ref, onBlur, disabled } = field;
|
|
9920
|
-
const haveError = !!
|
|
9921
|
-
const errorMsg = (_a2 =
|
|
9943
|
+
const haveError = !!fieldState.error;
|
|
9944
|
+
const errorMsg = (_a2 = fieldState.error) == null ? void 0 : _a2.message;
|
|
9922
9945
|
const handleChange = (v) => {
|
|
9923
9946
|
onChange(v);
|
|
9924
9947
|
};
|
|
@@ -9945,49 +9968,56 @@ var MultiSelectFormField = (_a) => {
|
|
|
9945
9968
|
] });
|
|
9946
9969
|
};
|
|
9947
9970
|
|
|
9971
|
+
// src/components/FormFields/utils/validation.ts
|
|
9972
|
+
var isValidEmail = (email) => {
|
|
9973
|
+
const emailRexep = /^(([^<>()[\].,;:\s@"]+(\.[^<>()[\].,;:\s@"]+)*)|(".+"))@(([^<>()[\].,;:\s@"]+\.)+[^<>()[\].,;:\s@"]{2,})$/i;
|
|
9974
|
+
return emailRexep.test(email);
|
|
9975
|
+
};
|
|
9976
|
+
var validateEmail = (errorMsg) => (value) => {
|
|
9977
|
+
return !isValidEmail(value) ? errorMsg : true;
|
|
9978
|
+
};
|
|
9979
|
+
var minMaxLength = (min, max, errorMsg) => (value) => {
|
|
9980
|
+
var length = value.length;
|
|
9981
|
+
return length > max || length < min ? errorMsg : true;
|
|
9982
|
+
};
|
|
9983
|
+
|
|
9948
9984
|
// src/components/FormFields/PhoneFormField.tsx
|
|
9949
|
-
var import_react_hook_form5 = require("react-hook-form");
|
|
9950
9985
|
var import_jsx_runtime36 = require("react/jsx-runtime");
|
|
9951
|
-
var PhoneFormField = (
|
|
9952
|
-
|
|
9953
|
-
|
|
9954
|
-
|
|
9955
|
-
|
|
9956
|
-
|
|
9957
|
-
|
|
9958
|
-
|
|
9959
|
-
|
|
9960
|
-
|
|
9961
|
-
|
|
9962
|
-
|
|
9963
|
-
|
|
9964
|
-
|
|
9965
|
-
|
|
9966
|
-
|
|
9967
|
-
|
|
9968
|
-
|
|
9969
|
-
|
|
9970
|
-
|
|
9971
|
-
|
|
9972
|
-
|
|
9973
|
-
|
|
9974
|
-
|
|
9975
|
-
|
|
9976
|
-
|
|
9977
|
-
|
|
9978
|
-
|
|
9979
|
-
name,
|
|
9980
|
-
label,
|
|
9981
|
-
required,
|
|
9982
|
-
haveError
|
|
9986
|
+
var PhoneFormField = ({
|
|
9987
|
+
name,
|
|
9988
|
+
label,
|
|
9989
|
+
required
|
|
9990
|
+
}) => {
|
|
9991
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
9992
|
+
TextFormField,
|
|
9993
|
+
{
|
|
9994
|
+
name,
|
|
9995
|
+
label,
|
|
9996
|
+
required,
|
|
9997
|
+
addon: "+ 55",
|
|
9998
|
+
mask: {
|
|
9999
|
+
mask: "(__) _____-____}",
|
|
10000
|
+
replacement: { _: /\d/ }
|
|
10001
|
+
},
|
|
10002
|
+
placeholder: "(00) 00000-0000",
|
|
10003
|
+
type: "tel",
|
|
10004
|
+
validate: minMaxLength(13, 14, "Telefone inv\xE1lido"),
|
|
10005
|
+
valueFormatter: {
|
|
10006
|
+
format(v) {
|
|
10007
|
+
if (!v || v === "") return v;
|
|
10008
|
+
return v.replace(/^\+55/, "");
|
|
10009
|
+
},
|
|
10010
|
+
unformat(v) {
|
|
10011
|
+
if (!v || v === "") return v;
|
|
10012
|
+
return "+55" + v;
|
|
10013
|
+
}
|
|
9983
10014
|
}
|
|
9984
|
-
|
|
9985
|
-
|
|
9986
|
-
] });
|
|
10015
|
+
}
|
|
10016
|
+
);
|
|
9987
10017
|
};
|
|
9988
10018
|
|
|
9989
10019
|
// src/components/FormFields/CPFFormField.tsx
|
|
9990
|
-
var
|
|
10020
|
+
var import_react_hook_form5 = require("react-hook-form");
|
|
9991
10021
|
var import_jsx_runtime37 = require("react/jsx-runtime");
|
|
9992
10022
|
var isValidCPF = (cpf) => {
|
|
9993
10023
|
cpf = cpf.replace(/[^\d]+/g, "");
|
|
@@ -10012,8 +10042,8 @@ var CPFFormField = ({
|
|
|
10012
10042
|
validationErrorMessage,
|
|
10013
10043
|
foreignerLabel
|
|
10014
10044
|
}) => {
|
|
10015
|
-
const { control, setValue } = (0,
|
|
10016
|
-
const foreigner = (0,
|
|
10045
|
+
const { control, setValue } = (0, import_react_hook_form5.useFormContext)();
|
|
10046
|
+
const foreigner = (0, import_react_hook_form5.useWatch)({ name: "foreigner", control });
|
|
10017
10047
|
return /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(Flex2, { direction: "column", children: [
|
|
10018
10048
|
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
|
|
10019
10049
|
TextFormField,
|
|
@@ -10026,11 +10056,9 @@ var CPFFormField = ({
|
|
|
10026
10056
|
mask: "___.___.___-__",
|
|
10027
10057
|
replacement: { _: /[0-9]/ }
|
|
10028
10058
|
},
|
|
10029
|
-
|
|
10030
|
-
|
|
10031
|
-
|
|
10032
|
-
return isValidCPF(value) || validationErrorMessage;
|
|
10033
|
-
}
|
|
10059
|
+
validate: (value) => {
|
|
10060
|
+
if (!required || foreigner) return true;
|
|
10061
|
+
return isValidCPF(value) || validationErrorMessage;
|
|
10034
10062
|
},
|
|
10035
10063
|
disabled: foreigner
|
|
10036
10064
|
}
|
|
@@ -10113,12 +10141,10 @@ var CNPJFormField = ({
|
|
|
10113
10141
|
mask: "__.___.___/____-__",
|
|
10114
10142
|
replacement: { _: /[0-9]/ }
|
|
10115
10143
|
},
|
|
10116
|
-
|
|
10117
|
-
|
|
10118
|
-
|
|
10119
|
-
|
|
10120
|
-
return isValidCNPJ(value) || validationErrorMessage;
|
|
10121
|
-
}
|
|
10144
|
+
validate: (value) => {
|
|
10145
|
+
const isEmpty = value.replace(matchesNonDigit, "").length === 0;
|
|
10146
|
+
if (!required && isEmpty) return true;
|
|
10147
|
+
return isValidCNPJ(value) || validationErrorMessage;
|
|
10122
10148
|
}
|
|
10123
10149
|
}
|
|
10124
10150
|
);
|
|
@@ -10171,12 +10197,10 @@ var BirthDateFormField = ({
|
|
|
10171
10197
|
mask: "__/__/____",
|
|
10172
10198
|
replacement: { _: /[0-9]/ }
|
|
10173
10199
|
},
|
|
10174
|
-
|
|
10175
|
-
|
|
10176
|
-
|
|
10177
|
-
|
|
10178
|
-
return isValidBirthDate(value, language) || validationErrorMessage;
|
|
10179
|
-
}
|
|
10200
|
+
validate: (value) => {
|
|
10201
|
+
const isEmpty = value.replace(/[^\d]+/g, "").length === 0;
|
|
10202
|
+
if (!required && isEmpty) return true;
|
|
10203
|
+
return isValidBirthDate(value, language) || validationErrorMessage;
|
|
10180
10204
|
}
|
|
10181
10205
|
}
|
|
10182
10206
|
);
|
|
@@ -10206,23 +10230,27 @@ var IdentityDocumentNumberFormField = ({
|
|
|
10206
10230
|
mask: "__.___.___-_",
|
|
10207
10231
|
replacement: { _: /[0-9]/ }
|
|
10208
10232
|
},
|
|
10209
|
-
|
|
10210
|
-
|
|
10211
|
-
|
|
10212
|
-
|
|
10213
|
-
return isValidRG(value) || validationErrorMessage;
|
|
10214
|
-
}
|
|
10233
|
+
validate: (value) => {
|
|
10234
|
+
const isEmpty = value.replace(/[^\d]/g, "").length === 0;
|
|
10235
|
+
if (!required && isEmpty) return true;
|
|
10236
|
+
return isValidRG(value) || validationErrorMessage;
|
|
10215
10237
|
}
|
|
10216
10238
|
}
|
|
10217
10239
|
);
|
|
10218
10240
|
};
|
|
10219
10241
|
|
|
10220
10242
|
// src/components/FormFields/AddressFormFields/index.tsx
|
|
10221
|
-
var
|
|
10222
|
-
|
|
10243
|
+
var import_react_hook_form8 = require("react-hook-form");
|
|
10244
|
+
|
|
10245
|
+
// src/components/FormFields/SelectFormField.tsx
|
|
10246
|
+
var import_react_hook_form6 = require("react-hook-form");
|
|
10247
|
+
|
|
10248
|
+
// src/utils/getNestedValue.ts
|
|
10249
|
+
function getNestedValue(obj, path) {
|
|
10250
|
+
return path.split(".").reduce((acc, key) => acc == null ? void 0 : acc[key], obj);
|
|
10251
|
+
}
|
|
10223
10252
|
|
|
10224
10253
|
// src/components/FormFields/SelectFormField.tsx
|
|
10225
|
-
var import_react_hook_form7 = require("react-hook-form");
|
|
10226
10254
|
var import_jsx_runtime41 = require("react/jsx-runtime");
|
|
10227
10255
|
var SelectFormField = ({
|
|
10228
10256
|
name,
|
|
@@ -10237,7 +10265,7 @@ var SelectFormField = ({
|
|
|
10237
10265
|
const {
|
|
10238
10266
|
control,
|
|
10239
10267
|
formState: { errors }
|
|
10240
|
-
} = (0,
|
|
10268
|
+
} = (0, import_react_hook_form6.useFormContext)();
|
|
10241
10269
|
const fieldError = getNestedValue(errors, name);
|
|
10242
10270
|
const haveError = !!fieldError;
|
|
10243
10271
|
const errorMsg = fieldError == null ? void 0 : fieldError.message;
|
|
@@ -10255,7 +10283,7 @@ var SelectFormField = ({
|
|
|
10255
10283
|
}
|
|
10256
10284
|
),
|
|
10257
10285
|
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
|
10258
|
-
|
|
10286
|
+
import_react_hook_form6.Controller,
|
|
10259
10287
|
{
|
|
10260
10288
|
control,
|
|
10261
10289
|
name,
|
|
@@ -10340,19 +10368,15 @@ function CountryFormField({
|
|
|
10340
10368
|
}
|
|
10341
10369
|
|
|
10342
10370
|
// src/components/FormFields/AddressFormFields/PostalCodeFormField.tsx
|
|
10343
|
-
var import_react_hook_form8 = require("react-hook-form");
|
|
10344
10371
|
var import_jsx_runtime43 = require("react/jsx-runtime");
|
|
10345
10372
|
var PostalCodeFormField = ({
|
|
10346
10373
|
name,
|
|
10347
10374
|
label,
|
|
10348
10375
|
required,
|
|
10349
10376
|
placeholder,
|
|
10350
|
-
validationErrorMessage
|
|
10377
|
+
validationErrorMessage,
|
|
10378
|
+
onChange
|
|
10351
10379
|
}) => {
|
|
10352
|
-
const { control } = (0, import_react_hook_form8.useFormContext)();
|
|
10353
|
-
const {
|
|
10354
|
-
field: { onChange, value }
|
|
10355
|
-
} = (0, import_react_hook_form8.useController)({ name, control });
|
|
10356
10380
|
return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
|
|
10357
10381
|
TextFormField,
|
|
10358
10382
|
{
|
|
@@ -10364,14 +10388,11 @@ var PostalCodeFormField = ({
|
|
|
10364
10388
|
mask: "_____-___",
|
|
10365
10389
|
replacement: { _: /[0-9]/ }
|
|
10366
10390
|
},
|
|
10367
|
-
value,
|
|
10368
|
-
|
|
10369
|
-
|
|
10370
|
-
|
|
10371
|
-
|
|
10372
|
-
if (!required && isEmpty) return true;
|
|
10373
|
-
return /^\d{8}$/.test(value2.replace(/\D/g, "")) || validationErrorMessage;
|
|
10374
|
-
}
|
|
10391
|
+
onChange: (e) => onChange == null ? void 0 : onChange(e.target.value),
|
|
10392
|
+
validate: (value) => {
|
|
10393
|
+
const isEmpty = value.replace(/[^\d]/g, "").length === 0;
|
|
10394
|
+
if (!required && isEmpty) return true;
|
|
10395
|
+
return /^\d{8}$/.test(value.replace(/\D/g, "")) || validationErrorMessage;
|
|
10375
10396
|
}
|
|
10376
10397
|
}
|
|
10377
10398
|
);
|
|
@@ -10428,8 +10449,8 @@ function StateFormField({
|
|
|
10428
10449
|
}
|
|
10429
10450
|
|
|
10430
10451
|
// src/components/FormFields/AddressFormFields/CityFormField.tsx
|
|
10431
|
-
var
|
|
10432
|
-
var
|
|
10452
|
+
var import_react18 = require("react");
|
|
10453
|
+
var import_react_hook_form7 = require("react-hook-form");
|
|
10433
10454
|
var import_jsx_runtime45 = require("react/jsx-runtime");
|
|
10434
10455
|
function CityFormField({
|
|
10435
10456
|
name,
|
|
@@ -10439,11 +10460,11 @@ function CityFormField({
|
|
|
10439
10460
|
isBrazil,
|
|
10440
10461
|
placeholder
|
|
10441
10462
|
}) {
|
|
10442
|
-
const { control, watch } = (0,
|
|
10463
|
+
const { control, watch } = (0, import_react_hook_form7.useFormContext)();
|
|
10443
10464
|
const selectedState = watch(stateName);
|
|
10444
|
-
const [cities, setCities] = (0,
|
|
10445
|
-
const [loading, setLoading] = (0,
|
|
10446
|
-
(0,
|
|
10465
|
+
const [cities, setCities] = (0, import_react18.useState)([]);
|
|
10466
|
+
const [loading, setLoading] = (0, import_react18.useState)(false);
|
|
10467
|
+
(0, import_react18.useEffect)(() => {
|
|
10447
10468
|
if (!isBrazil) {
|
|
10448
10469
|
setCities([]);
|
|
10449
10470
|
return;
|
|
@@ -10483,7 +10504,7 @@ function CityFormField({
|
|
|
10483
10504
|
fetchCities();
|
|
10484
10505
|
}, [selectedState, isBrazil]);
|
|
10485
10506
|
return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(import_jsx_runtime45.Fragment, { children: isBrazil && cities.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
|
|
10486
|
-
|
|
10507
|
+
import_react_hook_form7.Controller,
|
|
10487
10508
|
{
|
|
10488
10509
|
name,
|
|
10489
10510
|
control,
|
|
@@ -10543,28 +10564,27 @@ function AddressFormFields({
|
|
|
10543
10564
|
required,
|
|
10544
10565
|
layout = "column"
|
|
10545
10566
|
}) {
|
|
10546
|
-
const { control, setValue } = (0,
|
|
10547
|
-
const { errors } = (0,
|
|
10548
|
-
const selectedCountry = (0,
|
|
10549
|
-
const cep = (0, import_react_hook_form10.useWatch)({ control, name: `${name}.zip_code` });
|
|
10567
|
+
const { control, setValue } = (0, import_react_hook_form8.useFormContext)();
|
|
10568
|
+
const { errors } = (0, import_react_hook_form8.useFormState)({ control });
|
|
10569
|
+
const selectedCountry = (0, import_react_hook_form8.useWatch)({ control, name: `${name}.country` });
|
|
10550
10570
|
const isBrazil = selectedCountry === "Brasil";
|
|
10551
10571
|
const addressErrors = getNestedValue2(errors, name);
|
|
10552
10572
|
const haveError = !!addressErrors;
|
|
10553
|
-
|
|
10573
|
+
const handleCEPChange = (cep) => {
|
|
10574
|
+
if (!isBrazil) return;
|
|
10554
10575
|
const cleanedCep = cep == null ? void 0 : cep.replace(/\D/g, "");
|
|
10555
|
-
if (
|
|
10556
|
-
|
|
10557
|
-
|
|
10558
|
-
|
|
10559
|
-
|
|
10560
|
-
|
|
10561
|
-
|
|
10562
|
-
|
|
10563
|
-
|
|
10564
|
-
|
|
10565
|
-
|
|
10566
|
-
|
|
10567
|
-
}, [cep, isBrazil]);
|
|
10576
|
+
if ((cleanedCep == null ? void 0 : cleanedCep.length) !== 8) return;
|
|
10577
|
+
fetch(`https://viacep.com.br/ws/${cleanedCep}/json`).then((res) => res.json()).then((data) => {
|
|
10578
|
+
if (!data.erro) {
|
|
10579
|
+
setValue(`${name}.street`, data.logradouro || "");
|
|
10580
|
+
setValue(`${name}.neighborhood`, data.bairro || "");
|
|
10581
|
+
setValue(`${name}.city`, data.localidade || "");
|
|
10582
|
+
setValue(`${name}.state`, data.uf || "");
|
|
10583
|
+
}
|
|
10584
|
+
}).catch(() => {
|
|
10585
|
+
console.error("Erro ao buscar CEP");
|
|
10586
|
+
});
|
|
10587
|
+
};
|
|
10568
10588
|
return /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(AddressContainerStyled, { layout, children: [
|
|
10569
10589
|
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
|
|
10570
10590
|
FormLabel,
|
|
@@ -10591,7 +10611,8 @@ function AddressFormFields({
|
|
|
10591
10611
|
label: "CEP",
|
|
10592
10612
|
required,
|
|
10593
10613
|
placeholder: "00000-000",
|
|
10594
|
-
validationErrorMessage: "CEP inv\xE1lido"
|
|
10614
|
+
validationErrorMessage: "CEP inv\xE1lido",
|
|
10615
|
+
onChange: handleCEPChange
|
|
10595
10616
|
}
|
|
10596
10617
|
) : /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
|
|
10597
10618
|
TextFormField,
|
|
@@ -10642,7 +10663,7 @@ function AddressFormFields({
|
|
|
10642
10663
|
}
|
|
10643
10664
|
|
|
10644
10665
|
// src/components/FormFields/RadioGroupFormField.tsx
|
|
10645
|
-
var
|
|
10666
|
+
var import_react_hook_form9 = require("react-hook-form");
|
|
10646
10667
|
var import_jsx_runtime47 = require("react/jsx-runtime");
|
|
10647
10668
|
var RadioGroupFormField = ({
|
|
10648
10669
|
name,
|
|
@@ -10658,7 +10679,7 @@ var RadioGroupFormField = ({
|
|
|
10658
10679
|
const {
|
|
10659
10680
|
control,
|
|
10660
10681
|
formState: { errors }
|
|
10661
|
-
} = (0,
|
|
10682
|
+
} = (0, import_react_hook_form9.useFormContext)();
|
|
10662
10683
|
const fieldError = getNestedValue(errors, name);
|
|
10663
10684
|
const haveError = !!fieldError;
|
|
10664
10685
|
const errorMsg = fieldError == null ? void 0 : fieldError.message;
|
|
@@ -10676,7 +10697,7 @@ var RadioGroupFormField = ({
|
|
|
10676
10697
|
}
|
|
10677
10698
|
),
|
|
10678
10699
|
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
10679
|
-
|
|
10700
|
+
import_react_hook_form9.Controller,
|
|
10680
10701
|
{
|
|
10681
10702
|
name,
|
|
10682
10703
|
control,
|
|
@@ -10703,7 +10724,7 @@ var RadioGroupFormField = ({
|
|
|
10703
10724
|
};
|
|
10704
10725
|
|
|
10705
10726
|
// src/components/FormFields/CheckboxGroupFormField.tsx
|
|
10706
|
-
var
|
|
10727
|
+
var import_react_hook_form10 = require("react-hook-form");
|
|
10707
10728
|
var import_jsx_runtime48 = require("react/jsx-runtime");
|
|
10708
10729
|
var CheckboxGroupFormField = ({
|
|
10709
10730
|
name,
|
|
@@ -10719,7 +10740,7 @@ var CheckboxGroupFormField = ({
|
|
|
10719
10740
|
const {
|
|
10720
10741
|
control,
|
|
10721
10742
|
formState: { errors }
|
|
10722
|
-
} = (0,
|
|
10743
|
+
} = (0, import_react_hook_form10.useFormContext)();
|
|
10723
10744
|
const fieldError = getNestedValue(errors, name);
|
|
10724
10745
|
const haveError = !!fieldError;
|
|
10725
10746
|
const errorMsg = fieldError == null ? void 0 : fieldError.message;
|
|
@@ -10738,7 +10759,7 @@ var CheckboxGroupFormField = ({
|
|
|
10738
10759
|
}
|
|
10739
10760
|
),
|
|
10740
10761
|
/* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
|
|
10741
|
-
|
|
10762
|
+
import_react_hook_form10.Controller,
|
|
10742
10763
|
{
|
|
10743
10764
|
name,
|
|
10744
10765
|
control,
|
|
@@ -10768,6 +10789,26 @@ var CheckboxGroupFormField = ({
|
|
|
10768
10789
|
/* @__PURE__ */ (0, import_jsx_runtime48.jsx)(ErrorFormMessage, { message: errorMsg })
|
|
10769
10790
|
] });
|
|
10770
10791
|
};
|
|
10792
|
+
|
|
10793
|
+
// src/components/FormFields/EmailFormField.tsx
|
|
10794
|
+
var import_jsx_runtime49 = require("react/jsx-runtime");
|
|
10795
|
+
var EmailFormField = ({
|
|
10796
|
+
name,
|
|
10797
|
+
label,
|
|
10798
|
+
required
|
|
10799
|
+
}) => {
|
|
10800
|
+
return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
|
|
10801
|
+
TextFormField,
|
|
10802
|
+
{
|
|
10803
|
+
name,
|
|
10804
|
+
label,
|
|
10805
|
+
required,
|
|
10806
|
+
placeholder: "@mail.com",
|
|
10807
|
+
type: "email",
|
|
10808
|
+
validate: validateEmail("E-mail inv\xE1lido.")
|
|
10809
|
+
}
|
|
10810
|
+
);
|
|
10811
|
+
};
|
|
10771
10812
|
// Annotate the CommonJS export names for ESM import in node:
|
|
10772
10813
|
0 && (module.exports = {
|
|
10773
10814
|
AddressFormFields,
|
|
@@ -10805,6 +10846,7 @@ var CheckboxGroupFormField = ({
|
|
|
10805
10846
|
Drawer,
|
|
10806
10847
|
DropdownMenu,
|
|
10807
10848
|
DropdownMenuItem,
|
|
10849
|
+
EmailFormField,
|
|
10808
10850
|
ErrorFormMessage,
|
|
10809
10851
|
Filter,
|
|
10810
10852
|
FilterItem,
|