@brett_lamy/ui 3.1.0 → 4.0.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 +3 -3
- package/dist/components/edge-drawer.d.ts.map +1 -1
- package/dist/components/floating-sheet.d.ts +21 -5
- package/dist/components/floating-sheet.d.ts.map +1 -1
- package/dist/components/floating-sheet.js +108 -100
- package/dist/index.css +1 -1
- package/dist/index.d.ts +1 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +59 -61
- package/dist/lib/sheet-drag.d.ts +10 -2
- package/dist/lib/sheet-drag.d.ts.map +1 -1
- package/dist/lib/sheet-drag.js +72 -69
- package/package.json +1 -1
- package/dist/components/snap-sheet.d.ts +0 -13
- package/dist/components/snap-sheet.d.ts.map +0 -1
- package/dist/components/snap-sheet.js +0 -100
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { cn as e } from "../lib/utils.js";
|
|
3
|
-
import { prefersReducedMotion as t, springs as n } from "../lib/motion.js";
|
|
4
|
-
import { animate as r, motion as i, useMotionValue as a, useTransform as o } from "framer-motion";
|
|
5
|
-
import * as s from "react";
|
|
6
|
-
import { useEffect as c, useRef as l, useState as u } from "react";
|
|
7
|
-
import { jsx as d, jsxs as f } from "react/jsx-runtime";
|
|
8
|
-
//#region src/components/snap-sheet.tsx
|
|
9
|
-
function p({ open: p, onClose: m, snaps: h, children: g, className: _, style: v }) {
|
|
10
|
-
let y = h || [.55, .94], b = Math.max(...y), [x, S] = u(!1), C = l(null), w = a(1e4), T = l(null), E = l({
|
|
11
|
-
drag: !1,
|
|
12
|
-
y0: 0,
|
|
13
|
-
ty0: 0,
|
|
14
|
-
samples: []
|
|
15
|
-
}), D = () => C.current ? C.current.offsetHeight : 700, O = (e) => D() * (b - y[e]), k = o(w, (e) => {
|
|
16
|
-
let t = D();
|
|
17
|
-
return Math.min(1, Math.max(0, (b - e / t) / b));
|
|
18
|
-
}), A = (e, i = 0, a) => {
|
|
19
|
-
if (T.current?.stop(), t()) {
|
|
20
|
-
w.set(e), a?.();
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
T.current = r(w, e, {
|
|
24
|
-
...n.tray,
|
|
25
|
-
velocity: i,
|
|
26
|
-
onComplete: a
|
|
27
|
-
});
|
|
28
|
-
};
|
|
29
|
-
if (c(() => {
|
|
30
|
-
p ? S(!0) : x && A(D() * b, 0, () => S(!1));
|
|
31
|
-
}, [p]), s.useLayoutEffect(() => {
|
|
32
|
-
!x || !p || (w.set(D() * b), A(O(0)));
|
|
33
|
-
}, [x]), c(() => () => T.current?.stop(), []), !p && !x) return null;
|
|
34
|
-
let j = (e) => {
|
|
35
|
-
T.current?.stop(), E.current = {
|
|
36
|
-
drag: !0,
|
|
37
|
-
y0: e.clientY,
|
|
38
|
-
ty0: w.get(),
|
|
39
|
-
samples: [{
|
|
40
|
-
t: e.timeStamp,
|
|
41
|
-
y: e.clientY
|
|
42
|
-
}]
|
|
43
|
-
}, e.currentTarget.setPointerCapture(e.pointerId);
|
|
44
|
-
}, M = (e) => {
|
|
45
|
-
let t = E.current;
|
|
46
|
-
if (!t.drag) return;
|
|
47
|
-
t.samples.push({
|
|
48
|
-
t: e.timeStamp,
|
|
49
|
-
y: e.clientY
|
|
50
|
-
}), t.samples.length > 6 && t.samples.shift();
|
|
51
|
-
let n = t.ty0 + (e.clientY - t.y0), r = O(y.indexOf(b));
|
|
52
|
-
n < r && (n = r - (r - n) ** .72), w.set(Math.max(0, n));
|
|
53
|
-
}, N = (e) => {
|
|
54
|
-
let t = E.current;
|
|
55
|
-
if (!t.drag) return;
|
|
56
|
-
t.drag = !1;
|
|
57
|
-
let n = t.samples.filter((t) => e.timeStamp - t.t < 90)[0] ?? t.samples[0], r = n ? (e.clientY - n.y) / Math.max(1, e.timeStamp - n.t) : 0, i = w.get() + r * 200, a = D(), o = -1, s = Infinity;
|
|
58
|
-
if (y.forEach((e, t) => {
|
|
59
|
-
let n = Math.abs(i - a * (b - e));
|
|
60
|
-
n < s && (s = n, o = t);
|
|
61
|
-
}), Math.abs(i - a * b) < s || i > a * (b - Math.min(...y)) + a * .12) {
|
|
62
|
-
A(a * b, r * 1e3), m();
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
A(O(o), r * 1e3);
|
|
66
|
-
};
|
|
67
|
-
return /* @__PURE__ */ f("div", {
|
|
68
|
-
ref: C,
|
|
69
|
-
"data-slot": "snap-sheet",
|
|
70
|
-
className: "absolute inset-0 z-70 overflow-hidden",
|
|
71
|
-
children: [/* @__PURE__ */ d(i.div, {
|
|
72
|
-
"data-slot": "snap-sheet-scrim",
|
|
73
|
-
onClick: m,
|
|
74
|
-
className: "absolute inset-0 bg-black/45",
|
|
75
|
-
style: { opacity: k }
|
|
76
|
-
}), /* @__PURE__ */ f(i.div, {
|
|
77
|
-
"data-slot": "snap-sheet-panel",
|
|
78
|
-
className: e("absolute right-0 bottom-0 left-0 flex h-(--sheet-h) touch-none flex-col rounded-t-2xl border-x border-t border-border bg-card shadow-[0_-12px_40px_black] shadow-black/8 dark:shadow-black/50", _),
|
|
79
|
-
style: {
|
|
80
|
-
...v,
|
|
81
|
-
y: w,
|
|
82
|
-
"--sheet-h": b * 100 + "%"
|
|
83
|
-
},
|
|
84
|
-
children: [/* @__PURE__ */ d("div", {
|
|
85
|
-
"data-slot": "snap-sheet-handle",
|
|
86
|
-
onPointerDown: j,
|
|
87
|
-
onPointerMove: M,
|
|
88
|
-
onPointerUp: N,
|
|
89
|
-
onPointerCancel: N,
|
|
90
|
-
className: "shrink-0 cursor-grab touch-none pt-2 pb-1",
|
|
91
|
-
children: /* @__PURE__ */ d("div", { className: "mx-auto h-[5px] w-[38px] rounded-[3px] bg-handle" })
|
|
92
|
-
}), /* @__PURE__ */ d("div", {
|
|
93
|
-
className: "flex min-h-0 flex-1 flex-col",
|
|
94
|
-
children: g
|
|
95
|
-
})]
|
|
96
|
-
})]
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
//#endregion
|
|
100
|
-
export { p as SnapSheet };
|