@pylerai/design-system 2.2.1 → 2.3.1-rc.0

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.
@@ -2,54 +2,54 @@
2
2
  import { jsx as h } from "react/jsx-runtime";
3
3
  import { cn as T } from "../../lib/utils.js";
4
4
  import * as o from "react";
5
- const A = o.createContext(null);
6
- function I() {
7
- const e = o.useContext(A);
5
+ const $ = o.createContext(null);
6
+ function C() {
7
+ const e = o.useContext($);
8
8
  if (!e) throw new Error("TabsTrigger must be used within Tabs");
9
9
  return e;
10
10
  }
11
- const R = o.forwardRef(
11
+ const A = o.forwardRef(
12
12
  ({
13
13
  value: e,
14
14
  defaultValue: t = "",
15
- onValueChange: d,
16
- variant: l = "underline",
17
- children: i,
18
- className: c
19
- }, f) => {
20
- const [x, p] = o.useState(t), g = e !== void 0, b = g ? e : x, m = o.useId(), [w, s] = o.useState(() => /* @__PURE__ */ new Set()), y = o.useCallback((u) => (s((a) => {
21
- if (a.has(u)) return a;
22
- const r = new Set(a);
23
- return r.add(u), r;
24
- }), () => s((a) => {
25
- if (!a.has(u)) return a;
26
- const r = new Set(a);
27
- return r.delete(u), r;
28
- })), []), k = (u) => {
29
- g || p(u), d == null || d(u);
30
- }, n = o.useMemo(
31
- () => ({ value: b, onValueChange: k, variant: l, baseId: m, panels: w, registerPanel: y }),
15
+ onValueChange: l,
16
+ variant: a = "underline",
17
+ children: f,
18
+ className: x
19
+ }, b) => {
20
+ const [u, p] = o.useState(t), g = e !== void 0, i = g ? e : u, m = o.useId(), [w, n] = o.useState(() => /* @__PURE__ */ new Set()), y = o.useCallback((c) => (n((d) => {
21
+ if (d.has(c)) return d;
22
+ const r = new Set(d);
23
+ return r.add(c), r;
24
+ }), () => n((d) => {
25
+ if (!d.has(c)) return d;
26
+ const r = new Set(d);
27
+ return r.delete(c), r;
28
+ })), []), k = (c) => {
29
+ g || p(c), l?.(c);
30
+ }, s = o.useMemo(
31
+ () => ({ value: i, onValueChange: k, variant: a, baseId: m, panels: w, registerPanel: y }),
32
32
  // handleChange 는 렌더마다 새로 만들어지지만 참조하는 값이 아래 의존성에 모두 들어 있다
33
33
  // eslint-disable-next-line react-hooks/exhaustive-deps
34
- [b, g, d, l, m, w, y]
34
+ [i, g, l, a, m, w, y]
35
35
  );
36
- return /* @__PURE__ */ h(A.Provider, { value: n, children: /* @__PURE__ */ h("div", { ref: f, className: T("flex flex-col", c), children: i }) });
36
+ return /* @__PURE__ */ h($.Provider, { value: s, children: /* @__PURE__ */ h("div", { ref: b, className: T("flex flex-col", x), children: f }) });
37
37
  }
38
38
  );
39
- R.displayName = "Tabs";
40
- const P = o.forwardRef(
41
- ({ children: e, className: t }, d) => {
42
- const { variant: l } = I();
39
+ A.displayName = "Tabs";
40
+ const R = o.forwardRef(
41
+ ({ children: e, className: t }, l) => {
42
+ const { variant: a } = C();
43
43
  return /* @__PURE__ */ h(
44
44
  "div",
45
45
  {
46
- ref: d,
46
+ ref: l,
47
47
  role: "tablist",
48
48
  className: T(
49
49
  "flex items-center",
50
- l === "underline" && "gap-5",
51
- l === "outline" && "gap-1",
52
- l === "round" && "bg-ds-surface-strong p-1 rounded-ds-md",
50
+ a === "underline" && "gap-5",
51
+ a === "outline" && "gap-1",
52
+ a === "round" && "bg-ds-surface-strong p-1 rounded-ds-md",
53
53
  t
54
54
  ),
55
55
  children: e
@@ -57,93 +57,93 @@ const P = o.forwardRef(
57
57
  );
58
58
  }
59
59
  );
60
- P.displayName = "TabsList";
61
- const S = o.forwardRef(
62
- ({ value: e, disabled: t, children: d, className: l, onClick: i, onKeyDown: c, ...f }, x) => {
63
- const { value: p, onValueChange: g, variant: b, baseId: m, panels: w } = I(), s = p === e, y = w.has(e), k = (n) => {
64
- if (c == null || c(n), n.defaultPrevented || !["ArrowRight", "ArrowLeft", "Home", "End"].includes(n.key)) return;
65
- const a = n.currentTarget.closest('[role="tablist"]'), r = Array.from(
66
- (a == null ? void 0 : a.querySelectorAll('[role="tab"]:not([disabled])')) ?? []
60
+ R.displayName = "TabsList";
61
+ const P = o.forwardRef(
62
+ ({ value: e, disabled: t, children: l, className: a, onClick: f, onKeyDown: x, ...b }, u) => {
63
+ const { value: p, onValueChange: g, variant: i, baseId: m, panels: w } = C(), n = p === e, y = w.has(e), k = (s) => {
64
+ if (x?.(s), s.defaultPrevented || !["ArrowRight", "ArrowLeft", "Home", "End"].includes(s.key)) return;
65
+ const d = s.currentTarget.closest('[role="tablist"]'), r = Array.from(
66
+ d?.querySelectorAll('[role="tab"]:not([disabled])') ?? []
67
67
  );
68
68
  if (r.length === 0) return;
69
- n.preventDefault();
70
- const N = r.indexOf(n.currentTarget), $ = n.key === "Home" ? 0 : n.key === "End" ? r.length - 1 : n.key === "ArrowRight" ? (N + 1 + r.length) % r.length : (N - 1 + r.length) % r.length;
71
- r[$].focus(), r[$].click();
69
+ s.preventDefault();
70
+ const I = r.indexOf(s.currentTarget), N = s.key === "Home" ? 0 : s.key === "End" ? r.length - 1 : s.key === "ArrowRight" ? (I + 1 + r.length) % r.length : (I - 1 + r.length) % r.length;
71
+ r[N].focus(), r[N].click();
72
72
  };
73
73
  return /* @__PURE__ */ h(
74
74
  "button",
75
75
  {
76
- ref: x,
76
+ ref: u,
77
77
  role: "tab",
78
78
  type: "button",
79
79
  id: `${m}-tab-${e}`,
80
- "aria-selected": s,
80
+ "aria-selected": n,
81
81
  "aria-controls": y ? `${m}-panel-${e}` : void 0,
82
- tabIndex: s ? 0 : -1,
82
+ tabIndex: n ? 0 : -1,
83
83
  disabled: t,
84
- onClick: (n) => {
85
- t || g(e), i == null || i(n);
84
+ onClick: (s) => {
85
+ t || g(e), f?.(s);
86
86
  },
87
87
  onKeyDown: k,
88
88
  className: T(
89
89
  "inline-flex items-center justify-center whitespace-nowrap shrink-0 transition-colors focus-visible:outline-none",
90
- b === "underline" && [
90
+ i === "underline" && [
91
91
  "h-11 text-body-2-sb",
92
- s && !t && "border-b-2 border-ds-text-strong text-ds-text-strong",
93
- !s && !t && "text-ds-text-normal",
92
+ n && !t && "border-b-2 border-ds-text-strong text-ds-text-strong",
93
+ !n && !t && "text-ds-text-normal",
94
94
  t && "text-ds-text-disabled cursor-not-allowed"
95
95
  ],
96
- b === "box" && [
96
+ i === "box" && [
97
97
  "h-10 px-3 rounded-ds-md text-body-3-m",
98
- s && !t && "bg-ds-surface-normal text-ds-text-strong",
99
- !s && !t && "bg-ds-background-default text-ds-text-normal",
98
+ n && !t && "bg-ds-surface-normal text-ds-text-strong",
99
+ !n && !t && "bg-ds-background-default text-ds-text-normal",
100
100
  t && "bg-ds-background-default text-ds-text-disabled cursor-not-allowed"
101
101
  ],
102
- b === "outline" && [
102
+ i === "outline" && [
103
103
  "h-8 px-3 rounded-full text-body-4-m",
104
- s && !t && "bg-ds-surface-normal text-ds-text-strong",
105
- !s && !t && "bg-ds-background-default border border-ds-line-normal text-ds-text-normal",
104
+ n && !t && "bg-ds-surface-normal text-ds-text-strong",
105
+ !n && !t && "bg-ds-background-default border border-ds-line-normal text-ds-text-normal",
106
106
  t && "bg-ds-background-default border border-ds-line-normal text-ds-text-disabled cursor-not-allowed"
107
107
  ],
108
- b === "round" && [
108
+ i === "round" && [
109
109
  "h-7 px-2.5 rounded text-body-4-r",
110
- s && !t && "bg-ds-surface-alternative text-ds-text-strong",
111
- !s && !t && "bg-ds-surface-strong text-ds-text-normal",
110
+ n && !t && "bg-ds-surface-alternative text-ds-text-strong",
111
+ !n && !t && "bg-ds-surface-strong text-ds-text-normal",
112
112
  t && "bg-ds-surface-strong text-ds-text-disabled cursor-not-allowed"
113
113
  ],
114
- l
114
+ a
115
115
  ),
116
- ...f,
117
- children: d
116
+ ...b,
117
+ children: l
118
118
  }
119
119
  );
120
120
  }
121
121
  );
122
- S.displayName = "TabsTrigger";
123
- const E = o.forwardRef(
124
- ({ value: e, children: t, className: d }, l) => {
125
- const { value: i, baseId: c, registerPanel: f } = I(), x = i === e;
122
+ P.displayName = "TabsTrigger";
123
+ const S = o.forwardRef(
124
+ ({ value: e, children: t, className: l }, a) => {
125
+ const { value: f, baseId: x, registerPanel: b } = C(), u = f === e;
126
126
  return o.useEffect(() => {
127
- if (x)
128
- return f(e);
129
- }, [x, e, f]), x ? /* @__PURE__ */ h(
127
+ if (u)
128
+ return b(e);
129
+ }, [u, e, b]), u ? /* @__PURE__ */ h(
130
130
  "div",
131
131
  {
132
- ref: l,
132
+ ref: a,
133
133
  role: "tabpanel",
134
- id: `${c}-panel-${e}`,
135
- "aria-labelledby": `${c}-tab-${e}`,
134
+ id: `${x}-panel-${e}`,
135
+ "aria-labelledby": `${x}-tab-${e}`,
136
136
  tabIndex: 0,
137
- className: T("mt-4", d),
137
+ className: T("mt-4", l),
138
138
  children: t
139
139
  }
140
140
  ) : null;
141
141
  }
142
142
  );
143
- E.displayName = "TabsContent";
143
+ S.displayName = "TabsContent";
144
144
  export {
145
- R as Tabs,
146
- E as TabsContent,
147
- P as TabsList,
148
- S as TabsTrigger
145
+ A as Tabs,
146
+ S as TabsContent,
147
+ R as TabsList,
148
+ P as TabsTrigger
149
149
  };
@@ -1,8 +1,8 @@
1
1
  "use client";
2
- import { jsx as e, jsxs as i } from "react/jsx-runtime";
3
- import { CautionIcon as a, NegativeIcon as m, PositiveIcon as d, ChevronRightIcon as l } from "../../lib/icons.js";
2
+ import { jsxs as i, jsx as e } from "react/jsx-runtime";
3
+ import { ChevronRightIcon as l, CautionIcon as a, NegativeIcon as m, PositiveIcon as d } from "../../lib/icons.js";
4
4
  import { cn as u } from "../../lib/utils.js";
5
- import { toast as s, Toaster as p } from "sonner";
5
+ import { Toaster as p, toast as s } from "sonner";
6
6
  function c({ icon: t, message: o }) {
7
7
  return /* @__PURE__ */ i("div", { className: "bg-ds-primitive-black flex items-center gap-1.5 p-3 rounded-ds-md w-[336px]", children: [
8
8
  t,
@@ -1,30 +1,30 @@
1
1
  "use client";
2
- import { jsx as n } from "react/jsx-runtime";
3
- import { cn as s } from "../../lib/utils.js";
2
+ import { jsx as t } from "react/jsx-runtime";
3
+ import { cn as l } from "../../lib/utils.js";
4
4
  import * as p from "react";
5
5
  const b = p.forwardRef(
6
- ({ checked: r, neutral: l, disabled: o, onChange: t, className: i, ...a }, e) => {
7
- const m = l ? "left-[11px]" : r ? "left-[17px]" : "left-[3px]", u = o ? r ? "bg-ds-primary-blue-disabled" : "bg-ds-line-normal" : r ? "bg-ds-primary-blue-normal" : "bg-ds-line-normal";
8
- return /* @__PURE__ */ n(
6
+ ({ checked: o, neutral: n, disabled: r, onChange: a, className: s, ...e }, i) => {
7
+ const m = n ? "left-[11px]" : o ? "left-[17px]" : "left-[3px]", u = r ? o ? "bg-ds-primary-blue-disabled" : "bg-ds-line-normal" : o ? "bg-ds-primary-blue-normal" : "bg-ds-line-normal";
8
+ return /* @__PURE__ */ t(
9
9
  "button",
10
10
  {
11
- ref: e,
11
+ ref: i,
12
12
  type: "button",
13
13
  role: "switch",
14
- "aria-checked": l ? "mixed" : r,
15
- disabled: o,
16
- onClick: () => !o && (t == null ? void 0 : t(!r)),
17
- className: s(
14
+ "aria-checked": n ? "mixed" : o,
15
+ disabled: r,
16
+ onClick: () => !r && a?.(!o),
17
+ className: l(
18
18
  "relative inline-flex h-6 w-10 shrink-0 rounded-full border border-ds-line-normal transition-colors",
19
- o && !r ? "bg-ds-surface-normal" : "bg-ds-background-default",
20
- o ? "cursor-not-allowed" : "cursor-pointer",
21
- i
19
+ r && !o ? "bg-ds-surface-normal" : "bg-ds-background-default",
20
+ r ? "cursor-not-allowed" : "cursor-pointer",
21
+ s
22
22
  ),
23
- ...a,
24
- children: /* @__PURE__ */ n(
23
+ ...e,
24
+ children: /* @__PURE__ */ t(
25
25
  "span",
26
26
  {
27
- className: s(
27
+ className: l(
28
28
  "absolute top-1/2 -translate-y-1/2 h-[18px] w-[18px] rounded-full transition-all duration-200",
29
29
  m,
30
30
  u
@@ -1,46 +1,42 @@
1
1
  "use client";
2
- import { jsxs as a, jsx as f } from "react/jsx-runtime";
3
- import * as c from "react";
4
- import { InformationModal as x, ActionModal as w, ContentModal as P } from "./modal.js";
5
- const p = c.createContext(null);
6
- let h = 0;
7
- function C() {
8
- return `modal-${++h}`;
2
+ import { jsxs as M, jsx as u } from "react/jsx-runtime";
3
+ import * as r from "react";
4
+ import { InformationModal as L, ActionModal as x, ContentModal as y } from "./modal.js";
5
+ const a = r.createContext(null);
6
+ let w = 0;
7
+ function f() {
8
+ return `modal-${++w}`;
9
9
  }
10
- function y({ children: o }) {
11
- const [b, s] = c.useState([]), i = c.useCallback((e, n) => {
12
- s((r) => {
13
- const t = r.find((u) => u.id === e);
14
- return t == null || t.resolve(n), r.filter((u) => u.id !== e);
15
- });
16
- }, []), l = c.useCallback((e) => new Promise((n) => {
17
- const r = C();
18
- s((t) => [...t, { ...e, id: r, type: "information", resolve: n }]);
19
- }), []), M = c.useCallback((e) => new Promise((n) => {
20
- const r = C();
21
- s((t) => [...t, { ...e, id: r, type: "action", resolve: n }]);
22
- }), []), L = c.useCallback((e) => new Promise((n) => {
23
- const r = C();
24
- s((t) => [...t, { ...e, id: r, type: "content", resolve: n }]);
10
+ function k({ children: c }) {
11
+ const [C, s] = r.useState([]), n = r.useCallback((e, i) => {
12
+ s((t) => (t.find((l) => l.id === e)?.resolve(i), t.filter((l) => l.id !== e)));
13
+ }, []), p = r.useCallback((e) => new Promise((i) => {
14
+ const t = f();
15
+ s((o) => [...o, { ...e, id: t, type: "information", resolve: i }]);
16
+ }), []), b = r.useCallback((e) => new Promise((i) => {
17
+ const t = f();
18
+ s((o) => [...o, { ...e, id: t, type: "action", resolve: i }]);
19
+ }), []), d = r.useCallback((e) => new Promise((i) => {
20
+ const t = f();
21
+ s((o) => [...o, { ...e, id: t, type: "content", resolve: i }]);
25
22
  }), []);
26
- return /* @__PURE__ */ a(p.Provider, { value: { openInformationModal: l, openActionModal: M, openContentModal: L }, children: [
27
- o,
28
- b.map((e) => e.type === "information" ? /* @__PURE__ */ f(
29
- x,
23
+ return /* @__PURE__ */ M(a.Provider, { value: { openInformationModal: p, openActionModal: b, openContentModal: d }, children: [
24
+ c,
25
+ C.map((e) => e.type === "information" ? /* @__PURE__ */ u(
26
+ L,
30
27
  {
31
28
  open: !0,
32
29
  title: e.title,
33
30
  description: e.description,
34
31
  confirmLabel: e.confirmLabel,
35
32
  onConfirm: () => {
36
- var n;
37
- (n = e.onConfirm) == null || n.call(e), i(e.id, !0);
33
+ e.onConfirm?.(), n(e.id, !0);
38
34
  },
39
- onClose: () => i(e.id, !1)
35
+ onClose: () => n(e.id, !1)
40
36
  },
41
37
  e.id
42
- ) : e.type === "action" ? /* @__PURE__ */ f(
43
- w,
38
+ ) : e.type === "action" ? /* @__PURE__ */ u(
39
+ x,
44
40
  {
45
41
  open: !0,
46
42
  title: e.title,
@@ -48,18 +44,16 @@ function y({ children: o }) {
48
44
  cancelLabel: e.cancelLabel,
49
45
  confirmLabel: e.confirmLabel,
50
46
  onCancel: () => {
51
- var n;
52
- (n = e.onCancel) == null || n.call(e), i(e.id, !1);
47
+ e.onCancel?.(), n(e.id, !1);
53
48
  },
54
49
  onConfirm: () => {
55
- var n;
56
- (n = e.onConfirm) == null || n.call(e), i(e.id, !0);
50
+ e.onConfirm?.(), n(e.id, !0);
57
51
  },
58
- onClose: () => i(e.id, !1)
52
+ onClose: () => n(e.id, !1)
59
53
  },
60
54
  e.id
61
- ) : /* @__PURE__ */ f(
62
- P,
55
+ ) : /* @__PURE__ */ u(
56
+ y,
63
57
  {
64
58
  open: !0,
65
59
  title: e.title,
@@ -68,27 +62,25 @@ function y({ children: o }) {
68
62
  cancelLabel: e.cancelLabel,
69
63
  confirmLabel: e.confirmLabel,
70
64
  onCancel: () => {
71
- var n;
72
- (n = e.onCancel) == null || n.call(e), i(e.id, !1);
65
+ e.onCancel?.(), n(e.id, !1);
73
66
  },
74
67
  onConfirm: () => {
75
- var n;
76
- (n = e.onConfirm) == null || n.call(e), i(e.id, !0);
68
+ e.onConfirm?.(), n(e.id, !0);
77
69
  },
78
- onClose: () => i(e.id, !1),
70
+ onClose: () => n(e.id, !1),
79
71
  children: e.content
80
72
  },
81
73
  e.id
82
74
  ))
83
75
  ] });
84
76
  }
85
- function I() {
86
- const o = c.useContext(p);
87
- if (!o)
77
+ function v() {
78
+ const c = r.useContext(a);
79
+ if (!c)
88
80
  throw new Error("useModal must be used within a ModalProvider");
89
- return o;
81
+ return c;
90
82
  }
91
83
  export {
92
- y as ModalProvider,
93
- I as useModal
84
+ k as ModalProvider,
85
+ v as useModal
94
86
  };
@@ -1,50 +1,49 @@
1
1
  "use client";
2
2
  import * as l from "react";
3
- const g = [
3
+ const p = [
4
4
  "a[href]",
5
5
  "button",
6
6
  "input",
7
7
  "select",
8
8
  "textarea",
9
9
  "[tabindex]"
10
- ].join(","), r = [];
11
- let c = null;
12
- function b(f) {
13
- return Array.from(f.querySelectorAll(g)).filter(
10
+ ].join(","), o = [];
11
+ let s = null;
12
+ function m(r) {
13
+ return Array.from(r.querySelectorAll(p)).filter(
14
14
  (n) => !n.hasAttribute("disabled") && n.getAttribute("aria-hidden") !== "true" && n.tabIndex !== -1 && // 화면에 실제로 그려진 요소만 (display:none, .sr-only 등 제외)
15
15
  n.offsetParent !== null
16
16
  );
17
17
  }
18
- function E(f, n) {
19
- const i = l.useRef(null), a = l.useRef(n);
20
- return a.current = n, l.useEffect(() => {
21
- const t = i.current;
22
- if (!f || !t) return;
23
- const u = document.activeElement;
24
- r.push(t), r.length === 1 && (c = document.body.style.overflow, document.body.style.overflow = "hidden"), (b(t)[0] ?? t).focus();
25
- const d = (e) => {
26
- if (r[r.length - 1] !== t) return;
18
+ function g(r, n) {
19
+ const f = l.useRef(null), i = l.useRef(n);
20
+ return i.current = n, l.useEffect(() => {
21
+ const t = f.current;
22
+ if (!r || !t) return;
23
+ const b = document.activeElement;
24
+ o.push(t), o.length === 1 && (s = document.body.style.overflow, document.body.style.overflow = "hidden"), (m(t)[0] ?? t).focus();
25
+ const a = (e) => {
26
+ if (o[o.length - 1] !== t) return;
27
27
  if (e.key === "Escape") {
28
- e.preventDefault(), a.current();
28
+ e.preventDefault(), i.current();
29
29
  return;
30
30
  }
31
31
  if (e.key !== "Tab") return;
32
- const o = b(t);
33
- if (o.length === 0) {
32
+ const u = m(t);
33
+ if (u.length === 0) {
34
34
  e.preventDefault(), t.focus();
35
35
  return;
36
36
  }
37
- const y = o[0], h = o[o.length - 1], s = document.activeElement, m = !t.contains(s);
38
- e.shiftKey && (s === y || m) ? (e.preventDefault(), h.focus()) : !e.shiftKey && (s === h || m) && (e.preventDefault(), y.focus());
37
+ const d = u[0], y = u[u.length - 1], c = document.activeElement, h = !t.contains(c);
38
+ e.shiftKey && (c === d || h) ? (e.preventDefault(), y.focus()) : !e.shiftKey && (c === y || h) && (e.preventDefault(), d.focus());
39
39
  };
40
- return document.addEventListener("keydown", d), () => {
41
- var o;
42
- document.removeEventListener("keydown", d);
43
- const e = r.indexOf(t);
44
- e !== -1 && r.splice(e, 1), r.length === 0 && c !== null && (document.body.style.overflow = c, c = null), (o = u == null ? void 0 : u.focus) == null || o.call(u);
40
+ return document.addEventListener("keydown", a), () => {
41
+ document.removeEventListener("keydown", a);
42
+ const e = o.indexOf(t);
43
+ e !== -1 && o.splice(e, 1), o.length === 0 && s !== null && (document.body.style.overflow = s, s = null), b?.focus?.();
45
44
  };
46
- }, [f]), i;
45
+ }, [r]), f;
47
46
  }
48
47
  export {
49
- E as useDialogA11y
48
+ g as useDialogA11y
50
49
  };