@plainsheet/react 0.3.1 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const k=require("react"),At=require("react-dom");function Lt(t){return t!=null}(function(){try{if(typeof document<"u"){var t=document.createElement("style");t.appendChild(document.createTextNode('.pbs-root{position:fixed;left:0;bottom:0;display:flex;flex-direction:column;align-items:center;justify-content:flex-start;width:100%;height:fit-content;max-height:100vh;z-index:2}.pbs-dialog-reset{background-color:transparent;color:inherit;border:none;outline:none;padding:0;margin:0}.pbs-backdrop{position:fixed;top:0;left:0;width:100%;height:100%;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(t)}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();var Ot=Object.defineProperty,Dt=(t,e,n)=>e in t?Ot(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,$=(t,e,n)=>Dt(t,typeof e!="symbol"?e+"":e,n);function T(t){return typeof t=="string"}function Pt(t,e){return t.classList.contains(Q(e))}function q(t,e){t.classList.add(Q(e))}function nt(t,e){t.classList.remove(Q(e))}function j(t,e,n){T(n)&&(T(e)&&nt(t,e),q(t,n))}function Q(t){return T(t)?t.trim().replace(/\./g,""):""}function R(t){return t.map(e=>Q(e)).filter(Boolean).join(" ")}function Bt(t){return t.map(e=>e==null?void 0:e.trim()).filter(Boolean).map(e=>`.${e}`).join(" ")}const lt="open",dt="hidden";function et(t,e){const n=e;if(Array.isArray(t)){t.forEach(o=>{z(o,n),o.setAttribute("aria-modal",n?"true":"false")});return}z(t,n),t.setAttribute("aria-modal",n?"true":"false")}function z(t,e){e?(q(t,lt),nt(t,dt)):(q(t,dt),nt(t,lt))}function St(t){return t instanceof HTMLElement}function A(t){return typeof t=="number"&&!Number.isNaN(t)}function Mt(t){St(t)&&t.focus()}function Yt(t){if(!St(t)||t.offsetParent===null||"disabled"in t&&t.disabled)return!1;const e=t.getAttribute("tabindex"),n=A(e)?parseInt(e,10):-1,o=["INPUT","BUTTON","SELECT","TEXTAREA","A","AREA","IFRAME"].includes(t.tagName),i=t instanceof HTMLAnchorElement&&t.href!==""||t instanceof HTMLAreaElement&&t.href!=="";return o||i||n>-1}var w=(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))(w||{}),ot=(t=>(t.Button="pbs-button-reset",t.Dialog="pbs-dialog-reset",t))(ot||{}),X=(t=>(t.Hidden="hidden",t))(X||{});function M(t,e,n){const o=document.createElement(t);return e.split(" ").forEach(i=>{q(o,i)}),T(n)&&o.setAttribute("data-testid",n),o}Bt([w.Root,w.ContentWrapper]);function pt(t,e,n,o){switch(o){case"content-height":return e>=t?yt(t,e,n):0;case"middle":return-(t/2-e);case"top":return-(t-e)+n;default:return 0}}function Ct(t,e){const n=e<t,o=e>t;return{isUp:n,isDown:o,stayedSame:e===t}}function wt(t,e){return e<t?-(t-e):e-t}function V(t,e){return t>e?t-e:e-t}function It(t,e){const n=t<e,o=t>e;return{isUp:n,isDown:o,stayedSame:t===e}}function ht(t,e,n){const o=t==="above";return n.filter(i=>{const r=i*e.viewportHeight;return o?e.visibleHeight<r:e.visibleHeight>r})}function yt(t,e,n){return-(t-e)+n}function mt(t){return Number(t.replace("px",""))}function K(t,...e){return Number(t.toFixed(...e))}function Et(t){const e=/(?<type>\w+)\((?<values>[^)]+)\)/g,n=[];let o;for(;(o=e.exec(t))!==null;){const i=o[1],r=o[2].split(",").map(c=>c.trim());n.push({type:i,values:r})}return n}function Rt(t){const e=t.style.transform,n=Et(e);return{transform:e,transformValues:n}}function Ht(t,e){return t.find(o=>o.type.startsWith(e))||null}const rt="translate";function P(t){const e=t.style.transform,n=Et(e),o=Ht(n,rt);return Tt(o??{type:rt,values:[]})}function J(t,{x:e,y:n}){const{transform:o,transformValues:i}=Rt(t),r=Ht(i,rt);if(r){const c=Tt(r);t.style.transform=`translate(${e??c.x??0}px,${n??c.y??0}px)`;return}if(o){t.style.transform=`${o}, translate(${e??0}px,${n??0}px)`;return}t.style.transform=`translate(${e??0}px,${n??0}px)`}function Tt(t){if(t.type!=="translate")throw new Error(`Could not get coordinates from ${t.type}, since is not translate.`);const e=t.values[0],n=t.values[1];return{x:mt(e)??0,y:mt(n)??0}}function it(t){return t!=null}function ft(t,{min:e,max:n}){return it(n)&&t>=n?n:it(e)&&t<=e?e:t}const Nt=(t,e,n)=>{e instanceof HTMLElement&&!Pt(e,w.Handle)&&n.scrollTop>=1||(t.isDragging=!0)},Ft=(t,e,n,o)=>i=>{o.startY=t.getCoordinates(i).y,o.containerStartTranslate=P(e),n.onDragStart()},Wt=(t,e,n,o,i)=>r=>{Ut(r,t,n,o,i,e,n.marginTop)};function Ut(t,e,n,o,i,r,c){if(!o.isDragging||!A(o.startY))return;const s=e.getCoordinates(t).y,p=wt(o.startY,s),f=window.innerHeight,u=r.clientHeight,b=u-(o.containerStartTranslate.y+p);if(b>=f)return;const E=Ct(o.startY,s);if(E.isUp&&!n.expandable&&b>=u)return;i.start(()=>{J(r,{y:o.containerStartTranslate.y+p})},0);const a=f-c,x=u-o.containerStartTranslate.y;if(E.isUp){const v=a-x,S=a-b,H=ft(1-K(S/v,2),{min:0,max:1});n.onDragMove(E,H)}else if(E.isDown){const v=ft(K(1-b/x,2),{min:0,max:1});n.onDragMove(E,v)}}const jt=(t,e,n,o,i,r,c)=>s=>{if(!o.isDragging||(o.isDragging=!1,!A(o.startY)))return;n.onDragEnd();const p=o.startY,f=t.getCoordinates(s).y,u=P(e).y,b=Ct(p,f),E=window.innerHeight,a=e.clientHeight;if(b.isUp){const x=[...n.snapPoints].sort((H,C)=>H-C),v=a+-u;if(!n.expandable&&v>=a)return;for(const H of x){const C=H*window.innerHeight;if(v<=C){const B=V(v,C);c.translateContainer({startY:u,endY:u-B,animationFrame:i,bottomSheetContainer:e});return}}const S=yt(E,a,n.marginTop);c.translateContainer({startY:u,endY:S,animationFrame:i,bottomSheetContainer:e})}else if(b.isDown){const x=[...n.snapPoints].sort((v,S)=>S-v);for(const v of x){const S=v*window.innerHeight,H=a+-u;if(H>=S){const C=V(H,S);c.translateContainer({startY:u,endY:u+C,animationFrame:i,bottomSheetContainer:e});return}}r()}};var W=(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))(W||{});function gt(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:W.All};class G{constructor(e){$(this,"currentTarget"),this.currentTarget=e}addEventListeners({onStart:e,onStartOptions:n=Gt,onMove:o,onEnd:i}){this.addTouchEventListeners({onStart:e,onStartOptions:n,onMove:o,onEnd:i}),this.addMouseEventListeners({onStart:e,onStartOptions:n,onMove:o,onEnd:i})}addTouchEventListeners({onStart:e,onStartOptions:n,onMove:o,onEnd:i}){e&&this.currentTarget.addEventListener("touchstart",r=>{if(n.eventPhase===W.All){e(r);return}gt(r.eventPhase)===n.eventPhase&&e(r)},{passive:!0}),o&&this.currentTarget.addEventListener("touchmove",o),i&&this.currentTarget.addEventListener("touchend",i)}addMouseEventListeners({onStart:e,onStartOptions:n,onMove:o,onEnd:i}){e&&this.currentTarget.addEventListener("mousedown",r=>{if(n.eventPhase===W.All){e(r);return}gt(r.eventPhase)===n.eventPhase&&e(r)},{passive:!0}),o&&this.currentTarget.addEventListener("mousemove",o),i&&this.currentTarget.addEventListener("mouseup",r=>{i(r)})}removeEventListeners({onStart:e,onMove:n,onEnd:o}){e&&this.currentTarget.removeEventListener("touchstart",e),o&&this.currentTarget.removeEventListener("touchend",o),n&&this.currentTarget.removeEventListener("touchmove",n),e&&this.currentTarget.removeEventListener("mousedown",e),n&&this.currentTarget.removeEventListener("mousemove",n),o&&this.currentTarget.removeEventListener("mouseup",o)}getCoordinates(e){if(e.type==="touchstart"||e.type==="mousedown"){if("touches"in e)return{x:e.touches[0].clientX,y:e.touches[0].clientY};if(e instanceof MouseEvent)return{x:e.clientX,y:e.clientY}}if(e.type==="touchend"||e.type==="mouseup"||e.type==="mousemove"||e.type==="touchmove"){if("touches"in e)return{x:e.changedTouches[0].clientX,y:e.changedTouches[0].clientY};if(e instanceof MouseEvent)return{x:e.clientX,y:e.clientY}}return{x:0,y:0}}}function _t(t,e){const n=$t(t);Xt(n),n.bottomSheetContainer.style.width=t.width;const o=document.createElement("div");o.innerHTML=t.content??"";const i=window.innerHeight;n.bottomSheetContainer.style.maxHeight=`${i}px`,n.bottomSheetContentWrapper.appendChild(o);const r=qt({bottomSheetElements:n,bottomSheetProps:t,options:e});return{elements:n,eventHandlers:r}}function $t(t){const e=M("dialog",R([w.Root,ot.Dialog,t.rootClass]),w.Root);e.ariaLabel=t.ariaLabel;const n=M("section",R([w.Container,t.containerClass]),w.Container);t.containerBorderRadius&&(n.style.borderRadius=t.containerBorderRadius);const o=M("div",w.GapFiller,w.GapFiller),i=M("button",R([w.Handle,ot.Button,t.shouldShowHandle?null:X.Hidden,t.handleClass]),w.Handle);i.setAttribute("type","button"),i.ariaLabel="bottom sheet close button";const r=M("span",R([w.HandleBar,t.shouldShowHandle?null:X.Hidden]),w.HandleBar),c=M("article",R([w.ContentWrapper,t.contentWrapperClass]),w.ContentWrapper),s=M("div",R([w.Backdrop,t.backdropClass,X.Hidden]),w.Backdrop);return t.backdropColor&&(s.style.backgroundColor=t.backdropColor),t.backDropTransition&&(s.style.transition=t.backDropTransition),{bottomSheetRoot:e,bottomSheetBackdrop:s,bottomSheetContainer:n,bottomSheetHandle:i,bottomSheetHandleBar:r,bottomSheetContentWrapper:c,bottomSheetContainerGapFiller:o}}function Xt({bottomSheetRoot:t,bottomSheetContainer:e,bottomSheetHandle:n,bottomSheetHandleBar:o,bottomSheetContentWrapper:i,bottomSheetContainerGapFiller:r}){t.appendChild(e),n.appendChild(o),e.appendChild(n),e.appendChild(i),e.appendChild(r)}function qt({bottomSheetElements:t,bottomSheetProps:e,options:n}){const{bottomSheetRoot:o,bottomSheetContainer:i,bottomSheetHandle:r,bottomSheetContainerGapFiller:c,bottomSheetContentWrapper:s}=t,{animationFrame:p}=n,f=new G(r),u=new G(s),b=new G(c),E=e.dragTriggers.reduce((g,L)=>{const O=o.querySelectorAll(L);if(!O.length)return g;const tt=Array.from(O).map(Y=>Y instanceof HTMLElement?new G(Y):null).filter(Y=>!!Y);return[...g,...tt]},[]),a=new G(window),x=Ft(a,i,e,n.draggingState),v=Wt(a,i,e,n.draggingState,p),S=jt(a,i,e,n.draggingState,p,n.onClose,n.bottomSheetState);function H(g){g.target instanceof Element&&!o.contains(g.target)&&n.onClose()}function C(g){Nt(n.draggingState,g.target,t.bottomSheetContentWrapper)}function B(){e.draggable&&(f.addEventListeners({onStart:C}),E.forEach(g=>{g.addEventListeners({onStart:C,onStartOptions:{eventPhase:W.Target}})})),e.draggable&&e.backgroundDraggable&&(u.addEventListeners({onStart:C,onStartOptions:{eventPhase:W.Target}}),b.addEventListeners({onStart:C})),e.draggable&&a.addEventListeners({onStart:x,onMove:v,onEnd:S}),e.draggable&&window.document.addEventListener("keyup",g=>{g.key==="Escape"&&n.onClose()}),e.shouldCloseOnOutsideClick&&window.document.addEventListener("click",H),r.addEventListener("keyup",g=>{if(g.key==="ArrowUp"){n.moveUp();return}if(g.key==="ArrowDown"){n.moveDown();return}if(g.shiftKey&&g.key==="Tab"){const L=_(t.bottomSheetContentWrapper);Mt(L)}})}function _(g){let L=[...Array.from(g.childNodes).reverse()];for(;L.length;){const O=L.shift();if(Yt(O))return O;O&&(L=[...L,...Array.from(O.childNodes).reverse()])}return null}function Z(){f.removeEventListeners({onStart:C}),u.removeEventListeners({onStart:C}),b.removeEventListeners({onStart:C}),E.forEach(g=>{g.removeEventListeners({onStart:C})}),a.removeEventListeners({onStart:x,onMove:v,onEnd:S}),window.removeEventListener("click",H)}return{attachEventListeners:B,clearEventListeners:Z}}class zt{constructor(){$(this,"animationId"),$(this,"isInProgress"),$(this,"startedAt"),this.animationId=null,this.isInProgress=!1,this.startedAt=null}start(e,n,o=!1){this.isInProgress=!0;const i=r=>{this.startedAt||(this.startedAt=r);const c=r-this.startedAt,s=n===0?1:K(c/n,2),p=s>=1&&!o;e(s),p?this.stop():this.animationId=requestAnimationFrame(i)};this.animationId=requestAnimationFrame(i)}stop(){this.isInProgress=!1,this.startedAt=null,A(this.animationId)&&cancelAnimationFrame(this.animationId)}}function Vt(t){const{startY:e,endY:n,bottomSheetContainer:o,animationFrame:i,onEnd:r,animationTimingFunction:c,animationDuration:s}=t,p=wt(e,n);i.stop();let f=!1;i.start(u=>{J(o,{y:e+p*c(u)}),!f&&u>=1&&(r==null||r(),f=!0)},s)}const at=(t,e)=>n=>{Vt({...n,animationTimingFunction:t,animationDuration:e})},F={TOP:"top",MIDDLE:"middle",CONTENT_HEIGHT:"content-height",CLOSED:"closed"};function Kt(t){return!(!A(t)||t>1||t<0)}function Jt(t,e){const n={set(o,i,r,c){return e(i,r),Reflect.set(o,i,r,c)}};return new Proxy(t,n)}function Qt(...t){console.error(t)}const N={EASE:"ease",EASE_IN:"ease-in",EASE_OUT:"ease-out",EASE_IN_OUT:"ease-in-out",SPRING:"spring"};function Zt(t){for(const e of Object.values(N))if(e===t)return!0;return!1}function kt(t){return!!(t instanceof Object&&"p1x"in t&&"p1y"in t&&"p2x"in t&&"p2y"in t&&A(t.p1x)&&A(t.p1y)&&A(t.p2x)&&A(t.p2y))}function U(t,e,n,o){return function(s){return c(i(s))};function i(s){let p=0,f=1,u=s,b;if(s===0||s===1)return s;for(;p<f;){if(b=r(u),Math.abs(b-s)<.001)return u;s>b?p=u:f=u,u=(f+p)/2}return u}function r(s){return 3*t*s*Math.pow(1-s,2)+3*n*Math.pow(s,2)*(1-s)+Math.pow(s,3)}function c(s){return 3*e*s*Math.pow(1-s,2)+3*o*Math.pow(s,2)*(1-s)+Math.pow(s,3)}}const te=U(.25,.1,.25,1),ee=U(.42,0,1,1),xt=U(.42,0,.58,1),bt=U(.4,.1,.6,1),ne=U(.45,1.5,.55,1);function oe(t){switch(t){case N.EASE:return te;case N.EASE_IN:return ee;case N.EASE_OUT:return xt;case N.EASE_IN_OUT:return bt;case N.SPRING:return ne;default:return bt}}function vt(t){return typeof t=="boolean"}const re={ariaLabel:"Bottom sheet",content:"",defaultPosition:F.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 ie(t){const e={...re},n=Object.entries(t).reduce((o,i)=>{const[r,c]=i;return it(c)&&(o[r]=c),o},{});return{...e,...n}}function st(t){if(kt(t)){const{p1x:e,p1y:n,p2x:o,p2y:i}=t;return U(e,n,o,i)}return Zt(t)?oe(t):xt}function ae(t,e,n){function o(i,r){switch(i){case"content":T(r)&&(t.bottomSheetContentWrapper.innerHTML=r);break;case"width":T(r)&&(t.bottomSheetContainer.style.width=r);break;case"shouldShowHandle":vt(r)||z(t.bottomSheetHandle,!1);break;case"shouldShowBackdrop":vt(r)||z(t.bottomSheetBackdrop,!1);break;case"containerBorderRadius":T(r)&&(t.bottomSheetContainer.style.borderRadius=r);break;case"backdropColor":T(r)&&(t.bottomSheetBackdrop.style.backgroundColor=r);break;case"backDropTransition":T(r)&&(t.bottomSheetBackdrop.style.transition=r);break;case"rootClass":if(!T(r))return;j(t.bottomSheetRoot,n.rootClass,r);break;case"containerClass":if(!T(r))return;j(t.bottomSheetContainer,n.containerClass,r);break;case"handleClass":if(!T(r))return;j(t.bottomSheetHandle,n.handleClass,r);break;case"contentWrapperClass":if(!T(r))return;j(t.bottomSheetContentWrapper,n.contentWrapperClass,r);break;case"backdropClass":if(!T(r))return;j(t.bottomSheetBackdrop,n.backdropClass,r);break;case"draggingAnimationTimings":if(kt(r)){const c=st(r),s=at(c,n.draggingAnimationDuration);e.translateContainer=s}break;case"draggingAnimationDuration":if(A(r)){const c=st(n.draggingAnimationTimings),s=at(c,r);e.translateContainer=s}break}}return o}function se(t){const e=ie(t),n=st(t.draggingAnimationTimings),o={isMounted:!1,translateContainer:at(n,e.draggingAnimationDuration)},i={startY:null,containerStartTranslate:{x:0,y:0},isDragging:!1,originalDocumentOverflowY:null};function r(){i.originalDocumentOverflowY&&i.originalDocumentOverflowY!=="hidden"&&(document.body.style.overflowY=i.originalDocumentOverflowY)}const c=new zt,s={animationFrame:c,onClose:H,bottomSheetState:o,draggingState:i,snapTo:ut,moveUp:tt,moveDown:Y},{elements:p,eventHandlers:f}=_t(e,s),u=Jt(e,ae(p,o,e)),{bottomSheetBackdrop:b,bottomSheetRoot:E,bottomSheetContainer:a}=p,x=l=>{const d=l??window.document.body;d.appendChild(E),d.appendChild(b);const h=window.innerHeight;J(a,{y:h}),f.attachEventListeners(),o.isMounted=!0},v=()=>{f.clearEventListeners(),Object.values(p).forEach(l=>{l.remove()}),r(),o.isMounted=!1},S=()=>{var l;if(C()||Qt('Bottom Sheet is not mounted yet. call the "mount" method first.'),(l=t.beforeOpen)==null||l.call(t),B())return;u.shouldShowBackdrop&&et(b,!0),et([a],!0),J(a,{y:a.clientHeight});const d=window.innerHeight,h=pt(d,a.clientHeight,u.marginTop,u.defaultPosition),m=P(a).y;o.translateContainer({startY:m,endY:h,animationFrame:c,bottomSheetContainer:a,onEnd:t.afterOpen}),p.bottomSheetHandle.focus();const y=document.body.style.overflowY;i.originalDocumentOverflowY=y||"initial",document.body.style.overflowY="hidden"};function H(){var l;if(_())return;(l=t.beforeClose)==null||l.call(t);const d=P(a).y,h=a.clientHeight;o.translateContainer({startY:d,endY:h,animationFrame:c,bottomSheetContainer:a,onEnd:()=>{var m;(m=t.afterClose)==null||m.call(t),et([b,a],!1)}}),r()}function C(){return o.isMounted}function B(){const l=P(a).y,d=window.innerHeight,h=a.clientHeight>=d?d:a.clientHeight;return l<h}function _(){return!B()}function Z(){const l=P(a).y,d=a.clientHeight,h=window.innerHeight;if(l<=5&&l>=-5)return F.CONTENT_HEIGHT;const m=d-l;if(m===h/2)return F.MIDDLE;const y=h-u.marginTop,D=10;return m<=y+D&&m>=y-D?F.TOP:F.CLOSED}function g(){return a.clientHeight}function L(l){if(!B())return;const d=P(a).y,h=a.clientHeight-d,m=window.innerHeight-l,y=It(h,m),D=V(h,m);o.translateContainer({startY:d,endY:d+(y.isUp?-D:D),animationFrame:c,bottomSheetContainer:a})}function O(l,{viewportHeight:d,visibleHeight:h}){let m=null;for(const y of l){const D=y*d,I=V(h,D);(m===null||I<m)&&(m=I)}return{minOffset:m}}function tt(){const l=[...u.snapPoints].reverse(),d=P(a).y,h=a.clientHeight,m=h-d;if(!u.expandable&&m>=h)return;const y=window.innerHeight,D=ht("above",{visibleHeight:m,viewportHeight:y},l),{minOffset:I}=O(D,{visibleHeight:m,viewportHeight:y});if(I===null&&m<y-u.marginTop){o.translateContainer({startY:d,endY:pt(y,h,u.marginTop,"top"),animationFrame:c,bottomSheetContainer:a});return}A(I)&&o.translateContainer({startY:d,endY:d-I,animationFrame:c,bottomSheetContainer:a})}function Y(){const l=P(a).y,d=a.clientHeight-l;if(d<1)return;const h=window.innerHeight,m=ht("below",{visibleHeight:d,viewportHeight:h},u.snapPoints),{minOffset:y}=O(m,{visibleHeight:d,viewportHeight:h});A(y)&&o.translateContainer({startY:l,endY:l+y,animationFrame:c,bottomSheetContainer:a})}function ut(l){const d=window.innerHeight;if(!Kt(l))return;const h=K(d*l,2);L(h)}return{props:u,elements:p,mount:x,unmount:v,open:S,close:H,getIsMounted:C,getIsOpen:B,getIsClosed:_,getPosition:Z,getHeight:g,moveTo:L,snapTo:ut}}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:()=>F.CLOSED,moveTo:()=>{},snapTo:()=>{},props:{content:""}}}const ce=ct(),ue=k.forwardRef(function(e,n){const{children:o,isOpen:i,setIsOpen:r,afterClose:c,mountingPoint:s,...p}=e,f=k.useRef(ce),[u,b]=k.useState(f.current);k.useImperativeHandle(n,()=>u,[u]);const E=k.useCallback(()=>{r(!1),c==null||c()},[c]);k.useEffect(()=>{i?u.open():u.close()},[i]);const a=k.useRef(null);return k.useEffect(function(){const v=Lt(e.mountingPoint)?e.mountingPoint:window.document.body;if(!v||u.getIsMounted())return;const S=se({content:"",...p,afterClose:E});return S.mount(v),a.current=S.elements.bottomSheetContentWrapper??null,f.current=S,b(S),()=>{u.unmount()}},[e.mountingPoint,p,E]),k.useEffect(function(){Object.assign(f.current.props,{...p}),b(f.current)},[p]),a.current?At.createPortal(e.children,a.current):null}),le=ct();function de(){const t=k.useRef(le),[e,n]=k.useState(!1),[o,i]=k.useState(t.current);return k.useEffect(()=>{i(t.current)},[t.current]),{props:k.useMemo(()=>({ref:t,isOpen:e,setIsOpen:n}),[e]),instance:o}}exports.BottomSheet=ue;exports.createPlaceholderBottomSheet=ct;exports.useBottomSheet=de;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const k=require("react"),xt=require("react-dom");function At(t){return t!=null}(function(){try{if(typeof document<"u"){var t=document.createElement("style");t.appendChild(document.createTextNode('.pbs-root{position:fixed;left:0;bottom:0;display:flex;flex-direction:column;align-items:center;justify-content:flex-start;width:100%;height:fit-content;max-height:100vh;z-index:2}.pbs-dialog-reset{background-color:transparent;color:inherit;border:none;outline:none;padding:0;margin:0}.pbs-backdrop{position:fixed;top:0;left:0;width:100%;height:100%;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(t)}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();var Ot=Object.defineProperty,Dt=(t,e,n)=>e in t?Ot(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,$=(t,e,n)=>Dt(t,typeof e!="symbol"?e+"":e,n);function H(t){return typeof t=="string"}function Bt(t,e){return t.classList.contains(Q(e))}function q(t,e){t.classList.add(Q(e))}function nt(t,e){t.classList.remove(Q(e))}function j(t,e,n){H(n)&&(H(e)&&nt(t,e),q(t,n))}function Q(t){return H(t)?t.trim().replace(/\./g,""):""}function R(t){return t.map(e=>Q(e)).filter(Boolean).join(" ")}function Pt(t){return t.map(e=>e==null?void 0:e.trim()).filter(Boolean).map(e=>`.${e}`).join(" ")}const ut="open",dt="hidden";function et(t,e){const n=e;if(Array.isArray(t)){t.forEach(o=>{z(o,n),o.setAttribute("aria-modal",n?"true":"false")});return}z(t,n),t.setAttribute("aria-modal",n?"true":"false")}function z(t,e){e?(q(t,ut),nt(t,dt)):(q(t,dt),nt(t,ut))}function St(t){return t instanceof HTMLElement}function x(t){return typeof t=="number"&&!Number.isNaN(t)}function Mt(t){St(t)&&t.focus()}function Yt(t){if(!St(t)||t.offsetParent===null||"disabled"in t&&t.disabled)return!1;const e=t.getAttribute("tabindex"),n=x(e)?parseInt(e,10):-1,o=["INPUT","BUTTON","SELECT","TEXTAREA","A","AREA","IFRAME"].includes(t.tagName),i=t instanceof HTMLAnchorElement&&t.href!==""||t instanceof HTMLAreaElement&&t.href!=="";return o||i||n>-1}var w=(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))(w||{}),ot=(t=>(t.Button="pbs-button-reset",t.Dialog="pbs-dialog-reset",t))(ot||{}),X=(t=>(t.Hidden="hidden",t))(X||{});function M(t,e,n){const o=document.createElement(t);return e.split(" ").forEach(i=>{q(o,i)}),H(n)&&o.setAttribute("data-testid",n),o}Pt([w.Root,w.ContentWrapper]);function ht(t,e,n,o){switch(o){case"content-height":return e>=t?yt(t,e,n):0;case"middle":return-(t/2-e);case"top":return-(t-e)+n;default:return 0}}function Ct(t,e){const n=e<t,o=e>t;return{isUp:n,isDown:o,stayedSame:e===t}}function wt(t,e){return e<t?-(t-e):e-t}function V(t,e){return t>e?t-e:e-t}function It(t,e){const n=t<e,o=t>e;return{isUp:n,isDown:o,stayedSame:t===e}}function pt(t,e,n){const o=t==="above";return n.filter(i=>{const r=i*e.viewportHeight;return o?e.visibleHeight<r:e.visibleHeight>r})}function yt(t,e,n){return-(t-e)+n}function mt(t){return Number(t.replace("px",""))}function K(t,...e){return Number(t.toFixed(...e))}function Et(t){const e=/(?<type>\w+)\((?<values>[^)]+)\)/g,n=[];let o;for(;(o=e.exec(t))!==null;){const i=o[1],r=o[2].split(",").map(c=>c.trim());n.push({type:i,values:r})}return n}function Rt(t){const e=t.style.transform,n=Et(e);return{transform:e,transformValues:n}}function Tt(t,e){return t.find(o=>o.type.startsWith(e))||null}const rt="translate";function B(t){const e=t.style.transform,n=Et(e),o=Tt(n,rt);return Ht(o??{type:rt,values:[]})}function J(t,{x:e,y:n}){const{transform:o,transformValues:i}=Rt(t),r=Tt(i,rt);if(r){const c=Ht(r);t.style.transform=`translate(${e??c.x??0}px,${n??c.y??0}px)`;return}if(o){t.style.transform=`${o}, translate(${e??0}px,${n??0}px)`;return}t.style.transform=`translate(${e??0}px,${n??0}px)`}function Ht(t){if(t.type!=="translate")throw new Error(`Could not get coordinates from ${t.type}, since is not translate.`);const e=t.values[0],n=t.values[1];return{x:mt(e)??0,y:mt(n)??0}}function it(t){return t!=null}function ft(t,{min:e,max:n}){return it(n)&&t>=n?n:it(e)&&t<=e?e:t}const Nt=(t,e,n)=>{e instanceof HTMLElement&&!Bt(e,w.Handle)&&n.scrollTop>=1||(t.isDragging=!0)},Ft=(t,e,n,o)=>i=>{o.startY=t.getCoordinates(i).y,o.containerStartTranslate=B(e),n.onDragStart()},Wt=(t,e,n,o,i)=>r=>{Ut(r,t,n,o,i,e,n.marginTop)};function Ut(t,e,n,o,i,r,c){if(!o.isDragging||!x(o.startY))return;const s=e.getCoordinates(t).y,h=wt(o.startY,s),f=window.innerHeight,l=r.clientHeight,b=l-(o.containerStartTranslate.y+h);if(b>=f)return;const E=Ct(o.startY,s);if(E.isUp&&!n.expandable&&b>=l)return;i.start(()=>{J(r,{y:o.containerStartTranslate.y+h})},0);const a=f-c,L=l-o.containerStartTranslate.y;if(E.isUp){const v=a-L,S=a-b,T=ft(1-K(S/v,2),{min:0,max:1});n.onDragMove(E,T)}else if(E.isDown){const v=ft(K(1-b/L,2),{min:0,max:1});n.onDragMove(E,v)}}const jt=(t,e,n,o,i,r,c)=>s=>{if(!o.isDragging||(o.isDragging=!1,!x(o.startY)))return;n.onDragEnd();const h=o.startY,f=t.getCoordinates(s).y,l=B(e).y,b=Ct(h,f),E=window.innerHeight,a=e.clientHeight;if(b.isUp){const L=[...n.snapPoints].sort((T,C)=>T-C),v=a+-l;if(!n.expandable&&v>=a)return;for(const T of L){const C=T*window.innerHeight;if(v<=C){const P=V(v,C);c.translateContainer({startY:l,endY:l-P,animationFrame:i,bottomSheetContainer:e});return}}const S=yt(E,a,n.marginTop);c.translateContainer({startY:l,endY:S,animationFrame:i,bottomSheetContainer:e})}else if(b.isDown){const L=[...n.snapPoints].sort((v,S)=>S-v);for(const v of L){const S=v*window.innerHeight,T=a+-l;if(T>=S){const C=V(T,S);c.translateContainer({startY:l,endY:l+C,animationFrame:i,bottomSheetContainer:e});return}}r()}};var W=(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))(W||{});function gt(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:W.All};class G{constructor(e){$(this,"currentTarget"),this.currentTarget=e}addEventListeners({onStart:e,onStartOptions:n=Gt,onMove:o,onEnd:i}){this.addTouchEventListeners({onStart:e,onStartOptions:n,onMove:o,onEnd:i}),this.addMouseEventListeners({onStart:e,onStartOptions:n,onMove:o,onEnd:i})}addTouchEventListeners({onStart:e,onStartOptions:n,onMove:o,onEnd:i}){e&&this.currentTarget.addEventListener("touchstart",r=>{if(n.eventPhase===W.All){e(r);return}gt(r.eventPhase)===n.eventPhase&&e(r)},{passive:!0}),o&&this.currentTarget.addEventListener("touchmove",o),i&&this.currentTarget.addEventListener("touchend",i)}addMouseEventListeners({onStart:e,onStartOptions:n,onMove:o,onEnd:i}){e&&this.currentTarget.addEventListener("mousedown",r=>{if(n.eventPhase===W.All){e(r);return}gt(r.eventPhase)===n.eventPhase&&e(r)},{passive:!0}),o&&this.currentTarget.addEventListener("mousemove",o),i&&this.currentTarget.addEventListener("mouseup",r=>{i(r)})}removeEventListeners({onStart:e,onMove:n,onEnd:o}){e&&this.currentTarget.removeEventListener("touchstart",e),o&&this.currentTarget.removeEventListener("touchend",o),n&&this.currentTarget.removeEventListener("touchmove",n),e&&this.currentTarget.removeEventListener("mousedown",e),n&&this.currentTarget.removeEventListener("mousemove",n),o&&this.currentTarget.removeEventListener("mouseup",o)}getCoordinates(e){if(e.type==="touchstart"||e.type==="mousedown"){if("touches"in e)return{x:e.touches[0].clientX,y:e.touches[0].clientY};if(e instanceof MouseEvent)return{x:e.clientX,y:e.clientY}}if(e.type==="touchend"||e.type==="mouseup"||e.type==="mousemove"||e.type==="touchmove"){if("touches"in e)return{x:e.changedTouches[0].clientX,y:e.changedTouches[0].clientY};if(e instanceof MouseEvent)return{x:e.clientX,y:e.clientY}}return{x:0,y:0}}}function _t(t,e){const n=$t(t);Xt(n),n.bottomSheetContainer.style.width=t.width;const o=document.createElement("div");o.innerHTML=t.content??"";const i=window.innerHeight;n.bottomSheetContainer.style.maxHeight=`${i}px`,n.bottomSheetContentWrapper.appendChild(o);const r=qt({bottomSheetElements:n,bottomSheetProps:t,options:e});return{elements:n,eventHandlers:r}}function $t(t){const e=M("dialog",R([w.Root,ot.Dialog,t.rootClass]),w.Root);e.ariaLabel=t.ariaLabel;const n=M("section",R([w.Container,t.containerClass]),w.Container);t.containerBorderRadius&&(n.style.borderRadius=t.containerBorderRadius);const o=M("div",w.GapFiller,w.GapFiller),i=M("button",R([w.Handle,ot.Button,t.shouldShowHandle?null:X.Hidden,t.handleClass]),w.Handle);i.setAttribute("type","button"),i.ariaLabel="bottom sheet close button";const r=M("span",R([w.HandleBar,t.shouldShowHandle?null:X.Hidden]),w.HandleBar),c=M("article",R([w.ContentWrapper,t.contentWrapperClass]),w.ContentWrapper),s=M("div",R([w.Backdrop,t.backdropClass,X.Hidden]),w.Backdrop);return t.backdropColor&&(s.style.backgroundColor=t.backdropColor),t.backDropTransition&&(s.style.transition=t.backDropTransition),{bottomSheetRoot:e,bottomSheetBackdrop:s,bottomSheetContainer:n,bottomSheetHandle:i,bottomSheetHandleBar:r,bottomSheetContentWrapper:c,bottomSheetContainerGapFiller:o}}function Xt({bottomSheetRoot:t,bottomSheetContainer:e,bottomSheetHandle:n,bottomSheetHandleBar:o,bottomSheetContentWrapper:i,bottomSheetContainerGapFiller:r}){t.appendChild(e),n.appendChild(o),e.appendChild(n),e.appendChild(i),e.appendChild(r)}function qt({bottomSheetElements:t,bottomSheetProps:e,options:n}){const{bottomSheetRoot:o,bottomSheetContainer:i,bottomSheetHandle:r,bottomSheetContainerGapFiller:c,bottomSheetContentWrapper:s}=t,{animationFrame:h}=n,f=new G(r),l=new G(s),b=new G(c),E=e.dragTriggers.reduce((g,A)=>{const D=o.querySelectorAll(A);if(!D.length)return g;const tt=Array.from(D).map(Y=>Y instanceof HTMLElement?new G(Y):null).filter(Y=>!!Y);return[...g,...tt]},[]),a=new G(window),L=Ft(a,i,e,n.draggingState),v=Wt(a,i,e,n.draggingState,h),S=jt(a,i,e,n.draggingState,h,n.onClose,n.bottomSheetState);function T(g){g.target instanceof Element&&!o.contains(g.target)&&n.onClose()}function C(g){Nt(n.draggingState,g.target,t.bottomSheetContentWrapper)}function P(){e.draggable&&(f.addEventListeners({onStart:C}),E.forEach(g=>{g.addEventListeners({onStart:C,onStartOptions:{eventPhase:W.Target}})})),e.draggable&&e.backgroundDraggable&&(l.addEventListeners({onStart:C,onStartOptions:{eventPhase:W.Target}}),b.addEventListeners({onStart:C})),e.draggable&&a.addEventListeners({onStart:L,onMove:v,onEnd:S}),e.draggable&&window.document.addEventListener("keyup",g=>{g.key==="Escape"&&n.onClose()}),e.shouldCloseOnOutsideClick&&window.document.addEventListener("click",T),r.addEventListener("keyup",g=>{if(g.key==="ArrowUp"){n.moveUp();return}if(g.key==="ArrowDown"){n.moveDown();return}if(g.shiftKey&&g.key==="Tab"){const A=_(t.bottomSheetContentWrapper);Mt(A)}})}function _(g){let A=[...Array.from(g.childNodes).reverse()];for(;A.length;){const D=A.shift();if(Yt(D))return D;D&&(A=[...A,...Array.from(D.childNodes).reverse()])}return null}function Z(){f.removeEventListeners({onStart:C}),l.removeEventListeners({onStart:C}),b.removeEventListeners({onStart:C}),E.forEach(g=>{g.removeEventListeners({onStart:C})}),a.removeEventListeners({onStart:L,onMove:v,onEnd:S}),window.removeEventListener("click",T)}return{attachEventListeners:P,clearEventListeners:Z}}class zt{constructor(){$(this,"animationId"),$(this,"isInProgress"),$(this,"startedAt"),this.animationId=null,this.isInProgress=!1,this.startedAt=null}start(e,n,o=!1){this.isInProgress=!0;const i=r=>{this.startedAt||(this.startedAt=r);const c=r-this.startedAt,s=n===0?1:K(c/n,2),h=s>=1&&!o;e(s),h?this.stop():this.animationId=requestAnimationFrame(i)};this.animationId=requestAnimationFrame(i)}stop(){this.isInProgress=!1,this.startedAt=null,x(this.animationId)&&cancelAnimationFrame(this.animationId)}}function Vt(t){const{startY:e,endY:n,bottomSheetContainer:o,animationFrame:i,onEnd:r,animationTimingFunction:c,animationDuration:s}=t,h=wt(e,n);i.stop();let f=!1;i.start(l=>{J(o,{y:e+h*c(l)}),!f&&l>=1&&(r==null||r(),f=!0)},s)}const at=(t,e)=>n=>{Vt({...n,animationTimingFunction:t,animationDuration:e})},F={TOP:"top",MIDDLE:"middle",CONTENT_HEIGHT:"content-height",CLOSED:"closed"};function Kt(t){return!(!x(t)||t>1||t<0)}function Jt(t,e){const n={set(o,i,r,c){return e(i,r),Reflect.set(o,i,r,c)}};return new Proxy(t,n)}function Qt(...t){console.error(t)}const N={EASE:"ease",EASE_IN:"ease-in",EASE_OUT:"ease-out",EASE_IN_OUT:"ease-in-out",SPRING:"spring"};function Zt(t){for(const e of Object.values(N))if(e===t)return!0;return!1}function kt(t){return!!(t instanceof Object&&"p1x"in t&&"p1y"in t&&"p2x"in t&&"p2y"in t&&x(t.p1x)&&x(t.p1y)&&x(t.p2x)&&x(t.p2y))}function U(t,e,n,o){return function(s){return c(i(s))};function i(s){let h=0,f=1,l=s,b;if(s===0||s===1)return s;for(;h<f;){if(b=r(l),Math.abs(b-s)<.001)return l;s>b?h=l:f=l,l=(f+h)/2}return l}function r(s){return 3*t*s*Math.pow(1-s,2)+3*n*Math.pow(s,2)*(1-s)+Math.pow(s,3)}function c(s){return 3*e*s*Math.pow(1-s,2)+3*o*Math.pow(s,2)*(1-s)+Math.pow(s,3)}}const bt=U(.25,.1,.25,1),te=U(.42,0,1,1),Lt=U(.42,0,.58,1),ee=U(.4,.1,.6,1),ne=U(.45,1.5,.55,1);function oe(t){switch(t){case N.EASE:return bt;case N.EASE_IN:return te;case N.EASE_OUT:return Lt;case N.EASE_IN_OUT:return ee;case N.SPRING:return ne;default:return bt}}function vt(t){return typeof t=="boolean"}const re={ariaLabel:"Bottom sheet",content:"",defaultPosition:F.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 ie(t){const e={...re},n=Object.entries(t).reduce((o,i)=>{const[r,c]=i;return it(c)&&(o[r]=c),o},{});return{...e,...n}}function st(t){if(kt(t)){const{p1x:e,p1y:n,p2x:o,p2y:i}=t;return U(e,n,o,i)}return Zt(t)?oe(t):Lt}function ae(t,e,n){function o(i,r){switch(i){case"content":H(r)&&(t.bottomSheetContentWrapper.innerHTML=r);break;case"width":H(r)&&(t.bottomSheetContainer.style.width=r);break;case"shouldShowHandle":vt(r)||z(t.bottomSheetHandle,!1);break;case"shouldShowBackdrop":vt(r)||z(t.bottomSheetBackdrop,!1);break;case"containerBorderRadius":H(r)&&(t.bottomSheetContainer.style.borderRadius=r);break;case"backdropColor":H(r)&&(t.bottomSheetBackdrop.style.backgroundColor=r);break;case"backDropTransition":H(r)&&(t.bottomSheetBackdrop.style.transition=r);break;case"rootClass":if(!H(r))return;j(t.bottomSheetRoot,n.rootClass,r);break;case"containerClass":if(!H(r))return;j(t.bottomSheetContainer,n.containerClass,r);break;case"handleClass":if(!H(r))return;j(t.bottomSheetHandle,n.handleClass,r);break;case"contentWrapperClass":if(!H(r))return;j(t.bottomSheetContentWrapper,n.contentWrapperClass,r);break;case"backdropClass":if(!H(r))return;j(t.bottomSheetBackdrop,n.backdropClass,r);break;case"draggingAnimationTimings":if(kt(r)){const c=st(r),s=at(c,n.draggingAnimationDuration);e.translateContainer=s}break;case"draggingAnimationDuration":if(x(r)){const c=st(n.draggingAnimationTimings),s=at(c,r);e.translateContainer=s}break}}return o}function se(t){const e=ie(t),n=st(t.draggingAnimationTimings),o={isMounted:!1,translateContainer:at(n,e.draggingAnimationDuration)},i={startY:null,containerStartTranslate:{x:0,y:0},isDragging:!1,originalDocumentOverflowY:null,originalDocumentOverscrollBehavior:null};function r(){i.originalDocumentOverflowY&&i.originalDocumentOverflowY!=="hidden"&&(document.body.style.overflowY=i.originalDocumentOverflowY),i.originalDocumentOverscrollBehavior&&(document.body.style.position=i.originalDocumentOverscrollBehavior)}const c=new zt,s={animationFrame:c,onClose:T,bottomSheetState:o,draggingState:i,snapTo:lt,moveUp:tt,moveDown:Y},{elements:h,eventHandlers:f}=_t(e,s),l=Jt(e,ae(h,o,e)),{bottomSheetBackdrop:b,bottomSheetRoot:E,bottomSheetContainer:a}=h,L=u=>{const d=u??window.document.body;d.appendChild(E),d.appendChild(b);const p=window.innerHeight;J(a,{y:p}),f.attachEventListeners(),o.isMounted=!0},v=()=>{f.clearEventListeners(),Object.values(h).forEach(u=>{u.remove()}),r(),o.isMounted=!1},S=()=>{var u;if(C()||Qt('Bottom Sheet is not mounted yet. call the "mount" method first.'),(u=t.beforeOpen)==null||u.call(t),P())return;l.shouldShowBackdrop&&et(b,!0),et([a],!0),J(a,{y:a.clientHeight});const d=window.innerHeight,p=ht(d,a.clientHeight,l.marginTop,l.defaultPosition),m=B(a).y;o.translateContainer({startY:m,endY:p,animationFrame:c,bottomSheetContainer:a,onEnd:t.afterOpen}),h.bottomSheetHandle.focus();const y=document.body.style.overflowY;i.originalDocumentOverflowY=y||"initial";const O=document.body.style.overscrollBehavior;i.originalDocumentOverscrollBehavior=O||"initial",document.body.style.overflow="hidden",document.body.style.overscrollBehavior="contain"};function T(){var u;if(_())return;(u=t.beforeClose)==null||u.call(t);const d=B(a).y,p=a.clientHeight;o.translateContainer({startY:d,endY:p,animationFrame:c,bottomSheetContainer:a,onEnd:()=>{var m;(m=t.afterClose)==null||m.call(t),et([b,a],!1)}}),r()}function C(){return o.isMounted}function P(){const u=B(a).y,d=window.innerHeight,p=a.clientHeight>=d?d:a.clientHeight;return u<p}function _(){return!P()}function Z(){const u=B(a).y,d=a.clientHeight,p=window.innerHeight;if(u<=5&&u>=-5)return F.CONTENT_HEIGHT;const m=d-u;if(m===p/2)return F.MIDDLE;const y=p-l.marginTop,O=10;return m<=y+O&&m>=y-O?F.TOP:F.CLOSED}function g(){return a.clientHeight}function A(u){if(!P())return;const d=B(a).y,p=a.clientHeight-d,m=window.innerHeight-u,y=It(p,m),O=V(p,m);o.translateContainer({startY:d,endY:d+(y.isUp?-O:O),animationFrame:c,bottomSheetContainer:a})}function D(u,{viewportHeight:d,visibleHeight:p}){let m=null;for(const y of u){const O=y*d,I=V(p,O);(m===null||I<m)&&(m=I)}return{minOffset:m}}function tt(){const u=[...l.snapPoints].reverse(),d=B(a).y,p=a.clientHeight,m=p-d;if(!l.expandable&&m>=p)return;const y=window.innerHeight,O=pt("above",{visibleHeight:m,viewportHeight:y},u),{minOffset:I}=D(O,{visibleHeight:m,viewportHeight:y});if(I===null&&m<y-l.marginTop){o.translateContainer({startY:d,endY:ht(y,p,l.marginTop,"top"),animationFrame:c,bottomSheetContainer:a});return}x(I)&&o.translateContainer({startY:d,endY:d-I,animationFrame:c,bottomSheetContainer:a})}function Y(){const u=B(a).y,d=a.clientHeight-u;if(d<1)return;const p=window.innerHeight,m=pt("below",{visibleHeight:d,viewportHeight:p},l.snapPoints),{minOffset:y}=D(m,{visibleHeight:d,viewportHeight:p});x(y)&&o.translateContainer({startY:u,endY:u+y,animationFrame:c,bottomSheetContainer:a})}function lt(u){const d=window.innerHeight;if(!Kt(u))return;const p=K(d*u,2);A(p)}return{props:l,elements:h,mount:L,unmount:v,open:S,close:T,getIsMounted:C,getIsOpen:P,getIsClosed:_,getPosition:Z,getHeight:g,moveTo:A,snapTo:lt}}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:()=>F.CLOSED,moveTo:()=>{},snapTo:()=>{},props:{content:""}}}const ce=ct(),le=k.forwardRef(function(e,n){const{children:o,isOpen:i,setIsOpen:r,afterClose:c,mountingPoint:s,...h}=e,f=k.useRef(ce),[l,b]=k.useState(f.current);k.useImperativeHandle(n,()=>l,[l]);const E=k.useCallback(()=>{r(!1),c==null||c()},[c]);k.useEffect(()=>{i?l.open():l.close()},[i]);const a=k.useRef(null);return k.useEffect(function(){const v=At(e.mountingPoint)?e.mountingPoint:window.document.body;if(!v||l.getIsMounted())return;const S=se({content:"",...h,afterClose:E});return S.mount(v),a.current=S.elements.bottomSheetContentWrapper??null,f.current=S,b(S),()=>{l.unmount()}},[e.mountingPoint,h,E]),k.useEffect(function(){Object.assign(f.current.props,{...h}),b(f.current)},[h]),a.current?xt.createPortal(e.children,a.current):null}),ue=ct();function de(){const t=k.useRef(ue),[e,n]=k.useState(!1),[o,i]=k.useState(t.current);return k.useEffect(()=>{i(t.current)},[t.current]),{props:k.useMemo(()=>({ref:t,isOpen:e,setIsOpen:n}),[e]),instance:o}}exports.BottomSheet=le;exports.createPlaceholderBottomSheet=ct;exports.useBottomSheet=de;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { forwardRef as Ot, useRef as nt, useState as ot, useImperativeHandle as Dt, useCallback as
|
|
1
|
+
import { forwardRef as Ot, useRef as nt, useState as ot, useImperativeHandle as Dt, useCallback as Bt, useEffect as _, useMemo as Pt } from "react";
|
|
2
2
|
import { createPortal as Mt } from "react-dom";
|
|
3
|
-
function
|
|
3
|
+
function Yt(t) {
|
|
4
4
|
return t != null;
|
|
5
5
|
}
|
|
6
6
|
(function() {
|
|
@@ -14,7 +14,7 @@ function Bt(t) {
|
|
|
14
14
|
}
|
|
15
15
|
})();
|
|
16
16
|
var It = Object.defineProperty, Nt = (t, e, n) => e in t ? It(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n, $ = (t, e, n) => Nt(t, typeof e != "symbol" ? e + "" : e, n);
|
|
17
|
-
function
|
|
17
|
+
function H(t) {
|
|
18
18
|
return typeof t == "string";
|
|
19
19
|
}
|
|
20
20
|
function Rt(t, e) {
|
|
@@ -27,10 +27,10 @@ function rt(t, e) {
|
|
|
27
27
|
t.classList.remove(Q(e));
|
|
28
28
|
}
|
|
29
29
|
function U(t, e, n) {
|
|
30
|
-
|
|
30
|
+
H(n) && (H(e) && rt(t, e), q(t, n));
|
|
31
31
|
}
|
|
32
32
|
function Q(t) {
|
|
33
|
-
return
|
|
33
|
+
return H(t) ? t.trim().replace(/\./g, "") : "";
|
|
34
34
|
}
|
|
35
35
|
function I(t) {
|
|
36
36
|
return t.map((e) => Q(e)).filter(Boolean).join(" ");
|
|
@@ -55,7 +55,7 @@ function z(t, e) {
|
|
|
55
55
|
function Ct(t) {
|
|
56
56
|
return t instanceof HTMLElement;
|
|
57
57
|
}
|
|
58
|
-
function
|
|
58
|
+
function L(t) {
|
|
59
59
|
return typeof t == "number" && !Number.isNaN(t);
|
|
60
60
|
}
|
|
61
61
|
function Wt(t) {
|
|
@@ -64,7 +64,7 @@ function Wt(t) {
|
|
|
64
64
|
function Ut(t) {
|
|
65
65
|
if (!Ct(t) || t.offsetParent === null || "disabled" in t && t.disabled)
|
|
66
66
|
return !1;
|
|
67
|
-
const e = t.getAttribute("tabindex"), n =
|
|
67
|
+
const e = t.getAttribute("tabindex"), n = L(e) ? parseInt(e, 10) : -1, o = [
|
|
68
68
|
"INPUT",
|
|
69
69
|
"BUTTON",
|
|
70
70
|
"SELECT",
|
|
@@ -76,11 +76,11 @@ function Ut(t) {
|
|
|
76
76
|
return o || i || n > -1;
|
|
77
77
|
}
|
|
78
78
|
var w = /* @__PURE__ */ ((t) => (t.Backdrop = "pbs-backdrop", t.Root = "pbs-root", t.Container = "pbs-container", t.GapFiller = "pbs-gap-filler", t.Handle = "pbs-handle", t.HandleBar = "pbs-handle-bar", t.ContentWrapper = "pbs-content-wrapper", t))(w || {}), it = /* @__PURE__ */ ((t) => (t.Button = "pbs-button-reset", t.Dialog = "pbs-dialog-reset", t))(it || {}), X = /* @__PURE__ */ ((t) => (t.Hidden = "hidden", t))(X || {});
|
|
79
|
-
function
|
|
79
|
+
function P(t, e, n) {
|
|
80
80
|
const o = document.createElement(t);
|
|
81
81
|
return e.split(" ").forEach((i) => {
|
|
82
82
|
q(o, i);
|
|
83
|
-
}),
|
|
83
|
+
}), H(n) && o.setAttribute("data-testid", n), o;
|
|
84
84
|
}
|
|
85
85
|
Ft([
|
|
86
86
|
w.Root,
|
|
@@ -136,7 +136,7 @@ function ft(t) {
|
|
|
136
136
|
function K(t, ...e) {
|
|
137
137
|
return Number(t.toFixed(...e));
|
|
138
138
|
}
|
|
139
|
-
function
|
|
139
|
+
function Tt(t) {
|
|
140
140
|
const e = /(?<type>\w+)\((?<values>[^)]+)\)/g, n = [];
|
|
141
141
|
let o;
|
|
142
142
|
for (; (o = e.exec(t)) !== null; ) {
|
|
@@ -146,17 +146,17 @@ function Ht(t) {
|
|
|
146
146
|
return n;
|
|
147
147
|
}
|
|
148
148
|
function Gt(t) {
|
|
149
|
-
const e = t.style.transform, n =
|
|
149
|
+
const e = t.style.transform, n = Tt(e);
|
|
150
150
|
return { transform: e, transformValues: n };
|
|
151
151
|
}
|
|
152
|
-
function
|
|
152
|
+
function Ht(t, e) {
|
|
153
153
|
return t.find(
|
|
154
154
|
(o) => o.type.startsWith(e)
|
|
155
155
|
) || null;
|
|
156
156
|
}
|
|
157
157
|
const at = "translate";
|
|
158
158
|
function D(t) {
|
|
159
|
-
const e = t.style.transform, n =
|
|
159
|
+
const e = t.style.transform, n = Tt(e), o = Ht(
|
|
160
160
|
n,
|
|
161
161
|
at
|
|
162
162
|
);
|
|
@@ -169,7 +169,7 @@ function J(t, { x: e, y: n }) {
|
|
|
169
169
|
const {
|
|
170
170
|
transform: o,
|
|
171
171
|
transformValues: i
|
|
172
|
-
} = Gt(t), r =
|
|
172
|
+
} = Gt(t), r = Ht(
|
|
173
173
|
i,
|
|
174
174
|
at
|
|
175
175
|
);
|
|
@@ -220,7 +220,7 @@ const _t = (t, e, n) => {
|
|
|
220
220
|
);
|
|
221
221
|
};
|
|
222
222
|
function qt(t, e, n, o, i, r, c) {
|
|
223
|
-
if (!o.isDragging || !
|
|
223
|
+
if (!o.isDragging || !L(o.startY))
|
|
224
224
|
return;
|
|
225
225
|
const s = e.getCoordinates(t).y, p = yt(o.startY, s), f = window.innerHeight, l = r.clientHeight, b = l - (o.containerStartTranslate.y + p);
|
|
226
226
|
if (b >= f)
|
|
@@ -235,14 +235,14 @@ function qt(t, e, n, o, i, r, c) {
|
|
|
235
235
|
}, 0);
|
|
236
236
|
const a = f - c, k = l - o.containerStartTranslate.y;
|
|
237
237
|
if (E.isUp) {
|
|
238
|
-
const v = a - k, S = a - b,
|
|
238
|
+
const v = a - k, S = a - b, T = gt(
|
|
239
239
|
1 - K(S / v, 2),
|
|
240
240
|
{
|
|
241
241
|
min: 0,
|
|
242
242
|
max: 1
|
|
243
243
|
}
|
|
244
244
|
);
|
|
245
|
-
n.onDragMove(E,
|
|
245
|
+
n.onDragMove(E, T);
|
|
246
246
|
} else if (E.isDown) {
|
|
247
247
|
const v = gt(
|
|
248
248
|
K(
|
|
@@ -258,26 +258,26 @@ function qt(t, e, n, o, i, r, c) {
|
|
|
258
258
|
}
|
|
259
259
|
}
|
|
260
260
|
const zt = (t, e, n, o, i, r, c) => (s) => {
|
|
261
|
-
if (!o.isDragging || (o.isDragging = !1, !
|
|
261
|
+
if (!o.isDragging || (o.isDragging = !1, !L(o.startY)))
|
|
262
262
|
return;
|
|
263
263
|
n.onDragEnd();
|
|
264
264
|
const p = o.startY, f = t.getCoordinates(s).y, l = D(e).y, b = wt(p, f), E = window.innerHeight, a = e.clientHeight;
|
|
265
265
|
if (b.isUp) {
|
|
266
266
|
const k = [...n.snapPoints].sort(
|
|
267
|
-
(
|
|
267
|
+
(T, C) => T - C
|
|
268
268
|
), v = a + -l;
|
|
269
269
|
if (!n.expandable && v >= a)
|
|
270
270
|
return;
|
|
271
|
-
for (const
|
|
272
|
-
const C =
|
|
271
|
+
for (const T of k) {
|
|
272
|
+
const C = T * window.innerHeight;
|
|
273
273
|
if (v <= C) {
|
|
274
|
-
const
|
|
274
|
+
const B = V(
|
|
275
275
|
v,
|
|
276
276
|
C
|
|
277
277
|
);
|
|
278
278
|
c.translateContainer({
|
|
279
279
|
startY: l,
|
|
280
|
-
endY: l -
|
|
280
|
+
endY: l - B,
|
|
281
281
|
animationFrame: i,
|
|
282
282
|
bottomSheetContainer: e
|
|
283
283
|
});
|
|
@@ -300,10 +300,10 @@ const zt = (t, e, n, o, i, r, c) => (s) => {
|
|
|
300
300
|
(v, S) => S - v
|
|
301
301
|
);
|
|
302
302
|
for (const v of k) {
|
|
303
|
-
const S = v * window.innerHeight,
|
|
304
|
-
if (
|
|
303
|
+
const S = v * window.innerHeight, T = a + -l;
|
|
304
|
+
if (T >= S) {
|
|
305
305
|
const C = V(
|
|
306
|
-
|
|
306
|
+
T,
|
|
307
307
|
S
|
|
308
308
|
);
|
|
309
309
|
c.translateContainer({
|
|
@@ -443,7 +443,7 @@ function Kt(t, e) {
|
|
|
443
443
|
return { elements: n, eventHandlers: r };
|
|
444
444
|
}
|
|
445
445
|
function Jt(t) {
|
|
446
|
-
const e =
|
|
446
|
+
const e = P(
|
|
447
447
|
"dialog",
|
|
448
448
|
I([
|
|
449
449
|
w.Root,
|
|
@@ -453,17 +453,17 @@ function Jt(t) {
|
|
|
453
453
|
w.Root
|
|
454
454
|
);
|
|
455
455
|
e.ariaLabel = t.ariaLabel;
|
|
456
|
-
const n =
|
|
456
|
+
const n = P(
|
|
457
457
|
"section",
|
|
458
458
|
I([w.Container, t.containerClass]),
|
|
459
459
|
w.Container
|
|
460
460
|
);
|
|
461
461
|
t.containerBorderRadius && (n.style.borderRadius = t.containerBorderRadius);
|
|
462
|
-
const o =
|
|
462
|
+
const o = P(
|
|
463
463
|
"div",
|
|
464
464
|
w.GapFiller,
|
|
465
465
|
w.GapFiller
|
|
466
|
-
), i =
|
|
466
|
+
), i = P(
|
|
467
467
|
"button",
|
|
468
468
|
I([
|
|
469
469
|
w.Handle,
|
|
@@ -474,21 +474,21 @@ function Jt(t) {
|
|
|
474
474
|
w.Handle
|
|
475
475
|
);
|
|
476
476
|
i.setAttribute("type", "button"), i.ariaLabel = "bottom sheet close button";
|
|
477
|
-
const r =
|
|
477
|
+
const r = P(
|
|
478
478
|
"span",
|
|
479
479
|
I([
|
|
480
480
|
w.HandleBar,
|
|
481
481
|
t.shouldShowHandle ? null : X.Hidden
|
|
482
482
|
]),
|
|
483
483
|
w.HandleBar
|
|
484
|
-
), c =
|
|
484
|
+
), c = P(
|
|
485
485
|
"article",
|
|
486
486
|
I([
|
|
487
487
|
w.ContentWrapper,
|
|
488
488
|
t.contentWrapperClass
|
|
489
489
|
]),
|
|
490
490
|
w.ContentWrapper
|
|
491
|
-
), s =
|
|
491
|
+
), s = P(
|
|
492
492
|
"div",
|
|
493
493
|
I([
|
|
494
494
|
w.Backdrop,
|
|
@@ -533,11 +533,11 @@ function Zt({
|
|
|
533
533
|
), b = new j(
|
|
534
534
|
c
|
|
535
535
|
), E = e.dragTriggers.reduce(
|
|
536
|
-
(g,
|
|
537
|
-
const
|
|
538
|
-
if (!
|
|
536
|
+
(g, x) => {
|
|
537
|
+
const O = o.querySelectorAll(x);
|
|
538
|
+
if (!O.length)
|
|
539
539
|
return g;
|
|
540
|
-
const tt = Array.from(
|
|
540
|
+
const tt = Array.from(O).map((M) => M instanceof HTMLElement ? new j(M) : null).filter((M) => !!M);
|
|
541
541
|
return [...g, ...tt];
|
|
542
542
|
},
|
|
543
543
|
[]
|
|
@@ -563,7 +563,7 @@ function Zt({
|
|
|
563
563
|
n.onClose,
|
|
564
564
|
n.bottomSheetState
|
|
565
565
|
);
|
|
566
|
-
function
|
|
566
|
+
function T(g) {
|
|
567
567
|
g.target instanceof Element && !o.contains(g.target) && n.onClose();
|
|
568
568
|
}
|
|
569
569
|
function C(g) {
|
|
@@ -573,7 +573,7 @@ function Zt({
|
|
|
573
573
|
t.bottomSheetContentWrapper
|
|
574
574
|
);
|
|
575
575
|
}
|
|
576
|
-
function
|
|
576
|
+
function B() {
|
|
577
577
|
e.draggable && (f.addEventListeners({
|
|
578
578
|
onStart: C
|
|
579
579
|
}), E.forEach((g) => {
|
|
@@ -596,7 +596,7 @@ function Zt({
|
|
|
596
596
|
onEnd: S
|
|
597
597
|
}), e.draggable && window.document.addEventListener("keyup", (g) => {
|
|
598
598
|
g.key === "Escape" && n.onClose();
|
|
599
|
-
}), e.shouldCloseOnOutsideClick && window.document.addEventListener("click",
|
|
599
|
+
}), e.shouldCloseOnOutsideClick && window.document.addEventListener("click", T), r.addEventListener("keyup", (g) => {
|
|
600
600
|
if (g.key === "ArrowUp") {
|
|
601
601
|
n.moveUp();
|
|
602
602
|
return;
|
|
@@ -606,22 +606,22 @@ function Zt({
|
|
|
606
606
|
return;
|
|
607
607
|
}
|
|
608
608
|
if (g.shiftKey && g.key === "Tab") {
|
|
609
|
-
const
|
|
609
|
+
const x = G(
|
|
610
610
|
t.bottomSheetContentWrapper
|
|
611
611
|
);
|
|
612
|
-
Wt(
|
|
612
|
+
Wt(x);
|
|
613
613
|
}
|
|
614
614
|
});
|
|
615
615
|
}
|
|
616
616
|
function G(g) {
|
|
617
|
-
let
|
|
618
|
-
for (;
|
|
619
|
-
const
|
|
620
|
-
if (Ut(
|
|
621
|
-
return
|
|
622
|
-
|
|
623
|
-
...
|
|
624
|
-
...Array.from(
|
|
617
|
+
let x = [...Array.from(g.childNodes).reverse()];
|
|
618
|
+
for (; x.length; ) {
|
|
619
|
+
const O = x.shift();
|
|
620
|
+
if (Ut(O))
|
|
621
|
+
return O;
|
|
622
|
+
O && (x = [
|
|
623
|
+
...x,
|
|
624
|
+
...Array.from(O.childNodes).reverse()
|
|
625
625
|
]);
|
|
626
626
|
}
|
|
627
627
|
return null;
|
|
@@ -641,10 +641,10 @@ function Zt({
|
|
|
641
641
|
onStart: k,
|
|
642
642
|
onMove: v,
|
|
643
643
|
onEnd: S
|
|
644
|
-
}), window.removeEventListener("click",
|
|
644
|
+
}), window.removeEventListener("click", T);
|
|
645
645
|
}
|
|
646
646
|
return {
|
|
647
|
-
attachEventListeners:
|
|
647
|
+
attachEventListeners: B,
|
|
648
648
|
clearEventListeners: Z
|
|
649
649
|
};
|
|
650
650
|
}
|
|
@@ -667,7 +667,7 @@ class te {
|
|
|
667
667
|
this.animationId = requestAnimationFrame(i);
|
|
668
668
|
}
|
|
669
669
|
stop() {
|
|
670
|
-
this.isInProgress = !1, this.startedAt = null,
|
|
670
|
+
this.isInProgress = !1, this.startedAt = null, L(this.animationId) && cancelAnimationFrame(this.animationId);
|
|
671
671
|
}
|
|
672
672
|
}
|
|
673
673
|
function ee(t) {
|
|
@@ -701,7 +701,7 @@ const ct = (t, e) => (n) => {
|
|
|
701
701
|
CLOSED: "closed"
|
|
702
702
|
};
|
|
703
703
|
function ne(t) {
|
|
704
|
-
return !(!
|
|
704
|
+
return !(!L(t) || t > 1 || t < 0);
|
|
705
705
|
}
|
|
706
706
|
function oe(t, e) {
|
|
707
707
|
const n = {
|
|
@@ -727,8 +727,8 @@ function ie(t) {
|
|
|
727
727
|
return !0;
|
|
728
728
|
return !1;
|
|
729
729
|
}
|
|
730
|
-
function
|
|
731
|
-
return !!(t instanceof Object && "p1x" in t && "p1y" in t && "p2x" in t && "p2y" in t &&
|
|
730
|
+
function Lt(t) {
|
|
731
|
+
return !!(t instanceof Object && "p1x" in t && "p1y" in t && "p2x" in t && "p2y" in t && L(t.p1x) && L(t.p1y) && L(t.p2x) && L(t.p2y));
|
|
732
732
|
}
|
|
733
733
|
function W(t, e, n, o) {
|
|
734
734
|
return function(s) {
|
|
@@ -752,17 +752,17 @@ function W(t, e, n, o) {
|
|
|
752
752
|
return 3 * e * s * Math.pow(1 - s, 2) + 3 * o * Math.pow(s, 2) * (1 - s) + Math.pow(s, 3);
|
|
753
753
|
}
|
|
754
754
|
}
|
|
755
|
-
const
|
|
755
|
+
const vt = W(0.25, 0.1, 0.25, 1), ae = W(0.42, 0, 1, 1), xt = W(0.42, 0, 0.58, 1), se = W(0.4, 0.1, 0.6, 1), ce = W(0.45, 1.5, 0.55, 1);
|
|
756
756
|
function le(t) {
|
|
757
757
|
switch (t) {
|
|
758
758
|
case N.EASE:
|
|
759
|
-
return
|
|
759
|
+
return vt;
|
|
760
760
|
case N.EASE_IN:
|
|
761
|
-
return
|
|
761
|
+
return ae;
|
|
762
762
|
case N.EASE_OUT:
|
|
763
|
-
return
|
|
763
|
+
return xt;
|
|
764
764
|
case N.EASE_IN_OUT:
|
|
765
|
-
return
|
|
765
|
+
return se;
|
|
766
766
|
case N.SPRING:
|
|
767
767
|
return ce;
|
|
768
768
|
default:
|
|
@@ -827,20 +827,20 @@ function de(t) {
|
|
|
827
827
|
};
|
|
828
828
|
}
|
|
829
829
|
function lt(t) {
|
|
830
|
-
if (
|
|
830
|
+
if (Lt(t)) {
|
|
831
831
|
const { p1x: e, p1y: n, p2x: o, p2y: i } = t;
|
|
832
832
|
return W(e, n, o, i);
|
|
833
833
|
}
|
|
834
|
-
return ie(t) ? le(t) :
|
|
834
|
+
return ie(t) ? le(t) : xt;
|
|
835
835
|
}
|
|
836
836
|
function pe(t, e, n) {
|
|
837
837
|
function o(i, r) {
|
|
838
838
|
switch (i) {
|
|
839
839
|
case "content":
|
|
840
|
-
|
|
840
|
+
H(r) && (t.bottomSheetContentWrapper.innerHTML = r);
|
|
841
841
|
break;
|
|
842
842
|
case "width":
|
|
843
|
-
|
|
843
|
+
H(r) && (t.bottomSheetContainer.style.width = r);
|
|
844
844
|
break;
|
|
845
845
|
case "shouldShowHandle":
|
|
846
846
|
St(r) || z(t.bottomSheetHandle, !1);
|
|
@@ -849,16 +849,16 @@ function pe(t, e, n) {
|
|
|
849
849
|
St(r) || z(t.bottomSheetBackdrop, !1);
|
|
850
850
|
break;
|
|
851
851
|
case "containerBorderRadius":
|
|
852
|
-
|
|
852
|
+
H(r) && (t.bottomSheetContainer.style.borderRadius = r);
|
|
853
853
|
break;
|
|
854
854
|
case "backdropColor":
|
|
855
|
-
|
|
855
|
+
H(r) && (t.bottomSheetBackdrop.style.backgroundColor = r);
|
|
856
856
|
break;
|
|
857
857
|
case "backDropTransition":
|
|
858
|
-
|
|
858
|
+
H(r) && (t.bottomSheetBackdrop.style.transition = r);
|
|
859
859
|
break;
|
|
860
860
|
case "rootClass":
|
|
861
|
-
if (!
|
|
861
|
+
if (!H(r))
|
|
862
862
|
return;
|
|
863
863
|
U(
|
|
864
864
|
t.bottomSheetRoot,
|
|
@@ -867,7 +867,7 @@ function pe(t, e, n) {
|
|
|
867
867
|
);
|
|
868
868
|
break;
|
|
869
869
|
case "containerClass":
|
|
870
|
-
if (!
|
|
870
|
+
if (!H(r))
|
|
871
871
|
return;
|
|
872
872
|
U(
|
|
873
873
|
t.bottomSheetContainer,
|
|
@@ -876,7 +876,7 @@ function pe(t, e, n) {
|
|
|
876
876
|
);
|
|
877
877
|
break;
|
|
878
878
|
case "handleClass":
|
|
879
|
-
if (!
|
|
879
|
+
if (!H(r))
|
|
880
880
|
return;
|
|
881
881
|
U(
|
|
882
882
|
t.bottomSheetHandle,
|
|
@@ -885,7 +885,7 @@ function pe(t, e, n) {
|
|
|
885
885
|
);
|
|
886
886
|
break;
|
|
887
887
|
case "contentWrapperClass":
|
|
888
|
-
if (!
|
|
888
|
+
if (!H(r))
|
|
889
889
|
return;
|
|
890
890
|
U(
|
|
891
891
|
t.bottomSheetContentWrapper,
|
|
@@ -894,7 +894,7 @@ function pe(t, e, n) {
|
|
|
894
894
|
);
|
|
895
895
|
break;
|
|
896
896
|
case "backdropClass":
|
|
897
|
-
if (!
|
|
897
|
+
if (!H(r))
|
|
898
898
|
return;
|
|
899
899
|
U(
|
|
900
900
|
t.bottomSheetBackdrop,
|
|
@@ -903,7 +903,7 @@ function pe(t, e, n) {
|
|
|
903
903
|
);
|
|
904
904
|
break;
|
|
905
905
|
case "draggingAnimationTimings":
|
|
906
|
-
if (
|
|
906
|
+
if (Lt(r)) {
|
|
907
907
|
const c = lt(r), s = ct(
|
|
908
908
|
c,
|
|
909
909
|
n.draggingAnimationDuration
|
|
@@ -912,7 +912,7 @@ function pe(t, e, n) {
|
|
|
912
912
|
}
|
|
913
913
|
break;
|
|
914
914
|
case "draggingAnimationDuration":
|
|
915
|
-
if (
|
|
915
|
+
if (L(r)) {
|
|
916
916
|
const c = lt(
|
|
917
917
|
n.draggingAnimationTimings
|
|
918
918
|
), s = ct(
|
|
@@ -942,14 +942,15 @@ function he(t) {
|
|
|
942
942
|
y: 0
|
|
943
943
|
},
|
|
944
944
|
isDragging: !1,
|
|
945
|
-
originalDocumentOverflowY: null
|
|
945
|
+
originalDocumentOverflowY: null,
|
|
946
|
+
originalDocumentOverscrollBehavior: null
|
|
946
947
|
};
|
|
947
948
|
function r() {
|
|
948
|
-
i.originalDocumentOverflowY && i.originalDocumentOverflowY !== "hidden" && (document.body.style.overflowY = i.originalDocumentOverflowY);
|
|
949
|
+
i.originalDocumentOverflowY && i.originalDocumentOverflowY !== "hidden" && (document.body.style.overflowY = i.originalDocumentOverflowY), i.originalDocumentOverscrollBehavior && (document.body.style.position = i.originalDocumentOverscrollBehavior);
|
|
949
950
|
}
|
|
950
951
|
const c = new te(), s = {
|
|
951
952
|
animationFrame: c,
|
|
952
|
-
onClose:
|
|
953
|
+
onClose: T,
|
|
953
954
|
bottomSheetState: o,
|
|
954
955
|
draggingState: i,
|
|
955
956
|
snapTo: ut,
|
|
@@ -976,7 +977,7 @@ function he(t) {
|
|
|
976
977
|
var u;
|
|
977
978
|
if (C() || re(
|
|
978
979
|
'Bottom Sheet is not mounted yet. call the "mount" method first.'
|
|
979
|
-
), (u = t.beforeOpen) == null || u.call(t),
|
|
980
|
+
), (u = t.beforeOpen) == null || u.call(t), B())
|
|
980
981
|
return;
|
|
981
982
|
l.shouldShowBackdrop && et(b, !0), et([a], !0), J(a, {
|
|
982
983
|
y: a.clientHeight
|
|
@@ -995,9 +996,11 @@ function he(t) {
|
|
|
995
996
|
onEnd: t.afterOpen
|
|
996
997
|
}), p.bottomSheetHandle.focus();
|
|
997
998
|
const y = document.body.style.overflowY;
|
|
998
|
-
i.originalDocumentOverflowY = y || "initial"
|
|
999
|
+
i.originalDocumentOverflowY = y || "initial";
|
|
1000
|
+
const A = document.body.style.overscrollBehavior;
|
|
1001
|
+
i.originalDocumentOverscrollBehavior = A || "initial", document.body.style.overflow = "hidden", document.body.style.overscrollBehavior = "contain";
|
|
999
1002
|
};
|
|
1000
|
-
function
|
|
1003
|
+
function T() {
|
|
1001
1004
|
var u;
|
|
1002
1005
|
if (G())
|
|
1003
1006
|
return;
|
|
@@ -1017,12 +1020,12 @@ function he(t) {
|
|
|
1017
1020
|
function C() {
|
|
1018
1021
|
return o.isMounted;
|
|
1019
1022
|
}
|
|
1020
|
-
function
|
|
1023
|
+
function B() {
|
|
1021
1024
|
const u = D(a).y, d = window.innerHeight, h = a.clientHeight >= d ? d : a.clientHeight;
|
|
1022
1025
|
return u < h;
|
|
1023
1026
|
}
|
|
1024
1027
|
function G() {
|
|
1025
|
-
return !
|
|
1028
|
+
return !B();
|
|
1026
1029
|
}
|
|
1027
1030
|
function Z() {
|
|
1028
1031
|
const u = D(a).y, d = a.clientHeight, h = window.innerHeight;
|
|
@@ -1031,34 +1034,34 @@ function he(t) {
|
|
|
1031
1034
|
const m = d - u;
|
|
1032
1035
|
if (m === h / 2)
|
|
1033
1036
|
return R.MIDDLE;
|
|
1034
|
-
const y = h - l.marginTop,
|
|
1035
|
-
return m <= y +
|
|
1037
|
+
const y = h - l.marginTop, A = 10;
|
|
1038
|
+
return m <= y + A && m >= y - A ? R.TOP : R.CLOSED;
|
|
1036
1039
|
}
|
|
1037
1040
|
function g() {
|
|
1038
1041
|
return a.clientHeight;
|
|
1039
1042
|
}
|
|
1040
|
-
function
|
|
1041
|
-
if (!
|
|
1043
|
+
function x(u) {
|
|
1044
|
+
if (!B())
|
|
1042
1045
|
return;
|
|
1043
|
-
const d = D(a).y, h = a.clientHeight - d, m = window.innerHeight - u, y = jt(h, m),
|
|
1046
|
+
const d = D(a).y, h = a.clientHeight - d, m = window.innerHeight - u, y = jt(h, m), A = V(h, m);
|
|
1044
1047
|
o.translateContainer({
|
|
1045
1048
|
startY: d,
|
|
1046
|
-
endY: d + (y.isUp ? -
|
|
1049
|
+
endY: d + (y.isUp ? -A : A),
|
|
1047
1050
|
animationFrame: c,
|
|
1048
1051
|
bottomSheetContainer: a
|
|
1049
1052
|
});
|
|
1050
1053
|
}
|
|
1051
|
-
function
|
|
1054
|
+
function O(u, {
|
|
1052
1055
|
viewportHeight: d,
|
|
1053
1056
|
visibleHeight: h
|
|
1054
1057
|
}) {
|
|
1055
1058
|
let m = null;
|
|
1056
1059
|
for (const y of u) {
|
|
1057
|
-
const
|
|
1060
|
+
const A = y * d, Y = V(
|
|
1058
1061
|
h,
|
|
1059
|
-
|
|
1062
|
+
A
|
|
1060
1063
|
);
|
|
1061
|
-
(m === null ||
|
|
1064
|
+
(m === null || Y < m) && (m = Y);
|
|
1062
1065
|
}
|
|
1063
1066
|
return {
|
|
1064
1067
|
minOffset: m
|
|
@@ -1068,15 +1071,15 @@ function he(t) {
|
|
|
1068
1071
|
const u = [...l.snapPoints].reverse(), d = D(a).y, h = a.clientHeight, m = h - d;
|
|
1069
1072
|
if (!l.expandable && m >= h)
|
|
1070
1073
|
return;
|
|
1071
|
-
const y = window.innerHeight,
|
|
1074
|
+
const y = window.innerHeight, A = mt(
|
|
1072
1075
|
"above",
|
|
1073
1076
|
{ visibleHeight: m, viewportHeight: y },
|
|
1074
1077
|
u
|
|
1075
|
-
), { minOffset:
|
|
1078
|
+
), { minOffset: Y } = O(A, {
|
|
1076
1079
|
visibleHeight: m,
|
|
1077
1080
|
viewportHeight: y
|
|
1078
1081
|
});
|
|
1079
|
-
if (
|
|
1082
|
+
if (Y === null && m < y - l.marginTop) {
|
|
1080
1083
|
o.translateContainer({
|
|
1081
1084
|
startY: d,
|
|
1082
1085
|
endY: ht(
|
|
@@ -1090,9 +1093,9 @@ function he(t) {
|
|
|
1090
1093
|
});
|
|
1091
1094
|
return;
|
|
1092
1095
|
}
|
|
1093
|
-
|
|
1096
|
+
L(Y) && o.translateContainer({
|
|
1094
1097
|
startY: d,
|
|
1095
|
-
endY: d -
|
|
1098
|
+
endY: d - Y,
|
|
1096
1099
|
animationFrame: c,
|
|
1097
1100
|
bottomSheetContainer: a
|
|
1098
1101
|
});
|
|
@@ -1105,11 +1108,11 @@ function he(t) {
|
|
|
1105
1108
|
"below",
|
|
1106
1109
|
{ visibleHeight: d, viewportHeight: h },
|
|
1107
1110
|
l.snapPoints
|
|
1108
|
-
), { minOffset: y } =
|
|
1111
|
+
), { minOffset: y } = O(m, {
|
|
1109
1112
|
visibleHeight: d,
|
|
1110
1113
|
viewportHeight: h
|
|
1111
1114
|
});
|
|
1112
|
-
|
|
1115
|
+
L(y) && o.translateContainer({
|
|
1113
1116
|
startY: u,
|
|
1114
1117
|
endY: u + y,
|
|
1115
1118
|
animationFrame: c,
|
|
@@ -1121,7 +1124,7 @@ function he(t) {
|
|
|
1121
1124
|
if (!ne(u))
|
|
1122
1125
|
return;
|
|
1123
1126
|
const h = K(d * u, 2);
|
|
1124
|
-
|
|
1127
|
+
x(h);
|
|
1125
1128
|
}
|
|
1126
1129
|
return {
|
|
1127
1130
|
props: l,
|
|
@@ -1129,17 +1132,17 @@ function he(t) {
|
|
|
1129
1132
|
mount: k,
|
|
1130
1133
|
unmount: v,
|
|
1131
1134
|
open: S,
|
|
1132
|
-
close:
|
|
1135
|
+
close: T,
|
|
1133
1136
|
getIsMounted: C,
|
|
1134
|
-
getIsOpen:
|
|
1137
|
+
getIsOpen: B,
|
|
1135
1138
|
getIsClosed: G,
|
|
1136
1139
|
getPosition: Z,
|
|
1137
1140
|
getHeight: g,
|
|
1138
|
-
moveTo:
|
|
1141
|
+
moveTo: x,
|
|
1139
1142
|
snapTo: ut
|
|
1140
1143
|
};
|
|
1141
1144
|
}
|
|
1142
|
-
function
|
|
1145
|
+
function At() {
|
|
1143
1146
|
return {
|
|
1144
1147
|
elements: {
|
|
1145
1148
|
bottomSheetRoot: void 0,
|
|
@@ -1172,7 +1175,7 @@ function Lt() {
|
|
|
1172
1175
|
}
|
|
1173
1176
|
};
|
|
1174
1177
|
}
|
|
1175
|
-
const me =
|
|
1178
|
+
const me = At(), ve = Ot(
|
|
1176
1179
|
function(e, n) {
|
|
1177
1180
|
const {
|
|
1178
1181
|
children: o,
|
|
@@ -1189,7 +1192,7 @@ const me = Lt(), ve = Ot(
|
|
|
1189
1192
|
() => l,
|
|
1190
1193
|
[l]
|
|
1191
1194
|
);
|
|
1192
|
-
const E =
|
|
1195
|
+
const E = Bt(() => {
|
|
1193
1196
|
r(!1), c == null || c();
|
|
1194
1197
|
}, [c]);
|
|
1195
1198
|
_(() => {
|
|
@@ -1198,7 +1201,7 @@ const me = Lt(), ve = Ot(
|
|
|
1198
1201
|
const a = nt(null);
|
|
1199
1202
|
return _(
|
|
1200
1203
|
function() {
|
|
1201
|
-
const v =
|
|
1204
|
+
const v = Yt(e.mountingPoint) ? e.mountingPoint : window.document.body;
|
|
1202
1205
|
if (!v || l.getIsMounted())
|
|
1203
1206
|
return;
|
|
1204
1207
|
const S = he({
|
|
@@ -1223,13 +1226,13 @@ const me = Lt(), ve = Ot(
|
|
|
1223
1226
|
a.current
|
|
1224
1227
|
) : null;
|
|
1225
1228
|
}
|
|
1226
|
-
), fe =
|
|
1229
|
+
), fe = At();
|
|
1227
1230
|
function Se() {
|
|
1228
1231
|
const t = nt(fe), [e, n] = ot(!1), [o, i] = ot(t.current);
|
|
1229
1232
|
return _(() => {
|
|
1230
1233
|
i(t.current);
|
|
1231
1234
|
}, [t.current]), {
|
|
1232
|
-
props:
|
|
1235
|
+
props: Pt(() => ({
|
|
1233
1236
|
ref: t,
|
|
1234
1237
|
isOpen: e,
|
|
1235
1238
|
setIsOpen: n
|
|
@@ -1239,6 +1242,6 @@ function Se() {
|
|
|
1239
1242
|
}
|
|
1240
1243
|
export {
|
|
1241
1244
|
ve as BottomSheet,
|
|
1242
|
-
|
|
1245
|
+
At as createPlaceholderBottomSheet,
|
|
1243
1246
|
Se as useBottomSheet
|
|
1244
1247
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(O,S){typeof exports=="object"&&typeof module<"u"?S(exports,require("react"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","react-dom"],S):(O=typeof globalThis<"u"?globalThis:O||self,S(O.BottomSheet={},O.React,O.ReactDOM))})(this,function(O,S,Lt){"use strict";function Ot(t){return t!=null}(function(){try{if(typeof document<"u"){var t=document.createElement("style");t.appendChild(document.createTextNode('.pbs-root{position:fixed;left:0;bottom:0;display:flex;flex-direction:column;align-items:center;justify-content:flex-start;width:100%;height:fit-content;max-height:100vh;z-index:2}.pbs-dialog-reset{background-color:transparent;color:inherit;border:none;outline:none;padding:0;margin:0}.pbs-backdrop{position:fixed;top:0;left:0;width:100%;height:100%;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(t)}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();var Dt=Object.defineProperty,Pt=(t,e,n)=>e in t?Dt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,$=(t,e,n)=>Pt(t,typeof e!="symbol"?e+"":e,n);function T(t){return typeof t=="string"}function Bt(t,e){return t.classList.contains(q(e))}function X(t,e){t.classList.add(q(e))}function tt(t,e){t.classList.remove(q(e))}function G(t,e,n){T(n)&&(T(e)&&tt(t,e),X(t,n))}function q(t){return T(t)?t.trim().replace(/\./g,""):""}function I(t){return t.map(e=>q(e)).filter(Boolean).join(" ")}function Mt(t){return t.map(e=>e==null?void 0:e.trim()).filter(Boolean).map(e=>`.${e}`).join(" ")}const lt="open",dt="hidden";function et(t,e){const n=e;if(Array.isArray(t)){t.forEach(o=>{z(o,n),o.setAttribute("aria-modal",n?"true":"false")});return}z(t,n),t.setAttribute("aria-modal",n?"true":"false")}function z(t,e){e?(X(t,lt),tt(t,dt)):(X(t,dt),tt(t,lt))}function pt(t){return t instanceof HTMLElement}function A(t){return typeof t=="number"&&!Number.isNaN(t)}function Yt(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"),n=A(e)?parseInt(e,10):-1,o=["INPUT","BUTTON","SELECT","TEXTAREA","A","AREA","IFRAME"].includes(t.tagName),i=t instanceof HTMLAnchorElement&&t.href!==""||t instanceof HTMLAreaElement&&t.href!=="";return o||i||n>-1}var C=(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))(C||{}),nt=(t=>(t.Button="pbs-button-reset",t.Dialog="pbs-dialog-reset",t))(nt||{}),V=(t=>(t.Hidden="hidden",t))(V||{});function Y(t,e,n){const o=document.createElement(t);return e.split(" ").forEach(i=>{X(o,i)}),T(n)&&o.setAttribute("data-testid",n),o}Mt([C.Root,C.ContentWrapper]);function ht(t,e,n,o){switch(o){case"content-height":return e>=t?bt(t,e,n):0;case"middle":return-(t/2-e);case"top":return-(t-e)+n;default:return 0}}function mt(t,e){const n=e<t,o=e>t;return{isUp:n,isDown:o,stayedSame:e===t}}function ft(t,e){return e<t?-(t-e):e-t}function K(t,e){return t>e?t-e:e-t}function Rt(t,e){const n=t<e,o=t>e;return{isUp:n,isDown:o,stayedSame:t===e}}function gt(t,e,n){const o=t==="above";return n.filter(i=>{const r=i*e.viewportHeight;return o?e.visibleHeight<r:e.visibleHeight>r})}function bt(t,e,n){return-(t-e)+n}function vt(t){return Number(t.replace("px",""))}function J(t,...e){return Number(t.toFixed(...e))}function St(t){const e=/(?<type>\w+)\((?<values>[^)]+)\)/g,n=[];let o;for(;(o=e.exec(t))!==null;){const i=o[1],r=o[2].split(",").map(c=>c.trim());n.push({type:i,values:r})}return n}function Nt(t){const e=t.style.transform,n=St(e);return{transform:e,transformValues:n}}function Ct(t,e){return t.find(o=>o.type.startsWith(e))||null}const ot="translate";function P(t){const e=t.style.transform,n=St(e),o=Ct(n,ot);return wt(o??{type:ot,values:[]})}function Q(t,{x:e,y:n}){const{transform:o,transformValues:i}=Nt(t),r=Ct(i,ot);if(r){const c=wt(r);t.style.transform=`translate(${e??c.x??0}px,${n??c.y??0}px)`;return}if(o){t.style.transform=`${o}, translate(${e??0}px,${n??0}px)`;return}t.style.transform=`translate(${e??0}px,${n??0}px)`}function wt(t){if(t.type!=="translate")throw new Error(`Could not get coordinates from ${t.type}, since is not translate.`);const e=t.values[0],n=t.values[1];return{x:vt(e)??0,y:vt(n)??0}}function rt(t){return t!=null}function yt(t,{min:e,max:n}){return rt(n)&&t>=n?n:rt(e)&&t<=e?e:t}const Ft=(t,e,n)=>{e instanceof HTMLElement&&!Bt(e,C.Handle)&&n.scrollTop>=1||(t.isDragging=!0)},Wt=(t,e,n,o)=>i=>{o.startY=t.getCoordinates(i).y,o.containerStartTranslate=P(e),n.onDragStart()},jt=(t,e,n,o,i)=>r=>{Ut(r,t,n,o,i,e,n.marginTop)};function Ut(t,e,n,o,i,r,c){if(!o.isDragging||!A(o.startY))return;const s=e.getCoordinates(t).y,p=ft(o.startY,s),f=window.innerHeight,u=r.clientHeight,b=u-(o.containerStartTranslate.y+p);if(b>=f)return;const H=mt(o.startY,s);if(H.isUp&&!n.expandable&&b>=u)return;i.start(()=>{Q(r,{y:o.containerStartTranslate.y+p})},0);const a=f-c,x=u-o.containerStartTranslate.y;if(H.isUp){const v=a-x,w=a-b,k=yt(1-J(w/v,2),{min:0,max:1});n.onDragMove(H,k)}else if(H.isDown){const v=yt(J(1-b/x,2),{min:0,max:1});n.onDragMove(H,v)}}const Gt=(t,e,n,o,i,r,c)=>s=>{if(!o.isDragging||(o.isDragging=!1,!A(o.startY)))return;n.onDragEnd();const p=o.startY,f=t.getCoordinates(s).y,u=P(e).y,b=mt(p,f),H=window.innerHeight,a=e.clientHeight;if(b.isUp){const x=[...n.snapPoints].sort((k,y)=>k-y),v=a+-u;if(!n.expandable&&v>=a)return;for(const k of x){const y=k*window.innerHeight;if(v<=y){const M=K(v,y);c.translateContainer({startY:u,endY:u-M,animationFrame:i,bottomSheetContainer:e});return}}const w=bt(H,a,n.marginTop);c.translateContainer({startY:u,endY:w,animationFrame:i,bottomSheetContainer:e})}else if(b.isDown){const x=[...n.snapPoints].sort((v,w)=>w-v);for(const v of x){const w=v*window.innerHeight,k=a+-u;if(k>=w){const y=K(k,w);c.translateContainer({startY:u,endY:u+y,animationFrame:i,bottomSheetContainer:e});return}}r()}};var R=(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))(R||{});function Et(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:R.All};class _{constructor(e){$(this,"currentTarget"),this.currentTarget=e}addEventListeners({onStart:e,onStartOptions:n=_t,onMove:o,onEnd:i}){this.addTouchEventListeners({onStart:e,onStartOptions:n,onMove:o,onEnd:i}),this.addMouseEventListeners({onStart:e,onStartOptions:n,onMove:o,onEnd:i})}addTouchEventListeners({onStart:e,onStartOptions:n,onMove:o,onEnd:i}){e&&this.currentTarget.addEventListener("touchstart",r=>{if(n.eventPhase===R.All){e(r);return}Et(r.eventPhase)===n.eventPhase&&e(r)},{passive:!0}),o&&this.currentTarget.addEventListener("touchmove",o),i&&this.currentTarget.addEventListener("touchend",i)}addMouseEventListeners({onStart:e,onStartOptions:n,onMove:o,onEnd:i}){e&&this.currentTarget.addEventListener("mousedown",r=>{if(n.eventPhase===R.All){e(r);return}Et(r.eventPhase)===n.eventPhase&&e(r)},{passive:!0}),o&&this.currentTarget.addEventListener("mousemove",o),i&&this.currentTarget.addEventListener("mouseup",r=>{i(r)})}removeEventListeners({onStart:e,onMove:n,onEnd:o}){e&&this.currentTarget.removeEventListener("touchstart",e),o&&this.currentTarget.removeEventListener("touchend",o),n&&this.currentTarget.removeEventListener("touchmove",n),e&&this.currentTarget.removeEventListener("mousedown",e),n&&this.currentTarget.removeEventListener("mousemove",n),o&&this.currentTarget.removeEventListener("mouseup",o)}getCoordinates(e){if(e.type==="touchstart"||e.type==="mousedown"){if("touches"in e)return{x:e.touches[0].clientX,y:e.touches[0].clientY};if(e instanceof MouseEvent)return{x:e.clientX,y:e.clientY}}if(e.type==="touchend"||e.type==="mouseup"||e.type==="mousemove"||e.type==="touchmove"){if("touches"in e)return{x:e.changedTouches[0].clientX,y:e.changedTouches[0].clientY};if(e instanceof MouseEvent)return{x:e.clientX,y:e.clientY}}return{x:0,y:0}}}function $t(t,e){const n=Xt(t);qt(n),n.bottomSheetContainer.style.width=t.width;const o=document.createElement("div");o.innerHTML=t.content??"";const i=window.innerHeight;n.bottomSheetContainer.style.maxHeight=`${i}px`,n.bottomSheetContentWrapper.appendChild(o);const r=zt({bottomSheetElements:n,bottomSheetProps:t,options:e});return{elements:n,eventHandlers:r}}function Xt(t){const e=Y("dialog",I([C.Root,nt.Dialog,t.rootClass]),C.Root);e.ariaLabel=t.ariaLabel;const n=Y("section",I([C.Container,t.containerClass]),C.Container);t.containerBorderRadius&&(n.style.borderRadius=t.containerBorderRadius);const o=Y("div",C.GapFiller,C.GapFiller),i=Y("button",I([C.Handle,nt.Button,t.shouldShowHandle?null:V.Hidden,t.handleClass]),C.Handle);i.setAttribute("type","button"),i.ariaLabel="bottom sheet close button";const r=Y("span",I([C.HandleBar,t.shouldShowHandle?null:V.Hidden]),C.HandleBar),c=Y("article",I([C.ContentWrapper,t.contentWrapperClass]),C.ContentWrapper),s=Y("div",I([C.Backdrop,t.backdropClass,V.Hidden]),C.Backdrop);return t.backdropColor&&(s.style.backgroundColor=t.backdropColor),t.backDropTransition&&(s.style.transition=t.backDropTransition),{bottomSheetRoot:e,bottomSheetBackdrop:s,bottomSheetContainer:n,bottomSheetHandle:i,bottomSheetHandleBar:r,bottomSheetContentWrapper:c,bottomSheetContainerGapFiller:o}}function qt({bottomSheetRoot:t,bottomSheetContainer:e,bottomSheetHandle:n,bottomSheetHandleBar:o,bottomSheetContentWrapper:i,bottomSheetContainerGapFiller:r}){t.appendChild(e),n.appendChild(o),e.appendChild(n),e.appendChild(i),e.appendChild(r)}function zt({bottomSheetElements:t,bottomSheetProps:e,options:n}){const{bottomSheetRoot:o,bottomSheetContainer:i,bottomSheetHandle:r,bottomSheetContainerGapFiller:c,bottomSheetContentWrapper:s}=t,{animationFrame:p}=n,f=new _(r),u=new _(s),b=new _(c),H=e.dragTriggers.reduce((g,L)=>{const D=o.querySelectorAll(L);if(!D.length)return g;const ut=Array.from(D).map(j=>j instanceof HTMLElement?new _(j):null).filter(j=>!!j);return[...g,...ut]},[]),a=new _(window),x=Wt(a,i,e,n.draggingState),v=jt(a,i,e,n.draggingState,p),w=Gt(a,i,e,n.draggingState,p,n.onClose,n.bottomSheetState);function k(g){g.target instanceof Element&&!o.contains(g.target)&&n.onClose()}function y(g){Ft(n.draggingState,g.target,t.bottomSheetContentWrapper)}function M(){e.draggable&&(f.addEventListeners({onStart:y}),H.forEach(g=>{g.addEventListeners({onStart:y,onStartOptions:{eventPhase:R.Target}})})),e.draggable&&e.backgroundDraggable&&(u.addEventListeners({onStart:y,onStartOptions:{eventPhase:R.Target}}),b.addEventListeners({onStart:y})),e.draggable&&a.addEventListeners({onStart:x,onMove:v,onEnd:w}),e.draggable&&window.document.addEventListener("keyup",g=>{g.key==="Escape"&&n.onClose()}),e.shouldCloseOnOutsideClick&&window.document.addEventListener("click",k),r.addEventListener("keyup",g=>{if(g.key==="ArrowUp"){n.moveUp();return}if(g.key==="ArrowDown"){n.moveDown();return}if(g.shiftKey&&g.key==="Tab"){const L=Z(t.bottomSheetContentWrapper);Yt(L)}})}function Z(g){let L=[...Array.from(g.childNodes).reverse()];for(;L.length;){const D=L.shift();if(It(D))return D;D&&(L=[...L,...Array.from(D.childNodes).reverse()])}return null}function ct(){f.removeEventListeners({onStart:y}),u.removeEventListeners({onStart:y}),b.removeEventListeners({onStart:y}),H.forEach(g=>{g.removeEventListeners({onStart:y})}),a.removeEventListeners({onStart:x,onMove:v,onEnd:w}),window.removeEventListener("click",k)}return{attachEventListeners:M,clearEventListeners:ct}}class Vt{constructor(){$(this,"animationId"),$(this,"isInProgress"),$(this,"startedAt"),this.animationId=null,this.isInProgress=!1,this.startedAt=null}start(e,n,o=!1){this.isInProgress=!0;const i=r=>{this.startedAt||(this.startedAt=r);const c=r-this.startedAt,s=n===0?1:J(c/n,2),p=s>=1&&!o;e(s),p?this.stop():this.animationId=requestAnimationFrame(i)};this.animationId=requestAnimationFrame(i)}stop(){this.isInProgress=!1,this.startedAt=null,A(this.animationId)&&cancelAnimationFrame(this.animationId)}}function Kt(t){const{startY:e,endY:n,bottomSheetContainer:o,animationFrame:i,onEnd:r,animationTimingFunction:c,animationDuration:s}=t,p=ft(e,n);i.stop();let f=!1;i.start(u=>{Q(o,{y:e+p*c(u)}),!f&&u>=1&&(r==null||r(),f=!0)},s)}const it=(t,e)=>n=>{Kt({...n,animationTimingFunction:t,animationDuration:e})},N={TOP:"top",MIDDLE:"middle",CONTENT_HEIGHT:"content-height",CLOSED:"closed"};function Jt(t){return!(!A(t)||t>1||t<0)}function Qt(t,e){const n={set(o,i,r,c){return e(i,r),Reflect.set(o,i,r,c)}};return new Proxy(t,n)}function Zt(...t){console.error(t)}const F={EASE:"ease",EASE_IN:"ease-in",EASE_OUT:"ease-out",EASE_IN_OUT:"ease-in-out",SPRING:"spring"};function te(t){for(const e of Object.values(F))if(e===t)return!0;return!1}function Ht(t){return!!(t instanceof Object&&"p1x"in t&&"p1y"in t&&"p2x"in t&&"p2y"in t&&A(t.p1x)&&A(t.p1y)&&A(t.p2x)&&A(t.p2y))}function W(t,e,n,o){return function(s){return c(i(s))};function i(s){let p=0,f=1,u=s,b;if(s===0||s===1)return s;for(;p<f;){if(b=r(u),Math.abs(b-s)<.001)return u;s>b?p=u:f=u,u=(f+p)/2}return u}function r(s){return 3*t*s*Math.pow(1-s,2)+3*n*Math.pow(s,2)*(1-s)+Math.pow(s,3)}function c(s){return 3*e*s*Math.pow(1-s,2)+3*o*Math.pow(s,2)*(1-s)+Math.pow(s,3)}}const ee=W(.25,.1,.25,1),ne=W(.42,0,1,1),Tt=W(.42,0,.58,1),kt=W(.4,.1,.6,1),oe=W(.45,1.5,.55,1);function re(t){switch(t){case F.EASE:return ee;case F.EASE_IN:return ne;case F.EASE_OUT:return Tt;case F.EASE_IN_OUT:return kt;case F.SPRING:return oe;default:return kt}}function xt(t){return typeof t=="boolean"}const ie={ariaLabel:"Bottom sheet",content:"",defaultPosition:N.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 ae(t){const e={...ie},n=Object.entries(t).reduce((o,i)=>{const[r,c]=i;return rt(c)&&(o[r]=c),o},{});return{...e,...n}}function at(t){if(Ht(t)){const{p1x:e,p1y:n,p2x:o,p2y:i}=t;return W(e,n,o,i)}return te(t)?re(t):Tt}function se(t,e,n){function o(i,r){switch(i){case"content":T(r)&&(t.bottomSheetContentWrapper.innerHTML=r);break;case"width":T(r)&&(t.bottomSheetContainer.style.width=r);break;case"shouldShowHandle":xt(r)||z(t.bottomSheetHandle,!1);break;case"shouldShowBackdrop":xt(r)||z(t.bottomSheetBackdrop,!1);break;case"containerBorderRadius":T(r)&&(t.bottomSheetContainer.style.borderRadius=r);break;case"backdropColor":T(r)&&(t.bottomSheetBackdrop.style.backgroundColor=r);break;case"backDropTransition":T(r)&&(t.bottomSheetBackdrop.style.transition=r);break;case"rootClass":if(!T(r))return;G(t.bottomSheetRoot,n.rootClass,r);break;case"containerClass":if(!T(r))return;G(t.bottomSheetContainer,n.containerClass,r);break;case"handleClass":if(!T(r))return;G(t.bottomSheetHandle,n.handleClass,r);break;case"contentWrapperClass":if(!T(r))return;G(t.bottomSheetContentWrapper,n.contentWrapperClass,r);break;case"backdropClass":if(!T(r))return;G(t.bottomSheetBackdrop,n.backdropClass,r);break;case"draggingAnimationTimings":if(Ht(r)){const c=at(r),s=it(c,n.draggingAnimationDuration);e.translateContainer=s}break;case"draggingAnimationDuration":if(A(r)){const c=at(n.draggingAnimationTimings),s=it(c,r);e.translateContainer=s}break}}return o}function ce(t){const e=ae(t),n=at(t.draggingAnimationTimings),o={isMounted:!1,translateContainer:it(n,e.draggingAnimationDuration)},i={startY:null,containerStartTranslate:{x:0,y:0},isDragging:!1,originalDocumentOverflowY:null};function r(){i.originalDocumentOverflowY&&i.originalDocumentOverflowY!=="hidden"&&(document.body.style.overflowY=i.originalDocumentOverflowY)}const c=new Vt,s={animationFrame:c,onClose:k,bottomSheetState:o,draggingState:i,snapTo:At,moveUp:ut,moveDown:j},{elements:p,eventHandlers:f}=$t(e,s),u=Qt(e,se(p,o,e)),{bottomSheetBackdrop:b,bottomSheetRoot:H,bottomSheetContainer:a}=p,x=l=>{const d=l??window.document.body;d.appendChild(H),d.appendChild(b);const h=window.innerHeight;Q(a,{y:h}),f.attachEventListeners(),o.isMounted=!0},v=()=>{f.clearEventListeners(),Object.values(p).forEach(l=>{l.remove()}),r(),o.isMounted=!1},w=()=>{var l;if(y()||Zt('Bottom Sheet is not mounted yet. call the "mount" method first.'),(l=t.beforeOpen)==null||l.call(t),M())return;u.shouldShowBackdrop&&et(b,!0),et([a],!0),Q(a,{y:a.clientHeight});const d=window.innerHeight,h=ht(d,a.clientHeight,u.marginTop,u.defaultPosition),m=P(a).y;o.translateContainer({startY:m,endY:h,animationFrame:c,bottomSheetContainer:a,onEnd:t.afterOpen}),p.bottomSheetHandle.focus();const E=document.body.style.overflowY;i.originalDocumentOverflowY=E||"initial",document.body.style.overflowY="hidden"};function k(){var l;if(Z())return;(l=t.beforeClose)==null||l.call(t);const d=P(a).y,h=a.clientHeight;o.translateContainer({startY:d,endY:h,animationFrame:c,bottomSheetContainer:a,onEnd:()=>{var m;(m=t.afterClose)==null||m.call(t),et([b,a],!1)}}),r()}function y(){return o.isMounted}function M(){const l=P(a).y,d=window.innerHeight,h=a.clientHeight>=d?d:a.clientHeight;return l<h}function Z(){return!M()}function ct(){const l=P(a).y,d=a.clientHeight,h=window.innerHeight;if(l<=5&&l>=-5)return N.CONTENT_HEIGHT;const m=d-l;if(m===h/2)return N.MIDDLE;const E=h-u.marginTop,B=10;return m<=E+B&&m>=E-B?N.TOP:N.CLOSED}function g(){return a.clientHeight}function L(l){if(!M())return;const d=P(a).y,h=a.clientHeight-d,m=window.innerHeight-l,E=Rt(h,m),B=K(h,m);o.translateContainer({startY:d,endY:d+(E.isUp?-B:B),animationFrame:c,bottomSheetContainer:a})}function D(l,{viewportHeight:d,visibleHeight:h}){let m=null;for(const E of l){const B=E*d,U=K(h,B);(m===null||U<m)&&(m=U)}return{minOffset:m}}function ut(){const l=[...u.snapPoints].reverse(),d=P(a).y,h=a.clientHeight,m=h-d;if(!u.expandable&&m>=h)return;const E=window.innerHeight,B=gt("above",{visibleHeight:m,viewportHeight:E},l),{minOffset:U}=D(B,{visibleHeight:m,viewportHeight:E});if(U===null&&m<E-u.marginTop){o.translateContainer({startY:d,endY:ht(E,h,u.marginTop,"top"),animationFrame:c,bottomSheetContainer:a});return}A(U)&&o.translateContainer({startY:d,endY:d-U,animationFrame:c,bottomSheetContainer:a})}function j(){const l=P(a).y,d=a.clientHeight-l;if(d<1)return;const h=window.innerHeight,m=gt("below",{visibleHeight:d,viewportHeight:h},u.snapPoints),{minOffset:E}=D(m,{visibleHeight:d,viewportHeight:h});A(E)&&o.translateContainer({startY:l,endY:l+E,animationFrame:c,bottomSheetContainer:a})}function At(l){const d=window.innerHeight;if(!Jt(l))return;const h=J(d*l,2);L(h)}return{props:u,elements:p,mount:x,unmount:v,open:w,close:k,getIsMounted:y,getIsOpen:M,getIsClosed:Z,getPosition:ct,getHeight:g,moveTo:L,snapTo:At}}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:()=>N.CLOSED,moveTo:()=>{},snapTo:()=>{},props:{content:""}}}const ue=st(),le=S.forwardRef(function(e,n){const{children:o,isOpen:i,setIsOpen:r,afterClose:c,mountingPoint:s,...p}=e,f=S.useRef(ue),[u,b]=S.useState(f.current);S.useImperativeHandle(n,()=>u,[u]);const H=S.useCallback(()=>{r(!1),c==null||c()},[c]);S.useEffect(()=>{i?u.open():u.close()},[i]);const a=S.useRef(null);return S.useEffect(function(){const v=Ot(e.mountingPoint)?e.mountingPoint:window.document.body;if(!v||u.getIsMounted())return;const w=ce({content:"",...p,afterClose:H});return w.mount(v),a.current=w.elements.bottomSheetContentWrapper??null,f.current=w,b(w),()=>{u.unmount()}},[e.mountingPoint,p,H]),S.useEffect(function(){Object.assign(f.current.props,{...p}),b(f.current)},[p]),a.current?Lt.createPortal(e.children,a.current):null}),de=st();function pe(){const t=S.useRef(de),[e,n]=S.useState(!1),[o,i]=S.useState(t.current);return S.useEffect(()=>{i(t.current)},[t.current]),{props:S.useMemo(()=>({ref:t,isOpen:e,setIsOpen:n}),[e]),instance:o}}O.BottomSheet=le,O.createPlaceholderBottomSheet=st,O.useBottomSheet=pe,Object.defineProperty(O,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(D,S){typeof exports=="object"&&typeof module<"u"?S(exports,require("react"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","react-dom"],S):(D=typeof globalThis<"u"?globalThis:D||self,S(D.BottomSheet={},D.React,D.ReactDOM))})(this,function(D,S,xt){"use strict";function At(t){return t!=null}(function(){try{if(typeof document<"u"){var t=document.createElement("style");t.appendChild(document.createTextNode('.pbs-root{position:fixed;left:0;bottom:0;display:flex;flex-direction:column;align-items:center;justify-content:flex-start;width:100%;height:fit-content;max-height:100vh;z-index:2}.pbs-dialog-reset{background-color:transparent;color:inherit;border:none;outline:none;padding:0;margin:0}.pbs-backdrop{position:fixed;top:0;left:0;width:100%;height:100%;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(t)}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();var Dt=Object.defineProperty,Bt=(t,e,n)=>e in t?Dt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,$=(t,e,n)=>Bt(t,typeof e!="symbol"?e+"":e,n);function H(t){return typeof t=="string"}function Pt(t,e){return t.classList.contains(q(e))}function X(t,e){t.classList.add(q(e))}function tt(t,e){t.classList.remove(q(e))}function G(t,e,n){H(n)&&(H(e)&&tt(t,e),X(t,n))}function q(t){return H(t)?t.trim().replace(/\./g,""):""}function I(t){return t.map(e=>q(e)).filter(Boolean).join(" ")}function Mt(t){return t.map(e=>e==null?void 0:e.trim()).filter(Boolean).map(e=>`.${e}`).join(" ")}const ut="open",dt="hidden";function et(t,e){const n=e;if(Array.isArray(t)){t.forEach(o=>{z(o,n),o.setAttribute("aria-modal",n?"true":"false")});return}z(t,n),t.setAttribute("aria-modal",n?"true":"false")}function z(t,e){e?(X(t,ut),tt(t,dt)):(X(t,dt),tt(t,ut))}function ht(t){return t instanceof HTMLElement}function O(t){return typeof t=="number"&&!Number.isNaN(t)}function Yt(t){ht(t)&&t.focus()}function It(t){if(!ht(t)||t.offsetParent===null||"disabled"in t&&t.disabled)return!1;const e=t.getAttribute("tabindex"),n=O(e)?parseInt(e,10):-1,o=["INPUT","BUTTON","SELECT","TEXTAREA","A","AREA","IFRAME"].includes(t.tagName),i=t instanceof HTMLAnchorElement&&t.href!==""||t instanceof HTMLAreaElement&&t.href!=="";return o||i||n>-1}var C=(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))(C||{}),nt=(t=>(t.Button="pbs-button-reset",t.Dialog="pbs-dialog-reset",t))(nt||{}),V=(t=>(t.Hidden="hidden",t))(V||{});function Y(t,e,n){const o=document.createElement(t);return e.split(" ").forEach(i=>{X(o,i)}),H(n)&&o.setAttribute("data-testid",n),o}Mt([C.Root,C.ContentWrapper]);function pt(t,e,n,o){switch(o){case"content-height":return e>=t?bt(t,e,n):0;case"middle":return-(t/2-e);case"top":return-(t-e)+n;default:return 0}}function mt(t,e){const n=e<t,o=e>t;return{isUp:n,isDown:o,stayedSame:e===t}}function ft(t,e){return e<t?-(t-e):e-t}function K(t,e){return t>e?t-e:e-t}function Rt(t,e){const n=t<e,o=t>e;return{isUp:n,isDown:o,stayedSame:t===e}}function gt(t,e,n){const o=t==="above";return n.filter(i=>{const r=i*e.viewportHeight;return o?e.visibleHeight<r:e.visibleHeight>r})}function bt(t,e,n){return-(t-e)+n}function vt(t){return Number(t.replace("px",""))}function J(t,...e){return Number(t.toFixed(...e))}function St(t){const e=/(?<type>\w+)\((?<values>[^)]+)\)/g,n=[];let o;for(;(o=e.exec(t))!==null;){const i=o[1],r=o[2].split(",").map(c=>c.trim());n.push({type:i,values:r})}return n}function Nt(t){const e=t.style.transform,n=St(e);return{transform:e,transformValues:n}}function Ct(t,e){return t.find(o=>o.type.startsWith(e))||null}const ot="translate";function P(t){const e=t.style.transform,n=St(e),o=Ct(n,ot);return wt(o??{type:ot,values:[]})}function Q(t,{x:e,y:n}){const{transform:o,transformValues:i}=Nt(t),r=Ct(i,ot);if(r){const c=wt(r);t.style.transform=`translate(${e??c.x??0}px,${n??c.y??0}px)`;return}if(o){t.style.transform=`${o}, translate(${e??0}px,${n??0}px)`;return}t.style.transform=`translate(${e??0}px,${n??0}px)`}function wt(t){if(t.type!=="translate")throw new Error(`Could not get coordinates from ${t.type}, since is not translate.`);const e=t.values[0],n=t.values[1];return{x:vt(e)??0,y:vt(n)??0}}function rt(t){return t!=null}function yt(t,{min:e,max:n}){return rt(n)&&t>=n?n:rt(e)&&t<=e?e:t}const Ft=(t,e,n)=>{e instanceof HTMLElement&&!Pt(e,C.Handle)&&n.scrollTop>=1||(t.isDragging=!0)},Wt=(t,e,n,o)=>i=>{o.startY=t.getCoordinates(i).y,o.containerStartTranslate=P(e),n.onDragStart()},jt=(t,e,n,o,i)=>r=>{Ut(r,t,n,o,i,e,n.marginTop)};function Ut(t,e,n,o,i,r,c){if(!o.isDragging||!O(o.startY))return;const s=e.getCoordinates(t).y,h=ft(o.startY,s),f=window.innerHeight,l=r.clientHeight,b=l-(o.containerStartTranslate.y+h);if(b>=f)return;const T=mt(o.startY,s);if(T.isUp&&!n.expandable&&b>=l)return;i.start(()=>{Q(r,{y:o.containerStartTranslate.y+h})},0);const a=f-c,L=l-o.containerStartTranslate.y;if(T.isUp){const v=a-L,w=a-b,k=yt(1-J(w/v,2),{min:0,max:1});n.onDragMove(T,k)}else if(T.isDown){const v=yt(J(1-b/L,2),{min:0,max:1});n.onDragMove(T,v)}}const Gt=(t,e,n,o,i,r,c)=>s=>{if(!o.isDragging||(o.isDragging=!1,!O(o.startY)))return;n.onDragEnd();const h=o.startY,f=t.getCoordinates(s).y,l=P(e).y,b=mt(h,f),T=window.innerHeight,a=e.clientHeight;if(b.isUp){const L=[...n.snapPoints].sort((k,y)=>k-y),v=a+-l;if(!n.expandable&&v>=a)return;for(const k of L){const y=k*window.innerHeight;if(v<=y){const M=K(v,y);c.translateContainer({startY:l,endY:l-M,animationFrame:i,bottomSheetContainer:e});return}}const w=bt(T,a,n.marginTop);c.translateContainer({startY:l,endY:w,animationFrame:i,bottomSheetContainer:e})}else if(b.isDown){const L=[...n.snapPoints].sort((v,w)=>w-v);for(const v of L){const w=v*window.innerHeight,k=a+-l;if(k>=w){const y=K(k,w);c.translateContainer({startY:l,endY:l+y,animationFrame:i,bottomSheetContainer:e});return}}r()}};var R=(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))(R||{});function Et(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:R.All};class _{constructor(e){$(this,"currentTarget"),this.currentTarget=e}addEventListeners({onStart:e,onStartOptions:n=_t,onMove:o,onEnd:i}){this.addTouchEventListeners({onStart:e,onStartOptions:n,onMove:o,onEnd:i}),this.addMouseEventListeners({onStart:e,onStartOptions:n,onMove:o,onEnd:i})}addTouchEventListeners({onStart:e,onStartOptions:n,onMove:o,onEnd:i}){e&&this.currentTarget.addEventListener("touchstart",r=>{if(n.eventPhase===R.All){e(r);return}Et(r.eventPhase)===n.eventPhase&&e(r)},{passive:!0}),o&&this.currentTarget.addEventListener("touchmove",o),i&&this.currentTarget.addEventListener("touchend",i)}addMouseEventListeners({onStart:e,onStartOptions:n,onMove:o,onEnd:i}){e&&this.currentTarget.addEventListener("mousedown",r=>{if(n.eventPhase===R.All){e(r);return}Et(r.eventPhase)===n.eventPhase&&e(r)},{passive:!0}),o&&this.currentTarget.addEventListener("mousemove",o),i&&this.currentTarget.addEventListener("mouseup",r=>{i(r)})}removeEventListeners({onStart:e,onMove:n,onEnd:o}){e&&this.currentTarget.removeEventListener("touchstart",e),o&&this.currentTarget.removeEventListener("touchend",o),n&&this.currentTarget.removeEventListener("touchmove",n),e&&this.currentTarget.removeEventListener("mousedown",e),n&&this.currentTarget.removeEventListener("mousemove",n),o&&this.currentTarget.removeEventListener("mouseup",o)}getCoordinates(e){if(e.type==="touchstart"||e.type==="mousedown"){if("touches"in e)return{x:e.touches[0].clientX,y:e.touches[0].clientY};if(e instanceof MouseEvent)return{x:e.clientX,y:e.clientY}}if(e.type==="touchend"||e.type==="mouseup"||e.type==="mousemove"||e.type==="touchmove"){if("touches"in e)return{x:e.changedTouches[0].clientX,y:e.changedTouches[0].clientY};if(e instanceof MouseEvent)return{x:e.clientX,y:e.clientY}}return{x:0,y:0}}}function $t(t,e){const n=Xt(t);qt(n),n.bottomSheetContainer.style.width=t.width;const o=document.createElement("div");o.innerHTML=t.content??"";const i=window.innerHeight;n.bottomSheetContainer.style.maxHeight=`${i}px`,n.bottomSheetContentWrapper.appendChild(o);const r=zt({bottomSheetElements:n,bottomSheetProps:t,options:e});return{elements:n,eventHandlers:r}}function Xt(t){const e=Y("dialog",I([C.Root,nt.Dialog,t.rootClass]),C.Root);e.ariaLabel=t.ariaLabel;const n=Y("section",I([C.Container,t.containerClass]),C.Container);t.containerBorderRadius&&(n.style.borderRadius=t.containerBorderRadius);const o=Y("div",C.GapFiller,C.GapFiller),i=Y("button",I([C.Handle,nt.Button,t.shouldShowHandle?null:V.Hidden,t.handleClass]),C.Handle);i.setAttribute("type","button"),i.ariaLabel="bottom sheet close button";const r=Y("span",I([C.HandleBar,t.shouldShowHandle?null:V.Hidden]),C.HandleBar),c=Y("article",I([C.ContentWrapper,t.contentWrapperClass]),C.ContentWrapper),s=Y("div",I([C.Backdrop,t.backdropClass,V.Hidden]),C.Backdrop);return t.backdropColor&&(s.style.backgroundColor=t.backdropColor),t.backDropTransition&&(s.style.transition=t.backDropTransition),{bottomSheetRoot:e,bottomSheetBackdrop:s,bottomSheetContainer:n,bottomSheetHandle:i,bottomSheetHandleBar:r,bottomSheetContentWrapper:c,bottomSheetContainerGapFiller:o}}function qt({bottomSheetRoot:t,bottomSheetContainer:e,bottomSheetHandle:n,bottomSheetHandleBar:o,bottomSheetContentWrapper:i,bottomSheetContainerGapFiller:r}){t.appendChild(e),n.appendChild(o),e.appendChild(n),e.appendChild(i),e.appendChild(r)}function zt({bottomSheetElements:t,bottomSheetProps:e,options:n}){const{bottomSheetRoot:o,bottomSheetContainer:i,bottomSheetHandle:r,bottomSheetContainerGapFiller:c,bottomSheetContentWrapper:s}=t,{animationFrame:h}=n,f=new _(r),l=new _(s),b=new _(c),T=e.dragTriggers.reduce((g,x)=>{const B=o.querySelectorAll(x);if(!B.length)return g;const lt=Array.from(B).map(j=>j instanceof HTMLElement?new _(j):null).filter(j=>!!j);return[...g,...lt]},[]),a=new _(window),L=Wt(a,i,e,n.draggingState),v=jt(a,i,e,n.draggingState,h),w=Gt(a,i,e,n.draggingState,h,n.onClose,n.bottomSheetState);function k(g){g.target instanceof Element&&!o.contains(g.target)&&n.onClose()}function y(g){Ft(n.draggingState,g.target,t.bottomSheetContentWrapper)}function M(){e.draggable&&(f.addEventListeners({onStart:y}),T.forEach(g=>{g.addEventListeners({onStart:y,onStartOptions:{eventPhase:R.Target}})})),e.draggable&&e.backgroundDraggable&&(l.addEventListeners({onStart:y,onStartOptions:{eventPhase:R.Target}}),b.addEventListeners({onStart:y})),e.draggable&&a.addEventListeners({onStart:L,onMove:v,onEnd:w}),e.draggable&&window.document.addEventListener("keyup",g=>{g.key==="Escape"&&n.onClose()}),e.shouldCloseOnOutsideClick&&window.document.addEventListener("click",k),r.addEventListener("keyup",g=>{if(g.key==="ArrowUp"){n.moveUp();return}if(g.key==="ArrowDown"){n.moveDown();return}if(g.shiftKey&&g.key==="Tab"){const x=Z(t.bottomSheetContentWrapper);Yt(x)}})}function Z(g){let x=[...Array.from(g.childNodes).reverse()];for(;x.length;){const B=x.shift();if(It(B))return B;B&&(x=[...x,...Array.from(B.childNodes).reverse()])}return null}function ct(){f.removeEventListeners({onStart:y}),l.removeEventListeners({onStart:y}),b.removeEventListeners({onStart:y}),T.forEach(g=>{g.removeEventListeners({onStart:y})}),a.removeEventListeners({onStart:L,onMove:v,onEnd:w}),window.removeEventListener("click",k)}return{attachEventListeners:M,clearEventListeners:ct}}class Vt{constructor(){$(this,"animationId"),$(this,"isInProgress"),$(this,"startedAt"),this.animationId=null,this.isInProgress=!1,this.startedAt=null}start(e,n,o=!1){this.isInProgress=!0;const i=r=>{this.startedAt||(this.startedAt=r);const c=r-this.startedAt,s=n===0?1:J(c/n,2),h=s>=1&&!o;e(s),h?this.stop():this.animationId=requestAnimationFrame(i)};this.animationId=requestAnimationFrame(i)}stop(){this.isInProgress=!1,this.startedAt=null,O(this.animationId)&&cancelAnimationFrame(this.animationId)}}function Kt(t){const{startY:e,endY:n,bottomSheetContainer:o,animationFrame:i,onEnd:r,animationTimingFunction:c,animationDuration:s}=t,h=ft(e,n);i.stop();let f=!1;i.start(l=>{Q(o,{y:e+h*c(l)}),!f&&l>=1&&(r==null||r(),f=!0)},s)}const it=(t,e)=>n=>{Kt({...n,animationTimingFunction:t,animationDuration:e})},N={TOP:"top",MIDDLE:"middle",CONTENT_HEIGHT:"content-height",CLOSED:"closed"};function Jt(t){return!(!O(t)||t>1||t<0)}function Qt(t,e){const n={set(o,i,r,c){return e(i,r),Reflect.set(o,i,r,c)}};return new Proxy(t,n)}function Zt(...t){console.error(t)}const F={EASE:"ease",EASE_IN:"ease-in",EASE_OUT:"ease-out",EASE_IN_OUT:"ease-in-out",SPRING:"spring"};function te(t){for(const e of Object.values(F))if(e===t)return!0;return!1}function Tt(t){return!!(t instanceof Object&&"p1x"in t&&"p1y"in t&&"p2x"in t&&"p2y"in t&&O(t.p1x)&&O(t.p1y)&&O(t.p2x)&&O(t.p2y))}function W(t,e,n,o){return function(s){return c(i(s))};function i(s){let h=0,f=1,l=s,b;if(s===0||s===1)return s;for(;h<f;){if(b=r(l),Math.abs(b-s)<.001)return l;s>b?h=l:f=l,l=(f+h)/2}return l}function r(s){return 3*t*s*Math.pow(1-s,2)+3*n*Math.pow(s,2)*(1-s)+Math.pow(s,3)}function c(s){return 3*e*s*Math.pow(1-s,2)+3*o*Math.pow(s,2)*(1-s)+Math.pow(s,3)}}const Ht=W(.25,.1,.25,1),ee=W(.42,0,1,1),kt=W(.42,0,.58,1),ne=W(.4,.1,.6,1),oe=W(.45,1.5,.55,1);function re(t){switch(t){case F.EASE:return Ht;case F.EASE_IN:return ee;case F.EASE_OUT:return kt;case F.EASE_IN_OUT:return ne;case F.SPRING:return oe;default:return Ht}}function Lt(t){return typeof t=="boolean"}const ie={ariaLabel:"Bottom sheet",content:"",defaultPosition:N.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 ae(t){const e={...ie},n=Object.entries(t).reduce((o,i)=>{const[r,c]=i;return rt(c)&&(o[r]=c),o},{});return{...e,...n}}function at(t){if(Tt(t)){const{p1x:e,p1y:n,p2x:o,p2y:i}=t;return W(e,n,o,i)}return te(t)?re(t):kt}function se(t,e,n){function o(i,r){switch(i){case"content":H(r)&&(t.bottomSheetContentWrapper.innerHTML=r);break;case"width":H(r)&&(t.bottomSheetContainer.style.width=r);break;case"shouldShowHandle":Lt(r)||z(t.bottomSheetHandle,!1);break;case"shouldShowBackdrop":Lt(r)||z(t.bottomSheetBackdrop,!1);break;case"containerBorderRadius":H(r)&&(t.bottomSheetContainer.style.borderRadius=r);break;case"backdropColor":H(r)&&(t.bottomSheetBackdrop.style.backgroundColor=r);break;case"backDropTransition":H(r)&&(t.bottomSheetBackdrop.style.transition=r);break;case"rootClass":if(!H(r))return;G(t.bottomSheetRoot,n.rootClass,r);break;case"containerClass":if(!H(r))return;G(t.bottomSheetContainer,n.containerClass,r);break;case"handleClass":if(!H(r))return;G(t.bottomSheetHandle,n.handleClass,r);break;case"contentWrapperClass":if(!H(r))return;G(t.bottomSheetContentWrapper,n.contentWrapperClass,r);break;case"backdropClass":if(!H(r))return;G(t.bottomSheetBackdrop,n.backdropClass,r);break;case"draggingAnimationTimings":if(Tt(r)){const c=at(r),s=it(c,n.draggingAnimationDuration);e.translateContainer=s}break;case"draggingAnimationDuration":if(O(r)){const c=at(n.draggingAnimationTimings),s=it(c,r);e.translateContainer=s}break}}return o}function ce(t){const e=ae(t),n=at(t.draggingAnimationTimings),o={isMounted:!1,translateContainer:it(n,e.draggingAnimationDuration)},i={startY:null,containerStartTranslate:{x:0,y:0},isDragging:!1,originalDocumentOverflowY:null,originalDocumentOverscrollBehavior:null};function r(){i.originalDocumentOverflowY&&i.originalDocumentOverflowY!=="hidden"&&(document.body.style.overflowY=i.originalDocumentOverflowY),i.originalDocumentOverscrollBehavior&&(document.body.style.position=i.originalDocumentOverscrollBehavior)}const c=new Vt,s={animationFrame:c,onClose:k,bottomSheetState:o,draggingState:i,snapTo:Ot,moveUp:lt,moveDown:j},{elements:h,eventHandlers:f}=$t(e,s),l=Qt(e,se(h,o,e)),{bottomSheetBackdrop:b,bottomSheetRoot:T,bottomSheetContainer:a}=h,L=u=>{const d=u??window.document.body;d.appendChild(T),d.appendChild(b);const p=window.innerHeight;Q(a,{y:p}),f.attachEventListeners(),o.isMounted=!0},v=()=>{f.clearEventListeners(),Object.values(h).forEach(u=>{u.remove()}),r(),o.isMounted=!1},w=()=>{var u;if(y()||Zt('Bottom Sheet is not mounted yet. call the "mount" method first.'),(u=t.beforeOpen)==null||u.call(t),M())return;l.shouldShowBackdrop&&et(b,!0),et([a],!0),Q(a,{y:a.clientHeight});const d=window.innerHeight,p=pt(d,a.clientHeight,l.marginTop,l.defaultPosition),m=P(a).y;o.translateContainer({startY:m,endY:p,animationFrame:c,bottomSheetContainer:a,onEnd:t.afterOpen}),h.bottomSheetHandle.focus();const E=document.body.style.overflowY;i.originalDocumentOverflowY=E||"initial";const A=document.body.style.overscrollBehavior;i.originalDocumentOverscrollBehavior=A||"initial",document.body.style.overflow="hidden",document.body.style.overscrollBehavior="contain"};function k(){var u;if(Z())return;(u=t.beforeClose)==null||u.call(t);const d=P(a).y,p=a.clientHeight;o.translateContainer({startY:d,endY:p,animationFrame:c,bottomSheetContainer:a,onEnd:()=>{var m;(m=t.afterClose)==null||m.call(t),et([b,a],!1)}}),r()}function y(){return o.isMounted}function M(){const u=P(a).y,d=window.innerHeight,p=a.clientHeight>=d?d:a.clientHeight;return u<p}function Z(){return!M()}function ct(){const u=P(a).y,d=a.clientHeight,p=window.innerHeight;if(u<=5&&u>=-5)return N.CONTENT_HEIGHT;const m=d-u;if(m===p/2)return N.MIDDLE;const E=p-l.marginTop,A=10;return m<=E+A&&m>=E-A?N.TOP:N.CLOSED}function g(){return a.clientHeight}function x(u){if(!M())return;const d=P(a).y,p=a.clientHeight-d,m=window.innerHeight-u,E=Rt(p,m),A=K(p,m);o.translateContainer({startY:d,endY:d+(E.isUp?-A:A),animationFrame:c,bottomSheetContainer:a})}function B(u,{viewportHeight:d,visibleHeight:p}){let m=null;for(const E of u){const A=E*d,U=K(p,A);(m===null||U<m)&&(m=U)}return{minOffset:m}}function lt(){const u=[...l.snapPoints].reverse(),d=P(a).y,p=a.clientHeight,m=p-d;if(!l.expandable&&m>=p)return;const E=window.innerHeight,A=gt("above",{visibleHeight:m,viewportHeight:E},u),{minOffset:U}=B(A,{visibleHeight:m,viewportHeight:E});if(U===null&&m<E-l.marginTop){o.translateContainer({startY:d,endY:pt(E,p,l.marginTop,"top"),animationFrame:c,bottomSheetContainer:a});return}O(U)&&o.translateContainer({startY:d,endY:d-U,animationFrame:c,bottomSheetContainer:a})}function j(){const u=P(a).y,d=a.clientHeight-u;if(d<1)return;const p=window.innerHeight,m=gt("below",{visibleHeight:d,viewportHeight:p},l.snapPoints),{minOffset:E}=B(m,{visibleHeight:d,viewportHeight:p});O(E)&&o.translateContainer({startY:u,endY:u+E,animationFrame:c,bottomSheetContainer:a})}function Ot(u){const d=window.innerHeight;if(!Jt(u))return;const p=J(d*u,2);x(p)}return{props:l,elements:h,mount:L,unmount:v,open:w,close:k,getIsMounted:y,getIsOpen:M,getIsClosed:Z,getPosition:ct,getHeight:g,moveTo:x,snapTo:Ot}}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:()=>N.CLOSED,moveTo:()=>{},snapTo:()=>{},props:{content:""}}}const le=st(),ue=S.forwardRef(function(e,n){const{children:o,isOpen:i,setIsOpen:r,afterClose:c,mountingPoint:s,...h}=e,f=S.useRef(le),[l,b]=S.useState(f.current);S.useImperativeHandle(n,()=>l,[l]);const T=S.useCallback(()=>{r(!1),c==null||c()},[c]);S.useEffect(()=>{i?l.open():l.close()},[i]);const a=S.useRef(null);return S.useEffect(function(){const v=At(e.mountingPoint)?e.mountingPoint:window.document.body;if(!v||l.getIsMounted())return;const w=ce({content:"",...h,afterClose:T});return w.mount(v),a.current=w.elements.bottomSheetContentWrapper??null,f.current=w,b(w),()=>{l.unmount()}},[e.mountingPoint,h,T]),S.useEffect(function(){Object.assign(f.current.props,{...h}),b(f.current)},[h]),a.current?xt.createPortal(e.children,a.current):null}),de=st();function he(){const t=S.useRef(de),[e,n]=S.useState(!1),[o,i]=S.useState(t.current);return S.useEffect(()=>{i(t.current)},[t.current]),{props:S.useMemo(()=>({ref:t,isOpen:e,setIsOpen:n}),[e]),instance:o}}D.BottomSheet=ue,D.createPlaceholderBottomSheet=st,D.useBottomSheet=he,Object.defineProperty(D,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plainsheet/react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"license": "MIT",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"access": "public"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@plainsheet/core": "0.
|
|
34
|
+
"@plainsheet/core": "0.7.1",
|
|
35
35
|
"@plainsheet/utility": "0.0.3"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
@@ -48,15 +48,15 @@
|
|
|
48
48
|
"typescript": "^5.5.3",
|
|
49
49
|
"typescript-eslint": "^8.0.0",
|
|
50
50
|
"vite": "^5.4.0",
|
|
51
|
-
"
|
|
52
|
-
"
|
|
51
|
+
"vite-plugin-dts": "^3.8.1",
|
|
52
|
+
"vitest": "^1.6.0"
|
|
53
53
|
},
|
|
54
54
|
"peerDependencies": {
|
|
55
55
|
"react": "^18",
|
|
56
56
|
"react-dom": "^18"
|
|
57
57
|
},
|
|
58
58
|
"scripts": {
|
|
59
|
-
"dev": "vite build --watch --mode development",
|
|
59
|
+
"dev": "vite build --watch --mode development --emptyOutDir=false",
|
|
60
60
|
"build": "tsc --noEmit && vite build",
|
|
61
61
|
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist",
|
|
62
62
|
"lint": "eslint . --max-warnings 0",
|