@gustavo-valsechi/client 1.4.72 → 1.4.74

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.
@@ -39,7 +39,6 @@ var import_styles = require("./styles");
39
39
  var import_lodash = __toESM(require("lodash"));
40
40
  const TargetContext = (0, import_react.createContext)({});
41
41
  const memory = [];
42
- const showMemory = [];
43
42
  const TargetProviderContainer = ({ children }) => {
44
43
  const containerRef = (0, import_react.useRef)([]);
45
44
  const [targets, setTargets] = (0, import_react.useState)([]);
@@ -50,24 +49,22 @@ const TargetProviderContainer = ({ children }) => {
50
49
  const element = (_a = target.ref) == null ? void 0 : _a.current;
51
50
  if (!element) return;
52
51
  element.addEventListener("click", () => {
53
- const isShow = import_lodash.default.find(showMemory, (data) => data.index === index);
52
+ const isShow = import_lodash.default.find(show, (data) => data.index === index);
54
53
  if (isShow) {
55
- const showIndex = import_lodash.default.findIndex(showMemory, (data) => data.index === index);
56
- showMemory.splice(showIndex, 1);
57
- console.log("showMemory", showMemory);
58
- setShow(showMemory);
54
+ const showIndex = import_lodash.default.findIndex(show, (data) => data.index === index);
55
+ show.splice(showIndex, 1);
56
+ setShow(show);
59
57
  return;
60
58
  }
61
- showMemory.push({ index, coords: getCoords(element) });
62
- console.log("showMemory", showMemory);
63
- setShow(showMemory);
59
+ show.push({ index, coords: getCoords(element) });
60
+ setShow(show);
64
61
  });
65
62
  });
66
- }, [targets]);
63
+ }, [targets, show]);
67
64
  (0, import_react.useEffect)(() => {
68
65
  if (!containerRef.current) return;
69
66
  import_lodash.default.forEach(containerRef.current, (element, index) => {
70
- const config = import_lodash.default.find(showMemory, (data) => data.index === index);
67
+ const config = import_lodash.default.find(show, (data) => data.index === index);
71
68
  if (!config) {
72
69
  element.style.opacity = "0";
73
70
  element.style.zIndex = "-1";
@@ -78,7 +75,7 @@ const TargetProviderContainer = ({ children }) => {
78
75
  element.style.opacity = "1";
79
76
  element.style.zIndex = "10";
80
77
  });
81
- }, [showMemory, containerRef]);
78
+ }, [show, containerRef]);
82
79
  const getCoords = (target) => {
83
80
  const rect = target.getBoundingClientRect();
84
81
  const targetTop = rect.top + window.scrollY;
@@ -5,7 +5,6 @@ import { Container } from "./styles";
5
5
  import _ from "lodash";
6
6
  const TargetContext = createContext({});
7
7
  const memory = [];
8
- const showMemory = [];
9
8
  const TargetProviderContainer = ({ children }) => {
10
9
  const containerRef = useRef([]);
11
10
  const [targets, setTargets] = useState([]);
@@ -16,24 +15,22 @@ const TargetProviderContainer = ({ children }) => {
16
15
  const element = (_a = target.ref) == null ? void 0 : _a.current;
17
16
  if (!element) return;
18
17
  element.addEventListener("click", () => {
19
- const isShow = _.find(showMemory, (data) => data.index === index);
18
+ const isShow = _.find(show, (data) => data.index === index);
20
19
  if (isShow) {
21
- const showIndex = _.findIndex(showMemory, (data) => data.index === index);
22
- showMemory.splice(showIndex, 1);
23
- console.log("showMemory", showMemory);
24
- setShow(showMemory);
20
+ const showIndex = _.findIndex(show, (data) => data.index === index);
21
+ show.splice(showIndex, 1);
22
+ setShow(show);
25
23
  return;
26
24
  }
27
- showMemory.push({ index, coords: getCoords(element) });
28
- console.log("showMemory", showMemory);
29
- setShow(showMemory);
25
+ show.push({ index, coords: getCoords(element) });
26
+ setShow(show);
30
27
  });
31
28
  });
32
- }, [targets]);
29
+ }, [targets, show]);
33
30
  useEffect(() => {
34
31
  if (!containerRef.current) return;
35
32
  _.forEach(containerRef.current, (element, index) => {
36
- const config = _.find(showMemory, (data) => data.index === index);
33
+ const config = _.find(show, (data) => data.index === index);
37
34
  if (!config) {
38
35
  element.style.opacity = "0";
39
36
  element.style.zIndex = "-1";
@@ -44,7 +41,7 @@ const TargetProviderContainer = ({ children }) => {
44
41
  element.style.opacity = "1";
45
42
  element.style.zIndex = "10";
46
43
  });
47
- }, [showMemory, containerRef]);
44
+ }, [show, containerRef]);
48
45
  const getCoords = (target) => {
49
46
  const rect = target.getBoundingClientRect();
50
47
  const targetTop = rect.top + window.scrollY;
@@ -6,6 +6,13 @@ export interface ITargetConfig {
6
6
  ref: React.RefObject<any>;
7
7
  component: React.ReactNode;
8
8
  }
9
+ export interface ITargetShow {
10
+ index: number;
11
+ coords: {
12
+ top: number;
13
+ left: number;
14
+ };
15
+ }
9
16
  export interface ITargetConfigCoords {
10
17
  top: number;
11
18
  left: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gustavo-valsechi/client",
3
- "version": "1.4.72",
3
+ "version": "1.4.74",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",