@shiflo/ui 0.0.9 → 0.0.10

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.
@@ -0,0 +1,3 @@
1
+ import { BottomSheetProps } from './BottomSheet.typing';
2
+ declare function BottomSheet({ open, onClose, children, transitionDuration, onClick, ref, hideDragHandleBar, style, ...props }: BottomSheetProps): import("react").JSX.Element;
3
+ export default BottomSheet;
@@ -0,0 +1,123 @@
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
+ border-radius: ${({ theme: { radius: t } }) => t[150]};
11
+ background-color: ${({
12
+ theme: {
13
+ palette: { common: t }
14
+ }
15
+ }) => t.background};
16
+ transition:
17
+ transform ${({ transitionDuration: t }) => `${t}ms`}
18
+ ${({ ease: t }) => t === "in" ? "ease-out" : "ease-in"},
19
+ background-color 0.2s;
20
+ `, K = b.div`
21
+ position: sticky;
22
+ top: 0;
23
+ left: 0;
24
+ display: flex;
25
+ justify-content: center;
26
+ align-items: center;
27
+ cursor: grab;
28
+ padding: ${({ theme: { spacing: t } }) => t[100]};
29
+ background-color: ${({
30
+ theme: {
31
+ palette: { common: t }
32
+ }
33
+ }) => t.background};
34
+ transition: background-color 0.2s;
35
+ `, N = b.div`
36
+ width: 24px;
37
+ height: 4px;
38
+ border-radius: ${({ theme: { radius: t } }) => t[100]};
39
+ background-color: ${({
40
+ theme: {
41
+ palette: { border: t }
42
+ }
43
+ }) => t.main};
44
+ transition: background-color 0.2s;
45
+ `;
46
+ function _({
47
+ open: t,
48
+ onClose: c,
49
+ children: T,
50
+ transitionDuration: s = 200,
51
+ onClick: L,
52
+ ref: j,
53
+ hideDragHandleBar: F,
54
+ style: I,
55
+ ...O
56
+ }) {
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
+ z(j, () => l.current);
59
+ const W = (r) => {
60
+ r.stopPropagation(), typeof L == "function" && L(r);
61
+ };
62
+ return S(() => {
63
+ let r;
64
+ return t ? r = requestAnimationFrame(() => {
65
+ h(!0);
66
+ }) : h(!1), () => {
67
+ r && cancelAnimationFrame(r);
68
+ };
69
+ }, [t]), S(() => {
70
+ const r = l.current, n = R.current, k = (e) => {
71
+ 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
+ if (!r || !d.current) return;
74
+ const u = e - v.current;
75
+ if (u < 0) return;
76
+ f.current = e;
77
+ const D = Date.now(), M = D - p.current;
78
+ if (M > 0) {
79
+ const q = f.current;
80
+ g.current = (e - q) / M, p.current = D;
81
+ }
82
+ n && (n.style.opacity = `${Math.max(0, 1 - u / (m.current * 2))}`), r.style.transform = `translate3d(0, ${u}px, 0)`;
83
+ }, a = () => {
84
+ if (!r || !d.current) return;
85
+ 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
+ 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);
91
+ };
92
+ }, [$, c, s]), /* @__PURE__ */ y(
93
+ G,
94
+ {
95
+ ref: R,
96
+ open: t,
97
+ onClose: c,
98
+ transitionDuration: s,
99
+ placement: "center-bottom",
100
+ children: /* @__PURE__ */ P(
101
+ J,
102
+ {
103
+ ref: l,
104
+ ease: t ? "in" : "out",
105
+ transitionDuration: s,
106
+ onClick: W,
107
+ ...O,
108
+ style: {
109
+ transform: `translate3d(0, ${$ ? "0" : "200%"}, 0)`,
110
+ ...I
111
+ },
112
+ children: [
113
+ !F && /* @__PURE__ */ y(K, { ref: i, children: /* @__PURE__ */ y(N, {}) }),
114
+ T
115
+ ]
116
+ }
117
+ )
118
+ }
119
+ );
120
+ }
121
+ export {
122
+ _ as default
123
+ };
@@ -0,0 +1,7 @@
1
+ import { ComponentPropsWithRef } from 'react';
2
+ export interface BottomSheetProps extends ComponentPropsWithRef<"div"> {
3
+ open?: boolean;
4
+ onClose: () => void;
5
+ transitionDuration?: number;
6
+ hideDragHandleBar?: boolean;
7
+ }
@@ -0,0 +1,4 @@
1
+ import { default as BottomSheet } from './BottomSheet';
2
+ import { BottomSheetProps } from './BottomSheet.typing';
3
+ export type { BottomSheetProps };
4
+ export default BottomSheet;
@@ -0,0 +1,4 @@
1
+ import o from "./BottomSheet.mjs";
2
+ export {
3
+ o as default
4
+ };
@@ -0,0 +1,3 @@
1
+ import { OverlayProps } from './Overlay.typing';
2
+ declare function Overlay({ children, open, onClose, transitionDuration, placement, style, ...props }: OverlayProps): import('react').ReactPortal | null;
3
+ export default Overlay;
@@ -0,0 +1,143 @@
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`
6
+ position: fixed;
7
+ top: 0;
8
+ left: 0;
9
+ width: 100%;
10
+ height: 100%;
11
+ `, h = a.div`
12
+ position: fixed;
13
+ top: 0;
14
+ left: 0;
15
+ width: 100%;
16
+ height: 100%;
17
+ background-color: ${({
18
+ theme: {
19
+ palette: { common: t }
20
+ }
21
+ }) => t.overlay};
22
+ transition:
23
+ opacity ${({ transitionDuration: t }) => `${t}ms`}
24
+ ${({ ease: t }) => t === "in" ? "ease-in" : "ease-out"},
25
+ background-color 0.2s;
26
+ `, O = a.div`
27
+ position: fixed;
28
+ top: 0;
29
+ left: 0;
30
+ width: 100%;
31
+ height: 100%;
32
+
33
+ ${({ placement: t }) => {
34
+ const e = {};
35
+ switch (t) {
36
+ case "top-left":
37
+ Object.assign(e, {
38
+ display: "flex",
39
+ justifyContent: "flex-start",
40
+ alignItems: "flex-start"
41
+ });
42
+ break;
43
+ case "top-right":
44
+ Object.assign(e, {
45
+ display: "flex",
46
+ justifyContent: "flex-end",
47
+ alignItems: "flex-start"
48
+ });
49
+ break;
50
+ case "bottom-left":
51
+ Object.assign(e, {
52
+ display: "flex",
53
+ justifyContent: "flex-start",
54
+ alignItems: "flex-end"
55
+ });
56
+ break;
57
+ case "bottom-right":
58
+ Object.assign(e, {
59
+ display: "flex",
60
+ justifyContent: "flex-end",
61
+ alignItems: "flex-end"
62
+ });
63
+ break;
64
+ case "center-top":
65
+ Object.assign(e, {
66
+ display: "flex",
67
+ justifyContent: "center",
68
+ alignItems: "flex-start"
69
+ });
70
+ break;
71
+ case "center-bottom":
72
+ Object.assign(e, {
73
+ display: "flex",
74
+ justifyContent: "center",
75
+ alignItems: "flex-end"
76
+ });
77
+ break;
78
+ case "center-middle":
79
+ Object.assign(e, {
80
+ display: "flex",
81
+ justifyContent: "center",
82
+ alignItems: "center"
83
+ });
84
+ break;
85
+ case "center-left":
86
+ Object.assign(e, {
87
+ display: "flex",
88
+ justifyContent: "flex-start",
89
+ alignItems: "center"
90
+ });
91
+ break;
92
+ case "center-right":
93
+ Object.assign(e, {
94
+ display: "flex",
95
+ justifyContent: "flex-end",
96
+ alignItems: "center"
97
+ });
98
+ break;
99
+ }
100
+ return e;
101
+ }}
102
+ `;
103
+ function $({
104
+ children: t,
105
+ open: e,
106
+ onClose: c,
107
+ transitionDuration: s = 200,
108
+ placement: d,
109
+ style: m,
110
+ ...u
111
+ }) {
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(() => {
118
+ l(!0);
119
+ }, s)), () => {
120
+ n && cancelAnimationFrame(n), i && clearTimeout(i);
121
+ };
122
+ }, [e, s]), y ? null : b(
123
+ /* @__PURE__ */ x(j, { onClick: c, children: [
124
+ /* @__PURE__ */ o(
125
+ h,
126
+ {
127
+ transitionDuration: s,
128
+ ease: e ? "in" : "out",
129
+ style: {
130
+ opacity: p ? 1 : 0,
131
+ ...m
132
+ },
133
+ ...u
134
+ }
135
+ ),
136
+ /* @__PURE__ */ o(O, { placement: d, children: t })
137
+ ] }),
138
+ document.body
139
+ );
140
+ }
141
+ export {
142
+ $ as default
143
+ };
@@ -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
+ }
@@ -0,0 +1,4 @@
1
+ import { default as Overlay } from './Overlay';
2
+ import { OverlayProps } from './Overlay.typing';
3
+ export type { OverlayProps };
4
+ export default Overlay;
@@ -0,0 +1,4 @@
1
+ import a from "./Overlay.mjs";
2
+ export {
3
+ a as default
4
+ };
@@ -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 t = {
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
- t as default
85
+ g as default
85
86
  };
@@ -1,6 +1,6 @@
1
1
  import a from "./radius.mjs";
2
- import F from "./spacing.mjs";
3
- import r from "./typography.mjs";
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: r,
80
- spacing: F,
80
+ typography: F,
81
+ spacing: r,
81
82
  radius: a
82
83
  };
83
84
  export {
@@ -65,6 +65,7 @@ declare module "basic-styled" {
65
65
  common: {
66
66
  background: string;
67
67
  surface: string;
68
+ overlay: string;
68
69
  };
69
70
  text: {
70
71
  primary: string;
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.9",
4
+ "version": "0.0.10",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "dist"