Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

next-tour

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

next-tour - npm Package Compare versions

Comparing version 0.2.1 to 0.2.2

17

dist/index.js

@@ -1,10 +0,2 @@

'use strict';
var m = require('react');
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
var m__default = /*#__PURE__*/_interopDefault(m);
var p=m.createContext(null),U=({children:e})=>{var y;let[t,o]=m.useState(!1),[r,i]=m.useState(null),[s,n]=m.useState(0),u=m.useRef([]).current,l=(y=r==null?void 0:r.steps.length)!=null?y:0,f=m.useCallback(c=>{u.push(c);},[]),b=m.useCallback(c=>{let L=u.find(K=>K.id===c);L&&(i(L),o(!0),n(1));},[u]),T=m.useCallback(()=>{o(!1),i(null),n(0);},[]),v=m.useCallback(()=>{n(c=>Math.min(l,c+1));},[l]),P=m.useCallback(()=>{n(c=>Math.max(1,c-1));},[]),B=m.useCallback(c=>{n(c);},[]);return m__default.default.createElement(p.Provider,{value:{isTourOpen:t,activeTour:r,activeStep:s,totalSteps:l,tours:u,addTour:f,startTour:b,endTour:T,goToStep:B,nextStep:v,prevStep:P}},e)},O=U;var $=()=>{let e=m.useContext(p);if(!e)throw new Error("Oops! It looks like useTourControls was called outside of a TourProvider context. Please ensure that your component is wrapped in a <TourProvider> to use the tour controls.");let{startTour:t,endTour:o,goToStep:r,nextStep:i,prevStep:s,addTour:n}=e;return {startTour:t,endTour:o,goToStep:r,nextStep:i,prevStep:s,addTour:n}},h=$;var z=()=>{let e=m.useContext(p);if(!e)throw new Error("Oops! It looks like useTour was called outside of a TourProvider context. Please ensure that your component is wrapped in a <TourProvider>");let{tours:t,activeStep:o,activeTour:r,isTourOpen:i,totalSteps:s}=e;return {tours:t,activeStep:o,activeTour:r,isTourOpen:i,totalSteps:s}},R=z;var Q=e=>{let t=m.useRef(null);return m.useEffect(()=>{let o=r=>{t.current&&!t.current.contains(r.target)&&e();};return document.addEventListener("pointerdown",o),()=>{document.removeEventListener("pointerdown",o);}},[e]),t},C=Q;var g=`
var q=Object.create;var v=Object.defineProperty;var U=Object.getOwnPropertyDescriptor;var _=Object.getOwnPropertyNames;var $=Object.getPrototypeOf,W=Object.prototype.hasOwnProperty;var z=(e,t)=>{for(var o in t)v(e,o,{get:t[o],enumerable:!0})},F=(e,t,o,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of _(t))!W.call(e,n)&&n!==o&&v(e,n,{get:()=>t[n],enumerable:!(r=U(t,n))||r.enumerable});return e};var E=(e,t,o)=>(o=e!=null?q($(e)):{},F(t||!e||!e.__esModule?v(o,"default",{value:e,enumerable:!0}):o,e)),G=e=>F(v({},"__esModule",{value:!0}),e);var se={};z(se,{Tour:()=>R,TourProvider:()=>M,useTourControls:()=>x,useTourState:()=>k});module.exports=G(se);var c=E(require("react")),h=(0,c.createContext)(null),J=({children:e})=>{var A;let[t,o]=(0,c.useState)(!1),[r,n]=(0,c.useState)(null),[u,s]=(0,c.useState)(0),l=(0,c.useRef)([]).current,f=(A=r==null?void 0:r.steps.length)!=null?A:0,T=(0,c.useCallback)(a=>{l.push(a)},[]),C=(0,c.useCallback)(a=>{let I=l.find(V=>V.id===a);I&&(n(I),o(!0),s(1))},[l]),b=(0,c.useCallback)(()=>{o(!1),n(null),s(0)},[]),g=(0,c.useCallback)(()=>{s(a=>Math.min(f,a+1))},[f]),S=(0,c.useCallback)(()=>{s(a=>Math.max(1,a-1))},[]),j=(0,c.useCallback)(a=>{s(a)},[]);return c.default.createElement(h.Provider,{value:{isTourOpen:t,activeTour:r,activeStep:u,totalSteps:f,tours:l,addTour:T,startTour:C,endTour:b,goToStep:j,nextStep:g,prevStep:S}},e)},M=J;var d=E(require("react"));var i=E(require("react"));var H=require("react");var Q=()=>{let e=(0,H.useContext)(h);if(!e)throw new Error("Oops! It looks like useTourControls was called outside of a TourProvider context. Please ensure that your component is wrapped in a <TourProvider> to use the tour controls.");let{startTour:t,endTour:o,goToStep:r,nextStep:n,prevStep:u,addTour:s}=e;return{startTour:t,endTour:o,goToStep:r,nextStep:n,prevStep:u,addTour:s}},x=Q;var D=require("react");var X=()=>{let e=(0,D.useContext)(h);if(!e)throw new Error("Oops! It looks like useTour was called outside of a TourProvider context. Please ensure that your component is wrapped in a <TourProvider>");let{tours:t,activeStep:o,activeTour:r,isTourOpen:n,totalSteps:u}=e;return{tours:t,activeStep:o,activeTour:r,isTourOpen:n,totalSteps:u}},k=X;var P=require("react"),Y=e=>{let t=(0,P.useRef)(null);return(0,P.useEffect)(()=>{let o=r=>{t.current&&!t.current.contains(r.target)&&e()};return document.addEventListener("pointerdown",o),()=>{document.removeEventListener("pointerdown",o)}},[e]),t},y=Y;var p=require("react");var L=`
a[href]:not([tabindex^="-"]),

@@ -24,7 +16,2 @@ area[href]:not([tabindex^="-"]),

object[usemap]:not([tabindex^="-"])
`;var Z=()=>{let e=m.useRef(document.activeElement),t=m.useRef(null),o=m.useCallback(r=>{if(r.key!=="Tab"||!t.current)return;let i=Array.from(t.current.querySelectorAll(g));if(i.length===0)return;let s=i[0],n=i[i.length-1],{activeElement:u}=document;r.shiftKey&&u===s?(n.focus(),r.preventDefault()):!r.shiftKey&&u===n&&(s.focus(),r.preventDefault());},[]);return m.useEffect(()=>{let r=t.current;if(!r)return;let i=Array.from(r.querySelectorAll(g));return i[0]&&(i[0].focus(),console.log("Focusing first focusable element within the container.")),document.addEventListener("keydown",o),()=>{document.removeEventListener("keydown",o),e.current&&(document.activeElement===document.body||r.contains(document.activeElement))&&e.current.focus();}},[o]),t},S=Z;var ee=(...e)=>t=>{e.forEach(o=>{o!=null&&(typeof o=="function"?o(t):o.current=t);});},I=ee;var F=(e,t,o)=>{let s=0,n=0;switch(o){case"top-center":s=e.top-t.height-10,n=e.left+e.width/2-t.width/2;break;case"bottom-center":s=e.top+e.height+10,n=e.left+e.width/2-t.width/2;break;case"left-center":s=e.top+e.height/2-t.height/2,n=e.left-t.width-10;break;case"right-center":s=e.top+e.height/2-t.height/2,n=e.left+e.width+10;break}return s=Math.max(10,Math.min(s,window.innerHeight-t.height-10)),n=Math.max(10,Math.min(n,window.innerWidth-t.width-10)),{top:s,left:n}};var D={left:0,top:0,width:0,height:0},x=m.createContext({isShow:!1,setIsShow:()=>{throw new Error("PopoverContext setIsShow should be used under provider")},preferredPosition:"bottom-center",triggerRect:D,setTriggerRect:()=>{throw new Error("PopoverContext setTriggerRect should be used under provider")}});function a({children:e,preferredPosition:t="bottom-center"}){let[o,r]=m.useState(!1),[i,s]=m.useState(D),n={isShow:o,setIsShow:r,preferredPosition:t,triggerRect:i,setTriggerRect:s};return m__default.default.createElement(x.Provider,{value:n},e)}function se({children:e}){let{setIsShow:t,setTriggerRect:o}=m.useContext(x),r=m.useRef(null);return m.cloneElement(e,{onClick:n=>{let u=r.current;if(u==null)return;let l=u.getBoundingClientRect();o(l),t(f=>!f);},ref:r})}function ie({children:e}){let{isShow:t}=m.useContext(x);return t?m__default.default.createElement(ue,null,e):null}function ue({children:e}){let{triggerRect:t,preferredPosition:o,setIsShow:r}=m.useContext(x),i=m.useRef(null),[s,n]=m.useState({left:0,top:0});m.useLayoutEffect(()=>{let T=i.current;if(T==null)return;let v=T.getBoundingClientRect(),P=F(t,v,o);n(P);},[]);let u=S(),l=m.useCallback(()=>{r(!1);},[]),f=C(l),b=I(i,u,f);return m__default.default.createElement("dialog",{open:!0,ref:b,style:{position:"fixed",left:`${s.left}px`,top:`${s.top}px`,margin:0}},e)}a.Trigger=se;a.Content=ie;var le=({children:e,...t})=>{let{addTour:o}=h();return m.useEffect(()=>{o(t);},[o,t]),m__default.default.createElement(a,{preferredPosition:"top-center"},m__default.default.createElement(a.Trigger,null,m__default.default.createElement("button",null,"hello")),m__default.default.createElement(a.Content,null,"This is the content",m__default.default.createElement("input",{type:"text"})))},N=le;
exports.Tour = N;
exports.TourProvider = O;
exports.useTourControls = h;
exports.useTourState = R;
`;var Z=()=>{let e=(0,p.useRef)(document.activeElement),t=(0,p.useRef)(null),o=(0,p.useCallback)(r=>{if(r.key!=="Tab"||!t.current)return;let n=Array.from(t.current.querySelectorAll(L));if(n.length===0)return;let u=n[0],s=n[n.length-1],{activeElement:l}=document;r.shiftKey&&l===u?(s.focus(),r.preventDefault()):!r.shiftKey&&l===s&&(u.focus(),r.preventDefault())},[]);return(0,p.useEffect)(()=>{let r=t.current;if(!r)return;let n=Array.from(r.querySelectorAll(L));return n[0]&&(n[0].focus(),console.log("Focusing first focusable element within the container.")),document.addEventListener("keydown",o),()=>{document.removeEventListener("keydown",o),e.current&&(document.activeElement===document.body||r.contains(document.activeElement))&&e.current.focus()}},[o]),t},O=Z;var ee=(...e)=>t=>{e.forEach(o=>{o!=null&&(typeof o=="function"?o(t):o.current=t)})},N=ee;var B=(e,t,o)=>{let u=0,s=0;switch(o){case"top-center":u=e.top-t.height-10,s=e.left+e.width/2-t.width/2;break;case"bottom-center":u=e.top+e.height+10,s=e.left+e.width/2-t.width/2;break;case"left-center":u=e.top+e.height/2-t.height/2,s=e.left-t.width-10;break;case"right-center":u=e.top+e.height/2-t.height/2,s=e.left+e.width+10;break}return u=Math.max(10,Math.min(u,window.innerHeight-t.height-10)),s=Math.max(10,Math.min(s,window.innerWidth-t.width-10)),{top:u,left:s}};var K={left:0,top:0,width:0,height:0},w=(0,i.createContext)({isShow:!1,setIsShow:()=>{throw new Error("PopoverContext setIsShow should be used under provider")},preferredPosition:"bottom-center",triggerRect:K,setTriggerRect:()=>{throw new Error("PopoverContext setTriggerRect should be used under provider")}});function m({children:e,preferredPosition:t="bottom-center"}){let[o,r]=(0,i.useState)(!1),[n,u]=(0,i.useState)(K),s={isShow:o,setIsShow:r,preferredPosition:t,triggerRect:n,setTriggerRect:u};return i.default.createElement(w.Provider,{value:s},e)}function te({children:e}){let{setIsShow:t,setTriggerRect:o}=(0,i.useContext)(w),r=(0,i.useRef)(null);return(0,i.cloneElement)(e,{onClick:s=>{let l=r.current;if(l==null)return;let f=l.getBoundingClientRect();o(f),t(T=>!T)},ref:r})}function oe({children:e}){let{isShow:t}=(0,i.useContext)(w);return t?i.default.createElement(re,null,e):null}function re({children:e}){let{triggerRect:t,preferredPosition:o,setIsShow:r}=(0,i.useContext)(w),n=(0,i.useRef)(null),[u,s]=(0,i.useState)({left:0,top:0});(0,i.useLayoutEffect)(()=>{let b=n.current;if(b==null)return;let g=b.getBoundingClientRect(),S=B(t,g,o);s(S)},[]);let l=O(),f=(0,i.useCallback)(()=>{r(!1)},[]),T=y(f),C=N(n,l,T);return i.default.createElement("dialog",{open:!0,ref:C,style:{position:"fixed",left:`${u.left}px`,top:`${u.top}px`,margin:0}},e)}m.Trigger=te;m.Content=oe;var ne=({children:e,...t})=>{let{addTour:o}=x();return(0,d.useEffect)(()=>{o(t)},[o,t]),d.default.createElement(m,{preferredPosition:"top-center"},d.default.createElement(m.Trigger,null,d.default.createElement("button",null,"hello")),d.default.createElement(m.Content,null,"This is the content",d.default.createElement("input",{type:"text"})))},R=ne;0&&(module.exports={Tour,TourProvider,useTourControls,useTourState});

2

package.json
{
"name": "next-tour",
"version": "0.2.1",
"version": "0.2.2",
"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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc