@yext/pages-components 1.1.15 → 1.2.1

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/index.d.ts CHANGED
@@ -342,7 +342,7 @@ declare const useIdentify: () => ((visitor: Record<string, string>) => void) | u
342
342
  *
343
343
  * @public
344
344
  */
345
- declare function AnalyticsProvider(props: PropsWithChildren<AnalyticsProviderProps>): JSX.Element;
345
+ declare function AnalyticsProvider(props: PropsWithChildren<AnalyticsProviderProps>): React.ReactElement;
346
346
  /**
347
347
  * This will look for the xYextDebug parameter and if it is present,
348
348
  * enable analytics debugging.
@@ -363,7 +363,7 @@ declare const useScope: () => string;
363
363
  *
364
364
  * @param props - AnalyticsScopeProps
365
365
  */
366
- declare function AnalyticsScopeProvider(props: PropsWithChildren<AnalyticsScopeProps>): JSX.Element;
366
+ declare function AnalyticsScopeProvider(props: PropsWithChildren<AnalyticsScopeProps>): React.ReactElement;
367
367
 
368
368
  /**
369
369
  * The type definition for a thumbnail.
@@ -1525,10 +1525,10 @@ interface MapProps {
1525
1525
  iframeId?: string;
1526
1526
  }
1527
1527
  interface MarkerProps {
1528
- children?: React__default.ReactChild;
1528
+ children?: React__default.ReactElement;
1529
1529
  coordinate: Coordinate;
1530
1530
  hideOffscreen?: boolean;
1531
- icon?: JSX.Element;
1531
+ icon?: React__default.ReactElement;
1532
1532
  id: string;
1533
1533
  onClick?: (id: string) => void;
1534
1534
  onHover?: (hovered: boolean, id: string) => void;
@@ -1544,8 +1544,8 @@ type ClusterTemplateProps = {
1544
1544
  };
1545
1545
  type ClustererProps = {
1546
1546
  clusterRadius?: number;
1547
- children: JSX.Element[] | JSX.Element;
1548
- ClusterTemplate?: (props: ClusterTemplateProps) => JSX.Element;
1547
+ children: React__default.ReactElement[] | React__default.ReactElement;
1548
+ ClusterTemplate?: (props: ClusterTemplateProps) => React__default.ReactElement;
1549
1549
  };
1550
1550
  type PinStoreType = {
1551
1551
  id: string;
@@ -1560,13 +1560,13 @@ interface ClustererContextType {
1560
1560
  declare function useMapContext(): Map$1;
1561
1561
  declare const Map: ({ apiKey, bounds, children, className, clientKey, controls, defaultCenter, defaultZoom, mapRef, padding, panHandler, panStartHandler, provider, providerOptions, singleZoom, iframeId, }: MapProps) => react_jsx_runtime.JSX.Element;
1562
1562
 
1563
- declare const Marker: ({ children, coordinate, hideOffscreen, id, icon, onClick, onFocus, onHover, zIndex, hasPinUrl, }: MarkerProps) => JSX.Element | null;
1563
+ declare const Marker: ({ children, coordinate, hideOffscreen, id, icon, onClick, onFocus, onHover, zIndex, hasPinUrl, }: MarkerProps) => React__default.ReactElement | null;
1564
1564
 
1565
1565
  declare function useClusterContext(): ClustererContextType;
1566
1566
  declare const Clusterer: ({ clusterRadius, children, ClusterTemplate, }: ClustererProps) => react_jsx_runtime.JSX.Element;
1567
1567
 
1568
1568
  interface LocationMapProps extends MapProps {
1569
- children?: React.ReactChild;
1569
+ children?: React.ReactElement;
1570
1570
  coordinate: Coordinate;
1571
1571
  linkSameTab?: boolean;
1572
1572
  pinUrl?: string;
@@ -1607,7 +1607,7 @@ declare function LexicalRichText({ serializedAST, nodeClassNames, }: LexicalRich
1607
1607
  */
1608
1608
  declare const LegacyRichText: (props: {
1609
1609
  markdown: string;
1610
- }) => ReactElement<any, string | React$1.JSXElementConstructor<any>> | null;
1610
+ }) => ReactElement<unknown, string | React$1.JSXElementConstructor<any>> | null;
1611
1611
 
1612
1612
  declare class HoursInterval {
1613
1613
  end: DateTime;
@@ -1,14 +1,14 @@
1
- import { A as e, a4 as t, ac as i, x as o, y as r, E as c, H as n, ae as g, _ as p, af as u, R as h, ak as m, Y as l, $ as S, a2 as d, ag as M, W as P, X as y, I as x, K as A, ai as L, V as C, U as f, N as O, L as R, a0 as T, T as b, a5 as v, O as B, M as I, aj as k, ah as D, Q as H, a7 as w, a6 as G, a9 as Q, a8 as z, aa as E, ab as F, a1 as U, ad as V, Z as W, F as j, w as J, J as K, a3 as N, z as X, S as Y, D as Z, P as _, C as $, G as q, B as aa } from "./index-CDEZRpEm.js";
1
+ import { A as e, K as t, W as o, e as i, f as r, k as c, n, Y as p, B as g, Z as u, C as h, a2 as m, D as l, E as S, G as d, _ as M, H as P, z as y, I as x, p as A, a0 as L, y as C, x as f, q as O, L as v, F as R, w as T, N as B, r as I, M as b, a1 as k, $ as D, t as H, Q as w, O as G, T as Q, R as z, U as E, V as F, P as U, X as V, S as W, l as j, d as q, o as J, J as K, u as N, v as X, j as Y, s as Z, i as _, m as $, h as aa } from "./index-GeO8DZvj.js";
2
2
  export {
3
3
  e as Address,
4
4
  t as AddressSchema,
5
- i as AggregateRatingSchema,
6
- o as Analytics,
5
+ o as AggregateRatingSchema,
6
+ i as Analytics,
7
7
  r as AnalyticsContext,
8
8
  c as AnalyticsProvider,
9
9
  n as AnalyticsScopeProvider,
10
- g as BaiduMaps,
11
- p as BaseSchema,
10
+ p as BaiduMaps,
11
+ g as BaseSchema,
12
12
  u as BingMaps,
13
13
  h as Clusterer,
14
14
  m as CoordinateClass,
@@ -24,12 +24,12 @@ export {
24
24
  C as LegacyRichText,
25
25
  f as LexicalRichText,
26
26
  O as Link,
27
- R as ListingPublisherOption,
28
- T as LocalBusiness,
29
- b as LocationMap,
30
- v as LocationSchema,
31
- B as Map,
32
- I as MapProviderOption,
27
+ v as ListingPublisherOption,
28
+ R as LocalBusiness,
29
+ T as LocationMap,
30
+ B as LocationSchema,
31
+ I as Map,
32
+ b as MapProviderOption,
33
33
  k as MapQuestMaps,
34
34
  D as MapboxMaps,
35
35
  H as Marker,
@@ -43,14 +43,14 @@ export {
43
43
  V as ReviewSchema,
44
44
  W as SchemaWrapper,
45
45
  j as debuggingParamDetected,
46
- J as getDirections,
47
- K as getImageUrl,
48
- N as getRichTextContent,
49
- X as useAnalytics,
50
- Y as useClusterContext,
51
- Z as useIdentify,
52
- _ as useMapContext,
53
- $ as usePageView,
54
- q as useScope,
46
+ q as getDirections,
47
+ J as getImageUrl,
48
+ K as getRichTextContent,
49
+ N as useAnalytics,
50
+ X as useClusterContext,
51
+ Y as useIdentify,
52
+ Z as useMapContext,
53
+ _ as usePageView,
54
+ $ as useScope,
55
55
  aa as useTrack
56
56
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yext/pages-components",
3
- "version": "1.1.15",
3
+ "version": "1.2.1",
4
4
  "description": "A React component library that supports Yext Pages development",
5
5
  "author": "sumo@yext.com",
6
6
  "license": "BSD-3-Clause",
@@ -18,17 +18,12 @@
18
18
  "dist",
19
19
  "THIRD-PARTY-NOTICES"
20
20
  ],
21
- "main": "./dist/pages-components.cjs",
22
21
  "module": "./dist/pages-components.js",
23
22
  "exports": {
24
23
  ".": {
25
24
  "import": {
26
25
  "types": "./dist/index.d.ts",
27
26
  "default": "./dist/pages-components.js"
28
- },
29
- "require": {
30
- "types": "./dist/index.d.cts",
31
- "default": "./dist/pages-components.cjs"
32
27
  }
33
28
  },
34
29
  "./style.css": "./dist/style.css"
@@ -38,8 +33,8 @@
38
33
  "node": "^18 || ^20 || ^22"
39
34
  },
40
35
  "peerDependencies": {
41
- "react": "^17.0.2 || ^18.2.0",
42
- "react-dom": "^17.0.2 || ^18.2.0",
36
+ "react": "^17.0.2 || ^18.2.0 || ^19.0.0",
37
+ "react-dom": "^17.0.2 || ^18.2.0 || ^19.0.0",
43
38
  "mapbox-gl": "^2.9.2"
44
39
  },
45
40
  "devDependencies": {
@@ -52,7 +47,8 @@
52
47
  "@storybook/react-vite": "^8.5.8",
53
48
  "@storybook/test-runner": "^0.21.3",
54
49
  "@storybook/testing-library": "^0.2.2",
55
- "@testing-library/react": "^14.1.2",
50
+ "@testing-library/dom": "^10.0.0",
51
+ "@testing-library/react": "^16.1.0",
56
52
  "@testing-library/user-event": "^14.5.1",
57
53
  "@types/bingmaps": "^0.0.1",
58
54
  "@types/google.maps": "^3.58.1",
@@ -61,8 +57,8 @@
61
57
  "@types/mapbox-gl": "^3.4.0",
62
58
  "@types/mdast": "3.0.10",
63
59
  "@types/node": "^20.10.4",
64
- "@types/react": "^18.2.45",
65
- "@types/react-dom": "^18.2.17",
60
+ "@types/react": "^19.0.0",
61
+ "@types/react-dom": "^19.0.0",
66
62
  "@vitejs/plugin-react": "^4.2.1",
67
63
  "axe-core": "^4.8.2",
68
64
  "axe-playwright": "^1.2.3",
@@ -72,8 +68,8 @@
72
68
  "@playwright/test": "^1.55.1",
73
69
  "playwright-core": "^1.55.1",
74
70
  "prop-types": "^15.8.1",
75
- "react": "^18.2.0",
76
- "react-dom": "^18.2.0",
71
+ "react": "^19.0.0",
72
+ "react-dom": "^19.0.0",
77
73
  "storybook": "^8.5.8",
78
74
  "tsup": "^8.0.1",
79
75
  "typescript": "^5.3.3",
@@ -82,19 +78,18 @@
82
78
  "vitest": "^3.0.5"
83
79
  },
84
80
  "dependencies": {
85
- "@lexical/code": "0.12.6",
86
- "@lexical/hashtag": "0.12.6",
87
- "@lexical/html": "0.12.6",
88
- "@lexical/link": "0.12.6",
89
- "@lexical/list": "0.12.6",
90
- "@lexical/react": "0.12.6",
91
- "@lexical/rich-text": "0.12.6",
92
- "@lexical/table": "0.12.6",
81
+ "@lexical/code": "~0.38.2",
82
+ "@lexical/hashtag": "~0.38.2",
83
+ "@lexical/html": "~0.38.2",
84
+ "@lexical/link": "~0.38.2",
85
+ "@lexical/list": "~0.38.2",
86
+ "@lexical/react": "~0.38.2",
87
+ "@lexical/rich-text": "~0.38.2",
88
+ "@lexical/table": "~0.38.2",
93
89
  "@yext/analytics": "^1.0.0",
94
- "browser-or-node": "^2.1.1",
95
- "classnames": "^2.3.2",
96
- "cross-fetch": "^4.0.0",
97
- "lexical": "0.12.6",
90
+ "browser-or-node": "^3.0.0",
91
+ "classnames": "^2.5.1",
92
+ "lexical": "~0.38.2",
98
93
  "mdast-util-from-markdown": "1.2.0",
99
94
  "mdast-util-to-hast": "12.3.0",
100
95
  "micromark-util-chunked": "1.0.0",
@@ -103,8 +98,8 @@
103
98
  "micromark-util-resolve-all": "1.0.0",
104
99
  "micromark-util-symbol": "1.0.1",
105
100
  "micromark-util-types": "1.0.2",
106
- "picocolors": "^1.0.0",
107
- "react-markdown": "^8.0.0",
101
+ "picocolors": "^1.1.1",
102
+ "react-markdown": "^9.0.2",
108
103
  "remark-rehype": "10.1.0",
109
104
  "unified": "11.0.4",
110
105
  "uvu": "0.5.6"
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./index-CjhHamzw.cjs"),m=require("react"),N=require("react-dom");function S(){return i.getRuntime().name!=="browser"||window.hasOwnProperty("debuggerInitialized")?null:(window.debuggerInitialized=!0,N.createPortal(i.jsxRuntimeExports.jsx(k,{}),document.body))}const B=(e,n)=>{const s=e.dataset.yaAction,t=e.dataset.yaScopeoverride,r=e.dataset.yaEventname,c=t||n;return{action:s,originalEventName:c?`${c}_${r}`:r,scope:c}},C=(e,n)=>{const s=[];let t=e;for(;t!=null&&t.parentElement;)t=t.parentElement.closest(n),t&&s.push(t);return s},b={},R="YA_NO_SCOPE",w=(e,n,s,t)=>{b.hasOwnProperty(e)?b[e].events.map(r=>r.el).includes(t)||(b[e].events=[...b[e].events,{eventData:n,el:t}]):b[e]={scopeEl:s||t,events:[{eventData:n,el:t}]}};function k(){const[e,n]=m.useState(),[s,t]=m.useState([]),[r,c]=m.useState(!1),o=a=>{n(e===a?void 0:a)};return m.useEffect(()=>{let a=null;const d=()=>{a&&a.abort(),a=new AbortController;const l=a.signal;document.documentElement.classList.add("xYextDebug"),document.querySelectorAll("[data-ya-eventname]").forEach((u,j)=>{const p=u.closest("[data-ya-scope]"),v=p==null?void 0:p.dataset.yaScope,x=B(u,v);u.addEventListener("mouseenter",()=>{t([{elem:u,key:`${x.originalEventName}_${j}`,action:x.action,originalEventName:x.originalEventName,scope:x.scope}])},{signal:l}),u.addEventListener("mouseleave",()=>{t([])},{signal:l});const E=u.dataset.yaScopeoverride;E?w(E,x,p,u):[v,...C(u,"[data-ya-scope]").map(y=>y.dataset.yaScope)].forEach(y=>{w(y||R,x,p,u)})}),c(!0)};d();const g=new MutationObserver(d);return g.observe(document,{childList:!0,subtree:!0}),()=>{document.documentElement.classList.remove("xYextDebug"),g.disconnect(),a==null||a.abort()}},[]),r?i.jsxRuntimeExports.jsxs(i.jsxRuntimeExports.Fragment,{children:[i.jsxRuntimeExports.jsxs("div",{className:"analytics-debugger",children:[i.jsxRuntimeExports.jsxs("div",{className:"analytics-debugger-toggles",children:[i.jsxRuntimeExports.jsx("button",{className:i.c("analytics-debugger-toggle",{"is-active":e==="Events"}),onClick:()=>o("Events"),children:"Events"}),i.jsxRuntimeExports.jsx("button",{className:i.c("analytics-debugger-toggle",{"is-active":e==="Scopes"}),onClick:()=>o("Scopes"),children:"Scopes"})]}),e&&i.jsxRuntimeExports.jsx("div",{className:"analytics-debugger-tabs",children:e==="Events"?i.jsxRuntimeExports.jsx(O,{data:b,setTooltips:t}):i.jsxRuntimeExports.jsx(Y,{data:b,setTooltips:t})})]}),i.jsxRuntimeExports.jsx(T,{tooltips:s})]}):null}const D=()=>{const e={};return Object.values(b).forEach(n=>{n.events.forEach(s=>{const{originalEventName:t}=s.eventData;e[t]||(e[t]=[]),!e[t].find(r=>r.el===s.el)&&e[t].push(s)})}),e};function O(e){const{setTooltips:n}=e,[s,t]=m.useState([]),[r,c]=m.useState(""),o=(a,d)=>{s.forEach(l=>l.classList.remove("analytics-event-highlight"));const g=a.map(l=>(l.el.scrollIntoView({behavior:"smooth",block:"nearest"}),l.el.classList.add("analytics-event-highlight"),l.el));t(g),c(d),n(a.map((l,h)=>({elem:l.el,key:`${l.eventData.originalEventName}_${h}`,action:l.eventData.action,originalEventName:l.eventData.originalEventName,scope:l.eventData.scope})))};return i.jsxRuntimeExports.jsxs("div",{className:"analytics-debugger-tab",children:[i.jsxRuntimeExports.jsx("h2",{className:"analytics-debugger-tab-title",children:"Event Names"}),i.jsxRuntimeExports.jsx("ul",{className:"analytics-debugger-list",children:Object.entries(D()).map(([a,d],g)=>{const l=`${a}_${g}`;return i.jsxRuntimeExports.jsx("li",{className:"analytics-debugger-listItem",children:i.jsxRuntimeExports.jsx("button",{className:i.c("analytics-debugger-button",{"is-active":l===r}),onClick:()=>o(d,l),children:a})},l)})})]})}function Y(e){const{data:n,setTooltips:s}=e,[t,r]=m.useState(""),c=o=>{const a=n[o];a.scopeEl&&(a.scopeEl.scrollIntoView({behavior:"smooth",block:"nearest"}),r(o),s(a.events.map((d,g)=>{const l=d.eventData;return{elem:d.el,key:`${l.originalEventName}_${g}`,action:l.action,originalEventName:l.originalEventName,scope:l.scope}})))};return i.jsxRuntimeExports.jsxs("div",{className:"analytics-debugger-tab",children:[i.jsxRuntimeExports.jsx("h2",{className:"analytics-debugger-tab-title",children:"Scope Names"}),i.jsxRuntimeExports.jsx("ul",{className:"analytics-debugger-list",children:Object.keys(n).map((o,a)=>{if(o!==R)return i.jsxRuntimeExports.jsx("li",{className:"analytics-debugger-listItem",children:i.jsxRuntimeExports.jsx("button",{className:i.c("analytics-debugger-button",{"is-active":o===t}),onClick:()=>c(o),children:o})},o+a)})})]})}function T(e){const n=m.useRef({});return m.useEffect(()=>{if(n.current)for(const s of Object.values(n.current)){const t=Object.values(n.current).map(r=>r.el).filter(r=>r!==s.el);A(s,t),s.el.style.visibility="visible"}},[e.tooltips]),i.jsxRuntimeExports.jsx(i.jsxRuntimeExports.Fragment,{children:e.tooltips.map(s=>i.jsxRuntimeExports.jsxs("div",{style:{visibility:"hidden"},className:"analytics-debugger-tooltip",ref:t=>{t?n.current[s.key]={el:t,tooltip:s}:delete n.current[s.key]},children:[i.jsxRuntimeExports.jsxs("span",{children:["Action: ",s.action]}),i.jsxRuntimeExports.jsx("br",{}),i.jsxRuntimeExports.jsxs("span",{children:["Scope: ",s.scope]}),i.jsxRuntimeExports.jsx("br",{}),i.jsxRuntimeExports.jsxs("span",{children:["Original Event Name: ",s.originalEventName]})]},s.key))})}function A(e,n){for(let s=0;s<9;s++){const t=I(e.tooltip.elem.getBoundingClientRect(),e.el,s);if(e.el.style.inset=`${t.top} auto auto ${t.left}`,!!L(e.el.getBoundingClientRect().left,e.el.getBoundingClientRect().top+window.scrollY,e.el.getBoundingClientRect().right,e.el.getBoundingClientRect().bottom+window.scrollY))continue;let c=!0;for(let o=0;o<n.length;o++){const a=n[o];$(e.el,a)&&(c=!1)}if(c)break}}function $(e,n){const s=e.getBoundingClientRect().top+window.scrollY,t=e.getBoundingClientRect().left,r=s+e.clientHeight,c=t+e.clientWidth,o=n.getBoundingClientRect().top+window.scrollY,a=n.getBoundingClientRect().left,d=o+n.clientHeight,g=a+n.clientWidth,l=(h,u,j,p,v,x,E,f)=>j<=v&&v<=E&&p<=x&&x<=f||j<=h&&h<=E&&p<=u&&u<=f||j<=h&&h<=E&&p<=x&&x<=f||j<=v&&v<=E&&p<=u&&u<=f;return l(t,s,a,o,c,r,g,d)||l(a,o,t,s,g,d,c,r)}function L(e,n,s,t){return e<0||s>window.innerWidth||n<0||t>document.documentElement.scrollHeight}function I(e,n,s){const t=n.clientHeight,r=n.clientWidth;let c,o;switch(s){case 0:{o=window.scrollY+e.top-t+"px",c=e.left-r+"px";break}case 1:{o=window.scrollY+e.top-t+"px",c=e.left+"px";break}case 2:{o=window.scrollY+e.top-t+"px",c=e.right+"px";break}case 3:{o=window.scrollY+e.top-t+"px",c=e.right-r+"px";break}case 4:{o=window.scrollY+e.bottom+"px",c=e.left-r+"px";break}case 5:{o=window.scrollY+e.bottom+"px",c=e.left+"px";break}case 6:{o=window.scrollY+e.bottom+"px",c=e.right-r+"px";break}case 7:{o=window.scrollY+e.bottom+"px",c=e.right+"px";break}default:o=0,c=0}return{top:o,left:c}}exports.AnalyticsDebuggerInternal=k;exports.default=S;
@@ -1,316 +0,0 @@
1
- import { g as C, j as o, c as j } from "./index-CDEZRpEm.js";
2
- import { useState as w, useEffect as N, useRef as O } from "react";
3
- import { createPortal as D } from "react-dom";
4
- function z() {
5
- return C().name !== "browser" || window.hasOwnProperty("debuggerInitialized") ? null : (window.debuggerInitialized = !0, D(/* @__PURE__ */ o.jsx(R, {}), document.body));
6
- }
7
- const S = (e, s) => {
8
- const n = e.dataset.yaAction, t = e.dataset.yaScopeoverride, r = e.dataset.yaEventname, c = t || s;
9
- return {
10
- action: n,
11
- originalEventName: c ? `${c}_${r}` : r,
12
- scope: c
13
- };
14
- }, Y = (e, s) => {
15
- const n = [];
16
- let t = e;
17
- for (; t != null && t.parentElement; )
18
- t = t.parentElement.closest(s), t && n.push(t);
19
- return n;
20
- }, b = {}, B = "YA_NO_SCOPE", k = (e, s, n, t) => {
21
- b.hasOwnProperty(e) ? b[e].events.map((r) => r.el).includes(t) || (b[e].events = [
22
- ...b[e].events,
23
- {
24
- eventData: s,
25
- el: t
26
- }
27
- ]) : b[e] = {
28
- scopeEl: n || t,
29
- // overidden scopes still need an element
30
- events: [
31
- {
32
- eventData: s,
33
- el: t
34
- }
35
- ]
36
- };
37
- };
38
- function R() {
39
- const [e, s] = w(), [n, t] = w([]), [r, c] = w(!1), i = (a) => {
40
- s(e === a ? void 0 : a);
41
- };
42
- return N(() => {
43
- let a = null;
44
- const u = () => {
45
- a && a.abort(), a = new AbortController();
46
- const l = a.signal;
47
- document.documentElement.classList.add("xYextDebug"), document.querySelectorAll(
48
- "[data-ya-eventname]"
49
- ).forEach((d, x) => {
50
- const m = d.closest("[data-ya-scope]"), v = m == null ? void 0 : m.dataset.yaScope, p = S(d, v);
51
- d.addEventListener(
52
- "mouseenter",
53
- () => {
54
- t([
55
- {
56
- elem: d,
57
- key: `${p.originalEventName}_${x}`,
58
- action: p.action,
59
- originalEventName: p.originalEventName,
60
- scope: p.scope
61
- }
62
- ]);
63
- },
64
- { signal: l }
65
- ), d.addEventListener(
66
- "mouseleave",
67
- () => {
68
- t([]);
69
- },
70
- { signal: l }
71
- );
72
- const f = d.dataset.yaScopeoverride;
73
- f ? k(f, p, m, d) : [
74
- v,
75
- ...Y(d, "[data-ya-scope]").map(
76
- (E) => E.dataset.yaScope
77
- )
78
- ].forEach((E) => {
79
- k(E || B, p, m, d);
80
- });
81
- }), c(!0);
82
- };
83
- u();
84
- const g = new MutationObserver(u);
85
- return g.observe(document, {
86
- childList: !0,
87
- subtree: !0
88
- }), () => {
89
- document.documentElement.classList.remove("xYextDebug"), g.disconnect(), a == null || a.abort();
90
- };
91
- }, []), r ? /* @__PURE__ */ o.jsxs(o.Fragment, { children: [
92
- /* @__PURE__ */ o.jsxs("div", { className: "analytics-debugger", children: [
93
- /* @__PURE__ */ o.jsxs("div", { className: "analytics-debugger-toggles", children: [
94
- /* @__PURE__ */ o.jsx(
95
- "button",
96
- {
97
- className: j("analytics-debugger-toggle", {
98
- "is-active": e === "Events"
99
- }),
100
- onClick: () => i("Events"),
101
- children: "Events"
102
- }
103
- ),
104
- /* @__PURE__ */ o.jsx(
105
- "button",
106
- {
107
- className: j("analytics-debugger-toggle", {
108
- "is-active": e === "Scopes"
109
- }),
110
- onClick: () => i("Scopes"),
111
- children: "Scopes"
112
- }
113
- )
114
- ] }),
115
- e && /* @__PURE__ */ o.jsx("div", { className: "analytics-debugger-tabs", children: e === "Events" ? /* @__PURE__ */ o.jsx(A, { data: b, setTooltips: t }) : /* @__PURE__ */ o.jsx($, { data: b, setTooltips: t }) })
116
- ] }),
117
- /* @__PURE__ */ o.jsx(L, { tooltips: n })
118
- ] }) : null;
119
- }
120
- const T = () => {
121
- const e = {};
122
- return Object.values(b).forEach((s) => {
123
- s.events.forEach((n) => {
124
- const { originalEventName: t } = n.eventData;
125
- e[t] || (e[t] = []), !e[t].find(
126
- (r) => r.el === n.el
127
- ) && e[t].push(n);
128
- });
129
- }), e;
130
- };
131
- function A(e) {
132
- const { setTooltips: s } = e, [n, t] = w([]), [r, c] = w(""), i = (a, u) => {
133
- n.forEach(
134
- (l) => l.classList.remove("analytics-event-highlight")
135
- );
136
- const g = a.map((l) => (l.el.scrollIntoView({ behavior: "smooth", block: "nearest" }), l.el.classList.add("analytics-event-highlight"), l.el));
137
- t(g), c(u), s(
138
- a.map((l, h) => ({
139
- elem: l.el,
140
- key: `${l.eventData.originalEventName}_${h}`,
141
- action: l.eventData.action,
142
- originalEventName: l.eventData.originalEventName,
143
- scope: l.eventData.scope
144
- }))
145
- );
146
- };
147
- return /* @__PURE__ */ o.jsxs("div", { className: "analytics-debugger-tab", children: [
148
- /* @__PURE__ */ o.jsx("h2", { className: "analytics-debugger-tab-title", children: "Event Names" }),
149
- /* @__PURE__ */ o.jsx("ul", { className: "analytics-debugger-list", children: Object.entries(T()).map(
150
- ([a, u], g) => {
151
- const l = `${a}_${g}`;
152
- return /* @__PURE__ */ o.jsx("li", { className: "analytics-debugger-listItem", children: /* @__PURE__ */ o.jsx(
153
- "button",
154
- {
155
- className: j("analytics-debugger-button", {
156
- "is-active": l === r
157
- }),
158
- onClick: () => i(u, l),
159
- children: a
160
- }
161
- ) }, l);
162
- }
163
- ) })
164
- ] });
165
- }
166
- function $(e) {
167
- const { data: s, setTooltips: n } = e, [t, r] = w(""), c = (i) => {
168
- const a = s[i];
169
- a.scopeEl && (a.scopeEl.scrollIntoView({
170
- behavior: "smooth",
171
- block: "nearest"
172
- }), r(i), n(
173
- a.events.map((u, g) => {
174
- const l = u.eventData;
175
- return {
176
- elem: u.el,
177
- key: `${l.originalEventName}_${g}`,
178
- action: l.action,
179
- originalEventName: l.originalEventName,
180
- scope: l.scope
181
- };
182
- })
183
- ));
184
- };
185
- return /* @__PURE__ */ o.jsxs("div", { className: "analytics-debugger-tab", children: [
186
- /* @__PURE__ */ o.jsx("h2", { className: "analytics-debugger-tab-title", children: "Scope Names" }),
187
- /* @__PURE__ */ o.jsx("ul", { className: "analytics-debugger-list", children: Object.keys(s).map((i, a) => {
188
- if (i !== B)
189
- return /* @__PURE__ */ o.jsx("li", { className: "analytics-debugger-listItem", children: /* @__PURE__ */ o.jsx(
190
- "button",
191
- {
192
- className: j("analytics-debugger-button", {
193
- "is-active": i === t
194
- }),
195
- onClick: () => c(i),
196
- children: i
197
- }
198
- ) }, i + a);
199
- }) })
200
- ] });
201
- }
202
- function L(e) {
203
- const s = O({});
204
- return N(() => {
205
- if (s.current)
206
- for (const n of Object.values(s.current)) {
207
- const t = Object.values(s.current).map((r) => r.el).filter((r) => r !== n.el);
208
- _(n, t), n.el.style.visibility = "visible";
209
- }
210
- }, [e.tooltips]), /* @__PURE__ */ o.jsx(o.Fragment, { children: e.tooltips.map((n) => /* @__PURE__ */ o.jsxs(
211
- "div",
212
- {
213
- style: { visibility: "hidden" },
214
- className: "analytics-debugger-tooltip",
215
- ref: (t) => {
216
- t ? s.current[n.key] = {
217
- el: t,
218
- tooltip: n
219
- } : delete s.current[n.key];
220
- },
221
- children: [
222
- /* @__PURE__ */ o.jsxs("span", { children: [
223
- "Action: ",
224
- n.action
225
- ] }),
226
- /* @__PURE__ */ o.jsx("br", {}),
227
- /* @__PURE__ */ o.jsxs("span", { children: [
228
- "Scope: ",
229
- n.scope
230
- ] }),
231
- /* @__PURE__ */ o.jsx("br", {}),
232
- /* @__PURE__ */ o.jsxs("span", { children: [
233
- "Original Event Name: ",
234
- n.originalEventName
235
- ] })
236
- ]
237
- },
238
- n.key
239
- )) });
240
- }
241
- function _(e, s) {
242
- for (let n = 0; n < 9; n++) {
243
- const t = H(
244
- e.tooltip.elem.getBoundingClientRect(),
245
- e.el,
246
- n
247
- );
248
- if (e.el.style.inset = `${t.top} auto auto ${t.left}`, !!P(
249
- e.el.getBoundingClientRect().left,
250
- e.el.getBoundingClientRect().top + window.scrollY,
251
- e.el.getBoundingClientRect().right,
252
- e.el.getBoundingClientRect().bottom + window.scrollY
253
- )) continue;
254
- let c = !0;
255
- for (let i = 0; i < s.length; i++) {
256
- const a = s[i];
257
- I(e.el, a) && (c = !1);
258
- }
259
- if (c) break;
260
- }
261
- }
262
- function I(e, s) {
263
- const n = e.getBoundingClientRect().top + window.scrollY, t = e.getBoundingClientRect().left, r = n + e.clientHeight, c = t + e.clientWidth, i = s.getBoundingClientRect().top + window.scrollY, a = s.getBoundingClientRect().left, u = i + s.clientHeight, g = a + s.clientWidth, l = (h, d, x, m, v, p, f, y) => x <= v && v <= f && m <= p && p <= y || x <= h && h <= f && m <= d && d <= y || x <= h && h <= f && m <= p && p <= y || x <= v && v <= f && m <= d && d <= y;
264
- return l(t, n, a, i, c, r, g, u) || l(a, i, t, n, g, u, c, r);
265
- }
266
- function P(e, s, n, t) {
267
- return e < 0 || n > window.innerWidth || s < 0 || t > document.documentElement.scrollHeight;
268
- }
269
- function H(e, s, n) {
270
- const t = s.clientHeight, r = s.clientWidth;
271
- let c, i;
272
- switch (n) {
273
- case 0: {
274
- i = window.scrollY + e.top - t + "px", c = e.left - r + "px";
275
- break;
276
- }
277
- case 1: {
278
- i = window.scrollY + e.top - t + "px", c = e.left + "px";
279
- break;
280
- }
281
- case 2: {
282
- i = window.scrollY + e.top - t + "px", c = e.right + "px";
283
- break;
284
- }
285
- case 3: {
286
- i = window.scrollY + e.top - t + "px", c = e.right - r + "px";
287
- break;
288
- }
289
- case 4: {
290
- i = window.scrollY + e.bottom + "px", c = e.left - r + "px";
291
- break;
292
- }
293
- case 5: {
294
- i = window.scrollY + e.bottom + "px", c = e.left + "px";
295
- break;
296
- }
297
- case 6: {
298
- i = window.scrollY + e.bottom + "px", c = e.right - r + "px";
299
- break;
300
- }
301
- case 7: {
302
- i = window.scrollY + e.bottom + "px", c = e.right + "px";
303
- break;
304
- }
305
- default:
306
- i = 0, c = 0;
307
- }
308
- return {
309
- top: i,
310
- left: c
311
- };
312
- }
313
- export {
314
- R as AnalyticsDebuggerInternal,
315
- z as default
316
- };