@levi-gemcommerce/analytics 1.0.0-dev.30 → 1.0.0-dev.32

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.
@@ -0,0 +1 @@
1
+ export declare const useSearchParams: () => [URLSearchParams];
package/dist/esm/index.js CHANGED
@@ -12,7 +12,6 @@ import { useTranslation } from 'react-i18next';
12
12
  import { create } from 'zustand';
13
13
  import { useQuery } from '@tanstack/react-query';
14
14
  import { PolarisVizProvider, LineChart, DonutChart } from '@shopify/polaris-viz';
15
- import { useSearchParams } from '@remix-run/react';
16
15
  import { unstable_batchedUpdates, createPortal } from 'react-dom';
17
16
  import { t as t$1 } from 'i18next';
18
17
 
@@ -3240,6 +3239,14 @@ const useFunnelChartStore = create()((set, get) => ({
3240
3239
  const MAX_FUNNEL_ADDITIONAL_LEVEL = 3;
3241
3240
  const FINAL_FUNNEL_FIXED_LEVEL = 3;
3242
3241
 
3242
+ // Framework-agnostic replacement for @remix-run/react useSearchParams.
3243
+ // Returns a read-only URLSearchParams from window.location.search so the SDK
3244
+ // works outside of a Remix/React Router context (e.g. Next.js, plain React).
3245
+ const useSearchParams = () => {
3246
+ const params = typeof window !== 'undefined' ? new URLSearchParams(window.location.search) : new URLSearchParams();
3247
+ return [params];
3248
+ };
3249
+
3243
3250
  const usePathAnalysisFunnel = ({ pathAnalytics, pathAnalysisCacheKey, dataFirstLevels, }) => {
3244
3251
  const [searchParams] = useSearchParams();
3245
3252
  const setFirstLevelLocationPath = usePathAnalysisStore((state) => state.setFirstLevelLocationPath);
@@ -21846,9 +21853,10 @@ function getVerticalLabels({ labels, characterWidths, longestLabelWidth, targetW
21846
21853
  }
21847
21854
 
21848
21855
  function getFontSize() {
21849
- const isMobile = typeof window !== 'undefined' && ('ontouchstart' in window || navigator.maxTouchPoints > 0);
21850
- const fontSize = isMobile ? TOUCH_FONT_SIZE : FONT_SIZE;
21851
- return fontSize;
21856
+ if (typeof window === 'undefined')
21857
+ return FONT_SIZE;
21858
+ const isMobile = 'ontouchstart' in window || navigator.maxTouchPoints > 0;
21859
+ return isMobile ? TOUCH_FONT_SIZE : FONT_SIZE;
21852
21860
  }
21853
21861
 
21854
21862
  function useLabels({ allowLineWrap, align = 'center', labels, onHeightChange = () => { }, targetWidth }) {
@@ -23124,12 +23132,17 @@ function TooltipTitle({ children, theme, color }) {
23124
23132
  }
23125
23133
 
23126
23134
  const useRootContainer = (id) => {
23127
- const ref = useRef(document.getElementById(id));
23135
+ const ref = useRef(null);
23128
23136
  function getRootElem() {
23137
+ if (typeof document === 'undefined')
23138
+ return null;
23129
23139
  if (!ref.current) {
23130
- ref.current = document.createElement('div');
23131
- ref.current.id = id;
23132
- document.body.appendChild(ref.current);
23140
+ ref.current = document.getElementById(id);
23141
+ if (!ref.current) {
23142
+ ref.current = document.createElement('div');
23143
+ ref.current.id = id;
23144
+ document.body.appendChild(ref.current);
23145
+ }
23133
23146
  }
23134
23147
  return ref.current;
23135
23148
  }
@@ -23138,6 +23151,8 @@ const useRootContainer = (id) => {
23138
23151
 
23139
23152
  function TooltipWithPortal({ children }) {
23140
23153
  const container = useRootContainer(TOOLTIP_ID);
23154
+ if (!container)
23155
+ return null;
23141
23156
  return createPortal(children, container);
23142
23157
  }
23143
23158
 
@@ -12,7 +12,6 @@ import { useTranslation } from 'react-i18next';
12
12
  import { create } from 'zustand';
13
13
  import { useQuery } from '@tanstack/react-query';
14
14
  import { PolarisVizProvider, LineChart, DonutChart } from '@shopify/polaris-viz';
15
- import { useSearchParams } from '@remix-run/react';
16
15
  import { unstable_batchedUpdates, createPortal } from 'react-dom';
17
16
  import { t as t$1 } from 'i18next';
18
17
 
@@ -3240,6 +3239,14 @@ const useFunnelChartStore = create()((set, get) => ({
3240
3239
  const MAX_FUNNEL_ADDITIONAL_LEVEL = 3;
3241
3240
  const FINAL_FUNNEL_FIXED_LEVEL = 3;
3242
3241
 
3242
+ // Framework-agnostic replacement for @remix-run/react useSearchParams.
3243
+ // Returns a read-only URLSearchParams from window.location.search so the SDK
3244
+ // works outside of a Remix/React Router context (e.g. Next.js, plain React).
3245
+ const useSearchParams = () => {
3246
+ const params = typeof window !== 'undefined' ? new URLSearchParams(window.location.search) : new URLSearchParams();
3247
+ return [params];
3248
+ };
3249
+
3243
3250
  const usePathAnalysisFunnel = ({ pathAnalytics, pathAnalysisCacheKey, dataFirstLevels, }) => {
3244
3251
  const [searchParams] = useSearchParams();
3245
3252
  const setFirstLevelLocationPath = usePathAnalysisStore((state) => state.setFirstLevelLocationPath);
@@ -21846,9 +21853,10 @@ function getVerticalLabels({ labels, characterWidths, longestLabelWidth, targetW
21846
21853
  }
21847
21854
 
21848
21855
  function getFontSize() {
21849
- const isMobile = typeof window !== 'undefined' && ('ontouchstart' in window || navigator.maxTouchPoints > 0);
21850
- const fontSize = isMobile ? TOUCH_FONT_SIZE : FONT_SIZE;
21851
- return fontSize;
21856
+ if (typeof window === 'undefined')
21857
+ return FONT_SIZE;
21858
+ const isMobile = 'ontouchstart' in window || navigator.maxTouchPoints > 0;
21859
+ return isMobile ? TOUCH_FONT_SIZE : FONT_SIZE;
21852
21860
  }
21853
21861
 
21854
21862
  function useLabels({ allowLineWrap, align = 'center', labels, onHeightChange = () => { }, targetWidth }) {
@@ -23124,12 +23132,17 @@ function TooltipTitle({ children, theme, color }) {
23124
23132
  }
23125
23133
 
23126
23134
  const useRootContainer = (id) => {
23127
- const ref = useRef(document.getElementById(id));
23135
+ const ref = useRef(null);
23128
23136
  function getRootElem() {
23137
+ if (typeof document === 'undefined')
23138
+ return null;
23129
23139
  if (!ref.current) {
23130
- ref.current = document.createElement('div');
23131
- ref.current.id = id;
23132
- document.body.appendChild(ref.current);
23140
+ ref.current = document.getElementById(id);
23141
+ if (!ref.current) {
23142
+ ref.current = document.createElement('div');
23143
+ ref.current.id = id;
23144
+ document.body.appendChild(ref.current);
23145
+ }
23133
23146
  }
23134
23147
  return ref.current;
23135
23148
  }
@@ -23138,6 +23151,8 @@ const useRootContainer = (id) => {
23138
23151
 
23139
23152
  function TooltipWithPortal({ children }) {
23140
23153
  const container = useRootContainer(TOOLTIP_ID);
23154
+ if (!container)
23155
+ return null;
23141
23156
  return createPortal(children, container);
23142
23157
  }
23143
23158
 
@@ -1,4 +1,4 @@
1
1
  import type { ReactNode } from 'react';
2
2
  export declare function TooltipWithPortal({ children }: {
3
3
  children: ReactNode;
4
- }): import("react").ReactPortal;
4
+ }): import("react").ReactPortal | null;
@@ -1 +1 @@
1
- export declare const useRootContainer: (id: string) => HTMLElement;
1
+ export declare const useRootContainer: (id: string) => HTMLElement | null;
@@ -0,0 +1 @@
1
+ export declare const useSearchParams: () => [URLSearchParams];
@@ -1,4 +1,4 @@
1
1
  import type { ReactNode } from 'react';
2
2
  export declare function TooltipWithPortal({ children }: {
3
3
  children: ReactNode;
4
- }): import("react").ReactPortal;
4
+ }): import("react").ReactPortal | null;
@@ -1 +1 @@
1
- export declare const useRootContainer: (id: string) => HTMLElement;
1
+ export declare const useRootContainer: (id: string) => HTMLElement | null;