@yext/pages-components 1.0.0-rc.0 → 1.0.0-rc.2

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
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("./index-VNOXn8Iz.cjs"),p=require("react"),R=require("react-dom");function E(){return s.getRuntime().name!=="browser"||window.hasOwnProperty("debuggerInitialized")?null:(window.debuggerInitialized=!0,R.createPortal(s.jsxRuntimeExports.jsx(w,{}),document.body))}const b={};function w(){const[t,o]=p.useState(),[i,n]=p.useState([]),[l,a]=p.useState(!1),e=r=>{o(t===r?void 0:r)};return p.useEffect(()=>(document.documentElement.classList.add("xYextDebug"),document.querySelectorAll("[data-ya-scope]").forEach(c=>{const u=c.dataset.yaScope,d=c.querySelectorAll("[data-ya-track]");d.forEach((x,m)=>{const g=x.dataset.yaTrack;x.addEventListener("mouseenter",()=>{n([{eventEl:x,eventName:`${u}_${g}`,key:`${u}_${g}_${m}`}])}),x.addEventListener("mouseleave",()=>{n([])})}),u&&(b.hasOwnProperty(u)?b[u].events=[...b[u].events,...Array.from(d)]:b[u]={scope:c,events:Array.from(d)})}),a(!0),()=>{document.documentElement.classList.remove("xYextDebug")}),[]),l?s.jsxRuntimeExports.jsxs(s.jsxRuntimeExports.Fragment,{children:[s.jsxRuntimeExports.jsxs("div",{className:"analytics-debugger",children:[s.jsxRuntimeExports.jsxs("div",{className:"analytics-debugger-toggles",children:[s.jsxRuntimeExports.jsx("button",{className:s.c("analytics-debugger-toggle",{"is-active":t==="Events"}),onClick:()=>e("Events"),children:"Events"}),s.jsxRuntimeExports.jsx("button",{className:s.c("analytics-debugger-toggle",{"is-active":t==="Scopes"}),onClick:()=>e("Scopes"),children:"Scopes"})]}),t&&s.jsxRuntimeExports.jsx("div",{className:"analytics-debugger-tabs",children:t==="Events"?s.jsxRuntimeExports.jsx(k,{data:b,setTooltips:n}):s.jsxRuntimeExports.jsx($,{data:b,setTooltips:n})})]}),s.jsxRuntimeExports.jsx(T,{tooltips:i})]}):null}function k(t){const{data:o,setTooltips:i}=t,[n,l]=p.useState(),[a,e]=p.useState(""),r=(c,u,d)=>{c.scrollIntoView({behavior:"smooth",block:"nearest"}),n&&n.classList.remove("analytics-event-highlight"),l(c),c.classList.add("analytics-event-highlight"),e(d),i([{eventEl:c,eventName:u,key:d}])};return s.jsxRuntimeExports.jsxs("div",{className:"analytics-debugger-tab",children:[s.jsxRuntimeExports.jsx("h2",{className:"analytics-debugger-tab-title",children:"Event Names"}),s.jsxRuntimeExports.jsx("ul",{className:"analytics-debugger-list",children:Object.entries(o).map(([c,u])=>u.events.map((d,x)=>{const m=`${c}_${d.dataset.yaTrack}`,g=`${m}_${x}`;return s.jsxRuntimeExports.jsx("li",{className:"analytics-debugger-listItem",children:s.jsxRuntimeExports.jsx("button",{className:s.c("analytics-debugger-button",{"is-active":g===a}),onClick:()=>r(d,m,g),children:m})},g)}))})]})}function $(t){const{data:o,setTooltips:i}=t,[n,l]=p.useState(""),a=e=>{const r=o[e];r.scope.scrollIntoView({behavior:"smooth",block:"nearest"}),l(e),i(r.events.map((c,u)=>({eventEl:c,eventName:`${e}_${c.dataset.yaTrack}`,key:`${e}_${c.dataset.yaTrack}_${u}`})))};return s.jsxRuntimeExports.jsxs("div",{className:"analytics-debugger-tab",children:[s.jsxRuntimeExports.jsx("h2",{className:"analytics-debugger-tab-title",children:"Scope Names"}),s.jsxRuntimeExports.jsx("ul",{className:"analytics-debugger-list",children:Object.keys(o).map((e,r)=>s.jsxRuntimeExports.jsx("li",{className:"analytics-debugger-listItem",children:s.jsxRuntimeExports.jsx("button",{className:s.c("analytics-debugger-button",{"is-active":e===n}),onClick:()=>a(e),children:e})},e+r))})]})}function T(t){const o=p.useRef({});return p.useEffect(()=>{if(o.current)for(const i of Object.values(o.current)){const n=Object.values(o.current).map(l=>l.el).filter(l=>l!==i.el);B(i,n),i.el.style.visibility="visible"}},[t.tooltips]),s.jsxRuntimeExports.jsx(s.jsxRuntimeExports.Fragment,{children:t.tooltips.map(i=>s.jsxRuntimeExports.jsx("div",{style:{visibility:"hidden"},className:"analytics-debugger-tooltip",ref:n=>{n?o.current[i.key]={el:n,tooltip:i}:delete o.current[i.key]},children:s.jsxRuntimeExports.jsx("span",{children:i.eventName})},i.key))})}function B(t,o){for(let i=0;i<9;i++){const n=N(t.tooltip.eventEl.getBoundingClientRect(),t.el,i);if(t.el.style.inset=`${n.top} auto auto ${n.left}`,!!C(t.el.getBoundingClientRect().left,t.el.getBoundingClientRect().top+window.scrollY,t.el.getBoundingClientRect().right,t.el.getBoundingClientRect().bottom+window.scrollY))continue;let a=!0;for(let e=0;e<o.length;e++){const r=o[e];S(t.el,r)&&(a=!1)}if(a)break}}function S(t,o){const i=t.getBoundingClientRect().top+window.scrollY,n=t.getBoundingClientRect().left,l=i+t.clientHeight,a=n+t.clientWidth,e=o.getBoundingClientRect().top+window.scrollY,r=o.getBoundingClientRect().left,c=e+o.clientHeight,u=r+o.clientWidth,d=(x,m,g,h,j,f,v,y)=>g<=j&&j<=v&&h<=f&&f<=y||g<=x&&x<=v&&h<=m&&m<=y||g<=x&&x<=v&&h<=f&&f<=y||g<=j&&j<=v&&h<=m&&m<=y;return d(n,i,r,e,a,l,u,c)||d(r,e,n,i,u,c,a,l)}function C(t,o,i,n){return t<0||i>window.innerWidth||o<0||n>document.documentElement.scrollHeight}function N(t,o,i){const n=o.clientHeight,l=o.clientWidth;let a,e;switch(i){case 0:{e=window.scrollY+t.top-n+"px",a=t.left-l+"px";break}case 1:{e=window.scrollY+t.top-n+"px",a=t.left+"px";break}case 2:{e=window.scrollY+t.top-n+"px",a=t.right+"px";break}case 3:{e=window.scrollY+t.top-n+"px",a=t.right-l+"px";break}case 4:{e=window.scrollY+t.bottom+"px",a=t.left-l+"px";break}case 5:{e=window.scrollY+t.bottom+"px",a=t.left+"px";break}case 6:{e=window.scrollY+t.bottom+"px",a=t.right-l+"px";break}case 7:{e=window.scrollY+t.bottom+"px",a=t.right+"px";break}default:e=0,a=0}return{top:e,left:a}}exports.AnalyticsDebuggerInternal=w;exports.default=E;
@@ -0,0 +1,220 @@
1
+ import { g as B, j as o, c as j } from "./index-8UcaCfkH.js";
2
+ import { useState as p, useEffect as k, useRef as T } from "react";
3
+ import { createPortal as $ } from "react-dom";
4
+ function H() {
5
+ return B().name !== "browser" || window.hasOwnProperty("debuggerInitialized") ? null : (window.debuggerInitialized = !0, $(/* @__PURE__ */ o.jsx(C, {}), document.body));
6
+ }
7
+ const m = {};
8
+ function C() {
9
+ const [e, i] = p(), [s, n] = p([]), [l, a] = p(!1), t = (r) => {
10
+ i(e === r ? void 0 : r);
11
+ };
12
+ return k(() => (document.documentElement.classList.add("xYextDebug"), document.querySelectorAll("[data-ya-scope]").forEach((c) => {
13
+ const d = c.dataset.yaScope, u = c.querySelectorAll("[data-ya-track]");
14
+ u.forEach((g, h) => {
15
+ const b = g.dataset.yaTrack;
16
+ g.addEventListener("mouseenter", () => {
17
+ n([
18
+ {
19
+ eventEl: g,
20
+ eventName: `${d}_${b}`,
21
+ key: `${d}_${b}_${h}`
22
+ }
23
+ ]);
24
+ }), g.addEventListener("mouseleave", () => {
25
+ n([]);
26
+ });
27
+ }), d && (m.hasOwnProperty(d) ? m[d].events = [
28
+ ...m[d].events,
29
+ ...Array.from(u)
30
+ ] : m[d] = {
31
+ scope: c,
32
+ events: Array.from(u)
33
+ });
34
+ }), a(!0), () => {
35
+ document.documentElement.classList.remove("xYextDebug");
36
+ }), []), l ? /* @__PURE__ */ o.jsxs(o.Fragment, { children: [
37
+ /* @__PURE__ */ o.jsxs("div", { className: "analytics-debugger", children: [
38
+ /* @__PURE__ */ o.jsxs("div", { className: "analytics-debugger-toggles", children: [
39
+ /* @__PURE__ */ o.jsx(
40
+ "button",
41
+ {
42
+ className: j("analytics-debugger-toggle", {
43
+ "is-active": e === "Events"
44
+ }),
45
+ onClick: () => t("Events"),
46
+ children: "Events"
47
+ }
48
+ ),
49
+ /* @__PURE__ */ o.jsx(
50
+ "button",
51
+ {
52
+ className: j("analytics-debugger-toggle", {
53
+ "is-active": e === "Scopes"
54
+ }),
55
+ onClick: () => t("Scopes"),
56
+ children: "Scopes"
57
+ }
58
+ )
59
+ ] }),
60
+ e && /* @__PURE__ */ o.jsx("div", { className: "analytics-debugger-tabs", children: e === "Events" ? /* @__PURE__ */ o.jsx(N, { data: m, setTooltips: n }) : /* @__PURE__ */ o.jsx(Y, { data: m, setTooltips: n }) })
61
+ ] }),
62
+ /* @__PURE__ */ o.jsx(R, { tooltips: s })
63
+ ] }) : null;
64
+ }
65
+ function N(e) {
66
+ const { data: i, setTooltips: s } = e, [n, l] = p(), [a, t] = p(""), r = (c, d, u) => {
67
+ c.scrollIntoView({ behavior: "smooth", block: "nearest" }), n && n.classList.remove("analytics-event-highlight"), l(c), c.classList.add("analytics-event-highlight"), t(u), s([
68
+ {
69
+ eventEl: c,
70
+ eventName: d,
71
+ key: u
72
+ }
73
+ ]);
74
+ };
75
+ return /* @__PURE__ */ o.jsxs("div", { className: "analytics-debugger-tab", children: [
76
+ /* @__PURE__ */ o.jsx("h2", { className: "analytics-debugger-tab-title", children: "Event Names" }),
77
+ /* @__PURE__ */ o.jsx("ul", { className: "analytics-debugger-list", children: Object.entries(i).map(
78
+ ([c, d]) => d.events.map((u, g) => {
79
+ const h = `${c}_${u.dataset.yaTrack}`, b = `${h}_${g}`;
80
+ return /* @__PURE__ */ o.jsx("li", { className: "analytics-debugger-listItem", children: /* @__PURE__ */ o.jsx(
81
+ "button",
82
+ {
83
+ className: j("analytics-debugger-button", {
84
+ "is-active": b === a
85
+ }),
86
+ onClick: () => r(u, h, b),
87
+ children: h
88
+ }
89
+ ) }, b);
90
+ })
91
+ ) })
92
+ ] });
93
+ }
94
+ function Y(e) {
95
+ const { data: i, setTooltips: s } = e, [n, l] = p(""), a = (t) => {
96
+ const r = i[t];
97
+ r.scope.scrollIntoView({ behavior: "smooth", block: "nearest" }), l(t), s(
98
+ r.events.map((c, d) => ({
99
+ eventEl: c,
100
+ eventName: `${t}_${c.dataset.yaTrack}`,
101
+ key: `${t}_${c.dataset.yaTrack}_${d}`
102
+ }))
103
+ );
104
+ };
105
+ return /* @__PURE__ */ o.jsxs("div", { className: "analytics-debugger-tab", children: [
106
+ /* @__PURE__ */ o.jsx("h2", { className: "analytics-debugger-tab-title", children: "Scope Names" }),
107
+ /* @__PURE__ */ o.jsx("ul", { className: "analytics-debugger-list", children: Object.keys(i).map((t, r) => /* @__PURE__ */ o.jsx("li", { className: "analytics-debugger-listItem", children: /* @__PURE__ */ o.jsx(
108
+ "button",
109
+ {
110
+ className: j("analytics-debugger-button", {
111
+ "is-active": t === n
112
+ }),
113
+ onClick: () => a(t),
114
+ children: t
115
+ }
116
+ ) }, t + r)) })
117
+ ] });
118
+ }
119
+ function R(e) {
120
+ const i = T({});
121
+ return k(() => {
122
+ if (i.current)
123
+ for (const s of Object.values(i.current)) {
124
+ const n = Object.values(i.current).map((l) => l.el).filter((l) => l !== s.el);
125
+ E(s, n), s.el.style.visibility = "visible";
126
+ }
127
+ }, [e.tooltips]), /* @__PURE__ */ o.jsx(o.Fragment, { children: e.tooltips.map((s) => /* @__PURE__ */ o.jsx(
128
+ "div",
129
+ {
130
+ style: { visibility: "hidden" },
131
+ className: "analytics-debugger-tooltip",
132
+ ref: (n) => {
133
+ n ? i.current[s.key] = {
134
+ el: n,
135
+ tooltip: s
136
+ } : delete i.current[s.key];
137
+ },
138
+ children: /* @__PURE__ */ o.jsx("span", { children: s.eventName })
139
+ },
140
+ s.key
141
+ )) });
142
+ }
143
+ function E(e, i) {
144
+ for (let s = 0; s < 9; s++) {
145
+ const n = L(
146
+ e.tooltip.eventEl.getBoundingClientRect(),
147
+ e.el,
148
+ s
149
+ );
150
+ if (e.el.style.inset = `${n.top} auto auto ${n.left}`, !!S(
151
+ e.el.getBoundingClientRect().left,
152
+ e.el.getBoundingClientRect().top + window.scrollY,
153
+ e.el.getBoundingClientRect().right,
154
+ e.el.getBoundingClientRect().bottom + window.scrollY
155
+ ))
156
+ continue;
157
+ let a = !0;
158
+ for (let t = 0; t < i.length; t++) {
159
+ const r = i[t];
160
+ A(e.el, r) && (a = !1);
161
+ }
162
+ if (a)
163
+ break;
164
+ }
165
+ }
166
+ function A(e, i) {
167
+ const s = e.getBoundingClientRect().top + window.scrollY, n = e.getBoundingClientRect().left, l = s + e.clientHeight, a = n + e.clientWidth, t = i.getBoundingClientRect().top + window.scrollY, r = i.getBoundingClientRect().left, c = t + i.clientHeight, d = r + i.clientWidth, u = (g, h, b, f, v, x, y, w) => b <= v && v <= y && f <= x && x <= w || b <= g && g <= y && f <= h && h <= w || b <= g && g <= y && f <= x && x <= w || b <= v && v <= y && f <= h && h <= w;
168
+ return u(n, s, r, t, a, l, d, c) || u(r, t, n, s, d, c, a, l);
169
+ }
170
+ function S(e, i, s, n) {
171
+ return e < 0 || s > window.innerWidth || i < 0 || n > document.documentElement.scrollHeight;
172
+ }
173
+ function L(e, i, s) {
174
+ const n = i.clientHeight, l = i.clientWidth;
175
+ let a, t;
176
+ switch (s) {
177
+ case 0: {
178
+ t = window.scrollY + e.top - n + "px", a = e.left - l + "px";
179
+ break;
180
+ }
181
+ case 1: {
182
+ t = window.scrollY + e.top - n + "px", a = e.left + "px";
183
+ break;
184
+ }
185
+ case 2: {
186
+ t = window.scrollY + e.top - n + "px", a = e.right + "px";
187
+ break;
188
+ }
189
+ case 3: {
190
+ t = window.scrollY + e.top - n + "px", a = e.right - l + "px";
191
+ break;
192
+ }
193
+ case 4: {
194
+ t = window.scrollY + e.bottom + "px", a = e.left - l + "px";
195
+ break;
196
+ }
197
+ case 5: {
198
+ t = window.scrollY + e.bottom + "px", a = e.left + "px";
199
+ break;
200
+ }
201
+ case 6: {
202
+ t = window.scrollY + e.bottom + "px", a = e.right - l + "px";
203
+ break;
204
+ }
205
+ case 7: {
206
+ t = window.scrollY + e.bottom + "px", a = e.right + "px";
207
+ break;
208
+ }
209
+ default:
210
+ t = 0, a = 0;
211
+ }
212
+ return {
213
+ top: t,
214
+ left: a
215
+ };
216
+ }
217
+ export {
218
+ C as AnalyticsDebuggerInternal,
219
+ H as default
220
+ };