@plainsheet/core 0.5.1 → 0.6.0
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 +1 -1
- package/dist/animation/animation.d.ts +1 -1
- package/dist/bottom-sheet.d.ts +3 -3
- package/dist/bottom-sheet.d.ts.map +1 -1
- package/dist/calculator/position-calculator.d.ts +1 -1
- package/dist/event-handlers/dragging-handler.d.ts +6 -6
- package/dist/event-handlers/dragging-handler.d.ts.map +1 -1
- package/dist/initializer/bottom-sheet-initializer.d.ts +4 -4
- package/dist/initializer/bottom-sheet-initializer.d.ts.map +1 -1
- package/dist/initializer/bottom-sheet-placeholder.d.ts +2 -2
- package/dist/initializer/bottom-sheet-placeholder.d.ts.map +1 -1
- package/dist/initializer/bottom-sheet-props-initializer.d.ts +6 -6
- 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 +437 -429
- package/dist/plainsheet-core.umd.js +2 -2
- package/dist/types/bottom-sheet-props.type.d.ts +4 -4
- package/dist/types/bottom-sheet-props.type.d.ts.map +1 -1
- package/dist/types/bottom-sheet-state.type.d.ts +2 -2
- package/dist/types/bottom-sheet-state.type.d.ts.map +1 -1
- package/dist/types/bottom-sheet.type.d.ts +4 -4
- package/dist/types/bottom-sheet.type.d.ts.map +1 -1
- package/dist/utils/dom/translate.d.ts +1 -1
- package/dist/utils/event-listeners/TabEventListener.d.ts +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { AnimationFrame } from '../utils/animation/animation-frame';
|
|
2
1
|
import { AnimationTimingFunction } from '../utils/animation/animation.type';
|
|
2
|
+
import { AnimationFrame } from '../utils/animation/animation-frame';
|
|
3
3
|
|
|
4
4
|
export interface TranslateContainerParams {
|
|
5
5
|
startY: number;
|
package/dist/bottom-sheet.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { BottomSheetCoreProps } from './types/bottom-sheet-props.type';
|
|
2
|
+
import { BottomSheetCore } from './types/bottom-sheet.type';
|
|
3
3
|
|
|
4
|
-
export declare function createBottomSheet(props:
|
|
4
|
+
export declare function createBottomSheet(props: BottomSheetCoreProps): BottomSheetCore;
|
|
5
5
|
//# sourceMappingURL=bottom-sheet.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bottom-sheet.d.ts","sourceRoot":"","sources":["../src/bottom-sheet.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAC9B,OAAO,0BAA0B,CAAC;AAClC,OAAO,2BAA2B,CAAC;AACnC,OAAO,wBAAwB,CAAC;AAChC,OAAO,yBAAyB,CAAC;AAiBjC,OAAO,KAAK,EAEV,
|
|
1
|
+
{"version":3,"file":"bottom-sheet.d.ts","sourceRoot":"","sources":["../src/bottom-sheet.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAC9B,OAAO,0BAA0B,CAAC;AAClC,OAAO,2BAA2B,CAAC;AACnC,OAAO,wBAAwB,CAAC;AAChC,OAAO,yBAAyB,CAAC;AAiBjC,OAAO,KAAK,EAEV,oBAAoB,EAErB,MAAM,iCAAiC,CAAC;AAEzC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAYjE,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,oBAAoB,GAC1B,eAAe,CAqXjB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { DraggingDirection } from './position-calculator.type';
|
|
2
1
|
import { BottomSheetPosition, SnapPoints } from '../types/bottom-sheet-props.type';
|
|
2
|
+
import { DraggingDirection } from './position-calculator.type';
|
|
3
3
|
|
|
4
4
|
/** It expects the bottom sheet to be open. */
|
|
5
5
|
export declare function convertDefaultPositionToYCoordinate(viewportHeight: number, containerHeight: number, marginTop: number, position: BottomSheetPosition): number;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { BottomSheetProps } from '../types/bottom-sheet-props.type';
|
|
2
|
-
import { TabEvent, TabEventListener } from '../utils/event-listeners/TabEventListener';
|
|
3
|
-
import { AnimationFrame } from '../utils/animation/animation-frame';
|
|
4
1
|
import { BottomSheetState, DraggingState } from '../types';
|
|
2
|
+
import { AnimationFrame } from '../utils/animation/animation-frame';
|
|
3
|
+
import { TabEvent, TabEventListener } from '../utils/event-listeners/TabEventListener';
|
|
4
|
+
import { BottomSheetCoreProps } from '../types/bottom-sheet-props.type';
|
|
5
5
|
|
|
6
6
|
export declare const handleDragTriggerClick: (draggingState: DraggingState, eventTrigger: EventTarget | null, contentWrapper: HTMLElement) => void;
|
|
7
|
-
export declare const handleDragStart: (mouseEventListener: TabEventListener, bottomSheetContainer: HTMLElement, bottomSheetProps: Required<
|
|
8
|
-
export declare const handleDragMove: (mouseEventListener: TabEventListener, bottomSheetContainer: HTMLElement, bottomSheetProps: Required<
|
|
9
|
-
export declare const handleDragEnd: (eventListener: TabEventListener, bottomSheetContainer: HTMLElement, bottomSheetProps: Required<
|
|
7
|
+
export declare const handleDragStart: (mouseEventListener: TabEventListener, bottomSheetContainer: HTMLElement, bottomSheetProps: Required<BottomSheetCoreProps>, draggingState: DraggingState) => (event: TabEvent) => void;
|
|
8
|
+
export declare const handleDragMove: (mouseEventListener: TabEventListener, bottomSheetContainer: HTMLElement, bottomSheetProps: Required<BottomSheetCoreProps>, draggingState: DraggingState, animationFrame: AnimationFrame) => (event: TabEvent) => void;
|
|
9
|
+
export declare const handleDragEnd: (eventListener: TabEventListener, bottomSheetContainer: HTMLElement, bottomSheetProps: Required<BottomSheetCoreProps>, draggingState: DraggingState, animationFrame: AnimationFrame, onClose: () => void, bottomSheetState: BottomSheetState) => (event: TabEvent) => void;
|
|
10
10
|
//# sourceMappingURL=dragging-handler.d.ts.map
|
|
@@ -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,
|
|
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,kBAClB,aAAa,gBACd,WAAW,GAAG,IAAI,kBAChB,WAAW,KAC1B,IAYF,CAAC;AAEF,eAAO,MAAM,eAAe,uBAEJ,gBAAgB,wBACd,WAAW,oBACf,QAAQ,CAAC,oBAAoB,CAAC,iBACjC,aAAa,aAEtB,QAAQ,SAKf,CAAC;AAEJ,eAAO,MAAM,cAAc,uBAEH,gBAAgB,wBACd,WAAW,oBACf,QAAQ,CAAC,oBAAoB,CAAC,iBACjC,aAAa,kBACZ,cAAc,aAExB,QAAQ,SAUf,CAAC;AA+EJ,eAAO,MAAM,aAAa,kBAEP,gBAAgB,wBACT,WAAW,oBACf,QAAQ,CAAC,oBAAoB,CAAC,iBACjC,aAAa,kBACZ,cAAc,WACrB,MAAM,IAAI,oBACD,gBAAgB,aAE5B,QAAQ,SAqGf,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { BottomSheetProps } from '../types/bottom-sheet-props.type';
|
|
2
|
-
import { AnimationFrame } from '../utils/animation/animation-frame';
|
|
3
1
|
import { BottomSheetState, DraggingState } from '../types';
|
|
2
|
+
import { AnimationFrame } from '../utils/animation/animation-frame';
|
|
3
|
+
import { BottomSheetCoreProps } from '../types/bottom-sheet-props.type';
|
|
4
4
|
|
|
5
5
|
export interface InitializerOptions {
|
|
6
6
|
animationFrame: AnimationFrame;
|
|
@@ -14,7 +14,7 @@ interface InitializeBottomSheetElementsReturnType {
|
|
|
14
14
|
elements: BottomSheetElements;
|
|
15
15
|
eventHandlers: InitializeEventsReturnType;
|
|
16
16
|
}
|
|
17
|
-
export declare function initializeBottomSheetElements(props: Required<
|
|
17
|
+
export declare function initializeBottomSheetElements(props: Required<BottomSheetCoreProps>, options: InitializerOptions): InitializeBottomSheetElementsReturnType;
|
|
18
18
|
export interface BottomSheetElements {
|
|
19
19
|
bottomSheetRoot: HTMLElement;
|
|
20
20
|
bottomSheetBackdrop: HTMLElement;
|
|
@@ -26,7 +26,7 @@ export interface BottomSheetElements {
|
|
|
26
26
|
}
|
|
27
27
|
export interface InitializeEventsParams {
|
|
28
28
|
bottomSheetElements: BottomSheetElements;
|
|
29
|
-
bottomSheetProps: Required<
|
|
29
|
+
bottomSheetProps: Required<BottomSheetCoreProps>;
|
|
30
30
|
options: InitializerOptions;
|
|
31
31
|
}
|
|
32
32
|
interface InitializeEventsReturnType {
|
|
@@ -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,
|
|
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;AAE7E,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,CAsBzC;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;AA2GD,MAAM,WAAW,sBAAsB;IACrC,mBAAmB,EAAE,mBAAmB,CAAC;IACzC,gBAAgB,EAAE,QAAQ,CAAC,oBAAoB,CAAC,CAAC;IACjD,OAAO,EAAE,kBAAkB,CAAC;CAC7B;AAED,UAAU,0BAA0B;IAClC,oBAAoB,EAAE,MAAM,IAAI,CAAC;IACjC,mBAAmB,EAAE,MAAM,IAAI,CAAC;CACjC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BottomSheetCore } from '../types/bottom-sheet.type';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* @returns A fallback BottomSheet instance to provide non-null BottomSheet methods to library users.
|
|
5
5
|
*/
|
|
6
|
-
export declare function createPlaceholderBottomSheet():
|
|
6
|
+
export declare function createPlaceholderBottomSheet(): BottomSheetCore;
|
|
7
7
|
//# sourceMappingURL=bottom-sheet-placeholder.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bottom-sheet-placeholder.d.ts","sourceRoot":"","sources":["../../src/initializer/bottom-sheet-placeholder.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"bottom-sheet-placeholder.d.ts","sourceRoot":"","sources":["../../src/initializer/bottom-sheet-placeholder.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAElE;;GAEG;AACH,wBAAgB,4BAA4B,IAAI,eAAe,CAoC9D"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ObserverSetHandler } from '../utils/proxy/observe';
|
|
1
|
+
import { BottomSheetCoreProps, BottomSheetState, RequiredBottomSheetProps } from '../types';
|
|
3
2
|
import { AnimationTimingFunction } from '../utils';
|
|
4
|
-
import {
|
|
3
|
+
import { ObserverSetHandler } from '../utils/proxy/observe';
|
|
4
|
+
import { BottomSheetElements } from './bottom-sheet-initializer';
|
|
5
5
|
|
|
6
|
-
export declare function overwriteDefaultProps(props:
|
|
7
|
-
export declare function interpretAnimationTimingsProp(draggingAnimationTimings:
|
|
8
|
-
export declare function createPropSetHandler(elements: BottomSheetElements, bottomSheetState: BottomSheetState, propsWithDefaults: Required<
|
|
6
|
+
export declare function overwriteDefaultProps(props: BottomSheetCoreProps): RequiredBottomSheetProps;
|
|
7
|
+
export declare function interpretAnimationTimingsProp(draggingAnimationTimings: BottomSheetCoreProps["draggingAnimationTimings"]): AnimationTimingFunction;
|
|
8
|
+
export declare function createPropSetHandler(elements: BottomSheetElements, bottomSheetState: BottomSheetState, propsWithDefaults: Required<BottomSheetCoreProps>): ObserverSetHandler;
|
|
9
9
|
//# sourceMappingURL=bottom-sheet-props-initializer.d.ts.map
|
|
@@ -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,
|
|
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,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAEtE,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,GAChD,kBAAkB,CAuHpB"}
|
|
@@ -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%;pointer-events:none;background-color:transparent;z-index:1;transition:background-color .2s ease-out}.pbs-backdrop.hidden{display:none}.pbs-backdrop.open{background-color:#454545b3}.pbs-container{--pbs-container-background-color: rgb(240, 240, 240);background-color:var(--pbs-container-background-color);position:relative;display:none;flex-direction:column;align-items:center;justify-content:flex-start;width:92%;height:fit-content;max-height:100vh;border-radius:10px 10px 0 0}.pbs-container.open{display:flex}.pbs-container .pbs-gap-filler{position:absolute;bottom:calc(-100vh + .5px);left:0;background-color:var(--pbs-container-background-color);content:"";width:100%;height:100vh}.pbs-handle{position:relative;display:flex;align-items:center;justify-content:center;width:100%;height:30px;cursor:pointer}.pbs-handle.hidden{display:none}.pbs-button-reset{background-color:transparent;-webkit-appearance:none;-moz-appearance:none;appearance:none;outline:none;border:none}button:focus.pbs-button-reset{outline:none}.pbs-handle-bar{background-color:#a8a8a8;position:relative;width:12%;height:7px;border-radius:12px}.pbs-handle-bar.hidden{display:none}.pbs-content-wrapper{position:relative;width:100%;height:fit-content;max-height:100%;overflow-y:scroll}.pbs-content-wrapper::-webkit-scrollbar{display:none}.example{-ms-overflow-style:none;scrollbar-width:none}')),document.head.appendChild(e)}}catch(n){console.error("vite-plugin-css-injected-by-js",n)}})();
|
|
2
|
-
"use strict";var St=Object.defineProperty;var Dt=(t,n,e)=>n in t?St(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),e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function v(t){return typeof t=="string"}function kt(t,n){return t.classList.contains(Q(n))}function X(t,n){t.classList.add(Q(n))}function et(t,n){t.classList.remove(Q(n))}function W(t,n,e){v(e)&&(v(n)&&et(t,n),X(t,e))}function Q(t){return v(t)?t.trim().replace(/\./g,""):""}function F(t){return t.map(n=>Q(n)).filter(Boolean).join(" ")}function Bt(t){return t.map(n=>n==null?void 0:n.trim()).filter(Boolean).map(n=>`.${n}`).join(" ")}const lt="open",dt="hidden";function nt(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?(X(t,lt),et(t,dt)):(X(t,dt),et(t,lt))}function bt(t){return t instanceof HTMLElement}function A(t){return typeof t=="number"&&!Number.isNaN(t)}function Yt(t){bt(t)&&t.focus()}function It(t){if(!bt(t)||t.offsetParent===null||"disabled"in t&&t.disabled)return!1;const e=t.getAttribute("tabindex"),r=A(e)?parseInt(e,10):-1,o=["INPUT","BUTTON","SELECT","TEXTAREA","A","AREA","IFRAME"].includes(t.tagName),c=t instanceof HTMLAnchorElement&&t.href!==""||t instanceof HTMLAreaElement&&t.href!=="";return o||c||r>-1}var b=(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))(b||{}),K=(t=>(t.Button="pbs-button-reset",t.Dialog="pbs-dialog-reset",t))(K||{}),V=(t=>(t.Hidden="hidden",t))(V||{});function N(t,n,e){const r=document.createElement(t);return n.split(" ").forEach(o=>{X(r,o)}),v(e)&&r.setAttribute("data-testid",e),r}const Nt={CONTENTS_WRAPPER:Bt([b.Root,b.ContentWrapper])};function ft(t,n,e,r){switch(r){case"content-height":return n>=t?wt(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 z(t,n){return t>n?t-n:n-t}function Mt(t,n){const e=t<n,r=t>n;return{isUp:e,isDown:r,stayedSame:t===n}}function gt(t,n,e){const r=t==="above";return e.filter(i=>{const o=i*n.viewportHeight;return r?n.visibleHeight<o:n.visibleHeight>o})}function wt(t,n,e){return-(t-n)+e}function ht(t){return Number(t.replace("px",""))}function q(t,...n){return Number(t.toFixed(...n))}function Ht(t){const n=/(?<type>\w+)\((?<values>[^)]+)\)/g,e=[];let r;for(;(r=n.exec(t))!==null;){const i=r[1],o=r[2].split(",").map(c=>c.trim());e.push({type:i,values:o})}return e}function Pt(t){const n=t.style.transform,e=Ht(n);return{transform:n,transformValues:e}}function yt(t,n){const e=t.find(r=>r.type.startsWith(n));return e||null}const rt="translate";function Y(t){const n=t.style.transform,e=Ht(n),r=yt(e,rt);return vt(r??{type:rt,values:[]})}function J(t,{x:n,y:e}){const{transform:r,transformValues:i}=Pt(t),o=yt(i,rt);if(o){const c=vt(o);t.style.transform=`translate(${n??c.x??0}px,${e??c.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 vt(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:ht(n)??0,y:ht(e)??0}}function ot(t){return t!=null}function mt(t,{min:n,max:e}){return ot(e)&&t>=e?e:ot(n)&&t<=n?n:t}const xt=(t,n,e)=>{n instanceof HTMLElement&&!kt(n,b.Handle)&&e.scrollTop>=1||(t.isDragging=!0)},_t=(t,n,e,r)=>i=>{r.startY=t.getCoordinates(i).y,r.containerStartTranslate=Y(n),r.originalDocumentOverflowY=document.body.style.overflowY,document.body.style.overflowY="hidden",e.onDragStart()},Ft=(t,n,e,r,i)=>o=>{Rt(o,t,e,r,i,n,e.marginTop)};function Rt(t,n,e,r,i,o,c){if(!r.isDragging||!A(r.startY))return;const f=n.getCoordinates(t).y,a=Et(r.startY,f),T=window.innerHeight,u=o.clientHeight,p=u-(r.containerStartTranslate.y+a);if(p>=T)return;const w=Ct(r.startY,f);if(w.isUp&&!e.expandable&&p>=u)return;i.start(()=>{J(o,{y:r.containerStartTranslate.y+a})},0);const s=T-c,L=u-r.containerStartTranslate.y;if(w.isUp){const H=s-L,O=s-p,y=mt(1-q(O/H,2),{min:0,max:1});e.onDragMove(w,y)}else if(w.isDown){const H=mt(q(1-p/L,2),{min:0,max:1});e.onDragMove(w,H)}}const Ut=(t,n,e,r,i,o,c)=>f=>{if(!r.isDragging||(r.isDragging=!1,document.body.style.overflowY=r.originalDocumentOverflowY,!A(r.startY)))return;e.onDragEnd();const a=r.startY,T=t.getCoordinates(f).y,u=Y(n).y,p=Ct(a,T),w=window.innerHeight,s=n.clientHeight;if(p.isUp){const L=[...e.snapPoints].sort((y,C)=>y-C),H=s+-u;if(!e.expandable&&H>=s)return;for(const y of L){const C=y*window.innerHeight;if(H<=C){const I=z(H,C);c.translateContainer({startY:u,endY:u-I,animationFrame:i,bottomSheetContainer:n});return}}const O=wt(w,s,e.marginTop);c.translateContainer({startY:u,endY:O,animationFrame:i,bottomSheetContainer:n})}else if(p.isDown){const L=[...e.snapPoints].sort((H,O)=>O-H);for(const H of L){const O=H*window.innerHeight,y=s+-u;if(y>=O){const C=z(y,O);c.translateContainer({startY:u,endY:u+C,animationFrame:i,bottomSheetContainer:n});return}}o()}};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 it(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 G{constructor(n){U(this,"currentTarget");this.currentTarget=n}addEventListeners({onStart:n,onStartOptions:e=Wt,onMove:r,onEnd:i}){this.addTouchEventListeners({onStart:n,onStartOptions:e,onMove:r,onEnd:i}),this.addMouseEventListeners({onStart:n,onStartOptions:e,onMove:r,onEnd:i})}addTouchEventListeners({onStart:n,onStartOptions:e,onMove:r,onEnd:i}){n&&this.currentTarget.addEventListener("touchstart",o=>{if(e.eventPhase===x.All){n(o);return}it(o.eventPhase)===e.eventPhase&&n(o)},{passive:!0}),r&&this.currentTarget.addEventListener("touchmove",r),i&&this.currentTarget.addEventListener("touchend",i)}addMouseEventListeners({onStart:n,onStartOptions:e,onMove:r,onEnd:i}){n&&this.currentTarget.addEventListener("mousedown",o=>{if(e.eventPhase===x.All){n(o);return}it(o.eventPhase)===e.eventPhase&&n(o)},{passive:!0}),r&&this.currentTarget.addEventListener("mousemove",r),i&&this.currentTarget.addEventListener("mouseup",o=>{i(o)})}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 Gt(t,n){const e=Vt(t);$t(e),e.bottomSheetContainer.style.width=t.width;const r=document.createElement("div");r.innerHTML=t.content??"";const i=window.innerHeight;e.bottomSheetContainer.style.maxHeight=`${i}px`,e.bottomSheetContentWrapper.appendChild(r);const o=Xt({bottomSheetElements:e,bottomSheetProps:t,options:n});return{elements:e,eventHandlers:o}}function Vt(t){const n=N("dialog",F([b.Root,K.Dialog,t.rootClass]),b.Root);n.ariaLabel=t.ariaLabel;const e=N("section",F([b.Container,t.containerClass]),b.Container);t.containerBorderRadius&&(e.style.borderRadius=t.containerBorderRadius);const r=N("div",b.GapFiller,b.GapFiller),i=N("button",F([b.Handle,K.Button,t.shouldShowHandle?null:V.Hidden,t.handleClass]),b.Handle);i.setAttribute("type","button"),i.ariaLabel="bottom sheet close button";const o=N("span",F([b.HandleBar,t.shouldShowHandle?null:V.Hidden]),b.HandleBar),c=N("article",F([b.ContentWrapper,t.contentWrapperClass]),b.ContentWrapper),f=N("div",F([b.Backdrop,t.backdropClass,V.Hidden]),b.Backdrop);return t.backdropColor&&(f.style.backgroundColor=t.backdropColor),t.backDropTransition&&(f.style.transition=t.backDropTransition),{bottomSheetRoot:n,bottomSheetBackdrop:f,bottomSheetContainer:e,bottomSheetHandle:i,bottomSheetHandleBar:o,bottomSheetContentWrapper:c,bottomSheetContainerGapFiller:r}}function $t({bottomSheetRoot:t,bottomSheetContainer:n,bottomSheetHandle:e,bottomSheetHandleBar:r,bottomSheetContentWrapper:i,bottomSheetContainerGapFiller:o}){t.appendChild(n),e.appendChild(r),n.appendChild(e),n.appendChild(i),n.appendChild(o)}function Xt({bottomSheetElements:t,bottomSheetProps:n,options:e}){const{bottomSheetRoot:r,bottomSheetContainer:i,bottomSheetHandle:o,bottomSheetContainerGapFiller:c,bottomSheetContentWrapper:f}=t,{animationFrame:a}=e,T=new G(o),u=new G(f),p=new G(c),w=n.dragTriggers.reduce((m,S)=>{const k=r.querySelectorAll(S);if(!k.length)return m;const tt=Array.from(k).map(_=>_ instanceof HTMLElement?new G(_):null).filter(_=>!!_);return[...m,...tt]},[]),s=new G(window),L=_t(s,i,n,e.draggingState),H=Ft(s,i,n,e.draggingState,a),O=Ut(s,i,n,e.draggingState,a,e.onClose,e.bottomSheetState);function y(m){m.target instanceof Element&&!r.contains(m.target)&&e.onClose()}function C(m){xt(e.draggingState,m.target,t.bottomSheetContentWrapper)}function I(){n.draggable&&(T.addEventListeners({onStart:C}),w.forEach(m=>{m.addEventListeners({onStart:C,onStartOptions:{eventPhase:x.Target}})})),n.draggable&&n.backgroundDraggable&&(u.addEventListeners({onStart:C,onStartOptions:{eventPhase:x.Target}}),p.addEventListeners({onStart:C})),n.draggable&&s.addEventListeners({onStart:L,onMove:H,onEnd:O}),n.draggable&&window.document.addEventListener("keyup",m=>{m.key==="Escape"&&e.onClose()}),n.shouldCloseOnOutsideClick&&window.document.addEventListener("click",y),o.addEventListener("keyup",m=>{if(m.key==="ArrowUp"){e.moveUp();return}if(m.key==="ArrowDown"){e.moveDown();return}if(m.shiftKey&&m.key==="Tab"){const S=$(t.bottomSheetContentWrapper);Yt(S)}})}function $(m){let S=[...Array.from(m.childNodes).reverse()];for(;S.length;){const k=S.shift();if(It(k))return k;k&&(S=[...S,...Array.from(k.childNodes).reverse()])}return null}function Z(){T.removeEventListeners({onStart:C}),u.removeEventListeners({onStart:C}),p.removeEventListeners({onStart:C}),w.forEach(m=>{m.removeEventListeners({onStart:C})}),s.removeEventListeners({onStart:L,onMove:H,onEnd:O}),window.removeEventListener("click",y)}return{attachEventListeners:I,clearEventListeners:Z}}class jt{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 i=o=>{this.startedAt||(this.startedAt=o);const c=o-this.startedAt,a=e===0?1:q(c/e,2),T=a>=1&&!r;n(a),T?this.stop():this.animationId=requestAnimationFrame(i)};this.animationId=requestAnimationFrame(i)}stop(){this.isInProgress=!1,this.startedAt=null,A(this.animationId)&&cancelAnimationFrame(this.animationId)}}function Kt(t){const{startY:n,endY:e,bottomSheetContainer:r,animationFrame:i,onEnd:o,animationTimingFunction:c,animationDuration:f}=t,a=Et(n,e);i.stop();let T=!1;i.start(u=>{J(r,{y:n+a*c(u)}),!T&&u>=1&&(o==null||o(),T=!0)},f)}const st=(t,n)=>e=>{Kt({...e,animationTimingFunction:t,animationDuration:n})},P={TOP:"top",MIDDLE:"middle",CONTENT_HEIGHT:"content-height",CLOSED:"closed"};function zt(t){return!(!A(t)||t>1||t<0)}function qt(t,n){const e={set(r,i,o,c){return n(i,o),Reflect.set(r,i,o,c)}};return new Proxy(t,e)}function Jt(...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 Ot(t){for(const n of Object.values(M))if(n===t)return!0;return!1}function ct(t){return!!(t instanceof Object&&"p1x"in t&&"p1y"in t&&"p2x"in t&&"p2y"in t&&A(t.p1x)&&A(t.p1y)&&A(t.p2x)&&A(t.p2y))}function R(t,n,e,r){return function(a){return f(o(a))};function o(a){let T=0,u=1,p=a,w;if(a===0||a===1)return a;for(;T<u;){if(w=c(p),Math.abs(w-a)<.001)return p;a>w?T=p:u=p,p=(u+T)/2}return p}function c(a){return 3*t*a*Math.pow(1-a,2)+3*e*Math.pow(a,2)*(1-a)+Math.pow(a,3)}function f(a){return 3*n*a*Math.pow(1-a,2)+3*r*Math.pow(a,2)*(1-a)+Math.pow(a,3)}}const Qt=R(.25,.1,.25,1),Zt=R(.42,0,1,1),At=R(.42,0,.58,1),pt=R(.4,.1,.6,1),tn=R(.45,1.5,.55,1);function nn(t){switch(t){case M.EASE:return Qt;case M.EASE_IN:return Zt;case M.EASE_OUT:return At;case M.EASE_IN_OUT:return pt;case M.SPRING:return tn;default:return pt}}function Tt(t){return typeof t=="boolean"}const Lt={ariaLabel:"Bottom sheet",content:"",defaultPosition:P.CONTENT_HEIGHT,marginTop:20,snapPoints:[],width:"92%",dragTriggers:[],beforeOpen:()=>{},afterOpen:()=>{},beforeClose:()=>{},afterClose:()=>{},onDragStart:()=>{},onDragMove:()=>{},onDragEnd:()=>{},expandable:!0,draggable:!0,backgroundDraggable:!0,shouldCloseOnOutsideClick:!0,shouldShowBackdrop:!0,shouldShowHandle:!0,backDropTransition:null,backdropColor:null,containerBorderRadius:null,rootClass:null,containerClass:null,handleClass:null,contentWrapperClass:null,backdropClass:null,draggingAnimationTimings:"ease-in-out",draggingAnimationDuration:180};function en(t){const n={...Lt},e=Object.entries(t).reduce((i,o)=>{const[c,f]=o;return ot(f)&&(i[c]=f),i},{});return{...n,...e}}function at(t){if(ct(t)){const{p1x:n,p1y:e,p2x:r,p2y:i}=t;return R(n,e,r,i)}return Ot(t)?nn(t):At}function rn(t,n,e){function r(i,o){switch(i){case"content":v(o)&&(t.bottomSheetContentWrapper.innerHTML=o);break;case"width":v(o)&&(t.bottomSheetContainer.style.width=o);break;case"shouldShowHandle":Tt(o)||j(t.bottomSheetHandle,!1);break;case"shouldShowBackdrop":Tt(o)||j(t.bottomSheetBackdrop,!1);break;case"containerBorderRadius":v(o)&&(t.bottomSheetContainer.style.borderRadius=o);break;case"backdropColor":v(o)&&(t.bottomSheetBackdrop.style.backgroundColor=o);break;case"backDropTransition":v(o)&&(t.bottomSheetBackdrop.style.transition=o);break;case"rootClass":if(!v(o))return;W(t.bottomSheetRoot,e.rootClass,o);break;case"containerClass":if(!v(o))return;W(t.bottomSheetContainer,e.containerClass,o);break;case"handleClass":if(!v(o))return;W(t.bottomSheetHandle,e.handleClass,o);break;case"contentWrapperClass":if(!v(o))return;W(t.bottomSheetContentWrapper,e.contentWrapperClass,o);break;case"backdropClass":if(!v(o))return;W(t.bottomSheetBackdrop,e.backdropClass,o);break;case"draggingAnimationTimings":if(ct(o)){const c=at(o),f=st(c,e.draggingAnimationDuration);n.translateContainer=f}break;case"draggingAnimationDuration":if(A(o)){const c=at(e.draggingAnimationTimings),f=st(c,o);n.translateContainer=f}break}}return r}function on(t){const n=en(t),e=at(t.draggingAnimationTimings),i={isMounted:!1,translateContainer:st(e,n.draggingAnimationDuration)},o={startY:null,containerStartTranslate:{x:0,y:0},isDragging:!1,originalDocumentOverflowY:document.body.style.overflowY},c=new jt,f={animationFrame:c,onClose:y,bottomSheetState:i,draggingState:o,snapTo:ut,moveUp:tt,moveDown:_},{elements:a,eventHandlers:T}=Gt(n,f),u=qt(n,rn(a,i,n)),{bottomSheetBackdrop:p,bottomSheetRoot:w,bottomSheetContainer:s}=a,L=l=>{const d=l??window.document.body;d.appendChild(w),d.appendChild(p);const g=window.innerHeight;J(s,{y:g}),T.attachEventListeners(),i.isMounted=!0},H=()=>{T.clearEventListeners(),Object.values(a).forEach(l=>{l.remove()}),i.isMounted=!1},O=()=>{var E;if(C()||Jt('Bottom Sheet is not mounted yet. call the "mount" method first.'),(E=t.beforeOpen)==null||E.call(t),I())return;u.shouldShowBackdrop&&nt(p,!0),nt([s],!0),J(s,{y:s.clientHeight});const d=window.innerHeight,g=ft(d,s.clientHeight,u.marginTop,u.defaultPosition),h=Y(s).y;i.translateContainer({startY:h,endY:g,animationFrame:c,bottomSheetContainer:s,onEnd:t.afterOpen}),a.bottomSheetHandle.focus()};function y(){var g;if($())return;(g=t.beforeClose)==null||g.call(t);const l=Y(s).y,d=s.clientHeight;i.translateContainer({startY:l,endY:d,animationFrame:c,bottomSheetContainer:s,onEnd:()=>{var h;(h=t.afterClose)==null||h.call(t),nt([p,s],!1)}})}function C(){return i.isMounted}function I(){const l=Y(s).y,d=window.innerHeight,g=s.clientHeight>=d?d:s.clientHeight;return l<g}function $(){return!I()}function Z(){const l=Y(s).y,d=s.clientHeight,g=window.innerHeight;if(l<=5&&l>=-5)return P.CONTENT_HEIGHT;const h=d-l;if(h===g/2)return P.MIDDLE;const E=g-u.marginTop,D=10;return h<=E+D&&h>=E-D?P.TOP:P.CLOSED}function m(){return s.clientHeight}function S(l){const d=Y(s).y,h=s.clientHeight-d,E=window.innerHeight-l,D=Mt(h,E),B=z(h,E);i.translateContainer({startY:d,endY:d+(D.isUp?-B:B),animationFrame:c,bottomSheetContainer:s})}function k(l,{viewportHeight:d,visibleHeight:g}){let h=null;for(const E of l){const D=E*d,B=z(g,D);(h===null||B<h)&&(h=B)}return{minOffset:h}}function tt(){const l=[...u.snapPoints].reverse(),d=Y(s).y,g=s.clientHeight,h=g-d;if(!u.expandable&&h>=g)return;const E=window.innerHeight,D=gt("above",{visibleHeight:h,viewportHeight:E},l),{minOffset:B}=k(D,{visibleHeight:h,viewportHeight:E});if(B===null&&h<E-u.marginTop){i.translateContainer({startY:d,endY:ft(E,g,u.marginTop,"top"),animationFrame:c,bottomSheetContainer:s});return}A(B)&&i.translateContainer({startY:d,endY:d-B,animationFrame:c,bottomSheetContainer:s})}function _(){const l=Y(s).y,g=s.clientHeight-l;if(g<1)return;const h=window.innerHeight,E=gt("below",{visibleHeight:g,viewportHeight:h},u.snapPoints),{minOffset:D}=k(E,{visibleHeight:g,viewportHeight:h});A(D)&&i.translateContainer({startY:l,endY:l+D,animationFrame:c,bottomSheetContainer:s})}function ut(l){const d=window.innerHeight;if(!zt(l))return;const g=q(d*l,2);S(g)}return{props:u,elements:a,mount:L,unmount:H,open:O,close:y,getIsMounted:C,getIsOpen:I,getIsClosed:$,getPosition:Z,getHeight:m,moveTo:S,snapTo:ut}}function sn(){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=Lt;exports.BOTTOM_SHEET_POSITION=P;exports.BOTTOM_SHEET_SELECTORS=Nt;exports.COMMON_ANIMATION_KEYS=M;exports.ClassNames=b;exports.EventPhase=x;exports.ResetClassNames=K;exports.UtilClassNames=V;exports.createBottomSheet=on;exports.createPlaceholderBottomSheet=sn;exports.eventPhaseToEnum=it;exports.isAnimationTimingPoints=ct;exports.isCommonAnimationTimingsKey=Ot;
|
|
2
|
+
"use strict";var Dt=Object.defineProperty;var kt=(t,n,e)=>n in t?Dt(t,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[n]=e;var W=(t,n,e)=>kt(t,typeof n!="symbol"?n+"":n,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function O(t){return typeof t=="string"}function Bt(t,n){return t.classList.contains(tt(n))}function K(t,n){t.classList.add(tt(n))}function et(t,n){t.classList.remove(tt(n))}function G(t,n,e){O(e)&&(O(n)&&et(t,n),K(t,e))}function tt(t){return O(t)?t.trim().replace(/\./g,""):""}function R(t){return t.map(n=>tt(n)).filter(Boolean).join(" ")}function Yt(t){return t.map(n=>n==null?void 0:n.trim()).filter(Boolean).map(n=>`.${n}`).join(" ")}const lt="open",dt="hidden";function nt(t,n){const e=n;if(Array.isArray(t)){t.forEach(r=>{z(r,e),r.setAttribute("aria-modal",e?"true":"false")});return}z(t,e),t.setAttribute("aria-modal",e?"true":"false")}function z(t,n){n?(K(t,lt),et(t,dt)):(K(t,dt),et(t,lt))}function bt(t){return t instanceof HTMLElement}function S(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=S(e)?parseInt(e,10):-1,o=["INPUT","BUTTON","SELECT","TEXTAREA","A","AREA","IFRAME"].includes(t.tagName),c=t instanceof HTMLAnchorElement&&t.href!==""||t instanceof HTMLAreaElement&&t.href!=="";return o||c||r>-1}var b=(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))(b||{}),q=(t=>(t.Button="pbs-button-reset",t.Dialog="pbs-dialog-reset",t))(q||{}),$=(t=>(t.Hidden="hidden",t))($||{});function I(t,n,e){const r=document.createElement(t);return n.split(" ").forEach(o=>{K(r,o)}),O(e)&&r.setAttribute("data-testid",e),r}const Mt={CONTENTS_WRAPPER:Yt([b.Root,b.ContentWrapper])};function ft(t,n,e,r){switch(r){case"content-height":return n>=t?wt(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 J(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 gt(t,n,e){const r=t==="above";return e.filter(i=>{const o=i*n.viewportHeight;return r?n.visibleHeight<o:n.visibleHeight>o})}function wt(t,n,e){return-(t-n)+e}function ht(t){return Number(t.replace("px",""))}function Q(t,...n){return Number(t.toFixed(...n))}function Ht(t){const n=/(?<type>\w+)\((?<values>[^)]+)\)/g,e=[];let r;for(;(r=n.exec(t))!==null;){const i=r[1],o=r[2].split(",").map(c=>c.trim());e.push({type:i,values:o})}return e}function xt(t){const n=t.style.transform,e=Ht(n);return{transform:n,transformValues:e}}function vt(t,n){const e=t.find(r=>r.type.startsWith(n));return e||null}const rt="translate";function Y(t){const n=t.style.transform,e=Ht(n),r=vt(e,rt);return yt(r??{type:rt,values:[]})}function Z(t,{x:n,y:e}){const{transform:r,transformValues:i}=xt(t),o=vt(i,rt);if(o){const c=yt(o);t.style.transform=`translate(${n??c.x??0}px,${e??c.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 yt(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:ht(n)??0,y:ht(e)??0}}function ot(t){return t!=null}function mt(t,{min:n,max:e}){return ot(e)&&t>=e?e:ot(n)&&t<=n?n:t}const _t=(t,n,e)=>{n instanceof HTMLElement&&!Bt(n,b.Handle)&&e.scrollTop>=1||(t.isDragging=!0)},Ft=(t,n,e,r)=>i=>{r.startY=t.getCoordinates(i).y,r.containerStartTranslate=Y(n),e.onDragStart()},Rt=(t,n,e,r,i)=>o=>{Ut(o,t,e,r,i,n,e.marginTop)};function Ut(t,n,e,r,i,o,c){if(!r.isDragging||!S(r.startY))return;const u=n.getCoordinates(t).y,a=Et(r.startY,u),p=window.innerHeight,g=o.clientHeight,l=g-(r.containerStartTranslate.y+a);if(l>=p)return;const C=Ct(r.startY,u);if(C.isUp&&!e.expandable&&l>=g)return;i.start(()=>{Z(o,{y:r.containerStartTranslate.y+a})},0);const v=p-c,s=g-r.containerStartTranslate.y;if(C.isUp){const w=v-s,A=v-l,L=mt(1-Q(A/w,2),{min:0,max:1});e.onDragMove(C,L)}else if(C.isDown){const w=mt(Q(1-l/s,2),{min:0,max:1});e.onDragMove(C,w)}}const Wt=(t,n,e,r,i,o,c)=>u=>{if(!r.isDragging||(r.isDragging=!1,!S(r.startY)))return;e.onDragEnd();const a=r.startY,p=t.getCoordinates(u).y,g=Y(n).y,l=Ct(a,p),C=window.innerHeight,v=n.clientHeight;if(l.isUp){const s=[...e.snapPoints].sort((L,E)=>L-E),w=v+-g;if(!e.expandable&&w>=v)return;for(const L of s){const E=L*window.innerHeight;if(w<=E){const x=J(w,E);c.translateContainer({startY:g,endY:g-x,animationFrame:i,bottomSheetContainer:n});return}}const A=wt(C,v,e.marginTop);c.translateContainer({startY:g,endY:A,animationFrame:i,bottomSheetContainer:n})}else if(l.isDown){const s=[...e.snapPoints].sort((w,A)=>A-w);for(const w of s){const A=w*window.innerHeight,L=v+-g;if(L>=A){const E=J(L,A);c.translateContainer({startY:g,endY:g+E,animationFrame:i,bottomSheetContainer:n});return}}o()}};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 it(t){switch(t){case 0:return 0;case 1:return 1;case 2:return 2;case 3:return 3;default:return-1}}const Gt={eventPhase:P.All};class V{constructor(n){W(this,"currentTarget");this.currentTarget=n}addEventListeners({onStart:n,onStartOptions:e=Gt,onMove:r,onEnd:i}){this.addTouchEventListeners({onStart:n,onStartOptions:e,onMove:r,onEnd:i}),this.addMouseEventListeners({onStart:n,onStartOptions:e,onMove:r,onEnd:i})}addTouchEventListeners({onStart:n,onStartOptions:e,onMove:r,onEnd:i}){n&&this.currentTarget.addEventListener("touchstart",o=>{if(e.eventPhase===P.All){n(o);return}it(o.eventPhase)===e.eventPhase&&n(o)},{passive:!0}),r&&this.currentTarget.addEventListener("touchmove",r),i&&this.currentTarget.addEventListener("touchend",i)}addMouseEventListeners({onStart:n,onStartOptions:e,onMove:r,onEnd:i}){n&&this.currentTarget.addEventListener("mousedown",o=>{if(e.eventPhase===P.All){n(o);return}it(o.eventPhase)===e.eventPhase&&n(o)},{passive:!0}),r&&this.currentTarget.addEventListener("mousemove",r),i&&this.currentTarget.addEventListener("mouseup",o=>{i(o)})}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 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 i=window.innerHeight;e.bottomSheetContainer.style.maxHeight=`${i}px`,e.bottomSheetContentWrapper.appendChild(r);const o=jt({bottomSheetElements:e,bottomSheetProps:t,options:n});return{elements:e,eventHandlers:o}}function $t(t){const n=I("dialog",R([b.Root,q.Dialog,t.rootClass]),b.Root);n.ariaLabel=t.ariaLabel;const e=I("section",R([b.Container,t.containerClass]),b.Container);t.containerBorderRadius&&(e.style.borderRadius=t.containerBorderRadius);const r=I("div",b.GapFiller,b.GapFiller),i=I("button",R([b.Handle,q.Button,t.shouldShowHandle?null:$.Hidden,t.handleClass]),b.Handle);i.setAttribute("type","button"),i.ariaLabel="bottom sheet close button";const o=I("span",R([b.HandleBar,t.shouldShowHandle?null:$.Hidden]),b.HandleBar),c=I("article",R([b.ContentWrapper,t.contentWrapperClass]),b.ContentWrapper),u=I("div",R([b.Backdrop,t.backdropClass,$.Hidden]),b.Backdrop);return t.backdropColor&&(u.style.backgroundColor=t.backdropColor),t.backDropTransition&&(u.style.transition=t.backDropTransition),{bottomSheetRoot:n,bottomSheetBackdrop:u,bottomSheetContainer:e,bottomSheetHandle:i,bottomSheetHandleBar:o,bottomSheetContentWrapper:c,bottomSheetContainerGapFiller:r}}function Xt({bottomSheetRoot:t,bottomSheetContainer:n,bottomSheetHandle:e,bottomSheetHandleBar:r,bottomSheetContentWrapper:i,bottomSheetContainerGapFiller:o}){t.appendChild(n),e.appendChild(r),n.appendChild(e),n.appendChild(i),n.appendChild(o)}function jt({bottomSheetElements:t,bottomSheetProps:n,options:e}){const{bottomSheetRoot:r,bottomSheetContainer:i,bottomSheetHandle:o,bottomSheetContainerGapFiller:c,bottomSheetContentWrapper:u}=t,{animationFrame:a}=e,p=new V(o),g=new V(u),l=new V(c),C=n.dragTriggers.reduce((T,D)=>{const k=r.querySelectorAll(D);if(!k.length)return T;const j=Array.from(k).map(F=>F instanceof HTMLElement?new V(F):null).filter(F=>!!F);return[...T,...j]},[]),v=new V(window),s=Ft(v,i,n,e.draggingState),w=Rt(v,i,n,e.draggingState,a),A=Wt(v,i,n,e.draggingState,a,e.onClose,e.bottomSheetState);function L(T){T.target instanceof Element&&!r.contains(T.target)&&e.onClose()}function E(T){_t(e.draggingState,T.target,t.bottomSheetContentWrapper)}function x(){n.draggable&&(p.addEventListeners({onStart:E}),C.forEach(T=>{T.addEventListeners({onStart:E,onStartOptions:{eventPhase:P.Target}})})),n.draggable&&n.backgroundDraggable&&(g.addEventListeners({onStart:E,onStartOptions:{eventPhase:P.Target}}),l.addEventListeners({onStart:E})),n.draggable&&v.addEventListeners({onStart:s,onMove:w,onEnd:A}),n.draggable&&window.document.addEventListener("keyup",T=>{T.key==="Escape"&&e.onClose()}),n.shouldCloseOnOutsideClick&&window.document.addEventListener("click",L),o.addEventListener("keyup",T=>{if(T.key==="ArrowUp"){e.moveUp();return}if(T.key==="ArrowDown"){e.moveDown();return}if(T.shiftKey&&T.key==="Tab"){const D=_(t.bottomSheetContentWrapper);It(D)}})}function _(T){let D=[...Array.from(T.childNodes).reverse()];for(;D.length;){const k=D.shift();if(Nt(k))return k;k&&(D=[...D,...Array.from(k.childNodes).reverse()])}return null}function X(){p.removeEventListeners({onStart:E}),g.removeEventListeners({onStart:E}),l.removeEventListeners({onStart:E}),C.forEach(T=>{T.removeEventListeners({onStart:E})}),v.removeEventListeners({onStart:s,onMove:w,onEnd:A}),window.removeEventListener("click",L)}return{attachEventListeners:x,clearEventListeners:X}}class Kt{constructor(){W(this,"animationId");W(this,"isInProgress");W(this,"startedAt");this.animationId=null,this.isInProgress=!1,this.startedAt=null}start(n,e,r=!1){this.isInProgress=!0;const i=o=>{this.startedAt||(this.startedAt=o);const c=o-this.startedAt,a=e===0?1:Q(c/e,2),p=a>=1&&!r;n(a),p?this.stop():this.animationId=requestAnimationFrame(i)};this.animationId=requestAnimationFrame(i)}stop(){this.isInProgress=!1,this.startedAt=null,S(this.animationId)&&cancelAnimationFrame(this.animationId)}}function zt(t){const{startY:n,endY:e,bottomSheetContainer:r,animationFrame:i,onEnd:o,animationTimingFunction:c,animationDuration:u}=t,a=Et(n,e);i.stop();let p=!1;i.start(g=>{Z(r,{y:n+a*c(g)}),!p&&g>=1&&(o==null||o(),p=!0)},u)}const st=(t,n)=>e=>{zt({...e,animationTimingFunction:t,animationDuration:n})},M={TOP:"top",MIDDLE:"middle",CONTENT_HEIGHT:"content-height",CLOSED:"closed"};function qt(t){return!(!S(t)||t>1||t<0)}function Jt(t,n){const e={set(r,i,o,c){return n(i,o),Reflect.set(r,i,o,c)}};return new Proxy(t,e)}function Qt(...t){console.error(t)}const N={EASE:"ease",EASE_IN:"ease-in",EASE_OUT:"ease-out",EASE_IN_OUT:"ease-in-out",SPRING:"spring"};function Ot(t){for(const n of Object.values(N))if(n===t)return!0;return!1}function ct(t){return!!(t instanceof Object&&"p1x"in t&&"p1y"in t&&"p2x"in t&&"p2y"in t&&S(t.p1x)&&S(t.p1y)&&S(t.p2x)&&S(t.p2y))}function U(t,n,e,r){return function(a){return u(o(a))};function o(a){let p=0,g=1,l=a,C;if(a===0||a===1)return a;for(;p<g;){if(C=c(l),Math.abs(C-a)<.001)return l;a>C?p=l:g=l,l=(g+p)/2}return l}function c(a){return 3*t*a*Math.pow(1-a,2)+3*e*Math.pow(a,2)*(1-a)+Math.pow(a,3)}function u(a){return 3*n*a*Math.pow(1-a,2)+3*r*Math.pow(a,2)*(1-a)+Math.pow(a,3)}}const Zt=U(.25,.1,.25,1),tn=U(.42,0,1,1),At=U(.42,0,.58,1),pt=U(.4,.1,.6,1),nn=U(.45,1.5,.55,1);function en(t){switch(t){case N.EASE:return Zt;case N.EASE_IN:return tn;case N.EASE_OUT:return At;case N.EASE_IN_OUT:return pt;case N.SPRING:return nn;default:return pt}}function Tt(t){return typeof t=="boolean"}const Lt={ariaLabel:"Bottom sheet",content:"",defaultPosition:M.CONTENT_HEIGHT,marginTop:20,snapPoints:[],width:"92%",dragTriggers:[],beforeOpen:()=>{},afterOpen:()=>{},beforeClose:()=>{},afterClose:()=>{},onDragStart:()=>{},onDragMove:()=>{},onDragEnd:()=>{},expandable:!0,draggable:!0,backgroundDraggable:!0,shouldCloseOnOutsideClick:!0,shouldShowBackdrop:!0,shouldShowHandle:!0,backDropTransition:null,backdropColor:null,containerBorderRadius:null,rootClass:null,containerClass:null,handleClass:null,contentWrapperClass:null,backdropClass:null,draggingAnimationTimings:"ease-in-out",draggingAnimationDuration:180};function rn(t){const n={...Lt},e=Object.entries(t).reduce((i,o)=>{const[c,u]=o;return ot(u)&&(i[c]=u),i},{});return{...n,...e}}function at(t){if(ct(t)){const{p1x:n,p1y:e,p2x:r,p2y:i}=t;return U(n,e,r,i)}return Ot(t)?en(t):At}function on(t,n,e){function r(i,o){switch(i){case"content":O(o)&&(t.bottomSheetContentWrapper.innerHTML=o);break;case"width":O(o)&&(t.bottomSheetContainer.style.width=o);break;case"shouldShowHandle":Tt(o)||z(t.bottomSheetHandle,!1);break;case"shouldShowBackdrop":Tt(o)||z(t.bottomSheetBackdrop,!1);break;case"containerBorderRadius":O(o)&&(t.bottomSheetContainer.style.borderRadius=o);break;case"backdropColor":O(o)&&(t.bottomSheetBackdrop.style.backgroundColor=o);break;case"backDropTransition":O(o)&&(t.bottomSheetBackdrop.style.transition=o);break;case"rootClass":if(!O(o))return;G(t.bottomSheetRoot,e.rootClass,o);break;case"containerClass":if(!O(o))return;G(t.bottomSheetContainer,e.containerClass,o);break;case"handleClass":if(!O(o))return;G(t.bottomSheetHandle,e.handleClass,o);break;case"contentWrapperClass":if(!O(o))return;G(t.bottomSheetContentWrapper,e.contentWrapperClass,o);break;case"backdropClass":if(!O(o))return;G(t.bottomSheetBackdrop,e.backdropClass,o);break;case"draggingAnimationTimings":if(ct(o)){const c=at(o),u=st(c,e.draggingAnimationDuration);n.translateContainer=u}break;case"draggingAnimationDuration":if(S(o)){const c=at(e.draggingAnimationTimings),u=st(c,o);n.translateContainer=u}break}}return r}function sn(t){const n=rn(t),e=at(t.draggingAnimationTimings),i={isMounted:!1,translateContainer:st(e,n.draggingAnimationDuration)},o={startY:null,containerStartTranslate:{x:0,y:0},isDragging:!1,originalDocumentOverflowY:null};function c(){o.originalDocumentOverflowY&&o.originalDocumentOverflowY!=="hidden"&&(document.body.style.overflowY=o.originalDocumentOverflowY)}const u=new Kt,a={animationFrame:u,onClose:E,bottomSheetState:i,draggingState:o,snapTo:ut,moveUp:F,moveDown:St},{elements:p,eventHandlers:g}=Vt(n,a),l=Jt(n,on(p,i,n)),{bottomSheetBackdrop:C,bottomSheetRoot:v,bottomSheetContainer:s}=p,w=d=>{const f=d??window.document.body;f.appendChild(v),f.appendChild(C);const h=window.innerHeight;Z(s,{y:h}),g.attachEventListeners(),i.isMounted=!0},A=()=>{g.clearEventListeners(),Object.values(p).forEach(d=>{d.remove()}),c(),i.isMounted=!1},L=()=>{var y;if(x()||Qt('Bottom Sheet is not mounted yet. call the "mount" method first.'),(y=t.beforeOpen)==null||y.call(t),_())return;l.shouldShowBackdrop&&nt(C,!0),nt([s],!0),Z(s,{y:s.clientHeight});const f=window.innerHeight,h=ft(f,s.clientHeight,l.marginTop,l.defaultPosition),m=Y(s).y;i.translateContainer({startY:m,endY:h,animationFrame:u,bottomSheetContainer:s,onEnd:t.afterOpen}),p.bottomSheetHandle.focus();const H=document.body.style.overflowY;o.originalDocumentOverflowY=H||"initial",document.body.style.overflowY="hidden"};function E(){var h;if(X())return;(h=t.beforeClose)==null||h.call(t);const d=Y(s).y,f=s.clientHeight;i.translateContainer({startY:d,endY:f,animationFrame:u,bottomSheetContainer:s,onEnd:()=>{var m;(m=t.afterClose)==null||m.call(t),nt([C,s],!1)}}),c()}function x(){return i.isMounted}function _(){const d=Y(s).y,f=window.innerHeight,h=s.clientHeight>=f?f:s.clientHeight;return d<h}function X(){return!_()}function T(){const d=Y(s).y,f=s.clientHeight,h=window.innerHeight;if(d<=5&&d>=-5)return M.CONTENT_HEIGHT;const m=f-d;if(m===h/2)return M.MIDDLE;const H=h-l.marginTop,y=10;return m<=H+y&&m>=H-y?M.TOP:M.CLOSED}function D(){return s.clientHeight}function k(d){if(!_())return;const f=Y(s).y,m=s.clientHeight-f,H=window.innerHeight-d,y=Pt(m,H),B=J(m,H);i.translateContainer({startY:f,endY:f+(y.isUp?-B:B),animationFrame:u,bottomSheetContainer:s})}function j(d,{viewportHeight:f,visibleHeight:h}){let m=null;for(const H of d){const y=H*f,B=J(h,y);(m===null||B<m)&&(m=B)}return{minOffset:m}}function F(){const d=[...l.snapPoints].reverse(),f=Y(s).y,h=s.clientHeight,m=h-f;if(!l.expandable&&m>=h)return;const H=window.innerHeight,y=gt("above",{visibleHeight:m,viewportHeight:H},d),{minOffset:B}=j(y,{visibleHeight:m,viewportHeight:H});if(B===null&&m<H-l.marginTop){i.translateContainer({startY:f,endY:ft(H,h,l.marginTop,"top"),animationFrame:u,bottomSheetContainer:s});return}S(B)&&i.translateContainer({startY:f,endY:f-B,animationFrame:u,bottomSheetContainer:s})}function St(){const d=Y(s).y,h=s.clientHeight-d;if(h<1)return;const m=window.innerHeight,H=gt("below",{visibleHeight:h,viewportHeight:m},l.snapPoints),{minOffset:y}=j(H,{visibleHeight:h,viewportHeight:m});S(y)&&i.translateContainer({startY:d,endY:d+y,animationFrame:u,bottomSheetContainer:s})}function ut(d){const f=window.innerHeight;if(!qt(d))return;const h=Q(f*d,2);k(h)}return{props:l,elements:p,mount:w,unmount:A,open:L,close:E,getIsMounted:x,getIsOpen:_,getIsClosed:X,getPosition:T,getHeight:D,moveTo:k,snapTo:ut}}function an(){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:()=>M.CLOSED,moveTo:()=>{},snapTo:()=>{},props:{content:""}}}exports.BOTTOM_SHEET_DEFAULT_PROPS=Lt;exports.BOTTOM_SHEET_POSITION=M;exports.BOTTOM_SHEET_SELECTORS=Mt;exports.COMMON_ANIMATION_KEYS=N;exports.ClassNames=b;exports.EventPhase=P;exports.ResetClassNames=q;exports.UtilClassNames=$;exports.createBottomSheet=sn;exports.createPlaceholderBottomSheet=an;exports.eventPhaseToEnum=it;exports.isAnimationTimingPoints=ct;exports.isCommonAnimationTimingsKey=Ot;
|