@pipelinesolucoes/form 1.2.0-beta.3 → 1.2.0-beta.30
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/README.md +16 -2
- package/dist/components/ChipList.d.ts +9 -0
- package/dist/components/ChipList.js +60 -0
- package/dist/components/ChipList.js.map +1 -0
- package/dist/components/SelectField.d.ts +73 -0
- package/dist/components/SelectField.js +142 -0
- package/dist/components/SelectField.js.map +1 -0
- package/dist/components/TextFieldBirthDateWithAge.d.ts +83 -0
- package/dist/components/TextFieldBirthDateWithAge.js +259 -0
- package/dist/components/TextFieldBirthDateWithAge.js.map +1 -0
- package/dist/components/TextFieldCPFValidate.d.ts +37 -0
- package/dist/components/TextFieldCPFValidate.js +147 -0
- package/dist/components/TextFieldCPFValidate.js.map +1 -0
- package/dist/components/TextFieldNumberValidate.d.ts +110 -0
- package/dist/components/TextFieldNumberValidate.js +196 -0
- package/dist/components/TextFieldNumberValidate.js.map +1 -0
- package/dist/components/TextFieldPassword.d.ts +141 -53
- package/dist/components/TextFieldPassword.js +161 -98
- package/dist/components/TextFieldPassword.js.map +1 -1
- package/dist/components/TextFieldValidate.d.ts +89 -43
- package/dist/components/TextFieldValidate.js +103 -94
- package/dist/components/TextFieldValidate.js.map +1 -1
- package/dist/components/login/FormLogin.d.ts +129 -6
- package/dist/components/login/FormLogin.js +155 -29
- package/dist/components/login/FormLogin.js.map +1 -1
- package/dist/components/login/FormPasswordRecovery.d.ts +97 -89
- package/dist/components/login/FormPasswordRecovery.js +131 -124
- package/dist/components/login/FormPasswordRecovery.js.map +1 -1
- package/dist/components/login/FormSignUp.d.ts +130 -11
- package/dist/components/login/FormSignUp.js +154 -29
- package/dist/components/login/FormSignUp.js.map +1 -1
- package/dist/components/login/StyleLogin.d.ts +7 -0
- package/dist/components/login/StyleLogin.js +16 -1
- package/dist/components/login/StyleLogin.js.map +1 -1
- package/dist/components/recaptcha/RecaptchaForm.d.ts +8 -14
- package/dist/components/recaptcha/RecaptchaForm.js +30 -25
- package/dist/components/recaptcha/RecaptchaForm.js.map +1 -1
- package/dist/constant.d.ts +11 -0
- package/dist/constant.js +12 -0
- package/dist/constant.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -1
- package/dist/{components/style → style}/ButtonFormStyled.d.ts +1 -1
- package/dist/{components/style → style}/ButtonFormStyled.js +6 -5
- package/dist/style/ButtonFormStyled.js.map +1 -0
- package/dist/{components/style → style}/LinkFormStyled.d.ts +1 -1
- package/dist/{components/style → style}/LinkFormStyled.js +5 -4
- package/dist/style/LinkFormStyled.js.map +1 -0
- package/dist/style/TextFieldStyle.d.ts +19 -0
- package/dist/style/TextFieldStyle.js +61 -0
- package/dist/style/TextFieldStyle.js.map +1 -0
- package/dist/theme.js +46 -18
- package/dist/theme.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/FieldProps.d.ts +1 -0
- package/dist/utils/formatCEP.d.ts +20 -0
- package/dist/utils/formatCEP.js +35 -0
- package/dist/utils/formatCEP.js.map +1 -0
- package/dist/utils/formatCpf.d.ts +14 -0
- package/dist/utils/formatCpf.js +35 -0
- package/dist/utils/formatCpf.js.map +1 -0
- package/dist/utils/validateCpf.d.ts +40 -0
- package/dist/utils/validateCpf.js +67 -0
- package/dist/utils/validateCpf.js.map +1 -0
- package/dist/utils/validateEmail.js +1 -1
- package/dist/utils/validateEmail.js.map +1 -1
- package/package.json +4 -2
- package/dist/components/recaptcha/FormStyled.d.ts +0 -30
- package/dist/components/recaptcha/FormStyled.js +0 -67
- package/dist/components/recaptcha/FormStyled.js.map +0 -1
- package/dist/components/style/ButtonFormStyled.js.map +0 -1
- package/dist/components/style/LinkFormStyled.js.map +0 -1
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { useTheme } from '@mui/material/styles';
|
|
4
|
+
import { TextFieldStyled } from '../style/TextFieldStyle';
|
|
5
|
+
import { fbbackground, fbbackgroundDisabled, fbborderColor, fbborderRadius, fbboxShadow, fbcolor, fbcolorDisabled, fbcolorFocused, fbheigth, fbpadding, } from '../constant';
|
|
6
|
+
const computeError = (value, { required, requiredMessage, minLength, pattern, patternMessage, validate, }) => {
|
|
7
|
+
const v = value !== null && value !== void 0 ? value : '';
|
|
8
|
+
if (required && v.trim().length === 0)
|
|
9
|
+
return requiredMessage || 'Campo obrigatório';
|
|
10
|
+
if (typeof minLength === 'number' && v.length < minLength)
|
|
11
|
+
return `Mínimo de ${minLength} caracteres`;
|
|
12
|
+
if (pattern) {
|
|
13
|
+
const re = typeof pattern === 'string' ? new RegExp(pattern) : pattern;
|
|
14
|
+
if (!re.test(v))
|
|
15
|
+
return patternMessage || 'Formato inválido';
|
|
16
|
+
}
|
|
17
|
+
if (validate) {
|
|
18
|
+
const customMsg = validate(v);
|
|
19
|
+
if (typeof customMsg === 'string' && customMsg)
|
|
20
|
+
return customMsg;
|
|
21
|
+
}
|
|
22
|
+
return null;
|
|
23
|
+
};
|
|
24
|
+
const sanitizeNumeric = (raw) => (raw !== null && raw !== void 0 ? raw : '').replace(/[^\d]/g, '');
|
|
25
|
+
/**
|
|
26
|
+
* Campo de texto numérico com suporte a validações comuns e customizadas, construído
|
|
27
|
+
* sobre o TextField do Material UI e estilizado via Design System da Pipeline.
|
|
28
|
+
*
|
|
29
|
+
* Diferença principal:
|
|
30
|
+
* - Este componente **aceita apenas números (0–9)**, removendo automaticamente qualquer caractere não numérico.
|
|
31
|
+
*
|
|
32
|
+
* Funcionalidades principais:
|
|
33
|
+
* - Suporte a modo controlado (`value`)
|
|
34
|
+
* - Validações nativas (obrigatório, tamanho mínimo, regex)
|
|
35
|
+
* - Validação customizada via função
|
|
36
|
+
* - Controle de momento de exibição do erro (`change` ou `blur`)
|
|
37
|
+
* - Suporte a campo multilinha (mantido por compatibilidade)
|
|
38
|
+
* - Customização visual via props e tokens de theme
|
|
39
|
+
*
|
|
40
|
+
* Tokens de estilo (ordem de prioridade):
|
|
41
|
+
* - `prop` do componente
|
|
42
|
+
* - `theme.pipelinesolucoes.forms.field`
|
|
43
|
+
* - Fallback interno (constantes `fb*`)
|
|
44
|
+
*
|
|
45
|
+
* Tipografia:
|
|
46
|
+
* - Suporte à tipografia do Material UI via `textVariant`
|
|
47
|
+
* - Fallback para `theme.pipelinesolucoes.forms.field.typography`
|
|
48
|
+
* - Fallback final para `theme.typography.body1`
|
|
49
|
+
*
|
|
50
|
+
* @param {string} [id] Identificador do campo, repassado ao input do Material UI.
|
|
51
|
+
* @param {string} [label] Texto do rótulo exibido acima do campo.
|
|
52
|
+
* @param {string} [placeholder] Texto exibido quando o campo está vazio.
|
|
53
|
+
* @param {string} [value] Valor atual do campo (modo controlado). Somente dígitos serão mantidos.
|
|
54
|
+
*
|
|
55
|
+
* @param {boolean} [disabled=false] Define se o campo está desabilitado.
|
|
56
|
+
*
|
|
57
|
+
* @param {number} [minLength] Número mínimo de caracteres permitidos.
|
|
58
|
+
* @param {number} [maxLength] Número máximo de caracteres permitidos.
|
|
59
|
+
*
|
|
60
|
+
* @param {boolean} [multiline=false] Define se o campo aceita múltiplas linhas (mantido por compatibilidade).
|
|
61
|
+
* @param {number} [rows=3] Quantidade de linhas visíveis quando `multiline` está ativo.
|
|
62
|
+
*
|
|
63
|
+
* ### Estilo / Aparência
|
|
64
|
+
* @param {import('@mui/material/styles').TypographyVariant} [textVariant] Variante tipográfica do Material UI aplicada ao texto e placeholder.
|
|
65
|
+
* @param {string} [background] Cor de fundo do campo.
|
|
66
|
+
* @param {string} [backgroundDisabled] Cor de fundo do campo quando desabilitado.
|
|
67
|
+
* @param {string} [backgroundFocused] Cor de fundo do campo quando focado.
|
|
68
|
+
* @param {string} [color] Cor do texto do campo (texto digitado e label).
|
|
69
|
+
* @param {string} [colorFocused] Cor aplicada ao estado focado (usada como cor de borda no focus).
|
|
70
|
+
* @param {string} [colorDisabled] Cor do texto do campo quando desabilitado.
|
|
71
|
+
* @param {string} [borderRadius] Raio da borda do campo.
|
|
72
|
+
* @param {string} [boxShadow] Sombra do campo.
|
|
73
|
+
* @param {string} [borderColor] Cor da borda do campo (estado padrão/hover).
|
|
74
|
+
* @param {string} [padding] Espaçamento interno do input (aplicado no texto e textarea).
|
|
75
|
+
*
|
|
76
|
+
* ---
|
|
77
|
+
* ### Validação
|
|
78
|
+
* @param {boolean} [required=false] Indica se o campo é obrigatório.
|
|
79
|
+
* @param {string} [requiredMessage] Mensagem exibida quando o campo obrigatório está vazio.
|
|
80
|
+
* @param {RegExp | string} [pattern] Expressão regular utilizada para validação do valor (aplicada após sanitização numérica).
|
|
81
|
+
* @param {string} [patternMessage] Mensagem exibida quando o valor não atende ao pattern.
|
|
82
|
+
* @param {'change' | 'blur'} [showErrorOn='blur'] Define quando o erro será exibido.
|
|
83
|
+
* @param {(value: string) => string | null | undefined} [validate] Função de validação customizada (recebe o valor sanitizado).
|
|
84
|
+
*
|
|
85
|
+
* ---
|
|
86
|
+
* ### Eventos
|
|
87
|
+
* @param {(event: React.ChangeEvent<HTMLInputElement>) => void} [onChange] Callback disparado ao alterar o valor (com `event.target.value` já sanitizado).
|
|
88
|
+
* @param {(event: React.FocusEvent<HTMLInputElement>) => void} [onBlur] Callback disparado ao perder o foco.
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* ```tsx
|
|
92
|
+
* const Example = () => {
|
|
93
|
+
* const [age, setAge] = React.useState('');
|
|
94
|
+
*
|
|
95
|
+
* return (
|
|
96
|
+
* <TextFieldNumberValidate
|
|
97
|
+
* label="Idade"
|
|
98
|
+
* placeholder="Somente números"
|
|
99
|
+
* value={age}
|
|
100
|
+
* onChange={(e) => setAge(e.target.value)}
|
|
101
|
+
* required
|
|
102
|
+
* minLength={1}
|
|
103
|
+
* maxLength={3}
|
|
104
|
+
* showErrorOn="blur"
|
|
105
|
+
* borderRadius="6px"
|
|
106
|
+
* textVariant="subtitle2"
|
|
107
|
+
* />
|
|
108
|
+
* );
|
|
109
|
+
* };
|
|
110
|
+
* ```
|
|
111
|
+
*/
|
|
112
|
+
const TextFieldNumberValidate = ({ id, label, placeholder, value = '', textVariant, background, backgroundFocused, backgroundDisabled, color, colorFocused, colorDisabled, borderRadius, boxShadow, borderColor, padding, height, disabled = false, maxLength, minLength, required = false, requiredMessage = 'campo obrigatório', pattern, patternMessage = 'formato inválido', validate, showErrorOn = 'blur', onChange, onBlur, }) => {
|
|
113
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
114
|
+
const [touched, setTouched] = React.useState(false);
|
|
115
|
+
const sanitizedValue = React.useMemo(() => sanitizeNumeric(value), [value]);
|
|
116
|
+
const errorMessage = React.useMemo(() => {
|
|
117
|
+
const v = sanitizedValue;
|
|
118
|
+
if (showErrorOn === 'change') {
|
|
119
|
+
return computeError(v, { required, requiredMessage, minLength, pattern, patternMessage, validate });
|
|
120
|
+
}
|
|
121
|
+
if (showErrorOn === 'blur' && touched) {
|
|
122
|
+
return computeError(v, { required, requiredMessage, minLength, pattern, patternMessage, validate });
|
|
123
|
+
}
|
|
124
|
+
return null;
|
|
125
|
+
}, [
|
|
126
|
+
sanitizedValue,
|
|
127
|
+
required,
|
|
128
|
+
requiredMessage,
|
|
129
|
+
minLength,
|
|
130
|
+
pattern,
|
|
131
|
+
patternMessage,
|
|
132
|
+
validate,
|
|
133
|
+
showErrorOn,
|
|
134
|
+
touched,
|
|
135
|
+
]);
|
|
136
|
+
const handleBlur = (event) => {
|
|
137
|
+
if (!touched)
|
|
138
|
+
setTouched(true);
|
|
139
|
+
onBlur === null || onBlur === void 0 ? void 0 : onBlur(event);
|
|
140
|
+
};
|
|
141
|
+
const handleChange = (event) => {
|
|
142
|
+
if (!onChange)
|
|
143
|
+
return;
|
|
144
|
+
const next = sanitizeNumeric(event.target.value);
|
|
145
|
+
// Cria um "evento" compatível com o callback, garantindo value sanitizado
|
|
146
|
+
const syntheticEvent = Object.assign(Object.assign({}, event), { target: Object.assign(Object.assign({}, event.target), { value: next }), currentTarget: Object.assign(Object.assign({}, event.currentTarget), { value: next }) });
|
|
147
|
+
onChange(syntheticEvent);
|
|
148
|
+
};
|
|
149
|
+
const handleKeyDown = (event) => {
|
|
150
|
+
// Permite teclas de navegação/edição
|
|
151
|
+
const allowed = [
|
|
152
|
+
'Backspace',
|
|
153
|
+
'Delete',
|
|
154
|
+
'Tab',
|
|
155
|
+
'Enter',
|
|
156
|
+
'Escape',
|
|
157
|
+
'ArrowLeft',
|
|
158
|
+
'ArrowRight',
|
|
159
|
+
'ArrowUp',
|
|
160
|
+
'ArrowDown',
|
|
161
|
+
'Home',
|
|
162
|
+
'End',
|
|
163
|
+
];
|
|
164
|
+
if (allowed.includes(event.key))
|
|
165
|
+
return;
|
|
166
|
+
// Permite Ctrl/Cmd + atalhos (A, C, V, X)
|
|
167
|
+
if (event.ctrlKey || event.metaKey)
|
|
168
|
+
return;
|
|
169
|
+
// Bloqueia qualquer tecla que não seja dígito
|
|
170
|
+
if (!/^\d$/.test(event.key)) {
|
|
171
|
+
event.preventDefault();
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
const theme = useTheme();
|
|
175
|
+
const field = (_b = (_a = theme.pipelinesolucoes) === null || _a === void 0 ? void 0 : _a.forms) === null || _b === void 0 ? void 0 : _b.field;
|
|
176
|
+
const bg = (_c = background !== null && background !== void 0 ? background : field === null || field === void 0 ? void 0 : field.background) !== null && _c !== void 0 ? _c : fbbackground;
|
|
177
|
+
const bgFocused = (_d = backgroundFocused !== null && backgroundFocused !== void 0 ? backgroundFocused : field === null || field === void 0 ? void 0 : field.backgroundFocused) !== null && _d !== void 0 ? _d : bg;
|
|
178
|
+
const bgDisabled = (_e = backgroundDisabled !== null && backgroundDisabled !== void 0 ? backgroundDisabled : field === null || field === void 0 ? void 0 : field.backgroundDisabled) !== null && _e !== void 0 ? _e : fbbackgroundDisabled;
|
|
179
|
+
const txt = (_f = color !== null && color !== void 0 ? color : field === null || field === void 0 ? void 0 : field.color) !== null && _f !== void 0 ? _f : fbcolor;
|
|
180
|
+
const txtDisabled = (_g = colorDisabled !== null && colorDisabled !== void 0 ? colorDisabled : field === null || field === void 0 ? void 0 : field.colorDisabled) !== null && _g !== void 0 ? _g : fbcolorDisabled;
|
|
181
|
+
const br = (_h = borderRadius !== null && borderRadius !== void 0 ? borderRadius : field === null || field === void 0 ? void 0 : field.borderRadius) !== null && _h !== void 0 ? _h : fbborderRadius;
|
|
182
|
+
const sh = (_j = boxShadow !== null && boxShadow !== void 0 ? boxShadow : field === null || field === void 0 ? void 0 : field.boxShadow) !== null && _j !== void 0 ? _j : fbboxShadow;
|
|
183
|
+
const bd = (_k = borderColor !== null && borderColor !== void 0 ? borderColor : field === null || field === void 0 ? void 0 : field.borderColor) !== null && _k !== void 0 ? _k : fbborderColor;
|
|
184
|
+
const bdFocused = (_l = colorFocused !== null && colorFocused !== void 0 ? colorFocused : field === null || field === void 0 ? void 0 : field.colorFocused) !== null && _l !== void 0 ? _l : fbcolorFocused;
|
|
185
|
+
const pad = (_m = padding !== null && padding !== void 0 ? padding : field === null || field === void 0 ? void 0 : field.padding) !== null && _m !== void 0 ? _m : fbpadding;
|
|
186
|
+
const hg = (_o = height !== null && height !== void 0 ? height : field === null || field === void 0 ? void 0 : field.height) !== null && _o !== void 0 ? _o : fbheigth;
|
|
187
|
+
const typo = (_q = (_p = (textVariant && theme.typography[textVariant])) !== null && _p !== void 0 ? _p : field === null || field === void 0 ? void 0 : field.typography) !== null && _q !== void 0 ? _q : theme.typography.body1;
|
|
188
|
+
return (_jsx(TextFieldStyled, { id: id, label: label, placeholder: placeholder, value: sanitizedValue, typo: typo, onChange: handleChange, onBlur: handleBlur, background: bg, backgroundFocused: bgFocused, backgroundDisabled: bgDisabled, colorText: txt, colorFocused: bdFocused, colorDisabled: txtDisabled, borderRadius: br, boxShadow: sh, borderColor: bd, padding: pad, disabled: disabled, required: required, fullWidth: true, height: hg, error: Boolean(errorMessage), helperText: errorMessage || ' ', onKeyDown: handleKeyDown, slotProps: {
|
|
189
|
+
input: {
|
|
190
|
+
inputProps: Object.assign({ inputMode: 'numeric', pattern: '[0-9]*' }, (typeof maxLength === 'number' ? { maxLength } : {})),
|
|
191
|
+
},
|
|
192
|
+
} }));
|
|
193
|
+
};
|
|
194
|
+
TextFieldNumberValidate.displayName = 'TextFieldNumberValidate';
|
|
195
|
+
export default TextFieldNumberValidate;
|
|
196
|
+
//# sourceMappingURL=TextFieldNumberValidate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TextFieldNumberValidate.js","sourceRoot":"","sources":["../../src/components/TextFieldNumberValidate.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAqB,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAEnE,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EACL,YAAY,EACZ,oBAAoB,EACpB,aAAa,EACb,cAAc,EACd,WAAW,EACX,OAAO,EACP,eAAe,EACf,cAAc,EACd,QAAQ,EACR,SAAS,GACV,MAAM,aAAa,CAAC;AAgCrB,MAAM,YAAY,GAAG,CACnB,KAAa,EACb,EACE,QAAQ,EACR,eAAe,EACf,SAAS,EACT,OAAO,EACP,cAAc,EACd,QAAQ,GAIT,EACc,EAAE;IACjB,MAAM,CAAC,GAAG,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,EAAE,CAAC;IACtB,IAAI,QAAQ,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,eAAe,IAAI,mBAAmB,CAAC;IACrF,IAAI,OAAO,SAAS,KAAK,QAAQ,IAAI,CAAC,CAAC,MAAM,GAAG,SAAS;QAAE,OAAO,aAAa,SAAS,aAAa,CAAC;IAEtG,IAAI,OAAO,EAAE,CAAC;QACZ,MAAM,EAAE,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AO,CACL,KAAC,eAAe,IACd,EAAE,EAAE,EAAE,EACN,KAAK,EAAE,KAAK,EACZ,WAAW,EAAE,WAAW,EACxB,KAAK,EAAE,cAAc,EACrB,IAAI,EAAE,IAAI,EACV,QAAQ,EAAE,YAAY,EACtB,MAAM,EAAE,UAAU,EAClB,UAAU,EAAE,EAAE,EACd,iBAAiB,EAAE,SAAS,EAC5B,kBAAkB,EAAE,UAAU,EAC9B,SAAS,EAAE,GAAG,EACd,YAAY,EAAE,SAAS,EACvB,aAAa,EAAE,WAAW,EAC1B,YAAY,EAAE,EAAE,EAChB,SAAS,EAAE,EAAE,EACb,WAAW,EAAE,EAAE,EACf,OAAO,EAAE,GAAG,EACZ,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,EAClB,SAAS,QACT,MAAM,EAAE,EAAE,EACV,KAAK,EAAE,OAAO,CAAC,YAAY,CAAC,EAC5B,UAAU,EAAE,YAAY,IAAI,GAAG,EAC/B,SAAS,EAAE,aAAa,EACxB,SAAS,EAAE;YACT,KAAK,EAAE;gBACL,UAAU,kBACR,SAAS,EAAE,SAAS,EACpB,OAAO,EAAE,QAAQ,IACd,CAAC,OAAO,SAAS,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CACxD;aACF;SACF,GACD,CACH,CAAC;AACJ,CAAC,CAAC;AAEF,uBAAuB,CAAC,WAAW,GAAG,yBAAyB,CAAC;AAEhE,eAAe,uBAAuB,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { TypographyVariant } from '@mui/material/styles';
|
|
2
3
|
import { BorderProps, ColorProps, LayoutProps } from '@pipelinesolucoes/theme';
|
|
3
4
|
type ValidationStatus = 'idle' | 'required' | 'invalid' | 'valid';
|
|
4
5
|
interface PasswordValidationResult {
|
|
@@ -7,79 +8,166 @@ interface PasswordValidationResult {
|
|
|
7
8
|
message: string;
|
|
8
9
|
value: string;
|
|
9
10
|
}
|
|
10
|
-
interface TextFieldPasswordProps extends
|
|
11
|
+
interface TextFieldPasswordProps extends Omit<ColorProps, 'backgroundHover' | 'colorHover'>, Omit<BorderProps, 'border'>, Pick<LayoutProps, 'height' | 'padding' | 'margin'> {
|
|
11
12
|
id?: string;
|
|
12
13
|
label?: string;
|
|
13
14
|
placeholder?: string;
|
|
14
15
|
value?: string;
|
|
15
|
-
|
|
16
|
-
backgroundDisabled?: string;
|
|
17
|
-
color?: string;
|
|
18
|
-
colorFocused?: string;
|
|
19
|
-
colorDisabled?: string;
|
|
20
|
-
borderRadius?: string;
|
|
21
|
-
boxShadow?: string;
|
|
22
|
-
borderColor?: string;
|
|
23
|
-
padding?: string;
|
|
16
|
+
textVariant?: TypographyVariant;
|
|
24
17
|
disabled?: boolean;
|
|
25
18
|
required?: boolean;
|
|
26
19
|
requiredMessage?: string;
|
|
27
20
|
pattern?: RegExp;
|
|
28
21
|
patternMessage?: string;
|
|
29
22
|
showErrorOn?: 'blur' | 'change' | 'both';
|
|
30
|
-
/**
|
|
31
|
-
* Retorna somente a senha digitada (string).
|
|
32
|
-
*/
|
|
33
23
|
onPasswordChange?: (password: string) => void;
|
|
34
|
-
/**
|
|
35
|
-
* "Evento" com o resultado completo da validação.
|
|
36
|
-
*/
|
|
37
24
|
onValidationChange?: (result: PasswordValidationResult) => void;
|
|
38
|
-
/**
|
|
39
|
-
* Se você ainda quiser receber o evento nativo.
|
|
40
|
-
*/
|
|
41
25
|
onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
42
26
|
onBlur?: (event: React.FocusEvent<HTMLInputElement>) => void;
|
|
43
27
|
}
|
|
44
28
|
/**
|
|
45
29
|
* Componente de campo de senha baseado no TextField do Material UI, com botão para alternar
|
|
46
|
-
* entre mostrar
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
* -
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
30
|
+
* entre mostrar e ocultar a senha.
|
|
31
|
+
*
|
|
32
|
+
* O componente oferece:
|
|
33
|
+
* - Retorno apenas do valor da senha digitada via `onPasswordChange`
|
|
34
|
+
* - Validação automática de obrigatoriedade e formato (Regex)
|
|
35
|
+
* - Exibição controlada de mensagens de erro
|
|
36
|
+
* - Evento de validação completo via `onValidationChange`
|
|
37
|
+
* - Estilização via props com fallback para tokens do theme da Pipeline
|
|
38
|
+
*
|
|
39
|
+
* ---
|
|
40
|
+
*
|
|
41
|
+
* ### Tokens de estilo (ordem de prioridade)
|
|
42
|
+
*
|
|
43
|
+
* Para propriedades visuais, o componente resolve os valores nesta ordem:
|
|
44
|
+
* 1. **Props do componente**
|
|
45
|
+
* 2. **Theme da Pipeline** (`theme.pipelinesolucoes.forms.field`)
|
|
46
|
+
* 3. **Fallback interno** (valores padrão do componente)
|
|
47
|
+
*
|
|
48
|
+
* ---
|
|
49
|
+
*
|
|
50
|
+
* ### Tipografia
|
|
51
|
+
*
|
|
52
|
+
* A tipografia do texto digitado e do placeholder pode ser definida de duas formas:
|
|
53
|
+
*
|
|
54
|
+
* 1. **Material UI**
|
|
55
|
+
* Ao informar `textVariant`, o componente utiliza `theme.typography[textVariant]`.
|
|
56
|
+
*
|
|
57
|
+
* 2. **Theme da Pipeline**
|
|
58
|
+
* Quando `textVariant` não é informado, utiliza `theme.pipelinesolucoes.forms.field.typography`.
|
|
59
|
+
*
|
|
60
|
+
* **Ordem de prioridade (tipografia):**
|
|
61
|
+
* 1. `textVariant` (prop do componente)
|
|
62
|
+
* 2. `theme.typography[textVariant]` (Material UI)
|
|
63
|
+
* 3. `theme.pipelinesolucoes.forms.field.typography` (Pipeline)
|
|
64
|
+
* 4. Fallback interno (`theme.typography.body1`)
|
|
65
|
+
*
|
|
66
|
+
* ---
|
|
67
|
+
*
|
|
68
|
+
* @param {string} [id]
|
|
69
|
+
* ID do input.
|
|
70
|
+
*
|
|
71
|
+
* @param {string} [label]
|
|
72
|
+
* Label exibido no campo.
|
|
73
|
+
*
|
|
74
|
+
* @param {string} [placeholder]
|
|
75
|
+
* Texto de placeholder do input.
|
|
76
|
+
*
|
|
77
|
+
* @param {string} [value]
|
|
78
|
+
* Valor controlado do campo.
|
|
79
|
+
*
|
|
80
|
+
* @param {import('@mui/material/styles').TypographyVariant} [textVariant]
|
|
81
|
+
* Variante de tipografia do Material UI aplicada ao texto digitado e ao placeholder.
|
|
82
|
+
* Quando omitida, utiliza a tipografia do theme da Pipeline (`theme.pipelinesolucoes.forms.field.typography`).
|
|
83
|
+
*
|
|
84
|
+
* ---
|
|
85
|
+
* ### Estilo / Aparência
|
|
86
|
+
*
|
|
87
|
+
* @param {string} [background]
|
|
88
|
+
* Cor de fundo do campo.
|
|
89
|
+
* Ordem: `background` → `theme.pipelinesolucoes.forms.field.background` → `#fff`.
|
|
90
|
+
*
|
|
91
|
+
* @param {string} [backgroundDisabled]
|
|
92
|
+
* Cor de fundo do campo quando desabilitado.
|
|
93
|
+
* Ordem: `backgroundDisabled` → `theme.pipelinesolucoes.forms.field.backgroundDisabled` → `#E5E7EB`.
|
|
94
|
+
*
|
|
95
|
+
* @param {string} [color]
|
|
96
|
+
* Cor do texto do campo (texto digitado e label).
|
|
97
|
+
* Ordem: `color` → `theme.pipelinesolucoes.forms.field.color` → `#000`.
|
|
98
|
+
*
|
|
99
|
+
* @param {string} [colorFocused]
|
|
100
|
+
* Cor aplicada ao estado focado (usada como cor de borda no focus).
|
|
101
|
+
* Ordem: `colorFocused` → `theme.pipelinesolucoes.forms.field.colorFocused` → `#1976d2`.
|
|
102
|
+
*
|
|
103
|
+
* @param {string} [colorDisabled]
|
|
104
|
+
* Cor do texto do campo quando desabilitado.
|
|
105
|
+
* Ordem: `colorDisabled` → `theme.pipelinesolucoes.forms.field.colorDisabled` → `#9CA3AF`.
|
|
106
|
+
*
|
|
107
|
+
* @param {string} [borderRadius]
|
|
108
|
+
* Raio da borda do campo.
|
|
109
|
+
* Ordem: `borderRadius` → `theme.pipelinesolucoes.forms.field.borderRadius` → `"0"`.
|
|
110
|
+
*
|
|
111
|
+
* @param {string} [boxShadow]
|
|
112
|
+
* Sombra do campo.
|
|
113
|
+
* Ordem: `boxShadow` → `theme.pipelinesolucoes.forms.field.boxShadow` → `"none"`.
|
|
114
|
+
*
|
|
115
|
+
* @param {string} [borderColor]
|
|
116
|
+
* Cor da borda do campo (estado padrão/hover).
|
|
117
|
+
* Ordem: `borderColor` → `theme.pipelinesolucoes.forms.field.borderColor` → `#ccc`.
|
|
118
|
+
*
|
|
119
|
+
* @param {string} [padding]
|
|
120
|
+
* Espaçamento interno do input (aplicado no texto e textarea).
|
|
121
|
+
* Ordem: `padding` → `theme.pipelinesolucoes.forms.field.padding` → `"4px 8px"`.
|
|
122
|
+
*
|
|
123
|
+
* ---
|
|
124
|
+
* ### Validação
|
|
125
|
+
*
|
|
126
|
+
* @param {boolean} [required=true]
|
|
127
|
+
* Define se o campo é obrigatório.
|
|
128
|
+
*
|
|
129
|
+
* @param {RegExp} [pattern=/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[^A-Za-z0-9]).{8,}$/]
|
|
130
|
+
* Expressão regular usada para validar o formato da senha.
|
|
131
|
+
*
|
|
132
|
+
* @param {string} [requiredMessage='Senha obrigatória']
|
|
133
|
+
* Mensagem exibida quando o campo obrigatório está vazio.
|
|
134
|
+
*
|
|
135
|
+
* @param {string} [patternMessage]
|
|
136
|
+
* Mensagem exibida quando a senha não atende ao formato definido.
|
|
137
|
+
*
|
|
138
|
+
* @param {'blur' | 'change' | 'both'} [showErrorOn='blur']
|
|
139
|
+
* Define quando a validação e exibição de erros deve ocorrer.
|
|
140
|
+
*
|
|
141
|
+
* @param {boolean} [disabled=false]
|
|
142
|
+
* Desabilita o campo.
|
|
143
|
+
*
|
|
144
|
+
* ---
|
|
145
|
+
* ### Eventos
|
|
146
|
+
*
|
|
147
|
+
* @param {(password: string) => void} [onPasswordChange]
|
|
148
|
+
* Callback que retorna apenas o valor da senha digitada.
|
|
149
|
+
*
|
|
150
|
+
* @param {(result: PasswordValidationResult) => void} [onValidationChange]
|
|
151
|
+
* Callback disparado sempre que a validação é executada, contendo o resultado completo.
|
|
152
|
+
*
|
|
153
|
+
* @param {(event: React.ChangeEvent<HTMLInputElement>) => void} [onChange]
|
|
154
|
+
* Evento `onChange` nativo do input (opcional).
|
|
155
|
+
*
|
|
156
|
+
* @param {(event: React.FocusEvent<HTMLInputElement>) => void} [onBlur]
|
|
157
|
+
* Evento `onBlur` nativo do input (opcional).
|
|
158
|
+
*
|
|
159
|
+
* ---
|
|
64
160
|
*
|
|
65
161
|
* @example
|
|
66
162
|
* ```tsx
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
* label="Senha"
|
|
76
|
-
* value={password}
|
|
77
|
-
* onPasswordChange={(p) => setPassword(p)}
|
|
78
|
-
* onValidationChange={(r) => console.log(r)}
|
|
79
|
-
* validateOn="both"
|
|
80
|
-
* />
|
|
81
|
-
* );
|
|
82
|
-
* };
|
|
163
|
+
* <TextFieldPassword
|
|
164
|
+
* label="Senha"
|
|
165
|
+
* background="#fff"
|
|
166
|
+
* borderRadius="10px"
|
|
167
|
+
* textVariant="body2"
|
|
168
|
+
* showErrorOn="both"
|
|
169
|
+
* onPasswordChange={(password) => console.log(password)}
|
|
170
|
+
* />
|
|
83
171
|
* ```
|
|
84
172
|
*/
|
|
85
173
|
declare const TextFieldPassword: React.FC<TextFieldPasswordProps>;
|