@shiflo/ui 0.0.9 → 0.0.11
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/components/BottomSheet/BottomSheet.d.ts +3 -0
- package/dist/components/BottomSheet/BottomSheet.mjs +124 -0
- package/dist/components/BottomSheet/BottomSheet.typing.d.ts +7 -0
- package/dist/components/BottomSheet/index.d.ts +4 -0
- package/dist/components/BottomSheet/index.mjs +4 -0
- package/dist/components/Overlay/Overlay.d.ts +3 -0
- package/dist/components/Overlay/Overlay.mjs +151 -0
- package/dist/components/Overlay/Overlay.typing.d.ts +7 -0
- package/dist/components/Overlay/index.d.ts +4 -0
- package/dist/components/Overlay/index.mjs +4 -0
- package/dist/theme/dark.mjs +4 -3
- package/dist/theme/light.mjs +6 -5
- package/dist/theme/typing.d.ts +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { jsx as y, jsxs as P } from "react/jsx-runtime";
|
|
2
|
+
import { useState as V, useRef as o, useImperativeHandle as z, useEffect as S } from "react";
|
|
3
|
+
import b from "basic-styled";
|
|
4
|
+
import G from "../Overlay/Overlay.mjs";
|
|
5
|
+
const J = b.div`
|
|
6
|
+
width: 100%;
|
|
7
|
+
max-height: calc(100% - ${({ theme: { spacing: t } }) => t[800]});
|
|
8
|
+
overflow-y: auto;
|
|
9
|
+
margin: ${({ theme: { spacing: t } }) => t[400]};
|
|
10
|
+
margin-bottom: ${({ theme: { spacing: t } }) => `calc(${t[400]} + var(--safe-area-inset-bottom, 0px))`};
|
|
11
|
+
border-radius: ${({ theme: { radius: t } }) => t[150]};
|
|
12
|
+
background-color: ${({
|
|
13
|
+
theme: {
|
|
14
|
+
palette: { common: t }
|
|
15
|
+
}
|
|
16
|
+
}) => t.background};
|
|
17
|
+
transition:
|
|
18
|
+
transform ${({ transitionDuration: t }) => `${t}ms`}
|
|
19
|
+
${({ ease: t }) => t === "in" ? "ease-out" : "ease-in"},
|
|
20
|
+
background-color 0.2s;
|
|
21
|
+
`, K = b.div`
|
|
22
|
+
position: sticky;
|
|
23
|
+
top: 0;
|
|
24
|
+
left: 0;
|
|
25
|
+
display: flex;
|
|
26
|
+
justify-content: center;
|
|
27
|
+
align-items: center;
|
|
28
|
+
cursor: grab;
|
|
29
|
+
padding: ${({ theme: { spacing: t } }) => t[100]};
|
|
30
|
+
background-color: ${({
|
|
31
|
+
theme: {
|
|
32
|
+
palette: { common: t }
|
|
33
|
+
}
|
|
34
|
+
}) => t.background};
|
|
35
|
+
transition: background-color 0.2s;
|
|
36
|
+
`, N = b.div`
|
|
37
|
+
width: 24px;
|
|
38
|
+
height: 4px;
|
|
39
|
+
border-radius: ${({ theme: { radius: t } }) => t[100]};
|
|
40
|
+
background-color: ${({
|
|
41
|
+
theme: {
|
|
42
|
+
palette: { border: t }
|
|
43
|
+
}
|
|
44
|
+
}) => t.main};
|
|
45
|
+
transition: background-color 0.2s;
|
|
46
|
+
`;
|
|
47
|
+
function _({
|
|
48
|
+
open: t,
|
|
49
|
+
onClose: c,
|
|
50
|
+
children: T,
|
|
51
|
+
transitionDuration: s = 200,
|
|
52
|
+
onClick: $,
|
|
53
|
+
ref: j,
|
|
54
|
+
hideDragHandleBar: I,
|
|
55
|
+
style: O,
|
|
56
|
+
...A
|
|
57
|
+
}) {
|
|
58
|
+
const [L, h] = V(!1), l = o(null), R = o(null), i = o(null), d = o(!1), v = o(0), f = o(0), m = o(0), g = o(0), p = o(0), F = o(0.25);
|
|
59
|
+
z(j, () => l.current);
|
|
60
|
+
const W = (r) => {
|
|
61
|
+
r.stopPropagation(), typeof $ == "function" && $(r);
|
|
62
|
+
};
|
|
63
|
+
return S(() => {
|
|
64
|
+
let r;
|
|
65
|
+
return t ? r = requestAnimationFrame(() => {
|
|
66
|
+
h(!0);
|
|
67
|
+
}) : h(!1), () => {
|
|
68
|
+
r && cancelAnimationFrame(r);
|
|
69
|
+
};
|
|
70
|
+
}, [t]), S(() => {
|
|
71
|
+
const r = l.current, n = R.current, k = (e) => {
|
|
72
|
+
r && (r.scrollTop > 0 || (d.current = !0, v.current = e, f.current = e, m.current = r.offsetHeight, p.current = Date.now(), r.style.transition = "none", r.style.cursor = "grabbing", n && (n.style.transition = "none"), i.current && (i.current.style.cursor = "grabbing")));
|
|
73
|
+
}, x = (e) => {
|
|
74
|
+
if (!r || !d.current) return;
|
|
75
|
+
const u = e - v.current;
|
|
76
|
+
if (u < 0) return;
|
|
77
|
+
f.current = e;
|
|
78
|
+
const D = Date.now(), M = D - p.current;
|
|
79
|
+
if (M > 0) {
|
|
80
|
+
const q = f.current;
|
|
81
|
+
g.current = (e - q) / M, p.current = D;
|
|
82
|
+
}
|
|
83
|
+
n && (n.style.opacity = `${Math.max(0, 1 - u / (m.current * 2))}`), r.style.transform = `translate3d(0, ${u}px, 0)`;
|
|
84
|
+
}, a = () => {
|
|
85
|
+
if (!r || !d.current) return;
|
|
86
|
+
d.current = !1, r.style.cursor = "default", i.current && (i.current.style.cursor = "grab");
|
|
87
|
+
const e = f.current - v.current, u = m.current * F.current;
|
|
88
|
+
r.style.transition = `transform ${s}ms ease-out`, n && (n.style.transition = `opacity ${s}ms ease-out`), e > u || g.current > 0.5 && g.current > 0 ? (r.style.transform = "translate3d(0, 200%, 0)", n && (n.style.opacity = "0"), c == null || c()) : (r.style.transform = "translate3d(0, 0, 0)", n && (n.style.opacity = "1"));
|
|
89
|
+
}, w = (e) => k(e.clientY), H = (e) => x(e.clientY), Y = (e) => k(e.touches[0].clientY), B = (e) => x(e.touches[0].clientY);
|
|
90
|
+
return r == null || r.addEventListener("mousedown", w), r == null || r.addEventListener("mousemove", H), r == null || r.addEventListener("mouseup", a), r == null || r.addEventListener("mouseleave", a), r == null || r.addEventListener("touchstart", Y), r == null || r.addEventListener("touchmove", B), r == null || r.addEventListener("touchend", a), r == null || r.addEventListener("touchcancel", a), () => {
|
|
91
|
+
r == null || r.removeEventListener("mousedown", w), r == null || r.removeEventListener("mousemove", H), r == null || r.removeEventListener("mouseup", a), r == null || r.removeEventListener("mouseleave", a), r == null || r.removeEventListener("touchstart", Y), r == null || r.removeEventListener("touchmove", B), r == null || r.removeEventListener("touchend", a), r == null || r.removeEventListener("touchcancel", a);
|
|
92
|
+
};
|
|
93
|
+
}, [L, c, s]), /* @__PURE__ */ y(
|
|
94
|
+
G,
|
|
95
|
+
{
|
|
96
|
+
ref: R,
|
|
97
|
+
open: t,
|
|
98
|
+
onClose: c,
|
|
99
|
+
transitionDuration: s,
|
|
100
|
+
placement: "center-bottom",
|
|
101
|
+
children: /* @__PURE__ */ P(
|
|
102
|
+
J,
|
|
103
|
+
{
|
|
104
|
+
ref: l,
|
|
105
|
+
ease: t ? "in" : "out",
|
|
106
|
+
transitionDuration: s,
|
|
107
|
+
onClick: W,
|
|
108
|
+
...A,
|
|
109
|
+
style: {
|
|
110
|
+
transform: `translate3d(0, ${L ? "0" : "200%"}, 0)`,
|
|
111
|
+
...O
|
|
112
|
+
},
|
|
113
|
+
children: [
|
|
114
|
+
!I && /* @__PURE__ */ y(K, { ref: i, children: /* @__PURE__ */ y(N, {}) }),
|
|
115
|
+
T
|
|
116
|
+
]
|
|
117
|
+
}
|
|
118
|
+
)
|
|
119
|
+
}
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
export {
|
|
123
|
+
_ as default
|
|
124
|
+
};
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { jsxs as j, jsx as f } from "react/jsx-runtime";
|
|
2
|
+
import { useState as c, useRef as h, useImperativeHandle as O, useLayoutEffect as I, useEffect as k } from "react";
|
|
3
|
+
import { createPortal as C } from "react-dom";
|
|
4
|
+
import i from "basic-styled";
|
|
5
|
+
const v = i.div`
|
|
6
|
+
position: fixed;
|
|
7
|
+
top: 0;
|
|
8
|
+
left: 0;
|
|
9
|
+
width: 100%;
|
|
10
|
+
height: 100%;
|
|
11
|
+
z-index: 1;
|
|
12
|
+
`, $ = i.div`
|
|
13
|
+
position: fixed;
|
|
14
|
+
top: 0;
|
|
15
|
+
left: 0;
|
|
16
|
+
width: 100%;
|
|
17
|
+
height: 100%;
|
|
18
|
+
background-color: ${({
|
|
19
|
+
theme: {
|
|
20
|
+
palette: { common: n }
|
|
21
|
+
}
|
|
22
|
+
}) => n.overlay};
|
|
23
|
+
transition:
|
|
24
|
+
opacity ${({ transitionDuration: n }) => `${n}ms`}
|
|
25
|
+
${({ ease: n }) => n === "in" ? "ease-in" : "ease-out"},
|
|
26
|
+
background-color 0.2s;
|
|
27
|
+
`, w = i.div`
|
|
28
|
+
position: fixed;
|
|
29
|
+
top: 0;
|
|
30
|
+
left: 0;
|
|
31
|
+
width: 100%;
|
|
32
|
+
height: 100%;
|
|
33
|
+
|
|
34
|
+
${({ placement: n }) => {
|
|
35
|
+
const e = {};
|
|
36
|
+
switch (n) {
|
|
37
|
+
case "top-left":
|
|
38
|
+
Object.assign(e, {
|
|
39
|
+
display: "flex",
|
|
40
|
+
justifyContent: "flex-start",
|
|
41
|
+
alignItems: "flex-start"
|
|
42
|
+
});
|
|
43
|
+
break;
|
|
44
|
+
case "top-right":
|
|
45
|
+
Object.assign(e, {
|
|
46
|
+
display: "flex",
|
|
47
|
+
justifyContent: "flex-end",
|
|
48
|
+
alignItems: "flex-start"
|
|
49
|
+
});
|
|
50
|
+
break;
|
|
51
|
+
case "bottom-left":
|
|
52
|
+
Object.assign(e, {
|
|
53
|
+
display: "flex",
|
|
54
|
+
justifyContent: "flex-start",
|
|
55
|
+
alignItems: "flex-end"
|
|
56
|
+
});
|
|
57
|
+
break;
|
|
58
|
+
case "bottom-right":
|
|
59
|
+
Object.assign(e, {
|
|
60
|
+
display: "flex",
|
|
61
|
+
justifyContent: "flex-end",
|
|
62
|
+
alignItems: "flex-end"
|
|
63
|
+
});
|
|
64
|
+
break;
|
|
65
|
+
case "center-top":
|
|
66
|
+
Object.assign(e, {
|
|
67
|
+
display: "flex",
|
|
68
|
+
justifyContent: "center",
|
|
69
|
+
alignItems: "flex-start"
|
|
70
|
+
});
|
|
71
|
+
break;
|
|
72
|
+
case "center-bottom":
|
|
73
|
+
Object.assign(e, {
|
|
74
|
+
display: "flex",
|
|
75
|
+
justifyContent: "center",
|
|
76
|
+
alignItems: "flex-end"
|
|
77
|
+
});
|
|
78
|
+
break;
|
|
79
|
+
case "center-middle":
|
|
80
|
+
Object.assign(e, {
|
|
81
|
+
display: "flex",
|
|
82
|
+
justifyContent: "center",
|
|
83
|
+
alignItems: "center"
|
|
84
|
+
});
|
|
85
|
+
break;
|
|
86
|
+
case "center-left":
|
|
87
|
+
Object.assign(e, {
|
|
88
|
+
display: "flex",
|
|
89
|
+
justifyContent: "flex-start",
|
|
90
|
+
alignItems: "center"
|
|
91
|
+
});
|
|
92
|
+
break;
|
|
93
|
+
case "center-right":
|
|
94
|
+
Object.assign(e, {
|
|
95
|
+
display: "flex",
|
|
96
|
+
justifyContent: "flex-end",
|
|
97
|
+
alignItems: "center"
|
|
98
|
+
});
|
|
99
|
+
break;
|
|
100
|
+
}
|
|
101
|
+
return e;
|
|
102
|
+
}}
|
|
103
|
+
`;
|
|
104
|
+
function R({
|
|
105
|
+
children: n,
|
|
106
|
+
open: e,
|
|
107
|
+
onClose: d,
|
|
108
|
+
transitionDuration: a = 200,
|
|
109
|
+
placement: u,
|
|
110
|
+
style: y,
|
|
111
|
+
ref: m,
|
|
112
|
+
...p
|
|
113
|
+
}) {
|
|
114
|
+
const [x, r] = c(!0), [g, l] = c(!1), s = h(null);
|
|
115
|
+
return O(m, () => s.current), I(() => {
|
|
116
|
+
let t;
|
|
117
|
+
return e ? (r(!1), t = requestAnimationFrame(() => {
|
|
118
|
+
l(!0);
|
|
119
|
+
})) : l(!1), () => {
|
|
120
|
+
t && cancelAnimationFrame(t);
|
|
121
|
+
};
|
|
122
|
+
}, [e, a]), k(() => {
|
|
123
|
+
const t = s.current, o = (b) => {
|
|
124
|
+
e || b.propertyName === "opacity" && r(!0);
|
|
125
|
+
};
|
|
126
|
+
return t == null || t.addEventListener("transitionend", o), () => {
|
|
127
|
+
t == null || t.removeEventListener("transitionend", o);
|
|
128
|
+
};
|
|
129
|
+
}, [e]), x ? null : C(
|
|
130
|
+
/* @__PURE__ */ j(v, { onClick: d, children: [
|
|
131
|
+
/* @__PURE__ */ f(
|
|
132
|
+
$,
|
|
133
|
+
{
|
|
134
|
+
ref: s,
|
|
135
|
+
transitionDuration: a,
|
|
136
|
+
ease: e ? "in" : "out",
|
|
137
|
+
style: {
|
|
138
|
+
opacity: g ? 1 : 0,
|
|
139
|
+
...y
|
|
140
|
+
},
|
|
141
|
+
...p
|
|
142
|
+
}
|
|
143
|
+
),
|
|
144
|
+
/* @__PURE__ */ f(w, { placement: u, children: n })
|
|
145
|
+
] }),
|
|
146
|
+
document.body
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
export {
|
|
150
|
+
R as default
|
|
151
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ComponentPropsWithRef } from 'react';
|
|
2
|
+
export interface OverlayProps extends ComponentPropsWithRef<"div"> {
|
|
3
|
+
open?: boolean;
|
|
4
|
+
onClose?: () => void;
|
|
5
|
+
transitionDuration?: number;
|
|
6
|
+
placement?: "top-left" | "top-right" | "bottom-left" | "bottom-right" | "center-top" | "center-bottom" | "center-middle" | "center-left" | "center-right";
|
|
7
|
+
}
|
package/dist/theme/dark.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import a from "./radius.mjs";
|
|
2
2
|
import r from "./spacing.mjs";
|
|
3
3
|
import i from "./typography.mjs";
|
|
4
|
-
const
|
|
4
|
+
const g = {
|
|
5
5
|
mode: "dark",
|
|
6
6
|
palette: {
|
|
7
7
|
primary: {
|
|
@@ -63,7 +63,8 @@ const t = {
|
|
|
63
63
|
},
|
|
64
64
|
common: {
|
|
65
65
|
background: "#22252A",
|
|
66
|
-
surface: "#30333A"
|
|
66
|
+
surface: "#30333A",
|
|
67
|
+
overlay: "rgba(0, 0, 0, 0.7)"
|
|
67
68
|
},
|
|
68
69
|
text: {
|
|
69
70
|
primary: "#EAECEF",
|
|
@@ -81,5 +82,5 @@ const t = {
|
|
|
81
82
|
radius: a
|
|
82
83
|
};
|
|
83
84
|
export {
|
|
84
|
-
|
|
85
|
+
g as default
|
|
85
86
|
};
|
package/dist/theme/light.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import a from "./radius.mjs";
|
|
2
|
-
import
|
|
3
|
-
import
|
|
2
|
+
import r from "./spacing.mjs";
|
|
3
|
+
import F from "./typography.mjs";
|
|
4
4
|
const C = {
|
|
5
5
|
mode: "light",
|
|
6
6
|
palette: {
|
|
@@ -63,7 +63,8 @@ const C = {
|
|
|
63
63
|
},
|
|
64
64
|
common: {
|
|
65
65
|
background: "#FFFFFF",
|
|
66
|
-
surface: "#FFFFFF"
|
|
66
|
+
surface: "#FFFFFF",
|
|
67
|
+
overlay: "rgba(0, 0, 0, 0.5)"
|
|
67
68
|
},
|
|
68
69
|
text: {
|
|
69
70
|
primary: "#212529",
|
|
@@ -76,8 +77,8 @@ const C = {
|
|
|
76
77
|
dark: "#6C757D"
|
|
77
78
|
}
|
|
78
79
|
},
|
|
79
|
-
typography:
|
|
80
|
-
spacing:
|
|
80
|
+
typography: F,
|
|
81
|
+
spacing: r,
|
|
81
82
|
radius: a
|
|
82
83
|
};
|
|
83
84
|
export {
|
package/dist/theme/typing.d.ts
CHANGED