motile-ui 1.3.1 → 1.4.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.js +53 -51
- 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
|
@@ -1,33 +1,33 @@
|
|
|
1
1
|
import { jsxs as L, jsx as n } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
2
|
+
import k, { useEffect as j, useState as R, useRef as P, useId as ee, useCallback as $, createContext as te, useContext as oe } from "react";
|
|
3
3
|
import { Drawer as C } from "../Drawer/Drawer.js";
|
|
4
4
|
import { useClickOutside as se } from "../../hooks/useClickOutside.js";
|
|
5
5
|
import { useEscapeKey as ne } from "../../hooks/useEscapeKey.js";
|
|
6
6
|
import { useMediaQuery as le } from "../../hooks/useMediaQuery.js";
|
|
7
|
-
import { Slot as
|
|
7
|
+
import { Slot as re } from "../../utils/Slot.js";
|
|
8
8
|
import './Select.css';/* empty css */
|
|
9
|
-
const
|
|
10
|
-
const e = oe(
|
|
9
|
+
const Q = te(null), z = () => {
|
|
10
|
+
const e = oe(Q);
|
|
11
11
|
if (!e)
|
|
12
12
|
throw new Error("Select components must be used within Select.Root");
|
|
13
13
|
return e;
|
|
14
|
-
},
|
|
14
|
+
}, B = ({
|
|
15
15
|
value: e,
|
|
16
16
|
defaultValue: c,
|
|
17
17
|
onValueChange: l,
|
|
18
|
-
open:
|
|
18
|
+
open: r,
|
|
19
19
|
onOpenChange: o,
|
|
20
20
|
disabled: a = !1,
|
|
21
21
|
zIndex: u = 40,
|
|
22
22
|
hideCheckIcon: g = !1,
|
|
23
|
-
maxWidth:
|
|
23
|
+
maxWidth: i = 768,
|
|
24
24
|
closeOnBackdrop: s = !0,
|
|
25
25
|
color: S,
|
|
26
26
|
children: w
|
|
27
27
|
}) => {
|
|
28
|
-
const [d, _] = R(c), [y, p] = R(!1), f = P(null), v = P(null), m = e !== void 0, h = m ? e : d, E =
|
|
28
|
+
const [d, _] = R(c), [y, p] = R(!1), f = P(null), v = P(null), m = e !== void 0, h = m ? e : d, E = r !== void 0, b = E ? r : y, K = P(b);
|
|
29
29
|
K.current = b;
|
|
30
|
-
const [
|
|
30
|
+
const [F, T] = R(/* @__PURE__ */ new Map()), G = `select-content-${ee()}`, J = i ? `(max-width: ${typeof i == "number" ? `${i}px` : i})` : "(max-width: 768px)", M = le(J), X = typeof s == "boolean" ? s : s.clickOutside ?? !1, H = typeof s == "boolean" ? s : s.escapeKey ?? !1, x = $(
|
|
31
31
|
(t) => {
|
|
32
32
|
E || p(t), o == null || o(t);
|
|
33
33
|
},
|
|
@@ -38,8 +38,8 @@ const O = te(null), z = () => {
|
|
|
38
38
|
}, Z = $(
|
|
39
39
|
(t, I) => {
|
|
40
40
|
T((N) => {
|
|
41
|
-
const
|
|
42
|
-
return
|
|
41
|
+
const O = new Map(N);
|
|
42
|
+
return O.set(t, I), O;
|
|
43
43
|
});
|
|
44
44
|
},
|
|
45
45
|
[]
|
|
@@ -52,15 +52,17 @@ const O = te(null), z = () => {
|
|
|
52
52
|
se({
|
|
53
53
|
refs: [v, f],
|
|
54
54
|
handler: () => {
|
|
55
|
-
b &&
|
|
55
|
+
b && X && x(!1);
|
|
56
56
|
},
|
|
57
|
-
enabled: b && !
|
|
57
|
+
enabled: b && !M
|
|
58
58
|
}), ne({
|
|
59
59
|
handler: () => {
|
|
60
60
|
var t;
|
|
61
|
-
b &&
|
|
61
|
+
b && H && (x(!1), (t = f.current) == null || t.focus());
|
|
62
62
|
},
|
|
63
|
-
enabled: b && !
|
|
63
|
+
enabled: b && !M && H,
|
|
64
|
+
stacked: !0
|
|
65
|
+
// 중첩 오버레이에서 ESC는 최상단만 닫는다
|
|
64
66
|
}), j(() => {
|
|
65
67
|
if (!b) return;
|
|
66
68
|
const t = () => {
|
|
@@ -69,7 +71,7 @@ const O = te(null), z = () => {
|
|
|
69
71
|
return window.addEventListener("resize", t), () => window.removeEventListener("resize", t);
|
|
70
72
|
}, [b, x]), j(() => {
|
|
71
73
|
K.current && x(!1);
|
|
72
|
-
}, [
|
|
74
|
+
}, [M, x]);
|
|
73
75
|
const W = {
|
|
74
76
|
open: b,
|
|
75
77
|
setOpen: x,
|
|
@@ -78,24 +80,24 @@ const O = te(null), z = () => {
|
|
|
78
80
|
disabled: a,
|
|
79
81
|
triggerRef: f,
|
|
80
82
|
contentRef: v,
|
|
81
|
-
contentId:
|
|
82
|
-
itemLabels:
|
|
83
|
+
contentId: G,
|
|
84
|
+
itemLabels: F,
|
|
83
85
|
registerItem: Z,
|
|
84
86
|
unregisterItem: V,
|
|
85
87
|
zIndex: u,
|
|
86
88
|
hideCheckIcon: g,
|
|
87
|
-
isMobile:
|
|
88
|
-
maxWidth:
|
|
89
|
+
isMobile: M,
|
|
90
|
+
maxWidth: i,
|
|
89
91
|
closeOnBackdrop: s,
|
|
90
92
|
color: S
|
|
91
93
|
};
|
|
92
|
-
return /* @__PURE__ */ n(
|
|
94
|
+
return /* @__PURE__ */ n(Q.Provider, { value: W, children: /* @__PURE__ */ n("div", { style: { position: "relative" }, children: w }) });
|
|
93
95
|
};
|
|
94
|
-
|
|
95
|
-
const
|
|
96
|
-
const { open: u, setOpen: g, disabled:
|
|
97
|
-
|
|
98
|
-
}, y =
|
|
96
|
+
B.displayName = "Select.Root";
|
|
97
|
+
const U = k.forwardRef(({ children: e, className: c, style: l, asChild: r = !1, ...o }, a) => {
|
|
98
|
+
const { open: u, setOpen: g, disabled: i, triggerRef: s, contentId: S, zIndex: w, color: d } = z(), _ = () => {
|
|
99
|
+
i || g(!u);
|
|
100
|
+
}, y = k.useCallback(
|
|
99
101
|
(h) => {
|
|
100
102
|
s.current = h, typeof a == "function" ? a(h) : a && (a.current = h);
|
|
101
103
|
},
|
|
@@ -111,7 +113,7 @@ const B = M.forwardRef(({ children: e, className: c, style: l, asChild: i = !1,
|
|
|
111
113
|
"aria-controls": S,
|
|
112
114
|
"aria-expanded": u,
|
|
113
115
|
"aria-haspopup": "listbox",
|
|
114
|
-
disabled:
|
|
116
|
+
disabled: i,
|
|
115
117
|
className: p,
|
|
116
118
|
style: f,
|
|
117
119
|
onClick: _,
|
|
@@ -137,25 +139,25 @@ const B = M.forwardRef(({ children: e, className: c, style: l, asChild: i = !1,
|
|
|
137
139
|
)
|
|
138
140
|
}
|
|
139
141
|
);
|
|
140
|
-
return
|
|
142
|
+
return r ? /* @__PURE__ */ n(re, { ...v, children: e }) : /* @__PURE__ */ L("button", { ...v, children: [
|
|
141
143
|
e,
|
|
142
144
|
m
|
|
143
145
|
] });
|
|
144
146
|
});
|
|
145
|
-
|
|
146
|
-
const
|
|
147
|
+
U.displayName = "Select.Trigger";
|
|
148
|
+
const q = ({
|
|
147
149
|
placeholder: e = "선택하세요"
|
|
148
150
|
}) => {
|
|
149
|
-
const { value: c, itemLabels: l } = z(),
|
|
150
|
-
return /* @__PURE__ */ n("span", { className: "motile-select__value", children:
|
|
151
|
+
const { value: c, itemLabels: l } = z(), r = c ? l.get(c) : void 0;
|
|
152
|
+
return /* @__PURE__ */ n("span", { className: "motile-select__value", children: r || e });
|
|
151
153
|
};
|
|
152
|
-
|
|
153
|
-
const
|
|
154
|
+
q.displayName = "Select.Value";
|
|
155
|
+
const A = k.forwardRef(({ children: e, className: c, style: l, ...r }, o) => {
|
|
154
156
|
const {
|
|
155
157
|
open: a,
|
|
156
158
|
setOpen: u,
|
|
157
159
|
contentRef: g,
|
|
158
|
-
contentId:
|
|
160
|
+
contentId: i,
|
|
159
161
|
zIndex: s,
|
|
160
162
|
isMobile: S,
|
|
161
163
|
closeOnBackdrop: w,
|
|
@@ -164,7 +166,7 @@ const q = M.forwardRef(({ children: e, className: c, style: l, ...i }, o) => {
|
|
|
164
166
|
j(() => {
|
|
165
167
|
y(!0);
|
|
166
168
|
}, []);
|
|
167
|
-
const p =
|
|
169
|
+
const p = k.useCallback(
|
|
168
170
|
(m) => {
|
|
169
171
|
g.current = m, typeof o == "function" ? o(m) : o && (o.current = m);
|
|
170
172
|
},
|
|
@@ -194,10 +196,10 @@ const q = M.forwardRef(({ children: e, className: c, style: l, ...i }, o) => {
|
|
|
194
196
|
children: /* @__PURE__ */ n(
|
|
195
197
|
"div",
|
|
196
198
|
{
|
|
197
|
-
id:
|
|
199
|
+
id: i,
|
|
198
200
|
role: "listbox",
|
|
199
201
|
className: `motile-select__mobile-list ${c || ""}`,
|
|
200
|
-
...
|
|
202
|
+
...r,
|
|
201
203
|
children: e
|
|
202
204
|
}
|
|
203
205
|
)
|
|
@@ -222,28 +224,28 @@ const q = M.forwardRef(({ children: e, className: c, style: l, ...i }, o) => {
|
|
|
222
224
|
"div",
|
|
223
225
|
{
|
|
224
226
|
ref: p,
|
|
225
|
-
id:
|
|
227
|
+
id: i,
|
|
226
228
|
role: "listbox",
|
|
227
229
|
className: f,
|
|
228
230
|
style: v,
|
|
229
231
|
tabIndex: -1,
|
|
230
|
-
...
|
|
232
|
+
...r,
|
|
231
233
|
children: e
|
|
232
234
|
}
|
|
233
235
|
);
|
|
234
236
|
});
|
|
235
|
-
|
|
236
|
-
const
|
|
237
|
+
A.displayName = "Select.Content";
|
|
238
|
+
const D = k.forwardRef(
|
|
237
239
|
({
|
|
238
240
|
value: e,
|
|
239
241
|
selected: c,
|
|
240
242
|
disabled: l = !1,
|
|
241
|
-
children:
|
|
243
|
+
children: r,
|
|
242
244
|
className: o,
|
|
243
245
|
style: a,
|
|
244
246
|
onClick: u,
|
|
245
247
|
...g
|
|
246
|
-
},
|
|
248
|
+
}, i) => {
|
|
247
249
|
const {
|
|
248
250
|
value: s,
|
|
249
251
|
onValueChange: S,
|
|
@@ -253,8 +255,8 @@ const A = M.forwardRef(
|
|
|
253
255
|
color: y
|
|
254
256
|
} = z(), p = c !== void 0 ? c : e !== void 0 && s === e;
|
|
255
257
|
j(() => {
|
|
256
|
-
e !== void 0 && d(e,
|
|
257
|
-
}, [e,
|
|
258
|
+
e !== void 0 && d(e, r);
|
|
259
|
+
}, [e, r, d]);
|
|
258
260
|
const f = (h) => {
|
|
259
261
|
l || (u == null || u(h), !h.defaultPrevented && (e !== void 0 ? S(e) : w(!1)));
|
|
260
262
|
}, v = [
|
|
@@ -269,7 +271,7 @@ const A = M.forwardRef(
|
|
|
269
271
|
return /* @__PURE__ */ L(
|
|
270
272
|
"div",
|
|
271
273
|
{
|
|
272
|
-
ref:
|
|
274
|
+
ref: i,
|
|
273
275
|
role: "option",
|
|
274
276
|
"aria-selected": p,
|
|
275
277
|
"aria-disabled": l,
|
|
@@ -278,7 +280,7 @@ const A = M.forwardRef(
|
|
|
278
280
|
onClick: f,
|
|
279
281
|
...g,
|
|
280
282
|
children: [
|
|
281
|
-
|
|
283
|
+
r,
|
|
282
284
|
p && !_ && /* @__PURE__ */ n(
|
|
283
285
|
"svg",
|
|
284
286
|
{
|
|
@@ -305,19 +307,19 @@ const A = M.forwardRef(
|
|
|
305
307
|
);
|
|
306
308
|
}
|
|
307
309
|
);
|
|
308
|
-
|
|
310
|
+
D.displayName = "Select.Item";
|
|
309
311
|
const be = {
|
|
310
|
-
Root:
|
|
311
|
-
Trigger:
|
|
312
|
-
Value:
|
|
313
|
-
Content:
|
|
314
|
-
Item:
|
|
312
|
+
Root: B,
|
|
313
|
+
Trigger: U,
|
|
314
|
+
Value: q,
|
|
315
|
+
Content: A,
|
|
316
|
+
Item: D
|
|
315
317
|
};
|
|
316
318
|
export {
|
|
317
319
|
be as Select,
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
320
|
+
A as SelectContent,
|
|
321
|
+
D as SelectItem,
|
|
322
|
+
B as SelectRoot,
|
|
323
|
+
U as SelectTrigger,
|
|
324
|
+
q as SelectValue
|
|
323
325
|
};
|
|
@@ -180,7 +180,9 @@ function E({ children: e, className: n = "", style: o }) {
|
|
|
180
180
|
allowedSelectors: [".motile-sheet__body"]
|
|
181
181
|
}), K({
|
|
182
182
|
handler: i,
|
|
183
|
-
enabled: t && S.escapeKey
|
|
183
|
+
enabled: t && S.escapeKey,
|
|
184
|
+
stacked: !0
|
|
185
|
+
// 중첩 오버레이에서 ESC는 최상단만 닫는다
|
|
184
186
|
}), b(() => {
|
|
185
187
|
if (t)
|
|
186
188
|
h(!0);
|
|
@@ -16,31 +16,33 @@ const _ = R(null), g = () => {
|
|
|
16
16
|
onOpenChange: t,
|
|
17
17
|
direction: i = "up",
|
|
18
18
|
color: d,
|
|
19
|
-
closeOnClickOutside:
|
|
20
|
-
closeOnEscapeKey:
|
|
21
|
-
children:
|
|
19
|
+
closeOnClickOutside: a = !0,
|
|
20
|
+
closeOnEscapeKey: o = !0,
|
|
21
|
+
children: r
|
|
22
22
|
}) => {
|
|
23
|
-
const l = y(null),
|
|
23
|
+
const l = y(null), n = b();
|
|
24
24
|
v({
|
|
25
25
|
refs: [l],
|
|
26
26
|
handler: () => {
|
|
27
|
-
|
|
27
|
+
a && t(!1);
|
|
28
28
|
},
|
|
29
29
|
enabled: e
|
|
30
30
|
}), A({
|
|
31
31
|
handler: () => {
|
|
32
|
-
|
|
32
|
+
o && t(!1);
|
|
33
33
|
},
|
|
34
|
-
enabled: e
|
|
34
|
+
enabled: e && o,
|
|
35
|
+
stacked: !0
|
|
36
|
+
// 중첩 오버레이에서 ESC는 최상단만 닫는다
|
|
35
37
|
});
|
|
36
38
|
const p = m.useMemo(
|
|
37
39
|
() => ({
|
|
38
40
|
open: e,
|
|
39
41
|
onOpenChange: t,
|
|
40
42
|
direction: i,
|
|
41
|
-
triggerId:
|
|
43
|
+
triggerId: n
|
|
42
44
|
}),
|
|
43
|
-
[e, t, i,
|
|
45
|
+
[e, t, i, n]
|
|
44
46
|
), u = d ? { "--motile-speeddial-color": d } : void 0;
|
|
45
47
|
return /* @__PURE__ */ s(_.Provider, { value: p, children: /* @__PURE__ */ s(
|
|
46
48
|
"div",
|
|
@@ -48,87 +50,87 @@ const _ = R(null), g = () => {
|
|
|
48
50
|
ref: l,
|
|
49
51
|
className: "motile-speed-dial",
|
|
50
52
|
style: u,
|
|
51
|
-
children:
|
|
53
|
+
children: r
|
|
52
54
|
}
|
|
53
55
|
) });
|
|
54
|
-
}, S = c(({ className: e, onClick: t, children: i, asChild: d = !1, ...
|
|
55
|
-
const { open:
|
|
56
|
-
t == null || t(u), u.defaultPrevented || l(!
|
|
56
|
+
}, S = c(({ className: e, onClick: t, children: i, asChild: d = !1, ...a }, o) => {
|
|
57
|
+
const { open: r, onOpenChange: l, triggerId: n } = g(), p = (u) => {
|
|
58
|
+
t == null || t(u), u.defaultPrevented || l(!r);
|
|
57
59
|
};
|
|
58
60
|
return d ? /* @__PURE__ */ s(
|
|
59
61
|
f,
|
|
60
62
|
{
|
|
61
|
-
ref:
|
|
62
|
-
id:
|
|
63
|
+
ref: o,
|
|
64
|
+
id: n,
|
|
63
65
|
className: e ? `motile-speed-dial__trigger ${e}` : "motile-speed-dial__trigger",
|
|
64
|
-
"aria-expanded":
|
|
66
|
+
"aria-expanded": r,
|
|
65
67
|
"aria-haspopup": "menu",
|
|
66
68
|
onClick: p,
|
|
67
|
-
...
|
|
69
|
+
...a,
|
|
68
70
|
children: i
|
|
69
71
|
}
|
|
70
72
|
) : /* @__PURE__ */ s(
|
|
71
73
|
"button",
|
|
72
74
|
{
|
|
73
|
-
ref:
|
|
75
|
+
ref: o,
|
|
74
76
|
type: "button",
|
|
75
|
-
id:
|
|
77
|
+
id: n,
|
|
76
78
|
className: e ? `motile-speed-dial__trigger ${e}` : "motile-speed-dial__trigger",
|
|
77
|
-
"aria-expanded":
|
|
79
|
+
"aria-expanded": r,
|
|
78
80
|
"aria-haspopup": "menu",
|
|
79
81
|
onClick: p,
|
|
80
|
-
...
|
|
82
|
+
...a,
|
|
81
83
|
children: i
|
|
82
84
|
}
|
|
83
85
|
);
|
|
84
86
|
});
|
|
85
87
|
S.displayName = "SpeedDial.Trigger";
|
|
86
88
|
const x = c(({ className: e, children: t, ...i }, d) => {
|
|
87
|
-
const { open:
|
|
88
|
-
if (!
|
|
89
|
-
const l = m.Children.map(t, (
|
|
89
|
+
const { open: a, direction: o, triggerId: r } = g();
|
|
90
|
+
if (!a) return null;
|
|
91
|
+
const l = m.Children.map(t, (n, p) => m.isValidElement(n) ? m.cloneElement(n, {
|
|
90
92
|
style: {
|
|
91
93
|
"--action-index": p,
|
|
92
|
-
...
|
|
94
|
+
...n.props.style || {}
|
|
93
95
|
}
|
|
94
|
-
}) :
|
|
96
|
+
}) : n);
|
|
95
97
|
return /* @__PURE__ */ s(
|
|
96
98
|
"div",
|
|
97
99
|
{
|
|
98
100
|
ref: d,
|
|
99
101
|
role: "menu",
|
|
100
|
-
"aria-labelledby":
|
|
102
|
+
"aria-labelledby": r,
|
|
101
103
|
className: e ? `motile-speed-dial__actions ${e}` : "motile-speed-dial__actions",
|
|
102
|
-
"data-direction":
|
|
104
|
+
"data-direction": o,
|
|
103
105
|
...i,
|
|
104
106
|
children: l
|
|
105
107
|
}
|
|
106
108
|
);
|
|
107
109
|
});
|
|
108
110
|
x.displayName = "SpeedDial.Actions";
|
|
109
|
-
const D = c(({ className: e, onClick: t, children: i, asChild: d = !1, ...
|
|
110
|
-
const
|
|
111
|
+
const D = c(({ className: e, onClick: t, children: i, asChild: d = !1, ...a }, o) => {
|
|
112
|
+
const r = (l) => {
|
|
111
113
|
t == null || t(l);
|
|
112
114
|
};
|
|
113
115
|
return d ? /* @__PURE__ */ s(
|
|
114
116
|
f,
|
|
115
117
|
{
|
|
116
|
-
ref:
|
|
118
|
+
ref: o,
|
|
117
119
|
role: "menuitem",
|
|
118
120
|
className: e ? `motile-speed-dial__action ${e}` : "motile-speed-dial__action",
|
|
119
|
-
onClick:
|
|
120
|
-
...
|
|
121
|
+
onClick: r,
|
|
122
|
+
...a,
|
|
121
123
|
children: i
|
|
122
124
|
}
|
|
123
125
|
) : /* @__PURE__ */ s(
|
|
124
126
|
"button",
|
|
125
127
|
{
|
|
126
|
-
ref:
|
|
128
|
+
ref: o,
|
|
127
129
|
type: "button",
|
|
128
130
|
role: "menuitem",
|
|
129
131
|
className: e ? `motile-speed-dial__action ${e}` : "motile-speed-dial__action",
|
|
130
|
-
onClick:
|
|
131
|
-
...
|
|
132
|
+
onClick: r,
|
|
133
|
+
...a,
|
|
132
134
|
children: i
|
|
133
135
|
}
|
|
134
136
|
);
|
|
@@ -54,5 +54,11 @@ export interface TextareaProps extends React.TextareaHTMLAttributes<HTMLTextArea
|
|
|
54
54
|
* @default false
|
|
55
55
|
*/
|
|
56
56
|
autoSize?: boolean | AutoSizeConfig;
|
|
57
|
+
/**
|
|
58
|
+
* 모바일에서 이 입력에 포커스된 채 스크롤하면 포커스를 해제해 소프트 키보드를
|
|
59
|
+
* 닫습니다 (useAutoBlur 내장). 데스크톱(비터치)에는 영향이 없습니다.
|
|
60
|
+
* @default false
|
|
61
|
+
*/
|
|
62
|
+
autoBlur?: boolean;
|
|
57
63
|
}
|
|
58
64
|
export declare const Textarea: React.ForwardRefExoticComponent<TextareaProps & React.RefAttributes<HTMLTextAreaElement>>;
|
|
@@ -1,60 +1,64 @@
|
|
|
1
|
-
import { jsxs as m, jsx as
|
|
2
|
-
import { forwardRef as
|
|
1
|
+
import { jsxs as m, jsx as R } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as X, useRef as C, useState as Z, useMemo as F, useEffect as z, useLayoutEffect as ee } from "react";
|
|
3
|
+
import { useAutoBlur as te } from "../../hooks/useAutoBlur.js";
|
|
3
4
|
import './Textarea.css';/* empty css */
|
|
4
|
-
const
|
|
5
|
+
const oe = X(
|
|
5
6
|
({
|
|
6
|
-
autoFocus:
|
|
7
|
-
autoSelect:
|
|
8
|
-
isError:
|
|
7
|
+
autoFocus: y = !1,
|
|
8
|
+
autoSelect: _ = !1,
|
|
9
|
+
isError: j,
|
|
9
10
|
errorMessage: o,
|
|
10
|
-
className:
|
|
11
|
+
className: I,
|
|
11
12
|
value: n,
|
|
12
13
|
color: b,
|
|
13
|
-
style:
|
|
14
|
+
style: E,
|
|
14
15
|
maxLength: f,
|
|
15
16
|
label: l,
|
|
16
17
|
placeholder: v,
|
|
17
18
|
rows: d = 4,
|
|
18
|
-
resize:
|
|
19
|
+
resize: S = "none",
|
|
19
20
|
autoSize: s = !1,
|
|
21
|
+
autoBlur: W = !1,
|
|
20
22
|
...H
|
|
21
|
-
},
|
|
22
|
-
const
|
|
23
|
+
}, k) => {
|
|
24
|
+
const A = C(null), r = k || A, B = C(null);
|
|
25
|
+
te({ containerRef: B, enabled: W });
|
|
26
|
+
const [c, D] = Z({ height: void 0, isMaxHeight: !1 }), p = j ?? !!o, t = F(() => typeof s == "boolean" ? s ? { minRows: d, maxRows: void 0 } : void 0 : s ? {
|
|
23
27
|
minRows: s.minRows ?? d,
|
|
24
28
|
maxRows: s.maxRows
|
|
25
29
|
} : void 0, [s, d]);
|
|
26
|
-
|
|
27
|
-
if (
|
|
30
|
+
z(() => {
|
|
31
|
+
if (y && r.current) {
|
|
28
32
|
const a = setTimeout(() => {
|
|
29
|
-
|
|
33
|
+
r.current && (r.current.focus(), _ && r.current.select());
|
|
30
34
|
}, 50);
|
|
31
35
|
return () => clearTimeout(a);
|
|
32
36
|
}
|
|
33
|
-
}, [
|
|
34
|
-
if (!t || !
|
|
35
|
-
const a =
|
|
37
|
+
}, [y, _]), ee(() => {
|
|
38
|
+
if (!t || !r.current) return;
|
|
39
|
+
const a = r.current;
|
|
36
40
|
if (!(n && String(n).length > 0) && c.height === void 0)
|
|
37
41
|
return;
|
|
38
42
|
a.style.height = "auto";
|
|
39
|
-
const
|
|
40
|
-
let
|
|
41
|
-
x !== void 0 &&
|
|
43
|
+
const M = a.scrollHeight, h = window.getComputedStyle(a), N = parseInt(h.lineHeight, 10), O = parseInt(h.paddingTop, 10), Q = parseInt(h.paddingBottom, 10), U = parseInt(h.borderTopWidth, 10), V = parseInt(h.borderBottomWidth, 10), T = O + Q + U + V, x = t.minRows ? N * t.minRows + T : void 0, u = t.maxRows ? N * t.maxRows + T : void 0;
|
|
44
|
+
let i = M, w = !1;
|
|
45
|
+
x !== void 0 && i < x && (i = x), u !== void 0 && i > u && (i = u, w = !0), a.style.height = `${i}px`, D(($) => i !== $.height || w !== $.isMaxHeight ? { height: i, isMaxHeight: w } : $);
|
|
42
46
|
}, [n, t]);
|
|
43
|
-
const e = "motile-textarea",
|
|
47
|
+
const e = "motile-textarea", P = [
|
|
44
48
|
e,
|
|
45
49
|
p && `${e}--error`,
|
|
46
50
|
p && `${e}--shake`,
|
|
47
51
|
l && `${e}--with-label`,
|
|
48
|
-
|
|
49
|
-
].filter(Boolean).join(" "),
|
|
52
|
+
I
|
|
53
|
+
].filter(Boolean).join(" "), Y = [
|
|
50
54
|
`${e}-wrapper`,
|
|
51
55
|
l && `${e}-wrapper--with-label`
|
|
52
|
-
].filter(Boolean).join(" "),
|
|
56
|
+
].filter(Boolean).join(" "), q = [
|
|
53
57
|
`${e}__label`,
|
|
54
58
|
p && `${e}__label--error`
|
|
55
|
-
].filter(Boolean).join(" "),
|
|
56
|
-
...
|
|
57
|
-
resize: t ? "none" :
|
|
59
|
+
].filter(Boolean).join(" "), G = b ? { "--motile-textarea-color": b } : void 0, J = {
|
|
60
|
+
...E,
|
|
61
|
+
resize: t ? "none" : S,
|
|
58
62
|
...t ? {
|
|
59
63
|
// 계산된 후에만 height 적용 (첫 렌더에서는 native rows 사용)
|
|
60
64
|
...c.height !== void 0 && { height: c.height },
|
|
@@ -62,24 +66,24 @@ const z = Q(
|
|
|
62
66
|
...c.height !== void 0 && { minHeight: "auto" },
|
|
63
67
|
overflowY: c.isMaxHeight ? "auto" : "hidden"
|
|
64
68
|
} : {}
|
|
65
|
-
},
|
|
69
|
+
}, K = n ? String(n).length : 0, g = f !== void 0, L = [
|
|
66
70
|
H["aria-describedby"],
|
|
67
71
|
o ? `${e}-error` : void 0
|
|
68
72
|
].filter(Boolean).join(" ") || void 0;
|
|
69
|
-
return /* @__PURE__ */ m("div", { className: `${e}-root`, children: [
|
|
70
|
-
/* @__PURE__ */ m("div", { className:
|
|
71
|
-
l && /* @__PURE__ */
|
|
72
|
-
/* @__PURE__ */
|
|
73
|
+
return /* @__PURE__ */ m("div", { className: `${e}-root`, ref: B, children: [
|
|
74
|
+
/* @__PURE__ */ m("div", { className: Y, style: G, children: [
|
|
75
|
+
l && /* @__PURE__ */ R("label", { className: q, children: l }),
|
|
76
|
+
/* @__PURE__ */ R(
|
|
73
77
|
"textarea",
|
|
74
78
|
{
|
|
75
79
|
...H,
|
|
76
|
-
"aria-describedby":
|
|
77
|
-
ref:
|
|
78
|
-
className:
|
|
80
|
+
"aria-describedby": L,
|
|
81
|
+
ref: r,
|
|
82
|
+
className: P,
|
|
79
83
|
value: n,
|
|
80
84
|
maxLength: f,
|
|
81
85
|
rows: (t == null ? void 0 : t.minRows) ?? d,
|
|
82
|
-
style:
|
|
86
|
+
style: J,
|
|
83
87
|
placeholder: l ? v || " " : v
|
|
84
88
|
}
|
|
85
89
|
)
|
|
@@ -89,7 +93,7 @@ const z = Q(
|
|
|
89
93
|
{
|
|
90
94
|
className: `${e}__helper-text ${o && g ? `${e}__helper-text--both` : o ? `${e}__helper-text--error-only` : `${e}__helper-text--counter-only`}`,
|
|
91
95
|
children: [
|
|
92
|
-
o && /* @__PURE__ */
|
|
96
|
+
o && /* @__PURE__ */ R(
|
|
93
97
|
"span",
|
|
94
98
|
{
|
|
95
99
|
id: `${e}-error`,
|
|
@@ -99,7 +103,7 @@ const z = Q(
|
|
|
99
103
|
}
|
|
100
104
|
),
|
|
101
105
|
g && /* @__PURE__ */ m("span", { className: `${e}__counter`, children: [
|
|
102
|
-
|
|
106
|
+
K,
|
|
103
107
|
"/",
|
|
104
108
|
f
|
|
105
109
|
] })
|
|
@@ -109,7 +113,7 @@ const z = Q(
|
|
|
109
113
|
] });
|
|
110
114
|
}
|
|
111
115
|
);
|
|
112
|
-
|
|
116
|
+
oe.displayName = "Textarea";
|
|
113
117
|
export {
|
|
114
|
-
|
|
118
|
+
oe as Textarea
|
|
115
119
|
};
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
export type { UseAutoBlurOptions } from './useAutoBlur';
|
|
2
|
+
export { useAutoBlur } from './useAutoBlur';
|
|
1
3
|
export type { UseClickOutsideOptions } from './useClickOutside';
|
|
2
4
|
export { useClickOutside } from './useClickOutside';
|
|
3
5
|
export type { UseEscapeKeyOptions } from './useEscapeKey';
|
package/dist/hooks/index.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { useAutoBlur as r } from "./useAutoBlur.js";
|
|
2
|
+
import { useClickOutside as s } from "./useClickOutside.js";
|
|
3
|
+
import { useEscapeKey as p } from "./useEscapeKey.js";
|
|
4
|
+
import { useMediaQuery as m } from "./useMediaQuery.js";
|
|
5
|
+
import { useScrollLock as c } from "./useScrollLock.js";
|
|
5
6
|
export {
|
|
6
|
-
r as
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
r as useAutoBlur,
|
|
8
|
+
s as useClickOutside,
|
|
9
|
+
p as useEscapeKey,
|
|
10
|
+
m as useMediaQuery,
|
|
11
|
+
c as useScrollLock
|
|
10
12
|
};
|