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

vaul

Package Overview
Dependencies
Maintainers
1
Versions
66
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vaul - npm Package Compare versions

Comparing version 0.6.5 to 0.6.6

2

dist/index.d.ts

@@ -31,3 +31,3 @@ import * as DialogPrimitive from '@radix-ui/react-dialog';

declare function Root({ open: openProp, onOpenChange, children, shouldScaleBackground, onDrag: onDragProp, onRelease: onReleaseProp, experimentalSafariThemeAnimation, snapPoints, nested, closeThreshold, scrollLockTimeout, dismissible, fadeFromIndex, activeSnapPoint: activeSnapPointProp, setActiveSnapPoint: setActiveSnapPointProp, fixed, modal, onClose, }: DialogProps): React.JSX.Element;
declare function NestedRoot({ children, onDrag, onOpenChange }: DialogProps): React.JSX.Element;
declare function NestedRoot({ children, onDrag, onOpenChange, ...rest }: DialogProps): React.JSX.Element;
declare const Drawer: {

@@ -34,0 +34,0 @@ Root: typeof Root;

"use client"
"use client";var wt=Object.create;var ue=Object.defineProperty;var St=Object.getOwnPropertyDescriptor;var Rt=Object.getOwnPropertyNames;var Dt=Object.getPrototypeOf,Mt=Object.prototype.hasOwnProperty;var Ct=(e,n)=>{for(var t in n)ue(e,t,{get:n[t],enumerable:!0})},Ve=(e,n,t,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let i of Rt(n))!Mt.call(e,i)&&i!==t&&ue(e,i,{get:()=>n[i],enumerable:!(o=St(n,i))||o.enumerable});return e};var j=(e,n,t)=>(t=e!=null?wt(Dt(e)):{},Ve(n||!e||!e.__esModule?ue(t,"default",{value:e,enumerable:!0}):t,e)),xt=e=>Ve(ue({},"__esModule",{value:!0}),e);var nn={};Ct(nn,{Drawer:()=>tn});module.exports=xt(nn);var I=j(require("@radix-ui/react-dialog")),h=j(require("react"));var Se=j(require("react")),Re=Se.default.createContext({drawerRef:{current:null},overlayRef:{current:null},scaleBackground:()=>{},onPress:()=>{},onRelease:()=>{},onDrag:()=>{},onNestedDrag:()=>{},onNestedOpenChange:()=>{},onNestedRelease:()=>{},dismissible:!1,isOpen:!1,keyboardIsOpen:{current:!1},experimentalSafariThemeAnimation:!1,snapPointsOffset:null,snapPoints:null,modal:!1,shouldFade:!1,activeSnapPoint:null,setActiveSnapPoint:()=>{},visible:!1,closeDrawer:()=>{},setVisible:()=>{}}),se=()=>Se.default.useContext(Re);function De(e,{insertAt:n}={}){if(!e||typeof document=="undefined")return;let t=document.head||document.getElementsByTagName("head")[0],o=document.createElement("style");o.type="text/css",n==="top"&&t.firstChild?t.insertBefore(o,t.firstChild):t.appendChild(o),o.styleSheet?o.styleSheet.cssText=e:o.appendChild(document.createTextNode(e))}De(`[vaul-drawer]{touch-action:none;transform:translate3d(0,100%,0);transition:transform .5s cubic-bezier(.32,.72,0,1)}[vaul-drawer][vaul-drawer-visible=true]{transform:translate3d(0,var(--snap-point-height, 0),0)}[vaul-overlay]{opacity:0;transition:opacity .5s cubic-bezier(.32,.72,0,1)}[vaul-overlay][vaul-drawer-visible=true]{opacity:1}[vaul-drawer]:after{content:"";position:absolute;top:100%;background:inherit;background-color:inherit;left:0;right:0;height:200%}[vaul-overlay][vaul-snap-points=true]:not([vaul-snap-points-overlay="true"]):not([data-state="closed"]){opacity:0}[vaul-overlay][vaul-snap-points-overlay=true]:not([vaul-drawer-visible="false"]){opacity:1}@keyframes fake-animation{}@keyframes show-theme-overlay{0%{background:var(--vaul-overlay-background-start)}to{background:var(--vaul-overlay-background-end)}}@keyframes hide-theme-overlay{0%{background:var(--vaul-overlay-background-end)}to{background:var(--vaul-overlay-background-start)}}@media (hover: hover) and (pointer: fine){[vaul-drawer]{user-select:none}}
`);var de=require("react"),Ot=typeof window!="undefined"?de.useLayoutEffect:de.useEffect;function xe(...e){return(...n)=>{for(let t of e)typeof t=="function"&&t(...n)}}function Ht(){return Oe(/^Mac/)}function It(){return Oe(/^iPhone/)}function We(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}function Lt(){return Oe(/^iPad/)||Ht()&&navigator.maxTouchPoints>1}function X(){return It()||Lt()}function Oe(e){return typeof window!="undefined"&&window.navigator!=null?e.test(window.navigator.platform):void 0}var Me=typeof document!="undefined"&&window.visualViewport;function je(e){let n=window.getComputedStyle(e);return/(auto|scroll)/.test(n.overflow+n.overflowX+n.overflowY)}function Ue(e){for(je(e)&&(e=e.parentElement);e&&!je(e);)e=e.parentElement;return e||document.scrollingElement||document.documentElement}var At=new Set(["checkbox","radio","range","color","file","image","button","submit","reset"]),ce=0,Ce;function Ye(e={}){let{isDisabled:n}=e;Ot(()=>{if(!n)return ce++,ce===1&&(X()?Ce=$t():Ce=Nt()),()=>{ce--,ce===0&&Ce()}},[n])}function Nt(){return xe(fe(document.documentElement,"paddingRight",`${window.innerWidth-document.documentElement.clientWidth}px`),fe(document.documentElement,"overflow","hidden"))}function $t(){let e,n=0,t=l=>{e=Ue(l.target),!(e===document.documentElement&&e===document.body)&&(n=l.changedTouches[0].pageY)},o=l=>{if(!e||e===document.documentElement||e===document.body){l.preventDefault();return}let s=l.changedTouches[0].pageY,x=e.scrollTop,O=e.scrollHeight-e.clientHeight;O!==0&&((x<=0&&s>n||x>=O&&s<n)&&l.preventDefault(),n=s)},i=l=>{let s=l.target;Z(s)&&s!==document.activeElement&&(l.preventDefault(),s.style.transform="translateY(-2000px)",s.focus(),requestAnimationFrame(()=>{s.style.transform=""}))},r=l=>{let s=l.target;Z(s)&&(s.style.transform="translateY(-2000px)",requestAnimationFrame(()=>{s.style.transform="",Me&&(Me.height<window.innerHeight?requestAnimationFrame(()=>{ze(s)}):Me.addEventListener("resize",()=>ze(s),{once:!0}))}))},a=()=>{window.scrollTo(0,0)},u=window.pageXOffset,E=window.pageYOffset,T=xe(fe(document.documentElement,"paddingRight",`${window.innerWidth-document.documentElement.clientWidth}px`),fe(document.documentElement,"overflow","hidden"));window.scrollTo(0,0);let v=xe(Q(document,"touchstart",t,{passive:!1,capture:!0}),Q(document,"touchmove",o,{passive:!1,capture:!0}),Q(document,"touchend",i,{passive:!1,capture:!0}),Q(document,"focus",r,!0),Q(window,"scroll",a));return()=>{T(),v(),window.scrollTo(u,E)}}function fe(e,n,t){let o=e.style[n];return e.style[n]=t,()=>{e.style[n]=o}}function Q(e,n,t,o){return e.addEventListener(n,t,o),()=>{e.removeEventListener(n,t,o)}}function ze(e){let n=document.scrollingElement||document.documentElement;for(;e&&e!==n;){let t=Ue(e);if(t!==document.documentElement&&t!==document.body&&t!==e){let o=t.getBoundingClientRect().top,i=e.getBoundingClientRect().top,r=e.getBoundingClientRect().bottom,a=t.getBoundingClientRect().bottom;r>a&&(t.scrollTop+=i-o)}e=t.parentElement}}function Z(e){return e instanceof HTMLInputElement&&!At.has(e.type)||e instanceof HTMLTextAreaElement||e instanceof HTMLElement&&e.isContentEditable}var _e=j(require("react"));function Pt(e,n){typeof e=="function"?e(n):e!=null&&(e.current=n)}function Ft(...e){return n=>e.forEach(t=>Pt(t,n))}function He(...e){return _e.useCallback(Ft(...e),e)}var L=j(require("react"));var kt=4,Bt=.001,Vt=1e-7,jt=10,ee=11,me=1/(ee-1),zt=typeof Float32Array=="function";function qe(e,n){return 1-3*n+3*e}function Ge(e,n){return 3*n-6*e}function Ke(e){return 3*e}function be(e,n,t){return((qe(n,t)*e+Ge(n,t))*e+Ke(n))*e}function Je(e,n,t){return 3*qe(n,t)*e*e+2*Ge(n,t)*e+Ke(n)}function Wt(e,n,t,o,i){var r,a,u=0;do a=n+(t-n)/2,r=be(a,o,i)-e,r>0?t=a:n=a;while(Math.abs(r)>Vt&&++u<jt);return a}function Ut(e,n,t,o){for(var i=0;i<kt;++i){var r=Je(n,t,o);if(r===0)return n;var a=be(n,t,o)-e;n-=a/r}return n}function Yt(e){return e}function Qe(e,n,t,o){if(!(0<=e&&e<=1&&0<=t&&t<=1))throw new Error("bezier x values must be in [0, 1] range");if(e===n&&t===o)return Yt;for(var i=zt?new Float32Array(ee):new Array(ee),r=0;r<ee;++r)i[r]=be(r*me,e,t);function a(u){for(var E=0,T=1,v=ee-1;T!==v&&i[T]<=u;++T)E+=me;--T;var l=(u-i[T])/(i[T+1]-i[T]),s=E+l*me,x=Je(s,e,t);return x>=Bt?Ut(u,s,e,t):x===0?s:Wt(u,E,E+me,e,t)}return function(E){return E===0||E===1?E:be(a(E),n,o)}}var _t=Qe(.32,.72,0,1);function qt(e){let n=e.match(/rgba?\((\d+),\s*(\d+),\s*(\d+),\s*(\d*(?:\.\d+)?)\)/);if(!n)throw new Error("Invalid color string");return[Number(n[1]),Number(n[2]),Number(n[3]),Number(n[4])]}function Gt(e,n){let[t,o,i,r]=qt(e);return[Math.round(r*t+(1-r)*Number(n[0])),Math.round(r*o+(1-r)*Number(n[1])),Math.round(r*i+(1-r)*Number(n[2]))]}function Kt(e){return _t(e)}function Jt(e,n,t,o){arguments.length<3&&(t=.5);let i=e.slice();for(let r=0;r<3;r++){let a=n[r]-e[r],u=o?e[r]+t*a:e[r]+Kt(t)*a;i[r]=Math.round(u),i[r]<0&&(i[r]=0),i[r]>255&&(i[r]=255)}return i}function te(e,n,t,o){let i=1/(t-1),r=[];for(let a=0;a<t;a++)r.push(Jt(e,n,i*a,!!o));return r}function Ze(e,n,t,o){let[i,r]=L.default.useState([255,255,255]),[a,u]=L.default.useState([153,153,153]),[E,T]=L.default.useState(!1),[v,l]=L.default.useState(null),[s,x]=L.default.useState(null),O=L.default.useMemo(()=>X()&&We()&&o,[o]),k=L.default.useMemo(()=>i&&a?te(i,a,50):null,[a,i]),N=L.default.useMemo(()=>i&&a?te(a,i,50):null,[a,i]),g=L.default.useMemo(()=>i&&a?te(a,i,50,!0):null,[a,i]);L.default.useEffect(()=>{if(!O)return;let b=getComputedStyle(document.documentElement),M=b.getPropertyValue("--vaul-overlay-background").split(",").map(P=>Number(P)),C=b.getPropertyValue("--vaul-overlay-background-end"),R=Gt(C,M);r(M),u(R)},[O]),L.default.useEffect(()=>{if(O&&!v){let b=document.querySelector('meta[name="theme-color"]');b?l(b.getAttribute("content")):(b=document.createElement("meta"),b.name="theme-color",document.getElementsByTagName("head")[0].appendChild(b)),x(b)}},[v,O]);let c=(0,L.useCallback)(b=>{let M,C;function R(P){M||(M=P);let he=P-M,_=Math.floor(he/10);if(n.current&&b&&!E&&e.current){if(e.current.style.transform==="translateY(0px)"&&e.current.getAttribute("vaul-clicked-outside")!=="true")return;if(_<b.length){let F=b[_];s==null||s.setAttribute("content",`rgb(${F.join(",")})`),_===b.length-1&&v&&!t&&(s==null||s.setAttribute("content",v)),C=requestAnimationFrame(R)}}}return C=requestAnimationFrame(R),C},[e,t,s,E,v,n]);L.default.useEffect(()=>{if(!O||!k||!N)return;let b=c(t?k:N);return t&&T(!1),()=>{b&&cancelAnimationFrame(b)}},[t,O,c,k,N]);function p(b){let M=document.querySelector('meta[name="theme-color"]');if(!O||!M||!g)return;let C=Math.floor(b*g.length);C=Math.max(0,Math.min(g.length-1,C));let R=g[C];M.setAttribute("content",`rgb(${R.join(",")})`)}function $(b){let M=document.querySelector('meta[name="theme-color"]');if(!M||!O)return;T(!0);let C=M.getAttribute("content").match(/\d+/g).map(Number),R=te(C,a,50);!b&&i&&(R=te(C,i,50)),c(R)}return{onDrag:p,onRelease:$}}var ge=j(require("react")),z=null;function Xe({isOpen:e,modal:n,nested:t}){let o=ge.default.useRef(0);function i(){if(z===null){z={position:document.body.style.position,top:document.body.style.top,left:document.body.style.left,height:document.body.style.height};let{scrollX:a,innerHeight:u}=window;document.body.style.setProperty("position","fixed","important"),document.body.style.top=`${-o.current}px`,document.body.style.left=`${-a}px`,document.body.style.right="0px",document.body.style.height="auto",setTimeout(()=>requestAnimationFrame(()=>{let E=u-window.innerHeight;E&&o.current>=u&&(document.body.style.top=`${-(o.current+E)}px`)}),300)}}function r(){if(z!==null){let a=-parseInt(document.body.style.top,10),u=-parseInt(document.body.style.left,10);document.body.style.position=z.position,document.body.style.top=z.top,document.body.style.left=z.left,document.body.style.height=z.height,document.body.style.right="unset",requestAnimationFrame(()=>{window.scrollTo(u,a)}),z=null}}ge.default.useEffect(()=>{function a(){o.current=window.scrollY}return a(),window.addEventListener("scroll",a),()=>{window.removeEventListener("scroll",a)}},[]),ge.default.useEffect(()=>{t||(e?(i(),n||setTimeout(()=>{r()},500)):r())},[e])}var U=j(require("react"));var et=new WeakMap;function w(e,n,t=!1){if(!e||!(e instanceof HTMLElement)||!n)return;let o={};Object.entries(n).forEach(([i,r])=>{if(i.startsWith("--")){e.style.setProperty(i,r);return}o[i]=e.style[i],e.style[i]=r}),!t&&et.set(e,o)}function pe(e,n){if(!e||!(e instanceof HTMLElement))return;let t=et.get(e);t&&(n?e.style[n]=t[n]:Object.entries(t).forEach(([o,i])=>{e.style[o]=i}))}function ne(e){let n=window.getComputedStyle(e),t=n.transform||n.webkitTransform||n.mozTransform,o=t.match(/^matrix3d\((.+)\)$/);return o?parseFloat(o[1].split(", ")[13]):(o=t.match(/^matrix\((.+)\)$/),o?parseFloat(o[1].split(", ")[5]):null)}function tt(e){return 8*(Math.log(e+1)-2)}var y={DURATION:.5,EASE:[.32,.72,0,1]},ve=.4;var W=j(require("react"));function nt(e){let n=W.default.useRef(e);return W.default.useEffect(()=>{n.current=e}),W.default.useMemo(()=>(...t)=>{var o;return(o=n.current)==null?void 0:o.call(n,...t)},[])}function Qt({defaultProp:e,onChange:n}){let t=W.default.useState(e),[o]=t,i=W.default.useRef(o),r=nt(n);return W.default.useEffect(()=>{i.current!==o&&(r(o),i.current=o)},[o,i,r]),t}function rt({prop:e,defaultProp:n,onChange:t=()=>{}}){let[o,i]=Qt({defaultProp:n,onChange:t}),r=e!==void 0,a=r?e:o,u=nt(t),E=W.default.useCallback(T=>{if(r){let l=typeof T=="function"?T(e):T;l!==e&&u(l)}else i(T)},[r,e,i,u]);return[a,E]}function ot({activeSnapPointProp:e,setActiveSnapPointProp:n,snapPoints:t,drawerRef:o,overlayRef:i,fadeFromIndex:r}){let[a,u]=rt({prop:e,defaultProp:t==null?void 0:t[0],onChange:n}),E=U.default.useMemo(()=>a===(t==null?void 0:t[t.length-1]),[t,a]),T=t&&t.length>0&&r&&t[r]===a||!t,v=U.default.useMemo(()=>{var g;return(g=t==null?void 0:t.findIndex(c=>c===a))!=null?g:null},[t,a]),l=U.default.useMemo(()=>{var g;return(g=t==null?void 0:t.map(c=>{let p=typeof window!="undefined",$=typeof c=="string",b=0;$&&(b=parseInt(c,10));let M=$?b:p?c*window.innerHeight:0;return p?window.innerHeight-M:M}))!=null?g:[]},[t]),s=U.default.useMemo(()=>v!==null?l==null?void 0:l[v]:null,[l,v]),x=U.default.useCallback(g=>{var p;let c=(p=l==null?void 0:l.findIndex($=>$===g))!=null?p:null;w(o.current,{transition:`transform ${y.DURATION}s cubic-bezier(${y.EASE.join(",")})`,transform:`translate3d(0, ${g}px, 0)`}),l&&c!==l.length-1&&c!==r?w(i.current,{transition:`opacity ${y.DURATION}s cubic-bezier(${y.EASE.join(",")})`,opacity:"0"}):w(i.current,{transition:`opacity ${y.DURATION}s cubic-bezier(${y.EASE.join(",")})`,opacity:"1"}),u(c!==null?t==null?void 0:t[c]:null)},[o,t,l,r,i,u]);U.default.useEffect(()=>{var g;if(e){let c=(g=t==null?void 0:t.findIndex(p=>p===e))!=null?g:null;l&&c&&typeof l[c]=="number"&&x(l[c])}},[e,t,l,x]);function O({draggedDistance:g,closeDrawer:c,velocity:p}){if(typeof s!="number"||r===void 0)return;let $=s-g,b=v===r-1,M=v===0;if(b&&w(i.current,{transition:`opacity ${y.DURATION}s cubic-bezier(${y.EASE.join(",")})`}),p>2&&g<0){c();return}if(p>2&&g>0&&l&&t){x(l[t.length-1]);return}let C=l==null?void 0:l.reduce((R,P)=>typeof R!="number"||typeof P!="number"?R:Math.abs(P-$)<Math.abs(R-$)?P:R);if(p>ve&&Math.abs(g)<window.innerHeight*.4){let R=g>0?1:-1;if(R>0&&E||(M&&R<0&&c(),v===null))return;x(l[v+R]);return}x(C)}function k({draggedDistance:g}){var p;if(s===null)return;let c=s-g;if(c<l[l.length-1]){u((p=t==null?void 0:t[t.length-1])!=null?p:null),w(o.current,{transform:"translate3d(0, 0px, 0)"});return}w(o.current,{transform:`translate3d(0, ${c}px, 0)`})}function N(g,c){if(!t||!v||!l||r===void 0)return null;let p=v===r-1;if(v>=r&&c)return 0;if(p&&!c)return 1;if(!T&&!p)return null;let b=p?v+1:v-1,M=p?l[b]-l[b-1]:l[b+1]-l[b],C=g/Math.abs(M);return p?1-C:C}return{isLastSnapPoint:E,activeSnapPoint:a,shouldFade:T,getPercentageDragged:N,setActiveSnapPoint:u,activeSnapPointIndex:v,onRelease:O,onDrag:k,snapPointsOffset:l}}var Zt=.25,Xt=500,it=8,Y=16,at=26;function lt({open:e,onOpenChange:n,children:t,shouldScaleBackground:o,onDrag:i,onRelease:r,experimentalSafariThemeAnimation:a,snapPoints:u,nested:E,closeThreshold:T=Zt,scrollLockTimeout:v=Xt,dismissible:l=!0,fadeFromIndex:s=u&&u.length-1,activeSnapPoint:x,setActiveSnapPoint:O,fixed:k,modal:N=!0,onClose:g}){var Be;let[c=!1,p]=h.default.useState(!1),[$,b]=h.default.useState(!1),[M,C]=h.default.useState(!1),[R,P]=h.default.useState(!1),[he,_]=h.default.useState(!1),F=h.default.useRef(null),Ee=h.default.useRef(null),Ie=h.default.useRef(null),K=h.default.useRef(null),J=h.default.useRef(!1),ye=h.default.useRef(null),Te=h.default.useRef(0),q=h.default.useRef(!1),Le=h.default.useRef(0),d=h.default.useRef(null),Ae=h.default.useRef(((Be=d.current)==null?void 0:Be.getBoundingClientRect().height)||0),{onDrag:ct,onRelease:re}=Ze(d,F,c,a),{activeSnapPoint:ft,activeSnapPointIndex:oe,setActiveSnapPoint:Ne,onRelease:dt,snapPointsOffset:ie,onDrag:mt,shouldFade:$e,getPercentageDragged:bt}=ot({snapPoints:u,activeSnapPointProp:x,setActiveSnapPointProp:O,drawerRef:d,fadeFromIndex:s,overlayRef:F});Ye({isDisabled:!c||R||!N||he}),Xe({isOpen:c,modal:N,nested:E});function ae(){return(window.innerWidth-at)/window.innerWidth}function gt(f){var m;l&&(d.current&&!d.current.contains(f.target)||(Ae.current=((m=d.current)==null?void 0:m.getBoundingClientRect().height)||0,P(!0),Ee.current=new Date,X()&&window.addEventListener("touchend",()=>J.current=!1,{once:!0}),f.target.setPointerCapture(f.pointerId),Te.current=f.clientY))}function Pe(f,m){var B;let S=f,A=new Date,H=(B=window.getSelection())==null?void 0:B.toString(),D=d.current?ne(d.current):null;if(D>0)return!0;if(H&&H.length>0)return!1;if(K.current&&A.getTime()-K.current.getTime()<v&&D===0)return K.current=new Date,!1;for(;S;){if(S.scrollHeight>S.clientHeight){if(S.getAttribute("role")==="dialog")return!0;if(m&&S!==document.body&&!D&&D>=0)return K.current=new Date,!1;if(S.scrollTop!==0)return K.current=new Date,!1}S=S.parentNode}return!0}function pt(f){if(R){let m=Te.current-f.clientY,S=m>0;if(!J.current&&!Pe(f.target,S))return;if(J.current=!0,w(d.current,{transition:"none"}),w(F.current,{transition:"none"}),u&&mt({draggedDistance:m}),m>0&&!u){let V=tt(m);w(d.current,{transform:`translate3d(0, ${Math.min(V*-1,0)}px, 0)`});return}let A=Math.abs(m),H=document.querySelector("[vaul-drawer-wrapper]"),D=A/Ae.current,B=bt(A,S);B!==null&&(D=B);let we=1-D;if(($e||s&&oe===s-1)&&(ct(D),i==null||i(f,D),w(F.current,{opacity:`${we}`,transition:"none"},!0)),H&&F.current&&o){let V=Math.min(ae()+D*(1-ae()),1),le=8-D*8,Tt=Math.max(0,14-D*14);w(H,{borderRadius:`${le}px`,transform:`scale(${V}) translate3d(0, ${Tt}px, 0)`,transition:"none"},!0)}u||w(d.current,{transform:`translate3d(0, ${A}px, 0)`})}}h.default.useEffect(()=>{var m;function f(){var A;if(!d.current)return;let S=document.activeElement;if(Z(S)||q.current){let H=((A=window.visualViewport)==null?void 0:A.height)||0,D=window.innerHeight-H,B=d.current.getBoundingClientRect().height||0,we=d.current.getBoundingClientRect().top;if(Math.abs(Le.current-D)>60&&(q.current=!q.current),u&&u.length>0&&ie&&oe){let V=ie[oe]||0;D+=V}if(Le.current=D,B>H||q.current){let V=d.current.getBoundingClientRect().height,le=V;V>H&&(le=H-at),k?d.current.style.height=`${V-Math.max(D,0)}px`:d.current.style.height=`${Math.max(le,H-we)}px`}else d.current.style.height="initial";u&&u.length>0&&!q.current?d.current.style.bottom="0px":d.current.style.bottom=`${Math.max(D,0)}px`}}return(m=window.visualViewport)==null||m.addEventListener("resize",f),()=>{var S;return(S=window.visualViewport)==null?void 0:S.removeEventListener("resize",f)}},[oe,u,ie]);function G(){d.current&&(g==null||g(),d.current&&(w(d.current,{transform:"translate3d(0, 100%, 0)",transition:`transform ${y.DURATION}s cubic-bezier(${y.EASE.join(",")})`}),w(F.current,{opacity:"0",transition:`opacity ${y.DURATION}s cubic-bezier(${y.EASE.join(",")})`}),ke(!1)),setTimeout(()=>{p(!1),b(!1)},300),setTimeout(()=>{u&&Ne(u[0])},500))}h.default.useEffect(()=>{if(!c&&o){let f=setTimeout(()=>{pe(document.body)},200);return()=>clearTimeout(f)}},[c,o]),h.default.useEffect(()=>{e?p(!0):G()},[e]),h.default.useEffect(()=>{M&&(n==null||n(c))},[c]),h.default.useEffect(()=>{C(!0)},[]);function Fe(){if(!d.current)return;let f=document.querySelector("[vaul-drawer-wrapper]"),m=ne(d.current);w(d.current,{transform:"translate3d(0, 0, 0)",transition:`transform ${y.DURATION}s cubic-bezier(${y.EASE.join(",")})`}),w(F.current,{transition:`opacity ${y.DURATION}s cubic-bezier(${y.EASE.join(",")})`,opacity:"1"}),o&&m&&m>0&&c&&w(f,{borderRadius:`${it}px`,overflow:"hidden",transform:`scale(${ae()}) translate3d(0, calc(env(safe-area-inset-top) + 14px), 0)`,transformOrigin:"top",transitionProperty:"transform, border-radius",transitionDuration:`${y.DURATION}s`,transitionTimingFunction:`cubic-bezier(${y.EASE.join(",")})`},!0)}function vt(f){if(!R||!d.current)return;J.current&&Z(f.target)&&f.target.blur(),J.current=!1,P(!1),Ie.current=new Date;let m=ne(d.current);if(!Pe(f.target,!1)||!m||Number.isNaN(m)||Ee.current===null)return;let S=f.clientY,A=Ie.current.getTime()-Ee.current.getTime(),H=Te.current-S,D=Math.abs(H)/A;if(D>.05&&(_(!0),setTimeout(()=>{_(!1)},200)),u){dt({draggedDistance:H,closeDrawer:G,velocity:D});return}if(H>0){Fe(),r==null||r(f,!0),re(!0);return}if(D>ve){G(),r==null||r(f,!1),re(!1);return}let B=Math.min(d.current.getBoundingClientRect().height||0,window.innerHeight);if(m>=B*T){G(),r==null||r(f,!1),re(!1);return}r==null||r(f,!0),re(!0),Fe()}function ke(f){let m=document.querySelector("[vaul-drawer-wrapper]");!m||!o||(f?(w(document.body,{background:"black"},!0),w(m,{borderRadius:`${it}px`,overflow:"hidden",transform:`scale(${ae()}) translate3d(0, calc(env(safe-area-inset-top) + 14px), 0)`,transformOrigin:"top",transitionProperty:"transform, border-radius",transitionDuration:`${y.DURATION}s`,transitionTimingFunction:`cubic-bezier(${y.EASE.join(",")})`})):(pe(m,"transform"),pe(m,"borderRadius"),w(m,{transitionProperty:"transform, border-radius",transitionDuration:`${y.DURATION}s`,transitionTimingFunction:`cubic-bezier(${y.EASE.join(",")})`})))}function ht(f){let m=f?(window.innerWidth-Y)/window.innerWidth:1,S=f?-Y:0;ye.current&&window.clearTimeout(ye.current),w(d.current,{transition:`transform ${y.DURATION}s cubic-bezier(${y.EASE.join(",")})`,transform:`scale(${m}) translate3d(0, ${S}px, 0)`}),!f&&d.current&&(ye.current=setTimeout(()=>{w(d.current,{transition:"none",transform:`translate3d(0, ${ne(d.current)}px, 0)`})},500))}function Et(f,m){if(m<0)return;let S=(window.innerWidth-Y)/window.innerWidth,A=S+m*(1-S),H=-Y+m*Y;w(d.current,{transform:`scale(${A}) translate3d(0, ${H}px, 0)`,transition:"none"})}function yt(f,m){let S=m?(window.innerWidth-Y)/window.innerWidth:1,A=m?-Y:0;m&&w(d.current,{transition:`transform ${y.DURATION}s cubic-bezier(${y.EASE.join(",")})`,transform:`scale(${S}) translate3d(0, ${A}px, 0)`})}return h.default.createElement(I.Root,{modal:N,onOpenChange:f=>{f?p(f):G()},open:c},h.default.createElement(Re.Provider,{value:{visible:$,activeSnapPoint:ft,snapPoints:u,setActiveSnapPoint:Ne,drawerRef:d,overlayRef:F,scaleBackground:ke,onPress:gt,setVisible:b,onRelease:vt,onDrag:pt,dismissible:l,isOpen:c,shouldFade:$e,closeDrawer:G,onNestedDrag:Et,onNestedOpenChange:ht,onNestedRelease:yt,keyboardIsOpen:q,modal:N,snapPointsOffset:ie,experimentalSafariThemeAnimation:a}},t))}var ut=h.default.forwardRef(function({children:e,style:n,...t},o){let{overlayRef:i,snapPoints:r,onRelease:a,experimentalSafariThemeAnimation:u,shouldFade:E,isOpen:T,visible:v}=se(),l=He(o,i),s=r&&r.length>0;return h.default.createElement(I.Overlay,{onMouseUp:a,ref:l,"vaul-drawer-visible":v?"true":"false","vaul-overlay":"","vaul-snap-points":T&&s?"true":"false","vaul-snap-points-overlay":T&&E?"true":"false","vaul-theme-transition":u?"true":"false",...t})});ut.displayName="Drawer.Overlay";var st=h.default.forwardRef(function({children:e,onOpenAutoFocus:n,onPointerDownOutside:t,onAnimationEnd:o,style:i,...r},a){let{drawerRef:u,onPress:E,onRelease:T,onDrag:v,dismissible:l,keyboardIsOpen:s,snapPointsOffset:x,visible:O,setVisible:k,closeDrawer:N,scaleBackground:g}=se(),c=He(a,u);return h.default.useEffect(()=>{k(!0),g(!0)},[]),h.default.createElement(I.Content,{onOpenAutoFocus:p=>{n?n(p):p.preventDefault()},onPointerDown:E,onPointerDownOutside:p=>{s.current&&(s.current=!1),p.preventDefault(),l&&(N(),t==null||t(p))},onPointerMove:v,onPointerUp:T,ref:c,style:x?{"--snap-point-height":`${x[0]}px`,...i}:i,...r,"vaul-drawer":"","vaul-drawer-visible":O?"true":"false"},e)});st.displayName="Drawer.Content";function en({children:e,onDrag:n,onOpenChange:t}){let{onNestedDrag:o,onNestedOpenChange:i,onNestedRelease:r}=se();if(!o)throw new Error("Drawer.NestedRoot must be placed in another drawer");return h.default.createElement(lt,{nested:!0,onClose:()=>{i(!1)},onDrag:(a,u)=>{o(a,u),n==null||n(a,u)},onOpenChange:a=>{a&&i(a),t==null||t(a)},onRelease:r},e)}var tn={Root:lt,NestedRoot:en,Content:st,Overlay:ut,Trigger:I.Trigger,Portal:I.Portal,Close:I.Close,Title:I.Title,Description:I.Description};0&&(module.exports={Drawer});
"use client";var mt=Object.create;var ae=Object.defineProperty;var pt=Object.getOwnPropertyDescriptor;var gt=Object.getOwnPropertyNames;var bt=Object.getPrototypeOf,vt=Object.prototype.hasOwnProperty;var ht=(e,n)=>{for(var t in n)ae(e,t,{get:n[t],enumerable:!0})},Pe=(e,n,t,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let l of gt(n))!vt.call(e,l)&&l!==t&&ae(e,l,{get:()=>n[l],enumerable:!(r=pt(n,l))||r.enumerable});return e};var W=(e,n,t)=>(t=e!=null?mt(bt(e)):{},Pe(n||!e||!e.__esModule?ae(t,"default",{value:e,enumerable:!0}):t,e)),wt=e=>Pe(ae({},"__esModule",{value:!0}),e);var $t={};ht($t,{Drawer:()=>It});module.exports=wt($t);var S=W(require("@radix-ui/react-dialog")),m=W(require("react"));var he=W(require("react")),we=he.default.createContext({drawerRef:{current:null},overlayRef:{current:null},scaleBackground:()=>{},onPress:()=>{},onRelease:()=>{},onDrag:()=>{},onNestedDrag:()=>{},onNestedOpenChange:()=>{},onNestedRelease:()=>{},dismissible:!1,isOpen:!1,keyboardIsOpen:{current:!1},experimentalSafariThemeAnimation:!1,snapPointsOffset:null,snapPoints:null,modal:!1,shouldFade:!1,activeSnapPoint:null,setActiveSnapPoint:()=>{},visible:!1,closeDrawer:()=>{},setVisible:()=>{}}),le=()=>he.default.useContext(we);function Te(e,{insertAt:n}={}){if(!e||typeof document=="undefined")return;let t=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css",n==="top"&&t.firstChild?t.insertBefore(r,t.firstChild):t.appendChild(r),r.styleSheet?r.styleSheet.cssText=e:r.appendChild(document.createTextNode(e))}Te(`[vaul-drawer]{touch-action:none;transform:translate3d(0,100%,0);transition:transform .5s cubic-bezier(.32,.72,0,1)}[vaul-drawer][vaul-drawer-visible=true]{transform:translate3d(0,var(--snap-point-height, 0),0)}[vaul-overlay]{opacity:0;transition:opacity .5s cubic-bezier(.32,.72,0,1)}[vaul-overlay][vaul-drawer-visible=true]{opacity:1}[vaul-overlay][vaul-theme-transition=true]{opacity:1;background:transparent}[vaul-drawer]:after{content:"";position:absolute;top:100%;background:inherit;background-color:inherit;left:0;right:0;height:200%}[vaul-overlay][vaul-snap-points=true]:not([vaul-snap-points-overlay="true"]):not([data-state="closed"]){opacity:0}[vaul-overlay][vaul-snap-points-overlay=true]:not([vaul-drawer-visible="false"]){opacity:1}@keyframes fake-animation{}@keyframes show-theme-overlay{0%{background:var(--vaul-overlay-background-start)}to{background:var(--vaul-overlay-background-end)}}@keyframes hide-theme-overlay{0%{background:var(--vaul-overlay-background-end)}to{background:var(--vaul-overlay-background-start)}}@media (hover: hover) and (pointer: fine){[vaul-drawer]{user-select:none}}
`);var ce=require("react"),Tt=typeof window!="undefined"?ce.useLayoutEffect:ce.useEffect;function De(...e){return(...n)=>{for(let t of e)typeof t=="function"&&t(...n)}}function yt(){return Re(/^Mac/)}function Et(){return Re(/^iPhone/)}function Dt(){return Re(/^iPad/)||yt()&&navigator.maxTouchPoints>1}function Se(){return Et()||Dt()}function Re(e){return typeof window!="undefined"&&window.navigator!=null?e.test(window.navigator.platform):void 0}var ye=typeof document!="undefined"&&window.visualViewport;function ke(e){let n=window.getComputedStyle(e);return/(auto|scroll)/.test(n.overflow+n.overflowX+n.overflowY)}function Ve(e){for(ke(e)&&(e=e.parentElement);e&&!ke(e);)e=e.parentElement;return e||document.scrollingElement||document.documentElement}var St=new Set(["checkbox","radio","range","color","file","image","button","submit","reset"]),se=0,Ee;function je(e={}){let{isDisabled:n}=e;Tt(()=>{if(!n)return se++,se===1&&(Se()?Ee=xt():Ee=Rt()),()=>{se--,se===0&&Ee()}},[n])}function Rt(){return De(ue(document.documentElement,"paddingRight",`${window.innerWidth-document.documentElement.clientWidth}px`),ue(document.documentElement,"overflow","hidden"))}function xt(){let e,n=0,t=c=>{e=Ve(c.target),!(e===document.documentElement&&e===document.body)&&(n=c.changedTouches[0].pageY)},r=c=>{if(!e||e===document.documentElement||e===document.body){c.preventDefault();return}let o=c.changedTouches[0].pageY,C=e.scrollTop,x=e.scrollHeight-e.clientHeight;x!==0&&((C<=0&&o>n||C>=x&&o<n)&&c.preventDefault(),n=o)},l=c=>{let o=c.target;Z(o)&&o!==document.activeElement&&(c.preventDefault(),o.style.transform="translateY(-2000px)",o.focus(),requestAnimationFrame(()=>{o.style.transform=""}))},a=c=>{let o=c.target;Z(o)&&(o.style.transform="translateY(-2000px)",requestAnimationFrame(()=>{o.style.transform="",ye&&(ye.height<window.innerHeight?requestAnimationFrame(()=>{Fe(o)}):ye.addEventListener("resize",()=>Fe(o),{once:!0}))}))},g=()=>{window.scrollTo(0,0)},i=window.pageXOffset,y=window.pageYOffset,D=De(ue(document.documentElement,"paddingRight",`${window.innerWidth-document.documentElement.clientWidth}px`),ue(document.documentElement,"overflow","hidden"));window.scrollTo(0,0);let H=De(Q(document,"touchstart",t,{passive:!1,capture:!0}),Q(document,"touchmove",r,{passive:!1,capture:!0}),Q(document,"touchend",l,{passive:!1,capture:!0}),Q(document,"focus",a,!0),Q(window,"scroll",g));return()=>{D(),H(),window.scrollTo(i,y)}}function ue(e,n,t){let r=e.style[n];return e.style[n]=t,()=>{e.style[n]=r}}function Q(e,n,t,r){return e.addEventListener(n,t,r),()=>{e.removeEventListener(n,t,r)}}function Fe(e){let n=document.scrollingElement||document.documentElement;for(;e&&e!==n;){let t=Ve(e);if(t!==document.documentElement&&t!==document.body&&t!==e){let r=t.getBoundingClientRect().top,l=e.getBoundingClientRect().top,a=e.getBoundingClientRect().bottom,g=t.getBoundingClientRect().bottom;a>g&&(t.scrollTop+=l-r)}e=t.parentElement}}function Z(e){return e instanceof HTMLInputElement&&!St.has(e.type)||e instanceof HTMLTextAreaElement||e instanceof HTMLElement&&e.isContentEditable}var We=W(require("react"));function Mt(e,n){typeof e=="function"?e(n):e!=null&&(e.current=n)}function Ht(...e){return n=>e.forEach(t=>Mt(t,n))}function xe(...e){return We.useCallback(Ht(...e),e)}var fe=W(require("react")),F=null;function Ue({isOpen:e,modal:n,nested:t}){let r=fe.default.useRef(0);function l(){if(F===null){F={position:document.body.style.position,top:document.body.style.top,left:document.body.style.left,height:document.body.style.height};let{scrollX:g,innerHeight:i}=window;document.body.style.setProperty("position","fixed","important"),document.body.style.top=`${-r.current}px`,document.body.style.left=`${-g}px`,document.body.style.right="0px",document.body.style.height="auto",setTimeout(()=>requestAnimationFrame(()=>{let y=i-window.innerHeight;y&&r.current>=i&&(document.body.style.top=`${-(r.current+y)}px`)}),300)}}function a(){if(F!==null){let g=-parseInt(document.body.style.top,10),i=-parseInt(document.body.style.left,10);document.body.style.position=F.position,document.body.style.top=F.top,document.body.style.left=F.left,document.body.style.height=F.height,document.body.style.right="unset",requestAnimationFrame(()=>{window.scrollTo(i,g)}),F=null}}fe.default.useEffect(()=>{function g(){r.current=window.scrollY}return g(),window.addEventListener("scroll",g),()=>{window.removeEventListener("scroll",g)}},[]),fe.default.useEffect(()=>{t||(e?(l(),n||setTimeout(()=>{a()},500)):a())},[e])}var U=W(require("react"));var Ye=new WeakMap;function h(e,n,t=!1){if(!e||!(e instanceof HTMLElement)||!n)return;let r={};Object.entries(n).forEach(([l,a])=>{if(l.startsWith("--")){e.style.setProperty(l,a);return}r[l]=e.style[l],e.style[l]=a}),!t&&Ye.set(e,r)}function de(e,n){if(!e||!(e instanceof HTMLElement))return;let t=Ye.get(e);t&&(n?e.style[n]=t[n]:Object.entries(t).forEach(([r,l])=>{e.style[r]=l}))}function ee(e){let n=window.getComputedStyle(e),t=n.transform||n.webkitTransform||n.mozTransform,r=t.match(/^matrix3d\((.+)\)$/);return r?parseFloat(r[1].split(", ")[13]):(r=t.match(/^matrix\((.+)\)$/),r?parseFloat(r[1].split(", ")[5]):null)}function ze(e){return 8*(Math.log(e+1)-2)}var p={DURATION:.5,EASE:[.32,.72,0,1]},me=.4;var V=W(require("react"));function Be(e){let n=V.default.useRef(e);return V.default.useEffect(()=>{n.current=e}),V.default.useMemo(()=>(...t)=>{var r;return(r=n.current)==null?void 0:r.call(n,...t)},[])}function Ct({defaultProp:e,onChange:n}){let t=V.default.useState(e),[r]=t,l=V.default.useRef(r),a=Be(n);return V.default.useEffect(()=>{l.current!==r&&(a(r),l.current=r)},[r,l,a]),t}function _e({prop:e,defaultProp:n,onChange:t=()=>{}}){let[r,l]=Ct({defaultProp:n,onChange:t}),a=e!==void 0,g=a?e:r,i=Be(t),y=V.default.useCallback(D=>{if(a){let c=typeof D=="function"?D(e):D;c!==e&&i(c)}else l(D)},[a,e,l,i]);return[g,y]}function qe({activeSnapPointProp:e,setActiveSnapPointProp:n,snapPoints:t,drawerRef:r,overlayRef:l,fadeFromIndex:a,onSnapPointChange:g}){let[i,y]=_e({prop:e,defaultProp:t==null?void 0:t[0],onChange:n}),D=U.default.useMemo(()=>i===(t==null?void 0:t[t.length-1]),[t,i]),H=t&&t.length>0&&a&&t[a]===i||!t,c=U.default.useMemo(()=>{var s;return(s=t==null?void 0:t.findIndex(b=>b===i))!=null?s:null},[t,i]),o=U.default.useMemo(()=>{var s;return(s=t==null?void 0:t.map(b=>{let T=typeof window!="undefined",M=typeof b=="string",O=0;M&&(O=parseInt(b,10));let N=M?O:T?b*window.innerHeight:0;return T?window.innerHeight-N:N}))!=null?s:[]},[t]),C=U.default.useMemo(()=>c!==null?o==null?void 0:o[c]:null,[o,c]),x=U.default.useCallback(s=>{var T;let b=(T=o==null?void 0:o.findIndex(M=>M===s))!=null?T:null;g(b),h(r.current,{transition:`transform ${p.DURATION}s cubic-bezier(${p.EASE.join(",")})`,transform:`translate3d(0, ${s}px, 0)`}),o&&b!==o.length-1&&b!==a?h(l.current,{transition:`opacity ${p.DURATION}s cubic-bezier(${p.EASE.join(",")})`,opacity:"0"}):h(l.current,{transition:`opacity ${p.DURATION}s cubic-bezier(${p.EASE.join(",")})`,opacity:"1"}),y(b!==null?t==null?void 0:t[b]:null)},[r,t,o,a,l,y]);U.default.useEffect(()=>{var s;if(e){let b=(s=t==null?void 0:t.findIndex(T=>T===e))!=null?s:null;o&&b&&typeof o[b]=="number"&&x(o[b])}},[e,t,o,x]);function _({draggedDistance:s,closeDrawer:b,velocity:T}){if(a===void 0)return;let M=C-s,O=c===a-1,N=c===0;if(O&&h(l.current,{transition:`opacity ${p.DURATION}s cubic-bezier(${p.EASE.join(",")})`}),T>2&&s<0){b();return}if(T>2&&s>0&&o&&t){x(o[t.length-1]);return}let P=o==null?void 0:o.reduce((L,q)=>typeof L!="number"||typeof q!="number"?L:Math.abs(q-M)<Math.abs(L-M)?q:L);if(T>me&&Math.abs(s)<window.innerHeight*.4){let L=s>0?1:-1;if(L>0&&D){x(o[t.length-1]);return}if(N&&L<0&&b(),c===null)return;x(o[c+L]);return}x(P)}function $({draggedDistance:s}){if(C===null)return;let b=C-s;h(r.current,{transform:`translate3d(0, ${b}px, 0)`})}function j(s,b){if(!t||typeof c!="number"||!o||a===void 0)return null;let T=c===a-1;if(c>=a&&b)return 0;if(T&&!b)return 1;if(!H&&!T)return null;let O=T?c+1:c-1,N=T?o[O]-o[O-1]:o[O+1]-o[O],P=s/Math.abs(N);return T?1-P:P}return{isLastSnapPoint:D,activeSnapPoint:i,shouldFade:H,getPercentageDragged:j,setActiveSnapPoint:y,activeSnapPointIndex:c,onRelease:_,onDrag:$,snapPointsOffset:o}}var Ot=.25,Lt=500,Ke=8,Y=16,Xe=26;function Je({open:e,onOpenChange:n,children:t,shouldScaleBackground:r,onDrag:l,onRelease:a,experimentalSafariThemeAnimation:g,snapPoints:i,nested:y,closeThreshold:D=Ot,scrollLockTimeout:H=Lt,dismissible:c=!0,fadeFromIndex:o=i&&i.length-1,activeSnapPoint:C,setActiveSnapPoint:x,fixed:_,modal:$=!0,onClose:j}){var Ne;let[s=!1,b]=m.default.useState(!1),[T,M]=m.default.useState(!1),[O,N]=m.default.useState(!1),[P,L]=m.default.useState(!1),[q,Me]=m.default.useState(!1),k=m.default.useRef(null),te=m.default.useRef(null),pe=m.default.useRef(null),He=m.default.useRef(null),K=m.default.useRef(null),X=m.default.useRef(!1),ge=m.default.useRef(null),be=m.default.useRef(0),z=m.default.useRef(!1),Ce=m.default.useRef(0),f=m.default.useRef(null),Oe=m.default.useRef(((Ne=f.current)==null?void 0:Ne.getBoundingClientRect().height)||0),{onDrag:et,onRelease:ne}=(void 0)(f,k,T,g),tt=(0,m.useCallback)(u=>{i&&u===J.length-1&&(te.current=new Date)},[]),{activeSnapPoint:nt,activeSnapPointIndex:G,setActiveSnapPoint:Le,onRelease:rt,snapPointsOffset:J,onDrag:ot,shouldFade:Ae,getPercentageDragged:it}=qe({snapPoints:i,activeSnapPointProp:C,setActiveSnapPointProp:x,drawerRef:f,fadeFromIndex:o,overlayRef:k,onSnapPointChange:tt});je({isDisabled:!s||P||!$||q}),Ue({isOpen:s,modal:$,nested:y});function re(){return(window.innerWidth-Xe)/window.innerWidth}function at(u){var d;!c&&!i||f.current&&!f.current.contains(u.target)||(Oe.current=((d=f.current)==null?void 0:d.getBoundingClientRect().height)||0,L(!0),pe.current=new Date,Se()&&window.addEventListener("touchend",()=>X.current=!1,{once:!0}),u.target.setPointerCapture(u.pointerId),be.current=u.clientY)}function Ie(u,d){var A;let v=u,R=new Date,E=(A=window.getSelection())==null?void 0:A.toString(),w=f.current?ee(f.current):null;if(te.current&&R.getTime()-te.current.getTime()<500)return!1;if(w>0)return!0;if(E&&E.length>0)return!1;if(K.current&&R.getTime()-K.current.getTime()<H&&w===0)return K.current=new Date,!1;for(;v;){if(v.scrollHeight>v.clientHeight){if(v.getAttribute("role")==="dialog")return!0;if(d&&v!==document.body&&!w&&w>=0)return K.current=new Date,!1;if(v.scrollTop!==0)return K.current=new Date,!1}v=v.parentNode}return!0}function lt(u){if(P){let d=be.current-u.clientY,v=d>0;if(i&&G===0&&!c||!X.current&&!Ie(u.target,v))return;if(X.current=!0,h(f.current,{transition:"none"}),h(k.current,{transition:"none"}),i&&ot({draggedDistance:d}),d>0&&!i){let I=ze(d);h(f.current,{transform:`translate3d(0, ${Math.min(I*-1,0)}px, 0)`});return}let R=Math.abs(d),E=document.querySelector("[vaul-drawer-wrapper]"),w=R/Oe.current,A=it(R,v);A!==null&&(w=A);let ve=1-w;if((Ae||o&&G===o-1)&&(et(w),l==null||l(u,w),g||h(k.current,{opacity:`${ve}`,transition:"none"},!0)),E&&k.current&&r){let I=Math.min(re()+w*(1-re()),1),ie=8-w*8,dt=Math.max(0,14-w*14);h(E,{borderRadius:`${ie}px`,transform:`scale(${I}) translate3d(0, ${dt}px, 0)`,transition:"none"},!0)}i||h(f.current,{transform:`translate3d(0, ${R}px, 0)`})}}m.default.useEffect(()=>{if(document.querySelector("[vaul-drawer-wrapper]"))return()=>oe(!1)},[]),m.default.useEffect(()=>{var d;function u(){var R;if(!f.current)return;let v=document.activeElement;if(Z(v)||z.current){let E=((R=window.visualViewport)==null?void 0:R.height)||0,w=window.innerHeight-E,A=f.current.getBoundingClientRect().height||0,ve=f.current.getBoundingClientRect().top;if(Math.abs(Ce.current-w)>60&&(z.current=!z.current),i&&i.length>0&&J&&G){let I=J[G]||0;w+=I}if(Ce.current=w,A>E||z.current){let I=f.current.getBoundingClientRect().height,ie=I;I>E&&(ie=E-Xe),_?f.current.style.height=`${I-Math.max(w,0)}px`:f.current.style.height=`${Math.max(ie,E-ve)}px`}else f.current.style.height="initial";i&&i.length>0&&!z.current?f.current.style.bottom="0px":f.current.style.bottom=`${Math.max(w,0)}px`}}return(d=window.visualViewport)==null||d.addEventListener("resize",u),()=>{var v;return(v=window.visualViewport)==null?void 0:v.removeEventListener("resize",u)}},[G,i,J]);function B(){f.current&&(j==null||j(),f.current&&(h(f.current,{transform:"translate3d(0, 100%, 0)",transition:`transform ${p.DURATION}s cubic-bezier(${p.EASE.join(",")})`}),g||h(k.current,{opacity:"0",transition:`opacity ${p.DURATION}s cubic-bezier(${p.EASE.join(",")})`}),oe(!1)),M(!1),setTimeout(()=>{b(!1)},300),setTimeout(()=>{i&&Le(i[0])},500))}m.default.useEffect(()=>{if(!s&&r){let u=setTimeout(()=>{de(document.body)},200);return()=>clearTimeout(u)}},[s,r]),m.default.useEffect(()=>{e?b(!0):B()},[e]),m.default.useEffect(()=>{O&&(n==null||n(s))},[s]),m.default.useEffect(()=>{N(!0)},[]);function $e(){if(!f.current)return;let u=document.querySelector("[vaul-drawer-wrapper]"),d=ee(f.current);h(f.current,{transform:"translate3d(0, 0, 0)",transition:`transform ${p.DURATION}s cubic-bezier(${p.EASE.join(",")})`}),g||h(k.current,{transition:`opacity ${p.DURATION}s cubic-bezier(${p.EASE.join(",")})`,opacity:"1"}),r&&d&&d>0&&s&&h(u,{borderRadius:`${Ke}px`,overflow:"hidden",transform:`scale(${re()}) translate3d(0, calc(env(safe-area-inset-top) + 14px), 0)`,transformOrigin:"top",transitionProperty:"transform, border-radius",transitionDuration:`${p.DURATION}s`,transitionTimingFunction:`cubic-bezier(${p.EASE.join(",")})`},!0)}function st(u){if(!P||!f.current)return;X.current&&Z(u.target)&&u.target.blur(),X.current=!1,L(!1),He.current=new Date;let d=ee(f.current);if(!Ie(u.target,!1)||!d||Number.isNaN(d)||pe.current===null)return;let v=u.clientY,R=He.current.getTime()-pe.current.getTime(),E=be.current-v,w=Math.abs(E)/R;if(w>.05&&(Me(!0),setTimeout(()=>{Me(!1)},200)),i){rt({draggedDistance:E,closeDrawer:B,velocity:w});return}if(E>0){$e(),a==null||a(u,!0),ne(!0);return}if(w>me){B(),a==null||a(u,!1),ne(!1);return}let A=Math.min(f.current.getBoundingClientRect().height||0,window.innerHeight);if(d>=A*D){B(),a==null||a(u,!1),ne(!1);return}a==null||a(u,!0),ne(!0),$e()}m.default.useEffect(()=>{s&&(te.current=new Date,M(!0),oe(!0))},[s]);function oe(u){let d=document.querySelector("[vaul-drawer-wrapper]");!d||!r||(u?(h(document.body,{background:"black"},!0),h(d,{borderRadius:`${Ke}px`,overflow:"hidden",transform:`scale(${re()}) translate3d(0, calc(env(safe-area-inset-top) + 14px), 0)`,transformOrigin:"top",transitionProperty:"transform, border-radius",transitionDuration:`${p.DURATION}s`,transitionTimingFunction:`cubic-bezier(${p.EASE.join(",")})`})):(de(d,"transform"),de(d,"borderRadius"),h(d,{transitionProperty:"transform, border-radius",transitionDuration:`${p.DURATION}s`,transitionTimingFunction:`cubic-bezier(${p.EASE.join(",")})`})))}function ut(u){let d=u?(window.innerWidth-Y)/window.innerWidth:1,v=u?-Y:0;ge.current&&window.clearTimeout(ge.current),h(f.current,{transition:`transform ${p.DURATION}s cubic-bezier(${p.EASE.join(",")})`,transform:`scale(${d}) translate3d(0, ${v}px, 0)`}),!u&&f.current&&(ge.current=setTimeout(()=>{h(f.current,{transition:"none",transform:`translate3d(0, ${ee(f.current)}px, 0)`})},500))}function ct(u,d){if(d<0)return;let v=(window.innerWidth-Y)/window.innerWidth,R=v+d*(1-v),E=-Y+d*Y;h(f.current,{transform:`scale(${R}) translate3d(0, ${E}px, 0)`,transition:"none"})}function ft(u,d){let v=d?(window.innerWidth-Y)/window.innerWidth:1,R=d?-Y:0;d&&h(f.current,{transition:`transform ${p.DURATION}s cubic-bezier(${p.EASE.join(",")})`,transform:`scale(${v}) translate3d(0, ${R}px, 0)`})}return m.default.createElement(S.Root,{modal:$,onOpenChange:u=>{u?b(u):B()},open:s},m.default.createElement(we.Provider,{value:{visible:T,activeSnapPoint:nt,snapPoints:i,setActiveSnapPoint:Le,drawerRef:f,overlayRef:k,scaleBackground:oe,onPress:at,setVisible:M,onRelease:st,onDrag:lt,dismissible:c,isOpen:s,shouldFade:Ae,closeDrawer:B,onNestedDrag:ct,onNestedOpenChange:ut,onNestedRelease:ft,keyboardIsOpen:z,modal:$,snapPointsOffset:J,experimentalSafariThemeAnimation:g}},t))}var Qe=m.default.forwardRef(function({children:e,style:n,...t},r){let{overlayRef:l,snapPoints:a,onRelease:g,experimentalSafariThemeAnimation:i,shouldFade:y,isOpen:D,visible:H}=le(),c=xe(r,l),o=a&&a.length>0;return m.default.createElement(S.Overlay,{onMouseUp:g,ref:c,"vaul-drawer-visible":H&&!i?"true":"false","vaul-overlay":"","vaul-snap-points":D&&o?"true":"false","vaul-snap-points-overlay":D&&y?"true":"false","vaul-theme-transition":i?"true":"false",...t})});Qe.displayName="Drawer.Overlay";var Ze=m.default.forwardRef(function({children:e,onOpenAutoFocus:n,onPointerDownOutside:t,onAnimationEnd:r,style:l,...a},g){let{drawerRef:i,onPress:y,onRelease:D,onDrag:H,dismissible:c,keyboardIsOpen:o,snapPointsOffset:C,visible:x,closeDrawer:_,modal:$}=le(),j=xe(g,i);return m.default.createElement(S.Content,{onOpenAutoFocus:s=>{n?n(s):(s.preventDefault(),i.current.focus())},onPointerDown:y,onPointerDownOutside:s=>{if(!$){s.preventDefault();return}o.current&&(o.current=!1),s.preventDefault(),c&&(_(),t==null||t(s))},onPointerMove:H,onPointerUp:D,ref:j,style:C?{"--snap-point-height":`${C[0]}px`,...l}:l,...a,"vaul-drawer":"","vaul-drawer-visible":x?"true":"false"},e)});Ze.displayName="Drawer.Content";function At({children:e,onDrag:n,onOpenChange:t,...r}){let{onNestedDrag:l,onNestedOpenChange:a,onNestedRelease:g}=le();if(!l)throw new Error("Drawer.NestedRoot must be placed in another drawer");return m.default.createElement(Je,{nested:!0,onClose:()=>{a(!1)},onDrag:(i,y)=>{l(i,y),n==null||n(i,y)},onOpenChange:i=>{i&&a(i),t==null||t(i)},onRelease:g,...r},e)}var It={Root:Je,NestedRoot:At,Content:Ze,Overlay:Qe,Trigger:S.Trigger,Portal:S.Portal,Close:S.Close,Title:S.Title,Description:S.Description};0&&(module.exports={Drawer});
//# sourceMappingURL=index.js.map
{
"name": "vaul",
"version": "0.6.5",
"version": "0.6.6",
"description": "Drawer component for React.",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -53,3 +53,3 @@ https://github.com/emilkowalski/vaul/assets/36730035/fdf8c5e8-ade8-433b-8bb0-4ce10e722516

`closeThreshold`: Number between 0 and 1 that determines when the drawer should be closed. Example: ` closeThreshold` of 0.5 would close the drawer if the user swiped for 50% of the height of the drawer or more.
`closeThreshold`: Number between 0 and 1 that determines when the drawer should be closed. Example: threshold of 0.5 would close the drawer if the user swiped for 50% of the height of the drawer or more.

@@ -56,0 +56,0 @@ `scrollLockTimeout`: Duration for which the drawer is not draggable after scrolling content inside of the drawer. Defaults to 500ms

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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