@bettercms-ai/next 0.10.1 β†’ 0.11.0

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/README.md CHANGED
@@ -135,9 +135,15 @@ form renders inline exactly where you placed it. Render the page's blocks with
135
135
  (heading, text, image, button, spacer, video, columns) renders to plain, class-driven
136
136
  markup you can style.
137
137
 
138
+ > πŸ”΄ **Pass `components={readComponents()}` too.** Pages authored as SECTIONS β€” the shape the
139
+ > dashboard's "Add a section" picker and the AI both produce β€” are lists of `component` blocks.
140
+ > A `component` block whose definition was not delivered renders **nothing**, so a page can
141
+ > build green and come back showing only your layout's nav and footer. Both readers pull from
142
+ > the same `bcms-content.json` the deploy Action writes, so this costs one extra call.
143
+
138
144
  ```tsx
139
145
  // app/[slug]/page.tsx
140
- import { createBetterCMS, readForms } from "@bettercms-ai/next";
146
+ import { createBetterCMS, readForms, readComponents } from "@bettercms-ai/next";
141
147
  import { BcmsBlocks } from "@bettercms-ai/next/blocks"; // its own "use client" entry
142
148
 
143
149
  const cms = createBetterCMS({ workspace: "my-workspace", apiKey: process.env.BETTERCMS_API_KEY! });
@@ -150,6 +156,10 @@ export default async function Page({ params }: { params: { slug: string } }) {
150
156
  <BcmsBlocks
151
157
  blocks={page.blocks}
152
158
  forms={forms}
159
+ // πŸ”΄ NOT optional in practice. A page built out of SECTIONS is a list of `component`
160
+ // blocks, and a `component` block with no matching definition renders NOTHING. Omit
161
+ // this and such a page builds green, returns 200, and shows only your nav and footer.
162
+ components={readComponents()}
153
163
  turnstileSiteKey={turnstileSiteKey ?? undefined}
154
164
  />
155
165
  );
package/dist/blocks.js CHANGED
@@ -8,6 +8,7 @@ import {
8
8
  useState as useState2
9
9
  } from "react";
10
10
  import { blockStyleToCss } from "@bettercms-ai/types";
11
+ import { componentInstanceAddresses } from "@bettercms-ai/types";
11
12
  import { applyOverrides } from "@bettercms-ai/ui/resolve";
12
13
 
13
14
  // src/form.tsx
@@ -262,6 +263,27 @@ function Field({ field, value, error, onChange }) {
262
263
  ] });
263
264
  }
264
265
 
266
+ // src/bindings.ts
267
+ import { formatPropsAttribute } from "@bettercms-ai/types";
268
+ function addressFor(id, prop, ctx) {
269
+ if (!id) return null;
270
+ const key = `${id}__${prop}`;
271
+ if (ctx.fieldAddresses) return ctx.fieldAddresses.get(key) ?? null;
272
+ return key;
273
+ }
274
+ function bind(id, prop, kind, ctx) {
275
+ const address = addressFor(id, prop, ctx);
276
+ return address ? { "data-bcms-field": address, "data-bcms-kind": kind } : {};
277
+ }
278
+ function bindProps(id, entries, ctx) {
279
+ const resolved = entries.flatMap(({ prop, kind, attr, present }) => {
280
+ if (!present) return [];
281
+ const address = addressFor(id, prop, ctx);
282
+ return address ? [{ address, kind, attr }] : [];
283
+ });
284
+ return resolved.length ? { "data-bcms-props": formatPropsAttribute(resolved) } : {};
285
+ }
286
+
265
287
  // src/blocks.tsx
266
288
  import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
267
289
  var MAX_COMPONENT_DEPTH = 10;
@@ -309,17 +331,22 @@ function renderBlock(block, ctx) {
309
331
  function renderBlockInner(block, ctx) {
310
332
  switch (block.type) {
311
333
  case "heading":
312
- return renderHeading(block);
334
+ return renderHeading(block, ctx);
335
+ // `richtext` and `text` carry the same payload and differ only in the authoring surface,
336
+ // so delivery renders them identically β€” Astro (BcmsBlocks.astro) and the hosted renderer
337
+ // (render-page.ts) both alias them. Next did not, so `richtext` fell to `default: null`
338
+ // and a richtext block rendered NOTHING on a Next site: 200 OK, green build, blank region.
313
339
  case "text":
314
- return renderText(block);
340
+ case "richtext":
341
+ return renderText(block, ctx);
315
342
  case "image":
316
- return renderImage(block);
343
+ return renderImage(block, ctx);
317
344
  case "button":
318
- return renderButton(block);
345
+ return renderButton(block, ctx);
319
346
  case "spacer":
320
347
  return renderSpacer(block);
321
348
  case "video":
322
- return renderVideo(block);
349
+ return renderVideo(block, ctx);
323
350
  case "columns":
324
351
  return renderColumns(block, ctx);
325
352
  case "form":
@@ -327,9 +354,9 @@ function renderBlockInner(block, ctx) {
327
354
  case "section":
328
355
  return renderSection(block, ctx);
329
356
  case "navbar":
330
- return renderNavbar(block);
357
+ return renderNavbar(block, ctx);
331
358
  case "footer":
332
- return renderFooter(block);
359
+ return renderFooter(block, ctx);
333
360
  case "slider":
334
361
  return /* @__PURE__ */ jsx2(BcmsSlider, { block, ctx }, block.id);
335
362
  case "tabs":
@@ -337,26 +364,25 @@ function renderBlockInner(block, ctx) {
337
364
  case "component":
338
365
  return renderComponent(block, ctx);
339
366
  default:
340
- return null;
367
+ return renderUnhandledBlock(block);
341
368
  }
342
369
  }
343
- function renderHeading({ id, props }) {
370
+ function renderHeading({ id, props }, ctx) {
344
371
  const Tag = `h${props.level ?? 2}`;
345
- return /* @__PURE__ */ jsx2(Tag, { className: "bcms-block bcms-block--heading", "data-bcms-field": `${id}__text`, children: props.text }, id);
372
+ return /* @__PURE__ */ jsx2(Tag, { className: "bcms-block bcms-block--heading", ...bind(id, "text", "text", ctx), children: props.text }, id);
346
373
  }
347
- function renderText({ id, props }) {
374
+ function renderText({ id, props }, ctx) {
348
375
  return /* @__PURE__ */ jsx2(
349
376
  "div",
350
377
  {
351
378
  className: "bcms-block bcms-block--text",
352
- "data-bcms-field": `${id}__html`,
353
- "data-bcms-kind": "richtext",
379
+ ...bind(id, "html", "richtext", ctx),
354
380
  dangerouslySetInnerHTML: { __html: props.html }
355
381
  },
356
382
  id
357
383
  );
358
384
  }
359
- function renderImage({ id, props }) {
385
+ function renderImage({ id, props }, ctx) {
360
386
  const img = /* @__PURE__ */ jsx2(
361
387
  "img",
362
388
  {
@@ -365,8 +391,8 @@ function renderImage({ id, props }) {
365
391
  width: props.width,
366
392
  height: props.height,
367
393
  loading: "lazy",
368
- "data-bcms-field": `${id}__src`,
369
- "data-bcms-kind": "image"
394
+ ...bind(id, "src", "image", ctx),
395
+ ...bindProps(id, [{ prop: "alt", kind: "text", attr: "alt", present: props.alt != null }], ctx)
370
396
  }
371
397
  );
372
398
  if (!props.caption) {
@@ -374,16 +400,17 @@ function renderImage({ id, props }) {
374
400
  }
375
401
  return /* @__PURE__ */ jsxs2("figure", { className: "bcms-block bcms-block--image", children: [
376
402
  img,
377
- /* @__PURE__ */ jsx2("figcaption", { children: props.caption })
403
+ /* @__PURE__ */ jsx2("figcaption", { ...bind(id, "caption", "text", ctx), children: props.caption })
378
404
  ] }, id);
379
405
  }
380
- function renderButton({ id, props }) {
406
+ function renderButton({ id, props }, ctx) {
381
407
  return /* @__PURE__ */ jsx2(
382
408
  "a",
383
409
  {
384
410
  href: props.href,
385
411
  className: `bcms-block bcms-block--button bcms-button--${props.variant ?? "primary"}`,
386
- "data-bcms-field": `${id}__text`,
412
+ ...bind(id, "text", "text", ctx),
413
+ ...bindProps(id, [{ prop: "href", kind: "url", attr: "href", present: props.href != null }], ctx),
387
414
  children: props.text
388
415
  },
389
416
  id
@@ -400,13 +427,21 @@ function renderSpacer({ id, props }) {
400
427
  id
401
428
  );
402
429
  }
403
- function renderVideo({ id, props }) {
430
+ function renderVideo({ id, props }, ctx) {
404
431
  return /* @__PURE__ */ jsx2(
405
432
  "video",
406
433
  {
407
434
  className: "bcms-block bcms-block--video",
408
435
  src: props.url,
409
436
  poster: props.poster,
437
+ ...bindProps(
438
+ id,
439
+ [
440
+ { prop: "url", kind: "url", attr: "src", present: props.url != null },
441
+ { prop: "poster", kind: "url", attr: "poster", present: props.poster != null }
442
+ ],
443
+ ctx
444
+ ),
410
445
  autoPlay: props.autoplay,
411
446
  loop: props.loop,
412
447
  controls: true
@@ -441,41 +476,79 @@ function renderSection({ id, props }, ctx) {
441
476
  {
442
477
  className: "bcms-block bcms-block--section",
443
478
  style: { background: props.background, padding: props.paddingY != null ? `${props.paddingY}px 0` : void 0 },
444
- children: props.maxWidth ? /* @__PURE__ */ jsx2("div", { style: { maxWidth: props.maxWidth, margin: "0 auto" }, children: inner }) : inner
479
+ children: props.maxWidth ? /* @__PURE__ */ jsx2("div", { className: "bcms-section-inner", style: { maxWidth: props.maxWidth, margin: "0 auto" }, children: inner }) : inner
445
480
  },
446
481
  id
447
482
  );
448
483
  }
449
- function renderNavbar({ id, props }) {
484
+ function renderNavbar({ id, props }, ctx) {
450
485
  return /* @__PURE__ */ jsxs2("nav", { className: "bcms-block bcms-block--navbar", children: [
451
- props.logo?.src ? /* @__PURE__ */ jsx2("a", { className: "bcms-navbar-logo", href: props.logo.href ?? "/", children: /* @__PURE__ */ jsx2("img", { src: props.logo.src, alt: props.logo.alt }) }) : null,
452
- /* @__PURE__ */ jsx2("div", { className: "bcms-navbar-links", children: props.links.map((l, i) => /* @__PURE__ */ jsx2("a", { href: l.href, children: l.label }, i)) }),
453
- props.cta ? /* @__PURE__ */ jsx2("a", { className: "bcms-button bcms-button--primary", href: props.cta.href, children: props.cta.text }) : null
486
+ props.logo?.src ? /* @__PURE__ */ jsx2("a", { className: "bcms-navbar-logo", href: props.logo.href ?? "/", children: /* @__PURE__ */ jsx2(
487
+ "img",
488
+ {
489
+ src: props.logo.src,
490
+ alt: props.logo.alt,
491
+ ...bind(id, "logo.src", "image", ctx),
492
+ ...bindProps(id, [{ prop: "logo.alt", kind: "text", attr: "alt", present: props.logo.alt != null }], ctx)
493
+ }
494
+ ) }) : null,
495
+ /* @__PURE__ */ jsx2("div", { className: "bcms-navbar-links", children: props.links.map((l, i) => /* @__PURE__ */ jsx2(
496
+ "a",
497
+ {
498
+ href: l.href,
499
+ ...bind(id, `links[${i}].label`, "text", ctx),
500
+ ...bindProps(id, [{ prop: `links[${i}].href`, kind: "url", attr: "href", present: l.href != null }], ctx),
501
+ children: l.label
502
+ },
503
+ i
504
+ )) }),
505
+ props.cta ? /* @__PURE__ */ jsx2(
506
+ "a",
507
+ {
508
+ className: "bcms-button bcms-button--primary",
509
+ href: props.cta.href,
510
+ ...bind(id, "cta.text", "text", ctx),
511
+ ...bindProps(id, [{ prop: "cta.href", kind: "url", attr: "href", present: props.cta.href != null }], ctx),
512
+ children: props.cta.text
513
+ }
514
+ ) : null
454
515
  ] }, id);
455
516
  }
456
- function renderFooter({ id, props }) {
517
+ function renderFooter({ id, props }, ctx) {
457
518
  return /* @__PURE__ */ jsxs2("footer", { className: "bcms-block bcms-block--footer", children: [
458
519
  /* @__PURE__ */ jsx2("div", { className: "bcms-footer-cols", children: props.columns.map((col, i) => /* @__PURE__ */ jsxs2("div", { className: "bcms-footer-col", children: [
459
- col.heading ? /* @__PURE__ */ jsx2("h4", { children: col.heading }) : null,
460
- /* @__PURE__ */ jsx2("ul", { children: col.links.map((l, j) => /* @__PURE__ */ jsx2("li", { children: /* @__PURE__ */ jsx2("a", { href: l.href, children: l.label }) }, j)) })
520
+ col.heading ? /* @__PURE__ */ jsx2("h4", { ...bind(id, `columns[${i}].heading`, "text", ctx), children: col.heading }) : null,
521
+ /* @__PURE__ */ jsx2("ul", { children: col.links.map((l, j) => /* @__PURE__ */ jsx2("li", { children: /* @__PURE__ */ jsx2(
522
+ "a",
523
+ {
524
+ href: l.href,
525
+ ...bind(id, `columns[${i}].links[${j}].label`, "text", ctx),
526
+ ...bindProps(
527
+ id,
528
+ [{ prop: `columns[${i}].links[${j}].href`, kind: "url", attr: "href", present: l.href != null }],
529
+ ctx
530
+ ),
531
+ children: l.label
532
+ }
533
+ ) }, j)) })
461
534
  ] }, i)) }),
462
- props.copyright ? /* @__PURE__ */ jsx2("p", { className: "bcms-footer-copy", children: props.copyright }) : null
535
+ props.copyright ? /* @__PURE__ */ jsx2("p", { className: "bcms-footer-copy", ...bind(id, "copyright", "text", ctx), children: props.copyright }) : null
463
536
  ] }, id);
464
537
  }
465
- function BcmsSlider({ block, ctx }) {
538
+ function BcmsSlider({ block, ctx, ...rest }) {
466
539
  const { slides } = block.props;
467
540
  const [i, setI] = useState2(0);
468
541
  const go = (n) => setI((n + slides.length) % (slides.length || 1));
469
- return /* @__PURE__ */ jsxs2("div", { className: "bcms-block bcms-block--slider", style: { position: "relative" }, children: [
542
+ return /* @__PURE__ */ jsxs2("div", { className: "bcms-block bcms-block--slider", style: { position: "relative" }, ...rest, children: [
470
543
  slides.map((s, idx) => /* @__PURE__ */ jsx2("div", { className: "bcms-slide", hidden: idx !== i, children: s.children.map((child) => renderBlock(child, ctx)) }, s.id)),
471
544
  /* @__PURE__ */ jsx2("button", { type: "button", className: "bcms-slider-prev", "aria-label": "Previous", onClick: () => go(i - 1), children: "\u2039" }),
472
545
  /* @__PURE__ */ jsx2("button", { type: "button", className: "bcms-slider-next", "aria-label": "Next", onClick: () => go(i + 1), children: "\u203A" })
473
546
  ] });
474
547
  }
475
- function BcmsTabs({ block, ctx }) {
548
+ function BcmsTabs({ block, ctx, ...rest }) {
476
549
  const { tabs } = block.props;
477
550
  const [active, setActive] = useState2(0);
478
- return /* @__PURE__ */ jsxs2("div", { className: "bcms-block bcms-block--tabs", children: [
551
+ return /* @__PURE__ */ jsxs2("div", { className: "bcms-block bcms-block--tabs", ...rest, children: [
479
552
  /* @__PURE__ */ jsx2("div", { className: "bcms-tablist", role: "tablist", children: tabs.map((t, idx) => /* @__PURE__ */ jsx2(
480
553
  "button",
481
554
  {
@@ -484,6 +557,7 @@ function BcmsTabs({ block, ctx }) {
484
557
  className: "bcms-tab",
485
558
  "aria-selected": idx === active,
486
559
  onClick: () => setActive(idx),
560
+ ...bind(block.id, `tabs[${idx}].label`, "text", ctx),
487
561
  children: t.label
488
562
  },
489
563
  t.id
@@ -491,14 +565,60 @@ function BcmsTabs({ block, ctx }) {
491
565
  tabs.map((t, idx) => /* @__PURE__ */ jsx2("div", { role: "tabpanel", className: "bcms-tabpanel", hidden: idx !== active, children: t.children.map((child) => renderBlock(child, ctx)) }, t.id))
492
566
  ] });
493
567
  }
568
+ var warnedMissing = /* @__PURE__ */ new Set();
494
569
  function renderComponent({ id, props }, ctx) {
495
570
  const def = ctx.componentsById.get(props.componentId);
496
- if (!def) return null;
571
+ if (!def) return renderMissingComponent(props.componentId, ctx);
497
572
  if (ctx.depth >= MAX_COMPONENT_DEPTH || ctx.seen.has(def.id)) return null;
498
573
  const resolved = applyOverrides(def.blockJson, def.props ?? [], props.overrides ?? {});
499
- const childCtx = { ...ctx, depth: ctx.depth + 1, seen: /* @__PURE__ */ new Set([...ctx.seen, def.id]) };
574
+ const childCtx = {
575
+ ...ctx,
576
+ depth: ctx.depth + 1,
577
+ seen: /* @__PURE__ */ new Set([...ctx.seen, def.id]),
578
+ fieldAddresses: componentInstanceAddresses(id, def.props)
579
+ };
500
580
  return /* @__PURE__ */ jsx2("div", { className: "bcms-block bcms-block--component", children: resolved.map((child) => renderBlock(child, childCtx)) }, id);
501
581
  }
582
+ var warnedUnhandled = /* @__PURE__ */ new Set();
583
+ function renderUnhandledBlock(block) {
584
+ if (!warnedUnhandled.has(block.type)) {
585
+ warnedUnhandled.add(block.type);
586
+ console.warn(
587
+ `[BcmsBlocks] block type "${block.type}" has no renderer here, so it rendered NOTHING. The hosted renderer draws it; this SDK does not yet.`
588
+ );
589
+ }
590
+ return null;
591
+ }
592
+ function renderMissingComponent(componentId, ctx) {
593
+ if (!warnedMissing.has(componentId)) {
594
+ warnedMissing.add(componentId);
595
+ console.warn(
596
+ `[BcmsBlocks] component "${componentId}" was not delivered, so this section rendered NOTHING.` + (ctx.componentsById.size === 0 ? ` No components were passed at all \u2014 add components={readComponents()} to <BcmsBlocks>.` : ` ${ctx.componentsById.size} component(s) were passed but none match. It is probably still a DRAFT: publish it, then rebuild.`)
597
+ );
598
+ }
599
+ if (process.env.NODE_ENV === "production") return null;
600
+ return /* @__PURE__ */ jsxs2(
601
+ "div",
602
+ {
603
+ className: "bcms-block bcms-block--component-missing",
604
+ "data-bcms-missing-component": componentId,
605
+ style: {
606
+ padding: "12px 16px",
607
+ border: "1px dashed #d4d4d8",
608
+ borderRadius: 8,
609
+ color: "#71717a",
610
+ font: "500 13px/1.5 system-ui, -apple-system, sans-serif"
611
+ },
612
+ children: [
613
+ "Section ",
614
+ /* @__PURE__ */ jsx2("code", { children: componentId }),
615
+ " was not delivered.",
616
+ " ",
617
+ ctx.componentsById.size === 0 ? "Pass components={readComponents()} to <BcmsBlocks>." : "Publish the component, then rebuild."
618
+ ]
619
+ }
620
+ );
621
+ }
502
622
  export {
503
623
  BcmsBlocks
504
624
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/blocks.tsx","../src/form.tsx"],"sourcesContent":["\"use client\";\n\n/**\n * <BcmsBlocks> β€” render a BetterCMS page's block_json natively in React.\n *\n * Pass the `blocks` from a page (delivery API `/content/:slug` β†’ `entry.blocks`)\n * plus the `forms` you read with `readForms()`. Every block type renders to plain,\n * class-driven markup (the host site owns the styling); a `form` block resolves its\n * `formId` against `forms` and renders `<BcmsForm>` inline exactly where the user\n * placed it in the page builder. This is the turnkey \"Webflow\" path β€” forms show up\n * wherever they were dropped on the page, with no manual wiring.\n *\n * Ships from its own \"use client\" entry (like <BcmsForm>) so it can be rendered from\n * a Next App Router Server Component without breaking the RSC boundary.\n */\n\nimport {\n cloneElement,\n isValidElement,\n useState,\n type CSSProperties,\n type ReactElement,\n type ReactNode,\n} from \"react\";\nimport { blockStyleToCss } from \"@bettercms-ai/types\";\nimport type {\n ContentBlock,\n HeadingBlock,\n TextBlock,\n ImageBlock,\n ButtonBlock,\n SpacerBlock,\n VideoBlock,\n ColumnsBlock,\n FormBlock,\n SectionBlock,\n NavbarBlock,\n FooterBlock,\n SliderBlock,\n TabsBlock,\n ComponentBlock,\n DeliveryComponent,\n} from \"@bettercms-ai/types\";\nimport type { DeliveryForm } from \"@bettercms-ai/sdk\";\nimport { applyOverrides } from \"@bettercms-ai/ui/resolve\";\nimport { BcmsForm } from \"./form.js\";\n\nconst MAX_COMPONENT_DEPTH = 10;\n\nexport interface BcmsBlocksProps {\n /** A page's blocks (delivery API `/content/:slug` β†’ `entry.blocks`). */\n blocks: ContentBlock[];\n /** Forms available to `form` blocks β€” from `readForms().forms`. */\n forms?: DeliveryForm[];\n /** Reusable components available to `component` blocks β€” from `readComponents()`. */\n components?: DeliveryComponent[];\n /** Turnstile site key β€” forwarded to `<BcmsForm>` for form blocks. */\n turnstileSiteKey?: string;\n /** API origin forwarded to `<BcmsForm>`. Defaults to the SDK default. */\n apiBase?: string;\n /** Class for the wrapping <div>. */\n className?: string;\n}\n\n/** Render a page's blocks. Unknown/empty blocks render nothing (fail-soft). */\nexport function BcmsBlocks({\n blocks,\n forms,\n components,\n turnstileSiteKey,\n apiBase,\n className,\n}: BcmsBlocksProps): ReactElement {\n const formsById = new Map((forms ?? []).map((f) => [f.id, f]));\n const componentsById = new Map((components ?? []).map((cmp) => [cmp.id, cmp]));\n const ctx: RenderCtx = { formsById, componentsById, turnstileSiteKey, apiBase, depth: 0, seen: new Set() };\n return (\n /**\n * πŸ”΄ `data-bcms-page` marks THIS SUBTREE as ours to edit β€” the SDK's equivalent of the hosted\n * renderer's `<main class=\"bcms-page\">` (render-page.ts).\n *\n * The Visual Editor decides whether to show section controls by asking the page what it is.\n * Its only test was that hosted wrapper, which an SDK-rendered site never has β€” so every\n * headless site was treated as \"not ours\", and move/duplicate/delete/reorder stayed hidden\n * on pages that fully support them. Measured on a live SDK site: 34 blocks rendered,\n * 0 recognised.\n *\n * It must sit on the CONTAINER rather than be inferred from the blocks, so that a page with\n * NO blocks yet is still recognised β€” otherwise there is no way to add the first section,\n * which is exactly the state a new page starts in.\n */\n <div className={className} data-bcms-page=\"\">\n {blocks.map((block) => tagTopLevel(block, renderBlock(block, ctx)))}\n </div>\n );\n}\n\n/**\n * Stamp a TOP-LEVEL block's own id onto the element it rendered.\n *\n * The editor hit-tests `[data-bcms-block]` to find sections β€” for hover chrome, reorder targets,\n * drop indicators and per-section presence. Blocks already carried `bcms-block` CLASSES, which\n * look equivalent and are not: they are on every block at every depth and carry no id, so they\n * can identify neither which section you are pointing at nor which one to move.\n *\n * πŸ”΄ `cloneElement`, NOT a wrapper `<div>`. The hosted renderer wraps because it assembles HTML\n * strings and has no other option; here an extra element would land inside the customer's own\n * layout, breaking `>` child selectors and any grid/flex parent that counts its children. This\n * adds an attribute and changes no structure.\n *\n * Only the top level is tagged, deliberately: a section is a top-level block, and tagging nested\n * ones would make a column's child look like a section you could drag out of its parent.\n */\nfunction tagTopLevel(block: ContentBlock, node: ReactNode): ReactNode {\n // A block that rendered nothing (unknown type, fail-soft) has nothing to stamp β€” and stamping\n // a fragment or string would throw.\n if (!isValidElement(node)) return node;\n return cloneElement(node as ReactElement<Record<string, unknown>>, {\n \"data-bcms-block\": block.id,\n });\n}\n\ninterface RenderCtx {\n formsById: Map<string, DeliveryForm>;\n componentsById: Map<string, DeliveryComponent>;\n turnstileSiteKey?: string;\n apiBase?: string;\n depth: number;\n seen: Set<string>;\n}\n\nfunction renderBlock(block: ContentBlock, ctx: RenderCtx): ReactNode {\n const node = renderBlockInner(block, ctx);\n const style = blockStyleToCss(block.style);\n if (!style || node == null) return node;\n // FLO-264: honor the block's bounded style tokens in the headless render too, so\n // @bettercms-ai/next output matches the builder canvas + hosted site.\n return (\n <div key={block.id} style={style as CSSProperties}>\n {node}\n </div>\n );\n}\n\nfunction renderBlockInner(block: ContentBlock, ctx: RenderCtx): ReactNode {\n switch (block.type) {\n case \"heading\":\n return renderHeading(block);\n case \"text\":\n return renderText(block);\n case \"image\":\n return renderImage(block);\n case \"button\":\n return renderButton(block);\n case \"spacer\":\n return renderSpacer(block);\n case \"video\":\n return renderVideo(block);\n case \"columns\":\n return renderColumns(block, ctx);\n case \"form\":\n return renderForm(block, ctx);\n case \"section\":\n return renderSection(block, ctx);\n case \"navbar\":\n return renderNavbar(block);\n case \"footer\":\n return renderFooter(block);\n case \"slider\":\n return <BcmsSlider key={block.id} block={block} ctx={ctx} />;\n case \"tabs\":\n return <BcmsTabs key={block.id} block={block} ctx={ctx} />;\n case \"component\":\n return renderComponent(block, ctx);\n default:\n return null;\n }\n}\n\nfunction renderHeading({ id, props }: HeadingBlock): ReactNode {\n const Tag = `h${props.level ?? 2}` as \"h1\" | \"h2\" | \"h3\";\n return (\n <Tag key={id} className=\"bcms-block bcms-block--heading\" data-bcms-field={`${id}__text`}>\n {props.text}\n </Tag>\n );\n}\n\nfunction renderText({ id, props }: TextBlock): ReactNode {\n // `html` is sanitized server-side before storage.\n return (\n <div\n key={id}\n className=\"bcms-block bcms-block--text\"\n data-bcms-field={`${id}__html`}\n data-bcms-kind=\"richtext\"\n dangerouslySetInnerHTML={{ __html: props.html }}\n />\n );\n}\n\nfunction renderImage({ id, props }: ImageBlock): ReactNode {\n const img = (\n <img\n src={props.src}\n alt={props.alt}\n width={props.width}\n height={props.height}\n loading=\"lazy\"\n // Heading/text/button have always been click-to-edit on the Visual Editor canvas because\n // they carry this attribute; the image block did not, so a block page's images were the\n // one thing you could only change from the dock. `kind=\"image\"` keeps it selection-only\n // (no contentEditable on an <img>) while letting the editor reflect a new src live.\n data-bcms-field={`${id}__src`}\n data-bcms-kind=\"image\"\n />\n );\n if (!props.caption) {\n return (\n <figure key={id} className=\"bcms-block bcms-block--image\">\n {img}\n </figure>\n );\n }\n return (\n <figure key={id} className=\"bcms-block bcms-block--image\">\n {img}\n <figcaption>{props.caption}</figcaption>\n </figure>\n );\n}\n\nfunction renderButton({ id, props }: ButtonBlock): ReactNode {\n return (\n <a\n key={id}\n href={props.href}\n className={`bcms-block bcms-block--button bcms-button--${props.variant ?? \"primary\"}`}\n data-bcms-field={`${id}__text`}\n >\n {props.text}\n </a>\n );\n}\n\nfunction renderSpacer({ id, props }: SpacerBlock): ReactNode {\n return (\n <div\n key={id}\n className=\"bcms-block bcms-block--spacer\"\n style={{ height: props.height }}\n aria-hidden=\"true\"\n />\n );\n}\n\nfunction renderVideo({ id, props }: VideoBlock): ReactNode {\n return (\n <video\n key={id}\n className=\"bcms-block bcms-block--video\"\n src={props.url}\n poster={props.poster}\n autoPlay={props.autoplay}\n loop={props.loop}\n controls\n />\n );\n}\n\nfunction renderColumns({ id, props }: ColumnsBlock, ctx: RenderCtx): ReactNode {\n return (\n <div\n key={id}\n className=\"bcms-block bcms-block--columns\"\n style={{\n display: \"grid\",\n gridTemplateColumns: `repeat(${props.columns.length || 1}, 1fr)`,\n gap: props.gap,\n }}\n >\n {props.columns.map((column, i) => (\n <div key={i} className=\"bcms-column\">\n {column.map((child) => renderBlock(child, ctx))}\n </div>\n ))}\n </div>\n );\n}\n\nfunction renderForm({ id, props }: FormBlock, ctx: RenderCtx): ReactNode {\n const form = ctx.formsById.get(props.formId);\n if (!form) return null; // form deleted or not delivered β€” render nothing\n return (\n <div key={id} className=\"bcms-block bcms-block--form\">\n <BcmsForm form={form} turnstileSiteKey={ctx.turnstileSiteKey} apiBase={ctx.apiBase} />\n </div>\n );\n}\n\nfunction renderSection({ id, props }: SectionBlock, ctx: RenderCtx): ReactNode {\n const inner = props.children.map((child) => renderBlock(child, ctx));\n return (\n <section\n key={id}\n className=\"bcms-block bcms-block--section\"\n style={{ background: props.background, padding: props.paddingY != null ? `${props.paddingY}px 0` : undefined }}\n >\n {props.maxWidth ? <div style={{ maxWidth: props.maxWidth, margin: \"0 auto\" }}>{inner}</div> : inner}\n </section>\n );\n}\n\nfunction renderNavbar({ id, props }: NavbarBlock): ReactNode {\n return (\n <nav key={id} className=\"bcms-block bcms-block--navbar\">\n {props.logo?.src ? (\n <a className=\"bcms-navbar-logo\" href={props.logo.href ?? \"/\"}>\n <img src={props.logo.src} alt={props.logo.alt} />\n </a>\n ) : null}\n <div className=\"bcms-navbar-links\">\n {props.links.map((l, i) => (\n <a key={i} href={l.href}>\n {l.label}\n </a>\n ))}\n </div>\n {props.cta ? (\n <a className=\"bcms-button bcms-button--primary\" href={props.cta.href}>\n {props.cta.text}\n </a>\n ) : null}\n </nav>\n );\n}\n\nfunction renderFooter({ id, props }: FooterBlock): ReactNode {\n return (\n <footer key={id} className=\"bcms-block bcms-block--footer\">\n <div className=\"bcms-footer-cols\">\n {props.columns.map((col, i) => (\n <div key={i} className=\"bcms-footer-col\">\n {col.heading ? <h4>{col.heading}</h4> : null}\n <ul>\n {col.links.map((l, j) => (\n <li key={j}>\n <a href={l.href}>{l.label}</a>\n </li>\n ))}\n </ul>\n </div>\n ))}\n </div>\n {props.copyright ? <p className=\"bcms-footer-copy\">{props.copyright}</p> : null}\n </footer>\n );\n}\n\nfunction BcmsSlider({ block, ctx }: { block: SliderBlock; ctx: RenderCtx }): ReactElement {\n const { slides } = block.props;\n const [i, setI] = useState(0);\n const go = (n: number) => setI((n + slides.length) % (slides.length || 1));\n return (\n <div className=\"bcms-block bcms-block--slider\" style={{ position: \"relative\" }}>\n {slides.map((s, idx) => (\n <div key={s.id} className=\"bcms-slide\" hidden={idx !== i}>\n {s.children.map((child) => renderBlock(child, ctx))}\n </div>\n ))}\n <button type=\"button\" className=\"bcms-slider-prev\" aria-label=\"Previous\" onClick={() => go(i - 1)}>\n β€Ή\n </button>\n <button type=\"button\" className=\"bcms-slider-next\" aria-label=\"Next\" onClick={() => go(i + 1)}>\n β€Ί\n </button>\n </div>\n );\n}\n\nfunction BcmsTabs({ block, ctx }: { block: TabsBlock; ctx: RenderCtx }): ReactElement {\n const { tabs } = block.props;\n const [active, setActive] = useState(0);\n return (\n <div className=\"bcms-block bcms-block--tabs\">\n <div className=\"bcms-tablist\" role=\"tablist\">\n {tabs.map((t, idx) => (\n <button\n key={t.id}\n role=\"tab\"\n type=\"button\"\n className=\"bcms-tab\"\n aria-selected={idx === active}\n onClick={() => setActive(idx)}\n >\n {t.label}\n </button>\n ))}\n </div>\n {tabs.map((t, idx) => (\n <div key={t.id} role=\"tabpanel\" className=\"bcms-tabpanel\" hidden={idx !== active}>\n {t.children.map((child) => renderBlock(child, ctx))}\n </div>\n ))}\n </div>\n );\n}\n\nfunction renderComponent({ id, props }: ComponentBlock, ctx: RenderCtx): ReactNode {\n const def = ctx.componentsById.get(props.componentId);\n if (!def) return null; // not delivered β€” fail-soft\n if (ctx.depth >= MAX_COMPONENT_DEPTH || ctx.seen.has(def.id)) return null; // cycle/depth guard\n const resolved = applyOverrides<ContentBlock>(def.blockJson, def.props ?? [], props.overrides ?? {});\n const childCtx: RenderCtx = { ...ctx, depth: ctx.depth + 1, seen: new Set([...ctx.seen, def.id]) };\n return (\n <div key={id} className=\"bcms-block bcms-block--component\">\n {resolved.map((child) => renderBlock(child, childCtx))}\n </div>\n );\n}\n\n","\"use client\";\n\n/**\n * <BcmsForm> β€” render a BetterCMS form natively in React, the headless way.\n *\n * Pass a form straight from your content snapshot (`readSnapshot().forms[n]`) or\n * the delivery API. It renders real inputs (no iframe), handles conditional\n * `showIf` fields, URL-query prefill, the honeypot, an optional Turnstile widget,\n * and submits via `@bettercms-ai/sdk`'s `submitForm`. All visible markup is\n * unstyled and class-driven, so the host site owns the look.\n */\n\nimport { useEffect, useMemo, useState, type FormEvent, type ReactElement } from \"react\";\nimport {\n submitForm,\n shouldShowField,\n formInitialValues,\n asStringArray,\n toggleOption,\n type DeliveryForm,\n type DeliveryFormField,\n type FormValue,\n type FormValues,\n type FormSubmitError,\n} from \"@bettercms-ai/sdk\";\n\nconst TURNSTILE_SRC = \"https://challenges.cloudflare.com/turnstile/v0/api.js\";\n\n// Field type β†’ native <input type>. Other types render their own element.\nconst INPUT_TYPES: Partial<Record<DeliveryFormField[\"type\"], string>> = {\n text: \"text\",\n email: \"email\",\n phone: \"tel\",\n url: \"url\",\n number: \"number\",\n date: \"date\",\n};\n\nexport interface BcmsFormProps {\n /** A form from your content snapshot or the delivery API. */\n form: DeliveryForm;\n /** API origin. Defaults to the SDK default (https://api.bettercms.ai). */\n apiBase?: string;\n /** Turnstile site key β€” needed to render the widget when `form.turnstileEnabled`. */\n turnstileSiteKey?: string;\n /** Called with the new submission id after a successful submit (before any redirect). */\n onSubmitted?: (submissionId: string) => void;\n /** Class for the <form> element; field wrappers/status use `bcms-*` classes. */\n className?: string;\n}\n\ntype Status = { state: \"idle\" | \"submitting\" | \"error\" | \"success\"; message?: string };\n\nfunction readPrefill(): Record<string, string> {\n if (typeof window === \"undefined\") return {};\n const out: Record<string, string> = {};\n new URLSearchParams(window.location.search).forEach((v, k) => {\n out[k] = v;\n });\n return out;\n}\n\nfunction resetTurnstile(): void {\n const t = (globalThis as { turnstile?: { reset: () => void } }).turnstile;\n if (t) {\n try {\n t.reset();\n } catch {\n /* widget not mounted yet */\n }\n }\n}\n\nexport function BcmsForm({\n form,\n apiBase,\n turnstileSiteKey,\n onSubmitted,\n className,\n}: BcmsFormProps): ReactElement {\n const showTurnstile = Boolean(form.turnstileEnabled && turnstileSiteKey);\n const [values, setValues] = useState<FormValues>(() => {\n const init = formInitialValues(form, readPrefill());\n if (form.honeypotField) init[form.honeypotField] = \"\";\n return init;\n });\n const [status, setStatus] = useState<Status>({ state: \"idle\" });\n const [fieldErrors, setFieldErrors] = useState<Record<string, string>>({});\n\n // Cloudflare auto-renders any `.cf-turnstile` element once its script is present.\n useEffect(() => {\n if (!showTurnstile || document.querySelector(`script[src=\"${TURNSTILE_SRC}\"]`)) return;\n const script = document.createElement(\"script\");\n script.src = TURNSTILE_SRC;\n script.async = true;\n script.defer = true;\n document.head.appendChild(script);\n }, [showTurnstile]);\n\n const visibleFields = useMemo(\n () => form.fields.filter((f) => f.type !== \"hidden\" && shouldShowField(f, values)),\n [form.fields, values],\n );\n\n const setValue = (key: string, value: FormValue) =>\n setValues((prev) => ({ ...prev, [key]: value }));\n\n async function handleSubmit(e: FormEvent<HTMLFormElement>): Promise<void> {\n e.preventDefault();\n setStatus({ state: \"submitting\" });\n setFieldErrors({});\n\n const tokenEl = e.currentTarget.querySelector<HTMLInputElement>(\n '[name=\"cf-turnstile-response\"]',\n );\n const turnstileToken = tokenEl?.value || undefined;\n\n // Drop conditionally-hidden fields so a hidden required field can't block submit;\n // keep hidden-type fields and the honeypot (the API classifies bots on it).\n const data: FormValues = {};\n for (const field of form.fields) {\n if (field.type === \"hidden\" || shouldShowField(field, values)) {\n data[field.key] = values[field.key];\n }\n }\n if (form.honeypotField) data[form.honeypotField] = values[form.honeypotField] ?? \"\";\n\n try {\n const { id } = await submitForm({ formId: form.id, data, turnstileToken, baseUrl: apiBase });\n onSubmitted?.(id);\n if (form.redirectUrl) {\n window.location.href = form.redirectUrl;\n return;\n }\n const reset = formInitialValues(form);\n if (form.honeypotField) reset[form.honeypotField] = \"\";\n setValues(reset);\n setStatus({\n state: \"success\",\n message: form.successMessage ?? \"Thanks! Your submission was received.\",\n });\n resetTurnstile();\n } catch (err) {\n const e2 = err as FormSubmitError;\n if (e2.fieldErrors) setFieldErrors(e2.fieldErrors);\n setStatus({ state: \"error\", message: e2.message || \"Something went wrong. Please try again.\" });\n resetTurnstile();\n }\n }\n\n return (\n // `data-bcms-form` carries the id so the Visual Editor can find THIS form in the\n // preview frame and patch its copy live. Valued rather than bare: the runtime\n // selectors are `form[data-bcms-form]`, which a valued attribute still matches.\n <form className={className} onSubmit={handleSubmit} noValidate data-bcms-form={form.id}>\n {visibleFields.map((field) => (\n <Field\n key={field.key}\n field={field}\n value={values[field.key]}\n error={fieldErrors[field.key]}\n onChange={(v) => setValue(field.key, v)}\n />\n ))}\n\n {form.honeypotField ? (\n <span aria-hidden=\"true\" style={{ position: \"absolute\", left: \"-9999px\" }}>\n <input\n type=\"text\"\n name={form.honeypotField}\n tabIndex={-1}\n autoComplete=\"off\"\n value={String(values[form.honeypotField] ?? \"\")}\n onChange={(e) => setValue(form.honeypotField as string, e.target.value)}\n />\n </span>\n ) : null}\n\n {showTurnstile ? <div className=\"cf-turnstile\" data-sitekey={turnstileSiteKey} /> : null}\n\n <button type=\"submit\" disabled={status.state === \"submitting\"} data-bcms-form-part=\"submit\">\n {status.state === \"submitting\" ? \"Submitting…\" : form.submitLabel ?? \"Submit\"}\n </button>\n\n {status.message ? (\n <p\n className={`bcms-form-status bcms-form-status--${status.state}`}\n role=\"status\"\n aria-live=\"polite\"\n >\n {status.message}\n </p>\n ) : null}\n </form>\n );\n}\n\ninterface FieldProps {\n field: DeliveryFormField;\n value: FormValue;\n error?: string;\n onChange: (value: FormValue) => void;\n}\n\nfunction Field({ field, value, error, onChange }: FieldProps): ReactElement {\n const required = field.required;\n const errorNode = error ? (\n <span className=\"bcms-field-error\" role=\"alert\">\n {error}\n </span>\n ) : null;\n // Every author-editable string carries a `data-bcms-form-part` so the Visual Editor can\n // repaint it live. A string the dock can edit but cannot mark shows stale on the canvas.\n const helpNode = field.helpText ? (\n <span className=\"bcms-field-help\" data-bcms-form-part=\"help\">\n {field.helpText}\n </span>\n ) : null;\n\n if (field.type === \"checkbox\" || field.type === \"consent\") {\n return (\n <label\n className=\"bcms-field bcms-field--checkbox\"\n data-field={field.key}\n data-bcms-form-field={field.key}\n >\n <input\n type=\"checkbox\"\n name={field.key}\n required={required}\n checked={Boolean(value)}\n onChange={(e) => onChange(e.target.checked)}\n />{\" \"}\n <span data-bcms-form-part=\"label\">\n {field.label}\n {required ? \" *\" : \"\"}\n </span>\n {helpNode}\n {errorNode}\n </label>\n );\n }\n\n // Pick-one and pick-many are groups of controls, not a single element, so they\n // return their own <fieldset> rather than flowing into the label+control shape\n // below. Without these two branches both fell through to `<input type=\"text\">`.\n if (field.type === \"radio\" || field.type === \"checkboxes\") {\n const multi = field.type === \"checkboxes\";\n const selected = asStringArray(value);\n return (\n <fieldset\n className={`bcms-field bcms-field--${multi ? \"checkboxes\" : \"radio\"}`}\n data-field={field.key}\n data-bcms-form-field={field.key}\n >\n <legend data-bcms-form-part=\"label\">\n {field.label}\n {required ? \" *\" : \"\"}\n </legend>\n {(field.options ?? []).map((opt) => (\n <label key={opt} className=\"bcms-option\">\n <input\n type={multi ? \"checkbox\" : \"radio\"}\n name={field.key}\n value={opt}\n // `required` on every radio in a group is the native way to demand one\n // choice. On checkboxes it would demand ALL of them, so it is omitted β€”\n // the API enforces non-empty instead.\n required={!multi && required}\n checked={multi ? selected.includes(opt) : value === opt}\n onChange={(e) =>\n onChange(multi ? toggleOption(value, opt, e.target.checked) : opt)\n }\n />{\" \"}\n <span data-bcms-form-part=\"option\">{opt}</span>\n </label>\n ))}\n {helpNode}\n {errorNode}\n </fieldset>\n );\n }\n\n const str = String(value ?? \"\");\n let control: ReactElement;\n if (field.type === \"textarea\") {\n control = (\n <textarea\n name={field.key}\n placeholder={field.placeholder}\n required={required}\n value={str}\n onChange={(e) => onChange(e.target.value)}\n />\n );\n } else if (field.type === \"select\") {\n control = (\n <select name={field.key} required={required} value={str} onChange={(e) => onChange(e.target.value)}>\n <option value=\"\" disabled>\n Choose…\n </option>\n {(field.options ?? []).map((opt) => (\n <option key={opt} value={opt} data-bcms-form-part=\"option\">\n {opt}\n </option>\n ))}\n </select>\n );\n } else {\n control = (\n <input\n type={INPUT_TYPES[field.type] ?? \"text\"}\n name={field.key}\n placeholder={field.placeholder}\n required={required}\n value={str}\n onChange={(e) => onChange(e.target.value)}\n />\n );\n }\n\n return (\n <p className=\"bcms-field\" data-field={field.key} data-bcms-form-field={field.key}>\n <label data-bcms-form-part=\"label\">\n {field.label}\n {required ? \" *\" : \"\"}\n </label>\n <br />\n {control}\n {helpNode}\n {errorNode}\n </p>\n );\n}\n"],"mappings":";;;;AAgBA;AAAA,EACE;AAAA,EACA;AAAA,EACA,YAAAA;AAAA,OAIK;AACP,SAAS,uBAAuB;AAoBhC,SAAS,sBAAsB;;;AChC/B,SAAS,WAAW,SAAS,gBAAmD;AAChF;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAMK;AAkIH,SAEI,KAFJ;AAhIJ,IAAM,gBAAgB;AAGtB,IAAM,cAAkE;AAAA,EACtE,MAAM;AAAA,EACN,OAAO;AAAA,EACP,OAAO;AAAA,EACP,KAAK;AAAA,EACL,QAAQ;AAAA,EACR,MAAM;AACR;AAiBA,SAAS,cAAsC;AAC7C,MAAI,OAAO,WAAW,YAAa,QAAO,CAAC;AAC3C,QAAM,MAA8B,CAAC;AACrC,MAAI,gBAAgB,OAAO,SAAS,MAAM,EAAE,QAAQ,CAAC,GAAG,MAAM;AAC5D,QAAI,CAAC,IAAI;AAAA,EACX,CAAC;AACD,SAAO;AACT;AAEA,SAAS,iBAAuB;AAC9B,QAAM,IAAK,WAAqD;A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Z,gBAAAA;AAAA,MAAC;AAAA;AAAA,QAEC,MAAK;AAAA,QACL,MAAK;AAAA,QACL,WAAU;AAAA,QACV,iBAAe,QAAQ;AAAA,QACvB,SAAS,MAAM,UAAU,GAAG;AAAA,QAE3B,YAAE;AAAA;AAAA,MAPE,EAAE;AAAA,IAQT,CACD,GACH;AAAA,IACC,KAAK,IAAI,CAAC,GAAG,QACZ,gBAAAA,KAAC,SAAe,MAAK,YAAW,WAAU,iBAAgB,QAAQ,QAAQ,QACvE,YAAE,SAAS,IAAI,CAAC,UAAU,YAAY,OAAO,GAAG,CAAC,KAD1C,EAAE,EAEZ,CACD;AAAA,KACH;AAEJ;AAEA,SAAS,gBAAgB,EAAE,IAAI,MAAM,GAAmB,KAA2B;AACjF,QAAM,MAAM,IAAI,eAAe,IAAI,MAAM,WAAW;AACpD,MAAI,CAAC,IAAK,QAAO;AACjB,MAAI,IAAI,SAAS,uBAAuB,IAAI,KAAK,IAAI,IAAI,EAAE,EAAG,QAAO;AACrE,QAAM,WAAW,eAA6B,IAAI,WAAW,IAAI,SAAS,CAAC,GAAG,MAAM,aAAa,CAAC,CAAC;AACnG,QAAM,WAAsB,EAAE,GAAG,KAAK,OAAO,IAAI,QAAQ,GAAG,MAAM,oBAAI,IAAI,CAAC,GAAG,IAAI,MAAM,IAAI,EAAE,CAAC,EAAE;AACjG,SACE,gBAAAA,KAAC,SAAa,WAAU,oCACrB,mBAAS,IAAI,CAAC,UAAU,YAAY,OAAO,QAAQ,CAAC,KAD7C,EAEV;AAEJ;","names":["useState","jsx","jsxs","useState"]}
1
+ {"version":3,"sources":["../src/blocks.tsx","../src/form.tsx","../src/bindings.ts"],"sourcesContent":["\"use client\";\n\n/**\n * <BcmsBlocks> β€” render a BetterCMS page's block_json natively in React.\n *\n * Pass the `blocks` from a page (delivery API `/content/:slug` β†’ `entry.blocks`)\n * plus the `forms` you read with `readForms()`. Every block type renders to plain,\n * class-driven markup (the host site owns the styling); a `form` block resolves its\n * `formId` against `forms` and renders `<BcmsForm>` inline exactly where the user\n * placed it in the page builder. This is the turnkey \"Webflow\" path β€” forms show up\n * wherever they were dropped on the page, with no manual wiring.\n *\n * Ships from its own \"use client\" entry (like <BcmsForm>) so it can be rendered from\n * a Next App Router Server Component without breaking the RSC boundary.\n */\n\nimport {\n cloneElement,\n isValidElement,\n useState,\n type CSSProperties,\n type ReactElement,\n type ReactNode,\n} from \"react\";\nimport { blockStyleToCss } from \"@bettercms-ai/types\";\nimport type {\n ContentBlock,\n HeadingBlock,\n TextBlock,\n ImageBlock,\n ButtonBlock,\n SpacerBlock,\n VideoBlock,\n ColumnsBlock,\n FormBlock,\n SectionBlock,\n NavbarBlock,\n FooterBlock,\n SliderBlock,\n TabsBlock,\n ComponentBlock,\n DeliveryComponent,\n} from \"@bettercms-ai/types\";\nimport type { DeliveryForm } from \"@bettercms-ai/sdk\";\nimport { componentInstanceAddresses } from \"@bettercms-ai/types\";\nimport { applyOverrides } from \"@bettercms-ai/ui/resolve\";\nimport { BcmsForm } from \"./form.js\";\n\nconst MAX_COMPONENT_DEPTH = 10;\n\nexport interface BcmsBlocksProps {\n /** A page's blocks (delivery API `/content/:slug` β†’ `entry.blocks`). */\n blocks: ContentBlock[];\n /** Forms available to `form` blocks β€” from `readForms().forms`. */\n forms?: DeliveryForm[];\n /** Reusable components available to `component` blocks β€” from `readComponents()`. */\n components?: DeliveryComponent[];\n /** Turnstile site key β€” forwarded to `<BcmsForm>` for form blocks. */\n turnstileSiteKey?: string;\n /** API origin forwarded to `<BcmsForm>`. Defaults to the SDK default. */\n apiBase?: string;\n /** Class for the wrapping <div>. */\n className?: string;\n}\n\n/** Render a page's blocks. Unknown/empty blocks render nothing (fail-soft). */\nexport function BcmsBlocks({\n blocks,\n forms,\n components,\n turnstileSiteKey,\n apiBase,\n className,\n}: BcmsBlocksProps): ReactElement {\n const formsById = new Map((forms ?? []).map((f) => [f.id, f]));\n const componentsById = new Map((components ?? []).map((cmp) => [cmp.id, cmp]));\n const ctx: RenderCtx = { formsById, componentsById, turnstileSiteKey, apiBase, depth: 0, seen: new Set() };\n return (\n /**\n * πŸ”΄ `data-bcms-page` marks THIS SUBTREE as ours to edit β€” the SDK's equivalent of the hosted\n * renderer's `<main class=\"bcms-page\">` (render-page.ts).\n *\n * The Visual Editor decides whether to show section controls by asking the page what it is.\n * Its only test was that hosted wrapper, which an SDK-rendered site never has β€” so every\n * headless site was treated as \"not ours\", and move/duplicate/delete/reorder stayed hidden\n * on pages that fully support them. Measured on a live SDK site: 34 blocks rendered,\n * 0 recognised.\n *\n * It must sit on the CONTAINER rather than be inferred from the blocks, so that a page with\n * NO blocks yet is still recognised β€” otherwise there is no way to add the first section,\n * which is exactly the state a new page starts in.\n */\n <div className={className} data-bcms-page=\"\">\n {blocks.map((block) => tagTopLevel(block, renderBlock(block, ctx)))}\n </div>\n );\n}\n\n/**\n * Stamp a TOP-LEVEL block's own id onto the element it rendered.\n *\n * The editor hit-tests `[data-bcms-block]` to find sections β€” for hover chrome, reorder targets,\n * drop indicators and per-section presence. Blocks already carried `bcms-block` CLASSES, which\n * look equivalent and are not: they are on every block at every depth and carry no id, so they\n * can identify neither which section you are pointing at nor which one to move.\n *\n * πŸ”΄ `cloneElement`, NOT a wrapper `<div>`. The hosted renderer wraps because it assembles HTML\n * strings and has no other option; here an extra element would land inside the customer's own\n * layout, breaking `>` child selectors and any grid/flex parent that counts its children. This\n * adds an attribute and changes no structure.\n *\n * Only the top level is tagged, deliberately: a section is a top-level block, and tagging nested\n * ones would make a column's child look like a section you could drag out of its parent.\n */\nfunction tagTopLevel(block: ContentBlock, node: ReactNode): ReactNode {\n // A block that rendered nothing (unknown type, fail-soft) has nothing to stamp β€” and stamping\n // a fragment or string would throw.\n if (!isValidElement(node)) return node;\n return cloneElement(node as ReactElement<Record<string, unknown>>, {\n \"data-bcms-block\": block.id,\n });\n}\n\nimport { bind, bindProps } from \"./bindings.js\";\n\ninterface RenderCtx {\n formsById: Map<string, DeliveryForm>;\n componentsById: Map<string, DeliveryComponent>;\n turnstileSiteKey?: string;\n apiBase?: string;\n depth: number;\n seen: Set<string>;\n /**\n * Present only inside a component instance, where it is AUTHORITATIVE: it maps the\n * DEFINITION's `<blockId>__<prop>` to this instance's `<id>__overrides.<key>`. A prop the\n * definition does not declare resolves to nothing and is left unannotated, rather than\n * carrying a definition-scoped address that binds to no field.\n */\n fieldAddresses?: Map<string, string>;\n}\n\nfunction renderBlock(block: ContentBlock, ctx: RenderCtx): ReactNode {\n const node = renderBlockInner(block, ctx);\n const style = blockStyleToCss(block.style);\n if (!style || node == null) return node;\n // FLO-264: honor the block's bounded style tokens in the headless render too, so\n // @bettercms-ai/next output matches the builder canvas + hosted site.\n return (\n <div key={block.id} style={style as CSSProperties}>\n {node}\n </div>\n );\n}\n\nfunction renderBlockInner(block: ContentBlock, ctx: RenderCtx): ReactNode {\n switch (block.type) {\n case \"heading\":\n return renderHeading(block, ctx);\n // `richtext` and `text` carry the same payload and differ only in the authoring surface,\n // so delivery renders them identically β€” Astro (BcmsBlocks.astro) and the hosted renderer\n // (render-page.ts) both alias them. Next did not, so `richtext` fell to `default: null`\n // and a richtext block rendered NOTHING on a Next site: 200 OK, green build, blank region.\n case \"text\":\n case \"richtext\":\n return renderText(block as TextBlock, ctx);\n case \"image\":\n return renderImage(block, ctx);\n case \"button\":\n return renderButton(block, ctx);\n case \"spacer\":\n return renderSpacer(block);\n case \"video\":\n return renderVideo(block, ctx);\n case \"columns\":\n return renderColumns(block, ctx);\n case \"form\":\n return renderForm(block, ctx);\n case \"section\":\n return renderSection(block, ctx);\n case \"navbar\":\n return renderNavbar(block, ctx);\n case \"footer\":\n return renderFooter(block, ctx);\n case \"slider\":\n return <BcmsSlider key={block.id} block={block} ctx={ctx} />;\n case \"tabs\":\n return <BcmsTabs key={block.id} block={block} ctx={ctx} />;\n case \"component\":\n return renderComponent(block, ctx);\n default:\n return renderUnhandledBlock(block);\n }\n}\n\nfunction renderHeading({ id, props }: HeadingBlock, ctx: RenderCtx): ReactNode {\n const Tag = `h${props.level ?? 2}` as \"h1\" | \"h2\" | \"h3\";\n return (\n <Tag key={id} className=\"bcms-block bcms-block--heading\" {...bind(id, \"text\", \"text\", ctx)}>\n {props.text}\n </Tag>\n );\n}\n\nfunction renderText({ id, props }: TextBlock, ctx: RenderCtx): ReactNode {\n // `html` is sanitized server-side before storage.\n return (\n <div\n key={id}\n className=\"bcms-block bcms-block--text\"\n {...bind(id, \"html\", \"richtext\", ctx)}\n dangerouslySetInnerHTML={{ __html: props.html }}\n />\n );\n}\n\nfunction renderImage({ id, props }: ImageBlock, ctx: RenderCtx): ReactNode {\n const img = (\n <img\n src={props.src}\n alt={props.alt}\n width={props.width}\n height={props.height}\n loading=\"lazy\"\n // Heading/text/button have always been click-to-edit on the Visual Editor canvas because\n // they carry this attribute; the image block did not, so a block page's images were the\n // one thing you could only change from the dock. `kind=\"image\"` keeps it selection-only\n // (no contentEditable on an <img>) while letting the editor reflect a new src live.\n {...bind(id, \"src\", \"image\", ctx)}\n // `alt` rides the props lane: this <img> already carries the src binding and an element\n // cannot hold two addresses. It is also the one image property a screen-reader user\n // depends on, so leaving it dock-only made the canvas worse at the accessibility half.\n {...bindProps(id, [{ prop: \"alt\", kind: \"text\", attr: \"alt\", present: props.alt != null }], ctx)}\n />\n );\n if (!props.caption) {\n return (\n <figure key={id} className=\"bcms-block bcms-block--image\">\n {img}\n </figure>\n );\n }\n return (\n <figure key={id} className=\"bcms-block bcms-block--image\">\n {img}\n <figcaption {...bind(id, \"caption\", \"text\", ctx)}>{props.caption}</figcaption>\n </figure>\n );\n}\n\nfunction renderButton({ id, props }: ButtonBlock, ctx: RenderCtx): ReactNode {\n return (\n <a\n key={id}\n href={props.href}\n className={`bcms-block bcms-block--button bcms-button--${props.variant ?? \"primary\"}`}\n {...bind(id, \"text\", \"text\", ctx)}\n // A URL never takes a caret β€” typing one onto the page has nowhere to report a malformed\n // value β€” so it is addressed here and edited in the element toolbar.\n {...bindProps(id, [{ prop: \"href\", kind: \"url\", attr: \"href\", present: props.href != null }], ctx)}\n >\n {props.text}\n </a>\n );\n}\n\nfunction renderSpacer({ id, props }: SpacerBlock): ReactNode {\n return (\n <div\n key={id}\n className=\"bcms-block bcms-block--spacer\"\n style={{ height: props.height }}\n aria-hidden=\"true\"\n />\n );\n}\n\nfunction renderVideo({ id, props }: VideoBlock, ctx: RenderCtx): ReactNode {\n return (\n <video\n key={id}\n className=\"bcms-block bcms-block--video\"\n src={props.url}\n poster={props.poster}\n // A video has no text node at all, so it was the one block a click could not reach: no\n // binding meant no `data-node-id` and nothing to hit-test. Both its values are attributes,\n // so the props lane carries the whole block.\n {...bindProps(\n id,\n [\n { prop: \"url\", kind: \"url\", attr: \"src\", present: props.url != null },\n { prop: \"poster\", kind: \"url\", attr: \"poster\", present: props.poster != null },\n ],\n ctx,\n )}\n autoPlay={props.autoplay}\n loop={props.loop}\n controls\n />\n );\n}\n\nfunction renderColumns({ id, props }: ColumnsBlock, ctx: RenderCtx): ReactNode {\n return (\n <div\n key={id}\n className=\"bcms-block bcms-block--columns\"\n style={{\n display: \"grid\",\n gridTemplateColumns: `repeat(${props.columns.length || 1}, 1fr)`,\n gap: props.gap,\n }}\n >\n {props.columns.map((column, i) => (\n <div key={i} className=\"bcms-column\">\n {column.map((child) => renderBlock(child, ctx))}\n </div>\n ))}\n </div>\n );\n}\n\nfunction renderForm({ id, props }: FormBlock, ctx: RenderCtx): ReactNode {\n const form = ctx.formsById.get(props.formId);\n if (!form) return null; // form deleted or not delivered β€” render nothing\n return (\n <div key={id} className=\"bcms-block bcms-block--form\">\n <BcmsForm form={form} turnstileSiteKey={ctx.turnstileSiteKey} apiBase={ctx.apiBase} />\n </div>\n );\n}\n\nfunction renderSection({ id, props }: SectionBlock, ctx: RenderCtx): ReactNode {\n const inner = props.children.map((child) => renderBlock(child, ctx));\n return (\n <section\n key={id}\n className=\"bcms-block bcms-block--section\"\n style={{ background: props.background, padding: props.paddingY != null ? `${props.paddingY}px 0` : undefined }}\n >\n {/* πŸ”΄ `bcms-section-inner` β€” the Astro package and the hosted renderer both class this\n wrapper; Next was the only lane that left it bare. That is not cosmetic: the wrapper\n is CONDITIONAL on `maxWidth`, so a host stylesheet that wants to reach a section's\n children has to target `> div`, which also matches every classed block that happens\n to render as a div (a columns grid, a text block) and restyles their internals. With\n the class there, one selector covers all three lanes and nothing reaches past it.\n Toggling `maxWidth` in the editor must not silently retune a section's rhythm. */}\n {props.maxWidth ? (\n <div className=\"bcms-section-inner\" style={{ maxWidth: props.maxWidth, margin: \"0 auto\" }}>{inner}</div>\n ) : (\n inner\n )}\n </section>\n );\n}\n\n/**\n * Every link is addressed individually, by index. This was the flagship \"nested under arrays\"\n * exclusion, on the grounds that the writer could not reach it β€” but `parseFieldPath` and\n * `setFieldPath` have walked N indices since FLO-949 and `setValue` takes any path. Only the\n * offer was missing, so a site's navigation was uneditable on the canvas while being perfectly\n * writable through the dock.\n */\nfunction renderNavbar({ id, props }: NavbarBlock, ctx: RenderCtx): ReactNode {\n return (\n <nav key={id} className=\"bcms-block bcms-block--navbar\">\n {props.logo?.src ? (\n <a className=\"bcms-navbar-logo\" href={props.logo.href ?? \"/\"}>\n <img\n src={props.logo.src}\n alt={props.logo.alt}\n {...bind(id, \"logo.src\", \"image\", ctx)}\n {...bindProps(id, [{ prop: \"logo.alt\", kind: \"text\", attr: \"alt\", present: props.logo.alt != null }], ctx)}\n />\n </a>\n ) : null}\n <div className=\"bcms-navbar-links\">\n {props.links.map((l, i) => (\n <a\n key={i}\n href={l.href}\n {...bind(id, `links[${i}].label`, \"text\", ctx)}\n {...bindProps(id, [{ prop: `links[${i}].href`, kind: \"url\", attr: \"href\", present: l.href != null }], ctx)}\n >\n {l.label}\n </a>\n ))}\n </div>\n {props.cta ? (\n <a\n className=\"bcms-button bcms-button--primary\"\n href={props.cta.href}\n {...bind(id, \"cta.text\", \"text\", ctx)}\n {...bindProps(id, [{ prop: \"cta.href\", kind: \"url\", attr: \"href\", present: props.cta.href != null }], ctx)}\n >\n {props.cta.text}\n </a>\n ) : null}\n </nav>\n );\n}\n\n/**\n * A footer link is the deepest addressable thing on a page: `columns[i].links[j].label`, two\n * indices. That is the shape the old grammar note called unaddressable, and the shape the ENTRY\n * lane still refuses β€” but the two are different problems. The entry cap is about resolving a\n * repeater row's `_id` identity; a block path is direct, so there is no identity to resolve.\n */\nfunction renderFooter({ id, props }: FooterBlock, ctx: RenderCtx): ReactNode {\n return (\n <footer key={id} className=\"bcms-block bcms-block--footer\">\n <div className=\"bcms-footer-cols\">\n {props.columns.map((col, i) => (\n <div key={i} className=\"bcms-footer-col\">\n {col.heading ? <h4 {...bind(id, `columns[${i}].heading`, \"text\", ctx)}>{col.heading}</h4> : null}\n <ul>\n {col.links.map((l, j) => (\n <li key={j}>\n <a\n href={l.href}\n {...bind(id, `columns[${i}].links[${j}].label`, \"text\", ctx)}\n {...bindProps(\n id,\n [{ prop: `columns[${i}].links[${j}].href`, kind: \"url\", attr: \"href\", present: l.href != null }],\n ctx,\n )}\n >\n {l.label}\n </a>\n </li>\n ))}\n </ul>\n </div>\n ))}\n </div>\n {props.copyright ? (\n <p className=\"bcms-footer-copy\" {...bind(id, \"copyright\", \"text\", ctx)}>\n {props.copyright}\n </p>\n ) : null}\n </footer>\n );\n}\n\n/**\n * πŸ”΄ `...rest` is load-bearing, not tidiness. `tagTopLevel` stamps a top-level block by\n * `cloneElement`, which sets `data-bcms-block` as a PROP on this component β€” and a component\n * that does not spread it drops the attribute with no error and no warning. A top-level slider\n * or tabs block then renders perfectly and is invisible to the Visual Editor's section lane:\n * no move, no duplicate, no delete, no presence. Intrinsic elements do not have this failure\n * mode, which is why every other block type was fine and these two were not.\n */\nfunction BcmsSlider({ block, ctx, ...rest }: { block: SliderBlock; ctx: RenderCtx }): ReactElement {\n const { slides } = block.props;\n const [i, setI] = useState(0);\n const go = (n: number) => setI((n + slides.length) % (slides.length || 1));\n return (\n <div className=\"bcms-block bcms-block--slider\" style={{ position: \"relative\" }} {...rest}>\n {slides.map((s, idx) => (\n <div key={s.id} className=\"bcms-slide\" hidden={idx !== i}>\n {s.children.map((child) => renderBlock(child, ctx))}\n </div>\n ))}\n <button type=\"button\" className=\"bcms-slider-prev\" aria-label=\"Previous\" onClick={() => go(i - 1)}>\n β€Ή\n </button>\n <button type=\"button\" className=\"bcms-slider-next\" aria-label=\"Next\" onClick={() => go(i + 1)}>\n β€Ί\n </button>\n </div>\n );\n}\n\n/** `...rest` for the same reason as <BcmsSlider> above β€” see its comment. */\nfunction BcmsTabs({ block, ctx, ...rest }: { block: TabsBlock; ctx: RenderCtx }): ReactElement {\n const { tabs } = block.props;\n const [active, setActive] = useState(0);\n return (\n <div className=\"bcms-block bcms-block--tabs\" {...rest}>\n <div className=\"bcms-tablist\" role=\"tablist\">\n {tabs.map((t, idx) => (\n <button\n key={t.id}\n role=\"tab\"\n type=\"button\"\n className=\"bcms-tab\"\n aria-selected={idx === active}\n onClick={() => setActive(idx)}\n {...bind(block.id, `tabs[${idx}].label`, \"text\", ctx)}\n >\n {t.label}\n </button>\n ))}\n </div>\n {tabs.map((t, idx) => (\n <div key={t.id} role=\"tabpanel\" className=\"bcms-tabpanel\" hidden={idx !== active}>\n {t.children.map((child) => renderBlock(child, ctx))}\n </div>\n ))}\n </div>\n );\n}\n\n/**\n * Missing-component ids already reported. Module-level so a page that places the same section\n * twenty times logs once, not twenty times β€” a wall of identical lines is skipped, and this\n * message has to be read.\n */\nconst warnedMissing = new Set<string>();\n\nfunction renderComponent({ id, props }: ComponentBlock, ctx: RenderCtx): ReactNode {\n const def = ctx.componentsById.get(props.componentId);\n if (!def) return renderMissingComponent(props.componentId, ctx);\n if (ctx.depth >= MAX_COMPONENT_DEPTH || ctx.seen.has(def.id)) return null; // cycle/depth guard\n const resolved = applyOverrides<ContentBlock>(def.blockJson, def.props ?? [], props.overrides ?? {});\n // The instance's own addresses replace the definition's for the whole subtree. Without this\n // every stamp inside a component named a block shared by every instance of it: an orphan on\n // one placement, and a duplicate that drops BOTH on two.\n const childCtx: RenderCtx = {\n ...ctx,\n depth: ctx.depth + 1,\n seen: new Set([...ctx.seen, def.id]),\n fieldAddresses: componentInstanceAddresses(id, def.props),\n };\n return (\n <div key={id} className=\"bcms-block bcms-block--component\">\n {resolved.map((child) => renderBlock(child, childCtx))}\n </div>\n );\n}\n\n/**\n * A `component` block whose definition was not delivered.\n *\n * πŸ”΄ This used to be `return null // fail-soft`, and that comment was the bug. A page authored\n * as SECTIONS is a list of `component` blocks and nothing else, so \"fail-soft\" meant the entire\n * page body rendered as nothing while the build stayed green and the site answered 200 β€” what\n * remained on screen was the layout's own nav and footer. Two live sites were replaced by that\n * on 2026-08-18, and the only reason it was caught is that a human looked at the page.\n *\n * The near-universal cause is a host site that never passes `components` β€” the SDK's own README\n * example omitted it β€” so the message names the fix rather than the symptom.\n *\n * Still renders nothing in production: a placeholder box would be worse than a gap on a live\n * customer site. The console line ships in BOTH modes, because it is emitted during the build\n * and the build log is the one place a headless deploy can be inspected after the fact.\n */\nconst warnedUnhandled = new Set<string>();\n\n/**\n * A block type this renderer has no case for.\n *\n * `default: return null` is how `richtext` rendered NOTHING on a Next site for a whole release\n * β€” 200 OK, green build, blank region, no error anywhere. `collection` is in that state today:\n * it is delivered, the hosted renderer draws it, and this one silently drops it. Saying so out\n * loud does not implement the missing renderer, but it converts an invisible blank into a\n * message that names the type, which is the difference between a bug you find and one you ship.\n */\nfunction renderUnhandledBlock(block: ContentBlock): ReactNode {\n if (!warnedUnhandled.has(block.type)) {\n warnedUnhandled.add(block.type);\n // eslint-disable-next-line no-console\n console.warn(\n `[BcmsBlocks] block type \"${block.type}\" has no renderer here, so it rendered NOTHING. ` +\n `The hosted renderer draws it; this SDK does not yet.`,\n );\n }\n return null;\n}\n\nfunction renderMissingComponent(componentId: string, ctx: RenderCtx): ReactNode {\n if (!warnedMissing.has(componentId)) {\n warnedMissing.add(componentId);\n // eslint-disable-next-line no-console\n console.warn(\n `[BcmsBlocks] component \"${componentId}\" was not delivered, so this section rendered NOTHING.` +\n (ctx.componentsById.size === 0\n ? ` No components were passed at all β€” add components={readComponents()} to <BcmsBlocks>.`\n : ` ${ctx.componentsById.size} component(s) were passed but none match. It is probably still a DRAFT: publish it, then rebuild.`),\n );\n }\n if (process.env.NODE_ENV === \"production\") return null;\n return (\n <div\n className=\"bcms-block bcms-block--component-missing\"\n data-bcms-missing-component={componentId}\n style={{\n padding: \"12px 16px\",\n border: \"1px dashed #d4d4d8\",\n borderRadius: 8,\n color: \"#71717a\",\n font: \"500 13px/1.5 system-ui, -apple-system, sans-serif\",\n }}\n >\n Section <code>{componentId}</code> was not delivered.{\" \"}\n {ctx.componentsById.size === 0\n ? \"Pass components={readComponents()} to <BcmsBlocks>.\"\n : \"Publish the component, then rebuild.\"}\n </div>\n );\n}\n\n","\"use client\";\n\n/**\n * <BcmsForm> β€” render a BetterCMS form natively in React, the headless way.\n *\n * Pass a form straight from your content snapshot (`readSnapshot().forms[n]`) or\n * the delivery API. It renders real inputs (no iframe), handles conditional\n * `showIf` fields, URL-query prefill, the honeypot, an optional Turnstile widget,\n * and submits via `@bettercms-ai/sdk`'s `submitForm`. All visible markup is\n * unstyled and class-driven, so the host site owns the look.\n */\n\nimport { useEffect, useMemo, useState, type FormEvent, type ReactElement } from \"react\";\nimport {\n submitForm,\n shouldShowField,\n formInitialValues,\n asStringArray,\n toggleOption,\n type DeliveryForm,\n type DeliveryFormField,\n type FormValue,\n type FormValues,\n type FormSubmitError,\n} from \"@bettercms-ai/sdk\";\n\nconst TURNSTILE_SRC = \"https://challenges.cloudflare.com/turnstile/v0/api.js\";\n\n// Field type β†’ native <input type>. Other types render their own element.\nconst INPUT_TYPES: Partial<Record<DeliveryFormField[\"type\"], string>> = {\n text: \"text\",\n email: \"email\",\n phone: \"tel\",\n url: \"url\",\n number: \"number\",\n date: \"date\",\n};\n\nexport interface BcmsFormProps {\n /** A form from your content snapshot or the delivery API. */\n form: DeliveryForm;\n /** API origin. Defaults to the SDK default (https://api.bettercms.ai). */\n apiBase?: string;\n /** Turnstile site key β€” needed to render the widget when `form.turnstileEnabled`. */\n turnstileSiteKey?: string;\n /** Called with the new submission id after a successful submit (before any redirect). */\n onSubmitted?: (submissionId: string) => void;\n /** Class for the <form> element; field wrappers/status use `bcms-*` classes. */\n className?: string;\n}\n\ntype Status = { state: \"idle\" | \"submitting\" | \"error\" | \"success\"; message?: string };\n\nfunction readPrefill(): Record<string, string> {\n if (typeof window === \"undefined\") return {};\n const out: Record<string, string> = {};\n new URLSearchParams(window.location.search).forEach((v, k) => {\n out[k] = v;\n });\n return out;\n}\n\nfunction resetTurnstile(): void {\n const t = (globalThis as { turnstile?: { reset: () => void } }).turnstile;\n if (t) {\n try {\n t.reset();\n } catch {\n /* widget not mounted yet */\n }\n }\n}\n\nexport function BcmsForm({\n form,\n apiBase,\n turnstileSiteKey,\n onSubmitted,\n className,\n}: BcmsFormProps): ReactElement {\n const showTurnstile = Boolean(form.turnstileEnabled && turnstileSiteKey);\n const [values, setValues] = useState<FormValues>(() => {\n const init = formInitialValues(form, readPrefill());\n if (form.honeypotField) init[form.honeypotField] = \"\";\n return init;\n });\n const [status, setStatus] = useState<Status>({ state: \"idle\" });\n const [fieldErrors, setFieldErrors] = useState<Record<string, string>>({});\n\n // Cloudflare auto-renders any `.cf-turnstile` element once its script is present.\n useEffect(() => {\n if (!showTurnstile || document.querySelector(`script[src=\"${TURNSTILE_SRC}\"]`)) return;\n const script = document.createElement(\"script\");\n script.src = TURNSTILE_SRC;\n script.async = true;\n script.defer = true;\n document.head.appendChild(script);\n }, [showTurnstile]);\n\n const visibleFields = useMemo(\n () => form.fields.filter((f) => f.type !== \"hidden\" && shouldShowField(f, values)),\n [form.fields, values],\n );\n\n const setValue = (key: string, value: FormValue) =>\n setValues((prev) => ({ ...prev, [key]: value }));\n\n async function handleSubmit(e: FormEvent<HTMLFormElement>): Promise<void> {\n e.preventDefault();\n setStatus({ state: \"submitting\" });\n setFieldErrors({});\n\n const tokenEl = e.currentTarget.querySelector<HTMLInputElement>(\n '[name=\"cf-turnstile-response\"]',\n );\n const turnstileToken = tokenEl?.value || undefined;\n\n // Drop conditionally-hidden fields so a hidden required field can't block submit;\n // keep hidden-type fields and the honeypot (the API classifies bots on it).\n const data: FormValues = {};\n for (const field of form.fields) {\n if (field.type === \"hidden\" || shouldShowField(field, values)) {\n data[field.key] = values[field.key];\n }\n }\n if (form.honeypotField) data[form.honeypotField] = values[form.honeypotField] ?? \"\";\n\n try {\n const { id } = await submitForm({ formId: form.id, data, turnstileToken, baseUrl: apiBase });\n onSubmitted?.(id);\n if (form.redirectUrl) {\n window.location.href = form.redirectUrl;\n return;\n }\n const reset = formInitialValues(form);\n if (form.honeypotField) reset[form.honeypotField] = \"\";\n setValues(reset);\n setStatus({\n state: \"success\",\n message: form.successMessage ?? \"Thanks! Your submission was received.\",\n });\n resetTurnstile();\n } catch (err) {\n const e2 = err as FormSubmitError;\n if (e2.fieldErrors) setFieldErrors(e2.fieldErrors);\n setStatus({ state: \"error\", message: e2.message || \"Something went wrong. Please try again.\" });\n resetTurnstile();\n }\n }\n\n return (\n // `data-bcms-form` carries the id so the Visual Editor can find THIS form in the\n // preview frame and patch its copy live. Valued rather than bare: the runtime\n // selectors are `form[data-bcms-form]`, which a valued attribute still matches.\n <form className={className} onSubmit={handleSubmit} noValidate data-bcms-form={form.id}>\n {visibleFields.map((field) => (\n <Field\n key={field.key}\n field={field}\n value={values[field.key]}\n error={fieldErrors[field.key]}\n onChange={(v) => setValue(field.key, v)}\n />\n ))}\n\n {form.honeypotField ? (\n <span aria-hidden=\"true\" style={{ position: \"absolute\", left: \"-9999px\" }}>\n <input\n type=\"text\"\n name={form.honeypotField}\n tabIndex={-1}\n autoComplete=\"off\"\n value={String(values[form.honeypotField] ?? \"\")}\n onChange={(e) => setValue(form.honeypotField as string, e.target.value)}\n />\n </span>\n ) : null}\n\n {showTurnstile ? <div className=\"cf-turnstile\" data-sitekey={turnstileSiteKey} /> : null}\n\n <button type=\"submit\" disabled={status.state === \"submitting\"} data-bcms-form-part=\"submit\">\n {status.state === \"submitting\" ? \"Submitting…\" : form.submitLabel ?? \"Submit\"}\n </button>\n\n {status.message ? (\n <p\n className={`bcms-form-status bcms-form-status--${status.state}`}\n role=\"status\"\n aria-live=\"polite\"\n >\n {status.message}\n </p>\n ) : null}\n </form>\n );\n}\n\ninterface FieldProps {\n field: DeliveryFormField;\n value: FormValue;\n error?: string;\n onChange: (value: FormValue) => void;\n}\n\nfunction Field({ field, value, error, onChange }: FieldProps): ReactElement {\n const required = field.required;\n const errorNode = error ? (\n <span className=\"bcms-field-error\" role=\"alert\">\n {error}\n </span>\n ) : null;\n // Every author-editable string carries a `data-bcms-form-part` so the Visual Editor can\n // repaint it live. A string the dock can edit but cannot mark shows stale on the canvas.\n const helpNode = field.helpText ? (\n <span className=\"bcms-field-help\" data-bcms-form-part=\"help\">\n {field.helpText}\n </span>\n ) : null;\n\n if (field.type === \"checkbox\" || field.type === \"consent\") {\n return (\n <label\n className=\"bcms-field bcms-field--checkbox\"\n data-field={field.key}\n data-bcms-form-field={field.key}\n >\n <input\n type=\"checkbox\"\n name={field.key}\n required={required}\n checked={Boolean(value)}\n onChange={(e) => onChange(e.target.checked)}\n />{\" \"}\n <span data-bcms-form-part=\"label\">\n {field.label}\n {required ? \" *\" : \"\"}\n </span>\n {helpNode}\n {errorNode}\n </label>\n );\n }\n\n // Pick-one and pick-many are groups of controls, not a single element, so they\n // return their own <fieldset> rather than flowing into the label+control shape\n // below. Without these two branches both fell through to `<input type=\"text\">`.\n if (field.type === \"radio\" || field.type === \"checkboxes\") {\n const multi = field.type === \"checkboxes\";\n const selected = asStringArray(value);\n return (\n <fieldset\n className={`bcms-field bcms-field--${multi ? \"checkboxes\" : \"radio\"}`}\n data-field={field.key}\n data-bcms-form-field={field.key}\n >\n <legend data-bcms-form-part=\"label\">\n {field.label}\n {required ? \" *\" : \"\"}\n </legend>\n {(field.options ?? []).map((opt) => (\n <label key={opt} className=\"bcms-option\">\n <input\n type={multi ? \"checkbox\" : \"radio\"}\n name={field.key}\n value={opt}\n // `required` on every radio in a group is the native way to demand one\n // choice. On checkboxes it would demand ALL of them, so it is omitted β€”\n // the API enforces non-empty instead.\n required={!multi && required}\n checked={multi ? selected.includes(opt) : value === opt}\n onChange={(e) =>\n onChange(multi ? toggleOption(value, opt, e.target.checked) : opt)\n }\n />{\" \"}\n <span data-bcms-form-part=\"option\">{opt}</span>\n </label>\n ))}\n {helpNode}\n {errorNode}\n </fieldset>\n );\n }\n\n const str = String(value ?? \"\");\n let control: ReactElement;\n if (field.type === \"textarea\") {\n control = (\n <textarea\n name={field.key}\n placeholder={field.placeholder}\n required={required}\n value={str}\n onChange={(e) => onChange(e.target.value)}\n />\n );\n } else if (field.type === \"select\") {\n control = (\n <select name={field.key} required={required} value={str} onChange={(e) => onChange(e.target.value)}>\n <option value=\"\" disabled>\n Choose…\n </option>\n {(field.options ?? []).map((opt) => (\n <option key={opt} value={opt} data-bcms-form-part=\"option\">\n {opt}\n </option>\n ))}\n </select>\n );\n } else {\n control = (\n <input\n type={INPUT_TYPES[field.type] ?? \"text\"}\n name={field.key}\n placeholder={field.placeholder}\n required={required}\n value={str}\n onChange={(e) => onChange(e.target.value)}\n />\n );\n }\n\n return (\n <p className=\"bcms-field\" data-field={field.key} data-bcms-form-field={field.key}>\n <label data-bcms-form-part=\"label\">\n {field.label}\n {required ? \" *\" : \"\"}\n </label>\n <br />\n {control}\n {helpNode}\n {errorNode}\n </p>\n );\n}\n","/**\n * Visual Editor addresses for the Next renderer.\n *\n * The attributes are ALWAYS on, deliberately β€” a headless site's HTML is the customer's own,\n * `data-bcms-*` is inert for visitors, and there is no request-time draft render to gate them\n * against. That has been true since they were introduced; what was wrong is WHICH address they\n * carried inside a component.\n *\n * A component's block ids belong to the DEFINITION and are shared by every instance of it, so a\n * definition-scoped `<defBlockId>__text` resolves to no field in the loaded entry β€” the editor\n * logs it as an orphan β€” and two instances of one component produce the SAME address twice,\n * which `stampNodeIds` drops from BOTH. The hosted renderer avoided this by rendering component\n * subtrees unannotated; this one had no equivalent, so it emitted live-looking attributes that\n * bound to nothing. `addresses` fixes it at the source instead: inside an instance the map is\n * authoritative and resolves each declared prop to `<instanceId>__overrides.<key>`.\n */\nimport type { BindingKind } from \"@bettercms-ai/types\";\nimport { formatPropsAttribute } from \"@bettercms-ai/types\";\n\n/** The subset of the render context binding needs. */\nexport interface BindingCtx {\n /** Present only inside a component instance, where it is AUTHORITATIVE. */\n fieldAddresses?: Map<string, string>;\n}\n\n/** The address a write lands on, or null when none exists and nothing should be advertised. */\nexport function addressFor(id: string | undefined, prop: string, ctx: BindingCtx): string | null {\n if (!id) return null;\n const key = `${id}__${prop}`;\n if (ctx.fieldAddresses) return ctx.fieldAddresses.get(key) ?? null;\n return key;\n}\n\n/**\n * Attributes for a value rendered as this element's own content β€” spread onto the JSX tag.\n * Returns an empty object when unaddressable, so it spreads to nothing.\n */\nexport function bind(\n id: string | undefined,\n prop: string,\n kind: BindingKind,\n ctx: BindingCtx,\n): Record<string, string> {\n const address = addressFor(id, prop, ctx);\n return address ? { \"data-bcms-field\": address, \"data-bcms-kind\": kind } : {};\n}\n\n/**\n * Attributes for values that live in an ATTRIBUTE of this element (`alt`, `href`, a video's\n * `src`). `data-bcms-field` addresses one element and an element cannot hold two, so these ride\n * `data-bcms-props`: `<address>|<kind>|<domAttribute>`, semicolon separated.\n *\n * Entries whose value is absent are dropped: `setFieldPath` refuses to create a final key, so\n * an address for a key the block does not carry is a write the editor would reject.\n */\nexport function bindProps(\n id: string | undefined,\n entries: readonly { prop: string; kind: BindingKind; attr: string; present: boolean }[],\n ctx: BindingCtx,\n): Record<string, string> {\n const resolved = entries.flatMap(({ prop, kind, attr, present }) => {\n if (!present) return [];\n const address = addressFor(id, prop, ctx);\n return address ? [{ address, kind, attr }] : [];\n });\n return resolved.length ? { \"data-bcms-props\": formatPropsAttribute(resolved) } : {};\n}\n"],"mappings":";;;;AAgBA;AAAA,EACE;AAAA,E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;AAAA,QACT,QAAQ;AAAA,QACR,cAAc;AAAA,QACd,OAAO;AAAA,QACP,MAAM;AAAA,MACR;AAAA,MACD;AAAA;AAAA,QACS,gBAAAD,KAAC,UAAM,uBAAY;AAAA,QAAO;AAAA,QAAoB;AAAA,QACrD,IAAI,eAAe,SAAS,IACzB,wDACA;AAAA;AAAA;AAAA,EACN;AAEJ;","names":["useState","jsx","jsxs","useState"]}
@@ -0,0 +1,41 @@
1
+ import { ReactElement } from 'react';
2
+ import { BcmsBlocksProps } from './blocks.js';
3
+ import '@bettercms-ai/types';
4
+ import '@bettercms-ai/sdk';
5
+
6
+ /**
7
+ * BcmsDraftBridge β€” the site half of the visual editor's draft bridge (FLO-1178).
8
+ *
9
+ * Wrap your page's blocks in this instead of calling <BcmsBlocks> directly and the BetterCMS
10
+ * visual editor can re-render your DRAFTS β€” structure included β€” with YOUR components and CSS,
11
+ * so the canvas never falls back to the platform's approximate renderer for this site:
12
+ *
13
+ * import { BcmsDraftBridge } from "@bettercms-ai/next/draft-bridge";
14
+ * <BcmsDraftBridge slug={slug} blocks={page.blocks} components={readComponents()} … />
15
+ *
16
+ * Standalone (not framed) it renders byte-for-byte what <BcmsBlocks> renders β€” the bridge
17
+ * never wakes. Inside the editor, the EDITOR feeds the bridge over postMessage (Storyblok's
18
+ * model): the site never fetches drafts itself, so no credentials ever enter the page.
19
+ *
20
+ * Protocol, all same-origin (the editor serves the site through a same-origin proxy):
21
+ *
22
+ * editor β†’ site { type: "bcms:bridge-init" }
23
+ * site β†’ editor { type: "bcms:bridge-ready", slug }
24
+ * editor β†’ site { type: "bcms:draft-doc", slug, blocks, components? }
25
+ *
26
+ * The acceptance predicate has three parts, all required β€” (i) `event.origin` equals this
27
+ * page's own origin, (ii) the sender IS the parent frame, (iii) a draft doc is accepted only
28
+ * after this component's own init→ready handshake. A third-party page that iframes the live
29
+ * site sits on a foreign origin, so every message fails (i): the bridge adds zero attack
30
+ * surface to visitors. Draft content riding a push is the same trust tier the site already
31
+ * renders from the CMS snapshot β€” the editor is the same author surface.
32
+ *
33
+ * Hydration-safe by construction: initial state IS the server-rendered snapshot; a draft doc
34
+ * can only arrive after mount.
35
+ */
36
+
37
+ declare function BcmsDraftBridge({ slug, blocks, components, ...rest }: BcmsBlocksProps & {
38
+ slug: string;
39
+ }): ReactElement;
40
+
41
+ export { BcmsDraftBridge };