motile-ui 1.0.2 → 1.0.4
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/Accordion/Accordion.css +1 -0
- package/dist/components/Accordion/Accordion.js +121 -0
- package/dist/components/Badge/Badge.css +1 -0
- package/dist/components/Badge/Badge.js +24 -0
- package/dist/components/Button/Button.css +1 -0
- package/dist/components/Button/Button.js +73 -0
- package/dist/components/Checkbox/Checkbox.css +1 -0
- package/dist/components/Checkbox/Checkbox.js +69 -0
- package/dist/components/Dock/Dock.css +1 -0
- package/dist/components/Dock/Dock.js +151 -0
- package/dist/components/Drawer/Drawer.css +1 -0
- package/dist/components/Drawer/Drawer.js +277 -0
- package/dist/components/Input/Input.css +1 -0
- package/dist/components/Input/Input.js +122 -0
- package/dist/components/Modal/Modal.css +1 -0
- package/dist/components/Modal/Modal.js +235 -0
- package/dist/components/Popover/Popover.css +1 -0
- package/dist/components/Popover/Popover.js +197 -0
- package/dist/components/Sheet/Sheet.css +1 -0
- package/dist/components/Sheet/Sheet.js +285 -0
- package/dist/components/Skeleton/Skeleton.css +1 -0
- package/dist/components/Skeleton/Skeleton.js +30 -0
- package/dist/components/SpeedDial/SpeedDial.css +1 -0
- package/dist/components/SpeedDial/SpeedDial.js +149 -0
- package/dist/components/Switch/Switch.css +1 -0
- package/dist/components/Switch/Switch.js +31 -0
- package/dist/components/Textarea/Textarea.css +1 -0
- package/dist/components/Textarea/Textarea.js +115 -0
- package/dist/components/Toast/Toast.css +1 -0
- package/dist/components/Toast/Toast.js +184 -0
- package/dist/components/Toast/useToast.js +30 -0
- package/dist/components/Tooltip/Tooltip.css +1 -0
- package/dist/components/Tooltip/Tooltip.js +323 -0
- package/dist/hooks/useClickOutside.js +24 -0
- package/dist/hooks/useEscapeKey.js +18 -0
- package/dist/hooks/useHistoryClose.js +42 -0
- package/dist/hooks/useScrollLock.js +73 -0
- package/dist/index.js +42 -0
- package/dist/utils/FloatingArrow.js +55 -0
- package/dist/utils/Slot.js +44 -0
- package/package.json +88 -6
- package/dist/index.css +0 -1
- package/dist/motile-ui.es.js +0 -2492
- package/dist/motile-ui.umd.js +0 -2
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import { jsxs as $, jsx as g } from "react/jsx-runtime";
|
|
2
|
+
import h, { useCallback as R, useId as k, useRef as I, useMemo as N, createContext as j, useContext as E } from "react";
|
|
3
|
+
import './Popover.css';/* empty css */
|
|
4
|
+
import { Slot as T } from "../../utils/Slot.js";
|
|
5
|
+
import { useClickOutside as A } from "../../hooks/useClickOutside.js";
|
|
6
|
+
import { useEscapeKey as B } from "../../hooks/useEscapeKey.js";
|
|
7
|
+
import { FloatingArrow as F } from "../../utils/FloatingArrow.js";
|
|
8
|
+
const S = j(null);
|
|
9
|
+
function C() {
|
|
10
|
+
const t = E(S);
|
|
11
|
+
if (!t)
|
|
12
|
+
throw new Error("Popover components must be used within Popover.Root");
|
|
13
|
+
return t;
|
|
14
|
+
}
|
|
15
|
+
function K({
|
|
16
|
+
value: t,
|
|
17
|
+
defaultValue: s = !1,
|
|
18
|
+
onChange: o
|
|
19
|
+
}) {
|
|
20
|
+
const e = t !== void 0, [r, i] = h.useState(s), l = e ? t : r, a = R(
|
|
21
|
+
(c) => {
|
|
22
|
+
const m = typeof c == "function" ? c(l) : c;
|
|
23
|
+
e || i(m), o == null || o(m);
|
|
24
|
+
},
|
|
25
|
+
[e, o, l]
|
|
26
|
+
);
|
|
27
|
+
return [l, a];
|
|
28
|
+
}
|
|
29
|
+
function M({
|
|
30
|
+
children: t,
|
|
31
|
+
position: s = "top",
|
|
32
|
+
align: o = "center",
|
|
33
|
+
variant: e = "filled",
|
|
34
|
+
showArrow: r = !1,
|
|
35
|
+
zIndex: i = 10,
|
|
36
|
+
color: l,
|
|
37
|
+
bounceCount: a = 0,
|
|
38
|
+
open: c,
|
|
39
|
+
defaultOpen: m = !1,
|
|
40
|
+
onOpenChange: f,
|
|
41
|
+
onClickOutside: u,
|
|
42
|
+
onDismiss: v,
|
|
43
|
+
autoClose: d = !0
|
|
44
|
+
}) {
|
|
45
|
+
const n = k().replace(/:/g, ""), x = I(null), w = I(null), b = I(null), [P, p] = K({
|
|
46
|
+
value: c,
|
|
47
|
+
defaultValue: m,
|
|
48
|
+
onChange: f
|
|
49
|
+
}), y = N(
|
|
50
|
+
() => ({
|
|
51
|
+
open: P,
|
|
52
|
+
setOpen: p,
|
|
53
|
+
position: s,
|
|
54
|
+
align: o,
|
|
55
|
+
variant: e,
|
|
56
|
+
showArrow: r,
|
|
57
|
+
zIndex: i,
|
|
58
|
+
color: l,
|
|
59
|
+
autoClose: d,
|
|
60
|
+
bounceCount: a,
|
|
61
|
+
onOpenChange: f,
|
|
62
|
+
onClickOutside: u,
|
|
63
|
+
onDismiss: v,
|
|
64
|
+
triggerId: `${n}-trigger`,
|
|
65
|
+
contentId: `${n}-content`,
|
|
66
|
+
triggerRef: x,
|
|
67
|
+
contentRef: w,
|
|
68
|
+
wrapperRef: b
|
|
69
|
+
}),
|
|
70
|
+
[
|
|
71
|
+
P,
|
|
72
|
+
p,
|
|
73
|
+
s,
|
|
74
|
+
o,
|
|
75
|
+
e,
|
|
76
|
+
r,
|
|
77
|
+
i,
|
|
78
|
+
l,
|
|
79
|
+
d,
|
|
80
|
+
a,
|
|
81
|
+
f,
|
|
82
|
+
u,
|
|
83
|
+
v,
|
|
84
|
+
n
|
|
85
|
+
]
|
|
86
|
+
);
|
|
87
|
+
return /* @__PURE__ */ g(S.Provider, { value: y, children: /* @__PURE__ */ g("div", { ref: b, className: "motile-popover-wrapper", children: t }) });
|
|
88
|
+
}
|
|
89
|
+
function V({ children: t, asChild: s = !1 }) {
|
|
90
|
+
const { open: o, setOpen: e, triggerId: r, contentId: i, triggerRef: l } = C(), a = R(() => {
|
|
91
|
+
e((c) => !c);
|
|
92
|
+
}, [e]);
|
|
93
|
+
return s ? /* @__PURE__ */ g(
|
|
94
|
+
T,
|
|
95
|
+
{
|
|
96
|
+
ref: (c) => {
|
|
97
|
+
l.current = c;
|
|
98
|
+
},
|
|
99
|
+
id: r,
|
|
100
|
+
"aria-expanded": o,
|
|
101
|
+
"aria-controls": i,
|
|
102
|
+
onClick: a,
|
|
103
|
+
children: t
|
|
104
|
+
}
|
|
105
|
+
) : /* @__PURE__ */ g(
|
|
106
|
+
"button",
|
|
107
|
+
{
|
|
108
|
+
ref: l,
|
|
109
|
+
id: r,
|
|
110
|
+
type: "button",
|
|
111
|
+
"aria-expanded": o,
|
|
112
|
+
"aria-controls": i,
|
|
113
|
+
onClick: a,
|
|
114
|
+
children: t
|
|
115
|
+
}
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
function q({
|
|
119
|
+
children: t,
|
|
120
|
+
className: s = "",
|
|
121
|
+
style: o
|
|
122
|
+
}) {
|
|
123
|
+
const {
|
|
124
|
+
open: e,
|
|
125
|
+
setOpen: r,
|
|
126
|
+
position: i,
|
|
127
|
+
align: l,
|
|
128
|
+
variant: a,
|
|
129
|
+
showArrow: c,
|
|
130
|
+
zIndex: m,
|
|
131
|
+
color: f,
|
|
132
|
+
autoClose: u,
|
|
133
|
+
bounceCount: v,
|
|
134
|
+
onClickOutside: d,
|
|
135
|
+
onDismiss: n,
|
|
136
|
+
contentId: x,
|
|
137
|
+
contentRef: w,
|
|
138
|
+
wrapperRef: b
|
|
139
|
+
} = C();
|
|
140
|
+
if (B({
|
|
141
|
+
handler: R(
|
|
142
|
+
(p) => {
|
|
143
|
+
u && (n == null || n(p), p.defaultPrevented || r(!1));
|
|
144
|
+
},
|
|
145
|
+
[u, n, r]
|
|
146
|
+
),
|
|
147
|
+
enabled: e
|
|
148
|
+
}), A({
|
|
149
|
+
refs: [b],
|
|
150
|
+
handler: R(
|
|
151
|
+
(p) => {
|
|
152
|
+
u && (d == null || d(p), n == null || n(p), p.defaultPrevented || r(!1));
|
|
153
|
+
},
|
|
154
|
+
[u, d, n, r]
|
|
155
|
+
),
|
|
156
|
+
enabled: e
|
|
157
|
+
}), !e) return null;
|
|
158
|
+
const P = v !== 0;
|
|
159
|
+
return /* @__PURE__ */ $(
|
|
160
|
+
"div",
|
|
161
|
+
{
|
|
162
|
+
ref: w,
|
|
163
|
+
id: x,
|
|
164
|
+
role: "dialog",
|
|
165
|
+
"aria-modal": "false",
|
|
166
|
+
className: `motile-popover-content motile-popover-content--${a} ${s}`,
|
|
167
|
+
"data-placement": i,
|
|
168
|
+
"data-align": l,
|
|
169
|
+
"data-bounce": P ? "true" : "false",
|
|
170
|
+
style: {
|
|
171
|
+
zIndex: m,
|
|
172
|
+
...f && { "--motile-popover-color": f },
|
|
173
|
+
"--bounce-count": v,
|
|
174
|
+
...o
|
|
175
|
+
},
|
|
176
|
+
children: [
|
|
177
|
+
c && /* @__PURE__ */ g(
|
|
178
|
+
F,
|
|
179
|
+
{
|
|
180
|
+
className: "motile-popover-arrow",
|
|
181
|
+
variant: a,
|
|
182
|
+
color: f || (a === "filled" ? "var(--motile-ui-popover, var(--motile-theme, #3b82f6))" : "var(--motile-ui-popover, var(--motile-theme, #e5e7eb))")
|
|
183
|
+
}
|
|
184
|
+
),
|
|
185
|
+
t
|
|
186
|
+
]
|
|
187
|
+
}
|
|
188
|
+
);
|
|
189
|
+
}
|
|
190
|
+
const U = {
|
|
191
|
+
Root: M,
|
|
192
|
+
Trigger: V,
|
|
193
|
+
Content: q
|
|
194
|
+
};
|
|
195
|
+
export {
|
|
196
|
+
U as Popover
|
|
197
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.motile-sheet__overlay{position:fixed;top:0;right:0;bottom:0;left:0;background-color:#0000;transition:background-color .3s ease;overscroll-behavior:contain;display:flex}.motile-sheet__overlay--left{justify-content:flex-start}.motile-sheet__overlay--right{justify-content:flex-end}.motile-sheet__overlay--visible{background-color:#0006}.motile-sheet__content{position:fixed;top:0;bottom:0;margin:0;width:100%;max-width:var(--sheet-max-width, 600px);height:100vh;height:100dvh;background-color:#fff;box-shadow:0 0 30px #00000026;display:flex;flex-direction:column;transition:transform .3s ease;will-change:transform;overscroll-behavior:contain;box-sizing:border-box}.motile-sheet__content--left{left:0;border-right:1px solid #e5e7eb;transform:translate(-100%)}.motile-sheet__content--left.motile-sheet__content--visible{transform:translate(0)}.motile-sheet__content--right{right:0;border-left:1px solid #e5e7eb;transform:translate(100%)}.motile-sheet__content--right.motile-sheet__content--visible{transform:translate(0)}@media (max-width: 768px){.motile-sheet__content{max-width:none;width:100%}}.motile-sheet__header{height:56px;display:flex;align-items:center;justify-content:space-between;gap:12px;padding:0 20px;flex-shrink:0;border-bottom:1px solid #e5e7eb;background-color:#fff;user-select:none;-webkit-user-select:none}.motile-sheet__header button{color:inherit}@media (min-width: 769px){.motile-sheet__header{height:64px;padding:0 24px}}.motile-sheet__back-button{display:flex;align-items:center;gap:12px;background:none;border:none;padding:8px 12px 8px 4px;margin-left:-4px;cursor:pointer;border-radius:8px;color:#111827;transition:all .2s ease;font-size:16px;font-weight:600}.motile-sheet__back-button:hover{background-color:#f3f4f6}.motile-sheet__back-button:active{transform:scale(.98)}.motile-sheet__chevron{width:24px;height:24px;flex-shrink:0}.motile-sheet__title{flex:1;min-width:0;margin:0;font-size:18px;font-weight:600;color:#111827;line-height:1.4;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}@media (max-width: 768px){.motile-sheet__title{font-size:16px}}.motile-sheet__close{display:flex;align-items:center;justify-content:center;min-width:32px;min-height:32px;padding:0;margin:0;background:none;border:none;border-radius:6px;cursor:pointer;color:#6b7280;transition:all .15s ease;flex-shrink:0;-webkit-tap-highlight-color:transparent}.motile-sheet__close:hover{background-color:#f3f4f6;color:#111827}.motile-sheet__close:active{transform:scale(.95);background-color:#e5e7eb}.motile-sheet__close:focus-visible{outline:2px solid #3b82f6;outline-offset:2px}.motile-sheet__body{flex:1 1 auto;min-height:0;overflow-y:auto;overflow-x:hidden;padding:20px;-webkit-overflow-scrolling:touch;overscroll-behavior:contain;width:100%;box-sizing:border-box;background-color:#fff}@media (min-width: 769px){.motile-sheet__body{padding:20px 24px}}.motile-sheet__body::-webkit-scrollbar{width:6px}.motile-sheet__body::-webkit-scrollbar-track{background:transparent}.motile-sheet__body::-webkit-scrollbar-thumb{background-color:#0003;border-radius:3px}.motile-sheet__body::-webkit-scrollbar-thumb:hover{background-color:#0000004d}@media (prefers-color-scheme: dark){.motile-sheet__content{background-color:#1f2937;box-shadow:0 0 30px #00000080}.motile-sheet__content--left{border-right-color:#374151}.motile-sheet__content--right{border-left-color:#374151}.motile-sheet__header{background-color:#1f2937;border-bottom-color:#374151}.motile-sheet__back-button{color:#f9fafb}.motile-sheet__back-button:hover{background-color:#374151}.motile-sheet__title{color:#f9fafb}.motile-sheet__body{background-color:#1f2937}.motile-sheet__body::-webkit-scrollbar-thumb{background-color:#fff3}.motile-sheet__body::-webkit-scrollbar-thumb:hover{background-color:#ffffff4d}.motile-sheet__close{color:#9ca3af}.motile-sheet__close:hover{background-color:#374151;color:#f9fafb}.motile-sheet__close:active{background-color:#4b5563}}@media (prefers-reduced-motion: reduce){.motile-sheet__content,.motile-sheet__overlay{transition:none}}@media (hover: none) and (pointer: coarse){.motile-sheet__header{height:60px}.motile-sheet__chevron{width:26px;height:26px}}
|
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
import { jsx as u, jsxs as $ } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback as v, useState as S, useEffect as k, useId as F, useRef as x, useMemo as A, createContext as T, useContext as w } from "react";
|
|
3
|
+
import { createPortal as K } from "react-dom";
|
|
4
|
+
import { Slot as g } from "../../utils/Slot.js";
|
|
5
|
+
import { useScrollLock as N } from "../../hooks/useScrollLock.js";
|
|
6
|
+
import { useClickOutside as H } from "../../hooks/useClickOutside.js";
|
|
7
|
+
import { useEscapeKey as V } from "../../hooks/useEscapeKey.js";
|
|
8
|
+
import { useHistoryClose as q } from "../../hooks/useHistoryClose.js";
|
|
9
|
+
import './Sheet.css';/* empty css */
|
|
10
|
+
const I = T(null);
|
|
11
|
+
function _() {
|
|
12
|
+
const e = w(I);
|
|
13
|
+
if (!e)
|
|
14
|
+
throw new Error("Sheet components must be used within Sheet.Root");
|
|
15
|
+
return e;
|
|
16
|
+
}
|
|
17
|
+
function z({
|
|
18
|
+
value: e,
|
|
19
|
+
defaultValue: n = !1,
|
|
20
|
+
onChange: o
|
|
21
|
+
}) {
|
|
22
|
+
const t = e !== void 0, [i, a] = S(n), s = t ? e : i, l = v(
|
|
23
|
+
(r) => {
|
|
24
|
+
const f = typeof r == "function" ? r(s) : r;
|
|
25
|
+
t || a(f), o == null || o(f);
|
|
26
|
+
},
|
|
27
|
+
[t, o, s]
|
|
28
|
+
);
|
|
29
|
+
return [s, l];
|
|
30
|
+
}
|
|
31
|
+
function B({
|
|
32
|
+
children: e,
|
|
33
|
+
position: n = "right",
|
|
34
|
+
closeOnBackdrop: o = !0,
|
|
35
|
+
maxWidth: t = "600px",
|
|
36
|
+
zIndex: i = 1e3,
|
|
37
|
+
open: a,
|
|
38
|
+
defaultOpen: s = !1,
|
|
39
|
+
onOpenChange: l
|
|
40
|
+
}) {
|
|
41
|
+
const r = F().replace(/:/g, ""), f = x(null), h = x(null), [d, c] = z({
|
|
42
|
+
value: a,
|
|
43
|
+
defaultValue: s,
|
|
44
|
+
onChange: l
|
|
45
|
+
}), { isClosingFromHistory: p, navigateAndClose: y } = q({
|
|
46
|
+
isOpen: d,
|
|
47
|
+
onClose: () => c(!1)
|
|
48
|
+
}), m = A(
|
|
49
|
+
() => ({
|
|
50
|
+
open: d,
|
|
51
|
+
setOpen: c,
|
|
52
|
+
position: n,
|
|
53
|
+
closeOnBackdrop: o,
|
|
54
|
+
maxWidth: t,
|
|
55
|
+
zIndex: i,
|
|
56
|
+
onOpenChange: l,
|
|
57
|
+
triggerId: `${r}-trigger`,
|
|
58
|
+
contentId: `${r}-content`,
|
|
59
|
+
overlayRef: f,
|
|
60
|
+
sheetRef: h,
|
|
61
|
+
isClosingFromHistory: p,
|
|
62
|
+
navigateAndClose: y
|
|
63
|
+
}),
|
|
64
|
+
[
|
|
65
|
+
d,
|
|
66
|
+
c,
|
|
67
|
+
n,
|
|
68
|
+
o,
|
|
69
|
+
t,
|
|
70
|
+
i,
|
|
71
|
+
l,
|
|
72
|
+
r,
|
|
73
|
+
f,
|
|
74
|
+
h,
|
|
75
|
+
p,
|
|
76
|
+
y
|
|
77
|
+
]
|
|
78
|
+
);
|
|
79
|
+
return /* @__PURE__ */ u(I.Provider, { value: m, children: e });
|
|
80
|
+
}
|
|
81
|
+
function P({ children: e, asChild: n = !1 }) {
|
|
82
|
+
const { open: o, setOpen: t, triggerId: i, contentId: a } = _(), s = v(() => {
|
|
83
|
+
t((l) => !l);
|
|
84
|
+
}, [t]);
|
|
85
|
+
return n ? /* @__PURE__ */ u(
|
|
86
|
+
g,
|
|
87
|
+
{
|
|
88
|
+
id: i,
|
|
89
|
+
"aria-expanded": o,
|
|
90
|
+
"aria-controls": a,
|
|
91
|
+
onClick: s,
|
|
92
|
+
children: e
|
|
93
|
+
}
|
|
94
|
+
) : /* @__PURE__ */ u(
|
|
95
|
+
"button",
|
|
96
|
+
{
|
|
97
|
+
id: i,
|
|
98
|
+
type: "button",
|
|
99
|
+
"aria-expanded": o,
|
|
100
|
+
"aria-controls": a,
|
|
101
|
+
onClick: s,
|
|
102
|
+
children: e
|
|
103
|
+
}
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
function j({ children: e, container: n }) {
|
|
107
|
+
const { open: o } = _(), [t, i] = S(!1);
|
|
108
|
+
return k(() => {
|
|
109
|
+
i(!0);
|
|
110
|
+
}, []), !t || !o ? null : K(e, n || document.body);
|
|
111
|
+
}
|
|
112
|
+
function E({ className: e = "", style: n }) {
|
|
113
|
+
const { open: o, setOpen: t, position: i, closeOnBackdrop: a, zIndex: s, overlayRef: l } = _(), [r, f] = S(!1), [h, d] = S(!1), c = typeof a == "boolean" ? { clickOutside: a } : {
|
|
114
|
+
escapeKey: a.escapeKey ?? !1,
|
|
115
|
+
clickOutside: a.clickOutside ?? !1
|
|
116
|
+
};
|
|
117
|
+
k(() => {
|
|
118
|
+
if (o)
|
|
119
|
+
f(!0);
|
|
120
|
+
else if (r) {
|
|
121
|
+
d(!1);
|
|
122
|
+
const m = setTimeout(() => {
|
|
123
|
+
f(!1);
|
|
124
|
+
}, 300);
|
|
125
|
+
return () => clearTimeout(m);
|
|
126
|
+
}
|
|
127
|
+
}, [o, r]), k(() => {
|
|
128
|
+
if (!r || !o) return;
|
|
129
|
+
const m = requestAnimationFrame(() => {
|
|
130
|
+
const b = requestAnimationFrame(() => {
|
|
131
|
+
d(!0);
|
|
132
|
+
});
|
|
133
|
+
return () => cancelAnimationFrame(b);
|
|
134
|
+
});
|
|
135
|
+
return () => cancelAnimationFrame(m);
|
|
136
|
+
}, [r, o]);
|
|
137
|
+
const p = v(
|
|
138
|
+
(m) => {
|
|
139
|
+
c.clickOutside && m.target === l.current && t(!1);
|
|
140
|
+
},
|
|
141
|
+
[c.clickOutside, t, l]
|
|
142
|
+
);
|
|
143
|
+
if (!r)
|
|
144
|
+
return null;
|
|
145
|
+
const y = {
|
|
146
|
+
zIndex: s,
|
|
147
|
+
...n
|
|
148
|
+
};
|
|
149
|
+
return /* @__PURE__ */ u(
|
|
150
|
+
"div",
|
|
151
|
+
{
|
|
152
|
+
ref: l,
|
|
153
|
+
className: `motile-sheet__overlay ${h ? "motile-sheet__overlay--visible" : ""} motile-sheet__overlay--${i} ${e}`,
|
|
154
|
+
style: y,
|
|
155
|
+
onClick: p,
|
|
156
|
+
role: "presentation"
|
|
157
|
+
}
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
function L({ children: e, className: n = "", style: o }) {
|
|
161
|
+
const {
|
|
162
|
+
open: t,
|
|
163
|
+
setOpen: i,
|
|
164
|
+
position: a,
|
|
165
|
+
closeOnBackdrop: s,
|
|
166
|
+
maxWidth: l,
|
|
167
|
+
zIndex: r,
|
|
168
|
+
contentId: f,
|
|
169
|
+
sheetRef: h,
|
|
170
|
+
isClosingFromHistory: d
|
|
171
|
+
} = _(), [c, p] = S(!1), [y, m] = S(!1), b = typeof s == "boolean" ? { escapeKey: s, clickOutside: s } : {
|
|
172
|
+
escapeKey: s.escapeKey ?? !1,
|
|
173
|
+
clickOutside: s.clickOutside ?? !1
|
|
174
|
+
};
|
|
175
|
+
if (N({
|
|
176
|
+
enabled: t,
|
|
177
|
+
allowedSelectors: [".motile-sheet__body"]
|
|
178
|
+
}), H({
|
|
179
|
+
refs: [h],
|
|
180
|
+
handler: () => i(!1),
|
|
181
|
+
enabled: t && b.clickOutside
|
|
182
|
+
}), V({
|
|
183
|
+
handler: () => i(!1),
|
|
184
|
+
enabled: t && b.escapeKey
|
|
185
|
+
}), k(() => {
|
|
186
|
+
if (t)
|
|
187
|
+
p(!0);
|
|
188
|
+
else if (c) {
|
|
189
|
+
m(!1);
|
|
190
|
+
const C = setTimeout(() => {
|
|
191
|
+
p(!1);
|
|
192
|
+
}, d ? 0 : 300);
|
|
193
|
+
return () => clearTimeout(C);
|
|
194
|
+
}
|
|
195
|
+
}, [t, c, d]), k(() => {
|
|
196
|
+
if (!c || !t || d) return;
|
|
197
|
+
const O = requestAnimationFrame(() => {
|
|
198
|
+
const C = requestAnimationFrame(() => {
|
|
199
|
+
m(!0);
|
|
200
|
+
});
|
|
201
|
+
return () => cancelAnimationFrame(C);
|
|
202
|
+
});
|
|
203
|
+
return () => cancelAnimationFrame(O);
|
|
204
|
+
}, [c, t, d]), !c)
|
|
205
|
+
return null;
|
|
206
|
+
const R = {
|
|
207
|
+
...l !== "600px" && { "--sheet-max-width": l },
|
|
208
|
+
zIndex: r + 1,
|
|
209
|
+
...o
|
|
210
|
+
};
|
|
211
|
+
return /* @__PURE__ */ u(
|
|
212
|
+
"div",
|
|
213
|
+
{
|
|
214
|
+
ref: h,
|
|
215
|
+
id: f,
|
|
216
|
+
className: `motile-sheet__content motile-sheet__content--${a} ${y ? "motile-sheet__content--visible" : ""} ${n}`,
|
|
217
|
+
style: R,
|
|
218
|
+
role: "dialog",
|
|
219
|
+
"aria-modal": "true",
|
|
220
|
+
children: e
|
|
221
|
+
}
|
|
222
|
+
);
|
|
223
|
+
}
|
|
224
|
+
function D({ children: e, className: n = "" }) {
|
|
225
|
+
return /* @__PURE__ */ u("div", { className: `motile-sheet__header ${n}`, children: e });
|
|
226
|
+
}
|
|
227
|
+
function M({ children: e, className: n = "" }) {
|
|
228
|
+
return /* @__PURE__ */ u("h2", { id: "sheet-title", className: `motile-sheet__title ${n}`, children: e });
|
|
229
|
+
}
|
|
230
|
+
function W({ children: e, className: n = "" }) {
|
|
231
|
+
return /* @__PURE__ */ u("div", { className: `motile-sheet__body ${n}`, children: e });
|
|
232
|
+
}
|
|
233
|
+
function G({ children: e, asChild: n = !1 }) {
|
|
234
|
+
const { setOpen: o } = _(), t = v(() => {
|
|
235
|
+
o(!1);
|
|
236
|
+
}, [o]);
|
|
237
|
+
return n ? /* @__PURE__ */ u(
|
|
238
|
+
g,
|
|
239
|
+
{
|
|
240
|
+
className: "motile-sheet__close",
|
|
241
|
+
onClick: t,
|
|
242
|
+
"aria-label": "닫기",
|
|
243
|
+
children: e
|
|
244
|
+
}
|
|
245
|
+
) : /* @__PURE__ */ u(
|
|
246
|
+
"button",
|
|
247
|
+
{
|
|
248
|
+
className: "motile-sheet__close",
|
|
249
|
+
onClick: t,
|
|
250
|
+
"aria-label": "닫기",
|
|
251
|
+
type: "button",
|
|
252
|
+
children: e || /* @__PURE__ */ $(
|
|
253
|
+
"svg",
|
|
254
|
+
{
|
|
255
|
+
width: "20",
|
|
256
|
+
height: "20",
|
|
257
|
+
viewBox: "0 0 24 24",
|
|
258
|
+
fill: "none",
|
|
259
|
+
stroke: "currentColor",
|
|
260
|
+
strokeWidth: "2",
|
|
261
|
+
strokeLinecap: "round",
|
|
262
|
+
strokeLinejoin: "round",
|
|
263
|
+
children: [
|
|
264
|
+
/* @__PURE__ */ u("line", { x1: "18", y1: "6", x2: "6", y2: "18" }),
|
|
265
|
+
/* @__PURE__ */ u("line", { x1: "6", y1: "6", x2: "18", y2: "18" })
|
|
266
|
+
]
|
|
267
|
+
}
|
|
268
|
+
)
|
|
269
|
+
}
|
|
270
|
+
);
|
|
271
|
+
}
|
|
272
|
+
const ne = {
|
|
273
|
+
Root: B,
|
|
274
|
+
Trigger: P,
|
|
275
|
+
Portal: j,
|
|
276
|
+
Overlay: E,
|
|
277
|
+
Content: L,
|
|
278
|
+
Header: D,
|
|
279
|
+
Title: M,
|
|
280
|
+
Body: W,
|
|
281
|
+
Close: G
|
|
282
|
+
};
|
|
283
|
+
export {
|
|
284
|
+
ne as Sheet
|
|
285
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.motile-skeleton{display:inline-block;position:relative;overflow:hidden;background-color:#e5e7eb}.motile-skeleton:after{content:"";position:absolute;top:0;left:0;right:0;bottom:0;background:linear-gradient(90deg,#fff0,#fff6,#fff0);transform:translate(-100%);animation:motile-skeleton-shimmer 1.5s ease-in-out infinite}@keyframes motile-skeleton-shimmer{0%{transform:translate(-100%)}to{transform:translate(100%)}}@media (prefers-reduced-motion: reduce){.motile-skeleton:after{animation:none;display:none}}@media (prefers-color-scheme: dark){.motile-skeleton{background-color:#374151}.motile-skeleton:after{background:linear-gradient(90deg,#fff0,#ffffff1a,#fff0)}}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { jsx as p } from "react/jsx-runtime";
|
|
2
|
+
import './Skeleton.css';/* empty css */
|
|
3
|
+
const f = ({
|
|
4
|
+
width: o = "100%",
|
|
5
|
+
height: r = "1rem",
|
|
6
|
+
borderRadius: s = "4px",
|
|
7
|
+
className: a,
|
|
8
|
+
style: i,
|
|
9
|
+
...l
|
|
10
|
+
}) => {
|
|
11
|
+
const n = ["motile-skeleton", a].filter(Boolean).join(" "), t = (e, c) => e === void 0 ? c : typeof e == "number" ? `${e}px` : e, m = {
|
|
12
|
+
...i,
|
|
13
|
+
width: t(o, "100%"),
|
|
14
|
+
height: t(r, "1rem"),
|
|
15
|
+
borderRadius: t(s, "4px")
|
|
16
|
+
};
|
|
17
|
+
return /* @__PURE__ */ p(
|
|
18
|
+
"div",
|
|
19
|
+
{
|
|
20
|
+
className: n,
|
|
21
|
+
style: m,
|
|
22
|
+
"aria-busy": "true",
|
|
23
|
+
"aria-live": "polite",
|
|
24
|
+
...l
|
|
25
|
+
}
|
|
26
|
+
);
|
|
27
|
+
};
|
|
28
|
+
export {
|
|
29
|
+
f as Skeleton
|
|
30
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.motile-speed-dial{position:relative;display:inline-flex;align-items:center;justify-content:center}.motile-speed-dial__trigger{position:relative;z-index:2;display:flex;align-items:center;justify-content:center;width:56px;height:56px;padding:0;border:none;border-radius:50%;background-color:var(--motile-speeddial-color, var(--motile-theme, #3b82f6));color:#fff;box-shadow:0 4px 12px #00000026,0 2px 4px #0000001a;cursor:pointer;transition:all .2s cubic-bezier(.4,0,.2,1);font-size:16px;font-weight:500}.motile-speed-dial__trigger:hover{filter:brightness(.9);box-shadow:0 6px 16px #0003,0 3px 6px #00000026;transform:scale(1.05)}.motile-speed-dial__trigger:active{filter:brightness(.85);transform:scale(.95);box-shadow:0 2px 8px #00000026,0 1px 3px #0000001a}.motile-speed-dial__trigger[aria-expanded=true]{filter:brightness(.75);transform:rotate(45deg)}.motile-speed-dial__actions{position:absolute;display:flex;gap:12px;z-index:1}.motile-speed-dial__actions[data-direction=up]{flex-direction:column-reverse;bottom:100%;left:50%;transform:translate(-50%);margin-bottom:12px}.motile-speed-dial__actions[data-direction=down]{flex-direction:column;top:100%;left:50%;transform:translate(-50%);margin-top:12px}.motile-speed-dial__actions[data-direction=left]{flex-direction:row-reverse;right:100%;top:50%;transform:translateY(-50%);margin-right:12px}.motile-speed-dial__actions[data-direction=right]{flex-direction:row;left:100%;top:50%;transform:translateY(-50%);margin-left:12px}.motile-speed-dial__action{display:flex;align-items:center;justify-content:center;width:48px;height:48px;padding:0;border:none;border-radius:50%;background-color:#fff;color:#374151;box-shadow:0 2px 8px #0000001a,0 1px 3px #00000014;cursor:pointer;transition:all .2s cubic-bezier(.4,0,.2,1);font-size:14px}.motile-speed-dial__action:hover{background-color:#f3f4f6;box-shadow:0 4px 12px #00000026,0 2px 4px #0000001a;transform:scale(1.08)}.motile-speed-dial__action:active{transform:scale(.95);box-shadow:0 1px 4px #0000001a,0 0 2px #00000014}.motile-speed-dial__actions[data-direction=up] .motile-speed-dial__action{animation:motile-speed-dial-slide-up .3s cubic-bezier(.34,1.56,.64,1) backwards;animation-delay:calc(var(--action-index) * .05s)}.motile-speed-dial__actions[data-direction=down] .motile-speed-dial__action{animation:motile-speed-dial-slide-down .3s cubic-bezier(.34,1.56,.64,1) backwards;animation-delay:calc(var(--action-index) * .05s)}.motile-speed-dial__actions[data-direction=left] .motile-speed-dial__action{animation:motile-speed-dial-slide-left .3s cubic-bezier(.34,1.56,.64,1) backwards;animation-delay:calc(var(--action-index) * .05s)}.motile-speed-dial__actions[data-direction=right] .motile-speed-dial__action{animation:motile-speed-dial-slide-right .3s cubic-bezier(.34,1.56,.64,1) backwards;animation-delay:calc(var(--action-index) * .05s)}@keyframes motile-speed-dial-slide-up{0%{opacity:0;transform:translateY(10px)}to{opacity:1;transform:translateY(0)}}@keyframes motile-speed-dial-slide-down{0%{opacity:0;transform:translateY(-10px)}to{opacity:1;transform:translateY(0)}}@keyframes motile-speed-dial-slide-left{0%{opacity:0;transform:translate(10px)}to{opacity:1;transform:translate(0)}}@keyframes motile-speed-dial-slide-right{0%{opacity:0;transform:translate(-10px)}to{opacity:1;transform:translate(0)}}@media (prefers-reduced-motion: reduce){.motile-speed-dial__actions[data-direction=up] .motile-speed-dial__action,.motile-speed-dial__actions[data-direction=down] .motile-speed-dial__action,.motile-speed-dial__actions[data-direction=left] .motile-speed-dial__action,.motile-speed-dial__actions[data-direction=right] .motile-speed-dial__action{animation:none}}.motile-speed-dial__trigger:focus-visible,.motile-speed-dial__action:focus-visible{outline:2px solid #3b82f6;outline-offset:2px}@media (prefers-color-scheme: dark){.motile-speed-dial__trigger{box-shadow:0 4px 12px #0000004d,0 2px 4px #0003}.motile-speed-dial__trigger:hover{box-shadow:0 6px 16px #0006,0 3px 6px #0000004d}.motile-speed-dial__action{background-color:#374151;color:#f9fafb;box-shadow:0 2px 8px #0000004d,0 1px 3px #0003}.motile-speed-dial__action:hover{background-color:#4b5563;box-shadow:0 4px 12px #0006,0 2px 4px #0000004d}}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { jsx as s } from "react/jsx-runtime";
|
|
2
|
+
import m, { forwardRef as c, useRef as y, useId as b, createContext as R, useContext as h } from "react";
|
|
3
|
+
import { Slot as f } from "../../utils/Slot.js";
|
|
4
|
+
import { useClickOutside as v } from "../../hooks/useClickOutside.js";
|
|
5
|
+
import { useEscapeKey as A } from "../../hooks/useEscapeKey.js";
|
|
6
|
+
import './SpeedDial.css';/* empty css */
|
|
7
|
+
const _ = R(null), g = () => {
|
|
8
|
+
const e = h(_);
|
|
9
|
+
if (!e)
|
|
10
|
+
throw new Error(
|
|
11
|
+
"SpeedDial compound components must be used within SpeedDial.Root"
|
|
12
|
+
);
|
|
13
|
+
return e;
|
|
14
|
+
}, I = ({
|
|
15
|
+
open: e,
|
|
16
|
+
onOpenChange: t,
|
|
17
|
+
direction: i = "up",
|
|
18
|
+
color: d,
|
|
19
|
+
closeOnClickOutside: n = !0,
|
|
20
|
+
closeOnEscapeKey: a = !0,
|
|
21
|
+
children: o
|
|
22
|
+
}) => {
|
|
23
|
+
const l = y(null), r = b();
|
|
24
|
+
v({
|
|
25
|
+
refs: [l],
|
|
26
|
+
handler: () => {
|
|
27
|
+
n && t(!1);
|
|
28
|
+
},
|
|
29
|
+
enabled: e
|
|
30
|
+
}), A({
|
|
31
|
+
handler: () => {
|
|
32
|
+
a && t(!1);
|
|
33
|
+
},
|
|
34
|
+
enabled: e
|
|
35
|
+
});
|
|
36
|
+
const p = m.useMemo(
|
|
37
|
+
() => ({
|
|
38
|
+
open: e,
|
|
39
|
+
onOpenChange: t,
|
|
40
|
+
direction: i,
|
|
41
|
+
triggerId: r
|
|
42
|
+
}),
|
|
43
|
+
[e, t, i, r]
|
|
44
|
+
), u = d ? { "--motile-speeddial-color": d } : void 0;
|
|
45
|
+
return /* @__PURE__ */ s(_.Provider, { value: p, children: /* @__PURE__ */ s(
|
|
46
|
+
"div",
|
|
47
|
+
{
|
|
48
|
+
ref: l,
|
|
49
|
+
className: "motile-speed-dial",
|
|
50
|
+
style: u,
|
|
51
|
+
children: o
|
|
52
|
+
}
|
|
53
|
+
) });
|
|
54
|
+
}, S = c(({ className: e, onClick: t, children: i, asChild: d = !1, ...n }, a) => {
|
|
55
|
+
const { open: o, onOpenChange: l, triggerId: r } = g(), p = (u) => {
|
|
56
|
+
t == null || t(u), u.defaultPrevented || l(!o);
|
|
57
|
+
};
|
|
58
|
+
return d ? /* @__PURE__ */ s(
|
|
59
|
+
f,
|
|
60
|
+
{
|
|
61
|
+
ref: a,
|
|
62
|
+
id: r,
|
|
63
|
+
className: e ? `motile-speed-dial__trigger ${e}` : "motile-speed-dial__trigger",
|
|
64
|
+
"aria-expanded": o,
|
|
65
|
+
"aria-haspopup": "menu",
|
|
66
|
+
onClick: p,
|
|
67
|
+
...n,
|
|
68
|
+
children: i
|
|
69
|
+
}
|
|
70
|
+
) : /* @__PURE__ */ s(
|
|
71
|
+
"button",
|
|
72
|
+
{
|
|
73
|
+
ref: a,
|
|
74
|
+
type: "button",
|
|
75
|
+
id: r,
|
|
76
|
+
className: e ? `motile-speed-dial__trigger ${e}` : "motile-speed-dial__trigger",
|
|
77
|
+
"aria-expanded": o,
|
|
78
|
+
"aria-haspopup": "menu",
|
|
79
|
+
onClick: p,
|
|
80
|
+
...n,
|
|
81
|
+
children: i
|
|
82
|
+
}
|
|
83
|
+
);
|
|
84
|
+
});
|
|
85
|
+
S.displayName = "SpeedDial.Trigger";
|
|
86
|
+
const x = c(({ className: e, children: t, ...i }, d) => {
|
|
87
|
+
const { open: n, direction: a, triggerId: o } = g();
|
|
88
|
+
if (!n) return null;
|
|
89
|
+
const l = m.Children.map(t, (r, p) => m.isValidElement(r) ? m.cloneElement(r, {
|
|
90
|
+
style: {
|
|
91
|
+
"--action-index": p,
|
|
92
|
+
...r.props.style || {}
|
|
93
|
+
}
|
|
94
|
+
}) : r);
|
|
95
|
+
return /* @__PURE__ */ s(
|
|
96
|
+
"div",
|
|
97
|
+
{
|
|
98
|
+
ref: d,
|
|
99
|
+
role: "menu",
|
|
100
|
+
"aria-labelledby": o,
|
|
101
|
+
className: e ? `motile-speed-dial__actions ${e}` : "motile-speed-dial__actions",
|
|
102
|
+
"data-direction": a,
|
|
103
|
+
...i,
|
|
104
|
+
children: l
|
|
105
|
+
}
|
|
106
|
+
);
|
|
107
|
+
});
|
|
108
|
+
x.displayName = "SpeedDial.Actions";
|
|
109
|
+
const D = c(({ className: e, onClick: t, children: i, asChild: d = !1, ...n }, a) => {
|
|
110
|
+
const o = (l) => {
|
|
111
|
+
t == null || t(l);
|
|
112
|
+
};
|
|
113
|
+
return d ? /* @__PURE__ */ s(
|
|
114
|
+
f,
|
|
115
|
+
{
|
|
116
|
+
ref: a,
|
|
117
|
+
role: "menuitem",
|
|
118
|
+
className: e ? `motile-speed-dial__action ${e}` : "motile-speed-dial__action",
|
|
119
|
+
onClick: o,
|
|
120
|
+
...n,
|
|
121
|
+
children: i
|
|
122
|
+
}
|
|
123
|
+
) : /* @__PURE__ */ s(
|
|
124
|
+
"button",
|
|
125
|
+
{
|
|
126
|
+
ref: a,
|
|
127
|
+
type: "button",
|
|
128
|
+
role: "menuitem",
|
|
129
|
+
className: e ? `motile-speed-dial__action ${e}` : "motile-speed-dial__action",
|
|
130
|
+
onClick: o,
|
|
131
|
+
...n,
|
|
132
|
+
children: i
|
|
133
|
+
}
|
|
134
|
+
);
|
|
135
|
+
});
|
|
136
|
+
D.displayName = "SpeedDial.Action";
|
|
137
|
+
const P = {
|
|
138
|
+
Root: I,
|
|
139
|
+
Trigger: S,
|
|
140
|
+
Actions: x,
|
|
141
|
+
Action: D
|
|
142
|
+
};
|
|
143
|
+
export {
|
|
144
|
+
P as SpeedDial,
|
|
145
|
+
D as SpeedDialAction,
|
|
146
|
+
x as SpeedDialActions,
|
|
147
|
+
I as SpeedDialRoot,
|
|
148
|
+
S as SpeedDialTrigger
|
|
149
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.motile-switch-container{display:inline-flex;flex-direction:column;gap:4px}.motile-switch-wrapper{display:flex;align-items:center;gap:8px;cursor:pointer;position:relative;-webkit-user-select:none;user-select:none}.motile-switch-container--disabled .motile-switch-wrapper{cursor:not-allowed;opacity:.6}.motile-switch{position:absolute;opacity:0;width:0;height:0;margin:0;pointer-events:none}.motile-switch:focus{outline:none}.motile-switch__track{position:relative;width:44px;height:24px;background-color:#e5e7eb;border-radius:24px;transition:background-color .2s cubic-bezier(.4,0,.2,1);display:flex;align-items:center;flex-shrink:0;box-sizing:border-box}.motile-switch__thumb{position:absolute;width:18px;height:18px;background-color:#fff;border-radius:50%;left:3px;transition:transform .2s cubic-bezier(.4,0,.2,1);box-shadow:0 2px 4px #0000001a}.motile-switch:checked+.motile-switch__track{background-color:var( --motile-switch-color, var(--motile-ui-switch, var(--motile-theme, #3b82f6)) )}.motile-switch:checked+.motile-switch__track .motile-switch__thumb{transform:translate(20px)}.motile-switch:not(:checked)+.motile-switch__track:hover{background-color:#d1d5db}.motile-switch:checked+.motile-switch__track:hover{background-color:color-mix(in srgb,var( --motile-switch-color, var(--motile-ui-switch, var(--motile-theme, #3b82f6)) ) 90%,black)}.motile-switch:disabled+.motile-switch__track{background-color:#f3f4f6;cursor:not-allowed}.motile-switch:disabled:checked+.motile-switch__track{background-color:#d1d5db}.motile-switch:disabled+.motile-switch__track .motile-switch__thumb{box-shadow:none}.motile-switch--elastic+.motile-switch__track .motile-switch__thumb{transition:none;will-change:transform}.motile-switch--elastic:checked+.motile-switch__track .motile-switch__thumb{animation:switch-slide-on .35s cubic-bezier(.25,.1,.25,1);transform:translate(20px);transform-origin:left center}.motile-switch--elastic:not(:checked)+.motile-switch__track .motile-switch__thumb{animation:switch-slide-off .35s cubic-bezier(.25,.1,.25,1);transform:translate(0);transform-origin:right center}@keyframes switch-slide-on{0%{transform:translate(0) scaleX(1)}10%{transform:translate(.5px) scaleX(1.05)}25%{transform:translate(3px) scaleX(1.25)}45%{transform:translate(8px) scaleX(1.4)}65%{transform:translate(14px) scaleX(1.3)}85%{transform:translate(18.5px) scaleX(1.08)}95%{transform:translate(19.8px) scaleX(1.02)}to{transform:translate(20px) scaleX(1)}}@keyframes switch-slide-off{0%{transform:translate(20px) scaleX(1)}10%{transform:translate(19.5px) scaleX(1.05)}25%{transform:translate(17px) scaleX(1.25)}45%{transform:translate(12px) scaleX(1.4)}65%{transform:translate(6px) scaleX(1.3)}85%{transform:translate(1.5px) scaleX(1.08)}95%{transform:translate(.2px) scaleX(1.02)}to{transform:translate(0) scaleX(1)}}.motile-switch--bounce+.motile-switch__track .motile-switch__thumb{transition:none;will-change:transform}.motile-switch--bounce:checked+.motile-switch__track .motile-switch__thumb{animation:switch-bounce-on .65s cubic-bezier(.68,-.55,.27,1.55);transform:translate(20px)}.motile-switch--bounce:not(:checked)+.motile-switch__track .motile-switch__thumb{animation:switch-bounce-off .65s cubic-bezier(.68,-.55,.27,1.55);transform:translate(0)}@keyframes switch-bounce-on{0%{transform:translate(0)}60%{transform:translate(23px)}80%{transform:translate(18px)}95%{transform:translate(20.5px)}to{transform:translate(20px)}}@keyframes switch-bounce-off{0%{transform:translate(20px)}60%{transform:translate(-3px)}80%{transform:translate(2px)}95%{transform:translate(-.5px)}to{transform:translate(0)}}
|