@plainsheet/react 0.4.7 → 0.4.8

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.
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const k=require("react"),xt=require("react-dom");function At(t){return t!=null}(function(){try{if(typeof document<"u"){var t=document.createElement("style");t.appendChild(document.createTextNode('.pbs-root{position:fixed;left:0;bottom:0;display:flex;flex-direction:column;align-items:center;justify-content:flex-start;width:100%;height:fit-content;max-height:100vh;z-index:2}.pbs-dialog-reset{background-color:transparent;color:inherit;border:none;outline:none;padding:0;margin:0}.pbs-backdrop{position:fixed;top:0;left:0;width:100%;height:100%;background-color:transparent;z-index:1;transition:background-color .2s ease-out}.pbs-backdrop.hidden{visibility:hidden}.pbs-backdrop.open{background-color:#454545b3}.pbs-backdrop.transparent{background-color:transparent}.pbs-container{--pbs-container-background-color: rgb(240, 240, 240);background-color:var(--pbs-container-background-color);position:relative;display:none;flex-direction:column;align-items:center;justify-content:flex-start;width:92%;height:fit-content;max-height:100vh;border-radius:10px 10px 0 0}.pbs-container.open{display:flex}.pbs-container .pbs-gap-filler{position:absolute;bottom:calc(-100vh + .5px);left:0;background-color:var(--pbs-container-background-color);content:"";width:100%;height:100vh}.pbs-handle{position:relative;display:flex;align-items:center;justify-content:center;width:100%;height:30px;cursor:pointer}.pbs-handle.hidden{display:none}.pbs-button-reset{background-color:transparent;-webkit-appearance:none;-moz-appearance:none;appearance:none;outline:none;border:none}button:focus.pbs-button-reset{outline:none}.pbs-handle-bar{background-color:#a8a8a8;position:relative;width:12%;height:7px;border-radius:12px}.pbs-handle-bar.hidden{display:none}.pbs-content-wrapper{position:relative;width:100%;height:fit-content;max-height:100%;overflow-y:scroll}.pbs-content-wrapper::-webkit-scrollbar{display:none}.example{-ms-overflow-style:none;scrollbar-width:none}')),document.head.appendChild(t)}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();var Dt=Object.defineProperty,Bt=(t,e,n)=>e in t?Dt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,V=(t,e,n)=>Bt(t,typeof e!="symbol"?e+"":e,n);function A(t){return typeof t=="string"}function Mt(t,e){return t.classList.contains(et(e))}function z(t,e){t.classList.add(et(e))}function ot(t,e){t.classList.remove(et(e))}function X(t,e,n){A(n)&&(A(e)&&ot(t,e),z(t,n))}function et(t){return A(t)?t.trim().replace(/\./g,""):""}function N(t){return t.map(e=>et(e)).filter(Boolean).join(" ")}function Pt(t){return t.map(e=>e==null?void 0:e.trim()).filter(Boolean).map(e=>`.${e}`).join(" ")}const ut="open",dt="hidden";function nt(t,e){const n=e;if(Array.isArray(t)){t.forEach(o=>{J(o,n),o.setAttribute("aria-modal",n?"true":"false")});return}J(t,n),t.setAttribute("aria-modal",n?"true":"false")}function J(t,e){e?(z(t,ut),ot(t,dt)):(z(t,dt),ot(t,ut))}function St(t){return t instanceof HTMLElement}function D(t){return typeof t=="number"&&!Number.isNaN(t)}function Yt(t){St(t)&&t.focus()}function It(t){if(!St(t)||t.offsetParent===null||"disabled"in t&&t.disabled)return!1;const e=t.getAttribute("tabindex"),n=D(e)?parseInt(e,10):-1,o=["INPUT","BUTTON","SELECT","TEXTAREA","A","AREA","IFRAME"].includes(t.tagName),r=t instanceof HTMLAnchorElement&&t.href!==""||t instanceof HTMLAreaElement&&t.href!=="";return o||r||n>-1}var H=(t=>(t.Backdrop="pbs-backdrop",t.Root="pbs-root",t.Container="pbs-container",t.GapFiller="pbs-gap-filler",t.Handle="pbs-handle",t.HandleBar="pbs-handle-bar",t.ContentWrapper="pbs-content-wrapper",t))(H||{}),rt=(t=>(t.Button="pbs-button-reset",t.Dialog="pbs-dialog-reset",t))(rt||{}),K=(t=>(t.Hidden="hidden",t))(K||{});function P(t,e,n){const o=document.createElement(t);return e.split(" ").forEach(r=>{z(o,r)}),A(n)&&o.setAttribute("data-testid",n),o}Pt([H.Root,H.ContentWrapper]);function pt(t,e,n,o){switch(o){case"content-height":return e>=t?Et(t,e,n):0;case"middle":return-(t/2-e);case"top":return-(t-e)+n;default:return 0}}function yt(t,e){const n=e<t,o=e>t;return{isUp:n,isDown:o,stayedSame:e===t}}function Ct(t,e){return e<t?-(t-e):e-t}function Q(t,e){return t>e?t-e:e-t}function Rt(t,e){const n=t<e,o=t>e;return{isUp:n,isDown:o,stayedSame:t===e}}function ht(t,e,n){const o=t==="above";return n.filter(r=>{const i=r*e.viewportHeight;return o?e.visibleHeight<i:e.visibleHeight>i})}function Et(t,e,n){return-(t-e)+n}function mt(t){return Number(t.replace("px",""))}function Z(t,...e){return Number(t.toFixed(...e))}function wt(t){const e=/(?<type>\w+)\((?<values>[^)]+)\)/g,n=[];let o;for(;(o=e.exec(t))!==null;){const r=o[1],i=o[2].split(",").map(a=>a.trim());n.push({type:r,values:i})}return n}function Wt(t){const e=t.style.transform,n=wt(e);return{transform:e,transformValues:n}}function kt(t,e){return t.find(o=>o.type.startsWith(e))||null}const at="translate";function M(t){const e=t.style.transform,n=wt(e),o=kt(n,at);return Ht(o??{type:at,values:[]})}function tt(t,{x:e,y:n}){const{transform:o,transformValues:r}=Wt(t),i=kt(r,at);if(i){const a=Ht(i);t.style.transform=`translate(${e??a.x??0}px,${n??a.y??0}px)`;return}if(o){t.style.transform=`${o}, translate(${e??0}px,${n??0}px)`;return}t.style.transform=`translate(${e??0}px,${n??0}px)`}function Ht(t){if(t.type!=="translate")throw new Error(`Could not get coordinates from ${t.type}, since is not translate.`);const e=t.values[0],n=t.values[1];return{x:mt(e)??0,y:mt(n)??0}}function it(t){return t!=null}function bt(t,{min:e,max:n}){return it(n)&&t>=n?n:it(e)&&t<=e?e:t}const Nt=(t,e,n)=>{e instanceof HTMLElement&&!Mt(e,H.Handle)&&n.scrollTop>=1||(t.isDragging=!0)},Ft=(t,e,n,o)=>r=>{o.startY=t.getCoordinates(r).y,o.containerStartTranslate=M(e),n.onDragStart()},jt=(t,e,n,o,r)=>i=>{Ut(i,t,n,o,r,e,n.marginTop)};function Ut(t,e,n,o,r,i,a){if(!o.isDragging||!D(o.startY))return;const s=e.getCoordinates(t).y,u=Ct(o.startY,s),h=window.innerHeight,c=i.clientHeight,m=c-(o.containerStartTranslate.y+u);if(m>=h)return;const C=yt(o.startY,s);if(C.isUp&&!n.expandable&&m>=c)return;r.start(()=>{tt(i,{y:o.containerStartTranslate.y+u})},0);const l=h-a,E=c-o.containerStartTranslate.y;if(C.isUp){const g=l-E,S=l-m,w=bt(1-Z(S/g,2),{min:0,max:1});n.onDragMove(C,w)}else if(C.isDown){const g=bt(Z(1-m/E,2),{min:0,max:1});n.onDragMove(C,g)}}const $t=(t,e,n,o,r,i,a)=>s=>{if(!o.isDragging||(o.isDragging=!1,!D(o.startY)))return;n.onDragEnd();const u=o.startY,h=t.getCoordinates(s).y,c=M(e).y,m=yt(u,h),C=window.innerHeight,l=e.clientHeight;if(m.isUp){const E=[...n.snapPoints].sort((w,x)=>w-x),g=l+-c;if(!n.expandable&&g>=l)return;for(const w of E){const x=w*window.innerHeight;if(g<=x){const T=Q(g,x);a.translateContainer({startY:c,endY:c-T,animationFrame:r,bottomSheetContainer:e});return}}const S=Et(C,l,n.marginTop);a.translateContainer({startY:c,endY:S,animationFrame:r,bottomSheetContainer:e})}else if(m.isDown){const E=[...n.snapPoints].sort((g,S)=>S-g);for(const g of E){const S=g*window.innerHeight,w=l+-c;if(w>=S){const x=Q(w,S);a.translateContainer({startY:c,endY:c+x,animationFrame:r,bottomSheetContainer:e});return}}i()}};var U=(t=>(t[t.All=-1]="All",t[t.None=0]="None",t[t.Capture=1]="Capture",t[t.Target=2]="Target",t[t.Bubble=3]="Bubble",t))(U||{});function ft(t){switch(t){case 0:return 0;case 1:return 1;case 2:return 2;case 3:return 3;default:return-1}}const Gt={eventPhase:U.All};class q{constructor(e){V(this,"currentTarget"),this.currentTarget=e}addEventListeners({onStart:e,onStartOptions:n=Gt,onMove:o,onEnd:r}){this.addTouchEventListeners({onStart:e,onStartOptions:n,onMove:o,onEnd:r}),this.addMouseEventListeners({onStart:e,onStartOptions:n,onMove:o,onEnd:r})}addTouchEventListeners({onStart:e,onStartOptions:n,onMove:o,onEnd:r}){e&&this.currentTarget.addEventListener("touchstart",i=>{if(n.eventPhase===U.All){e(i);return}ft(i.eventPhase)===n.eventPhase&&e(i)},{passive:!0}),o&&this.currentTarget.addEventListener("touchmove",o),r&&this.currentTarget.addEventListener("touchend",r)}addMouseEventListeners({onStart:e,onStartOptions:n,onMove:o,onEnd:r}){e&&this.currentTarget.addEventListener("mousedown",i=>{if(n.eventPhase===U.All){e(i);return}ft(i.eventPhase)===n.eventPhase&&e(i)},{passive:!0}),o&&this.currentTarget.addEventListener("mousemove",o),r&&this.currentTarget.addEventListener("mouseup",i=>{r(i)})}removeEventListeners({onStart:e,onMove:n,onEnd:o}){e&&this.currentTarget.removeEventListener("touchstart",e),o&&this.currentTarget.removeEventListener("touchend",o),n&&this.currentTarget.removeEventListener("touchmove",n),e&&this.currentTarget.removeEventListener("mousedown",e),n&&this.currentTarget.removeEventListener("mousemove",n),o&&this.currentTarget.removeEventListener("mouseup",o)}getCoordinates(e){if(e.type==="touchstart"||e.type==="mousedown"){if("touches"in e)return{x:e.touches[0].clientX,y:e.touches[0].clientY};if(e instanceof MouseEvent)return{x:e.clientX,y:e.clientY}}if(e.type==="touchend"||e.type==="mouseup"||e.type==="mousemove"||e.type==="touchmove"){if("touches"in e)return{x:e.changedTouches[0].clientX,y:e.changedTouches[0].clientY};if(e instanceof MouseEvent)return{x:e.clientX,y:e.clientY}}return{x:0,y:0}}}function Tt(t){const e=t;return`${e} ${e} 0px 0px`}function _t(t,e){const n=Xt(t);qt(n),n.bottomSheetContainer.style.width=t.width;const o=document.createElement("div");o.innerHTML=t.content??"";const r=window.innerHeight;n.bottomSheetContainer.style.maxHeight=`${r}px`,n.bottomSheetContentWrapper.appendChild(o);const i=zt({bottomSheetElements:n,bottomSheetProps:t,options:e});return t.rootStyle&&Object.assign(n.bottomSheetRoot.style,t.rootStyle),t.backdropStyle&&Object.assign(n.bottomSheetBackdrop.style,t.backdropStyle),t.containerStyle&&Object.assign(n.bottomSheetContainer.style,t.containerStyle),t.handleStyle&&Object.assign(n.bottomSheetHandleBar.style,t.handleStyle),t.contentWrapperStyle&&Object.assign(n.bottomSheetContentWrapper.style,t.contentWrapperStyle),{elements:n,eventHandlers:i}}function Xt(t){const e=P("dialog",N([H.Root,rt.Dialog,t.rootClass]),H.Root);e.ariaLabel=t.ariaLabel;const n=P("section",N([H.Container,t.containerClass]),H.Container);t.containerBorderRadius&&(n.style.borderRadius=Tt(t.containerBorderRadius));const o=P("div",H.GapFiller,H.GapFiller),r=P("button",N([H.Handle,rt.Button,t.shouldShowHandle?null:K.Hidden,t.handleClass]),H.Handle);r.setAttribute("type","button"),r.ariaLabel="bottom sheet close button";const i=P("span",N([H.HandleBar,t.shouldShowHandle?null:K.Hidden]),H.HandleBar),a=P("article",N([H.ContentWrapper,t.contentWrapperClass]),H.ContentWrapper),s=P("div",N([H.Backdrop,t.backdropClass,K.Hidden]),H.Backdrop);return t.backdropColor&&(s.style.backgroundColor=t.backdropColor),t.backDropTransition&&(s.style.transition=t.backDropTransition),{bottomSheetRoot:e,bottomSheetBackdrop:s,bottomSheetContainer:n,bottomSheetHandle:r,bottomSheetHandleBar:i,bottomSheetContentWrapper:a,bottomSheetContainerGapFiller:o}}function qt({bottomSheetRoot:t,bottomSheetContainer:e,bottomSheetHandle:n,bottomSheetHandleBar:o,bottomSheetContentWrapper:r,bottomSheetContainerGapFiller:i}){t.appendChild(e),n.appendChild(o),e.appendChild(n),e.appendChild(r),e.appendChild(i)}function zt({bottomSheetElements:t,bottomSheetProps:e,options:n}){const{bottomSheetRoot:o,bottomSheetContainer:r,bottomSheetHandle:i,bottomSheetContainerGapFiller:a,bottomSheetContentWrapper:s,bottomSheetBackdrop:u}=t,{animationFrame:h}=n,c=new q(i),m=new q(s),C=new q(a),l=e.dragTriggers.reduce((O,y)=>{const v=o.querySelectorAll(y);if(!v.length)return O;const p=Array.from(v).map(d=>d instanceof HTMLElement?new q(d):null).filter(d=>!!d);return[...O,...p]},[]),E=new q(window),g=Ft(E,r,e,n.draggingState),S=jt(E,r,e,n.draggingState,h),w=$t(E,r,e,n.draggingState,h,n.onClose,n.bottomSheetState);function x(O){O.target instanceof Element&&!o.contains(O.target)&&n.onClose()}function T(O){Nt(n.draggingState,O.target,t.bottomSheetContentWrapper)}function Y(O){const y=O??e;y.draggable&&(c.addEventListeners({onStart:T}),l.forEach(v=>{v.addEventListeners({onStart:T,onStartOptions:{eventPhase:U.Target}})})),y.draggable&&y.backgroundDraggable&&(m.addEventListeners({onStart:T,onStartOptions:{eventPhase:U.Target}}),C.addEventListeners({onStart:T})),y.draggable&&E.addEventListeners({onStart:g,onMove:S,onEnd:w}),y.draggable&&window.document.addEventListener("keyup",v=>{v.key==="Escape"&&n.onClose()}),i.addEventListener("keyup",v=>{if(v.key==="ArrowUp"){n.moveUp();return}if(v.key==="ArrowDown"){n.moveDown();return}if(v.shiftKey&&v.key==="Tab"){const p=I(t.bottomSheetContentWrapper);Yt(p)}})}function G(){e.shouldCloseOnOutsideClick?u.addEventListener("click",x):u.style.pointerEvents="none"}function _(){u.removeEventListener("click",x)}function I(O){let y=[...Array.from(O.childNodes).reverse()];for(;y.length;){const v=y.shift();if(It(v))return v;v&&(y=[...y,...Array.from(v.childNodes).reverse()])}return null}function R(){c.removeEventListeners({onStart:T}),m.removeEventListeners({onStart:T}),C.removeEventListeners({onStart:T}),l.forEach(O=>{O.removeEventListeners({onStart:T})}),E.removeEventListeners({onStart:g,onMove:S,onEnd:w})}return{attachEventListeners:Y,clearEventListeners:R,attacheOnOpenEventListeners:G,clearOnOpenEventListeners:_}}class Vt{constructor(){V(this,"animationId"),V(this,"isInProgress"),V(this,"startedAt"),this.animationId=null,this.isInProgress=!1,this.startedAt=null}start(e,n,o=!1){this.isInProgress=!0;const r=i=>{this.startedAt||(this.startedAt=i);const a=i-this.startedAt,s=n===0?1:Z(a/n,2),u=s>=1&&!o;e(s),u?this.stop():this.animationId=requestAnimationFrame(r)};this.animationId=requestAnimationFrame(r)}stop(){this.isInProgress=!1,this.startedAt=null,D(this.animationId)&&cancelAnimationFrame(this.animationId)}}function Kt(t){const{startY:e,endY:n,bottomSheetContainer:o,animationFrame:r,onEnd:i,animationTimingFunction:a,animationDuration:s}=t,u=Ct(e,n);r.stop();let h=!1;r.start(c=>{tt(o,{y:e+u*a(c)}),!h&&c>=1&&(i==null||i(),h=!0)},s)}const st=(t,e)=>n=>{Kt({...n,animationTimingFunction:t,animationDuration:e})},j={TOP:"top",MIDDLE:"middle",CONTENT_HEIGHT:"content-height",CLOSED:"closed"};function Jt(t){return!(!D(t)||t>1||t<0)}function Qt(t,e){const n={set(o,r,i,a){return e(r,i),Reflect.set(o,r,i,a)}};return new Proxy(t,n)}function Zt(...t){console.error(t)}const F={EASE:"ease",EASE_IN:"ease-in",EASE_OUT:"ease-out",EASE_IN_OUT:"ease-in-out",SPRING:"spring"};function te(t){for(const e of Object.values(F))if(e===t)return!0;return!1}function Ot(t){return!!(t instanceof Object&&"p1x"in t&&"p1y"in t&&"p2x"in t&&"p2y"in t&&D(t.p1x)&&D(t.p1y)&&D(t.p2x)&&D(t.p2y))}function $(t,e,n,o){return function(s){return a(r(s))};function r(s){let u=0,h=1,c=s,m;if(s===0||s===1)return s;for(;u<h;){if(m=i(c),Math.abs(m-s)<.001)return c;s>m?u=c:h=c,c=(h+u)/2}return c}function i(s){return 3*t*s*Math.pow(1-s,2)+3*n*Math.pow(s,2)*(1-s)+Math.pow(s,3)}function a(s){return 3*e*s*Math.pow(1-s,2)+3*o*Math.pow(s,2)*(1-s)+Math.pow(s,3)}}const gt=$(.25,.1,.25,1),ee=$(.42,0,1,1),Lt=$(.42,0,.58,1),ne=$(.4,.1,.6,1),oe=$(.45,1.5,.55,1);function re(t){switch(t){case F.EASE:return gt;case F.EASE_IN:return ee;case F.EASE_OUT:return Lt;case F.EASE_IN_OUT:return ne;case F.SPRING:return oe;default:return gt}}function vt(t){return typeof t=="boolean"}const ae={ariaLabel:"Bottom sheet",content:"",defaultPosition:j.CONTENT_HEIGHT,marginTop:20,snapPoints:[],width:"92%",dragTriggers:[],beforeOpen:()=>{},afterOpen:()=>{},beforeClose:()=>{},afterClose:()=>{},onDragStart:()=>{},onDragMove:()=>{},onDragEnd:()=>{},expandable:!0,draggable:!0,backgroundDraggable:!0,shouldCloseOnOutsideClick:!0,shouldShowBackdrop:!0,shouldShowHandle:!0,backDropTransition:null,backdropColor:null,containerBorderRadius:null,rootClass:null,containerClass:null,handleClass:null,contentWrapperClass:null,backdropClass:null,draggingAnimationTimings:"ease-in-out",draggingAnimationDuration:180,rootStyle:{},containerStyle:{},handleStyle:{},contentWrapperStyle:{},backdropStyle:{}};function ie(t){const e={...ae},n=Object.entries(t).reduce((o,r)=>{const[i,a]=r;return it(a)&&(o[i]=a),o},{});return{...e,...n}}function ct(t){if(Ot(t)){const{p1x:e,p1y:n,p2x:o,p2y:r}=t;return $(e,n,o,r)}return te(t)?re(t):Lt}function se(t,e,n,o){function r(i,a){switch(i){case"content":A(a)&&(t.bottomSheetContentWrapper.innerHTML=a);break;case"width":A(a)&&(t.bottomSheetContainer.style.width=a);break;case"shouldShowHandle":vt(a)||J(t.bottomSheetHandle,!1);break;case"shouldShowBackdrop":vt(a)||J(t.bottomSheetBackdrop,!1);break;case"containerBorderRadius":A(a)&&(t.bottomSheetContainer.style.borderRadius=Tt(a));break;case"backdropColor":A(a)&&(t.bottomSheetBackdrop.style.backgroundColor=a);break;case"backDropTransition":A(a)&&(t.bottomSheetBackdrop.style.transition=a);break;case"rootClass":if(!A(a))return;X(t.bottomSheetRoot,n.rootClass,a);break;case"containerClass":if(!A(a))return;X(t.bottomSheetContainer,n.containerClass,a);break;case"handleClass":if(!A(a))return;X(t.bottomSheetHandle,n.handleClass,a);break;case"contentWrapperClass":if(!A(a))return;X(t.bottomSheetContentWrapper,n.contentWrapperClass,a);break;case"backdropClass":if(!A(a))return;X(t.bottomSheetBackdrop,n.backdropClass,a);break;case"expandable":o.clearEventListeners(),o.attachEventListeners(n);break;case"draggable":o.clearEventListeners(),o.attachEventListeners(n);break;case"draggingAnimationTimings":if(Ot(a)){const s=ct(a),u=st(s,n.draggingAnimationDuration);e.translateContainer=u}break;case"draggingAnimationDuration":if(D(a)){const s=ct(n.draggingAnimationTimings),u=st(s,a);e.translateContainer=u}break;case"rootStyle":n.rootStyle&&Object.assign(t.bottomSheetRoot.style,n.rootStyle);break;case"backdropStyle":n.backdropStyle&&Object.assign(t.bottomSheetBackdrop.style,n.backdropStyle);break;case"containerStyle":n.containerStyle&&Object.assign(t.bottomSheetContainer.style,n.containerStyle);break;case"handleStyle":n.handleStyle&&Object.assign(t.bottomSheetHandleBar.style,n.handleStyle);break;case"contentWrapperStyle":n.contentWrapperStyle&&Object.assign(t.bottomSheetContentWrapper.style,n.contentWrapperStyle);break}}return r}function ce(t){const e=ie(t),n=ct(t.draggingAnimationTimings),o={isMounted:!1,translateContainer:st(n,e.draggingAnimationDuration)},r={startY:null,containerStartTranslate:{x:0,y:0},isDragging:!1,originalDocumentOverflowY:null,originalDocumentOverscrollBehavior:null};function i(){r.originalDocumentOverflowY&&r.originalDocumentOverflowY!=="hidden"&&(document.body.style.overflowY=r.originalDocumentOverflowY),r.originalDocumentOverscrollBehavior&&(document.body.style.position=r.originalDocumentOverscrollBehavior)}const a=new Vt,s={animationFrame:a,onClose:w,bottomSheetState:o,draggingState:r,snapTo:v,moveUp:O,moveDown:y},{elements:u,eventHandlers:h}=_t(e,s),c=Qt(e,se(u,o,e,h)),{bottomSheetBackdrop:m,bottomSheetRoot:C,bottomSheetContainer:l}=u,E=p=>{const d=p??window.document.body;d.appendChild(C),d.appendChild(m);const b=window.innerHeight;tt(l,{y:b}),h.attachEventListeners(),o.isMounted=!0},g=()=>{h.clearEventListeners(),Object.values(u).forEach(p=>{p.remove()}),i(),o.isMounted=!1},S=()=>{var p;if(x()||Zt('Bottom Sheet is not mounted yet. call the "mount" method first.'),(p=t.beforeOpen)==null||p.call(t),T())return;nt(m,!0),c.shouldShowBackdrop||z(m,"transparent"),nt([l],!0),tt(l,{y:l.clientHeight});const d=window.innerHeight,b=pt(d,l.clientHeight,c.marginTop,c.defaultPosition),f=M(l).y;o.translateContainer({startY:f,endY:b,animationFrame:a,bottomSheetContainer:l,onEnd:t.afterOpen});const L=document.body.style.overflowY;r.originalDocumentOverflowY=L||"initial";const B=document.body.style.overscrollBehavior;r.originalDocumentOverscrollBehavior=B||"initial",document.body.style.overflow="hidden",document.body.style.overscrollBehavior="contain",u.bottomSheetHandle.focus(),h.attacheOnOpenEventListeners()};function w(){var p;if(Y())return;(p=t.beforeClose)==null||p.call(t);const d=M(l).y,b=l.clientHeight;o.translateContainer({startY:d,endY:b,animationFrame:a,bottomSheetContainer:l,onEnd:()=>{var f;(f=t.afterClose)==null||f.call(t),nt([m,l],!1),h.clearOnOpenEventListeners()}}),i()}function x(){return o.isMounted}function T(){const p=M(l).y,d=window.innerHeight,b=l.clientHeight>=d?d:l.clientHeight;return p<=b}function Y(){return!T()}function G(){const p=M(l).y,d=l.clientHeight,b=window.innerHeight;if(p<=5&&p>=-5)return j.CONTENT_HEIGHT;const f=d-p;if(f===b/2)return j.MIDDLE;const L=b-c.marginTop,B=10;return f<=L+B&&f>=L-B?j.TOP:j.CLOSED}function _(){return l.clientHeight}function I(p){if(!T())return;const d=M(l).y,b=l.clientHeight-d,f=window.innerHeight-p,L=Rt(b,f),B=Q(b,f);o.translateContainer({startY:d,endY:d+(L.isUp?-B:B),animationFrame:a,bottomSheetContainer:l})}function R(p,{viewportHeight:d,visibleHeight:b}){let f=null;for(const L of p){const B=L*d,W=Q(b,B);(f===null||W<f)&&(f=W)}return{minOffset:f}}function O(){const p=[...c.snapPoints].reverse(),d=M(l).y,b=l.clientHeight,f=b-d;if(!c.expandable&&f>=b)return;const L=window.innerHeight,B=ht("above",{visibleHeight:f,viewportHeight:L},p),{minOffset:W}=R(B,{visibleHeight:f,viewportHeight:L});if(W===null&&f<L-c.marginTop){o.translateContainer({startY:d,endY:pt(L,b,c.marginTop,"top"),animationFrame:a,bottomSheetContainer:l});return}D(W)&&o.translateContainer({startY:d,endY:d-W,animationFrame:a,bottomSheetContainer:l})}function y(){const p=M(l).y,d=l.clientHeight-p;if(d<1)return;const b=window.innerHeight,f=ht("below",{visibleHeight:d,viewportHeight:b},c.snapPoints),{minOffset:L}=R(f,{visibleHeight:d,viewportHeight:b});D(L)&&o.translateContainer({startY:p,endY:p+L,animationFrame:a,bottomSheetContainer:l})}function v(p){const d=window.innerHeight;if(!Jt(p))return;const b=Z(d*p,2);I(b)}return{props:c,elements:u,mount:E,unmount:g,open:S,close:w,getIsMounted:x,getIsOpen:T,getIsClosed:Y,getPosition:G,getHeight:_,moveTo:I,snapTo:v}}function lt(){return{elements:{bottomSheetRoot:void 0,bottomSheetBackdrop:void 0,bottomSheetContainer:void 0,bottomSheetHandle:void 0,bottomSheetHandleBar:void 0,bottomSheetContentWrapper:void 0,bottomSheetContainerGapFiller:void 0},mount:()=>{},unmount:()=>{},open:()=>{},close:()=>{},getIsMounted:()=>!1,getHeight:()=>0,getIsOpen:()=>!1,getIsClosed:()=>!0,getPosition:()=>j.CLOSED,moveTo:()=>{},snapTo:()=>{},props:{content:""}}}const le=lt(),ue=k.forwardRef(function(e,n){const{children:o,isOpen:r,setIsOpen:i,afterClose:a,mountingPointRef:s,...u}=e,h=k.useRef(le),[c,m]=k.useState(h.current);k.useImperativeHandle(n,()=>c,[c]);const C=k.useCallback(()=>{i(!1),a==null||a()},[a]);k.useEffect(()=>{r?c.open():c.close()},[r]);const l=k.useRef(null);return k.useEffect(function(){var w;if(s&&!s.current)return;const g=At((w=e.mountingPointRef)==null?void 0:w.current)?e.mountingPointRef.current:window.document.body;if(!g||c.getIsMounted())return;const S=ce({content:"",...u,afterClose:C});return S.mount(g),l.current=S.elements.bottomSheetContentWrapper??null,h.current=S,m(S),()=>{c.unmount()}},[e.mountingPointRef,u,C]),k.useEffect(function(){Object.assign(h.current.props,{...u}),m(h.current)},[u]),k.useEffect(function(){return()=>{h.current.unmount()}},[]),l.current?xt.createPortal(e.children,l.current):null}),de=lt();function pe(t={}){const e=k.useRef(de),[n,o]=k.useState(!1),[r,i]=k.useState(e.current);k.useEffect(()=>{i(e.current)},[e.current]);const{beforeOpen:a,afterOpen:s,beforeClose:u,afterClose:h,onDragStart:c,onDragMove:m,onDragEnd:C,...l}=t,E=()=>{a==null||a()},g=()=>{s==null||s(),o(!0)},S=()=>{u==null||u()},w=()=>{h==null||h(),o(!1)},x=()=>{c==null||c()},T=(y,v)=>{m==null||m(y,v)},Y=()=>{C==null||C()},G=k.useMemo(()=>({ref:e,isOpen:n,setIsOpen:o,beforeOpen:E,afterOpen:g,beforeClose:S,afterClose:w,onDragStart:x,onDragMove:T,onDragEnd:Y,...l}),[e.current,n,o,t]),_=k.useCallback(()=>{o(!0)},[o]),I=k.useCallback(()=>{o(!0)},[o]),R=k.useCallback((...y)=>{r.moveTo(...y)},[r]),O=k.useCallback((...y)=>{r.snapTo(...y)},[r]);return{props:G,instance:r,isOpen:n,setIsOpen:o,open:_,close:I,moveTo:R,snapTo:O}}exports.BottomSheet=ue;exports.createPlaceholderBottomSheet=lt;exports.useBottomSheet=pe;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const k=require("react"),xt=require("react-dom");function At(t){return t!=null}(function(){try{if(typeof document<"u"){var t=document.createElement("style");t.appendChild(document.createTextNode('.pbs-root{position:fixed;left:0;bottom:0;display:flex;flex-direction:column;align-items:center;justify-content:flex-start;width:100%;height:fit-content;max-height:100vh;z-index:2}.pbs-dialog-reset{background-color:transparent;color:inherit;border:none;outline:none;padding:0;margin:0}.pbs-backdrop{position:fixed;top:0;left:0;width:100%;height:100%;background-color:transparent;z-index:1;transition:background-color .2s ease-out}.pbs-backdrop.hidden{visibility:hidden}.pbs-backdrop.open{background-color:#454545b3}.pbs-backdrop.transparent{background-color:transparent}.pbs-container{--pbs-container-background-color: rgb(240, 240, 240);background-color:var(--pbs-container-background-color);position:relative;display:none;flex-direction:column;align-items:center;justify-content:flex-start;width:92%;height:fit-content;max-height:100vh;border-radius:10px 10px 0 0}.pbs-container.open{display:flex}.pbs-container .pbs-gap-filler{position:absolute;bottom:calc(-100vh + .5px);left:0;background-color:var(--pbs-container-background-color);content:"";width:100%;height:100vh}.pbs-handle{position:relative;display:flex;align-items:center;justify-content:center;width:100%;height:30px;cursor:pointer}.pbs-handle.hidden{display:none}.pbs-button-reset{background-color:transparent;-webkit-appearance:none;-moz-appearance:none;appearance:none;outline:none;border:none}button:focus.pbs-button-reset{outline:none}.pbs-handle-bar{background-color:#a8a8a8;position:relative;width:12%;height:7px;border-radius:12px}.pbs-handle-bar.hidden{display:none}.pbs-content-wrapper{position:relative;width:100%;height:fit-content;max-height:100%;overflow-y:scroll}.pbs-content-wrapper::-webkit-scrollbar{display:none}.example{-ms-overflow-style:none;scrollbar-width:none}')),document.head.appendChild(t)}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();var Dt=Object.defineProperty,Bt=(t,e,n)=>e in t?Dt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,K=(t,e,n)=>Bt(t,typeof e!="symbol"?e+"":e,n);function A(t){return typeof t=="string"}function Mt(t,e){return t.classList.contains(et(e))}function V(t,e){t.classList.add(et(e))}function ot(t,e){t.classList.remove(et(e))}function X(t,e,n){A(n)&&(A(e)&&ot(t,e),V(t,n))}function et(t){return A(t)?t.trim().replace(/\./g,""):""}function N(t){return t.map(e=>et(e)).filter(Boolean).join(" ")}function Pt(t){return t.map(e=>e==null?void 0:e.trim()).filter(Boolean).map(e=>`.${e}`).join(" ")}const ut="open",dt="hidden";function nt(t,e){const n=e;if(Array.isArray(t)){t.forEach(o=>{Q(o,n),o.setAttribute("aria-modal",n?"true":"false")});return}Q(t,n),t.setAttribute("aria-modal",n?"true":"false")}function Q(t,e){e?(V(t,ut),ot(t,dt)):(V(t,dt),ot(t,ut))}function St(t){return t instanceof HTMLElement}function D(t){return typeof t=="number"&&!Number.isNaN(t)}function Yt(t){St(t)&&t.focus()}function It(t){if(!St(t)||t.offsetParent===null||"disabled"in t&&t.disabled)return!1;const e=t.getAttribute("tabindex"),n=D(e)?parseInt(e,10):-1,o=["INPUT","BUTTON","SELECT","TEXTAREA","A","AREA","IFRAME"].includes(t.tagName),r=t instanceof HTMLAnchorElement&&t.href!==""||t instanceof HTMLAreaElement&&t.href!=="";return o||r||n>-1}var T=(t=>(t.Backdrop="pbs-backdrop",t.Root="pbs-root",t.Container="pbs-container",t.GapFiller="pbs-gap-filler",t.Handle="pbs-handle",t.HandleBar="pbs-handle-bar",t.ContentWrapper="pbs-content-wrapper",t))(T||{}),rt=(t=>(t.Button="pbs-button-reset",t.Dialog="pbs-dialog-reset",t))(rt||{}),J=(t=>(t.Hidden="hidden",t))(J||{});function P(t,e,n){const o=document.createElement(t);return e.split(" ").forEach(r=>{V(o,r)}),A(n)&&o.setAttribute("data-testid",n),o}Pt([T.Root,T.ContentWrapper]);function pt(t,e,n,o){switch(o){case"content-height":return e>=t?Et(t,e,n):0;case"middle":return-(t/2-e);case"top":return-(t-e)+n;default:return 0}}function yt(t,e){const n=e<t,o=e>t;return{isUp:n,isDown:o,stayedSame:e===t}}function Ct(t,e){return e<t?-(t-e):e-t}function z(t,e){return t>e?t-e:e-t}function Rt(t,e){const n=t<e,o=t>e;return{isUp:n,isDown:o,stayedSame:t===e}}function ht(t,e,n){const o=t==="above";return n.filter(r=>{const i=r*e.viewportHeight;return o?e.visibleHeight<i:e.visibleHeight>i})}function Et(t,e,n){return-(t-e)+n}function mt(t){return Number(t.replace("px",""))}function Z(t,...e){return Number(t.toFixed(...e))}function wt(t){const e=/(?<type>\w+)\((?<values>[^)]+)\)/g,n=[];let o;for(;(o=e.exec(t))!==null;){const r=o[1],i=o[2].split(",").map(a=>a.trim());n.push({type:r,values:i})}return n}function Wt(t){const e=t.style.transform,n=wt(e);return{transform:e,transformValues:n}}function kt(t,e){return t.find(o=>o.type.startsWith(e))||null}const at="translate";function M(t){const e=t.style.transform,n=wt(e),o=kt(n,at);return Tt(o??{type:at,values:[]})}function tt(t,{x:e,y:n}){const{transform:o,transformValues:r}=Wt(t),i=kt(r,at);if(i){const a=Tt(i);t.style.transform=`translate(${e??a.x??0}px,${n??a.y??0}px)`;return}if(o){t.style.transform=`${o}, translate(${e??0}px,${n??0}px)`;return}t.style.transform=`translate(${e??0}px,${n??0}px)`}function Tt(t){if(t.type!=="translate")throw new Error(`Could not get coordinates from ${t.type}, since is not translate.`);const e=t.values[0],n=t.values[1];return{x:mt(e)??0,y:mt(n)??0}}function it(t){return t!=null}function bt(t,{min:e,max:n}){return it(n)&&t>=n?n:it(e)&&t<=e?e:t}const Nt=(t,e,n)=>{e instanceof HTMLElement&&!Mt(e,T.Handle)&&n.scrollTop>=1||(t.isDragging=!0)},Ft=(t,e,n,o)=>r=>{o.startY=t.getCoordinates(r).y,o.containerStartTranslate=M(e),n.onDragStart()},jt=(t,e,n,o,r)=>i=>{Ut(i,t,n,o,r,e,n.marginTop)};function Ut(t,e,n,o,r,i,a){if(!o.isDragging||!D(o.startY))return;const c=e.getCoordinates(t).y,u=Ct(o.startY,c),h=window.innerHeight,s=i.clientHeight,m=s-(o.containerStartTranslate.y+u);if(m>=h)return;const C=yt(o.startY,c);if(C.isUp&&!n.expandable&&m>=s||n.preventClosing&&m<=s)return;r.start(()=>{tt(i,{y:o.containerStartTranslate.y+u})},0);const l=h-a,E=s-o.containerStartTranslate.y;if(C.isUp){const b=l-E,v=l-m,w=bt(1-Z(v/b,2),{min:0,max:1});n.onDragMove(C,w)}else if(C.isDown){const b=bt(Z(1-m/E,2),{min:0,max:1});n.onDragMove(C,b)}}const $t=(t,e,n,o,r,i,a)=>c=>{if(!o.isDragging||(o.isDragging=!1,!D(o.startY)))return;n.onDragEnd();const u=o.startY,h=t.getCoordinates(c).y,s=M(e).y,m=yt(u,h),C=window.innerHeight,l=e.clientHeight;if(m.isUp){const E=[...n.snapPoints].sort((w,x)=>w-x),b=l+-s;if(!n.expandable&&b>=l)return;for(const w of E){const x=w*window.innerHeight;if(b<=x){const H=z(b,x);a.translateContainer({startY:s,endY:s-H,animationFrame:r,bottomSheetContainer:e});return}}const v=Et(C,l,n.marginTop);a.translateContainer({startY:s,endY:v,animationFrame:r,bottomSheetContainer:e})}else if(m.isDown){const E=[...n.snapPoints].sort((b,v)=>v-b);for(const b of E){const v=b*window.innerHeight,w=l+-s;if(w>=v){const x=z(w,v);a.translateContainer({startY:s,endY:s+x,animationFrame:r,bottomSheetContainer:e});return}}if(n.preventClosing){const b=l+-s;if(b>=l){const v=z(b,l);a.translateContainer({startY:s,endY:s+v,animationFrame:r,bottomSheetContainer:e})}return}i()}};var U=(t=>(t[t.All=-1]="All",t[t.None=0]="None",t[t.Capture=1]="Capture",t[t.Target=2]="Target",t[t.Bubble=3]="Bubble",t))(U||{});function ft(t){switch(t){case 0:return 0;case 1:return 1;case 2:return 2;case 3:return 3;default:return-1}}const Gt={eventPhase:U.All};class q{constructor(e){K(this,"currentTarget"),this.currentTarget=e}addEventListeners({onStart:e,onStartOptions:n=Gt,onMove:o,onEnd:r}){this.addTouchEventListeners({onStart:e,onStartOptions:n,onMove:o,onEnd:r}),this.addMouseEventListeners({onStart:e,onStartOptions:n,onMove:o,onEnd:r})}addTouchEventListeners({onStart:e,onStartOptions:n,onMove:o,onEnd:r}){e&&this.currentTarget.addEventListener("touchstart",i=>{if(n.eventPhase===U.All){e(i);return}ft(i.eventPhase)===n.eventPhase&&e(i)},{passive:!0}),o&&this.currentTarget.addEventListener("touchmove",o),r&&this.currentTarget.addEventListener("touchend",r)}addMouseEventListeners({onStart:e,onStartOptions:n,onMove:o,onEnd:r}){e&&this.currentTarget.addEventListener("mousedown",i=>{if(n.eventPhase===U.All){e(i);return}ft(i.eventPhase)===n.eventPhase&&e(i)},{passive:!0}),o&&this.currentTarget.addEventListener("mousemove",o),r&&this.currentTarget.addEventListener("mouseup",i=>{r(i)})}removeEventListeners({onStart:e,onMove:n,onEnd:o}){e&&this.currentTarget.removeEventListener("touchstart",e),o&&this.currentTarget.removeEventListener("touchend",o),n&&this.currentTarget.removeEventListener("touchmove",n),e&&this.currentTarget.removeEventListener("mousedown",e),n&&this.currentTarget.removeEventListener("mousemove",n),o&&this.currentTarget.removeEventListener("mouseup",o)}getCoordinates(e){if(e.type==="touchstart"||e.type==="mousedown"){if("touches"in e)return{x:e.touches[0].clientX,y:e.touches[0].clientY};if(e instanceof MouseEvent)return{x:e.clientX,y:e.clientY}}if(e.type==="touchend"||e.type==="mouseup"||e.type==="mousemove"||e.type==="touchmove"){if("touches"in e)return{x:e.changedTouches[0].clientX,y:e.changedTouches[0].clientY};if(e instanceof MouseEvent)return{x:e.clientX,y:e.clientY}}return{x:0,y:0}}}function Ht(t){const e=t;return`${e} ${e} 0px 0px`}function _t(t,e){const n=Xt(t);qt(n),n.bottomSheetContainer.style.width=t.width;const o=document.createElement("div");o.innerHTML=t.content??"";const r=window.innerHeight;n.bottomSheetContainer.style.maxHeight=`${r}px`,n.bottomSheetContentWrapper.appendChild(o);const i=zt({bottomSheetElements:n,bottomSheetProps:t,options:e});return t.rootStyle&&Object.assign(n.bottomSheetRoot.style,t.rootStyle),t.backdropStyle&&Object.assign(n.bottomSheetBackdrop.style,t.backdropStyle),t.containerStyle&&Object.assign(n.bottomSheetContainer.style,t.containerStyle),t.handleStyle&&Object.assign(n.bottomSheetHandleBar.style,t.handleStyle),t.contentWrapperStyle&&Object.assign(n.bottomSheetContentWrapper.style,t.contentWrapperStyle),{elements:n,eventHandlers:i}}function Xt(t){const e=P("dialog",N([T.Root,rt.Dialog,t.rootClass]),T.Root);e.ariaLabel=t.ariaLabel;const n=P("section",N([T.Container,t.containerClass]),T.Container);t.containerBorderRadius&&(n.style.borderRadius=Ht(t.containerBorderRadius));const o=P("div",T.GapFiller,T.GapFiller),r=P("button",N([T.Handle,rt.Button,t.shouldShowHandle?null:J.Hidden,t.handleClass]),T.Handle);r.setAttribute("type","button"),r.ariaLabel="bottom sheet close button";const i=P("span",N([T.HandleBar,t.shouldShowHandle?null:J.Hidden]),T.HandleBar),a=P("article",N([T.ContentWrapper,t.contentWrapperClass]),T.ContentWrapper),c=P("div",N([T.Backdrop,t.backdropClass,J.Hidden]),T.Backdrop);return t.backdropColor&&(c.style.backgroundColor=t.backdropColor),t.backDropTransition&&(c.style.transition=t.backDropTransition),{bottomSheetRoot:e,bottomSheetBackdrop:c,bottomSheetContainer:n,bottomSheetHandle:r,bottomSheetHandleBar:i,bottomSheetContentWrapper:a,bottomSheetContainerGapFiller:o}}function qt({bottomSheetRoot:t,bottomSheetContainer:e,bottomSheetHandle:n,bottomSheetHandleBar:o,bottomSheetContentWrapper:r,bottomSheetContainerGapFiller:i}){t.appendChild(e),n.appendChild(o),e.appendChild(n),e.appendChild(r),e.appendChild(i)}function zt({bottomSheetElements:t,bottomSheetProps:e,options:n}){const{bottomSheetRoot:o,bottomSheetContainer:r,bottomSheetHandle:i,bottomSheetContainerGapFiller:a,bottomSheetContentWrapper:c,bottomSheetBackdrop:u}=t,{animationFrame:h}=n,s=new q(i),m=new q(c),C=new q(a),l=e.dragTriggers.reduce((O,y)=>{const S=o.querySelectorAll(y);if(!S.length)return O;const p=Array.from(S).map(d=>d instanceof HTMLElement?new q(d):null).filter(d=>!!d);return[...O,...p]},[]),E=new q(window),b=Ft(E,r,e,n.draggingState),v=jt(E,r,e,n.draggingState,h),w=$t(E,r,e,n.draggingState,h,n.onClose,n.bottomSheetState);function x(O){O.target instanceof Element&&!o.contains(O.target)&&n.onClose()}function H(O){Nt(n.draggingState,O.target,t.bottomSheetContentWrapper)}function Y(O){const y=O??e;y.draggable&&(s.addEventListeners({onStart:H}),l.forEach(S=>{S.addEventListeners({onStart:H,onStartOptions:{eventPhase:U.Target}})})),y.draggable&&y.backgroundDraggable&&(m.addEventListeners({onStart:H,onStartOptions:{eventPhase:U.Target}}),C.addEventListeners({onStart:H})),y.draggable&&E.addEventListeners({onStart:b,onMove:v,onEnd:w}),y.draggable&&window.document.addEventListener("keyup",S=>{S.key==="Escape"&&n.onClose()}),i.addEventListener("keyup",S=>{if(S.key==="ArrowUp"){n.moveUp();return}if(S.key==="ArrowDown"){n.moveDown();return}if(S.shiftKey&&S.key==="Tab"){const p=I(t.bottomSheetContentWrapper);Yt(p)}})}function G(){e.shouldCloseOnOutsideClick?u.addEventListener("click",x):u.style.pointerEvents="none"}function _(){u.removeEventListener("click",x)}function I(O){let y=[...Array.from(O.childNodes).reverse()];for(;y.length;){const S=y.shift();if(It(S))return S;S&&(y=[...y,...Array.from(S.childNodes).reverse()])}return null}function R(){s.removeEventListeners({onStart:H}),m.removeEventListeners({onStart:H}),C.removeEventListeners({onStart:H}),l.forEach(O=>{O.removeEventListeners({onStart:H})}),E.removeEventListeners({onStart:b,onMove:v,onEnd:w})}return{attachEventListeners:Y,clearEventListeners:R,attacheOnOpenEventListeners:G,clearOnOpenEventListeners:_}}class Vt{constructor(){K(this,"animationId"),K(this,"isInProgress"),K(this,"startedAt"),this.animationId=null,this.isInProgress=!1,this.startedAt=null}start(e,n,o=!1){this.isInProgress=!0;const r=i=>{this.startedAt||(this.startedAt=i);const a=i-this.startedAt,c=n===0?1:Z(a/n,2),u=c>=1&&!o;e(c),u?this.stop():this.animationId=requestAnimationFrame(r)};this.animationId=requestAnimationFrame(r)}stop(){this.isInProgress=!1,this.startedAt=null,D(this.animationId)&&cancelAnimationFrame(this.animationId)}}function Kt(t){const{startY:e,endY:n,bottomSheetContainer:o,animationFrame:r,onEnd:i,animationTimingFunction:a,animationDuration:c}=t,u=Ct(e,n);r.stop();let h=!1;r.start(s=>{tt(o,{y:e+u*a(s)}),!h&&s>=1&&(i==null||i(),h=!0)},c)}const st=(t,e)=>n=>{Kt({...n,animationTimingFunction:t,animationDuration:e})},j={TOP:"top",MIDDLE:"middle",CONTENT_HEIGHT:"content-height",CLOSED:"closed"};function Jt(t){return!(!D(t)||t>1||t<0)}function Qt(t,e){const n={set(o,r,i,a){return e(r,i),Reflect.set(o,r,i,a)}};return new Proxy(t,n)}function Zt(...t){console.error(t)}const F={EASE:"ease",EASE_IN:"ease-in",EASE_OUT:"ease-out",EASE_IN_OUT:"ease-in-out",SPRING:"spring"};function te(t){for(const e of Object.values(F))if(e===t)return!0;return!1}function Ot(t){return!!(t instanceof Object&&"p1x"in t&&"p1y"in t&&"p2x"in t&&"p2y"in t&&D(t.p1x)&&D(t.p1y)&&D(t.p2x)&&D(t.p2y))}function $(t,e,n,o){return function(c){return a(r(c))};function r(c){let u=0,h=1,s=c,m;if(c===0||c===1)return c;for(;u<h;){if(m=i(s),Math.abs(m-c)<.001)return s;c>m?u=s:h=s,s=(h+u)/2}return s}function i(c){return 3*t*c*Math.pow(1-c,2)+3*n*Math.pow(c,2)*(1-c)+Math.pow(c,3)}function a(c){return 3*e*c*Math.pow(1-c,2)+3*o*Math.pow(c,2)*(1-c)+Math.pow(c,3)}}const gt=$(.25,.1,.25,1),ee=$(.42,0,1,1),Lt=$(.42,0,.58,1),ne=$(.4,.1,.6,1),oe=$(.45,1.5,.55,1);function re(t){switch(t){case F.EASE:return gt;case F.EASE_IN:return ee;case F.EASE_OUT:return Lt;case F.EASE_IN_OUT:return ne;case F.SPRING:return oe;default:return gt}}function vt(t){return typeof t=="boolean"}const ae={ariaLabel:"Bottom sheet",content:"",defaultPosition:j.CONTENT_HEIGHT,marginTop:20,snapPoints:[],width:"92%",dragTriggers:[],beforeOpen:()=>{},afterOpen:()=>{},beforeClose:()=>{},afterClose:()=>{},onDragStart:()=>{},onDragMove:()=>{},onDragEnd:()=>{},expandable:!0,preventClosing:!1,draggable:!0,backgroundDraggable:!0,shouldCloseOnOutsideClick:!0,shouldShowBackdrop:!0,shouldShowHandle:!0,backDropTransition:null,backdropColor:null,containerBorderRadius:null,rootClass:null,containerClass:null,handleClass:null,contentWrapperClass:null,backdropClass:null,draggingAnimationTimings:"ease-in-out",draggingAnimationDuration:180,rootStyle:{},containerStyle:{},handleStyle:{},contentWrapperStyle:{},backdropStyle:{}};function ie(t){const e={...ae},n=Object.entries(t).reduce((o,r)=>{const[i,a]=r;return it(a)&&(o[i]=a),o},{});return{...e,...n}}function ct(t){if(Ot(t)){const{p1x:e,p1y:n,p2x:o,p2y:r}=t;return $(e,n,o,r)}return te(t)?re(t):Lt}function se(t,e,n,o){function r(i,a){switch(i){case"content":A(a)&&(t.bottomSheetContentWrapper.innerHTML=a);break;case"width":A(a)&&(t.bottomSheetContainer.style.width=a);break;case"shouldShowHandle":vt(a)||Q(t.bottomSheetHandle,!1);break;case"shouldShowBackdrop":vt(a)||Q(t.bottomSheetBackdrop,!1);break;case"containerBorderRadius":A(a)&&(t.bottomSheetContainer.style.borderRadius=Ht(a));break;case"backdropColor":A(a)&&(t.bottomSheetBackdrop.style.backgroundColor=a);break;case"backDropTransition":A(a)&&(t.bottomSheetBackdrop.style.transition=a);break;case"rootClass":if(!A(a))return;X(t.bottomSheetRoot,n.rootClass,a);break;case"containerClass":if(!A(a))return;X(t.bottomSheetContainer,n.containerClass,a);break;case"handleClass":if(!A(a))return;X(t.bottomSheetHandle,n.handleClass,a);break;case"contentWrapperClass":if(!A(a))return;X(t.bottomSheetContentWrapper,n.contentWrapperClass,a);break;case"backdropClass":if(!A(a))return;X(t.bottomSheetBackdrop,n.backdropClass,a);break;case"expandable":o.clearEventListeners(),o.attachEventListeners(n);break;case"preventClosing":o.clearEventListeners(),o.attachEventListeners(n);break;case"draggable":o.clearEventListeners(),o.attachEventListeners(n);break;case"draggingAnimationTimings":if(Ot(a)){const c=ct(a),u=st(c,n.draggingAnimationDuration);e.translateContainer=u}break;case"draggingAnimationDuration":if(D(a)){const c=ct(n.draggingAnimationTimings),u=st(c,a);e.translateContainer=u}break;case"rootStyle":n.rootStyle&&Object.assign(t.bottomSheetRoot.style,n.rootStyle);break;case"backdropStyle":n.backdropStyle&&Object.assign(t.bottomSheetBackdrop.style,n.backdropStyle);break;case"containerStyle":n.containerStyle&&Object.assign(t.bottomSheetContainer.style,n.containerStyle);break;case"handleStyle":n.handleStyle&&Object.assign(t.bottomSheetHandleBar.style,n.handleStyle);break;case"contentWrapperStyle":n.contentWrapperStyle&&Object.assign(t.bottomSheetContentWrapper.style,n.contentWrapperStyle);break}}return r}function ce(t){const e=ie(t),n=ct(t.draggingAnimationTimings),o={isMounted:!1,translateContainer:st(n,e.draggingAnimationDuration)},r={startY:null,containerStartTranslate:{x:0,y:0},isDragging:!1,originalDocumentOverflowY:null,originalDocumentOverscrollBehavior:null};function i(){r.originalDocumentOverflowY&&r.originalDocumentOverflowY!=="hidden"&&(document.body.style.overflowY=r.originalDocumentOverflowY),r.originalDocumentOverscrollBehavior&&(document.body.style.position=r.originalDocumentOverscrollBehavior)}const a=new Vt,c={animationFrame:a,onClose:w,bottomSheetState:o,draggingState:r,snapTo:S,moveUp:O,moveDown:y},{elements:u,eventHandlers:h}=_t(e,c),s=Qt(e,se(u,o,e,h)),{bottomSheetBackdrop:m,bottomSheetRoot:C,bottomSheetContainer:l}=u,E=p=>{const d=p??window.document.body;d.appendChild(C),d.appendChild(m);const f=window.innerHeight;tt(l,{y:f}),h.attachEventListeners(),o.isMounted=!0},b=()=>{h.clearEventListeners(),Object.values(u).forEach(p=>{p.remove()}),i(),o.isMounted=!1},v=()=>{var p;if(x()||Zt('Bottom Sheet is not mounted yet. call the "mount" method first.'),(p=t.beforeOpen)==null||p.call(t),H())return;nt(m,!0),s.shouldShowBackdrop||V(m,"transparent"),nt([l],!0),tt(l,{y:l.clientHeight});const d=window.innerHeight,f=pt(d,l.clientHeight,s.marginTop,s.defaultPosition),g=M(l).y;o.translateContainer({startY:g,endY:f,animationFrame:a,bottomSheetContainer:l,onEnd:t.afterOpen});const L=document.body.style.overflowY;r.originalDocumentOverflowY=L||"initial";const B=document.body.style.overscrollBehavior;r.originalDocumentOverscrollBehavior=B||"initial",document.body.style.overflow="hidden",document.body.style.overscrollBehavior="contain",u.bottomSheetHandle.focus(),h.attacheOnOpenEventListeners()};function w(){var p;if(Y())return;(p=t.beforeClose)==null||p.call(t);const d=M(l).y,f=l.clientHeight;o.translateContainer({startY:d,endY:f,animationFrame:a,bottomSheetContainer:l,onEnd:()=>{var g;(g=t.afterClose)==null||g.call(t),nt([m,l],!1),h.clearOnOpenEventListeners()}}),i()}function x(){return o.isMounted}function H(){const p=M(l).y,d=window.innerHeight,f=l.clientHeight>=d?d:l.clientHeight;return p<=f}function Y(){return!H()}function G(){const p=M(l).y,d=l.clientHeight,f=window.innerHeight;if(p<=5&&p>=-5)return j.CONTENT_HEIGHT;const g=d-p;if(g===f/2)return j.MIDDLE;const L=f-s.marginTop,B=10;return g<=L+B&&g>=L-B?j.TOP:j.CLOSED}function _(){return l.clientHeight}function I(p){if(!H())return;const d=M(l).y,f=l.clientHeight-d,g=window.innerHeight-p,L=Rt(f,g),B=z(f,g);o.translateContainer({startY:d,endY:d+(L.isUp?-B:B),animationFrame:a,bottomSheetContainer:l})}function R(p,{viewportHeight:d,visibleHeight:f}){let g=null;for(const L of p){const B=L*d,W=z(f,B);(g===null||W<g)&&(g=W)}return{minOffset:g}}function O(){const p=[...s.snapPoints].reverse(),d=M(l).y,f=l.clientHeight,g=f-d;if(!s.expandable&&g>=f)return;const L=window.innerHeight,B=ht("above",{visibleHeight:g,viewportHeight:L},p),{minOffset:W}=R(B,{visibleHeight:g,viewportHeight:L});if(W===null&&g<L-s.marginTop){o.translateContainer({startY:d,endY:pt(L,f,s.marginTop,"top"),animationFrame:a,bottomSheetContainer:l});return}D(W)&&o.translateContainer({startY:d,endY:d-W,animationFrame:a,bottomSheetContainer:l})}function y(){const p=M(l).y,d=l.clientHeight-p;if(d<1)return;const f=window.innerHeight,g=ht("below",{visibleHeight:d,viewportHeight:f},s.snapPoints),{minOffset:L}=R(g,{visibleHeight:d,viewportHeight:f});D(L)&&o.translateContainer({startY:p,endY:p+L,animationFrame:a,bottomSheetContainer:l})}function S(p){const d=window.innerHeight;if(!Jt(p))return;const f=Z(d*p,2);I(f)}return{props:s,elements:u,mount:E,unmount:b,open:v,close:w,getIsMounted:x,getIsOpen:H,getIsClosed:Y,getPosition:G,getHeight:_,moveTo:I,snapTo:S}}function lt(){return{elements:{bottomSheetRoot:void 0,bottomSheetBackdrop:void 0,bottomSheetContainer:void 0,bottomSheetHandle:void 0,bottomSheetHandleBar:void 0,bottomSheetContentWrapper:void 0,bottomSheetContainerGapFiller:void 0},mount:()=>{},unmount:()=>{},open:()=>{},close:()=>{},getIsMounted:()=>!1,getHeight:()=>0,getIsOpen:()=>!1,getIsClosed:()=>!0,getPosition:()=>j.CLOSED,moveTo:()=>{},snapTo:()=>{},props:{content:""}}}const le=lt(),ue=k.forwardRef(function(e,n){const{children:o,isOpen:r,setIsOpen:i,afterClose:a,mountingPointRef:c,...u}=e,h=k.useRef(le),[s,m]=k.useState(h.current);k.useImperativeHandle(n,()=>s,[s]);const C=k.useCallback(()=>{i(!1),a==null||a()},[a]);k.useEffect(()=>{r?s.open():s.close()},[r]);const l=k.useRef(null);return k.useEffect(function(){var w;if(c&&!c.current)return;const b=At((w=e.mountingPointRef)==null?void 0:w.current)?e.mountingPointRef.current:window.document.body;if(!b||s.getIsMounted())return;const v=ce({content:"",...u,afterClose:C});return v.mount(b),l.current=v.elements.bottomSheetContentWrapper??null,h.current=v,m(v),()=>{s.unmount()}},[e.mountingPointRef,u,C]),k.useEffect(function(){Object.assign(h.current.props,{...u}),m(h.current)},[u]),k.useEffect(function(){return()=>{h.current.unmount()}},[]),l.current?xt.createPortal(e.children,l.current):null}),de=lt();function pe(t={}){const e=k.useRef(de),[n,o]=k.useState(!1),[r,i]=k.useState(e.current);k.useEffect(()=>{i(e.current)},[e.current]);const{beforeOpen:a,afterOpen:c,beforeClose:u,afterClose:h,onDragStart:s,onDragMove:m,onDragEnd:C,...l}=t,E=()=>{a==null||a()},b=()=>{c==null||c(),o(!0)},v=()=>{u==null||u()},w=()=>{h==null||h(),o(!1)},x=()=>{s==null||s()},H=(y,S)=>{m==null||m(y,S)},Y=()=>{C==null||C()},G=k.useMemo(()=>({ref:e,isOpen:n,setIsOpen:o,beforeOpen:E,afterOpen:b,beforeClose:v,afterClose:w,onDragStart:x,onDragMove:H,onDragEnd:Y,...l}),[e.current,n,o,t]),_=k.useCallback(()=>{o(!0)},[o]),I=k.useCallback(()=>{o(!0)},[o]),R=k.useCallback((...y)=>{r.moveTo(...y)},[r]),O=k.useCallback((...y)=>{r.snapTo(...y)},[r]);return{props:G,instance:r,isOpen:n,setIsOpen:o,open:_,close:I,moveTo:R,snapTo:O}}exports.BottomSheet=ue;exports.createPlaceholderBottomSheet=lt;exports.useBottomSheet=pe;
@@ -13,21 +13,21 @@ function It(t) {
13
13
  console.error("vite-plugin-css-injected-by-js", e);
14
14
  }
15
15
  })();
16
- var Rt = Object.defineProperty, Wt = (t, e, n) => e in t ? Rt(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n, K = (t, e, n) => Wt(t, typeof e != "symbol" ? e + "" : e, n);
16
+ var Rt = Object.defineProperty, Wt = (t, e, n) => e in t ? Rt(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n, J = (t, e, n) => Wt(t, typeof e != "symbol" ? e + "" : e, n);
17
17
  function x(t) {
18
18
  return typeof t == "string";
19
19
  }
20
20
  function Nt(t, e) {
21
21
  return t.classList.contains(nt(e));
22
22
  }
23
- function V(t, e) {
23
+ function K(t, e) {
24
24
  t.classList.add(nt(e));
25
25
  }
26
26
  function it(t, e) {
27
27
  t.classList.remove(nt(e));
28
28
  }
29
29
  function _(t, e, n) {
30
- x(n) && (x(e) && it(t, e), V(t, n));
30
+ x(n) && (x(e) && it(t, e), K(t, n));
31
31
  }
32
32
  function nt(t) {
33
33
  return x(t) ? t.trim().replace(/\./g, "") : "";
@@ -43,14 +43,14 @@ function ot(t, e) {
43
43
  const n = e;
44
44
  if (Array.isArray(t)) {
45
45
  t.forEach((o) => {
46
- Q(o, n), o.setAttribute("aria-modal", n ? "true" : "false");
46
+ Z(o, n), o.setAttribute("aria-modal", n ? "true" : "false");
47
47
  });
48
48
  return;
49
49
  }
50
- Q(t, n), t.setAttribute("aria-modal", n ? "true" : "false");
50
+ Z(t, n), t.setAttribute("aria-modal", n ? "true" : "false");
51
51
  }
52
- function Q(t, e) {
53
- e ? (V(t, pt), it(t, ht)) : (V(t, ht), it(t, pt));
52
+ function Z(t, e) {
53
+ e ? (K(t, pt), it(t, ht)) : (K(t, ht), it(t, pt));
54
54
  }
55
55
  function Ct(t) {
56
56
  return t instanceof HTMLElement;
@@ -75,21 +75,21 @@ function Ut(t) {
75
75
  ].includes(t.tagName), r = t instanceof HTMLAnchorElement && t.href !== "" || t instanceof HTMLAreaElement && t.href !== "";
76
76
  return o || r || n > -1;
77
77
  }
78
- var k = /* @__PURE__ */ ((t) => (t.Backdrop = "pbs-backdrop", t.Root = "pbs-root", t.Container = "pbs-container", t.GapFiller = "pbs-gap-filler", t.Handle = "pbs-handle", t.HandleBar = "pbs-handle-bar", t.ContentWrapper = "pbs-content-wrapper", t))(k || {}), st = /* @__PURE__ */ ((t) => (t.Button = "pbs-button-reset", t.Dialog = "pbs-dialog-reset", t))(st || {}), J = /* @__PURE__ */ ((t) => (t.Hidden = "hidden", t))(J || {});
78
+ var T = /* @__PURE__ */ ((t) => (t.Backdrop = "pbs-backdrop", t.Root = "pbs-root", t.Container = "pbs-container", t.GapFiller = "pbs-gap-filler", t.Handle = "pbs-handle", t.HandleBar = "pbs-handle-bar", t.ContentWrapper = "pbs-content-wrapper", t))(T || {}), st = /* @__PURE__ */ ((t) => (t.Button = "pbs-button-reset", t.Dialog = "pbs-dialog-reset", t))(st || {}), Q = /* @__PURE__ */ ((t) => (t.Hidden = "hidden", t))(Q || {});
79
79
  function M(t, e, n) {
80
80
  const o = document.createElement(t);
81
81
  return e.split(" ").forEach((r) => {
82
- V(o, r);
82
+ K(o, r);
83
83
  }), x(n) && o.setAttribute("data-testid", n), o;
84
84
  }
85
85
  Ft([
86
- k.Root,
87
- k.ContentWrapper
86
+ T.Root,
87
+ T.ContentWrapper
88
88
  ]);
89
89
  function mt(t, e, n, o) {
90
90
  switch (o) {
91
91
  case "content-height":
92
- return e >= t ? kt(t, e, n) : 0;
92
+ return e >= t ? Tt(t, e, n) : 0;
93
93
  case "middle":
94
94
  return -(t / 2 - e);
95
95
  case "top":
@@ -109,7 +109,7 @@ function Et(t, e) {
109
109
  function wt(t, e) {
110
110
  return e < t ? -(t - e) : e - t;
111
111
  }
112
- function Z(t, e) {
112
+ function V(t, e) {
113
113
  return t > e ? t - e : e - t;
114
114
  }
115
115
  function $t(t, e) {
@@ -127,7 +127,7 @@ function bt(t, e, n) {
127
127
  return o ? e.visibleHeight < i : e.visibleHeight > i;
128
128
  });
129
129
  }
130
- function kt(t, e, n) {
130
+ function Tt(t, e, n) {
131
131
  return -(t - e) + n;
132
132
  }
133
133
  function ft(t) {
@@ -136,7 +136,7 @@ function ft(t) {
136
136
  function tt(t, ...e) {
137
137
  return Number(t.toFixed(...e));
138
138
  }
139
- function Ht(t) {
139
+ function kt(t) {
140
140
  const e = /(?<type>\w+)\((?<values>[^)]+)\)/g, n = [];
141
141
  let o;
142
142
  for (; (o = e.exec(t)) !== null; ) {
@@ -146,17 +146,17 @@ function Ht(t) {
146
146
  return n;
147
147
  }
148
148
  function Gt(t) {
149
- const e = t.style.transform, n = Ht(e);
149
+ const e = t.style.transform, n = kt(e);
150
150
  return { transform: e, transformValues: n };
151
151
  }
152
- function Tt(t, e) {
152
+ function Ht(t, e) {
153
153
  return t.find(
154
154
  (o) => o.type.startsWith(e)
155
155
  ) || null;
156
156
  }
157
157
  const ct = "translate";
158
158
  function B(t) {
159
- const e = t.style.transform, n = Ht(e), o = Tt(
159
+ const e = t.style.transform, n = kt(e), o = Ht(
160
160
  n,
161
161
  ct
162
162
  );
@@ -169,7 +169,7 @@ function et(t, { x: e, y: n }) {
169
169
  const {
170
170
  transform: o,
171
171
  transformValues: r
172
- } = Gt(t), i = Tt(
172
+ } = Gt(t), i = Ht(
173
173
  r,
174
174
  ct
175
175
  );
@@ -205,7 +205,7 @@ function gt(t, {
205
205
  return lt(n) && t >= n ? n : lt(e) && t <= e ? e : t;
206
206
  }
207
207
  const _t = (t, e, n) => {
208
- e instanceof HTMLElement && !Nt(e, k.Handle) && n.scrollTop >= 1 || (t.isDragging = !0);
208
+ e instanceof HTMLElement && !Nt(e, T.Handle) && n.scrollTop >= 1 || (t.isDragging = !0);
209
209
  }, Xt = (t, e, n, o) => (r) => {
210
210
  o.startY = t.getCoordinates(r).y, o.containerStartTranslate = B(e), n.onDragStart();
211
211
  }, zt = (t, e, n, o, r) => (i) => {
@@ -222,21 +222,21 @@ const _t = (t, e, n) => {
222
222
  function qt(t, e, n, o, r, i, a) {
223
223
  if (!o.isDragging || !A(o.startY))
224
224
  return;
225
- const s = e.getCoordinates(t).y, u = wt(o.startY, s), h = window.innerHeight, c = i.clientHeight, m = c - (o.containerStartTranslate.y + u);
225
+ const c = e.getCoordinates(t).y, u = wt(o.startY, c), h = window.innerHeight, s = i.clientHeight, m = s - (o.containerStartTranslate.y + u);
226
226
  if (m >= h)
227
227
  return;
228
- const C = Et(o.startY, s);
229
- if (C.isUp && !n.expandable && m >= c)
228
+ const C = Et(o.startY, c);
229
+ if (C.isUp && !n.expandable && m >= s || n.preventClosing && m <= s)
230
230
  return;
231
231
  r.start(() => {
232
232
  et(i, {
233
233
  y: o.containerStartTranslate.y + u
234
234
  });
235
235
  }, 0);
236
- const l = h - a, E = c - o.containerStartTranslate.y;
236
+ const l = h - a, E = s - o.containerStartTranslate.y;
237
237
  if (C.isUp) {
238
- const g = l - E, S = l - m, w = gt(
239
- 1 - tt(S / g, 2),
238
+ const b = l - E, v = l - m, w = gt(
239
+ 1 - tt(v / b, 2),
240
240
  {
241
241
  min: 0,
242
242
  max: 1
@@ -244,7 +244,7 @@ function qt(t, e, n, o, r, i, a) {
244
244
  );
245
245
  n.onDragMove(C, w);
246
246
  } else if (C.isDown) {
247
- const g = gt(
247
+ const b = gt(
248
248
  tt(
249
249
  1 - m / E,
250
250
  2
@@ -254,67 +254,80 @@ function qt(t, e, n, o, r, i, a) {
254
254
  max: 1
255
255
  }
256
256
  );
257
- n.onDragMove(C, g);
257
+ n.onDragMove(C, b);
258
258
  }
259
259
  }
260
- const Vt = (t, e, n, o, r, i, a) => (s) => {
260
+ const Vt = (t, e, n, o, r, i, a) => (c) => {
261
261
  if (!o.isDragging || (o.isDragging = !1, !A(o.startY)))
262
262
  return;
263
263
  n.onDragEnd();
264
- const u = o.startY, h = t.getCoordinates(s).y, c = B(e).y, m = Et(u, h), C = window.innerHeight, l = e.clientHeight;
264
+ const u = o.startY, h = t.getCoordinates(c).y, s = B(e).y, m = Et(u, h), C = window.innerHeight, l = e.clientHeight;
265
265
  if (m.isUp) {
266
266
  const E = [...n.snapPoints].sort(
267
267
  (w, L) => w - L
268
- ), g = l + -c;
269
- if (!n.expandable && g >= l)
268
+ ), b = l + -s;
269
+ if (!n.expandable && b >= l)
270
270
  return;
271
271
  for (const w of E) {
272
272
  const L = w * window.innerHeight;
273
- if (g <= L) {
274
- const H = Z(
275
- g,
273
+ if (b <= L) {
274
+ const k = V(
275
+ b,
276
276
  L
277
277
  );
278
278
  a.translateContainer({
279
- startY: c,
280
- endY: c - H,
279
+ startY: s,
280
+ endY: s - k,
281
281
  animationFrame: r,
282
282
  bottomSheetContainer: e
283
283
  });
284
284
  return;
285
285
  }
286
286
  }
287
- const S = kt(
287
+ const v = Tt(
288
288
  C,
289
289
  l,
290
290
  n.marginTop
291
291
  );
292
292
  a.translateContainer({
293
- startY: c,
294
- endY: S,
293
+ startY: s,
294
+ endY: v,
295
295
  animationFrame: r,
296
296
  bottomSheetContainer: e
297
297
  });
298
298
  } else if (m.isDown) {
299
299
  const E = [...n.snapPoints].sort(
300
- (g, S) => S - g
300
+ (b, v) => v - b
301
301
  );
302
- for (const g of E) {
303
- const S = g * window.innerHeight, w = l + -c;
304
- if (w >= S) {
305
- const L = Z(
302
+ for (const b of E) {
303
+ const v = b * window.innerHeight, w = l + -s;
304
+ if (w >= v) {
305
+ const L = V(
306
306
  w,
307
- S
307
+ v
308
308
  );
309
309
  a.translateContainer({
310
- startY: c,
311
- endY: c + L,
310
+ startY: s,
311
+ endY: s + L,
312
312
  animationFrame: r,
313
313
  bottomSheetContainer: e
314
314
  });
315
315
  return;
316
316
  }
317
317
  }
318
+ if (n.preventClosing) {
319
+ const b = l + -s;
320
+ if (b >= l) {
321
+ const v = V(b, l);
322
+ a.translateContainer({
323
+ startY: s,
324
+ endY: s + v,
325
+ animationFrame: r,
326
+ bottomSheetContainer: e
327
+ });
328
+ }
329
+ return;
330
+ }
318
331
  i();
319
332
  }
320
333
  };
@@ -338,7 +351,7 @@ const Kt = {
338
351
  };
339
352
  class X {
340
353
  constructor(e) {
341
- K(this, "currentTarget"), this.currentTarget = e;
354
+ J(this, "currentTarget"), this.currentTarget = e;
342
355
  }
343
356
  addEventListeners({
344
357
  onStart: e,
@@ -453,62 +466,62 @@ function Qt(t) {
453
466
  const e = M(
454
467
  "dialog",
455
468
  W([
456
- k.Root,
469
+ T.Root,
457
470
  st.Dialog,
458
471
  t.rootClass
459
472
  ]),
460
- k.Root
473
+ T.Root
461
474
  );
462
475
  e.ariaLabel = t.ariaLabel;
463
476
  const n = M(
464
477
  "section",
465
- W([k.Container, t.containerClass]),
466
- k.Container
478
+ W([T.Container, t.containerClass]),
479
+ T.Container
467
480
  );
468
481
  t.containerBorderRadius && (n.style.borderRadius = Lt(
469
482
  t.containerBorderRadius
470
483
  ));
471
484
  const o = M(
472
485
  "div",
473
- k.GapFiller,
474
- k.GapFiller
486
+ T.GapFiller,
487
+ T.GapFiller
475
488
  ), r = M(
476
489
  "button",
477
490
  W([
478
- k.Handle,
491
+ T.Handle,
479
492
  st.Button,
480
- t.shouldShowHandle ? null : J.Hidden,
493
+ t.shouldShowHandle ? null : Q.Hidden,
481
494
  t.handleClass
482
495
  ]),
483
- k.Handle
496
+ T.Handle
484
497
  );
485
498
  r.setAttribute("type", "button"), r.ariaLabel = "bottom sheet close button";
486
499
  const i = M(
487
500
  "span",
488
501
  W([
489
- k.HandleBar,
490
- t.shouldShowHandle ? null : J.Hidden
502
+ T.HandleBar,
503
+ t.shouldShowHandle ? null : Q.Hidden
491
504
  ]),
492
- k.HandleBar
505
+ T.HandleBar
493
506
  ), a = M(
494
507
  "article",
495
508
  W([
496
- k.ContentWrapper,
509
+ T.ContentWrapper,
497
510
  t.contentWrapperClass
498
511
  ]),
499
- k.ContentWrapper
500
- ), s = M(
512
+ T.ContentWrapper
513
+ ), c = M(
501
514
  "div",
502
515
  W([
503
- k.Backdrop,
516
+ T.Backdrop,
504
517
  t.backdropClass,
505
- J.Hidden
518
+ Q.Hidden
506
519
  ]),
507
- k.Backdrop
520
+ T.Backdrop
508
521
  );
509
- return t.backdropColor && (s.style.backgroundColor = t.backdropColor), t.backDropTransition && (s.style.transition = t.backDropTransition), {
522
+ return t.backdropColor && (c.style.backgroundColor = t.backdropColor), t.backDropTransition && (c.style.transition = t.backDropTransition), {
510
523
  bottomSheetRoot: e,
511
- bottomSheetBackdrop: s,
524
+ bottomSheetBackdrop: c,
512
525
  bottomSheetContainer: n,
513
526
  bottomSheetHandle: r,
514
527
  bottomSheetHandleBar: i,
@@ -536,29 +549,29 @@ function te({
536
549
  bottomSheetContainer: r,
537
550
  bottomSheetHandle: i,
538
551
  bottomSheetContainerGapFiller: a,
539
- bottomSheetContentWrapper: s,
552
+ bottomSheetContentWrapper: c,
540
553
  bottomSheetBackdrop: u
541
- } = t, { animationFrame: h } = n, c = new X(i), m = new X(
542
- s
554
+ } = t, { animationFrame: h } = n, s = new X(i), m = new X(
555
+ c
543
556
  ), C = new X(
544
557
  a
545
558
  ), l = e.dragTriggers.reduce(
546
- (T, y) => {
547
- const v = o.querySelectorAll(y);
548
- if (!v.length)
549
- return T;
550
- const p = Array.from(v).map((d) => d instanceof HTMLElement ? new X(d) : null).filter((d) => !!d);
551
- return [...T, ...p];
559
+ (H, y) => {
560
+ const S = o.querySelectorAll(y);
561
+ if (!S.length)
562
+ return H;
563
+ const p = Array.from(S).map((d) => d instanceof HTMLElement ? new X(d) : null).filter((d) => !!d);
564
+ return [...H, ...p];
552
565
  },
553
566
  []
554
567
  ), E = new X(
555
568
  window
556
- ), g = Xt(
569
+ ), b = Xt(
557
570
  E,
558
571
  r,
559
572
  e,
560
573
  n.draggingState
561
- ), S = zt(
574
+ ), v = zt(
562
575
  E,
563
576
  r,
564
577
  e,
@@ -573,50 +586,50 @@ function te({
573
586
  n.onClose,
574
587
  n.bottomSheetState
575
588
  );
576
- function L(T) {
577
- T.target instanceof Element && !o.contains(T.target) && n.onClose();
589
+ function L(H) {
590
+ H.target instanceof Element && !o.contains(H.target) && n.onClose();
578
591
  }
579
- function H(T) {
592
+ function k(H) {
580
593
  _t(
581
594
  n.draggingState,
582
- T.target,
595
+ H.target,
583
596
  t.bottomSheetContentWrapper
584
597
  );
585
598
  }
586
- function P(T) {
587
- const y = T ?? e;
588
- y.draggable && (c.addEventListeners({
589
- onStart: H
590
- }), l.forEach((v) => {
591
- v.addEventListeners({
592
- onStart: H,
599
+ function P(H) {
600
+ const y = H ?? e;
601
+ y.draggable && (s.addEventListeners({
602
+ onStart: k
603
+ }), l.forEach((S) => {
604
+ S.addEventListeners({
605
+ onStart: k,
593
606
  onStartOptions: {
594
607
  eventPhase: j.Target
595
608
  }
596
609
  });
597
610
  })), y.draggable && y.backgroundDraggable && (m.addEventListeners({
598
- onStart: H,
611
+ onStart: k,
599
612
  onStartOptions: {
600
613
  eventPhase: j.Target
601
614
  }
602
615
  }), C.addEventListeners({
603
- onStart: H
616
+ onStart: k
604
617
  })), y.draggable && E.addEventListeners({
605
- onStart: g,
606
- onMove: S,
618
+ onStart: b,
619
+ onMove: v,
607
620
  onEnd: w
608
- }), y.draggable && window.document.addEventListener("keyup", (v) => {
609
- v.key === "Escape" && n.onClose();
610
- }), i.addEventListener("keyup", (v) => {
611
- if (v.key === "ArrowUp") {
621
+ }), y.draggable && window.document.addEventListener("keyup", (S) => {
622
+ S.key === "Escape" && n.onClose();
623
+ }), i.addEventListener("keyup", (S) => {
624
+ if (S.key === "ArrowUp") {
612
625
  n.moveUp();
613
626
  return;
614
627
  }
615
- if (v.key === "ArrowDown") {
628
+ if (S.key === "ArrowDown") {
616
629
  n.moveDown();
617
630
  return;
618
631
  }
619
- if (v.shiftKey && v.key === "Tab") {
632
+ if (S.shiftKey && S.key === "Tab") {
620
633
  const p = Y(
621
634
  t.bottomSheetContentWrapper
622
635
  );
@@ -630,33 +643,33 @@ function te({
630
643
  function G() {
631
644
  u.removeEventListener("click", L);
632
645
  }
633
- function Y(T) {
634
- let y = [...Array.from(T.childNodes).reverse()];
646
+ function Y(H) {
647
+ let y = [...Array.from(H.childNodes).reverse()];
635
648
  for (; y.length; ) {
636
- const v = y.shift();
637
- if (Ut(v))
638
- return v;
639
- v && (y = [
649
+ const S = y.shift();
650
+ if (Ut(S))
651
+ return S;
652
+ S && (y = [
640
653
  ...y,
641
- ...Array.from(v.childNodes).reverse()
654
+ ...Array.from(S.childNodes).reverse()
642
655
  ]);
643
656
  }
644
657
  return null;
645
658
  }
646
659
  function I() {
647
- c.removeEventListeners({
648
- onStart: H
660
+ s.removeEventListeners({
661
+ onStart: k
649
662
  }), m.removeEventListeners({
650
- onStart: H
663
+ onStart: k
651
664
  }), C.removeEventListeners({
652
- onStart: H
653
- }), l.forEach((T) => {
654
- T.removeEventListeners({
655
- onStart: H
665
+ onStart: k
666
+ }), l.forEach((H) => {
667
+ H.removeEventListeners({
668
+ onStart: k
656
669
  });
657
670
  }), E.removeEventListeners({
658
- onStart: g,
659
- onMove: S,
671
+ onStart: b,
672
+ onMove: v,
660
673
  onEnd: w
661
674
  });
662
675
  }
@@ -669,7 +682,7 @@ function te({
669
682
  }
670
683
  class ee {
671
684
  constructor() {
672
- K(this, "animationId"), K(this, "isInProgress"), K(this, "startedAt"), this.animationId = null, this.isInProgress = !1, this.startedAt = null;
685
+ J(this, "animationId"), J(this, "isInProgress"), J(this, "startedAt"), this.animationId = null, this.isInProgress = !1, this.startedAt = null;
673
686
  }
674
687
  /**
675
688
  *
@@ -680,8 +693,8 @@ class ee {
680
693
  this.isInProgress = !0;
681
694
  const r = (i) => {
682
695
  this.startedAt || (this.startedAt = i);
683
- const a = i - this.startedAt, s = n === 0 ? 1 : tt(a / n, 2), u = s >= 1 && !o;
684
- e(s), u ? this.stop() : this.animationId = requestAnimationFrame(r);
696
+ const a = i - this.startedAt, c = n === 0 ? 1 : tt(a / n, 2), u = c >= 1 && !o;
697
+ e(c), u ? this.stop() : this.animationId = requestAnimationFrame(r);
685
698
  };
686
699
  this.animationId = requestAnimationFrame(r);
687
700
  }
@@ -697,15 +710,15 @@ function ne(t) {
697
710
  animationFrame: r,
698
711
  onEnd: i,
699
712
  animationTimingFunction: a,
700
- animationDuration: s
713
+ animationDuration: c
701
714
  } = t, u = wt(e, n);
702
715
  r.stop();
703
716
  let h = !1;
704
- r.start((c) => {
717
+ r.start((s) => {
705
718
  et(o, {
706
- y: e + u * a(c)
707
- }), !h && c >= 1 && (i == null || i(), h = !0);
708
- }, s);
719
+ y: e + u * a(s)
720
+ }), !h && s >= 1 && (i == null || i(), h = !0);
721
+ }, c);
709
722
  }
710
723
  const ut = (t, e) => (n) => {
711
724
  ne({
@@ -750,25 +763,25 @@ function xt(t) {
750
763
  return !!(t instanceof Object && "p1x" in t && "p1y" in t && "p2x" in t && "p2y" in t && A(t.p1x) && A(t.p1y) && A(t.p2x) && A(t.p2y));
751
764
  }
752
765
  function U(t, e, n, o) {
753
- return function(s) {
754
- return a(r(s));
766
+ return function(c) {
767
+ return a(r(c));
755
768
  };
756
- function r(s) {
757
- let u = 0, h = 1, c = s, m;
758
- if (s === 0 || s === 1)
759
- return s;
769
+ function r(c) {
770
+ let u = 0, h = 1, s = c, m;
771
+ if (c === 0 || c === 1)
772
+ return c;
760
773
  for (; u < h; ) {
761
- if (m = i(c), Math.abs(m - s) < 1e-3)
762
- return c;
763
- s > m ? u = c : h = c, c = (h + u) / 2;
774
+ if (m = i(s), Math.abs(m - c) < 1e-3)
775
+ return s;
776
+ c > m ? u = s : h = s, s = (h + u) / 2;
764
777
  }
765
- return c;
778
+ return s;
766
779
  }
767
- function i(s) {
768
- return 3 * t * s * Math.pow(1 - s, 2) + 3 * n * Math.pow(s, 2) * (1 - s) + Math.pow(s, 3);
780
+ function i(c) {
781
+ return 3 * t * c * Math.pow(1 - c, 2) + 3 * n * Math.pow(c, 2) * (1 - c) + Math.pow(c, 3);
769
782
  }
770
- function a(s) {
771
- return 3 * e * s * Math.pow(1 - s, 2) + 3 * o * Math.pow(s, 2) * (1 - s) + Math.pow(s, 3);
783
+ function a(c) {
784
+ return 3 * e * c * Math.pow(1 - c, 2) + 3 * o * Math.pow(c, 2) * (1 - c) + Math.pow(c, 3);
772
785
  }
773
786
  }
774
787
  const St = U(0.25, 0.1, 0.25, 1), se = U(0.42, 0, 1, 1), At = U(0.42, 0, 0.58, 1), ce = U(0.4, 0.1, 0.6, 1), le = U(0.45, 1.5, 0.55, 1);
@@ -814,6 +827,7 @@ const de = {
814
827
  onDragEnd: () => {
815
828
  },
816
829
  expandable: !0,
830
+ preventClosing: !1,
817
831
  draggable: !0,
818
832
  backgroundDraggable: !0,
819
833
  shouldCloseOnOutsideClick: !0,
@@ -867,10 +881,10 @@ function he(t, e, n, o) {
867
881
  x(a) && (t.bottomSheetContainer.style.width = a);
868
882
  break;
869
883
  case "shouldShowHandle":
870
- yt(a) || Q(t.bottomSheetHandle, !1);
884
+ yt(a) || Z(t.bottomSheetHandle, !1);
871
885
  break;
872
886
  case "shouldShowBackdrop":
873
- yt(a) || Q(t.bottomSheetBackdrop, !1);
887
+ yt(a) || Z(t.bottomSheetBackdrop, !1);
874
888
  break;
875
889
  case "containerBorderRadius":
876
890
  x(a) && (t.bottomSheetContainer.style.borderRadius = Lt(a));
@@ -929,13 +943,16 @@ function he(t, e, n, o) {
929
943
  case "expandable":
930
944
  o.clearEventListeners(), o.attachEventListeners(n);
931
945
  break;
946
+ case "preventClosing":
947
+ o.clearEventListeners(), o.attachEventListeners(n);
948
+ break;
932
949
  case "draggable":
933
950
  o.clearEventListeners(), o.attachEventListeners(n);
934
951
  break;
935
952
  case "draggingAnimationTimings":
936
953
  if (xt(a)) {
937
- const s = dt(a), u = ut(
938
- s,
954
+ const c = dt(a), u = ut(
955
+ c,
939
956
  n.draggingAnimationDuration
940
957
  );
941
958
  e.translateContainer = u;
@@ -943,10 +960,10 @@ function he(t, e, n, o) {
943
960
  break;
944
961
  case "draggingAnimationDuration":
945
962
  if (A(a)) {
946
- const s = dt(
963
+ const c = dt(
947
964
  n.draggingAnimationTimings
948
965
  ), u = ut(
949
- s,
966
+ c,
950
967
  a
951
968
  );
952
969
  e.translateContainer = u;
@@ -1008,18 +1025,18 @@ function me(t) {
1008
1025
  function i() {
1009
1026
  r.originalDocumentOverflowY && r.originalDocumentOverflowY !== "hidden" && (document.body.style.overflowY = r.originalDocumentOverflowY), r.originalDocumentOverscrollBehavior && (document.body.style.position = r.originalDocumentOverscrollBehavior);
1010
1027
  }
1011
- const a = new ee(), s = {
1028
+ const a = new ee(), c = {
1012
1029
  animationFrame: a,
1013
1030
  onClose: w,
1014
1031
  bottomSheetState: o,
1015
1032
  draggingState: r,
1016
- snapTo: v,
1017
- moveUp: T,
1033
+ snapTo: S,
1034
+ moveUp: H,
1018
1035
  moveDown: y
1019
1036
  }, { elements: u, eventHandlers: h } = Jt(
1020
1037
  e,
1021
- s
1022
- ), c = re(
1038
+ c
1039
+ ), s = re(
1023
1040
  e,
1024
1041
  he(
1025
1042
  u,
@@ -1030,32 +1047,32 @@ function me(t) {
1030
1047
  ), { bottomSheetBackdrop: m, bottomSheetRoot: C, bottomSheetContainer: l } = u, E = (p) => {
1031
1048
  const d = p ?? window.document.body;
1032
1049
  d.appendChild(C), d.appendChild(m);
1033
- const b = window.innerHeight;
1050
+ const f = window.innerHeight;
1034
1051
  et(l, {
1035
- y: b
1052
+ y: f
1036
1053
  }), h.attachEventListeners(), o.isMounted = !0;
1037
- }, g = () => {
1054
+ }, b = () => {
1038
1055
  h.clearEventListeners(), Object.values(u).forEach((p) => {
1039
1056
  p.remove();
1040
1057
  }), i(), o.isMounted = !1;
1041
- }, S = () => {
1058
+ }, v = () => {
1042
1059
  var p;
1043
1060
  if (L() || ae(
1044
1061
  'Bottom Sheet is not mounted yet. call the "mount" method first.'
1045
- ), (p = t.beforeOpen) == null || p.call(t), H())
1062
+ ), (p = t.beforeOpen) == null || p.call(t), k())
1046
1063
  return;
1047
- ot(m, !0), c.shouldShowBackdrop || V(m, "transparent"), ot([l], !0), et(l, {
1064
+ ot(m, !0), s.shouldShowBackdrop || K(m, "transparent"), ot([l], !0), et(l, {
1048
1065
  y: l.clientHeight
1049
1066
  });
1050
- const d = window.innerHeight, b = mt(
1067
+ const d = window.innerHeight, f = mt(
1051
1068
  d,
1052
1069
  l.clientHeight,
1053
- c.marginTop,
1054
- c.defaultPosition
1055
- ), f = B(l).y;
1070
+ s.marginTop,
1071
+ s.defaultPosition
1072
+ ), g = B(l).y;
1056
1073
  o.translateContainer({
1057
- startY: f,
1058
- endY: b,
1074
+ startY: g,
1075
+ endY: f,
1059
1076
  animationFrame: a,
1060
1077
  bottomSheetContainer: l,
1061
1078
  onEnd: t.afterOpen
@@ -1070,45 +1087,45 @@ function me(t) {
1070
1087
  if (P())
1071
1088
  return;
1072
1089
  (p = t.beforeClose) == null || p.call(t);
1073
- const d = B(l).y, b = l.clientHeight;
1090
+ const d = B(l).y, f = l.clientHeight;
1074
1091
  o.translateContainer({
1075
1092
  startY: d,
1076
- endY: b,
1093
+ endY: f,
1077
1094
  animationFrame: a,
1078
1095
  bottomSheetContainer: l,
1079
1096
  onEnd: () => {
1080
- var f;
1081
- (f = t.afterClose) == null || f.call(t), ot([m, l], !1), h.clearOnOpenEventListeners();
1097
+ var g;
1098
+ (g = t.afterClose) == null || g.call(t), ot([m, l], !1), h.clearOnOpenEventListeners();
1082
1099
  }
1083
1100
  }), i();
1084
1101
  }
1085
1102
  function L() {
1086
1103
  return o.isMounted;
1087
1104
  }
1088
- function H() {
1089
- const p = B(l).y, d = window.innerHeight, b = l.clientHeight >= d ? d : l.clientHeight;
1090
- return p <= b;
1105
+ function k() {
1106
+ const p = B(l).y, d = window.innerHeight, f = l.clientHeight >= d ? d : l.clientHeight;
1107
+ return p <= f;
1091
1108
  }
1092
1109
  function P() {
1093
- return !H();
1110
+ return !k();
1094
1111
  }
1095
1112
  function $() {
1096
- const p = B(l).y, d = l.clientHeight, b = window.innerHeight;
1113
+ const p = B(l).y, d = l.clientHeight, f = window.innerHeight;
1097
1114
  if (p <= 5 && p >= -5)
1098
1115
  return F.CONTENT_HEIGHT;
1099
- const f = d - p;
1100
- if (f === b / 2)
1116
+ const g = d - p;
1117
+ if (g === f / 2)
1101
1118
  return F.MIDDLE;
1102
- const O = b - c.marginTop, D = 10;
1103
- return f <= O + D && f >= O - D ? F.TOP : F.CLOSED;
1119
+ const O = f - s.marginTop, D = 10;
1120
+ return g <= O + D && g >= O - D ? F.TOP : F.CLOSED;
1104
1121
  }
1105
1122
  function G() {
1106
1123
  return l.clientHeight;
1107
1124
  }
1108
1125
  function Y(p) {
1109
- if (!H())
1126
+ if (!k())
1110
1127
  return;
1111
- const d = B(l).y, b = l.clientHeight - d, f = window.innerHeight - p, O = $t(b, f), D = Z(b, f);
1128
+ const d = B(l).y, f = l.clientHeight - d, g = window.innerHeight - p, O = $t(f, g), D = V(f, g);
1112
1129
  o.translateContainer({
1113
1130
  startY: d,
1114
1131
  endY: d + (O.isUp ? -D : D),
@@ -1118,39 +1135,39 @@ function me(t) {
1118
1135
  }
1119
1136
  function I(p, {
1120
1137
  viewportHeight: d,
1121
- visibleHeight: b
1138
+ visibleHeight: f
1122
1139
  }) {
1123
- let f = null;
1140
+ let g = null;
1124
1141
  for (const O of p) {
1125
- const D = O * d, R = Z(
1126
- b,
1142
+ const D = O * d, R = V(
1143
+ f,
1127
1144
  D
1128
1145
  );
1129
- (f === null || R < f) && (f = R);
1146
+ (g === null || R < g) && (g = R);
1130
1147
  }
1131
1148
  return {
1132
- minOffset: f
1149
+ minOffset: g
1133
1150
  };
1134
1151
  }
1135
- function T() {
1136
- const p = [...c.snapPoints].reverse(), d = B(l).y, b = l.clientHeight, f = b - d;
1137
- if (!c.expandable && f >= b)
1152
+ function H() {
1153
+ const p = [...s.snapPoints].reverse(), d = B(l).y, f = l.clientHeight, g = f - d;
1154
+ if (!s.expandable && g >= f)
1138
1155
  return;
1139
1156
  const O = window.innerHeight, D = bt(
1140
1157
  "above",
1141
- { visibleHeight: f, viewportHeight: O },
1158
+ { visibleHeight: g, viewportHeight: O },
1142
1159
  p
1143
1160
  ), { minOffset: R } = I(D, {
1144
- visibleHeight: f,
1161
+ visibleHeight: g,
1145
1162
  viewportHeight: O
1146
1163
  });
1147
- if (R === null && f < O - c.marginTop) {
1164
+ if (R === null && g < O - s.marginTop) {
1148
1165
  o.translateContainer({
1149
1166
  startY: d,
1150
1167
  endY: mt(
1151
1168
  O,
1152
- b,
1153
- c.marginTop,
1169
+ f,
1170
+ s.marginTop,
1154
1171
  "top"
1155
1172
  ),
1156
1173
  animationFrame: a,
@@ -1169,13 +1186,13 @@ function me(t) {
1169
1186
  const p = B(l).y, d = l.clientHeight - p;
1170
1187
  if (d < 1)
1171
1188
  return;
1172
- const b = window.innerHeight, f = bt(
1189
+ const f = window.innerHeight, g = bt(
1173
1190
  "below",
1174
- { visibleHeight: d, viewportHeight: b },
1175
- c.snapPoints
1176
- ), { minOffset: O } = I(f, {
1191
+ { visibleHeight: d, viewportHeight: f },
1192
+ s.snapPoints
1193
+ ), { minOffset: O } = I(g, {
1177
1194
  visibleHeight: d,
1178
- viewportHeight: b
1195
+ viewportHeight: f
1179
1196
  });
1180
1197
  A(O) && o.translateContainer({
1181
1198
  startY: p,
@@ -1184,27 +1201,27 @@ function me(t) {
1184
1201
  bottomSheetContainer: l
1185
1202
  });
1186
1203
  }
1187
- function v(p) {
1204
+ function S(p) {
1188
1205
  const d = window.innerHeight;
1189
1206
  if (!oe(p))
1190
1207
  return;
1191
- const b = tt(d * p, 2);
1192
- Y(b);
1208
+ const f = tt(d * p, 2);
1209
+ Y(f);
1193
1210
  }
1194
1211
  return {
1195
- props: c,
1212
+ props: s,
1196
1213
  elements: u,
1197
1214
  mount: E,
1198
- unmount: g,
1199
- open: S,
1215
+ unmount: b,
1216
+ open: v,
1200
1217
  close: w,
1201
1218
  getIsMounted: L,
1202
- getIsOpen: H,
1219
+ getIsOpen: k,
1203
1220
  getIsClosed: P,
1204
1221
  getPosition: $,
1205
1222
  getHeight: G,
1206
1223
  moveTo: Y,
1207
- snapTo: v
1224
+ snapTo: S
1208
1225
  };
1209
1226
  }
1210
1227
  function Dt() {
@@ -1247,38 +1264,38 @@ const be = Dt(), Se = Bt(
1247
1264
  isOpen: r,
1248
1265
  setIsOpen: i,
1249
1266
  afterClose: a,
1250
- mountingPointRef: s,
1267
+ mountingPointRef: c,
1251
1268
  ...u
1252
- } = e, h = rt(be), [c, m] = at(
1269
+ } = e, h = rt(be), [s, m] = at(
1253
1270
  h.current
1254
1271
  );
1255
1272
  Mt(
1256
1273
  n,
1257
- () => c,
1258
- [c]
1274
+ () => s,
1275
+ [s]
1259
1276
  );
1260
1277
  const C = z(() => {
1261
1278
  i(!1), a == null || a();
1262
1279
  }, [a]);
1263
1280
  q(() => {
1264
- r ? c.open() : c.close();
1281
+ r ? s.open() : s.close();
1265
1282
  }, [r]);
1266
1283
  const l = rt(null);
1267
1284
  return q(
1268
1285
  function() {
1269
1286
  var w;
1270
- if (s && !s.current)
1287
+ if (c && !c.current)
1271
1288
  return;
1272
- const g = It((w = e.mountingPointRef) == null ? void 0 : w.current) ? e.mountingPointRef.current : window.document.body;
1273
- if (!g || c.getIsMounted())
1289
+ const b = It((w = e.mountingPointRef) == null ? void 0 : w.current) ? e.mountingPointRef.current : window.document.body;
1290
+ if (!b || s.getIsMounted())
1274
1291
  return;
1275
- const S = me({
1292
+ const v = me({
1276
1293
  content: "",
1277
1294
  ...u,
1278
1295
  afterClose: C
1279
1296
  });
1280
- return S.mount(g), l.current = S.elements.bottomSheetContentWrapper ?? null, h.current = S, m(S), () => {
1281
- c.unmount();
1297
+ return v.mount(b), l.current = v.elements.bottomSheetContentWrapper ?? null, h.current = v, m(v), () => {
1298
+ s.unmount();
1282
1299
  };
1283
1300
  },
1284
1301
  [e.mountingPointRef, u, C]
@@ -1306,25 +1323,25 @@ function ye(t = {}) {
1306
1323
  }, [e.current]);
1307
1324
  const {
1308
1325
  beforeOpen: a,
1309
- afterOpen: s,
1326
+ afterOpen: c,
1310
1327
  beforeClose: u,
1311
1328
  afterClose: h,
1312
- onDragStart: c,
1329
+ onDragStart: s,
1313
1330
  onDragMove: m,
1314
1331
  onDragEnd: C,
1315
1332
  ...l
1316
1333
  } = t, E = () => {
1317
1334
  a == null || a();
1318
- }, g = () => {
1319
- s == null || s(), o(!0);
1320
- }, S = () => {
1335
+ }, b = () => {
1336
+ c == null || c(), o(!0);
1337
+ }, v = () => {
1321
1338
  u == null || u();
1322
1339
  }, w = () => {
1323
1340
  h == null || h(), o(!1);
1324
1341
  }, L = () => {
1325
- c == null || c();
1326
- }, H = (y, v) => {
1327
- m == null || m(y, v);
1342
+ s == null || s();
1343
+ }, k = (y, S) => {
1344
+ m == null || m(y, S);
1328
1345
  }, P = () => {
1329
1346
  C == null || C();
1330
1347
  }, $ = Pt(() => ({
@@ -1332,11 +1349,11 @@ function ye(t = {}) {
1332
1349
  isOpen: n,
1333
1350
  setIsOpen: o,
1334
1351
  beforeOpen: E,
1335
- afterOpen: g,
1336
- beforeClose: S,
1352
+ afterOpen: b,
1353
+ beforeClose: v,
1337
1354
  afterClose: w,
1338
1355
  onDragStart: L,
1339
- onDragMove: H,
1356
+ onDragMove: k,
1340
1357
  onDragEnd: P,
1341
1358
  ...l
1342
1359
  }), [e.current, n, o, t]), G = z(() => {
@@ -1348,7 +1365,7 @@ function ye(t = {}) {
1348
1365
  r.moveTo(...y);
1349
1366
  },
1350
1367
  [r]
1351
- ), T = z(
1368
+ ), H = z(
1352
1369
  (...y) => {
1353
1370
  r.snapTo(...y);
1354
1371
  },
@@ -1362,7 +1379,7 @@ function ye(t = {}) {
1362
1379
  open: G,
1363
1380
  close: Y,
1364
1381
  moveTo: I,
1365
- snapTo: T
1382
+ snapTo: H
1366
1383
  };
1367
1384
  }
1368
1385
  export {
@@ -1 +1 @@
1
- (function(M,b){typeof exports=="object"&&typeof module<"u"?b(exports,require("react"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","react-dom"],b):(M=typeof globalThis<"u"?globalThis:M||self,b(M.BottomSheet={},M.React,M.ReactDOM))})(this,function(M,b,At){"use strict";function Bt(t){return t!=null}(function(){try{if(typeof document<"u"){var t=document.createElement("style");t.appendChild(document.createTextNode('.pbs-root{position:fixed;left:0;bottom:0;display:flex;flex-direction:column;align-items:center;justify-content:flex-start;width:100%;height:fit-content;max-height:100vh;z-index:2}.pbs-dialog-reset{background-color:transparent;color:inherit;border:none;outline:none;padding:0;margin:0}.pbs-backdrop{position:fixed;top:0;left:0;width:100%;height:100%;background-color:transparent;z-index:1;transition:background-color .2s ease-out}.pbs-backdrop.hidden{visibility:hidden}.pbs-backdrop.open{background-color:#454545b3}.pbs-backdrop.transparent{background-color:transparent}.pbs-container{--pbs-container-background-color: rgb(240, 240, 240);background-color:var(--pbs-container-background-color);position:relative;display:none;flex-direction:column;align-items:center;justify-content:flex-start;width:92%;height:fit-content;max-height:100vh;border-radius:10px 10px 0 0}.pbs-container.open{display:flex}.pbs-container .pbs-gap-filler{position:absolute;bottom:calc(-100vh + .5px);left:0;background-color:var(--pbs-container-background-color);content:"";width:100%;height:100vh}.pbs-handle{position:relative;display:flex;align-items:center;justify-content:center;width:100%;height:30px;cursor:pointer}.pbs-handle.hidden{display:none}.pbs-button-reset{background-color:transparent;-webkit-appearance:none;-moz-appearance:none;appearance:none;outline:none;border:none}button:focus.pbs-button-reset{outline:none}.pbs-handle-bar{background-color:#a8a8a8;position:relative;width:12%;height:7px;border-radius:12px}.pbs-handle-bar.hidden{display:none}.pbs-content-wrapper{position:relative;width:100%;height:fit-content;max-height:100%;overflow-y:scroll}.pbs-content-wrapper::-webkit-scrollbar{display:none}.example{-ms-overflow-style:none;scrollbar-width:none}')),document.head.appendChild(t)}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();var Dt=Object.defineProperty,Mt=(t,e,n)=>e in t?Dt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,K=(t,e,n)=>Mt(t,typeof e!="symbol"?e+"":e,n);function x(t){return typeof t=="string"}function Pt(t,e){return t.classList.contains(J(e))}function _(t,e){t.classList.add(J(e))}function ot(t,e){t.classList.remove(J(e))}function X(t,e,n){x(n)&&(x(e)&&ot(t,e),_(t,n))}function J(t){return x(t)?t.trim().replace(/\./g,""):""}function Y(t){return t.map(e=>J(e)).filter(Boolean).join(" ")}function Rt(t){return t.map(e=>e==null?void 0:e.trim()).filter(Boolean).map(e=>`.${e}`).join(" ")}const dt="open",pt="hidden";function rt(t,e){const n=e;if(Array.isArray(t)){t.forEach(o=>{Q(o,n),o.setAttribute("aria-modal",n?"true":"false")});return}Q(t,n),t.setAttribute("aria-modal",n?"true":"false")}function Q(t,e){e?(_(t,dt),ot(t,pt)):(_(t,pt),ot(t,dt))}function ht(t){return t instanceof HTMLElement}function B(t){return typeof t=="number"&&!Number.isNaN(t)}function Yt(t){ht(t)&&t.focus()}function It(t){if(!ht(t)||t.offsetParent===null||"disabled"in t&&t.disabled)return!1;const e=t.getAttribute("tabindex"),n=B(e)?parseInt(e,10):-1,o=["INPUT","BUTTON","SELECT","TEXTAREA","A","AREA","IFRAME"].includes(t.tagName),r=t instanceof HTMLAnchorElement&&t.href!==""||t instanceof HTMLAreaElement&&t.href!=="";return o||r||n>-1}var T=(t=>(t.Backdrop="pbs-backdrop",t.Root="pbs-root",t.Container="pbs-container",t.GapFiller="pbs-gap-filler",t.Handle="pbs-handle",t.HandleBar="pbs-handle-bar",t.ContentWrapper="pbs-content-wrapper",t))(T||{}),it=(t=>(t.Button="pbs-button-reset",t.Dialog="pbs-dialog-reset",t))(it||{}),Z=(t=>(t.Hidden="hidden",t))(Z||{});function R(t,e,n){const o=document.createElement(t);return e.split(" ").forEach(r=>{_(o,r)}),x(n)&&o.setAttribute("data-testid",n),o}Rt([T.Root,T.ContentWrapper]);function mt(t,e,n,o){switch(o){case"content-height":return e>=t?vt(t,e,n):0;case"middle":return-(t/2-e);case"top":return-(t-e)+n;default:return 0}}function ft(t,e){const n=e<t,o=e>t;return{isUp:n,isDown:o,stayedSame:e===t}}function bt(t,e){return e<t?-(t-e):e-t}function tt(t,e){return t>e?t-e:e-t}function Wt(t,e){const n=t<e,o=t>e;return{isUp:n,isDown:o,stayedSame:t===e}}function gt(t,e,n){const o=t==="above";return n.filter(r=>{const a=r*e.viewportHeight;return o?e.visibleHeight<a:e.visibleHeight>a})}function vt(t,e,n){return-(t-e)+n}function St(t){return Number(t.replace("px",""))}function et(t,...e){return Number(t.toFixed(...e))}function yt(t){const e=/(?<type>\w+)\((?<values>[^)]+)\)/g,n=[];let o;for(;(o=e.exec(t))!==null;){const r=o[1],a=o[2].split(",").map(i=>i.trim());n.push({type:r,values:a})}return n}function Nt(t){const e=t.style.transform,n=yt(e);return{transform:e,transformValues:n}}function Ct(t,e){return t.find(o=>o.type.startsWith(e))||null}const at="translate";function P(t){const e=t.style.transform,n=yt(e),o=Ct(n,at);return Et(o??{type:at,values:[]})}function nt(t,{x:e,y:n}){const{transform:o,transformValues:r}=Nt(t),a=Ct(r,at);if(a){const i=Et(a);t.style.transform=`translate(${e??i.x??0}px,${n??i.y??0}px)`;return}if(o){t.style.transform=`${o}, translate(${e??0}px,${n??0}px)`;return}t.style.transform=`translate(${e??0}px,${n??0}px)`}function Et(t){if(t.type!=="translate")throw new Error(`Could not get coordinates from ${t.type}, since is not translate.`);const e=t.values[0],n=t.values[1];return{x:St(e)??0,y:St(n)??0}}function st(t){return t!=null}function wt(t,{min:e,max:n}){return st(n)&&t>=n?n:st(e)&&t<=e?e:t}const Ft=(t,e,n)=>{e instanceof HTMLElement&&!Pt(e,T.Handle)&&n.scrollTop>=1||(t.isDragging=!0)},jt=(t,e,n,o)=>r=>{o.startY=t.getCoordinates(r).y,o.containerStartTranslate=P(e),n.onDragStart()},Ut=(t,e,n,o,r)=>a=>{$t(a,t,n,o,r,e,n.marginTop)};function $t(t,e,n,o,r,a,i){if(!o.isDragging||!B(o.startY))return;const s=e.getCoordinates(t).y,u=bt(o.startY,s),h=window.innerHeight,c=a.clientHeight,m=c-(o.containerStartTranslate.y+u);if(m>=h)return;const E=ft(o.startY,s);if(E.isUp&&!n.expandable&&m>=c)return;r.start(()=>{nt(a,{y:o.containerStartTranslate.y+u})},0);const l=h-i,w=c-o.containerStartTranslate.y;if(E.isUp){const v=l-w,y=l-m,k=wt(1-et(y/v,2),{min:0,max:1});n.onDragMove(E,k)}else if(E.isDown){const v=wt(et(1-m/w,2),{min:0,max:1});n.onDragMove(E,v)}}const Gt=(t,e,n,o,r,a,i)=>s=>{if(!o.isDragging||(o.isDragging=!1,!B(o.startY)))return;n.onDragEnd();const u=o.startY,h=t.getCoordinates(s).y,c=P(e).y,m=ft(u,h),E=window.innerHeight,l=e.clientHeight;if(m.isUp){const w=[...n.snapPoints].sort((k,A)=>k-A),v=l+-c;if(!n.expandable&&v>=l)return;for(const k of w){const A=k*window.innerHeight;if(v<=A){const H=tt(v,A);i.translateContainer({startY:c,endY:c-H,animationFrame:r,bottomSheetContainer:e});return}}const y=vt(E,l,n.marginTop);i.translateContainer({startY:c,endY:y,animationFrame:r,bottomSheetContainer:e})}else if(m.isDown){const w=[...n.snapPoints].sort((v,y)=>y-v);for(const v of w){const y=v*window.innerHeight,k=l+-c;if(k>=y){const A=tt(k,y);i.translateContainer({startY:c,endY:c+A,animationFrame:r,bottomSheetContainer:e});return}}a()}};var I=(t=>(t[t.All=-1]="All",t[t.None=0]="None",t[t.Capture=1]="Capture",t[t.Target=2]="Target",t[t.Bubble=3]="Bubble",t))(I||{});function kt(t){switch(t){case 0:return 0;case 1:return 1;case 2:return 2;case 3:return 3;default:return-1}}const _t={eventPhase:I.All};class q{constructor(e){K(this,"currentTarget"),this.currentTarget=e}addEventListeners({onStart:e,onStartOptions:n=_t,onMove:o,onEnd:r}){this.addTouchEventListeners({onStart:e,onStartOptions:n,onMove:o,onEnd:r}),this.addMouseEventListeners({onStart:e,onStartOptions:n,onMove:o,onEnd:r})}addTouchEventListeners({onStart:e,onStartOptions:n,onMove:o,onEnd:r}){e&&this.currentTarget.addEventListener("touchstart",a=>{if(n.eventPhase===I.All){e(a);return}kt(a.eventPhase)===n.eventPhase&&e(a)},{passive:!0}),o&&this.currentTarget.addEventListener("touchmove",o),r&&this.currentTarget.addEventListener("touchend",r)}addMouseEventListeners({onStart:e,onStartOptions:n,onMove:o,onEnd:r}){e&&this.currentTarget.addEventListener("mousedown",a=>{if(n.eventPhase===I.All){e(a);return}kt(a.eventPhase)===n.eventPhase&&e(a)},{passive:!0}),o&&this.currentTarget.addEventListener("mousemove",o),r&&this.currentTarget.addEventListener("mouseup",a=>{r(a)})}removeEventListeners({onStart:e,onMove:n,onEnd:o}){e&&this.currentTarget.removeEventListener("touchstart",e),o&&this.currentTarget.removeEventListener("touchend",o),n&&this.currentTarget.removeEventListener("touchmove",n),e&&this.currentTarget.removeEventListener("mousedown",e),n&&this.currentTarget.removeEventListener("mousemove",n),o&&this.currentTarget.removeEventListener("mouseup",o)}getCoordinates(e){if(e.type==="touchstart"||e.type==="mousedown"){if("touches"in e)return{x:e.touches[0].clientX,y:e.touches[0].clientY};if(e instanceof MouseEvent)return{x:e.clientX,y:e.clientY}}if(e.type==="touchend"||e.type==="mouseup"||e.type==="mousemove"||e.type==="touchmove"){if("touches"in e)return{x:e.changedTouches[0].clientX,y:e.changedTouches[0].clientY};if(e instanceof MouseEvent)return{x:e.clientX,y:e.clientY}}return{x:0,y:0}}}function Tt(t){const e=t;return`${e} ${e} 0px 0px`}function Xt(t,e){const n=qt(t);zt(n),n.bottomSheetContainer.style.width=t.width;const o=document.createElement("div");o.innerHTML=t.content??"";const r=window.innerHeight;n.bottomSheetContainer.style.maxHeight=`${r}px`,n.bottomSheetContentWrapper.appendChild(o);const a=Vt({bottomSheetElements:n,bottomSheetProps:t,options:e});return t.rootStyle&&Object.assign(n.bottomSheetRoot.style,t.rootStyle),t.backdropStyle&&Object.assign(n.bottomSheetBackdrop.style,t.backdropStyle),t.containerStyle&&Object.assign(n.bottomSheetContainer.style,t.containerStyle),t.handleStyle&&Object.assign(n.bottomSheetHandleBar.style,t.handleStyle),t.contentWrapperStyle&&Object.assign(n.bottomSheetContentWrapper.style,t.contentWrapperStyle),{elements:n,eventHandlers:a}}function qt(t){const e=R("dialog",Y([T.Root,it.Dialog,t.rootClass]),T.Root);e.ariaLabel=t.ariaLabel;const n=R("section",Y([T.Container,t.containerClass]),T.Container);t.containerBorderRadius&&(n.style.borderRadius=Tt(t.containerBorderRadius));const o=R("div",T.GapFiller,T.GapFiller),r=R("button",Y([T.Handle,it.Button,t.shouldShowHandle?null:Z.Hidden,t.handleClass]),T.Handle);r.setAttribute("type","button"),r.ariaLabel="bottom sheet close button";const a=R("span",Y([T.HandleBar,t.shouldShowHandle?null:Z.Hidden]),T.HandleBar),i=R("article",Y([T.ContentWrapper,t.contentWrapperClass]),T.ContentWrapper),s=R("div",Y([T.Backdrop,t.backdropClass,Z.Hidden]),T.Backdrop);return t.backdropColor&&(s.style.backgroundColor=t.backdropColor),t.backDropTransition&&(s.style.transition=t.backDropTransition),{bottomSheetRoot:e,bottomSheetBackdrop:s,bottomSheetContainer:n,bottomSheetHandle:r,bottomSheetHandleBar:a,bottomSheetContentWrapper:i,bottomSheetContainerGapFiller:o}}function zt({bottomSheetRoot:t,bottomSheetContainer:e,bottomSheetHandle:n,bottomSheetHandleBar:o,bottomSheetContentWrapper:r,bottomSheetContainerGapFiller:a}){t.appendChild(e),n.appendChild(o),e.appendChild(n),e.appendChild(r),e.appendChild(a)}function Vt({bottomSheetElements:t,bottomSheetProps:e,options:n}){const{bottomSheetRoot:o,bottomSheetContainer:r,bottomSheetHandle:a,bottomSheetContainerGapFiller:i,bottomSheetContentWrapper:s,bottomSheetBackdrop:u}=t,{animationFrame:h}=n,c=new q(a),m=new q(s),E=new q(i),l=e.dragTriggers.reduce((O,C)=>{const S=o.querySelectorAll(C);if(!S.length)return O;const p=Array.from(S).map(d=>d instanceof HTMLElement?new q(d):null).filter(d=>!!d);return[...O,...p]},[]),w=new q(window),v=jt(w,r,e,n.draggingState),y=Ut(w,r,e,n.draggingState,h),k=Gt(w,r,e,n.draggingState,h,n.onClose,n.bottomSheetState);function A(O){O.target instanceof Element&&!o.contains(O.target)&&n.onClose()}function H(O){Ft(n.draggingState,O.target,t.bottomSheetContentWrapper)}function j(O){const C=O??e;C.draggable&&(c.addEventListeners({onStart:H}),l.forEach(S=>{S.addEventListeners({onStart:H,onStartOptions:{eventPhase:I.Target}})})),C.draggable&&C.backgroundDraggable&&(m.addEventListeners({onStart:H,onStartOptions:{eventPhase:I.Target}}),E.addEventListeners({onStart:H})),C.draggable&&w.addEventListeners({onStart:v,onMove:y,onEnd:k}),C.draggable&&window.document.addEventListener("keyup",S=>{S.key==="Escape"&&n.onClose()}),a.addEventListener("keyup",S=>{if(S.key==="ArrowUp"){n.moveUp();return}if(S.key==="ArrowDown"){n.moveDown();return}if(S.shiftKey&&S.key==="Tab"){const p=U(t.bottomSheetContentWrapper);Yt(p)}})}function z(){e.shouldCloseOnOutsideClick?u.addEventListener("click",A):u.style.pointerEvents="none"}function V(){u.removeEventListener("click",A)}function U(O){let C=[...Array.from(O.childNodes).reverse()];for(;C.length;){const S=C.shift();if(It(S))return S;S&&(C=[...C,...Array.from(S.childNodes).reverse()])}return null}function $(){c.removeEventListeners({onStart:H}),m.removeEventListeners({onStart:H}),E.removeEventListeners({onStart:H}),l.forEach(O=>{O.removeEventListeners({onStart:H})}),w.removeEventListeners({onStart:v,onMove:y,onEnd:k})}return{attachEventListeners:j,clearEventListeners:$,attacheOnOpenEventListeners:z,clearOnOpenEventListeners:V}}class Kt{constructor(){K(this,"animationId"),K(this,"isInProgress"),K(this,"startedAt"),this.animationId=null,this.isInProgress=!1,this.startedAt=null}start(e,n,o=!1){this.isInProgress=!0;const r=a=>{this.startedAt||(this.startedAt=a);const i=a-this.startedAt,s=n===0?1:et(i/n,2),u=s>=1&&!o;e(s),u?this.stop():this.animationId=requestAnimationFrame(r)};this.animationId=requestAnimationFrame(r)}stop(){this.isInProgress=!1,this.startedAt=null,B(this.animationId)&&cancelAnimationFrame(this.animationId)}}function Jt(t){const{startY:e,endY:n,bottomSheetContainer:o,animationFrame:r,onEnd:a,animationTimingFunction:i,animationDuration:s}=t,u=bt(e,n);r.stop();let h=!1;r.start(c=>{nt(o,{y:e+u*i(c)}),!h&&c>=1&&(a==null||a(),h=!0)},s)}const ct=(t,e)=>n=>{Jt({...n,animationTimingFunction:t,animationDuration:e})},W={TOP:"top",MIDDLE:"middle",CONTENT_HEIGHT:"content-height",CLOSED:"closed"};function Qt(t){return!(!B(t)||t>1||t<0)}function Zt(t,e){const n={set(o,r,a,i){return e(r,a),Reflect.set(o,r,a,i)}};return new Proxy(t,n)}function te(...t){console.error(t)}const N={EASE:"ease",EASE_IN:"ease-in",EASE_OUT:"ease-out",EASE_IN_OUT:"ease-in-out",SPRING:"spring"};function ee(t){for(const e of Object.values(N))if(e===t)return!0;return!1}function Ht(t){return!!(t instanceof Object&&"p1x"in t&&"p1y"in t&&"p2x"in t&&"p2y"in t&&B(t.p1x)&&B(t.p1y)&&B(t.p2x)&&B(t.p2y))}function F(t,e,n,o){return function(s){return i(r(s))};function r(s){let u=0,h=1,c=s,m;if(s===0||s===1)return s;for(;u<h;){if(m=a(c),Math.abs(m-s)<.001)return c;s>m?u=c:h=c,c=(h+u)/2}return c}function a(s){return 3*t*s*Math.pow(1-s,2)+3*n*Math.pow(s,2)*(1-s)+Math.pow(s,3)}function i(s){return 3*e*s*Math.pow(1-s,2)+3*o*Math.pow(s,2)*(1-s)+Math.pow(s,3)}}const Ot=F(.25,.1,.25,1),ne=F(.42,0,1,1),Lt=F(.42,0,.58,1),oe=F(.4,.1,.6,1),re=F(.45,1.5,.55,1);function ie(t){switch(t){case N.EASE:return Ot;case N.EASE_IN:return ne;case N.EASE_OUT:return Lt;case N.EASE_IN_OUT:return oe;case N.SPRING:return re;default:return Ot}}function xt(t){return typeof t=="boolean"}const ae={ariaLabel:"Bottom sheet",content:"",defaultPosition:W.CONTENT_HEIGHT,marginTop:20,snapPoints:[],width:"92%",dragTriggers:[],beforeOpen:()=>{},afterOpen:()=>{},beforeClose:()=>{},afterClose:()=>{},onDragStart:()=>{},onDragMove:()=>{},onDragEnd:()=>{},expandable:!0,draggable:!0,backgroundDraggable:!0,shouldCloseOnOutsideClick:!0,shouldShowBackdrop:!0,shouldShowHandle:!0,backDropTransition:null,backdropColor:null,containerBorderRadius:null,rootClass:null,containerClass:null,handleClass:null,contentWrapperClass:null,backdropClass:null,draggingAnimationTimings:"ease-in-out",draggingAnimationDuration:180,rootStyle:{},containerStyle:{},handleStyle:{},contentWrapperStyle:{},backdropStyle:{}};function se(t){const e={...ae},n=Object.entries(t).reduce((o,r)=>{const[a,i]=r;return st(i)&&(o[a]=i),o},{});return{...e,...n}}function lt(t){if(Ht(t)){const{p1x:e,p1y:n,p2x:o,p2y:r}=t;return F(e,n,o,r)}return ee(t)?ie(t):Lt}function ce(t,e,n,o){function r(a,i){switch(a){case"content":x(i)&&(t.bottomSheetContentWrapper.innerHTML=i);break;case"width":x(i)&&(t.bottomSheetContainer.style.width=i);break;case"shouldShowHandle":xt(i)||Q(t.bottomSheetHandle,!1);break;case"shouldShowBackdrop":xt(i)||Q(t.bottomSheetBackdrop,!1);break;case"containerBorderRadius":x(i)&&(t.bottomSheetContainer.style.borderRadius=Tt(i));break;case"backdropColor":x(i)&&(t.bottomSheetBackdrop.style.backgroundColor=i);break;case"backDropTransition":x(i)&&(t.bottomSheetBackdrop.style.transition=i);break;case"rootClass":if(!x(i))return;X(t.bottomSheetRoot,n.rootClass,i);break;case"containerClass":if(!x(i))return;X(t.bottomSheetContainer,n.containerClass,i);break;case"handleClass":if(!x(i))return;X(t.bottomSheetHandle,n.handleClass,i);break;case"contentWrapperClass":if(!x(i))return;X(t.bottomSheetContentWrapper,n.contentWrapperClass,i);break;case"backdropClass":if(!x(i))return;X(t.bottomSheetBackdrop,n.backdropClass,i);break;case"expandable":o.clearEventListeners(),o.attachEventListeners(n);break;case"draggable":o.clearEventListeners(),o.attachEventListeners(n);break;case"draggingAnimationTimings":if(Ht(i)){const s=lt(i),u=ct(s,n.draggingAnimationDuration);e.translateContainer=u}break;case"draggingAnimationDuration":if(B(i)){const s=lt(n.draggingAnimationTimings),u=ct(s,i);e.translateContainer=u}break;case"rootStyle":n.rootStyle&&Object.assign(t.bottomSheetRoot.style,n.rootStyle);break;case"backdropStyle":n.backdropStyle&&Object.assign(t.bottomSheetBackdrop.style,n.backdropStyle);break;case"containerStyle":n.containerStyle&&Object.assign(t.bottomSheetContainer.style,n.containerStyle);break;case"handleStyle":n.handleStyle&&Object.assign(t.bottomSheetHandleBar.style,n.handleStyle);break;case"contentWrapperStyle":n.contentWrapperStyle&&Object.assign(t.bottomSheetContentWrapper.style,n.contentWrapperStyle);break}}return r}function le(t){const e=se(t),n=lt(t.draggingAnimationTimings),o={isMounted:!1,translateContainer:ct(n,e.draggingAnimationDuration)},r={startY:null,containerStartTranslate:{x:0,y:0},isDragging:!1,originalDocumentOverflowY:null,originalDocumentOverscrollBehavior:null};function a(){r.originalDocumentOverflowY&&r.originalDocumentOverflowY!=="hidden"&&(document.body.style.overflowY=r.originalDocumentOverflowY),r.originalDocumentOverscrollBehavior&&(document.body.style.position=r.originalDocumentOverscrollBehavior)}const i=new Kt,s={animationFrame:i,onClose:k,bottomSheetState:o,draggingState:r,snapTo:S,moveUp:O,moveDown:C},{elements:u,eventHandlers:h}=Xt(e,s),c=Zt(e,ce(u,o,e,h)),{bottomSheetBackdrop:m,bottomSheetRoot:E,bottomSheetContainer:l}=u,w=p=>{const d=p??window.document.body;d.appendChild(E),d.appendChild(m);const f=window.innerHeight;nt(l,{y:f}),h.attachEventListeners(),o.isMounted=!0},v=()=>{h.clearEventListeners(),Object.values(u).forEach(p=>{p.remove()}),a(),o.isMounted=!1},y=()=>{var p;if(A()||te('Bottom Sheet is not mounted yet. call the "mount" method first.'),(p=t.beforeOpen)==null||p.call(t),H())return;rt(m,!0),c.shouldShowBackdrop||_(m,"transparent"),rt([l],!0),nt(l,{y:l.clientHeight});const d=window.innerHeight,f=mt(d,l.clientHeight,c.marginTop,c.defaultPosition),g=P(l).y;o.translateContainer({startY:g,endY:f,animationFrame:i,bottomSheetContainer:l,onEnd:t.afterOpen});const L=document.body.style.overflowY;r.originalDocumentOverflowY=L||"initial";const D=document.body.style.overscrollBehavior;r.originalDocumentOverscrollBehavior=D||"initial",document.body.style.overflow="hidden",document.body.style.overscrollBehavior="contain",u.bottomSheetHandle.focus(),h.attacheOnOpenEventListeners()};function k(){var p;if(j())return;(p=t.beforeClose)==null||p.call(t);const d=P(l).y,f=l.clientHeight;o.translateContainer({startY:d,endY:f,animationFrame:i,bottomSheetContainer:l,onEnd:()=>{var g;(g=t.afterClose)==null||g.call(t),rt([m,l],!1),h.clearOnOpenEventListeners()}}),a()}function A(){return o.isMounted}function H(){const p=P(l).y,d=window.innerHeight,f=l.clientHeight>=d?d:l.clientHeight;return p<=f}function j(){return!H()}function z(){const p=P(l).y,d=l.clientHeight,f=window.innerHeight;if(p<=5&&p>=-5)return W.CONTENT_HEIGHT;const g=d-p;if(g===f/2)return W.MIDDLE;const L=f-c.marginTop,D=10;return g<=L+D&&g>=L-D?W.TOP:W.CLOSED}function V(){return l.clientHeight}function U(p){if(!H())return;const d=P(l).y,f=l.clientHeight-d,g=window.innerHeight-p,L=Wt(f,g),D=tt(f,g);o.translateContainer({startY:d,endY:d+(L.isUp?-D:D),animationFrame:i,bottomSheetContainer:l})}function $(p,{viewportHeight:d,visibleHeight:f}){let g=null;for(const L of p){const D=L*d,G=tt(f,D);(g===null||G<g)&&(g=G)}return{minOffset:g}}function O(){const p=[...c.snapPoints].reverse(),d=P(l).y,f=l.clientHeight,g=f-d;if(!c.expandable&&g>=f)return;const L=window.innerHeight,D=gt("above",{visibleHeight:g,viewportHeight:L},p),{minOffset:G}=$(D,{visibleHeight:g,viewportHeight:L});if(G===null&&g<L-c.marginTop){o.translateContainer({startY:d,endY:mt(L,f,c.marginTop,"top"),animationFrame:i,bottomSheetContainer:l});return}B(G)&&o.translateContainer({startY:d,endY:d-G,animationFrame:i,bottomSheetContainer:l})}function C(){const p=P(l).y,d=l.clientHeight-p;if(d<1)return;const f=window.innerHeight,g=gt("below",{visibleHeight:d,viewportHeight:f},c.snapPoints),{minOffset:L}=$(g,{visibleHeight:d,viewportHeight:f});B(L)&&o.translateContainer({startY:p,endY:p+L,animationFrame:i,bottomSheetContainer:l})}function S(p){const d=window.innerHeight;if(!Qt(p))return;const f=et(d*p,2);U(f)}return{props:c,elements:u,mount:w,unmount:v,open:y,close:k,getIsMounted:A,getIsOpen:H,getIsClosed:j,getPosition:z,getHeight:V,moveTo:U,snapTo:S}}function ut(){return{elements:{bottomSheetRoot:void 0,bottomSheetBackdrop:void 0,bottomSheetContainer:void 0,bottomSheetHandle:void 0,bottomSheetHandleBar:void 0,bottomSheetContentWrapper:void 0,bottomSheetContainerGapFiller:void 0},mount:()=>{},unmount:()=>{},open:()=>{},close:()=>{},getIsMounted:()=>!1,getHeight:()=>0,getIsOpen:()=>!1,getIsClosed:()=>!0,getPosition:()=>W.CLOSED,moveTo:()=>{},snapTo:()=>{},props:{content:""}}}const ue=ut(),de=b.forwardRef(function(e,n){const{children:o,isOpen:r,setIsOpen:a,afterClose:i,mountingPointRef:s,...u}=e,h=b.useRef(ue),[c,m]=b.useState(h.current);b.useImperativeHandle(n,()=>c,[c]);const E=b.useCallback(()=>{a(!1),i==null||i()},[i]);b.useEffect(()=>{r?c.open():c.close()},[r]);const l=b.useRef(null);return b.useEffect(function(){var k;if(s&&!s.current)return;const v=Bt((k=e.mountingPointRef)==null?void 0:k.current)?e.mountingPointRef.current:window.document.body;if(!v||c.getIsMounted())return;const y=le({content:"",...u,afterClose:E});return y.mount(v),l.current=y.elements.bottomSheetContentWrapper??null,h.current=y,m(y),()=>{c.unmount()}},[e.mountingPointRef,u,E]),b.useEffect(function(){Object.assign(h.current.props,{...u}),m(h.current)},[u]),b.useEffect(function(){return()=>{h.current.unmount()}},[]),l.current?At.createPortal(e.children,l.current):null}),pe=ut();function he(t={}){const e=b.useRef(pe),[n,o]=b.useState(!1),[r,a]=b.useState(e.current);b.useEffect(()=>{a(e.current)},[e.current]);const{beforeOpen:i,afterOpen:s,beforeClose:u,afterClose:h,onDragStart:c,onDragMove:m,onDragEnd:E,...l}=t,w=()=>{i==null||i()},v=()=>{s==null||s(),o(!0)},y=()=>{u==null||u()},k=()=>{h==null||h(),o(!1)},A=()=>{c==null||c()},H=(C,S)=>{m==null||m(C,S)},j=()=>{E==null||E()},z=b.useMemo(()=>({ref:e,isOpen:n,setIsOpen:o,beforeOpen:w,afterOpen:v,beforeClose:y,afterClose:k,onDragStart:A,onDragMove:H,onDragEnd:j,...l}),[e.current,n,o,t]),V=b.useCallback(()=>{o(!0)},[o]),U=b.useCallback(()=>{o(!0)},[o]),$=b.useCallback((...C)=>{r.moveTo(...C)},[r]),O=b.useCallback((...C)=>{r.snapTo(...C)},[r]);return{props:z,instance:r,isOpen:n,setIsOpen:o,open:V,close:U,moveTo:$,snapTo:O}}M.BottomSheet=de,M.createPlaceholderBottomSheet=ut,M.useBottomSheet=he,Object.defineProperty(M,Symbol.toStringTag,{value:"Module"})});
1
+ (function(M,g){typeof exports=="object"&&typeof module<"u"?g(exports,require("react"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","react-dom"],g):(M=typeof globalThis<"u"?globalThis:M||self,g(M.BottomSheet={},M.React,M.ReactDOM))})(this,function(M,g,At){"use strict";function Bt(t){return t!=null}(function(){try{if(typeof document<"u"){var t=document.createElement("style");t.appendChild(document.createTextNode('.pbs-root{position:fixed;left:0;bottom:0;display:flex;flex-direction:column;align-items:center;justify-content:flex-start;width:100%;height:fit-content;max-height:100vh;z-index:2}.pbs-dialog-reset{background-color:transparent;color:inherit;border:none;outline:none;padding:0;margin:0}.pbs-backdrop{position:fixed;top:0;left:0;width:100%;height:100%;background-color:transparent;z-index:1;transition:background-color .2s ease-out}.pbs-backdrop.hidden{visibility:hidden}.pbs-backdrop.open{background-color:#454545b3}.pbs-backdrop.transparent{background-color:transparent}.pbs-container{--pbs-container-background-color: rgb(240, 240, 240);background-color:var(--pbs-container-background-color);position:relative;display:none;flex-direction:column;align-items:center;justify-content:flex-start;width:92%;height:fit-content;max-height:100vh;border-radius:10px 10px 0 0}.pbs-container.open{display:flex}.pbs-container .pbs-gap-filler{position:absolute;bottom:calc(-100vh + .5px);left:0;background-color:var(--pbs-container-background-color);content:"";width:100%;height:100vh}.pbs-handle{position:relative;display:flex;align-items:center;justify-content:center;width:100%;height:30px;cursor:pointer}.pbs-handle.hidden{display:none}.pbs-button-reset{background-color:transparent;-webkit-appearance:none;-moz-appearance:none;appearance:none;outline:none;border:none}button:focus.pbs-button-reset{outline:none}.pbs-handle-bar{background-color:#a8a8a8;position:relative;width:12%;height:7px;border-radius:12px}.pbs-handle-bar.hidden{display:none}.pbs-content-wrapper{position:relative;width:100%;height:fit-content;max-height:100%;overflow-y:scroll}.pbs-content-wrapper::-webkit-scrollbar{display:none}.example{-ms-overflow-style:none;scrollbar-width:none}')),document.head.appendChild(t)}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();var Dt=Object.defineProperty,Mt=(t,e,n)=>e in t?Dt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,J=(t,e,n)=>Mt(t,typeof e!="symbol"?e+"":e,n);function x(t){return typeof t=="string"}function Pt(t,e){return t.classList.contains(Q(e))}function _(t,e){t.classList.add(Q(e))}function ot(t,e){t.classList.remove(Q(e))}function X(t,e,n){x(n)&&(x(e)&&ot(t,e),_(t,n))}function Q(t){return x(t)?t.trim().replace(/\./g,""):""}function R(t){return t.map(e=>Q(e)).filter(Boolean).join(" ")}function Yt(t){return t.map(e=>e==null?void 0:e.trim()).filter(Boolean).map(e=>`.${e}`).join(" ")}const dt="open",pt="hidden";function rt(t,e){const n=e;if(Array.isArray(t)){t.forEach(o=>{Z(o,n),o.setAttribute("aria-modal",n?"true":"false")});return}Z(t,n),t.setAttribute("aria-modal",n?"true":"false")}function Z(t,e){e?(_(t,dt),ot(t,pt)):(_(t,pt),ot(t,dt))}function ht(t){return t instanceof HTMLElement}function B(t){return typeof t=="number"&&!Number.isNaN(t)}function Rt(t){ht(t)&&t.focus()}function It(t){if(!ht(t)||t.offsetParent===null||"disabled"in t&&t.disabled)return!1;const e=t.getAttribute("tabindex"),n=B(e)?parseInt(e,10):-1,o=["INPUT","BUTTON","SELECT","TEXTAREA","A","AREA","IFRAME"].includes(t.tagName),r=t instanceof HTMLAnchorElement&&t.href!==""||t instanceof HTMLAreaElement&&t.href!=="";return o||r||n>-1}var k=(t=>(t.Backdrop="pbs-backdrop",t.Root="pbs-root",t.Container="pbs-container",t.GapFiller="pbs-gap-filler",t.Handle="pbs-handle",t.HandleBar="pbs-handle-bar",t.ContentWrapper="pbs-content-wrapper",t))(k||{}),it=(t=>(t.Button="pbs-button-reset",t.Dialog="pbs-dialog-reset",t))(it||{}),tt=(t=>(t.Hidden="hidden",t))(tt||{});function Y(t,e,n){const o=document.createElement(t);return e.split(" ").forEach(r=>{_(o,r)}),x(n)&&o.setAttribute("data-testid",n),o}Yt([k.Root,k.ContentWrapper]);function mt(t,e,n,o){switch(o){case"content-height":return e>=t?vt(t,e,n):0;case"middle":return-(t/2-e);case"top":return-(t-e)+n;default:return 0}}function ft(t,e){const n=e<t,o=e>t;return{isUp:n,isDown:o,stayedSame:e===t}}function bt(t,e){return e<t?-(t-e):e-t}function q(t,e){return t>e?t-e:e-t}function Wt(t,e){const n=t<e,o=t>e;return{isUp:n,isDown:o,stayedSame:t===e}}function gt(t,e,n){const o=t==="above";return n.filter(r=>{const a=r*e.viewportHeight;return o?e.visibleHeight<a:e.visibleHeight>a})}function vt(t,e,n){return-(t-e)+n}function St(t){return Number(t.replace("px",""))}function et(t,...e){return Number(t.toFixed(...e))}function yt(t){const e=/(?<type>\w+)\((?<values>[^)]+)\)/g,n=[];let o;for(;(o=e.exec(t))!==null;){const r=o[1],a=o[2].split(",").map(i=>i.trim());n.push({type:r,values:a})}return n}function Nt(t){const e=t.style.transform,n=yt(e);return{transform:e,transformValues:n}}function Ct(t,e){return t.find(o=>o.type.startsWith(e))||null}const at="translate";function P(t){const e=t.style.transform,n=yt(e),o=Ct(n,at);return Et(o??{type:at,values:[]})}function nt(t,{x:e,y:n}){const{transform:o,transformValues:r}=Nt(t),a=Ct(r,at);if(a){const i=Et(a);t.style.transform=`translate(${e??i.x??0}px,${n??i.y??0}px)`;return}if(o){t.style.transform=`${o}, translate(${e??0}px,${n??0}px)`;return}t.style.transform=`translate(${e??0}px,${n??0}px)`}function Et(t){if(t.type!=="translate")throw new Error(`Could not get coordinates from ${t.type}, since is not translate.`);const e=t.values[0],n=t.values[1];return{x:St(e)??0,y:St(n)??0}}function st(t){return t!=null}function wt(t,{min:e,max:n}){return st(n)&&t>=n?n:st(e)&&t<=e?e:t}const Ft=(t,e,n)=>{e instanceof HTMLElement&&!Pt(e,k.Handle)&&n.scrollTop>=1||(t.isDragging=!0)},jt=(t,e,n,o)=>r=>{o.startY=t.getCoordinates(r).y,o.containerStartTranslate=P(e),n.onDragStart()},Ut=(t,e,n,o,r)=>a=>{$t(a,t,n,o,r,e,n.marginTop)};function $t(t,e,n,o,r,a,i){if(!o.isDragging||!B(o.startY))return;const c=e.getCoordinates(t).y,u=bt(o.startY,c),h=window.innerHeight,s=a.clientHeight,m=s-(o.containerStartTranslate.y+u);if(m>=h)return;const E=ft(o.startY,c);if(E.isUp&&!n.expandable&&m>=s||n.preventClosing&&m<=s)return;r.start(()=>{nt(a,{y:o.containerStartTranslate.y+u})},0);const l=h-i,w=s-o.containerStartTranslate.y;if(E.isUp){const f=l-w,S=l-m,T=wt(1-et(S/f,2),{min:0,max:1});n.onDragMove(E,T)}else if(E.isDown){const f=wt(et(1-m/w,2),{min:0,max:1});n.onDragMove(E,f)}}const Gt=(t,e,n,o,r,a,i)=>c=>{if(!o.isDragging||(o.isDragging=!1,!B(o.startY)))return;n.onDragEnd();const u=o.startY,h=t.getCoordinates(c).y,s=P(e).y,m=ft(u,h),E=window.innerHeight,l=e.clientHeight;if(m.isUp){const w=[...n.snapPoints].sort((T,A)=>T-A),f=l+-s;if(!n.expandable&&f>=l)return;for(const T of w){const A=T*window.innerHeight;if(f<=A){const H=q(f,A);i.translateContainer({startY:s,endY:s-H,animationFrame:r,bottomSheetContainer:e});return}}const S=vt(E,l,n.marginTop);i.translateContainer({startY:s,endY:S,animationFrame:r,bottomSheetContainer:e})}else if(m.isDown){const w=[...n.snapPoints].sort((f,S)=>S-f);for(const f of w){const S=f*window.innerHeight,T=l+-s;if(T>=S){const A=q(T,S);i.translateContainer({startY:s,endY:s+A,animationFrame:r,bottomSheetContainer:e});return}}if(n.preventClosing){const f=l+-s;if(f>=l){const S=q(f,l);i.translateContainer({startY:s,endY:s+S,animationFrame:r,bottomSheetContainer:e})}return}a()}};var I=(t=>(t[t.All=-1]="All",t[t.None=0]="None",t[t.Capture=1]="Capture",t[t.Target=2]="Target",t[t.Bubble=3]="Bubble",t))(I||{});function Tt(t){switch(t){case 0:return 0;case 1:return 1;case 2:return 2;case 3:return 3;default:return-1}}const _t={eventPhase:I.All};class z{constructor(e){J(this,"currentTarget"),this.currentTarget=e}addEventListeners({onStart:e,onStartOptions:n=_t,onMove:o,onEnd:r}){this.addTouchEventListeners({onStart:e,onStartOptions:n,onMove:o,onEnd:r}),this.addMouseEventListeners({onStart:e,onStartOptions:n,onMove:o,onEnd:r})}addTouchEventListeners({onStart:e,onStartOptions:n,onMove:o,onEnd:r}){e&&this.currentTarget.addEventListener("touchstart",a=>{if(n.eventPhase===I.All){e(a);return}Tt(a.eventPhase)===n.eventPhase&&e(a)},{passive:!0}),o&&this.currentTarget.addEventListener("touchmove",o),r&&this.currentTarget.addEventListener("touchend",r)}addMouseEventListeners({onStart:e,onStartOptions:n,onMove:o,onEnd:r}){e&&this.currentTarget.addEventListener("mousedown",a=>{if(n.eventPhase===I.All){e(a);return}Tt(a.eventPhase)===n.eventPhase&&e(a)},{passive:!0}),o&&this.currentTarget.addEventListener("mousemove",o),r&&this.currentTarget.addEventListener("mouseup",a=>{r(a)})}removeEventListeners({onStart:e,onMove:n,onEnd:o}){e&&this.currentTarget.removeEventListener("touchstart",e),o&&this.currentTarget.removeEventListener("touchend",o),n&&this.currentTarget.removeEventListener("touchmove",n),e&&this.currentTarget.removeEventListener("mousedown",e),n&&this.currentTarget.removeEventListener("mousemove",n),o&&this.currentTarget.removeEventListener("mouseup",o)}getCoordinates(e){if(e.type==="touchstart"||e.type==="mousedown"){if("touches"in e)return{x:e.touches[0].clientX,y:e.touches[0].clientY};if(e instanceof MouseEvent)return{x:e.clientX,y:e.clientY}}if(e.type==="touchend"||e.type==="mouseup"||e.type==="mousemove"||e.type==="touchmove"){if("touches"in e)return{x:e.changedTouches[0].clientX,y:e.changedTouches[0].clientY};if(e instanceof MouseEvent)return{x:e.clientX,y:e.clientY}}return{x:0,y:0}}}function kt(t){const e=t;return`${e} ${e} 0px 0px`}function Xt(t,e){const n=qt(t);zt(n),n.bottomSheetContainer.style.width=t.width;const o=document.createElement("div");o.innerHTML=t.content??"";const r=window.innerHeight;n.bottomSheetContainer.style.maxHeight=`${r}px`,n.bottomSheetContentWrapper.appendChild(o);const a=Vt({bottomSheetElements:n,bottomSheetProps:t,options:e});return t.rootStyle&&Object.assign(n.bottomSheetRoot.style,t.rootStyle),t.backdropStyle&&Object.assign(n.bottomSheetBackdrop.style,t.backdropStyle),t.containerStyle&&Object.assign(n.bottomSheetContainer.style,t.containerStyle),t.handleStyle&&Object.assign(n.bottomSheetHandleBar.style,t.handleStyle),t.contentWrapperStyle&&Object.assign(n.bottomSheetContentWrapper.style,t.contentWrapperStyle),{elements:n,eventHandlers:a}}function qt(t){const e=Y("dialog",R([k.Root,it.Dialog,t.rootClass]),k.Root);e.ariaLabel=t.ariaLabel;const n=Y("section",R([k.Container,t.containerClass]),k.Container);t.containerBorderRadius&&(n.style.borderRadius=kt(t.containerBorderRadius));const o=Y("div",k.GapFiller,k.GapFiller),r=Y("button",R([k.Handle,it.Button,t.shouldShowHandle?null:tt.Hidden,t.handleClass]),k.Handle);r.setAttribute("type","button"),r.ariaLabel="bottom sheet close button";const a=Y("span",R([k.HandleBar,t.shouldShowHandle?null:tt.Hidden]),k.HandleBar),i=Y("article",R([k.ContentWrapper,t.contentWrapperClass]),k.ContentWrapper),c=Y("div",R([k.Backdrop,t.backdropClass,tt.Hidden]),k.Backdrop);return t.backdropColor&&(c.style.backgroundColor=t.backdropColor),t.backDropTransition&&(c.style.transition=t.backDropTransition),{bottomSheetRoot:e,bottomSheetBackdrop:c,bottomSheetContainer:n,bottomSheetHandle:r,bottomSheetHandleBar:a,bottomSheetContentWrapper:i,bottomSheetContainerGapFiller:o}}function zt({bottomSheetRoot:t,bottomSheetContainer:e,bottomSheetHandle:n,bottomSheetHandleBar:o,bottomSheetContentWrapper:r,bottomSheetContainerGapFiller:a}){t.appendChild(e),n.appendChild(o),e.appendChild(n),e.appendChild(r),e.appendChild(a)}function Vt({bottomSheetElements:t,bottomSheetProps:e,options:n}){const{bottomSheetRoot:o,bottomSheetContainer:r,bottomSheetHandle:a,bottomSheetContainerGapFiller:i,bottomSheetContentWrapper:c,bottomSheetBackdrop:u}=t,{animationFrame:h}=n,s=new z(a),m=new z(c),E=new z(i),l=e.dragTriggers.reduce((O,C)=>{const y=o.querySelectorAll(C);if(!y.length)return O;const p=Array.from(y).map(d=>d instanceof HTMLElement?new z(d):null).filter(d=>!!d);return[...O,...p]},[]),w=new z(window),f=jt(w,r,e,n.draggingState),S=Ut(w,r,e,n.draggingState,h),T=Gt(w,r,e,n.draggingState,h,n.onClose,n.bottomSheetState);function A(O){O.target instanceof Element&&!o.contains(O.target)&&n.onClose()}function H(O){Ft(n.draggingState,O.target,t.bottomSheetContentWrapper)}function j(O){const C=O??e;C.draggable&&(s.addEventListeners({onStart:H}),l.forEach(y=>{y.addEventListeners({onStart:H,onStartOptions:{eventPhase:I.Target}})})),C.draggable&&C.backgroundDraggable&&(m.addEventListeners({onStart:H,onStartOptions:{eventPhase:I.Target}}),E.addEventListeners({onStart:H})),C.draggable&&w.addEventListeners({onStart:f,onMove:S,onEnd:T}),C.draggable&&window.document.addEventListener("keyup",y=>{y.key==="Escape"&&n.onClose()}),a.addEventListener("keyup",y=>{if(y.key==="ArrowUp"){n.moveUp();return}if(y.key==="ArrowDown"){n.moveDown();return}if(y.shiftKey&&y.key==="Tab"){const p=U(t.bottomSheetContentWrapper);Rt(p)}})}function V(){e.shouldCloseOnOutsideClick?u.addEventListener("click",A):u.style.pointerEvents="none"}function K(){u.removeEventListener("click",A)}function U(O){let C=[...Array.from(O.childNodes).reverse()];for(;C.length;){const y=C.shift();if(It(y))return y;y&&(C=[...C,...Array.from(y.childNodes).reverse()])}return null}function $(){s.removeEventListeners({onStart:H}),m.removeEventListeners({onStart:H}),E.removeEventListeners({onStart:H}),l.forEach(O=>{O.removeEventListeners({onStart:H})}),w.removeEventListeners({onStart:f,onMove:S,onEnd:T})}return{attachEventListeners:j,clearEventListeners:$,attacheOnOpenEventListeners:V,clearOnOpenEventListeners:K}}class Kt{constructor(){J(this,"animationId"),J(this,"isInProgress"),J(this,"startedAt"),this.animationId=null,this.isInProgress=!1,this.startedAt=null}start(e,n,o=!1){this.isInProgress=!0;const r=a=>{this.startedAt||(this.startedAt=a);const i=a-this.startedAt,c=n===0?1:et(i/n,2),u=c>=1&&!o;e(c),u?this.stop():this.animationId=requestAnimationFrame(r)};this.animationId=requestAnimationFrame(r)}stop(){this.isInProgress=!1,this.startedAt=null,B(this.animationId)&&cancelAnimationFrame(this.animationId)}}function Jt(t){const{startY:e,endY:n,bottomSheetContainer:o,animationFrame:r,onEnd:a,animationTimingFunction:i,animationDuration:c}=t,u=bt(e,n);r.stop();let h=!1;r.start(s=>{nt(o,{y:e+u*i(s)}),!h&&s>=1&&(a==null||a(),h=!0)},c)}const ct=(t,e)=>n=>{Jt({...n,animationTimingFunction:t,animationDuration:e})},W={TOP:"top",MIDDLE:"middle",CONTENT_HEIGHT:"content-height",CLOSED:"closed"};function Qt(t){return!(!B(t)||t>1||t<0)}function Zt(t,e){const n={set(o,r,a,i){return e(r,a),Reflect.set(o,r,a,i)}};return new Proxy(t,n)}function te(...t){console.error(t)}const N={EASE:"ease",EASE_IN:"ease-in",EASE_OUT:"ease-out",EASE_IN_OUT:"ease-in-out",SPRING:"spring"};function ee(t){for(const e of Object.values(N))if(e===t)return!0;return!1}function Ht(t){return!!(t instanceof Object&&"p1x"in t&&"p1y"in t&&"p2x"in t&&"p2y"in t&&B(t.p1x)&&B(t.p1y)&&B(t.p2x)&&B(t.p2y))}function F(t,e,n,o){return function(c){return i(r(c))};function r(c){let u=0,h=1,s=c,m;if(c===0||c===1)return c;for(;u<h;){if(m=a(s),Math.abs(m-c)<.001)return s;c>m?u=s:h=s,s=(h+u)/2}return s}function a(c){return 3*t*c*Math.pow(1-c,2)+3*n*Math.pow(c,2)*(1-c)+Math.pow(c,3)}function i(c){return 3*e*c*Math.pow(1-c,2)+3*o*Math.pow(c,2)*(1-c)+Math.pow(c,3)}}const Ot=F(.25,.1,.25,1),ne=F(.42,0,1,1),Lt=F(.42,0,.58,1),oe=F(.4,.1,.6,1),re=F(.45,1.5,.55,1);function ie(t){switch(t){case N.EASE:return Ot;case N.EASE_IN:return ne;case N.EASE_OUT:return Lt;case N.EASE_IN_OUT:return oe;case N.SPRING:return re;default:return Ot}}function xt(t){return typeof t=="boolean"}const ae={ariaLabel:"Bottom sheet",content:"",defaultPosition:W.CONTENT_HEIGHT,marginTop:20,snapPoints:[],width:"92%",dragTriggers:[],beforeOpen:()=>{},afterOpen:()=>{},beforeClose:()=>{},afterClose:()=>{},onDragStart:()=>{},onDragMove:()=>{},onDragEnd:()=>{},expandable:!0,preventClosing:!1,draggable:!0,backgroundDraggable:!0,shouldCloseOnOutsideClick:!0,shouldShowBackdrop:!0,shouldShowHandle:!0,backDropTransition:null,backdropColor:null,containerBorderRadius:null,rootClass:null,containerClass:null,handleClass:null,contentWrapperClass:null,backdropClass:null,draggingAnimationTimings:"ease-in-out",draggingAnimationDuration:180,rootStyle:{},containerStyle:{},handleStyle:{},contentWrapperStyle:{},backdropStyle:{}};function se(t){const e={...ae},n=Object.entries(t).reduce((o,r)=>{const[a,i]=r;return st(i)&&(o[a]=i),o},{});return{...e,...n}}function lt(t){if(Ht(t)){const{p1x:e,p1y:n,p2x:o,p2y:r}=t;return F(e,n,o,r)}return ee(t)?ie(t):Lt}function ce(t,e,n,o){function r(a,i){switch(a){case"content":x(i)&&(t.bottomSheetContentWrapper.innerHTML=i);break;case"width":x(i)&&(t.bottomSheetContainer.style.width=i);break;case"shouldShowHandle":xt(i)||Z(t.bottomSheetHandle,!1);break;case"shouldShowBackdrop":xt(i)||Z(t.bottomSheetBackdrop,!1);break;case"containerBorderRadius":x(i)&&(t.bottomSheetContainer.style.borderRadius=kt(i));break;case"backdropColor":x(i)&&(t.bottomSheetBackdrop.style.backgroundColor=i);break;case"backDropTransition":x(i)&&(t.bottomSheetBackdrop.style.transition=i);break;case"rootClass":if(!x(i))return;X(t.bottomSheetRoot,n.rootClass,i);break;case"containerClass":if(!x(i))return;X(t.bottomSheetContainer,n.containerClass,i);break;case"handleClass":if(!x(i))return;X(t.bottomSheetHandle,n.handleClass,i);break;case"contentWrapperClass":if(!x(i))return;X(t.bottomSheetContentWrapper,n.contentWrapperClass,i);break;case"backdropClass":if(!x(i))return;X(t.bottomSheetBackdrop,n.backdropClass,i);break;case"expandable":o.clearEventListeners(),o.attachEventListeners(n);break;case"preventClosing":o.clearEventListeners(),o.attachEventListeners(n);break;case"draggable":o.clearEventListeners(),o.attachEventListeners(n);break;case"draggingAnimationTimings":if(Ht(i)){const c=lt(i),u=ct(c,n.draggingAnimationDuration);e.translateContainer=u}break;case"draggingAnimationDuration":if(B(i)){const c=lt(n.draggingAnimationTimings),u=ct(c,i);e.translateContainer=u}break;case"rootStyle":n.rootStyle&&Object.assign(t.bottomSheetRoot.style,n.rootStyle);break;case"backdropStyle":n.backdropStyle&&Object.assign(t.bottomSheetBackdrop.style,n.backdropStyle);break;case"containerStyle":n.containerStyle&&Object.assign(t.bottomSheetContainer.style,n.containerStyle);break;case"handleStyle":n.handleStyle&&Object.assign(t.bottomSheetHandleBar.style,n.handleStyle);break;case"contentWrapperStyle":n.contentWrapperStyle&&Object.assign(t.bottomSheetContentWrapper.style,n.contentWrapperStyle);break}}return r}function le(t){const e=se(t),n=lt(t.draggingAnimationTimings),o={isMounted:!1,translateContainer:ct(n,e.draggingAnimationDuration)},r={startY:null,containerStartTranslate:{x:0,y:0},isDragging:!1,originalDocumentOverflowY:null,originalDocumentOverscrollBehavior:null};function a(){r.originalDocumentOverflowY&&r.originalDocumentOverflowY!=="hidden"&&(document.body.style.overflowY=r.originalDocumentOverflowY),r.originalDocumentOverscrollBehavior&&(document.body.style.position=r.originalDocumentOverscrollBehavior)}const i=new Kt,c={animationFrame:i,onClose:T,bottomSheetState:o,draggingState:r,snapTo:y,moveUp:O,moveDown:C},{elements:u,eventHandlers:h}=Xt(e,c),s=Zt(e,ce(u,o,e,h)),{bottomSheetBackdrop:m,bottomSheetRoot:E,bottomSheetContainer:l}=u,w=p=>{const d=p??window.document.body;d.appendChild(E),d.appendChild(m);const b=window.innerHeight;nt(l,{y:b}),h.attachEventListeners(),o.isMounted=!0},f=()=>{h.clearEventListeners(),Object.values(u).forEach(p=>{p.remove()}),a(),o.isMounted=!1},S=()=>{var p;if(A()||te('Bottom Sheet is not mounted yet. call the "mount" method first.'),(p=t.beforeOpen)==null||p.call(t),H())return;rt(m,!0),s.shouldShowBackdrop||_(m,"transparent"),rt([l],!0),nt(l,{y:l.clientHeight});const d=window.innerHeight,b=mt(d,l.clientHeight,s.marginTop,s.defaultPosition),v=P(l).y;o.translateContainer({startY:v,endY:b,animationFrame:i,bottomSheetContainer:l,onEnd:t.afterOpen});const L=document.body.style.overflowY;r.originalDocumentOverflowY=L||"initial";const D=document.body.style.overscrollBehavior;r.originalDocumentOverscrollBehavior=D||"initial",document.body.style.overflow="hidden",document.body.style.overscrollBehavior="contain",u.bottomSheetHandle.focus(),h.attacheOnOpenEventListeners()};function T(){var p;if(j())return;(p=t.beforeClose)==null||p.call(t);const d=P(l).y,b=l.clientHeight;o.translateContainer({startY:d,endY:b,animationFrame:i,bottomSheetContainer:l,onEnd:()=>{var v;(v=t.afterClose)==null||v.call(t),rt([m,l],!1),h.clearOnOpenEventListeners()}}),a()}function A(){return o.isMounted}function H(){const p=P(l).y,d=window.innerHeight,b=l.clientHeight>=d?d:l.clientHeight;return p<=b}function j(){return!H()}function V(){const p=P(l).y,d=l.clientHeight,b=window.innerHeight;if(p<=5&&p>=-5)return W.CONTENT_HEIGHT;const v=d-p;if(v===b/2)return W.MIDDLE;const L=b-s.marginTop,D=10;return v<=L+D&&v>=L-D?W.TOP:W.CLOSED}function K(){return l.clientHeight}function U(p){if(!H())return;const d=P(l).y,b=l.clientHeight-d,v=window.innerHeight-p,L=Wt(b,v),D=q(b,v);o.translateContainer({startY:d,endY:d+(L.isUp?-D:D),animationFrame:i,bottomSheetContainer:l})}function $(p,{viewportHeight:d,visibleHeight:b}){let v=null;for(const L of p){const D=L*d,G=q(b,D);(v===null||G<v)&&(v=G)}return{minOffset:v}}function O(){const p=[...s.snapPoints].reverse(),d=P(l).y,b=l.clientHeight,v=b-d;if(!s.expandable&&v>=b)return;const L=window.innerHeight,D=gt("above",{visibleHeight:v,viewportHeight:L},p),{minOffset:G}=$(D,{visibleHeight:v,viewportHeight:L});if(G===null&&v<L-s.marginTop){o.translateContainer({startY:d,endY:mt(L,b,s.marginTop,"top"),animationFrame:i,bottomSheetContainer:l});return}B(G)&&o.translateContainer({startY:d,endY:d-G,animationFrame:i,bottomSheetContainer:l})}function C(){const p=P(l).y,d=l.clientHeight-p;if(d<1)return;const b=window.innerHeight,v=gt("below",{visibleHeight:d,viewportHeight:b},s.snapPoints),{minOffset:L}=$(v,{visibleHeight:d,viewportHeight:b});B(L)&&o.translateContainer({startY:p,endY:p+L,animationFrame:i,bottomSheetContainer:l})}function y(p){const d=window.innerHeight;if(!Qt(p))return;const b=et(d*p,2);U(b)}return{props:s,elements:u,mount:w,unmount:f,open:S,close:T,getIsMounted:A,getIsOpen:H,getIsClosed:j,getPosition:V,getHeight:K,moveTo:U,snapTo:y}}function ut(){return{elements:{bottomSheetRoot:void 0,bottomSheetBackdrop:void 0,bottomSheetContainer:void 0,bottomSheetHandle:void 0,bottomSheetHandleBar:void 0,bottomSheetContentWrapper:void 0,bottomSheetContainerGapFiller:void 0},mount:()=>{},unmount:()=>{},open:()=>{},close:()=>{},getIsMounted:()=>!1,getHeight:()=>0,getIsOpen:()=>!1,getIsClosed:()=>!0,getPosition:()=>W.CLOSED,moveTo:()=>{},snapTo:()=>{},props:{content:""}}}const ue=ut(),de=g.forwardRef(function(e,n){const{children:o,isOpen:r,setIsOpen:a,afterClose:i,mountingPointRef:c,...u}=e,h=g.useRef(ue),[s,m]=g.useState(h.current);g.useImperativeHandle(n,()=>s,[s]);const E=g.useCallback(()=>{a(!1),i==null||i()},[i]);g.useEffect(()=>{r?s.open():s.close()},[r]);const l=g.useRef(null);return g.useEffect(function(){var T;if(c&&!c.current)return;const f=Bt((T=e.mountingPointRef)==null?void 0:T.current)?e.mountingPointRef.current:window.document.body;if(!f||s.getIsMounted())return;const S=le({content:"",...u,afterClose:E});return S.mount(f),l.current=S.elements.bottomSheetContentWrapper??null,h.current=S,m(S),()=>{s.unmount()}},[e.mountingPointRef,u,E]),g.useEffect(function(){Object.assign(h.current.props,{...u}),m(h.current)},[u]),g.useEffect(function(){return()=>{h.current.unmount()}},[]),l.current?At.createPortal(e.children,l.current):null}),pe=ut();function he(t={}){const e=g.useRef(pe),[n,o]=g.useState(!1),[r,a]=g.useState(e.current);g.useEffect(()=>{a(e.current)},[e.current]);const{beforeOpen:i,afterOpen:c,beforeClose:u,afterClose:h,onDragStart:s,onDragMove:m,onDragEnd:E,...l}=t,w=()=>{i==null||i()},f=()=>{c==null||c(),o(!0)},S=()=>{u==null||u()},T=()=>{h==null||h(),o(!1)},A=()=>{s==null||s()},H=(C,y)=>{m==null||m(C,y)},j=()=>{E==null||E()},V=g.useMemo(()=>({ref:e,isOpen:n,setIsOpen:o,beforeOpen:w,afterOpen:f,beforeClose:S,afterClose:T,onDragStart:A,onDragMove:H,onDragEnd:j,...l}),[e.current,n,o,t]),K=g.useCallback(()=>{o(!0)},[o]),U=g.useCallback(()=>{o(!0)},[o]),$=g.useCallback((...C)=>{r.moveTo(...C)},[r]),O=g.useCallback((...C)=>{r.snapTo(...C)},[r]);return{props:V,instance:r,isOpen:n,setIsOpen:o,open:K,close:U,moveTo:$,snapTo:O}}M.BottomSheet=de,M.createPlaceholderBottomSheet=ut,M.useBottomSheet=he,Object.defineProperty(M,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plainsheet/react",
3
- "version": "0.4.7",
3
+ "version": "0.4.8",
4
4
  "private": false,
5
5
  "sideEffects": false,
6
6
  "license": "MIT",
@@ -31,7 +31,7 @@
31
31
  "access": "public"
32
32
  },
33
33
  "dependencies": {
34
- "@plainsheet/core": "0.7.7",
34
+ "@plainsheet/core": "0.7.8",
35
35
  "@plainsheet/utility": "0.0.3"
36
36
  },
37
37
  "devDependencies": {