@pipelinesolucoes/form 1.2.0-beta.3 → 1.2.0-beta.31
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 +277 -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
package/README.md
CHANGED
|
@@ -24,14 +24,28 @@ A biblioteca inclui os seguintes componentes:
|
|
|
24
24
|
Faz a validação do e-mail, dispara um `onSubmit` assíncrono (obrigatório) e exibe a mensagem retornada.
|
|
25
25
|
|
|
26
26
|
- **TextFieldPassword**
|
|
27
|
-
Componente de campo de senha baseado no TextField do Material UI, com botão para alternar entre mostrar/ocultar a senha.
|
|
27
|
+
Componente de campo de senha baseado no TextField do Material UI, com botão para alternar entre mostrar/ocultar a senha.
|
|
28
|
+
O componente:
|
|
28
29
|
- Retorna somente a senha digitada via `onPasswordChange`
|
|
29
30
|
- Valida obrigatório + formato (regex) e exibe mensagens de erro automaticamente
|
|
30
31
|
- Dispara um "evento" de validação via `onValidationChange`
|
|
31
32
|
|
|
32
33
|
- **TextFieldValidate**
|
|
33
34
|
Componente de campo de texto com validação, baseado no TextField do Material UI.
|
|
34
|
-
Permite personalização visual via `styled` e suporte a validações comuns (obrigatório, tamanho mínimo, regex) e validação customizada.
|
|
35
|
+
Permite personalização visual via `styled` e suporte a validações comuns (obrigatório, tamanho mínimo, regex) e validação customizada.
|
|
36
|
+
|
|
37
|
+
- **TextFieldNumberValidate**
|
|
38
|
+
Campo de texto numérico com suporte a validações comuns e customizadas, construído sobre o TextField do Material UI e
|
|
39
|
+
estilizado via Design System da Pipeline.
|
|
40
|
+
|
|
41
|
+
- **TextFieldBirthDateWithAge**
|
|
42
|
+
Campo de data de nascimento com entrada somente numérica, máscara `dd/mm/yyyy`,
|
|
43
|
+
validações comuns (required, min/maxLength, pattern) + validação customizada,
|
|
44
|
+
e cálculo automático de idade exibido na label.
|
|
45
|
+
|
|
46
|
+
- **TextFieldCPFValidate**
|
|
47
|
+
Campo de CPF com entrada somente numérica, máscara `000.000.000-00`,
|
|
48
|
+
validações comuns (required, min/maxLength, pattern) + validação customizada.
|
|
35
49
|
|
|
36
50
|
- **NotificationSnackbar**
|
|
37
51
|
Componente que exibe uma notificação no topo da tela utilizando o Snackbar e Alert do Material UI.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { TypographyVariant } from '@mui/material/styles';
|
|
3
|
+
import { BorderProps, ColorProps, LayoutProps } from '@pipelinesolucoes/theme';
|
|
4
|
+
export interface ChipListProps extends Pick<ColorProps, 'background' | 'color' | 'backgroundHover' | 'colorHover'>, Pick<LayoutProps, 'width' | 'height' | 'padding' | 'margin'>, BorderProps {
|
|
5
|
+
items: string[];
|
|
6
|
+
variant?: TypographyVariant;
|
|
7
|
+
}
|
|
8
|
+
declare const ChipList: React.FC<ChipListProps>;
|
|
9
|
+
export default ChipList;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import Box from '@mui/material/Box';
|
|
4
|
+
import Chip from '@mui/material/Chip';
|
|
5
|
+
import { styled, useTheme } from '@mui/material/styles';
|
|
6
|
+
const StyledChipArea = styled(Box)({
|
|
7
|
+
display: 'flex',
|
|
8
|
+
flexWrap: 'wrap',
|
|
9
|
+
gap: 8,
|
|
10
|
+
});
|
|
11
|
+
const StyledChip = styled(Chip, {
|
|
12
|
+
shouldForwardProp: (prop) => ![
|
|
13
|
+
'width',
|
|
14
|
+
'height',
|
|
15
|
+
'padding',
|
|
16
|
+
'margin',
|
|
17
|
+
'background',
|
|
18
|
+
'colorText',
|
|
19
|
+
'borderRadius',
|
|
20
|
+
'boxShadow',
|
|
21
|
+
'border',
|
|
22
|
+
'backgroundHover',
|
|
23
|
+
'colorHover',
|
|
24
|
+
'typo',
|
|
25
|
+
].includes(prop),
|
|
26
|
+
})(({ width, height, padding, margin, background, colorText, borderRadius, boxShadow, border, backgroundHover, colorHover, typo }) => (Object.assign(Object.assign({ width,
|
|
27
|
+
height,
|
|
28
|
+
padding,
|
|
29
|
+
margin,
|
|
30
|
+
borderRadius,
|
|
31
|
+
boxShadow, backgroundColor: background, color: colorText, border }, (typo !== null && typo !== void 0 ? typo : {})), { '&:hover': {
|
|
32
|
+
backgroundColor: backgroundHover !== null && backgroundHover !== void 0 ? backgroundHover : background,
|
|
33
|
+
color: colorHover !== null && colorHover !== void 0 ? colorHover : colorText,
|
|
34
|
+
}, '&.MuiChip-outlined': {
|
|
35
|
+
backgroundColor: 'transparent',
|
|
36
|
+
}, '&.MuiChip-outlined:hover': {
|
|
37
|
+
backgroundColor: backgroundHover !== null && backgroundHover !== void 0 ? backgroundHover : 'transparent',
|
|
38
|
+
color: colorHover !== null && colorHover !== void 0 ? colorHover : colorText,
|
|
39
|
+
} })));
|
|
40
|
+
const ChipList = ({ items, variant, width, height, padding, margin, background, color, borderRadius, boxShadow, border, backgroundHover, colorHover, }) => {
|
|
41
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1;
|
|
42
|
+
const theme = useTheme();
|
|
43
|
+
const themechip = (_b = (_a = theme.pipelinesolucoes) === null || _a === void 0 ? void 0 : _a.forms) === null || _b === void 0 ? void 0 : _b.chip;
|
|
44
|
+
const wchip = (_d = (_c = themechip === null || themechip === void 0 ? void 0 : themechip.width) !== null && _c !== void 0 ? _c : width) !== null && _d !== void 0 ? _d : '100%';
|
|
45
|
+
const hchip = (_f = (_e = themechip === null || themechip === void 0 ? void 0 : themechip.height) !== null && _e !== void 0 ? _e : height) !== null && _f !== void 0 ? _f : 'auto';
|
|
46
|
+
const pchip = (_h = (_g = themechip === null || themechip === void 0 ? void 0 : themechip.padding) !== null && _g !== void 0 ? _g : padding) !== null && _h !== void 0 ? _h : '16px';
|
|
47
|
+
const mchip = (_k = (_j = themechip === null || themechip === void 0 ? void 0 : themechip.margin) !== null && _j !== void 0 ? _j : margin) !== null && _k !== void 0 ? _k : '0';
|
|
48
|
+
const bchip = (_m = (_l = themechip === null || themechip === void 0 ? void 0 : themechip.background) !== null && _l !== void 0 ? _l : background) !== null && _m !== void 0 ? _m : '#ffffff';
|
|
49
|
+
const clchip = (_p = (_o = themechip === null || themechip === void 0 ? void 0 : themechip.color) !== null && _o !== void 0 ? _o : color) !== null && _p !== void 0 ? _p : 'inherit';
|
|
50
|
+
const brchip = (_r = (_q = themechip === null || themechip === void 0 ? void 0 : themechip.borderRadius) !== null && _q !== void 0 ? _q : borderRadius) !== null && _r !== void 0 ? _r : 'inherit';
|
|
51
|
+
const bschip = (_t = (_s = themechip === null || themechip === void 0 ? void 0 : themechip.boxShadow) !== null && _s !== void 0 ? _s : boxShadow) !== null && _t !== void 0 ? _t : 'none';
|
|
52
|
+
const bdchip = (_v = (_u = themechip === null || themechip === void 0 ? void 0 : themechip.border) !== null && _u !== void 0 ? _u : border) !== null && _v !== void 0 ? _v : 'inherit';
|
|
53
|
+
const bHoverchip = (_x = (_w = themechip === null || themechip === void 0 ? void 0 : themechip.backgroundHover) !== null && _w !== void 0 ? _w : backgroundHover) !== null && _x !== void 0 ? _x : bchip;
|
|
54
|
+
const clHoverchip = (_z = (_y = themechip === null || themechip === void 0 ? void 0 : themechip.colorHover) !== null && _y !== void 0 ? _y : colorHover) !== null && _z !== void 0 ? _z : clchip;
|
|
55
|
+
const typo = (_1 = (_0 = (variant && theme.typography[variant])) !== null && _0 !== void 0 ? _0 : themechip === null || themechip === void 0 ? void 0 : themechip.typography) !== null && _1 !== void 0 ? _1 : theme.typography.body1;
|
|
56
|
+
return (_jsx(StyledChipArea, { children: items.map((item, idx) => (_jsx(StyledChip, { label: item, width: wchip, height: hchip, padding: pchip, margin: mchip, background: bchip, colorText: clchip, borderRadius: brchip, boxShadow: bschip, border: bdchip, backgroundHover: bHoverchip, colorHover: clHoverchip, typo: typo }, `${item}-${idx}`))) }));
|
|
57
|
+
};
|
|
58
|
+
ChipList.displayName = 'ChipList';
|
|
59
|
+
export default ChipList;
|
|
60
|
+
//# sourceMappingURL=ChipList.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChipList.js","sourceRoot":"","sources":["../../src/components/ChipList.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAGb,OAAO,GAAG,MAAM,mBAAmB,CAAC;AACpC,OAAO,IAAI,MAAM,oBAAoB,CAAC;AACtC,OAA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MAAA,MAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,MAAM,mCAAI,MAAM,mCAAI,SAAS,CAAC;IACxD,MAAM,UAAU,GAAG,MAAA,MAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,eAAe,mCAAI,eAAe,mCAAI,KAAK,CAAC;IAC1E,MAAM,WAAW,GAAG,MAAA,MAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,UAAU,mCAAI,UAAU,mCAAI,MAAM,CAAC;IAElE,MAAM,IAAI,GACR,MAAA,MAAA,CAAC,OAAO,IAAI,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,mCACtC,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,UAAU,mCACrB,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC;IAEzB,OAAO,CACL,KAAC,cAAc,cACZ,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,CAAC,CACxB,KAAC,UAAU,IAET,KAAK,EAAE,IAAI,EACX,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,KAAK,EACb,OAAO,EAAE,KAAK,EACd,MAAM,EAAE,KAAK,EACb,UAAU,EAAE,KAAK,EACjB,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,MAAM,EACpB,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,EACd,eAAe,EAAE,UAAU,EAC3B,UAAU,EAAE,WAAW,EACvB,IAAI,EAAE,IAAI,IAbL,GAAG,IAAI,IAAI,GAAG,EAAE,CAcrB,CACH,CAAC,GACa,CAClB,CAAC;AACJ,CAAC,CAAC;AAEF,QAAQ,CAAC,WAAW,GAAG,UAAU,CAAC;AAClC,eAAe,QAAQ,CAAC"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { TypographyProps } from '@mui/material/Typography';
|
|
3
|
+
import { BorderProps, ColorProps, LayoutProps } from '@pipelinesolucoes/theme';
|
|
4
|
+
export interface SelectFieldOption {
|
|
5
|
+
value: string | number;
|
|
6
|
+
label: string;
|
|
7
|
+
}
|
|
8
|
+
interface SelectFieldProps extends Omit<ColorProps, 'backgroundHover' | 'colorHover'>, Omit<BorderProps, 'border'>, Pick<LayoutProps, 'height' | 'padding' | 'width' | 'margin'> {
|
|
9
|
+
id?: string;
|
|
10
|
+
label?: string;
|
|
11
|
+
placeholder?: string;
|
|
12
|
+
value?: string | number;
|
|
13
|
+
disabled?: boolean;
|
|
14
|
+
variant?: TypographyProps['variant'];
|
|
15
|
+
helperText?: string;
|
|
16
|
+
helperTextColor?: string;
|
|
17
|
+
options: SelectFieldOption[];
|
|
18
|
+
onChange: (value: string | number) => void;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* ComboBox baseado no Material UI, sem validação e sem máscaras,
|
|
22
|
+
* permitindo customização visual e controle completo do valor selecionado.
|
|
23
|
+
*
|
|
24
|
+
* @param {string} [id] Identificador único do campo (usado para acessibilidade).
|
|
25
|
+
* @param {ComboBoxOption[]} options Lista de opções exibidas no ComboBox.
|
|
26
|
+
* @param {string | number} value Valor selecionado.
|
|
27
|
+
* @param {(value: string | number) => void} onChange Callback disparado ao selecionar uma opção.
|
|
28
|
+
* @param {string} [label] Texto do rótulo do campo.
|
|
29
|
+
* @param {string} [placeholder] Texto exibido quando nenhum valor está selecionado.
|
|
30
|
+
* @param {string} [helperText] Texto auxiliar exibido abaixo do campo.
|
|
31
|
+
* @param {string} [helperTextColor] Cor do helperText. Se não for informada, usa a cor de erro do theme.
|
|
32
|
+
* @param {TypographyProps['variant']} [variant='body1'] Variante da tipografia aplicada ao label, valor, opções e helperText.
|
|
33
|
+
* @param {string | number} [width='100%'] Largura do componente.
|
|
34
|
+
* @param {string | number} [height='auto'] Altura do campo.
|
|
35
|
+
* @param {string | number} [containerMargin=0] Margem externa do container.
|
|
36
|
+
* @param {string | number} [padding=0] Padding interno do texto selecionado.
|
|
37
|
+
* @param {string} [background='transparent'] Cor de fundo do campo e do menu aberto.
|
|
38
|
+
* @param {string} [colorText='#000'] Cor do texto (label, valor selecionado e itens).
|
|
39
|
+
* @param {string | number} [borderRadius=4] Raio da borda.
|
|
40
|
+
* @param {string} [boxShadow='none'] Sombra do campo.
|
|
41
|
+
* @param {string} [borderColor='#c4c4c4'] Cor da borda.
|
|
42
|
+
* @param {boolean} [disabled=false] Desabilita o campo.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```tsx
|
|
46
|
+
* import { ComboBox } from '@/components/ComboBox';
|
|
47
|
+
*
|
|
48
|
+
* const Example = () => (
|
|
49
|
+
* <ComboBox
|
|
50
|
+
* id="category"
|
|
51
|
+
* label="Categoria"
|
|
52
|
+
* placeholder="Selecione uma opção"
|
|
53
|
+
* helperText="Campo obrigatório"
|
|
54
|
+
* helperTextColor="warning.main"
|
|
55
|
+
* variant="body2"
|
|
56
|
+
* background="#111"
|
|
57
|
+
* colorText="#fff"
|
|
58
|
+
* options={[
|
|
59
|
+
* { value: 1, label: 'Frontend' },
|
|
60
|
+
* { value: 2, label: 'Backend' },
|
|
61
|
+
* ]}
|
|
62
|
+
* value={1}
|
|
63
|
+
* onChange={(v) => console.log(v)}
|
|
64
|
+
* width={320}
|
|
65
|
+
* containerMargin="16px 0"
|
|
66
|
+
* padding="12px"
|
|
67
|
+
* borderRadius={12}
|
|
68
|
+
* />
|
|
69
|
+
* );
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
|
+
declare const SelectField: React.FC<SelectFieldProps>;
|
|
73
|
+
export default SelectField;
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { FormControl, InputLabel, MenuItem, Select, FormHelperText, Typography } from '@mui/material';
|
|
4
|
+
import { styled, useTheme } from '@mui/material/styles';
|
|
5
|
+
import { fbbackground, fbborderColor, fbborderRadius, fbboxShadow, fbcolor, fbcolorFocused, fbheigth, fbpadding } from '../constant';
|
|
6
|
+
const StyledWrapper = styled('div', {
|
|
7
|
+
shouldForwardProp: (prop) => !['width', 'margin'].includes(prop),
|
|
8
|
+
})(({ width, margin }) => ({
|
|
9
|
+
width: width,
|
|
10
|
+
margin: margin,
|
|
11
|
+
}));
|
|
12
|
+
const StyledFormControl = styled(FormControl, {
|
|
13
|
+
shouldForwardProp: (prop) => !['height',
|
|
14
|
+
'padding',
|
|
15
|
+
'background',
|
|
16
|
+
'borderRadius',
|
|
17
|
+
'boxShadow',
|
|
18
|
+
'borderColor',
|
|
19
|
+
'colorText',
|
|
20
|
+
].includes(prop),
|
|
21
|
+
})(({ height, padding, background, borderRadius, boxShadow, borderColor, colorText }) => ({
|
|
22
|
+
width: '100%',
|
|
23
|
+
'& .MuiOutlinedInput-root': {
|
|
24
|
+
height: height,
|
|
25
|
+
background: background !== null && background !== void 0 ? background : fbbackground,
|
|
26
|
+
borderRadius: borderRadius !== null && borderRadius !== void 0 ? borderRadius : fbborderRadius,
|
|
27
|
+
boxShadow: boxShadow !== null && boxShadow !== void 0 ? boxShadow : fbboxShadow,
|
|
28
|
+
'& fieldset': {
|
|
29
|
+
borderColor: borderColor !== null && borderColor !== void 0 ? borderColor : fbborderColor,
|
|
30
|
+
},
|
|
31
|
+
'&:hover fieldset': {
|
|
32
|
+
borderColor: borderColor !== null && borderColor !== void 0 ? borderColor : fbborderColor,
|
|
33
|
+
},
|
|
34
|
+
'&.Mui-focused fieldset': {
|
|
35
|
+
borderColor: borderColor !== null && borderColor !== void 0 ? borderColor : fbcolorFocused,
|
|
36
|
+
},
|
|
37
|
+
'& .MuiSelect-select': {
|
|
38
|
+
padding: padding !== null && padding !== void 0 ? padding : fbpadding,
|
|
39
|
+
color: colorText !== null && colorText !== void 0 ? colorText : fbcolor,
|
|
40
|
+
display: 'flex',
|
|
41
|
+
alignItems: 'center',
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
'& .MuiInputLabel-root': {
|
|
45
|
+
color: colorText !== null && colorText !== void 0 ? colorText : fbcolor,
|
|
46
|
+
},
|
|
47
|
+
'& .MuiInputLabel-root.Mui-focused': {
|
|
48
|
+
color: colorText !== null && colorText !== void 0 ? colorText : fbcolor,
|
|
49
|
+
},
|
|
50
|
+
}));
|
|
51
|
+
/**
|
|
52
|
+
* ComboBox baseado no Material UI, sem validação e sem máscaras,
|
|
53
|
+
* permitindo customização visual e controle completo do valor selecionado.
|
|
54
|
+
*
|
|
55
|
+
* @param {string} [id] Identificador único do campo (usado para acessibilidade).
|
|
56
|
+
* @param {ComboBoxOption[]} options Lista de opções exibidas no ComboBox.
|
|
57
|
+
* @param {string | number} value Valor selecionado.
|
|
58
|
+
* @param {(value: string | number) => void} onChange Callback disparado ao selecionar uma opção.
|
|
59
|
+
* @param {string} [label] Texto do rótulo do campo.
|
|
60
|
+
* @param {string} [placeholder] Texto exibido quando nenhum valor está selecionado.
|
|
61
|
+
* @param {string} [helperText] Texto auxiliar exibido abaixo do campo.
|
|
62
|
+
* @param {string} [helperTextColor] Cor do helperText. Se não for informada, usa a cor de erro do theme.
|
|
63
|
+
* @param {TypographyProps['variant']} [variant='body1'] Variante da tipografia aplicada ao label, valor, opções e helperText.
|
|
64
|
+
* @param {string | number} [width='100%'] Largura do componente.
|
|
65
|
+
* @param {string | number} [height='auto'] Altura do campo.
|
|
66
|
+
* @param {string | number} [containerMargin=0] Margem externa do container.
|
|
67
|
+
* @param {string | number} [padding=0] Padding interno do texto selecionado.
|
|
68
|
+
* @param {string} [background='transparent'] Cor de fundo do campo e do menu aberto.
|
|
69
|
+
* @param {string} [colorText='#000'] Cor do texto (label, valor selecionado e itens).
|
|
70
|
+
* @param {string | number} [borderRadius=4] Raio da borda.
|
|
71
|
+
* @param {string} [boxShadow='none'] Sombra do campo.
|
|
72
|
+
* @param {string} [borderColor='#c4c4c4'] Cor da borda.
|
|
73
|
+
* @param {boolean} [disabled=false] Desabilita o campo.
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* ```tsx
|
|
77
|
+
* import { ComboBox } from '@/components/ComboBox';
|
|
78
|
+
*
|
|
79
|
+
* const Example = () => (
|
|
80
|
+
* <ComboBox
|
|
81
|
+
* id="category"
|
|
82
|
+
* label="Categoria"
|
|
83
|
+
* placeholder="Selecione uma opção"
|
|
84
|
+
* helperText="Campo obrigatório"
|
|
85
|
+
* helperTextColor="warning.main"
|
|
86
|
+
* variant="body2"
|
|
87
|
+
* background="#111"
|
|
88
|
+
* colorText="#fff"
|
|
89
|
+
* options={[
|
|
90
|
+
* { value: 1, label: 'Frontend' },
|
|
91
|
+
* { value: 2, label: 'Backend' },
|
|
92
|
+
* ]}
|
|
93
|
+
* value={1}
|
|
94
|
+
* onChange={(v) => console.log(v)}
|
|
95
|
+
* width={320}
|
|
96
|
+
* containerMargin="16px 0"
|
|
97
|
+
* padding="12px"
|
|
98
|
+
* borderRadius={12}
|
|
99
|
+
* />
|
|
100
|
+
* );
|
|
101
|
+
* ```
|
|
102
|
+
*/
|
|
103
|
+
const SelectField = ({ id, label, placeholder, value, background, backgroundDisabled, color, colorFocused, colorDisabled, borderRadius, boxShadow, borderColor, width = "100%", height, padding, margin = '0', disabled = false, variant = 'body1', helperText, helperTextColor, options, onChange, }) => {
|
|
104
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
105
|
+
const labelId = id ? `${id}-label` : undefined;
|
|
106
|
+
const shouldShrinkLabel = Boolean(value) || Boolean(placeholder);
|
|
107
|
+
const handleChange = (event, _child) => {
|
|
108
|
+
const raw = event.target.value;
|
|
109
|
+
const matched = options.find((opt) => String(opt.value) === raw);
|
|
110
|
+
onChange(matched ? matched.value : raw);
|
|
111
|
+
};
|
|
112
|
+
const theme = useTheme();
|
|
113
|
+
const field = (_b = (_a = theme.pipelinesolucoes) === null || _a === void 0 ? void 0 : _a.forms) === null || _b === void 0 ? void 0 : _b.field;
|
|
114
|
+
const bg = (_c = background !== null && background !== void 0 ? background : field === null || field === void 0 ? void 0 : field.background) !== null && _c !== void 0 ? _c : '#fff';
|
|
115
|
+
const txt = (_d = color !== null && color !== void 0 ? color : field === null || field === void 0 ? void 0 : field.color) !== null && _d !== void 0 ? _d : '#000';
|
|
116
|
+
const bgDisabled = (_e = backgroundDisabled !== null && backgroundDisabled !== void 0 ? backgroundDisabled : field === null || field === void 0 ? void 0 : field.backgroundDisabled) !== null && _e !== void 0 ? _e : "#E5E7EB";
|
|
117
|
+
const txtDisabled = (_f = colorDisabled !== null && colorDisabled !== void 0 ? colorDisabled : field === null || field === void 0 ? void 0 : field.colorDisabled) !== null && _f !== void 0 ? _f : "#9CA3AF";
|
|
118
|
+
const bdFocused = (_g = colorFocused !== null && colorFocused !== void 0 ? colorFocused : field === null || field === void 0 ? void 0 : field.colorFocused) !== null && _g !== void 0 ? _g : '#1976d2';
|
|
119
|
+
const br = (_h = borderRadius !== null && borderRadius !== void 0 ? borderRadius : field === null || field === void 0 ? void 0 : field.borderRadius) !== null && _h !== void 0 ? _h : "0";
|
|
120
|
+
const sh = (_j = boxShadow !== null && boxShadow !== void 0 ? boxShadow : field === null || field === void 0 ? void 0 : field.boxShadow) !== null && _j !== void 0 ? _j : "none";
|
|
121
|
+
const bd = (_k = borderColor !== null && borderColor !== void 0 ? borderColor : field === null || field === void 0 ? void 0 : field.borderColor) !== null && _k !== void 0 ? _k : '#ccc';
|
|
122
|
+
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';
|
|
123
|
+
const mg = (_m = margin !== null && margin !== void 0 ? margin : field === null || field === void 0 ? void 0 : field.margin) !== null && _m !== void 0 ? _m : '0';
|
|
124
|
+
const hg = (_o = height !== null && height !== void 0 ? height : field === null || field === void 0 ? void 0 : field.height) !== null && _o !== void 0 ? _o : fbheigth;
|
|
125
|
+
return (_jsx(StyledWrapper, { width: width, margin: mg, children: _jsxs(StyledFormControl, { id: id, disabled: disabled, variant: "outlined", background: bg, borderRadius: br, boxShadow: sh, borderColor: bd, colorText: txt, height: hg, padding: pad, children: [label && (_jsx(InputLabel, { id: labelId, htmlFor: id, shrink: shouldShrinkLabel, children: _jsx(Typography, { variant: variant, sx: { color: txt }, children: label }) })), _jsx(Select, { id: id, labelId: labelId, value: value !== undefined && value !== null ? String(value) : '', onChange: handleChange, displayEmpty: true, label: label, MenuProps: {
|
|
126
|
+
PaperProps: {
|
|
127
|
+
sx: {
|
|
128
|
+
backgroundColor: bg,
|
|
129
|
+
},
|
|
130
|
+
},
|
|
131
|
+
}, renderValue: (selected) => {
|
|
132
|
+
var _a;
|
|
133
|
+
if ((selected === '' || selected === undefined) && placeholder) {
|
|
134
|
+
return (_jsx(Typography, { variant: variant, color: "text.disabled", children: placeholder }));
|
|
135
|
+
}
|
|
136
|
+
const option = options.find((opt) => String(opt.value) === selected);
|
|
137
|
+
return _jsx(Typography, { variant: variant, children: (_a = option === null || option === void 0 ? void 0 : option.label) !== null && _a !== void 0 ? _a : '' });
|
|
138
|
+
}, children: options.map((option) => (_jsx(MenuItem, { value: String(option.value), children: _jsx(Typography, { variant: variant, sx: { color: txt }, children: option.label }) }, option.value))) }), helperText && (_jsx(FormHelperText, { error: !helperTextColor, children: _jsx(Typography, { variant: variant, sx: { color: helperTextColor }, children: helperText }) }))] }) }));
|
|
139
|
+
};
|
|
140
|
+
SelectField.displayName = 'SelectField';
|
|
141
|
+
export default SelectField;
|
|
142
|
+
//# sourceMappingURL=SelectField.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SelectField.js","sourceRoot":"","sources":["../../src/components/SelectField.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAGb,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAqB,cAAc,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AACzH,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,sBAAsB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AE,OAAO,EAAE,EAAE,EAAE,EAAE,KAAK,EAAE,eAAe,EAAE,YACzD,UAAU,GACA,GACE,CAClB,IAEiB,GACN,CACjB,CAAC;AACJ,CAAC,CAAC;AAEF,WAAW,CAAC,WAAW,GAAG,aAAa,CAAC;AAExC,eAAe,WAAW,CAAC"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { TypographyVariant } from '@mui/material/styles';
|
|
3
|
+
import { BorderProps, ColorProps, LayoutProps } from '@pipelinesolucoes/theme';
|
|
4
|
+
interface TextFieldBirthDateWithAgeProps extends Omit<ColorProps, 'backgroundHover' | 'colorHover'>, Omit<BorderProps, 'border'>, Pick<LayoutProps, 'height' | 'padding'> {
|
|
5
|
+
id?: string;
|
|
6
|
+
label?: string;
|
|
7
|
+
placeholder?: string;
|
|
8
|
+
value?: string;
|
|
9
|
+
textVariant?: TypographyVariant;
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
minLength?: number;
|
|
12
|
+
maxLength?: number;
|
|
13
|
+
required?: boolean;
|
|
14
|
+
requiredMessage?: string;
|
|
15
|
+
pattern?: RegExp | string;
|
|
16
|
+
patternMessage?: string;
|
|
17
|
+
showErrorOn?: 'change' | 'blur';
|
|
18
|
+
validate?: (value: string) => string | null | undefined;
|
|
19
|
+
onChange?: (event: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => void;
|
|
20
|
+
onBlur?: (event: React.FocusEvent<HTMLInputElement | HTMLTextAreaElement>) => void;
|
|
21
|
+
/**
|
|
22
|
+
* Callback disparado sempre que a idade puder ser calculada.
|
|
23
|
+
* Retorna `null` quando a data é inválida ou incompleta.
|
|
24
|
+
*/
|
|
25
|
+
onAgeChange?: (age: number | null) => void;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Campo de data de nascimento com entrada somente numérica, máscara `dd/mm/yyyy`,
|
|
29
|
+
* validações comuns (required, min/maxLength, pattern) + validação customizada,
|
|
30
|
+
* e cálculo automático de idade exibido na label.
|
|
31
|
+
*
|
|
32
|
+
* Regras:
|
|
33
|
+
* - O usuário digita apenas números.
|
|
34
|
+
* - Ao digitar, o valor é formatado automaticamente como `dd/mm/yyyy` (sem normalizar ano).
|
|
35
|
+
* - Ao perder o foco, se estiver em `dd/mm/yy`, o componente normaliza o ano para 4 dígitos.
|
|
36
|
+
* - Quando a data estiver completa e for válida, a idade é calculada e exibida na label.
|
|
37
|
+
* - Erros sempre têm prioridade no helperText (a label não exibe idade quando há erro).
|
|
38
|
+
*
|
|
39
|
+
* Tokens de estilo (ordem de prioridade):
|
|
40
|
+
* - props do componente
|
|
41
|
+
* - `theme.pipelinesolucoes.forms.field`
|
|
42
|
+
* - fallback interno (constantes `fb*`)
|
|
43
|
+
*
|
|
44
|
+
* @param {string} [id] Identificador do campo.
|
|
45
|
+
* @param {string} [label] Rótulo exibido acima do campo.
|
|
46
|
+
* @param {string} [placeholder='dd/mm/aaaa'] Placeholder do input.
|
|
47
|
+
* @param {string} [value] Valor do campo (controlado).
|
|
48
|
+
* @param {boolean} [disabled=false] Define se o campo está desabilitado.
|
|
49
|
+
*
|
|
50
|
+
* @param {number} [minLength] Número mínimo de caracteres para validação (após máscara).
|
|
51
|
+
* @param {number} [maxLength] Número máximo de caracteres para validação (após máscara).
|
|
52
|
+
*
|
|
53
|
+
* @param {boolean} [required=false] Define se é obrigatório.
|
|
54
|
+
* @param {string} [requiredMessage='Campo obrigatório'] Mensagem de obrigatório.
|
|
55
|
+
* @param {RegExp | string} [pattern] Pattern para validação do valor formatado.
|
|
56
|
+
* @param {string} [patternMessage='Formato inválido'] Mensagem do pattern.
|
|
57
|
+
* @param {'change' | 'blur'} [showErrorOn='blur'] Momento de exibir o erro.
|
|
58
|
+
* @param {(value: string) => string | null | undefined} [validate] Validação customizada do valor formatado.
|
|
59
|
+
*
|
|
60
|
+
* @param {(age: number | null) => void} [onAgeChange] Callback com a idade calculada (ou null se inválido/incompleto).
|
|
61
|
+
* @param {(event: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => void} [onChange] Callback disparado ao alterar (já com valor formatado).
|
|
62
|
+
* @param {(event: React.FocusEvent<HTMLInputElement | HTMLTextAreaElement>) => void} [onBlur] Callback disparado ao perder o foco.
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* ```tsx
|
|
66
|
+
* const Example = () => {
|
|
67
|
+
* const [birthDate, setBirthDate] = React.useState('');
|
|
68
|
+
*
|
|
69
|
+
* return (
|
|
70
|
+
* <TextFieldBirthDateWithAge
|
|
71
|
+
* label="Data de nascimento"
|
|
72
|
+
* value={birthDate}
|
|
73
|
+
* required
|
|
74
|
+
* showErrorOn="blur"
|
|
75
|
+
* onChange={(e) => setBirthDate(e.target.value)}
|
|
76
|
+
* onAgeChange={(age) => console.log('idade', age)}
|
|
77
|
+
* />
|
|
78
|
+
* );
|
|
79
|
+
* };
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
82
|
+
declare const TextFieldBirthDateWithAge: React.FC<TextFieldBirthDateWithAgeProps>;
|
|
83
|
+
export default TextFieldBirthDateWithAge;
|