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

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.
Files changed (52) hide show
  1. package/dist/actions-MFI2V4DX.mjs +116 -0
  2. package/dist/atoms/index.d.mts +2 -2
  3. package/dist/atoms/index.d.ts +2 -2
  4. package/dist/atoms/index.js +1 -1
  5. package/dist/atoms/index.mjs +1 -1
  6. package/dist/builtin-atoms-C-sNyYJl.d.mts +647 -0
  7. package/dist/builtin-atoms-C-sNyYJl.d.ts +647 -0
  8. package/dist/builtin-atoms-DCKrjG7i.d.mts +96 -0
  9. package/dist/builtin-atoms-DCKrjG7i.d.ts +96 -0
  10. package/dist/builtin-atoms-DRD3EwG6.d.mts +648 -0
  11. package/dist/builtin-atoms-DRD3EwG6.d.ts +648 -0
  12. package/dist/builtin-atoms-jt04b7Rw.d.mts +643 -0
  13. package/dist/builtin-atoms-jt04b7Rw.d.ts +643 -0
  14. package/dist/chunk-247T4GDJ.mjs +677 -0
  15. package/dist/chunk-3H6CR7E7.mjs +1924 -0
  16. package/dist/chunk-3PL6FL6I.mjs +96 -0
  17. package/dist/chunk-3SJSW3C4.mjs +2039 -0
  18. package/dist/chunk-5OI2VI57.mjs +1964 -0
  19. package/dist/chunk-CL6FYZ43.mjs +105 -0
  20. package/dist/chunk-ENQOCZI5.mjs +1938 -0
  21. package/dist/chunk-FB3WCZAU.mjs +512 -0
  22. package/dist/chunk-GLJ7VC7Z.mjs +684 -0
  23. package/dist/chunk-HHMWR6NA.mjs +504 -0
  24. package/dist/chunk-HULEMSN2.mjs +120 -0
  25. package/dist/chunk-J5MW6CRU.mjs +1938 -0
  26. package/dist/chunk-PNTTKNYU.mjs +677 -0
  27. package/dist/chunk-TY5OTJP4.mjs +684 -0
  28. package/dist/chunk-WV7DVCP6.mjs +513 -0
  29. package/dist/chunk-YFMPTGUF.mjs +677 -0
  30. package/dist/{chunk-2VJQJM7S.mjs → chunk-ZDWACXZN.mjs} +1 -1
  31. package/dist/composition-BJ6QQTWT.mjs +12 -0
  32. package/dist/composition-XBGKKCI7.mjs +57 -0
  33. package/dist/content-QVPFUG4P.mjs +246 -0
  34. package/dist/control-flow-CBREHWJW.mjs +35 -0
  35. package/dist/control-flow-FWBOI6SM.mjs +35 -0
  36. package/dist/control-flow-ZWUGCDSP.mjs +35 -0
  37. package/dist/data-WCMIZYKD.mjs +97 -0
  38. package/dist/grouping-E6F377VZ.mjs +204 -0
  39. package/dist/grouping-FRPOEXO3.mjs +233 -0
  40. package/dist/index.d.mts +4 -433
  41. package/dist/index.d.ts +4 -433
  42. package/dist/index.js +3648 -581
  43. package/dist/index.mjs +335 -1040
  44. package/dist/input-PUOZDNSI.mjs +222 -0
  45. package/dist/layout-RATDMCLP.mjs +106 -0
  46. package/dist/navigation-VCT7ZBMA.mjs +15 -0
  47. package/dist/navigation-WFV7YWOU.mjs +14 -0
  48. package/dist/player/index.d.mts +37 -11
  49. package/dist/player/index.d.ts +37 -11
  50. package/dist/player/index.js +3280 -174
  51. package/dist/player/index.mjs +55 -5
  52. package/package.json +4 -4
@@ -0,0 +1,105 @@
1
+ // src/player/atoms/navigation.tsx
2
+ import { useState, useCallback, createContext, useContext } from "react";
3
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
4
+ var RouterCtx = createContext({
5
+ path: "/",
6
+ navigate: () => {
7
+ },
8
+ params: {}
9
+ });
10
+ function usePlayerRouter() {
11
+ return useContext(RouterCtx);
12
+ }
13
+ var Router = ({ children, basePath, className, style }) => {
14
+ const [path, setPath] = useState(basePath ?? "/");
15
+ const navigate = useCallback((to) => {
16
+ setPath(to);
17
+ }, []);
18
+ return /* @__PURE__ */ jsx(RouterCtx.Provider, { value: { path, navigate, params: {} }, children: /* @__PURE__ */ jsx("div", { className, style, children }) });
19
+ };
20
+ function matchPath(pattern, currentPath, exact) {
21
+ const params = {};
22
+ const patternParts = pattern.split("/").filter(Boolean);
23
+ const pathParts = currentPath.split("/").filter(Boolean);
24
+ if (exact && patternParts.length !== pathParts.length) {
25
+ return { match: false, params };
26
+ }
27
+ if (patternParts.length > pathParts.length) {
28
+ return { match: false, params };
29
+ }
30
+ for (let i = 0; i < patternParts.length; i++) {
31
+ const pp = patternParts[i];
32
+ if (pp.startsWith(":")) {
33
+ params[pp.slice(1)] = pathParts[i];
34
+ } else if (pp === "*") {
35
+ return { match: true, params };
36
+ } else if (pp !== pathParts[i]) {
37
+ return { match: false, params };
38
+ }
39
+ }
40
+ return { match: true, params };
41
+ }
42
+ var Route = ({ children, path: routePath, exact, className, style }) => {
43
+ const { path } = useContext(RouterCtx);
44
+ const pattern = routePath ?? "/";
45
+ const { match, params } = matchPath(pattern, path, exact !== false);
46
+ if (!match) return null;
47
+ return /* @__PURE__ */ jsx(RouterCtx.Provider, { value: { path, navigate: useContext(RouterCtx).navigate, params }, children: /* @__PURE__ */ jsx("div", { className, style, children }) });
48
+ };
49
+ var NavLink = ({
50
+ children,
51
+ to,
52
+ label,
53
+ icon,
54
+ activeClassName,
55
+ className,
56
+ style,
57
+ onClick
58
+ }) => {
59
+ const { path, navigate } = useContext(RouterCtx);
60
+ const target = to ?? "/";
61
+ const isActive = path === target || path.startsWith(target + "/");
62
+ const text = children ?? label;
63
+ const handleClick = useCallback((e) => {
64
+ e.preventDefault();
65
+ navigate(target);
66
+ if (typeof onClick === "function") onClick(e);
67
+ }, [navigate, target, onClick]);
68
+ return /* @__PURE__ */ jsxs(
69
+ "button",
70
+ {
71
+ className: `${className ?? ""} ${isActive && activeClassName ? activeClassName : ""}`.trim() || void 0,
72
+ onClick: handleClick,
73
+ style: {
74
+ background: isActive ? "#ebf8ff" : "transparent",
75
+ color: isActive ? "#2b6cb0" : "#4a5568",
76
+ border: "none",
77
+ borderRadius: 6,
78
+ padding: "6px 12px",
79
+ fontSize: 14,
80
+ fontWeight: isActive ? 600 : 400,
81
+ cursor: "pointer",
82
+ display: "inline-flex",
83
+ alignItems: "center",
84
+ gap: 6,
85
+ transition: "background 0.15s, color 0.15s",
86
+ ...style
87
+ },
88
+ children: [
89
+ icon ? /* @__PURE__ */ jsx("span", { children: String(icon) }) : null,
90
+ text != null ? String(text) : null
91
+ ]
92
+ }
93
+ );
94
+ };
95
+ var RoleGuard = ({ children, role: _role, roles: _roles, fallback: _fallback }) => {
96
+ return /* @__PURE__ */ jsx(Fragment, { children });
97
+ };
98
+
99
+ export {
100
+ usePlayerRouter,
101
+ Router,
102
+ Route,
103
+ NavLink,
104
+ RoleGuard
105
+ };