@spillway-cms/blocks 0.1.30 → 0.1.31
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/shared.js +11 -3
- package/dist/shared.js.map +1 -1
- package/package.json +2 -2
package/dist/shared.js
CHANGED
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
const isNode = (v) => !!v && typeof v === 'object' && typeof v.type === 'string' && !!v.props && typeof v.props === 'object';
|
|
3
|
-
/**
|
|
4
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Slot arrays stored in props become components, as Puck would pass them, so Columns and the like still render. Of a block's own
|
|
5
|
+
* props only the ones its fields declare as slots are turned (`fields`); a list of blocks under any other name is data the block
|
|
6
|
+
* reads itself, such as the `blocks` the server attaches to a site component. Inside array items every list of blocks is a slot.
|
|
7
|
+
*/
|
|
8
|
+
function withSlots(props, config, depth, fields) {
|
|
5
9
|
const out = {};
|
|
6
10
|
for (const [k, v] of Object.entries(props)) {
|
|
7
11
|
if (Array.isArray(v) && v.length > 0 && v.every(isNode)) {
|
|
12
|
+
if (fields && fields[k]?.type !== 'slot') {
|
|
13
|
+
out[k] = v;
|
|
14
|
+
continue;
|
|
15
|
+
}
|
|
8
16
|
const children = v;
|
|
9
17
|
out[k] = (p) => (_jsx("div", { className: p?.className, style: p?.style, children: children.map((c, i) => (_jsx(RenderNode, { node: c, config: config, depth: depth + 1 }, String(c.props.id ?? i)))) }));
|
|
10
18
|
}
|
|
@@ -22,7 +30,7 @@ export function RenderNode({ node, config, depth = 0 }) {
|
|
|
22
30
|
const comp = config.components[node.type];
|
|
23
31
|
if (!comp || node.type === 'Shared')
|
|
24
32
|
return null;
|
|
25
|
-
const props = withSlots(node.props, config, depth);
|
|
33
|
+
const props = withSlots(node.props, config, depth, (comp.fields ?? {}));
|
|
26
34
|
const Render = comp.render;
|
|
27
35
|
return _jsx(Render, { ...props, puck: { renderDropZone: () => null, isEditing: false, dragRef: null, metadata: {} } });
|
|
28
36
|
}
|
package/dist/shared.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../src/shared.tsx"],"names":[],"mappings":";AAkBA,MAAM,MAAM,GAAG,CAAC,CAAU,EAAa,EAAE,CACvC,CAAC,CAAC,CAAC,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,OAAQ,CAAU,CAAC,IAAI,KAAK,QAAQ,IAAI,CAAC,CAAE,CAAU,CAAC,KAAK,IAAI,OAAQ,CAAU,CAAC,KAAK,KAAK,QAAQ,CAAC;AAEvI
|
|
1
|
+
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../src/shared.tsx"],"names":[],"mappings":";AAkBA,MAAM,MAAM,GAAG,CAAC,CAAU,EAAa,EAAE,CACvC,CAAC,CAAC,CAAC,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,OAAQ,CAAU,CAAC,IAAI,KAAK,QAAQ,IAAI,CAAC,CAAE,CAAU,CAAC,KAAK,IAAI,OAAQ,CAAU,CAAC,KAAK,KAAK,QAAQ,CAAC;AAEvI;;;;GAIG;AACH,SAAS,SAAS,CAAC,KAA8B,EAAE,MAAc,EAAE,KAAa,EAAE,MAAsD;IACtI,MAAM,GAAG,GAA4B,EAAE,CAAC;IACxC,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAC3C,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC;YACxD,IAAI,MAAM,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,IAAI,KAAK,MAAM,EAAE,CAAC;gBACzC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;gBACX,SAAS;YACX,CAA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AC,IAAI,EAAC,MAAM,YAChD,SAAS,CAAC,CAAC,CAAC,iBAAiB,SAAS,4BAA4B,CAAC,CAAC,CAAC,6BAA6B,GAC/F,GACF,GACE,CACX,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,SAAS,GAAG;;;;;;;;;;;;CAYxB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spillway-cms/blocks",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.31",
|
|
4
4
|
"description": "Core block library for Spillway CMS: Puck components that render on the server and in the editor",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"@puckeditor/core": "^0.24.0"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@spillway-cms/shared": "0.1.
|
|
34
|
+
"@spillway-cms/shared": "0.1.31"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@puckeditor/core": "^0.24.0",
|