@pylerai/design-system 2.2.0 → 2.3.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.
- package/dist/components/ui/calendar.js +155 -156
- package/dist/components/ui/checkbox.js +18 -18
- package/dist/components/ui/dropdown.js +119 -116
- package/dist/components/ui/modal.d.ts +9 -3
- package/dist/components/ui/modal.js +88 -85
- package/dist/components/ui/radio.js +16 -16
- package/dist/components/ui/table.js +86 -86
- package/dist/components/ui/tabs.js +77 -77
- package/dist/components/ui/toast.js +3 -3
- package/dist/components/ui/toggle.js +16 -16
- package/dist/components/ui/use-modal.js +41 -49
- package/dist/lib/use-dialog-a11y.js +25 -26
- package/dist/style.css +1 -1
- package/dist/tokens/pyler-light.js +20 -20
- package/package.json +14 -14
|
@@ -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
|
|
6
|
-
function
|
|
7
|
-
const e = o.useContext(
|
|
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
|
|
11
|
+
const A = o.forwardRef(
|
|
12
12
|
({
|
|
13
13
|
value: e,
|
|
14
14
|
defaultValue: t = "",
|
|
15
|
-
onValueChange:
|
|
16
|
-
variant:
|
|
17
|
-
children:
|
|
18
|
-
className:
|
|
19
|
-
},
|
|
20
|
-
const [
|
|
21
|
-
if (
|
|
22
|
-
const r = new Set(
|
|
23
|
-
return r.add(
|
|
24
|
-
}), () =>
|
|
25
|
-
if (!
|
|
26
|
-
const r = new Set(
|
|
27
|
-
return r.delete(
|
|
28
|
-
})), []), k = (
|
|
29
|
-
g || p(
|
|
30
|
-
},
|
|
31
|
-
() => ({ value:
|
|
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
|
-
[
|
|
34
|
+
[i, g, l, a, m, w, y]
|
|
35
35
|
);
|
|
36
|
-
return /* @__PURE__ */ h(
|
|
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
|
-
|
|
40
|
-
const
|
|
41
|
-
({ children: e, className: t },
|
|
42
|
-
const { variant:
|
|
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:
|
|
46
|
+
ref: l,
|
|
47
47
|
role: "tablist",
|
|
48
48
|
className: T(
|
|
49
49
|
"flex items-center",
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
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
|
-
|
|
61
|
-
const
|
|
62
|
-
({ value: e, disabled: t, children:
|
|
63
|
-
const { value: p, onValueChange: g, variant:
|
|
64
|
-
if (
|
|
65
|
-
const
|
|
66
|
-
|
|
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
|
-
|
|
70
|
-
const
|
|
71
|
-
r[
|
|
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:
|
|
76
|
+
ref: u,
|
|
77
77
|
role: "tab",
|
|
78
78
|
type: "button",
|
|
79
79
|
id: `${m}-tab-${e}`,
|
|
80
|
-
"aria-selected":
|
|
80
|
+
"aria-selected": n,
|
|
81
81
|
"aria-controls": y ? `${m}-panel-${e}` : void 0,
|
|
82
|
-
tabIndex:
|
|
82
|
+
tabIndex: n ? 0 : -1,
|
|
83
83
|
disabled: t,
|
|
84
|
-
onClick: (
|
|
85
|
-
t || g(e),
|
|
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
|
-
|
|
90
|
+
i === "underline" && [
|
|
91
91
|
"h-11 text-body-2-sb",
|
|
92
|
-
|
|
93
|
-
!
|
|
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
|
-
|
|
96
|
+
i === "box" && [
|
|
97
97
|
"h-10 px-3 rounded-ds-md text-body-3-m",
|
|
98
|
-
|
|
99
|
-
!
|
|
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
|
-
|
|
102
|
+
i === "outline" && [
|
|
103
103
|
"h-8 px-3 rounded-full text-body-4-m",
|
|
104
|
-
|
|
105
|
-
!
|
|
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
|
-
|
|
108
|
+
i === "round" && [
|
|
109
109
|
"h-7 px-2.5 rounded text-body-4-r",
|
|
110
|
-
|
|
111
|
-
!
|
|
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
|
-
|
|
114
|
+
a
|
|
115
115
|
),
|
|
116
|
-
...
|
|
117
|
-
children:
|
|
116
|
+
...b,
|
|
117
|
+
children: l
|
|
118
118
|
}
|
|
119
119
|
);
|
|
120
120
|
}
|
|
121
121
|
);
|
|
122
|
-
|
|
123
|
-
const
|
|
124
|
-
({ value: e, children: t, className:
|
|
125
|
-
const { value:
|
|
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 (
|
|
128
|
-
return
|
|
129
|
-
}, [
|
|
127
|
+
if (u)
|
|
128
|
+
return b(e);
|
|
129
|
+
}, [u, e, b]), u ? /* @__PURE__ */ h(
|
|
130
130
|
"div",
|
|
131
131
|
{
|
|
132
|
-
ref:
|
|
132
|
+
ref: a,
|
|
133
133
|
role: "tabpanel",
|
|
134
|
-
id: `${
|
|
135
|
-
"aria-labelledby": `${
|
|
134
|
+
id: `${x}-panel-${e}`,
|
|
135
|
+
"aria-labelledby": `${x}-tab-${e}`,
|
|
136
136
|
tabIndex: 0,
|
|
137
|
-
className: T("mt-4",
|
|
137
|
+
className: T("mt-4", l),
|
|
138
138
|
children: t
|
|
139
139
|
}
|
|
140
140
|
) : null;
|
|
141
141
|
}
|
|
142
142
|
);
|
|
143
|
-
|
|
143
|
+
S.displayName = "TabsContent";
|
|
144
144
|
export {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
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 {
|
|
3
|
-
import { CautionIcon as a, NegativeIcon as m, PositiveIcon as d
|
|
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 {
|
|
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
|
|
3
|
-
import { cn as
|
|
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:
|
|
7
|
-
const m =
|
|
8
|
-
return /* @__PURE__ */
|
|
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:
|
|
11
|
+
ref: i,
|
|
12
12
|
type: "button",
|
|
13
13
|
role: "switch",
|
|
14
|
-
"aria-checked":
|
|
15
|
-
disabled:
|
|
16
|
-
onClick: () => !
|
|
17
|
-
className:
|
|
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
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
r && !o ? "bg-ds-surface-normal" : "bg-ds-background-default",
|
|
20
|
+
r ? "cursor-not-allowed" : "cursor-pointer",
|
|
21
|
+
s
|
|
22
22
|
),
|
|
23
|
-
...
|
|
24
|
-
children: /* @__PURE__ */
|
|
23
|
+
...e,
|
|
24
|
+
children: /* @__PURE__ */ t(
|
|
25
25
|
"span",
|
|
26
26
|
{
|
|
27
|
-
className:
|
|
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
|
|
3
|
-
import * as
|
|
4
|
-
import { InformationModal as
|
|
5
|
-
const
|
|
6
|
-
let
|
|
7
|
-
function
|
|
8
|
-
return `modal-${++
|
|
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
|
|
11
|
-
const [
|
|
12
|
-
s((
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
});
|
|
16
|
-
}, []),
|
|
17
|
-
const
|
|
18
|
-
s((
|
|
19
|
-
}), []),
|
|
20
|
-
const
|
|
21
|
-
s((
|
|
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
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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
|
-
|
|
37
|
-
(n = e.onConfirm) == null || n.call(e), i(e.id, !0);
|
|
33
|
+
e.onConfirm?.(), n(e.id, !0);
|
|
38
34
|
},
|
|
39
|
-
onClose: () =>
|
|
35
|
+
onClose: () => n(e.id, !1)
|
|
40
36
|
},
|
|
41
37
|
e.id
|
|
42
|
-
) : e.type === "action" ? /* @__PURE__ */
|
|
43
|
-
|
|
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
|
-
|
|
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
|
-
|
|
56
|
-
(n = e.onConfirm) == null || n.call(e), i(e.id, !0);
|
|
50
|
+
e.onConfirm?.(), n(e.id, !0);
|
|
57
51
|
},
|
|
58
|
-
onClose: () =>
|
|
52
|
+
onClose: () => n(e.id, !1)
|
|
59
53
|
},
|
|
60
54
|
e.id
|
|
61
|
-
) : /* @__PURE__ */
|
|
62
|
-
|
|
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
|
-
|
|
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
|
-
|
|
76
|
-
(n = e.onConfirm) == null || n.call(e), i(e.id, !0);
|
|
68
|
+
e.onConfirm?.(), n(e.id, !0);
|
|
77
69
|
},
|
|
78
|
-
onClose: () =>
|
|
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
|
|
86
|
-
const
|
|
87
|
-
if (!
|
|
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
|
|
81
|
+
return c;
|
|
90
82
|
}
|
|
91
83
|
export {
|
|
92
|
-
|
|
93
|
-
|
|
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
|
|
3
|
+
const p = [
|
|
4
4
|
"a[href]",
|
|
5
5
|
"button",
|
|
6
6
|
"input",
|
|
7
7
|
"select",
|
|
8
8
|
"textarea",
|
|
9
9
|
"[tabindex]"
|
|
10
|
-
].join(","),
|
|
11
|
-
let
|
|
12
|
-
function
|
|
13
|
-
return Array.from(
|
|
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
|
|
19
|
-
const
|
|
20
|
-
return
|
|
21
|
-
const t =
|
|
22
|
-
if (!
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
const
|
|
26
|
-
if (
|
|
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(),
|
|
28
|
+
e.preventDefault(), i.current();
|
|
29
29
|
return;
|
|
30
30
|
}
|
|
31
31
|
if (e.key !== "Tab") return;
|
|
32
|
-
const
|
|
33
|
-
if (
|
|
32
|
+
const u = m(t);
|
|
33
|
+
if (u.length === 0) {
|
|
34
34
|
e.preventDefault(), t.focus();
|
|
35
35
|
return;
|
|
36
36
|
}
|
|
37
|
-
const
|
|
38
|
-
e.shiftKey && (
|
|
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",
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
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
|
-
}, [
|
|
45
|
+
}, [r]), f;
|
|
47
46
|
}
|
|
48
47
|
export {
|
|
49
|
-
|
|
48
|
+
g as useDialogA11y
|
|
50
49
|
};
|