@douxcode/vue-spring-bottom-sheet 2.2.2 → 2.4.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
@@ -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 | Description | Payload |
160
- | -------------- | -------------------------------------- | ----------------------- |
161
- | opened | Emitted when sheet finishes opening | - |
162
- | closed | Emitted when sheet finishes closing | - |
163
- | dragging-up | Emitted when user drags sheet upward | - |
164
- | dragging-down | Emitted when user drags sheet downward | - |
165
- | instinctHeight | Emitted when content height changes | height (number) |
166
- | snapped | Emitted when sheet finishes snapping | snapPointIndex (number) |
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
 
@@ -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
- opened: () => any;
27
- closed: () => any;
28
- ready: () => any;
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
- onOpened?: (() => any) | undefined;
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,53 +1,53 @@
1
- import { ref as P, computed as E, defineComponent as xe, watch as q, onMounted as Me, toRefs as Oe, nextTick as N, onUnmounted as _e, createBlock as Z, openBlock as ee, Teleport as Be, createElementVNode as te, createVNode as $, unref as m, withCtx as I, createCommentVNode as fe, normalizeStyle as Ie, renderSlot as ae } from "vue";
2
- import { useMotionValue as pe, animate as _, AnimatePresence as he, Motion as A } from "motion-v";
3
- import { useVModel as Ee, useWindowSize as De, useElementBounding as Q, useScrollLock as ge } from "@vueuse/core";
4
- import { useFocusTrap as He } from "@vueuse/integrations/useFocusTrap";
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 $, 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 A } from "motion-v";
3
+ import { useVModel as Ve, useWindowSize as Re, useElementBounding as Q, useScrollLock as ye } from "@vueuse/core";
4
+ import { useFocusTrap as Fe } 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 Ve(n, a, o) {
10
- const t = P(0), i = E(() => n.value.map((p) => typeof p == "string" ? G(p, o.value) : p)), y = E(() => Math.min(...i.value)), r = E(() => Math.max(...i.value)), h = E(() => {
11
- const p = i.value.reduce(
9
+ function $e(n, a, o) {
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
+ const p = s.value.reduce(
12
12
  (g, x) => Math.abs(x - a.value) < Math.abs(g - a.value) ? x : g
13
13
  );
14
- return i.value.indexOf(p);
14
+ return s.value.indexOf(p);
15
15
  });
16
16
  return {
17
17
  currentSnapPointIndex: t,
18
- flattenedSnapPoints: i,
18
+ flattenedSnapPoints: s,
19
19
  minSnapPoint: y,
20
20
  maxSnapPoint: r,
21
21
  closestSnapPointIndex: h
22
22
  };
23
23
  }
24
- function Re(n, a, o) {
25
- let t = (i) => n(i, ...a);
24
+ function Ae(n, a, o) {
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 Fe(n, a, o) {
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 Re(n, a, o);
31
+ if (t === 1) return Ae(n, a, o);
32
32
  throw new Error("Wrong number of arguments");
33
33
  }
34
- function $e(n, { triggerAt: a = "end", minQuietPeriodMs: o, maxBurstDurationMs: t, minGapMs: i, reducer: y = Ae }) {
34
+ function ze(n, { triggerAt: a = "end", minQuietPeriodMs: o, maxBurstDurationMs: t, minGapMs: s, reducer: y = Le }) {
35
35
  let r, h, p, g, x = () => {
36
- let s = p;
37
- s !== void 0 && (p = void 0, n(s), i !== void 0 && (h = setTimeout(D, i)));
36
+ let i = p;
37
+ i !== void 0 && (p = void 0, n(i), s !== void 0 && (h = setTimeout(D, s)));
38
38
  }, D = () => {
39
39
  clearTimeout(h), h = void 0, r === void 0 && x();
40
40
  }, H = () => {
41
41
  clearTimeout(r), r = void 0, g = void 0, h === void 0 && x();
42
42
  };
43
- return { call: (...s) => {
43
+ return { call: (...i) => {
44
44
  let c = r === void 0 && h === void 0;
45
- if ((a !== "start" || c) && (p = y(p, ...s)), !(r === void 0 && !c)) {
46
- if (o !== void 0 || t !== void 0 || i === void 0) {
45
+ if ((a !== "start" || c) && (p = y(p, ...i)), !(r === void 0 && !c)) {
46
+ if (o !== void 0 || t !== void 0 || s === void 0) {
47
47
  clearTimeout(r);
48
- let w = Date.now();
49
- g ?? (g = w);
50
- let W = t === void 0 ? o ?? 0 : Math.min(o ?? t, t - (w - g));
48
+ let k = Date.now();
49
+ g ?? (g = k);
50
+ let W = t === void 0 ? o ?? 0 : Math.min(o ?? t, t - (k - g));
51
51
  r = setTimeout(H, W);
52
52
  }
53
53
  a !== "end" && c && x();
@@ -60,24 +60,24 @@ function $e(n, { triggerAt: a = "end", minQuietPeriodMs: o, maxBurstDurationMs:
60
60
  return r === void 0 && h === void 0;
61
61
  } };
62
62
  }
63
- var Ae = () => "";
63
+ var Le = () => "";
64
64
  function b(...n) {
65
- return Fe(We, n);
65
+ return We(je, n);
66
66
  }
67
- var We = (n, { min: a, max: o }) => a !== void 0 && n < a ? a : o !== void 0 && n > o ? o : n;
68
- function Le(n, a, o) {
67
+ var je = (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 ze(n, a) {
71
+ function Ne(n, a) {
72
72
  return Math.pow(n, a * 5);
73
73
  }
74
- function me(n, a, o) {
75
- return a === 0 || Math.abs(a) === 1 / 0 ? ze(n, o) : n * a * o / (a + o * n);
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 ne(n, a, o, t = 0.15) {
78
- return t === 0 ? Le(n, a, o) : n < a ? -me(a - n, o - a, t) + a : n > o ? +me(n - o, o - a, t) + o : n;
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 je = { "data-vsbs-container": "" }, qe = /* @__PURE__ */ xe({
80
+ const Qe = { "data-vsbs-container": "" }, Ge = /* @__PURE__ */ Be({
81
81
  __name: "BottomSheet",
82
82
  props: {
83
83
  duration: { default: 250 },
@@ -89,62 +89,68 @@ const je = { "data-vsbs-container": "" }, qe = /* @__PURE__ */ xe({
89
89
  expandOnContentDrag: { type: Boolean, default: !0 },
90
90
  modelValue: { type: Boolean },
91
91
  teleportTo: { default: "body" },
92
- teleportDefer: { type: Boolean, default: !1 }
92
+ teleportDefer: { type: Boolean, default: !1 },
93
+ headerClass: {},
94
+ contentClass: {},
95
+ footerClass: {}
93
96
  },
94
- 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"],
95
98
  setup(n, { expose: a, emit: o }) {
96
- const t = n, i = o, y = Ee(t, "modelValue", i, {
99
+ const t = n, s = o, y = Ve(t, "modelValue", s, {
97
100
  passive: !0
98
101
  });
99
102
  q(y, (e) => {
100
- e && J();
101
- }), Me(() => {
102
- y.value && J();
103
+ e && X();
104
+ }), Ie(() => {
105
+ y.value && X();
103
106
  });
104
- const r = P(), h = P(null), p = P(null), g = P(null), x = P(null), D = P(null), H = P(null), s = P(t.expandOnContentDrag), { height: c } = De(), { height: w } = Q(r), { height: W } = Q(h), { height: oe } = Q(D), { height: le } = Q(p), K = E({
107
+ const r = P(), h = P(null), p = P(null), g = P(null), x = P(null), D = P(null), H = P(null), i = P(t.expandOnContentDrag), { height: c } = Re(), { height: k } = Q(r), { height: W } = Q(h), { height: se } = Q(D), { height: re } = Q(p), K = _({
105
108
  get() {
106
109
  return b(
107
- Math.ceil(oe.value + W.value + le.value),
110
+ Math.ceil(se.value + W.value + re.value),
108
111
  {
109
112
  max: c.value
110
113
  }
111
114
  );
112
115
  },
113
116
  set(e) {
114
- [W.value, oe.value, le.value] = e;
117
+ [W.value, se.value, re.value] = e;
115
118
  }
116
- }), l = P(0), v = P(0), k = pe(0), S = pe(0), { snapPoints: be } = Oe(t), d = E(() => be.value ?? [K.value]), {
119
+ }), l = P(0), v = P(0), C = me(0), S = me(0), { snapPoints: Pe } = Ee(t), d = _(() => Pe.value ?? [K.value]), {
117
120
  flattenedSnapPoints: U,
118
- currentSnapPointIndex: B,
121
+ currentSnapPointIndex: I,
119
122
  closestSnapPointIndex: V,
120
123
  minSnapPoint: O,
121
124
  maxSnapPoint: R
122
- } = Ve(d, l, c);
125
+ } = $e(d, l, c);
123
126
  let M;
124
- const L = ge(document.body), z = ge(document.documentElement), Y = He([r, H], {
127
+ const z = ye(document.body), L = ye(document.documentElement), Y = Fe([r, H], {
125
128
  immediate: !1,
126
129
  fallbackFocus: () => r.value || document.body
127
130
  });
128
- function ue(e) {
129
- s.value = !0, ie(e);
130
- }
131
131
  function ie(e) {
132
- s.value && e.preventDefault();
132
+ i.value = !0, ve(e);
133
+ }
134
+ function ve(e) {
135
+ i.value && e.preventDefault();
133
136
  }
134
- const re = (e) => {
137
+ const de = (e) => {
135
138
  e.key === "Escape" && j();
136
- }, ye = () => {
139
+ }, Ce = () => {
137
140
  t.canBackdropClose && j();
138
- }, J = async () => {
139
- y.value = !0, t.blocking && (L.value = !0, z.value = !0), await N();
141
+ };
142
+ let J = !1;
143
+ const X = async () => {
144
+ if (J) return;
145
+ y.value = !0, J = !0, s("opening-started"), t.blocking && (z.value = !0, L.value = !0), await N();
140
146
  const e = r.value.$el;
141
- w.value = e.getBoundingClientRect().height;
142
- const u = e.querySelector("[data-vsbs-content]"), f = e.querySelector("[data-vsbs-header]"), C = e.querySelector("[data-vsbs-footer]");
147
+ k.value = e.getBoundingClientRect().height;
148
+ const u = e.querySelector("[data-vsbs-content]"), f = e.querySelector("[data-vsbs-header]"), w = e.querySelector("[data-vsbs-footer]");
143
149
  if (K.value = [
144
150
  f.getBoundingClientRect().height,
145
151
  u.getBoundingClientRect().height,
146
- C.getBoundingClientRect().height
147
- ], await N(), B.value = U.value.findIndex(
152
+ w.getBoundingClientRect().height
153
+ ], await N(), I.value = U.value.findIndex(
148
154
  (T) => T === O.value
149
155
  ), t.initialSnapPoint) {
150
156
  const T = t.initialSnapPoint;
@@ -160,142 +166,144 @@ const je = { "data-vsbs-container": "" }, qe = /* @__PURE__ */ xe({
160
166
  l.value = b(O.value, {
161
167
  max: c.value
162
168
  });
163
- v.value = l.value, k.set(l.value), S.set(l.value), M = _(k, l.value, {
169
+ v.value = l.value, C.set(l.value), S.set(l.value), M = B(C, l.value, {
164
170
  duration: t.duration / 1e3,
165
171
  ease: "easeInOut"
166
- }), M = _(S, 0, {
172
+ }), M = B(S, 0, {
167
173
  duration: t.duration / 1e3,
168
174
  ease: "easeInOut"
169
- }), window.addEventListener("keydown", re), t.blocking && setTimeout(() => {
170
- k.get() < 1 && (i("opened"), Y.activate());
175
+ }), window.addEventListener("keydown", de), J = !1, t.blocking && setTimeout(() => {
176
+ C.get() < 1 && (s("opened"), Y.activate());
171
177
  }, t.duration);
172
- }, j = () => {
173
- y.value = !1, t.blocking && (L.value = !1, z.value = !1), window.removeEventListener("keydown", re), t.blocking && Y.deactivate(), setTimeout(() => {
174
- i("closed");
175
- }, t.duration);
176
- }, se = (e) => {
178
+ };
179
+ let Z = !1;
180
+ const j = () => {
181
+ Z || (y.value = !1, Z = !0, s("closing-started"), t.blocking && (z.value = !1, L.value = !1), window.removeEventListener("keydown", de), t.blocking && Y.deactivate(), setTimeout(() => {
182
+ s("closed"), Z = !1;
183
+ }, t.duration));
184
+ }, ce = (e) => {
177
185
  if (!d.value) return;
178
186
  if (e < 0 || e >= d.value.length) {
179
187
  console.warn("Index out of bounds");
180
188
  return;
181
189
  }
182
- B.value = e;
190
+ I.value = e;
183
191
  let u;
184
192
  typeof d.value[e] == "number" ? u = b(d.value[e], {
185
193
  max: c.value
186
- }) : u = G(d.value[e], c.value), l.value = u, M = _(k, l.value, {
194
+ }) : u = G(d.value[e], c.value), l.value = u, M = B(C, l.value, {
187
195
  duration: t.duration / 1e3,
188
196
  ease: "easeInOut",
189
- onComplete: () => i("snapped", d.value.indexOf(d.value[e]))
197
+ onComplete: () => s("snapped", d.value.indexOf(d.value[e]))
190
198
  });
191
199
  };
192
- function ve(e) {
193
- e > 0 ? i("dragging-down") : e < 0 && i("dragging-up");
200
+ function fe(e) {
201
+ e > 0 ? s("dragging-down") : e < 0 && s("dragging-up");
194
202
  }
195
- const de = () => {
196
- l.value = w.value, v.value = S.get(), k.jump(l.value), S.jump(v.value);
197
- }, ce = async (e, u) => {
203
+ const pe = () => {
204
+ l.value = k.value, v.value = S.get(), C.jump(l.value), S.jump(v.value);
205
+ }, he = async (e, u) => {
198
206
  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(
199
- t.canSwipeClose ? b(v.value, { min: 0 }) : b(ne(v.value, -w.value, 0, 0.5), {
207
+ t.canSwipeClose ? b(v.value, { min: 0 }) : b(ue(v.value, -k.value, 0, 0.5), {
200
208
  min: 0
201
209
  })
202
- )), k.set(
203
- b(ne(l.value, 0, R.value, 0.25), {
210
+ )), C.set(
211
+ b(ue(l.value, 0, R.value, 0.25), {
204
212
  min: 0,
205
213
  max: c.value
206
214
  })
207
- ), ve(u.delta.y));
208
- }, X = () => {
215
+ ), fe(u.delta.y));
216
+ }, ee = () => {
209
217
  v.value = t.canSwipeClose ? [0, l.value].reduce(
210
218
  (u, f) => Math.abs(f - v.value) < Math.abs(u - v.value) ? f : u
211
- ) : 0, M = _(S, v.value, {
219
+ ) : 0, M = B(S, v.value, {
212
220
  duration: t.duration / 1e3,
213
221
  ease: "easeInOut"
214
- }), v.value === l.value && (v.value = 0, j()), B.value = V.value;
222
+ }), v.value === l.value && (v.value = 0, j()), I.value = V.value;
215
223
  let e;
216
224
  typeof d.value[V.value] == "number" ? e = b(d.value[V.value], {
217
225
  max: c.value
218
226
  }) : e = G(
219
227
  d.value[V.value],
220
228
  c.value
221
- ), l.value = e, M = _(k, l.value, {
229
+ ), l.value = e, M = B(C, l.value, {
222
230
  duration: t.duration / 1e3,
223
231
  ease: "easeInOut",
224
- onComplete: () => i(
232
+ onComplete: () => s(
225
233
  "snapped",
226
234
  d.value.indexOf(d.value[V.value])
227
235
  )
228
- }), M = _(S, 0, {
236
+ }), M = B(S, 0, {
229
237
  duration: t.duration / 1e3,
230
238
  ease: "easeInOut"
231
239
  });
232
- }, Se = (e, u) => {
233
- if (l.value = w.value, v.value = S.get(), M.stop(), !g.value) return;
234
- const f = g.value.scrollTop === 0, C = u.delta.y > 0, T = U.value.length === 1, F = 0.5 > Math.abs(l.value - R.value);
240
+ }, ke = (e, u) => {
241
+ if (l.value = k.value, v.value = S.get(), M.stop(), !g.value) return;
242
+ const f = g.value.scrollTop === 0, w = u.delta.y > 0, T = U.value.length === 1, F = 0.5 > Math.abs(l.value - R.value);
235
243
  if (T) {
236
244
  if (!t.expandOnContentDrag) {
237
- s.value = !1;
245
+ i.value = !1;
238
246
  return;
239
247
  }
240
- S.get() === 0 && f && C && (s.value = !0), S.get() === 0 && f && !C && (s.value = !1);
248
+ S.get() === 0 && f && w && (i.value = !0), S.get() === 0 && f && !w && (i.value = !1);
241
249
  } else {
242
250
  if (!t.expandOnContentDrag) {
243
- s.value = !1;
251
+ i.value = !1;
244
252
  return;
245
253
  }
246
- s.value = !0, F && (C && f && (s.value = !0), !C && f && (s.value = !1), f || (s.value = !1));
254
+ i.value = !0, F && (w && f && (i.value = !0), !w && f && (i.value = !1), f || (i.value = !1));
247
255
  }
248
- }, Pe = async (e, u) => {
256
+ }, we = async (e, u) => {
249
257
  if (await N(), !t.expandOnContentDrag) {
250
- s.value = !1;
258
+ i.value = !1;
251
259
  return;
252
260
  }
253
261
  if (!r.value) return;
254
- v.value === 0 && s.value && t.expandOnContentDrag && (l.value -= u.delta.y), l.value <= O.value && (l.value = O.value, s.value && t.expandOnContentDrag && (v.value += u.delta.y), v.value = b(v.value, { min: 0, max: O.value }), S.set(
255
- t.canSwipeClose ? b(v.value, { min: 0 }) : b(ne(v.value, -w.value, 0, 0.5), {
262
+ 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(
263
+ t.canSwipeClose ? b(v.value, { min: 0 }) : b(ue(v.value, -k.value, 0, 0.5), {
256
264
  min: 0
257
265
  })
258
- )), l.value > R.value && (l.value = R.value), l.value = b(l.value, { max: c.value }), U.value.length === 1 || l.value === R.value && (s.value = !1), k.set(l.value), ve(u.delta.y);
259
- }, ke = () => {
260
- t.blocking || (L.value = !0, z.value = !0);
261
- }, we = () => {
262
- t.blocking || (L.value = !1, z.value = !1);
263
- }, Ce = () => {
266
+ )), l.value > R.value && (l.value = R.value), l.value = b(l.value, { max: c.value }), U.value.length === 1 || l.value === R.value && (i.value = !1), C.set(l.value), fe(u.delta.y);
267
+ }, Te = () => {
268
+ t.blocking || (z.value = !0, L.value = !0);
269
+ }, xe = () => {
270
+ t.blocking || (z.value = !1, L.value = !1);
271
+ }, Me = () => {
264
272
  if (!g.value) return;
265
273
  const e = g.value.scrollTop === 0;
266
- s.value = e;
267
- }, Te = $e((e) => se(e), {
274
+ i.value = e;
275
+ }, Oe = ze((e) => ce(e), {
268
276
  minQuietPeriodMs: t.duration,
269
277
  reducer: (e, u) => u
270
278
  });
271
279
  return q(d, (e, u) => {
272
280
  if (y.value === !1 || !e || !u) return;
273
- const f = e[B.value], C = u[B.value];
274
- typeof f != "string" && typeof C != "string" && (l.value = b(f, {
281
+ const f = e[I.value], w = u[I.value];
282
+ typeof f != "string" && typeof w != "string" && (l.value = b(f, {
275
283
  max: c.value
276
- }), f !== C && (M = _(k, l.value, {
284
+ }), f !== w && (M = B(C, l.value, {
277
285
  duration: t.duration / 1e3,
278
286
  ease: "easeInOut"
279
287
  })));
280
288
  }), q(c, () => {
281
- Te.call(B.value);
289
+ Oe.call(I.value);
282
290
  }), q(K, (e) => {
283
- i("instinctHeight", e);
291
+ s("instinctHeight", e);
284
292
  }), _e(() => {
285
293
  Y.deactivate();
286
- }), a({ open: J, close: j, snapToPoint: se }), (e, u) => (ee(), Z(Be, {
294
+ }), a({ open: X, close: j, snapToPoint: ce }), (e, u) => (ae(), te(De, {
287
295
  to: e.teleportTo,
288
296
  defer: e.teleportDefer
289
297
  }, [
290
- te("div", je, [
291
- $(m(he), null, {
292
- default: I(() => [
293
- m(y) && e.blocking ? (ee(), Z(m(A), {
298
+ ne("div", Qe, [
299
+ $(m(be), null, {
300
+ default: E(() => [
301
+ m(y) && e.blocking ? (ae(), te(m(A), {
294
302
  key: 0,
295
303
  ref_key: "backdrop",
296
304
  ref: H,
297
305
  "data-vsbs-backdrop": "",
298
- onClick: u[0] || (u[0] = (f) => ye()),
306
+ onClick: u[0] || (u[0] = (f) => Ce()),
299
307
  transition: {
300
308
  ease: "easeInOut",
301
309
  duration: e.duration / 1e3
@@ -303,65 +311,67 @@ const je = { "data-vsbs-container": "" }, qe = /* @__PURE__ */ xe({
303
311
  initial: { opacity: 0 },
304
312
  animate: { opacity: 1 },
305
313
  exit: { opacity: 0 }
306
- }, null, 8, ["transition"])) : fe("", !0)
314
+ }, null, 8, ["transition"])) : ge("", !0)
307
315
  ]),
308
316
  _: 1
309
317
  }),
310
- $(m(he), null, {
311
- default: I(() => [
312
- m(y) ? (ee(), Z(m(A), {
318
+ $(m(be), null, {
319
+ default: E(() => [
320
+ m(y) ? (ae(), te(m(A), {
313
321
  key: 0,
314
322
  ref_key: "sheet",
315
323
  ref: r,
316
- exit: { y: "100%", height: m(w) },
324
+ exit: { y: "100%", height: m(k) },
317
325
  initial: { y: "100%" },
318
- style: Ie({ y: m(S), height: m(k) }),
326
+ style: He({ y: m(S), height: m(C) }),
319
327
  "data-vsbs-shadow": !e.blocking,
320
328
  "data-vsbs-sheet-show": m(y),
321
329
  "aria-modal": "true",
322
330
  "data-vsbs-sheet": "",
323
331
  tabindex: "-1",
324
- onTouchstart: ke,
325
- onTouchend: we
332
+ onTouchstart: Te,
333
+ onTouchend: xe
326
334
  }, {
327
- default: I(() => [
335
+ default: E(() => [
328
336
  $(m(A), {
329
337
  ref_key: "sheetHeader",
330
338
  ref: h,
331
339
  "data-vsbs-header": "",
332
- onPanStart: de,
333
- onPan: ce,
334
- onPanEnd: X,
335
- onTouchmove: ue
340
+ onPanStart: pe,
341
+ onPan: he,
342
+ onPanEnd: ee,
343
+ onTouchmove: ie,
344
+ class: oe(e.headerClass)
336
345
  }, {
337
- default: I(() => [
338
- ae(e.$slots, "header", {}, void 0, !0)
346
+ default: E(() => [
347
+ le(e.$slots, "header", {}, void 0, !0)
339
348
  ]),
340
349
  _: 3
341
- }, 512),
342
- te("div", {
350
+ }, 8, ["class"]),
351
+ ne("div", {
343
352
  ref_key: "sheetScroll",
344
353
  ref: g,
345
354
  "data-vsbs-scroll": "",
346
- onScrollend: Ce
355
+ onScrollend: Me
347
356
  }, [
348
357
  $(m(A), {
349
358
  ref_key: "sheetContentWrapper",
350
359
  ref: x,
351
360
  "data-vsbs-content-wrapper": "",
352
- onPanStart: Se,
353
- onPan: Pe,
354
- onPanEnd: X,
355
- onTouchmove: ie
361
+ onPanStart: ke,
362
+ onPan: we,
363
+ onPanEnd: ee,
364
+ onTouchmove: ve
356
365
  }, {
357
- default: I(() => [
358
- te("div", {
366
+ default: E(() => [
367
+ ne("div", {
359
368
  ref_key: "sheetContent",
360
369
  ref: D,
361
- "data-vsbs-content": ""
370
+ "data-vsbs-content": "",
371
+ class: oe(e.contentClass)
362
372
  }, [
363
- ae(e.$slots, "default", {}, void 0, !0)
364
- ], 512)
373
+ le(e.$slots, "default", {}, void 0, !0)
374
+ ], 2)
365
375
  ]),
366
376
  _: 3
367
377
  }, 512)
@@ -370,31 +380,32 @@ const je = { "data-vsbs-container": "" }, qe = /* @__PURE__ */ xe({
370
380
  ref_key: "sheetFooter",
371
381
  ref: p,
372
382
  "data-vsbs-footer": "",
373
- onPanStart: de,
374
- onPan: ce,
375
- onPanEnd: X,
376
- onTouchmove: ue
383
+ onPanStart: pe,
384
+ onPan: he,
385
+ onPanEnd: ee,
386
+ onTouchmove: ie,
387
+ class: oe(e.footerClass)
377
388
  }, {
378
- default: I(() => [
379
- ae(e.$slots, "footer", {}, void 0, !0)
389
+ default: E(() => [
390
+ le(e.$slots, "footer", {}, void 0, !0)
380
391
  ]),
381
392
  _: 3
382
- }, 512)
393
+ }, 8, ["class"])
383
394
  ]),
384
395
  _: 3
385
- }, 8, ["exit", "style", "data-vsbs-shadow", "data-vsbs-sheet-show"])) : fe("", !0)
396
+ }, 8, ["exit", "style", "data-vsbs-shadow", "data-vsbs-sheet-show"])) : ge("", !0)
386
397
  ]),
387
398
  _: 3
388
399
  })
389
400
  ])
390
401
  ], 8, ["to", "defer"]));
391
402
  }
392
- }), Ne = (n, a) => {
403
+ }), Ke = (n, a) => {
393
404
  const o = n.__vccOpts || n;
394
- for (const [t, i] of a)
395
- o[t] = i;
405
+ for (const [t, s] of a)
406
+ o[t] = s;
396
407
  return o;
397
- }, Ye = /* @__PURE__ */ Ne(qe, [["__scopeId", "data-v-3f13e251"]]);
408
+ }, Ze = /* @__PURE__ */ Ke(Ge, [["__scopeId", "data-v-ff3b8e9e"]]);
398
409
  export {
399
- Ye as default
410
+ Ze as default
400
411
  };
package/dist/style.css CHANGED
@@ -1 +1 @@
1
- [data-vsbs-container][data-v-3f13e251]{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-3f13e251]{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-3f13e251]: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-3f13e251]{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-3f13e251]{visibility:visible}[data-vsbs-header][data-v-3f13e251]{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-3f13e251]: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-3f13e251]:empty{box-shadow:none;padding:14px var(--vsbs-padding-x, 16px) 10px}[data-vsbs-footer][data-v-3f13e251]{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-3f13e251]:empty{display:none}[data-vsbs-scroll][data-v-3f13e251]{flex-grow:1;overflow-y:auto;overscroll-behavior:none}[data-vsbs-content-wrapper][data-v-3f13e251]{height:100%}[data-vsbs-content][data-v-3f13e251]{display:grid;padding:8px var(--vsbs-padding-x, 16px);-webkit-user-select:none;user-select:none}
1
+ [data-vsbs-container][data-v-ff3b8e9e]{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-ff3b8e9e]{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-ff3b8e9e]: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-ff3b8e9e]{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-ff3b8e9e]{visibility:visible}[data-vsbs-header][data-v-ff3b8e9e]{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-ff3b8e9e]: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-ff3b8e9e]:empty{box-shadow:none;padding:14px var(--vsbs-padding-x, 16px) 10px}[data-vsbs-footer][data-v-ff3b8e9e]{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-ff3b8e9e]:empty{display:none}[data-vsbs-scroll][data-v-ff3b8e9e]{flex-grow:1;overflow-y:auto;overscroll-behavior:none}[data-vsbs-content-wrapper][data-v-ff3b8e9e]{height:100%}[data-vsbs-content][data-v-ff3b8e9e]{display:grid;padding:8px var(--vsbs-padding-x, 16px);-webkit-user-select:none;user-select:none}
package/dist/types.d.ts CHANGED
@@ -10,4 +10,7 @@ export interface BottomSheetProps {
10
10
  modelValue?: boolean;
11
11
  teleportTo?: string | RendererElement;
12
12
  teleportDefer?: boolean;
13
+ headerClass?: string;
14
+ contentClass?: string;
15
+ footerClass?: string;
13
16
  }
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.2.2",
35
+ "version": "2.4.0",
36
36
  "type": "module",
37
37
  "exports": {
38
38
  ".": {
@@ -59,27 +59,27 @@
59
59
  "vue": ">=3.3"
60
60
  },
61
61
  "dependencies": {
62
- "@vueuse/core": "^13.0.0",
63
- "@vueuse/integrations": "^13.0.0",
62
+ "@vueuse/core": "^13.2.0",
63
+ "@vueuse/integrations": "^13.2.0",
64
64
  "focus-trap": "^7.6.4",
65
- "motion-v": "^1.0.0-beta.1",
66
- "remeda": "^2.21.2",
67
- "vue": "^3.5.13"
65
+ "motion-v": "^1.0.2",
66
+ "remeda": "^2.21.6",
67
+ "vue": "^3.5.14"
68
68
  },
69
69
  "devDependencies": {
70
- "@types/node": "^22.13.11",
71
- "@vitejs/plugin-vue": "^5.2.1",
70
+ "@types/node": "^22.15.18",
71
+ "@vitejs/plugin-vue": "^5.2.4",
72
72
  "@vue/eslint-config-prettier": "^10.2.0",
73
73
  "@vue/eslint-config-typescript": "^14.5.0",
74
74
  "@vue/tsconfig": "^0.7.0",
75
75
  "ajv": "^8.17.1",
76
- "eslint": "^9.23.0",
77
- "eslint-plugin-vue": "^10.0.0",
76
+ "eslint": "^9.27.0",
77
+ "eslint-plugin-vue": "^10.1.0",
78
78
  "prettier": "^3.5.3",
79
79
  "typescript": "~5.6.3",
80
- "vite": "^6.2.2",
80
+ "vite": "^6.3.5",
81
81
  "vite-plugin-dts": "4.5.3",
82
- "vue-tsc": "^2.2.8"
82
+ "vue-tsc": "^2.2.10"
83
83
  },
84
84
  "files": [
85
85
  "dist",