@buoy-gg/bottom-sheet 7.0.56 → 7.0.58

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/web/index.mjs CHANGED
@@ -1 +1 @@
1
- "use client";typeof window<"u"&&typeof globalThis.global>"u"&&(globalThis.global=globalThis);import{useState as R,useRef as E,useEffect as q}from"react";import{ToolBackground as Z}from"@buoy-gg/shared-ui/web";function ee(t){return t*.25}function te(t,e,n,o,r,s,d,p=80){let m=Math.max(0,s.left||0),f=r.width-Math.max(0,s.right||0),c=Math.max(0,s.top||0),y=r.height-Math.max(0,s.bottom||0),l=e.left+e.width,h=e.top+e.height,g=e.left,b=e.top,v=l,x=h;switch(t){case"topLeft":{g=Math.max(m,Math.min(e.left+n,l-d)),b=Math.max(c,Math.min(e.top+o,h-p));break}case"topRight":{v=Math.min(f,Math.max(l+n,e.left+d)),b=Math.max(c,Math.min(e.top+o,h-p));break}case"bottomLeft":{g=Math.max(m,Math.min(e.left+n,l-d)),x=Math.min(y,Math.max(h+o,e.top+p));break}case"bottomRight":{v=Math.min(f,Math.max(l+n,e.left+d)),x=Math.min(y,Math.max(h+o,e.top+p));break}}return{left:g,top:b,width:Math.max(d,v-g),height:Math.max(p,x-b)}}function oe(t,e,n,o){return t>.8&&e>50||e>150&&n<=o}import{useEffect as ne,useRef as D}from"react";function re(t,e){let n=D(0),o=D(0),r=D(null),s=D({onDouble:t,onTriple:e});return s.current={onDouble:t,onTriple:e},ne(()=>()=>{r.current&&clearTimeout(r.current)},[]),D(()=>{let d=Date.now();d-n.current>500&&(o.current=0),o.current++,n.current=d,r.current&&clearTimeout(r.current),r.current=setTimeout(()=>{o.current===2?s.current.onDouble():o.current>=3&&s.current.onTriple(),o.current=0},300)}).current}import{jsx as a,jsxs as z}from"react/jsx-runtime";var ie={background:"rgba(8, 12, 21, 0.98)",panel:"rgba(16, 22, 35, 0.98)",border:"#00B8E666",primary:"#FFFFFF",secondary:"#B8BFC9",muted:"#7A8599",success:"#4AFF9F",error:"#FF5252",info:"#00B8E6"};function ae(t){return window.addEventListener("resize",t),window.visualViewport?.addEventListener("resize",t),()=>{window.removeEventListener("resize",t),window.visualViewport?.removeEventListener("resize",t)}}function J(){return{width:window.innerWidth,height:window.innerHeight}}function K(){let t=document.createElement("div");t.style.cssText="position:fixed;visibility:hidden;pointer-events:none;top:env(safe-area-inset-top);bottom:env(safe-area-inset-bottom);left:env(safe-area-inset-left);right:env(safe-area-inset-right)",document.body.appendChild(t);let e=getComputedStyle(t),n={top:parseFloat(e.top)||0,bottom:parseFloat(e.bottom)||0,left:parseFloat(e.left)||0,right:parseFloat(e.right)||0};return document.body.removeChild(t),n}function le(){let[t,e]=R(()=>({viewport:J(),insets:K()}));return q(()=>ae(()=>{e({viewport:J(),insets:K()})}),[]),t}function V(t,e){if(!t.isPrimary)return;let n=t.currentTarget,o=t.clientX,r=t.clientY,s=t.clientY,d=performance.now(),p=0,m=0;e.onStart?.(t),n.setPointerCapture(t.pointerId);let f=l=>{if(l.pointerId!==t.pointerId)return;let h=l.clientX-o,g=l.clientY-r;m=Math.max(m,Math.abs(h)+Math.abs(g));let b=performance.now(),v=b-d;v>0&&(p=(l.clientY-s)/v,s=l.clientY,d=b),e.onMove(l,{dx:h,dy:g})},c=l=>{l.pointerId===t.pointerId&&(y(),e.onEnd(l,{dx:l.clientX-o,dy:l.clientY-r,vy:p,wasTap:m<=5}))},y=()=>{n.removeEventListener("pointermove",f),n.removeEventListener("pointerup",c),n.removeEventListener("pointercancel",c)};n.addEventListener("pointermove",f),n.addEventListener("pointerup",c),n.addEventListener("pointercancel",c)}function O({isResizing:t,mode:e,hasCustomContent:n=false,theme:o}){return z("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",padding:n?"6px 0 2px":"8px 0",position:"relative"},children:[a("div",{style:{width:t?40:e==="floating"?50:40,height:e==="floating"?5:3,backgroundColor:t?o.success:e==="floating"?o.muted:o.info+"99",borderRadius:2,boxShadow:`0 0 4px ${o.info}CC`}}),t&&e==="bottomSheet"&&a("div",{style:{position:"absolute",display:"flex",flexDirection:"row",gap:2,marginTop:12},children:[0,1,2].map(r=>a("div",{style:{width:12,height:1,backgroundColor:o.success,opacity:.6}},r))})]})}function U({header:t,isResizing:e,mode:n,theme:o}){return t?.customContent?z("div",{style:{flex:1,display:"flex",flexDirection:"column",justifyContent:"center"},children:[a(O,{isResizing:e,mode:n,hasCustomContent:true,theme:o}),t.customContent]}):z("div",{style:{flex:1,display:"flex",flexDirection:"column",justifyContent:"center",position:"relative"},children:[a(O,{isResizing:e,mode:n,theme:o}),z("div",{style:{padding:"0 16px",display:"flex",flexDirection:"column",alignItems:"center"},children:[t?.title&&a("span",{style:{fontSize:16,fontWeight:600,color:o.primary},children:t.title}),t?.subtitle&&a("span",{style:{fontSize:12,color:o.secondary,paddingTop:4},children:t.subtitle})]}),a("div",{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"none"},children:a("span",{style:{fontSize:10,color:o.muted,fontStyle:"italic"},children:"Double tap: Toggle \u2022 Triple tap: Close"})})]})}function _({children:t,footer:e,footerHeight:n,disableScrollWrapper:o,contentStyle:r,theme:s,background:d}){return z("div",{style:{flex:1,minHeight:0,display:"flex",flexDirection:"column",backgroundColor:s.background,borderBottomLeftRadius:16,borderBottomRightRadius:16,overflow:"hidden",position:"relative",...r},children:[d?a(Z,{}):null,o?t:a("div",{style:{flex:1,minHeight:0,overflowY:"auto",WebkitOverflowScrolling:"touch",paddingBottom:n},children:t}),e?a("div",{style:{position:"absolute",left:0,right:0,bottom:0,backgroundColor:s.background,borderBottomLeftRadius:16,borderBottomRightRadius:16},children:e}):null]})}var Q="transform 320ms cubic-bezier(0.16, 1, 0.3, 1)",G="opacity 200ms ease";function se({props:t,theme:e,viewport:n,effectiveMaxHeight:o,panelHeight:r,setPanelHeight:s,onHeaderTap:d}){let{onClose:p,children:m,header:f,styles:c={},minHeight:y=100,footer:l,footerHeight:h=0,disableScrollWrapper:g,zIndex:b=1e3,background:v=true}=t,x=E(null),C=E(null),[S,Y]=R(false),[$,W]=R(false),A=E(false),k=E(r);q(()=>{let M=requestAnimationFrame(()=>W(true));return()=>cancelAnimationFrame(M)},[]);let L=M=>{if(A.current)return;let j=M.currentTarget.getBoundingClientRect().top,X=M.clientY-j;V(M,{onStart:()=>Y(true),onMove:H=>{let B=H.clientY-X,i=Math.max(y,Math.min(n.height-B,o));k.current=i,x.current&&(x.current.style.height=`${i}px`)},onEnd:(H,{dy:B,vy:i,wasTap:u})=>{if(Y(false),u){d();return}if(oe(i,B,k.current,y)){A.current=true;let T=C.current;T&&(T.style.transition=`${Q}, ${G}`,T.style.transform="translateY(100%)",T.style.opacity="0"),setTimeout(p,220);return}s(k.current)}})};return a("div",{style:{position:"fixed",inset:0,zIndex:b,pointerEvents:"none"},children:a("div",{ref:C,style:{position:"absolute",bottom:0,left:0,right:0,pointerEvents:"auto",transform:$?"translateY(0)":"translateY(100%)",opacity:$?1:0,transition:`${Q}, ${G}`},children:z("div",{ref:x,style:{display:"flex",flexDirection:"column",height:r,backgroundColor:e.panel,borderTopLeftRadius:16,borderTopRightRadius:16,border:`1px solid ${e.border}`,boxShadow:`0 -4px 12px ${e.info}4D, 0 -2px 24px rgba(0,0,0,0.4)`,...c.container},children:[a("div",{onPointerDown:L,style:{minHeight:56,display:"flex",backgroundColor:e.panel,borderTopLeftRadius:16,borderTopRightRadius:16,borderBottom:"1px solid rgba(255, 255, 255, 0.1)",cursor:S?"ns-resize":"grab",touchAction:"none",userSelect:"none"},children:a(U,{header:f,isResizing:S,mode:"bottomSheet",theme:e})}),a(_,{footer:l,footerHeight:h,disableScrollWrapper:g,contentStyle:c.content,theme:e,background:v,children:m})]})})})}function de({isActive:t,theme:e}){return a("div",{style:{width:20,height:20,borderRadius:10,margin:5,backgroundColor:t?e.success+"1A":"transparent",border:t?`2px solid ${e.success}`:"2px solid transparent",boxShadow:t?`0 0 8px ${e.success}99`:"none"}})}function ce({props:t,theme:e,viewport:n,insets:o,rect:r,setRect:s,onHeaderTap:d}){let{onClose:p,children:m,header:f,styles:c={},footer:y,footerHeight:l=0,onBack:h,disableScrollWrapper:g,zIndex:b=1e3,background:v=true}=t,x=E(null),[C,S]=R(false),[Y,$]=R(false),[W,A]=R(false),k=E(r);k.current=r;let L=E(r);q(()=>{let i=requestAnimationFrame(()=>A(true));return()=>cancelAnimationFrame(i)},[]);let M=i=>{L.current=i;let u=x.current;u&&(u.style.transform=`translate(${i.left}px, ${i.top}px)`,u.style.width=`${i.width}px`,u.style.height=`${i.height}px`)},j=i=>{let u=k.current,T=i.clientX-u.left,I=i.clientY-u.top;V(i,{onMove:(P,{dx:F,dy:w})=>{Math.abs(F)+Math.abs(w)>5&&S(true),M({...L.current,left:P.clientX-T,top:P.clientY-I})},onEnd:(P,{wasTap:F})=>{if(S(false),F){d();return}let w=L.current,N={...w,left:Math.max(o.left,Math.min(w.left,n.width-o.right-w.width)),top:Math.max(o.top,Math.min(w.top,n.height-o.bottom-w.height))};M(N),s(N)}})},X=i=>u=>{u.stopPropagation();let T={...k.current},I=false;V(u,{onStart:()=>$(true),onMove:(P,{dx:F,dy:w})=>{Math.abs(F)<.5&&Math.abs(w)<.5||(I=true,M(te(i,T,F,w,n,o,ee(n.width),80)))},onEnd:()=>{if($(false),!I){if(i==="topRight"){p();return}if(i==="topLeft"&&h){h();return}}s(L.current)}})},H=C||Y,B=[{corner:"topLeft",style:{top:4,left:4}},{corner:"topRight",style:{top:4,right:4}},{corner:"bottomLeft",style:{bottom:4,left:4}},{corner:"bottomRight",style:{bottom:4,right:4}}];return z("div",{ref:x,style:{position:"fixed",top:0,left:0,transform:`translate(${r.left}px, ${r.top}px)`,width:r.width,height:r.height,display:"flex",flexDirection:"column",backgroundColor:e.panel,borderRadius:16,border:H?`2px solid ${e.success}`:`1px solid ${e.border}`,boxShadow:H?`0 0 12px ${e.success}99`:`0 0 20px ${e.info}80, 0 8px 32px rgba(0,0,0,0.5)`,zIndex:b,opacity:W?1:0,transition:G,...c.container},children:[a("div",{onPointerDown:j,style:{minHeight:56,display:"flex",backgroundColor:e.panel,borderTopLeftRadius:14,borderTopRightRadius:14,borderBottom:"1px solid rgba(255, 255, 255, 0.1)",cursor:C?"grabbing":"grab",touchAction:"none",userSelect:"none"},children:a(U,{header:f,isResizing:H,mode:"floating",theme:e})}),a(_,{footer:y,footerHeight:l,disableScrollWrapper:g,contentStyle:c.content,theme:e,background:v,children:m}),B.map(({corner:i,style:u})=>a("div",{onPointerDown:X(i),style:{position:"absolute",width:30,height:30,zIndex:10,touchAction:"none",cursor:i==="topLeft"||i==="bottomRight"?"nwse-resize":"nesw-resize",...u},children:a(de,{isActive:H,theme:e})},i))]})}var he=t=>{let{visible:e,onClose:n,maxHeight:o,initialHeight:r=400,initialMode:s="bottomSheet",onModeChange:d,theme:p}=t,m={...ie,...p},{viewport:f,insets:c}=le(),[y,l]=R(s),[h,g]=R(r),[b,v]=R(()=>({width:380,height:500,left:(window.innerWidth-380)/2,top:(window.innerHeight-500)/2})),x=o||f.height-c.top,C=re(()=>{let S=y==="bottomSheet"?"floating":"bottomSheet";l(S),d?.(S)},n);return e?y==="floating"?a(ce,{props:t,theme:m,viewport:f,insets:c,rect:b,setRect:v,onHeaderTap:C}):a(se,{props:t,theme:m,viewport:f,effectiveMaxHeight:x,panelHeight:Math.min(h,x),setPanelHeight:g,onHeaderTap:C}):null};export{he as BottomSheet};
1
+ "use client";var pe=(()=>{try{let t=globalThis.Capacitor;if(t&&typeof t.isNativePlatform=="function"&&t.isNativePlatform())return t.DEBUG===true}catch{}return process.env.NODE_ENV!=="production"})();typeof window<"u"&&typeof globalThis.global>"u"&&(globalThis.global=globalThis);import{useState as C,useRef as H,useEffect as N}from"react";import{ToolBackground as Z}from"@buoy-gg/shared-ui/web";function ee(t){return t*.25}function te(t,e,n,o,r,s,d,p=80){let m=Math.max(0,s.left||0),f=r.width-Math.max(0,s.right||0),c=Math.max(0,s.top||0),y=r.height-Math.max(0,s.bottom||0),l=e.left+e.width,h=e.top+e.height,g=e.left,b=e.top,v=l,x=h;switch(t){case"topLeft":{g=Math.max(m,Math.min(e.left+n,l-d)),b=Math.max(c,Math.min(e.top+o,h-p));break}case"topRight":{v=Math.min(f,Math.max(l+n,e.left+d)),b=Math.max(c,Math.min(e.top+o,h-p));break}case"bottomLeft":{g=Math.max(m,Math.min(e.left+n,l-d)),x=Math.min(y,Math.max(h+o,e.top+p));break}case"bottomRight":{v=Math.min(f,Math.max(l+n,e.left+d)),x=Math.min(y,Math.max(h+o,e.top+p));break}}return{left:g,top:b,width:Math.max(d,v-g),height:Math.max(p,x-b)}}function oe(t,e,n,o){return t>.8&&e>50||e>150&&n<=o}import{useEffect as ne,useRef as B}from"react";function re(t,e){let n=B(0),o=B(0),r=B(null),s=B({onDouble:t,onTriple:e});return s.current={onDouble:t,onTriple:e},ne(()=>()=>{r.current&&clearTimeout(r.current)},[]),B(()=>{let d=Date.now();d-n.current>500&&(o.current=0),o.current++,n.current=d,r.current&&clearTimeout(r.current),r.current=setTimeout(()=>{o.current===2?s.current.onDouble():o.current>=3&&s.current.onTriple(),o.current=0},300)}).current}import{jsx as a,jsxs as z}from"react/jsx-runtime";var ie={background:"rgba(8, 12, 21, 0.98)",panel:"rgba(16, 22, 35, 0.98)",border:"#00B8E666",primary:"#FFFFFF",secondary:"#B8BFC9",muted:"#7A8599",success:"#4AFF9F",error:"#FF5252",info:"#00B8E6"};function ae(t){return window.addEventListener("resize",t),window.visualViewport?.addEventListener("resize",t),()=>{window.removeEventListener("resize",t),window.visualViewport?.removeEventListener("resize",t)}}function G(){return{width:window.innerWidth,height:window.innerHeight}}function U(){let t=document.createElement("div");t.style.cssText="position:fixed;visibility:hidden;pointer-events:none;top:env(safe-area-inset-top);bottom:env(safe-area-inset-bottom);left:env(safe-area-inset-left);right:env(safe-area-inset-right)",document.body.appendChild(t);let e=getComputedStyle(t),n={top:parseFloat(e.top)||0,bottom:parseFloat(e.bottom)||0,left:parseFloat(e.left)||0,right:parseFloat(e.right)||0};return document.body.removeChild(t),n}function le(){let[t,e]=C(()=>({viewport:G(),insets:U()}));return N(()=>ae(()=>{e({viewport:G(),insets:U()})}),[]),t}function O(t,e){if(!t.isPrimary)return;let n=t.currentTarget,o=t.clientX,r=t.clientY,s=t.clientY,d=performance.now(),p=0,m=0;e.onStart?.(t),n.setPointerCapture(t.pointerId);let f=l=>{if(l.pointerId!==t.pointerId)return;let h=l.clientX-o,g=l.clientY-r;m=Math.max(m,Math.abs(h)+Math.abs(g));let b=performance.now(),v=b-d;v>0&&(p=(l.clientY-s)/v,s=l.clientY,d=b),e.onMove(l,{dx:h,dy:g})},c=l=>{l.pointerId===t.pointerId&&(y(),e.onEnd(l,{dx:l.clientX-o,dy:l.clientY-r,vy:p,wasTap:m<=5}))},y=()=>{n.removeEventListener("pointermove",f),n.removeEventListener("pointerup",c),n.removeEventListener("pointercancel",c)};n.addEventListener("pointermove",f),n.addEventListener("pointerup",c),n.addEventListener("pointercancel",c)}function _({isResizing:t,mode:e,hasCustomContent:n=false,theme:o}){return z("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",padding:n?"6px 0 2px":"8px 0",position:"relative"},children:[a("div",{style:{width:t?40:e==="floating"?50:40,height:e==="floating"?5:3,backgroundColor:t?o.success:e==="floating"?o.muted:o.info+"99",borderRadius:2,boxShadow:`0 0 4px ${o.info}CC`}}),t&&e==="bottomSheet"&&a("div",{style:{position:"absolute",display:"flex",flexDirection:"row",gap:2,marginTop:12},children:[0,1,2].map(r=>a("div",{style:{width:12,height:1,backgroundColor:o.success,opacity:.6}},r))})]})}function J({header:t,isResizing:e,mode:n,theme:o}){return t?.customContent?z("div",{style:{flex:1,display:"flex",flexDirection:"column",justifyContent:"center"},children:[a(_,{isResizing:e,mode:n,hasCustomContent:true,theme:o}),t.customContent]}):z("div",{style:{flex:1,display:"flex",flexDirection:"column",justifyContent:"center",position:"relative"},children:[a(_,{isResizing:e,mode:n,theme:o}),z("div",{style:{padding:"0 16px",display:"flex",flexDirection:"column",alignItems:"center"},children:[t?.title&&a("span",{style:{fontSize:16,fontWeight:600,color:o.primary},children:t.title}),t?.subtitle&&a("span",{style:{fontSize:12,color:o.secondary,paddingTop:4},children:t.subtitle})]}),a("div",{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"none"},children:a("span",{style:{fontSize:10,color:o.muted,fontStyle:"italic"},children:"Double tap: Toggle \u2022 Triple tap: Close"})})]})}function K({children:t,footer:e,footerHeight:n,disableScrollWrapper:o,contentStyle:r,theme:s,background:d}){return z("div",{style:{flex:1,minHeight:0,display:"flex",flexDirection:"column",backgroundColor:s.background,borderBottomLeftRadius:16,borderBottomRightRadius:16,overflow:"hidden",position:"relative",...r},children:[d?a(Z,{}):null,o?t:a("div",{style:{flex:1,minHeight:0,overflowY:"auto",WebkitOverflowScrolling:"touch",paddingBottom:n},children:t}),e?a("div",{style:{position:"absolute",left:0,right:0,bottom:0,backgroundColor:s.background,borderBottomLeftRadius:16,borderBottomRightRadius:16},children:e}):null]})}var Q="transform 320ms cubic-bezier(0.16, 1, 0.3, 1)",V="opacity 200ms ease";function se({props:t,theme:e,viewport:n,effectiveMaxHeight:o,panelHeight:r,setPanelHeight:s,onHeaderTap:d}){let{onClose:p,children:m,header:f,styles:c={},minHeight:y=100,footer:l,footerHeight:h=0,disableScrollWrapper:g,zIndex:b=1e3,background:v=true}=t,x=H(null),R=H(null),[S,Y]=C(false),[$,W]=C(false),A=H(false),E=H(r);N(()=>{let M=requestAnimationFrame(()=>W(true));return()=>cancelAnimationFrame(M)},[]);let L=M=>{if(A.current)return;let j=M.currentTarget.getBoundingClientRect().top,X=M.clientY-j;O(M,{onStart:()=>Y(true),onMove:k=>{let D=k.clientY-X,i=Math.max(y,Math.min(n.height-D,o));E.current=i,x.current&&(x.current.style.height=`${i}px`)},onEnd:(k,{dy:D,vy:i,wasTap:u})=>{if(Y(false),u){d();return}if(oe(i,D,E.current,y)){A.current=true;let T=R.current;T&&(T.style.transition=`${Q}, ${V}`,T.style.transform="translateY(100%)",T.style.opacity="0"),setTimeout(p,220);return}s(E.current)}})};return a("div",{style:{position:"fixed",inset:0,zIndex:b,pointerEvents:"none"},children:a("div",{ref:R,style:{position:"absolute",bottom:0,left:0,right:0,pointerEvents:"auto",transform:$?"translateY(0)":"translateY(100%)",opacity:$?1:0,transition:`${Q}, ${V}`},children:z("div",{ref:x,style:{display:"flex",flexDirection:"column",height:r,backgroundColor:e.panel,borderTopLeftRadius:16,borderTopRightRadius:16,border:`1px solid ${e.border}`,boxShadow:`0 -4px 12px ${e.info}4D, 0 -2px 24px rgba(0,0,0,0.4)`,...c.container},children:[a("div",{onPointerDown:L,style:{minHeight:56,display:"flex",backgroundColor:e.panel,borderTopLeftRadius:16,borderTopRightRadius:16,borderBottom:"1px solid rgba(255, 255, 255, 0.1)",cursor:S?"ns-resize":"grab",touchAction:"none",userSelect:"none"},children:a(J,{header:f,isResizing:S,mode:"bottomSheet",theme:e})}),a(K,{footer:l,footerHeight:h,disableScrollWrapper:g,contentStyle:c.content,theme:e,background:v,children:m})]})})})}function de({isActive:t,theme:e}){return a("div",{style:{width:20,height:20,borderRadius:10,margin:5,backgroundColor:t?e.success+"1A":"transparent",border:t?`2px solid ${e.success}`:"2px solid transparent",boxShadow:t?`0 0 8px ${e.success}99`:"none"}})}function ce({props:t,theme:e,viewport:n,insets:o,rect:r,setRect:s,onHeaderTap:d}){let{onClose:p,children:m,header:f,styles:c={},footer:y,footerHeight:l=0,onBack:h,disableScrollWrapper:g,zIndex:b=1e3,background:v=true}=t,x=H(null),[R,S]=C(false),[Y,$]=C(false),[W,A]=C(false),E=H(r);E.current=r;let L=H(r);N(()=>{let i=requestAnimationFrame(()=>A(true));return()=>cancelAnimationFrame(i)},[]);let M=i=>{L.current=i;let u=x.current;u&&(u.style.transform=`translate(${i.left}px, ${i.top}px)`,u.style.width=`${i.width}px`,u.style.height=`${i.height}px`)},j=i=>{let u=E.current,T=i.clientX-u.left,I=i.clientY-u.top;O(i,{onMove:(P,{dx:F,dy:w})=>{Math.abs(F)+Math.abs(w)>5&&S(true),M({...L.current,left:P.clientX-T,top:P.clientY-I})},onEnd:(P,{wasTap:F})=>{if(S(false),F){d();return}let w=L.current,q={...w,left:Math.max(o.left,Math.min(w.left,n.width-o.right-w.width)),top:Math.max(o.top,Math.min(w.top,n.height-o.bottom-w.height))};M(q),s(q)}})},X=i=>u=>{u.stopPropagation();let T={...E.current},I=false;O(u,{onStart:()=>$(true),onMove:(P,{dx:F,dy:w})=>{Math.abs(F)<.5&&Math.abs(w)<.5||(I=true,M(te(i,T,F,w,n,o,ee(n.width),80)))},onEnd:()=>{if($(false),!I){if(i==="topRight"){p();return}if(i==="topLeft"&&h){h();return}}s(L.current)}})},k=R||Y,D=[{corner:"topLeft",style:{top:4,left:4}},{corner:"topRight",style:{top:4,right:4}},{corner:"bottomLeft",style:{bottom:4,left:4}},{corner:"bottomRight",style:{bottom:4,right:4}}];return z("div",{ref:x,style:{position:"fixed",top:0,left:0,transform:`translate(${r.left}px, ${r.top}px)`,width:r.width,height:r.height,display:"flex",flexDirection:"column",backgroundColor:e.panel,borderRadius:16,border:k?`2px solid ${e.success}`:`1px solid ${e.border}`,boxShadow:k?`0 0 12px ${e.success}99`:`0 0 20px ${e.info}80, 0 8px 32px rgba(0,0,0,0.5)`,zIndex:b,opacity:W?1:0,transition:V,...c.container},children:[a("div",{onPointerDown:j,style:{minHeight:56,display:"flex",backgroundColor:e.panel,borderTopLeftRadius:14,borderTopRightRadius:14,borderBottom:"1px solid rgba(255, 255, 255, 0.1)",cursor:R?"grabbing":"grab",touchAction:"none",userSelect:"none"},children:a(J,{header:f,isResizing:k,mode:"floating",theme:e})}),a(K,{footer:y,footerHeight:l,disableScrollWrapper:g,contentStyle:c.content,theme:e,background:v,children:m}),D.map(({corner:i,style:u})=>a("div",{onPointerDown:X(i),style:{position:"absolute",width:30,height:30,zIndex:10,touchAction:"none",cursor:i==="topLeft"||i==="bottomRight"?"nwse-resize":"nesw-resize",...u},children:a(de,{isActive:k,theme:e})},i))]})}var he=t=>{let{visible:e,onClose:n,maxHeight:o,initialHeight:r=400,initialMode:s="bottomSheet",onModeChange:d,theme:p}=t,m={...ie,...p},{viewport:f,insets:c}=le(),[y,l]=C(s),[h,g]=C(r),[b,v]=C(()=>({width:380,height:500,left:(window.innerWidth-380)/2,top:(window.innerHeight-500)/2})),x=o||f.height-c.top,R=re(()=>{let S=y==="bottomSheet"?"floating":"bottomSheet";l(S),d?.(S)},n);return e?y==="floating"?a(ce,{props:t,theme:m,viewport:f,insets:c,rect:b,setRect:v,onHeaderTap:R}):a(se,{props:t,theme:m,viewport:f,effectiveMaxHeight:x,panelHeight:Math.min(h,x),setPanelHeight:g,onHeaderTap:R}):null};export{he as BottomSheet};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@buoy-gg/bottom-sheet",
3
- "version": "7.0.56",
3
+ "version": "7.0.58",
4
4
  "description": "Bottom sheet and floating window components for React Native, with configurable presentation and native-driver animations.",
5
5
  "main": "lib/commonjs/index.js",
6
6
  "module": "lib/module/index.js",
@@ -34,7 +34,7 @@
34
34
  ],
35
35
  "sideEffects": false,
36
36
  "dependencies": {
37
- "@buoy-gg/shared-ui": "^7.0.56"
37
+ "@buoy-gg/shared-ui": "^7.0.58"
38
38
  },
39
39
  "peerDependencies": {
40
40
  "react": "*"