@shiflo/ui 0.2.1 → 0.2.3

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.
@@ -1,3 +1,3 @@
1
1
  import { BottomSheetProps } from './BottomSheet.typing';
2
- declare function BottomSheet({ open, onClose, children, transitionDuration, maxWidth, onClick, ref, hideDragHandleBar, hideOverlay, style, ...props }: BottomSheetProps): import("@emotion/react/jsx-runtime").JSX.Element;
2
+ declare function BottomSheet({ open, onClose, children, transitionDuration, maxWidth, onClick, ref, hideDragHandleBar, hideOverlay, disablePortal, style, ...props }: BottomSheetProps): import("@emotion/react/jsx-runtime").JSX.Element;
3
3
  export default BottomSheet;
@@ -1,8 +1,8 @@
1
- import { jsx as g, jsxs as V } from "@emotion/react/jsx-runtime";
2
- import { useState as z, useRef as o, useImperativeHandle as C, useEffect as M } from "react";
1
+ import { jsx as g, jsxs as z } from "@emotion/react/jsx-runtime";
2
+ import { useState as C, useRef as o, useImperativeHandle as G, useEffect as M } from "react";
3
3
  import y from "@emotion/styled";
4
- import G from "../Overlay/Overlay.mjs";
5
- const J = y.div`
4
+ import J from "../Overlay/Overlay.mjs";
5
+ const K = y.div`
6
6
  width: calc(100% - ${({ theme: { spacing: t } }) => t[800]});
7
7
  max-width: ${({ maxWidth: t = "375px" }) => t};
8
8
  max-height: calc(100% - ${({ theme: { spacing: t } }) => t[800]});
@@ -19,7 +19,7 @@ const J = y.div`
19
19
  transform ${({ transitionDuration: t }) => `${t}ms`}
20
20
  ${({ ease: t }) => t === "in" ? "ease-out" : "ease-in"},
21
21
  background-color 0.2s;
22
- `, K = y.div`
22
+ `, N = y.div`
23
23
  position: sticky;
24
24
  top: 0;
25
25
  left: 0;
@@ -34,7 +34,7 @@ const J = y.div`
34
34
  }
35
35
  }) => t.background};
36
36
  transition: background-color 0.2s;
37
- `, N = y.div`
37
+ `, Q = y.div`
38
38
  width: 24px;
39
39
  height: 4px;
40
40
  border-radius: ${({ theme: { radius: t } }) => t[100]};
@@ -45,7 +45,7 @@ const J = y.div`
45
45
  }) => t.main};
46
46
  transition: background-color 0.2s;
47
47
  `;
48
- function _({
48
+ function ee({
49
49
  open: t,
50
50
  onClose: d,
51
51
  children: S,
@@ -55,12 +55,13 @@ function _({
55
55
  ref: j,
56
56
  hideDragHandleBar: I,
57
57
  hideOverlay: O,
58
- style: A,
59
- ...F
58
+ disablePortal: A,
59
+ style: F,
60
+ ...W
60
61
  }) {
61
- const [E, $] = z(!1), m = o(null), L = o(null), c = o(null), u = o(!1), f = o(0), l = o(0), h = o(0), v = o(0), p = o(0), W = o(0.25);
62
- C(j, () => m.current);
63
- const q = (e) => {
62
+ const [E, $] = C(!1), m = o(null), L = o(null), c = o(null), u = o(!1), f = o(0), l = o(0), h = o(0), v = o(0), p = o(0), q = o(0.25);
63
+ G(j, () => m.current);
64
+ const P = (e) => {
64
65
  e.stopPropagation(), typeof b == "function" && b(e);
65
66
  };
66
67
  return M(() => {
@@ -80,46 +81,47 @@ function _({
80
81
  l.current = r;
81
82
  const B = Date.now(), D = B - p.current;
82
83
  if (D > 0) {
83
- const P = l.current;
84
- v.current = (r - P) / D, p.current = B;
84
+ const V = l.current;
85
+ v.current = (r - V) / D, p.current = B;
85
86
  }
86
87
  n && (n.style.opacity = `${Math.max(0, 1 - i / (h.current * 2))}`), e.style.transform = `translate3d(0, ${i}px, 0)`;
87
88
  }, s = () => {
88
89
  if (!e || !u.current) return;
89
90
  u.current = !1, e.style.cursor = "default", c.current && (c.current.style.cursor = "grab");
90
- const r = l.current - f.current, i = h.current * W.current;
91
+ const r = l.current - f.current, i = h.current * q.current;
91
92
  e.style.transition = `transform ${a}ms ease-out`, n && (n.style.transition = `opacity ${a}ms ease-out`), r > i || v.current > 0.5 && v.current > 0 ? (e.style.transform = "translate3d(0, 200%, 0)", n && (n.style.opacity = "0"), d?.()) : (e.style.transform = "translate3d(0, 0, 0)", n && (n.style.opacity = "1"));
92
93
  }, R = (r) => x(r.clientY), w = (r) => k(r.clientY), H = (r) => x(r.touches[0].clientY), Y = (r) => k(r.touches[0].clientY);
93
94
  return e?.addEventListener("mousedown", R), e?.addEventListener("mousemove", w), e?.addEventListener("mouseup", s), e?.addEventListener("mouseleave", s), e?.addEventListener("touchstart", H), e?.addEventListener("touchmove", Y), e?.addEventListener("touchend", s), e?.addEventListener("touchcancel", s), () => {
94
95
  e?.removeEventListener("mousedown", R), e?.removeEventListener("mousemove", w), e?.removeEventListener("mouseup", s), e?.removeEventListener("mouseleave", s), e?.removeEventListener("touchstart", H), e?.removeEventListener("touchmove", Y), e?.removeEventListener("touchend", s), e?.removeEventListener("touchcancel", s);
95
96
  };
96
97
  }, [E, d, a]), /* @__PURE__ */ g(
97
- G,
98
+ J,
98
99
  {
99
100
  ref: L,
100
101
  open: t,
101
102
  onClose: d,
102
103
  transitionDuration: a,
103
104
  placement: "center-bottom",
105
+ disablePortal: A,
104
106
  css: O ? {
105
107
  pointerEvents: "none",
106
108
  backgroundColor: "transparent !important"
107
109
  } : void 0,
108
- children: /* @__PURE__ */ V(
109
- J,
110
+ children: /* @__PURE__ */ z(
111
+ K,
110
112
  {
111
113
  ref: m,
112
114
  ease: t ? "in" : "out",
113
115
  transitionDuration: a,
114
116
  maxWidth: T,
115
- onClick: q,
116
- ...F,
117
+ onClick: P,
118
+ ...W,
117
119
  style: {
118
120
  transform: `translate3d(0, ${E ? "0" : "200%"}, 0)`,
119
- ...A
121
+ ...F
120
122
  },
121
123
  children: [
122
- !I && /* @__PURE__ */ g(K, { ref: c, children: /* @__PURE__ */ g(N, {}) }),
124
+ !I && /* @__PURE__ */ g(N, { ref: c, children: /* @__PURE__ */ g(Q, {}) }),
123
125
  S
124
126
  ]
125
127
  }
@@ -128,5 +130,5 @@ function _({
128
130
  );
129
131
  }
130
132
  export {
131
- _ as default
133
+ ee as default
132
134
  };
@@ -7,4 +7,5 @@ export interface BottomSheetProps extends ComponentPropsWithRef<"div">, Pick<Uti
7
7
  maxWidth?: string;
8
8
  hideDragHandleBar?: boolean;
9
9
  hideOverlay?: boolean;
10
+ disablePortal?: boolean;
10
11
  }
@@ -1,3 +1,3 @@
1
1
  import { DialogProps } from './Dialog.typing';
2
- declare function Dialog({ open, onClose, children, transitionDuration, onClick, style, maxWidth, ...props }: DialogProps): import("@emotion/react/jsx-runtime").JSX.Element;
2
+ declare function Dialog({ open, onClose, children, transitionDuration, onClick, style, maxWidth, disablePortal, ...props }: DialogProps): import("@emotion/react/jsx-runtime").JSX.Element;
3
3
  export default Dialog;
@@ -1,8 +1,8 @@
1
1
  import { jsx as s } from "@emotion/react/jsx-runtime";
2
- import { useState as $, useRef as p, useEffect as h } from "react";
3
- import g from "@emotion/styled";
4
- import y from "../Overlay/Overlay.mjs";
5
- const x = g.div`
2
+ import { useState as p, useRef as h, useEffect as g } from "react";
3
+ import y from "@emotion/styled";
4
+ import x from "../Overlay/Overlay.mjs";
5
+ const b = y.div`
6
6
  width: calc(100% - ${({ theme: { spacing: e } }) => e[800]});
7
7
  max-width: ${({ maxWidth: e = "375px" }) => e};
8
8
  max-height: calc(100% - ${({ theme: { spacing: e } }) => e[800]});
@@ -22,7 +22,7 @@ const x = g.div`
22
22
  ${({ ease: e }) => e === "in" ? "ease-out" : "ease-in"},
23
23
  background-color 0.2s;
24
24
  `;
25
- function O({
25
+ function A({
26
26
  open: e,
27
27
  onClose: n,
28
28
  children: m,
@@ -30,12 +30,13 @@ function O({
30
30
  onClick: o,
31
31
  style: l,
32
32
  maxWidth: c = "375px",
33
- ...f
33
+ disablePortal: f,
34
+ ...u
34
35
  }) {
35
- const [r, i] = $(!1), u = p(null), d = (t) => {
36
+ const [r, i] = p(!1), d = h(null), $ = (t) => {
36
37
  t.stopPropagation(), typeof o == "function" && o(t);
37
38
  };
38
- return h(() => {
39
+ return g(() => {
39
40
  let t;
40
41
  return e ? t = requestAnimationFrame(() => {
41
42
  i(!0);
@@ -43,21 +44,22 @@ function O({
43
44
  t && cancelAnimationFrame(t);
44
45
  };
45
46
  }, [e]), /* @__PURE__ */ s(
46
- y,
47
+ x,
47
48
  {
48
- ref: u,
49
+ ref: d,
49
50
  open: e,
50
51
  onClose: n,
51
52
  transitionDuration: a,
52
53
  placement: "center-middle",
54
+ disablePortal: f,
53
55
  children: /* @__PURE__ */ s(
54
- x,
56
+ b,
55
57
  {
56
58
  ease: e ? "in" : "out",
57
59
  transitionDuration: a,
58
60
  maxWidth: c,
59
- onClick: d,
60
- ...f,
61
+ onClick: $,
62
+ ...u,
61
63
  style: {
62
64
  transform: `scale(${r ? 1 : 0.9})`,
63
65
  opacity: r ? 1 : 0,
@@ -70,5 +72,5 @@ function O({
70
72
  );
71
73
  }
72
74
  export {
73
- O as default
75
+ A as default
74
76
  };
@@ -5,4 +5,5 @@ export interface DialogProps extends ComponentPropsWithRef<"div">, Pick<UtilityP
5
5
  onClose?: () => void;
6
6
  transitionDuration?: number;
7
7
  maxWidth?: string;
8
+ disablePortal?: boolean;
8
9
  }
@@ -1,3 +1,3 @@
1
1
  import { OverlayProps } from './Overlay.typing';
2
- declare function Overlay({ children, open, onClose, transitionDuration, placement, style, ref, onClick, ...props }: OverlayProps): import('react').ReactPortal | null;
2
+ declare function Overlay({ children, open, onClose, transitionDuration, placement, style, ref, onClick, disablePortal, ...props }: OverlayProps): import("@emotion/react/jsx-runtime").JSX.Element | null;
3
3
  export default Overlay;
@@ -1,13 +1,13 @@
1
- import { jsxs as k, jsx as l } from "@emotion/react/jsx-runtime";
2
- import { useState as f, useRef as j, useImperativeHandle as x, useLayoutEffect as E, useEffect as $ } from "react";
3
- import { createPortal as I } from "react-dom";
4
- import s from "@emotion/styled";
5
- const w = s.div`
1
+ import { jsxs as p, jsx as s } from "@emotion/react/jsx-runtime";
2
+ import { useState as y, useRef as C, useImperativeHandle as I, useLayoutEffect as w, useEffect as L } from "react";
3
+ import { createPortal as A } from "react-dom";
4
+ import o from "@emotion/styled";
5
+ const g = o.div`
6
6
  position: fixed;
7
7
  top: 0;
8
8
  left: 0;
9
9
  z-index: 1;
10
- `, C = s.div`
10
+ `, h = o.div`
11
11
  position: fixed;
12
12
  top: 0;
13
13
  left: 0;
@@ -15,135 +15,149 @@ const w = s.div`
15
15
  height: 100%;
16
16
  background-color: ${({
17
17
  theme: {
18
- palette: { common: e }
18
+ palette: { common: t }
19
19
  }
20
- }) => e.overlay};
20
+ }) => t.overlay};
21
21
  transition:
22
- opacity ${({ transitionDuration: e }) => `${e}ms`}
23
- ${({ ease: e }) => e === "in" ? "ease-in" : "ease-out"},
22
+ opacity ${({ transitionDuration: t }) => `${t}ms`}
23
+ ${({ ease: t }) => t === "in" ? "ease-in" : "ease-out"},
24
24
  background-color 0.2s;
25
- `, L = s.div`
25
+ `, O = o.div`
26
26
  position: fixed;
27
27
  width: 100%;
28
28
  display: flex;
29
29
  justify-content: center;
30
30
  align-items: center;
31
31
 
32
- ${({ placement: e }) => {
33
- const t = {};
34
- switch (e) {
32
+ ${({ placement: t }) => {
33
+ const e = {};
34
+ switch (t) {
35
35
  case "top-left":
36
- Object.assign(t, {
36
+ Object.assign(e, {
37
37
  top: 0,
38
38
  left: 0
39
39
  });
40
40
  break;
41
41
  case "top-right":
42
- Object.assign(t, {
42
+ Object.assign(e, {
43
43
  top: 0,
44
44
  right: 0
45
45
  });
46
46
  break;
47
47
  case "bottom-left":
48
- Object.assign(t, {
48
+ Object.assign(e, {
49
49
  bottom: 0,
50
50
  left: 0
51
51
  });
52
52
  break;
53
53
  case "bottom-right":
54
- Object.assign(t, {
54
+ Object.assign(e, {
55
55
  bottom: 0,
56
56
  right: 0
57
57
  });
58
58
  break;
59
59
  case "center-top":
60
- Object.assign(t, {
60
+ Object.assign(e, {
61
61
  top: 0,
62
62
  left: "50%",
63
63
  transform: "translate3d(-50%, 0, 0)"
64
64
  });
65
65
  break;
66
66
  case "center-bottom":
67
- Object.assign(t, {
67
+ Object.assign(e, {
68
68
  bottom: 0,
69
69
  left: "50%",
70
70
  transform: "translate3d(-50%, 0, 0)"
71
71
  });
72
72
  break;
73
73
  case "center-middle":
74
- Object.assign(t, {
74
+ Object.assign(e, {
75
75
  top: "50%",
76
76
  left: "50%",
77
77
  transform: "translate3d(-50%, -50%, 0)"
78
78
  });
79
79
  break;
80
80
  case "center-left":
81
- Object.assign(t, {
81
+ Object.assign(e, {
82
82
  top: "50%",
83
83
  left: 0,
84
84
  transform: "translate3d(0, -50%, 0)"
85
85
  });
86
86
  break;
87
87
  case "center-right":
88
- Object.assign(t, {
88
+ Object.assign(e, {
89
89
  top: "50%",
90
90
  right: 0,
91
91
  transform: "translate3d(0, -50%, 0)"
92
92
  });
93
93
  break;
94
94
  }
95
- return t;
95
+ return e;
96
96
  }}
97
97
  `;
98
- function U({
99
- children: e,
100
- open: t,
101
- onClose: d,
98
+ function q({
99
+ children: t,
100
+ open: e,
101
+ onClose: k,
102
102
  transitionDuration: a = 200,
103
- placement: m,
104
- style: u,
105
- ref: b,
106
- onClick: p,
107
- ...g
103
+ placement: i,
104
+ style: c,
105
+ ref: v,
106
+ onClick: j,
107
+ disablePortal: x = !0,
108
+ ...l
108
109
  }) {
109
- const [y, o] = f(!0), [h, i] = f(!1), n = j(null), O = (r) => {
110
- d?.(), p?.(r);
110
+ const [E, f] = y(!0), [d, m] = y(!1), n = C(null), u = (r) => {
111
+ k?.(), j?.(r);
111
112
  };
112
- return x(b, () => n.current), E(() => {
113
+ return I(v, () => n.current), w(() => {
113
114
  let r;
114
- return t ? (o(!1), r = requestAnimationFrame(() => {
115
- i(!0);
116
- })) : i(!1), () => {
115
+ return e ? (f(!1), r = requestAnimationFrame(() => {
116
+ m(!0);
117
+ })) : m(!1), () => {
117
118
  r && cancelAnimationFrame(r);
118
119
  };
119
- }, [t, a]), $(() => {
120
- const r = n.current, c = (v) => {
121
- t || v.propertyName === "opacity" && o(!0);
120
+ }, [e, a]), L(() => {
121
+ const r = n.current, b = ($) => {
122
+ e || $.propertyName === "opacity" && f(!0);
122
123
  };
123
- return r?.addEventListener("transitionend", c), () => {
124
- r?.removeEventListener("transitionend", c);
124
+ return r?.addEventListener("transitionend", b), () => {
125
+ r?.removeEventListener("transitionend", b);
125
126
  };
126
- }, [t]), y ? null : I(
127
- /* @__PURE__ */ k(w, { children: [
128
- /* @__PURE__ */ l(
129
- C,
127
+ }, [e]), E ? null : x ? /* @__PURE__ */ p(g, { children: [
128
+ /* @__PURE__ */ s(
129
+ h,
130
+ {
131
+ ref: n,
132
+ transitionDuration: a,
133
+ ease: e ? "in" : "out",
134
+ onClick: u,
135
+ style: { opacity: d ? 1 : 0, ...c },
136
+ ...l
137
+ }
138
+ ),
139
+ /* @__PURE__ */ s(O, { placement: i, children: t })
140
+ ] }) : A(
141
+ /* @__PURE__ */ p(g, { children: [
142
+ /* @__PURE__ */ s(
143
+ h,
130
144
  {
131
145
  ref: n,
132
146
  transitionDuration: a,
133
- ease: t ? "in" : "out",
134
- onClick: O,
147
+ ease: e ? "in" : "out",
148
+ onClick: u,
135
149
  style: {
136
- opacity: h ? 1 : 0,
137
- ...u
150
+ opacity: d ? 1 : 0,
151
+ ...c
138
152
  },
139
- ...g
153
+ ...l
140
154
  }
141
155
  ),
142
- /* @__PURE__ */ l(L, { placement: m, children: e })
156
+ /* @__PURE__ */ s(O, { placement: i, children: t })
143
157
  ] }),
144
158
  document.body
145
159
  );
146
160
  }
147
161
  export {
148
- U as default
162
+ q as default
149
163
  };
@@ -6,4 +6,5 @@ export interface OverlayProps extends ComponentPropsWithRef<"div">, Pick<Utility
6
6
  transitionDuration?: number;
7
7
  placement?: "top-left" | "top-right" | "bottom-left" | "bottom-right" | "center-top" | "center-bottom" | "center-middle" | "center-left" | "center-right";
8
8
  hideOverlay?: boolean;
9
+ disablePortal?: boolean;
9
10
  }
@@ -34,6 +34,7 @@ function l() {
34
34
  color: e.primary,
35
35
  backgroundColor: o.background,
36
36
  transition: "background-color 0.3s, color 0.3s",
37
+ fontSmooth: "antialiased",
37
38
  fontFamily: `Spoqa Han Sans Neo, -apple-system, BlinkMacSystemFont, Helvetica Neue,
38
39
  Apple SD Gothic Neo, Malgun Gothic, 맑은 고딕, 나눔고딕, Nanum Gothic,
39
40
  Noto Sans KR, Noto Sans CJK KR, arial, 돋움, Dotum, Tahoma, Geneva, sans-serif`
@@ -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 e = {
4
+ const t = {
5
5
  mode: "dark",
6
6
  palette: {
7
7
  primary: {
@@ -65,9 +65,9 @@ const e = {
65
65
  dark: "#CCB77A"
66
66
  },
67
67
  error: {
68
- light: "#8C4F4F",
69
- main: "#F5A3A3",
70
- dark: "#C88585"
68
+ light: "#7F1D1D",
69
+ main: "#EF4444",
70
+ dark: "#C53030"
71
71
  },
72
72
  info: {
73
73
  light: "#446E9E",
@@ -99,5 +99,5 @@ const e = {
99
99
  radius: a
100
100
  };
101
101
  export {
102
- e as default
102
+ t as default
103
103
  };
@@ -65,9 +65,9 @@ const e = {
65
65
  dark: "#B89A4F"
66
66
  },
67
67
  error: {
68
- light: "#FBC7C7",
69
- main: "#D67C7C",
70
- dark: "#B85C5C"
68
+ light: "#FFD6D6",
69
+ main: "#DC2626",
70
+ dark: "#B91C1C"
71
71
  },
72
72
  info: {
73
73
  light: "#C7E0FA",
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.2.1",
4
+ "version": "0.2.3",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "dist"