@gemx-dev/heatmap-react 3.5.45 → 3.5.46
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/Layout/ContentHeader.d.ts +4 -0
- package/dist/esm/components/Layout/ContentHeader.d.ts.map +1 -0
- package/dist/esm/components/Layout/HeatmapLayout.d.ts +2 -3
- package/dist/esm/components/Layout/HeatmapLayout.d.ts.map +1 -1
- package/dist/esm/components/Layout/VizMode.d.ts +2 -0
- package/dist/esm/components/Layout/VizMode.d.ts.map +1 -0
- package/dist/esm/components/Test.d.ts +121 -0
- package/dist/esm/components/Test.d.ts.map +1 -0
- package/dist/esm/components/VizDom/VizDomContainer.d.ts +6 -0
- package/dist/esm/components/VizDom/VizDomContainer.d.ts.map +1 -0
- package/dist/esm/components/VizDom/VizDomRenderer.d.ts.map +1 -1
- package/dist/esm/components/VizElement/ClickedElementOverlay.d.ts +17 -0
- package/dist/esm/components/VizElement/ClickedElementOverlay.d.ts.map +1 -0
- package/dist/esm/components/VizElement/HeatmapElements.d.ts +2 -2
- package/dist/esm/components/VizElement/HeatmapElements.d.ts.map +1 -1
- package/dist/esm/components/VizElement/HoveredElementOverlay.d.ts +12 -0
- package/dist/esm/components/VizElement/HoveredElementOverlay.d.ts.map +1 -0
- package/dist/esm/components/VizElement/MissingElementMessage.d.ts +7 -0
- package/dist/esm/components/VizElement/MissingElementMessage.d.ts.map +1 -0
- package/dist/esm/components/VizElement/VizElements.d.ts.map +1 -1
- package/dist/esm/components/VizElement/temp/ClarityVisualizer.d.ts +150 -0
- package/dist/esm/components/VizElement/temp/ClarityVisualizer.d.ts.map +1 -0
- package/dist/esm/components/VizElement/temp/VizElementRank.d.ts +74 -0
- package/dist/esm/components/VizElement/temp/VizElementRank.d.ts.map +1 -0
- package/dist/esm/components/VizLive/VizLive.d.ts +2 -0
- package/dist/esm/components/VizLive/VizLive.d.ts.map +1 -0
- package/dist/esm/components/VizLive/VizLiveHeatmap.d.ts.map +1 -1
- package/dist/esm/components/VizLive/VizLiveRenderer.d.ts.map +1 -1
- package/dist/esm/configs/style.d.ts +0 -2
- package/dist/esm/configs/style.d.ts.map +1 -1
- package/dist/esm/helpers/elm-getter.d.ts +2 -2
- package/dist/esm/helpers/elm-getter.d.ts.map +1 -1
- package/dist/esm/helpers/index.d.ts +2 -2
- package/dist/esm/helpers/index.d.ts.map +1 -1
- package/dist/esm/helpers/viewport-fixer.d.ts +13 -0
- package/dist/esm/helpers/viewport-fixer.d.ts.map +1 -0
- package/dist/esm/helpers/viewport-replacer.d.ts +26 -0
- package/dist/esm/helpers/viewport-replacer.d.ts.map +1 -0
- package/dist/esm/hooks/index.d.ts +1 -2
- package/dist/esm/hooks/index.d.ts.map +1 -1
- package/dist/esm/hooks/register/useRegisterData.d.ts +2 -2
- package/dist/esm/hooks/register/useRegisterData.d.ts.map +1 -1
- package/dist/esm/hooks/register/useRegisterHeatmap.d.ts +2 -7
- package/dist/esm/hooks/register/useRegisterHeatmap.d.ts.map +1 -1
- package/dist/esm/hooks/{viz-elements → vix-elements}/index.d.ts.map +1 -1
- package/dist/esm/hooks/{viz-elements → vix-elements}/useClickedElement.d.ts.map +1 -1
- package/dist/esm/hooks/{viz-elements → vix-elements}/useElementCalloutVisible.d.ts.map +1 -1
- package/dist/esm/hooks/{viz-elements → vix-elements}/useHeatmapEffects.d.ts.map +1 -1
- package/dist/esm/hooks/{viz-elements → vix-elements}/useHeatmapElementPosition.d.ts.map +1 -1
- package/dist/esm/hooks/{viz-elements → vix-elements}/useHoveredElement.d.ts +0 -4
- package/dist/esm/hooks/vix-elements/useHoveredElement.d.ts.map +1 -0
- package/dist/esm/hooks/viz-canvas/index.d.ts +1 -1
- package/dist/esm/hooks/viz-canvas/index.d.ts.map +1 -1
- package/dist/esm/hooks/viz-canvas/useClickmap.d.ts +1 -3
- package/dist/esm/hooks/viz-canvas/useClickmap.d.ts.map +1 -1
- package/dist/esm/hooks/viz-canvas/useHeatmapVizCanvas.d.ts +2 -0
- package/dist/esm/hooks/viz-canvas/useHeatmapVizCanvas.d.ts.map +1 -0
- package/dist/esm/hooks/viz-canvas/useScrollmap.d.ts +1 -3
- package/dist/esm/hooks/viz-canvas/useScrollmap.d.ts.map +1 -1
- package/dist/esm/hooks/viz-live/index.d.ts +1 -1
- package/dist/{umd/hooks/viz-live/useVizLiveIframeMsg.d.ts → esm/hooks/viz-live/useIframeMessage.d.ts} +10 -2
- package/dist/esm/hooks/viz-live/useIframeMessage.d.ts.map +1 -0
- package/dist/esm/hooks/viz-render/useHeatmapRender.d.ts.map +1 -1
- package/dist/esm/hooks/viz-scale/useContainerDimensions.d.ts.map +1 -1
- package/dist/esm/hooks/viz-scale/useHeatmapScale.d.ts +1 -1
- package/dist/esm/hooks/viz-scale/useHeatmapScale.d.ts.map +1 -1
- package/dist/esm/hooks/viz-scale/useIframeHeight.d.ts +10 -0
- package/dist/esm/hooks/viz-scale/useIframeHeight.d.ts.map +1 -0
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +210 -1181
- package/dist/esm/index.mjs +210 -1181
- package/dist/esm/stores/config.d.ts +1 -5
- package/dist/esm/stores/config.d.ts.map +1 -1
- package/dist/esm/stores/data.d.ts +3 -5
- package/dist/esm/stores/data.d.ts.map +1 -1
- package/dist/esm/stores/index.d.ts +0 -2
- package/dist/esm/stores/index.d.ts.map +1 -1
- package/dist/esm/stores/interaction.d.ts.map +1 -1
- package/dist/esm/stores/mode-live.d.ts +0 -4
- package/dist/esm/stores/mode-live.d.ts.map +1 -1
- package/dist/esm/stores/viz.d.ts +4 -0
- package/dist/esm/stores/viz.d.ts.map +1 -1
- package/dist/esm/types/clarity.d.ts +0 -5
- package/dist/esm/types/clarity.d.ts.map +1 -1
- package/dist/esm/types/heatmap.d.ts +0 -13
- package/dist/esm/types/heatmap.d.ts.map +1 -1
- package/dist/esm/types/index.d.ts +1 -4
- package/dist/esm/types/index.d.ts.map +1 -1
- package/dist/esm/types/viewport-fixer.d.ts +31 -0
- package/dist/esm/types/viewport-fixer.d.ts.map +1 -0
- package/dist/esm/types/viz-element.d.ts +6 -0
- package/dist/esm/types/viz-element.d.ts.map +1 -1
- package/dist/umd/components/Layout/ContentHeader.d.ts +4 -0
- package/dist/umd/components/Layout/ContentHeader.d.ts.map +1 -0
- package/dist/umd/components/Layout/HeatmapLayout.d.ts +2 -3
- package/dist/umd/components/Layout/HeatmapLayout.d.ts.map +1 -1
- package/dist/umd/components/Test.d.ts +121 -0
- package/dist/umd/components/Test.d.ts.map +1 -0
- package/dist/umd/components/VizDom/VizDomContainer.d.ts +2 -0
- package/dist/umd/components/VizDom/VizDomContainer.d.ts.map +1 -0
- package/dist/umd/components/VizDom/VizDomRenderer.d.ts.map +1 -1
- package/dist/umd/components/VizElement/ClickedElementOverlay.d.ts +17 -0
- package/dist/umd/components/VizElement/ClickedElementOverlay.d.ts.map +1 -0
- package/dist/umd/components/VizElement/HeatmapElements.d.ts +2 -2
- package/dist/umd/components/VizElement/HeatmapElements.d.ts.map +1 -1
- package/dist/umd/components/VizElement/HoveredElementOverlay.d.ts +12 -0
- package/dist/umd/components/VizElement/HoveredElementOverlay.d.ts.map +1 -0
- package/dist/umd/components/VizElement/MissingElementMessage.d.ts +7 -0
- package/dist/umd/components/VizElement/MissingElementMessage.d.ts.map +1 -0
- package/dist/umd/components/VizElement/VizElements.d.ts.map +1 -1
- package/dist/umd/components/VizElement/temp/ClarityVisualizer.d.ts +150 -0
- package/dist/umd/components/VizElement/temp/ClarityVisualizer.d.ts.map +1 -0
- package/dist/umd/components/VizElement/temp/VizElementRank.d.ts +74 -0
- package/dist/umd/components/VizElement/temp/VizElementRank.d.ts.map +1 -0
- package/dist/umd/components/VizLive/VizLiveHeatmap.d.ts.map +1 -1
- package/dist/umd/components/VizLive/VizLiveRenderer.d.ts.map +1 -1
- package/dist/umd/configs/style.d.ts +0 -2
- package/dist/umd/configs/style.d.ts.map +1 -1
- package/dist/umd/helpers/elm-getter.d.ts +2 -2
- package/dist/umd/helpers/elm-getter.d.ts.map +1 -1
- package/dist/umd/helpers/index.d.ts +2 -2
- package/dist/umd/helpers/index.d.ts.map +1 -1
- package/dist/umd/helpers/viewport-fixer.d.ts +13 -0
- package/dist/umd/helpers/viewport-fixer.d.ts.map +1 -0
- package/dist/umd/helpers/viewport-replacer.d.ts +26 -0
- package/dist/umd/helpers/viewport-replacer.d.ts.map +1 -0
- package/dist/umd/hooks/index.d.ts +1 -2
- package/dist/umd/hooks/index.d.ts.map +1 -1
- package/dist/umd/hooks/register/useRegisterData.d.ts +2 -2
- package/dist/umd/hooks/register/useRegisterData.d.ts.map +1 -1
- package/dist/umd/hooks/register/useRegisterHeatmap.d.ts +2 -7
- package/dist/umd/hooks/register/useRegisterHeatmap.d.ts.map +1 -1
- package/dist/umd/hooks/{viz-elements → vix-elements}/index.d.ts.map +1 -1
- package/dist/umd/hooks/{viz-elements → vix-elements}/useClickedElement.d.ts.map +1 -1
- package/dist/umd/hooks/{viz-elements → vix-elements}/useElementCalloutVisible.d.ts.map +1 -1
- package/dist/umd/hooks/{viz-elements → vix-elements}/useHeatmapEffects.d.ts.map +1 -1
- package/dist/umd/hooks/{viz-elements → vix-elements}/useHeatmapElementPosition.d.ts.map +1 -1
- package/dist/umd/hooks/{viz-elements → vix-elements}/useHoveredElement.d.ts +0 -4
- package/dist/umd/hooks/vix-elements/useHoveredElement.d.ts.map +1 -0
- package/dist/umd/hooks/viz-canvas/index.d.ts +1 -1
- package/dist/umd/hooks/viz-canvas/index.d.ts.map +1 -1
- package/dist/umd/hooks/viz-canvas/useClickmap.d.ts +1 -3
- package/dist/umd/hooks/viz-canvas/useClickmap.d.ts.map +1 -1
- package/dist/umd/hooks/viz-canvas/useHeatmapVizCanvas.d.ts +2 -0
- package/dist/umd/hooks/viz-canvas/useHeatmapVizCanvas.d.ts.map +1 -0
- package/dist/umd/hooks/viz-canvas/useScrollmap.d.ts +1 -3
- package/dist/umd/hooks/viz-canvas/useScrollmap.d.ts.map +1 -1
- package/dist/umd/hooks/viz-live/index.d.ts +1 -1
- package/dist/{esm/hooks/viz-live/useVizLiveIframeMsg.d.ts → umd/hooks/viz-live/useIframeMessage.d.ts} +10 -2
- package/dist/umd/hooks/viz-live/useIframeMessage.d.ts.map +1 -0
- package/dist/umd/hooks/viz-render/useHeatmapRender.d.ts.map +1 -1
- package/dist/umd/hooks/viz-scale/useContainerDimensions.d.ts.map +1 -1
- package/dist/umd/hooks/viz-scale/useHeatmapScale.d.ts +1 -1
- package/dist/umd/hooks/viz-scale/useHeatmapScale.d.ts.map +1 -1
- package/dist/umd/hooks/viz-scale/useIframeHeight.d.ts +10 -0
- package/dist/umd/hooks/viz-scale/useIframeHeight.d.ts.map +1 -0
- package/dist/umd/index.d.ts +1 -1
- package/dist/umd/index.d.ts.map +1 -1
- package/dist/umd/index.js +2 -2
- package/dist/umd/stores/config.d.ts +1 -5
- package/dist/umd/stores/config.d.ts.map +1 -1
- package/dist/umd/stores/data.d.ts +3 -5
- package/dist/umd/stores/data.d.ts.map +1 -1
- package/dist/umd/stores/index.d.ts +0 -2
- package/dist/umd/stores/index.d.ts.map +1 -1
- package/dist/umd/stores/interaction.d.ts.map +1 -1
- package/dist/umd/stores/mode-live.d.ts +0 -4
- package/dist/umd/stores/mode-live.d.ts.map +1 -1
- package/dist/umd/stores/viz.d.ts +4 -0
- package/dist/umd/stores/viz.d.ts.map +1 -1
- package/dist/umd/types/clarity.d.ts +0 -5
- package/dist/umd/types/clarity.d.ts.map +1 -1
- package/dist/umd/types/heatmap.d.ts +0 -13
- package/dist/umd/types/heatmap.d.ts.map +1 -1
- package/dist/umd/types/index.d.ts +1 -4
- package/dist/umd/types/index.d.ts.map +1 -1
- package/dist/umd/types/viewport-fixer.d.ts +31 -0
- package/dist/umd/types/viewport-fixer.d.ts.map +1 -0
- package/dist/umd/types/viz-element.d.ts +6 -0
- package/dist/umd/types/viz-element.d.ts.map +1 -1
- package/package.json +13 -15
- package/src/components/GraphView.tsx +58 -0
- package/src/components/Layout/ContentMetricBar.tsx +23 -0
- package/src/components/Layout/ContentToolbar.tsx +22 -0
- package/src/components/Layout/ContentTopBar.tsx +24 -0
- package/src/components/Layout/ContentVizByMode.tsx +14 -0
- package/src/components/Layout/HeatmapLayout.tsx +60 -0
- package/src/components/Layout/LeftSidebar.tsx +44 -0
- package/src/components/Layout/WrapperLayout.tsx +12 -0
- package/src/components/Layout/WrapperPreview.tsx +24 -0
- package/src/components/Layout/index.ts +1 -0
- package/src/components/VizDom/ReplayControls.tsx +48 -0
- package/src/components/VizDom/VizContainer.tsx +40 -0
- package/src/components/VizDom/VizDomHeatmap.tsx +28 -0
- package/src/components/VizDom/VizDomRenderer.tsx +82 -0
- package/src/components/VizDom/VizLoading.tsx +8 -0
- package/src/components/VizDom/WrapperVisual.tsx +73 -0
- package/src/components/VizDom/index.ts +5 -0
- package/src/components/VizElement/DefaultRankBadges.tsx +36 -0
- package/src/components/VizElement/ElementCallout.tsx +82 -0
- package/src/components/VizElement/ElementMissing.tsx +35 -0
- package/src/components/VizElement/ElementOverlay.tsx +66 -0
- package/src/components/VizElement/HeatmapElements.tsx +127 -0
- package/src/components/VizElement/HeatmapExample.tsx +70 -0
- package/src/components/VizElement/RankBadge.tsx +25 -0
- package/src/components/VizElement/VizElements.tsx +57 -0
- package/src/components/VizElement/index.ts +1 -0
- package/src/components/VizLive/VizLiveHeatmap.tsx +27 -0
- package/src/components/VizLive/VizLiveRenderer.tsx +47 -0
- package/src/components/VizLive/index.ts +1 -0
- package/src/components/VizScrollmap/AverageFoldLine.tsx +57 -0
- package/src/components/VizScrollmap/HoverZones.tsx +58 -0
- package/src/components/VizScrollmap/MetricRow.tsx +0 -0
- package/src/components/VizScrollmap/ScrollMapMinimap.tsx +64 -0
- package/src/components/VizScrollmap/ScrollMapOverlay.tsx +79 -0
- package/src/components/VizScrollmap/ScrollZoneHoverArea.tsx +35 -0
- package/src/components/VizScrollmap/ScrollZoneTooltip.tsx +146 -0
- package/src/components/VizScrollmap/ScrollmapMarker.tsx +106 -0
- package/src/components/VizScrollmap/VizScrollMap.tsx +36 -0
- package/{dist/esm/components/VizScrollmap/index.d.ts → src/components/VizScrollmap/index.ts} +0 -1
- package/src/components/VizScrollmapV2/ScrollmapOverlay.css +94 -0
- package/src/components/VizScrollmapV2/ScrollmapOverlayV2.tsx +130 -0
- package/{dist/esm/components/VizScrollmapV2/index.d.ts → src/components/VizScrollmapV2/index.ts} +0 -1
- package/src/components/VizScrollmapV2/scrollmap.types.ts +21 -0
- package/src/components/VizScrollmapV2/useScrollmapOverlay.ts +187 -0
- package/src/components/index.tsx +2 -0
- package/src/configs/iframe.ts +15 -0
- package/src/configs/index.ts +2 -0
- package/src/configs/style.ts +21 -0
- package/src/constants/index.ts +4 -0
- package/src/global.d.ts +5 -0
- package/src/helpers/elm-callout.ts +347 -0
- package/src/helpers/elm-getter.ts +70 -0
- package/src/helpers/iframe-helper/fixer.ts +100 -0
- package/src/helpers/iframe-helper/index.ts +1 -0
- package/src/helpers/iframe-helper/init.ts +56 -0
- package/src/helpers/iframe-helper/navigation-blocker-v2.ts +371 -0
- package/src/helpers/iframe-helper/navigation-blocker.ts +367 -0
- package/src/helpers/iframe-helper/style-replacer.ts +231 -0
- package/src/helpers/iframe.ts +42 -0
- package/src/helpers/index.ts +8 -0
- package/src/helpers/viz-canvas/area-clustering.ts +234 -0
- package/src/helpers/viz-canvas/area-overlay-manager-v2.ts +176 -0
- package/src/helpers/viz-canvas/area-overlay-manager.ts +273 -0
- package/src/helpers/viz-canvas/hierarchical-area-clustering.ts +420 -0
- package/{dist/esm/helpers/viz-canvas/index.d.ts → src/helpers/viz-canvas/index.ts} +0 -1
- package/src/helpers/viz-elements.ts +43 -0
- package/src/hooks/index.ts +8 -0
- package/src/hooks/register/index.ts +4 -0
- package/src/hooks/register/useRegisterConfig.ts +17 -0
- package/src/hooks/register/useRegisterControl.ts +13 -0
- package/src/hooks/register/useRegisterData.ts +36 -0
- package/src/hooks/register/useRegisterHeatmap.ts +38 -0
- package/src/hooks/viz-area/useAreaHeatmap.ts +336 -0
- package/src/hooks/viz-area/useAreaHeatmapManager.ts +692 -0
- package/src/hooks/viz-canvas/index.ts +1 -0
- package/src/hooks/viz-canvas/useAreamap.ts +162 -0
- package/src/hooks/viz-canvas/useClickmap.ts +24 -0
- package/src/hooks/viz-canvas/useHeatmapCanvas.ts +27 -0
- package/src/hooks/viz-canvas/useScrollmap.ts +22 -0
- package/src/hooks/viz-elements/index.ts +5 -0
- package/src/hooks/viz-elements/useClickedElement.ts +86 -0
- package/src/hooks/viz-elements/useElementCalloutVisible.ts +45 -0
- package/src/hooks/viz-elements/useHeatmapEffects.ts +30 -0
- package/src/hooks/viz-elements/useHeatmapElementPosition.ts +60 -0
- package/src/hooks/viz-elements/useHeatmapMouseHandler.ts +255 -0
- package/src/hooks/viz-elements/useHoveredElement.ts +170 -0
- package/src/hooks/viz-live/index.ts +1 -0
- package/src/hooks/viz-live/useVizLiveIframeMsg.ts +88 -0
- package/src/hooks/viz-live/useVizLiveRender.ts +67 -0
- package/src/hooks/viz-render/index.ts +1 -0
- package/src/hooks/viz-render/useHeatmapRender.ts +71 -0
- package/src/hooks/viz-render/useHeatmapVizRender.ts +20 -0
- package/src/hooks/viz-render/useReplayRender.ts +160 -0
- package/src/hooks/viz-scale/index.ts +2 -0
- package/src/hooks/viz-scale/useContainerDimensions.ts +48 -0
- package/src/hooks/viz-scale/useContentDimensions.ts +25 -0
- package/src/hooks/viz-scale/useHeatmapScale.ts +52 -0
- package/src/hooks/viz-scale/useObserveIframeHeight.ts +162 -0
- package/src/hooks/viz-scale/useScaleCalculation.ts +31 -0
- package/src/hooks/viz-scale/useScrollSync.ts +36 -0
- package/src/hooks/viz-scale/useWrapperRefHeight.ts +91 -0
- package/{dist/esm/hooks/viz-scrollmap/index.d.ts → src/hooks/viz-scrollmap/index.ts} +0 -1
- package/src/hooks/viz-scrollmap/useScrollmapZones.ts +165 -0
- package/src/hooks/viz-scrollmap/useZonePositions.ts +38 -0
- package/src/index.ts +10 -0
- package/src/stores/comp.ts +31 -0
- package/src/stores/config.ts +37 -0
- package/src/stores/data.ts +30 -0
- package/src/stores/index.ts +10 -0
- package/src/stores/interaction.ts +32 -0
- package/src/stores/mode-live.ts +38 -0
- package/src/stores/mode-single.ts +18 -0
- package/src/stores/viz-scrollmap.ts +22 -0
- package/src/stores/viz.ts +17 -0
- package/src/styles/base.css +1 -0
- package/src/styles/style.css +137 -0
- package/src/types/clarity.ts +45 -0
- package/src/types/control.ts +10 -0
- package/src/types/elm-callout.ts +9 -0
- package/src/types/heatmap-info.ts +11 -0
- package/src/types/heatmap.ts +25 -0
- package/src/types/iframe-helper.ts +18 -0
- package/src/types/index.ts +12 -0
- package/src/types/viz-canvas.ts +20 -0
- package/src/types/viz-element.ts +34 -0
- package/src/types/viz-scrollmap.ts +28 -0
- package/src/ui/BoxStack/BoxStack.tsx +136 -0
- package/src/ui/BoxStack/index.ts +1 -0
- package/src/ui/index.ts +1 -0
- package/src/utils/debounce.ts +10 -0
- package/src/utils/device.ts +7 -0
- package/src/utils/retry.ts +20 -0
- package/src/utils/sort.ts +5 -0
- package/dist/esm/components/VizElement/HeatmapExample.d.ts +0 -2
- package/dist/esm/components/VizElement/HeatmapExample.d.ts.map +0 -1
- package/dist/esm/components/VizScrollmap/AverageFoldLine.d.ts +0 -8
- package/dist/esm/components/VizScrollmap/AverageFoldLine.d.ts.map +0 -1
- package/dist/esm/components/VizScrollmap/HoverZones.d.ts +0 -10
- package/dist/esm/components/VizScrollmap/HoverZones.d.ts.map +0 -1
- package/dist/esm/components/VizScrollmap/MetricRow.d.ts +0 -1
- package/dist/esm/components/VizScrollmap/MetricRow.d.ts.map +0 -1
- package/dist/esm/components/VizScrollmap/ScrollMapMinimap.d.ts +0 -8
- package/dist/esm/components/VizScrollmap/ScrollMapMinimap.d.ts.map +0 -1
- package/dist/esm/components/VizScrollmap/ScrollMapOverlay.d.ts +0 -7
- package/dist/esm/components/VizScrollmap/ScrollMapOverlay.d.ts.map +0 -1
- package/dist/esm/components/VizScrollmap/ScrollZoneHoverArea.d.ts +0 -14
- package/dist/esm/components/VizScrollmap/ScrollZoneHoverArea.d.ts.map +0 -1
- package/dist/esm/components/VizScrollmap/ScrollZoneTooltip.d.ts +0 -10
- package/dist/esm/components/VizScrollmap/ScrollZoneTooltip.d.ts.map +0 -1
- package/dist/esm/components/VizScrollmap/ScrollmapMarker.d.ts +0 -7
- package/dist/esm/components/VizScrollmap/ScrollmapMarker.d.ts.map +0 -1
- package/dist/esm/components/VizScrollmap/VizScrollMap.d.ts +0 -7
- package/dist/esm/components/VizScrollmap/VizScrollMap.d.ts.map +0 -1
- package/dist/esm/components/VizScrollmap/index.d.ts.map +0 -1
- package/dist/esm/components/VizScrollmapV2/ScrollmapOverlayV2.d.ts +0 -5
- package/dist/esm/components/VizScrollmapV2/ScrollmapOverlayV2.d.ts.map +0 -1
- package/dist/esm/components/VizScrollmapV2/index.d.ts.map +0 -1
- package/dist/esm/components/VizScrollmapV2/scrollmap.types.d.ts +0 -18
- package/dist/esm/components/VizScrollmapV2/scrollmap.types.d.ts.map +0 -1
- package/dist/esm/components/VizScrollmapV2/useScrollmapOverlay.d.ts +0 -16
- package/dist/esm/components/VizScrollmapV2/useScrollmapOverlay.d.ts.map +0 -1
- package/dist/esm/helpers/iframe-helper/fixer.d.ts +0 -18
- package/dist/esm/helpers/iframe-helper/fixer.d.ts.map +0 -1
- package/dist/esm/helpers/iframe-helper/index.d.ts +0 -2
- package/dist/esm/helpers/iframe-helper/index.d.ts.map +0 -1
- package/dist/esm/helpers/iframe-helper/init.d.ts +0 -5
- package/dist/esm/helpers/iframe-helper/init.d.ts.map +0 -1
- package/dist/esm/helpers/iframe-helper/navigation-blocker-v2.d.ts +0 -28
- package/dist/esm/helpers/iframe-helper/navigation-blocker-v2.d.ts.map +0 -1
- package/dist/esm/helpers/iframe-helper/navigation-blocker.d.ts +0 -20
- package/dist/esm/helpers/iframe-helper/navigation-blocker.d.ts.map +0 -1
- package/dist/esm/helpers/iframe-helper/style-replacer.d.ts +0 -25
- package/dist/esm/helpers/iframe-helper/style-replacer.d.ts.map +0 -1
- package/dist/esm/helpers/viz-canvas/area-clustering.d.ts +0 -44
- package/dist/esm/helpers/viz-canvas/area-clustering.d.ts.map +0 -1
- package/dist/esm/helpers/viz-canvas/area-overlay-manager-v2.d.ts +0 -17
- package/dist/esm/helpers/viz-canvas/area-overlay-manager-v2.d.ts.map +0 -1
- package/dist/esm/helpers/viz-canvas/area-overlay-manager.d.ts +0 -51
- package/dist/esm/helpers/viz-canvas/area-overlay-manager.d.ts.map +0 -1
- package/dist/esm/helpers/viz-canvas/hierarchical-area-clustering.d.ts +0 -73
- package/dist/esm/helpers/viz-canvas/hierarchical-area-clustering.d.ts.map +0 -1
- package/dist/esm/helpers/viz-canvas/index.d.ts.map +0 -1
- package/dist/esm/hooks/viz-area/useAreaHeatmap.d.ts +0 -59
- package/dist/esm/hooks/viz-area/useAreaHeatmap.d.ts.map +0 -1
- package/dist/esm/hooks/viz-area/useAreaHeatmapManager.d.ts +0 -77
- package/dist/esm/hooks/viz-area/useAreaHeatmapManager.d.ts.map +0 -1
- package/dist/esm/hooks/viz-canvas/useAreamap.d.ts +0 -14
- package/dist/esm/hooks/viz-canvas/useAreamap.d.ts.map +0 -1
- package/dist/esm/hooks/viz-canvas/useHeatmapCanvas.d.ts +0 -4
- package/dist/esm/hooks/viz-canvas/useHeatmapCanvas.d.ts.map +0 -1
- package/dist/esm/hooks/viz-elements/useHeatmapMouseHandler.d.ts +0 -34
- package/dist/esm/hooks/viz-elements/useHeatmapMouseHandler.d.ts.map +0 -1
- package/dist/esm/hooks/viz-elements/useHoveredElement.d.ts.map +0 -1
- package/dist/esm/hooks/viz-live/useVizLiveIframeMsg.d.ts.map +0 -1
- package/dist/esm/hooks/viz-live/useVizLiveRender.d.ts +0 -4
- package/dist/esm/hooks/viz-live/useVizLiveRender.d.ts.map +0 -1
- package/dist/esm/hooks/viz-scale/useObserveIframeHeight.d.ts +0 -10
- package/dist/esm/hooks/viz-scale/useObserveIframeHeight.d.ts.map +0 -1
- package/dist/esm/hooks/viz-scrollmap/index.d.ts.map +0 -1
- package/dist/esm/hooks/viz-scrollmap/useScrollmapZones.d.ts +0 -29
- package/dist/esm/hooks/viz-scrollmap/useScrollmapZones.d.ts.map +0 -1
- package/dist/esm/hooks/viz-scrollmap/useZonePositions.d.ts +0 -12
- package/dist/esm/hooks/viz-scrollmap/useZonePositions.d.ts.map +0 -1
- package/dist/esm/stores/mode-single.d.ts +0 -9
- package/dist/esm/stores/mode-single.d.ts.map +0 -1
- package/dist/esm/stores/viz-scrollmap.d.ts +0 -11
- package/dist/esm/stores/viz-scrollmap.d.ts.map +0 -1
- package/dist/esm/types/heatmap-info.d.ts +0 -11
- package/dist/esm/types/heatmap-info.d.ts.map +0 -1
- package/dist/esm/types/iframe-helper.d.ts +0 -20
- package/dist/esm/types/iframe-helper.d.ts.map +0 -1
- package/dist/esm/types/viz-canvas.d.ts +0 -23
- package/dist/esm/types/viz-canvas.d.ts.map +0 -1
- package/dist/esm/types/viz-scrollmap.d.ts +0 -27
- package/dist/esm/types/viz-scrollmap.d.ts.map +0 -1
- package/dist/umd/components/VizElement/HeatmapExample.d.ts +0 -2
- package/dist/umd/components/VizElement/HeatmapExample.d.ts.map +0 -1
- package/dist/umd/components/VizScrollmap/AverageFoldLine.d.ts +0 -8
- package/dist/umd/components/VizScrollmap/AverageFoldLine.d.ts.map +0 -1
- package/dist/umd/components/VizScrollmap/HoverZones.d.ts +0 -10
- package/dist/umd/components/VizScrollmap/HoverZones.d.ts.map +0 -1
- package/dist/umd/components/VizScrollmap/MetricRow.d.ts +0 -1
- package/dist/umd/components/VizScrollmap/MetricRow.d.ts.map +0 -1
- package/dist/umd/components/VizScrollmap/ScrollMapMinimap.d.ts +0 -8
- package/dist/umd/components/VizScrollmap/ScrollMapMinimap.d.ts.map +0 -1
- package/dist/umd/components/VizScrollmap/ScrollMapOverlay.d.ts +0 -7
- package/dist/umd/components/VizScrollmap/ScrollMapOverlay.d.ts.map +0 -1
- package/dist/umd/components/VizScrollmap/ScrollZoneHoverArea.d.ts +0 -14
- package/dist/umd/components/VizScrollmap/ScrollZoneHoverArea.d.ts.map +0 -1
- package/dist/umd/components/VizScrollmap/ScrollZoneTooltip.d.ts +0 -10
- package/dist/umd/components/VizScrollmap/ScrollZoneTooltip.d.ts.map +0 -1
- package/dist/umd/components/VizScrollmap/ScrollmapMarker.d.ts +0 -7
- package/dist/umd/components/VizScrollmap/ScrollmapMarker.d.ts.map +0 -1
- package/dist/umd/components/VizScrollmap/VizScrollMap.d.ts +0 -7
- package/dist/umd/components/VizScrollmap/VizScrollMap.d.ts.map +0 -1
- package/dist/umd/components/VizScrollmap/index.d.ts +0 -2
- package/dist/umd/components/VizScrollmap/index.d.ts.map +0 -1
- package/dist/umd/components/VizScrollmapV2/ScrollmapOverlayV2.d.ts +0 -5
- package/dist/umd/components/VizScrollmapV2/ScrollmapOverlayV2.d.ts.map +0 -1
- package/dist/umd/components/VizScrollmapV2/index.d.ts +0 -2
- package/dist/umd/components/VizScrollmapV2/index.d.ts.map +0 -1
- package/dist/umd/components/VizScrollmapV2/scrollmap.types.d.ts +0 -18
- package/dist/umd/components/VizScrollmapV2/scrollmap.types.d.ts.map +0 -1
- package/dist/umd/components/VizScrollmapV2/useScrollmapOverlay.d.ts +0 -16
- package/dist/umd/components/VizScrollmapV2/useScrollmapOverlay.d.ts.map +0 -1
- package/dist/umd/helpers/iframe-helper/fixer.d.ts +0 -18
- package/dist/umd/helpers/iframe-helper/fixer.d.ts.map +0 -1
- package/dist/umd/helpers/iframe-helper/index.d.ts +0 -2
- package/dist/umd/helpers/iframe-helper/index.d.ts.map +0 -1
- package/dist/umd/helpers/iframe-helper/init.d.ts +0 -5
- package/dist/umd/helpers/iframe-helper/init.d.ts.map +0 -1
- package/dist/umd/helpers/iframe-helper/navigation-blocker-v2.d.ts +0 -28
- package/dist/umd/helpers/iframe-helper/navigation-blocker-v2.d.ts.map +0 -1
- package/dist/umd/helpers/iframe-helper/navigation-blocker.d.ts +0 -20
- package/dist/umd/helpers/iframe-helper/navigation-blocker.d.ts.map +0 -1
- package/dist/umd/helpers/iframe-helper/style-replacer.d.ts +0 -25
- package/dist/umd/helpers/iframe-helper/style-replacer.d.ts.map +0 -1
- package/dist/umd/helpers/viz-canvas/area-clustering.d.ts +0 -44
- package/dist/umd/helpers/viz-canvas/area-clustering.d.ts.map +0 -1
- package/dist/umd/helpers/viz-canvas/area-overlay-manager-v2.d.ts +0 -17
- package/dist/umd/helpers/viz-canvas/area-overlay-manager-v2.d.ts.map +0 -1
- package/dist/umd/helpers/viz-canvas/area-overlay-manager.d.ts +0 -51
- package/dist/umd/helpers/viz-canvas/area-overlay-manager.d.ts.map +0 -1
- package/dist/umd/helpers/viz-canvas/hierarchical-area-clustering.d.ts +0 -73
- package/dist/umd/helpers/viz-canvas/hierarchical-area-clustering.d.ts.map +0 -1
- package/dist/umd/helpers/viz-canvas/index.d.ts +0 -3
- package/dist/umd/helpers/viz-canvas/index.d.ts.map +0 -1
- package/dist/umd/hooks/viz-area/useAreaHeatmap.d.ts +0 -59
- package/dist/umd/hooks/viz-area/useAreaHeatmap.d.ts.map +0 -1
- package/dist/umd/hooks/viz-area/useAreaHeatmapManager.d.ts +0 -77
- package/dist/umd/hooks/viz-area/useAreaHeatmapManager.d.ts.map +0 -1
- package/dist/umd/hooks/viz-canvas/useAreamap.d.ts +0 -14
- package/dist/umd/hooks/viz-canvas/useAreamap.d.ts.map +0 -1
- package/dist/umd/hooks/viz-canvas/useHeatmapCanvas.d.ts +0 -4
- package/dist/umd/hooks/viz-canvas/useHeatmapCanvas.d.ts.map +0 -1
- package/dist/umd/hooks/viz-elements/useHeatmapMouseHandler.d.ts +0 -34
- package/dist/umd/hooks/viz-elements/useHeatmapMouseHandler.d.ts.map +0 -1
- package/dist/umd/hooks/viz-elements/useHoveredElement.d.ts.map +0 -1
- package/dist/umd/hooks/viz-live/useVizLiveIframeMsg.d.ts.map +0 -1
- package/dist/umd/hooks/viz-live/useVizLiveRender.d.ts +0 -4
- package/dist/umd/hooks/viz-live/useVizLiveRender.d.ts.map +0 -1
- package/dist/umd/hooks/viz-scale/useObserveIframeHeight.d.ts +0 -10
- package/dist/umd/hooks/viz-scale/useObserveIframeHeight.d.ts.map +0 -1
- package/dist/umd/hooks/viz-scrollmap/index.d.ts +0 -3
- package/dist/umd/hooks/viz-scrollmap/index.d.ts.map +0 -1
- package/dist/umd/hooks/viz-scrollmap/useScrollmapZones.d.ts +0 -29
- package/dist/umd/hooks/viz-scrollmap/useScrollmapZones.d.ts.map +0 -1
- package/dist/umd/hooks/viz-scrollmap/useZonePositions.d.ts +0 -12
- package/dist/umd/hooks/viz-scrollmap/useZonePositions.d.ts.map +0 -1
- package/dist/umd/stores/mode-single.d.ts +0 -9
- package/dist/umd/stores/mode-single.d.ts.map +0 -1
- package/dist/umd/stores/viz-scrollmap.d.ts +0 -11
- package/dist/umd/stores/viz-scrollmap.d.ts.map +0 -1
- package/dist/umd/types/heatmap-info.d.ts +0 -11
- package/dist/umd/types/heatmap-info.d.ts.map +0 -1
- package/dist/umd/types/iframe-helper.d.ts +0 -20
- package/dist/umd/types/iframe-helper.d.ts.map +0 -1
- package/dist/umd/types/viz-canvas.d.ts +0 -23
- package/dist/umd/types/viz-canvas.d.ts.map +0 -1
- package/dist/umd/types/viz-scrollmap.d.ts +0 -27
- package/dist/umd/types/viz-scrollmap.d.ts.map +0 -1
- /package/dist/esm/hooks/{viz-elements → vix-elements}/index.d.ts +0 -0
- /package/dist/esm/hooks/{viz-elements → vix-elements}/useClickedElement.d.ts +0 -0
- /package/dist/esm/hooks/{viz-elements → vix-elements}/useElementCalloutVisible.d.ts +0 -0
- /package/dist/esm/hooks/{viz-elements → vix-elements}/useHeatmapEffects.d.ts +0 -0
- /package/dist/esm/hooks/{viz-elements → vix-elements}/useHeatmapElementPosition.d.ts +0 -0
- /package/dist/umd/hooks/{viz-elements → vix-elements}/index.d.ts +0 -0
- /package/dist/umd/hooks/{viz-elements → vix-elements}/useClickedElement.d.ts +0 -0
- /package/dist/umd/hooks/{viz-elements → vix-elements}/useElementCalloutVisible.d.ts +0 -0
- /package/dist/umd/hooks/{viz-elements → vix-elements}/useHeatmapEffects.d.ts +0 -0
- /package/dist/umd/hooks/{viz-elements → vix-elements}/useHeatmapElementPosition.d.ts +0 -0
package/dist/esm/index.mjs
CHANGED
|
@@ -61,8 +61,6 @@ const HEATMAP_STYLE = {
|
|
|
61
61
|
},
|
|
62
62
|
wrapper: {
|
|
63
63
|
padding: `${HEATMAP_CONFIG.padding}px 0`,
|
|
64
|
-
paddingBlock: `${HEATMAP_CONFIG.padding}px`,
|
|
65
|
-
paddingInline: `${HEATMAP_CONFIG.padding}px`,
|
|
66
64
|
},
|
|
67
65
|
};
|
|
68
66
|
const DEFAULT_SIDEBAR_WIDTH = 260;
|
|
@@ -93,37 +91,18 @@ var IHeatmapType;
|
|
|
93
91
|
IHeatmapType["Click"] = "click";
|
|
94
92
|
IHeatmapType["Scroll"] = "scroll";
|
|
95
93
|
})(IHeatmapType || (IHeatmapType = {}));
|
|
96
|
-
var IClickType;
|
|
97
|
-
(function (IClickType) {
|
|
98
|
-
IClickType["Total"] = "total-clicks";
|
|
99
|
-
IClickType["Rage"] = "rage-clicks";
|
|
100
|
-
IClickType["Dead"] = "dead-clicks";
|
|
101
|
-
IClickType["Error"] = "error-clicks";
|
|
102
|
-
IClickType["First"] = "first-clicks";
|
|
103
|
-
IClickType["Last"] = "last-clicks";
|
|
104
|
-
})(IClickType || (IClickType = {}));
|
|
105
|
-
var IScrollType;
|
|
106
|
-
(function (IScrollType) {
|
|
107
|
-
IScrollType["Depth"] = "scroll-depth";
|
|
108
|
-
IScrollType["Attention"] = "attention-scroll";
|
|
109
|
-
IScrollType["Revenue"] = "revenue-scroll";
|
|
110
|
-
})(IScrollType || (IScrollType = {}));
|
|
111
94
|
|
|
112
95
|
const useHeatmapConfigStore = create()((set, get) => {
|
|
113
96
|
return {
|
|
114
97
|
mode: 'single',
|
|
115
98
|
width: 1440,
|
|
116
99
|
sidebarWidth: DEFAULT_SIDEBAR_WIDTH,
|
|
117
|
-
heatmapType: IHeatmapType.
|
|
118
|
-
clickType: IClickType.Total,
|
|
119
|
-
scrollType: IScrollType.Depth,
|
|
100
|
+
heatmapType: IHeatmapType.Click,
|
|
120
101
|
setMode: (mode) => set({ mode }),
|
|
121
102
|
resetMode: () => set({ mode: 'single' }),
|
|
122
103
|
setWidth: (width) => set({ width }),
|
|
123
104
|
setSidebarWidth: (sidebarWidth) => set({ sidebarWidth }),
|
|
124
105
|
setHeatmapType: (heatmapType) => set({ heatmapType }),
|
|
125
|
-
setClickType: (clickType) => set({ clickType }),
|
|
126
|
-
setScrollType: (scrollType) => set({ scrollType }),
|
|
127
106
|
};
|
|
128
107
|
});
|
|
129
108
|
|
|
@@ -132,13 +111,11 @@ const useHeatmapDataStore = create()((set, get) => {
|
|
|
132
111
|
data: undefined,
|
|
133
112
|
clickmap: undefined,
|
|
134
113
|
dataInfo: undefined,
|
|
135
|
-
scrollmap: undefined,
|
|
136
114
|
isRendering: true,
|
|
137
115
|
setIsRendering: (isRendering) => set({ isRendering }),
|
|
138
116
|
setDataInfo: (dataInfo) => set({ dataInfo }),
|
|
139
117
|
setData: (data) => set({ data }),
|
|
140
118
|
setClickmap: (clickmap) => set({ clickmap }),
|
|
141
|
-
setScrollmap: (scrollmap) => set({ scrollmap }),
|
|
142
119
|
};
|
|
143
120
|
});
|
|
144
121
|
|
|
@@ -162,23 +139,15 @@ const useHeatmapVizStore = create()((set, get) => {
|
|
|
162
139
|
isRenderViz: false,
|
|
163
140
|
setIsRenderViz: (isRenderViz) => set({ isRenderViz }),
|
|
164
141
|
scale: 1,
|
|
142
|
+
vizRef: undefined,
|
|
143
|
+
iframeHeight: 0,
|
|
165
144
|
setScale: (scale) => set({ scale }),
|
|
166
|
-
|
|
167
|
-
})
|
|
168
|
-
|
|
169
|
-
const useHeatmapVizScrollmapStore = create()((set, get) => {
|
|
170
|
-
return {
|
|
171
|
-
zones: [],
|
|
172
|
-
hoveredZone: null,
|
|
173
|
-
showMinimap: true,
|
|
174
|
-
setZones: (zones) => set({ zones }),
|
|
175
|
-
setHoveredZone: (hoveredZone) => set({ hoveredZone }),
|
|
176
|
-
setShowMinimap: (showMinimap) => set({ showMinimap }),
|
|
145
|
+
setVizRef: (vizRef) => set({ vizRef }),
|
|
146
|
+
setIframeHeight: (iframeHeight) => set({ iframeHeight }),
|
|
177
147
|
};
|
|
178
148
|
});
|
|
179
149
|
|
|
180
150
|
const initialState = {
|
|
181
|
-
payloads: [],
|
|
182
151
|
htmlContent: '',
|
|
183
152
|
wrapperHeight: 0,
|
|
184
153
|
iframeHeight: 0,
|
|
@@ -187,23 +156,12 @@ const useHeatmapLiveStore = create()((set, get) => {
|
|
|
187
156
|
return {
|
|
188
157
|
...initialState,
|
|
189
158
|
reset: () => set(initialState),
|
|
190
|
-
setPayloads: (payloads) => set({ payloads }),
|
|
191
|
-
addPayload: (payload) => set((state) => ({ payloads: [...state.payloads, payload] })),
|
|
192
159
|
setHtmlContent: (htmlContent) => set({ htmlContent }),
|
|
193
160
|
setWrapperHeight: (wrapperHeight) => set({ wrapperHeight }),
|
|
194
161
|
setIframeHeight: (iframeHeight) => set({ iframeHeight }),
|
|
195
162
|
};
|
|
196
163
|
});
|
|
197
164
|
|
|
198
|
-
const useHeatmapSingleStore = create()((set, get) => {
|
|
199
|
-
return {
|
|
200
|
-
vizRef: null,
|
|
201
|
-
iframeHeight: 0,
|
|
202
|
-
setVizRef: (vizRef) => set({ vizRef }),
|
|
203
|
-
setIframeHeight: (iframeHeight) => set({ iframeHeight }),
|
|
204
|
-
};
|
|
205
|
-
});
|
|
206
|
-
|
|
207
165
|
const useRegisterConfig = () => {
|
|
208
166
|
const mode = useHeatmapConfigStore((state) => state.mode);
|
|
209
167
|
const width = useHeatmapConfigStore((state) => state.width);
|
|
@@ -251,25 +209,16 @@ const useRegisterData = (data, dataInfo) => {
|
|
|
251
209
|
}, [dataInfo]);
|
|
252
210
|
};
|
|
253
211
|
|
|
254
|
-
const useRegisterHeatmap = (
|
|
212
|
+
const useRegisterHeatmap = (clickmap) => {
|
|
255
213
|
const setClickmap = useHeatmapDataStore((state) => state.setClickmap);
|
|
256
|
-
const setScrollmap = useHeatmapDataStore((state) => state.setScrollmap);
|
|
257
214
|
const handleSetClickmap = useCallback((clickmap) => {
|
|
258
215
|
if (!clickmap)
|
|
259
216
|
return;
|
|
260
217
|
setClickmap(clickmap);
|
|
261
218
|
}, [clickmap]);
|
|
262
|
-
const handleSetScrollmap = useCallback((scrollmap) => {
|
|
263
|
-
if (!scrollmap)
|
|
264
|
-
return;
|
|
265
|
-
setScrollmap(scrollmap);
|
|
266
|
-
}, [scrollmap]);
|
|
267
219
|
useEffect(() => {
|
|
268
220
|
handleSetClickmap(clickmap);
|
|
269
221
|
}, [clickmap]);
|
|
270
|
-
useEffect(() => {
|
|
271
|
-
handleSetScrollmap(scrollmap);
|
|
272
|
-
}, [scrollmap]);
|
|
273
222
|
};
|
|
274
223
|
|
|
275
224
|
const PADDING = 0;
|
|
@@ -552,311 +501,91 @@ function isElementInViewport(elementRect, visualRef, scale) {
|
|
|
552
501
|
return elementBottom > viewportTop && elementTop < viewportBottom;
|
|
553
502
|
}
|
|
554
503
|
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
504
|
+
const getScriptInjectCode = async () => {
|
|
505
|
+
const moduleResult = (await Promise.resolve().then(function () { return viewportReplacer; }));
|
|
506
|
+
const ActualClass = moduleResult.default;
|
|
507
|
+
const classCode = ActualClass.toString();
|
|
508
|
+
const classInstantiateCode = ActualClass.name;
|
|
509
|
+
const scriptCode = `
|
|
510
|
+
(function() {
|
|
511
|
+
'use strict';
|
|
512
|
+
${classCode}
|
|
513
|
+
new ${classInstantiateCode}()
|
|
514
|
+
})();
|
|
515
|
+
`;
|
|
516
|
+
return scriptCode;
|
|
517
|
+
};
|
|
518
|
+
class ViewportUnitsFixer {
|
|
519
|
+
iframe = null;
|
|
520
|
+
config;
|
|
521
|
+
constructor(config) {
|
|
522
|
+
this.config = config;
|
|
523
|
+
this.iframe = config.iframe;
|
|
569
524
|
this.init();
|
|
570
525
|
}
|
|
571
|
-
init() {
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
this.blockLinkNavigation();
|
|
576
|
-
// Chặn form submissions
|
|
577
|
-
this.blockFormSubmissions();
|
|
578
|
-
// Chặn window.open (này an toàn)
|
|
579
|
-
this.blockWindowOpen();
|
|
580
|
-
// Chặn beforeunload để prevent navigation
|
|
581
|
-
this.blockBeforeUnload();
|
|
582
|
-
// Monitor DOM changes để block dynamic links
|
|
583
|
-
this.monitorDOMChanges();
|
|
584
|
-
// Inject CSP nếu có thể
|
|
585
|
-
this.injectCSP();
|
|
586
|
-
}
|
|
587
|
-
catch (error) {
|
|
588
|
-
console.error('[NavigationBlocker] Init error:', error);
|
|
589
|
-
}
|
|
590
|
-
}
|
|
591
|
-
blockLinkNavigation() {
|
|
592
|
-
// Sử dụng capture phase để chặn sớm nhất
|
|
593
|
-
this.doc.addEventListener('click', (e) => {
|
|
594
|
-
if (!this.isEnabled)
|
|
595
|
-
return;
|
|
596
|
-
const target = e.target;
|
|
597
|
-
const link = target.closest('a');
|
|
598
|
-
if (link) {
|
|
599
|
-
const href = link.getAttribute('href');
|
|
600
|
-
// Cho phép hash links và empty links
|
|
601
|
-
if (!href || href === '' || href === '#' || href.startsWith('#')) {
|
|
602
|
-
console.log('[NavigationBlocker] Allowed hash navigation:', href);
|
|
603
|
-
return;
|
|
604
|
-
}
|
|
605
|
-
// Chặn tất cả các loại navigation
|
|
606
|
-
console.log('[NavigationBlocker] Blocked link navigation to:', href);
|
|
607
|
-
e.preventDefault();
|
|
608
|
-
e.stopPropagation();
|
|
609
|
-
e.stopImmediatePropagation();
|
|
610
|
-
this.notifyBlockedNavigation(href);
|
|
611
|
-
}
|
|
612
|
-
}, true);
|
|
613
|
-
// Chặn cả middle click và right click "open in new tab"
|
|
614
|
-
this.doc.addEventListener('auxclick', (e) => {
|
|
615
|
-
if (!this.isEnabled)
|
|
616
|
-
return;
|
|
617
|
-
const target = e.target;
|
|
618
|
-
const link = target.closest('a');
|
|
619
|
-
if (link) {
|
|
620
|
-
const href = link.getAttribute('href');
|
|
621
|
-
if (href && !href.startsWith('#')) {
|
|
622
|
-
console.log('[NavigationBlocker] Blocked auxclick navigation');
|
|
623
|
-
e.preventDefault();
|
|
624
|
-
e.stopPropagation();
|
|
625
|
-
e.stopImmediatePropagation();
|
|
626
|
-
}
|
|
627
|
-
}
|
|
628
|
-
}, true);
|
|
629
|
-
// Disable tất cả links ngay từ đầu
|
|
630
|
-
this.disableAllLinks();
|
|
631
|
-
}
|
|
632
|
-
disableAllLinks() {
|
|
633
|
-
this.doc.querySelectorAll('a[href]').forEach((link) => {
|
|
634
|
-
const href = link.getAttribute('href');
|
|
635
|
-
if (href && !href.startsWith('#')) {
|
|
636
|
-
// Thêm pointer-events: none và cursor
|
|
637
|
-
link.style.cursor = 'not-allowed';
|
|
638
|
-
link.setAttribute('data-navigation-blocked', 'true');
|
|
639
|
-
// Remove href để browser không hiện preview
|
|
640
|
-
link.setAttribute('data-original-href', href);
|
|
641
|
-
link.removeAttribute('href');
|
|
642
|
-
// Hoặc giữ href nhưng disable
|
|
643
|
-
// link.setAttribute('onclick', 'return false');
|
|
644
|
-
}
|
|
645
|
-
});
|
|
646
|
-
}
|
|
647
|
-
blockFormSubmissions() {
|
|
648
|
-
this.doc.addEventListener('submit', (e) => {
|
|
649
|
-
if (!this.isEnabled)
|
|
650
|
-
return;
|
|
651
|
-
const form = e.target;
|
|
652
|
-
const action = form.getAttribute('action');
|
|
653
|
-
// Cho phép forms không có action
|
|
654
|
-
if (!action || action === '' || action === '#') {
|
|
655
|
-
console.log('[NavigationBlocker] Allowed same-page form');
|
|
656
|
-
e.preventDefault();
|
|
657
|
-
this.handleFormSubmit(form);
|
|
658
|
-
return;
|
|
659
|
-
}
|
|
660
|
-
// Chặn tất cả external submissions
|
|
661
|
-
console.log('[NavigationBlocker] Blocked form submission to:', action);
|
|
662
|
-
e.preventDefault();
|
|
663
|
-
e.stopPropagation();
|
|
664
|
-
e.stopImmediatePropagation();
|
|
665
|
-
this.notifyBlockedNavigation(action);
|
|
666
|
-
}, true);
|
|
667
|
-
}
|
|
668
|
-
blockWindowOpen() {
|
|
669
|
-
// Override window.open - đây là safe
|
|
670
|
-
this.win.open = ((...args) => {
|
|
671
|
-
if (!this.isEnabled) {
|
|
672
|
-
return this.originalWindowOpen(...args);
|
|
673
|
-
}
|
|
674
|
-
const url = args[0]?.toString() || 'popup';
|
|
675
|
-
console.log('[NavigationBlocker] Blocked window.open:', url);
|
|
676
|
-
this.notifyBlockedNavigation(url);
|
|
677
|
-
return null;
|
|
678
|
-
});
|
|
679
|
-
}
|
|
680
|
-
blockBeforeUnload() {
|
|
681
|
-
// Chặn unload
|
|
682
|
-
this.win.addEventListener('beforeunload', (e) => {
|
|
683
|
-
if (!this.isEnabled)
|
|
684
|
-
return;
|
|
685
|
-
console.log('[NavigationBlocker] Blocked beforeunload');
|
|
686
|
-
e.preventDefault();
|
|
687
|
-
e.returnValue = '';
|
|
688
|
-
return '';
|
|
689
|
-
}, true);
|
|
690
|
-
// Chặn unload
|
|
691
|
-
this.win.addEventListener('unload', (e) => {
|
|
692
|
-
if (!this.isEnabled)
|
|
693
|
-
return;
|
|
694
|
-
console.log('[NavigationBlocker] Blocked unload');
|
|
695
|
-
e.preventDefault();
|
|
696
|
-
e.stopPropagation();
|
|
697
|
-
}, true);
|
|
698
|
-
// Monitor popstate
|
|
699
|
-
this.win.addEventListener('popstate', (e) => {
|
|
700
|
-
if (!this.isEnabled)
|
|
701
|
-
return;
|
|
702
|
-
console.log('[NavigationBlocker] Blocked popstate');
|
|
703
|
-
e.preventDefault();
|
|
704
|
-
e.stopPropagation();
|
|
705
|
-
}, true);
|
|
706
|
-
}
|
|
707
|
-
monitorDOMChanges() {
|
|
708
|
-
// Monitor khi có links mới được thêm vào
|
|
709
|
-
const observer = new MutationObserver((mutations) => {
|
|
710
|
-
if (!this.isEnabled)
|
|
711
|
-
return;
|
|
712
|
-
mutations.forEach((mutation) => {
|
|
713
|
-
mutation.addedNodes.forEach((node) => {
|
|
714
|
-
if (node.nodeType === Node.ELEMENT_NODE) {
|
|
715
|
-
const element = node;
|
|
716
|
-
// Nếu là link
|
|
717
|
-
if (element.tagName === 'A') {
|
|
718
|
-
const href = element.getAttribute('href');
|
|
719
|
-
if (href && !href.startsWith('#')) {
|
|
720
|
-
element.style.cursor = 'not-allowed';
|
|
721
|
-
element.setAttribute('data-navigation-blocked', 'true');
|
|
722
|
-
element.setAttribute('data-original-href', href);
|
|
723
|
-
element.removeAttribute('href');
|
|
724
|
-
}
|
|
725
|
-
}
|
|
726
|
-
// Tìm links trong subtree
|
|
727
|
-
element.querySelectorAll('a[href]').forEach((link) => {
|
|
728
|
-
const href = link.getAttribute('href');
|
|
729
|
-
if (href && !href.startsWith('#')) {
|
|
730
|
-
link.style.cursor = 'not-allowed';
|
|
731
|
-
link.setAttribute('data-navigation-blocked', 'true');
|
|
732
|
-
link.setAttribute('data-original-href', href);
|
|
733
|
-
link.removeAttribute('href');
|
|
734
|
-
}
|
|
735
|
-
});
|
|
736
|
-
}
|
|
737
|
-
});
|
|
738
|
-
});
|
|
739
|
-
});
|
|
740
|
-
observer.observe(this.doc.body, {
|
|
741
|
-
childList: true,
|
|
742
|
-
subtree: true,
|
|
743
|
-
});
|
|
744
|
-
this.observers.push(observer);
|
|
745
|
-
}
|
|
746
|
-
injectCSP() {
|
|
747
|
-
// Thêm CSP meta tag nếu chưa có (optional)
|
|
748
|
-
try {
|
|
749
|
-
const existingCSP = this.doc.querySelector('meta[http-equiv="Content-Security-Policy"]');
|
|
750
|
-
if (!existingCSP) {
|
|
751
|
-
const meta = this.doc.createElement('meta');
|
|
752
|
-
meta.httpEquiv = 'Content-Security-Policy';
|
|
753
|
-
meta.content = "navigate-to 'none'"; // Chặn tất cả navigation
|
|
754
|
-
this.doc.head.appendChild(meta);
|
|
755
|
-
console.log('[NavigationBlocker] Injected CSP');
|
|
756
|
-
}
|
|
526
|
+
async init() {
|
|
527
|
+
if (!this.iframe) {
|
|
528
|
+
console.error('[Parent] Required elements not found');
|
|
529
|
+
return;
|
|
757
530
|
}
|
|
758
|
-
|
|
759
|
-
|
|
531
|
+
// this.injectScriptContent = await generateIframeInjectScript();
|
|
532
|
+
window.addEventListener('message', this.handleMessage.bind(this));
|
|
533
|
+
if (this.iframe.contentDocument?.readyState === 'complete') {
|
|
534
|
+
await this.injectScript();
|
|
760
535
|
}
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
const formData = new FormData(form);
|
|
764
|
-
const data = {};
|
|
765
|
-
formData.forEach((value, key) => {
|
|
766
|
-
data[key] = value;
|
|
767
|
-
});
|
|
768
|
-
console.log('[NavigationBlocker] Handling form data:', data);
|
|
769
|
-
window.dispatchEvent(new CustomEvent('iframe-form-submit', {
|
|
770
|
-
detail: { form, data },
|
|
771
|
-
}));
|
|
772
|
-
}
|
|
773
|
-
notifyBlockedNavigation(url) {
|
|
774
|
-
console.warn('[NavigationBlocker] Navigation blocked to:', url);
|
|
775
|
-
window.dispatchEvent(new CustomEvent('iframe-navigation-blocked', {
|
|
776
|
-
detail: { url, timestamp: Date.now() },
|
|
777
|
-
}));
|
|
778
|
-
if (this.shouldShowMessage(url)) {
|
|
779
|
-
this.showBlockedMessage(url);
|
|
536
|
+
else {
|
|
537
|
+
this.iframe.addEventListener('load', () => this.injectScript());
|
|
780
538
|
}
|
|
781
539
|
}
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
}
|
|
785
|
-
showBlockedMessage(url) {
|
|
786
|
-
if (!this.showMessage)
|
|
540
|
+
async injectScript() {
|
|
541
|
+
if (!this.iframe?.contentWindow || !this.iframe.contentDocument)
|
|
787
542
|
return;
|
|
788
|
-
const
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
pointer-events: none;
|
|
804
|
-
`;
|
|
805
|
-
const shortUrl = url.length > 50 ? url.substring(0, 47) + '...' : url;
|
|
806
|
-
message.innerHTML = `
|
|
807
|
-
<div style="font-weight: 600; margin-bottom: 4px;">🚫 Navigation Blocked</div>
|
|
808
|
-
<div style="font-size: 12px; opacity: 0.9;">${this.escapeHtml(shortUrl)}</div>
|
|
809
|
-
`;
|
|
810
|
-
this.doc.body.appendChild(message);
|
|
811
|
-
setTimeout(() => {
|
|
812
|
-
message.style.opacity = '0';
|
|
813
|
-
message.style.transition = 'opacity 0.3s';
|
|
814
|
-
setTimeout(() => message.remove(), 300);
|
|
815
|
-
}, 3000);
|
|
816
|
-
}
|
|
817
|
-
escapeHtml(text) {
|
|
818
|
-
const div = this.doc.createElement('div');
|
|
819
|
-
div.textContent = text;
|
|
820
|
-
return div.innerHTML;
|
|
821
|
-
}
|
|
822
|
-
enable() {
|
|
823
|
-
this.isEnabled = true;
|
|
824
|
-
console.log('[NavigationBlocker] Enabled');
|
|
825
|
-
}
|
|
826
|
-
enableMessage() {
|
|
827
|
-
this.showMessage = true;
|
|
828
|
-
console.log('[NavigationBlocker] Enabled message');
|
|
829
|
-
}
|
|
830
|
-
disable() {
|
|
831
|
-
this.isEnabled = false;
|
|
832
|
-
console.log('[NavigationBlocker] Disabled');
|
|
543
|
+
const win = this.iframe.contentWindow;
|
|
544
|
+
const doc = this.iframe.contentDocument;
|
|
545
|
+
win.__viewportConfig = this.config;
|
|
546
|
+
const script = doc.createElement('script');
|
|
547
|
+
const codeInject = await getScriptInjectCode();
|
|
548
|
+
script.textContent = codeInject;
|
|
549
|
+
script.type = 'text/javascript';
|
|
550
|
+
script.id = 'viewport-replacer';
|
|
551
|
+
script.onload = () => console.log('[Parent] Viewport replacer module loaded');
|
|
552
|
+
script.onerror = () => {
|
|
553
|
+
this.config.onSuccess?.({
|
|
554
|
+
height: 1000,
|
|
555
|
+
});
|
|
556
|
+
};
|
|
557
|
+
doc.head.appendChild(script);
|
|
833
558
|
}
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
559
|
+
handleMessage(event) {
|
|
560
|
+
const data = event.data;
|
|
561
|
+
if (!data || data.type !== 'IFRAME_HEIGHT_CALCULATED')
|
|
562
|
+
return;
|
|
563
|
+
this.config.onSuccess?.(data);
|
|
837
564
|
}
|
|
838
|
-
|
|
839
|
-
this.
|
|
840
|
-
this.showMessage = false;
|
|
841
|
-
// Cleanup observers
|
|
842
|
-
this.observers.forEach((observer) => observer.disconnect());
|
|
843
|
-
this.observers = [];
|
|
844
|
-
console.log('[NavigationBlocker] Destroyed');
|
|
565
|
+
recalculate() {
|
|
566
|
+
this.injectScript();
|
|
845
567
|
}
|
|
846
568
|
}
|
|
569
|
+
function initViewportFixer(config) {
|
|
570
|
+
const fixer = new ViewportUnitsFixer(config);
|
|
571
|
+
window.viewportFixer = fixer;
|
|
572
|
+
window.addEventListener('iframe-dimensions-applied', ((e) => {
|
|
573
|
+
const ev = e;
|
|
574
|
+
console.log('Iframe dimensions finalized:', ev.detail);
|
|
575
|
+
}));
|
|
576
|
+
return fixer;
|
|
577
|
+
}
|
|
847
578
|
|
|
848
|
-
class
|
|
849
|
-
doc;
|
|
850
|
-
win;
|
|
579
|
+
class ViewportUnitsReplacer {
|
|
851
580
|
config;
|
|
852
581
|
regex = /([-.\d]+)(vh|svh|lvh|dvh|vw|svw|lvw|dvw)/gi;
|
|
853
|
-
constructor(
|
|
854
|
-
if (!
|
|
855
|
-
throw new Error('Iframe
|
|
582
|
+
constructor() {
|
|
583
|
+
if (!window.__viewportConfig) {
|
|
584
|
+
throw new Error('[Iframe] Do not have viewport config');
|
|
856
585
|
}
|
|
857
|
-
this.
|
|
858
|
-
|
|
859
|
-
this.
|
|
586
|
+
this.config = window.__viewportConfig;
|
|
587
|
+
console.log('[Iframe] ViewportUnitsReplacer started with config:', this.config);
|
|
588
|
+
this.init();
|
|
860
589
|
}
|
|
861
590
|
px(value) {
|
|
862
591
|
return `${value.toFixed(2)}px`;
|
|
@@ -882,28 +611,26 @@ class IframeStyleReplacer {
|
|
|
882
611
|
}
|
|
883
612
|
processInlineStyles() {
|
|
884
613
|
let count = 0;
|
|
885
|
-
|
|
614
|
+
document.querySelectorAll('[style]').forEach((el) => {
|
|
886
615
|
const style = el.getAttribute('style');
|
|
887
616
|
if (style && this.regex.test(style)) {
|
|
888
|
-
this.regex.lastIndex = 0;
|
|
889
617
|
el.setAttribute('style', this.replaceInText(style));
|
|
890
618
|
count++;
|
|
891
619
|
}
|
|
892
620
|
});
|
|
893
|
-
console.log(`[
|
|
621
|
+
console.log(`[Iframe] Replaced ${count} inline style elements`);
|
|
894
622
|
return count;
|
|
895
623
|
}
|
|
896
624
|
processStyleTags() {
|
|
897
625
|
let count = 0;
|
|
898
|
-
|
|
626
|
+
document.querySelectorAll('style').forEach((tag) => {
|
|
899
627
|
const css = tag.textContent || '';
|
|
900
628
|
if (this.regex.test(css)) {
|
|
901
|
-
this.regex.lastIndex = 0;
|
|
902
629
|
tag.textContent = this.replaceInText(css);
|
|
903
630
|
count++;
|
|
904
631
|
}
|
|
905
632
|
});
|
|
906
|
-
console.log(`[
|
|
633
|
+
console.log(`[Iframe] Replaced ${count} <style> tags`);
|
|
907
634
|
return count;
|
|
908
635
|
}
|
|
909
636
|
processRule(rule) {
|
|
@@ -914,7 +641,6 @@ class IframeStyleReplacer {
|
|
|
914
641
|
const prop = style[i];
|
|
915
642
|
const value = style.getPropertyValue(prop);
|
|
916
643
|
if (value && this.regex.test(value)) {
|
|
917
|
-
this.regex.lastIndex = 0;
|
|
918
644
|
style.setProperty(prop, this.replaceInText(value), style.getPropertyPriority(prop));
|
|
919
645
|
count++;
|
|
920
646
|
}
|
|
@@ -930,11 +656,11 @@ class IframeStyleReplacer {
|
|
|
930
656
|
}
|
|
931
657
|
processStylesheets() {
|
|
932
658
|
let total = 0;
|
|
933
|
-
Array.from(
|
|
659
|
+
Array.from(document.styleSheets).forEach((sheet) => {
|
|
934
660
|
try {
|
|
935
661
|
// Bỏ qua external CSS (cross-origin)
|
|
936
|
-
if (sheet.href && !sheet.href.startsWith(
|
|
937
|
-
console.log('[
|
|
662
|
+
if (sheet.href && !sheet.href.startsWith(location.origin)) {
|
|
663
|
+
console.log('[Iframe] Skipping external CSS:', sheet.href);
|
|
938
664
|
return;
|
|
939
665
|
}
|
|
940
666
|
const rules = sheet.cssRules || sheet.rules;
|
|
@@ -945,27 +671,26 @@ class IframeStyleReplacer {
|
|
|
945
671
|
}
|
|
946
672
|
}
|
|
947
673
|
catch (e) {
|
|
948
|
-
console.warn('[
|
|
674
|
+
console.warn('[Iframe] Cannot read stylesheet (CORS?):', e.message);
|
|
949
675
|
}
|
|
950
676
|
});
|
|
951
|
-
console.log(`[
|
|
677
|
+
console.log(`[Iframe] Replaced ${total} rules in stylesheets`);
|
|
952
678
|
return total;
|
|
953
679
|
}
|
|
954
680
|
async processLinkedStylesheets() {
|
|
955
|
-
const links =
|
|
681
|
+
const links = document.querySelectorAll('link[rel="stylesheet"]');
|
|
956
682
|
let count = 0;
|
|
957
683
|
for (const link of Array.from(links)) {
|
|
958
|
-
if (!link.href.startsWith(
|
|
959
|
-
console.log('[
|
|
684
|
+
if (!link.href.startsWith(location.origin)) {
|
|
685
|
+
console.log('[Iframe] Skipping external CSS:', link.href);
|
|
960
686
|
continue;
|
|
961
687
|
}
|
|
962
688
|
try {
|
|
963
689
|
const res = await fetch(link.href);
|
|
964
690
|
let css = await res.text();
|
|
965
691
|
if (this.regex.test(css)) {
|
|
966
|
-
this.regex.lastIndex = 0;
|
|
967
692
|
css = this.replaceInText(css);
|
|
968
|
-
const style =
|
|
693
|
+
const style = document.createElement('style');
|
|
969
694
|
style.textContent = css;
|
|
970
695
|
style.dataset.originalHref = link.href;
|
|
971
696
|
link.parentNode?.insertBefore(style, link);
|
|
@@ -974,25 +699,30 @@ class IframeStyleReplacer {
|
|
|
974
699
|
}
|
|
975
700
|
}
|
|
976
701
|
catch (e) {
|
|
977
|
-
console.warn('[
|
|
702
|
+
console.warn('[Iframe] Cannot load CSS:', link.href, e);
|
|
978
703
|
}
|
|
979
704
|
}
|
|
980
|
-
console.log(`[
|
|
705
|
+
console.log(`[Iframe] Replaced ${count} linked CSS files`);
|
|
981
706
|
return count;
|
|
982
707
|
}
|
|
983
708
|
getFinalHeight() {
|
|
984
709
|
// Trigger reflow
|
|
985
|
-
void
|
|
986
|
-
return Math.max(
|
|
710
|
+
void document.body.offsetHeight;
|
|
711
|
+
return Math.max(document.body.scrollHeight, document.body.offsetHeight, document.documentElement.scrollHeight, document.documentElement.offsetHeight, document.documentElement.clientHeight);
|
|
987
712
|
}
|
|
988
|
-
|
|
989
|
-
|
|
713
|
+
notifyParent(height) {
|
|
714
|
+
window.parent.postMessage({
|
|
715
|
+
type: 'IFRAME_HEIGHT_CALCULATED',
|
|
716
|
+
height,
|
|
717
|
+
width: document.body.scrollWidth,
|
|
718
|
+
}, '*');
|
|
719
|
+
console.log('[Iframe] Sent height to parent:', height);
|
|
990
720
|
}
|
|
991
721
|
async waitForResources() {
|
|
992
|
-
if ('fonts' in
|
|
993
|
-
await
|
|
722
|
+
if ('fonts' in document) {
|
|
723
|
+
await document.fonts.ready;
|
|
994
724
|
}
|
|
995
|
-
const images = Array.from(
|
|
725
|
+
const images = Array.from(document.images).filter((img) => !img.complete);
|
|
996
726
|
if (images.length > 0) {
|
|
997
727
|
await Promise.all(images.map((img) => new Promise((resolve) => {
|
|
998
728
|
img.onload = img.onerror = resolve;
|
|
@@ -1001,131 +731,35 @@ class IframeStyleReplacer {
|
|
|
1001
731
|
}
|
|
1002
732
|
async run() {
|
|
1003
733
|
try {
|
|
1004
|
-
console.log('[IframeStyleReplacer] Starting viewport units replacement...');
|
|
1005
734
|
this.processInlineStyles();
|
|
1006
735
|
this.processStyleTags();
|
|
1007
736
|
this.processStylesheets();
|
|
1008
737
|
await this.processLinkedStylesheets();
|
|
1009
738
|
// await this.waitForResources();
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
const width = this.getFinalWidth();
|
|
1014
|
-
console.log('[IframeStyleReplacer] Calculated dimensions:', { height, width });
|
|
1015
|
-
resolve({ height, width });
|
|
1016
|
-
});
|
|
739
|
+
requestAnimationFrame(() => {
|
|
740
|
+
const height = this.getFinalHeight();
|
|
741
|
+
this.notifyParent(height);
|
|
1017
742
|
});
|
|
1018
743
|
}
|
|
1019
744
|
catch (err) {
|
|
1020
|
-
console.error('[
|
|
1021
|
-
|
|
1022
|
-
height: this.doc.body.scrollHeight || 1000,
|
|
1023
|
-
width: this.doc.body.scrollWidth || 1000,
|
|
1024
|
-
};
|
|
745
|
+
console.error('[Iframe] Critical error:', err);
|
|
746
|
+
this.notifyParent(document.body.scrollHeight || 1000);
|
|
1025
747
|
}
|
|
1026
748
|
}
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
}
|
|
1031
|
-
|
|
1032
|
-
class IframeHelperFixer {
|
|
1033
|
-
iframe;
|
|
1034
|
-
config;
|
|
1035
|
-
replacer = null;
|
|
1036
|
-
navigationBlocker = null;
|
|
1037
|
-
constructor(config) {
|
|
1038
|
-
this.config = config;
|
|
1039
|
-
this.iframe = config.iframe;
|
|
1040
|
-
this.init();
|
|
1041
|
-
}
|
|
1042
|
-
async init() {
|
|
1043
|
-
if (!this.iframe) {
|
|
1044
|
-
console.error('[IframeHelper] iframe not found');
|
|
1045
|
-
this.config.onError?.(new Error('iframe not found'));
|
|
1046
|
-
return;
|
|
1047
|
-
}
|
|
1048
|
-
// Wait for iframe to load completely
|
|
1049
|
-
if (this.iframe.contentDocument?.readyState === 'complete') {
|
|
1050
|
-
await this.process();
|
|
749
|
+
init() {
|
|
750
|
+
if (document.readyState === 'loading') {
|
|
751
|
+
document.addEventListener('DOMContentLoaded', () => this.run());
|
|
1051
752
|
}
|
|
1052
753
|
else {
|
|
1053
|
-
this.
|
|
1054
|
-
}
|
|
1055
|
-
}
|
|
1056
|
-
async process() {
|
|
1057
|
-
if (!this.iframe.contentDocument || !this.iframe.contentWindow) {
|
|
1058
|
-
console.error('[IframeHelper] Cannot access iframe document');
|
|
1059
|
-
this.config.onError?.(new Error('Cannot access iframe document'));
|
|
1060
|
-
return;
|
|
754
|
+
this.run();
|
|
1061
755
|
}
|
|
1062
|
-
try {
|
|
1063
|
-
console.log('[IframeHelper] Processing viewport units...');
|
|
1064
|
-
// Create replacer instance
|
|
1065
|
-
this.replacer = new IframeStyleReplacer(this.iframe, this.config);
|
|
1066
|
-
// Create navigation blocker
|
|
1067
|
-
this.navigationBlocker = new IframeNavigationBlockerV2(this.iframe);
|
|
1068
|
-
// Run replacement
|
|
1069
|
-
const result = await this.replacer.run();
|
|
1070
|
-
console.log('[IframeHelper] Process completed:', result);
|
|
1071
|
-
// Trigger success callback
|
|
1072
|
-
this.config.onSuccess?.(result);
|
|
1073
|
-
// Dispatch custom event
|
|
1074
|
-
window.dispatchEvent(new CustomEvent('iframe-dimensions-applied', {
|
|
1075
|
-
detail: result,
|
|
1076
|
-
}));
|
|
1077
|
-
}
|
|
1078
|
-
catch (error) {
|
|
1079
|
-
console.error('[IframeHelper] Failed to process:', error);
|
|
1080
|
-
this.config.onError?.(error);
|
|
1081
|
-
}
|
|
1082
|
-
}
|
|
1083
|
-
async recalculate() {
|
|
1084
|
-
console.log('[IframeHelper] Recalculating...');
|
|
1085
|
-
await this.process();
|
|
1086
|
-
}
|
|
1087
|
-
updateConfig(config) {
|
|
1088
|
-
this.config = { ...this.config, ...config };
|
|
1089
|
-
if (this.replacer) {
|
|
1090
|
-
this.replacer.updateConfig(config);
|
|
1091
|
-
}
|
|
1092
|
-
}
|
|
1093
|
-
enableNavigationBlocking() {
|
|
1094
|
-
this.navigationBlocker?.enable();
|
|
1095
|
-
}
|
|
1096
|
-
enableNavigationBlockingMessage() {
|
|
1097
|
-
this.navigationBlocker?.enableMessage();
|
|
1098
|
-
}
|
|
1099
|
-
disableNavigationBlocking() {
|
|
1100
|
-
this.navigationBlocker?.disable();
|
|
1101
|
-
}
|
|
1102
|
-
disableNavigationBlockingMessage() {
|
|
1103
|
-
this.navigationBlocker?.disableMessage();
|
|
1104
|
-
}
|
|
1105
|
-
destroy() {
|
|
1106
|
-
this.replacer = null;
|
|
1107
|
-
this.navigationBlocker?.destroy();
|
|
1108
|
-
this.navigationBlocker = null;
|
|
1109
|
-
console.log('[IframeHelper] Destroyed');
|
|
1110
756
|
}
|
|
1111
757
|
}
|
|
1112
758
|
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
console.log('[IframeHelper] Iframe dimensions finalized:', ev.detail);
|
|
1118
|
-
}));
|
|
1119
|
-
window.addEventListener('iframe-navigation-blocked', ((e) => {
|
|
1120
|
-
const ev = e;
|
|
1121
|
-
console.warn('[IframeHelper] Iframe tried to navigate to:', ev.detail.url);
|
|
1122
|
-
}));
|
|
1123
|
-
window.addEventListener('iframe-form-submit', ((e) => {
|
|
1124
|
-
const ev = e;
|
|
1125
|
-
console.log('[IframeHelper] Iframe form submitted:', ev.detail.data);
|
|
1126
|
-
}));
|
|
1127
|
-
return fixer;
|
|
1128
|
-
}
|
|
759
|
+
var viewportReplacer = /*#__PURE__*/Object.freeze({
|
|
760
|
+
__proto__: null,
|
|
761
|
+
default: ViewportUnitsReplacer
|
|
762
|
+
});
|
|
1129
763
|
|
|
1130
764
|
const scrollToElementIfNeeded = (visualRef, rect, scale) => {
|
|
1131
765
|
if (!visualRef.current)
|
|
@@ -1239,7 +873,7 @@ const useHeatmapEffects = ({ isVisible, isElementSidebarOpen, setShouldShowCallo
|
|
|
1239
873
|
|
|
1240
874
|
const useHeatmapElementPosition = ({ iframeRef, wrapperRef, visualizer }) => {
|
|
1241
875
|
const widthScale = useHeatmapVizStore((state) => state.scale);
|
|
1242
|
-
const iframeHeight =
|
|
876
|
+
const iframeHeight = useHeatmapVizStore((state) => state.iframeHeight);
|
|
1243
877
|
const heatmapWidth = useHeatmapConfigStore((state) => state.width);
|
|
1244
878
|
return useCallback((element) => {
|
|
1245
879
|
const hash = element?.hash;
|
|
@@ -1287,109 +921,6 @@ const debounce = (fn, delay) => {
|
|
|
1287
921
|
};
|
|
1288
922
|
};
|
|
1289
923
|
|
|
1290
|
-
// ===================== UTILITY FUNCTIONS =====================
|
|
1291
|
-
/**
|
|
1292
|
-
* Lấy bounding box tuyệt đối của element (relative to document)
|
|
1293
|
-
*/
|
|
1294
|
-
function getBoundingBox(element) {
|
|
1295
|
-
if (typeof element.getBoundingClientRect !== 'function') {
|
|
1296
|
-
return null;
|
|
1297
|
-
}
|
|
1298
|
-
const rect = element.getBoundingClientRect();
|
|
1299
|
-
// Lấy scroll offset (hỗ trợ cả cách cũ và mới)
|
|
1300
|
-
const scrollLeft = 'pageXOffset' in window ? window.pageXOffset : document.documentElement.scrollLeft;
|
|
1301
|
-
const scrollTop = 'pageYOffset' in window ? window.pageYOffset : document.documentElement.scrollTop;
|
|
1302
|
-
// Kiểm tra element có kích thước hợp lệ
|
|
1303
|
-
if (!rect || (rect.height === 0 && rect.width === 0)) {
|
|
1304
|
-
return null;
|
|
1305
|
-
}
|
|
1306
|
-
// Trả về vị trí tuyệt đối
|
|
1307
|
-
return {
|
|
1308
|
-
left: Math.floor(rect.left + scrollLeft),
|
|
1309
|
-
top: Math.floor(rect.top + scrollTop),
|
|
1310
|
-
width: Math.floor(rect.width),
|
|
1311
|
-
height: Math.floor(rect.height),
|
|
1312
|
-
};
|
|
1313
|
-
}
|
|
1314
|
-
/**
|
|
1315
|
-
* Lấy tất cả elements tại tọa độ (x, y), hỗ trợ Shadow DOM
|
|
1316
|
-
*/
|
|
1317
|
-
function getElementsAtPoint(documentOrShadowRoot, x, y, filterFunction, visitedShadowRoots = new Set()) {
|
|
1318
|
-
// Lấy tất cả elements tại vị trí
|
|
1319
|
-
const elementsAtPoint = documentOrShadowRoot.elementsFromPoint(x, y);
|
|
1320
|
-
if (!filterFunction) {
|
|
1321
|
-
return elementsAtPoint;
|
|
1322
|
-
}
|
|
1323
|
-
// Tìm element đầu tiên match với filter
|
|
1324
|
-
const matchedElement = elementsAtPoint.find(filterFunction);
|
|
1325
|
-
// Nếu element có Shadow DOM và chưa visit -> đệ quy vào
|
|
1326
|
-
if (matchedElement?.shadowRoot && !visitedShadowRoots.has(matchedElement.shadowRoot)) {
|
|
1327
|
-
visitedShadowRoots.add(matchedElement.shadowRoot);
|
|
1328
|
-
return getElementsAtPoint(matchedElement.shadowRoot, x, y, filterFunction, visitedShadowRoots);
|
|
1329
|
-
}
|
|
1330
|
-
return elementsAtPoint;
|
|
1331
|
-
}
|
|
1332
|
-
// ===================== EXAMPLE USAGE =====================
|
|
1333
|
-
/*
|
|
1334
|
-
import { useRef, useState } from 'react';
|
|
1335
|
-
|
|
1336
|
-
function HeatmapComponent() {
|
|
1337
|
-
const heatmapWrapperRef = useRef<HTMLDivElement>(null);
|
|
1338
|
-
const iframeRef = useRef<HTMLIFrameElement>(null);
|
|
1339
|
-
const parentRef = useRef<HTMLDivElement>(null);
|
|
1340
|
-
|
|
1341
|
-
const [hoveredElement, setHoveredElement] = useState<HoveredElementInfo | null>(null);
|
|
1342
|
-
|
|
1343
|
-
const heatmapInfo = {
|
|
1344
|
-
width: 1920,
|
|
1345
|
-
elementMapInfo: {
|
|
1346
|
-
'hash123': {
|
|
1347
|
-
totalclicks: 45,
|
|
1348
|
-
selector: 'button.submit'
|
|
1349
|
-
}
|
|
1350
|
-
},
|
|
1351
|
-
sortedElements: [...]
|
|
1352
|
-
};
|
|
1353
|
-
|
|
1354
|
-
const { handleMouseMove } = useHeatmapMouseHandler({
|
|
1355
|
-
heatmapWrapperRef,
|
|
1356
|
-
iframeRef,
|
|
1357
|
-
parentRef,
|
|
1358
|
-
heatmapInfo,
|
|
1359
|
-
scaleRatio: 0.8, // 80% zoom
|
|
1360
|
-
onElementHover: (info) => {
|
|
1361
|
-
setHoveredElement(info);
|
|
1362
|
-
console.log('Hovered element:', info);
|
|
1363
|
-
}
|
|
1364
|
-
});
|
|
1365
|
-
|
|
1366
|
-
return (
|
|
1367
|
-
<div ref={parentRef}>
|
|
1368
|
-
<div
|
|
1369
|
-
ref={heatmapWrapperRef}
|
|
1370
|
-
onMouseMove={handleMouseMove}
|
|
1371
|
-
>
|
|
1372
|
-
<iframe ref={iframeRef} />
|
|
1373
|
-
|
|
1374
|
-
{hoveredElement && (
|
|
1375
|
-
<div className="tooltip" style={{
|
|
1376
|
-
position: 'absolute',
|
|
1377
|
-
left: hoveredElement.left,
|
|
1378
|
-
top: hoveredElement.top
|
|
1379
|
-
}}>
|
|
1380
|
-
Clicks: {hoveredElement.clicks}
|
|
1381
|
-
<br />
|
|
1382
|
-
Rank: #{hoveredElement.rank}
|
|
1383
|
-
<br />
|
|
1384
|
-
Selector: {hoveredElement.selector}
|
|
1385
|
-
</div>
|
|
1386
|
-
)}
|
|
1387
|
-
</div>
|
|
1388
|
-
</div>
|
|
1389
|
-
);
|
|
1390
|
-
}
|
|
1391
|
-
*/
|
|
1392
|
-
|
|
1393
924
|
const useHoveredElement = ({ iframeRef, getRect }) => {
|
|
1394
925
|
const hoveredElement = useHeatmapInteractionStore((state) => state.hoveredElement);
|
|
1395
926
|
const setHoveredElement = useHeatmapInteractionStore((state) => state.setHoveredElement);
|
|
@@ -1411,7 +942,7 @@ const useHoveredElement = ({ iframeRef, getRect }) => {
|
|
|
1411
942
|
const doc = iframe.contentDocument;
|
|
1412
943
|
const iframeRect = iframe.getBoundingClientRect();
|
|
1413
944
|
const { x, y } = convertViewportToIframeCoords(event.clientX, event.clientY, iframeRect, widthScale);
|
|
1414
|
-
const targetElement = findTargetElement(doc, x, y
|
|
945
|
+
const targetElement = findTargetElement(doc, x, y);
|
|
1415
946
|
if (!targetElement || !isValidElement(targetElement, heatmapInfo)) {
|
|
1416
947
|
reset();
|
|
1417
948
|
return;
|
|
@@ -1462,25 +993,7 @@ const convertViewportToIframeCoords = (clientX, clientY, iframeRect, scale) => {
|
|
|
1462
993
|
}
|
|
1463
994
|
return { x, y };
|
|
1464
995
|
};
|
|
1465
|
-
const findTargetElement = (doc, x, y
|
|
1466
|
-
const HEATMAP_ELEMENT_ATTRIBUTE = 'data-clarity-hashalpha';
|
|
1467
|
-
const elementsAtPoint = getElementsAtPoint(doc, Math.round(x), Math.round(y), (element) => element.hasAttribute(HEATMAP_ELEMENT_ATTRIBUTE));
|
|
1468
|
-
let dataElement = null;
|
|
1469
|
-
for (let i = 0; i < elementsAtPoint.length; i++) {
|
|
1470
|
-
const element = elementsAtPoint[i];
|
|
1471
|
-
const elementHash = element.getAttribute(HEATMAP_ELEMENT_ATTRIBUTE);
|
|
1472
|
-
if (elementHash && heatmapInfo.elementMapInfo?.[elementHash]) {
|
|
1473
|
-
heatmapInfo.elementMapInfo[elementHash];
|
|
1474
|
-
const boundingBox = getBoundingBox(element);
|
|
1475
|
-
if (boundingBox) {
|
|
1476
|
-
dataElement = element;
|
|
1477
|
-
break;
|
|
1478
|
-
}
|
|
1479
|
-
}
|
|
1480
|
-
}
|
|
1481
|
-
if (!!dataElement) {
|
|
1482
|
-
return dataElement;
|
|
1483
|
-
}
|
|
996
|
+
const findTargetElement = (doc, x, y) => {
|
|
1484
997
|
let targetElement = getElementAtPoint(doc, x, y);
|
|
1485
998
|
if (!targetElement) {
|
|
1486
999
|
targetElement = doc.elementFromPoint(x, y);
|
|
@@ -1504,9 +1017,9 @@ var MessageType;
|
|
|
1504
1017
|
MessageType["GX_DOM_TRACKING_PAYLOAD"] = "GX_DOM_TRACKING_PAYLOAD";
|
|
1505
1018
|
MessageType["CLARITY_READY"] = "CLARITY_READY";
|
|
1506
1019
|
})(MessageType || (MessageType = {}));
|
|
1507
|
-
function
|
|
1020
|
+
function useIframeMessage(options = {}) {
|
|
1508
1021
|
const { trustedOrigins = [], onMessage } = options;
|
|
1509
|
-
const
|
|
1022
|
+
const [payloads, setPayloads] = useState([]);
|
|
1510
1023
|
const [isReady, setIsReady] = useState(false);
|
|
1511
1024
|
const iframeRef = useRef(null);
|
|
1512
1025
|
const isValidOrigin = useCallback((origin) => {
|
|
@@ -1532,9 +1045,9 @@ function useVizLiveIframeMsg(options = {}) {
|
|
|
1532
1045
|
switch (message.type) {
|
|
1533
1046
|
case MessageType.GX_DOM_TRACKING_PAYLOAD:
|
|
1534
1047
|
if (message.payload) {
|
|
1535
|
-
const
|
|
1536
|
-
if (
|
|
1537
|
-
|
|
1048
|
+
const decodedPayloads = decodePayloads(message.payload);
|
|
1049
|
+
if (decodedPayloads) {
|
|
1050
|
+
setPayloads((prev) => [...prev, decodedPayloads]);
|
|
1538
1051
|
}
|
|
1539
1052
|
}
|
|
1540
1053
|
break;
|
|
@@ -1549,19 +1062,27 @@ function useVizLiveIframeMsg(options = {}) {
|
|
|
1549
1062
|
window.removeEventListener('message', handleMessage);
|
|
1550
1063
|
};
|
|
1551
1064
|
}, [handleMessage]);
|
|
1065
|
+
const clearPayloads = useCallback(() => {
|
|
1066
|
+
setPayloads([]);
|
|
1067
|
+
}, []);
|
|
1068
|
+
const reset = useCallback(() => {
|
|
1069
|
+
setPayloads([]);
|
|
1070
|
+
setIsReady(false);
|
|
1071
|
+
}, []);
|
|
1552
1072
|
return {
|
|
1553
1073
|
iframeRef,
|
|
1074
|
+
payloads,
|
|
1554
1075
|
isReady,
|
|
1076
|
+
clearPayloads,
|
|
1077
|
+
reset,
|
|
1555
1078
|
};
|
|
1556
1079
|
}
|
|
1557
|
-
|
|
1558
|
-
function useVizLiveRender() {
|
|
1080
|
+
function useIframeRender() {
|
|
1559
1081
|
const wrapperHeight = useHeatmapLiveStore((state) => state.wrapperHeight);
|
|
1560
|
-
const setIframeHeight = useHeatmapLiveStore((state) => state.setIframeHeight);
|
|
1561
1082
|
const contentWidth = useHeatmapConfigStore((state) => state.width);
|
|
1083
|
+
const setIframeHeight = useHeatmapVizStore((state) => state.setIframeHeight);
|
|
1562
1084
|
const htmlContent = useHeatmapLiveStore((state) => state.htmlContent);
|
|
1563
|
-
const
|
|
1564
|
-
const { iframeRef, isReady } = useVizLiveIframeMsg();
|
|
1085
|
+
const { iframeRef, payloads, isReady } = useIframeMessage();
|
|
1565
1086
|
useEffect(() => {
|
|
1566
1087
|
if (!htmlContent || !iframeRef.current)
|
|
1567
1088
|
return;
|
|
@@ -1581,50 +1102,50 @@ function useVizLiveRender() {
|
|
|
1581
1102
|
const iframe = iframeRef.current;
|
|
1582
1103
|
if (!iframe || !htmlContent)
|
|
1583
1104
|
return;
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
height && setIframeHeight(height);
|
|
1587
|
-
setIsRenderViz(true);
|
|
1105
|
+
reset$1(iframe, { width: contentWidth, height: wrapperHeight }, (height) => {
|
|
1106
|
+
setIframeHeight(height);
|
|
1588
1107
|
});
|
|
1589
1108
|
}, [isReady, contentWidth, wrapperHeight]);
|
|
1590
1109
|
return {
|
|
1591
1110
|
iframeRef,
|
|
1111
|
+
payloads,
|
|
1112
|
+
isReady,
|
|
1592
1113
|
};
|
|
1593
1114
|
}
|
|
1594
|
-
function reset(iframe,
|
|
1595
|
-
const
|
|
1596
|
-
targetWidth:
|
|
1597
|
-
targetHeight:
|
|
1115
|
+
function reset$1(iframe, payloads, onSuccess) {
|
|
1116
|
+
const viewportFixer = initViewportFixer({
|
|
1117
|
+
targetWidth: payloads.width,
|
|
1118
|
+
targetHeight: payloads.height,
|
|
1598
1119
|
iframe: iframe,
|
|
1599
1120
|
onSuccess: (data) => {
|
|
1600
|
-
iframe.height = `${data.height}px`;
|
|
1601
1121
|
onSuccess(data.height);
|
|
1122
|
+
iframe.height = `${data.height}px`;
|
|
1602
1123
|
},
|
|
1603
1124
|
});
|
|
1604
|
-
|
|
1605
|
-
|
|
1125
|
+
viewportFixer.recalculate();
|
|
1126
|
+
return iframe;
|
|
1606
1127
|
}
|
|
1607
1128
|
|
|
1608
|
-
let visualizer = new Visualizer();
|
|
1609
1129
|
const useHeatmapRender = () => {
|
|
1610
1130
|
const data = useHeatmapDataStore((state) => state.data);
|
|
1611
|
-
const setVizRef =
|
|
1131
|
+
const setVizRef = useHeatmapVizStore((state) => state.setVizRef);
|
|
1612
1132
|
const setIsRenderViz = useHeatmapVizStore((state) => state.setIsRenderViz);
|
|
1613
|
-
const setIframeHeight =
|
|
1133
|
+
const setIframeHeight = useHeatmapVizStore((state) => state.setIframeHeight);
|
|
1614
1134
|
const iframeRef = useRef(null);
|
|
1615
1135
|
const renderHeatmap = useCallback(async (payloads) => {
|
|
1616
1136
|
if (!payloads || payloads.length === 0)
|
|
1617
1137
|
return;
|
|
1618
1138
|
setIsRenderViz(false);
|
|
1139
|
+
const visualizer = new Visualizer();
|
|
1619
1140
|
const iframe = iframeRef.current;
|
|
1620
1141
|
if (!iframe?.contentWindow)
|
|
1621
1142
|
return;
|
|
1622
1143
|
await visualizer.html(payloads, iframe.contentWindow);
|
|
1623
|
-
|
|
1144
|
+
reset(iframe, payloads, (height) => {
|
|
1624
1145
|
height && setIframeHeight(height);
|
|
1625
1146
|
setIsRenderViz(true);
|
|
1626
|
-
setVizRef(visualizer);
|
|
1627
1147
|
});
|
|
1148
|
+
setVizRef(visualizer);
|
|
1628
1149
|
}, []);
|
|
1629
1150
|
useEffect(() => {
|
|
1630
1151
|
if (!data || data.length === 0)
|
|
@@ -1638,20 +1159,21 @@ const useHeatmapRender = () => {
|
|
|
1638
1159
|
iframeRef,
|
|
1639
1160
|
};
|
|
1640
1161
|
};
|
|
1641
|
-
function
|
|
1162
|
+
function reset(iframe, payloads, onSuccess) {
|
|
1642
1163
|
const { size } = findLastSizeOfDom(payloads);
|
|
1643
1164
|
const docWidth = size.width ?? 0;
|
|
1644
1165
|
const docHeight = size.height ?? 0;
|
|
1645
|
-
|
|
1166
|
+
const viewportFixer = initViewportFixer({
|
|
1646
1167
|
targetWidth: docWidth,
|
|
1647
1168
|
targetHeight: docHeight,
|
|
1648
1169
|
iframe: iframe,
|
|
1649
1170
|
onSuccess: (data) => {
|
|
1650
|
-
iframe.height = `${data.height}px`;
|
|
1651
1171
|
onSuccess(data.height);
|
|
1172
|
+
iframe.height = `${data.height}px`;
|
|
1652
1173
|
},
|
|
1653
1174
|
});
|
|
1654
|
-
|
|
1175
|
+
viewportFixer.recalculate();
|
|
1176
|
+
return iframe;
|
|
1655
1177
|
}
|
|
1656
1178
|
|
|
1657
1179
|
function isMobileDevice(userAgent) {
|
|
@@ -1836,64 +1358,30 @@ const useContentDimensions = ({ iframeRef, }) => {
|
|
|
1836
1358
|
return { contentWidth };
|
|
1837
1359
|
};
|
|
1838
1360
|
|
|
1839
|
-
const
|
|
1361
|
+
const useIframeHeight = (props) => {
|
|
1840
1362
|
const { iframeRef, setIframeHeight } = props;
|
|
1841
1363
|
const isRenderViz = useHeatmapVizStore((state) => state.isRenderViz);
|
|
1842
1364
|
const resizeObserverRef = useRef(null);
|
|
1843
1365
|
const mutationObserverRef = useRef(null);
|
|
1844
|
-
const debounceTimerRef = useRef(null);
|
|
1845
|
-
const lastHeightRef = useRef(0);
|
|
1846
|
-
const animationFrameRef = useRef(null);
|
|
1847
1366
|
const updateIframeHeight = useCallback(() => {
|
|
1848
1367
|
const iframe = iframeRef.current;
|
|
1849
|
-
if (!iframe
|
|
1368
|
+
if (!iframe)
|
|
1850
1369
|
return;
|
|
1851
1370
|
try {
|
|
1852
1371
|
const iframeDocument = iframe.contentDocument;
|
|
1853
1372
|
const iframeBody = iframeDocument?.body;
|
|
1854
|
-
|
|
1855
|
-
if (!iframeBody || !iframeDocumentElement)
|
|
1373
|
+
if (!iframeBody)
|
|
1856
1374
|
return;
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
if (actualHeight > 0) {
|
|
1863
|
-
lastHeightRef.current = actualHeight;
|
|
1864
|
-
iframe.height = `${actualHeight}px`;
|
|
1865
|
-
iframe.style.height = `${actualHeight}px`;
|
|
1866
|
-
setIframeHeight(actualHeight);
|
|
1867
|
-
}
|
|
1868
|
-
});
|
|
1375
|
+
const bodyHeight = Math.max(iframeBody.scrollHeight, iframeBody.offsetHeight, iframeBody.clientHeight);
|
|
1376
|
+
if (bodyHeight > 0) {
|
|
1377
|
+
iframe.height = `${bodyHeight}px`;
|
|
1378
|
+
setIframeHeight(bodyHeight);
|
|
1379
|
+
}
|
|
1869
1380
|
}
|
|
1870
1381
|
catch (error) {
|
|
1871
1382
|
console.warn('Cannot measure iframe content:', error);
|
|
1872
1383
|
}
|
|
1873
1384
|
}, [iframeRef, setIframeHeight]);
|
|
1874
|
-
const debouncedUpdate = useCallback(() => {
|
|
1875
|
-
// Cancel pending updates
|
|
1876
|
-
if (debounceTimerRef.current) {
|
|
1877
|
-
clearTimeout(debounceTimerRef.current);
|
|
1878
|
-
}
|
|
1879
|
-
if (animationFrameRef.current) {
|
|
1880
|
-
cancelAnimationFrame(animationFrameRef.current);
|
|
1881
|
-
}
|
|
1882
|
-
debounceTimerRef.current = setTimeout(() => {
|
|
1883
|
-
animationFrameRef.current = requestAnimationFrame(() => {
|
|
1884
|
-
updateIframeHeight();
|
|
1885
|
-
});
|
|
1886
|
-
}, 50);
|
|
1887
|
-
}, [updateIframeHeight]);
|
|
1888
|
-
// Immediate update không debounce (cho ResizeObserver)
|
|
1889
|
-
const immediateUpdate = useCallback(() => {
|
|
1890
|
-
if (animationFrameRef.current) {
|
|
1891
|
-
cancelAnimationFrame(animationFrameRef.current);
|
|
1892
|
-
}
|
|
1893
|
-
animationFrameRef.current = requestAnimationFrame(() => {
|
|
1894
|
-
updateIframeHeight();
|
|
1895
|
-
});
|
|
1896
|
-
}, [updateIframeHeight]);
|
|
1897
1385
|
useEffect(() => {
|
|
1898
1386
|
const iframe = iframeRef.current;
|
|
1899
1387
|
if (!iframe || !isRenderViz)
|
|
@@ -1911,24 +1399,22 @@ const useObserveIframeHeight = (props) => {
|
|
|
1911
1399
|
if (mutationObserverRef.current) {
|
|
1912
1400
|
mutationObserverRef.current.disconnect();
|
|
1913
1401
|
}
|
|
1402
|
+
// ResizeObserver for size changes
|
|
1914
1403
|
if (typeof window.ResizeObserver !== 'undefined') {
|
|
1915
|
-
resizeObserverRef.current = new ResizeObserver(
|
|
1404
|
+
resizeObserverRef.current = new ResizeObserver(updateIframeHeight);
|
|
1916
1405
|
resizeObserverRef.current.observe(iframeBody);
|
|
1917
|
-
const iframeDocumentElement = iframeDocument?.documentElement;
|
|
1918
|
-
if (iframeDocumentElement) {
|
|
1919
|
-
resizeObserverRef.current.observe(iframeDocumentElement);
|
|
1920
|
-
}
|
|
1921
1406
|
}
|
|
1407
|
+
// MutationObserver for DOM changes
|
|
1922
1408
|
if (typeof window.MutationObserver !== 'undefined') {
|
|
1923
|
-
mutationObserverRef.current = new MutationObserver(
|
|
1409
|
+
mutationObserverRef.current = new MutationObserver(updateIframeHeight);
|
|
1924
1410
|
mutationObserverRef.current.observe(iframeBody, {
|
|
1925
1411
|
childList: true,
|
|
1926
1412
|
subtree: true,
|
|
1927
1413
|
attributes: true,
|
|
1928
|
-
|
|
1929
|
-
characterData: false,
|
|
1414
|
+
characterData: true,
|
|
1930
1415
|
});
|
|
1931
1416
|
}
|
|
1417
|
+
// Initial measurement
|
|
1932
1418
|
updateIframeHeight();
|
|
1933
1419
|
}
|
|
1934
1420
|
catch (error) {
|
|
@@ -1942,23 +1428,15 @@ const useObserveIframeHeight = (props) => {
|
|
|
1942
1428
|
iframe.addEventListener('load', setupObservers, { once: true });
|
|
1943
1429
|
}
|
|
1944
1430
|
return () => {
|
|
1945
|
-
// Cleanup observers
|
|
1946
1431
|
if (resizeObserverRef.current) {
|
|
1947
1432
|
resizeObserverRef.current.disconnect();
|
|
1948
1433
|
}
|
|
1949
1434
|
if (mutationObserverRef.current) {
|
|
1950
1435
|
mutationObserverRef.current.disconnect();
|
|
1951
1436
|
}
|
|
1952
|
-
// Cleanup timers
|
|
1953
|
-
if (debounceTimerRef.current) {
|
|
1954
|
-
clearTimeout(debounceTimerRef.current);
|
|
1955
|
-
}
|
|
1956
|
-
if (animationFrameRef.current) {
|
|
1957
|
-
cancelAnimationFrame(animationFrameRef.current);
|
|
1958
|
-
}
|
|
1959
1437
|
iframe.removeEventListener('load', setupObservers);
|
|
1960
1438
|
};
|
|
1961
|
-
}, [iframeRef, isRenderViz, updateIframeHeight
|
|
1439
|
+
}, [iframeRef, isRenderViz, updateIframeHeight]);
|
|
1962
1440
|
return {};
|
|
1963
1441
|
};
|
|
1964
1442
|
|
|
@@ -2004,18 +1482,16 @@ const useHeatmapScale = (props) => {
|
|
|
2004
1482
|
// 2. Get content dimensions from config
|
|
2005
1483
|
const { contentWidth } = useContentDimensions({ iframeRef });
|
|
2006
1484
|
// 3. Observe iframe height (now reacts to width changes)
|
|
2007
|
-
|
|
1485
|
+
useIframeHeight({ iframeRef, setIframeHeight });
|
|
2008
1486
|
// 4. Calculate scale
|
|
2009
1487
|
const { scale } = useScaleCalculation({ containerWidth, contentWidth });
|
|
2010
1488
|
// 5. Setup scroll sync
|
|
2011
1489
|
const { handleScroll } = useScrollSync({ iframeRef });
|
|
2012
|
-
const scaledHeight = iframeHeight * scale;
|
|
2013
|
-
const scaledWidth = contentWidth * scale;
|
|
2014
1490
|
return {
|
|
2015
1491
|
containerWidth,
|
|
2016
1492
|
containerHeight,
|
|
2017
|
-
scaledWidth,
|
|
2018
|
-
scaledHeight,
|
|
1493
|
+
scaledWidth: contentWidth * scale,
|
|
1494
|
+
scaledHeight: iframeHeight * scale,
|
|
2019
1495
|
handleScroll,
|
|
2020
1496
|
};
|
|
2021
1497
|
};
|
|
@@ -2089,135 +1565,6 @@ const useWrapperRefHeight = (props) => {
|
|
|
2089
1565
|
return {};
|
|
2090
1566
|
};
|
|
2091
1567
|
|
|
2092
|
-
const useZonePositions = (options) => {
|
|
2093
|
-
const iframeHeight = useHeatmapSingleStore((state) => state.iframeHeight);
|
|
2094
|
-
const getZonePosition = useCallback((zone) => {
|
|
2095
|
-
if (!iframeHeight) {
|
|
2096
|
-
return null;
|
|
2097
|
-
}
|
|
2098
|
-
const startYPx = (zone.startY / 100) * iframeHeight;
|
|
2099
|
-
const heightPx = ((zone.endY - zone.startY) / 100) * iframeHeight;
|
|
2100
|
-
return {
|
|
2101
|
-
top: startYPx,
|
|
2102
|
-
height: heightPx,
|
|
2103
|
-
};
|
|
2104
|
-
}, [iframeHeight]);
|
|
2105
|
-
return {
|
|
2106
|
-
getZonePosition,
|
|
2107
|
-
};
|
|
2108
|
-
};
|
|
2109
|
-
|
|
2110
|
-
const SCROLL_GRADIENT_COLORS = [
|
|
2111
|
-
[255, 0, 0], // Red
|
|
2112
|
-
[255, 255, 0], // Yellow
|
|
2113
|
-
[0, 255, 0], // Green
|
|
2114
|
-
];
|
|
2115
|
-
const useScrollmapZones = (options) => {
|
|
2116
|
-
const { mode = 'basic', enabled = true, iframeRef, wrapperRef } = options;
|
|
2117
|
-
const [isReady, setIsReady] = useState(false);
|
|
2118
|
-
const [zones, setZones] = useState([]);
|
|
2119
|
-
const scrollmap = useHeatmapDataStore((state) => state.scrollmap);
|
|
2120
|
-
const scrollMapInfo = useHeatmapDataStore((state) => state.dataInfo?.scrollMapInfo);
|
|
2121
|
-
const { getZonePosition } = useZonePositions();
|
|
2122
|
-
const maxUsers = useMemo(() => {
|
|
2123
|
-
if (!scrollmap || scrollmap.length === 0)
|
|
2124
|
-
return 100;
|
|
2125
|
-
return Math.max(...scrollmap.map((d) => d.percUsers));
|
|
2126
|
-
}, [scrollmap]);
|
|
2127
|
-
const createZones = useCallback((data) => {
|
|
2128
|
-
if (mode === 'basic') {
|
|
2129
|
-
const breakpoints = [0, 25, 50, 75, 100];
|
|
2130
|
-
const zones = [];
|
|
2131
|
-
for (let i = 0; i < breakpoints.length - 1; i++) {
|
|
2132
|
-
const startY = breakpoints[i];
|
|
2133
|
-
const endY = breakpoints[i + 1];
|
|
2134
|
-
const pointsInRange = data.filter((d) => d.scrollReachY >= startY && d.scrollReachY < endY);
|
|
2135
|
-
const avgUsers = pointsInRange.length > 0
|
|
2136
|
-
? pointsInRange.reduce((sum, p) => sum + p.percUsers, 0) / pointsInRange.length
|
|
2137
|
-
: 0;
|
|
2138
|
-
zones.push({
|
|
2139
|
-
id: `zone_${startY}_${endY}`,
|
|
2140
|
-
startY,
|
|
2141
|
-
endY,
|
|
2142
|
-
percUsers: avgUsers,
|
|
2143
|
-
label: `${startY}% - ${endY}%`,
|
|
2144
|
-
});
|
|
2145
|
-
}
|
|
2146
|
-
return zones;
|
|
2147
|
-
}
|
|
2148
|
-
else {
|
|
2149
|
-
// Metrics mode: 20 zones (5% intervals)
|
|
2150
|
-
const zones = [];
|
|
2151
|
-
const interval = 5;
|
|
2152
|
-
// Prepare metrics map
|
|
2153
|
-
let metricsMap;
|
|
2154
|
-
if (scrollMapInfo && Object.keys(scrollMapInfo).length > 0) {
|
|
2155
|
-
metricsMap = new Map();
|
|
2156
|
-
Object.entries(scrollMapInfo).forEach(([key, value]) => {
|
|
2157
|
-
metricsMap.set(Number(key), value);
|
|
2158
|
-
});
|
|
2159
|
-
}
|
|
2160
|
-
for (let i = 0; i < 100; i += interval) {
|
|
2161
|
-
const startY = i;
|
|
2162
|
-
const endY = i + interval;
|
|
2163
|
-
const point = data.find((d) => d.scrollReachY === startY) || {
|
|
2164
|
-
scrollReachY: startY,
|
|
2165
|
-
cumulativeSum: 0,
|
|
2166
|
-
percUsers: 0,
|
|
2167
|
-
};
|
|
2168
|
-
const metrics = metricsMap?.get(startY);
|
|
2169
|
-
zones.push({
|
|
2170
|
-
id: `zone_${startY}_${endY}`,
|
|
2171
|
-
startY,
|
|
2172
|
-
endY,
|
|
2173
|
-
percUsers: point.percUsers,
|
|
2174
|
-
metrics,
|
|
2175
|
-
label: `${startY}% - ${endY}%`,
|
|
2176
|
-
});
|
|
2177
|
-
}
|
|
2178
|
-
return zones;
|
|
2179
|
-
}
|
|
2180
|
-
}, [mode, scrollMapInfo]);
|
|
2181
|
-
/**
|
|
2182
|
-
* Initialize zones
|
|
2183
|
-
*/
|
|
2184
|
-
useEffect(() => {
|
|
2185
|
-
if (!enabled || !scrollmap || scrollmap.length === 0) {
|
|
2186
|
-
setIsReady(false);
|
|
2187
|
-
return;
|
|
2188
|
-
}
|
|
2189
|
-
try {
|
|
2190
|
-
const newZones = createZones(scrollmap);
|
|
2191
|
-
setZones(newZones);
|
|
2192
|
-
setIsReady(true);
|
|
2193
|
-
console.log(`[useScrollmap] Created ${newZones.length} zones in ${mode} mode`);
|
|
2194
|
-
}
|
|
2195
|
-
catch (error) {
|
|
2196
|
-
console.error('[useScrollmap] Error:', error);
|
|
2197
|
-
setIsReady(false);
|
|
2198
|
-
}
|
|
2199
|
-
}, [enabled, scrollmap, mode, createZones]);
|
|
2200
|
-
return {
|
|
2201
|
-
zones,
|
|
2202
|
-
isReady,
|
|
2203
|
-
maxUsers,
|
|
2204
|
-
getZonePosition,
|
|
2205
|
-
};
|
|
2206
|
-
};
|
|
2207
|
-
/**
|
|
2208
|
-
* Get scroll gradient color for minimap
|
|
2209
|
-
*/
|
|
2210
|
-
const getScrollGradientColor = (normalized) => {
|
|
2211
|
-
const idx = Math.min(Math.floor(normalized * 2), 1);
|
|
2212
|
-
const [r1, g1, b1] = SCROLL_GRADIENT_COLORS[idx];
|
|
2213
|
-
const [r2, g2, b2] = SCROLL_GRADIENT_COLORS[idx + 1];
|
|
2214
|
-
const localPercent = (normalized * 2) % 1;
|
|
2215
|
-
const r = Math.round(r1 + (r2 - r1) * localPercent);
|
|
2216
|
-
const g = Math.round(g1 + (g2 - g1) * localPercent);
|
|
2217
|
-
const b = Math.round(b1 + (b2 - b1) * localPercent);
|
|
2218
|
-
return `rgb(${r}, ${g}, ${b})`;
|
|
2219
|
-
};
|
|
2220
|
-
|
|
2221
1568
|
const BoxStack = forwardRef(({ children, ...props }, ref) => {
|
|
2222
1569
|
const id = props.id;
|
|
2223
1570
|
const flexDirection = props.flexDirection;
|
|
@@ -2304,57 +1651,35 @@ const VizContainer = ({ children, setWrapperHeight }) => {
|
|
|
2304
1651
|
const useClickmap = () => {
|
|
2305
1652
|
const [isInitialized, setIsInitialized] = useState(false);
|
|
2306
1653
|
const clickmap = useHeatmapDataStore((state) => state.clickmap);
|
|
2307
|
-
const vizRef =
|
|
2308
|
-
|
|
1654
|
+
const vizRef = useHeatmapVizStore((state) => state.vizRef);
|
|
1655
|
+
useEffect(() => {
|
|
2309
1656
|
if (isInitialized)
|
|
2310
1657
|
return;
|
|
2311
1658
|
if (!vizRef || !clickmap || clickmap.length === 0)
|
|
2312
1659
|
return;
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
setIsInitialized(true);
|
|
2317
|
-
}
|
|
2318
|
-
catch (error) {
|
|
2319
|
-
console.error(`🚀 🐥 ~ useClickmap ~ error:`, error);
|
|
2320
|
-
}
|
|
1660
|
+
vizRef.clearmap();
|
|
1661
|
+
vizRef?.clickmap(clickmap);
|
|
1662
|
+
setIsInitialized(true);
|
|
2321
1663
|
}, [vizRef, clickmap]);
|
|
2322
|
-
return {
|
|
1664
|
+
return {};
|
|
2323
1665
|
};
|
|
2324
1666
|
|
|
2325
1667
|
const useScrollmap = () => {
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
const start = useCallback(() => {
|
|
2329
|
-
// if (isInitialized) return;
|
|
2330
|
-
if (!vizRef || !scrollmap || scrollmap.length === 0)
|
|
2331
|
-
return;
|
|
2332
|
-
try {
|
|
2333
|
-
vizRef?.clearmap?.();
|
|
2334
|
-
vizRef?.scrollmap?.(scrollmap);
|
|
2335
|
-
// setIsInitialized(true);
|
|
2336
|
-
}
|
|
2337
|
-
catch (error) {
|
|
2338
|
-
console.error(`🚀 🐥 ~ useScrollmap ~ error:`, error);
|
|
2339
|
-
}
|
|
2340
|
-
}, [vizRef, scrollmap]);
|
|
2341
|
-
return { start };
|
|
1668
|
+
useHeatmapDataStore((state) => state.clickmap);
|
|
1669
|
+
return {};
|
|
2342
1670
|
};
|
|
2343
1671
|
|
|
2344
|
-
const
|
|
1672
|
+
const useHeatmapVizCanvas = () => {
|
|
2345
1673
|
const heatmapType = useHeatmapConfigStore((state) => state.heatmapType);
|
|
2346
|
-
const
|
|
2347
|
-
const { start: startScrollmap } = useScrollmap();
|
|
2348
|
-
useEffect(() => {
|
|
1674
|
+
const heatmapRender = useMemo(() => {
|
|
2349
1675
|
switch (heatmapType) {
|
|
2350
1676
|
case IHeatmapType.Click:
|
|
2351
|
-
|
|
2352
|
-
break;
|
|
1677
|
+
return useClickmap;
|
|
2353
1678
|
case IHeatmapType.Scroll:
|
|
2354
|
-
|
|
2355
|
-
break;
|
|
1679
|
+
return useScrollmap;
|
|
2356
1680
|
}
|
|
2357
|
-
}, [heatmapType
|
|
1681
|
+
}, [heatmapType]);
|
|
1682
|
+
return heatmapRender?.();
|
|
2358
1683
|
};
|
|
2359
1684
|
|
|
2360
1685
|
const CLICKED_ELEMENT_ID = 'gx-hm-clicked-element';
|
|
@@ -2417,7 +1742,7 @@ const ElementCallout = (props) => {
|
|
|
2417
1742
|
window.removeEventListener('resize', handleUpdate);
|
|
2418
1743
|
visualRef?.current?.removeEventListener('scroll', handleUpdate);
|
|
2419
1744
|
};
|
|
2420
|
-
}, [
|
|
1745
|
+
}, [target, visualRef, hozOffset, alignment]);
|
|
2421
1746
|
const calloutContent = (jsx("div", { ref: calloutRef, className: `clarity-callout clarity-callout--${position.placement} clarity-callout--align-${position.horizontalAlign}`, style: {
|
|
2422
1747
|
position: 'fixed',
|
|
2423
1748
|
top: position.top,
|
|
@@ -2482,8 +1807,8 @@ const ELEMENT_CALLOUT = {
|
|
|
2482
1807
|
alignment: 'left',
|
|
2483
1808
|
};
|
|
2484
1809
|
const HeatmapElements = (props) => {
|
|
2485
|
-
const
|
|
2486
|
-
const { iframeRef, wrapperRef, visualRef, visualizer, iframeDimensions, isElementSidebarOpen, isVisible = true, areDefaultRanksHidden, isSecondary, } = props;
|
|
1810
|
+
const height = useHeatmapVizStore((state) => state.iframeHeight);
|
|
1811
|
+
const { iframeRef, wrapperRef, visualRef, visualizer, iframeDimensions, isElementSidebarOpen, isVisible = true, areDefaultRanksHidden, isSecondary, ...rest } = props;
|
|
2487
1812
|
const getRect = useHeatmapElementPosition({
|
|
2488
1813
|
iframeRef,
|
|
2489
1814
|
wrapperRef,
|
|
@@ -2512,21 +1837,14 @@ const HeatmapElements = (props) => {
|
|
|
2512
1837
|
});
|
|
2513
1838
|
if (!isVisible)
|
|
2514
1839
|
return null;
|
|
2515
|
-
return (jsxs("div", { onMouseMove: (
|
|
2516
|
-
handleMouseMove(event);
|
|
2517
|
-
// handleMouseMove2(event as any);
|
|
2518
|
-
}, onMouseLeave: handleMouseLeave, className: "gx-hm-elements", style: { ...iframeDimensions, height: `${iframeHeight}px` }, children: [jsx(ElementMissing, { show: showMissingElement }), jsx(DefaultRankBadges, { getRect: getRect, hidden: areDefaultRanksHidden }), jsx(ElementOverlay, { type: "clicked", element: clickedElement, isSecondary: isSecondary }), jsx(ElementOverlay, { type: "hovered", element: hoveredElement, isSecondary: isSecondary, onClick: handleClick }), hoveredElement?.hash !== clickedElement?.hash && hoveredElement && (jsx(ElementCallout, { element: hoveredElement, target: `#${HOVERED_ELEMENT_ID}`, visualRef: visualRef, ...ELEMENT_CALLOUT })), shouldShowCallout && clickedElement && (jsx(ElementCallout, { element: clickedElement, target: `#${CLICKED_ELEMENT_ID}`, visualRef: visualRef, ...ELEMENT_CALLOUT }))] }));
|
|
1840
|
+
return (jsxs("div", { onMouseMove: handleMouseMove, onMouseLeave: handleMouseLeave, className: "gx-hm-elements", style: { ...iframeDimensions, height }, children: [jsx(ElementMissing, { show: showMissingElement }), jsx(DefaultRankBadges, { getRect: getRect, hidden: areDefaultRanksHidden }), jsx(ElementOverlay, { type: "clicked", element: clickedElement, isSecondary: isSecondary }), jsx(ElementOverlay, { type: "hovered", element: hoveredElement, isSecondary: isSecondary, onClick: handleClick }), hoveredElement?.hash !== clickedElement?.hash && hoveredElement && (jsx(ElementCallout, { element: hoveredElement, target: `#${HOVERED_ELEMENT_ID}`, visualRef: visualRef, ...ELEMENT_CALLOUT })), shouldShowCallout && clickedElement && (jsx(ElementCallout, { element: clickedElement, target: `#${CLICKED_ELEMENT_ID}`, visualRef: visualRef, ...ELEMENT_CALLOUT }))] }));
|
|
2519
1841
|
};
|
|
2520
1842
|
|
|
2521
1843
|
const VizElements = ({ iframeRef, visualRef, wrapperRef }) => {
|
|
2522
1844
|
const heatmapInfo = useHeatmapDataStore((state) => state.dataInfo);
|
|
2523
|
-
const contentWidth =
|
|
2524
|
-
const vizRef = useHeatmapSingleStore((state) => state.vizRef);
|
|
1845
|
+
const contentWidth = useHeatmapDataStore((state) => state.config?.width ?? 0);
|
|
2525
1846
|
const visualizer = {
|
|
2526
1847
|
get: (hash) => {
|
|
2527
|
-
if (vizRef) {
|
|
2528
|
-
return vizRef.get(hash);
|
|
2529
|
-
}
|
|
2530
1848
|
const doc = iframeRef.current?.contentDocument;
|
|
2531
1849
|
if (!doc)
|
|
2532
1850
|
return null;
|
|
@@ -2552,293 +1870,6 @@ const VizElements = ({ iframeRef, visualRef, wrapperRef }) => {
|
|
|
2552
1870
|
} }));
|
|
2553
1871
|
};
|
|
2554
1872
|
|
|
2555
|
-
const AverageFoldLine = ({ iframeRef, wrapperRef }) => {
|
|
2556
|
-
const averageFold = useHeatmapDataStore((state) => state.dataInfo?.averageFold || 50);
|
|
2557
|
-
const { getZonePosition } = useZonePositions();
|
|
2558
|
-
const position = getZonePosition({
|
|
2559
|
-
startY: averageFold,
|
|
2560
|
-
endY: averageFold,
|
|
2561
|
-
});
|
|
2562
|
-
if (!position)
|
|
2563
|
-
return null;
|
|
2564
|
-
return (jsx("div", { style: {
|
|
2565
|
-
position: 'absolute',
|
|
2566
|
-
top: `${position.top}px`,
|
|
2567
|
-
left: 0,
|
|
2568
|
-
width: '100%',
|
|
2569
|
-
height: '2px',
|
|
2570
|
-
backgroundColor: '#0078D4',
|
|
2571
|
-
pointerEvents: 'none',
|
|
2572
|
-
zIndex: 2,
|
|
2573
|
-
boxShadow: '0 0 4px rgba(0,120,212,0.5)',
|
|
2574
|
-
display: 'flex',
|
|
2575
|
-
alignItems: 'center',
|
|
2576
|
-
}, children: jsxs("div", { style: {
|
|
2577
|
-
position: 'absolute',
|
|
2578
|
-
padding: '8px',
|
|
2579
|
-
backgroundColor: 'rgba(0, 120, 212, 0.9)',
|
|
2580
|
-
color: 'white',
|
|
2581
|
-
fontSize: '16px',
|
|
2582
|
-
fontWeight: 600,
|
|
2583
|
-
borderRadius: '4px',
|
|
2584
|
-
whiteSpace: 'nowrap',
|
|
2585
|
-
left: '12px',
|
|
2586
|
-
minWidth: '120px',
|
|
2587
|
-
textAlign: 'center',
|
|
2588
|
-
}, children: ["Average fold - ", averageFold.toFixed(0), "%"] }) }));
|
|
2589
|
-
};
|
|
2590
|
-
|
|
2591
|
-
const ScrollmapMarker = ({ iframeRef, wrapperRef }) => {
|
|
2592
|
-
const scrollmap = useHeatmapDataStore((state) => state.scrollmap);
|
|
2593
|
-
const scrollType = useHeatmapConfigStore((state) => state.scrollType);
|
|
2594
|
-
const { getZonePosition } = useZonePositions();
|
|
2595
|
-
if (!scrollmap || scrollmap.length === 0)
|
|
2596
|
-
return null;
|
|
2597
|
-
const findScrollPositionForUserPercent = (targetPercent) => {
|
|
2598
|
-
for (let i = 0; i < scrollmap.length; i++) {
|
|
2599
|
-
if (scrollmap[i].percUsers <= targetPercent) {
|
|
2600
|
-
if (i > 0) {
|
|
2601
|
-
return scrollmap[i - 1].scrollReachY;
|
|
2602
|
-
}
|
|
2603
|
-
return scrollmap[i].scrollReachY;
|
|
2604
|
-
}
|
|
2605
|
-
}
|
|
2606
|
-
return scrollmap[scrollmap.length - 1]?.scrollReachY || null;
|
|
2607
|
-
};
|
|
2608
|
-
const boundaries = [
|
|
2609
|
-
{ percent: 75, label: '75%', color: '#10B981' },
|
|
2610
|
-
{ percent: 50, label: '50%', color: '#F59E0B' },
|
|
2611
|
-
{ percent: 25, label: '25%', color: '#EF4444' },
|
|
2612
|
-
{ percent: 5, label: '5%', color: '#8B5CF6' },
|
|
2613
|
-
];
|
|
2614
|
-
const isScrollDepth = scrollType === IScrollType.Depth;
|
|
2615
|
-
if (!isScrollDepth)
|
|
2616
|
-
return null;
|
|
2617
|
-
return (jsx(Fragment, { children: boundaries.map((boundary) => {
|
|
2618
|
-
const scrollY = findScrollPositionForUserPercent(boundary.percent);
|
|
2619
|
-
if (scrollY === null)
|
|
2620
|
-
return null;
|
|
2621
|
-
const position = getZonePosition({
|
|
2622
|
-
startY: scrollY,
|
|
2623
|
-
endY: scrollY,
|
|
2624
|
-
});
|
|
2625
|
-
if (!position)
|
|
2626
|
-
return null;
|
|
2627
|
-
return (jsx("div", { className: `marker-boundary-line-${boundary.percent}`, style: {
|
|
2628
|
-
position: 'absolute',
|
|
2629
|
-
top: `${position.top}px`,
|
|
2630
|
-
left: 0,
|
|
2631
|
-
transformOrigin: 'left center',
|
|
2632
|
-
width: '100%',
|
|
2633
|
-
height: '0px',
|
|
2634
|
-
// borderBottom: `2px dashed #323130`,
|
|
2635
|
-
borderBottom: `2px solid ${boundary.color}`,
|
|
2636
|
-
// background: 'repeating-linear-gradient(90deg, #323130, transparent 2px 3px)',
|
|
2637
|
-
zIndex: 1,
|
|
2638
|
-
display: 'flex',
|
|
2639
|
-
alignItems: 'center',
|
|
2640
|
-
}, children: jsx("div", { style: {
|
|
2641
|
-
position: 'absolute',
|
|
2642
|
-
padding: '8px',
|
|
2643
|
-
backgroundColor: boundary.color,
|
|
2644
|
-
color: 'white',
|
|
2645
|
-
fontSize: '16px',
|
|
2646
|
-
fontWeight: 600,
|
|
2647
|
-
borderRadius: '4px',
|
|
2648
|
-
whiteSpace: 'nowrap',
|
|
2649
|
-
left: '12px',
|
|
2650
|
-
minWidth: '120px',
|
|
2651
|
-
textAlign: 'center',
|
|
2652
|
-
// textAlign: 'center',
|
|
2653
|
-
// padding: '8px',
|
|
2654
|
-
// paddingInline: '8px',
|
|
2655
|
-
// fontSize: '16px',
|
|
2656
|
-
// background: '#fff',
|
|
2657
|
-
// width: 'auto',
|
|
2658
|
-
// borderRadius: '4px',
|
|
2659
|
-
// position: 'absolute',
|
|
2660
|
-
// left: '12px',
|
|
2661
|
-
// minWidth: '120px',
|
|
2662
|
-
}, children: boundary.label }) }, boundary.label));
|
|
2663
|
-
}) }));
|
|
2664
|
-
};
|
|
2665
|
-
|
|
2666
|
-
const ScrollMapMinimap = ({ zones, maxUsers }) => {
|
|
2667
|
-
const showMinimap = useHeatmapVizScrollmapStore((state) => state.showMinimap);
|
|
2668
|
-
const scrollType = useHeatmapConfigStore((state) => state.scrollType);
|
|
2669
|
-
const isScrollType = [IScrollType.Attention].includes(scrollType);
|
|
2670
|
-
if (!showMinimap || !isScrollType)
|
|
2671
|
-
return null;
|
|
2672
|
-
return (jsx("div", { style: {
|
|
2673
|
-
position: 'fixed',
|
|
2674
|
-
left: '20px',
|
|
2675
|
-
top: '50%',
|
|
2676
|
-
transform: 'translateY(-50%)',
|
|
2677
|
-
width: '60px',
|
|
2678
|
-
height: '400px',
|
|
2679
|
-
backgroundColor: 'white',
|
|
2680
|
-
borderRadius: '8px',
|
|
2681
|
-
boxShadow: '0 4px 16px rgba(0,0,0,0.15)',
|
|
2682
|
-
zIndex: 10002,
|
|
2683
|
-
padding: '8px',
|
|
2684
|
-
boxSizing: 'border-box',
|
|
2685
|
-
}, children: jsx("div", { style: {
|
|
2686
|
-
width: '100%',
|
|
2687
|
-
height: '100%',
|
|
2688
|
-
borderRadius: '4px',
|
|
2689
|
-
overflow: 'hidden',
|
|
2690
|
-
display: 'flex',
|
|
2691
|
-
flexDirection: 'column',
|
|
2692
|
-
}, children: zones.map((zone) => {
|
|
2693
|
-
const normalized = maxUsers > 0 ? zone.percUsers / maxUsers : 0;
|
|
2694
|
-
const color = getScrollGradientColor(normalized);
|
|
2695
|
-
return (jsx("div", { title: `${zone.label}: ${zone.percUsers.toFixed(2)}%`, style: {
|
|
2696
|
-
width: '100%',
|
|
2697
|
-
flex: `${zone.endY - zone.startY}`,
|
|
2698
|
-
backgroundColor: color,
|
|
2699
|
-
borderBottom: '1px solid rgba(255,255,255,0.2)',
|
|
2700
|
-
} }, zone.id));
|
|
2701
|
-
}) }) }));
|
|
2702
|
-
};
|
|
2703
|
-
|
|
2704
|
-
const ScrollZoneTooltip = ({ zone, position, currentScrollPercent, scrollmap, }) => {
|
|
2705
|
-
const tooltipRef = useRef(null);
|
|
2706
|
-
const currentData = useMemo(() => {
|
|
2707
|
-
if (!scrollmap || scrollmap.length === 0)
|
|
2708
|
-
return null;
|
|
2709
|
-
const roundedPercent = Math.floor(currentScrollPercent);
|
|
2710
|
-
return scrollmap.find((d) => d.scrollReachY === roundedPercent) || null;
|
|
2711
|
-
}, [scrollmap, currentScrollPercent]);
|
|
2712
|
-
return (jsxs("div", { id: "gx-hm-scrollmap-tooltip", ref: tooltipRef, style: {
|
|
2713
|
-
position: 'fixed',
|
|
2714
|
-
top: `${position.y}px`,
|
|
2715
|
-
backgroundColor: 'black',
|
|
2716
|
-
zIndex: 10001,
|
|
2717
|
-
pointerEvents: 'none',
|
|
2718
|
-
width: '100%',
|
|
2719
|
-
height: '2px',
|
|
2720
|
-
}, children: [jsxs("div", { style: {
|
|
2721
|
-
position: 'absolute',
|
|
2722
|
-
left: '50%',
|
|
2723
|
-
top: '-50%',
|
|
2724
|
-
transform: 'translate(-50%, -50%)',
|
|
2725
|
-
padding: '16px',
|
|
2726
|
-
borderRadius: '8px',
|
|
2727
|
-
boxShadow: '0 4px 16px rgba(0,0,0,0.15)',
|
|
2728
|
-
fontSize: '14px',
|
|
2729
|
-
width: 'fit-content',
|
|
2730
|
-
backgroundColor: 'white',
|
|
2731
|
-
minWidth: '230px',
|
|
2732
|
-
display: 'flex',
|
|
2733
|
-
gap: '8px',
|
|
2734
|
-
alignItems: 'center',
|
|
2735
|
-
}, children: [jsxs("p", { style: {
|
|
2736
|
-
fontWeight: 650,
|
|
2737
|
-
fontSize: '20px',
|
|
2738
|
-
lineHeight: '24px',
|
|
2739
|
-
letterSpacing: '-0.2px',
|
|
2740
|
-
verticalAlign: 'middle',
|
|
2741
|
-
fontVariantNumeric: 'tabular-nums',
|
|
2742
|
-
}, children: [currentData?.percUsers?.toFixed(2), "%", ' '] }), jsx("p", { style: { fontWeight: 450 }, children: "user scrolled this far" })] }), jsx(TooltipByZone, { zone: zone })] }));
|
|
2743
|
-
};
|
|
2744
|
-
const TooltipByZone = ({ zone }) => {
|
|
2745
|
-
const scrollType = useHeatmapConfigStore((state) => state.scrollType);
|
|
2746
|
-
if (!zone)
|
|
2747
|
-
return null;
|
|
2748
|
-
const contentMarkup = () => {
|
|
2749
|
-
switch (scrollType) {
|
|
2750
|
-
case IScrollType.Depth:
|
|
2751
|
-
return jsx(BasicTooltipContent, { zone: zone });
|
|
2752
|
-
case IScrollType.Attention:
|
|
2753
|
-
return jsx(MetricsTooltipContent, { zone: zone });
|
|
2754
|
-
default:
|
|
2755
|
-
return jsx(BasicTooltipContent, { zone: zone });
|
|
2756
|
-
}
|
|
2757
|
-
};
|
|
2758
|
-
return (jsx("div", { style: { paddingTop: '12px', borderTop: '1px solid #E5E7EB' }, children: contentMarkup() }));
|
|
2759
|
-
};
|
|
2760
|
-
const BasicTooltipContent = ({ zone }) => {
|
|
2761
|
-
if (!zone)
|
|
2762
|
-
return null;
|
|
2763
|
-
return (jsxs(Fragment, { children: [jsx("div", { style: { fontWeight: 600, marginBottom: '8px' }, children: zone.label }), jsxs("div", { style: { fontSize: '24px', fontWeight: 700, color: '#0078D4' }, children: [zone.percUsers.toFixed(2), "%"] }), jsx("div", { style: { fontSize: '12px', color: '#605E5C', marginTop: '4px' }, children: "of users reached this point" })] }));
|
|
2764
|
-
};
|
|
2765
|
-
const MetricsTooltipContent = ({ zone }) => {
|
|
2766
|
-
if (!zone)
|
|
2767
|
-
return null;
|
|
2768
|
-
return (jsxs(Fragment, { children: [jsx("div", { style: { fontWeight: 600, marginBottom: '8px' }, children: zone.label }), jsxs("div", { style: { fontSize: '20px', fontWeight: 700, marginBottom: '8px' }, children: [zone.percUsers.toFixed(2), "% users"] }), zone.metrics && (jsxs("div", { style: { display: 'grid', gap: '6px', fontSize: '13px' }, children: [zone.metrics.revenue !== undefined && (jsx(MetricRow, { label: "Revenue", value: `$${zone.metrics.revenue.toFixed(2)}` })), zone.metrics.conversionRate !== undefined && (jsx(MetricRow, { label: "Conversion", value: `${zone.metrics.conversionRate.toFixed(2)}%` })), zone.metrics.orders !== undefined && (jsx(MetricRow, { label: "Orders", value: zone.metrics.orders.toString() }))] }))] }));
|
|
2769
|
-
};
|
|
2770
|
-
const MetricRow = ({ label, value }) => (jsxs("div", { style: { display: 'flex', justifyContent: 'space-between' }, children: [jsxs("span", { style: { color: '#605E5C' }, children: [label, ":"] }), jsx("span", { style: { fontWeight: 600 }, children: value })] }));
|
|
2771
|
-
|
|
2772
|
-
const HoverZones = ({ iframeRef, wrapperRef, position, currentScrollPercent, }) => {
|
|
2773
|
-
const scrollmap = useHeatmapDataStore((state) => state.scrollmap);
|
|
2774
|
-
// const hoveredZone = useHeatmapVizScrollmapStore((state) => state.hoveredZone);
|
|
2775
|
-
// const setHoveredZone = useHeatmapVizScrollmapStore((state) => state.setHoveredZone);
|
|
2776
|
-
const { zones, isReady, maxUsers } = useScrollmapZones({
|
|
2777
|
-
iframeRef,
|
|
2778
|
-
wrapperRef,
|
|
2779
|
-
});
|
|
2780
|
-
if (!isReady || !zones.length)
|
|
2781
|
-
return null;
|
|
2782
|
-
if (!position)
|
|
2783
|
-
return null;
|
|
2784
|
-
return (jsxs(Fragment, { children: [jsx(ScrollZoneTooltip, { position: position, currentScrollPercent: currentScrollPercent, scrollmap: scrollmap || [] }), jsx(ScrollMapMinimap, { zones: zones, maxUsers: maxUsers })] }));
|
|
2785
|
-
};
|
|
2786
|
-
|
|
2787
|
-
const ScrollMapOverlay = ({ wrapperRef, iframeRef }) => {
|
|
2788
|
-
const overlayRef = useRef(null);
|
|
2789
|
-
const [position, setPosition] = useState();
|
|
2790
|
-
const [currentScrollPercent, setCurrentScrollPercent] = useState(0);
|
|
2791
|
-
const widthScale = useHeatmapVizStore((state) => state.scale);
|
|
2792
|
-
const iframeHeight = useHeatmapSingleStore((state) => state.iframeHeight);
|
|
2793
|
-
const handleMouseMove = (event) => {
|
|
2794
|
-
if (!iframeRef.current || !wrapperRef.current)
|
|
2795
|
-
return;
|
|
2796
|
-
const iframe = iframeRef.current;
|
|
2797
|
-
const iframeRect = iframe.getBoundingClientRect();
|
|
2798
|
-
const { x, y } = convertViewportToIframeCoords(event.clientX, event.clientY, iframeRect, widthScale);
|
|
2799
|
-
const wrapperEl = wrapperRef.current;
|
|
2800
|
-
const scrollOffset = (wrapperEl?.scrollTop || 0) / widthScale;
|
|
2801
|
-
const actualY = y + scrollOffset;
|
|
2802
|
-
const scrollPercent = Math.min(100, Math.max(0, (actualY / iframeHeight) * 100));
|
|
2803
|
-
setCurrentScrollPercent(scrollPercent);
|
|
2804
|
-
setPosition({ x, y });
|
|
2805
|
-
};
|
|
2806
|
-
const onMouseMove = useCallback((event) => {
|
|
2807
|
-
requestAnimationFrame(() => handleMouseMove(event));
|
|
2808
|
-
}, [handleMouseMove]);
|
|
2809
|
-
const onMouseLeave = () => {
|
|
2810
|
-
requestAnimationFrame(() => {
|
|
2811
|
-
setCurrentScrollPercent(0);
|
|
2812
|
-
setPosition(undefined);
|
|
2813
|
-
});
|
|
2814
|
-
};
|
|
2815
|
-
return (jsx("div", { ref: overlayRef, id: "gx-hm-scrollmap-overlay", onMouseMove: onMouseMove, onMouseLeave: onMouseLeave, style: {
|
|
2816
|
-
position: 'absolute',
|
|
2817
|
-
top: 0,
|
|
2818
|
-
left: 0,
|
|
2819
|
-
width: '100%',
|
|
2820
|
-
height: `${iframeHeight}px`,
|
|
2821
|
-
zIndex: 3,
|
|
2822
|
-
}, children: jsx(HoverZones, { position: position, currentScrollPercent: currentScrollPercent, iframeRef: iframeRef, wrapperRef: wrapperRef }) }));
|
|
2823
|
-
};
|
|
2824
|
-
|
|
2825
|
-
const SCROLL_TYPES = [IHeatmapType.Scroll];
|
|
2826
|
-
const VizScrollMap = ({ iframeRef, wrapperRef }) => {
|
|
2827
|
-
const iframeHeight = useHeatmapSingleStore((state) => state.iframeHeight);
|
|
2828
|
-
const heatmapType = useHeatmapConfigStore((state) => state.heatmapType);
|
|
2829
|
-
const isHeatmapScroll = SCROLL_TYPES.includes(heatmapType);
|
|
2830
|
-
if (!iframeHeight || !isHeatmapScroll)
|
|
2831
|
-
return null;
|
|
2832
|
-
return (jsxs("div", { style: {
|
|
2833
|
-
position: 'absolute',
|
|
2834
|
-
top: 0,
|
|
2835
|
-
left: '2px',
|
|
2836
|
-
width: `calc(100% - 4px)`,
|
|
2837
|
-
height: '100%',
|
|
2838
|
-
transform: 'translateZ(0)',
|
|
2839
|
-
}, children: [jsx(ScrollmapMarker, { iframeRef: iframeRef, wrapperRef: wrapperRef }), jsx(AverageFoldLine, { iframeRef: iframeRef, wrapperRef: wrapperRef }), jsx(ScrollMapOverlay, { wrapperRef: wrapperRef, iframeRef: iframeRef })] }));
|
|
2840
|
-
};
|
|
2841
|
-
|
|
2842
1873
|
const WrapperVisual = ({ children, visualRef, wrapperRef, scaledHeight, iframeHeight, onScroll, }) => {
|
|
2843
1874
|
const contentWidth = useHeatmapConfigStore((state) => state.width);
|
|
2844
1875
|
const widthScale = useHeatmapVizStore((state) => state.scale);
|
|
@@ -2873,9 +1904,8 @@ const WrapperVisual = ({ children, visualRef, wrapperRef, scaledHeight, iframeHe
|
|
|
2873
1904
|
|
|
2874
1905
|
const VizDomRenderer = ({ mode = 'heatmap' }) => {
|
|
2875
1906
|
const width = useHeatmapConfigStore((state) => state.width);
|
|
2876
|
-
const
|
|
2877
|
-
const
|
|
2878
|
-
const setIframeHeight = useHeatmapSingleStore((state) => state.setIframeHeight);
|
|
1907
|
+
const iframeHeight = useHeatmapVizStore((state) => state.iframeHeight);
|
|
1908
|
+
const setIframeHeight = useHeatmapVizStore((state) => state.setIframeHeight);
|
|
2879
1909
|
const setSelectedElement = useHeatmapInteractionStore((state) => state.setSelectedElement);
|
|
2880
1910
|
const wrapperRef = useRef(null);
|
|
2881
1911
|
const visualRef = useRef(null);
|
|
@@ -2885,13 +1915,14 @@ const VizDomRenderer = ({ mode = 'heatmap' }) => {
|
|
|
2885
1915
|
iframeRef,
|
|
2886
1916
|
visualRef,
|
|
2887
1917
|
iframeHeight,
|
|
1918
|
+
setIframeHeight,
|
|
2888
1919
|
});
|
|
2889
1920
|
const contentWidth = width ?? 0;
|
|
2890
1921
|
const onScroll = (e) => {
|
|
2891
1922
|
const scrollTop = e.currentTarget.scrollTop;
|
|
2892
1923
|
handleScroll(scrollTop);
|
|
2893
1924
|
};
|
|
2894
|
-
|
|
1925
|
+
useHeatmapVizCanvas();
|
|
2895
1926
|
const cleanUp = () => {
|
|
2896
1927
|
setIframeHeight(0);
|
|
2897
1928
|
setSelectedElement(null);
|
|
@@ -2899,7 +1930,7 @@ const VizDomRenderer = ({ mode = 'heatmap' }) => {
|
|
|
2899
1930
|
useEffect(() => {
|
|
2900
1931
|
return cleanUp;
|
|
2901
1932
|
}, []);
|
|
2902
|
-
return (jsxs(WrapperVisual, { visualRef: visualRef, wrapperRef: wrapperRef, scaledHeight: scaledHeight, onScroll: onScroll, iframeHeight: iframeHeight, children: [
|
|
1933
|
+
return (jsxs(WrapperVisual, { visualRef: visualRef, wrapperRef: wrapperRef, scaledHeight: scaledHeight, onScroll: onScroll, iframeHeight: iframeHeight, children: [jsx(VizElements, { iframeRef: iframeRef, visualRef: visualRef, wrapperRef: wrapperRef }), jsx("iframe", { ref: iframeRef, ...HEATMAP_IFRAME, width: contentWidth, height: iframeHeight, scrolling: "no" })] }));
|
|
2903
1934
|
};
|
|
2904
1935
|
|
|
2905
1936
|
const VizLoading = () => {
|
|
@@ -2909,12 +1940,12 @@ const VizLoading = () => {
|
|
|
2909
1940
|
const VizDomHeatmap = () => {
|
|
2910
1941
|
const controls = useHeatmapControlStore((state) => state.controls);
|
|
2911
1942
|
const isRendering = useHeatmapDataStore((state) => state.isRendering);
|
|
2912
|
-
const iframeHeight =
|
|
2913
|
-
const setIframeHeight =
|
|
2914
|
-
const setVizRef =
|
|
1943
|
+
const iframeHeight = useHeatmapVizStore((state) => state.iframeHeight);
|
|
1944
|
+
const setIframeHeight = useHeatmapVizStore((state) => state.setIframeHeight);
|
|
1945
|
+
const setVizRef = useHeatmapVizStore((state) => state.setVizRef);
|
|
2915
1946
|
useEffect(() => {
|
|
2916
1947
|
return () => {
|
|
2917
|
-
setVizRef(
|
|
1948
|
+
setVizRef(undefined);
|
|
2918
1949
|
setIframeHeight(0);
|
|
2919
1950
|
};
|
|
2920
1951
|
}, []);
|
|
@@ -2929,7 +1960,7 @@ const VizLiveRenderer = () => {
|
|
|
2929
1960
|
const setIframeHeight = useHeatmapLiveStore((state) => state.setIframeHeight);
|
|
2930
1961
|
const visualRef = useRef(null);
|
|
2931
1962
|
const wrapperRef = useRef(null);
|
|
2932
|
-
const { iframeRef } =
|
|
1963
|
+
const { iframeRef } = useIframeRender();
|
|
2933
1964
|
const { scaledHeight, handleScroll } = useHeatmapScale({
|
|
2934
1965
|
wrapperRef,
|
|
2935
1966
|
iframeRef,
|
|
@@ -2941,15 +1972,13 @@ const VizLiveRenderer = () => {
|
|
|
2941
1972
|
const scrollTop = e.currentTarget.scrollTop;
|
|
2942
1973
|
handleScroll(scrollTop);
|
|
2943
1974
|
};
|
|
2944
|
-
return (jsx(WrapperVisual, { visualRef: visualRef, wrapperRef: wrapperRef, scaledHeight: scaledHeight, iframeHeight: iframeHeight, onScroll: onScroll, children: jsx("iframe", { ref: iframeRef, ...HEATMAP_IFRAME, width: contentWidth,
|
|
2945
|
-
// height={iframeHeight}
|
|
2946
|
-
scrolling: "no", sandbox: "allow-scripts allow-same-origin" }) }));
|
|
1975
|
+
return (jsx(WrapperVisual, { visualRef: visualRef, wrapperRef: wrapperRef, scaledHeight: scaledHeight, iframeHeight: iframeHeight, onScroll: onScroll, children: jsx("iframe", { ref: iframeRef, ...HEATMAP_IFRAME, width: contentWidth, height: iframeHeight, scrolling: "no", sandbox: "allow-scripts allow-same-origin" }) }));
|
|
2947
1976
|
};
|
|
2948
1977
|
|
|
2949
1978
|
const VizLiveHeatmap = () => {
|
|
2950
1979
|
const controls = useHeatmapControlStore((state) => state.controls);
|
|
2951
1980
|
const isRendering = useHeatmapDataStore((state) => state.isRendering);
|
|
2952
|
-
const iframeHeight =
|
|
1981
|
+
const iframeHeight = useHeatmapVizStore((state) => state.iframeHeight);
|
|
2953
1982
|
const wrapperHeight = useHeatmapLiveStore((state) => state.wrapperHeight);
|
|
2954
1983
|
const setWrapperHeight = useHeatmapLiveStore((state) => state.setWrapperHeight);
|
|
2955
1984
|
const reset = useHeatmapLiveStore((state) => state.reset);
|
|
@@ -3006,10 +2035,10 @@ const WrapperLayout = () => {
|
|
|
3006
2035
|
return (jsxs(BoxStack, { id: "gx-hm-layout", flexDirection: "column", flex: "1", children: [jsx(ContentTopBar, {}), jsx(WrapperPreview, {})] }));
|
|
3007
2036
|
};
|
|
3008
2037
|
|
|
3009
|
-
const HeatmapLayout = ({ data, clickmap,
|
|
2038
|
+
const HeatmapLayout = ({ data, clickmap, controls, dataInfo, }) => {
|
|
3010
2039
|
useRegisterControl(controls);
|
|
3011
2040
|
useRegisterData(data, dataInfo);
|
|
3012
|
-
useRegisterHeatmap(
|
|
2041
|
+
useRegisterHeatmap(clickmap);
|
|
3013
2042
|
useRegisterConfig();
|
|
3014
2043
|
return (jsx(BoxStack, { id: "gx-hm-project", flexDirection: "column", flex: "1", height: "100%", style: getVariableStyle(), children: jsx(BoxStack, { id: "gx-hm-project-content", flexDirection: "column", flex: "1", children: jsx("div", { style: {
|
|
3015
2044
|
minHeight: '100%',
|
|
@@ -3024,4 +2053,4 @@ const HeatmapLayout = ({ data, clickmap, scrollmap, controls, dataInfo, }) => {
|
|
|
3024
2053
|
}
|
|
3025
2054
|
};
|
|
3026
2055
|
|
|
3027
|
-
export { GraphView, HeatmapLayout,
|
|
2056
|
+
export { GraphView, HeatmapLayout, IHeatmapType, useHeatmapConfigStore, useHeatmapDataStore, useHeatmapInteractionStore, useHeatmapLiveStore };
|