@ssplib/react-components 0.0.161 → 0.0.163
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.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
export default function CheckBox({ name, title, defaultValue, xs, sm, md, onChange, }: {
|
|
2
|
+
export default function CheckBox({ name, title, defaultValue, xs, sm, md, onChange, onClick, }: {
|
|
3
3
|
name: string;
|
|
4
4
|
title: string | JSX.Element;
|
|
5
5
|
defaultValue?: boolean;
|
|
@@ -7,4 +7,5 @@ export default function CheckBox({ name, title, defaultValue, xs, sm, md, onChan
|
|
|
7
7
|
xs?: number;
|
|
8
8
|
sm?: number;
|
|
9
9
|
md?: number;
|
|
10
|
+
onClick?: (e: React.SyntheticEvent<Element, Event>) => void;
|
|
10
11
|
}): JSX.Element;
|
|
@@ -7,9 +7,9 @@ const material_1 = require("@mui/material");
|
|
|
7
7
|
const react_1 = require("react");
|
|
8
8
|
const form_1 = require("../../../context/form");
|
|
9
9
|
const react_2 = __importDefault(require("react"));
|
|
10
|
-
function CheckBox({ name, title, defaultValue = false, xs = 12, sm, md, onChange, }) {
|
|
10
|
+
function CheckBox({ name, title, defaultValue = false, xs = 12, sm, md, onChange, onClick, }) {
|
|
11
11
|
const context = (0, react_1.useContext)(form_1.FormContext);
|
|
12
12
|
return (react_2.default.createElement(material_1.Grid, Object.assign({ item: true }, { xs, sm, md }),
|
|
13
|
-
react_2.default.createElement(material_1.FormControlLabel, Object.assign({ control: react_2.default.createElement(material_1.Checkbox, { size: 'small', defaultChecked: defaultValue }), label: title }, context === null || context === void 0 ? void 0 : context.formRegister(name), { onChange: onChange }))));
|
|
13
|
+
react_2.default.createElement(material_1.FormControlLabel, Object.assign({ control: react_2.default.createElement(material_1.Checkbox, { size: 'small', defaultChecked: defaultValue }), label: title }, context === null || context === void 0 ? void 0 : context.formRegister(name), { onChange: onChange, onClick: onClick }))));
|
|
14
14
|
}
|
|
15
15
|
exports.default = CheckBox;
|
|
@@ -63,7 +63,6 @@ function getChildrenNames(children) {
|
|
|
63
63
|
function RequiredCheckBoxGroup(_a) {
|
|
64
64
|
var _b;
|
|
65
65
|
var { customText = 'Selecione pelo menos 1 opção' } = _a, props = __rest(_a, ["customText"]);
|
|
66
|
-
console.log('ENTROU NO RequiredCheckBoxGroup - VALOR DE props: ', props);
|
|
67
66
|
const context = (0, react_1.useContext)(form_1.FormContext);
|
|
68
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 } },
|
|
69
68
|
react_1.default.createElement("input", Object.assign({ key: 1, type: 'text' }, context.formRegister(props.name, {
|
|
@@ -72,8 +71,16 @@ function RequiredCheckBoxGroup(_a) {
|
|
|
72
71
|
let canContinue = false;
|
|
73
72
|
names.forEach((x, i) => {
|
|
74
73
|
const nameValue = context.formGetValues(x);
|
|
75
|
-
if (nameValue)
|
|
74
|
+
if (nameValue) {
|
|
76
75
|
canContinue = true;
|
|
76
|
+
}
|
|
77
|
+
console.log("todos os value", context.formGetValues());
|
|
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');
|
|
77
84
|
console.log(`ENTROU NO forEach DO return - VALOR DE names: ${names} - VALOR ATUAL: ${x} - INDEX: ${i}`);
|
|
78
85
|
});
|
|
79
86
|
if (!canContinue)
|