@ssplib/react-components 0.0.295 → 0.0.296
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/detalhes/Category.d.ts +1 -0
- package/components/detalhes/Category.js +14 -0
- package/components/detalhes/Field.d.ts +1 -0
- package/components/detalhes/Field.js +42 -0
- package/components/detalhes/FieldLabel.d.ts +1 -0
- package/components/detalhes/FieldLabel.js +28 -0
- package/components/detalhes/File.d.ts +1 -0
- package/components/detalhes/File.js +62 -0
- package/components/form/checkbox/CheckBox.js +18 -0
- package/components/form/checkbox/CheckBoxAdditional.d.ts +1 -0
- package/components/form/checkbox/CheckBoxAdditional.js +95 -0
- package/components/form/checkbox/CheckBoxWarning.js +43 -0
- package/components/form/checkbox/RequiredCheckBoxValidator.d.ts +1 -0
- package/components/form/checkbox/RequiredCheckBoxValidator.js +85 -0
- package/components/form/date/DatePicker.d.ts +1 -0
- package/components/form/date/DatePicker.js +105 -0
- package/components/form/date/GenericDatePicker.d.ts +1 -0
- package/components/form/date/GenericDatePicker.js +105 -0
- package/components/form/date/TimePicker.d.ts +1 -0
- package/components/form/date/TimePicker.js +82 -0
- package/components/form/file/DropFileUpload.d.ts +1 -0
- package/components/form/file/DropFileUpload.js +226 -0
- package/components/form/file/FileUpload.d.ts +1 -0
- package/components/form/file/FileUpload.js +200 -0
- package/components/form/input/ActiveInput.js +33 -0
- package/components/form/input/AutoComplete.d.ts +1 -0
- package/components/form/input/AutoComplete.js +69 -0
- package/components/form/input/FetchAutoComplete.d.ts +1 -0
- package/components/form/input/FetchAutoComplete.js +134 -0
- package/components/form/input/FixedAutoComplete.d.ts +1 -0
- package/components/form/input/FixedAutoComplete.js +83 -0
- package/components/form/input/GenericFetchAutoComplete.d.ts +1 -0
- package/components/form/input/GenericFetchAutoComplete.js +132 -0
- package/components/form/input/GenericInput.js +168 -0
- package/components/form/input/GenericMaskInput.js +79 -0
- package/components/form/input/GenericMultInput.d.ts +1 -0
- package/components/form/input/GenericMultInput.js +67 -0
- package/components/form/input/Input.js +168 -0
- package/components/form/input/MaskInput.js +78 -0
- package/components/form/input/MultInput.d.ts +1 -0
- package/components/form/input/MultInput.js +67 -0
- package/components/form/input/OtherCheckBox.d.ts +1 -0
- package/components/form/input/OtherCheckBox.js +56 -0
- package/components/form/stepper/Stepper.js +135 -0
- package/components/form/stepper/StepperBlock.js +97 -0
- package/components/form/switch/Switch.js +54 -0
- package/components/form/switch/ToggleVisibility.d.ts +1 -0
- package/components/form/switch/ToggleVisibility.js +61 -0
- package/components/form/table/FilterSection.d.ts +1 -0
- package/components/form/table/FilterSection.js +217 -0
- package/components/form/table/GenericTable.js +1034 -0
- package/components/form/table/Table.js +514 -0
- package/components/form/table/TableErrorState.js +27 -0
- package/components/form/table/TableLoadingState.d.ts +1 -0
- package/components/form/table/TableLoadingState.js +39 -0
- package/components/form/table/types.js +2 -0
- package/components/form/table/utils.d.ts +1 -0
- package/components/form/table/utils.js +361 -0
- package/components/icons/icons.d.ts +1 -0
- package/components/icons/icons.js +24 -0
- package/components/map/AnimatedMarker.js +65 -0
- package/components/map/DraggableMarker.js +66 -0
- package/components/map/Map.js +23 -0
- package/components/map/index.d.ts +1 -0
- package/components/map/index.js +31 -0
- package/components/modal/Modal.d.ts +1 -0
- package/components/modal/Modal.js +105 -0
- package/components/navbar/NavBar.d.ts +1 -0
- package/components/navbar/NavBar.js +171 -0
- package/components/navbar/TabNavBar.d.ts +1 -0
- package/components/navbar/TabNavBar.js +179 -0
- package/components/providers/FormProvider.js +54 -0
- package/components/providers/KeycloakAuthProvider.d.ts +1 -0
- package/components/providers/KeycloakAuthProvider.js +118 -0
- package/components/providers/OAuthProvider.d.ts +1 -0
- package/components/providers/OAuthProvider.js +138 -0
- package/components/providers/SspComponentsProvider.d.ts +1 -0
- package/components/providers/SspComponentsProvider.js +18 -0
- package/components/utils/Bt.d.ts +1 -0
- package/components/utils/Bt.js +35 -0
- package/components/utils/CustomMenu.js +39 -0
- package/context/auth.d.ts +1 -0
- package/context/auth.js +5 -0
- package/context/form.js +5 -0
- package/index.d.ts +18 -18
- package/index.js +94 -0
- package/package.json +1 -1
- package/types/auth.js +2 -0
- package/types/form.js +31 -0
- package/Map-31d95a26.js +0 -2
- package/Map-31d95a26.js.map +0 -1
- package/Map-644d2f90.js +0 -2
- package/Map-644d2f90.js.map +0 -1
- package/components/form/input/OptionalInput.d.ts +0 -10
- package/components/loading/LinearProgress.d.ts +0 -2
- package/components/loading/LoadingScreen.d.ts +0 -7
- package/components/providers/GenericFormProvider.d.ts +0 -10
- package/components/teste/Teste.d.ts +0 -3
- package/decorators/FormBaseDecorator.d.ts +0 -2
- package/decorators/GenericFormBaseDecorator.d.ts +0 -2
- package/decorators/StepperDecorator.d.ts +0 -2
- package/index.cjs +0 -3
- package/index.cjs.map +0 -1
- package/index.esm.js +0 -3
- package/index.esm.js.map +0 -1
- package/stories/Autocomplete.stories.d.ts +0 -6
- package/stories/CheckBox.stories.d.ts +0 -6
- package/stories/CheckBoxWarning.stories.d.ts +0 -6
- package/stories/DatePicker.stories.d.ts +0 -6
- package/stories/DetalhesCategory.stories.d.ts +0 -6
- package/stories/DetalhesField.stories.d.ts +0 -6
- package/stories/DetalhesFieldLabel.stories.d.ts +0 -6
- package/stories/DetalhesFile.stories.d.ts +0 -6
- package/stories/DropFileUpload.stories.d.ts +0 -6
- package/stories/ExemploAssitirValorInput.stories.d.ts +0 -7
- package/stories/ExemploInputs.stories.d.ts +0 -7
- package/stories/ExemploTable.stories.d.ts +0 -1
- package/stories/ExemploValoresCompartilhados.stories.d.ts +0 -7
- package/stories/FetchAutocomplete.stories.d.ts +0 -6
- package/stories/FileUpload.stories.d.ts +0 -6
- package/stories/FixedAutocomplete.stories.d.ts +0 -6
- package/stories/GenericFetchAutocomplete.stories.d.ts +0 -6
- package/stories/GenericInput.stories.d.ts +0 -6
- package/stories/GenericTable.stories.d.ts +0 -6
- package/stories/Input.stories.d.ts +0 -6
- package/stories/LinearProgress.stories.d.ts +0 -6
- package/stories/LoadingScreen.stories.d.ts +0 -6
- package/stories/Map.stories.d.ts +0 -6
- package/stories/MultInput.stories.d.ts +0 -6
- package/stories/NavBar.stories.d.ts +0 -6
- package/stories/OptionalInput.stories.d.ts +0 -6
- package/stories/OtherCheckBox.stories.d.ts +0 -6
- package/stories/Stepper.stories.d.ts +0 -6
- package/stories/StepperBlock.stories.d.ts +0 -6
- package/stories/Switch.stories.d.ts +0 -6
- package/stories/Table.stories.d.ts +0 -4
- package/stories/TableWithStaticData.stories.d.ts +0 -6
- package/stories/Teste.stories.d.ts +0 -6
- package/stories/TimePicker.stories.d.ts +0 -6
|
@@ -0,0 +1,79 @@
|
|
|
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;
|
|
@@ -0,0 +1,67 @@
|
|
|
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;
|
|
@@ -0,0 +1,168 @@
|
|
|
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 form_1 = require("../../../context/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 context = (0, react_1.useContext)(form_1.FormContext);
|
|
49
|
+
(0, react_1.useEffect)(() => {
|
|
50
|
+
if (watchValue !== undefined)
|
|
51
|
+
context.formSetValue(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)(context === null || context === void 0 ? void 0 : context.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({}, context === null || context === void 0 ? void 0 : context.formRegister(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);
|
|
@@ -0,0 +1,78 @@
|
|
|
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 TextMaskCustom = react_1.default.forwardRef(function TextMaskCustom(props, ref) {
|
|
42
|
+
const { onChange, maskProps, onMask, maskValue, setMaskValue, watchValue } = props, prop = __rest(props, ["onChange", "maskProps", "onMask", "maskValue", "setMaskValue", "watchValue"]);
|
|
43
|
+
const [mask, setMask] = (0, react_1.useState)(maskProps.mask);
|
|
44
|
+
delete prop.value;
|
|
45
|
+
const myRef = (0, react_1.useRef)(null);
|
|
46
|
+
const [myValue, setMyValue] = (0, react_1.useState)('');
|
|
47
|
+
const context = (0, react_1.useContext)(form_1.FormContext);
|
|
48
|
+
(0, react_1.useEffect)(() => {
|
|
49
|
+
if (watchValue) {
|
|
50
|
+
setMyValue(watchValue);
|
|
51
|
+
}
|
|
52
|
+
}, [watchValue]);
|
|
53
|
+
(0, react_1.useEffect)(() => {
|
|
54
|
+
context.formSetValue(prop.name, myRef.current.element.value);
|
|
55
|
+
}, [myValue]);
|
|
56
|
+
delete prop.watchValue;
|
|
57
|
+
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) => {
|
|
58
|
+
setMyValue(value);
|
|
59
|
+
mask.updateValue();
|
|
60
|
+
if (!onMask)
|
|
61
|
+
return;
|
|
62
|
+
onMask(value, setMask);
|
|
63
|
+
} })));
|
|
64
|
+
});
|
|
65
|
+
function MaskInput(props) {
|
|
66
|
+
const context = (0, react_1.useContext)(form_1.FormContext);
|
|
67
|
+
const [maskValue, setMaskValue] = (0, react_1.useState)('');
|
|
68
|
+
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
69
|
+
react_1.default.createElement(material_1.TextField, Object.assign({}, props.formConfig, { onInput: (e) => {
|
|
70
|
+
const name = props.formConfig.name;
|
|
71
|
+
const value = e.target.value;
|
|
72
|
+
context.formSetValue(name, value);
|
|
73
|
+
}, InputProps: {
|
|
74
|
+
inputComponent: TextMaskCustom,
|
|
75
|
+
inputProps: { maskProps: props.maskProps, onMask: props.onMask, maskValue, setMaskValue, watchValue: props.watchValue },
|
|
76
|
+
}, disabled: props.disabled, fullWidth: true }))));
|
|
77
|
+
}
|
|
78
|
+
exports.default = MaskInput;
|
|
@@ -0,0 +1,67 @@
|
|
|
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 form_1 = require("../../../context/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_1.useContext)(form_1.FormContext);
|
|
49
|
+
(0, react_1.useEffect)(() => {
|
|
50
|
+
context.formSetValue(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.formRegister(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.errors, name) ? true : false, helperText: (_b = (0, lodash_get_1.default)(context.errors, name)) === null || _b === void 0 ? void 0 : _b.message, sx: {
|
|
64
|
+
bgcolor: 'white',
|
|
65
|
+
}, placeholder: customPlaceholder ? customPlaceholder : title }))));
|
|
66
|
+
}
|
|
67
|
+
exports.default = MultInput;
|
|
@@ -0,0 +1,56 @@
|
|
|
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 form_1 = require("../../../context/form");
|
|
33
|
+
function SSPOtherCheckBox({ name, required = false, xs = 12, sm, md }) {
|
|
34
|
+
var _a;
|
|
35
|
+
const context = (0, react_1.useContext)(form_1.FormContext);
|
|
36
|
+
const checkName = `switch-${name}`;
|
|
37
|
+
(0, react_1.useEffect)(() => {
|
|
38
|
+
const checkValue = context.formWatch(checkName);
|
|
39
|
+
if (!checkValue)
|
|
40
|
+
context.formSetValue(name, undefined);
|
|
41
|
+
}, [context]);
|
|
42
|
+
return (react_1.default.createElement(material_1.Grid, Object.assign({ item: true }, { xs, sm, md }),
|
|
43
|
+
react_1.default.createElement(material_1.Stack, { direction: 'row' },
|
|
44
|
+
react_1.default.createElement(material_1.Box, null,
|
|
45
|
+
react_1.default.createElement(material_1.Checkbox, Object.assign({ size: 'small' }, context.formRegister(checkName), { sx: { paddingLeft: 0, margin: 0 } }))),
|
|
46
|
+
context.formWatch(checkName) ? (react_1.default.createElement(material_1.TextField, Object.assign({ size: 'small' }, context.formRegister(name, {
|
|
47
|
+
validate: (v, f) => {
|
|
48
|
+
const value = context.formWatch(checkName);
|
|
49
|
+
if (value === true) {
|
|
50
|
+
if (!v || (v.length <= 0 && required))
|
|
51
|
+
return 'Este campo não pode ser vazio';
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
}), { required: true, error: (0, lodash_get_1.default)(context.errors, name) ? true : false, helperText: (_a = (0, lodash_get_1.default)(context.errors, name)) === null || _a === void 0 ? void 0 : _a.message, placeholder: 'Outro' }))) : (react_1.default.createElement(material_1.TextField, { size: 'small', disabled: true, placeholder: 'Outro' })))));
|
|
55
|
+
}
|
|
56
|
+
exports.default = SSPOtherCheckBox;
|