@gustavo-valsechi/client 1.4.119 → 1.4.120
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.
- package/dist/contexts/target/index.js +14 -14
- package/dist/contexts/target/index.mjs +14 -14
- package/package.json +1 -1
|
@@ -50,22 +50,25 @@ const TargetProviderContainer = ({ children }) => {
|
|
|
50
50
|
if (isFocusable) return target.ref.current;
|
|
51
51
|
return inputRef.current[index];
|
|
52
52
|
};
|
|
53
|
-
const close = (
|
|
53
|
+
const close = (target, index) => {
|
|
54
|
+
const element = containerRef.current[index];
|
|
54
55
|
element.style.opacity = "0";
|
|
55
56
|
element.style.zIndex = "-1";
|
|
56
57
|
insideMemory.splice(import_lodash.default.findIndex(insideMemory, (i) => i === index), 1);
|
|
57
58
|
};
|
|
58
|
-
const open = (
|
|
59
|
+
const open = (target, index, coords) => {
|
|
60
|
+
const element = containerRef.current[index];
|
|
59
61
|
element.style.top = `${coords.top}px`;
|
|
60
62
|
element.style.left = `${coords.left}px`;
|
|
61
63
|
element.style.opacity = "1";
|
|
62
64
|
element.style.zIndex = "10";
|
|
65
|
+
elementFocusable(target, index).focus();
|
|
63
66
|
};
|
|
64
67
|
(0, import_react.useEffect)(() => {
|
|
65
68
|
const handleScroll = () => {
|
|
66
69
|
import_lodash.default.forEach(containerRef.current, (element, index) => {
|
|
67
70
|
if (import_lodash.default.some(insideMemory, (i) => i === index)) return;
|
|
68
|
-
close(
|
|
71
|
+
close(targets[index], index);
|
|
69
72
|
});
|
|
70
73
|
};
|
|
71
74
|
window.addEventListener("scroll", handleScroll, { passive: true });
|
|
@@ -98,31 +101,29 @@ const TargetProviderContainer = ({ children }) => {
|
|
|
98
101
|
});
|
|
99
102
|
observer.disconnect();
|
|
100
103
|
};
|
|
101
|
-
}, []);
|
|
104
|
+
}, [targets]);
|
|
102
105
|
(0, import_react.useEffect)(() => {
|
|
103
106
|
import_lodash.default.forEach(targets, (target, index) => {
|
|
104
107
|
var _a;
|
|
105
108
|
const element = (_a = target.ref) == null ? void 0 : _a.current;
|
|
106
109
|
if (!(element == null ? void 0 : element.addEventListener)) return;
|
|
107
110
|
const focusable = elementFocusable(target, index);
|
|
108
|
-
const targetElement =
|
|
111
|
+
const targetElement = containerRef.current[index];
|
|
109
112
|
element.addEventListener("click", () => {
|
|
110
|
-
if (!targetElement) return;
|
|
111
113
|
const styles = window.getComputedStyle(targetElement);
|
|
112
114
|
if (styles.opacity === "1") {
|
|
113
|
-
close(
|
|
115
|
+
close(target, index);
|
|
114
116
|
return;
|
|
115
117
|
}
|
|
116
118
|
const coords = getCoords(element);
|
|
117
|
-
open(
|
|
118
|
-
focusable.focus();
|
|
119
|
+
open(target, index, coords);
|
|
119
120
|
});
|
|
120
121
|
element.addEventListener("resize", () => {
|
|
121
|
-
import_lodash.default.forEach(containerRef.current, (elementRef) => close(
|
|
122
|
+
import_lodash.default.forEach(containerRef.current, (elementRef) => close(target, index));
|
|
122
123
|
});
|
|
123
124
|
focusable.addEventListener("blur", () => {
|
|
124
125
|
if (import_lodash.default.some(insideMemory, (i) => i === index)) return;
|
|
125
|
-
close(
|
|
126
|
+
close(target, index);
|
|
126
127
|
});
|
|
127
128
|
});
|
|
128
129
|
}, [targets, inputRef, containerRef]);
|
|
@@ -156,9 +157,8 @@ const TargetProviderContainer = ({ children }) => {
|
|
|
156
157
|
};
|
|
157
158
|
const closeTarget = (ref) => {
|
|
158
159
|
const index = import_lodash.default.findIndex(memory, (data) => data.ref.current === ref.current);
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
close(targetElement, index);
|
|
160
|
+
insideMemory.splice(import_lodash.default.findIndex(insideMemory, (i) => i === index), 1);
|
|
161
|
+
elementFocusable(targets[index], index).blur();
|
|
162
162
|
};
|
|
163
163
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
164
164
|
TargetContext.Provider,
|
|
@@ -16,22 +16,25 @@ const TargetProviderContainer = ({ children }) => {
|
|
|
16
16
|
if (isFocusable) return target.ref.current;
|
|
17
17
|
return inputRef.current[index];
|
|
18
18
|
};
|
|
19
|
-
const close = (
|
|
19
|
+
const close = (target, index) => {
|
|
20
|
+
const element = containerRef.current[index];
|
|
20
21
|
element.style.opacity = "0";
|
|
21
22
|
element.style.zIndex = "-1";
|
|
22
23
|
insideMemory.splice(_.findIndex(insideMemory, (i) => i === index), 1);
|
|
23
24
|
};
|
|
24
|
-
const open = (
|
|
25
|
+
const open = (target, index, coords) => {
|
|
26
|
+
const element = containerRef.current[index];
|
|
25
27
|
element.style.top = `${coords.top}px`;
|
|
26
28
|
element.style.left = `${coords.left}px`;
|
|
27
29
|
element.style.opacity = "1";
|
|
28
30
|
element.style.zIndex = "10";
|
|
31
|
+
elementFocusable(target, index).focus();
|
|
29
32
|
};
|
|
30
33
|
useEffect(() => {
|
|
31
34
|
const handleScroll = () => {
|
|
32
35
|
_.forEach(containerRef.current, (element, index) => {
|
|
33
36
|
if (_.some(insideMemory, (i) => i === index)) return;
|
|
34
|
-
close(
|
|
37
|
+
close(targets[index], index);
|
|
35
38
|
});
|
|
36
39
|
};
|
|
37
40
|
window.addEventListener("scroll", handleScroll, { passive: true });
|
|
@@ -64,31 +67,29 @@ const TargetProviderContainer = ({ children }) => {
|
|
|
64
67
|
});
|
|
65
68
|
observer.disconnect();
|
|
66
69
|
};
|
|
67
|
-
}, []);
|
|
70
|
+
}, [targets]);
|
|
68
71
|
useEffect(() => {
|
|
69
72
|
_.forEach(targets, (target, index) => {
|
|
70
73
|
var _a;
|
|
71
74
|
const element = (_a = target.ref) == null ? void 0 : _a.current;
|
|
72
75
|
if (!(element == null ? void 0 : element.addEventListener)) return;
|
|
73
76
|
const focusable = elementFocusable(target, index);
|
|
74
|
-
const targetElement =
|
|
77
|
+
const targetElement = containerRef.current[index];
|
|
75
78
|
element.addEventListener("click", () => {
|
|
76
|
-
if (!targetElement) return;
|
|
77
79
|
const styles = window.getComputedStyle(targetElement);
|
|
78
80
|
if (styles.opacity === "1") {
|
|
79
|
-
close(
|
|
81
|
+
close(target, index);
|
|
80
82
|
return;
|
|
81
83
|
}
|
|
82
84
|
const coords = getCoords(element);
|
|
83
|
-
open(
|
|
84
|
-
focusable.focus();
|
|
85
|
+
open(target, index, coords);
|
|
85
86
|
});
|
|
86
87
|
element.addEventListener("resize", () => {
|
|
87
|
-
_.forEach(containerRef.current, (elementRef) => close(
|
|
88
|
+
_.forEach(containerRef.current, (elementRef) => close(target, index));
|
|
88
89
|
});
|
|
89
90
|
focusable.addEventListener("blur", () => {
|
|
90
91
|
if (_.some(insideMemory, (i) => i === index)) return;
|
|
91
|
-
close(
|
|
92
|
+
close(target, index);
|
|
92
93
|
});
|
|
93
94
|
});
|
|
94
95
|
}, [targets, inputRef, containerRef]);
|
|
@@ -122,9 +123,8 @@ const TargetProviderContainer = ({ children }) => {
|
|
|
122
123
|
};
|
|
123
124
|
const closeTarget = (ref) => {
|
|
124
125
|
const index = _.findIndex(memory, (data) => data.ref.current === ref.current);
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
close(targetElement, index);
|
|
126
|
+
insideMemory.splice(_.findIndex(insideMemory, (i) => i === index), 1);
|
|
127
|
+
elementFocusable(targets[index], index).blur();
|
|
128
128
|
};
|
|
129
129
|
return /* @__PURE__ */ jsxs(
|
|
130
130
|
TargetContext.Provider,
|