onboard-engine 1.5.4 → 1.5.5

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.js CHANGED
@@ -1,3 +1,3 @@
1
1
  "use client";
2
- "use strict";"use client";var tt=Object.create;var U=Object.defineProperty;var et=Object.getOwnPropertyDescriptor;var nt=Object.getOwnPropertyNames;var ot=Object.getPrototypeOf,rt=Object.prototype.hasOwnProperty;var it=(r,c)=>{for(var y in c)U(r,y,{get:c[y],enumerable:!0})},_=(r,c,y,T)=>{if(c&&typeof c=="object"||typeof c=="function")for(let S of nt(c))!rt.call(r,S)&&S!==y&&U(r,S,{get:()=>c[S],enumerable:!(T=et(c,S))||T.enumerable});return r};var st=(r,c,y)=>(y=r!=null?tt(ot(r)):{},_(c||!r||!r.__esModule?U(y,"default",{value:r,enumerable:!0}):y,r)),at=r=>_(U({},"__esModule",{value:!0}),r);var bt={};it(bt,{OnboardingProvider:()=>pt,useOnboarding:()=>K});module.exports=at(bt);var l=require("react"),H=st(require("js-cookie"));var x=require("react"),G=require("react-dom");var b=require("react/jsx-runtime"),ut=()=>(0,b.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,b.jsx)("path",{d:"M15 18l-6-6 6-6"})}),lt=()=>(0,b.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,b.jsx)("path",{d:"M9 18l6-6-6-6"})}),ct=()=>(0,b.jsxs)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,b.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,b.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]}),Q=()=>{let{config:r,currentStep:c,nextStep:y,prevStep:T,finish:S,isFirstStep:L,isLastStep:p}=K(),[g,h]=(0,x.useState)(null),[W,$]=(0,x.useState)({top:0,left:0}),[R,C]=(0,x.useState)({x:0,y:0}),z=(0,x.useRef)(!1),E=(0,x.useRef)({x:0,y:0}),P=(0,x.useRef)(null);(0,x.useEffect)(()=>{C({x:0,y:0})},[c]);let N=(0,x.useRef)(()=>{}),O=(0,x.useCallback)(i=>{if(!z.current)return;let f=i.clientX-E.current.x,k=i.clientY-E.current.y;C({x:f,y:k})},[]),I=(0,x.useCallback)(()=>{z.current=!1,P.current&&(P.current.style.transition="top 0.3s cubic-bezier(0.25, 0.1, 0.25, 1), left 0.3s cubic-bezier(0.25, 0.1, 0.25, 1)",P.current.style.cursor=r.metadata.draggable?"grab":"auto"),window.removeEventListener("pointermove",O),window.removeEventListener("pointerup",N.current)},[r.metadata.draggable,O]);(0,x.useEffect)(()=>{N.current=I},[I]);let j=i=>{r.metadata.draggable&&(i.stopPropagation(),i.preventDefault(),z.current=!0,E.current={x:i.clientX-R.x,y:i.clientY-R.y},P.current&&(P.current.style.transition="none",P.current.style.cursor="grabbing"),window.addEventListener("pointermove",O),window.addEventListener("pointerup",I))},B=(0,x.useCallback)(i=>{let o=i.top,n=window.innerHeight-i.bottom,a=i.left,u=window.innerWidth-i.right,d=0,s=0;return n>232?(d=i.bottom+12,s=Math.max(20,Math.min(window.innerWidth-300-20,i.left+i.width/2-300/2))):o>232?(d=i.top-200-12,s=Math.max(20,Math.min(window.innerWidth-300-20,i.left+i.width/2-300/2))):u>332?(d=Math.max(20,Math.min(window.innerHeight-200-20,i.top+i.height/2-200/2)),s=i.right+12):a>332?(d=Math.max(20,Math.min(window.innerHeight-200-20,i.top+i.height/2-200/2)),s=i.left-300-12):(d=window.innerHeight/2-200/2,s=window.innerWidth/2-300/2),{top:d+window.scrollY,left:s+window.scrollX}},[]),F=(0,x.useCallback)(()=>{if(!c)return;let i=document.querySelector(`[data-onboarding-id="${c.attribute}"]`);if(i){let f=i.getBoundingClientRect(),k=r.style?.padding||0,e={top:f.top-k,bottom:f.bottom+k,left:f.left-k,right:f.right+k,width:f.width+k*2,height:f.height+k*2},t={top:e.top+window.scrollY,left:e.left+window.scrollX,width:e.width,height:e.height},o=B(e);h(n=>n&&Math.abs(n.top-t.top)<.5&&Math.abs(n.left-t.left)<.5&&Math.abs(n.width-t.width)<.5&&Math.abs(n.height-t.height)<.5?n:t),$(n=>Math.abs(n.top-o.top)<.5&&Math.abs(n.left-o.left)<.5?n:o)}else h(null)},[c,B,r.style]);if((0,x.useEffect)(()=>{let i,f=()=>{clearTimeout(i),i=setTimeout(F,16)};f(),window.addEventListener("resize",f),window.addEventListener("scroll",f);let k=new MutationObserver(t=>{t.some(n=>n.type==="childList"||n.type==="attributes"&&n.attributeName?.includes("data-onboarding-id"))&&f()});k.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["data-onboarding-id","style","class"]});let e=null;if(typeof ResizeObserver<"u"){e=new ResizeObserver(f),e.observe(document.body);let t=c?.attribute?document.querySelector(`[data-onboarding-id="${c.attribute}"]`):null;t&&e.observe(t)}return()=>{clearTimeout(i),window.removeEventListener("resize",f),window.removeEventListener("scroll",f),window.removeEventListener("pointermove",O),window.removeEventListener("pointerup",I),k.disconnect(),e&&e.disconnect()}},[F,c?.attribute,O,I]),!c||!g)return null;let A={...r.style?.background,transition:"all 0.3s cubic-bezier(0.25, 0.1, 0.25, 1)"},v=i=>{i.stopPropagation()},J=(0,b.jsxs)("div",{className:"onboard-overlay-container",children:[(0,b.jsx)("div",{style:{height:g.top,...A},className:"onboard-overlay-mask onboard-mask-top",onPointerDown:v,onMouseDown:v,onClick:v}),(0,b.jsx)("div",{style:{top:g.top+g.height,height:`calc(100vh - ${g.top+g.height}px)`,...A},className:"onboard-overlay-mask onboard-mask-bottom",onPointerDown:v,onMouseDown:v,onClick:v}),(0,b.jsx)("div",{style:{top:g.top,height:g.height,width:g.left,...A},className:"onboard-overlay-mask onboard-mask-left",onPointerDown:v,onMouseDown:v,onClick:v}),(0,b.jsx)("div",{style:{top:g.top,height:g.height,left:g.left+g.width,width:`calc(100% - ${g.left+g.width}px)`,...A},className:"onboard-overlay-mask",onPointerDown:v,onMouseDown:v,onClick:v}),(0,b.jsxs)("div",{ref:P,className:"onboard-tooltip",onPointerDown:j,style:{zIndex:1e6,...r.style?.container,top:W.top+R.y,left:W.left+R.x,transition:"top 0.3s cubic-bezier(0.25, 0.1, 0.25, 1), left 0.3s cubic-bezier(0.25, 0.1, 0.25, 1)",cursor:r.metadata.draggable?"grab":"auto",touchAction:"none"},onMouseDown:v,onClick:v,children:[(0,b.jsxs)("div",{className:"onboard-tooltip-header",children:[(0,b.jsx)("h3",{className:"onboard-tooltip-title",children:c.title}),(0,b.jsx)("button",{onClick:i=>{i.stopPropagation(),S()},className:"onboard-close-button",children:(0,b.jsx)(ct,{})})]}),(0,b.jsx)("p",{className:"onboard-tooltip-description",children:c.description}),(0,b.jsxs)("div",{className:"onboard-tooltip-footer",children:[(0,b.jsxs)("button",{onClick:i=>{i.stopPropagation(),T()},disabled:L,className:"onboard-button-ghost",style:{background:"none",border:"none",cursor:L?"not-allowed":"pointer",...r.style?.prev},children:[(0,b.jsx)(ut,{}),"Prev"]}),p?(0,b.jsx)("button",{onClick:i=>{i.stopPropagation(),y()},className:"onboard-button-primary",style:{border:"none",cursor:"pointer",...r.style?.finish},children:"Finish"}):(0,b.jsxs)("button",{onClick:i=>{i.stopPropagation(),y()},className:"onboard-button-primary",style:{border:"none",cursor:"pointer",...L?r.style?.start:{},...L?{}:r.style?.next},children:[L&&r.style?.start?"Start":"Next",!(L&&r.style?.start)&&(0,b.jsx)(lt,{})]})]})]})]});return typeof document<"u"?(0,G.createPortal)(J,document.body):null};var X=require("react/jsx-runtime"),V=(0,l.createContext)(void 0),D="onboarding_state",dt=()=>{if(typeof window<"u"){let r=H.default.get(D);if(r)try{let c=JSON.parse(r);if(c&&typeof c=="object")return{currentStepIndex:c.currentStepIndex??0,currentSubStepIndex:c.currentSubStepIndex??null,isActive:c.isActive??!0,completedSteps:c.completedSteps??[],subStepProgress:c.subStepProgress??{}}}catch{}}return{currentStepIndex:0,currentSubStepIndex:null,isActive:!0,completedSteps:[],subStepProgress:{}}},pt=({config:r,ssr:c=!1,onNavigate:y,children:T})=>{let[S,L]=(0,l.useState)(!1),[p,g]=(0,l.useState)({currentStepIndex:0,currentSubStepIndex:null,isActive:!1,completedSteps:[],subStepProgress:{}}),[h,W]=(0,l.useState)(""),[$,R]=(0,l.useState)(!1),C=(0,l.useRef)(r),z=(0,l.useRef)(y),E=(0,l.useRef)(""),P=(0,l.useRef)(""),N=(0,l.useRef)(!1);(0,l.useEffect)(()=>{L(!0);let e=dt();g(e),W(window.location.pathname),P.current=window.location.pathname},[]),(0,l.useEffect)(()=>{S&&h!==P.current&&(P.current=h,E.current="")},[h,S]),(0,l.useEffect)(()=>{C.current=r,z.current=y},[r,y]),(0,l.useEffect)(()=>{if(!S)return;let e=()=>{let a=window.location.pathname;W(a)};window.addEventListener("popstate",e);let t=window.history.pushState,o=window.history.replaceState;window.history.pushState=function(...a){t.apply(this,a),e()},window.history.replaceState=function(...a){o.apply(this,a),e()};let n=setInterval(e,200);return()=>{window.removeEventListener("popstate",e),window.history.pushState=t,window.history.replaceState=o,clearInterval(n)}},[S]);let O=(0,l.useCallback)(e=>{e&&(z.current?z.current(e):window.location.href=e)},[]),I=(0,l.useCallback)((e,t)=>{if(!e?.urlMatch||!t)return!1;let o=!1;if(e.urlMatch.includes("*")){let n=e.urlMatch.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/\\\*/g,".*");o=new RegExp(`^${n}$`).test(t)}else o=t===e.urlMatch;return o},[]),j=(0,l.useCallback)((e,t)=>{let o=C.current,n=[],a=window.location.pathname,u=(s,w=-1)=>{if(w!==null&&(s.click&&n.push(s.attribute),s.subSteps)){let m=w===-1?s.subSteps.length:w;for(let M=0;M<m;M++)s.subSteps[M].click&&n.push(s.subSteps[M].attribute)}};for(let s=0;s<=e;s++){let w=o.steps[s];I(w,a)&&(s<e?u(w):t!==null&&u(w,t))}if(n.length===0)return;let d=s=>{if(s>=n.length)return;let w=n[s],m=document.querySelector(`[data-onboarding-id="${w}"]`);m&&m.click(),setTimeout(()=>d(s+1),500)};setTimeout(()=>d(0),500)},[I,h]);(0,l.useEffect)(()=>{if(c&&!S){L(!0);return}let e=C.current,t=e.metadata.inOrder!==!1;g(o=>{if(!o.isActive)return o;let n={...o},a=!1;if(t){let u=e.steps.findIndex((d,s)=>!o.completedSteps.includes(s));if(u!==-1){u!==o.currentStepIndex&&(n.currentStepIndex=u,n.currentSubStepIndex=o.subStepProgress[u]??null,a=!0);let d=e.steps[u];I(d,h)||d.urlBase&&h!==d.urlBase&&O(d.urlBase)}}else{let u=e.steps.findIndex((d,s)=>I(d,h)&&!o.completedSteps.includes(s));u!==-1&&u!==o.currentStepIndex&&(n.currentStepIndex=u,n.currentSubStepIndex=o.subStepProgress[u]??null,a=!0)}return a?n:o})},[c,S,h,O,I]),(0,l.useEffect)(()=>{if(!p.isActive||!S)return;let e=C.current,t=e.steps[p.currentStepIndex],o=`${h}-${p.currentStepIndex}-${p.currentSubStepIndex}`;if(E.current===o)return;let n=N.current;if(N.current=!1,n&&h===P.current){E.current=o;return}t&&I(t,h)&&e.metadata.simulateClicksOnNavigate&&E.current!==o&&(E.current=o,P.current=h,j(p.currentStepIndex,p.currentSubStepIndex))},[p.currentStepIndex,p.currentSubStepIndex,p.isActive,h,S,I,j]),(0,l.useEffect)(()=>{S&&H.default.set(D,JSON.stringify(p),{expires:365})},[p,S]);let B=(0,l.useMemo)(()=>{let e=r.steps[p.currentStepIndex];if(!e)return null;let t=I(e,h);if(p.currentSubStepIndex!==null&&e.subSteps){let o=e.subSteps[p.currentSubStepIndex];return t||$?o||e:null}return t?e:null},[r.steps,p.currentStepIndex,p.currentSubStepIndex,h,I,$]),F=p.currentStepIndex===0&&p.currentSubStepIndex===null,A=(0,l.useMemo)(()=>{let e=r.steps.length,t=r.steps[p.currentStepIndex],o=t?.subSteps&&t.subSteps.length>0;return p.currentStepIndex===e-1?o?p.currentSubStepIndex===t.subSteps.length-1:!0:!1},[r.steps,p.currentStepIndex,p.currentSubStepIndex]),v=(0,l.useCallback)(()=>{let e=C.current;N.current=!0,g(t=>{let{currentStepIndex:o,currentSubStepIndex:n,completedSteps:a}=t,u=e.steps[o];if(!u)return t;let d=n!==null&&u.subSteps?u.subSteps[n]:u;if(d.click){let m=document.querySelector(`[data-onboarding-id="${d.attribute}"]`);m&&m.click()}let s,w;if(u.subSteps&&(n===null||n<u.subSteps.length-1)){let m=n===null?0:n+1,M=u.subSteps[m];R(!0),setTimeout(()=>R(!1),1e3),w=d.navigate||M.navigate,!w&&n===null&&(w=u.navigate),s={...t,currentSubStepIndex:m,subStepProgress:{...t.subStepProgress,[o]:m}}}else{let m=o;if(o<e.steps.length-1){let M=o+1,Y=e.steps[M],q=t.subStepProgress[M]??null,Z=q!==null&&Y.subSteps?Y.subSteps[q]:null;w=d.navigate||Y.navigate||Z?.navigate,s={...t,currentStepIndex:M,currentSubStepIndex:q,completedSteps:a.includes(m)?a:[...a,m],subStepProgress:{...t.subStepProgress,[m]:n}}}else e.onOnboardingComplete&&e.onOnboardingComplete(),w=d.navigate||u.navigate,s={...t,isActive:!1,completedSteps:a.includes(m)?a:[...a,m],subStepProgress:{...t.subStepProgress,[m]:n}}}return H.default.set(D,JSON.stringify(s),{expires:365}),w&&O(w),s})},[O]),J=(0,l.useCallback)(()=>{let e=C.current;N.current=!0,g(t=>{let o,n;if(t.currentSubStepIndex!==null&&t.currentSubStepIndex>0){let a=t.currentSubStepIndex-1;n=e.steps[t.currentStepIndex].subSteps[a].navigate,o={...t,currentSubStepIndex:a,subStepProgress:{...t.subStepProgress,[t.currentStepIndex]:a}}}else if(t.currentStepIndex>0&&t.currentSubStepIndex===0)n=e.steps[t.currentStepIndex].navigate,o={...t,currentSubStepIndex:null,subStepProgress:{...t.subStepProgress,[t.currentStepIndex]:null}};else if(t.currentStepIndex>0){let a=t.currentStepIndex-1,u=e.steps[a],d=t.subStepProgress[a]??(u.subSteps?u.subSteps.length-1:null),s=d!==null&&u.subSteps?u.subSteps[d]:null;n=u.navigate||s?.navigate,o={...t,currentStepIndex:a,currentSubStepIndex:d,isActive:!0,subStepProgress:{...t.subStepProgress,[a]:d}}}else return t;return H.default.set(D,JSON.stringify(o),{expires:365}),n&&O(n),o})},[O]),i=(0,l.useCallback)(()=>{g(e=>({...e,isActive:!1})),C.current.onOnboardingComplete&&C.current.onOnboardingComplete()},[]),f=(0,l.useCallback)((e,t=null)=>{let o=C.current;N.current=!0,g(n=>{let a=o.steps[e],u=t!==null&&a.subSteps?a.subSteps[t]:null,d=a.navigate||u?.navigate,s={...n,currentStepIndex:e,currentSubStepIndex:t,isActive:!0,subStepProgress:{...n.subStepProgress,[e]:t}};return H.default.set(D,JSON.stringify(s),{expires:365}),d&&O(d),s})},[O]);return(0,X.jsxs)(V,{value:{config:r,state:p,nextStep:v,prevStep:J,finish:i,goToStep:f,currentStep:B,isFirstStep:F,isLastStep:A},children:[T,S&&p.isActive&&(0,X.jsx)(Q,{})]})},K=()=>{let r=(0,l.useContext)(V);if(r===void 0)throw new Error("useOnboarding must be used within an OnboardingProvider");return r};0&&(module.exports={OnboardingProvider,useOnboarding});
2
+ "use strict";"use client";var et=Object.create;var Y=Object.defineProperty;var nt=Object.getOwnPropertyDescriptor;var ot=Object.getOwnPropertyNames;var rt=Object.getPrototypeOf,it=Object.prototype.hasOwnProperty;var st=(o,l)=>{for(var v in l)Y(o,v,{get:l[v],enumerable:!0})},G=(o,l,v,A)=>{if(l&&typeof l=="object"||typeof l=="function")for(let y of ot(l))!it.call(o,y)&&y!==v&&Y(o,y,{get:()=>l[y],enumerable:!(A=nt(l,y))||A.enumerable});return o};var at=(o,l,v)=>(v=o!=null?et(rt(o)):{},G(l||!o||!o.__esModule?Y(v,"default",{value:o,enumerable:!0}):v,o)),ut=o=>G(Y({},"__esModule",{value:!0}),o);var gt={};st(gt,{OnboardingProvider:()=>bt,useOnboarding:()=>_});module.exports=ut(gt);var c=require("react"),j=at(require("js-cookie"));var S=require("react"),Q=require("react-dom");var b=require("react/jsx-runtime"),ct=()=>(0,b.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,b.jsx)("path",{d:"M15 18l-6-6 6-6"})}),lt=()=>(0,b.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,b.jsx)("path",{d:"M9 18l6-6-6-6"})}),dt=()=>(0,b.jsxs)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,b.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,b.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]}),V=()=>{let{config:o,currentStep:l,nextStep:v,prevStep:A,finish:y,isFirstStep:z,isLastStep:d}=_(),[g,h]=(0,S.useState)(null),[X,J]=(0,S.useState)({top:0,left:0}),[H,k]=(0,S.useState)({x:0,y:0}),W=(0,S.useRef)(!1),R=(0,S.useRef)({x:0,y:0}),O=(0,S.useRef)(null);(0,S.useEffect)(()=>{k({x:0,y:0})},[l]);let T=(0,S.useRef)(()=>{}),C=(0,S.useCallback)(i=>{if(!W.current)return;let m=i.clientX-R.current.x,P=i.clientY-R.current.y;k({x:m,y:P})},[]),I=(0,S.useCallback)(()=>{W.current=!1,O.current&&(O.current.style.transition="top 0.3s cubic-bezier(0.25, 0.1, 0.25, 1), left 0.3s cubic-bezier(0.25, 0.1, 0.25, 1)",O.current.style.cursor=o.metadata.draggable?"grab":"auto"),window.removeEventListener("pointermove",C),window.removeEventListener("pointerup",T.current)},[o.metadata.draggable,C]);(0,S.useEffect)(()=>{T.current=I},[I]);let M=i=>{o.metadata.draggable&&(i.stopPropagation(),i.preventDefault(),W.current=!0,R.current={x:i.clientX-H.x,y:i.clientY-H.y},O.current&&(O.current.style.transition="none",O.current.style.cursor="grabbing"),window.addEventListener("pointermove",C),window.addEventListener("pointerup",I))},B=(0,S.useCallback)(i=>{let t=i.top,n=window.innerHeight-i.bottom,a=i.left,s=window.innerWidth-i.right,r=0,u=0;return n>232?(r=i.bottom+12,u=Math.max(20,Math.min(window.innerWidth-300-20,i.left+i.width/2-300/2))):t>232?(r=i.top-200-12,u=Math.max(20,Math.min(window.innerWidth-300-20,i.left+i.width/2-300/2))):s>332?(r=Math.max(20,Math.min(window.innerHeight-200-20,i.top+i.height/2-200/2)),u=i.right+12):a>332?(r=Math.max(20,Math.min(window.innerHeight-200-20,i.top+i.height/2-200/2)),u=i.left-300-12):(r=window.innerHeight/2-200/2,u=window.innerWidth/2-300/2),{top:r+window.scrollY,left:u+window.scrollX}},[]),L=(0,S.useCallback)(()=>{if(!l)return;let i=document.querySelector(`[data-onboarding-id="${l.attribute}"]`);if(i){let m=i.getBoundingClientRect(),P=o.style?.padding||0,N={top:m.top-P,bottom:m.bottom+P,left:m.left-P,right:m.right+P,width:m.width+P*2,height:m.height+P*2},e={top:N.top+window.scrollY,left:N.left+window.scrollX,width:N.width,height:N.height},t=B(N);h(n=>n&&n.top===e.top&&n.left===e.left&&n.width===e.width&&n.height===e.height?n:e),J(n=>n.top===t.top&&n.left===t.left?n:t)}else h(null)},[l,B,o.style]);if((0,S.useEffect)(()=>{L(),window.addEventListener("resize",L),window.addEventListener("scroll",L);let i=new MutationObserver(L);i.observe(document.body,{childList:!0,subtree:!0,attributes:!0});let m=null;if(typeof ResizeObserver<"u"){m=new ResizeObserver(L),m.observe(document.body);let P=l?.attribute?document.querySelector(`[data-onboarding-id="${l.attribute}"]`):null;P&&m.observe(P)}return()=>{window.removeEventListener("resize",L),window.removeEventListener("scroll",L),window.removeEventListener("pointermove",C),window.removeEventListener("pointerup",I),i.disconnect(),m&&m.disconnect()}},[L,l?.attribute,C,I]),!l||!g)return null;let $={...o.style?.background,transition:"all 0.3s cubic-bezier(0.25, 0.1, 0.25, 1)"},w=i=>{i.stopPropagation()},q=(0,b.jsxs)("div",{className:"onboard-overlay-container",children:[(0,b.jsx)("div",{style:{height:g.top,...$},className:"onboard-overlay-mask onboard-mask-top",onPointerDown:w,onMouseDown:w,onClick:w}),(0,b.jsx)("div",{style:{top:g.top+g.height,height:`calc(100vh - ${g.top+g.height}px)`,...$},className:"onboard-overlay-mask onboard-mask-bottom",onPointerDown:w,onMouseDown:w,onClick:w}),(0,b.jsx)("div",{style:{top:g.top,height:g.height,width:g.left,...$},className:"onboard-overlay-mask onboard-mask-left",onPointerDown:w,onMouseDown:w,onClick:w}),(0,b.jsx)("div",{style:{top:g.top,height:g.height,left:g.left+g.width,width:`calc(100% - ${g.left+g.width}px)`,...$},className:"onboard-overlay-mask",onPointerDown:w,onMouseDown:w,onClick:w}),(0,b.jsxs)("div",{ref:O,className:"onboard-tooltip",onPointerDown:M,style:{zIndex:1e6,...o.style?.container,top:X.top+H.y,left:X.left+H.x,transition:"top 0.3s cubic-bezier(0.25, 0.1, 0.25, 1), left 0.3s cubic-bezier(0.25, 0.1, 0.25, 1)",cursor:o.metadata.draggable?"grab":"auto",touchAction:"none"},onMouseDown:w,onClick:w,children:[(0,b.jsxs)("div",{className:"onboard-tooltip-header",children:[(0,b.jsx)("h3",{className:"onboard-tooltip-title",children:l.title}),(0,b.jsx)("button",{onClick:i=>{i.stopPropagation(),y()},className:"onboard-close-button",children:(0,b.jsx)(dt,{})})]}),(0,b.jsx)("p",{className:"onboard-tooltip-description",children:l.description}),(0,b.jsxs)("div",{className:"onboard-tooltip-footer",children:[(0,b.jsxs)("button",{onClick:i=>{i.stopPropagation(),A()},disabled:z,className:"onboard-button-ghost",style:{background:"none",border:"none",cursor:z?"not-allowed":"pointer",...o.style?.prev},children:[(0,b.jsx)(ct,{}),"Prev"]}),d?(0,b.jsx)("button",{onClick:i=>{i.stopPropagation(),v()},className:"onboard-button-primary",style:{border:"none",cursor:"pointer",...o.style?.finish},children:"Finish"}):(0,b.jsxs)("button",{onClick:i=>{i.stopPropagation(),v()},className:"onboard-button-primary",style:{border:"none",cursor:"pointer",...z?o.style?.start:{},...z?{}:o.style?.next},children:[z&&o.style?.start?"Start":"Next",!(z&&o.style?.start)&&(0,b.jsx)(lt,{})]})]})]})]});return typeof document<"u"?(0,Q.createPortal)(q,document.body):null};var D=require("react/jsx-runtime"),Z=(0,c.createContext)(void 0),F="onboarding_state",pt=()=>{if(typeof window<"u"){let o=j.default.get(F);if(o)try{let l=JSON.parse(o);if(l&&typeof l=="object")return{currentStepIndex:l.currentStepIndex??0,currentSubStepIndex:l.currentSubStepIndex??null,isActive:l.isActive??!0,completedSteps:l.completedSteps??[],subStepProgress:l.subStepProgress??{}}}catch{}}return{currentStepIndex:0,currentSubStepIndex:null,isActive:!0,completedSteps:[],subStepProgress:{}}},bt=({config:o,ssr:l=!1,onNavigate:v,children:A})=>{let[y,z]=(0,c.useState)(!l),[d,g]=(0,c.useState)(pt),[h,X]=(0,c.useState)(typeof window<"u"?window.location.pathname:""),[J,H]=(0,c.useState)(!1),k=(0,c.useRef)(o),W=(0,c.useRef)(v),R=(0,c.useRef)(d),O=(0,c.useRef)(""),T=(0,c.useRef)(typeof window<"u"?window.location.pathname:""),C=(0,c.useRef)(!1);(0,c.useEffect)(()=>{R.current=d},[d]),(0,c.useEffect)(()=>{k.current=o,W.current=v},[o,v]),(0,c.useEffect)(()=>{h!==T.current&&(T.current=h,O.current="")},[h]),(0,c.useEffect)(()=>{if(typeof window>"u")return;let e=()=>{let s=window.location.pathname;X(s)};window.addEventListener("popstate",e);let t=window.history.pushState,n=window.history.replaceState;window.history.pushState=function(...s){t.apply(this,s),e()},window.history.replaceState=function(...s){n.apply(this,s),e()},window.addEventListener("locationchange",e);let a=setInterval(e,200);return()=>{window.removeEventListener("popstate",e),window.history.pushState=t,window.history.replaceState=n,window.removeEventListener("locationchange",e),clearInterval(a)}},[]);let I=(0,c.useCallback)(e=>{if(e)if(W.current)W.current(e);else try{window.location.href=e}catch{}},[]),M=(0,c.useCallback)((e,t)=>{if(!e?.urlMatch||!t)return!1;let n=u=>u.endsWith("/")&&u!=="/"?u.slice(0,-1):u,a=n(t),s=n(e.urlMatch),r=!1;if(s.includes("*")){let u=s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/\\\*/g,".*");r=new RegExp(`^${u}$`).test(a)}else r=a===s;return r},[]),B=(0,c.useCallback)((e,t)=>{let n=k.current,a=[],s=window.location.pathname,r=(p,x=-1)=>{if(x!==null&&(p.click&&a.push(p.attribute),p.subSteps)){let f=x===-1?p.subSteps.length:x;for(let E=0;E<f;E++)p.subSteps[E].click&&a.push(p.subSteps[E].attribute)}};for(let p=0;p<=e;p++){let x=n.steps[p];M(x,s)&&(p<e?r(x):t!==null&&r(x,t))}if(a.length===0)return;let u=p=>{if(p>=a.length)return;let x=a[p],f=document.querySelector(`[data-onboarding-id="${x}"]`);f&&f.click(),setTimeout(()=>u(p+1),500)};setTimeout(()=>u(0),500)},[M]);(0,c.useEffect)(()=>{if(l&&!y){z(!0);return}let e=k.current,t=R.current,n=e.metadata.inOrder!==!1;if(!t.isActive)return;let a=null,s;if(n){let r=e.steps.findIndex((u,p)=>!t.completedSteps.includes(p));if(r!==-1){r!==t.currentStepIndex&&(a={...t,currentStepIndex:r,currentSubStepIndex:t.subStepProgress[r]??null});let u=e.steps[r];M(u,h)||u.urlBase&&h!==u.urlBase&&(s=u.urlBase)}}else{let r=e.steps.findIndex((u,p)=>M(u,h)&&!t.completedSteps.includes(p));r!==-1&&r!==t.currentStepIndex&&(a={...t,currentStepIndex:r,currentSubStepIndex:t.subStepProgress[r]??null})}a&&g(a),s&&I(s)},[l,y,h,I,M,d.isActive,d.currentStepIndex,d.completedSteps,d.subStepProgress]),(0,c.useEffect)(()=>{if(!d.isActive||!y)return;let e=k.current,t=e.steps[d.currentStepIndex],n=`${h}-${d.currentStepIndex}-${d.currentSubStepIndex}`;if(O.current===n)return;let a=C.current;if(C.current=!1,a&&h===T.current){O.current=n;return}t&&M(t,h)&&e.metadata.simulateClicksOnNavigate&&O.current!==n&&(O.current=n,T.current=h,B(d.currentStepIndex,d.currentSubStepIndex))},[d.currentStepIndex,d.currentSubStepIndex,d.isActive,h,y,M,B]),(0,c.useEffect)(()=>{y&&j.default.set(F,JSON.stringify(d),{expires:365})},[d,y]);let L=(0,c.useMemo)(()=>{let e=o.steps[d.currentStepIndex];if(!e)return null;let t=M(e,h);if(d.currentSubStepIndex!==null&&e.subSteps){let n=e.subSteps[d.currentSubStepIndex];return t||J?n||e:null}return t?e:null},[o.steps,d.currentStepIndex,d.currentSubStepIndex,h,M,J]),$=d.currentStepIndex===0&&d.currentSubStepIndex===null,w=(0,c.useMemo)(()=>{let e=o.steps.length,t=o.steps[d.currentStepIndex],n=t?.subSteps&&t.subSteps.length>0;return d.currentStepIndex===e-1?n?d.currentSubStepIndex===t.subSteps.length-1:!0:!1},[o.steps,d.currentStepIndex,d.currentSubStepIndex]),q=(0,c.useCallback)(()=>{let e=k.current,t=R.current;C.current=!0;let{currentStepIndex:n,currentSubStepIndex:a,completedSteps:s}=t,r=e.steps[n];if(!r)return;let u=a!==null&&r.subSteps?r.subSteps[a]:r;if(u.click){let f=document.querySelector(`[data-onboarding-id="${u.attribute}"]`);f&&f.click()}let p,x;if(r.subSteps&&(a===null||a<r.subSteps.length-1)){let f=a===null?0:a+1,E=r.subSteps[f];H(!0),setTimeout(()=>H(!1),1e3),x=u.navigate||E.navigate,!x&&a===null&&(x=r.navigate),p={...t,currentSubStepIndex:f,subStepProgress:{...t.subStepProgress,[n]:f}}}else{let f=n;if(n<e.steps.length-1){let E=n+1,U=e.steps[E],K=t.subStepProgress[E]??null,tt=K!==null&&U.subSteps?U.subSteps[K]:null;x=u.navigate||U.navigate||tt?.navigate,p={...t,currentStepIndex:E,currentSubStepIndex:K,completedSteps:s.includes(f)?s:[...s,f],subStepProgress:{...t.subStepProgress,[f]:a}}}else e.onOnboardingComplete&&e.onOnboardingComplete(),x=u.navigate||r.navigate,p={...t,isActive:!1,completedSteps:s.includes(f)?s:[...s,f],subStepProgress:{...t.subStepProgress,[f]:a}}}j.default.set(F,JSON.stringify(p),{expires:365}),x&&I(x),g(p)},[I]),i=(0,c.useCallback)(()=>{let e=k.current,t=R.current;C.current=!0;let n=null,a;if(t.currentSubStepIndex!==null&&t.currentSubStepIndex>0){let s=t.currentSubStepIndex-1;a=e.steps[t.currentStepIndex].subSteps[s].navigate,n={...t,currentSubStepIndex:s,subStepProgress:{...t.subStepProgress,[t.currentStepIndex]:s}}}else if(t.currentStepIndex>0&&t.currentSubStepIndex===0)a=e.steps[t.currentStepIndex].navigate,n={...t,currentSubStepIndex:null,subStepProgress:{...t.subStepProgress,[t.currentStepIndex]:null}};else if(t.currentStepIndex>0){let s=t.currentStepIndex-1,r=e.steps[s],u=t.subStepProgress[s]??(r.subSteps?r.subSteps.length-1:null),p=u!==null&&r.subSteps?r.subSteps[u]:null;a=r.navigate||p?.navigate,n={...t,currentStepIndex:s,currentSubStepIndex:u,isActive:!0,subStepProgress:{...t.subStepProgress,[s]:u}}}n&&(j.default.set(F,JSON.stringify(n),{expires:365}),a&&I(a),g(n))},[I]),m=(0,c.useCallback)(()=>{g(e=>({...e,isActive:!1})),k.current.onOnboardingComplete&&k.current.onOnboardingComplete()},[]),P=(0,c.useCallback)((e,t=null)=>{let n=k.current,a=R.current;C.current=!0;let s=n.steps[e];if(!s)return;let r=t!==null&&s.subSteps?s.subSteps[t]:null,u=s.navigate||r?.navigate,p={...a,currentStepIndex:e,currentSubStepIndex:t,isActive:!0,subStepProgress:{...a.subStepProgress,[e]:t}};j.default.set(F,JSON.stringify(p),{expires:365}),u&&I(u),g(p)},[I]),N={config:o,state:d,nextStep:q,prevStep:i,finish:m,goToStep:P,currentStep:L,isFirstStep:$,isLastStep:w};return y?(0,D.jsxs)(Z.Provider,{value:N,children:[A,d.isActive&&(0,D.jsx)(V,{})]}):(0,D.jsx)(D.Fragment,{children:A})},_=()=>{let o=(0,c.useContext)(Z);if(o===void 0)throw new Error("useOnboarding must be used within an OnboardingProvider");return o};0&&(module.exports={OnboardingProvider,useOnboarding});
3
3
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/components/OnboardingProvider.tsx","../src/components/OnboardingOverlay.tsx"],"sourcesContent":["'use client';\n\nimport './styles.css';\nexport * from './components/OnboardingProvider';\nexport * from './types';\n","'use client';\n\nimport React, {\n createContext,\n useContext,\n useEffect,\n useState,\n useCallback,\n useMemo,\n useRef,\n} from 'react';\nimport Cookies from 'js-cookie';\nimport { OnboardingConfig, OnboardingState, OnboardingStep, OnboardingSubStep } from '../types';\nimport { OnboardingOverlay } from './OnboardingOverlay';\n\ninterface OnboardingContextType {\n config: OnboardingConfig;\n state: OnboardingState;\n nextStep: () => void;\n prevStep: () => void;\n finish: () => void;\n goToStep: (stepIndex: number, subStepIndex?: number | null) => void;\n currentStep: OnboardingStep | OnboardingSubStep | null;\n isFirstStep: boolean;\n isLastStep: boolean;\n}\n\nconst OnboardingContext = createContext<OnboardingContextType | undefined>(undefined);\n\nconst COOKIE_NAME = 'onboarding_state';\n\nconst getInitialState = (): OnboardingState => {\n if (typeof window !== 'undefined') {\n const saved = Cookies.get(COOKIE_NAME);\n if (saved) {\n try {\n const parsed = JSON.parse(saved);\n if (parsed && typeof parsed === 'object') {\n return {\n currentStepIndex: parsed.currentStepIndex ?? 0,\n currentSubStepIndex: parsed.currentSubStepIndex ?? null,\n isActive: parsed.isActive ?? true,\n completedSteps: parsed.completedSteps ?? [],\n subStepProgress: parsed.subStepProgress ?? {},\n };\n }\n } catch {\n // Ignore\n }\n }\n }\n return {\n currentStepIndex: 0,\n currentSubStepIndex: null,\n isActive: true,\n completedSteps: [],\n subStepProgress: {},\n };\n};\n\nexport const OnboardingProvider: React.FC<{\n config: OnboardingConfig;\n ssr?: boolean;\n onNavigate?: (url: string) => void;\n children: React.ReactNode;\n}> = ({ config, ssr = false, onNavigate, children }) => {\n const [isMounted, setIsMounted] = useState(false);\n const [state, setState] = useState<OnboardingState>({\n currentStepIndex: 0,\n currentSubStepIndex: null,\n isActive: false,\n completedSteps: [],\n subStepProgress: {},\n });\n const [currentPath, setCurrentPath] = useState('');\n const [isTransitioning, setIsTransitioning] = useState(false);\n\n const configRef = useRef(config);\n const onNavigateRef = useRef(onNavigate);\n const lastSimulatedKey = useRef<string>('');\n const lastPathForSimulation = useRef<string>('');\n const wasInternalAction = useRef(false);\n\n useEffect(() => {\n setIsMounted(true);\n const initialState = getInitialState();\n setState(initialState);\n setCurrentPath(window.location.pathname);\n lastPathForSimulation.current = window.location.pathname;\n }, []);\n\n useEffect(() => {\n if (isMounted && currentPath !== lastPathForSimulation.current) {\n lastPathForSimulation.current = currentPath;\n lastSimulatedKey.current = '';\n }\n }, [currentPath, isMounted]);\n\n useEffect(() => {\n configRef.current = config;\n onNavigateRef.current = onNavigate;\n }, [config, onNavigate]);\n\n useEffect(() => {\n if (!isMounted) return;\n\n const handlePathChange = () => {\n const newPath = window.location.pathname;\n setCurrentPath(newPath);\n };\n\n window.addEventListener('popstate', handlePathChange);\n\n const originalPushState = window.history.pushState;\n const originalReplaceState = window.history.replaceState;\n\n window.history.pushState = function (...args) {\n originalPushState.apply(this, args);\n handlePathChange();\n };\n\n window.history.replaceState = function (...args) {\n originalReplaceState.apply(this, args);\n handlePathChange();\n };\n\n const interval = setInterval(handlePathChange, 200);\n\n return () => {\n window.removeEventListener('popstate', handlePathChange);\n window.history.pushState = originalPushState;\n window.history.replaceState = originalReplaceState;\n clearInterval(interval);\n };\n }, [isMounted]);\n\n const handleNavigation = useCallback((link?: string) => {\n if (!link) return;\n if (onNavigateRef.current) {\n onNavigateRef.current(link);\n } else {\n window.location.href = link;\n }\n }, []);\n\n const isMatch = useCallback((step: OnboardingStep, path: string) => {\n if (!step?.urlMatch || !path) return false;\n\n let match = false;\n if (step.urlMatch.includes('*')) {\n const pattern = step.urlMatch\n .replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&') // Escape special regex chars\n .replace(/\\\\\\*/g, '.*'); // Convert escaped * back to .*\n match = new RegExp(`^${pattern}$`).test(path);\n } else {\n match = path === step.urlMatch;\n }\n return match;\n }, []);\n\n const simulateClicks = useCallback(\n (stepIndex: number, subStepIndex: number | null) => {\n const currentConfig = configRef.current;\n const actions: string[] = [];\n const path = window.location.pathname;\n const collectStepClicks = (step: OnboardingStep, upToSubStep: number | null = -1) => {\n if (upToSubStep === null) {\n // We are arriving at the main step itself. No sub-steps. \n // In this case, we don't click the step's attribute because arriving there \n // should show it. Re-clicking might close it if it's a toggle.\n return;\n }\n\n if (step.click) actions.push(step.attribute);\n if (step.subSteps) {\n const limit = upToSubStep === -1 ? step.subSteps.length : upToSubStep;\n for (let i = 0; i < limit; i++) {\n if (step.subSteps[i].click) actions.push(step.subSteps[i].attribute);\n }\n }\n };\n\n for (let i = 0; i <= stepIndex; i++) {\n const step = currentConfig.steps[i];\n if (isMatch(step, path)) {\n if (i < stepIndex) collectStepClicks(step);\n else if (subStepIndex !== null) {\n // We are arriving at a sub-step. Replay clicks leading to it.\n collectStepClicks(step, subStepIndex);\n }\n }\n }\n\n if (actions.length === 0) return;\n\n const performClick = (index: number) => {\n if (index >= actions.length) return;\n const attr = actions[index];\n const element = document.querySelector(`[data-onboarding-id=\"${attr}\"]`) as HTMLElement;\n if (element) element.click();\n setTimeout(() => performClick(index + 1), 500);\n };\n\n setTimeout(() => performClick(0), 500);\n },\n [isMatch, currentPath],\n );\n\n // Reconcile state with path\n useEffect(() => {\n if (ssr && !isMounted) {\n setIsMounted(true);\n return;\n }\n\n const currentConfig = configRef.current;\n const isInOrder = (currentConfig.metadata.inOrder as boolean | undefined) !== false;\n\n // Use functional update to avoid depending on 'state'\n setState((prev) => {\n if (!prev.isActive) return prev;\n\n const nextState = { ...prev };\n let changed = false;\n\n if (!isInOrder) {\n const matchedIndex = currentConfig.steps.findIndex(\n (step, index) => isMatch(step, currentPath) && !prev.completedSteps.includes(index),\n );\n\n if (matchedIndex !== -1 && matchedIndex !== prev.currentStepIndex) {\n nextState.currentStepIndex = matchedIndex;\n nextState.currentSubStepIndex = prev.subStepProgress[matchedIndex] ?? null;\n changed = true;\n }\n } else {\n const firstUnfinishedIndex = currentConfig.steps.findIndex(\n (_, i) => !prev.completedSteps.includes(i),\n );\n\n if (firstUnfinishedIndex !== -1) {\n if (firstUnfinishedIndex !== prev.currentStepIndex) {\n nextState.currentStepIndex = firstUnfinishedIndex;\n nextState.currentSubStepIndex = prev.subStepProgress[firstUnfinishedIndex] ?? null;\n changed = true;\n }\n\n const step = currentConfig.steps[firstUnfinishedIndex];\n if (!isMatch(step, currentPath)) {\n if (step.urlBase && currentPath !== step.urlBase) {\n handleNavigation(step.urlBase);\n }\n }\n }\n }\n\n return changed ? nextState : prev;\n });\n }, [ssr, isMounted, currentPath, handleNavigation, isMatch]);\n\n // Handle click simulation separately\n useEffect(() => {\n if (!state.isActive || !isMounted) return;\n const currentConfig = configRef.current;\n const step = currentConfig.steps[state.currentStepIndex];\n\n const simKey = `${currentPath}-${state.currentStepIndex}-${state.currentSubStepIndex}`;\n\n // Skip if we already simulated this exact state\n if (lastSimulatedKey.current === simKey) {\n return;\n }\n\n const internal = wasInternalAction.current;\n wasInternalAction.current = false;\n\n // Skip if path is same and it was an internal action (Next/Prev/GoTo)\n // because manual progression handles its own clicks.\n if (internal && currentPath === lastPathForSimulation.current) {\n lastSimulatedKey.current = simKey;\n return;\n }\n\n if (step && isMatch(step, currentPath) && currentConfig.metadata.simulateClicksOnNavigate) {\n if (lastSimulatedKey.current !== simKey) {\n lastSimulatedKey.current = simKey;\n lastPathForSimulation.current = currentPath;\n simulateClicks(state.currentStepIndex, state.currentSubStepIndex);\n }\n }\n }, [\n state.currentStepIndex,\n state.currentSubStepIndex,\n state.isActive,\n currentPath,\n isMounted,\n isMatch,\n simulateClicks,\n ]);\n\n // Persist state to cookies\n useEffect(() => {\n if (isMounted) {\n Cookies.set(COOKIE_NAME, JSON.stringify(state), { expires: 365 });\n }\n }, [state, isMounted]);\n\n const currentStep = useMemo(() => {\n const step = config.steps[state.currentStepIndex];\n if (!step) return null;\n\n const isUrlMatch = isMatch(step, currentPath);\n\n if (state.currentSubStepIndex !== null && step.subSteps) {\n const subStep = step.subSteps[state.currentSubStepIndex];\n if (isUrlMatch || isTransitioning) {\n return subStep || step;\n }\n return null;\n }\n\n if (!isUrlMatch) return null;\n\n return step;\n }, [\n config.steps,\n state.currentStepIndex,\n state.currentSubStepIndex,\n currentPath,\n isMatch,\n isTransitioning,\n ]);\n\n const isFirstStep = state.currentStepIndex === 0 && state.currentSubStepIndex === null;\n const isLastStep = useMemo(() => {\n const totalSteps = config.steps.length;\n const step = config.steps[state.currentStepIndex];\n const hasSubSteps = step?.subSteps && step.subSteps.length > 0;\n\n if (state.currentStepIndex === totalSteps - 1) {\n if (hasSubSteps) return state.currentSubStepIndex === step.subSteps!.length - 1;\n return true;\n }\n return false;\n }, [config.steps, state.currentStepIndex, state.currentSubStepIndex]);\n\n const nextStep = useCallback(() => {\n const currentConfig = configRef.current;\n wasInternalAction.current = true;\n\n setState((prev) => {\n const { currentStepIndex, currentSubStepIndex, completedSteps } = prev;\n const stepObj = currentConfig.steps[currentStepIndex];\n if (!stepObj) return prev;\n\n const currentActiveStep =\n currentSubStepIndex !== null && stepObj.subSteps\n ? stepObj.subSteps[currentSubStepIndex]\n : stepObj;\n\n if (currentActiveStep.click) {\n const element = document.querySelector(\n `[data-onboarding-id=\"${currentActiveStep.attribute}\"]`,\n ) as HTMLElement;\n if (element) element.click();\n }\n\n let nextState: OnboardingState;\n let navTo: string | undefined;\n\n if (\n stepObj.subSteps &&\n (currentSubStepIndex === null || currentSubStepIndex < stepObj.subSteps.length - 1)\n ) {\n const nextSubIndex = currentSubStepIndex === null ? 0 : currentSubStepIndex + 1;\n const nextSubStep = stepObj.subSteps[nextSubIndex];\n\n setIsTransitioning(true);\n setTimeout(() => setIsTransitioning(false), 1000);\n\n navTo = currentActiveStep.navigate || nextSubStep.navigate;\n if (!navTo && currentSubStepIndex === null) navTo = stepObj.navigate;\n\n nextState = {\n ...prev,\n currentSubStepIndex: nextSubIndex,\n subStepProgress: {\n ...prev.subStepProgress,\n [currentStepIndex]: nextSubIndex,\n },\n };\n } else {\n const stepIndexToComplete = currentStepIndex;\n if (currentStepIndex < currentConfig.steps.length - 1) {\n const nextIndex = currentStepIndex + 1;\n const nextStepObj = currentConfig.steps[nextIndex];\n const targetSubStepIndex = prev.subStepProgress[nextIndex] ?? null;\n const targetSubStep =\n targetSubStepIndex !== null && nextStepObj.subSteps\n ? nextStepObj.subSteps[targetSubStepIndex]\n : null;\n\n navTo = currentActiveStep.navigate || nextStepObj.navigate || targetSubStep?.navigate;\n\n nextState = {\n ...prev,\n currentStepIndex: nextIndex,\n currentSubStepIndex: targetSubStepIndex,\n completedSteps: completedSteps.includes(stepIndexToComplete)\n ? completedSteps\n : [...completedSteps, stepIndexToComplete],\n subStepProgress: {\n ...prev.subStepProgress,\n [stepIndexToComplete]: currentSubStepIndex,\n },\n };\n } else {\n if (currentConfig.onOnboardingComplete) currentConfig.onOnboardingComplete();\n\n navTo = currentActiveStep.navigate || stepObj.navigate;\n\n nextState = {\n ...prev,\n isActive: false,\n completedSteps: completedSteps.includes(stepIndexToComplete)\n ? completedSteps\n : [...completedSteps, stepIndexToComplete],\n subStepProgress: {\n ...prev.subStepProgress,\n [stepIndexToComplete]: currentSubStepIndex,\n },\n };\n }\n }\n\n Cookies.set(COOKIE_NAME, JSON.stringify(nextState), { expires: 365 });\n if (navTo) handleNavigation(navTo);\n return nextState;\n });\n }, [handleNavigation]);\n\n const prevStep = useCallback(() => {\n const currentConfig = configRef.current;\n wasInternalAction.current = true;\n setState((prev) => {\n let nextState: OnboardingState;\n let navTo: string | undefined;\n\n if (prev.currentSubStepIndex !== null && prev.currentSubStepIndex > 0) {\n const nextSubIndex = prev.currentSubStepIndex - 1;\n const nextSubStep = currentConfig.steps[prev.currentStepIndex].subSteps![nextSubIndex];\n navTo = nextSubStep.navigate;\n\n nextState = {\n ...prev,\n currentSubStepIndex: nextSubIndex,\n subStepProgress: {\n ...prev.subStepProgress,\n [prev.currentStepIndex]: nextSubIndex,\n },\n };\n } else if (prev.currentStepIndex > 0 && prev.currentSubStepIndex === 0) {\n const stepObj = currentConfig.steps[prev.currentStepIndex];\n navTo = stepObj.navigate;\n\n nextState = {\n ...prev,\n currentSubStepIndex: null,\n subStepProgress: {\n ...prev.subStepProgress,\n [prev.currentStepIndex]: null,\n },\n };\n } else if (prev.currentStepIndex > 0) {\n const prevIndex = prev.currentStepIndex - 1;\n const prevStepObj = currentConfig.steps[prevIndex];\n const prevSubStepIndex =\n prev.subStepProgress[prevIndex] ??\n (prevStepObj.subSteps ? prevStepObj.subSteps.length - 1 : null);\n const prevSubStep =\n prevSubStepIndex !== null && prevStepObj.subSteps\n ? prevStepObj.subSteps[prevSubStepIndex]\n : null;\n\n navTo = prevStepObj.navigate || prevSubStep?.navigate;\n\n nextState = {\n ...prev,\n currentStepIndex: prevIndex,\n currentSubStepIndex: prevSubStepIndex,\n isActive: true,\n subStepProgress: {\n ...prev.subStepProgress,\n [prevIndex]: prevSubStepIndex,\n },\n };\n } else {\n return prev;\n }\n\n Cookies.set(COOKIE_NAME, JSON.stringify(nextState), { expires: 365 });\n if (navTo) handleNavigation(navTo);\n return nextState;\n });\n }, [handleNavigation]);\n\n const finish = useCallback(() => {\n setState((prev) => ({ ...prev, isActive: false }));\n if (configRef.current.onOnboardingComplete) configRef.current.onOnboardingComplete();\n }, []);\n\n const goToStep = useCallback(\n (stepIndex: number, subStepIndex: number | null = null) => {\n const currentConfig = configRef.current;\n wasInternalAction.current = true;\n setState((prev) => {\n const nextStepObj = currentConfig.steps[stepIndex];\n const targetSubStep =\n subStepIndex !== null && nextStepObj.subSteps\n ? nextStepObj.subSteps[subStepIndex]\n : null;\n\n const navTo = nextStepObj.navigate || targetSubStep?.navigate;\n\n const nextState = {\n ...prev,\n currentStepIndex: stepIndex,\n currentSubStepIndex: subStepIndex,\n isActive: true,\n subStepProgress: {\n ...prev.subStepProgress,\n [stepIndex]: subStepIndex,\n },\n };\n\n Cookies.set(COOKIE_NAME, JSON.stringify(nextState), { expires: 365 });\n if (navTo) handleNavigation(navTo);\n return nextState;\n });\n },\n [handleNavigation],\n );\n\n const value = {\n config,\n state,\n nextStep,\n prevStep,\n finish,\n goToStep,\n currentStep,\n isFirstStep,\n isLastStep,\n };\n\n return (\n <OnboardingContext value={value}>\n {children}\n {isMounted && state.isActive && <OnboardingOverlay />}\n </OnboardingContext>\n );\n};\n\nexport const useOnboarding = () => {\n const context = useContext(OnboardingContext);\n if (context === undefined)\n throw new Error('useOnboarding must be used within an OnboardingProvider');\n return context;\n};\n","'use client';\n\nimport React, { useState, useEffect, useCallback, useRef } from 'react';\nimport { createPortal } from 'react-dom';\nimport { useOnboarding } from './OnboardingProvider';\n\nconst ChevronLeftIcon = () => (\n <svg\n width=\"16\"\n height=\"16\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d=\"M15 18l-6-6 6-6\" />\n </svg>\n);\n\nconst ChevronRightIcon = () => (\n <svg\n width=\"16\"\n height=\"16\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d=\"M9 18l6-6-6-6\" />\n </svg>\n);\n\nconst XIcon = () => (\n <svg\n width=\"18\"\n height=\"18\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <line x1=\"18\" y1=\"6\" x2=\"6\" y2=\"18\" />\n <line x1=\"6\" y1=\"6\" x2=\"18\" y2=\"18\" />\n </svg>\n);\n\nexport const OnboardingOverlay: React.FC = () => {\n const { config, currentStep, nextStep, prevStep, finish, isFirstStep, isLastStep } =\n useOnboarding();\n const [coords, setCoords] = useState<{\n top: number;\n left: number;\n width: number;\n height: number;\n } | null>(null);\n const [position, setPosition] = useState<{ top: number; left: number }>({ top: 0, left: 0 });\n const [dragOffset, setDragOffset] = useState<{ x: number; y: number }>({ x: 0, y: 0 });\n const isDragging = useRef(false);\n const dragStart = useRef<{ x: number; y: number }>({ x: 0, y: 0 });\n const tooltipRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n // eslint-disable-next-line react-hooks/set-state-in-effect\n setDragOffset({ x: 0, y: 0 });\n }, [currentStep]);\n\n const handlePointerUpRef = useRef<() => void>(() => {});\n\n const handlePointerMove = useCallback((e: PointerEvent) => {\n if (!isDragging.current) return;\n\n const newX = e.clientX - dragStart.current.x;\n const newY = e.clientY - dragStart.current.y;\n\n setDragOffset({ x: newX, y: newY });\n }, []);\n\n const handlePointerUp = useCallback(() => {\n isDragging.current = false;\n\n if (tooltipRef.current) {\n tooltipRef.current.style.transition =\n 'top 0.3s cubic-bezier(0.25, 0.1, 0.25, 1), left 0.3s cubic-bezier(0.25, 0.1, 0.25, 1)';\n tooltipRef.current.style.cursor = config.metadata.draggable ? 'grab' : 'auto';\n }\n\n window.removeEventListener('pointermove', handlePointerMove);\n window.removeEventListener('pointerup', handlePointerUpRef.current);\n }, [config.metadata.draggable, handlePointerMove]);\n\n useEffect(() => {\n handlePointerUpRef.current = handlePointerUp;\n }, [handlePointerUp]);\n\n const handlePointerDown = (e: React.PointerEvent) => {\n if (!config.metadata.draggable) return;\n e.stopPropagation();\n e.preventDefault();\n isDragging.current = true;\n dragStart.current = { x: e.clientX - dragOffset.x, y: e.clientY - dragOffset.y };\n\n if (tooltipRef.current) {\n tooltipRef.current.style.transition = 'none';\n tooltipRef.current.style.cursor = 'grabbing';\n }\n\n window.addEventListener('pointermove', handlePointerMove);\n window.addEventListener('pointerup', handlePointerUp);\n };\n\n const calculateBestPosition = useCallback(\n (rect: {\n top: number;\n bottom: number;\n left: number;\n right: number;\n width: number;\n height: number;\n }) => {\n const tooltipWidth = 300;\n const tooltipHeight = 200;\n const gap = 12;\n const padding = 20;\n\n const spaceAbove = rect.top;\n const spaceBelow = window.innerHeight - rect.bottom;\n const spaceLeft = rect.left;\n const spaceRight = window.innerWidth - rect.right;\n\n let top = 0;\n let left = 0;\n\n if (spaceBelow > tooltipHeight + gap + padding) {\n top = rect.bottom + gap;\n left = Math.max(\n padding,\n Math.min(\n window.innerWidth - tooltipWidth - padding,\n rect.left + rect.width / 2 - tooltipWidth / 2,\n ),\n );\n } else if (spaceAbove > tooltipHeight + gap + padding) {\n top = rect.top - tooltipHeight - gap;\n left = Math.max(\n padding,\n Math.min(\n window.innerWidth - tooltipWidth - padding,\n rect.left + rect.width / 2 - tooltipWidth / 2,\n ),\n );\n } else if (spaceRight > tooltipWidth + gap + padding) {\n top = Math.max(\n padding,\n Math.min(\n window.innerHeight - tooltipHeight - padding,\n rect.top + rect.height / 2 - tooltipHeight / 2,\n ),\n );\n left = rect.right + gap;\n } else if (spaceLeft > tooltipWidth + gap + padding) {\n top = Math.max(\n padding,\n Math.min(\n window.innerHeight - tooltipHeight - padding,\n rect.top + rect.height / 2 - tooltipHeight / 2,\n ),\n );\n left = rect.left - tooltipWidth - gap;\n } else {\n top = window.innerHeight / 2 - tooltipHeight / 2;\n left = window.innerWidth / 2 - tooltipWidth / 2;\n }\n\n return { top: top + window.scrollY, left: left + window.scrollX };\n },\n [],\n );\n\n const updateCoords = useCallback(() => {\n if (!currentStep) {\n return;\n }\n\n const element = document.querySelector(\n `[data-onboarding-id=\"${currentStep.attribute}\"]`,\n ) as HTMLElement;\n\n if (element) {\n const rect = element.getBoundingClientRect();\n const padding = config.style?.padding || 0;\n const paddedRect = {\n top: rect.top - padding,\n bottom: rect.bottom + padding,\n left: rect.left - padding,\n right: rect.right + padding,\n width: rect.width + padding * 2,\n height: rect.height + padding * 2,\n };\n\n const newCoords = {\n top: paddedRect.top + window.scrollY,\n left: paddedRect.left + window.scrollX,\n width: paddedRect.width,\n height: paddedRect.height,\n };\n\n const newPosition = calculateBestPosition(paddedRect);\n\n setCoords((prev) => {\n if (\n prev &&\n Math.abs(prev.top - newCoords.top) < 0.5 &&\n Math.abs(prev.left - newCoords.left) < 0.5 &&\n Math.abs(prev.width - newCoords.width) < 0.5 &&\n Math.abs(prev.height - newCoords.height) < 0.5\n ) {\n return prev;\n }\n return newCoords;\n });\n\n setPosition((prev) => {\n if (Math.abs(prev.top - newPosition.top) < 0.5 && Math.abs(prev.left - newPosition.left) < 0.5) {\n return prev;\n }\n return newPosition;\n });\n } else {\n setCoords(null);\n }\n }, [currentStep, calculateBestPosition, config.style]);\n\n useEffect(() => {\n let timeoutId: ReturnType<typeof setTimeout>;\n const debouncedUpdate = () => {\n clearTimeout(timeoutId);\n timeoutId = setTimeout(updateCoords, 16); // ~60fps debounce\n };\n\n debouncedUpdate();\n window.addEventListener('resize', debouncedUpdate);\n window.addEventListener('scroll', debouncedUpdate);\n\n const observer = new MutationObserver((mutations) => {\n // Only trigger if relevant attributes or nodes changed\n const shouldUpdate = mutations.some(m => \n m.type === 'childList' || \n (m.type === 'attributes' && m.attributeName?.includes('data-onboarding-id'))\n );\n if (shouldUpdate) debouncedUpdate();\n });\n\n observer.observe(document.body, { \n childList: true, \n subtree: true, \n attributes: true,\n attributeFilter: ['data-onboarding-id', 'style', 'class'] \n });\n\n let resizeObserver: ResizeObserver | null = null;\n if (typeof ResizeObserver !== 'undefined') {\n resizeObserver = new ResizeObserver(debouncedUpdate);\n resizeObserver.observe(document.body);\n\n const element = currentStep?.attribute\n ? document.querySelector(`[data-onboarding-id=\"${currentStep.attribute}\"]`)\n : null;\n if (element) {\n resizeObserver.observe(element);\n }\n }\n\n return () => {\n clearTimeout(timeoutId);\n window.removeEventListener('resize', debouncedUpdate);\n window.removeEventListener('scroll', debouncedUpdate);\n window.removeEventListener('pointermove', handlePointerMove);\n window.removeEventListener('pointerup', handlePointerUp);\n observer.disconnect();\n if (resizeObserver) resizeObserver.disconnect();\n };\n }, [updateCoords, currentStep?.attribute, handlePointerMove, handlePointerUp]);\n\n if (!currentStep || !coords) {\n return null;\n }\n\n const maskStyle = {\n ...config.style?.background,\n transition: 'all 0.3s cubic-bezier(0.25, 0.1, 0.25, 1)',\n };\n\n const stopPropagation = (e: React.PointerEvent | React.MouseEvent) => {\n e.stopPropagation();\n };\n\n const overlayContent = (\n <div className=\"onboard-overlay-container\">\n <div\n style={{ height: coords.top, ...maskStyle }}\n className=\"onboard-overlay-mask onboard-mask-top\"\n onPointerDown={stopPropagation}\n onMouseDown={stopPropagation}\n onClick={stopPropagation}\n />\n <div\n style={{\n top: coords.top + coords.height,\n height: `calc(100vh - ${coords.top + coords.height}px)`,\n ...maskStyle,\n }}\n className=\"onboard-overlay-mask onboard-mask-bottom\"\n onPointerDown={stopPropagation}\n onMouseDown={stopPropagation}\n onClick={stopPropagation}\n />\n <div\n style={{ top: coords.top, height: coords.height, width: coords.left, ...maskStyle }}\n className=\"onboard-overlay-mask onboard-mask-left\"\n onPointerDown={stopPropagation}\n onMouseDown={stopPropagation}\n onClick={stopPropagation}\n />\n <div\n style={{\n top: coords.top,\n height: coords.height,\n left: coords.left + coords.width,\n width: `calc(100% - ${coords.left + coords.width}px)`,\n ...maskStyle,\n }}\n className=\"onboard-overlay-mask\"\n onPointerDown={stopPropagation}\n onMouseDown={stopPropagation}\n onClick={stopPropagation}\n />\n\n <div\n ref={tooltipRef}\n className=\"onboard-tooltip\"\n onPointerDown={handlePointerDown}\n style={{\n zIndex: 1000000,\n ...config.style?.container,\n top: position.top + dragOffset.y,\n left: position.left + dragOffset.x,\n transition:\n 'top 0.3s cubic-bezier(0.25, 0.1, 0.25, 1), left 0.3s cubic-bezier(0.25, 0.1, 0.25, 1)',\n cursor: config.metadata.draggable ? 'grab' : 'auto',\n touchAction: 'none',\n }}\n onMouseDown={stopPropagation}\n onClick={stopPropagation}\n >\n <div className=\"onboard-tooltip-header\">\n <h3 className=\"onboard-tooltip-title\">{currentStep.title}</h3>\n <button\n onClick={(e) => {\n e.stopPropagation();\n finish();\n }}\n className=\"onboard-close-button\"\n >\n <XIcon />\n </button>\n </div>\n <p className=\"onboard-tooltip-description\">{currentStep.description}</p>\n\n <div className=\"onboard-tooltip-footer\">\n <button\n onClick={(e) => {\n e.stopPropagation();\n prevStep();\n }}\n disabled={isFirstStep}\n className=\"onboard-button-ghost\"\n style={{\n background: 'none',\n border: 'none',\n cursor: isFirstStep ? 'not-allowed' : 'pointer',\n ...config.style?.prev,\n }}\n >\n <ChevronLeftIcon />\n Prev\n </button>\n\n {isLastStep ? (\n <button\n onClick={(e) => {\n e.stopPropagation();\n nextStep();\n }}\n className=\"onboard-button-primary\"\n style={{ border: 'none', cursor: 'pointer', ...config.style?.finish }}\n >\n Finish\n </button>\n ) : (\n <button\n onClick={(e) => {\n e.stopPropagation();\n nextStep();\n }}\n className=\"onboard-button-primary\"\n style={{\n border: 'none',\n cursor: 'pointer',\n ...(isFirstStep ? config.style?.start : {}),\n ...(!isFirstStep ? config.style?.next : {}),\n }}\n >\n {isFirstStep && config.style?.start ? 'Start' : 'Next'}\n {!(isFirstStep && config.style?.start) && <ChevronRightIcon />}\n </button>\n )}\n </div>\n </div>\n </div>\n );\n\n return typeof document !== 'undefined' ? createPortal(overlayContent, document.body) : null;\n};\n"],"mappings":";olBAAA,IAAAA,GAAA,GAAAC,GAAAD,GAAA,wBAAAE,GAAA,kBAAAC,IAAA,eAAAC,GAAAJ,ICEA,IAAAK,EAQO,iBACPC,EAAoB,yBCTpB,IAAAC,EAAgE,iBAChEC,EAA6B,qBAczB,IAAAC,EAAA,6BAXEC,GAAkB,OACtB,OAAC,OACC,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A,CAACtB,CAAgB,CACnB,EAcA,SACE,QAAC/B,EAAA,CAAkB,MAbP,CACZ,OAAAO,EACA,MAAAM,EACA,SAAAsD,EACA,SAAAc,EACA,OAAAK,EACA,SAAAC,EACA,YAAA3B,EACA,YAAAG,EACA,WAAAC,CACF,EAIK,UAAAtD,EACAC,GAAaE,EAAM,aAAY,OAAC2E,EAAA,EAAkB,GACrD,CAEJ,EAEaC,EAAgB,IAAM,CACjC,IAAMC,KAAU,cAAW1F,CAAiB,EAC5C,GAAI0F,IAAY,OACd,MAAM,IAAI,MAAM,yDAAyD,EAC3E,OAAOA,CACT","names":["index_exports","__export","OnboardingProvider","useOnboarding","__toCommonJS","import_react","import_js_cookie","import_react","import_react_dom","import_jsx_runtime","ChevronLeftIcon","ChevronRightIcon","XIcon","OnboardingOverlay","config","currentStep","nextStep","prevStep","finish","isFirstStep","isLastStep","useOnboarding","coords","setCoords","position","setPosition","dragOffset","setDragOffset","isDragging","dragStart","tooltipRef","handlePointerUpRef","handlePointerMove","e","newX","newY","handlePointerUp","handlePointerDown","calculateBestPosition","rect","spaceAbove","spaceBelow","spaceLeft","spaceRight","top","left","updateCoords","element","padding","paddedRect","newCoords","newPosition","prev","timeoutId","debouncedUpdate","observer","mutations","m","resizeObserver","maskStyle","stopPropagation","overlayContent","import_jsx_runtime","OnboardingContext","COOKIE_NAME","getInitialState","saved","Cookies","parsed","OnboardingProvider","config","ssr","onNavigate","children","isMounted","setIsMounted","state","setState","currentPath","setCurrentPath","isTransitioning","setIsTransitioning","configRef","onNavigateRef","lastSimulatedKey","lastPathForSimulation","wasInternalAction","initialState","handlePathChange","newPath","originalPushState","originalReplaceState","args","interval","handleNavigation","link","isMatch","step","path","match","pattern","simulateClicks","stepIndex","subStepIndex","currentConfig","actions","collectStepClicks","upToSubStep","limit","i","performClick","index","attr","element","isInOrder","prev","nextState","changed","firstUnfinishedIndex","_","matchedIndex","simKey","internal","currentStep","isUrlMatch","subStep","isFirstStep","isLastStep","totalSteps","hasSubSteps","nextStep","currentStepIndex","currentSubStepIndex","completedSteps","stepObj","currentActiveStep","navTo","nextSubIndex","nextSubStep","stepIndexToComplete","nextIndex","nextStepObj","targetSubStepIndex","targetSubStep","prevStep","prevIndex","prevStepObj","prevSubStepIndex","prevSubStep","finish","goToStep","OnboardingOverlay","useOnboarding","context"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/components/OnboardingProvider.tsx","../src/components/OnboardingOverlay.tsx"],"sourcesContent":["'use client';\n\nimport './styles.css';\nexport * from './components/OnboardingProvider';\nexport * from './types';\n","'use client';\n\nimport React, {\n createContext,\n useContext,\n useEffect,\n useState,\n useCallback,\n useMemo,\n useRef,\n} from 'react';\nimport Cookies from 'js-cookie';\nimport { OnboardingConfig, OnboardingState, OnboardingStep, OnboardingSubStep } from '../types';\nimport { OnboardingOverlay } from './OnboardingOverlay';\n\ninterface OnboardingContextType {\n config: OnboardingConfig;\n state: OnboardingState;\n nextStep: () => void;\n prevStep: () => void;\n finish: () => void;\n goToStep: (stepIndex: number, subStepIndex?: number | null) => void;\n currentStep: OnboardingStep | OnboardingSubStep | null;\n isFirstStep: boolean;\n isLastStep: boolean;\n}\n\nconst OnboardingContext = createContext<OnboardingContextType | undefined>(undefined);\n\nconst COOKIE_NAME = 'onboarding_state';\n\nconst getInitialState = (): OnboardingState => {\n if (typeof window !== 'undefined') {\n const saved = Cookies.get(COOKIE_NAME);\n if (saved) {\n try {\n const parsed = JSON.parse(saved);\n if (parsed && typeof parsed === 'object') {\n return {\n currentStepIndex: parsed.currentStepIndex ?? 0,\n currentSubStepIndex: parsed.currentSubStepIndex ?? null,\n isActive: parsed.isActive ?? true,\n completedSteps: parsed.completedSteps ?? [],\n subStepProgress: parsed.subStepProgress ?? {},\n };\n }\n } catch {\n // Ignore\n }\n }\n }\n return {\n currentStepIndex: 0,\n currentSubStepIndex: null,\n isActive: true,\n completedSteps: [],\n subStepProgress: {},\n };\n};\n\nexport const OnboardingProvider: React.FC<{\n config: OnboardingConfig;\n ssr?: boolean;\n onNavigate?: (url: string) => void;\n children: React.ReactNode;\n}> = ({ config, ssr = false, onNavigate, children }) => {\n const [isMounted, setIsMounted] = useState(!ssr);\n const [state, setState] = useState<OnboardingState>(getInitialState);\n const [currentPath, setCurrentPath] = useState(\n typeof window !== 'undefined' ? window.location.pathname : '',\n );\n const [isTransitioning, setIsTransitioning] = useState(false);\n\n const configRef = useRef(config);\n const onNavigateRef = useRef(onNavigate);\n const stateRef = useRef(state);\n const lastSimulatedKey = useRef<string>('');\n const lastPathForSimulation = useRef<string>(\n typeof window !== 'undefined' ? window.location.pathname : '',\n );\n const wasInternalAction = useRef(false);\n\n useEffect(() => {\n stateRef.current = state;\n }, [state]);\n\n useEffect(() => {\n configRef.current = config;\n onNavigateRef.current = onNavigate;\n }, [config, onNavigate]);\n\n useEffect(() => {\n if (currentPath !== lastPathForSimulation.current) {\n lastPathForSimulation.current = currentPath;\n lastSimulatedKey.current = ''; // Reset simulation tracking on path change\n }\n }, [currentPath]);\n\n useEffect(() => {\n if (typeof window === 'undefined') return;\n\n const handlePathChange = () => {\n const newPath = window.location.pathname;\n setCurrentPath(newPath);\n };\n\n window.addEventListener('popstate', handlePathChange);\n\n const originalPushState = window.history.pushState;\n const originalReplaceState = window.history.replaceState;\n\n window.history.pushState = function (...args) {\n originalPushState.apply(this, args);\n handlePathChange();\n };\n\n window.history.replaceState = function (...args) {\n originalReplaceState.apply(this, args);\n handlePathChange();\n };\n\n window.addEventListener('locationchange', handlePathChange);\n const interval = setInterval(handlePathChange, 200);\n\n return () => {\n window.removeEventListener('popstate', handlePathChange);\n window.history.pushState = originalPushState;\n window.history.replaceState = originalReplaceState;\n window.removeEventListener('locationchange', handlePathChange);\n clearInterval(interval);\n };\n }, []);\n\n const handleNavigation = useCallback((link?: string) => {\n if (!link) return;\n if (onNavigateRef.current) {\n onNavigateRef.current(link);\n } else {\n try {\n window.location.href = link;\n } catch {\n // Fallback for non-browser environments or invalid URLs in tests\n }\n }\n }, []);\n\n const isMatch = useCallback((step: OnboardingStep, path: string) => {\n if (!step?.urlMatch || !path) return false;\n\n const normalize = (p: string) => (p.endsWith('/') && p !== '/' ? p.slice(0, -1) : p);\n const normalizedPath = normalize(path);\n const normalizedMatch = normalize(step.urlMatch);\n\n let match = false;\n if (normalizedMatch.includes('*')) {\n const pattern = normalizedMatch\n .replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&') // Escape special regex chars\n .replace(/\\\\\\*/g, '.*'); // Convert escaped * back to .*\n match = new RegExp(`^${pattern}$`).test(normalizedPath);\n } else {\n match = normalizedPath === normalizedMatch;\n }\n return match;\n }, []);\n\n const simulateClicks = useCallback(\n (stepIndex: number, subStepIndex: number | null) => {\n const currentConfig = configRef.current;\n const actions: string[] = [];\n const path = window.location.pathname;\n \n const collectStepClicks = (step: OnboardingStep, upToSubStep: number | null = -1) => {\n if (upToSubStep === null) {\n return;\n }\n\n if (step.click) actions.push(step.attribute);\n if (step.subSteps) {\n const limit = upToSubStep === -1 ? step.subSteps.length : upToSubStep;\n for (let i = 0; i < limit; i++) {\n if (step.subSteps[i].click) actions.push(step.subSteps[i].attribute);\n }\n }\n };\n\n for (let i = 0; i <= stepIndex; i++) {\n const step = currentConfig.steps[i];\n if (isMatch(step, path)) {\n if (i < stepIndex) collectStepClicks(step);\n else if (subStepIndex !== null) {\n collectStepClicks(step, subStepIndex);\n }\n }\n }\n\n if (actions.length === 0) return;\n\n const performClick = (index: number) => {\n if (index >= actions.length) return;\n const attr = actions[index];\n const element = document.querySelector(`[data-onboarding-id=\"${attr}\"]`) as HTMLElement;\n if (element) element.click();\n setTimeout(() => performClick(index + 1), 500);\n };\n\n setTimeout(() => performClick(0), 500);\n },\n [isMatch],\n );\n\n // Reconcile state with path\n useEffect(() => {\n if (ssr && !isMounted) {\n setIsMounted(true);\n return;\n }\n\n const currentConfig = configRef.current;\n const currentState = stateRef.current;\n const isInOrder = (currentConfig.metadata.inOrder as boolean | undefined) !== false;\n\n if (!currentState.isActive) return;\n\n let nextState: OnboardingState | null = null;\n let navTo: string | undefined;\n\n if (!isInOrder) {\n const matchedIndex = currentConfig.steps.findIndex(\n (step, index) => isMatch(step, currentPath) && !currentState.completedSteps.includes(index),\n );\n\n if (matchedIndex !== -1 && matchedIndex !== currentState.currentStepIndex) {\n nextState = {\n ...currentState,\n currentStepIndex: matchedIndex,\n currentSubStepIndex: currentState.subStepProgress[matchedIndex] ?? null,\n };\n }\n } else {\n const firstUnfinishedIndex = currentConfig.steps.findIndex(\n (_, i) => !currentState.completedSteps.includes(i),\n );\n\n if (firstUnfinishedIndex !== -1) {\n if (firstUnfinishedIndex !== currentState.currentStepIndex) {\n nextState = {\n ...currentState,\n currentStepIndex: firstUnfinishedIndex,\n currentSubStepIndex: currentState.subStepProgress[firstUnfinishedIndex] ?? null,\n };\n }\n\n const step = currentConfig.steps[firstUnfinishedIndex];\n if (!isMatch(step, currentPath)) {\n if (step.urlBase && currentPath !== step.urlBase) {\n navTo = step.urlBase;\n }\n }\n }\n }\n\n if (nextState) {\n setState(nextState);\n }\n if (navTo) {\n handleNavigation(navTo);\n }\n }, [ssr, isMounted, currentPath, handleNavigation, isMatch, state.isActive, state.currentStepIndex, state.completedSteps, state.subStepProgress]);\n\n // Handle click simulation separately\n useEffect(() => {\n if (!state.isActive || !isMounted) return;\n const currentConfig = configRef.current;\n const step = currentConfig.steps[state.currentStepIndex];\n\n const simKey = `${currentPath}-${state.currentStepIndex}-${state.currentSubStepIndex}`;\n\n if (lastSimulatedKey.current === simKey) {\n return;\n }\n\n const internal = wasInternalAction.current;\n wasInternalAction.current = false;\n\n if (internal && currentPath === lastPathForSimulation.current) {\n lastSimulatedKey.current = simKey;\n return;\n }\n\n if (step && isMatch(step, currentPath) && currentConfig.metadata.simulateClicksOnNavigate) {\n if (lastSimulatedKey.current !== simKey) {\n lastSimulatedKey.current = simKey;\n lastPathForSimulation.current = currentPath;\n simulateClicks(state.currentStepIndex, state.currentSubStepIndex);\n }\n }\n }, [\n state.currentStepIndex,\n state.currentSubStepIndex,\n state.isActive,\n currentPath,\n isMounted,\n isMatch,\n simulateClicks,\n ]);\n\n // Persist state to cookies\n useEffect(() => {\n if (isMounted) {\n Cookies.set(COOKIE_NAME, JSON.stringify(state), { expires: 365 });\n }\n }, [state, isMounted]);\n\n const currentStep = useMemo(() => {\n const step = config.steps[state.currentStepIndex];\n if (!step) return null;\n\n const isUrlMatch = isMatch(step, currentPath);\n\n if (state.currentSubStepIndex !== null && step.subSteps) {\n const subStep = step.subSteps[state.currentSubStepIndex];\n if (isUrlMatch || isTransitioning) {\n return subStep || step;\n }\n return null;\n }\n\n if (!isUrlMatch) return null;\n\n return step;\n }, [\n config.steps,\n state.currentStepIndex,\n state.currentSubStepIndex,\n currentPath,\n isMatch,\n isTransitioning,\n ]);\n\n const isFirstStep = state.currentStepIndex === 0 && state.currentSubStepIndex === null;\n const isLastStep = useMemo(() => {\n const totalSteps = config.steps.length;\n const step = config.steps[state.currentStepIndex];\n const hasSubSteps = step?.subSteps && step.subSteps.length > 0;\n\n if (state.currentStepIndex === totalSteps - 1) {\n if (hasSubSteps) return state.currentSubStepIndex === step.subSteps!.length - 1;\n return true;\n }\n return false;\n }, [config.steps, state.currentStepIndex, state.currentSubStepIndex]);\n\n const nextStep = useCallback(() => {\n const currentConfig = configRef.current;\n const currentState = stateRef.current;\n wasInternalAction.current = true;\n\n const { currentStepIndex, currentSubStepIndex, completedSteps } = currentState;\n const stepObj = currentConfig.steps[currentStepIndex];\n if (!stepObj) return;\n\n const currentActiveStep =\n currentSubStepIndex !== null && stepObj.subSteps\n ? stepObj.subSteps[currentSubStepIndex]\n : stepObj;\n\n if (currentActiveStep.click) {\n const element = document.querySelector(\n `[data-onboarding-id=\"${currentActiveStep.attribute}\"]`,\n ) as HTMLElement;\n if (element) element.click();\n }\n\n let nextState: OnboardingState;\n let navTo: string | undefined;\n\n if (\n stepObj.subSteps &&\n (currentSubStepIndex === null || currentSubStepIndex < stepObj.subSteps.length - 1)\n ) {\n const nextSubIndex = currentSubStepIndex === null ? 0 : currentSubStepIndex + 1;\n const nextSubStep = stepObj.subSteps[nextSubIndex];\n\n setIsTransitioning(true);\n setTimeout(() => setIsTransitioning(false), 1000);\n\n navTo = currentActiveStep.navigate || nextSubStep.navigate;\n if (!navTo && currentSubStepIndex === null) navTo = stepObj.navigate;\n\n nextState = {\n ...currentState,\n currentSubStepIndex: nextSubIndex,\n subStepProgress: {\n ...currentState.subStepProgress,\n [currentStepIndex]: nextSubIndex,\n },\n };\n } else {\n const stepIndexToComplete = currentStepIndex;\n if (currentStepIndex < currentConfig.steps.length - 1) {\n const nextIndex = currentStepIndex + 1;\n const nextStepObj = currentConfig.steps[nextIndex];\n const targetSubStepIndex = currentState.subStepProgress[nextIndex] ?? null;\n const targetSubStep =\n targetSubStepIndex !== null && nextStepObj.subSteps\n ? nextStepObj.subSteps[targetSubStepIndex]\n : null;\n\n navTo = currentActiveStep.navigate || nextStepObj.navigate || targetSubStep?.navigate;\n\n nextState = {\n ...currentState,\n currentStepIndex: nextIndex,\n currentSubStepIndex: targetSubStepIndex,\n completedSteps: completedSteps.includes(stepIndexToComplete)\n ? completedSteps\n : [...completedSteps, stepIndexToComplete],\n subStepProgress: {\n ...currentState.subStepProgress,\n [stepIndexToComplete]: currentSubStepIndex,\n },\n };\n } else {\n if (currentConfig.onOnboardingComplete) currentConfig.onOnboardingComplete();\n\n navTo = currentActiveStep.navigate || stepObj.navigate;\n\n nextState = {\n ...currentState,\n isActive: false,\n completedSteps: completedSteps.includes(stepIndexToComplete)\n ? completedSteps\n : [...completedSteps, stepIndexToComplete],\n subStepProgress: {\n ...currentState.subStepProgress,\n [stepIndexToComplete]: currentSubStepIndex,\n },\n };\n }\n }\n\n Cookies.set(COOKIE_NAME, JSON.stringify(nextState), { expires: 365 });\n if (navTo) handleNavigation(navTo);\n setState(nextState);\n }, [handleNavigation]);\n\n const prevStep = useCallback(() => {\n const currentConfig = configRef.current;\n const currentState = stateRef.current;\n wasInternalAction.current = true;\n\n let nextState: OnboardingState | null = null;\n let navTo: string | undefined;\n\n if (currentState.currentSubStepIndex !== null && currentState.currentSubStepIndex > 0) {\n const nextSubIndex = currentState.currentSubStepIndex - 1;\n const nextSubStep = currentConfig.steps[currentState.currentStepIndex].subSteps![nextSubIndex];\n navTo = nextSubStep.navigate;\n\n nextState = {\n ...currentState,\n currentSubStepIndex: nextSubIndex,\n subStepProgress: {\n ...currentState.subStepProgress,\n [currentState.currentStepIndex]: nextSubIndex,\n },\n };\n } else if (currentState.currentStepIndex > 0 && currentState.currentSubStepIndex === 0) {\n const stepObj = currentConfig.steps[currentState.currentStepIndex];\n navTo = stepObj.navigate;\n\n nextState = {\n ...currentState,\n currentSubStepIndex: null,\n subStepProgress: {\n ...currentState.subStepProgress,\n [currentState.currentStepIndex]: null,\n },\n };\n } else if (currentState.currentStepIndex > 0) {\n const prevIndex = currentState.currentStepIndex - 1;\n const prevStepObj = currentConfig.steps[prevIndex];\n const prevSubStepIndex =\n currentState.subStepProgress[prevIndex] ??\n (prevStepObj.subSteps ? prevStepObj.subSteps.length - 1 : null);\n const prevSubStep =\n prevSubStepIndex !== null && prevStepObj.subSteps\n ? prevStepObj.subSteps[prevSubStepIndex]\n : null;\n\n navTo = prevStepObj.navigate || prevSubStep?.navigate;\n\n nextState = {\n ...currentState,\n currentStepIndex: prevIndex,\n currentSubStepIndex: prevSubStepIndex,\n isActive: true,\n subStepProgress: {\n ...currentState.subStepProgress,\n [prevIndex]: prevSubStepIndex,\n },\n };\n }\n\n if (nextState) {\n Cookies.set(COOKIE_NAME, JSON.stringify(nextState), { expires: 365 });\n if (navTo) handleNavigation(navTo);\n setState(nextState);\n }\n }, [handleNavigation]);\n\n const finish = useCallback(() => {\n setState((prev) => ({ ...prev, isActive: false }));\n if (configRef.current.onOnboardingComplete) configRef.current.onOnboardingComplete();\n }, []);\n\n const goToStep = useCallback(\n (stepIndex: number, subStepIndex: number | null = null) => {\n const currentConfig = configRef.current;\n const currentState = stateRef.current;\n wasInternalAction.current = true;\n\n const nextStepObj = currentConfig.steps[stepIndex];\n if (!nextStepObj) return;\n\n const targetSubStep =\n subStepIndex !== null && nextStepObj.subSteps\n ? nextStepObj.subSteps[subStepIndex]\n : null;\n\n const navTo = nextStepObj.navigate || targetSubStep?.navigate;\n\n const nextState = {\n ...currentState,\n currentStepIndex: stepIndex,\n currentSubStepIndex: subStepIndex,\n isActive: true,\n subStepProgress: {\n ...currentState.subStepProgress,\n [stepIndex]: subStepIndex,\n },\n };\n\n Cookies.set(COOKIE_NAME, JSON.stringify(nextState), { expires: 365 });\n if (navTo) handleNavigation(navTo);\n setState(nextState);\n },\n [handleNavigation],\n );\n\n const value = {\n config,\n state,\n nextStep,\n prevStep,\n finish,\n goToStep,\n currentStep,\n isFirstStep,\n isLastStep,\n };\n\n if (!isMounted) return <>{children}</>;\n\n return (\n <OnboardingContext.Provider value={value}>\n {children}\n {state.isActive && <OnboardingOverlay />}\n </OnboardingContext.Provider>\n );\n};\n\nexport const useOnboarding = () => {\n const context = useContext(OnboardingContext);\n if (context === undefined)\n throw new Error('useOnboarding must be used within an OnboardingProvider');\n return context;\n};\n","'use client';\n\nimport React, { useState, useEffect, useCallback, useRef } from 'react';\nimport { createPortal } from 'react-dom';\nimport { useOnboarding } from './OnboardingProvider';\n\nconst ChevronLeftIcon = () => (\n <svg\n width=\"16\"\n height=\"16\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d=\"M15 18l-6-6 6-6\" />\n </svg>\n);\n\nconst ChevronRightIcon = () => (\n <svg\n width=\"16\"\n height=\"16\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d=\"M9 18l6-6-6-6\" />\n </svg>\n);\n\nconst XIcon = () => (\n <svg\n width=\"18\"\n height=\"18\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <line x1=\"18\" y1=\"6\" x2=\"6\" y2=\"18\" />\n <line x1=\"6\" y1=\"6\" x2=\"18\" y2=\"18\" />\n </svg>\n);\n\nexport const OnboardingOverlay: React.FC = () => {\n const { config, currentStep, nextStep, prevStep, finish, isFirstStep, isLastStep } =\n useOnboarding();\n const [coords, setCoords] = useState<{\n top: number;\n left: number;\n width: number;\n height: number;\n } | null>(null);\n const [position, setPosition] = useState<{ top: number; left: number }>({ top: 0, left: 0 });\n const [dragOffset, setDragOffset] = useState<{ x: number; y: number }>({ x: 0, y: 0 });\n const isDragging = useRef(false);\n const dragStart = useRef<{ x: number; y: number }>({ x: 0, y: 0 });\n const tooltipRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n // eslint-disable-next-line react-hooks/set-state-in-effect\n setDragOffset({ x: 0, y: 0 });\n }, [currentStep]);\n\n const handlePointerUpRef = useRef<() => void>(() => {});\n\n const handlePointerMove = useCallback((e: PointerEvent) => {\n if (!isDragging.current) return;\n\n const newX = e.clientX - dragStart.current.x;\n const newY = e.clientY - dragStart.current.y;\n\n setDragOffset({ x: newX, y: newY });\n }, []);\n\n const handlePointerUp = useCallback(() => {\n isDragging.current = false;\n\n if (tooltipRef.current) {\n tooltipRef.current.style.transition =\n 'top 0.3s cubic-bezier(0.25, 0.1, 0.25, 1), left 0.3s cubic-bezier(0.25, 0.1, 0.25, 1)';\n tooltipRef.current.style.cursor = config.metadata.draggable ? 'grab' : 'auto';\n }\n\n window.removeEventListener('pointermove', handlePointerMove);\n window.removeEventListener('pointerup', handlePointerUpRef.current);\n }, [config.metadata.draggable, handlePointerMove]);\n\n useEffect(() => {\n handlePointerUpRef.current = handlePointerUp;\n }, [handlePointerUp]);\n\n const handlePointerDown = (e: React.PointerEvent) => {\n if (!config.metadata.draggable) return;\n e.stopPropagation();\n e.preventDefault();\n isDragging.current = true;\n dragStart.current = { x: e.clientX - dragOffset.x, y: e.clientY - dragOffset.y };\n\n if (tooltipRef.current) {\n tooltipRef.current.style.transition = 'none';\n tooltipRef.current.style.cursor = 'grabbing';\n }\n\n window.addEventListener('pointermove', handlePointerMove);\n window.addEventListener('pointerup', handlePointerUp);\n };\n\n const calculateBestPosition = useCallback(\n (rect: {\n top: number;\n bottom: number;\n left: number;\n right: number;\n width: number;\n height: number;\n }) => {\n const tooltipWidth = 300;\n const tooltipHeight = 200;\n const gap = 12;\n const padding = 20;\n\n const spaceAbove = rect.top;\n const spaceBelow = window.innerHeight - rect.bottom;\n const spaceLeft = rect.left;\n const spaceRight = window.innerWidth - rect.right;\n\n let top = 0;\n let left = 0;\n\n if (spaceBelow > tooltipHeight + gap + padding) {\n top = rect.bottom + gap;\n left = Math.max(\n padding,\n Math.min(\n window.innerWidth - tooltipWidth - padding,\n rect.left + rect.width / 2 - tooltipWidth / 2,\n ),\n );\n } else if (spaceAbove > tooltipHeight + gap + padding) {\n top = rect.top - tooltipHeight - gap;\n left = Math.max(\n padding,\n Math.min(\n window.innerWidth - tooltipWidth - padding,\n rect.left + rect.width / 2 - tooltipWidth / 2,\n ),\n );\n } else if (spaceRight > tooltipWidth + gap + padding) {\n top = Math.max(\n padding,\n Math.min(\n window.innerHeight - tooltipHeight - padding,\n rect.top + rect.height / 2 - tooltipHeight / 2,\n ),\n );\n left = rect.right + gap;\n } else if (spaceLeft > tooltipWidth + gap + padding) {\n top = Math.max(\n padding,\n Math.min(\n window.innerHeight - tooltipHeight - padding,\n rect.top + rect.height / 2 - tooltipHeight / 2,\n ),\n );\n left = rect.left - tooltipWidth - gap;\n } else {\n top = window.innerHeight / 2 - tooltipHeight / 2;\n left = window.innerWidth / 2 - tooltipWidth / 2;\n }\n\n return { top: top + window.scrollY, left: left + window.scrollX };\n },\n [],\n );\n\n const updateCoords = useCallback(() => {\n if (!currentStep) return;\n\n const element = document.querySelector(\n `[data-onboarding-id=\"${currentStep.attribute}\"]`,\n ) as HTMLElement;\n if (element) {\n const rect = element.getBoundingClientRect();\n const padding = config.style?.padding || 0;\n\n const paddedRect = {\n top: rect.top - padding,\n bottom: rect.bottom + padding,\n left: rect.left - padding,\n right: rect.right + padding,\n width: rect.width + padding * 2,\n height: rect.height + padding * 2,\n };\n\n const newCoords = {\n top: paddedRect.top + window.scrollY,\n left: paddedRect.left + window.scrollX,\n width: paddedRect.width,\n height: paddedRect.height,\n };\n\n const newPosition = calculateBestPosition(paddedRect);\n\n setCoords((prev) => {\n if (\n prev &&\n prev.top === newCoords.top &&\n prev.left === newCoords.left &&\n prev.width === newCoords.width &&\n prev.height === newCoords.height\n ) {\n return prev;\n }\n return newCoords;\n });\n\n setPosition((prev) => {\n if (prev.top === newPosition.top && prev.left === newPosition.left) {\n return prev;\n }\n return newPosition;\n });\n } else {\n setCoords(null);\n }\n }, [currentStep, calculateBestPosition, config.style]);\n\n useEffect(() => {\n // eslint-disable-next-line react-hooks/set-state-in-effect\n updateCoords();\n window.addEventListener('resize', updateCoords);\n window.addEventListener('scroll', updateCoords);\n\n const observer = new MutationObserver(updateCoords);\n observer.observe(document.body, { childList: true, subtree: true, attributes: true });\n\n let resizeObserver: ResizeObserver | null = null;\n if (typeof ResizeObserver !== 'undefined') {\n resizeObserver = new ResizeObserver(updateCoords);\n resizeObserver.observe(document.body);\n\n const element = currentStep?.attribute\n ? document.querySelector(`[data-onboarding-id=\"${currentStep.attribute}\"]`)\n : null;\n if (element) {\n resizeObserver.observe(element);\n }\n }\n\n return () => {\n window.removeEventListener('resize', updateCoords);\n window.removeEventListener('scroll', updateCoords);\n window.removeEventListener('pointermove', handlePointerMove);\n window.removeEventListener('pointerup', handlePointerUp);\n observer.disconnect();\n if (resizeObserver) resizeObserver.disconnect();\n };\n }, [updateCoords, currentStep?.attribute, handlePointerMove, handlePointerUp]);\n\n if (!currentStep || !coords) return null;\n\n const maskStyle = {\n ...config.style?.background,\n transition: 'all 0.3s cubic-bezier(0.25, 0.1, 0.25, 1)',\n };\n\n const stopPropagation = (e: React.PointerEvent | React.MouseEvent) => {\n e.stopPropagation();\n };\n\n const overlayContent = (\n <div className=\"onboard-overlay-container\">\n <div\n style={{ height: coords.top, ...maskStyle }}\n className=\"onboard-overlay-mask onboard-mask-top\"\n onPointerDown={stopPropagation}\n onMouseDown={stopPropagation}\n onClick={stopPropagation}\n />\n <div\n style={{\n top: coords.top + coords.height,\n height: `calc(100vh - ${coords.top + coords.height}px)`,\n ...maskStyle,\n }}\n className=\"onboard-overlay-mask onboard-mask-bottom\"\n onPointerDown={stopPropagation}\n onMouseDown={stopPropagation}\n onClick={stopPropagation}\n />\n <div\n style={{ top: coords.top, height: coords.height, width: coords.left, ...maskStyle }}\n className=\"onboard-overlay-mask onboard-mask-left\"\n onPointerDown={stopPropagation}\n onMouseDown={stopPropagation}\n onClick={stopPropagation}\n />\n <div\n style={{\n top: coords.top,\n height: coords.height,\n left: coords.left + coords.width,\n width: `calc(100% - ${coords.left + coords.width}px)`,\n ...maskStyle,\n }}\n className=\"onboard-overlay-mask\"\n onPointerDown={stopPropagation}\n onMouseDown={stopPropagation}\n onClick={stopPropagation}\n />\n\n <div\n ref={tooltipRef}\n className=\"onboard-tooltip\"\n onPointerDown={handlePointerDown}\n style={{\n zIndex: 1000000,\n ...config.style?.container,\n top: position.top + dragOffset.y,\n left: position.left + dragOffset.x,\n transition:\n 'top 0.3s cubic-bezier(0.25, 0.1, 0.25, 1), left 0.3s cubic-bezier(0.25, 0.1, 0.25, 1)',\n cursor: config.metadata.draggable ? 'grab' : 'auto',\n touchAction: 'none',\n }}\n onMouseDown={stopPropagation}\n onClick={stopPropagation}\n >\n <div className=\"onboard-tooltip-header\">\n <h3 className=\"onboard-tooltip-title\">{currentStep.title}</h3>\n <button\n onClick={(e) => {\n e.stopPropagation();\n finish();\n }}\n className=\"onboard-close-button\"\n >\n <XIcon />\n </button>\n </div>\n <p className=\"onboard-tooltip-description\">{currentStep.description}</p>\n\n <div className=\"onboard-tooltip-footer\">\n <button\n onClick={(e) => {\n e.stopPropagation();\n prevStep();\n }}\n disabled={isFirstStep}\n className=\"onboard-button-ghost\"\n style={{\n background: 'none',\n border: 'none',\n cursor: isFirstStep ? 'not-allowed' : 'pointer',\n ...config.style?.prev,\n }}\n >\n <ChevronLeftIcon />\n Prev\n </button>\n\n {isLastStep ? (\n <button\n onClick={(e) => {\n e.stopPropagation();\n nextStep();\n }}\n className=\"onboard-button-primary\"\n style={{ border: 'none', cursor: 'pointer', ...config.style?.finish }}\n >\n Finish\n </button>\n ) : (\n <button\n onClick={(e) => {\n e.stopPropagation();\n nextStep();\n }}\n className=\"onboard-button-primary\"\n style={{\n border: 'none',\n cursor: 'pointer',\n ...(isFirstStep ? config.style?.start : {}),\n ...(!isFirstStep ? config.style?.next : {}),\n }}\n >\n {isFirstStep && config.style?.start ? 'Start' : 'Next'}\n {!(isFirstStep && config.style?.start) && <ChevronRightIcon />}\n </button>\n )}\n </div>\n </div>\n </div>\n );\n\n return typeof document !== 'undefined' ? createPortal(overlayContent, document.body) : null;\n};\n"],"mappings":";olBAAA,IAAAA,GAAA,GAAAC,GAAAD,GAAA,wBAAAE,GAAA,kBAAAC,IAAA,eAAAC,GAAAJ,ICEA,IAAAK,EAQO,iBACPC,EAAoB,yBCTpB,IAAAC,EAAgE,iBAChEC,EAA6B,qBAczB,IAAAC,EAAA,6BAXEC,GAAkB,OACtB,OAAC,OACC,MAAM,KACN,OAAO,KACP,QAAQ,YACR,KAAK,OACL,OAAO,eACP,YAAY,IACZ,cAAc,QACd,eAAe,QAEf,mBAAC,QAAK,EAAE,kBAAkB,EAC5B,EAGIC,GAAmB,OACvB,OAAC,OACC,MAAM,KACN,OAAO,KACP,QAAQ,YACR,KAAK,OACL,OAAO,eACP,YAAY,IACZ,cAAc,QACd,eAAe,QAEf,mBAAC,QAAK,EAAE,gBAAgB,EAC1B,EAGIC,GAAQ,OACZ,QAAC,OACC,MAAM,KAC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S,eAAY,IAAM,CAC/B3E,EAAU4E,IAAU,CAAE,GAAGA,EAAM,SAAU,EAAM,EAAE,EAC7CvE,EAAU,QAAQ,sBAAsBA,EAAU,QAAQ,qBAAqB,CACrF,EAAG,CAAC,CAAC,EAECwE,KAAW,eACf,CAAChD,EAAmBC,EAA8B,OAAS,CACzD,IAAMC,EAAgB1B,EAAU,QAC1BoC,EAAelC,EAAS,QAC9BG,EAAkB,QAAU,GAE5B,IAAMyD,EAAcpC,EAAc,MAAMF,CAAS,EACjD,GAAI,CAACsC,EAAa,OAElB,IAAME,EACJvC,IAAiB,MAAQqC,EAAY,SACjCA,EAAY,SAASrC,CAAY,EACjC,KAEAc,EAAQuB,EAAY,UAAYE,GAAe,SAE/C1B,EAAY,CAChB,GAAGF,EACH,iBAAkBZ,EAClB,oBAAqBC,EACrB,SAAU,GACV,gBAAiB,CACf,GAAGW,EAAa,gBAChB,CAACZ,CAAS,EAAGC,CACf,CACF,EAEA,EAAAxC,QAAQ,IAAIH,EAAa,KAAK,UAAUwD,CAAS,EAAG,CAAE,QAAS,GAAI,CAAC,EAChEC,GAAO3B,EAAiB2B,CAAK,EACjC5C,EAAS2C,CAAS,CACpB,EACA,CAAC1B,CAAgB,CACnB,EAEM6D,EAAQ,CACZ,OAAArF,EACA,MAAAM,EACA,SAAA0D,EACA,SAAAa,EACA,OAAAK,EACA,SAAAE,EACA,YAAA3B,EACA,YAAAG,EACA,WAAAC,CACF,EAEA,OAAKzD,KAGH,QAACX,EAAkB,SAAlB,CAA2B,MAAO4F,EAChC,UAAAlF,EACAG,EAAM,aAAY,OAACgF,EAAA,EAAkB,GACxC,KANqB,mBAAG,SAAAnF,EAAS,CAQrC,EAEaoF,EAAgB,IAAM,CACjC,IAAMC,KAAU,cAAW/F,CAAiB,EAC5C,GAAI+F,IAAY,OACd,MAAM,IAAI,MAAM,yDAAyD,EAC3E,OAAOA,CACT","names":["index_exports","__export","OnboardingProvider","useOnboarding","__toCommonJS","import_react","import_js_cookie","import_react","import_react_dom","import_jsx_runtime","ChevronLeftIcon","ChevronRightIcon","XIcon","OnboardingOverlay","config","currentStep","nextStep","prevStep","finish","isFirstStep","isLastStep","useOnboarding","coords","setCoords","position","setPosition","dragOffset","setDragOffset","isDragging","dragStart","tooltipRef","handlePointerUpRef","handlePointerMove","e","newX","newY","handlePointerUp","handlePointerDown","calculateBestPosition","rect","spaceAbove","spaceBelow","spaceLeft","spaceRight","top","left","updateCoords","element","padding","paddedRect","newCoords","newPosition","prev","observer","resizeObserver","maskStyle","stopPropagation","overlayContent","import_jsx_runtime","OnboardingContext","COOKIE_NAME","getInitialState","saved","Cookies","parsed","OnboardingProvider","config","ssr","onNavigate","children","isMounted","setIsMounted","state","setState","currentPath","setCurrentPath","isTransitioning","setIsTransitioning","configRef","onNavigateRef","stateRef","lastSimulatedKey","lastPathForSimulation","wasInternalAction","handlePathChange","newPath","originalPushState","originalReplaceState","args","interval","handleNavigation","link","isMatch","step","path","normalize","p","normalizedPath","normalizedMatch","match","pattern","simulateClicks","stepIndex","subStepIndex","currentConfig","actions","collectStepClicks","upToSubStep","limit","i","performClick","index","attr","element","currentState","isInOrder","nextState","navTo","firstUnfinishedIndex","_","matchedIndex","simKey","internal","currentStep","isUrlMatch","subStep","isFirstStep","isLastStep","totalSteps","hasSubSteps","nextStep","currentStepIndex","currentSubStepIndex","completedSteps","stepObj","currentActiveStep","nextSubIndex","nextSubStep","stepIndexToComplete","nextIndex","nextStepObj","targetSubStepIndex","targetSubStep","prevStep","prevIndex","prevStepObj","prevSubStepIndex","prevSubStep","finish","prev","goToStep","value","OnboardingOverlay","useOnboarding","context"]}
package/dist/index.mjs CHANGED
@@ -1,3 +1,3 @@
1
1
  "use client";
2
- "use client";import{createContext as ut,useContext as lt,useEffect as R,useState as Y,useCallback as z,useMemo as et,useRef as W}from"react";import D from"js-cookie";import{useState as Q,useEffect as V,useCallback as X,useRef as J}from"react";import{createPortal as rt}from"react-dom";import{jsx as h,jsxs as N}from"react/jsx-runtime";var it=()=>h("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:h("path",{d:"M15 18l-6-6 6-6"})}),st=()=>h("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:h("path",{d:"M9 18l6-6-6-6"})}),at=()=>N("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[h("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),h("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]}),Z=()=>{let{config:l,currentStep:p,nextStep:T,prevStep:q,finish:v,isFirstStep:k,isLastStep:c}=tt(),[d,g]=Q(null),[H,j]=Q({top:0,left:0}),[L,O]=Q({x:0,y:0}),E=J(!1),C=J({x:0,y:0}),y=J(null);V(()=>{O({x:0,y:0})},[p]);let M=J(()=>{}),w=X(r=>{if(!E.current)return;let b=r.clientX-C.current.x,I=r.clientY-C.current.y;O({x:b,y:I})},[]),x=X(()=>{E.current=!1,y.current&&(y.current.style.transition="top 0.3s cubic-bezier(0.25, 0.1, 0.25, 1), left 0.3s cubic-bezier(0.25, 0.1, 0.25, 1)",y.current.style.cursor=l.metadata.draggable?"grab":"auto"),window.removeEventListener("pointermove",w),window.removeEventListener("pointerup",M.current)},[l.metadata.draggable,w]);V(()=>{M.current=x},[x]);let B=r=>{l.metadata.draggable&&(r.stopPropagation(),r.preventDefault(),E.current=!0,C.current={x:r.clientX-L.x,y:r.clientY-L.y},y.current&&(y.current.style.transition="none",y.current.style.cursor="grabbing"),window.addEventListener("pointermove",w),window.addEventListener("pointerup",x))},F=X(r=>{let o=r.top,n=window.innerHeight-r.bottom,s=r.left,a=window.innerWidth-r.right,u=0,i=0;return n>232?(u=r.bottom+12,i=Math.max(20,Math.min(window.innerWidth-300-20,r.left+r.width/2-300/2))):o>232?(u=r.top-200-12,i=Math.max(20,Math.min(window.innerWidth-300-20,r.left+r.width/2-300/2))):a>332?(u=Math.max(20,Math.min(window.innerHeight-200-20,r.top+r.height/2-200/2)),i=r.right+12):s>332?(u=Math.max(20,Math.min(window.innerHeight-200-20,r.top+r.height/2-200/2)),i=r.left-300-12):(u=window.innerHeight/2-200/2,i=window.innerWidth/2-300/2),{top:u+window.scrollY,left:i+window.scrollX}},[]),U=X(()=>{if(!p)return;let r=document.querySelector(`[data-onboarding-id="${p.attribute}"]`);if(r){let b=r.getBoundingClientRect(),I=l.style?.padding||0,e={top:b.top-I,bottom:b.bottom+I,left:b.left-I,right:b.right+I,width:b.width+I*2,height:b.height+I*2},t={top:e.top+window.scrollY,left:e.left+window.scrollX,width:e.width,height:e.height},o=F(e);g(n=>n&&Math.abs(n.top-t.top)<.5&&Math.abs(n.left-t.left)<.5&&Math.abs(n.width-t.width)<.5&&Math.abs(n.height-t.height)<.5?n:t),j(n=>Math.abs(n.top-o.top)<.5&&Math.abs(n.left-o.left)<.5?n:o)}else g(null)},[p,F,l.style]);if(V(()=>{let r,b=()=>{clearTimeout(r),r=setTimeout(U,16)};b(),window.addEventListener("resize",b),window.addEventListener("scroll",b);let I=new MutationObserver(t=>{t.some(n=>n.type==="childList"||n.type==="attributes"&&n.attributeName?.includes("data-onboarding-id"))&&b()});I.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["data-onboarding-id","style","class"]});let e=null;if(typeof ResizeObserver<"u"){e=new ResizeObserver(b),e.observe(document.body);let t=p?.attribute?document.querySelector(`[data-onboarding-id="${p.attribute}"]`):null;t&&e.observe(t)}return()=>{clearTimeout(r),window.removeEventListener("resize",b),window.removeEventListener("scroll",b),window.removeEventListener("pointermove",w),window.removeEventListener("pointerup",x),I.disconnect(),e&&e.disconnect()}},[U,p?.attribute,w,x]),!p||!d)return null;let A={...l.style?.background,transition:"all 0.3s cubic-bezier(0.25, 0.1, 0.25, 1)"},m=r=>{r.stopPropagation()},K=N("div",{className:"onboard-overlay-container",children:[h("div",{style:{height:d.top,...A},className:"onboard-overlay-mask onboard-mask-top",onPointerDown:m,onMouseDown:m,onClick:m}),h("div",{style:{top:d.top+d.height,height:`calc(100vh - ${d.top+d.height}px)`,...A},className:"onboard-overlay-mask onboard-mask-bottom",onPointerDown:m,onMouseDown:m,onClick:m}),h("div",{style:{top:d.top,height:d.height,width:d.left,...A},className:"onboard-overlay-mask onboard-mask-left",onPointerDown:m,onMouseDown:m,onClick:m}),h("div",{style:{top:d.top,height:d.height,left:d.left+d.width,width:`calc(100% - ${d.left+d.width}px)`,...A},className:"onboard-overlay-mask",onPointerDown:m,onMouseDown:m,onClick:m}),N("div",{ref:y,className:"onboard-tooltip",onPointerDown:B,style:{zIndex:1e6,...l.style?.container,top:H.top+L.y,left:H.left+L.x,transition:"top 0.3s cubic-bezier(0.25, 0.1, 0.25, 1), left 0.3s cubic-bezier(0.25, 0.1, 0.25, 1)",cursor:l.metadata.draggable?"grab":"auto",touchAction:"none"},onMouseDown:m,onClick:m,children:[N("div",{className:"onboard-tooltip-header",children:[h("h3",{className:"onboard-tooltip-title",children:p.title}),h("button",{onClick:r=>{r.stopPropagation(),v()},className:"onboard-close-button",children:h(at,{})})]}),h("p",{className:"onboard-tooltip-description",children:p.description}),N("div",{className:"onboard-tooltip-footer",children:[N("button",{onClick:r=>{r.stopPropagation(),q()},disabled:k,className:"onboard-button-ghost",style:{background:"none",border:"none",cursor:k?"not-allowed":"pointer",...l.style?.prev},children:[h(it,{}),"Prev"]}),c?h("button",{onClick:r=>{r.stopPropagation(),T()},className:"onboard-button-primary",style:{border:"none",cursor:"pointer",...l.style?.finish},children:"Finish"}):N("button",{onClick:r=>{r.stopPropagation(),T()},className:"onboard-button-primary",style:{border:"none",cursor:"pointer",...k?l.style?.start:{},...k?{}:l.style?.next},children:[k&&l.style?.start?"Start":"Next",!(k&&l.style?.start)&&h(st,{})]})]})]})]});return typeof document<"u"?rt(K,document.body):null};import{jsx as dt,jsxs as pt}from"react/jsx-runtime";var nt=ut(void 0),$="onboarding_state",ct=()=>{if(typeof window<"u"){let l=D.get($);if(l)try{let p=JSON.parse(l);if(p&&typeof p=="object")return{currentStepIndex:p.currentStepIndex??0,currentSubStepIndex:p.currentSubStepIndex??null,isActive:p.isActive??!0,completedSteps:p.completedSteps??[],subStepProgress:p.subStepProgress??{}}}catch{}}return{currentStepIndex:0,currentSubStepIndex:null,isActive:!0,completedSteps:[],subStepProgress:{}}},Pt=({config:l,ssr:p=!1,onNavigate:T,children:q})=>{let[v,k]=Y(!1),[c,d]=Y({currentStepIndex:0,currentSubStepIndex:null,isActive:!1,completedSteps:[],subStepProgress:{}}),[g,H]=Y(""),[j,L]=Y(!1),O=W(l),E=W(T),C=W(""),y=W(""),M=W(!1);R(()=>{k(!0);let e=ct();d(e),H(window.location.pathname),y.current=window.location.pathname},[]),R(()=>{v&&g!==y.current&&(y.current=g,C.current="")},[g,v]),R(()=>{O.current=l,E.current=T},[l,T]),R(()=>{if(!v)return;let e=()=>{let s=window.location.pathname;H(s)};window.addEventListener("popstate",e);let t=window.history.pushState,o=window.history.replaceState;window.history.pushState=function(...s){t.apply(this,s),e()},window.history.replaceState=function(...s){o.apply(this,s),e()};let n=setInterval(e,200);return()=>{window.removeEventListener("popstate",e),window.history.pushState=t,window.history.replaceState=o,clearInterval(n)}},[v]);let w=z(e=>{e&&(E.current?E.current(e):window.location.href=e)},[]),x=z((e,t)=>{if(!e?.urlMatch||!t)return!1;let o=!1;if(e.urlMatch.includes("*")){let n=e.urlMatch.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/\\\*/g,".*");o=new RegExp(`^${n}$`).test(t)}else o=t===e.urlMatch;return o},[]),B=z((e,t)=>{let o=O.current,n=[],s=window.location.pathname,a=(i,f=-1)=>{if(f!==null&&(i.click&&n.push(i.attribute),i.subSteps)){let S=f===-1?i.subSteps.length:f;for(let P=0;P<S;P++)i.subSteps[P].click&&n.push(i.subSteps[P].attribute)}};for(let i=0;i<=e;i++){let f=o.steps[i];x(f,s)&&(i<e?a(f):t!==null&&a(f,t))}if(n.length===0)return;let u=i=>{if(i>=n.length)return;let f=n[i],S=document.querySelector(`[data-onboarding-id="${f}"]`);S&&S.click(),setTimeout(()=>u(i+1),500)};setTimeout(()=>u(0),500)},[x,g]);R(()=>{if(p&&!v){k(!0);return}let e=O.current,t=e.metadata.inOrder!==!1;d(o=>{if(!o.isActive)return o;let n={...o},s=!1;if(t){let a=e.steps.findIndex((u,i)=>!o.completedSteps.includes(i));if(a!==-1){a!==o.currentStepIndex&&(n.currentStepIndex=a,n.currentSubStepIndex=o.subStepProgress[a]??null,s=!0);let u=e.steps[a];x(u,g)||u.urlBase&&g!==u.urlBase&&w(u.urlBase)}}else{let a=e.steps.findIndex((u,i)=>x(u,g)&&!o.completedSteps.includes(i));a!==-1&&a!==o.currentStepIndex&&(n.currentStepIndex=a,n.currentSubStepIndex=o.subStepProgress[a]??null,s=!0)}return s?n:o})},[p,v,g,w,x]),R(()=>{if(!c.isActive||!v)return;let e=O.current,t=e.steps[c.currentStepIndex],o=`${g}-${c.currentStepIndex}-${c.currentSubStepIndex}`;if(C.current===o)return;let n=M.current;if(M.current=!1,n&&g===y.current){C.current=o;return}t&&x(t,g)&&e.metadata.simulateClicksOnNavigate&&C.current!==o&&(C.current=o,y.current=g,B(c.currentStepIndex,c.currentSubStepIndex))},[c.currentStepIndex,c.currentSubStepIndex,c.isActive,g,v,x,B]),R(()=>{v&&D.set($,JSON.stringify(c),{expires:365})},[c,v]);let F=et(()=>{let e=l.steps[c.currentStepIndex];if(!e)return null;let t=x(e,g);if(c.currentSubStepIndex!==null&&e.subSteps){let o=e.subSteps[c.currentSubStepIndex];return t||j?o||e:null}return t?e:null},[l.steps,c.currentStepIndex,c.currentSubStepIndex,g,x,j]),U=c.currentStepIndex===0&&c.currentSubStepIndex===null,A=et(()=>{let e=l.steps.length,t=l.steps[c.currentStepIndex],o=t?.subSteps&&t.subSteps.length>0;return c.currentStepIndex===e-1?o?c.currentSubStepIndex===t.subSteps.length-1:!0:!1},[l.steps,c.currentStepIndex,c.currentSubStepIndex]),m=z(()=>{let e=O.current;M.current=!0,d(t=>{let{currentStepIndex:o,currentSubStepIndex:n,completedSteps:s}=t,a=e.steps[o];if(!a)return t;let u=n!==null&&a.subSteps?a.subSteps[n]:a;if(u.click){let S=document.querySelector(`[data-onboarding-id="${u.attribute}"]`);S&&S.click()}let i,f;if(a.subSteps&&(n===null||n<a.subSteps.length-1)){let S=n===null?0:n+1,P=a.subSteps[S];L(!0),setTimeout(()=>L(!1),1e3),f=u.navigate||P.navigate,!f&&n===null&&(f=a.navigate),i={...t,currentSubStepIndex:S,subStepProgress:{...t.subStepProgress,[o]:S}}}else{let S=o;if(o<e.steps.length-1){let P=o+1,_=e.steps[P],G=t.subStepProgress[P]??null,ot=G!==null&&_.subSteps?_.subSteps[G]:null;f=u.navigate||_.navigate||ot?.navigate,i={...t,currentStepIndex:P,currentSubStepIndex:G,completedSteps:s.includes(S)?s:[...s,S],subStepProgress:{...t.subStepProgress,[S]:n}}}else e.onOnboardingComplete&&e.onOnboardingComplete(),f=u.navigate||a.navigate,i={...t,isActive:!1,completedSteps:s.includes(S)?s:[...s,S],subStepProgress:{...t.subStepProgress,[S]:n}}}return D.set($,JSON.stringify(i),{expires:365}),f&&w(f),i})},[w]),K=z(()=>{let e=O.current;M.current=!0,d(t=>{let o,n;if(t.currentSubStepIndex!==null&&t.currentSubStepIndex>0){let s=t.currentSubStepIndex-1;n=e.steps[t.currentStepIndex].subSteps[s].navigate,o={...t,currentSubStepIndex:s,subStepProgress:{...t.subStepProgress,[t.currentStepIndex]:s}}}else if(t.currentStepIndex>0&&t.currentSubStepIndex===0)n=e.steps[t.currentStepIndex].navigate,o={...t,currentSubStepIndex:null,subStepProgress:{...t.subStepProgress,[t.currentStepIndex]:null}};else if(t.currentStepIndex>0){let s=t.currentStepIndex-1,a=e.steps[s],u=t.subStepProgress[s]??(a.subSteps?a.subSteps.length-1:null),i=u!==null&&a.subSteps?a.subSteps[u]:null;n=a.navigate||i?.navigate,o={...t,currentStepIndex:s,currentSubStepIndex:u,isActive:!0,subStepProgress:{...t.subStepProgress,[s]:u}}}else return t;return D.set($,JSON.stringify(o),{expires:365}),n&&w(n),o})},[w]),r=z(()=>{d(e=>({...e,isActive:!1})),O.current.onOnboardingComplete&&O.current.onOnboardingComplete()},[]),b=z((e,t=null)=>{let o=O.current;M.current=!0,d(n=>{let s=o.steps[e],a=t!==null&&s.subSteps?s.subSteps[t]:null,u=s.navigate||a?.navigate,i={...n,currentStepIndex:e,currentSubStepIndex:t,isActive:!0,subStepProgress:{...n.subStepProgress,[e]:t}};return D.set($,JSON.stringify(i),{expires:365}),u&&w(u),i})},[w]);return pt(nt,{value:{config:l,state:c,nextStep:m,prevStep:K,finish:r,goToStep:b,currentStep:F,isFirstStep:U,isLastStep:A},children:[q,v&&c.isActive&&dt(Z,{})]})},tt=()=>{let l=lt(nt);if(l===void 0)throw new Error("useOnboarding must be used within an OnboardingProvider");return l};export{Pt as OnboardingProvider,tt as useOnboarding};
2
+ "use client";import{createContext as lt,useContext as dt,useEffect as H,useState as K,useCallback as W,useMemo as nt,useRef as $}from"react";import B from"js-cookie";import{useState as V,useEffect as Z,useCallback as q,useRef as U}from"react";import{createPortal as st}from"react-dom";import{jsx as h,jsxs as A}from"react/jsx-runtime";var at=()=>h("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:h("path",{d:"M15 18l-6-6 6-6"})}),ut=()=>h("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:h("path",{d:"M9 18l6-6-6-6"})}),ct=()=>A("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[h("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),h("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]}),tt=()=>{let{config:c,currentStep:d,nextStep:T,prevStep:X,finish:C,isFirstStep:L,isLastStep:u}=et(),[p,g]=V(null),[J,Y]=V({top:0,left:0}),[R,y]=V({x:0,y:0}),z=U(!1),M=U({x:0,y:0}),v=U(null);Z(()=>{y({x:0,y:0})},[d]);let N=U(()=>{}),I=q(r=>{if(!z.current)return;let f=r.clientX-M.current.x,w=r.clientY-M.current.y;y({x:f,y:w})},[]),x=q(()=>{z.current=!1,v.current&&(v.current.style.transition="top 0.3s cubic-bezier(0.25, 0.1, 0.25, 1), left 0.3s cubic-bezier(0.25, 0.1, 0.25, 1)",v.current.style.cursor=c.metadata.draggable?"grab":"auto"),window.removeEventListener("pointermove",I),window.removeEventListener("pointerup",N.current)},[c.metadata.draggable,I]);Z(()=>{N.current=x},[x]);let P=r=>{c.metadata.draggable&&(r.stopPropagation(),r.preventDefault(),z.current=!0,M.current={x:r.clientX-R.x,y:r.clientY-R.y},v.current&&(v.current.style.transition="none",v.current.style.cursor="grabbing"),window.addEventListener("pointermove",I),window.addEventListener("pointerup",x))},j=q(r=>{let t=r.top,n=window.innerHeight-r.bottom,s=r.left,i=window.innerWidth-r.right,o=0,a=0;return n>232?(o=r.bottom+12,a=Math.max(20,Math.min(window.innerWidth-300-20,r.left+r.width/2-300/2))):t>232?(o=r.top-200-12,a=Math.max(20,Math.min(window.innerWidth-300-20,r.left+r.width/2-300/2))):i>332?(o=Math.max(20,Math.min(window.innerHeight-200-20,r.top+r.height/2-200/2)),a=r.right+12):s>332?(o=Math.max(20,Math.min(window.innerHeight-200-20,r.top+r.height/2-200/2)),a=r.left-300-12):(o=window.innerHeight/2-200/2,a=window.innerWidth/2-300/2),{top:o+window.scrollY,left:a+window.scrollX}},[]),O=q(()=>{if(!d)return;let r=document.querySelector(`[data-onboarding-id="${d.attribute}"]`);if(r){let f=r.getBoundingClientRect(),w=c.style?.padding||0,E={top:f.top-w,bottom:f.bottom+w,left:f.left-w,right:f.right+w,width:f.width+w*2,height:f.height+w*2},e={top:E.top+window.scrollY,left:E.left+window.scrollX,width:E.width,height:E.height},t=j(E);g(n=>n&&n.top===e.top&&n.left===e.left&&n.width===e.width&&n.height===e.height?n:e),Y(n=>n.top===t.top&&n.left===t.left?n:t)}else g(null)},[d,j,c.style]);if(Z(()=>{O(),window.addEventListener("resize",O),window.addEventListener("scroll",O);let r=new MutationObserver(O);r.observe(document.body,{childList:!0,subtree:!0,attributes:!0});let f=null;if(typeof ResizeObserver<"u"){f=new ResizeObserver(O),f.observe(document.body);let w=d?.attribute?document.querySelector(`[data-onboarding-id="${d.attribute}"]`):null;w&&f.observe(w)}return()=>{window.removeEventListener("resize",O),window.removeEventListener("scroll",O),window.removeEventListener("pointermove",I),window.removeEventListener("pointerup",x),r.disconnect(),f&&f.disconnect()}},[O,d?.attribute,I,x]),!d||!p)return null;let D={...c.style?.background,transition:"all 0.3s cubic-bezier(0.25, 0.1, 0.25, 1)"},m=r=>{r.stopPropagation()},_=A("div",{className:"onboard-overlay-container",children:[h("div",{style:{height:p.top,...D},className:"onboard-overlay-mask onboard-mask-top",onPointerDown:m,onMouseDown:m,onClick:m}),h("div",{style:{top:p.top+p.height,height:`calc(100vh - ${p.top+p.height}px)`,...D},className:"onboard-overlay-mask onboard-mask-bottom",onPointerDown:m,onMouseDown:m,onClick:m}),h("div",{style:{top:p.top,height:p.height,width:p.left,...D},className:"onboard-overlay-mask onboard-mask-left",onPointerDown:m,onMouseDown:m,onClick:m}),h("div",{style:{top:p.top,height:p.height,left:p.left+p.width,width:`calc(100% - ${p.left+p.width}px)`,...D},className:"onboard-overlay-mask",onPointerDown:m,onMouseDown:m,onClick:m}),A("div",{ref:v,className:"onboard-tooltip",onPointerDown:P,style:{zIndex:1e6,...c.style?.container,top:J.top+R.y,left:J.left+R.x,transition:"top 0.3s cubic-bezier(0.25, 0.1, 0.25, 1), left 0.3s cubic-bezier(0.25, 0.1, 0.25, 1)",cursor:c.metadata.draggable?"grab":"auto",touchAction:"none"},onMouseDown:m,onClick:m,children:[A("div",{className:"onboard-tooltip-header",children:[h("h3",{className:"onboard-tooltip-title",children:d.title}),h("button",{onClick:r=>{r.stopPropagation(),C()},className:"onboard-close-button",children:h(ct,{})})]}),h("p",{className:"onboard-tooltip-description",children:d.description}),A("div",{className:"onboard-tooltip-footer",children:[A("button",{onClick:r=>{r.stopPropagation(),X()},disabled:L,className:"onboard-button-ghost",style:{background:"none",border:"none",cursor:L?"not-allowed":"pointer",...c.style?.prev},children:[h(at,{}),"Prev"]}),u?h("button",{onClick:r=>{r.stopPropagation(),T()},className:"onboard-button-primary",style:{border:"none",cursor:"pointer",...c.style?.finish},children:"Finish"}):A("button",{onClick:r=>{r.stopPropagation(),T()},className:"onboard-button-primary",style:{border:"none",cursor:"pointer",...L?c.style?.start:{},...L?{}:c.style?.next},children:[L&&c.style?.start?"Start":"Next",!(L&&c.style?.start)&&h(ut,{})]})]})]})]});return typeof document<"u"?st(_,document.body):null};import{Fragment as bt,jsx as ot,jsxs as gt}from"react/jsx-runtime";var rt=lt(void 0),F="onboarding_state",pt=()=>{if(typeof window<"u"){let c=B.get(F);if(c)try{let d=JSON.parse(c);if(d&&typeof d=="object")return{currentStepIndex:d.currentStepIndex??0,currentSubStepIndex:d.currentSubStepIndex??null,isActive:d.isActive??!0,completedSteps:d.completedSteps??[],subStepProgress:d.subStepProgress??{}}}catch{}}return{currentStepIndex:0,currentSubStepIndex:null,isActive:!0,completedSteps:[],subStepProgress:{}}},Ct=({config:c,ssr:d=!1,onNavigate:T,children:X})=>{let[C,L]=K(!d),[u,p]=K(pt),[g,J]=K(typeof window<"u"?window.location.pathname:""),[Y,R]=K(!1),y=$(c),z=$(T),M=$(u),v=$(""),N=$(typeof window<"u"?window.location.pathname:""),I=$(!1);H(()=>{M.current=u},[u]),H(()=>{y.current=c,z.current=T},[c,T]),H(()=>{g!==N.current&&(N.current=g,v.current="")},[g]),H(()=>{if(typeof window>"u")return;let e=()=>{let i=window.location.pathname;J(i)};window.addEventListener("popstate",e);let t=window.history.pushState,n=window.history.replaceState;window.history.pushState=function(...i){t.apply(this,i),e()},window.history.replaceState=function(...i){n.apply(this,i),e()},window.addEventListener("locationchange",e);let s=setInterval(e,200);return()=>{window.removeEventListener("popstate",e),window.history.pushState=t,window.history.replaceState=n,window.removeEventListener("locationchange",e),clearInterval(s)}},[]);let x=W(e=>{if(e)if(z.current)z.current(e);else try{window.location.href=e}catch{}},[]),P=W((e,t)=>{if(!e?.urlMatch||!t)return!1;let n=a=>a.endsWith("/")&&a!=="/"?a.slice(0,-1):a,s=n(t),i=n(e.urlMatch),o=!1;if(i.includes("*")){let a=i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/\\\*/g,".*");o=new RegExp(`^${a}$`).test(s)}else o=s===i;return o},[]),j=W((e,t)=>{let n=y.current,s=[],i=window.location.pathname,o=(l,S=-1)=>{if(S!==null&&(l.click&&s.push(l.attribute),l.subSteps)){let b=S===-1?l.subSteps.length:S;for(let k=0;k<b;k++)l.subSteps[k].click&&s.push(l.subSteps[k].attribute)}};for(let l=0;l<=e;l++){let S=n.steps[l];P(S,i)&&(l<e?o(S):t!==null&&o(S,t))}if(s.length===0)return;let a=l=>{if(l>=s.length)return;let S=s[l],b=document.querySelector(`[data-onboarding-id="${S}"]`);b&&b.click(),setTimeout(()=>a(l+1),500)};setTimeout(()=>a(0),500)},[P]);H(()=>{if(d&&!C){L(!0);return}let e=y.current,t=M.current,n=e.metadata.inOrder!==!1;if(!t.isActive)return;let s=null,i;if(n){let o=e.steps.findIndex((a,l)=>!t.completedSteps.includes(l));if(o!==-1){o!==t.currentStepIndex&&(s={...t,currentStepIndex:o,currentSubStepIndex:t.subStepProgress[o]??null});let a=e.steps[o];P(a,g)||a.urlBase&&g!==a.urlBase&&(i=a.urlBase)}}else{let o=e.steps.findIndex((a,l)=>P(a,g)&&!t.completedSteps.includes(l));o!==-1&&o!==t.currentStepIndex&&(s={...t,currentStepIndex:o,currentSubStepIndex:t.subStepProgress[o]??null})}s&&p(s),i&&x(i)},[d,C,g,x,P,u.isActive,u.currentStepIndex,u.completedSteps,u.subStepProgress]),H(()=>{if(!u.isActive||!C)return;let e=y.current,t=e.steps[u.currentStepIndex],n=`${g}-${u.currentStepIndex}-${u.currentSubStepIndex}`;if(v.current===n)return;let s=I.current;if(I.current=!1,s&&g===N.current){v.current=n;return}t&&P(t,g)&&e.metadata.simulateClicksOnNavigate&&v.current!==n&&(v.current=n,N.current=g,j(u.currentStepIndex,u.currentSubStepIndex))},[u.currentStepIndex,u.currentSubStepIndex,u.isActive,g,C,P,j]),H(()=>{C&&B.set(F,JSON.stringify(u),{expires:365})},[u,C]);let O=nt(()=>{let e=c.steps[u.currentStepIndex];if(!e)return null;let t=P(e,g);if(u.currentSubStepIndex!==null&&e.subSteps){let n=e.subSteps[u.currentSubStepIndex];return t||Y?n||e:null}return t?e:null},[c.steps,u.currentStepIndex,u.currentSubStepIndex,g,P,Y]),D=u.currentStepIndex===0&&u.currentSubStepIndex===null,m=nt(()=>{let e=c.steps.length,t=c.steps[u.currentStepIndex],n=t?.subSteps&&t.subSteps.length>0;return u.currentStepIndex===e-1?n?u.currentSubStepIndex===t.subSteps.length-1:!0:!1},[c.steps,u.currentStepIndex,u.currentSubStepIndex]),_=W(()=>{let e=y.current,t=M.current;I.current=!0;let{currentStepIndex:n,currentSubStepIndex:s,completedSteps:i}=t,o=e.steps[n];if(!o)return;let a=s!==null&&o.subSteps?o.subSteps[s]:o;if(a.click){let b=document.querySelector(`[data-onboarding-id="${a.attribute}"]`);b&&b.click()}let l,S;if(o.subSteps&&(s===null||s<o.subSteps.length-1)){let b=s===null?0:s+1,k=o.subSteps[b];R(!0),setTimeout(()=>R(!1),1e3),S=a.navigate||k.navigate,!S&&s===null&&(S=o.navigate),l={...t,currentSubStepIndex:b,subStepProgress:{...t.subStepProgress,[n]:b}}}else{let b=n;if(n<e.steps.length-1){let k=n+1,G=e.steps[k],Q=t.subStepProgress[k]??null,it=Q!==null&&G.subSteps?G.subSteps[Q]:null;S=a.navigate||G.navigate||it?.navigate,l={...t,currentStepIndex:k,currentSubStepIndex:Q,completedSteps:i.includes(b)?i:[...i,b],subStepProgress:{...t.subStepProgress,[b]:s}}}else e.onOnboardingComplete&&e.onOnboardingComplete(),S=a.navigate||o.navigate,l={...t,isActive:!1,completedSteps:i.includes(b)?i:[...i,b],subStepProgress:{...t.subStepProgress,[b]:s}}}B.set(F,JSON.stringify(l),{expires:365}),S&&x(S),p(l)},[x]),r=W(()=>{let e=y.current,t=M.current;I.current=!0;let n=null,s;if(t.currentSubStepIndex!==null&&t.currentSubStepIndex>0){let i=t.currentSubStepIndex-1;s=e.steps[t.currentStepIndex].subSteps[i].navigate,n={...t,currentSubStepIndex:i,subStepProgress:{...t.subStepProgress,[t.currentStepIndex]:i}}}else if(t.currentStepIndex>0&&t.currentSubStepIndex===0)s=e.steps[t.currentStepIndex].navigate,n={...t,currentSubStepIndex:null,subStepProgress:{...t.subStepProgress,[t.currentStepIndex]:null}};else if(t.currentStepIndex>0){let i=t.currentStepIndex-1,o=e.steps[i],a=t.subStepProgress[i]??(o.subSteps?o.subSteps.length-1:null),l=a!==null&&o.subSteps?o.subSteps[a]:null;s=o.navigate||l?.navigate,n={...t,currentStepIndex:i,currentSubStepIndex:a,isActive:!0,subStepProgress:{...t.subStepProgress,[i]:a}}}n&&(B.set(F,JSON.stringify(n),{expires:365}),s&&x(s),p(n))},[x]),f=W(()=>{p(e=>({...e,isActive:!1})),y.current.onOnboardingComplete&&y.current.onOnboardingComplete()},[]),w=W((e,t=null)=>{let n=y.current,s=M.current;I.current=!0;let i=n.steps[e];if(!i)return;let o=t!==null&&i.subSteps?i.subSteps[t]:null,a=i.navigate||o?.navigate,l={...s,currentStepIndex:e,currentSubStepIndex:t,isActive:!0,subStepProgress:{...s.subStepProgress,[e]:t}};B.set(F,JSON.stringify(l),{expires:365}),a&&x(a),p(l)},[x]),E={config:c,state:u,nextStep:_,prevStep:r,finish:f,goToStep:w,currentStep:O,isFirstStep:D,isLastStep:m};return C?gt(rt.Provider,{value:E,children:[X,u.isActive&&ot(tt,{})]}):ot(bt,{children:X})},et=()=>{let c=dt(rt);if(c===void 0)throw new Error("useOnboarding must be used within an OnboardingProvider");return c};export{Ct as OnboardingProvider,et as useOnboarding};
3
3
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/OnboardingProvider.tsx","../src/components/OnboardingOverlay.tsx"],"sourcesContent":["'use client';\n\nimport React, {\n createContext,\n useContext,\n useEffect,\n useState,\n useCallback,\n useMemo,\n useRef,\n} from 'react';\nimport Cookies from 'js-cookie';\nimport { OnboardingConfig, OnboardingState, OnboardingStep, OnboardingSubStep } from '../types';\nimport { OnboardingOverlay } from './OnboardingOverlay';\n\ninterface OnboardingContextType {\n config: OnboardingConfig;\n state: OnboardingState;\n nextStep: () => void;\n prevStep: () => void;\n finish: () => void;\n goToStep: (stepIndex: number, subStepIndex?: number | null) => void;\n currentStep: OnboardingStep | OnboardingSubStep | null;\n isFirstStep: boolean;\n isLastStep: boolean;\n}\n\nconst OnboardingContext = createContext<OnboardingContextType | undefined>(undefined);\n\nconst COOKIE_NAME = 'onboarding_state';\n\nconst getInitialState = (): OnboardingState => {\n if (typeof window !== 'undefined') {\n const saved = Cookies.get(COOKIE_NAME);\n if (saved) {\n try {\n const parsed = JSON.parse(saved);\n if (parsed && typeof parsed === 'object') {\n return {\n currentStepIndex: parsed.currentStepIndex ?? 0,\n currentSubStepIndex: parsed.currentSubStepIndex ?? null,\n isActive: parsed.isActive ?? true,\n completedSteps: parsed.completedSteps ?? [],\n subStepProgress: parsed.subStepProgress ?? {},\n };\n }\n } catch {\n // Ignore\n }\n }\n }\n return {\n currentStepIndex: 0,\n currentSubStepIndex: null,\n isActive: true,\n completedSteps: [],\n subStepProgress: {},\n };\n};\n\nexport const OnboardingProvider: React.FC<{\n config: OnboardingConfig;\n ssr?: boolean;\n onNavigate?: (url: string) => void;\n children: React.ReactNode;\n}> = ({ config, ssr = false, onNavigate, children }) => {\n const [isMounted, setIsMounted] = useState(false);\n const [state, setState] = useState<OnboardingState>({\n currentStepIndex: 0,\n currentSubStepIndex: null,\n isActive: false,\n completedSteps: [],\n subStepProgress: {},\n });\n const [currentPath, setCurrentPath] = useState('');\n const [isTransitioning, setIsTransitioning] = useState(false);\n\n const configRef = useRef(config);\n const onNavigateRef = useRef(onNavigate);\n const lastSimulatedKey = useRef<string>('');\n const lastPathForSimulation = useRef<string>('');\n const wasInternalAction = useRef(false);\n\n useEffect(() => {\n setIsMounted(true);\n const initialState = getInitialState();\n setState(initialState);\n setCurrentPath(window.location.pathname);\n lastPathForSimulation.current = window.location.pathname;\n }, []);\n\n useEffect(() => {\n if (isMounted && currentPath !== lastPathForSimulation.current) {\n lastPathForSimulation.current = currentPath;\n lastSimulatedKey.current = '';\n }\n }, [currentPath, isMounted]);\n\n useEffect(() => {\n configRef.current = config;\n onNavigateRef.current = onNavigate;\n }, [config, onNavigate]);\n\n useEffect(() => {\n if (!isMounted) return;\n\n const handlePathChange = () => {\n const newPath = window.location.pathname;\n setCurrentPath(newPath);\n };\n\n window.addEventListener('popstate', handlePathChange);\n\n const originalPushState = window.history.pushState;\n const originalReplaceState = window.history.replaceState;\n\n window.history.pushState = function (...args) {\n originalPushState.apply(this, args);\n handlePathChange();\n };\n\n window.history.replaceState = function (...args) {\n originalReplaceState.apply(this, args);\n handlePathChange();\n };\n\n const interval = setInterval(handlePathChange, 200);\n\n return () => {\n window.removeEventListener('popstate', handlePathChange);\n window.history.pushState = originalPushState;\n window.history.replaceState = originalReplaceState;\n clearInterval(interval);\n };\n }, [isMounted]);\n\n const handleNavigation = useCallback((link?: string) => {\n if (!link) return;\n if (onNavigateRef.current) {\n onNavigateRef.current(link);\n } else {\n window.location.href = link;\n }\n }, []);\n\n const isMatch = useCallback((step: OnboardingStep, path: string) => {\n if (!step?.urlMatch || !path) return false;\n\n let match = false;\n if (step.urlMatch.includes('*')) {\n const pattern = step.urlMatch\n .replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&') // Escape special regex chars\n .replace(/\\\\\\*/g, '.*'); // Convert escaped * back to .*\n match = new RegExp(`^${pattern}$`).test(path);\n } else {\n match = path === step.urlMatch;\n }\n return match;\n }, []);\n\n const simulateClicks = useCallback(\n (stepIndex: number, subStepIndex: number | null) => {\n const currentConfig = configRef.current;\n const actions: string[] = [];\n const path = window.location.pathname;\n const collectStepClicks = (step: OnboardingStep, upToSubStep: number | null = -1) => {\n if (upToSubStep === null) {\n // We are arriving at the main step itself. No sub-steps. \n // In this case, we don't click the step's attribute because arriving there \n // should show it. Re-clicking might close it if it's a toggle.\n return;\n }\n\n if (step.click) actions.push(step.attribute);\n if (step.subSteps) {\n const limit = upToSubStep === -1 ? step.subSteps.length : upToSubStep;\n for (let i = 0; i < limit; i++) {\n if (step.subSteps[i].click) actions.push(step.subSteps[i].attribute);\n }\n }\n };\n\n for (let i = 0; i <= stepIndex; i++) {\n const step = currentConfig.steps[i];\n if (isMatch(step, path)) {\n if (i < stepIndex) collectStepClicks(step);\n else if (subStepIndex !== null) {\n // We are arriving at a sub-step. Replay clicks leading to it.\n collectStepClicks(step, subStepIndex);\n }\n }\n }\n\n if (actions.length === 0) return;\n\n const performClick = (index: number) => {\n if (index >= actions.length) return;\n const attr = actions[index];\n const element = document.querySelector(`[data-onboarding-id=\"${attr}\"]`) as HTMLElement;\n if (element) element.click();\n setTimeout(() => performClick(index + 1), 500);\n };\n\n setTimeout(() => performClick(0), 500);\n },\n [isMatch, currentPath],\n );\n\n // Reconcile state with path\n useEffect(() => {\n if (ssr && !isMounted) {\n setIsMounted(true);\n return;\n }\n\n const currentConfig = configRef.current;\n const isInOrder = (currentConfig.metadata.inOrder as boolean | undefined) !== false;\n\n // Use functional update to avoid depending on 'state'\n setState((prev) => {\n if (!prev.isActive) return prev;\n\n const nextState = { ...prev };\n let changed = false;\n\n if (!isInOrder) {\n const matchedIndex = currentConfig.steps.findIndex(\n (step, index) => isMatch(step, currentPath) && !prev.completedSteps.includes(index),\n );\n\n if (matchedIndex !== -1 && matchedIndex !== prev.currentStepIndex) {\n nextState.currentStepIndex = matchedIndex;\n nextState.currentSubStepIndex = prev.subStepProgress[matchedIndex] ?? null;\n changed = true;\n }\n } else {\n const firstUnfinishedIndex = currentConfig.steps.findIndex(\n (_, i) => !prev.completedSteps.includes(i),\n );\n\n if (firstUnfinishedIndex !== -1) {\n if (firstUnfinishedIndex !== prev.currentStepIndex) {\n nextState.currentStepIndex = firstUnfinishedIndex;\n nextState.currentSubStepIndex = prev.subStepProgress[firstUnfinishedIndex] ?? null;\n changed = true;\n }\n\n const step = currentConfig.steps[firstUnfinishedIndex];\n if (!isMatch(step, currentPath)) {\n if (step.urlBase && currentPath !== step.urlBase) {\n handleNavigation(step.urlBase);\n }\n }\n }\n }\n\n return changed ? nextState : prev;\n });\n }, [ssr, isMounted, currentPath, handleNavigation, isMatch]);\n\n // Handle click simulation separately\n useEffect(() => {\n if (!state.isActive || !isMounted) return;\n const currentConfig = configRef.current;\n const step = currentConfig.steps[state.currentStepIndex];\n\n const simKey = `${currentPath}-${state.currentStepIndex}-${state.currentSubStepIndex}`;\n\n // Skip if we already simulated this exact state\n if (lastSimulatedKey.current === simKey) {\n return;\n }\n\n const internal = wasInternalAction.current;\n wasInternalAction.current = false;\n\n // Skip if path is same and it was an internal action (Next/Prev/GoTo)\n // because manual progression handles its own clicks.\n if (internal && currentPath === lastPathForSimulation.current) {\n lastSimulatedKey.current = simKey;\n return;\n }\n\n if (step && isMatch(step, currentPath) && currentConfig.metadata.simulateClicksOnNavigate) {\n if (lastSimulatedKey.current !== simKey) {\n lastSimulatedKey.current = simKey;\n lastPathForSimulation.current = currentPath;\n simulateClicks(state.currentStepIndex, state.currentSubStepIndex);\n }\n }\n }, [\n state.currentStepIndex,\n state.currentSubStepIndex,\n state.isActive,\n currentPath,\n isMounted,\n isMatch,\n simulateClicks,\n ]);\n\n // Persist state to cookies\n useEffect(() => {\n if (isMounted) {\n Cookies.set(COOKIE_NAME, JSON.stringify(state), { expires: 365 });\n }\n }, [state, isMounted]);\n\n const currentStep = useMemo(() => {\n const step = config.steps[state.currentStepIndex];\n if (!step) return null;\n\n const isUrlMatch = isMatch(step, currentPath);\n\n if (state.currentSubStepIndex !== null && step.subSteps) {\n const subStep = step.subSteps[state.currentSubStepIndex];\n if (isUrlMatch || isTransitioning) {\n return subStep || step;\n }\n return null;\n }\n\n if (!isUrlMatch) return null;\n\n return step;\n }, [\n config.steps,\n state.currentStepIndex,\n state.currentSubStepIndex,\n currentPath,\n isMatch,\n isTransitioning,\n ]);\n\n const isFirstStep = state.currentStepIndex === 0 && state.currentSubStepIndex === null;\n const isLastStep = useMemo(() => {\n const totalSteps = config.steps.length;\n const step = config.steps[state.currentStepIndex];\n const hasSubSteps = step?.subSteps && step.subSteps.length > 0;\n\n if (state.currentStepIndex === totalSteps - 1) {\n if (hasSubSteps) return state.currentSubStepIndex === step.subSteps!.length - 1;\n return true;\n }\n return false;\n }, [config.steps, state.currentStepIndex, state.currentSubStepIndex]);\n\n const nextStep = useCallback(() => {\n const currentConfig = configRef.current;\n wasInternalAction.current = true;\n\n setState((prev) => {\n const { currentStepIndex, currentSubStepIndex, completedSteps } = prev;\n const stepObj = currentConfig.steps[currentStepIndex];\n if (!stepObj) return prev;\n\n const currentActiveStep =\n currentSubStepIndex !== null && stepObj.subSteps\n ? stepObj.subSteps[currentSubStepIndex]\n : stepObj;\n\n if (currentActiveStep.click) {\n const element = document.querySelector(\n `[data-onboarding-id=\"${currentActiveStep.attribute}\"]`,\n ) as HTMLElement;\n if (element) element.click();\n }\n\n let nextState: OnboardingState;\n let navTo: string | undefined;\n\n if (\n stepObj.subSteps &&\n (currentSubStepIndex === null || currentSubStepIndex < stepObj.subSteps.length - 1)\n ) {\n const nextSubIndex = currentSubStepIndex === null ? 0 : currentSubStepIndex + 1;\n const nextSubStep = stepObj.subSteps[nextSubIndex];\n\n setIsTransitioning(true);\n setTimeout(() => setIsTransitioning(false), 1000);\n\n navTo = currentActiveStep.navigate || nextSubStep.navigate;\n if (!navTo && currentSubStepIndex === null) navTo = stepObj.navigate;\n\n nextState = {\n ...prev,\n currentSubStepIndex: nextSubIndex,\n subStepProgress: {\n ...prev.subStepProgress,\n [currentStepIndex]: nextSubIndex,\n },\n };\n } else {\n const stepIndexToComplete = currentStepIndex;\n if (currentStepIndex < currentConfig.steps.length - 1) {\n const nextIndex = currentStepIndex + 1;\n const nextStepObj = currentConfig.steps[nextIndex];\n const targetSubStepIndex = prev.subStepProgress[nextIndex] ?? null;\n const targetSubStep =\n targetSubStepIndex !== null && nextStepObj.subSteps\n ? nextStepObj.subSteps[targetSubStepIndex]\n : null;\n\n navTo = currentActiveStep.navigate || nextStepObj.navigate || targetSubStep?.navigate;\n\n nextState = {\n ...prev,\n currentStepIndex: nextIndex,\n currentSubStepIndex: targetSubStepIndex,\n completedSteps: completedSteps.includes(stepIndexToComplete)\n ? completedSteps\n : [...completedSteps, stepIndexToComplete],\n subStepProgress: {\n ...prev.subStepProgress,\n [stepIndexToComplete]: currentSubStepIndex,\n },\n };\n } else {\n if (currentConfig.onOnboardingComplete) currentConfig.onOnboardingComplete();\n\n navTo = currentActiveStep.navigate || stepObj.navigate;\n\n nextState = {\n ...prev,\n isActive: false,\n completedSteps: completedSteps.includes(stepIndexToComplete)\n ? completedSteps\n : [...completedSteps, stepIndexToComplete],\n subStepProgress: {\n ...prev.subStepProgress,\n [stepIndexToComplete]: currentSubStepIndex,\n },\n };\n }\n }\n\n Cookies.set(COOKIE_NAME, JSON.stringify(nextState), { expires: 365 });\n if (navTo) handleNavigation(navTo);\n return nextState;\n });\n }, [handleNavigation]);\n\n const prevStep = useCallback(() => {\n const currentConfig = configRef.current;\n wasInternalAction.current = true;\n setState((prev) => {\n let nextState: OnboardingState;\n let navTo: string | undefined;\n\n if (prev.currentSubStepIndex !== null && prev.currentSubStepIndex > 0) {\n const nextSubIndex = prev.currentSubStepIndex - 1;\n const nextSubStep = currentConfig.steps[prev.currentStepIndex].subSteps![nextSubIndex];\n navTo = nextSubStep.navigate;\n\n nextState = {\n ...prev,\n currentSubStepIndex: nextSubIndex,\n subStepProgress: {\n ...prev.subStepProgress,\n [prev.currentStepIndex]: nextSubIndex,\n },\n };\n } else if (prev.currentStepIndex > 0 && prev.currentSubStepIndex === 0) {\n const stepObj = currentConfig.steps[prev.currentStepIndex];\n navTo = stepObj.navigate;\n\n nextState = {\n ...prev,\n currentSubStepIndex: null,\n subStepProgress: {\n ...prev.subStepProgress,\n [prev.currentStepIndex]: null,\n },\n };\n } else if (prev.currentStepIndex > 0) {\n const prevIndex = prev.currentStepIndex - 1;\n const prevStepObj = currentConfig.steps[prevIndex];\n const prevSubStepIndex =\n prev.subStepProgress[prevIndex] ??\n (prevStepObj.subSteps ? prevStepObj.subSteps.length - 1 : null);\n const prevSubStep =\n prevSubStepIndex !== null && prevStepObj.subSteps\n ? prevStepObj.subSteps[prevSubStepIndex]\n : null;\n\n navTo = prevStepObj.navigate || prevSubStep?.navigate;\n\n nextState = {\n ...prev,\n currentStepIndex: prevIndex,\n currentSubStepIndex: prevSubStepIndex,\n isActive: true,\n subStepProgress: {\n ...prev.subStepProgress,\n [prevIndex]: prevSubStepIndex,\n },\n };\n } else {\n return prev;\n }\n\n Cookies.set(COOKIE_NAME, JSON.stringify(nextState), { expires: 365 });\n if (navTo) handleNavigation(navTo);\n return nextState;\n });\n }, [handleNavigation]);\n\n const finish = useCallback(() => {\n setState((prev) => ({ ...prev, isActive: false }));\n if (configRef.current.onOnboardingComplete) configRef.current.onOnboardingComplete();\n }, []);\n\n const goToStep = useCallback(\n (stepIndex: number, subStepIndex: number | null = null) => {\n const currentConfig = configRef.current;\n wasInternalAction.current = true;\n setState((prev) => {\n const nextStepObj = currentConfig.steps[stepIndex];\n const targetSubStep =\n subStepIndex !== null && nextStepObj.subSteps\n ? nextStepObj.subSteps[subStepIndex]\n : null;\n\n const navTo = nextStepObj.navigate || targetSubStep?.navigate;\n\n const nextState = {\n ...prev,\n currentStepIndex: stepIndex,\n currentSubStepIndex: subStepIndex,\n isActive: true,\n subStepProgress: {\n ...prev.subStepProgress,\n [stepIndex]: subStepIndex,\n },\n };\n\n Cookies.set(COOKIE_NAME, JSON.stringify(nextState), { expires: 365 });\n if (navTo) handleNavigation(navTo);\n return nextState;\n });\n },\n [handleNavigation],\n );\n\n const value = {\n config,\n state,\n nextStep,\n prevStep,\n finish,\n goToStep,\n currentStep,\n isFirstStep,\n isLastStep,\n };\n\n return (\n <OnboardingContext value={value}>\n {children}\n {isMounted && state.isActive && <OnboardingOverlay />}\n </OnboardingContext>\n );\n};\n\nexport const useOnboarding = () => {\n const context = useContext(OnboardingContext);\n if (context === undefined)\n throw new Error('useOnboarding must be used within an OnboardingProvider');\n return context;\n};\n","'use client';\n\nimport React, { useState, useEffect, useCallback, useRef } from 'react';\nimport { createPortal } from 'react-dom';\nimport { useOnboarding } from './OnboardingProvider';\n\nconst ChevronLeftIcon = () => (\n <svg\n width=\"16\"\n height=\"16\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d=\"M15 18l-6-6 6-6\" />\n </svg>\n);\n\nconst ChevronRightIcon = () => (\n <svg\n width=\"16\"\n height=\"16\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d=\"M9 18l6-6-6-6\" />\n </svg>\n);\n\nconst XIcon = () => (\n <svg\n width=\"18\"\n height=\"18\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <line x1=\"18\" y1=\"6\" x2=\"6\" y2=\"18\" />\n <line x1=\"6\" y1=\"6\" x2=\"18\" y2=\"18\" />\n </svg>\n);\n\nexport const OnboardingOverlay: React.FC = () => {\n const { config, currentStep, nextStep, prevStep, finish, isFirstStep, isLastStep } =\n useOnboarding();\n const [coords, setCoords] = useState<{\n top: number;\n left: number;\n width: number;\n height: number;\n } | null>(null);\n const [position, setPosition] = useState<{ top: number; left: number }>({ top: 0, left: 0 });\n const [dragOffset, setDragOffset] = useState<{ x: number; y: number }>({ x: 0, y: 0 });\n const isDragging = useRef(false);\n const dragStart = useRef<{ x: number; y: number }>({ x: 0, y: 0 });\n const tooltipRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n // eslint-disable-next-line react-hooks/set-state-in-effect\n setDragOffset({ x: 0, y: 0 });\n }, [currentStep]);\n\n const handlePointerUpRef = useRef<() => void>(() => {});\n\n const handlePointerMove = useCallback((e: PointerEvent) => {\n if (!isDragging.current) return;\n\n const newX = e.clientX - dragStart.current.x;\n const newY = e.clientY - dragStart.current.y;\n\n setDragOffset({ x: newX, y: newY });\n }, []);\n\n const handlePointerUp = useCallback(() => {\n isDragging.current = false;\n\n if (tooltipRef.current) {\n tooltipRef.current.style.transition =\n 'top 0.3s cubic-bezier(0.25, 0.1, 0.25, 1), left 0.3s cubic-bezier(0.25, 0.1, 0.25, 1)';\n tooltipRef.current.style.cursor = config.metadata.draggable ? 'grab' : 'auto';\n }\n\n window.removeEventListener('pointermove', handlePointerMove);\n window.removeEventListener('pointerup', handlePointerUpRef.current);\n }, [config.metadata.draggable, handlePointerMove]);\n\n useEffect(() => {\n handlePointerUpRef.current = handlePointerUp;\n }, [handlePointerUp]);\n\n const handlePointerDown = (e: React.PointerEvent) => {\n if (!config.metadata.draggable) return;\n e.stopPropagation();\n e.preventDefault();\n isDragging.current = true;\n dragStart.current = { x: e.clientX - dragOffset.x, y: e.clientY - dragOffset.y };\n\n if (tooltipRef.current) {\n tooltipRef.current.style.transition = 'none';\n tooltipRef.current.style.cursor = 'grabbing';\n }\n\n window.addEventListener('pointermove', handlePointerMove);\n window.addEventListener('pointerup', handlePointerUp);\n };\n\n const calculateBestPosition = useCallback(\n (rect: {\n top: number;\n bottom: number;\n left: number;\n right: number;\n width: number;\n height: number;\n }) => {\n const tooltipWidth = 300;\n const tooltipHeight = 200;\n const gap = 12;\n const padding = 20;\n\n const spaceAbove = rect.top;\n const spaceBelow = window.innerHeight - rect.bottom;\n const spaceLeft = rect.left;\n const spaceRight = window.innerWidth - rect.right;\n\n let top = 0;\n let left = 0;\n\n if (spaceBelow > tooltipHeight + gap + padding) {\n top = rect.bottom + gap;\n left = Math.max(\n padding,\n Math.min(\n window.innerWidth - tooltipWidth - padding,\n rect.left + rect.width / 2 - tooltipWidth / 2,\n ),\n );\n } else if (spaceAbove > tooltipHeight + gap + padding) {\n top = rect.top - tooltipHeight - gap;\n left = Math.max(\n padding,\n Math.min(\n window.innerWidth - tooltipWidth - padding,\n rect.left + rect.width / 2 - tooltipWidth / 2,\n ),\n );\n } else if (spaceRight > tooltipWidth + gap + padding) {\n top = Math.max(\n padding,\n Math.min(\n window.innerHeight - tooltipHeight - padding,\n rect.top + rect.height / 2 - tooltipHeight / 2,\n ),\n );\n left = rect.right + gap;\n } else if (spaceLeft > tooltipWidth + gap + padding) {\n top = Math.max(\n padding,\n Math.min(\n window.innerHeight - tooltipHeight - padding,\n rect.top + rect.height / 2 - tooltipHeight / 2,\n ),\n );\n left = rect.left - tooltipWidth - gap;\n } else {\n top = window.innerHeight / 2 - tooltipHeight / 2;\n left = window.innerWidth / 2 - tooltipWidth / 2;\n }\n\n return { top: top + window.scrollY, left: left + window.scrollX };\n },\n [],\n );\n\n const updateCoords = useCallback(() => {\n if (!currentStep) {\n return;\n }\n\n const element = document.querySelector(\n `[data-onboarding-id=\"${currentStep.attribute}\"]`,\n ) as HTMLElement;\n\n if (element) {\n const rect = element.getBoundingClientRect();\n const padding = config.style?.padding || 0;\n const paddedRect = {\n top: rect.top - padding,\n bottom: rect.bottom + padding,\n left: rect.left - padding,\n right: rect.right + padding,\n width: rect.width + padding * 2,\n height: rect.height + padding * 2,\n };\n\n const newCoords = {\n top: paddedRect.top + window.scrollY,\n left: paddedRect.left + window.scrollX,\n width: paddedRect.width,\n height: paddedRect.height,\n };\n\n const newPosition = calculateBestPosition(paddedRect);\n\n setCoords((prev) => {\n if (\n prev &&\n Math.abs(prev.top - newCoords.top) < 0.5 &&\n Math.abs(prev.left - newCoords.left) < 0.5 &&\n Math.abs(prev.width - newCoords.width) < 0.5 &&\n Math.abs(prev.height - newCoords.height) < 0.5\n ) {\n return prev;\n }\n return newCoords;\n });\n\n setPosition((prev) => {\n if (Math.abs(prev.top - newPosition.top) < 0.5 && Math.abs(prev.left - newPosition.left) < 0.5) {\n return prev;\n }\n return newPosition;\n });\n } else {\n setCoords(null);\n }\n }, [currentStep, calculateBestPosition, config.style]);\n\n useEffect(() => {\n let timeoutId: ReturnType<typeof setTimeout>;\n const debouncedUpdate = () => {\n clearTimeout(timeoutId);\n timeoutId = setTimeout(updateCoords, 16); // ~60fps debounce\n };\n\n debouncedUpdate();\n window.addEventListener('resize', debouncedUpdate);\n window.addEventListener('scroll', debouncedUpdate);\n\n const observer = new MutationObserver((mutations) => {\n // Only trigger if relevant attributes or nodes changed\n const shouldUpdate = mutations.some(m => \n m.type === 'childList' || \n (m.type === 'attributes' && m.attributeName?.includes('data-onboarding-id'))\n );\n if (shouldUpdate) debouncedUpdate();\n });\n\n observer.observe(document.body, { \n childList: true, \n subtree: true, \n attributes: true,\n attributeFilter: ['data-onboarding-id', 'style', 'class'] \n });\n\n let resizeObserver: ResizeObserver | null = null;\n if (typeof ResizeObserver !== 'undefined') {\n resizeObserver = new ResizeObserver(debouncedUpdate);\n resizeObserver.observe(document.body);\n\n const element = currentStep?.attribute\n ? document.querySelector(`[data-onboarding-id=\"${currentStep.attribute}\"]`)\n : null;\n if (element) {\n resizeObserver.observe(element);\n }\n }\n\n return () => {\n clearTimeout(timeoutId);\n window.removeEventListener('resize', debouncedUpdate);\n window.removeEventListener('scroll', debouncedUpdate);\n window.removeEventListener('pointermove', handlePointerMove);\n window.removeEventListener('pointerup', handlePointerUp);\n observer.disconnect();\n if (resizeObserver) resizeObserver.disconnect();\n };\n }, [updateCoords, currentStep?.attribute, handlePointerMove, handlePointerUp]);\n\n if (!currentStep || !coords) {\n return null;\n }\n\n const maskStyle = {\n ...config.style?.background,\n transition: 'all 0.3s cubic-bezier(0.25, 0.1, 0.25, 1)',\n };\n\n const stopPropagation = (e: React.PointerEvent | React.MouseEvent) => {\n e.stopPropagation();\n };\n\n const overlayContent = (\n <div className=\"onboard-overlay-container\">\n <div\n style={{ height: coords.top, ...maskStyle }}\n className=\"onboard-overlay-mask onboard-mask-top\"\n onPointerDown={stopPropagation}\n onMouseDown={stopPropagation}\n onClick={stopPropagation}\n />\n <div\n style={{\n top: coords.top + coords.height,\n height: `calc(100vh - ${coords.top + coords.height}px)`,\n ...maskStyle,\n }}\n className=\"onboard-overlay-mask onboard-mask-bottom\"\n onPointerDown={stopPropagation}\n onMouseDown={stopPropagation}\n onClick={stopPropagation}\n />\n <div\n style={{ top: coords.top, height: coords.height, width: coords.left, ...maskStyle }}\n className=\"onboard-overlay-mask onboard-mask-left\"\n onPointerDown={stopPropagation}\n onMouseDown={stopPropagation}\n onClick={stopPropagation}\n />\n <div\n style={{\n top: coords.top,\n height: coords.height,\n left: coords.left + coords.width,\n width: `calc(100% - ${coords.left + coords.width}px)`,\n ...maskStyle,\n }}\n className=\"onboard-overlay-mask\"\n onPointerDown={stopPropagation}\n onMouseDown={stopPropagation}\n onClick={stopPropagation}\n />\n\n <div\n ref={tooltipRef}\n className=\"onboard-tooltip\"\n onPointerDown={handlePointerDown}\n style={{\n zIndex: 1000000,\n ...config.style?.container,\n top: position.top + dragOffset.y,\n left: position.left + dragOffset.x,\n transition:\n 'top 0.3s cubic-bezier(0.25, 0.1, 0.25, 1), left 0.3s cubic-bezier(0.25, 0.1, 0.25, 1)',\n cursor: config.metadata.draggable ? 'grab' : 'auto',\n touchAction: 'none',\n }}\n onMouseDown={stopPropagation}\n onClick={stopPropagation}\n >\n <div className=\"onboard-tooltip-header\">\n <h3 className=\"onboard-tooltip-title\">{currentStep.title}</h3>\n <button\n onClick={(e) => {\n e.stopPropagation();\n finish();\n }}\n className=\"onboard-close-button\"\n >\n <XIcon />\n </button>\n </div>\n <p className=\"onboard-tooltip-description\">{currentStep.description}</p>\n\n <div className=\"onboard-tooltip-footer\">\n <button\n onClick={(e) => {\n e.stopPropagation();\n prevStep();\n }}\n disabled={isFirstStep}\n className=\"onboard-button-ghost\"\n style={{\n background: 'none',\n border: 'none',\n cursor: isFirstStep ? 'not-allowed' : 'pointer',\n ...config.style?.prev,\n }}\n >\n <ChevronLeftIcon />\n Prev\n </button>\n\n {isLastStep ? (\n <button\n onClick={(e) => {\n e.stopPropagation();\n nextStep();\n }}\n className=\"onboard-button-primary\"\n style={{ border: 'none', cursor: 'pointer', ...config.style?.finish }}\n >\n Finish\n </button>\n ) : (\n <button\n onClick={(e) => {\n e.stopPropagation();\n nextStep();\n }}\n className=\"onboard-button-primary\"\n style={{\n border: 'none',\n cursor: 'pointer',\n ...(isFirstStep ? config.style?.start : {}),\n ...(!isFirstStep ? config.style?.next : {}),\n }}\n >\n {isFirstStep && config.style?.start ? 'Start' : 'Next'}\n {!(isFirstStep && config.style?.start) && <ChevronRightIcon />}\n </button>\n )}\n </div>\n </div>\n </div>\n );\n\n return typeof document !== 'undefined' ? createPortal(overlayContent, document.body) : null;\n};\n"],"mappings":";aAEA,OACE,iBAAAA,GACA,cAAAC,GACA,aAAAC,EACA,YAAAC,EACA,eAAAC,EACA,WAAAC,GACA,UAAAC,MACK,QACP,OAAOC,MAAa,YCTpB,OAAgB,YAAAC,EAAU,aAAAC,EAAW,eAAAC,EAAa,UAAAC,MAAc,QAChE,OAAS,gBAAAC,OAAoB,YAczB,cAAAC,EAoBF,QAAAC,MApBE,oBA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S,EAAGC,CACf,CACF,EAEA,OAAAxC,EAAQ,IAAIH,EAAa,KAAK,UAAUwD,CAAS,EAAG,CAAE,QAAS,GAAI,CAAC,EAChEqB,GAAO5C,EAAiB4C,CAAK,EAC1BrB,CACT,CAAC,CACH,EACA,CAACvB,CAAgB,CACnB,EAcA,OACEpC,GAACC,GAAA,CAAkB,MAbP,CACZ,OAAAQ,EACA,MAAAO,EACA,SAAA0D,EACA,SAAAc,EACA,OAAAK,EACA,SAAAC,EACA,YAAA5B,EACA,YAAAI,EACA,WAAAC,CACF,EAIK,UAAA3D,EACAC,GAAaG,EAAM,UAAYjB,GAACgG,EAAA,EAAkB,GACrD,CAEJ,EAEaC,GAAgB,IAAM,CACjC,IAAMC,EAAUC,GAAWjG,EAAiB,EAC5C,GAAIgG,IAAY,OACd,MAAM,IAAI,MAAM,yDAAyD,EAC3E,OAAOA,CACT","names":["createContext","useContext","useEffect","useState","useCallback","useMemo","useRef","Cookies","useState","useEffect","useCallback","useRef","createPortal","jsx","jsxs","ChevronLeftIcon","ChevronRightIcon","XIcon","OnboardingOverlay","config","currentStep","nextStep","prevStep","finish","isFirstStep","isLastStep","useOnboarding","coords","setCoords","useState","position","setPosition","dragOffset","setDragOffset","isDragging","useRef","dragStart","tooltipRef","useEffect","handlePointerUpRef","handlePointerMove","useCallback","e","newX","newY","handlePointerUp","handlePointerDown","calculateBestPosition","rect","spaceAbove","spaceBelow","spaceLeft","spaceRight","top","left","updateCoords","element","padding","paddedRect","newCoords","newPosition","prev","timeoutId","debouncedUpdate","observer","mutations","m","resizeObserver","maskStyle","stopPropagation","overlayContent","createPortal","jsx","jsxs","OnboardingContext","createContext","COOKIE_NAME","getInitialState","saved","Cookies","parsed","OnboardingProvider","config","ssr","onNavigate","children","isMounted","setIsMounted","useState","state","setState","currentPath","setCurrentPath","isTransitioning","setIsTransitioning","configRef","useRef","onNavigateRef","lastSimulatedKey","lastPathForSimulation","wasInternalAction","useEffect","initialState","handlePathChange","newPath","originalPushState","originalReplaceState","args","interval","handleNavigation","useCallback","link","isMatch","step","path","match","pattern","simulateClicks","stepIndex","subStepIndex","currentConfig","actions","collectStepClicks","upToSubStep","limit","i","performClick","index","attr","element","isInOrder","prev","nextState","changed","firstUnfinishedIndex","_","matchedIndex","simKey","internal","currentStep","useMemo","isUrlMatch","subStep","isFirstStep","isLastStep","totalSteps","hasSubSteps","nextStep","currentStepIndex","currentSubStepIndex","completedSteps","stepObj","currentActiveStep","navTo","nextSubIndex","nextSubStep","stepIndexToComplete","nextIndex","nextStepObj","targetSubStepIndex","targetSubStep","prevStep","prevIndex","prevStepObj","prevSubStepIndex","prevSubStep","finish","goToStep","OnboardingOverlay","useOnboarding","context","useContext"]}
1
+ {"version":3,"sources":["../src/components/OnboardingProvider.tsx","../src/components/OnboardingOverlay.tsx"],"sourcesContent":["'use client';\n\nimport React, {\n createContext,\n useContext,\n useEffect,\n useState,\n useCallback,\n useMemo,\n useRef,\n} from 'react';\nimport Cookies from 'js-cookie';\nimport { OnboardingConfig, OnboardingState, OnboardingStep, OnboardingSubStep } from '../types';\nimport { OnboardingOverlay } from './OnboardingOverlay';\n\ninterface OnboardingContextType {\n config: OnboardingConfig;\n state: OnboardingState;\n nextStep: () => void;\n prevStep: () => void;\n finish: () => void;\n goToStep: (stepIndex: number, subStepIndex?: number | null) => void;\n currentStep: OnboardingStep | OnboardingSubStep | null;\n isFirstStep: boolean;\n isLastStep: boolean;\n}\n\nconst OnboardingContext = createContext<OnboardingContextType | undefined>(undefined);\n\nconst COOKIE_NAME = 'onboarding_state';\n\nconst getInitialState = (): OnboardingState => {\n if (typeof window !== 'undefined') {\n const saved = Cookies.get(COOKIE_NAME);\n if (saved) {\n try {\n const parsed = JSON.parse(saved);\n if (parsed && typeof parsed === 'object') {\n return {\n currentStepIndex: parsed.currentStepIndex ?? 0,\n currentSubStepIndex: parsed.currentSubStepIndex ?? null,\n isActive: parsed.isActive ?? true,\n completedSteps: parsed.completedSteps ?? [],\n subStepProgress: parsed.subStepProgress ?? {},\n };\n }\n } catch {\n // Ignore\n }\n }\n }\n return {\n currentStepIndex: 0,\n currentSubStepIndex: null,\n isActive: true,\n completedSteps: [],\n subStepProgress: {},\n };\n};\n\nexport const OnboardingProvider: React.FC<{\n config: OnboardingConfig;\n ssr?: boolean;\n onNavigate?: (url: string) => void;\n children: React.ReactNode;\n}> = ({ config, ssr = false, onNavigate, children }) => {\n const [isMounted, setIsMounted] = useState(!ssr);\n const [state, setState] = useState<OnboardingState>(getInitialState);\n const [currentPath, setCurrentPath] = useState(\n typeof window !== 'undefined' ? window.location.pathname : '',\n );\n const [isTransitioning, setIsTransitioning] = useState(false);\n\n const configRef = useRef(config);\n const onNavigateRef = useRef(onNavigate);\n const stateRef = useRef(state);\n const lastSimulatedKey = useRef<string>('');\n const lastPathForSimulation = useRef<string>(\n typeof window !== 'undefined' ? window.location.pathname : '',\n );\n const wasInternalAction = useRef(false);\n\n useEffect(() => {\n stateRef.current = state;\n }, [state]);\n\n useEffect(() => {\n configRef.current = config;\n onNavigateRef.current = onNavigate;\n }, [config, onNavigate]);\n\n useEffect(() => {\n if (currentPath !== lastPathForSimulation.current) {\n lastPathForSimulation.current = currentPath;\n lastSimulatedKey.current = ''; // Reset simulation tracking on path change\n }\n }, [currentPath]);\n\n useEffect(() => {\n if (typeof window === 'undefined') return;\n\n const handlePathChange = () => {\n const newPath = window.location.pathname;\n setCurrentPath(newPath);\n };\n\n window.addEventListener('popstate', handlePathChange);\n\n const originalPushState = window.history.pushState;\n const originalReplaceState = window.history.replaceState;\n\n window.history.pushState = function (...args) {\n originalPushState.apply(this, args);\n handlePathChange();\n };\n\n window.history.replaceState = function (...args) {\n originalReplaceState.apply(this, args);\n handlePathChange();\n };\n\n window.addEventListener('locationchange', handlePathChange);\n const interval = setInterval(handlePathChange, 200);\n\n return () => {\n window.removeEventListener('popstate', handlePathChange);\n window.history.pushState = originalPushState;\n window.history.replaceState = originalReplaceState;\n window.removeEventListener('locationchange', handlePathChange);\n clearInterval(interval);\n };\n }, []);\n\n const handleNavigation = useCallback((link?: string) => {\n if (!link) return;\n if (onNavigateRef.current) {\n onNavigateRef.current(link);\n } else {\n try {\n window.location.href = link;\n } catch {\n // Fallback for non-browser environments or invalid URLs in tests\n }\n }\n }, []);\n\n const isMatch = useCallback((step: OnboardingStep, path: string) => {\n if (!step?.urlMatch || !path) return false;\n\n const normalize = (p: string) => (p.endsWith('/') && p !== '/' ? p.slice(0, -1) : p);\n const normalizedPath = normalize(path);\n const normalizedMatch = normalize(step.urlMatch);\n\n let match = false;\n if (normalizedMatch.includes('*')) {\n const pattern = normalizedMatch\n .replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&') // Escape special regex chars\n .replace(/\\\\\\*/g, '.*'); // Convert escaped * back to .*\n match = new RegExp(`^${pattern}$`).test(normalizedPath);\n } else {\n match = normalizedPath === normalizedMatch;\n }\n return match;\n }, []);\n\n const simulateClicks = useCallback(\n (stepIndex: number, subStepIndex: number | null) => {\n const currentConfig = configRef.current;\n const actions: string[] = [];\n const path = window.location.pathname;\n \n const collectStepClicks = (step: OnboardingStep, upToSubStep: number | null = -1) => {\n if (upToSubStep === null) {\n return;\n }\n\n if (step.click) actions.push(step.attribute);\n if (step.subSteps) {\n const limit = upToSubStep === -1 ? step.subSteps.length : upToSubStep;\n for (let i = 0; i < limit; i++) {\n if (step.subSteps[i].click) actions.push(step.subSteps[i].attribute);\n }\n }\n };\n\n for (let i = 0; i <= stepIndex; i++) {\n const step = currentConfig.steps[i];\n if (isMatch(step, path)) {\n if (i < stepIndex) collectStepClicks(step);\n else if (subStepIndex !== null) {\n collectStepClicks(step, subStepIndex);\n }\n }\n }\n\n if (actions.length === 0) return;\n\n const performClick = (index: number) => {\n if (index >= actions.length) return;\n const attr = actions[index];\n const element = document.querySelector(`[data-onboarding-id=\"${attr}\"]`) as HTMLElement;\n if (element) element.click();\n setTimeout(() => performClick(index + 1), 500);\n };\n\n setTimeout(() => performClick(0), 500);\n },\n [isMatch],\n );\n\n // Reconcile state with path\n useEffect(() => {\n if (ssr && !isMounted) {\n setIsMounted(true);\n return;\n }\n\n const currentConfig = configRef.current;\n const currentState = stateRef.current;\n const isInOrder = (currentConfig.metadata.inOrder as boolean | undefined) !== false;\n\n if (!currentState.isActive) return;\n\n let nextState: OnboardingState | null = null;\n let navTo: string | undefined;\n\n if (!isInOrder) {\n const matchedIndex = currentConfig.steps.findIndex(\n (step, index) => isMatch(step, currentPath) && !currentState.completedSteps.includes(index),\n );\n\n if (matchedIndex !== -1 && matchedIndex !== currentState.currentStepIndex) {\n nextState = {\n ...currentState,\n currentStepIndex: matchedIndex,\n currentSubStepIndex: currentState.subStepProgress[matchedIndex] ?? null,\n };\n }\n } else {\n const firstUnfinishedIndex = currentConfig.steps.findIndex(\n (_, i) => !currentState.completedSteps.includes(i),\n );\n\n if (firstUnfinishedIndex !== -1) {\n if (firstUnfinishedIndex !== currentState.currentStepIndex) {\n nextState = {\n ...currentState,\n currentStepIndex: firstUnfinishedIndex,\n currentSubStepIndex: currentState.subStepProgress[firstUnfinishedIndex] ?? null,\n };\n }\n\n const step = currentConfig.steps[firstUnfinishedIndex];\n if (!isMatch(step, currentPath)) {\n if (step.urlBase && currentPath !== step.urlBase) {\n navTo = step.urlBase;\n }\n }\n }\n }\n\n if (nextState) {\n setState(nextState);\n }\n if (navTo) {\n handleNavigation(navTo);\n }\n }, [ssr, isMounted, currentPath, handleNavigation, isMatch, state.isActive, state.currentStepIndex, state.completedSteps, state.subStepProgress]);\n\n // Handle click simulation separately\n useEffect(() => {\n if (!state.isActive || !isMounted) return;\n const currentConfig = configRef.current;\n const step = currentConfig.steps[state.currentStepIndex];\n\n const simKey = `${currentPath}-${state.currentStepIndex}-${state.currentSubStepIndex}`;\n\n if (lastSimulatedKey.current === simKey) {\n return;\n }\n\n const internal = wasInternalAction.current;\n wasInternalAction.current = false;\n\n if (internal && currentPath === lastPathForSimulation.current) {\n lastSimulatedKey.current = simKey;\n return;\n }\n\n if (step && isMatch(step, currentPath) && currentConfig.metadata.simulateClicksOnNavigate) {\n if (lastSimulatedKey.current !== simKey) {\n lastSimulatedKey.current = simKey;\n lastPathForSimulation.current = currentPath;\n simulateClicks(state.currentStepIndex, state.currentSubStepIndex);\n }\n }\n }, [\n state.currentStepIndex,\n state.currentSubStepIndex,\n state.isActive,\n currentPath,\n isMounted,\n isMatch,\n simulateClicks,\n ]);\n\n // Persist state to cookies\n useEffect(() => {\n if (isMounted) {\n Cookies.set(COOKIE_NAME, JSON.stringify(state), { expires: 365 });\n }\n }, [state, isMounted]);\n\n const currentStep = useMemo(() => {\n const step = config.steps[state.currentStepIndex];\n if (!step) return null;\n\n const isUrlMatch = isMatch(step, currentPath);\n\n if (state.currentSubStepIndex !== null && step.subSteps) {\n const subStep = step.subSteps[state.currentSubStepIndex];\n if (isUrlMatch || isTransitioning) {\n return subStep || step;\n }\n return null;\n }\n\n if (!isUrlMatch) return null;\n\n return step;\n }, [\n config.steps,\n state.currentStepIndex,\n state.currentSubStepIndex,\n currentPath,\n isMatch,\n isTransitioning,\n ]);\n\n const isFirstStep = state.currentStepIndex === 0 && state.currentSubStepIndex === null;\n const isLastStep = useMemo(() => {\n const totalSteps = config.steps.length;\n const step = config.steps[state.currentStepIndex];\n const hasSubSteps = step?.subSteps && step.subSteps.length > 0;\n\n if (state.currentStepIndex === totalSteps - 1) {\n if (hasSubSteps) return state.currentSubStepIndex === step.subSteps!.length - 1;\n return true;\n }\n return false;\n }, [config.steps, state.currentStepIndex, state.currentSubStepIndex]);\n\n const nextStep = useCallback(() => {\n const currentConfig = configRef.current;\n const currentState = stateRef.current;\n wasInternalAction.current = true;\n\n const { currentStepIndex, currentSubStepIndex, completedSteps } = currentState;\n const stepObj = currentConfig.steps[currentStepIndex];\n if (!stepObj) return;\n\n const currentActiveStep =\n currentSubStepIndex !== null && stepObj.subSteps\n ? stepObj.subSteps[currentSubStepIndex]\n : stepObj;\n\n if (currentActiveStep.click) {\n const element = document.querySelector(\n `[data-onboarding-id=\"${currentActiveStep.attribute}\"]`,\n ) as HTMLElement;\n if (element) element.click();\n }\n\n let nextState: OnboardingState;\n let navTo: string | undefined;\n\n if (\n stepObj.subSteps &&\n (currentSubStepIndex === null || currentSubStepIndex < stepObj.subSteps.length - 1)\n ) {\n const nextSubIndex = currentSubStepIndex === null ? 0 : currentSubStepIndex + 1;\n const nextSubStep = stepObj.subSteps[nextSubIndex];\n\n setIsTransitioning(true);\n setTimeout(() => setIsTransitioning(false), 1000);\n\n navTo = currentActiveStep.navigate || nextSubStep.navigate;\n if (!navTo && currentSubStepIndex === null) navTo = stepObj.navigate;\n\n nextState = {\n ...currentState,\n currentSubStepIndex: nextSubIndex,\n subStepProgress: {\n ...currentState.subStepProgress,\n [currentStepIndex]: nextSubIndex,\n },\n };\n } else {\n const stepIndexToComplete = currentStepIndex;\n if (currentStepIndex < currentConfig.steps.length - 1) {\n const nextIndex = currentStepIndex + 1;\n const nextStepObj = currentConfig.steps[nextIndex];\n const targetSubStepIndex = currentState.subStepProgress[nextIndex] ?? null;\n const targetSubStep =\n targetSubStepIndex !== null && nextStepObj.subSteps\n ? nextStepObj.subSteps[targetSubStepIndex]\n : null;\n\n navTo = currentActiveStep.navigate || nextStepObj.navigate || targetSubStep?.navigate;\n\n nextState = {\n ...currentState,\n currentStepIndex: nextIndex,\n currentSubStepIndex: targetSubStepIndex,\n completedSteps: completedSteps.includes(stepIndexToComplete)\n ? completedSteps\n : [...completedSteps, stepIndexToComplete],\n subStepProgress: {\n ...currentState.subStepProgress,\n [stepIndexToComplete]: currentSubStepIndex,\n },\n };\n } else {\n if (currentConfig.onOnboardingComplete) currentConfig.onOnboardingComplete();\n\n navTo = currentActiveStep.navigate || stepObj.navigate;\n\n nextState = {\n ...currentState,\n isActive: false,\n completedSteps: completedSteps.includes(stepIndexToComplete)\n ? completedSteps\n : [...completedSteps, stepIndexToComplete],\n subStepProgress: {\n ...currentState.subStepProgress,\n [stepIndexToComplete]: currentSubStepIndex,\n },\n };\n }\n }\n\n Cookies.set(COOKIE_NAME, JSON.stringify(nextState), { expires: 365 });\n if (navTo) handleNavigation(navTo);\n setState(nextState);\n }, [handleNavigation]);\n\n const prevStep = useCallback(() => {\n const currentConfig = configRef.current;\n const currentState = stateRef.current;\n wasInternalAction.current = true;\n\n let nextState: OnboardingState | null = null;\n let navTo: string | undefined;\n\n if (currentState.currentSubStepIndex !== null && currentState.currentSubStepIndex > 0) {\n const nextSubIndex = currentState.currentSubStepIndex - 1;\n const nextSubStep = currentConfig.steps[currentState.currentStepIndex].subSteps![nextSubIndex];\n navTo = nextSubStep.navigate;\n\n nextState = {\n ...currentState,\n currentSubStepIndex: nextSubIndex,\n subStepProgress: {\n ...currentState.subStepProgress,\n [currentState.currentStepIndex]: nextSubIndex,\n },\n };\n } else if (currentState.currentStepIndex > 0 && currentState.currentSubStepIndex === 0) {\n const stepObj = currentConfig.steps[currentState.currentStepIndex];\n navTo = stepObj.navigate;\n\n nextState = {\n ...currentState,\n currentSubStepIndex: null,\n subStepProgress: {\n ...currentState.subStepProgress,\n [currentState.currentStepIndex]: null,\n },\n };\n } else if (currentState.currentStepIndex > 0) {\n const prevIndex = currentState.currentStepIndex - 1;\n const prevStepObj = currentConfig.steps[prevIndex];\n const prevSubStepIndex =\n currentState.subStepProgress[prevIndex] ??\n (prevStepObj.subSteps ? prevStepObj.subSteps.length - 1 : null);\n const prevSubStep =\n prevSubStepIndex !== null && prevStepObj.subSteps\n ? prevStepObj.subSteps[prevSubStepIndex]\n : null;\n\n navTo = prevStepObj.navigate || prevSubStep?.navigate;\n\n nextState = {\n ...currentState,\n currentStepIndex: prevIndex,\n currentSubStepIndex: prevSubStepIndex,\n isActive: true,\n subStepProgress: {\n ...currentState.subStepProgress,\n [prevIndex]: prevSubStepIndex,\n },\n };\n }\n\n if (nextState) {\n Cookies.set(COOKIE_NAME, JSON.stringify(nextState), { expires: 365 });\n if (navTo) handleNavigation(navTo);\n setState(nextState);\n }\n }, [handleNavigation]);\n\n const finish = useCallback(() => {\n setState((prev) => ({ ...prev, isActive: false }));\n if (configRef.current.onOnboardingComplete) configRef.current.onOnboardingComplete();\n }, []);\n\n const goToStep = useCallback(\n (stepIndex: number, subStepIndex: number | null = null) => {\n const currentConfig = configRef.current;\n const currentState = stateRef.current;\n wasInternalAction.current = true;\n\n const nextStepObj = currentConfig.steps[stepIndex];\n if (!nextStepObj) return;\n\n const targetSubStep =\n subStepIndex !== null && nextStepObj.subSteps\n ? nextStepObj.subSteps[subStepIndex]\n : null;\n\n const navTo = nextStepObj.navigate || targetSubStep?.navigate;\n\n const nextState = {\n ...currentState,\n currentStepIndex: stepIndex,\n currentSubStepIndex: subStepIndex,\n isActive: true,\n subStepProgress: {\n ...currentState.subStepProgress,\n [stepIndex]: subStepIndex,\n },\n };\n\n Cookies.set(COOKIE_NAME, JSON.stringify(nextState), { expires: 365 });\n if (navTo) handleNavigation(navTo);\n setState(nextState);\n },\n [handleNavigation],\n );\n\n const value = {\n config,\n state,\n nextStep,\n prevStep,\n finish,\n goToStep,\n currentStep,\n isFirstStep,\n isLastStep,\n };\n\n if (!isMounted) return <>{children}</>;\n\n return (\n <OnboardingContext.Provider value={value}>\n {children}\n {state.isActive && <OnboardingOverlay />}\n </OnboardingContext.Provider>\n );\n};\n\nexport const useOnboarding = () => {\n const context = useContext(OnboardingContext);\n if (context === undefined)\n throw new Error('useOnboarding must be used within an OnboardingProvider');\n return context;\n};\n","'use client';\n\nimport React, { useState, useEffect, useCallback, useRef } from 'react';\nimport { createPortal } from 'react-dom';\nimport { useOnboarding } from './OnboardingProvider';\n\nconst ChevronLeftIcon = () => (\n <svg\n width=\"16\"\n height=\"16\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d=\"M15 18l-6-6 6-6\" />\n </svg>\n);\n\nconst ChevronRightIcon = () => (\n <svg\n width=\"16\"\n height=\"16\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d=\"M9 18l6-6-6-6\" />\n </svg>\n);\n\nconst XIcon = () => (\n <svg\n width=\"18\"\n height=\"18\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <line x1=\"18\" y1=\"6\" x2=\"6\" y2=\"18\" />\n <line x1=\"6\" y1=\"6\" x2=\"18\" y2=\"18\" />\n </svg>\n);\n\nexport const OnboardingOverlay: React.FC = () => {\n const { config, currentStep, nextStep, prevStep, finish, isFirstStep, isLastStep } =\n useOnboarding();\n const [coords, setCoords] = useState<{\n top: number;\n left: number;\n width: number;\n height: number;\n } | null>(null);\n const [position, setPosition] = useState<{ top: number; left: number }>({ top: 0, left: 0 });\n const [dragOffset, setDragOffset] = useState<{ x: number; y: number }>({ x: 0, y: 0 });\n const isDragging = useRef(false);\n const dragStart = useRef<{ x: number; y: number }>({ x: 0, y: 0 });\n const tooltipRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n // eslint-disable-next-line react-hooks/set-state-in-effect\n setDragOffset({ x: 0, y: 0 });\n }, [currentStep]);\n\n const handlePointerUpRef = useRef<() => void>(() => {});\n\n const handlePointerMove = useCallback((e: PointerEvent) => {\n if (!isDragging.current) return;\n\n const newX = e.clientX - dragStart.current.x;\n const newY = e.clientY - dragStart.current.y;\n\n setDragOffset({ x: newX, y: newY });\n }, []);\n\n const handlePointerUp = useCallback(() => {\n isDragging.current = false;\n\n if (tooltipRef.current) {\n tooltipRef.current.style.transition =\n 'top 0.3s cubic-bezier(0.25, 0.1, 0.25, 1), left 0.3s cubic-bezier(0.25, 0.1, 0.25, 1)';\n tooltipRef.current.style.cursor = config.metadata.draggable ? 'grab' : 'auto';\n }\n\n window.removeEventListener('pointermove', handlePointerMove);\n window.removeEventListener('pointerup', handlePointerUpRef.current);\n }, [config.metadata.draggable, handlePointerMove]);\n\n useEffect(() => {\n handlePointerUpRef.current = handlePointerUp;\n }, [handlePointerUp]);\n\n const handlePointerDown = (e: React.PointerEvent) => {\n if (!config.metadata.draggable) return;\n e.stopPropagation();\n e.preventDefault();\n isDragging.current = true;\n dragStart.current = { x: e.clientX - dragOffset.x, y: e.clientY - dragOffset.y };\n\n if (tooltipRef.current) {\n tooltipRef.current.style.transition = 'none';\n tooltipRef.current.style.cursor = 'grabbing';\n }\n\n window.addEventListener('pointermove', handlePointerMove);\n window.addEventListener('pointerup', handlePointerUp);\n };\n\n const calculateBestPosition = useCallback(\n (rect: {\n top: number;\n bottom: number;\n left: number;\n right: number;\n width: number;\n height: number;\n }) => {\n const tooltipWidth = 300;\n const tooltipHeight = 200;\n const gap = 12;\n const padding = 20;\n\n const spaceAbove = rect.top;\n const spaceBelow = window.innerHeight - rect.bottom;\n const spaceLeft = rect.left;\n const spaceRight = window.innerWidth - rect.right;\n\n let top = 0;\n let left = 0;\n\n if (spaceBelow > tooltipHeight + gap + padding) {\n top = rect.bottom + gap;\n left = Math.max(\n padding,\n Math.min(\n window.innerWidth - tooltipWidth - padding,\n rect.left + rect.width / 2 - tooltipWidth / 2,\n ),\n );\n } else if (spaceAbove > tooltipHeight + gap + padding) {\n top = rect.top - tooltipHeight - gap;\n left = Math.max(\n padding,\n Math.min(\n window.innerWidth - tooltipWidth - padding,\n rect.left + rect.width / 2 - tooltipWidth / 2,\n ),\n );\n } else if (spaceRight > tooltipWidth + gap + padding) {\n top = Math.max(\n padding,\n Math.min(\n window.innerHeight - tooltipHeight - padding,\n rect.top + rect.height / 2 - tooltipHeight / 2,\n ),\n );\n left = rect.right + gap;\n } else if (spaceLeft > tooltipWidth + gap + padding) {\n top = Math.max(\n padding,\n Math.min(\n window.innerHeight - tooltipHeight - padding,\n rect.top + rect.height / 2 - tooltipHeight / 2,\n ),\n );\n left = rect.left - tooltipWidth - gap;\n } else {\n top = window.innerHeight / 2 - tooltipHeight / 2;\n left = window.innerWidth / 2 - tooltipWidth / 2;\n }\n\n return { top: top + window.scrollY, left: left + window.scrollX };\n },\n [],\n );\n\n const updateCoords = useCallback(() => {\n if (!currentStep) return;\n\n const element = document.querySelector(\n `[data-onboarding-id=\"${currentStep.attribute}\"]`,\n ) as HTMLElement;\n if (element) {\n const rect = element.getBoundingClientRect();\n const padding = config.style?.padding || 0;\n\n const paddedRect = {\n top: rect.top - padding,\n bottom: rect.bottom + padding,\n left: rect.left - padding,\n right: rect.right + padding,\n width: rect.width + padding * 2,\n height: rect.height + padding * 2,\n };\n\n const newCoords = {\n top: paddedRect.top + window.scrollY,\n left: paddedRect.left + window.scrollX,\n width: paddedRect.width,\n height: paddedRect.height,\n };\n\n const newPosition = calculateBestPosition(paddedRect);\n\n setCoords((prev) => {\n if (\n prev &&\n prev.top === newCoords.top &&\n prev.left === newCoords.left &&\n prev.width === newCoords.width &&\n prev.height === newCoords.height\n ) {\n return prev;\n }\n return newCoords;\n });\n\n setPosition((prev) => {\n if (prev.top === newPosition.top && prev.left === newPosition.left) {\n return prev;\n }\n return newPosition;\n });\n } else {\n setCoords(null);\n }\n }, [currentStep, calculateBestPosition, config.style]);\n\n useEffect(() => {\n // eslint-disable-next-line react-hooks/set-state-in-effect\n updateCoords();\n window.addEventListener('resize', updateCoords);\n window.addEventListener('scroll', updateCoords);\n\n const observer = new MutationObserver(updateCoords);\n observer.observe(document.body, { childList: true, subtree: true, attributes: true });\n\n let resizeObserver: ResizeObserver | null = null;\n if (typeof ResizeObserver !== 'undefined') {\n resizeObserver = new ResizeObserver(updateCoords);\n resizeObserver.observe(document.body);\n\n const element = currentStep?.attribute\n ? document.querySelector(`[data-onboarding-id=\"${currentStep.attribute}\"]`)\n : null;\n if (element) {\n resizeObserver.observe(element);\n }\n }\n\n return () => {\n window.removeEventListener('resize', updateCoords);\n window.removeEventListener('scroll', updateCoords);\n window.removeEventListener('pointermove', handlePointerMove);\n window.removeEventListener('pointerup', handlePointerUp);\n observer.disconnect();\n if (resizeObserver) resizeObserver.disconnect();\n };\n }, [updateCoords, currentStep?.attribute, handlePointerMove, handlePointerUp]);\n\n if (!currentStep || !coords) return null;\n\n const maskStyle = {\n ...config.style?.background,\n transition: 'all 0.3s cubic-bezier(0.25, 0.1, 0.25, 1)',\n };\n\n const stopPropagation = (e: React.PointerEvent | React.MouseEvent) => {\n e.stopPropagation();\n };\n\n const overlayContent = (\n <div className=\"onboard-overlay-container\">\n <div\n style={{ height: coords.top, ...maskStyle }}\n className=\"onboard-overlay-mask onboard-mask-top\"\n onPointerDown={stopPropagation}\n onMouseDown={stopPropagation}\n onClick={stopPropagation}\n />\n <div\n style={{\n top: coords.top + coords.height,\n height: `calc(100vh - ${coords.top + coords.height}px)`,\n ...maskStyle,\n }}\n className=\"onboard-overlay-mask onboard-mask-bottom\"\n onPointerDown={stopPropagation}\n onMouseDown={stopPropagation}\n onClick={stopPropagation}\n />\n <div\n style={{ top: coords.top, height: coords.height, width: coords.left, ...maskStyle }}\n className=\"onboard-overlay-mask onboard-mask-left\"\n onPointerDown={stopPropagation}\n onMouseDown={stopPropagation}\n onClick={stopPropagation}\n />\n <div\n style={{\n top: coords.top,\n height: coords.height,\n left: coords.left + coords.width,\n width: `calc(100% - ${coords.left + coords.width}px)`,\n ...maskStyle,\n }}\n className=\"onboard-overlay-mask\"\n onPointerDown={stopPropagation}\n onMouseDown={stopPropagation}\n onClick={stopPropagation}\n />\n\n <div\n ref={tooltipRef}\n className=\"onboard-tooltip\"\n onPointerDown={handlePointerDown}\n style={{\n zIndex: 1000000,\n ...config.style?.container,\n top: position.top + dragOffset.y,\n left: position.left + dragOffset.x,\n transition:\n 'top 0.3s cubic-bezier(0.25, 0.1, 0.25, 1), left 0.3s cubic-bezier(0.25, 0.1, 0.25, 1)',\n cursor: config.metadata.draggable ? 'grab' : 'auto',\n touchAction: 'none',\n }}\n onMouseDown={stopPropagation}\n onClick={stopPropagation}\n >\n <div className=\"onboard-tooltip-header\">\n <h3 className=\"onboard-tooltip-title\">{currentStep.title}</h3>\n <button\n onClick={(e) => {\n e.stopPropagation();\n finish();\n }}\n className=\"onboard-close-button\"\n >\n <XIcon />\n </button>\n </div>\n <p className=\"onboard-tooltip-description\">{currentStep.description}</p>\n\n <div className=\"onboard-tooltip-footer\">\n <button\n onClick={(e) => {\n e.stopPropagation();\n prevStep();\n }}\n disabled={isFirstStep}\n className=\"onboard-button-ghost\"\n style={{\n background: 'none',\n border: 'none',\n cursor: isFirstStep ? 'not-allowed' : 'pointer',\n ...config.style?.prev,\n }}\n >\n <ChevronLeftIcon />\n Prev\n </button>\n\n {isLastStep ? (\n <button\n onClick={(e) => {\n e.stopPropagation();\n nextStep();\n }}\n className=\"onboard-button-primary\"\n style={{ border: 'none', cursor: 'pointer', ...config.style?.finish }}\n >\n Finish\n </button>\n ) : (\n <button\n onClick={(e) => {\n e.stopPropagation();\n nextStep();\n }}\n className=\"onboard-button-primary\"\n style={{\n border: 'none',\n cursor: 'pointer',\n ...(isFirstStep ? config.style?.start : {}),\n ...(!isFirstStep ? config.style?.next : {}),\n }}\n >\n {isFirstStep && config.style?.start ? 'Start' : 'Next'}\n {!(isFirstStep && config.style?.start) && <ChevronRightIcon />}\n </button>\n )}\n </div>\n </div>\n </div>\n );\n\n return typeof document !== 'undefined' ? createPortal(overlayContent, document.body) : null;\n};\n"],"mappings":";aAEA,OACE,iBAAAA,GACA,cAAAC,GACA,aAAAC,EACA,YAAAC,EACA,eAAAC,EACA,WAAAC,GACA,UAAAC,MACK,QACP,OAAOC,MAAa,YCTpB,OAAgB,YAAAC,EAAU,aAAAC,EAAW,eAAAC,EAAa,UAAAC,MAAc,QAChE,OAAS,gBAAAC,OAAoB,YAczB,cAAAC,EAoBF,QAAAC,MApBE,oBAXJ,IAAMC,GAAkB,IACtBF,EAAC,OACC,MAAM,KACN,OAAO,KACP,QAAQ,YACR,KAAK,OACL,OAAO,eACP,YAAY,IACZ,cAAc,QACd,eAA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,YAAA5B,EACA,YAAAI,EACA,WAAAC,CACF,EAEA,OAAK9D,EAGHb,GAACC,GAAkB,SAAlB,CAA2B,MAAOkG,EAChC,UAAAvF,EACAI,EAAM,UAAYjB,GAACqG,GAAA,EAAkB,GACxC,EANqBrG,GAAAD,GAAA,CAAG,SAAAc,EAAS,CAQrC,EAEayF,GAAgB,IAAM,CACjC,IAAMC,EAAUC,GAAWtG,EAAiB,EAC5C,GAAIqG,IAAY,OACd,MAAM,IAAI,MAAM,yDAAyD,EAC3E,OAAOA,CACT","names":["createContext","useContext","useEffect","useState","useCallback","useMemo","useRef","Cookies","useState","useEffect","useCallback","useRef","createPortal","jsx","jsxs","ChevronLeftIcon","ChevronRightIcon","XIcon","OnboardingOverlay","config","currentStep","nextStep","prevStep","finish","isFirstStep","isLastStep","useOnboarding","coords","setCoords","useState","position","setPosition","dragOffset","setDragOffset","isDragging","useRef","dragStart","tooltipRef","useEffect","handlePointerUpRef","handlePointerMove","useCallback","e","newX","newY","handlePointerUp","handlePointerDown","calculateBestPosition","rect","spaceAbove","spaceBelow","spaceLeft","spaceRight","top","left","updateCoords","element","padding","paddedRect","newCoords","newPosition","prev","observer","resizeObserver","maskStyle","stopPropagation","overlayContent","createPortal","Fragment","jsx","jsxs","OnboardingContext","createContext","COOKIE_NAME","getInitialState","saved","Cookies","parsed","OnboardingProvider","config","ssr","onNavigate","children","isMounted","setIsMounted","useState","state","setState","currentPath","setCurrentPath","isTransitioning","setIsTransitioning","configRef","useRef","onNavigateRef","stateRef","lastSimulatedKey","lastPathForSimulation","wasInternalAction","useEffect","handlePathChange","newPath","originalPushState","originalReplaceState","args","interval","handleNavigation","useCallback","link","isMatch","step","path","normalize","p","normalizedPath","normalizedMatch","match","pattern","simulateClicks","stepIndex","subStepIndex","currentConfig","actions","collectStepClicks","upToSubStep","limit","i","performClick","index","attr","element","currentState","isInOrder","nextState","navTo","firstUnfinishedIndex","_","matchedIndex","simKey","internal","currentStep","useMemo","isUrlMatch","subStep","isFirstStep","isLastStep","totalSteps","hasSubSteps","nextStep","currentStepIndex","currentSubStepIndex","completedSteps","stepObj","currentActiveStep","nextSubIndex","nextSubStep","stepIndexToComplete","nextIndex","nextStepObj","targetSubStepIndex","targetSubStep","prevStep","prevIndex","prevStepObj","prevSubStepIndex","prevSubStep","finish","prev","goToStep","value","OnboardingOverlay","useOnboarding","context","useContext"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "onboard-engine",
3
- "version": "1.5.4",
3
+ "version": "1.5.5",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "types": "./dist/index.d.ts",