@douxcode/vue-spring-bottom-sheet 1.0.5 → 1.0.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 CHANGED
@@ -1,10 +1,10 @@
1
- import { computed as S, defineComponent as te, ref as u, toRefs as ae, 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 O } from "vue";
2
- import { useWindowSize as he, useElementBounding as x, useScrollLock as pe } from "@vueuse/core";
3
- import { useGesture as P, rubberbandIfOutOfBounds as E } from "@vueuse/gesture";
1
+ import { computed as C, defineComponent as te, ref as u, toRefs as ae, 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
+ import { useWindowSize as he, useElementBounding as B, useScrollLock as pe } from "@vueuse/core";
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";
5
5
  import { useFocusTrap as be } from "@vueuse/integrations/useFocusTrap";
6
6
  function ye(c, g) {
7
- const i = S(() => c.value.slice().sort((h, v) => h - v)), n = S(() => i.value[0]), l = S(() => i.value[i.value.length - 1]), s = S(() => {
7
+ const i = C(() => c.value.slice().sort((h, v) => h - v)), n = C(() => i.value[0]), o = C(() => i.value[i.value.length - 1]), s = C(() => {
8
8
  const h = i.value.reduce(
9
9
  (v, m) => Math.abs(m - g.value) < Math.abs(v - g.value) ? m : v
10
10
  );
@@ -12,7 +12,7 @@ function ye(c, g) {
12
12
  });
13
13
  return {
14
14
  minSnap: n,
15
- maxSnap: l,
15
+ maxSnap: o,
16
16
  snapPoints: c,
17
17
  closestSnapPoint: s
18
18
  };
@@ -29,107 +29,107 @@ 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, l = i, s = u(null), h = u(null), v = u(null), m = u(null), I = u(null), F = u(null), L = u(null), D = u(!1), r = u(n.expandOnContentDrag), { height: W } = he(), { height: T } = x(s), { height: z } = x(h), { height: G } = x(v), { height: K } = x(F), { activate: Y, deactivate: j } = be([s, L]), p = S(() => Math.ceil(K.value + z.value + G.value)), { motionProperties: b } = fe(s), { push: y, stop: q, motionValues: B } = ge(), { set: k } = me(b, {}, { push: y, motionValues: B, stop: q }), e = u(0), a = u(0), { snapPoints: J } = ae(n), Q = S(() => J.value ?? [p.value]), { minSnap: f, maxSnap: w, snapPoints: C, closestSnapPoint: U } = ye(Q, e), $ = pe(document.body), N = (t) => {
33
- t.key === "Escape" && _();
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), a = u(0), { snapPoints: J } = ae(n), Q = C(() => J.value ?? [p.value]), { minSnap: f, maxSnap: S, snapPoints: D, closestSnapPoint: U } = ye(Q, e), $ = pe(document.body), N = (t) => {
33
+ t.key === "Escape" && x();
34
34
  }, X = () => {
35
- s.value && (e.value = n.defaultBreakpoint ?? f.value, k({
35
+ s.value && (e.value = Math.min(n.defaultBreakpoint ?? f.value, b.value), w({
36
36
  height: e.value,
37
37
  y: e.value
38
- }), y("y", 0, b, { type: "tween", easings: "easeInOut", bounce: 0, duration: 300 }), D.value = !0, $.value = !0, window.addEventListener("keydown", N), n.blocking && setTimeout(() => {
39
- B.value.y.get() - 0 < 0.1 && (l("opened"), Y());
38
+ }), k("y", 0, y, { type: "tween", easings: "easeInOut", bounce: 0, duration: 300 }), T.value = !0, $.value = !0, window.addEventListener("keydown", N), n.blocking && setTimeout(() => {
39
+ H.value.y.get() - 0 < 0.1 && (o("opened"), Y());
40
40
  }, 300));
41
- }, _ = () => {
42
- s.value && (y("y", T.value, b, { type: "tween", bounce: 0, duration: 300 }), D.value = !1, $.value = !1, n.blocking && j(), window.removeEventListener("keydown", N), setTimeout(() => {
43
- B.value.y.get() - T.value < 0.1 && l("closed");
41
+ }, x = () => {
42
+ s.value && (k("y", _.value, y, { type: "tween", bounce: 0, duration: 300 }), T.value = !1, $.value = !1, n.blocking && j(), window.removeEventListener("keydown", N), setTimeout(() => {
43
+ H.value.y.get() - _.value < 0.1 && o("closed");
44
44
  }, 300));
45
45
  }, Z = () => {
46
- n.canBackdropClose && _();
46
+ n.canBackdropClose && x();
47
47
  };
48
48
  function ee(t) {
49
49
  r.value && t.preventDefault();
50
50
  }
51
51
  const V = (t) => {
52
- s.value && (e.value = t, y("height", e.value, b, {
52
+ s.value && (e.value = t, 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: t, direction: o }) => {
59
- s.value && (a.value === 0 && (e.value -= t[1]), e.value <= f.value && (e.value = f.value, a.value += t[1], a.value = Math.max(0, Math.min(a.value, f.value)), k({
60
- y: n.canSwipeClose ? a.value : E(a.value, -T.value, 0, 0.5)
61
- })), k({
62
- height: Math.min(Math.max(E(e.value, 0, w.value, 0.25), 0), W.value)
63
- }), o[1] > 0 ? l("dragging-down") : o[1] < 0 && l("dragging-up"));
64
- }, M = () => {
65
- s.value && (a.value = n.canSwipeClose ? [0, e.value].reduce((t, o) => Math.abs(o - a.value) < Math.abs(t - a.value) ? o : t) : 0, y("y", a.value, b, { type: "tween", easings: "easeInOut", bounce: 0, duration: 300 }), a.value === e.value && (a.value = 0, _()), e.value = C.value[U.value], y("height", e.value, b, { type: "tween", easings: "easeInOut", bounce: 0, duration: 300 }));
58
+ }, A = ({ delta: t, direction: l }) => {
59
+ s.value && (a.value === 0 && (e.value -= t[1]), e.value <= f.value && (e.value = f.value, a.value += t[1], a.value = Math.max(0, Math.min(a.value, f.value)), w({
60
+ y: n.canSwipeClose ? a.value : I(a.value, -_.value, 0, 0.5)
61
+ })), w({
62
+ height: Math.min(Math.max(I(e.value, 0, S.value, 0.25), 0), b.value)
63
+ }), l[1] > 0 ? o("dragging-down") : l[1] < 0 && o("dragging-up"));
64
+ }, O = () => {
65
+ s.value && (a.value = n.canSwipeClose ? [0, e.value].reduce((t, l) => Math.abs(l - a.value) < Math.abs(t - a.value) ? l : t) : 0, k("y", a.value, y, { type: "tween", easings: "easeInOut", bounce: 0, duration: 300 }), a.value === e.value && (a.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
- return P(
67
+ return E(
68
68
  {
69
69
  onDrag: A,
70
- onDragEnd: M
70
+ onDragEnd: O
71
71
  },
72
72
  {
73
73
  domTarget: h,
74
74
  drag: { filterTaps: !0 }
75
75
  }
76
- ), P(
76
+ ), E(
77
77
  {
78
78
  onDrag: A,
79
- onDragEnd: M
79
+ onDragEnd: O
80
80
  },
81
81
  {
82
82
  domTarget: v,
83
83
  drag: { filterTaps: !0 }
84
84
  }
85
- ), P(
85
+ ), E(
86
86
  {
87
87
  onDragStart: ({ direction: t }) => {
88
- const o = m.value.scrollTop === 0, H = t[1] > 0;
89
- C.value.length === 1 ? a.value === 0 && o && (r.value = H) : (n.expandOnContentDrag && e.value !== w.value && (r.value = !0), e.value === w.value && o && (r.value = H));
88
+ const l = m.value.scrollTop === 0, M = t[1] > 0;
89
+ D.value.length === 1 ? a.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: t }) => {
91
+ onDrag: ({ delta: t, direction: l }) => {
92
92
  if (!n.expandOnContentDrag) {
93
93
  r.value = !1;
94
94
  return;
95
95
  }
96
96
  if (!s.value) return;
97
- a.value === 0 && r.value && n.expandOnContentDrag && (e.value -= t[1]), e.value <= f.value && (e.value = f.value, r.value && n.expandOnContentDrag && (a.value += t[1]), a.value = Math.max(0, Math.min(a.value, f.value)), k({
98
- y: n.canSwipeClose ? a.value : E(a.value, -T.value, 0, 0.5)
99
- })), e.value > w.value && (e.value = w.value);
100
- const o = m.value.scrollTop === 0;
101
- C.value.length === 1 ? t[1] < 0 && a.value === 0 && o && (r.value = !1) : e.value === w.value && (r.value = !1), k({
97
+ a.value === 0 && r.value && n.expandOnContentDrag && (e.value -= t[1]), e.value <= f.value && (e.value = f.value, r.value && n.expandOnContentDrag && (a.value += t[1]), a.value = Math.max(0, Math.min(a.value, f.value)), w({
98
+ y: n.canSwipeClose ? a.value : I(a.value, -_.value, 0, 0.5)
99
+ })), e.value > S.value && (e.value = S.value), e.value = Math.min(e.value, b.value);
100
+ const M = m.value.scrollTop === 0;
101
+ D.value.length === 1 ? t[1] < 0 && a.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
  },
105
- onDragEnd: M
105
+ onDragEnd: O
106
106
  },
107
107
  {
108
- domTarget: I,
108
+ domTarget: F,
109
109
  drag: { filterTaps: !0 }
110
110
  }
111
111
  ), ne(p, () => {
112
- l("minHeight", p.value), C.value.length === 1 && R(() => {
113
- C.value[0] === p.value && V(p.value);
112
+ o("minHeight", p.value), D.value.length === 1 && R(() => {
113
+ D.value[0] === p.value && V(Math.min(p.value, b.value));
114
114
  });
115
115
  }), oe(() => {
116
- l("minHeight", p.value), l("maxHeight", W.value), e.value = n.defaultBreakpoint ?? Number(p.value), k({
116
+ o("minHeight", p.value), o("maxHeight", b.value), e.value = n.defaultBreakpoint ?? Number(p.value), w({
117
117
  height: e.value,
118
118
  y: e.value
119
119
  }), R(() => {
120
- l("ready");
120
+ o("ready");
121
121
  });
122
- }), g({ open: X, close: _, snapToPoint: V }), (t, o) => (le(), se(ue, { to: "body" }, [
122
+ }), g({ open: X, close: x, snapToPoint: V }), (t, l) => (le(), se(ue, { to: "body" }, [
123
123
  d("div", ke, [
124
124
  ie(re, { name: "fade" }, {
125
125
  default: ve(() => [
126
126
  de(d("div", {
127
127
  ref_key: "backdrop",
128
- ref: L,
128
+ ref: W,
129
129
  "data-vsbs-backdrop": "",
130
- onClick: o[0] || (o[0] = (H) => Z())
130
+ onClick: l[0] || (l[0] = (M) => Z())
131
131
  }, null, 512), [
132
- [ce, D.value && t.blocking]
132
+ [ce, T.value && t.blocking]
133
133
  ])
134
134
  ]),
135
135
  _: 1
@@ -138,7 +138,7 @@ const ke = { "data-vsbs-container": "" }, we = ["data-vsbs-shadow", "data-vsbs-s
138
138
  ref_key: "sheet",
139
139
  ref: s,
140
140
  "data-vsbs-shadow": !t.blocking,
141
- "data-vsbs-sheet-show": D.value,
141
+ "data-vsbs-sheet-show": T.value,
142
142
  "aria-modal": "true",
143
143
  "data-vsbs-sheet": "",
144
144
  tabindex: "-1"
@@ -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
- O(t.$slots, "header", {}, void 0, !0)
151
+ P(t.$slots, "header", {}, void 0, !0)
152
152
  ], 512),
153
153
  d("div", {
154
154
  ref_key: "sheetScroll",
@@ -158,15 +158,15 @@ const ke = { "data-vsbs-container": "" }, we = ["data-vsbs-shadow", "data-vsbs-s
158
158
  }, [
159
159
  d("div", {
160
160
  ref_key: "sheetContentWrapper",
161
- ref: I,
161
+ ref: F,
162
162
  "data-vsbs-content-wrapper": ""
163
163
  }, [
164
164
  d("div", {
165
165
  ref_key: "sheetContent",
166
- ref: F,
166
+ ref: L,
167
167
  "data-vsbs-content": ""
168
168
  }, [
169
- O(t.$slots, "default", {}, void 0, !0)
169
+ P(t.$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
- O(t.$slots, "footer", {}, void 0, !0)
178
+ P(t.$slots, "footer", {}, void 0, !0)
179
179
  ], 512)
180
180
  ], 8, we)
181
181
  ])
@@ -183,10 +183,10 @@ const ke = { "data-vsbs-container": "" }, we = ["data-vsbs-shadow", "data-vsbs-s
183
183
  }
184
184
  }), Ce = (c, g) => {
185
185
  const i = c.__vccOpts || c;
186
- for (const [n, l] of g)
187
- i[n] = l;
186
+ for (const [n, o] of g)
187
+ i[n] = o;
188
188
  return i;
189
- }, He = /* @__PURE__ */ Ce(Se, [["__scopeId", "data-v-853fc310"]]);
189
+ }, He = /* @__PURE__ */ Ce(Se, [["__scopeId", "data-v-d498ee26"]]);
190
190
  export {
191
191
  He as default
192
192
  };
package/dist/style.css CHANGED
@@ -1 +1 @@
1
- [data-vsbs-backdrop][data-v-853fc310]{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-853fc310]{box-shadow:0 -5px 60px #26597333,0 -1px #2659730f}[data-vsbs-sheet][data-v-853fc310]{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-853fc310]{visibility:visible}[data-vsbs-header][data-v-853fc310]{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-853fc310]: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-853fc310]:empty{box-shadow:none;padding:12px 16px 8px}[data-vsbs-footer][data-v-853fc310]{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-853fc310]:empty{display:none}[data-vsbs-scroll][data-v-853fc310]{flex-grow:1;overflow-y:auto;overscroll-behavior:contain}[data-vsbs-content-wrapper][data-v-853fc310]{height:100%}[data-vsbs-content][data-v-853fc310]{display:grid;padding:1vh 3vh 3vh;-webkit-user-select:none;user-select:none}.fade-enter-active[data-v-853fc310],.fade-leave-active[data-v-853fc310]{transition:opacity .3s ease}.fade-enter-from[data-v-853fc310],.fade-leave-to[data-v-853fc310]{opacity:0}
1
+ [data-vsbs-backdrop][data-v-d498ee26]{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-d498ee26]{box-shadow:0 -5px 60px #26597333,0 -1px #2659730f}[data-vsbs-sheet][data-v-d498ee26]{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-d498ee26]{visibility:visible}[data-vsbs-header][data-v-d498ee26]{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-d498ee26]: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-d498ee26]:empty{box-shadow:none;padding:12px 16px 8px}[data-vsbs-footer][data-v-d498ee26]{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-d498ee26]:empty{display:none}[data-vsbs-scroll][data-v-d498ee26]{flex-grow:1;overflow-y:auto;overscroll-behavior:contain}[data-vsbs-content-wrapper][data-v-d498ee26]{height:100%}[data-vsbs-content][data-v-d498ee26]{display:grid;padding:1vh 3vh 3vh;-webkit-user-select:none;user-select:none}.fade-enter-active[data-v-d498ee26],.fade-leave-active[data-v-d498ee26]{transition:opacity .3s ease}.fade-enter-from[data-v-d498ee26],.fade-leave-to[data-v-d498ee26]{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": "1.0.5",
35
+ "version": "1.0.6",
36
36
  "type": "module",
37
37
  "exports": {
38
38
  ".": {
@@ -49,7 +49,8 @@
49
49
  "scripts": {
50
50
  "build": "vue-tsc -b && vite build",
51
51
  "build:watch": "vite build --watch",
52
- "preview": "vite preview"
52
+ "preview": "vite preview",
53
+ "publish": "npm run build && npm publish --access public"
53
54
  },
54
55
  "peerDependencies": {
55
56
  "vue": ">=3.3",