Comparing version 0.4.1 to 0.4.5
@@ -5,12 +5,12 @@ import * as DialogPrimitive from '@radix-ui/react-dialog'; | ||
type WithFadeFromProps = { | ||
snapPoints: number[]; | ||
snapPoints: (number | string)[]; | ||
fadeFromIndex: number; | ||
}; | ||
type WithoutFadeFromProps = { | ||
snapPoints?: number[]; | ||
snapPoints?: (number | string)[]; | ||
fadeFromIndex?: never; | ||
}; | ||
type DialogProps = { | ||
activeSnapPoint?: number | null; | ||
setActiveSnapPoint?(snapPoint: number | null): void; | ||
activeSnapPoint?: number | string | null; | ||
setActiveSnapPoint?(snapPoint: number | string | null): void; | ||
children?: React.ReactNode; | ||
@@ -17,0 +17,0 @@ open?: boolean; |
"use client" | ||
"use client";var ht=Object.create;var ae=Object.defineProperty;var yt=Object.getOwnPropertyDescriptor;var wt=Object.getOwnPropertyNames;var Tt=Object.getPrototypeOf,Et=Object.prototype.hasOwnProperty;var St=(e,n)=>{for(var t in n)ae(e,t,{get:n[t],enumerable:!0})},Le=(e,n,t,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of wt(n))!Et.call(e,r)&&r!==t&&ae(e,r,{get:()=>n[r],enumerable:!(o=yt(n,r))||o.enumerable});return e};var z=(e,n,t)=>(t=e!=null?ht(Tt(e)):{},Le(n||!e||!e.__esModule?ae(t,"default",{value:e,enumerable:!0}):t,e)),Rt=e=>Le(ae({},"__esModule",{value:!0}),e);var Xt={};St(Xt,{Drawer:()=>Zt});module.exports=Rt(Xt);var A=z(require("@radix-ui/react-dialog"));var B=z(require("react"));function $e(e){let n=B.default.useRef(e);return B.default.useEffect(()=>{n.current=e}),B.default.useMemo(()=>(...t)=>{var o;return(o=n.current)==null?void 0:o.call(n,...t)},[])}function Dt({defaultProp:e,onChange:n}){let t=B.default.useState(e),[o]=t,r=B.default.useRef(o),i=$e(n);return B.default.useEffect(()=>{r.current!==o&&(i(o),r.current=o)},[o,r,i]),t}function le({prop:e,defaultProp:n,onChange:t=()=>{}}){let[o,r]=Dt({defaultProp:n,onChange:t}),i=e!==void 0,a=i?e:o,d=$e(t),c=B.default.useCallback(b=>{if(i){let f=typeof b=="function"?b(e):b;f!==e&&d(f)}else r(b)},[i,e,r,d]);return[a,c]}var Ee=z(require("react")),Se=Ee.default.createContext(void 0),ue=()=>Ee.default.useContext(Se);var R=z(require("react"));function Re(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))}Re(`[vaul-drawer]{will-change:transform;touch-action:none;animation:show-dialog .5s cubic-bezier(.32,.72,0,1);transform:translateY(var(--snap-point-height, 0))}[vaul-drawer]:after{content:"";position:absolute;top:100%;background:inherit;background-color:inherit;left:0;right:0;height:200%}[vaul-drawer][data-state=closed]{animation:hide-dialog .5s cubic-bezier(.32,.72,0,1) forwards}[vaul-drawer][vaul-closed-by-dragging=true]{animation:fake-animation .5s cubic-bezier(.32,.72,0,1) forwards}[vaul-overlay]:not([vaul-snap-points="true"]){animation:show-overlay .5s cubic-bezier(.32,.72,0,1)}[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]{opacity:1}[vaul-overlay][vaul-theme-transition=true]{animation:show-theme-overlay .5s cubic-bezier(.32,.72,0,1)}[vaul-overlay][data-state=closed]:not([vaul-snap-points="true"]),[vaul-overlay][data-state=closed][vaul-snap-points-overlay=true]{animation:hide-overlay .5s cubic-bezier(.32,.72,0,1)}[vaul-overlay][vaul-theme-transition=true][data-state=closed]{animation:hide-theme-overlay .5s cubic-bezier(.32,.72,0,1) forwards}@keyframes fake-animation{}@keyframes show-dialog{0%{transform:translateY(100%)}to{transform:translateY(var(--snap-point-height, 0))}}@keyframes hide-dialog{0%{transform:translateY(var(--hide-from, 0))}to{transform:translateY(var(--hide-to, 100%))}}@keyframes show-overlay{0%{opacity:0}to{opacity:1}}@keyframes hide-overlay{0%{opacity:var(--opacity-from, 1)}to{opacity:0}}@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 me=require("react"),Mt=typeof window!="undefined"?me.useLayoutEffect:me.useEffect;function Ce(...e){return(...n)=>{for(let t of e)typeof t=="function"&&t(...n)}}function Ct(){return xe(/^Mac/)}function xt(){return xe(/^iPhone/)}function Ye(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}function Ot(){return xe(/^iPad/)||Ct()&&navigator.maxTouchPoints>1}function Q(){return xt()||Ot()}function xe(e){return typeof window!="undefined"&&window.navigator!=null?e.test(window.navigator.platform):void 0}var De=typeof document!="undefined"&&window.visualViewport;function Pe(e){let n=window.getComputedStyle(e);return/(auto|scroll)/.test(n.overflow+n.overflowX+n.overflowY)}function ke(e){for(Pe(e)&&(e=e.parentElement);e&&!Pe(e);)e=e.parentElement;return e||document.scrollingElement||document.documentElement}var It=new Set(["checkbox","radio","range","color","file","image","button","submit","reset"]),se=0,Me;function Ve(e={}){let{isDisabled:n}=e;Mt(()=>{if(!n)return se++,se===1&&(Q()?Me=Ht():Me=At()),()=>{se--,se===0&&Me()}},[n])}function At(){return Ce(ce(document.documentElement,"paddingRight",`${window.innerWidth-document.documentElement.clientWidth}px`),ce(document.documentElement,"overflow","hidden"))}function Ht(){let e,n=0,t=f=>{e=ke(f.target),!(e===document.documentElement&&e===document.body)&&(n=f.changedTouches[0].pageY)},o=f=>{if(!e||e===document.documentElement||e===document.body){f.preventDefault();return}let l=f.changedTouches[0].pageY,x=e.scrollTop,D=e.scrollHeight-e.clientHeight;D!==0&&((x<=0&&l>n||x>=D&&l<n)&&f.preventDefault(),n=l)},r=f=>{let l=f.target;fe(l)&&l!==document.activeElement&&(f.preventDefault(),l.style.transform="translateY(-2000px)",l.focus(),requestAnimationFrame(()=>{l.style.transform=""}))},i=f=>{let l=f.target;fe(l)&&(l.style.transform="translateY(-2000px)",requestAnimationFrame(()=>{l.style.transform="",De&&(De.height<window.innerHeight?requestAnimationFrame(()=>{Fe(l)}):De.addEventListener("resize",()=>Fe(l),{once:!0}))}))},a=()=>{window.scrollTo(0,0)},d=window.pageXOffset,c=window.pageYOffset,b=Ce(ce(document.documentElement,"paddingRight",`${window.innerWidth-document.documentElement.clientWidth}px`),ce(document.documentElement,"overflow","hidden"));window.scrollTo(0,0);let M=Ce(J(document,"touchstart",t,{passive:!1,capture:!0}),J(document,"touchmove",o,{passive:!1,capture:!0}),J(document,"touchend",r,{passive:!1,capture:!0}),J(document,"focus",i,!0),J(window,"scroll",a));return()=>{b(),M(),window.scrollTo(d,c)}}function ce(e,n,t){let o=e.style[n];return e.style[n]=t,()=>{e.style[n]=o}}function J(e,n,t,o){return e.addEventListener(n,t,o),()=>{e.removeEventListener(n,t,o)}}function Fe(e){let n=document.scrollingElement||document.documentElement;for(;e&&e!==n;){let t=ke(e);if(t!==document.documentElement&&t!==document.body&&t!==e){let o=t.getBoundingClientRect().top,r=e.getBoundingClientRect().top,i=e.getBoundingClientRect().bottom,a=t.getBoundingClientRect().bottom;i>a&&(t.scrollTop+=r-o)}e=t.parentElement}}function fe(e){return e instanceof HTMLInputElement&&!It.has(e.type)||e instanceof HTMLTextAreaElement||e instanceof HTMLElement&&e.isContentEditable}var ze=z(require("react"));function Nt(e,n){typeof e=="function"?e(n):e!=null&&(e.current=n)}function Lt(...e){return n=>e.forEach(t=>Nt(t,n))}function Oe(...e){return ze.useCallback(Lt(...e),e)}var N=z(require("react"));var $t=4,Pt=.001,Ft=1e-7,Yt=10,Z=11,de=1/(Z-1),kt=typeof Float32Array=="function";function Be(e,n){return 1-3*n+3*e}function je(e,n){return 3*n-6*e}function We(e){return 3*e}function pe(e,n,t){return((Be(n,t)*e+je(n,t))*e+We(n))*e}function Ue(e,n,t){return 3*Be(n,t)*e*e+2*je(n,t)*e+We(n)}function Vt(e,n,t,o,r){var i,a,d=0;do a=n+(t-n)/2,i=pe(a,o,r)-e,i>0?t=a:n=a;while(Math.abs(i)>Ft&&++d<Yt);return a}function zt(e,n,t,o){for(var r=0;r<$t;++r){var i=Ue(n,t,o);if(i===0)return n;var a=pe(n,t,o)-e;n-=a/i}return n}function Bt(e){return e}function _e(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 Bt;for(var r=kt?new Float32Array(Z):new Array(Z),i=0;i<Z;++i)r[i]=pe(i*de,e,t);function a(d){for(var c=0,b=1,M=Z-1;b!==M&&r[b]<=d;++b)c+=de;--b;var f=(d-r[b])/(r[b+1]-r[b]),l=c+f*de,x=Ue(l,e,t);return x>=Pt?zt(d,l,e,t):x===0?l:Vt(d,c,c+de,e,t)}return function(c){return c===0||c===1?c:pe(a(c),n,o)}}var jt=_e(.32,.72,0,1);function Wt(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 Ut(e,n){let[t,o,r,i]=Wt(e);return[Math.round(i*t+(1-i)*Number(n[0])),Math.round(i*o+(1-i)*Number(n[1])),Math.round(i*r+(1-i)*Number(n[2]))]}function _t(e){return jt(e)}function qt(e,n,t,o){arguments.length<3&&(t=.5);let r=e.slice();for(let i=0;i<3;i++){let a=n[i]-e[i],d=o?e[i]+t*a:e[i]+_t(t)*a;r[i]=Math.round(d),r[i]<0&&(r[i]=0),r[i]>255&&(r[i]=255)}return r}function X(e,n,t,o){let r=1/(t-1),i=[];for(let a=0;a<t;a++)i.push(qt(e,n,r*a,!!o));return i}function qe(e,n,t,o){let[r,i]=N.default.useState([255,255,255]),[a,d]=N.default.useState([153,153,153]),[c,b]=N.default.useState(!1),[M,f]=N.default.useState(null),[l,x]=N.default.useState(null),D=N.default.useMemo(()=>Q()&&Ye()&&o,[o]),L=N.default.useMemo(()=>r&&a?X(r,a,50):null,[a,r]),O=N.default.useMemo(()=>r&&a?X(a,r,50):null,[a,r]),Y=N.default.useMemo(()=>r&&a?X(a,r,50,!0):null,[a,r]);N.default.useEffect(()=>{if(!D)return;let s=getComputedStyle(document.documentElement),S=s.getPropertyValue("--vaul-overlay-background").split(",").map(H=>Number(H)),C=s.getPropertyValue("--vaul-overlay-background-end"),T=Ut(C,S);i(S),d(T)},[D]),N.default.useEffect(()=>{if(D&&!M){let s=document.querySelector('meta[name="theme-color"]');s?f(s.getAttribute("content")):(s=document.createElement("meta"),s.name="theme-color",document.getElementsByTagName("head")[0].appendChild(s)),x(s)}},[M,D]);let m=(0,N.useCallback)(s=>{let S,C;function T(H){S||(S=H);let j=H-S,k=Math.floor(j/10);if(n.current&&s&&!c){if(e.current.style.transform==="translateY(0px)"&&e.current.getAttribute("vaul-clicked-outside")!=="true")return;if(k<s.length){let te=s[k];l==null||l.setAttribute("content",`rgb(${te.join(",")})`),k===s.length-1&&M&&!t&&(l==null||l.setAttribute("content",M)),C=requestAnimationFrame(T)}}}return C=requestAnimationFrame(T),C},[e,t,l,c,M,n]);N.default.useEffect(()=>{if(!D||!L||!O)return;let s=m(t?L:O);return t&&b(!1),()=>{s&&cancelAnimationFrame(s)}},[t,D,m,L,O]);function w(s){let S=document.querySelector('meta[name="theme-color"]');if(!D||!S||!Y)return;let C=Math.floor(s*Y.length);C=Math.max(0,Math.min(Y.length-1,C));let T=Y[C];S.setAttribute("content",`rgb(${T.join(",")})`)}function E(s){let S=document.querySelector('meta[name="theme-color"]');if(!S||!D)return;b(!0);let C=S.getAttribute("content").match(/\d+/g).map(Number),T=X(C,a,50);!s&&r&&(T=X(C,r,50)),m(T)}return{onDrag:w,onRelease:E}}var ve=z(require("react"));var W=null;function Ge({isOpen:e,modal:n}){let t=ve.default.useRef(0);function o(){if(W===null){W={position:document.body.style.position,top:document.body.style.top,left:document.body.style.left};let{scrollX:i,innerHeight:a}=window;document.body.style.setProperty("position","fixed","important"),document.body.style.top=`${-t.current}px`,document.body.style.left=`${-i}px`,document.body.style.right="0px",setTimeout(()=>requestAnimationFrame(()=>{let d=a-window.innerHeight;d&&t.current>=a&&(document.body.style.top=`${-(t.current+d)}px`)}),300)}}function r(){if(W!==null){let i=-parseInt(document.body.style.top,10),a=-parseInt(document.body.style.left,10);document.body.style.position=W.position,document.body.style.top=W.top,document.body.style.left=W.left,document.body.style.right="unset",requestAnimationFrame(()=>{window.scrollTo(a,i)}),W=null}}ve.default.useEffect(()=>{function i(){t.current=window.scrollY}return i(),window.addEventListener("scroll",i),()=>{window.removeEventListener("scroll",i)}},[]),ve.default.useEffect(()=>{Q()&&(e?(o(),n||setTimeout(()=>{r()},500)):r())},[e])}var K=z(require("react"));var Ke=new WeakMap;function Je(e){let n=e.getBoundingClientRect();return window.visualViewport?n.top>=0&&n.left>=0&&n.bottom<=window.visualViewport.height+40&&n.right<=window.visualViewport.width:!1}function h(e,n,t=!1){if(!e||!(e instanceof HTMLElement)||!n)return;let o={};Object.entries(n).forEach(([r,i])=>{if(r.startsWith("--")){e.style.setProperty(r,i);return}o[r]=e.style[r],e.style[r]=i}),!t&&Ke.set(e,o)}function be(e,n){if(!e||!(e instanceof HTMLElement))return;let t=Ke.get(e);if(!t){e.style={};return}n?e.style[n]=t[n]:Object.entries(t).forEach(([o,r])=>{e.style[o]=r})}function ee(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 ge(e){return 8*(Math.log(e+1)-2)}var y={DURATION:.5,EASE:[.32,.72,0,1]},he=.4;function Qe({activeSnapPointProp:e,setActiveSnapPointProp:n,snapPoints:t,drawerRef:o,overlayRef:r,fadeFromIndex:i}){let[a,d]=le({prop:e,defaultProp:t==null?void 0:t[0],onChange:n}),c=typeof window!="undefined",b=K.default.useMemo(()=>a===(t==null?void 0:t[t.length-1]),[t,a]),M=t&&t.length>0&&t[i]===a||!t,f=K.default.useMemo(()=>{var m;return(m=t==null?void 0:t.findIndex(w=>w===a))!=null?m:null},[t,a]),l=K.default.useMemo(()=>{var m;return(m=t==null?void 0:t.map(w=>c&&window.innerHeight-w*window.innerHeight))!=null?m:null},[t]),x=K.default.useMemo(()=>{var m;return(m=l==null?void 0:l[f])!=null?m:null},[l,a]);function D(m){var E,s;let w=(E=l==null?void 0:l.findIndex(S=>S===m))!=null?E:null;h(o.current,{transition:`transform ${y.DURATION}s cubic-bezier(${y.EASE.join(",")})`,transform:`translateY(${m}px)`}),w!==l.length-1&&w!==i?h(r.current,{transition:`opacity ${y.DURATION}s cubic-bezier(${y.EASE.join(",")})`,opacity:"0"}):h(r.current,{transition:`opacity ${y.DURATION}s cubic-bezier(${y.EASE.join(",")})`,opacity:"1"}),d((s=t==null?void 0:t[w])!=null?s:null)}K.default.useEffect(()=>{var m;if(e){let w=(m=t==null?void 0:t.findIndex(E=>E===e))!=null?m:null;D(l[w])}},[e]);function L({draggedDistance:m,closeDrawer:w,velocity:E}){let s=x-m,S=f===i-1,C=f===0;if(S&&h(r.current,{transition:`opacity ${y.DURATION}s cubic-bezier(${y.EASE.join(",")})`}),E>2&&m<0){w();return}if(E>2&&m>0){D(l[t.length-1]);return}let T=l==null?void 0:l.reduce((H,j)=>Math.abs(j-s)<Math.abs(H-s)?j:H);if(E>he&&Math.abs(m)<window.innerHeight*.4){let H=m>0?1:-1;if(H>0&&b)return;C&&H<0&&w(),D(l[f+H]);return}D(T)}function O({draggedDistance:m}){let w=x-m;if(b&&w<x){let E=ge(m);h(o.current,{transform:`translateY(${Math.min(x-E,x)}px)`});return}h(o.current,{transform:`translateY(${w}px)`})}function Y(m,w){if(!t)return null;let E=f===i-1;if(f>=i&&w)return 0;if(E&&!w)return 1;if(!M&&!E)return null;let S=E?f+1:f-1,C=E?l[S]-l[S-1]:l[S+1]-l[S],T=m/Math.abs(C);return E?1-T:T}return{isLastSnapPoint:b,activeSnapPoint:a,shouldFade:M,getPercentageDragged:Y,setActiveSnapPoint:d,activeSnapPointIndex:f,onRelease:L,onDrag:O,snapPointHeights:l}}var Gt=.25,Kt=500,Jt=501,Ze=8,U=16,Xe=26;function et({open:e,defaultOpen:n,onOpenChange:t,children:o,shouldScaleBackground:r,onDrag:i,onRelease:a,experimentalSafariThemeAnimation:d,snapPoints:c,closeThreshold:b=Gt,scrollLockTimeout:M=Kt,dismissible:f=!0,fadeFromIndex:l=(c==null?void 0:c.length)-1,activeSnapPoint:x,setActiveSnapPoint:D,modal:L=!0}){let[O=!1,Y]=le({prop:e,defaultProp:n,onChange:t}),[m,w]=R.default.useState(!1),[E,s]=R.default.useState(!0),[S,C]=R.default.useState(!1),T=R.default.useRef(null),H=R.default.useRef(null),j=R.default.useRef(null),k=R.default.useRef(null),te=R.default.useRef(null),ye=R.default.useRef(0),_=R.default.useRef(!1),Ie=R.default.useRef(0),p=R.default.useRef(null),{onDrag:rt,onRelease:ne}=qe(p,T,O,d),{activeSnapPoint:ot,activeSnapPointIndex:we,setActiveSnapPoint:it,onRelease:at,snapPointHeights:Ae,onDrag:lt,shouldFade:Te,getPercentageDragged:ut}=Qe({snapPoints:c,activeSnapPointProp:x,setActiveSnapPointProp:D,drawerRef:p,fadeFromIndex:l,overlayRef:T});Ve({isDisabled:!O||m||E||!L||S}),Ge({isOpen:O,modal:L});function re(){return(window.innerWidth-Xe)/window.innerWidth}function st(u){f&&(p.current&&!p.current.contains(u.target)||(w(!0),H.current=new Date,u.target.setPointerCapture(u.pointerId),ye.current=u.clientY))}function He(u,v){let g=u,$=new Date,P=window.getSelection().toString(),I=p.current?ee(p.current):null;if(P.length>0)return!1;if(k.current&&$.getTime()-k.current.getTime()<M&&I===0)return k.current=new Date,!1;for(;g;){if(g.scrollHeight>g.clientHeight){if(g.role==="dialog"||g.getAttribute("vaul-drawer"))return!0;if(g.scrollTop>0)return k.current=new Date,!1;if(v&&g!==document.body&&!I)return k.current=new Date,!1}g=g.parentNode}return!0}function ct(u){var v;if(m){let g=ye.current-u.clientY,$=g>0;if(!He(u.target,$))return;let P=((v=p.current)==null?void 0:v.getBoundingClientRect().height)||0;if(h(p.current,{transition:"none"}),h(T.current,{transition:"none"}),c&<({draggedDistance:g}),g>0&&!c){let G=ge(g);h(p.current,{transform:`translateY(${Math.min(G*-1,0)}px)`});return}let I=Math.abs(g),V=document.querySelector("[vaul-drawer-wrapper]"),F=I/P,ie=ut(I,$);ie!==null&&(F=ie);let q=1-F;if((Te||we===l-1)&&(rt(F),i==null||i(u,F),h(T.current,{opacity:`${q}`,transition:"none"},!0)),V&&T.current&&r){let G=Math.min(re()+F*(1-re()),1),bt=8-F*8,gt=Math.max(0,14-F*14);h(V,{borderRadius:`${bt}px`,transform:`scale(${G}) translateY(${gt}px)`,transition:"none"},!0)}c||h(p.current,{transform:`translateY(${I}px)`})}}R.default.useEffect(()=>{function u(){var g,$,P;if(!p.current)return;let v=document.activeElement;if(!Je(v)&&fe(v)||_.current){let I=window.visualViewport.height,V=window.innerHeight-I,F=((g=p.current)==null?void 0:g.getBoundingClientRect().height)||0,ie=($=p.current)==null?void 0:$.getBoundingClientRect().top;if(Math.abs(Ie.current-V)>60&&(_.current=!_.current),c&&c.length>0){let q=Ae[we];V+=q}if(Ie.current=V,F>I||_.current){let q=(P=p.current)==null?void 0:P.getBoundingClientRect().height,G=q;q>I&&(G=I-Xe),p.current.style.height=`${Math.max(G,I-ie)}px`}else p.current.style.height="initial";c&&c.length>0&&!_.current?p.current.style.bottom="0px":p.current.style.bottom=`${Math.max(V,0)}px`}}return window.visualViewport.addEventListener("resize",u),()=>window.visualViewport.removeEventListener("resize",u)},[we]);function oe(){var u;if(f&&(p.current.setAttribute("vaul-closed-by-dragging","true"),Y(!1),p.current)){h(p.current,{transform:"translateY(100%)",transition:`transform ${y.DURATION}s cubic-bezier(${y.EASE.join(",")})`});let v=((u=T.current)==null?void 0:u.style.opacity)||1;h(T.current,{"--opacity-from":`${Te?v:0}`})}}R.default.useEffect(()=>{if(!O&&r){let u=setTimeout(()=>{be(document.body)},200);return()=>clearTimeout(u)}},[O,r]);function Ne(){let u=document.querySelector("[vaul-drawer-wrapper]"),v=ee(p.current);h(p.current,{transform:"translateY(0px)",transition:`transform ${y.DURATION}s cubic-bezier(${y.EASE.join(",")})`}),h(T.current,{transition:`opacity ${y.DURATION}s cubic-bezier(${y.EASE.join(",")})`,opacity:"1"}),r&&v>0&&O&&h(u,{borderRadius:`${Ze}px`,overflow:"hidden",transform:`scale(${re()}) translateY(calc(env(safe-area-inset-top) + 14px))`,transformOrigin:"top",transitionProperty:"transform, border-radius",transitionDuration:`${y.DURATION}s`,transitionTimingFunction:`cubic-bezier(${y.EASE.join(",")})`},!0)}function ft(u){var F;if(!m)return;u.preventDefault(),w(!1),j.current=new Date;let v=ee(p.current);if(!He(u.target,!1)||!v||Number.isNaN(v)||H.current===null)return;let g=u.clientY,$=j.current.getTime()-H.current.getTime(),P=ye.current-g,I=Math.abs(P)/$;if(I>.05&&(C(!0),setTimeout(()=>{C(!1)},200)),c){at({draggedDistance:P,closeDrawer:oe,velocity:I});return}if(P>0){Ne(),a==null||a(u,!0),ne(!0);return}if(I>he){oe(),a==null||a(u,!1),ne(!1);return}let V=Math.min(((F=p.current)==null?void 0:F.getBoundingClientRect().height)||0,window.innerHeight);if(v>=V*b){oe(),a==null||a(u,!1),ne(!1);return}a==null||a(u,!0),ne(!0),Ne()}function mt(u){let v=document.querySelector("[vaul-drawer-wrapper]");!v||!r||(u.animationName==="show-dialog"?(h(document.body,{background:"black"},!0),h(v,{borderRadius:`${Ze}px`,overflow:"hidden",transform:`scale(${re()}) translateY(calc(env(safe-area-inset-top) + 14px))`,transformOrigin:"top",transitionProperty:"transform, border-radius",transitionDuration:`${y.DURATION}s`,transitionTimingFunction:`cubic-bezier(${y.EASE.join(",")})`})):(u.animationName==="hide-dialog"||u.animationName==="fake-animation")&&(be(v,"transform"),be(v,"borderRadius"),h(v,{transitionProperty:"transform, border-radius",transitionDuration:`${y.DURATION}s`,transitionTimingFunction:`cubic-bezier(${y.EASE.join(",")})`})))}function dt(u){let v=u?(window.innerWidth-U)/window.innerWidth:1,g=u?-U:0;window.clearTimeout(te.current),h(p.current,{transition:`transform ${y.DURATION}s cubic-bezier(${y.EASE.join(",")})`,transform:`scale(${v}) translateY(${g}px)`}),u||(te.current=setTimeout(()=>{h(p.current,{transition:"none",transform:`translateY(${ee(p.current)}px)`})},500))}function pt(u,v){if(v<0)return;let g=(window.innerWidth-U)/window.innerWidth,$=g+v*(1-g),P=-U+v*U;h(p.current,{transform:`scale(${$}) translateY(${P}px)`,transition:"none"})}function vt(u,v){let g=v?(window.innerWidth-U)/window.innerWidth:1,$=v?-U:0;v&&h(p.current,{transition:`transform ${y.DURATION}s cubic-bezier(${y.EASE.join(",")})`,transform:`scale(${g}) translateY(${$}px)`})}return R.default.createElement(A.Root,{open:O,onOpenChange:u=>{!u&&c&&oe(),Y(u)},modal:L},R.default.createElement(Se.Provider,{value:{activeSnapPoint:ot,snapPoints:c,setActiveSnapPoint:it,drawerRef:p,overlayRef:T,onAnimationStart:mt,onPress:st,onRelease:ft,onDrag:ct,dismissible:f,isOpen:O,shouldFade:Te,onNestedDrag:pt,onNestedOpenChange:dt,onNestedRelease:vt,keyboardIsOpen:_,setIsAnimating:s,modal:L,snapPointHeights:Ae,experimentalSafariThemeAnimation:d}},o))}var tt=R.default.forwardRef(function({children:e,style:n,...t},o){let{overlayRef:r,snapPoints:i,onRelease:a,experimentalSafariThemeAnimation:d,shouldFade:c,isOpen:b}=ue(),M=Oe(o,r),f=i&&i.length>0;return R.default.createElement(A.Overlay,{onMouseUp:a,ref:M,"vaul-overlay":"","vaul-snap-points":b&&f?"true":"false","vaul-theme-transition":d?"true":"false","vaul-snap-points-overlay":b&&c?"true":"false",...t})});tt.displayName="Drawer.Overlay";var nt=R.default.forwardRef(function({children:e,onOpenAutoFocus:n,onPointerDownOutside:t,onAnimationEnd:o,style:r,...i},a){let{drawerRef:d,onPress:c,onRelease:b,onAnimationStart:M,onDrag:f,dismissible:l,isOpen:x,keyboardIsOpen:D,setIsAnimating:L,snapPointHeights:O,setActiveSnapPoint:Y,snapPoints:m}=ue(),w=Oe(a,d),E=R.default.useRef(null);return R.default.createElement(A.Content,{onAnimationStart:s=>{window.clearTimeout(E.current),L(!0),E.current=setTimeout(()=>{L(!1),o==null||o(x),m&&!x&&Y(m[0])},Jt),M(s)},onPointerDown:c,onPointerUp:b,onPointerMove:f,onOpenAutoFocus:s=>{n?n(s):s.preventDefault()},onPointerDownOutside:s=>{D.current&&(D.current=!1,h(d.current,{"--hide-to":"200%"})),l||s.preventDefault(),d.current.setAttribute("vaul-clicked-outside","true"),t==null||t(s)},ref:w,style:O?{"--snap-point-height":`${O[0]}px`,...r}:r,...i,"vaul-drawer":""},e)});nt.displayName="Drawer.Content";function Qt({children:e,onDrag:n,onOpenChange:t}){let{onNestedDrag:o,onNestedOpenChange:r,onNestedRelease:i}=ue();if(!o)throw new Error("Drawer.NestedRoot must be placed in another drawer");return R.default.createElement(et,{onDrag:(a,d)=>{o(a,d),n==null||n(a,d)},onOpenChange:a=>{r(a),t==null||t(a)},onRelease:i},e)}var Zt=Object.assign({},{Root:et,NestedRoot:Qt,Content:nt,Overlay:tt,Trigger:A.Trigger,Portal:A.Portal,Close:A.Close,Title:A.Title,Description:A.Description});0&&(module.exports={Drawer}); | ||
"use client";var ht=Object.create;var ae=Object.defineProperty;var yt=Object.getOwnPropertyDescriptor;var wt=Object.getOwnPropertyNames;var Tt=Object.getPrototypeOf,Et=Object.prototype.hasOwnProperty;var St=(e,n)=>{for(var t in n)ae(e,t,{get:n[t],enumerable:!0})},Ne=(e,n,t,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of wt(n))!Et.call(e,r)&&r!==t&&ae(e,r,{get:()=>n[r],enumerable:!(o=yt(n,r))||o.enumerable});return e};var z=(e,n,t)=>(t=e!=null?ht(Tt(e)):{},Ne(n||!e||!e.__esModule?ae(t,"default",{value:e,enumerable:!0}):t,e)),Rt=e=>Ne(ae({},"__esModule",{value:!0}),e);var Xt={};St(Xt,{Drawer:()=>Zt});module.exports=Rt(Xt);var O=z(require("@radix-ui/react-dialog"));var B=z(require("react"));function Le(e){let n=B.default.useRef(e);return B.default.useEffect(()=>{n.current=e}),B.default.useMemo(()=>(...t)=>{var o;return(o=n.current)==null?void 0:o.call(n,...t)},[])}function Dt({defaultProp:e,onChange:n}){let t=B.default.useState(e),[o]=t,r=B.default.useRef(o),i=Le(n);return B.default.useEffect(()=>{r.current!==o&&(i(o),r.current=o)},[o,r,i]),t}function le({prop:e,defaultProp:n,onChange:t=()=>{}}){let[o,r]=Dt({defaultProp:n,onChange:t}),i=e!==void 0,a=i?e:o,m=Le(t),c=B.default.useCallback(v=>{if(i){let f=typeof v=="function"?v(e):v;f!==e&&m(f)}else r(v)},[i,e,r,m]);return[a,c]}var Te=z(require("react")),Ee=Te.default.createContext(void 0),ue=()=>Te.default.useContext(Ee);var R=z(require("react"));function Se(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))}Se(`[vaul-drawer]{will-change:transform;touch-action:none;animation:show-dialog .5s cubic-bezier(.32,.72,0,1);transform:translateY(var(--snap-point-height, 0))}[vaul-drawer]:after{content:"";position:absolute;top:100%;background:inherit;background-color:inherit;left:0;right:0;height:200%}[vaul-drawer][data-state=closed]{animation:hide-dialog .5s cubic-bezier(.32,.72,0,1) forwards}[vaul-drawer][vaul-closed-by-dragging=true]{animation:fake-animation .5s cubic-bezier(.32,.72,0,1) forwards}[vaul-overlay]:not([vaul-snap-points="true"]){animation:show-overlay .5s cubic-bezier(.32,.72,0,1)}[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]{opacity:1}[vaul-overlay][vaul-theme-transition=true]{animation:show-theme-overlay .5s cubic-bezier(.32,.72,0,1)}[vaul-overlay][data-state=closed]:not([vaul-snap-points="true"]),[vaul-overlay][data-state=closed][vaul-snap-points-overlay=true]{animation:hide-overlay .5s cubic-bezier(.32,.72,0,1)}[vaul-overlay][vaul-theme-transition=true][data-state=closed]{animation:hide-theme-overlay .5s cubic-bezier(.32,.72,0,1) forwards}@keyframes fake-animation{}@keyframes show-dialog{0%{transform:translateY(100%)}to{transform:translateY(var(--snap-point-height, 0))}}@keyframes hide-dialog{0%{transform:translateY(var(--hide-from, 0))}to{transform:translateY(var(--hide-to, 100%))}}@keyframes show-overlay{0%{opacity:0}to{opacity:1}}@keyframes hide-overlay{0%{opacity:var(--opacity-from, 1)}to{opacity:0}}@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 me=require("react"),Mt=typeof window!="undefined"?me.useLayoutEffect:me.useEffect;function Me(...e){return(...n)=>{for(let t of e)typeof t=="function"&&t(...n)}}function Ct(){return Ce(/^Mac/)}function xt(){return Ce(/^iPhone/)}function Fe(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}function It(){return Ce(/^iPad/)||Ct()&&navigator.maxTouchPoints>1}function Q(){return xt()||It()}function Ce(e){return typeof window!="undefined"&&window.navigator!=null?e.test(window.navigator.platform):void 0}var Re=typeof document!="undefined"&&window.visualViewport;function $e(e){let n=window.getComputedStyle(e);return/(auto|scroll)/.test(n.overflow+n.overflowX+n.overflowY)}function Ye(e){for($e(e)&&(e=e.parentElement);e&&!$e(e);)e=e.parentElement;return e||document.scrollingElement||document.documentElement}var Ot=new Set(["checkbox","radio","range","color","file","image","button","submit","reset"]),se=0,De;function ke(e={}){let{isDisabled:n}=e;Mt(()=>{if(!n)return se++,se===1&&(Q()?De=Ht():De=At()),()=>{se--,se===0&&De()}},[n])}function At(){return Me(ce(document.documentElement,"paddingRight",`${window.innerWidth-document.documentElement.clientWidth}px`),ce(document.documentElement,"overflow","hidden"))}function Ht(){let e,n=0,t=f=>{e=Ye(f.target),!(e===document.documentElement&&e===document.body)&&(n=f.changedTouches[0].pageY)},o=f=>{if(!e||e===document.documentElement||e===document.body){f.preventDefault();return}let l=f.changedTouches[0].pageY,A=e.scrollTop,D=e.scrollHeight-e.clientHeight;D!==0&&((A<=0&&l>n||A>=D&&l<n)&&f.preventDefault(),n=l)},r=f=>{let l=f.target;fe(l)&&l!==document.activeElement&&(f.preventDefault(),l.style.transform="translateY(-2000px)",l.focus(),requestAnimationFrame(()=>{l.style.transform=""}))},i=f=>{let l=f.target;fe(l)&&(l.style.transform="translateY(-2000px)",requestAnimationFrame(()=>{l.style.transform="",Re&&(Re.height<window.innerHeight?requestAnimationFrame(()=>{Pe(l)}):Re.addEventListener("resize",()=>Pe(l),{once:!0}))}))},a=()=>{window.scrollTo(0,0)},m=window.pageXOffset,c=window.pageYOffset,v=Me(ce(document.documentElement,"paddingRight",`${window.innerWidth-document.documentElement.clientWidth}px`),ce(document.documentElement,"overflow","hidden"));window.scrollTo(0,0);let M=Me(J(document,"touchstart",t,{passive:!1,capture:!0}),J(document,"touchmove",o,{passive:!1,capture:!0}),J(document,"touchend",r,{passive:!1,capture:!0}),J(document,"focus",i,!0),J(window,"scroll",a));return()=>{v(),M(),window.scrollTo(m,c)}}function ce(e,n,t){let o=e.style[n];return e.style[n]=t,()=>{e.style[n]=o}}function J(e,n,t,o){return e.addEventListener(n,t,o),()=>{e.removeEventListener(n,t,o)}}function Pe(e){let n=document.scrollingElement||document.documentElement;for(;e&&e!==n;){let t=Ye(e);if(t!==document.documentElement&&t!==document.body&&t!==e){let o=t.getBoundingClientRect().top,r=e.getBoundingClientRect().top,i=e.getBoundingClientRect().bottom,a=t.getBoundingClientRect().bottom;i>a&&(t.scrollTop+=r-o)}e=t.parentElement}}function fe(e){return e instanceof HTMLInputElement&&!Ot.has(e.type)||e instanceof HTMLTextAreaElement||e instanceof HTMLElement&&e.isContentEditable}var Ve=z(require("react"));function Nt(e,n){typeof e=="function"?e(n):e!=null&&(e.current=n)}function Lt(...e){return n=>e.forEach(t=>Nt(t,n))}function xe(...e){return Ve.useCallback(Lt(...e),e)}var N=z(require("react"));var $t=4,Pt=.001,Ft=1e-7,Yt=10,Z=11,de=1/(Z-1),kt=typeof Float32Array=="function";function ze(e,n){return 1-3*n+3*e}function Be(e,n){return 3*n-6*e}function je(e){return 3*e}function pe(e,n,t){return((ze(n,t)*e+Be(n,t))*e+je(n))*e}function We(e,n,t){return 3*ze(n,t)*e*e+2*Be(n,t)*e+je(n)}function Vt(e,n,t,o,r){var i,a,m=0;do a=n+(t-n)/2,i=pe(a,o,r)-e,i>0?t=a:n=a;while(Math.abs(i)>Ft&&++m<Yt);return a}function zt(e,n,t,o){for(var r=0;r<$t;++r){var i=We(n,t,o);if(i===0)return n;var a=pe(n,t,o)-e;n-=a/i}return n}function Bt(e){return e}function Ue(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 Bt;for(var r=kt?new Float32Array(Z):new Array(Z),i=0;i<Z;++i)r[i]=pe(i*de,e,t);function a(m){for(var c=0,v=1,M=Z-1;v!==M&&r[v]<=m;++v)c+=de;--v;var f=(m-r[v])/(r[v+1]-r[v]),l=c+f*de,A=We(l,e,t);return A>=Pt?zt(m,l,e,t):A===0?l:Vt(m,c,c+de,e,t)}return function(c){return c===0||c===1?c:pe(a(c),n,o)}}var jt=Ue(.32,.72,0,1);function Wt(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 Ut(e,n){let[t,o,r,i]=Wt(e);return[Math.round(i*t+(1-i)*Number(n[0])),Math.round(i*o+(1-i)*Number(n[1])),Math.round(i*r+(1-i)*Number(n[2]))]}function _t(e){return jt(e)}function qt(e,n,t,o){arguments.length<3&&(t=.5);let r=e.slice();for(let i=0;i<3;i++){let a=n[i]-e[i],m=o?e[i]+t*a:e[i]+_t(t)*a;r[i]=Math.round(m),r[i]<0&&(r[i]=0),r[i]>255&&(r[i]=255)}return r}function X(e,n,t,o){let r=1/(t-1),i=[];for(let a=0;a<t;a++)i.push(qt(e,n,r*a,!!o));return i}function _e(e,n,t,o){let[r,i]=N.default.useState([255,255,255]),[a,m]=N.default.useState([153,153,153]),[c,v]=N.default.useState(!1),[M,f]=N.default.useState(null),[l,A]=N.default.useState(null),D=N.default.useMemo(()=>Q()&&Fe()&&o,[o]),L=N.default.useMemo(()=>r&&a?X(r,a,50):null,[a,r]),x=N.default.useMemo(()=>r&&a?X(a,r,50):null,[a,r]),Y=N.default.useMemo(()=>r&&a?X(a,r,50,!0):null,[a,r]);N.default.useEffect(()=>{if(!D)return;let u=getComputedStyle(document.documentElement),E=u.getPropertyValue("--vaul-overlay-background").split(",").map(H=>Number(H)),C=u.getPropertyValue("--vaul-overlay-background-end"),S=Ut(C,E);i(E),m(S)},[D]),N.default.useEffect(()=>{if(D&&!M){let u=document.querySelector('meta[name="theme-color"]');u?f(u.getAttribute("content")):(u=document.createElement("meta"),u.name="theme-color",document.getElementsByTagName("head")[0].appendChild(u)),A(u)}},[M,D]);let d=(0,N.useCallback)(u=>{let E,C;function S(H){E||(E=H);let j=H-E,k=Math.floor(j/10);if(n.current&&u&&!c){if(e.current.style.transform==="translateY(0px)"&&e.current.getAttribute("vaul-clicked-outside")!=="true")return;if(k<u.length){let te=u[k];l==null||l.setAttribute("content",`rgb(${te.join(",")})`),k===u.length-1&&M&&!t&&(l==null||l.setAttribute("content",M)),C=requestAnimationFrame(S)}}}return C=requestAnimationFrame(S),C},[e,t,l,c,M,n]);N.default.useEffect(()=>{if(!D||!L||!x)return;let u=d(t?L:x);return t&&v(!1),()=>{u&&cancelAnimationFrame(u)}},[t,D,d,L,x]);function b(u){let E=document.querySelector('meta[name="theme-color"]');if(!D||!E||!Y)return;let C=Math.floor(u*Y.length);C=Math.max(0,Math.min(Y.length-1,C));let S=Y[C];E.setAttribute("content",`rgb(${S.join(",")})`)}function h(u){let E=document.querySelector('meta[name="theme-color"]');if(!E||!D)return;v(!0);let C=E.getAttribute("content").match(/\d+/g).map(Number),S=X(C,a,50);!u&&r&&(S=X(C,r,50)),d(S)}return{onDrag:b,onRelease:h}}var ge=z(require("react"));var W=null;function qe({isOpen:e,modal:n}){let t=ge.default.useRef(0);function o(){if(W===null){W={position:document.body.style.position,top:document.body.style.top,left:document.body.style.left};let{scrollX:i,innerHeight:a}=window;document.body.style.setProperty("position","fixed","important"),document.body.style.top=`${-t.current}px`,document.body.style.left=`${-i}px`,document.body.style.right="0px",setTimeout(()=>requestAnimationFrame(()=>{let m=a-window.innerHeight;m&&t.current>=a&&(document.body.style.top=`${-(t.current+m)}px`)}),300)}}function r(){if(W!==null){let i=-parseInt(document.body.style.top,10),a=-parseInt(document.body.style.left,10);document.body.style.position=W.position,document.body.style.top=W.top,document.body.style.left=W.left,document.body.style.right="unset",requestAnimationFrame(()=>{window.scrollTo(a,i)}),W=null}}ge.default.useEffect(()=>{function i(){t.current=window.scrollY}return i(),window.addEventListener("scroll",i),()=>{window.removeEventListener("scroll",i)}},[]),ge.default.useEffect(()=>{Q()&&(e?(o(),n||setTimeout(()=>{r()},500)):r())},[e])}var K=z(require("react"));var Ge=new WeakMap;function Ke(e){let n=e.getBoundingClientRect();return window.visualViewport?n.top>=0&&n.left>=0&&n.bottom<=window.visualViewport.height+40&&n.right<=window.visualViewport.width:!1}function w(e,n,t=!1){if(!e||!(e instanceof HTMLElement)||!n)return;let o={};Object.entries(n).forEach(([r,i])=>{if(r.startsWith("--")){e.style.setProperty(r,i);return}o[r]=e.style[r],e.style[r]=i}),!t&&Ge.set(e,o)}function ve(e,n){if(!e||!(e instanceof HTMLElement))return;let t=Ge.get(e);if(!t){e.style={};return}n?e.style[n]=t[n]:Object.entries(t).forEach(([o,r])=>{e.style[o]=r})}function ee(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 Je(e){return 8*(Math.log(e+1)-2)}var T={DURATION:.5,EASE:[.32,.72,0,1]},be=.4;function Qe({activeSnapPointProp:e,setActiveSnapPointProp:n,snapPoints:t,drawerRef:o,overlayRef:r,fadeFromIndex:i}){let[a,m]=le({prop:e,defaultProp:t==null?void 0:t[0],onChange:n}),c=typeof window!="undefined",v=K.default.useMemo(()=>a===(t==null?void 0:t[t.length-1]),[t,a]),M=t&&t.length>0&&t[i]===a||!t,f=K.default.useMemo(()=>{var d;return(d=t==null?void 0:t.findIndex(b=>b===a))!=null?d:null},[t,a]),l=K.default.useMemo(()=>{var d;return(d=t==null?void 0:t.map(b=>{let h=typeof b=="string",u=0;h&&(u=parseInt(b,10));let E=h?u:c?b*window.innerHeight:0;return c&&window.innerHeight-E}))!=null?d:null},[t]),A=K.default.useMemo(()=>{var d;return(d=l==null?void 0:l[f])!=null?d:null},[l,a]);function D(d){var h,u;let b=(h=l==null?void 0:l.findIndex(E=>E===d))!=null?h:null;w(o.current,{transition:`transform ${T.DURATION}s cubic-bezier(${T.EASE.join(",")})`,transform:`translateY(${d}px)`}),b!==l.length-1&&b!==i?w(r.current,{transition:`opacity ${T.DURATION}s cubic-bezier(${T.EASE.join(",")})`,opacity:"0"}):w(r.current,{transition:`opacity ${T.DURATION}s cubic-bezier(${T.EASE.join(",")})`,opacity:"1"}),m((u=t==null?void 0:t[b])!=null?u:null)}K.default.useEffect(()=>{var d;if(e){let b=(d=t==null?void 0:t.findIndex(h=>h===e))!=null?d:null;D(l[b])}},[e]);function L({draggedDistance:d,closeDrawer:b,velocity:h}){let u=A-d,E=f===i-1,C=f===0;if(E&&w(r.current,{transition:`opacity ${T.DURATION}s cubic-bezier(${T.EASE.join(",")})`}),h>2&&d<0){b();return}if(h>2&&d>0){D(l[t.length-1]);return}let S=l==null?void 0:l.reduce((H,j)=>Math.abs(j-u)<Math.abs(H-u)?j:H);if(h>be&&Math.abs(d)<window.innerHeight*.4){let H=d>0?1:-1;if(H>0&&v)return;C&&H<0&&b(),D(l[f+H]);return}D(S)}function x({draggedDistance:d}){var h;let b=A-d;if(b<l[l.length-1]){m((h=t==null?void 0:t[t.length-1])!=null?h:null),w(o.current,{transform:"translateY(0px)"});return}w(o.current,{transform:`translateY(${b}px)`})}function Y(d,b){if(!t)return null;let h=f===i-1;if(f>=i&&b)return 0;if(h&&!b)return 1;if(!M&&!h)return null;let E=h?f+1:f-1,C=h?l[E]-l[E-1]:l[E+1]-l[E],S=d/Math.abs(C);return h?1-S:S}return{isLastSnapPoint:v,activeSnapPoint:a,shouldFade:M,getPercentageDragged:Y,setActiveSnapPoint:m,activeSnapPointIndex:f,onRelease:L,onDrag:x,snapPointsOffset:l}}var Gt=.25,Kt=500,Jt=501,Ze=8,U=16,Xe=26;function et({open:e,defaultOpen:n,onOpenChange:t,children:o,shouldScaleBackground:r,onDrag:i,onRelease:a,experimentalSafariThemeAnimation:m,snapPoints:c,closeThreshold:v=Gt,scrollLockTimeout:M=Kt,dismissible:f=!0,fadeFromIndex:l=(c==null?void 0:c.length)-1,activeSnapPoint:A,setActiveSnapPoint:D,modal:L=!0}){let[x=!1,Y]=le({prop:e,defaultProp:n,onChange:t}),[d,b]=R.default.useState(!1),[h,u]=R.default.useState(!0),[E,C]=R.default.useState(!1),S=R.default.useRef(null),H=R.default.useRef(null),j=R.default.useRef(null),k=R.default.useRef(null),te=R.default.useRef(null),he=R.default.useRef(0),_=R.default.useRef(!1),Ie=R.default.useRef(0),p=R.default.useRef(null),{onDrag:rt,onRelease:ne}=_e(p,S,x,m),{activeSnapPoint:ot,activeSnapPointIndex:ye,setActiveSnapPoint:it,onRelease:at,snapPointsOffset:Oe,onDrag:lt,shouldFade:we,getPercentageDragged:ut}=Qe({snapPoints:c,activeSnapPointProp:A,setActiveSnapPointProp:D,drawerRef:p,fadeFromIndex:l,overlayRef:S});ke({isDisabled:!x||d||h||!L||E}),qe({isOpen:x,modal:L});function re(){return(window.innerWidth-Xe)/window.innerWidth}function st(s){f&&(p.current&&!p.current.contains(s.target)||(b(!0),H.current=new Date,s.target.setPointerCapture(s.pointerId),he.current=s.clientY))}function Ae(s,g){let y=s,$=new Date,P=window.getSelection().toString(),I=p.current?ee(p.current):null;if(P.length>0)return!1;if(k.current&&$.getTime()-k.current.getTime()<M&&I===0)return k.current=new Date,!1;for(;y;){if(y.scrollHeight>y.clientHeight){if(y.role==="dialog"||y.getAttribute("vaul-drawer"))return!0;if(y.scrollTop!==0)return k.current=new Date,!1;if(g&&y!==document.body&&!I)return k.current=new Date,!1}y=y.parentNode}return!0}function ct(s){var g;if(d){let y=he.current-s.clientY,$=y>0;if(!Ae(s.target,$))return;let P=((g=p.current)==null?void 0:g.getBoundingClientRect().height)||0;if(w(p.current,{transition:"none"}),w(S.current,{transition:"none"}),c&<({draggedDistance:y}),y>0&&!c){let G=Je(y);w(p.current,{transform:`translateY(${Math.min(G*-1,0)}px)`});return}let I=Math.abs(y),V=document.querySelector("[vaul-drawer-wrapper]"),F=I/P,ie=ut(I,$);ie!==null&&(F=ie);let q=1-F;if((we||ye===l-1)&&(rt(F),i==null||i(s,F),w(S.current,{opacity:`${q}`,transition:"none"},!0)),V&&S.current&&r){let G=Math.min(re()+F*(1-re()),1),vt=8-F*8,bt=Math.max(0,14-F*14);w(V,{borderRadius:`${vt}px`,transform:`scale(${G}) translateY(${bt}px)`,transition:"none"},!0)}c||w(p.current,{transform:`translateY(${I}px)`})}}R.default.useEffect(()=>{function s(){var y,$,P;if(!p.current)return;let g=document.activeElement;if(!Ke(g)&&fe(g)||_.current){let I=window.visualViewport.height,V=window.innerHeight-I,F=((y=p.current)==null?void 0:y.getBoundingClientRect().height)||0,ie=($=p.current)==null?void 0:$.getBoundingClientRect().top;if(Math.abs(Ie.current-V)>60&&(_.current=!_.current),c&&c.length>0){let q=Oe[ye];V+=q}if(Ie.current=V,F>I||_.current){let q=(P=p.current)==null?void 0:P.getBoundingClientRect().height,G=q;q>I&&(G=I-Xe),p.current.style.height=`${Math.max(G,I-ie)}px`}else p.current.style.height="initial";c&&c.length>0&&!_.current?p.current.style.bottom="0px":p.current.style.bottom=`${Math.max(V,0)}px`}}return window.visualViewport.addEventListener("resize",s),()=>window.visualViewport.removeEventListener("resize",s)},[ye]);function oe(){var s;if(f&&(p.current.setAttribute("vaul-closed-by-dragging","true"),Y(!1),p.current)){w(p.current,{transform:"translateY(100%)",transition:`transform ${T.DURATION}s cubic-bezier(${T.EASE.join(",")})`});let g=((s=S.current)==null?void 0:s.style.opacity)||1;w(S.current,{"--opacity-from":`${we?g:0}`})}}R.default.useEffect(()=>{if(!x&&r){let s=setTimeout(()=>{ve(document.body)},200);return()=>clearTimeout(s)}},[x,r]);function He(){let s=document.querySelector("[vaul-drawer-wrapper]"),g=ee(p.current);w(p.current,{transform:"translateY(0px)",transition:`transform ${T.DURATION}s cubic-bezier(${T.EASE.join(",")})`}),w(S.current,{transition:`opacity ${T.DURATION}s cubic-bezier(${T.EASE.join(",")})`,opacity:"1"}),r&&g>0&&x&&w(s,{borderRadius:`${Ze}px`,overflow:"hidden",transform:`scale(${re()}) translateY(calc(env(safe-area-inset-top) + 14px))`,transformOrigin:"top",transitionProperty:"transform, border-radius",transitionDuration:`${T.DURATION}s`,transitionTimingFunction:`cubic-bezier(${T.EASE.join(",")})`},!0)}function ft(s){var F;if(!d)return;b(!1),j.current=new Date;let g=ee(p.current);if(!Ae(s.target,!1)||!g||Number.isNaN(g)||H.current===null)return;let y=s.clientY,$=j.current.getTime()-H.current.getTime(),P=he.current-y,I=Math.abs(P)/$;if(I>.05&&(C(!0),setTimeout(()=>{C(!1)},200)),c){at({draggedDistance:P,closeDrawer:oe,velocity:I});return}if(P>0){He(),a==null||a(s,!0),ne(!0);return}if(I>be){oe(),a==null||a(s,!1),ne(!1);return}let V=Math.min(((F=p.current)==null?void 0:F.getBoundingClientRect().height)||0,window.innerHeight);if(g>=V*v){oe(),a==null||a(s,!1),ne(!1);return}a==null||a(s,!0),ne(!0),He()}function mt(s){let g=document.querySelector("[vaul-drawer-wrapper]");!g||!r||(s.animationName==="show-dialog"?(w(document.body,{background:"black"},!0),w(g,{borderRadius:`${Ze}px`,overflow:"hidden",transform:`scale(${re()}) translateY(calc(env(safe-area-inset-top) + 14px))`,transformOrigin:"top",transitionProperty:"transform, border-radius",transitionDuration:`${T.DURATION}s`,transitionTimingFunction:`cubic-bezier(${T.EASE.join(",")})`})):(s.animationName==="hide-dialog"||s.animationName==="fake-animation")&&(ve(g,"transform"),ve(g,"borderRadius"),w(g,{transitionProperty:"transform, border-radius",transitionDuration:`${T.DURATION}s`,transitionTimingFunction:`cubic-bezier(${T.EASE.join(",")})`})))}function dt(s){let g=s?(window.innerWidth-U)/window.innerWidth:1,y=s?-U:0;window.clearTimeout(te.current),w(p.current,{transition:`transform ${T.DURATION}s cubic-bezier(${T.EASE.join(",")})`,transform:`scale(${g}) translateY(${y}px)`}),s||(te.current=setTimeout(()=>{w(p.current,{transition:"none",transform:`translateY(${ee(p.current)}px)`})},500))}function pt(s,g){if(g<0)return;let y=(window.innerWidth-U)/window.innerWidth,$=y+g*(1-y),P=-U+g*U;w(p.current,{transform:`scale(${$}) translateY(${P}px)`,transition:"none"})}function gt(s,g){let y=g?(window.innerWidth-U)/window.innerWidth:1,$=g?-U:0;g&&w(p.current,{transition:`transform ${T.DURATION}s cubic-bezier(${T.EASE.join(",")})`,transform:`scale(${y}) translateY(${$}px)`})}return R.default.createElement(O.Root,{open:x,onOpenChange:s=>{!s&&c&&oe(),Y(s)},modal:L},R.default.createElement(Ee.Provider,{value:{activeSnapPoint:ot,snapPoints:c,setActiveSnapPoint:it,drawerRef:p,overlayRef:S,onAnimationStart:mt,onPress:st,onRelease:ft,onDrag:ct,dismissible:f,isOpen:x,shouldFade:we,onNestedDrag:pt,onNestedOpenChange:dt,onNestedRelease:gt,keyboardIsOpen:_,setIsAnimating:u,modal:L,snapPointsOffset:Oe,experimentalSafariThemeAnimation:m}},o))}var tt=R.default.forwardRef(function({children:e,style:n,...t},o){let{overlayRef:r,snapPoints:i,onRelease:a,experimentalSafariThemeAnimation:m,shouldFade:c,isOpen:v}=ue(),M=xe(o,r),f=i&&i.length>0;return R.default.createElement(O.Overlay,{onMouseUp:a,ref:M,"vaul-overlay":"","vaul-snap-points":v&&f?"true":"false","vaul-theme-transition":m?"true":"false","vaul-snap-points-overlay":v&&c?"true":"false",...t})});tt.displayName="Drawer.Overlay";var nt=R.default.forwardRef(function({children:e,onOpenAutoFocus:n,onPointerDownOutside:t,onAnimationEnd:o,style:r,...i},a){let{drawerRef:m,onPress:c,onRelease:v,onAnimationStart:M,onDrag:f,dismissible:l,isOpen:A,keyboardIsOpen:D,setIsAnimating:L,snapPointsOffset:x,setActiveSnapPoint:Y,snapPoints:d}=ue(),b=xe(a,m),h=R.default.useRef(null);return R.default.createElement(O.Content,{onAnimationStart:u=>{window.clearTimeout(h.current),L(!0),h.current=setTimeout(()=>{L(!1),o==null||o(A),d&&!A&&Y(d[0])},Jt),M(u)},onPointerDown:c,onPointerUp:v,onPointerMove:f,onOpenAutoFocus:u=>{n?n(u):u.preventDefault()},onPointerDownOutside:u=>{D.current&&(D.current=!1,w(m.current,{"--hide-to":"200%"})),l||u.preventDefault(),m.current.setAttribute("vaul-clicked-outside","true"),t==null||t(u)},ref:b,style:x?{"--snap-point-height":`${x[0]}px`,...r}:r,...i,"vaul-drawer":""},e)});nt.displayName="Drawer.Content";function Qt({children:e,onDrag:n,onOpenChange:t}){let{onNestedDrag:o,onNestedOpenChange:r,onNestedRelease:i}=ue();if(!o)throw new Error("Drawer.NestedRoot must be placed in another drawer");return R.default.createElement(et,{onDrag:(a,m)=>{o(a,m),n==null||n(a,m)},onOpenChange:a=>{r(a),t==null||t(a)},onRelease:i},e)}var Zt=Object.assign({},{Root:et,NestedRoot:Qt,Content:nt,Overlay:tt,Trigger:O.Trigger,Portal:O.Portal,Close:O.Close,Title:O.Title,Description:O.Description});0&&(module.exports={Drawer}); | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "vaul", | ||
"version": "0.4.1", | ||
"version": "0.4.5", | ||
"description": "Drawer component for React.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -52,6 +52,10 @@ 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. | ||
`scrollLockTimeout`: Duration for which the drawer is not draggable after scrolling content inside of the drawer. Defaults to 500ms | ||
`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. | ||
`scrollLockTimeout`: Duration for which the drawer is not draggable after scrolling content inside of the drawer. Defaults to 500ms | ||
`snapPoints`: Array of numbers from 0 to 100 that corresponds to % of the screen a given snap point should take up. Should go from least visible. Example `[0.2, 0.5, 0.8]`. | ||
`fadeFromIndex`: Index of a snapPoint from which the overlay fade should be applied. Defaults to the last snap point. | ||
`modal`: When `false`it allows to interact with elements outside of the drawer without closing it. Defaults to`true`. | ||
@@ -58,0 +62,0 @@ |
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
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
254184
224
93
0