@plainsheet/core 0.5.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/LICENSE +22 -0
- package/README.md +70 -0
- package/dist/animation/animation.d.ts +20 -0
- package/dist/animation/animation.d.ts.map +1 -0
- package/dist/animation/animation.type.d.ts +6 -0
- package/dist/animation/animation.type.d.ts.map +1 -0
- package/dist/bottom-sheet.d.ts +5 -0
- package/dist/bottom-sheet.d.ts.map +1 -0
- package/dist/calculator/index.d.ts +2 -0
- package/dist/calculator/index.d.ts.map +1 -0
- package/dist/calculator/position-calculator.d.ts +24 -0
- package/dist/calculator/position-calculator.d.ts.map +1 -0
- package/dist/calculator/position-calculator.type.d.ts +6 -0
- package/dist/calculator/position-calculator.type.d.ts.map +1 -0
- package/dist/class-names/class-names.d.ts +43 -0
- package/dist/class-names/class-names.d.ts.map +1 -0
- package/dist/class-names/index.d.ts +3 -0
- package/dist/class-names/index.d.ts.map +1 -0
- package/dist/class-names/selectors.d.ts +4 -0
- package/dist/class-names/selectors.d.ts.map +1 -0
- package/dist/event-handlers/dragging-handler.d.ts +10 -0
- package/dist/event-handlers/dragging-handler.d.ts.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/initializer/bottom-sheet-defaults.d.ts +5 -0
- package/dist/initializer/bottom-sheet-defaults.d.ts.map +1 -0
- package/dist/initializer/bottom-sheet-initializer.d.ts +37 -0
- package/dist/initializer/bottom-sheet-initializer.d.ts.map +1 -0
- package/dist/initializer/bottom-sheet-placeholder.d.ts +7 -0
- package/dist/initializer/bottom-sheet-placeholder.d.ts.map +1 -0
- package/dist/initializer/bottom-sheet-props-initializer.d.ts +9 -0
- package/dist/initializer/bottom-sheet-props-initializer.d.ts.map +1 -0
- package/dist/initializer/index.d.ts +3 -0
- package/dist/initializer/index.d.ts.map +1 -0
- package/dist/plainsheet-core.cjs.js +2 -0
- package/dist/plainsheet-core.es.js +1176 -0
- package/dist/plainsheet-core.umd.js +3 -0
- package/dist/types/bottom-sheet-props.type.d.ts +84 -0
- package/dist/types/bottom-sheet-props.type.d.ts.map +1 -0
- package/dist/types/bottom-sheet-state.type.d.ts +16 -0
- package/dist/types/bottom-sheet-state.type.d.ts.map +1 -0
- package/dist/types/bottom-sheet.type.d.ts +61 -0
- package/dist/types/bottom-sheet.type.d.ts.map +1 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/utils/animation/animation-frame.d.ts +18 -0
- package/dist/utils/animation/animation-frame.d.ts.map +1 -0
- package/dist/utils/animation/animation.type.d.ts +23 -0
- package/dist/utils/animation/animation.type.d.ts.map +1 -0
- package/dist/utils/animation/common-animations.d.ts +9 -0
- package/dist/utils/animation/common-animations.d.ts.map +1 -0
- package/dist/utils/animation/cubic-bezier.d.ts +5 -0
- package/dist/utils/animation/cubic-bezier.d.ts.map +1 -0
- package/dist/utils/animation/index.d.ts +2 -0
- package/dist/utils/animation/index.d.ts.map +1 -0
- package/dist/utils/animation/linear.d.ts +2 -0
- package/dist/utils/animation/linear.d.ts.map +1 -0
- package/dist/utils/dom/class-names.d.ts +9 -0
- package/dist/utils/dom/class-names.d.ts.map +1 -0
- package/dist/utils/dom/element.d.ts +2 -0
- package/dist/utils/dom/element.d.ts.map +1 -0
- package/dist/utils/dom/focus.d.ts +3 -0
- package/dist/utils/dom/focus.d.ts.map +1 -0
- package/dist/utils/dom/transform.d.ts +11 -0
- package/dist/utils/dom/transform.d.ts.map +1 -0
- package/dist/utils/dom/translate.d.ts +7 -0
- package/dist/utils/dom/translate.d.ts.map +1 -0
- package/dist/utils/dom/visibility.d.ts +3 -0
- package/dist/utils/dom/visibility.d.ts.map +1 -0
- package/dist/utils/event-listeners/EventPhase.d.ts +9 -0
- package/dist/utils/event-listeners/EventPhase.d.ts.map +1 -0
- package/dist/utils/event-listeners/TabEventListener.d.ts +32 -0
- package/dist/utils/event-listeners/TabEventListener.d.ts.map +1 -0
- package/dist/utils/event-listeners/index.d.ts +2 -0
- package/dist/utils/event-listeners/index.d.ts.map +1 -0
- package/dist/utils/index.d.ts +3 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/log/log.d.ts +6 -0
- package/dist/utils/log/log.d.ts.map +1 -0
- package/dist/utils/math/min-max.d.ts +5 -0
- package/dist/utils/math/min-max.d.ts.map +1 -0
- package/dist/utils/math/unit.d.ts +3 -0
- package/dist/utils/math/unit.d.ts.map +1 -0
- package/dist/utils/proxy/observe.d.ts +3 -0
- package/dist/utils/proxy/observe.d.ts.map +1 -0
- package/dist/utils/types/css-attribute.d.ts +12 -0
- package/dist/utils/types/css-attribute.d.ts.map +1 -0
- package/dist/utils/types/exists.d.ts +2 -0
- package/dist/utils/types/exists.d.ts.map +1 -0
- package/dist/utils/types/is-boolean.d.ts +2 -0
- package/dist/utils/types/is-boolean.d.ts.map +1 -0
- package/dist/utils/types/is-element.d.ts +3 -0
- package/dist/utils/types/is-element.d.ts.map +1 -0
- package/dist/utils/types/is-number.d.ts +2 -0
- package/dist/utils/types/is-number.d.ts.map +1 -0
- package/dist/utils/types/is-percent.d.ts +2 -0
- package/dist/utils/types/is-percent.d.ts.map +1 -0
- package/dist/utils/types/is-string.d.ts +2 -0
- package/dist/utils/types/is-string.d.ts.map +1 -0
- package/package.json +56 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Dong Hyeok Byun
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
Footer
|
package/README.md
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="https://plain-bottom-sheet-pbs-docs.vercel.app/">
|
|
3
|
+
<img src="./documents/assets/header.png" width="328" height="167">
|
|
4
|
+
</a>
|
|
5
|
+
</p>
|
|
6
|
+
|
|
7
|
+
<a href="https://bundlejs.com/?q=core@latest" target="\_parent">
|
|
8
|
+
<img alt="" src="https://deno.bundlejs.com/badge?q=core@latest&badge=detailed" />
|
|
9
|
+
</a>
|
|
10
|
+
|
|
11
|
+
<a href="https://bundlejs.com/?q=@plainsheet/react@latest" target="\_parent">
|
|
12
|
+
<img alt="" src="https://deno.bundlejs.com/badge?q=@plainsheet/react@latest" />
|
|
13
|
+
</a>
|
|
14
|
+
|
|
15
|
+
<a href="https://codecov.io/gh/PeterByun/plain-bottom-sheet" >
|
|
16
|
+
<img src="https://codecov.io/gh/PeterByun/plain-bottom-sheet/graph/badge.svg?token=WFHGUAI3GC"/>
|
|
17
|
+
</a>
|
|
18
|
+
|
|
19
|
+
The **minimalistic**, **configurable** bottom sheet for any web project.
|
|
20
|
+
|
|
21
|
+
### [Check out our website](https://plain-bottom-sheet-pbs-docs.vercel.app/), for a quick start guide, APIs, examples, and more!
|
|
22
|
+
|
|
23
|
+
## Why?
|
|
24
|
+
|
|
25
|
+
### 🧩 Framework-agnostic
|
|
26
|
+
|
|
27
|
+
Works with vanilla JavaScript🍦, or React ⚛️.
|
|
28
|
+
|
|
29
|
+
### ⛓️💥 Zero Dependencies
|
|
30
|
+
|
|
31
|
+
So your app does not depend on any other libraries that you don't need.
|
|
32
|
+
|
|
33
|
+
### ☁️ Super Lightweight(Only 7 kB, compressed)
|
|
34
|
+
|
|
35
|
+
So you don't have to compromise loading speed.
|
|
36
|
+
|
|
37
|
+
### 📱 Mobile-friendly
|
|
38
|
+
|
|
39
|
+
Works just like the native bottom sheet.
|
|
40
|
+
|
|
41
|
+
### 🎛 Highly Configurable
|
|
42
|
+
|
|
43
|
+
- Style it anyway you want, using CSS.
|
|
44
|
+
- Change its behaviors, on the fly.
|
|
45
|
+
- Hook into life-cycle events, and states.
|
|
46
|
+
|
|
47
|
+
### 🦮 Accessibility Support
|
|
48
|
+
|
|
49
|
+
Keyboard interactions and focus management works out-of-box.
|
|
50
|
+
|
|
51
|
+
### 🍰 Works Out of The Box
|
|
52
|
+
|
|
53
|
+
Without any configs.
|
|
54
|
+
|
|
55
|
+
### 🦾 Fully-typed
|
|
56
|
+
|
|
57
|
+
### ⚡️ Performant By Default
|
|
58
|
+
|
|
59
|
+
## Philosophy
|
|
60
|
+
|
|
61
|
+
As the name suggests, we strive to make the plain bottom sheet minimalistic yet feature-rich and highly configurable.
|
|
62
|
+
We try our best to write concise, well-tested, and maintainable code to achieve this goal.
|
|
63
|
+
|
|
64
|
+
## Support the project 🤍
|
|
65
|
+
|
|
66
|
+
We very much appreciate all your support.
|
|
67
|
+
|
|
68
|
+
- If you find it useful or interesting, please [star the repository](https://github.com/plainsheet/plainsheet/stargazers),
|
|
69
|
+
- [Share this repository](https://github.com/plainsheet/plainsheet?tab=readme-ov-file) with others, if you would like to.
|
|
70
|
+
- If you find any issues, feel free to [open an issue](https://github.com/plainsheet/plainsheet/issues). We appreciate every opinion.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { AnimationFrame } from '../utils/animation/animation-frame';
|
|
2
|
+
import { AnimationTimingFunction } from '../utils/animation/animation.type';
|
|
3
|
+
|
|
4
|
+
export interface TranslateContainerParams {
|
|
5
|
+
startY: number;
|
|
6
|
+
endY: number;
|
|
7
|
+
animationFrame: AnimationFrame;
|
|
8
|
+
bottomSheetContainer: HTMLElement;
|
|
9
|
+
onEnd?: () => void;
|
|
10
|
+
animationTimingFunction: AnimationTimingFunction;
|
|
11
|
+
/**
|
|
12
|
+
* In Milliseconds.
|
|
13
|
+
*/
|
|
14
|
+
animationDuration: number;
|
|
15
|
+
}
|
|
16
|
+
export type TranslateContainerParamsExceptAnimation = Omit<TranslateContainerParams, "animationTimingFunction" | "animationDuration">;
|
|
17
|
+
export type TranslateContainer = ReturnType<typeof translateContainerWithAnim>;
|
|
18
|
+
export declare function translateContainer(params: TranslateContainerParams): void;
|
|
19
|
+
export declare const translateContainerWithAnim: (animTimingFunction: AnimationTimingFunction, animDuration: number) => (params: TranslateContainerParamsExceptAnimation) => void;
|
|
20
|
+
//# sourceMappingURL=animation.d.ts.map
|
|
@@ -0,0 +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,uBAChB,uBAAuB,gBAAgB,MAAM,cACzD,uCAAuC,SAM/C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"animation.type.d.ts","sourceRoot":"","sources":["../../src/animation/animation.type.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC;AAE9B,MAAM,WAAW,WAAW;IAC1B,CAAC,EAAE,QAAQ,CAAC;IACZ,CAAC,EAAE,QAAQ,CAAC;CACb"}
|
|
@@ -0,0 +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,gBAAgB,EAEjB,MAAM,iCAAiC,CAAC;AAEzC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAY7D,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,gBAAgB,GAAG,WAAW,CAiWtE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/calculator/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { DraggingDirection } from './position-calculator.type';
|
|
2
|
+
import { BottomSheetPosition, SnapPoints } from '../types/bottom-sheet-props.type';
|
|
3
|
+
|
|
4
|
+
/** It expects the bottom sheet to be open. */
|
|
5
|
+
export declare function convertDefaultPositionToYCoordinate(viewportHeight: number, containerHeight: number, marginTop: number, position: BottomSheetPosition): number;
|
|
6
|
+
export declare function calcDraggingDirection(startY: number, endY: number): DraggingDirection;
|
|
7
|
+
/**
|
|
8
|
+
* @param startY- Point Y where the dragging started.
|
|
9
|
+
* @param endY- Point Y where the dragging ended.
|
|
10
|
+
* @returns ±number, which is the distance between startY and endY .
|
|
11
|
+
*/
|
|
12
|
+
export declare function calcOffset(startY: number, endY: number): number;
|
|
13
|
+
export declare function calcDiffOfHeight(leftHeight: number, rightHeight: number): number;
|
|
14
|
+
export declare function calcDirectionWithHeight(leftHeight: number, rightHeight: number): {
|
|
15
|
+
isUp: boolean;
|
|
16
|
+
isDown: boolean;
|
|
17
|
+
stayedSame: boolean;
|
|
18
|
+
};
|
|
19
|
+
export declare function extractPoints(where: "above" | "below", container: {
|
|
20
|
+
viewportHeight: number;
|
|
21
|
+
visibleHeight: number;
|
|
22
|
+
}, points: SnapPoints): SnapPoints;
|
|
23
|
+
export declare function calcTopPointYLimit(viewportHeight: number, containerHeight: number, marginTop: number): number;
|
|
24
|
+
//# sourceMappingURL=position-calculator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"position-calculator.d.ts","sourceRoot":"","sources":["../../src/calculator/position-calculator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mBAAmB,EACnB,UAAU,EACX,MAAM,kCAAkC,CAAC;AAC1C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAEpE,8CAA8C;AAC9C,wBAAgB,mCAAmC,CACjD,cAAc,EAAE,MAAM,EACtB,eAAe,EAAE,MAAM,EACvB,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,mBAAmB,GAC5B,MAAM,CAeR;AAED,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,GACX,iBAAiB,CAUnB;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAK/D;AAED,wBAAgB,gBAAgB,CAC9B,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,MAAM,GAClB,MAAM,CAQR;AAED,wBAAgB,uBAAuB,CACrC,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,MAAM,GAClB;IACD,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,EAAE,OAAO,CAAC;IAChB,UAAU,EAAE,OAAO,CAAC;CACrB,CAUA;AAED,wBAAgB,aAAa,CAC3B,KAAK,EAAE,OAAO,GAAG,OAAO,EACxB,SAAS,EAAE;IACT,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,MAAM,CAAC;CACvB,EACD,MAAM,EAAE,UAAU,GACjB,UAAU,CASZ;AAED,wBAAgB,kBAAkB,CAChC,cAAc,EAAE,MAAM,EACtB,eAAe,EAAE,MAAM,EACvB,SAAS,EAAE,MAAM,GAChB,MAAM,CAER"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"position-calculator.type.d.ts","sourceRoot":"","sources":["../../src/calculator/position-calculator.type.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,EAAE,OAAO,CAAC;IAChB,UAAU,EAAE,OAAO,CAAC;CACrB"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export declare enum ClassNames {
|
|
2
|
+
/**
|
|
3
|
+
* The dark background that appears when the bottom sheet is open.
|
|
4
|
+
*/
|
|
5
|
+
Backdrop = "pbs-backdrop",
|
|
6
|
+
/**
|
|
7
|
+
* The root element that is beside the backdrop.
|
|
8
|
+
*/
|
|
9
|
+
Root = "pbs-root",
|
|
10
|
+
/**
|
|
11
|
+
* The actual bottom sheet element.
|
|
12
|
+
* It holds the handle and content, and moves up and down.
|
|
13
|
+
*/
|
|
14
|
+
Container = "pbs-container",
|
|
15
|
+
/**
|
|
16
|
+
* Fills the gap between the bottom of the sheet and the bottom of the viewport,
|
|
17
|
+
* when the sheet is animated to show a bouncing effect.
|
|
18
|
+
*/
|
|
19
|
+
GapFiller = "pbs-gap-filler",
|
|
20
|
+
/**
|
|
21
|
+
* The handle to drag the bottom sheet.
|
|
22
|
+
* It wraps the handle bar and provide a touch area.
|
|
23
|
+
*/
|
|
24
|
+
Handle = "pbs-handle",
|
|
25
|
+
/**
|
|
26
|
+
* The handle bar to move the bottom sheet
|
|
27
|
+
* using arrow keys.
|
|
28
|
+
*/
|
|
29
|
+
HandleBar = "pbs-handle-bar",
|
|
30
|
+
/**
|
|
31
|
+
* The wrapper that holds the user-provided content.
|
|
32
|
+
* It is used to measure the content and provide a stable layout.
|
|
33
|
+
*/
|
|
34
|
+
ContentWrapper = "pbs-content-wrapper"
|
|
35
|
+
}
|
|
36
|
+
export declare enum ResetClassNames {
|
|
37
|
+
Button = "pbs-button-reset",
|
|
38
|
+
Dialog = "pbs-dialog-reset"
|
|
39
|
+
}
|
|
40
|
+
export declare enum UtilClassNames {
|
|
41
|
+
Hidden = "hidden"
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=class-names.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"class-names.d.ts","sourceRoot":"","sources":["../../src/class-names/class-names.ts"],"names":[],"mappings":"AAAA,oBAAY,UAAU;IACpB;;OAEG;IACH,QAAQ,iBAAiB;IAEzB;;OAEG;IACH,IAAI,aAAa;IACjB;;;OAGG;IACH,SAAS,kBAAkB;IAC3B;;;OAGG;IACH,SAAS,mBAAmB;IAE5B;;;OAGG;IACH,MAAM,eAAe;IACrB;;;OAGG;IACH,SAAS,mBAAmB;IAE5B;;;OAGG;IACH,cAAc,wBAAwB;CACvC;AAED,oBAAY,eAAe;IACzB,MAAM,qBAAqB;IAC3B,MAAM,qBAAqB;CAC5B;AAED,oBAAY,cAAc;IACxB,MAAM,WAAW;CAClB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/class-names/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"selectors.d.ts","sourceRoot":"","sources":["../../src/class-names/selectors.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,sBAAsB;;CAKlC,CAAC"}
|
|
@@ -0,0 +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
|
+
import { BottomSheetState, DraggingState } from '../types';
|
|
5
|
+
|
|
6
|
+
export declare const handleDragTriggerClick: (draggingState: DraggingState, eventTrigger: EventTarget | null, contentWrapper: HTMLElement) => void;
|
|
7
|
+
export declare const handleDragStart: (mouseEventListener: TabEventListener, bottomSheetContainer: HTMLElement, bottomSheetProps: Required<BottomSheetProps>, draggingState: DraggingState) => (event: TabEvent) => void;
|
|
8
|
+
export declare const handleDragMove: (mouseEventListener: TabEventListener, bottomSheetContainer: HTMLElement, bottomSheetProps: Required<BottomSheetProps>, draggingState: DraggingState, animationFrame: AnimationFrame) => (event: TabEvent) => void;
|
|
9
|
+
export declare const handleDragEnd: (eventListener: TabEventListener, bottomSheetContainer: HTMLElement, bottomSheetProps: Required<BottomSheetProps>, draggingState: DraggingState, animationFrame: AnimationFrame, onClose: () => void, bottomSheetState: BottomSheetState) => (event: TabEvent) => void;
|
|
10
|
+
//# sourceMappingURL=dragging-handler.d.ts.map
|
|
@@ -0,0 +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,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAIzE,eAAO,MAAM,sBAAsB,kBAClB,aAAa,gBACd,WAAW,GAAG,IAAI,kBAChB,WAAW,KAC1B,IAYF,CAAC;AAEF,eAAO,MAAM,eAAe,uBAEJ,gBAAgB,wBACd,WAAW,oBACf,SAAS,gBAAgB,CAAC,iBAC7B,aAAa,aAEtB,QAAQ,SAQf,CAAC;AAEJ,eAAO,MAAM,cAAc,uBAEH,gBAAgB,wBACd,WAAW,oBACf,SAAS,gBAAgB,CAAC,iBAC7B,aAAa,kBACZ,cAAc,aAExB,QAAQ,SAUf,CAAC;AA+EJ,eAAO,MAAM,aAAa,kBAEP,gBAAgB,wBACT,WAAW,oBACf,SAAS,gBAAgB,CAAC,iBAC7B,aAAa,kBACZ,cAAc,WACrB,MAAM,IAAI,oBACD,gBAAgB,aAE5B,QAAQ,SAsGf,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from './bottom-sheet';
|
|
2
|
+
export * from './types';
|
|
3
|
+
export * from './initializer';
|
|
4
|
+
export * from './class-names/class-names';
|
|
5
|
+
export * from './class-names/selectors';
|
|
6
|
+
export * from './calculator';
|
|
7
|
+
export * from './class-names';
|
|
8
|
+
export * from './utils';
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,SAAS,CAAC;AAExB,cAAc,eAAe,CAAC;AAE9B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yBAAyB,CAAC;AAExC,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAE9B,cAAc,SAAS,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { RequiredBottomSheetProps } from '../types/bottom-sheet-props.type';
|
|
2
|
+
|
|
3
|
+
export type BottomSheetDefaultPropKeys = keyof RequiredBottomSheetProps;
|
|
4
|
+
export declare const BOTTOM_SHEET_DEFAULT_PROPS: RequiredBottomSheetProps;
|
|
5
|
+
//# sourceMappingURL=bottom-sheet-defaults.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bottom-sheet-defaults.d.ts","sourceRoot":"","sources":["../../src/initializer/bottom-sheet-defaults.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAGjF,MAAM,MAAM,0BAA0B,GAAG,MAAM,wBAAwB,CAAC;AAExE,eAAO,MAAM,0BAA0B,EAAE,wBA+BxC,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { BottomSheetProps } from '../types/bottom-sheet-props.type';
|
|
2
|
+
import { AnimationFrame } from '../utils/animation/animation-frame';
|
|
3
|
+
import { BottomSheetState, DraggingState } from '../types';
|
|
4
|
+
|
|
5
|
+
export interface InitializerOptions {
|
|
6
|
+
animationFrame: AnimationFrame;
|
|
7
|
+
bottomSheetState: BottomSheetState;
|
|
8
|
+
onClose: () => void;
|
|
9
|
+
draggingState: DraggingState;
|
|
10
|
+
moveUp: () => void;
|
|
11
|
+
moveDown: () => void;
|
|
12
|
+
}
|
|
13
|
+
interface InitializeBottomSheetElementsReturnType {
|
|
14
|
+
elements: BottomSheetElements;
|
|
15
|
+
eventHandlers: InitializeEventsReturnType;
|
|
16
|
+
}
|
|
17
|
+
export declare function initializeBottomSheetElements(props: Required<BottomSheetProps>, options: InitializerOptions): InitializeBottomSheetElementsReturnType;
|
|
18
|
+
export interface BottomSheetElements {
|
|
19
|
+
bottomSheetRoot: HTMLElement;
|
|
20
|
+
bottomSheetBackdrop: HTMLElement;
|
|
21
|
+
bottomSheetContainer: HTMLElement;
|
|
22
|
+
bottomSheetHandle: HTMLElement;
|
|
23
|
+
bottomSheetHandleBar: HTMLElement;
|
|
24
|
+
bottomSheetContentWrapper: HTMLElement;
|
|
25
|
+
bottomSheetContainerGapFiller: HTMLElement;
|
|
26
|
+
}
|
|
27
|
+
export interface InitializeEventsParams {
|
|
28
|
+
bottomSheetElements: BottomSheetElements;
|
|
29
|
+
bottomSheetProps: Required<BottomSheetProps>;
|
|
30
|
+
options: InitializerOptions;
|
|
31
|
+
}
|
|
32
|
+
interface InitializeEventsReturnType {
|
|
33
|
+
attachEventListeners: () => void;
|
|
34
|
+
clearEventListeners: () => void;
|
|
35
|
+
}
|
|
36
|
+
export {};
|
|
37
|
+
//# sourceMappingURL=bottom-sheet-initializer.d.ts.map
|
|
@@ -0,0 +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,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAEzE,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,gBAAgB,CAAC,EACjC,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,gBAAgB,CAAC,CAAC;IAC7C,OAAO,EAAE,kBAAkB,CAAC;CAC7B;AAED,UAAU,0BAA0B;IAClC,oBAAoB,EAAE,MAAM,IAAI,CAAC;IACjC,mBAAmB,EAAE,MAAM,IAAI,CAAC;CACjC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { BottomSheet } from '../types/bottom-sheet.type';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @returns A fallback BottomSheet instance to provide non-null BottomSheet methods to library users.
|
|
5
|
+
*/
|
|
6
|
+
export declare function createPlaceholderBottomSheet(): BottomSheet;
|
|
7
|
+
//# sourceMappingURL=bottom-sheet-placeholder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bottom-sheet-placeholder.d.ts","sourceRoot":"","sources":["../../src/initializer/bottom-sheet-placeholder.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAE9D;;GAEG;AACH,wBAAgB,4BAA4B,IAAI,WAAW,CAoC1D"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { BottomSheetElements } from './bottom-sheet-initializer';
|
|
2
|
+
import { ObserverSetHandler } from '../utils/proxy/observe';
|
|
3
|
+
import { AnimationTimingFunction } from '../utils';
|
|
4
|
+
import { BottomSheetProps, BottomSheetState, RequiredBottomSheetProps } from '../types';
|
|
5
|
+
|
|
6
|
+
export declare function overwriteDefaultProps(props: BottomSheetProps): RequiredBottomSheetProps;
|
|
7
|
+
export declare function interpretAnimationTimingsProp(draggingAnimationTimings: BottomSheetProps["draggingAnimationTimings"]): AnimationTimingFunction;
|
|
8
|
+
export declare function createPropSetHandler(elements: BottomSheetElements, bottomSheetState: BottomSheetState, propsWithDefaults: Required<BottomSheetProps>): ObserverSetHandler;
|
|
9
|
+
//# sourceMappingURL=bottom-sheet-props-initializer.d.ts.map
|
|
@@ -0,0 +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,gBAAgB,EAChB,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,gBAAgB,GACtB,wBAAwB,CAuB1B;AAED,wBAAgB,6BAA6B,CAC3C,wBAAwB,EAAE,gBAAgB,CAAC,0BAA0B,CAAC,GACrE,uBAAuB,CAWzB;AAED,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,mBAAmB,EAC7B,gBAAgB,EAAE,gBAAgB,EAClC,iBAAiB,EAAE,QAAQ,CAAC,gBAAgB,CAAC,GAC5C,kBAAkB,CAuHpB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/initializer/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,yBAAyB,CAAC;AACrE,cAAc,4BAA4B,CAAC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
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;
|