onboard-engine 1.0.1 → 1.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,7 +1,3 @@
1
- <p align="center">
2
- <img src="logo.png" alt="Onboard Engine Logo" width="200" />
3
- </p>
4
-
5
1
  # Onboard Engine
6
2
 
7
3
  **A modern, lightweight, and customizable onboarding library for React and Next.js applications.**
@@ -224,4 +220,4 @@ Contributions are welcome! Please feel free to submit a Pull Request.
224
220
 
225
221
  ## License
226
222
 
227
- ISC © [Forsrobin](https://github.com/Forsrobin)
223
+ ISC © [Forsrobin](https://github.com/Forsrobin)
package/dist/index.css CHANGED
@@ -1,2 +1,2 @@
1
- .onboard-overlay-mask{position:absolute;background-color:#000000b3;pointer-events:auto;transition:all .3s cubic-bezier(.25,.1,.25,1)}.onboard-tooltip{position:absolute;width:300px;background-color:#fff;border-radius:12px;box-shadow:0 25px 50px -12px #00000040;pointer-events:auto;padding:20px;border:1px solid #f3f4f6;z-index:10000;transition:top .3s cubic-bezier(.25,.1,.25,1),left .3s cubic-bezier(.25,.1,.25,1)}.onboard-button-primary{background-color:#000;color:#fff;padding:8px 16px;border-radius:8px;font-weight:600;font-size:14px;transition:all .2s;display:flex;align-items:center;gap:4px}.onboard-button-primary:hover{background-color:#1f2937}.onboard-button-primary:active{transform:scale(.95)}.onboard-button-ghost{color:#4b5563;font-weight:500;font-size:14px;transition:color .2s;display:flex;align-items:center;gap:4px}.onboard-button-ghost:hover{color:#111827}.onboard-button-ghost:disabled{color:#d1d5db;cursor:not-allowed}
1
+ .onboard-overlay-container{position:fixed;inset:0;z-index:999999;pointer-events:none}.onboard-overlay-mask{position:absolute;background-color:#000000b3;pointer-events:auto;transition:all .3s cubic-bezier(.25,.1,.25,1)}.onboard-mask-top{top:0;left:0;width:100%}.onboard-mask-bottom{left:0;width:100%}.onboard-mask-left{left:0}.onboard-tooltip{position:absolute;width:300px;background-color:#fff;border-radius:12px;box-shadow:0 25px 50px -12px #00000040;pointer-events:auto;padding:20px;border:1px solid #f3f4f6;z-index:10000;transition:top .3s cubic-bezier(.25,.1,.25,1),left .3s cubic-bezier(.25,.1,.25,1)}.onboard-tooltip-header{display:flex;justify-content:space-between;align-items:flex-start;margin-bottom:8px}.onboard-tooltip-title{margin:0;font-weight:700;color:#111827;font-size:18px;line-height:1.2}.onboard-close-button{background:none;border:none;cursor:pointer;padding:4px;color:#9ca3af;display:flex;align-items:center;justify-content:center}.onboard-close-button:hover{color:#6b7280}.onboard-tooltip-description{margin:0 0 24px;color:#4b5563;font-size:14px;line-height:1.5}.onboard-tooltip-footer{display:flex;align-items:center;justify-content:space-between}.onboard-button-primary{background-color:#000;color:#fff;padding:8px 16px;border-radius:8px;font-weight:600;font-size:14px;transition:all .2s;display:flex;align-items:center;gap:4px}.onboard-button-primary:hover{background-color:#1f2937}.onboard-button-primary:active{transform:scale(.95)}.onboard-button-ghost{color:#4b5563;font-weight:500;font-size:14px;transition:color .2s;display:flex;align-items:center;gap:4px}.onboard-button-ghost:hover{color:#111827}.onboard-button-ghost:disabled{color:#d1d5db;cursor:not-allowed}
2
2
  /*# sourceMappingURL=index.css.map */
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/styles.css"],"sourcesContent":[".onboard-overlay-mask {\n position: absolute;\n background-color: rgba(0, 0, 0, 0.7);\n pointer-events: auto;\n transition: all 0.3s cubic-bezier(0.25, 0.1, 0.25, 1);\n}\n\n.onboard-tooltip {\n position: absolute;\n width: 300px;\n background-color: white;\n border-radius: 12px;\n box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);\n pointer-events: auto;\n padding: 20px;\n border: 1px solid #f3f4f6;\n z-index: 10000;\n 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);\n}\n\n.onboard-button-primary {\n background-color: black;\n color: white;\n padding: 8px 16px;\n border-radius: 8px;\n font-weight: 600;\n font-size: 14px;\n transition: all 0.2s;\n display: flex;\n align-items: center;\n gap: 4px;\n}\n\n.onboard-button-primary:hover {\n background-color: #1f2937;\n}\n\n.onboard-button-primary:active {\n transform: scale(0.95);\n}\n\n.onboard-button-ghost {\n color: #4b5563;\n font-weight: 500;\n font-size: 14px;\n transition: color 0.2s;\n display: flex;\n align-items: center;\n gap: 4px;\n}\n\n.onboard-button-ghost:hover {\n color: #111827;\n}\n\n.onboard-button-ghost:disabled {\n color: #d1d5db;\n cursor: not-allowed;\n}\n"],"mappings":"AAAA,CAAC,qBACC,SAAU,SACV,iBAAkB,UAClB,eAAgB,KAChB,WAAY,IAAI,IAAK,aAAa,GAAI,CAAE,EAAG,CAAE,GAAI,CAAE,EACrD,CAEA,CAAC,gBACC,SAAU,SACV,MAAO,MACP,iBAAkB,KAVpB,cAWiB,KACf,WAAY,EAAE,KAAK,KAAK,MAAM,UAC9B,eAAgB,KAblB,QAcW,KACT,OAAQ,IAAI,MAAM,QAClB,QAAS,MACT,WAAY,IAAI,IAAK,aAAa,GAAI,CAAE,EAAG,CAAE,GAAI,CAAE,EAAE,CAAE,KAAK,IAAK,aAAa,GAAI,CAAE,EAAG,CAAE,GAAI,CAAE,EACjG,CAEA,CAAC,uBACC,iBAAkB,KAClB,MAAO,KAtBT,QAuBW,IAAI,KAvBf,cAwBiB,IACf,YAAa,IACb,UAAW,KACX,WAAY,IAAI,IAChB,QAAS,KACT,YAAa,OACb,IAAK,GACP,CAEA,CAbC,sBAasB,OACrB,iBAAkB,OACpB,CAEA,CAjBC,sBAiBsB,QACrB,UAAW,MAAM,IACnB,CAEA,CAAC,qBACC,MAAO,QACP,YAAa,IACb,UAAW,KACX,WAAY,MAAM,IAClB,QAAS,KACT,YAAa,OACb,IAAK,GACP,CAEA,CAVC,oBAUoB,OACnB,MAAO,OACT,CAEA,CAdC,oBAcoB,UACnB,MAAO,QACP,OAAQ,WACV","names":[]}
1
+ {"version":3,"sources":["../src/styles.css"],"sourcesContent":[".onboard-overlay-container {\n position: fixed;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n z-index: 999999;\n pointer-events: none;\n}\n\n.onboard-overlay-mask {\n position: absolute;\n background-color: rgba(0, 0, 0, 0.7);\n pointer-events: auto;\n transition: all 0.3s cubic-bezier(0.25, 0.1, 0.25, 1);\n}\n\n.onboard-mask-top {\n top: 0;\n left: 0;\n width: 100%;\n}\n\n.onboard-mask-bottom {\n left: 0;\n width: 100%;\n}\n\n.onboard-mask-left {\n left: 0;\n}\n\n.onboard-tooltip {\n position: absolute;\n width: 300px;\n background-color: white;\n border-radius: 12px;\n box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);\n pointer-events: auto;\n padding: 20px;\n border: 1px solid #f3f4f6;\n z-index: 10000;\n 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);\n}\n\n.onboard-tooltip-header {\n display: flex;\n justify-content: space-between;\n align-items: flex-start;\n margin-bottom: 8px;\n}\n\n.onboard-tooltip-title {\n margin: 0;\n font-weight: bold;\n color: #111827;\n font-size: 18px;\n line-height: 1.2;\n}\n\n.onboard-close-button {\n background: none;\n border: none;\n cursor: pointer;\n padding: 4px;\n color: #9ca3af;\n display: flex;\n align-items: center;\n justify-content: center;\n}\n\n.onboard-close-button:hover {\n color: #6b7280;\n}\n\n.onboard-tooltip-description {\n margin: 0;\n color: #4b5563;\n font-size: 14px;\n margin-bottom: 24px;\n line-height: 1.5;\n}\n\n.onboard-tooltip-footer {\n display: flex;\n align-items: center;\n justify-content: space-between;\n}\n\n.onboard-button-primary {\n background-color: black;\n color: white;\n padding: 8px 16px;\n border-radius: 8px;\n font-weight: 600;\n font-size: 14px;\n transition: all 0.2s;\n display: flex;\n align-items: center;\n gap: 4px;\n}\n\n.onboard-button-primary:hover {\n background-color: #1f2937;\n}\n\n.onboard-button-primary:active {\n transform: scale(0.95);\n}\n\n.onboard-button-ghost {\n color: #4b5563;\n font-weight: 500;\n font-size: 14px;\n transition: color 0.2s;\n display: flex;\n align-items: center;\n gap: 4px;\n}\n\n.onboard-button-ghost:hover {\n color: #111827;\n}\n\n.onboard-button-ghost:disabled {\n color: #d1d5db;\n cursor: not-allowed;\n}"],"mappings":"AAAA,CAAC,0BACC,SAAU,MACV,MAAK,EAIL,QAAS,OACT,eAAgB,IAClB,CAEA,CAAC,qBACC,SAAU,SACV,iBAAkB,UAClB,eAAgB,KAChB,WAAY,IAAI,IAAK,aAAa,GAAI,CAAE,EAAG,CAAE,GAAI,CAAE,EACrD,CAEA,CAAC,iBACC,IAAK,EACL,KAAM,EACN,MAAO,IACT,CAEA,CAAC,oBACC,KAAM,EACN,MAAO,IACT,CAEA,CAAC,kBACC,KAAM,CACR,CAEA,CAAC,gBACC,SAAU,SACV,MAAO,MACP,iBAAkB,KAnCpB,cAoCiB,KACf,WAAY,EAAE,KAAK,KAAK,MAAM,UAC9B,eAAgB,KAtClB,QAuCW,KACT,OAAQ,IAAI,MAAM,QAClB,QAAS,MACT,WAAY,IAAI,IAAK,aAAa,GAAI,CAAE,EAAG,CAAE,GAAI,CAAE,EAAE,CAAE,KAAK,IAAK,aAAa,GAAI,CAAE,EAAG,CAAE,GAAI,CAAE,EACjG,CAEA,CAAC,uBACC,QAAS,KACT,gBAAiB,cACjB,YAAa,WACb,cAAe,GACjB,CAEA,CAAC,sBApDD,OAqDU,EACR,YAAa,IACb,MAAO,QACP,UAAW,KACX,YAAa,GACf,CAEA,CAAC,qBACC,WAAY,KACZ,OAAQ,KACR,OAAQ,QA/DV,QAgEW,IACT,MAAO,QACP,QAAS,KACT,YAAa,OACb,gBAAiB,MACnB,CAEA,CAXC,oBAWoB,OACnB,MAAO,OACT,CAEA,CAAC,4BA3ED,OA4EU,IAGO,KAFf,MAAO,QACP,UAAW,KAEX,YAAa,GACf,CAEA,CAAC,uBACC,QAAS,KACT,YAAa,OACb,gBAAiB,aACnB,CAEA,CAAC,uBACC,iBAAkB,KAClB,MAAO,KA3FT,QA4FW,IAAI,KA5Ff,cA6FiB,IACf,YAAa,IACb,UAAW,KACX,WAAY,IAAI,IAChB,QAAS,KACT,YAAa,OACb,IAAK,GACP,CAEA,CAbC,sBAasB,OACrB,iBAAkB,OACpB,CAEA,CAjBC,sBAiBsB,QACrB,UAAW,MAAM,IACnB,CAEA,CAAC,qBACC,MAAO,QACP,YAAa,IACb,UAAW,KACX,WAAY,MAAM,IAClB,QAAS,KACT,YAAa,OACb,IAAK,GACP,CAEA,CAVC,oBAUoB,OACnB,MAAO,OACT,CAEA,CAdC,oBAcoB,UACnB,MAAO,QACP,OAAQ,WACV","names":[]}
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
1
  "use client";
2
- "use strict";"use client";var Q=Object.create;var W=Object.defineProperty;var V=Object.getOwnPropertyDescriptor;var Z=Object.getOwnPropertyNames;var tt=Object.getPrototypeOf,et=Object.prototype.hasOwnProperty;var nt=(e,s)=>{for(var f in s)W(e,f,{get:s[f],enumerable:!0})},F=(e,s,f,y)=>{if(s&&typeof s=="object"||typeof s=="function")for(let m of Z(s))!et.call(e,m)&&m!==f&&W(e,m,{get:()=>s[m],enumerable:!(y=V(s,m))||y.enumerable});return e};var T=(e,s,f)=>(f=e!=null?Q(tt(e)):{},F(s||!e||!e.__esModule?W(f,"default",{value:e,enumerable:!0}):f,e)),ot=e=>F(W({},"__esModule",{value:!0}),e);var it={};nt(it,{OnboardingProvider:()=>rt,useOnboarding:()=>$});module.exports=ot(it);var l=T(require("react")),B=T(require("js-cookie"));var b=require("react"),X=require("react-dom");var a=require("react/jsx-runtime"),j=()=>{let{config:e,currentStep:s,nextStep:f,prevStep:y,finish:m,isFirstStep:n,isLastStep:p}=$(),[d,v]=(0,b.useState)(null),[H,D]=(0,b.useState)({top:0,left:0}),[C,A]=(0,b.useState)({x:0,y:0}),E=(0,b.useRef)(!1),R=(0,b.useRef)({x:0,y:0}),w=(0,b.useRef)(null);(0,b.useEffect)(()=>{A({x:0,y:0})},[s]);let N=r=>{e.metadata.draggable&&(r.stopPropagation(),r.preventDefault(),E.current=!0,R.current={x:r.clientX-C.x,y:r.clientY-C.y},w.current&&(w.current.style.transition="none",w.current.style.cursor="grabbing"),window.addEventListener("pointermove",I),window.addEventListener("pointerup",t))},I=(0,b.useCallback)(r=>{if(!E.current)return;let g=r.clientX-R.current.x,S=r.clientY-R.current.y;A({x:g,y:S})},[]),t=(0,b.useCallback)(()=>{E.current=!1,w.current&&(w.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)",w.current.style.cursor=e.metadata.draggable?"grab":"auto"),window.removeEventListener("pointermove",I),window.removeEventListener("pointerup",t)},[e.metadata.draggable,I]);(0,b.useEffect)(()=>()=>{window.removeEventListener("pointermove",I),window.removeEventListener("pointerup",t)},[I,t]);let c=(0,b.useCallback)(r=>{let z=r.top,x=window.innerHeight-r.bottom,U=r.left,G=window.innerWidth-r.right,P=0,L=0;return x>232?(P=r.bottom+12,L=Math.max(20,Math.min(window.innerWidth-300-20,r.left+r.width/2-300/2))):z>232?(P=r.top-200-12,L=Math.max(20,Math.min(window.innerWidth-300-20,r.left+r.width/2-300/2))):G>332?(P=Math.max(20,Math.min(window.innerHeight-200-20,r.top+r.height/2-200/2)),L=r.right+12):U>332?(P=Math.max(20,Math.min(window.innerHeight-200-20,r.top+r.height/2-200/2)),L=r.left-300-12):(P=window.innerHeight/2-200/2,L=window.innerWidth/2-300/2),{top:P+window.scrollY,left:L+window.scrollX}},[]),i=(0,b.useCallback)(()=>{if(!s)return;let r=document.querySelector(`[data-onboarding-id="${s.attribute}"]`);if(r){let g=r.getBoundingClientRect(),S=e.style?.padding||0,k={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},M={top:k.top+window.scrollY,left:k.left+window.scrollX,width:k.width,height:k.height},z=c(k);v(x=>x&&x.top===M.top&&x.left===M.left&&x.width===M.width&&x.height===M.height?x:M),D(x=>x.top===z.top&&x.left===z.left?x:z)}else v(null)},[s,c,e.style]);if((0,b.useEffect)(()=>{i(),window.addEventListener("resize",i),window.addEventListener("scroll",i);let r=new MutationObserver(i);r.observe(document.body,{childList:!0,subtree:!0,attributes:!0});let g=null;if(typeof ResizeObserver<"u"){g=new ResizeObserver(i),g.observe(document.body);let S=s?.attribute?document.querySelector(`[data-onboarding-id="${s.attribute}"]`):null;S&&g.observe(S)}return()=>{window.removeEventListener("resize",i),window.removeEventListener("scroll",i),r.disconnect(),g&&g.disconnect()}},[i,s?.attribute]),!s||!d)return null;let u={...e.style?.background,transition:"all 0.3s cubic-bezier(0.25, 0.1, 0.25, 1)"},o=r=>{r.stopPropagation()},h=()=>(0,a.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,a.jsx)("path",{d:"M15 18l-6-6 6-6"})}),J=()=>(0,a.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,a.jsx)("path",{d:"M9 18l6-6-6-6"})}),_=()=>(0,a.jsxs)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,a.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,a.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]}),K=(0,a.jsxs)("div",{className:"fixed inset-0 z-[999999] pointer-events-none",children:[(0,a.jsx)("div",{style:{height:d.top,...u},className:"onboard-overlay-mask top-0 left-0 w-full pointer-events-auto",onPointerDown:o,onMouseDown:o,onClick:o}),(0,a.jsx)("div",{style:{top:d.top+d.height,height:`calc(100vh - ${d.top+d.height}px)`,...u},className:"onboard-overlay-mask left-0 w-full pointer-events-auto",onPointerDown:o,onMouseDown:o,onClick:o}),(0,a.jsx)("div",{style:{top:d.top,height:d.height,width:d.left,...u},className:"onboard-overlay-mask left-0 pointer-events-auto",onPointerDown:o,onMouseDown:o,onClick:o}),(0,a.jsx)("div",{style:{top:d.top,height:d.height,left:d.left+d.width,width:`calc(100% - ${d.left+d.width}px)`,...u},className:"onboard-overlay-mask pointer-events-auto",onPointerDown:o,onMouseDown:o,onClick:o}),(0,a.jsxs)("div",{ref:w,className:"onboard-tooltip pointer-events-auto",onPointerDown:N,style:{zIndex:1e6,...e.style?.container,top:H.top+C.y,left:H.left+C.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:e.metadata.draggable?"grab":"auto",touchAction:"none"},onMouseDown:o,onClick:o,children:[(0,a.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",marginBottom:"8px"},children:[(0,a.jsx)("h3",{style:{margin:0,fontWeight:"bold",color:"#111827",fontSize:"18px",lineHeight:1.2},children:s.title}),(0,a.jsx)("button",{onClick:r=>{r.stopPropagation(),m()},style:{background:"none",border:"none",cursor:"pointer",padding:"4px",color:"#9ca3af"},children:(0,a.jsx)(_,{})})]}),(0,a.jsx)("p",{style:{margin:0,color:"#4b5563",fontSize:"14px",marginBottom:"24px",lineHeight:1.5},children:s.description}),(0,a.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[(0,a.jsxs)("button",{onClick:r=>{r.stopPropagation(),y()},disabled:n,className:"onboard-button-ghost",style:{background:"none",border:"none",cursor:n?"not-allowed":"pointer",...e.style?.prev},children:[(0,a.jsx)(h,{}),"Prev"]}),p?(0,a.jsx)("button",{onClick:r=>{r.stopPropagation(),m()},className:"onboard-button-primary",style:{border:"none",cursor:"pointer",...e.style?.finish},children:"Finish"}):(0,a.jsxs)("button",{onClick:r=>{r.stopPropagation(),f()},className:"onboard-button-primary",style:{border:"none",cursor:"pointer",...n?e.style?.start:{},...n?{}:e.style?.next},children:[n&&e.style?.start?"Start":"Next",!(n&&e.style?.start)&&(0,a.jsx)(J,{})]})]})]})]});return typeof document<"u"?(0,X.createPortal)(K,document.body):null};var O=require("react/jsx-runtime"),q=(0,l.createContext)(void 0),Y="onboarding_state",rt=({config:e,ssr:s=!1,children:f})=>{let[y,m]=(0,l.useState)(!s),[n,p]=(0,l.useState)({currentStepIndex:0,currentSubStepIndex:null,isActive:!0}),d=l.default.useRef(e);(0,l.useEffect)(()=>{d.current=e},[e]);let v=(0,l.useCallback)(t=>{t&&(d.current.metadata.nextRouter,window.location.href=t)},[]);(0,l.useEffect)(()=>{s&&m(!0)},[s]);let H=(t,c)=>{if(t.urlMatch instanceof RegExp)return t.urlMatch.test(c);if(typeof t.urlMatch=="string"&&t.urlMatch.includes("*")){let i=t.urlMatch.replace(/[.+?^${}()|[\]\\]/g,"\\$&").replace(/\*/g,".*");return new RegExp(`^${i}$`).test(c)}return c===t.urlMatch};(0,l.useEffect)(()=>{let t=d.current,c=window.location.pathname,i=-1;t.metadata.inOrder===!1&&(i=t.steps.findIndex(o=>H(o,c)));let u=B.default.get(Y);if(u)try{let o=JSON.parse(u);if(t.metadata.inOrder===!1)i!==-1?o.currentStepIndex===i?p(o):p(h=>({...h,currentStepIndex:i,currentSubStepIndex:null,isActive:!0})):p(h=>({...o,isActive:!1}));else if(p(o),t.metadata.inOrder!==!1){let h=t.steps[o.currentStepIndex];h&&o.isActive&&typeof h.urlMatch=="string"&&window.location.pathname!==h.urlMatch&&v(h.urlMatch)}}catch(o){console.error("Failed to parse onboarding state from cookie",o),i!==-1&&p(h=>({...h,currentStepIndex:i,currentSubStepIndex:null,isActive:!0}))}else if(i!==-1)p(o=>({...o,currentStepIndex:i,currentSubStepIndex:null,isActive:!0}));else if(t.metadata.inOrder===!1)p(o=>({...o,isActive:!1}));else{let o=t.steps[0];o&&typeof o.urlMatch=="string"&&window.location.pathname!==o.urlMatch&&v(o.urlMatch)}},[v]),(0,l.useEffect)(()=>{y&&B.default.set(Y,JSON.stringify(n),{expires:365})},[n,y]);let D=(0,l.useMemo)(()=>{let t=e.steps[n.currentStepIndex];return t?n.currentSubStepIndex!==null&&t.subSteps&&t.subSteps[n.currentSubStepIndex]||t:null},[e.steps,n.currentStepIndex,n.currentSubStepIndex]),C=n.currentStepIndex===0&&n.currentSubStepIndex===null,A=(0,l.useMemo)(()=>{let t=e.steps.length,c=n.currentStepIndex===t-1,i=e.steps[n.currentStepIndex],u=i?.subSteps&&i.subSteps.length>0;return c?u?n.currentSubStepIndex===i.subSteps.length-1:!0:!1},[e.steps,n.currentStepIndex,n.currentSubStepIndex]),E=(0,l.useCallback)(()=>{let t=d.current,c=t.steps[n.currentStepIndex],i=n.currentSubStepIndex!==null&&c.subSteps?c.subSteps[n.currentSubStepIndex]:c;if(i.click){let u=document.querySelector(`[data-onboarding-id="${i.attribute}"]`);u&&u.click()}if(c.subSteps&&(n.currentSubStepIndex===null||n.currentSubStepIndex<c.subSteps.length-1)){let u=n.currentSubStepIndex===null?0:n.currentSubStepIndex+1,o=c.subSteps[u];p(h=>({...h,currentSubStepIndex:u})),o.navigate&&v(o.navigate);return}if(n.currentStepIndex<t.steps.length-1){let u=n.currentStepIndex+1,o=t.steps[u];p({currentStepIndex:u,currentSubStepIndex:null,isActive:!0}),o.navigate&&v(o.navigate)}else p(u=>({...u,isActive:!1})),t.onOnboardingComplete&&t.onOnboardingComplete()},[n.currentStepIndex,n.currentSubStepIndex,v]),R=(0,l.useCallback)(()=>{let t=d.current,c=t.steps[n.currentStepIndex];if(n.currentSubStepIndex!==null&&n.currentSubStepIndex>0){p(i=>({...i,currentSubStepIndex:i.currentSubStepIndex-1}));return}if(n.currentSubStepIndex===0){p(i=>({...i,currentSubStepIndex:null}));return}if(n.currentStepIndex>0){let i=n.currentStepIndex-1,u=t.steps[i],o=u.subSteps?u.subSteps.length-1:null;p({currentStepIndex:i,currentSubStepIndex:o,isActive:!0})}},[n.currentStepIndex,n.currentSubStepIndex]),w=(0,l.useCallback)(()=>{p(t=>({...t,isActive:!1})),d.current.onOnboardingComplete&&d.current.onOnboardingComplete()},[]),N=(0,l.useCallback)((t,c=null)=>{p({currentStepIndex:t,currentSubStepIndex:c,isActive:!0})},[]),I={config:e,state:n,nextStep:E,prevStep:R,finish:w,goToStep:N,currentStep:D,isFirstStep:C,isLastStep:A};return y?(0,O.jsxs)(q.Provider,{value:I,children:[f,n.isActive&&(0,O.jsx)(j,{})]}):(0,O.jsx)(O.Fragment,{children:f})},$=()=>{let e=(0,l.useContext)(q);if(e===void 0)throw new Error("useOnboarding must be used within an OnboardingProvider");return e};0&&(module.exports={OnboardingProvider,useOnboarding});
2
+ "use strict";"use client";var Q=Object.create;var H=Object.defineProperty;var V=Object.getOwnPropertyDescriptor;var Z=Object.getOwnPropertyNames;var tt=Object.getPrototypeOf,et=Object.prototype.hasOwnProperty;var nt=(e,s)=>{for(var f in s)H(e,f,{get:s[f],enumerable:!0})},T=(e,s,f,y)=>{if(s&&typeof s=="object"||typeof s=="function")for(let x of Z(s))!et.call(e,x)&&x!==f&&H(e,x,{get:()=>s[x],enumerable:!(y=V(s,x))||y.enumerable});return e};var j=(e,s,f)=>(f=e!=null?Q(tt(e)):{},T(s||!e||!e.__esModule?H(f,"default",{value:e,enumerable:!0}):f,e)),ot=e=>T(H({},"__esModule",{value:!0}),e);var it={};nt(it,{OnboardingProvider:()=>rt,useOnboarding:()=>$});module.exports=ot(it);var u=j(require("react")),F=j(require("js-cookie"));var b=require("react"),B=require("react-dom");var a=require("react/jsx-runtime"),X=()=>{let{config:e,currentStep:s,nextStep:f,prevStep:y,finish:x,isFirstStep:n,isLastStep:p}=$(),[d,w]=(0,b.useState)(null),[N,W]=(0,b.useState)({top:0,left:0}),[k,A]=(0,b.useState)({x:0,y:0}),E=(0,b.useRef)(!1),R=(0,b.useRef)({x:0,y:0}),v=(0,b.useRef)(null);(0,b.useEffect)(()=>{A({x:0,y:0})},[s]);let D=r=>{e.metadata.draggable&&(r.stopPropagation(),r.preventDefault(),E.current=!0,R.current={x:r.clientX-k.x,y:r.clientY-k.y},v.current&&(v.current.style.transition="none",v.current.style.cursor="grabbing"),window.addEventListener("pointermove",I),window.addEventListener("pointerup",t))},I=(0,b.useCallback)(r=>{if(!E.current)return;let g=r.clientX-R.current.x,S=r.clientY-R.current.y;A({x:g,y:S})},[]),t=(0,b.useCallback)(()=>{E.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=e.metadata.draggable?"grab":"auto"),window.removeEventListener("pointermove",I),window.removeEventListener("pointerup",t)},[e.metadata.draggable,I]);(0,b.useEffect)(()=>()=>{window.removeEventListener("pointermove",I),window.removeEventListener("pointerup",t)},[I,t]);let c=(0,b.useCallback)(r=>{let z=r.top,m=window.innerHeight-r.bottom,U=r.left,G=window.innerWidth-r.right,P=0,L=0;return m>232?(P=r.bottom+12,L=Math.max(20,Math.min(window.innerWidth-300-20,r.left+r.width/2-300/2))):z>232?(P=r.top-200-12,L=Math.max(20,Math.min(window.innerWidth-300-20,r.left+r.width/2-300/2))):G>332?(P=Math.max(20,Math.min(window.innerHeight-200-20,r.top+r.height/2-200/2)),L=r.right+12):U>332?(P=Math.max(20,Math.min(window.innerHeight-200-20,r.top+r.height/2-200/2)),L=r.left-300-12):(P=window.innerHeight/2-200/2,L=window.innerWidth/2-300/2),{top:P+window.scrollY,left:L+window.scrollX}},[]),i=(0,b.useCallback)(()=>{if(!s)return;let r=document.querySelector(`[data-onboarding-id="${s.attribute}"]`);if(r){let g=r.getBoundingClientRect(),S=e.style?.padding||0,C={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},M={top:C.top+window.scrollY,left:C.left+window.scrollX,width:C.width,height:C.height},z=c(C);w(m=>m&&m.top===M.top&&m.left===M.left&&m.width===M.width&&m.height===M.height?m:M),W(m=>m.top===z.top&&m.left===z.left?m:z)}else w(null)},[s,c,e.style]);if((0,b.useEffect)(()=>{i(),window.addEventListener("resize",i),window.addEventListener("scroll",i);let r=new MutationObserver(i);r.observe(document.body,{childList:!0,subtree:!0,attributes:!0});let g=null;if(typeof ResizeObserver<"u"){g=new ResizeObserver(i),g.observe(document.body);let S=s?.attribute?document.querySelector(`[data-onboarding-id="${s.attribute}"]`):null;S&&g.observe(S)}return()=>{window.removeEventListener("resize",i),window.removeEventListener("scroll",i),r.disconnect(),g&&g.disconnect()}},[i,s?.attribute]),!s||!d)return null;let l={...e.style?.background,transition:"all 0.3s cubic-bezier(0.25, 0.1, 0.25, 1)"},o=r=>{r.stopPropagation()},h=()=>(0,a.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,a.jsx)("path",{d:"M15 18l-6-6 6-6"})}),J=()=>(0,a.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,a.jsx)("path",{d:"M9 18l6-6-6-6"})}),_=()=>(0,a.jsxs)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,a.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,a.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]}),K=(0,a.jsxs)("div",{className:"onboard-overlay-container",children:[(0,a.jsx)("div",{style:{height:d.top,...l},className:"onboard-overlay-mask onboard-mask-top",onPointerDown:o,onMouseDown:o,onClick:o}),(0,a.jsx)("div",{style:{top:d.top+d.height,height:`calc(100vh - ${d.top+d.height}px)`,...l},className:"onboard-overlay-mask onboard-mask-bottom",onPointerDown:o,onMouseDown:o,onClick:o}),(0,a.jsx)("div",{style:{top:d.top,height:d.height,width:d.left,...l},className:"onboard-overlay-mask onboard-mask-left",onPointerDown:o,onMouseDown:o,onClick:o}),(0,a.jsx)("div",{style:{top:d.top,height:d.height,left:d.left+d.width,width:`calc(100% - ${d.left+d.width}px)`,...l},className:"onboard-overlay-mask",onPointerDown:o,onMouseDown:o,onClick:o}),(0,a.jsxs)("div",{ref:v,className:"onboard-tooltip",onPointerDown:D,style:{zIndex:1e6,...e.style?.container,top:N.top+k.y,left:N.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:e.metadata.draggable?"grab":"auto",touchAction:"none"},onMouseDown:o,onClick:o,children:[(0,a.jsxs)("div",{className:"onboard-tooltip-header",children:[(0,a.jsx)("h3",{className:"onboard-tooltip-title",children:s.title}),(0,a.jsx)("button",{onClick:r=>{r.stopPropagation(),x()},className:"onboard-close-button",children:(0,a.jsx)(_,{})})]}),(0,a.jsx)("p",{className:"onboard-tooltip-description",children:s.description}),(0,a.jsxs)("div",{className:"onboard-tooltip-footer",children:[(0,a.jsxs)("button",{onClick:r=>{r.stopPropagation(),y()},disabled:n,className:"onboard-button-ghost",style:{background:"none",border:"none",cursor:n?"not-allowed":"pointer",...e.style?.prev},children:[(0,a.jsx)(h,{}),"Prev"]}),p?(0,a.jsx)("button",{onClick:r=>{r.stopPropagation(),x()},className:"onboard-button-primary",style:{border:"none",cursor:"pointer",...e.style?.finish},children:"Finish"}):(0,a.jsxs)("button",{onClick:r=>{r.stopPropagation(),f()},className:"onboard-button-primary",style:{border:"none",cursor:"pointer",...n?e.style?.start:{},...n?{}:e.style?.next},children:[n&&e.style?.start?"Start":"Next",!(n&&e.style?.start)&&(0,a.jsx)(J,{})]})]})]})]});return typeof document<"u"?(0,B.createPortal)(K,document.body):null};var O=require("react/jsx-runtime"),q=(0,u.createContext)(void 0),Y="onboarding_state",rt=({config:e,ssr:s=!1,children:f})=>{let[y,x]=(0,u.useState)(!s),[n,p]=(0,u.useState)({currentStepIndex:0,currentSubStepIndex:null,isActive:!0}),d=u.default.useRef(e);(0,u.useEffect)(()=>{d.current=e},[e]);let w=(0,u.useCallback)(t=>{t&&(d.current.metadata.nextRouter,window.location.href=t)},[]);(0,u.useEffect)(()=>{s&&x(!0)},[s]);let N=(t,c)=>{if(t.urlMatch instanceof RegExp)return t.urlMatch.test(c);if(typeof t.urlMatch=="string"&&t.urlMatch.includes("*")){let i=t.urlMatch.replace(/[.+?^${}()|[\]\\]/g,"\\$&").replace(/\*/g,".*");return new RegExp(`^${i}$`).test(c)}return c===t.urlMatch};(0,u.useEffect)(()=>{let t=d.current,c=window.location.pathname,i=-1;t.metadata.inOrder===!1&&(i=t.steps.findIndex(o=>N(o,c)));let l=F.default.get(Y);if(l)try{let o=JSON.parse(l);if(t.metadata.inOrder===!1)i!==-1?o.currentStepIndex===i?p(o):p(h=>({...h,currentStepIndex:i,currentSubStepIndex:null,isActive:!0})):p(h=>({...o,isActive:!1}));else if(p(o),t.metadata.inOrder!==!1){let h=t.steps[o.currentStepIndex];h&&o.isActive&&typeof h.urlMatch=="string"&&window.location.pathname!==h.urlMatch&&w(h.urlMatch)}}catch(o){console.error("Failed to parse onboarding state from cookie",o),i!==-1&&p(h=>({...h,currentStepIndex:i,currentSubStepIndex:null,isActive:!0}))}else if(i!==-1)p(o=>({...o,currentStepIndex:i,currentSubStepIndex:null,isActive:!0}));else if(t.metadata.inOrder===!1)p(o=>({...o,isActive:!1}));else{let o=t.steps[0];o&&typeof o.urlMatch=="string"&&window.location.pathname!==o.urlMatch&&w(o.urlMatch)}},[w]),(0,u.useEffect)(()=>{y&&F.default.set(Y,JSON.stringify(n),{expires:365})},[n,y]);let W=(0,u.useMemo)(()=>{let t=e.steps[n.currentStepIndex];return t?n.currentSubStepIndex!==null&&t.subSteps&&t.subSteps[n.currentSubStepIndex]||t:null},[e.steps,n.currentStepIndex,n.currentSubStepIndex]),k=n.currentStepIndex===0&&n.currentSubStepIndex===null,A=(0,u.useMemo)(()=>{let t=e.steps.length,c=n.currentStepIndex===t-1,i=e.steps[n.currentStepIndex],l=i?.subSteps&&i.subSteps.length>0;return c?l?n.currentSubStepIndex===i.subSteps.length-1:!0:!1},[e.steps,n.currentStepIndex,n.currentSubStepIndex]),E=(0,u.useCallback)(()=>{let t=d.current,c=t.steps[n.currentStepIndex],i=n.currentSubStepIndex!==null&&c.subSteps?c.subSteps[n.currentSubStepIndex]:c;if(i.click){let l=document.querySelector(`[data-onboarding-id="${i.attribute}"]`);l&&l.click()}if(c.subSteps&&(n.currentSubStepIndex===null||n.currentSubStepIndex<c.subSteps.length-1)){let l=n.currentSubStepIndex===null?0:n.currentSubStepIndex+1,o=c.subSteps[l];p(h=>({...h,currentSubStepIndex:l})),o.navigate&&w(o.navigate);return}if(n.currentStepIndex<t.steps.length-1){let l=n.currentStepIndex+1,o=t.steps[l];p({currentStepIndex:l,currentSubStepIndex:null,isActive:!0}),o.navigate&&w(o.navigate)}else p(l=>({...l,isActive:!1})),t.onOnboardingComplete&&t.onOnboardingComplete()},[n.currentStepIndex,n.currentSubStepIndex,w]),R=(0,u.useCallback)(()=>{let t=d.current,c=t.steps[n.currentStepIndex];if(n.currentSubStepIndex!==null&&n.currentSubStepIndex>0){p(i=>({...i,currentSubStepIndex:i.currentSubStepIndex-1}));return}if(n.currentSubStepIndex===0){p(i=>({...i,currentSubStepIndex:null}));return}if(n.currentStepIndex>0){let i=n.currentStepIndex-1,l=t.steps[i],o=l.subSteps?l.subSteps.length-1:null;p({currentStepIndex:i,currentSubStepIndex:o,isActive:!0})}},[n.currentStepIndex,n.currentSubStepIndex]),v=(0,u.useCallback)(()=>{p(t=>({...t,isActive:!1})),d.current.onOnboardingComplete&&d.current.onOnboardingComplete()},[]),D=(0,u.useCallback)((t,c=null)=>{p({currentStepIndex:t,currentSubStepIndex:c,isActive:!0})},[]),I={config:e,state:n,nextStep:E,prevStep:R,finish:v,goToStep:D,currentStep:W,isFirstStep:k,isLastStep:A};return y?(0,O.jsxs)(q.Provider,{value:I,children:[f,n.isActive&&(0,O.jsx)(X,{})]}):(0,O.jsx)(O.Fragment,{children:f})},$=()=>{let e=(0,u.useContext)(q);if(e===void 0)throw new Error("useOnboarding must be used within an OnboardingProvider");return e};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, { createContext, useContext, useEffect, useState, useCallback, useMemo } 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 children: React.ReactNode;\n}> = ({ config, ssr = false, 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 // Stabilize config to prevent infinite loops if the user passes a new object on every render\n const configRef = React.useRef(config);\n useEffect(() => {\n configRef.current = config;\n }, [config]);\n\n const handleNavigation = useCallback((link?: string) => {\n if (!link) return;\n \n if (configRef.current.metadata.nextRouter) {\n window.location.href = link;\n } else {\n window.location.href = link;\n }\n }, []);\n\n useEffect(() => {\n if (ssr) {\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 // Escape regex special characters but keep '*' as '.*'\n const pattern = step.urlMatch\n .replace(/[.+?^${}()|[\\]\\\\]/g, '\\\\$&') // Escape regex chars\n .replace(/\\*/g, '.*'); // Convert * to .*\n return new RegExp(`^${pattern}$`).test(path);\n }\n\n return path === step.urlMatch;\n };\n\n useEffect(() => {\n const currentConfig = configRef.current;\n const currentPath = window.location.pathname;\n let matchedStepIndex = -1;\n \n // Check if inOrder is explicitly false to find matching step from URL\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 inOrder is false\n if ((currentConfig.metadata.inOrder as boolean | undefined) === false) {\n if (matchedStepIndex !== -1) {\n // We found a matching step for this URL\n if (parsed.currentStepIndex === matchedStepIndex) {\n // If it matches the saved step, restore state (keep substeps)\n setState(parsed);\n } else {\n // Different step, switch to it\n setState(prev => ({\n ...prev,\n currentStepIndex: matchedStepIndex,\n currentSubStepIndex: null,\n isActive: true\n }));\n }\n } else {\n // inOrder is false, and NO step matches this URL.\n // We should hide the onboarding, essentially \"pausing\" it until we return to a valid page.\n setState(prev => ({ ...parsed, isActive: false }));\n }\n } else {\n // Standard behavior (inOrder: true OR no match found) - restore saved state\n setState(parsed);\n\n // Only enforce navigation if inOrder is true (or default)\n if ((currentConfig.metadata.inOrder as boolean | undefined) !== false) {\n const step = currentConfig.steps[parsed.currentStepIndex];\n if (step && parsed.isActive) {\n // Always enforce location based on the main step's urlMatch\n if (typeof step.urlMatch === 'string' && window.location.pathname !== step.urlMatch) {\n handleNavigation(step.urlMatch);\n }\n }\n }\n }\n } catch (e) {\n console.error('Failed to parse onboarding state from cookie', e);\n // Fallback if cookie fails but we have a match\n if (matchedStepIndex !== -1) {\n setState(prev => ({\n ...prev,\n currentStepIndex: matchedStepIndex,\n currentSubStepIndex: null,\n isActive: true\n }));\n }\n }\n } else if (matchedStepIndex !== -1) {\n // No cookie, but we have a URL match\n setState(prev => ({\n ...prev,\n currentStepIndex: matchedStepIndex,\n currentSubStepIndex: null,\n isActive: true\n }));\n } else if ((currentConfig.metadata.inOrder as boolean | undefined) === false) {\n // No cookie, no match, and inOrder is false.\n // We are on a page that doesn't trigger any onboarding step.\n setState(prev => ({ ...prev, isActive: false }));\n } else {\n // No cookie, no match, inOrder is true (default).\n // Enforce navigation for the default first step if needed.\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 }, [handleNavigation]); // Removed config.steps dependency\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 step = currentConfig.steps[state.currentStepIndex];\n const currentActiveStep = state.currentSubStepIndex !== null && step.subSteps \n ? step.subSteps[state.currentSubStepIndex] \n : step;\n\n // Perform click if requested for the current step before moving to the next\n if (currentActiveStep.click) {\n const element = document.querySelector(`[data-onboarding-id=\"${currentActiveStep.attribute}\"]`) as HTMLElement;\n if (element) {\n element.click();\n }\n }\n \n // Check for subSteps\n if (step.subSteps && (state.currentSubStepIndex === null || state.currentSubStepIndex < step.subSteps.length - 1)) {\n const nextSubIndex = state.currentSubStepIndex === null ? 0 : state.currentSubStepIndex + 1;\n const nextSubStep = step.subSteps[nextSubIndex];\n setState(prev => ({ ...prev, currentSubStepIndex: nextSubIndex }));\n \n if (nextSubStep.navigate) handleNavigation(nextSubStep.navigate);\n return;\n }\n\n // Move to next main step\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 const step = currentConfig.steps[state.currentStepIndex];\n\n if (state.currentSubStepIndex !== null && state.currentSubStepIndex > 0) {\n setState(prev => ({ ...prev, currentSubStepIndex: prev.currentSubStepIndex! - 1 }));\n return;\n }\n\n if (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};","\"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 } = useOnboarding();\n const [coords, setCoords] = useState<{ top: number; left: number; width: number; height: number } | 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 useEffect(() => {\n setDragOffset({ x: 0, y: 0 });\n }, [currentStep]);\n\n const handlePointerDown = (e: React.PointerEvent) => {\n if (!config.metadata.draggable) return;\n e.stopPropagation(); // Prevent click-through\n e.preventDefault(); // Prevent text selection\n isDragging.current = true;\n dragStart.current = { x: e.clientX - dragOffset.x, y: e.clientY - dragOffset.y };\n \n // Disable transition during drag for responsiveness\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 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 // Re-enable transition\n if (tooltipRef.current) {\n tooltipRef.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)';\n tooltipRef.current.style.cursor = config.metadata.draggable ? 'grab' : 'auto';\n }\n\n window.removeEventListener('pointermove', handlePointerMove);\n window.removeEventListener('pointerup', handlePointerUp);\n }, [config.metadata.draggable, handlePointerMove]);\n\n // Clean up listeners on unmount\n useEffect(() => {\n return () => {\n window.removeEventListener('pointermove', handlePointerMove);\n window.removeEventListener('pointerup', handlePointerUp);\n };\n }, [handlePointerMove, handlePointerUp]);\n\n const calculateBestPosition = useCallback((rect: { top: number; bottom: number; left: number; right: number; width: number; height: number }) => {\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(padding, Math.min(window.innerWidth - tooltipWidth - padding, rect.left + rect.width / 2 - tooltipWidth / 2));\n } else if (spaceAbove > tooltipHeight + gap + padding) {\n top = rect.top - tooltipHeight - gap;\n left = Math.max(padding, Math.min(window.innerWidth - tooltipWidth - padding, rect.left + rect.width / 2 - tooltipWidth / 2));\n } else if (spaceRight > tooltipWidth + gap + padding) {\n top = Math.max(padding, Math.min(window.innerHeight - tooltipHeight - padding, rect.top + rect.height / 2 - tooltipHeight / 2));\n left = rect.right + gap;\n } else if (spaceLeft > tooltipWidth + gap + padding) {\n top = Math.max(padding, Math.min(window.innerHeight - tooltipHeight - padding, rect.top + rect.height / 2 - tooltipHeight / 2));\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 const updateCoords = useCallback(() => {\n if (!currentStep) return;\n\n const element = document.querySelector(`[data-onboarding-id=\"${currentStep.attribute}\"]`) 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 // Prevent infinite loops by only updating if values actually changed\n setCoords(prev => {\n if (prev && \n prev.top === newCoords.top && \n prev.left === newCoords.left && \n prev.width === newCoords.width && \n prev.height === newCoords.height) {\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 width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\">\n <path d=\"M15 18l-6-6 6-6\" />\n </svg>\n );\n\n const ChevronRightIcon = () => (\n <svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\">\n <path d=\"M9 18l6-6-6-6\" />\n </svg>\n );\n\n const XIcon = () => (\n <svg width=\"18\" height=\"18\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\">\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=\"fixed inset-0 z-[999999] pointer-events-none\">\n {/* Top Mask */}\n <div\n style={{ height: coords.top, ...maskStyle }}\n className=\"onboard-overlay-mask top-0 left-0 w-full pointer-events-auto\"\n onPointerDown={stopPropagation}\n onMouseDown={stopPropagation}\n onClick={stopPropagation}\n />\n {/* Bottom Mask */}\n <div\n style={{ top: coords.top + coords.height, height: `calc(100vh - ${coords.top + coords.height}px)`, ...maskStyle }}\n className=\"onboard-overlay-mask left-0 w-full pointer-events-auto\"\n onPointerDown={stopPropagation}\n onMouseDown={stopPropagation}\n onClick={stopPropagation}\n />\n {/* Left Mask */}\n <div\n style={{ top: coords.top, height: coords.height, width: coords.left, ...maskStyle }}\n className=\"onboard-overlay-mask left-0 pointer-events-auto\"\n onPointerDown={stopPropagation}\n onMouseDown={stopPropagation}\n onClick={stopPropagation}\n />\n {/* Right Mask */}\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 pointer-events-auto\"\n onPointerDown={stopPropagation}\n onMouseDown={stopPropagation}\n onClick={stopPropagation}\n />\n\n {/* Tooltip */}\n <div\n ref={tooltipRef}\n className=\"onboard-tooltip pointer-events-auto\"\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: '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' // Prevent scrolling on touch devices while dragging\n }}\n onMouseDown={stopPropagation}\n onClick={stopPropagation}\n >\n <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'flex-start', marginBottom: '8px' }}>\n <h3 style={{ margin: 0, fontWeight: 'bold', color: '#111827', fontSize: '18px', lineHeight: 1.2 }}>{currentStep.title}</h3>\n <button \n onClick={(e) => { e.stopPropagation(); finish(); }}\n style={{ background: 'none', border: 'none', cursor: 'pointer', padding: '4px', color: '#9ca3af' }}\n >\n <XIcon />\n </button>\n </div>\n <p style={{ margin: 0, color: '#4b5563', fontSize: '14px', marginBottom: '24px', lineHeight: 1.5 }}>\n {currentStep.description}\n </p>\n \n <div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between' }}>\n <button\n onClick={(e) => { e.stopPropagation(); prevStep(); }}\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) => { e.stopPropagation(); finish(); }}\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) => { e.stopPropagation(); nextStep(); }}\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' \n ? createPortal(overlayContent, document.body) \n : null;\n};\n"],"mappings":";6kBAAA,IAAAA,GAAA,GAAAC,GAAAD,GAAA,wBAAAE,GAAA,kBAAAC,IAAA,eAAAC,GAAAJ,ICEA,IAAAK,EAA4F,oBAC5FC,EAAoB,wBCDpB,IAAAC,EAAgE,iBAChEC,EAA6B,qBA6LvB,IAAAC,EAAA,6BA1LOC,EAA8B,IAAM,CAC/C,GAAM,CAAE,OAAAC,EAAQ,YAAAC,EAAa,SAAAC,EAAU,SAAAC,EAAU,OAAAC,EAAQ,YAAAC,EAAa,WAAAC,CAAW,EAAIC,EAAc,EAC7F,CAACC,EAAQC,CAAS,KAAI,YAA8E,IAAI,EACxG,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,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ACF,CAEA,GAAIhB,EAAM,iBAAmB,EAAG,CAC9B,IAAMgC,EAAYhC,EAAM,iBAAmB,EACrCiC,EAAcvB,EAAc,MAAMsB,CAAS,EAC3CE,EAAmBD,EAAY,SAAWA,EAAY,SAAS,OAAS,EAAI,KAElFhC,EAAS,CACP,iBAAkB+B,EAClB,oBAAqBE,EACrB,SAAU,EACZ,CAAC,CACH,CACF,EAAG,CAAClC,EAAM,iBAAkBA,EAAM,mBAAmB,CAAC,EAEhDmC,KAAS,eAAY,IAAM,CAC/BlC,EAASe,IAAS,CAAE,GAAGA,EAAM,SAAU,EAAM,EAAE,EAC3Cd,EAAU,QAAQ,sBACpBA,EAAU,QAAQ,qBAAqB,CAE3C,EAAG,CAAC,CAAC,EAECkC,KAAW,eAAY,CAACC,EAAmBC,EAA8B,OAAS,CACtFrC,EAAS,CACP,iBAAkBoC,EAClB,oBAAqBC,EACrB,SAAU,EACZ,CAAC,CACH,EAAG,CAAC,CAAC,EAECC,EAAQ,CACZ,OAAA5C,EACA,MAAAK,EACA,SAAAwB,EACA,SAAAO,EACA,OAAAI,EACA,SAAAC,EACA,YAAAlB,EACA,YAAAC,EACA,WAAAC,CACF,EAEA,OAAKtB,KAGH,QAACN,EAAkB,SAAlB,CAA2B,MAAO+C,EAChC,UAAA1C,EACAG,EAAM,aAAY,OAACwC,EAAA,EAAkB,GACxC,KANqB,mBAAG,SAAA3C,EAAS,CAQrC,EAEa4C,EAAgB,IAAM,CACjC,IAAMC,KAAU,cAAWlD,CAAiB,EAC5C,GAAIkD,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","handlePointerDown","e","handlePointerMove","handlePointerUp","newX","newY","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","children","isMounted","setIsMounted","state","setState","configRef","React","handleNavigation","link","isMatch","step","path","pattern","currentConfig","currentPath","matchedStepIndex","savedState","Cookies","parsed","prev","e","currentStep","isFirstStep","isLastStep","totalSteps","isLastMainStep","hasSubSteps","nextStep","currentActiveStep","element","nextSubIndex","nextSubStep","nextIndex","nextStepObj","prevStep","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, { createContext, useContext, useEffect, useState, useCallback, useMemo } 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 children: React.ReactNode;\n}> = ({ config, ssr = false, 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 // Stabilize config to prevent infinite loops if the user passes a new object on every render\n const configRef = React.useRef(config);\n useEffect(() => {\n configRef.current = config;\n }, [config]);\n\n const handleNavigation = useCallback((link?: string) => {\n if (!link) return;\n \n if (configRef.current.metadata.nextRouter) {\n window.location.href = link;\n } else {\n window.location.href = link;\n }\n }, []);\n\n useEffect(() => {\n if (ssr) {\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 // Escape regex special characters but keep '*' as '.*'\n const pattern = step.urlMatch\n .replace(/[.+?^${}()|[\\]\\\\]/g, '\\\\$&') // Escape regex chars\n .replace(/\\*/g, '.*'); // Convert * to .*\n return new RegExp(`^${pattern}$`).test(path);\n }\n\n return path === step.urlMatch;\n };\n\n useEffect(() => {\n const currentConfig = configRef.current;\n const currentPath = window.location.pathname;\n let matchedStepIndex = -1;\n \n // Check if inOrder is explicitly false to find matching step from URL\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 inOrder is false\n if ((currentConfig.metadata.inOrder as boolean | undefined) === false) {\n if (matchedStepIndex !== -1) {\n // We found a matching step for this URL\n if (parsed.currentStepIndex === matchedStepIndex) {\n // If it matches the saved step, restore state (keep substeps)\n setState(parsed);\n } else {\n // Different step, switch to it\n setState(prev => ({\n ...prev,\n currentStepIndex: matchedStepIndex,\n currentSubStepIndex: null,\n isActive: true\n }));\n }\n } else {\n // inOrder is false, and NO step matches this URL.\n // We should hide the onboarding, essentially \"pausing\" it until we return to a valid page.\n setState(prev => ({ ...parsed, isActive: false }));\n }\n } else {\n // Standard behavior (inOrder: true OR no match found) - restore saved state\n setState(parsed);\n\n // Only enforce navigation if inOrder is true (or default)\n if ((currentConfig.metadata.inOrder as boolean | undefined) !== false) {\n const step = currentConfig.steps[parsed.currentStepIndex];\n if (step && parsed.isActive) {\n // Always enforce location based on the main step's urlMatch\n if (typeof step.urlMatch === 'string' && window.location.pathname !== step.urlMatch) {\n handleNavigation(step.urlMatch);\n }\n }\n }\n }\n } catch (e) {\n console.error('Failed to parse onboarding state from cookie', e);\n // Fallback if cookie fails but we have a match\n if (matchedStepIndex !== -1) {\n setState(prev => ({\n ...prev,\n currentStepIndex: matchedStepIndex,\n currentSubStepIndex: null,\n isActive: true\n }));\n }\n }\n } else if (matchedStepIndex !== -1) {\n // No cookie, but we have a URL match\n setState(prev => ({\n ...prev,\n currentStepIndex: matchedStepIndex,\n currentSubStepIndex: null,\n isActive: true\n }));\n } else if ((currentConfig.metadata.inOrder as boolean | undefined) === false) {\n // No cookie, no match, and inOrder is false.\n // We are on a page that doesn't trigger any onboarding step.\n setState(prev => ({ ...prev, isActive: false }));\n } else {\n // No cookie, no match, inOrder is true (default).\n // Enforce navigation for the default first step if needed.\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 }, [handleNavigation]); // Removed config.steps dependency\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 step = currentConfig.steps[state.currentStepIndex];\n const currentActiveStep = state.currentSubStepIndex !== null && step.subSteps \n ? step.subSteps[state.currentSubStepIndex] \n : step;\n\n // Perform click if requested for the current step before moving to the next\n if (currentActiveStep.click) {\n const element = document.querySelector(`[data-onboarding-id=\"${currentActiveStep.attribute}\"]`) as HTMLElement;\n if (element) {\n element.click();\n }\n }\n \n // Check for subSteps\n if (step.subSteps && (state.currentSubStepIndex === null || state.currentSubStepIndex < step.subSteps.length - 1)) {\n const nextSubIndex = state.currentSubStepIndex === null ? 0 : state.currentSubStepIndex + 1;\n const nextSubStep = step.subSteps[nextSubIndex];\n setState(prev => ({ ...prev, currentSubStepIndex: nextSubIndex }));\n \n if (nextSubStep.navigate) handleNavigation(nextSubStep.navigate);\n return;\n }\n\n // Move to next main step\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 const step = currentConfig.steps[state.currentStepIndex];\n\n if (state.currentSubStepIndex !== null && state.currentSubStepIndex > 0) {\n setState(prev => ({ ...prev, currentSubStepIndex: prev.currentSubStepIndex! - 1 }));\n return;\n }\n\n if (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};","\"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 } = useOnboarding();\n const [coords, setCoords] = useState<{ top: number; left: number; width: number; height: number } | 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 useEffect(() => {\n setDragOffset({ x: 0, y: 0 });\n }, [currentStep]);\n\n const handlePointerDown = (e: React.PointerEvent) => {\n if (!config.metadata.draggable) return;\n e.stopPropagation(); // Prevent click-through\n e.preventDefault(); // Prevent text selection\n isDragging.current = true;\n dragStart.current = { x: e.clientX - dragOffset.x, y: e.clientY - dragOffset.y };\n \n // Disable transition during drag for responsiveness\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 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 // Re-enable transition\n if (tooltipRef.current) {\n tooltipRef.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)';\n tooltipRef.current.style.cursor = config.metadata.draggable ? 'grab' : 'auto';\n }\n\n window.removeEventListener('pointermove', handlePointerMove);\n window.removeEventListener('pointerup', handlePointerUp);\n }, [config.metadata.draggable, handlePointerMove]);\n\n // Clean up listeners on unmount\n useEffect(() => {\n return () => {\n window.removeEventListener('pointermove', handlePointerMove);\n window.removeEventListener('pointerup', handlePointerUp);\n };\n }, [handlePointerMove, handlePointerUp]);\n\n const calculateBestPosition = useCallback((rect: { top: number; bottom: number; left: number; right: number; width: number; height: number }) => {\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(padding, Math.min(window.innerWidth - tooltipWidth - padding, rect.left + rect.width / 2 - tooltipWidth / 2));\n } else if (spaceAbove > tooltipHeight + gap + padding) {\n top = rect.top - tooltipHeight - gap;\n left = Math.max(padding, Math.min(window.innerWidth - tooltipWidth - padding, rect.left + rect.width / 2 - tooltipWidth / 2));\n } else if (spaceRight > tooltipWidth + gap + padding) {\n top = Math.max(padding, Math.min(window.innerHeight - tooltipHeight - padding, rect.top + rect.height / 2 - tooltipHeight / 2));\n left = rect.right + gap;\n } else if (spaceLeft > tooltipWidth + gap + padding) {\n top = Math.max(padding, Math.min(window.innerHeight - tooltipHeight - padding, rect.top + rect.height / 2 - tooltipHeight / 2));\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 const updateCoords = useCallback(() => {\n if (!currentStep) return;\n\n const element = document.querySelector(`[data-onboarding-id=\"${currentStep.attribute}\"]`) 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 // Prevent infinite loops by only updating if values actually changed\n setCoords(prev => {\n if (prev && \n prev.top === newCoords.top && \n prev.left === newCoords.left && \n prev.width === newCoords.width && \n prev.height === newCoords.height) {\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 width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\">\n <path d=\"M15 18l-6-6 6-6\" />\n </svg>\n );\n\n const ChevronRightIcon = () => (\n <svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\">\n <path d=\"M9 18l6-6-6-6\" />\n </svg>\n );\n\n const XIcon = () => (\n <svg width=\"18\" height=\"18\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\">\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 {/* Top Mask */}\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 {/* Bottom Mask */}\n <div\n style={{ top: coords.top + coords.height, height: `calc(100vh - ${coords.top + coords.height}px)`, ...maskStyle }}\n className=\"onboard-overlay-mask onboard-mask-bottom\"\n onPointerDown={stopPropagation}\n onMouseDown={stopPropagation}\n onClick={stopPropagation}\n />\n {/* Left Mask */}\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 {/* Right Mask */}\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 {/* Tooltip */}\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: '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' // Prevent scrolling on touch devices while dragging\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) => { e.stopPropagation(); finish(); }}\n className=\"onboard-close-button\"\n >\n <XIcon />\n </button>\n </div>\n <p className=\"onboard-tooltip-description\">\n {currentStep.description}\n </p>\n \n <div className=\"onboard-tooltip-footer\">\n <button\n onClick={(e) => { e.stopPropagation(); prevStep(); }}\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) => { e.stopPropagation(); finish(); }}\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) => { e.stopPropagation(); nextStep(); }}\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' \n ? createPortal(overlayContent, document.body) \n : null;\n};\n"],"mappings":";6kBAAA,IAAAA,GAAA,GAAAC,GAAAD,GAAA,wBAAAE,GAAA,kBAAAC,IAAA,eAAAC,GAAAJ,ICEA,IAAAK,EAA4F,oBAC5FC,EAAoB,wBCDpB,IAAAC,EAAgE,iBAChEC,EAA6B,qBA6LvB,IAAAC,EAAA,6BA1LOC,EAA8B,IAAM,CAC/C,GAAM,CAAE,OAAAC,EAAQ,YAAAC,EAAa,SAAAC,EAAU,SAAAC,EAAU,OAAAC,EAAQ,YAAAC,EAAa,WAAAC,CAAW,EAAIC,EAAc,EAC7F,CAACC,EAAQC,CAAS,KAAI,YAA8E,IAAI,EACxG,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,EA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kBA,EAAM,mBAAmB,CAAC,EAEhDmC,KAAS,eAAY,IAAM,CAC/BlC,EAASe,IAAS,CAAE,GAAGA,EAAM,SAAU,EAAM,EAAE,EAC3Cd,EAAU,QAAQ,sBACpBA,EAAU,QAAQ,qBAAqB,CAE3C,EAAG,CAAC,CAAC,EAECkC,KAAW,eAAY,CAACC,EAAmBC,EAA8B,OAAS,CACtFrC,EAAS,CACP,iBAAkBoC,EAClB,oBAAqBC,EACrB,SAAU,EACZ,CAAC,CACH,EAAG,CAAC,CAAC,EAECC,EAAQ,CACZ,OAAA5C,EACA,MAAAK,EACA,SAAAwB,EACA,SAAAO,EACA,OAAAI,EACA,SAAAC,EACA,YAAAlB,EACA,YAAAC,EACA,WAAAC,CACF,EAEA,OAAKtB,KAGH,QAACN,EAAkB,SAAlB,CAA2B,MAAO+C,EAChC,UAAA1C,EACAG,EAAM,aAAY,OAACwC,EAAA,EAAkB,GACxC,KANqB,mBAAG,SAAA3C,EAAS,CAQrC,EAEa4C,EAAgB,IAAM,CACjC,IAAMC,KAAU,cAAWlD,CAAiB,EAC5C,GAAIkD,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","handlePointerDown","e","handlePointerMove","handlePointerUp","newX","newY","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","children","isMounted","setIsMounted","state","setState","configRef","React","handleNavigation","link","isMatch","step","path","pattern","currentConfig","currentPath","matchedStepIndex","savedState","Cookies","parsed","prev","e","currentStep","isFirstStep","isLastStep","totalSteps","isLastMainStep","hasSubSteps","nextStep","currentActiveStep","element","nextSubIndex","nextSubStep","nextIndex","nextStepObj","prevStep","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 et,{createContext as nt,useContext as ot,useEffect as W,useState as j,useCallback as L,useMemo as Y}from"react";import q from"js-cookie";import{useState as $,useEffect as B,useCallback as A,useRef as F}from"react";import{createPortal as tt}from"react-dom";import{jsx as l,jsxs as m}from"react/jsx-runtime";var T=()=>{let{config:i,currentStep:p,nextStep:E,prevStep:C,finish:R,isFirstStep:e,isLastStep:u}=X(),[s,h]=$(null),[z,D]=$({top:0,left:0}),[v,H]=$({x:0,y:0}),k=F(!1),M=F({x:0,y:0}),S=F(null);B(()=>{H({x:0,y:0})},[p]);let N=o=>{i.metadata.draggable&&(o.stopPropagation(),o.preventDefault(),k.current=!0,M.current={x:o.clientX-v.x,y:o.clientY-v.y},S.current&&(S.current.style.transition="none",S.current.style.cursor="grabbing"),window.addEventListener("pointermove",x),window.addEventListener("pointerup",t))},x=A(o=>{if(!k.current)return;let c=o.clientX-M.current.x,g=o.clientY-M.current.y;H({x:c,y:g})},[]),t=A(()=>{k.current=!1,S.current&&(S.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)",S.current.style.cursor=i.metadata.draggable?"grab":"auto"),window.removeEventListener("pointermove",x),window.removeEventListener("pointerup",t)},[i.metadata.draggable,x]);B(()=>()=>{window.removeEventListener("pointermove",x),window.removeEventListener("pointerup",t)},[x,t]);let d=A(o=>{let P=o.top,f=window.innerHeight-o.bottom,V=o.left,Z=window.innerWidth-o.right,I=0,O=0;return f>232?(I=o.bottom+12,O=Math.max(20,Math.min(window.innerWidth-300-20,o.left+o.width/2-300/2))):P>232?(I=o.top-200-12,O=Math.max(20,Math.min(window.innerWidth-300-20,o.left+o.width/2-300/2))):Z>332?(I=Math.max(20,Math.min(window.innerHeight-200-20,o.top+o.height/2-200/2)),O=o.right+12):V>332?(I=Math.max(20,Math.min(window.innerHeight-200-20,o.top+o.height/2-200/2)),O=o.left-300-12):(I=window.innerHeight/2-200/2,O=window.innerWidth/2-300/2),{top:I+window.scrollY,left:O+window.scrollX}},[]),r=A(()=>{if(!p)return;let o=document.querySelector(`[data-onboarding-id="${p.attribute}"]`);if(o){let c=o.getBoundingClientRect(),g=i.style?.padding||0,w={top:c.top-g,bottom:c.bottom+g,left:c.left-g,right:c.right+g,width:c.width+g*2,height:c.height+g*2},y={top:w.top+window.scrollY,left:w.left+window.scrollX,width:w.width,height:w.height},P=d(w);h(f=>f&&f.top===y.top&&f.left===y.left&&f.width===y.width&&f.height===y.height?f:y),D(f=>f.top===P.top&&f.left===P.left?f:P)}else h(null)},[p,d,i.style]);if(B(()=>{r(),window.addEventListener("resize",r),window.addEventListener("scroll",r);let o=new MutationObserver(r);o.observe(document.body,{childList:!0,subtree:!0,attributes:!0});let c=null;if(typeof ResizeObserver<"u"){c=new ResizeObserver(r),c.observe(document.body);let g=p?.attribute?document.querySelector(`[data-onboarding-id="${p.attribute}"]`):null;g&&c.observe(g)}return()=>{window.removeEventListener("resize",r),window.removeEventListener("scroll",r),o.disconnect(),c&&c.disconnect()}},[r,p?.attribute]),!p||!s)return null;let a={...i.style?.background,transition:"all 0.3s cubic-bezier(0.25, 0.1, 0.25, 1)"},n=o=>{o.stopPropagation()},b=()=>l("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:l("path",{d:"M15 18l-6-6 6-6"})}),U=()=>l("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:l("path",{d:"M9 18l6-6-6-6"})}),G=()=>m("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[l("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),l("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]}),Q=m("div",{className:"fixed inset-0 z-[999999] pointer-events-none",children:[l("div",{style:{height:s.top,...a},className:"onboard-overlay-mask top-0 left-0 w-full pointer-events-auto",onPointerDown:n,onMouseDown:n,onClick:n}),l("div",{style:{top:s.top+s.height,height:`calc(100vh - ${s.top+s.height}px)`,...a},className:"onboard-overlay-mask left-0 w-full pointer-events-auto",onPointerDown:n,onMouseDown:n,onClick:n}),l("div",{style:{top:s.top,height:s.height,width:s.left,...a},className:"onboard-overlay-mask left-0 pointer-events-auto",onPointerDown:n,onMouseDown:n,onClick:n}),l("div",{style:{top:s.top,height:s.height,left:s.left+s.width,width:`calc(100% - ${s.left+s.width}px)`,...a},className:"onboard-overlay-mask pointer-events-auto",onPointerDown:n,onMouseDown:n,onClick:n}),m("div",{ref:S,className:"onboard-tooltip pointer-events-auto",onPointerDown:N,style:{zIndex:1e6,...i.style?.container,top:z.top+v.y,left:z.left+v.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:[m("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",marginBottom:"8px"},children:[l("h3",{style:{margin:0,fontWeight:"bold",color:"#111827",fontSize:"18px",lineHeight:1.2},children:p.title}),l("button",{onClick:o=>{o.stopPropagation(),R()},style:{background:"none",border:"none",cursor:"pointer",padding:"4px",color:"#9ca3af"},children:l(G,{})})]}),l("p",{style:{margin:0,color:"#4b5563",fontSize:"14px",marginBottom:"24px",lineHeight:1.5},children:p.description}),m("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[m("button",{onClick:o=>{o.stopPropagation(),C()},disabled:e,className:"onboard-button-ghost",style:{background:"none",border:"none",cursor:e?"not-allowed":"pointer",...i.style?.prev},children:[l(b,{}),"Prev"]}),u?l("button",{onClick:o=>{o.stopPropagation(),R()},className:"onboard-button-primary",style:{border:"none",cursor:"pointer",...i.style?.finish},children:"Finish"}):m("button",{onClick:o=>{o.stopPropagation(),E()},className:"onboard-button-primary",style:{border:"none",cursor:"pointer",...e?i.style?.start:{},...e?{}:i.style?.next},children:[e&&i.style?.start?"Start":"Next",!(e&&i.style?.start)&&l(U,{})]})]})]})]});return typeof document<"u"?tt(Q,document.body):null};import{Fragment as rt,jsx as _,jsxs as it}from"react/jsx-runtime";var K=nt(void 0),J="onboarding_state",St=({config:i,ssr:p=!1,children:E})=>{let[C,R]=j(!p),[e,u]=j({currentStepIndex:0,currentSubStepIndex:null,isActive:!0}),s=et.useRef(i);W(()=>{s.current=i},[i]);let h=L(t=>{t&&(s.current.metadata.nextRouter,window.location.href=t)},[]);W(()=>{p&&R(!0)},[p]);let z=(t,d)=>{if(t.urlMatch instanceof RegExp)return t.urlMatch.test(d);if(typeof t.urlMatch=="string"&&t.urlMatch.includes("*")){let r=t.urlMatch.replace(/[.+?^${}()|[\]\\]/g,"\\$&").replace(/\*/g,".*");return new RegExp(`^${r}$`).test(d)}return d===t.urlMatch};W(()=>{let t=s.current,d=window.location.pathname,r=-1;t.metadata.inOrder===!1&&(r=t.steps.findIndex(n=>z(n,d)));let a=q.get(J);if(a)try{let n=JSON.parse(a);if(t.metadata.inOrder===!1)r!==-1?n.currentStepIndex===r?u(n):u(b=>({...b,currentStepIndex:r,currentSubStepIndex:null,isActive:!0})):u(b=>({...n,isActive:!1}));else if(u(n),t.metadata.inOrder!==!1){let b=t.steps[n.currentStepIndex];b&&n.isActive&&typeof b.urlMatch=="string"&&window.location.pathname!==b.urlMatch&&h(b.urlMatch)}}catch(n){console.error("Failed to parse onboarding state from cookie",n),r!==-1&&u(b=>({...b,currentStepIndex:r,currentSubStepIndex:null,isActive:!0}))}else if(r!==-1)u(n=>({...n,currentStepIndex:r,currentSubStepIndex:null,isActive:!0}));else if(t.metadata.inOrder===!1)u(n=>({...n,isActive:!1}));else{let n=t.steps[0];n&&typeof n.urlMatch=="string"&&window.location.pathname!==n.urlMatch&&h(n.urlMatch)}},[h]),W(()=>{C&&q.set(J,JSON.stringify(e),{expires:365})},[e,C]);let D=Y(()=>{let t=i.steps[e.currentStepIndex];return t?e.currentSubStepIndex!==null&&t.subSteps&&t.subSteps[e.currentSubStepIndex]||t:null},[i.steps,e.currentStepIndex,e.currentSubStepIndex]),v=e.currentStepIndex===0&&e.currentSubStepIndex===null,H=Y(()=>{let t=i.steps.length,d=e.currentStepIndex===t-1,r=i.steps[e.currentStepIndex],a=r?.subSteps&&r.subSteps.length>0;return d?a?e.currentSubStepIndex===r.subSteps.length-1:!0:!1},[i.steps,e.currentStepIndex,e.currentSubStepIndex]),k=L(()=>{let t=s.current,d=t.steps[e.currentStepIndex],r=e.currentSubStepIndex!==null&&d.subSteps?d.subSteps[e.currentSubStepIndex]:d;if(r.click){let a=document.querySelector(`[data-onboarding-id="${r.attribute}"]`);a&&a.click()}if(d.subSteps&&(e.currentSubStepIndex===null||e.currentSubStepIndex<d.subSteps.length-1)){let a=e.currentSubStepIndex===null?0:e.currentSubStepIndex+1,n=d.subSteps[a];u(b=>({...b,currentSubStepIndex:a})),n.navigate&&h(n.navigate);return}if(e.currentStepIndex<t.steps.length-1){let a=e.currentStepIndex+1,n=t.steps[a];u({currentStepIndex:a,currentSubStepIndex:null,isActive:!0}),n.navigate&&h(n.navigate)}else u(a=>({...a,isActive:!1})),t.onOnboardingComplete&&t.onOnboardingComplete()},[e.currentStepIndex,e.currentSubStepIndex,h]),M=L(()=>{let t=s.current,d=t.steps[e.currentStepIndex];if(e.currentSubStepIndex!==null&&e.currentSubStepIndex>0){u(r=>({...r,currentSubStepIndex:r.currentSubStepIndex-1}));return}if(e.currentSubStepIndex===0){u(r=>({...r,currentSubStepIndex:null}));return}if(e.currentStepIndex>0){let r=e.currentStepIndex-1,a=t.steps[r],n=a.subSteps?a.subSteps.length-1:null;u({currentStepIndex:r,currentSubStepIndex:n,isActive:!0})}},[e.currentStepIndex,e.currentSubStepIndex]),S=L(()=>{u(t=>({...t,isActive:!1})),s.current.onOnboardingComplete&&s.current.onOnboardingComplete()},[]),N=L((t,d=null)=>{u({currentStepIndex:t,currentSubStepIndex:d,isActive:!0})},[]),x={config:i,state:e,nextStep:k,prevStep:M,finish:S,goToStep:N,currentStep:D,isFirstStep:v,isLastStep:H};return C?it(K.Provider,{value:x,children:[E,e.isActive&&_(T,{})]}):_(rt,{children:E})},X=()=>{let i=ot(K);if(i===void 0)throw new Error("useOnboarding must be used within an OnboardingProvider");return i};export{St as OnboardingProvider,X as useOnboarding};
2
+ "use client";import et,{createContext as nt,useContext as ot,useEffect as H,useState as X,useCallback as L,useMemo as Y}from"react";import q from"js-cookie";import{useState as $,useEffect as F,useCallback as A,useRef as T}from"react";import{createPortal as tt}from"react-dom";import{jsx as u,jsxs as x}from"react/jsx-runtime";var j=()=>{let{config:i,currentStep:p,nextStep:E,prevStep:k,finish:R,isFirstStep:e,isLastStep:l}=B(),[s,h]=$(null),[z,W]=$({top:0,left:0}),[w,N]=$({x:0,y:0}),C=T(!1),M=T({x:0,y:0}),S=T(null);F(()=>{N({x:0,y:0})},[p]);let D=o=>{i.metadata.draggable&&(o.stopPropagation(),o.preventDefault(),C.current=!0,M.current={x:o.clientX-w.x,y:o.clientY-w.y},S.current&&(S.current.style.transition="none",S.current.style.cursor="grabbing"),window.addEventListener("pointermove",m),window.addEventListener("pointerup",t))},m=A(o=>{if(!C.current)return;let c=o.clientX-M.current.x,g=o.clientY-M.current.y;N({x:c,y:g})},[]),t=A(()=>{C.current=!1,S.current&&(S.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)",S.current.style.cursor=i.metadata.draggable?"grab":"auto"),window.removeEventListener("pointermove",m),window.removeEventListener("pointerup",t)},[i.metadata.draggable,m]);F(()=>()=>{window.removeEventListener("pointermove",m),window.removeEventListener("pointerup",t)},[m,t]);let d=A(o=>{let P=o.top,f=window.innerHeight-o.bottom,V=o.left,Z=window.innerWidth-o.right,I=0,O=0;return f>232?(I=o.bottom+12,O=Math.max(20,Math.min(window.innerWidth-300-20,o.left+o.width/2-300/2))):P>232?(I=o.top-200-12,O=Math.max(20,Math.min(window.innerWidth-300-20,o.left+o.width/2-300/2))):Z>332?(I=Math.max(20,Math.min(window.innerHeight-200-20,o.top+o.height/2-200/2)),O=o.right+12):V>332?(I=Math.max(20,Math.min(window.innerHeight-200-20,o.top+o.height/2-200/2)),O=o.left-300-12):(I=window.innerHeight/2-200/2,O=window.innerWidth/2-300/2),{top:I+window.scrollY,left:O+window.scrollX}},[]),r=A(()=>{if(!p)return;let o=document.querySelector(`[data-onboarding-id="${p.attribute}"]`);if(o){let c=o.getBoundingClientRect(),g=i.style?.padding||0,v={top:c.top-g,bottom:c.bottom+g,left:c.left-g,right:c.right+g,width:c.width+g*2,height:c.height+g*2},y={top:v.top+window.scrollY,left:v.left+window.scrollX,width:v.width,height:v.height},P=d(v);h(f=>f&&f.top===y.top&&f.left===y.left&&f.width===y.width&&f.height===y.height?f:y),W(f=>f.top===P.top&&f.left===P.left?f:P)}else h(null)},[p,d,i.style]);if(F(()=>{r(),window.addEventListener("resize",r),window.addEventListener("scroll",r);let o=new MutationObserver(r);o.observe(document.body,{childList:!0,subtree:!0,attributes:!0});let c=null;if(typeof ResizeObserver<"u"){c=new ResizeObserver(r),c.observe(document.body);let g=p?.attribute?document.querySelector(`[data-onboarding-id="${p.attribute}"]`):null;g&&c.observe(g)}return()=>{window.removeEventListener("resize",r),window.removeEventListener("scroll",r),o.disconnect(),c&&c.disconnect()}},[r,p?.attribute]),!p||!s)return null;let a={...i.style?.background,transition:"all 0.3s cubic-bezier(0.25, 0.1, 0.25, 1)"},n=o=>{o.stopPropagation()},b=()=>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"})}),U=()=>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"})}),G=()=>x("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"})]}),Q=x("div",{className:"onboard-overlay-container",children:[u("div",{style:{height:s.top,...a},className:"onboard-overlay-mask onboard-mask-top",onPointerDown:n,onMouseDown:n,onClick:n}),u("div",{style:{top:s.top+s.height,height:`calc(100vh - ${s.top+s.height}px)`,...a},className:"onboard-overlay-mask onboard-mask-bottom",onPointerDown:n,onMouseDown:n,onClick:n}),u("div",{style:{top:s.top,height:s.height,width:s.left,...a},className:"onboard-overlay-mask onboard-mask-left",onPointerDown:n,onMouseDown:n,onClick:n}),u("div",{style:{top:s.top,height:s.height,left:s.left+s.width,width:`calc(100% - ${s.left+s.width}px)`,...a},className:"onboard-overlay-mask",onPointerDown:n,onMouseDown:n,onClick:n}),x("div",{ref:S,className:"onboard-tooltip",onPointerDown:D,style:{zIndex:1e6,...i.style?.container,top:z.top+w.y,left:z.left+w.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:[x("div",{className:"onboard-tooltip-header",children:[u("h3",{className:"onboard-tooltip-title",children:p.title}),u("button",{onClick:o=>{o.stopPropagation(),R()},className:"onboard-close-button",children:u(G,{})})]}),u("p",{className:"onboard-tooltip-description",children:p.description}),x("div",{className:"onboard-tooltip-footer",children:[x("button",{onClick:o=>{o.stopPropagation(),k()},disabled:e,className:"onboard-button-ghost",style:{background:"none",border:"none",cursor:e?"not-allowed":"pointer",...i.style?.prev},children:[u(b,{}),"Prev"]}),l?u("button",{onClick:o=>{o.stopPropagation(),R()},className:"onboard-button-primary",style:{border:"none",cursor:"pointer",...i.style?.finish},children:"Finish"}):x("button",{onClick:o=>{o.stopPropagation(),E()},className:"onboard-button-primary",style:{border:"none",cursor:"pointer",...e?i.style?.start:{},...e?{}:i.style?.next},children:[e&&i.style?.start?"Start":"Next",!(e&&i.style?.start)&&u(U,{})]})]})]})]});return typeof document<"u"?tt(Q,document.body):null};import{Fragment as rt,jsx as _,jsxs as it}from"react/jsx-runtime";var K=nt(void 0),J="onboarding_state",St=({config:i,ssr:p=!1,children:E})=>{let[k,R]=X(!p),[e,l]=X({currentStepIndex:0,currentSubStepIndex:null,isActive:!0}),s=et.useRef(i);H(()=>{s.current=i},[i]);let h=L(t=>{t&&(s.current.metadata.nextRouter,window.location.href=t)},[]);H(()=>{p&&R(!0)},[p]);let z=(t,d)=>{if(t.urlMatch instanceof RegExp)return t.urlMatch.test(d);if(typeof t.urlMatch=="string"&&t.urlMatch.includes("*")){let r=t.urlMatch.replace(/[.+?^${}()|[\]\\]/g,"\\$&").replace(/\*/g,".*");return new RegExp(`^${r}$`).test(d)}return d===t.urlMatch};H(()=>{let t=s.current,d=window.location.pathname,r=-1;t.metadata.inOrder===!1&&(r=t.steps.findIndex(n=>z(n,d)));let a=q.get(J);if(a)try{let n=JSON.parse(a);if(t.metadata.inOrder===!1)r!==-1?n.currentStepIndex===r?l(n):l(b=>({...b,currentStepIndex:r,currentSubStepIndex:null,isActive:!0})):l(b=>({...n,isActive:!1}));else if(l(n),t.metadata.inOrder!==!1){let b=t.steps[n.currentStepIndex];b&&n.isActive&&typeof b.urlMatch=="string"&&window.location.pathname!==b.urlMatch&&h(b.urlMatch)}}catch(n){console.error("Failed to parse onboarding state from cookie",n),r!==-1&&l(b=>({...b,currentStepIndex:r,currentSubStepIndex:null,isActive:!0}))}else if(r!==-1)l(n=>({...n,currentStepIndex:r,currentSubStepIndex:null,isActive:!0}));else if(t.metadata.inOrder===!1)l(n=>({...n,isActive:!1}));else{let n=t.steps[0];n&&typeof n.urlMatch=="string"&&window.location.pathname!==n.urlMatch&&h(n.urlMatch)}},[h]),H(()=>{k&&q.set(J,JSON.stringify(e),{expires:365})},[e,k]);let W=Y(()=>{let t=i.steps[e.currentStepIndex];return t?e.currentSubStepIndex!==null&&t.subSteps&&t.subSteps[e.currentSubStepIndex]||t:null},[i.steps,e.currentStepIndex,e.currentSubStepIndex]),w=e.currentStepIndex===0&&e.currentSubStepIndex===null,N=Y(()=>{let t=i.steps.length,d=e.currentStepIndex===t-1,r=i.steps[e.currentStepIndex],a=r?.subSteps&&r.subSteps.length>0;return d?a?e.currentSubStepIndex===r.subSteps.length-1:!0:!1},[i.steps,e.currentStepIndex,e.currentSubStepIndex]),C=L(()=>{let t=s.current,d=t.steps[e.currentStepIndex],r=e.currentSubStepIndex!==null&&d.subSteps?d.subSteps[e.currentSubStepIndex]:d;if(r.click){let a=document.querySelector(`[data-onboarding-id="${r.attribute}"]`);a&&a.click()}if(d.subSteps&&(e.currentSubStepIndex===null||e.currentSubStepIndex<d.subSteps.length-1)){let a=e.currentSubStepIndex===null?0:e.currentSubStepIndex+1,n=d.subSteps[a];l(b=>({...b,currentSubStepIndex:a})),n.navigate&&h(n.navigate);return}if(e.currentStepIndex<t.steps.length-1){let a=e.currentStepIndex+1,n=t.steps[a];l({currentStepIndex:a,currentSubStepIndex:null,isActive:!0}),n.navigate&&h(n.navigate)}else l(a=>({...a,isActive:!1})),t.onOnboardingComplete&&t.onOnboardingComplete()},[e.currentStepIndex,e.currentSubStepIndex,h]),M=L(()=>{let t=s.current,d=t.steps[e.currentStepIndex];if(e.currentSubStepIndex!==null&&e.currentSubStepIndex>0){l(r=>({...r,currentSubStepIndex:r.currentSubStepIndex-1}));return}if(e.currentSubStepIndex===0){l(r=>({...r,currentSubStepIndex:null}));return}if(e.currentStepIndex>0){let r=e.currentStepIndex-1,a=t.steps[r],n=a.subSteps?a.subSteps.length-1:null;l({currentStepIndex:r,currentSubStepIndex:n,isActive:!0})}},[e.currentStepIndex,e.currentSubStepIndex]),S=L(()=>{l(t=>({...t,isActive:!1})),s.current.onOnboardingComplete&&s.current.onOnboardingComplete()},[]),D=L((t,d=null)=>{l({currentStepIndex:t,currentSubStepIndex:d,isActive:!0})},[]),m={config:i,state:e,nextStep:C,prevStep:M,finish:S,goToStep:D,currentStep:W,isFirstStep:w,isLastStep:N};return k?it(K.Provider,{value:m,children:[E,e.isActive&&_(j,{})]}):_(rt,{children:E})},B=()=>{let i=ot(K);if(i===void 0)throw new Error("useOnboarding must be used within an OnboardingProvider");return i};export{St as OnboardingProvider,B 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, { createContext, useContext, useEffect, useState, useCallback, useMemo } 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 children: React.ReactNode;\n}> = ({ config, ssr = false, 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 // Stabilize config to prevent infinite loops if the user passes a new object on every render\n const configRef = React.useRef(config);\n useEffect(() => {\n configRef.current = config;\n }, [config]);\n\n const handleNavigation = useCallback((link?: string) => {\n if (!link) return;\n \n if (configRef.current.metadata.nextRouter) {\n window.location.href = link;\n } else {\n window.location.href = link;\n }\n }, []);\n\n useEffect(() => {\n if (ssr) {\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 // Escape regex special characters but keep '*' as '.*'\n const pattern = step.urlMatch\n .replace(/[.+?^${}()|[\\]\\\\]/g, '\\\\$&') // Escape regex chars\n .replace(/\\*/g, '.*'); // Convert * to .*\n return new RegExp(`^${pattern}$`).test(path);\n }\n\n return path === step.urlMatch;\n };\n\n useEffect(() => {\n const currentConfig = configRef.current;\n const currentPath = window.location.pathname;\n let matchedStepIndex = -1;\n \n // Check if inOrder is explicitly false to find matching step from URL\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 inOrder is false\n if ((currentConfig.metadata.inOrder as boolean | undefined) === false) {\n if (matchedStepIndex !== -1) {\n // We found a matching step for this URL\n if (parsed.currentStepIndex === matchedStepIndex) {\n // If it matches the saved step, restore state (keep substeps)\n setState(parsed);\n } else {\n // Different step, switch to it\n setState(prev => ({\n ...prev,\n currentStepIndex: matchedStepIndex,\n currentSubStepIndex: null,\n isActive: true\n }));\n }\n } else {\n // inOrder is false, and NO step matches this URL.\n // We should hide the onboarding, essentially \"pausing\" it until we return to a valid page.\n setState(prev => ({ ...parsed, isActive: false }));\n }\n } else {\n // Standard behavior (inOrder: true OR no match found) - restore saved state\n setState(parsed);\n\n // Only enforce navigation if inOrder is true (or default)\n if ((currentConfig.metadata.inOrder as boolean | undefined) !== false) {\n const step = currentConfig.steps[parsed.currentStepIndex];\n if (step && parsed.isActive) {\n // Always enforce location based on the main step's urlMatch\n if (typeof step.urlMatch === 'string' && window.location.pathname !== step.urlMatch) {\n handleNavigation(step.urlMatch);\n }\n }\n }\n }\n } catch (e) {\n console.error('Failed to parse onboarding state from cookie', e);\n // Fallback if cookie fails but we have a match\n if (matchedStepIndex !== -1) {\n setState(prev => ({\n ...prev,\n currentStepIndex: matchedStepIndex,\n currentSubStepIndex: null,\n isActive: true\n }));\n }\n }\n } else if (matchedStepIndex !== -1) {\n // No cookie, but we have a URL match\n setState(prev => ({\n ...prev,\n currentStepIndex: matchedStepIndex,\n currentSubStepIndex: null,\n isActive: true\n }));\n } else if ((currentConfig.metadata.inOrder as boolean | undefined) === false) {\n // No cookie, no match, and inOrder is false.\n // We are on a page that doesn't trigger any onboarding step.\n setState(prev => ({ ...prev, isActive: false }));\n } else {\n // No cookie, no match, inOrder is true (default).\n // Enforce navigation for the default first step if needed.\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 }, [handleNavigation]); // Removed config.steps dependency\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 step = currentConfig.steps[state.currentStepIndex];\n const currentActiveStep = state.currentSubStepIndex !== null && step.subSteps \n ? step.subSteps[state.currentSubStepIndex] \n : step;\n\n // Perform click if requested for the current step before moving to the next\n if (currentActiveStep.click) {\n const element = document.querySelector(`[data-onboarding-id=\"${currentActiveStep.attribute}\"]`) as HTMLElement;\n if (element) {\n element.click();\n }\n }\n \n // Check for subSteps\n if (step.subSteps && (state.currentSubStepIndex === null || state.currentSubStepIndex < step.subSteps.length - 1)) {\n const nextSubIndex = state.currentSubStepIndex === null ? 0 : state.currentSubStepIndex + 1;\n const nextSubStep = step.subSteps[nextSubIndex];\n setState(prev => ({ ...prev, currentSubStepIndex: nextSubIndex }));\n \n if (nextSubStep.navigate) handleNavigation(nextSubStep.navigate);\n return;\n }\n\n // Move to next main step\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 const step = currentConfig.steps[state.currentStepIndex];\n\n if (state.currentSubStepIndex !== null && state.currentSubStepIndex > 0) {\n setState(prev => ({ ...prev, currentSubStepIndex: prev.currentSubStepIndex! - 1 }));\n return;\n }\n\n if (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};","\"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 } = useOnboarding();\n const [coords, setCoords] = useState<{ top: number; left: number; width: number; height: number } | 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 useEffect(() => {\n setDragOffset({ x: 0, y: 0 });\n }, [currentStep]);\n\n const handlePointerDown = (e: React.PointerEvent) => {\n if (!config.metadata.draggable) return;\n e.stopPropagation(); // Prevent click-through\n e.preventDefault(); // Prevent text selection\n isDragging.current = true;\n dragStart.current = { x: e.clientX - dragOffset.x, y: e.clientY - dragOffset.y };\n \n // Disable transition during drag for responsiveness\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 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 // Re-enable transition\n if (tooltipRef.current) {\n tooltipRef.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)';\n tooltipRef.current.style.cursor = config.metadata.draggable ? 'grab' : 'auto';\n }\n\n window.removeEventListener('pointermove', handlePointerMove);\n window.removeEventListener('pointerup', handlePointerUp);\n }, [config.metadata.draggable, handlePointerMove]);\n\n // Clean up listeners on unmount\n useEffect(() => {\n return () => {\n window.removeEventListener('pointermove', handlePointerMove);\n window.removeEventListener('pointerup', handlePointerUp);\n };\n }, [handlePointerMove, handlePointerUp]);\n\n const calculateBestPosition = useCallback((rect: { top: number; bottom: number; left: number; right: number; width: number; height: number }) => {\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(padding, Math.min(window.innerWidth - tooltipWidth - padding, rect.left + rect.width / 2 - tooltipWidth / 2));\n } else if (spaceAbove > tooltipHeight + gap + padding) {\n top = rect.top - tooltipHeight - gap;\n left = Math.max(padding, Math.min(window.innerWidth - tooltipWidth - padding, rect.left + rect.width / 2 - tooltipWidth / 2));\n } else if (spaceRight > tooltipWidth + gap + padding) {\n top = Math.max(padding, Math.min(window.innerHeight - tooltipHeight - padding, rect.top + rect.height / 2 - tooltipHeight / 2));\n left = rect.right + gap;\n } else if (spaceLeft > tooltipWidth + gap + padding) {\n top = Math.max(padding, Math.min(window.innerHeight - tooltipHeight - padding, rect.top + rect.height / 2 - tooltipHeight / 2));\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 const updateCoords = useCallback(() => {\n if (!currentStep) return;\n\n const element = document.querySelector(`[data-onboarding-id=\"${currentStep.attribute}\"]`) 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 // Prevent infinite loops by only updating if values actually changed\n setCoords(prev => {\n if (prev && \n prev.top === newCoords.top && \n prev.left === newCoords.left && \n prev.width === newCoords.width && \n prev.height === newCoords.height) {\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 width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\">\n <path d=\"M15 18l-6-6 6-6\" />\n </svg>\n );\n\n const ChevronRightIcon = () => (\n <svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\">\n <path d=\"M9 18l6-6-6-6\" />\n </svg>\n );\n\n const XIcon = () => (\n <svg width=\"18\" height=\"18\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\">\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=\"fixed inset-0 z-[999999] pointer-events-none\">\n {/* Top Mask */}\n <div\n style={{ height: coords.top, ...maskStyle }}\n className=\"onboard-overlay-mask top-0 left-0 w-full pointer-events-auto\"\n onPointerDown={stopPropagation}\n onMouseDown={stopPropagation}\n onClick={stopPropagation}\n />\n {/* Bottom Mask */}\n <div\n style={{ top: coords.top + coords.height, height: `calc(100vh - ${coords.top + coords.height}px)`, ...maskStyle }}\n className=\"onboard-overlay-mask left-0 w-full pointer-events-auto\"\n onPointerDown={stopPropagation}\n onMouseDown={stopPropagation}\n onClick={stopPropagation}\n />\n {/* Left Mask */}\n <div\n style={{ top: coords.top, height: coords.height, width: coords.left, ...maskStyle }}\n className=\"onboard-overlay-mask left-0 pointer-events-auto\"\n onPointerDown={stopPropagation}\n onMouseDown={stopPropagation}\n onClick={stopPropagation}\n />\n {/* Right Mask */}\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 pointer-events-auto\"\n onPointerDown={stopPropagation}\n onMouseDown={stopPropagation}\n onClick={stopPropagation}\n />\n\n {/* Tooltip */}\n <div\n ref={tooltipRef}\n className=\"onboard-tooltip pointer-events-auto\"\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: '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' // Prevent scrolling on touch devices while dragging\n }}\n onMouseDown={stopPropagation}\n onClick={stopPropagation}\n >\n <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'flex-start', marginBottom: '8px' }}>\n <h3 style={{ margin: 0, fontWeight: 'bold', color: '#111827', fontSize: '18px', lineHeight: 1.2 }}>{currentStep.title}</h3>\n <button \n onClick={(e) => { e.stopPropagation(); finish(); }}\n style={{ background: 'none', border: 'none', cursor: 'pointer', padding: '4px', color: '#9ca3af' }}\n >\n <XIcon />\n </button>\n </div>\n <p style={{ margin: 0, color: '#4b5563', fontSize: '14px', marginBottom: '24px', lineHeight: 1.5 }}>\n {currentStep.description}\n </p>\n \n <div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between' }}>\n <button\n onClick={(e) => { e.stopPropagation(); prevStep(); }}\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) => { e.stopPropagation(); finish(); }}\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) => { e.stopPropagation(); nextStep(); }}\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' \n ? createPortal(overlayContent, document.body) \n : null;\n};\n"],"mappings":";aAEA,OAAOA,IAAS,iBAAAC,GAAe,cAAAC,GAAY,aAAAC,EAAW,YAAAC,EAAU,eAAAC,EAAa,WAAAC,MAAe,QAC5F,OAAOC,MAAa,YCDpB,OAAgB,YAAAC,EAAU,aAAAC,EAAW,eAAAC,EAAa,UAAAC,MAAc,QAChE,OAAS,gBAAAC,OAAoB,YA6LvB,cAAAC,EAWF,QAAAC,M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Z,OAAAhD,EACA,MAAAM,EACA,SAAA2B,EACA,SAAAO,EACA,OAAAI,EACA,SAAAC,EACA,YAAAnB,EACA,YAAAE,EACA,WAAAC,CACF,EAEA,OAAK1B,EAGHR,GAACC,EAAkB,SAAlB,CAA2B,MAAOoD,EAChC,UAAA9C,EACAI,EAAM,UAAYZ,EAACuD,EAAA,EAAkB,GACxC,EANqBvD,EAAAD,GAAA,CAAG,SAAAS,EAAS,CAQrC,EAEagD,EAAgB,IAAM,CACjC,IAAMC,EAAUC,GAAWxD,CAAiB,EAC5C,GAAIuD,IAAY,OACd,MAAM,IAAI,MAAM,yDAAyD,EAE3E,OAAOA,CACT","names":["React","createContext","useContext","useEffect","useState","useCallback","useMemo","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","handlePointerDown","e","handlePointerMove","handlePointerUp","useCallback","newX","newY","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","children","isMounted","setIsMounted","useState","state","setState","configRef","React","useEffect","handleNavigation","useCallback","link","isMatch","step","path","pattern","currentConfig","currentPath","matchedStepIndex","savedState","Cookies","parsed","prev","e","currentStep","useMemo","isFirstStep","isLastStep","totalSteps","isLastMainStep","hasSubSteps","nextStep","currentActiveStep","element","nextSubIndex","nextSubStep","nextIndex","nextStepObj","prevStep","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, { createContext, useContext, useEffect, useState, useCallback, useMemo } 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 children: React.ReactNode;\n}> = ({ config, ssr = false, 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 // Stabilize config to prevent infinite loops if the user passes a new object on every render\n const configRef = React.useRef(config);\n useEffect(() => {\n configRef.current = config;\n }, [config]);\n\n const handleNavigation = useCallback((link?: string) => {\n if (!link) return;\n \n if (configRef.current.metadata.nextRouter) {\n window.location.href = link;\n } else {\n window.location.href = link;\n }\n }, []);\n\n useEffect(() => {\n if (ssr) {\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 // Escape regex special characters but keep '*' as '.*'\n const pattern = step.urlMatch\n .replace(/[.+?^${}()|[\\]\\\\]/g, '\\\\$&') // Escape regex chars\n .replace(/\\*/g, '.*'); // Convert * to .*\n return new RegExp(`^${pattern}$`).test(path);\n }\n\n return path === step.urlMatch;\n };\n\n useEffect(() => {\n const currentConfig = configRef.current;\n const currentPath = window.location.pathname;\n let matchedStepIndex = -1;\n \n // Check if inOrder is explicitly false to find matching step from URL\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 inOrder is false\n if ((currentConfig.metadata.inOrder as boolean | undefined) === false) {\n if (matchedStepIndex !== -1) {\n // We found a matching step for this URL\n if (parsed.currentStepIndex === matchedStepIndex) {\n // If it matches the saved step, restore state (keep substeps)\n setState(parsed);\n } else {\n // Different step, switch to it\n setState(prev => ({\n ...prev,\n currentStepIndex: matchedStepIndex,\n currentSubStepIndex: null,\n isActive: true\n }));\n }\n } else {\n // inOrder is false, and NO step matches this URL.\n // We should hide the onboarding, essentially \"pausing\" it until we return to a valid page.\n setState(prev => ({ ...parsed, isActive: false }));\n }\n } else {\n // Standard behavior (inOrder: true OR no match found) - restore saved state\n setState(parsed);\n\n // Only enforce navigation if inOrder is true (or default)\n if ((currentConfig.metadata.inOrder as boolean | undefined) !== false) {\n const step = currentConfig.steps[parsed.currentStepIndex];\n if (step && parsed.isActive) {\n // Always enforce location based on the main step's urlMatch\n if (typeof step.urlMatch === 'string' && window.location.pathname !== step.urlMatch) {\n handleNavigation(step.urlMatch);\n }\n }\n }\n }\n } catch (e) {\n console.error('Failed to parse onboarding state from cookie', e);\n // Fallback if cookie fails but we have a match\n if (matchedStepIndex !== -1) {\n setState(prev => ({\n ...prev,\n currentStepIndex: matchedStepIndex,\n currentSubStepIndex: null,\n isActive: true\n }));\n }\n }\n } else if (matchedStepIndex !== -1) {\n // No cookie, but we have a URL match\n setState(prev => ({\n ...prev,\n currentStepIndex: matchedStepIndex,\n currentSubStepIndex: null,\n isActive: true\n }));\n } else if ((currentConfig.metadata.inOrder as boolean | undefined) === false) {\n // No cookie, no match, and inOrder is false.\n // We are on a page that doesn't trigger any onboarding step.\n setState(prev => ({ ...prev, isActive: false }));\n } else {\n // No cookie, no match, inOrder is true (default).\n // Enforce navigation for the default first step if needed.\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 }, [handleNavigation]); // Removed config.steps dependency\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 step = currentConfig.steps[state.currentStepIndex];\n const currentActiveStep = state.currentSubStepIndex !== null && step.subSteps \n ? step.subSteps[state.currentSubStepIndex] \n : step;\n\n // Perform click if requested for the current step before moving to the next\n if (currentActiveStep.click) {\n const element = document.querySelector(`[data-onboarding-id=\"${currentActiveStep.attribute}\"]`) as HTMLElement;\n if (element) {\n element.click();\n }\n }\n \n // Check for subSteps\n if (step.subSteps && (state.currentSubStepIndex === null || state.currentSubStepIndex < step.subSteps.length - 1)) {\n const nextSubIndex = state.currentSubStepIndex === null ? 0 : state.currentSubStepIndex + 1;\n const nextSubStep = step.subSteps[nextSubIndex];\n setState(prev => ({ ...prev, currentSubStepIndex: nextSubIndex }));\n \n if (nextSubStep.navigate) handleNavigation(nextSubStep.navigate);\n return;\n }\n\n // Move to next main step\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 const step = currentConfig.steps[state.currentStepIndex];\n\n if (state.currentSubStepIndex !== null && state.currentSubStepIndex > 0) {\n setState(prev => ({ ...prev, currentSubStepIndex: prev.currentSubStepIndex! - 1 }));\n return;\n }\n\n if (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};","\"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 } = useOnboarding();\n const [coords, setCoords] = useState<{ top: number; left: number; width: number; height: number } | 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 useEffect(() => {\n setDragOffset({ x: 0, y: 0 });\n }, [currentStep]);\n\n const handlePointerDown = (e: React.PointerEvent) => {\n if (!config.metadata.draggable) return;\n e.stopPropagation(); // Prevent click-through\n e.preventDefault(); // Prevent text selection\n isDragging.current = true;\n dragStart.current = { x: e.clientX - dragOffset.x, y: e.clientY - dragOffset.y };\n \n // Disable transition during drag for responsiveness\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 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 // Re-enable transition\n if (tooltipRef.current) {\n tooltipRef.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)';\n tooltipRef.current.style.cursor = config.metadata.draggable ? 'grab' : 'auto';\n }\n\n window.removeEventListener('pointermove', handlePointerMove);\n window.removeEventListener('pointerup', handlePointerUp);\n }, [config.metadata.draggable, handlePointerMove]);\n\n // Clean up listeners on unmount\n useEffect(() => {\n return () => {\n window.removeEventListener('pointermove', handlePointerMove);\n window.removeEventListener('pointerup', handlePointerUp);\n };\n }, [handlePointerMove, handlePointerUp]);\n\n const calculateBestPosition = useCallback((rect: { top: number; bottom: number; left: number; right: number; width: number; height: number }) => {\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(padding, Math.min(window.innerWidth - tooltipWidth - padding, rect.left + rect.width / 2 - tooltipWidth / 2));\n } else if (spaceAbove > tooltipHeight + gap + padding) {\n top = rect.top - tooltipHeight - gap;\n left = Math.max(padding, Math.min(window.innerWidth - tooltipWidth - padding, rect.left + rect.width / 2 - tooltipWidth / 2));\n } else if (spaceRight > tooltipWidth + gap + padding) {\n top = Math.max(padding, Math.min(window.innerHeight - tooltipHeight - padding, rect.top + rect.height / 2 - tooltipHeight / 2));\n left = rect.right + gap;\n } else if (spaceLeft > tooltipWidth + gap + padding) {\n top = Math.max(padding, Math.min(window.innerHeight - tooltipHeight - padding, rect.top + rect.height / 2 - tooltipHeight / 2));\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 const updateCoords = useCallback(() => {\n if (!currentStep) return;\n\n const element = document.querySelector(`[data-onboarding-id=\"${currentStep.attribute}\"]`) 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 // Prevent infinite loops by only updating if values actually changed\n setCoords(prev => {\n if (prev && \n prev.top === newCoords.top && \n prev.left === newCoords.left && \n prev.width === newCoords.width && \n prev.height === newCoords.height) {\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 width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\">\n <path d=\"M15 18l-6-6 6-6\" />\n </svg>\n );\n\n const ChevronRightIcon = () => (\n <svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\">\n <path d=\"M9 18l6-6-6-6\" />\n </svg>\n );\n\n const XIcon = () => (\n <svg width=\"18\" height=\"18\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\">\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 {/* Top Mask */}\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 {/* Bottom Mask */}\n <div\n style={{ top: coords.top + coords.height, height: `calc(100vh - ${coords.top + coords.height}px)`, ...maskStyle }}\n className=\"onboard-overlay-mask onboard-mask-bottom\"\n onPointerDown={stopPropagation}\n onMouseDown={stopPropagation}\n onClick={stopPropagation}\n />\n {/* Left Mask */}\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 {/* Right Mask */}\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 {/* Tooltip */}\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: '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' // Prevent scrolling on touch devices while dragging\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) => { e.stopPropagation(); finish(); }}\n className=\"onboard-close-button\"\n >\n <XIcon />\n </button>\n </div>\n <p className=\"onboard-tooltip-description\">\n {currentStep.description}\n </p>\n \n <div className=\"onboard-tooltip-footer\">\n <button\n onClick={(e) => { e.stopPropagation(); prevStep(); }}\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) => { e.stopPropagation(); finish(); }}\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) => { e.stopPropagation(); nextStep(); }}\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' \n ? createPortal(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,EACA,SAAAO,EACA,OAAAI,EACA,SAAAC,EACA,YAAAnB,EACA,YAAAE,EACA,WAAAC,CACF,EAEA,OAAK1B,EAGHR,GAACC,EAAkB,SAAlB,CAA2B,MAAOoD,EAChC,UAAA9C,EACAI,EAAM,UAAYZ,EAACuD,EAAA,EAAkB,GACxC,EANqBvD,EAAAD,GAAA,CAAG,SAAAS,EAAS,CAQrC,EAEagD,EAAgB,IAAM,CACjC,IAAMC,EAAUC,GAAWxD,CAAiB,EAC5C,GAAIuD,IAAY,OACd,MAAM,IAAI,MAAM,yDAAyD,EAE3E,OAAOA,CACT","names":["React","createContext","useContext","useEffect","useState","useCallback","useMemo","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","handlePointerDown","e","handlePointerMove","handlePointerUp","useCallback","newX","newY","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","children","isMounted","setIsMounted","useState","state","setState","configRef","React","useEffect","handleNavigation","useCallback","link","isMatch","step","path","pattern","currentConfig","currentPath","matchedStepIndex","savedState","Cookies","parsed","prev","e","currentStep","useMemo","isFirstStep","isLastStep","totalSteps","isLastMainStep","hasSubSteps","nextStep","currentActiveStep","element","nextSubIndex","nextSubStep","nextIndex","nextStepObj","prevStep","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.0.1",
3
+ "version": "1.3.1",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "types": "./dist/index.d.ts",
@@ -55,8 +55,6 @@
55
55
  "vitest": "^4.0.17"
56
56
  },
57
57
  "dependencies": {
58
- "clsx": "^2.1.1",
59
- "js-cookie": "^3.0.5",
60
- "tailwind-merge": "^2.6.0"
58
+ "js-cookie": "^3.0.5"
61
59
  }
62
60
  }