@douxcode/vue-spring-bottom-sheet 1.0.6 → 1.0.8

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
@@ -62,14 +62,12 @@ const close = () => {
62
62
 
63
63
  ## Usage in Nuxt 3
64
64
 
65
- For Nuxt 3, just wrap component in `<client-only>`
65
+ For Nuxt 3, just wrap component in `<ClientOnly>`
66
66
 
67
67
  ```vue
68
68
  <template>
69
69
  <ClientOnly>
70
- <template>
71
- <BottomSheet ref="bottomSheet"> Your awesome content </BottomSheet>
72
- </template>
70
+ <BottomSheet ref="bottomSheet"> Your awesome content </BottomSheet>
73
71
  </ClientOnly>
74
72
  </template>
75
73
  ```
@@ -77,15 +75,14 @@ For Nuxt 3, just wrap component in `<client-only>`
77
75
  ## CSS Custom Properties
78
76
 
79
77
  ```css
80
- :root {
81
- --rsbs-backdrop-bg: rgba(0, 0, 0, 0.6);
82
- --rsbs-bg: #fff;
83
- --rsbs-handle-bg: hsla(0, 0%, 0%, 0.14);
84
- --rsbs-max-w: auto;
85
- --rsbs-ml: env(safe-area-inset-left);
86
- --rsbs-mr: env(safe-area-inset-right);
87
- --rsbs-overlay-rounded: 16px;
88
- }
78
+ --vsbs-backdrop-bg: rgba(0, 0, 0, 0.5);
79
+ --vsbs-shadow-color: hsla(0, 0%, 35%, 0.2);
80
+ --vsbs-background: #fff;
81
+ --vsbs-border-radius: 16px;
82
+ --vsbs-max-width: 640px;
83
+ --vsbs-border-color: rgba(46, 59, 66, 0.125);
84
+ --vsbs-padding-x: 16px;
85
+ --vsbs-handle-background: rgba(0, 0, 0, 0.28);
89
86
  ```
90
87
 
91
88
  ## Props
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
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";
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__ */ te({
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), 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();
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(t) {
49
- r.value && t.preventDefault();
48
+ function ee(a) {
49
+ r.value && a.preventDefault();
50
50
  }
51
- const V = (t) => {
52
- s.value && (e.value = t, k("height", e.value, y, {
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: 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)
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 && (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 }));
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: t }) => {
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));
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: t, direction: l }) => {
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
- 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)
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 ? t[1] < 0 && a.value === 0 && M && (r.value = !1) : e.value === S.value && (r.value = !1), w({
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 }), (t, l) => (le(), se(ue, { to: "body" }, [
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 && t.blocking]
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": !t.blocking,
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(t.$slots, "header", {}, void 0, !0)
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(t.$slots, "default", {}, void 0, !0)
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(t.$slots, "footer", {}, void 0, !0)
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-d498ee26"]]);
189
+ }, He = /* @__PURE__ */ Ce(Se, [["__scopeId", "data-v-f08e630c"]]);
190
190
  export {
191
191
  He as default
192
192
  };
package/dist/style.css CHANGED
@@ -1 +1 @@
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}
1
+ [data-vsbs-backdrop][data-v-f08e630c]{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-f08e630c]{box-shadow:0 -5px 60px 0 var(--vsbs-shadow-color, hsla(0, 0%, 35%, .2))}[data-vsbs-sheet][data-v-f08e630c]{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-f08e630c]{visibility:visible}[data-vsbs-header][data-v-f08e630c]{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:1}[data-vsbs-header][data-v-f08e630c]: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-f08e630c]:empty{box-shadow:none;padding:12px var(--vsbs-padding-x, 16px) 8px}[data-vsbs-footer][data-v-f08e630c]{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-f08e630c]:empty{display:none}[data-vsbs-scroll][data-v-f08e630c]{flex-grow:1;overflow-y:auto;overscroll-behavior:contain}[data-vsbs-content-wrapper][data-v-f08e630c]{height:100%}[data-vsbs-content][data-v-f08e630c]{display:grid;padding:1vh var(--vsbs-padding-x, 16px);-webkit-user-select:none;user-select:none}.fade-enter-active[data-v-f08e630c],.fade-leave-active[data-v-f08e630c]{transition:opacity .3s ease}.fade-enter-from[data-v-f08e630c],.fade-leave-to[data-v-f08e630c]{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.6",
35
+ "version": "1.0.8",
36
36
  "type": "module",
37
37
  "exports": {
38
38
  ".": {