@ssplib/react-components 0.0.160 → 0.0.162
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.
|
@@ -42,8 +42,10 @@ const form_1 = require("../../../context/form");
|
|
|
42
42
|
const material_1 = require("@mui/material");
|
|
43
43
|
const lodash_get_1 = __importDefault(require("lodash.get"));
|
|
44
44
|
function getChildrenNames(children) {
|
|
45
|
+
console.log('ENTROU NO getChildrenNames');
|
|
45
46
|
let arr = [];
|
|
46
47
|
children.forEach((x) => {
|
|
48
|
+
console.log('ENTROU NO forEach DO getChildrenNames - VALOR DE x: ', x);
|
|
47
49
|
if (!x.props)
|
|
48
50
|
return;
|
|
49
51
|
if (x.props.children) {
|
|
@@ -63,14 +65,24 @@ function RequiredCheckBoxGroup(_a) {
|
|
|
63
65
|
var { customText = 'Selecione pelo menos 1 opção' } = _a, props = __rest(_a, ["customText"]);
|
|
64
66
|
const context = (0, react_1.useContext)(form_1.FormContext);
|
|
65
67
|
return (react_1.default.createElement(material_1.Grid, { container: true, sx: { border: (0, lodash_get_1.default)(context.errors, props.name) ? '2px solid #a51c30' : '', padding: 1, borderRadius: 2 } },
|
|
66
|
-
react_1.default.createElement("input", Object.assign({ type: 'text' }, context.formRegister(props.name, {
|
|
67
|
-
validate: (v,
|
|
68
|
+
react_1.default.createElement("input", Object.assign({ key: 1, type: 'text' }, context.formRegister(props.name, {
|
|
69
|
+
validate: (v, i) => {
|
|
68
70
|
const names = getChildrenNames(Array.isArray(props.children) ? props.children : [props.children]);
|
|
69
71
|
let canContinue = false;
|
|
70
|
-
names.forEach((x) => {
|
|
72
|
+
names.forEach((x, i) => {
|
|
71
73
|
const nameValue = context.formGetValues(x);
|
|
72
|
-
if (nameValue)
|
|
74
|
+
if (nameValue) {
|
|
73
75
|
canContinue = true;
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
console.log("Erro validação");
|
|
79
|
+
console.log("names", names);
|
|
80
|
+
console.log("x", x);
|
|
81
|
+
console.log('i', i);
|
|
82
|
+
console.log("nameValue", nameValue);
|
|
83
|
+
console.log('Erro validação');
|
|
84
|
+
}
|
|
85
|
+
console.log(`ENTROU NO forEach DO return - VALOR DE names: ${names} - VALOR ATUAL: ${x} - INDEX: ${i}`);
|
|
74
86
|
});
|
|
75
87
|
if (!canContinue)
|
|
76
88
|
return customText;
|