@douxcode/vue-spring-bottom-sheet 3.0.0 → 3.1.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 +17 -17
- package/dist/BottomSheet.d.ts +3 -3
- package/dist/composables/useDragGestures.d.ts +28 -41
- package/dist/composables/useSwipeDetection.d.ts +1 -4
- package/dist/index.mjs +437 -483
- package/dist/style.css +1 -1
- package/dist/utils/constants.d.ts +0 -2
- package/dist/utils/isInteractable.d.ts +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -25,9 +25,9 @@ bun install @douxcode/vue-spring-bottom-sheet
|
|
|
25
25
|
<script setup>
|
|
26
26
|
import BottomSheet from '@douxcode/vue-spring-bottom-sheet'
|
|
27
27
|
import '@douxcode/vue-spring-bottom-sheet/dist/style.css'
|
|
28
|
-
import {
|
|
28
|
+
import { useTemplateRef } from 'vue'
|
|
29
29
|
|
|
30
|
-
const bottomSheet =
|
|
30
|
+
const bottomSheet = useTemplateRef('bottomSheet')
|
|
31
31
|
|
|
32
32
|
const open = () => {
|
|
33
33
|
bottomSheet.value.open()
|
|
@@ -130,21 +130,21 @@ For Nuxt 3, just wrap component in `<ClientOnly>`
|
|
|
130
130
|
|
|
131
131
|
### Prop Definitions
|
|
132
132
|
|
|
133
|
-
| Prop | Type
|
|
134
|
-
| ------------------- |
|
|
135
|
-
| duration | Number
|
|
136
|
-
| snapPoints | Array<number
|
|
137
|
-
| initialSnapPoint | Number
|
|
138
|
-
| blocking | Boolean
|
|
139
|
-
| canSwipeClose | Boolean
|
|
140
|
-
| swipeCloseThreshold | Number
|
|
141
|
-
| canBackdropClose | Boolean
|
|
142
|
-
| expandOnContentDrag | Boolean
|
|
143
|
-
| teleportTo | String \| RendererElement
|
|
144
|
-
| teleportDefer | Boolean
|
|
145
|
-
| headerClass | String
|
|
146
|
-
| contentClass | String
|
|
147
|
-
| footerClass | String
|
|
133
|
+
| Prop | Type | Default | Description |
|
|
134
|
+
| ------------------- | --------------------------- | ---------------- | ------------------------------------------------------------------------- |
|
|
135
|
+
| duration | Number | 250 | Animation duration in milliseconds |
|
|
136
|
+
| snapPoints | Array<number\|`${number}%`> | [instinctHeight] | Custom snapping positions |
|
|
137
|
+
| initialSnapPoint | Number | minHeight | Initial snap point index |
|
|
138
|
+
| blocking | Boolean | true | Block interactions with underlying content |
|
|
139
|
+
| canSwipeClose | Boolean | true | Enable swipe-to-close gesture |
|
|
140
|
+
| swipeCloseThreshold | Number\|`${number}%` | "50%" | The amount of translation (in px or %) after which the element will close |
|
|
141
|
+
| canBackdropClose | Boolean | true | Allow closing by tapping backdrop |
|
|
142
|
+
| expandOnContentDrag | Boolean | true | Enable expanding by dragging content |
|
|
143
|
+
| teleportTo | String \| RendererElement | body | Teleport to a specific element |
|
|
144
|
+
| teleportDefer | Boolean | false | Defer teleporting until opened (Vue 3.5+ only) |
|
|
145
|
+
| headerClass | String | '' | Set header element class |
|
|
146
|
+
| contentClass | String | '' | Set content element class |
|
|
147
|
+
| footerClass | String | '' | Set footer element class |
|
|
148
148
|
|
|
149
149
|
## Exposed methods
|
|
150
150
|
|
package/dist/BottomSheet.d.ts
CHANGED
|
@@ -21,7 +21,7 @@ declare const __VLS_component: import('vue').DefineComponent<BottomSheetProps, {
|
|
|
21
21
|
open: () => Promise<void>;
|
|
22
22
|
close: () => void;
|
|
23
23
|
snapToPoint: (index: number) => void;
|
|
24
|
-
}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
24
|
+
}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
25
25
|
opened: () => any;
|
|
26
26
|
"opening-started": () => any;
|
|
27
27
|
closed: () => any;
|
|
@@ -42,11 +42,11 @@ declare const __VLS_component: import('vue').DefineComponent<BottomSheetProps, {
|
|
|
42
42
|
onInstinctHeight?: ((instinctHeight: number) => any) | undefined;
|
|
43
43
|
"onUpdate:modelValue"?: (() => any) | undefined;
|
|
44
44
|
}>, {
|
|
45
|
-
canSwipeClose: boolean;
|
|
46
|
-
expandOnContentDrag: boolean;
|
|
47
45
|
blocking: boolean;
|
|
48
46
|
duration: number;
|
|
47
|
+
canSwipeClose: boolean;
|
|
49
48
|
canBackdropClose: boolean;
|
|
49
|
+
expandOnContentDrag: boolean;
|
|
50
50
|
teleportTo: string | import('vue').RendererElement;
|
|
51
51
|
teleportDefer: boolean;
|
|
52
52
|
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {
|
|
@@ -1,47 +1,34 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { BottomSheetProps } from '../types';
|
|
2
|
+
import { Ref, ShallowRef } from 'vue';
|
|
3
|
+
type DragHandle = 'header' | 'footer';
|
|
4
|
+
type PointerCaptureTarget = DragHandle | 'content';
|
|
5
|
+
interface UseDragGesturesOptions {
|
|
6
|
+
sheetHeaderRef: ShallowRef<HTMLElement | null>;
|
|
7
|
+
sheetFooterRef: ShallowRef<HTMLElement | null>;
|
|
8
|
+
sheetContentRef: ShallowRef<HTMLElement | null>;
|
|
4
9
|
sheetScrollRef: ShallowRef<HTMLElement | null>;
|
|
5
10
|
height: Ref<number>;
|
|
6
11
|
translateY: Ref<number>;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
flattenedSnapPoints:
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
maxSnapPoint: ComputedRef<number>;
|
|
15
|
-
canSwipeClose: Ref<boolean>;
|
|
16
|
-
swipeCloseThreshold: Ref<string | number | undefined>;
|
|
17
|
-
expandOnContentDrag: Ref<boolean>;
|
|
12
|
+
minSnapPoint: Readonly<Ref<number>>;
|
|
13
|
+
maxSnapPoint: Readonly<Ref<number>>;
|
|
14
|
+
closestSnapPointIndex: Readonly<Ref<number>>;
|
|
15
|
+
flattenedSnapPoints: Readonly<Ref<number[]>>;
|
|
16
|
+
canSwipeClose: Readonly<Ref<boolean>>;
|
|
17
|
+
expandOnContentDrag: Readonly<Ref<boolean>>;
|
|
18
|
+
swipeCloseThreshold: Readonly<Ref<BottomSheetProps['swipeCloseThreshold']>>;
|
|
18
19
|
onClose: () => void;
|
|
19
|
-
|
|
20
|
-
onDraggingUp
|
|
21
|
-
onDraggingDown
|
|
20
|
+
onSnapToPoint: (index: number) => void;
|
|
21
|
+
onDraggingUp?: () => void;
|
|
22
|
+
onDraggingDown?: () => void;
|
|
22
23
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
onPointermove: (event: PointerEvent) => void;
|
|
33
|
-
onPointerup: (event: PointerEvent) => void;
|
|
34
|
-
onPointercancel: (event: PointerEvent) => void;
|
|
35
|
-
onContextmenu: (event: MouseEvent) => void;
|
|
36
|
-
onTouchmove: (event: TouchEvent) => void;
|
|
37
|
-
}>;
|
|
38
|
-
contentWrapperHandlers: ComputedRef<{
|
|
39
|
-
onPointerdown: (event: PointerEvent) => void;
|
|
40
|
-
onPointermove: (event: PointerEvent) => void;
|
|
41
|
-
onPointerup: (event: PointerEvent) => void;
|
|
42
|
-
onPointercancel: (event: PointerEvent) => void;
|
|
43
|
-
onContextmenu: (event: MouseEvent) => void;
|
|
44
|
-
onTouchmove: (event: TouchEvent) => void;
|
|
45
|
-
}>;
|
|
46
|
-
scrollEnd: () => void;
|
|
24
|
+
export declare const useDragGestures: (options: UseDragGesturesOptions) => {
|
|
25
|
+
isDragging: ShallowRef<boolean, boolean>;
|
|
26
|
+
handleSheetScroll: (event: TouchEvent) => void;
|
|
27
|
+
handlePointerDown: (event: PointerEvent, type: DragHandle) => void;
|
|
28
|
+
handleContentPointerDown: (event: PointerEvent) => void;
|
|
29
|
+
handlePointerMove: (event: PointerEvent) => void;
|
|
30
|
+
handleContentPointerMove: (event: PointerEvent) => void;
|
|
31
|
+
handleLostPointerCapture: (event: PointerEvent, type: PointerCaptureTarget) => void;
|
|
32
|
+
handleTouchStart: (event: TouchEvent) => void;
|
|
47
33
|
};
|
|
34
|
+
export {};
|
|
@@ -3,10 +3,7 @@ export interface SwipeResult {
|
|
|
3
3
|
velocity: number;
|
|
4
4
|
isSwipe: boolean;
|
|
5
5
|
}
|
|
6
|
-
export
|
|
7
|
-
velocityThreshold?: number;
|
|
8
|
-
}
|
|
9
|
-
export declare function useSwipeDetection(options?: UseSwipeDetectionOptions): {
|
|
6
|
+
export declare function useSwipeDetection(): {
|
|
10
7
|
start: (y: number) => void;
|
|
11
8
|
update: (y: number) => void;
|
|
12
9
|
end: () => SwipeResult;
|
package/dist/index.mjs
CHANGED
|
@@ -1,372 +1,284 @@
|
|
|
1
|
-
import { ref as
|
|
2
|
-
import { useScrollLock as
|
|
3
|
-
import { useFocusTrap as
|
|
4
|
-
function
|
|
5
|
-
|
|
6
|
-
return
|
|
1
|
+
import { ref as I, shallowRef as x, computed as H, defineComponent as Be, useCssVars as Oe, watch as A, nextTick as _, onMounted as Ae, toRef as F, onUnmounted as Fe, openBlock as $, createElementBlock as ee, Fragment as $e, createBlock as fe, Teleport as ve, createElementVNode as V, createVNode as he, Transition as ge, withCtx as me, unref as v, createCommentVNode as pe, normalizeStyle as Ve, normalizeClass as te, renderSlot as ne } from "vue";
|
|
2
|
+
import { useScrollLock as Ne, useVModel as ze, useWindowSize as qe, useElementBounding as U } from "@vueuse/core";
|
|
3
|
+
import { useFocusTrap as Ke } from "@vueuse/integrations/useFocusTrap";
|
|
4
|
+
function Ue(e, t, o) {
|
|
5
|
+
let n = (r) => e(r, ...t);
|
|
6
|
+
return o === void 0 ? n : Object.assign(n, { lazy: o, lazyArgs: t });
|
|
7
7
|
}
|
|
8
|
-
function
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
);
|
|
13
|
-
return n.value.indexOf(f);
|
|
14
|
-
});
|
|
15
|
-
return {
|
|
16
|
-
currentSnapPointIndex: e,
|
|
17
|
-
flattenedSnapPoints: n,
|
|
18
|
-
minSnapPoint: i,
|
|
19
|
-
maxSnapPoint: r,
|
|
20
|
-
closestSnapPointIndex: p
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
function Fe(t, a, u) {
|
|
24
|
-
let e = (n) => t(n, ...a);
|
|
25
|
-
return u === void 0 ? e : Object.assign(e, { lazy: u, lazyArgs: a });
|
|
26
|
-
}
|
|
27
|
-
function $e(t, a, u) {
|
|
28
|
-
let e = t.length - a.length;
|
|
29
|
-
if (e === 0) return t(...a);
|
|
30
|
-
if (e === 1) return Fe(t, a, u);
|
|
8
|
+
function We(e, t, o) {
|
|
9
|
+
let n = e.length - t.length;
|
|
10
|
+
if (n === 0) return e(...t);
|
|
11
|
+
if (n === 1) return Ue(e, t, o);
|
|
31
12
|
throw Error("Wrong number of arguments");
|
|
32
13
|
}
|
|
33
|
-
function
|
|
34
|
-
return
|
|
14
|
+
function E(...e) {
|
|
15
|
+
return We(Ge, e);
|
|
35
16
|
}
|
|
36
|
-
const
|
|
37
|
-
function
|
|
38
|
-
let
|
|
39
|
-
let g =
|
|
40
|
-
g !== void 0 && (
|
|
41
|
-
},
|
|
42
|
-
clearTimeout(
|
|
43
|
-
},
|
|
44
|
-
clearTimeout(
|
|
17
|
+
const Ge = (e, { min: t, max: o }) => t !== void 0 && e < t ? t : o !== void 0 && e > o ? o : e, Te = /* @__PURE__ */ Symbol("funnel/voidReducer"), Qe = () => Te;
|
|
18
|
+
function Xe(e, { triggerAt: t = "end", minQuietPeriodMs: o, maxBurstDurationMs: n, minGapMs: r, reducer: i = Qe }) {
|
|
19
|
+
let u, f, d, h, m = () => {
|
|
20
|
+
let g = d;
|
|
21
|
+
g !== void 0 && (d = void 0, g === Te ? e() : e(g), r !== void 0 && (f = setTimeout(P, r)));
|
|
22
|
+
}, P = () => {
|
|
23
|
+
clearTimeout(f), f = void 0, u === void 0 && m();
|
|
24
|
+
}, C = () => {
|
|
25
|
+
clearTimeout(u), u = void 0, h = void 0, f === void 0 && m();
|
|
45
26
|
};
|
|
46
27
|
return { call: (...g) => {
|
|
47
|
-
let
|
|
48
|
-
if ((
|
|
49
|
-
if (
|
|
50
|
-
clearTimeout(
|
|
51
|
-
let
|
|
52
|
-
|
|
53
|
-
let
|
|
54
|
-
|
|
28
|
+
let T = u === void 0 && f === void 0;
|
|
29
|
+
if ((t !== "start" || T) && (d = i(d, ...g)), !(u === void 0 && !T)) {
|
|
30
|
+
if (o !== void 0 || n !== void 0 || r === void 0) {
|
|
31
|
+
clearTimeout(u);
|
|
32
|
+
let y = Date.now();
|
|
33
|
+
h ??= y;
|
|
34
|
+
let Y = n === void 0 ? o ?? 0 : Math.min(o ?? n, Math.max(0, n - (y - h)));
|
|
35
|
+
u = setTimeout(C, Y);
|
|
55
36
|
}
|
|
56
|
-
|
|
37
|
+
t !== "end" && T && m();
|
|
57
38
|
}
|
|
58
39
|
}, cancel: () => {
|
|
59
|
-
clearTimeout(
|
|
40
|
+
clearTimeout(u), u = void 0, h = void 0, clearTimeout(f), f = void 0, d = void 0;
|
|
60
41
|
}, flush: () => {
|
|
61
|
-
|
|
42
|
+
C(), P();
|
|
62
43
|
}, get isIdle() {
|
|
63
|
-
return
|
|
44
|
+
return u === void 0 && f === void 0;
|
|
64
45
|
} };
|
|
65
46
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
}
|
|
89
|
-
const h = Math.abs(d) >= a;
|
|
90
|
-
let g = "none";
|
|
91
|
-
return h && (g = d < 0 ? "up" : "down"), r.value = [], {
|
|
92
|
-
direction: g,
|
|
93
|
-
velocity: Math.abs(d),
|
|
94
|
-
isSwipe: h
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
};
|
|
47
|
+
const je = 5, Je = 30, Ze = 400;
|
|
48
|
+
function _e() {
|
|
49
|
+
const e = I([]);
|
|
50
|
+
function t(r) {
|
|
51
|
+
e.value = [{ y: r, time: performance.now() }];
|
|
52
|
+
}
|
|
53
|
+
function o(r) {
|
|
54
|
+
const i = e.value;
|
|
55
|
+
i.push({ y: r, time: performance.now() }), i.length > je && i.shift();
|
|
56
|
+
}
|
|
57
|
+
function n() {
|
|
58
|
+
const r = e.value;
|
|
59
|
+
if (r.length < 2)
|
|
60
|
+
return { direction: "none", velocity: 0, isSwipe: !1 };
|
|
61
|
+
const i = r[0], u = r[r.length - 1];
|
|
62
|
+
if (!i || !u)
|
|
63
|
+
return { direction: "none", velocity: 0, isSwipe: !1 };
|
|
64
|
+
const f = i.y - u.y, d = (u.time - i.time) / 1e3, h = d > 0 ? Math.abs(f) / d : 0, m = Math.abs(f) >= Je && h >= Ze;
|
|
65
|
+
let P = "none";
|
|
66
|
+
return m && (P = f > 0 ? "up" : "down"), e.value = [], { direction: P, velocity: h, isSwipe: m };
|
|
67
|
+
}
|
|
68
|
+
return { start: t, update: o, end: n };
|
|
98
69
|
}
|
|
99
|
-
function
|
|
100
|
-
|
|
70
|
+
function et(e, t) {
|
|
71
|
+
if (e === void 0)
|
|
72
|
+
return t / 2;
|
|
73
|
+
if (typeof e == "number")
|
|
74
|
+
return e;
|
|
75
|
+
if (typeof e == "string" && e.includes("%")) {
|
|
76
|
+
const o = Number(e.replace("%", ""));
|
|
77
|
+
return t * (o / 100);
|
|
78
|
+
}
|
|
79
|
+
return t / 2;
|
|
101
80
|
}
|
|
102
|
-
|
|
103
|
-
|
|
81
|
+
const tt = 10, Se = 0.25;
|
|
82
|
+
function be(e) {
|
|
83
|
+
const t = e, o = e instanceof HTMLAnchorElement || e instanceof HTMLButtonElement || e instanceof HTMLInputElement || e instanceof HTMLTextAreaElement || e instanceof HTMLSelectElement || e instanceof HTMLLabelElement || e instanceof HTMLVideoElement || e instanceof HTMLAudioElement, n = e.hasAttribute("onclick") || e.hasAttribute("role"), r = t.tabIndex >= 0 || e.hasAttribute("tabindex"), i = t.isContentEditable || e instanceof HTMLInputElement && !e.disabled || e instanceof HTMLTextAreaElement && !e.disabled;
|
|
84
|
+
return o || n || r || i;
|
|
104
85
|
}
|
|
105
|
-
function
|
|
106
|
-
return
|
|
86
|
+
function nt(e, t, o) {
|
|
87
|
+
return Math.max(t, Math.min(e, o));
|
|
107
88
|
}
|
|
108
|
-
function
|
|
109
|
-
return e
|
|
89
|
+
function at(e, t) {
|
|
90
|
+
return Math.pow(e, t * 5);
|
|
110
91
|
}
|
|
111
|
-
function
|
|
112
|
-
return
|
|
92
|
+
function we(e, t, o) {
|
|
93
|
+
return t === 0 || Math.abs(t) === 1 / 0 ? at(e, o) : e * t * o / (t + o * e);
|
|
113
94
|
}
|
|
114
|
-
function
|
|
115
|
-
|
|
116
|
-
return a / 2;
|
|
117
|
-
if (typeof t == "number")
|
|
118
|
-
return t;
|
|
119
|
-
if (typeof t == "string" && t.includes("%")) {
|
|
120
|
-
const u = Number(t.replace("%", ""));
|
|
121
|
-
return a * (u / 100);
|
|
122
|
-
}
|
|
123
|
-
return a / 2;
|
|
95
|
+
function Pe(e, t, o, n = 0.15) {
|
|
96
|
+
return n === 0 ? nt(e, t, o) : e < t ? -we(t - e, o - t, n) + t : e > o ? +we(e - o, o - t, n) + o : e;
|
|
124
97
|
}
|
|
125
|
-
const
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
if (!a.value) return;
|
|
151
|
-
const o = window.getComputedStyle(a.value), c = parseFloat(o.height);
|
|
152
|
-
let l = 0;
|
|
153
|
-
o.transform && o.transform !== "none" && (l = new DOMMatrix(o.transform).m42), e.value = c, n.value = l;
|
|
154
|
-
}, le = () => {
|
|
155
|
-
const o = v.value;
|
|
156
|
-
b.value = o;
|
|
157
|
-
const c = p.value[o];
|
|
158
|
-
if (!c) return;
|
|
159
|
-
const l = ae(c, r.value);
|
|
160
|
-
e.value = l, n.value = 0, R(p.value.indexOf(c));
|
|
161
|
-
}, _ = (o = !0) => {
|
|
162
|
-
const c = O.end();
|
|
163
|
-
if (o && c.isSwipe && c.direction === "down" && g.value && e.value <= d.value + Ge)
|
|
164
|
-
return n.value = e.value, x(), !0;
|
|
165
|
-
let l;
|
|
166
|
-
if (o && c.isSwipe && f.value.length > 1) {
|
|
167
|
-
const Y = [...f.value].sort((y, L) => y - L);
|
|
168
|
-
if (c.direction === "up") {
|
|
169
|
-
const y = Y.find((L) => L > e.value + 1);
|
|
170
|
-
l = y !== void 0 ? f.value.indexOf(y) : v.value;
|
|
171
|
-
} else {
|
|
172
|
-
const y = [...Y].reverse().find((L) => L < e.value - 1);
|
|
173
|
-
l = y !== void 0 ? f.value.indexOf(y) : v.value;
|
|
174
|
-
}
|
|
175
|
-
} else
|
|
176
|
-
l = v.value;
|
|
177
|
-
b.value = l;
|
|
178
|
-
const s = p.value[l];
|
|
179
|
-
if (!s)
|
|
180
|
-
return x(), !0;
|
|
181
|
-
const m = ae(s, r.value);
|
|
182
|
-
return m === 0 ? (x(), !0) : (e.value = m, n.value = 0, R(p.value.indexOf(s)), !1);
|
|
183
|
-
}, ue = (o) => {
|
|
184
|
-
a.value && o.button === 0 && (z(), T.value = !0, F.value = o.clientY, V.value = e.value, k.value = n.value, M.value = o.clientY, O.start(o.clientY), o.target.setPointerCapture(o.pointerId));
|
|
185
|
-
}, A = (o) => {
|
|
186
|
-
if (!T.value) return;
|
|
187
|
-
if (o.buttons !== 1) {
|
|
188
|
-
$(o);
|
|
189
|
-
return;
|
|
190
|
-
}
|
|
191
|
-
const c = o.clientY - F.value, l = o.clientY;
|
|
192
|
-
n.value <= 0 && (e.value = V.value - c), e.value <= d.value && (e.value = d.value, n.value = k.value + c, g.value ? n.value = I(n.value, { min: 0 }) : n.value = I(
|
|
193
|
-
de(
|
|
194
|
-
n.value,
|
|
195
|
-
-i.value,
|
|
196
|
-
0,
|
|
197
|
-
xe
|
|
198
|
-
),
|
|
199
|
-
{ min: 0 }
|
|
200
|
-
)), e.value = I(
|
|
201
|
-
de(e.value, 0, h.value, Xe),
|
|
202
|
-
{
|
|
203
|
-
min: 0,
|
|
204
|
-
max: r.value
|
|
205
|
-
}
|
|
206
|
-
), K(o.clientY - M.value), O.update(o.clientY), M.value = l;
|
|
207
|
-
}, $ = (o) => {
|
|
208
|
-
if (T.value = !1, o.target.releasePointerCapture(o.pointerId), g.value) {
|
|
209
|
-
const c = Ce(w.value, e.value);
|
|
210
|
-
if (n.value > c) {
|
|
211
|
-
n.value = e.value, x();
|
|
98
|
+
const ot = (e) => {
|
|
99
|
+
const t = _e(), o = x(!1);
|
|
100
|
+
let n = !0, r = 0, i = 0, u = !1, f = 0, d = !1, h = 0;
|
|
101
|
+
const m = (a) => {
|
|
102
|
+
a > 0 ? e.onDraggingDown?.() : a < 0 && e.onDraggingUp?.();
|
|
103
|
+
}, P = () => {
|
|
104
|
+
if (u) return;
|
|
105
|
+
const a = document.activeElement;
|
|
106
|
+
a instanceof HTMLElement && a !== document.body && (a.blur(), u = !0);
|
|
107
|
+
}, C = (a) => {
|
|
108
|
+
typeof a.cancelable != "boolean" || a.cancelable ? n && a.preventDefault() : console.warn("The following event couldn't be canceled:");
|
|
109
|
+
}, g = (a, p) => {
|
|
110
|
+
const b = p === "header" ? e.sheetHeaderRef.value : e.sheetFooterRef.value;
|
|
111
|
+
b && a.button === 0 && (r = e.height.value, i = e.translateY.value, u = !1, h = 0, d = !1, n = !0, o.value = !0, t.start(a.clientY), b.setPointerCapture(a.pointerId));
|
|
112
|
+
}, T = (a) => {
|
|
113
|
+
e.sheetContentRef.value && a.button === 0 && e.expandOnContentDrag.value !== !1 && (be(a.target) || (r = e.height.value, i = e.translateY.value, f = a.clientY, u = !1, h = 0, d = !1, n = !0, o.value = !0, t.start(a.clientY), e.sheetContentRef.value.setPointerCapture(a.pointerId)));
|
|
114
|
+
}, y = (a) => {
|
|
115
|
+
if (o.value) {
|
|
116
|
+
if (Math.abs(a.movementY) > 0 && P(), t.update(a.clientY), m(a.movementY), e.translateY.value > 0) {
|
|
117
|
+
e.canSwipeClose.value ? e.translateY.value = e.translateY.value + a.movementY : (i = i + a.movementY, e.translateY.value = Pe(
|
|
118
|
+
i,
|
|
119
|
+
-e.minSnapPoint.value,
|
|
120
|
+
0,
|
|
121
|
+
Se
|
|
122
|
+
));
|
|
212
123
|
return;
|
|
213
124
|
}
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
125
|
+
r = E(r - a.movementY, {
|
|
126
|
+
min: e.minSnapPoint.value
|
|
127
|
+
}), e.height.value = Pe(
|
|
128
|
+
r,
|
|
129
|
+
0,
|
|
130
|
+
e.maxSnapPoint.value,
|
|
131
|
+
Se
|
|
132
|
+
), e.height.value <= e.minSnapPoint.value && (e.translateY.value = e.translateY.value + a.movementY);
|
|
219
133
|
}
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
const
|
|
224
|
-
if (
|
|
225
|
-
if (!
|
|
226
|
-
|
|
227
|
-
return;
|
|
228
|
-
}
|
|
229
|
-
n.value === 0 && c && l && (S.value = !0), n.value === 0 && c && !l && (S.value = !1);
|
|
230
|
-
} else {
|
|
231
|
-
if (!C.value) {
|
|
232
|
-
S.value = !1;
|
|
134
|
+
}, Y = (a) => {
|
|
135
|
+
if (h >= 2)
|
|
136
|
+
return;
|
|
137
|
+
const p = e.sheetScrollRef.value, b = p?.scrollTop === 0, w = a.clientY - f > 0, S = e.flattenedSnapPoints.value.length === 1, z = 0.5 > Math.abs(e.height.value - e.maxSnapPoint.value), D = (p?.scrollHeight ?? 0) > (p?.clientHeight ?? 0);
|
|
138
|
+
if (S) {
|
|
139
|
+
if (!e.expandOnContentDrag.value) {
|
|
140
|
+
n = !1;
|
|
233
141
|
return;
|
|
234
142
|
}
|
|
235
|
-
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
},
|
|
240
|
-
if (!
|
|
241
|
-
if (
|
|
242
|
-
|
|
143
|
+
e.translateY.value === 0 && b && w && (n = !0), e.translateY.value === 0 && b && !w && (n = !1);
|
|
144
|
+
} else
|
|
145
|
+
n = !0, z && (w && b && (n = !0), !w && b && (n = !1), b || (n = !1));
|
|
146
|
+
d = !D, h++;
|
|
147
|
+
}, R = (a) => {
|
|
148
|
+
if (!o.value || !e.sheetScrollRef.value || (Math.abs(a.movementY) > 0 && P(), Y(a), h <= 1)) return;
|
|
149
|
+
if (t.update(a.clientY), m(a.movementY), e.translateY.value > 0) {
|
|
150
|
+
e.canSwipeClose.value && (e.translateY.value = E(e.translateY.value + a.movementY, { min: 0 }));
|
|
243
151
|
return;
|
|
244
152
|
}
|
|
245
|
-
|
|
246
|
-
|
|
153
|
+
e.height.value = E(e.height.value - a.movementY, {
|
|
154
|
+
min: e.minSnapPoint.value,
|
|
155
|
+
max: e.maxSnapPoint.value
|
|
156
|
+
}), !(e.flattenedSnapPoints.value.length === 1) && e.height.value === e.maxSnapPoint.value && (n = !1), e.height.value <= e.minSnapPoint.value && (e.translateY.value = E(e.translateY.value + a.movementY, {
|
|
157
|
+
min: 0,
|
|
158
|
+
...e.canSwipeClose.value === !1 ? { max: 0 } : {}
|
|
159
|
+
}));
|
|
160
|
+
}, N = () => {
|
|
161
|
+
const a = t.end();
|
|
162
|
+
if (a.isSwipe && a.direction === "down" && e.canSwipeClose.value && e.height.value <= e.minSnapPoint.value + tt) {
|
|
163
|
+
e.onClose();
|
|
247
164
|
return;
|
|
248
165
|
}
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
166
|
+
if (e.canSwipeClose.value) {
|
|
167
|
+
const p = et(
|
|
168
|
+
e.swipeCloseThreshold.value,
|
|
169
|
+
e.height.value
|
|
170
|
+
);
|
|
171
|
+
if (e.translateY.value > p) {
|
|
172
|
+
e.onClose();
|
|
256
173
|
return;
|
|
257
174
|
}
|
|
258
175
|
}
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
)
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
}, U = (o) => {
|
|
269
|
-
if (T.value = !1, B.value = !0, o.target.releasePointerCapture(o.pointerId), g.value) {
|
|
270
|
-
const l = Ce(w.value, e.value);
|
|
271
|
-
if (n.value > l) {
|
|
272
|
-
n.value = e.value, x();
|
|
273
|
-
return;
|
|
176
|
+
if (a.isSwipe && e.flattenedSnapPoints.value.length > 1) {
|
|
177
|
+
const p = [...e.flattenedSnapPoints.value].sort((w, S) => w - S);
|
|
178
|
+
let b = e.closestSnapPointIndex.value;
|
|
179
|
+
if (a.direction === "up") {
|
|
180
|
+
const w = p.find((S) => S > e.height.value + 1);
|
|
181
|
+
w !== void 0 && (b = e.flattenedSnapPoints.value.indexOf(w));
|
|
182
|
+
} else if (a.direction === "down") {
|
|
183
|
+
const w = [...p].reverse().find((S) => S < e.height.value - 1);
|
|
184
|
+
w !== void 0 && (b = e.flattenedSnapPoints.value.indexOf(w));
|
|
274
185
|
}
|
|
275
|
-
|
|
276
|
-
n.value = 0;
|
|
277
|
-
if (n.value === e.value) {
|
|
278
|
-
n.value = 0, x();
|
|
186
|
+
e.onSnapToPoint(b), e.translateY.value = 0;
|
|
279
187
|
return;
|
|
280
188
|
}
|
|
281
|
-
|
|
282
|
-
_(c);
|
|
283
|
-
}, W = (o) => {
|
|
284
|
-
T.value && (o.preventDefault(), T.value = !1, B.value = !0, le());
|
|
285
|
-
}, G = (o) => {
|
|
286
|
-
S.value = !0, Z(o);
|
|
287
|
-
}, Z = (o) => {
|
|
288
|
-
S.value && o.preventDefault();
|
|
289
|
-
}, Q = () => {
|
|
290
|
-
if (!u.value) return;
|
|
291
|
-
const o = u.value.scrollTop === 0;
|
|
292
|
-
S.value = o;
|
|
293
|
-
}, N = D(() => ({
|
|
294
|
-
onPointerdown: ue,
|
|
295
|
-
onPointermove: A,
|
|
296
|
-
onPointerup: $,
|
|
297
|
-
onPointercancel: $,
|
|
298
|
-
onContextmenu: W,
|
|
299
|
-
onTouchmove: G
|
|
300
|
-
})), ee = D(() => ({
|
|
301
|
-
onPointerdown: J,
|
|
302
|
-
onPointermove: se,
|
|
303
|
-
onPointerup: U,
|
|
304
|
-
onPointercancel: U,
|
|
305
|
-
onContextmenu: W,
|
|
306
|
-
onTouchmove: Z
|
|
307
|
-
}));
|
|
308
|
-
return {
|
|
309
|
-
isDragging: T,
|
|
310
|
-
preventContentScroll: S,
|
|
311
|
-
headerFooterHandlers: N,
|
|
312
|
-
contentWrapperHandlers: ee,
|
|
313
|
-
scrollEnd: Q
|
|
314
|
-
};
|
|
315
|
-
}
|
|
316
|
-
function _e(t) {
|
|
317
|
-
const { blocking: a } = t, u = Pe(document.body), e = Pe(document.documentElement), n = () => {
|
|
318
|
-
u.value = !0, e.value = !0;
|
|
319
|
-
}, i = () => {
|
|
320
|
-
u.value = !1, e.value = !1;
|
|
189
|
+
e.onSnapToPoint(e.closestSnapPointIndex.value), e.translateY.value = 0;
|
|
321
190
|
};
|
|
322
191
|
return {
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
192
|
+
isDragging: o,
|
|
193
|
+
handleSheetScroll: C,
|
|
194
|
+
handlePointerDown: g,
|
|
195
|
+
handleContentPointerDown: T,
|
|
196
|
+
handlePointerMove: y,
|
|
197
|
+
handleContentPointerMove: R,
|
|
198
|
+
handleLostPointerCapture: (a, p) => {
|
|
199
|
+
o.value = !1, p === "header" ? e.sheetHeaderRef.value?.releasePointerCapture(a.pointerId) : p === "footer" ? e.sheetFooterRef.value?.releasePointerCapture(a.pointerId) : e.sheetContentRef.value?.releasePointerCapture(a.pointerId), h = 0, d = !1, u = !1, N();
|
|
330
200
|
},
|
|
331
|
-
|
|
332
|
-
a.
|
|
333
|
-
},
|
|
334
|
-
touchEndHandler: () => {
|
|
335
|
-
a.value || i();
|
|
201
|
+
handleTouchStart: (a) => {
|
|
202
|
+
be(a.target) || d && a.preventDefault();
|
|
336
203
|
}
|
|
337
204
|
};
|
|
338
|
-
}
|
|
339
|
-
function
|
|
340
|
-
const { sheetRef:
|
|
205
|
+
};
|
|
206
|
+
function rt(e) {
|
|
207
|
+
const { sheetRef: t, backdropRef: o, blocking: n, onEscape: r } = e, i = I(null), u = Ke([t, o], {
|
|
341
208
|
immediate: !1,
|
|
342
|
-
fallbackFocus: () =>
|
|
343
|
-
}),
|
|
344
|
-
g.key === "Escape" &&
|
|
345
|
-
},
|
|
346
|
-
|
|
347
|
-
for (const
|
|
348
|
-
|
|
349
|
-
}), i.value.observe(
|
|
209
|
+
fallbackFocus: () => t.value || document.body
|
|
210
|
+
}), f = (g) => {
|
|
211
|
+
g.key === "Escape" && r();
|
|
212
|
+
}, d = () => {
|
|
213
|
+
t.value && (i.value = new MutationObserver((g) => {
|
|
214
|
+
for (const T of g)
|
|
215
|
+
T.type === "attributes" && T.attributeName === "aria-expanded" && (T.target.getAttribute("aria-expanded") === "true" ? u.pause() : t.value?.querySelector('[aria-expanded="true"]') || u.unpause());
|
|
216
|
+
}), i.value.observe(t.value, {
|
|
350
217
|
attributes: !0,
|
|
351
218
|
attributeFilter: ["aria-expanded"],
|
|
352
219
|
subtree: !0
|
|
353
220
|
}));
|
|
354
|
-
},
|
|
221
|
+
}, h = () => {
|
|
355
222
|
i.value && (i.value.disconnect(), i.value = null);
|
|
356
223
|
};
|
|
357
224
|
return {
|
|
358
225
|
activate: () => {
|
|
359
|
-
|
|
226
|
+
n.value && (u.activate(), d()), window.addEventListener("keydown", f);
|
|
360
227
|
},
|
|
361
228
|
deactivate: () => {
|
|
362
|
-
window.removeEventListener("keydown",
|
|
229
|
+
window.removeEventListener("keydown", f), h(), n.value && u.deactivate();
|
|
363
230
|
},
|
|
364
231
|
cleanup: () => {
|
|
365
|
-
|
|
232
|
+
h(), u.deactivate();
|
|
366
233
|
}
|
|
367
234
|
};
|
|
368
235
|
}
|
|
369
|
-
|
|
236
|
+
function lt(e) {
|
|
237
|
+
const { blocking: t } = e, o = Ne(document.documentElement), n = () => {
|
|
238
|
+
o.value = !0;
|
|
239
|
+
}, r = () => {
|
|
240
|
+
o.value = !1;
|
|
241
|
+
};
|
|
242
|
+
return {
|
|
243
|
+
lock: n,
|
|
244
|
+
unlock: r,
|
|
245
|
+
lockIfBlocking: () => {
|
|
246
|
+
t.value && n();
|
|
247
|
+
},
|
|
248
|
+
unlockIfBlocking: () => {
|
|
249
|
+
t.value && r();
|
|
250
|
+
},
|
|
251
|
+
touchStartHandler: () => {
|
|
252
|
+
t.value || n();
|
|
253
|
+
},
|
|
254
|
+
touchEndHandler: () => {
|
|
255
|
+
t.value || r();
|
|
256
|
+
}
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
function ke(e, t) {
|
|
260
|
+
const o = parseFloat(e);
|
|
261
|
+
return t * o / 100;
|
|
262
|
+
}
|
|
263
|
+
function st(e, t, o) {
|
|
264
|
+
const n = I(0), r = H(() => e.value.map((d) => typeof d == "string" ? ke(d, o.value) : d)), i = H(() => Math.min(...r.value)), u = H(() => Math.max(...r.value)), f = H(() => {
|
|
265
|
+
const d = r.value.reduce(
|
|
266
|
+
(h, m) => Math.abs(m - t.value) < Math.abs(h - t.value) ? m : h
|
|
267
|
+
);
|
|
268
|
+
return r.value.indexOf(d);
|
|
269
|
+
});
|
|
270
|
+
return {
|
|
271
|
+
currentSnapPointIndex: n,
|
|
272
|
+
flattenedSnapPoints: r,
|
|
273
|
+
minSnapPoint: i,
|
|
274
|
+
maxSnapPoint: u,
|
|
275
|
+
closestSnapPointIndex: f
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
function Ce(e, t) {
|
|
279
|
+
return typeof e == "number" ? E(e, { max: t }) : ke(e, t);
|
|
280
|
+
}
|
|
281
|
+
const it = ["data-vsbs-shadow", "data-vsbs-sheet-show"], ut = /* @__PURE__ */ Be({
|
|
370
282
|
__name: "BottomSheet",
|
|
371
283
|
props: {
|
|
372
284
|
duration: { default: 250 },
|
|
@@ -385,213 +297,255 @@ const Ze = ["data-vsbs-shadow", "data-vsbs-sheet-show"], et = /* @__PURE__ */ ye
|
|
|
385
297
|
footerClass: {}
|
|
386
298
|
},
|
|
387
299
|
emits: ["opened", "opening-started", "closed", "closing-started", "dragging-up", "dragging-down", "snapped", "instinctHeight", "update:modelValue"],
|
|
388
|
-
setup(
|
|
389
|
-
|
|
390
|
-
|
|
300
|
+
setup(e, { expose: t, emit: o }) {
|
|
301
|
+
Oe((s) => ({
|
|
302
|
+
v7643c7ff: b.value
|
|
391
303
|
}));
|
|
392
|
-
const
|
|
304
|
+
const n = e, r = o, i = ze(n, "modelValue", r, {
|
|
393
305
|
passive: !0
|
|
394
306
|
});
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
}),
|
|
398
|
-
|
|
307
|
+
A(i, (s) => {
|
|
308
|
+
s ? j() : B();
|
|
309
|
+
}), A(i, async (s) => {
|
|
310
|
+
if (!s) {
|
|
311
|
+
C.value = 0;
|
|
312
|
+
return;
|
|
313
|
+
}
|
|
314
|
+
await _(), M();
|
|
315
|
+
}), Ae(() => {
|
|
316
|
+
De(), i.value && j();
|
|
399
317
|
});
|
|
400
|
-
const
|
|
401
|
-
Math.ceil(
|
|
402
|
-
{ max:
|
|
403
|
-
)),
|
|
404
|
-
|
|
405
|
-
},
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
(
|
|
450
|
-
), e.initialSnapPoint !== void 0) {
|
|
451
|
-
const y = e.initialSnapPoint;
|
|
452
|
-
if (y < 0 || y >= k.value.length) {
|
|
318
|
+
const u = x(null), f = x(null), d = x(null), h = x(null), m = x(null), P = x(null), C = I(0), { height: g } = qe(), { height: T } = U(u), { height: y } = U(f), { height: Y } = U(m), { height: R } = U(d), N = H(() => E(
|
|
319
|
+
Math.ceil(Y.value + y.value + R.value),
|
|
320
|
+
{ max: g.value }
|
|
321
|
+
)), ae = (s, l, c) => {
|
|
322
|
+
y.value = s, Y.value = l, R.value = c;
|
|
323
|
+
}, k = I(0), a = I(0), p = H(() => E(k.value + C.value, {
|
|
324
|
+
max: g.value
|
|
325
|
+
})), b = H(() => n.duration + "ms"), w = F(() => n.snapPoints), S = H(() => w.value ?? [N.value]), {
|
|
326
|
+
flattenedSnapPoints: z,
|
|
327
|
+
currentSnapPointIndex: D,
|
|
328
|
+
closestSnapPointIndex: xe,
|
|
329
|
+
minSnapPoint: W,
|
|
330
|
+
maxSnapPoint: Ee
|
|
331
|
+
} = st(S, k, g), oe = F(() => n.blocking), ye = F(() => n.canSwipeClose), Me = F(() => n.swipeCloseThreshold), He = F(() => n.expandOnContentDrag), L = lt({ blocking: oe }), G = rt({
|
|
332
|
+
sheetRef: u,
|
|
333
|
+
backdropRef: P,
|
|
334
|
+
blocking: oe,
|
|
335
|
+
onEscape: () => B()
|
|
336
|
+
}), Q = x(!1), X = x(!1), Ye = () => {
|
|
337
|
+
n.canBackdropClose && B();
|
|
338
|
+
}, M = () => {
|
|
339
|
+
const s = window.visualViewport;
|
|
340
|
+
if (!s || !i.value) {
|
|
341
|
+
C.value = 0;
|
|
342
|
+
return;
|
|
343
|
+
}
|
|
344
|
+
const l = Math.max(0, window.innerHeight - s.height - s.offsetTop);
|
|
345
|
+
C.value = Math.round(l);
|
|
346
|
+
};
|
|
347
|
+
let re = null;
|
|
348
|
+
const De = () => {
|
|
349
|
+
const s = window.visualViewport;
|
|
350
|
+
s && (s.addEventListener("resize", M), s.addEventListener("scroll", M), window.addEventListener("resize", M), re = () => {
|
|
351
|
+
s.removeEventListener("resize", M), s.removeEventListener("scroll", M), window.removeEventListener("resize", M);
|
|
352
|
+
});
|
|
353
|
+
}, j = async () => {
|
|
354
|
+
if (Q.value) return;
|
|
355
|
+
i.value = !0, Q.value = !0, r("opening-started"), L.lockIfBlocking(), await _(), M();
|
|
356
|
+
const s = u.value;
|
|
357
|
+
T.value = s.getBoundingClientRect().height;
|
|
358
|
+
const l = s.querySelector("[data-vsbs-content]"), c = s.querySelector("[data-vsbs-header]"), K = s.querySelector("[data-vsbs-footer]");
|
|
359
|
+
if (ae(
|
|
360
|
+
c.getBoundingClientRect().height,
|
|
361
|
+
l.getBoundingClientRect().height,
|
|
362
|
+
K.getBoundingClientRect().height
|
|
363
|
+
), await _(), D.value = z.value.findIndex(
|
|
364
|
+
(O) => O === W.value
|
|
365
|
+
), n.initialSnapPoint !== void 0) {
|
|
366
|
+
const O = n.initialSnapPoint;
|
|
367
|
+
if (O < 0 || O >= S.value.length) {
|
|
453
368
|
console.warn("Index out of bounds");
|
|
454
369
|
return;
|
|
455
370
|
}
|
|
456
|
-
const
|
|
457
|
-
if (!
|
|
458
|
-
|
|
371
|
+
const de = S.value[O];
|
|
372
|
+
if (!de) return;
|
|
373
|
+
k.value = Ce(de, g.value);
|
|
459
374
|
} else
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
i.value && (
|
|
464
|
-
},
|
|
465
|
-
}),
|
|
466
|
-
},
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
},
|
|
470
|
-
},
|
|
471
|
-
if (!
|
|
472
|
-
if (
|
|
375
|
+
k.value = E(W.value, { max: g.value });
|
|
376
|
+
a.value = k.value, requestAnimationFrame(() => {
|
|
377
|
+
a.value = 0, n.blocking && setTimeout(() => {
|
|
378
|
+
i.value && (r("opened"), G.activate());
|
|
379
|
+
}, n.duration);
|
|
380
|
+
}), Q.value = !1;
|
|
381
|
+
}, B = () => {
|
|
382
|
+
X.value || (i.value = !1, X.value = !0, r("closing-started"), L.unlockIfBlocking(), G.deactivate(), a.value = k.value, setTimeout(() => {
|
|
383
|
+
r("closed"), X.value = !1;
|
|
384
|
+
}, n.duration));
|
|
385
|
+
}, J = (s) => {
|
|
386
|
+
if (!S.value) return;
|
|
387
|
+
if (s < 0 || s >= S.value.length) {
|
|
473
388
|
console.warn("Index out of bounds");
|
|
474
389
|
return;
|
|
475
390
|
}
|
|
476
|
-
|
|
477
|
-
const
|
|
478
|
-
|
|
479
|
-
},
|
|
480
|
-
|
|
481
|
-
|
|
391
|
+
D.value = s;
|
|
392
|
+
const l = S.value[s];
|
|
393
|
+
l && (k.value = Ce(l, g.value), r("snapped", S.value.indexOf(l)));
|
|
394
|
+
}, {
|
|
395
|
+
isDragging: Le,
|
|
396
|
+
handleSheetScroll: le,
|
|
397
|
+
handlePointerDown: se,
|
|
398
|
+
handleContentPointerDown: ie,
|
|
399
|
+
handlePointerMove: q,
|
|
400
|
+
handleContentPointerMove: ue,
|
|
401
|
+
handleLostPointerCapture: Z,
|
|
402
|
+
handleTouchStart: ce
|
|
403
|
+
} = ot({
|
|
404
|
+
sheetHeaderRef: f,
|
|
405
|
+
sheetFooterRef: d,
|
|
406
|
+
sheetContentRef: m,
|
|
407
|
+
sheetScrollRef: h,
|
|
408
|
+
height: k,
|
|
409
|
+
translateY: a,
|
|
410
|
+
minSnapPoint: W,
|
|
411
|
+
maxSnapPoint: Ee,
|
|
412
|
+
closestSnapPointIndex: xe,
|
|
413
|
+
flattenedSnapPoints: z,
|
|
414
|
+
canSwipeClose: ye,
|
|
415
|
+
expandOnContentDrag: He,
|
|
416
|
+
swipeCloseThreshold: Me,
|
|
417
|
+
onClose: B,
|
|
418
|
+
onSnapToPoint: J,
|
|
419
|
+
onDraggingUp: () => r("dragging-up"),
|
|
420
|
+
onDraggingDown: () => r("dragging-down")
|
|
421
|
+
}), Ie = Xe((s) => J(s), {
|
|
422
|
+
minQuietPeriodMs: n.duration,
|
|
423
|
+
reducer: (s, l) => l
|
|
482
424
|
});
|
|
483
|
-
|
|
484
|
-
if (i.value === !1 || !
|
|
485
|
-
const
|
|
486
|
-
!
|
|
487
|
-
}),
|
|
488
|
-
|
|
489
|
-
}),
|
|
490
|
-
|
|
491
|
-
}),
|
|
492
|
-
|
|
425
|
+
A(S, (s, l) => {
|
|
426
|
+
if (i.value === !1 || !s || !l) return;
|
|
427
|
+
const c = s[D.value], K = l[D.value];
|
|
428
|
+
!c || typeof c == "string" || !K || typeof K == "string" || (k.value = E(c, { max: g.value }));
|
|
429
|
+
}), A(g, () => {
|
|
430
|
+
Ie.call(D.value);
|
|
431
|
+
}), A(N, (s) => {
|
|
432
|
+
r("instinctHeight", s);
|
|
433
|
+
}), Fe(() => {
|
|
434
|
+
re?.(), G.cleanup();
|
|
493
435
|
});
|
|
494
|
-
const
|
|
495
|
-
const
|
|
496
|
-
|
|
436
|
+
const Re = (s) => {
|
|
437
|
+
const l = s;
|
|
438
|
+
l.style.transition = `transform ${n.duration}ms ease, height ${n.duration}ms ease`, l.style.transform = `translateY(${p.value}px)`;
|
|
497
439
|
};
|
|
498
|
-
return
|
|
499
|
-
(
|
|
500
|
-
to:
|
|
501
|
-
defer:
|
|
440
|
+
return t({ open: j, close: B, snapToPoint: J }), (s, l) => ($(), ee($e, null, [
|
|
441
|
+
($(), fe(ve, {
|
|
442
|
+
to: e.teleportTo,
|
|
443
|
+
defer: e.teleportDefer
|
|
502
444
|
}, [
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
445
|
+
V("div", null, [
|
|
446
|
+
he(ge, { name: "vsbs-backdrop" }, {
|
|
447
|
+
default: me(() => [
|
|
448
|
+
v(i) && e.blocking ? ($(), ee("div", {
|
|
449
|
+
key: 0,
|
|
450
|
+
ref_key: "backdrop",
|
|
451
|
+
ref: P,
|
|
452
|
+
"data-vsbs-backdrop": "",
|
|
453
|
+
onClick: l[0] || (l[0] = (c) => Ye())
|
|
454
|
+
}, null, 512)) : pe("", !0)
|
|
455
|
+
]),
|
|
456
|
+
_: 1
|
|
457
|
+
})
|
|
458
|
+
])
|
|
515
459
|
], 8, ["to", "defer"])),
|
|
516
|
-
(
|
|
517
|
-
to:
|
|
518
|
-
defer:
|
|
460
|
+
($(), fe(ve, {
|
|
461
|
+
to: e.teleportTo,
|
|
462
|
+
defer: e.teleportDefer
|
|
519
463
|
}, [
|
|
520
|
-
ge
|
|
464
|
+
he(ge, {
|
|
521
465
|
name: "vsbs-sheet",
|
|
522
|
-
onLeave:
|
|
466
|
+
onLeave: Re
|
|
523
467
|
}, {
|
|
524
|
-
default:
|
|
525
|
-
|
|
468
|
+
default: me(() => [
|
|
469
|
+
v(i) ? ($(), ee("div", {
|
|
526
470
|
key: 0,
|
|
527
471
|
ref_key: "sheet",
|
|
528
|
-
ref:
|
|
529
|
-
style:
|
|
530
|
-
transform: `translateY(${
|
|
531
|
-
height: `${
|
|
532
|
-
|
|
472
|
+
ref: u,
|
|
473
|
+
style: Ve({
|
|
474
|
+
transform: `translateY(${a.value}px)`,
|
|
475
|
+
height: `${p.value}px`,
|
|
476
|
+
paddingBottom: `${C.value}px`,
|
|
477
|
+
transition: v(Le) ? "none" : `transform ${e.duration}ms ease, height ${e.duration}ms ease`
|
|
533
478
|
}),
|
|
534
|
-
"data-vsbs-shadow": !
|
|
535
|
-
"data-vsbs-sheet-show":
|
|
479
|
+
"data-vsbs-shadow": !e.blocking,
|
|
480
|
+
"data-vsbs-sheet-show": v(i),
|
|
536
481
|
"aria-modal": "true",
|
|
537
482
|
"data-vsbs-sheet": "",
|
|
538
483
|
tabindex: "-1",
|
|
539
|
-
onTouchstart:
|
|
540
|
-
(...
|
|
541
|
-
onTouchend:
|
|
542
|
-
(...
|
|
484
|
+
onTouchstart: l[12] || (l[12] = //@ts-ignore
|
|
485
|
+
(...c) => v(L).touchStartHandler && v(L).touchStartHandler(...c)),
|
|
486
|
+
onTouchend: l[13] || (l[13] = //@ts-ignore
|
|
487
|
+
(...c) => v(L).touchEndHandler && v(L).touchEndHandler(...c))
|
|
543
488
|
}, [
|
|
544
|
-
|
|
489
|
+
V("div", {
|
|
545
490
|
ref_key: "sheetHeader",
|
|
546
|
-
ref:
|
|
547
|
-
"data-vsbs-header": ""
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
491
|
+
ref: f,
|
|
492
|
+
"data-vsbs-header": "",
|
|
493
|
+
class: te(e.headerClass),
|
|
494
|
+
onPointerdown: l[1] || (l[1] = (c) => v(se)(c, "header")),
|
|
495
|
+
onPointermove: l[2] || (l[2] = //@ts-ignore
|
|
496
|
+
(...c) => v(q) && v(q)(...c)),
|
|
497
|
+
onLostpointercapture: l[3] || (l[3] = (c) => v(Z)(c, "header"))
|
|
498
|
+
}, [
|
|
499
|
+
ne(s.$slots, "header", {}, void 0, !0)
|
|
500
|
+
], 34),
|
|
501
|
+
V("div", {
|
|
555
502
|
ref_key: "sheetScroll",
|
|
556
|
-
ref:
|
|
503
|
+
ref: h,
|
|
557
504
|
"data-vsbs-scroll": "",
|
|
558
|
-
|
|
559
|
-
(...
|
|
505
|
+
onTouchstart: l[4] || (l[4] = //@ts-ignore
|
|
506
|
+
(...c) => v(ce) && v(ce)(...c)),
|
|
507
|
+
onTouchmove: l[5] || (l[5] = //@ts-ignore
|
|
508
|
+
(...c) => v(le) && v(le)(...c)),
|
|
509
|
+
onPointerdown: l[6] || (l[6] = //@ts-ignore
|
|
510
|
+
(...c) => v(ie) && v(ie)(...c)),
|
|
511
|
+
onPointermove: l[7] || (l[7] = //@ts-ignore
|
|
512
|
+
(...c) => v(ue) && v(ue)(...c)),
|
|
513
|
+
onLostpointercapture: l[8] || (l[8] = (c) => v(Z)(c, "content"))
|
|
560
514
|
}, [
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
},
|
|
568
|
-
|
|
569
|
-
], 2)
|
|
570
|
-
], 16)
|
|
515
|
+
V("div", {
|
|
516
|
+
ref_key: "sheetContent",
|
|
517
|
+
ref: m,
|
|
518
|
+
"data-vsbs-content": "",
|
|
519
|
+
class: te(e.contentClass)
|
|
520
|
+
}, [
|
|
521
|
+
ne(s.$slots, "default", {}, void 0, !0)
|
|
522
|
+
], 2)
|
|
571
523
|
], 544),
|
|
572
|
-
|
|
524
|
+
V("div", {
|
|
573
525
|
ref_key: "sheetFooter",
|
|
574
|
-
ref:
|
|
575
|
-
"data-vsbs-footer": ""
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
526
|
+
ref: d,
|
|
527
|
+
"data-vsbs-footer": "",
|
|
528
|
+
class: te(e.footerClass),
|
|
529
|
+
onPointerdown: l[9] || (l[9] = (c) => v(se)(c, "footer")),
|
|
530
|
+
onPointermove: l[10] || (l[10] = //@ts-ignore
|
|
531
|
+
(...c) => v(q) && v(q)(...c)),
|
|
532
|
+
onLostpointercapture: l[11] || (l[11] = (c) => v(Z)(c, "footer"))
|
|
533
|
+
}, [
|
|
534
|
+
ne(s.$slots, "footer", {}, void 0, !0)
|
|
535
|
+
], 34)
|
|
536
|
+
], 44, it)) : pe("", !0)
|
|
583
537
|
]),
|
|
584
538
|
_: 3
|
|
585
539
|
})
|
|
586
540
|
], 8, ["to", "defer"]))
|
|
587
541
|
], 64));
|
|
588
542
|
}
|
|
589
|
-
}),
|
|
590
|
-
const
|
|
591
|
-
for (const [
|
|
592
|
-
|
|
593
|
-
return
|
|
594
|
-
},
|
|
543
|
+
}), ct = (e, t) => {
|
|
544
|
+
const o = e.__vccOpts || e;
|
|
545
|
+
for (const [n, r] of t)
|
|
546
|
+
o[n] = r;
|
|
547
|
+
return o;
|
|
548
|
+
}, ht = /* @__PURE__ */ ct(ut, [["__scopeId", "data-v-efbe17f6"]]);
|
|
595
549
|
export {
|
|
596
|
-
|
|
550
|
+
ht as default
|
|
597
551
|
};
|
package/dist/style.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
[data-vsbs-backdrop][data-v-
|
|
1
|
+
[data-vsbs-backdrop][data-v-efbe17f6]{background-color:var(--vsbs-backdrop-bg, rgba(0, 0, 0, .5));inset:0;pointer-events:auto;position:fixed;-webkit-user-select:none;user-select:none;will-change:opacity;--vsbs-duration: var(--v7643c7ff)}[data-vsbs-shadow=true][data-v-efbe17f6]:before{content:"";z-index:-1;position:absolute;top:0;height:100lvh;width:100%;border-radius:var(--vsbs-border-radius, 16px);box-shadow:0 -5px 60px 0 var(--vsbs-shadow-color, rgba(89, 89, 89, .2))}[data-vsbs-sheet][data-v-efbe17f6]{background-color:var(--vsbs-background, #fff);box-sizing:border-box;border-top-left-radius:var(--vsbs-border-radius, 16px);border-top-right-radius:var(--vsbs-border-radius, 16px);border-right:1px solid var(--vsbs-outer-border-color, transparent);border-left:1px solid var(--vsbs-outer-border-color, transparent);bottom:0;display:flex;flex-direction:column;left:0;margin-left:auto;margin-right:auto;max-width:var(--vsbs-max-width, 640px);pointer-events:all;position:fixed;right:0;width:100%;will-change:height,transform}[data-vsbs-sheet-show=true][data-v-efbe17f6]{visibility:visible}[data-vsbs-header][data-v-efbe17f6]{touch-action:none;box-shadow:0 1px 0 var(--vsbs-border-color, rgba(46, 59, 66, .125));flex-shrink:0;padding:20px var(--vsbs-padding-x, 16px) 8px;-webkit-user-select:none;user-select:none;z-index:3;border-top-left-radius:var(--vsbs-border-radius, 16px);border-top-right-radius:var(--vsbs-border-radius, 16px);border-top:1px solid var(--vsbs-outer-border-color, transparent)}[data-vsbs-header][data-v-efbe17f6]:before{background-color:var(--vsbs-handle-background, rgba(0, 0, 0, .28));border-radius:2px;content:"";display:block;height:4px;left:50%;position:absolute;top:8px;transform:translate(-50%);width:36px}[data-vsbs-header][data-v-efbe17f6]:empty{box-shadow:none;padding:14px var(--vsbs-padding-x, 16px) 10px}[data-vsbs-footer][data-v-efbe17f6]{touch-action:none;box-shadow:0 -1px 0 var(--vsbs-border-color, rgba(46, 59, 66, .125));flex-grow:0;flex-shrink:0;padding:16px var(--vsbs-padding-x, 16px);-webkit-user-select:none;user-select:none}[data-vsbs-footer][data-v-efbe17f6]:empty{display:none}[data-vsbs-scroll][data-v-efbe17f6]{flex-grow:1;overflow-y:auto;overscroll-behavior:none}[data-vsbs-content][data-v-efbe17f6]{display:grid;padding:8px var(--vsbs-padding-x, 16px);-webkit-user-select:none;user-select:none}.vsbs-backdrop-enter-active[data-v-efbe17f6],.vsbs-backdrop-leave-active[data-v-efbe17f6]{transition:opacity var(--vsbs-duration) ease}.vsbs-backdrop-enter-from[data-v-efbe17f6],.vsbs-backdrop-leave-to[data-v-efbe17f6]{opacity:0}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isInteractable(element: Element): boolean;
|