@douxcode/vue-spring-bottom-sheet 3.0.0-next.6 → 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 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 { ref } from 'vue'
28
+ import { useTemplateRef } from 'vue'
29
29
 
30
- const bottomSheet = ref(null)
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 | Default | Description |
134
- | ------------------- | ------------------------- | ---------------- | ------------------------------------------------------------------------- |
135
- | duration | Number | 250 | Animation duration in milliseconds |
136
- | snapPoints | Array<number\|string> | [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\|String | "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 |
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
 
@@ -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 { Ref, ComputedRef, ShallowRef } from 'vue';
2
- export interface UseDragGesturesOptions {
3
- sheetRef: ShallowRef<HTMLElement | null>;
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
- sheetHeight: Ref<number>;
8
- windowHeight: Ref<number>;
9
- snapPointsRef: ComputedRef<Array<number | `${number}%`>>;
10
- flattenedSnapPoints: ComputedRef<number[]>;
11
- currentSnapPointIndex: Ref<number>;
12
- closestSnapPointIndex: ComputedRef<number>;
13
- minSnapPoint: ComputedRef<number>;
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
- onSnapped: (index: number) => void;
20
- onDraggingUp: () => void;
21
- onDraggingDown: () => void;
20
+ onSnapToPoint: (index: number) => void;
21
+ onDraggingUp?: () => void;
22
+ onDraggingDown?: () => void;
22
23
  }
23
- /**
24
- * Composable that handles all drag/pan gesture logic for the bottom sheet.
25
- * Manages header/footer dragging, content area dragging, and snap point navigation.
26
- */
27
- export declare function useDragGestures(options: UseDragGesturesOptions): {
28
- isDragging: Ref<boolean, boolean>;
29
- preventContentScroll: Ref<boolean, boolean>;
30
- headerFooterHandlers: ComputedRef<{
31
- onPointerdown: (event: PointerEvent) => void;
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 interface UseSwipeDetectionOptions {
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 P, computed as D, defineComponent as ye, useCssVars as Ee, watch as te, onMounted as De, shallowRef as q, toRefs as He, nextTick as fe, onUnmounted as Be, openBlock as X, createElementBlock as ie, Fragment as Ie, createBlock as pe, Teleport as he, createVNode as ge, Transition as me, withCtx as Se, unref as E, createCommentVNode as be, normalizeStyle as Me, createElementVNode as j, mergeProps as ce, renderSlot as ve, normalizeClass as Ye } from "vue";
2
- import { useScrollLock as Pe, useVModel as Re, useWindowSize as Oe, useElementBounding as ne } from "@vueuse/core";
3
- import { useFocusTrap as Ae } from "@vueuse/integrations/useFocusTrap";
4
- function Te(t, a) {
5
- const u = parseFloat(t);
6
- return a * u / 100;
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 Le(t, a, u) {
9
- const e = P(0), n = D(() => t.value.map((f) => typeof f == "string" ? Te(f, u.value) : f)), i = D(() => Math.min(...n.value)), r = D(() => Math.max(...n.value)), p = D(() => {
10
- const f = n.value.reduce(
11
- (b, v) => Math.abs(v - a.value) < Math.abs(b - a.value) ? v : b
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 I(...t) {
34
- return $e(Ne, t);
14
+ function E(...e) {
15
+ return We(Ge, e);
35
16
  }
36
- const Ne = (t, { min: a, max: u }) => a !== void 0 && t < a ? a : u !== void 0 && t > u ? u : t, ke = /* @__PURE__ */ Symbol("funnel/voidReducer"), Ve = () => ke;
37
- function Ue(t, { triggerAt: a = "end", minQuietPeriodMs: u, maxBurstDurationMs: e, minGapMs: n, reducer: i = Ve }) {
38
- let r, p, f, b, v = () => {
39
- let g = f;
40
- g !== void 0 && (f = void 0, g === ke ? t() : t(g), n !== void 0 && (p = setTimeout(d, n)));
41
- }, d = () => {
42
- clearTimeout(p), p = void 0, r === void 0 && v();
43
- }, h = () => {
44
- clearTimeout(r), r = void 0, b = void 0, p === void 0 && v();
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 w = r === void 0 && p === void 0;
48
- if ((a !== "start" || w) && (f = i(f, ...g)), !(r === void 0 && !w)) {
49
- if (u !== void 0 || e !== void 0 || n === void 0) {
50
- clearTimeout(r);
51
- let C = Date.now();
52
- b ??= C;
53
- let x = e === void 0 ? u ?? 0 : Math.min(u ?? e, Math.max(0, e - (C - b)));
54
- r = setTimeout(h, x);
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
- a !== "end" && w && v();
37
+ t !== "end" && T && m();
57
38
  }
58
39
  }, cancel: () => {
59
- clearTimeout(r), r = void 0, b = void 0, clearTimeout(p), p = void 0, f = void 0;
40
+ clearTimeout(u), u = void 0, h = void 0, clearTimeout(f), f = void 0, d = void 0;
60
41
  }, flush: () => {
61
- h(), d();
42
+ C(), P();
62
43
  }, get isIdle() {
63
- return r === void 0 && p === void 0;
44
+ return u === void 0 && f === void 0;
64
45
  } };
65
46
  }
66
- function We(t = {}) {
67
- const { velocityThreshold: a = 0.5 } = t, u = P(0), e = P(0), n = P(0), i = P(0), r = P([]);
68
- return {
69
- start: (v) => {
70
- const d = performance.now();
71
- u.value = v, e.value = d, n.value = v, i.value = d, r.value = [{ y: v, time: d }];
72
- },
73
- update: (v) => {
74
- const d = performance.now();
75
- n.value = v, i.value = d, r.value.push({ y: v, time: d });
76
- const h = d - 100;
77
- r.value = r.value.filter((g) => g.time > h).slice(-5);
78
- },
79
- end: () => {
80
- const v = r.value;
81
- let d = 0;
82
- if (v.length >= 2) {
83
- const w = v[0], C = v[v.length - 1];
84
- if (w && C) {
85
- const x = C.y - w.y, R = C.time - w.time;
86
- R > 0 && (d = x / R);
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 qe(t, a, u) {
100
- return Math.max(a, Math.min(t, u));
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
- function ze(t, a) {
103
- return Math.pow(t, a * 5);
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 we(t, a, u) {
106
- return a === 0 || Math.abs(a) === 1 / 0 ? ze(t, u) : t * a * u / (a + u * t);
86
+ function nt(e, t, o) {
87
+ return Math.max(t, Math.min(e, o));
107
88
  }
108
- function de(t, a, u, e = 0.15) {
109
- return e === 0 ? qe(t, a, u) : t < a ? -we(a - t, u - a, e) + a : t > u ? +we(t - u, u - a, e) + u : t;
89
+ function at(e, t) {
90
+ return Math.pow(e, t * 5);
110
91
  }
111
- function ae(t, a) {
112
- return typeof t == "number" ? I(t, { max: a }) : Te(t, a);
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 Ce(t, a) {
115
- if (t === void 0)
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 Ge = 10, Qe = 3, Xe = 0.25, xe = 0.5, je = 0.5;
126
- function Ke(t) {
127
- const {
128
- sheetRef: a,
129
- sheetScrollRef: u,
130
- height: e,
131
- translateY: n,
132
- sheetHeight: i,
133
- windowHeight: r,
134
- snapPointsRef: p,
135
- flattenedSnapPoints: f,
136
- currentSnapPointIndex: b,
137
- closestSnapPointIndex: v,
138
- minSnapPoint: d,
139
- maxSnapPoint: h,
140
- canSwipeClose: g,
141
- swipeCloseThreshold: w,
142
- expandOnContentDrag: C,
143
- onClose: x,
144
- onSnapped: R,
145
- onDraggingUp: oe,
146
- onDraggingDown: H
147
- } = t, T = P(!1), F = P(0), V = P(0), k = P(0), M = P(0), B = P(!0), S = P(!0), O = We({ velocityThreshold: je }), K = (o) => {
148
- o > 0 ? H() : o < 0 && oe();
149
- }, z = () => {
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
- } else
215
- n.value = 0;
216
- if (n.value === e.value) {
217
- n.value = 0, x();
218
- return;
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
- }, re = (o) => {
222
- if (!u.value) return;
223
- const c = u.value.scrollTop === 0, l = o > 0, s = f.value.length === 1, m = 0.5 > Math.abs(e.value - h.value);
224
- if (s) {
225
- if (!C.value) {
226
- S.value = !1;
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
- S.value = !0, m && (l && c && (S.value = !0), !l && c && (S.value = !1), c || (S.value = !1));
236
- }
237
- }, J = (o) => {
238
- 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, B.value = !0, O.start(o.clientY), o.target.setPointerCapture(o.pointerId));
239
- }, se = (o) => {
240
- if (!T.value) return;
241
- if (o.buttons !== 1) {
242
- U(o);
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
- if (!C.value) {
246
- S.value = !1;
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
- const c = o.clientY - F.value, l = o.clientY, s = o.clientY - M.value;
250
- if (B.value) {
251
- const Y = o.clientY - F.value;
252
- if (Math.abs(Y) > Qe)
253
- B.value = !1, re(Y);
254
- else {
255
- M.value = l;
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
- n.value === 0 && S.value && C.value && (e.value = V.value - c), e.value <= d.value && (e.value = d.value, S.value && C.value && (n.value = k.value + c), n.value = I(n.value, { min: 0, max: d.value }), g.value ? n.value = I(n.value, { min: 0 }) : n.value = I(
260
- de(
261
- n.value,
262
- -i.value,
263
- 0,
264
- xe
265
- ),
266
- { min: 0 }
267
- )), e.value > h.value && (e.value = h.value), e.value = I(e.value, { max: r.value }), f.value.length === 1 || e.value === h.value && (S.value = !1), K(s), O.update(o.clientY), M.value = l;
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
- } else
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
- const c = S.value;
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
- lock: n,
324
- unlock: i,
325
- lockIfBlocking: () => {
326
- a.value && n();
327
- },
328
- unlockIfBlocking: () => {
329
- a.value && i();
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
- touchStartHandler: () => {
332
- a.value || n();
333
- },
334
- touchEndHandler: () => {
335
- a.value || i();
201
+ handleTouchStart: (a) => {
202
+ be(a.target) || d && a.preventDefault();
336
203
  }
337
204
  };
338
- }
339
- function Je(t) {
340
- const { sheetRef: a, backdropRef: u, blocking: e, onEscape: n } = t, i = P(null), r = Ae([a, u], {
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: () => a.value || document.body
343
- }), p = (g) => {
344
- g.key === "Escape" && n();
345
- }, f = () => {
346
- a.value && (i.value = new MutationObserver((g) => {
347
- for (const w of g)
348
- w.type === "attributes" && w.attributeName === "aria-expanded" && (w.target.getAttribute("aria-expanded") === "true" ? r.pause() : a.value?.querySelector('[aria-expanded="true"]') || r.unpause());
349
- }), i.value.observe(a.value, {
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
- }, b = () => {
221
+ }, h = () => {
355
222
  i.value && (i.value.disconnect(), i.value = null);
356
223
  };
357
224
  return {
358
225
  activate: () => {
359
- e.value && (r.activate(), f()), window.addEventListener("keydown", p);
226
+ n.value && (u.activate(), d()), window.addEventListener("keydown", f);
360
227
  },
361
228
  deactivate: () => {
362
- window.removeEventListener("keydown", p), b(), e.value && r.deactivate();
229
+ window.removeEventListener("keydown", f), h(), n.value && u.deactivate();
363
230
  },
364
231
  cleanup: () => {
365
- b(), r.deactivate();
232
+ h(), u.deactivate();
366
233
  }
367
234
  };
368
235
  }
369
- const Ze = ["data-vsbs-shadow", "data-vsbs-sheet-show"], et = /* @__PURE__ */ ye({
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(t, { expose: a, emit: u }) {
389
- Ee((l) => ({
390
- v76198695: F.value
300
+ setup(e, { expose: t, emit: o }) {
301
+ Oe((s) => ({
302
+ v7643c7ff: b.value
391
303
  }));
392
- const e = t, n = u, i = Re(e, "modelValue", n, {
304
+ const n = e, r = o, i = ze(n, "modelValue", r, {
393
305
  passive: !0
394
306
  });
395
- te(i, (l) => {
396
- l ? Q() : N();
397
- }), De(() => {
398
- i.value && Q();
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 r = q(null), p = q(null), f = q(null), b = q(null), v = q(null), d = q(null), { height: h } = Oe(), { height: g } = ne(r), { height: w } = ne(p), { height: C } = ne(v), { height: x } = ne(f), R = D(() => I(
401
- Math.ceil(C.value + w.value + x.value),
402
- { max: h.value }
403
- )), oe = (l, s, m) => {
404
- w.value = l, C.value = s, x.value = m;
405
- }, H = P(0), T = P(0), F = D(() => e.duration + "ms"), { snapPoints: V } = He(e), k = D(() => V.value ?? [R.value]), {
406
- flattenedSnapPoints: M,
407
- currentSnapPointIndex: B,
408
- closestSnapPointIndex: S,
409
- minSnapPoint: O,
410
- maxSnapPoint: K
411
- } = Le(k, H, h), z = D(() => e.blocking), le = D(() => e.canSwipeClose), _ = D(() => e.swipeCloseThreshold), ue = D(() => e.expandOnContentDrag), A = _e({ blocking: z }), $ = Je({
412
- sheetRef: r,
413
- backdropRef: d,
414
- blocking: z,
415
- onEscape: () => N()
416
- }), { isDragging: re, headerFooterHandlers: J, contentWrapperHandlers: se, scrollEnd: U } = Ke({
417
- sheetRef: r,
418
- sheetScrollRef: b,
419
- height: H,
420
- translateY: T,
421
- sheetHeight: g,
422
- windowHeight: h,
423
- snapPointsRef: k,
424
- flattenedSnapPoints: M,
425
- currentSnapPointIndex: B,
426
- closestSnapPointIndex: S,
427
- minSnapPoint: O,
428
- maxSnapPoint: K,
429
- canSwipeClose: le,
430
- swipeCloseThreshold: _,
431
- expandOnContentDrag: ue,
432
- onClose: () => N(),
433
- onSnapped: (l) => n("snapped", l),
434
- onDraggingUp: () => n("dragging-up"),
435
- onDraggingDown: () => n("dragging-down")
436
- }), W = P(!1), G = P(!1), Z = () => {
437
- e.canBackdropClose && N();
438
- }, Q = async () => {
439
- if (W.value) return;
440
- i.value = !0, W.value = !0, n("opening-started"), A.lockIfBlocking(), await fe();
441
- const l = r.value;
442
- g.value = l.getBoundingClientRect().height;
443
- const s = l.querySelector("[data-vsbs-content]"), m = l.querySelector("[data-vsbs-header]"), Y = l.querySelector("[data-vsbs-footer]");
444
- if (oe(
445
- m.getBoundingClientRect().height,
446
- s.getBoundingClientRect().height,
447
- Y.getBoundingClientRect().height
448
- ), await fe(), B.value = M.value.findIndex(
449
- (y) => y === O.value
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 L = k.value[y];
457
- if (!L) return;
458
- H.value = ae(L, h.value);
371
+ const de = S.value[O];
372
+ if (!de) return;
373
+ k.value = Ce(de, g.value);
459
374
  } else
460
- H.value = I(O.value, { max: h.value });
461
- T.value = H.value, requestAnimationFrame(() => {
462
- T.value = 0, e.blocking && setTimeout(() => {
463
- i.value && (n("opened"), $.activate());
464
- }, e.duration);
465
- }), W.value = !1;
466
- }, N = () => {
467
- G.value || (i.value = !1, G.value = !0, n("closing-started"), A.unlockIfBlocking(), $.deactivate(), T.value = H.value, setTimeout(() => {
468
- n("closed"), G.value = !1;
469
- }, e.duration));
470
- }, ee = (l) => {
471
- if (!k.value) return;
472
- if (l < 0 || l >= k.value.length) {
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
- B.value = l;
477
- const s = k.value[l];
478
- s && (H.value = ae(s, h.value), n("snapped", k.value.indexOf(s)));
479
- }, o = Ue((l) => ee(l), {
480
- minQuietPeriodMs: e.duration,
481
- reducer: (l, s) => s
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
- te(k, (l, s) => {
484
- if (i.value === !1 || !l || !s) return;
485
- const m = l[B.value], Y = s[B.value];
486
- !m || typeof m == "string" || !Y || typeof Y == "string" || (H.value = I(m, { max: h.value }));
487
- }), te(h, () => {
488
- o.call(B.value);
489
- }), te(R, (l) => {
490
- n("instinctHeight", l);
491
- }), Be(() => {
492
- $.cleanup();
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 c = (l) => {
495
- const s = l;
496
- s.style.transition = `transform ${e.duration}ms ease, height ${e.duration}ms ease`, s.style.transform = `translateY(${H.value}px)`;
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 a({ open: Q, close: N, snapToPoint: ee }), (l, s) => (X(), ie(Ie, null, [
499
- (X(), pe(he, {
500
- to: t.teleportTo,
501
- defer: t.teleportDefer
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
- ge(me, { name: "vsbs-backdrop" }, {
504
- default: Se(() => [
505
- E(i) && t.blocking ? (X(), ie("div", {
506
- key: 0,
507
- ref_key: "backdrop",
508
- ref: d,
509
- "data-vsbs-backdrop": "",
510
- onClick: s[0] || (s[0] = (m) => Z())
511
- }, null, 512)) : be("", !0)
512
- ]),
513
- _: 1
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
- (X(), pe(he, {
517
- to: t.teleportTo,
518
- defer: t.teleportDefer
460
+ ($(), fe(ve, {
461
+ to: e.teleportTo,
462
+ defer: e.teleportDefer
519
463
  }, [
520
- ge(me, {
464
+ he(ge, {
521
465
  name: "vsbs-sheet",
522
- onLeave: c
466
+ onLeave: Re
523
467
  }, {
524
- default: Se(() => [
525
- E(i) ? (X(), ie("div", {
468
+ default: me(() => [
469
+ v(i) ? ($(), ee("div", {
526
470
  key: 0,
527
471
  ref_key: "sheet",
528
- ref: r,
529
- style: Me({
530
- transform: `translateY(${T.value}px)`,
531
- height: `${H.value}px`,
532
- transition: E(re) ? "none" : `transform ${t.duration}ms ease, height ${t.duration}ms ease`
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": !t.blocking,
535
- "data-vsbs-sheet-show": E(i),
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: s[2] || (s[2] = //@ts-ignore
540
- (...m) => E(A).touchStartHandler && E(A).touchStartHandler(...m)),
541
- onTouchend: s[3] || (s[3] = //@ts-ignore
542
- (...m) => E(A).touchEndHandler && E(A).touchEndHandler(...m))
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
- j("div", ce({
489
+ V("div", {
545
490
  ref_key: "sheetHeader",
546
- ref: p,
547
- "data-vsbs-header": ""
548
- }, E(J), {
549
- class: t.headerClass,
550
- style: { "touch-action": "none" }
551
- }), [
552
- ve(l.$slots, "header", {}, void 0, !0)
553
- ], 16),
554
- j("div", {
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: b,
503
+ ref: h,
557
504
  "data-vsbs-scroll": "",
558
- onScrollend: s[1] || (s[1] = //@ts-ignore
559
- (...m) => E(U) && E(U)(...m))
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
- j("div", ce({ "data-vsbs-content-wrapper": "" }, E(se), { style: { touchAction: "pan-y" } }), [
562
- j("div", {
563
- ref_key: "sheetContent",
564
- ref: v,
565
- "data-vsbs-content": "",
566
- class: Ye(t.contentClass)
567
- }, [
568
- ve(l.$slots, "default", {}, void 0, !0)
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
- j("div", ce({
524
+ V("div", {
573
525
  ref_key: "sheetFooter",
574
- ref: f,
575
- "data-vsbs-footer": ""
576
- }, E(J), {
577
- class: t.footerClass,
578
- style: { "touch-action": "none" }
579
- }), [
580
- ve(l.$slots, "footer", {}, void 0, !0)
581
- ], 16)
582
- ], 44, Ze)) : be("", !0)
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
- }), tt = (t, a) => {
590
- const u = t.__vccOpts || t;
591
- for (const [e, n] of a)
592
- u[e] = n;
593
- return u;
594
- }, lt = /* @__PURE__ */ tt(et, [["__scopeId", "data-v-533b8a6d"]]);
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
- lt as default
550
+ ht as default
597
551
  };
package/dist/style.css CHANGED
@@ -1 +1 @@
1
- [data-vsbs-backdrop][data-v-533b8a6d]{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(--v76198695)}[data-vsbs-shadow=true][data-v-533b8a6d]: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-533b8a6d]{background-color:var(--vsbs-background, #fff);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-533b8a6d]{visibility:visible}[data-vsbs-header][data-v-533b8a6d]{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-533b8a6d]: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-533b8a6d]:empty{box-shadow:none;padding:14px var(--vsbs-padding-x, 16px) 10px}[data-vsbs-footer][data-v-533b8a6d]{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-533b8a6d]:empty{display:none}[data-vsbs-scroll][data-v-533b8a6d]{flex-grow:1;overflow-y:auto;overscroll-behavior:none}[data-vsbs-content-wrapper][data-v-533b8a6d]{height:100%}[data-vsbs-content][data-v-533b8a6d]{display:grid;padding:8px var(--vsbs-padding-x, 16px);-webkit-user-select:none;user-select:none}.vsbs-backdrop-enter-active[data-v-533b8a6d],.vsbs-backdrop-leave-active[data-v-533b8a6d]{transition:opacity var(--vsbs-duration) ease}.vsbs-backdrop-enter-from[data-v-533b8a6d],.vsbs-backdrop-leave-to[data-v-533b8a6d]{opacity:0}
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}
@@ -1,5 +1,3 @@
1
1
  export declare const SNAP_POINT_TOLERANCE_PX = 10;
2
2
  export declare const MOVEMENT_THRESHOLD_PX = 3;
3
3
  export declare const RUBBERBAND_ELASTICITY = 0.25;
4
- export declare const RUBBERBAND_ELASTICITY_STRONG = 0.5;
5
- export declare const DEFAULT_VELOCITY_THRESHOLD = 0.5;
@@ -0,0 +1 @@
1
+ export declare function isInteractable(element: Element): boolean;
package/package.json CHANGED
@@ -30,7 +30,7 @@
30
30
  "url": "https://github.com/megaarmos/vue-spring-bottom-sheet/issues"
31
31
  },
32
32
  "private": false,
33
- "version": "3.0.0-next.6",
33
+ "version": "3.1.0",
34
34
  "type": "module",
35
35
  "exports": {
36
36
  ".": {