@plainsheet/react 0.4.9 → 0.4.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
<p align="center">
|
|
2
2
|
<a href="https://https://www.plainsheet.org/">
|
|
3
|
-
<img src="https://github.com/plainsheet/plainsheet/raw/main/documents/assets/header.png" width="328" height="167">
|
|
3
|
+
<img src="https://github.com/plainsheet/plainsheet/raw/main/documents/assets/readme-header.png" width="328" height="167">
|
|
4
4
|
</a>
|
|
5
5
|
</p>
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
</a>
|
|
7
|
+

|
|
8
|
+

|
|
10
9
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
</a>
|
|
10
|
+

|
|
11
|
+

|
|
14
12
|
|
|
15
13
|
<a href="https://codecov.io/gh/PeterByun/plain-bottom-sheet" >
|
|
16
14
|
<img src="https://codecov.io/gh/PeterByun/plain-bottom-sheet/graph/badge.svg?token=WFHGUAI3GC"/>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const k=require("react"),xe=require("react-dom");function Be(e){return e!=null}(function(){try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode('.pbs-root{position:fixed;left:0;bottom:0;display:flex;flex-direction:column;align-items:center;justify-content:flex-start;width:100%;height:fit-content;max-height:100vh;z-index:2}.pbs-dialog-reset{background-color:transparent;color:inherit;border:none;outline:none;padding:0;margin:0}.pbs-backdrop{position:fixed;top:0;left:0;width:100%;height:100%;background-color:transparent;z-index:1;transition:background-color .2s ease-out}.pbs-backdrop.hidden{visibility:hidden}.pbs-backdrop.open{background-color:#454545b3}.pbs-backdrop.transparent{background-color:transparent}.pbs-container{--pbs-container-background-color: rgb(240, 240, 240);background-color:var(--pbs-container-background-color);position:relative;display:none;flex-direction:column;align-items:center;justify-content:flex-start;width:92%;height:fit-content;max-height:100vh;border-radius:10px 10px 0 0}.pbs-container.open{display:flex}.pbs-container .pbs-gap-filler{position:absolute;bottom:calc(-100vh + .5px);left:0;background-color:var(--pbs-container-background-color);content:"";width:100%;height:100vh}.pbs-handle{position:relative;display:flex;align-items:center;justify-content:center;width:100%;height:30px;cursor:pointer}.pbs-handle.hidden{display:none}.pbs-button-reset{background-color:transparent;-webkit-appearance:none;-moz-appearance:none;appearance:none;outline:none;border:none}button:focus.pbs-button-reset{outline:none}.pbs-handle-bar{background-color:#a8a8a8;position:relative;width:12%;height:7px;border-radius:12px}.pbs-handle-bar.hidden{display:none}.pbs-content-wrapper{position:relative;width:100%;height:fit-content;max-height:100%;overflow-y:scroll}.pbs-content-wrapper::-webkit-scrollbar{display:none}.example{-ms-overflow-style:none;scrollbar-width:none}')),document.head.appendChild(e)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}})();var Ae=Object.defineProperty,De=(e,t,n)=>t in e?Ae(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,K=(e,t,n)=>De(e,typeof t!="symbol"?t+"":t,n);function x(e){return typeof e=="string"}function Me(e,t){return e.classList.contains(te(t))}function V(e,t){e.classList.add(te(t))}function oe(e,t){e.classList.remove(te(t))}function X(e,t,n){x(n)&&(x(t)&&oe(e,t),V(e,n))}function te(e){return x(e)?e.trim().replace(/\./g,""):""}function W(e){return e.map(t=>te(t)).filter(Boolean).join(" ")}function Pe(e){return e.map(t=>t==null?void 0:t.trim()).filter(Boolean).map(t=>`.${t}`).join(" ")}const ue="open",de="hidden";function ne(e,t){const n=t;if(Array.isArray(e)){e.forEach(o=>{Q(o,n),o.setAttribute("aria-modal",n?"true":"false")});return}Q(e,n),e.setAttribute("aria-modal",n?"true":"false")}function Q(e,t){t?(V(e,ue),oe(e,de)):(V(e,de),oe(e,ue))}function ve(e){return e instanceof HTMLElement}function A(e){return typeof e=="number"&&!Number.isNaN(e)}function Ye(e){ve(e)&&e.focus()}function Fe(e){if(!ve(e)||e.offsetParent===null||"disabled"in e&&e.disabled)return!1;const t=e.getAttribute("tabindex"),n=A(t)?parseInt(t,10):-1,o=["INPUT","BUTTON","SELECT","TEXTAREA","A","AREA","IFRAME"].includes(e.tagName),r=e instanceof HTMLAnchorElement&&e.href!==""||e instanceof HTMLAreaElement&&e.href!=="";return o||r||n>-1}var T=(e=>(e.Backdrop="pbs-backdrop",e.Root="pbs-root",e.Container="pbs-container",e.GapFiller="pbs-gap-filler",e.Handle="pbs-handle",e.HandleBar="pbs-handle-bar",e.ContentWrapper="pbs-content-wrapper",e))(T||{}),re=(e=>(e.Button="pbs-button-reset",e.Dialog="pbs-dialog-reset",e))(re||{}),J=(e=>(e.Hidden="hidden",e))(J||{});function P(e,t,n){const o=document.createElement(e);return t.split(" ").forEach(r=>{V(o,r)}),x(n)&&o.setAttribute("data-testid",n),o}Pe([T.Root,T.ContentWrapper]);function pe(e,t,n,o){switch(o){case"content-height":return t>=e?Ee(e,t,n):0;case"middle":return-(e/2-t);case"top":return-(e-t)+n;default:return 0}}function ye(e,t){const n=t<e,o=t>e;return{isUp:n,isDown:o,stayedSame:t===e}}function Ce(e,t){return t<e?-(e-t):t-e}function z(e,t){return e>t?e-t:t-e}function Ie(e,t){const n=e<t,o=e>t;return{isUp:n,isDown:o,stayedSame:e===t}}function he(e,t,n){const o=e==="above";return n.filter(r=>{const i=r*t.viewportHeight;return o?t.visibleHeight<i:t.visibleHeight>i})}function Ee(e,t,n){return-(e-t)+n}function me(e){return Number(e.replace("px",""))}function Z(e,...t){return Number(e.toFixed(...t))}function we(e){const t=/(?<type>\w+)\((?<values>[^)]+)\)/g,n=[];let o;for(;(o=t.exec(e))!==null;){const r=o[1],i=o[2].split(",").map(a=>a.trim());n.push({type:r,values:i})}return n}function Re(e){const t=e.style.transform,n=we(t);return{transform:t,transformValues:n}}function ke(e,t){return e.find(o=>o.type.startsWith(t))||null}const ae="translate";function M(e){const t=e.style.transform,n=we(t),o=ke(n,ae);return Te(o??{type:ae,values:[]})}function ee(e,{x:t,y:n}){const{transform:o,transformValues:r}=Re(e),i=ke(r,ae);if(i){const a=Te(i);e.style.transform=`translate(${t??a.x??0}px,${n??a.y??0}px)`;return}if(o){e.style.transform=`${o}, translate(${t??0}px,${n??0}px)`;return}e.style.transform=`translate(${t??0}px,${n??0}px)`}function Te(e){if(e.type!=="translate")throw new Error(`Could not get coordinates from ${e.type}, since is not translate.`);const t=e.values[0],n=e.values[1];return{x:me(t)??0,y:me(n)??0}}function ie(e){return e!=null}function fe(e,{min:t,max:n}){return ie(n)&&e>=n?n:ie(t)&&e<=t?t:e}const We=(e,t,n)=>{t instanceof HTMLElement&&!Me(t,T.Handle)&&n.scrollTop>=1||(e.isDragging=!0)},Ne=(e,t,n,o)=>r=>{o.startY=e.getCoordinates(r).y,o.containerStartTranslate=M(t),n.onDragStart()},je=(e,t,n,o,r)=>i=>{Ge(i,e,n,o,r,t,n.marginTop)};function Ge(e,t,n,o,r,i,a){if(!o.isDragging||!A(o.startY))return;const c=t.getCoordinates(e).y,u=Ce(o.startY,c),h=window.innerHeight,s=i.clientHeight,m=s-(o.containerStartTranslate.y+u);if(m>=h)return;const C=ye(o.startY,c);if(C.isUp&&!n.expandable&&m>=s||n.preventClosing&&m<=s)return;r.start(()=>{ee(i,{y:o.containerStartTranslate.y+u})},0);const l=h-a,E=s-o.containerStartTranslate.y;if(C.isUp){const f=l-E,S=l-m,w=fe(1-Z(S/f,2),{min:0,max:1});n.onDragMove(C,w)}else if(C.isDown){const f=fe(Z(1-m/E,2),{min:0,max:1});n.onDragMove(C,f)}}const Ue=(e,t,n,o,r,i,a)=>c=>{if(!o.isDragging||(o.isDragging=!1,!A(o.startY)))return;n.onDragEnd();const u=o.startY,h=e.getCoordinates(c).y,s=M(t).y,m=ye(u,h),C=window.innerHeight,l=t.clientHeight;if(m.isUp){const E=[...n.snapPoints].sort((w,B)=>w-B),f=l+-s;if(!n.expandable&&f>=l)return;for(const w of E){const B=w*window.innerHeight;if(f<=B){const H=z(f,B);a.translateContainer({startY:s,endY:s-H,animationFrame:r,bottomSheetContainer:t});return}}const S=Ee(C,l,n.marginTop);a.translateContainer({startY:s,endY:S,animationFrame:r,bottomSheetContainer:t})}else if(m.isDown){const E=[...n.snapPoints].sort((f,S)=>S-f);for(const f of E){const S=f*window.innerHeight,w=l+-s;if(w>=S){const B=z(w,S);a.translateContainer({startY:s,endY:s+B,animationFrame:r,bottomSheetContainer:t});return}}if(n.preventClosing){const f=l+-s;if(f>=l){const S=z(f,l);a.translateContainer({startY:s,endY:s+S,animationFrame:r,bottomSheetContainer:t})}return}i()}};var G=(e=>(e[e.All=-1]="All",e[e.None=0]="None",e[e.Capture=1]="Capture",e[e.Target=2]="Target",e[e.Bubble=3]="Bubble",e))(G||{});function be(e){switch(e){case 0:return 0;case 1:return 1;case 2:return 2;case 3:return 3;default:return-1}}const $e={eventPhase:G.All};class q{constructor(t){K(this,"currentTarget"),this.currentTarget=t}addEventListeners({onStart:t,onStartOptions:n=$e,onMove:o,onEnd:r}){this.addTouchEventListeners({onStart:t,onStartOptions:n,onMove:o,onEnd:r}),this.addMouseEventListeners({onStart:t,onStartOptions:n,onMove:o,onEnd:r})}addTouchEventListeners({onStart:t,onStartOptions:n,onMove:o,onEnd:r}){t&&this.currentTarget.addEventListener("touchstart",i=>{if(n.eventPhase===G.All){t(i);return}be(i.eventPhase)===n.eventPhase&&t(i)},{passive:!0}),o&&this.currentTarget.addEventListener("touchmove",o),r&&this.currentTarget.addEventListener("touchend",r)}addMouseEventListeners({onStart:t,onStartOptions:n,onMove:o,onEnd:r}){t&&this.currentTarget.addEventListener("mousedown",i=>{if(n.eventPhase===G.All){t(i);return}be(i.eventPhase)===n.eventPhase&&t(i)},{passive:!0}),o&&this.currentTarget.addEventListener("mousemove",o),r&&this.currentTarget.addEventListener("mouseup",i=>{r(i)})}removeEventListeners({onStart:t,onMove:n,onEnd:o}){t&&this.currentTarget.removeEventListener("touchstart",t),o&&this.currentTarget.removeEventListener("touchend",o),n&&this.currentTarget.removeEventListener("touchmove",n),t&&this.currentTarget.removeEventListener("mousedown",t),n&&this.currentTarget.removeEventListener("mousemove",n),o&&this.currentTarget.removeEventListener("mouseup",o)}getCoordinates(t){if(t.type==="touchstart"||t.type==="mousedown"){if("touches"in t)return{x:t.touches[0].clientX,y:t.touches[0].clientY};if(t instanceof MouseEvent)return{x:t.clientX,y:t.clientY}}if(t.type==="touchend"||t.type==="mouseup"||t.type==="mousemove"||t.type==="touchmove"){if("touches"in t)return{x:t.changedTouches[0].clientX,y:t.changedTouches[0].clientY};if(t instanceof MouseEvent)return{x:t.clientX,y:t.clientY}}return{x:0,y:0}}}function He(e){const t=e;return`${t} ${t} 0px 0px`}function _e(e,t){const n=Xe(e);qe(n),n.bottomSheetContainer.style.width=e.width;const o=document.createElement("div");o.innerHTML=e.content??"";const r=window.innerHeight;n.bottomSheetContainer.style.maxHeight=`${r}px`,n.bottomSheetContentWrapper.appendChild(o);const i=ze({bottomSheetElements:n,bottomSheetProps:e,options:t});return e.rootStyle&&Object.assign(n.bottomSheetRoot.style,e.rootStyle),e.backdropStyle&&Object.assign(n.bottomSheetBackdrop.style,e.backdropStyle),e.containerGapFillerStyle&&Object.assign(n.bottomSheetContainer.style,e.containerStyle),e.containerStyle&&Object.assign(n.bottomSheetContainerGapFiller.style,e.containerGapFillerStyle),e.handleStyle&&Object.assign(n.bottomSheetHandleBar.style,e.handleStyle),e.contentWrapperStyle&&Object.assign(n.bottomSheetContentWrapper.style,e.contentWrapperStyle),{elements:n,eventHandlers:i}}function Xe(e){const t=P("dialog",W([T.Root,re.Dialog,e.rootClass]),T.Root);t.ariaLabel=e.ariaLabel;const n=P("section",W([T.Container,e.containerClass]),T.Container);e.containerBorderRadius&&(n.style.borderRadius=He(e.containerBorderRadius));const o=P("div",T.GapFiller,T.GapFiller);e.containerBackgroundColor&&(n.style.backgroundColor=e.containerBackgroundColor,o.style.backgroundColor=e.containerBackgroundColor);const r=P("button",W([T.Handle,re.Button,e.shouldShowHandle?null:J.Hidden,e.handleClass]),T.Handle);r.setAttribute("type","button"),r.ariaLabel="bottom sheet close button";const i=P("span",W([T.HandleBar,e.shouldShowHandle?null:J.Hidden]),T.HandleBar),a=P("article",W([T.ContentWrapper,e.contentWrapperClass]),T.ContentWrapper),c=P("div",W([T.Backdrop,e.backdropClass,J.Hidden]),T.Backdrop);return e.backdropColor&&(c.style.backgroundColor=e.backdropColor),e.backDropTransition&&(c.style.transition=e.backDropTransition),{bottomSheetRoot:t,bottomSheetBackdrop:c,bottomSheetContainer:n,bottomSheetHandle:r,bottomSheetHandleBar:i,bottomSheetContentWrapper:a,bottomSheetContainerGapFiller:o}}function qe({bottomSheetRoot:e,bottomSheetContainer:t,bottomSheetHandle:n,bottomSheetHandleBar:o,bottomSheetContentWrapper:r,bottomSheetContainerGapFiller:i}){e.appendChild(t),n.appendChild(o),t.appendChild(n),t.appendChild(r),t.appendChild(i)}function ze({bottomSheetElements:e,bottomSheetProps:t,options:n}){const{bottomSheetRoot:o,bottomSheetContainer:r,bottomSheetHandle:i,bottomSheetContainerGapFiller:a,bottomSheetContentWrapper:c,bottomSheetBackdrop:u}=e,{animationFrame:h}=n,s=new q(i),m=new q(c),C=new q(a),l=t.dragTriggers.reduce((O,y)=>{const v=o.querySelectorAll(y);if(!v.length)return O;const p=Array.from(v).map(d=>d instanceof HTMLElement?new q(d):null).filter(d=>!!d);return[...O,...p]},[]),E=new q(window),f=Ne(E,r,t,n.draggingState),S=je(E,r,t,n.draggingState,h),w=Ue(E,r,t,n.draggingState,h,n.onClose,n.bottomSheetState);function B(O){O.target instanceof Element&&!o.contains(O.target)&&n.onClose()}function H(O){We(n.draggingState,O.target,e.bottomSheetContentWrapper)}function Y(O){const y=O??t;y.draggable&&(s.addEventListeners({onStart:H}),l.forEach(v=>{v.addEventListeners({onStart:H,onStartOptions:{eventPhase:G.Target}})})),y.draggable&&y.backgroundDraggable&&(m.addEventListeners({onStart:H,onStartOptions:{eventPhase:G.Target}}),C.addEventListeners({onStart:H})),y.draggable&&E.addEventListeners({onStart:f,onMove:S,onEnd:w}),y.draggable&&window.document.addEventListener("keyup",v=>{v.key==="Escape"&&n.onClose()}),i.addEventListener("keyup",v=>{if(v.key==="ArrowUp"){n.moveUp();return}if(v.key==="ArrowDown"){n.moveDown();return}if(v.shiftKey&&v.key==="Tab"){const p=F(e.bottomSheetContentWrapper);Ye(p)}})}function $(){t.shouldCloseOnOutsideClick?u.addEventListener("click",B):u.style.pointerEvents="none"}function _(){u.removeEventListener("click",B)}function F(O){let y=[...Array.from(O.childNodes).reverse()];for(;y.length;){const v=y.shift();if(Fe(v))return v;v&&(y=[...y,...Array.from(v.childNodes).reverse()])}return null}function I(){s.removeEventListeners({onStart:H}),m.removeEventListeners({onStart:H}),C.removeEventListeners({onStart:H}),l.forEach(O=>{O.removeEventListeners({onStart:H})}),E.removeEventListeners({onStart:f,onMove:S,onEnd:w})}return{attachEventListeners:Y,clearEventListeners:I,attacheOnOpenEventListeners:$,clearOnOpenEventListeners:_}}class Ve{constructor(){K(this,"animationId"),K(this,"isInProgress"),K(this,"startedAt"),this.animationId=null,this.isInProgress=!1,this.startedAt=null}start(t,n,o=!1){this.isInProgress=!0;const r=i=>{this.startedAt||(this.startedAt=i);const a=i-this.startedAt,c=n===0?1:Z(a/n,2),u=c>=1&&!o;t(c),u?this.stop():this.animationId=requestAnimationFrame(r)};this.animationId=requestAnimationFrame(r)}stop(){this.isInProgress=!1,this.startedAt=null,A(this.animationId)&&cancelAnimationFrame(this.animationId)}}function Ke(e){const{startY:t,endY:n,bottomSheetContainer:o,animationFrame:r,onEnd:i,animationTimingFunction:a,animationDuration:c}=e,u=Ce(t,n);r.stop();let h=!1;r.start(s=>{ee(o,{y:t+u*a(s)}),!h&&s>=1&&(i==null||i(),h=!0)},c)}const se=(e,t)=>n=>{Ke({...n,animationTimingFunction:e,animationDuration:t})},j={TOP:"top",MIDDLE:"middle",CONTENT_HEIGHT:"content-height",CLOSED:"closed"};function Je(e){return!(!A(e)||e>1||e<0)}function Qe(e,t){const n={set(o,r,i,a){return t(r,i),Reflect.set(o,r,i,a)}};return new Proxy(e,n)}function Ze(...e){console.error(e)}const N={EASE:"ease",EASE_IN:"ease-in",EASE_OUT:"ease-out",EASE_IN_OUT:"ease-in-out",SPRING:"spring"};function et(e){for(const t of Object.values(N))if(t===e)return!0;return!1}function Oe(e){return!!(e instanceof Object&&"p1x"in e&&"p1y"in e&&"p2x"in e&&"p2y"in e&&A(e.p1x)&&A(e.p1y)&&A(e.p2x)&&A(e.p2y))}function U(e,t,n,o){return function(c){return a(r(c))};function r(c){let u=0,h=1,s=c,m;if(c===0||c===1)return c;for(;u<h;){if(m=i(s),Math.abs(m-c)<.001)return s;c>m?u=s:h=s,s=(h+u)/2}return s}function i(c){return 3*e*c*Math.pow(1-c,2)+3*n*Math.pow(c,2)*(1-c)+Math.pow(c,3)}function a(c){return 3*t*c*Math.pow(1-c,2)+3*o*Math.pow(c,2)*(1-c)+Math.pow(c,3)}}const ge=U(.25,.1,.25,1),tt=U(.42,0,1,1),Le=U(.42,0,.58,1),nt=U(.4,.1,.6,1),ot=U(.45,1.5,.55,1);function rt(e){switch(e){case N.EASE:return ge;case N.EASE_IN:return tt;case N.EASE_OUT:return Le;case N.EASE_IN_OUT:return nt;case N.SPRING:return ot;default:return ge}}function Se(e){return typeof e=="boolean"}const at={ariaLabel:"Bottom sheet",content:"",defaultPosition:j.CONTENT_HEIGHT,marginTop:20,snapPoints:[],width:"92%",dragTriggers:[],beforeOpen:()=>{},afterOpen:()=>{},beforeClose:()=>{},afterClose:()=>{},onDragStart:()=>{},onDragMove:()=>{},onDragEnd:()=>{},expandable:!0,preventClosing:!1,draggable:!0,backgroundDraggable:!0,shouldCloseOnOutsideClick:!0,shouldShowBackdrop:!0,shouldShowHandle:!0,backDropTransition:null,backdropColor:null,containerBackgroundColor:null,containerBorderRadius:null,rootClass:null,containerClass:null,handleClass:null,contentWrapperClass:null,backdropClass:null,draggingAnimationTimings:"ease-in-out",draggingAnimationDuration:180,rootStyle:{},containerStyle:{},handleStyle:{},contentWrapperStyle:{},backdropStyle:{},containerGapFillerStyle:{}};function it(e){const t={...at},n=Object.entries(e).reduce((o,r)=>{const[i,a]=r;return ie(a)&&(o[i]=a),o},{});return{...t,...n}}function ce(e){if(Oe(e)){const{p1x:t,p1y:n,p2x:o,p2y:r}=e;return U(t,n,o,r)}return et(e)?rt(e):Le}function st(e,t,n,o){function r(i,a){switch(i){case"content":x(a)&&(e.bottomSheetContentWrapper.innerHTML=a);break;case"width":x(a)&&(e.bottomSheetContainer.style.width=a);break;case"shouldShowHandle":Se(a)||Q(e.bottomSheetHandle,!1);break;case"shouldShowBackdrop":Se(a)||Q(e.bottomSheetBackdrop,!1);break;case"containerBorderRadius":x(a)&&(e.bottomSheetContainer.style.borderRadius=He(a));break;case"containerBackgroundColor":x(a)&&(e.bottomSheetContainer.style.backgroundColor=a,e.bottomSheetContainerGapFiller.style.backgroundColor=a);break;case"backdropColor":x(a)&&(e.bottomSheetBackdrop.style.backgroundColor=a);break;case"backDropTransition":x(a)&&(e.bottomSheetBackdrop.style.transition=a);break;case"rootClass":if(!x(a))return;X(e.bottomSheetRoot,n.rootClass,a);break;case"containerClass":if(!x(a))return;X(e.bottomSheetContainer,n.containerClass,a);break;case"handleClass":if(!x(a))return;X(e.bottomSheetHandle,n.handleClass,a);break;case"contentWrapperClass":if(!x(a))return;X(e.bottomSheetContentWrapper,n.contentWrapperClass,a);break;case"backdropClass":if(!x(a))return;X(e.bottomSheetBackdrop,n.backdropClass,a);break;case"expandable":o.clearEventListeners(),o.attachEventListeners(n);break;case"preventClosing":o.clearEventListeners(),o.attachEventListeners(n);break;case"draggable":o.clearEventListeners(),o.attachEventListeners(n);break;case"draggingAnimationTimings":if(Oe(a)){const c=ce(a),u=se(c,n.draggingAnimationDuration);t.translateContainer=u}break;case"draggingAnimationDuration":if(A(a)){const c=ce(n.draggingAnimationTimings),u=se(c,a);t.translateContainer=u}break;case"rootStyle":n.rootStyle&&Object.assign(e.bottomSheetRoot.style,n.rootStyle);break;case"backdropStyle":n.backdropStyle&&Object.assign(e.bottomSheetBackdrop.style,n.backdropStyle);break;case"containerStyle":n.containerStyle&&Object.assign(e.bottomSheetContainer.style,n.containerStyle);break;case"containerGapFillerStyle":n.containerGapFillerStyle&&Object.assign(e.bottomSheetContainerGapFiller.style,n.containerGapFillerStyle);break;case"handleStyle":n.handleStyle&&Object.assign(e.bottomSheetHandleBar.style,n.handleStyle);break;case"contentWrapperStyle":n.contentWrapperStyle&&Object.assign(e.bottomSheetContentWrapper.style,n.contentWrapperStyle);break}}return r}function ct(e){const t=it(e),n=ce(e.draggingAnimationTimings),o={isMounted:!1,translateContainer:se(n,t.draggingAnimationDuration)},r={startY:null,containerStartTranslate:{x:0,y:0},isDragging:!1,originalDocumentOverflowY:null,originalDocumentOverscrollBehavior:null};function i(){r.originalDocumentOverflowY&&r.originalDocumentOverflowY!=="hidden"&&(document.body.style.overflowY=r.originalDocumentOverflowY),r.originalDocumentOverscrollBehavior&&(document.body.style.position=r.originalDocumentOverscrollBehavior)}const a=new Ve,c={animationFrame:a,onClose:w,bottomSheetState:o,draggingState:r,snapTo:v,moveUp:O,moveDown:y},{elements:u,eventHandlers:h}=_e(t,c),s=Qe(t,st(u,o,t,h)),{bottomSheetBackdrop:m,bottomSheetRoot:C,bottomSheetContainer:l}=u,E=p=>{const d=p??window.document.body;d.appendChild(C),d.appendChild(m);const b=window.innerHeight;ee(l,{y:b}),h.attachEventListeners(),o.isMounted=!0},f=()=>{h.clearEventListeners(),Object.values(u).forEach(p=>{p.remove()}),i(),o.isMounted=!1},S=()=>{var p;if(B()||Ze('Bottom Sheet is not mounted yet. call the "mount" method first.'),(p=e.beforeOpen)==null||p.call(e),H())return;ne(m,!0),s.shouldShowBackdrop||V(m,"transparent"),ne([l],!0),ee(l,{y:l.clientHeight});const d=window.innerHeight,b=pe(d,l.clientHeight,s.marginTop,s.defaultPosition),g=M(l).y;o.translateContainer({startY:g,endY:b,animationFrame:a,bottomSheetContainer:l,onEnd:e.afterOpen});const L=document.body.style.overflowY;r.originalDocumentOverflowY=L||"initial";const D=document.body.style.overscrollBehavior;r.originalDocumentOverscrollBehavior=D||"initial",document.body.style.overflow="hidden",document.body.style.overscrollBehavior="contain",u.bottomSheetHandle.focus(),h.attacheOnOpenEventListeners()};function w(){var p;if(Y())return;(p=e.beforeClose)==null||p.call(e);const d=M(l).y,b=l.clientHeight;o.translateContainer({startY:d,endY:b,animationFrame:a,bottomSheetContainer:l,onEnd:()=>{var g;(g=e.afterClose)==null||g.call(e),ne([m,l],!1),h.clearOnOpenEventListeners()}}),i()}function B(){return o.isMounted}function H(){const p=M(l).y,d=window.innerHeight,b=l.clientHeight>=d?d:l.clientHeight;return p<=b}function Y(){return!H()}function $(){const p=M(l).y,d=l.clientHeight,b=window.innerHeight;if(p<=5&&p>=-5)return j.CONTENT_HEIGHT;const g=d-p;if(g===b/2)return j.MIDDLE;const L=b-s.marginTop,D=10;return g<=L+D&&g>=L-D?j.TOP:j.CLOSED}function _(){return l.clientHeight}function F(p){if(!H())return;const d=M(l).y,b=l.clientHeight-d,g=window.innerHeight-p,L=Ie(b,g),D=z(b,g);o.translateContainer({startY:d,endY:d+(L.isUp?-D:D),animationFrame:a,bottomSheetContainer:l})}function I(p,{viewportHeight:d,visibleHeight:b}){let g=null;for(const L of p){const D=L*d,R=z(b,D);(g===null||R<g)&&(g=R)}return{minOffset:g}}function O(){const p=[...s.snapPoints].reverse(),d=M(l).y,b=l.clientHeight,g=b-d;if(!s.expandable&&g>=b)return;const L=window.innerHeight,D=he("above",{visibleHeight:g,viewportHeight:L},p),{minOffset:R}=I(D,{visibleHeight:g,viewportHeight:L});if(R===null&&g<L-s.marginTop){o.translateContainer({startY:d,endY:pe(L,b,s.marginTop,"top"),animationFrame:a,bottomSheetContainer:l});return}A(R)&&o.translateContainer({startY:d,endY:d-R,animationFrame:a,bottomSheetContainer:l})}function y(){const p=M(l).y,d=l.clientHeight-p;if(d<1)return;const b=window.innerHeight,g=he("below",{visibleHeight:d,viewportHeight:b},s.snapPoints),{minOffset:L}=I(g,{visibleHeight:d,viewportHeight:b});A(L)&&o.translateContainer({startY:p,endY:p+L,animationFrame:a,bottomSheetContainer:l})}function v(p){const d=window.innerHeight;if(!Je(p))return;const b=Z(d*p,2);F(b)}return{props:s,elements:u,mount:E,unmount:f,open:S,close:w,getIsMounted:B,getIsOpen:H,getIsClosed:Y,getPosition:$,getHeight:_,moveTo:F,snapTo:v}}function le(){return{elements:{bottomSheetRoot:void 0,bottomSheetBackdrop:void 0,bottomSheetContainer:void 0,bottomSheetHandle:void 0,bottomSheetHandleBar:void 0,bottomSheetContentWrapper:void 0,bottomSheetContainerGapFiller:void 0},mount:()=>{},unmount:()=>{},open:()=>{},close:()=>{},getIsMounted:()=>!1,getHeight:()=>0,getIsOpen:()=>!1,getIsClosed:()=>!0,getPosition:()=>j.CLOSED,moveTo:()=>{},snapTo:()=>{},props:{content:""}}}const lt=le(),ut=k.forwardRef(function(t,n){const{children:o,isOpen:r,setIsOpen:i,afterClose:a,mountingPointRef:c,...u}=t,h=k.useRef(lt),[s,m]=k.useState(h.current);k.useImperativeHandle(n,()=>s,[s]);const C=k.useCallback(()=>{i(!1),a==null||a()},[a]);k.useEffect(()=>{r?s.open():s.close()},[r]);const l=k.useRef(null);return k.useEffect(function(){var w;if(c&&!c.current)return;const f=Be((w=t.mountingPointRef)==null?void 0:w.current)?t.mountingPointRef.current:window.document.body;if(!f||s.getIsMounted())return;const S=ct({content:"",...u,afterClose:C});return S.mount(f),l.current=S.elements.bottomSheetContentWrapper??null,h.current=S,m(S),()=>{s.unmount()}},[t.mountingPointRef,u,C]),k.useEffect(function(){Object.assign(h.current.props,{...u}),m(h.current)},[u]),k.useEffect(function(){return()=>{h.current.unmount()}},[]),l.current?xe.createPortal(t.children,l.current):null}),dt=le();function pt(e={}){const t=k.useRef(dt),[n,o]=k.useState(!1),[r,i]=k.useState(t.current);k.useEffect(()=>{i(t.current)},[t.current]);const{beforeOpen:a,afterOpen:c,beforeClose:u,afterClose:h,onDragStart:s,onDragMove:m,onDragEnd:C,...l}=e,E=()=>{a==null||a()},f=()=>{c==null||c(),o(!0)},S=()=>{u==null||u()},w=()=>{h==null||h(),o(!1)},B=()=>{s==null||s()},H=(y,v)=>{m==null||m(y,v)},Y=()=>{C==null||C()},$=k.useMemo(()=>({ref:t,isOpen:n,setIsOpen:o,beforeOpen:E,afterOpen:f,beforeClose:S,afterClose:w,onDragStart:B,onDragMove:H,onDragEnd:Y,...l}),[t.current,n,o,e]),_=k.useCallback(()=>{o(!0)},[o]),F=k.useCallback(()=>{o(!0)},[o]),I=k.useCallback((...y)=>{r.moveTo(...y)},[r]),O=k.useCallback((...y)=>{r.snapTo(...y)},[r]);return{props:$,instance:r,isOpen:n,setIsOpen:o,open:_,close:F,moveTo:I,snapTo:O}}exports.BottomSheet=ut;exports.createPlaceholderBottomSheet=le;exports.useBottomSheet=pt;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const w=require("react"),xt=require("react-dom");function Bt(t){return t!=null}(function(){try{if(typeof document<"u"){var t=document.createElement("style");t.appendChild(document.createTextNode('.pbs-root{position:fixed;left:0;bottom:0;display:flex;flex-direction:column;align-items:center;justify-content:flex-start;width:100%;height:fit-content;max-height:100vh;z-index:2}.pbs-dialog-reset{background-color:transparent;color:inherit;border:none;outline:none;padding:0;margin:0}.pbs-backdrop{position:fixed;top:0;left:0;width:100%;height:100%;background-color:transparent;z-index:1;transition:background-color .2s ease-out}.pbs-backdrop.hidden{visibility:hidden}.pbs-backdrop.open{background-color:#454545b3}.pbs-backdrop.transparent{background-color:transparent}.pbs-container{--pbs-container-background-color: rgb(240, 240, 240);background-color:var(--pbs-container-background-color);position:relative;display:none;flex-direction:column;align-items:center;justify-content:flex-start;width:92%;height:fit-content;max-height:100vh;border-radius:10px 10px 0 0}.pbs-container.open{display:flex}.pbs-container .pbs-gap-filler{position:absolute;bottom:calc(-100vh + .5px);left:0;background-color:var(--pbs-container-background-color);content:"";width:100%;height:100vh}.pbs-handle{position:relative;display:flex;align-items:center;justify-content:center;width:100%;height:30px;cursor:pointer}.pbs-handle.hidden{display:none}.pbs-button-reset{background-color:transparent;-webkit-appearance:none;-moz-appearance:none;appearance:none;outline:none;border:none}button:focus.pbs-button-reset{outline:none}.pbs-handle-bar{background-color:#a8a8a8;position:relative;width:12%;height:7px;border-radius:12px}.pbs-handle-bar.hidden{display:none}.pbs-content-wrapper{position:relative;width:100%;height:fit-content;max-height:100%;overflow-y:scroll}.pbs-content-wrapper::-webkit-scrollbar{display:none}.example{-ms-overflow-style:none;scrollbar-width:none}')),document.head.appendChild(t)}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();var At=Object.defineProperty,Dt=(t,e,n)=>e in t?At(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,K=(t,e,n)=>Dt(t,typeof e!="symbol"?e+"":e,n);function x(t){return typeof t=="string"}function Mt(t,e){return t.classList.contains(et(e))}function V(t,e){t.classList.add(et(e))}function ot(t,e){t.classList.remove(et(e))}function X(t,e,n){x(n)&&(x(e)&&ot(t,e),V(t,n))}function et(t){return x(t)?t.trim().replace(/\./g,""):""}function W(t){return t.map(e=>et(e)).filter(Boolean).join(" ")}function Pt(t){return t.map(e=>e==null?void 0:e.trim()).filter(Boolean).map(e=>`.${e}`).join(" ")}const ut="open",dt="hidden";function nt(t,e){const n=e;if(Array.isArray(t)){t.forEach(o=>{Q(o,n),o.setAttribute("aria-modal",n?"true":"false")});return}Q(t,n),t.setAttribute("aria-modal",n?"true":"false")}function Q(t,e){e?(V(t,ut),ot(t,dt)):(V(t,dt),ot(t,ut))}function St(t){return t instanceof HTMLElement}function A(t){return typeof t=="number"&&!Number.isNaN(t)}function Yt(t){St(t)&&t.focus()}function Ft(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),r=t instanceof HTMLAnchorElement&&t.href!==""||t instanceof HTMLAreaElement&&t.href!=="";return o||r||n>-1}var T=(t=>(t.Backdrop="pbs-backdrop",t.Root="pbs-root",t.Container="pbs-container",t.GapFiller="pbs-gap-filler",t.Handle="pbs-handle",t.HandleBar="pbs-handle-bar",t.ContentWrapper="pbs-content-wrapper",t))(T||{}),rt=(t=>(t.Button="pbs-button-reset",t.Dialog="pbs-dialog-reset",t))(rt||{}),J=(t=>(t.Hidden="hidden",t))(J||{});function P(t,e,n){const o=document.createElement(t);return e.split(" ").forEach(r=>{V(o,r)}),x(n)&&o.setAttribute("data-testid",n),o}Pt([T.Root,T.ContentWrapper]);function pt(t,e,n,o){switch(o){case"content-height":return e>=t?Et(t,e,n):0;case"middle":return-(t/2-e);case"top":return-(t-e)+n;default:return 0}}function yt(t,e){const n=e<t,o=e>t;return{isUp:n,isDown:o,stayedSame:e===t}}function Ct(t,e){return e<t?-(t-e):e-t}function z(t,e){return t>e?t-e:e-t}function 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(r=>{const i=r*e.viewportHeight;return o?e.visibleHeight<i:e.visibleHeight>i})}function Et(t,e,n){return-(t-e)+n}function mt(t){return Number(t.replace("px",""))}function Z(t,...e){return Number(t.toFixed(...e))}function wt(t){const e=/(?<type>\w+)\((?<values>[^)]+)\)/g,n=[];let o;for(;(o=e.exec(t))!==null;){const r=o[1],i=o[2].split(",").map(a=>a.trim());n.push({type:r,values:i})}return n}function Rt(t){const e=t.style.transform,n=wt(e);return{transform:e,transformValues:n}}function kt(t,e){return t.find(o=>o.type.startsWith(e))||null}const at="translate";function M(t){const e=t.style.transform,n=wt(e),o=kt(n,at);return Tt(o??{type:at,values:[]})}function tt(t,{x:e,y:n}){const{transform:o,transformValues:r}=Rt(t),i=kt(r,at);if(i){const a=Tt(i);t.style.transform=`translate(${e??a.x??0}px,${n??a.y??0}px)`;return}if(o){t.style.transform=`${o}, translate(${e??0}px,${n??0}px)`;return}t.style.transform=`translate(${e??0}px,${n??0}px)`}function Tt(t){if(t.type!=="translate")throw new Error(`Could not get coordinates from ${t.type}, since is not translate.`);const e=t.values[0],n=t.values[1];return{x:mt(e)??0,y:mt(n)??0}}function it(t){return t!=null}function ft(t,{min:e,max:n}){return it(n)&&t>=n?n:it(e)&&t<=e?e:t}const Wt=(t,e,n)=>{e instanceof HTMLElement&&!Mt(e,T.Handle)&&n.scrollTop>=1||(t.isDragging=!0)},Nt=(t,e,n,o)=>r=>{o.startY=t.getCoordinates(r).y,o.containerStartTranslate=M(e),n.onDragStart()},jt=(t,e,n,o,r)=>i=>{Gt(i,t,n,o,r,e,n.marginTop)};function Gt(t,e,n,o,r,i,a){if(!o.isDragging||!A(o.startY))return;const l=e.getCoordinates(t).y,u=Ct(o.startY,l),h=window.innerHeight,s=i.clientHeight,f=s-(o.containerStartTranslate.y+u);if(f>=h)return;const y=yt(o.startY,l);if(y.isUp&&!n.expandable&&f>=s||n.preventClosing&&f<=s)return;r.start(()=>{tt(i,{y:o.containerStartTranslate.y+u})},0);const c=h-a,C=s-o.containerStartTranslate.y;if(y.isUp){const v=c-C,S=c-f,E=ft(1-Z(S/v,2),{min:0,max:1});n.onDragMove(y,E)}else if(y.isDown){const v=ft(Z(1-f/C,2),{min:0,max:1});n.onDragMove(y,v)}}const Ut=(t,e,n,o,r,i,a)=>l=>{if(!o.isDragging||(o.isDragging=!1,!A(o.startY)))return;n.onDragEnd();const u=o.startY,h=t.getCoordinates(l).y,s=M(e).y,f=yt(u,h),y=window.innerHeight,c=e.clientHeight;if(f.isUp){if(!n.expandable)return;const C=[...n.snapPoints].sort((E,B)=>E-B),v=c+-s;for(const E of C){const B=E*window.innerHeight;if(v<=B){const k=z(v,B);a.translateContainer({startY:s,endY:s-k,animationFrame:r,bottomSheetContainer:e});return}}const S=Et(y,c,n.marginTop);a.translateContainer({startY:s,endY:S,animationFrame:r,bottomSheetContainer:e})}else if(f.isDown){const C=[...n.snapPoints].sort((v,S)=>S-v);for(const v of C){const S=v*window.innerHeight,E=c+-s;if(E>=S){const B=z(E,S);a.translateContainer({startY:s,endY:s+B,animationFrame:r,bottomSheetContainer:e});return}}if(n.preventClosing){const v=c+-s;if(v>=c){const S=z(v,c);a.translateContainer({startY:s,endY:s+S,animationFrame:r,bottomSheetContainer:e})}return}i()}};var G=(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))(G||{});function bt(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:G.All};class q{constructor(e){K(this,"currentTarget"),this.currentTarget=e}addEventListeners({onStart:e,onStartOptions:n=$t,onMove:o,onEnd:r}){this.addTouchEventListeners({onStart:e,onStartOptions:n,onMove:o,onEnd:r}),this.addMouseEventListeners({onStart:e,onStartOptions:n,onMove:o,onEnd:r})}addTouchEventListeners({onStart:e,onStartOptions:n,onMove:o,onEnd:r}){e&&this.currentTarget.addEventListener("touchstart",i=>{if(n.eventPhase===G.All){e(i);return}bt(i.eventPhase)===n.eventPhase&&e(i)},{passive:!0}),o&&this.currentTarget.addEventListener("touchmove",o),r&&this.currentTarget.addEventListener("touchend",r)}addMouseEventListeners({onStart:e,onStartOptions:n,onMove:o,onEnd:r}){e&&this.currentTarget.addEventListener("mousedown",i=>{if(n.eventPhase===G.All){e(i);return}bt(i.eventPhase)===n.eventPhase&&e(i)},{passive:!0}),o&&this.currentTarget.addEventListener("mousemove",o),r&&this.currentTarget.addEventListener("mouseup",i=>{r(i)})}removeEventListeners({onStart:e,onMove:n,onEnd:o}){e&&this.currentTarget.removeEventListener("touchstart",e),o&&this.currentTarget.removeEventListener("touchend",o),n&&this.currentTarget.removeEventListener("touchmove",n),e&&this.currentTarget.removeEventListener("mousedown",e),n&&this.currentTarget.removeEventListener("mousemove",n),o&&this.currentTarget.removeEventListener("mouseup",o)}getCoordinates(e){if(e.type==="touchstart"||e.type==="mousedown"){if("touches"in e)return{x:e.touches[0].clientX,y:e.touches[0].clientY};if(e instanceof MouseEvent)return{x:e.clientX,y:e.clientY}}if(e.type==="touchend"||e.type==="mouseup"||e.type==="mousemove"||e.type==="touchmove"){if("touches"in e)return{x:e.changedTouches[0].clientX,y:e.changedTouches[0].clientY};if(e instanceof MouseEvent)return{x:e.clientX,y:e.clientY}}return{x:0,y:0}}}function Ht(t){const e=t;return`${e} ${e} 0px 0px`}function _t(t,e){const n=Xt(t);qt(n),n.bottomSheetContainer.style.width=t.width;const o=document.createElement("div");o.innerHTML=t.content??"";const r=window.innerHeight;n.bottomSheetContainer.style.maxHeight=`${r}px`,n.bottomSheetContentWrapper.appendChild(o);const i=zt({bottomSheetElements:n,bottomSheetProps:t,options:e});return t.rootStyle&&Object.assign(n.bottomSheetRoot.style,t.rootStyle),t.backdropStyle&&Object.assign(n.bottomSheetBackdrop.style,t.backdropStyle),t.containerGapFillerStyle&&Object.assign(n.bottomSheetContainer.style,t.containerStyle),t.containerStyle&&Object.assign(n.bottomSheetContainerGapFiller.style,t.containerGapFillerStyle),t.handleStyle&&Object.assign(n.bottomSheetHandleBar.style,t.handleStyle),t.contentWrapperStyle&&Object.assign(n.bottomSheetContentWrapper.style,t.contentWrapperStyle),{elements:n,eventHandlers:i}}function Xt(t){const e=P("dialog",W([T.Root,rt.Dialog,t.rootClass]),T.Root);e.ariaLabel=t.ariaLabel;const n=P("section",W([T.Container,t.containerClass]),T.Container);t.containerBorderRadius&&(n.style.borderRadius=Ht(t.containerBorderRadius));const o=P("div",T.GapFiller,T.GapFiller);t.containerBackgroundColor&&(n.style.backgroundColor=t.containerBackgroundColor,o.style.backgroundColor=t.containerBackgroundColor);const r=P("button",W([T.Handle,rt.Button,t.shouldShowHandle?null:J.Hidden,t.handleClass]),T.Handle);r.setAttribute("type","button"),r.ariaLabel="bottom sheet close button";const i=P("span",W([T.HandleBar,t.shouldShowHandle?null:J.Hidden]),T.HandleBar),a=P("article",W([T.ContentWrapper,t.contentWrapperClass]),T.ContentWrapper),l=P("div",W([T.Backdrop,t.backdropClass,J.Hidden]),T.Backdrop);return t.backdropColor&&(l.style.backgroundColor=t.backdropColor),t.backDropTransition&&(l.style.transition=t.backDropTransition),{bottomSheetRoot:e,bottomSheetBackdrop:l,bottomSheetContainer:n,bottomSheetHandle:r,bottomSheetHandleBar:i,bottomSheetContentWrapper:a,bottomSheetContainerGapFiller:o}}function qt({bottomSheetRoot:t,bottomSheetContainer:e,bottomSheetHandle:n,bottomSheetHandleBar:o,bottomSheetContentWrapper:r,bottomSheetContainerGapFiller:i}){t.appendChild(e),n.appendChild(o),e.appendChild(n),e.appendChild(r),e.appendChild(i)}function zt({bottomSheetElements:t,bottomSheetProps:e,options:n}){const{bottomSheetRoot:o,bottomSheetContainer:r,bottomSheetHandle:i,bottomSheetContainerGapFiller:a,bottomSheetContentWrapper:l,bottomSheetBackdrop:u}=t,{animationFrame:h}=n,s=new q(i),f=new q(l),y=new q(a);let c=[];const C=new q(window),v=Nt(C,r,e,n.draggingState),S=jt(C,r,e,n.draggingState,h),E=Ut(C,r,e,n.draggingState,h,n.onClose,n.bottomSheetState);function B(H){H.target instanceof Element&&!o.contains(H.target)&&n.onClose()}function k(H){Wt(n.draggingState,H.target,t.bottomSheetContentWrapper)}function Y(H){const L=H??e;L.draggable&&L.backgroundDraggable&&(f.addEventListeners({onStart:k,onStartOptions:{eventPhase:G.Target}}),y.addEventListeners({onStart:k})),L.draggable&&C.addEventListeners({onStart:v,onMove:S,onEnd:E}),L.draggable&&window.document.addEventListener("keyup",b=>{b.key==="Escape"&&n.onClose()}),i.addEventListener("keyup",b=>{if(b.key==="ArrowUp"){n.moveUp();return}if(b.key==="ArrowDown"){n.moveDown();return}if(b.shiftKey&&b.key==="Tab"){const d=F(t.bottomSheetContentWrapper);Yt(d)}})}function $(H){const L=H??e;e.shouldCloseOnOutsideClick&&!e.preventClosing?u.addEventListener("click",B):u.style.pointerEvents="none",L.draggable&&(s.addEventListeners({onStart:k}),c.forEach(b=>{b.removeEventListeners({onStart:k})}),c=e.dragTriggers.reduce((b,d)=>{const p=o.querySelectorAll(d);if(!p.length)return b;const g=Array.from(p).map(m=>m instanceof HTMLElement?new q(m):null).filter(m=>!!m);return[...b,...g]},[]),c.forEach(b=>{b.addEventListeners({onStart:k,onStartOptions:{eventPhase:G.Target}})}))}function _(){u.removeEventListener("click",B)}function F(H){let L=[...Array.from(H.childNodes).reverse()];for(;L.length;){const b=L.shift();if(Ft(b))return b;b&&(L=[...L,...Array.from(b.childNodes).reverse()])}return null}function I(){s.removeEventListeners({onStart:k}),f.removeEventListeners({onStart:k}),y.removeEventListeners({onStart:k}),c.forEach(H=>{H.removeEventListeners({onStart:k})}),C.removeEventListeners({onStart:v,onMove:S,onEnd:E})}return{attachEventListeners:Y,clearEventListeners:I,attacheOnOpenEventListeners:$,clearOnOpenEventListeners:_}}class Vt{constructor(){K(this,"animationId"),K(this,"isInProgress"),K(this,"startedAt"),this.animationId=null,this.isInProgress=!1,this.startedAt=null}start(e,n,o=!1){this.isInProgress=!0;const r=i=>{this.startedAt||(this.startedAt=i);const a=i-this.startedAt,l=n===0?1:Z(a/n,2),u=l>=1&&!o;e(l),u?this.stop():this.animationId=requestAnimationFrame(r)};this.animationId=requestAnimationFrame(r)}stop(){this.isInProgress=!1,this.startedAt=null,A(this.animationId)&&cancelAnimationFrame(this.animationId)}}function Kt(t){const{startY:e,endY:n,bottomSheetContainer:o,animationFrame:r,onEnd:i,animationTimingFunction:a,animationDuration:l}=t,u=Ct(e,n);r.stop();let h=!1;r.start(s=>{tt(o,{y:e+u*a(s)}),!h&&s>=1&&(i==null||i(),h=!0)},l)}const st=(t,e)=>n=>{Kt({...n,animationTimingFunction:t,animationDuration:e})},j={TOP:"top",MIDDLE:"middle",CONTENT_HEIGHT:"content-height",CLOSED:"closed"};function Jt(t){return!(!A(t)||t>1||t<0)}function Qt(t,e){const n={set(o,r,i,a){return e(r,i),Reflect.set(o,r,i,a)}};return new Proxy(t,n)}function Zt(...t){console.error(t)}const N={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(N))if(e===t)return!0;return!1}function Ot(t){return!!(t instanceof Object&&"p1x"in t&&"p1y"in t&&"p2x"in t&&"p2y"in t&&A(t.p1x)&&A(t.p1y)&&A(t.p2x)&&A(t.p2y))}function U(t,e,n,o){return function(l){return a(r(l))};function r(l){let u=0,h=1,s=l,f;if(l===0||l===1)return l;for(;u<h;){if(f=i(s),Math.abs(f-l)<.001)return s;l>f?u=s:h=s,s=(h+u)/2}return s}function i(l){return 3*t*l*Math.pow(1-l,2)+3*n*Math.pow(l,2)*(1-l)+Math.pow(l,3)}function a(l){return 3*e*l*Math.pow(1-l,2)+3*o*Math.pow(l,2)*(1-l)+Math.pow(l,3)}}const gt=U(.25,.1,.25,1),ee=U(.42,0,1,1),Lt=U(.42,0,.58,1),ne=U(.4,.1,.6,1),oe=U(.45,1.5,.55,1);function re(t){switch(t){case N.EASE:return gt;case N.EASE_IN:return ee;case N.EASE_OUT:return Lt;case N.EASE_IN_OUT:return ne;case N.SPRING:return oe;default:return gt}}function vt(t){return typeof t=="boolean"}const ae={ariaLabel:"Bottom sheet",content:"",defaultPosition:j.CONTENT_HEIGHT,marginTop:20,snapPoints:[],width:"92%",dragTriggers:[],beforeOpen:()=>{},afterOpen:()=>{},beforeClose:()=>{},afterClose:()=>{},onDragStart:()=>{},onDragMove:()=>{},onDragEnd:()=>{},expandable:!0,preventClosing:!1,draggable:!0,backgroundDraggable:!0,shouldCloseOnOutsideClick:!0,shouldShowBackdrop:!0,shouldShowHandle:!0,backDropTransition:null,backdropColor:null,containerBackgroundColor:null,containerBorderRadius:null,rootClass:null,containerClass:null,handleClass:null,contentWrapperClass:null,backdropClass:null,draggingAnimationTimings:"ease-in-out",draggingAnimationDuration:180,rootStyle:{},containerStyle:{},handleStyle:{},contentWrapperStyle:{},backdropStyle:{},containerGapFillerStyle:{}};function ie(t){const e={...ae},n=Object.entries(t).reduce((o,r)=>{const[i,a]=r;return it(a)&&(o[i]=a),o},{});return{...e,...n}}function ct(t){if(Ot(t)){const{p1x:e,p1y:n,p2x:o,p2y:r}=t;return U(e,n,o,r)}return te(t)?re(t):Lt}function se(t,e,n,o){function r(i,a){switch(i){case"content":x(a)&&(t.bottomSheetContentWrapper.innerHTML=a);break;case"width":x(a)&&(t.bottomSheetContainer.style.width=a);break;case"shouldShowHandle":vt(a)||Q(t.bottomSheetHandle,!1);break;case"shouldShowBackdrop":vt(a)||Q(t.bottomSheetBackdrop,!1);break;case"containerBorderRadius":x(a)&&(t.bottomSheetContainer.style.borderRadius=Ht(a));break;case"containerBackgroundColor":x(a)&&(t.bottomSheetContainer.style.backgroundColor=a,t.bottomSheetContainerGapFiller.style.backgroundColor=a);break;case"backdropColor":x(a)&&(t.bottomSheetBackdrop.style.backgroundColor=a);break;case"backDropTransition":x(a)&&(t.bottomSheetBackdrop.style.transition=a);break;case"rootClass":if(!x(a))return;X(t.bottomSheetRoot,n.rootClass,a);break;case"containerClass":if(!x(a))return;X(t.bottomSheetContainer,n.containerClass,a);break;case"handleClass":if(!x(a))return;X(t.bottomSheetHandle,n.handleClass,a);break;case"contentWrapperClass":if(!x(a))return;X(t.bottomSheetContentWrapper,n.contentWrapperClass,a);break;case"backdropClass":if(!x(a))return;X(t.bottomSheetBackdrop,n.backdropClass,a);break;case"expandable":o.clearEventListeners(),o.attachEventListeners(n);break;case"preventClosing":o.clearEventListeners(),o.attachEventListeners(n);break;case"draggable":o.clearEventListeners(),o.attachEventListeners(n);break;case"dragTriggers":o.clearEventListeners(),o.attachEventListeners(n);break;case"draggingAnimationTimings":if(Ot(a)){const l=ct(a),u=st(l,n.draggingAnimationDuration);e.translateContainer=u}break;case"draggingAnimationDuration":if(A(a)){const l=ct(n.draggingAnimationTimings),u=st(l,a);e.translateContainer=u}break;case"rootStyle":n.rootStyle&&Object.assign(t.bottomSheetRoot.style,n.rootStyle);break;case"backdropStyle":n.backdropStyle&&Object.assign(t.bottomSheetBackdrop.style,n.backdropStyle);break;case"containerStyle":n.containerStyle&&Object.assign(t.bottomSheetContainer.style,n.containerStyle);break;case"containerGapFillerStyle":n.containerGapFillerStyle&&Object.assign(t.bottomSheetContainerGapFiller.style,n.containerGapFillerStyle);break;case"handleStyle":n.handleStyle&&Object.assign(t.bottomSheetHandleBar.style,n.handleStyle);break;case"contentWrapperStyle":n.contentWrapperStyle&&Object.assign(t.bottomSheetContentWrapper.style,n.contentWrapperStyle);break}}return r}function ce(t){const e=ie(t),n=ct(t.draggingAnimationTimings),o={isMounted:!1,translateContainer:st(n,e.draggingAnimationDuration)},r={startY:null,containerStartTranslate:{x:0,y:0},isDragging:!1,originalDocumentOverflowY:null,originalDocumentOverscrollBehavior:null};function i(){r.originalDocumentOverflowY&&r.originalDocumentOverflowY!=="hidden"&&(document.body.style.overflowY=r.originalDocumentOverflowY),r.originalDocumentOverscrollBehavior&&(document.body.style.position=r.originalDocumentOverscrollBehavior)}const a=new Vt,l={animationFrame:a,onClose:E,bottomSheetState:o,draggingState:r,snapTo:b,moveUp:H,moveDown:L},{elements:u,eventHandlers:h}=_t(e,l),s=Qt(e,se(u,o,e,h)),{bottomSheetBackdrop:f,bottomSheetRoot:y,bottomSheetContainer:c}=u,C=d=>{const p=d??window.document.body;p.appendChild(y),p.appendChild(f);const g=window.innerHeight;tt(c,{y:g}),h.attachEventListeners(),o.isMounted=!0},v=()=>{h.clearEventListeners(),Object.values(u).forEach(d=>{d.remove()}),i(),o.isMounted=!1},S=()=>{var d;if(B()||Zt('Bottom Sheet is not mounted yet. call the "mount" method first.'),(d=t.beforeOpen)==null||d.call(t),k())return;nt(f,!0),s.shouldShowBackdrop||V(f,"transparent"),nt([c],!0),tt(c,{y:c.clientHeight});const p=window.innerHeight,g=pt(p,c.clientHeight,s.marginTop,s.defaultPosition),m=M(c).y;o.translateContainer({startY:m,endY:g,animationFrame:a,bottomSheetContainer:c,onEnd:t.afterOpen});const O=document.body.style.overflowY;r.originalDocumentOverflowY=O||"initial";const D=document.body.style.overscrollBehavior;r.originalDocumentOverscrollBehavior=D||"initial",document.body.style.overflow="hidden",document.body.style.overscrollBehavior="contain",u.bottomSheetHandle.focus(),h.attacheOnOpenEventListeners()};function E(){var d;if(Y())return;(d=t.beforeClose)==null||d.call(t);const p=M(c).y,g=c.clientHeight;o.translateContainer({startY:p,endY:g,animationFrame:a,bottomSheetContainer:c,onEnd:()=>{var m;(m=t.afterClose)==null||m.call(t),nt([f,c],!1),h.clearOnOpenEventListeners()}}),i()}function B(){return o.isMounted}function k(){const d=M(c).y,p=window.innerHeight,g=c.clientHeight>=p?p:c.clientHeight;return d<=g}function Y(){return!k()}function $(){const d=M(c).y,p=c.clientHeight,g=window.innerHeight;if(d<=5&&d>=-5)return j.CONTENT_HEIGHT;const m=p-d;if(m===g/2)return j.MIDDLE;const O=g-s.marginTop,D=10;return m<=O+D&&m>=O-D?j.TOP:j.CLOSED}function _(){return c.clientHeight}function F(d){if(!k())return;const p=M(c).y,g=c.clientHeight-p,m=window.innerHeight-d,O=It(g,m),D=z(g,m);o.translateContainer({startY:p,endY:p+(O.isUp?-D:D),animationFrame:a,bottomSheetContainer:c})}function I(d,{viewportHeight:p,visibleHeight:g}){let m=null;for(const O of d){const D=O*p,R=z(g,D);(m===null||R<m)&&(m=R)}return{minOffset:m}}function H(){const d=[...s.snapPoints].reverse(),p=M(c).y,g=c.clientHeight,m=g-p;if(!s.expandable&&m>=g)return;const O=window.innerHeight,D=ht("above",{visibleHeight:m,viewportHeight:O},d),{minOffset:R}=I(D,{visibleHeight:m,viewportHeight:O});if(R===null&&m<O-s.marginTop){o.translateContainer({startY:p,endY:pt(O,g,s.marginTop,"top"),animationFrame:a,bottomSheetContainer:c});return}A(R)&&o.translateContainer({startY:p,endY:p-R,animationFrame:a,bottomSheetContainer:c})}function L(){const d=M(c).y,p=c.clientHeight-d;if(p<1)return;const g=window.innerHeight,m=ht("below",{visibleHeight:p,viewportHeight:g},s.snapPoints),{minOffset:O}=I(m,{visibleHeight:p,viewportHeight:g});A(O)&&o.translateContainer({startY:d,endY:d+O,animationFrame:a,bottomSheetContainer:c})}function b(d){const p=window.innerHeight;if(!Jt(d))return;const g=Z(p*d,2);F(g)}return{props:s,elements:u,mount:C,unmount:v,open:S,close:E,getIsMounted:B,getIsOpen:k,getIsClosed:Y,getPosition:$,getHeight:_,moveTo:F,snapTo:b}}function lt(){return{elements:{bottomSheetRoot:void 0,bottomSheetBackdrop:void 0,bottomSheetContainer:void 0,bottomSheetHandle:void 0,bottomSheetHandleBar:void 0,bottomSheetContentWrapper:void 0,bottomSheetContainerGapFiller:void 0},mount:()=>{},unmount:()=>{},open:()=>{},close:()=>{},getIsMounted:()=>!1,getHeight:()=>0,getIsOpen:()=>!1,getIsClosed:()=>!0,getPosition:()=>j.CLOSED,moveTo:()=>{},snapTo:()=>{},props:{content:""}}}const le=lt(),ue=w.forwardRef(function(e,n){const{children:o,isOpen:r,setIsOpen:i,afterClose:a,mountingPointRef:l,...u}=e,h=w.useRef(le),[s,f]=w.useState(h.current);w.useImperativeHandle(n,()=>s,[s]);const y=w.useCallback(()=>{i(!1),a==null||a()},[a]);w.useEffect(()=>{r?s.open():s.close()},[r]);const c=w.useRef(null);return w.useEffect(function(){var E;if(l&&!l.current)return;const v=Bt((E=e.mountingPointRef)==null?void 0:E.current)?e.mountingPointRef.current:window.document.body;if(!v||s.getIsMounted())return;const S=ce({content:"",...u,afterClose:y});return S.mount(v),c.current=S.elements.bottomSheetContentWrapper??null,h.current=S,f(S),()=>{s.unmount()}},[e.mountingPointRef,u,y]),w.useEffect(function(){Object.assign(h.current.props,{...u}),f(h.current)},[u]),w.useEffect(function(){return()=>{h.current.unmount()}},[]),c.current?xt.createPortal(e.children,c.current):null}),de=lt();function pe(t={}){const e=w.useRef(de),[n,o]=w.useState(!1),r=!n,[i,a]=w.useState(e.current);w.useEffect(()=>{a(e.current)},[e.current]);const{beforeOpen:l,afterOpen:u,beforeClose:h,afterClose:s,onDragStart:f,onDragMove:y,onDragEnd:c,...C}=t,v=()=>{l==null||l()},S=()=>{u==null||u(),o(!0)},E=()=>{h==null||h()},B=()=>{s==null||s(),o(!1)},k=()=>{f==null||f()},Y=(b,d)=>{y==null||y(b,d)},$=()=>{c==null||c()},_=w.useMemo(()=>({ref:e,isOpen:n,setIsOpen:o,beforeOpen:v,afterOpen:S,beforeClose:E,afterClose:B,onDragStart:k,onDragMove:Y,onDragEnd:$,...C}),[e.current,n,o,t]),F=w.useCallback(()=>{o(!0)},[o]),I=w.useCallback(()=>{o(!1)},[o]),H=w.useCallback((...b)=>{i.moveTo(...b)},[i]),L=w.useCallback((...b)=>{i.snapTo(...b)},[i]);return{props:_,instance:i,isOpen:n,isClosed:r,setIsOpen:o,open:F,close:I,moveTo:H,snapTo:L}}exports.BottomSheet=ue;exports.createPlaceholderBottomSheet=lt;exports.useBottomSheet=pe;
|
|
@@ -222,31 +222,31 @@ const _t = (t, e, n) => {
|
|
|
222
222
|
function qt(t, e, n, o, r, i, a) {
|
|
223
223
|
if (!o.isDragging || !A(o.startY))
|
|
224
224
|
return;
|
|
225
|
-
const
|
|
226
|
-
if (
|
|
225
|
+
const l = e.getCoordinates(t).y, u = wt(o.startY, l), h = window.innerHeight, s = i.clientHeight, f = s - (o.containerStartTranslate.y + u);
|
|
226
|
+
if (f >= h)
|
|
227
227
|
return;
|
|
228
|
-
const
|
|
229
|
-
if (
|
|
228
|
+
const y = Et(o.startY, l);
|
|
229
|
+
if (y.isUp && !n.expandable && f >= s || n.preventClosing && f <= s)
|
|
230
230
|
return;
|
|
231
231
|
r.start(() => {
|
|
232
232
|
et(i, {
|
|
233
233
|
y: o.containerStartTranslate.y + u
|
|
234
234
|
});
|
|
235
235
|
}, 0);
|
|
236
|
-
const
|
|
237
|
-
if (
|
|
238
|
-
const
|
|
239
|
-
1 - tt(S /
|
|
236
|
+
const c = h - a, C = s - o.containerStartTranslate.y;
|
|
237
|
+
if (y.isUp) {
|
|
238
|
+
const v = c - C, S = c - f, E = gt(
|
|
239
|
+
1 - tt(S / v, 2),
|
|
240
240
|
{
|
|
241
241
|
min: 0,
|
|
242
242
|
max: 1
|
|
243
243
|
}
|
|
244
244
|
);
|
|
245
|
-
n.onDragMove(
|
|
246
|
-
} else if (
|
|
247
|
-
const
|
|
245
|
+
n.onDragMove(y, E);
|
|
246
|
+
} else if (y.isDown) {
|
|
247
|
+
const v = gt(
|
|
248
248
|
tt(
|
|
249
|
-
1 -
|
|
249
|
+
1 - f / C,
|
|
250
250
|
2
|
|
251
251
|
),
|
|
252
252
|
{
|
|
@@ -254,30 +254,30 @@ function qt(t, e, n, o, r, i, a) {
|
|
|
254
254
|
max: 1
|
|
255
255
|
}
|
|
256
256
|
);
|
|
257
|
-
n.onDragMove(
|
|
257
|
+
n.onDragMove(y, v);
|
|
258
258
|
}
|
|
259
259
|
}
|
|
260
|
-
const Vt = (t, e, n, o, r, i, a) => (
|
|
260
|
+
const Vt = (t, e, n, o, r, i, a) => (l) => {
|
|
261
261
|
if (!o.isDragging || (o.isDragging = !1, !A(o.startY)))
|
|
262
262
|
return;
|
|
263
263
|
n.onDragEnd();
|
|
264
|
-
const u = o.startY, h = t.getCoordinates(
|
|
265
|
-
if (
|
|
266
|
-
|
|
267
|
-
(w, x) => w - x
|
|
268
|
-
), f = l + -s;
|
|
269
|
-
if (!n.expandable && f >= l)
|
|
264
|
+
const u = o.startY, h = t.getCoordinates(l).y, s = D(e).y, f = Et(u, h), y = window.innerHeight, c = e.clientHeight;
|
|
265
|
+
if (f.isUp) {
|
|
266
|
+
if (!n.expandable)
|
|
270
267
|
return;
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
268
|
+
const C = [...n.snapPoints].sort(
|
|
269
|
+
(E, x) => E - x
|
|
270
|
+
), v = c + -s;
|
|
271
|
+
for (const E of C) {
|
|
272
|
+
const x = E * window.innerHeight;
|
|
273
|
+
if (v <= x) {
|
|
274
|
+
const w = V(
|
|
275
|
+
v,
|
|
276
276
|
x
|
|
277
277
|
);
|
|
278
278
|
a.translateContainer({
|
|
279
279
|
startY: s,
|
|
280
|
-
endY: s -
|
|
280
|
+
endY: s - w,
|
|
281
281
|
animationFrame: r,
|
|
282
282
|
bottomSheetContainer: e
|
|
283
283
|
});
|
|
@@ -285,8 +285,8 @@ const Vt = (t, e, n, o, r, i, a) => (c) => {
|
|
|
285
285
|
}
|
|
286
286
|
}
|
|
287
287
|
const S = kt(
|
|
288
|
-
|
|
289
|
-
|
|
288
|
+
y,
|
|
289
|
+
c,
|
|
290
290
|
n.marginTop
|
|
291
291
|
);
|
|
292
292
|
a.translateContainer({
|
|
@@ -295,15 +295,15 @@ const Vt = (t, e, n, o, r, i, a) => (c) => {
|
|
|
295
295
|
animationFrame: r,
|
|
296
296
|
bottomSheetContainer: e
|
|
297
297
|
});
|
|
298
|
-
} else if (
|
|
299
|
-
const
|
|
300
|
-
(
|
|
298
|
+
} else if (f.isDown) {
|
|
299
|
+
const C = [...n.snapPoints].sort(
|
|
300
|
+
(v, S) => S - v
|
|
301
301
|
);
|
|
302
|
-
for (const
|
|
303
|
-
const S =
|
|
304
|
-
if (
|
|
302
|
+
for (const v of C) {
|
|
303
|
+
const S = v * window.innerHeight, E = c + -s;
|
|
304
|
+
if (E >= S) {
|
|
305
305
|
const x = V(
|
|
306
|
-
|
|
306
|
+
E,
|
|
307
307
|
S
|
|
308
308
|
);
|
|
309
309
|
a.translateContainer({
|
|
@@ -316,9 +316,9 @@ const Vt = (t, e, n, o, r, i, a) => (c) => {
|
|
|
316
316
|
}
|
|
317
317
|
}
|
|
318
318
|
if (n.preventClosing) {
|
|
319
|
-
const
|
|
320
|
-
if (
|
|
321
|
-
const S = V(
|
|
319
|
+
const v = c + -s;
|
|
320
|
+
if (v >= c) {
|
|
321
|
+
const S = V(v, c);
|
|
322
322
|
a.translateContainer({
|
|
323
323
|
startY: s,
|
|
324
324
|
endY: s + S,
|
|
@@ -332,7 +332,7 @@ const Vt = (t, e, n, o, r, i, a) => (c) => {
|
|
|
332
332
|
}
|
|
333
333
|
};
|
|
334
334
|
var j = /* @__PURE__ */ ((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))(j || {});
|
|
335
|
-
function
|
|
335
|
+
function vt(t) {
|
|
336
336
|
switch (t) {
|
|
337
337
|
case 0:
|
|
338
338
|
return 0;
|
|
@@ -374,7 +374,7 @@ class X {
|
|
|
374
374
|
e(i);
|
|
375
375
|
return;
|
|
376
376
|
}
|
|
377
|
-
|
|
377
|
+
vt(i.eventPhase) === n.eventPhase && e(i);
|
|
378
378
|
},
|
|
379
379
|
{
|
|
380
380
|
passive: !0
|
|
@@ -394,7 +394,7 @@ class X {
|
|
|
394
394
|
e(i);
|
|
395
395
|
return;
|
|
396
396
|
}
|
|
397
|
-
|
|
397
|
+
vt(i.eventPhase) === n.eventPhase && e(i);
|
|
398
398
|
},
|
|
399
399
|
{
|
|
400
400
|
passive: !0
|
|
@@ -515,7 +515,7 @@ function Qt(t) {
|
|
|
515
515
|
t.contentWrapperClass
|
|
516
516
|
]),
|
|
517
517
|
k.ContentWrapper
|
|
518
|
-
),
|
|
518
|
+
), l = M(
|
|
519
519
|
"div",
|
|
520
520
|
R([
|
|
521
521
|
k.Backdrop,
|
|
@@ -524,9 +524,9 @@ function Qt(t) {
|
|
|
524
524
|
]),
|
|
525
525
|
k.Backdrop
|
|
526
526
|
);
|
|
527
|
-
return t.backdropColor && (
|
|
527
|
+
return t.backdropColor && (l.style.backgroundColor = t.backdropColor), t.backDropTransition && (l.style.transition = t.backDropTransition), {
|
|
528
528
|
bottomSheetRoot: e,
|
|
529
|
-
bottomSheetBackdrop:
|
|
529
|
+
bottomSheetBackdrop: l,
|
|
530
530
|
bottomSheetContainer: n,
|
|
531
531
|
bottomSheetHandle: r,
|
|
532
532
|
bottomSheetHandleBar: i,
|
|
@@ -554,36 +554,29 @@ function te({
|
|
|
554
554
|
bottomSheetContainer: r,
|
|
555
555
|
bottomSheetHandle: i,
|
|
556
556
|
bottomSheetContainerGapFiller: a,
|
|
557
|
-
bottomSheetContentWrapper:
|
|
557
|
+
bottomSheetContentWrapper: l,
|
|
558
558
|
bottomSheetBackdrop: u
|
|
559
|
-
} = t, { animationFrame: h } = n, s = new X(i),
|
|
560
|
-
|
|
561
|
-
),
|
|
559
|
+
} = t, { animationFrame: h } = n, s = new X(i), f = new X(
|
|
560
|
+
l
|
|
561
|
+
), y = new X(
|
|
562
562
|
a
|
|
563
|
-
)
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
if (!v.length)
|
|
567
|
-
return H;
|
|
568
|
-
const p = Array.from(v).map((d) => d instanceof HTMLElement ? new X(d) : null).filter((d) => !!d);
|
|
569
|
-
return [...H, ...p];
|
|
570
|
-
},
|
|
571
|
-
[]
|
|
572
|
-
), E = new X(
|
|
563
|
+
);
|
|
564
|
+
let c = [];
|
|
565
|
+
const C = new X(
|
|
573
566
|
window
|
|
574
|
-
),
|
|
575
|
-
|
|
567
|
+
), v = Xt(
|
|
568
|
+
C,
|
|
576
569
|
r,
|
|
577
570
|
e,
|
|
578
571
|
n.draggingState
|
|
579
572
|
), S = zt(
|
|
580
|
-
|
|
573
|
+
C,
|
|
581
574
|
r,
|
|
582
575
|
e,
|
|
583
576
|
n.draggingState,
|
|
584
577
|
h
|
|
585
|
-
),
|
|
586
|
-
|
|
578
|
+
), E = Vt(
|
|
579
|
+
C,
|
|
587
580
|
r,
|
|
588
581
|
e,
|
|
589
582
|
n.draggingState,
|
|
@@ -591,91 +584,102 @@ function te({
|
|
|
591
584
|
n.onClose,
|
|
592
585
|
n.bottomSheetState
|
|
593
586
|
);
|
|
594
|
-
function x(
|
|
595
|
-
|
|
587
|
+
function x(T) {
|
|
588
|
+
T.target instanceof Element && !o.contains(T.target) && n.onClose();
|
|
596
589
|
}
|
|
597
|
-
function T
|
|
590
|
+
function w(T) {
|
|
598
591
|
_t(
|
|
599
592
|
n.draggingState,
|
|
600
|
-
|
|
593
|
+
T.target,
|
|
601
594
|
t.bottomSheetContentWrapper
|
|
602
595
|
);
|
|
603
596
|
}
|
|
604
|
-
function Y(
|
|
605
|
-
const
|
|
606
|
-
|
|
607
|
-
onStart:
|
|
608
|
-
}), l.forEach((v) => {
|
|
609
|
-
v.addEventListeners({
|
|
610
|
-
onStart: T,
|
|
611
|
-
onStartOptions: {
|
|
612
|
-
eventPhase: j.Target
|
|
613
|
-
}
|
|
614
|
-
});
|
|
615
|
-
})), y.draggable && y.backgroundDraggable && (m.addEventListeners({
|
|
616
|
-
onStart: T,
|
|
597
|
+
function Y(T) {
|
|
598
|
+
const O = T ?? e;
|
|
599
|
+
O.draggable && O.backgroundDraggable && (f.addEventListeners({
|
|
600
|
+
onStart: w,
|
|
617
601
|
onStartOptions: {
|
|
618
602
|
eventPhase: j.Target
|
|
619
603
|
}
|
|
620
|
-
}),
|
|
621
|
-
onStart:
|
|
622
|
-
})),
|
|
623
|
-
onStart:
|
|
604
|
+
}), y.addEventListeners({
|
|
605
|
+
onStart: w
|
|
606
|
+
})), O.draggable && C.addEventListeners({
|
|
607
|
+
onStart: v,
|
|
624
608
|
onMove: S,
|
|
625
|
-
onEnd:
|
|
626
|
-
}),
|
|
627
|
-
|
|
628
|
-
}), i.addEventListener("keyup", (
|
|
629
|
-
if (
|
|
609
|
+
onEnd: E
|
|
610
|
+
}), O.draggable && window.document.addEventListener("keyup", (b) => {
|
|
611
|
+
b.key === "Escape" && n.onClose();
|
|
612
|
+
}), i.addEventListener("keyup", (b) => {
|
|
613
|
+
if (b.key === "ArrowUp") {
|
|
630
614
|
n.moveUp();
|
|
631
615
|
return;
|
|
632
616
|
}
|
|
633
|
-
if (
|
|
617
|
+
if (b.key === "ArrowDown") {
|
|
634
618
|
n.moveDown();
|
|
635
619
|
return;
|
|
636
620
|
}
|
|
637
|
-
if (
|
|
638
|
-
const
|
|
621
|
+
if (b.shiftKey && b.key === "Tab") {
|
|
622
|
+
const d = P(
|
|
639
623
|
t.bottomSheetContentWrapper
|
|
640
624
|
);
|
|
641
|
-
jt(
|
|
625
|
+
jt(d);
|
|
642
626
|
}
|
|
643
627
|
});
|
|
644
628
|
}
|
|
645
|
-
function U() {
|
|
646
|
-
|
|
629
|
+
function U(T) {
|
|
630
|
+
const O = T ?? e;
|
|
631
|
+
e.shouldCloseOnOutsideClick && !e.preventClosing ? u.addEventListener("click", x) : u.style.pointerEvents = "none", O.draggable && (s.addEventListeners({
|
|
632
|
+
onStart: w
|
|
633
|
+
}), c.forEach((b) => {
|
|
634
|
+
b.removeEventListeners({
|
|
635
|
+
onStart: w
|
|
636
|
+
});
|
|
637
|
+
}), c = e.dragTriggers.reduce((b, d) => {
|
|
638
|
+
const p = o.querySelectorAll(d);
|
|
639
|
+
if (!p.length)
|
|
640
|
+
return b;
|
|
641
|
+
const g = Array.from(p).map((m) => m instanceof HTMLElement ? new X(m) : null).filter((m) => !!m);
|
|
642
|
+
return [...b, ...g];
|
|
643
|
+
}, []), c.forEach((b) => {
|
|
644
|
+
b.addEventListeners({
|
|
645
|
+
onStart: w,
|
|
646
|
+
onStartOptions: {
|
|
647
|
+
eventPhase: j.Target
|
|
648
|
+
}
|
|
649
|
+
});
|
|
650
|
+
}));
|
|
647
651
|
}
|
|
648
652
|
function $() {
|
|
649
653
|
u.removeEventListener("click", x);
|
|
650
654
|
}
|
|
651
|
-
function P(
|
|
652
|
-
let
|
|
653
|
-
for (;
|
|
654
|
-
const
|
|
655
|
-
if (Gt(
|
|
656
|
-
return
|
|
657
|
-
|
|
658
|
-
...
|
|
659
|
-
...Array.from(
|
|
655
|
+
function P(T) {
|
|
656
|
+
let O = [...Array.from(T.childNodes).reverse()];
|
|
657
|
+
for (; O.length; ) {
|
|
658
|
+
const b = O.shift();
|
|
659
|
+
if (Gt(b))
|
|
660
|
+
return b;
|
|
661
|
+
b && (O = [
|
|
662
|
+
...O,
|
|
663
|
+
...Array.from(b.childNodes).reverse()
|
|
660
664
|
]);
|
|
661
665
|
}
|
|
662
666
|
return null;
|
|
663
667
|
}
|
|
664
668
|
function F() {
|
|
665
669
|
s.removeEventListeners({
|
|
666
|
-
onStart:
|
|
667
|
-
}),
|
|
668
|
-
onStart:
|
|
669
|
-
}),
|
|
670
|
-
onStart:
|
|
671
|
-
}),
|
|
672
|
-
|
|
673
|
-
onStart:
|
|
670
|
+
onStart: w
|
|
671
|
+
}), f.removeEventListeners({
|
|
672
|
+
onStart: w
|
|
673
|
+
}), y.removeEventListeners({
|
|
674
|
+
onStart: w
|
|
675
|
+
}), c.forEach((T) => {
|
|
676
|
+
T.removeEventListeners({
|
|
677
|
+
onStart: w
|
|
674
678
|
});
|
|
675
|
-
}),
|
|
676
|
-
onStart:
|
|
679
|
+
}), C.removeEventListeners({
|
|
680
|
+
onStart: v,
|
|
677
681
|
onMove: S,
|
|
678
|
-
onEnd:
|
|
682
|
+
onEnd: E
|
|
679
683
|
});
|
|
680
684
|
}
|
|
681
685
|
return {
|
|
@@ -698,8 +702,8 @@ class ee {
|
|
|
698
702
|
this.isInProgress = !0;
|
|
699
703
|
const r = (i) => {
|
|
700
704
|
this.startedAt || (this.startedAt = i);
|
|
701
|
-
const a = i - this.startedAt,
|
|
702
|
-
e(
|
|
705
|
+
const a = i - this.startedAt, l = n === 0 ? 1 : tt(a / n, 2), u = l >= 1 && !o;
|
|
706
|
+
e(l), u ? this.stop() : this.animationId = requestAnimationFrame(r);
|
|
703
707
|
};
|
|
704
708
|
this.animationId = requestAnimationFrame(r);
|
|
705
709
|
}
|
|
@@ -715,7 +719,7 @@ function ne(t) {
|
|
|
715
719
|
animationFrame: r,
|
|
716
720
|
onEnd: i,
|
|
717
721
|
animationTimingFunction: a,
|
|
718
|
-
animationDuration:
|
|
722
|
+
animationDuration: l
|
|
719
723
|
} = t, u = wt(e, n);
|
|
720
724
|
r.stop();
|
|
721
725
|
let h = !1;
|
|
@@ -723,7 +727,7 @@ function ne(t) {
|
|
|
723
727
|
et(o, {
|
|
724
728
|
y: e + u * a(s)
|
|
725
729
|
}), !h && s >= 1 && (i == null || i(), h = !0);
|
|
726
|
-
},
|
|
730
|
+
}, l);
|
|
727
731
|
}
|
|
728
732
|
const ut = (t, e) => (n) => {
|
|
729
733
|
ne({
|
|
@@ -768,32 +772,32 @@ function xt(t) {
|
|
|
768
772
|
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));
|
|
769
773
|
}
|
|
770
774
|
function G(t, e, n, o) {
|
|
771
|
-
return function(
|
|
772
|
-
return a(r(
|
|
775
|
+
return function(l) {
|
|
776
|
+
return a(r(l));
|
|
773
777
|
};
|
|
774
|
-
function r(
|
|
775
|
-
let u = 0, h = 1, s =
|
|
776
|
-
if (
|
|
777
|
-
return
|
|
778
|
+
function r(l) {
|
|
779
|
+
let u = 0, h = 1, s = l, f;
|
|
780
|
+
if (l === 0 || l === 1)
|
|
781
|
+
return l;
|
|
778
782
|
for (; u < h; ) {
|
|
779
|
-
if (
|
|
783
|
+
if (f = i(s), Math.abs(f - l) < 1e-3)
|
|
780
784
|
return s;
|
|
781
|
-
|
|
785
|
+
l > f ? u = s : h = s, s = (h + u) / 2;
|
|
782
786
|
}
|
|
783
787
|
return s;
|
|
784
788
|
}
|
|
785
|
-
function i(
|
|
786
|
-
return 3 * t *
|
|
789
|
+
function i(l) {
|
|
790
|
+
return 3 * t * l * Math.pow(1 - l, 2) + 3 * n * Math.pow(l, 2) * (1 - l) + Math.pow(l, 3);
|
|
787
791
|
}
|
|
788
|
-
function a(
|
|
789
|
-
return 3 * e *
|
|
792
|
+
function a(l) {
|
|
793
|
+
return 3 * e * l * Math.pow(1 - l, 2) + 3 * o * Math.pow(l, 2) * (1 - l) + Math.pow(l, 3);
|
|
790
794
|
}
|
|
791
795
|
}
|
|
792
|
-
const
|
|
796
|
+
const St = G(0.25, 0.1, 0.25, 1), se = G(0.42, 0, 1, 1), At = G(0.42, 0, 0.58, 1), ce = G(0.4, 0.1, 0.6, 1), le = G(0.45, 1.5, 0.55, 1);
|
|
793
797
|
function ue(t) {
|
|
794
798
|
switch (t) {
|
|
795
799
|
case W.EASE:
|
|
796
|
-
return
|
|
800
|
+
return St;
|
|
797
801
|
case W.EASE_IN:
|
|
798
802
|
return se;
|
|
799
803
|
case W.EASE_OUT:
|
|
@@ -803,7 +807,7 @@ function ue(t) {
|
|
|
803
807
|
case W.SPRING:
|
|
804
808
|
return le;
|
|
805
809
|
default:
|
|
806
|
-
return
|
|
810
|
+
return St;
|
|
807
811
|
}
|
|
808
812
|
}
|
|
809
813
|
function yt(t) {
|
|
@@ -959,10 +963,13 @@ function he(t, e, n, o) {
|
|
|
959
963
|
case "draggable":
|
|
960
964
|
o.clearEventListeners(), o.attachEventListeners(n);
|
|
961
965
|
break;
|
|
966
|
+
case "dragTriggers":
|
|
967
|
+
o.clearEventListeners(), o.attachEventListeners(n);
|
|
968
|
+
break;
|
|
962
969
|
case "draggingAnimationTimings":
|
|
963
970
|
if (xt(a)) {
|
|
964
|
-
const
|
|
965
|
-
|
|
971
|
+
const l = dt(a), u = ut(
|
|
972
|
+
l,
|
|
966
973
|
n.draggingAnimationDuration
|
|
967
974
|
);
|
|
968
975
|
e.translateContainer = u;
|
|
@@ -970,10 +977,10 @@ function he(t, e, n, o) {
|
|
|
970
977
|
break;
|
|
971
978
|
case "draggingAnimationDuration":
|
|
972
979
|
if (A(a)) {
|
|
973
|
-
const
|
|
980
|
+
const l = dt(
|
|
974
981
|
n.draggingAnimationTimings
|
|
975
982
|
), u = ut(
|
|
976
|
-
|
|
983
|
+
l,
|
|
977
984
|
a
|
|
978
985
|
);
|
|
979
986
|
e.translateContainer = u;
|
|
@@ -1041,17 +1048,17 @@ function me(t) {
|
|
|
1041
1048
|
function i() {
|
|
1042
1049
|
r.originalDocumentOverflowY && r.originalDocumentOverflowY !== "hidden" && (document.body.style.overflowY = r.originalDocumentOverflowY), r.originalDocumentOverscrollBehavior && (document.body.style.position = r.originalDocumentOverscrollBehavior);
|
|
1043
1050
|
}
|
|
1044
|
-
const a = new ee(),
|
|
1051
|
+
const a = new ee(), l = {
|
|
1045
1052
|
animationFrame: a,
|
|
1046
|
-
onClose:
|
|
1053
|
+
onClose: E,
|
|
1047
1054
|
bottomSheetState: o,
|
|
1048
1055
|
draggingState: r,
|
|
1049
|
-
snapTo:
|
|
1050
|
-
moveUp:
|
|
1051
|
-
moveDown:
|
|
1056
|
+
snapTo: b,
|
|
1057
|
+
moveUp: T,
|
|
1058
|
+
moveDown: O
|
|
1052
1059
|
}, { elements: u, eventHandlers: h } = Jt(
|
|
1053
1060
|
e,
|
|
1054
|
-
|
|
1061
|
+
l
|
|
1055
1062
|
), s = re(
|
|
1056
1063
|
e,
|
|
1057
1064
|
he(
|
|
@@ -1060,184 +1067,184 @@ function me(t) {
|
|
|
1060
1067
|
e,
|
|
1061
1068
|
h
|
|
1062
1069
|
)
|
|
1063
|
-
), { bottomSheetBackdrop:
|
|
1064
|
-
const
|
|
1065
|
-
|
|
1066
|
-
const
|
|
1067
|
-
et(
|
|
1068
|
-
y:
|
|
1070
|
+
), { bottomSheetBackdrop: f, bottomSheetRoot: y, bottomSheetContainer: c } = u, C = (d) => {
|
|
1071
|
+
const p = d ?? window.document.body;
|
|
1072
|
+
p.appendChild(y), p.appendChild(f);
|
|
1073
|
+
const g = window.innerHeight;
|
|
1074
|
+
et(c, {
|
|
1075
|
+
y: g
|
|
1069
1076
|
}), h.attachEventListeners(), o.isMounted = !0;
|
|
1070
|
-
},
|
|
1071
|
-
h.clearEventListeners(), Object.values(u).forEach((
|
|
1072
|
-
|
|
1077
|
+
}, v = () => {
|
|
1078
|
+
h.clearEventListeners(), Object.values(u).forEach((d) => {
|
|
1079
|
+
d.remove();
|
|
1073
1080
|
}), i(), o.isMounted = !1;
|
|
1074
1081
|
}, S = () => {
|
|
1075
|
-
var
|
|
1082
|
+
var d;
|
|
1076
1083
|
if (x() || ae(
|
|
1077
1084
|
'Bottom Sheet is not mounted yet. call the "mount" method first.'
|
|
1078
|
-
), (
|
|
1085
|
+
), (d = t.beforeOpen) == null || d.call(t), w())
|
|
1079
1086
|
return;
|
|
1080
|
-
ot(
|
|
1081
|
-
y:
|
|
1087
|
+
ot(f, !0), s.shouldShowBackdrop || K(f, "transparent"), ot([c], !0), et(c, {
|
|
1088
|
+
y: c.clientHeight
|
|
1082
1089
|
});
|
|
1083
|
-
const
|
|
1084
|
-
|
|
1085
|
-
|
|
1090
|
+
const p = window.innerHeight, g = mt(
|
|
1091
|
+
p,
|
|
1092
|
+
c.clientHeight,
|
|
1086
1093
|
s.marginTop,
|
|
1087
1094
|
s.defaultPosition
|
|
1088
|
-
),
|
|
1095
|
+
), m = D(c).y;
|
|
1089
1096
|
o.translateContainer({
|
|
1090
|
-
startY:
|
|
1091
|
-
endY:
|
|
1097
|
+
startY: m,
|
|
1098
|
+
endY: g,
|
|
1092
1099
|
animationFrame: a,
|
|
1093
|
-
bottomSheetContainer:
|
|
1100
|
+
bottomSheetContainer: c,
|
|
1094
1101
|
onEnd: t.afterOpen
|
|
1095
1102
|
});
|
|
1096
|
-
const
|
|
1097
|
-
r.originalDocumentOverflowY =
|
|
1103
|
+
const H = document.body.style.overflowY;
|
|
1104
|
+
r.originalDocumentOverflowY = H || "initial";
|
|
1098
1105
|
const B = document.body.style.overscrollBehavior;
|
|
1099
1106
|
r.originalDocumentOverscrollBehavior = B || "initial", document.body.style.overflow = "hidden", document.body.style.overscrollBehavior = "contain", u.bottomSheetHandle.focus(), h.attacheOnOpenEventListeners();
|
|
1100
1107
|
};
|
|
1101
|
-
function
|
|
1102
|
-
var
|
|
1108
|
+
function E() {
|
|
1109
|
+
var d;
|
|
1103
1110
|
if (Y())
|
|
1104
1111
|
return;
|
|
1105
|
-
(
|
|
1106
|
-
const
|
|
1112
|
+
(d = t.beforeClose) == null || d.call(t);
|
|
1113
|
+
const p = D(c).y, g = c.clientHeight;
|
|
1107
1114
|
o.translateContainer({
|
|
1108
|
-
startY:
|
|
1109
|
-
endY:
|
|
1115
|
+
startY: p,
|
|
1116
|
+
endY: g,
|
|
1110
1117
|
animationFrame: a,
|
|
1111
|
-
bottomSheetContainer:
|
|
1118
|
+
bottomSheetContainer: c,
|
|
1112
1119
|
onEnd: () => {
|
|
1113
|
-
var
|
|
1114
|
-
(
|
|
1120
|
+
var m;
|
|
1121
|
+
(m = t.afterClose) == null || m.call(t), ot([f, c], !1), h.clearOnOpenEventListeners();
|
|
1115
1122
|
}
|
|
1116
1123
|
}), i();
|
|
1117
1124
|
}
|
|
1118
1125
|
function x() {
|
|
1119
1126
|
return o.isMounted;
|
|
1120
1127
|
}
|
|
1121
|
-
function
|
|
1122
|
-
const
|
|
1123
|
-
return
|
|
1128
|
+
function w() {
|
|
1129
|
+
const d = D(c).y, p = window.innerHeight, g = c.clientHeight >= p ? p : c.clientHeight;
|
|
1130
|
+
return d <= g;
|
|
1124
1131
|
}
|
|
1125
1132
|
function Y() {
|
|
1126
|
-
return !
|
|
1133
|
+
return !w();
|
|
1127
1134
|
}
|
|
1128
1135
|
function U() {
|
|
1129
|
-
const
|
|
1130
|
-
if (
|
|
1136
|
+
const d = D(c).y, p = c.clientHeight, g = window.innerHeight;
|
|
1137
|
+
if (d <= 5 && d >= -5)
|
|
1131
1138
|
return N.CONTENT_HEIGHT;
|
|
1132
|
-
const
|
|
1133
|
-
if (
|
|
1139
|
+
const m = p - d;
|
|
1140
|
+
if (m === g / 2)
|
|
1134
1141
|
return N.MIDDLE;
|
|
1135
|
-
const
|
|
1136
|
-
return
|
|
1142
|
+
const H = g - s.marginTop, B = 10;
|
|
1143
|
+
return m <= H + B && m >= H - B ? N.TOP : N.CLOSED;
|
|
1137
1144
|
}
|
|
1138
1145
|
function $() {
|
|
1139
|
-
return
|
|
1146
|
+
return c.clientHeight;
|
|
1140
1147
|
}
|
|
1141
|
-
function P(
|
|
1142
|
-
if (!
|
|
1148
|
+
function P(d) {
|
|
1149
|
+
if (!w())
|
|
1143
1150
|
return;
|
|
1144
|
-
const
|
|
1151
|
+
const p = D(c).y, g = c.clientHeight - p, m = window.innerHeight - d, H = Ut(g, m), B = V(g, m);
|
|
1145
1152
|
o.translateContainer({
|
|
1146
|
-
startY:
|
|
1147
|
-
endY:
|
|
1153
|
+
startY: p,
|
|
1154
|
+
endY: p + (H.isUp ? -B : B),
|
|
1148
1155
|
animationFrame: a,
|
|
1149
|
-
bottomSheetContainer:
|
|
1156
|
+
bottomSheetContainer: c
|
|
1150
1157
|
});
|
|
1151
1158
|
}
|
|
1152
|
-
function F(
|
|
1153
|
-
viewportHeight:
|
|
1154
|
-
visibleHeight:
|
|
1159
|
+
function F(d, {
|
|
1160
|
+
viewportHeight: p,
|
|
1161
|
+
visibleHeight: g
|
|
1155
1162
|
}) {
|
|
1156
|
-
let
|
|
1157
|
-
for (const
|
|
1158
|
-
const B =
|
|
1159
|
-
|
|
1163
|
+
let m = null;
|
|
1164
|
+
for (const H of d) {
|
|
1165
|
+
const B = H * p, I = V(
|
|
1166
|
+
g,
|
|
1160
1167
|
B
|
|
1161
1168
|
);
|
|
1162
|
-
(
|
|
1169
|
+
(m === null || I < m) && (m = I);
|
|
1163
1170
|
}
|
|
1164
1171
|
return {
|
|
1165
|
-
minOffset:
|
|
1172
|
+
minOffset: m
|
|
1166
1173
|
};
|
|
1167
1174
|
}
|
|
1168
|
-
function
|
|
1169
|
-
const
|
|
1170
|
-
if (!s.expandable &&
|
|
1175
|
+
function T() {
|
|
1176
|
+
const d = [...s.snapPoints].reverse(), p = D(c).y, g = c.clientHeight, m = g - p;
|
|
1177
|
+
if (!s.expandable && m >= g)
|
|
1171
1178
|
return;
|
|
1172
|
-
const
|
|
1179
|
+
const H = window.innerHeight, B = ft(
|
|
1173
1180
|
"above",
|
|
1174
|
-
{ visibleHeight:
|
|
1175
|
-
|
|
1181
|
+
{ visibleHeight: m, viewportHeight: H },
|
|
1182
|
+
d
|
|
1176
1183
|
), { minOffset: I } = F(B, {
|
|
1177
|
-
visibleHeight:
|
|
1178
|
-
viewportHeight:
|
|
1184
|
+
visibleHeight: m,
|
|
1185
|
+
viewportHeight: H
|
|
1179
1186
|
});
|
|
1180
|
-
if (I === null &&
|
|
1187
|
+
if (I === null && m < H - s.marginTop) {
|
|
1181
1188
|
o.translateContainer({
|
|
1182
|
-
startY:
|
|
1189
|
+
startY: p,
|
|
1183
1190
|
endY: mt(
|
|
1184
|
-
|
|
1185
|
-
|
|
1191
|
+
H,
|
|
1192
|
+
g,
|
|
1186
1193
|
s.marginTop,
|
|
1187
1194
|
"top"
|
|
1188
1195
|
),
|
|
1189
1196
|
animationFrame: a,
|
|
1190
|
-
bottomSheetContainer:
|
|
1197
|
+
bottomSheetContainer: c
|
|
1191
1198
|
});
|
|
1192
1199
|
return;
|
|
1193
1200
|
}
|
|
1194
1201
|
A(I) && o.translateContainer({
|
|
1195
|
-
startY:
|
|
1196
|
-
endY:
|
|
1202
|
+
startY: p,
|
|
1203
|
+
endY: p - I,
|
|
1197
1204
|
animationFrame: a,
|
|
1198
|
-
bottomSheetContainer:
|
|
1205
|
+
bottomSheetContainer: c
|
|
1199
1206
|
});
|
|
1200
1207
|
}
|
|
1201
|
-
function
|
|
1202
|
-
const
|
|
1203
|
-
if (
|
|
1208
|
+
function O() {
|
|
1209
|
+
const d = D(c).y, p = c.clientHeight - d;
|
|
1210
|
+
if (p < 1)
|
|
1204
1211
|
return;
|
|
1205
|
-
const
|
|
1212
|
+
const g = window.innerHeight, m = ft(
|
|
1206
1213
|
"below",
|
|
1207
|
-
{ visibleHeight:
|
|
1214
|
+
{ visibleHeight: p, viewportHeight: g },
|
|
1208
1215
|
s.snapPoints
|
|
1209
|
-
), { minOffset:
|
|
1210
|
-
visibleHeight:
|
|
1211
|
-
viewportHeight:
|
|
1216
|
+
), { minOffset: H } = F(m, {
|
|
1217
|
+
visibleHeight: p,
|
|
1218
|
+
viewportHeight: g
|
|
1212
1219
|
});
|
|
1213
|
-
A(
|
|
1214
|
-
startY:
|
|
1215
|
-
endY:
|
|
1220
|
+
A(H) && o.translateContainer({
|
|
1221
|
+
startY: d,
|
|
1222
|
+
endY: d + H,
|
|
1216
1223
|
animationFrame: a,
|
|
1217
|
-
bottomSheetContainer:
|
|
1224
|
+
bottomSheetContainer: c
|
|
1218
1225
|
});
|
|
1219
1226
|
}
|
|
1220
|
-
function
|
|
1221
|
-
const
|
|
1222
|
-
if (!oe(
|
|
1227
|
+
function b(d) {
|
|
1228
|
+
const p = window.innerHeight;
|
|
1229
|
+
if (!oe(d))
|
|
1223
1230
|
return;
|
|
1224
|
-
const
|
|
1225
|
-
P(
|
|
1231
|
+
const g = tt(p * d, 2);
|
|
1232
|
+
P(g);
|
|
1226
1233
|
}
|
|
1227
1234
|
return {
|
|
1228
1235
|
props: s,
|
|
1229
1236
|
elements: u,
|
|
1230
|
-
mount:
|
|
1231
|
-
unmount:
|
|
1237
|
+
mount: C,
|
|
1238
|
+
unmount: v,
|
|
1232
1239
|
open: S,
|
|
1233
|
-
close:
|
|
1240
|
+
close: E,
|
|
1234
1241
|
getIsMounted: x,
|
|
1235
|
-
getIsOpen:
|
|
1242
|
+
getIsOpen: w,
|
|
1236
1243
|
getIsClosed: Y,
|
|
1237
1244
|
getPosition: U,
|
|
1238
1245
|
getHeight: $,
|
|
1239
1246
|
moveTo: P,
|
|
1240
|
-
snapTo:
|
|
1247
|
+
snapTo: b
|
|
1241
1248
|
};
|
|
1242
1249
|
}
|
|
1243
1250
|
function Bt() {
|
|
@@ -1273,16 +1280,16 @@ function Bt() {
|
|
|
1273
1280
|
}
|
|
1274
1281
|
};
|
|
1275
1282
|
}
|
|
1276
|
-
const fe = Bt(),
|
|
1283
|
+
const fe = Bt(), Se = Dt(
|
|
1277
1284
|
function(e, n) {
|
|
1278
1285
|
const {
|
|
1279
1286
|
children: o,
|
|
1280
1287
|
isOpen: r,
|
|
1281
1288
|
setIsOpen: i,
|
|
1282
1289
|
afterClose: a,
|
|
1283
|
-
mountingPointRef:
|
|
1290
|
+
mountingPointRef: l,
|
|
1284
1291
|
...u
|
|
1285
|
-
} = e, h = rt(fe), [s,
|
|
1292
|
+
} = e, h = rt(fe), [s, f] = at(
|
|
1286
1293
|
h.current
|
|
1287
1294
|
);
|
|
1288
1295
|
Mt(
|
|
@@ -1290,116 +1297,117 @@ const fe = Bt(), ve = Dt(
|
|
|
1290
1297
|
() => s,
|
|
1291
1298
|
[s]
|
|
1292
1299
|
);
|
|
1293
|
-
const
|
|
1300
|
+
const y = z(() => {
|
|
1294
1301
|
i(!1), a == null || a();
|
|
1295
1302
|
}, [a]);
|
|
1296
1303
|
q(() => {
|
|
1297
1304
|
r ? s.open() : s.close();
|
|
1298
1305
|
}, [r]);
|
|
1299
|
-
const
|
|
1306
|
+
const c = rt(null);
|
|
1300
1307
|
return q(
|
|
1301
1308
|
function() {
|
|
1302
|
-
var
|
|
1303
|
-
if (
|
|
1309
|
+
var E;
|
|
1310
|
+
if (l && !l.current)
|
|
1304
1311
|
return;
|
|
1305
|
-
const
|
|
1306
|
-
if (!
|
|
1312
|
+
const v = Ft((E = e.mountingPointRef) == null ? void 0 : E.current) ? e.mountingPointRef.current : window.document.body;
|
|
1313
|
+
if (!v || s.getIsMounted())
|
|
1307
1314
|
return;
|
|
1308
1315
|
const S = me({
|
|
1309
1316
|
content: "",
|
|
1310
1317
|
...u,
|
|
1311
|
-
afterClose:
|
|
1318
|
+
afterClose: y
|
|
1312
1319
|
});
|
|
1313
|
-
return S.mount(
|
|
1320
|
+
return S.mount(v), c.current = S.elements.bottomSheetContentWrapper ?? null, h.current = S, f(S), () => {
|
|
1314
1321
|
s.unmount();
|
|
1315
1322
|
};
|
|
1316
1323
|
},
|
|
1317
|
-
[e.mountingPointRef, u,
|
|
1324
|
+
[e.mountingPointRef, u, y]
|
|
1318
1325
|
), q(
|
|
1319
1326
|
function() {
|
|
1320
1327
|
Object.assign(h.current.props, {
|
|
1321
1328
|
...u
|
|
1322
|
-
}),
|
|
1329
|
+
}), f(h.current);
|
|
1323
1330
|
},
|
|
1324
1331
|
[u]
|
|
1325
1332
|
), q(function() {
|
|
1326
1333
|
return () => {
|
|
1327
1334
|
h.current.unmount();
|
|
1328
1335
|
};
|
|
1329
|
-
}, []),
|
|
1336
|
+
}, []), c.current ? Pt(
|
|
1330
1337
|
e.children,
|
|
1331
|
-
|
|
1338
|
+
c.current
|
|
1332
1339
|
) : null;
|
|
1333
1340
|
}
|
|
1334
1341
|
), be = Bt();
|
|
1335
1342
|
function ye(t = {}) {
|
|
1336
|
-
const e = rt(be), [n, o] = at(!1),
|
|
1343
|
+
const e = rt(be), [n, o] = at(!1), r = !n, [i, a] = at(e.current);
|
|
1337
1344
|
q(() => {
|
|
1338
|
-
|
|
1345
|
+
a(e.current);
|
|
1339
1346
|
}, [e.current]);
|
|
1340
1347
|
const {
|
|
1341
|
-
beforeOpen:
|
|
1342
|
-
afterOpen:
|
|
1343
|
-
beforeClose:
|
|
1344
|
-
afterClose:
|
|
1345
|
-
onDragStart:
|
|
1346
|
-
onDragMove:
|
|
1347
|
-
onDragEnd:
|
|
1348
|
-
...
|
|
1349
|
-
} = t,
|
|
1350
|
-
|
|
1351
|
-
}, f = () => {
|
|
1352
|
-
c == null || c(), o(!0);
|
|
1348
|
+
beforeOpen: l,
|
|
1349
|
+
afterOpen: u,
|
|
1350
|
+
beforeClose: h,
|
|
1351
|
+
afterClose: s,
|
|
1352
|
+
onDragStart: f,
|
|
1353
|
+
onDragMove: y,
|
|
1354
|
+
onDragEnd: c,
|
|
1355
|
+
...C
|
|
1356
|
+
} = t, v = () => {
|
|
1357
|
+
l == null || l();
|
|
1353
1358
|
}, S = () => {
|
|
1354
|
-
u == null || u();
|
|
1355
|
-
},
|
|
1356
|
-
h == null || h()
|
|
1359
|
+
u == null || u(), o(!0);
|
|
1360
|
+
}, E = () => {
|
|
1361
|
+
h == null || h();
|
|
1357
1362
|
}, x = () => {
|
|
1358
|
-
s == null || s();
|
|
1359
|
-
},
|
|
1360
|
-
|
|
1361
|
-
}, Y = () => {
|
|
1362
|
-
|
|
1363
|
-
}, U =
|
|
1363
|
+
s == null || s(), o(!1);
|
|
1364
|
+
}, w = () => {
|
|
1365
|
+
f == null || f();
|
|
1366
|
+
}, Y = (b, d) => {
|
|
1367
|
+
y == null || y(b, d);
|
|
1368
|
+
}, U = () => {
|
|
1369
|
+
c == null || c();
|
|
1370
|
+
}, $ = Yt(() => ({
|
|
1364
1371
|
ref: e,
|
|
1365
1372
|
isOpen: n,
|
|
1366
1373
|
setIsOpen: o,
|
|
1367
|
-
beforeOpen:
|
|
1368
|
-
afterOpen:
|
|
1369
|
-
beforeClose:
|
|
1370
|
-
afterClose:
|
|
1371
|
-
onDragStart:
|
|
1372
|
-
onDragMove:
|
|
1373
|
-
onDragEnd:
|
|
1374
|
-
...
|
|
1375
|
-
}), [e.current, n, o, t]),
|
|
1376
|
-
o(!0);
|
|
1377
|
-
}, [o]), P = z(() => {
|
|
1374
|
+
beforeOpen: v,
|
|
1375
|
+
afterOpen: S,
|
|
1376
|
+
beforeClose: E,
|
|
1377
|
+
afterClose: x,
|
|
1378
|
+
onDragStart: w,
|
|
1379
|
+
onDragMove: Y,
|
|
1380
|
+
onDragEnd: U,
|
|
1381
|
+
...C
|
|
1382
|
+
}), [e.current, n, o, t]), P = z(() => {
|
|
1378
1383
|
o(!0);
|
|
1379
|
-
}, [o]), F = z(
|
|
1380
|
-
(
|
|
1381
|
-
|
|
1384
|
+
}, [o]), F = z(() => {
|
|
1385
|
+
o(!1);
|
|
1386
|
+
}, [o]), T = z(
|
|
1387
|
+
(...b) => {
|
|
1388
|
+
i.moveTo(...b);
|
|
1382
1389
|
},
|
|
1383
|
-
[
|
|
1384
|
-
),
|
|
1385
|
-
(...
|
|
1386
|
-
|
|
1390
|
+
[i]
|
|
1391
|
+
), O = z(
|
|
1392
|
+
(...b) => {
|
|
1393
|
+
i.snapTo(...b);
|
|
1387
1394
|
},
|
|
1388
|
-
[
|
|
1395
|
+
[i]
|
|
1389
1396
|
);
|
|
1390
1397
|
return {
|
|
1391
|
-
props:
|
|
1392
|
-
instance:
|
|
1398
|
+
props: $,
|
|
1399
|
+
instance: i,
|
|
1393
1400
|
isOpen: n,
|
|
1401
|
+
isClosed: r,
|
|
1394
1402
|
setIsOpen: o,
|
|
1395
|
-
open:
|
|
1396
|
-
close:
|
|
1397
|
-
moveTo:
|
|
1398
|
-
snapTo:
|
|
1403
|
+
open: P,
|
|
1404
|
+
close: F,
|
|
1405
|
+
moveTo: T,
|
|
1406
|
+
snapTo: O
|
|
1399
1407
|
};
|
|
1400
1408
|
}
|
|
1401
1409
|
export {
|
|
1402
|
-
|
|
1410
|
+
Se as BottomSheet,
|
|
1403
1411
|
Bt as createPlaceholderBottomSheet,
|
|
1404
1412
|
ye as useBottomSheet
|
|
1405
1413
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(M,g){typeof exports=="object"&&typeof module<"u"?g(exports,require("react"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","react-dom"],g):(M=typeof globalThis<"u"?globalThis:M||self,g(M.BottomSheet={},M.React,M.ReactDOM))})(this,function(M,g,xe){"use strict";function Ae(e){return e!=null}(function(){try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode('.pbs-root{position:fixed;left:0;bottom:0;display:flex;flex-direction:column;align-items:center;justify-content:flex-start;width:100%;height:fit-content;max-height:100vh;z-index:2}.pbs-dialog-reset{background-color:transparent;color:inherit;border:none;outline:none;padding:0;margin:0}.pbs-backdrop{position:fixed;top:0;left:0;width:100%;height:100%;background-color:transparent;z-index:1;transition:background-color .2s ease-out}.pbs-backdrop.hidden{visibility:hidden}.pbs-backdrop.open{background-color:#454545b3}.pbs-backdrop.transparent{background-color:transparent}.pbs-container{--pbs-container-background-color: rgb(240, 240, 240);background-color:var(--pbs-container-background-color);position:relative;display:none;flex-direction:column;align-items:center;justify-content:flex-start;width:92%;height:fit-content;max-height:100vh;border-radius:10px 10px 0 0}.pbs-container.open{display:flex}.pbs-container .pbs-gap-filler{position:absolute;bottom:calc(-100vh + .5px);left:0;background-color:var(--pbs-container-background-color);content:"";width:100%;height:100vh}.pbs-handle{position:relative;display:flex;align-items:center;justify-content:center;width:100%;height:30px;cursor:pointer}.pbs-handle.hidden{display:none}.pbs-button-reset{background-color:transparent;-webkit-appearance:none;-moz-appearance:none;appearance:none;outline:none;border:none}button:focus.pbs-button-reset{outline:none}.pbs-handle-bar{background-color:#a8a8a8;position:relative;width:12%;height:7px;border-radius:12px}.pbs-handle-bar.hidden{display:none}.pbs-content-wrapper{position:relative;width:100%;height:fit-content;max-height:100%;overflow-y:scroll}.pbs-content-wrapper::-webkit-scrollbar{display:none}.example{-ms-overflow-style:none;scrollbar-width:none}')),document.head.appendChild(e)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}})();var De=Object.defineProperty,Me=(e,t,n)=>t in e?De(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,J=(e,t,n)=>Me(e,typeof t!="symbol"?t+"":t,n);function B(e){return typeof e=="string"}function Pe(e,t){return e.classList.contains(Q(t))}function _(e,t){e.classList.add(Q(t))}function oe(e,t){e.classList.remove(Q(t))}function X(e,t,n){B(n)&&(B(t)&&oe(e,t),_(e,n))}function Q(e){return B(e)?e.trim().replace(/\./g,""):""}function F(e){return e.map(t=>Q(t)).filter(Boolean).join(" ")}function Ye(e){return e.map(t=>t==null?void 0:t.trim()).filter(Boolean).map(t=>`.${t}`).join(" ")}const de="open",pe="hidden";function re(e,t){const n=t;if(Array.isArray(e)){e.forEach(o=>{Z(o,n),o.setAttribute("aria-modal",n?"true":"false")});return}Z(e,n),e.setAttribute("aria-modal",n?"true":"false")}function Z(e,t){t?(_(e,de),oe(e,pe)):(_(e,pe),oe(e,de))}function he(e){return e instanceof HTMLElement}function A(e){return typeof e=="number"&&!Number.isNaN(e)}function Fe(e){he(e)&&e.focus()}function Re(e){if(!he(e)||e.offsetParent===null||"disabled"in e&&e.disabled)return!1;const t=e.getAttribute("tabindex"),n=A(t)?parseInt(t,10):-1,o=["INPUT","BUTTON","SELECT","TEXTAREA","A","AREA","IFRAME"].includes(e.tagName),r=e instanceof HTMLAnchorElement&&e.href!==""||e instanceof HTMLAreaElement&&e.href!=="";return o||r||n>-1}var T=(e=>(e.Backdrop="pbs-backdrop",e.Root="pbs-root",e.Container="pbs-container",e.GapFiller="pbs-gap-filler",e.Handle="pbs-handle",e.HandleBar="pbs-handle-bar",e.ContentWrapper="pbs-content-wrapper",e))(T||{}),ae=(e=>(e.Button="pbs-button-reset",e.Dialog="pbs-dialog-reset",e))(ae||{}),ee=(e=>(e.Hidden="hidden",e))(ee||{});function Y(e,t,n){const o=document.createElement(e);return t.split(" ").forEach(r=>{_(o,r)}),B(n)&&o.setAttribute("data-testid",n),o}Ye([T.Root,T.ContentWrapper]);function fe(e,t,n,o){switch(o){case"content-height":return t>=e?Se(e,t,n):0;case"middle":return-(e/2-t);case"top":return-(e-t)+n;default:return 0}}function me(e,t){const n=t<e,o=t>e;return{isUp:n,isDown:o,stayedSame:t===e}}function be(e,t){return t<e?-(e-t):t-e}function q(e,t){return e>t?e-t:t-e}function Ie(e,t){const n=e<t,o=e>t;return{isUp:n,isDown:o,stayedSame:e===t}}function ge(e,t,n){const o=e==="above";return n.filter(r=>{const i=r*t.viewportHeight;return o?t.visibleHeight<i:t.visibleHeight>i})}function Se(e,t,n){return-(e-t)+n}function ve(e){return Number(e.replace("px",""))}function te(e,...t){return Number(e.toFixed(...t))}function ye(e){const t=/(?<type>\w+)\((?<values>[^)]+)\)/g,n=[];let o;for(;(o=t.exec(e))!==null;){const r=o[1],i=o[2].split(",").map(a=>a.trim());n.push({type:r,values:i})}return n}function We(e){const t=e.style.transform,n=ye(t);return{transform:t,transformValues:n}}function Ce(e,t){return e.find(o=>o.type.startsWith(t))||null}const ie="translate";function P(e){const t=e.style.transform,n=ye(t),o=Ce(n,ie);return Ee(o??{type:ie,values:[]})}function ne(e,{x:t,y:n}){const{transform:o,transformValues:r}=We(e),i=Ce(r,ie);if(i){const a=Ee(i);e.style.transform=`translate(${t??a.x??0}px,${n??a.y??0}px)`;return}if(o){e.style.transform=`${o}, translate(${t??0}px,${n??0}px)`;return}e.style.transform=`translate(${t??0}px,${n??0}px)`}function Ee(e){if(e.type!=="translate")throw new Error(`Could not get coordinates from ${e.type}, since is not translate.`);const t=e.values[0],n=e.values[1];return{x:ve(t)??0,y:ve(n)??0}}function se(e){return e!=null}function we(e,{min:t,max:n}){return se(n)&&e>=n?n:se(t)&&e<=t?t:e}const Ne=(e,t,n)=>{t instanceof HTMLElement&&!Pe(t,T.Handle)&&n.scrollTop>=1||(e.isDragging=!0)},je=(e,t,n,o)=>r=>{o.startY=e.getCoordinates(r).y,o.containerStartTranslate=P(t),n.onDragStart()},Ge=(e,t,n,o,r)=>i=>{Ue(i,e,n,o,r,t,n.marginTop)};function Ue(e,t,n,o,r,i,a){if(!o.isDragging||!A(o.startY))return;const c=t.getCoordinates(e).y,u=be(o.startY,c),h=window.innerHeight,s=i.clientHeight,f=s-(o.containerStartTranslate.y+u);if(f>=h)return;const E=me(o.startY,c);if(E.isUp&&!n.expandable&&f>=s||n.preventClosing&&f<=s)return;r.start(()=>{ne(i,{y:o.containerStartTranslate.y+u})},0);const l=h-a,w=s-o.containerStartTranslate.y;if(E.isUp){const m=l-w,v=l-f,k=we(1-te(v/m,2),{min:0,max:1});n.onDragMove(E,k)}else if(E.isDown){const m=we(te(1-f/w,2),{min:0,max:1});n.onDragMove(E,m)}}const $e=(e,t,n,o,r,i,a)=>c=>{if(!o.isDragging||(o.isDragging=!1,!A(o.startY)))return;n.onDragEnd();const u=o.startY,h=e.getCoordinates(c).y,s=P(t).y,f=me(u,h),E=window.innerHeight,l=t.clientHeight;if(f.isUp){const w=[...n.snapPoints].sort((k,x)=>k-x),m=l+-s;if(!n.expandable&&m>=l)return;for(const k of w){const x=k*window.innerHeight;if(m<=x){const H=q(m,x);a.translateContainer({startY:s,endY:s-H,animationFrame:r,bottomSheetContainer:t});return}}const v=Se(E,l,n.marginTop);a.translateContainer({startY:s,endY:v,animationFrame:r,bottomSheetContainer:t})}else if(f.isDown){const w=[...n.snapPoints].sort((m,v)=>v-m);for(const m of w){const v=m*window.innerHeight,k=l+-s;if(k>=v){const x=q(k,v);a.translateContainer({startY:s,endY:s+x,animationFrame:r,bottomSheetContainer:t});return}}if(n.preventClosing){const m=l+-s;if(m>=l){const v=q(m,l);a.translateContainer({startY:s,endY:s+v,animationFrame:r,bottomSheetContainer:t})}return}i()}};var R=(e=>(e[e.All=-1]="All",e[e.None=0]="None",e[e.Capture=1]="Capture",e[e.Target=2]="Target",e[e.Bubble=3]="Bubble",e))(R||{});function ke(e){switch(e){case 0:return 0;case 1:return 1;case 2:return 2;case 3:return 3;default:return-1}}const _e={eventPhase:R.All};class z{constructor(t){J(this,"currentTarget"),this.currentTarget=t}addEventListeners({onStart:t,onStartOptions:n=_e,onMove:o,onEnd:r}){this.addTouchEventListeners({onStart:t,onStartOptions:n,onMove:o,onEnd:r}),this.addMouseEventListeners({onStart:t,onStartOptions:n,onMove:o,onEnd:r})}addTouchEventListeners({onStart:t,onStartOptions:n,onMove:o,onEnd:r}){t&&this.currentTarget.addEventListener("touchstart",i=>{if(n.eventPhase===R.All){t(i);return}ke(i.eventPhase)===n.eventPhase&&t(i)},{passive:!0}),o&&this.currentTarget.addEventListener("touchmove",o),r&&this.currentTarget.addEventListener("touchend",r)}addMouseEventListeners({onStart:t,onStartOptions:n,onMove:o,onEnd:r}){t&&this.currentTarget.addEventListener("mousedown",i=>{if(n.eventPhase===R.All){t(i);return}ke(i.eventPhase)===n.eventPhase&&t(i)},{passive:!0}),o&&this.currentTarget.addEventListener("mousemove",o),r&&this.currentTarget.addEventListener("mouseup",i=>{r(i)})}removeEventListeners({onStart:t,onMove:n,onEnd:o}){t&&this.currentTarget.removeEventListener("touchstart",t),o&&this.currentTarget.removeEventListener("touchend",o),n&&this.currentTarget.removeEventListener("touchmove",n),t&&this.currentTarget.removeEventListener("mousedown",t),n&&this.currentTarget.removeEventListener("mousemove",n),o&&this.currentTarget.removeEventListener("mouseup",o)}getCoordinates(t){if(t.type==="touchstart"||t.type==="mousedown"){if("touches"in t)return{x:t.touches[0].clientX,y:t.touches[0].clientY};if(t instanceof MouseEvent)return{x:t.clientX,y:t.clientY}}if(t.type==="touchend"||t.type==="mouseup"||t.type==="mousemove"||t.type==="touchmove"){if("touches"in t)return{x:t.changedTouches[0].clientX,y:t.changedTouches[0].clientY};if(t instanceof MouseEvent)return{x:t.clientX,y:t.clientY}}return{x:0,y:0}}}function Te(e){const t=e;return`${t} ${t} 0px 0px`}function Xe(e,t){const n=qe(e);ze(n),n.bottomSheetContainer.style.width=e.width;const o=document.createElement("div");o.innerHTML=e.content??"";const r=window.innerHeight;n.bottomSheetContainer.style.maxHeight=`${r}px`,n.bottomSheetContentWrapper.appendChild(o);const i=Ve({bottomSheetElements:n,bottomSheetProps:e,options:t});return e.rootStyle&&Object.assign(n.bottomSheetRoot.style,e.rootStyle),e.backdropStyle&&Object.assign(n.bottomSheetBackdrop.style,e.backdropStyle),e.containerGapFillerStyle&&Object.assign(n.bottomSheetContainer.style,e.containerStyle),e.containerStyle&&Object.assign(n.bottomSheetContainerGapFiller.style,e.containerGapFillerStyle),e.handleStyle&&Object.assign(n.bottomSheetHandleBar.style,e.handleStyle),e.contentWrapperStyle&&Object.assign(n.bottomSheetContentWrapper.style,e.contentWrapperStyle),{elements:n,eventHandlers:i}}function qe(e){const t=Y("dialog",F([T.Root,ae.Dialog,e.rootClass]),T.Root);t.ariaLabel=e.ariaLabel;const n=Y("section",F([T.Container,e.containerClass]),T.Container);e.containerBorderRadius&&(n.style.borderRadius=Te(e.containerBorderRadius));const o=Y("div",T.GapFiller,T.GapFiller);e.containerBackgroundColor&&(n.style.backgroundColor=e.containerBackgroundColor,o.style.backgroundColor=e.containerBackgroundColor);const r=Y("button",F([T.Handle,ae.Button,e.shouldShowHandle?null:ee.Hidden,e.handleClass]),T.Handle);r.setAttribute("type","button"),r.ariaLabel="bottom sheet close button";const i=Y("span",F([T.HandleBar,e.shouldShowHandle?null:ee.Hidden]),T.HandleBar),a=Y("article",F([T.ContentWrapper,e.contentWrapperClass]),T.ContentWrapper),c=Y("div",F([T.Backdrop,e.backdropClass,ee.Hidden]),T.Backdrop);return e.backdropColor&&(c.style.backgroundColor=e.backdropColor),e.backDropTransition&&(c.style.transition=e.backDropTransition),{bottomSheetRoot:t,bottomSheetBackdrop:c,bottomSheetContainer:n,bottomSheetHandle:r,bottomSheetHandleBar:i,bottomSheetContentWrapper:a,bottomSheetContainerGapFiller:o}}function ze({bottomSheetRoot:e,bottomSheetContainer:t,bottomSheetHandle:n,bottomSheetHandleBar:o,bottomSheetContentWrapper:r,bottomSheetContainerGapFiller:i}){e.appendChild(t),n.appendChild(o),t.appendChild(n),t.appendChild(r),t.appendChild(i)}function Ve({bottomSheetElements:e,bottomSheetProps:t,options:n}){const{bottomSheetRoot:o,bottomSheetContainer:r,bottomSheetHandle:i,bottomSheetContainerGapFiller:a,bottomSheetContentWrapper:c,bottomSheetBackdrop:u}=e,{animationFrame:h}=n,s=new z(i),f=new z(c),E=new z(a),l=t.dragTriggers.reduce((O,C)=>{const y=o.querySelectorAll(C);if(!y.length)return O;const p=Array.from(y).map(d=>d instanceof HTMLElement?new z(d):null).filter(d=>!!d);return[...O,...p]},[]),w=new z(window),m=je(w,r,t,n.draggingState),v=Ge(w,r,t,n.draggingState,h),k=$e(w,r,t,n.draggingState,h,n.onClose,n.bottomSheetState);function x(O){O.target instanceof Element&&!o.contains(O.target)&&n.onClose()}function H(O){Ne(n.draggingState,O.target,e.bottomSheetContentWrapper)}function j(O){const C=O??t;C.draggable&&(s.addEventListeners({onStart:H}),l.forEach(y=>{y.addEventListeners({onStart:H,onStartOptions:{eventPhase:R.Target}})})),C.draggable&&C.backgroundDraggable&&(f.addEventListeners({onStart:H,onStartOptions:{eventPhase:R.Target}}),E.addEventListeners({onStart:H})),C.draggable&&w.addEventListeners({onStart:m,onMove:v,onEnd:k}),C.draggable&&window.document.addEventListener("keyup",y=>{y.key==="Escape"&&n.onClose()}),i.addEventListener("keyup",y=>{if(y.key==="ArrowUp"){n.moveUp();return}if(y.key==="ArrowDown"){n.moveDown();return}if(y.shiftKey&&y.key==="Tab"){const p=G(e.bottomSheetContentWrapper);Fe(p)}})}function V(){t.shouldCloseOnOutsideClick?u.addEventListener("click",x):u.style.pointerEvents="none"}function K(){u.removeEventListener("click",x)}function G(O){let C=[...Array.from(O.childNodes).reverse()];for(;C.length;){const y=C.shift();if(Re(y))return y;y&&(C=[...C,...Array.from(y.childNodes).reverse()])}return null}function U(){s.removeEventListeners({onStart:H}),f.removeEventListeners({onStart:H}),E.removeEventListeners({onStart:H}),l.forEach(O=>{O.removeEventListeners({onStart:H})}),w.removeEventListeners({onStart:m,onMove:v,onEnd:k})}return{attachEventListeners:j,clearEventListeners:U,attacheOnOpenEventListeners:V,clearOnOpenEventListeners:K}}class Ke{constructor(){J(this,"animationId"),J(this,"isInProgress"),J(this,"startedAt"),this.animationId=null,this.isInProgress=!1,this.startedAt=null}start(t,n,o=!1){this.isInProgress=!0;const r=i=>{this.startedAt||(this.startedAt=i);const a=i-this.startedAt,c=n===0?1:te(a/n,2),u=c>=1&&!o;t(c),u?this.stop():this.animationId=requestAnimationFrame(r)};this.animationId=requestAnimationFrame(r)}stop(){this.isInProgress=!1,this.startedAt=null,A(this.animationId)&&cancelAnimationFrame(this.animationId)}}function Je(e){const{startY:t,endY:n,bottomSheetContainer:o,animationFrame:r,onEnd:i,animationTimingFunction:a,animationDuration:c}=e,u=be(t,n);r.stop();let h=!1;r.start(s=>{ne(o,{y:t+u*a(s)}),!h&&s>=1&&(i==null||i(),h=!0)},c)}const ce=(e,t)=>n=>{Je({...n,animationTimingFunction:e,animationDuration:t})},I={TOP:"top",MIDDLE:"middle",CONTENT_HEIGHT:"content-height",CLOSED:"closed"};function Qe(e){return!(!A(e)||e>1||e<0)}function Ze(e,t){const n={set(o,r,i,a){return t(r,i),Reflect.set(o,r,i,a)}};return new Proxy(e,n)}function et(...e){console.error(e)}const W={EASE:"ease",EASE_IN:"ease-in",EASE_OUT:"ease-out",EASE_IN_OUT:"ease-in-out",SPRING:"spring"};function tt(e){for(const t of Object.values(W))if(t===e)return!0;return!1}function He(e){return!!(e instanceof Object&&"p1x"in e&&"p1y"in e&&"p2x"in e&&"p2y"in e&&A(e.p1x)&&A(e.p1y)&&A(e.p2x)&&A(e.p2y))}function N(e,t,n,o){return function(c){return a(r(c))};function r(c){let u=0,h=1,s=c,f;if(c===0||c===1)return c;for(;u<h;){if(f=i(s),Math.abs(f-c)<.001)return s;c>f?u=s:h=s,s=(h+u)/2}return s}function i(c){return 3*e*c*Math.pow(1-c,2)+3*n*Math.pow(c,2)*(1-c)+Math.pow(c,3)}function a(c){return 3*t*c*Math.pow(1-c,2)+3*o*Math.pow(c,2)*(1-c)+Math.pow(c,3)}}const Oe=N(.25,.1,.25,1),nt=N(.42,0,1,1),Le=N(.42,0,.58,1),ot=N(.4,.1,.6,1),rt=N(.45,1.5,.55,1);function at(e){switch(e){case W.EASE:return Oe;case W.EASE_IN:return nt;case W.EASE_OUT:return Le;case W.EASE_IN_OUT:return ot;case W.SPRING:return rt;default:return Oe}}function Be(e){return typeof e=="boolean"}const it={ariaLabel:"Bottom sheet",content:"",defaultPosition:I.CONTENT_HEIGHT,marginTop:20,snapPoints:[],width:"92%",dragTriggers:[],beforeOpen:()=>{},afterOpen:()=>{},beforeClose:()=>{},afterClose:()=>{},onDragStart:()=>{},onDragMove:()=>{},onDragEnd:()=>{},expandable:!0,preventClosing:!1,draggable:!0,backgroundDraggable:!0,shouldCloseOnOutsideClick:!0,shouldShowBackdrop:!0,shouldShowHandle:!0,backDropTransition:null,backdropColor:null,containerBackgroundColor:null,containerBorderRadius:null,rootClass:null,containerClass:null,handleClass:null,contentWrapperClass:null,backdropClass:null,draggingAnimationTimings:"ease-in-out",draggingAnimationDuration:180,rootStyle:{},containerStyle:{},handleStyle:{},contentWrapperStyle:{},backdropStyle:{},containerGapFillerStyle:{}};function st(e){const t={...it},n=Object.entries(e).reduce((o,r)=>{const[i,a]=r;return se(a)&&(o[i]=a),o},{});return{...t,...n}}function le(e){if(He(e)){const{p1x:t,p1y:n,p2x:o,p2y:r}=e;return N(t,n,o,r)}return tt(e)?at(e):Le}function ct(e,t,n,o){function r(i,a){switch(i){case"content":B(a)&&(e.bottomSheetContentWrapper.innerHTML=a);break;case"width":B(a)&&(e.bottomSheetContainer.style.width=a);break;case"shouldShowHandle":Be(a)||Z(e.bottomSheetHandle,!1);break;case"shouldShowBackdrop":Be(a)||Z(e.bottomSheetBackdrop,!1);break;case"containerBorderRadius":B(a)&&(e.bottomSheetContainer.style.borderRadius=Te(a));break;case"containerBackgroundColor":B(a)&&(e.bottomSheetContainer.style.backgroundColor=a,e.bottomSheetContainerGapFiller.style.backgroundColor=a);break;case"backdropColor":B(a)&&(e.bottomSheetBackdrop.style.backgroundColor=a);break;case"backDropTransition":B(a)&&(e.bottomSheetBackdrop.style.transition=a);break;case"rootClass":if(!B(a))return;X(e.bottomSheetRoot,n.rootClass,a);break;case"containerClass":if(!B(a))return;X(e.bottomSheetContainer,n.containerClass,a);break;case"handleClass":if(!B(a))return;X(e.bottomSheetHandle,n.handleClass,a);break;case"contentWrapperClass":if(!B(a))return;X(e.bottomSheetContentWrapper,n.contentWrapperClass,a);break;case"backdropClass":if(!B(a))return;X(e.bottomSheetBackdrop,n.backdropClass,a);break;case"expandable":o.clearEventListeners(),o.attachEventListeners(n);break;case"preventClosing":o.clearEventListeners(),o.attachEventListeners(n);break;case"draggable":o.clearEventListeners(),o.attachEventListeners(n);break;case"draggingAnimationTimings":if(He(a)){const c=le(a),u=ce(c,n.draggingAnimationDuration);t.translateContainer=u}break;case"draggingAnimationDuration":if(A(a)){const c=le(n.draggingAnimationTimings),u=ce(c,a);t.translateContainer=u}break;case"rootStyle":n.rootStyle&&Object.assign(e.bottomSheetRoot.style,n.rootStyle);break;case"backdropStyle":n.backdropStyle&&Object.assign(e.bottomSheetBackdrop.style,n.backdropStyle);break;case"containerStyle":n.containerStyle&&Object.assign(e.bottomSheetContainer.style,n.containerStyle);break;case"containerGapFillerStyle":n.containerGapFillerStyle&&Object.assign(e.bottomSheetContainerGapFiller.style,n.containerGapFillerStyle);break;case"handleStyle":n.handleStyle&&Object.assign(e.bottomSheetHandleBar.style,n.handleStyle);break;case"contentWrapperStyle":n.contentWrapperStyle&&Object.assign(e.bottomSheetContentWrapper.style,n.contentWrapperStyle);break}}return r}function lt(e){const t=st(e),n=le(e.draggingAnimationTimings),o={isMounted:!1,translateContainer:ce(n,t.draggingAnimationDuration)},r={startY:null,containerStartTranslate:{x:0,y:0},isDragging:!1,originalDocumentOverflowY:null,originalDocumentOverscrollBehavior:null};function i(){r.originalDocumentOverflowY&&r.originalDocumentOverflowY!=="hidden"&&(document.body.style.overflowY=r.originalDocumentOverflowY),r.originalDocumentOverscrollBehavior&&(document.body.style.position=r.originalDocumentOverscrollBehavior)}const a=new Ke,c={animationFrame:a,onClose:k,bottomSheetState:o,draggingState:r,snapTo:y,moveUp:O,moveDown:C},{elements:u,eventHandlers:h}=Xe(t,c),s=Ze(t,ct(u,o,t,h)),{bottomSheetBackdrop:f,bottomSheetRoot:E,bottomSheetContainer:l}=u,w=p=>{const d=p??window.document.body;d.appendChild(E),d.appendChild(f);const b=window.innerHeight;ne(l,{y:b}),h.attachEventListeners(),o.isMounted=!0},m=()=>{h.clearEventListeners(),Object.values(u).forEach(p=>{p.remove()}),i(),o.isMounted=!1},v=()=>{var p;if(x()||et('Bottom Sheet is not mounted yet. call the "mount" method first.'),(p=e.beforeOpen)==null||p.call(e),H())return;re(f,!0),s.shouldShowBackdrop||_(f,"transparent"),re([l],!0),ne(l,{y:l.clientHeight});const d=window.innerHeight,b=fe(d,l.clientHeight,s.marginTop,s.defaultPosition),S=P(l).y;o.translateContainer({startY:S,endY:b,animationFrame:a,bottomSheetContainer:l,onEnd:e.afterOpen});const L=document.body.style.overflowY;r.originalDocumentOverflowY=L||"initial";const D=document.body.style.overscrollBehavior;r.originalDocumentOverscrollBehavior=D||"initial",document.body.style.overflow="hidden",document.body.style.overscrollBehavior="contain",u.bottomSheetHandle.focus(),h.attacheOnOpenEventListeners()};function k(){var p;if(j())return;(p=e.beforeClose)==null||p.call(e);const d=P(l).y,b=l.clientHeight;o.translateContainer({startY:d,endY:b,animationFrame:a,bottomSheetContainer:l,onEnd:()=>{var S;(S=e.afterClose)==null||S.call(e),re([f,l],!1),h.clearOnOpenEventListeners()}}),i()}function x(){return o.isMounted}function H(){const p=P(l).y,d=window.innerHeight,b=l.clientHeight>=d?d:l.clientHeight;return p<=b}function j(){return!H()}function V(){const p=P(l).y,d=l.clientHeight,b=window.innerHeight;if(p<=5&&p>=-5)return I.CONTENT_HEIGHT;const S=d-p;if(S===b/2)return I.MIDDLE;const L=b-s.marginTop,D=10;return S<=L+D&&S>=L-D?I.TOP:I.CLOSED}function K(){return l.clientHeight}function G(p){if(!H())return;const d=P(l).y,b=l.clientHeight-d,S=window.innerHeight-p,L=Ie(b,S),D=q(b,S);o.translateContainer({startY:d,endY:d+(L.isUp?-D:D),animationFrame:a,bottomSheetContainer:l})}function U(p,{viewportHeight:d,visibleHeight:b}){let S=null;for(const L of p){const D=L*d,$=q(b,D);(S===null||$<S)&&(S=$)}return{minOffset:S}}function O(){const p=[...s.snapPoints].reverse(),d=P(l).y,b=l.clientHeight,S=b-d;if(!s.expandable&&S>=b)return;const L=window.innerHeight,D=ge("above",{visibleHeight:S,viewportHeight:L},p),{minOffset:$}=U(D,{visibleHeight:S,viewportHeight:L});if($===null&&S<L-s.marginTop){o.translateContainer({startY:d,endY:fe(L,b,s.marginTop,"top"),animationFrame:a,bottomSheetContainer:l});return}A($)&&o.translateContainer({startY:d,endY:d-$,animationFrame:a,bottomSheetContainer:l})}function C(){const p=P(l).y,d=l.clientHeight-p;if(d<1)return;const b=window.innerHeight,S=ge("below",{visibleHeight:d,viewportHeight:b},s.snapPoints),{minOffset:L}=U(S,{visibleHeight:d,viewportHeight:b});A(L)&&o.translateContainer({startY:p,endY:p+L,animationFrame:a,bottomSheetContainer:l})}function y(p){const d=window.innerHeight;if(!Qe(p))return;const b=te(d*p,2);G(b)}return{props:s,elements:u,mount:w,unmount:m,open:v,close:k,getIsMounted:x,getIsOpen:H,getIsClosed:j,getPosition:V,getHeight:K,moveTo:G,snapTo:y}}function ue(){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:()=>I.CLOSED,moveTo:()=>{},snapTo:()=>{},props:{content:""}}}const ut=ue(),dt=g.forwardRef(function(t,n){const{children:o,isOpen:r,setIsOpen:i,afterClose:a,mountingPointRef:c,...u}=t,h=g.useRef(ut),[s,f]=g.useState(h.current);g.useImperativeHandle(n,()=>s,[s]);const E=g.useCallback(()=>{i(!1),a==null||a()},[a]);g.useEffect(()=>{r?s.open():s.close()},[r]);const l=g.useRef(null);return g.useEffect(function(){var k;if(c&&!c.current)return;const m=Ae((k=t.mountingPointRef)==null?void 0:k.current)?t.mountingPointRef.current:window.document.body;if(!m||s.getIsMounted())return;const v=lt({content:"",...u,afterClose:E});return v.mount(m),l.current=v.elements.bottomSheetContentWrapper??null,h.current=v,f(v),()=>{s.unmount()}},[t.mountingPointRef,u,E]),g.useEffect(function(){Object.assign(h.current.props,{...u}),f(h.current)},[u]),g.useEffect(function(){return()=>{h.current.unmount()}},[]),l.current?xe.createPortal(t.children,l.current):null}),pt=ue();function ht(e={}){const t=g.useRef(pt),[n,o]=g.useState(!1),[r,i]=g.useState(t.current);g.useEffect(()=>{i(t.current)},[t.current]);const{beforeOpen:a,afterOpen:c,beforeClose:u,afterClose:h,onDragStart:s,onDragMove:f,onDragEnd:E,...l}=e,w=()=>{a==null||a()},m=()=>{c==null||c(),o(!0)},v=()=>{u==null||u()},k=()=>{h==null||h(),o(!1)},x=()=>{s==null||s()},H=(C,y)=>{f==null||f(C,y)},j=()=>{E==null||E()},V=g.useMemo(()=>({ref:t,isOpen:n,setIsOpen:o,beforeOpen:w,afterOpen:m,beforeClose:v,afterClose:k,onDragStart:x,onDragMove:H,onDragEnd:j,...l}),[t.current,n,o,e]),K=g.useCallback(()=>{o(!0)},[o]),G=g.useCallback(()=>{o(!0)},[o]),U=g.useCallback((...C)=>{r.moveTo(...C)},[r]),O=g.useCallback((...C)=>{r.snapTo(...C)},[r]);return{props:V,instance:r,isOpen:n,setIsOpen:o,open:K,close:G,moveTo:U,snapTo:O}}M.BottomSheet=dt,M.createPlaceholderBottomSheet=ue,M.useBottomSheet=ht,Object.defineProperty(M,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(M,v){typeof exports=="object"&&typeof module<"u"?v(exports,require("react"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","react-dom"],v):(M=typeof globalThis<"u"?globalThis:M||self,v(M.BottomSheet={},M.React,M.ReactDOM))})(this,function(M,v,xe){"use strict";function Ae(e){return e!=null}(function(){try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode('.pbs-root{position:fixed;left:0;bottom:0;display:flex;flex-direction:column;align-items:center;justify-content:flex-start;width:100%;height:fit-content;max-height:100vh;z-index:2}.pbs-dialog-reset{background-color:transparent;color:inherit;border:none;outline:none;padding:0;margin:0}.pbs-backdrop{position:fixed;top:0;left:0;width:100%;height:100%;background-color:transparent;z-index:1;transition:background-color .2s ease-out}.pbs-backdrop.hidden{visibility:hidden}.pbs-backdrop.open{background-color:#454545b3}.pbs-backdrop.transparent{background-color:transparent}.pbs-container{--pbs-container-background-color: rgb(240, 240, 240);background-color:var(--pbs-container-background-color);position:relative;display:none;flex-direction:column;align-items:center;justify-content:flex-start;width:92%;height:fit-content;max-height:100vh;border-radius:10px 10px 0 0}.pbs-container.open{display:flex}.pbs-container .pbs-gap-filler{position:absolute;bottom:calc(-100vh + .5px);left:0;background-color:var(--pbs-container-background-color);content:"";width:100%;height:100vh}.pbs-handle{position:relative;display:flex;align-items:center;justify-content:center;width:100%;height:30px;cursor:pointer}.pbs-handle.hidden{display:none}.pbs-button-reset{background-color:transparent;-webkit-appearance:none;-moz-appearance:none;appearance:none;outline:none;border:none}button:focus.pbs-button-reset{outline:none}.pbs-handle-bar{background-color:#a8a8a8;position:relative;width:12%;height:7px;border-radius:12px}.pbs-handle-bar.hidden{display:none}.pbs-content-wrapper{position:relative;width:100%;height:fit-content;max-height:100%;overflow-y:scroll}.pbs-content-wrapper::-webkit-scrollbar{display:none}.example{-ms-overflow-style:none;scrollbar-width:none}')),document.head.appendChild(e)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}})();var De=Object.defineProperty,Me=(e,t,n)=>t in e?De(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,J=(e,t,n)=>Me(e,typeof t!="symbol"?t+"":t,n);function L(e){return typeof e=="string"}function Pe(e,t){return e.classList.contains(Q(t))}function _(e,t){e.classList.add(Q(t))}function oe(e,t){e.classList.remove(Q(t))}function X(e,t,n){L(n)&&(L(t)&&oe(e,t),_(e,n))}function Q(e){return L(e)?e.trim().replace(/\./g,""):""}function R(e){return e.map(t=>Q(t)).filter(Boolean).join(" ")}function Ye(e){return e.map(t=>t==null?void 0:t.trim()).filter(Boolean).map(t=>`.${t}`).join(" ")}const de="open",pe="hidden";function re(e,t){const n=t;if(Array.isArray(e)){e.forEach(o=>{Z(o,n),o.setAttribute("aria-modal",n?"true":"false")});return}Z(e,n),e.setAttribute("aria-modal",n?"true":"false")}function Z(e,t){t?(_(e,de),oe(e,pe)):(_(e,pe),oe(e,de))}function he(e){return e instanceof HTMLElement}function A(e){return typeof e=="number"&&!Number.isNaN(e)}function Re(e){he(e)&&e.focus()}function Fe(e){if(!he(e)||e.offsetParent===null||"disabled"in e&&e.disabled)return!1;const t=e.getAttribute("tabindex"),n=A(t)?parseInt(t,10):-1,o=["INPUT","BUTTON","SELECT","TEXTAREA","A","AREA","IFRAME"].includes(e.tagName),r=e instanceof HTMLAnchorElement&&e.href!==""||e instanceof HTMLAreaElement&&e.href!=="";return o||r||n>-1}var k=(e=>(e.Backdrop="pbs-backdrop",e.Root="pbs-root",e.Container="pbs-container",e.GapFiller="pbs-gap-filler",e.Handle="pbs-handle",e.HandleBar="pbs-handle-bar",e.ContentWrapper="pbs-content-wrapper",e))(k||{}),ae=(e=>(e.Button="pbs-button-reset",e.Dialog="pbs-dialog-reset",e))(ae||{}),ee=(e=>(e.Hidden="hidden",e))(ee||{});function Y(e,t,n){const o=document.createElement(e);return t.split(" ").forEach(r=>{_(o,r)}),L(n)&&o.setAttribute("data-testid",n),o}Ye([k.Root,k.ContentWrapper]);function me(e,t,n,o){switch(o){case"content-height":return t>=e?ve(e,t,n):0;case"middle":return-(e/2-t);case"top":return-(e-t)+n;default:return 0}}function fe(e,t){const n=t<e,o=t>e;return{isUp:n,isDown:o,stayedSame:t===e}}function be(e,t){return t<e?-(e-t):t-e}function q(e,t){return e>t?e-t:t-e}function Ie(e,t){const n=e<t,o=e>t;return{isUp:n,isDown:o,stayedSame:e===t}}function ge(e,t,n){const o=e==="above";return n.filter(r=>{const i=r*t.viewportHeight;return o?t.visibleHeight<i:t.visibleHeight>i})}function ve(e,t,n){return-(e-t)+n}function Se(e){return Number(e.replace("px",""))}function te(e,...t){return Number(e.toFixed(...t))}function ye(e){const t=/(?<type>\w+)\((?<values>[^)]+)\)/g,n=[];let o;for(;(o=t.exec(e))!==null;){const r=o[1],i=o[2].split(",").map(a=>a.trim());n.push({type:r,values:i})}return n}function We(e){const t=e.style.transform,n=ye(t);return{transform:t,transformValues:n}}function Ce(e,t){return e.find(o=>o.type.startsWith(t))||null}const ie="translate";function P(e){const t=e.style.transform,n=ye(t),o=Ce(n,ie);return Ee(o??{type:ie,values:[]})}function ne(e,{x:t,y:n}){const{transform:o,transformValues:r}=We(e),i=Ce(r,ie);if(i){const a=Ee(i);e.style.transform=`translate(${t??a.x??0}px,${n??a.y??0}px)`;return}if(o){e.style.transform=`${o}, translate(${t??0}px,${n??0}px)`;return}e.style.transform=`translate(${t??0}px,${n??0}px)`}function Ee(e){if(e.type!=="translate")throw new Error(`Could not get coordinates from ${e.type}, since is not translate.`);const t=e.values[0],n=e.values[1];return{x:Se(t)??0,y:Se(n)??0}}function se(e){return e!=null}function we(e,{min:t,max:n}){return se(n)&&e>=n?n:se(t)&&e<=t?t:e}const Ne=(e,t,n)=>{t instanceof HTMLElement&&!Pe(t,k.Handle)&&n.scrollTop>=1||(e.isDragging=!0)},je=(e,t,n,o)=>r=>{o.startY=e.getCoordinates(r).y,o.containerStartTranslate=P(t),n.onDragStart()},Ge=(e,t,n,o,r)=>i=>{Ue(i,e,n,o,r,t,n.marginTop)};function Ue(e,t,n,o,r,i,a){if(!o.isDragging||!A(o.startY))return;const l=t.getCoordinates(e).y,u=be(o.startY,l),h=window.innerHeight,s=i.clientHeight,f=s-(o.containerStartTranslate.y+u);if(f>=h)return;const C=fe(o.startY,l);if(C.isUp&&!n.expandable&&f>=s||n.preventClosing&&f<=s)return;r.start(()=>{ne(i,{y:o.containerStartTranslate.y+u})},0);const c=h-a,E=s-o.containerStartTranslate.y;if(C.isUp){const S=c-E,y=c-f,w=we(1-te(y/S,2),{min:0,max:1});n.onDragMove(C,w)}else if(C.isDown){const S=we(te(1-f/E,2),{min:0,max:1});n.onDragMove(C,S)}}const $e=(e,t,n,o,r,i,a)=>l=>{if(!o.isDragging||(o.isDragging=!1,!A(o.startY)))return;n.onDragEnd();const u=o.startY,h=e.getCoordinates(l).y,s=P(t).y,f=fe(u,h),C=window.innerHeight,c=t.clientHeight;if(f.isUp){if(!n.expandable)return;const E=[...n.snapPoints].sort((w,x)=>w-x),S=c+-s;for(const w of E){const x=w*window.innerHeight;if(S<=x){const T=q(S,x);a.translateContainer({startY:s,endY:s-T,animationFrame:r,bottomSheetContainer:t});return}}const y=ve(C,c,n.marginTop);a.translateContainer({startY:s,endY:y,animationFrame:r,bottomSheetContainer:t})}else if(f.isDown){const E=[...n.snapPoints].sort((S,y)=>y-S);for(const S of E){const y=S*window.innerHeight,w=c+-s;if(w>=y){const x=q(w,y);a.translateContainer({startY:s,endY:s+x,animationFrame:r,bottomSheetContainer:t});return}}if(n.preventClosing){const S=c+-s;if(S>=c){const y=q(S,c);a.translateContainer({startY:s,endY:s+y,animationFrame:r,bottomSheetContainer:t})}return}i()}};var F=(e=>(e[e.All=-1]="All",e[e.None=0]="None",e[e.Capture=1]="Capture",e[e.Target=2]="Target",e[e.Bubble=3]="Bubble",e))(F||{});function ke(e){switch(e){case 0:return 0;case 1:return 1;case 2:return 2;case 3:return 3;default:return-1}}const _e={eventPhase:F.All};class z{constructor(t){J(this,"currentTarget"),this.currentTarget=t}addEventListeners({onStart:t,onStartOptions:n=_e,onMove:o,onEnd:r}){this.addTouchEventListeners({onStart:t,onStartOptions:n,onMove:o,onEnd:r}),this.addMouseEventListeners({onStart:t,onStartOptions:n,onMove:o,onEnd:r})}addTouchEventListeners({onStart:t,onStartOptions:n,onMove:o,onEnd:r}){t&&this.currentTarget.addEventListener("touchstart",i=>{if(n.eventPhase===F.All){t(i);return}ke(i.eventPhase)===n.eventPhase&&t(i)},{passive:!0}),o&&this.currentTarget.addEventListener("touchmove",o),r&&this.currentTarget.addEventListener("touchend",r)}addMouseEventListeners({onStart:t,onStartOptions:n,onMove:o,onEnd:r}){t&&this.currentTarget.addEventListener("mousedown",i=>{if(n.eventPhase===F.All){t(i);return}ke(i.eventPhase)===n.eventPhase&&t(i)},{passive:!0}),o&&this.currentTarget.addEventListener("mousemove",o),r&&this.currentTarget.addEventListener("mouseup",i=>{r(i)})}removeEventListeners({onStart:t,onMove:n,onEnd:o}){t&&this.currentTarget.removeEventListener("touchstart",t),o&&this.currentTarget.removeEventListener("touchend",o),n&&this.currentTarget.removeEventListener("touchmove",n),t&&this.currentTarget.removeEventListener("mousedown",t),n&&this.currentTarget.removeEventListener("mousemove",n),o&&this.currentTarget.removeEventListener("mouseup",o)}getCoordinates(t){if(t.type==="touchstart"||t.type==="mousedown"){if("touches"in t)return{x:t.touches[0].clientX,y:t.touches[0].clientY};if(t instanceof MouseEvent)return{x:t.clientX,y:t.clientY}}if(t.type==="touchend"||t.type==="mouseup"||t.type==="mousemove"||t.type==="touchmove"){if("touches"in t)return{x:t.changedTouches[0].clientX,y:t.changedTouches[0].clientY};if(t instanceof MouseEvent)return{x:t.clientX,y:t.clientY}}return{x:0,y:0}}}function Te(e){const t=e;return`${t} ${t} 0px 0px`}function Xe(e,t){const n=qe(e);ze(n),n.bottomSheetContainer.style.width=e.width;const o=document.createElement("div");o.innerHTML=e.content??"";const r=window.innerHeight;n.bottomSheetContainer.style.maxHeight=`${r}px`,n.bottomSheetContentWrapper.appendChild(o);const i=Ve({bottomSheetElements:n,bottomSheetProps:e,options:t});return e.rootStyle&&Object.assign(n.bottomSheetRoot.style,e.rootStyle),e.backdropStyle&&Object.assign(n.bottomSheetBackdrop.style,e.backdropStyle),e.containerGapFillerStyle&&Object.assign(n.bottomSheetContainer.style,e.containerStyle),e.containerStyle&&Object.assign(n.bottomSheetContainerGapFiller.style,e.containerGapFillerStyle),e.handleStyle&&Object.assign(n.bottomSheetHandleBar.style,e.handleStyle),e.contentWrapperStyle&&Object.assign(n.bottomSheetContentWrapper.style,e.contentWrapperStyle),{elements:n,eventHandlers:i}}function qe(e){const t=Y("dialog",R([k.Root,ae.Dialog,e.rootClass]),k.Root);t.ariaLabel=e.ariaLabel;const n=Y("section",R([k.Container,e.containerClass]),k.Container);e.containerBorderRadius&&(n.style.borderRadius=Te(e.containerBorderRadius));const o=Y("div",k.GapFiller,k.GapFiller);e.containerBackgroundColor&&(n.style.backgroundColor=e.containerBackgroundColor,o.style.backgroundColor=e.containerBackgroundColor);const r=Y("button",R([k.Handle,ae.Button,e.shouldShowHandle?null:ee.Hidden,e.handleClass]),k.Handle);r.setAttribute("type","button"),r.ariaLabel="bottom sheet close button";const i=Y("span",R([k.HandleBar,e.shouldShowHandle?null:ee.Hidden]),k.HandleBar),a=Y("article",R([k.ContentWrapper,e.contentWrapperClass]),k.ContentWrapper),l=Y("div",R([k.Backdrop,e.backdropClass,ee.Hidden]),k.Backdrop);return e.backdropColor&&(l.style.backgroundColor=e.backdropColor),e.backDropTransition&&(l.style.transition=e.backDropTransition),{bottomSheetRoot:t,bottomSheetBackdrop:l,bottomSheetContainer:n,bottomSheetHandle:r,bottomSheetHandleBar:i,bottomSheetContentWrapper:a,bottomSheetContainerGapFiller:o}}function ze({bottomSheetRoot:e,bottomSheetContainer:t,bottomSheetHandle:n,bottomSheetHandleBar:o,bottomSheetContentWrapper:r,bottomSheetContainerGapFiller:i}){e.appendChild(t),n.appendChild(o),t.appendChild(n),t.appendChild(r),t.appendChild(i)}function Ve({bottomSheetElements:e,bottomSheetProps:t,options:n}){const{bottomSheetRoot:o,bottomSheetContainer:r,bottomSheetHandle:i,bottomSheetContainerGapFiller:a,bottomSheetContentWrapper:l,bottomSheetBackdrop:u}=e,{animationFrame:h}=n,s=new z(i),f=new z(l),C=new z(a);let c=[];const E=new z(window),S=je(E,r,t,n.draggingState),y=Ge(E,r,t,n.draggingState,h),w=$e(E,r,t,n.draggingState,h,n.onClose,n.bottomSheetState);function x(H){H.target instanceof Element&&!o.contains(H.target)&&n.onClose()}function T(H){Ne(n.draggingState,H.target,e.bottomSheetContentWrapper)}function j(H){const B=H??t;B.draggable&&B.backgroundDraggable&&(f.addEventListeners({onStart:T,onStartOptions:{eventPhase:F.Target}}),C.addEventListeners({onStart:T})),B.draggable&&E.addEventListeners({onStart:S,onMove:y,onEnd:w}),B.draggable&&window.document.addEventListener("keyup",b=>{b.key==="Escape"&&n.onClose()}),i.addEventListener("keyup",b=>{if(b.key==="ArrowUp"){n.moveUp();return}if(b.key==="ArrowDown"){n.moveDown();return}if(b.shiftKey&&b.key==="Tab"){const d=G(e.bottomSheetContentWrapper);Re(d)}})}function V(H){const B=H??t;t.shouldCloseOnOutsideClick&&!t.preventClosing?u.addEventListener("click",x):u.style.pointerEvents="none",B.draggable&&(s.addEventListeners({onStart:T}),c.forEach(b=>{b.removeEventListeners({onStart:T})}),c=t.dragTriggers.reduce((b,d)=>{const p=o.querySelectorAll(d);if(!p.length)return b;const g=Array.from(p).map(m=>m instanceof HTMLElement?new z(m):null).filter(m=>!!m);return[...b,...g]},[]),c.forEach(b=>{b.addEventListeners({onStart:T,onStartOptions:{eventPhase:F.Target}})}))}function K(){u.removeEventListener("click",x)}function G(H){let B=[...Array.from(H.childNodes).reverse()];for(;B.length;){const b=B.shift();if(Fe(b))return b;b&&(B=[...B,...Array.from(b.childNodes).reverse()])}return null}function U(){s.removeEventListeners({onStart:T}),f.removeEventListeners({onStart:T}),C.removeEventListeners({onStart:T}),c.forEach(H=>{H.removeEventListeners({onStart:T})}),E.removeEventListeners({onStart:S,onMove:y,onEnd:w})}return{attachEventListeners:j,clearEventListeners:U,attacheOnOpenEventListeners:V,clearOnOpenEventListeners:K}}class Ke{constructor(){J(this,"animationId"),J(this,"isInProgress"),J(this,"startedAt"),this.animationId=null,this.isInProgress=!1,this.startedAt=null}start(t,n,o=!1){this.isInProgress=!0;const r=i=>{this.startedAt||(this.startedAt=i);const a=i-this.startedAt,l=n===0?1:te(a/n,2),u=l>=1&&!o;t(l),u?this.stop():this.animationId=requestAnimationFrame(r)};this.animationId=requestAnimationFrame(r)}stop(){this.isInProgress=!1,this.startedAt=null,A(this.animationId)&&cancelAnimationFrame(this.animationId)}}function Je(e){const{startY:t,endY:n,bottomSheetContainer:o,animationFrame:r,onEnd:i,animationTimingFunction:a,animationDuration:l}=e,u=be(t,n);r.stop();let h=!1;r.start(s=>{ne(o,{y:t+u*a(s)}),!h&&s>=1&&(i==null||i(),h=!0)},l)}const ce=(e,t)=>n=>{Je({...n,animationTimingFunction:e,animationDuration:t})},I={TOP:"top",MIDDLE:"middle",CONTENT_HEIGHT:"content-height",CLOSED:"closed"};function Qe(e){return!(!A(e)||e>1||e<0)}function Ze(e,t){const n={set(o,r,i,a){return t(r,i),Reflect.set(o,r,i,a)}};return new Proxy(e,n)}function et(...e){console.error(e)}const W={EASE:"ease",EASE_IN:"ease-in",EASE_OUT:"ease-out",EASE_IN_OUT:"ease-in-out",SPRING:"spring"};function tt(e){for(const t of Object.values(W))if(t===e)return!0;return!1}function He(e){return!!(e instanceof Object&&"p1x"in e&&"p1y"in e&&"p2x"in e&&"p2y"in e&&A(e.p1x)&&A(e.p1y)&&A(e.p2x)&&A(e.p2y))}function N(e,t,n,o){return function(l){return a(r(l))};function r(l){let u=0,h=1,s=l,f;if(l===0||l===1)return l;for(;u<h;){if(f=i(s),Math.abs(f-l)<.001)return s;l>f?u=s:h=s,s=(h+u)/2}return s}function i(l){return 3*e*l*Math.pow(1-l,2)+3*n*Math.pow(l,2)*(1-l)+Math.pow(l,3)}function a(l){return 3*t*l*Math.pow(1-l,2)+3*o*Math.pow(l,2)*(1-l)+Math.pow(l,3)}}const Oe=N(.25,.1,.25,1),nt=N(.42,0,1,1),Le=N(.42,0,.58,1),ot=N(.4,.1,.6,1),rt=N(.45,1.5,.55,1);function at(e){switch(e){case W.EASE:return Oe;case W.EASE_IN:return nt;case W.EASE_OUT:return Le;case W.EASE_IN_OUT:return ot;case W.SPRING:return rt;default:return Oe}}function Be(e){return typeof e=="boolean"}const it={ariaLabel:"Bottom sheet",content:"",defaultPosition:I.CONTENT_HEIGHT,marginTop:20,snapPoints:[],width:"92%",dragTriggers:[],beforeOpen:()=>{},afterOpen:()=>{},beforeClose:()=>{},afterClose:()=>{},onDragStart:()=>{},onDragMove:()=>{},onDragEnd:()=>{},expandable:!0,preventClosing:!1,draggable:!0,backgroundDraggable:!0,shouldCloseOnOutsideClick:!0,shouldShowBackdrop:!0,shouldShowHandle:!0,backDropTransition:null,backdropColor:null,containerBackgroundColor:null,containerBorderRadius:null,rootClass:null,containerClass:null,handleClass:null,contentWrapperClass:null,backdropClass:null,draggingAnimationTimings:"ease-in-out",draggingAnimationDuration:180,rootStyle:{},containerStyle:{},handleStyle:{},contentWrapperStyle:{},backdropStyle:{},containerGapFillerStyle:{}};function st(e){const t={...it},n=Object.entries(e).reduce((o,r)=>{const[i,a]=r;return se(a)&&(o[i]=a),o},{});return{...t,...n}}function le(e){if(He(e)){const{p1x:t,p1y:n,p2x:o,p2y:r}=e;return N(t,n,o,r)}return tt(e)?at(e):Le}function ct(e,t,n,o){function r(i,a){switch(i){case"content":L(a)&&(e.bottomSheetContentWrapper.innerHTML=a);break;case"width":L(a)&&(e.bottomSheetContainer.style.width=a);break;case"shouldShowHandle":Be(a)||Z(e.bottomSheetHandle,!1);break;case"shouldShowBackdrop":Be(a)||Z(e.bottomSheetBackdrop,!1);break;case"containerBorderRadius":L(a)&&(e.bottomSheetContainer.style.borderRadius=Te(a));break;case"containerBackgroundColor":L(a)&&(e.bottomSheetContainer.style.backgroundColor=a,e.bottomSheetContainerGapFiller.style.backgroundColor=a);break;case"backdropColor":L(a)&&(e.bottomSheetBackdrop.style.backgroundColor=a);break;case"backDropTransition":L(a)&&(e.bottomSheetBackdrop.style.transition=a);break;case"rootClass":if(!L(a))return;X(e.bottomSheetRoot,n.rootClass,a);break;case"containerClass":if(!L(a))return;X(e.bottomSheetContainer,n.containerClass,a);break;case"handleClass":if(!L(a))return;X(e.bottomSheetHandle,n.handleClass,a);break;case"contentWrapperClass":if(!L(a))return;X(e.bottomSheetContentWrapper,n.contentWrapperClass,a);break;case"backdropClass":if(!L(a))return;X(e.bottomSheetBackdrop,n.backdropClass,a);break;case"expandable":o.clearEventListeners(),o.attachEventListeners(n);break;case"preventClosing":o.clearEventListeners(),o.attachEventListeners(n);break;case"draggable":o.clearEventListeners(),o.attachEventListeners(n);break;case"dragTriggers":o.clearEventListeners(),o.attachEventListeners(n);break;case"draggingAnimationTimings":if(He(a)){const l=le(a),u=ce(l,n.draggingAnimationDuration);t.translateContainer=u}break;case"draggingAnimationDuration":if(A(a)){const l=le(n.draggingAnimationTimings),u=ce(l,a);t.translateContainer=u}break;case"rootStyle":n.rootStyle&&Object.assign(e.bottomSheetRoot.style,n.rootStyle);break;case"backdropStyle":n.backdropStyle&&Object.assign(e.bottomSheetBackdrop.style,n.backdropStyle);break;case"containerStyle":n.containerStyle&&Object.assign(e.bottomSheetContainer.style,n.containerStyle);break;case"containerGapFillerStyle":n.containerGapFillerStyle&&Object.assign(e.bottomSheetContainerGapFiller.style,n.containerGapFillerStyle);break;case"handleStyle":n.handleStyle&&Object.assign(e.bottomSheetHandleBar.style,n.handleStyle);break;case"contentWrapperStyle":n.contentWrapperStyle&&Object.assign(e.bottomSheetContentWrapper.style,n.contentWrapperStyle);break}}return r}function lt(e){const t=st(e),n=le(e.draggingAnimationTimings),o={isMounted:!1,translateContainer:ce(n,t.draggingAnimationDuration)},r={startY:null,containerStartTranslate:{x:0,y:0},isDragging:!1,originalDocumentOverflowY:null,originalDocumentOverscrollBehavior:null};function i(){r.originalDocumentOverflowY&&r.originalDocumentOverflowY!=="hidden"&&(document.body.style.overflowY=r.originalDocumentOverflowY),r.originalDocumentOverscrollBehavior&&(document.body.style.position=r.originalDocumentOverscrollBehavior)}const a=new Ke,l={animationFrame:a,onClose:w,bottomSheetState:o,draggingState:r,snapTo:b,moveUp:H,moveDown:B},{elements:u,eventHandlers:h}=Xe(t,l),s=Ze(t,ct(u,o,t,h)),{bottomSheetBackdrop:f,bottomSheetRoot:C,bottomSheetContainer:c}=u,E=d=>{const p=d??window.document.body;p.appendChild(C),p.appendChild(f);const g=window.innerHeight;ne(c,{y:g}),h.attachEventListeners(),o.isMounted=!0},S=()=>{h.clearEventListeners(),Object.values(u).forEach(d=>{d.remove()}),i(),o.isMounted=!1},y=()=>{var d;if(x()||et('Bottom Sheet is not mounted yet. call the "mount" method first.'),(d=e.beforeOpen)==null||d.call(e),T())return;re(f,!0),s.shouldShowBackdrop||_(f,"transparent"),re([c],!0),ne(c,{y:c.clientHeight});const p=window.innerHeight,g=me(p,c.clientHeight,s.marginTop,s.defaultPosition),m=P(c).y;o.translateContainer({startY:m,endY:g,animationFrame:a,bottomSheetContainer:c,onEnd:e.afterOpen});const O=document.body.style.overflowY;r.originalDocumentOverflowY=O||"initial";const D=document.body.style.overscrollBehavior;r.originalDocumentOverscrollBehavior=D||"initial",document.body.style.overflow="hidden",document.body.style.overscrollBehavior="contain",u.bottomSheetHandle.focus(),h.attacheOnOpenEventListeners()};function w(){var d;if(j())return;(d=e.beforeClose)==null||d.call(e);const p=P(c).y,g=c.clientHeight;o.translateContainer({startY:p,endY:g,animationFrame:a,bottomSheetContainer:c,onEnd:()=>{var m;(m=e.afterClose)==null||m.call(e),re([f,c],!1),h.clearOnOpenEventListeners()}}),i()}function x(){return o.isMounted}function T(){const d=P(c).y,p=window.innerHeight,g=c.clientHeight>=p?p:c.clientHeight;return d<=g}function j(){return!T()}function V(){const d=P(c).y,p=c.clientHeight,g=window.innerHeight;if(d<=5&&d>=-5)return I.CONTENT_HEIGHT;const m=p-d;if(m===g/2)return I.MIDDLE;const O=g-s.marginTop,D=10;return m<=O+D&&m>=O-D?I.TOP:I.CLOSED}function K(){return c.clientHeight}function G(d){if(!T())return;const p=P(c).y,g=c.clientHeight-p,m=window.innerHeight-d,O=Ie(g,m),D=q(g,m);o.translateContainer({startY:p,endY:p+(O.isUp?-D:D),animationFrame:a,bottomSheetContainer:c})}function U(d,{viewportHeight:p,visibleHeight:g}){let m=null;for(const O of d){const D=O*p,$=q(g,D);(m===null||$<m)&&(m=$)}return{minOffset:m}}function H(){const d=[...s.snapPoints].reverse(),p=P(c).y,g=c.clientHeight,m=g-p;if(!s.expandable&&m>=g)return;const O=window.innerHeight,D=ge("above",{visibleHeight:m,viewportHeight:O},d),{minOffset:$}=U(D,{visibleHeight:m,viewportHeight:O});if($===null&&m<O-s.marginTop){o.translateContainer({startY:p,endY:me(O,g,s.marginTop,"top"),animationFrame:a,bottomSheetContainer:c});return}A($)&&o.translateContainer({startY:p,endY:p-$,animationFrame:a,bottomSheetContainer:c})}function B(){const d=P(c).y,p=c.clientHeight-d;if(p<1)return;const g=window.innerHeight,m=ge("below",{visibleHeight:p,viewportHeight:g},s.snapPoints),{minOffset:O}=U(m,{visibleHeight:p,viewportHeight:g});A(O)&&o.translateContainer({startY:d,endY:d+O,animationFrame:a,bottomSheetContainer:c})}function b(d){const p=window.innerHeight;if(!Qe(d))return;const g=te(p*d,2);G(g)}return{props:s,elements:u,mount:E,unmount:S,open:y,close:w,getIsMounted:x,getIsOpen:T,getIsClosed:j,getPosition:V,getHeight:K,moveTo:G,snapTo:b}}function ue(){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:()=>I.CLOSED,moveTo:()=>{},snapTo:()=>{},props:{content:""}}}const ut=ue(),dt=v.forwardRef(function(t,n){const{children:o,isOpen:r,setIsOpen:i,afterClose:a,mountingPointRef:l,...u}=t,h=v.useRef(ut),[s,f]=v.useState(h.current);v.useImperativeHandle(n,()=>s,[s]);const C=v.useCallback(()=>{i(!1),a==null||a()},[a]);v.useEffect(()=>{r?s.open():s.close()},[r]);const c=v.useRef(null);return v.useEffect(function(){var w;if(l&&!l.current)return;const S=Ae((w=t.mountingPointRef)==null?void 0:w.current)?t.mountingPointRef.current:window.document.body;if(!S||s.getIsMounted())return;const y=lt({content:"",...u,afterClose:C});return y.mount(S),c.current=y.elements.bottomSheetContentWrapper??null,h.current=y,f(y),()=>{s.unmount()}},[t.mountingPointRef,u,C]),v.useEffect(function(){Object.assign(h.current.props,{...u}),f(h.current)},[u]),v.useEffect(function(){return()=>{h.current.unmount()}},[]),c.current?xe.createPortal(t.children,c.current):null}),pt=ue();function ht(e={}){const t=v.useRef(pt),[n,o]=v.useState(!1),r=!n,[i,a]=v.useState(t.current);v.useEffect(()=>{a(t.current)},[t.current]);const{beforeOpen:l,afterOpen:u,beforeClose:h,afterClose:s,onDragStart:f,onDragMove:C,onDragEnd:c,...E}=e,S=()=>{l==null||l()},y=()=>{u==null||u(),o(!0)},w=()=>{h==null||h()},x=()=>{s==null||s(),o(!1)},T=()=>{f==null||f()},j=(b,d)=>{C==null||C(b,d)},V=()=>{c==null||c()},K=v.useMemo(()=>({ref:t,isOpen:n,setIsOpen:o,beforeOpen:S,afterOpen:y,beforeClose:w,afterClose:x,onDragStart:T,onDragMove:j,onDragEnd:V,...E}),[t.current,n,o,e]),G=v.useCallback(()=>{o(!0)},[o]),U=v.useCallback(()=>{o(!1)},[o]),H=v.useCallback((...b)=>{i.moveTo(...b)},[i]),B=v.useCallback((...b)=>{i.snapTo(...b)},[i]);return{props:K,instance:i,isOpen:n,isClosed:r,setIsOpen:o,open:G,close:U,moveTo:H,snapTo:B}}M.BottomSheet=dt,M.createPlaceholderBottomSheet=ue,M.useBottomSheet=ht,Object.defineProperty(M,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plainsheet/react",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.11",
|
|
4
4
|
"private": false,
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"license": "MIT",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"access": "public"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@plainsheet/core": "0.7.
|
|
34
|
+
"@plainsheet/core": "0.7.11",
|
|
35
35
|
"@plainsheet/utility": "0.0.3"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
@@ -61,6 +61,7 @@
|
|
|
61
61
|
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist",
|
|
62
62
|
"lint": "eslint . --max-warnings 0",
|
|
63
63
|
"test": "vitest run",
|
|
64
|
-
"test:watch": "vitest --ui"
|
|
64
|
+
"test:watch": "vitest --ui",
|
|
65
|
+
"readme": "sh ../../scripts/copy-root-readme.sh"
|
|
65
66
|
}
|
|
66
67
|
}
|