@douxcode/vue-spring-bottom-sheet 1.0.6 → 1.0.7
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 +28 -28
- package/dist/style.css +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { computed as C, defineComponent as
|
|
1
|
+
import { computed as C, defineComponent as ae, ref as u, toRefs as te, watch as ne, nextTick as R, onMounted as oe, openBlock as le, createBlock as se, Teleport as ue, createElementVNode as d, createVNode as ie, Transition as re, withCtx as ve, withDirectives as de, vShow as ce, renderSlot as P } from "vue";
|
|
2
2
|
import { useWindowSize as he, useElementBounding as B, useScrollLock as pe } from "@vueuse/core";
|
|
3
3
|
import { useGesture as E, rubberbandIfOutOfBounds as I } from "@vueuse/gesture";
|
|
4
4
|
import { useMotionProperties as fe, useMotionTransitions as ge, useMotionControls as me } from "@vueuse/motion";
|
|
@@ -17,7 +17,7 @@ function ye(c, g) {
|
|
|
17
17
|
closestSnapPoint: s
|
|
18
18
|
};
|
|
19
19
|
}
|
|
20
|
-
const ke = { "data-vsbs-container": "" }, we = ["data-vsbs-shadow", "data-vsbs-sheet-show"], Se = /* @__PURE__ */
|
|
20
|
+
const ke = { "data-vsbs-container": "" }, we = ["data-vsbs-shadow", "data-vsbs-sheet-show"], Se = /* @__PURE__ */ ae({
|
|
21
21
|
__name: "BottomSheet",
|
|
22
22
|
props: {
|
|
23
23
|
snapPoints: {},
|
|
@@ -29,8 +29,8 @@ const ke = { "data-vsbs-container": "" }, we = ["data-vsbs-shadow", "data-vsbs-s
|
|
|
29
29
|
},
|
|
30
30
|
emits: ["opened", "closed", "ready", "dragging-up", "dragging-down", "minHeight", "maxHeight"],
|
|
31
31
|
setup(c, { expose: g, emit: i }) {
|
|
32
|
-
const n = c, o = i, s = u(null), h = u(null), v = u(null), m = u(null), F = u(null), L = u(null), W = u(null), T = u(!1), r = u(n.expandOnContentDrag), { height: b } = he(), { height: _ } = B(s), { height: z } = B(h), { height: G } = B(v), { height: K } = B(L), { activate: Y, deactivate: j } = be([s, W]), p = C(() => Math.ceil(K.value + z.value + G.value)), { motionProperties: y } = fe(s), { push: k, stop: q, motionValues: H } = ge(), { set: w } = me(y, {}, { push: k, motionValues: H, stop: q }), e = u(0),
|
|
33
|
-
|
|
32
|
+
const n = c, o = i, s = u(null), h = u(null), v = u(null), m = u(null), F = u(null), L = u(null), W = u(null), T = u(!1), r = u(n.expandOnContentDrag), { height: b } = he(), { height: _ } = B(s), { height: z } = B(h), { height: G } = B(v), { height: K } = B(L), { activate: Y, deactivate: j } = be([s, W]), p = C(() => Math.ceil(K.value + z.value + G.value)), { motionProperties: y } = fe(s), { push: k, stop: q, motionValues: H } = ge(), { set: w } = me(y, {}, { push: k, motionValues: H, stop: q }), e = u(0), t = u(0), { snapPoints: J } = te(n), Q = C(() => J.value ?? [p.value]), { minSnap: f, maxSnap: S, snapPoints: D, closestSnapPoint: U } = ye(Q, e), $ = pe(document.body), N = (a) => {
|
|
33
|
+
a.key === "Escape" && x();
|
|
34
34
|
}, X = () => {
|
|
35
35
|
s.value && (e.value = Math.min(n.defaultBreakpoint ?? f.value, b.value), w({
|
|
36
36
|
height: e.value,
|
|
@@ -45,24 +45,24 @@ const ke = { "data-vsbs-container": "" }, we = ["data-vsbs-shadow", "data-vsbs-s
|
|
|
45
45
|
}, Z = () => {
|
|
46
46
|
n.canBackdropClose && x();
|
|
47
47
|
};
|
|
48
|
-
function ee(
|
|
49
|
-
r.value &&
|
|
48
|
+
function ee(a) {
|
|
49
|
+
r.value && a.preventDefault();
|
|
50
50
|
}
|
|
51
|
-
const V = (
|
|
52
|
-
s.value && (e.value =
|
|
51
|
+
const V = (a) => {
|
|
52
|
+
s.value && (e.value = a, k("height", e.value, y, {
|
|
53
53
|
type: "tween",
|
|
54
54
|
easings: "easeInOut",
|
|
55
55
|
bounce: 0,
|
|
56
56
|
duration: 300
|
|
57
57
|
}));
|
|
58
|
-
}, A = ({ delta:
|
|
59
|
-
s.value && (
|
|
60
|
-
y: n.canSwipeClose ?
|
|
61
|
-
})), w({
|
|
62
|
-
height: Math.
|
|
58
|
+
}, A = ({ delta: a, direction: l }) => {
|
|
59
|
+
s.value && (t.value === 0 && (e.value -= a[1]), e.value <= f.value && (e.value = f.value, t.value += a[1], t.value = Math.max(0, Math.min(t.value, f.value)), w({
|
|
60
|
+
y: n.canSwipeClose ? t.value : I(t.value, -_.value, 0, 0.5)
|
|
61
|
+
})), e.value = Math.min(e.value, b.value), w({
|
|
62
|
+
height: Math.max(I(e.value, 0, S.value, 0.25), 0)
|
|
63
63
|
}), l[1] > 0 ? o("dragging-down") : l[1] < 0 && o("dragging-up"));
|
|
64
64
|
}, O = () => {
|
|
65
|
-
s.value && (
|
|
65
|
+
s.value && (t.value = n.canSwipeClose ? [0, e.value].reduce((a, l) => Math.abs(l - t.value) < Math.abs(a - t.value) ? l : a) : 0, k("y", t.value, y, { type: "tween", easings: "easeInOut", bounce: 0, duration: 300 }), t.value === e.value && (t.value = 0, x()), e.value = Math.min(D.value[U.value], b.value), k("height", e.value, y, { type: "tween", easings: "easeInOut", bounce: 0, duration: 300 }));
|
|
66
66
|
};
|
|
67
67
|
return E(
|
|
68
68
|
{
|
|
@@ -84,21 +84,21 @@ const ke = { "data-vsbs-container": "" }, we = ["data-vsbs-shadow", "data-vsbs-s
|
|
|
84
84
|
}
|
|
85
85
|
), E(
|
|
86
86
|
{
|
|
87
|
-
onDragStart: ({ direction:
|
|
88
|
-
const l = m.value.scrollTop === 0, M =
|
|
89
|
-
D.value.length === 1 ?
|
|
87
|
+
onDragStart: ({ direction: a }) => {
|
|
88
|
+
const l = m.value.scrollTop === 0, M = a[1] > 0;
|
|
89
|
+
D.value.length === 1 ? t.value === 0 && l && (r.value = M) : (n.expandOnContentDrag && e.value !== S.value && (r.value = !0), e.value === S.value && l && (r.value = M));
|
|
90
90
|
},
|
|
91
|
-
onDrag: ({ delta:
|
|
91
|
+
onDrag: ({ delta: a, direction: l }) => {
|
|
92
92
|
if (!n.expandOnContentDrag) {
|
|
93
93
|
r.value = !1;
|
|
94
94
|
return;
|
|
95
95
|
}
|
|
96
96
|
if (!s.value) return;
|
|
97
|
-
|
|
98
|
-
y: n.canSwipeClose ?
|
|
97
|
+
t.value === 0 && r.value && n.expandOnContentDrag && (e.value -= a[1]), e.value <= f.value && (e.value = f.value, r.value && n.expandOnContentDrag && (t.value += a[1]), t.value = Math.max(0, Math.min(t.value, f.value)), w({
|
|
98
|
+
y: n.canSwipeClose ? t.value : I(t.value, -_.value, 0, 0.5)
|
|
99
99
|
})), e.value > S.value && (e.value = S.value), e.value = Math.min(e.value, b.value);
|
|
100
100
|
const M = m.value.scrollTop === 0;
|
|
101
|
-
D.value.length === 1 ?
|
|
101
|
+
D.value.length === 1 ? a[1] < 0 && t.value === 0 && M && (r.value = !1) : e.value === S.value && (r.value = !1), w({
|
|
102
102
|
height: e.value
|
|
103
103
|
}), l[1] > 0 ? o("dragging-down") : l[1] < 0 && o("dragging-up");
|
|
104
104
|
},
|
|
@@ -119,7 +119,7 @@ const ke = { "data-vsbs-container": "" }, we = ["data-vsbs-shadow", "data-vsbs-s
|
|
|
119
119
|
}), R(() => {
|
|
120
120
|
o("ready");
|
|
121
121
|
});
|
|
122
|
-
}), g({ open: X, close: x, snapToPoint: V }), (
|
|
122
|
+
}), g({ open: X, close: x, snapToPoint: V }), (a, l) => (le(), se(ue, { to: "body" }, [
|
|
123
123
|
d("div", ke, [
|
|
124
124
|
ie(re, { name: "fade" }, {
|
|
125
125
|
default: ve(() => [
|
|
@@ -129,7 +129,7 @@ const ke = { "data-vsbs-container": "" }, we = ["data-vsbs-shadow", "data-vsbs-s
|
|
|
129
129
|
"data-vsbs-backdrop": "",
|
|
130
130
|
onClick: l[0] || (l[0] = (M) => Z())
|
|
131
131
|
}, null, 512), [
|
|
132
|
-
[ce, T.value &&
|
|
132
|
+
[ce, T.value && a.blocking]
|
|
133
133
|
])
|
|
134
134
|
]),
|
|
135
135
|
_: 1
|
|
@@ -137,7 +137,7 @@ const ke = { "data-vsbs-container": "" }, we = ["data-vsbs-shadow", "data-vsbs-s
|
|
|
137
137
|
d("div", {
|
|
138
138
|
ref_key: "sheet",
|
|
139
139
|
ref: s,
|
|
140
|
-
"data-vsbs-shadow": !
|
|
140
|
+
"data-vsbs-shadow": !a.blocking,
|
|
141
141
|
"data-vsbs-sheet-show": T.value,
|
|
142
142
|
"aria-modal": "true",
|
|
143
143
|
"data-vsbs-sheet": "",
|
|
@@ -148,7 +148,7 @@ const ke = { "data-vsbs-container": "" }, we = ["data-vsbs-shadow", "data-vsbs-s
|
|
|
148
148
|
ref: h,
|
|
149
149
|
"data-vsbs-header": ""
|
|
150
150
|
}, [
|
|
151
|
-
P(
|
|
151
|
+
P(a.$slots, "header", {}, void 0, !0)
|
|
152
152
|
], 512),
|
|
153
153
|
d("div", {
|
|
154
154
|
ref_key: "sheetScroll",
|
|
@@ -166,7 +166,7 @@ const ke = { "data-vsbs-container": "" }, we = ["data-vsbs-shadow", "data-vsbs-s
|
|
|
166
166
|
ref: L,
|
|
167
167
|
"data-vsbs-content": ""
|
|
168
168
|
}, [
|
|
169
|
-
P(
|
|
169
|
+
P(a.$slots, "default", {}, void 0, !0)
|
|
170
170
|
], 512)
|
|
171
171
|
], 512)
|
|
172
172
|
], 544),
|
|
@@ -175,7 +175,7 @@ const ke = { "data-vsbs-container": "" }, we = ["data-vsbs-shadow", "data-vsbs-s
|
|
|
175
175
|
ref: v,
|
|
176
176
|
"data-vsbs-footer": ""
|
|
177
177
|
}, [
|
|
178
|
-
P(
|
|
178
|
+
P(a.$slots, "footer", {}, void 0, !0)
|
|
179
179
|
], 512)
|
|
180
180
|
], 8, we)
|
|
181
181
|
])
|
|
@@ -186,7 +186,7 @@ const ke = { "data-vsbs-container": "" }, we = ["data-vsbs-shadow", "data-vsbs-s
|
|
|
186
186
|
for (const [n, o] of g)
|
|
187
187
|
i[n] = o;
|
|
188
188
|
return i;
|
|
189
|
-
}, He = /* @__PURE__ */ Ce(Se, [["__scopeId", "data-v-
|
|
189
|
+
}, He = /* @__PURE__ */ Ce(Se, [["__scopeId", "data-v-31145f24"]]);
|
|
190
190
|
export {
|
|
191
191
|
He as default
|
|
192
192
|
};
|
package/dist/style.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
[data-vsbs-backdrop][data-v-
|
|
1
|
+
[data-vsbs-backdrop][data-v-31145f24]{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:100}[data-vsbs-shadow=true][data-v-31145f24]{box-shadow:0 -5px 60px #26597333,0 -1px #2659730f}[data-vsbs-sheet][data-v-31145f24]{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:visibility .3s ease-in-out;visibility:hidden;width:100%;will-change:height;z-index:100}[data-vsbs-sheet-show=true][data-v-31145f24]{visibility:visible}[data-vsbs-header][data-v-31145f24]{box-shadow:0 1px #2e3b4220;flex-shrink:0;padding:20px 16px 8px;-webkit-user-select:none;user-select:none;z-index:1}[data-vsbs-header][data-v-31145f24]: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-31145f24]:empty{box-shadow:none;padding:12px 16px 8px}[data-vsbs-footer][data-v-31145f24]{box-shadow:0 -1px #2e3b4220;flex-grow:0;flex-shrink:0;padding:16px;-webkit-user-select:none;user-select:none}[data-vsbs-footer][data-v-31145f24]:empty{display:none}[data-vsbs-scroll][data-v-31145f24]{flex-grow:1;overflow-y:auto;overscroll-behavior:contain}[data-vsbs-content-wrapper][data-v-31145f24]{height:100%}[data-vsbs-content][data-v-31145f24]{display:grid;padding:1vh 3vh 3vh;-webkit-user-select:none;user-select:none}.fade-enter-active[data-v-31145f24],.fade-leave-active[data-v-31145f24]{transition:opacity .3s ease}.fade-enter-from[data-v-31145f24],.fade-leave-to[data-v-31145f24]{opacity:0}
|