@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 CHANGED
@@ -1,12 +1,12 @@
1
- import { ref as g, computed as I, defineComponent as Re, useCssVars as Le, watch as U, onMounted as _e, toRefs as Ae, nextTick as ge, onUnmounted as Ve, createElementBlock as ae, openBlock as V, Fragment as We, createBlock as we, Teleport as Se, createVNode as Ce, Transition as be, withCtx as ye, createCommentVNode as Pe, unref as le, normalizeStyle as ze, createElementVNode as W, normalizeClass as oe, renderSlot as ue } from "vue";
2
- import { useVModel as Ne, useWindowSize as qe, useElementBounding as J, useScrollLock as Te } from "@vueuse/core";
3
- import { useFocusTrap as Qe } from "@vueuse/integrations/useFocusTrap";
4
- function z(o, l) {
5
- const r = parseFloat(o);
6
- return l * r / 100;
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 je(o, l, r) {
9
- const t = g(0), v = I(() => o.value.map((b) => typeof b == "string" ? z(b, r.value) : b)), C = I(() => Math.min(...v.value)), i = I(() => Math.max(...v.value)), y = I(() => {
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 Ge(o = {}) {
24
- const { velocityThreshold: l = 0.5 } = o, r = g(0), t = g(0), v = g(0), C = g(0), i = g([]);
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
- r.value = w, t.value = S, v.value = w, C.value = S, i.value = [{ y: w, time: S }];
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 Ke(o, l, r) {
53
+ function Ue(o, l, s) {
54
54
  let t = (v) => o(v, ...l);
55
- return r === void 0 ? t : Object.assign(t, { lazy: r, lazyArgs: l });
55
+ return s === void 0 ? t : Object.assign(t, { lazy: s, lazyArgs: l });
56
56
  }
57
- function Ue(o, l, r) {
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 Ke(o, l, r);
60
+ if (t === 1) return Ue(o, l, s);
61
61
  throw new Error("Wrong number of arguments");
62
62
  }
63
- function Je(o, { triggerAt: l = "end", minQuietPeriodMs: r, maxBurstDurationMs: t, minGapMs: v, reducer: C = Xe }) {
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 (r !== void 0 || t !== void 0 || v === void 0) {
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 ? r ?? 0 : Math.min(r ?? t, t - (D - P));
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 Xe = () => "";
92
+ var Ze = () => "";
93
93
  function T(...o) {
94
- return Ue(Ze, o);
94
+ return Je(et, o);
95
95
  }
96
- var Ze = (o, { min: l, max: r }) => l !== void 0 && o < l ? l : r !== void 0 && o > r ? r : o;
97
- function et(o, l, r) {
98
- return Math.max(l, Math.min(o, r));
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 tt(o, l) {
100
+ function nt(o, l) {
101
101
  return Math.pow(o, l * 5);
102
102
  }
103
- function ke(o, l, r) {
104
- return l === 0 || Math.abs(l) === 1 / 0 ? tt(o, r) : o * l * r / (l + r * o);
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 se(o, l, r, t = 0.15) {
107
- return t === 0 ? et(o, l, r) : o < l ? -ke(l - o, r - l, t) + l : o > r ? +ke(o - r, r - l, t) + r : o;
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 nt = ["data-vsbs-shadow", "data-vsbs-sheet-show"], at = /* @__PURE__ */ Re({
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: r }) {
129
- Le((e) => ({
130
- "55bcd70e": xe.value
128
+ setup(o, { expose: l, emit: s }) {
129
+ _e((e) => ({
130
+ "03a2828a": Ye.value
131
131
  }));
132
- const t = o, v = r, C = Ne(t, "modelValue", v, {
132
+ const t = o, v = s, C = qe(t, "modelValue", v, {
133
133
  passive: !0
134
134
  });
135
- U(C, (e) => {
136
- e && te();
137
- }), _e(() => {
138
- C.value && te();
135
+ J(C, (e) => {
136
+ e && ne();
137
+ }), Ae(() => {
138
+ C.value && ne();
139
139
  });
140
- const i = g(null), y = g(null), b = g(null), P = g(null), w = g(null), S = g(null), M = g(null), d = g(t.expandOnContentDrag), { height: h } = qe(), { height: D } = J(i), { height: $ } = J(y), { height: L } = J(S), { height: re } = J(b), X = 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 + re.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, re.value] = e;
150
+ [$.value, L.value, ie.value] = e;
151
151
  }
152
- }), a = g(0), u = g(0), xe = I(() => t.duration + "ms"), { snapPoints: Ye } = Ae(t), f = I(() => Ye.value ?? [X.value]), {
153
- flattenedSnapPoints: k,
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
- } = je(f, a, h), N = Te(document.body), q = Te(document.documentElement), E = g(!1), A = g(0), Q = g(0), j = g(0), H = g(0), G = g(!0), R = Ge({ velocityThreshold: 0.5 }), Z = Qe([i, M], {
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 ce = (e) => {
169
- e.key === "Escape" && x();
170
- }, Me = () => {
171
- t.canBackdropClose && x();
168
+ const de = (e) => {
169
+ e.key === "Escape" && Y();
170
+ }, De = () => {
171
+ t.canBackdropClose && Y();
172
172
  };
173
- let ee = !1;
174
- const te = async () => {
175
- if (ee) return;
176
- C.value = !0, ee = !0, v("opening-started"), t.blocking && (N.value = !0, q.value = !0), await ge();
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]"), s = e.querySelector("[data-vsbs-header]"), p = e.querySelector("[data-vsbs-footer]");
180
- if (X.value = [
181
- s.getBoundingClientRect().height,
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
- p.getBoundingClientRect().height
184
- ], await ge(), B.value = k.value.findIndex(
185
- (c) => c === O.value
183
+ c.getBoundingClientRect().height
184
+ ], await we(), B.value = x.value.findIndex(
185
+ (f) => f === O.value
186
186
  ), t.initialSnapPoint) {
187
- const c = t.initialSnapPoint;
188
- if (c < 0 || c >= f.value.length) {
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 m;
193
- typeof f.value[c] == "number" ? m = T(f.value[c], {
192
+ let g;
193
+ typeof p.value[f] == "number" ? g = T(p.value[f], {
194
194
  max: h.value
195
- }) : m = z(f.value[c], h.value), a.value = m;
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"), Z.activate());
202
+ C.value && (v("opened"), ee.activate());
203
203
  }, t.duration);
204
- }), window.addEventListener("keydown", ce), ee = !1;
204
+ }), window.addEventListener("keydown", de), te = !1;
205
205
  };
206
- let ne = !1;
207
- const x = () => {
208
- ne || (C.value = !1, ne = !0, v("closing-started"), t.blocking && (N.value = !1, q.value = !1), window.removeEventListener("keydown", ce), t.blocking && Z.deactivate(), u.value = a.value, setTimeout(() => {
209
- v("closed"), ne = !1;
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
- }, de = (e) => {
212
- if (!f.value) return;
213
- if (e < 0 || e >= f.value.length) {
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 f.value[e] == "number" ? n = T(f.value[e], {
219
+ typeof p.value[e] == "number" ? n = T(p.value[e], {
220
220
  max: h.value
221
- }) : n = z(f.value[e], h.value), a.value = n, v("snapped", f.value.indexOf(f.value[e]));
221
+ }) : n = N(p.value[e], h.value), a.value = n, v("snapped", p.value.indexOf(p.value[e]));
222
222
  };
223
- function fe(e) {
223
+ function pe(e) {
224
224
  e > 0 ? v("dragging-down") : e < 0 && v("dragging-up");
225
225
  }
226
- const pe = (e) => {
226
+ const he = (e) => {
227
227
  if (!i.value) return;
228
- const n = window.getComputedStyle(i.value), s = parseFloat(n.height);
229
- let p = 0;
230
- 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, R.start(e.clientY), e.target.setPointerCapture(e.pointerId);
231
- }, he = (e) => {
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, s = e.clientY;
234
- u.value <= 0 && (a.value = Q.value - n), a.value <= O.value && (a.value = O.value, u.value = j.value + n, t.canSwipeClose ? u.value = T(u.value, { min: 0 }) : u.value = T(
235
- se(u.value, -D.value, 0, 0.5),
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(se(a.value, 0, _.value, 0.25), {
237
+ )), a.value = T(re(a.value, 0, _.value, 0.25), {
238
238
  min: 0,
239
239
  max: h.value
240
- }), fe(e.clientY - H.value), R.update(e.clientY), H.value = s;
241
- }, K = (e) => {
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 c = a.value / 2;
244
- if (t.swipeCloseThreshold && typeof t.swipeCloseThreshold == "number" && (c = t.swipeCloseThreshold), t.swipeCloseThreshold && typeof t.swipeCloseThreshold == "string" && t.swipeCloseThreshold.includes("%") && (c = a.value * (Number(t.swipeCloseThreshold.replace("%", "")) / 100)), u.value > c) {
245
- u.value = a.value, x();
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, x();
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, x();
256
+ u.value = a.value, Y();
257
257
  return;
258
258
  }
259
- let s;
260
- if (n.isSwipe && k.value.length > 1) {
261
- const c = [...k.value].sort((m, Y) => m - Y);
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 m = c.find((Y) => Y > a.value + 1);
264
- s = m !== void 0 ? k.value.indexOf(m) : F.value;
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 m = [...c].reverse().find((Y) => Y < a.value - 1);
267
- s = m !== void 0 ? k.value.indexOf(m) : F.value;
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
- s = F.value;
271
- B.value = s;
272
- let p;
273
- if (typeof f.value[s] == "number" ? p = T(f.value[s], {
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
- }) : p = z(
276
- f.value[s],
275
+ }) : c = N(
276
+ p.value[r],
277
277
  h.value
278
- ), p === 0) {
279
- x();
278
+ ), c === 0) {
279
+ Y();
280
280
  return;
281
281
  }
282
- a.value = p, u.value = 0, v("snapped", f.value.indexOf(f.value[s]));
283
- }, De = (e) => {
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, s = e > 0, p = k.value.length === 1, c = 0.5 > Math.abs(a.value - _.value);
286
- if (console.log(e), p) {
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 && s && (d.value = !0), u.value === 0 && n && !s && (d.value = !1);
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, c && (s && n && (d.value = !0), !s && n && (d.value = !1), n || (d.value = !1));
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, s = e.clientY, p = e.clientY - H.value;
311
- if (G.value) {
312
- const m = e.clientY - A.value;
313
- if (Math.abs(m) > 3)
314
- G.value = !1, De(m);
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 = s;
316
+ H.value = r;
317
317
  return;
318
318
  }
319
319
  }
320
- u.value === 0 && d.value && t.expandOnContentDrag && (a.value = Q.value - n), a.value <= O.value && (a.value = O.value, d.value && t.expandOnContentDrag && (u.value = j.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
- se(u.value, -D.value, 0, 0.5),
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 }), k.value.length === 1 || a.value === _.value && (d.value = !1), fe(p), R.update(e.clientY), H.value = s;
324
- }, me = (e) => {
325
- if (E.value = !1, G.value = !0, e.target.releasePointerCapture(e.pointerId), t.canSwipeClose) {
326
- let c = a.value / 2;
327
- if (t.swipeCloseThreshold && typeof t.swipeCloseThreshold == "number" && (c = t.swipeCloseThreshold), t.swipeCloseThreshold && typeof t.swipeCloseThreshold == "string" && t.swipeCloseThreshold.includes("%") && (c = a.value * (Number(t.swipeCloseThreshold.replace("%", "")) / 100)), u.value > c) {
328
- u.value = a.value, x();
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, x();
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, x();
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 s;
343
- if (n.isSwipe && k.value.length > 1) {
344
- const c = [...k.value].sort((m, Y) => m - Y);
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 m = c.find((Y) => Y > a.value + 1);
347
- s = m !== void 0 ? k.value.indexOf(m) : F.value;
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 m = [...c].reverse().find((Y) => Y < a.value - 1);
350
- s = m !== void 0 ? k.value.indexOf(m) : F.value;
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
- s = F.value;
354
- B.value = s;
355
- let p;
356
- if (typeof f.value[s] == "number" ? p = T(f.value[s], {
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
- }) : p = z(
359
- f.value[s],
358
+ }) : f = N(
359
+ p.value[c],
360
360
  h.value
361
- ), p === 0) {
362
- x();
361
+ ), f === 0) {
362
+ Y();
363
363
  return;
364
364
  }
365
- a.value = p, u.value = 0, v("snapped", f.value.indexOf(f.value[s]));
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 || (N.value = !1, q.value = !1);
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
- }, $e = Je((e) => de(e), {
374
+ }, Fe = Xe((e) => fe(e), {
375
375
  minQuietPeriodMs: t.duration,
376
376
  reducer: (e, n) => n
377
377
  });
378
- U(f, (e, n) => {
378
+ J(p, (e, n) => {
379
379
  if (C.value === !1 || !e || !n) return;
380
- const s = e[B.value], p = n[B.value];
381
- typeof s != "string" && typeof p != "string" && (a.value = T(s, {
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
- }), U(h, () => {
385
- $e.call(B.value);
386
- }), U(X, (e) => {
384
+ }), J(h, () => {
385
+ Fe.call(B.value);
386
+ }), J(Z, (e) => {
387
387
  v("instinctHeight", e);
388
- }), Ve(() => {
389
- Z.deactivate();
388
+ }), We(() => {
389
+ ee.deactivate();
390
390
  });
391
- const Fe = (e) => {
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: te, close: x, snapToPoint: de }), (e, n) => (V(), ae(We, null, [
396
- (V(), we(Se, {
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
- Ce(be, { name: "vsbs-backdrop" }, {
401
- default: ye(() => [
402
- le(C) && e.blocking ? (V(), ae("div", {
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] = (s) => Me())
408
- }, null, 512)) : Pe("", !0)
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
- (V(), we(Se, {
413
+ (W(), Se(Ce, {
414
414
  to: e.teleportTo,
415
415
  defer: e.teleportDefer
416
416
  }, [
417
- Ce(be, {
417
+ be(ye, {
418
418
  name: "vsbs-sheet",
419
- onLeave: Fe
419
+ onLeave: Re
420
420
  }, {
421
- default: ye(() => [
422
- le(C) ? (V(), ae("div", {
421
+ default: Pe(() => [
422
+ oe(C) ? (W(), le("div", {
423
423
  key: 0,
424
424
  ref_key: "sheet",
425
425
  ref: i,
426
- style: ze({
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": le(C),
432
+ "data-vsbs-sheet-show": oe(C),
433
433
  "aria-modal": "true",
434
434
  "data-vsbs-sheet": "",
435
435
  tabindex: "-1",
436
- onTouchstart: Ee,
437
- onTouchend: He
436
+ onTouchstart: He,
437
+ onTouchend: Ie
438
438
  }, [
439
- W("div", {
439
+ z("div", {
440
440
  ref_key: "sheetHeader",
441
441
  ref: y,
442
442
  "data-vsbs-header": "",
443
- onPointerdown: pe,
444
- onPointermove: he,
445
- onPointerup: K,
446
- onPointercancel: K,
447
- onTouchmove: ie,
448
- class: oe(e.headerClass),
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
- ue(e.$slots, "header", {}, void 0, !0)
451
+ se(e.$slots, "header", {}, void 0, !0)
452
452
  ], 34),
453
- W("div", {
453
+ z("div", {
454
454
  ref_key: "sheetScroll",
455
455
  ref: P,
456
456
  "data-vsbs-scroll": "",
457
- onScrollend: Ie
457
+ onScrollend: $e
458
458
  }, [
459
- W("div", {
459
+ z("div", {
460
460
  ref_key: "sheetContentWrapper",
461
461
  ref: w,
462
462
  "data-vsbs-content-wrapper": "",
463
- onPointerdown: Oe,
464
- onPointermove: Be,
465
- onPointerup: me,
466
- onPointercancel: me,
467
- onTouchmove: ve,
463
+ onPointerdown: Be,
464
+ onPointermove: Ee,
465
+ onPointerup: ge,
466
+ onPointercancel: ge,
467
+ onTouchmove: ce,
468
468
  style: { touchAction: "pan-y" }
469
469
  }, [
470
- W("div", {
470
+ z("div", {
471
471
  ref_key: "sheetContent",
472
472
  ref: S,
473
473
  "data-vsbs-content": "",
474
- class: oe(e.contentClass)
474
+ class: ue(e.contentClass)
475
475
  }, [
476
- ue(e.$slots, "default", {}, void 0, !0)
476
+ se(e.$slots, "default", {}, void 0, !0)
477
477
  ], 2)
478
478
  ], 544)
479
479
  ], 544),
480
- W("div", {
480
+ z("div", {
481
481
  ref_key: "sheetFooter",
482
482
  ref: b,
483
483
  "data-vsbs-footer": "",
484
- onPointerdown: pe,
485
- onPointermove: he,
486
- onPointerup: K,
487
- onPointercancel: K,
488
- onTouchmove: ie,
489
- class: oe(e.footerClass),
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
- ue(e.$slots, "footer", {}, void 0, !0)
492
+ se(e.$slots, "footer", {}, void 0, !0)
493
493
  ], 34)
494
- ], 44, nt)) : Pe("", !0)
494
+ ], 44, at)) : Te("", !0)
495
495
  ]),
496
496
  _: 3
497
497
  })
498
498
  ], 8, ["to", "defer"]))
499
499
  ], 64));
500
500
  }
501
- }), lt = (o, l) => {
502
- const r = o.__vccOpts || o;
501
+ }), ot = (o, l) => {
502
+ const s = o.__vccOpts || o;
503
503
  for (const [t, v] of l)
504
- r[t] = v;
505
- return r;
506
- }, rt = /* @__PURE__ */ lt(at, [["__scopeId", "data-v-ac41efee"]]);
504
+ s[t] = v;
505
+ return s;
506
+ }, it = /* @__PURE__ */ ot(lt, [["__scopeId", "data-v-606a4041"]]);
507
507
  export {
508
- rt as default
508
+ it as default
509
509
  };
package/dist/style.css CHANGED
@@ -1 +1 @@
1
- [data-vsbs-backdrop][data-v-ac41efee]{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(--55bcd70e)}[data-vsbs-shadow=true][data-v-ac41efee]: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-ac41efee]{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-ac41efee]{visibility:visible}[data-vsbs-header][data-v-ac41efee]{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-ac41efee]: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-ac41efee]:empty{box-shadow:none;padding:14px var(--vsbs-padding-x, 16px) 10px}[data-vsbs-footer][data-v-ac41efee]{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-ac41efee]:empty{display:none}[data-vsbs-scroll][data-v-ac41efee]{flex-grow:1;overflow-y:auto;overscroll-behavior:none}[data-vsbs-content-wrapper][data-v-ac41efee]{height:100%}[data-vsbs-content][data-v-ac41efee]{display:grid;padding:8px var(--vsbs-padding-x, 16px);-webkit-user-select:none;user-select:none}.vsbs-backdrop-enter-active[data-v-ac41efee],.vsbs-backdrop-leave-active[data-v-ac41efee]{transition:opacity var(--vsbs-duration) ease}.vsbs-backdrop-enter-from[data-v-ac41efee],.vsbs-backdrop-leave-to[data-v-ac41efee]{opacity:0}
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}
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.6.0-next.1",
35
+ "version": "3.0.0-next.1",
36
36
  "type": "module",
37
37
  "exports": {
38
38
  ".": {