@ssplib/react-components 0.0.67 → 0.0.69
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,10 +1,12 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
export declare function ToggleVisibility(props: {
|
|
2
|
+
export declare function ToggleVisibility({ invert, ...props }: {
|
|
3
3
|
switchId: string;
|
|
4
4
|
unregisterNameList: string[];
|
|
5
|
+
invert?: boolean;
|
|
5
6
|
}): JSX.Element;
|
|
6
|
-
export declare function SwitchWatch(props: {
|
|
7
|
+
export declare function SwitchWatch({ invert, ...props }: {
|
|
7
8
|
children: JSX.Element | JSX.Element[];
|
|
8
9
|
switchId: string;
|
|
9
10
|
unregisterNameList: string[];
|
|
11
|
+
invert?: boolean;
|
|
10
12
|
}): JSX.Element;
|
|
@@ -22,16 +22,28 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
22
22
|
__setModuleDefault(result, mod);
|
|
23
23
|
return result;
|
|
24
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
|
+
};
|
|
25
36
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
37
|
exports.SwitchWatch = exports.ToggleVisibility = void 0;
|
|
27
38
|
const react_1 = __importStar(require("react"));
|
|
28
39
|
const form_1 = require("../../../context/form");
|
|
29
40
|
// Coloque esse componente dentro de um bloco que é retirado com o valor do input
|
|
30
|
-
function ToggleVisibility(
|
|
41
|
+
function ToggleVisibility(_a) {
|
|
42
|
+
var { invert = false } = _a, props = __rest(_a, ["invert"]);
|
|
31
43
|
const context = (0, react_1.useContext)(form_1.FormContext);
|
|
32
44
|
(0, react_1.useEffect)(() => {
|
|
33
45
|
return () => {
|
|
34
|
-
if (context.formWatch(props.switchId)) {
|
|
46
|
+
if (context.formWatch(props.switchId) === invert) {
|
|
35
47
|
props.unregisterNameList.forEach((x) => context.formUnregister(x));
|
|
36
48
|
}
|
|
37
49
|
};
|
|
@@ -39,10 +51,11 @@ function ToggleVisibility(props) {
|
|
|
39
51
|
return react_1.default.createElement(react_1.default.Fragment, null);
|
|
40
52
|
}
|
|
41
53
|
exports.ToggleVisibility = ToggleVisibility;
|
|
42
|
-
function SwitchWatch(
|
|
54
|
+
function SwitchWatch(_a) {
|
|
55
|
+
var { invert = false } = _a, props = __rest(_a, ["invert"]);
|
|
43
56
|
const context = (0, react_1.useContext)(form_1.FormContext);
|
|
44
|
-
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
45
|
-
react_1.default.createElement(ToggleVisibility, { switchId: props.switchId, unregisterNameList: props.unregisterNameList }),
|
|
57
|
+
return (react_1.default.createElement(react_1.default.Fragment, null, (context === null || context === void 0 ? void 0 : context.formWatch(props.switchId)) !== invert && (react_1.default.createElement(react_1.default.Fragment, null,
|
|
58
|
+
react_1.default.createElement(ToggleVisibility, { switchId: props.switchId, unregisterNameList: props.unregisterNameList, invert: invert }),
|
|
46
59
|
props.children))));
|
|
47
60
|
}
|
|
48
61
|
exports.SwitchWatch = SwitchWatch;
|