@douxcode/vue-spring-bottom-sheet 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.txt +21 -0
- package/README.md +122 -0
- package/dist/BottomSheet.d.ts +55 -0
- package/dist/composables/useSnapPoints.d.ts +7 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.mjs +1116 -0
- package/dist/style.css +1 -0
- package/package.json +82 -0
package/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 megaarmos
|
|
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.
|
package/README.md
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
# Vue Spring Bottom Sheet
|
|
2
|
+
|
|
3
|
+
**vue-spring-bottom-sheet** is built on top of **[@vueuse/gesture]** and **[@vueuse/motion]**.
|
|
4
|
+
|
|
5
|
+
😎 **Modern** and 🚀 **Performant** Bottom Sheet for Vue.js
|
|
6
|
+
|
|
7
|
+
# Installation
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
npm install @douxcode/vue-bottom-sheet
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
# Getting started
|
|
14
|
+
|
|
15
|
+
## Basic usage
|
|
16
|
+
|
|
17
|
+
```vue
|
|
18
|
+
<script setup>
|
|
19
|
+
import BottomSheet from '@douxcode/vue-bottom-sheet'
|
|
20
|
+
import '@douxcode/vue-bottom-sheet/dist/style.css'
|
|
21
|
+
import { ref } from 'vue'
|
|
22
|
+
|
|
23
|
+
const bottomSheet = ref(null)
|
|
24
|
+
|
|
25
|
+
const open = () => {
|
|
26
|
+
bottomSheet.value.open()
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const close = () => {
|
|
30
|
+
bottomSheet.value.close()
|
|
31
|
+
}
|
|
32
|
+
</script>
|
|
33
|
+
|
|
34
|
+
<template>
|
|
35
|
+
<BottomSheet ref="bottomSheet"> Your awesome content </BottomSheet>
|
|
36
|
+
</template>
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Basic usage `setup` + TS
|
|
40
|
+
|
|
41
|
+
```vue
|
|
42
|
+
<script setup lang="ts">
|
|
43
|
+
import BottomSheet from '@douxcode/vue-bottom-sheet'
|
|
44
|
+
import '@douxcode/vue-bottom-sheet/dist/style.css'
|
|
45
|
+
import { ref } from 'vue'
|
|
46
|
+
|
|
47
|
+
const bottomSheet = ref<InstanceType<typeof BottomSheet>>()
|
|
48
|
+
|
|
49
|
+
const open = () => {
|
|
50
|
+
bottomSheet.value.open()
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const close = () => {
|
|
54
|
+
bottomSheet.value.close()
|
|
55
|
+
}
|
|
56
|
+
</script>
|
|
57
|
+
|
|
58
|
+
<template>
|
|
59
|
+
<BottomSheet ref="bottomSheet"> Your content </BottomSheet>
|
|
60
|
+
</template>
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Usage in Nuxt 3
|
|
64
|
+
|
|
65
|
+
For Nuxt 3, just wrap component in `<client-only>`
|
|
66
|
+
|
|
67
|
+
```vue
|
|
68
|
+
<template>
|
|
69
|
+
<ClientOnly>
|
|
70
|
+
<template>
|
|
71
|
+
<BottomSheet ref="bottomSheet"> Your awesome content </BottomSheet>
|
|
72
|
+
</template>
|
|
73
|
+
</ClientOnly>
|
|
74
|
+
</template>
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## CSS Custom Properties
|
|
78
|
+
|
|
79
|
+
```css
|
|
80
|
+
:root {
|
|
81
|
+
--rsbs-backdrop-bg: rgba(0, 0, 0, 0.6);
|
|
82
|
+
--rsbs-bg: #fff;
|
|
83
|
+
--rsbs-handle-bg: hsla(0, 0%, 0%, 0.14);
|
|
84
|
+
--rsbs-max-w: auto;
|
|
85
|
+
--rsbs-ml: env(safe-area-inset-left);
|
|
86
|
+
--rsbs-mr: env(safe-area-inset-right);
|
|
87
|
+
--rsbs-overlay-rounded: 16px;
|
|
88
|
+
}
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## Props
|
|
92
|
+
|
|
93
|
+
| Prop | Type | Description | Example | Defaults |
|
|
94
|
+
| ------------------- | -------- | -------------------------------------------------------------------------------- | -------------------------------- | --------- |
|
|
95
|
+
| snapPoints | Number[] | Define custom snapping positions for the bottom sheet | `:snapPoints="[300, 600, 900]"` | true |
|
|
96
|
+
| defaultSnapPoint | Number | Specify the default breakpoint | `:default-snap-point="600"` | true |
|
|
97
|
+
| blocking | Boolean | Control whether the bottom sheet blocks interactions with the underlying content | `:blocking="true"` | true |
|
|
98
|
+
| canSwipeClose | Boolean | Enable or disable swiping gestures to close the sheet | `:can-swipe-close="true"` | true |
|
|
99
|
+
| canOverlayClose | Boolean | Allow tapping on overlay to close it | `:can-overlay-close="true"` | true |
|
|
100
|
+
| expandOnContentDrag | Boolean | Enable expanding the sheet by dragging its content | `:expand-on-content-drag="true"` | #0000004D |
|
|
101
|
+
|
|
102
|
+
## Exposed methods
|
|
103
|
+
|
|
104
|
+
Assuming there is `const bottomSheet = ref()`
|
|
105
|
+
|
|
106
|
+
| Method | Description | Example |
|
|
107
|
+
| ----------- | -------------------------------------------------- | ------------------------------------ |
|
|
108
|
+
| snapToPoint | Exposed method for snapping component to the point | `bottomSheet.value.snapToPoint(300)` |
|
|
109
|
+
| open | Exposed method for opening component | `bottomSheet.value.open()` |
|
|
110
|
+
| close | Exposed method for closing component | `bottomSheet.value.close()` |
|
|
111
|
+
|
|
112
|
+
## Events
|
|
113
|
+
|
|
114
|
+
| Event | Description | Example |
|
|
115
|
+
| ---------- | ------------------------------------------------------------------------ | ------------------------- |
|
|
116
|
+
| min-height | Fires when min-height of sheet has changed and passes it as an argument | `@min-height="(n) => {}"` |
|
|
117
|
+
| max-height | Fires when max-height of window has changed and passes it as an argument | `@max-height="(n) => {}"` |
|
|
118
|
+
| opened | Fire when component is opened | `@opened="() => {}"` |
|
|
119
|
+
| closed | Fire when component is closed | `@closed="() => {}"` |
|
|
120
|
+
|
|
121
|
+
[@vueuse/gesture]: https://gesture.vueuse.org/
|
|
122
|
+
[@vueuse/motion]: https://motion.vueuse.org/
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
interface IProps {
|
|
2
|
+
snapPoints?: number[];
|
|
3
|
+
defaultBreakpoint?: number;
|
|
4
|
+
blocking?: boolean;
|
|
5
|
+
canSwipeClose?: boolean;
|
|
6
|
+
canBackdropClose?: boolean;
|
|
7
|
+
expandOnContentDrag?: boolean;
|
|
8
|
+
}
|
|
9
|
+
declare function __VLS_template(): {
|
|
10
|
+
slots: {
|
|
11
|
+
header?(_: {}): any;
|
|
12
|
+
default?(_: {}): any;
|
|
13
|
+
footer?(_: {}): any;
|
|
14
|
+
};
|
|
15
|
+
refs: {
|
|
16
|
+
backdrop: HTMLDivElement;
|
|
17
|
+
sheet: HTMLDivElement;
|
|
18
|
+
sheetHeader: HTMLDivElement;
|
|
19
|
+
sheetScroll: HTMLDivElement;
|
|
20
|
+
sheetContentWrapper: HTMLDivElement;
|
|
21
|
+
sheetContent: HTMLDivElement;
|
|
22
|
+
sheetFooter: HTMLDivElement;
|
|
23
|
+
};
|
|
24
|
+
attrs: Partial<{}>;
|
|
25
|
+
};
|
|
26
|
+
type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
|
|
27
|
+
declare const __VLS_component: import('vue').DefineComponent<IProps, {
|
|
28
|
+
open: () => void;
|
|
29
|
+
close: () => void;
|
|
30
|
+
snapToPoint: (snapPoint: number) => void;
|
|
31
|
+
}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
|
|
32
|
+
opened: () => any;
|
|
33
|
+
closed: () => any;
|
|
34
|
+
ready: () => any;
|
|
35
|
+
minHeight: (minSheetHeight: number) => any;
|
|
36
|
+
maxHeight: (maxSheetHeight: number) => any;
|
|
37
|
+
}, string, import('vue').PublicProps, Readonly<IProps> & Readonly<{
|
|
38
|
+
onOpened?: (() => any) | undefined;
|
|
39
|
+
onClosed?: (() => any) | undefined;
|
|
40
|
+
onReady?: (() => any) | undefined;
|
|
41
|
+
onMinHeight?: ((minSheetHeight: number) => any) | undefined;
|
|
42
|
+
onMaxHeight?: ((maxSheetHeight: number) => any) | undefined;
|
|
43
|
+
}>, {
|
|
44
|
+
blocking: boolean;
|
|
45
|
+
canSwipeClose: boolean;
|
|
46
|
+
canBackdropClose: boolean;
|
|
47
|
+
expandOnContentDrag: boolean;
|
|
48
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
49
|
+
declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
|
|
50
|
+
export default _default;
|
|
51
|
+
type __VLS_WithTemplateSlots<T, S> = T & {
|
|
52
|
+
new (): {
|
|
53
|
+
$slots: S;
|
|
54
|
+
};
|
|
55
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Ref } from 'vue';
|
|
2
|
+
export declare function useSnapPoints(snapPoints: Ref<number[]>, height: Ref<number>): {
|
|
3
|
+
minSnap: import('vue').ComputedRef<number>;
|
|
4
|
+
maxSnap: import('vue').ComputedRef<number>;
|
|
5
|
+
snapPoints: Ref<number[], number[]>;
|
|
6
|
+
closestSnapPoint: import('vue').ComputedRef<number>;
|
|
7
|
+
};
|
package/dist/index.d.ts
ADDED