@thebase/ui 1.1.0 → 1.1.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.
@@ -1 +1 @@
1
- (()=>{var F=Object.defineProperty;var B=(e,t)=>{for(var n in t)F(e,n,{get:t[n],enumerable:!0})};var _={};B(_,{DEFAULT_FILE_TYPES:()=>A,init:()=>ce,track:()=>d});var A=["pdf","xlsx","docx","txt","rtf","csv","exe","key","pps","ppt","pptx","7z","pkg","rar","gz","zip","avi","mov","mp4","mpeg","wmv","midi","mp3","wav","wma","dmg"];var $=/^localhost$|^127(\.[0-9]+){0,2}\.[0-9]+$|^\[::1?\]$/,z=/thebase-event-name(=|--)(.+)/,V="/api/event",q=/^(https?:\/\/|\/)/,o={},C=A,p,O,w=!1,v,I,N={},E=-1,r=0,l=0,u,s;function G(e){if(o.isInitialized)throw Error("thebase.analytics.init() can only be called once");let t=e.apiPath||V,n=e.endpoint||e.backendUrl&&`${e.backendUrl.replace(/\/+$/,"")}/${t.replace(/^\/+/,"")}`;if(!n)throw Error("thebase.analytics.init(): backendUrl (or endpoint) is required");if(!q.test(n))throw Error(`thebase.analytics.init(): "${n}" must be an http(s):// URL or a /path on this site`);Object.assign(o,e,{domain:e.domain||location.hostname,endpoint:n,autoCapturePageviews:e.autoCapturePageviews!==!1,logging:e.logging!==!1,bindToWindow:e.bindToWindow!==!1,isInitialized:!0})}function M(e,t,n){fetch(e,{method:"POST",headers:{"Content-Type":"text/plain"},keepalive:!0,body:JSON.stringify(t)}).then(i=>n?.callback?.({status:i.status})).catch(i=>n?.callback?.({error:i}))}function K(){w&&(x(),u=S(),s=L())}function W(e){v=!1,I=e.u,N=e.p,E=-1,l=0,r=Date.now(),j()}function x(){let e=D();if(v||E>=s&&e<3e3)return;E=s;let t={n:"engagement",sd:Math.round(s/u*100),d:o.domain,u:I,p:N,e,v:36};r=0,l=0,o.hashBasedRouting&&(t.h=1),M(o.endpoint,t)}function m(){document.visibilityState==="visible"&&document.hasFocus()&&r===0?r=Date.now():(document.visibilityState==="hidden"||!document.hasFocus())&&(l=D(),r=0,x())}function j(){w||(document.addEventListener("visibilitychange",m),window.addEventListener("blur",m),window.addEventListener("focus",m),w=!0)}function D(){return r?l+(Date.now()-r):l}function S(){let e=document.body,t=document.documentElement;return Math.max(e.scrollHeight,e.offsetHeight,e.clientHeight,t.scrollHeight,t.offsetHeight,t.clientHeight)}function L(){return u<=window.innerHeight?u:window.scrollY+window.innerHeight}function Y(){u=S()}function J(){s=Math.max(s,L())}function Q(){u=S(),s=L(),new window.ResizeObserver(Y).observe(document.documentElement),document.addEventListener("scroll",J)}function d(e,t){if(!o.isInitialized)throw Error("thebase.analytics.track() can only be called after thebase.analytics.init()");let n=e==="pageview";if(n&&K(),!o.captureOnLocalhost){if($.test(location.hostname)||location.protocol==="file:")return f(e,t,"localhost");if((window._phantom||window.__nightmare||navigator.webdriver||window.Cypress)&&!window.__thebase)return f(e,t)}try{if(localStorage.thebase_ignore==="true")return f(e,t,"localStorage flag")}catch{}let i={n:e,v:36,u:t?.u||t?.url||location.href,d:o.domain,r:document.referrer||null};if(t?.props&&(i.p=t.props),t?.interactive===!1&&(i.i=!1),t?.revenue&&(i.$=t.revenue),o.customProperties){let a=typeof o.customProperties=="function"?o.customProperties(e):o.customProperties;typeof a=="object"&&(i.p={...a,...i.p})}if(o.hashBasedRouting&&(i.h=1),typeof o.transformRequest=="function"&&(i=o.transformRequest(i),!i))return f(e,t,"transformRequest");n&&W(i),M(o.endpoint,i,t)}function f(e,t,n){n&&o.logging&&console.warn(`Ignoring Event: ${n}`),t?.callback?.(),e==="pageview"&&(v=!0)}function H(e){return e?.tagName?.toLowerCase()==="a"}function X(e){for(;e&&(e.tagName===void 0||!H(e)||!e.href);)e=e.parentNode;return e}function Z(e){return e&&typeof e.href=="string"&&e.host&&e.host!==location.host}function ee(e){return!!e&&C.includes(e.split(".").pop())}function T(e){return!!e?.classList&&[...e.classList].some(t=>z.test(t))}function y(e,t){return!!e&&t<=3&&(T(e)||y(e.parentNode,t+1))}function U(e){let t=T(e)?e:e?.parentNode,n={name:null,props:{},revenue:{}};if(!t?.classList)return n;for(let i of t.classList){let a=i.match(/thebase-event-(.+)(=|--)(.+)/);if(a){let k=a[3].replace(/\+/g," ");a[1].toLowerCase()==="name"?n.name=k:n.props[a[1]]=k}let c=i.match(/thebase-revenue-(.+)(=|--)(.+)/);c&&(n.revenue[c[1]]=c[3])}return n}function g(e){d(e.name,{props:e.props,revenue:e.revenue})}function R(e){if(e.type==="auxclick"&&e.button!==1)return;let t=X(e.target);if(y(t,0))return;if(o.outboundLinks&&Z(t))return g({name:"Outbound Link: Click",props:{url:t.href}});let n=t&&typeof t.href=="string"&&t.href.split("?")[0];o.fileDownloads&&ee(n)&&g({name:"File Download",props:{url:n}})}function P(e){if(e.type==="auxclick"&&e.button!==1)return;let t,n,i=e.target;for(let c=0;c<=3&&i;c++){if(i.tagName?.toLowerCase()==="form")return;H(i)&&(t=i),T(i)&&(n=i),i=i.parentNode}if(!n)return;let a=U(n);t&&(a.props.url=t.href),g(a)}function te(e){let t=e.target;(t.hasAttribute("novalidate")||t.checkValidity())&&!y(t,0)&&d("Form: Submission")}function ne(e){let t=U(e.target);t.name&&g(t)}function ie(){document.addEventListener("click",R),document.addEventListener("auxclick",R),Array.isArray(o.fileDownloads?.fileExtensions)&&(C=o.fileDownloads.fileExtensions),o.formSubmissions&&document.addEventListener("submit",te,!0),document.addEventListener("submit",ne),document.addEventListener("click",P),document.addEventListener("auxclick",P)}function h(e){!o.hashBasedRouting&&e&&p===location.pathname||(p=location.pathname,d("pageview"))}function b(){h(!0)}function oe(...e){O.apply(this,e),b()}function ae(){!p&&document.visibilityState==="visible"&&h()}function re(e){e.persisted&&h()}function se(){o.hashBasedRouting?window.addEventListener("hashchange",b):(O=window.history.pushState,window.history.pushState=oe,window.addEventListener("popstate",b)),document.visibilityState==="hidden"||document.visibilityState==="prerender"?document.addEventListener("visibilitychange",ae):h(),window.addEventListener("pageshow",re)}function ce(e){G(e||{}),Q(),o.autoCapturePageviews&&se(),ie(),o.bindToWindow&&(window.thebase??(window.thebase={}),window.thebase.track=d,window.thebase.track.s="npm",window.thebase.track.v=36,window.thebase.track.l=!0)}window.thebase??(window.thebase={});window.thebase.analytics=_;})();
1
+ (()=>{var F=Object.defineProperty;var B=(e,t)=>{for(var n in t)F(e,n,{get:t[n],enumerable:!0})};var k={};B(k,{DEFAULT_FILE_TYPES:()=>C,init:()=>ue,track:()=>d,visitorContext:()=>Q});var C=["pdf","xlsx","docx","txt","rtf","csv","exe","key","pps","ppt","pptx","7z","pkg","rar","gz","zip","avi","mov","mp4","mpeg","wmv","midi","mp3","wav","wma","dmg"];var z=/^localhost$|^127(\.[0-9]+){0,2}\.[0-9]+$|^\[::1?\]$/,$=/thebase-event-name(=|--)(.+)/,V="/api/event",q=/^(https?:\/\/|\/)/,o={},O=C,m,A,w=!1,v,I,M={},E=-1,r=0,l=0,u,s;function G(e){if(o.isInitialized)throw Error("thebase.analytics.init() can only be called once");let t=e.apiPath||V,n=e.endpoint||e.backendUrl&&`${e.backendUrl.replace(/\/+$/,"")}/${t.replace(/^\/+/,"")}`;if(!n)throw Error("thebase.analytics.init(): backendUrl (or endpoint) is required");if(!q.test(n))throw Error(`thebase.analytics.init(): "${n}" must be an http(s):// URL or a /path on this site`);Object.assign(o,e,{domain:e.domain||location.hostname,endpoint:n,autoCapturePageviews:e.autoCapturePageviews!==!1,logging:e.logging!==!1,bindToWindow:e.bindToWindow!==!1,isInitialized:!0})}function N(e,t,n){fetch(e,{method:"POST",headers:{"Content-Type":"text/plain"},keepalive:!0,body:JSON.stringify(t)}).then(i=>n?.callback?.({status:i.status})).catch(i=>n?.callback?.({error:i}))}function K(){w&&(x(),u=S(),s=L())}function W(e){v=!1,I=e.u,M=e.p,E=-1,l=0,r=Date.now(),j()}function x(){let e=D();if(v||E>=s&&e<3e3)return;E=s;let t={n:"engagement",sd:Math.round(s/u*100),d:o.domain,u:I,p:M,e,v:36};r=0,l=0,o.hashBasedRouting&&(t.h=1),N(o.endpoint,t)}function p(){document.visibilityState==="visible"&&document.hasFocus()&&r===0?r=Date.now():(document.visibilityState==="hidden"||!document.hasFocus())&&(l=D(),r=0,x())}function j(){w||(document.addEventListener("visibilitychange",p),window.addEventListener("blur",p),window.addEventListener("focus",p),w=!0)}function D(){return r?l+(Date.now()-r):l}function S(){let e=document.body,t=document.documentElement;return Math.max(e.scrollHeight,e.offsetHeight,e.clientHeight,t.scrollHeight,t.offsetHeight,t.clientHeight)}function L(){return u<=window.innerHeight?u:window.scrollY+window.innerHeight}function Y(){u=S()}function J(){s=Math.max(s,L())}function Z(){u=S(),s=L(),new window.ResizeObserver(Y).observe(document.documentElement),document.addEventListener("scroll",J)}function Q(){let e=window.innerWidth;return{tz:Intl.DateTimeFormat().resolvedOptions().timeZone,lang:navigator.language,screen:e<576?"Mobile":e<992?"Tablet":e<1440?"Laptop":"Desktop"}}function d(e,t){if(!o.isInitialized)throw Error("thebase.analytics.track() can only be called after thebase.analytics.init()");let n=e==="pageview";if(n&&K(),!o.captureOnLocalhost){if(z.test(location.hostname)||location.protocol==="file:")return f(e,t,"localhost");if((window._phantom||window.__nightmare||navigator.webdriver||window.Cypress)&&!window.__thebase)return f(e,t)}try{if(localStorage.thebase_ignore==="true")return f(e,t,"localStorage flag")}catch{}let i={n:e,v:36,u:t?.u||t?.url||location.href,d:o.domain,r:document.referrer||null};if(t?.props&&(i.p=t.props),t?.interactive===!1&&(i.i=!1),t?.revenue&&(i.$=t.revenue),o.customProperties){let a=typeof o.customProperties=="function"?o.customProperties(e):o.customProperties;typeof a=="object"&&(i.p={...a,...i.p})}if(o.hashBasedRouting&&(i.h=1),typeof o.transformRequest=="function"&&(i=o.transformRequest(i),!i))return f(e,t,"transformRequest");n&&W(i),N(o.endpoint,i,t)}function f(e,t,n){n&&o.logging&&console.warn(`Ignoring Event: ${n}`),t?.callback?.(),e==="pageview"&&(v=!0)}function H(e){return e?.tagName?.toLowerCase()==="a"}function X(e){for(;e&&(e.tagName===void 0||!H(e)||!e.href);)e=e.parentNode;return e}function ee(e){return e&&typeof e.href=="string"&&e.host&&e.host!==location.host}function te(e){return!!e&&O.includes(e.split(".").pop())}function T(e){return!!e?.classList&&[...e.classList].some(t=>$.test(t))}function y(e,t){return!!e&&t<=3&&(T(e)||y(e.parentNode,t+1))}function U(e){let t=T(e)?e:e?.parentNode,n={name:null,props:{},revenue:{}};if(!t?.classList)return n;for(let i of t.classList){let a=i.match(/thebase-event-(.+)(=|--)(.+)/);if(a){let _=a[3].replace(/\+/g," ");a[1].toLowerCase()==="name"?n.name=_:n.props[a[1]]=_}let c=i.match(/thebase-revenue-(.+)(=|--)(.+)/);c&&(n.revenue[c[1]]=c[3])}return n}function g(e){d(e.name,{props:e.props,revenue:e.revenue})}function R(e){if(e.type==="auxclick"&&e.button!==1)return;let t=X(e.target);if(y(t,0))return;if(o.outboundLinks&&ee(t))return g({name:"Outbound Link: Click",props:{url:t.href}});let n=t&&typeof t.href=="string"&&t.href.split("?")[0];o.fileDownloads&&te(n)&&g({name:"File Download",props:{url:n}})}function P(e){if(e.type==="auxclick"&&e.button!==1)return;let t,n,i=e.target;for(let c=0;c<=3&&i;c++){if(i.tagName?.toLowerCase()==="form")return;H(i)&&(t=i),T(i)&&(n=i),i=i.parentNode}if(!n)return;let a=U(n);t&&(a.props.url=t.href),g(a)}function ne(e){let t=e.target;(t.hasAttribute("novalidate")||t.checkValidity())&&!y(t,0)&&d("Form: Submission")}function ie(e){let t=U(e.target);t.name&&g(t)}function oe(){document.addEventListener("click",R),document.addEventListener("auxclick",R),Array.isArray(o.fileDownloads?.fileExtensions)&&(O=o.fileDownloads.fileExtensions),o.formSubmissions&&document.addEventListener("submit",ne,!0),document.addEventListener("submit",ie),document.addEventListener("click",P),document.addEventListener("auxclick",P)}function h(e){!o.hashBasedRouting&&e&&m===location.pathname||(m=location.pathname,d("pageview"))}function b(){h(!0)}function ae(...e){A.apply(this,e),b()}function re(){!m&&document.visibilityState==="visible"&&h()}function se(e){e.persisted&&h()}function ce(){o.hashBasedRouting?window.addEventListener("hashchange",b):(A=window.history.pushState,window.history.pushState=ae,window.addEventListener("popstate",b)),document.visibilityState==="hidden"||document.visibilityState==="prerender"?document.addEventListener("visibilitychange",re):h(),window.addEventListener("pageshow",se)}function ue(e){G(e||{}),Z(),o.autoCapturePageviews&&ce(),oe(),o.bindToWindow&&(window.thebase??(window.thebase={}),window.thebase.track=d,window.thebase.track.s="npm",window.thebase.track.v=36,window.thebase.track.l=!0)}window.thebase??(window.thebase={});window.thebase.analytics=k;})();