@gustavo-valsechi/client 1.4.103 → 1.4.104

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,11 +39,11 @@ 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 insideMemory = [];
42
43
  const TargetProviderContainer = ({ children }) => {
43
44
  const inputRef = (0, import_react.useRef)([]);
44
45
  const containerRef = (0, import_react.useRef)([]);
45
46
  const [targets, setTargets] = (0, import_react.useState)([]);
46
- const [inside, setInside] = (0, import_react.useState)([]);
47
47
  const elementFocusable = (target, index) => {
48
48
  const focusableTags = ["input", "select", "textarea", "button"];
49
49
  const isFocusable = import_lodash.default.some(focusableTags, (tag) => target.ref.current.tagName.toLowerCase() === tag);
@@ -63,7 +63,7 @@ const TargetProviderContainer = ({ children }) => {
63
63
  (0, import_react.useEffect)(() => {
64
64
  const handleScroll = () => {
65
65
  import_lodash.default.forEach(containerRef.current, (element, index) => {
66
- if (import_lodash.default.some(inside, (i) => i === index)) return;
66
+ if (import_lodash.default.some(insideMemory, (i) => i === index)) return;
67
67
  close(element);
68
68
  });
69
69
  };
@@ -97,7 +97,7 @@ const TargetProviderContainer = ({ children }) => {
97
97
  });
98
98
  observer.disconnect();
99
99
  };
100
- }, [inside]);
100
+ }, []);
101
101
  (0, import_react.useEffect)(() => {
102
102
  import_lodash.default.forEach(targets, (target, index) => {
103
103
  var _a;
@@ -120,12 +120,12 @@ const TargetProviderContainer = ({ children }) => {
120
120
  import_lodash.default.forEach(containerRef.current, (elementRef) => close(elementRef));
121
121
  });
122
122
  focusable.addEventListener("blur", () => {
123
- console.log(inside);
124
- if (import_lodash.default.some(inside, (i) => i === index)) return;
123
+ console.log(insideMemory);
124
+ if (import_lodash.default.some(insideMemory, (i) => i === index)) return;
125
125
  close(containerRef.current[index]);
126
126
  });
127
127
  });
128
- }, [targets, inputRef, containerRef, inside]);
128
+ }, [targets, inputRef, containerRef]);
129
129
  const getCoords = (target) => {
130
130
  const rect = target.getBoundingClientRect();
131
131
  const targetTop = rect.top + window.scrollY;
@@ -167,11 +167,11 @@ const TargetProviderContainer = ({ children }) => {
167
167
  {
168
168
  ref: (element) => containerRef.current[index] = element,
169
169
  onMouseEnter: () => {
170
- setInside(import_lodash.default.concat(inside, index));
170
+ insideMemory.push(index);
171
171
  elementFocusable(target, index).focus();
172
172
  },
173
173
  onMouseLeave: () => {
174
- setInside(import_lodash.default.filter(inside, (i) => i !== index));
174
+ insideMemory.splice(import_lodash.default.findIndex(insideMemory, (i) => i === index), 1);
175
175
  elementFocusable(target, index).focus();
176
176
  },
177
177
  children: target.component
@@ -5,11 +5,11 @@ import { Container } from "./styles";
5
5
  import _ from "lodash";
6
6
  const TargetContext = createContext({});
7
7
  const memory = [];
8
+ const insideMemory = [];
8
9
  const TargetProviderContainer = ({ children }) => {
9
10
  const inputRef = useRef([]);
10
11
  const containerRef = useRef([]);
11
12
  const [targets, setTargets] = useState([]);
12
- const [inside, setInside] = useState([]);
13
13
  const elementFocusable = (target, index) => {
14
14
  const focusableTags = ["input", "select", "textarea", "button"];
15
15
  const isFocusable = _.some(focusableTags, (tag) => target.ref.current.tagName.toLowerCase() === tag);
@@ -29,7 +29,7 @@ const TargetProviderContainer = ({ children }) => {
29
29
  useEffect(() => {
30
30
  const handleScroll = () => {
31
31
  _.forEach(containerRef.current, (element, index) => {
32
- if (_.some(inside, (i) => i === index)) return;
32
+ if (_.some(insideMemory, (i) => i === index)) return;
33
33
  close(element);
34
34
  });
35
35
  };
@@ -63,7 +63,7 @@ const TargetProviderContainer = ({ children }) => {
63
63
  });
64
64
  observer.disconnect();
65
65
  };
66
- }, [inside]);
66
+ }, []);
67
67
  useEffect(() => {
68
68
  _.forEach(targets, (target, index) => {
69
69
  var _a;
@@ -86,12 +86,12 @@ const TargetProviderContainer = ({ children }) => {
86
86
  _.forEach(containerRef.current, (elementRef) => close(elementRef));
87
87
  });
88
88
  focusable.addEventListener("blur", () => {
89
- console.log(inside);
90
- if (_.some(inside, (i) => i === index)) return;
89
+ console.log(insideMemory);
90
+ if (_.some(insideMemory, (i) => i === index)) return;
91
91
  close(containerRef.current[index]);
92
92
  });
93
93
  });
94
- }, [targets, inputRef, containerRef, inside]);
94
+ }, [targets, inputRef, containerRef]);
95
95
  const getCoords = (target) => {
96
96
  const rect = target.getBoundingClientRect();
97
97
  const targetTop = rect.top + window.scrollY;
@@ -133,11 +133,11 @@ const TargetProviderContainer = ({ children }) => {
133
133
  {
134
134
  ref: (element) => containerRef.current[index] = element,
135
135
  onMouseEnter: () => {
136
- setInside(_.concat(inside, index));
136
+ insideMemory.push(index);
137
137
  elementFocusable(target, index).focus();
138
138
  },
139
139
  onMouseLeave: () => {
140
- setInside(_.filter(inside, (i) => i !== index));
140
+ insideMemory.splice(_.findIndex(insideMemory, (i) => i === index), 1);
141
141
  elementFocusable(target, index).focus();
142
142
  },
143
143
  children: target.component
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gustavo-valsechi/client",
3
- "version": "1.4.103",
3
+ "version": "1.4.104",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",