@ssplib/react-components 0.0.34 → 0.0.36
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/components/form/input/Input.d.ts +4 -2
- package/components/form/input/Input.js +9 -7
- package/components/form/input/MultInput.d.ts +3 -1
- package/components/form/input/MultInput.js +5 -1
- package/components/form/stepper/Stepper.js +0 -2
- package/components/form/table/Table.js +4 -4
- package/components/navbar/NavBar.d.ts +1 -1
- package/components/navbar/NavBar.js +4 -3
- package/components/providers/OAuthProvider.js +1 -1
- package/package.json +1 -1
- package/types/auth.d.ts +1 -0
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
export declare function Input({ type, numberMask, xs, sm, md, ...props }: {
|
|
3
|
-
type: 'cnpj' | 'cpf' | 'input' | 'email' | 'cpf_cnpj' | 'phone' | 'input' | 'number' | 'rg';
|
|
2
|
+
export declare function Input({ type, numberMask, xs, sm, inputMinLength, inputMaxLength, md, ...props }: {
|
|
3
|
+
type: 'cnpj' | 'cpf' | 'input' | 'email' | 'cpf_cnpj' | 'phone' | 'input' | 'number' | 'rg' | 'password';
|
|
4
4
|
name: string;
|
|
5
5
|
title?: string;
|
|
6
6
|
required?: boolean;
|
|
7
7
|
numberMask?: string;
|
|
8
8
|
customPlaceholder?: string;
|
|
9
|
+
inputMinLength?: number;
|
|
10
|
+
inputMaxLength?: number;
|
|
9
11
|
xs?: number;
|
|
10
12
|
sm?: number;
|
|
11
13
|
md?: number;
|
|
@@ -44,7 +44,7 @@ const react_1 = __importStar(require("react"));
|
|
|
44
44
|
const MaskInput_1 = __importDefault(require("./MaskInput"));
|
|
45
45
|
const form_1 = require("../../../context/form");
|
|
46
46
|
function Input(_a) {
|
|
47
|
-
var { type = 'input', numberMask = '000000000000000', xs = 12, sm, md } = _a, props = __rest(_a, ["type", "numberMask", "xs", "sm", "md"]);
|
|
47
|
+
var { type = 'input', numberMask = '000000000000000', xs = 12, sm, inputMinLength = 3, inputMaxLength = 255, md } = _a, props = __rest(_a, ["type", "numberMask", "xs", "sm", "inputMinLength", "inputMaxLength", "md"]);
|
|
48
48
|
const context = (0, react_1.useContext)(form_1.FormContext);
|
|
49
49
|
const chooseInput = (0, react_1.useCallback)(() => {
|
|
50
50
|
const inputConfig = {
|
|
@@ -70,14 +70,14 @@ function Input(_a) {
|
|
|
70
70
|
return 'O CPF precisa ter no mínimo 11 dígitos';
|
|
71
71
|
}
|
|
72
72
|
//
|
|
73
|
-
else if (type === 'input') {
|
|
74
|
-
if (v.length >
|
|
75
|
-
return
|
|
76
|
-
if (v.length <
|
|
77
|
-
return
|
|
73
|
+
else if (type === 'input' || type === 'password') {
|
|
74
|
+
if (v.length > inputMaxLength)
|
|
75
|
+
return `Limite máximo de ${inputMaxLength} caracteres`;
|
|
76
|
+
if (v.length < inputMinLength && props.required)
|
|
77
|
+
return `Limite mínimo de ${inputMinLength} caracteres`;
|
|
78
78
|
}
|
|
79
79
|
//
|
|
80
|
-
else if (type === 'email'
|
|
80
|
+
else if (type === 'email') {
|
|
81
81
|
if (v.length > 50)
|
|
82
82
|
return 'Limite máximo de 50 caracteres';
|
|
83
83
|
if (!/^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/g.test(v) && props.required)
|
|
@@ -100,6 +100,8 @@ function Input(_a) {
|
|
|
100
100
|
case 'input':
|
|
101
101
|
case 'email':
|
|
102
102
|
return react_1.default.createElement(material_1.TextField, Object.assign({}, formConfig));
|
|
103
|
+
case 'password':
|
|
104
|
+
return react_1.default.createElement(material_1.TextField, Object.assign({}, formConfig, { type: 'password' }));
|
|
103
105
|
case 'number':
|
|
104
106
|
return (react_1.default.createElement(MaskInput_1.default, { formConfig: formConfig, maskProps: {
|
|
105
107
|
mask: numberMask,
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
export default function MultInput({ name, required, title, customPlaceholder, xs, sm, md, ...props }: {
|
|
2
|
+
export default function MultInput({ name, required, title, customPlaceholder, xs, sm, inputMinLength, inputMaxLength, md, ...props }: {
|
|
3
3
|
name: string;
|
|
4
4
|
title?: string;
|
|
5
5
|
customPlaceholder?: string;
|
|
6
6
|
required?: boolean;
|
|
7
|
+
inputMinLength?: number;
|
|
8
|
+
inputMaxLength?: number;
|
|
7
9
|
xs?: number;
|
|
8
10
|
sm?: number;
|
|
9
11
|
md?: number;
|
|
@@ -44,7 +44,7 @@ const react_1 = __importStar(require("react"));
|
|
|
44
44
|
const form_1 = require("../../../context/form");
|
|
45
45
|
function MultInput(_a) {
|
|
46
46
|
var _b;
|
|
47
|
-
var { name, required = false, title, customPlaceholder, xs = 12, sm, md } = _a, props = __rest(_a, ["name", "required", "title", "customPlaceholder", "xs", "sm", "md"]);
|
|
47
|
+
var { name, required = false, title, customPlaceholder, xs = 12, sm, inputMinLength = 3, inputMaxLength = 255, md } = _a, props = __rest(_a, ["name", "required", "title", "customPlaceholder", "xs", "sm", "inputMinLength", "inputMaxLength", "md"]);
|
|
48
48
|
const context = (0, react_1.useContext)(form_1.FormContext);
|
|
49
49
|
return (react_1.default.createElement(material_1.Grid, Object.assign({ item: true }, { xs, sm, md }),
|
|
50
50
|
title && (react_1.default.createElement(InputLabel_1.default, { required: required, sx: { textTransform: 'capitalize' } }, title)),
|
|
@@ -52,6 +52,10 @@ function MultInput(_a) {
|
|
|
52
52
|
validate: (v, f) => {
|
|
53
53
|
if (required && v.length <= 0)
|
|
54
54
|
return 'Este campo é obrigatório';
|
|
55
|
+
if (v.length > inputMaxLength)
|
|
56
|
+
return `Limite máximo de ${inputMaxLength} caracteres`;
|
|
57
|
+
if (v.length < inputMinLength && required)
|
|
58
|
+
return `Limite mínimo de ${inputMinLength} caracteres`;
|
|
55
59
|
},
|
|
56
60
|
}), { error: (0, lodash_get_1.default)(context.errors, name) ? true : false, helperText: (_b = (0, lodash_get_1.default)(context.errors, name)) === null || _b === void 0 ? void 0 : _b.message, placeholder: customPlaceholder ? customPlaceholder : title }))));
|
|
57
61
|
}
|
|
@@ -68,7 +68,6 @@ function Stepper(props) {
|
|
|
68
68
|
const result = yield context.formTrigger(getKeys(context.formGetValues(), activeStep));
|
|
69
69
|
if (!result) {
|
|
70
70
|
setCanPass(true);
|
|
71
|
-
console.log('teste: ', context.formGetValues());
|
|
72
71
|
return;
|
|
73
72
|
}
|
|
74
73
|
setActiveStep((prevActiveStep) => prevActiveStep + 1);
|
|
@@ -78,7 +77,6 @@ function Stepper(props) {
|
|
|
78
77
|
if (!result) {
|
|
79
78
|
e.preventDefault();
|
|
80
79
|
setCanPass(true);
|
|
81
|
-
console.log('teste: ', context.formGetValues());
|
|
82
80
|
return;
|
|
83
81
|
}
|
|
84
82
|
});
|
|
@@ -254,10 +254,10 @@ function Table({ columns, fetchFunc, emptyMsg = {
|
|
|
254
254
|
react_1.default.createElement(Typography_1.default, { fontSize: 16, sx: { wordWrap: 'break-word', color: '#1E293B' }, fontFamily: 'Inter' }, c.keyName === 'stEventoExterno' ? getStatusMsg((0, lodash_get_1.default)(x, c.keyName)) : (0, lodash_get_1.default)(x, c.keyName)))))),
|
|
255
255
|
react_1.default.createElement(Grid_1.default, { item: true, xs: 12, md: 12 / columnSize },
|
|
256
256
|
react_1.default.createElement(material_1.Stack, { direction: 'row', alignItems: 'center', justifyContent: isSmall ? 'start' : 'flex-end', sx: { height: '100%', paddingBottom: isSmall ? 2 : 0 } }, action(x))))))))),
|
|
257
|
-
getMaxItems().length > 0 &&
|
|
258
|
-
react_1.default.createElement(material_1.Stack, { direction: 'row', justifyContent: 'flex-end', marginTop: 2 },
|
|
259
|
-
react_1.default.createElement(material_1.Button, { startIcon: react_1.default.createElement(FileDownload_1.default, null), variant: 'contained', size: 'small', onClick: downloadCSV, sx: { backgroundColor: '#22C55E', marginRight: { xs: 2, md: 0 } } }, "Salvar .CSV")),
|
|
260
|
-
react_1.default.createElement(material_1.Stack, { direction: 'row', justifyContent: 'center',
|
|
257
|
+
getMaxItems().length > 0 && (react_1.default.createElement(react_1.default.Fragment, null,
|
|
258
|
+
csv && (react_1.default.createElement(material_1.Stack, { direction: 'row', justifyContent: 'flex-end', marginTop: 2 },
|
|
259
|
+
react_1.default.createElement(material_1.Button, { startIcon: react_1.default.createElement(FileDownload_1.default, null), variant: 'contained', size: 'small', onClick: downloadCSV, sx: { backgroundColor: '#22C55E', marginRight: { xs: 2, md: 0 } } }, "Salvar .CSV"))),
|
|
260
|
+
react_1.default.createElement(material_1.Stack, { direction: 'row', justifyContent: 'center', paddingY: 4 },
|
|
261
261
|
react_1.default.createElement(Pagination_1.default, { count: paginationCount, siblingCount: isSmall ? 0 : 1, size: 'large', onChange: onPaginationChange, page: listPage })))))));
|
|
262
262
|
}
|
|
263
263
|
exports.Table = Table;
|
|
@@ -6,8 +6,8 @@ export default function NavBar({ links, title, img, pos, next, el, menuItems, }:
|
|
|
6
6
|
}[];
|
|
7
7
|
title: string;
|
|
8
8
|
img: string;
|
|
9
|
-
next?: boolean;
|
|
10
9
|
menuItems: JSX.Element | JSX.Element[];
|
|
10
|
+
next?: boolean;
|
|
11
11
|
el?: JSX.Element;
|
|
12
12
|
pos?: 'fixed' | 'inherit';
|
|
13
13
|
}): JSX.Element;
|
|
@@ -41,7 +41,7 @@ function NavBar({ links, title, img, pos = 'fixed', next = true, el, menuItems,
|
|
|
41
41
|
let router = undefined;
|
|
42
42
|
if (next)
|
|
43
43
|
router = (0, router_1.useRouter)();
|
|
44
|
-
const { user, login, logout,
|
|
44
|
+
const { user, login, logout, type } = (0, react_1.useContext)(auth_1.AuthContext);
|
|
45
45
|
const [anchor, setAnchor] = (0, react_1.useState)(null);
|
|
46
46
|
const [avatarAnchor, setAvatarAnchor] = (0, react_1.useState)(null);
|
|
47
47
|
const menuOpen = Boolean(anchor);
|
|
@@ -115,8 +115,9 @@ function NavBar({ links, title, img, pos = 'fixed', next = true, el, menuItems,
|
|
|
115
115
|
react_1.default.createElement(material_1.Stack, { direction: 'row', spacing: 0.4, alignItems: 'center', onClick: (e) => setAvatarAnchor(e.currentTarget), sx: { userSelect: 'none' } },
|
|
116
116
|
react_1.default.createElement(material_1.Typography, null, "Ol\u00E1,"),
|
|
117
117
|
react_1.default.createElement(material_1.Typography, { fontWeight: 600 }, user.name),
|
|
118
|
-
react_1.default.createElement(KeyboardArrowDown_1.default, null)))) : (react_1.default.createElement(material_1.Button, { variant: 'contained', size: 'small', startIcon: react_1.default.createElement(Person_1.default, null), onClick: login, sx: { color: 'white', textTransform: 'inherit', borderRadius: 50, paddingX: 2 } },
|
|
119
|
-
react_1.default.createElement(material_1.Typography, { fontWeight: 600, fontSize: 15, padding: 0.4 }, "Entrar com o gov.br"))))
|
|
118
|
+
react_1.default.createElement(KeyboardArrowDown_1.default, null)))) : type === 'govbr' ? (react_1.default.createElement(material_1.Button, { variant: 'contained', size: 'small', startIcon: react_1.default.createElement(Person_1.default, null), onClick: login, sx: { color: 'white', textTransform: 'inherit', borderRadius: 50, paddingX: 2 } },
|
|
119
|
+
react_1.default.createElement(material_1.Typography, { fontWeight: 600, fontSize: 15, padding: 0.4 }, "Entrar com o gov.br"))) : (react_1.default.createElement(material_1.Button, { variant: 'contained', size: 'small', startIcon: react_1.default.createElement(Person_1.default, null), onClick: login, sx: { color: 'white', textTransform: 'inherit', borderRadius: 50, paddingX: 2 } },
|
|
120
|
+
react_1.default.createElement(material_1.Typography, { fontWeight: 600, fontSize: 15, padding: 0.4 }, "Login"))))))),
|
|
120
121
|
loading && react_1.default.createElement(LinearProgress_1.default, null)),
|
|
121
122
|
react_1.default.createElement(material_1.Box, { paddingBottom: 9 })));
|
|
122
123
|
}
|
|
@@ -131,6 +131,6 @@ function OAuthProvider({ children, AUTH_URL, oidcConfig, redirectURL, validateTo
|
|
|
131
131
|
localStorage.removeItem(userImgName);
|
|
132
132
|
router.replace(redirectURL).finally(() => setUserLoaded(true));
|
|
133
133
|
}
|
|
134
|
-
return react_1.default.createElement(auth_1.AuthContext.Provider, { value: { user, isAuth, userLoaded, login, logout, saveUserData } }, children);
|
|
134
|
+
return react_1.default.createElement(auth_1.AuthContext.Provider, { value: { user, isAuth, userLoaded, login, logout, saveUserData, type: 'govbr' } }, children);
|
|
135
135
|
}
|
|
136
136
|
exports.OAuthProvider = OAuthProvider;
|
package/package.json
CHANGED