@douxcode/vue-spring-bottom-sheet 1.2.5 → 1.2.6
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 +53 -53
- package/dist/style.css +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { computed as y, defineComponent as ce, useCssVars as fe, ref as g, toRefs as he, watch as ee, nextTick as
|
|
1
|
+
import { computed as y, defineComponent as ce, useCssVars as fe, ref as g, toRefs as he, watch as ee, nextTick as R, onMounted as ge, openBlock as pe, createBlock as me, Teleport as be, createElementVNode as b, createVNode as ye, Transition as Se, withCtx as we, withDirectives as ke, vShow as Te, renderSlot as z } from "vue";
|
|
2
2
|
import { useWindowSize as Ce, useElementBounding as I, useScrollLock as te } from "@vueuse/core";
|
|
3
|
-
import { useGesture as
|
|
3
|
+
import { useGesture as N, rubberbandIfOutOfBounds as G } from "@vueuse/gesture";
|
|
4
4
|
import { useMotionProperties as De, useMotionTransitions as xe, useMotionControls as Me } from "@vueuse/motion";
|
|
5
5
|
import { useFocusTrap as Pe } from "@vueuse/integrations/useFocusTrap";
|
|
6
6
|
function _e(o, u, a) {
|
|
@@ -13,7 +13,7 @@ function He(o, u, a) {
|
|
|
13
13
|
if (e === 1) return _e(o, u, a);
|
|
14
14
|
throw new Error("Wrong number of arguments");
|
|
15
15
|
}
|
|
16
|
-
function Oe(o, { triggerAt: u = "end", minQuietPeriodMs: a, maxBurstDurationMs: e, minGapMs: n, reducer:
|
|
16
|
+
function Oe(o, { triggerAt: u = "end", minQuietPeriodMs: a, maxBurstDurationMs: e, minGapMs: n, reducer: c = Be }) {
|
|
17
17
|
let s, r, f, S, C = () => {
|
|
18
18
|
let v = f;
|
|
19
19
|
v !== void 0 && (f = void 0, o(v), n !== void 0 && (r = setTimeout(H, n)));
|
|
@@ -24,7 +24,7 @@ function Oe(o, { triggerAt: u = "end", minQuietPeriodMs: a, maxBurstDurationMs:
|
|
|
24
24
|
};
|
|
25
25
|
return { call: (...v) => {
|
|
26
26
|
let h = s === void 0 && r === void 0;
|
|
27
|
-
if ((u !== "start" || h) && (f =
|
|
27
|
+
if ((u !== "start" || h) && (f = c(f, ...v)), !(s === void 0 && !h)) {
|
|
28
28
|
if (a !== void 0 || e !== void 0 || n === void 0) {
|
|
29
29
|
clearTimeout(s);
|
|
30
30
|
let p = Date.now();
|
|
@@ -48,7 +48,7 @@ function $(...o) {
|
|
|
48
48
|
}
|
|
49
49
|
var Ee = (o, { min: u, max: a }) => u !== void 0 && o < u ? u : a !== void 0 && o > a ? a : o;
|
|
50
50
|
function Ie(o, u) {
|
|
51
|
-
const a = y(() => o.value.sort()), e = y(() => a.value[0]), n = y(() => a.value[a.value.length - 1]),
|
|
51
|
+
const a = y(() => o.value.sort()), e = y(() => a.value[0]), n = y(() => a.value[a.value.length - 1]), c = y(() => {
|
|
52
52
|
const s = a.value.reduce(
|
|
53
53
|
(r, f) => Math.abs(f - u.value) < Math.abs(r - u.value) ? f : r
|
|
54
54
|
);
|
|
@@ -58,7 +58,7 @@ function Ie(o, u) {
|
|
|
58
58
|
minSnap: e,
|
|
59
59
|
maxSnap: n,
|
|
60
60
|
snapPoints: o,
|
|
61
|
-
closestSnapPointIndex:
|
|
61
|
+
closestSnapPointIndex: c
|
|
62
62
|
};
|
|
63
63
|
}
|
|
64
64
|
const $e = { "data-vsbs-container": "" }, We = ["data-vsbs-shadow", "data-vsbs-sheet-show"], Fe = /* @__PURE__ */ ce({
|
|
@@ -75,15 +75,15 @@ const $e = { "data-vsbs-container": "" }, We = ["data-vsbs-shadow", "data-vsbs-s
|
|
|
75
75
|
emits: ["opened", "closed", "ready", "dragging-up", "dragging-down", "minHeight", "maxHeight"],
|
|
76
76
|
setup(o, { expose: u, emit: a }) {
|
|
77
77
|
fe((i) => ({
|
|
78
|
-
|
|
79
|
-
"
|
|
78
|
+
"14f7879e": ne.value,
|
|
79
|
+
"5872cb4c": ue.value
|
|
80
80
|
}));
|
|
81
|
-
const e = o, n = a,
|
|
81
|
+
const e = o, n = a, c = g(null), s = g(null), r = g(null), f = g(null), S = g(null), C = g(null), H = g(null), w = g(!1), v = g(e.expandOnContentDrag), { height: h } = Ce(), { height: p } = I(c), { height: W } = I(s), { height: ae } = I(r), { height: oe } = I(C), Q = Pe([c, H], {
|
|
82
82
|
immediate: !1,
|
|
83
|
-
fallbackFocus: () =>
|
|
83
|
+
fallbackFocus: () => c.value || document.body
|
|
84
84
|
}), k = y(
|
|
85
85
|
() => Math.ceil(oe.value + W.value + ae.value)
|
|
86
|
-
), ne = y(() => `visibility ${e.duration}ms ease-in-out`), ue = y(() => `opacity ${e.duration}ms ease-in-out`), { motionProperties: D } = De(
|
|
86
|
+
), ne = y(() => `visibility ${e.duration}ms ease-in-out`), ue = y(() => `opacity ${e.duration}ms ease-in-out`), { motionProperties: D } = De(c), { push: x, stop: le, motionValues: O } = xe(), { set: M, stop: j } = Me(
|
|
87
87
|
D,
|
|
88
88
|
{},
|
|
89
89
|
{ push: x, motionValues: O, stop: le }
|
|
@@ -92,10 +92,10 @@ const $e = { "data-vsbs-container": "" }, We = ["data-vsbs-shadow", "data-vsbs-s
|
|
|
92
92
|
maxSnap: _,
|
|
93
93
|
snapPoints: T,
|
|
94
94
|
closestSnapPointIndex: F
|
|
95
|
-
} = Ie(se, t),
|
|
95
|
+
} = Ie(se, t), L = te(document.body), V = te(document.documentElement), K = (i) => {
|
|
96
96
|
i.key === "Escape" && E();
|
|
97
97
|
}, re = () => {
|
|
98
|
-
|
|
98
|
+
c.value && (t.value = Math.min(e.defaultSnapPoint ?? P.value, h.value), M({
|
|
99
99
|
height: t.value,
|
|
100
100
|
y: t.value
|
|
101
101
|
}), x("y", 0, D, {
|
|
@@ -103,15 +103,15 @@ const $e = { "data-vsbs-container": "" }, We = ["data-vsbs-shadow", "data-vsbs-s
|
|
|
103
103
|
easings: "easeInOut",
|
|
104
104
|
bounce: 0,
|
|
105
105
|
duration: e.duration
|
|
106
|
-
}), w.value = !0,
|
|
107
|
-
O.value.y.get() - 0 < 0.1 && (n("opened"),
|
|
106
|
+
}), w.value = !0, window.addEventListener("keydown", K), e.blocking && setTimeout(() => {
|
|
107
|
+
O.value.y.get() - 0 < 0.1 && (n("opened"), Q.activate());
|
|
108
108
|
}, e.duration));
|
|
109
109
|
}, E = () => {
|
|
110
|
-
|
|
110
|
+
c.value && (x("y", p.value, D, {
|
|
111
111
|
type: "tween",
|
|
112
112
|
bounce: 0,
|
|
113
113
|
duration: e.duration
|
|
114
|
-
}), w.value = !1,
|
|
114
|
+
}), w.value = !1, e.blocking && Q.deactivate(), window.removeEventListener("keydown", K), setTimeout(() => {
|
|
115
115
|
O.value.y.get() - p.value < 0.1 && n("closed");
|
|
116
116
|
}, e.duration));
|
|
117
117
|
}, ve = () => {
|
|
@@ -123,7 +123,7 @@ const $e = { "data-vsbs-container": "" }, We = ["data-vsbs-shadow", "data-vsbs-s
|
|
|
123
123
|
function q(i) {
|
|
124
124
|
v.value && i.preventDefault();
|
|
125
125
|
}
|
|
126
|
-
const
|
|
126
|
+
const X = (i) => {
|
|
127
127
|
t.value = i, x("height", t.value, D, {
|
|
128
128
|
type: "tween",
|
|
129
129
|
easings: "easeInOut",
|
|
@@ -131,20 +131,20 @@ const $e = { "data-vsbs-container": "" }, We = ["data-vsbs-shadow", "data-vsbs-s
|
|
|
131
131
|
duration: e.duration
|
|
132
132
|
});
|
|
133
133
|
}, J = ({
|
|
134
|
-
delta: [i,
|
|
134
|
+
delta: [i, d],
|
|
135
135
|
direction: [B, m]
|
|
136
136
|
}) => {
|
|
137
|
-
|
|
138
|
-
y: e.canSwipeClose ? $(l.value, { min: 0 }) : $(
|
|
137
|
+
c.value && (l.value <= 0 && (t.value -= d), t.value <= P.value && (t.value = P.value, l.value += d, M({
|
|
138
|
+
y: e.canSwipeClose ? $(l.value, { min: 0 }) : $(G(l.value, -p.value, 0, 0.5), { min: 0 })
|
|
139
139
|
})), M({
|
|
140
|
-
height: $(
|
|
140
|
+
height: $(G(t.value, 0, _.value, 0.25), {
|
|
141
141
|
min: 0,
|
|
142
142
|
max: h.value
|
|
143
143
|
})
|
|
144
144
|
}), m > 0 ? n("dragging-down") : m < 0 && n("dragging-up"));
|
|
145
|
-
},
|
|
146
|
-
|
|
147
|
-
(i,
|
|
145
|
+
}, A = () => {
|
|
146
|
+
L.value = !1, V.value = !1, l.value = e.canSwipeClose ? [0, t.value].reduce(
|
|
147
|
+
(i, d) => Math.abs(d - l.value) < Math.abs(i - l.value) ? d : i
|
|
148
148
|
) : 0, x("y", l.value, D, {
|
|
149
149
|
type: "tween",
|
|
150
150
|
easings: "easeInOut",
|
|
@@ -155,52 +155,52 @@ const $e = { "data-vsbs-container": "" }, We = ["data-vsbs-shadow", "data-vsbs-s
|
|
|
155
155
|
easings: "easeInOut",
|
|
156
156
|
bounce: 0,
|
|
157
157
|
duration: e.duration
|
|
158
|
-
})
|
|
158
|
+
});
|
|
159
159
|
}, Z = () => {
|
|
160
|
-
t.value = p.value, l.value = O.value.y.get(),
|
|
160
|
+
L.value = !0, V.value = !0, t.value = p.value, l.value = O.value.y.get(), j();
|
|
161
161
|
};
|
|
162
|
-
|
|
162
|
+
N(
|
|
163
163
|
{
|
|
164
164
|
onDragStart: Z,
|
|
165
165
|
onDrag: J,
|
|
166
|
-
onDragEnd:
|
|
166
|
+
onDragEnd: A
|
|
167
167
|
},
|
|
168
168
|
{
|
|
169
169
|
domTarget: s,
|
|
170
170
|
drag: { filterTaps: !0 }
|
|
171
171
|
}
|
|
172
|
-
),
|
|
172
|
+
), N(
|
|
173
173
|
{
|
|
174
174
|
onDragStart: Z,
|
|
175
175
|
onDrag: J,
|
|
176
|
-
onDragEnd:
|
|
176
|
+
onDragEnd: A
|
|
177
177
|
},
|
|
178
178
|
{
|
|
179
179
|
domTarget: r,
|
|
180
180
|
drag: { filterTaps: !0 }
|
|
181
181
|
}
|
|
182
|
-
),
|
|
182
|
+
), N(
|
|
183
183
|
{
|
|
184
|
-
onDragStart: ({ direction: [i,
|
|
185
|
-
t.value = p.value, l.value = O.value.y.get(),
|
|
186
|
-
const B = f.value.scrollTop === 0, m =
|
|
184
|
+
onDragStart: ({ direction: [i, d] }) => {
|
|
185
|
+
L.value = !0, V.value = !0, t.value = p.value, l.value = O.value.y.get(), j();
|
|
186
|
+
const B = f.value.scrollTop === 0, m = d > 0;
|
|
187
187
|
T.value.length === 1 ? l.value === 0 && B && (v.value = m) : (e.expandOnContentDrag && t.value !== _.value && (v.value = !0), t.value === _.value && B && (v.value = m));
|
|
188
188
|
},
|
|
189
|
-
onDrag: ({ delta: [i,
|
|
189
|
+
onDrag: ({ delta: [i, d], direction: [B, m] }) => {
|
|
190
190
|
if (!e.expandOnContentDrag) {
|
|
191
191
|
v.value = !1;
|
|
192
192
|
return;
|
|
193
193
|
}
|
|
194
|
-
if (!
|
|
195
|
-
l.value === 0 && v.value && e.expandOnContentDrag && (t.value -=
|
|
196
|
-
y: e.canSwipeClose ? l.value :
|
|
194
|
+
if (!c.value) return;
|
|
195
|
+
l.value === 0 && v.value && e.expandOnContentDrag && (t.value -= d), t.value <= P.value && (t.value = P.value, v.value && e.expandOnContentDrag && (l.value += d), l.value = $(l.value, { min: 0, max: P.value }), M({
|
|
196
|
+
y: e.canSwipeClose ? l.value : G(l.value, -p.value, 0, 0.5)
|
|
197
197
|
})), t.value > _.value && (t.value = _.value), t.value = Math.min(t.value, h.value);
|
|
198
198
|
const Y = f.value.scrollTop === 0;
|
|
199
|
-
T.value.length === 1 ?
|
|
199
|
+
T.value.length === 1 ? d < 0 && l.value === 0 && Y && (v.value = !1) : t.value === _.value && (v.value = !1), M({
|
|
200
200
|
height: t.value
|
|
201
201
|
}), m > 0 ? n("dragging-down") : m < 0 && n("dragging-up");
|
|
202
202
|
},
|
|
203
|
-
onDragEnd:
|
|
203
|
+
onDragEnd: A
|
|
204
204
|
},
|
|
205
205
|
{
|
|
206
206
|
domTarget: S,
|
|
@@ -209,8 +209,8 @@ const $e = { "data-vsbs-container": "" }, We = ["data-vsbs-shadow", "data-vsbs-s
|
|
|
209
209
|
);
|
|
210
210
|
const de = Oe(
|
|
211
211
|
() => {
|
|
212
|
-
n("maxHeight", h.value),
|
|
213
|
-
t.value = T.value[F.value],
|
|
212
|
+
n("maxHeight", h.value), R(() => {
|
|
213
|
+
t.value = T.value[F.value], X(T.value[F.value]);
|
|
214
214
|
});
|
|
215
215
|
},
|
|
216
216
|
{ minQuietPeriodMs: 50 }
|
|
@@ -218,17 +218,17 @@ const $e = { "data-vsbs-container": "" }, We = ["data-vsbs-shadow", "data-vsbs-s
|
|
|
218
218
|
return ee(h, () => {
|
|
219
219
|
de.call();
|
|
220
220
|
}), ee(k, () => {
|
|
221
|
-
n("minHeight", k.value), T.value.length === 1 &&
|
|
222
|
-
T.value[0] === k.value &&
|
|
221
|
+
n("minHeight", k.value), T.value.length === 1 && R(() => {
|
|
222
|
+
T.value[0] === k.value && X(Math.min(k.value, h.value));
|
|
223
223
|
});
|
|
224
224
|
}), ge(() => {
|
|
225
225
|
n("minHeight", k.value), n("maxHeight", h.value), t.value = e.defaultSnapPoint ?? Number(k.value), M({
|
|
226
226
|
height: t.value,
|
|
227
227
|
y: t.value
|
|
228
|
-
}),
|
|
228
|
+
}), R(() => {
|
|
229
229
|
n("ready");
|
|
230
230
|
});
|
|
231
|
-
}), u({ open: re, close: E, snapToPoint:
|
|
231
|
+
}), u({ open: re, close: E, snapToPoint: X }), (i, d) => (pe(), me(be, { to: "body" }, [
|
|
232
232
|
b("div", $e, [
|
|
233
233
|
ye(Se, { name: "fade" }, {
|
|
234
234
|
default: we(() => [
|
|
@@ -236,7 +236,7 @@ const $e = { "data-vsbs-container": "" }, We = ["data-vsbs-shadow", "data-vsbs-s
|
|
|
236
236
|
ref_key: "backdrop",
|
|
237
237
|
ref: H,
|
|
238
238
|
"data-vsbs-backdrop": "",
|
|
239
|
-
onClick:
|
|
239
|
+
onClick: d[0] || (d[0] = (B) => ve())
|
|
240
240
|
}, null, 512), [
|
|
241
241
|
[Te, w.value && i.blocking]
|
|
242
242
|
])
|
|
@@ -245,7 +245,7 @@ const $e = { "data-vsbs-container": "" }, We = ["data-vsbs-shadow", "data-vsbs-s
|
|
|
245
245
|
}),
|
|
246
246
|
b("div", {
|
|
247
247
|
ref_key: "sheet",
|
|
248
|
-
ref:
|
|
248
|
+
ref: c,
|
|
249
249
|
"data-vsbs-shadow": !i.blocking,
|
|
250
250
|
"data-vsbs-sheet-show": w.value,
|
|
251
251
|
"aria-modal": "true",
|
|
@@ -258,7 +258,7 @@ const $e = { "data-vsbs-container": "" }, We = ["data-vsbs-shadow", "data-vsbs-s
|
|
|
258
258
|
"data-vsbs-header": "",
|
|
259
259
|
onTouchmove: U
|
|
260
260
|
}, [
|
|
261
|
-
|
|
261
|
+
z(i.$slots, "header", {}, void 0, !0)
|
|
262
262
|
], 544),
|
|
263
263
|
b("div", {
|
|
264
264
|
ref_key: "sheetScroll",
|
|
@@ -276,7 +276,7 @@ const $e = { "data-vsbs-container": "" }, We = ["data-vsbs-shadow", "data-vsbs-s
|
|
|
276
276
|
ref: C,
|
|
277
277
|
"data-vsbs-content": ""
|
|
278
278
|
}, [
|
|
279
|
-
|
|
279
|
+
z(i.$slots, "default", {}, void 0, !0)
|
|
280
280
|
], 512)
|
|
281
281
|
], 512)
|
|
282
282
|
], 544),
|
|
@@ -286,7 +286,7 @@ const $e = { "data-vsbs-container": "" }, We = ["data-vsbs-shadow", "data-vsbs-s
|
|
|
286
286
|
"data-vsbs-footer": "",
|
|
287
287
|
onTouchmove: U
|
|
288
288
|
}, [
|
|
289
|
-
|
|
289
|
+
z(i.$slots, "footer", {}, void 0, !0)
|
|
290
290
|
], 544)
|
|
291
291
|
], 8, We)
|
|
292
292
|
])
|
|
@@ -297,7 +297,7 @@ const $e = { "data-vsbs-container": "" }, We = ["data-vsbs-shadow", "data-vsbs-s
|
|
|
297
297
|
for (const [e, n] of u)
|
|
298
298
|
a[e] = n;
|
|
299
299
|
return a;
|
|
300
|
-
}, Ne = /* @__PURE__ */ Le(Fe, [["__scopeId", "data-v-
|
|
300
|
+
}, Ne = /* @__PURE__ */ Le(Fe, [["__scopeId", "data-v-7f53bf25"]]);
|
|
301
301
|
export {
|
|
302
302
|
Ne as default
|
|
303
303
|
};
|
package/dist/style.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
[data-vsbs-container][data-v-
|
|
1
|
+
[data-vsbs-container][data-v-7f53bf25]{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-7f53bf25]{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-7f53bf25]{box-shadow:0 -5px 60px 0 var(--vsbs-shadow-color, rgba(89, 89, 89, .2))}[data-vsbs-sheet][data-v-7f53bf25]{background-color:var(--vsbs-background, #fff);border-top-left-radius:var(--vsbs-border-radius, 16px);border-top-right-radius:var(--vsbs-border-radius, 16px);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;transition:var(--14f7879e);visibility:hidden;width:100%;will-change:height;z-index:2}[data-vsbs-sheet-show=true][data-v-7f53bf25]{visibility:visible}[data-vsbs-header][data-v-7f53bf25]{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}[data-vsbs-header][data-v-7f53bf25]: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-7f53bf25]:empty{box-shadow:none;padding:12px var(--vsbs-padding-x, 16px) 8px}[data-vsbs-footer][data-v-7f53bf25]{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-7f53bf25]:empty{display:none}[data-vsbs-scroll][data-v-7f53bf25]{flex-grow:1;overflow-y:auto;overscroll-behavior:contain}[data-vsbs-content-wrapper][data-v-7f53bf25]{height:100%}[data-vsbs-content][data-v-7f53bf25]{display:grid;padding:1vh var(--vsbs-padding-x, 16px);-webkit-user-select:none;user-select:none}.fade-enter-active[data-v-7f53bf25],.fade-leave-active[data-v-7f53bf25]{transition:var(--5872cb4c)}.fade-enter-from[data-v-7f53bf25],.fade-leave-to[data-v-7f53bf25]{opacity:0}
|