@shiflo/ui 0.0.10 → 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.mjs +17 -16
- package/dist/components/BottomSheet/BottomSheet.typing.d.ts +1 -1
- package/dist/components/Overlay/Overlay.d.ts +1 -1
- package/dist/components/Overlay/Overlay.mjs +46 -38
- package/dist/components/Overlay/Overlay.typing.d.ts +1 -1
- package/package.json +1 -1
|
@@ -7,6 +7,7 @@ const J = b.div`
|
|
|
7
7
|
max-height: calc(100% - ${({ theme: { spacing: t } }) => t[800]});
|
|
8
8
|
overflow-y: auto;
|
|
9
9
|
margin: ${({ theme: { spacing: t } }) => t[400]};
|
|
10
|
+
margin-bottom: ${({ theme: { spacing: t } }) => `calc(${t[400]} + var(--safe-area-inset-bottom, 0px))`};
|
|
10
11
|
border-radius: ${({ theme: { radius: t } }) => t[150]};
|
|
11
12
|
background-color: ${({
|
|
12
13
|
theme: {
|
|
@@ -48,16 +49,16 @@ function _({
|
|
|
48
49
|
onClose: c,
|
|
49
50
|
children: T,
|
|
50
51
|
transitionDuration: s = 200,
|
|
51
|
-
onClick:
|
|
52
|
+
onClick: $,
|
|
52
53
|
ref: j,
|
|
53
|
-
hideDragHandleBar:
|
|
54
|
-
style:
|
|
55
|
-
...
|
|
54
|
+
hideDragHandleBar: I,
|
|
55
|
+
style: O,
|
|
56
|
+
...A
|
|
56
57
|
}) {
|
|
57
|
-
const [
|
|
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);
|
|
58
59
|
z(j, () => l.current);
|
|
59
60
|
const W = (r) => {
|
|
60
|
-
r.stopPropagation(), typeof
|
|
61
|
+
r.stopPropagation(), typeof $ == "function" && $(r);
|
|
61
62
|
};
|
|
62
63
|
return S(() => {
|
|
63
64
|
let r;
|
|
@@ -69,7 +70,7 @@ function _({
|
|
|
69
70
|
}, [t]), S(() => {
|
|
70
71
|
const r = l.current, n = R.current, k = (e) => {
|
|
71
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")));
|
|
72
|
-
},
|
|
73
|
+
}, x = (e) => {
|
|
73
74
|
if (!r || !d.current) return;
|
|
74
75
|
const u = e - v.current;
|
|
75
76
|
if (u < 0) return;
|
|
@@ -83,13 +84,13 @@ function _({
|
|
|
83
84
|
}, a = () => {
|
|
84
85
|
if (!r || !d.current) return;
|
|
85
86
|
d.current = !1, r.style.cursor = "default", i.current && (i.current.style.cursor = "grab");
|
|
86
|
-
const e = f.current - v.current, u = m.current *
|
|
87
|
+
const e = f.current - v.current, u = m.current * F.current;
|
|
87
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"));
|
|
88
|
-
},
|
|
89
|
-
return r == null || r.addEventListener("mousedown",
|
|
90
|
-
r == null || r.removeEventListener("mousedown",
|
|
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);
|
|
91
92
|
};
|
|
92
|
-
}, [
|
|
93
|
+
}, [L, c, s]), /* @__PURE__ */ y(
|
|
93
94
|
G,
|
|
94
95
|
{
|
|
95
96
|
ref: R,
|
|
@@ -104,13 +105,13 @@ function _({
|
|
|
104
105
|
ease: t ? "in" : "out",
|
|
105
106
|
transitionDuration: s,
|
|
106
107
|
onClick: W,
|
|
107
|
-
...
|
|
108
|
+
...A,
|
|
108
109
|
style: {
|
|
109
|
-
transform: `translate3d(0, ${
|
|
110
|
-
...
|
|
110
|
+
transform: `translate3d(0, ${L ? "0" : "200%"}, 0)`,
|
|
111
|
+
...O
|
|
111
112
|
},
|
|
112
113
|
children: [
|
|
113
|
-
!
|
|
114
|
+
!I && /* @__PURE__ */ y(K, { ref: i, children: /* @__PURE__ */ y(N, {}) }),
|
|
114
115
|
T
|
|
115
116
|
]
|
|
116
117
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { OverlayProps } from './Overlay.typing';
|
|
2
|
-
declare function Overlay({ children, open, onClose, transitionDuration, placement, style, ...props }: OverlayProps): import('react').ReactPortal | null;
|
|
2
|
+
declare function Overlay({ children, open, onClose, transitionDuration, placement, style, ref, ...props }: OverlayProps): import('react').ReactPortal | null;
|
|
3
3
|
export default Overlay;
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useState as
|
|
3
|
-
import { createPortal as
|
|
4
|
-
import
|
|
5
|
-
const
|
|
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
6
|
position: fixed;
|
|
7
7
|
top: 0;
|
|
8
8
|
left: 0;
|
|
9
9
|
width: 100%;
|
|
10
10
|
height: 100%;
|
|
11
|
-
|
|
11
|
+
z-index: 1;
|
|
12
|
+
`, $ = i.div`
|
|
12
13
|
position: fixed;
|
|
13
14
|
top: 0;
|
|
14
15
|
left: 0;
|
|
@@ -16,23 +17,23 @@ const j = a.div`
|
|
|
16
17
|
height: 100%;
|
|
17
18
|
background-color: ${({
|
|
18
19
|
theme: {
|
|
19
|
-
palette: { common:
|
|
20
|
+
palette: { common: n }
|
|
20
21
|
}
|
|
21
|
-
}) =>
|
|
22
|
+
}) => n.overlay};
|
|
22
23
|
transition:
|
|
23
|
-
opacity ${({ transitionDuration:
|
|
24
|
-
${({ ease:
|
|
24
|
+
opacity ${({ transitionDuration: n }) => `${n}ms`}
|
|
25
|
+
${({ ease: n }) => n === "in" ? "ease-in" : "ease-out"},
|
|
25
26
|
background-color 0.2s;
|
|
26
|
-
`,
|
|
27
|
+
`, w = i.div`
|
|
27
28
|
position: fixed;
|
|
28
29
|
top: 0;
|
|
29
30
|
left: 0;
|
|
30
31
|
width: 100%;
|
|
31
32
|
height: 100%;
|
|
32
33
|
|
|
33
|
-
${({ placement:
|
|
34
|
+
${({ placement: n }) => {
|
|
34
35
|
const e = {};
|
|
35
|
-
switch (
|
|
36
|
+
switch (n) {
|
|
36
37
|
case "top-left":
|
|
37
38
|
Object.assign(e, {
|
|
38
39
|
display: "flex",
|
|
@@ -100,44 +101,51 @@ const j = a.div`
|
|
|
100
101
|
return e;
|
|
101
102
|
}}
|
|
102
103
|
`;
|
|
103
|
-
function
|
|
104
|
-
children:
|
|
104
|
+
function R({
|
|
105
|
+
children: n,
|
|
105
106
|
open: e,
|
|
106
|
-
onClose:
|
|
107
|
-
transitionDuration:
|
|
108
|
-
placement:
|
|
109
|
-
style:
|
|
110
|
-
|
|
107
|
+
onClose: d,
|
|
108
|
+
transitionDuration: a = 200,
|
|
109
|
+
placement: u,
|
|
110
|
+
style: y,
|
|
111
|
+
ref: m,
|
|
112
|
+
...p
|
|
111
113
|
}) {
|
|
112
|
-
const [
|
|
113
|
-
return
|
|
114
|
-
let
|
|
115
|
-
return e ? (
|
|
116
|
-
r(!0);
|
|
117
|
-
})) : (r(!1), i = setTimeout(() => {
|
|
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
118
|
l(!0);
|
|
119
|
-
}
|
|
120
|
-
|
|
119
|
+
})) : l(!1), () => {
|
|
120
|
+
t && cancelAnimationFrame(t);
|
|
121
121
|
};
|
|
122
|
-
}, [e,
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
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
|
+
$,
|
|
126
133
|
{
|
|
127
|
-
|
|
134
|
+
ref: s,
|
|
135
|
+
transitionDuration: a,
|
|
128
136
|
ease: e ? "in" : "out",
|
|
129
137
|
style: {
|
|
130
|
-
opacity:
|
|
131
|
-
...
|
|
138
|
+
opacity: g ? 1 : 0,
|
|
139
|
+
...y
|
|
132
140
|
},
|
|
133
|
-
...
|
|
141
|
+
...p
|
|
134
142
|
}
|
|
135
143
|
),
|
|
136
|
-
/* @__PURE__ */
|
|
144
|
+
/* @__PURE__ */ f(w, { placement: u, children: n })
|
|
137
145
|
] }),
|
|
138
146
|
document.body
|
|
139
147
|
);
|
|
140
148
|
}
|
|
141
149
|
export {
|
|
142
|
-
|
|
150
|
+
R as default
|
|
143
151
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ComponentPropsWithRef } from 'react';
|
|
2
2
|
export interface OverlayProps extends ComponentPropsWithRef<"div"> {
|
|
3
3
|
open?: boolean;
|
|
4
|
-
onClose
|
|
4
|
+
onClose?: () => void;
|
|
5
5
|
transitionDuration?: number;
|
|
6
6
|
placement?: "top-left" | "top-right" | "bottom-left" | "bottom-right" | "center-top" | "center-bottom" | "center-middle" | "center-left" | "center-right";
|
|
7
7
|
}
|