@gustavo-valsechi/client 1.4.46 → 1.4.48

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.
@@ -48,13 +48,13 @@ const TargetProviderContainer = ({ children }) => {
48
48
  if (!element) return;
49
49
  element.addEventListener("click", () => {
50
50
  const newTargets = [...targets];
51
- const coords = getCoords(element);
52
- newTargets.splice(index, 1, { ...target, show: !target.show, coords });
51
+ newTargets.splice(index, 1, { ...target, show: !target.show });
53
52
  setTargets(newTargets);
54
53
  });
55
54
  });
56
- }, [targets]);
55
+ }, []);
57
56
  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, coords: { top: 0, left: 0 } });
74
+ memory.push({ ...target, show: false });
75
75
  setTargets(memory);
76
76
  };
77
77
  const remove = (ref) => {
@@ -89,14 +89,21 @@ const TargetProviderContainer = ({ children }) => {
89
89
  children: [
90
90
  import_lodash.default.map(
91
91
  targets,
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, {})
92
+ (target, index) => {
93
+ var _a;
94
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
95
+ import_styles.Container,
96
+ {
97
+ style: {
98
+ ...getCoords((_a = target.ref) == null ? void 0 : _a.current),
99
+ zIndex: target.show ? "10" : "-1",
100
+ opacity: target.show ? "1" : "0"
101
+ },
102
+ children: target.component
103
+ },
104
+ index
105
+ );
106
+ }
100
107
  ),
101
108
  children
102
109
  ]
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
+ import { 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
- const coords = getCoords(element);
18
- newTargets.splice(index, 1, { ...target, show: !target.show, coords });
17
+ newTargets.splice(index, 1, { ...target, show: !target.show });
19
18
  setTargets(newTargets);
20
19
  });
21
20
  });
22
- }, [targets]);
21
+ }, []);
23
22
  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, coords: { top: 0, left: 0 } });
40
+ memory.push({ ...target, show: false });
41
41
  setTargets(memory);
42
42
  };
43
43
  const remove = (ref) => {
@@ -55,14 +55,21 @@ const TargetProviderContainer = ({ children }) => {
55
55
  children: [
56
56
  _.map(
57
57
  targets,
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, {})
58
+ (target, index) => {
59
+ var _a;
60
+ return /* @__PURE__ */ jsx(
61
+ Container,
62
+ {
63
+ style: {
64
+ ...getCoords((_a = target.ref) == null ? void 0 : _a.current),
65
+ zIndex: target.show ? "10" : "-1",
66
+ opacity: target.show ? "1" : "0"
67
+ },
68
+ children: target.component
69
+ },
70
+ index
71
+ );
72
+ }
66
73
  ),
67
74
  children
68
75
  ]
@@ -34,7 +34,6 @@ module.exports = __toCommonJS(styles_exports);
34
34
  var import_styled_components = __toESM(require("styled-components"));
35
35
  const Container = import_styled_components.default.div`
36
36
  position: absolute;
37
- z-index: 10;
38
37
 
39
38
  @media(max-width: ${({ theme }) => theme.mobileMaxWidth}) {
40
39
  width: 100%;
@@ -1,7 +1,6 @@
1
1
  import styled from "styled-components";
2
2
  const Container = styled.div`
3
3
  position: absolute;
4
- z-index: 10;
5
4
 
6
5
  @media(max-width: ${({ theme }) => theme.mobileMaxWidth}) {
7
6
  width: 100%;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gustavo-valsechi/client",
3
- "version": "1.4.46",
3
+ "version": "1.4.48",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",