@bettercms-ai/next 0.25.0 → 0.26.1

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/blocks.d.ts CHANGED
@@ -35,9 +35,9 @@ interface BcmsBlocksProps {
35
35
  */
36
36
  now?: Date;
37
37
  /**
38
- * Draw the blocks outside their window too, marked `data-bcms-window="pending|expired"`.
39
- * For a draft preview, where an author must be able to find what they scheduled. Off, a block
40
- * outside its window is not rendered, at any depth.
38
+ * Draw the blocks outside their window too, marked `data-bcms-window="pending|expired"`, and the
39
+ * blocks hidden on every breakpoint, marked `data-bcms-hidden="all"`. For a draft preview, where
40
+ * an author must be able to find what they scheduled or hid. Off, neither is rendered, at any depth.
41
41
  */
42
42
  showScheduled?: boolean;
43
43
  }
package/dist/blocks.js CHANGED
@@ -7,11 +7,11 @@ import {
7
7
  isValidElement,
8
8
  useState as useState2
9
9
  } from "react";
10
- import { RESPONSIVE_CSS, blockStyleToCss, blockStyleToInnerCss, hideOnAttr, usesHideOn, visibleBlocks, windowState, splitButtonStyle, buttonIconOf, buttonIconSvg, buttonVariantOf, headingPaintCss, withButtonLookProps } from "@bettercms-ai/types";
10
+ import { RESPONSIVE_CSS, imageFrameCss, blockStyleToCss, blockStyleToInnerCss, hideOnAttr, hiddenEverywhere, usesHideOn, visibleBlocks, windowState, splitButtonStyle, buttonIconOf, buttonIconSvg, buttonVariantOf, headingPaintCss, withButtonLookProps } from "@bettercms-ai/types";
11
11
  import { componentInstanceAddresses } from "@bettercms-ai/types";
12
12
  import { applyOverrides } from "@bettercms-ai/ui/resolve";
13
13
  import { PortableText } from "@bettercms-ai/ui/blocks";
14
- import { embeddedComponentBlock, readStructuredContent } from "@bettercms-ai/richtext";
14
+ import { embeddedComponentRender, readStructuredContent } from "@bettercms-ai/richtext";
15
15
  import { headingParts, richtextHeadingLevel } from "@bettercms-ai/richtext/heading";
16
16
 
17
17
  // src/form.tsx
@@ -468,8 +468,12 @@ function tagTopLevel(block, node) {
468
468
  function renderBlock(block, ctx) {
469
469
  const node = renderStyledBlock(block, ctx);
470
470
  const state = ctx.showScheduled && ctx.now ? windowState(block, ctx.now) : "live";
471
- if (state === "live" || !isValidElement(node)) return node;
472
- return cloneElement(node, { "data-bcms-window": state });
471
+ const hidden = !!ctx.showScheduled && hiddenEverywhere(block);
472
+ if (state === "live" && !hidden || !isValidElement(node)) return node;
473
+ return cloneElement(node, {
474
+ ...state === "live" ? {} : { "data-bcms-window": state },
475
+ ...hidden ? { "data-bcms-hidden": "all" } : {}
476
+ });
473
477
  }
474
478
  function renderStyledBlock(block, ctx) {
475
479
  const node = renderBlockInner(block, ctx);
@@ -541,8 +545,12 @@ function renderText({ id, props, style }, ctx) {
541
545
  if (structured) {
542
546
  const base = addressFor(id, "html", ctx);
543
547
  const renderEmbed = (value) => {
544
- const embed = embeddedComponentBlock(value);
545
- return embed ? renderComponent(embed, { ...ctx, owner: base }) : void 0;
548
+ const embed = embeddedComponentRender(value);
549
+ if (!embed) return void 0;
550
+ if (embed.kind === "linked") return renderComponent(embed.block, { ...ctx, owner: base });
551
+ const { copy } = embed;
552
+ const childCtx = { ...ctx, depth: ctx.depth + 1, fieldAddresses: /* @__PURE__ */ new Map(), owner: void 0 };
553
+ return /* @__PURE__ */ jsx2("div", { className: "bcms-block bcms-block--component", "data-bcms-component-copy": copy.componentId, "data-bcms-instance": copy.id, children: copy.blocks.map((child) => renderBlock(child, childCtx)) });
546
554
  };
547
555
  return /* @__PURE__ */ jsx2("div", { className: "bcms-block bcms-block--text", children: /* @__PURE__ */ jsx2(PortableText, { value: structured, ...base ? { bindingBase: base } : {}, renderBlock: renderEmbed }) }, id);
548
556
  }
@@ -556,7 +564,8 @@ function renderText({ id, props, style }, ctx) {
556
564
  id
557
565
  );
558
566
  }
559
- function renderImage({ id, props }, ctx) {
567
+ function renderImage({ id, props, style }, ctx) {
568
+ if (!String(props.src ?? "").trim()) return null;
560
569
  const img = /* @__PURE__ */ jsx2(
561
570
  "img",
562
571
  {
@@ -564,7 +573,7 @@ function renderImage({ id, props }, ctx) {
564
573
  alt: props.alt,
565
574
  width: props.width,
566
575
  height: props.height,
567
- style: props.width ? { width: `${props.width}px`, maxWidth: "100%", height: "auto" } : void 0,
576
+ style: imageFrameCss(style) ?? (props.width ? { width: `${props.width}px`, maxWidth: "100%", height: "auto" } : void 0),
568
577
  loading: "lazy",
569
578
  ...bind(id, "src", "image", ctx),
570
579
  ...bindProps(id, [{ prop: "alt", kind: "text", attr: "alt", present: props.alt != null }], ctx)
@@ -581,13 +590,21 @@ function renderImage({ id, props }, ctx) {
581
590
  function renderButton({ id, props, style }, ctx) {
582
591
  const icon = buttonIconOf(props.icon);
583
592
  const paint = splitButtonStyle(style).paint;
593
+ const className = `bcms-block bcms-block--button bcms-button--${buttonVariantOf(props.variant)}${props.size === "sm" || props.size === "lg" ? ` bcms-button--${props.size}` : ""}${props.fullWidth === true ? " bcms-button--full" : ""}`;
594
+ if (props.action === "code") {
595
+ return /* @__PURE__ */ jsxs2("button", { type: "button", style: paint, className, ...bind(id, "text", "text", ctx), children: [
596
+ icon && /* @__PURE__ */ jsx2("span", { className: "bcms-button__icon", dangerouslySetInnerHTML: { __html: buttonIconSvg(icon, "bcms-btn-icon") } }),
597
+ props.text,
598
+ props.arrow === true && /* @__PURE__ */ jsx2("span", { className: "bcms-button__arrow", dangerouslySetInnerHTML: { __html: buttonIconSvg("arrow-right", "bcms-btn-arrow") } })
599
+ ] }, id);
600
+ }
584
601
  return /* @__PURE__ */ jsxs2(
585
602
  "a",
586
603
  {
587
604
  href: props.href,
588
605
  style: paint,
589
606
  ...props.newTab === true ? { target: "_blank", rel: "noopener noreferrer" } : {},
590
- className: `bcms-block bcms-block--button bcms-button--${buttonVariantOf(props.variant)}${props.size === "sm" || props.size === "lg" ? ` bcms-button--${props.size}` : ""}${props.fullWidth === true ? " bcms-button--full" : ""}`,
607
+ className,
591
608
  ...bind(id, "text", "text", ctx),
592
609
  ...bindProps(id, [{ prop: "href", kind: "url", attr: "href", present: props.href != null }], ctx),
593
610
  children: [
@@ -1 +1 @@
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 { RESPONSIVE_CSS, blockStyleToCss, blockStyleToInnerCss, hideOnAttr, usesHideOn, visibleBlocks, windowState, splitButtonStyle, buttonIconOf, buttonIconSvg, buttonVariantOf, headingPaintCss, withButtonLookProps } 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 { PortableText } from \"@bettercms-ai/ui/blocks\";\nimport { embeddedComponentBlock, readStructuredContent } from \"@bettercms-ai/richtext\";\nimport { headingParts, richtextHeadingLevel } from \"@bettercms-ai/richtext/heading\";\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 * The instant block windows (`block.window`) are read against. Defaults to the render time: the\n * build for a static page, the request for a server-rendered one.\n */\n now?: Date;\n /**\n * Draw the blocks outside their window too, marked `data-bcms-window=\"pending|expired\"`.\n * For a draft preview, where an author must be able to find what they scheduled. Off, a block\n * outside its window is not rendered, at any depth.\n */\n showScheduled?: boolean;\n}\n\n/** Render a page's blocks. Unknown/empty blocks render nothing (fail-soft). */\nexport function BcmsBlocks({\n blocks: all,\n forms,\n components,\n turnstileSiteKey,\n apiBase,\n className,\n now,\n showScheduled,\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 at = now ?? new Date();\n const blocks = showScheduled ? all : visibleBlocks(all, at);\n const ctx: RenderCtx = { formsById, componentsById, turnstileSiteKey, apiBase, depth: 0, seen: new Set(), now: at, showScheduled };\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 {/* Only when a block hides somewhere, so a page without `hideOn` renders exactly as before. */}\n {usesHideOn([blocks, components]) && <style dangerouslySetInnerHTML={{ __html: RESPONSIVE_CSS }} />}\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, addressFor } 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 * Set only for a component EMBEDDED in rich text: the rich-text field's address, which names\n * the instance (`<owner>#<_key>`), or null when that field has none — so the embed gets no\n * addresses rather than a bare `_key` that resolves to nothing.\n */\n owner?: string | null;\n /** The instant block windows are read against, and whether a block outside its window is drawn (marked). */\n now?: Date;\n showScheduled?: boolean;\n}\n\n/**\n * One block, with its window mark. `<BcmsBlocks>` has already removed every block outside its\n * window unless `showScheduled`; then the block is drawn and its root says which side of the\n * window it is on. `cloneElement`, for the reason `tagTopLevel` gives.\n */\nfunction renderBlock(block: ContentBlock, ctx: RenderCtx): ReactNode {\n const node = renderStyledBlock(block, ctx);\n const state = ctx.showScheduled && ctx.now ? windowState(block, ctx.now) : \"live\";\n if (state === \"live\" || !isValidElement(node)) return node;\n return cloneElement(node as ReactElement<Record<string, unknown>>, { \"data-bcms-window\": state });\n}\n\nfunction renderStyledBlock(block: ContentBlock, ctx: RenderCtx): ReactNode {\n const node = renderBlockInner(block, ctx);\n // A button's paint is on its `<a>` (renderButton); its wrapper only places it, as on hosted.\n const own = block.type === \"button\" ? splitButtonStyle(block.style).placement : block.style;\n const style = blockStyleToCss(own);\n const inner = blockStyleToInnerCss(own);\n const hide = hideOnAttr(own);\n if ((!style && !inner && !hide) || node == null) return node;\n /**\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 *\n * The content column (`contentWidth`) is a SECOND box inside the style wrapper, as on the hosted\n * lane (`applyBlockStyle`): the wrapper keeps the full-bleed background and the inner box is the\n * only thing that narrows. With a column and no other style the column box is the root itself.\n * Either way the outermost element is what `tagTopLevel` stamps with `data-bcms-block`.\n */\n const column = inner ? (\n <div key={block.id} className=\"bcms-block-inner\" style={inner}>\n {node}\n </div>\n ) : node;\n if (!style && !hide) return column;\n // `data-bcms-hide` is the hook `RESPONSIVE_CSS` keys on (see <BcmsBlocks>); it rides the wrapper.\n return (\n <div key={block.id} style={style as CSSProperties | undefined} {...(hide ? { \"data-bcms-hide\": hide } : {})}>\n {column}\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, style }: HeadingBlock, ctx: RenderCtx): ReactNode {\n const Tag = `h${props.level ?? 2}` as \"h1\" | \"h2\" | \"h3\";\n // HEADING-STYLE-PAINT: size/weight on the <hN> itself; undefined (neither token) ⇒ no attribute.\n const paint = headingPaintCss(style, { level: props.level ?? 2 }) as CSSProperties | undefined;\n return (\n <Tag key={id} className=\"bcms-block bcms-block--heading\" style={paint} {...bind(id, \"text\", \"text\", ctx)}>\n {props.text}\n </Tag>\n );\n}\n\nfunction renderText({ id, props, style }: TextBlock, ctx: RenderCtx): ReactNode {\n /**\n * `props.level` renders the rich copy AS <hN> — the same markup the hosted renderer emits\n * (src/lib/richtext/heading.ts), assembled by the SAME shared helper so the three lanes cannot\n * drift. Absent ⇒ the ordinary container below, byte-identical to before. A value that is not\n * one line of inline copy falls through rather than nesting paragraphs inside a heading.\n *\n * The heading serialises its structured value to a STRING rather than mounting <PortableText>:\n * the hosted and Astro lanes both emit the string, and `parity.test.ts` compares the markup.\n */\n const level = richtextHeadingLevel(props.level);\n if (level) {\n const heading = headingParts(props, addressFor(id, \"html\", ctx));\n if (heading !== null) {\n const Tag = `h${level}` as \"h1\";\n const binding = heading.address\n ? { \"data-bcms-field\": heading.address, \"data-bcms-kind\": \"richtext\" }\n : {};\n const paint = headingPaintCss(style, { level }) as CSSProperties | undefined;\n return <Tag key={id} style={paint} {...binding} dangerouslySetInnerHTML={{ __html: heading.inner }} />;\n }\n }\n\n /**\n * STRUCTURED CONTENT WINS, and until now this lane did not know it existed.\n *\n * The hosted renderer preferred `props.content` over `props.html` and the shared React\n * renderer did too, but this file read `html` unconditionally — so a block whose structured\n * value had diverged from its derived cache rendered the STALE cache on Next sites and the\n * fresh value everywhere else. Silent, per-lane, and green in CI, which is the same shape as\n * the bug that made `richtext` render nothing at all here for a whole release.\n *\n * `addressFor`, not a hand-built `${id}__html`: inside a placed component the address has to\n * be remapped to the instance, or the binding resolves to no field and two instances of one\n * component collide into a duplicate that drops both.\n */\n const structured = readStructuredContent(props);\n if (structured) {\n const base = addressFor(id, \"html\", ctx);\n // A component embedded in the text mounts through the ordinary `component` block.\n const renderEmbed = (value: Record<string, unknown>): ReactNode => {\n const embed = embeddedComponentBlock(value);\n return embed ? renderComponent(embed, { ...ctx, owner: base }) : undefined;\n };\n return (\n <div key={id} className=\"bcms-block bcms-block--text\">\n <PortableText value={structured} {...(base ? { bindingBase: base } : {})} renderBlock={renderEmbed} />\n </div>\n );\n }\n\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\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 // The hosted page gets this from its stylesheet (`.bcms-page img`); a Next site has no such\n // rule, so a set width would overflow a narrower column. A style also beats a site's\n // `img { width: 100% }`, which a bare attribute does not.\n style={props.width ? { width: `${props.width}px`, maxWidth: \"100%\", height: \"auto\" } : undefined}\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, style }: ButtonBlock, ctx: RenderCtx): ReactNode {\n const icon = buttonIconOf(props.icon);\n const paint = splitButtonStyle(style).paint;\n return (\n <a\n key={id}\n href={props.href}\n style={paint as CSSProperties | undefined}\n {...(props.newTab === true ? { target: \"_blank\", rel: \"noopener noreferrer\" } : {})}\n className={`bcms-block bcms-block--button bcms-button--${buttonVariantOf(props.variant)}${props.size === \"sm\" || props.size === \"lg\" ? ` bcms-button--${props.size}` : \"\"}${props.fullWidth === true ? \" bcms-button--full\" : \"\"}`}\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 {icon && <span className=\"bcms-button__icon\" dangerouslySetInnerHTML={{ __html: buttonIconSvg(icon, \"bcms-btn-icon\") }} />}\n {props.text}\n {props.arrow === true && <span className=\"bcms-button__arrow\" dangerouslySetInnerHTML={{ __html: buttonIconSvg(\"arrow-right\", \"bcms-btn-arrow\") }} />}\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 // A Button's instance may override its look too.\n const resolved = applyOverrides<ContentBlock>(def.blockJson, withButtonLookProps(def), props.overrides ?? {});\n // A definition holds no window (the write refuses one); one that slipped in is still honoured.\n const shown = ctx.showScheduled || !ctx.now ? resolved : visibleBlocks(resolved, ctx.now);\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: ctx.owner === null ? new Map() : componentInstanceAddresses(id, def.props, ctx.owner),\n owner: undefined,\n };\n return (\n <div\n key={id}\n className=\"bcms-block bcms-block--component\"\n data-bcms-component={def.id}\n data-bcms-variant=\"base\"\n data-bcms-instance={id}\n >\n {shown.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","\"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 { lazy, Suspense, useEffect, useMemo, useRef, 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/**\n * The country-picker phone control, loaded only when a form actually has one.\n *\n * It carries libphonenumber's metadata (~80KB), which no form without a picker should pay\n * for. The import specifier must survive into `dist/form.js` rather than being inlined —\n * see the `external` entry in tsup.config.ts and the dist greps in the tests.\n */\nconst PhoneField = lazy(() => import(\"./phone-field.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\ntype Page = { label: string | null; key: string | null; fields: DeliveryFormField[] };\n\n/**\n * Cut the flat field list into pages at its `step` dividers, or null when it has none. Fields\n * before the first divider are page 1; an empty page is dropped. The hosted renderer and\n * BcmsForm.astro carry the same rule: each package publishes on its own, so none of them can\n * count on a newer shared helper arriving with it.\n */\nfunction splitSteps(fields: DeliveryFormField[]): Page[] | null {\n if (!fields.some((f) => f.type === \"step\")) return null;\n const pages: Page[] = [];\n let cur: Page = { label: null, key: null, fields: [] };\n for (const f of fields) {\n if (f.type !== \"step\") {\n cur.fields.push(f);\n continue;\n }\n if (cur.fields.length) pages.push(cur);\n cur = { label: f.label, key: f.key, fields: [] };\n }\n if (cur.fields.length) pages.push(cur);\n return pages;\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 // Steps. Until the component has mounted every page is shown, so server-rendered output (and a\n // visitor without JavaScript) gets one long form; `enhanced` then turns it into pages.\n const pages = useMemo(() => splitSteps(form.fields), [form.fields]);\n const [enhanced, setEnhanced] = useState(false);\n const [step, setStep] = useState(0);\n const pageRefs = useRef<(HTMLFieldSetElement | null)[]>([]);\n const headingRefs = useRef<(HTMLHeadingElement | null)[]>([]);\n const moveFocus = useRef(false);\n const last = pages ? pages.length - 1 : 0;\n const paged = Boolean(pages && enhanced);\n useEffect(() => setEnhanced(true), []);\n // Focus follows the visitor to the new page's heading, never on first paint.\n useEffect(() => {\n if (!moveFocus.current) return;\n moveFocus.current = false;\n headingRefs.current[step]?.focus();\n }, [step]);\n\n // The browser's own validity, for ONE page: the first control that fails reports its message.\n function pageInvalid(i: number): boolean {\n const controls = pageRefs.current[i]?.querySelectorAll<HTMLInputElement>(\"input,select,textarea\") ?? [];\n for (const c of controls) {\n if (!c.checkValidity()) {\n c.reportValidity();\n return true;\n }\n }\n return false;\n }\n function goTo(i: number): void {\n moveFocus.current = true;\n setStep(i);\n }\n function next(): void {\n if (!pageInvalid(step)) goTo(step + 1);\n }\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\" && f.type !== \"step\" && 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 // Enter inside a field before the last page moves on rather than submitting half a form.\n if (paged && step < last) return next();\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 === \"step\") continue; // a divider is never an answer\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 setStep(0);\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) {\n setFieldErrors(e2.fieldErrors);\n // The server found a problem on a page the visitor has left: take them back to it.\n const bad = pages?.findIndex((p) => p.fields.some((f) => e2.fieldErrors?.[f.key]));\n if (bad !== undefined && bad >= 0) goTo(bad);\n }\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 {pages\n ? pages.map((page, i) => (\n <fieldset\n key={page.key ?? \"first\"}\n ref={(el) => {\n pageRefs.current[i] = el;\n }}\n className=\"bcms-step\"\n data-bcms-step={i + 1}\n hidden={paged && i !== step}\n aria-labelledby={`bcms-step-${form.id}-${i + 1}`}\n >\n <h3\n id={`bcms-step-${form.id}-${i + 1}`}\n className=\"bcms-step-title\"\n tabIndex={-1}\n ref={(el) => {\n headingRefs.current[i] = el;\n }}\n data-bcms-form-field={page.key ?? undefined}\n >\n <span className=\"bcms-step-count\">\n Step {i + 1} of {pages.length}\n </span>\n {page.label ? (\n <>\n {\" \"}\n <span data-bcms-form-part=\"label\">{page.label}</span>\n </>\n ) : null}\n </h3>\n {visibleFields\n .filter((f) => page.fields.includes(f))\n .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 {paged ? (\n <div className=\"bcms-step-nav\">\n {i > 0 ? (\n <button type=\"button\" data-bcms-step-back onClick={() => goTo(i - 1)}>\n Back\n </button>\n ) : null}\n {i < last ? (\n <button type=\"button\" data-bcms-step-next onClick={next}>\n Next\n </button>\n ) : null}\n </div>\n ) : null}\n </fieldset>\n ))\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\n type=\"submit\"\n hidden={paged && step < last}\n disabled={status.state === \"submitting\"}\n data-bcms-form-part=\"submit\"\n >\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 if (field.type === \"phone\" && field.ui?.countryPicker) {\n // The fallback is a usable tel input inside the SAME wrapper, so the host's `.bcms-phone`\n // rules apply before and after the chunk lands and the swap is not a layout surprise.\n control = (\n <Suspense\n fallback={\n <span className=\"bcms-phone\">\n <input type=\"tel\" name={field.key} placeholder={field.placeholder} required={required} value={str} onChange={(e) => onChange(e.target.value)} autoComplete=\"tel\" dir=\"ltr\" />\n </span>\n }\n >\n <PhoneField\n name={field.key}\n value={str}\n onChange={onChange}\n placeholder={field.placeholder}\n required={required}\n defaultCountry={field.ui.defaultCountry}\n />\n </Suspense>\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, which\n * `stampNodeIds` numbers as two COPIES of that one orphan (`data-node-index`) rather than two\n * fields: editing either edits nothing, on 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,EACA;AAAA,EACA,YAAAA;AAAA,OAIK;AACP,SAAS,gBAAgB,iBAAiB,sBAAsB,YAAY,YAAY,eAAe,aAAa,kBAAkB,cAAc,eAAe,iBAAiB,iBAAiB,2BAA2B;AAoBhO,SAAS,kCAAkC;AAC3C,SAAS,sBAAsB;AAC/B,SAAS,oBAAoB;AAC7B,SAAS,wBAAwB,6BAA6B;AAC9D,SAAS,cAAc,4BAA4B;;;ACpCnD,SAAS,MAAM,UAAU,WAAW,SAAS,QAAQ,gBAAmD;AACxG;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAMK;AAuOS,SAIE,UAEE,KANJ;AArOhB,IAAM,gBAAgB;AAStB,IAAM,aAAa,KAAK,MAAM,OAAO,kBAAkB,CAAC;AAGxD,IAAM,cAAkE;AAAA,EACtE,MAAM;AAAA,EACN,OAAO;AAAA,EACP,OAAO;AAAA,EACP,KAAK;AAAA,EACL,QAAQ;AAAA,EACR,MAAM;AACR;AAiBA,SAAS,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A,EACN;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 { RESPONSIVE_CSS, imageFrameCss, blockStyleToCss, blockStyleToInnerCss, hideOnAttr, hiddenEverywhere, usesHideOn, visibleBlocks, windowState, splitButtonStyle, buttonIconOf, buttonIconSvg, buttonVariantOf, headingPaintCss, withButtonLookProps } 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 { PortableText } from \"@bettercms-ai/ui/blocks\";\nimport { embeddedComponentRender, readStructuredContent } from \"@bettercms-ai/richtext\";\nimport { headingParts, richtextHeadingLevel } from \"@bettercms-ai/richtext/heading\";\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 * The instant block windows (`block.window`) are read against. Defaults to the render time: the\n * build for a static page, the request for a server-rendered one.\n */\n now?: Date;\n /**\n * Draw the blocks outside their window too, marked `data-bcms-window=\"pending|expired\"`, and the\n * blocks hidden on every breakpoint, marked `data-bcms-hidden=\"all\"`. For a draft preview, where\n * an author must be able to find what they scheduled or hid. Off, neither is rendered, at any depth.\n */\n showScheduled?: boolean;\n}\n\n/** Render a page's blocks. Unknown/empty blocks render nothing (fail-soft). */\nexport function BcmsBlocks({\n blocks: all,\n forms,\n components,\n turnstileSiteKey,\n apiBase,\n className,\n now,\n showScheduled,\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 at = now ?? new Date();\n const blocks = showScheduled ? all : visibleBlocks(all, at);\n const ctx: RenderCtx = { formsById, componentsById, turnstileSiteKey, apiBase, depth: 0, seen: new Set(), now: at, showScheduled };\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 {/* Only when a block hides somewhere, so a page without `hideOn` renders exactly as before. */}\n {usesHideOn([blocks, components]) && <style dangerouslySetInnerHTML={{ __html: RESPONSIVE_CSS }} />}\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, addressFor } 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 * Set only for a component EMBEDDED in rich text: the rich-text field's address, which names\n * the instance (`<owner>#<_key>`), or null when that field has none — so the embed gets no\n * addresses rather than a bare `_key` that resolves to nothing.\n */\n owner?: string | null;\n /** The instant block windows are read against, and whether a block outside its window is drawn (marked). */\n now?: Date;\n showScheduled?: boolean;\n}\n\n/**\n * One block, with its window mark. `<BcmsBlocks>` has already removed every block outside its\n * window unless `showScheduled`; then the block is drawn and its root says which side of the\n * window it is on. `cloneElement`, for the reason `tagTopLevel` gives.\n */\nfunction renderBlock(block: ContentBlock, ctx: RenderCtx): ReactNode {\n const node = renderStyledBlock(block, ctx);\n const state = ctx.showScheduled && ctx.now ? windowState(block, ctx.now) : \"live\";\n // Hidden on every breakpoint: drawn only with `showScheduled` (pruned otherwise), and marked.\n const hidden = !!ctx.showScheduled && hiddenEverywhere(block);\n if ((state === \"live\" && !hidden) || !isValidElement(node)) return node;\n return cloneElement(node as ReactElement<Record<string, unknown>>, {\n ...(state === \"live\" ? {} : { \"data-bcms-window\": state }),\n ...(hidden ? { \"data-bcms-hidden\": \"all\" } : {}),\n });\n}\n\nfunction renderStyledBlock(block: ContentBlock, ctx: RenderCtx): ReactNode {\n const node = renderBlockInner(block, ctx);\n // A button's paint is on its `<a>` (renderButton); its wrapper only places it, as on hosted.\n const own = block.type === \"button\" ? splitButtonStyle(block.style).placement : block.style;\n const style = blockStyleToCss(own);\n const inner = blockStyleToInnerCss(own);\n const hide = hideOnAttr(own);\n if ((!style && !inner && !hide) || node == null) return node;\n /**\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 *\n * The content column (`contentWidth`) is a SECOND box inside the style wrapper, as on the hosted\n * lane (`applyBlockStyle`): the wrapper keeps the full-bleed background and the inner box is the\n * only thing that narrows. With a column and no other style the column box is the root itself.\n * Either way the outermost element is what `tagTopLevel` stamps with `data-bcms-block`.\n */\n const column = inner ? (\n <div key={block.id} className=\"bcms-block-inner\" style={inner}>\n {node}\n </div>\n ) : node;\n if (!style && !hide) return column;\n // `data-bcms-hide` is the hook `RESPONSIVE_CSS` keys on (see <BcmsBlocks>); it rides the wrapper.\n return (\n <div key={block.id} style={style as CSSProperties | undefined} {...(hide ? { \"data-bcms-hide\": hide } : {})}>\n {column}\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, style }: HeadingBlock, ctx: RenderCtx): ReactNode {\n const Tag = `h${props.level ?? 2}` as \"h1\" | \"h2\" | \"h3\";\n // HEADING-STYLE-PAINT: size/weight on the <hN> itself; undefined (neither token) ⇒ no attribute.\n const paint = headingPaintCss(style, { level: props.level ?? 2 }) as CSSProperties | undefined;\n return (\n <Tag key={id} className=\"bcms-block bcms-block--heading\" style={paint} {...bind(id, \"text\", \"text\", ctx)}>\n {props.text}\n </Tag>\n );\n}\n\nfunction renderText({ id, props, style }: TextBlock, ctx: RenderCtx): ReactNode {\n /**\n * `props.level` renders the rich copy AS <hN> — the same markup the hosted renderer emits\n * (src/lib/richtext/heading.ts), assembled by the SAME shared helper so the three lanes cannot\n * drift. Absent ⇒ the ordinary container below, byte-identical to before. A value that is not\n * one line of inline copy falls through rather than nesting paragraphs inside a heading.\n *\n * The heading serialises its structured value to a STRING rather than mounting <PortableText>:\n * the hosted and Astro lanes both emit the string, and `parity.test.ts` compares the markup.\n */\n const level = richtextHeadingLevel(props.level);\n if (level) {\n const heading = headingParts(props, addressFor(id, \"html\", ctx));\n if (heading !== null) {\n const Tag = `h${level}` as \"h1\";\n const binding = heading.address\n ? { \"data-bcms-field\": heading.address, \"data-bcms-kind\": \"richtext\" }\n : {};\n const paint = headingPaintCss(style, { level }) as CSSProperties | undefined;\n return <Tag key={id} style={paint} {...binding} dangerouslySetInnerHTML={{ __html: heading.inner }} />;\n }\n }\n\n /**\n * STRUCTURED CONTENT WINS, and until now this lane did not know it existed.\n *\n * The hosted renderer preferred `props.content` over `props.html` and the shared React\n * renderer did too, but this file read `html` unconditionally — so a block whose structured\n * value had diverged from its derived cache rendered the STALE cache on Next sites and the\n * fresh value everywhere else. Silent, per-lane, and green in CI, which is the same shape as\n * the bug that made `richtext` render nothing at all here for a whole release.\n *\n * `addressFor`, not a hand-built `${id}__html`: inside a placed component the address has to\n * be remapped to the instance, or the binding resolves to no field and two instances of one\n * component collide into a duplicate that drops both.\n */\n const structured = readStructuredContent(props);\n if (structured) {\n const base = addressFor(id, \"html\", ctx);\n // A component embedded in the text mounts through the ordinary `component` block.\n const renderEmbed = (value: Record<string, unknown>): ReactNode => {\n const embed = embeddedComponentRender(value);\n if (!embed) return undefined;\n if (embed.kind === \"linked\") return renderComponent(embed.block, { ...ctx, owner: base });\n // A separate copy draws its own frozen blocks and never looks the component up.\n const { copy } = embed;\n const childCtx: RenderCtx = { ...ctx, depth: ctx.depth + 1, fieldAddresses: new Map(), owner: undefined };\n return (\n <div className=\"bcms-block bcms-block--component\" data-bcms-component-copy={copy.componentId} data-bcms-instance={copy.id}>\n {(copy.blocks as ContentBlock[]).map((child) => renderBlock(child, childCtx))}\n </div>\n );\n };\n return (\n <div key={id} className=\"bcms-block bcms-block--text\">\n <PortableText value={structured} {...(base ? { bindingBase: base } : {})} renderBlock={renderEmbed} />\n </div>\n );\n }\n\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\n\nfunction renderImage({ id, props, style }: ImageBlock, ctx: RenderCtx): ReactNode {\n // An unset src renders nothing, figure included, as on the hosted lane (render-page D3): `src=\"\"`\n // would request the page itself and draw a broken image. Null also skips the style wrapper.\n if (!String(props.src ?? \"\").trim()) return null;\n const img = (\n <img\n src={props.src}\n alt={props.alt}\n width={props.width}\n height={props.height}\n // The hosted page gets this from its stylesheet (`.bcms-page img`); a Next site has no such\n // rule, so a set width would overflow a narrower column. A style also beats a site's\n // `img { width: 100% }`, which a bare attribute does not.\n // V2's media frame (`style.aspect`), drawn as the hosted lane draws it (imageFrameCss).\n style={imageFrameCss(style) ?? (props.width ? { width: `${props.width}px`, maxWidth: \"100%\", height: \"auto\" } : undefined)}\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, style }: ButtonBlock, ctx: RenderCtx): ReactNode {\n const icon = buttonIconOf(props.icon);\n const paint = splitButtonStyle(style).paint;\n const className = `bcms-block bcms-block--button bcms-button--${buttonVariantOf(props.variant)}${props.size === \"sm\" || props.size === \"lg\" ? ` bcms-button--${props.size}` : \"\"}${props.fullWidth === true ? \" bcms-button--full\" : \"\"}`;\n // The site's script owns the click: a `<button type=\"button\">`, never an anchor with an invented href.\n if (props.action === \"code\") {\n return (\n <button key={id} type=\"button\" style={paint as CSSProperties | undefined} className={className} {...bind(id, \"text\", \"text\", ctx)}>\n {icon && <span className=\"bcms-button__icon\" dangerouslySetInnerHTML={{ __html: buttonIconSvg(icon, \"bcms-btn-icon\") }} />}\n {props.text}\n {props.arrow === true && <span className=\"bcms-button__arrow\" dangerouslySetInnerHTML={{ __html: buttonIconSvg(\"arrow-right\", \"bcms-btn-arrow\") }} />}\n </button>\n );\n }\n return (\n <a\n key={id}\n href={props.href}\n style={paint as CSSProperties | undefined}\n {...(props.newTab === true ? { target: \"_blank\", rel: \"noopener noreferrer\" } : {})}\n className={className}\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 {icon && <span className=\"bcms-button__icon\" dangerouslySetInnerHTML={{ __html: buttonIconSvg(icon, \"bcms-btn-icon\") }} />}\n {props.text}\n {props.arrow === true && <span className=\"bcms-button__arrow\" dangerouslySetInnerHTML={{ __html: buttonIconSvg(\"arrow-right\", \"bcms-btn-arrow\") }} />}\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 // A Button's instance may override its look too.\n const resolved = applyOverrides<ContentBlock>(def.blockJson, withButtonLookProps(def), props.overrides ?? {});\n // A definition holds no window (the write refuses one); one that slipped in is still honoured.\n const shown = ctx.showScheduled || !ctx.now ? resolved : visibleBlocks(resolved, ctx.now);\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: ctx.owner === null ? new Map() : componentInstanceAddresses(id, def.props, ctx.owner),\n owner: undefined,\n };\n return (\n <div\n key={id}\n className=\"bcms-block bcms-block--component\"\n data-bcms-component={def.id}\n data-bcms-variant=\"base\"\n data-bcms-instance={id}\n >\n {shown.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","\"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 { lazy, Suspense, useEffect, useMemo, useRef, 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/**\n * The country-picker phone control, loaded only when a form actually has one.\n *\n * It carries libphonenumber's metadata (~80KB), which no form without a picker should pay\n * for. The import specifier must survive into `dist/form.js` rather than being inlined —\n * see the `external` entry in tsup.config.ts and the dist greps in the tests.\n */\nconst PhoneField = lazy(() => import(\"./phone-field.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\ntype Page = { label: string | null; key: string | null; fields: DeliveryFormField[] };\n\n/**\n * Cut the flat field list into pages at its `step` dividers, or null when it has none. Fields\n * before the first divider are page 1; an empty page is dropped. The hosted renderer and\n * BcmsForm.astro carry the same rule: each package publishes on its own, so none of them can\n * count on a newer shared helper arriving with it.\n */\nfunction splitSteps(fields: DeliveryFormField[]): Page[] | null {\n if (!fields.some((f) => f.type === \"step\")) return null;\n const pages: Page[] = [];\n let cur: Page = { label: null, key: null, fields: [] };\n for (const f of fields) {\n if (f.type !== \"step\") {\n cur.fields.push(f);\n continue;\n }\n if (cur.fields.length) pages.push(cur);\n cur = { label: f.label, key: f.key, fields: [] };\n }\n if (cur.fields.length) pages.push(cur);\n return pages;\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 // Steps. Until the component has mounted every page is shown, so server-rendered output (and a\n // visitor without JavaScript) gets one long form; `enhanced` then turns it into pages.\n const pages = useMemo(() => splitSteps(form.fields), [form.fields]);\n const [enhanced, setEnhanced] = useState(false);\n const [step, setStep] = useState(0);\n const pageRefs = useRef<(HTMLFieldSetElement | null)[]>([]);\n const headingRefs = useRef<(HTMLHeadingElement | null)[]>([]);\n const moveFocus = useRef(false);\n const last = pages ? pages.length - 1 : 0;\n const paged = Boolean(pages && enhanced);\n useEffect(() => setEnhanced(true), []);\n // Focus follows the visitor to the new page's heading, never on first paint.\n useEffect(() => {\n if (!moveFocus.current) return;\n moveFocus.current = false;\n headingRefs.current[step]?.focus();\n }, [step]);\n\n // The browser's own validity, for ONE page: the first control that fails reports its message.\n function pageInvalid(i: number): boolean {\n const controls = pageRefs.current[i]?.querySelectorAll<HTMLInputElement>(\"input,select,textarea\") ?? [];\n for (const c of controls) {\n if (!c.checkValidity()) {\n c.reportValidity();\n return true;\n }\n }\n return false;\n }\n function goTo(i: number): void {\n moveFocus.current = true;\n setStep(i);\n }\n function next(): void {\n if (!pageInvalid(step)) goTo(step + 1);\n }\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\" && f.type !== \"step\" && 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 // Enter inside a field before the last page moves on rather than submitting half a form.\n if (paged && step < last) return next();\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 === \"step\") continue; // a divider is never an answer\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 setStep(0);\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) {\n setFieldErrors(e2.fieldErrors);\n // The server found a problem on a page the visitor has left: take them back to it.\n const bad = pages?.findIndex((p) => p.fields.some((f) => e2.fieldErrors?.[f.key]));\n if (bad !== undefined && bad >= 0) goTo(bad);\n }\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 {pages\n ? pages.map((page, i) => (\n <fieldset\n key={page.key ?? \"first\"}\n ref={(el) => {\n pageRefs.current[i] = el;\n }}\n className=\"bcms-step\"\n data-bcms-step={i + 1}\n hidden={paged && i !== step}\n aria-labelledby={`bcms-step-${form.id}-${i + 1}`}\n >\n <h3\n id={`bcms-step-${form.id}-${i + 1}`}\n className=\"bcms-step-title\"\n tabIndex={-1}\n ref={(el) => {\n headingRefs.current[i] = el;\n }}\n data-bcms-form-field={page.key ?? undefined}\n >\n <span className=\"bcms-step-count\">\n Step {i + 1} of {pages.length}\n </span>\n {page.label ? (\n <>\n {\" \"}\n <span data-bcms-form-part=\"label\">{page.label}</span>\n </>\n ) : null}\n </h3>\n {visibleFields\n .filter((f) => page.fields.includes(f))\n .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 {paged ? (\n <div className=\"bcms-step-nav\">\n {i > 0 ? (\n <button type=\"button\" data-bcms-step-back onClick={() => goTo(i - 1)}>\n Back\n </button>\n ) : null}\n {i < last ? (\n <button type=\"button\" data-bcms-step-next onClick={next}>\n Next\n </button>\n ) : null}\n </div>\n ) : null}\n </fieldset>\n ))\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\n type=\"submit\"\n hidden={paged && step < last}\n disabled={status.state === \"submitting\"}\n data-bcms-form-part=\"submit\"\n >\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 if (field.type === \"phone\" && field.ui?.countryPicker) {\n // The fallback is a usable tel input inside the SAME wrapper, so the host's `.bcms-phone`\n // rules apply before and after the chunk lands and the swap is not a layout surprise.\n control = (\n <Suspense\n fallback={\n <span className=\"bcms-phone\">\n <input type=\"tel\" name={field.key} placeholder={field.placeholder} required={required} value={str} onChange={(e) => onChange(e.target.value)} autoComplete=\"tel\" dir=\"ltr\" />\n </span>\n }\n >\n <PhoneField\n name={field.key}\n value={str}\n onChange={onChange}\n placeholder={field.placeholder}\n required={required}\n defaultCountry={field.ui.defaultCountry}\n />\n </Suspense>\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, which\n * `stampNodeIds` numbers as two COPIES of that one orphan (`data-node-index`) rather than two\n * fields: editing either edits nothing, on 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,EACA;AAAA,EACA,YAAAA;AAAA,OAIK;AACP,SAAS,gBAAgB,eAAe,iBAAiB,sBAAsB,YAAY,kBAAkB,YAAY,eAAe,aAAa,kBAAkB,cAAc,eAAe,iBAAiB,iBAAiB,2BAA2B;AAoBjQ,SAAS,kCAAkC;AAC3C,SAAS,sBAAsB;AAC/B,SAAS,oBAAoB;AAC7B,SAAS,yBAAyB,6BAA6B;AAC/D,SAAS,cAAc,4BAA4B;;;ACpCnD,SAAS,MAAM,UAAU,WAAW,SAAS,QAAQ,gBAAmD;AACxG;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAMK;AAuOS,SAIE,UAEE,KANJ;AArOhB,IAAM,gBAAgB;AAStB,IAAM,aAAa,KAAK,MAAM,OAAO,kBAAkB,CAAC;AAGxD,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;AAUA,SAAS,WAAW,QAA4C;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AAY;AAWxC,SAAS,qBAAqB,OAAgC;AAC5D,MAAI,CAAC,gBAAgB,IAAI,MAAM,IAAI,GAAG;AACpC,oBAAgB,IAAI,MAAM,IAAI;AAE9B,YAAQ;AAAA,MACN,4BAA4B,MAAM,IAAI;AAAA,IAExC;AAAA,EACF;AACA,SAAO;AACT;AAEA,SAAS,uBAAuB,aAAqB,KAA2B;AAC9E,MAAI,CAAC,cAAc,IAAI,WAAW,GAAG;AACnC,kBAAc,IAAI,WAAW;AAE7B,YAAQ;AAAA,MACN,2BAA2B,WAAW,4DACnC,IAAI,eAAe,SAAS,IACzB,gGACA,IAAI,IAAI,eAAe,IAAI;AAAA,IACnC;AAAA,EACF;AACA,MAAI,QAAQ,IAAI,aAAa,aAAc,QAAO;AAClD,SACE,gBAAAC;AAAA,IAAC;AAAA;AAAA,MACC,WAAU;AAAA,MACV,+BAA6B;AAAA,MAC7B,OAAO;AAAA,QACL,SAAS;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"]}
@@ -10,11 +10,11 @@ import {
10
10
  isValidElement,
11
11
  useState as useState2
12
12
  } from "react";
13
- import { RESPONSIVE_CSS, blockStyleToCss, blockStyleToInnerCss, hideOnAttr, usesHideOn, visibleBlocks, windowState, splitButtonStyle, buttonIconOf, buttonIconSvg, buttonVariantOf, headingPaintCss, withButtonLookProps } from "@bettercms-ai/types";
13
+ import { RESPONSIVE_CSS, imageFrameCss, blockStyleToCss, blockStyleToInnerCss, hideOnAttr, hiddenEverywhere, usesHideOn, visibleBlocks, windowState, splitButtonStyle, buttonIconOf, buttonIconSvg, buttonVariantOf, headingPaintCss, withButtonLookProps } from "@bettercms-ai/types";
14
14
  import { componentInstanceAddresses } from "@bettercms-ai/types";
15
15
  import { applyOverrides } from "@bettercms-ai/ui/resolve";
16
16
  import { PortableText } from "@bettercms-ai/ui/blocks";
17
- import { embeddedComponentBlock, readStructuredContent } from "@bettercms-ai/richtext";
17
+ import { embeddedComponentRender, readStructuredContent } from "@bettercms-ai/richtext";
18
18
  import { headingParts, richtextHeadingLevel } from "@bettercms-ai/richtext/heading";
19
19
 
20
20
  // src/form.tsx
@@ -471,8 +471,12 @@ function tagTopLevel(block, node) {
471
471
  function renderBlock(block, ctx) {
472
472
  const node = renderStyledBlock(block, ctx);
473
473
  const state = ctx.showScheduled && ctx.now ? windowState(block, ctx.now) : "live";
474
- if (state === "live" || !isValidElement(node)) return node;
475
- return cloneElement(node, { "data-bcms-window": state });
474
+ const hidden = !!ctx.showScheduled && hiddenEverywhere(block);
475
+ if (state === "live" && !hidden || !isValidElement(node)) return node;
476
+ return cloneElement(node, {
477
+ ...state === "live" ? {} : { "data-bcms-window": state },
478
+ ...hidden ? { "data-bcms-hidden": "all" } : {}
479
+ });
476
480
  }
477
481
  function renderStyledBlock(block, ctx) {
478
482
  const node = renderBlockInner(block, ctx);
@@ -544,8 +548,12 @@ function renderText({ id, props, style }, ctx) {
544
548
  if (structured) {
545
549
  const base = addressFor(id, "html", ctx);
546
550
  const renderEmbed = (value) => {
547
- const embed = embeddedComponentBlock(value);
548
- return embed ? renderComponent(embed, { ...ctx, owner: base }) : void 0;
551
+ const embed = embeddedComponentRender(value);
552
+ if (!embed) return void 0;
553
+ if (embed.kind === "linked") return renderComponent(embed.block, { ...ctx, owner: base });
554
+ const { copy } = embed;
555
+ const childCtx = { ...ctx, depth: ctx.depth + 1, fieldAddresses: /* @__PURE__ */ new Map(), owner: void 0 };
556
+ return /* @__PURE__ */ jsx2("div", { className: "bcms-block bcms-block--component", "data-bcms-component-copy": copy.componentId, "data-bcms-instance": copy.id, children: copy.blocks.map((child) => renderBlock(child, childCtx)) });
549
557
  };
550
558
  return /* @__PURE__ */ jsx2("div", { className: "bcms-block bcms-block--text", children: /* @__PURE__ */ jsx2(PortableText, { value: structured, ...base ? { bindingBase: base } : {}, renderBlock: renderEmbed }) }, id);
551
559
  }
@@ -559,7 +567,8 @@ function renderText({ id, props, style }, ctx) {
559
567
  id
560
568
  );
561
569
  }
562
- function renderImage({ id, props }, ctx) {
570
+ function renderImage({ id, props, style }, ctx) {
571
+ if (!String(props.src ?? "").trim()) return null;
563
572
  const img = /* @__PURE__ */ jsx2(
564
573
  "img",
565
574
  {
@@ -567,7 +576,7 @@ function renderImage({ id, props }, ctx) {
567
576
  alt: props.alt,
568
577
  width: props.width,
569
578
  height: props.height,
570
- style: props.width ? { width: `${props.width}px`, maxWidth: "100%", height: "auto" } : void 0,
579
+ style: imageFrameCss(style) ?? (props.width ? { width: `${props.width}px`, maxWidth: "100%", height: "auto" } : void 0),
571
580
  loading: "lazy",
572
581
  ...bind(id, "src", "image", ctx),
573
582
  ...bindProps(id, [{ prop: "alt", kind: "text", attr: "alt", present: props.alt != null }], ctx)
@@ -584,13 +593,21 @@ function renderImage({ id, props }, ctx) {
584
593
  function renderButton({ id, props, style }, ctx) {
585
594
  const icon = buttonIconOf(props.icon);
586
595
  const paint = splitButtonStyle(style).paint;
596
+ const className = `bcms-block bcms-block--button bcms-button--${buttonVariantOf(props.variant)}${props.size === "sm" || props.size === "lg" ? ` bcms-button--${props.size}` : ""}${props.fullWidth === true ? " bcms-button--full" : ""}`;
597
+ if (props.action === "code") {
598
+ return /* @__PURE__ */ jsxs2("button", { type: "button", style: paint, className, ...bind(id, "text", "text", ctx), children: [
599
+ icon && /* @__PURE__ */ jsx2("span", { className: "bcms-button__icon", dangerouslySetInnerHTML: { __html: buttonIconSvg(icon, "bcms-btn-icon") } }),
600
+ props.text,
601
+ props.arrow === true && /* @__PURE__ */ jsx2("span", { className: "bcms-button__arrow", dangerouslySetInnerHTML: { __html: buttonIconSvg("arrow-right", "bcms-btn-arrow") } })
602
+ ] }, id);
603
+ }
587
604
  return /* @__PURE__ */ jsxs2(
588
605
  "a",
589
606
  {
590
607
  href: props.href,
591
608
  style: paint,
592
609
  ...props.newTab === true ? { target: "_blank", rel: "noopener noreferrer" } : {},
593
- className: `bcms-block bcms-block--button bcms-button--${buttonVariantOf(props.variant)}${props.size === "sm" || props.size === "lg" ? ` bcms-button--${props.size}` : ""}${props.fullWidth === true ? " bcms-button--full" : ""}`,
610
+ className,
594
611
  ...bind(id, "text", "text", ctx),
595
612
  ...bindProps(id, [{ prop: "href", kind: "url", attr: "href", present: props.href != null }], ctx),
596
613
  children: [