@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.
@@ -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: L,
52
+ onClick: $,
52
53
  ref: j,
53
- hideDragHandleBar: F,
54
- style: I,
55
- ...O
54
+ hideDragHandleBar: I,
55
+ style: O,
56
+ ...A
56
57
  }) {
57
- const [$, 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), A = o(0.25);
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 L == "function" && L(r);
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
- }, w = (e) => {
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 * A.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
- }, x = (e) => k(e.clientY), H = (e) => w(e.clientY), Y = (e) => k(e.touches[0].clientY), B = (e) => w(e.touches[0].clientY);
89
- return r == null || r.addEventListener("mousedown", x), 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), () => {
90
- r == null || r.removeEventListener("mousedown", x), 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);
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
- }, [$, c, s]), /* @__PURE__ */ y(
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
- ...O,
108
+ ...A,
108
109
  style: {
109
- transform: `translate3d(0, ${$ ? "0" : "200%"}, 0)`,
110
- ...I
110
+ transform: `translate3d(0, ${L ? "0" : "200%"}, 0)`,
111
+ ...O
111
112
  },
112
113
  children: [
113
- !F && /* @__PURE__ */ y(K, { ref: i, children: /* @__PURE__ */ y(N, {}) }),
114
+ !I && /* @__PURE__ */ y(K, { ref: i, children: /* @__PURE__ */ y(N, {}) }),
114
115
  T
115
116
  ]
116
117
  }
@@ -1,7 +1,7 @@
1
1
  import { ComponentPropsWithRef } from 'react';
2
2
  export interface BottomSheetProps extends ComponentPropsWithRef<"div"> {
3
3
  open?: boolean;
4
- onClose: () => void;
4
+ onClose?: () => void;
5
5
  transitionDuration?: number;
6
6
  hideDragHandleBar?: boolean;
7
7
  }
@@ -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 x, jsx as o } from "react/jsx-runtime";
2
- import { useState as f, useEffect as g } from "react";
3
- import { createPortal as b } from "react-dom";
4
- import a from "basic-styled";
5
- const j = a.div`
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
- `, h = a.div`
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: t }
20
+ palette: { common: n }
20
21
  }
21
- }) => t.overlay};
22
+ }) => n.overlay};
22
23
  transition:
23
- opacity ${({ transitionDuration: t }) => `${t}ms`}
24
- ${({ ease: t }) => t === "in" ? "ease-in" : "ease-out"},
24
+ opacity ${({ transitionDuration: n }) => `${n}ms`}
25
+ ${({ ease: n }) => n === "in" ? "ease-in" : "ease-out"},
25
26
  background-color 0.2s;
26
- `, O = a.div`
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: t }) => {
34
+ ${({ placement: n }) => {
34
35
  const e = {};
35
- switch (t) {
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: t,
104
+ function R({
105
+ children: n,
105
106
  open: e,
106
- onClose: c,
107
- transitionDuration: s = 200,
108
- placement: d,
109
- style: m,
110
- ...u
107
+ onClose: d,
108
+ transitionDuration: a = 200,
109
+ placement: u,
110
+ style: y,
111
+ ref: m,
112
+ ...p
111
113
  }) {
112
- const [y, l] = f(!0), [p, r] = f(!1);
113
- return g(() => {
114
- let n, i;
115
- return e ? (l(!1), n = requestAnimationFrame(() => {
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
- }, s)), () => {
120
- n && cancelAnimationFrame(n), i && clearTimeout(i);
119
+ })) : l(!1), () => {
120
+ t && cancelAnimationFrame(t);
121
121
  };
122
- }, [e, s]), y ? null : b(
123
- /* @__PURE__ */ x(j, { onClick: c, children: [
124
- /* @__PURE__ */ o(
125
- h,
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
- transitionDuration: s,
134
+ ref: s,
135
+ transitionDuration: a,
128
136
  ease: e ? "in" : "out",
129
137
  style: {
130
- opacity: p ? 1 : 0,
131
- ...m
138
+ opacity: g ? 1 : 0,
139
+ ...y
132
140
  },
133
- ...u
141
+ ...p
134
142
  }
135
143
  ),
136
- /* @__PURE__ */ o(O, { placement: d, children: t })
144
+ /* @__PURE__ */ f(w, { placement: u, children: n })
137
145
  ] }),
138
146
  document.body
139
147
  );
140
148
  }
141
149
  export {
142
- $ as default
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: () => void;
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
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@shiflo/ui",
3
3
  "description": "Shiflo React UI Components",
4
- "version": "0.0.10",
4
+ "version": "0.0.11",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "dist"