@gustavo-valsechi/client 1.4.276 → 1.4.278
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/src/contexts/target/events/blur.d.ts +1 -0
- package/dist/src/contexts/target/events/blur.js +47 -0
- package/dist/src/contexts/target/events/blur.mjs +13 -0
- package/dist/src/contexts/target/events/click.d.ts +1 -0
- package/dist/src/contexts/target/events/click.js +41 -0
- package/dist/src/contexts/target/events/click.mjs +17 -0
- package/dist/src/contexts/target/events/focus.d.ts +1 -0
- package/dist/src/contexts/target/events/focus.js +32 -0
- package/dist/src/contexts/target/events/focus.mjs +8 -0
- package/dist/src/contexts/target/events/index.d.ts +4 -0
- package/dist/src/contexts/target/events/index.js +29 -0
- package/dist/src/contexts/target/events/index.mjs +5 -0
- package/dist/src/contexts/target/events/scroll.d.ts +1 -0
- package/dist/src/contexts/target/events/scroll.js +83 -0
- package/dist/src/contexts/target/events/scroll.mjs +49 -0
- package/dist/src/contexts/target/index.js +11 -75
- package/dist/src/contexts/target/index.mjs +11 -75
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const onBlur: (target: any, index: any, close: any, focusable: any, insideMemory: any) => void;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
for (var name in all)
|
|
11
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from))
|
|
16
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
20
|
+
};
|
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
+
mod
|
|
28
|
+
));
|
|
29
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
+
var blur_exports = {};
|
|
31
|
+
__export(blur_exports, {
|
|
32
|
+
onBlur: () => onBlur
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(blur_exports);
|
|
35
|
+
var import_lodash = __toESM(require("lodash"));
|
|
36
|
+
const onBlur = (target, index, close, focusable, insideMemory) => {
|
|
37
|
+
if (import_lodash.default.some(insideMemory, (i) => i === index)) {
|
|
38
|
+
console.log("BLUR", target, index);
|
|
39
|
+
focusable.focus();
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
close(index);
|
|
43
|
+
};
|
|
44
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
45
|
+
0 && (module.exports = {
|
|
46
|
+
onBlur
|
|
47
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import _ from "lodash";
|
|
3
|
+
const onBlur = (target, index, close, focusable, insideMemory) => {
|
|
4
|
+
if (_.some(insideMemory, (i) => i === index)) {
|
|
5
|
+
console.log("BLUR", target, index);
|
|
6
|
+
focusable.focus();
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
close(index);
|
|
10
|
+
};
|
|
11
|
+
export {
|
|
12
|
+
onBlur
|
|
13
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const onClick: (target: any, index: any, close: any, focusable: any, targetElement: any, theme: any, setModal: any) => void;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
var click_exports = {};
|
|
21
|
+
__export(click_exports, {
|
|
22
|
+
onClick: () => onClick
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(click_exports);
|
|
25
|
+
const onClick = (target, index, close, focusable, targetElement, theme, setModal) => {
|
|
26
|
+
if (theme.content.isMobile) {
|
|
27
|
+
setModal(index);
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
const styles = window.getComputedStyle(targetElement);
|
|
31
|
+
if (styles.opacity === "1") {
|
|
32
|
+
close(index);
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
console.log("CLICK", target, index);
|
|
36
|
+
focusable.focus();
|
|
37
|
+
};
|
|
38
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
39
|
+
0 && (module.exports = {
|
|
40
|
+
onClick
|
|
41
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
const onClick = (target, index, close, focusable, targetElement, theme, setModal) => {
|
|
3
|
+
if (theme.content.isMobile) {
|
|
4
|
+
setModal(index);
|
|
5
|
+
return;
|
|
6
|
+
}
|
|
7
|
+
const styles = window.getComputedStyle(targetElement);
|
|
8
|
+
if (styles.opacity === "1") {
|
|
9
|
+
close(index);
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
console.log("CLICK", target, index);
|
|
13
|
+
focusable.focus();
|
|
14
|
+
};
|
|
15
|
+
export {
|
|
16
|
+
onClick
|
|
17
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const onFocus: (target: any, index: any, open: any) => void;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
var focus_exports = {};
|
|
21
|
+
__export(focus_exports, {
|
|
22
|
+
onFocus: () => onFocus
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(focus_exports);
|
|
25
|
+
const onFocus = (target, index, open) => {
|
|
26
|
+
console.log("FOCUS", target, index);
|
|
27
|
+
open(target, index);
|
|
28
|
+
};
|
|
29
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
30
|
+
0 && (module.exports = {
|
|
31
|
+
onFocus
|
|
32
|
+
});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __copyProps = (to, from, except, desc) => {
|
|
8
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
9
|
+
for (let key of __getOwnPropNames(from))
|
|
10
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
11
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
12
|
+
}
|
|
13
|
+
return to;
|
|
14
|
+
};
|
|
15
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
16
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
17
|
+
var events_exports = {};
|
|
18
|
+
module.exports = __toCommonJS(events_exports);
|
|
19
|
+
__reExport(events_exports, require("./blur"), module.exports);
|
|
20
|
+
__reExport(events_exports, require("./scroll"), module.exports);
|
|
21
|
+
__reExport(events_exports, require("./focus"), module.exports);
|
|
22
|
+
__reExport(events_exports, require("./click"), module.exports);
|
|
23
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
24
|
+
0 && (module.exports = {
|
|
25
|
+
...require("./blur"),
|
|
26
|
+
...require("./scroll"),
|
|
27
|
+
...require("./focus"),
|
|
28
|
+
...require("./click")
|
|
29
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const onScroll: (close: any, containerRef: any, insideMemory: any) => () => void;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
for (var name in all)
|
|
11
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from))
|
|
16
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
20
|
+
};
|
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
+
mod
|
|
28
|
+
));
|
|
29
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
+
var scroll_exports = {};
|
|
31
|
+
__export(scroll_exports, {
|
|
32
|
+
onScroll: () => onScroll
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(scroll_exports);
|
|
35
|
+
var import_lodash = __toESM(require("lodash"));
|
|
36
|
+
const onScroll = (close, containerRef, insideMemory) => {
|
|
37
|
+
const handleScroll = () => {
|
|
38
|
+
import_lodash.default.forEach(containerRef.current, (element, index) => {
|
|
39
|
+
if (import_lodash.default.some(insideMemory, (i) => i === index)) return;
|
|
40
|
+
close(index);
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
window.addEventListener("scroll", handleScroll, { passive: true });
|
|
44
|
+
const addScrollListener = (el) => {
|
|
45
|
+
el.addEventListener("scroll", handleScroll, { passive: true });
|
|
46
|
+
};
|
|
47
|
+
const handleScrollabels = (el) => {
|
|
48
|
+
if (el.children) import_lodash.default.forEach(el.children, (children) => handleScrollabels(children));
|
|
49
|
+
const style = getComputedStyle(el);
|
|
50
|
+
if (/(auto|scroll|overlay)/.test(style.overflow + style.overflowY + style.overflowX)) {
|
|
51
|
+
addScrollListener(el);
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
const modalScrollables = document.querySelectorAll(".modal-content");
|
|
55
|
+
const divScrollables = document.querySelectorAll("div");
|
|
56
|
+
const articleScrollables = document.querySelectorAll("article");
|
|
57
|
+
const ulScrollables = document.querySelectorAll("ul");
|
|
58
|
+
modalScrollables.forEach((el) => handleScrollabels(el));
|
|
59
|
+
divScrollables.forEach((el) => handleScrollabels(el));
|
|
60
|
+
articleScrollables.forEach((el) => handleScrollabels(el));
|
|
61
|
+
ulScrollables.forEach((el) => handleScrollabels(el));
|
|
62
|
+
const observer = new MutationObserver((mutations) => {
|
|
63
|
+
for (const mutation of mutations) {
|
|
64
|
+
mutation.addedNodes.forEach((node) => {
|
|
65
|
+
if (!(node instanceof HTMLElement)) return;
|
|
66
|
+
handleScrollabels(node);
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
observer.observe(document.body, { childList: true, subtree: true });
|
|
71
|
+
return () => {
|
|
72
|
+
window.removeEventListener("scroll", handleScroll);
|
|
73
|
+
document.querySelectorAll(".modal-content").forEach((el) => el.removeEventListener("scroll", handleScroll));
|
|
74
|
+
document.querySelectorAll("div").forEach((el) => el.removeEventListener("scroll", handleScroll));
|
|
75
|
+
document.querySelectorAll("article").forEach((el) => el.removeEventListener("scroll", handleScroll));
|
|
76
|
+
document.querySelectorAll("ul").forEach((el) => el.removeEventListener("scroll", handleScroll));
|
|
77
|
+
observer.disconnect();
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
81
|
+
0 && (module.exports = {
|
|
82
|
+
onScroll
|
|
83
|
+
});
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import _ from "lodash";
|
|
3
|
+
const onScroll = (close, containerRef, insideMemory) => {
|
|
4
|
+
const handleScroll = () => {
|
|
5
|
+
_.forEach(containerRef.current, (element, index) => {
|
|
6
|
+
if (_.some(insideMemory, (i) => i === index)) return;
|
|
7
|
+
close(index);
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
window.addEventListener("scroll", handleScroll, { passive: true });
|
|
11
|
+
const addScrollListener = (el) => {
|
|
12
|
+
el.addEventListener("scroll", handleScroll, { passive: true });
|
|
13
|
+
};
|
|
14
|
+
const handleScrollabels = (el) => {
|
|
15
|
+
if (el.children) _.forEach(el.children, (children) => handleScrollabels(children));
|
|
16
|
+
const style = getComputedStyle(el);
|
|
17
|
+
if (/(auto|scroll|overlay)/.test(style.overflow + style.overflowY + style.overflowX)) {
|
|
18
|
+
addScrollListener(el);
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
const modalScrollables = document.querySelectorAll(".modal-content");
|
|
22
|
+
const divScrollables = document.querySelectorAll("div");
|
|
23
|
+
const articleScrollables = document.querySelectorAll("article");
|
|
24
|
+
const ulScrollables = document.querySelectorAll("ul");
|
|
25
|
+
modalScrollables.forEach((el) => handleScrollabels(el));
|
|
26
|
+
divScrollables.forEach((el) => handleScrollabels(el));
|
|
27
|
+
articleScrollables.forEach((el) => handleScrollabels(el));
|
|
28
|
+
ulScrollables.forEach((el) => handleScrollabels(el));
|
|
29
|
+
const observer = new MutationObserver((mutations) => {
|
|
30
|
+
for (const mutation of mutations) {
|
|
31
|
+
mutation.addedNodes.forEach((node) => {
|
|
32
|
+
if (!(node instanceof HTMLElement)) return;
|
|
33
|
+
handleScrollabels(node);
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
observer.observe(document.body, { childList: true, subtree: true });
|
|
38
|
+
return () => {
|
|
39
|
+
window.removeEventListener("scroll", handleScroll);
|
|
40
|
+
document.querySelectorAll(".modal-content").forEach((el) => el.removeEventListener("scroll", handleScroll));
|
|
41
|
+
document.querySelectorAll("div").forEach((el) => el.removeEventListener("scroll", handleScroll));
|
|
42
|
+
document.querySelectorAll("article").forEach((el) => el.removeEventListener("scroll", handleScroll));
|
|
43
|
+
document.querySelectorAll("ul").forEach((el) => el.removeEventListener("scroll", handleScroll));
|
|
44
|
+
observer.disconnect();
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
export {
|
|
48
|
+
onScroll
|
|
49
|
+
};
|
|
@@ -39,6 +39,7 @@ var import_react = __toESM(require("react"));
|
|
|
39
39
|
var import_styles = require("./styles");
|
|
40
40
|
var import_theme = require("../theme");
|
|
41
41
|
var import_react_dom = require("react-dom");
|
|
42
|
+
var import_events = require("./events");
|
|
42
43
|
var import_lodash = __toESM(require("lodash"));
|
|
43
44
|
var import_modal = __toESM(require("./modal"));
|
|
44
45
|
const TargetContext = (0, import_react.createContext)({});
|
|
@@ -51,50 +52,8 @@ const TargetProviderContainer = ({ children }) => {
|
|
|
51
52
|
const [targets, setTargets] = (0, import_react.useState)([]);
|
|
52
53
|
const [modal, setModal] = (0, import_react.useState)(-1);
|
|
53
54
|
(0, import_react.useEffect)(() => {
|
|
54
|
-
|
|
55
|
-
import_lodash.default.forEach(containerRef.current, (element, index) => {
|
|
56
|
-
if (import_lodash.default.some(insideMemory, (i) => i === index)) return;
|
|
57
|
-
close(index);
|
|
58
|
-
});
|
|
59
|
-
};
|
|
60
|
-
window.addEventListener("scroll", handleScroll, { passive: true });
|
|
61
|
-
const addScrollListener = (el) => {
|
|
62
|
-
el.addEventListener("scroll", handleScroll, { passive: true });
|
|
63
|
-
};
|
|
64
|
-
const handleScrollabels = (el) => {
|
|
65
|
-
if (el.children) import_lodash.default.forEach(el.children, (children2) => handleScrollabels(children2));
|
|
66
|
-
const style = getComputedStyle(el);
|
|
67
|
-
if (/(auto|scroll|overlay)/.test(style.overflow + style.overflowY + style.overflowX)) {
|
|
68
|
-
addScrollListener(el);
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
const modalScrollables = document.querySelectorAll(".modal-content");
|
|
72
|
-
const divScrollables = document.querySelectorAll("div");
|
|
73
|
-
const articleScrollables = document.querySelectorAll("article");
|
|
74
|
-
const ulScrollables = document.querySelectorAll("ul");
|
|
75
|
-
modalScrollables.forEach((el) => handleScrollabels(el));
|
|
76
|
-
divScrollables.forEach((el) => handleScrollabels(el));
|
|
77
|
-
articleScrollables.forEach((el) => handleScrollabels(el));
|
|
78
|
-
ulScrollables.forEach((el) => handleScrollabels(el));
|
|
79
|
-
const observer = new MutationObserver((mutations) => {
|
|
80
|
-
for (const mutation of mutations) {
|
|
81
|
-
mutation.addedNodes.forEach((node) => {
|
|
82
|
-
if (!(node instanceof HTMLElement)) return;
|
|
83
|
-
handleScrollabels(node);
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
observer.observe(document.body, { childList: true, subtree: true });
|
|
88
|
-
return () => {
|
|
89
|
-
window.removeEventListener("scroll", handleScroll);
|
|
90
|
-
document.querySelectorAll(".modal-content").forEach((el) => el.removeEventListener("scroll", handleScroll));
|
|
91
|
-
document.querySelectorAll("div").forEach((el) => el.removeEventListener("scroll", handleScroll));
|
|
92
|
-
document.querySelectorAll("article").forEach((el) => el.removeEventListener("scroll", handleScroll));
|
|
93
|
-
document.querySelectorAll("ul").forEach((el) => el.removeEventListener("scroll", handleScroll));
|
|
94
|
-
observer.disconnect();
|
|
95
|
-
};
|
|
55
|
+
(0, import_events.onScroll)(close, containerRef, insideMemory);
|
|
96
56
|
}, [containerRef]);
|
|
97
|
-
console.log("targets", targets);
|
|
98
57
|
(0, import_react.useEffect)(() => {
|
|
99
58
|
import_lodash.default.forEach(targets, (target, index) => {
|
|
100
59
|
var _a, _b;
|
|
@@ -103,38 +62,15 @@ const TargetProviderContainer = ({ children }) => {
|
|
|
103
62
|
if (!(toggleElement == null ? void 0 : toggleElement.addEventListener)) return;
|
|
104
63
|
const focusable = elementFocusable(target, index);
|
|
105
64
|
const targetElement = containerRef.current[index];
|
|
106
|
-
toggleElement.
|
|
107
|
-
|
|
108
|
-
setModal(index);
|
|
109
|
-
return;
|
|
110
|
-
}
|
|
111
|
-
const styles = window.getComputedStyle(targetElement);
|
|
112
|
-
if (styles.opacity === "1") {
|
|
113
|
-
close(index);
|
|
114
|
-
return;
|
|
115
|
-
}
|
|
116
|
-
console.log("CLICK", target, index);
|
|
117
|
-
focusable.focus();
|
|
118
|
-
});
|
|
65
|
+
toggleElement.removeEventListener("click", () => (0, import_events.onClick)(target, index, close, focusable, targetElement, theme, setModal));
|
|
66
|
+
toggleElement.addEventListener("click", () => (0, import_events.onClick)(target, index, close, focusable, targetElement, theme, setModal));
|
|
119
67
|
if (theme.content.isMobile) return;
|
|
120
|
-
toggleElement.
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
focusable.addEventListener("focus", () => {
|
|
127
|
-
console.log("FOCUS", target, index);
|
|
128
|
-
open(target, index);
|
|
129
|
-
});
|
|
130
|
-
focusable.addEventListener("blur", () => {
|
|
131
|
-
if (import_lodash.default.some(insideMemory, (i) => i === index)) {
|
|
132
|
-
console.log("BLUR", target, index);
|
|
133
|
-
focusable.focus();
|
|
134
|
-
return;
|
|
135
|
-
}
|
|
136
|
-
close(index);
|
|
137
|
-
});
|
|
68
|
+
toggleElement.removeEventListener("mouseleave", () => removeInside(index));
|
|
69
|
+
focusable.removeEventListener("focus", () => (0, import_events.onFocus)(target, index, open));
|
|
70
|
+
focusable.removeEventListener("blur", () => (0, import_events.onBlur)(target, index, close, focusable, insideMemory));
|
|
71
|
+
toggleElement.addEventListener("mouseleave", () => removeInside(index));
|
|
72
|
+
focusable.addEventListener("focus", () => (0, import_events.onFocus)(target, index, open));
|
|
73
|
+
focusable.addEventListener("blur", () => (0, import_events.onBlur)(target, index, close, focusable, insideMemory));
|
|
138
74
|
});
|
|
139
75
|
}, [targets, inputRef, containerRef, theme.content.isMobile]);
|
|
140
76
|
const getCoords = (target, component) => {
|
|
@@ -187,7 +123,7 @@ const TargetProviderContainer = ({ children }) => {
|
|
|
187
123
|
const add = (target) => {
|
|
188
124
|
const exists = import_lodash.default.find(memory, (data) => data.ref.current === target.ref.current);
|
|
189
125
|
if (exists) return;
|
|
190
|
-
console.log("memory", memory);
|
|
126
|
+
console.log("memory", [...memory]);
|
|
191
127
|
memory.push(target);
|
|
192
128
|
setTargets([...memory]);
|
|
193
129
|
};
|
|
@@ -5,6 +5,7 @@ import React, { createContext, useContext, useEffect, useState, useRef } from "r
|
|
|
5
5
|
import { Container } from "./styles";
|
|
6
6
|
import { useTheme } from "../theme";
|
|
7
7
|
import { createPortal } from "react-dom";
|
|
8
|
+
import { onScroll, onBlur, onFocus, onClick } from "./events";
|
|
8
9
|
import _ from "lodash";
|
|
9
10
|
import Modal from "./modal";
|
|
10
11
|
const TargetContext = createContext({});
|
|
@@ -17,50 +18,8 @@ const TargetProviderContainer = ({ children }) => {
|
|
|
17
18
|
const [targets, setTargets] = useState([]);
|
|
18
19
|
const [modal, setModal] = useState(-1);
|
|
19
20
|
useEffect(() => {
|
|
20
|
-
|
|
21
|
-
_.forEach(containerRef.current, (element, index) => {
|
|
22
|
-
if (_.some(insideMemory, (i) => i === index)) return;
|
|
23
|
-
close(index);
|
|
24
|
-
});
|
|
25
|
-
};
|
|
26
|
-
window.addEventListener("scroll", handleScroll, { passive: true });
|
|
27
|
-
const addScrollListener = (el) => {
|
|
28
|
-
el.addEventListener("scroll", handleScroll, { passive: true });
|
|
29
|
-
};
|
|
30
|
-
const handleScrollabels = (el) => {
|
|
31
|
-
if (el.children) _.forEach(el.children, (children2) => handleScrollabels(children2));
|
|
32
|
-
const style = getComputedStyle(el);
|
|
33
|
-
if (/(auto|scroll|overlay)/.test(style.overflow + style.overflowY + style.overflowX)) {
|
|
34
|
-
addScrollListener(el);
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
const modalScrollables = document.querySelectorAll(".modal-content");
|
|
38
|
-
const divScrollables = document.querySelectorAll("div");
|
|
39
|
-
const articleScrollables = document.querySelectorAll("article");
|
|
40
|
-
const ulScrollables = document.querySelectorAll("ul");
|
|
41
|
-
modalScrollables.forEach((el) => handleScrollabels(el));
|
|
42
|
-
divScrollables.forEach((el) => handleScrollabels(el));
|
|
43
|
-
articleScrollables.forEach((el) => handleScrollabels(el));
|
|
44
|
-
ulScrollables.forEach((el) => handleScrollabels(el));
|
|
45
|
-
const observer = new MutationObserver((mutations) => {
|
|
46
|
-
for (const mutation of mutations) {
|
|
47
|
-
mutation.addedNodes.forEach((node) => {
|
|
48
|
-
if (!(node instanceof HTMLElement)) return;
|
|
49
|
-
handleScrollabels(node);
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
observer.observe(document.body, { childList: true, subtree: true });
|
|
54
|
-
return () => {
|
|
55
|
-
window.removeEventListener("scroll", handleScroll);
|
|
56
|
-
document.querySelectorAll(".modal-content").forEach((el) => el.removeEventListener("scroll", handleScroll));
|
|
57
|
-
document.querySelectorAll("div").forEach((el) => el.removeEventListener("scroll", handleScroll));
|
|
58
|
-
document.querySelectorAll("article").forEach((el) => el.removeEventListener("scroll", handleScroll));
|
|
59
|
-
document.querySelectorAll("ul").forEach((el) => el.removeEventListener("scroll", handleScroll));
|
|
60
|
-
observer.disconnect();
|
|
61
|
-
};
|
|
21
|
+
onScroll(close, containerRef, insideMemory);
|
|
62
22
|
}, [containerRef]);
|
|
63
|
-
console.log("targets", targets);
|
|
64
23
|
useEffect(() => {
|
|
65
24
|
_.forEach(targets, (target, index) => {
|
|
66
25
|
var _a, _b;
|
|
@@ -69,38 +28,15 @@ const TargetProviderContainer = ({ children }) => {
|
|
|
69
28
|
if (!(toggleElement == null ? void 0 : toggleElement.addEventListener)) return;
|
|
70
29
|
const focusable = elementFocusable(target, index);
|
|
71
30
|
const targetElement = containerRef.current[index];
|
|
72
|
-
toggleElement.
|
|
73
|
-
|
|
74
|
-
setModal(index);
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
const styles = window.getComputedStyle(targetElement);
|
|
78
|
-
if (styles.opacity === "1") {
|
|
79
|
-
close(index);
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
|
-
console.log("CLICK", target, index);
|
|
83
|
-
focusable.focus();
|
|
84
|
-
});
|
|
31
|
+
toggleElement.removeEventListener("click", () => onClick(target, index, close, focusable, targetElement, theme, setModal));
|
|
32
|
+
toggleElement.addEventListener("click", () => onClick(target, index, close, focusable, targetElement, theme, setModal));
|
|
85
33
|
if (theme.content.isMobile) return;
|
|
86
|
-
toggleElement.
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
focusable.addEventListener("focus", () => {
|
|
93
|
-
console.log("FOCUS", target, index);
|
|
94
|
-
open(target, index);
|
|
95
|
-
});
|
|
96
|
-
focusable.addEventListener("blur", () => {
|
|
97
|
-
if (_.some(insideMemory, (i) => i === index)) {
|
|
98
|
-
console.log("BLUR", target, index);
|
|
99
|
-
focusable.focus();
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
close(index);
|
|
103
|
-
});
|
|
34
|
+
toggleElement.removeEventListener("mouseleave", () => removeInside(index));
|
|
35
|
+
focusable.removeEventListener("focus", () => onFocus(target, index, open));
|
|
36
|
+
focusable.removeEventListener("blur", () => onBlur(target, index, close, focusable, insideMemory));
|
|
37
|
+
toggleElement.addEventListener("mouseleave", () => removeInside(index));
|
|
38
|
+
focusable.addEventListener("focus", () => onFocus(target, index, open));
|
|
39
|
+
focusable.addEventListener("blur", () => onBlur(target, index, close, focusable, insideMemory));
|
|
104
40
|
});
|
|
105
41
|
}, [targets, inputRef, containerRef, theme.content.isMobile]);
|
|
106
42
|
const getCoords = (target, component) => {
|
|
@@ -153,7 +89,7 @@ const TargetProviderContainer = ({ children }) => {
|
|
|
153
89
|
const add = (target) => {
|
|
154
90
|
const exists = _.find(memory, (data) => data.ref.current === target.ref.current);
|
|
155
91
|
if (exists) return;
|
|
156
|
-
console.log("memory", memory);
|
|
92
|
+
console.log("memory", [...memory]);
|
|
157
93
|
memory.push(target);
|
|
158
94
|
setTargets([...memory]);
|
|
159
95
|
};
|