@ssplib/react-components 0.0.296 → 0.0.298
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/package.json +12 -2
- package/components/detalhes/Category.d.ts +0 -4
- package/components/detalhes/Category.js +0 -14
- package/components/detalhes/Field.d.ts +0 -9
- package/components/detalhes/Field.js +0 -42
- package/components/detalhes/FieldLabel.d.ts +0 -9
- package/components/detalhes/FieldLabel.js +0 -28
- package/components/detalhes/File.d.ts +0 -8
- package/components/detalhes/File.js +0 -62
- package/components/form/checkbox/CheckBox.d.ts +0 -10
- package/components/form/checkbox/CheckBox.js +0 -18
- package/components/form/checkbox/CheckBoxAdditional.d.ts +0 -8
- package/components/form/checkbox/CheckBoxAdditional.js +0 -95
- package/components/form/checkbox/CheckBoxWarning.d.ts +0 -10
- package/components/form/checkbox/CheckBoxWarning.js +0 -43
- package/components/form/checkbox/RequiredCheckBoxValidator.d.ts +0 -6
- package/components/form/checkbox/RequiredCheckBoxValidator.js +0 -85
- package/components/form/date/DatePicker.d.ts +0 -14
- package/components/form/date/DatePicker.js +0 -105
- package/components/form/date/GenericDatePicker.d.ts +0 -14
- package/components/form/date/GenericDatePicker.js +0 -105
- package/components/form/date/TimePicker.d.ts +0 -11
- package/components/form/date/TimePicker.js +0 -82
- package/components/form/file/DropFileUpload.d.ts +0 -17
- package/components/form/file/DropFileUpload.js +0 -226
- package/components/form/file/FileUpload.d.ts +0 -14
- package/components/form/file/FileUpload.js +0 -200
- package/components/form/input/ActiveInput.d.ts +0 -12
- package/components/form/input/ActiveInput.js +0 -33
- package/components/form/input/AutoComplete.d.ts +0 -12
- package/components/form/input/AutoComplete.js +0 -69
- package/components/form/input/FetchAutoComplete.d.ts +0 -20
- package/components/form/input/FetchAutoComplete.js +0 -134
- package/components/form/input/FixedAutoComplete.d.ts +0 -19
- package/components/form/input/FixedAutoComplete.js +0 -83
- package/components/form/input/GenericFetchAutoComplete.d.ts +0 -20
- package/components/form/input/GenericFetchAutoComplete.js +0 -132
- package/components/form/input/GenericInput.d.ts +0 -19
- package/components/form/input/GenericInput.js +0 -168
- package/components/form/input/GenericMaskInput.d.ts +0 -14
- package/components/form/input/GenericMaskInput.js +0 -79
- package/components/form/input/GenericMultInput.d.ts +0 -14
- package/components/form/input/GenericMultInput.js +0 -67
- package/components/form/input/Input.d.ts +0 -19
- package/components/form/input/Input.js +0 -168
- package/components/form/input/MaskInput.d.ts +0 -14
- package/components/form/input/MaskInput.js +0 -78
- package/components/form/input/MultInput.d.ts +0 -14
- package/components/form/input/MultInput.js +0 -67
- package/components/form/input/OtherCheckBox.d.ts +0 -8
- package/components/form/input/OtherCheckBox.js +0 -56
- package/components/form/stepper/Stepper.d.ts +0 -16
- package/components/form/stepper/Stepper.js +0 -135
- package/components/form/stepper/StepperBlock.d.ts +0 -14
- package/components/form/stepper/StepperBlock.js +0 -97
- package/components/form/switch/Switch.d.ts +0 -11
- package/components/form/switch/Switch.js +0 -54
- package/components/form/switch/ToggleVisibility.d.ts +0 -14
- package/components/form/switch/ToggleVisibility.js +0 -61
- package/components/form/table/FilterSection.d.ts +0 -8
- package/components/form/table/FilterSection.js +0 -217
- package/components/form/table/GenericTable.d.ts +0 -8
- package/components/form/table/GenericTable.js +0 -1034
- package/components/form/table/Table.d.ts +0 -5
- package/components/form/table/Table.js +0 -514
- package/components/form/table/TableErrorState.d.ts +0 -9
- package/components/form/table/TableErrorState.js +0 -27
- package/components/form/table/TableLoadingState.d.ts +0 -6
- package/components/form/table/TableLoadingState.js +0 -39
- package/components/form/table/types.d.ts +0 -212
- package/components/form/table/types.js +0 -2
- package/components/form/table/utils.d.ts +0 -30
- package/components/form/table/utils.js +0 -361
- package/components/icons/icons.d.ts +0 -4
- package/components/icons/icons.js +0 -24
- package/components/map/AnimatedMarker.d.ts +0 -5
- package/components/map/AnimatedMarker.js +0 -65
- package/components/map/DraggableMarker.d.ts +0 -12
- package/components/map/DraggableMarker.js +0 -66
- package/components/map/Map.d.ts +0 -17
- package/components/map/Map.js +0 -23
- package/components/map/index.d.ts +0 -2
- package/components/map/index.js +0 -31
- package/components/modal/Modal.d.ts +0 -8
- package/components/modal/Modal.js +0 -105
- package/components/navbar/NavBar.d.ts +0 -16
- package/components/navbar/NavBar.js +0 -171
- package/components/navbar/TabNavBar.d.ts +0 -18
- package/components/navbar/TabNavBar.js +0 -179
- package/components/providers/FormProvider.d.ts +0 -11
- package/components/providers/FormProvider.js +0 -54
- package/components/providers/KeycloakAuthProvider.d.ts +0 -11
- package/components/providers/KeycloakAuthProvider.js +0 -118
- package/components/providers/OAuthProvider.d.ts +0 -19
- package/components/providers/OAuthProvider.js +0 -138
- package/components/providers/SspComponentsProvider.d.ts +0 -4
- package/components/providers/SspComponentsProvider.js +0 -18
- package/components/utils/Bt.d.ts +0 -9
- package/components/utils/Bt.js +0 -35
- package/components/utils/CustomMenu.d.ts +0 -12
- package/components/utils/CustomMenu.js +0 -39
- package/context/auth.d.ts +0 -3
- package/context/auth.js +0 -5
- package/context/form.d.ts +0 -20
- package/context/form.js +0 -5
- package/index.d.ts +0 -44
- package/index.js +0 -94
- package/types/auth.d.ts +0 -72
- package/types/auth.js +0 -2
- package/types/form.d.ts +0 -64
- package/types/form.js +0 -31
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
const material_1 = require("@mui/material");
|
|
30
|
-
const lodash_get_1 = __importDefault(require("lodash.get"));
|
|
31
|
-
const react_1 = __importStar(require("react"));
|
|
32
|
-
const auth_1 = require("../../../context/auth");
|
|
33
|
-
const react_hook_form_1 = require("react-hook-form");
|
|
34
|
-
let useDefault = true;
|
|
35
|
-
function GenericFetchAutoComplete({ name, url, title, customLoadingText, shouldRefetch = true, required = false, defaultValue, route = '', onChange = () => { }, xs = 12, sm, watchValue, md, disabled = false, }) {
|
|
36
|
-
const context = (0, react_hook_form_1.useFormContext)();
|
|
37
|
-
const [loading, setLoading] = (0, react_1.useState)(true);
|
|
38
|
-
const [list, setList] = (0, react_1.useState)([]);
|
|
39
|
-
const [loadingText, setLoadingText] = (0, react_1.useState)('Carregando...');
|
|
40
|
-
const [dValue, setDValue] = (0, react_1.useState)(null);
|
|
41
|
-
const [value, setValue] = (0, react_1.useState)(null);
|
|
42
|
-
const { user } = (0, react_1.useContext)(auth_1.AuthContext);
|
|
43
|
-
(0, react_1.useEffect)(() => {
|
|
44
|
-
if (defaultValue) {
|
|
45
|
-
fetch(url, {
|
|
46
|
-
method: 'GET',
|
|
47
|
-
headers: {
|
|
48
|
-
Authorization: `Bearer ${user === null || user === void 0 ? void 0 : user.token}`,
|
|
49
|
-
},
|
|
50
|
-
}).then((res) => {
|
|
51
|
-
if (res.ok) {
|
|
52
|
-
console.log('llll');
|
|
53
|
-
res.json().then((j) => {
|
|
54
|
-
let value = (0, lodash_get_1.default)(j, route, j).filter((x) => x.id === defaultValue);
|
|
55
|
-
if (value.length > 0) {
|
|
56
|
-
setList((0, lodash_get_1.default)(j, route, j));
|
|
57
|
-
setLoading(false);
|
|
58
|
-
context.setValue(name, defaultValue);
|
|
59
|
-
setDValue(value[0]);
|
|
60
|
-
}
|
|
61
|
-
else {
|
|
62
|
-
setLoadingText('Erro ao carregar dados. Valor inválido');
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
else {
|
|
67
|
-
setLoadingText('Erro ao carregar dados');
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
}, []);
|
|
72
|
-
(0, react_1.useEffect)(() => {
|
|
73
|
-
if (watchValue && useDefault) {
|
|
74
|
-
setValue(watchValue);
|
|
75
|
-
context.setValue(name, watchValue.id);
|
|
76
|
-
onChange(watchValue.id);
|
|
77
|
-
}
|
|
78
|
-
}, [watchValue]);
|
|
79
|
-
function onFocus() {
|
|
80
|
-
if ((defaultValue || !shouldRefetch) && list.length > 0)
|
|
81
|
-
return;
|
|
82
|
-
setLoading(true);
|
|
83
|
-
setList([]);
|
|
84
|
-
customLoadingText && setLoadingText(customLoadingText);
|
|
85
|
-
fetch(url, {
|
|
86
|
-
method: 'GET',
|
|
87
|
-
headers: {
|
|
88
|
-
Authorization: `Bearer ${user === null || user === void 0 ? void 0 : user.token}`,
|
|
89
|
-
},
|
|
90
|
-
}).then((res) => {
|
|
91
|
-
if (res.ok) {
|
|
92
|
-
res.json().then((j) => {
|
|
93
|
-
setList((0, lodash_get_1.default)(j, route, j));
|
|
94
|
-
setLoading(false);
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
else {
|
|
98
|
-
setLoadingText('Erro ao carregar dados');
|
|
99
|
-
}
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
function handleAutoCompleteChange(value) {
|
|
103
|
-
useDefault = false;
|
|
104
|
-
if (value) {
|
|
105
|
-
setValue(value);
|
|
106
|
-
context.setValue(name, value.id);
|
|
107
|
-
onChange(value.id);
|
|
108
|
-
return;
|
|
109
|
-
}
|
|
110
|
-
setValue(null);
|
|
111
|
-
context.setValue(name, '');
|
|
112
|
-
onChange(undefined);
|
|
113
|
-
}
|
|
114
|
-
if (defaultValue && list.length <= 0 && !dValue)
|
|
115
|
-
return (react_1.default.createElement(material_1.Grid, Object.assign({ item: true }, { xs, sm, md }),
|
|
116
|
-
react_1.default.createElement(material_1.TextField, { size: 'small', fullWidth: true, placeholder: loadingText, disabled: true })));
|
|
117
|
-
return (react_1.default.createElement(material_1.Grid, Object.assign({ item: true }, { xs, sm, md }),
|
|
118
|
-
title && react_1.default.createElement(material_1.InputLabel, { required: required }, title),
|
|
119
|
-
react_1.default.createElement("input", Object.assign({ type: 'text' }, context === null || context === void 0 ? void 0 : context.register(name, {
|
|
120
|
-
validate: (v, f) => {
|
|
121
|
-
if (v.length <= 0 && required)
|
|
122
|
-
return 'Este campo é obrigatório';
|
|
123
|
-
},
|
|
124
|
-
}), { hidden: true })),
|
|
125
|
-
react_1.default.createElement(material_1.Autocomplete, { value: value, loading: loading, loadingText: loadingText, options: list, defaultValue: dValue, getOptionDisabled: (option) => { var _a; return (_a = option === null || option === void 0 ? void 0 : option.disabled) !== null && _a !== void 0 ? _a : false; }, isOptionEqualToValue: (op, value) => op.id === value.id, onChange: (e, v) => handleAutoCompleteChange(v), renderInput: (params) => {
|
|
126
|
-
var _a;
|
|
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.formState.errors, name) ? true : false, helperText: (_a = (0, lodash_get_1.default)(context.formState.errors, name)) === null || _a === void 0 ? void 0 : _a.message })));
|
|
128
|
-
}, sx: {
|
|
129
|
-
bgcolor: 'white',
|
|
130
|
-
}, size: 'small', fullWidth: true, disabled: disabled })));
|
|
131
|
-
}
|
|
132
|
-
exports.default = GenericFetchAutoComplete;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
export declare function Input({ type, numberMask, xs, sm, inputMinLength, inputMaxLength, defaultValue, md, disabled, watchValue, ...props }: {
|
|
3
|
-
type: 'cnpj' | 'cpf' | 'input' | 'email' | 'cpf_cnpj' | 'phone' | 'input' | 'number' | 'rg' | 'password' | 'cep' | 'sei';
|
|
4
|
-
name: string;
|
|
5
|
-
watchValue?: string;
|
|
6
|
-
title?: string;
|
|
7
|
-
required?: boolean;
|
|
8
|
-
numberMask?: string;
|
|
9
|
-
customPlaceholder?: string;
|
|
10
|
-
defaultValue?: string;
|
|
11
|
-
inputMinLength?: number;
|
|
12
|
-
inputMaxLength?: number;
|
|
13
|
-
xs?: number;
|
|
14
|
-
sm?: number;
|
|
15
|
-
md?: number;
|
|
16
|
-
disabled?: boolean;
|
|
17
|
-
}): JSX.Element;
|
|
18
|
-
declare const _default: React.MemoExoticComponent<typeof Input>;
|
|
19
|
-
export default _default;
|
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
26
|
-
var t = {};
|
|
27
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
28
|
-
t[p] = s[p];
|
|
29
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
30
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
31
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
32
|
-
t[p[i]] = s[p[i]];
|
|
33
|
-
}
|
|
34
|
-
return t;
|
|
35
|
-
};
|
|
36
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
37
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
38
|
-
};
|
|
39
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
-
exports.Input = void 0;
|
|
41
|
-
const material_1 = require("@mui/material");
|
|
42
|
-
const lodash_get_1 = __importDefault(require("lodash.get"));
|
|
43
|
-
const react_1 = __importStar(require("react"));
|
|
44
|
-
const MaskInput_1 = __importDefault(require("./MaskInput"));
|
|
45
|
-
const react_hook_form_1 = require("react-hook-form");
|
|
46
|
-
function Input(_a) {
|
|
47
|
-
var { type = 'input', numberMask = '000000000000000', xs = 12, sm, inputMinLength = 1, inputMaxLength = 255, defaultValue = '', md, disabled = false, watchValue } = _a, props = __rest(_a, ["type", "numberMask", "xs", "sm", "inputMinLength", "inputMaxLength", "defaultValue", "md", "disabled", "watchValue"]);
|
|
48
|
-
const methods = (0, react_hook_form_1.useFormContext)();
|
|
49
|
-
(0, react_1.useEffect)(() => {
|
|
50
|
-
if (watchValue !== undefined)
|
|
51
|
-
methods.setValue(props.name, watchValue);
|
|
52
|
-
}, [watchValue]);
|
|
53
|
-
const chooseInput = () => {
|
|
54
|
-
const inputConfig = {
|
|
55
|
-
fullWidth: true,
|
|
56
|
-
size: 'small',
|
|
57
|
-
placeholder: props.customPlaceholder ? props.customPlaceholder : props.title,
|
|
58
|
-
};
|
|
59
|
-
const name = props.name;
|
|
60
|
-
const errorData = (0, lodash_get_1.default)(methods === null || methods === void 0 ? void 0 : methods.formState.errors, props.name);
|
|
61
|
-
const helperText = errorData === null || errorData === void 0 ? void 0 : errorData.message;
|
|
62
|
-
const error = errorData ? true : false;
|
|
63
|
-
const formConfig = Object.assign(Object.assign(Object.assign(Object.assign({}, methods === null || methods === void 0 ? void 0 : methods.register(name, {
|
|
64
|
-
validate: (v, f) => {
|
|
65
|
-
const value = v !== null && v !== void 0 ? v : '';
|
|
66
|
-
if (value.length <= 0 && props.required)
|
|
67
|
-
return 'Este campo é obrigatório';
|
|
68
|
-
if (type === 'cnpj') {
|
|
69
|
-
if (value.length < 18 && props.required)
|
|
70
|
-
return 'O CNPJ precisa ter no mínimo 14 dígitos';
|
|
71
|
-
}
|
|
72
|
-
//
|
|
73
|
-
else if (type === 'cpf') {
|
|
74
|
-
if (value.length < 14 && props.required)
|
|
75
|
-
return 'O CPF precisa ter no mínimo 11 dígitos';
|
|
76
|
-
} //
|
|
77
|
-
else if (type === 'sei') {
|
|
78
|
-
if (value.length < 22 && props.required)
|
|
79
|
-
return 'O Número SEI precisa ter no mínimo 19 dígitos';
|
|
80
|
-
}
|
|
81
|
-
//
|
|
82
|
-
else if (type === 'cep') {
|
|
83
|
-
if (value.length < 9 && props.required)
|
|
84
|
-
return 'O CPF precisa ter no mínimo 8 dígitos';
|
|
85
|
-
}
|
|
86
|
-
//
|
|
87
|
-
else if (type === 'input' || type === 'password' || type === 'number') {
|
|
88
|
-
if (value.length > inputMaxLength)
|
|
89
|
-
return `Limite máximo de ${inputMaxLength} caracteres`;
|
|
90
|
-
if (value.length < inputMinLength && props.required)
|
|
91
|
-
return `Limite mínimo de ${inputMinLength} caracteres`;
|
|
92
|
-
}
|
|
93
|
-
//
|
|
94
|
-
else if (type === 'email') {
|
|
95
|
-
if (value.length > 50)
|
|
96
|
-
return 'Limite máximo de 50 caracteres';
|
|
97
|
-
if (!/^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/g.test(v) && props.required)
|
|
98
|
-
return 'O e-mail inserido não é valido';
|
|
99
|
-
}
|
|
100
|
-
//
|
|
101
|
-
else if (type === 'cpf_cnpj') {
|
|
102
|
-
if ((value.length < 14 || (value.length > 14 && value.length < 18)) && props.required)
|
|
103
|
-
return 'O CPF/CNPJ precisa ter no mínimo 11/14 dígitos';
|
|
104
|
-
}
|
|
105
|
-
//
|
|
106
|
-
else if (type === 'phone') {
|
|
107
|
-
if (value.length < 14 && props.required)
|
|
108
|
-
return 'O número precisa ter pelo menos 10 dígitos';
|
|
109
|
-
}
|
|
110
|
-
},
|
|
111
|
-
})), { error,
|
|
112
|
-
helperText }), inputConfig), { sx: {
|
|
113
|
-
backgroundColor: 'white',
|
|
114
|
-
} });
|
|
115
|
-
switch (type) {
|
|
116
|
-
case 'input':
|
|
117
|
-
case 'email':
|
|
118
|
-
return react_1.default.createElement(material_1.TextField, Object.assign({}, formConfig, { defaultValue: defaultValue, disabled: disabled }));
|
|
119
|
-
case 'password':
|
|
120
|
-
return react_1.default.createElement(material_1.TextField, Object.assign({}, formConfig, { type: 'password', disabled: disabled }));
|
|
121
|
-
case 'number':
|
|
122
|
-
return (react_1.default.createElement(MaskInput_1.default, { formConfig: formConfig, defaultValue: defaultValue, maskProps: {
|
|
123
|
-
mask: numberMask,
|
|
124
|
-
}, watchValue: watchValue, disabled: disabled }));
|
|
125
|
-
case 'cep':
|
|
126
|
-
return (react_1.default.createElement(MaskInput_1.default, { formConfig: formConfig, defaultValue: defaultValue, maskProps: {
|
|
127
|
-
mask: '00000-000',
|
|
128
|
-
}, watchValue: watchValue, disabled: disabled }));
|
|
129
|
-
case 'phone':
|
|
130
|
-
return (react_1.default.createElement(MaskInput_1.default, { formConfig: formConfig, defaultValue: defaultValue, maskProps: {
|
|
131
|
-
mask: '(00) [#]0000-0000',
|
|
132
|
-
definitions: {
|
|
133
|
-
'#': /^9$/,
|
|
134
|
-
},
|
|
135
|
-
}, watchValue: watchValue, disabled: disabled }));
|
|
136
|
-
case 'sei':
|
|
137
|
-
return (react_1.default.createElement(MaskInput_1.default, { formConfig: formConfig, defaultValue: defaultValue, maskProps: {
|
|
138
|
-
mask: '00000-00000000/0000-00',
|
|
139
|
-
}, watchValue: watchValue, disabled: disabled }));
|
|
140
|
-
case 'cpf_cnpj':
|
|
141
|
-
return (react_1.default.createElement(MaskInput_1.default, { formConfig: formConfig, defaultValue: defaultValue, maskProps: {
|
|
142
|
-
mask: '000.000.000-00[0]',
|
|
143
|
-
}, onMask: (value, setMask) => {
|
|
144
|
-
if (value.length > 14)
|
|
145
|
-
setMask('00.000.000/0000-00');
|
|
146
|
-
else
|
|
147
|
-
setMask('000.000.000-00[0]');
|
|
148
|
-
}, watchValue: watchValue, disabled: disabled }));
|
|
149
|
-
case 'cpf':
|
|
150
|
-
return (react_1.default.createElement(MaskInput_1.default, { formConfig: formConfig, defaultValue: defaultValue, maskProps: {
|
|
151
|
-
mask: '000.000.000-00',
|
|
152
|
-
}, watchValue: watchValue, disabled: disabled }));
|
|
153
|
-
case 'cnpj':
|
|
154
|
-
return (react_1.default.createElement(MaskInput_1.default, { formConfig: formConfig, defaultValue: defaultValue, maskProps: {
|
|
155
|
-
mask: '00.000.000/0000-00',
|
|
156
|
-
}, watchValue: watchValue, disabled: disabled }));
|
|
157
|
-
case 'rg':
|
|
158
|
-
return (react_1.default.createElement(MaskInput_1.default, { formConfig: formConfig, defaultValue: defaultValue, maskProps: {
|
|
159
|
-
mask: '00000[000000]',
|
|
160
|
-
}, watchValue: watchValue, disabled: disabled }));
|
|
161
|
-
}
|
|
162
|
-
};
|
|
163
|
-
return (react_1.default.createElement(material_1.Grid, Object.assign({ item: true }, { xs, sm, md }),
|
|
164
|
-
props.title && (react_1.default.createElement(material_1.InputLabel, { htmlFor: 'campo', required: props.required }, props.title)),
|
|
165
|
-
chooseInput()));
|
|
166
|
-
}
|
|
167
|
-
exports.Input = Input;
|
|
168
|
-
exports.default = react_1.default.memo(Input);
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
export default function GenericMaskInput(props: {
|
|
3
|
-
formConfig: object;
|
|
4
|
-
defaultValue?: string;
|
|
5
|
-
maskProps: {
|
|
6
|
-
mask: string | RegExp;
|
|
7
|
-
definitions?: {
|
|
8
|
-
[key: string]: string | RegExp;
|
|
9
|
-
};
|
|
10
|
-
};
|
|
11
|
-
disabled?: boolean;
|
|
12
|
-
watchValue?: string;
|
|
13
|
-
onMask?: (value: string, setMask: React.Dispatch<React.SetStateAction<string>>) => void;
|
|
14
|
-
}): JSX.Element;
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
26
|
-
var t = {};
|
|
27
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
28
|
-
t[p] = s[p];
|
|
29
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
30
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
31
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
32
|
-
t[p[i]] = s[p[i]];
|
|
33
|
-
}
|
|
34
|
-
return t;
|
|
35
|
-
};
|
|
36
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
-
const material_1 = require("@mui/material");
|
|
38
|
-
const react_1 = __importStar(require("react"));
|
|
39
|
-
const react_imask_1 = require("react-imask");
|
|
40
|
-
const form_1 = require("../../../context/form");
|
|
41
|
-
const react_hook_form_1 = require("react-hook-form");
|
|
42
|
-
const TextMaskCustom = react_1.default.forwardRef(function TextMaskCustom(props, ref) {
|
|
43
|
-
const { onChange, maskProps, onMask, maskValue, setMaskValue, watchValue } = props, prop = __rest(props, ["onChange", "maskProps", "onMask", "maskValue", "setMaskValue", "watchValue"]);
|
|
44
|
-
const [mask, setMask] = (0, react_1.useState)(maskProps.mask);
|
|
45
|
-
delete prop.value;
|
|
46
|
-
const myRef = (0, react_1.useRef)(null);
|
|
47
|
-
const [myValue, setMyValue] = (0, react_1.useState)('');
|
|
48
|
-
const context = (0, react_hook_form_1.useFormContext)();
|
|
49
|
-
(0, react_1.useEffect)(() => {
|
|
50
|
-
if (watchValue) {
|
|
51
|
-
setMyValue(watchValue);
|
|
52
|
-
}
|
|
53
|
-
}, [watchValue]);
|
|
54
|
-
(0, react_1.useEffect)(() => {
|
|
55
|
-
context.setValue(prop.name, myRef.current.element.value);
|
|
56
|
-
}, [myValue]);
|
|
57
|
-
delete prop.watchValue;
|
|
58
|
-
return (react_1.default.createElement(react_imask_1.IMaskInput, Object.assign({}, prop, maskProps, { mask: mask, value: myValue, ref: myRef, inputRef: ref, onChange: (e) => { }, onAccept: (value, mask) => {
|
|
59
|
-
setMyValue(value);
|
|
60
|
-
mask.updateValue();
|
|
61
|
-
if (!onMask)
|
|
62
|
-
return;
|
|
63
|
-
onMask(value, setMask);
|
|
64
|
-
} })));
|
|
65
|
-
});
|
|
66
|
-
function GenericMaskInput(props) {
|
|
67
|
-
const context = (0, react_1.useContext)(form_1.FormContext);
|
|
68
|
-
const [maskValue, setMaskValue] = (0, react_1.useState)('');
|
|
69
|
-
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
70
|
-
react_1.default.createElement(material_1.TextField, Object.assign({}, props.formConfig, { onInput: (e) => {
|
|
71
|
-
const name = props.formConfig.name;
|
|
72
|
-
const value = e.target.value;
|
|
73
|
-
context.formSetValue(name, value);
|
|
74
|
-
}, InputProps: {
|
|
75
|
-
inputComponent: TextMaskCustom,
|
|
76
|
-
inputProps: { maskProps: props.maskProps, onMask: props.onMask, maskValue, setMaskValue, watchValue: props.watchValue },
|
|
77
|
-
}, disabled: props.disabled, fullWidth: true }))));
|
|
78
|
-
}
|
|
79
|
-
exports.default = GenericMaskInput;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
export default function MultInput({ name, required, title, customPlaceholder, defaultValue, xs, sm, watchValue, inputMinLength, inputMaxLength, md, ...props }: {
|
|
3
|
-
name: string;
|
|
4
|
-
title?: string;
|
|
5
|
-
watchValue?: string;
|
|
6
|
-
customPlaceholder?: string;
|
|
7
|
-
required?: boolean;
|
|
8
|
-
defaultValue?: string;
|
|
9
|
-
inputMinLength?: number;
|
|
10
|
-
inputMaxLength?: number;
|
|
11
|
-
xs?: number;
|
|
12
|
-
sm?: number;
|
|
13
|
-
md?: number;
|
|
14
|
-
}): JSX.Element;
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
26
|
-
var t = {};
|
|
27
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
28
|
-
t[p] = s[p];
|
|
29
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
30
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
31
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
32
|
-
t[p[i]] = s[p[i]];
|
|
33
|
-
}
|
|
34
|
-
return t;
|
|
35
|
-
};
|
|
36
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
37
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
38
|
-
};
|
|
39
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
-
const material_1 = require("@mui/material");
|
|
41
|
-
const InputLabel_1 = __importDefault(require("@mui/material/InputLabel"));
|
|
42
|
-
const lodash_get_1 = __importDefault(require("lodash.get"));
|
|
43
|
-
const react_1 = __importStar(require("react"));
|
|
44
|
-
const react_hook_form_1 = require("react-hook-form");
|
|
45
|
-
function MultInput(_a) {
|
|
46
|
-
var _b;
|
|
47
|
-
var { name, required = false, title, customPlaceholder, defaultValue = '', xs = 12, sm, watchValue = '', inputMinLength = 3, inputMaxLength = 255, md } = _a, props = __rest(_a, ["name", "required", "title", "customPlaceholder", "defaultValue", "xs", "sm", "watchValue", "inputMinLength", "inputMaxLength", "md"]);
|
|
48
|
-
const context = (0, react_hook_form_1.useFormContext)();
|
|
49
|
-
(0, react_1.useEffect)(() => {
|
|
50
|
-
context.setValue(name, watchValue);
|
|
51
|
-
}, [watchValue]);
|
|
52
|
-
return (react_1.default.createElement(material_1.Grid, Object.assign({ item: true }, { xs, sm, md }),
|
|
53
|
-
title && (react_1.default.createElement(InputLabel_1.default, { required: required, sx: { textTransform: 'capitalize' } }, title)),
|
|
54
|
-
react_1.default.createElement(material_1.TextField, Object.assign({ multiline: true, fullWidth: true, minRows: 3, defaultValue: defaultValue }, context.register(name, {
|
|
55
|
-
validate: (v, f) => {
|
|
56
|
-
if (required && v.length <= 0)
|
|
57
|
-
return 'Este campo é obrigatório';
|
|
58
|
-
if (v.length > inputMaxLength)
|
|
59
|
-
return `Limite máximo de ${inputMaxLength} caracteres`;
|
|
60
|
-
if (v.length < inputMinLength && required)
|
|
61
|
-
return `Limite mínimo de ${inputMinLength} caracteres`;
|
|
62
|
-
},
|
|
63
|
-
}), { error: (0, lodash_get_1.default)(context.formState.errors, name) ? true : false, helperText: (_b = (0, lodash_get_1.default)(context.formState.errors, name)) === null || _b === void 0 ? void 0 : _b.message, sx: {
|
|
64
|
-
bgcolor: 'white',
|
|
65
|
-
}, placeholder: customPlaceholder ? customPlaceholder : title }))));
|
|
66
|
-
}
|
|
67
|
-
exports.default = MultInput;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
export declare function Input({ type, numberMask, xs, sm, inputMinLength, inputMaxLength, defaultValue, md, disabled, watchValue, ...props }: {
|
|
3
|
-
type: 'cnpj' | 'cpf' | 'input' | 'email' | 'cpf_cnpj' | 'phone' | 'input' | 'number' | 'rg' | 'password' | 'cep' | 'sei';
|
|
4
|
-
name: string;
|
|
5
|
-
watchValue?: string;
|
|
6
|
-
title?: string;
|
|
7
|
-
required?: boolean;
|
|
8
|
-
numberMask?: string;
|
|
9
|
-
customPlaceholder?: string;
|
|
10
|
-
defaultValue?: string;
|
|
11
|
-
inputMinLength?: number;
|
|
12
|
-
inputMaxLength?: number;
|
|
13
|
-
xs?: number;
|
|
14
|
-
sm?: number;
|
|
15
|
-
md?: number;
|
|
16
|
-
disabled?: boolean;
|
|
17
|
-
}): JSX.Element;
|
|
18
|
-
declare const _default: React.MemoExoticComponent<typeof Input>;
|
|
19
|
-
export default _default;
|