@yext/pages-components 1.0.0-rc.9 → 1.0.0

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.
@@ -1,36 +1,6 @@
1
1
  This file was generated with the generate-license-file npm package!
2
2
  https://www.npmjs.com/package/generate-license-file
3
3
 
4
- The following npm package may be included in this product:
5
-
6
- - @types/mdast@3.0.10
7
-
8
- This package contains the following license and notice below:
9
-
10
- MIT License
11
-
12
- Copyright (c) Microsoft Corporation.
13
-
14
- Permission is hereby granted, free of charge, to any person obtaining a copy
15
- of this software and associated documentation files (the "Software"), to deal
16
- in the Software without restriction, including without limitation the rights
17
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
18
- copies of the Software, and to permit persons to whom the Software is
19
- furnished to do so, subject to the following conditions:
20
-
21
- The above copyright notice and this permission notice shall be included in all
22
- copies or substantial portions of the Software.
23
-
24
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
27
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
29
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30
- SOFTWARE
31
-
32
- -----------
33
-
34
4
  The following npm package may be included in this product:
35
5
 
36
6
  - unified@11.0.4
@@ -203,7 +173,7 @@ SOFTWARE.
203
173
 
204
174
  The following npm package may be included in this product:
205
175
 
206
- - @yext/analytics@0.6.5
176
+ - @yext/analytics@1.0.0-beta.5
207
177
 
208
178
  This package contains the following license and notice below:
209
179
 
@@ -244,7 +214,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
244
214
 
245
215
  The following npm package may be included in this product:
246
216
 
247
- - react-markdown@8.0.7
217
+ - react-markdown@8.0.0
248
218
 
249
219
  This package contains the following license and notice below:
250
220
 
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./index-CPtU5eOw.cjs"),x=require("react"),N=require("react-dom");function k(){return i.getRuntime().name!=="browser"||window.hasOwnProperty("debuggerInitialized")?null:(window.debuggerInitialized=!0,N.createPortal(i.jsxRuntimeExports.jsx(w,{}),document.body))}const S=(e,n)=>{const s=e.dataset.yaAction,t=e.dataset.yaScopeoverride,c=e.dataset.yaEventname,a=t||n;return{action:s,originalEventName:a?`${a}_${c}`:c,scope:a}},C=(e,n)=>{const s=[];let t=e;for(;t!=null&&t.parentElement;)t=t.parentElement.closest(n),t&&s.push(t);return s},m={},R="YA_NO_SCOPE",y=(e,n,s,t)=>{m.hasOwnProperty(e)?m[e].events.map(c=>c.el).includes(t)||(m[e].events=[...m[e].events,{eventData:n,el:t}]):m[e]={scopeEl:s||t,events:[{eventData:n,el:t}]}};function w(){const[e,n]=x.useState(),[s,t]=x.useState([]),[c,a]=x.useState(!1),o=l=>{n(e===l?void 0:l)};return x.useEffect(()=>(document.documentElement.classList.add("xYextDebug"),document.querySelectorAll("[data-ya-eventname]").forEach((r,d)=>{const u=r.closest("[data-ya-scope]"),v=u==null?void 0:u.dataset.yaScope,g=S(r,v);r.addEventListener("mouseenter",()=>{t([{elem:r,key:`${g.originalEventName}_${d}`,action:g.action,originalEventName:g.originalEventName,scope:g.scope}])}),r.addEventListener("mouseleave",()=>{t([])});const b=r.dataset.yaScopeoverride;b?y(b,g,u,r):[v,...C(r,"[data-ya-scope]").map(p=>p.dataset.yaScope)].forEach(p=>{y(p||R,g,u,r)})}),a(!0),()=>{document.documentElement.classList.remove("xYextDebug")}),[]),c?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:m,setTooltips:t}):i.jsxRuntimeExports.jsx(Y,{data:m,setTooltips:t})})]}),i.jsxRuntimeExports.jsx(T,{tooltips:s})]}):null}const B=()=>{const e=[];return Object.entries(m).map(([n,s])=>s.events.map(t=>{e.map(c=>c.eventData.originalEventName).includes(t.eventData.originalEventName)||e.push(t)})),e};function O(e){const{setTooltips:n}=e,[s,t]=x.useState(),[c,a]=x.useState(""),o=(l,r,d)=>{l.scrollIntoView({behavior:"smooth",block:"nearest"}),s&&s.classList.remove("analytics-event-highlight"),t(l),l.classList.add("analytics-event-highlight"),a(d),n([{elem:l,key:d,action:r.action,originalEventName:r.originalEventName,scope:r.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:B().map((l,r)=>{const d=l.eventData,u=`${d.originalEventName}_${r}`;return i.jsxRuntimeExports.jsx("li",{className:"analytics-debugger-listItem",children:i.jsxRuntimeExports.jsx("button",{className:i.c("analytics-debugger-button",{"is-active":u===c}),onClick:()=>o(l.el,d,u),children:d.originalEventName})},u)})})]})}function Y(e){const{data:n,setTooltips:s}=e,[t,c]=x.useState(""),a=o=>{const l=n[o];l.scopeEl&&(l.scopeEl.scrollIntoView({behavior:"smooth",block:"nearest"}),c(o),s(l.events.map((r,d)=>{const u=r.eventData;return{elem:r.el,key:`${u.originalEventName}_${d}`,action:u.action,originalEventName:u.originalEventName,scope:u.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,l)=>{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:()=>a(o),children:o})},o+l)})})]})}function T(e){const n=x.useRef({});return x.useEffect(()=>{if(n.current)for(const s of Object.values(n.current)){const t=Object.values(n.current).map(c=>c.el).filter(c=>c!==s.el);$(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 $(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}`,!!A(e.el.getBoundingClientRect().left,e.el.getBoundingClientRect().top+window.scrollY,e.el.getBoundingClientRect().right,e.el.getBoundingClientRect().bottom+window.scrollY))continue;let a=!0;for(let o=0;o<n.length;o++){const l=n[o];D(e.el,l)&&(a=!1)}if(a)break}}function D(e,n){const s=e.getBoundingClientRect().top+window.scrollY,t=e.getBoundingClientRect().left,c=s+e.clientHeight,a=t+e.clientWidth,o=n.getBoundingClientRect().top+window.scrollY,l=n.getBoundingClientRect().left,r=o+n.clientHeight,d=l+n.clientWidth,u=(v,g,b,h,p,j,E,f)=>b<=p&&p<=E&&h<=j&&j<=f||b<=v&&v<=E&&h<=g&&g<=f||b<=v&&v<=E&&h<=j&&j<=f||b<=p&&p<=E&&h<=g&&g<=f;return u(t,s,l,o,a,c,d,r)||u(l,o,t,s,d,r,a,c)}function A(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,c=n.clientWidth;let a,o;switch(s){case 0:{o=window.scrollY+e.top-t+"px",a=e.left-c+"px";break}case 1:{o=window.scrollY+e.top-t+"px",a=e.left+"px";break}case 2:{o=window.scrollY+e.top-t+"px",a=e.right+"px";break}case 3:{o=window.scrollY+e.top-t+"px",a=e.right-c+"px";break}case 4:{o=window.scrollY+e.bottom+"px",a=e.left-c+"px";break}case 5:{o=window.scrollY+e.bottom+"px",a=e.left+"px";break}case 6:{o=window.scrollY+e.bottom+"px",a=e.right-c+"px";break}case 7:{o=window.scrollY+e.bottom+"px",a=e.right+"px";break}default:o=0,a=0}return{top:o,left:a}}exports.AnalyticsDebuggerInternal=w;exports.default=k;
@@ -0,0 +1,286 @@
1
+ import { g as C, j as o, c as j } from "./index-DaOqO1Xz.js";
2
+ import { useState as b, useEffect as N, useRef as B } from "react";
3
+ import { createPortal as S } from "react-dom";
4
+ function q() {
5
+ return C().name !== "browser" || window.hasOwnProperty("debuggerInitialized") ? null : (window.debuggerInitialized = !0, S(/* @__PURE__ */ o.jsx(R, {}), document.body));
6
+ }
7
+ const Y = (e, s) => {
8
+ const n = e.dataset.yaAction, t = e.dataset.yaScopeoverride, c = e.dataset.yaEventname, a = t || s;
9
+ return {
10
+ action: n,
11
+ originalEventName: a ? `${a}_${c}` : c,
12
+ scope: a
13
+ };
14
+ }, O = (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
+ }, p = {}, k = "YA_NO_SCOPE", E = (e, s, n, t) => {
21
+ p.hasOwnProperty(e) ? p[e].events.map((c) => c.el).includes(t) || (p[e].events = [
22
+ ...p[e].events,
23
+ {
24
+ eventData: s,
25
+ el: t
26
+ }
27
+ ]) : p[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] = b(), [n, t] = b([]), [c, a] = b(!1), i = (l) => {
40
+ s(e === l ? void 0 : l);
41
+ };
42
+ return N(() => (document.documentElement.classList.add("xYextDebug"), document.querySelectorAll(
43
+ "[data-ya-eventname]"
44
+ ).forEach((r, u) => {
45
+ const d = r.closest("[data-ya-scope]"), v = d == null ? void 0 : d.dataset.yaScope, g = Y(r, v);
46
+ r.addEventListener("mouseenter", () => {
47
+ t([
48
+ {
49
+ elem: r,
50
+ key: `${g.originalEventName}_${u}`,
51
+ action: g.action,
52
+ originalEventName: g.originalEventName,
53
+ scope: g.scope
54
+ }
55
+ ]);
56
+ }), r.addEventListener("mouseleave", () => {
57
+ t([]);
58
+ });
59
+ const h = r.dataset.yaScopeoverride;
60
+ h ? E(h, g, d, r) : [
61
+ v,
62
+ ...O(r, "[data-ya-scope]").map(
63
+ (m) => m.dataset.yaScope
64
+ )
65
+ ].forEach((m) => {
66
+ E(m || k, g, d, r);
67
+ });
68
+ }), a(!0), () => {
69
+ document.documentElement.classList.remove("xYextDebug");
70
+ }), []), c ? /* @__PURE__ */ o.jsxs(o.Fragment, { children: [
71
+ /* @__PURE__ */ o.jsxs("div", { className: "analytics-debugger", children: [
72
+ /* @__PURE__ */ o.jsxs("div", { className: "analytics-debugger-toggles", children: [
73
+ /* @__PURE__ */ o.jsx(
74
+ "button",
75
+ {
76
+ className: j("analytics-debugger-toggle", {
77
+ "is-active": e === "Events"
78
+ }),
79
+ onClick: () => i("Events"),
80
+ children: "Events"
81
+ }
82
+ ),
83
+ /* @__PURE__ */ o.jsx(
84
+ "button",
85
+ {
86
+ className: j("analytics-debugger-toggle", {
87
+ "is-active": e === "Scopes"
88
+ }),
89
+ onClick: () => i("Scopes"),
90
+ children: "Scopes"
91
+ }
92
+ )
93
+ ] }),
94
+ e && /* @__PURE__ */ o.jsx("div", { className: "analytics-debugger-tabs", children: e === "Events" ? /* @__PURE__ */ o.jsx(D, { data: p, setTooltips: t }) : /* @__PURE__ */ o.jsx(A, { data: p, setTooltips: t }) })
95
+ ] }),
96
+ /* @__PURE__ */ o.jsx($, { tooltips: n })
97
+ ] }) : null;
98
+ }
99
+ const T = () => {
100
+ const e = [];
101
+ return Object.entries(p).map(
102
+ ([s, n]) => n.events.map((t) => {
103
+ e.map((c) => c.eventData.originalEventName).includes(t.eventData.originalEventName) || e.push(t);
104
+ })
105
+ ), e;
106
+ };
107
+ function D(e) {
108
+ const { setTooltips: s } = e, [n, t] = b(), [c, a] = b(""), i = (l, r, u) => {
109
+ l.scrollIntoView({ behavior: "smooth", block: "nearest" }), n && n.classList.remove("analytics-event-highlight"), t(l), l.classList.add("analytics-event-highlight"), a(u), s([
110
+ {
111
+ elem: l,
112
+ key: u,
113
+ action: r.action,
114
+ originalEventName: r.originalEventName,
115
+ scope: r.scope
116
+ }
117
+ ]);
118
+ };
119
+ return /* @__PURE__ */ o.jsxs("div", { className: "analytics-debugger-tab", children: [
120
+ /* @__PURE__ */ o.jsx("h2", { className: "analytics-debugger-tab-title", children: "Event Names" }),
121
+ /* @__PURE__ */ o.jsx("ul", { className: "analytics-debugger-list", children: T().map((l, r) => {
122
+ const u = l.eventData, d = `${u.originalEventName}_${r}`;
123
+ return /* @__PURE__ */ o.jsx("li", { className: "analytics-debugger-listItem", children: /* @__PURE__ */ o.jsx(
124
+ "button",
125
+ {
126
+ className: j("analytics-debugger-button", {
127
+ "is-active": d === c
128
+ }),
129
+ onClick: () => i(l.el, u, d),
130
+ children: u.originalEventName
131
+ }
132
+ ) }, d);
133
+ }) })
134
+ ] });
135
+ }
136
+ function A(e) {
137
+ const { data: s, setTooltips: n } = e, [t, c] = b(""), a = (i) => {
138
+ const l = s[i];
139
+ l.scopeEl && (l.scopeEl.scrollIntoView({
140
+ behavior: "smooth",
141
+ block: "nearest"
142
+ }), c(i), n(
143
+ l.events.map((r, u) => {
144
+ const d = r.eventData;
145
+ return {
146
+ elem: r.el,
147
+ key: `${d.originalEventName}_${u}`,
148
+ action: d.action,
149
+ originalEventName: d.originalEventName,
150
+ scope: d.scope
151
+ };
152
+ })
153
+ ));
154
+ };
155
+ return /* @__PURE__ */ o.jsxs("div", { className: "analytics-debugger-tab", children: [
156
+ /* @__PURE__ */ o.jsx("h2", { className: "analytics-debugger-tab-title", children: "Scope Names" }),
157
+ /* @__PURE__ */ o.jsx("ul", { className: "analytics-debugger-list", children: Object.keys(s).map((i, l) => {
158
+ if (i !== k)
159
+ return /* @__PURE__ */ o.jsx("li", { className: "analytics-debugger-listItem", children: /* @__PURE__ */ o.jsx(
160
+ "button",
161
+ {
162
+ className: j("analytics-debugger-button", {
163
+ "is-active": i === t
164
+ }),
165
+ onClick: () => a(i),
166
+ children: i
167
+ }
168
+ ) }, i + l);
169
+ }) })
170
+ ] });
171
+ }
172
+ function $(e) {
173
+ const s = B({});
174
+ return N(() => {
175
+ if (s.current)
176
+ for (const n of Object.values(s.current)) {
177
+ const t = Object.values(s.current).map((c) => c.el).filter((c) => c !== n.el);
178
+ L(n, t), n.el.style.visibility = "visible";
179
+ }
180
+ }, [e.tooltips]), /* @__PURE__ */ o.jsx(o.Fragment, { children: e.tooltips.map((n) => /* @__PURE__ */ o.jsxs(
181
+ "div",
182
+ {
183
+ style: { visibility: "hidden" },
184
+ className: "analytics-debugger-tooltip",
185
+ ref: (t) => {
186
+ t ? s.current[n.key] = {
187
+ el: t,
188
+ tooltip: n
189
+ } : delete s.current[n.key];
190
+ },
191
+ children: [
192
+ /* @__PURE__ */ o.jsxs("span", { children: [
193
+ "Action: ",
194
+ n.action
195
+ ] }),
196
+ /* @__PURE__ */ o.jsx("br", {}),
197
+ /* @__PURE__ */ o.jsxs("span", { children: [
198
+ "Scope: ",
199
+ n.scope
200
+ ] }),
201
+ /* @__PURE__ */ o.jsx("br", {}),
202
+ /* @__PURE__ */ o.jsxs("span", { children: [
203
+ "Original Event Name: ",
204
+ n.originalEventName
205
+ ] })
206
+ ]
207
+ },
208
+ n.key
209
+ )) });
210
+ }
211
+ function L(e, s) {
212
+ for (let n = 0; n < 9; n++) {
213
+ const t = P(
214
+ e.tooltip.elem.getBoundingClientRect(),
215
+ e.el,
216
+ n
217
+ );
218
+ if (e.el.style.inset = `${t.top} auto auto ${t.left}`, !!I(
219
+ e.el.getBoundingClientRect().left,
220
+ e.el.getBoundingClientRect().top + window.scrollY,
221
+ e.el.getBoundingClientRect().right,
222
+ e.el.getBoundingClientRect().bottom + window.scrollY
223
+ )) continue;
224
+ let a = !0;
225
+ for (let i = 0; i < s.length; i++) {
226
+ const l = s[i];
227
+ _(e.el, l) && (a = !1);
228
+ }
229
+ if (a) break;
230
+ }
231
+ }
232
+ function _(e, s) {
233
+ const n = e.getBoundingClientRect().top + window.scrollY, t = e.getBoundingClientRect().left, c = n + e.clientHeight, a = t + e.clientWidth, i = s.getBoundingClientRect().top + window.scrollY, l = s.getBoundingClientRect().left, r = i + s.clientHeight, u = l + s.clientWidth, d = (v, g, h, f, m, x, w, y) => h <= m && m <= w && f <= x && x <= y || h <= v && v <= w && f <= g && g <= y || h <= v && v <= w && f <= x && x <= y || h <= m && m <= w && f <= g && g <= y;
234
+ return d(t, n, l, i, a, c, u, r) || d(l, i, t, n, u, r, a, c);
235
+ }
236
+ function I(e, s, n, t) {
237
+ return e < 0 || n > window.innerWidth || s < 0 || t > document.documentElement.scrollHeight;
238
+ }
239
+ function P(e, s, n) {
240
+ const t = s.clientHeight, c = s.clientWidth;
241
+ let a, i;
242
+ switch (n) {
243
+ case 0: {
244
+ i = window.scrollY + e.top - t + "px", a = e.left - c + "px";
245
+ break;
246
+ }
247
+ case 1: {
248
+ i = window.scrollY + e.top - t + "px", a = e.left + "px";
249
+ break;
250
+ }
251
+ case 2: {
252
+ i = window.scrollY + e.top - t + "px", a = e.right + "px";
253
+ break;
254
+ }
255
+ case 3: {
256
+ i = window.scrollY + e.top - t + "px", a = e.right - c + "px";
257
+ break;
258
+ }
259
+ case 4: {
260
+ i = window.scrollY + e.bottom + "px", a = e.left - c + "px";
261
+ break;
262
+ }
263
+ case 5: {
264
+ i = window.scrollY + e.bottom + "px", a = e.left + "px";
265
+ break;
266
+ }
267
+ case 6: {
268
+ i = window.scrollY + e.bottom + "px", a = e.right - c + "px";
269
+ break;
270
+ }
271
+ case 7: {
272
+ i = window.scrollY + e.bottom + "px", a = e.right + "px";
273
+ break;
274
+ }
275
+ default:
276
+ i = 0, a = 0;
277
+ }
278
+ return {
279
+ top: i,
280
+ left: a
281
+ };
282
+ }
283
+ export {
284
+ R as AnalyticsDebuggerInternal,
285
+ q as default
286
+ };