onboard-engine 1.4.1 → 1.4.3

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 Q=Object.create;var T=Object.defineProperty;var V=Object.getOwnPropertyDescriptor;var Z=Object.getOwnPropertyNames;var tt=Object.getPrototypeOf,et=Object.prototype.hasOwnProperty;var nt=(n,d)=>{for(var g in d)T(n,g,{get:d[g],enumerable:!0})},X=(n,d,g,I)=>{if(d&&typeof d=="object"||typeof d=="function")for(let f of Z(d))!et.call(n,f)&&f!==g&&T(n,f,{get:()=>d[f],enumerable:!(I=V(d,f))||I.enumerable});return n};var Y=(n,d,g)=>(g=n!=null?Q(tt(n)):{},X(d||!n||!n.__esModule?T(g,"default",{value:n,enumerable:!0}):g,n)),ot=n=>X(T({},"__esModule",{value:!0}),n);var it={};nt(it,{OnboardingProvider:()=>rt,useOnboarding:()=>F});module.exports=ot(it);var a=Y(require("react")),B=Y(require("js-cookie"));var b=require("react"),q=require("react-dom");var l=require("react/jsx-runtime"),J=()=>{let{config:n,currentStep:d,nextStep:g,prevStep:I,finish:f,isFirstStep:y,isLastStep:r}=F(),[i,x]=(0,b.useState)(null),[M,O]=(0,b.useState)({top:0,left:0}),[P,D]=(0,b.useState)({x:0,y:0}),A=(0,b.useRef)(!1),H=(0,b.useRef)({x:0,y:0}),v=(0,b.useRef)(null);(0,b.useEffect)(()=>{D({x:0,y:0})},[d]);let k=(0,b.useCallback)(t=>{if(!A.current)return;let c=t.clientX-H.current.x,h=t.clientY-H.current.y;D({x:c,y:h})},[]),E=(0,b.useCallback)(()=>{A.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=n.metadata.draggable?"grab":"auto"),window.removeEventListener("pointermove",k),window.removeEventListener("pointerup",E)},[n.metadata.draggable,k]),j=t=>{n.metadata.draggable&&(t.stopPropagation(),t.preventDefault(),A.current=!0,H.current={x:t.clientX-P.x,y:t.clientY-P.y},v.current&&(v.current.style.transition="none",v.current.style.cursor="grabbing"),window.addEventListener("pointermove",k),window.addEventListener("pointerup",E))};(0,b.useEffect)(()=>()=>{window.removeEventListener("pointermove",k),window.removeEventListener("pointerup",E)},[k,E]);let $=(0,b.useCallback)(t=>{let W=t.top,S=window.innerHeight-t.bottom,K=t.left,G=window.innerWidth-t.right,z=0,N=0;return S>232?(z=t.bottom+12,N=Math.max(20,Math.min(window.innerWidth-300-20,t.left+t.width/2-300/2))):W>232?(z=t.top-200-12,N=Math.max(20,Math.min(window.innerWidth-300-20,t.left+t.width/2-300/2))):G>332?(z=Math.max(20,Math.min(window.innerHeight-200-20,t.top+t.height/2-200/2)),N=t.right+12):K>332?(z=Math.max(20,Math.min(window.innerHeight-200-20,t.top+t.height/2-200/2)),N=t.left-300-12):(z=window.innerHeight/2-200/2,N=window.innerWidth/2-300/2),{top:z+window.scrollY,left:N+window.scrollX}},[]),m=(0,b.useCallback)(()=>{if(!d)return;let t=document.querySelector(`[data-onboarding-id="${d.attribute}"]`);if(t){let c=t.getBoundingClientRect(),h=n.style?.padding||0,L={top:c.top-h,bottom:c.bottom+h,left:c.left-h,right:c.right+h,width:c.width+h*2,height:c.height+h*2},R={top:L.top+window.scrollY,left:L.left+window.scrollX,width:L.width,height:L.height},W=$(L);x(S=>S&&S.top===R.top&&S.left===R.left&&S.width===R.width&&S.height===R.height?S:R),O(S=>S.top===W.top&&S.left===W.left?S:W)}else x(null)},[d,$,n.style]);if((0,b.useEffect)(()=>{m(),window.addEventListener("resize",m),window.addEventListener("scroll",m);let t=new MutationObserver(m);t.observe(document.body,{childList:!0,subtree:!0,attributes:!0});let c=null;if(typeof ResizeObserver<"u"){c=new ResizeObserver(m),c.observe(document.body);let h=d?.attribute?document.querySelector(`[data-onboarding-id="${d.attribute}"]`):null;h&&c.observe(h)}return()=>{window.removeEventListener("resize",m),window.removeEventListener("scroll",m),t.disconnect(),c&&c.disconnect()}},[m,d?.attribute]),!d||!i)return null;let e={...n.style?.background,transition:"all 0.3s cubic-bezier(0.25, 0.1, 0.25, 1)"},o=t=>{t.stopPropagation()},u=()=>(0,l.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,l.jsx)("path",{d:"M15 18l-6-6 6-6"})}),p=()=>(0,l.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,l.jsx)("path",{d:"M9 18l6-6-6-6"})}),s=()=>(0,l.jsxs)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,l.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,l.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]}),w=(0,l.jsxs)("div",{className:"onboard-overlay-container",children:[(0,l.jsx)("div",{style:{height:i.top,...e},className:"onboard-overlay-mask onboard-mask-top",onPointerDown:o,onMouseDown:o,onClick:o}),(0,l.jsx)("div",{style:{top:i.top+i.height,height:`calc(100vh - ${i.top+i.height}px)`,...e},className:"onboard-overlay-mask onboard-mask-bottom",onPointerDown:o,onMouseDown:o,onClick:o}),(0,l.jsx)("div",{style:{top:i.top,height:i.height,width:i.left,...e},className:"onboard-overlay-mask onboard-mask-left",onPointerDown:o,onMouseDown:o,onClick:o}),(0,l.jsx)("div",{style:{top:i.top,height:i.height,left:i.left+i.width,width:`calc(100% - ${i.left+i.width}px)`,...e},className:"onboard-overlay-mask",onPointerDown:o,onMouseDown:o,onClick:o}),(0,l.jsxs)("div",{ref:v,className:"onboard-tooltip",onPointerDown:j,style:{zIndex:1e6,...n.style?.container,top:M.top+P.y,left:M.left+P.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:n.metadata.draggable?"grab":"auto",touchAction:"none"},onMouseDown:o,onClick:o,children:[(0,l.jsxs)("div",{className:"onboard-tooltip-header",children:[(0,l.jsx)("h3",{className:"onboard-tooltip-title",children:d.title}),(0,l.jsx)("button",{onClick:t=>{t.stopPropagation(),f()},className:"onboard-close-button",children:(0,l.jsx)(s,{})})]}),(0,l.jsx)("p",{className:"onboard-tooltip-description",children:d.description}),(0,l.jsxs)("div",{className:"onboard-tooltip-footer",children:[(0,l.jsxs)("button",{onClick:t=>{t.stopPropagation(),I()},disabled:y,className:"onboard-button-ghost",style:{background:"none",border:"none",cursor:y?"not-allowed":"pointer",...n.style?.prev},children:[(0,l.jsx)(u,{}),"Prev"]}),r?(0,l.jsx)("button",{onClick:t=>{t.stopPropagation(),f()},className:"onboard-button-primary",style:{border:"none",cursor:"pointer",...n.style?.finish},children:"Finish"}):(0,l.jsxs)("button",{onClick:t=>{t.stopPropagation(),g()},className:"onboard-button-primary",style:{border:"none",cursor:"pointer",...y?n.style?.start:{},...y?{}:n.style?.next},children:[y&&n.style?.start?"Start":"Next",!(y&&n.style?.start)&&(0,l.jsx)(p,{})]})]})]})]});return typeof document<"u"?(0,q.createPortal)(w,document.body):null};var C=require("react/jsx-runtime"),_=(0,a.createContext)(void 0),U="onboarding_state",rt=({config:n,ssr:d=!1,onNavigate:g,children:I})=>{let[f,y]=(0,a.useState)(!d),[r,i]=(0,a.useState)({currentStepIndex:0,currentSubStepIndex:null,isActive:!0}),x=a.default.useRef(n);(0,a.useEffect)(()=>{x.current=n},[n]);let M=a.default.useRef(g);(0,a.useEffect)(()=>{M.current=g},[g]);let O=(0,a.useCallback)(e=>{e&&(M.current?M.current(e):(n.metadata.nextRouter,window.location.href=e))},[n.metadata.nextRouter]);(0,a.useEffect)(()=>{d&&y(!0)},[d]);let P=(e,o)=>{if(e.urlMatch instanceof RegExp)return e.urlMatch.test(o);if(typeof e.urlMatch=="string"&&e.urlMatch.includes("*")){let u=e.urlMatch.replace(/[.+?^${}()|[\\]/g,"\\$&").replace(/\*/g,".*");return new RegExp(`^${u}$`).test(o)}return o===e.urlMatch},D=(0,a.useEffectEvent)(()=>{let e=x.current,o=window.location.pathname,u=-1;e.metadata.inOrder===!1&&(u=e.steps.findIndex(s=>P(s,o)));let p=B.default.get(U);if(p)try{let s=JSON.parse(p);if(e.metadata.inOrder===!1)u!==-1?s.currentStepIndex===u?i(s):i({currentStepIndex:u,currentSubStepIndex:null,isActive:!0}):i({...s,isActive:!1});else if(i(s),e.metadata.inOrder!==!1){let w=e.steps[s.currentStepIndex];if(w&&s.isActive){let t;if(s.currentStepIndex>0){let c=e.steps[s.currentStepIndex-1];c.navigate&&(t=c.navigate)}!t&&typeof w.urlMatch=="string"&&(t=w.urlMatch),t&&window.location.pathname!==t&&O(t),e.metadata.simulateClicksOnNavigate&&s.currentSubStepIndex!==null&&w.click&&setTimeout(()=>{let c=document.querySelector(`[data-onboarding-id="${w.attribute}"]`);c&&c.click()},500)}}}catch(s){console.error("Failed to parse onboarding state from cookie",s),u!==-1&&i({currentStepIndex:u,currentSubStepIndex:null,isActive:!0})}else if(u!==-1)i({currentStepIndex:u,currentSubStepIndex:null,isActive:!0});else if(e.metadata.inOrder===!1)i(s=>({...s,isActive:!1}));else{let s=e.steps[0];s&&typeof s.urlMatch=="string"&&window.location.pathname!==s.urlMatch&&O(s.urlMatch)}});(0,a.useEffect)(()=>{D()},[]),(0,a.useEffect)(()=>{f&&B.default.set(U,JSON.stringify(r),{expires:365})},[r,f]);let A=(0,a.useMemo)(()=>{let e=n.steps[r.currentStepIndex];return e?r.currentSubStepIndex!==null&&e.subSteps&&e.subSteps[r.currentSubStepIndex]||e:null},[n.steps,r.currentStepIndex,r.currentSubStepIndex]),H=r.currentStepIndex===0&&r.currentSubStepIndex===null,v=(0,a.useMemo)(()=>{let e=n.steps.length,o=r.currentStepIndex===e-1,u=n.steps[r.currentStepIndex],p=u?.subSteps&&u.subSteps.length>0;return o?p?r.currentSubStepIndex===u.subSteps.length-1:!0:!1},[n.steps,r.currentStepIndex,r.currentSubStepIndex]),k=(0,a.useCallback)(()=>{let e=x.current,o=e.steps[r.currentStepIndex],u=r.currentSubStepIndex!==null&&o.subSteps?o.subSteps[r.currentSubStepIndex]:o;if(u.click){let p=document.querySelector(`[data-onboarding-id="${u.attribute}"]`);p&&p.click()}if(o.subSteps&&(r.currentSubStepIndex===null||r.currentSubStepIndex<o.subSteps.length-1)){let p=r.currentSubStepIndex===null?0:r.currentSubStepIndex+1,s=o.subSteps[p];i(w=>({...w,currentSubStepIndex:p})),s.navigate&&O(s.navigate);return}if(r.currentStepIndex<e.steps.length-1){let p=r.currentStepIndex+1,s=e.steps[p];i({currentStepIndex:p,currentSubStepIndex:null,isActive:!0}),s.navigate&&O(s.navigate)}else i(p=>({...p,isActive:!1})),e.onOnboardingComplete&&e.onOnboardingComplete()},[r.currentStepIndex,r.currentSubStepIndex,O]),E=(0,a.useCallback)(()=>{let e=x.current;if(r.currentSubStepIndex!==null&&r.currentSubStepIndex>0){i(o=>({...o,currentSubStepIndex:o.currentSubStepIndex-1}));return}if(r.currentStepIndex>0&&r.currentSubStepIndex===0){i(o=>({...o,currentSubStepIndex:null}));return}if(r.currentStepIndex>0){let o=r.currentStepIndex-1,u=e.steps[o],p=u.subSteps?u.subSteps.length-1:null;i({currentStepIndex:o,currentSubStepIndex:p,isActive:!0})}},[r.currentStepIndex,r.currentSubStepIndex]),j=(0,a.useCallback)(()=>{i(e=>({...e,isActive:!1})),x.current.onOnboardingComplete&&x.current.onOnboardingComplete()},[]),$=(0,a.useCallback)((e,o=null)=>{i({currentStepIndex:e,currentSubStepIndex:o,isActive:!0})},[]),m={config:n,state:r,nextStep:k,prevStep:E,finish:j,goToStep:$,currentStep:A,isFirstStep:H,isLastStep:v};return f?(0,C.jsxs)(_.Provider,{value:m,children:[I,r.isActive&&(0,C.jsx)(J,{})]}):(0,C.jsx)(C.Fragment,{children:I})},F=()=>{let n=(0,a.useContext)(_);if(n===void 0)throw new Error("useOnboarding must be used within an OnboardingProvider");return n};0&&(module.exports={OnboardingProvider,useOnboarding});
2
+ "use strict";"use client";var G=Object.create;var $=Object.defineProperty;var Q=Object.getOwnPropertyDescriptor;var V=Object.getOwnPropertyNames;var Z=Object.getPrototypeOf,tt=Object.prototype.hasOwnProperty;var et=(n,s)=>{for(var f in s)$(n,f,{get:s[f],enumerable:!0})},X=(n,s,f,k)=>{if(s&&typeof s=="object"||typeof s=="function")for(let h of V(s))!tt.call(n,h)&&h!==f&&$(n,h,{get:()=>s[h],enumerable:!(k=Q(s,h))||k.enumerable});return n};var nt=(n,s,f)=>(f=n!=null?G(Z(n)):{},X(s||!n||!n.__esModule?$(f,"default",{value:n,enumerable:!0}):f,n)),ot=n=>X($({},"__esModule",{value:!0}),n);var dt={};et(dt,{OnboardingProvider:()=>at,useOnboarding:()=>F});module.exports=ot(dt);var c=require("react"),B=nt(require("js-cookie"));var b=require("react"),Y=require("react-dom");var l=require("react/jsx-runtime"),rt=()=>(0,l.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,l.jsx)("path",{d:"M15 18l-6-6 6-6"})}),it=()=>(0,l.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,l.jsx)("path",{d:"M9 18l6-6-6-6"})}),st=()=>(0,l.jsxs)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,l.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,l.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]}),q=()=>{let{config:n,currentStep:s,nextStep:f,prevStep:k,finish:h,isFirstStep:w,isLastStep:o}=F(),[r,x]=(0,b.useState)(null),[M,y]=(0,b.useState)({top:0,left:0}),[P,W]=(0,b.useState)({x:0,y:0}),N=(0,b.useRef)(!1),A=(0,b.useRef)({x:0,y:0}),v=(0,b.useRef)(null),[T,j]=(0,b.useState)(s);s!==T&&(j(s),W({x:0,y:0}));let D=(0,b.useRef)(()=>{}),O=(0,b.useCallback)(e=>{if(!N.current)return;let g=e.clientX-A.current.x,S=e.clientY-A.current.y;W({x:g,y:S})},[]),t=(0,b.useCallback)(()=>{N.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=n.metadata.draggable?"grab":"auto"),window.removeEventListener("pointermove",O),window.removeEventListener("pointerup",D.current)},[n.metadata.draggable,O]);(0,b.useEffect)(()=>{D.current=t},[t]);let a=e=>{n.metadata.draggable&&(e.stopPropagation(),e.preventDefault(),N.current=!0,A.current={x:e.clientX-P.x,y:e.clientY-P.y},v.current&&(v.current.style.transition="none",v.current.style.cursor="grabbing"),window.addEventListener("pointermove",O),window.addEventListener("pointerup",t))},u=(0,b.useCallback)(e=>{let H=e.top,m=window.innerHeight-e.bottom,_=e.left,K=window.innerWidth-e.right,E=0,z=0;return m>232?(E=e.bottom+12,z=Math.max(20,Math.min(window.innerWidth-300-20,e.left+e.width/2-300/2))):H>232?(E=e.top-200-12,z=Math.max(20,Math.min(window.innerWidth-300-20,e.left+e.width/2-300/2))):K>332?(E=Math.max(20,Math.min(window.innerHeight-200-20,e.top+e.height/2-200/2)),z=e.right+12):_>332?(E=Math.max(20,Math.min(window.innerHeight-200-20,e.top+e.height/2-200/2)),z=e.left-300-12):(E=window.innerHeight/2-200/2,z=window.innerWidth/2-300/2),{top:E+window.scrollY,left:z+window.scrollX}},[]),d=(0,b.useCallback)(()=>{if(!s)return;let e=document.querySelector(`[data-onboarding-id="${s.attribute}"]`);if(e){let g=e.getBoundingClientRect(),S=n.style?.padding||0,L={top:g.top-S,bottom:g.bottom+S,left:g.left-S,right:g.right+S,width:g.width+S*2,height:g.height+S*2},R={top:L.top+window.scrollY,left:L.left+window.scrollX,width:L.width,height:L.height},H=u(L);x(m=>m&&m.top===R.top&&m.left===R.left&&m.width===R.width&&m.height===R.height?m:R),y(m=>m.top===H.top&&m.left===H.left?m:H)}else x(null)},[s,u,n.style]);if((0,b.useEffect)(()=>{d(),window.addEventListener("resize",d),window.addEventListener("scroll",d);let e=new MutationObserver(d);e.observe(document.body,{childList:!0,subtree:!0,attributes:!0});let g=null;if(typeof ResizeObserver<"u"){g=new ResizeObserver(d),g.observe(document.body);let S=s?.attribute?document.querySelector(`[data-onboarding-id="${s.attribute}"]`):null;S&&g.observe(S)}return()=>{window.removeEventListener("resize",d),window.removeEventListener("scroll",d),window.removeEventListener("pointermove",O),window.removeEventListener("pointerup",t),e.disconnect(),g&&g.disconnect()}},[d,s?.attribute,O,t]),!s||!r)return null;let i={...n.style?.background,transition:"all 0.3s cubic-bezier(0.25, 0.1, 0.25, 1)"},p=e=>{e.stopPropagation()},I=(0,l.jsxs)("div",{className:"onboard-overlay-container",children:[(0,l.jsx)("div",{style:{height:r.top,...i},className:"onboard-overlay-mask onboard-mask-top",onPointerDown:p,onMouseDown:p,onClick:p}),(0,l.jsx)("div",{style:{top:r.top+r.height,height:`calc(100vh - ${r.top+r.height}px)`,...i},className:"onboard-overlay-mask onboard-mask-bottom",onPointerDown:p,onMouseDown:p,onClick:p}),(0,l.jsx)("div",{style:{top:r.top,height:r.height,width:r.left,...i},className:"onboard-overlay-mask onboard-mask-left",onPointerDown:p,onMouseDown:p,onClick:p}),(0,l.jsx)("div",{style:{top:r.top,height:r.height,left:r.left+r.width,width:`calc(100% - ${r.left+r.width}px)`,...i},className:"onboard-overlay-mask",onPointerDown:p,onMouseDown:p,onClick:p}),(0,l.jsxs)("div",{ref:v,className:"onboard-tooltip",onPointerDown:a,style:{zIndex:1e6,...n.style?.container,top:M.top+P.y,left:M.left+P.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:n.metadata.draggable?"grab":"auto",touchAction:"none"},onMouseDown:p,onClick:p,children:[(0,l.jsxs)("div",{className:"onboard-tooltip-header",children:[(0,l.jsx)("h3",{className:"onboard-tooltip-title",children:s.title}),(0,l.jsx)("button",{onClick:e=>{e.stopPropagation(),h()},className:"onboard-close-button",children:(0,l.jsx)(st,{})})]}),(0,l.jsx)("p",{className:"onboard-tooltip-description",children:s.description}),(0,l.jsxs)("div",{className:"onboard-tooltip-footer",children:[(0,l.jsxs)("button",{onClick:e=>{e.stopPropagation(),k()},disabled:w,className:"onboard-button-ghost",style:{background:"none",border:"none",cursor:w?"not-allowed":"pointer",...n.style?.prev},children:[(0,l.jsx)(rt,{}),"Prev"]}),o?(0,l.jsx)("button",{onClick:e=>{e.stopPropagation(),h()},className:"onboard-button-primary",style:{border:"none",cursor:"pointer",...n.style?.finish},children:"Finish"}):(0,l.jsxs)("button",{onClick:e=>{e.stopPropagation(),f()},className:"onboard-button-primary",style:{border:"none",cursor:"pointer",...w?n.style?.start:{},...w?{}:n.style?.next},children:[w&&n.style?.start?"Start":"Next",!(w&&n.style?.start)&&(0,l.jsx)(it,{})]})]})]})]});return typeof document<"u"?(0,Y.createPortal)(I,document.body):null};var C=require("react/jsx-runtime"),J=(0,c.createContext)(void 0),U="onboarding_state",at=({config:n,ssr:s=!1,onNavigate:f,children:k})=>{let[h,w]=(0,c.useState)(!s),[o,r]=(0,c.useState)({currentStepIndex:0,currentSubStepIndex:null,isActive:!0}),x=(0,c.useRef)(n),M=(0,c.useRef)(f);(0,c.useEffect)(()=>{x.current=n,M.current=f},[n,f]);let y=(0,c.useCallback)(t=>{t&&(M.current?M.current(t):window.location.href=t)},[]),P=(t,a)=>{if(t.urlMatch instanceof RegExp)return t.urlMatch.test(a);if(typeof t.urlMatch=="string"&&t.urlMatch.includes("*")){let u=t.urlMatch.replace(/[.+?^${}()|[\\]/g,"\\$&").replace(/\*/g,".*");return new RegExp(`^${u}$`).test(a)}return a===t.urlMatch};(0,c.useEffect)(()=>{s&&w(!0);let t=x.current,a=window.location.pathname,u=-1;t.metadata.inOrder===!1&&(u=t.steps.findIndex(i=>P(i,a)));let d=B.default.get(U);if(d)try{let i=JSON.parse(d);if(t.metadata.inOrder===!1)u!==-1?i.currentStepIndex===u?r(i):r({currentStepIndex:u,currentSubStepIndex:null,isActive:!0}):r({...i,isActive:!1});else if(r(i),t.metadata.inOrder!==!1){let p=t.steps[i.currentStepIndex];if(p&&i.isActive){let I;if(i.currentStepIndex>0){let e=t.steps[i.currentStepIndex-1];e.navigate&&(I=e.navigate)}!I&&typeof p.urlMatch=="string"&&(I=p.urlMatch),I&&window.location.pathname!==I&&y(I),t.metadata.simulateClicksOnNavigate&&i.currentSubStepIndex!==null&&p.click&&setTimeout(()=>{let e=document.querySelector(`[data-onboarding-id="${p.attribute}"]`);e&&e.click()},500)}}}catch(i){console.error("Failed to parse onboarding state from cookie",i),u!==-1&&r({currentStepIndex:u,currentSubStepIndex:null,isActive:!0})}else if(u!==-1)r({currentStepIndex:u,currentSubStepIndex:null,isActive:!0});else if(t.metadata.inOrder===!1)r(i=>({...i,isActive:!1}));else{let i=t.steps[0];i&&typeof i.urlMatch=="string"&&window.location.pathname!==i.urlMatch&&y(i.urlMatch)}},[s,y]),(0,c.useEffect)(()=>{h&&B.default.set(U,JSON.stringify(o),{expires:365})},[o,h]);let W=(0,c.useMemo)(()=>{let t=n.steps[o.currentStepIndex];return t?o.currentSubStepIndex!==null&&t.subSteps&&t.subSteps[o.currentSubStepIndex]||t:null},[n.steps,o.currentStepIndex,o.currentSubStepIndex]),N=o.currentStepIndex===0&&o.currentSubStepIndex===null,A=(0,c.useMemo)(()=>{let t=n.steps.length,a=o.currentStepIndex===t-1,u=n.steps[o.currentStepIndex],d=u?.subSteps&&u.subSteps.length>0;return a?d?o.currentSubStepIndex===u.subSteps.length-1:!0:!1},[n.steps,o.currentStepIndex,o.currentSubStepIndex]),v=(0,c.useCallback)(()=>{let t=x.current,a=t.steps[o.currentStepIndex],u=o.currentSubStepIndex!==null&&a.subSteps?a.subSteps[o.currentSubStepIndex]:a;if(u.click){let d=document.querySelector(`[data-onboarding-id="${u.attribute}"]`);d&&d.click()}if(a.subSteps&&(o.currentSubStepIndex===null||o.currentSubStepIndex<a.subSteps.length-1)){let d=o.currentSubStepIndex===null?0:o.currentSubStepIndex+1,i=a.subSteps[d];r(p=>({...p,currentSubStepIndex:d})),i.navigate&&y(i.navigate);return}if(o.currentStepIndex<t.steps.length-1){let d=o.currentStepIndex+1,i=t.steps[d];r({currentStepIndex:d,currentSubStepIndex:null,isActive:!0}),i.navigate&&y(i.navigate)}else r(d=>({...d,isActive:!1})),t.onOnboardingComplete&&t.onOnboardingComplete()},[o.currentStepIndex,o.currentSubStepIndex,y]),T=(0,c.useCallback)(()=>{let t=x.current;if(o.currentSubStepIndex!==null&&o.currentSubStepIndex>0){r(a=>({...a,currentSubStepIndex:a.currentSubStepIndex-1}));return}if(o.currentStepIndex>0&&o.currentSubStepIndex===0){r(a=>({...a,currentSubStepIndex:null}));return}if(o.currentStepIndex>0){let a=o.currentStepIndex-1,u=t.steps[a],d=u.subSteps?u.subSteps.length-1:null;r({currentStepIndex:a,currentSubStepIndex:d,isActive:!0})}},[o.currentStepIndex,o.currentSubStepIndex]),j=(0,c.useCallback)(()=>{r(t=>({...t,isActive:!1})),x.current.onOnboardingComplete&&x.current.onOnboardingComplete()},[]),D=(0,c.useCallback)((t,a=null)=>{r({currentStepIndex:t,currentSubStepIndex:a,isActive:!0})},[]),O={config:n,state:o,nextStep:v,prevStep:T,finish:j,goToStep:D,currentStep:W,isFirstStep:N,isLastStep:A};return h?(0,C.jsxs)(J.Provider,{value:O,children:[k,o.isActive&&(0,C.jsx)(q,{})]}):(0,C.jsx)(C.Fragment,{children:k})},F=()=>{let n=(0,c.useContext)(J);if(n===void 0)throw new Error("useOnboarding must be used within an OnboardingProvider");return n};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 useEffectEvent,\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\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>({\n currentStepIndex: 0,\n currentSubStepIndex: null,\n isActive: true,\n });\n\n const configRef = React.useRef(config);\n useEffect(() => {\n configRef.current = config;\n }, [config]);\n\n const onNavigateRef = React.useRef(onNavigate);\n useEffect(() => {\n onNavigateRef.current = onNavigate;\n }, [onNavigate]);\n\n const handleNavigation = useCallback(\n (link?: string) => {\n if (!link) return;\n\n if (onNavigateRef.current) {\n onNavigateRef.current(link);\n } else if (config.metadata.nextRouter) {\n window.location.href = link;\n } else {\n window.location.href = link;\n }\n },\n [config.metadata.nextRouter],\n );\n\n useEffect(() => {\n if (ssr) {\n // eslint-disable-next-line react-hooks/set-state-in-effect\n setIsMounted(true);\n }\n }, [ssr]);\n\n const isMatch = (step: OnboardingStep, path: string) => {\n if (step.urlMatch instanceof RegExp) return step.urlMatch.test(path);\n\n if (typeof step.urlMatch === 'string' && step.urlMatch.includes('*')) {\n const pattern = step.urlMatch.replace(/[.+?^${}()|[\\\\]/g, '\\\\$&').replace(/\\*/g, '.*');\n return new RegExp(`^${pattern}$`).test(path);\n }\n\n return path === step.urlMatch;\n };\n\n const onRestoreState = useEffectEvent(() => {\n const currentConfig = configRef.current;\n const currentPath = window.location.pathname;\n let matchedStepIndex = -1;\n\n if ((currentConfig.metadata.inOrder as boolean | undefined) === false) {\n matchedStepIndex = currentConfig.steps.findIndex((step) => isMatch(step, currentPath));\n }\n\n const savedState = Cookies.get(COOKIE_NAME);\n if (savedState) {\n try {\n const parsed: OnboardingState = JSON.parse(savedState);\n\n if ((currentConfig.metadata.inOrder as boolean | undefined) === false) {\n if (matchedStepIndex !== -1) {\n if (parsed.currentStepIndex === matchedStepIndex) {\n setState(parsed);\n } else {\n setState({\n currentStepIndex: matchedStepIndex,\n currentSubStepIndex: null,\n isActive: true,\n });\n }\n } else {\n setState({ ...parsed, isActive: false });\n }\n } else {\n setState(parsed);\n\n if ((currentConfig.metadata.inOrder as boolean | undefined) !== false) {\n const step = currentConfig.steps[parsed.currentStepIndex];\n if (step && parsed.isActive) {\n let targetUrl: string | undefined;\n\n if (parsed.currentStepIndex > 0) {\n const prevStep = currentConfig.steps[parsed.currentStepIndex - 1];\n if (prevStep.navigate) {\n targetUrl = prevStep.navigate;\n }\n }\n\n if (!targetUrl && typeof step.urlMatch === 'string') {\n targetUrl = step.urlMatch;\n }\n\n if (targetUrl && window.location.pathname !== targetUrl) {\n handleNavigation(targetUrl);\n }\n\n if (currentConfig.metadata.simulateClicksOnNavigate) {\n if (parsed.currentSubStepIndex !== null && step.click) {\n setTimeout(() => {\n const element = document.querySelector(\n `[data-onboarding-id=\"${step.attribute}\"]`,\n ) as HTMLElement;\n if (element) {\n element.click();\n }\n }, 500);\n }\n }\n }\n }\n }\n } catch (e) {\n console.error('Failed to parse onboarding state from cookie', e);\n if (matchedStepIndex !== -1) {\n setState({\n currentStepIndex: matchedStepIndex,\n currentSubStepIndex: null,\n isActive: true,\n });\n }\n }\n } else if (matchedStepIndex !== -1) {\n setState({\n currentStepIndex: matchedStepIndex,\n currentSubStepIndex: null,\n isActive: true,\n });\n } else if ((currentConfig.metadata.inOrder as boolean | undefined) === false) {\n setState((prev) => ({ ...prev, isActive: false }));\n } else {\n const step = currentConfig.steps[0];\n if (step && typeof step.urlMatch === 'string' && window.location.pathname !== step.urlMatch) {\n handleNavigation(step.urlMatch);\n }\n }\n });\n\n useEffect(() => {\n onRestoreState();\n }, []);\n\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 if (state.currentSubStepIndex !== null && step.subSteps) {\n return step.subSteps[state.currentSubStepIndex] || step;\n }\n return step;\n }, [config.steps, state.currentStepIndex, state.currentSubStepIndex]);\n\n const isFirstStep = state.currentStepIndex === 0 && state.currentSubStepIndex === null;\n const isLastStep = useMemo(() => {\n const totalSteps = config.steps.length;\n const isLastMainStep = state.currentStepIndex === totalSteps - 1;\n const step = config.steps[state.currentStepIndex];\n const hasSubSteps = step?.subSteps && step.subSteps.length > 0;\n\n if (isLastMainStep) {\n if (hasSubSteps) {\n return state.currentSubStepIndex === step.subSteps!.length - 1;\n }\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 stepObj = currentConfig.steps[state.currentStepIndex];\n const currentActiveStep =\n state.currentSubStepIndex !== null && stepObj.subSteps\n ? stepObj.subSteps[state.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) {\n element.click();\n }\n }\n\n if (\n stepObj.subSteps &&\n (state.currentSubStepIndex === null ||\n state.currentSubStepIndex < stepObj.subSteps.length - 1)\n ) {\n const nextSubIndex = state.currentSubStepIndex === null ? 0 : state.currentSubStepIndex + 1;\n const nextSubStep = stepObj.subSteps[nextSubIndex];\n setState((prev) => ({ ...prev, currentSubStepIndex: nextSubIndex }));\n\n if (nextSubStep.navigate) handleNavigation(nextSubStep.navigate);\n return;\n }\n\n if (state.currentStepIndex < currentConfig.steps.length - 1) {\n const nextIndex = state.currentStepIndex + 1;\n const nextStepObj = currentConfig.steps[nextIndex];\n setState({\n currentStepIndex: nextIndex,\n currentSubStepIndex: null,\n isActive: true,\n });\n\n if (nextStepObj.navigate) handleNavigation(nextStepObj.navigate);\n } else {\n setState((prev) => ({ ...prev, isActive: false }));\n if (currentConfig.onOnboardingComplete) {\n currentConfig.onOnboardingComplete();\n }\n }\n }, [state.currentStepIndex, state.currentSubStepIndex, handleNavigation]);\n\n const prevStep = useCallback(() => {\n const currentConfig = configRef.current;\n\n if (state.currentSubStepIndex !== null && state.currentSubStepIndex > 0) {\n setState((prev) => ({ ...prev, currentSubStepIndex: prev.currentSubStepIndex! - 1 }));\n return;\n }\n\n if (state.currentStepIndex > 0 && state.currentSubStepIndex === 0) {\n setState((prev) => ({ ...prev, currentSubStepIndex: null }));\n return;\n }\n\n if (state.currentStepIndex > 0) {\n const prevIndex = state.currentStepIndex - 1;\n const prevStepObj = currentConfig.steps[prevIndex];\n const prevSubStepIndex = prevStepObj.subSteps ? prevStepObj.subSteps.length - 1 : null;\n\n setState({\n currentStepIndex: prevIndex,\n currentSubStepIndex: prevSubStepIndex,\n isActive: true,\n });\n }\n }, [state.currentStepIndex, state.currentSubStepIndex]);\n\n const finish = useCallback(() => {\n setState((prev) => ({ ...prev, isActive: false }));\n if (configRef.current.onOnboardingComplete) {\n configRef.current.onOnboardingComplete();\n }\n }, []);\n\n const goToStep = useCallback((stepIndex: number, subStepIndex: number | null = null) => {\n setState({\n currentStepIndex: stepIndex,\n currentSubStepIndex: subStepIndex,\n isActive: true,\n });\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 }\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\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 setDragOffset({ x: 0, y: 0 });\n }, [currentStep]);\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 // eslint-disable-next-line react-hooks/immutability\n window.removeEventListener('pointerup', handlePointerUp);\n }, [config.metadata.draggable, handlePointerMove]);\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 useEffect(() => {\n return () => {\n window.removeEventListener('pointermove', handlePointerMove);\n window.removeEventListener('pointerup', handlePointerUp);\n };\n }, [handlePointerMove, handlePointerUp]);\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 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 observer.disconnect();\n if (resizeObserver) resizeObserver.disconnect();\n };\n }, [updateCoords, currentStep?.attribute]);\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 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\n const 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\n const 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\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 finish();\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":";6kBAAA,IAAAA,GAAA,GAAAC,GAAAD,GAAA,wBAAAE,GAAA,kBAAAC,IAAA,eAAAC,GAAAJ,ICEA,IAAAK,EAQO,oBACPC,EAAoB,wBCTpB,IAAAC,EAAgE,iBAChEC,EAA6B,qBA+OvB,IAAAC,EAAA,6BA5OOC,EAA8B,IAAM,CAC/C,GAAM,CAAE,OAAAC,EAAQ,YAAAC,EAAa,SAAAC,EAAU,SAAAC,EAAU,OAAAC,EAAQ,YAAAC,EAAa,WAAAC,CAAW,EAC/EC,EAAc,EACV,CAACC,EAAQC,CAAS,KAAI,YAKlB,IAAI,EACR,CAACC,EAAUC,CAAW,KAAI,YAAwC,CAAE,IAAK,EAAG,KAAM,CAAE,CAAC,EACrF,CAACC,EAAYC,CAAa,KAAI,YAAmC,CAAE,EAAG,EAAG,EAAG,CAAE,CAAC,EAC/EC,KAAa,UAAO,EAAK,EACzBC,KAAY,UAAiC,CAAE,EAAG,EAAG,EAAG,CAAE,CAAC,EAC3DC,KAAa,UAAuB,IAAI,KAE9C,aAAU,IAAM,CACdH,EAAc,CAAE,EAAG,EAAG,EAAG,CAAE,CAAC,CAC9B,EAAG,CAACZ,CAAW,CAAC,EAEhB,IAAMgB,KAAoB,eAAaC,GAAoB,CACzD,GAAI,CAACJ,EAAW,QAAS,OAEzB,IAAMK,EAAOD,EA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,EAAYpC,EAAM,iBAAmB,EACrCqC,EAAczB,EAAc,MAAMwB,CAAS,EAC3CE,EAAmBD,EAAY,SAAWA,EAAY,SAAS,OAAS,EAAI,KAElFpC,EAAS,CACP,iBAAkBmC,EAClB,oBAAqBE,EACrB,SAAU,EACZ,CAAC,CACH,CACF,EAAG,CAACtC,EAAM,iBAAkBA,EAAM,mBAAmB,CAAC,EAEhDuC,KAAS,eAAY,IAAM,CAC/BtC,EAAUqB,IAAU,CAAE,GAAGA,EAAM,SAAU,EAAM,EAAE,EAC7CpB,EAAU,QAAQ,sBACpBA,EAAU,QAAQ,qBAAqB,CAE3C,EAAG,CAAC,CAAC,EAECsC,KAAW,eAAY,CAACC,EAAmBC,EAA8B,OAAS,CACtFzC,EAAS,CACP,iBAAkBwC,EAClB,oBAAqBC,EACrB,SAAU,EACZ,CAAC,CACH,EAAG,CAAC,CAAC,EAECC,EAAQ,CACZ,OAAAjD,EACA,MAAAM,EACA,SAAA6B,EACA,SAAAV,EACA,OAAAoB,EACA,SAAAC,EACA,YAAAjB,EACA,YAAAC,EACA,WAAAC,CACF,EAEA,OAAK3B,KAGH,QAACP,EAAkB,SAAlB,CAA2B,MAAOoD,EAChC,UAAA9C,EACAG,EAAM,aAAY,OAAC4C,EAAA,EAAkB,GACxC,KANqB,mBAAG,SAAA/C,EAAS,CAQrC,EAEagD,EAAgB,IAAM,CACjC,IAAMC,KAAU,cAAWvD,CAAiB,EAC5C,GAAIuD,IAAY,OACd,MAAM,IAAI,MAAM,yDAAyD,EAE3E,OAAOA,CACT","names":["index_exports","__export","OnboardingProvider","useOnboarding","__toCommonJS","import_react","import_js_cookie","import_react","import_react_dom","import_jsx_runtime","OnboardingOverlay","config","currentStep","nextStep","prevStep","finish","isFirstStep","isLastStep","useOnboarding","coords","setCoords","position","setPosition","dragOffset","setDragOffset","isDragging","dragStart","tooltipRef","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","ChevronLeftIcon","ChevronRightIcon","XIcon","overlayContent","import_jsx_runtime","OnboardingContext","COOKIE_NAME","OnboardingProvider","config","ssr","onNavigate","children","isMounted","setIsMounted","state","setState","configRef","React","onNavigateRef","handleNavigation","link","isMatch","step","path","pattern","onRestoreState","currentConfig","currentPath","matchedStepIndex","savedState","Cookies","parsed","targetUrl","prevStep","element","e","prev","currentStep","isFirstStep","isLastStep","totalSteps","isLastMainStep","hasSubSteps","nextStep","stepObj","currentActiveStep","nextSubIndex","nextSubStep","nextIndex","nextStepObj","prevIndex","prevStepObj","prevSubStepIndex","finish","goToStep","stepIndex","subStepIndex","value","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\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>({\n currentStepIndex: 0,\n currentSubStepIndex: null,\n isActive: true,\n });\n\n const configRef = useRef(config);\n const onNavigateRef = useRef(onNavigate);\n\n useEffect(() => {\n configRef.current = config;\n onNavigateRef.current = onNavigate;\n }, [config, onNavigate]);\n\n const handleNavigation = useCallback((link?: string) => {\n if (!link) return;\n\n if (onNavigateRef.current) {\n onNavigateRef.current(link);\n } else {\n window.location.href = link;\n }\n }, []);\n\n const isMatch = (step: OnboardingStep, path: string) => {\n if (step.urlMatch instanceof RegExp) return step.urlMatch.test(path);\n\n if (typeof step.urlMatch === 'string' && step.urlMatch.includes('*')) {\n const pattern = step.urlMatch.replace(/[.+?^${}()|[\\\\]/g, '\\\\$&').replace(/\\*/g, '.*');\n return new RegExp(`^${pattern}$`).test(path);\n }\n\n return path === step.urlMatch;\n };\n\n useEffect(() => {\n if (ssr) {\n // eslint-disable-next-line react-hooks/set-state-in-effect\n setIsMounted(true);\n }\n\n const currentConfig = configRef.current;\n const currentPath = window.location.pathname;\n let matchedStepIndex = -1;\n\n if ((currentConfig.metadata.inOrder as boolean | undefined) === false) {\n matchedStepIndex = currentConfig.steps.findIndex((step) => isMatch(step, currentPath));\n }\n\n const savedState = Cookies.get(COOKIE_NAME);\n if (savedState) {\n try {\n const parsed: OnboardingState = JSON.parse(savedState);\n\n if ((currentConfig.metadata.inOrder as boolean | undefined) === false) {\n if (matchedStepIndex !== -1) {\n if (parsed.currentStepIndex === matchedStepIndex) {\n setState(parsed);\n } else {\n setState({\n currentStepIndex: matchedStepIndex,\n currentSubStepIndex: null,\n isActive: true,\n });\n }\n } else {\n setState({ ...parsed, isActive: false });\n }\n } else {\n setState(parsed);\n\n if ((currentConfig.metadata.inOrder as boolean | undefined) !== false) {\n const step = currentConfig.steps[parsed.currentStepIndex];\n if (step && parsed.isActive) {\n let targetUrl: string | undefined;\n\n if (parsed.currentStepIndex > 0) {\n const prevStep = currentConfig.steps[parsed.currentStepIndex - 1];\n if (prevStep.navigate) {\n targetUrl = prevStep.navigate;\n }\n }\n\n if (!targetUrl && typeof step.urlMatch === 'string') {\n targetUrl = step.urlMatch;\n }\n\n if (targetUrl && window.location.pathname !== targetUrl) {\n handleNavigation(targetUrl);\n }\n\n if (currentConfig.metadata.simulateClicksOnNavigate) {\n if (parsed.currentSubStepIndex !== null && step.click) {\n setTimeout(() => {\n const element = document.querySelector(\n `[data-onboarding-id=\"${step.attribute}\"]`,\n ) as HTMLElement;\n if (element) {\n element.click();\n }\n }, 500);\n }\n }\n }\n }\n }\n } catch (e) {\n console.error('Failed to parse onboarding state from cookie', e);\n if (matchedStepIndex !== -1) {\n setState({\n currentStepIndex: matchedStepIndex,\n currentSubStepIndex: null,\n isActive: true,\n });\n }\n }\n } else if (matchedStepIndex !== -1) {\n setState({\n currentStepIndex: matchedStepIndex,\n currentSubStepIndex: null,\n isActive: true,\n });\n } else if ((currentConfig.metadata.inOrder as boolean | undefined) === false) {\n setState((prev) => ({ ...prev, isActive: false }));\n } else {\n const step = currentConfig.steps[0];\n if (step && typeof step.urlMatch === 'string' && window.location.pathname !== step.urlMatch) {\n handleNavigation(step.urlMatch);\n }\n }\n }, [ssr, handleNavigation]);\n\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 if (state.currentSubStepIndex !== null && step.subSteps) {\n return step.subSteps[state.currentSubStepIndex] || step;\n }\n return step;\n }, [config.steps, state.currentStepIndex, state.currentSubStepIndex]);\n\n const isFirstStep = state.currentStepIndex === 0 && state.currentSubStepIndex === null;\n const isLastStep = useMemo(() => {\n const totalSteps = config.steps.length;\n const isLastMainStep = state.currentStepIndex === totalSteps - 1;\n const step = config.steps[state.currentStepIndex];\n const hasSubSteps = step?.subSteps && step.subSteps.length > 0;\n\n if (isLastMainStep) {\n if (hasSubSteps) {\n return state.currentSubStepIndex === step.subSteps!.length - 1;\n }\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 stepObj = currentConfig.steps[state.currentStepIndex];\n const currentActiveStep =\n state.currentSubStepIndex !== null && stepObj.subSteps\n ? stepObj.subSteps[state.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) {\n element.click();\n }\n }\n\n if (\n stepObj.subSteps &&\n (state.currentSubStepIndex === null ||\n state.currentSubStepIndex < stepObj.subSteps.length - 1)\n ) {\n const nextSubIndex = state.currentSubStepIndex === null ? 0 : state.currentSubStepIndex + 1;\n const nextSubStep = stepObj.subSteps[nextSubIndex];\n setState((prev) => ({ ...prev, currentSubStepIndex: nextSubIndex }));\n\n if (nextSubStep.navigate) handleNavigation(nextSubStep.navigate);\n return;\n }\n\n if (state.currentStepIndex < currentConfig.steps.length - 1) {\n const nextIndex = state.currentStepIndex + 1;\n const nextStepObj = currentConfig.steps[nextIndex];\n setState({\n currentStepIndex: nextIndex,\n currentSubStepIndex: null,\n isActive: true,\n });\n\n if (nextStepObj.navigate) handleNavigation(nextStepObj.navigate);\n } else {\n setState((prev) => ({ ...prev, isActive: false }));\n if (currentConfig.onOnboardingComplete) {\n currentConfig.onOnboardingComplete();\n }\n }\n }, [state.currentStepIndex, state.currentSubStepIndex, handleNavigation]);\n\n const prevStep = useCallback(() => {\n const currentConfig = configRef.current;\n\n if (state.currentSubStepIndex !== null && state.currentSubStepIndex > 0) {\n setState((prev) => ({ ...prev, currentSubStepIndex: prev.currentSubStepIndex! - 1 }));\n return;\n }\n\n if (state.currentStepIndex > 0 && state.currentSubStepIndex === 0) {\n setState((prev) => ({ ...prev, currentSubStepIndex: null }));\n return;\n }\n\n if (state.currentStepIndex > 0) {\n const prevIndex = state.currentStepIndex - 1;\n const prevStepObj = currentConfig.steps[prevIndex];\n const prevSubStepIndex = prevStepObj.subSteps ? prevStepObj.subSteps.length - 1 : null;\n\n setState({\n currentStepIndex: prevIndex,\n currentSubStepIndex: prevSubStepIndex,\n isActive: true,\n });\n }\n }, [state.currentStepIndex, state.currentSubStepIndex]);\n\n const finish = useCallback(() => {\n setState((prev) => ({ ...prev, isActive: false }));\n if (configRef.current.onOnboardingComplete) {\n configRef.current.onOnboardingComplete();\n }\n }, []);\n\n const goToStep = useCallback((stepIndex: number, subStepIndex: number | null = null) => {\n setState({\n currentStepIndex: stepIndex,\n currentSubStepIndex: subStepIndex,\n isActive: true,\n });\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 }\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 // Reset drag offset when step changes\n const [prevStepRef, setPrevStepRef] = useState(currentStep);\n if (currentStep !== prevStepRef) {\n setPrevStepRef(currentStep);\n setDragOffset({ x: 0, y: 0 });\n }\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 finish();\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":";4kBAAA,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,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,CAEA,GAAIpB,EAAM,iBAAmB,GAAKA,EAAM,sBAAwB,EAAG,CACjEC,EAAUmB,IAAU,CAAE,GAAGA,EAAM,oBAAqB,IAAK,EAAE,EAC3D,MACF,CAEA,GAAIpB,EAAM,iBAAmB,EAAG,CAC9B,IAAMkC,EAAYlC,EAAM,iBAAmB,EACrCmC,EAAczB,EAAc,MAAMwB,CAAS,EAC3CE,EAAmBD,EAAY,SAAWA,EAAY,SAAS,OAAS,EAAI,KAElFlC,EAAS,CACP,iBAAkBiC,EAClB,oBAAqBE,EACrB,SAAU,EACZ,CAAC,CACH,CACF,EAAG,CAACpC,EAAM,iBAAkBA,EAAM,mBAAmB,CAAC,EAEhDqC,KAAS,eAAY,IAAM,CAC/BpC,EAAUmB,IAAU,CAAE,GAAGA,EAAM,SAAU,EAAM,EAAE,EAC7ClB,EAAU,QAAQ,sBACpBA,EAAU,QAAQ,qBAAqB,CAE3C,EAAG,CAAC,CAAC,EAECoC,KAAW,eAAY,CAACC,EAAmBC,EAA8B,OAAS,CACtFvC,EAAS,CACP,iBAAkBsC,EAClB,oBAAqBC,EACrB,SAAU,EACZ,CAAC,CACH,EAAG,CAAC,CAAC,EAECC,EAAQ,CACZ,OAAA/C,EACA,MAAAM,EACA,SAAA2B,EACA,SAAAV,EACA,OAAAoB,EACA,SAAAC,EACA,YAAAjB,EACA,YAAAC,EACA,WAAAC,CACF,EAEA,OAAKzB,KAGH,QAACP,EAAkB,SAAlB,CAA2B,MAAOkD,EAChC,UAAA5C,EACAG,EAAM,aAAY,OAAC0C,EAAA,EAAkB,GACxC,KANqB,mBAAG,SAAA7C,EAAS,CAQrC,EAEa8C,EAAgB,IAAM,CACjC,IAAMC,KAAU,cAAWrD,CAAiB,EAC5C,GAAIqD,IAAY,OACd,MAAM,IAAI,MAAM,yDAAyD,EAE3E,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","prevStepRef","setPrevStepRef","handlePointerUpRef","handlePointerMove","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","OnboardingProvider","config","ssr","onNavigate","children","isMounted","setIsMounted","state","setState","configRef","onNavigateRef","handleNavigation","link","isMatch","step","path","pattern","currentConfig","currentPath","matchedStepIndex","savedState","Cookies","parsed","targetUrl","prevStep","element","e","prev","currentStep","isFirstStep","isLastStep","totalSteps","isLastMainStep","hasSubSteps","nextStep","stepObj","currentActiveStep","nextSubIndex","nextSubStep","nextIndex","nextStepObj","prevIndex","prevStepObj","prevSubStepIndex","finish","goToStep","stepIndex","subStepIndex","value","OnboardingOverlay","useOnboarding","context"]}
package/dist/index.mjs CHANGED
@@ -1,3 +1,3 @@
1
1
  "use client";
2
- "use client";import J,{createContext as nt,useContext as ot,useEffect as A,useState as U,useCallback as H,useMemo as _,useEffectEvent as rt}from"react";import K from"js-cookie";import{useState as F,useEffect as B,useCallback as T,useRef as X}from"react";import{createPortal as et}from"react-dom";import{jsx as u,jsxs as w}from"react/jsx-runtime";var Y=()=>{let{config:i,currentStep:c,nextStep:L,prevStep:W,finish:y,isFirstStep:m,isLastStep:o}=q(),[r,f]=F(null),[I,x]=F({top:0,left:0}),[O,D]=F({x:0,y:0}),R=X(!1),z=X({x:0,y:0}),h=X(null);B(()=>{D({x:0,y:0})},[c]);let v=T(t=>{if(!R.current)return;let d=t.clientX-z.current.x,p=t.clientY-z.current.y;D({x:d,y:p})},[]),k=T(()=>{R.current=!1,h.current&&(h.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)",h.current.style.cursor=i.metadata.draggable?"grab":"auto"),window.removeEventListener("pointermove",v),window.removeEventListener("pointerup",k)},[i.metadata.draggable,v]),j=t=>{i.metadata.draggable&&(t.stopPropagation(),t.preventDefault(),R.current=!0,z.current={x:t.clientX-O.x,y:t.clientY-O.y},h.current&&(h.current.style.transition="none",h.current.style.cursor="grabbing"),window.addEventListener("pointermove",v),window.addEventListener("pointerup",k))};B(()=>()=>{window.removeEventListener("pointermove",v),window.removeEventListener("pointerup",k)},[v,k]);let $=T(t=>{let N=t.top,b=window.innerHeight-t.bottom,Z=t.left,tt=window.innerWidth-t.right,P=0,E=0;return b>232?(P=t.bottom+12,E=Math.max(20,Math.min(window.innerWidth-300-20,t.left+t.width/2-300/2))):N>232?(P=t.top-200-12,E=Math.max(20,Math.min(window.innerWidth-300-20,t.left+t.width/2-300/2))):tt>332?(P=Math.max(20,Math.min(window.innerHeight-200-20,t.top+t.height/2-200/2)),E=t.right+12):Z>332?(P=Math.max(20,Math.min(window.innerHeight-200-20,t.top+t.height/2-200/2)),E=t.left-300-12):(P=window.innerHeight/2-200/2,E=window.innerWidth/2-300/2),{top:P+window.scrollY,left:E+window.scrollX}},[]),g=T(()=>{if(!c)return;let t=document.querySelector(`[data-onboarding-id="${c.attribute}"]`);if(t){let d=t.getBoundingClientRect(),p=i.style?.padding||0,C={top:d.top-p,bottom:d.bottom+p,left:d.left-p,right:d.right+p,width:d.width+p*2,height:d.height+p*2},M={top:C.top+window.scrollY,left:C.left+window.scrollX,width:C.width,height:C.height},N=$(C);f(b=>b&&b.top===M.top&&b.left===M.left&&b.width===M.width&&b.height===M.height?b:M),x(b=>b.top===N.top&&b.left===N.left?b:N)}else f(null)},[c,$,i.style]);if(B(()=>{g(),window.addEventListener("resize",g),window.addEventListener("scroll",g);let t=new MutationObserver(g);t.observe(document.body,{childList:!0,subtree:!0,attributes:!0});let d=null;if(typeof ResizeObserver<"u"){d=new ResizeObserver(g),d.observe(document.body);let p=c?.attribute?document.querySelector(`[data-onboarding-id="${c.attribute}"]`):null;p&&d.observe(p)}return()=>{window.removeEventListener("resize",g),window.removeEventListener("scroll",g),t.disconnect(),d&&d.disconnect()}},[g,c?.attribute]),!c||!r)return null;let e={...i.style?.background,transition:"all 0.3s cubic-bezier(0.25, 0.1, 0.25, 1)"},n=t=>{t.stopPropagation()},a=()=>u("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:u("path",{d:"M15 18l-6-6 6-6"})}),l=()=>u("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:u("path",{d:"M9 18l6-6-6-6"})}),s=()=>w("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),u("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]}),S=w("div",{className:"onboard-overlay-container",children:[u("div",{style:{height:r.top,...e},className:"onboard-overlay-mask onboard-mask-top",onPointerDown:n,onMouseDown:n,onClick:n}),u("div",{style:{top:r.top+r.height,height:`calc(100vh - ${r.top+r.height}px)`,...e},className:"onboard-overlay-mask onboard-mask-bottom",onPointerDown:n,onMouseDown:n,onClick:n}),u("div",{style:{top:r.top,height:r.height,width:r.left,...e},className:"onboard-overlay-mask onboard-mask-left",onPointerDown:n,onMouseDown:n,onClick:n}),u("div",{style:{top:r.top,height:r.height,left:r.left+r.width,width:`calc(100% - ${r.left+r.width}px)`,...e},className:"onboard-overlay-mask",onPointerDown:n,onMouseDown:n,onClick:n}),w("div",{ref:h,className:"onboard-tooltip",onPointerDown:j,style:{zIndex:1e6,...i.style?.container,top:I.top+O.y,left:I.left+O.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:i.metadata.draggable?"grab":"auto",touchAction:"none"},onMouseDown:n,onClick:n,children:[w("div",{className:"onboard-tooltip-header",children:[u("h3",{className:"onboard-tooltip-title",children:c.title}),u("button",{onClick:t=>{t.stopPropagation(),y()},className:"onboard-close-button",children:u(s,{})})]}),u("p",{className:"onboard-tooltip-description",children:c.description}),w("div",{className:"onboard-tooltip-footer",children:[w("button",{onClick:t=>{t.stopPropagation(),W()},disabled:m,className:"onboard-button-ghost",style:{background:"none",border:"none",cursor:m?"not-allowed":"pointer",...i.style?.prev},children:[u(a,{}),"Prev"]}),o?u("button",{onClick:t=>{t.stopPropagation(),y()},className:"onboard-button-primary",style:{border:"none",cursor:"pointer",...i.style?.finish},children:"Finish"}):w("button",{onClick:t=>{t.stopPropagation(),L()},className:"onboard-button-primary",style:{border:"none",cursor:"pointer",...m?i.style?.start:{},...m?{}:i.style?.next},children:[m&&i.style?.start?"Start":"Next",!(m&&i.style?.start)&&u(l,{})]})]})]})]});return typeof document<"u"?et(S,document.body):null};import{Fragment as it,jsx as Q,jsxs as st}from"react/jsx-runtime";var V=nt(void 0),G="onboarding_state",mt=({config:i,ssr:c=!1,onNavigate:L,children:W})=>{let[y,m]=U(!c),[o,r]=U({currentStepIndex:0,currentSubStepIndex:null,isActive:!0}),f=J.useRef(i);A(()=>{f.current=i},[i]);let I=J.useRef(L);A(()=>{I.current=L},[L]);let x=H(e=>{e&&(I.current?I.current(e):(i.metadata.nextRouter,window.location.href=e))},[i.metadata.nextRouter]);A(()=>{c&&m(!0)},[c]);let O=(e,n)=>{if(e.urlMatch instanceof RegExp)return e.urlMatch.test(n);if(typeof e.urlMatch=="string"&&e.urlMatch.includes("*")){let a=e.urlMatch.replace(/[.+?^${}()|[\\]/g,"\\$&").replace(/\*/g,".*");return new RegExp(`^${a}$`).test(n)}return n===e.urlMatch},D=rt(()=>{let e=f.current,n=window.location.pathname,a=-1;e.metadata.inOrder===!1&&(a=e.steps.findIndex(s=>O(s,n)));let l=K.get(G);if(l)try{let s=JSON.parse(l);if(e.metadata.inOrder===!1)a!==-1?s.currentStepIndex===a?r(s):r({currentStepIndex:a,currentSubStepIndex:null,isActive:!0}):r({...s,isActive:!1});else if(r(s),e.metadata.inOrder!==!1){let S=e.steps[s.currentStepIndex];if(S&&s.isActive){let t;if(s.currentStepIndex>0){let d=e.steps[s.currentStepIndex-1];d.navigate&&(t=d.navigate)}!t&&typeof S.urlMatch=="string"&&(t=S.urlMatch),t&&window.location.pathname!==t&&x(t),e.metadata.simulateClicksOnNavigate&&s.currentSubStepIndex!==null&&S.click&&setTimeout(()=>{let d=document.querySelector(`[data-onboarding-id="${S.attribute}"]`);d&&d.click()},500)}}}catch(s){console.error("Failed to parse onboarding state from cookie",s),a!==-1&&r({currentStepIndex:a,currentSubStepIndex:null,isActive:!0})}else if(a!==-1)r({currentStepIndex:a,currentSubStepIndex:null,isActive:!0});else if(e.metadata.inOrder===!1)r(s=>({...s,isActive:!1}));else{let s=e.steps[0];s&&typeof s.urlMatch=="string"&&window.location.pathname!==s.urlMatch&&x(s.urlMatch)}});A(()=>{D()},[]),A(()=>{y&&K.set(G,JSON.stringify(o),{expires:365})},[o,y]);let R=_(()=>{let e=i.steps[o.currentStepIndex];return e?o.currentSubStepIndex!==null&&e.subSteps&&e.subSteps[o.currentSubStepIndex]||e:null},[i.steps,o.currentStepIndex,o.currentSubStepIndex]),z=o.currentStepIndex===0&&o.currentSubStepIndex===null,h=_(()=>{let e=i.steps.length,n=o.currentStepIndex===e-1,a=i.steps[o.currentStepIndex],l=a?.subSteps&&a.subSteps.length>0;return n?l?o.currentSubStepIndex===a.subSteps.length-1:!0:!1},[i.steps,o.currentStepIndex,o.currentSubStepIndex]),v=H(()=>{let e=f.current,n=e.steps[o.currentStepIndex],a=o.currentSubStepIndex!==null&&n.subSteps?n.subSteps[o.currentSubStepIndex]:n;if(a.click){let l=document.querySelector(`[data-onboarding-id="${a.attribute}"]`);l&&l.click()}if(n.subSteps&&(o.currentSubStepIndex===null||o.currentSubStepIndex<n.subSteps.length-1)){let l=o.currentSubStepIndex===null?0:o.currentSubStepIndex+1,s=n.subSteps[l];r(S=>({...S,currentSubStepIndex:l})),s.navigate&&x(s.navigate);return}if(o.currentStepIndex<e.steps.length-1){let l=o.currentStepIndex+1,s=e.steps[l];r({currentStepIndex:l,currentSubStepIndex:null,isActive:!0}),s.navigate&&x(s.navigate)}else r(l=>({...l,isActive:!1})),e.onOnboardingComplete&&e.onOnboardingComplete()},[o.currentStepIndex,o.currentSubStepIndex,x]),k=H(()=>{let e=f.current;if(o.currentSubStepIndex!==null&&o.currentSubStepIndex>0){r(n=>({...n,currentSubStepIndex:n.currentSubStepIndex-1}));return}if(o.currentStepIndex>0&&o.currentSubStepIndex===0){r(n=>({...n,currentSubStepIndex:null}));return}if(o.currentStepIndex>0){let n=o.currentStepIndex-1,a=e.steps[n],l=a.subSteps?a.subSteps.length-1:null;r({currentStepIndex:n,currentSubStepIndex:l,isActive:!0})}},[o.currentStepIndex,o.currentSubStepIndex]),j=H(()=>{r(e=>({...e,isActive:!1})),f.current.onOnboardingComplete&&f.current.onOnboardingComplete()},[]),$=H((e,n=null)=>{r({currentStepIndex:e,currentSubStepIndex:n,isActive:!0})},[]),g={config:i,state:o,nextStep:v,prevStep:k,finish:j,goToStep:$,currentStep:R,isFirstStep:z,isLastStep:h};return y?st(V.Provider,{value:g,children:[W,o.isActive&&Q(Y,{})]}):Q(it,{children:W})},q=()=>{let i=ot(V);if(i===void 0)throw new Error("useOnboarding must be used within an OnboardingProvider");return i};export{mt as OnboardingProvider,q as useOnboarding};
2
+ "use client";import{createContext as it,useContext as st,useEffect as B,useState as U,useCallback as N,useMemo as J,useRef as _}from"react";import K from"js-cookie";import{useState as D,useEffect as X,useCallback as $,useRef as T}from"react";import{createPortal as et}from"react-dom";import{jsx as u,jsxs as w}from"react/jsx-runtime";var nt=()=>u("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:u("path",{d:"M15 18l-6-6 6-6"})}),ot=()=>u("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:u("path",{d:"M9 18l6-6-6-6"})}),rt=()=>w("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),u("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]}),Y=()=>{let{config:i,currentStep:c,nextStep:L,prevStep:A,finish:y,isFirstStep:S,isLastStep:n}=q(),[o,f]=D(null),[I,m]=D({top:0,left:0}),[k,H]=D({x:0,y:0}),R=T(!1),E=T({x:0,y:0}),h=T(null),[j,F]=D(c);c!==j&&(F(c),H({x:0,y:0}));let W=T(()=>{}),v=$(e=>{if(!R.current)return;let p=e.clientX-E.current.x,b=e.clientY-E.current.y;H({x:p,y:b})},[]),t=$(()=>{R.current=!1,h.current&&(h.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)",h.current.style.cursor=i.metadata.draggable?"grab":"auto"),window.removeEventListener("pointermove",v),window.removeEventListener("pointerup",W.current)},[i.metadata.draggable,v]);X(()=>{W.current=t},[t]);let s=e=>{i.metadata.draggable&&(e.stopPropagation(),e.preventDefault(),R.current=!0,E.current={x:e.clientX-k.x,y:e.clientY-k.y},h.current&&(h.current.style.transition="none",h.current.style.cursor="grabbing"),window.addEventListener("pointermove",v),window.addEventListener("pointerup",t))},d=$(e=>{let z=e.top,g=window.innerHeight-e.bottom,Z=e.left,tt=window.innerWidth-e.right,M=0,P=0;return g>232?(M=e.bottom+12,P=Math.max(20,Math.min(window.innerWidth-300-20,e.left+e.width/2-300/2))):z>232?(M=e.top-200-12,P=Math.max(20,Math.min(window.innerWidth-300-20,e.left+e.width/2-300/2))):tt>332?(M=Math.max(20,Math.min(window.innerHeight-200-20,e.top+e.height/2-200/2)),P=e.right+12):Z>332?(M=Math.max(20,Math.min(window.innerHeight-200-20,e.top+e.height/2-200/2)),P=e.left-300-12):(M=window.innerHeight/2-200/2,P=window.innerWidth/2-300/2),{top:M+window.scrollY,left:P+window.scrollX}},[]),a=$(()=>{if(!c)return;let e=document.querySelector(`[data-onboarding-id="${c.attribute}"]`);if(e){let p=e.getBoundingClientRect(),b=i.style?.padding||0,O={top:p.top-b,bottom:p.bottom+b,left:p.left-b,right:p.right+b,width:p.width+b*2,height:p.height+b*2},C={top:O.top+window.scrollY,left:O.left+window.scrollX,width:O.width,height:O.height},z=d(O);f(g=>g&&g.top===C.top&&g.left===C.left&&g.width===C.width&&g.height===C.height?g:C),m(g=>g.top===z.top&&g.left===z.left?g:z)}else f(null)},[c,d,i.style]);if(X(()=>{a(),window.addEventListener("resize",a),window.addEventListener("scroll",a);let e=new MutationObserver(a);e.observe(document.body,{childList:!0,subtree:!0,attributes:!0});let p=null;if(typeof ResizeObserver<"u"){p=new ResizeObserver(a),p.observe(document.body);let b=c?.attribute?document.querySelector(`[data-onboarding-id="${c.attribute}"]`):null;b&&p.observe(b)}return()=>{window.removeEventListener("resize",a),window.removeEventListener("scroll",a),window.removeEventListener("pointermove",v),window.removeEventListener("pointerup",t),e.disconnect(),p&&p.disconnect()}},[a,c?.attribute,v,t]),!c||!o)return null;let r={...i.style?.background,transition:"all 0.3s cubic-bezier(0.25, 0.1, 0.25, 1)"},l=e=>{e.stopPropagation()},x=w("div",{className:"onboard-overlay-container",children:[u("div",{style:{height:o.top,...r},className:"onboard-overlay-mask onboard-mask-top",onPointerDown:l,onMouseDown:l,onClick:l}),u("div",{style:{top:o.top+o.height,height:`calc(100vh - ${o.top+o.height}px)`,...r},className:"onboard-overlay-mask onboard-mask-bottom",onPointerDown:l,onMouseDown:l,onClick:l}),u("div",{style:{top:o.top,height:o.height,width:o.left,...r},className:"onboard-overlay-mask onboard-mask-left",onPointerDown:l,onMouseDown:l,onClick:l}),u("div",{style:{top:o.top,height:o.height,left:o.left+o.width,width:`calc(100% - ${o.left+o.width}px)`,...r},className:"onboard-overlay-mask",onPointerDown:l,onMouseDown:l,onClick:l}),w("div",{ref:h,className:"onboard-tooltip",onPointerDown:s,style:{zIndex:1e6,...i.style?.container,top:I.top+k.y,left:I.left+k.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:i.metadata.draggable?"grab":"auto",touchAction:"none"},onMouseDown:l,onClick:l,children:[w("div",{className:"onboard-tooltip-header",children:[u("h3",{className:"onboard-tooltip-title",children:c.title}),u("button",{onClick:e=>{e.stopPropagation(),y()},className:"onboard-close-button",children:u(rt,{})})]}),u("p",{className:"onboard-tooltip-description",children:c.description}),w("div",{className:"onboard-tooltip-footer",children:[w("button",{onClick:e=>{e.stopPropagation(),A()},disabled:S,className:"onboard-button-ghost",style:{background:"none",border:"none",cursor:S?"not-allowed":"pointer",...i.style?.prev},children:[u(nt,{}),"Prev"]}),n?u("button",{onClick:e=>{e.stopPropagation(),y()},className:"onboard-button-primary",style:{border:"none",cursor:"pointer",...i.style?.finish},children:"Finish"}):w("button",{onClick:e=>{e.stopPropagation(),L()},className:"onboard-button-primary",style:{border:"none",cursor:"pointer",...S?i.style?.start:{},...S?{}:i.style?.next},children:[S&&i.style?.start?"Start":"Next",!(S&&i.style?.start)&&u(ot,{})]})]})]})]});return typeof document<"u"?et(x,document.body):null};import{Fragment as at,jsx as Q,jsxs as dt}from"react/jsx-runtime";var V=it(void 0),G="onboarding_state",wt=({config:i,ssr:c=!1,onNavigate:L,children:A})=>{let[y,S]=U(!c),[n,o]=U({currentStepIndex:0,currentSubStepIndex:null,isActive:!0}),f=_(i),I=_(L);B(()=>{f.current=i,I.current=L},[i,L]);let m=N(t=>{t&&(I.current?I.current(t):window.location.href=t)},[]),k=(t,s)=>{if(t.urlMatch instanceof RegExp)return t.urlMatch.test(s);if(typeof t.urlMatch=="string"&&t.urlMatch.includes("*")){let d=t.urlMatch.replace(/[.+?^${}()|[\\]/g,"\\$&").replace(/\*/g,".*");return new RegExp(`^${d}$`).test(s)}return s===t.urlMatch};B(()=>{c&&S(!0);let t=f.current,s=window.location.pathname,d=-1;t.metadata.inOrder===!1&&(d=t.steps.findIndex(r=>k(r,s)));let a=K.get(G);if(a)try{let r=JSON.parse(a);if(t.metadata.inOrder===!1)d!==-1?r.currentStepIndex===d?o(r):o({currentStepIndex:d,currentSubStepIndex:null,isActive:!0}):o({...r,isActive:!1});else if(o(r),t.metadata.inOrder!==!1){let l=t.steps[r.currentStepIndex];if(l&&r.isActive){let x;if(r.currentStepIndex>0){let e=t.steps[r.currentStepIndex-1];e.navigate&&(x=e.navigate)}!x&&typeof l.urlMatch=="string"&&(x=l.urlMatch),x&&window.location.pathname!==x&&m(x),t.metadata.simulateClicksOnNavigate&&r.currentSubStepIndex!==null&&l.click&&setTimeout(()=>{let e=document.querySelector(`[data-onboarding-id="${l.attribute}"]`);e&&e.click()},500)}}}catch(r){console.error("Failed to parse onboarding state from cookie",r),d!==-1&&o({currentStepIndex:d,currentSubStepIndex:null,isActive:!0})}else if(d!==-1)o({currentStepIndex:d,currentSubStepIndex:null,isActive:!0});else if(t.metadata.inOrder===!1)o(r=>({...r,isActive:!1}));else{let r=t.steps[0];r&&typeof r.urlMatch=="string"&&window.location.pathname!==r.urlMatch&&m(r.urlMatch)}},[c,m]),B(()=>{y&&K.set(G,JSON.stringify(n),{expires:365})},[n,y]);let H=J(()=>{let t=i.steps[n.currentStepIndex];return t?n.currentSubStepIndex!==null&&t.subSteps&&t.subSteps[n.currentSubStepIndex]||t:null},[i.steps,n.currentStepIndex,n.currentSubStepIndex]),R=n.currentStepIndex===0&&n.currentSubStepIndex===null,E=J(()=>{let t=i.steps.length,s=n.currentStepIndex===t-1,d=i.steps[n.currentStepIndex],a=d?.subSteps&&d.subSteps.length>0;return s?a?n.currentSubStepIndex===d.subSteps.length-1:!0:!1},[i.steps,n.currentStepIndex,n.currentSubStepIndex]),h=N(()=>{let t=f.current,s=t.steps[n.currentStepIndex],d=n.currentSubStepIndex!==null&&s.subSteps?s.subSteps[n.currentSubStepIndex]:s;if(d.click){let a=document.querySelector(`[data-onboarding-id="${d.attribute}"]`);a&&a.click()}if(s.subSteps&&(n.currentSubStepIndex===null||n.currentSubStepIndex<s.subSteps.length-1)){let a=n.currentSubStepIndex===null?0:n.currentSubStepIndex+1,r=s.subSteps[a];o(l=>({...l,currentSubStepIndex:a})),r.navigate&&m(r.navigate);return}if(n.currentStepIndex<t.steps.length-1){let a=n.currentStepIndex+1,r=t.steps[a];o({currentStepIndex:a,currentSubStepIndex:null,isActive:!0}),r.navigate&&m(r.navigate)}else o(a=>({...a,isActive:!1})),t.onOnboardingComplete&&t.onOnboardingComplete()},[n.currentStepIndex,n.currentSubStepIndex,m]),j=N(()=>{let t=f.current;if(n.currentSubStepIndex!==null&&n.currentSubStepIndex>0){o(s=>({...s,currentSubStepIndex:s.currentSubStepIndex-1}));return}if(n.currentStepIndex>0&&n.currentSubStepIndex===0){o(s=>({...s,currentSubStepIndex:null}));return}if(n.currentStepIndex>0){let s=n.currentStepIndex-1,d=t.steps[s],a=d.subSteps?d.subSteps.length-1:null;o({currentStepIndex:s,currentSubStepIndex:a,isActive:!0})}},[n.currentStepIndex,n.currentSubStepIndex]),F=N(()=>{o(t=>({...t,isActive:!1})),f.current.onOnboardingComplete&&f.current.onOnboardingComplete()},[]),W=N((t,s=null)=>{o({currentStepIndex:t,currentSubStepIndex:s,isActive:!0})},[]),v={config:i,state:n,nextStep:h,prevStep:j,finish:F,goToStep:W,currentStep:H,isFirstStep:R,isLastStep:E};return y?dt(V.Provider,{value:v,children:[A,n.isActive&&Q(Y,{})]}):Q(at,{children:A})},q=()=>{let i=st(V);if(i===void 0)throw new Error("useOnboarding must be used within an OnboardingProvider");return i};export{wt as OnboardingProvider,q 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 useEffectEvent,\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\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>({\n currentStepIndex: 0,\n currentSubStepIndex: null,\n isActive: true,\n });\n\n const configRef = React.useRef(config);\n useEffect(() => {\n configRef.current = config;\n }, [config]);\n\n const onNavigateRef = React.useRef(onNavigate);\n useEffect(() => {\n onNavigateRef.current = onNavigate;\n }, [onNavigate]);\n\n const handleNavigation = useCallback(\n (link?: string) => {\n if (!link) return;\n\n if (onNavigateRef.current) {\n onNavigateRef.current(link);\n } else if (config.metadata.nextRouter) {\n window.location.href = link;\n } else {\n window.location.href = link;\n }\n },\n [config.metadata.nextRouter],\n );\n\n useEffect(() => {\n if (ssr) {\n // eslint-disable-next-line react-hooks/set-state-in-effect\n setIsMounted(true);\n }\n }, [ssr]);\n\n const isMatch = (step: OnboardingStep, path: string) => {\n if (step.urlMatch instanceof RegExp) return step.urlMatch.test(path);\n\n if (typeof step.urlMatch === 'string' && step.urlMatch.includes('*')) {\n const pattern = step.urlMatch.replace(/[.+?^${}()|[\\\\]/g, '\\\\$&').replace(/\\*/g, '.*');\n return new RegExp(`^${pattern}$`).test(path);\n }\n\n return path === step.urlMatch;\n };\n\n const onRestoreState = useEffectEvent(() => {\n const currentConfig = configRef.current;\n const currentPath = window.location.pathname;\n let matchedStepIndex = -1;\n\n if ((currentConfig.metadata.inOrder as boolean | undefined) === false) {\n matchedStepIndex = currentConfig.steps.findIndex((step) => isMatch(step, currentPath));\n }\n\n const savedState = Cookies.get(COOKIE_NAME);\n if (savedState) {\n try {\n const parsed: OnboardingState = JSON.parse(savedState);\n\n if ((currentConfig.metadata.inOrder as boolean | undefined) === false) {\n if (matchedStepIndex !== -1) {\n if (parsed.currentStepIndex === matchedStepIndex) {\n setState(parsed);\n } else {\n setState({\n currentStepIndex: matchedStepIndex,\n currentSubStepIndex: null,\n isActive: true,\n });\n }\n } else {\n setState({ ...parsed, isActive: false });\n }\n } else {\n setState(parsed);\n\n if ((currentConfig.metadata.inOrder as boolean | undefined) !== false) {\n const step = currentConfig.steps[parsed.currentStepIndex];\n if (step && parsed.isActive) {\n let targetUrl: string | undefined;\n\n if (parsed.currentStepIndex > 0) {\n const prevStep = currentConfig.steps[parsed.currentStepIndex - 1];\n if (prevStep.navigate) {\n targetUrl = prevStep.navigate;\n }\n }\n\n if (!targetUrl && typeof step.urlMatch === 'string') {\n targetUrl = step.urlMatch;\n }\n\n if (targetUrl && window.location.pathname !== targetUrl) {\n handleNavigation(targetUrl);\n }\n\n if (currentConfig.metadata.simulateClicksOnNavigate) {\n if (parsed.currentSubStepIndex !== null && step.click) {\n setTimeout(() => {\n const element = document.querySelector(\n `[data-onboarding-id=\"${step.attribute}\"]`,\n ) as HTMLElement;\n if (element) {\n element.click();\n }\n }, 500);\n }\n }\n }\n }\n }\n } catch (e) {\n console.error('Failed to parse onboarding state from cookie', e);\n if (matchedStepIndex !== -1) {\n setState({\n currentStepIndex: matchedStepIndex,\n currentSubStepIndex: null,\n isActive: true,\n });\n }\n }\n } else if (matchedStepIndex !== -1) {\n setState({\n currentStepIndex: matchedStepIndex,\n currentSubStepIndex: null,\n isActive: true,\n });\n } else if ((currentConfig.metadata.inOrder as boolean | undefined) === false) {\n setState((prev) => ({ ...prev, isActive: false }));\n } else {\n const step = currentConfig.steps[0];\n if (step && typeof step.urlMatch === 'string' && window.location.pathname !== step.urlMatch) {\n handleNavigation(step.urlMatch);\n }\n }\n });\n\n useEffect(() => {\n onRestoreState();\n }, []);\n\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 if (state.currentSubStepIndex !== null && step.subSteps) {\n return step.subSteps[state.currentSubStepIndex] || step;\n }\n return step;\n }, [config.steps, state.currentStepIndex, state.currentSubStepIndex]);\n\n const isFirstStep = state.currentStepIndex === 0 && state.currentSubStepIndex === null;\n const isLastStep = useMemo(() => {\n const totalSteps = config.steps.length;\n const isLastMainStep = state.currentStepIndex === totalSteps - 1;\n const step = config.steps[state.currentStepIndex];\n const hasSubSteps = step?.subSteps && step.subSteps.length > 0;\n\n if (isLastMainStep) {\n if (hasSubSteps) {\n return state.currentSubStepIndex === step.subSteps!.length - 1;\n }\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 stepObj = currentConfig.steps[state.currentStepIndex];\n const currentActiveStep =\n state.currentSubStepIndex !== null && stepObj.subSteps\n ? stepObj.subSteps[state.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) {\n element.click();\n }\n }\n\n if (\n stepObj.subSteps &&\n (state.currentSubStepIndex === null ||\n state.currentSubStepIndex < stepObj.subSteps.length - 1)\n ) {\n const nextSubIndex = state.currentSubStepIndex === null ? 0 : state.currentSubStepIndex + 1;\n const nextSubStep = stepObj.subSteps[nextSubIndex];\n setState((prev) => ({ ...prev, currentSubStepIndex: nextSubIndex }));\n\n if (nextSubStep.navigate) handleNavigation(nextSubStep.navigate);\n return;\n }\n\n if (state.currentStepIndex < currentConfig.steps.length - 1) {\n const nextIndex = state.currentStepIndex + 1;\n const nextStepObj = currentConfig.steps[nextIndex];\n setState({\n currentStepIndex: nextIndex,\n currentSubStepIndex: null,\n isActive: true,\n });\n\n if (nextStepObj.navigate) handleNavigation(nextStepObj.navigate);\n } else {\n setState((prev) => ({ ...prev, isActive: false }));\n if (currentConfig.onOnboardingComplete) {\n currentConfig.onOnboardingComplete();\n }\n }\n }, [state.currentStepIndex, state.currentSubStepIndex, handleNavigation]);\n\n const prevStep = useCallback(() => {\n const currentConfig = configRef.current;\n\n if (state.currentSubStepIndex !== null && state.currentSubStepIndex > 0) {\n setState((prev) => ({ ...prev, currentSubStepIndex: prev.currentSubStepIndex! - 1 }));\n return;\n }\n\n if (state.currentStepIndex > 0 && state.currentSubStepIndex === 0) {\n setState((prev) => ({ ...prev, currentSubStepIndex: null }));\n return;\n }\n\n if (state.currentStepIndex > 0) {\n const prevIndex = state.currentStepIndex - 1;\n const prevStepObj = currentConfig.steps[prevIndex];\n const prevSubStepIndex = prevStepObj.subSteps ? prevStepObj.subSteps.length - 1 : null;\n\n setState({\n currentStepIndex: prevIndex,\n currentSubStepIndex: prevSubStepIndex,\n isActive: true,\n });\n }\n }, [state.currentStepIndex, state.currentSubStepIndex]);\n\n const finish = useCallback(() => {\n setState((prev) => ({ ...prev, isActive: false }));\n if (configRef.current.onOnboardingComplete) {\n configRef.current.onOnboardingComplete();\n }\n }, []);\n\n const goToStep = useCallback((stepIndex: number, subStepIndex: number | null = null) => {\n setState({\n currentStepIndex: stepIndex,\n currentSubStepIndex: subStepIndex,\n isActive: true,\n });\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 }\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\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 setDragOffset({ x: 0, y: 0 });\n }, [currentStep]);\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 // eslint-disable-next-line react-hooks/immutability\n window.removeEventListener('pointerup', handlePointerUp);\n }, [config.metadata.draggable, handlePointerMove]);\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 useEffect(() => {\n return () => {\n window.removeEventListener('pointermove', handlePointerMove);\n window.removeEventListener('pointerup', handlePointerUp);\n };\n }, [handlePointerMove, handlePointerUp]);\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 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 observer.disconnect();\n if (resizeObserver) resizeObserver.disconnect();\n };\n }, [updateCoords, currentStep?.attribute]);\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 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\n const 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\n const 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\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 finish();\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,OAAOA,GACL,iBAAAC,GACA,cAAAC,GACA,aAAAC,EACA,YAAAC,EACA,eAAAC,EACA,WAAAC,EACA,kBAAAC,OACK,QACP,OAAOC,MAAa,YCTpB,OAAgB,YAAAC,EAAU,aAAAC,EAAW,eAAAC,EAAa,UAAAC,MAAc,QAChE,OAAS,gBAAAC,OAAoB,YA+OvB,cAAAC,EAoBF,QAAAC,MApBE,oBA5OC,IAAMC,EAA8B,IAAM,CAC/C,GAAM,CAAE,OAAAC,EAAQ,YAAAC,EAAa,SAAAC,EAAU,SAAAC,EAAU,OAAAC,EAAQ,YAAAC,EAAa,WAAAC,CAAW,EAC/EC,EAAc,EACV,CAACC,EAAQC,CAAS,EAAIC,EAKlB,IAAI,EACR,CAACC,EAAUC,CAAW,EAAIF,EAAwC,CAAE,IAAK,EAAG,KAAM,CAAE,CAAC,EACrF,CAACG,EAAYC,CAAa,EAAIJ,EAAmC,CAAE,EAAG,EAAG,EAAG,CAAE,CAAC,EAC/EK,EAAaC,EAAO,EAAK,EACzBC,EAAYD,EAAiC,CAAE,EAAG,EAAG,EAAG,CAAE,CAAC,EAC3DE,EAAaF,EAAuB,IAAI,EAE9CG,EAAU,IAAM,CACdL,EAAc,CAAE,EAAG,EAAG,EAAG,CAAE,CAAC,CAC9B,EAAG,CAACb,CAAW,CAAC,EAEhB,IAAMmB,EAAoBC,EAAaC,GAAoB,CACzD,GAAI,CAACP,EAAW,QAAS,OAEzB,IAAMQ,EAAOD,EAAE,QAAUL,EAAU,QAAQ,EACrCO,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qB,IAAK,EAAE,EAC3D,MACF,CAEA,GAAIzB,EAAM,iBAAmB,EAAG,CAC9B,IAAMwC,EAAYxC,EAAM,iBAAmB,EACrCyC,EAAc1B,EAAc,MAAMyB,CAAS,EAC3CE,EAAmBD,EAAY,SAAWA,EAAY,SAAS,OAAS,EAAI,KAElFxC,EAAS,CACP,iBAAkBuC,EAClB,oBAAqBE,EACrB,SAAU,EACZ,CAAC,CACH,CACF,EAAG,CAAC1C,EAAM,iBAAkBA,EAAM,mBAAmB,CAAC,EAEhD2C,EAASpC,EAAY,IAAM,CAC/BN,EAAUwB,IAAU,CAAE,GAAGA,EAAM,SAAU,EAAM,EAAE,EAC7CvB,EAAU,QAAQ,sBACpBA,EAAU,QAAQ,qBAAqB,CAE3C,EAAG,CAAC,CAAC,EAEC0C,EAAWrC,EAAY,CAACsC,EAAmBC,EAA8B,OAAS,CACtF7C,EAAS,CACP,iBAAkB4C,EAClB,oBAAqBC,EACrB,SAAU,EACZ,CAAC,CACH,EAAG,CAAC,CAAC,EAECC,EAAQ,CACZ,OAAAtD,EACA,MAAAO,EACA,SAAAiC,EACA,SAAAX,EACA,OAAAqB,EACA,SAAAC,EACA,YAAAlB,EACA,YAAAE,EACA,WAAAC,CACF,EAEA,OAAKhC,EAGHT,GAACC,EAAkB,SAAlB,CAA2B,MAAO0D,EAChC,UAAAnD,EACAI,EAAM,UAAYb,EAAC6D,EAAA,EAAkB,GACxC,EANqB7D,EAAAD,GAAA,CAAG,SAAAU,EAAS,CAQrC,EAEaqD,EAAgB,IAAM,CACjC,IAAMC,EAAUC,GAAW9D,CAAiB,EAC5C,GAAI6D,IAAY,OACd,MAAM,IAAI,MAAM,yDAAyD,EAE3E,OAAOA,CACT","names":["React","createContext","useContext","useEffect","useState","useCallback","useMemo","useEffectEvent","Cookies","useState","useEffect","useCallback","useRef","createPortal","jsx","jsxs","OnboardingOverlay","config","currentStep","nextStep","prevStep","finish","isFirstStep","isLastStep","useOnboarding","coords","setCoords","useState","position","setPosition","dragOffset","setDragOffset","isDragging","useRef","dragStart","tooltipRef","useEffect","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","ChevronLeftIcon","ChevronRightIcon","XIcon","overlayContent","createPortal","Fragment","jsx","jsxs","OnboardingContext","createContext","COOKIE_NAME","OnboardingProvider","config","ssr","onNavigate","children","isMounted","setIsMounted","useState","state","setState","configRef","React","useEffect","onNavigateRef","handleNavigation","useCallback","link","isMatch","step","path","pattern","onRestoreState","useEffectEvent","currentConfig","currentPath","matchedStepIndex","savedState","Cookies","parsed","targetUrl","prevStep","element","e","prev","currentStep","useMemo","isFirstStep","isLastStep","totalSteps","isLastMainStep","hasSubSteps","nextStep","stepObj","currentActiveStep","nextSubIndex","nextSubStep","nextIndex","nextStepObj","prevIndex","prevStepObj","prevSubStepIndex","finish","goToStep","stepIndex","subStepIndex","value","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\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>({\n currentStepIndex: 0,\n currentSubStepIndex: null,\n isActive: true,\n });\n\n const configRef = useRef(config);\n const onNavigateRef = useRef(onNavigate);\n\n useEffect(() => {\n configRef.current = config;\n onNavigateRef.current = onNavigate;\n }, [config, onNavigate]);\n\n const handleNavigation = useCallback((link?: string) => {\n if (!link) return;\n\n if (onNavigateRef.current) {\n onNavigateRef.current(link);\n } else {\n window.location.href = link;\n }\n }, []);\n\n const isMatch = (step: OnboardingStep, path: string) => {\n if (step.urlMatch instanceof RegExp) return step.urlMatch.test(path);\n\n if (typeof step.urlMatch === 'string' && step.urlMatch.includes('*')) {\n const pattern = step.urlMatch.replace(/[.+?^${}()|[\\\\]/g, '\\\\$&').replace(/\\*/g, '.*');\n return new RegExp(`^${pattern}$`).test(path);\n }\n\n return path === step.urlMatch;\n };\n\n useEffect(() => {\n if (ssr) {\n // eslint-disable-next-line react-hooks/set-state-in-effect\n setIsMounted(true);\n }\n\n const currentConfig = configRef.current;\n const currentPath = window.location.pathname;\n let matchedStepIndex = -1;\n\n if ((currentConfig.metadata.inOrder as boolean | undefined) === false) {\n matchedStepIndex = currentConfig.steps.findIndex((step) => isMatch(step, currentPath));\n }\n\n const savedState = Cookies.get(COOKIE_NAME);\n if (savedState) {\n try {\n const parsed: OnboardingState = JSON.parse(savedState);\n\n if ((currentConfig.metadata.inOrder as boolean | undefined) === false) {\n if (matchedStepIndex !== -1) {\n if (parsed.currentStepIndex === matchedStepIndex) {\n setState(parsed);\n } else {\n setState({\n currentStepIndex: matchedStepIndex,\n currentSubStepIndex: null,\n isActive: true,\n });\n }\n } else {\n setState({ ...parsed, isActive: false });\n }\n } else {\n setState(parsed);\n\n if ((currentConfig.metadata.inOrder as boolean | undefined) !== false) {\n const step = currentConfig.steps[parsed.currentStepIndex];\n if (step && parsed.isActive) {\n let targetUrl: string | undefined;\n\n if (parsed.currentStepIndex > 0) {\n const prevStep = currentConfig.steps[parsed.currentStepIndex - 1];\n if (prevStep.navigate) {\n targetUrl = prevStep.navigate;\n }\n }\n\n if (!targetUrl && typeof step.urlMatch === 'string') {\n targetUrl = step.urlMatch;\n }\n\n if (targetUrl && window.location.pathname !== targetUrl) {\n handleNavigation(targetUrl);\n }\n\n if (currentConfig.metadata.simulateClicksOnNavigate) {\n if (parsed.currentSubStepIndex !== null && step.click) {\n setTimeout(() => {\n const element = document.querySelector(\n `[data-onboarding-id=\"${step.attribute}\"]`,\n ) as HTMLElement;\n if (element) {\n element.click();\n }\n }, 500);\n }\n }\n }\n }\n }\n } catch (e) {\n console.error('Failed to parse onboarding state from cookie', e);\n if (matchedStepIndex !== -1) {\n setState({\n currentStepIndex: matchedStepIndex,\n currentSubStepIndex: null,\n isActive: true,\n });\n }\n }\n } else if (matchedStepIndex !== -1) {\n setState({\n currentStepIndex: matchedStepIndex,\n currentSubStepIndex: null,\n isActive: true,\n });\n } else if ((currentConfig.metadata.inOrder as boolean | undefined) === false) {\n setState((prev) => ({ ...prev, isActive: false }));\n } else {\n const step = currentConfig.steps[0];\n if (step && typeof step.urlMatch === 'string' && window.location.pathname !== step.urlMatch) {\n handleNavigation(step.urlMatch);\n }\n }\n }, [ssr, handleNavigation]);\n\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 if (state.currentSubStepIndex !== null && step.subSteps) {\n return step.subSteps[state.currentSubStepIndex] || step;\n }\n return step;\n }, [config.steps, state.currentStepIndex, state.currentSubStepIndex]);\n\n const isFirstStep = state.currentStepIndex === 0 && state.currentSubStepIndex === null;\n const isLastStep = useMemo(() => {\n const totalSteps = config.steps.length;\n const isLastMainStep = state.currentStepIndex === totalSteps - 1;\n const step = config.steps[state.currentStepIndex];\n const hasSubSteps = step?.subSteps && step.subSteps.length > 0;\n\n if (isLastMainStep) {\n if (hasSubSteps) {\n return state.currentSubStepIndex === step.subSteps!.length - 1;\n }\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 stepObj = currentConfig.steps[state.currentStepIndex];\n const currentActiveStep =\n state.currentSubStepIndex !== null && stepObj.subSteps\n ? stepObj.subSteps[state.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) {\n element.click();\n }\n }\n\n if (\n stepObj.subSteps &&\n (state.currentSubStepIndex === null ||\n state.currentSubStepIndex < stepObj.subSteps.length - 1)\n ) {\n const nextSubIndex = state.currentSubStepIndex === null ? 0 : state.currentSubStepIndex + 1;\n const nextSubStep = stepObj.subSteps[nextSubIndex];\n setState((prev) => ({ ...prev, currentSubStepIndex: nextSubIndex }));\n\n if (nextSubStep.navigate) handleNavigation(nextSubStep.navigate);\n return;\n }\n\n if (state.currentStepIndex < currentConfig.steps.length - 1) {\n const nextIndex = state.currentStepIndex + 1;\n const nextStepObj = currentConfig.steps[nextIndex];\n setState({\n currentStepIndex: nextIndex,\n currentSubStepIndex: null,\n isActive: true,\n });\n\n if (nextStepObj.navigate) handleNavigation(nextStepObj.navigate);\n } else {\n setState((prev) => ({ ...prev, isActive: false }));\n if (currentConfig.onOnboardingComplete) {\n currentConfig.onOnboardingComplete();\n }\n }\n }, [state.currentStepIndex, state.currentSubStepIndex, handleNavigation]);\n\n const prevStep = useCallback(() => {\n const currentConfig = configRef.current;\n\n if (state.currentSubStepIndex !== null && state.currentSubStepIndex > 0) {\n setState((prev) => ({ ...prev, currentSubStepIndex: prev.currentSubStepIndex! - 1 }));\n return;\n }\n\n if (state.currentStepIndex > 0 && state.currentSubStepIndex === 0) {\n setState((prev) => ({ ...prev, currentSubStepIndex: null }));\n return;\n }\n\n if (state.currentStepIndex > 0) {\n const prevIndex = state.currentStepIndex - 1;\n const prevStepObj = currentConfig.steps[prevIndex];\n const prevSubStepIndex = prevStepObj.subSteps ? prevStepObj.subSteps.length - 1 : null;\n\n setState({\n currentStepIndex: prevIndex,\n currentSubStepIndex: prevSubStepIndex,\n isActive: true,\n });\n }\n }, [state.currentStepIndex, state.currentSubStepIndex]);\n\n const finish = useCallback(() => {\n setState((prev) => ({ ...prev, isActive: false }));\n if (configRef.current.onOnboardingComplete) {\n configRef.current.onOnboardingComplete();\n }\n }, []);\n\n const goToStep = useCallback((stepIndex: number, subStepIndex: number | null = null) => {\n setState({\n currentStepIndex: stepIndex,\n currentSubStepIndex: subStepIndex,\n isActive: true,\n });\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 }\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 // Reset drag offset when step changes\n const [prevStepRef, setPrevStepRef] = useState(currentStep);\n if (currentStep !== prevStepRef) {\n setPrevStepRef(currentStep);\n setDragOffset({ x: 0, y: 0 });\n }\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 finish();\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,EACA,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,eAAe,QAEf,SAAAA,E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A2B,MAAOwD,EAChC,UAAAjD,EACAI,EAAM,UAAYb,EAAC2D,EAAA,EAAkB,GACxC,EANqB3D,EAAAD,GAAA,CAAG,SAAAU,EAAS,CAQrC,EAEamD,EAAgB,IAAM,CACjC,IAAMC,EAAUC,GAAW5D,CAAiB,EAC5C,GAAI2D,IAAY,OACd,MAAM,IAAI,MAAM,yDAAyD,EAE3E,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","prevStepRef","setPrevStepRef","handlePointerUpRef","handlePointerMove","useCallback","newX","newY","handlePointerUp","useEffect","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","OnboardingProvider","config","ssr","onNavigate","children","isMounted","setIsMounted","useState","state","setState","configRef","useRef","onNavigateRef","useEffect","handleNavigation","useCallback","link","isMatch","step","path","pattern","currentConfig","currentPath","matchedStepIndex","savedState","Cookies","parsed","targetUrl","prevStep","element","e","prev","currentStep","useMemo","isFirstStep","isLastStep","totalSteps","isLastMainStep","hasSubSteps","nextStep","stepObj","currentActiveStep","nextSubIndex","nextSubStep","nextIndex","nextStepObj","prevIndex","prevStepObj","prevSubStepIndex","finish","goToStep","stepIndex","subStepIndex","value","OnboardingOverlay","useOnboarding","context","useContext"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "onboard-engine",
3
- "version": "1.4.1",
3
+ "version": "1.4.3",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "types": "./dist/index.d.ts",
@@ -28,13 +28,25 @@
28
28
  "prepublishOnly": "npm run build"
29
29
  },
30
30
  "private": false,
31
+ "description": "A lightweight, powerful onboarding and product tour engine for React applications.",
31
32
  "repository": {
32
33
  "type": "git",
33
34
  "url": "git+https://github.com/Forsrobin/onboard-engine.git"
34
35
  },
35
- "keywords": [],
36
- "author": "",
37
- "license": "ISC",
36
+ "keywords": [
37
+ "react",
38
+ "onboarding",
39
+ "product-tour",
40
+ "walkthrough",
41
+ "guide",
42
+ "user-onboarding",
43
+ "ui",
44
+ "ux",
45
+ "onboard-engine",
46
+ "nextjs"
47
+ ],
48
+ "author": "Robin Fors",
49
+ "license": "MIT",
38
50
  "type": "commonjs",
39
51
  "bugs": {
40
52
  "url": "https://github.com/Forsrobin/onboard-engine/issues"