PluginProbe ʕ •ᴥ•ʔ
Everest Forms – Contact Form, Payment Form, Quiz, Survey & Custom Form Builder with AI / 3.5.2
Everest Forms – Contact Form, Payment Form, Quiz, Survey & Custom Form Builder with AI v3.5.2
3.5.2 3.5.1 3.5.0 3.4.8 3.4.7 3.4.6 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.5.1 1.1.6 1.1.7 1.1.8 1.1.9 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.4.8 1.4.9 1.5.0 1.5.1 1.5.10 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.5.9 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.6.1 1.6.7 1.7.0 1.7.0.1 1.7.0.2 1.7.0.3 1.7.1 1.7.2 1.7.2.1 1.7.2.2 1.7.3 1.7.4 1.7.5 1.7.5.1 1.7.5.2 1.7.6 1.7.7 1.7.7.1 1.7.7.2 1.7.8 1.7.9 1.8.0 1.8.0.1 1.8.1 1.8.2 1.8.2.1 1.8.2.2 1.8.2.3 1.8.3 1.8.4 1.8.5 1.8.6 1.8.7 1.8.8 1.8.9 1.9.0 1.9.0.1 1.9.1 1.9.2 1.9.3 1.9.4 1.9.4.1 1.9.5 1.9.6 1.9.7 1.9.8 1.9.9 2.0.0 2.0.0.1 2.0.1 2.0.2 2.0.3 2.0.3.1 2.0.4 2.0.4.1 2.0.5 2.0.6 2.0.7 2.0.8 2.0.8.1 2.0.9 3.0.0 3.0.0.1 3.0.1 3.0.2 3.0.3 3.0.3.1 3.0.4 3.0.4.1 3.0.4.2 3.0.5 3.0.5.1 3.0.5.2 3.0.6 3.0.6.1 3.0.7.1 3.0.8 3.0.8.1 3.0.9 3.0.9.1 3.0.9.2 3.0.9.3 3.0.9.4 3.0.9.5 3.1.0 3.1.1 3.1.2 3.2.0 3.2.1 3.2.2 3.2.3 3.2.4 3.2.5 3.2.6 3.3.0 3.4.0 3.4.1 3.4.2 3.4.2.1 3.4.3 3.4.4 3.4.5 trunk 1.0 1.0.1 1.0.2 1.0.3
everest-forms / src / dashboard / components / IntersectionObserver / IntersectionObserver.js
everest-forms / src / dashboard / components / IntersectionObserver Last commit date
IntersectionObserver.js 4 months ago
IntersectionObserver.js
141 lines
1 /**
2 * External Dependencies
3 */
4 import React, { useEffect, useRef, useState } from "react";
5 import {
6 HStack,
7 IconButton,
8 Link,
9 Menu,
10 MenuButton,
11 MenuItem,
12 MenuList,
13 } from "@chakra-ui/react";
14 import { NavLink, useLocation } from "react-router-dom";
15 import PropTypes from "prop-types";
16
17 /**
18 * Internal Dependencies
19 */
20 import { DotsHorizontal } from "../Icon/Icon";
21 import { convertRoute, isExternalRoute } from "../../Constants";
22
23 const IntersectionStyles = {
24 visible: {
25 order: 0,
26 visibility: "visible",
27 opacity: 1,
28 },
29 inVisible: {
30 order: 100,
31 visibility: "hidden",
32 pointerEvents: "none",
33 },
34 toolbarWrapper: {
35 overflow: "hidden",
36 display: "flex",
37 border: "1px solid black",
38 alignItem: "center",
39 },
40 overflowStyle: {
41 order: 99,
42 position: "sticky",
43 right: "0",
44 backgroundColor: "white",
45 },
46 };
47
48 const IntersectObserver = ({ children, routes }) => {
49 const ref = useRef(null);
50 const [visibleMap, setVisibleMap] = useState({});
51 const location = useLocation();
52 const hiddenRoutes = routes.filter((route) => !visibleMap[route.route]);
53
54 const selectedHiddenRoute = hiddenRoutes.find(
55 (h) => h.route === location.pathname
56 );
57
58 const { pageType, adminURL } =
59 typeof _EVF_DASHBOARD_ !== "undefined" && _EVF_DASHBOARD_;
60 const isSettingsPage = pageType === "settings";
61 const isEntriesPage = pageType === "entries";
62 const isFormsPage = pageType === "forms";
63 const isAnalyticsPage = pageType === "analytics";
64 const isNonDashboardPage = isSettingsPage || isEntriesPage || isAnalyticsPage || isFormsPage;
65
66 useEffect(() => {
67 if (!ref.current) return;
68 const observer = new IntersectionObserver(
69 (entries) => {
70 const updatedEntries = {};
71 entries.forEach((entry) => {
72 const target = entry.target.dataset?.["target"];
73 if (entry.isIntersecting && target) {
74 updatedEntries[target] = true;
75 }
76 if (!entry.isIntersecting && target) {
77 updatedEntries[target] = false;
78 }
79 });
80
81 setVisibleMap((prev) => ({
82 ...prev,
83 ...updatedEntries,
84 }));
85 },
86 {
87 root: ref.current,
88 threshold: 0.98,
89 }
90 );
91
92 Array.from(ref.current.children).forEach((item) => {
93 if (item.getAttribute("data-target")) {
94 observer.observe(item);
95 }
96 });
97
98 return () => observer.disconnect();
99 }, []);
100
101 const shouldShowMenu = Object.values(visibleMap).some((v) => v === false);
102
103 return (
104 <HStack
105 ref={ref}
106 width={{
107 base: "50px",
108 sm: "240px",
109 md: "520px",
110 lg: "570px",
111 xl: "680px",
112 }}
113 overflow={"hidden"}
114 h="full"
115 >
116 {React.Children.map(children, (child) => {
117 const otherSX = visibleMap[child.props["data-target"]]
118 ? IntersectionStyles.visible
119 : IntersectionStyles.inVisible;
120
121 return React.cloneElement(child, {
122 sx: { ...children?.props?.sx, ...otherSX },
123 });
124 })}
125
126 </HStack>
127 );
128 };
129
130 IntersectObserver.propTypes = {
131 children: PropTypes.any,
132 routes: PropTypes.arrayOf(
133 PropTypes.shape({
134 label: PropTypes.string.isRequired,
135 route: PropTypes.string.isRequired,
136 })
137 ).isRequired,
138 };
139
140 export default IntersectObserver;
141