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,31 @@
|
|
|
1
|
+
import { jsx as e, jsxs as h } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as p } from "react";
|
|
3
|
+
import './Switch.css';/* empty css */
|
|
4
|
+
const $ = p(
|
|
5
|
+
({ variant: t = "smooth", color: o, className: c, disabled: a, style: i, ...n }, l) => {
|
|
6
|
+
const s = "motile-switch", r = [
|
|
7
|
+
`${s}-container`,
|
|
8
|
+
`${s}-container--${t}`,
|
|
9
|
+
a && `${s}-container--disabled`
|
|
10
|
+
].filter(Boolean).join(" "), m = [s, `${s}--${t}`, c].filter(Boolean).join(" ");
|
|
11
|
+
return /* @__PURE__ */ e("div", { className: r, style: o ? { "--motile-switch-color": o } : void 0, children: /* @__PURE__ */ h("label", { className: `${s}-wrapper`, children: [
|
|
12
|
+
/* @__PURE__ */ e(
|
|
13
|
+
"input",
|
|
14
|
+
{
|
|
15
|
+
...n,
|
|
16
|
+
ref: l,
|
|
17
|
+
type: "checkbox",
|
|
18
|
+
className: m,
|
|
19
|
+
disabled: a,
|
|
20
|
+
style: i,
|
|
21
|
+
role: "switch"
|
|
22
|
+
}
|
|
23
|
+
),
|
|
24
|
+
/* @__PURE__ */ e("span", { className: `${s}__track`, children: /* @__PURE__ */ e("span", { className: `${s}__thumb` }) })
|
|
25
|
+
] }) });
|
|
26
|
+
}
|
|
27
|
+
);
|
|
28
|
+
$.displayName = "Switch";
|
|
29
|
+
export {
|
|
30
|
+
$ as Switch
|
|
31
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.motile-textarea-root{display:block;width:100%}.motile-textarea{width:100%;border:2px solid #e5e8eb;border-radius:12px;padding:12px 16px;font-size:16px;font-weight:400;color:#111827;background:#fff;outline:none;transition:none;min-height:120px;line-height:1.6;box-sizing:border-box;font-family:inherit;resize:none}.motile-textarea:hover:not(:disabled):not(:focus):not(.motile-textarea--error){border-color:#c9cdd2}.motile-textarea:focus{border:2px solid var( --motile-textarea-color, var(--motile-ui-textarea, var(--motile-theme, #3182f6)) )}.motile-textarea:disabled{background:#f9fafb;color:#9ca3af;cursor:not-allowed;border-color:#e5e7eb;resize:none}.motile-textarea.motile-textarea--error{border:2px solid #ef4444;background:#fef5f5}.motile-textarea.motile-textarea--error:focus{border:2px solid #ef4444;background:#fef5f5}.motile-textarea--shake{animation:motile-textarea-shake .5s ease-in-out}@keyframes motile-textarea-shake{0%{transform:translate(0)}15%{transform:translate(-10px)}30%{transform:translate(8px)}45%{transform:translate(-6px)}60%{transform:translate(4px)}75%{transform:translate(-2px)}to{transform:translate(0)}}.motile-textarea::placeholder{color:#9ca3af;opacity:1}.motile-textarea-wrapper{position:relative;width:100%}.motile-textarea--with-clear{padding-right:40px}.motile-textarea--with-clear:focus{padding-right:40px}.motile-textarea__clear-button{position:absolute;right:12px;top:12px;display:flex;align-items:center;justify-content:center;width:20px;height:20px;padding:0;background:transparent;border:none;color:#9ca3af;cursor:pointer;border-radius:4px;transition:background-color .2s ease,color .2s ease}.motile-textarea__clear-button:hover{background:#f3f4f6;color:#6b7280}.motile-textarea__clear-icon{width:16px;height:16px}@media (max-width: 768px){.motile-textarea{font-size:16px;padding:12px;min-height:100px}.motile-textarea:focus{border:2px solid var( --motile-textarea-color, var(--motile-ui-textarea, var(--motile-theme, #3182f6)) )}.motile-textarea--with-clear{padding-right:36px}.motile-textarea--with-clear:focus{padding-right:36px}}@supports (-webkit-touch-callout: none){.motile-textarea{-webkit-tap-highlight-color:transparent}}.motile-textarea__helper-text{display:flex;align-items:flex-start;margin-top:4px;min-height:16px;gap:8px}.motile-textarea__helper-text--both{justify-content:space-between}.motile-textarea__helper-text--error-only{justify-content:flex-start}.motile-textarea__helper-text--counter-only{justify-content:flex-end}.motile-textarea__error-message{font-size:12px;color:#ef4444;line-height:16px;flex:1}.motile-textarea__counter{font-size:12px;color:#9ca3af;line-height:16px;white-space:nowrap;flex-shrink:0}.motile-textarea__label{position:absolute;left:16px;top:16px;font-size:16px;color:#9ca3af;pointer-events:none;transition:all .2s ease;background:transparent;padding:0;z-index:1}.motile-textarea--with-label::placeholder{opacity:0}.motile-textarea--with-label:focus::placeholder{opacity:1}.motile-textarea-wrapper:has(.motile-textarea:focus) .motile-textarea__label,.motile-textarea-wrapper:has(.motile-textarea:not(:placeholder-shown)) .motile-textarea__label{top:0;transform:translateY(-50%);font-size:12px;color:var( --motile-textarea-color, var(--motile-ui-textarea, var(--motile-theme, #3182f6)) );background:#fff;padding:0 4px}.motile-textarea-wrapper:has(.motile-textarea:focus) .motile-textarea__label--error,.motile-textarea-wrapper:has(.motile-textarea:not(:placeholder-shown)) .motile-textarea__label--error{color:#ef4444}.motile-textarea.motile-textarea--with-label{padding-top:12px;padding-bottom:12px}@media (max-width: 768px){.motile-textarea__label{font-size:16px;left:12px;top:16px}.motile-textarea-wrapper:has(.motile-textarea:focus) .motile-textarea__label,.motile-textarea-wrapper:has(.motile-textarea:not(:placeholder-shown)) .motile-textarea__label{font-size:12px}}.motile-textarea{scrollbar-width:thin;scrollbar-color:rgba(0,0,0,.2) transparent}.motile-textarea::-webkit-scrollbar{width:6px}.motile-textarea::-webkit-scrollbar-track{background:transparent}.motile-textarea::-webkit-scrollbar-thumb{background-color:#0003;border-radius:3px;transition:background-color .2s ease}.motile-textarea::-webkit-scrollbar-thumb:hover{background-color:#0000004d}.motile-textarea::-webkit-scrollbar-thumb:active{background-color:#0006}@media (prefers-color-scheme: dark){.motile-textarea{scrollbar-color:rgba(255,255,255,.2) transparent}.motile-textarea::-webkit-scrollbar-thumb{background-color:#fff3}.motile-textarea::-webkit-scrollbar-thumb:hover{background-color:#ffffff4d}.motile-textarea::-webkit-scrollbar-thumb:active{background-color:#fff6}}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { jsxs as m, jsx as y } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as Q, useRef as U, useState as V, useMemo as X, useEffect as Z, useLayoutEffect as F } from "react";
|
|
3
|
+
import './Textarea.css';/* empty css */
|
|
4
|
+
const z = Q(
|
|
5
|
+
({
|
|
6
|
+
autoFocus: _ = !1,
|
|
7
|
+
autoSelect: R = !1,
|
|
8
|
+
isError: T,
|
|
9
|
+
errorMessage: o,
|
|
10
|
+
className: C,
|
|
11
|
+
value: n,
|
|
12
|
+
color: b,
|
|
13
|
+
style: j,
|
|
14
|
+
maxLength: f,
|
|
15
|
+
label: l,
|
|
16
|
+
placeholder: v,
|
|
17
|
+
rows: d = 4,
|
|
18
|
+
resize: I = "none",
|
|
19
|
+
autoSize: s = !1,
|
|
20
|
+
...H
|
|
21
|
+
}, E) => {
|
|
22
|
+
const S = U(null), i = E || S, [c, W] = V({ height: void 0, isMaxHeight: !1 }), p = T ?? !!o, t = X(() => typeof s == "boolean" ? s ? { minRows: d, maxRows: void 0 } : void 0 : s ? {
|
|
23
|
+
minRows: s.minRows ?? d,
|
|
24
|
+
maxRows: s.maxRows
|
|
25
|
+
} : void 0, [s, d]);
|
|
26
|
+
Z(() => {
|
|
27
|
+
if (_ && i.current) {
|
|
28
|
+
const a = setTimeout(() => {
|
|
29
|
+
i.current && (i.current.focus(), R && i.current.select());
|
|
30
|
+
}, 50);
|
|
31
|
+
return () => clearTimeout(a);
|
|
32
|
+
}
|
|
33
|
+
}, [_, R]), F(() => {
|
|
34
|
+
if (!t || !i.current) return;
|
|
35
|
+
const a = i.current;
|
|
36
|
+
if (!(n && String(n).length > 0) && c.height === void 0)
|
|
37
|
+
return;
|
|
38
|
+
a.style.height = "auto";
|
|
39
|
+
const J = a.scrollHeight, h = window.getComputedStyle(a), B = parseInt(h.lineHeight, 10), K = parseInt(h.paddingTop, 10), L = parseInt(h.paddingBottom, 10), M = parseInt(h.borderTopWidth, 10), O = parseInt(h.borderBottomWidth, 10), N = K + L + M + O, x = t.minRows ? B * t.minRows + N : void 0, w = t.maxRows ? B * t.maxRows + N : void 0;
|
|
40
|
+
let r = J, u = !1;
|
|
41
|
+
x !== void 0 && r < x && (r = x), w !== void 0 && r > w && (r = w, u = !0), a.style.height = `${r}px`, W(($) => r !== $.height || u !== $.isMaxHeight ? { height: r, isMaxHeight: u } : $);
|
|
42
|
+
}, [n, t]);
|
|
43
|
+
const e = "motile-textarea", k = [
|
|
44
|
+
e,
|
|
45
|
+
p && `${e}--error`,
|
|
46
|
+
p && `${e}--shake`,
|
|
47
|
+
l && `${e}--with-label`,
|
|
48
|
+
C
|
|
49
|
+
].filter(Boolean).join(" "), D = [
|
|
50
|
+
`${e}-wrapper`,
|
|
51
|
+
l && `${e}-wrapper--with-label`
|
|
52
|
+
].filter(Boolean).join(" "), P = [
|
|
53
|
+
`${e}__label`,
|
|
54
|
+
p && `${e}__label--error`
|
|
55
|
+
].filter(Boolean).join(" "), Y = b ? { "--motile-textarea-color": b } : void 0, q = {
|
|
56
|
+
...j,
|
|
57
|
+
resize: t ? "none" : I,
|
|
58
|
+
...t ? {
|
|
59
|
+
// 계산된 후에만 height 적용 (첫 렌더에서는 native rows 사용)
|
|
60
|
+
...c.height !== void 0 && { height: c.height },
|
|
61
|
+
// 계산된 후에만 minHeight 오버라이드
|
|
62
|
+
...c.height !== void 0 && { minHeight: "auto" },
|
|
63
|
+
overflowY: c.isMaxHeight ? "auto" : "hidden"
|
|
64
|
+
} : {}
|
|
65
|
+
}, A = n ? String(n).length : 0, g = f !== void 0, G = [
|
|
66
|
+
H["aria-describedby"],
|
|
67
|
+
o ? `${e}-error` : void 0
|
|
68
|
+
].filter(Boolean).join(" ") || void 0;
|
|
69
|
+
return /* @__PURE__ */ m("div", { className: `${e}-root`, children: [
|
|
70
|
+
/* @__PURE__ */ m("div", { className: D, style: Y, children: [
|
|
71
|
+
l && /* @__PURE__ */ y("label", { className: P, children: l }),
|
|
72
|
+
/* @__PURE__ */ y(
|
|
73
|
+
"textarea",
|
|
74
|
+
{
|
|
75
|
+
...H,
|
|
76
|
+
"aria-describedby": G,
|
|
77
|
+
ref: i,
|
|
78
|
+
className: k,
|
|
79
|
+
value: n,
|
|
80
|
+
maxLength: f,
|
|
81
|
+
rows: (t == null ? void 0 : t.minRows) ?? d,
|
|
82
|
+
style: q,
|
|
83
|
+
placeholder: l ? v || " " : v
|
|
84
|
+
}
|
|
85
|
+
)
|
|
86
|
+
] }),
|
|
87
|
+
(o || g) && /* @__PURE__ */ m(
|
|
88
|
+
"div",
|
|
89
|
+
{
|
|
90
|
+
className: `${e}__helper-text ${o && g ? `${e}__helper-text--both` : o ? `${e}__helper-text--error-only` : `${e}__helper-text--counter-only`}`,
|
|
91
|
+
children: [
|
|
92
|
+
o && /* @__PURE__ */ y(
|
|
93
|
+
"span",
|
|
94
|
+
{
|
|
95
|
+
id: `${e}-error`,
|
|
96
|
+
className: `${e}__error-message`,
|
|
97
|
+
role: "alert",
|
|
98
|
+
children: o
|
|
99
|
+
}
|
|
100
|
+
),
|
|
101
|
+
g && /* @__PURE__ */ m("span", { className: `${e}__counter`, children: [
|
|
102
|
+
A,
|
|
103
|
+
"/",
|
|
104
|
+
f
|
|
105
|
+
] })
|
|
106
|
+
]
|
|
107
|
+
}
|
|
108
|
+
)
|
|
109
|
+
] });
|
|
110
|
+
}
|
|
111
|
+
);
|
|
112
|
+
z.displayName = "Textarea";
|
|
113
|
+
export {
|
|
114
|
+
z as Textarea
|
|
115
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.motile-toast-container{position:fixed;pointer-events:none;display:flex;flex-direction:column;gap:8px}.motile-toast-container{top:0;left:0;right:0;align-items:center;padding:calc(env(safe-area-inset-top,0px) + 16px) 16px 16px 16px}@media (min-width: 768px){.motile-toast-container{top:0;left:auto;right:0;align-items:flex-end;padding:16px;max-width:400px}}.motile-toast{pointer-events:auto;display:inline-flex;align-items:flex-start;width:calc(100vw - 32px);min-width:200px;padding:12px 16px;background:#000000d9;border-radius:8px;backdrop-filter:blur(10px);-webkit-backdrop-filter:blur(10px);box-shadow:0 2px 8px #00000026;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,sans-serif;-webkit-font-smoothing:antialiased;-webkit-user-select:none;user-select:none;-webkit-tap-highlight-color:transparent;will-change:transform,opacity;animation:slideDown .3s ease-out}@media (min-width: 768px){.motile-toast{width:auto;max-width:320px;animation:slideInRight .3s ease-out}}.motile-toast--exiting{animation:fadeOut .15s ease-out forwards}.motile-toast__icon{flex-shrink:0;width:18px;height:18px;display:flex;align-items:center;justify-content:center;color:#fff;margin-right:8px;margin-top:1px}.motile-toast--success .motile-toast__icon{color:#4ade80}.motile-toast--error .motile-toast__icon{color:#f87171}.motile-toast--warning .motile-toast__icon{color:#fbbf24}.motile-toast--info .motile-toast__icon{color:#60a5fa}.motile-toast__message{flex:1;min-width:0;font-size:14px;font-weight:500;line-height:1.4;color:#fff;word-wrap:break-word;word-break:break-word;overflow-wrap:break-word}@keyframes slideDown{0%{opacity:0;transform:translateY(-16px)}to{opacity:1;transform:translateY(0)}}@keyframes slideInRight{0%{opacity:0;transform:translate(16px)}to{opacity:1;transform:translate(0)}}@keyframes fadeOut{to{opacity:0;transform:scale(.95)}}@media (prefers-color-scheme: dark){.motile-toast{background:#fffffff2}.motile-toast__message,.motile-toast__icon{color:#18181b}.motile-toast--success .motile-toast__icon{color:#22c55e}.motile-toast--error .motile-toast__icon{color:#ef4444}.motile-toast--warning .motile-toast__icon{color:#f59e0b}.motile-toast--info .motile-toast__icon{color:#3b82f6}}@media (prefers-reduced-motion: reduce){.motile-toast{animation:none!important}}.motile-toast *{user-select:none;-webkit-user-select:none}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { jsxs as s, jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import { useState as w, useEffect as g, useCallback as f, useMemo as p, createContext as L, useContext as y } from "react";
|
|
3
|
+
import { createPortal as I } from "react-dom";
|
|
4
|
+
import './Toast.css';/* empty css */
|
|
5
|
+
const C = L(null);
|
|
6
|
+
function V() {
|
|
7
|
+
const e = y(C);
|
|
8
|
+
if (!e) {
|
|
9
|
+
if (typeof window > "u")
|
|
10
|
+
return {
|
|
11
|
+
toasts: [],
|
|
12
|
+
addToast: () => ""
|
|
13
|
+
};
|
|
14
|
+
throw new Error("useToastContext must be used within ToastProvider");
|
|
15
|
+
}
|
|
16
|
+
return e;
|
|
17
|
+
}
|
|
18
|
+
function $({ toast: e, onRemove: a }) {
|
|
19
|
+
const [i, c] = w(!1), l = f(() => {
|
|
20
|
+
c(!0), setTimeout(() => {
|
|
21
|
+
a(e.id);
|
|
22
|
+
}, 250);
|
|
23
|
+
}, [e.id, a]);
|
|
24
|
+
g(() => {
|
|
25
|
+
const h = setTimeout(l, e.duration);
|
|
26
|
+
return () => {
|
|
27
|
+
clearTimeout(h);
|
|
28
|
+
};
|
|
29
|
+
}, [l, e.duration]);
|
|
30
|
+
const d = p(() => e.variant === "success" ? /* @__PURE__ */ s(
|
|
31
|
+
"svg",
|
|
32
|
+
{
|
|
33
|
+
width: "20",
|
|
34
|
+
height: "20",
|
|
35
|
+
viewBox: "0 0 20 20",
|
|
36
|
+
fill: "none",
|
|
37
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
38
|
+
children: [
|
|
39
|
+
/* @__PURE__ */ t("circle", { cx: "10", cy: "10", r: "9", fill: "currentColor", opacity: "0.2" }),
|
|
40
|
+
/* @__PURE__ */ t(
|
|
41
|
+
"path",
|
|
42
|
+
{
|
|
43
|
+
d: "M6 10L8.5 12.5L14 7",
|
|
44
|
+
stroke: "currentColor",
|
|
45
|
+
strokeWidth: "2",
|
|
46
|
+
strokeLinecap: "round",
|
|
47
|
+
strokeLinejoin: "round"
|
|
48
|
+
}
|
|
49
|
+
)
|
|
50
|
+
]
|
|
51
|
+
}
|
|
52
|
+
) : e.variant === "error" ? /* @__PURE__ */ s(
|
|
53
|
+
"svg",
|
|
54
|
+
{
|
|
55
|
+
width: "20",
|
|
56
|
+
height: "20",
|
|
57
|
+
viewBox: "0 0 20 20",
|
|
58
|
+
fill: "none",
|
|
59
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
60
|
+
children: [
|
|
61
|
+
/* @__PURE__ */ t("circle", { cx: "10", cy: "10", r: "9", fill: "currentColor", opacity: "0.2" }),
|
|
62
|
+
/* @__PURE__ */ t(
|
|
63
|
+
"path",
|
|
64
|
+
{
|
|
65
|
+
d: "M7 7L13 13M13 7L7 13",
|
|
66
|
+
stroke: "currentColor",
|
|
67
|
+
strokeWidth: "2",
|
|
68
|
+
strokeLinecap: "round"
|
|
69
|
+
}
|
|
70
|
+
)
|
|
71
|
+
]
|
|
72
|
+
}
|
|
73
|
+
) : e.variant === "warning" ? /* @__PURE__ */ s(
|
|
74
|
+
"svg",
|
|
75
|
+
{
|
|
76
|
+
width: "20",
|
|
77
|
+
height: "20",
|
|
78
|
+
viewBox: "0 0 20 20",
|
|
79
|
+
fill: "none",
|
|
80
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
81
|
+
children: [
|
|
82
|
+
/* @__PURE__ */ t("path", { d: "M10 2L2 17H18L10 2Z", fill: "currentColor", opacity: "0.2" }),
|
|
83
|
+
/* @__PURE__ */ t(
|
|
84
|
+
"path",
|
|
85
|
+
{
|
|
86
|
+
d: "M10 7V11M10 14V14.5",
|
|
87
|
+
stroke: "currentColor",
|
|
88
|
+
strokeWidth: "2",
|
|
89
|
+
strokeLinecap: "round"
|
|
90
|
+
}
|
|
91
|
+
)
|
|
92
|
+
]
|
|
93
|
+
}
|
|
94
|
+
) : e.variant === "info" ? /* @__PURE__ */ s(
|
|
95
|
+
"svg",
|
|
96
|
+
{
|
|
97
|
+
width: "20",
|
|
98
|
+
height: "20",
|
|
99
|
+
viewBox: "0 0 20 20",
|
|
100
|
+
fill: "none",
|
|
101
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
102
|
+
children: [
|
|
103
|
+
/* @__PURE__ */ t("circle", { cx: "10", cy: "10", r: "9", fill: "currentColor", opacity: "0.2" }),
|
|
104
|
+
/* @__PURE__ */ t(
|
|
105
|
+
"path",
|
|
106
|
+
{
|
|
107
|
+
d: "M10 7V7.5M10 10V14",
|
|
108
|
+
stroke: "currentColor",
|
|
109
|
+
strokeWidth: "2",
|
|
110
|
+
strokeLinecap: "round"
|
|
111
|
+
}
|
|
112
|
+
)
|
|
113
|
+
]
|
|
114
|
+
}
|
|
115
|
+
) : null, [e.variant]), n = "motile-toast", u = [
|
|
116
|
+
n,
|
|
117
|
+
`${n}--${e.variant}`,
|
|
118
|
+
i && `${n}--exiting`
|
|
119
|
+
].filter(Boolean).join(" ");
|
|
120
|
+
return /* @__PURE__ */ s(
|
|
121
|
+
"div",
|
|
122
|
+
{
|
|
123
|
+
className: u,
|
|
124
|
+
role: "status",
|
|
125
|
+
"aria-live": "polite",
|
|
126
|
+
"aria-atomic": "true",
|
|
127
|
+
"data-toast-id": e.id,
|
|
128
|
+
children: [
|
|
129
|
+
d && /* @__PURE__ */ t("div", { className: `${n}__icon`, children: d }),
|
|
130
|
+
/* @__PURE__ */ t("div", { className: `${n}__message`, children: e.message })
|
|
131
|
+
]
|
|
132
|
+
}
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
function j({ children: e, zIndex: a = 9999 }) {
|
|
136
|
+
const [i, c] = w([]), [l, d] = w(!1);
|
|
137
|
+
g(() => {
|
|
138
|
+
d(!0);
|
|
139
|
+
}, []);
|
|
140
|
+
const n = f(
|
|
141
|
+
(r, m = "default", o) => {
|
|
142
|
+
const v = `toast-${Date.now()}-${Math.random()}`, k = {
|
|
143
|
+
id: v,
|
|
144
|
+
message: r,
|
|
145
|
+
variant: m,
|
|
146
|
+
duration: (o == null ? void 0 : o.duration) ?? 4e3,
|
|
147
|
+
zIndex: o == null ? void 0 : o.zIndex,
|
|
148
|
+
createdAt: Date.now()
|
|
149
|
+
};
|
|
150
|
+
return c((M) => [k, ...M]), v;
|
|
151
|
+
},
|
|
152
|
+
[]
|
|
153
|
+
), u = f((r) => {
|
|
154
|
+
c((m) => m.filter((o) => o.id !== r));
|
|
155
|
+
}, []), h = p(
|
|
156
|
+
() => ({
|
|
157
|
+
toasts: i,
|
|
158
|
+
addToast: n
|
|
159
|
+
}),
|
|
160
|
+
[i, n]
|
|
161
|
+
), x = i.filter(
|
|
162
|
+
(r) => r.zIndex !== void 0
|
|
163
|
+
), T = x.length > 0 ? Math.max(...x.map((r) => r.zIndex)) : a;
|
|
164
|
+
return /* @__PURE__ */ s(C.Provider, { value: h, children: [
|
|
165
|
+
e,
|
|
166
|
+
l && I(
|
|
167
|
+
/* @__PURE__ */ t(
|
|
168
|
+
"div",
|
|
169
|
+
{
|
|
170
|
+
className: "motile-toast-container",
|
|
171
|
+
"aria-live": "polite",
|
|
172
|
+
"aria-label": "Notifications",
|
|
173
|
+
style: { zIndex: T },
|
|
174
|
+
children: i.map((r) => /* @__PURE__ */ t($, { toast: r, onRemove: u }, r.id))
|
|
175
|
+
}
|
|
176
|
+
),
|
|
177
|
+
document.body
|
|
178
|
+
)
|
|
179
|
+
] });
|
|
180
|
+
}
|
|
181
|
+
export {
|
|
182
|
+
j as ToastProvider,
|
|
183
|
+
V as useToastContext
|
|
184
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { useCallback as o } from "react";
|
|
2
|
+
import { useToastContext as i } from "./Toast.js";
|
|
3
|
+
function d() {
|
|
4
|
+
const { addToast: r } = i(), s = o(
|
|
5
|
+
(t, n) => r(t, "default", n),
|
|
6
|
+
[r]
|
|
7
|
+
), e = o(
|
|
8
|
+
(t, n) => r(t, "success", n),
|
|
9
|
+
[r]
|
|
10
|
+
), u = o(
|
|
11
|
+
(t, n) => r(t, "error", n),
|
|
12
|
+
[r]
|
|
13
|
+
), c = o(
|
|
14
|
+
(t, n) => r(t, "warning", n),
|
|
15
|
+
[r]
|
|
16
|
+
), a = o(
|
|
17
|
+
(t, n) => r(t, "info", n),
|
|
18
|
+
[r]
|
|
19
|
+
);
|
|
20
|
+
return {
|
|
21
|
+
show: s,
|
|
22
|
+
success: e,
|
|
23
|
+
error: u,
|
|
24
|
+
warning: c,
|
|
25
|
+
info: a
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
export {
|
|
29
|
+
d as useToast
|
|
30
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.motile-tooltip-trigger{position:relative;display:inline-block;line-height:normal;vertical-align:middle}.motile-tooltip-bubble{position:fixed;z-index:2147483647;padding:8px 12px;border-radius:8px;font-size:14px;font-weight:500;line-height:1.4;box-shadow:0 6px 20px #0003;opacity:0;pointer-events:none;transition:opacity .2s cubic-bezier(.16,1,.3,1),transform .2s cubic-bezier(.16,1,.3,1)}.motile-tooltip-bubble[data-placement=top]{transform:translateY(8px) scale(.96)}.motile-tooltip-bubble[data-placement=bottom]{transform:translateY(-8px) scale(.96)}.motile-tooltip-bubble[data-placement=left]{transform:translate(8px) scale(.96)}.motile-tooltip-bubble[data-placement=right]{transform:translate(-8px) scale(.96)}.motile-tooltip-bubble[data-open=true]{opacity:1;transform:translate(0) scale(1)}.motile-tooltip-bubble[data-keep-open]{pointer-events:auto}.motile-tooltip-bubble--filled{--arrow-color: var( --motile-tooltip-color, var(--motile-ui-tooltip, rgba(0, 0, 0, .9)) );background:var(--arrow-color);color:#fff}.motile-tooltip-bubble--outlined{--arrow-color: var(--motile-tooltip-color, var(--motile-ui-tooltip, #3b82f6));background:#fff;color:var(--arrow-color);border:1px solid var(--arrow-color)}.motile-tooltip-bubble.measuring{visibility:hidden!important;opacity:1!important;max-width:none!important;max-height:none!important;left:0!important;top:0!important}.motile-tooltip-arrow{position:absolute;pointer-events:none;z-index:1}.motile-tooltip-bubble[data-placement=top] .motile-tooltip-arrow{bottom:-7.25px;left:var(--arrow-offset, 50%);transform:translate(-50%) rotate(180deg)}.motile-tooltip-bubble[data-placement=bottom] .motile-tooltip-arrow{top:-7px;left:var(--arrow-offset, 50%);transform:translate(-50%) rotate(0)}.motile-tooltip-bubble[data-placement=left] .motile-tooltip-arrow{right:-9.25px;top:var(--arrow-offset, 50%);transform:translateY(-50%) rotate(90deg)}.motile-tooltip-bubble[data-placement=right] .motile-tooltip-arrow{left:-9.25px;top:var(--arrow-offset, 50%);transform:translateY(-50%) rotate(-90deg)}
|