@plainsheet/core 0.7.9 → 0.7.10
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 +4 -6
- package/dist/animation/animation.d.ts.map +1 -1
- package/dist/event-handlers/dragging-handler.d.ts.map +1 -1
- package/dist/initializer/bottom-sheet-initializer.d.ts +1 -1
- package/dist/initializer/bottom-sheet-initializer.d.ts.map +1 -1
- package/dist/initializer/bottom-sheet-props-initializer.d.ts.map +1 -1
- package/dist/plainsheet-core.cjs.js +1 -1
- package/dist/plainsheet-core.es.js +188 -181
- package/dist/plainsheet-core.umd.js +2 -2
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -4,13 +4,11 @@
|
|
|
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
|
-
{"version":3,"file":"animation.d.ts","sourceRoot":"","sources":["../../src/animation/animation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAElF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAGzE,MAAM,WAAW,wBAAwB;IACvC,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,EAAE,cAAc,CAAC;IAC/B,oBAAoB,EAAE,WAAW,CAAC;IAClC,KAAK,CAAC,EAAE,MAAM,IAAI,CAAC;IACnB,uBAAuB,EAAE,uBAAuB,CAAC;IACjD;;OAEG;IACH,iBAAiB,EAAE,MAAM,CAAC;CAC3B;AACD,MAAM,MAAM,uCAAuC,GAAG,IAAI,CACxD,wBAAwB,EACxB,yBAAyB,GAAG,mBAAmB,CAChD,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG,UAAU,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAE/E,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,wBAAwB,GAAG,IAAI,CA0BzE;AAED,eAAO,MAAM,0BAA0B,
|
|
1
|
+
{"version":3,"file":"animation.d.ts","sourceRoot":"","sources":["../../src/animation/animation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAElF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAGzE,MAAM,WAAW,wBAAwB;IACvC,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,EAAE,cAAc,CAAC;IAC/B,oBAAoB,EAAE,WAAW,CAAC;IAClC,KAAK,CAAC,EAAE,MAAM,IAAI,CAAC;IACnB,uBAAuB,EAAE,uBAAuB,CAAC;IACjD;;OAEG;IACH,iBAAiB,EAAE,MAAM,CAAC;CAC3B;AACD,MAAM,MAAM,uCAAuC,GAAG,IAAI,CACxD,wBAAwB,EACxB,yBAAyB,GAAG,mBAAmB,CAChD,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG,UAAU,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAE/E,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,wBAAwB,GAAG,IAAI,CA0BzE;AAED,eAAO,MAAM,0BAA0B,GACpC,oBAAoB,uBAAuB,EAAE,cAAc,MAAM,MACjE,QAAQ,uCAAuC,SAM/C,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dragging-handler.d.ts","sourceRoot":"","sources":["../../src/event-handlers/dragging-handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AASjE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAGzE,OAAO,KAAK,EACV,QAAQ,EACR,gBAAgB,EACjB,MAAM,2CAA2C,CAAC;AACnD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AAI7E,eAAO,MAAM,sBAAsB,
|
|
1
|
+
{"version":3,"file":"dragging-handler.d.ts","sourceRoot":"","sources":["../../src/event-handlers/dragging-handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AASjE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAGzE,OAAO,KAAK,EACV,QAAQ,EACR,gBAAgB,EACjB,MAAM,2CAA2C,CAAC;AACnD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AAI7E,eAAO,MAAM,sBAAsB,GACjC,eAAe,aAAa,EAC5B,cAAc,WAAW,GAAG,IAAI,EAChC,gBAAgB,WAAW,KAC1B,IAYF,CAAC;AAEF,eAAO,MAAM,eAAe,GAExB,oBAAoB,gBAAgB,EACpC,sBAAsB,WAAW,EACjC,kBAAkB,QAAQ,CAAC,oBAAoB,CAAC,EAChD,eAAe,aAAa,MAE7B,OAAO,QAAQ,SAKf,CAAC;AAEJ,eAAO,MAAM,cAAc,GAEvB,oBAAoB,gBAAgB,EACpC,sBAAsB,WAAW,EACjC,kBAAkB,QAAQ,CAAC,oBAAoB,CAAC,EAChD,eAAe,aAAa,EAC5B,gBAAgB,cAAc,MAE/B,OAAO,QAAQ,SAUf,CAAC;AAyFJ,eAAO,MAAM,aAAa,GAEtB,eAAe,gBAAgB,EAC/B,sBAAsB,WAAW,EACjC,kBAAkB,QAAQ,CAAC,oBAAoB,CAAC,EAChD,eAAe,aAAa,EAC5B,gBAAgB,cAAc,EAC9B,SAAS,MAAM,IAAI,EACnB,kBAAkB,gBAAgB,MAEnC,OAAO,QAAQ,SAsHf,CAAC"}
|
|
@@ -32,7 +32,7 @@ export interface InitializeEventsParams {
|
|
|
32
32
|
export interface InitializeEventsReturnType {
|
|
33
33
|
attachEventListeners: (updatedProps?: InitializeEventsParams["bottomSheetProps"]) => void;
|
|
34
34
|
clearEventListeners: () => void;
|
|
35
|
-
attacheOnOpenEventListeners: () => void;
|
|
35
|
+
attacheOnOpenEventListeners: (updatedProps?: InitializeEventsParams["bottomSheetProps"]) => void;
|
|
36
36
|
clearOnOpenEventListeners: () => void;
|
|
37
37
|
}
|
|
38
38
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bottom-sheet-initializer.d.ts","sourceRoot":"","sources":["../../src/initializer/bottom-sheet-initializer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAejE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAOzE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AAG7E,MAAM,WAAW,kBAAkB;IACjC,cAAc,EAAE,cAAc,CAAC;IAC/B,gBAAgB,EAAE,gBAAgB,CAAC;IACnC,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,aAAa,EAAE,aAAa,CAAC;IAC7B,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,QAAQ,EAAE,MAAM,IAAI,CAAC;CACtB;AAED,UAAU,uCAAuC;IAC/C,QAAQ,EAAE,mBAAmB,CAAC;IAC9B,aAAa,EAAE,0BAA0B,CAAC;CAC3C;AAED,wBAAgB,6BAA6B,CAC3C,KAAK,EAAE,QAAQ,CAAC,oBAAoB,CAAC,EACrC,OAAO,EAAE,kBAAkB,GAC1B,uCAAuC,CAiDzC;AAED,MAAM,WAAW,mBAAmB;IAClC,eAAe,EAAE,WAAW,CAAC;IAC7B,mBAAmB,EAAE,WAAW,CAAC;IACjC,oBAAoB,EAAE,WAAW,CAAC;IAClC,iBAAiB,EAAE,WAAW,CAAC;IAC/B,oBAAoB,EAAE,WAAW,CAAC;IAClC,yBAAyB,EAAE,WAAW,CAAC;IACvC,6BAA6B,EAAE,WAAW,CAAC;CAC5C;AAkHD,MAAM,WAAW,sBAAsB;IACrC,mBAAmB,EAAE,mBAAmB,CAAC;IACzC,gBAAgB,EAAE,QAAQ,CAAC,oBAAoB,CAAC,CAAC;IACjD,OAAO,EAAE,kBAAkB,CAAC;CAC7B;AAED,MAAM,WAAW,0BAA0B;IACzC,oBAAoB,EAAE,CACpB,YAAY,CAAC,EAAE,sBAAsB,CAAC,kBAAkB,CAAC,KACtD,IAAI,CAAC;IACV,mBAAmB,EAAE,MAAM,IAAI,CAAC;IAChC,2BAA2B,EAAE,
|
|
1
|
+
{"version":3,"file":"bottom-sheet-initializer.d.ts","sourceRoot":"","sources":["../../src/initializer/bottom-sheet-initializer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAejE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAOzE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AAG7E,MAAM,WAAW,kBAAkB;IACjC,cAAc,EAAE,cAAc,CAAC;IAC/B,gBAAgB,EAAE,gBAAgB,CAAC;IACnC,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,aAAa,EAAE,aAAa,CAAC;IAC7B,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,QAAQ,EAAE,MAAM,IAAI,CAAC;CACtB;AAED,UAAU,uCAAuC;IAC/C,QAAQ,EAAE,mBAAmB,CAAC;IAC9B,aAAa,EAAE,0BAA0B,CAAC;CAC3C;AAED,wBAAgB,6BAA6B,CAC3C,KAAK,EAAE,QAAQ,CAAC,oBAAoB,CAAC,EACrC,OAAO,EAAE,kBAAkB,GAC1B,uCAAuC,CAiDzC;AAED,MAAM,WAAW,mBAAmB;IAClC,eAAe,EAAE,WAAW,CAAC;IAC7B,mBAAmB,EAAE,WAAW,CAAC;IACjC,oBAAoB,EAAE,WAAW,CAAC;IAClC,iBAAiB,EAAE,WAAW,CAAC;IAC/B,oBAAoB,EAAE,WAAW,CAAC;IAClC,yBAAyB,EAAE,WAAW,CAAC;IACvC,6BAA6B,EAAE,WAAW,CAAC;CAC5C;AAkHD,MAAM,WAAW,sBAAsB;IACrC,mBAAmB,EAAE,mBAAmB,CAAC;IACzC,gBAAgB,EAAE,QAAQ,CAAC,oBAAoB,CAAC,CAAC;IACjD,OAAO,EAAE,kBAAkB,CAAC;CAC7B;AAED,MAAM,WAAW,0BAA0B;IACzC,oBAAoB,EAAE,CACpB,YAAY,CAAC,EAAE,sBAAsB,CAAC,kBAAkB,CAAC,KACtD,IAAI,CAAC;IACV,mBAAmB,EAAE,MAAM,IAAI,CAAC;IAChC,2BAA2B,EAAE,CAC3B,YAAY,CAAC,EAAE,sBAAsB,CAAC,kBAAkB,CAAC,KACtD,IAAI,CAAC;IACV,yBAAyB,EAAE,MAAM,IAAI,CAAC;CACvC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bottom-sheet-props-initializer.d.ts","sourceRoot":"","sources":["../../src/initializer/bottom-sheet-props-initializer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EACpB,gBAAgB,EAChB,wBAAwB,EACzB,MAAM,WAAW,CAAC;AACnB,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,WAAW,CAAC;AAezD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAIlE,OAAO,KAAK,EACV,mBAAmB,EACnB,0BAA0B,EAC3B,MAAM,4BAA4B,CAAC;AAGpC,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,oBAAoB,GAC1B,wBAAwB,CAuB1B;AAED,wBAAgB,6BAA6B,CAC3C,wBAAwB,EAAE,oBAAoB,CAAC,0BAA0B,CAAC,GACzE,uBAAuB,CAWzB;AAED,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,mBAAmB,EAC7B,gBAAgB,EAAE,gBAAgB,EAClC,iBAAiB,EAAE,QAAQ,CAAC,oBAAoB,CAAC,EACjD,aAAa,EAAE,0BAA0B,GACxC,kBAAkB,
|
|
1
|
+
{"version":3,"file":"bottom-sheet-props-initializer.d.ts","sourceRoot":"","sources":["../../src/initializer/bottom-sheet-props-initializer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EACpB,gBAAgB,EAChB,wBAAwB,EACzB,MAAM,WAAW,CAAC;AACnB,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,WAAW,CAAC;AAezD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAIlE,OAAO,KAAK,EACV,mBAAmB,EACnB,0BAA0B,EAC3B,MAAM,4BAA4B,CAAC;AAGpC,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,oBAAoB,GAC1B,wBAAwB,CAuB1B;AAED,wBAAgB,6BAA6B,CAC3C,wBAAwB,EAAE,oBAAoB,CAAC,0BAA0B,CAAC,GACzE,uBAAuB,CAWzB;AAED,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,mBAAmB,EAC7B,gBAAgB,EAAE,gBAAgB,EAClC,iBAAiB,EAAE,QAAQ,CAAC,oBAAoB,CAAC,EACjD,aAAa,EAAE,0BAA0B,GACxC,kBAAkB,CA8LpB"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
(function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode('.pbs-root{position:fixed;left:0;bottom:0;display:flex;flex-direction:column;align-items:center;justify-content:flex-start;width:100%;height:fit-content;max-height:100vh;z-index:2}.pbs-dialog-reset{background-color:transparent;color:inherit;border:none;outline:none;padding:0;margin:0}.pbs-backdrop{position:fixed;top:0;left:0;width:100%;height:100%;background-color:transparent;z-index:1;transition:background-color .2s ease-out}.pbs-backdrop.hidden{visibility:hidden}.pbs-backdrop.open{background-color:#454545b3}.pbs-backdrop.transparent{background-color:transparent}.pbs-container{--pbs-container-background-color: rgb(240, 240, 240);background-color:var(--pbs-container-background-color);position:relative;display:none;flex-direction:column;align-items:center;justify-content:flex-start;width:92%;height:fit-content;max-height:100vh;border-radius:10px 10px 0 0}.pbs-container.open{display:flex}.pbs-container .pbs-gap-filler{position:absolute;bottom:calc(-100vh + .5px);left:0;background-color:var(--pbs-container-background-color);content:"";width:100%;height:100vh}.pbs-handle{position:relative;display:flex;align-items:center;justify-content:center;width:100%;height:30px;cursor:pointer}.pbs-handle.hidden{display:none}.pbs-button-reset{background-color:transparent;-webkit-appearance:none;-moz-appearance:none;appearance:none;outline:none;border:none}button:focus.pbs-button-reset{outline:none}.pbs-handle-bar{background-color:#a8a8a8;position:relative;width:12%;height:7px;border-radius:12px}.pbs-handle-bar.hidden{display:none}.pbs-content-wrapper{position:relative;width:100%;height:fit-content;max-height:100%;overflow-y:scroll}.pbs-content-wrapper::-webkit-scrollbar{display:none}.example{-ms-overflow-style:none;scrollbar-width:none}')),document.head.appendChild(e)}}catch(n){console.error("vite-plugin-css-injected-by-js",n)}})();
|
|
2
|
-
"use strict";var Bt=Object.defineProperty;var Dt=(t,n,e)=>n in t?Bt(t,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[n]=e;var U=(t,n,e)=>Dt(t,typeof n!="symbol"?n+"":n,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function w(t){return typeof t=="string"}function Yt(t,n){return t.classList.contains(tt(n))}function X(t,n){t.classList.add(tt(n))}function ot(t,n){t.classList.remove(tt(n))}function j(t,n,e){w(e)&&(w(n)&&ot(t,n),X(t,e))}function tt(t){return w(t)?t.trim().replace(/\./g,""):""}function _(t){return t.map(n=>tt(n)).filter(Boolean).join(" ")}function It(t){return t.map(n=>n==null?void 0:n.trim()).filter(Boolean).map(n=>`.${n}`).join(" ")}const dt="open",ft="hidden";function rt(t,n){const e=n;if(Array.isArray(t)){t.forEach(r=>{q(r,e),r.setAttribute("aria-modal",e?"true":"false")});return}q(t,e),t.setAttribute("aria-modal",e?"true":"false")}function q(t,n){n?(X(t,dt),ot(t,ft)):(X(t,ft),ot(t,dt))}function yt(t){return t instanceof HTMLElement}function Y(t){return typeof t=="number"&&!Number.isNaN(t)}function Nt(t){yt(t)&&t.focus()}function Mt(t){if(!yt(t)||t.offsetParent===null||"disabled"in t&&t.disabled)return!1;const e=t.getAttribute("tabindex"),r=Y(e)?parseInt(e,10):-1,i=["INPUT","BUTTON","SELECT","TEXTAREA","A","AREA","IFRAME"].includes(t.tagName),a=t instanceof HTMLAnchorElement&&t.href!==""||t instanceof HTMLAreaElement&&t.href!=="";return i||a||r>-1}var y=(t=>(t.Backdrop="pbs-backdrop",t.Root="pbs-root",t.Container="pbs-container",t.GapFiller="pbs-gap-filler",t.Handle="pbs-handle",t.HandleBar="pbs-handle-bar",t.ContentWrapper="pbs-content-wrapper",t))(y||{}),J=(t=>(t.Button="pbs-button-reset",t.Dialog="pbs-dialog-reset",t))(J||{}),V=(t=>(t.Hidden="hidden",t))(V||{});function N(t,n,e){const r=document.createElement(t);return n.split(" ").forEach(i=>{X(r,i)}),w(e)&&r.setAttribute("data-testid",e),r}const Pt={CONTENTS_WRAPPER:It([y.Root,y.ContentWrapper])};function gt(t,n,e,r){switch(r){case"content-height":return n>=t?St(t,n,e):0;case"middle":return-(t/2-n);case"top":return-(t-n)+e;default:return 0}}function Ct(t,n){const e=n<t,r=n>t;return{isUp:e,isDown:r,stayedSame:n===t}}function Et(t,n){return n<t?-(t-n):n-t}function $(t,n){return t>n?t-n:n-t}function xt(t,n){const e=t<n,r=t>n;return{isUp:e,isDown:r,stayedSame:t===n}}function ht(t,n,e){const r=t==="above";return e.filter(o=>{const i=o*n.viewportHeight;return r?n.visibleHeight<i:n.visibleHeight>i})}function St(t,n,e){return-(t-n)+e}function mt(t){return Number(t.replace("px",""))}function Q(t,...n){return Number(t.toFixed(...n))}function vt(t){const n=/(?<type>\w+)\((?<values>[^)]+)\)/g,e=[];let r;for(;(r=n.exec(t))!==null;){const o=r[1],i=r[2].split(",").map(a=>a.trim());e.push({type:o,values:i})}return e}function Ft(t){const n=t.style.transform,e=vt(n);return{transform:n,transformValues:e}}function Ot(t,n){const e=t.find(r=>r.type.startsWith(n));return e||null}const it="translate";function I(t){const n=t.style.transform,e=vt(n),r=Ot(e,it);return wt(r??{type:it,values:[]})}function Z(t,{x:n,y:e}){const{transform:r,transformValues:o}=Ft(t),i=Ot(o,it);if(i){const a=wt(i);t.style.transform=`translate(${n??a.x??0}px,${e??a.y??0}px)`;return}if(r){t.style.transform=`${r}, translate(${n??0}px,${e??0}px)`;return}t.style.transform=`translate(${n??0}px,${e??0}px)`}function wt(t){if(t.type!=="translate")throw new Error(`Could not get coordinates from ${t.type}, since is not translate.`);const n=t.values[0],e=t.values[1];return{x:mt(n)??0,y:mt(e)??0}}function at(t){return t!=null}function bt(t,{min:n,max:e}){return at(e)&&t>=e?e:at(n)&&t<=n?n:t}const Rt=(t,n,e)=>{n instanceof HTMLElement&&!Yt(n,y.Handle)&&e.scrollTop>=1||(t.isDragging=!0)},_t=(t,n,e,r)=>o=>{r.startY=t.getCoordinates(o).y,r.containerStartTranslate=I(n),e.onDragStart()},Gt=(t,n,e,r,o)=>i=>{Ut(i,t,e,r,o,n,e.marginTop)};function Ut(t,n,e,r,o,i,a){if(!r.isDragging||!Y(r.startY))return;const u=n.getCoordinates(t).y,s=Et(r.startY,u),b=window.innerHeight,l=i.clientHeight,f=l-(r.containerStartTranslate.y+s);if(f>=b)return;const p=Ct(r.startY,u);if(p.isUp&&!e.expandable&&f>=l||e.preventClosing&&f<=l)return;o.start(()=>{Z(i,{y:r.containerStartTranslate.y+s})},0);const v=b-a,c=l-r.containerStartTranslate.y;if(p.isUp){const T=v-c,O=v-f,k=bt(1-Q(O/T,2),{min:0,max:1});e.onDragMove(p,k)}else if(p.isDown){const T=bt(Q(1-f/c,2),{min:0,max:1});e.onDragMove(p,T)}}const jt=(t,n,e,r,o,i,a)=>u=>{if(!r.isDragging||(r.isDragging=!1,!Y(r.startY)))return;e.onDragEnd();const s=r.startY,b=t.getCoordinates(u).y,l=I(n).y,f=Ct(s,b),p=window.innerHeight,v=n.clientHeight;if(f.isUp){const c=[...e.snapPoints].sort((k,B)=>k-B),T=v+-l;if(!e.expandable&&T>=v)return;for(const k of c){const B=k*window.innerHeight;if(T<=B){const L=$(T,B);a.translateContainer({startY:l,endY:l-L,animationFrame:o,bottomSheetContainer:n});return}}const O=St(p,v,e.marginTop);a.translateContainer({startY:l,endY:O,animationFrame:o,bottomSheetContainer:n})}else if(f.isDown){const c=[...e.snapPoints].sort((T,O)=>O-T);for(const T of c){const O=T*window.innerHeight,k=v+-l;if(k>=O){const B=$(k,O);a.translateContainer({startY:l,endY:l+B,animationFrame:o,bottomSheetContainer:n});return}}if(e.preventClosing){const T=v+-l;if(T>=v){const O=$(T,v);a.translateContainer({startY:l,endY:l+O,animationFrame:o,bottomSheetContainer:n})}return}i()}};var x=(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))(x||{});function st(t){switch(t){case 0:return 0;case 1:return 1;case 2:return 2;case 3:return 3;default:return-1}}const Wt={eventPhase:x.All};class W{constructor(n){U(this,"currentTarget");this.currentTarget=n}addEventListeners({onStart:n,onStartOptions:e=Wt,onMove:r,onEnd:o}){this.addTouchEventListeners({onStart:n,onStartOptions:e,onMove:r,onEnd:o}),this.addMouseEventListeners({onStart:n,onStartOptions:e,onMove:r,onEnd:o})}addTouchEventListeners({onStart:n,onStartOptions:e,onMove:r,onEnd:o}){n&&this.currentTarget.addEventListener("touchstart",i=>{if(e.eventPhase===x.All){n(i);return}st(i.eventPhase)===e.eventPhase&&n(i)},{passive:!0}),r&&this.currentTarget.addEventListener("touchmove",r),o&&this.currentTarget.addEventListener("touchend",o)}addMouseEventListeners({onStart:n,onStartOptions:e,onMove:r,onEnd:o}){n&&this.currentTarget.addEventListener("mousedown",i=>{if(e.eventPhase===x.All){n(i);return}st(i.eventPhase)===e.eventPhase&&n(i)},{passive:!0}),r&&this.currentTarget.addEventListener("mousemove",r),o&&this.currentTarget.addEventListener("mouseup",i=>{o(i)})}removeEventListeners({onStart:n,onMove:e,onEnd:r}){n&&this.currentTarget.removeEventListener("touchstart",n),r&&this.currentTarget.removeEventListener("touchend",r),e&&this.currentTarget.removeEventListener("touchmove",e),n&&this.currentTarget.removeEventListener("mousedown",n),e&&this.currentTarget.removeEventListener("mousemove",e),r&&this.currentTarget.removeEventListener("mouseup",r)}getCoordinates(n){if(n.type==="touchstart"||n.type==="mousedown"){if("touches"in n)return{x:n.touches[0].clientX,y:n.touches[0].clientY};if(n instanceof MouseEvent)return{x:n.clientX,y:n.clientY}}if(n.type==="touchend"||n.type==="mouseup"||n.type==="mousemove"||n.type==="touchmove"){if("touches"in n)return{x:n.changedTouches[0].clientX,y:n.changedTouches[0].clientY};if(n instanceof MouseEvent)return{x:n.clientX,y:n.clientY}}return{x:0,y:0}}}function Ht(t){const n=t;return`${n} ${n} 0px 0px`}function Vt(t,n){const e=$t(t);Xt(e),e.bottomSheetContainer.style.width=t.width;const r=document.createElement("div");r.innerHTML=t.content??"";const o=window.innerHeight;e.bottomSheetContainer.style.maxHeight=`${o}px`,e.bottomSheetContentWrapper.appendChild(r);const i=Kt({bottomSheetElements:e,bottomSheetProps:t,options:n});return t.rootStyle&&Object.assign(e.bottomSheetRoot.style,t.rootStyle),t.backdropStyle&&Object.assign(e.bottomSheetBackdrop.style,t.backdropStyle),t.containerGapFillerStyle&&Object.assign(e.bottomSheetContainer.style,t.containerStyle),t.containerStyle&&Object.assign(e.bottomSheetContainerGapFiller.style,t.containerGapFillerStyle),t.handleStyle&&Object.assign(e.bottomSheetHandleBar.style,t.handleStyle),t.contentWrapperStyle&&Object.assign(e.bottomSheetContentWrapper.style,t.contentWrapperStyle),{elements:e,eventHandlers:i}}function $t(t){const n=N("dialog",_([y.Root,J.Dialog,t.rootClass]),y.Root);n.ariaLabel=t.ariaLabel;const e=N("section",_([y.Container,t.containerClass]),y.Container);t.containerBorderRadius&&(e.style.borderRadius=Ht(t.containerBorderRadius));const r=N("div",y.GapFiller,y.GapFiller);t.containerBackgroundColor&&(e.style.backgroundColor=t.containerBackgroundColor,r.style.backgroundColor=t.containerBackgroundColor);const o=N("button",_([y.Handle,J.Button,t.shouldShowHandle?null:V.Hidden,t.handleClass]),y.Handle);o.setAttribute("type","button"),o.ariaLabel="bottom sheet close button";const i=N("span",_([y.HandleBar,t.shouldShowHandle?null:V.Hidden]),y.HandleBar),a=N("article",_([y.ContentWrapper,t.contentWrapperClass]),y.ContentWrapper),u=N("div",_([y.Backdrop,t.backdropClass,V.Hidden]),y.Backdrop);return t.backdropColor&&(u.style.backgroundColor=t.backdropColor),t.backDropTransition&&(u.style.transition=t.backDropTransition),{bottomSheetRoot:n,bottomSheetBackdrop:u,bottomSheetContainer:e,bottomSheetHandle:o,bottomSheetHandleBar:i,bottomSheetContentWrapper:a,bottomSheetContainerGapFiller:r}}function Xt({bottomSheetRoot:t,bottomSheetContainer:n,bottomSheetHandle:e,bottomSheetHandleBar:r,bottomSheetContentWrapper:o,bottomSheetContainerGapFiller:i}){t.appendChild(n),e.appendChild(r),n.appendChild(e),n.appendChild(o),n.appendChild(i)}function Kt({bottomSheetElements:t,bottomSheetProps:n,options:e}){const{bottomSheetRoot:r,bottomSheetContainer:o,bottomSheetHandle:i,bottomSheetContainerGapFiller:a,bottomSheetContentWrapper:u,bottomSheetBackdrop:s}=t,{animationFrame:b}=e,l=new W(i),f=new W(u),p=new W(a),v=n.dragTriggers.reduce((E,H)=>{const C=r.querySelectorAll(H);if(!C.length)return E;const R=Array.from(C).map(d=>d instanceof HTMLElement?new W(d):null).filter(d=>!!d);return[...E,...R]},[]),c=new W(window),T=_t(c,o,n,e.draggingState),O=Gt(c,o,n,e.draggingState,b),k=jt(c,o,n,e.draggingState,b,e.onClose,e.bottomSheetState);function B(E){E.target instanceof Element&&!r.contains(E.target)&&e.onClose()}function L(E){Rt(e.draggingState,E.target,t.bottomSheetContentWrapper)}function F(E){const H=E??n;H.draggable&&(l.addEventListeners({onStart:L}),v.forEach(C=>{C.addEventListeners({onStart:L,onStartOptions:{eventPhase:x.Target}})})),H.draggable&&H.backgroundDraggable&&(f.addEventListeners({onStart:L,onStartOptions:{eventPhase:x.Target}}),p.addEventListeners({onStart:L})),H.draggable&&c.addEventListeners({onStart:T,onMove:O,onEnd:k}),H.draggable&&window.document.addEventListener("keyup",C=>{C.key==="Escape"&&e.onClose()}),i.addEventListener("keyup",C=>{if(C.key==="ArrowUp"){e.moveUp();return}if(C.key==="ArrowDown"){e.moveDown();return}if(C.shiftKey&&C.key==="Tab"){const R=et(t.bottomSheetContentWrapper);Nt(R)}})}function K(){n.shouldCloseOnOutsideClick?s.addEventListener("click",B):s.style.pointerEvents="none"}function nt(){s.removeEventListener("click",B)}function et(E){let H=[...Array.from(E.childNodes).reverse()];for(;H.length;){const C=H.shift();if(Mt(C))return C;C&&(H=[...H,...Array.from(C.childNodes).reverse()])}return null}function z(){l.removeEventListeners({onStart:L}),f.removeEventListeners({onStart:L}),p.removeEventListeners({onStart:L}),v.forEach(E=>{E.removeEventListeners({onStart:L})}),c.removeEventListeners({onStart:T,onMove:O,onEnd:k})}return{attachEventListeners:F,clearEventListeners:z,attacheOnOpenEventListeners:K,clearOnOpenEventListeners:nt}}class zt{constructor(){U(this,"animationId");U(this,"isInProgress");U(this,"startedAt");this.animationId=null,this.isInProgress=!1,this.startedAt=null}start(n,e,r=!1){this.isInProgress=!0;const o=i=>{this.startedAt||(this.startedAt=i);const a=i-this.startedAt,s=e===0?1:Q(a/e,2),b=s>=1&&!r;n(s),b?this.stop():this.animationId=requestAnimationFrame(o)};this.animationId=requestAnimationFrame(o)}stop(){this.isInProgress=!1,this.startedAt=null,Y(this.animationId)&&cancelAnimationFrame(this.animationId)}}function qt(t){const{startY:n,endY:e,bottomSheetContainer:r,animationFrame:o,onEnd:i,animationTimingFunction:a,animationDuration:u}=t,s=Et(n,e);o.stop();let b=!1;o.start(l=>{Z(r,{y:n+s*a(l)}),!b&&l>=1&&(i==null||i(),b=!0)},u)}const ct=(t,n)=>e=>{qt({...e,animationTimingFunction:t,animationDuration:n})},P={TOP:"top",MIDDLE:"middle",CONTENT_HEIGHT:"content-height",CLOSED:"closed"};function Jt(t){return!(!Y(t)||t>1||t<0)}function Qt(t,n){const e={set(r,o,i,a){return n(o,i),Reflect.set(r,o,i,a)}};return new Proxy(t,e)}function Zt(...t){console.error(t)}const M={EASE:"ease",EASE_IN:"ease-in",EASE_OUT:"ease-out",EASE_IN_OUT:"ease-in-out",SPRING:"spring"};function kt(t){for(const n of Object.values(M))if(n===t)return!0;return!1}function ut(t){return!!(t instanceof Object&&"p1x"in t&&"p1y"in t&&"p2x"in t&&"p2y"in t&&Y(t.p1x)&&Y(t.p1y)&&Y(t.p2x)&&Y(t.p2y))}function G(t,n,e,r){return function(s){return u(i(s))};function i(s){let b=0,l=1,f=s,p;if(s===0||s===1)return s;for(;b<l;){if(p=a(f),Math.abs(p-s)<.001)return f;s>p?b=f:l=f,f=(l+b)/2}return f}function a(s){return 3*t*s*Math.pow(1-s,2)+3*e*Math.pow(s,2)*(1-s)+Math.pow(s,3)}function u(s){return 3*n*s*Math.pow(1-s,2)+3*r*Math.pow(s,2)*(1-s)+Math.pow(s,3)}}const pt=G(.25,.1,.25,1),tn=G(.42,0,1,1),Lt=G(.42,0,.58,1),nn=G(.4,.1,.6,1),en=G(.45,1.5,.55,1);function rn(t){switch(t){case M.EASE:return pt;case M.EASE_IN:return tn;case M.EASE_OUT:return Lt;case M.EASE_IN_OUT:return nn;case M.SPRING:return en;default:return pt}}function Tt(t){return typeof t=="boolean"}const At={ariaLabel:"Bottom sheet",content:"",defaultPosition:P.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 on(t){const n={...At},e=Object.entries(t).reduce((o,i)=>{const[a,u]=i;return at(u)&&(o[a]=u),o},{});return{...n,...e}}function lt(t){if(ut(t)){const{p1x:n,p1y:e,p2x:r,p2y:o}=t;return G(n,e,r,o)}return kt(t)?rn(t):Lt}function an(t,n,e,r){function o(i,a){switch(i){case"content":w(a)&&(t.bottomSheetContentWrapper.innerHTML=a);break;case"width":w(a)&&(t.bottomSheetContainer.style.width=a);break;case"shouldShowHandle":Tt(a)||q(t.bottomSheetHandle,!1);break;case"shouldShowBackdrop":Tt(a)||q(t.bottomSheetBackdrop,!1);break;case"containerBorderRadius":w(a)&&(t.bottomSheetContainer.style.borderRadius=Ht(a));break;case"containerBackgroundColor":w(a)&&(t.bottomSheetContainer.style.backgroundColor=a,t.bottomSheetContainerGapFiller.style.backgroundColor=a);break;case"backdropColor":w(a)&&(t.bottomSheetBackdrop.style.backgroundColor=a);break;case"backDropTransition":w(a)&&(t.bottomSheetBackdrop.style.transition=a);break;case"rootClass":if(!w(a))return;j(t.bottomSheetRoot,e.rootClass,a);break;case"containerClass":if(!w(a))return;j(t.bottomSheetContainer,e.containerClass,a);break;case"handleClass":if(!w(a))return;j(t.bottomSheetHandle,e.handleClass,a);break;case"contentWrapperClass":if(!w(a))return;j(t.bottomSheetContentWrapper,e.contentWrapperClass,a);break;case"backdropClass":if(!w(a))return;j(t.bottomSheetBackdrop,e.backdropClass,a);break;case"expandable":r.clearEventListeners(),r.attachEventListeners(e);break;case"preventClosing":r.clearEventListeners(),r.attachEventListeners(e);break;case"draggable":r.clearEventListeners(),r.attachEventListeners(e);break;case"draggingAnimationTimings":if(ut(a)){const u=lt(a),s=ct(u,e.draggingAnimationDuration);n.translateContainer=s}break;case"draggingAnimationDuration":if(Y(a)){const u=lt(e.draggingAnimationTimings),s=ct(u,a);n.translateContainer=s}break;case"rootStyle":e.rootStyle&&Object.assign(t.bottomSheetRoot.style,e.rootStyle);break;case"backdropStyle":e.backdropStyle&&Object.assign(t.bottomSheetBackdrop.style,e.backdropStyle);break;case"containerStyle":e.containerStyle&&Object.assign(t.bottomSheetContainer.style,e.containerStyle);break;case"containerGapFillerStyle":e.containerGapFillerStyle&&Object.assign(t.bottomSheetContainerGapFiller.style,e.containerGapFillerStyle);break;case"handleStyle":e.handleStyle&&Object.assign(t.bottomSheetHandleBar.style,e.handleStyle);break;case"contentWrapperStyle":e.contentWrapperStyle&&Object.assign(t.bottomSheetContentWrapper.style,e.contentWrapperStyle);break}}return o}function sn(t){const n=on(t),e=lt(t.draggingAnimationTimings),o={isMounted:!1,translateContainer:ct(e,n.draggingAnimationDuration)},i={startY:null,containerStartTranslate:{x:0,y:0},isDragging:!1,originalDocumentOverflowY:null,originalDocumentOverscrollBehavior:null};function a(){i.originalDocumentOverflowY&&i.originalDocumentOverflowY!=="hidden"&&(document.body.style.overflowY=i.originalDocumentOverflowY),i.originalDocumentOverscrollBehavior&&(document.body.style.position=i.originalDocumentOverscrollBehavior)}const u=new zt,s={animationFrame:u,onClose:B,bottomSheetState:o,draggingState:i,snapTo:R,moveUp:H,moveDown:C},{elements:b,eventHandlers:l}=Vt(n,s),f=Qt(n,an(b,o,n,l)),{bottomSheetBackdrop:p,bottomSheetRoot:v,bottomSheetContainer:c}=b,T=d=>{const g=d??window.document.body;g.appendChild(v),g.appendChild(p);const h=window.innerHeight;Z(c,{y:h}),l.attachEventListeners(),o.isMounted=!0},O=()=>{l.clearEventListeners(),Object.values(b).forEach(d=>{d.remove()}),a(),o.isMounted=!1},k=()=>{var D;if(L()||Zt('Bottom Sheet is not mounted yet. call the "mount" method first.'),(D=t.beforeOpen)==null||D.call(t),F())return;rt(p,!0),f.shouldShowBackdrop||X(p,"transparent"),rt([c],!0),Z(c,{y:c.clientHeight});const g=window.innerHeight,h=gt(g,c.clientHeight,f.marginTop,f.defaultPosition),m=I(c).y;o.translateContainer({startY:m,endY:h,animationFrame:u,bottomSheetContainer:c,onEnd:t.afterOpen});const S=document.body.style.overflowY;i.originalDocumentOverflowY=S||"initial";const A=document.body.style.overscrollBehavior;i.originalDocumentOverscrollBehavior=A||"initial",document.body.style.overflow="hidden",document.body.style.overscrollBehavior="contain",b.bottomSheetHandle.focus(),l.attacheOnOpenEventListeners()};function B(){var h;if(K())return;(h=t.beforeClose)==null||h.call(t);const d=I(c).y,g=c.clientHeight;o.translateContainer({startY:d,endY:g,animationFrame:u,bottomSheetContainer:c,onEnd:()=>{var m;(m=t.afterClose)==null||m.call(t),rt([p,c],!1),l.clearOnOpenEventListeners()}}),a()}function L(){return o.isMounted}function F(){const d=I(c).y,g=window.innerHeight,h=c.clientHeight>=g?g:c.clientHeight;return d<=h}function K(){return!F()}function nt(){const d=I(c).y,g=c.clientHeight,h=window.innerHeight;if(d<=5&&d>=-5)return P.CONTENT_HEIGHT;const m=g-d;if(m===h/2)return P.MIDDLE;const S=h-f.marginTop,A=10;return m<=S+A&&m>=S-A?P.TOP:P.CLOSED}function et(){return c.clientHeight}function z(d){if(!F())return;const g=I(c).y,m=c.clientHeight-g,S=window.innerHeight-d,A=xt(m,S),D=$(m,S);o.translateContainer({startY:g,endY:g+(A.isUp?-D:D),animationFrame:u,bottomSheetContainer:c})}function E(d,{viewportHeight:g,visibleHeight:h}){let m=null;for(const S of d){const A=S*g,D=$(h,A);(m===null||D<m)&&(m=D)}return{minOffset:m}}function H(){const d=[...f.snapPoints].reverse(),g=I(c).y,h=c.clientHeight,m=h-g;if(!f.expandable&&m>=h)return;const S=window.innerHeight,A=ht("above",{visibleHeight:m,viewportHeight:S},d),{minOffset:D}=E(A,{visibleHeight:m,viewportHeight:S});if(D===null&&m<S-f.marginTop){o.translateContainer({startY:g,endY:gt(S,h,f.marginTop,"top"),animationFrame:u,bottomSheetContainer:c});return}Y(D)&&o.translateContainer({startY:g,endY:g-D,animationFrame:u,bottomSheetContainer:c})}function C(){const d=I(c).y,h=c.clientHeight-d;if(h<1)return;const m=window.innerHeight,S=ht("below",{visibleHeight:h,viewportHeight:m},f.snapPoints),{minOffset:A}=E(S,{visibleHeight:h,viewportHeight:m});Y(A)&&o.translateContainer({startY:d,endY:d+A,animationFrame:u,bottomSheetContainer:c})}function R(d){const g=window.innerHeight;if(!Jt(d))return;const h=Q(g*d,2);z(h)}return{props:f,elements:b,mount:T,unmount:O,open:k,close:B,getIsMounted:L,getIsOpen:F,getIsClosed:K,getPosition:nt,getHeight:et,moveTo:z,snapTo:R}}function cn(){return{elements:{bottomSheetRoot:void 0,bottomSheetBackdrop:void 0,bottomSheetContainer:void 0,bottomSheetHandle:void 0,bottomSheetHandleBar:void 0,bottomSheetContentWrapper:void 0,bottomSheetContainerGapFiller:void 0},mount:()=>{},unmount:()=>{},open:()=>{},close:()=>{},getIsMounted:()=>!1,getHeight:()=>0,getIsOpen:()=>!1,getIsClosed:()=>!0,getPosition:()=>P.CLOSED,moveTo:()=>{},snapTo:()=>{},props:{content:""}}}exports.BOTTOM_SHEET_DEFAULT_PROPS=At;exports.BOTTOM_SHEET_POSITION=P;exports.BOTTOM_SHEET_SELECTORS=Pt;exports.COMMON_ANIMATION_KEYS=M;exports.ClassNames=y;exports.EventPhase=x;exports.ResetClassNames=J;exports.UtilClassNames=V;exports.createBottomSheet=sn;exports.createPlaceholderBottomSheet=cn;exports.eventPhaseToEnum=st;exports.isAnimationTimingPoints=ut;exports.isCommonAnimationTimingsKey=kt;
|
|
2
|
+
"use strict";var Bt=Object.defineProperty;var Dt=(t,n,e)=>n in t?Bt(t,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[n]=e;var U=(t,n,e)=>Dt(t,typeof n!="symbol"?n+"":n,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function w(t){return typeof t=="string"}function Yt(t,n){return t.classList.contains(tt(n))}function X(t,n){t.classList.add(tt(n))}function ot(t,n){t.classList.remove(tt(n))}function j(t,n,e){w(e)&&(w(n)&&ot(t,n),X(t,e))}function tt(t){return w(t)?t.trim().replace(/\./g,""):""}function _(t){return t.map(n=>tt(n)).filter(Boolean).join(" ")}function It(t){return t.map(n=>n==null?void 0:n.trim()).filter(Boolean).map(n=>`.${n}`).join(" ")}const dt="open",ft="hidden";function rt(t,n){const e=n;if(Array.isArray(t)){t.forEach(r=>{q(r,e),r.setAttribute("aria-modal",e?"true":"false")});return}q(t,e),t.setAttribute("aria-modal",e?"true":"false")}function q(t,n){n?(X(t,dt),ot(t,ft)):(X(t,ft),ot(t,dt))}function yt(t){return t instanceof HTMLElement}function Y(t){return typeof t=="number"&&!Number.isNaN(t)}function Nt(t){yt(t)&&t.focus()}function Mt(t){if(!yt(t)||t.offsetParent===null||"disabled"in t&&t.disabled)return!1;const e=t.getAttribute("tabindex"),r=Y(e)?parseInt(e,10):-1,i=["INPUT","BUTTON","SELECT","TEXTAREA","A","AREA","IFRAME"].includes(t.tagName),a=t instanceof HTMLAnchorElement&&t.href!==""||t instanceof HTMLAreaElement&&t.href!=="";return i||a||r>-1}var C=(t=>(t.Backdrop="pbs-backdrop",t.Root="pbs-root",t.Container="pbs-container",t.GapFiller="pbs-gap-filler",t.Handle="pbs-handle",t.HandleBar="pbs-handle-bar",t.ContentWrapper="pbs-content-wrapper",t))(C||{}),J=(t=>(t.Button="pbs-button-reset",t.Dialog="pbs-dialog-reset",t))(J||{}),W=(t=>(t.Hidden="hidden",t))(W||{});function N(t,n,e){const r=document.createElement(t);return n.split(" ").forEach(i=>{X(r,i)}),w(e)&&r.setAttribute("data-testid",e),r}const Pt={CONTENTS_WRAPPER:It([C.Root,C.ContentWrapper])};function gt(t,n,e,r){switch(r){case"content-height":return n>=t?vt(t,n,e):0;case"middle":return-(t/2-n);case"top":return-(t-n)+e;default:return 0}}function Ct(t,n){const e=n<t,r=n>t;return{isUp:e,isDown:r,stayedSame:n===t}}function Et(t,n){return n<t?-(t-n):n-t}function $(t,n){return t>n?t-n:n-t}function xt(t,n){const e=t<n,r=t>n;return{isUp:e,isDown:r,stayedSame:t===n}}function ht(t,n,e){const r=t==="above";return e.filter(o=>{const i=o*n.viewportHeight;return r?n.visibleHeight<i:n.visibleHeight>i})}function vt(t,n,e){return-(t-n)+e}function mt(t){return Number(t.replace("px",""))}function Q(t,...n){return Number(t.toFixed(...n))}function St(t){const n=/(?<type>\w+)\((?<values>[^)]+)\)/g,e=[];let r;for(;(r=n.exec(t))!==null;){const o=r[1],i=r[2].split(",").map(a=>a.trim());e.push({type:o,values:i})}return e}function Ft(t){const n=t.style.transform,e=St(n);return{transform:n,transformValues:e}}function Ot(t,n){const e=t.find(r=>r.type.startsWith(n));return e||null}const it="translate";function I(t){const n=t.style.transform,e=St(n),r=Ot(e,it);return wt(r??{type:it,values:[]})}function Z(t,{x:n,y:e}){const{transform:r,transformValues:o}=Ft(t),i=Ot(o,it);if(i){const a=wt(i);t.style.transform=`translate(${n??a.x??0}px,${e??a.y??0}px)`;return}if(r){t.style.transform=`${r}, translate(${n??0}px,${e??0}px)`;return}t.style.transform=`translate(${n??0}px,${e??0}px)`}function wt(t){if(t.type!=="translate")throw new Error(`Could not get coordinates from ${t.type}, since is not translate.`);const n=t.values[0],e=t.values[1];return{x:mt(n)??0,y:mt(e)??0}}function at(t){return t!=null}function bt(t,{min:n,max:e}){return at(e)&&t>=e?e:at(n)&&t<=n?n:t}const Rt=(t,n,e)=>{n instanceof HTMLElement&&!Yt(n,C.Handle)&&e.scrollTop>=1||(t.isDragging=!0)},_t=(t,n,e,r)=>o=>{r.startY=t.getCoordinates(o).y,r.containerStartTranslate=I(n),e.onDragStart()},Gt=(t,n,e,r,o)=>i=>{Ut(i,t,e,r,o,n,e.marginTop)};function Ut(t,n,e,r,o,i,a){if(!r.isDragging||!Y(r.startY))return;const u=n.getCoordinates(t).y,s=Et(r.startY,u),b=window.innerHeight,l=i.clientHeight,d=l-(r.containerStartTranslate.y+s);if(d>=b)return;const T=Ct(r.startY,u);if(T.isUp&&!e.expandable&&d>=l||e.preventClosing&&d<=l)return;o.start(()=>{Z(i,{y:r.containerStartTranslate.y+s})},0);const E=b-a,c=l-r.containerStartTranslate.y;if(T.isUp){const y=E-c,S=E-d,L=bt(1-Q(S/y,2),{min:0,max:1});e.onDragMove(T,L)}else if(T.isDown){const y=bt(Q(1-d/c,2),{min:0,max:1});e.onDragMove(T,y)}}const jt=(t,n,e,r,o,i,a)=>u=>{if(!r.isDragging||(r.isDragging=!1,!Y(r.startY)))return;e.onDragEnd();const s=r.startY,b=t.getCoordinates(u).y,l=I(n).y,d=Ct(s,b),T=window.innerHeight,E=n.clientHeight;if(d.isUp){const c=[...e.snapPoints].sort((L,B)=>L-B),y=E+-l;if(!e.expandable&&y>=E)return;for(const L of c){const B=L*window.innerHeight;if(y<=B){const H=$(y,B);a.translateContainer({startY:l,endY:l-H,animationFrame:o,bottomSheetContainer:n});return}}const S=vt(T,E,e.marginTop);a.translateContainer({startY:l,endY:S,animationFrame:o,bottomSheetContainer:n})}else if(d.isDown){const c=[...e.snapPoints].sort((y,S)=>S-y);for(const y of c){const S=y*window.innerHeight,L=E+-l;if(L>=S){const B=$(L,S);a.translateContainer({startY:l,endY:l+B,animationFrame:o,bottomSheetContainer:n});return}}if(e.preventClosing){const y=E+-l;if(y>=E){const S=$(y,E);a.translateContainer({startY:l,endY:l+S,animationFrame:o,bottomSheetContainer:n})}return}i()}};var x=(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))(x||{});function st(t){switch(t){case 0:return 0;case 1:return 1;case 2:return 2;case 3:return 3;default:return-1}}const Vt={eventPhase:x.All};class V{constructor(n){U(this,"currentTarget");this.currentTarget=n}addEventListeners({onStart:n,onStartOptions:e=Vt,onMove:r,onEnd:o}){this.addTouchEventListeners({onStart:n,onStartOptions:e,onMove:r,onEnd:o}),this.addMouseEventListeners({onStart:n,onStartOptions:e,onMove:r,onEnd:o})}addTouchEventListeners({onStart:n,onStartOptions:e,onMove:r,onEnd:o}){n&&this.currentTarget.addEventListener("touchstart",i=>{if(e.eventPhase===x.All){n(i);return}st(i.eventPhase)===e.eventPhase&&n(i)},{passive:!0}),r&&this.currentTarget.addEventListener("touchmove",r),o&&this.currentTarget.addEventListener("touchend",o)}addMouseEventListeners({onStart:n,onStartOptions:e,onMove:r,onEnd:o}){n&&this.currentTarget.addEventListener("mousedown",i=>{if(e.eventPhase===x.All){n(i);return}st(i.eventPhase)===e.eventPhase&&n(i)},{passive:!0}),r&&this.currentTarget.addEventListener("mousemove",r),o&&this.currentTarget.addEventListener("mouseup",i=>{o(i)})}removeEventListeners({onStart:n,onMove:e,onEnd:r}){n&&this.currentTarget.removeEventListener("touchstart",n),r&&this.currentTarget.removeEventListener("touchend",r),e&&this.currentTarget.removeEventListener("touchmove",e),n&&this.currentTarget.removeEventListener("mousedown",n),e&&this.currentTarget.removeEventListener("mousemove",e),r&&this.currentTarget.removeEventListener("mouseup",r)}getCoordinates(n){if(n.type==="touchstart"||n.type==="mousedown"){if("touches"in n)return{x:n.touches[0].clientX,y:n.touches[0].clientY};if(n instanceof MouseEvent)return{x:n.clientX,y:n.clientY}}if(n.type==="touchend"||n.type==="mouseup"||n.type==="mousemove"||n.type==="touchmove"){if("touches"in n)return{x:n.changedTouches[0].clientX,y:n.changedTouches[0].clientY};if(n instanceof MouseEvent)return{x:n.clientX,y:n.clientY}}return{x:0,y:0}}}function Ht(t){const n=t;return`${n} ${n} 0px 0px`}function Wt(t,n){const e=$t(t);Xt(e),e.bottomSheetContainer.style.width=t.width;const r=document.createElement("div");r.innerHTML=t.content??"";const o=window.innerHeight;e.bottomSheetContainer.style.maxHeight=`${o}px`,e.bottomSheetContentWrapper.appendChild(r);const i=Kt({bottomSheetElements:e,bottomSheetProps:t,options:n});return t.rootStyle&&Object.assign(e.bottomSheetRoot.style,t.rootStyle),t.backdropStyle&&Object.assign(e.bottomSheetBackdrop.style,t.backdropStyle),t.containerGapFillerStyle&&Object.assign(e.bottomSheetContainer.style,t.containerStyle),t.containerStyle&&Object.assign(e.bottomSheetContainerGapFiller.style,t.containerGapFillerStyle),t.handleStyle&&Object.assign(e.bottomSheetHandleBar.style,t.handleStyle),t.contentWrapperStyle&&Object.assign(e.bottomSheetContentWrapper.style,t.contentWrapperStyle),{elements:e,eventHandlers:i}}function $t(t){const n=N("dialog",_([C.Root,J.Dialog,t.rootClass]),C.Root);n.ariaLabel=t.ariaLabel;const e=N("section",_([C.Container,t.containerClass]),C.Container);t.containerBorderRadius&&(e.style.borderRadius=Ht(t.containerBorderRadius));const r=N("div",C.GapFiller,C.GapFiller);t.containerBackgroundColor&&(e.style.backgroundColor=t.containerBackgroundColor,r.style.backgroundColor=t.containerBackgroundColor);const o=N("button",_([C.Handle,J.Button,t.shouldShowHandle?null:W.Hidden,t.handleClass]),C.Handle);o.setAttribute("type","button"),o.ariaLabel="bottom sheet close button";const i=N("span",_([C.HandleBar,t.shouldShowHandle?null:W.Hidden]),C.HandleBar),a=N("article",_([C.ContentWrapper,t.contentWrapperClass]),C.ContentWrapper),u=N("div",_([C.Backdrop,t.backdropClass,W.Hidden]),C.Backdrop);return t.backdropColor&&(u.style.backgroundColor=t.backdropColor),t.backDropTransition&&(u.style.transition=t.backDropTransition),{bottomSheetRoot:n,bottomSheetBackdrop:u,bottomSheetContainer:e,bottomSheetHandle:o,bottomSheetHandleBar:i,bottomSheetContentWrapper:a,bottomSheetContainerGapFiller:r}}function Xt({bottomSheetRoot:t,bottomSheetContainer:n,bottomSheetHandle:e,bottomSheetHandleBar:r,bottomSheetContentWrapper:o,bottomSheetContainerGapFiller:i}){t.appendChild(n),e.appendChild(r),n.appendChild(e),n.appendChild(o),n.appendChild(i)}function Kt({bottomSheetElements:t,bottomSheetProps:n,options:e}){const{bottomSheetRoot:r,bottomSheetContainer:o,bottomSheetHandle:i,bottomSheetContainerGapFiller:a,bottomSheetContentWrapper:u,bottomSheetBackdrop:s}=t,{animationFrame:b}=e,l=new V(i),d=new V(u),T=new V(a);let E=[];const c=new V(window),y=_t(c,o,n,e.draggingState),S=Gt(c,o,n,e.draggingState,b),L=jt(c,o,n,e.draggingState,b,e.onClose,e.bottomSheetState);function B(O){O.target instanceof Element&&!r.contains(O.target)&&e.onClose()}function H(O){Rt(e.draggingState,O.target,t.bottomSheetContentWrapper)}function F(O){const k=O??n;k.draggable&&k.backgroundDraggable&&(d.addEventListeners({onStart:H,onStartOptions:{eventPhase:x.Target}}),T.addEventListeners({onStart:H})),k.draggable&&c.addEventListeners({onStart:y,onMove:S,onEnd:L}),k.draggable&&window.document.addEventListener("keyup",p=>{p.key==="Escape"&&e.onClose()}),i.addEventListener("keyup",p=>{if(p.key==="ArrowUp"){e.moveUp();return}if(p.key==="ArrowDown"){e.moveDown();return}if(p.shiftKey&&p.key==="Tab"){const R=et(t.bottomSheetContentWrapper);Nt(R)}})}function K(O){const k=O??n;n.shouldCloseOnOutsideClick&&!n.preventClosing?s.addEventListener("click",B):s.style.pointerEvents="none",k.draggable&&(l.addEventListeners({onStart:H}),E.forEach(p=>{p.removeEventListeners({onStart:H})}),E=n.dragTriggers.reduce((p,R)=>{const g=r.querySelectorAll(R);if(!g.length)return p;const h=Array.from(g).map(f=>f instanceof HTMLElement?new V(f):null).filter(f=>!!f);return[...p,...h]},[]),E.forEach(p=>{p.addEventListeners({onStart:H,onStartOptions:{eventPhase:x.Target}})}))}function nt(){s.removeEventListener("click",B)}function et(O){let k=[...Array.from(O.childNodes).reverse()];for(;k.length;){const p=k.shift();if(Mt(p))return p;p&&(k=[...k,...Array.from(p.childNodes).reverse()])}return null}function z(){l.removeEventListeners({onStart:H}),d.removeEventListeners({onStart:H}),T.removeEventListeners({onStart:H}),E.forEach(O=>{O.removeEventListeners({onStart:H})}),c.removeEventListeners({onStart:y,onMove:S,onEnd:L})}return{attachEventListeners:F,clearEventListeners:z,attacheOnOpenEventListeners:K,clearOnOpenEventListeners:nt}}class zt{constructor(){U(this,"animationId");U(this,"isInProgress");U(this,"startedAt");this.animationId=null,this.isInProgress=!1,this.startedAt=null}start(n,e,r=!1){this.isInProgress=!0;const o=i=>{this.startedAt||(this.startedAt=i);const a=i-this.startedAt,s=e===0?1:Q(a/e,2),b=s>=1&&!r;n(s),b?this.stop():this.animationId=requestAnimationFrame(o)};this.animationId=requestAnimationFrame(o)}stop(){this.isInProgress=!1,this.startedAt=null,Y(this.animationId)&&cancelAnimationFrame(this.animationId)}}function qt(t){const{startY:n,endY:e,bottomSheetContainer:r,animationFrame:o,onEnd:i,animationTimingFunction:a,animationDuration:u}=t,s=Et(n,e);o.stop();let b=!1;o.start(l=>{Z(r,{y:n+s*a(l)}),!b&&l>=1&&(i==null||i(),b=!0)},u)}const ct=(t,n)=>e=>{qt({...e,animationTimingFunction:t,animationDuration:n})},P={TOP:"top",MIDDLE:"middle",CONTENT_HEIGHT:"content-height",CLOSED:"closed"};function Jt(t){return!(!Y(t)||t>1||t<0)}function Qt(t,n){const e={set(r,o,i,a){return n(o,i),Reflect.set(r,o,i,a)}};return new Proxy(t,e)}function Zt(...t){console.error(t)}const M={EASE:"ease",EASE_IN:"ease-in",EASE_OUT:"ease-out",EASE_IN_OUT:"ease-in-out",SPRING:"spring"};function Lt(t){for(const n of Object.values(M))if(n===t)return!0;return!1}function ut(t){return!!(t instanceof Object&&"p1x"in t&&"p1y"in t&&"p2x"in t&&"p2y"in t&&Y(t.p1x)&&Y(t.p1y)&&Y(t.p2x)&&Y(t.p2y))}function G(t,n,e,r){return function(s){return u(i(s))};function i(s){let b=0,l=1,d=s,T;if(s===0||s===1)return s;for(;b<l;){if(T=a(d),Math.abs(T-s)<.001)return d;s>T?b=d:l=d,d=(l+b)/2}return d}function a(s){return 3*t*s*Math.pow(1-s,2)+3*e*Math.pow(s,2)*(1-s)+Math.pow(s,3)}function u(s){return 3*n*s*Math.pow(1-s,2)+3*r*Math.pow(s,2)*(1-s)+Math.pow(s,3)}}const pt=G(.25,.1,.25,1),tn=G(.42,0,1,1),kt=G(.42,0,.58,1),nn=G(.4,.1,.6,1),en=G(.45,1.5,.55,1);function rn(t){switch(t){case M.EASE:return pt;case M.EASE_IN:return tn;case M.EASE_OUT:return kt;case M.EASE_IN_OUT:return nn;case M.SPRING:return en;default:return pt}}function Tt(t){return typeof t=="boolean"}const At={ariaLabel:"Bottom sheet",content:"",defaultPosition:P.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 on(t){const n={...At},e=Object.entries(t).reduce((o,i)=>{const[a,u]=i;return at(u)&&(o[a]=u),o},{});return{...n,...e}}function lt(t){if(ut(t)){const{p1x:n,p1y:e,p2x:r,p2y:o}=t;return G(n,e,r,o)}return Lt(t)?rn(t):kt}function an(t,n,e,r){function o(i,a){switch(i){case"content":w(a)&&(t.bottomSheetContentWrapper.innerHTML=a);break;case"width":w(a)&&(t.bottomSheetContainer.style.width=a);break;case"shouldShowHandle":Tt(a)||q(t.bottomSheetHandle,!1);break;case"shouldShowBackdrop":Tt(a)||q(t.bottomSheetBackdrop,!1);break;case"containerBorderRadius":w(a)&&(t.bottomSheetContainer.style.borderRadius=Ht(a));break;case"containerBackgroundColor":w(a)&&(t.bottomSheetContainer.style.backgroundColor=a,t.bottomSheetContainerGapFiller.style.backgroundColor=a);break;case"backdropColor":w(a)&&(t.bottomSheetBackdrop.style.backgroundColor=a);break;case"backDropTransition":w(a)&&(t.bottomSheetBackdrop.style.transition=a);break;case"rootClass":if(!w(a))return;j(t.bottomSheetRoot,e.rootClass,a);break;case"containerClass":if(!w(a))return;j(t.bottomSheetContainer,e.containerClass,a);break;case"handleClass":if(!w(a))return;j(t.bottomSheetHandle,e.handleClass,a);break;case"contentWrapperClass":if(!w(a))return;j(t.bottomSheetContentWrapper,e.contentWrapperClass,a);break;case"backdropClass":if(!w(a))return;j(t.bottomSheetBackdrop,e.backdropClass,a);break;case"expandable":r.clearEventListeners(),r.attachEventListeners(e);break;case"preventClosing":r.clearEventListeners(),r.attachEventListeners(e);break;case"draggable":r.clearEventListeners(),r.attachEventListeners(e);break;case"dragTriggers":r.clearEventListeners(),r.attachEventListeners(e);break;case"draggingAnimationTimings":if(ut(a)){const u=lt(a),s=ct(u,e.draggingAnimationDuration);n.translateContainer=s}break;case"draggingAnimationDuration":if(Y(a)){const u=lt(e.draggingAnimationTimings),s=ct(u,a);n.translateContainer=s}break;case"rootStyle":e.rootStyle&&Object.assign(t.bottomSheetRoot.style,e.rootStyle);break;case"backdropStyle":e.backdropStyle&&Object.assign(t.bottomSheetBackdrop.style,e.backdropStyle);break;case"containerStyle":e.containerStyle&&Object.assign(t.bottomSheetContainer.style,e.containerStyle);break;case"containerGapFillerStyle":e.containerGapFillerStyle&&Object.assign(t.bottomSheetContainerGapFiller.style,e.containerGapFillerStyle);break;case"handleStyle":e.handleStyle&&Object.assign(t.bottomSheetHandleBar.style,e.handleStyle);break;case"contentWrapperStyle":e.contentWrapperStyle&&Object.assign(t.bottomSheetContentWrapper.style,e.contentWrapperStyle);break}}return o}function sn(t){const n=on(t),e=lt(t.draggingAnimationTimings),o={isMounted:!1,translateContainer:ct(e,n.draggingAnimationDuration)},i={startY:null,containerStartTranslate:{x:0,y:0},isDragging:!1,originalDocumentOverflowY:null,originalDocumentOverscrollBehavior:null};function a(){i.originalDocumentOverflowY&&i.originalDocumentOverflowY!=="hidden"&&(document.body.style.overflowY=i.originalDocumentOverflowY),i.originalDocumentOverscrollBehavior&&(document.body.style.position=i.originalDocumentOverscrollBehavior)}const u=new zt,s={animationFrame:u,onClose:B,bottomSheetState:o,draggingState:i,snapTo:R,moveUp:k,moveDown:p},{elements:b,eventHandlers:l}=Wt(n,s),d=Qt(n,an(b,o,n,l)),{bottomSheetBackdrop:T,bottomSheetRoot:E,bottomSheetContainer:c}=b,y=g=>{const h=g??window.document.body;h.appendChild(E),h.appendChild(T);const f=window.innerHeight;Z(c,{y:f}),l.attachEventListeners(),o.isMounted=!0},S=()=>{l.clearEventListeners(),Object.values(b).forEach(g=>{g.remove()}),a(),o.isMounted=!1},L=()=>{var D;if(H()||Zt('Bottom Sheet is not mounted yet. call the "mount" method first.'),(D=t.beforeOpen)==null||D.call(t),F())return;rt(T,!0),d.shouldShowBackdrop||X(T,"transparent"),rt([c],!0),Z(c,{y:c.clientHeight});const h=window.innerHeight,f=gt(h,c.clientHeight,d.marginTop,d.defaultPosition),m=I(c).y;o.translateContainer({startY:m,endY:f,animationFrame:u,bottomSheetContainer:c,onEnd:t.afterOpen});const v=document.body.style.overflowY;i.originalDocumentOverflowY=v||"initial";const A=document.body.style.overscrollBehavior;i.originalDocumentOverscrollBehavior=A||"initial",document.body.style.overflow="hidden",document.body.style.overscrollBehavior="contain",b.bottomSheetHandle.focus(),l.attacheOnOpenEventListeners()};function B(){var f;if(K())return;(f=t.beforeClose)==null||f.call(t);const g=I(c).y,h=c.clientHeight;o.translateContainer({startY:g,endY:h,animationFrame:u,bottomSheetContainer:c,onEnd:()=>{var m;(m=t.afterClose)==null||m.call(t),rt([T,c],!1),l.clearOnOpenEventListeners()}}),a()}function H(){return o.isMounted}function F(){const g=I(c).y,h=window.innerHeight,f=c.clientHeight>=h?h:c.clientHeight;return g<=f}function K(){return!F()}function nt(){const g=I(c).y,h=c.clientHeight,f=window.innerHeight;if(g<=5&&g>=-5)return P.CONTENT_HEIGHT;const m=h-g;if(m===f/2)return P.MIDDLE;const v=f-d.marginTop,A=10;return m<=v+A&&m>=v-A?P.TOP:P.CLOSED}function et(){return c.clientHeight}function z(g){if(!F())return;const h=I(c).y,m=c.clientHeight-h,v=window.innerHeight-g,A=xt(m,v),D=$(m,v);o.translateContainer({startY:h,endY:h+(A.isUp?-D:D),animationFrame:u,bottomSheetContainer:c})}function O(g,{viewportHeight:h,visibleHeight:f}){let m=null;for(const v of g){const A=v*h,D=$(f,A);(m===null||D<m)&&(m=D)}return{minOffset:m}}function k(){const g=[...d.snapPoints].reverse(),h=I(c).y,f=c.clientHeight,m=f-h;if(!d.expandable&&m>=f)return;const v=window.innerHeight,A=ht("above",{visibleHeight:m,viewportHeight:v},g),{minOffset:D}=O(A,{visibleHeight:m,viewportHeight:v});if(D===null&&m<v-d.marginTop){o.translateContainer({startY:h,endY:gt(v,f,d.marginTop,"top"),animationFrame:u,bottomSheetContainer:c});return}Y(D)&&o.translateContainer({startY:h,endY:h-D,animationFrame:u,bottomSheetContainer:c})}function p(){const g=I(c).y,f=c.clientHeight-g;if(f<1)return;const m=window.innerHeight,v=ht("below",{visibleHeight:f,viewportHeight:m},d.snapPoints),{minOffset:A}=O(v,{visibleHeight:f,viewportHeight:m});Y(A)&&o.translateContainer({startY:g,endY:g+A,animationFrame:u,bottomSheetContainer:c})}function R(g){const h=window.innerHeight;if(!Jt(g))return;const f=Q(h*g,2);z(f)}return{props:d,elements:b,mount:y,unmount:S,open:L,close:B,getIsMounted:H,getIsOpen:F,getIsClosed:K,getPosition:nt,getHeight:et,moveTo:z,snapTo:R}}function cn(){return{elements:{bottomSheetRoot:void 0,bottomSheetBackdrop:void 0,bottomSheetContainer:void 0,bottomSheetHandle:void 0,bottomSheetHandleBar:void 0,bottomSheetContentWrapper:void 0,bottomSheetContainerGapFiller:void 0},mount:()=>{},unmount:()=>{},open:()=>{},close:()=>{},getIsMounted:()=>!1,getHeight:()=>0,getIsOpen:()=>!1,getIsClosed:()=>!0,getPosition:()=>P.CLOSED,moveTo:()=>{},snapTo:()=>{},props:{content:""}}}exports.BOTTOM_SHEET_DEFAULT_PROPS=At;exports.BOTTOM_SHEET_POSITION=P;exports.BOTTOM_SHEET_SELECTORS=Pt;exports.COMMON_ANIMATION_KEYS=M;exports.ClassNames=C;exports.EventPhase=x;exports.ResetClassNames=J;exports.UtilClassNames=W;exports.createBottomSheet=sn;exports.createPlaceholderBottomSheet=cn;exports.eventPhaseToEnum=st;exports.isAnimationTimingPoints=ut;exports.isCommonAnimationTimingsKey=Lt;
|
|
@@ -99,7 +99,7 @@ function Ct(t, n) {
|
|
|
99
99
|
function Tt(t, n) {
|
|
100
100
|
return n < t ? -(t - n) : n - t;
|
|
101
101
|
}
|
|
102
|
-
function
|
|
102
|
+
function W(t, n) {
|
|
103
103
|
return t > n ? t - n : n - t;
|
|
104
104
|
}
|
|
105
105
|
function xt(t, n) {
|
|
@@ -213,31 +213,31 @@ const Ft = (t, n, e) => {
|
|
|
213
213
|
function Rt(t, n, e, r, o, i, a) {
|
|
214
214
|
if (!r.isDragging || !Y(r.startY))
|
|
215
215
|
return;
|
|
216
|
-
const u = n.getCoordinates(t).y, s = Tt(r.startY, u), b = window.innerHeight, l = i.clientHeight,
|
|
217
|
-
if (
|
|
216
|
+
const u = n.getCoordinates(t).y, s = Tt(r.startY, u), b = window.innerHeight, l = i.clientHeight, d = l - (r.containerStartTranslate.y + s);
|
|
217
|
+
if (d >= b)
|
|
218
218
|
return;
|
|
219
|
-
const
|
|
220
|
-
if (
|
|
219
|
+
const y = Ct(r.startY, u);
|
|
220
|
+
if (y.isUp && !e.expandable && d >= l || e.preventClosing && d <= l)
|
|
221
221
|
return;
|
|
222
222
|
o.start(() => {
|
|
223
223
|
Q(i, {
|
|
224
224
|
y: r.containerStartTranslate.y + s
|
|
225
225
|
});
|
|
226
226
|
}, 0);
|
|
227
|
-
const
|
|
228
|
-
if (
|
|
229
|
-
const
|
|
230
|
-
1 - J(
|
|
227
|
+
const E = b - a, c = l - r.containerStartTranslate.y;
|
|
228
|
+
if (y.isUp) {
|
|
229
|
+
const C = E - c, w = E - d, k = ht(
|
|
230
|
+
1 - J(w / C, 2),
|
|
231
231
|
{
|
|
232
232
|
min: 0,
|
|
233
233
|
max: 1
|
|
234
234
|
}
|
|
235
235
|
);
|
|
236
|
-
e.onDragMove(
|
|
237
|
-
} else if (
|
|
238
|
-
const
|
|
236
|
+
e.onDragMove(y, k);
|
|
237
|
+
} else if (y.isDown) {
|
|
238
|
+
const C = ht(
|
|
239
239
|
J(
|
|
240
|
-
1 -
|
|
240
|
+
1 - d / c,
|
|
241
241
|
2
|
|
242
242
|
),
|
|
243
243
|
{
|
|
@@ -245,57 +245,57 @@ function Rt(t, n, e, r, o, i, a) {
|
|
|
245
245
|
max: 1
|
|
246
246
|
}
|
|
247
247
|
);
|
|
248
|
-
e.onDragMove(
|
|
248
|
+
e.onDragMove(y, C);
|
|
249
249
|
}
|
|
250
250
|
}
|
|
251
251
|
const Gt = (t, n, e, r, o, i, a) => (u) => {
|
|
252
252
|
if (!r.isDragging || (r.isDragging = !1, !Y(r.startY)))
|
|
253
253
|
return;
|
|
254
254
|
e.onDragEnd();
|
|
255
|
-
const s = r.startY, b = t.getCoordinates(u).y, l = I(n).y,
|
|
256
|
-
if (
|
|
255
|
+
const s = r.startY, b = t.getCoordinates(u).y, l = I(n).y, d = Ct(s, b), y = window.innerHeight, E = n.clientHeight;
|
|
256
|
+
if (d.isUp) {
|
|
257
257
|
const c = [...e.snapPoints].sort(
|
|
258
258
|
(k, B) => k - B
|
|
259
|
-
),
|
|
260
|
-
if (!e.expandable &&
|
|
259
|
+
), C = E + -l;
|
|
260
|
+
if (!e.expandable && C >= E)
|
|
261
261
|
return;
|
|
262
262
|
for (const k of c) {
|
|
263
263
|
const B = k * window.innerHeight;
|
|
264
|
-
if (
|
|
265
|
-
const
|
|
266
|
-
|
|
264
|
+
if (C <= B) {
|
|
265
|
+
const O = W(
|
|
266
|
+
C,
|
|
267
267
|
B
|
|
268
268
|
);
|
|
269
269
|
a.translateContainer({
|
|
270
270
|
startY: l,
|
|
271
|
-
endY: l -
|
|
271
|
+
endY: l - O,
|
|
272
272
|
animationFrame: o,
|
|
273
273
|
bottomSheetContainer: n
|
|
274
274
|
});
|
|
275
275
|
return;
|
|
276
276
|
}
|
|
277
277
|
}
|
|
278
|
-
const
|
|
279
|
-
|
|
280
|
-
|
|
278
|
+
const w = Et(
|
|
279
|
+
y,
|
|
280
|
+
E,
|
|
281
281
|
e.marginTop
|
|
282
282
|
);
|
|
283
283
|
a.translateContainer({
|
|
284
284
|
startY: l,
|
|
285
|
-
endY:
|
|
285
|
+
endY: w,
|
|
286
286
|
animationFrame: o,
|
|
287
287
|
bottomSheetContainer: n
|
|
288
288
|
});
|
|
289
|
-
} else if (
|
|
289
|
+
} else if (d.isDown) {
|
|
290
290
|
const c = [...e.snapPoints].sort(
|
|
291
|
-
(
|
|
291
|
+
(C, w) => w - C
|
|
292
292
|
);
|
|
293
|
-
for (const
|
|
294
|
-
const
|
|
295
|
-
if (k >=
|
|
296
|
-
const B =
|
|
293
|
+
for (const C of c) {
|
|
294
|
+
const w = C * window.innerHeight, k = E + -l;
|
|
295
|
+
if (k >= w) {
|
|
296
|
+
const B = W(
|
|
297
297
|
k,
|
|
298
|
-
|
|
298
|
+
w
|
|
299
299
|
);
|
|
300
300
|
a.translateContainer({
|
|
301
301
|
startY: l,
|
|
@@ -307,12 +307,12 @@ const Gt = (t, n, e, r, o, i, a) => (u) => {
|
|
|
307
307
|
}
|
|
308
308
|
}
|
|
309
309
|
if (e.preventClosing) {
|
|
310
|
-
const
|
|
311
|
-
if (
|
|
312
|
-
const
|
|
310
|
+
const C = E + -l;
|
|
311
|
+
if (C >= E) {
|
|
312
|
+
const w = W(C, E);
|
|
313
313
|
a.translateContainer({
|
|
314
314
|
startY: l,
|
|
315
|
-
endY: l +
|
|
315
|
+
endY: l + w,
|
|
316
316
|
animationFrame: o,
|
|
317
317
|
bottomSheetContainer: n
|
|
318
318
|
});
|
|
@@ -340,7 +340,7 @@ function mt(t) {
|
|
|
340
340
|
const _t = {
|
|
341
341
|
eventPhase: G.All
|
|
342
342
|
};
|
|
343
|
-
class
|
|
343
|
+
class V {
|
|
344
344
|
constructor(n) {
|
|
345
345
|
j(this, "currentTarget");
|
|
346
346
|
this.currentTarget = n;
|
|
@@ -439,12 +439,12 @@ function Ht(t) {
|
|
|
439
439
|
}
|
|
440
440
|
function jt(t, n) {
|
|
441
441
|
const e = Ut(t);
|
|
442
|
-
|
|
442
|
+
Vt(e), e.bottomSheetContainer.style.width = t.width;
|
|
443
443
|
const r = document.createElement("div");
|
|
444
444
|
r.innerHTML = t.content ?? "";
|
|
445
445
|
const o = window.innerHeight;
|
|
446
446
|
e.bottomSheetContainer.style.maxHeight = `${o}px`, e.bottomSheetContentWrapper.appendChild(r);
|
|
447
|
-
const i =
|
|
447
|
+
const i = Wt({
|
|
448
448
|
bottomSheetElements: e,
|
|
449
449
|
bottomSheetProps: t,
|
|
450
450
|
options: n
|
|
@@ -526,7 +526,7 @@ function Ut(t) {
|
|
|
526
526
|
bottomSheetContainerGapFiller: r
|
|
527
527
|
};
|
|
528
528
|
}
|
|
529
|
-
function
|
|
529
|
+
function Vt({
|
|
530
530
|
bottomSheetRoot: t,
|
|
531
531
|
bottomSheetContainer: n,
|
|
532
532
|
bottomSheetHandle: e,
|
|
@@ -536,7 +536,7 @@ function Wt({
|
|
|
536
536
|
}) {
|
|
537
537
|
t.appendChild(n), e.appendChild(r), n.appendChild(e), n.appendChild(o), n.appendChild(i);
|
|
538
538
|
}
|
|
539
|
-
function
|
|
539
|
+
function Wt({
|
|
540
540
|
bottomSheetElements: t,
|
|
541
541
|
bottomSheetProps: n,
|
|
542
542
|
options: e
|
|
@@ -548,27 +548,20 @@ function Vt({
|
|
|
548
548
|
bottomSheetContainerGapFiller: a,
|
|
549
549
|
bottomSheetContentWrapper: u,
|
|
550
550
|
bottomSheetBackdrop: s
|
|
551
|
-
} = t, { animationFrame: b } = e, l = new
|
|
551
|
+
} = t, { animationFrame: b } = e, l = new V(i), d = new V(
|
|
552
552
|
u
|
|
553
|
-
),
|
|
553
|
+
), y = new V(
|
|
554
554
|
a
|
|
555
|
-
)
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
if (!C.length)
|
|
559
|
-
return E;
|
|
560
|
-
const F = Array.from(C).map((d) => d instanceof HTMLElement ? new W(d) : null).filter((d) => !!d);
|
|
561
|
-
return [...E, ...F];
|
|
562
|
-
},
|
|
563
|
-
[]
|
|
564
|
-
), c = new W(
|
|
555
|
+
);
|
|
556
|
+
let E = [];
|
|
557
|
+
const c = new V(
|
|
565
558
|
window
|
|
566
|
-
),
|
|
559
|
+
), C = Mt(
|
|
567
560
|
c,
|
|
568
561
|
o,
|
|
569
562
|
n,
|
|
570
563
|
e.draggingState
|
|
571
|
-
),
|
|
564
|
+
), w = Pt(
|
|
572
565
|
c,
|
|
573
566
|
o,
|
|
574
567
|
n,
|
|
@@ -583,50 +576,41 @@ function Vt({
|
|
|
583
576
|
e.onClose,
|
|
584
577
|
e.bottomSheetState
|
|
585
578
|
);
|
|
586
|
-
function B(
|
|
587
|
-
|
|
579
|
+
function B(S) {
|
|
580
|
+
S.target instanceof Element && !r.contains(S.target) && e.onClose();
|
|
588
581
|
}
|
|
589
|
-
function
|
|
582
|
+
function O(S) {
|
|
590
583
|
Ft(
|
|
591
584
|
e.draggingState,
|
|
592
|
-
|
|
585
|
+
S.target,
|
|
593
586
|
t.bottomSheetContentWrapper
|
|
594
587
|
);
|
|
595
588
|
}
|
|
596
|
-
function N(
|
|
597
|
-
const
|
|
598
|
-
|
|
599
|
-
onStart:
|
|
600
|
-
}), w.forEach((C) => {
|
|
601
|
-
C.addEventListeners({
|
|
602
|
-
onStart: L,
|
|
603
|
-
onStartOptions: {
|
|
604
|
-
eventPhase: G.Target
|
|
605
|
-
}
|
|
606
|
-
});
|
|
607
|
-
})), O.draggable && O.backgroundDraggable && (f.addEventListeners({
|
|
608
|
-
onStart: L,
|
|
589
|
+
function N(S) {
|
|
590
|
+
const L = S ?? n;
|
|
591
|
+
L.draggable && L.backgroundDraggable && (d.addEventListeners({
|
|
592
|
+
onStart: O,
|
|
609
593
|
onStartOptions: {
|
|
610
594
|
eventPhase: G.Target
|
|
611
595
|
}
|
|
612
|
-
}),
|
|
613
|
-
onStart:
|
|
614
|
-
})),
|
|
615
|
-
onStart:
|
|
616
|
-
onMove:
|
|
596
|
+
}), y.addEventListeners({
|
|
597
|
+
onStart: O
|
|
598
|
+
})), L.draggable && c.addEventListeners({
|
|
599
|
+
onStart: C,
|
|
600
|
+
onMove: w,
|
|
617
601
|
onEnd: k
|
|
618
|
-
}),
|
|
619
|
-
|
|
620
|
-
}), i.addEventListener("keyup", (
|
|
621
|
-
if (
|
|
602
|
+
}), L.draggable && window.document.addEventListener("keyup", (p) => {
|
|
603
|
+
p.key === "Escape" && e.onClose();
|
|
604
|
+
}), i.addEventListener("keyup", (p) => {
|
|
605
|
+
if (p.key === "ArrowUp") {
|
|
622
606
|
e.moveUp();
|
|
623
607
|
return;
|
|
624
608
|
}
|
|
625
|
-
if (
|
|
609
|
+
if (p.key === "ArrowDown") {
|
|
626
610
|
e.moveDown();
|
|
627
611
|
return;
|
|
628
612
|
}
|
|
629
|
-
if (
|
|
613
|
+
if (p.shiftKey && p.key === "Tab") {
|
|
630
614
|
const F = nt(
|
|
631
615
|
t.bottomSheetContentWrapper
|
|
632
616
|
);
|
|
@@ -634,39 +618,59 @@ function Vt({
|
|
|
634
618
|
}
|
|
635
619
|
});
|
|
636
620
|
}
|
|
637
|
-
function X() {
|
|
638
|
-
|
|
621
|
+
function X(S) {
|
|
622
|
+
const L = S ?? n;
|
|
623
|
+
n.shouldCloseOnOutsideClick && !n.preventClosing ? s.addEventListener("click", B) : s.style.pointerEvents = "none", L.draggable && (l.addEventListeners({
|
|
624
|
+
onStart: O
|
|
625
|
+
}), E.forEach((p) => {
|
|
626
|
+
p.removeEventListeners({
|
|
627
|
+
onStart: O
|
|
628
|
+
});
|
|
629
|
+
}), E = n.dragTriggers.reduce((p, F) => {
|
|
630
|
+
const g = r.querySelectorAll(F);
|
|
631
|
+
if (!g.length)
|
|
632
|
+
return p;
|
|
633
|
+
const h = Array.from(g).map((f) => f instanceof HTMLElement ? new V(f) : null).filter((f) => !!f);
|
|
634
|
+
return [...p, ...h];
|
|
635
|
+
}, []), E.forEach((p) => {
|
|
636
|
+
p.addEventListeners({
|
|
637
|
+
onStart: O,
|
|
638
|
+
onStartOptions: {
|
|
639
|
+
eventPhase: G.Target
|
|
640
|
+
}
|
|
641
|
+
});
|
|
642
|
+
}));
|
|
639
643
|
}
|
|
640
644
|
function tt() {
|
|
641
645
|
s.removeEventListener("click", B);
|
|
642
646
|
}
|
|
643
|
-
function nt(
|
|
644
|
-
let
|
|
645
|
-
for (;
|
|
646
|
-
const
|
|
647
|
-
if (It(
|
|
648
|
-
return
|
|
649
|
-
|
|
650
|
-
...
|
|
651
|
-
...Array.from(
|
|
647
|
+
function nt(S) {
|
|
648
|
+
let L = [...Array.from(S.childNodes).reverse()];
|
|
649
|
+
for (; L.length; ) {
|
|
650
|
+
const p = L.shift();
|
|
651
|
+
if (It(p))
|
|
652
|
+
return p;
|
|
653
|
+
p && (L = [
|
|
654
|
+
...L,
|
|
655
|
+
...Array.from(p.childNodes).reverse()
|
|
652
656
|
]);
|
|
653
657
|
}
|
|
654
658
|
return null;
|
|
655
659
|
}
|
|
656
660
|
function z() {
|
|
657
661
|
l.removeEventListeners({
|
|
658
|
-
onStart:
|
|
659
|
-
}),
|
|
660
|
-
onStart:
|
|
661
|
-
}),
|
|
662
|
-
onStart:
|
|
663
|
-
}),
|
|
664
|
-
|
|
665
|
-
onStart:
|
|
662
|
+
onStart: O
|
|
663
|
+
}), d.removeEventListeners({
|
|
664
|
+
onStart: O
|
|
665
|
+
}), y.removeEventListeners({
|
|
666
|
+
onStart: O
|
|
667
|
+
}), E.forEach((S) => {
|
|
668
|
+
S.removeEventListeners({
|
|
669
|
+
onStart: O
|
|
666
670
|
});
|
|
667
671
|
}), c.removeEventListeners({
|
|
668
|
-
onStart:
|
|
669
|
-
onMove:
|
|
672
|
+
onStart: C,
|
|
673
|
+
onMove: w,
|
|
670
674
|
onEnd: k
|
|
671
675
|
});
|
|
672
676
|
}
|
|
@@ -767,15 +771,15 @@ function _(t, n, e, r) {
|
|
|
767
771
|
return u(i(s));
|
|
768
772
|
};
|
|
769
773
|
function i(s) {
|
|
770
|
-
let b = 0, l = 1,
|
|
774
|
+
let b = 0, l = 1, d = s, y;
|
|
771
775
|
if (s === 0 || s === 1)
|
|
772
776
|
return s;
|
|
773
777
|
for (; b < l; ) {
|
|
774
|
-
if (
|
|
775
|
-
return
|
|
776
|
-
s >
|
|
778
|
+
if (y = a(d), Math.abs(y - s) < 1e-3)
|
|
779
|
+
return d;
|
|
780
|
+
s > y ? b = d : l = d, d = (l + b) / 2;
|
|
777
781
|
}
|
|
778
|
-
return
|
|
782
|
+
return d;
|
|
779
783
|
}
|
|
780
784
|
function a(s) {
|
|
781
785
|
return 3 * t * s * Math.pow(1 - s, 2) + 3 * e * Math.pow(s, 2) * (1 - s) + Math.pow(s, 3);
|
|
@@ -954,6 +958,9 @@ function on(t, n, e, r) {
|
|
|
954
958
|
case "draggable":
|
|
955
959
|
r.clearEventListeners(), r.attachEventListeners(e);
|
|
956
960
|
break;
|
|
961
|
+
case "dragTriggers":
|
|
962
|
+
r.clearEventListeners(), r.attachEventListeners(e);
|
|
963
|
+
break;
|
|
957
964
|
case "draggingAnimationTimings":
|
|
958
965
|
if (Ot(a)) {
|
|
959
966
|
const u = ct(a), s = st(
|
|
@@ -1042,12 +1049,12 @@ function cn(t) {
|
|
|
1042
1049
|
bottomSheetState: o,
|
|
1043
1050
|
draggingState: i,
|
|
1044
1051
|
snapTo: F,
|
|
1045
|
-
moveUp:
|
|
1046
|
-
moveDown:
|
|
1052
|
+
moveUp: L,
|
|
1053
|
+
moveDown: p
|
|
1047
1054
|
}, { elements: b, eventHandlers: l } = jt(
|
|
1048
1055
|
n,
|
|
1049
1056
|
s
|
|
1050
|
-
),
|
|
1057
|
+
), d = Kt(
|
|
1051
1058
|
n,
|
|
1052
1059
|
on(
|
|
1053
1060
|
b,
|
|
@@ -1055,35 +1062,35 @@ function cn(t) {
|
|
|
1055
1062
|
n,
|
|
1056
1063
|
l
|
|
1057
1064
|
)
|
|
1058
|
-
), { bottomSheetBackdrop:
|
|
1059
|
-
const
|
|
1060
|
-
|
|
1061
|
-
const
|
|
1065
|
+
), { bottomSheetBackdrop: y, bottomSheetRoot: E, bottomSheetContainer: c } = b, C = (g) => {
|
|
1066
|
+
const h = g ?? window.document.body;
|
|
1067
|
+
h.appendChild(E), h.appendChild(y);
|
|
1068
|
+
const f = window.innerHeight;
|
|
1062
1069
|
Q(c, {
|
|
1063
|
-
y:
|
|
1070
|
+
y: f
|
|
1064
1071
|
}), l.attachEventListeners(), o.isMounted = !0;
|
|
1065
|
-
},
|
|
1066
|
-
l.clearEventListeners(), Object.values(b).forEach((
|
|
1067
|
-
|
|
1072
|
+
}, w = () => {
|
|
1073
|
+
l.clearEventListeners(), Object.values(b).forEach((g) => {
|
|
1074
|
+
g.remove();
|
|
1068
1075
|
}), a(), o.isMounted = !1;
|
|
1069
1076
|
}, k = () => {
|
|
1070
1077
|
var D;
|
|
1071
|
-
if (
|
|
1078
|
+
if (O() || qt(
|
|
1072
1079
|
'Bottom Sheet is not mounted yet. call the "mount" method first.'
|
|
1073
1080
|
), (D = t.beforeOpen) == null || D.call(t), N())
|
|
1074
1081
|
return;
|
|
1075
|
-
et(
|
|
1082
|
+
et(y, !0), d.shouldShowBackdrop || $(y, "transparent"), et([c], !0), Q(c, {
|
|
1076
1083
|
y: c.clientHeight
|
|
1077
1084
|
});
|
|
1078
|
-
const
|
|
1079
|
-
|
|
1085
|
+
const h = window.innerHeight, f = dt(
|
|
1086
|
+
h,
|
|
1080
1087
|
c.clientHeight,
|
|
1081
|
-
|
|
1082
|
-
|
|
1088
|
+
d.marginTop,
|
|
1089
|
+
d.defaultPosition
|
|
1083
1090
|
), m = I(c).y;
|
|
1084
1091
|
o.translateContainer({
|
|
1085
1092
|
startY: m,
|
|
1086
|
-
endY:
|
|
1093
|
+
endY: f,
|
|
1087
1094
|
animationFrame: u,
|
|
1088
1095
|
bottomSheetContainer: c,
|
|
1089
1096
|
onEnd: t.afterOpen
|
|
@@ -1094,64 +1101,64 @@ function cn(t) {
|
|
|
1094
1101
|
i.originalDocumentOverscrollBehavior = A || "initial", document.body.style.overflow = "hidden", document.body.style.overscrollBehavior = "contain", b.bottomSheetHandle.focus(), l.attacheOnOpenEventListeners();
|
|
1095
1102
|
};
|
|
1096
1103
|
function B() {
|
|
1097
|
-
var
|
|
1104
|
+
var f;
|
|
1098
1105
|
if (X())
|
|
1099
1106
|
return;
|
|
1100
|
-
(
|
|
1101
|
-
const
|
|
1107
|
+
(f = t.beforeClose) == null || f.call(t);
|
|
1108
|
+
const g = I(c).y, h = c.clientHeight;
|
|
1102
1109
|
o.translateContainer({
|
|
1103
|
-
startY:
|
|
1104
|
-
endY:
|
|
1110
|
+
startY: g,
|
|
1111
|
+
endY: h,
|
|
1105
1112
|
animationFrame: u,
|
|
1106
1113
|
bottomSheetContainer: c,
|
|
1107
1114
|
onEnd: () => {
|
|
1108
1115
|
var m;
|
|
1109
|
-
(m = t.afterClose) == null || m.call(t), et([
|
|
1116
|
+
(m = t.afterClose) == null || m.call(t), et([y, c], !1), l.clearOnOpenEventListeners();
|
|
1110
1117
|
}
|
|
1111
1118
|
}), a();
|
|
1112
1119
|
}
|
|
1113
|
-
function
|
|
1120
|
+
function O() {
|
|
1114
1121
|
return o.isMounted;
|
|
1115
1122
|
}
|
|
1116
1123
|
function N() {
|
|
1117
|
-
const
|
|
1118
|
-
return
|
|
1124
|
+
const g = I(c).y, h = window.innerHeight, f = c.clientHeight >= h ? h : c.clientHeight;
|
|
1125
|
+
return g <= f;
|
|
1119
1126
|
}
|
|
1120
1127
|
function X() {
|
|
1121
1128
|
return !N();
|
|
1122
1129
|
}
|
|
1123
1130
|
function tt() {
|
|
1124
|
-
const
|
|
1125
|
-
if (
|
|
1131
|
+
const g = I(c).y, h = c.clientHeight, f = window.innerHeight;
|
|
1132
|
+
if (g <= 5 && g >= -5)
|
|
1126
1133
|
return R.CONTENT_HEIGHT;
|
|
1127
|
-
const m =
|
|
1128
|
-
if (m ===
|
|
1134
|
+
const m = h - g;
|
|
1135
|
+
if (m === f / 2)
|
|
1129
1136
|
return R.MIDDLE;
|
|
1130
|
-
const v =
|
|
1137
|
+
const v = f - d.marginTop, A = 10;
|
|
1131
1138
|
return m <= v + A && m >= v - A ? R.TOP : R.CLOSED;
|
|
1132
1139
|
}
|
|
1133
1140
|
function nt() {
|
|
1134
1141
|
return c.clientHeight;
|
|
1135
1142
|
}
|
|
1136
|
-
function z(
|
|
1143
|
+
function z(g) {
|
|
1137
1144
|
if (!N())
|
|
1138
1145
|
return;
|
|
1139
|
-
const
|
|
1146
|
+
const h = I(c).y, m = c.clientHeight - h, v = window.innerHeight - g, A = xt(m, v), D = W(m, v);
|
|
1140
1147
|
o.translateContainer({
|
|
1141
|
-
startY:
|
|
1142
|
-
endY:
|
|
1148
|
+
startY: h,
|
|
1149
|
+
endY: h + (A.isUp ? -D : D),
|
|
1143
1150
|
animationFrame: u,
|
|
1144
1151
|
bottomSheetContainer: c
|
|
1145
1152
|
});
|
|
1146
1153
|
}
|
|
1147
|
-
function
|
|
1148
|
-
viewportHeight:
|
|
1149
|
-
visibleHeight:
|
|
1154
|
+
function S(g, {
|
|
1155
|
+
viewportHeight: h,
|
|
1156
|
+
visibleHeight: f
|
|
1150
1157
|
}) {
|
|
1151
1158
|
let m = null;
|
|
1152
|
-
for (const v of
|
|
1153
|
-
const A = v *
|
|
1154
|
-
|
|
1159
|
+
for (const v of g) {
|
|
1160
|
+
const A = v * h, D = W(
|
|
1161
|
+
f,
|
|
1155
1162
|
A
|
|
1156
1163
|
);
|
|
1157
1164
|
(m === null || D < m) && (m = D);
|
|
@@ -1160,25 +1167,25 @@ function cn(t) {
|
|
|
1160
1167
|
minOffset: m
|
|
1161
1168
|
};
|
|
1162
1169
|
}
|
|
1163
|
-
function
|
|
1164
|
-
const
|
|
1165
|
-
if (!
|
|
1170
|
+
function L() {
|
|
1171
|
+
const g = [...d.snapPoints].reverse(), h = I(c).y, f = c.clientHeight, m = f - h;
|
|
1172
|
+
if (!d.expandable && m >= f)
|
|
1166
1173
|
return;
|
|
1167
1174
|
const v = window.innerHeight, A = ft(
|
|
1168
1175
|
"above",
|
|
1169
1176
|
{ visibleHeight: m, viewportHeight: v },
|
|
1170
|
-
|
|
1171
|
-
), { minOffset: D } =
|
|
1177
|
+
g
|
|
1178
|
+
), { minOffset: D } = S(A, {
|
|
1172
1179
|
visibleHeight: m,
|
|
1173
1180
|
viewportHeight: v
|
|
1174
1181
|
});
|
|
1175
|
-
if (D === null && m < v -
|
|
1182
|
+
if (D === null && m < v - d.marginTop) {
|
|
1176
1183
|
o.translateContainer({
|
|
1177
|
-
startY:
|
|
1184
|
+
startY: h,
|
|
1178
1185
|
endY: dt(
|
|
1179
1186
|
v,
|
|
1180
|
-
|
|
1181
|
-
|
|
1187
|
+
f,
|
|
1188
|
+
d.marginTop,
|
|
1182
1189
|
"top"
|
|
1183
1190
|
),
|
|
1184
1191
|
animationFrame: u,
|
|
@@ -1187,46 +1194,46 @@ function cn(t) {
|
|
|
1187
1194
|
return;
|
|
1188
1195
|
}
|
|
1189
1196
|
Y(D) && o.translateContainer({
|
|
1190
|
-
startY:
|
|
1191
|
-
endY:
|
|
1197
|
+
startY: h,
|
|
1198
|
+
endY: h - D,
|
|
1192
1199
|
animationFrame: u,
|
|
1193
1200
|
bottomSheetContainer: c
|
|
1194
1201
|
});
|
|
1195
1202
|
}
|
|
1196
|
-
function
|
|
1197
|
-
const
|
|
1198
|
-
if (
|
|
1203
|
+
function p() {
|
|
1204
|
+
const g = I(c).y, f = c.clientHeight - g;
|
|
1205
|
+
if (f < 1)
|
|
1199
1206
|
return;
|
|
1200
1207
|
const m = window.innerHeight, v = ft(
|
|
1201
1208
|
"below",
|
|
1202
|
-
{ visibleHeight:
|
|
1203
|
-
|
|
1204
|
-
), { minOffset: A } =
|
|
1205
|
-
visibleHeight:
|
|
1209
|
+
{ visibleHeight: f, viewportHeight: m },
|
|
1210
|
+
d.snapPoints
|
|
1211
|
+
), { minOffset: A } = S(v, {
|
|
1212
|
+
visibleHeight: f,
|
|
1206
1213
|
viewportHeight: m
|
|
1207
1214
|
});
|
|
1208
1215
|
Y(A) && o.translateContainer({
|
|
1209
|
-
startY:
|
|
1210
|
-
endY:
|
|
1216
|
+
startY: g,
|
|
1217
|
+
endY: g + A,
|
|
1211
1218
|
animationFrame: u,
|
|
1212
1219
|
bottomSheetContainer: c
|
|
1213
1220
|
});
|
|
1214
1221
|
}
|
|
1215
|
-
function F(
|
|
1216
|
-
const
|
|
1217
|
-
if (!zt(
|
|
1222
|
+
function F(g) {
|
|
1223
|
+
const h = window.innerHeight;
|
|
1224
|
+
if (!zt(g))
|
|
1218
1225
|
return;
|
|
1219
|
-
const
|
|
1220
|
-
z(
|
|
1226
|
+
const f = J(h * g, 2);
|
|
1227
|
+
z(f);
|
|
1221
1228
|
}
|
|
1222
1229
|
return {
|
|
1223
|
-
props:
|
|
1230
|
+
props: d,
|
|
1224
1231
|
elements: b,
|
|
1225
|
-
mount:
|
|
1226
|
-
unmount:
|
|
1232
|
+
mount: C,
|
|
1233
|
+
unmount: w,
|
|
1227
1234
|
open: k,
|
|
1228
1235
|
close: B,
|
|
1229
|
-
getIsMounted:
|
|
1236
|
+
getIsMounted: O,
|
|
1230
1237
|
getIsOpen: N,
|
|
1231
1238
|
getIsClosed: X,
|
|
1232
1239
|
getPosition: tt,
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
(function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode('.pbs-root{position:fixed;left:0;bottom:0;display:flex;flex-direction:column;align-items:center;justify-content:flex-start;width:100%;height:fit-content;max-height:100vh;z-index:2}.pbs-dialog-reset{background-color:transparent;color:inherit;border:none;outline:none;padding:0;margin:0}.pbs-backdrop{position:fixed;top:0;left:0;width:100%;height:100%;background-color:transparent;z-index:1;transition:background-color .2s ease-out}.pbs-backdrop.hidden{visibility:hidden}.pbs-backdrop.open{background-color:#454545b3}.pbs-backdrop.transparent{background-color:transparent}.pbs-container{--pbs-container-background-color: rgb(240, 240, 240);background-color:var(--pbs-container-background-color);position:relative;display:none;flex-direction:column;align-items:center;justify-content:flex-start;width:92%;height:fit-content;max-height:100vh;border-radius:10px 10px 0 0}.pbs-container.open{display:flex}.pbs-container .pbs-gap-filler{position:absolute;bottom:calc(-100vh + .5px);left:0;background-color:var(--pbs-container-background-color);content:"";width:100%;height:100vh}.pbs-handle{position:relative;display:flex;align-items:center;justify-content:center;width:100%;height:30px;cursor:pointer}.pbs-handle.hidden{display:none}.pbs-button-reset{background-color:transparent;-webkit-appearance:none;-moz-appearance:none;appearance:none;outline:none;border:none}button:focus.pbs-button-reset{outline:none}.pbs-handle-bar{background-color:#a8a8a8;position:relative;width:12%;height:7px;border-radius:12px}.pbs-handle-bar.hidden{display:none}.pbs-content-wrapper{position:relative;width:100%;height:fit-content;max-height:100%;overflow-y:scroll}.pbs-content-wrapper::-webkit-scrollbar{display:none}.example{-ms-overflow-style:none;scrollbar-width:none}')),document.head.appendChild(e)}}catch(n){console.error("vite-plugin-css-injected-by-js",n)}})();
|
|
2
|
-
(function(
|
|
3
|
-
/*$vite$:1*/`,document.head.appendChild(H);function y(t){return typeof t=="string"}function Yt(t,n){return t.classList.contains(q(n))}function $(t,n){t.classList.add(q(n))}function rt(t,n){t.classList.remove(q(n))}function W(t,n,e){y(e)&&(y(n)&&rt(t,n),$(t,e))}function q(t){return y(t)?t.trim().replace(/\./g,""):""}function R(t){return t.map(n=>q(n)).filter(Boolean).join(" ")}function xt(t){return t.map(n=>n==null?void 0:n.trim()).filter(Boolean).map(n=>`.${n}`).join(" ")}const gt="open",ht="hidden";function ot(t,n){const e=n;if(Array.isArray(t)){t.forEach(r=>{J(r,e),r.setAttribute("aria-modal",e?"true":"false")});return}J(t,e),t.setAttribute("aria-modal",e?"true":"false")}function J(t,n){n?($(t,gt),rt(t,ht)):($(t,ht),rt(t,gt))}function bt(t){return t instanceof HTMLElement}function Y(t){return typeof t=="number"&&!Number.isNaN(t)}function It(t){bt(t)&&t.focus()}function Nt(t){if(!bt(t)||t.offsetParent===null||"disabled"in t&&t.disabled)return!1;const e=t.getAttribute("tabindex"),r=Y(e)?parseInt(e,10):-1,i=["INPUT","BUTTON","SELECT","TEXTAREA","A","AREA","IFRAME"].includes(t.tagName),a=t instanceof HTMLAnchorElement&&t.href!==""||t instanceof HTMLAreaElement&&t.href!=="";return i||a||r>-1}var 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||{}),Q=(t=>(t.Button="pbs-button-reset",t.Dialog="pbs-dialog-reset",t))(Q||{}),V=(t=>(t.Hidden="hidden",t))(V||{});function M(t,n,e){const r=document.createElement(t);return n.split(" ").forEach(i=>{$(r,i)}),y(e)&&r.setAttribute("data-testid",e),r}const Mt={CONTENTS_WRAPPER:xt([T.Root,T.ContentWrapper])};function mt(t,n,e,r){switch(r){case"content-height":return n>=t?Ct(t,n,e):0;case"middle":return-(t/2-n);case"top":return-(t-n)+e;default:return 0}}function pt(t,n){const e=n<t,r=n>t;return{isUp:e,isDown:r,stayedSame:n===t}}function yt(t,n){return n<t?-(t-n):n-t}function z(t,n){return t>n?t-n:n-t}function Pt(t,n){const e=t<n,r=t>n;return{isUp:e,isDown:r,stayedSame:t===n}}function Tt(t,n,e){const r=t==="above";return e.filter(o=>{const i=o*n.viewportHeight;return r?n.visibleHeight<i:n.visibleHeight>i})}function Ct(t,n,e){return-(t-n)+e}function Et(t){return Number(t.replace("px",""))}function Z(t,...n){return Number(t.toFixed(...n))}function vt(t){const n=/(?<type>\w+)\((?<values>[^)]+)\)/g,e=[];let r;for(;(r=n.exec(t))!==null;){const o=r[1],i=r[2].split(",").map(a=>a.trim());e.push({type:o,values:i})}return e}function Ft(t){const n=t.style.transform,e=vt(n);return{transform:n,transformValues:e}}function wt(t,n){const e=t.find(r=>r.type.startsWith(n));return e||null}const it="translate";function N(t){const n=t.style.transform,e=vt(n),r=wt(e,it);return St(r??{type:it,values:[]})}function tt(t,{x:n,y:e}){const{transform:r,transformValues:o}=Ft(t),i=wt(o,it);if(i){const a=St(i);t.style.transform=`translate(${n??a.x??0}px,${e??a.y??0}px)`;return}if(r){t.style.transform=`${r}, translate(${n??0}px,${e??0}px)`;return}t.style.transform=`translate(${n??0}px,${e??0}px)`}function St(t){if(t.type!=="translate")throw new Error(`Could not get coordinates from ${t.type}, since is not translate.`);const n=t.values[0],e=t.values[1];return{x:Et(n)??0,y:Et(e)??0}}function at(t){return t!=null}function Ot(t,{min:n,max:e}){return at(e)&&t>=e?e:at(n)&&t<=n?n:t}const _t=(t,n,e)=>{n instanceof HTMLElement&&!Yt(n,T.Handle)&&e.scrollTop>=1||(t.isDragging=!0)},Rt=(t,n,e,r)=>o=>{r.startY=t.getCoordinates(o).y,r.containerStartTranslate=N(n),e.onDragStart()},jt=(t,n,e,r,o)=>i=>{Gt(i,t,e,r,o,n,e.marginTop)};function Gt(t,n,e,r,o,i,a){if(!r.isDragging||!Y(r.startY))return;const d=n.getCoordinates(t).y,s=yt(r.startY,d),p=window.innerHeight,l=i.clientHeight,f=l-(r.containerStartTranslate.y+s);if(f>=p)return;const C=pt(r.startY,d);if(C.isUp&&!e.expandable&&f>=l||e.preventClosing&&f<=l)return;o.start(()=>{tt(i,{y:r.containerStartTranslate.y+s})},0);const O=p-a,c=l-r.containerStartTranslate.y;if(C.isUp){const E=O-c,k=O-f,A=Ot(1-Z(k/E,2),{min:0,max:1});e.onDragMove(C,A)}else if(C.isDown){const E=Ot(Z(1-f/c,2),{min:0,max:1});e.onDragMove(C,E)}}const Ut=(t,n,e,r,o,i,a)=>d=>{if(!r.isDragging||(r.isDragging=!1,!Y(r.startY)))return;e.onDragEnd();const s=r.startY,p=t.getCoordinates(d).y,l=N(n).y,f=pt(s,p),C=window.innerHeight,O=n.clientHeight;if(f.isUp){const c=[...e.snapPoints].sort((A,x)=>A-x),E=O+-l;if(!e.expandable&&E>=O)return;for(const A of c){const x=A*window.innerHeight;if(E<=x){const B=z(E,x);a.translateContainer({startY:l,endY:l-B,animationFrame:o,bottomSheetContainer:n});return}}const k=Ct(C,O,e.marginTop);a.translateContainer({startY:l,endY:k,animationFrame:o,bottomSheetContainer:n})}else if(f.isDown){const c=[...e.snapPoints].sort((E,k)=>k-E);for(const E of c){const k=E*window.innerHeight,A=O+-l;if(A>=k){const x=z(A,k);a.translateContainer({startY:l,endY:l+x,animationFrame:o,bottomSheetContainer:n});return}}if(e.preventClosing){const E=O+-l;if(E>=O){const k=z(E,O);a.translateContainer({startY:l,endY:l+k,animationFrame:o,bottomSheetContainer:n})}return}i()}};var P=(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))(P||{});function st(t){switch(t){case 0:return 0;case 1:return 1;case 2:return 2;case 3:return 3;default:return-1}}const $t={eventPhase:P.All};class X{constructor(n){K(this,"currentTarget");this.currentTarget=n}addEventListeners({onStart:n,onStartOptions:e=$t,onMove:r,onEnd:o}){this.addTouchEventListeners({onStart:n,onStartOptions:e,onMove:r,onEnd:o}),this.addMouseEventListeners({onStart:n,onStartOptions:e,onMove:r,onEnd:o})}addTouchEventListeners({onStart:n,onStartOptions:e,onMove:r,onEnd:o}){n&&this.currentTarget.addEventListener("touchstart",i=>{if(e.eventPhase===P.All){n(i);return}st(i.eventPhase)===e.eventPhase&&n(i)},{passive:!0}),r&&this.currentTarget.addEventListener("touchmove",r),o&&this.currentTarget.addEventListener("touchend",o)}addMouseEventListeners({onStart:n,onStartOptions:e,onMove:r,onEnd:o}){n&&this.currentTarget.addEventListener("mousedown",i=>{if(e.eventPhase===P.All){n(i);return}st(i.eventPhase)===e.eventPhase&&n(i)},{passive:!0}),r&&this.currentTarget.addEventListener("mousemove",r),o&&this.currentTarget.addEventListener("mouseup",i=>{o(i)})}removeEventListeners({onStart:n,onMove:e,onEnd:r}){n&&this.currentTarget.removeEventListener("touchstart",n),r&&this.currentTarget.removeEventListener("touchend",r),e&&this.currentTarget.removeEventListener("touchmove",e),n&&this.currentTarget.removeEventListener("mousedown",n),e&&this.currentTarget.removeEventListener("mousemove",e),r&&this.currentTarget.removeEventListener("mouseup",r)}getCoordinates(n){if(n.type==="touchstart"||n.type==="mousedown"){if("touches"in n)return{x:n.touches[0].clientX,y:n.touches[0].clientY};if(n instanceof MouseEvent)return{x:n.clientX,y:n.clientY}}if(n.type==="touchend"||n.type==="mouseup"||n.type==="mousemove"||n.type==="touchmove"){if("touches"in n)return{x:n.changedTouches[0].clientX,y:n.changedTouches[0].clientY};if(n instanceof MouseEvent)return{x:n.clientX,y:n.clientY}}return{x:0,y:0}}}function kt(t){const n=t;return`${n} ${n} 0px 0px`}function Wt(t,n){const e=Vt(t);zt(e),e.bottomSheetContainer.style.width=t.width;const r=document.createElement("div");r.innerHTML=t.content??"";const o=window.innerHeight;e.bottomSheetContainer.style.maxHeight=`${o}px`,e.bottomSheetContentWrapper.appendChild(r);const i=Xt({bottomSheetElements:e,bottomSheetProps:t,options:n});return t.rootStyle&&Object.assign(e.bottomSheetRoot.style,t.rootStyle),t.backdropStyle&&Object.assign(e.bottomSheetBackdrop.style,t.backdropStyle),t.containerGapFillerStyle&&Object.assign(e.bottomSheetContainer.style,t.containerStyle),t.containerStyle&&Object.assign(e.bottomSheetContainerGapFiller.style,t.containerGapFillerStyle),t.handleStyle&&Object.assign(e.bottomSheetHandleBar.style,t.handleStyle),t.contentWrapperStyle&&Object.assign(e.bottomSheetContentWrapper.style,t.contentWrapperStyle),{elements:e,eventHandlers:i}}function Vt(t){const n=M("dialog",R([T.Root,Q.Dialog,t.rootClass]),T.Root);n.ariaLabel=t.ariaLabel;const e=M("section",R([T.Container,t.containerClass]),T.Container);t.containerBorderRadius&&(e.style.borderRadius=kt(t.containerBorderRadius));const r=M("div",T.GapFiller,T.GapFiller);t.containerBackgroundColor&&(e.style.backgroundColor=t.containerBackgroundColor,r.style.backgroundColor=t.containerBackgroundColor);const o=M("button",R([T.Handle,Q.Button,t.shouldShowHandle?null:V.Hidden,t.handleClass]),T.Handle);o.setAttribute("type","button"),o.ariaLabel="bottom sheet close button";const i=M("span",R([T.HandleBar,t.shouldShowHandle?null:V.Hidden]),T.HandleBar),a=M("article",R([T.ContentWrapper,t.contentWrapperClass]),T.ContentWrapper),d=M("div",R([T.Backdrop,t.backdropClass,V.Hidden]),T.Backdrop);return t.backdropColor&&(d.style.backgroundColor=t.backdropColor),t.backDropTransition&&(d.style.transition=t.backDropTransition),{bottomSheetRoot:n,bottomSheetBackdrop:d,bottomSheetContainer:e,bottomSheetHandle:o,bottomSheetHandleBar:i,bottomSheetContentWrapper:a,bottomSheetContainerGapFiller:r}}function zt({bottomSheetRoot:t,bottomSheetContainer:n,bottomSheetHandle:e,bottomSheetHandleBar:r,bottomSheetContentWrapper:o,bottomSheetContainerGapFiller:i}){t.appendChild(n),e.appendChild(r),n.appendChild(e),n.appendChild(o),n.appendChild(i)}function Xt({bottomSheetElements:t,bottomSheetProps:n,options:e}){const{bottomSheetRoot:r,bottomSheetContainer:o,bottomSheetHandle:i,bottomSheetContainerGapFiller:a,bottomSheetContentWrapper:d,bottomSheetBackdrop:s}=t,{animationFrame:p}=e,l=new X(i),f=new X(d),C=new X(a),O=n.dragTriggers.reduce((w,L)=>{const v=r.querySelectorAll(L);if(!v.length)return w;const U=Array.from(v).map(u=>u instanceof HTMLElement?new X(u):null).filter(u=>!!u);return[...w,...U]},[]),c=new X(window),E=Rt(c,o,n,e.draggingState),k=jt(c,o,n,e.draggingState,p),A=Ut(c,o,n,e.draggingState,p,e.onClose,e.bottomSheetState);function x(w){w.target instanceof Element&&!r.contains(w.target)&&e.onClose()}function B(w){_t(e.draggingState,w.target,t.bottomSheetContentWrapper)}function G(w){const L=w??n;L.draggable&&(l.addEventListeners({onStart:B}),O.forEach(v=>{v.addEventListeners({onStart:B,onStartOptions:{eventPhase:P.Target}})})),L.draggable&&L.backgroundDraggable&&(f.addEventListeners({onStart:B,onStartOptions:{eventPhase:P.Target}}),C.addEventListeners({onStart:B})),L.draggable&&c.addEventListeners({onStart:E,onMove:k,onEnd:A}),L.draggable&&window.document.addEventListener("keyup",v=>{v.key==="Escape"&&e.onClose()}),i.addEventListener("keyup",v=>{if(v.key==="ArrowUp"){e.moveUp();return}if(v.key==="ArrowDown"){e.moveDown();return}if(v.shiftKey&&v.key==="Tab"){const U=ft(t.bottomSheetContentWrapper);It(U)}})}function nt(){n.shouldCloseOnOutsideClick?s.addEventListener("click",x):s.style.pointerEvents="none"}function ut(){s.removeEventListener("click",x)}function ft(w){let L=[...Array.from(w.childNodes).reverse()];for(;L.length;){const v=L.shift();if(Nt(v))return v;v&&(L=[...L,...Array.from(v.childNodes).reverse()])}return null}function et(){l.removeEventListeners({onStart:B}),f.removeEventListeners({onStart:B}),C.removeEventListeners({onStart:B}),O.forEach(w=>{w.removeEventListeners({onStart:B})}),c.removeEventListeners({onStart:E,onMove:k,onEnd:A})}return{attachEventListeners:G,clearEventListeners:et,attacheOnOpenEventListeners:nt,clearOnOpenEventListeners:ut}}class Kt{constructor(){K(this,"animationId");K(this,"isInProgress");K(this,"startedAt");this.animationId=null,this.isInProgress=!1,this.startedAt=null}start(n,e,r=!1){this.isInProgress=!0;const o=i=>{this.startedAt||(this.startedAt=i);const a=i-this.startedAt,s=e===0?1:Z(a/e,2),p=s>=1&&!r;n(s),p?this.stop():this.animationId=requestAnimationFrame(o)};this.animationId=requestAnimationFrame(o)}stop(){this.isInProgress=!1,this.startedAt=null,Y(this.animationId)&&cancelAnimationFrame(this.animationId)}}function qt(t){const{startY:n,endY:e,bottomSheetContainer:r,animationFrame:o,onEnd:i,animationTimingFunction:a,animationDuration:d}=t,s=yt(n,e);o.stop();let p=!1;o.start(l=>{tt(r,{y:n+s*a(l)}),!p&&l>=1&&(i==null||i(),p=!0)},d)}const ct=(t,n)=>e=>{qt({...e,animationTimingFunction:t,animationDuration:n})},F={TOP:"top",MIDDLE:"middle",CONTENT_HEIGHT:"content-height",CLOSED:"closed"};function Jt(t){return!(!Y(t)||t>1||t<0)}function Qt(t,n){const e={set(r,o,i,a){return n(o,i),Reflect.set(r,o,i,a)}};return new Proxy(t,e)}function Zt(...t){console.error(t)}const _={EASE:"ease",EASE_IN:"ease-in",EASE_OUT:"ease-out",EASE_IN_OUT:"ease-in-out",SPRING:"spring"};function Ht(t){for(const n of Object.values(_))if(n===t)return!0;return!1}function lt(t){return!!(t instanceof Object&&"p1x"in t&&"p1y"in t&&"p2x"in t&&"p2y"in t&&Y(t.p1x)&&Y(t.p1y)&&Y(t.p2x)&&Y(t.p2y))}function j(t,n,e,r){return function(s){return d(i(s))};function i(s){let p=0,l=1,f=s,C;if(s===0||s===1)return s;for(;p<l;){if(C=a(f),Math.abs(C-s)<.001)return f;s>C?p=f:l=f,f=(l+p)/2}return f}function a(s){return 3*t*s*Math.pow(1-s,2)+3*e*Math.pow(s,2)*(1-s)+Math.pow(s,3)}function d(s){return 3*n*s*Math.pow(1-s,2)+3*r*Math.pow(s,2)*(1-s)+Math.pow(s,3)}}const Lt=j(.25,.1,.25,1),tn=j(.42,0,1,1),At=j(.42,0,.58,1),nn=j(.4,.1,.6,1),en=j(.45,1.5,.55,1);function rn(t){switch(t){case _.EASE:return Lt;case _.EASE_IN:return tn;case _.EASE_OUT:return At;case _.EASE_IN_OUT:return nn;case _.SPRING:return en;default:return Lt}}function Bt(t){return typeof t=="boolean"}const Dt={ariaLabel:"Bottom sheet",content:"",defaultPosition:F.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 on(t){const n={...Dt},e=Object.entries(t).reduce((o,i)=>{const[a,d]=i;return at(d)&&(o[a]=d),o},{});return{...n,...e}}function dt(t){if(lt(t)){const{p1x:n,p1y:e,p2x:r,p2y:o}=t;return j(n,e,r,o)}return Ht(t)?rn(t):At}function an(t,n,e,r){function o(i,a){switch(i){case"content":y(a)&&(t.bottomSheetContentWrapper.innerHTML=a);break;case"width":y(a)&&(t.bottomSheetContainer.style.width=a);break;case"shouldShowHandle":Bt(a)||J(t.bottomSheetHandle,!1);break;case"shouldShowBackdrop":Bt(a)||J(t.bottomSheetBackdrop,!1);break;case"containerBorderRadius":y(a)&&(t.bottomSheetContainer.style.borderRadius=kt(a));break;case"containerBackgroundColor":y(a)&&(t.bottomSheetContainer.style.backgroundColor=a,t.bottomSheetContainerGapFiller.style.backgroundColor=a);break;case"backdropColor":y(a)&&(t.bottomSheetBackdrop.style.backgroundColor=a);break;case"backDropTransition":y(a)&&(t.bottomSheetBackdrop.style.transition=a);break;case"rootClass":if(!y(a))return;W(t.bottomSheetRoot,e.rootClass,a);break;case"containerClass":if(!y(a))return;W(t.bottomSheetContainer,e.containerClass,a);break;case"handleClass":if(!y(a))return;W(t.bottomSheetHandle,e.handleClass,a);break;case"contentWrapperClass":if(!y(a))return;W(t.bottomSheetContentWrapper,e.contentWrapperClass,a);break;case"backdropClass":if(!y(a))return;W(t.bottomSheetBackdrop,e.backdropClass,a);break;case"expandable":r.clearEventListeners(),r.attachEventListeners(e);break;case"preventClosing":r.clearEventListeners(),r.attachEventListeners(e);break;case"draggable":r.clearEventListeners(),r.attachEventListeners(e);break;case"draggingAnimationTimings":if(lt(a)){const d=dt(a),s=ct(d,e.draggingAnimationDuration);n.translateContainer=s}break;case"draggingAnimationDuration":if(Y(a)){const d=dt(e.draggingAnimationTimings),s=ct(d,a);n.translateContainer=s}break;case"rootStyle":e.rootStyle&&Object.assign(t.bottomSheetRoot.style,e.rootStyle);break;case"backdropStyle":e.backdropStyle&&Object.assign(t.bottomSheetBackdrop.style,e.backdropStyle);break;case"containerStyle":e.containerStyle&&Object.assign(t.bottomSheetContainer.style,e.containerStyle);break;case"containerGapFillerStyle":e.containerGapFillerStyle&&Object.assign(t.bottomSheetContainerGapFiller.style,e.containerGapFillerStyle);break;case"handleStyle":e.handleStyle&&Object.assign(t.bottomSheetHandleBar.style,e.handleStyle);break;case"contentWrapperStyle":e.contentWrapperStyle&&Object.assign(t.bottomSheetContentWrapper.style,e.contentWrapperStyle);break}}return o}function sn(t){const n=on(t),e=dt(t.draggingAnimationTimings),o={isMounted:!1,translateContainer:ct(e,n.draggingAnimationDuration)},i={startY:null,containerStartTranslate:{x:0,y:0},isDragging:!1,originalDocumentOverflowY:null,originalDocumentOverscrollBehavior:null};function a(){i.originalDocumentOverflowY&&i.originalDocumentOverflowY!=="hidden"&&(document.body.style.overflowY=i.originalDocumentOverflowY),i.originalDocumentOverscrollBehavior&&(document.body.style.position=i.originalDocumentOverscrollBehavior)}const d=new Kt,s={animationFrame:d,onClose:x,bottomSheetState:o,draggingState:i,snapTo:U,moveUp:L,moveDown:v},{elements:p,eventHandlers:l}=Wt(n,s),f=Qt(n,an(p,o,n,l)),{bottomSheetBackdrop:C,bottomSheetRoot:O,bottomSheetContainer:c}=p,E=u=>{const g=u??window.document.body;g.appendChild(O),g.appendChild(C);const b=window.innerHeight;tt(c,{y:b}),l.attachEventListeners(),o.isMounted=!0},k=()=>{l.clearEventListeners(),Object.values(p).forEach(u=>{u.remove()}),a(),o.isMounted=!1},A=()=>{var I;if(B()||Zt('Bottom Sheet is not mounted yet. call the "mount" method first.'),(I=t.beforeOpen)==null||I.call(t),G())return;ot(C,!0),f.shouldShowBackdrop||$(C,"transparent"),ot([c],!0),tt(c,{y:c.clientHeight});const g=window.innerHeight,b=mt(g,c.clientHeight,f.marginTop,f.defaultPosition),m=N(c).y;o.translateContainer({startY:m,endY:b,animationFrame:d,bottomSheetContainer:c,onEnd:t.afterOpen});const S=document.body.style.overflowY;i.originalDocumentOverflowY=S||"initial";const D=document.body.style.overscrollBehavior;i.originalDocumentOverscrollBehavior=D||"initial",document.body.style.overflow="hidden",document.body.style.overscrollBehavior="contain",p.bottomSheetHandle.focus(),l.attacheOnOpenEventListeners()};function x(){var b;if(nt())return;(b=t.beforeClose)==null||b.call(t);const u=N(c).y,g=c.clientHeight;o.translateContainer({startY:u,endY:g,animationFrame:d,bottomSheetContainer:c,onEnd:()=>{var m;(m=t.afterClose)==null||m.call(t),ot([C,c],!1),l.clearOnOpenEventListeners()}}),a()}function B(){return o.isMounted}function G(){const u=N(c).y,g=window.innerHeight,b=c.clientHeight>=g?g:c.clientHeight;return u<=b}function nt(){return!G()}function ut(){const u=N(c).y,g=c.clientHeight,b=window.innerHeight;if(u<=5&&u>=-5)return F.CONTENT_HEIGHT;const m=g-u;if(m===b/2)return F.MIDDLE;const S=b-f.marginTop,D=10;return m<=S+D&&m>=S-D?F.TOP:F.CLOSED}function ft(){return c.clientHeight}function et(u){if(!G())return;const g=N(c).y,m=c.clientHeight-g,S=window.innerHeight-u,D=Pt(m,S),I=z(m,S);o.translateContainer({startY:g,endY:g+(D.isUp?-I:I),animationFrame:d,bottomSheetContainer:c})}function w(u,{viewportHeight:g,visibleHeight:b}){let m=null;for(const S of u){const D=S*g,I=z(b,D);(m===null||I<m)&&(m=I)}return{minOffset:m}}function L(){const u=[...f.snapPoints].reverse(),g=N(c).y,b=c.clientHeight,m=b-g;if(!f.expandable&&m>=b)return;const S=window.innerHeight,D=Tt("above",{visibleHeight:m,viewportHeight:S},u),{minOffset:I}=w(D,{visibleHeight:m,viewportHeight:S});if(I===null&&m<S-f.marginTop){o.translateContainer({startY:g,endY:mt(S,b,f.marginTop,"top"),animationFrame:d,bottomSheetContainer:c});return}Y(I)&&o.translateContainer({startY:g,endY:g-I,animationFrame:d,bottomSheetContainer:c})}function v(){const u=N(c).y,b=c.clientHeight-u;if(b<1)return;const m=window.innerHeight,S=Tt("below",{visibleHeight:b,viewportHeight:m},f.snapPoints),{minOffset:D}=w(S,{visibleHeight:b,viewportHeight:m});Y(D)&&o.translateContainer({startY:u,endY:u+D,animationFrame:d,bottomSheetContainer:c})}function U(u){const g=window.innerHeight;if(!Jt(u))return;const b=Z(g*u,2);et(b)}return{props:f,elements:p,mount:E,unmount:k,open:A,close:x,getIsMounted:B,getIsOpen:G,getIsClosed:nt,getPosition:ut,getHeight:ft,moveTo:et,snapTo:U}}function cn(){return{elements:{bottomSheetRoot:void 0,bottomSheetBackdrop:void 0,bottomSheetContainer:void 0,bottomSheetHandle:void 0,bottomSheetHandleBar:void 0,bottomSheetContentWrapper:void 0,bottomSheetContainerGapFiller:void 0},mount:()=>{},unmount:()=>{},open:()=>{},close:()=>{},getIsMounted:()=>!1,getHeight:()=>0,getIsOpen:()=>!1,getIsClosed:()=>!0,getPosition:()=>F.CLOSED,moveTo:()=>{},snapTo:()=>{},props:{content:""}}}h.BOTTOM_SHEET_DEFAULT_PROPS=Dt,h.BOTTOM_SHEET_POSITION=F,h.BOTTOM_SHEET_SELECTORS=Mt,h.COMMON_ANIMATION_KEYS=_,h.ClassNames=T,h.EventPhase=P,h.ResetClassNames=Q,h.UtilClassNames=V,h.createBottomSheet=sn,h.createPlaceholderBottomSheet=cn,h.eventPhaseToEnum=st,h.isAnimationTimingPoints=lt,h.isCommonAnimationTimingsKey=Ht,Object.defineProperty(h,Symbol.toStringTag,{value:"Module"})});
|
|
2
|
+
(function(b,H){typeof exports=="object"&&typeof module<"u"?H(exports):typeof define=="function"&&define.amd?define(["exports"],H):(b=typeof globalThis<"u"?globalThis:b||self,H(b.BottomSheet={}))})(this,function(b){"use strict";var ln=Object.defineProperty;var dn=(b,H,y)=>H in b?ln(b,H,{enumerable:!0,configurable:!0,writable:!0,value:y}):b[H]=y;var K=(b,H,y)=>dn(b,typeof H!="symbol"?H+"":H,y);var H=document.createElement("style");H.textContent=`.pbs-root{position:fixed;left:0;bottom:0;display:flex;flex-direction:column;align-items:center;justify-content:flex-start;width:100%;height:fit-content;max-height:100vh;z-index:2}.pbs-dialog-reset{background-color:transparent;color:inherit;border:none;outline:none;padding:0;margin:0}.pbs-backdrop{position:fixed;top:0;left:0;width:100%;height:100%;background-color:transparent;z-index:1;transition:background-color .2s ease-out}.pbs-backdrop.hidden{visibility:hidden}.pbs-backdrop.open{background-color:#454545b3}.pbs-backdrop.transparent{background-color:transparent}.pbs-container{--pbs-container-background-color: rgb(240, 240, 240);background-color:var(--pbs-container-background-color);position:relative;display:none;flex-direction:column;align-items:center;justify-content:flex-start;width:92%;height:fit-content;max-height:100vh;border-radius:10px 10px 0 0}.pbs-container.open{display:flex}.pbs-container .pbs-gap-filler{position:absolute;bottom:calc(-100vh + .5px);left:0;background-color:var(--pbs-container-background-color);content:"";width:100%;height:100vh}.pbs-handle{position:relative;display:flex;align-items:center;justify-content:center;width:100%;height:30px;cursor:pointer}.pbs-handle.hidden{display:none}.pbs-button-reset{background-color:transparent;-webkit-appearance:none;-moz-appearance:none;appearance:none;outline:none;border:none}button:focus.pbs-button-reset{outline:none}.pbs-handle-bar{background-color:#a8a8a8;position:relative;width:12%;height:7px;border-radius:12px}.pbs-handle-bar.hidden{display:none}.pbs-content-wrapper{position:relative;width:100%;height:fit-content;max-height:100%;overflow-y:scroll}.pbs-content-wrapper::-webkit-scrollbar{display:none}.example{-ms-overflow-style:none;scrollbar-width:none}
|
|
3
|
+
/*$vite$:1*/`,document.head.appendChild(H);function y(t){return typeof t=="string"}function Yt(t,n){return t.classList.contains(q(n))}function $(t,n){t.classList.add(q(n))}function rt(t,n){t.classList.remove(q(n))}function V(t,n,e){y(e)&&(y(n)&&rt(t,n),$(t,e))}function q(t){return y(t)?t.trim().replace(/\./g,""):""}function R(t){return t.map(n=>q(n)).filter(Boolean).join(" ")}function xt(t){return t.map(n=>n==null?void 0:n.trim()).filter(Boolean).map(n=>`.${n}`).join(" ")}const gt="open",ht="hidden";function ot(t,n){const e=n;if(Array.isArray(t)){t.forEach(r=>{J(r,e),r.setAttribute("aria-modal",e?"true":"false")});return}J(t,e),t.setAttribute("aria-modal",e?"true":"false")}function J(t,n){n?($(t,gt),rt(t,ht)):($(t,ht),rt(t,gt))}function bt(t){return t instanceof HTMLElement}function Y(t){return typeof t=="number"&&!Number.isNaN(t)}function It(t){bt(t)&&t.focus()}function Nt(t){if(!bt(t)||t.offsetParent===null||"disabled"in t&&t.disabled)return!1;const e=t.getAttribute("tabindex"),r=Y(e)?parseInt(e,10):-1,i=["INPUT","BUTTON","SELECT","TEXTAREA","A","AREA","IFRAME"].includes(t.tagName),a=t instanceof HTMLAnchorElement&&t.href!==""||t instanceof HTMLAreaElement&&t.href!=="";return i||a||r>-1}var C=(t=>(t.Backdrop="pbs-backdrop",t.Root="pbs-root",t.Container="pbs-container",t.GapFiller="pbs-gap-filler",t.Handle="pbs-handle",t.HandleBar="pbs-handle-bar",t.ContentWrapper="pbs-content-wrapper",t))(C||{}),Q=(t=>(t.Button="pbs-button-reset",t.Dialog="pbs-dialog-reset",t))(Q||{}),W=(t=>(t.Hidden="hidden",t))(W||{});function M(t,n,e){const r=document.createElement(t);return n.split(" ").forEach(i=>{$(r,i)}),y(e)&&r.setAttribute("data-testid",e),r}const Mt={CONTENTS_WRAPPER:xt([C.Root,C.ContentWrapper])};function mt(t,n,e,r){switch(r){case"content-height":return n>=t?Ct(t,n,e):0;case"middle":return-(t/2-n);case"top":return-(t-n)+e;default:return 0}}function pt(t,n){const e=n<t,r=n>t;return{isUp:e,isDown:r,stayedSame:n===t}}function yt(t,n){return n<t?-(t-n):n-t}function z(t,n){return t>n?t-n:n-t}function Pt(t,n){const e=t<n,r=t>n;return{isUp:e,isDown:r,stayedSame:t===n}}function Tt(t,n,e){const r=t==="above";return e.filter(o=>{const i=o*n.viewportHeight;return r?n.visibleHeight<i:n.visibleHeight>i})}function Ct(t,n,e){return-(t-n)+e}function Et(t){return Number(t.replace("px",""))}function Z(t,...n){return Number(t.toFixed(...n))}function vt(t){const n=/(?<type>\w+)\((?<values>[^)]+)\)/g,e=[];let r;for(;(r=n.exec(t))!==null;){const o=r[1],i=r[2].split(",").map(a=>a.trim());e.push({type:o,values:i})}return e}function Ft(t){const n=t.style.transform,e=vt(n);return{transform:n,transformValues:e}}function wt(t,n){const e=t.find(r=>r.type.startsWith(n));return e||null}const it="translate";function N(t){const n=t.style.transform,e=vt(n),r=wt(e,it);return St(r??{type:it,values:[]})}function tt(t,{x:n,y:e}){const{transform:r,transformValues:o}=Ft(t),i=wt(o,it);if(i){const a=St(i);t.style.transform=`translate(${n??a.x??0}px,${e??a.y??0}px)`;return}if(r){t.style.transform=`${r}, translate(${n??0}px,${e??0}px)`;return}t.style.transform=`translate(${n??0}px,${e??0}px)`}function St(t){if(t.type!=="translate")throw new Error(`Could not get coordinates from ${t.type}, since is not translate.`);const n=t.values[0],e=t.values[1];return{x:Et(n)??0,y:Et(e)??0}}function at(t){return t!=null}function Ot(t,{min:n,max:e}){return at(e)&&t>=e?e:at(n)&&t<=n?n:t}const _t=(t,n,e)=>{n instanceof HTMLElement&&!Yt(n,C.Handle)&&e.scrollTop>=1||(t.isDragging=!0)},Rt=(t,n,e,r)=>o=>{r.startY=t.getCoordinates(o).y,r.containerStartTranslate=N(n),e.onDragStart()},jt=(t,n,e,r,o)=>i=>{Gt(i,t,e,r,o,n,e.marginTop)};function Gt(t,n,e,r,o,i,a){if(!r.isDragging||!Y(r.startY))return;const d=n.getCoordinates(t).y,s=yt(r.startY,d),p=window.innerHeight,l=i.clientHeight,u=l-(r.containerStartTranslate.y+s);if(u>=p)return;const E=pt(r.startY,d);if(E.isUp&&!e.expandable&&u>=l||e.preventClosing&&u<=l)return;o.start(()=>{tt(i,{y:r.containerStartTranslate.y+s})},0);const w=p-a,c=l-r.containerStartTranslate.y;if(E.isUp){const v=w-c,O=w-u,A=Ot(1-Z(O/v,2),{min:0,max:1});e.onDragMove(E,A)}else if(E.isDown){const v=Ot(Z(1-u/c,2),{min:0,max:1});e.onDragMove(E,v)}}const Ut=(t,n,e,r,o,i,a)=>d=>{if(!r.isDragging||(r.isDragging=!1,!Y(r.startY)))return;e.onDragEnd();const s=r.startY,p=t.getCoordinates(d).y,l=N(n).y,u=pt(s,p),E=window.innerHeight,w=n.clientHeight;if(u.isUp){const c=[...e.snapPoints].sort((A,x)=>A-x),v=w+-l;if(!e.expandable&&v>=w)return;for(const A of c){const x=A*window.innerHeight;if(v<=x){const L=z(v,x);a.translateContainer({startY:l,endY:l-L,animationFrame:o,bottomSheetContainer:n});return}}const O=Ct(E,w,e.marginTop);a.translateContainer({startY:l,endY:O,animationFrame:o,bottomSheetContainer:n})}else if(u.isDown){const c=[...e.snapPoints].sort((v,O)=>O-v);for(const v of c){const O=v*window.innerHeight,A=w+-l;if(A>=O){const x=z(A,O);a.translateContainer({startY:l,endY:l+x,animationFrame:o,bottomSheetContainer:n});return}}if(e.preventClosing){const v=w+-l;if(v>=w){const O=z(v,w);a.translateContainer({startY:l,endY:l+O,animationFrame:o,bottomSheetContainer:n})}return}i()}};var P=(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))(P||{});function st(t){switch(t){case 0:return 0;case 1:return 1;case 2:return 2;case 3:return 3;default:return-1}}const $t={eventPhase:P.All};class X{constructor(n){K(this,"currentTarget");this.currentTarget=n}addEventListeners({onStart:n,onStartOptions:e=$t,onMove:r,onEnd:o}){this.addTouchEventListeners({onStart:n,onStartOptions:e,onMove:r,onEnd:o}),this.addMouseEventListeners({onStart:n,onStartOptions:e,onMove:r,onEnd:o})}addTouchEventListeners({onStart:n,onStartOptions:e,onMove:r,onEnd:o}){n&&this.currentTarget.addEventListener("touchstart",i=>{if(e.eventPhase===P.All){n(i);return}st(i.eventPhase)===e.eventPhase&&n(i)},{passive:!0}),r&&this.currentTarget.addEventListener("touchmove",r),o&&this.currentTarget.addEventListener("touchend",o)}addMouseEventListeners({onStart:n,onStartOptions:e,onMove:r,onEnd:o}){n&&this.currentTarget.addEventListener("mousedown",i=>{if(e.eventPhase===P.All){n(i);return}st(i.eventPhase)===e.eventPhase&&n(i)},{passive:!0}),r&&this.currentTarget.addEventListener("mousemove",r),o&&this.currentTarget.addEventListener("mouseup",i=>{o(i)})}removeEventListeners({onStart:n,onMove:e,onEnd:r}){n&&this.currentTarget.removeEventListener("touchstart",n),r&&this.currentTarget.removeEventListener("touchend",r),e&&this.currentTarget.removeEventListener("touchmove",e),n&&this.currentTarget.removeEventListener("mousedown",n),e&&this.currentTarget.removeEventListener("mousemove",e),r&&this.currentTarget.removeEventListener("mouseup",r)}getCoordinates(n){if(n.type==="touchstart"||n.type==="mousedown"){if("touches"in n)return{x:n.touches[0].clientX,y:n.touches[0].clientY};if(n instanceof MouseEvent)return{x:n.clientX,y:n.clientY}}if(n.type==="touchend"||n.type==="mouseup"||n.type==="mousemove"||n.type==="touchmove"){if("touches"in n)return{x:n.changedTouches[0].clientX,y:n.changedTouches[0].clientY};if(n instanceof MouseEvent)return{x:n.clientX,y:n.clientY}}return{x:0,y:0}}}function kt(t){const n=t;return`${n} ${n} 0px 0px`}function Vt(t,n){const e=Wt(t);zt(e),e.bottomSheetContainer.style.width=t.width;const r=document.createElement("div");r.innerHTML=t.content??"";const o=window.innerHeight;e.bottomSheetContainer.style.maxHeight=`${o}px`,e.bottomSheetContentWrapper.appendChild(r);const i=Xt({bottomSheetElements:e,bottomSheetProps:t,options:n});return t.rootStyle&&Object.assign(e.bottomSheetRoot.style,t.rootStyle),t.backdropStyle&&Object.assign(e.bottomSheetBackdrop.style,t.backdropStyle),t.containerGapFillerStyle&&Object.assign(e.bottomSheetContainer.style,t.containerStyle),t.containerStyle&&Object.assign(e.bottomSheetContainerGapFiller.style,t.containerGapFillerStyle),t.handleStyle&&Object.assign(e.bottomSheetHandleBar.style,t.handleStyle),t.contentWrapperStyle&&Object.assign(e.bottomSheetContentWrapper.style,t.contentWrapperStyle),{elements:e,eventHandlers:i}}function Wt(t){const n=M("dialog",R([C.Root,Q.Dialog,t.rootClass]),C.Root);n.ariaLabel=t.ariaLabel;const e=M("section",R([C.Container,t.containerClass]),C.Container);t.containerBorderRadius&&(e.style.borderRadius=kt(t.containerBorderRadius));const r=M("div",C.GapFiller,C.GapFiller);t.containerBackgroundColor&&(e.style.backgroundColor=t.containerBackgroundColor,r.style.backgroundColor=t.containerBackgroundColor);const o=M("button",R([C.Handle,Q.Button,t.shouldShowHandle?null:W.Hidden,t.handleClass]),C.Handle);o.setAttribute("type","button"),o.ariaLabel="bottom sheet close button";const i=M("span",R([C.HandleBar,t.shouldShowHandle?null:W.Hidden]),C.HandleBar),a=M("article",R([C.ContentWrapper,t.contentWrapperClass]),C.ContentWrapper),d=M("div",R([C.Backdrop,t.backdropClass,W.Hidden]),C.Backdrop);return t.backdropColor&&(d.style.backgroundColor=t.backdropColor),t.backDropTransition&&(d.style.transition=t.backDropTransition),{bottomSheetRoot:n,bottomSheetBackdrop:d,bottomSheetContainer:e,bottomSheetHandle:o,bottomSheetHandleBar:i,bottomSheetContentWrapper:a,bottomSheetContainerGapFiller:r}}function zt({bottomSheetRoot:t,bottomSheetContainer:n,bottomSheetHandle:e,bottomSheetHandleBar:r,bottomSheetContentWrapper:o,bottomSheetContainerGapFiller:i}){t.appendChild(n),e.appendChild(r),n.appendChild(e),n.appendChild(o),n.appendChild(i)}function Xt({bottomSheetElements:t,bottomSheetProps:n,options:e}){const{bottomSheetRoot:r,bottomSheetContainer:o,bottomSheetHandle:i,bottomSheetContainerGapFiller:a,bottomSheetContentWrapper:d,bottomSheetBackdrop:s}=t,{animationFrame:p}=e,l=new X(i),u=new X(d),E=new X(a);let w=[];const c=new X(window),v=Rt(c,o,n,e.draggingState),O=jt(c,o,n,e.draggingState,p),A=Ut(c,o,n,e.draggingState,p,e.onClose,e.bottomSheetState);function x(k){k.target instanceof Element&&!r.contains(k.target)&&e.onClose()}function L(k){_t(e.draggingState,k.target,t.bottomSheetContentWrapper)}function G(k){const B=k??n;B.draggable&&B.backgroundDraggable&&(u.addEventListeners({onStart:L,onStartOptions:{eventPhase:P.Target}}),E.addEventListeners({onStart:L})),B.draggable&&c.addEventListeners({onStart:v,onMove:O,onEnd:A}),B.draggable&&window.document.addEventListener("keyup",T=>{T.key==="Escape"&&e.onClose()}),i.addEventListener("keyup",T=>{if(T.key==="ArrowUp"){e.moveUp();return}if(T.key==="ArrowDown"){e.moveDown();return}if(T.shiftKey&&T.key==="Tab"){const U=ft(t.bottomSheetContentWrapper);It(U)}})}function nt(k){const B=k??n;n.shouldCloseOnOutsideClick&&!n.preventClosing?s.addEventListener("click",x):s.style.pointerEvents="none",B.draggable&&(l.addEventListeners({onStart:L}),w.forEach(T=>{T.removeEventListeners({onStart:L})}),w=n.dragTriggers.reduce((T,U)=>{const g=r.querySelectorAll(U);if(!g.length)return T;const h=Array.from(g).map(f=>f instanceof HTMLElement?new X(f):null).filter(f=>!!f);return[...T,...h]},[]),w.forEach(T=>{T.addEventListeners({onStart:L,onStartOptions:{eventPhase:P.Target}})}))}function ut(){s.removeEventListener("click",x)}function ft(k){let B=[...Array.from(k.childNodes).reverse()];for(;B.length;){const T=B.shift();if(Nt(T))return T;T&&(B=[...B,...Array.from(T.childNodes).reverse()])}return null}function et(){l.removeEventListeners({onStart:L}),u.removeEventListeners({onStart:L}),E.removeEventListeners({onStart:L}),w.forEach(k=>{k.removeEventListeners({onStart:L})}),c.removeEventListeners({onStart:v,onMove:O,onEnd:A})}return{attachEventListeners:G,clearEventListeners:et,attacheOnOpenEventListeners:nt,clearOnOpenEventListeners:ut}}class Kt{constructor(){K(this,"animationId");K(this,"isInProgress");K(this,"startedAt");this.animationId=null,this.isInProgress=!1,this.startedAt=null}start(n,e,r=!1){this.isInProgress=!0;const o=i=>{this.startedAt||(this.startedAt=i);const a=i-this.startedAt,s=e===0?1:Z(a/e,2),p=s>=1&&!r;n(s),p?this.stop():this.animationId=requestAnimationFrame(o)};this.animationId=requestAnimationFrame(o)}stop(){this.isInProgress=!1,this.startedAt=null,Y(this.animationId)&&cancelAnimationFrame(this.animationId)}}function qt(t){const{startY:n,endY:e,bottomSheetContainer:r,animationFrame:o,onEnd:i,animationTimingFunction:a,animationDuration:d}=t,s=yt(n,e);o.stop();let p=!1;o.start(l=>{tt(r,{y:n+s*a(l)}),!p&&l>=1&&(i==null||i(),p=!0)},d)}const ct=(t,n)=>e=>{qt({...e,animationTimingFunction:t,animationDuration:n})},F={TOP:"top",MIDDLE:"middle",CONTENT_HEIGHT:"content-height",CLOSED:"closed"};function Jt(t){return!(!Y(t)||t>1||t<0)}function Qt(t,n){const e={set(r,o,i,a){return n(o,i),Reflect.set(r,o,i,a)}};return new Proxy(t,e)}function Zt(...t){console.error(t)}const _={EASE:"ease",EASE_IN:"ease-in",EASE_OUT:"ease-out",EASE_IN_OUT:"ease-in-out",SPRING:"spring"};function Ht(t){for(const n of Object.values(_))if(n===t)return!0;return!1}function lt(t){return!!(t instanceof Object&&"p1x"in t&&"p1y"in t&&"p2x"in t&&"p2y"in t&&Y(t.p1x)&&Y(t.p1y)&&Y(t.p2x)&&Y(t.p2y))}function j(t,n,e,r){return function(s){return d(i(s))};function i(s){let p=0,l=1,u=s,E;if(s===0||s===1)return s;for(;p<l;){if(E=a(u),Math.abs(E-s)<.001)return u;s>E?p=u:l=u,u=(l+p)/2}return u}function a(s){return 3*t*s*Math.pow(1-s,2)+3*e*Math.pow(s,2)*(1-s)+Math.pow(s,3)}function d(s){return 3*n*s*Math.pow(1-s,2)+3*r*Math.pow(s,2)*(1-s)+Math.pow(s,3)}}const Lt=j(.25,.1,.25,1),tn=j(.42,0,1,1),At=j(.42,0,.58,1),nn=j(.4,.1,.6,1),en=j(.45,1.5,.55,1);function rn(t){switch(t){case _.EASE:return Lt;case _.EASE_IN:return tn;case _.EASE_OUT:return At;case _.EASE_IN_OUT:return nn;case _.SPRING:return en;default:return Lt}}function Bt(t){return typeof t=="boolean"}const Dt={ariaLabel:"Bottom sheet",content:"",defaultPosition:F.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 on(t){const n={...Dt},e=Object.entries(t).reduce((o,i)=>{const[a,d]=i;return at(d)&&(o[a]=d),o},{});return{...n,...e}}function dt(t){if(lt(t)){const{p1x:n,p1y:e,p2x:r,p2y:o}=t;return j(n,e,r,o)}return Ht(t)?rn(t):At}function an(t,n,e,r){function o(i,a){switch(i){case"content":y(a)&&(t.bottomSheetContentWrapper.innerHTML=a);break;case"width":y(a)&&(t.bottomSheetContainer.style.width=a);break;case"shouldShowHandle":Bt(a)||J(t.bottomSheetHandle,!1);break;case"shouldShowBackdrop":Bt(a)||J(t.bottomSheetBackdrop,!1);break;case"containerBorderRadius":y(a)&&(t.bottomSheetContainer.style.borderRadius=kt(a));break;case"containerBackgroundColor":y(a)&&(t.bottomSheetContainer.style.backgroundColor=a,t.bottomSheetContainerGapFiller.style.backgroundColor=a);break;case"backdropColor":y(a)&&(t.bottomSheetBackdrop.style.backgroundColor=a);break;case"backDropTransition":y(a)&&(t.bottomSheetBackdrop.style.transition=a);break;case"rootClass":if(!y(a))return;V(t.bottomSheetRoot,e.rootClass,a);break;case"containerClass":if(!y(a))return;V(t.bottomSheetContainer,e.containerClass,a);break;case"handleClass":if(!y(a))return;V(t.bottomSheetHandle,e.handleClass,a);break;case"contentWrapperClass":if(!y(a))return;V(t.bottomSheetContentWrapper,e.contentWrapperClass,a);break;case"backdropClass":if(!y(a))return;V(t.bottomSheetBackdrop,e.backdropClass,a);break;case"expandable":r.clearEventListeners(),r.attachEventListeners(e);break;case"preventClosing":r.clearEventListeners(),r.attachEventListeners(e);break;case"draggable":r.clearEventListeners(),r.attachEventListeners(e);break;case"dragTriggers":r.clearEventListeners(),r.attachEventListeners(e);break;case"draggingAnimationTimings":if(lt(a)){const d=dt(a),s=ct(d,e.draggingAnimationDuration);n.translateContainer=s}break;case"draggingAnimationDuration":if(Y(a)){const d=dt(e.draggingAnimationTimings),s=ct(d,a);n.translateContainer=s}break;case"rootStyle":e.rootStyle&&Object.assign(t.bottomSheetRoot.style,e.rootStyle);break;case"backdropStyle":e.backdropStyle&&Object.assign(t.bottomSheetBackdrop.style,e.backdropStyle);break;case"containerStyle":e.containerStyle&&Object.assign(t.bottomSheetContainer.style,e.containerStyle);break;case"containerGapFillerStyle":e.containerGapFillerStyle&&Object.assign(t.bottomSheetContainerGapFiller.style,e.containerGapFillerStyle);break;case"handleStyle":e.handleStyle&&Object.assign(t.bottomSheetHandleBar.style,e.handleStyle);break;case"contentWrapperStyle":e.contentWrapperStyle&&Object.assign(t.bottomSheetContentWrapper.style,e.contentWrapperStyle);break}}return o}function sn(t){const n=on(t),e=dt(t.draggingAnimationTimings),o={isMounted:!1,translateContainer:ct(e,n.draggingAnimationDuration)},i={startY:null,containerStartTranslate:{x:0,y:0},isDragging:!1,originalDocumentOverflowY:null,originalDocumentOverscrollBehavior:null};function a(){i.originalDocumentOverflowY&&i.originalDocumentOverflowY!=="hidden"&&(document.body.style.overflowY=i.originalDocumentOverflowY),i.originalDocumentOverscrollBehavior&&(document.body.style.position=i.originalDocumentOverscrollBehavior)}const d=new Kt,s={animationFrame:d,onClose:x,bottomSheetState:o,draggingState:i,snapTo:U,moveUp:B,moveDown:T},{elements:p,eventHandlers:l}=Vt(n,s),u=Qt(n,an(p,o,n,l)),{bottomSheetBackdrop:E,bottomSheetRoot:w,bottomSheetContainer:c}=p,v=g=>{const h=g??window.document.body;h.appendChild(w),h.appendChild(E);const f=window.innerHeight;tt(c,{y:f}),l.attachEventListeners(),o.isMounted=!0},O=()=>{l.clearEventListeners(),Object.values(p).forEach(g=>{g.remove()}),a(),o.isMounted=!1},A=()=>{var I;if(L()||Zt('Bottom Sheet is not mounted yet. call the "mount" method first.'),(I=t.beforeOpen)==null||I.call(t),G())return;ot(E,!0),u.shouldShowBackdrop||$(E,"transparent"),ot([c],!0),tt(c,{y:c.clientHeight});const h=window.innerHeight,f=mt(h,c.clientHeight,u.marginTop,u.defaultPosition),m=N(c).y;o.translateContainer({startY:m,endY:f,animationFrame:d,bottomSheetContainer:c,onEnd:t.afterOpen});const S=document.body.style.overflowY;i.originalDocumentOverflowY=S||"initial";const D=document.body.style.overscrollBehavior;i.originalDocumentOverscrollBehavior=D||"initial",document.body.style.overflow="hidden",document.body.style.overscrollBehavior="contain",p.bottomSheetHandle.focus(),l.attacheOnOpenEventListeners()};function x(){var f;if(nt())return;(f=t.beforeClose)==null||f.call(t);const g=N(c).y,h=c.clientHeight;o.translateContainer({startY:g,endY:h,animationFrame:d,bottomSheetContainer:c,onEnd:()=>{var m;(m=t.afterClose)==null||m.call(t),ot([E,c],!1),l.clearOnOpenEventListeners()}}),a()}function L(){return o.isMounted}function G(){const g=N(c).y,h=window.innerHeight,f=c.clientHeight>=h?h:c.clientHeight;return g<=f}function nt(){return!G()}function ut(){const g=N(c).y,h=c.clientHeight,f=window.innerHeight;if(g<=5&&g>=-5)return F.CONTENT_HEIGHT;const m=h-g;if(m===f/2)return F.MIDDLE;const S=f-u.marginTop,D=10;return m<=S+D&&m>=S-D?F.TOP:F.CLOSED}function ft(){return c.clientHeight}function et(g){if(!G())return;const h=N(c).y,m=c.clientHeight-h,S=window.innerHeight-g,D=Pt(m,S),I=z(m,S);o.translateContainer({startY:h,endY:h+(D.isUp?-I:I),animationFrame:d,bottomSheetContainer:c})}function k(g,{viewportHeight:h,visibleHeight:f}){let m=null;for(const S of g){const D=S*h,I=z(f,D);(m===null||I<m)&&(m=I)}return{minOffset:m}}function B(){const g=[...u.snapPoints].reverse(),h=N(c).y,f=c.clientHeight,m=f-h;if(!u.expandable&&m>=f)return;const S=window.innerHeight,D=Tt("above",{visibleHeight:m,viewportHeight:S},g),{minOffset:I}=k(D,{visibleHeight:m,viewportHeight:S});if(I===null&&m<S-u.marginTop){o.translateContainer({startY:h,endY:mt(S,f,u.marginTop,"top"),animationFrame:d,bottomSheetContainer:c});return}Y(I)&&o.translateContainer({startY:h,endY:h-I,animationFrame:d,bottomSheetContainer:c})}function T(){const g=N(c).y,f=c.clientHeight-g;if(f<1)return;const m=window.innerHeight,S=Tt("below",{visibleHeight:f,viewportHeight:m},u.snapPoints),{minOffset:D}=k(S,{visibleHeight:f,viewportHeight:m});Y(D)&&o.translateContainer({startY:g,endY:g+D,animationFrame:d,bottomSheetContainer:c})}function U(g){const h=window.innerHeight;if(!Jt(g))return;const f=Z(h*g,2);et(f)}return{props:u,elements:p,mount:v,unmount:O,open:A,close:x,getIsMounted:L,getIsOpen:G,getIsClosed:nt,getPosition:ut,getHeight:ft,moveTo:et,snapTo:U}}function cn(){return{elements:{bottomSheetRoot:void 0,bottomSheetBackdrop:void 0,bottomSheetContainer:void 0,bottomSheetHandle:void 0,bottomSheetHandleBar:void 0,bottomSheetContentWrapper:void 0,bottomSheetContainerGapFiller:void 0},mount:()=>{},unmount:()=>{},open:()=>{},close:()=>{},getIsMounted:()=>!1,getHeight:()=>0,getIsOpen:()=>!1,getIsClosed:()=>!0,getPosition:()=>F.CLOSED,moveTo:()=>{},snapTo:()=>{},props:{content:""}}}b.BOTTOM_SHEET_DEFAULT_PROPS=Dt,b.BOTTOM_SHEET_POSITION=F,b.BOTTOM_SHEET_SELECTORS=Mt,b.COMMON_ANIMATION_KEYS=_,b.ClassNames=C,b.EventPhase=P,b.ResetClassNames=Q,b.UtilClassNames=W,b.createBottomSheet=sn,b.createPlaceholderBottomSheet=cn,b.eventPhaseToEnum=st,b.isAnimationTimingPoints=lt,b.isCommonAnimationTimingsKey=Ht,Object.defineProperty(b,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plainsheet/core",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.10",
|
|
4
4
|
"private": false,
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"description": "The minimalistic, configurable React bottom-sheet for the Web developers",
|
|
@@ -51,6 +51,7 @@
|
|
|
51
51
|
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist",
|
|
52
52
|
"lint": "eslint . --max-warnings 0",
|
|
53
53
|
"test": "vitest run",
|
|
54
|
-
"test:watch": "vitest --ui"
|
|
54
|
+
"test:watch": "vitest --ui",
|
|
55
|
+
"readme": "sh ../../scripts/copy-root-readme.sh"
|
|
55
56
|
}
|
|
56
57
|
}
|