@douxcode/vue-spring-bottom-sheet 2.6.0-next.1 → 3.0.0-next.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/dist/index.mjs +216 -216
- package/dist/style.css +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { ref as
|
|
2
|
-
import { useVModel as
|
|
3
|
-
import { useFocusTrap as
|
|
4
|
-
function
|
|
5
|
-
const
|
|
6
|
-
return l *
|
|
1
|
+
import { ref as m, computed as I, defineComponent as Le, useCssVars as _e, watch as J, onMounted as Ae, toRefs as Ve, nextTick as we, onUnmounted as We, createElementBlock as le, openBlock as W, Fragment as ze, createBlock as Se, Teleport as Ce, createVNode as be, Transition as ye, withCtx as Pe, createCommentVNode as Te, unref as oe, normalizeStyle as Ne, createElementVNode as z, normalizeClass as ue, renderSlot as se } from "vue";
|
|
2
|
+
import { useVModel as qe, useWindowSize as Qe, useElementBounding as X, useScrollLock as ke } from "@vueuse/core";
|
|
3
|
+
import { useFocusTrap as je } from "@vueuse/integrations/useFocusTrap";
|
|
4
|
+
function N(o, l) {
|
|
5
|
+
const s = parseFloat(o);
|
|
6
|
+
return l * s / 100;
|
|
7
7
|
}
|
|
8
|
-
function
|
|
9
|
-
const t =
|
|
8
|
+
function Ge(o, l, s) {
|
|
9
|
+
const t = m(0), v = I(() => o.value.map((b) => typeof b == "string" ? N(b, s.value) : b)), C = I(() => Math.min(...v.value)), i = I(() => Math.max(...v.value)), y = I(() => {
|
|
10
10
|
const b = v.value.reduce(
|
|
11
11
|
(P, w) => Math.abs(w - l.value) < Math.abs(P - l.value) ? w : P
|
|
12
12
|
);
|
|
@@ -20,12 +20,12 @@ function je(o, l, r) {
|
|
|
20
20
|
closestSnapPointIndex: y
|
|
21
21
|
};
|
|
22
22
|
}
|
|
23
|
-
function
|
|
24
|
-
const { velocityThreshold: l = 0.5 } = o,
|
|
23
|
+
function Ke(o = {}) {
|
|
24
|
+
const { velocityThreshold: l = 0.5 } = o, s = m(0), t = m(0), v = m(0), C = m(0), i = m([]);
|
|
25
25
|
return {
|
|
26
26
|
start: (w) => {
|
|
27
27
|
const S = performance.now();
|
|
28
|
-
|
|
28
|
+
s.value = w, t.value = S, v.value = w, C.value = S, i.value = [{ y: w, time: S }];
|
|
29
29
|
},
|
|
30
30
|
update: (w) => {
|
|
31
31
|
const S = performance.now();
|
|
@@ -50,17 +50,17 @@ function Ge(o = {}) {
|
|
|
50
50
|
}
|
|
51
51
|
};
|
|
52
52
|
}
|
|
53
|
-
function
|
|
53
|
+
function Ue(o, l, s) {
|
|
54
54
|
let t = (v) => o(v, ...l);
|
|
55
|
-
return
|
|
55
|
+
return s === void 0 ? t : Object.assign(t, { lazy: s, lazyArgs: l });
|
|
56
56
|
}
|
|
57
|
-
function
|
|
57
|
+
function Je(o, l, s) {
|
|
58
58
|
let t = o.length - l.length;
|
|
59
59
|
if (t === 0) return o(...l);
|
|
60
|
-
if (t === 1) return
|
|
60
|
+
if (t === 1) return Ue(o, l, s);
|
|
61
61
|
throw new Error("Wrong number of arguments");
|
|
62
62
|
}
|
|
63
|
-
function
|
|
63
|
+
function Xe(o, { triggerAt: l = "end", minQuietPeriodMs: s, maxBurstDurationMs: t, minGapMs: v, reducer: C = Ze }) {
|
|
64
64
|
let i, y, b, P, w = () => {
|
|
65
65
|
let d = b;
|
|
66
66
|
d !== void 0 && (b = void 0, o(d), v !== void 0 && (y = setTimeout(S, v)));
|
|
@@ -72,11 +72,11 @@ function Je(o, { triggerAt: l = "end", minQuietPeriodMs: r, maxBurstDurationMs:
|
|
|
72
72
|
return { call: (...d) => {
|
|
73
73
|
let h = i === void 0 && y === void 0;
|
|
74
74
|
if ((l !== "start" || h) && (b = C(b, ...d)), !(i === void 0 && !h)) {
|
|
75
|
-
if (
|
|
75
|
+
if (s !== void 0 || t !== void 0 || v === void 0) {
|
|
76
76
|
clearTimeout(i);
|
|
77
77
|
let D = Date.now();
|
|
78
78
|
P ?? (P = D);
|
|
79
|
-
let $ = t === void 0 ?
|
|
79
|
+
let $ = t === void 0 ? s ?? 0 : Math.min(s ?? t, t - (D - P));
|
|
80
80
|
i = setTimeout(M, $);
|
|
81
81
|
}
|
|
82
82
|
l !== "end" && h && w();
|
|
@@ -89,24 +89,24 @@ function Je(o, { triggerAt: l = "end", minQuietPeriodMs: r, maxBurstDurationMs:
|
|
|
89
89
|
return i === void 0 && y === void 0;
|
|
90
90
|
} };
|
|
91
91
|
}
|
|
92
|
-
var
|
|
92
|
+
var Ze = () => "";
|
|
93
93
|
function T(...o) {
|
|
94
|
-
return
|
|
94
|
+
return Je(et, o);
|
|
95
95
|
}
|
|
96
|
-
var
|
|
97
|
-
function
|
|
98
|
-
return Math.max(l, Math.min(o,
|
|
96
|
+
var et = (o, { min: l, max: s }) => l !== void 0 && o < l ? l : s !== void 0 && o > s ? s : o;
|
|
97
|
+
function tt(o, l, s) {
|
|
98
|
+
return Math.max(l, Math.min(o, s));
|
|
99
99
|
}
|
|
100
|
-
function
|
|
100
|
+
function nt(o, l) {
|
|
101
101
|
return Math.pow(o, l * 5);
|
|
102
102
|
}
|
|
103
|
-
function
|
|
104
|
-
return l === 0 || Math.abs(l) === 1 / 0 ?
|
|
103
|
+
function xe(o, l, s) {
|
|
104
|
+
return l === 0 || Math.abs(l) === 1 / 0 ? nt(o, s) : o * l * s / (l + s * o);
|
|
105
105
|
}
|
|
106
|
-
function
|
|
107
|
-
return t === 0 ?
|
|
106
|
+
function re(o, l, s, t = 0.15) {
|
|
107
|
+
return t === 0 ? tt(o, l, s) : o < l ? -xe(l - o, s - l, t) + l : o > s ? +xe(o - s, s - l, t) + s : o;
|
|
108
108
|
}
|
|
109
|
-
const
|
|
109
|
+
const at = ["data-vsbs-shadow", "data-vsbs-sheet-show"], lt = /* @__PURE__ */ Le({
|
|
110
110
|
__name: "BottomSheet",
|
|
111
111
|
props: {
|
|
112
112
|
duration: { default: 250 },
|
|
@@ -125,385 +125,385 @@ const nt = ["data-vsbs-shadow", "data-vsbs-sheet-show"], at = /* @__PURE__ */ Re
|
|
|
125
125
|
footerClass: {}
|
|
126
126
|
},
|
|
127
127
|
emits: ["opened", "opening-started", "closed", "closing-started", "ready", "dragging-up", "dragging-down", "snapped", "instinctHeight", "update:modelValue"],
|
|
128
|
-
setup(o, { expose: l, emit:
|
|
129
|
-
|
|
130
|
-
"
|
|
128
|
+
setup(o, { expose: l, emit: s }) {
|
|
129
|
+
_e((e) => ({
|
|
130
|
+
"03a2828a": Ye.value
|
|
131
131
|
}));
|
|
132
|
-
const t = o, v =
|
|
132
|
+
const t = o, v = s, C = qe(t, "modelValue", v, {
|
|
133
133
|
passive: !0
|
|
134
134
|
});
|
|
135
|
-
|
|
136
|
-
e &&
|
|
137
|
-
}),
|
|
138
|
-
C.value &&
|
|
135
|
+
J(C, (e) => {
|
|
136
|
+
e && ne();
|
|
137
|
+
}), Ae(() => {
|
|
138
|
+
C.value && ne();
|
|
139
139
|
});
|
|
140
|
-
const i =
|
|
140
|
+
const i = m(null), y = m(null), b = m(null), P = m(null), w = m(null), S = m(null), M = m(null), d = m(t.expandOnContentDrag), { height: h } = Qe(), { height: D } = X(i), { height: $ } = X(y), { height: L } = X(S), { height: ie } = X(b), Z = I({
|
|
141
141
|
get() {
|
|
142
142
|
return T(
|
|
143
|
-
Math.ceil(L.value + $.value +
|
|
143
|
+
Math.ceil(L.value + $.value + ie.value),
|
|
144
144
|
{
|
|
145
145
|
max: h.value
|
|
146
146
|
}
|
|
147
147
|
);
|
|
148
148
|
},
|
|
149
149
|
set(e) {
|
|
150
|
-
[$.value, L.value,
|
|
150
|
+
[$.value, L.value, ie.value] = e;
|
|
151
151
|
}
|
|
152
|
-
}), a =
|
|
153
|
-
flattenedSnapPoints:
|
|
152
|
+
}), a = m(0), u = m(0), Ye = I(() => t.duration + "ms"), { snapPoints: Me } = Ve(t), p = I(() => Me.value ?? [Z.value]), {
|
|
153
|
+
flattenedSnapPoints: x,
|
|
154
154
|
currentSnapPointIndex: B,
|
|
155
155
|
closestSnapPointIndex: F,
|
|
156
156
|
minSnapPoint: O,
|
|
157
157
|
maxSnapPoint: _
|
|
158
|
-
} =
|
|
158
|
+
} = Ge(p, a, h), q = ke(document.body), Q = ke(document.documentElement), E = m(!1), A = m(0), j = m(0), G = m(0), H = m(0), K = m(!0), R = Ke({ velocityThreshold: 0.5 }), ee = je([i, M], {
|
|
159
159
|
immediate: !1,
|
|
160
160
|
fallbackFocus: () => i.value || document.body
|
|
161
161
|
});
|
|
162
|
-
function ie(e) {
|
|
163
|
-
d.value = !0, ve(e);
|
|
164
|
-
}
|
|
165
162
|
function ve(e) {
|
|
163
|
+
d.value = !0, ce(e);
|
|
164
|
+
}
|
|
165
|
+
function ce(e) {
|
|
166
166
|
d.value && e.preventDefault();
|
|
167
167
|
}
|
|
168
|
-
const
|
|
169
|
-
e.key === "Escape" &&
|
|
170
|
-
},
|
|
171
|
-
t.canBackdropClose &&
|
|
168
|
+
const de = (e) => {
|
|
169
|
+
e.key === "Escape" && Y();
|
|
170
|
+
}, De = () => {
|
|
171
|
+
t.canBackdropClose && Y();
|
|
172
172
|
};
|
|
173
|
-
let
|
|
174
|
-
const
|
|
175
|
-
if (
|
|
176
|
-
C.value = !0,
|
|
173
|
+
let te = !1;
|
|
174
|
+
const ne = async () => {
|
|
175
|
+
if (te) return;
|
|
176
|
+
C.value = !0, te = !0, v("opening-started"), t.blocking && (q.value = !0, Q.value = !0), await we();
|
|
177
177
|
const e = i.value;
|
|
178
178
|
D.value = e.getBoundingClientRect().height;
|
|
179
|
-
const n = e.querySelector("[data-vsbs-content]"),
|
|
180
|
-
if (
|
|
181
|
-
|
|
179
|
+
const n = e.querySelector("[data-vsbs-content]"), r = e.querySelector("[data-vsbs-header]"), c = e.querySelector("[data-vsbs-footer]");
|
|
180
|
+
if (Z.value = [
|
|
181
|
+
r.getBoundingClientRect().height,
|
|
182
182
|
n.getBoundingClientRect().height,
|
|
183
|
-
|
|
184
|
-
], await
|
|
185
|
-
(
|
|
183
|
+
c.getBoundingClientRect().height
|
|
184
|
+
], await we(), B.value = x.value.findIndex(
|
|
185
|
+
(f) => f === O.value
|
|
186
186
|
), t.initialSnapPoint) {
|
|
187
|
-
const
|
|
188
|
-
if (
|
|
187
|
+
const f = t.initialSnapPoint;
|
|
188
|
+
if (f < 0 || f >= p.value.length) {
|
|
189
189
|
console.warn("Index out of bounds");
|
|
190
190
|
return;
|
|
191
191
|
}
|
|
192
|
-
let
|
|
193
|
-
typeof
|
|
192
|
+
let g;
|
|
193
|
+
typeof p.value[f] == "number" ? g = T(p.value[f], {
|
|
194
194
|
max: h.value
|
|
195
|
-
}) :
|
|
195
|
+
}) : g = N(p.value[f], h.value), a.value = g;
|
|
196
196
|
} else
|
|
197
197
|
a.value = T(O.value, {
|
|
198
198
|
max: h.value
|
|
199
199
|
});
|
|
200
200
|
u.value = a.value, requestAnimationFrame(() => {
|
|
201
201
|
u.value = 0, t.blocking && setTimeout(() => {
|
|
202
|
-
C.value && (v("opened"),
|
|
202
|
+
C.value && (v("opened"), ee.activate());
|
|
203
203
|
}, t.duration);
|
|
204
|
-
}), window.addEventListener("keydown",
|
|
204
|
+
}), window.addEventListener("keydown", de), te = !1;
|
|
205
205
|
};
|
|
206
|
-
let
|
|
207
|
-
const
|
|
208
|
-
|
|
209
|
-
v("closed"),
|
|
206
|
+
let ae = !1;
|
|
207
|
+
const Y = () => {
|
|
208
|
+
ae || (C.value = !1, ae = !0, v("closing-started"), t.blocking && (q.value = !1, Q.value = !1), window.removeEventListener("keydown", de), t.blocking && ee.deactivate(), u.value = a.value, setTimeout(() => {
|
|
209
|
+
v("closed"), ae = !1;
|
|
210
210
|
}, t.duration));
|
|
211
|
-
},
|
|
212
|
-
if (!
|
|
213
|
-
if (e < 0 || e >=
|
|
211
|
+
}, fe = (e) => {
|
|
212
|
+
if (!p.value) return;
|
|
213
|
+
if (e < 0 || e >= p.value.length) {
|
|
214
214
|
console.warn("Index out of bounds");
|
|
215
215
|
return;
|
|
216
216
|
}
|
|
217
217
|
B.value = e;
|
|
218
218
|
let n;
|
|
219
|
-
typeof
|
|
219
|
+
typeof p.value[e] == "number" ? n = T(p.value[e], {
|
|
220
220
|
max: h.value
|
|
221
|
-
}) : n =
|
|
221
|
+
}) : n = N(p.value[e], h.value), a.value = n, v("snapped", p.value.indexOf(p.value[e]));
|
|
222
222
|
};
|
|
223
|
-
function
|
|
223
|
+
function pe(e) {
|
|
224
224
|
e > 0 ? v("dragging-down") : e < 0 && v("dragging-up");
|
|
225
225
|
}
|
|
226
|
-
const
|
|
226
|
+
const he = (e) => {
|
|
227
227
|
if (!i.value) return;
|
|
228
|
-
const n = window.getComputedStyle(i.value),
|
|
229
|
-
let
|
|
230
|
-
n.transform && n.transform !== "none" && (
|
|
231
|
-
},
|
|
228
|
+
const n = window.getComputedStyle(i.value), r = parseFloat(n.height);
|
|
229
|
+
let c = 0;
|
|
230
|
+
n.transform && n.transform !== "none" && (c = new DOMMatrix(n.transform).m42), a.value = r, u.value = c, E.value = !0, A.value = e.clientY, j.value = a.value, G.value = u.value, H.value = e.clientY, R.start(e.clientY), e.target.setPointerCapture(e.pointerId);
|
|
231
|
+
}, me = (e) => {
|
|
232
232
|
if (!E.value) return;
|
|
233
|
-
const n = e.clientY - A.value,
|
|
234
|
-
u.value <= 0 && (a.value =
|
|
235
|
-
|
|
233
|
+
const n = e.clientY - A.value, r = e.clientY;
|
|
234
|
+
u.value <= 0 && (a.value = j.value - n), a.value <= O.value && (a.value = O.value, u.value = G.value + n, t.canSwipeClose ? u.value = T(u.value, { min: 0 }) : u.value = T(
|
|
235
|
+
re(u.value, -D.value, 0, 0.5),
|
|
236
236
|
{ min: 0 }
|
|
237
|
-
)), a.value = T(
|
|
237
|
+
)), a.value = T(re(a.value, 0, _.value, 0.25), {
|
|
238
238
|
min: 0,
|
|
239
239
|
max: h.value
|
|
240
|
-
}),
|
|
241
|
-
},
|
|
240
|
+
}), pe(e.clientY - H.value), R.update(e.clientY), H.value = r;
|
|
241
|
+
}, U = (e) => {
|
|
242
242
|
if (E.value = !1, e.target.releasePointerCapture(e.pointerId), t.canSwipeClose) {
|
|
243
|
-
let
|
|
244
|
-
if (t.swipeCloseThreshold && typeof t.swipeCloseThreshold == "number" && (
|
|
245
|
-
u.value = a.value,
|
|
243
|
+
let f = a.value / 2;
|
|
244
|
+
if (t.swipeCloseThreshold && typeof t.swipeCloseThreshold == "number" && (f = t.swipeCloseThreshold), t.swipeCloseThreshold && typeof t.swipeCloseThreshold == "string" && t.swipeCloseThreshold.includes("%") && (f = a.value * (Number(t.swipeCloseThreshold.replace("%", "")) / 100)), u.value > f) {
|
|
245
|
+
u.value = a.value, Y();
|
|
246
246
|
return;
|
|
247
247
|
}
|
|
248
248
|
} else
|
|
249
249
|
u.value = 0;
|
|
250
250
|
if (u.value === a.value) {
|
|
251
|
-
u.value = 0,
|
|
251
|
+
u.value = 0, Y();
|
|
252
252
|
return;
|
|
253
253
|
}
|
|
254
254
|
const n = R.end();
|
|
255
255
|
if (n.isSwipe && n.direction === "down" && t.canSwipeClose && a.value <= O.value + 10) {
|
|
256
|
-
u.value = a.value,
|
|
256
|
+
u.value = a.value, Y();
|
|
257
257
|
return;
|
|
258
258
|
}
|
|
259
|
-
let
|
|
260
|
-
if (n.isSwipe &&
|
|
261
|
-
const
|
|
259
|
+
let r;
|
|
260
|
+
if (n.isSwipe && x.value.length > 1) {
|
|
261
|
+
const f = [...x.value].sort((g, k) => g - k);
|
|
262
262
|
if (n.direction === "up") {
|
|
263
|
-
const
|
|
264
|
-
|
|
263
|
+
const g = f.find((k) => k > a.value + 1);
|
|
264
|
+
r = g !== void 0 ? x.value.indexOf(g) : F.value;
|
|
265
265
|
} else {
|
|
266
|
-
const
|
|
267
|
-
|
|
266
|
+
const g = [...f].reverse().find((k) => k < a.value - 1);
|
|
267
|
+
r = g !== void 0 ? x.value.indexOf(g) : F.value;
|
|
268
268
|
}
|
|
269
269
|
} else
|
|
270
|
-
|
|
271
|
-
B.value =
|
|
272
|
-
let
|
|
273
|
-
if (typeof
|
|
270
|
+
r = F.value;
|
|
271
|
+
B.value = r;
|
|
272
|
+
let c;
|
|
273
|
+
if (typeof p.value[r] == "number" ? c = T(p.value[r], {
|
|
274
274
|
max: h.value
|
|
275
|
-
}) :
|
|
276
|
-
|
|
275
|
+
}) : c = N(
|
|
276
|
+
p.value[r],
|
|
277
277
|
h.value
|
|
278
|
-
),
|
|
279
|
-
|
|
278
|
+
), c === 0) {
|
|
279
|
+
Y();
|
|
280
280
|
return;
|
|
281
281
|
}
|
|
282
|
-
a.value =
|
|
283
|
-
},
|
|
282
|
+
a.value = c, u.value = 0, v("snapped", p.value.indexOf(p.value[r]));
|
|
283
|
+
}, Oe = (e) => {
|
|
284
284
|
if (!P.value) return;
|
|
285
|
-
const n = P.value.scrollTop === 0,
|
|
286
|
-
if (console.log(e),
|
|
285
|
+
const n = P.value.scrollTop === 0, r = e > 0, c = x.value.length === 1, f = 0.5 > Math.abs(a.value - _.value);
|
|
286
|
+
if (console.log(e), c) {
|
|
287
287
|
if (!t.expandOnContentDrag) {
|
|
288
288
|
d.value = !1;
|
|
289
289
|
return;
|
|
290
290
|
}
|
|
291
|
-
u.value === 0 && n &&
|
|
291
|
+
u.value === 0 && n && r && (d.value = !0), u.value === 0 && n && !r && (d.value = !1);
|
|
292
292
|
} else {
|
|
293
293
|
if (!t.expandOnContentDrag) {
|
|
294
294
|
d.value = !1;
|
|
295
295
|
return;
|
|
296
296
|
}
|
|
297
|
-
d.value = !0,
|
|
297
|
+
d.value = !0, f && (r && n && (d.value = !0), !r && n && (d.value = !1), n || (d.value = !1));
|
|
298
298
|
}
|
|
299
|
-
}, Oe = (e) => {
|
|
300
|
-
if (!i.value) return;
|
|
301
|
-
const n = window.getComputedStyle(i.value), s = parseFloat(n.height);
|
|
302
|
-
let p = 0;
|
|
303
|
-
n.transform && n.transform !== "none" && (p = new DOMMatrix(n.transform).m42), a.value = s, u.value = p, E.value = !0, A.value = e.clientY, Q.value = a.value, j.value = u.value, H.value = e.clientY, G.value = !0, R.start(e.clientY), e.target.setPointerCapture(e.pointerId);
|
|
304
299
|
}, Be = (e) => {
|
|
300
|
+
if (!i.value) return;
|
|
301
|
+
const n = window.getComputedStyle(i.value), r = parseFloat(n.height);
|
|
302
|
+
let c = 0;
|
|
303
|
+
n.transform && n.transform !== "none" && (c = new DOMMatrix(n.transform).m42), a.value = r, u.value = c, E.value = !0, A.value = e.clientY, j.value = a.value, G.value = u.value, H.value = e.clientY, K.value = !0, R.start(e.clientY), e.target.setPointerCapture(e.pointerId);
|
|
304
|
+
}, Ee = (e) => {
|
|
305
305
|
if (!E.value) return;
|
|
306
306
|
if (!t.expandOnContentDrag) {
|
|
307
307
|
d.value = !1;
|
|
308
308
|
return;
|
|
309
309
|
}
|
|
310
|
-
const n = e.clientY - A.value,
|
|
311
|
-
if (
|
|
312
|
-
const
|
|
313
|
-
if (Math.abs(
|
|
314
|
-
|
|
310
|
+
const n = e.clientY - A.value, r = e.clientY, c = e.clientY - H.value;
|
|
311
|
+
if (K.value) {
|
|
312
|
+
const g = e.clientY - A.value;
|
|
313
|
+
if (Math.abs(g) > 3)
|
|
314
|
+
K.value = !1, Oe(g);
|
|
315
315
|
else {
|
|
316
|
-
H.value =
|
|
316
|
+
H.value = r;
|
|
317
317
|
return;
|
|
318
318
|
}
|
|
319
319
|
}
|
|
320
|
-
u.value === 0 && d.value && t.expandOnContentDrag && (a.value =
|
|
321
|
-
|
|
320
|
+
u.value === 0 && d.value && t.expandOnContentDrag && (a.value = j.value - n), a.value <= O.value && (a.value = O.value, d.value && t.expandOnContentDrag && (u.value = G.value + n), u.value = T(u.value, { min: 0, max: O.value }), t.canSwipeClose ? u.value = T(u.value, { min: 0 }) : u.value = T(
|
|
321
|
+
re(u.value, -D.value, 0, 0.5),
|
|
322
322
|
{ min: 0 }
|
|
323
|
-
)), a.value > _.value && (a.value = _.value), a.value = T(a.value, { max: h.value }),
|
|
324
|
-
},
|
|
325
|
-
if (E.value = !1,
|
|
326
|
-
let
|
|
327
|
-
if (t.swipeCloseThreshold && typeof t.swipeCloseThreshold == "number" && (
|
|
328
|
-
u.value = a.value,
|
|
323
|
+
)), a.value > _.value && (a.value = _.value), a.value = T(a.value, { max: h.value }), x.value.length === 1 || a.value === _.value && (d.value = !1), pe(c), R.update(e.clientY), H.value = r;
|
|
324
|
+
}, ge = (e) => {
|
|
325
|
+
if (E.value = !1, K.value = !0, e.target.releasePointerCapture(e.pointerId), t.canSwipeClose) {
|
|
326
|
+
let g = a.value / 2;
|
|
327
|
+
if (t.swipeCloseThreshold && typeof t.swipeCloseThreshold == "number" && (g = t.swipeCloseThreshold), t.swipeCloseThreshold && typeof t.swipeCloseThreshold == "string" && t.swipeCloseThreshold.includes("%") && (g = a.value * (Number(t.swipeCloseThreshold.replace("%", "")) / 100)), u.value > g) {
|
|
328
|
+
u.value = a.value, Y();
|
|
329
329
|
return;
|
|
330
330
|
}
|
|
331
331
|
} else
|
|
332
332
|
u.value = 0;
|
|
333
333
|
if (u.value === a.value) {
|
|
334
|
-
u.value = 0,
|
|
334
|
+
u.value = 0, Y();
|
|
335
335
|
return;
|
|
336
336
|
}
|
|
337
|
-
const n = R.end();
|
|
338
|
-
if (n.isSwipe && n.direction === "down" && t.canSwipeClose && a.value <= O.value + 10) {
|
|
339
|
-
u.value = a.value,
|
|
337
|
+
const n = R.end(), r = d.value;
|
|
338
|
+
if (r && n.isSwipe && n.direction === "down" && t.canSwipeClose && a.value <= O.value + 10) {
|
|
339
|
+
u.value = a.value, Y();
|
|
340
340
|
return;
|
|
341
341
|
}
|
|
342
|
-
let
|
|
343
|
-
if (n.isSwipe &&
|
|
344
|
-
const
|
|
342
|
+
let c;
|
|
343
|
+
if (r && n.isSwipe && x.value.length > 1) {
|
|
344
|
+
const g = [...x.value].sort((k, V) => k - V);
|
|
345
345
|
if (n.direction === "up") {
|
|
346
|
-
const
|
|
347
|
-
|
|
346
|
+
const k = g.find((V) => V > a.value + 1);
|
|
347
|
+
c = k !== void 0 ? x.value.indexOf(k) : F.value;
|
|
348
348
|
} else {
|
|
349
|
-
const
|
|
350
|
-
|
|
349
|
+
const k = [...g].reverse().find((V) => V < a.value - 1);
|
|
350
|
+
c = k !== void 0 ? x.value.indexOf(k) : F.value;
|
|
351
351
|
}
|
|
352
352
|
} else
|
|
353
|
-
|
|
354
|
-
B.value =
|
|
355
|
-
let
|
|
356
|
-
if (typeof
|
|
353
|
+
c = F.value;
|
|
354
|
+
B.value = c;
|
|
355
|
+
let f;
|
|
356
|
+
if (typeof p.value[c] == "number" ? f = T(p.value[c], {
|
|
357
357
|
max: h.value
|
|
358
|
-
}) :
|
|
359
|
-
|
|
358
|
+
}) : f = N(
|
|
359
|
+
p.value[c],
|
|
360
360
|
h.value
|
|
361
|
-
),
|
|
362
|
-
|
|
361
|
+
), f === 0) {
|
|
362
|
+
Y();
|
|
363
363
|
return;
|
|
364
364
|
}
|
|
365
|
-
a.value =
|
|
366
|
-
}, Ee = () => {
|
|
367
|
-
t.blocking || (N.value = !0, q.value = !0);
|
|
365
|
+
a.value = f, u.value = 0, v("snapped", p.value.indexOf(p.value[c]));
|
|
368
366
|
}, He = () => {
|
|
369
|
-
t.blocking || (
|
|
367
|
+
t.blocking || (q.value = !0, Q.value = !0);
|
|
370
368
|
}, Ie = () => {
|
|
369
|
+
t.blocking || (q.value = !1, Q.value = !1);
|
|
370
|
+
}, $e = () => {
|
|
371
371
|
if (!P.value) return;
|
|
372
372
|
const e = P.value.scrollTop === 0;
|
|
373
373
|
d.value = e;
|
|
374
|
-
},
|
|
374
|
+
}, Fe = Xe((e) => fe(e), {
|
|
375
375
|
minQuietPeriodMs: t.duration,
|
|
376
376
|
reducer: (e, n) => n
|
|
377
377
|
});
|
|
378
|
-
|
|
378
|
+
J(p, (e, n) => {
|
|
379
379
|
if (C.value === !1 || !e || !n) return;
|
|
380
|
-
const
|
|
381
|
-
typeof
|
|
380
|
+
const r = e[B.value], c = n[B.value];
|
|
381
|
+
typeof r != "string" && typeof c != "string" && (a.value = T(r, {
|
|
382
382
|
max: h.value
|
|
383
383
|
}));
|
|
384
|
-
}),
|
|
385
|
-
|
|
386
|
-
}),
|
|
384
|
+
}), J(h, () => {
|
|
385
|
+
Fe.call(B.value);
|
|
386
|
+
}), J(Z, (e) => {
|
|
387
387
|
v("instinctHeight", e);
|
|
388
|
-
}),
|
|
389
|
-
|
|
388
|
+
}), We(() => {
|
|
389
|
+
ee.deactivate();
|
|
390
390
|
});
|
|
391
|
-
const
|
|
391
|
+
const Re = (e) => {
|
|
392
392
|
const n = e;
|
|
393
393
|
n.style.transition = `transform ${t.duration}ms ease, height ${t.duration}ms ease`, n.style.transform = `translateY(${a.value}px)`;
|
|
394
394
|
};
|
|
395
|
-
return l({ open:
|
|
396
|
-
(
|
|
395
|
+
return l({ open: ne, close: Y, snapToPoint: fe }), (e, n) => (W(), le(ze, null, [
|
|
396
|
+
(W(), Se(Ce, {
|
|
397
397
|
to: e.teleportTo,
|
|
398
398
|
defer: e.teleportDefer
|
|
399
399
|
}, [
|
|
400
|
-
|
|
401
|
-
default:
|
|
402
|
-
|
|
400
|
+
be(ye, { name: "vsbs-backdrop" }, {
|
|
401
|
+
default: Pe(() => [
|
|
402
|
+
oe(C) && e.blocking ? (W(), le("div", {
|
|
403
403
|
key: 0,
|
|
404
404
|
ref_key: "backdrop",
|
|
405
405
|
ref: M,
|
|
406
406
|
"data-vsbs-backdrop": "",
|
|
407
|
-
onClick: n[0] || (n[0] = (
|
|
408
|
-
}, null, 512)) :
|
|
407
|
+
onClick: n[0] || (n[0] = (r) => De())
|
|
408
|
+
}, null, 512)) : Te("", !0)
|
|
409
409
|
]),
|
|
410
410
|
_: 1
|
|
411
411
|
})
|
|
412
412
|
], 8, ["to", "defer"])),
|
|
413
|
-
(
|
|
413
|
+
(W(), Se(Ce, {
|
|
414
414
|
to: e.teleportTo,
|
|
415
415
|
defer: e.teleportDefer
|
|
416
416
|
}, [
|
|
417
|
-
|
|
417
|
+
be(ye, {
|
|
418
418
|
name: "vsbs-sheet",
|
|
419
|
-
onLeave:
|
|
419
|
+
onLeave: Re
|
|
420
420
|
}, {
|
|
421
|
-
default:
|
|
422
|
-
|
|
421
|
+
default: Pe(() => [
|
|
422
|
+
oe(C) ? (W(), le("div", {
|
|
423
423
|
key: 0,
|
|
424
424
|
ref_key: "sheet",
|
|
425
425
|
ref: i,
|
|
426
|
-
style:
|
|
426
|
+
style: Ne({
|
|
427
427
|
transform: `translateY(${u.value}px)`,
|
|
428
428
|
height: `${a.value}px`,
|
|
429
429
|
transition: E.value ? "none" : `transform ${e.duration}ms ease, height ${e.duration}ms ease`
|
|
430
430
|
}),
|
|
431
431
|
"data-vsbs-shadow": !e.blocking,
|
|
432
|
-
"data-vsbs-sheet-show":
|
|
432
|
+
"data-vsbs-sheet-show": oe(C),
|
|
433
433
|
"aria-modal": "true",
|
|
434
434
|
"data-vsbs-sheet": "",
|
|
435
435
|
tabindex: "-1",
|
|
436
|
-
onTouchstart:
|
|
437
|
-
onTouchend:
|
|
436
|
+
onTouchstart: He,
|
|
437
|
+
onTouchend: Ie
|
|
438
438
|
}, [
|
|
439
|
-
|
|
439
|
+
z("div", {
|
|
440
440
|
ref_key: "sheetHeader",
|
|
441
441
|
ref: y,
|
|
442
442
|
"data-vsbs-header": "",
|
|
443
|
-
onPointerdown:
|
|
444
|
-
onPointermove:
|
|
445
|
-
onPointerup:
|
|
446
|
-
onPointercancel:
|
|
447
|
-
onTouchmove:
|
|
448
|
-
class:
|
|
443
|
+
onPointerdown: he,
|
|
444
|
+
onPointermove: me,
|
|
445
|
+
onPointerup: U,
|
|
446
|
+
onPointercancel: U,
|
|
447
|
+
onTouchmove: ve,
|
|
448
|
+
class: ue(e.headerClass),
|
|
449
449
|
style: { "touch-action": "none" }
|
|
450
450
|
}, [
|
|
451
|
-
|
|
451
|
+
se(e.$slots, "header", {}, void 0, !0)
|
|
452
452
|
], 34),
|
|
453
|
-
|
|
453
|
+
z("div", {
|
|
454
454
|
ref_key: "sheetScroll",
|
|
455
455
|
ref: P,
|
|
456
456
|
"data-vsbs-scroll": "",
|
|
457
|
-
onScrollend:
|
|
457
|
+
onScrollend: $e
|
|
458
458
|
}, [
|
|
459
|
-
|
|
459
|
+
z("div", {
|
|
460
460
|
ref_key: "sheetContentWrapper",
|
|
461
461
|
ref: w,
|
|
462
462
|
"data-vsbs-content-wrapper": "",
|
|
463
|
-
onPointerdown:
|
|
464
|
-
onPointermove:
|
|
465
|
-
onPointerup:
|
|
466
|
-
onPointercancel:
|
|
467
|
-
onTouchmove:
|
|
463
|
+
onPointerdown: Be,
|
|
464
|
+
onPointermove: Ee,
|
|
465
|
+
onPointerup: ge,
|
|
466
|
+
onPointercancel: ge,
|
|
467
|
+
onTouchmove: ce,
|
|
468
468
|
style: { touchAction: "pan-y" }
|
|
469
469
|
}, [
|
|
470
|
-
|
|
470
|
+
z("div", {
|
|
471
471
|
ref_key: "sheetContent",
|
|
472
472
|
ref: S,
|
|
473
473
|
"data-vsbs-content": "",
|
|
474
|
-
class:
|
|
474
|
+
class: ue(e.contentClass)
|
|
475
475
|
}, [
|
|
476
|
-
|
|
476
|
+
se(e.$slots, "default", {}, void 0, !0)
|
|
477
477
|
], 2)
|
|
478
478
|
], 544)
|
|
479
479
|
], 544),
|
|
480
|
-
|
|
480
|
+
z("div", {
|
|
481
481
|
ref_key: "sheetFooter",
|
|
482
482
|
ref: b,
|
|
483
483
|
"data-vsbs-footer": "",
|
|
484
|
-
onPointerdown:
|
|
485
|
-
onPointermove:
|
|
486
|
-
onPointerup:
|
|
487
|
-
onPointercancel:
|
|
488
|
-
onTouchmove:
|
|
489
|
-
class:
|
|
484
|
+
onPointerdown: he,
|
|
485
|
+
onPointermove: me,
|
|
486
|
+
onPointerup: U,
|
|
487
|
+
onPointercancel: U,
|
|
488
|
+
onTouchmove: ve,
|
|
489
|
+
class: ue(e.footerClass),
|
|
490
490
|
style: { "touch-action": "none" }
|
|
491
491
|
}, [
|
|
492
|
-
|
|
492
|
+
se(e.$slots, "footer", {}, void 0, !0)
|
|
493
493
|
], 34)
|
|
494
|
-
], 44,
|
|
494
|
+
], 44, at)) : Te("", !0)
|
|
495
495
|
]),
|
|
496
496
|
_: 3
|
|
497
497
|
})
|
|
498
498
|
], 8, ["to", "defer"]))
|
|
499
499
|
], 64));
|
|
500
500
|
}
|
|
501
|
-
}),
|
|
502
|
-
const
|
|
501
|
+
}), ot = (o, l) => {
|
|
502
|
+
const s = o.__vccOpts || o;
|
|
503
503
|
for (const [t, v] of l)
|
|
504
|
-
|
|
505
|
-
return
|
|
506
|
-
},
|
|
504
|
+
s[t] = v;
|
|
505
|
+
return s;
|
|
506
|
+
}, it = /* @__PURE__ */ ot(lt, [["__scopeId", "data-v-606a4041"]]);
|
|
507
507
|
export {
|
|
508
|
-
|
|
508
|
+
it as default
|
|
509
509
|
};
|
package/dist/style.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
[data-vsbs-backdrop][data-v-
|
|
1
|
+
[data-vsbs-backdrop][data-v-606a4041]{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;--vsbs-duration: var(--03a2828a)}[data-vsbs-shadow=true][data-v-606a4041]: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-606a4041]{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-606a4041]{visibility:visible}[data-vsbs-header][data-v-606a4041]{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-606a4041]: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-606a4041]:empty{box-shadow:none;padding:14px var(--vsbs-padding-x, 16px) 10px}[data-vsbs-footer][data-v-606a4041]{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-606a4041]:empty{display:none}[data-vsbs-scroll][data-v-606a4041]{flex-grow:1;overflow-y:auto;overscroll-behavior:none}[data-vsbs-content-wrapper][data-v-606a4041]{height:100%}[data-vsbs-content][data-v-606a4041]{display:grid;padding:8px var(--vsbs-padding-x, 16px);-webkit-user-select:none;user-select:none}.vsbs-backdrop-enter-active[data-v-606a4041],.vsbs-backdrop-leave-active[data-v-606a4041]{transition:opacity var(--vsbs-duration) ease}.vsbs-backdrop-enter-from[data-v-606a4041],.vsbs-backdrop-leave-to[data-v-606a4041]{opacity:0}
|