@mmapp/react 0.1.0-alpha.19 → 0.1.0-alpha.20

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.
@@ -0,0 +1,116 @@
1
+ // src/player/atoms/actions.tsx
2
+ import { useState, useCallback } from "react";
3
+ import { jsx, jsxs } from "react/jsx-runtime";
4
+ var VARIANT_STYLES = {
5
+ primary: { background: "#3182ce", color: "#fff", border: "1px solid #3182ce" },
6
+ secondary: { background: "#edf2f7", color: "#4a5568", border: "1px solid #e2e8f0" },
7
+ outline: { background: "transparent", color: "#3182ce", border: "1px solid #3182ce" },
8
+ ghost: { background: "transparent", color: "#4a5568", border: "1px solid transparent" },
9
+ danger: { background: "#e53e3e", color: "#fff", border: "1px solid #e53e3e" },
10
+ destructive: { background: "#e53e3e", color: "#fff", border: "1px solid #e53e3e" },
11
+ success: { background: "#38a169", color: "#fff", border: "1px solid #38a169" },
12
+ link: { background: "transparent", color: "#3182ce", border: "none", textDecoration: "underline" },
13
+ default: { background: "#fff", color: "#1a202c", border: "1px solid #e2e8f0" }
14
+ };
15
+ var SIZE_STYLES = {
16
+ xs: { padding: "2px 8px", fontSize: 11 },
17
+ sm: { padding: "4px 12px", fontSize: 13 },
18
+ md: { padding: "6px 16px", fontSize: 14 },
19
+ lg: { padding: "8px 24px", fontSize: 16 },
20
+ xl: { padding: "12px 32px", fontSize: 18 }
21
+ };
22
+ var Button = ({
23
+ children,
24
+ label,
25
+ value,
26
+ onClick,
27
+ variant,
28
+ size,
29
+ disabled,
30
+ loading: loadingProp,
31
+ icon,
32
+ iconRight,
33
+ fullWidth,
34
+ className,
35
+ style
36
+ }) => {
37
+ const [isLoading, setIsLoading] = useState(false);
38
+ const text = children ?? label ?? value;
39
+ const isDisabled = Boolean(disabled) || isLoading || Boolean(loadingProp);
40
+ const vs = VARIANT_STYLES[variant ?? "default"] ?? VARIANT_STYLES.default;
41
+ const ss = SIZE_STYLES[size ?? "md"] ?? SIZE_STYLES.md;
42
+ const handleClick = useCallback(async (e) => {
43
+ if (isDisabled) return;
44
+ if (typeof onClick === "function") {
45
+ const result = onClick(e);
46
+ if (result && typeof result === "object" && typeof result.then === "function") {
47
+ setIsLoading(true);
48
+ try {
49
+ await result;
50
+ } finally {
51
+ setIsLoading(false);
52
+ }
53
+ }
54
+ }
55
+ }, [onClick, isDisabled]);
56
+ return /* @__PURE__ */ jsxs(
57
+ "button",
58
+ {
59
+ className,
60
+ disabled: isDisabled,
61
+ onClick: handleClick,
62
+ style: {
63
+ ...vs,
64
+ ...ss,
65
+ borderRadius: 6,
66
+ cursor: isDisabled ? "not-allowed" : "pointer",
67
+ opacity: isDisabled ? 0.6 : 1,
68
+ fontWeight: 500,
69
+ display: "inline-flex",
70
+ alignItems: "center",
71
+ justifyContent: "center",
72
+ gap: 6,
73
+ width: fullWidth ? "100%" : void 0,
74
+ transition: "opacity 0.15s, background 0.15s",
75
+ ...style
76
+ },
77
+ children: [
78
+ isLoading || loadingProp ? "\u23F3" : icon ? String(icon) : null,
79
+ text != null ? typeof text === "string" || typeof text === "number" ? String(text) : text : null,
80
+ iconRight ? String(iconRight) : null
81
+ ]
82
+ }
83
+ );
84
+ };
85
+ var Link = ({ children, href, to, label, onClick, external, className, style }) => {
86
+ const text = children ?? label;
87
+ const target = href ?? to;
88
+ const handleClick = useCallback((e) => {
89
+ if (typeof onClick === "function") {
90
+ e.preventDefault();
91
+ onClick(e);
92
+ }
93
+ }, [onClick]);
94
+ return /* @__PURE__ */ jsx(
95
+ "a",
96
+ {
97
+ href: target ?? "#",
98
+ className,
99
+ onClick: handleClick,
100
+ target: external ? "_blank" : void 0,
101
+ rel: external ? "noopener noreferrer" : void 0,
102
+ style: {
103
+ color: "#3182ce",
104
+ textDecoration: "none",
105
+ cursor: "pointer",
106
+ fontSize: 14,
107
+ ...style
108
+ },
109
+ children: text != null ? String(text) : target ?? "Link"
110
+ }
111
+ );
112
+ };
113
+ export {
114
+ Button,
115
+ Link
116
+ };