@gustavo-valsechi/client 1.4.48 → 1.4.49
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/dist/contexts/target/index.js +11 -18
- package/dist/contexts/target/index.mjs +12 -19
- package/package.json +1 -1
|
@@ -48,13 +48,13 @@ const TargetProviderContainer = ({ children }) => {
|
|
|
48
48
|
if (!element) return;
|
|
49
49
|
element.addEventListener("click", () => {
|
|
50
50
|
const newTargets = [...targets];
|
|
51
|
-
|
|
51
|
+
const coords = getCoords(element);
|
|
52
|
+
newTargets.splice(index, 1, { ...target, show: !target.show, coords });
|
|
52
53
|
setTargets(newTargets);
|
|
53
54
|
});
|
|
54
55
|
});
|
|
55
56
|
}, []);
|
|
56
57
|
const getCoords = (target) => {
|
|
57
|
-
if (!target) return {};
|
|
58
58
|
const rect = target.getBoundingClientRect();
|
|
59
59
|
const targetTop = rect.top + window.scrollY;
|
|
60
60
|
const targetLeft = rect.left + window.scrollX;
|
|
@@ -71,7 +71,7 @@ const TargetProviderContainer = ({ children }) => {
|
|
|
71
71
|
return coords;
|
|
72
72
|
};
|
|
73
73
|
const add = (target) => {
|
|
74
|
-
memory.push({ ...target, show: false });
|
|
74
|
+
memory.push({ ...target, show: false, coords: { top: 0, left: 0 } });
|
|
75
75
|
setTargets(memory);
|
|
76
76
|
};
|
|
77
77
|
const remove = (ref) => {
|
|
@@ -89,21 +89,14 @@ const TargetProviderContainer = ({ children }) => {
|
|
|
89
89
|
children: [
|
|
90
90
|
import_lodash.default.map(
|
|
91
91
|
targets,
|
|
92
|
-
(target, index) =>
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
opacity: target.show ? "1" : "0"
|
|
101
|
-
},
|
|
102
|
-
children: target.component
|
|
103
|
-
},
|
|
104
|
-
index
|
|
105
|
-
);
|
|
106
|
-
}
|
|
92
|
+
(target, index) => target.show ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
93
|
+
import_styles.Container,
|
|
94
|
+
{
|
|
95
|
+
style: target.coords,
|
|
96
|
+
children: target.component
|
|
97
|
+
},
|
|
98
|
+
index
|
|
99
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {})
|
|
107
100
|
),
|
|
108
101
|
children
|
|
109
102
|
]
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { createContext, useContext, useEffect, useState } from "react";
|
|
4
4
|
import { Container } from "./styles";
|
|
5
5
|
import _ from "lodash";
|
|
@@ -14,13 +14,13 @@ const TargetProviderContainer = ({ children }) => {
|
|
|
14
14
|
if (!element) return;
|
|
15
15
|
element.addEventListener("click", () => {
|
|
16
16
|
const newTargets = [...targets];
|
|
17
|
-
|
|
17
|
+
const coords = getCoords(element);
|
|
18
|
+
newTargets.splice(index, 1, { ...target, show: !target.show, coords });
|
|
18
19
|
setTargets(newTargets);
|
|
19
20
|
});
|
|
20
21
|
});
|
|
21
22
|
}, []);
|
|
22
23
|
const getCoords = (target) => {
|
|
23
|
-
if (!target) return {};
|
|
24
24
|
const rect = target.getBoundingClientRect();
|
|
25
25
|
const targetTop = rect.top + window.scrollY;
|
|
26
26
|
const targetLeft = rect.left + window.scrollX;
|
|
@@ -37,7 +37,7 @@ const TargetProviderContainer = ({ children }) => {
|
|
|
37
37
|
return coords;
|
|
38
38
|
};
|
|
39
39
|
const add = (target) => {
|
|
40
|
-
memory.push({ ...target, show: false });
|
|
40
|
+
memory.push({ ...target, show: false, coords: { top: 0, left: 0 } });
|
|
41
41
|
setTargets(memory);
|
|
42
42
|
};
|
|
43
43
|
const remove = (ref) => {
|
|
@@ -55,21 +55,14 @@ const TargetProviderContainer = ({ children }) => {
|
|
|
55
55
|
children: [
|
|
56
56
|
_.map(
|
|
57
57
|
targets,
|
|
58
|
-
(target, index) =>
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
opacity: target.show ? "1" : "0"
|
|
67
|
-
},
|
|
68
|
-
children: target.component
|
|
69
|
-
},
|
|
70
|
-
index
|
|
71
|
-
);
|
|
72
|
-
}
|
|
58
|
+
(target, index) => target.show ? /* @__PURE__ */ jsx(
|
|
59
|
+
Container,
|
|
60
|
+
{
|
|
61
|
+
style: target.coords,
|
|
62
|
+
children: target.component
|
|
63
|
+
},
|
|
64
|
+
index
|
|
65
|
+
) : /* @__PURE__ */ jsx(Fragment, {})
|
|
73
66
|
),
|
|
74
67
|
children
|
|
75
68
|
]
|