Comparing version 0.2.5 to 0.2.6
@@ -1,3 +0,3 @@ | ||
"use strict";var W=Object.create;var b=Object.defineProperty;var Q=Object.getOwnPropertyDescriptor;var V=Object.getOwnPropertyNames;var Y=Object.getPrototypeOf,$=Object.prototype.hasOwnProperty;var G=(t,o)=>{for(var r in o)b(t,r,{get:o[r],enumerable:!0})},H=(t,o,r,e)=>{if(o&&typeof o=="object"||typeof o=="function")for(let i of V(o))!$.call(t,i)&&i!==r&&b(t,i,{get:()=>o[i],enumerable:!(e=Q(o,i))||e.enumerable});return t};var m=(t,o,r)=>(r=t!=null?W(Y(t)):{},H(o||!t||!t.__esModule?b(r,"default",{value:t,enumerable:!0}):r,t)),J=t=>H(b({},"__esModule",{value:!0}),t);var at={};G(at,{Tour:()=>M,TourProvider:()=>w,useTourControls:()=>T,useTourState:()=>h});module.exports=J(at);var p=m(require("react")),g=p.default.createContext(null),X=({children:t})=>{var L;let[o,r]=p.default.useState(!1),[e,i]=p.default.useState(null),[n,s]=p.default.useState(0),u=p.default.useRef([]),a=(L=e==null?void 0:e.steps.length)!=null?L:0,x=c=>{u.current.push(c)},C=c=>{let I=u.current.find(R=>R.id===c);I&&(i(I),r(!0),s(0))},l=()=>{r(!1),i(null),s(0)},f=p.default.useCallback(()=>{s(c=>Math.min(a-1,c+1))},[a]),E=()=>{s(c=>Math.max(0,c-1))},q=p.default.useCallback(c=>{c<1||c>=a||s(c-1)},[a]);return p.default.createElement(g.Provider,{value:{isTourOpen:o,activeTour:e,activeStepIndex:n,totalSteps:a,tours:u.current,addTour:x,startTour:C,endTour:l,goToStep:q,nextStep:f,prevStep:E}},t)},w=X;function y(t,{insertAt:o}={}){if(!t||typeof document=="undefined")return;let r=document.head||document.getElementsByTagName("head")[0],e=document.createElement("style");e.type="text/css",o==="top"&&r.firstChild?r.insertBefore(e,r.firstChild):r.appendChild(e),e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}y(`:root{--nt-background-color: #ffffff;--nt-foreground-color: #2d3748;--nt-secondary-color: #4a5568;--nt-border-color: #cbd5e0;--nt-accent-color: #3182ce;--nt-shadow-color: rgba(0, 0, 0, .1);--nt-on-accent-color: #ffffff;--nt-radius: .6rem;--nt-spacing: 1rem;--nt-transition-timing-function-step: cubic-bezier(.2, 0, .2, 1);--nt-transition-duration: .2s;--nt-animation-duration: .2s}.dark{--nt-background-color: #1a202c;--nt-foreground-color: #e2e8f0;--nt-secondary-color: #a0aec0;--nt-border-color: #4a5568;--nt-accent-color: #63b3ed;--nt-shadow-color: rgba(0, 0, 0, .2);--nt-on-accent-color: #2d3748}[data-nt-popover]{position:fixed;z-index:10000;top:50%;left:50%}[data-nt-popover-container]{position:fixed;z-index:9999;top:0;left:0;width:100%;height:100%;animation:NtfadeIn var(--nt-animation-duration) ease-out}@keyframes NtfadeIn{0%{opacity:0}to{opacity:1}}:where([data-tour-step]){background-color:var(--nt-background-color);color:var(--nt-foreground-color);border:1px solid var(--nt-border-color);box-shadow:0 2px 4px var(--nt-shadow-color);padding:var(--nt-spacing);border-radius:var(--nt-radius);animation:NtScaleUp var(--nt-animation-duration) ease-out}@keyframes NtScaleUp{0%{transform:scale(.9);opacity:0}to{transform:scale(1);opacity:1}} | ||
`);var F=m(require("react"));var O=m(require("react"));var Z=()=>{let t=O.default.useContext(g);if(!t)throw new Error("useTourControls must be used within a <TourProvider> component");let{startTour:o,endTour:r,goToStep:e,nextStep:i,prevStep:n,addTour:s}=t;return{startTour:o,endTour:r,goToStep:e,nextStep:i,prevStep:n,addTour:s}},T=Z;var A=m(require("react"));var tt=()=>{let t=A.default.useContext(g);if(!t)throw new Error("useTourState must be used within a <TourProvider> component");let{tours:o,activeStepIndex:r,activeTour:e,isTourOpen:i,totalSteps:n}=t;return{tours:o,activeStepIndex:r,activeTour:e,isTourOpen:i,totalSteps:n}},h=tt;var _=m(require("react"));var N=` | ||
"use strict";var Q=Object.create;var P=Object.defineProperty;var R=Object.getOwnPropertyDescriptor;var Y=Object.getOwnPropertyNames;var $=Object.getPrototypeOf,G=Object.prototype.hasOwnProperty;var J=(t,e)=>{for(var r in e)P(t,r,{get:e[r],enumerable:!0})},H=(t,e,r,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Y(e))!G.call(t,s)&&s!==r&&P(t,s,{get:()=>e[s],enumerable:!(o=R(e,s))||o.enumerable});return t};var T=(t,e,r)=>(r=t!=null?Q($(t)):{},H(e||!t||!t.__esModule?P(r,"default",{value:t,enumerable:!0}):r,t)),X=t=>H(P({},"__esModule",{value:!0}),t);var at={};J(at,{Tour:()=>M,TourProvider:()=>E,useTourControls:()=>x,useTourState:()=>g});module.exports=X(at);var m=T(require("react")),b=m.default.createContext(null),Z=({children:t})=>{var I;let[e,r]=m.default.useState(!1),[o,s]=m.default.useState(null),[n,i]=m.default.useState(0),u=m.default.useRef([]),a=(I=o==null?void 0:o.steps.length)!=null?I:0,h=c=>{u.current.push(c)},p=c=>{let L=u.current.find(q=>q.id===c);L&&(s(L),r(!0),i(0))},l=()=>{r(!1),s(null),i(0)},f=m.default.useCallback(()=>{i(c=>Math.min(a-1,c+1))},[a]),w=()=>{i(c=>Math.max(0,c-1))},j=m.default.useCallback(c=>{c<1||c>=a||i(c-1)},[a]);return m.default.createElement(b.Provider,{value:{isTourOpen:e,activeTour:o,activeStepIndex:n,totalSteps:a,tours:u.current,addTour:h,startTour:p,endTour:l,goToStep:j,nextStep:f,prevStep:w}},t)},E=Z;function y(t,{insertAt:e}={}){if(!t||typeof document=="undefined")return;let r=document.head||document.getElementsByTagName("head")[0],o=document.createElement("style");o.type="text/css",e==="top"&&r.firstChild?r.insertBefore(o,r.firstChild):r.appendChild(o),o.styleSheet?o.styleSheet.cssText=t:o.appendChild(document.createTextNode(t))}y(`:root{--nt-background-color: #ffffff;--nt-foreground-color: #2d3748;--nt-secondary-color: #4a5568;--nt-border-color: #cbd5e0;--nt-accent-color: #3182ce;--nt-shadow-color: rgba(0, 0, 0, .1);--nt-on-accent-color: #ffffff;--nt-radius: .6rem;--nt-spacing: 1rem;--nt-transition-timing-function-step: cubic-bezier(.2, 0, .2, 1);--nt-transition-duration: .4s;--nt-animation-duration: .2s}.dark{--nt-background-color: #1a202c;--nt-foreground-color: #e2e8f0;--nt-secondary-color: #a0aec0;--nt-border-color: #4a5568;--nt-accent-color: #63b3ed;--nt-shadow-color: rgba(0, 0, 0, .2);--nt-on-accent-color: #2d3748}[data-nt-popover]{position:fixed;z-index:10000;top:50%;left:50%}[data-nt-popover-container]{position:fixed;z-index:9999;top:0;left:0;width:100%;height:100%;animation:NtFadeIn var(--nt-animation-duration) ease-out}@keyframes NtFadeIn{0%{opacity:0}to{opacity:1}}:where([data-tour-step]){background-color:var(--nt-background-color);color:var(--nt-foreground-color);border:1px solid var(--nt-border-color);box-shadow:0 2px 4px var(--nt-shadow-color);padding:var(--nt-spacing);border-radius:var(--nt-radius);animation:NtScaleUp var(--nt-animation-duration) ease-out}@keyframes NtScaleUp{0%{transform:scale(.9);opacity:0}to{transform:scale(1);opacity:1}} | ||
`);var F=T(require("react"));var N=T(require("react"));var tt=()=>{let t=N.default.useContext(b);if(!t)throw new Error("useTourControls must be used within a <TourProvider> component");let{startTour:e,endTour:r,goToStep:o,nextStep:s,prevStep:n,addTour:i}=t;return{startTour:e,endTour:r,goToStep:o,nextStep:s,prevStep:n,addTour:i}},x=tt;var O=T(require("react"));var et=()=>{let t=O.default.useContext(b);if(!t)throw new Error("useTourState must be used within a <TourProvider> component");let{tours:e,activeStepIndex:r,activeTour:o,isTourOpen:s,totalSteps:n}=t;return{tours:e,activeStepIndex:r,activeTour:o,isTourOpen:s,totalSteps:n}},g=et;var _=T(require("react"));var A=` | ||
a[href]:not([tabindex^="-"]), | ||
@@ -17,2 +17,2 @@ area[href]:not([tabindex^="-"]), | ||
object[usemap]:not([tabindex^="-"]) | ||
`,U="bottom-center";var et=t=>{_.default.useEffect(()=>{let o=t.current;if(!o)return;let r=()=>Array.from(o.querySelectorAll(N)).filter(n=>!n.hasAttribute("disabled")),e=r();e[0]&&e[0].focus();let i=n=>{if(n.key!=="Tab"||(e=r(),e.length===0))return;let{firstElement:s,lastElement:u}={firstElement:e[0],lastElement:e[e.length-1]};(n.shiftKey&&document.activeElement===s||!n.shiftKey&&document.activeElement===u)&&((n.shiftKey?u:s).focus(),n.preventDefault())};return document.addEventListener("keydown",i),()=>document.removeEventListener("keydown",i)},[t])},S=et;var ot=t=>{var n,s,u,a;let o=(n=t==null?void 0:t.highlightTarget)!=null?n:!0,r=(s=t==null?void 0:t.preventCloseOnClickOutside)!=null?s:!1,e=(u=t==null?void 0:t.showNavigation)!=null?u:!0,i=(a=t==null?void 0:t.showProgress)!=null?a:!0;return{highlightTarget:o,preventCloseOnClickOutside:r,showNavigation:e,showProgress:i}},k=ot;var v=m(require("react"));var d=m(require("react")),B=m(require("react-dom"));var D=(t,o,r)=>{let n=0,s=0;switch(r){case"top-center":n=t.top-o.height-10,s=t.left+t.width/2-o.width/2;break;case"bottom-center":n=t.top+t.height+10,s=t.left+t.width/2-o.width/2;break;case"left-center":n=t.top+t.height/2-o.height/2,s=t.left-o.width-10;break;case"right-center":n=t.top+t.height/2-o.height/2,s=t.left+t.width+10;break;case"window-center":n=window.innerHeight/2-o.height/2,s=window.innerWidth/2-o.width/2;break}return n=Math.max(10,Math.min(n,window.innerHeight-o.height-10)),s=Math.max(10,Math.min(s,window.innerWidth-o.width-10)),{top:n,left:s}};var z=d.default.createContext(null),rt=()=>{let t=d.default.useContext(z);if(!t)throw new Error("usePopover must be used within a Popover component");return t},K=({children:t,open:o,preferredPosition:r=U,target:e,onClickOutside:i,shouldHighlightTarget:n=!0})=>!e||!o?null:d.default.createElement(z.Provider,{value:{open:o,preferredPosition:r,target:e,onClickOutside:i,shouldHighlightTarget:n}},t),nt=({children:t,...o})=>{let{open:r,target:e,preferredPosition:i,onClickOutside:n,shouldHighlightTarget:s}=rt(),u=d.default.useRef(null),a=d.default.useRef(null),[x,C]=d.default.useState(null);return d.default.useEffect(()=>{if(e){let l=e.getBoundingClientRect();C(l)}},[e]),d.default.useEffect(()=>{if(!r||!x||!u.current)return;let l=D(x,u.current.getBoundingClientRect(),i),{current:f}=u;f.style.top=`${l.top}px`,f.style.left=`${l.left}px`;let E=setTimeout(()=>{f.style.transition="top var(--nt-transition-duration), left var(--nt-transition-duration)"},50);return()=>{f.style.transition="",clearTimeout(E)}},[r,x,i]),d.default.useEffect(()=>{if(s&&e&&a.current){e.style.zIndex="10001",a.current.style.backgroundColor="rgba(0, 0, 0, 0.5)";let l=a.current;return()=>{l&&(l.style.backgroundColor=""),e&&(e.style.zIndex="")}}},[s,e]),S(u),d.default.useEffect(()=>{let l=f=>{a.current===f.target&&(n==null||n())};return document.addEventListener("mousedown",l),()=>document.removeEventListener("mousedown",l)},[n]),B.default.createPortal(d.default.createElement("div",{ref:a,"data-nt-popover-container":!0},d.default.createElement("div",{...o,ref:u,"data-nt-popover":!0},t)),document.body)};K.Content=nt;var P=K;var it=({activeStep:t,tourOptions:o})=>{let{endTour:r}=T(),{isTourOpen:e}=h(),[i,n]=v.default.useState(null),{highlightTarget:s,preventCloseOnClickOutside:u}=k(o);return v.default.useEffect(()=>{if(!t)return;let a=document.querySelector(t.target);a&&n(a)},[t]),t?v.default.createElement(P,{open:e,target:i,preferredPosition:t.position,shouldHighlightTarget:s,onClickOutside:()=>u?void 0:r()},v.default.createElement(P.Content,{"data-tour-step":!0},t.content)):null},j=it;var st=t=>{let{addTour:o}=T(),{activeTour:r,activeStepIndex:e}=h();F.default.useEffect(()=>{o(t)},[o,t]);let i=(r==null?void 0:r.id)===t.id,n=i?r.steps[e]:null;return i?F.default.createElement(j,{activeStep:n,tourOptions:r.options}):null},M=st;0&&(module.exports={Tour,TourProvider,useTourControls,useTourState}); | ||
`,U="bottom-center";var ot=t=>{_.default.useEffect(()=>{let e=t.current;if(!e)return;let r=()=>Array.from(e.querySelectorAll(A)).filter(n=>!n.hasAttribute("disabled")),o=r();o[0]&&o[0].focus();let s=n=>{if(n.key!=="Tab"||(o=r(),o.length===0))return;let{firstElement:i,lastElement:u}={firstElement:o[0],lastElement:o[o.length-1]};(n.shiftKey&&document.activeElement===i||!n.shiftKey&&document.activeElement===u)&&((n.shiftKey?u:i).focus(),n.preventDefault())};return document.addEventListener("keydown",s),()=>document.removeEventListener("keydown",s)},[t])},S=ot;var rt=t=>{var n,i,u,a;let e=(n=t==null?void 0:t.highlightTarget)!=null?n:!0,r=(i=t==null?void 0:t.preventCloseOnClickOutside)!=null?i:!1,o=(u=t==null?void 0:t.showNavigation)!=null?u:!0,s=(a=t==null?void 0:t.showProgress)!=null?a:!0;return{highlightTarget:e,preventCloseOnClickOutside:r,showNavigation:o,showProgress:s}},k=rt;var v=T(require("react"));var B=(t,e,r)=>{let n=0,i=0;switch(r){case"top-center":n=t.top-e.height-10,i=t.left+t.width/2-e.width/2;break;case"bottom-center":n=t.top+t.height+10,i=t.left+t.width/2-e.width/2;break;case"left-center":n=t.top+t.height/2-e.height/2,i=t.left-e.width-10;break;case"right-center":n=t.top+t.height/2-e.height/2,i=t.left+t.width+10;break;case"window-center":n=window.innerHeight/2-e.height/2,i=window.innerWidth/2-e.width/2;break}return n=Math.max(10,Math.min(n,window.innerHeight-e.height-10)),i=Math.max(10,Math.min(i,window.innerWidth-e.width-10)),{top:n,left:i}},D=t=>{let e=t.getBoundingClientRect();return e.top>=0&&e.left>=0&&e.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&e.right<=(window.innerWidth||document.documentElement.clientWidth)};var d=T(require("react")),V=T(require("react-dom"));var z=d.default.createContext(null),nt=()=>{let t=d.default.useContext(z);if(!t)throw new Error("usePopover must be used within a Popover component");return t},K=({children:t,open:e,preferredPosition:r=U,target:o,onClickOutside:s,shouldHighlightTarget:n=!0})=>!o||!e?null:d.default.createElement(z.Provider,{value:{open:e,preferredPosition:r,target:o,onClickOutside:s,shouldHighlightTarget:n}},t),it=({children:t,...e})=>{let{open:r,target:o,preferredPosition:s,onClickOutside:n,shouldHighlightTarget:i}=nt(),u=d.default.useRef(null),a=d.default.useRef(null),[h,p]=d.default.useState(null);return d.default.useEffect(()=>{if(o){let l=o.getBoundingClientRect();p(l)}},[o]),d.default.useEffect(()=>{if(!r||!h||!u.current)return;let l=B(h,u.current.getBoundingClientRect(),s),{current:f}=u;f.style.top=`${l.top}px`,f.style.left=`${l.left}px`;let w=setTimeout(()=>{f.style.transition="top var(--nt-transition-duration), left var(--nt-transition-duration)"},50);return()=>{clearTimeout(w)}},[r,h,s]),d.default.useEffect(()=>{if(i&&o&&a.current){o.style.zIndex="10001",a.current.style.backgroundColor="rgba(0, 0, 0, 0.5)";let l=a.current;return()=>{l&&(l.style.backgroundColor=""),o&&(o.style.zIndex="")}}},[i,o]),S(u),d.default.useEffect(()=>{let l=f=>{a.current===f.target&&(n==null||n())};return document.addEventListener("mousedown",l),()=>document.removeEventListener("mousedown",l)},[n]),V.default.createPortal(d.default.createElement("div",{ref:a,"data-nt-popover-container":!0},d.default.createElement("div",{...e,ref:u,"data-nt-popover":!0},t)),document.body)};K.Content=it;var C=K;var st=({activeStep:t,tourOptions:e})=>{let{endTour:r,nextStep:o,prevStep:s}=x(),{isTourOpen:n}=g(),[i,u]=v.default.useState(null),{highlightTarget:a,preventCloseOnClickOutside:h}=k(e);return v.default.useEffect(()=>{if(!t)return;let p=document.querySelector(t.target);if(!p)return;if(D(p))i!==p&&u(p);else{u(null),p.scrollIntoView({behavior:"smooth",block:"center"});let f=setTimeout(()=>{u(p)},600);return()=>{clearTimeout(f),i!==null&&u(null)}}},[t,i]),t?v.default.createElement(C,{open:n,target:i,preferredPosition:t.position,shouldHighlightTarget:a,onClickOutside:()=>h?void 0:r()},v.default.createElement(C.Content,{"data-tour-step":!0},t.content,v.default.createElement("button",{onClick:s},"Prev"),v.default.createElement("button",{onClick:o},"Next"))):null},W=st;var ut=t=>{let{addTour:e}=x(),{activeTour:r,activeStepIndex:o}=g();F.default.useEffect(()=>{e(t)},[e,t]);let s=(r==null?void 0:r.id)===t.id,n=s?r.steps[o]:null;return s?F.default.createElement(W,{activeStep:n,tourOptions:r.options}):null},M=ut;0&&(module.exports={Tour,TourProvider,useTourControls,useTourState}); |
{ | ||
"name": "next-tour", | ||
"version": "0.2.5", | ||
"version": "0.2.6", | ||
"description": "Guided tours and walkthroughs for Next.js", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
24997
191