@gustavo-valsechi/client 1.4.102 → 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(
|
|
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
|
-
}, [
|
|
100
|
+
}, []);
|
|
101
101
|
(0, import_react.useEffect)(() => {
|
|
102
102
|
import_lodash.default.forEach(targets, (target, index) => {
|
|
103
103
|
var _a;
|
|
@@ -119,8 +119,13 @@ const TargetProviderContainer = ({ children }) => {
|
|
|
119
119
|
element.addEventListener("resize", () => {
|
|
120
120
|
import_lodash.default.forEach(containerRef.current, (elementRef) => close(elementRef));
|
|
121
121
|
});
|
|
122
|
+
focusable.addEventListener("blur", () => {
|
|
123
|
+
console.log(insideMemory);
|
|
124
|
+
if (import_lodash.default.some(insideMemory, (i) => i === index)) return;
|
|
125
|
+
close(containerRef.current[index]);
|
|
126
|
+
});
|
|
122
127
|
});
|
|
123
|
-
}, [targets, inputRef, containerRef
|
|
128
|
+
}, [targets, inputRef, containerRef]);
|
|
124
129
|
const getCoords = (target) => {
|
|
125
130
|
const rect = target.getBoundingClientRect();
|
|
126
131
|
const targetTop = rect.top + window.scrollY;
|
|
@@ -162,11 +167,11 @@ const TargetProviderContainer = ({ children }) => {
|
|
|
162
167
|
{
|
|
163
168
|
ref: (element) => containerRef.current[index] = element,
|
|
164
169
|
onMouseEnter: () => {
|
|
165
|
-
|
|
170
|
+
insideMemory.push(index);
|
|
166
171
|
elementFocusable(target, index).focus();
|
|
167
172
|
},
|
|
168
173
|
onMouseLeave: () => {
|
|
169
|
-
|
|
174
|
+
insideMemory.splice(import_lodash.default.findIndex(insideMemory, (i) => i === index), 1);
|
|
170
175
|
elementFocusable(target, index).focus();
|
|
171
176
|
},
|
|
172
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(
|
|
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
|
-
}, [
|
|
66
|
+
}, []);
|
|
67
67
|
useEffect(() => {
|
|
68
68
|
_.forEach(targets, (target, index) => {
|
|
69
69
|
var _a;
|
|
@@ -85,8 +85,13 @@ const TargetProviderContainer = ({ children }) => {
|
|
|
85
85
|
element.addEventListener("resize", () => {
|
|
86
86
|
_.forEach(containerRef.current, (elementRef) => close(elementRef));
|
|
87
87
|
});
|
|
88
|
+
focusable.addEventListener("blur", () => {
|
|
89
|
+
console.log(insideMemory);
|
|
90
|
+
if (_.some(insideMemory, (i) => i === index)) return;
|
|
91
|
+
close(containerRef.current[index]);
|
|
92
|
+
});
|
|
88
93
|
});
|
|
89
|
-
}, [targets, inputRef, containerRef
|
|
94
|
+
}, [targets, inputRef, containerRef]);
|
|
90
95
|
const getCoords = (target) => {
|
|
91
96
|
const rect = target.getBoundingClientRect();
|
|
92
97
|
const targetTop = rect.top + window.scrollY;
|
|
@@ -128,11 +133,11 @@ const TargetProviderContainer = ({ children }) => {
|
|
|
128
133
|
{
|
|
129
134
|
ref: (element) => containerRef.current[index] = element,
|
|
130
135
|
onMouseEnter: () => {
|
|
131
|
-
|
|
136
|
+
insideMemory.push(index);
|
|
132
137
|
elementFocusable(target, index).focus();
|
|
133
138
|
},
|
|
134
139
|
onMouseLeave: () => {
|
|
135
|
-
|
|
140
|
+
insideMemory.splice(_.findIndex(insideMemory, (i) => i === index), 1);
|
|
136
141
|
elementFocusable(target, index).focus();
|
|
137
142
|
},
|
|
138
143
|
children: target.component
|