@plainsheet/core 0.7.5 → 0.7.7

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,3 +1,3 @@
1
1
  (function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.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(e)}}catch(n){console.error("vite-plugin-css-injected-by-js",n)}})();
2
- (function(g,O){typeof exports=="object"&&typeof module<"u"?O(exports):typeof define=="function"&&define.amd?define(["exports"],O):(g=typeof globalThis<"u"?globalThis:g||self,O(g.BottomSheet={}))})(this,function(g){"use strict";var ln=Object.defineProperty;var un=(g,O,T)=>O in g?ln(g,O,{enumerable:!0,configurable:!0,writable:!0,value:T}):g[O]=T;var X=(g,O,T)=>un(g,typeof O!="symbol"?O+"":O,T);var O=document.createElement("style");O.textContent=`.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}
3
- /*$vite$:1*/`,document.head.appendChild(O);function T(t){return typeof t=="string"}function xt(t,n){return t.classList.contains(K(n))}function G(t,n){t.classList.add(K(n))}function rt(t,n){t.classList.remove(K(n))}function j(t,n,e){T(e)&&(T(n)&&rt(t,n),G(t,e))}function K(t){return T(t)?t.trim().replace(/\./g,""):""}function R(t){return t.map(n=>K(n)).filter(Boolean).join(" ")}function Yt(t){return t.map(n=>n==null?void 0:n.trim()).filter(Boolean).map(n=>`.${n}`).join(" ")}const ht="open",gt="hidden";function ot(t,n){const e=n;if(Array.isArray(t)){t.forEach(r=>{q(r,e),r.setAttribute("aria-modal",e?"true":"false")});return}q(t,e),t.setAttribute("aria-modal",e?"true":"false")}function q(t,n){n?(G(t,ht),rt(t,gt)):(G(t,gt),rt(t,ht))}function pt(t){return t instanceof HTMLElement}function B(t){return typeof t=="number"&&!Number.isNaN(t)}function Pt(t){pt(t)&&t.focus()}function It(t){if(!pt(t)||t.offsetParent===null||"disabled"in t&&t.disabled)return!1;const e=t.getAttribute("tabindex"),r=B(e)?parseInt(e,10):-1,i=["INPUT","BUTTON","SELECT","TEXTAREA","A","AREA","IFRAME"].includes(t.tagName),s=t instanceof HTMLAnchorElement&&t.href!==""||t instanceof HTMLAreaElement&&t.href!=="";return i||s||r>-1}var E=(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))(E||{}),J=(t=>(t.Button="pbs-button-reset",t.Dialog="pbs-dialog-reset",t))(J||{}),V=(t=>(t.Hidden="hidden",t))(V||{});function N(t,n,e){const r=document.createElement(t);return n.split(" ").forEach(i=>{G(r,i)}),T(e)&&r.setAttribute("data-testid",e),r}const Nt={CONTENTS_WRAPPER:Yt([E.Root,E.ContentWrapper])};function mt(t,n,e,r){switch(r){case"content-height":return n>=t?vt(t,n,e):0;case"middle":return-(t/2-n);case"top":return-(t-n)+e;default:return 0}}function bt(t,n){const e=n<t,r=n>t;return{isUp:e,isDown:r,stayedSame:n===t}}function Tt(t,n){return n<t?-(t-n):n-t}function Q(t,n){return t>n?t-n:n-t}function Mt(t,n){const e=t<n,r=t>n;return{isUp:e,isDown:r,stayedSame:t===n}}function Et(t,n,e){const r=t==="above";return e.filter(o=>{const i=o*n.viewportHeight;return r?n.visibleHeight<i:n.visibleHeight>i})}function vt(t,n,e){return-(t-n)+e}function Ct(t){return Number(t.replace("px",""))}function Z(t,...n){return Number(t.toFixed(...n))}function wt(t){const n=/(?<type>\w+)\((?<values>[^)]+)\)/g,e=[];let r;for(;(r=n.exec(t))!==null;){const o=r[1],i=r[2].split(",").map(s=>s.trim());e.push({type:o,values:i})}return e}function _t(t){const n=t.style.transform,e=wt(n);return{transform:n,transformValues:e}}function yt(t,n){const e=t.find(r=>r.type.startsWith(n));return e||null}const it="translate";function I(t){const n=t.style.transform,e=wt(n),r=yt(e,it);return Ht(r??{type:it,values:[]})}function tt(t,{x:n,y:e}){const{transform:r,transformValues:o}=_t(t),i=yt(o,it);if(i){const s=Ht(i);t.style.transform=`translate(${n??s.x??0}px,${e??s.y??0}px)`;return}if(r){t.style.transform=`${r}, translate(${n??0}px,${e??0}px)`;return}t.style.transform=`translate(${n??0}px,${e??0}px)`}function Ht(t){if(t.type!=="translate")throw new Error(`Could not get coordinates from ${t.type}, since is not translate.`);const n=t.values[0],e=t.values[1];return{x:Ct(n)??0,y:Ct(e)??0}}function st(t){return t!=null}function Ot(t,{min:n,max:e}){return st(e)&&t>=e?e:st(n)&&t<=n?n:t}const Ft=(t,n,e)=>{n instanceof HTMLElement&&!xt(n,E.Handle)&&e.scrollTop>=1||(t.isDragging=!0)},Rt=(t,n,e,r)=>o=>{r.startY=t.getCoordinates(o).y,r.containerStartTranslate=I(n),e.onDragStart()},Ut=(t,n,e,r,o)=>i=>{Wt(i,t,e,r,o,n,e.marginTop)};function Wt(t,n,e,r,o,i,s){if(!r.isDragging||!B(r.startY))return;const l=n.getCoordinates(t).y,a=Tt(r.startY,l),b=window.innerHeight,f=i.clientHeight,d=f-(r.containerStartTranslate.y+a);if(d>=b)return;const v=bt(r.startY,l);if(v.isUp&&!e.expandable&&d>=f)return;o.start(()=>{tt(i,{y:r.containerStartTranslate.y+a})},0);const x=b-s,c=f-r.containerStartTranslate.y;if(v.isUp){const w=x-c,k=x-d,A=Ot(1-Z(k/w,2),{min:0,max:1});e.onDragMove(v,A)}else if(v.isDown){const w=Ot(Z(1-d/c,2),{min:0,max:1});e.onDragMove(v,w)}}const $t=(t,n,e,r,o,i,s)=>l=>{if(!r.isDragging||(r.isDragging=!1,!B(r.startY)))return;e.onDragEnd();const a=r.startY,b=t.getCoordinates(l).y,f=I(n).y,d=bt(a,b),v=window.innerHeight,x=n.clientHeight;if(d.isUp){const c=[...e.snapPoints].sort((A,Y)=>A-Y),w=x+-f;if(!e.expandable&&w>=x)return;for(const A of c){const Y=A*window.innerHeight;if(w<=Y){const S=Q(w,Y);s.translateContainer({startY:f,endY:f-S,animationFrame:o,bottomSheetContainer:n});return}}const k=vt(v,x,e.marginTop);s.translateContainer({startY:f,endY:k,animationFrame:o,bottomSheetContainer:n})}else if(d.isDown){const c=[...e.snapPoints].sort((w,k)=>k-w);for(const w of c){const k=w*window.innerHeight,A=x+-f;if(A>=k){const Y=Q(A,k);s.translateContainer({startY:f,endY:f+Y,animationFrame:o,bottomSheetContainer:n});return}}i()}};var M=(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))(M||{});function at(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:M.All};class z{constructor(n){X(this,"currentTarget");this.currentTarget=n}addEventListeners({onStart:n,onStartOptions:e=Gt,onMove:r,onEnd:o}){this.addTouchEventListeners({onStart:n,onStartOptions:e,onMove:r,onEnd:o}),this.addMouseEventListeners({onStart:n,onStartOptions:e,onMove:r,onEnd:o})}addTouchEventListeners({onStart:n,onStartOptions:e,onMove:r,onEnd:o}){n&&this.currentTarget.addEventListener("touchstart",i=>{if(e.eventPhase===M.All){n(i);return}at(i.eventPhase)===e.eventPhase&&n(i)},{passive:!0}),r&&this.currentTarget.addEventListener("touchmove",r),o&&this.currentTarget.addEventListener("touchend",o)}addMouseEventListeners({onStart:n,onStartOptions:e,onMove:r,onEnd:o}){n&&this.currentTarget.addEventListener("mousedown",i=>{if(e.eventPhase===M.All){n(i);return}at(i.eventPhase)===e.eventPhase&&n(i)},{passive:!0}),r&&this.currentTarget.addEventListener("mousemove",r),o&&this.currentTarget.addEventListener("mouseup",i=>{o(i)})}removeEventListeners({onStart:n,onMove:e,onEnd:r}){n&&this.currentTarget.removeEventListener("touchstart",n),r&&this.currentTarget.removeEventListener("touchend",r),e&&this.currentTarget.removeEventListener("touchmove",e),n&&this.currentTarget.removeEventListener("mousedown",n),e&&this.currentTarget.removeEventListener("mousemove",e),r&&this.currentTarget.removeEventListener("mouseup",r)}getCoordinates(n){if(n.type==="touchstart"||n.type==="mousedown"){if("touches"in n)return{x:n.touches[0].clientX,y:n.touches[0].clientY};if(n instanceof MouseEvent)return{x:n.clientX,y:n.clientY}}if(n.type==="touchend"||n.type==="mouseup"||n.type==="mousemove"||n.type==="touchmove"){if("touches"in n)return{x:n.changedTouches[0].clientX,y:n.changedTouches[0].clientY};if(n instanceof MouseEvent)return{x:n.clientX,y:n.clientY}}return{x:0,y:0}}}function Lt(t){const n=t;return`${n} ${n} 0px 0px`}function jt(t,n){const e=Vt(t);zt(e),e.bottomSheetContainer.style.width=t.width;const r=document.createElement("div");r.innerHTML=t.content??"";const o=window.innerHeight;e.bottomSheetContainer.style.maxHeight=`${o}px`,e.bottomSheetContentWrapper.appendChild(r);const i=Xt({bottomSheetElements:e,bottomSheetProps:t,options:n});return{elements:e,eventHandlers:i}}function Vt(t){const n=N("dialog",R([E.Root,J.Dialog,t.rootClass]),E.Root);n.ariaLabel=t.ariaLabel;const e=N("section",R([E.Container,t.containerClass]),E.Container);t.containerBorderRadius&&(e.style.borderRadius=Lt(t.containerBorderRadius));const r=N("div",E.GapFiller,E.GapFiller),o=N("button",R([E.Handle,J.Button,t.shouldShowHandle?null:V.Hidden,t.handleClass]),E.Handle);o.setAttribute("type","button"),o.ariaLabel="bottom sheet close button";const i=N("span",R([E.HandleBar,t.shouldShowHandle?null:V.Hidden]),E.HandleBar),s=N("article",R([E.ContentWrapper,t.contentWrapperClass]),E.ContentWrapper),l=N("div",R([E.Backdrop,t.backdropClass,V.Hidden]),E.Backdrop);return t.backdropColor&&(l.style.backgroundColor=t.backdropColor),t.backDropTransition&&(l.style.transition=t.backDropTransition),{bottomSheetRoot:n,bottomSheetBackdrop:l,bottomSheetContainer:e,bottomSheetHandle:o,bottomSheetHandleBar:i,bottomSheetContentWrapper:s,bottomSheetContainerGapFiller:r}}function zt({bottomSheetRoot:t,bottomSheetContainer:n,bottomSheetHandle:e,bottomSheetHandleBar:r,bottomSheetContentWrapper:o,bottomSheetContainerGapFiller:i}){t.appendChild(n),e.appendChild(r),n.appendChild(e),n.appendChild(o),n.appendChild(i)}function Xt({bottomSheetElements:t,bottomSheetProps:n,options:e}){const{bottomSheetRoot:r,bottomSheetContainer:o,bottomSheetHandle:i,bottomSheetContainerGapFiller:s,bottomSheetContentWrapper:l,bottomSheetBackdrop:a}=t,{animationFrame:b}=e,f=new z(i),d=new z(l),v=new z(s),x=n.dragTriggers.reduce((y,L)=>{const C=r.querySelectorAll(L);if(!C.length)return y;const $=Array.from(C).map(u=>u instanceof HTMLElement?new z(u):null).filter(u=>!!u);return[...y,...$]},[]),c=new z(window),w=Rt(c,o,n,e.draggingState),k=Ut(c,o,n,e.draggingState,b),A=$t(c,o,n,e.draggingState,b,e.onClose,e.bottomSheetState);function Y(y){y.target instanceof Element&&!r.contains(y.target)&&e.onClose()}function S(y){Ft(e.draggingState,y.target,t.bottomSheetContentWrapper)}function W(y){const L=y??n;L.draggable&&(f.addEventListeners({onStart:S}),x.forEach(C=>{C.addEventListeners({onStart:S,onStartOptions:{eventPhase:M.Target}})})),L.draggable&&L.backgroundDraggable&&(d.addEventListeners({onStart:S,onStartOptions:{eventPhase:M.Target}}),v.addEventListeners({onStart:S})),L.draggable&&c.addEventListeners({onStart:w,onMove:k,onEnd:A}),L.draggable&&window.document.addEventListener("keyup",C=>{C.key==="Escape"&&e.onClose()}),i.addEventListener("keyup",C=>{if(C.key==="ArrowUp"){e.moveUp();return}if(C.key==="ArrowDown"){e.moveDown();return}if(C.shiftKey&&C.key==="Tab"){const $=ft(t.bottomSheetContentWrapper);Pt($)}})}function nt(){n.shouldCloseOnOutsideClick?a.addEventListener("click",Y):a.style.pointerEvents="none"}function dt(){a.removeEventListener("click",Y)}function ft(y){let L=[...Array.from(y.childNodes).reverse()];for(;L.length;){const C=L.shift();if(It(C))return C;C&&(L=[...L,...Array.from(C.childNodes).reverse()])}return null}function et(){f.removeEventListeners({onStart:S}),d.removeEventListeners({onStart:S}),v.removeEventListeners({onStart:S}),x.forEach(y=>{y.removeEventListeners({onStart:S})}),c.removeEventListeners({onStart:w,onMove:k,onEnd:A})}return{attachEventListeners:W,clearEventListeners:et,attacheOnOpenEventListeners:nt,clearOnOpenEventListeners:dt}}class Kt{constructor(){X(this,"animationId");X(this,"isInProgress");X(this,"startedAt");this.animationId=null,this.isInProgress=!1,this.startedAt=null}start(n,e,r=!1){this.isInProgress=!0;const o=i=>{this.startedAt||(this.startedAt=i);const s=i-this.startedAt,a=e===0?1:Z(s/e,2),b=a>=1&&!r;n(a),b?this.stop():this.animationId=requestAnimationFrame(o)};this.animationId=requestAnimationFrame(o)}stop(){this.isInProgress=!1,this.startedAt=null,B(this.animationId)&&cancelAnimationFrame(this.animationId)}}function qt(t){const{startY:n,endY:e,bottomSheetContainer:r,animationFrame:o,onEnd:i,animationTimingFunction:s,animationDuration:l}=t,a=Tt(n,e);o.stop();let b=!1;o.start(f=>{tt(r,{y:n+a*s(f)}),!b&&f>=1&&(i==null||i(),b=!0)},l)}const ct=(t,n)=>e=>{qt({...e,animationTimingFunction:t,animationDuration:n})},_={TOP:"top",MIDDLE:"middle",CONTENT_HEIGHT:"content-height",CLOSED:"closed"};function Jt(t){return!(!B(t)||t>1||t<0)}function Qt(t,n){const e={set(r,o,i,s){return n(o,i),Reflect.set(r,o,i,s)}};return new Proxy(t,e)}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 kt(t){for(const n of Object.values(F))if(n===t)return!0;return!1}function lt(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 U(t,n,e,r){return function(a){return l(i(a))};function i(a){let b=0,f=1,d=a,v;if(a===0||a===1)return a;for(;b<f;){if(v=s(d),Math.abs(v-a)<.001)return d;a>v?b=d:f=d,d=(f+b)/2}return d}function s(a){return 3*t*a*Math.pow(1-a,2)+3*e*Math.pow(a,2)*(1-a)+Math.pow(a,3)}function l(a){return 3*n*a*Math.pow(1-a,2)+3*r*Math.pow(a,2)*(1-a)+Math.pow(a,3)}}const At=U(.25,.1,.25,1),tn=U(.42,0,1,1),St=U(.42,0,.58,1),nn=U(.4,.1,.6,1),en=U(.45,1.5,.55,1);function rn(t){switch(t){case F.EASE:return At;case F.EASE_IN:return tn;case F.EASE_OUT:return St;case F.EASE_IN_OUT:return nn;case F.SPRING:return en;default:return At}}function Dt(t){return typeof t=="boolean"}const Bt={ariaLabel:"Bottom sheet",content:"",defaultPosition:_.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};function on(t){const n={...Bt},e=Object.entries(t).reduce((o,i)=>{const[s,l]=i;return st(l)&&(o[s]=l),o},{});return{...n,...e}}function ut(t){if(lt(t)){const{p1x:n,p1y:e,p2x:r,p2y:o}=t;return U(n,e,r,o)}return kt(t)?rn(t):St}function sn(t,n,e,r){function o(i,s){switch(i){case"content":T(s)&&(t.bottomSheetContentWrapper.innerHTML=s);break;case"width":T(s)&&(t.bottomSheetContainer.style.width=s);break;case"shouldShowHandle":Dt(s)||q(t.bottomSheetHandle,!1);break;case"shouldShowBackdrop":Dt(s)||q(t.bottomSheetBackdrop,!1);break;case"containerBorderRadius":T(s)&&(t.bottomSheetContainer.style.borderRadius=Lt(s));break;case"backdropColor":T(s)&&(t.bottomSheetBackdrop.style.backgroundColor=s);break;case"backDropTransition":T(s)&&(t.bottomSheetBackdrop.style.transition=s);break;case"rootClass":if(!T(s))return;j(t.bottomSheetRoot,e.rootClass,s);break;case"containerClass":if(!T(s))return;j(t.bottomSheetContainer,e.containerClass,s);break;case"handleClass":if(!T(s))return;j(t.bottomSheetHandle,e.handleClass,s);break;case"contentWrapperClass":if(!T(s))return;j(t.bottomSheetContentWrapper,e.contentWrapperClass,s);break;case"backdropClass":if(!T(s))return;j(t.bottomSheetBackdrop,e.backdropClass,s);break;case"expandable":r.clearEventListeners(),r.attachEventListeners(e);break;case"draggable":r.clearEventListeners(),r.attachEventListeners(e);break;case"draggingAnimationTimings":if(lt(s)){const l=ut(s),a=ct(l,e.draggingAnimationDuration);n.translateContainer=a}break;case"draggingAnimationDuration":if(B(s)){const l=ut(e.draggingAnimationTimings),a=ct(l,s);n.translateContainer=a}break}}return o}function an(t){const n=on(t),e=ut(t.draggingAnimationTimings),o={isMounted:!1,translateContainer:ct(e,n.draggingAnimationDuration)},i={startY:null,containerStartTranslate:{x:0,y:0},isDragging:!1,originalDocumentOverflowY:null,originalDocumentOverscrollBehavior:null};function s(){i.originalDocumentOverflowY&&i.originalDocumentOverflowY!=="hidden"&&(document.body.style.overflowY=i.originalDocumentOverflowY),i.originalDocumentOverscrollBehavior&&(document.body.style.position=i.originalDocumentOverscrollBehavior)}const l=new Kt,a={animationFrame:l,onClose:Y,bottomSheetState:o,draggingState:i,snapTo:$,moveUp:L,moveDown:C},{elements:b,eventHandlers:f}=jt(n,a),d=Qt(n,sn(b,o,n,f)),{bottomSheetBackdrop:v,bottomSheetRoot:x,bottomSheetContainer:c}=b,w=u=>{const h=u??window.document.body;h.appendChild(x),h.appendChild(v);const p=window.innerHeight;tt(c,{y:p}),f.attachEventListeners(),o.isMounted=!0},k=()=>{f.clearEventListeners(),Object.values(b).forEach(u=>{u.remove()}),s(),o.isMounted=!1},A=()=>{var P;if(S()||Zt('Bottom Sheet is not mounted yet. call the "mount" method first.'),(P=t.beforeOpen)==null||P.call(t),W())return;ot(v,!0),d.shouldShowBackdrop||G(v,"transparent"),ot([c],!0),tt(c,{y:c.clientHeight});const h=window.innerHeight,p=mt(h,c.clientHeight,d.marginTop,d.defaultPosition),m=I(c).y;o.translateContainer({startY:m,endY:p,animationFrame:l,bottomSheetContainer:c,onEnd:t.afterOpen});const H=document.body.style.overflowY;i.originalDocumentOverflowY=H||"initial";const D=document.body.style.overscrollBehavior;i.originalDocumentOverscrollBehavior=D||"initial",document.body.style.overflow="hidden",document.body.style.overscrollBehavior="contain",b.bottomSheetHandle.focus(),f.attacheOnOpenEventListeners()};function Y(){var p;if(nt())return;(p=t.beforeClose)==null||p.call(t);const u=I(c).y,h=c.clientHeight;o.translateContainer({startY:u,endY:h,animationFrame:l,bottomSheetContainer:c,onEnd:()=>{var m;(m=t.afterClose)==null||m.call(t),ot([v,c],!1),f.clearOnOpenEventListeners()}}),s()}function S(){return o.isMounted}function W(){const u=I(c).y,h=window.innerHeight,p=c.clientHeight>=h?h:c.clientHeight;return u<=p}function nt(){return!W()}function dt(){const u=I(c).y,h=c.clientHeight,p=window.innerHeight;if(u<=5&&u>=-5)return _.CONTENT_HEIGHT;const m=h-u;if(m===p/2)return _.MIDDLE;const H=p-d.marginTop,D=10;return m<=H+D&&m>=H-D?_.TOP:_.CLOSED}function ft(){return c.clientHeight}function et(u){if(!W())return;const h=I(c).y,m=c.clientHeight-h,H=window.innerHeight-u,D=Mt(m,H),P=Q(m,H);o.translateContainer({startY:h,endY:h+(D.isUp?-P:P),animationFrame:l,bottomSheetContainer:c})}function y(u,{viewportHeight:h,visibleHeight:p}){let m=null;for(const H of u){const D=H*h,P=Q(p,D);(m===null||P<m)&&(m=P)}return{minOffset:m}}function L(){const u=[...d.snapPoints].reverse(),h=I(c).y,p=c.clientHeight,m=p-h;if(!d.expandable&&m>=p)return;const H=window.innerHeight,D=Et("above",{visibleHeight:m,viewportHeight:H},u),{minOffset:P}=y(D,{visibleHeight:m,viewportHeight:H});if(P===null&&m<H-d.marginTop){o.translateContainer({startY:h,endY:mt(H,p,d.marginTop,"top"),animationFrame:l,bottomSheetContainer:c});return}B(P)&&o.translateContainer({startY:h,endY:h-P,animationFrame:l,bottomSheetContainer:c})}function C(){const u=I(c).y,p=c.clientHeight-u;if(p<1)return;const m=window.innerHeight,H=Et("below",{visibleHeight:p,viewportHeight:m},d.snapPoints),{minOffset:D}=y(H,{visibleHeight:p,viewportHeight:m});B(D)&&o.translateContainer({startY:u,endY:u+D,animationFrame:l,bottomSheetContainer:c})}function $(u){const h=window.innerHeight;if(!Jt(u))return;const p=Z(h*u,2);et(p)}return{props:d,elements:b,mount:w,unmount:k,open:A,close:Y,getIsMounted:S,getIsOpen:W,getIsClosed:nt,getPosition:dt,getHeight:ft,moveTo:et,snapTo:$}}function cn(){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:()=>_.CLOSED,moveTo:()=>{},snapTo:()=>{},props:{content:""}}}g.BOTTOM_SHEET_DEFAULT_PROPS=Bt,g.BOTTOM_SHEET_POSITION=_,g.BOTTOM_SHEET_SELECTORS=Nt,g.COMMON_ANIMATION_KEYS=F,g.ClassNames=E,g.EventPhase=M,g.ResetClassNames=J,g.UtilClassNames=V,g.createBottomSheet=an,g.createPlaceholderBottomSheet=cn,g.eventPhaseToEnum=at,g.isAnimationTimingPoints=lt,g.isCommonAnimationTimingsKey=kt,Object.defineProperty(g,Symbol.toStringTag,{value:"Module"})});
2
+ (function(g,O){typeof exports=="object"&&typeof module<"u"?O(exports):typeof define=="function"&&define.amd?define(["exports"],O):(g=typeof globalThis<"u"?globalThis:g||self,O(g.BottomSheet={}))})(this,function(g){"use strict";var ln=Object.defineProperty;var dn=(g,O,T)=>O in g?ln(g,O,{enumerable:!0,configurable:!0,writable:!0,value:T}):g[O]=T;var X=(g,O,T)=>dn(g,typeof O!="symbol"?O+"":O,T);var O=document.createElement("style");O.textContent=`.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}
3
+ /*$vite$:1*/`,document.head.appendChild(O);function T(t){return typeof t=="string"}function xt(t,n){return t.classList.contains(K(n))}function $(t,n){t.classList.add(K(n))}function rt(t,n){t.classList.remove(K(n))}function G(t,n,e){T(e)&&(T(n)&&rt(t,n),$(t,e))}function K(t){return T(t)?t.trim().replace(/\./g,""):""}function F(t){return t.map(n=>K(n)).filter(Boolean).join(" ")}function Yt(t){return t.map(n=>n==null?void 0:n.trim()).filter(Boolean).map(n=>`.${n}`).join(" ")}const ht="open",gt="hidden";function ot(t,n){const e=n;if(Array.isArray(t)){t.forEach(r=>{q(r,e),r.setAttribute("aria-modal",e?"true":"false")});return}q(t,e),t.setAttribute("aria-modal",e?"true":"false")}function q(t,n){n?($(t,ht),rt(t,gt)):($(t,gt),rt(t,ht))}function mt(t){return t instanceof HTMLElement}function D(t){return typeof t=="number"&&!Number.isNaN(t)}function Pt(t){mt(t)&&t.focus()}function It(t){if(!mt(t)||t.offsetParent===null||"disabled"in t&&t.disabled)return!1;const e=t.getAttribute("tabindex"),r=D(e)?parseInt(e,10):-1,i=["INPUT","BUTTON","SELECT","TEXTAREA","A","AREA","IFRAME"].includes(t.tagName),a=t instanceof HTMLAnchorElement&&t.href!==""||t instanceof HTMLAreaElement&&t.href!=="";return i||a||r>-1}var y=(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))(y||{}),J=(t=>(t.Button="pbs-button-reset",t.Dialog="pbs-dialog-reset",t))(J||{}),V=(t=>(t.Hidden="hidden",t))(V||{});function N(t,n,e){const r=document.createElement(t);return n.split(" ").forEach(i=>{$(r,i)}),T(e)&&r.setAttribute("data-testid",e),r}const Nt={CONTENTS_WRAPPER:Yt([y.Root,y.ContentWrapper])};function bt(t,n,e,r){switch(r){case"content-height":return n>=t?Et(t,n,e):0;case"middle":return-(t/2-n);case"top":return-(t-n)+e;default:return 0}}function pt(t,n){const e=n<t,r=n>t;return{isUp:e,isDown:r,stayedSame:n===t}}function Tt(t,n){return n<t?-(t-n):n-t}function Q(t,n){return t>n?t-n:n-t}function Mt(t,n){const e=t<n,r=t>n;return{isUp:e,isDown:r,stayedSame:t===n}}function yt(t,n,e){const r=t==="above";return e.filter(o=>{const i=o*n.viewportHeight;return r?n.visibleHeight<i:n.visibleHeight>i})}function Et(t,n,e){return-(t-n)+e}function Ct(t){return Number(t.replace("px",""))}function Z(t,...n){return Number(t.toFixed(...n))}function vt(t){const n=/(?<type>\w+)\((?<values>[^)]+)\)/g,e=[];let r;for(;(r=n.exec(t))!==null;){const o=r[1],i=r[2].split(",").map(a=>a.trim());e.push({type:o,values:i})}return e}function _t(t){const n=t.style.transform,e=vt(n);return{transform:n,transformValues:e}}function wt(t,n){const e=t.find(r=>r.type.startsWith(n));return e||null}const it="translate";function I(t){const n=t.style.transform,e=vt(n),r=wt(e,it);return St(r??{type:it,values:[]})}function tt(t,{x:n,y:e}){const{transform:r,transformValues:o}=_t(t),i=wt(o,it);if(i){const a=St(i);t.style.transform=`translate(${n??a.x??0}px,${e??a.y??0}px)`;return}if(r){t.style.transform=`${r}, translate(${n??0}px,${e??0}px)`;return}t.style.transform=`translate(${n??0}px,${e??0}px)`}function St(t){if(t.type!=="translate")throw new Error(`Could not get coordinates from ${t.type}, since is not translate.`);const n=t.values[0],e=t.values[1];return{x:Ct(n)??0,y:Ct(e)??0}}function at(t){return t!=null}function Ot(t,{min:n,max:e}){return at(e)&&t>=e?e:at(n)&&t<=n?n:t}const Rt=(t,n,e)=>{n instanceof HTMLElement&&!xt(n,y.Handle)&&e.scrollTop>=1||(t.isDragging=!0)},Ft=(t,n,e,r)=>o=>{r.startY=t.getCoordinates(o).y,r.containerStartTranslate=I(n),e.onDragStart()},jt=(t,n,e,r,o)=>i=>{Ut(i,t,e,r,o,n,e.marginTop)};function Ut(t,n,e,r,o,i,a){if(!r.isDragging||!D(r.startY))return;const l=n.getCoordinates(t).y,s=Tt(r.startY,l),p=window.innerHeight,f=i.clientHeight,u=f-(r.containerStartTranslate.y+s);if(u>=p)return;const E=pt(r.startY,l);if(E.isUp&&!e.expandable&&u>=f)return;o.start(()=>{tt(i,{y:r.containerStartTranslate.y+s})},0);const x=p-a,c=f-r.containerStartTranslate.y;if(E.isUp){const v=x-c,k=x-u,L=Ot(1-Z(k/v,2),{min:0,max:1});e.onDragMove(E,L)}else if(E.isDown){const v=Ot(Z(1-u/c,2),{min:0,max:1});e.onDragMove(E,v)}}const Wt=(t,n,e,r,o,i,a)=>l=>{if(!r.isDragging||(r.isDragging=!1,!D(r.startY)))return;e.onDragEnd();const s=r.startY,p=t.getCoordinates(l).y,f=I(n).y,u=pt(s,p),E=window.innerHeight,x=n.clientHeight;if(u.isUp){const c=[...e.snapPoints].sort((L,Y)=>L-Y),v=x+-f;if(!e.expandable&&v>=x)return;for(const L of c){const Y=L*window.innerHeight;if(v<=Y){const A=Q(v,Y);a.translateContainer({startY:f,endY:f-A,animationFrame:o,bottomSheetContainer:n});return}}const k=Et(E,x,e.marginTop);a.translateContainer({startY:f,endY:k,animationFrame:o,bottomSheetContainer:n})}else if(u.isDown){const c=[...e.snapPoints].sort((v,k)=>k-v);for(const v of c){const k=v*window.innerHeight,L=x+-f;if(L>=k){const Y=Q(L,k);a.translateContainer({startY:f,endY:f+Y,animationFrame:o,bottomSheetContainer:n});return}}i()}};var M=(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))(M||{});function st(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:M.All};class z{constructor(n){X(this,"currentTarget");this.currentTarget=n}addEventListeners({onStart:n,onStartOptions:e=$t,onMove:r,onEnd:o}){this.addTouchEventListeners({onStart:n,onStartOptions:e,onMove:r,onEnd:o}),this.addMouseEventListeners({onStart:n,onStartOptions:e,onMove:r,onEnd:o})}addTouchEventListeners({onStart:n,onStartOptions:e,onMove:r,onEnd:o}){n&&this.currentTarget.addEventListener("touchstart",i=>{if(e.eventPhase===M.All){n(i);return}st(i.eventPhase)===e.eventPhase&&n(i)},{passive:!0}),r&&this.currentTarget.addEventListener("touchmove",r),o&&this.currentTarget.addEventListener("touchend",o)}addMouseEventListeners({onStart:n,onStartOptions:e,onMove:r,onEnd:o}){n&&this.currentTarget.addEventListener("mousedown",i=>{if(e.eventPhase===M.All){n(i);return}st(i.eventPhase)===e.eventPhase&&n(i)},{passive:!0}),r&&this.currentTarget.addEventListener("mousemove",r),o&&this.currentTarget.addEventListener("mouseup",i=>{o(i)})}removeEventListeners({onStart:n,onMove:e,onEnd:r}){n&&this.currentTarget.removeEventListener("touchstart",n),r&&this.currentTarget.removeEventListener("touchend",r),e&&this.currentTarget.removeEventListener("touchmove",e),n&&this.currentTarget.removeEventListener("mousedown",n),e&&this.currentTarget.removeEventListener("mousemove",e),r&&this.currentTarget.removeEventListener("mouseup",r)}getCoordinates(n){if(n.type==="touchstart"||n.type==="mousedown"){if("touches"in n)return{x:n.touches[0].clientX,y:n.touches[0].clientY};if(n instanceof MouseEvent)return{x:n.clientX,y:n.clientY}}if(n.type==="touchend"||n.type==="mouseup"||n.type==="mousemove"||n.type==="touchmove"){if("touches"in n)return{x:n.changedTouches[0].clientX,y:n.changedTouches[0].clientY};if(n instanceof MouseEvent)return{x:n.clientX,y:n.clientY}}return{x:0,y:0}}}function Ht(t){const n=t;return`${n} ${n} 0px 0px`}function Gt(t,n){const e=Vt(t);zt(e),e.bottomSheetContainer.style.width=t.width;const r=document.createElement("div");r.innerHTML=t.content??"";const o=window.innerHeight;e.bottomSheetContainer.style.maxHeight=`${o}px`,e.bottomSheetContentWrapper.appendChild(r);const i=Xt({bottomSheetElements:e,bottomSheetProps:t,options:n});return t.rootStyle&&Object.assign(e.bottomSheetRoot.style,t.rootStyle),t.backdropStyle&&Object.assign(e.bottomSheetBackdrop.style,t.backdropStyle),t.containerStyle&&Object.assign(e.bottomSheetContainer.style,t.containerStyle),t.handleStyle&&Object.assign(e.bottomSheetHandleBar.style,t.handleStyle),t.contentWrapperStyle&&Object.assign(e.bottomSheetContentWrapper.style,t.contentWrapperStyle),{elements:e,eventHandlers:i}}function Vt(t){const n=N("dialog",F([y.Root,J.Dialog,t.rootClass]),y.Root);n.ariaLabel=t.ariaLabel;const e=N("section",F([y.Container,t.containerClass]),y.Container);t.containerBorderRadius&&(e.style.borderRadius=Ht(t.containerBorderRadius));const r=N("div",y.GapFiller,y.GapFiller),o=N("button",F([y.Handle,J.Button,t.shouldShowHandle?null:V.Hidden,t.handleClass]),y.Handle);o.setAttribute("type","button"),o.ariaLabel="bottom sheet close button";const i=N("span",F([y.HandleBar,t.shouldShowHandle?null:V.Hidden]),y.HandleBar),a=N("article",F([y.ContentWrapper,t.contentWrapperClass]),y.ContentWrapper),l=N("div",F([y.Backdrop,t.backdropClass,V.Hidden]),y.Backdrop);return t.backdropColor&&(l.style.backgroundColor=t.backdropColor),t.backDropTransition&&(l.style.transition=t.backDropTransition),{bottomSheetRoot:n,bottomSheetBackdrop:l,bottomSheetContainer:e,bottomSheetHandle:o,bottomSheetHandleBar:i,bottomSheetContentWrapper:a,bottomSheetContainerGapFiller:r}}function zt({bottomSheetRoot:t,bottomSheetContainer:n,bottomSheetHandle:e,bottomSheetHandleBar:r,bottomSheetContentWrapper:o,bottomSheetContainerGapFiller:i}){t.appendChild(n),e.appendChild(r),n.appendChild(e),n.appendChild(o),n.appendChild(i)}function Xt({bottomSheetElements:t,bottomSheetProps:n,options:e}){const{bottomSheetRoot:r,bottomSheetContainer:o,bottomSheetHandle:i,bottomSheetContainerGapFiller:a,bottomSheetContentWrapper:l,bottomSheetBackdrop:s}=t,{animationFrame:p}=e,f=new z(i),u=new z(l),E=new z(a),x=n.dragTriggers.reduce((w,H)=>{const C=r.querySelectorAll(H);if(!C.length)return w;const W=Array.from(C).map(d=>d instanceof HTMLElement?new z(d):null).filter(d=>!!d);return[...w,...W]},[]),c=new z(window),v=Ft(c,o,n,e.draggingState),k=jt(c,o,n,e.draggingState,p),L=Wt(c,o,n,e.draggingState,p,e.onClose,e.bottomSheetState);function Y(w){w.target instanceof Element&&!r.contains(w.target)&&e.onClose()}function A(w){Rt(e.draggingState,w.target,t.bottomSheetContentWrapper)}function U(w){const H=w??n;H.draggable&&(f.addEventListeners({onStart:A}),x.forEach(C=>{C.addEventListeners({onStart:A,onStartOptions:{eventPhase:M.Target}})})),H.draggable&&H.backgroundDraggable&&(u.addEventListeners({onStart:A,onStartOptions:{eventPhase:M.Target}}),E.addEventListeners({onStart:A})),H.draggable&&c.addEventListeners({onStart:v,onMove:k,onEnd:L}),H.draggable&&window.document.addEventListener("keyup",C=>{C.key==="Escape"&&e.onClose()}),i.addEventListener("keyup",C=>{if(C.key==="ArrowUp"){e.moveUp();return}if(C.key==="ArrowDown"){e.moveDown();return}if(C.shiftKey&&C.key==="Tab"){const W=ft(t.bottomSheetContentWrapper);Pt(W)}})}function nt(){n.shouldCloseOnOutsideClick?s.addEventListener("click",Y):s.style.pointerEvents="none"}function ut(){s.removeEventListener("click",Y)}function ft(w){let H=[...Array.from(w.childNodes).reverse()];for(;H.length;){const C=H.shift();if(It(C))return C;C&&(H=[...H,...Array.from(C.childNodes).reverse()])}return null}function et(){f.removeEventListeners({onStart:A}),u.removeEventListeners({onStart:A}),E.removeEventListeners({onStart:A}),x.forEach(w=>{w.removeEventListeners({onStart:A})}),c.removeEventListeners({onStart:v,onMove:k,onEnd:L})}return{attachEventListeners:U,clearEventListeners:et,attacheOnOpenEventListeners:nt,clearOnOpenEventListeners:ut}}class Kt{constructor(){X(this,"animationId");X(this,"isInProgress");X(this,"startedAt");this.animationId=null,this.isInProgress=!1,this.startedAt=null}start(n,e,r=!1){this.isInProgress=!0;const o=i=>{this.startedAt||(this.startedAt=i);const a=i-this.startedAt,s=e===0?1:Z(a/e,2),p=s>=1&&!r;n(s),p?this.stop():this.animationId=requestAnimationFrame(o)};this.animationId=requestAnimationFrame(o)}stop(){this.isInProgress=!1,this.startedAt=null,D(this.animationId)&&cancelAnimationFrame(this.animationId)}}function qt(t){const{startY:n,endY:e,bottomSheetContainer:r,animationFrame:o,onEnd:i,animationTimingFunction:a,animationDuration:l}=t,s=Tt(n,e);o.stop();let p=!1;o.start(f=>{tt(r,{y:n+s*a(f)}),!p&&f>=1&&(i==null||i(),p=!0)},l)}const ct=(t,n)=>e=>{qt({...e,animationTimingFunction:t,animationDuration:n})},_={TOP:"top",MIDDLE:"middle",CONTENT_HEIGHT:"content-height",CLOSED:"closed"};function Jt(t){return!(!D(t)||t>1||t<0)}function Qt(t,n){const e={set(r,o,i,a){return n(o,i),Reflect.set(r,o,i,a)}};return new Proxy(t,e)}function Zt(...t){console.error(t)}const R={EASE:"ease",EASE_IN:"ease-in",EASE_OUT:"ease-out",EASE_IN_OUT:"ease-in-out",SPRING:"spring"};function kt(t){for(const n of Object.values(R))if(n===t)return!0;return!1}function lt(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 j(t,n,e,r){return function(s){return l(i(s))};function i(s){let p=0,f=1,u=s,E;if(s===0||s===1)return s;for(;p<f;){if(E=a(u),Math.abs(E-s)<.001)return u;s>E?p=u:f=u,u=(f+p)/2}return u}function a(s){return 3*t*s*Math.pow(1-s,2)+3*e*Math.pow(s,2)*(1-s)+Math.pow(s,3)}function l(s){return 3*n*s*Math.pow(1-s,2)+3*r*Math.pow(s,2)*(1-s)+Math.pow(s,3)}}const Lt=j(.25,.1,.25,1),tn=j(.42,0,1,1),At=j(.42,0,.58,1),nn=j(.4,.1,.6,1),en=j(.45,1.5,.55,1);function rn(t){switch(t){case R.EASE:return Lt;case R.EASE_IN:return tn;case R.EASE_OUT:return At;case R.EASE_IN_OUT:return nn;case R.SPRING:return en;default:return Lt}}function Bt(t){return typeof t=="boolean"}const Dt={ariaLabel:"Bottom sheet",content:"",defaultPosition:_.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 on(t){const n={...Dt},e=Object.entries(t).reduce((o,i)=>{const[a,l]=i;return at(l)&&(o[a]=l),o},{});return{...n,...e}}function dt(t){if(lt(t)){const{p1x:n,p1y:e,p2x:r,p2y:o}=t;return j(n,e,r,o)}return kt(t)?rn(t):At}function an(t,n,e,r){function o(i,a){switch(i){case"content":T(a)&&(t.bottomSheetContentWrapper.innerHTML=a);break;case"width":T(a)&&(t.bottomSheetContainer.style.width=a);break;case"shouldShowHandle":Bt(a)||q(t.bottomSheetHandle,!1);break;case"shouldShowBackdrop":Bt(a)||q(t.bottomSheetBackdrop,!1);break;case"containerBorderRadius":T(a)&&(t.bottomSheetContainer.style.borderRadius=Ht(a));break;case"backdropColor":T(a)&&(t.bottomSheetBackdrop.style.backgroundColor=a);break;case"backDropTransition":T(a)&&(t.bottomSheetBackdrop.style.transition=a);break;case"rootClass":if(!T(a))return;G(t.bottomSheetRoot,e.rootClass,a);break;case"containerClass":if(!T(a))return;G(t.bottomSheetContainer,e.containerClass,a);break;case"handleClass":if(!T(a))return;G(t.bottomSheetHandle,e.handleClass,a);break;case"contentWrapperClass":if(!T(a))return;G(t.bottomSheetContentWrapper,e.contentWrapperClass,a);break;case"backdropClass":if(!T(a))return;G(t.bottomSheetBackdrop,e.backdropClass,a);break;case"expandable":r.clearEventListeners(),r.attachEventListeners(e);break;case"draggable":r.clearEventListeners(),r.attachEventListeners(e);break;case"draggingAnimationTimings":if(lt(a)){const l=dt(a),s=ct(l,e.draggingAnimationDuration);n.translateContainer=s}break;case"draggingAnimationDuration":if(D(a)){const l=dt(e.draggingAnimationTimings),s=ct(l,a);n.translateContainer=s}break;case"rootStyle":e.rootStyle&&Object.assign(t.bottomSheetRoot.style,e.rootStyle);break;case"backdropStyle":e.backdropStyle&&Object.assign(t.bottomSheetBackdrop.style,e.backdropStyle);break;case"containerStyle":e.containerStyle&&Object.assign(t.bottomSheetContainer.style,e.containerStyle);break;case"handleStyle":e.handleStyle&&Object.assign(t.bottomSheetHandleBar.style,e.handleStyle);break;case"contentWrapperStyle":e.contentWrapperStyle&&Object.assign(t.bottomSheetContentWrapper.style,e.contentWrapperStyle);break}}return o}function sn(t){const n=on(t),e=dt(t.draggingAnimationTimings),o={isMounted:!1,translateContainer:ct(e,n.draggingAnimationDuration)},i={startY:null,containerStartTranslate:{x:0,y:0},isDragging:!1,originalDocumentOverflowY:null,originalDocumentOverscrollBehavior:null};function a(){i.originalDocumentOverflowY&&i.originalDocumentOverflowY!=="hidden"&&(document.body.style.overflowY=i.originalDocumentOverflowY),i.originalDocumentOverscrollBehavior&&(document.body.style.position=i.originalDocumentOverscrollBehavior)}const l=new Kt,s={animationFrame:l,onClose:Y,bottomSheetState:o,draggingState:i,snapTo:W,moveUp:H,moveDown:C},{elements:p,eventHandlers:f}=Gt(n,s),u=Qt(n,an(p,o,n,f)),{bottomSheetBackdrop:E,bottomSheetRoot:x,bottomSheetContainer:c}=p,v=d=>{const h=d??window.document.body;h.appendChild(x),h.appendChild(E);const m=window.innerHeight;tt(c,{y:m}),f.attachEventListeners(),o.isMounted=!0},k=()=>{f.clearEventListeners(),Object.values(p).forEach(d=>{d.remove()}),a(),o.isMounted=!1},L=()=>{var P;if(A()||Zt('Bottom Sheet is not mounted yet. call the "mount" method first.'),(P=t.beforeOpen)==null||P.call(t),U())return;ot(E,!0),u.shouldShowBackdrop||$(E,"transparent"),ot([c],!0),tt(c,{y:c.clientHeight});const h=window.innerHeight,m=bt(h,c.clientHeight,u.marginTop,u.defaultPosition),b=I(c).y;o.translateContainer({startY:b,endY:m,animationFrame:l,bottomSheetContainer:c,onEnd:t.afterOpen});const S=document.body.style.overflowY;i.originalDocumentOverflowY=S||"initial";const B=document.body.style.overscrollBehavior;i.originalDocumentOverscrollBehavior=B||"initial",document.body.style.overflow="hidden",document.body.style.overscrollBehavior="contain",p.bottomSheetHandle.focus(),f.attacheOnOpenEventListeners()};function Y(){var m;if(nt())return;(m=t.beforeClose)==null||m.call(t);const d=I(c).y,h=c.clientHeight;o.translateContainer({startY:d,endY:h,animationFrame:l,bottomSheetContainer:c,onEnd:()=>{var b;(b=t.afterClose)==null||b.call(t),ot([E,c],!1),f.clearOnOpenEventListeners()}}),a()}function A(){return o.isMounted}function U(){const d=I(c).y,h=window.innerHeight,m=c.clientHeight>=h?h:c.clientHeight;return d<=m}function nt(){return!U()}function ut(){const d=I(c).y,h=c.clientHeight,m=window.innerHeight;if(d<=5&&d>=-5)return _.CONTENT_HEIGHT;const b=h-d;if(b===m/2)return _.MIDDLE;const S=m-u.marginTop,B=10;return b<=S+B&&b>=S-B?_.TOP:_.CLOSED}function ft(){return c.clientHeight}function et(d){if(!U())return;const h=I(c).y,b=c.clientHeight-h,S=window.innerHeight-d,B=Mt(b,S),P=Q(b,S);o.translateContainer({startY:h,endY:h+(B.isUp?-P:P),animationFrame:l,bottomSheetContainer:c})}function w(d,{viewportHeight:h,visibleHeight:m}){let b=null;for(const S of d){const B=S*h,P=Q(m,B);(b===null||P<b)&&(b=P)}return{minOffset:b}}function H(){const d=[...u.snapPoints].reverse(),h=I(c).y,m=c.clientHeight,b=m-h;if(!u.expandable&&b>=m)return;const S=window.innerHeight,B=yt("above",{visibleHeight:b,viewportHeight:S},d),{minOffset:P}=w(B,{visibleHeight:b,viewportHeight:S});if(P===null&&b<S-u.marginTop){o.translateContainer({startY:h,endY:bt(S,m,u.marginTop,"top"),animationFrame:l,bottomSheetContainer:c});return}D(P)&&o.translateContainer({startY:h,endY:h-P,animationFrame:l,bottomSheetContainer:c})}function C(){const d=I(c).y,m=c.clientHeight-d;if(m<1)return;const b=window.innerHeight,S=yt("below",{visibleHeight:m,viewportHeight:b},u.snapPoints),{minOffset:B}=w(S,{visibleHeight:m,viewportHeight:b});D(B)&&o.translateContainer({startY:d,endY:d+B,animationFrame:l,bottomSheetContainer:c})}function W(d){const h=window.innerHeight;if(!Jt(d))return;const m=Z(h*d,2);et(m)}return{props:u,elements:p,mount:v,unmount:k,open:L,close:Y,getIsMounted:A,getIsOpen:U,getIsClosed:nt,getPosition:ut,getHeight:ft,moveTo:et,snapTo:W}}function cn(){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:()=>_.CLOSED,moveTo:()=>{},snapTo:()=>{},props:{content:""}}}g.BOTTOM_SHEET_DEFAULT_PROPS=Dt,g.BOTTOM_SHEET_POSITION=_,g.BOTTOM_SHEET_SELECTORS=Nt,g.COMMON_ANIMATION_KEYS=R,g.ClassNames=y,g.EventPhase=M,g.ResetClassNames=J,g.UtilClassNames=V,g.createBottomSheet=sn,g.createPlaceholderBottomSheet=cn,g.eventPhaseToEnum=st,g.isAnimationTimingPoints=lt,g.isCommonAnimationTimingsKey=kt,Object.defineProperty(g,Symbol.toStringTag,{value:"Module"})});
@@ -61,6 +61,11 @@ export interface BottomSheetCoreProps {
61
61
  handleClass?: string | null;
62
62
  contentWrapperClass?: string | null;
63
63
  backdropClass?: string | null;
64
+ rootStyle?: PartialCSSStyles;
65
+ containerStyle?: PartialCSSStyles;
66
+ handleStyle?: PartialCSSStyles;
67
+ contentWrapperStyle?: PartialCSSStyles;
68
+ backdropStyle?: PartialCSSStyles;
64
69
  /**
65
70
  * Common animation timing functions such as "ease-in-out", or
66
71
  * an object {p1x: number, p1y: number, p2x: number, p2y: number} that describes the timing of animations as a Bezier curve.
@@ -90,4 +95,5 @@ export type BottomSheetPosition = (typeof BOTTOM_SHEET_POSITION)[keyof typeof BO
90
95
  * defaults to [0.5]
91
96
  */
92
97
  export type SnapPoints = number[];
98
+ export type PartialCSSStyles = Partial<CSSStyleDeclaration>;
93
99
  //# sourceMappingURL=bottom-sheet-props.type.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"bottom-sheet-props.type.d.ts","sourceRoot":"","sources":["../../src/types/bottom-sheet-props.type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yCAAyC,CAAC;AACjF,OAAO,KAAK,EACV,qBAAqB,EACrB,eAAe,EAChB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AAEvE,MAAM,MAAM,wBAAwB,GAAG,QAAQ,CAAC,oBAAoB,CAAC,CAAC;AACtE,MAAM,WAAW,oBAAoB;IACnC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAEhB,KAAK,CAAC,EAAE,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,MAAM,CAAC;CACpC;AACD,MAAM,MAAM,wBAAwB,GAChC,eAAe,GACf,qBAAqB,GACrB,IAAI,CAAC;AAET,eAAO,MAAM,qBAAqB;;;;;CAKxB,CAAC;AAEX;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAC7B,CAAC,OAAO,qBAAqB,CAAC,CAAC,MAAM,OAAO,qBAAqB,CAAC,CAAC;AAErE;;;;;GAKG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,EAAE,CAAC;AAElC,MAAM,MAAM,gBAAgB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plainsheet/core",
3
- "version": "0.7.5",
3
+ "version": "0.7.7",
4
4
  "private": false,
5
5
  "sideEffects": false,
6
6
  "description": "The minimalistic, configurable React bottom-sheet for the Web developers",