@gemx-dev/heatmap-react 3.5.21 → 3.5.23
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/esm/components/HeatmapLayout/ContentHeader.d.ts +4 -0
- package/dist/esm/components/HeatmapLayout/ContentHeader.d.ts.map +1 -0
- package/dist/esm/components/HeatmapLayout/HeatmapLayout.d.ts +7 -0
- package/dist/esm/components/HeatmapLayout/HeatmapLayout.d.ts.map +1 -0
- package/dist/esm/components/HeatmapLayout/LeftSidebar.d.ts +4 -0
- package/dist/esm/components/HeatmapLayout/LeftSidebar.d.ts.map +1 -0
- package/dist/esm/components/HeatmapLayout/ReplayControls.d.ts +2 -0
- package/dist/esm/components/HeatmapLayout/ReplayControls.d.ts.map +1 -0
- package/dist/esm/components/HeatmapLayout/VizDomContainer.d.ts +2 -0
- package/dist/esm/components/HeatmapLayout/VizDomContainer.d.ts.map +1 -0
- package/dist/esm/components/HeatmapLayout/VizDomRenderer.d.ts +6 -0
- package/dist/esm/components/HeatmapLayout/VizDomRenderer.d.ts.map +1 -0
- package/dist/esm/components/HeatmapLayout/WrapperLayout.d.ts +7 -0
- package/dist/esm/components/HeatmapLayout/WrapperLayout.d.ts.map +1 -0
- package/dist/esm/components/HeatmapLayout/WrapperPreview.d.ts +4 -0
- package/dist/esm/components/HeatmapLayout/WrapperPreview.d.ts.map +1 -0
- package/dist/esm/components/HeatmapLayout/index.d.ts +2 -0
- package/dist/esm/components/HeatmapLayout/index.d.ts.map +1 -0
- package/dist/esm/components/VizElement/ClarityVisualizer.d.ts +150 -0
- package/dist/esm/components/VizElement/ClarityVisualizer.d.ts.map +1 -0
- package/dist/esm/components/VizElement/HeatmapElementV2.d.ts +45 -0
- package/dist/esm/components/VizElement/HeatmapElementV2.d.ts.map +1 -0
- package/dist/esm/components/VizElement/PayloadProcessor.d.ts +65 -0
- package/dist/esm/components/VizElement/PayloadProcessor.d.ts.map +1 -0
- package/dist/esm/components/VizElement/VizElementRank.d.ts +74 -0
- package/dist/esm/components/VizElement/VizElementRank.d.ts.map +1 -0
- package/dist/esm/components/VizElement/constants.d.ts +5 -0
- package/dist/esm/components/VizElement/constants.d.ts.map +1 -0
- package/dist/esm/components/VizElement/helpers.d.ts +20 -0
- package/dist/esm/components/VizElement/helpers.d.ts.map +1 -0
- package/dist/esm/components/VizElement/types.d.ts +13 -0
- package/dist/esm/components/VizElement/types.d.ts.map +1 -0
- package/dist/esm/hooks/useHeatmapByMode.d.ts +6 -0
- package/dist/esm/hooks/useHeatmapByMode.d.ts.map +1 -0
- package/dist/esm/hooks/useHeatmapRender.d.ts +6 -0
- package/dist/esm/hooks/useHeatmapRender.d.ts.map +1 -0
- package/dist/esm/hooks/useHeatmapScale.d.ts +28 -0
- package/dist/esm/hooks/useHeatmapScale.d.ts.map +1 -0
- package/dist/esm/hooks/useReplayRender.d.ts +9 -0
- package/dist/esm/hooks/useReplayRender.d.ts.map +1 -0
- package/dist/esm/types/index.d.ts +3 -0
- package/dist/esm/types/index.d.ts.map +1 -0
- package/dist/umd/components/VizElement/VizElementRank.d.ts +75 -0
- package/dist/umd/components/VizElement/VizElementRank.d.ts.map +1 -0
- package/package.json +11 -14
- package/src/components/GraphView.tsx +58 -0
- package/src/components/Layout/ContentHeader.tsx +15 -0
- package/src/components/Layout/HeatmapLayout.tsx +63 -0
- package/src/components/Layout/LeftSidebar.tsx +32 -0
- package/src/components/Layout/WrapperLayout.tsx +18 -0
- package/src/components/Layout/WrapperPreview.tsx +14 -0
- package/src/components/Layout/index.ts +1 -0
- package/src/components/Test.tsx +1106 -0
- package/src/components/VizDom/ReplayControls.tsx +48 -0
- package/src/components/VizDom/VizDomContainer.tsx +25 -0
- package/src/components/VizDom/VizDomRenderer.tsx +87 -0
- package/src/components/VizDom/index.ts +1 -0
- package/src/components/VizElement/ClickedElementOverlay.tsx +65 -0
- package/src/components/VizElement/DefaultRankBadges.tsx +33 -0
- package/src/components/VizElement/ElementCallout.tsx +337 -0
- package/src/components/VizElement/HeatmapElements.tsx +147 -0
- package/src/components/VizElement/HoveredElementOverlay.tsx +46 -0
- package/src/components/VizElement/MissingElementMessage.tsx +32 -0
- package/src/components/VizElement/RankBadge.tsx +25 -0
- package/src/components/VizElement/VizElements.tsx +80 -0
- package/src/components/VizElement/index.ts +1 -0
- package/src/components/VizElement/temp/ClarityVisualizer.ts +764 -0
- package/src/components/VizElement/temp/VizElementRank.tsx +579 -0
- package/src/components/index.tsx +4 -0
- package/src/configs/iframe.ts +15 -0
- package/src/configs/index.ts +2 -0
- package/src/configs/style.ts +9 -0
- package/src/constants/index.ts +4 -0
- package/src/dist/components/GraphView.d.ts +9 -0
- package/src/dist/components/GraphView.d.ts.map +1 -0
- package/src/dist/components/Layout/ContentHeader.d.ts +4 -0
- package/src/dist/components/Layout/ContentHeader.d.ts.map +1 -0
- package/src/dist/components/Layout/HeatmapLayout.d.ts +11 -0
- package/src/dist/components/Layout/HeatmapLayout.d.ts.map +1 -0
- package/src/dist/components/Layout/LeftSidebar.d.ts +4 -0
- package/src/dist/components/Layout/LeftSidebar.d.ts.map +1 -0
- package/src/dist/components/Layout/WrapperLayout.d.ts +8 -0
- package/src/dist/components/Layout/WrapperLayout.d.ts.map +1 -0
- package/src/dist/components/Layout/WrapperPreview.d.ts +4 -0
- package/src/dist/components/Layout/WrapperPreview.d.ts.map +1 -0
- package/src/dist/components/Layout/index.d.ts +2 -0
- package/src/dist/components/Layout/index.d.ts.map +1 -0
- package/src/dist/components/Test.d.ts +121 -0
- package/src/dist/components/Test.d.ts.map +1 -0
- package/src/dist/components/VizDom/ReplayControls.d.ts +2 -0
- package/src/dist/components/VizDom/ReplayControls.d.ts.map +1 -0
- package/src/dist/components/VizDom/VizDomContainer.d.ts +2 -0
- package/src/dist/components/VizDom/VizDomContainer.d.ts.map +1 -0
- package/src/dist/components/VizDom/VizDomRenderer.d.ts +6 -0
- package/src/dist/components/VizDom/VizDomRenderer.d.ts.map +1 -0
- package/src/dist/components/VizDom/index.d.ts +2 -0
- package/src/dist/components/VizDom/index.d.ts.map +1 -0
- package/src/dist/components/VizElement/ClickedElementOverlay.d.ts +17 -0
- package/src/dist/components/VizElement/ClickedElementOverlay.d.ts.map +1 -0
- package/src/dist/components/VizElement/DefaultRankBadges.d.ts +11 -0
- package/src/dist/components/VizElement/DefaultRankBadges.d.ts.map +1 -0
- package/src/dist/components/VizElement/ElementCallout.d.ts +17 -0
- package/src/dist/components/VizElement/ElementCallout.d.ts.map +1 -0
- package/src/dist/components/VizElement/HeatmapElements.d.ts +23 -0
- package/src/dist/components/VizElement/HeatmapElements.d.ts.map +1 -0
- package/src/dist/components/VizElement/HoveredElementOverlay.d.ts +12 -0
- package/src/dist/components/VizElement/HoveredElementOverlay.d.ts.map +1 -0
- package/src/dist/components/VizElement/MissingElementMessage.d.ts +7 -0
- package/src/dist/components/VizElement/MissingElementMessage.d.ts.map +1 -0
- package/src/dist/components/VizElement/RankBadge.d.ts +10 -0
- package/src/dist/components/VizElement/RankBadge.d.ts.map +1 -0
- package/src/dist/components/VizElement/VizElements.d.ts +10 -0
- package/src/dist/components/VizElement/VizElements.d.ts.map +1 -0
- package/src/dist/components/VizElement/index.d.ts +2 -0
- package/src/dist/components/VizElement/index.d.ts.map +1 -0
- package/src/dist/components/VizElement/temp/ClarityVisualizer.d.ts +150 -0
- package/src/dist/components/VizElement/temp/ClarityVisualizer.d.ts.map +1 -0
- package/src/dist/components/VizElement/temp/VizElementRank.d.ts +74 -0
- package/src/dist/components/VizElement/temp/VizElementRank.d.ts.map +1 -0
- package/src/dist/components/index.d.ts +4 -0
- package/src/dist/components/index.d.ts.map +1 -0
- package/src/dist/configs/iframe.d.ts +10 -0
- package/src/dist/configs/iframe.d.ts.map +1 -0
- package/src/dist/configs/index.d.ts +3 -0
- package/src/dist/configs/index.d.ts.map +1 -0
- package/src/dist/configs/style.d.ts +9 -0
- package/src/dist/configs/style.d.ts.map +1 -0
- package/src/dist/constants/index.d.ts +5 -0
- package/src/dist/constants/index.d.ts.map +1 -0
- package/src/dist/helpers/iframe.d.ts +3 -0
- package/src/dist/helpers/iframe.d.ts.map +1 -0
- package/src/dist/helpers/index.d.ts +2 -0
- package/src/dist/helpers/index.d.ts.map +1 -0
- package/src/dist/helpers/viz-elements.d.ts +10 -0
- package/src/dist/helpers/viz-elements.d.ts.map +1 -0
- package/src/dist/hooks/index.d.ts +4 -0
- package/src/dist/hooks/index.d.ts.map +1 -0
- package/src/dist/hooks/vix-elements/index.d.ts +5 -0
- package/src/dist/hooks/vix-elements/index.d.ts.map +1 -0
- package/src/dist/hooks/vix-elements/useClickedElement.d.ts +14 -0
- package/src/dist/hooks/vix-elements/useClickedElement.d.ts.map +1 -0
- package/src/dist/hooks/vix-elements/useHeatmapEffects.d.ts +8 -0
- package/src/dist/hooks/vix-elements/useHeatmapEffects.d.ts.map +1 -0
- package/src/dist/hooks/vix-elements/useHeatmapElementPosition.d.ts +13 -0
- package/src/dist/hooks/vix-elements/useHeatmapElementPosition.d.ts.map +1 -0
- package/src/dist/hooks/vix-elements/useHoveredElement.d.ts +17 -0
- package/src/dist/hooks/vix-elements/useHoveredElement.d.ts.map +1 -0
- package/src/dist/hooks/viz-render/index.d.ts +2 -0
- package/src/dist/hooks/viz-render/index.d.ts.map +1 -0
- package/src/dist/hooks/viz-render/useHeatmapRender.d.ts +8 -0
- package/src/dist/hooks/viz-render/useHeatmapRender.d.ts.map +1 -0
- package/src/dist/hooks/viz-render/useHeatmapVizRender.d.ts +8 -0
- package/src/dist/hooks/viz-render/useHeatmapVizRender.d.ts.map +1 -0
- package/src/dist/hooks/viz-render/useReplayRender.d.ts +11 -0
- package/src/dist/hooks/viz-render/useReplayRender.d.ts.map +1 -0
- package/src/dist/hooks/viz-scale/index.d.ts +2 -0
- package/src/dist/hooks/viz-scale/index.d.ts.map +1 -0
- package/src/dist/hooks/viz-scale/useContainerDimensions.d.ts +10 -0
- package/src/dist/hooks/viz-scale/useContainerDimensions.d.ts.map +1 -0
- package/src/dist/hooks/viz-scale/useContentDimensions.d.ts +11 -0
- package/src/dist/hooks/viz-scale/useContentDimensions.d.ts.map +1 -0
- package/src/dist/hooks/viz-scale/useHeatmapScale.d.ts +19 -0
- package/src/dist/hooks/viz-scale/useHeatmapScale.d.ts.map +1 -0
- package/src/dist/hooks/viz-scale/useIframeHeight.d.ts +10 -0
- package/src/dist/hooks/viz-scale/useIframeHeight.d.ts.map +1 -0
- package/src/dist/hooks/viz-scale/useScaleCalculation.d.ts +10 -0
- package/src/dist/hooks/viz-scale/useScaleCalculation.d.ts.map +1 -0
- package/src/dist/hooks/viz-scale/useScrollSync.d.ts +10 -0
- package/src/dist/hooks/viz-scale/useScrollSync.d.ts.map +1 -0
- package/src/dist/index.d.ts +4 -0
- package/src/dist/index.d.ts.map +1 -0
- package/src/dist/stores/data.d.ts +18 -0
- package/src/dist/stores/data.d.ts.map +1 -0
- package/src/dist/stores/index.d.ts +2 -0
- package/src/dist/stores/index.d.ts.map +1 -0
- package/src/dist/ui/BoxStack/BoxStack.d.ts +56 -0
- package/src/dist/ui/BoxStack/BoxStack.d.ts.map +1 -0
- package/src/dist/ui/BoxStack/index.d.ts +2 -0
- package/src/dist/ui/BoxStack/index.d.ts.map +1 -0
- package/src/dist/ui/index.d.ts +2 -0
- package/src/dist/ui/index.d.ts.map +1 -0
- package/src/dist/utils/device.d.ts +2 -0
- package/src/dist/utils/device.d.ts.map +1 -0
- package/src/dist/utils/retry.d.ts +2 -0
- package/src/dist/utils/retry.d.ts.map +1 -0
- package/src/dist/utils/sort.d.ts +3 -0
- package/src/dist/utils/sort.d.ts.map +1 -0
- package/src/global.d.ts +5 -0
- package/src/helpers/iframe.ts +33 -0
- package/src/helpers/index.ts +1 -0
- package/src/helpers/viz-elements.ts +34 -0
- package/src/hooks/index.ts +3 -0
- package/src/hooks/vix-elements/index.ts +4 -0
- package/src/hooks/vix-elements/useClickedElement.ts +62 -0
- package/src/hooks/vix-elements/useHeatmapEffects.ts +29 -0
- package/src/hooks/vix-elements/useHeatmapElementPosition.ts +66 -0
- package/src/hooks/vix-elements/useHoveredElement.ts +135 -0
- package/src/hooks/viz-render/index.ts +1 -0
- package/src/hooks/viz-render/useHeatmapRender.ts +98 -0
- package/src/hooks/viz-render/useHeatmapVizRender.ts +22 -0
- package/src/hooks/viz-render/useReplayRender.ts +162 -0
- package/src/hooks/viz-scale/index.ts +1 -0
- package/src/hooks/viz-scale/useContainerDimensions.ts +46 -0
- package/src/hooks/viz-scale/useContentDimensions.ts +29 -0
- package/src/hooks/viz-scale/useHeatmapScale.ts +53 -0
- package/src/hooks/viz-scale/useIframeHeight.ts +119 -0
- package/src/hooks/viz-scale/useScaleCalculation.ts +28 -0
- package/src/hooks/viz-scale/useScrollSync.ts +36 -0
- package/src/index.ts +5 -0
- package/src/stores/data.ts +34 -0
- package/src/stores/index.ts +1 -0
- package/src/styles/base.css +1 -0
- package/src/styles/style.css +30 -0
- package/src/types/clarity.d.ts +38 -0
- package/src/types/heatmap.d.ts +3 -0
- package/src/types/index.d.ts +3 -0
- package/src/types/viz-element.d.ts +39 -0
- package/src/ui/BoxStack/BoxStack.tsx +120 -0
- package/src/ui/BoxStack/index.ts +1 -0
- package/src/ui/index.ts +1 -0
- package/src/utils/device.ts +7 -0
- package/src/utils/retry.ts +20 -0
- package/src/utils/sort.ts +5 -0
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
// Hook 3: Iframe Height Observer
|
|
2
|
+
|
|
3
|
+
import { useCallback, useEffect, useRef } from 'react';
|
|
4
|
+
import { useHeatmapDataStore } from '../../stores';
|
|
5
|
+
|
|
6
|
+
interface IUseIframeHeightProps {
|
|
7
|
+
iframeRef: React.RefObject<HTMLIFrameElement | null>;
|
|
8
|
+
contentWidth: number;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
interface IUseIframeHeightResult {
|
|
12
|
+
iframeHeight: number;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export const useIframeHeight = (props: IUseIframeHeightProps): IUseIframeHeightResult => {
|
|
16
|
+
const { iframeRef, contentWidth } = props;
|
|
17
|
+
const iframeHeight = useHeatmapDataStore((state) => state.iframeHeight);
|
|
18
|
+
const setIframeHeight = useHeatmapDataStore((state) => state.setIframeHeight);
|
|
19
|
+
|
|
20
|
+
const resizeObserverRef = useRef<ResizeObserver | null>(null);
|
|
21
|
+
const mutationObserverRef = useRef<MutationObserver | null>(null);
|
|
22
|
+
|
|
23
|
+
const updateIframeHeight = useCallback(() => {
|
|
24
|
+
const iframe = iframeRef.current;
|
|
25
|
+
if (!iframe) return;
|
|
26
|
+
|
|
27
|
+
try {
|
|
28
|
+
const iframeDocument = iframe.contentDocument;
|
|
29
|
+
const iframeBody = iframeDocument?.body;
|
|
30
|
+
if (!iframeBody) return;
|
|
31
|
+
|
|
32
|
+
const bodyHeight = Math.max(
|
|
33
|
+
iframeBody.scrollHeight,
|
|
34
|
+
iframeBody.offsetHeight,
|
|
35
|
+
iframeBody.clientHeight,
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
if (bodyHeight > 0) {
|
|
39
|
+
iframe.height = `${bodyHeight}px`;
|
|
40
|
+
setIframeHeight(bodyHeight);
|
|
41
|
+
}
|
|
42
|
+
} catch (error) {
|
|
43
|
+
console.warn('Cannot measure iframe content:', error);
|
|
44
|
+
}
|
|
45
|
+
}, [iframeRef, setIframeHeight]);
|
|
46
|
+
|
|
47
|
+
// Trigger height update when content width changes
|
|
48
|
+
useEffect(() => {
|
|
49
|
+
if (contentWidth > 0) {
|
|
50
|
+
// Delay to allow iframe content to reflow after width change
|
|
51
|
+
const timeoutId = setTimeout(() => {
|
|
52
|
+
updateIframeHeight();
|
|
53
|
+
}, 100);
|
|
54
|
+
|
|
55
|
+
return () => clearTimeout(timeoutId);
|
|
56
|
+
}
|
|
57
|
+
}, [contentWidth, updateIframeHeight]);
|
|
58
|
+
|
|
59
|
+
useEffect(() => {
|
|
60
|
+
const iframe = iframeRef.current;
|
|
61
|
+
if (!iframe) return;
|
|
62
|
+
|
|
63
|
+
const setupObservers = () => {
|
|
64
|
+
try {
|
|
65
|
+
const iframeDocument = iframe.contentDocument;
|
|
66
|
+
const iframeBody = iframeDocument?.body;
|
|
67
|
+
if (!iframeBody) return;
|
|
68
|
+
|
|
69
|
+
// Cleanup existing observers
|
|
70
|
+
if (resizeObserverRef.current) {
|
|
71
|
+
resizeObserverRef.current.disconnect();
|
|
72
|
+
}
|
|
73
|
+
if (mutationObserverRef.current) {
|
|
74
|
+
mutationObserverRef.current.disconnect();
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// ResizeObserver for size changes
|
|
78
|
+
if (typeof window.ResizeObserver !== 'undefined') {
|
|
79
|
+
resizeObserverRef.current = new ResizeObserver(updateIframeHeight);
|
|
80
|
+
resizeObserverRef.current.observe(iframeBody);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// MutationObserver for DOM changes
|
|
84
|
+
if (typeof window.MutationObserver !== 'undefined') {
|
|
85
|
+
mutationObserverRef.current = new MutationObserver(updateIframeHeight);
|
|
86
|
+
mutationObserverRef.current.observe(iframeBody, {
|
|
87
|
+
childList: true,
|
|
88
|
+
subtree: true,
|
|
89
|
+
attributes: true,
|
|
90
|
+
characterData: true,
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// Initial measurement
|
|
95
|
+
updateIframeHeight();
|
|
96
|
+
} catch (error) {
|
|
97
|
+
console.warn('Cannot access iframe content:', error);
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
if (iframe.contentDocument?.readyState === 'complete') {
|
|
102
|
+
setupObservers();
|
|
103
|
+
} else {
|
|
104
|
+
iframe.addEventListener('load', setupObservers, { once: true });
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return () => {
|
|
108
|
+
if (resizeObserverRef.current) {
|
|
109
|
+
resizeObserverRef.current.disconnect();
|
|
110
|
+
}
|
|
111
|
+
if (mutationObserverRef.current) {
|
|
112
|
+
mutationObserverRef.current.disconnect();
|
|
113
|
+
}
|
|
114
|
+
iframe.removeEventListener('load', setupObservers);
|
|
115
|
+
};
|
|
116
|
+
}, [iframeRef, updateIframeHeight]);
|
|
117
|
+
|
|
118
|
+
return { iframeHeight };
|
|
119
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
2
|
+
import { HEATMAP_CONFIG } from '../../configs';
|
|
3
|
+
|
|
4
|
+
interface IUseScaleCalculationProps {
|
|
5
|
+
containerWidth: number;
|
|
6
|
+
contentWidth: number;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
interface IUseScaleCalculationResult {
|
|
10
|
+
scale: number;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const useScaleCalculation = (
|
|
14
|
+
props: IUseScaleCalculationProps,
|
|
15
|
+
): IUseScaleCalculationResult => {
|
|
16
|
+
const { containerWidth, contentWidth } = props;
|
|
17
|
+
const [scale, setScale] = useState(1);
|
|
18
|
+
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
if (containerWidth > 0 && contentWidth > 0) {
|
|
21
|
+
const availableWidth = containerWidth - HEATMAP_CONFIG['paddingBlock'] * 2;
|
|
22
|
+
const calculatedScale = Math.min(availableWidth / contentWidth, 1);
|
|
23
|
+
setScale(calculatedScale);
|
|
24
|
+
}
|
|
25
|
+
}, [containerWidth, contentWidth]);
|
|
26
|
+
|
|
27
|
+
return { scale };
|
|
28
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { useCallback } from 'react';
|
|
2
|
+
|
|
3
|
+
interface IUseScrollSyncProps {
|
|
4
|
+
iframeRef: React.RefObject<HTMLIFrameElement | null>;
|
|
5
|
+
scale: number;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
interface IUseScrollSyncResult {
|
|
9
|
+
handleScroll: (scrollTop: number) => void;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const useScrollSync = (props: IUseScrollSyncProps): IUseScrollSyncResult => {
|
|
13
|
+
const { iframeRef, scale } = props;
|
|
14
|
+
|
|
15
|
+
const handleScroll = useCallback(
|
|
16
|
+
(scrollTop: number) => {
|
|
17
|
+
const iframe = iframeRef.current;
|
|
18
|
+
if (!iframe || scale <= 0) return;
|
|
19
|
+
|
|
20
|
+
try {
|
|
21
|
+
const iframeWindow = iframe.contentWindow;
|
|
22
|
+
const iframeDocument = iframe.contentDocument;
|
|
23
|
+
|
|
24
|
+
if (iframeWindow && iframeDocument) {
|
|
25
|
+
const iframeScrollTop = scrollTop / scale;
|
|
26
|
+
iframe.style.top = `${iframeScrollTop}px`;
|
|
27
|
+
}
|
|
28
|
+
} catch (error) {
|
|
29
|
+
console.warn('Cannot sync scroll to iframe:', error);
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
[iframeRef, scale],
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
return { handleScroll };
|
|
36
|
+
};
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { create } from 'zustand';
|
|
2
|
+
import { ClickMapPoint, DecodedPayload, IHeatmapConfig } from '../types';
|
|
3
|
+
|
|
4
|
+
export interface IHeatmapState {
|
|
5
|
+
hideSidebar: boolean;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface IHeatmapDataStore {
|
|
9
|
+
data?: DecodedPayload[];
|
|
10
|
+
clickmap?: ClickMapPoint[];
|
|
11
|
+
config?: IHeatmapConfig;
|
|
12
|
+
iframeHeight: number;
|
|
13
|
+
state: IHeatmapState;
|
|
14
|
+
setState: (state: IHeatmapState) => void;
|
|
15
|
+
setData: (data: DecodedPayload[]) => void;
|
|
16
|
+
setClickmap: (clickmap: ClickMapPoint[]) => void;
|
|
17
|
+
setConfig: (config: IHeatmapConfig) => void;
|
|
18
|
+
setIframeHeight: (iframeHeight: number) => void;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export const useHeatmapDataStore = create<IHeatmapDataStore>()((set, get) => ({
|
|
22
|
+
data: undefined,
|
|
23
|
+
clickmap: undefined,
|
|
24
|
+
config: undefined,
|
|
25
|
+
iframeHeight: 0,
|
|
26
|
+
state: {
|
|
27
|
+
hideSidebar: false,
|
|
28
|
+
},
|
|
29
|
+
setData: (data) => set({ data }),
|
|
30
|
+
setClickmap: (clickmap) => set({ clickmap }),
|
|
31
|
+
setState: (state) => set({ state: { ...get().state, ...state } }),
|
|
32
|
+
setConfig: (config) => set({ config: { ...get().config, ...config } }),
|
|
33
|
+
setIframeHeight: (iframeHeight) => set({ iframeHeight }),
|
|
34
|
+
}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './data';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@import '@xyflow/react/dist/style.css';
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
.gx-hm-wrapper iframe {
|
|
2
|
+
/* position: relative; */
|
|
3
|
+
display: block;
|
|
4
|
+
border: 1px solid #CCC;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.gx-hm-wrapper .gx-hm-elements {
|
|
8
|
+
position: absolute;
|
|
9
|
+
z-index: 2;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.rankBadge {
|
|
13
|
+
position: absolute;
|
|
14
|
+
width: 36px;
|
|
15
|
+
height: 36px;
|
|
16
|
+
background: #0078D4;
|
|
17
|
+
color: white;
|
|
18
|
+
border: 1px solid #FFFFFF;
|
|
19
|
+
border-radius: 32px;
|
|
20
|
+
text-align: center;
|
|
21
|
+
line-height: 32px;
|
|
22
|
+
filter: drop-shadow(0px 1.2px 3.6px rgba(0, 0, 0, 0.1));
|
|
23
|
+
cursor: default;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.heatmapElement {
|
|
27
|
+
position: absolute;
|
|
28
|
+
border: 1px solid white;
|
|
29
|
+
outline: 1px solid #0078D4;
|
|
30
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { Data, MergedPayload } from '@gemx-dev/clarity-visualize';
|
|
2
|
+
|
|
3
|
+
export interface HeatmapProject {
|
|
4
|
+
id: string;
|
|
5
|
+
name: string;
|
|
6
|
+
domain: string;
|
|
7
|
+
apiKey: string;
|
|
8
|
+
_count?: {
|
|
9
|
+
sessions: number;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface SessionData {
|
|
14
|
+
id: string;
|
|
15
|
+
projectId: string;
|
|
16
|
+
userId?: string;
|
|
17
|
+
startTime: Date;
|
|
18
|
+
endTime?: Date;
|
|
19
|
+
pageUrl: string;
|
|
20
|
+
userAgent?: string;
|
|
21
|
+
screenWidth?: number;
|
|
22
|
+
screenHeight?: number;
|
|
23
|
+
deviceType?: string;
|
|
24
|
+
browser?: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface ClickMapPoint {
|
|
28
|
+
hash: string;
|
|
29
|
+
selector: string;
|
|
30
|
+
totalclicks: number;
|
|
31
|
+
x: number[];
|
|
32
|
+
y: number[];
|
|
33
|
+
clicks: number[];
|
|
34
|
+
points: number;
|
|
35
|
+
}
|
|
36
|
+
export type DecodedPayload = Data.DecodedPayload;
|
|
37
|
+
export type DecodedEvents = MergedPayload['events'];
|
|
38
|
+
export type DecodedEvent = DecodedEvents[number];
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export interface ElementRect {
|
|
2
|
+
top: number;
|
|
3
|
+
left: number;
|
|
4
|
+
width: number;
|
|
5
|
+
height: number;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface ElementInfo extends ElementRect {
|
|
9
|
+
hash: string;
|
|
10
|
+
clicks: number;
|
|
11
|
+
rank: number;
|
|
12
|
+
selector: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface HeatmapElement {
|
|
16
|
+
hash: string;
|
|
17
|
+
selector?: string;
|
|
18
|
+
totalclicks?: number;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface ElementMapInfo {
|
|
22
|
+
[key: string]: {
|
|
23
|
+
totalclicks: number;
|
|
24
|
+
selector?: string;
|
|
25
|
+
hash: string;
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface HeatmapInfo {
|
|
30
|
+
sortedElements?: HeatmapElement[];
|
|
31
|
+
elementMapInfo?: ElementMapInfo;
|
|
32
|
+
totalClicks?: number;
|
|
33
|
+
width?: number;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Web Visualizer interface - simplified for web
|
|
37
|
+
export interface WebVisualizer {
|
|
38
|
+
get: (hash: string) => HTMLElement | null;
|
|
39
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
|
|
3
|
+
type Style = Omit<
|
|
4
|
+
React.CSSProperties,
|
|
5
|
+
| 'display'
|
|
6
|
+
| 'flexDirection'
|
|
7
|
+
| 'overflow'
|
|
8
|
+
| 'position'
|
|
9
|
+
| 'flex'
|
|
10
|
+
| 'justifyContent'
|
|
11
|
+
| 'alignItems'
|
|
12
|
+
| 'flexWrap'
|
|
13
|
+
| 'gap'
|
|
14
|
+
| 'height'
|
|
15
|
+
>;
|
|
16
|
+
|
|
17
|
+
type FlexDirection = 'row' | 'column';
|
|
18
|
+
type Overflow = 'hidden' | 'visible' | 'scroll' | 'auto';
|
|
19
|
+
type Position = 'relative' | 'absolute' | 'fixed' | 'sticky';
|
|
20
|
+
type Flex = `${number}` | 'auto' | 'initial' | 'none' | string;
|
|
21
|
+
type JustifyContent =
|
|
22
|
+
| 'flex-start'
|
|
23
|
+
| 'flex-end'
|
|
24
|
+
| 'center'
|
|
25
|
+
| 'space-between'
|
|
26
|
+
| 'space-around'
|
|
27
|
+
| 'space-evenly';
|
|
28
|
+
type AlignItems = 'flex-start' | 'flex-end' | 'center' | 'stretch' | 'baseline';
|
|
29
|
+
type FlexWrap = 'nowrap' | 'wrap' | 'wrap-reverse';
|
|
30
|
+
type Gap = number | string;
|
|
31
|
+
type Height = number | string;
|
|
32
|
+
|
|
33
|
+
export interface BoxStackProps {
|
|
34
|
+
id?: string;
|
|
35
|
+
children: React.ReactNode;
|
|
36
|
+
style?: Style;
|
|
37
|
+
/**
|
|
38
|
+
* The flex of the flex container.
|
|
39
|
+
* @default 'none'
|
|
40
|
+
*/
|
|
41
|
+
flex?: Flex;
|
|
42
|
+
/**
|
|
43
|
+
* The gap between the children.
|
|
44
|
+
* @default 0
|
|
45
|
+
*/
|
|
46
|
+
gap?: Gap;
|
|
47
|
+
/**
|
|
48
|
+
* The justify content of the flex container.
|
|
49
|
+
* @default undefined
|
|
50
|
+
*/
|
|
51
|
+
justifyContent?: JustifyContent;
|
|
52
|
+
/**
|
|
53
|
+
* The align items of the flex container.
|
|
54
|
+
* @default undefined
|
|
55
|
+
*/
|
|
56
|
+
alignItems?: AlignItems;
|
|
57
|
+
/**
|
|
58
|
+
* The direction of the flex container.
|
|
59
|
+
*/
|
|
60
|
+
flexDirection: FlexDirection;
|
|
61
|
+
/**
|
|
62
|
+
* The overflow of the flex container.
|
|
63
|
+
* @default 'hidden'
|
|
64
|
+
*/
|
|
65
|
+
overflow?: Overflow;
|
|
66
|
+
/**
|
|
67
|
+
* The position of the flex container.
|
|
68
|
+
* @default 'relative'
|
|
69
|
+
*/
|
|
70
|
+
position?: Position;
|
|
71
|
+
/**
|
|
72
|
+
* The height of the flex container.
|
|
73
|
+
* @default 'auto'
|
|
74
|
+
*/
|
|
75
|
+
height?: Height;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export const BoxStack: React.FC<BoxStackProps> = ({ children, ...props }) => {
|
|
79
|
+
const id = props.id;
|
|
80
|
+
const flexDirection = props.flexDirection;
|
|
81
|
+
const overflow = props.overflow || 'hidden';
|
|
82
|
+
const position = props.position || 'relative';
|
|
83
|
+
const flex = props.flex || 'none';
|
|
84
|
+
const justifyContent = props.justifyContent;
|
|
85
|
+
const alignItems = props.alignItems;
|
|
86
|
+
const style = props.style || {};
|
|
87
|
+
const gap = props.gap || 0;
|
|
88
|
+
const height = props.height || 'auto';
|
|
89
|
+
|
|
90
|
+
const styleGap = useMemo(() => {
|
|
91
|
+
switch (flexDirection) {
|
|
92
|
+
case 'row':
|
|
93
|
+
return {
|
|
94
|
+
columnGap: gap,
|
|
95
|
+
};
|
|
96
|
+
case 'column':
|
|
97
|
+
return {
|
|
98
|
+
rowGap: gap,
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
}, [gap, flexDirection]);
|
|
102
|
+
|
|
103
|
+
const styleProps = {
|
|
104
|
+
display: 'flex',
|
|
105
|
+
flexDirection,
|
|
106
|
+
overflow,
|
|
107
|
+
position,
|
|
108
|
+
flex,
|
|
109
|
+
justifyContent,
|
|
110
|
+
alignItems,
|
|
111
|
+
height,
|
|
112
|
+
...styleGap,
|
|
113
|
+
...style,
|
|
114
|
+
};
|
|
115
|
+
return (
|
|
116
|
+
<div id={id} style={styleProps}>
|
|
117
|
+
{children}
|
|
118
|
+
</div>
|
|
119
|
+
);
|
|
120
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './BoxStack';
|
package/src/ui/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './BoxStack';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export function isMobileDevice(userAgent: string): boolean {
|
|
2
|
+
if (!userAgent) return false;
|
|
3
|
+
|
|
4
|
+
return /android|webos|iphone|ipad|ipod|blackberry|windows phone|opera mini|iemobile|mobile|silk|fennec|bada|tizen|symbian|nokia|palmsource|meego|sailfish|kindle|playbook|bb10|rim/i.test(
|
|
5
|
+
userAgent,
|
|
6
|
+
);
|
|
7
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
function sleep(ms: number) {
|
|
2
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
export async function retry(
|
|
6
|
+
fn: () => Promise<any> | any,
|
|
7
|
+
retries: number,
|
|
8
|
+
delay: number,
|
|
9
|
+
): Promise<any> {
|
|
10
|
+
for (let i = 0; i < retries; i++) {
|
|
11
|
+
try {
|
|
12
|
+
await fn();
|
|
13
|
+
return; // If the function succeeds, exit the loop
|
|
14
|
+
} catch (error) {
|
|
15
|
+
if (i === retries - 1) return;
|
|
16
|
+
await sleep(delay);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
throw new Error('Max retries reached');
|
|
20
|
+
}
|