motile-ui 1.3.1 โ 1.5.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/README.md +4 -0
- package/dist/components/Drawer/Drawer.js +3 -1
- package/dist/components/Input/Input.d.ts +6 -0
- package/dist/components/Input/Input.js +48 -44
- package/dist/components/Modal/Modal.d.ts +13 -0
- package/dist/components/Modal/Modal.js +109 -99
- package/dist/components/Popover/Popover.js +23 -19
- package/dist/components/Select/Select.js +61 -59
- package/dist/components/Sheet/Sheet.js +3 -1
- package/dist/components/SpeedDial/SpeedDial.js +38 -36
- package/dist/components/Textarea/Textarea.d.ts +6 -0
- package/dist/components/Textarea/Textarea.js +44 -40
- package/dist/hooks/index.d.ts +2 -0
- package/dist/hooks/index.js +10 -8
- package/dist/hooks/useAutoBlur.d.ts +45 -0
- package/dist/hooks/useAutoBlur.js +32 -0
- package/dist/hooks/useEscapeKey.d.ts +15 -1
- package/dist/hooks/useEscapeKey.js +27 -12
- package/dist/hooks/useHistoryClose.js +89 -48
- package/dist/hooks/useScrollLock.js +42 -24
- package/package.json +1 -1
- package/dist/components/Accordion/Accordion.test.d.ts +0 -1
- package/dist/components/Badge/Badge.test.d.ts +0 -1
- package/dist/components/Button/Button.test.d.ts +0 -1
- package/dist/components/Checkbox/Checkbox.test.d.ts +0 -1
- package/dist/components/Dock/Dock.test.d.ts +0 -1
- package/dist/components/Drawer/Drawer.test.d.ts +0 -1
- package/dist/components/Input/Input.test.d.ts +0 -1
- package/dist/components/Modal/Modal.test.d.ts +0 -1
- package/dist/components/NumberFlow/NumberFlow.test.d.ts +0 -1
- package/dist/components/Popover/Popover.test.d.ts +0 -1
- package/dist/components/Select/Select.test.d.ts +0 -1
- package/dist/components/Sheet/Sheet.test.d.ts +0 -1
- package/dist/components/Skeleton/Skeleton.test.d.ts +0 -1
- package/dist/components/SpeedDial/SpeedDial.test.d.ts +0 -1
- package/dist/components/Switch/Switch.test.d.ts +0 -1
- package/dist/components/Tab/Tab.test.d.ts +0 -1
- package/dist/components/Textarea/Textarea.test.d.ts +0 -1
- package/dist/components/TimePicker/TimePicker.test.d.ts +0 -1
- package/dist/components/Toast/Toast.test.d.ts +0 -1
- package/dist/components/Tooltip/Tooltip.test.d.ts +0 -1
- package/dist/test/setup.d.ts +0 -1
- package/dist/test/utils.d.ts +0 -22
package/README.md
CHANGED
|
@@ -43,6 +43,8 @@
|
|
|
43
43
|
- ๐ฑ **๋ชจ๋ฐ์ผ ์ต์ ํ** - ํฐ์น ์นํ์ ์ธํฐ๋์
๊ณผ ๋ฐ์ํ ๋์์ธ
|
|
44
44
|
- โฟ **์ ๊ทผ์ฑ** - WCAG 2.1 AA ์ค์ ์ปดํฌ๋ํธ
|
|
45
45
|
- ๐ฏ **ํธ๋ฆฌ์์ดํน ์ง์** - ํ์ํ ๊ฒ๋ง import
|
|
46
|
+
- ๐ง
**์ค์ฒฉ ์ค๋ฒ๋ ์ด ์์ ** - Sheet ์ Sheet์ฒ๋ผ ์ค๋ฒ๋ ์ด๊ฐ ๊ฒน์ณ๋ ๋ค๋ก๊ฐ๊ธฐยทESCยท์คํฌ๋กค ์ ๊ธ์ด ํ ๊ฒน์ฉ ์ ํํ ๋์
|
|
47
|
+
- โจ๏ธ **์คํฌ๋กค ์ ํค๋ณด๋ ๋ซ๊ธฐ** - ๋ชจ๋ฐ์ผ์์ ์
๋ ฅ์ ํฌ์ปค์คํ ์ฑ ์คํฌ๋กคํ๋ฉด ์ํํธ ํค๋ณด๋๋ฅผ ์๋์ผ๋ก ๋ซ์ (useAutoBlur ํ
ยท autoBlur prop)
|
|
46
48
|
- ๐ **ํ๋ถํ ๋ฌธ์** - Storybook์ ํตํ ๋ผ์ด๋ธ ์์ ์ ๊ณต
|
|
47
49
|
|
|
48
50
|
---
|
|
@@ -234,6 +236,8 @@ MIT ยฉ [Innopers](https://github.com/Innopers)
|
|
|
234
236
|
- ๐ฑ **Mobile Optimized** - Touch-friendly interactions and responsive design
|
|
235
237
|
- โฟ **Accessible** - WCAG 2.1 AA compliant components
|
|
236
238
|
- ๐ฏ **Tree-shakeable** - Import only what you need
|
|
239
|
+
- ๐ง
**Nesting-Safe Overlays** - Back navigation, ESC, and scroll lock peel one layer at a time when overlays stack (e.g. Sheet over Sheet)
|
|
240
|
+
- โจ๏ธ **Dismiss Keyboard on Scroll** - On mobile, scrolling with an input focused auto-dismisses the soft keyboard (useAutoBlur hook ยท autoBlur prop)
|
|
237
241
|
- ๐ **Well Documented** - Comprehensive docs with live examples via Storybook
|
|
238
242
|
|
|
239
243
|
---
|
|
@@ -60,7 +60,9 @@ const $ = G(null), f = () => {
|
|
|
60
60
|
enabled: D && S.clickOutside
|
|
61
61
|
}), Z({
|
|
62
62
|
handler: p,
|
|
63
|
-
enabled: D && S.escapeKey
|
|
63
|
+
enabled: D && S.escapeKey,
|
|
64
|
+
stacked: !0
|
|
65
|
+
// ์ค์ฒฉ ์ค๋ฒ๋ ์ด์์ ESC๋ ์ต์๋จ๋ง ๋ซ๋๋ค
|
|
64
66
|
});
|
|
65
67
|
const j = {
|
|
66
68
|
open: x,
|
|
@@ -56,6 +56,12 @@ export interface InputProps extends React.InputHTMLAttributes<HTMLInputElement>
|
|
|
56
56
|
* Floating label (focus ์ ์๋ placeholder ์์น, focus/๊ฐ ์์ ๋ ์๋ก ์ด๋)
|
|
57
57
|
*/
|
|
58
58
|
label?: string;
|
|
59
|
+
/**
|
|
60
|
+
* ๋ชจ๋ฐ์ผ์์ ์ด ์
๋ ฅ์ ํฌ์ปค์ค๋ ์ฑ ์คํฌ๋กคํ๋ฉด ํฌ์ปค์ค๋ฅผ ํด์ ํด ์ํํธ ํค๋ณด๋๋ฅผ
|
|
61
|
+
* ๋ซ์ต๋๋ค (useAutoBlur ๋ด์ฅ). ๋ฐ์คํฌํฑ(๋นํฐ์น)์๋ ์ํฅ์ด ์์ต๋๋ค.
|
|
62
|
+
* @default false
|
|
63
|
+
*/
|
|
64
|
+
autoBlur?: boolean;
|
|
59
65
|
}
|
|
60
66
|
export declare const Input: React.ForwardRefExoticComponent<InputProps & React.RefAttributes<HTMLInputElement>>;
|
|
61
67
|
export {};
|
|
@@ -1,78 +1,82 @@
|
|
|
1
1
|
import { jsxs as a, jsx as t } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef as
|
|
2
|
+
import { forwardRef as H, useId as J, useRef as v, useEffect as K } from "react";
|
|
3
|
+
import { useAutoBlur as O } from "../../hooks/useAutoBlur.js";
|
|
3
4
|
import './Input.css';/* empty css */
|
|
4
|
-
const
|
|
5
|
+
const P = H(
|
|
5
6
|
({
|
|
6
|
-
id:
|
|
7
|
+
id: y,
|
|
7
8
|
autoFocus: $ = !1,
|
|
8
|
-
autoSelect:
|
|
9
|
-
variant:
|
|
10
|
-
isError:
|
|
9
|
+
autoSelect: f = !1,
|
|
10
|
+
variant: B = "outlined",
|
|
11
|
+
isError: C,
|
|
11
12
|
errorMessage: r,
|
|
12
13
|
onClear: m,
|
|
13
14
|
leftIcon: d,
|
|
14
15
|
rightIcon: p,
|
|
15
|
-
className:
|
|
16
|
-
value:
|
|
17
|
-
color:
|
|
18
|
-
style:
|
|
19
|
-
maxLength:
|
|
16
|
+
className: R,
|
|
17
|
+
value: l,
|
|
18
|
+
color: _,
|
|
19
|
+
style: j,
|
|
20
|
+
maxLength: u,
|
|
20
21
|
label: i,
|
|
22
|
+
autoBlur: x = !1,
|
|
21
23
|
placeholder: b,
|
|
22
24
|
...w
|
|
23
|
-
},
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
}, L) => {
|
|
26
|
+
const k = J().replace(/:/g, ""), n = y ?? `motile-input-${k}`, E = v(null), o = L || E, N = v(null);
|
|
27
|
+
O({ containerRef: N, enabled: x });
|
|
28
|
+
const s = C ?? !!r;
|
|
29
|
+
K(() => {
|
|
30
|
+
if ($ && o.current) {
|
|
31
|
+
const G = setTimeout(() => {
|
|
32
|
+
o.current && (o.current.focus(), f && o.current.select());
|
|
29
33
|
}, 50);
|
|
30
|
-
return () => clearTimeout(
|
|
34
|
+
return () => clearTimeout(G);
|
|
31
35
|
}
|
|
32
|
-
}, [$,
|
|
33
|
-
const e = "motile-input",
|
|
36
|
+
}, [$, f]);
|
|
37
|
+
const e = "motile-input", h = m && l, S = !!d, T = h || p, z = [
|
|
34
38
|
e,
|
|
35
|
-
`${e}--${
|
|
39
|
+
`${e}--${B}`,
|
|
36
40
|
s && `${e}--error`,
|
|
37
|
-
|
|
38
|
-
|
|
41
|
+
S && `${e}--with-left-icon`,
|
|
42
|
+
T && `${e}--with-right-content`,
|
|
39
43
|
i && `${e}--with-label`,
|
|
40
|
-
|
|
41
|
-
].filter(Boolean).join(" "),
|
|
44
|
+
R
|
|
45
|
+
].filter(Boolean).join(" "), A = [
|
|
42
46
|
`${e}-wrapper`,
|
|
43
47
|
i && `${e}-wrapper--with-label`,
|
|
44
48
|
s && `${e}-wrapper--shake`
|
|
45
|
-
].filter(Boolean).join(" "),
|
|
49
|
+
].filter(Boolean).join(" "), I = [
|
|
46
50
|
`${e}__label`,
|
|
47
51
|
s && `${e}__label--error`
|
|
48
|
-
].filter(Boolean).join(" "),
|
|
49
|
-
...
|
|
50
|
-
},
|
|
52
|
+
].filter(Boolean).join(" "), g = _ ? { "--motile-input-color": _ } : void 0, q = {
|
|
53
|
+
...j
|
|
54
|
+
}, D = l ? String(l).length : 0, c = u !== void 0, F = [
|
|
51
55
|
w["aria-describedby"],
|
|
52
56
|
r ? `${n}-error` : void 0,
|
|
53
57
|
c ? `${n}-counter` : void 0
|
|
54
58
|
].filter(Boolean).join(" ") || void 0;
|
|
55
|
-
return /* @__PURE__ */ a("div", { className: `${e}-root`, children: [
|
|
56
|
-
/* @__PURE__ */ a("div", { className:
|
|
57
|
-
i && /* @__PURE__ */ t("label", { className:
|
|
59
|
+
return /* @__PURE__ */ a("div", { className: `${e}-root`, ref: N, children: [
|
|
60
|
+
/* @__PURE__ */ a("div", { className: A, style: g, children: [
|
|
61
|
+
i && /* @__PURE__ */ t("label", { className: I, htmlFor: n, children: i }),
|
|
58
62
|
d && /* @__PURE__ */ t("div", { className: `${e}__left-icon`, children: d }),
|
|
59
63
|
/* @__PURE__ */ t(
|
|
60
64
|
"input",
|
|
61
65
|
{
|
|
62
66
|
id: n,
|
|
63
67
|
...w,
|
|
64
|
-
"aria-describedby":
|
|
68
|
+
"aria-describedby": F,
|
|
65
69
|
"aria-invalid": s || void 0,
|
|
66
|
-
ref:
|
|
67
|
-
className:
|
|
68
|
-
value:
|
|
69
|
-
maxLength:
|
|
70
|
-
style:
|
|
70
|
+
ref: o,
|
|
71
|
+
className: z,
|
|
72
|
+
value: l,
|
|
73
|
+
maxLength: u,
|
|
74
|
+
style: q,
|
|
71
75
|
placeholder: i ? b || " " : b
|
|
72
76
|
}
|
|
73
77
|
),
|
|
74
|
-
p && !
|
|
75
|
-
|
|
78
|
+
p && !h && /* @__PURE__ */ t("div", { className: `${e}__right-icon`, children: p }),
|
|
79
|
+
h && /* @__PURE__ */ t(
|
|
76
80
|
"button",
|
|
77
81
|
{
|
|
78
82
|
type: "button",
|
|
@@ -106,9 +110,9 @@ const J = D(
|
|
|
106
110
|
}
|
|
107
111
|
),
|
|
108
112
|
c && /* @__PURE__ */ a("span", { id: `${n}-counter`, className: `${e}__counter`, children: [
|
|
109
|
-
|
|
113
|
+
D,
|
|
110
114
|
"/",
|
|
111
|
-
|
|
115
|
+
u
|
|
112
116
|
] })
|
|
113
117
|
]
|
|
114
118
|
}
|
|
@@ -116,7 +120,7 @@ const J = D(
|
|
|
116
120
|
] });
|
|
117
121
|
}
|
|
118
122
|
);
|
|
119
|
-
|
|
123
|
+
P.displayName = "Input";
|
|
120
124
|
export {
|
|
121
|
-
|
|
125
|
+
P as Input
|
|
122
126
|
};
|
|
@@ -37,6 +37,19 @@ interface ModalRootProps {
|
|
|
37
37
|
* Modal ๋ด์ฉ
|
|
38
38
|
*/
|
|
39
39
|
children: React.ReactNode;
|
|
40
|
+
/**
|
|
41
|
+
* ๋ธ๋ผ์ฐ์ ํ์คํ ๋ฆฌ(๋ค๋ก๊ฐ๊ธฐ / iOS ์ค์์ดํ ์ ์ค์ฒ)๋ก Modal ๋ซ๊ธฐ ํ์ฑํ.
|
|
42
|
+
*
|
|
43
|
+
* ์ตํธ์ธ ๊ธฐ๋ฅ์ด๋ค. ํ์ฑ ์ ์ด๋ฆด ๋ ๋๋ฏธ ํ์คํ ๋ฆฌ ํญ๋ชฉ์ pushํ๊ณ ,
|
|
44
|
+
* ๋ธ๋ผ์ฐ์ ๋ค๋ก๊ฐ๊ธฐ๋ก Modal์ด ๋ซํ๋ค. ๋ด๋ถ์ ์ผ๋ก Sheet๊ณผ ๋์ผํ ์ค๋ฒ๋ ์ด
|
|
45
|
+
* ํ์คํ ๋ฆฌ ๋ ์ง์คํธ๋ฆฌ๋ฅผ ๊ณต์ ํ๋ฏ๋ก Sheet/Modal ์ค์ฒฉ์์๋ ์์ ํ๋ค.
|
|
46
|
+
*
|
|
47
|
+
* ์ฃผ์: ์ด๋ฆฐ ์ํ๋ก Modal.Root๊ฐ ์ธ๋ง์ดํธ๋๊ฑฐ๋ ์ธ๋ถ ๋ผ์ฐํ
(router.push ๋ฑ)์ผ๋ก
|
|
48
|
+
* ๋ซํ๋ฉด ์ ๋ฆฌ์ฉ back()์ด ์คํ๋์ง ์์ ๋๋ฏธ ํญ๋ชฉ์ด ๋จ์ ์ ์๋ค(๋ค๋ก๊ฐ๊ธฐ ํ ๋ฒ์ no-op).
|
|
49
|
+
*
|
|
50
|
+
* @default false
|
|
51
|
+
*/
|
|
52
|
+
enableHistoryClose?: boolean;
|
|
40
53
|
}
|
|
41
54
|
interface ModalOverlayProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
42
55
|
/**
|
|
@@ -1,124 +1,134 @@
|
|
|
1
|
-
import { jsx as l, jsxs as
|
|
2
|
-
import n, { useRef as
|
|
3
|
-
import { createPortal as
|
|
4
|
-
import { useClickOutside as
|
|
5
|
-
import { useEscapeKey as
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
1
|
+
import { jsx as l, jsxs as P } from "react/jsx-runtime";
|
|
2
|
+
import n, { useRef as O, useState as V, useEffect as q, useId as _, createContext as z, useContext as A } from "react";
|
|
3
|
+
import { createPortal as D } from "react-dom";
|
|
4
|
+
import { useClickOutside as G } from "../../hooks/useClickOutside.js";
|
|
5
|
+
import { useEscapeKey as J } from "../../hooks/useEscapeKey.js";
|
|
6
|
+
import { useHistoryClose as Q } from "../../hooks/useHistoryClose.js";
|
|
7
|
+
import { useScrollLock as U } from "../../hooks/useScrollLock.js";
|
|
8
|
+
import { Slot as W } from "../../utils/Slot.js";
|
|
8
9
|
import './Modal.css';/* empty css */
|
|
9
|
-
const
|
|
10
|
-
const o =
|
|
10
|
+
const h = z(null), u = () => {
|
|
11
|
+
const o = A(h);
|
|
11
12
|
if (!o)
|
|
12
13
|
throw new Error("Modal compound components must be used within Modal.Root");
|
|
13
14
|
return o;
|
|
14
|
-
},
|
|
15
|
+
}, X = ({
|
|
15
16
|
open: o,
|
|
16
17
|
onOpenChange: t,
|
|
17
|
-
children: e
|
|
18
|
+
children: e,
|
|
19
|
+
enableHistoryClose: a = !1
|
|
18
20
|
}) => {
|
|
19
|
-
const
|
|
21
|
+
const r = _(), d = _(), { close: s } = Q({
|
|
22
|
+
isOpen: o,
|
|
23
|
+
onClose: () => t(!1),
|
|
24
|
+
enabled: a
|
|
25
|
+
}), i = n.useMemo(
|
|
20
26
|
() => ({
|
|
21
27
|
open: o,
|
|
22
28
|
onOpenChange: t,
|
|
23
|
-
|
|
29
|
+
close: s,
|
|
30
|
+
enableHistoryClose: a,
|
|
31
|
+
titleId: r,
|
|
24
32
|
descriptionId: d
|
|
25
33
|
}),
|
|
26
|
-
[o, t, a, d]
|
|
34
|
+
[o, t, s, a, r, d]
|
|
27
35
|
);
|
|
28
|
-
return /* @__PURE__ */ l(
|
|
29
|
-
},
|
|
36
|
+
return /* @__PURE__ */ l(h.Provider, { value: i, children: e });
|
|
37
|
+
}, N = n.forwardRef(
|
|
30
38
|
({
|
|
31
39
|
container: o,
|
|
32
40
|
variant: t = "scale",
|
|
33
41
|
closeOnBackdrop: e = !0,
|
|
34
42
|
disableScrollLock: a = !1,
|
|
35
|
-
width:
|
|
36
|
-
maxWidth:
|
|
43
|
+
width: r,
|
|
44
|
+
maxWidth: d,
|
|
37
45
|
zIndex: s = 1e3,
|
|
38
|
-
className:
|
|
39
|
-
onClick:
|
|
40
|
-
style:
|
|
41
|
-
...
|
|
46
|
+
className: i,
|
|
47
|
+
onClick: c,
|
|
48
|
+
style: S,
|
|
49
|
+
...y
|
|
42
50
|
}, g) => {
|
|
43
|
-
const { open:
|
|
44
|
-
|
|
45
|
-
|
|
51
|
+
const { open: m, onOpenChange: E, close: p, enableHistoryClose: T } = u(), M = O(null), [j, k] = V(!1);
|
|
52
|
+
q(() => {
|
|
53
|
+
k(!0);
|
|
46
54
|
}, []);
|
|
47
|
-
const b = typeof e == "boolean" ? e : e.clickOutside ?? !1,
|
|
48
|
-
|
|
49
|
-
enabled:
|
|
55
|
+
const b = typeof e == "boolean" ? e : e.clickOutside ?? !1, v = typeof e == "boolean" ? e : e.escapeKey ?? !1;
|
|
56
|
+
U({
|
|
57
|
+
enabled: m && !a,
|
|
50
58
|
allowedSelectors: [".motile-modal__content"]
|
|
51
|
-
}),
|
|
59
|
+
}), G({
|
|
52
60
|
refs: [M],
|
|
53
61
|
handler: () => {
|
|
54
|
-
b &&
|
|
62
|
+
b && !T && E(!1);
|
|
55
63
|
},
|
|
56
|
-
enabled:
|
|
57
|
-
}),
|
|
64
|
+
enabled: m
|
|
65
|
+
}), J({
|
|
58
66
|
handler: () => {
|
|
59
|
-
|
|
67
|
+
v && p();
|
|
60
68
|
},
|
|
61
|
-
enabled:
|
|
69
|
+
enabled: m && v,
|
|
70
|
+
stacked: !0
|
|
71
|
+
// ์ค์ฒฉ ์ค๋ฒ๋ ์ด์์ ESC๋ ์ต์๋จ๋ง ๋ซ๋๋ค
|
|
62
72
|
});
|
|
63
|
-
const
|
|
64
|
-
|
|
73
|
+
const F = (f) => {
|
|
74
|
+
c == null || c(f), f.target === f.currentTarget && b && p();
|
|
65
75
|
};
|
|
66
|
-
if (!
|
|
67
|
-
const
|
|
76
|
+
if (!j || !m) return null;
|
|
77
|
+
const H = {
|
|
68
78
|
zIndex: s,
|
|
69
|
-
|
|
70
|
-
},
|
|
71
|
-
...
|
|
72
|
-
...
|
|
79
|
+
...S
|
|
80
|
+
}, K = {
|
|
81
|
+
...r && { "--modal-width": r },
|
|
82
|
+
...d && { "--modal-max-width": d },
|
|
73
83
|
zIndex: s + 1
|
|
74
|
-
},
|
|
84
|
+
}, L = /* @__PURE__ */ l(
|
|
75
85
|
"div",
|
|
76
86
|
{
|
|
77
87
|
ref: g,
|
|
78
|
-
className: `motile-modal__backdrop ${
|
|
79
|
-
"data-state":
|
|
88
|
+
className: `motile-modal__backdrop ${i || ""}`,
|
|
89
|
+
"data-state": m ? "open" : "closed",
|
|
80
90
|
"data-variant": t,
|
|
81
|
-
onClick:
|
|
82
|
-
style:
|
|
83
|
-
...
|
|
91
|
+
onClick: F,
|
|
92
|
+
style: H,
|
|
93
|
+
...y,
|
|
84
94
|
children: /* @__PURE__ */ l(
|
|
85
95
|
"div",
|
|
86
96
|
{
|
|
87
97
|
ref: M,
|
|
88
98
|
className: "motile-modal",
|
|
89
99
|
"data-variant": t,
|
|
90
|
-
style:
|
|
91
|
-
children:
|
|
100
|
+
style: K,
|
|
101
|
+
children: y.children
|
|
92
102
|
}
|
|
93
103
|
)
|
|
94
104
|
}
|
|
95
105
|
);
|
|
96
|
-
return
|
|
106
|
+
return D(L, o || document.body);
|
|
97
107
|
}
|
|
98
108
|
);
|
|
99
|
-
|
|
100
|
-
const
|
|
109
|
+
N.displayName = "Modal.Overlay";
|
|
110
|
+
const w = n.forwardRef(
|
|
101
111
|
({ className: o, forceMount: t, ...e }, a) => {
|
|
102
|
-
const { open:
|
|
103
|
-
return !
|
|
112
|
+
const { open: r, titleId: d, descriptionId: s } = u();
|
|
113
|
+
return !r && !t ? null : /* @__PURE__ */ l(
|
|
104
114
|
"div",
|
|
105
115
|
{
|
|
106
116
|
ref: a,
|
|
107
117
|
className: `motile-modal__content ${o || ""}`,
|
|
108
118
|
role: "dialog",
|
|
109
119
|
"aria-modal": "true",
|
|
110
|
-
"aria-labelledby":
|
|
120
|
+
"aria-labelledby": d,
|
|
111
121
|
"aria-describedby": s,
|
|
112
|
-
"data-state":
|
|
122
|
+
"data-state": r ? "open" : "closed",
|
|
113
123
|
...e
|
|
114
124
|
}
|
|
115
125
|
);
|
|
116
126
|
}
|
|
117
127
|
);
|
|
118
|
-
|
|
119
|
-
const
|
|
128
|
+
w.displayName = "Modal.Content";
|
|
129
|
+
const x = n.forwardRef(
|
|
120
130
|
({ className: o, ...t }, e) => {
|
|
121
|
-
const { titleId: a } =
|
|
131
|
+
const { titleId: a } = u();
|
|
122
132
|
return /* @__PURE__ */ l(
|
|
123
133
|
"h2",
|
|
124
134
|
{
|
|
@@ -130,10 +140,10 @@ const w = n.forwardRef(
|
|
|
130
140
|
);
|
|
131
141
|
}
|
|
132
142
|
);
|
|
133
|
-
|
|
134
|
-
const
|
|
143
|
+
x.displayName = "Modal.Title";
|
|
144
|
+
const R = n.forwardRef(
|
|
135
145
|
({ className: o, ...t }, e) => {
|
|
136
|
-
const { descriptionId: a } =
|
|
146
|
+
const { descriptionId: a } = u();
|
|
137
147
|
return /* @__PURE__ */ l(
|
|
138
148
|
"div",
|
|
139
149
|
{
|
|
@@ -145,30 +155,30 @@ const x = n.forwardRef(
|
|
|
145
155
|
);
|
|
146
156
|
}
|
|
147
157
|
);
|
|
148
|
-
|
|
149
|
-
const
|
|
150
|
-
({ asChild: o, className: t, onClick: e, children: a, ...
|
|
151
|
-
const {
|
|
152
|
-
e == null || e(
|
|
158
|
+
R.displayName = "Modal.Body";
|
|
159
|
+
const C = n.forwardRef(
|
|
160
|
+
({ asChild: o, className: t, onClick: e, children: a, ...r }, d) => {
|
|
161
|
+
const { close: s } = u(), i = (c) => {
|
|
162
|
+
e == null || e(c), s();
|
|
153
163
|
};
|
|
154
164
|
return o ? /* @__PURE__ */ l(
|
|
155
|
-
|
|
165
|
+
W,
|
|
156
166
|
{
|
|
157
|
-
...
|
|
158
|
-
onClick:
|
|
159
|
-
ref:
|
|
167
|
+
...r,
|
|
168
|
+
onClick: i,
|
|
169
|
+
ref: d,
|
|
160
170
|
children: a
|
|
161
171
|
}
|
|
162
172
|
) : /* @__PURE__ */ l(
|
|
163
173
|
"button",
|
|
164
174
|
{
|
|
165
|
-
ref:
|
|
175
|
+
ref: d,
|
|
166
176
|
type: "button",
|
|
167
177
|
className: `motile-modal__close ${t || ""}`,
|
|
168
|
-
onClick:
|
|
178
|
+
onClick: i,
|
|
169
179
|
"aria-label": "๋ซ๊ธฐ",
|
|
170
|
-
...
|
|
171
|
-
children: a || /* @__PURE__ */
|
|
180
|
+
...r,
|
|
181
|
+
children: a || /* @__PURE__ */ P(
|
|
172
182
|
"svg",
|
|
173
183
|
{
|
|
174
184
|
width: "18",
|
|
@@ -189,8 +199,8 @@ const R = n.forwardRef(
|
|
|
189
199
|
);
|
|
190
200
|
}
|
|
191
201
|
);
|
|
192
|
-
|
|
193
|
-
const
|
|
202
|
+
C.displayName = "Modal.Close";
|
|
203
|
+
const I = n.forwardRef(
|
|
194
204
|
({ className: o, ...t }, e) => /* @__PURE__ */ l(
|
|
195
205
|
"div",
|
|
196
206
|
{
|
|
@@ -200,8 +210,8 @@ const C = n.forwardRef(
|
|
|
200
210
|
}
|
|
201
211
|
)
|
|
202
212
|
);
|
|
203
|
-
|
|
204
|
-
const
|
|
213
|
+
I.displayName = "Modal.Footer";
|
|
214
|
+
const $ = n.forwardRef(
|
|
205
215
|
({ className: o, ...t }, e) => /* @__PURE__ */ l(
|
|
206
216
|
"div",
|
|
207
217
|
{
|
|
@@ -211,25 +221,25 @@ const I = n.forwardRef(
|
|
|
211
221
|
}
|
|
212
222
|
)
|
|
213
223
|
);
|
|
214
|
-
|
|
215
|
-
const
|
|
216
|
-
Root:
|
|
217
|
-
Overlay:
|
|
218
|
-
Content:
|
|
219
|
-
Title:
|
|
220
|
-
Body:
|
|
221
|
-
Close:
|
|
222
|
-
Footer:
|
|
223
|
-
Header:
|
|
224
|
+
$.displayName = "Modal.Header";
|
|
225
|
+
const de = {
|
|
226
|
+
Root: X,
|
|
227
|
+
Overlay: N,
|
|
228
|
+
Content: w,
|
|
229
|
+
Title: x,
|
|
230
|
+
Body: R,
|
|
231
|
+
Close: C,
|
|
232
|
+
Footer: I,
|
|
233
|
+
Header: $
|
|
224
234
|
};
|
|
225
235
|
export {
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
236
|
+
de as Modal,
|
|
237
|
+
R as ModalBody,
|
|
238
|
+
C as ModalClose,
|
|
239
|
+
w as ModalContent,
|
|
240
|
+
I as ModalFooter,
|
|
241
|
+
$ as ModalHeader,
|
|
242
|
+
N as ModalOverlay,
|
|
243
|
+
X as ModalRoot,
|
|
244
|
+
x as ModalTitle
|
|
235
245
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import
|
|
1
|
+
import { jsxs as y, jsx as g } from "react/jsx-runtime";
|
|
2
|
+
import $, { useCallback as b, useId as N, useRef as I, useMemo as j, createContext as E, useContext as T } from "react";
|
|
3
3
|
import { useClickOutside as h } from "../../hooks/useClickOutside.js";
|
|
4
4
|
import { useEscapeKey as A } from "../../hooks/useEscapeKey.js";
|
|
5
5
|
import { FloatingArrow as B } from "../../utils/FloatingArrow.js";
|
|
@@ -17,7 +17,7 @@ function K({
|
|
|
17
17
|
defaultValue: p = !1,
|
|
18
18
|
onChange: o
|
|
19
19
|
}) {
|
|
20
|
-
const e = t !== void 0, [r, s] =
|
|
20
|
+
const e = t !== void 0, [r, s] = $.useState(p), l = e ? t : r, c = b(
|
|
21
21
|
(a) => {
|
|
22
22
|
const d = typeof a == "function" ? a(l) : a;
|
|
23
23
|
e || s(d), o == null || o(d);
|
|
@@ -38,15 +38,15 @@ function M({
|
|
|
38
38
|
open: a,
|
|
39
39
|
defaultOpen: d = !1,
|
|
40
40
|
onOpenChange: m,
|
|
41
|
-
onClickOutside:
|
|
41
|
+
onClickOutside: u,
|
|
42
42
|
onDismiss: v,
|
|
43
|
-
autoClose:
|
|
43
|
+
autoClose: f = !0
|
|
44
44
|
}) {
|
|
45
45
|
const n = N().replace(/:/g, ""), x = I(null), w = I(null), P = I(null), [R, i] = K({
|
|
46
46
|
value: a,
|
|
47
47
|
defaultValue: d,
|
|
48
48
|
onChange: m
|
|
49
|
-
}),
|
|
49
|
+
}), k = j(
|
|
50
50
|
() => ({
|
|
51
51
|
open: R,
|
|
52
52
|
setOpen: i,
|
|
@@ -56,10 +56,10 @@ function M({
|
|
|
56
56
|
showArrow: r,
|
|
57
57
|
zIndex: s,
|
|
58
58
|
color: l,
|
|
59
|
-
autoClose:
|
|
59
|
+
autoClose: f,
|
|
60
60
|
bounceCount: c,
|
|
61
61
|
onOpenChange: m,
|
|
62
|
-
onClickOutside:
|
|
62
|
+
onClickOutside: u,
|
|
63
63
|
onDismiss: v,
|
|
64
64
|
triggerId: `${n}-trigger`,
|
|
65
65
|
contentId: `${n}-content`,
|
|
@@ -76,15 +76,15 @@ function M({
|
|
|
76
76
|
r,
|
|
77
77
|
s,
|
|
78
78
|
l,
|
|
79
|
-
|
|
79
|
+
f,
|
|
80
80
|
c,
|
|
81
81
|
m,
|
|
82
|
-
|
|
82
|
+
u,
|
|
83
83
|
v,
|
|
84
84
|
n
|
|
85
85
|
]
|
|
86
86
|
);
|
|
87
|
-
return /* @__PURE__ */ g(S.Provider, { value:
|
|
87
|
+
return /* @__PURE__ */ g(S.Provider, { value: k, children: /* @__PURE__ */ g("div", { ref: P, className: "motile-popover-wrapper", children: t }) });
|
|
88
88
|
}
|
|
89
89
|
function V({ children: t, asChild: p = !1 }) {
|
|
90
90
|
const { open: o, setOpen: e, triggerId: r, contentId: s, triggerRef: l } = C(), c = b(() => {
|
|
@@ -129,9 +129,9 @@ function q({
|
|
|
129
129
|
showArrow: a,
|
|
130
130
|
zIndex: d,
|
|
131
131
|
color: m,
|
|
132
|
-
autoClose:
|
|
132
|
+
autoClose: u,
|
|
133
133
|
bounceCount: v,
|
|
134
|
-
onClickOutside:
|
|
134
|
+
onClickOutside: f,
|
|
135
135
|
onDismiss: n,
|
|
136
136
|
contentId: x,
|
|
137
137
|
contentRef: w,
|
|
@@ -140,23 +140,27 @@ function q({
|
|
|
140
140
|
if (A({
|
|
141
141
|
handler: b(
|
|
142
142
|
(i) => {
|
|
143
|
-
|
|
143
|
+
u && (n == null || n(i), i.defaultPrevented || r(!1));
|
|
144
144
|
},
|
|
145
|
-
[
|
|
145
|
+
[u, n, r]
|
|
146
146
|
),
|
|
147
|
-
enabled
|
|
147
|
+
// enabled๋ฅผ ์ ์งํ๊ฒ ๊ณ์ฐ โ ๋ซํ์ง ์์(autoClose=false) ํ์ค๋ฒ๊ฐ
|
|
148
|
+
// ESC ์คํ์ top์ ์ ์ ํด ์๋ ์ค๋ฒ๋ ์ด์ ESC๋ฅผ ์ผํค์ง ์๊ฒ
|
|
149
|
+
enabled: e && u,
|
|
150
|
+
stacked: !0
|
|
151
|
+
// ์ค์ฒฉ ์ค๋ฒ๋ ์ด์์ ESC๋ ์ต์๋จ๋ง ๋ซ๋๋ค
|
|
148
152
|
}), h({
|
|
149
153
|
refs: [P],
|
|
150
154
|
handler: b(
|
|
151
155
|
(i) => {
|
|
152
|
-
|
|
156
|
+
u && (f == null || f(i), n == null || n(i), i.defaultPrevented || r(!1));
|
|
153
157
|
},
|
|
154
|
-
[
|
|
158
|
+
[u, f, n, r]
|
|
155
159
|
),
|
|
156
160
|
enabled: e
|
|
157
161
|
}), !e) return null;
|
|
158
162
|
const R = v !== 0;
|
|
159
|
-
return /* @__PURE__ */
|
|
163
|
+
return /* @__PURE__ */ y(
|
|
160
164
|
"div",
|
|
161
165
|
{
|
|
162
166
|
ref: w,
|