@mmapp/react 0.1.0-alpha.18 → 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.
- package/dist/actions-HOXZPBTT.mjs +116 -0
- package/dist/actions-MFI2V4DX.mjs +116 -0
- package/dist/atoms/index.d.mts +2 -2
- package/dist/atoms/index.d.ts +2 -2
- package/dist/atoms/index.js +1 -1
- package/dist/atoms/index.mjs +1 -1
- package/dist/builtin-atoms-C-sNyYJl.d.mts +647 -0
- package/dist/builtin-atoms-C-sNyYJl.d.ts +647 -0
- package/dist/builtin-atoms-DCKrjG7i.d.mts +96 -0
- package/dist/builtin-atoms-DCKrjG7i.d.ts +96 -0
- package/dist/builtin-atoms-DRD3EwG6.d.mts +648 -0
- package/dist/builtin-atoms-DRD3EwG6.d.ts +648 -0
- package/dist/builtin-atoms-jt04b7Rw.d.mts +643 -0
- package/dist/builtin-atoms-jt04b7Rw.d.ts +643 -0
- package/dist/chunk-247T4GDJ.mjs +677 -0
- package/dist/chunk-3H6CR7E7.mjs +1924 -0
- package/dist/chunk-3PL6FL6I.mjs +96 -0
- package/dist/chunk-3SJSW3C4.mjs +2039 -0
- package/dist/chunk-5OI2VI57.mjs +1964 -0
- package/dist/chunk-CL6FYZ43.mjs +105 -0
- package/dist/chunk-ENQOCZI5.mjs +1938 -0
- package/dist/chunk-FB3WCZAU.mjs +512 -0
- package/dist/chunk-FBKUGKQI.mjs +1938 -0
- package/dist/chunk-GLJ7VC7Z.mjs +684 -0
- package/dist/chunk-HHMWR6NA.mjs +504 -0
- package/dist/chunk-HULEMSN2.mjs +120 -0
- package/dist/chunk-J5MW6CRU.mjs +1938 -0
- package/dist/chunk-PNTTKNYU.mjs +677 -0
- package/dist/chunk-TY5OTJP4.mjs +684 -0
- package/dist/chunk-WV7DVCP6.mjs +513 -0
- package/dist/chunk-YFMPTGUF.mjs +677 -0
- package/dist/chunk-ZAHMWAER.mjs +1960 -0
- package/dist/{chunk-2VJQJM7S.mjs → chunk-ZDWACXZN.mjs} +1 -1
- package/dist/composition-BJ6QQTWT.mjs +12 -0
- package/dist/composition-XBGKKCI7.mjs +57 -0
- package/dist/content-QVPFUG4P.mjs +246 -0
- package/dist/control-flow-CBREHWJW.mjs +35 -0
- package/dist/control-flow-FWBOI6SM.mjs +35 -0
- package/dist/control-flow-ZWUGCDSP.mjs +35 -0
- package/dist/data-WCMIZYKD.mjs +97 -0
- package/dist/grouping-E6F377VZ.mjs +204 -0
- package/dist/grouping-FRPOEXO3.mjs +233 -0
- package/dist/index.d.mts +4 -433
- package/dist/index.d.ts +4 -433
- package/dist/index.js +3671 -582
- package/dist/index.mjs +335 -1040
- package/dist/input-PUOZDNSI.mjs +222 -0
- package/dist/layout-RATDMCLP.mjs +106 -0
- package/dist/navigation-VCT7ZBMA.mjs +15 -0
- package/dist/navigation-WFV7YWOU.mjs +14 -0
- package/dist/player/index.d.mts +37 -11
- package/dist/player/index.d.ts +37 -11
- package/dist/player/index.js +3321 -193
- package/dist/player/index.mjs +55 -5
- package/package.json +4 -4
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
// src/player/atoms/composition.tsx
|
|
2
|
+
import React, { createContext, useContext, useMemo } from "react";
|
|
3
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
+
var SlotRegistryContext = createContext(/* @__PURE__ */ new Map());
|
|
5
|
+
var SlotRegistryProvider = ({ contributions, children }) => {
|
|
6
|
+
const registry = useMemo(() => {
|
|
7
|
+
const map = /* @__PURE__ */ new Map();
|
|
8
|
+
for (const c of contributions) {
|
|
9
|
+
const list = map.get(c.name) ?? [];
|
|
10
|
+
list.push(c);
|
|
11
|
+
map.set(c.name, list);
|
|
12
|
+
}
|
|
13
|
+
for (const [, list] of map) {
|
|
14
|
+
list.sort((a, b) => (b.priority ?? 0) - (a.priority ?? 0));
|
|
15
|
+
}
|
|
16
|
+
return map;
|
|
17
|
+
}, [contributions]);
|
|
18
|
+
return /* @__PURE__ */ jsx(SlotRegistryContext.Provider, { value: registry, children });
|
|
19
|
+
};
|
|
20
|
+
function useSlotContributions(name) {
|
|
21
|
+
const registry = useContext(SlotRegistryContext);
|
|
22
|
+
return registry.get(name) ?? [];
|
|
23
|
+
}
|
|
24
|
+
var Slot = ({ children, name, fallback, className, style }) => {
|
|
25
|
+
const slotName = name ?? "";
|
|
26
|
+
const contributions = useSlotContributions(slotName);
|
|
27
|
+
const content = contributions.length > 0 ? contributions.map((c, i) => /* @__PURE__ */ jsx(React.Fragment, { children: c.tree }, i)) : children ?? fallback;
|
|
28
|
+
if (!content) return null;
|
|
29
|
+
return /* @__PURE__ */ jsx(
|
|
30
|
+
"div",
|
|
31
|
+
{
|
|
32
|
+
className,
|
|
33
|
+
"data-slot": slotName,
|
|
34
|
+
style,
|
|
35
|
+
children: content
|
|
36
|
+
}
|
|
37
|
+
);
|
|
38
|
+
};
|
|
39
|
+
var ModuleOutlet = ({ children, module: moduleName, basePath, className, style }) => {
|
|
40
|
+
const moduleKey = moduleName ?? "";
|
|
41
|
+
const contributions = useSlotContributions(`module:${moduleKey}`);
|
|
42
|
+
if (contributions.length > 0) {
|
|
43
|
+
return /* @__PURE__ */ jsx(
|
|
44
|
+
"div",
|
|
45
|
+
{
|
|
46
|
+
className,
|
|
47
|
+
"data-module": moduleKey,
|
|
48
|
+
style,
|
|
49
|
+
children: contributions.map((c, i) => /* @__PURE__ */ jsx(React.Fragment, { children: c.tree }, i))
|
|
50
|
+
}
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
if (children) {
|
|
54
|
+
return /* @__PURE__ */ jsx(
|
|
55
|
+
"div",
|
|
56
|
+
{
|
|
57
|
+
className,
|
|
58
|
+
"data-module": moduleKey,
|
|
59
|
+
style,
|
|
60
|
+
children
|
|
61
|
+
}
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
return /* @__PURE__ */ jsxs(
|
|
65
|
+
"div",
|
|
66
|
+
{
|
|
67
|
+
className,
|
|
68
|
+
"data-module": moduleKey,
|
|
69
|
+
style: {
|
|
70
|
+
padding: 16,
|
|
71
|
+
border: "1px dashed #cbd5e0",
|
|
72
|
+
borderRadius: 8,
|
|
73
|
+
color: "#a0aec0",
|
|
74
|
+
fontSize: 13,
|
|
75
|
+
textAlign: "center",
|
|
76
|
+
...style
|
|
77
|
+
},
|
|
78
|
+
children: [
|
|
79
|
+
"Module: ",
|
|
80
|
+
String(moduleName ?? "unknown"),
|
|
81
|
+
basePath ? /* @__PURE__ */ jsxs("span", { children: [
|
|
82
|
+
" (",
|
|
83
|
+
String(basePath),
|
|
84
|
+
")"
|
|
85
|
+
] }) : null
|
|
86
|
+
]
|
|
87
|
+
}
|
|
88
|
+
);
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
export {
|
|
92
|
+
SlotRegistryProvider,
|
|
93
|
+
useSlotContributions,
|
|
94
|
+
Slot,
|
|
95
|
+
ModuleOutlet
|
|
96
|
+
};
|