@plainsheet/core 0.7.1 → 0.7.4

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
- (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%;pointer-events:none;background-color:transparent;z-index:1;transition:background-color .2s ease-out}.pbs-backdrop.hidden{display:none}.pbs-backdrop.open{background-color:#454545b3}.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(h,A){typeof exports=="object"&&typeof module<"u"?A(exports):typeof define=="function"&&define.amd?define(["exports"],A):(h=typeof globalThis<"u"?globalThis:h||self,A(h.BottomSheet={}))})(this,function(h){"use strict";var ct=Object.defineProperty;var lt=(h,A,C)=>A in h?ct(h,A,{enumerable:!0,configurable:!0,writable:!0,value:C}):h[A]=C;var X=(h,A,C)=>lt(h,typeof A!="symbol"?A+"":A,C);var A=document.createElement("style");A.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%;pointer-events:none;background-color:transparent;z-index:1;transition:background-color .2s ease-out}.pbs-backdrop.hidden{display:none}.pbs-backdrop.open{background-color:#454545b3}.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(A);function C(n){return typeof n=="string"}function Bn(n,t){return n.classList.contains(K(t))}function z(n,t){n.classList.add(K(t))}function rn(n,t){n.classList.remove(K(t))}function $(n,t,e){C(e)&&(C(t)&&rn(n,t),z(n,e))}function K(n){return C(n)?n.trim().replace(/\./g,""):""}function F(n){return n.map(t=>K(t)).filter(Boolean).join(" ")}function Yn(n){return n.map(t=>t==null?void 0:t.trim()).filter(Boolean).map(t=>`.${t}`).join(" ")}const fn="open",hn="hidden";function on(n,t){const e=t;if(Array.isArray(n)){n.forEach(o=>{q(o,e),o.setAttribute("aria-modal",e?"true":"false")});return}q(n,e),n.setAttribute("aria-modal",e?"true":"false")}function q(n,t){t?(z(n,fn),rn(n,hn)):(z(n,hn),rn(n,fn))}function gn(n){return n instanceof HTMLElement}function S(n){return typeof n=="number"&&!Number.isNaN(n)}function xn(n){gn(n)&&n.focus()}function In(n){if(!gn(n)||n.offsetParent===null||"disabled"in n&&n.disabled)return!1;const e=n.getAttribute("tabindex"),o=S(e)?parseInt(e,10):-1,r=["INPUT","BUTTON","SELECT","TEXTAREA","A","AREA","IFRAME"].includes(n.tagName),c=n instanceof HTMLAnchorElement&&n.href!==""||n instanceof HTMLAreaElement&&n.href!=="";return r||c||o>-1}var E=(n=>(n.Backdrop="pbs-backdrop",n.Root="pbs-root",n.Container="pbs-container",n.GapFiller="pbs-gap-filler",n.Handle="pbs-handle",n.HandleBar="pbs-handle-bar",n.ContentWrapper="pbs-content-wrapper",n))(E||{}),J=(n=>(n.Button="pbs-button-reset",n.Dialog="pbs-dialog-reset",n))(J||{}),j=(n=>(n.Hidden="hidden",n))(j||{});function N(n,t,e){const o=document.createElement(n);return t.split(" ").forEach(r=>{z(o,r)}),C(e)&&o.setAttribute("data-testid",e),o}const Nn={CONTENTS_WRAPPER:Yn([E.Root,E.ContentWrapper])};function pn(n,t,e,o){switch(o){case"content-height":return t>=n?Cn(n,t,e):0;case"middle":return-(n/2-t);case"top":return-(n-t)+e;default:return 0}}function mn(n,t){const e=t<n,o=t>n;return{isUp:e,isDown:o,stayedSame:t===n}}function bn(n,t){return t<n?-(n-t):t-n}function Q(n,t){return n>t?n-t:t-n}function Mn(n,t){const e=n<t,o=n>t;return{isUp:e,isDown:o,stayedSame:n===t}}function Tn(n,t,e){const o=n==="above";return e.filter(i=>{const r=i*t.viewportHeight;return o?t.visibleHeight<r:t.visibleHeight>r})}function Cn(n,t,e){return-(n-t)+e}function En(n){return Number(n.replace("px",""))}function Z(n,...t){return Number(n.toFixed(...t))}function vn(n){const t=/(?<type>\w+)\((?<values>[^)]+)\)/g,e=[];let o;for(;(o=t.exec(n))!==null;){const i=o[1],r=o[2].split(",").map(c=>c.trim());e.push({type:i,values:r})}return e}function Pn(n){const t=n.style.transform,e=vn(t);return{transform:t,transformValues:e}}function wn(n,t){const e=n.find(o=>o.type.startsWith(t));return e||null}const sn="translate";function I(n){const t=n.style.transform,e=vn(t),o=wn(e,sn);return yn(o??{type:sn,values:[]})}function nn(n,{x:t,y:e}){const{transform:o,transformValues:i}=Pn(n),r=wn(i,sn);if(r){const c=yn(r);n.style.transform=`translate(${t??c.x??0}px,${e??c.y??0}px)`;return}if(o){n.style.transform=`${o}, translate(${t??0}px,${e??0}px)`;return}n.style.transform=`translate(${t??0}px,${e??0}px)`}function yn(n){if(n.type!=="translate")throw new Error(`Could not get coordinates from ${n.type}, since is not translate.`);const t=n.values[0],e=n.values[1];return{x:En(t)??0,y:En(e)??0}}function an(n){return n!=null}function Hn(n,{min:t,max:e}){return an(e)&&n>=e?e:an(t)&&n<=t?t:n}const _n=(n,t,e)=>{t instanceof HTMLElement&&!Bn(t,E.Handle)&&e.scrollTop>=1||(n.isDragging=!0)},Fn=(n,t,e,o)=>i=>{o.startY=n.getCoordinates(i).y,o.containerStartTranslate=I(t),e.onDragStart()},Rn=(n,t,e,o,i)=>r=>{Un(r,n,e,o,i,t,e.marginTop)};function Un(n,t,e,o,i,r,c){if(!o.isDragging||!S(o.startY))return;const l=t.getCoordinates(n).y,a=bn(o.startY,l),b=window.innerHeight,g=r.clientHeight,u=g-(o.containerStartTranslate.y+a);if(u>=b)return;const v=mn(o.startY,l);if(v.isUp&&!e.expandable&&u>=g)return;i.start(()=>{nn(r,{y:o.containerStartTranslate.y+a})},0);const O=b-c,s=g-o.containerStartTranslate.y;if(v.isUp){const y=O-s,L=O-u,k=Hn(1-Z(L/y,2),{min:0,max:1});e.onDragMove(v,k)}else if(v.isDown){const y=Hn(Z(1-u/s,2),{min:0,max:1});e.onDragMove(v,y)}}const Wn=(n,t,e,o,i,r,c)=>l=>{if(!o.isDragging||(o.isDragging=!1,!S(o.startY)))return;e.onDragEnd();const a=o.startY,b=n.getCoordinates(l).y,g=I(t).y,u=mn(a,b),v=window.innerHeight,O=t.clientHeight;if(u.isUp){const s=[...e.snapPoints].sort((k,w)=>k-w),y=O+-g;if(!e.expandable&&y>=O)return;for(const k of s){const w=k*window.innerHeight;if(y<=w){const U=Q(y,w);c.translateContainer({startY:g,endY:g-U,animationFrame:i,bottomSheetContainer:t});return}}const L=Cn(v,O,e.marginTop);c.translateContainer({startY:g,endY:L,animationFrame:i,bottomSheetContainer:t})}else if(u.isDown){const s=[...e.snapPoints].sort((y,L)=>L-y);for(const y of s){const L=y*window.innerHeight,k=O+-g;if(k>=L){const w=Q(k,L);c.translateContainer({startY:g,endY:g+w,animationFrame:i,bottomSheetContainer:t});return}}r()}};var M=(n=>(n[n.All=-1]="All",n[n.None=0]="None",n[n.Capture=1]="Capture",n[n.Target=2]="Target",n[n.Bubble=3]="Bubble",n))(M||{});function cn(n){switch(n){case 0:return 0;case 1:return 1;case 2:return 2;case 3:return 3;default:return-1}}const Gn={eventPhase:M.All};class V{constructor(t){X(this,"currentTarget");this.currentTarget=t}addEventListeners({onStart:t,onStartOptions:e=Gn,onMove:o,onEnd:i}){this.addTouchEventListeners({onStart:t,onStartOptions:e,onMove:o,onEnd:i}),this.addMouseEventListeners({onStart:t,onStartOptions:e,onMove:o,onEnd:i})}addTouchEventListeners({onStart:t,onStartOptions:e,onMove:o,onEnd:i}){t&&this.currentTarget.addEventListener("touchstart",r=>{if(e.eventPhase===M.All){t(r);return}cn(r.eventPhase)===e.eventPhase&&t(r)},{passive:!0}),o&&this.currentTarget.addEventListener("touchmove",o),i&&this.currentTarget.addEventListener("touchend",i)}addMouseEventListeners({onStart:t,onStartOptions:e,onMove:o,onEnd:i}){t&&this.currentTarget.addEventListener("mousedown",r=>{if(e.eventPhase===M.All){t(r);return}cn(r.eventPhase)===e.eventPhase&&t(r)},{passive:!0}),o&&this.currentTarget.addEventListener("mousemove",o),i&&this.currentTarget.addEventListener("mouseup",r=>{i(r)})}removeEventListeners({onStart:t,onMove:e,onEnd:o}){t&&this.currentTarget.removeEventListener("touchstart",t),o&&this.currentTarget.removeEventListener("touchend",o),e&&this.currentTarget.removeEventListener("touchmove",e),t&&this.currentTarget.removeEventListener("mousedown",t),e&&this.currentTarget.removeEventListener("mousemove",e),o&&this.currentTarget.removeEventListener("mouseup",o)}getCoordinates(t){if(t.type==="touchstart"||t.type==="mousedown"){if("touches"in t)return{x:t.touches[0].clientX,y:t.touches[0].clientY};if(t instanceof MouseEvent)return{x:t.clientX,y:t.clientY}}if(t.type==="touchend"||t.type==="mouseup"||t.type==="mousemove"||t.type==="touchmove"){if("touches"in t)return{x:t.changedTouches[0].clientX,y:t.changedTouches[0].clientY};if(t instanceof MouseEvent)return{x:t.clientX,y:t.clientY}}return{x:0,y:0}}}function $n(n,t){const e=jn(n);Vn(e),e.bottomSheetContainer.style.width=n.width;const o=document.createElement("div");o.innerHTML=n.content??"";const i=window.innerHeight;e.bottomSheetContainer.style.maxHeight=`${i}px`,e.bottomSheetContentWrapper.appendChild(o);const r=Xn({bottomSheetElements:e,bottomSheetProps:n,options:t});return{elements:e,eventHandlers:r}}function jn(n){const t=N("dialog",F([E.Root,J.Dialog,n.rootClass]),E.Root);t.ariaLabel=n.ariaLabel;const e=N("section",F([E.Container,n.containerClass]),E.Container);n.containerBorderRadius&&(e.style.borderRadius=n.containerBorderRadius);const o=N("div",E.GapFiller,E.GapFiller),i=N("button",F([E.Handle,J.Button,n.shouldShowHandle?null:j.Hidden,n.handleClass]),E.Handle);i.setAttribute("type","button"),i.ariaLabel="bottom sheet close button";const r=N("span",F([E.HandleBar,n.shouldShowHandle?null:j.Hidden]),E.HandleBar),c=N("article",F([E.ContentWrapper,n.contentWrapperClass]),E.ContentWrapper),l=N("div",F([E.Backdrop,n.backdropClass,j.Hidden]),E.Backdrop);return n.backdropColor&&(l.style.backgroundColor=n.backdropColor),n.backDropTransition&&(l.style.transition=n.backDropTransition),{bottomSheetRoot:t,bottomSheetBackdrop:l,bottomSheetContainer:e,bottomSheetHandle:i,bottomSheetHandleBar:r,bottomSheetContentWrapper:c,bottomSheetContainerGapFiller:o}}function Vn({bottomSheetRoot:n,bottomSheetContainer:t,bottomSheetHandle:e,bottomSheetHandleBar:o,bottomSheetContentWrapper:i,bottomSheetContainerGapFiller:r}){n.appendChild(t),e.appendChild(o),t.appendChild(e),t.appendChild(i),t.appendChild(r)}function Xn({bottomSheetElements:n,bottomSheetProps:t,options:e}){const{bottomSheetRoot:o,bottomSheetContainer:i,bottomSheetHandle:r,bottomSheetContainerGapFiller:c,bottomSheetContentWrapper:l}=n,{animationFrame:a}=e,b=new V(r),g=new V(l),u=new V(c),v=t.dragTriggers.reduce((T,Y)=>{const x=o.querySelectorAll(Y);if(!x.length)return T;const en=Array.from(x).map(G=>G instanceof HTMLElement?new V(G):null).filter(G=>!!G);return[...T,...en]},[]),O=new V(window),s=Fn(O,i,t,e.draggingState),y=Rn(O,i,t,e.draggingState,a),L=Wn(O,i,t,e.draggingState,a,e.onClose,e.bottomSheetState);function k(T){T.target instanceof Element&&!o.contains(T.target)&&e.onClose()}function w(T){_n(e.draggingState,T.target,n.bottomSheetContentWrapper)}function U(){t.draggable&&(b.addEventListeners({onStart:w}),v.forEach(T=>{T.addEventListeners({onStart:w,onStartOptions:{eventPhase:M.Target}})})),t.draggable&&t.backgroundDraggable&&(g.addEventListeners({onStart:w,onStartOptions:{eventPhase:M.Target}}),u.addEventListeners({onStart:w})),t.draggable&&O.addEventListeners({onStart:s,onMove:y,onEnd:L}),t.draggable&&window.document.addEventListener("keyup",T=>{T.key==="Escape"&&e.onClose()}),t.shouldCloseOnOutsideClick&&window.document.addEventListener("click",k),r.addEventListener("keyup",T=>{if(T.key==="ArrowUp"){e.moveUp();return}if(T.key==="ArrowDown"){e.moveDown();return}if(T.shiftKey&&T.key==="Tab"){const Y=W(n.bottomSheetContentWrapper);xn(Y)}})}function W(T){let Y=[...Array.from(T.childNodes).reverse()];for(;Y.length;){const x=Y.shift();if(In(x))return x;x&&(Y=[...Y,...Array.from(x.childNodes).reverse()])}return null}function tn(){b.removeEventListeners({onStart:w}),g.removeEventListeners({onStart:w}),u.removeEventListeners({onStart:w}),v.forEach(T=>{T.removeEventListeners({onStart:w})}),O.removeEventListeners({onStart:s,onMove:y,onEnd:L}),window.removeEventListener("click",k)}return{attachEventListeners:U,clearEventListeners:tn}}class zn{constructor(){X(this,"animationId");X(this,"isInProgress");X(this,"startedAt");this.animationId=null,this.isInProgress=!1,this.startedAt=null}start(t,e,o=!1){this.isInProgress=!0;const i=r=>{this.startedAt||(this.startedAt=r);const c=r-this.startedAt,a=e===0?1:Z(c/e,2),b=a>=1&&!o;t(a),b?this.stop():this.animationId=requestAnimationFrame(i)};this.animationId=requestAnimationFrame(i)}stop(){this.isInProgress=!1,this.startedAt=null,S(this.animationId)&&cancelAnimationFrame(this.animationId)}}function Kn(n){const{startY:t,endY:e,bottomSheetContainer:o,animationFrame:i,onEnd:r,animationTimingFunction:c,animationDuration:l}=n,a=bn(t,e);i.stop();let b=!1;i.start(g=>{nn(o,{y:t+a*c(g)}),!b&&g>=1&&(r==null||r(),b=!0)},l)}const ln=(n,t)=>e=>{Kn({...e,animationTimingFunction:n,animationDuration:t})},P={TOP:"top",MIDDLE:"middle",CONTENT_HEIGHT:"content-height",CLOSED:"closed"};function qn(n){return!(!S(n)||n>1||n<0)}function Jn(n,t){const e={set(o,i,r,c){return t(i,r),Reflect.set(o,i,r,c)}};return new Proxy(n,e)}function Qn(...n){console.error(n)}const _={EASE:"ease",EASE_IN:"ease-in",EASE_OUT:"ease-out",EASE_IN_OUT:"ease-in-out",SPRING:"spring"};function On(n){for(const t of Object.values(_))if(t===n)return!0;return!1}function un(n){return!!(n instanceof Object&&"p1x"in n&&"p1y"in n&&"p2x"in n&&"p2y"in n&&S(n.p1x)&&S(n.p1y)&&S(n.p2x)&&S(n.p2y))}function R(n,t,e,o){return function(a){return l(r(a))};function r(a){let b=0,g=1,u=a,v;if(a===0||a===1)return a;for(;b<g;){if(v=c(u),Math.abs(v-a)<.001)return u;a>v?b=u:g=u,u=(g+b)/2}return u}function c(a){return 3*n*a*Math.pow(1-a,2)+3*e*Math.pow(a,2)*(1-a)+Math.pow(a,3)}function l(a){return 3*t*a*Math.pow(1-a,2)+3*o*Math.pow(a,2)*(1-a)+Math.pow(a,3)}}const An=R(.25,.1,.25,1),Zn=R(.42,0,1,1),Ln=R(.42,0,.58,1),nt=R(.4,.1,.6,1),tt=R(.45,1.5,.55,1);function et(n){switch(n){case _.EASE:return An;case _.EASE_IN:return Zn;case _.EASE_OUT:return Ln;case _.EASE_IN_OUT:return nt;case _.SPRING:return tt;default:return An}}function kn(n){return typeof n=="boolean"}const Dn={ariaLabel:"Bottom sheet",content:"",defaultPosition:P.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 rt(n){const t={...Dn},e=Object.entries(n).reduce((i,r)=>{const[c,l]=r;return an(l)&&(i[c]=l),i},{});return{...t,...e}}function dn(n){if(un(n)){const{p1x:t,p1y:e,p2x:o,p2y:i}=n;return R(t,e,o,i)}return On(n)?et(n):Ln}function ot(n,t,e){function o(i,r){switch(i){case"content":C(r)&&(n.bottomSheetContentWrapper.innerHTML=r);break;case"width":C(r)&&(n.bottomSheetContainer.style.width=r);break;case"shouldShowHandle":kn(r)||q(n.bottomSheetHandle,!1);break;case"shouldShowBackdrop":kn(r)||q(n.bottomSheetBackdrop,!1);break;case"containerBorderRadius":C(r)&&(n.bottomSheetContainer.style.borderRadius=r);break;case"backdropColor":C(r)&&(n.bottomSheetBackdrop.style.backgroundColor=r);break;case"backDropTransition":C(r)&&(n.bottomSheetBackdrop.style.transition=r);break;case"rootClass":if(!C(r))return;$(n.bottomSheetRoot,e.rootClass,r);break;case"containerClass":if(!C(r))return;$(n.bottomSheetContainer,e.containerClass,r);break;case"handleClass":if(!C(r))return;$(n.bottomSheetHandle,e.handleClass,r);break;case"contentWrapperClass":if(!C(r))return;$(n.bottomSheetContentWrapper,e.contentWrapperClass,r);break;case"backdropClass":if(!C(r))return;$(n.bottomSheetBackdrop,e.backdropClass,r);break;case"draggingAnimationTimings":if(un(r)){const c=dn(r),l=ln(c,e.draggingAnimationDuration);t.translateContainer=l}break;case"draggingAnimationDuration":if(S(r)){const c=dn(e.draggingAnimationTimings),l=ln(c,r);t.translateContainer=l}break}}return o}function it(n){const t=rt(n),e=dn(n.draggingAnimationTimings),i={isMounted:!1,translateContainer:ln(e,t.draggingAnimationDuration)},r={startY:null,containerStartTranslate:{x:0,y:0},isDragging:!1,originalDocumentOverflowY:null,originalDocumentOverscrollBehavior:null};function c(){r.originalDocumentOverflowY&&r.originalDocumentOverflowY!=="hidden"&&(document.body.style.overflowY=r.originalDocumentOverflowY),r.originalDocumentOverscrollBehavior&&(document.body.style.position=r.originalDocumentOverscrollBehavior)}const l=new zn,a={animationFrame:l,onClose:w,bottomSheetState:i,draggingState:r,snapTo:Sn,moveUp:G,moveDown:at},{elements:b,eventHandlers:g}=$n(t,a),u=Jn(t,ot(b,i,t)),{bottomSheetBackdrop:v,bottomSheetRoot:O,bottomSheetContainer:s}=b,y=d=>{const f=d??window.document.body;f.appendChild(O),f.appendChild(v);const p=window.innerHeight;nn(s,{y:p}),g.attachEventListeners(),i.isMounted=!0},L=()=>{g.clearEventListeners(),Object.values(b).forEach(d=>{d.remove()}),c(),i.isMounted=!1},k=()=>{var B;if(U()||Qn('Bottom Sheet is not mounted yet. call the "mount" method first.'),(B=n.beforeOpen)==null||B.call(n),W())return;u.shouldShowBackdrop&&on(v,!0),on([s],!0),nn(s,{y:s.clientHeight});const f=window.innerHeight,p=pn(f,s.clientHeight,u.marginTop,u.defaultPosition),m=I(s).y;i.translateContainer({startY:m,endY:p,animationFrame:l,bottomSheetContainer:s,onEnd:n.afterOpen}),b.bottomSheetHandle.focus();const H=document.body.style.overflowY;r.originalDocumentOverflowY=H||"initial";const D=document.body.style.overscrollBehavior;r.originalDocumentOverscrollBehavior=D||"initial",document.body.style.overflow="hidden",document.body.style.overscrollBehavior="contain"};function w(){var p;if(tn())return;(p=n.beforeClose)==null||p.call(n);const d=I(s).y,f=s.clientHeight;i.translateContainer({startY:d,endY:f,animationFrame:l,bottomSheetContainer:s,onEnd:()=>{var m;(m=n.afterClose)==null||m.call(n),on([v,s],!1)}}),c()}function U(){return i.isMounted}function W(){const d=I(s).y,f=window.innerHeight,p=s.clientHeight>=f?f:s.clientHeight;return d<p}function tn(){return!W()}function T(){const d=I(s).y,f=s.clientHeight,p=window.innerHeight;if(d<=5&&d>=-5)return P.CONTENT_HEIGHT;const m=f-d;if(m===p/2)return P.MIDDLE;const H=p-u.marginTop,D=10;return m<=H+D&&m>=H-D?P.TOP:P.CLOSED}function Y(){return s.clientHeight}function x(d){if(!W())return;const f=I(s).y,m=s.clientHeight-f,H=window.innerHeight-d,D=Mn(m,H),B=Q(m,H);i.translateContainer({startY:f,endY:f+(D.isUp?-B:B),animationFrame:l,bottomSheetContainer:s})}function en(d,{viewportHeight:f,visibleHeight:p}){let m=null;for(const H of d){const D=H*f,B=Q(p,D);(m===null||B<m)&&(m=B)}return{minOffset:m}}function G(){const d=[...u.snapPoints].reverse(),f=I(s).y,p=s.clientHeight,m=p-f;if(!u.expandable&&m>=p)return;const H=window.innerHeight,D=Tn("above",{visibleHeight:m,viewportHeight:H},d),{minOffset:B}=en(D,{visibleHeight:m,viewportHeight:H});if(B===null&&m<H-u.marginTop){i.translateContainer({startY:f,endY:pn(H,p,u.marginTop,"top"),animationFrame:l,bottomSheetContainer:s});return}S(B)&&i.translateContainer({startY:f,endY:f-B,animationFrame:l,bottomSheetContainer:s})}function at(){const d=I(s).y,p=s.clientHeight-d;if(p<1)return;const m=window.innerHeight,H=Tn("below",{visibleHeight:p,viewportHeight:m},u.snapPoints),{minOffset:D}=en(H,{visibleHeight:p,viewportHeight:m});S(D)&&i.translateContainer({startY:d,endY:d+D,animationFrame:l,bottomSheetContainer:s})}function Sn(d){const f=window.innerHeight;if(!qn(d))return;const p=Z(f*d,2);x(p)}return{props:u,elements:b,mount:y,unmount:L,open:k,close:w,getIsMounted:U,getIsOpen:W,getIsClosed:tn,getPosition:T,getHeight:Y,moveTo:x,snapTo:Sn}}function st(){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:()=>P.CLOSED,moveTo:()=>{},snapTo:()=>{},props:{content:""}}}h.BOTTOM_SHEET_DEFAULT_PROPS=Dn,h.BOTTOM_SHEET_POSITION=P,h.BOTTOM_SHEET_SELECTORS=Nn,h.COMMON_ANIMATION_KEYS=_,h.ClassNames=E,h.EventPhase=M,h.ResetClassNames=J,h.UtilClassNames=j,h.createBottomSheet=it,h.createPlaceholderBottomSheet=st,h.eventPhaseToEnum=cn,h.isAnimationTimingPoints=un,h.isCommonAnimationTimingsKey=On,Object.defineProperty(h,Symbol.toStringTag,{value:"Module"})});
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,H){typeof exports=="object"&&typeof module<"u"?H(exports):typeof define=="function"&&define.amd?define(["exports"],H):(g=typeof globalThis<"u"?globalThis:g||self,H(g.BottomSheet={}))})(this,function(g){"use strict";var lt=Object.defineProperty;var ut=(g,H,E)=>H in g?lt(g,H,{enumerable:!0,configurable:!0,writable:!0,value:E}):g[H]=E;var z=(g,H,E)=>ut(g,typeof H!="symbol"?H+"":H,E);var H=document.createElement("style");H.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(H);function E(n){return typeof n=="string"}function Yn(n,t){return n.classList.contains(X(t))}function $(n,t){n.classList.add(X(t))}function rn(n,t){n.classList.remove(X(t))}function G(n,t,e){E(e)&&(E(t)&&rn(n,t),$(n,e))}function X(n){return E(n)?n.trim().replace(/\./g,""):""}function R(n){return n.map(t=>X(t)).filter(Boolean).join(" ")}function In(n){return n.map(t=>t==null?void 0:t.trim()).filter(Boolean).map(t=>`.${t}`).join(" ")}const gn="open",pn="hidden";function on(n,t){const e=t;if(Array.isArray(n)){n.forEach(o=>{K(o,e),o.setAttribute("aria-modal",e?"true":"false")});return}K(n,e),n.setAttribute("aria-modal",e?"true":"false")}function K(n,t){t?($(n,gn),rn(n,pn)):($(n,pn),rn(n,gn))}function mn(n){return n instanceof HTMLElement}function S(n){return typeof n=="number"&&!Number.isNaN(n)}function Nn(n){mn(n)&&n.focus()}function Mn(n){if(!mn(n)||n.offsetParent===null||"disabled"in n&&n.disabled)return!1;const e=n.getAttribute("tabindex"),o=S(e)?parseInt(e,10):-1,r=["INPUT","BUTTON","SELECT","TEXTAREA","A","AREA","IFRAME"].includes(n.tagName),c=n instanceof HTMLAnchorElement&&n.href!==""||n instanceof HTMLAreaElement&&n.href!=="";return r||c||o>-1}var v=(n=>(n.Backdrop="pbs-backdrop",n.Root="pbs-root",n.Container="pbs-container",n.GapFiller="pbs-gap-filler",n.Handle="pbs-handle",n.HandleBar="pbs-handle-bar",n.ContentWrapper="pbs-content-wrapper",n))(v||{}),q=(n=>(n.Button="pbs-button-reset",n.Dialog="pbs-dialog-reset",n))(q||{}),j=(n=>(n.Hidden="hidden",n))(j||{});function M(n,t,e){const o=document.createElement(n);return t.split(" ").forEach(r=>{$(o,r)}),E(e)&&o.setAttribute("data-testid",e),o}const Pn={CONTENTS_WRAPPER:In([v.Root,v.ContentWrapper])};function bn(n,t,e,o){switch(o){case"content-height":return t>=n?Cn(n,t,e):0;case"middle":return-(n/2-t);case"top":return-(n-t)+e;default:return 0}}function Tn(n,t){const e=t<n,o=t>n;return{isUp:e,isDown:o,stayedSame:t===n}}function En(n,t){return t<n?-(n-t):t-n}function J(n,t){return n>t?n-t:t-n}function _n(n,t){const e=n<t,o=n>t;return{isUp:e,isDown:o,stayedSame:n===t}}function vn(n,t,e){const o=n==="above";return e.filter(i=>{const r=i*t.viewportHeight;return o?t.visibleHeight<r:t.visibleHeight>r})}function Cn(n,t,e){return-(n-t)+e}function wn(n){return Number(n.replace("px",""))}function Q(n,...t){return Number(n.toFixed(...t))}function yn(n){const t=/(?<type>\w+)\((?<values>[^)]+)\)/g,e=[];let o;for(;(o=t.exec(n))!==null;){const i=o[1],r=o[2].split(",").map(c=>c.trim());e.push({type:i,values:r})}return e}function Fn(n){const t=n.style.transform,e=yn(t);return{transform:t,transformValues:e}}function Hn(n,t){const e=n.find(o=>o.type.startsWith(t));return e||null}const sn="translate";function I(n){const t=n.style.transform,e=yn(t),o=Hn(e,sn);return On(o??{type:sn,values:[]})}function Z(n,{x:t,y:e}){const{transform:o,transformValues:i}=Fn(n),r=Hn(i,sn);if(r){const c=On(r);n.style.transform=`translate(${t??c.x??0}px,${e??c.y??0}px)`;return}if(o){n.style.transform=`${o}, translate(${t??0}px,${e??0}px)`;return}n.style.transform=`translate(${t??0}px,${e??0}px)`}function On(n){if(n.type!=="translate")throw new Error(`Could not get coordinates from ${n.type}, since is not translate.`);const t=n.values[0],e=n.values[1];return{x:wn(t)??0,y:wn(e)??0}}function an(n){return n!=null}function Ln(n,{min:t,max:e}){return an(e)&&n>=e?e:an(t)&&n<=t?t:n}const Rn=(n,t,e)=>{t instanceof HTMLElement&&!Yn(t,v.Handle)&&e.scrollTop>=1||(n.isDragging=!0)},Un=(n,t,e,o)=>i=>{o.startY=n.getCoordinates(i).y,o.containerStartTranslate=I(t),e.onDragStart()},Wn=(n,t,e,o,i)=>r=>{$n(r,n,e,o,i,t,e.marginTop)};function $n(n,t,e,o,i,r,c){if(!o.isDragging||!S(o.startY))return;const l=t.getCoordinates(n).y,a=En(o.startY,l),T=window.innerHeight,f=r.clientHeight,d=f-(o.containerStartTranslate.y+a);if(d>=T)return;const C=Tn(o.startY,l);if(C.isUp&&!e.expandable&&d>=f)return;i.start(()=>{Z(r,{y:o.containerStartTranslate.y+a})},0);const D=T-c,s=f-o.containerStartTranslate.y;if(C.isUp){const w=D-s,O=D-d,L=Ln(1-Q(O/w,2),{min:0,max:1});e.onDragMove(C,L)}else if(C.isDown){const w=Ln(Q(1-d/s,2),{min:0,max:1});e.onDragMove(C,w)}}const Gn=(n,t,e,o,i,r,c)=>l=>{if(!o.isDragging||(o.isDragging=!1,!S(o.startY)))return;e.onDragEnd();const a=o.startY,T=n.getCoordinates(l).y,f=I(t).y,d=Tn(a,T),C=window.innerHeight,D=t.clientHeight;if(d.isUp){const s=[...e.snapPoints].sort((L,B)=>L-B),w=D+-f;if(!e.expandable&&w>=D)return;for(const L of s){const B=L*window.innerHeight;if(w<=B){const k=J(w,B);c.translateContainer({startY:f,endY:f-k,animationFrame:i,bottomSheetContainer:t});return}}const O=Cn(C,D,e.marginTop);c.translateContainer({startY:f,endY:O,animationFrame:i,bottomSheetContainer:t})}else if(d.isDown){const s=[...e.snapPoints].sort((w,O)=>O-w);for(const w of s){const O=w*window.innerHeight,L=D+-f;if(L>=O){const B=J(L,O);c.translateContainer({startY:f,endY:f+B,animationFrame:i,bottomSheetContainer:t});return}}r()}};var P=(n=>(n[n.All=-1]="All",n[n.None=0]="None",n[n.Capture=1]="Capture",n[n.Target=2]="Target",n[n.Bubble=3]="Bubble",n))(P||{});function cn(n){switch(n){case 0:return 0;case 1:return 1;case 2:return 2;case 3:return 3;default:return-1}}const jn={eventPhase:P.All};class V{constructor(t){z(this,"currentTarget");this.currentTarget=t}addEventListeners({onStart:t,onStartOptions:e=jn,onMove:o,onEnd:i}){this.addTouchEventListeners({onStart:t,onStartOptions:e,onMove:o,onEnd:i}),this.addMouseEventListeners({onStart:t,onStartOptions:e,onMove:o,onEnd:i})}addTouchEventListeners({onStart:t,onStartOptions:e,onMove:o,onEnd:i}){t&&this.currentTarget.addEventListener("touchstart",r=>{if(e.eventPhase===P.All){t(r);return}cn(r.eventPhase)===e.eventPhase&&t(r)},{passive:!0}),o&&this.currentTarget.addEventListener("touchmove",o),i&&this.currentTarget.addEventListener("touchend",i)}addMouseEventListeners({onStart:t,onStartOptions:e,onMove:o,onEnd:i}){t&&this.currentTarget.addEventListener("mousedown",r=>{if(e.eventPhase===P.All){t(r);return}cn(r.eventPhase)===e.eventPhase&&t(r)},{passive:!0}),o&&this.currentTarget.addEventListener("mousemove",o),i&&this.currentTarget.addEventListener("mouseup",r=>{i(r)})}removeEventListeners({onStart:t,onMove:e,onEnd:o}){t&&this.currentTarget.removeEventListener("touchstart",t),o&&this.currentTarget.removeEventListener("touchend",o),e&&this.currentTarget.removeEventListener("touchmove",e),t&&this.currentTarget.removeEventListener("mousedown",t),e&&this.currentTarget.removeEventListener("mousemove",e),o&&this.currentTarget.removeEventListener("mouseup",o)}getCoordinates(t){if(t.type==="touchstart"||t.type==="mousedown"){if("touches"in t)return{x:t.touches[0].clientX,y:t.touches[0].clientY};if(t instanceof MouseEvent)return{x:t.clientX,y:t.clientY}}if(t.type==="touchend"||t.type==="mouseup"||t.type==="mousemove"||t.type==="touchmove"){if("touches"in t)return{x:t.changedTouches[0].clientX,y:t.changedTouches[0].clientY};if(t instanceof MouseEvent)return{x:t.clientX,y:t.clientY}}return{x:0,y:0}}}function kn(n){const t=n;return`${t} ${t} 0px 0px`}function Vn(n,t){const e=zn(n);Xn(e),e.bottomSheetContainer.style.width=n.width;const o=document.createElement("div");o.innerHTML=n.content??"";const i=window.innerHeight;e.bottomSheetContainer.style.maxHeight=`${i}px`,e.bottomSheetContentWrapper.appendChild(o);const r=Kn({bottomSheetElements:e,bottomSheetProps:n,options:t});return{elements:e,eventHandlers:r}}function zn(n){const t=M("dialog",R([v.Root,q.Dialog,n.rootClass]),v.Root);t.ariaLabel=n.ariaLabel;const e=M("section",R([v.Container,n.containerClass]),v.Container);n.containerBorderRadius&&(e.style.borderRadius=kn(n.containerBorderRadius));const o=M("div",v.GapFiller,v.GapFiller),i=M("button",R([v.Handle,q.Button,n.shouldShowHandle?null:j.Hidden,n.handleClass]),v.Handle);i.setAttribute("type","button"),i.ariaLabel="bottom sheet close button";const r=M("span",R([v.HandleBar,n.shouldShowHandle?null:j.Hidden]),v.HandleBar),c=M("article",R([v.ContentWrapper,n.contentWrapperClass]),v.ContentWrapper),l=M("div",R([v.Backdrop,n.backdropClass,j.Hidden]),v.Backdrop);return n.backdropColor&&(l.style.backgroundColor=n.backdropColor),n.backDropTransition&&(l.style.transition=n.backDropTransition),{bottomSheetRoot:t,bottomSheetBackdrop:l,bottomSheetContainer:e,bottomSheetHandle:i,bottomSheetHandleBar:r,bottomSheetContentWrapper:c,bottomSheetContainerGapFiller:o}}function Xn({bottomSheetRoot:n,bottomSheetContainer:t,bottomSheetHandle:e,bottomSheetHandleBar:o,bottomSheetContentWrapper:i,bottomSheetContainerGapFiller:r}){n.appendChild(t),e.appendChild(o),t.appendChild(e),t.appendChild(i),t.appendChild(r)}function Kn({bottomSheetElements:n,bottomSheetProps:t,options:e}){const{bottomSheetRoot:o,bottomSheetContainer:i,bottomSheetHandle:r,bottomSheetContainerGapFiller:c,bottomSheetContentWrapper:l,bottomSheetBackdrop:a}=n,{animationFrame:T}=e,f=new V(r),d=new V(l),C=new V(c),D=t.dragTriggers.reduce((b,Y)=>{const N=o.querySelectorAll(Y);if(!N.length)return b;const en=Array.from(N).map(u=>u instanceof HTMLElement?new V(u):null).filter(u=>!!u);return[...b,...en]},[]),s=new V(window),w=Un(s,i,t,e.draggingState),O=Wn(s,i,t,e.draggingState,T),L=Gn(s,i,t,e.draggingState,T,e.onClose,e.bottomSheetState);function B(b){b.target instanceof Element&&!o.contains(b.target)&&e.onClose()}function k(b){Rn(e.draggingState,b.target,n.bottomSheetContentWrapper)}function W(){t.draggable&&(f.addEventListeners({onStart:k}),D.forEach(b=>{b.addEventListeners({onStart:k,onStartOptions:{eventPhase:P.Target}})})),t.draggable&&t.backgroundDraggable&&(d.addEventListeners({onStart:k,onStartOptions:{eventPhase:P.Target}}),C.addEventListeners({onStart:k})),t.draggable&&s.addEventListeners({onStart:w,onMove:O,onEnd:L}),t.draggable&&window.document.addEventListener("keyup",b=>{b.key==="Escape"&&e.onClose()}),r.addEventListener("keyup",b=>{if(b.key==="ArrowUp"){e.moveUp();return}if(b.key==="ArrowDown"){e.moveDown();return}if(b.shiftKey&&b.key==="Tab"){const Y=hn(n.bottomSheetContentWrapper);Nn(Y)}})}function nn(){t.shouldCloseOnOutsideClick?a.addEventListener("click",B):a.style.pointerEvents="none"}function fn(){a.removeEventListener("click",B)}function hn(b){let Y=[...Array.from(b.childNodes).reverse()];for(;Y.length;){const N=Y.shift();if(Mn(N))return N;N&&(Y=[...Y,...Array.from(N.childNodes).reverse()])}return null}function tn(){f.removeEventListeners({onStart:k}),d.removeEventListeners({onStart:k}),C.removeEventListeners({onStart:k}),D.forEach(b=>{b.removeEventListeners({onStart:k})}),s.removeEventListeners({onStart:w,onMove:O,onEnd:L})}return{attachEventListeners:W,clearEventListeners:tn,attacheOnOpenEventListeners:nn,clearOnOpenEventListeners:fn}}class qn{constructor(){z(this,"animationId");z(this,"isInProgress");z(this,"startedAt");this.animationId=null,this.isInProgress=!1,this.startedAt=null}start(t,e,o=!1){this.isInProgress=!0;const i=r=>{this.startedAt||(this.startedAt=r);const c=r-this.startedAt,a=e===0?1:Q(c/e,2),T=a>=1&&!o;t(a),T?this.stop():this.animationId=requestAnimationFrame(i)};this.animationId=requestAnimationFrame(i)}stop(){this.isInProgress=!1,this.startedAt=null,S(this.animationId)&&cancelAnimationFrame(this.animationId)}}function Jn(n){const{startY:t,endY:e,bottomSheetContainer:o,animationFrame:i,onEnd:r,animationTimingFunction:c,animationDuration:l}=n,a=En(t,e);i.stop();let T=!1;i.start(f=>{Z(o,{y:t+a*c(f)}),!T&&f>=1&&(r==null||r(),T=!0)},l)}const ln=(n,t)=>e=>{Jn({...e,animationTimingFunction:n,animationDuration:t})},_={TOP:"top",MIDDLE:"middle",CONTENT_HEIGHT:"content-height",CLOSED:"closed"};function Qn(n){return!(!S(n)||n>1||n<0)}function Zn(n,t){const e={set(o,i,r,c){return t(i,r),Reflect.set(o,i,r,c)}};return new Proxy(n,e)}function nt(...n){console.error(n)}const F={EASE:"ease",EASE_IN:"ease-in",EASE_OUT:"ease-out",EASE_IN_OUT:"ease-in-out",SPRING:"spring"};function An(n){for(const t of Object.values(F))if(t===n)return!0;return!1}function un(n){return!!(n instanceof Object&&"p1x"in n&&"p1y"in n&&"p2x"in n&&"p2y"in n&&S(n.p1x)&&S(n.p1y)&&S(n.p2x)&&S(n.p2y))}function U(n,t,e,o){return function(a){return l(r(a))};function r(a){let T=0,f=1,d=a,C;if(a===0||a===1)return a;for(;T<f;){if(C=c(d),Math.abs(C-a)<.001)return d;a>C?T=d:f=d,d=(f+T)/2}return d}function c(a){return 3*n*a*Math.pow(1-a,2)+3*e*Math.pow(a,2)*(1-a)+Math.pow(a,3)}function l(a){return 3*t*a*Math.pow(1-a,2)+3*o*Math.pow(a,2)*(1-a)+Math.pow(a,3)}}const Sn=U(.25,.1,.25,1),tt=U(.42,0,1,1),Dn=U(.42,0,.58,1),et=U(.4,.1,.6,1),rt=U(.45,1.5,.55,1);function ot(n){switch(n){case F.EASE:return Sn;case F.EASE_IN:return tt;case F.EASE_OUT:return Dn;case F.EASE_IN_OUT:return et;case F.SPRING:return rt;default:return Sn}}function Bn(n){return typeof n=="boolean"}const xn={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 it(n){const t={...xn},e=Object.entries(n).reduce((i,r)=>{const[c,l]=r;return an(l)&&(i[c]=l),i},{});return{...t,...e}}function dn(n){if(un(n)){const{p1x:t,p1y:e,p2x:o,p2y:i}=n;return U(t,e,o,i)}return An(n)?ot(n):Dn}function st(n,t,e){function o(i,r){switch(i){case"content":E(r)&&(n.bottomSheetContentWrapper.innerHTML=r);break;case"width":E(r)&&(n.bottomSheetContainer.style.width=r);break;case"shouldShowHandle":Bn(r)||K(n.bottomSheetHandle,!1);break;case"shouldShowBackdrop":Bn(r)||K(n.bottomSheetBackdrop,!1);break;case"containerBorderRadius":E(r)&&(n.bottomSheetContainer.style.borderRadius=kn(r));break;case"backdropColor":E(r)&&(n.bottomSheetBackdrop.style.backgroundColor=r);break;case"backDropTransition":E(r)&&(n.bottomSheetBackdrop.style.transition=r);break;case"rootClass":if(!E(r))return;G(n.bottomSheetRoot,e.rootClass,r);break;case"containerClass":if(!E(r))return;G(n.bottomSheetContainer,e.containerClass,r);break;case"handleClass":if(!E(r))return;G(n.bottomSheetHandle,e.handleClass,r);break;case"contentWrapperClass":if(!E(r))return;G(n.bottomSheetContentWrapper,e.contentWrapperClass,r);break;case"backdropClass":if(!E(r))return;G(n.bottomSheetBackdrop,e.backdropClass,r);break;case"draggingAnimationTimings":if(un(r)){const c=dn(r),l=ln(c,e.draggingAnimationDuration);t.translateContainer=l}break;case"draggingAnimationDuration":if(S(r)){const c=dn(e.draggingAnimationTimings),l=ln(c,r);t.translateContainer=l}break}}return o}function at(n){const t=it(n),e=dn(n.draggingAnimationTimings),i={isMounted:!1,translateContainer:ln(e,t.draggingAnimationDuration)},r={startY:null,containerStartTranslate:{x:0,y:0},isDragging:!1,originalDocumentOverflowY:null,originalDocumentOverscrollBehavior:null};function c(){r.originalDocumentOverflowY&&r.originalDocumentOverflowY!=="hidden"&&(document.body.style.overflowY=r.originalDocumentOverflowY),r.originalDocumentOverscrollBehavior&&(document.body.style.position=r.originalDocumentOverscrollBehavior)}const l=new qn,a={animationFrame:l,onClose:B,bottomSheetState:i,draggingState:r,snapTo:en,moveUp:Y,moveDown:N},{elements:T,eventHandlers:f}=Vn(t,a),d=Zn(t,st(T,i,t)),{bottomSheetBackdrop:C,bottomSheetRoot:D,bottomSheetContainer:s}=T,w=u=>{const h=u??window.document.body;h.appendChild(D),h.appendChild(C);const p=window.innerHeight;Z(s,{y:p}),f.attachEventListeners(),i.isMounted=!0},O=()=>{f.clearEventListeners(),Object.values(T).forEach(u=>{u.remove()}),c(),i.isMounted=!1},L=()=>{var x;if(k()||nt('Bottom Sheet is not mounted yet. call the "mount" method first.'),(x=n.beforeOpen)==null||x.call(n),W())return;on(C,!0),d.shouldShowBackdrop||$(C,"transparent"),on([s],!0),Z(s,{y:s.clientHeight});const h=window.innerHeight,p=bn(h,s.clientHeight,d.marginTop,d.defaultPosition),m=I(s).y;i.translateContainer({startY:m,endY:p,animationFrame:l,bottomSheetContainer:s,onEnd:n.afterOpen});const y=document.body.style.overflowY;r.originalDocumentOverflowY=y||"initial";const A=document.body.style.overscrollBehavior;r.originalDocumentOverscrollBehavior=A||"initial",document.body.style.overflow="hidden",document.body.style.overscrollBehavior="contain",T.bottomSheetHandle.focus(),f.attacheOnOpenEventListeners()};function B(){var p;if(nn())return;(p=n.beforeClose)==null||p.call(n);const u=I(s).y,h=s.clientHeight;i.translateContainer({startY:u,endY:h,animationFrame:l,bottomSheetContainer:s,onEnd:()=>{var m;(m=n.afterClose)==null||m.call(n),on([C,s],!1),f.clearOnOpenEventListeners()}}),c()}function k(){return i.isMounted}function W(){const u=I(s).y,h=window.innerHeight,p=s.clientHeight>=h?h:s.clientHeight;return u<=p}function nn(){return!W()}function fn(){const u=I(s).y,h=s.clientHeight,p=window.innerHeight;if(u<=5&&u>=-5)return _.CONTENT_HEIGHT;const m=h-u;if(m===p/2)return _.MIDDLE;const y=p-d.marginTop,A=10;return m<=y+A&&m>=y-A?_.TOP:_.CLOSED}function hn(){return s.clientHeight}function tn(u){if(!W())return;const h=I(s).y,m=s.clientHeight-h,y=window.innerHeight-u,A=_n(m,y),x=J(m,y);i.translateContainer({startY:h,endY:h+(A.isUp?-x:x),animationFrame:l,bottomSheetContainer:s})}function b(u,{viewportHeight:h,visibleHeight:p}){let m=null;for(const y of u){const A=y*h,x=J(p,A);(m===null||x<m)&&(m=x)}return{minOffset:m}}function Y(){const u=[...d.snapPoints].reverse(),h=I(s).y,p=s.clientHeight,m=p-h;if(!d.expandable&&m>=p)return;const y=window.innerHeight,A=vn("above",{visibleHeight:m,viewportHeight:y},u),{minOffset:x}=b(A,{visibleHeight:m,viewportHeight:y});if(x===null&&m<y-d.marginTop){i.translateContainer({startY:h,endY:bn(y,p,d.marginTop,"top"),animationFrame:l,bottomSheetContainer:s});return}S(x)&&i.translateContainer({startY:h,endY:h-x,animationFrame:l,bottomSheetContainer:s})}function N(){const u=I(s).y,p=s.clientHeight-u;if(p<1)return;const m=window.innerHeight,y=vn("below",{visibleHeight:p,viewportHeight:m},d.snapPoints),{minOffset:A}=b(y,{visibleHeight:p,viewportHeight:m});S(A)&&i.translateContainer({startY:u,endY:u+A,animationFrame:l,bottomSheetContainer:s})}function en(u){const h=window.innerHeight;if(!Qn(u))return;const p=Q(h*u,2);tn(p)}return{props:d,elements:T,mount:w,unmount:O,open:L,close:B,getIsMounted:k,getIsOpen:W,getIsClosed:nn,getPosition:fn,getHeight:hn,moveTo:tn,snapTo:en}}function ct(){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=xn,g.BOTTOM_SHEET_POSITION=_,g.BOTTOM_SHEET_SELECTORS=Pn,g.COMMON_ANIMATION_KEYS=F,g.ClassNames=v,g.EventPhase=P,g.ResetClassNames=q,g.UtilClassNames=j,g.createBottomSheet=at,g.createPlaceholderBottomSheet=ct,g.eventPhaseToEnum=cn,g.isAnimationTimingPoints=un,g.isCommonAnimationTimingsKey=An,Object.defineProperty(g,Symbol.toStringTag,{value:"Module"})});
@@ -49,7 +49,11 @@ export interface BottomSheetCoreProps {
49
49
  onDragEnd?: () => void;
50
50
  shouldShowHandle?: boolean;
51
51
  shouldShowBackdrop?: boolean;
52
- containerBorderRadius?: CSSUnit | null;
52
+ /**
53
+ * Border radius will be applied to the upper vertices.
54
+ * ex) If it is 10px, border radius becomes `10px 10px 0px 0px`
55
+ */
56
+ containerBorderRadius?: CSSUnit | string | null;
53
57
  backdropColor?: CSSColor | string | null;
54
58
  backDropTransition?: string | null;
55
59
  rootClass?: string | null;
@@ -62,18 +66,22 @@ export interface BottomSheetCoreProps {
62
66
  * an object {p1x: number, p1y: number, p2x: number, p2y: number} that describes the timing of animations as a Bezier curve.
63
67
  * @see https://developer.mozilla.org/en-US/docs/Web/CSS/animation-timing-function
64
68
  */
65
- draggingAnimationTimings?: CommonAnimation | AnimationTimingPoints | null;
69
+ draggingAnimationTimings?: DraggingAnimationTimings;
66
70
  /**
67
71
  * In milliseconds.
68
72
  */
69
73
  draggingAnimationDuration?: number;
70
74
  }
75
+ export type DraggingAnimationTimings = CommonAnimation | AnimationTimingPoints | null;
71
76
  export declare const BOTTOM_SHEET_POSITION: {
72
77
  readonly TOP: "top";
73
78
  readonly MIDDLE: "middle";
74
79
  readonly CONTENT_HEIGHT: "content-height";
75
80
  readonly CLOSED: "closed";
76
81
  };
82
+ /**
83
+ * "top" | "middle" | "content-height" | "closed"
84
+ */
77
85
  export type BottomSheetPosition = (typeof BOTTOM_SHEET_POSITION)[keyof typeof BOTTOM_SHEET_POSITION];
78
86
  /**
79
87
  * Points where it snaps to when the handle is released.
@@ -1 +1 @@
1
- {"version":3,"file":"bottom-sheet-props.type.d.ts","sourceRo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AAI,CAAC;IACpC,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAG9B;;;;OAIG;IACH,wBAAwB,CAAC,EAAE,wBAAwB,CAAC;IAEpD;;OAEG;IACH,yBAAyB,CAAC,EAAE,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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plainsheet/core",
3
- "version": "0.7.1",
3
+ "version": "0.7.4",
4
4
  "private": false,
5
5
  "sideEffects": false,
6
6
  "description": "The minimalistic, configurable React bottom-sheet for the Web developers",