@yext/visual-editor 0.0.18 → 0.0.19

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/README.md CHANGED
@@ -22,5 +22,4 @@ This library provides components necessary to set up a Pages repository that can
22
22
 
23
23
  | Function |
24
24
  |--------------------------------------------------------------------------|
25
- | [resolveVisualEditorData](./src/utils/README.md#resolvevisualeditordata) |
26
25
  | [resolveYextEntityField](./src/utils/README.md#resolveYextEntityField) |
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("./index-BC8EbMY5.cjs"),p=require("react"),k=require("react-dom");function S(){return l.Zl().name!=="browser"||window.hasOwnProperty("debuggerInitialized")?null:(window.debuggerInitialized=!0,k.createPortal(l.lt.jsx(j,{}),document.body))}const Y=(e,a)=>{const n=e.dataset.yaAction,t=e.dataset.yaScopeoverride,o=e.dataset.yaEventname,c=t||a;return{action:n,originalEventName:c?`${c}_${o}`:o,scope:c}},C=(e,a)=>{const n=[];let t=e;for(;t!=null&&t.parentElement;)t=t.parentElement.closest(a),t&&n.push(t);return n},b={},w="YA_NO_SCOPE",N=(e,a,n,t)=>{b.hasOwnProperty(e)?b[e].events.map(o=>o.el).includes(t)||(b[e].events=[...b[e].events,{eventData:a,el:t}]):b[e]={scopeEl:n||t,events:[{eventData:a,el:t}]}};function j(){const[e,a]=p.useState(),[n,t]=p.useState([]),[o,c]=p.useState(!1),s=i=>{a(e===i?void 0:i)};return p.useEffect(()=>(document.documentElement.classList.add("xYextDebug"),document.querySelectorAll("[data-ya-eventname]").forEach((i,u)=>{const r=i.closest("[data-ya-scope]"),d=r==null?void 0:r.dataset.yaScope,g=Y(i,d);i.addEventListener("mouseenter",()=>{t([{elem:i,key:`${g.originalEventName}_${u}`,action:g.action,originalEventName:g.originalEventName,scope:g.scope}])}),i.addEventListener("mouseleave",()=>{t([])});const v=i.dataset.yaScopeoverride;v?N(v,g,r,i):[d,...C(i,"[data-ya-scope]").map(m=>m.dataset.yaScope)].forEach(m=>{N(m||w,g,r,i)})}),c(!0),()=>{document.documentElement.classList.remove("xYextDebug")}),[]),o?l.lt.jsxs(l.lt.Fragment,{children:[l.lt.jsxs("div",{className:"analytics-debugger",children:[l.lt.jsxs("div",{className:"analytics-debugger-toggles",children:[l.lt.jsx("button",{className:l.Jl("analytics-debugger-toggle",{"is-active":e==="Events"}),onClick:()=>s("Events"),children:"Events"}),l.lt.jsx("button",{className:l.Jl("analytics-debugger-toggle",{"is-active":e==="Scopes"}),onClick:()=>s("Scopes"),children:"Scopes"})]}),e&&l.lt.jsx("div",{className:"analytics-debugger-tabs",children:e==="Events"?l.lt.jsx(O,{data:b,setTooltips:t}):l.lt.jsx(D,{data:b,setTooltips:t})})]}),l.lt.jsx($,{tooltips:n})]}):null}const R=()=>{const e=[];return Object.entries(b).map(([a,n])=>n.events.map(t=>{e.map(o=>o.eventData.originalEventName).includes(t.eventData.originalEventName)||e.push(t)})),e};function O(e){const{setTooltips:a}=e,[n,t]=p.useState(),[o,c]=p.useState(""),s=(i,u,r)=>{i.scrollIntoView({behavior:"smooth",block:"nearest"}),n&&n.classList.remove("analytics-event-highlight"),t(i),i.classList.add("analytics-event-highlight"),c(r),a([{elem:i,key:r,action:u.action,originalEventName:u.originalEventName,scope:u.scope}])};return l.lt.jsxs("div",{className:"analytics-debugger-tab",children:[l.lt.jsx("h2",{className:"analytics-debugger-tab-title",children:"Event Names"}),l.lt.jsx("ul",{className:"analytics-debugger-list",children:R().map((i,u)=>{const r=i.eventData,d=`${r.originalEventName}_${u}`;return l.lt.jsx("li",{className:"analytics-debugger-listItem",children:l.lt.jsx("button",{className:l.Jl("analytics-debugger-button",{"is-active":d===o}),onClick:()=>s(i.el,r,d),children:r.originalEventName})},d)})})]})}function D(e){const{data:a,setTooltips:n}=e,[t,o]=p.useState(""),c=s=>{const i=a[s];i.scopeEl&&(i.scopeEl.scrollIntoView({behavior:"smooth",block:"nearest"}),o(s),n(i.events.map((u,r)=>{const d=u.eventData;return{elem:u.el,key:`${d.originalEventName}_${r}`,action:d.action,originalEventName:d.originalEventName,scope:d.scope}})))};return l.lt.jsxs("div",{className:"analytics-debugger-tab",children:[l.lt.jsx("h2",{className:"analytics-debugger-tab-title",children:"Scope Names"}),l.lt.jsx("ul",{className:"analytics-debugger-list",children:Object.keys(a).map((s,i)=>{if(s!==w)return l.lt.jsx("li",{className:"analytics-debugger-listItem",children:l.lt.jsx("button",{className:l.Jl("analytics-debugger-button",{"is-active":s===t}),onClick:()=>c(s),children:s})},s+i)})})]})}function $(e){const a=p.useRef({});return p.useEffect(()=>{if(a.current)for(const n of Object.values(a.current)){const t=Object.values(a.current).map(o=>o.el).filter(o=>o!==n.el);B(n,t),n.el.style.visibility="visible"}},[e.tooltips]),l.lt.jsx(l.lt.Fragment,{children:e.tooltips.map(n=>l.lt.jsxs("div",{style:{visibility:"hidden"},className:"analytics-debugger-tooltip",ref:t=>{t?a.current[n.key]={el:t,tooltip:n}:delete a.current[n.key]},children:[l.lt.jsxs("span",{children:["Action: ",n.action]}),l.lt.jsx("br",{}),l.lt.jsxs("span",{children:["Scope: ",n.scope]}),l.lt.jsx("br",{}),l.lt.jsxs("span",{children:["Original Event Name: ",n.originalEventName]})]},n.key))})}function B(e,a){for(let n=0;n<9;n++){const t=_(e.tooltip.elem.getBoundingClientRect(),e.el,n);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 o=!0;for(let c=0;c<a.length;c++){const s=a[c];I(e.el,s)&&(o=!1)}if(o)break}}function I(e,a){const n=e.getBoundingClientRect().top+window.scrollY,t=e.getBoundingClientRect().left,o=n+e.clientHeight,c=t+e.clientWidth,s=a.getBoundingClientRect().top+window.scrollY,i=a.getBoundingClientRect().left,u=s+a.clientHeight,r=i+a.clientWidth,d=(g,v,m,h,x,y,E,f)=>m<=x&&x<=E&&h<=y&&y<=f||m<=g&&g<=E&&h<=v&&v<=f||m<=g&&g<=E&&h<=y&&y<=f||m<=x&&x<=E&&h<=v&&v<=f;return d(t,n,i,s,c,o,r,u)||d(i,s,t,n,r,u,c,o)}function L(e,a,n,t){return e<0||n>window.innerWidth||a<0||t>document.documentElement.scrollHeight}function _(e,a,n){const t=a.clientHeight,o=a.clientWidth;let c,s;switch(n){case 0:{s=window.scrollY+e.top-t+"px",c=e.left-o+"px";break}case 1:{s=window.scrollY+e.top-t+"px",c=e.left+"px";break}case 2:{s=window.scrollY+e.top-t+"px",c=e.right+"px";break}case 3:{s=window.scrollY+e.top-t+"px",c=e.right-o+"px";break}case 4:{s=window.scrollY+e.bottom+"px",c=e.left-o+"px";break}case 5:{s=window.scrollY+e.bottom+"px",c=e.left+"px";break}case 6:{s=window.scrollY+e.bottom+"px",c=e.right-o+"px";break}case 7:{s=window.scrollY+e.bottom+"px",c=e.right+"px";break}default:s=0,c=0}return{top:s,left:c}}exports.AnalyticsDebuggerInternal=j;exports.default=S;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("./index-eGvjhehK.cjs"),p=require("react"),k=require("react-dom");function S(){return l.Zl().name!=="browser"||window.hasOwnProperty("debuggerInitialized")?null:(window.debuggerInitialized=!0,k.createPortal(l.lt.jsx(j,{}),document.body))}const Y=(e,a)=>{const n=e.dataset.yaAction,t=e.dataset.yaScopeoverride,o=e.dataset.yaEventname,c=t||a;return{action:n,originalEventName:c?`${c}_${o}`:o,scope:c}},C=(e,a)=>{const n=[];let t=e;for(;t!=null&&t.parentElement;)t=t.parentElement.closest(a),t&&n.push(t);return n},b={},w="YA_NO_SCOPE",N=(e,a,n,t)=>{b.hasOwnProperty(e)?b[e].events.map(o=>o.el).includes(t)||(b[e].events=[...b[e].events,{eventData:a,el:t}]):b[e]={scopeEl:n||t,events:[{eventData:a,el:t}]}};function j(){const[e,a]=p.useState(),[n,t]=p.useState([]),[o,c]=p.useState(!1),s=i=>{a(e===i?void 0:i)};return p.useEffect(()=>(document.documentElement.classList.add("xYextDebug"),document.querySelectorAll("[data-ya-eventname]").forEach((i,u)=>{const r=i.closest("[data-ya-scope]"),d=r==null?void 0:r.dataset.yaScope,g=Y(i,d);i.addEventListener("mouseenter",()=>{t([{elem:i,key:`${g.originalEventName}_${u}`,action:g.action,originalEventName:g.originalEventName,scope:g.scope}])}),i.addEventListener("mouseleave",()=>{t([])});const v=i.dataset.yaScopeoverride;v?N(v,g,r,i):[d,...C(i,"[data-ya-scope]").map(m=>m.dataset.yaScope)].forEach(m=>{N(m||w,g,r,i)})}),c(!0),()=>{document.documentElement.classList.remove("xYextDebug")}),[]),o?l.lt.jsxs(l.lt.Fragment,{children:[l.lt.jsxs("div",{className:"analytics-debugger",children:[l.lt.jsxs("div",{className:"analytics-debugger-toggles",children:[l.lt.jsx("button",{className:l.Jl("analytics-debugger-toggle",{"is-active":e==="Events"}),onClick:()=>s("Events"),children:"Events"}),l.lt.jsx("button",{className:l.Jl("analytics-debugger-toggle",{"is-active":e==="Scopes"}),onClick:()=>s("Scopes"),children:"Scopes"})]}),e&&l.lt.jsx("div",{className:"analytics-debugger-tabs",children:e==="Events"?l.lt.jsx(O,{data:b,setTooltips:t}):l.lt.jsx(D,{data:b,setTooltips:t})})]}),l.lt.jsx($,{tooltips:n})]}):null}const R=()=>{const e=[];return Object.entries(b).map(([a,n])=>n.events.map(t=>{e.map(o=>o.eventData.originalEventName).includes(t.eventData.originalEventName)||e.push(t)})),e};function O(e){const{setTooltips:a}=e,[n,t]=p.useState(),[o,c]=p.useState(""),s=(i,u,r)=>{i.scrollIntoView({behavior:"smooth",block:"nearest"}),n&&n.classList.remove("analytics-event-highlight"),t(i),i.classList.add("analytics-event-highlight"),c(r),a([{elem:i,key:r,action:u.action,originalEventName:u.originalEventName,scope:u.scope}])};return l.lt.jsxs("div",{className:"analytics-debugger-tab",children:[l.lt.jsx("h2",{className:"analytics-debugger-tab-title",children:"Event Names"}),l.lt.jsx("ul",{className:"analytics-debugger-list",children:R().map((i,u)=>{const r=i.eventData,d=`${r.originalEventName}_${u}`;return l.lt.jsx("li",{className:"analytics-debugger-listItem",children:l.lt.jsx("button",{className:l.Jl("analytics-debugger-button",{"is-active":d===o}),onClick:()=>s(i.el,r,d),children:r.originalEventName})},d)})})]})}function D(e){const{data:a,setTooltips:n}=e,[t,o]=p.useState(""),c=s=>{const i=a[s];i.scopeEl&&(i.scopeEl.scrollIntoView({behavior:"smooth",block:"nearest"}),o(s),n(i.events.map((u,r)=>{const d=u.eventData;return{elem:u.el,key:`${d.originalEventName}_${r}`,action:d.action,originalEventName:d.originalEventName,scope:d.scope}})))};return l.lt.jsxs("div",{className:"analytics-debugger-tab",children:[l.lt.jsx("h2",{className:"analytics-debugger-tab-title",children:"Scope Names"}),l.lt.jsx("ul",{className:"analytics-debugger-list",children:Object.keys(a).map((s,i)=>{if(s!==w)return l.lt.jsx("li",{className:"analytics-debugger-listItem",children:l.lt.jsx("button",{className:l.Jl("analytics-debugger-button",{"is-active":s===t}),onClick:()=>c(s),children:s})},s+i)})})]})}function $(e){const a=p.useRef({});return p.useEffect(()=>{if(a.current)for(const n of Object.values(a.current)){const t=Object.values(a.current).map(o=>o.el).filter(o=>o!==n.el);B(n,t),n.el.style.visibility="visible"}},[e.tooltips]),l.lt.jsx(l.lt.Fragment,{children:e.tooltips.map(n=>l.lt.jsxs("div",{style:{visibility:"hidden"},className:"analytics-debugger-tooltip",ref:t=>{t?a.current[n.key]={el:t,tooltip:n}:delete a.current[n.key]},children:[l.lt.jsxs("span",{children:["Action: ",n.action]}),l.lt.jsx("br",{}),l.lt.jsxs("span",{children:["Scope: ",n.scope]}),l.lt.jsx("br",{}),l.lt.jsxs("span",{children:["Original Event Name: ",n.originalEventName]})]},n.key))})}function B(e,a){for(let n=0;n<9;n++){const t=_(e.tooltip.elem.getBoundingClientRect(),e.el,n);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 o=!0;for(let c=0;c<a.length;c++){const s=a[c];I(e.el,s)&&(o=!1)}if(o)break}}function I(e,a){const n=e.getBoundingClientRect().top+window.scrollY,t=e.getBoundingClientRect().left,o=n+e.clientHeight,c=t+e.clientWidth,s=a.getBoundingClientRect().top+window.scrollY,i=a.getBoundingClientRect().left,u=s+a.clientHeight,r=i+a.clientWidth,d=(g,v,m,h,x,y,E,f)=>m<=x&&x<=E&&h<=y&&y<=f||m<=g&&g<=E&&h<=v&&v<=f||m<=g&&g<=E&&h<=y&&y<=f||m<=x&&x<=E&&h<=v&&v<=f;return d(t,n,i,s,c,o,r,u)||d(i,s,t,n,r,u,c,o)}function L(e,a,n,t){return e<0||n>window.innerWidth||a<0||t>document.documentElement.scrollHeight}function _(e,a,n){const t=a.clientHeight,o=a.clientWidth;let c,s;switch(n){case 0:{s=window.scrollY+e.top-t+"px",c=e.left-o+"px";break}case 1:{s=window.scrollY+e.top-t+"px",c=e.left+"px";break}case 2:{s=window.scrollY+e.top-t+"px",c=e.right+"px";break}case 3:{s=window.scrollY+e.top-t+"px",c=e.right-o+"px";break}case 4:{s=window.scrollY+e.bottom+"px",c=e.left-o+"px";break}case 5:{s=window.scrollY+e.bottom+"px",c=e.left+"px";break}case 6:{s=window.scrollY+e.bottom+"px",c=e.right-o+"px";break}case 7:{s=window.scrollY+e.bottom+"px",c=e.right+"px";break}default:s=0,c=0}return{top:s,left:c}}exports.AnalyticsDebuggerInternal=j;exports.default=S;
@@ -1,4 +1,4 @@
1
- import { Z as Y, l as i, J as N } from "./index-BMCKPRVM.js";
1
+ import { Z as Y, l as i, J as N } from "./index-BGhAL0Pq.js";
2
2
  import { useState as v, useEffect as j, useRef as C } from "react";
3
3
  import { createPortal as S } from "react-dom";
4
4
  function z() {