@gustavo-valsechi/client 1.4.306 → 1.4.308

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.
@@ -56,7 +56,9 @@ const ModalProviderContainer = ({ children }) => {
56
56
  };
57
57
  const remove = (modalName) => {
58
58
  const removeModal = (name) => {
59
+ console.log("name", name);
59
60
  const index = import_lodash.default.findIndex(memory, (data) => data.name === name);
61
+ console.log("index", index);
60
62
  memory.slice(index, 1);
61
63
  setModals(memory);
62
64
  };
@@ -22,7 +22,9 @@ const ModalProviderContainer = ({ children }) => {
22
22
  };
23
23
  const remove = (modalName) => {
24
24
  const removeModal = (name) => {
25
+ console.log("name", name);
25
26
  const index = _.findIndex(memory, (data) => data.name === name);
27
+ console.log("index", index);
26
28
  memory.slice(index, 1);
27
29
  setModals(memory);
28
30
  };
@@ -72,21 +72,18 @@ const TargetProviderContainer = ({ children }) => {
72
72
  });
73
73
  }, [targets, inputRef, containerRef, theme.content.isMobile]);
74
74
  (0, import_react.useEffect)(() => {
75
- const removeTarget = (node) => {
76
- console.log("ANALISANDO TARGET");
77
- console.log("TARGETS", memory);
78
- console.log("NODE", node);
79
- if (!(node instanceof HTMLElement)) return;
80
- const targetRef = import_lodash.default.find(memory, (target) => {
81
- return target.ref.current === node || node.contains(target.ref.current);
82
- });
83
- if (!targetRef) return;
84
- console.log(targetRef);
85
- };
86
75
  const observer = new MutationObserver((mutations) => {
87
76
  for (const mutation of mutations) {
88
- mutation.addedNodes.forEach(removeTarget);
89
- mutation.removedNodes.forEach(removeTarget);
77
+ mutation.removedNodes.forEach((node) => {
78
+ if (!(node instanceof HTMLElement)) return;
79
+ const index = import_lodash.default.findIndex(memory, (target) => {
80
+ return target.ref.current === node || node.contains(target.ref.current);
81
+ });
82
+ if (index === -1) return;
83
+ removeInside(index);
84
+ memory.splice(index, 1);
85
+ setTargets([...memory]);
86
+ });
90
87
  }
91
88
  });
92
89
  observer.observe(document.body, { childList: true, subtree: true });
@@ -149,12 +146,6 @@ const TargetProviderContainer = ({ children }) => {
149
146
  memory.push(target);
150
147
  setTargets([...memory]);
151
148
  };
152
- const remove = (ref) => {
153
- const index = import_lodash.default.findIndex(memory, (data) => data.ref.current === ref.current);
154
- if (!theme.content.isMobile) removeInside(index);
155
- memory.splice(index, 1);
156
- setTargets([...memory]);
157
- };
158
149
  const closeTarget = (ref) => {
159
150
  if (theme.content.isMobile) return setModal(-1);
160
151
  const index = import_lodash.default.findIndex(memory, (data) => data.ref.current === ref.current);
@@ -184,8 +175,9 @@ const TargetProviderContainer = ({ children }) => {
184
175
  }
185
176
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
186
177
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
187
- import_styles.Container,
178
+ "div",
188
179
  {
180
+ className: "target-container",
189
181
  ref: (element) => containerRef.current[index] = element,
190
182
  onMouseLeave: () => {
191
183
  removeInside(index);
@@ -211,15 +203,14 @@ const TargetProviderContainer = ({ children }) => {
211
203
  {
212
204
  value: {
213
205
  save,
214
- remove,
215
206
  close: closeTarget,
216
207
  isActive
217
208
  },
218
209
  children: [
219
- import_lodash.default.map(
210
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_styles.Container, { id: "target-context-container", children: import_lodash.default.map(
220
211
  targets,
221
212
  (target, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react.default.Fragment, { children: renderContent(target, index) }, index)
222
- ),
213
+ ) }),
223
214
  children
224
215
  ]
225
216
  }
@@ -38,21 +38,18 @@ const TargetProviderContainer = ({ children }) => {
38
38
  });
39
39
  }, [targets, inputRef, containerRef, theme.content.isMobile]);
40
40
  useEffect(() => {
41
- const removeTarget = (node) => {
42
- console.log("ANALISANDO TARGET");
43
- console.log("TARGETS", memory);
44
- console.log("NODE", node);
45
- if (!(node instanceof HTMLElement)) return;
46
- const targetRef = _.find(memory, (target) => {
47
- return target.ref.current === node || node.contains(target.ref.current);
48
- });
49
- if (!targetRef) return;
50
- console.log(targetRef);
51
- };
52
41
  const observer = new MutationObserver((mutations) => {
53
42
  for (const mutation of mutations) {
54
- mutation.addedNodes.forEach(removeTarget);
55
- mutation.removedNodes.forEach(removeTarget);
43
+ mutation.removedNodes.forEach((node) => {
44
+ if (!(node instanceof HTMLElement)) return;
45
+ const index = _.findIndex(memory, (target) => {
46
+ return target.ref.current === node || node.contains(target.ref.current);
47
+ });
48
+ if (index === -1) return;
49
+ removeInside(index);
50
+ memory.splice(index, 1);
51
+ setTargets([...memory]);
52
+ });
56
53
  }
57
54
  });
58
55
  observer.observe(document.body, { childList: true, subtree: true });
@@ -115,12 +112,6 @@ const TargetProviderContainer = ({ children }) => {
115
112
  memory.push(target);
116
113
  setTargets([...memory]);
117
114
  };
118
- const remove = (ref) => {
119
- const index = _.findIndex(memory, (data) => data.ref.current === ref.current);
120
- if (!theme.content.isMobile) removeInside(index);
121
- memory.splice(index, 1);
122
- setTargets([...memory]);
123
- };
124
115
  const closeTarget = (ref) => {
125
116
  if (theme.content.isMobile) return setModal(-1);
126
117
  const index = _.findIndex(memory, (data) => data.ref.current === ref.current);
@@ -150,8 +141,9 @@ const TargetProviderContainer = ({ children }) => {
150
141
  }
151
142
  return /* @__PURE__ */ jsxs(Fragment, { children: [
152
143
  /* @__PURE__ */ jsx(
153
- Container,
144
+ "div",
154
145
  {
146
+ className: "target-container",
155
147
  ref: (element) => containerRef.current[index] = element,
156
148
  onMouseLeave: () => {
157
149
  removeInside(index);
@@ -177,15 +169,14 @@ const TargetProviderContainer = ({ children }) => {
177
169
  {
178
170
  value: {
179
171
  save,
180
- remove,
181
172
  close: closeTarget,
182
173
  isActive
183
174
  },
184
175
  children: [
185
- _.map(
176
+ /* @__PURE__ */ jsx(Container, { id: "target-context-container", children: _.map(
186
177
  targets,
187
178
  (target, index) => /* @__PURE__ */ jsx(React.Fragment, { children: renderContent(target, index) }, index)
188
- ),
179
+ ) }),
189
180
  children
190
181
  ]
191
182
  }
@@ -35,13 +35,15 @@ __export(styles_exports, {
35
35
  module.exports = __toCommonJS(styles_exports);
36
36
  var import_styled_components = __toESM(require("styled-components"));
37
37
  const Container = import_styled_components.default.div`
38
- position: absolute;
39
- opacity: 0;
40
- z-index: -1;
41
- user-select: none;
42
-
43
- @media(max-width: ${({ theme }) => theme.mobileMaxWidth}) {
44
- width: 100%;
38
+ .target-container {
39
+ position: absolute;
40
+ opacity: 0;
41
+ z-index: -1;
42
+ user-select: none;
43
+
44
+ @media(max-width: ${({ theme }) => theme.mobileMaxWidth}) {
45
+ width: 100%;
46
+ }
45
47
  }
46
48
  `;
47
49
  // Annotate the CommonJS export names for ESM import in node:
@@ -2,13 +2,15 @@
2
2
  "use client";
3
3
  import styled from "styled-components";
4
4
  const Container = styled.div`
5
- position: absolute;
6
- opacity: 0;
7
- z-index: -1;
8
- user-select: none;
9
-
10
- @media(max-width: ${({ theme }) => theme.mobileMaxWidth}) {
11
- width: 100%;
5
+ .target-container {
6
+ position: absolute;
7
+ opacity: 0;
8
+ z-index: -1;
9
+ user-select: none;
10
+
11
+ @media(max-width: ${({ theme }) => theme.mobileMaxWidth}) {
12
+ width: 100%;
13
+ }
12
14
  }
13
15
  `;
14
16
  export {
@@ -14,7 +14,6 @@ export interface ITargetConfigCoords {
14
14
  }
15
15
  export interface ITargetContext {
16
16
  save: (config: ITargetConfig) => void;
17
- remove: (ref: React.RefObject<any>) => void;
18
17
  close: (ref: React.RefObject<any>) => void;
19
18
  isActive: (ref: React.RefObject<any>) => boolean;
20
19
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gustavo-valsechi/client",
3
- "version": "1.4.306",
3
+ "version": "1.4.308",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",