@pipelinesolucoes/form 1.2.0-beta.1 → 1.2.0-beta.3
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/dist/components/NotificationSnackbar.d.ts +1 -2
- package/dist/components/NotificationSnackbar.js +1 -1
- package/dist/components/NotificationSnackbar.js.map +1 -1
- package/dist/components/TextFieldPassword.d.ts +4 -33
- package/dist/components/TextFieldPassword.js +17 -16
- package/dist/components/TextFieldPassword.js.map +1 -1
- package/dist/components/TextFieldValidate.d.ts +5 -6
- package/dist/components/TextFieldValidate.js +12 -11
- package/dist/components/TextFieldValidate.js.map +1 -1
- package/dist/components/login/ClickResult.d.ts +11 -0
- package/dist/components/login/ClickResult.js +2 -0
- package/dist/components/login/ClickResult.js.map +1 -0
- package/dist/components/login/FormLogin.d.ts +6 -140
- package/dist/components/login/FormLogin.js +30 -142
- package/dist/components/login/FormLogin.js.map +1 -1
- package/dist/components/login/FormPasswordRecovery.d.ts +1 -22
- package/dist/components/login/FormPasswordRecovery.js +27 -6
- package/dist/components/login/FormPasswordRecovery.js.map +1 -1
- package/dist/components/login/FormSignUp.d.ts +4 -136
- package/dist/components/login/FormSignUp.js +30 -150
- package/dist/components/login/FormSignUp.js.map +1 -1
- package/dist/components/login/GoogleButton.d.ts +1 -4
- package/dist/components/login/GoogleButton.js.map +1 -1
- package/dist/components/login/StyleLogin.d.ts +7 -0
- package/dist/components/login/StyleLogin.js +42 -0
- package/dist/components/login/StyleLogin.js.map +1 -0
- package/dist/components/{FormStyled.d.ts → recaptcha/FormStyled.d.ts} +0 -7
- package/dist/components/{FormStyled.js → recaptcha/FormStyled.js} +0 -13
- package/dist/components/recaptcha/FormStyled.js.map +1 -0
- package/dist/components/recaptcha/RecaptchaForm.js +1 -1
- package/dist/components/recaptcha/RecaptchaForm.js.map +1 -1
- package/dist/components/{ButtonFormStyled.d.ts → style/ButtonFormStyled.d.ts} +1 -1
- package/dist/components/style/ButtonFormStyled.js +22 -0
- package/dist/components/style/ButtonFormStyled.js.map +1 -0
- package/dist/components/style/LinkFormStyled.d.ts +7 -0
- package/dist/components/style/LinkFormStyled.js +15 -0
- package/dist/components/style/LinkFormStyled.js.map +1 -0
- package/dist/index.d.ts +0 -4
- package/dist/index.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/FieldProps.d.ts +4 -0
- package/package.json +5 -3
- package/dist/components/ButtonFormStyled.js +0 -22
- package/dist/components/ButtonFormStyled.js.map +0 -1
- package/dist/components/FormStyled.js.map +0 -1
- package/dist/types/BorderProps.d.ts +0 -6
- package/dist/types/BorderProps.js +0 -2
- package/dist/types/BorderProps.js.map +0 -1
- package/dist/types/ColorProps.d.ts +0 -9
- package/dist/types/ColorProps.js +0 -2
- package/dist/types/ColorProps.js.map +0 -1
- package/dist/types/LayoutProps.d.ts +0 -7
- package/dist/types/LayoutProps.js +0 -2
- package/dist/types/LayoutProps.js.map +0 -1
- package/dist/types/TextProps.d.ts +0 -5
- package/dist/types/TextProps.js +0 -2
- package/dist/types/TextProps.js.map +0 -1
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { ColorProps } from "../types/ColorProps";
|
|
2
|
-
import { TextProps } from "../types/TextProps";
|
|
3
1
|
import { AlertColor, TypographyVariant, SnackbarOrigin } from "@mui/material";
|
|
2
|
+
import { ColorProps, TextProps } from "@pipelinesolucoes/theme";
|
|
4
3
|
export interface NotificationSnackbarProps extends TextProps, ColorProps {
|
|
5
4
|
background?: string;
|
|
6
5
|
text: string;
|
|
@@ -43,7 +43,7 @@ import { Snackbar, Alert, Typography, useTheme } from "@mui/material";
|
|
|
43
43
|
* };
|
|
44
44
|
* ```
|
|
45
45
|
*/
|
|
46
|
-
const NotificationSnackbar = ({ background
|
|
46
|
+
const NotificationSnackbar = ({ background, open, text, variant = 'body1', severity = "success", anchorOrigin = { vertical: 'top', horizontal: 'center' }, onClose, }) => {
|
|
47
47
|
var _a, _b, _c, _d;
|
|
48
48
|
const theme = useTheme();
|
|
49
49
|
// 1) prop -> 2) token -> 3) fallback
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NotificationSnackbar.js","sourceRoot":"","sources":["../../src/components/NotificationSnackbar.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;
|
|
1
|
+
{"version":3,"file":"NotificationSnackbar.js","sourceRoot":"","sources":["../../src/components/NotificationSnackbar.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAGb,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAc,UAAU,EAAqC,QAAQ,EAAE,MAAM,eAAe,CAAC;AAarH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,MAAM,oBAAoB,GAAwC,CAAC,EACjE,UAAU,EACV,IAAI,EACJ,IAAI,EACJ,OAAO,GAAC,OAAO,EACf,QAAQ,GAAG,SAAS,EACpB,YAAY,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,EACxD,OAAO,GACR,EAAE,EAAE;;IAEH,MAAM,KAAK,GAAG,QAAQ,EAAE,CAAC;IAEzB,qCAAqC;IACrC,MAAM,kBAAkB,GACtB,MAAA,UAAU,aAAV,UAAU,cAAV,UAAU,GACV,MAAA,MAAA,MAAA,KAAK,CAAC,gBAAgB,0CAAE,KAAK,0CAAE,YAAY,0CAAE,UAAU,mCACvD,SAAS,CAAC;IAEZ,OAAO,CACL,KAAC,QAAQ,IACP,IAAI,EAAE,IAAI,EACV,gBAAgB,EAAE,IAAI,EACtB,OAAO,EAAE,OAAO,EAChB,YAAY,EAAE,YAAY,YAE1B,KAAC,KAAK,IAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAC,QAAQ,EAAC,EAAE,EAAE,EAAE,KAAK,EAAE,kBAAkB,EAAE,YAC7F,KAAC,UAAU,IAAC,OAAO,EAAE,OAAO,EAAE,SAAS,EAAC,MAAM,YAAE,IAAI,GAAc,GAC5D,GACC,CACZ,CAAC;AACJ,CAAC,CAAC;AAEF,oBAAoB,CAAC,WAAW,GAAG,sBAAsB,CAAC;AAE1D,eAAe,oBAAoB,CAAC"}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { BorderProps } from '
|
|
3
|
-
import { ColorProps } from '@/types/ColorProps';
|
|
4
|
-
import { LayoutProps } from '@/types/LayoutProps';
|
|
2
|
+
import { BorderProps, ColorProps, LayoutProps } from '@pipelinesolucoes/theme';
|
|
5
3
|
type ValidationStatus = 'idle' | 'required' | 'invalid' | 'valid';
|
|
6
4
|
interface PasswordValidationResult {
|
|
7
5
|
isValid: boolean;
|
|
@@ -13,10 +11,6 @@ interface TextFieldPasswordProps extends BorderProps, ColorProps, LayoutProps {
|
|
|
13
11
|
id?: string;
|
|
14
12
|
label?: string;
|
|
15
13
|
placeholder?: string;
|
|
16
|
-
/**
|
|
17
|
-
* Valor controlado do campo (opcional).
|
|
18
|
-
* Se você não passar `value`, o componente funciona de forma "semi-controlada" internamente.
|
|
19
|
-
*/
|
|
20
14
|
value?: string;
|
|
21
15
|
background?: string;
|
|
22
16
|
backgroundDisabled?: string;
|
|
@@ -28,34 +22,11 @@ interface TextFieldPasswordProps extends BorderProps, ColorProps, LayoutProps {
|
|
|
28
22
|
borderColor?: string;
|
|
29
23
|
padding?: string;
|
|
30
24
|
disabled?: boolean;
|
|
31
|
-
/**
|
|
32
|
-
* Se true, valida obrigatório.
|
|
33
|
-
* @default true
|
|
34
|
-
*/
|
|
35
25
|
required?: boolean;
|
|
36
|
-
/**
|
|
37
|
-
* Regra de formato (regex) para validar a senha.
|
|
38
|
-
* @default /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[^A-Za-z0-9]).{8,}$/
|
|
39
|
-
*/
|
|
40
|
-
passwordPattern?: RegExp;
|
|
41
|
-
/**
|
|
42
|
-
* Mensagem quando o campo é obrigatório e está vazio.
|
|
43
|
-
* @default 'Senha obrigatória'
|
|
44
|
-
*/
|
|
45
26
|
requiredMessage?: string;
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
*/
|
|
50
|
-
invalidMessage?: string;
|
|
51
|
-
/**
|
|
52
|
-
* Quando validar:
|
|
53
|
-
* - 'blur': valida ao sair do campo
|
|
54
|
-
* - 'change': valida a cada digitação
|
|
55
|
-
* - 'both': valida nos dois
|
|
56
|
-
* @default 'blur'
|
|
57
|
-
*/
|
|
58
|
-
validateOn?: 'blur' | 'change' | 'both';
|
|
27
|
+
pattern?: RegExp;
|
|
28
|
+
patternMessage?: string;
|
|
29
|
+
showErrorOn?: 'blur' | 'change' | 'both';
|
|
59
30
|
/**
|
|
60
31
|
* Retorna somente a senha digitada (string).
|
|
61
32
|
*/
|
|
@@ -20,17 +20,18 @@ const StyledTextField = styled(TextField, {
|
|
|
20
20
|
'colorText',
|
|
21
21
|
].includes(prop),
|
|
22
22
|
})(({ theme, background, backgroundDisabled, colorText, borderRadius, boxShadow, borderColor, colorFocused, colorDisabled, padding, }) => {
|
|
23
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
23
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
24
24
|
const field = (_b = (_a = theme.pipelinesolucoes) === null || _a === void 0 ? void 0 : _a.forms) === null || _b === void 0 ? void 0 : _b.field;
|
|
25
|
-
|
|
26
|
-
const
|
|
27
|
-
const
|
|
28
|
-
const
|
|
29
|
-
const
|
|
30
|
-
const
|
|
31
|
-
const
|
|
32
|
-
const
|
|
33
|
-
const
|
|
25
|
+
// props -> tokens -> fallback
|
|
26
|
+
const bg = (_c = background !== null && background !== void 0 ? background : field === null || field === void 0 ? void 0 : field.background) !== null && _c !== void 0 ? _c : '#fff';
|
|
27
|
+
const bgDisabled = (_d = backgroundDisabled !== null && backgroundDisabled !== void 0 ? backgroundDisabled : field === null || field === void 0 ? void 0 : field.backgroundDisabled) !== null && _d !== void 0 ? _d : "#E5E7EB";
|
|
28
|
+
const txt = (_e = colorText !== null && colorText !== void 0 ? colorText : field === null || field === void 0 ? void 0 : field.color) !== null && _e !== void 0 ? _e : '#000';
|
|
29
|
+
const txtDisabled = (_f = colorDisabled !== null && colorDisabled !== void 0 ? colorDisabled : field === null || field === void 0 ? void 0 : field.colorDisabled) !== null && _f !== void 0 ? _f : "#9CA3AF";
|
|
30
|
+
const br = (_g = borderRadius !== null && borderRadius !== void 0 ? borderRadius : field === null || field === void 0 ? void 0 : field.borderRadius) !== null && _g !== void 0 ? _g : "0";
|
|
31
|
+
const sh = (_h = boxShadow !== null && boxShadow !== void 0 ? boxShadow : field === null || field === void 0 ? void 0 : field.boxShadow) !== null && _h !== void 0 ? _h : "none";
|
|
32
|
+
const bd = (_j = borderColor !== null && borderColor !== void 0 ? borderColor : field === null || field === void 0 ? void 0 : field.borderColor) !== null && _j !== void 0 ? _j : '#ccc';
|
|
33
|
+
const bdFocused = (_k = colorFocused !== null && colorFocused !== void 0 ? colorFocused : field === null || field === void 0 ? void 0 : field.colorFocused) !== null && _k !== void 0 ? _k : '#1976d2';
|
|
34
|
+
const pad = (_l = padding !== null && padding !== void 0 ? padding : field === null || field === void 0 ? void 0 : field.padding) !== null && _l !== void 0 ? _l : '4px 8px'; // pode deixar undefined se quiser respeitar o default do MUI
|
|
34
35
|
return {
|
|
35
36
|
background: bg,
|
|
36
37
|
borderRadius: br,
|
|
@@ -106,7 +107,7 @@ const StyledTextField = styled(TextField, {
|
|
|
106
107
|
* };
|
|
107
108
|
* ```
|
|
108
109
|
*/
|
|
109
|
-
const TextFieldPassword = ({ id, label, placeholder, value, onPasswordChange, onValidationChange, required = true,
|
|
110
|
+
const TextFieldPassword = ({ id, label, placeholder, value, onPasswordChange, onValidationChange, required = true, pattern = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[^A-Za-z0-9]).{8,}$/, requiredMessage = 'Senha obrigatória', patternMessage = 'Senha inválida', showErrorOn = 'blur', background, backgroundDisabled, color, colorFocused, colorDisabled, borderRadius, boxShadow, borderColor, disabled = false, padding, onChange, onBlur, }) => {
|
|
110
111
|
const [showPassword, setShowPassword] = React.useState(false);
|
|
111
112
|
const [touched, setTouched] = React.useState(false);
|
|
112
113
|
// fallback interno caso o usuário não use `value`
|
|
@@ -121,15 +122,15 @@ const TextFieldPassword = ({ id, label, placeholder, value, onPasswordChange, on
|
|
|
121
122
|
if (required && trimmed.length === 0) {
|
|
122
123
|
return { isValid: false, status: 'required', message: requiredMessage, value: nextValue };
|
|
123
124
|
}
|
|
124
|
-
if (trimmed.length > 0 &&
|
|
125
|
-
return { isValid: false, status: 'invalid', message:
|
|
125
|
+
if (trimmed.length > 0 && pattern && !pattern.test(trimmed)) {
|
|
126
|
+
return { isValid: false, status: 'invalid', message: patternMessage, value: nextValue };
|
|
126
127
|
}
|
|
127
128
|
// se não é required e está vazio, consideramos "idle" (sem erro)
|
|
128
129
|
if (!required && trimmed.length === 0) {
|
|
129
130
|
return { isValid: true, status: 'idle', message: '', value: nextValue };
|
|
130
131
|
}
|
|
131
132
|
return { isValid: true, status: 'valid', message: '', value: nextValue };
|
|
132
|
-
}, [
|
|
133
|
+
}, [patternMessage, pattern, required, requiredMessage]);
|
|
133
134
|
const emitValidation = React.useCallback((nextValue) => {
|
|
134
135
|
const result = computeValidation(nextValue);
|
|
135
136
|
if (onValidationChange)
|
|
@@ -137,8 +138,8 @@ const TextFieldPassword = ({ id, label, placeholder, value, onPasswordChange, on
|
|
|
137
138
|
return result;
|
|
138
139
|
}, [computeValidation, onValidationChange]);
|
|
139
140
|
const [validation, setValidation] = React.useState(() => computeValidation(currentValue));
|
|
140
|
-
const shouldValidateOnChange =
|
|
141
|
-
const shouldValidateOnBlur =
|
|
141
|
+
const shouldValidateOnChange = showErrorOn === 'change' || showErrorOn === 'both';
|
|
142
|
+
const shouldValidateOnBlur = showErrorOn === 'blur' || showErrorOn === 'both';
|
|
142
143
|
const handleChange = (event) => {
|
|
143
144
|
const nextValue = event.target.value;
|
|
144
145
|
// atualiza interno caso não seja controlado
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextFieldPassword.js","sourceRoot":"","sources":["../../src/components/TextFieldPassword.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,SAAS,MAAM,yBAAyB,CAAC;AAChD,OAAO,cAAc,MAAM,8BAA8B,CAAC;AAC1D,OAAO,UAAU,MAAM,0BAA0B,CAAC;AAClD,OAAO,cAAc,MAAM,gCAAgC,CAAC;AAC5D,OAAO,iBAAiB,MAAM,mCAAmC,CAAC;AAClE,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"TextFieldPassword.js","sourceRoot":"","sources":["../../src/components/TextFieldPassword.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,SAAS,MAAM,yBAAyB,CAAC;AAChD,OAAO,cAAc,MAAM,8BAA8B,CAAC;AAC1D,OAAO,UAAU,MAAM,0BAA0B,CAAC;AAClD,OAAO,cAAc,MAAM,gCAAgC,CAAC;AAC5D,OAAO,iBAAiB,MAAM,mCAAmC,CAAC;AAClE,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAoD9C,MAAM,eAAe,GAAG,MAAM,CAAC,SAAS,EAAE;IACxC,iBAAiB,EAAE,CAAC,IAAI,EAAE,EAAE,CAC1B,CAAC;QACC,YAAY;QACZ,cAAc;QACd,WAAW;QACX,aAAa;QACb,cAAc;QACd,oBAAoB;QACpB,eAAe;QACf,SAAS;QACT,WAAW;KACZ,CAAC,QAAQ,CAAC,IAAc,CAAC;CAC7B,CAAC,CAWA,CAAC,EACC,KAAK,EACL,UAAU,EACV,kBAAkB,EAClB,SAAS,EACT,YAAY,EACZ,SAAS,EACT,WAAW,EACX,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,EAC1B,SAAS,EAAE,SAAS,EACpB,WAAW,EAAE,WAAW,EACxB,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,EAClB,SAAS,QACT,KAAK,EAAE,eAAe,EACtB,UAAU,EAAE,UAAU,EACtB,SAAS,EAAE;YACT,KAAK,EAAE;gBACL,YAAY,EAAE,CACZ,KAAC,cAAc,IAAC,QAAQ,EAAC,KAAK,YAC5B,KAAC,UAAU,IACT,OAAO,EAAE,GAAG,EAAE,CAAC,eAAe,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,EAC/C,IAAI,EAAC,KAAK,gBACE,YAAY,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,eAAe,YAE3D,YAAY,CAAC,CAAC,CAAC,KAAC,iBAAiB,KAAG,CAAC,CAAC,CAAC,KAAC,cAAc,KAAG,GAC/C,GACE,CAClB;aACF;SACF,EACD,QAAQ,EAAE,YAAY,EACtB,MAAM,EAAE,UAAU,GAClB,CACH,CAAC;AACJ,CAAC,CAAC;AAEF,iBAAiB,CAAC,WAAW,GAAG,mBAAmB,CAAC;AAEpD,eAAe,iBAAiB,CAAC"}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { BorderProps } from '
|
|
3
|
-
import { ColorProps } from '../types/ColorProps';
|
|
4
|
-
import { LayoutProps } from '../types/LayoutProps';
|
|
2
|
+
import { BorderProps, ColorProps, LayoutProps } from '@pipelinesolucoes/theme';
|
|
5
3
|
interface TextFieldValidateProps extends BorderProps, ColorProps, LayoutProps {
|
|
6
4
|
id?: string;
|
|
7
5
|
label?: string;
|
|
@@ -16,17 +14,18 @@ interface TextFieldValidateProps extends BorderProps, ColorProps, LayoutProps {
|
|
|
16
14
|
boxShadow?: string;
|
|
17
15
|
borderColor?: string;
|
|
18
16
|
padding?: string;
|
|
17
|
+
margin?: string;
|
|
19
18
|
disabled?: boolean;
|
|
20
|
-
multiline?: boolean;
|
|
21
|
-
rows?: number;
|
|
22
19
|
required?: boolean;
|
|
23
20
|
requiredMessage?: string;
|
|
24
21
|
pattern?: RegExp | string;
|
|
25
22
|
patternMessage?: string;
|
|
26
|
-
validate?: (value: string) => string | null | undefined;
|
|
27
23
|
showErrorOn?: 'change' | 'blur';
|
|
28
24
|
minLength?: number;
|
|
29
25
|
maxLength?: number;
|
|
26
|
+
multiline?: boolean;
|
|
27
|
+
rows?: number;
|
|
28
|
+
validate?: (value: string) => string | null | undefined;
|
|
30
29
|
onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
31
30
|
onBlur?: (event: React.FocusEvent<HTMLInputElement>) => void;
|
|
32
31
|
}
|
|
@@ -14,19 +14,20 @@ const StyledTextField = styled(TextField, {
|
|
|
14
14
|
"padding",
|
|
15
15
|
"colorText",
|
|
16
16
|
].includes(prop),
|
|
17
|
-
})(({ theme, background, backgroundDisabled, colorText, borderRadius, boxShadow, borderColor, colorFocused, colorDisabled, padding, }) => {
|
|
18
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
17
|
+
})(({ theme, background, backgroundDisabled, colorText, borderRadius, boxShadow, borderColor, colorFocused, colorDisabled, padding, margin }) => {
|
|
18
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
19
19
|
const field = (_b = (_a = theme.pipelinesolucoes) === null || _a === void 0 ? void 0 : _a.forms) === null || _b === void 0 ? void 0 : _b.field;
|
|
20
20
|
// props -> tokens -> fallback
|
|
21
|
-
const bg = (_c = background !== null && background !== void 0 ? background : field === null || field === void 0 ? void 0 : field.background) !== null && _c !== void 0 ? _c :
|
|
22
|
-
const bgDisabled = (_d = backgroundDisabled !== null && backgroundDisabled !== void 0 ? backgroundDisabled : field === null || field === void 0 ? void 0 : field.backgroundDisabled) !== null && _d !== void 0 ? _d :
|
|
23
|
-
const txt = (_e = colorText !== null && colorText !== void 0 ? colorText : field === null || field === void 0 ? void 0 : field.color) !== null && _e !== void 0 ? _e :
|
|
24
|
-
const txtDisabled = (_f = colorDisabled !== null && colorDisabled !== void 0 ? colorDisabled : field === null || field === void 0 ? void 0 : field.colorDisabled) !== null && _f !== void 0 ? _f :
|
|
25
|
-
const br = (_g = borderRadius !== null && borderRadius !== void 0 ? borderRadius : field === null || field === void 0 ? void 0 : field.borderRadius) !== null && _g !== void 0 ? _g : "
|
|
21
|
+
const bg = (_c = background !== null && background !== void 0 ? background : field === null || field === void 0 ? void 0 : field.background) !== null && _c !== void 0 ? _c : '#fff';
|
|
22
|
+
const bgDisabled = (_d = backgroundDisabled !== null && backgroundDisabled !== void 0 ? backgroundDisabled : field === null || field === void 0 ? void 0 : field.backgroundDisabled) !== null && _d !== void 0 ? _d : "#E5E7EB";
|
|
23
|
+
const txt = (_e = colorText !== null && colorText !== void 0 ? colorText : field === null || field === void 0 ? void 0 : field.color) !== null && _e !== void 0 ? _e : '#000';
|
|
24
|
+
const txtDisabled = (_f = colorDisabled !== null && colorDisabled !== void 0 ? colorDisabled : field === null || field === void 0 ? void 0 : field.colorDisabled) !== null && _f !== void 0 ? _f : "#9CA3AF";
|
|
25
|
+
const br = (_g = borderRadius !== null && borderRadius !== void 0 ? borderRadius : field === null || field === void 0 ? void 0 : field.borderRadius) !== null && _g !== void 0 ? _g : "0";
|
|
26
26
|
const sh = (_h = boxShadow !== null && boxShadow !== void 0 ? boxShadow : field === null || field === void 0 ? void 0 : field.boxShadow) !== null && _h !== void 0 ? _h : "none";
|
|
27
|
-
const bd = (_j = borderColor !== null && borderColor !== void 0 ? borderColor : field === null || field === void 0 ? void 0 : field.borderColor) !== null && _j !== void 0 ? _j :
|
|
28
|
-
const bdFocused = (_k = colorFocused !== null && colorFocused !== void 0 ? colorFocused : field === null || field === void 0 ? void 0 : field.colorFocused) !== null && _k !== void 0 ? _k :
|
|
29
|
-
const pad = padding !== null && padding !== void 0 ? padding : field === null || field === void 0 ? void 0 : field.padding; // pode deixar undefined se quiser respeitar o default do MUI
|
|
27
|
+
const bd = (_j = borderColor !== null && borderColor !== void 0 ? borderColor : field === null || field === void 0 ? void 0 : field.borderColor) !== null && _j !== void 0 ? _j : '#ccc';
|
|
28
|
+
const bdFocused = (_k = colorFocused !== null && colorFocused !== void 0 ? colorFocused : field === null || field === void 0 ? void 0 : field.colorFocused) !== null && _k !== void 0 ? _k : '#1976d2';
|
|
29
|
+
const pad = (_l = padding !== null && padding !== void 0 ? padding : field === null || field === void 0 ? void 0 : field.padding) !== null && _l !== void 0 ? _l : '4px 8px'; // pode deixar undefined se quiser respeitar o default do MUI
|
|
30
|
+
const mg = (_m = margin !== null && margin !== void 0 ? margin : field === null || field === void 0 ? void 0 : field.margin) !== null && _m !== void 0 ? _m : '0';
|
|
30
31
|
return {
|
|
31
32
|
// (opcional) pode manter, mas o mais importante é estilizar os slots internos:
|
|
32
33
|
background: bg,
|
|
@@ -144,7 +145,7 @@ const computeError = (value, { required, requiredMessage, minLength, pattern, pa
|
|
|
144
145
|
* };
|
|
145
146
|
* ```
|
|
146
147
|
*/
|
|
147
|
-
const TextFieldValidate = ({ id, label, background
|
|
148
|
+
const TextFieldValidate = ({ id, label, background, backgroundDisabled, color, colorFocused, colorDisabled, borderRadius, boxShadow, borderColor, placeholder, disabled = false, value = '', onChange, onBlur, multiline = false, rows = 3, required = false, requiredMessage = 'Campo obrigatório', minLength, pattern, patternMessage = 'Formato inválido', validate, showErrorOn = 'blur', maxLength, padding }) => {
|
|
148
149
|
const [touched, setTouched] = React.useState(false);
|
|
149
150
|
const errorMessage = React.useMemo(() => {
|
|
150
151
|
if (showErrorOn === 'change') {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextFieldValidate.js","sourceRoot":"","sources":["../../src/components/TextFieldValidate.tsx"],"names":[],"mappings":";AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,SAAS,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 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Retorno do onClick/onSubmit do componente pai.
|
|
3
|
+
* - success: define se a ação foi bem sucedida
|
|
4
|
+
* - message: mensagem para exibir no próprio FormLogin
|
|
5
|
+
* - color: cor opcional para a mensagem (caso queira sobrescrever as cores padrão)
|
|
6
|
+
*/
|
|
7
|
+
export interface ClickResult {
|
|
8
|
+
success: boolean;
|
|
9
|
+
message: string;
|
|
10
|
+
color?: string;
|
|
11
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ClickResult.js","sourceRoot":"","sources":["../../../src/components/login/ClickResult.ts"],"names":[],"mappings":""}
|
|
@@ -3,159 +3,25 @@ import { TypographyVariant } from '@mui/material/styles';
|
|
|
3
3
|
import { SvgIconProps } from '@mui/material';
|
|
4
4
|
import { ButtonProps } from '../../types/ButtonProps';
|
|
5
5
|
import { FieldProps } from '@/types/FieldProps';
|
|
6
|
-
import { ColorProps } from '
|
|
7
|
-
import {
|
|
8
|
-
/**
|
|
9
|
-
* Retorno do onClick/onSubmit do componente pai.
|
|
10
|
-
* - success: define se a ação foi bem sucedida
|
|
11
|
-
* - message: mensagem para exibir no próprio FormLogin
|
|
12
|
-
* - color: cor opcional para a mensagem (caso queira sobrescrever as cores padrão)
|
|
13
|
-
*/
|
|
14
|
-
export interface ClickResult {
|
|
15
|
-
success: boolean;
|
|
16
|
-
message: string;
|
|
17
|
-
color?: string;
|
|
18
|
-
}
|
|
6
|
+
import { BorderProps, ColorProps } from '@pipelinesolucoes/theme';
|
|
7
|
+
import { ClickResult } from './ClickResult';
|
|
19
8
|
export interface FormLoginProps extends ColorProps, BorderProps, ButtonProps, FieldProps {
|
|
9
|
+
urlRecuperarConta: string;
|
|
10
|
+
urlCriarConta: string;
|
|
20
11
|
Icon?: React.ElementType<SvgIconProps>;
|
|
21
12
|
titulo?: () => React.ReactElement;
|
|
22
13
|
googleButton: () => React.ReactElement;
|
|
23
|
-
color: string;
|
|
24
|
-
background?: string;
|
|
25
|
-
borderRadius?: string;
|
|
26
|
-
border?: string;
|
|
27
|
-
boxShadow?: string;
|
|
28
|
-
backgroundField?: string;
|
|
29
|
-
colorField?: string;
|
|
30
|
-
colorFocusedField?: string;
|
|
31
|
-
borderRadiusField?: string;
|
|
32
|
-
boxShadowField?: string;
|
|
33
|
-
borderColorField?: string;
|
|
34
|
-
paddingField?: string;
|
|
35
14
|
textButton?: string;
|
|
36
15
|
variantButton?: TypographyVariant;
|
|
37
|
-
backgroundButton?: string;
|
|
38
|
-
backgroundHoverButton?: string;
|
|
39
|
-
colorButton?: string;
|
|
40
|
-
colorHoverButton?: string;
|
|
41
|
-
borderRadiusButton?: string;
|
|
42
|
-
borderButton?: string;
|
|
43
|
-
boxShadowButton?: string;
|
|
44
|
-
widthButton?: string;
|
|
45
|
-
heightButton?: string;
|
|
46
|
-
paddingButton?: string;
|
|
47
|
-
marginButton?: string;
|
|
48
|
-
/** Cores padrão para mensagem (caso o pai não retorne color no ClickResult) */
|
|
49
16
|
color_message_sucess: string;
|
|
50
17
|
color_message_erro: string;
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
urlRecuperarConta: string;
|
|
54
|
-
urlCriarConta: string;
|
|
18
|
+
colorLink: string;
|
|
19
|
+
divider: string;
|
|
55
20
|
children?: React.ReactNode;
|
|
56
|
-
/**
|
|
57
|
-
* Evento disparado ao clicar no botão principal.
|
|
58
|
-
* O componente pai devolve a mensagem e o sucesso/erro.
|
|
59
|
-
*/
|
|
60
21
|
onClick?: (data: {
|
|
61
22
|
email: string;
|
|
62
23
|
password: string;
|
|
63
24
|
}) => Promise<ClickResult> | ClickResult;
|
|
64
25
|
}
|
|
65
|
-
/**
|
|
66
|
-
* Componente de formulário de login com suporte a autenticação via Google e login por email/senha.
|
|
67
|
-
* Inclui validação básica de email, exibição de mensagens de erro/sucesso retornadas pelo handler `onClick`
|
|
68
|
-
* e customização visual via props (container, campos, botão e links).
|
|
69
|
-
*
|
|
70
|
-
* @param {string} urlRecuperarConta URL para a página de recuperação de conta/senha. Obrigatório.
|
|
71
|
-
* @param {string} urlCriarConta URL para a página de criação de conta. Obrigatório.
|
|
72
|
-
* @param {React.ElementType<SvgIconProps>} [Icon] Ícone opcional (MUI SvgIcon) exibido no topo do formulário.
|
|
73
|
-
* @param {() => React.ReactElement} [titulo] Função que retorna o conteúdo do título exibido no topo do formulário.
|
|
74
|
-
* @param {() => React.ReactElement} googleButton Função que retorna o botão de login com Google. Obrigatório.
|
|
75
|
-
*
|
|
76
|
-
* @param {string} color Cor usada em alguns textos/containers auxiliares (ex.: wrapper dos links). Obrigatório.
|
|
77
|
-
* @param {string} [background='transparent'] Cor de fundo do container principal.
|
|
78
|
-
* @param {string} [borderRadius='0'] Raio da borda do container principal.
|
|
79
|
-
* @param {string} [border='none'] Borda do container principal.
|
|
80
|
-
* @param {string} [boxShadow='none'] Sombra do container principal.
|
|
81
|
-
*
|
|
82
|
-
* @param {string} [backgroundField='transparent'] Fundo dos campos (email/senha).
|
|
83
|
-
* @param {string} [colorField='#000'] Cor do texto dos campos (email/senha).
|
|
84
|
-
* @param {string} [colorFocusedField] Cor do estado focado do campo (se suportado pelos campos internos).
|
|
85
|
-
* @param {string} [borderRadiusField='0px'] Raio da borda dos campos.
|
|
86
|
-
* @param {string} [boxShadowField='none'] Sombra dos campos.
|
|
87
|
-
* @param {string} [borderColorField='#ccc'] Cor da borda dos campos.
|
|
88
|
-
* @param {string} [paddingField='4px 8px'] Espaçamento interno dos campos.
|
|
89
|
-
*
|
|
90
|
-
* @param {string} [textButton='Enviar'] Texto do botão principal.
|
|
91
|
-
* @param {TypographyVariant} [variantButton='body1'] Variante do Typography usada no texto do botão.
|
|
92
|
-
* @param {string} [backgroundButton='transparent'] Fundo do botão principal.
|
|
93
|
-
* @param {string} [backgroundHoverButton='transparent'] Fundo do botão no hover.
|
|
94
|
-
* @param {string} [colorButton='#000'] Cor do texto do botão.
|
|
95
|
-
* @param {string} [colorHoverButton='#000'] Cor do texto do botão no hover.
|
|
96
|
-
* @param {string} [borderRadiusButton='0'] Raio da borda do botão.
|
|
97
|
-
* @param {string} [borderButton='none'] Borda do botão.
|
|
98
|
-
* @param {string} [boxShadowButton='none'] Sombra do botão.
|
|
99
|
-
* @param {string} [widthButton='auto'] Largura do botão.
|
|
100
|
-
* @param {string} [heightButton='auto'] Altura do botão.
|
|
101
|
-
* @param {string} [paddingButton='4px 24px'] Padding do botão.
|
|
102
|
-
* @param {string} [marginButton='0'] Margem do botão.
|
|
103
|
-
*
|
|
104
|
-
* @param {string} color_message_sucess Cor padrão para mensagem de sucesso (caso `onClick` não retorne `color`). Obrigatório.
|
|
105
|
-
* @param {string} color_message_erro Cor padrão para mensagem de erro (caso `onClick` não retorne `color`). Obrigatório.
|
|
106
|
-
* @param {string} color_link Cor aplicada nos links "Esqueceu sua senha?" e "Criar conta". Obrigatório.
|
|
107
|
-
* @param {string} color_separador Cor da linha separadora (Divider). Obrigatório.
|
|
108
|
-
*
|
|
109
|
-
* @param {(data: { email: string; password: string }) => Promise<ClickResult> | ClickResult} [onClick]
|
|
110
|
-
* Handler chamado ao submeter o formulário. Recebe `{ email, password }` e deve retornar um `ClickResult`.
|
|
111
|
-
* - Se `success` for `true`, exibe `message` com `color_message_sucess` (ou `result.color` se fornecida)
|
|
112
|
-
* - Se `success` for `false`, exibe `message` com `color_message_erro` (ou `result.color` se fornecida)
|
|
113
|
-
* Se não for informado, o componente exibirá a mensagem: "Nenhuma ação foi configurada para o botão.".
|
|
114
|
-
*
|
|
115
|
-
* @param {React.ReactNode} [children] Conteúdo extra renderizado ao final do container (abaixo da mensagem).
|
|
116
|
-
*
|
|
117
|
-
* @example
|
|
118
|
-
* ```tsx
|
|
119
|
-
* import FormLogin from '@/components/FormLogin';
|
|
120
|
-
* import LockOutlinedIcon from '@mui/icons-material/LockOutlined';
|
|
121
|
-
* import { Button } from '@mui/material';
|
|
122
|
-
*
|
|
123
|
-
* export default function Example() {
|
|
124
|
-
* return (
|
|
125
|
-
* <FormLogin
|
|
126
|
-
* urlRecuperarConta="/recuperar"
|
|
127
|
-
* urlCriarConta="/cadastro"
|
|
128
|
-
* Icon={LockOutlinedIcon}
|
|
129
|
-
* titulo={() => <h2>Entrar</h2>}
|
|
130
|
-
* googleButton={() => <Button variant="outlined">Continuar com Google</Button>}
|
|
131
|
-
* color="#111"
|
|
132
|
-
* background="#fff"
|
|
133
|
-
* borderRadius="12px"
|
|
134
|
-
* boxShadow="0 10px 30px rgba(0,0,0,0.08)"
|
|
135
|
-
* backgroundField="#fafafa"
|
|
136
|
-
* borderColorField="#e0e0e0"
|
|
137
|
-
* paddingField="10px 12px"
|
|
138
|
-
* textButton="Acessar"
|
|
139
|
-
* backgroundButton="#111"
|
|
140
|
-
* backgroundHoverButton="#000"
|
|
141
|
-
* colorButton="#fff"
|
|
142
|
-
* colorHoverButton="#fff"
|
|
143
|
-
* borderRadiusButton="10px"
|
|
144
|
-
* paddingButton="10px 16px"
|
|
145
|
-
* color_message_sucess="#1b5e20"
|
|
146
|
-
* color_message_erro="#b71c1c"
|
|
147
|
-
* color_link="#1976d2"
|
|
148
|
-
* color_separador="#e0e0e0"
|
|
149
|
-
* onClick={async ({ email, password }) => {
|
|
150
|
-
* if (email === 'teste@exemplo.com' && password === '123') {
|
|
151
|
-
* return { success: true, message: 'Login realizado com sucesso!' };
|
|
152
|
-
* }
|
|
153
|
-
* return { success: false, message: 'Email ou senha inválidos.' };
|
|
154
|
-
* }}
|
|
155
|
-
* />
|
|
156
|
-
* );
|
|
157
|
-
* }
|
|
158
|
-
* ```
|
|
159
|
-
*/
|
|
160
26
|
declare const FormLogin: React.FC<FormLoginProps>;
|
|
161
27
|
export default FormLogin;
|