@ssplib/react-components 0.0.255 → 0.0.257
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/FetchAutoComplete.d.ts +2 -1
- package/components/form/input/FetchAutoComplete.js +2 -2
- package/components/form/input/Input.d.ts +2 -1
- package/components/form/input/Input.js +11 -11
- package/components/providers/KeycloakAuthProvider.d.ts +2 -1
- package/components/providers/KeycloakAuthProvider.js +2 -3
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
export default function FetchAutoComplete({ name, url, title, customLoadingText, shouldRefetch, required, defaultValue, route, onChange, xs, sm, watchValue, md, }: {
|
|
2
|
+
export default function FetchAutoComplete({ name, url, title, customLoadingText, shouldRefetch, required, defaultValue, route, onChange, xs, sm, watchValue, md, disabled, }: {
|
|
3
3
|
name: string;
|
|
4
4
|
url: string;
|
|
5
5
|
title: string;
|
|
@@ -16,4 +16,5 @@ export default function FetchAutoComplete({ name, url, title, customLoadingText,
|
|
|
16
16
|
xs?: number;
|
|
17
17
|
sm?: number;
|
|
18
18
|
md?: number;
|
|
19
|
+
disabled?: boolean;
|
|
19
20
|
}): JSX.Element;
|
|
@@ -32,7 +32,7 @@ const react_1 = __importStar(require("react"));
|
|
|
32
32
|
const auth_1 = require("../../../context/auth");
|
|
33
33
|
const form_1 = require("../../../context/form");
|
|
34
34
|
let useDefault = true;
|
|
35
|
-
function FetchAutoComplete({ name, url, title, customLoadingText, shouldRefetch = true, required = false, defaultValue, route = '', onChange = () => { }, xs = 12, sm, watchValue, md, }) {
|
|
35
|
+
function FetchAutoComplete({ name, url, title, customLoadingText, shouldRefetch = true, required = false, defaultValue, route = '', onChange = () => { }, xs = 12, sm, watchValue, md, disabled = false, }) {
|
|
36
36
|
const context = (0, react_1.useContext)(form_1.FormContext);
|
|
37
37
|
const [loading, setLoading] = (0, react_1.useState)(true);
|
|
38
38
|
const [list, setList] = (0, react_1.useState)([]);
|
|
@@ -127,6 +127,6 @@ function FetchAutoComplete({ name, url, title, customLoadingText, shouldRefetch
|
|
|
127
127
|
return (react_1.default.createElement(material_1.TextField, Object.assign({}, params, { size: 'small', fullWidth: true, placeholder: title, onFocus: onFocus, error: (0, lodash_get_1.default)(context === null || context === void 0 ? void 0 : context.errors, name) ? true : false, helperText: (_a = (0, lodash_get_1.default)(context === null || context === void 0 ? void 0 : context.errors, name)) === null || _a === void 0 ? void 0 : _a.message })));
|
|
128
128
|
}, sx: {
|
|
129
129
|
bgcolor: 'white',
|
|
130
|
-
}, size: 'small', fullWidth: true })));
|
|
130
|
+
}, size: 'small', fullWidth: true, disabled: disabled })));
|
|
131
131
|
}
|
|
132
132
|
exports.default = FetchAutoComplete;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
export declare function Input({ type, numberMask, xs, sm, inputMinLength, inputMaxLength, defaultValue, md, watchValue, ...props }: {
|
|
2
|
+
export declare function Input({ type, numberMask, xs, sm, inputMinLength, inputMaxLength, defaultValue, md, watchValue, disabled, ...props }: {
|
|
3
3
|
type: 'cnpj' | 'cpf' | 'input' | 'email' | 'cpf_cnpj' | 'phone' | 'input' | 'number' | 'rg' | 'password' | 'cep' | 'sei';
|
|
4
4
|
name: string;
|
|
5
5
|
watchValue?: string;
|
|
@@ -13,6 +13,7 @@ export declare function Input({ type, numberMask, xs, sm, inputMinLength, inputM
|
|
|
13
13
|
xs?: number;
|
|
14
14
|
sm?: number;
|
|
15
15
|
md?: number;
|
|
16
|
+
disabled?: boolean;
|
|
16
17
|
}): JSX.Element;
|
|
17
18
|
declare const _default: React.MemoExoticComponent<typeof Input>;
|
|
18
19
|
export default _default;
|
|
@@ -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, inputMinLength = 1, inputMaxLength = 255, defaultValue = '', md, watchValue = '' } = _a, props = __rest(_a, ["type", "numberMask", "xs", "sm", "inputMinLength", "inputMaxLength", "defaultValue", "md", "watchValue"]);
|
|
47
|
+
var { type = 'input', numberMask = '000000000000000', xs = 12, sm, inputMinLength = 1, inputMaxLength = 255, defaultValue = '', md, watchValue = '', disabled = false } = _a, props = __rest(_a, ["type", "numberMask", "xs", "sm", "inputMinLength", "inputMaxLength", "defaultValue", "md", "watchValue", "disabled"]);
|
|
48
48
|
const context = (0, react_1.useContext)(form_1.FormContext);
|
|
49
49
|
(0, react_1.useEffect)(() => {
|
|
50
50
|
context.formSetValue(props.name, watchValue);
|
|
@@ -114,28 +114,28 @@ function Input(_a) {
|
|
|
114
114
|
switch (type) {
|
|
115
115
|
case 'input':
|
|
116
116
|
case 'email':
|
|
117
|
-
return react_1.default.createElement(material_1.TextField, Object.assign({}, formConfig, { defaultValue: defaultValue }));
|
|
117
|
+
return react_1.default.createElement(material_1.TextField, Object.assign({}, formConfig, { defaultValue: defaultValue, disabled: disabled }));
|
|
118
118
|
case 'password':
|
|
119
|
-
return react_1.default.createElement(material_1.TextField, Object.assign({}, formConfig, { type: 'password' }));
|
|
119
|
+
return react_1.default.createElement(material_1.TextField, Object.assign({}, formConfig, { type: 'password', disabled: disabled }));
|
|
120
120
|
case 'number':
|
|
121
121
|
return (react_1.default.createElement(MaskInput_1.default, { formConfig: formConfig, defaultValue: defaultValue, maskProps: {
|
|
122
122
|
mask: numberMask,
|
|
123
|
-
}, watchValue: watchValue }));
|
|
123
|
+
}, watchValue: watchValue, disabled: disabled }));
|
|
124
124
|
case 'cep':
|
|
125
125
|
return (react_1.default.createElement(MaskInput_1.default, { formConfig: formConfig, defaultValue: defaultValue, maskProps: {
|
|
126
126
|
mask: '00000-000',
|
|
127
|
-
}, watchValue: watchValue }));
|
|
127
|
+
}, watchValue: watchValue, disabled: disabled }));
|
|
128
128
|
case 'phone':
|
|
129
129
|
return (react_1.default.createElement(MaskInput_1.default, { formConfig: formConfig, defaultValue: defaultValue, maskProps: {
|
|
130
130
|
mask: '(00) [#]0000-0000',
|
|
131
131
|
definitions: {
|
|
132
132
|
'#': /^9$/,
|
|
133
133
|
},
|
|
134
|
-
}, watchValue: watchValue }));
|
|
134
|
+
}, watchValue: watchValue, disabled: disabled }));
|
|
135
135
|
case 'sei':
|
|
136
136
|
return (react_1.default.createElement(MaskInput_1.default, { formConfig: formConfig, defaultValue: defaultValue, maskProps: {
|
|
137
137
|
mask: '00000-00000000/0000-00',
|
|
138
|
-
}, watchValue: watchValue }));
|
|
138
|
+
}, watchValue: watchValue, disabled: disabled }));
|
|
139
139
|
case 'cpf_cnpj':
|
|
140
140
|
return (react_1.default.createElement(MaskInput_1.default, { formConfig: formConfig, defaultValue: defaultValue, maskProps: {
|
|
141
141
|
mask: '000.000.000-00[0]',
|
|
@@ -144,19 +144,19 @@ function Input(_a) {
|
|
|
144
144
|
setMask('00.000.000/0000-00');
|
|
145
145
|
else
|
|
146
146
|
setMask('000.000.000-00[0]');
|
|
147
|
-
}, watchValue: watchValue }));
|
|
147
|
+
}, watchValue: watchValue, disabled: disabled }));
|
|
148
148
|
case 'cpf':
|
|
149
149
|
return (react_1.default.createElement(MaskInput_1.default, { formConfig: formConfig, defaultValue: defaultValue, maskProps: {
|
|
150
150
|
mask: '000.000.000-00',
|
|
151
|
-
}, watchValue: watchValue }));
|
|
151
|
+
}, watchValue: watchValue, disabled: disabled }));
|
|
152
152
|
case 'cnpj':
|
|
153
153
|
return (react_1.default.createElement(MaskInput_1.default, { formConfig: formConfig, defaultValue: defaultValue, maskProps: {
|
|
154
154
|
mask: '00.000.000/0000-00',
|
|
155
|
-
}, watchValue: watchValue }));
|
|
155
|
+
}, watchValue: watchValue, disabled: disabled }));
|
|
156
156
|
case 'rg':
|
|
157
157
|
return (react_1.default.createElement(MaskInput_1.default, { formConfig: formConfig, defaultValue: defaultValue, maskProps: {
|
|
158
158
|
mask: '00000[000000]',
|
|
159
|
-
}, watchValue: watchValue }));
|
|
159
|
+
}, watchValue: watchValue, disabled: disabled }));
|
|
160
160
|
}
|
|
161
161
|
};
|
|
162
162
|
return (react_1.default.createElement(material_1.Grid, Object.assign({ item: true }, { xs, sm, md }),
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
export declare const cookieName = "nextauth.token";
|
|
3
|
-
export declare function KeycloakAuthProvider({ url, realm, clientId, children, type, resource_name, }: {
|
|
3
|
+
export declare function KeycloakAuthProvider({ url, realm, clientId, children, type, resource_name, redirectUri, }: {
|
|
4
4
|
url: string;
|
|
5
5
|
realm: string;
|
|
6
6
|
clientId: string;
|
|
7
7
|
children: JSX.Element | JSX.Element[];
|
|
8
8
|
type?: 'govbr' | 'ad';
|
|
9
9
|
resource_name?: string;
|
|
10
|
+
redirectUri?: string;
|
|
10
11
|
}): JSX.Element;
|
|
@@ -33,11 +33,10 @@ const auth_1 = require("../../context/auth");
|
|
|
33
33
|
const keycloak_js_1 = __importDefault(require("keycloak-js"));
|
|
34
34
|
exports.cookieName = 'nextauth.token';
|
|
35
35
|
const userImgName = 'user-data.img';
|
|
36
|
-
function KeycloakAuthProvider({ url, realm, clientId, children, type = 'ad', resource_name = 'eventos-front', }) {
|
|
36
|
+
function KeycloakAuthProvider({ url, realm, clientId, children, type = 'ad', resource_name = 'eventos-front', redirectUri = '', }) {
|
|
37
37
|
const [user, setUser] = (0, react_1.useState)();
|
|
38
38
|
const [userLoaded, setUserLoaded] = (0, react_1.useState)(false);
|
|
39
39
|
const [kc, setKc] = (0, react_1.useState)(null);
|
|
40
|
-
const [token, setToken] = (0, react_1.useState)(undefined);
|
|
41
40
|
const router = (0, router_1.useRouter)();
|
|
42
41
|
const isAuth = !!user;
|
|
43
42
|
(0, react_1.useEffect)(() => {
|
|
@@ -87,7 +86,7 @@ function KeycloakAuthProvider({ url, realm, clientId, children, type = 'ad', res
|
|
|
87
86
|
logado: kc === null || kc === void 0 ? void 0 : kc.authenticated,
|
|
88
87
|
client_id: kc === null || kc === void 0 ? void 0 : kc.clientId,
|
|
89
88
|
});
|
|
90
|
-
kc === null || kc === void 0 ? void 0 : kc.login();
|
|
89
|
+
kc === null || kc === void 0 ? void 0 : kc.login({ redirectUri });
|
|
91
90
|
}
|
|
92
91
|
function logout() {
|
|
93
92
|
setUserLoaded(false);
|