@bettercms-ai/next 0.40.0 → 0.41.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -20,6 +20,13 @@ interface SectionRootBlock {
20
20
  style?: BlockStyle | Record<string, unknown> | null;
21
21
  }
22
22
  interface SectionRootAttrs {
23
+ /**
24
+ * The section's Anchor ID (`style.anchor`), present only when one is set, so a root with its own
25
+ * `id` keeps it otherwise. The section's CSS class (`style.cssClass`) is NOT spread: it would
26
+ * replace the root's own class. Read it with `sectionIdentityAttrs(block.style).className` and
27
+ * join it into the root's class list.
28
+ */
29
+ id?: string;
23
30
  "data-bcms-block"?: string;
24
31
  "data-bcms-style": "";
25
32
  /** `"mobile tablet"` when `style.hideOn` hides it there; the site ships `RESPONSIVE_CSS` for it. */
@@ -1,7 +1,7 @@
1
1
  import { ReactNode, ReactElement } from 'react';
2
2
  import { ContentBlock, DeliveryComponent } from '@bettercms-ai/types';
3
3
  import { DeliveryForm } from '@bettercms-ai/sdk';
4
- import { a as SectionRootAttrs } from './section-root-_bk8G5ry.js';
4
+ import { a as SectionRootAttrs } from './section-root-D4G89_4A.js';
5
5
 
6
6
  /**
7
7
  * <BcmsSections> — a code-built page's sections, in the order its CMS page lists them.
package/dist/sections.js CHANGED
@@ -4,12 +4,14 @@ import { CODE_SLOT_PREFIX, RESPONSIVE_CSS, planSections, usesHideOn, visibleBloc
4
4
  import { BcmsBlocks } from "./blocks.js";
5
5
 
6
6
  // src/section-root.ts
7
- import { blockStyleToColumnCss, blockStyleToCss, hideOnAttr } from "@bettercms-ai/types";
7
+ import { blockStyleToColumnCss, blockStyleToCss, hideOnAttr, sectionIdentityAttrs } from "@bettercms-ai/types";
8
8
  function sectionRootAttrs(block) {
9
9
  const css = blockStyleToCss(block?.style ?? void 0);
10
10
  const id = typeof block?.id === "string" && block.id !== "" ? block.id : void 0;
11
11
  const hide = hideOnAttr(block?.style);
12
+ const anchor = sectionIdentityAttrs(block?.style).id;
12
13
  return {
14
+ ...anchor ? { id: anchor } : {},
13
15
  ...id !== void 0 ? { "data-bcms-block": id } : {},
14
16
  "data-bcms-style": "",
15
17
  ...hide ? { "data-bcms-hide": hide } : {},
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/sections.tsx","../src/section-root.ts"],"sourcesContent":["/**\n * <BcmsSections> — a code-built page's sections, in the order its CMS page lists them.\n *\n * <BcmsSections {...sectionsFor(\"home\")}>\n * <BcmsSection bind=\"hero\"><Hero /></BcmsSection>\n * <BcmsSection bind=\"features\">{(root) => <Features rootProps={root} />}</BcmsSection>\n * </BcmsSections>\n *\n * Each section the page can draw is a `<BcmsSection>` child, named by its placement's bind: what is\n * inside is the site's own and is rendered as written. The CMS page's block list decides the rest:\n *\n * - a block bound to a section renders it at the block's position, stamped (below);\n * - a block with no bind (a section added from the library) renders through `<BcmsBlocks>`;\n * - a section no block names: `code:<bind>` always renders where the source has it; a bare `<bind>`\n * does too until the list names one of this page's sections, and from then on it is a removed one.\n *\n * With `blocks` null (a build without a snapshot) every child renders in source order, untouched.\n *\n * THE STAMP goes on the section's own root, never on a box of ours that changes layout:\n * - one DOM element (`<section>`): `data-bcms-block`, `data-bcms-style` and the block's style are\n * cloned onto it, its own style first;\n * - a function child is handed those props and puts them on its root itself: the way a COMPONENT\n * section takes its style, since a component may not pass unknown props on;\n * - a component or several children: a box of ours carries the stamp. `display:contents` while\n * the block has no style, so the page lays out as written; `display:flow-root` with the style on\n * it once the block has one, because a box that draws nothing cannot show a padding. A styled\n * box is ONE block box: in a flex or grid parent its children are one item, and their margins\n * stop collapsing with the neighbours'. The function-child form has no box and no such limit.\n *\n * Server-safe (no hooks, no \"use client\"): a Server Component in the App Router, and plain React\n * in the Pages Router, where `blocks` must come through page props so the client renders the same\n * list (`sectionsStaticProps`). Twin: BcmsSections.astro in @bettercms-ai/astro; the order is\n * `planSections` in @bettercms-ai/types.\n */\nimport { Children, Fragment, cloneElement, isValidElement, type CSSProperties, type ReactElement, type ReactNode } from \"react\";\nimport { CODE_SLOT_PREFIX, RESPONSIVE_CSS, planSections, usesHideOn, visibleBlocks, type ContentBlock, type DeliveryComponent } from \"@bettercms-ai/types\";\nimport type { DeliveryForm } from \"@bettercms-ai/sdk\";\nimport { BcmsBlocks } from \"./blocks.js\";\nimport { sectionRootAttrs, type SectionRootAttrs } from \"./section-root.js\";\n\n/** What a function child receives: spread it on the section's root element. Empty when no block places the section. */\nexport type SectionRootProps = Partial<SectionRootAttrs> & { \"data-bcms-sections\"?: string };\n\nexport interface BcmsSectionProps {\n /** The placement's bind (`hero`), or `code:<bind>` for a section the CMS did not hold when the page was wrapped. */\n bind: string;\n children: ReactNode | ((root: SectionRootProps) => ReactNode);\n}\n\nconst contentOf = (children: BcmsSectionProps[\"children\"], root: SectionRootProps): ReactNode =>\n typeof children === \"function\" ? children(root) : children;\n\n/** One section of the page. Outside `<BcmsSections>` it renders its children as they are. */\nexport function BcmsSection({ children }: BcmsSectionProps): ReactElement {\n return <>{contentOf(children, {})}</>;\n}\n\nexport interface BcmsSectionsProps {\n /** The CMS page's slug: `home`, `services`. */\n page: string;\n /** The page's block list: `sectionsFor(slug).blocks`, or a draft read. Null or absent renders the source order. */\n blocks?: ContentBlock[] | null;\n /** Component definitions and forms for the sections `<BcmsBlocks>` draws. */\n components?: DeliveryComponent[];\n forms?: DeliveryForm[];\n /** The instant block windows are read against. Defaults to the render time. */\n now?: Date;\n children?: ReactNode;\n}\n\nfunction stamped(children: BcmsSectionProps[\"children\"], block: ContentBlock, page: string): ReactNode {\n const attrs = sectionRootAttrs(block);\n if (attrs[\"data-bcms-block\"] === undefined) return contentOf(children, {});\n const root: SectionRootProps = { ...attrs, \"data-bcms-sections\": page };\n if (typeof children === \"function\") return children(root);\n const only = Children.toArray(children);\n const sole = only.length === 1 && isValidElement(only[0]) && typeof only[0].type === \"string\" ? (only[0] as ReactElement<Record<string, unknown>>) : null;\n if (sole) {\n // A root that already stamps a block is the site's own work.\n if (sole.props[\"data-bcms-block\"] !== undefined) return sole;\n // The site's declarations first, the block's after, as the in-place painter orders them.\n const style = attrs.style ? { ...(sole.props.style as CSSProperties | undefined), ...attrs.style } : sole.props.style;\n return cloneElement(sole, { ...root, style });\n }\n if (only.length === 0) return null;\n // As `stampSectionRoot` in @bettercms-ai/astro writes it, attribute for attribute.\n const box: CSSProperties = !attrs.style ? { display: \"contents\" } : attrs.style.display !== undefined ? attrs.style : { display: \"flow-root\", ...attrs.style };\n return (\n <div style={box} data-bcms-block={attrs[\"data-bcms-block\"]} data-bcms-style=\"\" data-bcms-hide={attrs[\"data-bcms-hide\"]} data-bcms-box=\"\" data-bcms-sections={page}>\n {children}\n </div>\n );\n}\n\nexport function BcmsSections({ page, blocks, components, forms, now, children }: BcmsSectionsProps): ReactElement {\n // A child that is not a <BcmsSection> is the page's too: it keeps its place, like a `code:` section.\n const slots = new Map<string, BcmsSectionProps[\"children\"]>();\n Children.toArray(children).forEach((child, n) => {\n const section = isValidElement(child) && child.type === BcmsSection ? (child.props as BcmsSectionProps) : null;\n const name = section ? section.bind : `${CODE_SLOT_PREFIX}~${n}`;\n if (!slots.has(name)) slots.set(name, section ? section.children : child);\n });\n const plan = planSections([...slots.keys()], Array.isArray(blocks) ? visibleBlocks(blocks, now ?? new Date()) : null);\n\n // Consecutive CMS blocks share one <BcmsBlocks>, so its container wraps the run once.\n const parts: Array<{ node: ReactNode } | { blocks: ContentBlock[] }> = [];\n for (const item of plan) {\n if (item.slot !== null) {\n const content = slots.get(item.slot)!;\n parts.push({ node: item.block ? stamped(content, item.block, page) : contentOf(content, {}) });\n continue;\n }\n const last = parts[parts.length - 1];\n if (last && \"blocks\" in last) last.blocks.push(item.block);\n else parts.push({ blocks: [item.block] });\n }\n // Only when a placed section hides somewhere, so a page without `hideOn` renders exactly as before.\n const hides = usesHideOn(plan.filter((item) => item.slot !== null).map((item) => item.block));\n return (\n <>\n {hides && <style dangerouslySetInnerHTML={{ __html: RESPONSIVE_CSS }} />}\n {parts.map((part, n) =>\n \"node\" in part ? (\n <Fragment key={n}>{part.node}</Fragment>\n ) : (\n <BcmsBlocks key={n} blocks={part.blocks} components={components} forms={forms} now={now} />\n ),\n )}\n </>\n );\n}\n","/**\n * C3/C4 — `sectionRootAttrs(block)`: the props a site's OWN section root spreads so the\n * BetterCMS editor offers that section's spacing and style handles.\n *\n * <section className=\"hero\" {...sectionRootAttrs(block)}>…</section>\n *\n * The editor shows those handles on a site-rendered page only when EVERY root the site stamps\n * with `data-bcms-block` also carries `data-bcms-style`, which is the site's promise that \"this\n * root's inline style is `blockStyleToCss(block.style)`\" — the same declarations `<BcmsBlocks>`\n * puts on its own wrapper. The marker is present even when the style is EMPTY (then there is no\n * `style` prop at all): an unstyled section is the one an author is about to give its first\n * spacing edit. Twin: `sectionRootAttrs` in @bettercms-ai/astro (style as a string there).\n */\nimport type { CSSProperties } from \"react\";\nimport { blockStyleToColumnCss, blockStyleToCss, hideOnAttr, type BlockStyle } from \"@bettercms-ai/types\";\n\nexport interface SectionRootBlock {\n id?: string | null;\n style?: BlockStyle | Record<string, unknown> | null;\n}\n\nexport interface SectionRootAttrs {\n \"data-bcms-block\"?: string;\n \"data-bcms-style\": \"\";\n /** `\"mobile tablet\"` when `style.hideOn` hides it there; the site ships `RESPONSIVE_CSS` for it. */\n \"data-bcms-hide\"?: string;\n /** `blockStyleToCss(block.style)`; absent when the block has no style. */\n style?: CSSProperties;\n}\n\nexport function sectionRootAttrs(block: SectionRootBlock | null | undefined): SectionRootAttrs {\n const css = blockStyleToCss((block?.style ?? undefined) as BlockStyle | undefined);\n const id = typeof block?.id === \"string\" && block.id !== \"\" ? block.id : undefined;\n const hide = hideOnAttr(block?.style);\n return {\n ...(id !== undefined ? { \"data-bcms-block\": id } : {}),\n \"data-bcms-style\": \"\",\n ...(hide ? { \"data-bcms-hide\": hide } : {}),\n ...(css ? { style: css as CSSProperties } : {}),\n };\n}\n\nexport interface SectionColumnAttrs {\n \"data-bcms-column\": \"\";\n /** `blockStyleToColumnCss(block.style)`; absent when the section has no column. */\n style?: CSSProperties;\n}\n\n/**\n * C3 — `sectionColumnAttrs(block)`: the props a site's own INNER container spreads so the section's\n * content WIDTH ships (`style.contentWidth`, placed by `contentAlign`). The column BetterCMS draws as\n * `.bcms-block-inner`, never on the root (its background stays full-bleed); `data-bcms-column` is the\n * site's promise that this box's inline style is that column. Twin: @bettercms-ai/astro.\n */\nexport function sectionColumnAttrs(block: SectionRootBlock | null | undefined): SectionColumnAttrs {\n const css = blockStyleToColumnCss((block?.style ?? undefined) as BlockStyle | undefined);\n return { \"data-bcms-column\": \"\", ...(css ? { style: css as CSSProperties } : {}) };\n}\n"],"mappings":";AAkCA,SAAS,UAAU,UAAU,cAAc,sBAA6E;AACxH,SAAS,kBAAkB,gBAAgB,cAAc,YAAY,qBAAgE;AAErI,SAAS,kBAAkB;;;ACvB3B,SAAS,uBAAuB,iBAAiB,kBAAmC;AAgB7E,SAAS,iBAAiB,OAA8D;AAC7F,QAAM,MAAM,gBAAiB,OAAO,SAAS,MAAoC;AACjF,QAAM,KAAK,OAAO,OAAO,OAAO,YAAY,MAAM,OAAO,KAAK,MAAM,KAAK;AACzE,QAAM,OAAO,WAAW,OAAO,KAAK;AACpC,SAAO;AAAA,IACL,GAAI,OAAO,SAAY,EAAE,mBAAmB,GAAG,IAAI,CAAC;AAAA,IACpD,mBAAmB;AAAA,IACnB,GAAI,OAAO,EAAE,kBAAkB,KAAK,IAAI,CAAC;AAAA,IACzC,GAAI,MAAM,EAAE,OAAO,IAAqB,IAAI,CAAC;AAAA,EAC/C;AACF;;;ADcS,qBAAAA,WAAA,KAiEL,YAjEK;AALT,IAAM,YAAY,CAAC,UAAwC,SACzD,OAAO,aAAa,aAAa,SAAS,IAAI,IAAI;AAG7C,SAAS,YAAY,EAAE,SAAS,GAAmC;AACxE,SAAO,oBAAAA,WAAA,EAAG,oBAAU,UAAU,CAAC,CAAC,GAAE;AACpC;AAeA,SAAS,QAAQ,UAAwC,OAAqB,MAAyB;AACrG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AAM,IAAI,IAAI,EAAG,OAAM,IAAI,MAAM,UAAU,QAAQ,WAAW,KAAK;AAAA,EAC1E,CAAC;AACD,QAAM,OAAO,aAAa,CAAC,GAAG,MAAM,KAAK,CAAC,GAAG,MAAM,QAAQ,MAAM,IAAI,cAAc,QAAQ,OAAO,oBAAI,KAAK,CAAC,IAAI,IAAI;AAGpH,QAAM,QAAiE,CAAC;AACxE,aAAW,QAAQ,MAAM;AACvB,QAAI,KAAK,SAAS,MAAM;AACtB,YAAM,UAAU,MAAM,IAAI,KAAK,IAAI;AACnC,YAAM,KAAK,EAAE,MAAM,KAAK,QAAQ,QAAQ,SAAS,KAAK,OAAO,IAAI,IAAI,UAAU,SAAS,CAAC,CAAC,EAAE,CAAC;AAC7F;AAAA,IACF;AACA,UAAM,OAAO,MAAM,MAAM,SAAS,CAAC;AACnC,QAAI,QAAQ,YAAY,KAAM,MAAK,OAAO,KAAK,KAAK,KAAK;AAAA,QACpD,OAAM,KAAK,EAAE,QAAQ,CAAC,KAAK,KAAK,EAAE,CAAC;AAAA,EAC1C;AAEA,QAAM,QAAQ,WAAW,KAAK,OAAO,CAAC,SAAS,KAAK,SAAS,IAAI,EAAE,IAAI,CAAC,SAAS,KAAK,KAAK,CAAC;AAC5F,SACE,qBAAAA,WAAA,EACG;AAAA,aAAS,oBAAC,WAAM,yBAAyB,EAAE,QAAQ,eAAe,GAAG;AAAA,IACrE,MAAM;AAAA,MAAI,CAAC,MAAM,MAChB,UAAU,OACR,oBAAC,YAAkB,eAAK,QAAT,CAAc,IAE7B,oBAAC,cAAmB,QAAQ,KAAK,QAAQ,YAAwB,OAAc,OAA9D,CAAwE;AAAA,IAE7F;AAAA,KACF;AAEJ;","names":["Fragment"]}
1
+ {"version":3,"sources":["../src/sections.tsx","../src/section-root.ts"],"sourcesContent":["/**\n * <BcmsSections> — a code-built page's sections, in the order its CMS page lists them.\n *\n * <BcmsSections {...sectionsFor(\"home\")}>\n * <BcmsSection bind=\"hero\"><Hero /></BcmsSection>\n * <BcmsSection bind=\"features\">{(root) => <Features rootProps={root} />}</BcmsSection>\n * </BcmsSections>\n *\n * Each section the page can draw is a `<BcmsSection>` child, named by its placement's bind: what is\n * inside is the site's own and is rendered as written. The CMS page's block list decides the rest:\n *\n * - a block bound to a section renders it at the block's position, stamped (below);\n * - a block with no bind (a section added from the library) renders through `<BcmsBlocks>`;\n * - a section no block names: `code:<bind>` always renders where the source has it; a bare `<bind>`\n * does too until the list names one of this page's sections, and from then on it is a removed one.\n *\n * With `blocks` null (a build without a snapshot) every child renders in source order, untouched.\n *\n * THE STAMP goes on the section's own root, never on a box of ours that changes layout:\n * - one DOM element (`<section>`): `data-bcms-block`, `data-bcms-style` and the block's style are\n * cloned onto it, its own style first;\n * - a function child is handed those props and puts them on its root itself: the way a COMPONENT\n * section takes its style, since a component may not pass unknown props on;\n * - a component or several children: a box of ours carries the stamp. `display:contents` while\n * the block has no style, so the page lays out as written; `display:flow-root` with the style on\n * it once the block has one, because a box that draws nothing cannot show a padding. A styled\n * box is ONE block box: in a flex or grid parent its children are one item, and their margins\n * stop collapsing with the neighbours'. The function-child form has no box and no such limit.\n *\n * Server-safe (no hooks, no \"use client\"): a Server Component in the App Router, and plain React\n * in the Pages Router, where `blocks` must come through page props so the client renders the same\n * list (`sectionsStaticProps`). Twin: BcmsSections.astro in @bettercms-ai/astro; the order is\n * `planSections` in @bettercms-ai/types.\n */\nimport { Children, Fragment, cloneElement, isValidElement, type CSSProperties, type ReactElement, type ReactNode } from \"react\";\nimport { CODE_SLOT_PREFIX, RESPONSIVE_CSS, planSections, usesHideOn, visibleBlocks, type ContentBlock, type DeliveryComponent } from \"@bettercms-ai/types\";\nimport type { DeliveryForm } from \"@bettercms-ai/sdk\";\nimport { BcmsBlocks } from \"./blocks.js\";\nimport { sectionRootAttrs, type SectionRootAttrs } from \"./section-root.js\";\n\n/** What a function child receives: spread it on the section's root element. Empty when no block places the section. */\nexport type SectionRootProps = Partial<SectionRootAttrs> & { \"data-bcms-sections\"?: string };\n\nexport interface BcmsSectionProps {\n /** The placement's bind (`hero`), or `code:<bind>` for a section the CMS did not hold when the page was wrapped. */\n bind: string;\n children: ReactNode | ((root: SectionRootProps) => ReactNode);\n}\n\nconst contentOf = (children: BcmsSectionProps[\"children\"], root: SectionRootProps): ReactNode =>\n typeof children === \"function\" ? children(root) : children;\n\n/** One section of the page. Outside `<BcmsSections>` it renders its children as they are. */\nexport function BcmsSection({ children }: BcmsSectionProps): ReactElement {\n return <>{contentOf(children, {})}</>;\n}\n\nexport interface BcmsSectionsProps {\n /** The CMS page's slug: `home`, `services`. */\n page: string;\n /** The page's block list: `sectionsFor(slug).blocks`, or a draft read. Null or absent renders the source order. */\n blocks?: ContentBlock[] | null;\n /** Component definitions and forms for the sections `<BcmsBlocks>` draws. */\n components?: DeliveryComponent[];\n forms?: DeliveryForm[];\n /** The instant block windows are read against. Defaults to the render time. */\n now?: Date;\n children?: ReactNode;\n}\n\nfunction stamped(children: BcmsSectionProps[\"children\"], block: ContentBlock, page: string): ReactNode {\n const attrs = sectionRootAttrs(block);\n if (attrs[\"data-bcms-block\"] === undefined) return contentOf(children, {});\n const root: SectionRootProps = { ...attrs, \"data-bcms-sections\": page };\n if (typeof children === \"function\") return children(root);\n const only = Children.toArray(children);\n const sole = only.length === 1 && isValidElement(only[0]) && typeof only[0].type === \"string\" ? (only[0] as ReactElement<Record<string, unknown>>) : null;\n if (sole) {\n // A root that already stamps a block is the site's own work.\n if (sole.props[\"data-bcms-block\"] !== undefined) return sole;\n // The site's declarations first, the block's after, as the in-place painter orders them.\n const style = attrs.style ? { ...(sole.props.style as CSSProperties | undefined), ...attrs.style } : sole.props.style;\n return cloneElement(sole, { ...root, style });\n }\n if (only.length === 0) return null;\n // As `stampSectionRoot` in @bettercms-ai/astro writes it, attribute for attribute.\n const box: CSSProperties = !attrs.style ? { display: \"contents\" } : attrs.style.display !== undefined ? attrs.style : { display: \"flow-root\", ...attrs.style };\n return (\n <div style={box} data-bcms-block={attrs[\"data-bcms-block\"]} data-bcms-style=\"\" data-bcms-hide={attrs[\"data-bcms-hide\"]} data-bcms-box=\"\" data-bcms-sections={page}>\n {children}\n </div>\n );\n}\n\nexport function BcmsSections({ page, blocks, components, forms, now, children }: BcmsSectionsProps): ReactElement {\n // A child that is not a <BcmsSection> is the page's too: it keeps its place, like a `code:` section.\n const slots = new Map<string, BcmsSectionProps[\"children\"]>();\n Children.toArray(children).forEach((child, n) => {\n const section = isValidElement(child) && child.type === BcmsSection ? (child.props as BcmsSectionProps) : null;\n const name = section ? section.bind : `${CODE_SLOT_PREFIX}~${n}`;\n if (!slots.has(name)) slots.set(name, section ? section.children : child);\n });\n const plan = planSections([...slots.keys()], Array.isArray(blocks) ? visibleBlocks(blocks, now ?? new Date()) : null);\n\n // Consecutive CMS blocks share one <BcmsBlocks>, so its container wraps the run once.\n const parts: Array<{ node: ReactNode } | { blocks: ContentBlock[] }> = [];\n for (const item of plan) {\n if (item.slot !== null) {\n const content = slots.get(item.slot)!;\n parts.push({ node: item.block ? stamped(content, item.block, page) : contentOf(content, {}) });\n continue;\n }\n const last = parts[parts.length - 1];\n if (last && \"blocks\" in last) last.blocks.push(item.block);\n else parts.push({ blocks: [item.block] });\n }\n // Only when a placed section hides somewhere, so a page without `hideOn` renders exactly as before.\n const hides = usesHideOn(plan.filter((item) => item.slot !== null).map((item) => item.block));\n return (\n <>\n {hides && <style dangerouslySetInnerHTML={{ __html: RESPONSIVE_CSS }} />}\n {parts.map((part, n) =>\n \"node\" in part ? (\n <Fragment key={n}>{part.node}</Fragment>\n ) : (\n <BcmsBlocks key={n} blocks={part.blocks} components={components} forms={forms} now={now} />\n ),\n )}\n </>\n );\n}\n","/**\n * C3/C4 — `sectionRootAttrs(block)`: the props a site's OWN section root spreads so the\n * BetterCMS editor offers that section's spacing and style handles.\n *\n * <section className=\"hero\" {...sectionRootAttrs(block)}>…</section>\n *\n * The editor shows those handles on a site-rendered page only when EVERY root the site stamps\n * with `data-bcms-block` also carries `data-bcms-style`, which is the site's promise that \"this\n * root's inline style is `blockStyleToCss(block.style)`\" — the same declarations `<BcmsBlocks>`\n * puts on its own wrapper. The marker is present even when the style is EMPTY (then there is no\n * `style` prop at all): an unstyled section is the one an author is about to give its first\n * spacing edit. Twin: `sectionRootAttrs` in @bettercms-ai/astro (style as a string there).\n */\nimport type { CSSProperties } from \"react\";\nimport { blockStyleToColumnCss, blockStyleToCss, hideOnAttr, sectionIdentityAttrs, type BlockStyle } from \"@bettercms-ai/types\";\n\nexport interface SectionRootBlock {\n id?: string | null;\n style?: BlockStyle | Record<string, unknown> | null;\n}\n\nexport interface SectionRootAttrs {\n /**\n * The section's Anchor ID (`style.anchor`), present only when one is set, so a root with its own\n * `id` keeps it otherwise. The section's CSS class (`style.cssClass`) is NOT spread: it would\n * replace the root's own class. Read it with `sectionIdentityAttrs(block.style).className` and\n * join it into the root's class list.\n */\n id?: string;\n \"data-bcms-block\"?: string;\n \"data-bcms-style\": \"\";\n /** `\"mobile tablet\"` when `style.hideOn` hides it there; the site ships `RESPONSIVE_CSS` for it. */\n \"data-bcms-hide\"?: string;\n /** `blockStyleToCss(block.style)`; absent when the block has no style. */\n style?: CSSProperties;\n}\n\nexport function sectionRootAttrs(block: SectionRootBlock | null | undefined): SectionRootAttrs {\n const css = blockStyleToCss((block?.style ?? undefined) as BlockStyle | undefined);\n const id = typeof block?.id === \"string\" && block.id !== \"\" ? block.id : undefined;\n const hide = hideOnAttr(block?.style);\n const anchor = sectionIdentityAttrs(block?.style).id;\n return {\n ...(anchor ? { id: anchor } : {}),\n ...(id !== undefined ? { \"data-bcms-block\": id } : {}),\n \"data-bcms-style\": \"\",\n ...(hide ? { \"data-bcms-hide\": hide } : {}),\n ...(css ? { style: css as CSSProperties } : {}),\n };\n}\n\nexport interface SectionColumnAttrs {\n \"data-bcms-column\": \"\";\n /** `blockStyleToColumnCss(block.style)`; absent when the section has no column. */\n style?: CSSProperties;\n}\n\n/**\n * C3 — `sectionColumnAttrs(block)`: the props a site's own INNER container spreads so the section's\n * content WIDTH ships (`style.contentWidth`, placed by `contentAlign`). The column BetterCMS draws as\n * `.bcms-block-inner`, never on the root (its background stays full-bleed); `data-bcms-column` is the\n * site's promise that this box's inline style is that column. Twin: @bettercms-ai/astro.\n */\nexport function sectionColumnAttrs(block: SectionRootBlock | null | undefined): SectionColumnAttrs {\n const css = blockStyleToColumnCss((block?.style ?? undefined) as BlockStyle | undefined);\n return { \"data-bcms-column\": \"\", ...(css ? { style: css as CSSProperties } : {}) };\n}\n"],"mappings":";AAkCA,SAAS,UAAU,UAAU,cAAc,sBAA6E;AACxH,SAAS,kBAAkB,gBAAgB,cAAc,YAAY,qBAAgE;AAErI,SAAS,kBAAkB;;;ACvB3B,SAAS,uBAAuB,iBAAiB,YAAY,4BAA6C;AAuBnG,SAAS,iBAAiB,OAA8D;AAC7F,QAAM,MAAM,gBAAiB,OAAO,SAAS,MAAoC;AACjF,QAAM,KAAK,OAAO,OAAO,OAAO,YAAY,MAAM,OAAO,KAAK,MAAM,KAAK;AACzE,QAAM,OAAO,WAAW,OAAO,KAAK;AACpC,QAAM,SAAS,qBAAqB,OAAO,KAAK,EAAE;AAClD,SAAO;AAAA,IACL,GAAI,SAAS,EAAE,IAAI,OAAO,IAAI,CAAC;AAAA,IAC/B,GAAI,OAAO,SAAY,EAAE,mBAAmB,GAAG,IAAI,CAAC;AAAA,IACpD,mBAAmB;AAAA,IACnB,GAAI,OAAO,EAAE,kBAAkB,KAAK,IAAI,CAAC;AAAA,IACzC,GAAI,MAAM,EAAE,OAAO,IAAqB,IAAI,CAAC;AAAA,EAC/C;AACF;;;ADKS,qBAAAA,WAAA,KAiEL,YAjEK;AALT,IAAM,YAAY,CAAC,UAAwC,SACzD,OAAO,aAAa,aAAa,SAAS,IAAI,IAAI;AAG7C,SAAS,YAAY,EAAE,SAAS,GAAmC;AACxE,SAAO,oBAAAA,WAAA,EAAG,oBAAU,UAAU,CAAC,CAAC,GAAE;AACpC;AAeA,SAAS,QA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MS adapter for Next.js — typed, cache-aware content reads (getEntry/listEntries), draft preview, build-time content snapshot, and llms.txt generation for the App Router. The /blocks, /form, /field, /search and /visual-editing entries are framework-free React and work in any React app (see the React+TS starter), which is why `next` is an OPTIONAL peer.",
6
6
  "bin": {
@@ -74,17 +74,17 @@
74
74
  ],
75
75
  "scripts": {
76
76
  "typecheck": "tsc --noEmit",
77
- "build": "tsup",
77
+ "build": "node -e \"require('fs').rmSync('dist',{recursive:true,force:true})\" && tsup",
78
78
  "test": "vitest run",
79
79
  "test:watch": "vitest"
80
80
  },
81
81
  "dependencies": {
82
82
  "@bettercms-ai/icons": "^0.4.0",
83
- "@bettercms-ai/image-url": "^0.4.0",
84
- "@bettercms-ai/richtext": "^0.19.0",
85
- "@bettercms-ai/sdk": "^1.43.0",
86
- "@bettercms-ai/types": "^1.67.0",
87
- "@bettercms-ai/ui": "^0.27.1",
83
+ "@bettercms-ai/image-url": "^0.5.0",
84
+ "@bettercms-ai/richtext": "^0.20.0",
85
+ "@bettercms-ai/sdk": "^1.44.0",
86
+ "@bettercms-ai/types": "^1.68.0",
87
+ "@bettercms-ai/ui": "^0.28.0",
88
88
  "react-phone-number-input": "^3.4.18"
89
89
  },
90
90
  "peerDependencies": {