@particle-academy/fancy-cms-ui 0.0.1-dev.1 → 0.0.1-dev.3

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,19 @@
1
+ import { ReactNode } from 'react';
2
+ import { N as Node, P as PageDoc } from './types-CpfPEq3V.cjs';
3
+
4
+ interface ElementContext {
5
+ node: Node;
6
+ doc: PageDoc;
7
+ /** Pre-rendered child nodes, in order. */
8
+ children: ReactNode;
9
+ }
10
+ /**
11
+ * Renders the INNER content of a node. The outer `[data-cms]` wrapper is added
12
+ * by {@link RenderNode}, so a renderer only returns what goes inside.
13
+ */
14
+ type ElementRenderer = (ctx: ElementContext) => ReactNode;
15
+ type ElementRegistry = Record<string, ElementRenderer>;
16
+ /** Built-in native elements. Containers render their children; leaves render content. */
17
+ declare const defaultRegistry: ElementRegistry;
18
+
19
+ export { type ElementContext as E, type ElementRegistry as a, type ElementRenderer as b, defaultRegistry as d };
@@ -0,0 +1,19 @@
1
+ import { ReactNode } from 'react';
2
+ import { N as Node, P as PageDoc } from './types-CpfPEq3V.js';
3
+
4
+ interface ElementContext {
5
+ node: Node;
6
+ doc: PageDoc;
7
+ /** Pre-rendered child nodes, in order. */
8
+ children: ReactNode;
9
+ }
10
+ /**
11
+ * Renders the INNER content of a node. The outer `[data-cms]` wrapper is added
12
+ * by {@link RenderNode}, so a renderer only returns what goes inside.
13
+ */
14
+ type ElementRenderer = (ctx: ElementContext) => ReactNode;
15
+ type ElementRegistry = Record<string, ElementRenderer>;
16
+ /** Built-in native elements. Containers render their children; leaves render content. */
17
+ declare const defaultRegistry: ElementRegistry;
18
+
19
+ export { type ElementContext as E, type ElementRegistry as a, type ElementRenderer as b, defaultRegistry as d };
@@ -142,6 +142,12 @@ interface Node {
142
142
  each: Binding;
143
143
  as: string;
144
144
  };
145
+ /**
146
+ * Host CSS class(es) applied to the node's element. The migration enabler:
147
+ * reuse the host site's existing stylesheet for pixel-perfect reproduction
148
+ * instead of re-deriving every rule through {@link StyleProps}.
149
+ */
150
+ className?: string;
145
151
  /** Derived from the addon manifest — interactive/3rd-party ⇒ hydration island. */
146
152
  island?: boolean;
147
153
  }
@@ -142,6 +142,12 @@ interface Node {
142
142
  each: Binding;
143
143
  as: string;
144
144
  };
145
+ /**
146
+ * Host CSS class(es) applied to the node's element. The migration enabler:
147
+ * reuse the host site's existing stylesheet for pixel-perfect reproduction
148
+ * instead of re-deriving every rule through {@link StyleProps}.
149
+ */
150
+ className?: string;
145
151
  /** Derived from the addon manifest — interactive/3rd-party ⇒ hydration island. */
146
152
  island?: boolean;
147
153
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@particle-academy/fancy-cms-ui",
3
- "version": "0.0.1-dev.1",
3
+ "version": "0.0.1-dev.3",
4
4
  "description": "Editor + isomorphic renderer for fancy-cms — the Stages document model, PageOp op-spine, the JS style→CSS emitter (one half of the dual-emitter pair with the PHP particle-academy/fancy-cms), and the React renderer. Built on the Fancy UI suite.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/react/registry.tsx","../src/react/RenderNode.tsx","../src/react/CmsPage.tsx"],"names":["jsx"],"mappings":";;;;AAmBA,SAAS,QAAQ,CAAA,EAAoC;AACnD,EAAA,IAAI,CAAA,KAAM,MAAA,IAAa,CAAA,KAAM,IAAA,EAAM,OAAO,EAAA;AAC1C,EAAA,IAAI,SAAA,CAAU,CAAC,CAAA,EAAG,OAAO,EAAA;AACzB,EAAA,OAAO,OAAO,CAAC,CAAA;AACjB;AAGO,IAAM,eAAA,GAAmC;AAAA,EAC9C,OAAA,EAAS,CAAC,EAAE,QAAA,EAAS,KAAM,QAAA;AAAA,EAC3B,KAAA,EAAO,CAAC,EAAE,QAAA,EAAS,KAAM,QAAA;AAAA,EACzB,IAAA,EAAM,CAAC,EAAE,QAAA,EAAS,KAAM,QAAA;AAAA,EACxB,KAAA,EAAO,CAAC,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AA,EAAI,UAAA,EAAU,IAAA,CAAK,EAAA,EAAI,iBAAA,EAAiB,IAAA,CAAK,MAAA,GAAS,IAAA,CAAK,IAAA,GAAO,MAAA,EAChE,QAAA,EAAA,KAAA,EACH,CAAA;AAEJ;ACnBO,SAAS,OAAA,CAAQ;AAAA,EACtB,GAAA;AAAA,EACA,QAAA,GAAW,eAAA;AAAA,EACX,aAAA,GAAgB;AAClB,CAAA,EAA+B;AAC7B,EAAA,4BACG,QAAA,EAAA,EACE,QAAA,EAAA;AAAA,IAAA,aAAA,mBAAgBA,IAAC,OAAA,EAAA,EAAM,iBAAA,EAAgB,IAAI,QAAA,EAAA,UAAA,CAAW,GAAG,GAAE,CAAA,GAAW,IAAA;AAAA,IACtE,GAAA,CAAI,QAAA,CAAS,GAAA,CAAI,CAAC,EAAA,qBACjBA,GAAAA,CAAC,UAAA,EAAA,EAAoB,GAAA,EAAU,EAAA,EAAQ,QAAA,EAAA,EAAtB,EAA0C,CAC5D;AAAA,GAAA,EACH,CAAA;AAEJ","file":"chunk-MRWUUNJR.js","sourcesContent":["import type { ReactNode } from \"react\";\nimport { isBinding, type Bound, type Json, type Node, type PageDoc } from \"../document/types\";\n\nexport interface ElementContext {\n node: Node;\n doc: PageDoc;\n /** Pre-rendered child nodes, in order. */\n children: ReactNode;\n}\n\n/**\n * Renders the INNER content of a node. The outer `[data-cms]` wrapper is added\n * by {@link RenderNode}, so a renderer only returns what goes inside.\n */\nexport type ElementRenderer = (ctx: ElementContext) => ReactNode;\n\nexport type ElementRegistry = Record<string, ElementRenderer>;\n\n/** Resolve a literal prop to a string (bindings resolve in Phase 3). */\nfunction literal(v: Bound<Json> | undefined): string {\n if (v === undefined || v === null) return \"\";\n if (isBinding(v)) return \"\";\n return String(v);\n}\n\n/** Built-in native elements. Containers render their children; leaves render content. */\nexport const defaultRegistry: ElementRegistry = {\n section: ({ children }) => children,\n stack: ({ children }) => children,\n grid: ({ children }) => children,\n frame: ({ children }) => children,\n shape: ({ children }) => children,\n text: ({ node }) => literal(node.props.content),\n image: ({ node }) => (\n <img\n src={literal(node.props.src)}\n alt={literal(node.props.alt)}\n style={{ width: \"100%\", height: \"100%\", objectFit: \"cover\", display: \"block\" }}\n />\n ),\n};\n","import type { ReactElement } from \"react\";\nimport type { PageDoc } from \"../document/types\";\nimport { childrenOf } from \"../document/reduce\";\nimport { defaultRegistry, type ElementRegistry } from \"./registry\";\n\nexport interface RenderNodeProps {\n doc: PageDoc;\n id: string;\n registry?: ElementRegistry;\n}\n\n/**\n * Render one node (and its subtree) to a `[data-cms]`-tagged element. The CSS\n * emitted by `emitDocCss` targets these `data-cms` handles. Interactive /\n * 3rd-party **islands** with no registered renderer become an empty, sized\n * placeholder the host hydrates client-side — mirroring the PHP renderer.\n */\nexport function RenderNode({ doc, id, registry = defaultRegistry }: RenderNodeProps): ReactElement | null {\n const node = doc.nodes[id];\n if (!node) return null;\n\n const kids = childrenOf(doc, id).map((child) => (\n <RenderNode key={child.id} doc={doc} id={child.id} registry={registry} />\n ));\n\n const renderer = registry[node.type];\n const inner = renderer ? renderer({ node, doc, children: kids }) : node.island ? null : kids;\n\n return (\n <div data-cms={node.id} data-cms-island={node.island ? node.type : undefined}>\n {inner}\n </div>\n );\n}\n","import { Fragment, type ReactElement } from \"react\";\nimport type { PageDoc } from \"../document/types\";\nimport { emitDocCss } from \"../render/css\";\nimport { RenderNode } from \"./RenderNode\";\nimport { defaultRegistry, type ElementRegistry } from \"./registry\";\n\nexport interface CmsPageProps {\n doc: PageDoc;\n registry?: ElementRegistry;\n /** Inject the compiled stylesheet. Set false when the host emits CSS itself. */\n includeStyles?: boolean;\n}\n\n/** Render a full page document: the compiled stylesheet + every section. */\nexport function CmsPage({\n doc,\n registry = defaultRegistry,\n includeStyles = true,\n}: CmsPageProps): ReactElement {\n return (\n <Fragment>\n {includeStyles ? <style data-cms-styles=\"\">{emitDocCss(doc)}</style> : null}\n {doc.sections.map((id) => (\n <RenderNode key={id} doc={doc} id={id} registry={registry} />\n ))}\n </Fragment>\n );\n}\n"]}