@douxcode/vue-spring-bottom-sheet 2.3.0 → 2.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -8
- package/dist/BottomSheet.d.ts +5 -17
- package/dist/index.mjs +155 -147
- package/dist/style.css +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -143,6 +143,9 @@ For Nuxt 3, just wrap component in `<ClientOnly>`
|
|
|
143
143
|
| expandOnContentDrag | Boolean | true | Enable expanding by dragging content |
|
|
144
144
|
| teleprtTo | String \| RendererElement | body | Teleport to a specific element |
|
|
145
145
|
| teleportDefer | Boolean | false | Defer teleporting until opened (Vue 3.5+ only) |
|
|
146
|
+
| headerClass | String | '' | Set header element class |
|
|
147
|
+
| contentClass | String | '' | Set content element class |
|
|
148
|
+
| footerClass | String | '' | Set footer element class |
|
|
146
149
|
|
|
147
150
|
## Exposed methods
|
|
148
151
|
|
|
@@ -156,14 +159,16 @@ Assuming there is `const bottomSheet = ref()`
|
|
|
156
159
|
|
|
157
160
|
## Events
|
|
158
161
|
|
|
159
|
-
| Event
|
|
160
|
-
| --------------
|
|
161
|
-
| opened
|
|
162
|
-
|
|
|
163
|
-
|
|
|
164
|
-
|
|
|
165
|
-
|
|
|
166
|
-
|
|
|
162
|
+
| Event | Description | Payload |
|
|
163
|
+
| -------------- | -------------------------------------- | ----------------------- |
|
|
164
|
+
| opened | Emitted when sheet finishes opening | - |
|
|
165
|
+
| opening-started | Emitted when sheet starts opening | - |
|
|
166
|
+
| closed | Emitted when sheet finishes closing | - |
|
|
167
|
+
| closing-started | Emitted when sheet starts closing | - |
|
|
168
|
+
| dragging-up | Emitted when user drags sheet upward | - |
|
|
169
|
+
| dragging-down | Emitted when user drags sheet downward | - |
|
|
170
|
+
| instinctHeight | Emitted when content height changes | height (number) |
|
|
171
|
+
| snapped | Emitted when sheet finishes snapping | snapPointIndex (number) |
|
|
167
172
|
|
|
168
173
|
## Acknowledgments
|
|
169
174
|
|
package/dist/BottomSheet.d.ts
CHANGED
|
@@ -22,24 +22,12 @@ declare const __VLS_component: import('vue').DefineComponent<BottomSheetProps, {
|
|
|
22
22
|
open: () => Promise<void>;
|
|
23
23
|
close: () => void;
|
|
24
24
|
snapToPoint: (index: number) => void;
|
|
25
|
-
}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
"dragging-up": () => any;
|
|
30
|
-
"dragging-down": () => any;
|
|
31
|
-
snapped: (snapPointIndex?: number | undefined) => any;
|
|
32
|
-
instinctHeight: (instinctHeight: number) => any;
|
|
33
|
-
"update:modelValue": () => any;
|
|
25
|
+
}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
26
|
+
[x: string]: any;
|
|
27
|
+
} & {
|
|
28
|
+
[x: string]: any;
|
|
34
29
|
}, string, import('vue').PublicProps, Readonly<BottomSheetProps> & Readonly<{
|
|
35
|
-
|
|
36
|
-
onClosed?: (() => any) | undefined;
|
|
37
|
-
onReady?: (() => any) | undefined;
|
|
38
|
-
"onDragging-up"?: (() => any) | undefined;
|
|
39
|
-
"onDragging-down"?: (() => any) | undefined;
|
|
40
|
-
onSnapped?: ((snapPointIndex?: number | undefined) => any) | undefined;
|
|
41
|
-
onInstinctHeight?: ((instinctHeight: number) => any) | undefined;
|
|
42
|
-
"onUpdate:modelValue"?: (() => any) | undefined;
|
|
30
|
+
[x: `on${Capitalize<any>}`]: ((...args: any) => any) | undefined;
|
|
43
31
|
}>, {
|
|
44
32
|
duration: number;
|
|
45
33
|
blocking: boolean;
|
package/dist/index.mjs
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { ref as P, computed as _, defineComponent as
|
|
2
|
-
import { useMotionValue as
|
|
3
|
-
import { useVModel as
|
|
4
|
-
import { useFocusTrap as
|
|
1
|
+
import { ref as P, computed as _, defineComponent as Be, watch as q, onMounted as Ie, toRefs as Ee, nextTick as N, onUnmounted as _e, createBlock as te, openBlock as ae, Teleport as De, createElementVNode as ne, createVNode as A, unref as m, withCtx as E, createCommentVNode as ge, normalizeStyle as He, normalizeClass as oe, renderSlot as le } from "vue";
|
|
2
|
+
import { useMotionValue as me, animate as B, AnimatePresence as be, Motion as $ } from "motion-v";
|
|
3
|
+
import { useVModel as Ve, useWindowSize as Fe, useElementBounding as Q, useScrollLock as ye } from "@vueuse/core";
|
|
4
|
+
import { useFocusTrap as Re } from "@vueuse/integrations/useFocusTrap";
|
|
5
5
|
function G(n, a) {
|
|
6
6
|
const o = parseFloat(n);
|
|
7
7
|
return a * o / 100;
|
|
8
8
|
}
|
|
9
|
-
function
|
|
9
|
+
function Ae(n, a, o) {
|
|
10
10
|
const t = P(0), s = _(() => n.value.map((p) => typeof p == "string" ? G(p, o.value) : p)), y = _(() => Math.min(...s.value)), r = _(() => Math.max(...s.value)), h = _(() => {
|
|
11
11
|
const p = s.value.reduce(
|
|
12
|
-
(g,
|
|
12
|
+
(g, M) => Math.abs(M - a.value) < Math.abs(g - a.value) ? M : g
|
|
13
13
|
);
|
|
14
14
|
return s.value.indexOf(p);
|
|
15
15
|
});
|
|
@@ -21,36 +21,36 @@ function Re(n, a, o) {
|
|
|
21
21
|
closestSnapPointIndex: h
|
|
22
22
|
};
|
|
23
23
|
}
|
|
24
|
-
function
|
|
24
|
+
function $e(n, a, o) {
|
|
25
25
|
let t = (s) => n(s, ...a);
|
|
26
26
|
return o === void 0 ? t : Object.assign(t, { lazy: o, lazyArgs: a });
|
|
27
27
|
}
|
|
28
|
-
function
|
|
28
|
+
function We(n, a, o) {
|
|
29
29
|
let t = n.length - a.length;
|
|
30
30
|
if (t === 0) return n(...a);
|
|
31
|
-
if (t === 1) return
|
|
31
|
+
if (t === 1) return $e(n, a, o);
|
|
32
32
|
throw new Error("Wrong number of arguments");
|
|
33
33
|
}
|
|
34
|
-
function
|
|
35
|
-
let r, h, p, g,
|
|
34
|
+
function je(n, { triggerAt: a = "end", minQuietPeriodMs: o, maxBurstDurationMs: t, minGapMs: s, reducer: y = ze }) {
|
|
35
|
+
let r, h, p, g, M = () => {
|
|
36
36
|
let i = p;
|
|
37
37
|
i !== void 0 && (p = void 0, n(i), s !== void 0 && (h = setTimeout(D, s)));
|
|
38
38
|
}, D = () => {
|
|
39
|
-
clearTimeout(h), h = void 0, r === void 0 &&
|
|
39
|
+
clearTimeout(h), h = void 0, r === void 0 && M();
|
|
40
40
|
}, H = () => {
|
|
41
|
-
clearTimeout(r), r = void 0, g = void 0, h === void 0 &&
|
|
41
|
+
clearTimeout(r), r = void 0, g = void 0, h === void 0 && M();
|
|
42
42
|
};
|
|
43
43
|
return { call: (...i) => {
|
|
44
44
|
let c = r === void 0 && h === void 0;
|
|
45
45
|
if ((a !== "start" || c) && (p = y(p, ...i)), !(r === void 0 && !c)) {
|
|
46
46
|
if (o !== void 0 || t !== void 0 || s === void 0) {
|
|
47
47
|
clearTimeout(r);
|
|
48
|
-
let
|
|
49
|
-
g ?? (g =
|
|
50
|
-
let W = t === void 0 ? o ?? 0 : Math.min(o ?? t, t - (
|
|
48
|
+
let C = Date.now();
|
|
49
|
+
g ?? (g = C);
|
|
50
|
+
let W = t === void 0 ? o ?? 0 : Math.min(o ?? t, t - (C - g));
|
|
51
51
|
r = setTimeout(H, W);
|
|
52
52
|
}
|
|
53
|
-
a !== "end" && c &&
|
|
53
|
+
a !== "end" && c && M();
|
|
54
54
|
}
|
|
55
55
|
}, cancel: () => {
|
|
56
56
|
clearTimeout(r), r = void 0, g = void 0, clearTimeout(h), h = void 0, p = void 0;
|
|
@@ -60,24 +60,24 @@ function Ae(n, { triggerAt: a = "end", minQuietPeriodMs: o, maxBurstDurationMs:
|
|
|
60
60
|
return r === void 0 && h === void 0;
|
|
61
61
|
} };
|
|
62
62
|
}
|
|
63
|
-
var
|
|
63
|
+
var ze = () => "";
|
|
64
64
|
function b(...n) {
|
|
65
|
-
return
|
|
65
|
+
return We(Le, n);
|
|
66
66
|
}
|
|
67
|
-
var
|
|
68
|
-
function
|
|
67
|
+
var Le = (n, { min: a, max: o }) => a !== void 0 && n < a ? a : o !== void 0 && n > o ? o : n;
|
|
68
|
+
function qe(n, a, o) {
|
|
69
69
|
return Math.max(a, Math.min(n, o));
|
|
70
70
|
}
|
|
71
|
-
function
|
|
71
|
+
function Ne(n, a) {
|
|
72
72
|
return Math.pow(n, a * 5);
|
|
73
73
|
}
|
|
74
|
-
function
|
|
75
|
-
return a === 0 || Math.abs(a) === 1 / 0 ?
|
|
74
|
+
function Se(n, a, o) {
|
|
75
|
+
return a === 0 || Math.abs(a) === 1 / 0 ? Ne(n, o) : n * a * o / (a + o * n);
|
|
76
76
|
}
|
|
77
|
-
function
|
|
78
|
-
return t === 0 ?
|
|
77
|
+
function ue(n, a, o, t = 0.15) {
|
|
78
|
+
return t === 0 ? qe(n, a, o) : n < a ? -Se(a - n, o - a, t) + a : n > o ? +Se(n - o, o - a, t) + o : n;
|
|
79
79
|
}
|
|
80
|
-
const
|
|
80
|
+
const Qe = { "data-vsbs-container": "" }, Ge = /* @__PURE__ */ Be({
|
|
81
81
|
__name: "BottomSheet",
|
|
82
82
|
props: {
|
|
83
83
|
duration: { default: 250 },
|
|
@@ -94,89 +94,97 @@ const qe = { "data-vsbs-container": "" }, Ne = /* @__PURE__ */ Me({
|
|
|
94
94
|
contentClass: {},
|
|
95
95
|
footerClass: {}
|
|
96
96
|
},
|
|
97
|
-
emits: ["opened", "closed", "ready", "dragging-up", "dragging-down", "snapped", "instinctHeight", "update:modelValue"],
|
|
97
|
+
emits: ["opened", "opening-started", "closed", "closing-started", "ready", "dragging-up", "dragging-down", "snapped", "instinctHeight", "update:modelValue"],
|
|
98
98
|
setup(n, { expose: a, emit: o }) {
|
|
99
|
-
const t = n, s = o, y =
|
|
99
|
+
const t = n, s = o, y = Ve(t, "modelValue", s, {
|
|
100
100
|
passive: !0
|
|
101
101
|
});
|
|
102
102
|
q(y, (e) => {
|
|
103
|
-
e &&
|
|
104
|
-
}),
|
|
105
|
-
y.value &&
|
|
103
|
+
e && X();
|
|
104
|
+
}), Ie(() => {
|
|
105
|
+
y.value && X();
|
|
106
106
|
});
|
|
107
|
-
const r = P(), h = P(null), p = P(null), g = P(null),
|
|
107
|
+
const r = P(), h = P(null), p = P(null), g = P(null), M = P(null), D = P(null), H = P(null), i = P(t.expandOnContentDrag), { height: c } = Fe(), { height: C } = Q(r), { height: W } = Q(h), { height: se } = Q(D), { height: re } = Q(p), K = _({
|
|
108
108
|
get() {
|
|
109
109
|
return b(
|
|
110
|
-
Math.ceil(
|
|
110
|
+
Math.ceil(se.value + W.value + re.value),
|
|
111
111
|
{
|
|
112
112
|
max: c.value
|
|
113
113
|
}
|
|
114
114
|
);
|
|
115
115
|
},
|
|
116
116
|
set(e) {
|
|
117
|
-
[W.value,
|
|
117
|
+
[W.value, se.value, re.value] = e;
|
|
118
118
|
}
|
|
119
|
-
}), l = P(0), v = P(0),
|
|
119
|
+
}), l = P(0), v = P(0), k = me(0), S = me(0), { snapPoints: Pe } = Ee(t), d = _(() => Pe.value ?? [K.value]), {
|
|
120
120
|
flattenedSnapPoints: U,
|
|
121
121
|
currentSnapPointIndex: I,
|
|
122
122
|
closestSnapPointIndex: V,
|
|
123
123
|
minSnapPoint: O,
|
|
124
|
-
maxSnapPoint:
|
|
125
|
-
} =
|
|
126
|
-
let
|
|
127
|
-
const
|
|
124
|
+
maxSnapPoint: F
|
|
125
|
+
} = Ae(d, l, c);
|
|
126
|
+
let w;
|
|
127
|
+
const j = ye(document.body), z = ye(document.documentElement), Y = Re([r, H], {
|
|
128
128
|
immediate: !1,
|
|
129
129
|
fallbackFocus: () => r.value || document.body
|
|
130
130
|
});
|
|
131
|
-
function
|
|
132
|
-
i.value = !0,
|
|
131
|
+
function ie(e) {
|
|
132
|
+
i.value = !0, ve(e);
|
|
133
133
|
}
|
|
134
|
-
function
|
|
134
|
+
function ve(e) {
|
|
135
135
|
i.value && e.preventDefault();
|
|
136
136
|
}
|
|
137
|
-
const
|
|
138
|
-
e.key === "Escape" &&
|
|
139
|
-
},
|
|
140
|
-
t.canBackdropClose &&
|
|
141
|
-
}
|
|
142
|
-
|
|
137
|
+
const de = (e) => {
|
|
138
|
+
e.key === "Escape" && L();
|
|
139
|
+
}, Ce = () => {
|
|
140
|
+
t.canBackdropClose && L();
|
|
141
|
+
};
|
|
142
|
+
let J = !1;
|
|
143
|
+
const X = async () => {
|
|
144
|
+
if (J) return;
|
|
145
|
+
y.value = !0, J = !0, s("opening-started"), t.blocking && (j.value = !0, z.value = !0), await N();
|
|
143
146
|
const e = r.value.$el;
|
|
144
|
-
|
|
145
|
-
const u = e.querySelector("[data-vsbs-content]"), f = e.querySelector("[data-vsbs-header]"),
|
|
147
|
+
C.value = e.getBoundingClientRect().height;
|
|
148
|
+
const u = e.querySelector("[data-vsbs-content]"), f = e.querySelector("[data-vsbs-header]"), T = e.querySelector("[data-vsbs-footer]");
|
|
146
149
|
if (K.value = [
|
|
147
150
|
f.getBoundingClientRect().height,
|
|
148
151
|
u.getBoundingClientRect().height,
|
|
149
|
-
|
|
152
|
+
T.getBoundingClientRect().height
|
|
150
153
|
], await N(), I.value = U.value.findIndex(
|
|
151
|
-
(
|
|
154
|
+
(x) => x === O.value
|
|
152
155
|
), t.initialSnapPoint) {
|
|
153
|
-
const
|
|
154
|
-
if (
|
|
156
|
+
const x = t.initialSnapPoint;
|
|
157
|
+
if (x < 0 || x >= d.value.length) {
|
|
155
158
|
console.warn("Index out of bounds");
|
|
156
159
|
return;
|
|
157
160
|
}
|
|
158
|
-
let
|
|
159
|
-
typeof d.value[
|
|
161
|
+
let R;
|
|
162
|
+
typeof d.value[x] == "number" ? R = b(d.value[x], {
|
|
160
163
|
max: c.value
|
|
161
|
-
}) :
|
|
164
|
+
}) : R = G(d.value[x], c.value), l.value = R;
|
|
162
165
|
} else
|
|
163
166
|
l.value = b(O.value, {
|
|
164
167
|
max: c.value
|
|
165
168
|
});
|
|
166
|
-
v.value = l.value,
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
169
|
+
v.value = l.value, k.jump(l.value), S.jump(l.value), requestAnimationFrame(() => {
|
|
170
|
+
w = B(k, l.value, {
|
|
171
|
+
duration: t.duration / 1e3,
|
|
172
|
+
ease: "easeInOut"
|
|
173
|
+
}), w = B(S, 0, {
|
|
174
|
+
duration: t.duration / 1e3,
|
|
175
|
+
ease: "easeInOut",
|
|
176
|
+
onComplete: () => {
|
|
177
|
+
t.blocking && (s("opened"), Y.activate());
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
}), window.addEventListener("keydown", de), J = !1;
|
|
181
|
+
};
|
|
182
|
+
let Z = !1;
|
|
183
|
+
const L = () => {
|
|
184
|
+
Z || (y.value = !1, Z = !0, s("closing-started"), t.blocking && (j.value = !1, z.value = !1), window.removeEventListener("keydown", de), t.blocking && Y.deactivate(), setTimeout(() => {
|
|
185
|
+
s("closed"), Z = !1;
|
|
186
|
+
}, t.duration));
|
|
187
|
+
}, ce = (e) => {
|
|
180
188
|
if (!d.value) return;
|
|
181
189
|
if (e < 0 || e >= d.value.length) {
|
|
182
190
|
console.warn("Index out of bounds");
|
|
@@ -186,119 +194,119 @@ const qe = { "data-vsbs-container": "" }, Ne = /* @__PURE__ */ Me({
|
|
|
186
194
|
let u;
|
|
187
195
|
typeof d.value[e] == "number" ? u = b(d.value[e], {
|
|
188
196
|
max: c.value
|
|
189
|
-
}) : u = G(d.value[e], c.value), l.value = u,
|
|
197
|
+
}) : u = G(d.value[e], c.value), l.value = u, w = B(k, l.value, {
|
|
190
198
|
duration: t.duration / 1e3,
|
|
191
199
|
ease: "easeInOut",
|
|
192
200
|
onComplete: () => s("snapped", d.value.indexOf(d.value[e]))
|
|
193
201
|
});
|
|
194
202
|
};
|
|
195
|
-
function
|
|
203
|
+
function fe(e) {
|
|
196
204
|
e > 0 ? s("dragging-down") : e < 0 && s("dragging-up");
|
|
197
205
|
}
|
|
198
|
-
const
|
|
199
|
-
l.value =
|
|
200
|
-
},
|
|
206
|
+
const pe = () => {
|
|
207
|
+
l.value = C.value, v.value = S.get(), k.jump(l.value), S.jump(v.value);
|
|
208
|
+
}, he = async (e, u) => {
|
|
201
209
|
await N(), r.value && (v.value <= 0 && (l.value -= u.delta.y), l.value <= O.value && (l.value = O.value, v.value += u.delta.y, S.set(
|
|
202
|
-
t.canSwipeClose ? b(v.value, { min: 0 }) : b(
|
|
210
|
+
t.canSwipeClose ? b(v.value, { min: 0 }) : b(ue(v.value, -C.value, 0, 0.5), {
|
|
203
211
|
min: 0
|
|
204
212
|
})
|
|
205
|
-
)),
|
|
206
|
-
b(
|
|
213
|
+
)), k.set(
|
|
214
|
+
b(ue(l.value, 0, F.value, 0.25), {
|
|
207
215
|
min: 0,
|
|
208
216
|
max: c.value
|
|
209
217
|
})
|
|
210
|
-
),
|
|
211
|
-
},
|
|
218
|
+
), fe(u.delta.y));
|
|
219
|
+
}, ee = () => {
|
|
212
220
|
v.value = t.canSwipeClose ? [0, l.value].reduce(
|
|
213
221
|
(u, f) => Math.abs(f - v.value) < Math.abs(u - v.value) ? f : u
|
|
214
|
-
) : 0,
|
|
222
|
+
) : 0, w = B(S, v.value, {
|
|
215
223
|
duration: t.duration / 1e3,
|
|
216
224
|
ease: "easeInOut"
|
|
217
|
-
}), v.value === l.value && (v.value = 0,
|
|
225
|
+
}), v.value === l.value && (v.value = 0, L()), I.value = V.value;
|
|
218
226
|
let e;
|
|
219
227
|
typeof d.value[V.value] == "number" ? e = b(d.value[V.value], {
|
|
220
228
|
max: c.value
|
|
221
229
|
}) : e = G(
|
|
222
230
|
d.value[V.value],
|
|
223
231
|
c.value
|
|
224
|
-
), l.value = e,
|
|
232
|
+
), l.value = e, w = B(k, l.value, {
|
|
225
233
|
duration: t.duration / 1e3,
|
|
226
234
|
ease: "easeInOut",
|
|
227
235
|
onComplete: () => s(
|
|
228
236
|
"snapped",
|
|
229
237
|
d.value.indexOf(d.value[V.value])
|
|
230
238
|
)
|
|
231
|
-
}),
|
|
239
|
+
}), w = B(S, 0, {
|
|
232
240
|
duration: t.duration / 1e3,
|
|
233
241
|
ease: "easeInOut"
|
|
234
242
|
});
|
|
235
|
-
},
|
|
236
|
-
if (l.value =
|
|
237
|
-
const f = g.value.scrollTop === 0,
|
|
238
|
-
if (
|
|
243
|
+
}, ke = (e, u) => {
|
|
244
|
+
if (l.value = C.value, v.value = S.get(), w && w.stop(), !g.value) return;
|
|
245
|
+
const f = g.value.scrollTop === 0, T = u.delta.y > 0, x = U.value.length === 1, R = 0.5 > Math.abs(l.value - F.value);
|
|
246
|
+
if (x) {
|
|
239
247
|
if (!t.expandOnContentDrag) {
|
|
240
248
|
i.value = !1;
|
|
241
249
|
return;
|
|
242
250
|
}
|
|
243
|
-
S.get() === 0 && f &&
|
|
251
|
+
S.get() === 0 && f && T && (i.value = !0), S.get() === 0 && f && !T && (i.value = !1);
|
|
244
252
|
} else {
|
|
245
253
|
if (!t.expandOnContentDrag) {
|
|
246
254
|
i.value = !1;
|
|
247
255
|
return;
|
|
248
256
|
}
|
|
249
|
-
i.value = !0,
|
|
257
|
+
i.value = !0, R && (T && f && (i.value = !0), !T && f && (i.value = !1), f || (i.value = !1));
|
|
250
258
|
}
|
|
251
|
-
},
|
|
259
|
+
}, we = async (e, u) => {
|
|
252
260
|
if (await N(), !t.expandOnContentDrag) {
|
|
253
261
|
i.value = !1;
|
|
254
262
|
return;
|
|
255
263
|
}
|
|
256
264
|
if (!r.value) return;
|
|
257
265
|
v.value === 0 && i.value && t.expandOnContentDrag && (l.value -= u.delta.y), l.value <= O.value && (l.value = O.value, i.value && t.expandOnContentDrag && (v.value += u.delta.y), v.value = b(v.value, { min: 0, max: O.value }), S.set(
|
|
258
|
-
t.canSwipeClose ? b(v.value, { min: 0 }) : b(
|
|
266
|
+
t.canSwipeClose ? b(v.value, { min: 0 }) : b(ue(v.value, -C.value, 0, 0.5), {
|
|
259
267
|
min: 0
|
|
260
268
|
})
|
|
261
|
-
)), l.value >
|
|
262
|
-
}, ke = () => {
|
|
263
|
-
t.blocking || (z.value = !0, L.value = !0);
|
|
264
|
-
}, we = () => {
|
|
265
|
-
t.blocking || (z.value = !1, L.value = !1);
|
|
269
|
+
)), l.value > F.value && (l.value = F.value), l.value = b(l.value, { max: c.value }), U.value.length === 1 || l.value === F.value && (i.value = !1), k.set(l.value), fe(u.delta.y);
|
|
266
270
|
}, Te = () => {
|
|
271
|
+
t.blocking || (j.value = !0, z.value = !0);
|
|
272
|
+
}, xe = () => {
|
|
273
|
+
t.blocking || (j.value = !1, z.value = !1);
|
|
274
|
+
}, Me = () => {
|
|
267
275
|
if (!g.value) return;
|
|
268
276
|
const e = g.value.scrollTop === 0;
|
|
269
277
|
i.value = e;
|
|
270
|
-
},
|
|
278
|
+
}, Oe = je((e) => ce(e), {
|
|
271
279
|
minQuietPeriodMs: t.duration,
|
|
272
280
|
reducer: (e, u) => u
|
|
273
281
|
});
|
|
274
282
|
return q(d, (e, u) => {
|
|
275
283
|
if (y.value === !1 || !e || !u) return;
|
|
276
|
-
const f = e[I.value],
|
|
277
|
-
typeof f != "string" && typeof
|
|
284
|
+
const f = e[I.value], T = u[I.value];
|
|
285
|
+
typeof f != "string" && typeof T != "string" && (l.value = b(f, {
|
|
278
286
|
max: c.value
|
|
279
|
-
}), f !==
|
|
287
|
+
}), f !== T && (w = B(k, l.value, {
|
|
280
288
|
duration: t.duration / 1e3,
|
|
281
289
|
ease: "easeInOut"
|
|
282
290
|
})));
|
|
283
291
|
}), q(c, () => {
|
|
284
|
-
|
|
292
|
+
Oe.call(I.value);
|
|
285
293
|
}), q(K, (e) => {
|
|
286
294
|
s("instinctHeight", e);
|
|
287
|
-
}),
|
|
295
|
+
}), _e(() => {
|
|
288
296
|
Y.deactivate();
|
|
289
|
-
}), a({ open:
|
|
297
|
+
}), a({ open: X, close: L, snapToPoint: ce }), (e, u) => (ae(), te(De, {
|
|
290
298
|
to: e.teleportTo,
|
|
291
299
|
defer: e.teleportDefer
|
|
292
300
|
}, [
|
|
293
|
-
|
|
294
|
-
|
|
301
|
+
ne("div", Qe, [
|
|
302
|
+
A(m(be), null, {
|
|
295
303
|
default: E(() => [
|
|
296
|
-
m(y) && e.blocking ? (
|
|
304
|
+
m(y) && e.blocking ? (ae(), te(m($), {
|
|
297
305
|
key: 0,
|
|
298
306
|
ref_key: "backdrop",
|
|
299
307
|
ref: H,
|
|
300
308
|
"data-vsbs-backdrop": "",
|
|
301
|
-
onClick: u[0] || (u[0] = (f) =>
|
|
309
|
+
onClick: u[0] || (u[0] = (f) => Ce()),
|
|
302
310
|
transition: {
|
|
303
311
|
ease: "easeInOut",
|
|
304
312
|
duration: e.duration / 1e3
|
|
@@ -306,101 +314,101 @@ const qe = { "data-vsbs-container": "" }, Ne = /* @__PURE__ */ Me({
|
|
|
306
314
|
initial: { opacity: 0 },
|
|
307
315
|
animate: { opacity: 1 },
|
|
308
316
|
exit: { opacity: 0 }
|
|
309
|
-
}, null, 8, ["transition"])) :
|
|
317
|
+
}, null, 8, ["transition"])) : ge("", !0)
|
|
310
318
|
]),
|
|
311
319
|
_: 1
|
|
312
320
|
}),
|
|
313
|
-
|
|
321
|
+
A(m(be), null, {
|
|
314
322
|
default: E(() => [
|
|
315
|
-
m(y) ? (
|
|
323
|
+
m(y) ? (ae(), te(m($), {
|
|
316
324
|
key: 0,
|
|
317
325
|
ref_key: "sheet",
|
|
318
326
|
ref: r,
|
|
319
|
-
exit: { y: "100%", height: m(
|
|
320
|
-
initial:
|
|
321
|
-
style:
|
|
327
|
+
exit: { y: "100%", height: m(C) },
|
|
328
|
+
initial: !1,
|
|
329
|
+
style: He({ y: m(S), height: m(k) }),
|
|
322
330
|
"data-vsbs-shadow": !e.blocking,
|
|
323
331
|
"data-vsbs-sheet-show": m(y),
|
|
324
332
|
"aria-modal": "true",
|
|
325
333
|
"data-vsbs-sheet": "",
|
|
326
334
|
tabindex: "-1",
|
|
327
|
-
onTouchstart:
|
|
328
|
-
onTouchend:
|
|
335
|
+
onTouchstart: Te,
|
|
336
|
+
onTouchend: xe
|
|
329
337
|
}, {
|
|
330
338
|
default: E(() => [
|
|
331
|
-
|
|
339
|
+
A(m($), {
|
|
332
340
|
ref_key: "sheetHeader",
|
|
333
341
|
ref: h,
|
|
334
342
|
"data-vsbs-header": "",
|
|
335
|
-
onPanStart:
|
|
336
|
-
onPan:
|
|
337
|
-
onPanEnd:
|
|
338
|
-
onTouchmove:
|
|
339
|
-
class:
|
|
343
|
+
onPanStart: pe,
|
|
344
|
+
onPan: he,
|
|
345
|
+
onPanEnd: ee,
|
|
346
|
+
onTouchmove: ie,
|
|
347
|
+
class: oe(e.headerClass)
|
|
340
348
|
}, {
|
|
341
349
|
default: E(() => [
|
|
342
|
-
|
|
350
|
+
le(e.$slots, "header", {}, void 0, !0)
|
|
343
351
|
]),
|
|
344
352
|
_: 3
|
|
345
353
|
}, 8, ["class"]),
|
|
346
|
-
|
|
354
|
+
ne("div", {
|
|
347
355
|
ref_key: "sheetScroll",
|
|
348
356
|
ref: g,
|
|
349
357
|
"data-vsbs-scroll": "",
|
|
350
|
-
onScrollend:
|
|
358
|
+
onScrollend: Me
|
|
351
359
|
}, [
|
|
352
|
-
|
|
360
|
+
A(m($), {
|
|
353
361
|
ref_key: "sheetContentWrapper",
|
|
354
|
-
ref:
|
|
362
|
+
ref: M,
|
|
355
363
|
"data-vsbs-content-wrapper": "",
|
|
356
|
-
onPanStart:
|
|
357
|
-
onPan:
|
|
358
|
-
onPanEnd:
|
|
359
|
-
onTouchmove:
|
|
364
|
+
onPanStart: ke,
|
|
365
|
+
onPan: we,
|
|
366
|
+
onPanEnd: ee,
|
|
367
|
+
onTouchmove: ve
|
|
360
368
|
}, {
|
|
361
369
|
default: E(() => [
|
|
362
|
-
|
|
370
|
+
ne("div", {
|
|
363
371
|
ref_key: "sheetContent",
|
|
364
372
|
ref: D,
|
|
365
373
|
"data-vsbs-content": "",
|
|
366
|
-
class:
|
|
374
|
+
class: oe(e.contentClass)
|
|
367
375
|
}, [
|
|
368
|
-
|
|
376
|
+
le(e.$slots, "default", {}, void 0, !0)
|
|
369
377
|
], 2)
|
|
370
378
|
]),
|
|
371
379
|
_: 3
|
|
372
380
|
}, 512)
|
|
373
381
|
], 544),
|
|
374
|
-
|
|
382
|
+
A(m($), {
|
|
375
383
|
ref_key: "sheetFooter",
|
|
376
384
|
ref: p,
|
|
377
385
|
"data-vsbs-footer": "",
|
|
378
|
-
onPanStart:
|
|
379
|
-
onPan:
|
|
380
|
-
onPanEnd:
|
|
381
|
-
onTouchmove:
|
|
382
|
-
class:
|
|
386
|
+
onPanStart: pe,
|
|
387
|
+
onPan: he,
|
|
388
|
+
onPanEnd: ee,
|
|
389
|
+
onTouchmove: ie,
|
|
390
|
+
class: oe(e.footerClass)
|
|
383
391
|
}, {
|
|
384
392
|
default: E(() => [
|
|
385
|
-
|
|
393
|
+
le(e.$slots, "footer", {}, void 0, !0)
|
|
386
394
|
]),
|
|
387
395
|
_: 3
|
|
388
396
|
}, 8, ["class"])
|
|
389
397
|
]),
|
|
390
398
|
_: 3
|
|
391
|
-
}, 8, ["exit", "style", "data-vsbs-shadow", "data-vsbs-sheet-show"])) :
|
|
399
|
+
}, 8, ["exit", "style", "data-vsbs-shadow", "data-vsbs-sheet-show"])) : ge("", !0)
|
|
392
400
|
]),
|
|
393
401
|
_: 3
|
|
394
402
|
})
|
|
395
403
|
])
|
|
396
404
|
], 8, ["to", "defer"]));
|
|
397
405
|
}
|
|
398
|
-
}),
|
|
406
|
+
}), Ke = (n, a) => {
|
|
399
407
|
const o = n.__vccOpts || n;
|
|
400
408
|
for (const [t, s] of a)
|
|
401
409
|
o[t] = s;
|
|
402
410
|
return o;
|
|
403
|
-
},
|
|
411
|
+
}, Ze = /* @__PURE__ */ Ke(Ge, [["__scopeId", "data-v-c353e679"]]);
|
|
404
412
|
export {
|
|
405
|
-
|
|
413
|
+
Ze as default
|
|
406
414
|
};
|
package/dist/style.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
[data-vsbs-container][data-v-
|
|
1
|
+
[data-vsbs-container][data-v-c353e679]{position:fixed;top:0;right:0;bottom:0;left:0;overflow:hidden;pointer-events:none;z-index:9999;visibility:visible}[data-vsbs-backdrop][data-v-c353e679]{background-color:var(--vsbs-backdrop-bg, rgba(0, 0, 0, .5));top:0;right:0;bottom:0;left:0;pointer-events:auto;position:fixed;-webkit-user-select:none;user-select:none;will-change:opacity;z-index:1}[data-vsbs-shadow=true][data-v-c353e679]: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-c353e679]{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-height:inherit;max-width:var(--vsbs-max-width, 640px);pointer-events:all;position:fixed;right:0;width:100%;will-change:height;z-index:2}[data-vsbs-sheet-show=true][data-v-c353e679]{visibility:visible}[data-vsbs-header][data-v-c353e679]{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-c353e679]: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-c353e679]:empty{box-shadow:none;padding:14px var(--vsbs-padding-x, 16px) 10px}[data-vsbs-footer][data-v-c353e679]{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-c353e679]:empty{display:none}[data-vsbs-scroll][data-v-c353e679]{flex-grow:1;overflow-y:auto;overscroll-behavior:none}[data-vsbs-content-wrapper][data-v-c353e679]{height:100%}[data-vsbs-content][data-v-c353e679]{display:grid;padding:8px var(--vsbs-padding-x, 16px);-webkit-user-select:none;user-select:none}
|
package/package.json
CHANGED
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"url": "https://github.com/megaarmos/vue-spring-bottom-sheet/issues"
|
|
33
33
|
},
|
|
34
34
|
"private": false,
|
|
35
|
-
"version": "2.
|
|
35
|
+
"version": "2.4.1",
|
|
36
36
|
"type": "module",
|
|
37
37
|
"exports": {
|
|
38
38
|
".": {
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"@vueuse/core": "^13.2.0",
|
|
63
63
|
"@vueuse/integrations": "^13.2.0",
|
|
64
64
|
"focus-trap": "^7.6.4",
|
|
65
|
-
"motion-v": "^1.0
|
|
65
|
+
"motion-v": "^1.5.0",
|
|
66
66
|
"remeda": "^2.21.6",
|
|
67
67
|
"vue": "^3.5.14"
|
|
68
68
|
},
|