@gustavo-valsechi/client 1.4.63 → 1.4.65
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 +19 -13
- package/dist/contexts/target/index.mjs +20 -14
- package/package.json +1 -1
|
@@ -53,15 +53,16 @@ const TargetProviderContainer = ({ children }) => {
|
|
|
53
53
|
if (isShow) {
|
|
54
54
|
const showIndex = import_lodash.default.findIndex(showMemory, (data) => data.index === index);
|
|
55
55
|
showMemory.splice(showIndex, 1);
|
|
56
|
+
console.log("showMemory", showMemory);
|
|
56
57
|
setShow(showMemory);
|
|
57
58
|
return;
|
|
58
59
|
}
|
|
59
60
|
showMemory.push({ index, coords: getCoords(element) });
|
|
61
|
+
console.log("showMemory", showMemory);
|
|
60
62
|
setShow(showMemory);
|
|
61
63
|
});
|
|
62
64
|
});
|
|
63
65
|
}, [targets]);
|
|
64
|
-
console.log(show);
|
|
65
66
|
const getCoords = (target) => {
|
|
66
67
|
const rect = target.getBoundingClientRect();
|
|
67
68
|
const targetTop = rect.top + window.scrollY;
|
|
@@ -87,6 +88,22 @@ const TargetProviderContainer = ({ children }) => {
|
|
|
87
88
|
memory.slice(index, 1);
|
|
88
89
|
setTargets(memory);
|
|
89
90
|
};
|
|
91
|
+
const renderTargets = (0, import_react.useCallback)(() => {
|
|
92
|
+
return import_lodash.default.map(targets, (target, index) => {
|
|
93
|
+
console.log("show", show);
|
|
94
|
+
const targetContent = import_lodash.default.find(show, (data) => data.index === index);
|
|
95
|
+
console.log("targetContent", targetContent);
|
|
96
|
+
if (!targetContent) return;
|
|
97
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
98
|
+
import_styles.Container,
|
|
99
|
+
{
|
|
100
|
+
style: targetContent.coords,
|
|
101
|
+
children: target.component
|
|
102
|
+
},
|
|
103
|
+
index
|
|
104
|
+
);
|
|
105
|
+
});
|
|
106
|
+
}, [targets, show]);
|
|
90
107
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
91
108
|
TargetContext.Provider,
|
|
92
109
|
{
|
|
@@ -95,18 +112,7 @@ const TargetProviderContainer = ({ children }) => {
|
|
|
95
112
|
remove
|
|
96
113
|
},
|
|
97
114
|
children: [
|
|
98
|
-
|
|
99
|
-
const targetContent = import_lodash.default.find(show, (data) => data.index === index);
|
|
100
|
-
if (!targetContent) return;
|
|
101
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
102
|
-
import_styles.Container,
|
|
103
|
-
{
|
|
104
|
-
style: targetContent.coords,
|
|
105
|
-
children: target.component
|
|
106
|
-
},
|
|
107
|
-
index
|
|
108
|
-
);
|
|
109
|
-
}),
|
|
115
|
+
renderTargets(),
|
|
110
116
|
children
|
|
111
117
|
]
|
|
112
118
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { createContext, useContext, useEffect, useState } from "react";
|
|
3
|
+
import { createContext, useContext, useEffect, useState, useCallback } from "react";
|
|
4
4
|
import { Container } from "./styles";
|
|
5
5
|
import _ from "lodash";
|
|
6
6
|
const TargetContext = createContext({});
|
|
@@ -19,15 +19,16 @@ const TargetProviderContainer = ({ children }) => {
|
|
|
19
19
|
if (isShow) {
|
|
20
20
|
const showIndex = _.findIndex(showMemory, (data) => data.index === index);
|
|
21
21
|
showMemory.splice(showIndex, 1);
|
|
22
|
+
console.log("showMemory", showMemory);
|
|
22
23
|
setShow(showMemory);
|
|
23
24
|
return;
|
|
24
25
|
}
|
|
25
26
|
showMemory.push({ index, coords: getCoords(element) });
|
|
27
|
+
console.log("showMemory", showMemory);
|
|
26
28
|
setShow(showMemory);
|
|
27
29
|
});
|
|
28
30
|
});
|
|
29
31
|
}, [targets]);
|
|
30
|
-
console.log(show);
|
|
31
32
|
const getCoords = (target) => {
|
|
32
33
|
const rect = target.getBoundingClientRect();
|
|
33
34
|
const targetTop = rect.top + window.scrollY;
|
|
@@ -53,6 +54,22 @@ const TargetProviderContainer = ({ children }) => {
|
|
|
53
54
|
memory.slice(index, 1);
|
|
54
55
|
setTargets(memory);
|
|
55
56
|
};
|
|
57
|
+
const renderTargets = useCallback(() => {
|
|
58
|
+
return _.map(targets, (target, index) => {
|
|
59
|
+
console.log("show", show);
|
|
60
|
+
const targetContent = _.find(show, (data) => data.index === index);
|
|
61
|
+
console.log("targetContent", targetContent);
|
|
62
|
+
if (!targetContent) return;
|
|
63
|
+
return /* @__PURE__ */ jsx(
|
|
64
|
+
Container,
|
|
65
|
+
{
|
|
66
|
+
style: targetContent.coords,
|
|
67
|
+
children: target.component
|
|
68
|
+
},
|
|
69
|
+
index
|
|
70
|
+
);
|
|
71
|
+
});
|
|
72
|
+
}, [targets, show]);
|
|
56
73
|
return /* @__PURE__ */ jsxs(
|
|
57
74
|
TargetContext.Provider,
|
|
58
75
|
{
|
|
@@ -61,18 +78,7 @@ const TargetProviderContainer = ({ children }) => {
|
|
|
61
78
|
remove
|
|
62
79
|
},
|
|
63
80
|
children: [
|
|
64
|
-
|
|
65
|
-
const targetContent = _.find(show, (data) => data.index === index);
|
|
66
|
-
if (!targetContent) return;
|
|
67
|
-
return /* @__PURE__ */ jsx(
|
|
68
|
-
Container,
|
|
69
|
-
{
|
|
70
|
-
style: targetContent.coords,
|
|
71
|
-
children: target.component
|
|
72
|
-
},
|
|
73
|
-
index
|
|
74
|
-
);
|
|
75
|
-
}),
|
|
81
|
+
renderTargets(),
|
|
76
82
|
children
|
|
77
83
|
]
|
|
78
84
|
}
|